diff --git a/native/.clang-format b/native/.clang-format index 9f238f2ae8..0d68186e73 100644 --- a/native/.clang-format +++ b/native/.clang-format @@ -16,3 +16,9 @@ SpacesBeforeTrailingComments: 1 ObjCBlockIndentWidth: 4 ObjCSpaceAfterProperty: true + +--- +Language: Cpp +# Force pointers to the type for C++. +DerivePointerAlignment: false +PointerAlignment: Right \ No newline at end of file diff --git a/native/.github/workflows/compile-platforms.yml b/native/.github/workflows/compile-platforms.yml index a7bfb1549b..29aafc637f 100644 --- a/native/.github/workflows/compile-platforms.yml +++ b/native/.github/workflows/compile-platforms.yml @@ -139,6 +139,7 @@ jobs: touch build-mac/proj/cfg.cmake echo "set(CC_USE_VULKAN OFF)" >> build-mac/proj/cfg.cmake echo "set(CC_USE_GLES2 OFF)" >> build-mac/proj/cfg.cmake + echo "set(CC_USE_GLES3 OFF)" >> build-mac/proj/cfg.cmake echo "set(CC_USE_METAL ON)" >> build-mac/proj/cfg.cmake echo "set(USE_WEBSOCKET_SERVER OFF)" >> build-mac/proj/cfg.cmake echo "set(CMAKE_CXX_STANDARD_REQUIRED ON)" >> build-mac/proj/cfg.cmake @@ -146,7 +147,7 @@ jobs: RES_DIR=$COCOS2DX_ROOT/templates/mac/build-mac cd build-mac - cmake ../ -GXcode -DCC_USE_GLES3=ON -DCMAKE_OSX_ARCHITECTURES=x86_64 -DRES_DIR=$RES_DIR -DCOCOS_X_PATH=$COCOS2DX_ROOT + cmake ../ -GXcode -DCMAKE_OSX_ARCHITECTURES=x86_64 -DRES_DIR=$RES_DIR -DCOCOS_X_PATH=$COCOS2DX_ROOT set +e cmake --build . --config Release -- -quiet -jobs $NUM_OF_CORES -arch x86_64 retcode=$? @@ -162,7 +163,7 @@ jobs: cd .. mkdir build-mac-apple-silicon cd build-mac-apple-silicon - cmake ../ -GXcode -DCC_USE_GLES3=OFF -DCMAKE_OSX_ARCHITECTURES=arm64 -DRES_DIR=$RES_DIR -DCOCOS_X_PATH=$COCOS2DX_ROOT + cmake ../ -GXcode -DCMAKE_OSX_ARCHITECTURES=arm64 -DRES_DIR=$RES_DIR -DCOCOS_X_PATH=$COCOS2DX_ROOT cmake --build . --config Release -- -quiet -jobs $NUM_OF_CORES -arch arm64 echo "Compile MacOSX ARM64 Release Done!" diff --git a/native/.github/workflows/linter-android.yml b/native/.github/workflows/linter-android.yml index 6fa43b93d1..809d3d8fc3 100644 --- a/native/.github/workflows/linter-android.yml +++ b/native/.github/workflows/linter-android.yml @@ -54,6 +54,9 @@ jobs: - exclude: 'cocos/base/etc1.*' - exclude: 'cocos/base/etc2.*' - exclude: 'cocos/bindings/manual/jsb_global.cpp' + - exclude: 'cocos/bindings/manual/jsb_dragonbones_manual.cpp' + - exclude: 'cocos/bindings/manual/jsb_spine_manual.cpp' + - exclude: 'cocos/bindings/manual/jsb_socketio.cpp' - exclude: 'cocos/bindings/manual/jsb_conversions.*' - exclude: 'cocos/bindings/jswrapper/v8/debugger/**' - exclude: 'cocos/audio/android/audio_utils/**' diff --git a/native/.github/workflows/unit-test.yml b/native/.github/workflows/unit-test.yml index 7adf4ab48d..12f2d30129 100644 --- a/native/.github/workflows/unit-test.yml +++ b/native/.github/workflows/unit-test.yml @@ -30,9 +30,10 @@ jobs: cmake -B tests/unit-test/build -S tests/unit-test -G"Visual Studio 16 2019" -A win32 cmake --build tests/unit-test/build --config Release ./tests/unit-test/build/src/Release/CocosTest.exe - - - name: Run Module Tests - shell: bash - run: | - cd tests/module-tests - bash run-test-windows.sh + + #### TODO(PatriceJiang): model split + # - name: Run Module Tests + # shell: bash + # run: | + # cd tests/module-tests + # bash run-test-windows.sh diff --git a/native/.gitignore b/native/.gitignore index 2e4a2c25ef..fdf94cab7c 100644 --- a/native/.gitignore +++ b/native/.gitignore @@ -55,6 +55,8 @@ bin/ obj/ gen/ assets/ +!/cocos/core/assets +!/cocos/3d/assets local.properties # Ignore python compiled files diff --git a/native/CMakeLists.txt b/native/CMakeLists.txt index c7dcf6c24d..937bb26557 100644 --- a/native/CMakeLists.txt +++ b/native/CMakeLists.txt @@ -283,10 +283,9 @@ endif() ##### base cocos_source_files( cocos/base/Agent.h + cocos/base/Any.h cocos/base/astc.cpp cocos/base/astc.h - cocos/base/AutoreleasePool.cpp - cocos/base/AutoreleasePool.h cocos/base/base64.cpp cocos/base/base64.h cocos/base/CachedArray.h @@ -294,6 +293,8 @@ cocos_source_files( cocos/base/CoreStd.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 @@ -303,9 +304,11 @@ cocos_source_files( cocos/base/Macros.h cocos/base/Map.h cocos/base/Object.h + cocos/base/Optional.h + cocos/base/Ptr.h cocos/base/Random.h - cocos/base/Ref.cpp - cocos/base/Ref.h + cocos/base/RefCounted.cpp + cocos/base/RefCounted.h cocos/base/Scheduler.cpp cocos/base/Scheduler.h cocos/base/StringHandle.cpp @@ -316,6 +319,7 @@ cocos_source_files( cocos/base/ThreadPool.cpp cocos/base/ThreadPool.h cocos/base/TypeDef.h + cocos/base/Variant.h cocos/base/Vector.h ) @@ -528,37 +532,37 @@ elseif(OHOS) ) elseif(MACOSX) cocos_source_files( - 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/Screen.mm - cocos/platform/mac/modules/Screen.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 - cocos/platform/mac/modules/SystemWindow.mm - cocos/platform/mac/modules/SystemWindow.h + 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 + NO_WERROR cocos/platform/mac/modules/Screen.mm + cocos/platform/mac/modules/Screen.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 + cocos/platform/mac/modules/SystemWindow.mm + cocos/platform/mac/modules/SystemWindow.h ) elseif(IOS) cocos_source_files( - cocos/platform/ios/modules/Accelerometer.mm - cocos/platform/ios/modules/Accelerometer.h - cocos/platform/ios/modules/Battery.mm - cocos/platform/ios/modules/Battery.h - 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 + NO_WERROR 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 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( @@ -686,8 +690,12 @@ 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 @@ -920,6 +928,17 @@ 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 @@ -1107,6 +1126,8 @@ cocos_source_files( 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 @@ -1124,48 +1145,51 @@ cocos_source_files( cocos/renderer/pipeline/deferred/PostProcessStage.h cocos/renderer/pipeline/UIPhase.cpp cocos/renderer/pipeline/UIPhase.h - - cocos/renderer/pipeline/helper/DefineMap.h - cocos/renderer/pipeline/helper/DefineMap.cpp - cocos/renderer/pipeline/helper/Utils.h cocos/renderer/pipeline/GeometryRenderer.h cocos/renderer/pipeline/GeometryRenderer.cpp + cocos/renderer/pipeline/helper/Utils.h + cocos/renderer/pipeline/helper/Utils.cpp ) +##### 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/AABB.h - cocos/scene/AABB.cpp - cocos/scene/BakedSkinningModel.h - cocos/scene/BakedSkinningModel.cpp + 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/Frustum.h - cocos/scene/Frustum.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/MorphModel.h - cocos/scene/BaseNode.h - cocos/scene/BaseNode.cpp - cocos/scene/Node.h - cocos/scene/Node.cpp - cocos/scene/Scene.h - cocos/scene/Scene.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/SkinningModel.h - cocos/scene/SkinningModel.cpp - cocos/scene/Sphere.h - cocos/scene/Sphere.cpp + cocos/scene/Skybox.h + cocos/scene/Skybox.cpp cocos/scene/SphereLight.h cocos/scene/SphereLight.cpp cocos/scene/SpotLight.h @@ -1174,8 +1198,75 @@ cocos_source_files( 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 +) + +##### 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 @@ -1480,20 +1571,310 @@ if(USE_PHYSICS_PHYSX) 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/framework/UITransform.h +# cocos/2d/framework/UITransform.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/CoreModuleHeader.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/CachedArray.cpp + 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 + + # 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/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/event/EventModuleHeader.h + cocos/core/event/EventTarget.cpp + cocos/core/event/EventTarget.h + cocos/core/event/EventTargetFactory.cpp + cocos/core/event/EventTargetFactory.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 + +) + +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/Triangle.cpp + cocos/core/geometry/Triangle.h + +) + ##### script bindings ######## dop cocos_source_files( NO_WERROR cocos/bindings/dop/BufferPool.cpp - cocos/bindings/dop/BufferPool.h + cocos/bindings/dop/BufferPool.h NO_WERROR cocos/bindings/dop/jsb_dop.cpp - cocos/bindings/dop/jsb_dop.h - cocos/bindings/dop/PoolType.h - cocos/bindings/dop/BufferAllocator.h + cocos/bindings/dop/jsb_dop.h + cocos/bindings/dop/PoolType.h + cocos/bindings/dop/BufferAllocator.h NO_WERROR cocos/bindings/dop/BufferAllocator.cpp ) @@ -1511,6 +1892,10 @@ cocos_source_files( cocos/bindings/auto/jsb_pipeline_auto.h NO_WERROR cocos/bindings/auto/jsb_scene_auto.cpp cocos/bindings/auto/jsb_scene_auto.h + NO_WERROR cocos/bindings/auto/jsb_assets_auto.cpp + cocos/bindings/auto/jsb_assets_auto.h + NO_WERROR cocos/bindings/auto/jsb_geometry_auto.cpp + cocos/bindings/auto/jsb_geometry_auto.h ) if(USE_AUDIO) @@ -1551,8 +1936,11 @@ if(USE_MIDDLEWARE) cocos/editor-support/SharedBufferManager.h cocos/editor-support/TypedArrayPool.cpp cocos/editor-support/TypedArrayPool.h + ) + + cocos_source_files( NO_WERROR cocos/bindings/auto/jsb_editor_support_auto.cpp - cocos/bindings/auto/jsb_editor_support_auto.h + cocos/bindings/auto/jsb_editor_support_auto.h ) if(USE_SPINE) @@ -1719,10 +2107,13 @@ if(USE_MIDDLEWARE) 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 - 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 + + ) + 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() @@ -1812,10 +2203,13 @@ if(USE_MIDDLEWARE) 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 + cocos/bindings/auto/jsb_dragonbones_auto.h NO_WERROR cocos/bindings/manual/jsb_dragonbones_manual.cpp - cocos/bindings/manual/jsb_dragonbones_manual.h + cocos/bindings/manual/jsb_dragonbones_manual.h ) endif() endif() @@ -1828,8 +2222,9 @@ cocos_source_files( #cocos/bindings/manual/jsb_extension_manual.h NO_WERROR cocos/bindings/manual/jsb_cocos_manual.cpp cocos/bindings/manual/jsb_cocos_manual.h - NO_WERROR cocos/bindings/manual/jsb_conversions.cpp cocos/bindings/manual/jsb_conversions.h + NO_WERROR cocos/bindings/manual/jsb_conversions_spec.cpp + cocos/bindings/manual/jsb_conversions_spec.h NO_WERROR cocos/bindings/manual/jsb_gfx_manual.cpp cocos/bindings/manual/jsb_gfx_manual.h NO_WERROR cocos/bindings/manual/jsb_global.cpp @@ -1840,8 +2235,9 @@ cocos_source_files( NO_WERROR cocos/bindings/manual/jsb_module_register.cpp cocos/bindings/manual/jsb_platform.h NO_WERROR cocos/bindings/manual/jsb_scene_manual.cpp - NO_WERROR cocos/bindings/manual/jsb_scene_manual_ext.cpp cocos/bindings/manual/jsb_scene_manual.h + NO_WERROR cocos/bindings/manual/jsb_assets_manual.cpp + cocos/bindings/manual/jsb_assets_manual.h NO_WERROR cocos/bindings/manual/jsb_network_manual.cpp cocos/bindings/manual/jsb_network_manual.h NO_WERROR cocos/bindings/manual/jsb_xmlhttprequest.cpp @@ -1912,7 +2308,7 @@ if(USE_SE_V8) cocos/bindings/jswrapper/v8/Object.h cocos/bindings/jswrapper/v8/ObjectWrap.cpp cocos/bindings/jswrapper/v8/ObjectWrap.h - cocos/bindings/jswrapper/v8/ScriptEngine.cpp + NO_WERROR cocos/bindings/jswrapper/v8/ScriptEngine.cpp cocos/bindings/jswrapper/v8/ScriptEngine.h cocos/bindings/jswrapper/v8/SeApi.h NO_WERROR cocos/bindings/jswrapper/v8/Utils.cpp @@ -1985,10 +2381,16 @@ cocos_source_files(MODULE ccbindings 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( NO_WERROR cocos/bindings/manual/jsb_global_init.cpp - cocos/bindings/manual/jsb_global_init.h + cocos/bindings/manual/jsb_global_init.h ) cocos_source_files( @@ -2073,7 +2475,7 @@ elseif(MACOSX) elseif(IOS) if(USE_EDIT_BOX) cocos_source_files( - NO_WERROR cocos/ui/edit-box/EditBox-ios.mm + NO_WERROR cocos/ui/edit-box/EditBox-ios.mm ) endif() if(USE_VIDEO) @@ -2125,6 +2527,70 @@ cocos_source_files( list(APPEND COCOS2D_SOURCE_LIST ${CC_EXTERNAL_SOURCES}) +### generate source files + + +macro(compile_ts file_without_ext) + add_custom_command( + OUTPUT ${file_without_ext}.js + COMMAND ${TSC_EXECUTABLE} --module commonjs ${file_without_ext}.ts + DEPENDS ${file_without_ext}.ts + VERBATIM USES_TERMINAL + ) +endmacro() + +compile_ts(${CWD}/cocos/core/builtin/effects) +compile_ts(${CWD}/cocos/core/builtin/shader-sources/glsl1) +compile_ts(${CWD}/cocos/core/builtin/shader-sources/glsl3) +compile_ts(${CWD}/cocos/core/builtin/shader-sources/glsl4) + +set(CC_GENERATED_FILES + ${CWD}/cocos/core/builtin/Effects.cpp + ${CWD}/cocos/core/builtin/shader-sources/glsl1.cpp + ${CWD}/cocos/core/builtin/shader-sources/glsl3.cpp + ${CWD}/cocos/core/builtin/shader-sources/glsl4.cpp +) + +add_custom_target(builtin-res + COMMAND ${CMAKE_COMMAND} -E echo "Generate builtin resources ..." + COMMAND ${NODE_EXECUTABLE} ${CWD}/cmake/scripts/glsl_gzip.js + ${CWD}/cocos/core/builtin/shader-sources/glsl1.js + glsl1 + ${CWD}/cocos/core/builtin/shader-sources/glsl1.cpp.in + ${CWD}/cocos/core/builtin/shader-sources/glsl1.cpp + COMMAND ${NODE_EXECUTABLE} ${CWD}/cmake/scripts/glsl_gzip.js + ${CWD}/cocos/core/builtin/shader-sources/glsl3.js + glsl3 + ${CWD}/cocos/core/builtin/shader-sources/glsl3.cpp.in + ${CWD}/cocos/core/builtin/shader-sources/glsl3.cpp + COMMAND ${NODE_EXECUTABLE} ${CWD}/cmake/scripts/glsl_gzip.js + ${CWD}/cocos/core/builtin/shader-sources/glsl4.js + glsl4 + ${CWD}/cocos/core/builtin/shader-sources/glsl4.cpp.in + ${CWD}/cocos/core/builtin/shader-sources/glsl4.cpp + COMMAND ${NODE_EXECUTABLE} ${CWD}/cmake/scripts/effects_gzip.js + ${CWD}/cocos/core/builtin/effects.js + effects + ${CWD}/cocos/core/builtin/Effects.cpp.in + ${CWD}/cocos/core/builtin/Effects.cpp + DEPENDS + ${CWD}/cocos/core/builtin/shader-sources/glsl1.js + ${CWD}/cocos/core/builtin/shader-sources/glsl3.js + ${CWD}/cocos/core/builtin/shader-sources/glsl4.js + ${CWD}/cocos/core/builtin/shader-sources/glsl1.cpp.in + ${CWD}/cocos/core/builtin/shader-sources/glsl3.cpp.in + ${CWD}/cocos/core/builtin/shader-sources/glsl4.cpp.in + ${CWD}/cocos/core/builtin/effects.js + ${CWD}/cocos/core/builtin/Effects.cpp.in + ${CWD}/cmake/scripts/glsl_gzip.js + ${CWD}/cmake/scripts/effects_gzip.js + VERBATIM USES_TERMINAL +) +set_target_properties(builtin-res PROPERTIES FOLDER Utils) + + +list(APPEND COCOS2D_SOURCE_LIST ${CC_GENERATED_FILES}) + if(USE_MODULES) add_library(ccmath ${ccmath_SOURCE_LIST}) add_library(cclog ${cclog_SOURCE_LIST}) @@ -2132,10 +2598,14 @@ if(USE_MODULES) 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 @@ -2174,6 +2644,9 @@ if(USE_MODULES) ${se_libs_name} uv ) + target_link_libraries(ccgeometry PUBLIC + ccmath + ) if(ANDROID) target_link_libraries(ccmath PUBLIC android_platform @@ -2201,6 +2674,7 @@ if(USE_MODULES) else() list(APPEND COCOS2D_SOURCE_LIST ${ccmath_SOURCE_LIST} + ${ccgeometry_SOURCE_LIST} ${cclog_SOURCE_LIST} ${ccfilesystem_SOURCE_LIST} ${ccunzip_SOURCE_LIST} @@ -2231,6 +2705,7 @@ if(ANDROID OR OHOS) target_include_directories(cocos2d_jni PUBLIC ${CWD} ${CWD}/cocos + ${CC_EXTERNAL_INCLUDES} ) if(ANDROID) target_link_libraries(cocos2d_jni PUBLIC @@ -2288,7 +2763,16 @@ if(MSVC) ${CWD}/external/win64/libs/glslang/*.dll ) endif() - target_compile_options(cocos2d PUBLIC /MP /wd4309) + target_compile_options(cocos2d 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) @@ -2341,8 +2825,14 @@ target_compile_definitions(cocos2d PRIVATE ${CC_EXTERNAL_PRIVATE_DEFINITIONS} ) + +if(NOT APPLE) + target_include_directories(cocos2d PUBLIC + ${CWD}/external/sources/EGL + ) +endif() + target_include_directories(cocos2d PUBLIC - ${CWD}/external/sources/EGL ${CWD}/external/sources/khronos ) diff --git a/native/cmake/predefine.cmake b/native/cmake/predefine.cmake index 04f614eb2c..d9c1d36fae 100644 --- a/native/cmake/predefine.cmake +++ b/native/cmake/predefine.cmake @@ -99,9 +99,8 @@ set(CMAKE_CXX_STANDARD 14) set(CMAKE_CXX_STANDARD_REQUIRED ON) set(CMAKE_CXX_EXTENSIONS OFF) - if("$ENV{COCOS_ENGINE_DEV}" EQUAL "1") - set(WERROR_FLAGS "-Werror") + set(WERROR_FLAGS "-Werror") # -Wshorten-64-to-32 -Werror=return-type if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "MSVC") set(WERROR_FLAGS "/WX") endif() @@ -187,3 +186,7 @@ function(cc_win32_definations target) SE_ENABLE_INSPECTOR ) endfunction() + + +find_program(NODE_EXECUTABLE NAMES node) +find_program(TSC_EXECUTABLE NAMES tsc) \ No newline at end of file diff --git a/native/cmake/scripts/effects_gzip.js b/native/cmake/scripts/effects_gzip.js new file mode 100644 index 0000000000..3b00c01cd6 --- /dev/null +++ b/native/cmake/scripts/effects_gzip.js @@ -0,0 +1,34 @@ +const zlib = require('zlib'); +const fs = require('fs'); +const process = require('process'); +const writeIfDifferent = require('./utils').writeIfDifferent; + +if (process.argv.length !== 6) { + console.error('bad argument'); + console.error(' - input file'); + console.error(' - export var'); + console.error(' - template file'); + console.error(' - output file'); + process.exit(-1); +} + +const inputFile = process.argv[2]; +const exportVar = process.argv[3]; +const template = process.argv[4]; +const outputFile = process.argv[5]; + +let data = require(inputFile)[exportVar]; + +let encoded = zlib.gzipSync(JSON.stringify(data, null, 2)).toString("base64"); +let array = []; +let start = 0, last = encoded.length; +const charPerRow = 118; +while (start < last) { + array.push(`"${encoded.substr(start, charPerRow)}"`); + start += charPerRow; +} +encoded = array.join("\n"); +let replaceData = fs.readFileSync(template).toString('utf-8').replace("${PLACE_HOLDER}", encoded); +writeIfDifferent(outputFile, replaceData, { encoding: 'utf-8' }); + +process.exit(0); \ No newline at end of file diff --git a/native/cmake/scripts/glsl_gzip.js b/native/cmake/scripts/glsl_gzip.js new file mode 100644 index 0000000000..e97a045acd --- /dev/null +++ b/native/cmake/scripts/glsl_gzip.js @@ -0,0 +1,55 @@ +const zlib = require('zlib'); +const fs = require('fs'); +const process = require('process'); +const writeIfDifferent = require('./utils').writeIfDifferent; + +const VERBOSE = false; + +if (process.argv.length !== 6) { + console.error('bad argument'); + console.error(' - input file'); + console.error(' - export var'); + console.error(' - template file'); + console.error(' - output file'); + process.exit(-1); +} + +const inputFile = process.argv[2]; +const exportVar = process.argv[3]; +const template = process.argv[4]; +const outputFile = process.argv[5]; + +if(VERBOSE) { + console.log(`--processing ${inputFile} : ${exportVar}`); +} + +const shaders = require(inputFile)[exportVar]; + +let newShaders = shaders.map((eff)=> '{' + eff.map(s => { + let o = {...s}; + let arr = ['{\n']; + let shaders = []; + for(let i in o) { + let gziped = zlib.gzipSync(o[i]).toString("base64"); + shaders.push(` {"${i}", GzipedString("${gziped}")}`); + } + arr.push(shaders.join(",\n")); + arr.push('\n}'); + return arr.join(""); +}).join("\n,") + '}'); + +let encoded = newShaders.join(',\n'); + + +if(VERBOSE) { + console.log(`--gen ${outputFile} : ${exportVar}`); +} + +let replaceData = fs.readFileSync(template).toString('utf-8').replace("${PLACE_HOLDER}", encoded); +writeIfDifferent(outputFile, replaceData, {encoding: 'utf-8'}); + +if(VERBOSE) { + console.log(`--done ${outputFile} : ${exportVar}`); +} + +process.exit(0); \ No newline at end of file diff --git a/native/cmake/scripts/utils.js b/native/cmake/scripts/utils.js new file mode 100644 index 0000000000..fdf15300e3 --- /dev/null +++ b/native/cmake/scripts/utils.js @@ -0,0 +1,38 @@ + + +const fs = require('fs'); + + +function all_eql(a, b) { + if (a.length !== b.length) { + return false; + } + const l = a.length; + for (let i = 0; i < l; i++) { + if (a[i] !== b[i]) { + return false; + } + } + return true; +} + +function equals_ignore_spaces(a, b) { + const lines_a = a.split('\n').map(x => x.trim()); + const lines_b = b.split('\n').map(x => x.trim()); + return all_eql(lines_a, lines_b); +} + + +function writeIfDifferent(file, data, args) { + if (fs.existsSync(file)) { + let content = fs.readFileSync(file, args).toString(args.encoding); + if (equals_ignore_spaces(content, data)) { + console.log(`Skip update ${file}`); + return; + } + } + fs.writeFileSync(file, data, args); + console.log(` write to file ${file}`); +} + +exports.writeIfDifferent = writeIfDifferent; \ No newline at end of file diff --git a/native/cocos/3d/assets/Mesh.cpp b/native/cocos/3d/assets/Mesh.cpp new file mode 100644 index 0000000000..1473830a0b --- /dev/null +++ b/native/cocos/3d/assets/Mesh.cpp @@ -0,0 +1,951 @@ +/**************************************************************************** + 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 "3d/assets/Mesh.h" +#include "3d/assets/Morph.h" +#include "3d/assets/Skeleton.h" +#include "3d/misc/BufferBlob.h" +#include "core/DataView.h" +#include "core/assets/RenderingSubMesh.h" +#include "math/Quaternion.h" + +#include "MurmurHash2/MurmurHash2.h" +#include "renderer/gfx-base/GFXDevice.h" + +namespace cc { + +namespace { + +uint32_t getOffset(const gfx::AttributeList &attributes, index_t attributeIndex) { + uint32_t result = 0; + for (index_t i = 0; i < attributeIndex; ++i) { + const auto &attribute = attributes[i]; + result += gfx::GFX_FORMAT_INFOS[static_cast(attribute.format)].size; + } + return result; +} + +// +uint32_t getComponentByteLength(gfx::Format format) { + const auto &info = gfx::GFX_FORMAT_INFOS[static_cast(format)]; + return info.size / info.count; +} + +using DataReaderCallback = std::function; + +DataReaderCallback getReader(const DataView &dataView, gfx::Format format) { + const auto & info = gfx::GFX_FORMAT_INFOS[static_cast(format)]; + const uint32_t stride = info.size / info.count; + + switch (info.type) { + case gfx::FormatType::UNORM: { + switch (stride) { + case 1: return [&](uint32_t offset) -> TypedArrayElementType { return dataView.getUint8(offset); }; + case 2: return [&](uint32_t offset) -> TypedArrayElementType { return dataView.getUint16(offset); }; + case 4: return [&](uint32_t offset) -> TypedArrayElementType { return dataView.getUint32(offset); }; + default: + break; + } + break; + } + case gfx::FormatType::SNORM: { + switch (stride) { + case 1: return [&](uint32_t offset) -> TypedArrayElementType { return dataView.getInt8(offset); }; + case 2: return [&](uint32_t offset) -> TypedArrayElementType { return dataView.getInt16(offset); }; + case 4: return [&](uint32_t offset) -> TypedArrayElementType { return dataView.getInt32(offset); }; + default: + break; + } + break; + } + case gfx::FormatType::INT: { + switch (stride) { + case 1: return [&](uint32_t offset) -> TypedArrayElementType { return dataView.getInt8(offset); }; + case 2: return [&](uint32_t offset) -> TypedArrayElementType { return dataView.getInt16(offset); }; + case 4: return [&](uint32_t offset) -> TypedArrayElementType { return dataView.getInt32(offset); }; + default: + break; + } + break; + } + case gfx::FormatType::UINT: { + switch (stride) { + case 1: return [&](uint32_t offset) -> TypedArrayElementType { return dataView.getUint8(offset); }; + case 2: return [&](uint32_t offset) -> TypedArrayElementType { return dataView.getUint16(offset); }; + case 4: return [&](uint32_t offset) -> TypedArrayElementType { return dataView.getUint32(offset); }; + default: + break; + } + break; + } + case gfx::FormatType::FLOAT: { + return [&](uint32_t offset) -> TypedArrayElementType { return dataView.getFloat32(offset); }; + } + default: + break; + } + + return nullptr; +} + +using DataWritterCallback = std::function; + +DataWritterCallback getWriter(DataView &dataView, gfx::Format format) { + const auto & info = gfx::GFX_FORMAT_INFOS[static_cast(format)]; + const uint32_t stride = info.size / info.count; + + switch (info.type) { + case gfx::FormatType::UNORM: { + switch (stride) { + case 1: return [&](uint32_t offset, const TypedArrayElementType &value) { dataView.setUint8(offset, cc::get(value)); }; + case 2: return [&](uint32_t offset, const TypedArrayElementType &value) { dataView.setUint16(offset, cc::get(value)); }; + case 4: return [&](uint32_t offset, const TypedArrayElementType &value) { dataView.setUint32(offset, cc::get(value)); }; + default: + break; + } + break; + } + case gfx::FormatType::SNORM: { + switch (stride) { + case 1: return [&](uint32_t offset, const TypedArrayElementType &value) { dataView.setInt8(offset, cc::get(value)); }; + case 2: return [&](uint32_t offset, const TypedArrayElementType &value) { dataView.setInt16(offset, cc::get(value)); }; + case 4: return [&](uint32_t offset, const TypedArrayElementType &value) { dataView.setInt32(offset, cc::get(value)); }; + default: + break; + } + break; + } + case gfx::FormatType::INT: { + switch (stride) { + case 1: return [&](uint32_t offset, const TypedArrayElementType &value) { dataView.setInt8(offset, cc::get(value)); }; + case 2: return [&](uint32_t offset, const TypedArrayElementType &value) { dataView.setInt16(offset, cc::get(value)); }; + case 4: return [&](uint32_t offset, const TypedArrayElementType &value) { dataView.setInt32(offset, cc::get(value)); }; + default: + break; + } + break; + } + case gfx::FormatType::UINT: { + switch (stride) { + case 1: return [&](uint32_t offset, const TypedArrayElementType &value) { dataView.setUint8(offset, cc::get(value)); }; + case 2: return [&](uint32_t offset, const TypedArrayElementType &value) { dataView.setUint16(offset, cc::get(value)); }; + case 4: return [&](uint32_t offset, const TypedArrayElementType &value) { dataView.setUint32(offset, cc::get(value)); }; + default: + break; + } + break; + } + case gfx::FormatType::FLOAT: { + return [&](uint32_t offset, const TypedArrayElementType &value) { dataView.setFloat32(offset, cc::get(value)); }; + } + default: + break; + } + + return nullptr; +} + +} // namespace + +cc::any Mesh::getNativeAsset() const { + return _data; //cjh FIXME: need copy? could be _data pointer? +} + +void Mesh::setNativeAsset(const cc::any &obj) { + auto *p = cc::any_cast(obj); + if (p != nullptr) { + _data = Uint8Array(p); + } +} + +uint32_t Mesh::getSubMeshCount() const { + return static_cast(_renderingSubMeshes.size()); +} + +const Vec3 &Mesh::getMinPosition() const { + return _struct.minPosition.has_value() ? _struct.minPosition.value() : Vec3::ZERO; +} + +const Vec3 &Mesh::getMaxPosition() const { + return _struct.maxPosition.has_value() ? _struct.maxPosition.value() : Vec3::ZERO; +} + +uint64_t Mesh::getHash() { + if (_hash == 0) { + _hash = murmurhash2::MurmurHash2(_data.buffer()->getData(), static_cast(_data.length()), 666); + } + + return _hash; +} + +const Mesh::JointBufferIndicesType &Mesh::getJointBufferIndices() { + if (!_jointBufferIndices.empty()) { + return _jointBufferIndices; + } + + _jointBufferIndices.reserve(_struct.primitives.size()); + for (auto &p : _struct.primitives) { + _jointBufferIndices.emplace_back(p.jointMapIndex.has_value() ? p.jointMapIndex.value() : 0); + } + + return _jointBufferIndices; +} + +void Mesh::initialize() { + if (_initialized) { + return; + } + if (!_data.buffer()) { + return; + } + + _initialized = true; + auto & buffer = _data; + gfx::Device * gfxDevice = gfx::Device::getInstance(); + auto vertexBuffers = createVertexBuffers(gfxDevice, buffer.buffer()); + gfx::BufferList indexBuffers; + std::vector> subMeshes; + + for (size_t i = 0; i < _struct.primitives.size(); i++) { + auto &prim = _struct.primitives[i]; + if (prim.vertexBundelIndices.empty()) { + continue; + } + + gfx::Buffer *indexBuffer = nullptr; + if (prim.indexView.has_value()) { + const auto &idxView = prim.indexView.value(); + + uint32_t dstStride = idxView.stride; + uint32_t dstSize = idxView.length; + if (dstStride == 4 && !gfxDevice->hasFeature(gfx::Feature::ELEMENT_INDEX_UINT)) { + uint32_t vertexCount = _struct.vertexBundles[prim.vertexBundelIndices[0]].view.count; + if (vertexCount >= 65536) { + //cjh warnID(10001, vertexCount, 65536); + continue; // Ignore this primitive + } + + dstStride >>= 1; // Reduce to short. + dstSize >>= 1; + } + + indexBuffer = gfxDevice->createBuffer(gfx::BufferInfo{ + gfx::BufferUsageBit::INDEX, + gfx::MemoryUsageBit::DEVICE, + dstSize, + dstStride, + }); + indexBuffers.emplace_back(indexBuffer); + + const uint8_t *ib = buffer.buffer()->getData() + idxView.offset; + + // ib = new (getIndexStrideCtor(idxView.stride))(buffer, idxView.offset, idxView.count); + if (idxView.stride != dstStride) { + //cjh need in c++? ib = getIndexStrideCtor(dstStride).from(ib); + } + indexBuffer->update(ib); + } + + gfx::BufferList vbReference; + vbReference.reserve(prim.vertexBundelIndices.size()); + for (const auto &idx : prim.vertexBundelIndices) { + vbReference.emplace_back(vertexBuffers[idx]); + } + + gfx::AttributeList gfxAttributes; + if (!prim.vertexBundelIndices.empty()) { + uint32_t idx = prim.vertexBundelIndices[0]; + const IVertexBundle & vertexBundle = _struct.vertexBundles[idx]; + const gfx::AttributeList &attrs = vertexBundle.attributes; + gfxAttributes.resize(attrs.size()); + for (size_t j = 0; j < attrs.size(); ++j) { + const auto &attr = attrs[j]; + gfxAttributes[j] = gfx::Attribute{attr.name, attr.format, attr.isNormalized, attr.stream, attr.isInstanced, attr.location}; + } + } + + auto *subMesh = new RenderingSubMesh(vbReference, gfxAttributes, prim.primitiveMode, indexBuffer); + subMesh->setMesh(this); + subMesh->setSubMeshIdx(static_cast(i)); + + subMeshes.emplace_back(subMesh); + } + + _renderingSubMeshes = subMeshes; + + if (_struct.morph.has_value()) { + morphRendering = createMorphRendering(this, gfxDevice); + } +} + +void Mesh::destroyRenderingMesh() { + if (!_renderingSubMeshes.empty()) { + for (auto &submesh : _renderingSubMeshes) { + submesh->destroy(); + } + _renderingSubMeshes.clear(); + _initialized = false; + } +} + +void Mesh::assign(const IStruct &structInfo, const Uint8Array &data) { + reset({structInfo, data}); +} + +void Mesh::reset(ICreateInfo &&info) { + destroyRenderingMesh(); + _struct = std::move(info.structInfo); + _data = std::move(info.data); + _hash = 0; +} + +Mesh::BoneSpaceBounds Mesh::getBoneSpaceBounds(Skeleton *skeleton) { + auto iter = _boneSpaceBounds.find(skeleton->getHash()); + if (iter != _boneSpaceBounds.end()) { + return iter->second; + } + Vec3 v32; + BoneSpaceBounds & bounds = _boneSpaceBounds[skeleton->getHash()]; + std::vector valid; + const auto & bindposes = skeleton->getBindposes(); + valid.reserve(bindposes.size()); + for (size_t i = 0; i < bindposes.size(); i++) { + bounds.emplace_back(new geometry::AABB{ + std::numeric_limits::infinity(), std::numeric_limits::infinity(), std::numeric_limits::infinity(), + -std::numeric_limits::infinity(), -std::numeric_limits::infinity(), -std::numeric_limits::infinity()}); + valid.emplace_back(false); + } + const auto &primitives = _struct.primitives; + for (index_t p = 0; p < primitives.size(); p++) { + const auto joints = readAttribute(p, gfx::ATTR_NAME_JOINTS); + const auto weights = readAttribute(p, gfx::ATTR_NAME_WEIGHTS); + const auto positions = readAttribute(p, gfx::ATTR_NAME_POSITION); + if (joints.index() == 0 || weights.index() == 0 || positions.index() == 0) { + continue; + } + + uint32_t vertCount = std::min({getTypedArrayLength(joints) / 4, + getTypedArrayLength(weights) / 4, + getTypedArrayLength(positions) / 3}); + for (uint32_t i = 0; i < vertCount; i++) { + Vec3 v31{ + getTypedArrayValue(positions, 3 * i + 0), + getTypedArrayValue(positions, 3 * i + 1), + getTypedArrayValue(positions, 3 * i + 2)}; + + for (uint32_t j = 0; j < 4; ++j) { + const uint32_t idx = 4 * i + j; + const auto joint = getTypedArrayValue(joints, idx); + + if (std::fabs(getTypedArrayValue(weights, idx)) < FLT_EPSILON || joint >= bindposes.size()) { + continue; + } + + Vec3::transformMat4(v31, bindposes[joint], &v32); + valid[joint] = true; + auto &b = bounds[joint]; + Vec3::min(b->center, v32, &b->center); + Vec3::max(b->halfExtents, v32, &b->halfExtents); + } + } + } + for (size_t i = 0; i < bindposes.size(); i++) { + auto &b = bounds[i]; + if (!valid[i]) { + bounds[i] = {}; + } else { + geometry::AABB::fromPoints(b->center, b->halfExtents, b); + } + } + return bounds; +} + +bool Mesh::merge(Mesh *mesh, const Mat4 *worldMatrix /* = nullptr */, bool validate /* = false*/) { + if (validate) { + if (!validateMergingMesh(mesh)) { + return false; + } + } + + Vec3 vec3Temp; + Quaternion rotate; + geometry::AABB boundingBox; + if (worldMatrix != nullptr) { + worldMatrix->getRotation(&rotate); + } + if (!_initialized) { + auto structInfo = mesh->_struct; //NOTE: Need copy struct, so don't use referece + Uint8Array data{mesh->_data.slice()}; + if (worldMatrix != nullptr) { + if (structInfo.maxPosition.has_value() && structInfo.minPosition.has_value()) { + Vec3::add(structInfo.maxPosition.value(), structInfo.minPosition.value(), &boundingBox.center); + boundingBox.center.scale(0.5F); + Vec3::subtract(structInfo.maxPosition.value(), structInfo.minPosition.value(), &boundingBox.halfExtents); + boundingBox.halfExtents.scale(0.5F); + + boundingBox.transform(*worldMatrix, &boundingBox); + Vec3::add(boundingBox.center, boundingBox.halfExtents, &structInfo.maxPosition.value()); + Vec3::subtract(boundingBox.center, boundingBox.halfExtents, &structInfo.minPosition.value()); + } + for (auto &vtxBdl : structInfo.vertexBundles) { + for (int j = 0; j < vtxBdl.attributes.size(); j++) { + if (vtxBdl.attributes[j].name == gfx::ATTR_NAME_POSITION || vtxBdl.attributes[j].name == gfx::ATTR_NAME_NORMAL) { + const gfx::Format format = vtxBdl.attributes[j].format; + + DataView inputView(data.buffer(), vtxBdl.view.offset + getOffset(vtxBdl.attributes, j)); + + auto reader = getReader(inputView, format); + if (reader == nullptr) { + continue; + } + + auto writer = getWriter(inputView, format); + if (writer == nullptr) { + continue; + } + + const uint32_t vertexCount = vtxBdl.view.count; + + const uint32_t vertexStride = vtxBdl.view.stride; + const uint32_t attrComponentByteLength = getComponentByteLength(format); + for (uint32_t vtxIdx = 0; vtxIdx < vertexCount; vtxIdx++) { + const uint32_t xOffset = vtxIdx * vertexStride; + const uint32_t yOffset = xOffset + attrComponentByteLength; + const uint32_t zOffset = yOffset + attrComponentByteLength; + vec3Temp.set( + getTypedArrayElementValue(reader(xOffset)), + getTypedArrayElementValue(reader(yOffset)), + getTypedArrayElementValue(reader(zOffset))); + const auto &attrName = vtxBdl.attributes[j].name; + + if (attrName == gfx::ATTR_NAME_POSITION) { + vec3Temp.transformMat4(vec3Temp, *worldMatrix); + } else if (attrName == gfx::ATTR_NAME_NORMAL) { + vec3Temp.transformQuat(rotate); + } + + writer(xOffset, vec3Temp.x); + writer(yOffset, vec3Temp.y); + writer(zOffset, vec3Temp.z); + } + } + } + } + } + reset({structInfo, data}); + initialize(); + return true; + } + + // merge buffer + BufferBlob bufferBlob; + + // merge vertex buffer + uint32_t vertCount = 0; + uint32_t vertStride = 0; + uint32_t srcOffset = 0; + uint32_t dstOffset = 0; + + uint32_t srcAttrOffset = 0; + uint32_t srcVBOffset = 0; + uint32_t dstVBOffset = 0; + uint32_t attrSize = 0; + + bool hasAttr = false; + + std::vector vertexBundles; + vertexBundles.resize(_struct.vertexBundles.size()); + + for (size_t i = 0; i < _struct.vertexBundles.size(); ++i) { + Uint8Array dstAttrView; + + const auto &bundle = _struct.vertexBundles[i]; + auto & dstBundle = mesh->_struct.vertexBundles[i]; + + srcOffset = bundle.view.offset; + dstOffset = dstBundle.view.offset; + vertStride = bundle.view.stride; + vertCount = bundle.view.count + dstBundle.view.count; + + auto * vb = new ArrayBuffer(vertCount * vertStride); + Uint8Array vbView(vb); + + Uint8Array srcVBView = _data.subarray(srcOffset, srcOffset + bundle.view.length); + srcOffset += srcVBView.length(); + Uint8Array dstVBView = mesh->_data.subarray(dstOffset, dstOffset + dstBundle.view.length); + dstOffset += dstVBView.length(); + + vbView.set(srcVBView); + + srcAttrOffset = 0; + for (const auto &attr : bundle.attributes) { + dstVBOffset = 0; + hasAttr = false; + for (const auto &dstAttr : dstBundle.attributes) { + if (attr.name == dstAttr.name && attr.format == dstAttr.format) { + hasAttr = true; + break; + } + dstVBOffset += gfx::GFX_FORMAT_INFOS[static_cast(dstAttr.format)].size; + } + if (hasAttr) { + attrSize = gfx::GFX_FORMAT_INFOS[static_cast(attr.format)].size; + srcVBOffset = bundle.view.length + srcAttrOffset; + for (uint32_t v = 0; v < dstBundle.view.count; ++v) { + dstAttrView = dstVBView.subarray(dstVBOffset, dstVBOffset + attrSize); + vbView.set(dstAttrView, srcVBOffset); + if ((attr.name == gfx::ATTR_NAME_POSITION || attr.name == gfx::ATTR_NAME_NORMAL) && worldMatrix != nullptr) { + Float32Array f32Temp(vbView.buffer(), srcVBOffset, 3); + vec3Temp.set(f32Temp[0], f32Temp[1], f32Temp[2]); + if (attr.name == gfx::ATTR_NAME_POSITION) { + vec3Temp.transformMat4(vec3Temp, *worldMatrix); + } else if (attr.name == gfx::ATTR_NAME_NORMAL) { + vec3Temp.transformQuat(rotate); + } + + f32Temp[0] = vec3Temp.x; + f32Temp[1] = vec3Temp.y; + f32Temp[2] = vec3Temp.z; + } + srcVBOffset += bundle.view.stride; + dstVBOffset += dstBundle.view.stride; + } + } + srcAttrOffset += gfx::GFX_FORMAT_INFOS[static_cast(attr.format)].size; + } + + auto &vertexBundle = vertexBundles[i]; + vertexBundle.attributes = bundle.attributes, + vertexBundle.view.offset = bufferBlob.getLength(); + vertexBundle.view.length = vb->byteLength(); + vertexBundle.view.count = vertCount; + vertexBundle.view.stride = vertStride; + + bufferBlob.addBuffer(vb); + } + + // merge index buffer + uint32_t idxCount = 0; + uint32_t idxStride = 2; + uint32_t vertBatchCount = 0; + + std::vector primitives; + primitives.resize(_struct.primitives.size()); + + for (size_t i = 0; i < _struct.primitives.size(); ++i) { + const auto &prim = _struct.primitives[i]; + auto & dstPrim = mesh->_struct.primitives[i]; + + primitives[i].primitiveMode = prim.primitiveMode; + primitives[i].vertexBundelIndices = prim.vertexBundelIndices; + + for (const uint32_t bundleIdx : prim.vertexBundelIndices) { + vertBatchCount = std::max(vertBatchCount, _struct.vertexBundles[bundleIdx].view.count); + } + + if (prim.indexView.has_value() && dstPrim.indexView.has_value()) { + idxCount = prim.indexView.value().count; + idxCount += dstPrim.indexView.value().count; + + srcOffset = prim.indexView.value().offset; + dstOffset = dstPrim.indexView.value().offset; + + if (idxCount < 256) { + idxStride = 1; + } else if (idxCount < 65536) { + idxStride = 2; + } else { + idxStride = 4; + } + + auto *ib = new ArrayBuffer(idxCount * idxStride); + + TypedArray ibView; + TypedArray srcIBView; + TypedArray dstIBView; + + if (idxStride == 2) { + ibView = Uint16Array(ib); + } else if (idxStride == 1) { + ibView = Uint8Array(ib); + } else { // Uint32 + ibView = Uint32Array(ib); + } + + // merge src indices + if (prim.indexView.value().stride == 2) { + srcIBView = Uint16Array(_data.buffer(), srcOffset, prim.indexView.value().count); + } else if (prim.indexView.value().stride == 1) { + srcIBView = Uint8Array(_data.buffer(), srcOffset, prim.indexView.value().count); + } else { // Uint32 + srcIBView = Uint32Array(_data.buffer(), srcOffset, prim.indexView.value().count); + } + // + if (idxStride == prim.indexView.value().stride) { + switch (idxStride) { + case 2: + cc::get(ibView).set(cc::get(srcIBView)); + break; + case 1: + cc::get(ibView).set(cc::get(srcIBView)); + break; + default: + cc::get(ibView).set(cc::get(srcIBView)); + break; + } + } else { + for (uint32_t n = 0; n < prim.indexView.value().count; ++n) { + if (idxStride == 2) { + cc::get(ibView)[n] = static_cast(getTypedArrayValue(srcIBView, n)); + } else if (idxStride == 1) { + cc::get(ibView)[n] = static_cast(getTypedArrayValue(srcIBView, n)); + } else { + cc::get(ibView)[n] = getTypedArrayValue(srcIBView, n); + } + } + } + srcOffset += prim.indexView.value().length; + + // merge dst indices + uint32_t indexViewStride = dstPrim.indexView.value().stride; + if (indexViewStride == 2) { + dstIBView = Uint16Array(mesh->_data.buffer(), dstOffset, dstPrim.indexView->count); + } else if (indexViewStride == 1) { + dstIBView = Uint8Array(mesh->_data.buffer(), dstOffset, dstPrim.indexView->count); + } else { // Uint32 + dstIBView = Uint32Array(mesh->_data.buffer(), dstOffset, dstPrim.indexView->count); + } + for (uint32_t n = 0; n < dstPrim.indexView.value().count; ++n) { + if (idxStride == 2) { + cc::get(ibView)[prim.indexView->count + n] = + vertBatchCount + static_cast(getTypedArrayValue(dstIBView, n)); + } else if (idxStride == 1) { + cc::get(ibView)[prim.indexView->count + n] = + vertBatchCount + static_cast(getTypedArrayValue(dstIBView, n)); + } else { + cc::get(ibView)[prim.indexView->count + n] = + vertBatchCount + getTypedArrayValue(dstIBView, n); + } + } + dstOffset += dstPrim.indexView.value().length; + + IBufferView indexView; + indexView.offset = bufferBlob.getLength(); + indexView.length = ib->byteLength(); + indexView.count = idxCount; + indexView.stride = idxStride; + primitives[i].indexView = indexView; + + bufferBlob.setNextAlignment(idxStride); + bufferBlob.addBuffer(ib); + } + } + + // Create mesh struct. + Mesh::IStruct meshStruct; + meshStruct.vertexBundles = vertexBundles; + meshStruct.primitives = primitives; + meshStruct.minPosition = _struct.minPosition; + meshStruct.maxPosition = _struct.maxPosition; + + if (meshStruct.minPosition && mesh->_struct.minPosition && meshStruct.maxPosition && mesh->_struct.maxPosition) { + if (worldMatrix != nullptr) { + if (mesh->_struct.maxPosition.has_value() && mesh->_struct.minPosition.has_value()) { + Vec3::add(mesh->_struct.maxPosition.value(), mesh->_struct.minPosition.value(), &boundingBox.center); + } + boundingBox.center.scale(0.5F); + if (mesh->_struct.maxPosition.has_value() && mesh->_struct.minPosition.has_value()) { + Vec3::subtract(mesh->_struct.maxPosition.value(), mesh->_struct.minPosition.value(), &boundingBox.halfExtents); + } + boundingBox.halfExtents.scale(0.5F); + boundingBox.transform(*worldMatrix, &boundingBox); + + Vec3::add(boundingBox.center, boundingBox.halfExtents, &vec3Temp); + Vec3::max(meshStruct.maxPosition.value(), vec3Temp, &meshStruct.maxPosition.value()); + Vec3::subtract(boundingBox.center, boundingBox.halfExtents, &vec3Temp); + Vec3::min(meshStruct.minPosition.value(), vec3Temp, &meshStruct.minPosition.value()); + } else { + Vec3::min(meshStruct.minPosition.value(), mesh->_struct.minPosition.value(), &meshStruct.minPosition.value()); + Vec3::max(meshStruct.maxPosition.value(), mesh->_struct.maxPosition.value(), &meshStruct.maxPosition.value()); + } + } + + // Create mesh. + reset({std::move(meshStruct), + std::move(Uint8Array(bufferBlob.getCombined()))}); + initialize(); + return true; +} + +bool Mesh::validateMergingMesh(Mesh *mesh) { + // validate vertex bundles + if (_struct.vertexBundles.size() != mesh->_struct.vertexBundles.size()) { + return false; + } + + for (size_t i = 0; i < _struct.vertexBundles.size(); ++i) { + const auto &bundle = _struct.vertexBundles[i]; + auto & dstBundle = mesh->_struct.vertexBundles[i]; + + if (bundle.attributes.size() != dstBundle.attributes.size()) { + return false; + } + for (size_t j = 0; j < bundle.attributes.size(); ++j) { + if (bundle.attributes[j].format != dstBundle.attributes[j].format) { + return false; + } + } + } + + // validate primitives + if (_struct.primitives.size() != mesh->_struct.primitives.size()) { + return false; + } + for (size_t i = 0; i < _struct.primitives.size(); ++i) { + const auto &prim = _struct.primitives[i]; + auto & dstPrim = mesh->_struct.primitives[i]; + if (prim.vertexBundelIndices.size() != dstPrim.vertexBundelIndices.size()) { + return false; + } + for (size_t j = 0; j < prim.vertexBundelIndices.size(); ++j) { + if (prim.vertexBundelIndices[j] != dstPrim.vertexBundelIndices[j]) { + return false; + } + } + if (prim.primitiveMode != dstPrim.primitiveMode) { + return false; + } + + if (prim.indexView.has_value()) { + if (!dstPrim.indexView.has_value()) { + return false; + } + } else if (dstPrim.indexView.has_value()) { + return false; + } + } + + return true; +} + +TypedArray Mesh::readAttribute(index_t primitiveIndex, const char *attributeName) { + TypedArray result; + accessAttribute(primitiveIndex, attributeName, [&](const IVertexBundle &vertexBundle, uint32_t iAttribute) { + const uint32_t vertexCount = vertexBundle.view.count; + const gfx::Format format = vertexBundle.attributes[iAttribute].format; + if (vertexCount == 0) { + return; + } + + DataView inputView(_data.buffer(), vertexBundle.view.offset + getOffset(vertexBundle.attributes, static_cast(iAttribute))); + + const auto &formatInfo = gfx::GFX_FORMAT_INFOS[static_cast(format)]; + + auto reader = getReader(inputView, format); + if (reader == nullptr) { + return; + } + + const uint32_t componentCount = formatInfo.count; + result = createTypedArrayWithGFXFormat(format, vertexCount * componentCount); + const uint32_t inputStride = vertexBundle.view.stride; + for (uint32_t iVertex = 0; iVertex < vertexCount; ++iVertex) { + for (uint32_t iComponent = 0; iComponent < componentCount; ++iComponent) { + TypedArrayElementType element = reader(inputStride * iVertex + getTypedArrayBytesPerElement(result) * iComponent); + setTypedArrayValue(result, componentCount * iVertex + iComponent, element); + } + } + }); + return result; +} + +bool Mesh::copyAttribute(index_t primitiveIndex, const char *attributeName, ArrayBuffer *buffer, uint32_t stride, uint32_t offset) { + bool written = false; + accessAttribute(primitiveIndex, attributeName, [&](const IVertexBundle &vertexBundle, uint32_t iAttribute) { + const uint32_t vertexCount = vertexBundle.view.count; + if (vertexCount == 0) { + written = true; + return; + } + const gfx::Format format = vertexBundle.attributes[iAttribute].format; + + DataView inputView(_data.buffer(), vertexBundle.view.offset + getOffset(vertexBundle.attributes, static_cast(iAttribute))); + + DataView outputView(buffer, offset); + + const auto &formatInfo = gfx::GFX_FORMAT_INFOS[static_cast(format)]; + + auto reader = getReader(inputView, format); + if (reader == nullptr) { + return; + } + + auto writer = getWriter(outputView, format); + if (writer == nullptr) { + return; + } + + const uint32_t componentCount = formatInfo.count; + + const uint32_t inputStride = vertexBundle.view.stride; + const uint32_t inputComponentByteLength = getComponentByteLength(format); + const uint32_t outputStride = stride; + const uint32_t outputComponentByteLength = inputComponentByteLength; + for (uint32_t iVertex = 0; iVertex < vertexCount; ++iVertex) { + for (uint32_t iComponent = 0; iComponent < componentCount; ++iComponent) { + const uint32_t inputOffset = inputStride * iVertex + inputComponentByteLength * iComponent; + const uint32_t outputOffset = outputStride * iVertex + outputComponentByteLength * iComponent; + writer(outputOffset, reader(inputOffset)); + } + } + written = true; + }); + return written; +} + +IBArray Mesh::readIndices(index_t primitiveIndex) { + if (primitiveIndex >= _struct.primitives.size()) { + return {}; + } + const auto &primitive = _struct.primitives[primitiveIndex]; + if (!primitive.indexView.has_value()) { + return {}; + } + const uint32_t stride = primitive.indexView.value().stride; + const uint32_t count = primitive.indexView.value().count; + const uint32_t byteOffset = primitive.indexView.value().offset; + IBArray ret; + if (stride == 1) { + ret = Uint8Array(_data.buffer(), byteOffset, count); + } else if (stride == 2) { + ret = Uint16Array(_data.buffer(), byteOffset, count); + } else { + ret = Uint32Array(_data.buffer(), byteOffset, count); + } + + return ret; +} + +bool Mesh::copyIndices(index_t primitiveIndex, TypedArray &outputArray) { + if (primitiveIndex >= _struct.primitives.size()) { + return false; + } + const auto &primitive = _struct.primitives[primitiveIndex]; + if (!primitive.indexView.has_value()) { + return false; + } + + const uint32_t indexCount = primitive.indexView.value().count; + const gfx::Format indexFormat = primitive.indexView.value().stride == 1 ? gfx::Format::R8UI + : (primitive.indexView.value().stride == 2 ? gfx::Format::R16UI + : gfx::Format::R32UI); + DataView view(_data.buffer()); + auto reader = getReader(view, indexFormat); + for (uint32_t i = 0; i < indexCount; ++i) { + TypedArrayElementType element = reader(primitive.indexView.value().offset + gfx::GFX_FORMAT_INFOS[static_cast(indexFormat)].size * i); + setTypedArrayValue(outputArray, i, element); + } + return true; +} + +void Mesh::accessAttribute(index_t primitiveIndex, const char *attributeName, const AccessorType &accessor) { + if (primitiveIndex >= _struct.primitives.size()) { + return; + } + + auto &primitive = _struct.primitives[primitiveIndex]; + for (const auto &vertexBundleIndex : primitive.vertexBundelIndices) { + const auto &vertexBundle = _struct.vertexBundles[vertexBundleIndex]; + auto iter = std::find_if(vertexBundle.attributes.begin(), vertexBundle.attributes.end(), [&](const auto &a) -> bool { return a.name == attributeName; }); + if (iter == vertexBundle.attributes.end()) { + continue; + } + accessor(vertexBundle, static_cast(iter - vertexBundle.attributes.begin())); + break; + } +} + +/* static */ +gfx::BufferList Mesh::createVertexBuffers(gfx::Device *gfxDevice, ArrayBuffer *data) { + gfx::BufferList buffers; + for (const auto &vertexBundle : _struct.vertexBundles) { + auto *vertexBuffer = gfxDevice->createBuffer({gfx::BufferUsageBit::VERTEX, + gfx::MemoryUsageBit::DEVICE, + vertexBundle.view.length, + vertexBundle.view.stride}); + + vertexBuffer->update(data->getData() + vertexBundle.view.offset, vertexBundle.view.length); + buffers.emplace_back(vertexBuffer); + } + return buffers; +} + +void Mesh::initDefault(const cc::optional &uuid) { + Super::initDefault(uuid); + reset({}); +} + +bool Mesh::validate() const { + return !_renderingSubMeshes.empty() && !_data.empty(); +} + +TypedArray Mesh::createTypedArrayWithGFXFormat(gfx::Format format, uint32_t count) { + const auto & info = gfx::GFX_FORMAT_INFOS[static_cast(format)]; + const uint32_t stride = info.size / info.count; + + switch (info.type) { + case gfx::FormatType::UNORM: + case gfx::FormatType::UINT: { + switch (stride) { + case 1: return Uint8Array(count); + case 2: return Uint16Array(count); + case 4: return Uint32Array(count); + default: + break; + } + break; + } + case gfx::FormatType::SNORM: + case gfx::FormatType::INT: { + switch (stride) { + case 1: return Int8Array(count); + case 2: return Int16Array(count); + case 4: return Int32Array(count); + default: + break; + } + break; + } + case gfx::FormatType::FLOAT: { + return Float32Array(count); + } + default: + break; + } + + return Float32Array(count); +} + +} // namespace cc diff --git a/native/cocos/3d/assets/Mesh.h b/native/cocos/3d/assets/Mesh.h new file mode 100644 index 0000000000..d8dd830193 --- /dev/null +++ b/native/cocos/3d/assets/Mesh.h @@ -0,0 +1,402 @@ +/**************************************************************************** + 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 "3d/assets/MorphRendering.h" +#include "3d/assets/Types.h" +#include "cocos/base/Optional.h" +#include "core/assets/Asset.h" +#include "core/geometry/AABB.h" +#include "math/Mat4.h" +#include "math/Vec3.h" +#include "renderer/gfx-base/GFXDef.h" + +namespace cc { + +class Skeleton; +class RenderingSubMesh; + +/** + * @en Mesh asset + * @zh 网格资源。 + */ +class Mesh : public Asset { +public: + using Super = Asset; + + using IBufferView = IMeshBufferView; + + /** + * @en Vertex bundle, it describes a set of interleaved vertex attributes and their values. + * @zh 顶点块。顶点块描述了一组**交错排列**(interleaved)的顶点属性并存储了顶点属性的实际数据。
+ * 交错排列是指在实际数据的缓冲区中,每个顶点的所有属性总是依次排列,并总是出现在下一个顶点的所有属性之前。 + */ + struct IVertexBundle { + cc::optional _padding; // NOTE: avoid jsb cache map + /** + * @en The actual value for all vertex attributes. + * You must use DataView to access the data. + * @zh 所有顶点属性的实际数据块。 + * 你必须使用 DataView 来读取数据。 + * 因为不能保证所有属性的起始偏移都按 TypedArray 要求的字节对齐。 + */ + IBufferView view; + + /** + * @en All attributes included in the bundle + * @zh 包含的所有顶点属性。 + */ + gfx::AttributeList attributes; + }; + + /** + * @en Sub mesh contains a list of primitives with the same type (Point, Line or Triangle) + * @zh 子网格。子网格由一系列相同类型的图元组成(例如点、线、面等)。 + */ + struct ISubMesh { + /** + * @en The vertex bundle references used by the sub mesh. + * @zh 此子网格引用的顶点块,索引至网格的顶点块数组。 + */ + std::vector vertexBundelIndices; + + /** + * @en The primitive mode of the sub mesh + * @zh 此子网格的图元类型。 + */ + gfx::PrimitiveMode primitiveMode; + + /** + * @en The index data of the sub mesh + * @zh 此子网格使用的索引数据。 + */ + cc::optional indexView; + + /** + * @en The joint map index in [[IStruct.jointMaps]]. Could be absent + * @zh 此子网格使用的关节索引映射表在 [[IStruct.jointMaps]] 中的索引。 + * 如未定义或指向的映射表不存在,则默认 VB 内所有关节索引数据直接对应骨骼资源数据。 + */ + cc::optional jointMapIndex; + }; + + /** + * @en The structure of the mesh + * @zh 描述了网格的结构。 + */ + struct IStruct { + /** + * @en All vertex bundles of the mesh + * @zh 此网格所有的顶点块。 + */ + std::vector vertexBundles; + + /** + * @en All sub meshes + * @zh 此网格的所有子网格。 + */ + std::vector primitives; + + /** + * @en The minimum position of all vertices in the mesh + * @zh (各分量都)小于等于此网格任何顶点位置的最大位置。 + */ + cc::optional minPosition; + + /** + * @en The maximum position of all vertices in the mesh + * @zh (各分量都)大于等于此网格任何顶点位置的最小位置。 + */ + cc::optional maxPosition; + + /** + * @en The joint index map list. + * @zh 此网格使用的关节索引映射关系列表,数组长度应为子模型中实际使用到的所有关节, + * 每个元素都对应一个原骨骼资源里的索引,按子模型 VB 内的实际索引排列。 + */ + cc::optional>> jointMaps; + + /** + * @en The morph information of the mesh + * @zh 网格的形变数据 + */ + cc::optional morph; + }; + + struct ICreateInfo { + /** + * @en Mesh structure + * @zh 网格结构。 + */ + IStruct structInfo; + + /** + * @en Mesh binary data + * @zh 网格二进制数据。 + */ + Uint8Array data; + }; + + Mesh() = default; + ~Mesh() override = default; + + cc::any getNativeAsset() const override; + void setNativeAsset(const cc::any &obj) override; + + void setAssetData(cc::ArrayBuffer *data) { + _data = Uint8Array(data); + } + const Uint8Array &getAssetData() { + return _data; + } + + /** + * @en The sub meshes count of the mesh. + * @zh 此网格的子网格数量。 + * @deprecated Please use [[renderingSubMeshes.length]] instead + */ + uint32_t getSubMeshCount() const; + + /** + * @en The minimum position of all vertices in the mesh + * @zh (各分量都)小于等于此网格任何顶点位置的最大位置。 + * @deprecated Please use [[struct.minPosition]] instead + */ + const Vec3 &getMinPosition() const; + + /** + * @en The maximum position of all vertices in the mesh + * @zh (各分量都)大于等于此网格任何顶点位置的最大位置。 + * @deprecated Please use [[struct.maxPosition]] instead + */ + const Vec3 &getMaxPosition() const; + + /** + * @en The struct of the mesh + * @zh 此网格的结构。 + */ + inline const IStruct &getStruct() const { + return _struct; + } + + inline void setStruct(const IStruct &input) { + _struct = input; + } + + inline Uint8Array &getData() { + return _data; + } + + inline void setData(const Uint8Array &data) { + _data = data; + } + + /** + * @en The hash of the mesh + * @zh 此网格的哈希值。 + */ + uint64_t getHash(); + + inline double getHashForJS() { + return static_cast(getHash()); + } + + /** + * @en Set the hash of the mesh + * @zh 设置此网格的哈希值。 + */ + void setHash(uint64_t hash) { _hash = hash; } + + using JointBufferIndicesType = std::vector; + /** + * The index of the joint buffer of all sub meshes in the joint map buffers + */ + const JointBufferIndicesType &getJointBufferIndices(); + + using RenderingSubMeshList = std::vector>; + /** + * @en The sub meshes for rendering. Mesh could be split into different sub meshes for rendering. + * @zh 此网格创建的渲染网格。 + */ + inline const RenderingSubMeshList &getRenderingSubMeshes() { + initialize(); + return _renderingSubMeshes; + } + + void onLoaded() override { + initialize(); + } + + void initialize(); + + /** + * @en Destroy the mesh and release all related GPU resources + * @zh 销毁此网格,并释放它占有的所有 GPU 资源。 + */ + bool destroy() override { + destroyRenderingMesh(); + return Super::destroy(); + } + + /** + * @en Release all related GPU resources + * @zh 释放此网格占有的所有 GPU 资源。 + */ + void destroyRenderingMesh(); + + /** + * @en Reset the struct and data of the mesh + * @zh 重置此网格的结构和数据。 + * @param struct The new struct + * @param data The new data + * @deprecated Will be removed in v3.0.0, please use [[reset]] instead + */ + void assign(const IStruct &structInfo, const Uint8Array &data); + + /** + * @en Reset the mesh with mesh creation information + * @zh 重置此网格。 + * @param info Mesh creation information including struct and data + */ + void reset(ICreateInfo &&info); + + using BoneSpaceBounds = std::vector>; + /** + * @en Get [[AABB]] bounds in the skeleton's bone space + * @zh 获取骨骼变换空间内下的 [[AABB]] 包围盒 + * @param skeleton + */ + BoneSpaceBounds getBoneSpaceBounds(Skeleton *skeleton); + + /** + * @en Merge the given mesh into the current mesh + * @zh 合并指定的网格到此网格中。 + * @param mesh The mesh to be merged + * @param worldMatrix The world matrix of the given mesh + * @param [validate=false] Whether to validate the mesh + * @returns Check the mesh state and return the validation result. + */ + bool merge(Mesh *mesh, const Mat4 *worldMatrix = nullptr, bool validate = false); + + /** + * @en Validation for whether the given mesh can be merged into the current mesh. + * To pass the validation, it must satisfy either of these two requirements: + * - When the current mesh have no data + * - When the two mesh have the same vertex bundle count, the same sub meshes count, and the same sub mesh layout. + * + * Same mesh layout means: + * - They have the same primitive type and reference to the same amount vertex bundle with the same indices. + * - And they all have or don't have index view + * @zh 验证指定网格是否可以合并至当前网格。 + * + * 当满足以下条件之一时,指定网格可以合并至当前网格: + * - 当前网格无数据而待合并网格有数据; + * - 它们的顶点块数目相同且对应顶点块的布局一致,并且它们的子网格数目相同且对应子网格的布局一致。 + * + * 两个顶点块布局一致当且仅当: + * - 它们具有相同数量的顶点属性且对应的顶点属性具有相同的属性格式。 + * + * 两个子网格布局一致,当且仅当: + * - 它们具有相同的图元类型并且引用相同数量、相同索引的顶点块;并且, + * - 要么都需要索引绘制,要么都不需要索引绘制。 + * @param mesh The other mesh to be validated + */ + bool validateMergingMesh(Mesh *mesh); + + /** + * @en Read the requested attribute of the given sub mesh + * @zh 读取子网格的指定属性。 + * @param primitiveIndex Sub mesh index + * @param attributeName Attribute name + * @returns Return null if not found or can't read, otherwise, will create a large enough typed array to contain all data of the attribute, + * the array type will match the data type of the attribute. + */ + TypedArray readAttribute(index_t primitiveIndex, const char *attributeName); + + /** + * @en Read the requested attribute of the given sub mesh and fill into the given buffer. + * @zh 读取子网格的指定属性到目标缓冲区中。 + * @param primitiveIndex Sub mesh index + * @param attributeName Attribute name + * @param buffer The target array buffer + * @param stride Byte distance between two attributes in the target buffer + * @param offset The offset of the first attribute in the target buffer + * @returns Return false if failed to access attribute, return true otherwise. + */ + bool copyAttribute(index_t primitiveIndex, const char *attributeName, ArrayBuffer *buffer, uint32_t stride, uint32_t offset); + + /** + * @en Read the indices data of the given sub mesh + * @zh 读取子网格的索引数据。 + * @param primitiveIndex Sub mesh index + * @returns Return null if not found or can't read, otherwise, will create a large enough typed array to contain all indices data, + * the array type will use the corresponding stride size. + */ + IBArray readIndices(index_t primitiveIndex); + + /** + * @en Read the indices data of the given sub mesh and fill into the given array + * @zh 读取子网格的索引数据到目标数组中。 + * @param primitiveIndex Sub mesh index + * @param outputArray The target output array + * @returns Return false if failed to access the indices data, return true otherwise. + */ + bool copyIndices(index_t primitiveIndex, TypedArray &outputArray); + +private: + using AccessorType = std::function; + + void accessAttribute(index_t primitiveIndex, const char *attributeName, const AccessorType &accessor); + + gfx::BufferList createVertexBuffers(gfx::Device *gfxDevice, ArrayBuffer *data); + + void initDefault(const cc::optional &uuid) override; + bool validate() const override; + + static TypedArray createTypedArrayWithGFXFormat(gfx::Format format, uint32_t count); + +public: + IntrusivePtr morphRendering; + +private: + IStruct _struct; + uint64_t _hash{0}; + Uint8Array _data; + + bool _initialized{false}; + + RenderingSubMeshList _renderingSubMeshes; + + std::unordered_map _boneSpaceBounds; + + JointBufferIndicesType _jointBufferIndices; + + friend class MeshDeserializer; + + CC_DISALLOW_COPY_MOVE_ASSIGN(Mesh); +}; + +} // namespace cc diff --git a/native/cocos/3d/assets/Morph.cpp b/native/cocos/3d/assets/Morph.cpp new file mode 100644 index 0000000000..d54501052a --- /dev/null +++ b/native/cocos/3d/assets/Morph.cpp @@ -0,0 +1,35 @@ +/**************************************************************************** + 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 "3d/assets/Morph.h" +#include "3d/assets/MorphRendering.h" + +namespace cc { + +MorphRendering *createMorphRendering(Mesh *mesh, gfx::Device *gfxDevice) { + return new StdMorphRendering(mesh, gfxDevice); +} + +} // namespace cc diff --git a/native/cocos/3d/assets/Morph.h b/native/cocos/3d/assets/Morph.h new file mode 100644 index 0000000000..b46a65bd14 --- /dev/null +++ b/native/cocos/3d/assets/Morph.h @@ -0,0 +1,83 @@ +/**************************************************************************** + 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 "3d/assets/Types.h" +#include "base/RefCounted.h" +#include "base/TypeDef.h" +#include "scene/Define.h" + +namespace cc { + +class Mesh; +class MorphRendering; +class MorphRenderingInstance; + +namespace gfx { +class Device; +class DescriptorSet; +} // namespace gfx + +MorphRendering *createMorphRendering(Mesh *mesh, gfx::Device *gfxDevice); + +/** + * Class which control rendering of a morph resource. + */ +class MorphRendering : public RefCounted { +public: + ~MorphRendering() override = default; + virtual MorphRenderingInstance *createInstance() = 0; +}; + +/** + * This rendering instance of a morph resource. + */ +class MorphRenderingInstance : public RefCounted { +public: + ~MorphRenderingInstance() override = default; + /** + * Sets weights of targets of specified sub mesh. + * @param subMeshIndex + * @param weights + */ + virtual void setWeights(index_t subMeshIndex, const MeshWeightsType &weights) = 0; + + /** + * Adapts pipeline state to do the rendering. + * @param subMeshIndex + * @param pipelineState + */ + virtual void adaptPipelineState(index_t subMeshIndex, gfx::DescriptorSet *descriptorSet) = 0; + + virtual std::vector requiredPatches(index_t subMeshIndex) = 0; + + /** + * Destroy the rendering instance. + */ + virtual void destroy() = 0; +}; + +} // namespace cc diff --git a/native/cocos/3d/assets/MorphRendering.cpp b/native/cocos/3d/assets/MorphRendering.cpp new file mode 100644 index 0000000000..309d8cc4b5 --- /dev/null +++ b/native/cocos/3d/assets/MorphRendering.cpp @@ -0,0 +1,728 @@ +/**************************************************************************** + 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 "3d/assets/MorphRendering.h" + +#include +#include "3d/assets/Mesh.h" +#include "3d/assets/Morph.h" +#include "base/RefCounted.h" +#include "core/DataView.h" +#include "core/TypedArray.h" +#include "core/assets/RenderingSubMesh.h" +#include "core/assets/Texture2D.h" +#include "platform/Image.h" +#include "renderer/pipeline/Define.h" +#include "scene/Pass.h" + +namespace cc { + +/** + * The instance of once sub-mesh morph rendering. + */ +class SubMeshMorphRenderingInstance : public RefCounted { +public: + ~SubMeshMorphRenderingInstance() override = default; + /** + * Set weights of each morph target. + * @param weights The weights. + */ + virtual void setWeights(const std::vector &weights) = 0; + + /** + * Asks the define overrides needed to do the rendering. + */ + virtual std::vector requiredPatches() = 0; + + /** + * Adapts the pipelineState to apply the rendering. + * @param pipelineState + */ + virtual void adaptPipelineState(gfx::DescriptorSet *descriptorSet) = 0; + + /** + * Destroy this instance. + */ + virtual void destroy() = 0; +}; + +/** + * Describes how to render a sub-mesh morph. + */ +class SubMeshMorphRendering : public RefCounted { +public: + ~SubMeshMorphRendering() override = default; + /** + * Creates a rendering instance. + */ + virtual SubMeshMorphRenderingInstance *createInstance() = 0; +}; + +namespace { +/** + * True if force to use cpu computing based sub-mesh rendering. + */ +const bool PREFER_CPU_COMPUTING = false; + +class MorphTexture final : public RefCounted { +public: + MorphTexture() = default; + + ~MorphTexture() override { + } + /** + * Gets the GFX texture. + */ + gfx::Texture *getTexture() { + return _textureAsset->getGFXTexture(); + } + + /** + * Gets the GFX sampler. + */ + gfx::Sampler *getSampler() { + return _sampler; + } + + /** + * Value view. + */ + Float32Array &getValueView() { + return _valueView; + } + + /** + * Destroy the texture. Release its GPU resources. + */ + void destroy() { + _textureAsset->destroy(); + // Samplers allocated from `samplerLib` are not required and + // should not be destroyed. + // _sampler.destroy(); + } + + /** + * Update the pixels content to `valueView`. + */ + void updatePixels() { + _textureAsset->uploadData(_arrayBuffer->getData()); + } + + void initialize(gfx::Device *gfxDevice, uint32_t width, uint32_t height, uint32_t pixelBytes, bool /*useFloat32Array*/, PixelFormat pixelFormat) { + _arrayBuffer = new ArrayBuffer(width * height * pixelBytes); + _valueView = Float32Array(_arrayBuffer); + + auto * imageAsset = new ImageAsset(); + IMemoryImageSource source{_arrayBuffer, false, width, height, pixelFormat}; + imageAsset->setNativeAsset(source); + + _textureAsset = new Texture2D(); + _textureAsset->setFilters(Texture2D::Filter::NEAREST, Texture2D::Filter::NEAREST); + _textureAsset->setMipFilter(Texture2D::Filter::NONE); + _textureAsset->setWrapMode(Texture2D::WrapMode::CLAMP_TO_EDGE, Texture2D::WrapMode::CLAMP_TO_EDGE, Texture2D::WrapMode::CLAMP_TO_EDGE); + _textureAsset->setImage(imageAsset); + + if (nullptr == _textureAsset->getGFXTexture()) { + CC_LOG_WARNING("Unexpected: failed to create morph texture?"); + } + _sampler = gfxDevice->getSampler(_textureAsset->getSamplerInfo()); + } + +private: + IntrusivePtr _textureAsset; + IntrusivePtr _sampler; + ArrayBuffer::Ptr _arrayBuffer; + Float32Array _valueView; + + CC_DISALLOW_COPY_MOVE_ASSIGN(MorphTexture); +}; + +struct GpuMorphAttribute { + std::string attributeName; + IntrusivePtr morphTexture; +}; + +struct CpuMorphAttributeTarget { + Float32Array displacements; +}; + +using CpuMorphAttributeTargetList = std::vector; + +struct CpuMorphAttribute { + std::string name; + CpuMorphAttributeTargetList targets; +}; + +struct Vec4TextureFactory { + uint32_t width{0}; + uint32_t height{0}; + std::function create{nullptr}; +}; + +/** + * Decides a best texture size to have the specified pixel capacity at least. + * The decided width and height has the following characteristics: + * - the width and height are both power of 2; + * - if the width and height are different, the width would be set to the larger once; + * - the width is ensured to be multiple of 4. + * @param nPixels Least pixel capacity. + */ +bool bestSizeToHavePixels(uint32_t nPixels, uint32_t *pWidth, uint32_t *pHeight) { + if (pWidth == nullptr || pHeight == nullptr) { + if (pWidth != nullptr) { + *pWidth = 0; + } + + if (pHeight != nullptr) { + *pHeight = 0; + } + return false; + } + + if (nPixels < 5) { + nPixels = 5; + } + const uint32_t aligned = pipeline::nextPow2(nPixels); + const auto epxSum = static_cast(std::log2(aligned)); + const uint32_t h = epxSum >> 1; + const uint32_t w = (epxSum & 1) ? (h + 1) : h; + + *pWidth = 1 << w; + *pHeight = 1 << h; + + return true; +} + +/** + * When use vertex-texture-fetch technique, we do need + * `gl_vertexId` when we sample per-vertex data. + * WebGL 1.0 does not have `gl_vertexId`; WebGL 2.0, however, does. + * @param mesh + * @param subMeshIndex + * @param gfxDevice + */ +void enableVertexId(Mesh *mesh, uint32_t subMeshIndex, gfx::Device *gfxDevice) { + mesh->getRenderingSubMeshes()[subMeshIndex]->enableVertexIdChannel(gfxDevice); +} + +/** + * + * @param gfxDevice + * @param vec4Capacity Capacity of vec4. + */ +Vec4TextureFactory createVec4TextureFactory(gfx::Device *gfxDevice, uint32_t vec4Capacity) { + bool hasFeatureFloatTexture = gfxDevice->hasFeature(gfx::Feature::TEXTURE_FLOAT); + + uint32_t pixelRequired = 0; + PixelFormat pixelFormat = PixelFormat::RGBA8888; + uint32_t pixelBytes = 4; + bool useFloat32Array = false; + if (hasFeatureFloatTexture) { + pixelRequired = vec4Capacity; + pixelBytes = 16; + pixelFormat = Texture2D::PixelFormat::RGBA32F; + useFloat32Array = true; + } else { + pixelRequired = 4 * vec4Capacity; + pixelBytes = 4; + pixelFormat = Texture2D::PixelFormat::RGBA8888; + useFloat32Array = false; + } + + uint32_t width = 0; + uint32_t height = 0; + bestSizeToHavePixels(pixelRequired, &width, &height); + CC_ASSERT(width * height >= pixelRequired); + + Vec4TextureFactory ret; + ret.width = width; + ret.height = height; + ret.create = [=]() -> MorphTexture * { + auto *texture = new MorphTexture(); // texture will be held by IntrusivePtr in GpuMorphAttribute + texture->initialize(gfxDevice, width, height, pixelBytes, useFloat32Array, pixelFormat); + return texture; + }; + + return ret; +} + +/** + * Provides the access to morph related uniforms. + */ +class MorphUniforms final : public RefCounted { +public: + MorphUniforms(gfx::Device *gfxDevice, uint32_t targetCount) { + _targetCount = targetCount; + _localBuffer = new DataView(new ArrayBuffer(pipeline::UBOMorph::SIZE)); + + _remoteBuffer = gfxDevice->createBuffer(gfx::BufferInfo{ + gfx::BufferUsageBit::UNIFORM | gfx::BufferUsageBit::TRANSFER_DST, + gfx::MemoryUsageBit::HOST | gfx::MemoryUsageBit::DEVICE, + pipeline::UBOMorph::SIZE, + pipeline::UBOMorph::SIZE, + }); + } + + ~MorphUniforms() override { + delete _localBuffer; + } + + void destroy() { + _remoteBuffer->destroy(); + } + + gfx::Buffer *getBuffer() const { + return _remoteBuffer; + } + + void setWeights(const std::vector &weights) { + CC_ASSERT(weights.size() == _targetCount); + for (size_t iWeight = 0; iWeight < weights.size(); ++iWeight) { + _localBuffer->setFloat32(static_cast(pipeline::UBOMorph::OFFSET_OF_WEIGHTS + 4 * iWeight), weights[iWeight]); + } + } + + void setMorphTextureInfo(float width, float height) { + _localBuffer->setFloat32(pipeline::UBOMorph::OFFSET_OF_DISPLACEMENT_TEXTURE_WIDTH, width); + _localBuffer->setFloat32(pipeline::UBOMorph::OFFSET_OF_DISPLACEMENT_TEXTURE_HEIGHT, height); + } + + void setVerticesCount(uint32_t count) { + _localBuffer->setFloat32(pipeline::UBOMorph::OFFSET_OF_VERTICES_COUNT, static_cast(count)); + } + + void commit() { + ArrayBuffer *buffer = _localBuffer->buffer(); + _remoteBuffer->update(buffer->getData(), buffer->byteLength()); + } + +private: + uint32_t _targetCount{0}; + DataView * _localBuffer{nullptr}; + IntrusivePtr _remoteBuffer; +}; + +class CpuComputing final : public SubMeshMorphRendering { +public: + explicit CpuComputing(Mesh *mesh, uint32_t subMeshIndex, const Morph *morph, gfx::Device *gfxDevice); + + SubMeshMorphRenderingInstance * createInstance() override; + const std::vector &getData() const; + +private: + std::vector _attributes; + gfx::Device * _gfxDevice{nullptr}; +}; + +class GpuComputing final : public SubMeshMorphRendering { +public: + explicit GpuComputing(Mesh *mesh, uint32_t subMeshIndex, const Morph *morph, gfx::Device *gfxDevice); + SubMeshMorphRenderingInstance *createInstance() override; + + void destroy(); + +private: + gfx::Device * _gfxDevice{nullptr}; + const SubMeshMorph * _subMeshMorph{nullptr}; + uint32_t _textureWidth{0}; + uint32_t _textureHeight{0}; + std::vector _attributes; + uint32_t _verticesCount{0}; + + friend class GpuComputingRenderingInstance; +}; + +class CpuComputingRenderingInstance final : public SubMeshMorphRenderingInstance { +public: + explicit CpuComputingRenderingInstance(CpuComputing *owner, uint32_t nVertices, gfx::Device *gfxDevice) { + _owner = owner; //NOTE: release by mesh`s destroy, it`ll call current instance`s destroy method + _morphUniforms = new MorphUniforms(gfxDevice, 0 /* TODO? */); + + auto vec4TextureFactory = createVec4TextureFactory(gfxDevice, nVertices); + _morphUniforms->setMorphTextureInfo(static_cast(vec4TextureFactory.width), static_cast(vec4TextureFactory.height)); + _morphUniforms->commit(); + for (const auto &attributeMorph : _owner->getData()) { + auto *morphTexture = vec4TextureFactory.create(); + _attributes.emplace_back(GpuMorphAttribute{attributeMorph.name, morphTexture}); + } + } + + void setWeights(const std::vector &weights) override { + for (size_t iAttribute = 0; iAttribute < _attributes.size(); ++iAttribute) { + const auto & myAttribute = _attributes[iAttribute]; + Float32Array &valueView = myAttribute.morphTexture->getValueView(); + const auto & attributeMorph = _owner->getData()[iAttribute]; + CC_ASSERT(weights.size() == attributeMorph.targets.size()); + for (size_t iTarget = 0; iTarget < attributeMorph.targets.size(); ++iTarget) { + const auto & targetDisplacements = attributeMorph.targets[iTarget].displacements; + const float weight = weights[iTarget]; + const uint32_t nVertices = targetDisplacements.length() / 3; + if (iTarget == 0) { + for (uint32_t iVertex = 0; iVertex < nVertices; ++iVertex) { + valueView[4 * iVertex + 0] = targetDisplacements[3 * iVertex + 0] * weight; + valueView[4 * iVertex + 1] = targetDisplacements[3 * iVertex + 1] * weight; + valueView[4 * iVertex + 2] = targetDisplacements[3 * iVertex + 2] * weight; + } + } else if (std::fabs(weight) >= std::numeric_limits::epsilon()) { + for (uint32_t iVertex = 0; iVertex < nVertices; ++iVertex) { + valueView[4 * iVertex + 0] += targetDisplacements[3 * iVertex + 0] * weight; + valueView[4 * iVertex + 1] += targetDisplacements[3 * iVertex + 1] * weight; + valueView[4 * iVertex + 2] += targetDisplacements[3 * iVertex + 2] * weight; + } + } + } + + myAttribute.morphTexture->updatePixels(); + } + } + + std::vector requiredPatches() override { + return { + {"CC_MORPH_TARGET_USE_TEXTURE", true}, + {"CC_MORPH_PRECOMPUTED", true}, + }; + } + + void adaptPipelineState(gfx::DescriptorSet *descriptorSet) override { + for (const auto &attribute : _attributes) { + const auto & attributeName = attribute.attributeName; + cc::optional binding; + if (attributeName == gfx::ATTR_NAME_POSITION) { + binding = uint32_t{pipeline::POSITIONMORPH::BINDING}; + } else if (attributeName == gfx::ATTR_NAME_NORMAL) { + binding = uint32_t{pipeline::NORMALMORPH::BINDING}; + } else if (attributeName == gfx::ATTR_NAME_TANGENT) { + binding = uint32_t{pipeline::TANGENTMORPH::BINDING}; + } else { + CC_LOG_WARNING("Unexpected attribute!"); + } + + if (binding.has_value()) { + descriptorSet->bindSampler(binding.value(), attribute.morphTexture->getSampler()); + descriptorSet->bindTexture(binding.value(), attribute.morphTexture->getTexture()); + } + } + descriptorSet->bindBuffer(pipeline::UBOMorph::BINDING, _morphUniforms->getBuffer()); + descriptorSet->update(); + } + + void destroy() override { + CC_SAFE_DESTROY(_morphUniforms); + for (auto &myAttribute : _attributes) { + CC_SAFE_DESTROY(myAttribute.morphTexture); + } + } + +private: + std::vector _attributes; + IntrusivePtr _owner; + IntrusivePtr _morphUniforms; +}; + +class GpuComputingRenderingInstance final : public SubMeshMorphRenderingInstance { +public: + explicit GpuComputingRenderingInstance(GpuComputing *owner, gfx::Device *gfxDevice) { + _owner = owner; + _morphUniforms = new MorphUniforms(gfxDevice, static_cast(_owner->_subMeshMorph->targets.size())); + _morphUniforms->setMorphTextureInfo(static_cast(_owner->_textureWidth), static_cast(_owner->_textureHeight)); + _morphUniforms->setVerticesCount(_owner->_verticesCount); + _morphUniforms->commit(); + _attributes = &_owner->_attributes; + } + + void setWeights(const std::vector &weights) override { + _morphUniforms->setWeights(weights); + _morphUniforms->commit(); + } + + std::vector requiredPatches() override { + return { + {"CC_MORPH_TARGET_USE_TEXTURE", true}, + }; + } + + void adaptPipelineState(gfx::DescriptorSet *descriptorSet) override { + for (const auto &attribute : *_attributes) { + const auto & attributeName = attribute.attributeName; + cc::optional binding; + if (attributeName == gfx::ATTR_NAME_POSITION) { + binding = uint32_t{pipeline::POSITIONMORPH::BINDING}; + } else if (attributeName == gfx::ATTR_NAME_NORMAL) { + binding = uint32_t{pipeline::NORMALMORPH::BINDING}; + } else if (attributeName == gfx::ATTR_NAME_TANGENT) { + binding = uint32_t{pipeline::TANGENTMORPH::BINDING}; + } else { + CC_LOG_WARNING("Unexpected attribute!"); + } + + if (binding.has_value()) { + descriptorSet->bindSampler(binding.value(), attribute.morphTexture->getSampler()); + descriptorSet->bindTexture(binding.value(), attribute.morphTexture->getTexture()); + } + } + descriptorSet->bindBuffer(pipeline::UBOMorph::BINDING, _morphUniforms->getBuffer()); + descriptorSet->update(); + } + + void destroy() override { + } + +private: + std::vector *_attributes{nullptr}; + IntrusivePtr _owner; + IntrusivePtr _morphUniforms; +}; + +CpuComputing::CpuComputing(Mesh *mesh, uint32_t subMeshIndex, const Morph *morph, gfx::Device *gfxDevice) { + _gfxDevice = gfxDevice; + const auto &subMeshMorph = morph->subMeshMorphs[subMeshIndex].value(); + enableVertexId(mesh, subMeshIndex, gfxDevice); + + for (size_t attributeIndex = 0, len = subMeshMorph.attributes.size(); attributeIndex < len; ++attributeIndex) { + const auto &attributeName = subMeshMorph.attributes[attributeIndex]; + + CpuMorphAttribute attr; + attr.name = attributeName; + attr.targets.resize(subMeshMorph.targets.size()); + + uint32_t i = 0; + for (const auto &attributeDisplacement : subMeshMorph.targets) { + const Mesh::IBufferView &displacementsView = attributeDisplacement.displacements[attributeIndex]; + attr.targets[i].displacements = Float32Array(mesh->getData().buffer(), + mesh->getData().byteOffset() + displacementsView.offset, + attributeDisplacement.displacements[attributeIndex].count); + + ++i; + } + + _attributes.emplace_back(attr); + } +} + +SubMeshMorphRenderingInstance *CpuComputing::createInstance() { + return new CpuComputingRenderingInstance( + this, + _attributes[0].targets[0].displacements.length() / 3, + _gfxDevice); +} + +const std::vector &CpuComputing::getData() const { + return _attributes; +} + +GpuComputing::GpuComputing(Mesh *mesh, uint32_t subMeshIndex, const Morph *morph, gfx::Device *gfxDevice) { + _gfxDevice = gfxDevice; + const auto &subMeshMorph = morph->subMeshMorphs[subMeshIndex].value(); + + _subMeshMorph = &subMeshMorph; + // assertIsNonNullable(subMeshMorph); + + enableVertexId(mesh, subMeshIndex, gfxDevice); + + uint32_t nVertices = mesh->getStruct().vertexBundles[mesh->getStruct().primitives[subMeshIndex].vertexBundelIndices[0]].view.count; + _verticesCount = nVertices; + uint32_t nTargets = static_cast(subMeshMorph.targets.size()); + uint32_t vec4Required = nVertices * nTargets; + + auto vec4TextureFactory = createVec4TextureFactory(gfxDevice, vec4Required); + _textureWidth = vec4TextureFactory.width; + _textureHeight = vec4TextureFactory.height; + + // Creates texture for each attribute. + uint32_t attributeIndex = 0; + _attributes.reserve(subMeshMorph.attributes.size()); + for (const auto &attributeName : subMeshMorph.attributes) { + auto * vec4Tex = vec4TextureFactory.create(); + Float32Array &valueView = vec4Tex->getValueView(); + // if (DEV) { // Make it easy to view texture in profilers... + // for (let i = 0; i < valueView.length / 4; ++i) { + // valueView[i * 4 + 3] = 1.0; + // } + // } + + uint32_t morphTargetIndex = 0; + for (const auto &morphTarget : subMeshMorph.targets) { + const auto & displacementsView = morphTarget.displacements[attributeIndex]; + Float32Array displacements(mesh->getData().buffer(), + mesh->getData().byteOffset() + displacementsView.offset, + displacementsView.count); + const uint32_t displacementsOffset = (nVertices * morphTargetIndex) * 4; + for (uint32_t iVertex = 0; iVertex < nVertices; ++iVertex) { + valueView[displacementsOffset + 4 * iVertex + 0] = displacements[3 * iVertex + 0]; + valueView[displacementsOffset + 4 * iVertex + 1] = displacements[3 * iVertex + 1]; + valueView[displacementsOffset + 4 * iVertex + 2] = displacements[3 * iVertex + 2]; + } + + ++morphTargetIndex; + } + + vec4Tex->updatePixels(); + + _attributes.emplace_back(GpuMorphAttribute{attributeName, vec4Tex}); + + ++attributeIndex; + } +} + +SubMeshMorphRenderingInstance *GpuComputing::createInstance() { + return new GpuComputingRenderingInstance(this, _gfxDevice); +} + +void GpuComputing::destroy() { + for (auto &attribute : _attributes) { + attribute.morphTexture->destroy(); + } +} + +} // namespace + +class StdMorphRenderingInstance : public MorphRenderingInstance { +public: + explicit StdMorphRenderingInstance(StdMorphRendering *owner) { + _owner = owner; + size_t nSubMeshes = _owner->_mesh->getStruct().primitives.size(); + _subMeshInstances.resize(nSubMeshes, nullptr); + + for (size_t iSubMesh = 0; iSubMesh < nSubMeshes; ++iSubMesh) { + if (_owner->_subMeshRenderings[iSubMesh] != nullptr) { + _subMeshInstances[iSubMesh] = _owner->_subMeshRenderings[iSubMesh]->createInstance(); + } + } + } + + ~StdMorphRenderingInstance() override = default; + + void setWeights(index_t subMeshIndex, const MeshWeightsType &weights) override { + if (_subMeshInstances[subMeshIndex]) { + _subMeshInstances[subMeshIndex]->setWeights(weights); + } + } + + void adaptPipelineState(index_t subMeshIndex, gfx::DescriptorSet *descriptorSet) override { + if (_subMeshInstances[subMeshIndex]) { + _subMeshInstances[subMeshIndex]->adaptPipelineState(descriptorSet); + } + } + + std::vector requiredPatches(index_t subMeshIndex) override { + CC_ASSERT(_owner->_mesh->getStruct().morph.has_value()); + const auto &subMeshMorphOpt = _owner->_mesh->getStruct().morph.value().subMeshMorphs[subMeshIndex]; + auto * subMeshRenderingInstance = _subMeshInstances[subMeshIndex].get(); + if (subMeshRenderingInstance == nullptr || !subMeshMorphOpt.has_value()) { + return {}; + } + const auto &subMeshMorph = subMeshMorphOpt.value(); + + std::vector patches{ + {"CC_USE_MORPH", true}, + {"CC_MORPH_TARGET_COUNT", static_cast(subMeshMorph.targets.size())}}; + + auto posIter = std::find(subMeshMorph.attributes.begin(), subMeshMorph.attributes.end(), gfx::ATTR_NAME_POSITION); + if (posIter != subMeshMorph.attributes.end()) { + patches.emplace_back(scene::IMacroPatch{ + "CC_MORPH_TARGET_HAS_POSITION", + true, + }); + } + + auto normalIter = std::find(subMeshMorph.attributes.begin(), subMeshMorph.attributes.end(), gfx::ATTR_NAME_NORMAL); + if (normalIter != subMeshMorph.attributes.end()) { + patches.emplace_back(scene::IMacroPatch{ + "CC_MORPH_TARGET_HAS_NORMAL", + true, + }); + } + + auto tangentIter = std::find(subMeshMorph.attributes.begin(), subMeshMorph.attributes.end(), gfx::ATTR_NAME_TANGENT); + if (tangentIter != subMeshMorph.attributes.end()) { + patches.emplace_back(scene::IMacroPatch{ + "CC_MORPH_TARGET_HAS_TANGENT", + true, + }); + } + + auto renderingInstancePatches = subMeshRenderingInstance->requiredPatches(); + for (auto &renderingInstancePatch : renderingInstancePatches) { + patches.emplace_back(renderingInstancePatch); + } + + return patches; + } + + void destroy() override { + for (auto &subMeshInstance : _subMeshInstances) { + if (subMeshInstance != nullptr) { + subMeshInstance->destroy(); + } + } + } + +private: + IntrusivePtr _owner; + std::vector> _subMeshInstances; +}; + +StdMorphRendering::StdMorphRendering(Mesh *mesh, gfx::Device *gfxDevice) { + _mesh = mesh; + const auto &structInfo = _mesh->getStruct(); + if (!structInfo.morph.has_value()) { + return; + } + + const size_t nSubMeshes = structInfo.primitives.size(); + _subMeshRenderings.resize(nSubMeshes, nullptr); + const auto &morph = structInfo.morph.value(); + for (size_t iSubMesh = 0; iSubMesh < nSubMeshes; ++iSubMesh) { + const auto &subMeshMorphHolder = morph.subMeshMorphs[iSubMesh]; + if (!subMeshMorphHolder.has_value()) { + continue; + } + + const auto &subMeshMorph = subMeshMorphHolder.value(); + + if (PREFER_CPU_COMPUTING || subMeshMorph.targets.size() > pipeline::UBOMorph::MAX_MORPH_TARGET_COUNT) { + _subMeshRenderings[iSubMesh] = new CpuComputing( + _mesh, + static_cast(iSubMesh), + &morph, + gfxDevice); + } else { + _subMeshRenderings[iSubMesh] = new GpuComputing( + _mesh, + static_cast(iSubMesh), + &morph, + gfxDevice); + } + } +} + +StdMorphRendering::~StdMorphRendering() = default; + +MorphRenderingInstance *StdMorphRendering::createInstance() { + auto *ret = new StdMorphRenderingInstance(this); + return ret; +} + +} // namespace cc diff --git a/native/cocos/3d/assets/MorphRendering.h b/native/cocos/3d/assets/MorphRendering.h new file mode 100644 index 0000000000..4644e3e63a --- /dev/null +++ b/native/cocos/3d/assets/MorphRendering.h @@ -0,0 +1,55 @@ +/**************************************************************************** + 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 "3d/assets/Morph.h" +#include "base/Ptr.h" + +namespace cc { + +class SubMeshMorphRendering; + +/** + * Standard morph rendering. + * The standard morph rendering renders each of sub-mesh morph separately. + * Sub-mesh morph rendering may select different technique according sub-mesh morph itself. + */ +class StdMorphRendering final : public MorphRendering { +public: + explicit StdMorphRendering(Mesh *mesh, gfx::Device *gfxDevice); + ~StdMorphRendering() override; + MorphRenderingInstance *createInstance() override; + +private: + Mesh * _mesh{nullptr}; + std::vector> _subMeshRenderings; + + CC_DISALLOW_COPY_MOVE_ASSIGN(StdMorphRendering); + + friend class StdMorphRenderingInstance; +}; + +} // namespace cc diff --git a/native/cocos/3d/assets/Skeleton.cpp b/native/cocos/3d/assets/Skeleton.cpp new file mode 100644 index 0000000000..50aadcf078 --- /dev/null +++ b/native/cocos/3d/assets/Skeleton.cpp @@ -0,0 +1,71 @@ +/**************************************************************************** + 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 "3d/assets/Skeleton.h" + +#include +#include + +#include "MurmurHash2/MurmurHash2.h" + +namespace cc { + +const std::vector &Skeleton::getInverseBindposes() { + if (!_invBindposes.has_value()) { + _invBindposes = std::vector{}; + for (const auto &bindpose : _bindposes) { + _invBindposes.value().emplace_back(bindpose.getInversed()); + } + } + return *_invBindposes; +} + +uint64_t Skeleton::getHash() { + // hashes should already be computed offline, but if not, make one + if (!_hash) { + std::stringstream sstr; + for (const auto &ibm : _bindposes) { + sstr << std::fixed << std::setprecision(2) + << ibm.m[0] << " " << ibm.m[1] << " " << ibm.m[2] << " " << ibm.m[3] << " " + << ibm.m[4] << " " << ibm.m[5] << " " << ibm.m[6] << " " << ibm.m[7] << " " + << ibm.m[8] << " " << ibm.m[9] << " " << ibm.m[10] << " " << ibm.m[11] << " " + << ibm.m[12] << " " << ibm.m[13] << " " << ibm.m[14] << " " << ibm.m[15] << "\n"; + } + std::string str{sstr.str()}; + _hash = murmurhash2::MurmurHash2(str.c_str(), static_cast(str.size()), 666); + } + return _hash; +} + +bool Skeleton::destroy() { + //cjh TODO: (legacyCC.director.root?.dataPoolManager as DataPoolManager)?.releaseSkeleton(this); + return Super::destroy(); +} + +bool Skeleton::validate() const { + return !_joints.empty() && !_bindposes.empty(); +} + +} // namespace cc diff --git a/native/cocos/3d/assets/Skeleton.h b/native/cocos/3d/assets/Skeleton.h new file mode 100644 index 0000000000..a168520de7 --- /dev/null +++ b/native/cocos/3d/assets/Skeleton.h @@ -0,0 +1,92 @@ +/**************************************************************************** + 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 "core/assets/Asset.h" + +namespace cc { + +/** + * @en The skeleton asset. It stores the path related to [[SkinnedMeshRenderer.skinningRoot]] of all bones and its bind pose matrix. + * @zh 骨骼资源。骨骼资源记录了每个关节(相对于 [[SkinnedMeshRenderer.skinningRoot]])的路径以及它的绑定姿势矩阵。 + */ +class Skeleton final : public Asset { +public: + using Super = Asset; + Skeleton() = default; + ~Skeleton() override = default; + /** + * @en The path of all bones, the length always equals the length of [[bindposes]] + * @zh 所有关节的路径。该数组的长度始终与 [[bindposes]] 的长度相同。 + */ + inline const std::vector &getJoints() const { + return _joints; + } + + inline void setJoints(const std::vector &value) { + _joints = value; + } + + /** + * @en The bind poses matrix of all bones, the length always equals the length of [[joints]] + * @zh 所有关节的绑定姿势矩阵。该数组的长度始终与 [[joints]] 的长度相同。 + */ + const std::vector &getBindposes() const { + return _bindposes; + } + + void setBindposes(const std::vector &value) { + _bindposes = value; + } + + /** + * @en Gets the inverse bind poses matrix + * @zh 获取反向绑定姿势矩阵 + */ + const std::vector &getInverseBindposes(); + + /** + * @en Gets the hash of the skeleton asset + * @zh 获取骨骼资源的哈希值 + */ + uint64_t getHash(); + void setHash(uint64_t hash) { _hash = hash; } + + inline double getHashForJS() { + return static_cast(getHash()); + } + + bool destroy() override; + bool validate() const override; + +private: + std::vector _joints; + std::vector _bindposes; + cc::optional> _invBindposes; + uint64_t _hash{0}; +}; + +} // namespace cc diff --git a/native/cocos/3d/assets/Types.cpp b/native/cocos/3d/assets/Types.cpp new file mode 100644 index 0000000000..f4f85312ee --- /dev/null +++ b/native/cocos/3d/assets/Types.cpp @@ -0,0 +1,30 @@ +/**************************************************************************** + 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 "3d/assets/Types.h" + +namespace cc { + +} // namespace cc diff --git a/native/cocos/3d/assets/Types.h b/native/cocos/3d/assets/Types.h new file mode 100644 index 0000000000..84dfd0e6dc --- /dev/null +++ b/native/cocos/3d/assets/Types.h @@ -0,0 +1,111 @@ +/**************************************************************************** + 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 +#include +#include +#include "cocos/base/Optional.h" +#include "core/TypedArray.h" +namespace cc { + +struct IMeshBufferView { + uint32_t offset{0}; + uint32_t length{0}; + uint32_t count{0}; + uint32_t stride{0}; +}; + +using MeshWeightsType = std::vector; + +/** + * @en Array views for index buffer + * @zh 允许存储索引的数组视图 + */ +using IBArray = cc::variant; + +template +T getIBArrayValue(const IBArray &arr, uint32_t idx) { +#define IBARRAY_GET_VALUE(type) \ + do { \ + auto *p = cc::get_if(&arr); \ + if (p != nullptr) { \ + return static_cast((*p)[idx]); \ + } \ + } while (false) + + IBARRAY_GET_VALUE(Uint16Array); + IBARRAY_GET_VALUE(Uint32Array); + IBARRAY_GET_VALUE(Uint8Array); + +#undef IBARRAY_GET_VALUE + + return 0; +} + +struct MorphTarget { + /** + * Displacement of each target attribute. + */ + std::vector displacements; +}; + +struct SubMeshMorph { + /** + * Attributes to morph. + */ + std::vector attributes; + + /** + * Targets. + */ + std::vector targets; + + /** + * Initial weights of each target. + */ + cc::optional weights; +}; + +struct Morph { + /** + * Morph data of each sub-mesh. + */ + std::vector> subMeshMorphs; + + /** + * Common initial weights of each sub-mesh. + */ + cc::optional weights; + + /** + * Name of each target of each sub-mesh morph. + * This field is only meaningful if every sub-mesh has the same number of targets. + */ + cc::optional> targetNames; +}; + +} // namespace cc diff --git a/native/cocos/3d/misc/Buffer.cpp b/native/cocos/3d/misc/Buffer.cpp new file mode 100644 index 0000000000..399b1a00e2 --- /dev/null +++ b/native/cocos/3d/misc/Buffer.cpp @@ -0,0 +1,116 @@ +/**************************************************************************** + 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 "3d/misc/Buffer.h" +#include "cocos/base/Variant.h" + +namespace cc { + +namespace { +Record typeMap{ + {gfx::FormatType::UNORM, "Uint"}, + {gfx::FormatType::SNORM, "Int"}, + {gfx::FormatType::UINT, "Uint"}, + {gfx::FormatType::INT, "Int"}, + {gfx::FormatType::UFLOAT, "Float"}, + {gfx::FormatType::FLOAT, "Float"}, +}; + +std::string getDataViewType(const gfx::FormatInfo &info) { + std::string type; + auto iter = typeMap.find(info.type); + if (iter != typeMap.end()) { + type = iter->second; + } else { + type = "Uint"; + } + + const uint32_t bytes = info.size / info.count * 8; + return type + std::to_string(bytes); +} + +} // namespace + +using DataVariant = cc::variant; +using MapBufferCallback = std::function; + +DataView mapBuffer(DataView & target, + const MapBufferCallback & callback, + cc::optional aFormat, + cc::optional aOffset, + cc::optional aLength, + cc::optional aStride, + DataView * out) { + gfx::Format format = aFormat.has_value() ? aFormat.value() : gfx::Format::R32F; + uint32_t offset = aOffset.has_value() ? aOffset.value() : 0; + uint32_t length = aLength.has_value() ? aLength.value() : target.byteLength() - offset; + uint32_t stride = aStride.has_value() ? aStride.value() : 0; + + DataView dataView; + if (out == nullptr) { + out = &dataView; + dataView.assign(target.buffer()->slice(target.byteOffset(), target.byteOffset() + target.byteLength())); + } + + const auto &info = gfx::GFX_FORMAT_INFOS[static_cast(format)]; + if (stride == 0) { + stride = info.size; + } + + static const std::string SET_PREFIX{"set"}; + static const std::string GET_PREFIX{"get"}; + + bool isFloat = info.type == gfx::FormatType::FLOAT || info.type == gfx::FormatType::UFLOAT; + DataView::IntWritter intWritter = nullptr; + if (!isFloat) { + intWritter = DataView::intWritterMap[SET_PREFIX + getDataViewType(info)]; + } + + DataView::ReaderVariant intReader; + if (!isFloat) { + intReader = DataView::intReaderMap[GET_PREFIX + getDataViewType(info)]; + } + + const uint32_t componentBytesLength = info.size / info.count; + const uint32_t nSeg = std::floor(length / stride); + + for (uint32_t iSeg = 0; iSeg < nSeg; ++iSeg) { + const uint32_t x = offset + stride * iSeg; + for (uint32_t iComponent = 0; iComponent < info.count; ++iComponent) { + const uint32_t y = x + componentBytesLength * iComponent; + if (isFloat) { + float cur = target.getFloat32(y); + out->setFloat32(y, cc::get<1>(callback(cur, iComponent, target))); + } else { + int32_t cur = target.readInt(intReader, y); + // iComponent is usually more useful than y + (target.*intWritter)(y, cc::get<0>(callback(cur, iComponent, target))); + } + } + } + return dataView; +} + +} // namespace cc diff --git a/native/cocos/3d/misc/Buffer.h b/native/cocos/3d/misc/Buffer.h new file mode 100644 index 0000000000..93bfd05087 --- /dev/null +++ b/native/cocos/3d/misc/Buffer.h @@ -0,0 +1,125 @@ +/**************************************************************************** + 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 "cocos/base/Optional.h" +#include "core/DataView.h" +#include "renderer/gfx-base/GFXDef.h" + +namespace cc { + +// default params behaviors just like on an plain, compact Float32Array +template +void writeBuffer(DataView & target, + const std::vector &data, + const gfx::Format & format = gfx::Format::R32F, + uint32_t offset = 0, + uint32_t stride = 0) { + const gfx::FormatInfo &info = gfx::GFX_FORMAT_INFOS[static_cast(format)]; + if (stride == 0) { + stride = info.size; + } + const uint32_t componentBytesLength = info.size / info.count; + const uint32_t nSeg = static_cast(std::floor(data.size() / info.count)); + + const uint32_t bytes = info.size / info.count * 8; + + for (uint32_t iSeg = 0; iSeg < nSeg; ++iSeg) { + uint32_t x = offset + stride * iSeg; + for (uint32_t iComponent = 0; iComponent < info.count; ++iComponent) { + const uint32_t y = x + componentBytesLength * iComponent; + // default Little-Endian + switch (info.type) { + case gfx::FormatType::UINT: + case gfx::FormatType::UNORM: + switch (bytes) { + case 8: + target.setUint8(y, static_cast(data[info.count * iSeg + iComponent])); + break; + case 16: + target.setUint16(y, static_cast(data[info.count * iSeg + iComponent])); + break; + case 32: + target.setUint32(y, static_cast(data[info.count * iSeg + iComponent])); + break; + default: + CC_ASSERT(false); + break; + } + break; + case gfx::FormatType::INT: + case gfx::FormatType::SNORM: + switch (bytes) { + case 8: + target.setInt8(y, static_cast(data[info.count * iSeg + iComponent])); + break; + case 16: + target.setInt16(y, static_cast(data[info.count * iSeg + iComponent])); + break; + case 32: + target.setInt32(y, static_cast(data[info.count * iSeg + iComponent])); + break; + default: + CC_ASSERT(false); + break; + } + break; + case gfx::FormatType::UFLOAT: + case gfx::FormatType::FLOAT: + switch (bytes) { + case 8: + target.setFloat32(y, static_cast(data[info.count * iSeg + iComponent])); + break; + case 16: + target.setFloat32(y, static_cast(data[info.count * iSeg + iComponent])); + break; + case 32: + target.setFloat32(y, static_cast(data[info.count * iSeg + iComponent])); + break; + default: + CC_ASSERT(false); + break; + } + break; + default: + CC_ASSERT(false); + break; + } + } + } +} + +using DataVariant = cc::variant; +using MapBufferCallback = std::function; + +DataView mapBuffer(DataView & target, + const MapBufferCallback & callback, + cc::optional aFormat, + cc::optional aOffset, + cc::optional aLength, + cc::optional aStride, + DataView * out); + +} // namespace cc diff --git a/native/cocos/3d/misc/BufferBlob.cpp b/native/cocos/3d/misc/BufferBlob.cpp new file mode 100644 index 0000000000..202b872975 --- /dev/null +++ b/native/cocos/3d/misc/BufferBlob.cpp @@ -0,0 +1,64 @@ +/**************************************************************************** + 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 "3d/misc/BufferBlob.h" +#include "core/TypedArray.h" + +namespace cc { + +void BufferBlob::setNextAlignment(uint32_t align) { + if (align != 0) { + const uint32_t remainder = _length % align; + if (remainder != 0) { + const uint32_t padding = align - remainder; + _arrayBufferOrPaddings.emplace_back(padding); + _length += padding; + } + } +} + +uint32_t BufferBlob::addBuffer(ArrayBuffer *arrayBuffer) { + const uint32_t result = _length; + _arrayBufferOrPaddings.emplace_back(arrayBuffer); + _length += arrayBuffer->byteLength(); + return result; +} + +ArrayBuffer::Ptr BufferBlob::getCombined() { + Int8Array result(_length); + uint32_t counter = 0; + + for (const auto &arrayBufferOrPadding : _arrayBufferOrPaddings) { + if (const auto *p = cc::get_if(&arrayBufferOrPadding)) { + counter += *p; + } else if (const auto *p = cc::get_if(&arrayBufferOrPadding)) { + result.set(*p, counter); + counter += (*p)->byteLength(); + } + } + + return result.buffer(); +} + +} // namespace cc diff --git a/native/cocos/3d/misc/BufferBlob.h b/native/cocos/3d/misc/BufferBlob.h new file mode 100644 index 0000000000..be923a6a38 --- /dev/null +++ b/native/cocos/3d/misc/BufferBlob.h @@ -0,0 +1,48 @@ +/**************************************************************************** + 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 +#include "cocos/base/Variant.h" +#include "core/ArrayBuffer.h" + +namespace cc { + +class BufferBlob { +public: + void setNextAlignment(uint32_t align); + + uint32_t addBuffer(ArrayBuffer *arrayBuffer); + + inline uint32_t getLength() const { return _length; } + + ArrayBuffer::Ptr getCombined(); + +private: + std::vector> _arrayBufferOrPaddings; + uint32_t _length{0}; +}; + +} // namespace cc diff --git a/native/cocos/3d/misc/CreateMesh.cpp b/native/cocos/3d/misc/CreateMesh.cpp new file mode 100644 index 0000000000..6bd4290158 --- /dev/null +++ b/native/cocos/3d/misc/CreateMesh.cpp @@ -0,0 +1,247 @@ +#include "3d/misc/CreateMesh.h" +#include +#include "3d/assets/Mesh.h" +#include "3d/misc/BufferBlob.h" +#include "3d/misc/Buffer.h" +#include "core/ArrayBuffer.h" +#include "core/DataView.h" +#include "renderer/gfx-base/GFXDef-common.h" + +namespace cc { +namespace { +gfx::AttributeList defAttrs = { + gfx::Attribute{gfx::ATTR_NAME_POSITION, gfx::Format::RGB32F}, + gfx::Attribute{gfx::ATTR_NAME_NORMAL, gfx::Format::RGB32F}, + gfx::Attribute{gfx::ATTR_NAME_TEX_COORD, gfx::Format::RG32F}, + gfx::Attribute{gfx::ATTR_NAME_TANGENT, gfx::Format::RGBA32F}, + gfx::Attribute{gfx::ATTR_NAME_COLOR, gfx::Format::RGBA32F}, +}; +} // namespace + +Mesh::ICreateInfo createMeshInfo(const IGeometry &geometry, const ICreateMeshOptions &options /* = {}*/) { + // Collect attributes and calculate length of result vertex buffer. + gfx::AttributeList attributes; + uint32_t stride = 0; + struct Channel { + uint32_t offset{0}; + std::vector data; // float? + gfx::Attribute attribute; + }; + std::vector channels; + uint32_t vertCount = 0; + + const gfx::Attribute *attr = nullptr; + + std::vector positions(geometry.positions); + + if (!positions.empty()) { + attr = nullptr; + if (geometry.attributes.has_value()) { + for (const auto &att : geometry.attributes.value()) { + if (att.name == gfx::ATTR_NAME_POSITION) { + attr = &att; + break; + } + } + } + + if (attr == nullptr) { + attr = &defAttrs[0]; + } + + attributes.emplace_back(*attr); + const auto &info = gfx::GFX_FORMAT_INFOS[static_cast(attr->format)]; + vertCount = std::max(vertCount, static_cast(std::floor(positions.size() / info.count))); + channels.emplace_back(Channel{stride, positions, *attr}); + stride += info.size; + } + + if (geometry.normals.has_value() && !geometry.normals.value().empty()) { + attr = nullptr; + if (geometry.attributes.has_value()) { + for (const auto &att : geometry.attributes.value()) { + if (att.name == gfx::ATTR_NAME_NORMAL) { + attr = &att; + break; + } + } + } + + if (attr == nullptr) { + attr = &defAttrs[1]; + } + + attributes.emplace_back(*attr); + const auto &info = gfx::GFX_FORMAT_INFOS[static_cast(attr->format)]; + vertCount = std::max(vertCount, static_cast(std::floor(geometry.normals->size() / info.count))); + channels.emplace_back(Channel{stride, geometry.normals.value(), *attr}); + stride += info.size; + } + + if (geometry.uvs.has_value() && !geometry.uvs.value().empty()) { + attr = nullptr; + if (geometry.attributes.has_value()) { + for (const auto &att : geometry.attributes.value()) { + if (att.name == gfx::ATTR_NAME_TEX_COORD) { + attr = &att; + break; + } + } + } + + if (attr == nullptr) { + attr = &defAttrs[2]; + } + + attributes.emplace_back(*attr); + const auto &info = gfx::GFX_FORMAT_INFOS[static_cast(attr->format)]; + vertCount = std::max(vertCount, static_cast(std::floor(geometry.uvs->size() / info.count))); + channels.emplace_back(Channel{stride, geometry.uvs.value(), *attr}); + stride += info.size; + } + + if (geometry.tangents.has_value() && !geometry.tangents.value().empty()) { + attr = nullptr; + if (geometry.attributes.has_value()) { + for (const auto &att : geometry.attributes.value()) { + if (att.name == gfx::ATTR_NAME_TANGENT) { + attr = &att; + break; + } + } + } + + if (attr == nullptr) { + attr = &defAttrs[3]; + } + + attributes.emplace_back(*attr); + const auto &info = gfx::GFX_FORMAT_INFOS[static_cast(attr->format)]; + vertCount = std::max(vertCount, static_cast(std::floor(geometry.tangents->size() / info.count))); + channels.emplace_back(Channel{stride, geometry.tangents.value(), *attr}); + stride += info.size; + } + + if (geometry.colors.has_value() && !geometry.colors.value().empty()) { + attr = nullptr; + if (geometry.attributes.has_value()) { + for (const auto &att : geometry.attributes.value()) { + if (att.name == gfx::ATTR_NAME_COLOR) { + attr = &att; + break; + } + } + } + + if (attr == nullptr) { + attr = &defAttrs[4]; + } + + attributes.emplace_back(*attr); + const auto &info = gfx::GFX_FORMAT_INFOS[static_cast(attr->format)]; + vertCount = std::max(vertCount, static_cast(std::floor(geometry.colors->size() / info.count))); + channels.emplace_back(Channel{stride, geometry.colors.value(), *attr}); + stride += info.size; + } + + if (geometry.customAttributes.has_value()) { + for (auto ca : geometry.customAttributes.value()) { + const auto &info = gfx::GFX_FORMAT_INFOS[static_cast(attr->format)]; + attributes.emplace_back(ca.attr); + vertCount = std::max(vertCount, static_cast(std::floor(ca.values.size() / info.count))); + channels.emplace_back(Channel{stride, ca.values, ca.attr}); + stride += info.size; + } + } + + // Use this to generate final merged buffer. + BufferBlob bufferBlob; + + // Fill vertex buffer. + auto * vertexBuffer = new ArrayBuffer(vertCount * stride); + DataView vertexBufferView(vertexBuffer); + for (const auto &channel : channels) { + writeBuffer(vertexBufferView, channel.data, channel.attribute.format, channel.offset, stride); + } + bufferBlob.setNextAlignment(0); + Mesh::IVertexBundle vertexBundle; + Mesh::IBufferView buffferView; + + buffferView.offset = bufferBlob.getLength(); + buffferView.length = static_cast(vertexBuffer->byteLength()); + buffferView.count = vertCount; + buffferView.stride = stride; + vertexBundle.attributes = attributes; + vertexBundle.view = buffferView; + + bufferBlob.addBuffer(vertexBuffer); + + // Fill index buffer. + ArrayBuffer * indexBuffer{nullptr}; + uint32_t idxCount = 0; + const uint32_t idxStride = 2; + if (geometry.indices.has_value()) { + const std::vector &indices = geometry.indices.value(); + idxCount = static_cast(indices.size()); + indexBuffer = new ArrayBuffer(idxStride * idxCount); + DataView indexBufferView(indexBuffer); + writeBuffer(indexBufferView, indices, gfx::Format::R16UI); + } + + // Create primitive. + Mesh::ISubMesh primitive; + primitive.vertexBundelIndices = {0}; + primitive.primitiveMode = geometry.primitiveMode.has_value() ? geometry.primitiveMode.value() : gfx::PrimitiveMode::TRIANGLE_LIST; + + if (indexBuffer) { + bufferBlob.setNextAlignment(idxStride); + Mesh::IBufferView bufferView; + bufferView.offset = bufferBlob.getLength(); + bufferView.length = indexBuffer->byteLength(); + bufferView.count = idxCount; + bufferView.stride = idxStride; + primitive.indexView = bufferView; + bufferBlob.addBuffer(indexBuffer); + } + + cc::optional minPosition = geometry.minPos; + if (minPosition.has_value() && options.calculateBounds.has_value() && options.calculateBounds.value()) { + minPosition = Vec3(std::numeric_limits::infinity(), std::numeric_limits::infinity(), std::numeric_limits::infinity()); + for (uint32_t iVertex = 0; iVertex < vertCount; ++iVertex) { + Vec3::min(minPosition.value(), Vec3(positions[iVertex * 3 + 0], positions[iVertex * 3 + 1], positions[iVertex * 3 + 2]), &minPosition.value()); + } + } + + cc::optional maxPosition = geometry.maxPos; + if (maxPosition.has_value() && options.calculateBounds.has_value() && options.calculateBounds.value()) { + maxPosition = Vec3(-std::numeric_limits::infinity(), -std::numeric_limits::infinity(), -std::numeric_limits::infinity()); + for (uint32_t iVertex = 0; iVertex < vertCount; ++iVertex) { + Vec3::max(maxPosition.value(), Vec3(positions[iVertex * 3 + 0], positions[iVertex * 3 + 1], positions[iVertex * 3 + 2]), &maxPosition.value()); + } + } + + // Create mesh struct + Mesh::IStruct meshStruct; + meshStruct.vertexBundles = {vertexBundle}; + meshStruct.primitives = {primitive}; + + if (minPosition.has_value()) { + meshStruct.minPosition = minPosition.value(); + } + if (maxPosition.has_value()) { + meshStruct.maxPosition = maxPosition.value(); + } + + Mesh::ICreateInfo createInfo; + createInfo.structInfo = std::move(meshStruct); + createInfo.data = Uint8Array(bufferBlob.getCombined()); + return createInfo; +} + +Mesh *createMesh(const IGeometry &geometry, const ICreateMeshOptions &options /* = {}*/) { + auto *out = new Mesh(); + out->reset(createMeshInfo(geometry, options)); + return out; +} + +} // namespace cc diff --git a/native/cocos/3d/misc/CreateMesh.h b/native/cocos/3d/misc/CreateMesh.h new file mode 100644 index 0000000000..dd646b1041 --- /dev/null +++ b/native/cocos/3d/misc/CreateMesh.h @@ -0,0 +1,41 @@ +/**************************************************************************** + 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 "cocos/base/Optional.h" + +#include "3d/assets/Mesh.h" +#include "primitive/PrimitiveDefine.h" + +namespace cc { + +struct ICreateMeshOptions { + cc::optional calculateBounds; +}; + +Mesh * createMesh(const IGeometry &geometry, const ICreateMeshOptions &options = {}); +Mesh::ICreateInfo createMeshInfo(const IGeometry &geometry, const ICreateMeshOptions &options = {}); + +} // namespace cc diff --git a/native/cocos/3d/models/BakedSkinningModel.cpp b/native/cocos/3d/models/BakedSkinningModel.cpp new file mode 100644 index 0000000000..dc78de64c0 --- /dev/null +++ b/native/cocos/3d/models/BakedSkinningModel.cpp @@ -0,0 +1,242 @@ +/**************************************************************************** + 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 "3d/models/BakedSkinningModel.h" +#include "3d/assets/Mesh.h" +//#include "3d/skeletal-animation/DataPoolManager.h" +#include "core/Root.h" +#include "scene/Model.h" +#include "scene/SubModel.h" + +namespace { +const cc::gfx::SamplerInfo JOINT_TEXTURE_SAMPLER_INFO{ + cc::gfx::Filter::POINT, + cc::gfx::Filter::POINT, + cc::gfx::Filter::NONE, + cc::gfx::Address::CLAMP, + cc::gfx::Address::CLAMP, + cc::gfx::Address::CLAMP, +}; + +std::vector myPatches{ + {"CC_USE_SKINNING", true}, + {"CC_USE_BAKED_ANIMATION", true}}; + +const std::string INST_JOINT_ANIM_INFO = "a_jointAnimInfo"; +} // namespace +namespace cc { + +BakedSkinningModel::BakedSkinningModel() +: Super() +//, _dataPoolManager(Root::getInstance()->getDataPoolManager()) +{ + _type = Model::Type::BAKED_SKINNING; + _jointMedium.jointTextureInfo.reset(4); + // JSB uses _dataPoolManager in JS and the data is synchronized by syncDataForJS & syncAnimInfoForJS + // _jointMedium.animInfo = _dataPoolManager->jointAnimationInfo->getData(); +} + +void BakedSkinningModel::destroy() { + // CC_SAFE_DELETE(uploadedAnim); + _jointMedium.boundsInfo.clear(); + + if (_jointMedium.buffer != nullptr) { + CC_SAFE_DESTROY(_jointMedium.buffer); + } + applyJointTexture(cc::nullopt); + Super::destroy(); +} + +void BakedSkinningModel::bindSkeleton(Skeleton *skeleton, Node *skinningRoot, Mesh *mesh) { + _skeleton = skeleton; + _mesh = mesh; + if (skeleton == nullptr || skinningRoot == nullptr || mesh == nullptr) return; + setTransform(skinningRoot); + + // JSB uses _dataPoolManager in JS and the data is synchronized by syncDataForJS & syncAnimInfoForJS + // _jointMedium.animInfo = _dataPoolManager->jointAnimationInfo->getData(skinningRoot->getUuid()); + + if (_jointMedium.buffer == nullptr) { + _jointMedium.buffer = _device->createBuffer({ + gfx::BufferUsageBit::UNIFORM | gfx::BufferUsageBit::TRANSFER_DST, + gfx::MemoryUsageBit::DEVICE, + pipeline::UBOSkinning::SIZE, + pipeline::UBOSkinning::SIZE, + }); + } +} + +void BakedSkinningModel::updateTransform(uint32_t stamp) { + Super::updateTransform(stamp); + if (!_isUploadedAnim) { + return; + } + IAnimInfo & animInfo = _jointMedium.animInfo; + geometry::AABB *skelBound = nullptr; + const float * curFrame = animInfo.curFrame; + // float curFrame = info.data[0]; + auto index = static_cast(std::roundf(*curFrame)); + if (!_jointMedium.boundsInfo.empty() && index < _jointMedium.boundsInfo.size()) { + skelBound = &_jointMedium.boundsInfo[index].value(); + } + + if (_worldBounds && skelBound != nullptr) { + Node *node = getTransform(); + skelBound->transform(node->getWorldMatrix(), _worldBounds); + } +} + +void BakedSkinningModel::updateUBOs(uint32_t stamp) { + Super::updateUBOs(stamp); + + IAnimInfo & info = _jointMedium.animInfo; + int idx = _instAnimInfoIdx; + const float *curFrame = info.curFrame; + uint32_t frameDataBytes = info.frameDataBytes; + // float curFrame = info.data[0]; + // uint32_t curFrameDataBytes = info.data.byteLength(); + if (idx >= 0) { + auto &views = getInstancedAttributeBlock()->views[idx]; + setTypedArrayValue(views, 0, *curFrame); + } else if (*info.dirtyForJSB != 0) { + info.buffer->update(curFrame, frameDataBytes); + *info.dirtyForJSB = 0; + } +} + +void BakedSkinningModel::applyJointTexture(const cc::optional &texture) { + auto oldTex = _jointMedium.texture; + if (oldTex.has_value() && texture.has_value() && (&oldTex.value() != &texture.value())) { + // _dataPoolManager->jointTexturePool->releaseHandle(oldTex.value()); + } + _jointMedium.texture = texture; + if (!texture.has_value()) { + return; + } + auto *buffer = _jointMedium.buffer.get(); + auto &jointTextureInfo = _jointMedium.jointTextureInfo; + jointTextureInfo[0] = static_cast(texture->handle.texture->getWidth()); + jointTextureInfo[1] = static_cast(_skeleton->getJoints().size()); + jointTextureInfo[2] = static_cast(texture->pixelOffset) + 0.1F; // guard against floor() underflow + jointTextureInfo[3] = 1 / jointTextureInfo[0]; + updateInstancedJointTextureInfo(); + if (buffer != nullptr) { + buffer->update(&jointTextureInfo[0], jointTextureInfo.byteLength()); + } + auto *tex = texture->handle.texture; + + for (const auto &subModel : _subModels) { + auto *descriptorSet = subModel->getDescriptorSet(); + descriptorSet->bindTexture(pipeline::JOINTTEXTURE::BINDING, tex); + } +} + +std::vector &BakedSkinningModel::getMacroPatches(index_t subModelIndex) { + auto &patches = Super::getMacroPatches(subModelIndex); + patches.reserve(patches.size() + myPatches.size()); + patches.insert(std::end(patches), std::begin(myPatches), std::end(myPatches)); + return patches; +} + +void BakedSkinningModel::updateLocalDescriptors(index_t subModelIndex, gfx::DescriptorSet *descriptorSet) { + Super::updateLocalDescriptors(subModelIndex, descriptorSet); + gfx::Buffer * buffer = _jointMedium.buffer; + auto & texture = _jointMedium.texture; + const IAnimInfo &animInfo = _jointMedium.animInfo; + descriptorSet->bindBuffer(pipeline::UBOSkinningTexture::BINDING, buffer); + descriptorSet->bindBuffer(pipeline::UBOSkinningAnimation::BINDING, animInfo.buffer); + if (texture.has_value()) { + auto *sampler = _device->getSampler(JOINT_TEXTURE_SAMPLER_INFO); + descriptorSet->bindTexture(pipeline::JOINTTEXTURE::BINDING, texture->handle.texture); + descriptorSet->bindSampler(pipeline::JOINTTEXTURE::BINDING, sampler); + } +} + +void BakedSkinningModel::updateInstancedAttributes(const std::vector &attributes, scene::Pass *pass) { + Super::updateInstancedAttributes(attributes, pass); + _instAnimInfoIdx = getInstancedAttributeIndex(INST_JOINT_ANIM_INFO); + updateInstancedJointTextureInfo(); +} + +void BakedSkinningModel::updateInstancedJointTextureInfo() { + const auto & jointTextureInfo = _jointMedium.jointTextureInfo; + const IAnimInfo &animInfo = _jointMedium.animInfo; + index_t idx = _instAnimInfoIdx; + if (idx >= 0) { + auto &view = getInstancedAttributeBlock()->views[idx]; + setTypedArrayValue(view, 0, *animInfo.curFrame); //NOTE: curFrame is only used in JSB. + setTypedArrayValue(view, 1, jointTextureInfo[1]); + setTypedArrayValue(view, 2, jointTextureInfo[2]); + } +} + +void BakedSkinningModel::syncAnimInfoForJS(gfx::Buffer *buffer, const Float32Array &data, Uint8Array &dirty) { + _jointMedium.animInfo.buffer = buffer; + _jointMedium.animInfo.curFrame = &data[0]; + _jointMedium.animInfo.frameDataBytes = data.byteLength(); + _jointMedium.animInfo.dirtyForJSB = &dirty[0]; +} + +void BakedSkinningModel::syncDataForJS(const std::vector> &boundsInfo, + const cc::optional & modelBound, + float jointTextureInfo0, + float jointTextureInfo1, + float jointTextureInfo2, + float jointTextureInfo3, + gfx::Texture * tex, + const Float32Array & animInfoData) { + _jointMedium.boundsInfo = boundsInfo; + + if (modelBound.has_value()) { + const geometry::AABB &modelBounldValue = modelBound.value(); + _modelBounds->set(modelBounldValue.center, modelBounldValue.halfExtents); + } else { + _modelBounds = nullptr; + } + + _jointMedium.jointTextureInfo[0] = jointTextureInfo0; + _jointMedium.jointTextureInfo[1] = jointTextureInfo1; + _jointMedium.jointTextureInfo[2] = jointTextureInfo2; + _jointMedium.jointTextureInfo[3] = jointTextureInfo3; + + _jointMedium.animInfo.curFrame = &animInfoData[0]; + _jointMedium.animInfo.frameDataBytes = animInfoData.byteLength(); + IJointTextureHandle textureInfo; + textureInfo.handle.texture = tex; + _jointMedium.texture = std::move(textureInfo); + + updateInstancedJointTextureInfo(); + + auto *buffer = _jointMedium.buffer.get(); + if (buffer != nullptr) { + buffer->update(&_jointMedium.jointTextureInfo[0], _jointMedium.jointTextureInfo.byteLength()); + } + + for (const auto &subModel : _subModels) { + auto *descriptorSet = subModel->getDescriptorSet(); + descriptorSet->bindTexture(pipeline::JOINTTEXTURE::BINDING, tex); + } +} + +} // namespace cc diff --git a/native/cocos/3d/models/BakedSkinningModel.h b/native/cocos/3d/models/BakedSkinningModel.h new file mode 100644 index 0000000000..2cbb5d614f --- /dev/null +++ b/native/cocos/3d/models/BakedSkinningModel.h @@ -0,0 +1,105 @@ +/**************************************************************************** + 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 + +#include "3d/assets/Skeleton.h" +#include "3d/models/MorphModel.h" +#include "3d/skeletal-animation/SkeletalAnimationUtils.h" +#include "core/scene-graph/Node.h" +#include "gfx-base/GFXDef-common.h" + +namespace cc { + +namespace gfx { +class Texture; +} + +class DataPoolManager; + +struct BakedJointInfo { + IntrusivePtr buffer; + Float32Array jointTextureInfo; + cc::optional texture; + IAnimInfo animInfo; + std::vector> boundsInfo; +}; + +class BakedSkinningModel final : public MorphModel { +public: + using Super = MorphModel; + BakedSkinningModel(); + ~BakedSkinningModel() override = default; + + void destroy() override; + + std::vector &getMacroPatches(index_t subModelIndex) override; + void updateLocalDescriptors(index_t subModelIndex, gfx::DescriptorSet *descriptorSet) override; + void updateTransform(uint32_t stamp) override; + void updateUBOs(uint32_t stamp) override; + void updateInstancedAttributes(const std::vector &attributes, scene::Pass *pass) override; + void updateInstancedJointTextureInfo(); + // void uploadAnimation(AnimationClip *anim); // TODO(xwx): AnimationClip not define + + void bindSkeleton(Skeleton *skeleton, Node *skinningRoot, Mesh *mesh); + + inline void updateModelBounds(geometry::AABB *modelBounds) { + if (modelBounds == nullptr) { + return; + } + _modelBounds->setValid(true); + _modelBounds->set(modelBounds->getCenter(), modelBounds->getHalfExtents()); + } + + void syncAnimInfoForJS(gfx::Buffer *buffer, const Float32Array &data, Uint8Array &dirty); + void syncDataForJS(const std::vector> &boundsInfo, + const cc::optional & modelBound, + float jointTextureInfo0, + float jointTextureInfo1, + float jointTextureInfo2, + float jointTextureInfo3, + gfx::Texture * tex, + const Float32Array & animInfoData); + + void setUploadedAnimForJS(bool value) { _isUploadedAnim = value; } + +protected: + void applyJointTexture(const cc::optional &texture); + +private: + BakedJointInfo _jointMedium; + index_t _instAnimInfoIdx{CC_INVALID_INDEX}; + // IntrusivePtr _dataPoolManager; + IntrusivePtr _skeleton; + IntrusivePtr _mesh; + // AnimationClip* uploadedAnim; + bool _isUploadedAnim{false}; + + CC_DISALLOW_COPY_MOVE_ASSIGN(BakedSkinningModel); +}; + +} // namespace cc diff --git a/native/cocos/3d/models/MorphModel.cpp b/native/cocos/3d/models/MorphModel.cpp new file mode 100644 index 0000000000..1a05792ffe --- /dev/null +++ b/native/cocos/3d/models/MorphModel.cpp @@ -0,0 +1,61 @@ +/**************************************************************************** + 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 "3d/models/MorphModel.h" +#include "core/event/EventTypesToJS.h" + +namespace cc { + +std::vector &MorphModel::getMacroPatches(index_t subModelIndex) { + if (_morphRenderingInstance) { + _macroPatches = _morphRenderingInstance->requiredPatches(subModelIndex); + } else { + _macroPatches.clear(); + } + + return _macroPatches; +} + +void MorphModel::initSubModel(index_t idx, RenderingSubMesh *subMeshData, Material *mat) { + Super::initSubModel(idx, subMeshData, launderMaterial(mat)); +} + +void MorphModel::destroy() { + Super::destroy(); + _morphRenderingInstance = nullptr; //minggo: should delete it? +} + +void MorphModel::setSubModelMaterial(index_t idx, Material *mat) { + Super::setSubModelMaterial(idx, launderMaterial(mat)); +} + +void MorphModel::updateLocalDescriptors(index_t subModelIndex, gfx::DescriptorSet *descriptorSet) { + Super::updateLocalDescriptors(subModelIndex, descriptorSet); + + if (_morphRenderingInstance) { + _morphRenderingInstance->adaptPipelineState(subModelIndex, descriptorSet); + } +} + +} // namespace cc diff --git a/native/cocos/3d/models/MorphModel.h b/native/cocos/3d/models/MorphModel.h new file mode 100644 index 0000000000..400844b2e9 --- /dev/null +++ b/native/cocos/3d/models/MorphModel.h @@ -0,0 +1,59 @@ +/**************************************************************************** + 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 +#include +#include "3d/assets/Morph.h" +#include "scene/Define.h" +#include "scene/Model.h" + +namespace cc { + +class MorphModel : public scene::Model { +public: + using Super = scene::Model; + + MorphModel() = default; + ~MorphModel() override = default; + CC_DISALLOW_COPY_MOVE_ASSIGN(MorphModel); + + std::vector &getMacroPatches(index_t subModelIndex) override; + void initSubModel(index_t idx, RenderingSubMesh *subMeshData, Material *mat) override; + void destroy() override; + void setSubModelMaterial(index_t idx, Material *mat) override; + + inline void setMorphRendering(MorphRenderingInstance *morphRendering) { _morphRenderingInstance = morphRendering; } + +protected: + void updateLocalDescriptors(index_t subModelIndex, gfx::DescriptorSet *descriptorSet) override; + +private: + inline Material *launderMaterial(Material *material) { return material; } //NOLINT(readability-convert-member-functions-to-static) + + IntrusivePtr _morphRenderingInstance; +}; + +} // namespace cc diff --git a/native/cocos/3d/models/SkinningModel.cpp b/native/cocos/3d/models/SkinningModel.cpp new file mode 100644 index 0000000000..c8429d3e8d --- /dev/null +++ b/native/cocos/3d/models/SkinningModel.cpp @@ -0,0 +1,227 @@ +/**************************************************************************** + 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 "3d/models/SkinningModel.h" + +#include +#include + +#include "3d/assets/Mesh.h" +#include "core/scene-graph/Node.h" +#include "renderer/gfx-base/GFXDevice.h" +#include "scene/Pass.h" +#include "scene/RenderScene.h" + +namespace { +void getRelevantBuffers(std::vector &outIndices, std::vector &outBuffers, const std::vector> &jointMaps, int32_t targetJoint) { + for (int32_t i = 0; i < jointMaps.size(); i++) { + index_t index = CC_INVALID_INDEX; + for (int32_t j = 0; j < jointMaps[i].size(); j++) { + if (jointMaps[i][j] == targetJoint) { + index = j; + break; + } + } + if (index >= 0) { + outBuffers.emplace_back(i); + outIndices.emplace_back(index); + } + } +} + +std::vector myPatches{{"CC_USE_SKINNING", true}}; + +} // namespace +namespace cc { + +SkinningModel::SkinningModel() { + _type = Model::Type::SKINNING; +} +SkinningModel::~SkinningModel() { + for (auto *curr : _dataArray) { + delete curr; + } +} + +void SkinningModel::destroy() { + bindSkeleton(nullptr, nullptr, nullptr); + if (!_buffers.empty()) { + for (gfx::Buffer *buffer : _buffers) { + CC_SAFE_DESTROY(buffer); + } + _buffers.clear(); + } + Super::destroy(); +} + +void SkinningModel::bindSkeleton(Skeleton *skeleton, Node *skinningRoot, Mesh *mesh) { + for (const JointInfo &joint : _joints) { + deleteTransform(joint.target); + } + _bufferIndices.clear(); + _joints.clear(); + + if (!skeleton || !skinningRoot || !mesh) return; + setTransform(skinningRoot); + auto boneSpaceBounds = mesh->getBoneSpaceBounds(skeleton); + const auto &jointMaps = mesh->getStruct().jointMaps; + ensureEnoughBuffers((jointMaps.has_value() && !jointMaps->empty()) ? static_cast(jointMaps->size()) : 1); + _bufferIndices = mesh->getJointBufferIndices(); + + for (index_t index = 0; index < skeleton->getJoints().size(); ++index) { + geometry::AABB *bound = boneSpaceBounds[index]; + auto * target = skinningRoot->getChildByPath(skeleton->getJoints()[index]); + if (!bound || !target) continue; + + auto * transform = cc::getTransform(target, skinningRoot); + const Mat4 & bindPose = skeleton->getBindposes()[index]; + std::vector indices; + std::vector buffers; + if (!jointMaps.has_value()) { + indices.emplace_back(index); + buffers.emplace_back(0); + } else { + getRelevantBuffers(indices, buffers, jointMaps.value(), index); + } + + JointInfo jointInfo; + jointInfo.bound = bound; + jointInfo.target = target; + jointInfo.bindpose = bindPose; + jointInfo.transform = transform; + jointInfo.buffers = std::move(buffers); + jointInfo.indices = std::move(indices); + _joints.emplace_back(std::move(jointInfo)); + } +} + +void SkinningModel::updateTransform(uint32_t stamp) { + auto *root = getTransform(); + if (root->getChangedFlags() || root->getDirtyFlag()) { + root->updateWorldTransform(); + _localDataUpdated = true; + } + Vec3 v3Min{INFINITY, INFINITY, INFINITY}; + Vec3 v3Max{-INFINITY, -INFINITY, -INFINITY}; + geometry::AABB ab1; + Vec3 v31; + Vec3 v32; + for (JointInfo &jointInfo : _joints) { + const auto *bound = jointInfo.bound; + auto * transform = jointInfo.transform; + Mat4 worldMatrix = cc::getWorldMatrix(transform, static_cast(stamp)); + jointInfo.bound->transform(worldMatrix, &ab1); + ab1.getBoundary(&v31, &v32); + Vec3::min(v3Min, v31, &v3Min); + Vec3::max(v3Max, v32, &v3Max); + } + if (_modelBounds->isValid() && _worldBounds) { + geometry::AABB::fromPoints(v3Min, v3Max, _modelBounds); + _modelBounds->transform(root->getWorldMatrix(), _worldBounds); + } +} + +void SkinningModel::updateUBOs(uint32_t stamp) { + Super::updateUBOs(stamp); + uint32_t bIdx = 0; + Mat4 mat4; + for (const JointInfo &jointInfo : _joints) { + Mat4::multiply(jointInfo.transform->world, jointInfo.bindpose, &mat4); + for (uint32_t buffer : jointInfo.buffers) { + uploadJointData(jointInfo.indices[bIdx] * 12, mat4, _dataArray[buffer]->data()); + bIdx++; + } + bIdx = 0; + } + bIdx = 0; + for (const auto &buffer : _buffers) { + buffer->update(_dataArray[bIdx]->data(), buffer->getSize()); + bIdx++; + } +} + +void SkinningModel::initSubModel(index_t idx, RenderingSubMesh *subMeshData, Material *mat) { + const auto &original = subMeshData->getVertexBuffers(); + auto & iaInfo = subMeshData->getIaInfo(); + iaInfo.vertexBuffers = subMeshData->getJointMappedBuffers(); + Super::initSubModel(idx, subMeshData, mat); + iaInfo.vertexBuffers = original; +} + +std::vector &SkinningModel::getMacroPatches(index_t subModelIndex) { + auto &patches = Super::getMacroPatches(subModelIndex); + patches.reserve(myPatches.size() + patches.size()); + patches.insert(std::begin(patches), std::begin(myPatches), std::end(myPatches)); + return patches; +} + +void SkinningModel::uploadJointData(uint32_t base, const Mat4 &mat, float *dst) { + memcpy(reinterpret_cast(dst + base), mat.m, sizeof(float) * 12); + dst[base + 3] = mat.m[12]; + dst[base + 7] = mat.m[13]; + dst[base + 11] = mat.m[14]; +} + +void SkinningModel::updateLocalDescriptors(index_t submodelIdx, gfx::DescriptorSet *descriptorset) { + Super::updateLocalDescriptors(submodelIdx, descriptorset); + gfx::Buffer *buffer = _buffers[_bufferIndices[submodelIdx]]; + if (buffer) { + descriptorset->bindBuffer(pipeline::UBOSkinning::BINDING, buffer); + } +} + +void SkinningModel::updateInstancedAttributes(const std::vector &attributes, scene::Pass *pass) { + if (pass->getBatchingScheme() != scene::BatchingSchemes::NONE) { + // TODO(holycanvas): #9203 better to print the complete path instead of only the current node + // warnID(3936, this.node.name); + CC_LOG_WARNING("pass batchingScheme is none, %s", getNode()->getName().c_str()); + } + Super::updateInstancedAttributes(attributes, pass); +} + +void SkinningModel::ensureEnoughBuffers(index_t count) { + for (index_t i = 0; i < count; i++) { + if (i >= _buffers.size()) { + _buffers.resize(i + 1); + } + + if (_buffers[i] == nullptr) { + _buffers[i] = _device->createBuffer({ + gfx::BufferUsageBit::UNIFORM | gfx::BufferUsageBit::TRANSFER_DST, + gfx::MemoryUsageBit::HOST | gfx::MemoryUsageBit::DEVICE, + pipeline::UBOSkinning::SIZE, + pipeline::UBOSkinning::SIZE, + }); + } + + if (i >= _dataArray.size()) { + _dataArray.resize(i + 1); + } + + if (_dataArray[i] == nullptr) { + _dataArray[i] = new std::array; + } + } +} +} // namespace cc diff --git a/native/cocos/scene/SkinningModel.h b/native/cocos/3d/models/SkinningModel.h similarity index 50% rename from native/cocos/scene/SkinningModel.h rename to native/cocos/3d/models/SkinningModel.h index 3a5f381c95..3c7218d4f4 100644 --- a/native/cocos/scene/SkinningModel.h +++ b/native/cocos/3d/models/SkinningModel.h @@ -27,70 +27,56 @@ #include #include +#include "3d/assets/Skeleton.h" +#include "3d/models/MorphModel.h" +#include "core/animation/SkeletalAnimationUtils.h" #include "math/Mat4.h" #include "renderer/gfx-base/GFXBuffer.h" #include "renderer/gfx-base/GFXDescriptorSet.h" #include "renderer/pipeline/Define.h" #include "scene/Model.h" -namespace cc { -namespace scene { -struct JointTransform { - Node *node{nullptr}; - Mat4 local; - Mat4 world; - int stamp{-1}; -}; +namespace cc { + +namespace geometry { +class AABB; +} struct JointInfo { - AABB * bound{nullptr}; - Node * target{nullptr}; - Mat4 bindpose; - JointTransform transform; - std::vector parents; - std::vector buffers; - std::vector indices; + geometry::AABB * bound{nullptr}; + Node * target{nullptr}; + Mat4 bindpose; + IJointTransform * transform{nullptr}; + std::vector buffers; + std::vector indices; }; -class SkinningModel : public Model { +class SkinningModel final : public MorphModel { public: - SkinningModel() = default; - SkinningModel(const SkinningModel &) = delete; - SkinningModel(SkinningModel &&) = delete; + using Super = MorphModel; + SkinningModel(); ~SkinningModel() override; - SkinningModel &operator=(const SkinningModel &) = delete; - SkinningModel &operator=(SkinningModel &&) = delete; - void setBuffers(std::vector buffers); - inline void setIndicesAndJoints(std::vector bufferIndices, std::vector joints) { - _bufferIndices = std::move(bufferIndices); - _joints = std::move(joints); - } - inline void updateLocalDescriptors(uint32_t submodelIdx, gfx::DescriptorSet *descriptorset) { - gfx::Buffer *buffer = _buffers[_bufferIndices[submodelIdx]]; - if (buffer) { - descriptorset->bindBuffer(pipeline::UBOSkinning::BINDING, buffer); - } - } - inline void setNeedUpdate(bool needUpdate) { - _needUpdate = needUpdate; - } + void updateLocalDescriptors(index_t submodelIdx, gfx::DescriptorSet *descriptorset) override; void updateTransform(uint32_t stamp) override; void updateUBOs(uint32_t stamp) override; + void destroy() override; -protected: - ModelType _type{ModelType::SKINNING}; + void initSubModel(index_t idx, RenderingSubMesh *subMeshData, Material *mat) override; + std::vector &getMacroPatches(index_t subModelIndex) override; + void updateInstancedAttributes(const std::vector &attributes, scene::Pass *pass) override; + + void bindSkeleton(Skeleton *skeleton, Node *skinningRoot, Mesh *mesh); private: - static void uploadJointData(uint32_t base, const Mat4 &mat, float *dst); - void updateWorldMatrix(JointInfo *info, uint32_t stamp); - bool _needUpdate{false}; - Mat4 _worldMatrix; - std::vector _bufferIndices; - std::vector _buffers; + static void uploadJointData(uint32_t base, const Mat4 &mat, float *dst); + void ensureEnoughBuffers(index_t count); + + std::vector _bufferIndices; + std::vector> _buffers; std::vector _joints; std::vector *> _dataArray; + CC_DISALLOW_COPY_MOVE_ASSIGN(SkinningModel); }; -} // namespace scene } // namespace cc diff --git a/native/cocos/3d/skeletal-animation/SkeletalAnimationUtils.cpp b/native/cocos/3d/skeletal-animation/SkeletalAnimationUtils.cpp new file mode 100644 index 0000000000..0be08c80ac --- /dev/null +++ b/native/cocos/3d/skeletal-animation/SkeletalAnimationUtils.cpp @@ -0,0 +1,499 @@ +/**************************************************************************** + 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 "3d/skeletal-animation/SkeletalAnimationUtils.h" +#include "3d/assets/Mesh.h" +#include "renderer/pipeline/Define.h" + +namespace { +const float INF = std::numeric_limits::infinity(); + +cc::gfx::Format selectJointsMediumFormat(cc::gfx::Device *device) { + if (device->hasFeature(cc::gfx::Feature::TEXTURE_FLOAT)) { + return cc::gfx::Format::RGBA32F; + } + return cc::gfx::Format::RGBA8; +} + +// Linear Blending Skinning +void uploadJointDataLBS(cc::Float32Array out, uint32_t base, const cc::Mat4 &mat, bool /*firstBone*/) { + out[base + 0] = mat.m[0]; + out[base + 1] = mat.m[1]; + out[base + 2] = mat.m[2]; + out[base + 3] = mat.m[12]; + out[base + 4] = mat.m[4]; + out[base + 5] = mat.m[5]; + out[base + 6] = mat.m[6]; + out[base + 7] = mat.m[13]; + out[base + 8] = mat.m[8]; + out[base + 9] = mat.m[9]; + out[base + 10] = mat.m[10]; + out[base + 11] = mat.m[14]; +} + +cc::Quaternion dq0; +cc::Quaternion dq1; +cc::Vec3 v31; +cc::Quaternion qt1; +cc::Vec3 v32; + +float dot(const cc::Quaternion &a, const cc::Quaternion &b) { + return a.x * b.x + a.y * b.y + a.z * b.z + a.w * b.w; +} + +void multiplyScalar(const cc::Quaternion &a, float b, cc::Quaternion *out) { + out->x = a.x * b; + out->y = a.y * b; + out->z = a.z * b; + out->w = a.w * b; +} + +// Dual Quaternion Skinning +void uploadJointDataDQS(cc::Float32Array out, uint32_t base, cc::Mat4 &mat, bool firstBone) { + cc::Mat4::toRTS(qt1, v31, v32, &mat); + // // sign consistency + if (firstBone) { + dq0 = qt1; + } else if (dot(dq0, qt1) < 0) { + multiplyScalar(qt1, -1, &qt1); + } + // conversion + dq1.x = v31.x; + dq1.y = v31.y; + dq1.z = v31.z; + dq1.w = 0; + multiplyScalar(dq1 * qt1, 0.5, &dq1); + // upload + out[base + 0] = qt1.x; + out[base + 1] = qt1.y; + out[base + 2] = qt1.z; + out[base + 3] = qt1.w; + out[base + 4] = dq1.x; + out[base + 5] = dq1.y; + out[base + 6] = dq1.z; + out[base + 7] = dq1.w; + out[base + 8] = v32.x; + out[base + 9] = v32.y; + out[base + 10] = v32.z; +} + +// change here and cc-skinning.chunk to use other skinning algorithms +constexpr auto UPLOAD_JOINT_DATA = uploadJointDataLBS; +const uint32_t MINIMUM_JOINT_TEXTURE_SIZE = /* EDITOR ? 2040 :*/ 480; // have to be multiples of 12 + +uint32_t roundUpTextureSize(uint32_t targetLength, uint32_t formatSize) { + double formatScale = 4 / std::sqrt(formatSize); + return static_cast(std::ceil(std::max(MINIMUM_JOINT_TEXTURE_SIZE * formatScale, static_cast(targetLength)) / 12) * 12); +} + +const cc::gfx::SamplerInfo JOINT_TEXTURE_SAMPLER_INFO{ + cc::gfx::Filter::POINT, + cc::gfx::Filter::POINT, + cc::gfx::Filter::NONE, + cc::gfx::Address::CLAMP, + cc::gfx::Address::CLAMP, + cc::gfx::Address::CLAMP, +}; + +cc::Mat4 *getWorldTransformUntilRoot(cc::Node *target, cc::Node *root, cc::Mat4 *outMatrix) { + outMatrix->setIdentity(); + cc::Mat4 mat4; + while (target != root) { + cc::Mat4::fromRTS(target->getRotation(), target->getPosition(), target->getScale(), &mat4); + cc::Mat4::multiply(*outMatrix, mat4, outMatrix); + target = target->getParent(); + } + return outMatrix; +} + +} // namespace +namespace cc { +JointTexturePool::JointTexturePool(gfx::Device *device) { + _device = device; + const auto &format = selectJointsMediumFormat(_device); + _formatSize = gfx::GFX_FORMAT_INFOS[static_cast(format)].size; + _pixelsPerJoint = 48.F / static_cast(_formatSize); + _pool = new TextureBufferPool(device); + ITextureBufferPoolInfo poolInfo; + poolInfo.format = format; + poolInfo.roundUpFn = roundUpType{roundUpTextureSize}; + _pool->initialize(poolInfo); + _customPool = new TextureBufferPool(device); + ITextureBufferPoolInfo customPoolInfo; + customPoolInfo.format = format; + customPoolInfo.roundUpFn = roundUpType{roundUpTextureSize}; + _customPool->initialize(customPoolInfo); +} + +void JointTexturePool::clear() { + CC_SAFE_DESTROY(_pool); + _textureBuffers.clear(); +} + +void JointTexturePool::registerCustomTextureLayouts(const std::vector &layouts) { + for (const auto &layout : layouts) { + auto chunkIdx = static_cast(_customPool->createChunk(layout.textureLength)); + for (const auto &content : layout.contents) { + auto skeleton = content.skeleton; + _chunkIdxMap[skeleton] = chunkIdx; // include default pose too + for (const auto &clip : content.clips) { + _chunkIdxMap[skeleton ^ clip] = chunkIdx; + } + } + } +} + +cc::optional JointTexturePool::getDefaultPoseTexture(Skeleton *skeleton, Mesh *mesh, Node *skinningRoot) { + uint64_t hash = skeleton->getHash() ^ 0; // may not equal to skeleton.hash + cc::optional texture; + if (_textureBuffers.find(hash) != _textureBuffers.end()) { + texture = _textureBuffers[hash]; + } + + const std::vector &joints = skeleton->getJoints(); + const std::vector & bindPoses = skeleton->getBindposes(); + Float32Array textureBuffer; + bool buildTexture = false; + auto jointCount = static_cast(joints.size()); + if (!texture.has_value()) { + uint32_t bufSize = jointCount * 12; + ITextureBufferHandle handle; + if (_chunkIdxMap.find(hash) != _chunkIdxMap.end()) { + handle = _customPool->alloc(bufSize * Float32Array::BYTES_PER_ELEMENT, _chunkIdxMap[hash]); + } else { + handle = _pool->alloc(bufSize * Float32Array::BYTES_PER_ELEMENT); + return texture; + } + IJointTextureHandle textureHandle; + textureHandle.pixelOffset = handle.start / _formatSize; + textureHandle.refCount = 1; + textureHandle.clipHash = 0; + textureHandle.skeletonHash = skeleton->getHash(); + textureHandle.readyToBeDeleted = false; + textureHandle.handle = handle; + texture = textureHandle; + textureBuffer = Float32Array(bufSize); + buildTexture = true; + } else { + texture->refCount++; + } + + geometry::AABB ab1; + Mat4 mat4; + Vec3 v34; + Vec3 v33; + Vec3 v3Min(-INF, -INF, -INF); + Vec3 v3Max(-INF, -INF, -INF); + auto boneSpaceBounds = mesh->getBoneSpaceBounds(skeleton); + for (uint32_t j = 0, offset = 0; j < jointCount; ++j, offset += 12) { + auto *node = skinningRoot->getChildByPath(joints[j]); + Mat4 mat = node ? *getWorldTransformUntilRoot(node, skinningRoot, &mat4) : skeleton->getInverseBindposes()[j]; + if (j < boneSpaceBounds.size()) { + auto *bound = boneSpaceBounds[j].get(); + bound->transform(mat, &ab1); + ab1.getBoundary(&v33, &v34); + Vec3::min(v3Min, v33, &v3Min); + Vec3::max(v3Max, v34, &v3Max); + } + + if (buildTexture) { + if (node != nullptr) { + Mat4::multiply(mat, bindPoses[j], &mat); + } + uploadJointDataLBS(textureBuffer, offset, node ? mat : Mat4::IDENTITY, j == 0); + } + } + + std::vector bounds; + texture->bounds[static_cast(mesh->getHash())] = bounds; + geometry::AABB::fromPoints(v3Min, v3Max, &bounds[0]); + if (buildTexture) { + _pool->update(texture->handle, textureBuffer.buffer()); + _textureBuffers[hash] = texture.value(); + } + + return texture; +} + +// TODO(xwx): need to implement this function after define AnimationClip +// cc::optional JointTexturePool::getSequencePoseTexture(Skeleton *skeleton,AnimationClip *clip, Mesh *mesh, Node *skinningRoot) { +// uint64_t hash = skeleton->getHash() ^ clip->getHash(); +// cc::optional texture; +// if (_textureBuffers.find(hash) != _textureBuffers.end()) { +// texture = _textureBuffers[hash]; +// if (texture->bounds.find(mesh->getHash()) != texture->bounds.end()) { +// texture->refCount++; +// return texture; +// } +// } +// const std::vector &joints = skeleton->getJoints(); +// const std::vector & bindPoses = skeleton->getBindposes(); +// // const clipData = SkelAnimDataHub.getOrExtract(clip); +// // const { frames } = clipData; +// Float32Array textureBuffer; +// bool buildTexture = false; +// uint32_t jointCount = joints.size(); +// if (!texture.has_value()) { +// uint32_t bufSize = jointCount * 12; +// ITextureBufferHandle handle; +// if (_chunkIdxMap.find(hash) != _chunkIdxMap.end()) { +// handle = _customPool->alloc(bufSize * sizeof(Float32Array), _chunkIdxMap[hash]); // TODO(xwx): Float32Array.BYTES_PER_ELEMENT == sizeof(Float32Array) ? +// } else { +// handle = _pool->alloc(bufSize * sizeof(Float32Array)); +// return texture; +// } +// // auto animInfos = createAnimInfos(skeleton, clip, skinningRoot); // TODO(xwx): createAnimInfos not implement + +// texture = IJointTextureHandle{ +// .pixelOffset = handle.start / _formatSize, +// .refCount = 1, +// .clipHash = 0, +// .skeletonHash = skeleton->getHash(), +// .readyToBeDeleted = false, +// .handle = handle, +// // .animInfos = animInfos // TODO(xwx) +// }; +// textureBuffer.resize(bufSize); +// buildTexture = true; +// } else { +// texture->refCount++; +// } +// auto boneSpaceBounds = mesh->getBoneSpaceBounds(skeleton); +// std::vector bounds; +// texture->bounds[mesh->getHash()] = bounds; + +// // for (uint32_t f = 0; f < frames; ++f) { // TODO(xwx): frames not define +// // bounds.emplace_back(geometry::AABB(INF, INF, INF, -INF, -INF, -INF)); +// // } + +// // TODO(xwx) : need to implement when define animInfos +// // for (uint32_t f = 0, offset = 0; f < frames; ++f) { +// // auto bound = bounds[f]; +// // for (uint32_t j = 0; j < jointCount; ++j, offset += 12) { +// // const { +// // curveData, +// // downstream, +// // bindposeIdx, +// // bindposeCorrection, +// // } = texture.animInfos ![j]; +// // let mat : Mat4; +// // let transformValid = true; +// // if (curveData && downstream) { // curve & static two-way combination +// // mat = Mat4.multiply(m4_1, curveData[f], downstream); +// // } else if (curveData) { // there is a curve directly controlling the joint +// // mat = curveData[f]; +// // } else if (downstream) { // fallback to default pose if no animation curve can be found upstream +// // mat = downstream; +// // } else { // bottom line: render the original mesh as-is +// // mat = skeleton.inverseBindposes[bindposeIdx]; +// // transformValid = false; +// // } +// // if (j < boneSpaceBounds.size()) { +// // auto bound = boneSpaceBounds[j]; +// // auto tarnsform = bindposeCorrection ? Mat4::multiply(mat, bindposeCorrection, &m42) : mat; // TODO(xwx): mat not define +// // ab1.getBoundary(&v33, &v34); +// // Vec3::min(bound.center, v33, &bound.center); +// // Vec3::max(bound.halfExtents, v34, &bound.halfExtents); +// // } + +// // if (buildTexture) { +// // if (transformValid) { +// // Mat4::multiply(mat, bindPoses[bindposIdx], &m41); +// // UPLOAD_JOINT_DATA(textureBuffer, offset, transformValid ? m41 : Mat4::IDENTITY, j == 0); +// // } +// // } +// // } +// // AABB::fromPoints(bound.center, bound.halfExtents, &bound); +// // } +// if (buildTexture) { +// // _pool->update(texture->handle, textureBuffer.buffer); // TODO(xwx): ArrayBuffer not implemented +// _textureBuffers[hash] = texture.value(); +// } +// return texture; +// } +// } + +void JointTexturePool::releaseHandle(IJointTextureHandle &handle) { + if (handle.refCount > 0) { + handle.refCount--; + } + if (!handle.refCount && handle.readyToBeDeleted) { + uint64_t hash = handle.skeletonHash ^ handle.clipHash; + if (_chunkIdxMap.find(hash) != _chunkIdxMap.end()) { + _customPool->free(handle.handle); + } else { + _pool->free(handle.handle); + } + if (&_textureBuffers[hash] == &handle) { // TODO(xwx): value equal or address equal? + _textureBuffers.erase(hash); + } + } +} + +void JointTexturePool::releaseSkeleton(Skeleton *skeleton) { + for (const auto &texture : _textureBuffers) { + auto handle = texture.second; + if (handle.skeletonHash == skeleton->getHash()) { + handle.readyToBeDeleted = true; + if (handle.refCount > 0) { + // delete handle record immediately so new allocations with the same asset could work + _textureBuffers.erase(handle.skeletonHash ^ handle.clipHash); + } else { + releaseHandle(handle); + } + } + } +} + +// TODO(xwx): AnimationClip not define +// public releaseAnimationClip(clip: AnimationClip) { +// const it = this._textureBuffers.values(); +// let res = it.next(); +// while (!res.done) { +// const handle = res.value; +// if (handle.clipHash == = clip.hash) { +// handle.readyToBeDeleted = true; +// if (handle.refCount) { +// // delete handle record immediately so new allocations with the same asset could work +// this._textureBuffers.delete(handle.skeletonHash ^ handle.clipHash); +// } else { +// this.releaseHandle(handle); +// } +// } +// res = it.next(); +// } +// } + +// TODO(xwx): AnimationClip not define +// private _createAnimInfos (skeleton: Skeleton, clip: AnimationClip, skinningRoot: Node) { +// const animInfos: IInternalJointAnimInfo[] = []; +// const { joints, bindposes } = skeleton; +// const jointCount = joints.length; +// const clipData = SkelAnimDataHub.getOrExtract(clip); +// for (let j = 0; j < jointCount; j++) { +// let animPath = joints[j]; +// let source = clipData.joints[animPath]; +// let animNode = skinningRoot.getChildByPath(animPath); +// let downstream: Mat4 | undefined; +// let correctionPath: string | undefined; +// while (!source) { +// const idx = animPath.lastIndexOf('/'); +// animPath = animPath.substring(0, idx); +// source = clipData.joints[animPath]; +// if (animNode) { +// if (!downstream) { downstream = new Mat4(); } +// Mat4.fromRTS(m4_1, animNode.rotation, animNode.position, animNode.scale); +// Mat4.multiply(downstream, m4_1, downstream); +// animNode = animNode.parent; +// } else { // record the nearest curve path if no downstream pose is present +// correctionPath = animPath; +// } +// if (idx < 0) { break; } +// } +// // the default behavior, just use the bindpose for current joint directly +// let bindposeIdx = j; +// let bindposeCorrection: Mat4 | undefined; +// /** +// * It is regularly observed that developers may choose to delete the whole +// * skeleton node tree for skinning models that only use baked animations +// * as an effective optimization strategy (substantial improvements on both +// * package size and runtime efficiency). +// * +// * This becomes troublesome in some cases during baking though, e.g. when a +// * skeleton joint node is not directly controlled by any animation curve, +// * but its parent nodes are. Due to lack of proper downstream default pose, +// * the joint transform can not be calculated accurately. +// * +// * We address this issue by employing some pragmatic approximation. +// * Specifically, by multiplying the bindpose of the joint corresponding to +// * the nearest curve, instead of the actual target joint. This effectively +// * merges the skinning influence of the 'incomplete' joint into its nearest +// * parent with accurate transform data. +// * It gives more visually-plausible results compared to the naive approach +// * for most cases we've covered. +// */ +// if (correctionPath !== undefined && source) { +// // just use the previous joint if the exact path is not found +// bindposeIdx = j - 1; +// for (let t = 0; t < jointCount; t++) { +// if (joints[t] === correctionPath) { +// bindposeIdx = t; +// bindposeCorrection = new Mat4(); +// Mat4.multiply(bindposeCorrection, bindposes[t], skeleton.inverseBindposes[j]); +// break; +// } +// } +// } +// animInfos.push({ +// curveData: source && source.transforms, downstream, bindposeIdx, bindposeCorrection, +// }); +// } +// return animInfos; +// } + +IAnimInfo JointAnimationInfo::getData(const std::string &nodeID) { + if (_pool.find(nodeID) != _pool.end()) { + return _pool[nodeID]; + } + + auto *buffer = _device->createBuffer(gfx::BufferInfo{ + gfx::BufferUsageBit::UNIFORM | gfx::BufferUsageBit::TRANSFER_DST, + gfx::MemoryUsageBit::HOST | gfx::MemoryUsageBit::DEVICE, + pipeline::UBOSkinningAnimation::SIZE, + pipeline::UBOSkinningAnimation::SIZE, + }); + + Float32Array data; + buffer->update(data.buffer()->getData()); + IAnimInfo info; + info.buffer = buffer; + info.data = data; + info.dirty = false; + _pool[nodeID] = info; + + return info; +} + +void JointAnimationInfo::destroy(const std::string &nodeID) { + if (_pool.find(nodeID) != _pool.end()) { + CC_SAFE_DESTROY_AND_DELETE(_pool[nodeID].buffer); + _pool.erase(nodeID); + } +} + +const IAnimInfo &JointAnimationInfo::switchClip(IAnimInfo &info /*, AnimationClip *clip */) { + info.data[0] = 0; + info.buffer->update(info.data.buffer()->getData()); + info.dirty = false; + return info; +} + +void JointAnimationInfo::clear() { + for (auto pool : _pool) { + CC_SAFE_DESTROY_AND_DELETE(pool.second.buffer); + } + _pool.clear(); +} +} // namespace cc diff --git a/native/cocos/3d/skeletal-animation/SkeletalAnimationUtils.h b/native/cocos/3d/skeletal-animation/SkeletalAnimationUtils.h new file mode 100644 index 0000000000..7e06442339 --- /dev/null +++ b/native/cocos/3d/skeletal-animation/SkeletalAnimationUtils.h @@ -0,0 +1,146 @@ +/**************************************************************************** + 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 +#include "cocos/base/Optional.h" + +#include "3d/assets/Skeleton.h" +#include "core/TypedArray.h" +#include "core/geometry/AABB.h" +#include "core/scene-graph/Node.h" +#include "gfx-base/GFXDef-common.h" +#include "renderer/core/TextureBufferPool.h" +#include "renderer/gfx-base/GFXBuffer.h" +#include "renderer/gfx-base/GFXDevice.h" + +namespace cc { + +class Mesh; + +struct IChunkContent { + int32_t skeleton{0}; // TODO(xwx): int or uint or float? + std::vector clips; // TODO(xwx): int or uint? +}; + +struct ICustomJointTextureLayout { + uint32_t textureLength{0}; + std::vector contents; +}; + +struct IInternalJointAnimInfo { + cc::optional downstream; // downstream default pose, if present + cc::optional> curveData; // the nearest animation curve, if present + index_t bindposeIdx{0}; // index of the actual bindpose to use + cc::optional bindposeCorrection; // correction factor from the original bindpose +}; + +struct IJointTextureHandle { + uint32_t pixelOffset{0}; + uint32_t refCount{0}; + uint64_t clipHash{0}; + uint64_t skeletonHash{0}; + bool readyToBeDeleted{false}; + ITextureBufferHandle handle; + std::unordered_map> bounds; + cc::optional> animInfos; +}; + +class JointTexturePool : public RefCounted { +public: + JointTexturePool() = default; + explicit JointTexturePool(gfx::Device *device); + ~JointTexturePool() override = default; + + inline float getPixelsPerJoint() const { return _pixelsPerJoint; } + + void clear(); + + void registerCustomTextureLayouts(const std::vector &layouts); + + /** + * @en + * Get joint texture for the default pose. + * @zh + * 获取默认姿势的骨骼贴图。 + */ + cc::optional getDefaultPoseTexture(Skeleton *skeleton, Mesh *mesh, Node *skinningRoot); + + /** + * @en + * Get joint texture for the specified animation clip. + * @zh + * 获取指定动画片段的骨骼贴图。 + */ + // cc::optional getSequencePoseTexture(Skeleton *skeleton, AnimationClip *clip, Mesh *mesh, Node *skinningRoot); + + void releaseHandle(IJointTextureHandle &handle); + + void releaseSkeleton(Skeleton *skeleton); + + // void releaseAnimationClip (AnimationClip* clip); // TODO(xwx): AnimationClip not define + +private: + // const IInternalJointAnimInfo &createAnimInfos(Skeleton *skeleton, AnimationClip *clip, Node *skinningRoot); // TODO(xwx): AnimationClip not define + + gfx::Device * _device{nullptr}; + IntrusivePtr _pool; + std::unordered_map _textureBuffers; + uint32_t _formatSize{0}; + float _pixelsPerJoint{0}; // TODO(xwx): int or float? + IntrusivePtr _customPool; + std::unordered_map _chunkIdxMap; // hash -> chunkIdx + + CC_DISALLOW_COPY_MOVE_ASSIGN(JointTexturePool); +}; + +struct IAnimInfo { + gfx::Buffer *buffer{nullptr}; + Float32Array data; + const float *curFrame{nullptr}; // Only used in JSB + uint32_t frameDataBytes{0}; // Only used in JSB + uint8_t * dirtyForJSB{nullptr}; // Only used in JSB + bool dirty{false}; +}; + +class JointAnimationInfo : public RefCounted { +public: + JointAnimationInfo(); + explicit JointAnimationInfo(gfx::Device *device); + ~JointAnimationInfo() override = default; + + IAnimInfo getData(const std::string &nodeID = "-1"); + void destroy(const std::string &nodeID); + static const IAnimInfo &switchClip(IAnimInfo &info /*, AnimationClip *clip */); + void clear(); + +private: + std::unordered_map _pool; // pre node + gfx::Device * _device{nullptr}; + + CC_DISALLOW_COPY_MOVE_ASSIGN(JointAnimationInfo); +}; + +} // namespace cc diff --git a/native/cocos/audio/android/AudioDecoder.cpp b/native/cocos/audio/android/AudioDecoder.cpp index 9a9346dcc9..7aae3ef26b 100644 --- a/native/cocos/audio/android/AudioDecoder.cpp +++ b/native/cocos/audio/android/AudioDecoder.cpp @@ -27,16 +27,15 @@ THE SOFTWARE. #include "audio/android/AudioDecoder.h" #include "audio/android/AudioResampler.h" #include "audio/android/PcmBufferProvider.h" -#include "audio/android/AudioResampler.h" -#include #include +#include namespace cc { size_t AudioDecoder::fileRead(void *ptr, size_t size, size_t nmemb, void *datasource) { - AudioDecoder *thiz = (AudioDecoder *)datasource; - ssize_t toReadBytes = std::min((ssize_t)(thiz->_fileData.getSize() - thiz->_fileCurrPos), (ssize_t)(nmemb * size)); + AudioDecoder *thiz = (AudioDecoder *)datasource; + ssize_t toReadBytes = std::min((ssize_t)(thiz->_fileData.getSize() - thiz->_fileCurrPos), (ssize_t)(nmemb * size)); if (toReadBytes > 0) { memcpy(ptr, (unsigned char *)thiz->_fileData.getBytes() + thiz->_fileCurrPos, toReadBytes); thiz->_fileCurrPos += toReadBytes; @@ -48,11 +47,11 @@ size_t AudioDecoder::fileRead(void *ptr, size_t size, size_t nmemb, void *dataso int AudioDecoder::fileSeek(void *datasource, int64_t offset, int whence) { AudioDecoder *thiz = (AudioDecoder *)datasource; if (whence == SEEK_SET) - thiz->_fileCurrPos = offset; + thiz->_fileCurrPos = static_cast(offset); else if (whence == SEEK_CUR) - thiz->_fileCurrPos = thiz->_fileCurrPos + offset; + thiz->_fileCurrPos = static_cast(thiz->_fileCurrPos + offset); else if (whence == SEEK_END) - thiz->_fileCurrPos = thiz->_fileData.getSize(); + thiz->_fileCurrPos = static_cast(thiz->_fileData.getSize()); return 0; } @@ -77,7 +76,7 @@ AudioDecoder::~AudioDecoder() { } bool AudioDecoder::init(const std::string &url, int sampleRate) { - _url = url; + _url = url; _sampleRate = sampleRate; return true; } @@ -131,16 +130,16 @@ bool AudioDecoder::resample() { ALOGV("Resample: %d --> %d", _result.sampleRate, _sampleRate); - auto r = _result; + auto r = _result; PcmBufferProvider provider; provider.init(r.pcmBuffer->data(), r.numFrames, r.pcmBuffer->size() / r.numFrames); - const int outFrameRate = _sampleRate; - int outputChannels = 2; - size_t outputFrameSize = outputChannels * sizeof(int32_t); - size_t outputFrames = ((int64_t)r.numFrames * outFrameRate) / r.sampleRate; - size_t outputSize = outputFrames * outputFrameSize; - void *outputVAddr = malloc(outputSize); + const int outFrameRate = _sampleRate; + int outputChannels = 2; + size_t outputFrameSize = outputChannels * sizeof(int32_t); + auto outputFrames = static_cast(((int64_t)r.numFrames * outFrameRate) / r.sampleRate); + size_t outputSize = outputFrames * outputFrameSize; + void * outputVAddr = malloc(outputSize); auto resampler = AudioResampler::create(AUDIO_FORMAT_PCM_16_BIT, r.numChannels, outFrameRate, AudioResampler::MED_QUALITY); @@ -154,7 +153,7 @@ bool AudioDecoder::resample() { std::vector Ovalues; if (Ovalues.empty()) { - Ovalues.push_back(outputFrames); + Ovalues.push_back(static_cast(outputFrames)); } for (size_t i = 0, j = 0; i < outputFrames;) { size_t thisFrames = Ovalues[j++]; @@ -164,8 +163,8 @@ bool AudioDecoder::resample() { if (thisFrames == 0 || thisFrames > outputFrames - i) { thisFrames = outputFrames - i; } - int outFrames = resampler->resample((int *)outputVAddr + outputChannels * i, thisFrames, - &provider); + int outFrames = static_cast(resampler->resample(static_cast(outputVAddr) + outputChannels * i, thisFrames, + &provider)); ALOGV("outFrames: %d", outFrames); i += thisFrames; } @@ -182,9 +181,9 @@ bool AudioDecoder::resample() { // mono takes left channel only (out of stereo output pair) // stereo and multichannel preserve all channels. - int channels = r.numChannels; - int32_t *out = (int32_t *)outputVAddr; - int16_t *convert = (int16_t *)malloc(outputFrames * channels * sizeof(int16_t)); + int channels = r.numChannels; + int32_t *out = (int32_t *)outputVAddr; + int16_t *convert = (int16_t *)malloc(outputFrames * channels * sizeof(int16_t)); const int volumeShift = 12; // shift requirement for Q4.27 to Q.15 // round to half towards zero and saturate at int16 (non-dithered) @@ -209,7 +208,7 @@ bool AudioDecoder::resample() { } // Reset result - _result.numFrames = outputFrames; + _result.numFrames = static_cast(outputFrames); _result.sampleRate = outFrameRate; auto buffer = std::make_shared>(); @@ -233,7 +232,7 @@ bool AudioDecoder::interleave() { } else if (_result.numChannels == 1) { // If it's a mono audio, try to compose a fake stereo buffer size_t newBufferSize = _result.pcmBuffer->size() * 2; - auto newBuffer = std::make_shared>(); + auto newBuffer = std::make_shared>(); newBuffer->reserve(newBufferSize); size_t totalFrameSizeInBytes = (size_t)(_result.numFrames * _result.bitsPerSample / 8); @@ -250,7 +249,7 @@ bool AudioDecoder::interleave() { } _result.numChannels = 2; _result.channelMask = SL_SPEAKER_FRONT_LEFT | SL_SPEAKER_FRONT_RIGHT; - _result.pcmBuffer = newBuffer; + _result.pcmBuffer = newBuffer; return true; } diff --git a/native/cocos/audio/android/AudioEngine-inl.h b/native/cocos/audio/android/AudioEngine-inl.h index 620651dbd2..bdd28b4a6b 100644 --- a/native/cocos/audio/android/AudioEngine-inl.h +++ b/native/cocos/audio/android/AudioEngine-inl.h @@ -30,7 +30,7 @@ #include #include -#include "base/Ref.h" +#include "base/RefCounted.h" #include "base/Utils.h" #define MAX_AUDIOINSTANCES 13 @@ -46,7 +46,7 @@ class AudioPlayerProvider; class AudioEngineImpl; -class AudioEngineImpl : public cc::Ref { +class AudioEngineImpl : public RefCounted { public: AudioEngineImpl(); ~AudioEngineImpl() override; diff --git a/native/cocos/audio/android/AudioResampler.h b/native/cocos/audio/android/AudioResampler.h index 806a7334b6..c073eaab6d 100644 --- a/native/cocos/audio/android/AudioResampler.h +++ b/native/cocos/audio/android/AudioResampler.h @@ -16,10 +16,10 @@ #pragma once -#include -#include #include +#include #include +#include #include "audio/android/AudioBufferProvider.h" @@ -43,10 +43,10 @@ public: // certain fixed rate conversions. Sample rate cannot be // changed dynamically. enum src_quality { - DEFAULT_QUALITY = 0, - LOW_QUALITY = 1, - MED_QUALITY = 2, - HIGH_QUALITY = 3, + DEFAULT_QUALITY = 0, + LOW_QUALITY = 1, + MED_QUALITY = 2, + HIGH_QUALITY = 3, VERY_HIGH_QUALITY = 4, }; @@ -82,7 +82,7 @@ public: virtual size_t resample(int32_t *out, size_t outFrameCount, AudioBufferProvider *provider) = 0; - virtual void reset(); + virtual void reset(); virtual size_t getUnreleasedFrames() const { return mInputIndex; } // called from destructor, so must not be virtual @@ -106,20 +106,20 @@ protected: int64_t calculateOutputPTS(int outputFrameIndex); - const int32_t mChannelCount; - const int32_t mSampleRate; - int32_t mInSampleRate; + const int32_t mChannelCount; + const int32_t mSampleRate; + int32_t mInSampleRate; AudioBufferProvider::Buffer mBuffer; union { - int16_t mVolume[2]; + int16_t mVolume[2]; uint32_t mVolumeRL; }; - int16_t mTargetVolume[2]; - size_t mInputIndex; - int32_t mPhaseIncrement; + int16_t mTargetVolume[2]; + size_t mInputIndex; + int32_t mPhaseIncrement; uint32_t mPhaseFraction; uint64_t mLocalTimeFreq; - int64_t mPTS; + int64_t mPTS; // returns the inFrameCount required to generate outFrameCount frames. // @@ -149,7 +149,7 @@ protected: // phaseWrapLimit is the wraparound (1 << kNumPhaseBits), if not specified explicitly. // inline size_t getInFrameCountRequired(size_t outFrameCount) { - return (static_cast(outFrameCount) * mInSampleRate + (mSampleRate - 1)) / mSampleRate; + return (static_cast(outFrameCount) * mInSampleRate + (mSampleRate - 1)) / mSampleRate; } inline float clampFloatVol(float volume) { diff --git a/native/cocos/audio/android/AudioResamplerPublic.h b/native/cocos/audio/android/AudioResamplerPublic.h index 267ffe05fb..2e8c58a682 100644 --- a/native/cocos/audio/android/AudioResamplerPublic.h +++ b/native/cocos/audio/android/AudioResamplerPublic.h @@ -19,7 +19,6 @@ #include #include - namespace cc { // AUDIO_RESAMPLER_DOWN_RATIO_MAX is the maximum ratio between the original @@ -145,7 +144,7 @@ static inline size_t destinationFramesPossible(size_t srcFrames, uint32_t srcSam return srcFrames; } uint64_t dstFrames = (uint64_t)srcFrames * dstSampleRate / srcSampleRate; - return dstFrames > 2 ? dstFrames - 2 : 0; + return dstFrames > 2 ? static_cast(dstFrames - 2) : 0; } static inline size_t sourceFramesNeededWithTimestretch( diff --git a/native/cocos/audio/apple/AudioEngine-inl.h b/native/cocos/audio/apple/AudioEngine-inl.h index 7570236dbe..5d54331e05 100644 --- a/native/cocos/audio/apple/AudioEngine-inl.h +++ b/native/cocos/audio/apple/AudioEngine-inl.h @@ -32,14 +32,14 @@ #include "audio/apple/AudioCache.h" #include "audio/apple/AudioPlayer.h" -#include "base/Ref.h" +#include "base/RefCounted.h" namespace cc { class Scheduler; #define MAX_AUDIOINSTANCES 24 -class AudioEngineImpl : public cc::Ref { +class AudioEngineImpl : public cc::RefCounted { public: AudioEngineImpl(); ~AudioEngineImpl(); diff --git a/native/cocos/audio/oalsoft/AudioEngine-soft.h b/native/cocos/audio/oalsoft/AudioEngine-soft.h index d3b52eca92..44a9044537 100644 --- a/native/cocos/audio/oalsoft/AudioEngine-soft.h +++ b/native/cocos/audio/oalsoft/AudioEngine-soft.h @@ -30,7 +30,7 @@ #include "audio/oalsoft/AudioCache.h" #include "audio/oalsoft/AudioPlayer.h" -#include "base/Ref.h" +#include "cocos/base/RefCounted.h" namespace cc { @@ -38,7 +38,7 @@ class Scheduler; #define MAX_AUDIOINSTANCES 32 -class CC_DLL AudioEngineImpl : public cc::Ref { +class CC_DLL AudioEngineImpl : public RefCounted { public: AudioEngineImpl(); ~AudioEngineImpl() override; diff --git a/native/cocos/base/Any.h b/native/cocos/base/Any.h new file mode 100644 index 0000000000..a27f9c33d1 --- /dev/null +++ b/native/cocos/base/Any.h @@ -0,0 +1,103 @@ +/**************************************************************************** + 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 + +#ifdef USE_CXX_17 + + #include + +namespace cc { + +using any = std::any; + +template +inline ValueType *any_cast(any *operand) noexcept { + return std::any_cast(operand); +} + +template +inline const ValueType *any_cast(const any *operand) noexcept { + return std::any_cast(operand); +} + +template +inline ValueType any_cast(any &operand) { + return std::any_cast(operand); +} + +template +inline ValueType any_cast(const any &operand) { + return std::any_cast(operand); +} + +template +inline ValueType any_cast(any &&operand) { + return std::any_cast(operand); +} + +} // namespace cc + +#else + + #include "boost/any.hpp" + +namespace cc { +class any : public boost::any { // NOLINT // use std style +public: + using boost::any::any; + + inline bool has_value() const noexcept { // NOLINT // use std style + return !this->empty(); + } +}; + +template +inline ValueType *any_cast(any *operand) noexcept { // NOLINT // use std style + return boost::any_cast(operand); +} + +template +inline const ValueType *any_cast(const any *operand) noexcept { // NOLINT // use std style + return boost::any_cast(operand); +} + +template +inline ValueType any_cast(any &operand) { // NOLINT // use std style + return boost::any_cast(operand); +} + +template +inline ValueType any_cast(const any &operand) { // NOLINT // use std style + return boost::any_cast(operand); +} + +template +inline ValueType any_cast(any &&operand) { // NOLINT // use std style + return boost::any_cast(operand); +} + +} // namespace cc +#endif diff --git a/native/cocos/base/AutoreleasePool.cpp b/native/cocos/base/AutoreleasePool.cpp deleted file mode 100644 index 95a589e5fc..0000000000 --- a/native/cocos/base/AutoreleasePool.cpp +++ /dev/null @@ -1,156 +0,0 @@ -/**************************************************************************** - Copyright (c) 2010-2012 cocos2d-x.org - Copyright (c) 2013-2016 Chukong Technologies Inc. - Copyright (c) 2017-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 "base/AutoreleasePool.h" -#include "base/Log.h" - -namespace cc { - -LegacyAutoreleasePool::LegacyAutoreleasePool() -#if defined(CC_DEBUG) && (CC_DEBUG > 0) -: _isClearing(false) -#endif -{ - _managedObjectArray.reserve(150); - PoolManager::getInstance()->push(this); -} - -LegacyAutoreleasePool::LegacyAutoreleasePool(std::string name) -: _name(std::move(name)) -#if defined(CC_DEBUG) && (CC_DEBUG > 0) - , - _isClearing(false) -#endif -{ - _managedObjectArray.reserve(150); - PoolManager::getInstance()->push(this); -} - -LegacyAutoreleasePool::~LegacyAutoreleasePool() { - CC_LOG_INFO("deallocing AutoreleasePool: %p", this); - clear(); - - PoolManager::getInstance()->pop(); -} - -void LegacyAutoreleasePool::addObject(Ref *object) { - _managedObjectArray.push_back(object); -} - -void LegacyAutoreleasePool::clear() { -#if defined(CC_DEBUG) && (CC_DEBUG > 0) - _isClearing = true; -#endif - std::vector releasings; - releasings.swap(_managedObjectArray); - for (const auto &obj : releasings) { - obj->release(); - } -#if defined(CC_DEBUG) && (CC_DEBUG > 0) - _isClearing = false; -#endif -} - -bool LegacyAutoreleasePool::contains(Ref *object) const { - for (const auto &obj : _managedObjectArray) { - if (obj == object) { - return true; - } - } - return false; -} - -void LegacyAutoreleasePool::dump() { - CC_LOG_DEBUG("autorelease pool: %s, number of managed object %d\n", _name.c_str(), static_cast(_managedObjectArray.size())); - CC_LOG_DEBUG("%20s%20s%20s", "Object pointer", "Object id", "reference count"); - for (const auto &obj : _managedObjectArray) { - CC_UNUSED_PARAM(obj); - CC_LOG_DEBUG("%20p%20u\n", obj, obj->getReferenceCount()); - } -} - -//-------------------------------------------------------------------- -// -// PoolManager -// -//-------------------------------------------------------------------- - -PoolManager *PoolManager::_singleInstance = nullptr; - -PoolManager *PoolManager::getInstance() { - if (_singleInstance == nullptr) { - _singleInstance = new (std::nothrow) PoolManager(); - _singleInstance->push(new LegacyAutoreleasePool()); - } - return _singleInstance; -} - -void PoolManager::destroyInstance() { - delete _singleInstance; - _singleInstance = nullptr; -} - -PoolManager::PoolManager() { - _releasePoolStack.reserve(10); -} - -PoolManager::~PoolManager() { - CC_LOG_INFO("deallocing PoolManager: %p", this); - - while (!_releasePoolStack.empty()) { - LegacyAutoreleasePool *pool = _releasePoolStack.back(); - - delete pool; - } -} - -LegacyAutoreleasePool *PoolManager::getCurrentPool() const { - if (_releasePoolStack.empty()) { - return nullptr; - } - return _releasePoolStack.back(); -} - -bool PoolManager::isObjectInPools(Ref *obj) const { - for (const auto &pool : _releasePoolStack) { - if (pool->contains(obj)) { - return true; - } - } - return false; -} - -void PoolManager::push(LegacyAutoreleasePool *pool) { - _releasePoolStack.push_back(pool); -} - -void PoolManager::pop() { - CC_ASSERT(!_releasePoolStack.empty()); - _releasePoolStack.pop_back(); -} - -} // namespace cc diff --git a/native/cocos/base/DeferredReleasePool.cpp b/native/cocos/base/DeferredReleasePool.cpp new file mode 100644 index 0000000000..c201179ebf --- /dev/null +++ b/native/cocos/base/DeferredReleasePool.cpp @@ -0,0 +1,64 @@ +/**************************************************************************** + Copyright (c) 2010-2012 cocos2d-x.org + Copyright (c) 2013-2016 Chukong Technologies Inc. + Copyright (c) 2017-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 "base/DeferredReleasePool.h" +#include +#include "base/Log.h" +namespace cc { + +std::vector DeferredReleasePool::managedObjectArray{}; + +void DeferredReleasePool::add(RefCounted *object) { + DeferredReleasePool::managedObjectArray.push_back(object); +} + +void DeferredReleasePool::clear() { + for (const auto &obj : DeferredReleasePool::managedObjectArray) { + obj->release(); + } + DeferredReleasePool::managedObjectArray.clear(); +} + +bool DeferredReleasePool::contains(RefCounted *object) { + for (const auto &obj : DeferredReleasePool::managedObjectArray) { // NOLINT(readability-use-anyofallof) // remove after using C++20 + if (obj == object) { + return true; + } + } + return false; +} + +void DeferredReleasePool::dump() { + CC_LOG_DEBUG("number of managed object %ul\n", DeferredReleasePool::managedObjectArray.size()); + CC_LOG_DEBUG("%20s%20s%20s", "Object pointer", "Object id", "reference count"); + for (const auto &obj : DeferredReleasePool::managedObjectArray) { + CC_UNUSED_PARAM(obj); + CC_LOG_DEBUG("%20p%20u\n", obj, obj->getRefCount()); + } +} + +} // namespace cc diff --git a/native/cocos/base/AutoreleasePool.h b/native/cocos/base/DeferredReleasePool.h similarity index 51% rename from native/cocos/base/AutoreleasePool.h rename to native/cocos/base/DeferredReleasePool.h index 2ac1a8aed5..c64836d20c 100644 --- a/native/cocos/base/AutoreleasePool.h +++ b/native/cocos/base/DeferredReleasePool.h @@ -27,58 +27,16 @@ #pragma once -#include #include -#include "base/Ref.h" +#include +#include "base/RefCounted.h" namespace cc { -/** - * A pool for managing autorelease objects. - */ -class CC_DLL LegacyAutoreleasePool { +class CC_DLL DeferredReleasePool { public: - /** - * @warning Don't create an autorelease pool in heap, create it in stack. - */ - LegacyAutoreleasePool(); - - /** - * Create an autorelease pool with specific name. This name is useful for debugging. - * @warning Don't create an autorelease pool in heap, create it in stack. - * - * @param name The name of created autorelease pool. - */ - explicit LegacyAutoreleasePool(std::string name); - - ~LegacyAutoreleasePool(); - - /** - * Add a given object to this autorelease pool. - * - * The same object may be added several times to an autorelease pool. When the - * pool is destructed, the object's `Ref::release()` method will be called - * the same times as it was added. - * - * @param object The object to be added into the autorelease pool. - */ - void addObject(Ref *object); - - /** - * Clear the autorelease pool. - * - * It will invoke each element's `release()` function. - */ - void clear(); - -#if defined(CC_DEBUG) && (CC_DEBUG > 0) - /** - * Whether the autorelease pool is doing `clear` operation. - * - * @return True if autorelease pool is clearing, false if not. - */ - bool isClearing() const { return _isClearing; }; -#endif + static void add(RefCounted *object); + static void clear(); /** * Checks whether the autorelease pool contains the specified object. @@ -86,7 +44,7 @@ public: * @param object The object to be checked. * @return True if the autorelease pool contains the object, false if not */ - bool contains(Ref *object) const; + static bool contains(RefCounted *object); /** * Dump the objects that are put into the autorelease pool. It is used for debugging. @@ -94,7 +52,7 @@ public: * The result will look like: * Object pointer address object id reference count */ - void dump(); + static void dump(); private: /** @@ -106,43 +64,7 @@ private: * be destructed properly by calling Ref::release() even if the object * is in the pool. */ - std::vector _managedObjectArray; - std::string _name; - -#if defined(CC_DEBUG) && (CC_DEBUG > 0) - /** - * The flag for checking whether the pool is doing `clear` operation. - */ - bool _isClearing; -#endif -}; - -class CC_DLL PoolManager { -public: - static PoolManager *getInstance(); - - static void destroyInstance(); - - /** - * Get current auto release pool, there is at least one auto release pool that created by engine. - * You can create your own auto release pool at demand, which will be put into auto release pool stack. - */ - LegacyAutoreleasePool *getCurrentPool() const; - - bool isObjectInPools(Ref *obj) const; - - friend class LegacyAutoreleasePool; - -private: - PoolManager(); - ~PoolManager(); - - void push(LegacyAutoreleasePool *pool); - void pop(); - - static PoolManager *_singleInstance; - - std::vector _releasePoolStack; + static std::vector managedObjectArray; }; } // namespace cc diff --git a/native/cocos/base/Macros.h b/native/cocos/base/Macros.h index 360c62fbdc..d97ca8259a 100644 --- a/native/cocos/base/Macros.h +++ b/native/cocos/base/Macros.h @@ -106,6 +106,9 @@ typedef SSIZE_T ssize_t; #define FLT_EPSILON 1.192092896e-07F #endif // FLT_EPSILON +#define CC_MIN(a, b) (((a) < (b)) ? (a) : (b)) +#define CC_MAX(a, b) (((a) < (b)) ? (b) : (a)) + /** Helper macros which converts 4-byte little/big endian integral number to the machine native number representation @@ -162,10 +165,10 @@ It should work same as apples CFSwapInt32LittleToHost(..) (p) = nullptr; \ } \ } while (0) -#define CC_SAFE_RETAIN(p) \ +#define CC_SAFE_ADD_REF(p) \ do { \ if (p) { \ - (p)->retain(); \ + (p)->addRef(); \ } \ } while (0) #define CC_BREAK_IF(cond) \ @@ -301,9 +304,9 @@ It should work same as apples CFSwapInt32LittleToHost(..) #include #else #if !defined(__QNX__) - #include + #include #else - #define CC_ENDIAN CC_ENDIAN_LITTLE + #define CC_ENDIAN CC_ENDIAN_LITTLE #endif #endif // (CC_PLATFORM == CC_PLATFORM_MAC_OSX) # @@ -406,25 +409,34 @@ It should work same as apples CFSwapInt32LittleToHost(..) _Pragma("clang diagnostic pop") #endif -#define CC_ENABLE_COPY_SEMANTICS(cls) \ +#define CC_DISALLOW_ASSIGN(TypeName) \ + TypeName &operator=(const TypeName &) = delete; \ + TypeName &operator=(TypeName &&) = delete + +#define CC_DISALLOW_COPY_MOVE_ASSIGN(TypeName) \ + TypeName(const TypeName &) = delete; \ + TypeName(TypeName &&) = delete; \ + CC_DISALLOW_ASSIGN(TypeName) + +#define ENABLE_COPY_SEMANTICS(cls) \ cls(const cls &) = default; \ cls &operator=(const cls &) = default; #define CC_DISABLE_COPY_SEMANTICS(cls) \ - cls(const cls &) = delete; \ + cls(const cls &) = delete; \ cls &operator=(const cls &) = delete; #define CC_ENABLE_MOVE_SEMANTICS(cls) \ - cls(cls &&) noexcept = default; \ + cls(cls &&) noexcept = default; \ cls &operator=(cls &&) noexcept = default; #define CC_DISABLE_MOVE_SEMANTICS(cls) \ - cls(cls &&) noexcept = delete; \ + cls(cls &&) noexcept = delete; \ cls &operator=(cls &&) noexcept = delete; #define CC_DISABLE_COPY_AND_MOVE_SEMANTICS(cls) \ - CC_DISABLE_COPY_SEMANTICS(cls) \ - CC_DISABLE_MOVE_SEMANTICS(cls) + CC_DISABLE_COPY_SEMANTICS(cls) \ + CC_DISABLE_MOVE_SEMANTICS(cls) #if (CC_COMPILER == CC_COMPILER_MSVC) #define CC_ALIGN(N) __declspec(align(N)) @@ -619,4 +631,32 @@ It should work same as apples CFSwapInt32LittleToHost(..) #else #define CC_PREDICT_TRUE(x) (x) #define CC_PREDICT_FALSE(x) (x) -#endif \ No newline at end of file +#endif + +#if defined(_MSC_VER) + #define CC_FORCE_INLINE __forceinline +#elif defined(__GNUC__) || defined(__clang__) + #define CC_FORCE_INLINE inline __attribute__((always_inline)) +#else + #if defined(__cplusplus) || defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L /* C99 */ + #define CC_FORCE_INLINE static inline + #elif + #define CC_FORCE_INLINE inline + #endif +#endif + +/// @name namespace cc { namespace event { +/// @{ +#ifdef __cplusplus + #define NS_CC_EVENT_BEGIN \ + namespace cc { \ + namespace event { + #define NS_CC_EVENT_END \ + } \ + } +#else + #define NS_CC_EVENT_BEGIN + #define NS_CC_EVENT_END +#endif +// end of namespace group +/// @} diff --git a/native/cocos/base/Map.h b/native/cocos/base/Map.h index 492336c441..c85f6e7d05 100644 --- a/native/cocos/base/Map.h +++ b/native/cocos/base/Map.h @@ -38,7 +38,7 @@ #include "base/Log.h" #include "base/Random.h" -#include "base/Ref.h" +#include "base/RefCounted.h" namespace cc { @@ -85,26 +85,26 @@ public: /** Default constructor */ Map() : _data() { - static_assert(std::is_convertible::value, "Invalid Type for cc::Map!"); + static_assert(std::is_convertible::value, "Invalid Type for cc::Map!"); } /** Constructor with capacity. */ explicit Map(ssize_t capacity) : _data() { - static_assert(std::is_convertible::value, "Invalid Type for cc::Map!"); + static_assert(std::is_convertible::value, "Invalid Type for cc::Map!"); _data.reserve(capacity); } /** Copy constructor. */ Map(const Map &other) { - static_assert(std::is_convertible::value, "Invalid Type for cc::Map!"); + static_assert(std::is_convertible::value, "Invalid Type for cc::Map!"); _data = other._data; addRefForAllObjects(); } /** Move constructor. */ Map(Map &&other) noexcept { - static_assert(std::is_convertible::value, "Invalid Type for cc::Map!"); + static_assert(std::is_convertible::value, "Invalid Type for cc::Map!"); _data = std::move(other._data); } @@ -237,7 +237,7 @@ public: */ void insert(const K &key, V object) { CCASSERT(object != nullptr, "Object is nullptr!"); - object->retain(); + object->addRef(); erase(key); _data.insert(std::make_pair(key, object)); } @@ -301,7 +301,7 @@ public: */ V getRandomObject() const { if (!_data.empty()) { - auto randIdx = RandomHelper::randomInt(0, static_cast(_data.size()) - 1); + auto randIdx = RandomHelper::randomInt(0, static_cast(_data.size()) - 1); const_iterator randIter = _data.begin(); std::advance(randIter, randIdx); return randIter->second; @@ -332,7 +332,7 @@ protected: /** Retains all the objects in the map */ void addRefForAllObjects() { for (auto iter = _data.begin(); iter != _data.end(); ++iter) { - iter->second->retain(); + iter->second->addRef(); } } diff --git a/native/cocos/base/Optional.h b/native/cocos/base/Optional.h new file mode 100644 index 0000000000..4181a3df1a --- /dev/null +++ b/native/cocos/base/Optional.h @@ -0,0 +1,57 @@ +/**************************************************************************** + 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 + +#ifdef USE_CXX_17 + + #include + +namespace cc { + +template +using optional = std::optional; + +using nullopt_t = std::nullopt_t; +inline constexpr nullopt_t nullopt{nullopt_t::__secret_tag{}, nullopt_t::__secret_tag{}}; + +}; // namespace cc +#else + #include + #include "boost/none.hpp" + #include "boost/optional.hpp" + +namespace cc { + +template + +using optional = boost::optional; +using nullopt_t = boost::none_t; + +const nullopt_t nullopt((boost::none_t::init_tag())); // NOLINT // use std style + +}; // namespace cc + +#endif diff --git a/native/cocos/base/Ptr.h b/native/cocos/base/Ptr.h new file mode 100644 index 0000000000..825bc088bc --- /dev/null +++ b/native/cocos/base/Ptr.h @@ -0,0 +1,211 @@ +/**************************************************************************** + 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. + ****************************************************************************/ + +// Originally the class is from WebRTC. +// https://chromium.googlesource.com/external/webrtc/+/master/api/scoped_refptr.h +// + +// A smart pointer class for reference counted objects. Use this class instead +// of calling addRef and Release manually on a reference counted object to +// avoid common memory leaks caused by forgetting to Release an object +// reference. Sample usage: +// +// class MyFoo : public RefCounted { +// ... +// }; +// +// void some_function() { +// IntrusivePtr foo = new MyFoo(); +// foo->Method(param); +// // `foo` is released when this function returns +// } +// +// void some_other_function() { +// IntrusivePtr foo = new MyFoo(); +// ... +// foo = nullptr; // explicitly releases `foo` +// ... +// if (foo) +// foo->Method(param); +// } +// +// The above examples show how IntrusivePtr acts like a pointer to T. +// Given two IntrusivePtr classes, it is also possible to exchange +// references between the two objects, like so: +// +// { +// IntrusivePtr a = new MyFoo(); +// IntrusivePtr b; +// +// b.swap(a); +// // now, `b` references the MyFoo object, and `a` references null. +// } +// +// To make both `a` and `b` in the above example reference the same MyFoo +// object, simply use the assignment operator: +// +// { +// IntrusivePtr a = new MyFoo(); +// IntrusivePtr b; +// +// b = a; +// // now, `a` and `b` each own a reference to the same MyFoo object. +// } +// + +#pragma once + +#include +#include "base/RefCounted.h" + +namespace cc { + +template +class IntrusivePtr { +public: + using element_type = T; + + IntrusivePtr() { + static_assert(std::is_base_of::value, "RefCounted required!"); + } + + IntrusivePtr(T *p) : _ptr(p) { // NOLINT + static_assert(std::is_base_of::value, "RefCounted required!"); + if (_ptr) { + reinterpret_cast(_ptr)->addRef(); + } + } + + IntrusivePtr(const IntrusivePtr &r) : _ptr(r._ptr) { + static_assert(std::is_base_of::value, "RefCounted required!"); + if (_ptr) { + reinterpret_cast(_ptr)->addRef(); + } + } + + template + IntrusivePtr(const IntrusivePtr &r) : _ptr(r.get()) { // NOLINT + static_assert(std::is_base_of::value, "RefCounted required!"); + if (_ptr) { + reinterpret_cast(_ptr)->addRef(); + } + } + + // Move constructors. + IntrusivePtr(IntrusivePtr &&r) noexcept : _ptr(r.release()) { + static_assert(std::is_base_of::value, "RefCounted required!"); + } + + template + IntrusivePtr(IntrusivePtr &&r) noexcept : _ptr(r.release()) { // NOLINT + static_assert(std::is_base_of::value, "RefCounted required!"); + } + + ~IntrusivePtr() { + if (_ptr) { + reinterpret_cast(_ptr)->release(); + } + } + + T *get() const { return _ptr; } + operator T *() const { return _ptr; } // NOLINT + T &operator*() const { return *_ptr; } + T *operator->() const { return _ptr; } + + // As reference count is 1 after creating a RefCounted object, so do not have to + // invoke p->addRef(); + IntrusivePtr &operator=(T *p) { + // AddRef first so that self assignment should work + if (p) { + reinterpret_cast(p)->addRef(); + } + if (_ptr) { + reinterpret_cast(_ptr)->release(); + } + _ptr = p; + return *this; + } + + IntrusivePtr &operator=(const IntrusivePtr &r) { // NOLINT + return *this = r._ptr; // NOLINT + } + + template + IntrusivePtr &operator=(const IntrusivePtr &r) { + return *this = r.get(); // NOLINT + } + + IntrusivePtr &operator=(IntrusivePtr &&r) noexcept { + IntrusivePtr(std::move(r)).swap(*this); + return *this; + } + + template + IntrusivePtr &operator=(IntrusivePtr &&r) noexcept { + IntrusivePtr(std::move(r)).swap(*this); + return *this; + } + + bool operator==(std::nullptr_t) { + return _ptr == nullptr; + } + + bool operator==(T *r) { + return _ptr == r; + } + + bool operator!=(std::nullptr_t) { + return _ptr != nullptr; + } + + bool operator!=(T *r) { + return _ptr != r; + } + + void swap(T **pp) noexcept { + T *p = _ptr; + _ptr = *pp; + *pp = p; + } + + void swap(IntrusivePtr &r) noexcept { swap(&r._ptr); } + +private: + // Returns the (possibly null) raw pointer, and makes the scoped_refptr hold a + // null pointer, all without touching the reference count of the underlying + // pointed-to object. The object is still reference counted, and the caller of + // release() is now the proud owner of one reference, so it is responsible for + // calling Release() once on the object when no longer using it. + T *release() { + T *retVal = _ptr; + _ptr = nullptr; + return retVal; + } + +protected: + T *_ptr{nullptr}; +}; + +} // namespace cc diff --git a/native/cocos/base/Ref.cpp b/native/cocos/base/Ref.cpp deleted file mode 100644 index ca2c715b73..0000000000 --- a/native/cocos/base/Ref.cpp +++ /dev/null @@ -1,157 +0,0 @@ -/**************************************************************************** - Copyright (c) 2010-2012 cocos2d-x.org - Copyright (c) 2013-2016 Chukong Technologies Inc. - Copyright (c) 2017-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 "base/Ref.h" -#include "base/AutoreleasePool.h" -#include "base/Macros.h" - -#if CC_REF_LEAK_DETECTION - #include // std::find -#endif - -namespace cc { - -#if CC_REF_LEAK_DETECTION -static void trackRef(Ref *ref); -static void untrackRef(Ref *ref); -#endif - -Ref::Ref() -: _referenceCount(1) // when the Ref is created, the reference count of it is 1 -{ -#if CC_REF_LEAK_DETECTION - trackRef(this); -#endif -} - -Ref::~Ref() { -#if CC_REF_LEAK_DETECTION - if (_referenceCount != 0) - untrackRef(this); -#endif -} - -void Ref::retain() { - CCASSERT(_referenceCount > 0, "reference count should be greater than 0"); - ++_referenceCount; -} - -void Ref::release() { - CCASSERT(_referenceCount > 0, "reference count should be greater than 0"); - --_referenceCount; - - if (_referenceCount == 0) { -#if defined(CC_DEBUG) && (CC_DEBUG > 0) - auto *poolManager = PoolManager::getInstance(); - auto *currentPool = poolManager->getCurrentPool(); - if (currentPool && !currentPool->isClearing() && poolManager->isObjectInPools(this)) { - // Trigger an assert if the reference count is 0 but the Ref is still in autorelease pool. - // This happens when 'autorelease/release' were not used in pairs with 'new/retain'. - // - // Wrong usage (1): - // - // auto obj = Node::create(); // Ref = 1, but it's an autorelease Ref which means it was in the autorelease pool. - // obj->autorelease(); // Wrong: If you wish to invoke autorelease several times, you should retain `obj` first. - // - // Wrong usage (2): - // - // auto obj = Node::create(); - // obj->release(); // Wrong: obj is an autorelease Ref, it will be released when clearing current pool. - // - // Correct usage (1): - // - // auto obj = Node::create(); - // |- new Node(); // `new` is the pair of the `autorelease` of next line - // |- autorelease(); // The pair of `new Node`. - // - // obj->retain(); - // obj->autorelease(); // This `autorelease` is the pair of `retain` of previous line. - // - // Correct usage (2): - // - // auto obj = Node::create(); - // obj->retain(); - // obj->release(); // This `release` is the pair of `retain` of previous line. - CCASSERT(false, "The reference shouldn't be 0 because it is still in autorelease pool."); - } -#endif - -#if CC_REF_LEAK_DETECTION - untrackRef(this); -#endif - delete this; - } -} - -Ref *Ref::autorelease() { - PoolManager::getInstance()->getCurrentPool()->addObject(this); - return this; -} - -unsigned int Ref::getReferenceCount() const { - return _referenceCount; -} - -#if CC_REF_LEAK_DETECTION - -static std::list __refAllocationList; - -void Ref::printLeaks() { - // Dump Ref object memory leaks - if (__refAllocationList.empty()) { - log("[memory] All Ref objects successfully cleaned up (no leaks detected).\n"); - } else { - log("[memory] WARNING: %d Ref objects still active in memory.\n", (int)__refAllocationList.size()); - - for (const auto &ref : __refAllocationList) { - CC_ASSERT(ref); - const char *type = typeid(*ref).name(); - log("[memory] LEAK: Ref object '%s' still active with reference count %d.\n", (type ? type : ""), ref->getReferenceCount()); - } - } -} - -static void trackRef(Ref *ref) { - CCASSERT(ref, "Invalid parameter, ref should not be null!"); - - // Create memory allocation record. - __refAllocationList.push_back(ref); -} - -static void untrackRef(Ref *ref) { - auto iter = std::find(__refAllocationList.begin(), __refAllocationList.end(), ref); - if (iter == __refAllocationList.end()) { - log("[memory] CORRUPTION: Attempting to free (%s) with invalid ref tracking record.\n", typeid(*ref).name()); - return; - } - - __refAllocationList.erase(iter); -} - -#endif // #if CC_REF_LEAK_DETECTION - -} // namespace cc diff --git a/native/cocos/base/RefCounted.cpp b/native/cocos/base/RefCounted.cpp new file mode 100644 index 0000000000..a4254b09b7 --- /dev/null +++ b/native/cocos/base/RefCounted.cpp @@ -0,0 +1,110 @@ +/**************************************************************************** + Copyright (c) 2010-2012 cocos2d-x.org + Copyright (c) 2013-2016 Chukong Technologies Inc. + Copyright (c) 2017-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 "base/RefCounted.h" + +#if CC_REF_LEAK_DETECTION + #include // std::find + #include + #include "base/Log.h" +#endif + +namespace cc { + +#if CC_REF_LEAK_DETECTION +static void trackRef(RefCounted *ref); +static void untrackRef(RefCounted *ref); +#endif + +RefCounted::RefCounted() { // NOLINT(modernize-use-equals-default) +#if CC_REF_LEAK_DETECTION + trackRef(this); +#endif +} + +RefCounted::~RefCounted() { // NOLINT(modernize-use-equals-default) +#if CC_REF_LEAK_DETECTION + untrackRef(this); +#endif +} + +void RefCounted::addRef() { + ++_referenceCount; +} + +void RefCounted::release() { + CC_ASSERT(_referenceCount > 0); + --_referenceCount; + + if (_referenceCount == 0) { + delete this; + } +} + +unsigned int RefCounted::getRefCount() const { + return _referenceCount; +} + +#if CC_REF_LEAK_DETECTION + +static std::list __refAllocationList; + +void RefCounted::printLeaks() { + // Dump Ref object memory leaks + if (__refAllocationList.empty()) { + CC_LOG_INFO("[memory] All Ref objects successfully cleaned up (no leaks detected).\n"); + } else { + CC_LOG_INFO("[memory] WARNING: %d Ref objects still active in memory.\n", (int)__refAllocationList.size()); + + for (const auto &ref : __refAllocationList) { + CC_ASSERT(ref); + const char *type = typeid(*ref).name(); + CC_LOG_INFO("[memory] LEAK: Ref object '%s' still active with reference count %d.\n", (type ? type : ""), ref->getRefCount()); + } + } +} + +static void trackRef(RefCounted *ref) { + CC_ASSERT(ref); + + // Create memory allocation record. + __refAllocationList.push_back(ref); +} + +static void untrackRef(RefCounted *ref) { + auto iter = std::find(__refAllocationList.begin(), __refAllocationList.end(), ref); + if (iter == __refAllocationList.end()) { + CC_LOG_INFO("[memory] CORRUPTION: Attempting to free (%s) with invalid ref tracking record.\n", typeid(*ref).name()); + return; + } + + __refAllocationList.erase(iter); +} + +#endif // #if CC_REF_LEAK_DETECTION + +} // namespace cc diff --git a/native/cocos/base/Ref.h b/native/cocos/base/RefCounted.h similarity index 82% rename from native/cocos/base/Ref.h rename to native/cocos/base/RefCounted.h index d8b023e5d6..3854b471d5 100644 --- a/native/cocos/base/Ref.h +++ b/native/cocos/base/RefCounted.h @@ -27,14 +27,14 @@ #pragma once -#include "base/Macros.h" #include "base/Config.h" +#include "base/Macros.h" #define CC_REF_LEAK_DETECTION 0 namespace cc { -class Ref; +class RefCounted; /** * Interface that defines how to clone an Ref. @@ -51,8 +51,10 @@ public: * Ref is used for reference count management. If a class inherits from Ref, * then it is easy to be shared in different places. */ -class CC_DLL Ref { +class CC_DLL RefCounted { public: + virtual ~RefCounted(); + /** * Retains the ownership. * @@ -60,7 +62,7 @@ public: * * @see release, autorelease */ - void retain(); + void addRef(); /** * Releases the ownership immediately. @@ -74,27 +76,12 @@ public: */ void release(); - /** - * Releases the ownership sometime soon automatically. - * - * This decrements the Ref's reference count at the end of current - * autorelease pool block. - * - * If the reference count reaches 0 after the decrement, this Ref is - * destructed. - * - * @returns The Ref itself. - * - * @see AutoreleasePool, retain, release - */ - Ref *autorelease(); - /** * Returns the Ref's current reference count. * * @returns The Ref's reference count. */ - unsigned int getReferenceCount() const; + unsigned int getRefCount() const; protected: /** @@ -102,15 +89,10 @@ protected: * * The Ref's reference count is 1 after construction. */ - Ref(); + RefCounted(); - virtual ~Ref(); - -protected: /// count of references - unsigned int _referenceCount; - - friend class AutoreleasePool; + unsigned int _referenceCount{0}; // Memory leak diagnostic data (only included when CC_REF_LEAK_DETECTION is defined and its value isn't zero) #if CC_REF_LEAK_DETECTION @@ -119,4 +101,7 @@ public: #endif }; +using SCHEDULE_CB = void (RefCounted::*)(float); +#define CC_SCHEDULE_CALLBACK(cb) static_cast(&cb) + } // namespace cc diff --git a/native/cocos/base/Scheduler.cpp b/native/cocos/base/Scheduler.cpp index 1d945ca0be..b761920028 100644 --- a/native/cocos/base/Scheduler.cpp +++ b/native/cocos/base/Scheduler.cpp @@ -29,12 +29,11 @@ #include "base/Scheduler.h" -#include #include - -#include "base/Macros.h" -#include "base/Log.h" #include +#include +#include "base/Log.h" +#include "base/Macros.h" namespace { constexpr unsigned CC_REPEAT_FOREVER{UINT_MAX - 1}; @@ -183,8 +182,9 @@ void Scheduler::schedule(const ccSchedulerFunc &callback, void *target, float in } auto *timer = new (std::nothrow) TimerTargetCallback(); + timer->addRef(); timer->initWithCallback(this, callback, target, key, interval, repeat, delay); - element->timers.push_back(timer); + element->timers.emplace_back(timer); } void Scheduler::unschedule(const std::string &key, void *target) { @@ -204,7 +204,7 @@ void Scheduler::unschedule(const std::string &key, void *target) { if (timer && key == timer->getKey()) { if (timer == element->currentTimer && (!element->currentTimerSalvaged)) { - element->currentTimer->retain(); + element->currentTimer->addRef(); element->currentTimerSalvaged = true; } @@ -273,7 +273,7 @@ void Scheduler::unscheduleAllForTarget(void *target) { auto & timers = element->timers; if (std::find(timers.begin(), timers.end(), element->currentTimer) != timers.end() && (!element->currentTimerSalvaged)) { - element->currentTimer->retain(); + element->currentTimer->addRef(); element->currentTimerSalvaged = true; } @@ -347,7 +347,7 @@ void Scheduler::update(float dt) { if (!_currentTarget->paused) { // The 'timers' array may change while inside this loop for (elt->timerIndex = 0; elt->timerIndex < static_cast(elt->timers.size()); ++(elt->timerIndex)) { - elt->currentTimer = elt->timers[elt->timerIndex]; + elt->currentTimer = elt->timers.at(elt->timerIndex); elt->currentTimerSalvaged = false; elt->currentTimer->update(dt); diff --git a/native/cocos/base/Scheduler.h b/native/cocos/base/Scheduler.h index 9da227abb4..7ce8315924 100644 --- a/native/cocos/base/Scheduler.h +++ b/native/cocos/base/Scheduler.h @@ -35,8 +35,7 @@ #include #include -#include "base/Ref.h" -//#include "base/Vector.h" +#include "base/RefCounted.h" namespace cc { @@ -47,7 +46,7 @@ using ccSchedulerFunc = std::function; /** * @cond */ -class CC_DLL Timer : public Ref { +class CC_DLL Timer : public RefCounted { public: /** get interval in seconds */ inline float getInterval() const { return _interval; }; @@ -65,15 +64,14 @@ public: protected: Timer() = default; -protected: Scheduler * _scheduler = nullptr; - float _elapsed = 0.f; + float _elapsed = 0.F; bool _runForever = false; bool _useDelay = false; unsigned int _timesExecuted = 0; unsigned int _repeat = 0; //0 = once, 1 is 2 x executed - float _delay = 0.f; - float _interval = 0.f; + float _delay = 0.F; + float _interval = 0.F; }; class CC_DLL TimerTargetCallback final : public Timer { diff --git a/native/cocos/base/StringUtil.cpp b/native/cocos/base/StringUtil.cpp old mode 100755 new mode 100644 index c7bd037224..49cc624fe2 --- a/native/cocos/base/StringUtil.cpp +++ b/native/cocos/base/StringUtil.cpp @@ -24,9 +24,13 @@ ****************************************************************************/ #include "StringUtil.h" -#include "memory/Memory.h" -#include + +#include #include +#include +#include "base/ZipUtils.h" +#include "base/base64.h" +#include "memory/Memory.h" #if (CC_PLATFORM == CC_PLATFORM_WINDOWS) #ifndef WIN32_LEAN_AND_MEAN @@ -59,8 +63,8 @@ int StringUtil::vprintf(char *buf, const char *last, const char *fmt, va_list ar return 0; } - int count = static_cast(last - buf); - int ret = vsnprintf(buf, count, fmt, args); + auto count = static_cast(last - buf); + int ret = vsnprintf(buf, count, fmt, args); if (ret >= count - 1) { return count - 1; } @@ -125,4 +129,49 @@ StringArray StringUtil::split(const String &str, const String &delims, uint maxS return strs; } +String &StringUtil::replace(String &str, const String &findStr, const String &replaceStr) { + size_t startPos = str.find(findStr); + if (startPos == std::string::npos) { + return str; + } + str.replace(startPos, findStr.length(), replaceStr); + return str; +} + +String &StringUtil::replaceAll(String &str, const String &findStr, const String &replaceStr) { + if (findStr.empty()) { + return str; + } + size_t startPos = 0; + while ((startPos = str.find(findStr, startPos)) != std::string::npos) { + str.replace(startPos, findStr.length(), replaceStr); + startPos += replaceStr.length(); + } + return str; +} + +String &StringUtil::tolower(String &str) { + std::transform(str.begin(), str.end(), str.begin(), + [](unsigned char c) { return std::tolower(c); }); + return str; +} + +String &StringUtil::toupper(String &str) { + std::transform(str.begin(), str.end(), str.begin(), + [](unsigned char c) { return std::toupper(c); }); + return str; +} + +std::string GzipedString::value() const { // NOLINT(readability-convert-member-functions-to-static) + uint8_t * outGzip{nullptr}; + uint8_t * outBase64{nullptr}; + auto * input = reinterpret_cast(const_cast(_str.c_str())); + auto lenOfBase64 = base64Decode(input, static_cast(_str.size()), &outBase64); + auto lenofUnzip = ZipUtils::inflateMemory(outBase64, static_cast(lenOfBase64), &outGzip); + std::string ret(outGzip, outGzip + lenofUnzip); + free(outGzip); + free(outBase64); + return ret; +} + } // namespace cc diff --git a/native/cocos/base/StringUtil.h b/native/cocos/base/StringUtil.h old mode 100755 new mode 100644 index b4d356452e..2d1b55109f --- a/native/cocos/base/StringUtil.h +++ b/native/cocos/base/StringUtil.h @@ -25,10 +25,11 @@ #pragma once +#include +#include #include "Macros.h" #include "TypeDef.h" #include "memory/Memory.h" -#include namespace cc { @@ -38,6 +39,41 @@ public: static int printf(char *buf, const char *last, const char *fmt, ...); static String format(const char *fmt, ...); static StringArray split(const String &str, const String &delims, uint maxSplits = 0); + static String & replace(String &str, const String &findStr, const String &replaceStr); + static String & replaceAll(String &str, const String &findStr, const String &replaceStr); + static String & tolower(String &str); + static String & toupper(String &str); +}; + +/** + * Store compressed text which compressed with gzip & base64 + * fetch plain-text with `value()`. + */ +class CC_DLL GzipedString { +public: + explicit GzipedString(std::string &&dat) : _str(dat) {} + explicit GzipedString(const char *dat) : _str(dat) {} + GzipedString(const GzipedString &o) = default; + GzipedString &operator=(const GzipedString &d) = default; + + GzipedString(GzipedString &&o) noexcept { + _str = std::move(o._str); + } + GzipedString &operator=(std::string &&d) { + _str = std::move(d); + return *this; + } + GzipedString &operator=(GzipedString &&d) noexcept { + _str = std::move(d._str); + return *this; + } + /** + * return text decompress with base64decode | un-gzip + */ + std::string value() const; + +private: + std::string _str{}; }; } // namespace cc diff --git a/native/cocos/base/TypeDef.h b/native/cocos/base/TypeDef.h old mode 100755 new mode 100644 index 59a6c8b9c9..3506f73a5d --- a/native/cocos/base/TypeDef.h +++ b/native/cocos/base/TypeDef.h @@ -26,20 +26,27 @@ #pragma once #include +#include +#include "base/Macros.h" - -using uint = std::uint32_t; -using ushort = std::uint16_t; +using uint = std::uint32_t; +using ushort = std::uint16_t; #if (CC_PLATFORM != CC_PLATFORM_LINUX && CC_PLATFORM != CC_PLATFORM_QNX) // linux has typedef ulong -using ulong = std::uint32_t; +using ulong = std::uint32_t; #endif using FlagBits = std::uint32_t; +using index_t = int32_t; +#define CC_INVALID_INDEX (-1) + +#define Record std::unordered_map // NOLINT(readability-identifier-naming) + #define CC_ENUM_CONVERSION_OPERATOR(T) \ inline std::underlying_type::type toNumber(const T v) { return static_cast::type>(v); } #define CC_ENUM_BITWISE_OPERATORS(T) \ + inline bool operator!(const T v) { return !static_cast::type>(v); } \ inline T operator~(const T v) { return static_cast(~static_cast::type>(v)); } \ inline bool operator||(const T lhs, const T rhs) { return (static_cast::type>(lhs) || static_cast::type>(rhs)); } \ inline bool operator&&(const T lhs, const T rhs) { return (static_cast::type>(lhs) && static_cast::type>(rhs)); } \ diff --git a/native/cocos/base/Utils.h b/native/cocos/base/Utils.h index c3beda253a..07380ac0a4 100644 --- a/native/cocos/base/Utils.h +++ b/native/cocos/base/Utils.h @@ -28,10 +28,10 @@ #pragma once #include -#include -#include #include #include +#include +#include #include "base/Macros.h" #include "base/TypeDef.h" /** @file ccUtils.h @@ -69,7 +69,7 @@ T alignTo(T size, T alignment) { return ((size - 1) / alignment + 1) * alignment; } -template +template constexpr uint ALIGN_TO = ((size - 1) / alignment + 1) * alignment; template @@ -82,5 +82,95 @@ uint toUint(T value) { return static_cast(value); } +template +Map &mergeToMap(Map &outMap, const Map &inMap) { + for (const auto &e : inMap) { + outMap.emplace(e.first, e.second); + } + return outMap; +} + +namespace array { + +/** + * @zh + * 移除首个指定的数组元素。判定元素相等时相当于于使用了 `Array.prototype.indexOf`。 + * @en + * Removes the first occurrence of a specific object from the array. + * Decision of the equality of elements is similar to `Array.prototype.indexOf`. + * @param array 数组。 + * @param value 待移除元素。 + */ +template +bool remove(std::vector &array, T value) { + auto iter = std::find(array.begin(), array.end(), value); + if (iter != array.end()) { + array.erase(iter); + return true; + } + return false; +} + +/** + * @zh + * 移除指定索引的数组元素。 + * @en + * Removes the array item at the specified index. + * @param array 数组。 + * @param index 待移除元素的索引。 + */ +template +bool removeAt(std::vector &array, int32_t index) { + if (index >= 0 && index < static_cast(array.size())) { + array.erase(array.begin() + index); + return true; + } + return false; +} + +/** + * @zh + * 移除指定索引的数组元素。 + * 此函数十分高效,但会改变数组的元素次序。 + * @en + * Removes the array item at the specified index. + * It's faster but the order of the array will be changed. + * @param array 数组。 + * @param index 待移除元素的索引。 + */ +template +bool fastRemoveAt(std::vector &array, int32_t index) { + const auto length = static_cast(array.size()); + if (index < 0 || index >= length) { + return false; + } + array[index] = array[length - 1]; + array.resize(length - 1); + return true; +} + +/** + * @zh + * 移除首个指定的数组元素。判定元素相等时相当于于使用了 `Array.prototype.indexOf`。 + * 此函数十分高效,但会改变数组的元素次序。 + * @en + * Removes the first occurrence of a specific object from the array. + * Decision of the equality of elements is similar to `Array.prototype.indexOf`. + * It's faster but the order of the array will be changed. + * @param array 数组。 + * @param value 待移除元素。 + */ +template +bool fastRemove(std::vector &array, T value) { + auto iter = std::find(array.begin(), array.end(), value); + if (iter != array.end()) { + *iter = array[array.size() - 1]; + array.resize(array.size() - 1); + return true; + } + return false; +} + +} // namespace array } // namespace utils } // namespace cc diff --git a/native/cocos/base/Variant.h b/native/cocos/base/Variant.h new file mode 100644 index 0000000000..20ba8a8434 --- /dev/null +++ b/native/cocos/base/Variant.h @@ -0,0 +1,212 @@ +/**************************************************************************** + 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 + +#ifdef USE_CXX_17 + + #include + +namespace cc { +template +using variant = std::variant; + +using monostate = std::monostate; + +template +inline constexpr bool holds_alternative(variant const &v) noexcept { + return std::holds_alternative(v); +} + +// get_if + +template +inline constexpr typename std::add_pointer>>::type get_if(variant *v) noexcept { + return std::get_if(v); +} + +template +inline constexpr typename std::add_pointer>>::type get_if(variant const *v) noexcept { + return std::get_if(v); +} + +template +inline constexpr typename std::add_pointer::type get_if(variant *v) noexcept { + return std::get_if(v); +} + +template +inline constexpr typename std::add_pointer::type get_if(variant const *v) noexcept { + return std::get_if(v); +} + +// get (index) + +template +inline constexpr std::variant_alternative_t> &get(variant &v) { + return std::get(v); +} + +template +inline constexpr std::variant_alternative_t> &&get(variant &&v) { + return std::get(std::forward>(v)); +} + +template +inline constexpr std::variant_alternative_t> const &get(variant const &v) { + return std::get(v); +} + +template +inline constexpr std::variant_alternative_t> const &&get(variant const &&v) { + return std::get(v); +} + +// get (type) + +template +inline constexpr U &get(variant &v) { + return std::get(v); +} + +template +inline constexpr U &&get(variant &&v) { + return std::get(v); +} + +template +inline constexpr U const &get(variant const &v) { + return std::get(v); +} + +template +inline constexpr U const &&get(variant const &&v) { + return std::get(v); +} + +// visit + +template +inline constexpr decltype(auto) visit(_Visitor &&__visitor, _Vs &&...__vs) { + return std::visit(std::forward<_Visitor>(__visitor), std::forward<_Vs>(__vs)...); +} + +}; // namespace cc + +#else + + #include "boost/variant2/variant.hpp" + +namespace cc { +template +using variant = boost::variant2::variant; + +using monostate = boost::variant2::monostate; + +template +inline constexpr bool holds_alternative(variant const &v) noexcept { // NOLINT // use std style + return boost::variant2::holds_alternative(v); +} + +// get_if + +template +inline constexpr typename std::add_pointer>>::type get_if(variant *v) noexcept { // NOLINT // use std style + return boost::variant2::get_if(v); +} + +template +inline constexpr typename std::add_pointer>>::type get_if(variant const *v) noexcept { // NOLINT // use std style + return boost::variant2::get_if(v); +} + +template +inline constexpr typename std::add_pointer::type get_if(variant *v) noexcept { // NOLINT // use std style + return boost::variant2::get_if(v); +} + +template +inline constexpr typename std::add_pointer::type get_if(variant const *v) noexcept { // NOLINT // use std style + return boost::variant2::get_if(v); +} + +// get (index) + +template +inline constexpr boost::variant2::variant_alternative_t> &get(variant &v) { + return boost::variant2::get(v); +} + +template +inline constexpr boost::variant2::variant_alternative_t> &&get(variant &&v) { + return boost::variant2::get(std::forward>(v)); +} + +template +inline constexpr boost::variant2::variant_alternative_t> const &get(variant const &v) { + return boost::variant2::get(v); +} + +template +inline constexpr boost::variant2::variant_alternative_t> const &&get(variant const &&v) { + return boost::variant2::get(v); +} + +// get (type) + +template +inline constexpr U &get(variant &v) { + return boost::variant2::get(v); +} + +template +inline constexpr U &&get(variant &&v) { + return boost::variant2::get(v); +} + +template +inline constexpr U const &get(variant const &v) { + return boost::variant2::get(v); +} + +template +inline constexpr U const &&get(variant const &&v) { + return boost::variant2::get(v); +} + +// visit + +template +inline constexpr auto visit(F &&f, V1 &&v1) -> boost::variant2::detail::Vret { + return boost::variant2::visit(std::forward(f), std::forward(v1)); +} + +template +inline constexpr auto visit(F &&f, V1 &&v1, V2 &&v2, V &&...v) -> boost::variant2::detail::Vret { + return boost::variant2::visit(std::forward(f), std::forward(v1), std::forward(v2), std::forward(v)...); +} + +}; // namespace cc +#endif diff --git a/native/cocos/base/Vector.h b/native/cocos/base/Vector.h index 9924482f13..88d31f221b 100644 --- a/native/cocos/base/Vector.h +++ b/native/cocos/base/Vector.h @@ -28,21 +28,25 @@ #pragma once +#include #include // for std::find +#include #include #include #include "base/Log.h" #include "base/Macros.h" #include "base/Random.h" -#include "base/Ref.h" +#include "base/RefCounted.h" +#include "base/TypeDef.h" +#include "core/TypedArray.h" namespace cc { /* * Similar to std::vector, but it will manage reference count automatically internally. - * Which means it will invoke Ref::retain() when adding an element, and invoke Ref::release() when removing an element. - * @warn The element should be `Ref` or its sub-class. + * Which means it will invoke RefCounted::addRef() when adding an element, and invoke RefCounted::release() when removing an element. + * @warn The element should be `RefCounted` or its sub-class. */ template class Vector { @@ -108,17 +112,17 @@ public: /** Constructor. */ Vector() : _data() { - static_assert(std::is_convertible::value, "Invalid Type for cc::Vector!"); + static_assert(std::is_convertible::value, "Invalid Type for cc::Vector!"); } /** * Constructor with a capacity. * @param capacity Capacity of the Vector. */ - explicit Vector(ssize_t capacity) + explicit Vector(uint32_t capacity) : _data() { - static_assert(std::is_convertible::value, "Invalid Type for cc::Vector!"); - CC_LOG_INFO("In the default constructor with capacity of Vector."); + static_assert(std::is_convertible::value, "Invalid Type for cc::Vector!"); + // CC_LOG_INFO("In the default constructor with capacity of Vector."); reserve(capacity); } @@ -131,29 +135,44 @@ public: /** Destructor. */ ~Vector() { - CC_LOG_INFO("In the destructor of Vector."); + // CC_LOG_INFO("In the destructor of Vector."); clear(); } /** Copy constructor. */ Vector(const Vector &other) { - static_assert(std::is_convertible::value, "Invalid Type for cc::Vector!"); - CC_LOG_INFO("In the copy constructor!"); + static_assert(std::is_convertible::value, "Invalid Type for cc::Vector!"); + // CC_LOG_INFO("In the copy constructor!"); _data = other._data; addRefForAllObjects(); } + /** Copy constructor. */ + explicit Vector(const std::vector &other) { + static_assert(std::is_convertible::value, "Invalid Type for cc::Vector!"); + // CC_LOG_INFO("In the copy constructor!"); + _data = other; + addRefForAllObjects(); + } + /** Constructor with std::move semantic. */ Vector(Vector &&other) noexcept { - static_assert(std::is_convertible::value, "Invalid Type for cc::Vector!"); - CC_LOG_INFO("In the move constructor of Vector!"); + static_assert(std::is_convertible::value, "Invalid Type for cc::Vector!"); + // CC_LOG_INFO("In the move constructor of Vector!"); _data = std::move(other._data); } + /** Constructor with std::move semantic. */ + explicit Vector(std::vector &&other) noexcept { + static_assert(std::is_convertible::value, "Invalid Type for cc::Vector!"); + // CC_LOG_INFO("In the move constructor of Vector!"); + _data = std::move(other); + } + /** Copy assignment operator. */ Vector &operator=(const Vector &other) { if (this != &other) { - CC_LOG_INFO("In the copy assignment operator!"); + // CC_LOG_INFO("In the copy assignment operator!"); clear(); _data = other._data; addRefForAllObjects(); @@ -164,7 +183,7 @@ public: /** Copy assignment operator with std::move semantic. */ Vector &operator=(Vector &&other) noexcept { if (this != &other) { - CC_LOG_INFO("In the move assignment operator!"); + // CC_LOG_INFO("In the move assignment operator!"); clear(); _data = std::move(other._data); } @@ -175,7 +194,7 @@ public: * Requests that the vector capacity be at least enough to contain n elements. * @param capacity Minimum capacity requested of the Vector. */ - void reserve(ssize_t n) { + void reserve(uint32_t n) { _data.reserve(n); } @@ -184,7 +203,7 @@ public: * It can be equal or greater, with the extra space allowing to accommodate for growth without the need to reallocate on each insertion. * @return The size of the currently allocated storage capacity in the Vector, measured in terms of the number elements it can hold. */ - ssize_t capacity() const { + uint32_t capacity() const { return _data.capacity(); } @@ -192,8 +211,8 @@ public: * @note This is the number of actual objects held in the Vector, which is not necessarily equal to its storage capacity. * @return The number of elements in the Vector. */ - ssize_t size() const { - return _data.size(); + uint32_t size() const { + return static_cast(_data.size()); } /** @brief Returns whether the Vector is empty (i.e. whether its size is 0). @@ -204,12 +223,12 @@ public: } /** Returns the maximum number of elements that the Vector can hold. */ - ssize_t maxSize() const { + uint32_t maxSize() const { return _data.max_size(); } /** Returns index of a certain object, return UINT_MAX if doesn't contain the object */ - ssize_t getIndex(T object) const { + uint32_t getIndex(T object) const { auto iter = std::find(_data.begin(), _data.end(), object); if (iter != _data.end()) { return iter - _data.begin(); @@ -237,8 +256,8 @@ public: } /** Returns the element at position 'index' in the Vector. */ - T at(ssize_t index) const { - CCASSERT(index >= 0 && index < size(), "index out of range in getObjectAtIndex()"); + T at(uint32_t index) const { + CC_ASSERT(index < size()); return _data[index]; } @@ -255,7 +274,7 @@ public: /** Returns a random element of the Vector. */ T getRandomObject() const { if (!_data.empty()) { - auto randIdx = static_cast(RandomHelper::randomInt(0, static_cast(_data.size()) - 1)); + auto randIdx = RandomHelper::randomInt(0, static_cast(_data.size()) - 1); return *(_data.begin() + randIdx); } return nullptr; @@ -276,12 +295,12 @@ public: * @return True if two vectors are equal, false if not. */ bool equals(const Vector &other) const { - ssize_t s = this->size(); + uint32_t s = this->size(); if (s != other.size()) { return false; } - for (ssize_t i = 0; i < s; i++) { + for (uint32_t i = 0; i < s; i++) { if (this->at(i) != other.at(i)) { return false; } @@ -293,16 +312,16 @@ public: /** Adds a new element at the end of the Vector. */ void pushBack(T object) { - CCASSERT(object != nullptr, "The object should not be nullptr"); + CC_ASSERT(object != nullptr); _data.push_back(object); - object->retain(); + object->addRef(); } /** Push all elements of an existing Vector to the end of current Vector. */ void pushBack(const Vector &other) { for (const auto &obj : other) { _data.push_back(obj); - obj->retain(); + obj->addRef(); } } @@ -311,18 +330,18 @@ public: * @param index The index to be inserted at. * @param object The object to be inserted. */ - void insert(ssize_t index, T object) { - CCASSERT(index >= 0 && index <= size(), "Invalid index!"); - CCASSERT(object != nullptr, "The object should not be nullptr"); + void insert(uint32_t index, T object) { + CC_ASSERT(index <= size()); + CC_ASSERT(object != nullptr); _data.insert((std::begin(_data) + index), object); - object->retain(); + object->addRef(); } // Removes Objects /** Removes the last element in the Vector. */ void popBack() { - CCASSERT(!_data.empty(), "no objects added"); + CC_ASSERT(!_data.empty()); auto last = _data.back(); _data.pop_back(); last->release(); @@ -334,7 +353,7 @@ public: * If its value is 'false', it will just erase the first occurrence. */ void eraseObject(T object, bool removeAll = false) { - CCASSERT(object != nullptr, "The object should not be nullptr"); + CC_ASSERT(object != nullptr); if (removeAll) { for (auto iter = _data.begin(); iter != _data.end();) { @@ -360,7 +379,7 @@ public: * This is the container end if the operation erased the last element in the sequence. */ iterator erase(iterator position) { - CCASSERT(position >= _data.begin() && position < _data.end(), "Invalid position!"); + CC_ASSERT(position >= _data.begin() && position < _data.end()); (*position)->release(); return _data.erase(position); } @@ -383,8 +402,8 @@ public: * @param index The index of the element to be removed from the Vector. * @return An iterator pointing to the successor of Vector[index]. */ - iterator erase(ssize_t index) { - CCASSERT(!_data.empty() && index >= 0 && index < size(), "Invalid index!"); + iterator erase(uint32_t index) { + CC_ASSERT(!_data.empty() && index < size()); auto it = std::next(begin(), index); (*it)->release(); return _data.erase(it); @@ -404,29 +423,25 @@ public: /** Swap the values object1 and object2. */ void swap(T object1, T object2) { - ssize_t idx1 = getIndex(object1); - ssize_t idx2 = getIndex(object2); - - CCASSERT(idx1 >= 0 && idx2 >= 0, "invalid object index"); - + uint32_t idx1 = getIndex(object1); + uint32_t idx2 = getIndex(object2); std::swap(_data[idx1], _data[idx2]); } /** Swap two elements by indexes. */ - void swap(ssize_t index1, ssize_t index2) { - CCASSERT(index1 >= 0 && index1 < size() && index2 >= 0 && index2 < size(), "Invalid indices"); - + void swap(uint32_t index1, uint32_t index2) { + CC_ASSERT(index1 < size() && index2 < size()); std::swap(_data[index1], _data[index2]); } /** Replace value at index with given object. */ - void replace(ssize_t index, T object) { - CCASSERT(index >= 0 && index < size(), "Invalid index!"); - CCASSERT(object != nullptr, "The object should not be nullptr"); + void replace(uint32_t index, T object) { + CC_ASSERT(index < size()); + CC_ASSERT(object != nullptr); - _data[index]->release(); + CC_SAFE_RELEASE(_data[index]); _data[index] = object; - object->retain(); + CC_SAFE_ADD_REF(object); } /** Reverses the Vector. */ @@ -439,11 +454,19 @@ public: _data.shrink_to_fit(); } + const std::vector &get() const { + return _data; + } + + void resize(uint32_t size) { + _data.resize(size); + } + protected: /** Retains all the objects in the vector */ void addRefForAllObjects() { for (const auto &obj : _data) { - obj->retain(); + obj->addRef(); } } diff --git a/native/cocos/base/memory/AllocatedObj.h b/native/cocos/base/memory/AllocatedObj.h index 3695ee5ef4..dce0b0c53a 100755 --- a/native/cocos/base/memory/AllocatedObj.h +++ b/native/cocos/base/memory/AllocatedObj.h @@ -26,8 +26,9 @@ THE SOFTWARE. #pragma once -#include "../Macros.h" #include +#include "../Macros.h" +#include "base/RefCounted.h" // Anything that has done a #define new will screw operator new definitions up // so undefine @@ -46,10 +47,10 @@ namespace cc { to use (e.g. see StdAllocPolicy). */ template -class CC_DLL AllocatedObject { +class CC_DLL AllocatedObject : public RefCounted { public: - explicit AllocatedObject() = default; - virtual ~AllocatedObject() = default; + explicit AllocatedObject() = default; + ~AllocatedObject() override = default; // operator new, with debug line info void *operator new(size_t sz, const char *file, int line, const char *func) { diff --git a/native/cocos/base/memory/Memory.h b/native/cocos/base/memory/Memory.h old mode 100755 new mode 100644 index dcc5a03e18..12fb4573a2 --- a/native/cocos/base/memory/Memory.h +++ b/native/cocos/base/memory/Memory.h @@ -30,7 +30,7 @@ #include "MemTracker.h" #include "StlAlloc.h" #if (CC_PLATFORM == CC_PLATFORM_MAC_IOS) -#include + #include #endif // Global Interface Definitions @@ -117,18 +117,24 @@ #define CC_DESTROY(ptr) \ { \ (ptr)->destroy(); \ - CC_DELETE(ptr); \ } + #define CC_SAFE_DESTROY(ptr) \ if (ptr) { \ (ptr)->destroy(); \ - CC_DELETE(ptr); \ - ptr = nullptr; \ } -#define CC_UNSAFE_DESTROY(ptr) \ - if (ptr) { \ - (ptr)->destroy(); \ - CC_DELETE(ptr); \ + +#define CC_SAFE_DESTROY_AND_DELETE(ptr) \ + if (ptr) { \ + (ptr)->destroy(); \ + CC_DELETE(ptr); \ + ptr = nullptr; \ + } + +#define CC_SAFE_DESTROY_NULL(ptr) \ + if (ptr) { \ + (ptr)->destroy(); \ + (ptr) = nullptr; \ } #define CC_SAFE_RELEASE_REF(ptr) \ @@ -150,7 +156,7 @@ inline void operator delete(void *ptr) throw() { free(ptr); } #endif #if (CC_PLATFORM == CC_PLATFORM_MAC_IOS) && (__IPHONE_OS_VERSION_MIN_REQUIRED < __IPHONE_11_0) -#define ALIGNAS(x) + #define ALIGNAS(x) #else -#define ALIGNAS(x) alignas(x) + #define ALIGNAS(x) alignas(x) #endif diff --git a/native/cocos/bindings/auto/.gitignore b/native/cocos/bindings/auto/.gitignore new file mode 100644 index 0000000000..a6c57f5fb2 --- /dev/null +++ b/native/cocos/bindings/auto/.gitignore @@ -0,0 +1 @@ +*.json diff --git a/native/cocos/bindings/auto/jsb_assets_auto.cpp b/native/cocos/bindings/auto/jsb_assets_auto.cpp new file mode 100644 index 0000000000..bdd309da82 --- /dev/null +++ b/native/cocos/bindings/auto/jsb_assets_auto.cpp @@ -0,0 +1,16686 @@ + +// clang-format off +#include "cocos/bindings/auto/jsb_assets_auto.h" +#include "cocos/bindings/manual/jsb_conversions.h" +#include "cocos/bindings/manual/jsb_global.h" +#include "core/assets/AssetsModuleHeader.h" +#include "3d/assets/Mesh.h" +#include "3d/assets/Morph.h" +#include "3d/assets/MorphRendering.h" +#include "3d/assets/Skeleton.h" +#include "cocos/bindings/auto/jsb_cocos_auto.h" + +#ifndef JSB_ALLOC +#define JSB_ALLOC(kls, ...) new (std::nothrow) kls(__VA_ARGS__) +#endif + +#ifndef JSB_FREE +#define JSB_FREE(ptr) delete ptr +#endif +se::Object* __jsb_cc_Error_proto = nullptr; // NOLINT +se::Class* __jsb_cc_Error_class = nullptr; // NOLINT + +static bool js_assets_Error_get_msg(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_assets_Error_get_msg : Invalid Native Object"); + + CC_UNUSED bool ok = true; + se::Value jsret; + ok &= nativevalue_to_se(cobj->msg, jsret, s.thisObject() /*ctx*/); + s.rval() = jsret; + SE_HOLD_RETURN_VALUE(cobj->msg, s.thisObject(), s.rval()); + return true; +} +SE_BIND_PROP_GET(js_assets_Error_get_msg) + +static bool js_assets_Error_set_msg(se::State& s) // NOLINT(readability-identifier-naming) +{ + const auto& args = s.args(); + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_assets_Error_set_msg : Invalid Native Object"); + + CC_UNUSED bool ok = true; + ok &= sevalue_to_native(args[0], &cobj->msg, s.thisObject()); + SE_PRECONDITION2(ok, false, "js_assets_Error_set_msg : Error processing new value"); + return true; +} +SE_BIND_PROP_SET(js_assets_Error_set_msg) + + +template<> +bool sevalue_to_native(const se::Value &from, cc::Error * to, se::Object *ctx) +{ + assert(from.isObject()); + se::Object *json = from.toObject(); + auto* data = reinterpret_cast(json->getPrivateData()); + if (data) { + *to = *data; + return true; + } + se::Value field; + bool ok = true; + json->getProperty("msg", &field, true); + if(!field.isNullOrUndefined()) { + ok &= sevalue_to_native(field, &(to->msg), ctx); + } + return ok; +} + +SE_DECLARE_FINALIZE_FUNC(js_cc_Error_finalize) + +static bool js_assets_Error_constructor(se::State& s) // NOLINT(readability-identifier-naming) +{ + CC_UNUSED bool ok = true; + const auto& args = s.args(); + size_t argc = args.size(); + + if(argc == 0) + { + auto *ptr = JSB_MAKE_PRIVATE_OBJECT(cc::Error); + s.thisObject()->setPrivateObject(ptr); + return true; + } + auto *ptr = JSB_MAKE_PRIVATE_OBJECT(cc::Error); + auto cobj = ptr->get(); + if (argc > 0 && !args[0].isUndefined()) { + ok &= sevalue_to_native(args[0], &(cobj->msg), nullptr); + } + + if(!ok) { + delete ptr; + SE_REPORT_ERROR("Argument convertion error"); + return false; + } + s.thisObject()->setPrivateObject(ptr); + return true; +} +SE_BIND_CTOR(js_assets_Error_constructor, __jsb_cc_Error_class, js_cc_Error_finalize) + +static bool js_cc_Error_finalize(se::State& s) // NOLINT(readability-identifier-naming) +{ + return true; +} +SE_BIND_FINALIZE_FUNC(js_cc_Error_finalize) + +bool js_register_assets_Error(se::Object* obj) // NOLINT(readability-identifier-naming) +{ + auto* cls = se::Class::create("Error", obj, nullptr, _SE(js_assets_Error_constructor)); + + cls->defineProperty("msg", _SE(js_assets_Error_get_msg), _SE(js_assets_Error_set_msg)); + cls->defineFinalizeFunction(_SE(js_cc_Error_finalize)); + cls->install(); + JSBClassType::registerClass(cls); + + __jsb_cc_Error_proto = cls->getProto(); + __jsb_cc_Error_class = cls; + + + se::ScriptEngine::getInstance()->clearException(); + return true; +} +se::Object* __jsb_cc_BoundingBox_proto = nullptr; // NOLINT +se::Class* __jsb_cc_BoundingBox_class = nullptr; // NOLINT + +static bool js_assets_BoundingBox_get_min(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_assets_BoundingBox_get_min : Invalid Native Object"); + + CC_UNUSED bool ok = true; + se::Value jsret; + ok &= nativevalue_to_se(cobj->min, jsret, s.thisObject() /*ctx*/); + s.rval() = jsret; + SE_HOLD_RETURN_VALUE(cobj->min, s.thisObject(), s.rval()); + return true; +} +SE_BIND_PROP_GET(js_assets_BoundingBox_get_min) + +static bool js_assets_BoundingBox_set_min(se::State& s) // NOLINT(readability-identifier-naming) +{ + const auto& args = s.args(); + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_assets_BoundingBox_set_min : Invalid Native Object"); + + CC_UNUSED bool ok = true; + ok &= sevalue_to_native(args[0], &cobj->min, s.thisObject()); + SE_PRECONDITION2(ok, false, "js_assets_BoundingBox_set_min : Error processing new value"); + return true; +} +SE_BIND_PROP_SET(js_assets_BoundingBox_set_min) + +static bool js_assets_BoundingBox_get_max(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_assets_BoundingBox_get_max : Invalid Native Object"); + + CC_UNUSED bool ok = true; + se::Value jsret; + ok &= nativevalue_to_se(cobj->max, jsret, s.thisObject() /*ctx*/); + s.rval() = jsret; + SE_HOLD_RETURN_VALUE(cobj->max, s.thisObject(), s.rval()); + return true; +} +SE_BIND_PROP_GET(js_assets_BoundingBox_get_max) + +static bool js_assets_BoundingBox_set_max(se::State& s) // NOLINT(readability-identifier-naming) +{ + const auto& args = s.args(); + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_assets_BoundingBox_set_max : Invalid Native Object"); + + CC_UNUSED bool ok = true; + ok &= sevalue_to_native(args[0], &cobj->max, s.thisObject()); + SE_PRECONDITION2(ok, false, "js_assets_BoundingBox_set_max : Error processing new value"); + return true; +} +SE_BIND_PROP_SET(js_assets_BoundingBox_set_max) + + +template<> +bool sevalue_to_native(const se::Value &from, cc::BoundingBox * to, se::Object *ctx) +{ + assert(from.isObject()); + se::Object *json = from.toObject(); + auto* data = reinterpret_cast(json->getPrivateData()); + if (data) { + *to = *data; + return true; + } + se::Value field; + bool ok = true; + json->getProperty("min", &field, true); + if(!field.isNullOrUndefined()) { + ok &= sevalue_to_native(field, &(to->min), ctx); + } + json->getProperty("max", &field, true); + if(!field.isNullOrUndefined()) { + ok &= sevalue_to_native(field, &(to->max), ctx); + } + return ok; +} + +SE_DECLARE_FINALIZE_FUNC(js_cc_BoundingBox_finalize) + +static bool js_assets_BoundingBox_constructor(se::State& s) // NOLINT(readability-identifier-naming) +{ + CC_UNUSED bool ok = true; + const auto& args = s.args(); + size_t argc = args.size(); + + if(argc == 0) + { + auto *ptr = JSB_MAKE_PRIVATE_OBJECT(cc::BoundingBox); + s.thisObject()->setPrivateObject(ptr); + return true; + } + + if(argc == 1 && args[0].isObject()) + { + se::Object *json = args[0].toObject(); + se::Value field; + auto *ptr = JSB_MAKE_PRIVATE_OBJECT(cc::BoundingBox); + auto cobj = ptr->get(); + ok &= sevalue_to_native(args[0], cobj, s.thisObject()); + if(!ok) { + delete ptr; + SE_REPORT_ERROR("argument convertion error"); + return false; + } + s.thisObject()->setPrivateObject(ptr); + return true; + } + auto *ptr = JSB_MAKE_PRIVATE_OBJECT(cc::BoundingBox); + auto cobj = ptr->get(); + if (argc > 0 && !args[0].isUndefined()) { + ok &= sevalue_to_native(args[0], &(cobj->min), nullptr); + } + if (argc > 1 && !args[1].isUndefined()) { + ok &= sevalue_to_native(args[1], &(cobj->max), nullptr); + } + + if(!ok) { + delete ptr; + SE_REPORT_ERROR("Argument convertion error"); + return false; + } + s.thisObject()->setPrivateObject(ptr); + return true; +} +SE_BIND_CTOR(js_assets_BoundingBox_constructor, __jsb_cc_BoundingBox_class, js_cc_BoundingBox_finalize) + +static bool js_cc_BoundingBox_finalize(se::State& s) // NOLINT(readability-identifier-naming) +{ + return true; +} +SE_BIND_FINALIZE_FUNC(js_cc_BoundingBox_finalize) + +bool js_register_assets_BoundingBox(se::Object* obj) // NOLINT(readability-identifier-naming) +{ + auto* cls = se::Class::create("BoundingBox", obj, nullptr, _SE(js_assets_BoundingBox_constructor)); + + cls->defineProperty("min", _SE(js_assets_BoundingBox_get_min), _SE(js_assets_BoundingBox_set_min)); + cls->defineProperty("max", _SE(js_assets_BoundingBox_get_max), _SE(js_assets_BoundingBox_set_max)); + cls->defineFinalizeFunction(_SE(js_cc_BoundingBox_finalize)); + cls->install(); + JSBClassType::registerClass(cls); + + __jsb_cc_BoundingBox_proto = cls->getProto(); + __jsb_cc_BoundingBox_class = cls; + + + se::ScriptEngine::getInstance()->clearException(); + return true; +} +se::Object* __jsb_cc_VertexIdChannel_proto = nullptr; // NOLINT +se::Class* __jsb_cc_VertexIdChannel_class = nullptr; // NOLINT + +static bool js_assets_VertexIdChannel_get_stream(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_assets_VertexIdChannel_get_stream : Invalid Native Object"); + + CC_UNUSED bool ok = true; + se::Value jsret; + ok &= nativevalue_to_se(cobj->stream, jsret, s.thisObject() /*ctx*/); + s.rval() = jsret; + SE_HOLD_RETURN_VALUE(cobj->stream, s.thisObject(), s.rval()); + return true; +} +SE_BIND_PROP_GET(js_assets_VertexIdChannel_get_stream) + +static bool js_assets_VertexIdChannel_set_stream(se::State& s) // NOLINT(readability-identifier-naming) +{ + const auto& args = s.args(); + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_assets_VertexIdChannel_set_stream : Invalid Native Object"); + + CC_UNUSED bool ok = true; + ok &= sevalue_to_native(args[0], &cobj->stream, s.thisObject()); + SE_PRECONDITION2(ok, false, "js_assets_VertexIdChannel_set_stream : Error processing new value"); + return true; +} +SE_BIND_PROP_SET(js_assets_VertexIdChannel_set_stream) + +static bool js_assets_VertexIdChannel_get_index(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_assets_VertexIdChannel_get_index : Invalid Native Object"); + + CC_UNUSED bool ok = true; + se::Value jsret; + ok &= nativevalue_to_se(cobj->index, jsret, s.thisObject() /*ctx*/); + s.rval() = jsret; + SE_HOLD_RETURN_VALUE(cobj->index, s.thisObject(), s.rval()); + return true; +} +SE_BIND_PROP_GET(js_assets_VertexIdChannel_get_index) + +static bool js_assets_VertexIdChannel_set_index(se::State& s) // NOLINT(readability-identifier-naming) +{ + const auto& args = s.args(); + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_assets_VertexIdChannel_set_index : Invalid Native Object"); + + CC_UNUSED bool ok = true; + ok &= sevalue_to_native(args[0], &cobj->index, s.thisObject()); + SE_PRECONDITION2(ok, false, "js_assets_VertexIdChannel_set_index : Error processing new value"); + return true; +} +SE_BIND_PROP_SET(js_assets_VertexIdChannel_set_index) + + +template<> +bool sevalue_to_native(const se::Value &from, cc::VertexIdChannel * to, se::Object *ctx) +{ + assert(from.isObject()); + se::Object *json = from.toObject(); + auto* data = reinterpret_cast(json->getPrivateData()); + if (data) { + *to = *data; + return true; + } + se::Value field; + bool ok = true; + json->getProperty("stream", &field, true); + if(!field.isNullOrUndefined()) { + ok &= sevalue_to_native(field, &(to->stream), ctx); + } + json->getProperty("index", &field, true); + if(!field.isNullOrUndefined()) { + ok &= sevalue_to_native(field, &(to->index), ctx); + } + return ok; +} + +SE_DECLARE_FINALIZE_FUNC(js_cc_VertexIdChannel_finalize) + +static bool js_assets_VertexIdChannel_constructor(se::State& s) // NOLINT(readability-identifier-naming) +{ + CC_UNUSED bool ok = true; + const auto& args = s.args(); + size_t argc = args.size(); + + if(argc == 0) + { + auto *ptr = JSB_MAKE_PRIVATE_OBJECT(cc::VertexIdChannel); + s.thisObject()->setPrivateObject(ptr); + return true; + } + + if(argc == 1 && args[0].isObject()) + { + se::Object *json = args[0].toObject(); + se::Value field; + auto *ptr = JSB_MAKE_PRIVATE_OBJECT(cc::VertexIdChannel); + auto cobj = ptr->get(); + ok &= sevalue_to_native(args[0], cobj, s.thisObject()); + if(!ok) { + delete ptr; + SE_REPORT_ERROR("argument convertion error"); + return false; + } + s.thisObject()->setPrivateObject(ptr); + return true; + } + auto *ptr = JSB_MAKE_PRIVATE_OBJECT(cc::VertexIdChannel); + auto cobj = ptr->get(); + if (argc > 0 && !args[0].isUndefined()) { + ok &= sevalue_to_native(args[0], &(cobj->stream), nullptr); + } + if (argc > 1 && !args[1].isUndefined()) { + ok &= sevalue_to_native(args[1], &(cobj->index), nullptr); + } + + if(!ok) { + delete ptr; + SE_REPORT_ERROR("Argument convertion error"); + return false; + } + s.thisObject()->setPrivateObject(ptr); + return true; +} +SE_BIND_CTOR(js_assets_VertexIdChannel_constructor, __jsb_cc_VertexIdChannel_class, js_cc_VertexIdChannel_finalize) + +static bool js_cc_VertexIdChannel_finalize(se::State& s) // NOLINT(readability-identifier-naming) +{ + return true; +} +SE_BIND_FINALIZE_FUNC(js_cc_VertexIdChannel_finalize) + +bool js_register_assets_VertexIdChannel(se::Object* obj) // NOLINT(readability-identifier-naming) +{ + auto* cls = se::Class::create("VertexIdChannel", obj, nullptr, _SE(js_assets_VertexIdChannel_constructor)); + + cls->defineProperty("stream", _SE(js_assets_VertexIdChannel_get_stream), _SE(js_assets_VertexIdChannel_set_stream)); + cls->defineProperty("index", _SE(js_assets_VertexIdChannel_get_index), _SE(js_assets_VertexIdChannel_set_index)); + cls->defineFinalizeFunction(_SE(js_cc_VertexIdChannel_finalize)); + cls->install(); + JSBClassType::registerClass(cls); + + __jsb_cc_VertexIdChannel_proto = cls->getProto(); + __jsb_cc_VertexIdChannel_class = cls; + + + se::ScriptEngine::getInstance()->clearException(); + return true; +} +se::Object* __jsb_cc_Asset_proto = nullptr; // NOLINT +se::Class* __jsb_cc_Asset_class = nullptr; // NOLINT + +static bool js_assets_Asset_addAssetRef(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_assets_Asset_addAssetRef : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 0) { + cc::Asset* result = cobj->addAssetRef(); + ok &= nativevalue_to_se(result, s.rval(), nullptr /*ctx*/); + SE_PRECONDITION2(ok, false, "js_assets_Asset_addAssetRef : Error processing arguments"); + SE_HOLD_RETURN_VALUE(result, s.thisObject(), s.rval()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 0); + return false; +} +SE_BIND_FUNC(js_assets_Asset_addAssetRef) + +static bool js_assets_Asset_createNode(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_assets_Asset_createNode : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 1) { + HolderType, true> arg0 = {}; + do { + if (args[0].isObject() && args[0].toObject()->isFunction()) + { + se::Value jsThis(s.thisObject()); + se::Value jsFunc(args[0]); + jsThis.toObject()->attachObject(jsFunc.toObject()); + auto * thisObj = s.thisObject(); + auto lambda = [=](cc::Error larg0, cc::Node* larg1) -> void { + se::ScriptEngine::getInstance()->clearException(); + se::AutoHandleScope hs; + + CC_UNUSED bool ok = true; + se::ValueArray args; + args.resize(2); + ok &= nativevalue_to_se(larg0, args[0], nullptr /*ctx*/); + ok &= nativevalue_to_se(larg1, args[1], nullptr /*ctx*/); + se::Value rval; + se::Object* funcObj = jsFunc.toObject(); + bool succeed = funcObj->call(args, thisObj, &rval); + if (!succeed) { + se::ScriptEngine::getInstance()->clearException(); + } + }; + arg0.data = lambda; + } + else + { + arg0.data = nullptr; + } + } while(false) + ; + SE_PRECONDITION2(ok, false, "js_assets_Asset_createNode : Error processing arguments"); + cobj->createNode(arg0.value()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 1); + return false; +} +SE_BIND_FUNC(js_assets_Asset_createNode) + +static bool js_assets_Asset_decAssetRef(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_assets_Asset_decAssetRef : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 0) { + cc::Asset* result = cobj->decAssetRef(); + ok &= nativevalue_to_se(result, s.rval(), nullptr /*ctx*/); + SE_PRECONDITION2(ok, false, "js_assets_Asset_decAssetRef : Error processing arguments"); + SE_HOLD_RETURN_VALUE(result, s.thisObject(), s.rval()); + return true; + } + if (argc == 1) { + HolderType arg0 = {}; + ok &= sevalue_to_native(args[0], &arg0, s.thisObject()); + SE_PRECONDITION2(ok, false, "js_assets_Asset_decAssetRef : Error processing arguments"); + cc::Asset* result = cobj->decAssetRef(arg0.value()); + ok &= nativevalue_to_se(result, s.rval(), nullptr /*ctx*/); + SE_PRECONDITION2(ok, false, "js_assets_Asset_decAssetRef : Error processing arguments"); + SE_HOLD_RETURN_VALUE(result, s.thisObject(), s.rval()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 1); + return false; +} +SE_BIND_FUNC(js_assets_Asset_decAssetRef) + +static bool js_assets_Asset_deserialize(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_assets_Asset_deserialize : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 2) { + HolderType arg0 = {}; + HolderType arg1 = {}; + ok &= sevalue_to_native(args[0], &arg0, s.thisObject()); + ok &= sevalue_to_native(args[1], &arg1, s.thisObject()); + SE_PRECONDITION2(ok, false, "js_assets_Asset_deserialize : Error processing arguments"); + cobj->deserialize(arg0.value(), arg1.value()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 2); + return false; +} +SE_BIND_FUNC(js_assets_Asset_deserialize) + +static bool js_assets_Asset_getNativeAsset(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_assets_Asset_getNativeAsset : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 0) { + cc::any result = cobj->getNativeAsset(); + ok &= nativevalue_to_se(result, s.rval(), nullptr /*ctx*/); + SE_PRECONDITION2(ok, false, "js_assets_Asset_getNativeAsset : Error processing arguments"); + SE_HOLD_RETURN_VALUE(result, s.thisObject(), s.rval()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 0); + return false; +} +SE_BIND_FUNC(js_assets_Asset_getNativeAsset) + +static bool js_assets_Asset_getNativeDep(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_assets_Asset_getNativeDep : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 0) { + cc::NativeDep result = cobj->getNativeDep(); + ok &= nativevalue_to_se(result, s.rval(), nullptr /*ctx*/); + SE_PRECONDITION2(ok, false, "js_assets_Asset_getNativeDep : Error processing arguments"); + SE_HOLD_RETURN_VALUE(result, s.thisObject(), s.rval()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 0); + return false; +} +SE_BIND_FUNC_AS_PROP_GET(js_assets_Asset_getNativeDep) + +static bool js_assets_Asset_getNativeUrl(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_assets_Asset_getNativeUrl : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 0) { + std::string result = cobj->getNativeUrl(); + ok &= nativevalue_to_se(result, s.rval(), nullptr /*ctx*/); + SE_PRECONDITION2(ok, false, "js_assets_Asset_getNativeUrl : Error processing arguments"); + SE_HOLD_RETURN_VALUE(result, s.thisObject(), s.rval()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 0); + return false; +} +SE_BIND_FUNC_AS_PROP_GET(js_assets_Asset_getNativeUrl) + +static bool js_assets_Asset_getRefCount(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_assets_Asset_getRefCount : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 0) { + unsigned int result = cobj->getRefCount(); + ok &= nativevalue_to_se(result, s.rval(), nullptr /*ctx*/); + SE_PRECONDITION2(ok, false, "js_assets_Asset_getRefCount : Error processing arguments"); + SE_HOLD_RETURN_VALUE(result, s.thisObject(), s.rval()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 0); + return false; +} +SE_BIND_FUNC(js_assets_Asset_getRefCount) + +static bool js_assets_Asset_getUuid(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_assets_Asset_getUuid : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 0) { + const std::string& result = cobj->getUuid(); + ok &= nativevalue_to_se(result, s.rval(), nullptr /*ctx*/); + SE_PRECONDITION2(ok, false, "js_assets_Asset_getUuid : Error processing arguments"); + SE_HOLD_RETURN_VALUE(result, s.thisObject(), s.rval()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 0); + return false; +} +SE_BIND_FUNC_AS_PROP_GET(js_assets_Asset_getUuid) + +static bool js_assets_Asset_initDefault(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_assets_Asset_initDefault : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 1) { + HolderType, true> arg0 = {}; + ok &= sevalue_to_native(args[0], &arg0, s.thisObject()); + SE_PRECONDITION2(ok, false, "js_assets_Asset_initDefault : Error processing arguments"); + cobj->initDefault(arg0.value()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 1); + return false; +} +SE_BIND_FUNC(js_assets_Asset_initDefault) + +static bool js_assets_Asset_isDefault(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_assets_Asset_isDefault : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 0) { + bool result = cobj->isDefault(); + ok &= nativevalue_to_se(result, s.rval(), nullptr /*ctx*/); + SE_PRECONDITION2(ok, false, "js_assets_Asset_isDefault : Error processing arguments"); + SE_HOLD_RETURN_VALUE(result, s.thisObject(), s.rval()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 0); + return false; +} +SE_BIND_FUNC_AS_PROP_GET(js_assets_Asset_isDefault) + +static bool js_assets_Asset_onLoaded(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_assets_Asset_onLoaded : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + if (argc == 0) { + cobj->onLoaded(); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 0); + return false; +} +SE_BIND_FUNC(js_assets_Asset_onLoaded) + +static bool js_assets_Asset_serialize(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_assets_Asset_serialize : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 1) { + HolderType arg0 = {}; + ok &= sevalue_to_native(args[0], &arg0, s.thisObject()); + SE_PRECONDITION2(ok, false, "js_assets_Asset_serialize : Error processing arguments"); + cc::any result = cobj->serialize(arg0.value()); + ok &= nativevalue_to_se(result, s.rval(), nullptr /*ctx*/); + SE_PRECONDITION2(ok, false, "js_assets_Asset_serialize : Error processing arguments"); + SE_HOLD_RETURN_VALUE(result, s.thisObject(), s.rval()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 1); + return false; +} +SE_BIND_FUNC(js_assets_Asset_serialize) + +static bool js_assets_Asset_setNativeAsset(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_assets_Asset_setNativeAsset : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 1) { + HolderType arg0 = {}; + ok &= sevalue_to_native(args[0], &arg0, s.thisObject()); + SE_PRECONDITION2(ok, false, "js_assets_Asset_setNativeAsset : Error processing arguments"); + cobj->setNativeAsset(arg0.value()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 1); + return false; +} +SE_BIND_FUNC(js_assets_Asset_setNativeAsset) + +static bool js_assets_Asset_setUuid(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_assets_Asset_setUuid : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 1) { + HolderType arg0 = {}; + ok &= sevalue_to_native(args[0], &arg0, s.thisObject()); + SE_PRECONDITION2(ok, false, "js_assets_Asset_setUuid : Error processing arguments"); + cobj->setUuid(arg0.value()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 1); + return false; +} +SE_BIND_FUNC_AS_PROP_SET(js_assets_Asset_setUuid) + +static bool js_assets_Asset_validate(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_assets_Asset_validate : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 0) { + bool result = cobj->validate(); + ok &= nativevalue_to_se(result, s.rval(), nullptr /*ctx*/); + SE_PRECONDITION2(ok, false, "js_assets_Asset_validate : Error processing arguments"); + SE_HOLD_RETURN_VALUE(result, s.thisObject(), s.rval()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 0); + return false; +} +SE_BIND_FUNC(js_assets_Asset_validate) + +static bool js_assets_Asset_get__native(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_assets_Asset_get__native : Invalid Native Object"); + + CC_UNUSED bool ok = true; + se::Value jsret; + ok &= nativevalue_to_se(cobj->_native, jsret, s.thisObject() /*ctx*/); + s.rval() = jsret; + SE_HOLD_RETURN_VALUE(cobj->_native, s.thisObject(), s.rval()); + return true; +} +SE_BIND_PROP_GET(js_assets_Asset_get__native) + +static bool js_assets_Asset_set__native(se::State& s) // NOLINT(readability-identifier-naming) +{ + const auto& args = s.args(); + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_assets_Asset_set__native : Invalid Native Object"); + + CC_UNUSED bool ok = true; + ok &= sevalue_to_native(args[0], &cobj->_native, s.thisObject()); + SE_PRECONDITION2(ok, false, "js_assets_Asset_set__native : Error processing new value"); + return true; +} +SE_BIND_PROP_SET(js_assets_Asset_set__native) + +static bool js_assets_Asset_get__nativeUrl(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_assets_Asset_get__nativeUrl : Invalid Native Object"); + + CC_UNUSED bool ok = true; + se::Value jsret; + ok &= nativevalue_to_se(cobj->_nativeUrl, jsret, s.thisObject() /*ctx*/); + s.rval() = jsret; + SE_HOLD_RETURN_VALUE(cobj->_nativeUrl, s.thisObject(), s.rval()); + return true; +} +SE_BIND_PROP_GET(js_assets_Asset_get__nativeUrl) + +static bool js_assets_Asset_set__nativeUrl(se::State& s) // NOLINT(readability-identifier-naming) +{ + const auto& args = s.args(); + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_assets_Asset_set__nativeUrl : Invalid Native Object"); + + CC_UNUSED bool ok = true; + ok &= sevalue_to_native(args[0], &cobj->_nativeUrl, s.thisObject()); + SE_PRECONDITION2(ok, false, "js_assets_Asset_set__nativeUrl : Error processing new value"); + return true; +} +SE_BIND_PROP_SET(js_assets_Asset_set__nativeUrl) + +SE_DECLARE_FINALIZE_FUNC(js_cc_Asset_finalize) + +static bool js_assets_Asset_constructor(se::State& s) // NOLINT(readability-identifier-naming) constructor.c +{ + auto *ptr = JSB_MAKE_PRIVATE_OBJECT(cc::Asset); + s.thisObject()->setPrivateObject(ptr); + return true; +} +SE_BIND_CTOR(js_assets_Asset_constructor, __jsb_cc_Asset_class, js_cc_Asset_finalize) + +static bool js_cc_Asset_finalize(se::State& s) // NOLINT(readability-identifier-naming) +{ + return true; +} +SE_BIND_FINALIZE_FUNC(js_cc_Asset_finalize) + +bool js_register_assets_Asset(se::Object* obj) // NOLINT(readability-identifier-naming) +{ + auto* cls = se::Class::create("Asset", obj, __jsb_cc_CCObject_proto, _SE(js_assets_Asset_constructor)); + + cls->defineProperty("_native", _SE(js_assets_Asset_get__native), _SE(js_assets_Asset_set__native)); + cls->defineProperty("_nativeUrl", _SE(js_assets_Asset_get__nativeUrl), _SE(js_assets_Asset_set__nativeUrl)); + cls->defineProperty("_uuid", _SE(js_assets_Asset_getUuid_asGetter), _SE(js_assets_Asset_setUuid_asSetter)); + cls->defineProperty("nativeUrl", _SE(js_assets_Asset_getNativeUrl_asGetter), nullptr); + cls->defineProperty("isDefault", _SE(js_assets_Asset_isDefault_asGetter), nullptr); + cls->defineProperty("_nativeDep", _SE(js_assets_Asset_getNativeDep_asGetter), nullptr); + cls->defineFunction("addRef", _SE(js_assets_Asset_addAssetRef)); + cls->defineFunction("createNode", _SE(js_assets_Asset_createNode)); + cls->defineFunction("decRef", _SE(js_assets_Asset_decAssetRef)); + cls->defineFunction("deserialize", _SE(js_assets_Asset_deserialize)); + cls->defineFunction("getNativeAsset", _SE(js_assets_Asset_getNativeAsset)); + cls->defineFunction("getRefCount", _SE(js_assets_Asset_getRefCount)); + cls->defineFunction("initDefault", _SE(js_assets_Asset_initDefault)); + cls->defineFunction("onLoaded", _SE(js_assets_Asset_onLoaded)); + cls->defineFunction("serialize", _SE(js_assets_Asset_serialize)); + cls->defineFunction("setNativeAsset", _SE(js_assets_Asset_setNativeAsset)); + cls->defineFunction("validate", _SE(js_assets_Asset_validate)); + cls->defineFinalizeFunction(_SE(js_cc_Asset_finalize)); + cls->install(); + JSBClassType::registerClass(cls); + + __jsb_cc_Asset_proto = cls->getProto(); + __jsb_cc_Asset_class = cls; + + + se::ScriptEngine::getInstance()->clearException(); + return true; +} +se::Object* __jsb_cc_BufferAsset_proto = nullptr; // NOLINT +se::Class* __jsb_cc_BufferAsset_class = nullptr; // NOLINT + +static bool js_assets_BufferAsset_getBuffer(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_assets_BufferAsset_getBuffer : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 0) { + cc::ArrayBuffer* result = cobj->getBuffer(); + ok &= nativevalue_to_se(result, s.rval(), nullptr /*ctx*/); + SE_PRECONDITION2(ok, false, "js_assets_BufferAsset_getBuffer : Error processing arguments"); + SE_HOLD_RETURN_VALUE(result, s.thisObject(), s.rval()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 0); + return false; +} +SE_BIND_FUNC_AS_PROP_GET(js_assets_BufferAsset_getBuffer) + +SE_DECLARE_FINALIZE_FUNC(js_cc_BufferAsset_finalize) + +static bool js_assets_BufferAsset_constructor(se::State& s) // NOLINT(readability-identifier-naming) constructor.c +{ + auto *ptr = JSB_MAKE_PRIVATE_OBJECT(cc::BufferAsset); + s.thisObject()->setPrivateObject(ptr); + return true; +} +SE_BIND_CTOR(js_assets_BufferAsset_constructor, __jsb_cc_BufferAsset_class, js_cc_BufferAsset_finalize) + +static bool js_cc_BufferAsset_finalize(se::State& s) // NOLINT(readability-identifier-naming) +{ + return true; +} +SE_BIND_FINALIZE_FUNC(js_cc_BufferAsset_finalize) + +bool js_register_assets_BufferAsset(se::Object* obj) // NOLINT(readability-identifier-naming) +{ + auto* cls = se::Class::create("BufferAsset", obj, __jsb_cc_Asset_proto, _SE(js_assets_BufferAsset_constructor)); + + cls->defineProperty("buffer", _SE(js_assets_BufferAsset_getBuffer_asGetter), nullptr); + cls->defineFinalizeFunction(_SE(js_cc_BufferAsset_finalize)); + cls->install(); + JSBClassType::registerClass(cls); + + __jsb_cc_BufferAsset_proto = cls->getProto(); + __jsb_cc_BufferAsset_class = cls; + + + se::ScriptEngine::getInstance()->clearException(); + return true; +} +se::Object* __jsb_cc_TextureBase_proto = nullptr; // NOLINT +se::Class* __jsb_cc_TextureBase_class = nullptr; // NOLINT + +static bool js_assets_TextureBase_getAnisotropy(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_assets_TextureBase_getAnisotropy : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 0) { + unsigned int result = cobj->getAnisotropy(); + ok &= nativevalue_to_se(result, s.rval(), nullptr /*ctx*/); + SE_PRECONDITION2(ok, false, "js_assets_TextureBase_getAnisotropy : Error processing arguments"); + SE_HOLD_RETURN_VALUE(result, s.thisObject(), s.rval()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 0); + return false; +} +SE_BIND_FUNC(js_assets_TextureBase_getAnisotropy) + +static bool js_assets_TextureBase_getGFXSampler(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_assets_TextureBase_getGFXSampler : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 0) { + cc::gfx::Sampler* result = cobj->getGFXSampler(); + ok &= nativevalue_to_se(result, s.rval(), nullptr /*ctx*/); + SE_PRECONDITION2(ok, false, "js_assets_TextureBase_getGFXSampler : Error processing arguments"); + SE_HOLD_RETURN_VALUE(result, s.thisObject(), s.rval()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 0); + return false; +} +SE_BIND_FUNC(js_assets_TextureBase_getGFXSampler) + +static bool js_assets_TextureBase_getGFXTexture(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_assets_TextureBase_getGFXTexture : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 0) { + cc::gfx::Texture* result = cobj->getGFXTexture(); + ok &= nativevalue_to_se(result, s.rval(), nullptr /*ctx*/); + SE_PRECONDITION2(ok, false, "js_assets_TextureBase_getGFXTexture : Error processing arguments"); + SE_HOLD_RETURN_VALUE(result, s.thisObject(), s.rval()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 0); + return false; +} +SE_BIND_FUNC(js_assets_TextureBase_getGFXTexture) + +static bool js_assets_TextureBase_getHashForJS(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_assets_TextureBase_getHashForJS : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 0) { + double result = cobj->getHashForJS(); + ok &= nativevalue_to_se(result, s.rval(), nullptr /*ctx*/); + SE_PRECONDITION2(ok, false, "js_assets_TextureBase_getHashForJS : Error processing arguments"); + SE_HOLD_RETURN_VALUE(result, s.thisObject(), s.rval()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 0); + return false; +} +SE_BIND_FUNC(js_assets_TextureBase_getHashForJS) + +static bool js_assets_TextureBase_getHeight(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_assets_TextureBase_getHeight : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 0) { + unsigned int result = cobj->getHeight(); + ok &= nativevalue_to_se(result, s.rval(), nullptr /*ctx*/); + SE_PRECONDITION2(ok, false, "js_assets_TextureBase_getHeight : Error processing arguments"); + SE_HOLD_RETURN_VALUE(result, s.thisObject(), s.rval()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 0); + return false; +} +SE_BIND_FUNC_AS_PROP_GET(js_assets_TextureBase_getHeight) + +static bool js_assets_TextureBase_getId(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_assets_TextureBase_getId : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 0) { + const std::string& result = cobj->getId(); + ok &= nativevalue_to_se(result, s.rval(), nullptr /*ctx*/); + SE_PRECONDITION2(ok, false, "js_assets_TextureBase_getId : Error processing arguments"); + SE_HOLD_RETURN_VALUE(result, s.thisObject(), s.rval()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 0); + return false; +} +SE_BIND_FUNC(js_assets_TextureBase_getId) + +static bool js_assets_TextureBase_getPixelFormat(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_assets_TextureBase_getPixelFormat : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 0) { + auto result = static_cast(cobj->getPixelFormat()); + ok &= nativevalue_to_se(result, s.rval(), nullptr /*ctx*/); + SE_PRECONDITION2(ok, false, "js_assets_TextureBase_getPixelFormat : Error processing arguments"); + SE_HOLD_RETURN_VALUE(result, s.thisObject(), s.rval()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 0); + return false; +} +SE_BIND_FUNC(js_assets_TextureBase_getPixelFormat) + +static bool js_assets_TextureBase_getSamplerInfo(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_assets_TextureBase_getSamplerInfo : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 0) { + const cc::gfx::SamplerInfo& result = cobj->getSamplerInfo(); + ok &= nativevalue_to_se(result, s.rval(), nullptr /*ctx*/); + SE_PRECONDITION2(ok, false, "js_assets_TextureBase_getSamplerInfo : Error processing arguments"); + SE_HOLD_RETURN_VALUE(result, s.thisObject(), s.rval()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 0); + return false; +} +SE_BIND_FUNC(js_assets_TextureBase_getSamplerInfo) + +static bool js_assets_TextureBase_getWidth(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_assets_TextureBase_getWidth : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 0) { + unsigned int result = cobj->getWidth(); + ok &= nativevalue_to_se(result, s.rval(), nullptr /*ctx*/); + SE_PRECONDITION2(ok, false, "js_assets_TextureBase_getWidth : Error processing arguments"); + SE_HOLD_RETURN_VALUE(result, s.thisObject(), s.rval()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 0); + return false; +} +SE_BIND_FUNC_AS_PROP_GET(js_assets_TextureBase_getWidth) + +static bool js_assets_TextureBase_isCompressed(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_assets_TextureBase_isCompressed : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 0) { + bool result = cobj->isCompressed(); + ok &= nativevalue_to_se(result, s.rval(), nullptr /*ctx*/); + SE_PRECONDITION2(ok, false, "js_assets_TextureBase_isCompressed : Error processing arguments"); + SE_HOLD_RETURN_VALUE(result, s.thisObject(), s.rval()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 0); + return false; +} +SE_BIND_FUNC_AS_PROP_GET(js_assets_TextureBase_isCompressed) + +static bool js_assets_TextureBase_setAnisotropy(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_assets_TextureBase_setAnisotropy : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 1) { + HolderType arg0 = {}; + ok &= sevalue_to_native(args[0], &arg0, s.thisObject()); + SE_PRECONDITION2(ok, false, "js_assets_TextureBase_setAnisotropy : Error processing arguments"); + cobj->setAnisotropy(arg0.value()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 1); + return false; +} +SE_BIND_FUNC(js_assets_TextureBase_setAnisotropy) + +static bool js_assets_TextureBase_setFilters(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_assets_TextureBase_setFilters : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 2) { + HolderType arg0 = {}; + HolderType arg1 = {}; + ok &= sevalue_to_native(args[0], &arg0, s.thisObject()); + ok &= sevalue_to_native(args[1], &arg1, s.thisObject()); + SE_PRECONDITION2(ok, false, "js_assets_TextureBase_setFilters : Error processing arguments"); + cobj->setFilters(arg0.value(), arg1.value()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 2); + return false; +} +SE_BIND_FUNC(js_assets_TextureBase_setFilters) + +static bool js_assets_TextureBase_setHeight(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_assets_TextureBase_setHeight : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 1) { + HolderType arg0 = {}; + ok &= sevalue_to_native(args[0], &arg0, s.thisObject()); + SE_PRECONDITION2(ok, false, "js_assets_TextureBase_setHeight : Error processing arguments"); + cobj->setHeight(arg0.value()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 1); + return false; +} +SE_BIND_FUNC_AS_PROP_SET(js_assets_TextureBase_setHeight) + +static bool js_assets_TextureBase_setMipFilter(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_assets_TextureBase_setMipFilter : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 1) { + HolderType arg0 = {}; + ok &= sevalue_to_native(args[0], &arg0, s.thisObject()); + SE_PRECONDITION2(ok, false, "js_assets_TextureBase_setMipFilter : Error processing arguments"); + cobj->setMipFilter(arg0.value()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 1); + return false; +} +SE_BIND_FUNC(js_assets_TextureBase_setMipFilter) + +static bool js_assets_TextureBase_setWidth(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_assets_TextureBase_setWidth : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 1) { + HolderType arg0 = {}; + ok &= sevalue_to_native(args[0], &arg0, s.thisObject()); + SE_PRECONDITION2(ok, false, "js_assets_TextureBase_setWidth : Error processing arguments"); + cobj->setWidth(arg0.value()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 1); + return false; +} +SE_BIND_FUNC_AS_PROP_SET(js_assets_TextureBase_setWidth) + +static bool js_assets_TextureBase_setWrapMode(se::State& s) // NOLINT(readability-identifier-naming) +{ + CC_UNUSED bool ok = true; + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2( cobj, false, "js_assets_TextureBase_setWrapMode : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + do { + if (argc == 2) { + HolderType arg0 = {}; + HolderType arg1 = {}; + + ok &= sevalue_to_native(args[0], &arg0, s.thisObject()); + if (!ok) { ok = true; break; } + ok &= sevalue_to_native(args[1], &arg1, s.thisObject()); + if (!ok) { ok = true; break; } + cobj->setWrapMode(arg0.value(), arg1.value()); + return true; + } + } while(false); + + do { + if (argc == 3) { + HolderType arg0 = {}; + HolderType arg1 = {}; + HolderType arg2 = {}; + + ok &= sevalue_to_native(args[0], &arg0, s.thisObject()); + if (!ok) { ok = true; break; } + ok &= sevalue_to_native(args[1], &arg1, s.thisObject()); + if (!ok) { ok = true; break; } + ok &= sevalue_to_native(args[2], &arg2, s.thisObject()); + if (!ok) { ok = true; break; } + cobj->setWrapMode(arg0.value(), arg1.value(), arg2.value()); + return true; + } + } while(false); + + SE_REPORT_ERROR("wrong number of arguments: %d", (int)argc); + return false; +} +SE_BIND_FUNC(js_assets_TextureBase_setWrapMode) + +static bool js_assets_TextureBase_get__format(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_assets_TextureBase_get__format : Invalid Native Object"); + + CC_UNUSED bool ok = true; + se::Value jsret; + ok &= nativevalue_to_se(cobj->_format, jsret, s.thisObject() /*ctx*/); + s.rval() = jsret; + SE_HOLD_RETURN_VALUE(cobj->_format, s.thisObject(), s.rval()); + return true; +} +SE_BIND_PROP_GET(js_assets_TextureBase_get__format) + +static bool js_assets_TextureBase_set__format(se::State& s) // NOLINT(readability-identifier-naming) +{ + const auto& args = s.args(); + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_assets_TextureBase_set__format : Invalid Native Object"); + + CC_UNUSED bool ok = true; + ok &= sevalue_to_native(args[0], &cobj->_format, s.thisObject()); + SE_PRECONDITION2(ok, false, "js_assets_TextureBase_set__format : Error processing new value"); + return true; +} +SE_BIND_PROP_SET(js_assets_TextureBase_set__format) + +static bool js_assets_TextureBase_get__minFilter(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_assets_TextureBase_get__minFilter : Invalid Native Object"); + + CC_UNUSED bool ok = true; + se::Value jsret; + ok &= nativevalue_to_se(cobj->_minFilter, jsret, s.thisObject() /*ctx*/); + s.rval() = jsret; + SE_HOLD_RETURN_VALUE(cobj->_minFilter, s.thisObject(), s.rval()); + return true; +} +SE_BIND_PROP_GET(js_assets_TextureBase_get__minFilter) + +static bool js_assets_TextureBase_set__minFilter(se::State& s) // NOLINT(readability-identifier-naming) +{ + const auto& args = s.args(); + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_assets_TextureBase_set__minFilter : Invalid Native Object"); + + CC_UNUSED bool ok = true; + ok &= sevalue_to_native(args[0], &cobj->_minFilter, s.thisObject()); + SE_PRECONDITION2(ok, false, "js_assets_TextureBase_set__minFilter : Error processing new value"); + return true; +} +SE_BIND_PROP_SET(js_assets_TextureBase_set__minFilter) + +static bool js_assets_TextureBase_get__magFilter(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_assets_TextureBase_get__magFilter : Invalid Native Object"); + + CC_UNUSED bool ok = true; + se::Value jsret; + ok &= nativevalue_to_se(cobj->_magFilter, jsret, s.thisObject() /*ctx*/); + s.rval() = jsret; + SE_HOLD_RETURN_VALUE(cobj->_magFilter, s.thisObject(), s.rval()); + return true; +} +SE_BIND_PROP_GET(js_assets_TextureBase_get__magFilter) + +static bool js_assets_TextureBase_set__magFilter(se::State& s) // NOLINT(readability-identifier-naming) +{ + const auto& args = s.args(); + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_assets_TextureBase_set__magFilter : Invalid Native Object"); + + CC_UNUSED bool ok = true; + ok &= sevalue_to_native(args[0], &cobj->_magFilter, s.thisObject()); + SE_PRECONDITION2(ok, false, "js_assets_TextureBase_set__magFilter : Error processing new value"); + return true; +} +SE_BIND_PROP_SET(js_assets_TextureBase_set__magFilter) + +static bool js_assets_TextureBase_get__mipFilter(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_assets_TextureBase_get__mipFilter : Invalid Native Object"); + + CC_UNUSED bool ok = true; + se::Value jsret; + ok &= nativevalue_to_se(cobj->_mipFilter, jsret, s.thisObject() /*ctx*/); + s.rval() = jsret; + SE_HOLD_RETURN_VALUE(cobj->_mipFilter, s.thisObject(), s.rval()); + return true; +} +SE_BIND_PROP_GET(js_assets_TextureBase_get__mipFilter) + +static bool js_assets_TextureBase_set__mipFilter(se::State& s) // NOLINT(readability-identifier-naming) +{ + const auto& args = s.args(); + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_assets_TextureBase_set__mipFilter : Invalid Native Object"); + + CC_UNUSED bool ok = true; + ok &= sevalue_to_native(args[0], &cobj->_mipFilter, s.thisObject()); + SE_PRECONDITION2(ok, false, "js_assets_TextureBase_set__mipFilter : Error processing new value"); + return true; +} +SE_BIND_PROP_SET(js_assets_TextureBase_set__mipFilter) + +static bool js_assets_TextureBase_get__wrapS(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_assets_TextureBase_get__wrapS : Invalid Native Object"); + + CC_UNUSED bool ok = true; + se::Value jsret; + ok &= nativevalue_to_se(cobj->_wrapS, jsret, s.thisObject() /*ctx*/); + s.rval() = jsret; + SE_HOLD_RETURN_VALUE(cobj->_wrapS, s.thisObject(), s.rval()); + return true; +} +SE_BIND_PROP_GET(js_assets_TextureBase_get__wrapS) + +static bool js_assets_TextureBase_set__wrapS(se::State& s) // NOLINT(readability-identifier-naming) +{ + const auto& args = s.args(); + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_assets_TextureBase_set__wrapS : Invalid Native Object"); + + CC_UNUSED bool ok = true; + ok &= sevalue_to_native(args[0], &cobj->_wrapS, s.thisObject()); + SE_PRECONDITION2(ok, false, "js_assets_TextureBase_set__wrapS : Error processing new value"); + return true; +} +SE_BIND_PROP_SET(js_assets_TextureBase_set__wrapS) + +static bool js_assets_TextureBase_get__wrapT(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_assets_TextureBase_get__wrapT : Invalid Native Object"); + + CC_UNUSED bool ok = true; + se::Value jsret; + ok &= nativevalue_to_se(cobj->_wrapT, jsret, s.thisObject() /*ctx*/); + s.rval() = jsret; + SE_HOLD_RETURN_VALUE(cobj->_wrapT, s.thisObject(), s.rval()); + return true; +} +SE_BIND_PROP_GET(js_assets_TextureBase_get__wrapT) + +static bool js_assets_TextureBase_set__wrapT(se::State& s) // NOLINT(readability-identifier-naming) +{ + const auto& args = s.args(); + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_assets_TextureBase_set__wrapT : Invalid Native Object"); + + CC_UNUSED bool ok = true; + ok &= sevalue_to_native(args[0], &cobj->_wrapT, s.thisObject()); + SE_PRECONDITION2(ok, false, "js_assets_TextureBase_set__wrapT : Error processing new value"); + return true; +} +SE_BIND_PROP_SET(js_assets_TextureBase_set__wrapT) + +static bool js_assets_TextureBase_get__wrapR(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_assets_TextureBase_get__wrapR : Invalid Native Object"); + + CC_UNUSED bool ok = true; + se::Value jsret; + ok &= nativevalue_to_se(cobj->_wrapR, jsret, s.thisObject() /*ctx*/); + s.rval() = jsret; + SE_HOLD_RETURN_VALUE(cobj->_wrapR, s.thisObject(), s.rval()); + return true; +} +SE_BIND_PROP_GET(js_assets_TextureBase_get__wrapR) + +static bool js_assets_TextureBase_set__wrapR(se::State& s) // NOLINT(readability-identifier-naming) +{ + const auto& args = s.args(); + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_assets_TextureBase_set__wrapR : Invalid Native Object"); + + CC_UNUSED bool ok = true; + ok &= sevalue_to_native(args[0], &cobj->_wrapR, s.thisObject()); + SE_PRECONDITION2(ok, false, "js_assets_TextureBase_set__wrapR : Error processing new value"); + return true; +} +SE_BIND_PROP_SET(js_assets_TextureBase_set__wrapR) + +static bool js_assets_TextureBase_get__anisotropy(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_assets_TextureBase_get__anisotropy : Invalid Native Object"); + + CC_UNUSED bool ok = true; + se::Value jsret; + ok &= nativevalue_to_se(cobj->_anisotropy, jsret, s.thisObject() /*ctx*/); + s.rval() = jsret; + SE_HOLD_RETURN_VALUE(cobj->_anisotropy, s.thisObject(), s.rval()); + return true; +} +SE_BIND_PROP_GET(js_assets_TextureBase_get__anisotropy) + +static bool js_assets_TextureBase_set__anisotropy(se::State& s) // NOLINT(readability-identifier-naming) +{ + const auto& args = s.args(); + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_assets_TextureBase_set__anisotropy : Invalid Native Object"); + + CC_UNUSED bool ok = true; + ok &= sevalue_to_native(args[0], &cobj->_anisotropy, s.thisObject()); + SE_PRECONDITION2(ok, false, "js_assets_TextureBase_set__anisotropy : Error processing new value"); + return true; +} +SE_BIND_PROP_SET(js_assets_TextureBase_set__anisotropy) + +static bool js_assets_TextureBase_get__width(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_assets_TextureBase_get__width : Invalid Native Object"); + + CC_UNUSED bool ok = true; + se::Value jsret; + ok &= nativevalue_to_se(cobj->_width, jsret, s.thisObject() /*ctx*/); + s.rval() = jsret; + SE_HOLD_RETURN_VALUE(cobj->_width, s.thisObject(), s.rval()); + return true; +} +SE_BIND_PROP_GET(js_assets_TextureBase_get__width) + +static bool js_assets_TextureBase_set__width(se::State& s) // NOLINT(readability-identifier-naming) +{ + const auto& args = s.args(); + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_assets_TextureBase_set__width : Invalid Native Object"); + + CC_UNUSED bool ok = true; + ok &= sevalue_to_native(args[0], &cobj->_width, s.thisObject()); + SE_PRECONDITION2(ok, false, "js_assets_TextureBase_set__width : Error processing new value"); + return true; +} +SE_BIND_PROP_SET(js_assets_TextureBase_set__width) + +static bool js_assets_TextureBase_get__height(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_assets_TextureBase_get__height : Invalid Native Object"); + + CC_UNUSED bool ok = true; + se::Value jsret; + ok &= nativevalue_to_se(cobj->_height, jsret, s.thisObject() /*ctx*/); + s.rval() = jsret; + SE_HOLD_RETURN_VALUE(cobj->_height, s.thisObject(), s.rval()); + return true; +} +SE_BIND_PROP_GET(js_assets_TextureBase_get__height) + +static bool js_assets_TextureBase_set__height(se::State& s) // NOLINT(readability-identifier-naming) +{ + const auto& args = s.args(); + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_assets_TextureBase_set__height : Invalid Native Object"); + + CC_UNUSED bool ok = true; + ok &= sevalue_to_native(args[0], &cobj->_height, s.thisObject()); + SE_PRECONDITION2(ok, false, "js_assets_TextureBase_set__height : Error processing new value"); + return true; +} +SE_BIND_PROP_SET(js_assets_TextureBase_set__height) +static bool js_cc_TextureBase_finalize(se::State& s) // NOLINT(readability-identifier-naming) +{ + return true; +} +SE_BIND_FINALIZE_FUNC(js_cc_TextureBase_finalize) + +bool js_register_assets_TextureBase(se::Object* obj) // NOLINT(readability-identifier-naming) +{ + auto* cls = se::Class::create("TextureBase", obj, __jsb_cc_Asset_proto, nullptr); + + cls->defineProperty("_format", _SE(js_assets_TextureBase_get__format), _SE(js_assets_TextureBase_set__format)); + cls->defineProperty("_minFilter", _SE(js_assets_TextureBase_get__minFilter), _SE(js_assets_TextureBase_set__minFilter)); + cls->defineProperty("_magFilter", _SE(js_assets_TextureBase_get__magFilter), _SE(js_assets_TextureBase_set__magFilter)); + cls->defineProperty("_mipFilter", _SE(js_assets_TextureBase_get__mipFilter), _SE(js_assets_TextureBase_set__mipFilter)); + cls->defineProperty("_wrapS", _SE(js_assets_TextureBase_get__wrapS), _SE(js_assets_TextureBase_set__wrapS)); + cls->defineProperty("_wrapT", _SE(js_assets_TextureBase_get__wrapT), _SE(js_assets_TextureBase_set__wrapT)); + cls->defineProperty("_wrapR", _SE(js_assets_TextureBase_get__wrapR), _SE(js_assets_TextureBase_set__wrapR)); + cls->defineProperty("_anisotropy", _SE(js_assets_TextureBase_get__anisotropy), _SE(js_assets_TextureBase_set__anisotropy)); + cls->defineProperty("_width", _SE(js_assets_TextureBase_get__width), _SE(js_assets_TextureBase_set__width)); + cls->defineProperty("_height", _SE(js_assets_TextureBase_get__height), _SE(js_assets_TextureBase_set__height)); + cls->defineProperty({"_height", "height"}, _SE(js_assets_TextureBase_getHeight_asGetter), _SE(js_assets_TextureBase_setHeight_asSetter)); + cls->defineProperty("isCompressed", _SE(js_assets_TextureBase_isCompressed_asGetter), nullptr); + cls->defineProperty({"_width", "width"}, _SE(js_assets_TextureBase_getWidth_asGetter), _SE(js_assets_TextureBase_setWidth_asSetter)); + cls->defineFunction("getAnisotropy", _SE(js_assets_TextureBase_getAnisotropy)); + cls->defineFunction("getGFXSampler", _SE(js_assets_TextureBase_getGFXSampler)); + cls->defineFunction("getGFXTexture", _SE(js_assets_TextureBase_getGFXTexture)); + cls->defineFunction("getHash", _SE(js_assets_TextureBase_getHashForJS)); + cls->defineFunction("getId", _SE(js_assets_TextureBase_getId)); + cls->defineFunction("getPixelFormat", _SE(js_assets_TextureBase_getPixelFormat)); + cls->defineFunction("getSamplerInfo", _SE(js_assets_TextureBase_getSamplerInfo)); + cls->defineFunction("setAnisotropy", _SE(js_assets_TextureBase_setAnisotropy)); + cls->defineFunction("setFilters", _SE(js_assets_TextureBase_setFilters)); + cls->defineFunction("setMipFilter", _SE(js_assets_TextureBase_setMipFilter)); + cls->defineFunction("setWrapMode", _SE(js_assets_TextureBase_setWrapMode)); + cls->defineFinalizeFunction(_SE(js_cc_TextureBase_finalize)); + cls->install(); + JSBClassType::registerClass(cls); + + __jsb_cc_TextureBase_proto = cls->getProto(); + __jsb_cc_TextureBase_class = cls; + + + se::ScriptEngine::getInstance()->clearException(); + return true; +} +se::Object* __jsb_cc_IPropertyInfo_proto = nullptr; // NOLINT +se::Class* __jsb_cc_IPropertyInfo_class = nullptr; // NOLINT + +static bool js_assets_IPropertyInfo_get_type(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_assets_IPropertyInfo_get_type : Invalid Native Object"); + + CC_UNUSED bool ok = true; + se::Value jsret; + ok &= nativevalue_to_se(cobj->type, jsret, s.thisObject() /*ctx*/); + s.rval() = jsret; + SE_HOLD_RETURN_VALUE(cobj->type, s.thisObject(), s.rval()); + return true; +} +SE_BIND_PROP_GET(js_assets_IPropertyInfo_get_type) + +static bool js_assets_IPropertyInfo_set_type(se::State& s) // NOLINT(readability-identifier-naming) +{ + const auto& args = s.args(); + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_assets_IPropertyInfo_set_type : Invalid Native Object"); + + CC_UNUSED bool ok = true; + ok &= sevalue_to_native(args[0], &cobj->type, s.thisObject()); + SE_PRECONDITION2(ok, false, "js_assets_IPropertyInfo_set_type : Error processing new value"); + return true; +} +SE_BIND_PROP_SET(js_assets_IPropertyInfo_set_type) + +static bool js_assets_IPropertyInfo_get_handleInfo(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_assets_IPropertyInfo_get_handleInfo : Invalid Native Object"); + + CC_UNUSED bool ok = true; + se::Value jsret; + ok &= nativevalue_to_se(cobj->handleInfo, jsret, s.thisObject() /*ctx*/); + s.rval() = jsret; + SE_HOLD_RETURN_VALUE(cobj->handleInfo, s.thisObject(), s.rval()); + return true; +} +SE_BIND_PROP_GET(js_assets_IPropertyInfo_get_handleInfo) + +static bool js_assets_IPropertyInfo_set_handleInfo(se::State& s) // NOLINT(readability-identifier-naming) +{ + const auto& args = s.args(); + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_assets_IPropertyInfo_set_handleInfo : Invalid Native Object"); + + CC_UNUSED bool ok = true; + ok &= sevalue_to_native(args[0], &cobj->handleInfo, s.thisObject()); + SE_PRECONDITION2(ok, false, "js_assets_IPropertyInfo_set_handleInfo : Error processing new value"); + return true; +} +SE_BIND_PROP_SET(js_assets_IPropertyInfo_set_handleInfo) + +static bool js_assets_IPropertyInfo_get_samplerHash(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_assets_IPropertyInfo_get_samplerHash : Invalid Native Object"); + + CC_UNUSED bool ok = true; + se::Value jsret; + ok &= nativevalue_to_se(cobj->samplerHash, jsret, s.thisObject() /*ctx*/); + s.rval() = jsret; + SE_HOLD_RETURN_VALUE(cobj->samplerHash, s.thisObject(), s.rval()); + return true; +} +SE_BIND_PROP_GET(js_assets_IPropertyInfo_get_samplerHash) + +static bool js_assets_IPropertyInfo_set_samplerHash(se::State& s) // NOLINT(readability-identifier-naming) +{ + const auto& args = s.args(); + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_assets_IPropertyInfo_set_samplerHash : Invalid Native Object"); + + CC_UNUSED bool ok = true; + ok &= sevalue_to_native(args[0], &cobj->samplerHash, s.thisObject()); + SE_PRECONDITION2(ok, false, "js_assets_IPropertyInfo_set_samplerHash : Error processing new value"); + return true; +} +SE_BIND_PROP_SET(js_assets_IPropertyInfo_set_samplerHash) + +static bool js_assets_IPropertyInfo_get_value(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_assets_IPropertyInfo_get_value : Invalid Native Object"); + + CC_UNUSED bool ok = true; + se::Value jsret; + ok &= nativevalue_to_se(cobj->value, jsret, s.thisObject() /*ctx*/); + s.rval() = jsret; + SE_HOLD_RETURN_VALUE(cobj->value, s.thisObject(), s.rval()); + return true; +} +SE_BIND_PROP_GET(js_assets_IPropertyInfo_get_value) + +static bool js_assets_IPropertyInfo_set_value(se::State& s) // NOLINT(readability-identifier-naming) +{ + const auto& args = s.args(); + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_assets_IPropertyInfo_set_value : Invalid Native Object"); + + CC_UNUSED bool ok = true; + ok &= sevalue_to_native(args[0], &cobj->value, s.thisObject()); + SE_PRECONDITION2(ok, false, "js_assets_IPropertyInfo_set_value : Error processing new value"); + return true; +} +SE_BIND_PROP_SET(js_assets_IPropertyInfo_set_value) + +static bool js_assets_IPropertyInfo_get_linear(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_assets_IPropertyInfo_get_linear : Invalid Native Object"); + + CC_UNUSED bool ok = true; + se::Value jsret; + ok &= nativevalue_to_se(cobj->linear, jsret, s.thisObject() /*ctx*/); + s.rval() = jsret; + SE_HOLD_RETURN_VALUE(cobj->linear, s.thisObject(), s.rval()); + return true; +} +SE_BIND_PROP_GET(js_assets_IPropertyInfo_get_linear) + +static bool js_assets_IPropertyInfo_set_linear(se::State& s) // NOLINT(readability-identifier-naming) +{ + const auto& args = s.args(); + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_assets_IPropertyInfo_set_linear : Invalid Native Object"); + + CC_UNUSED bool ok = true; + ok &= sevalue_to_native(args[0], &cobj->linear, s.thisObject()); + SE_PRECONDITION2(ok, false, "js_assets_IPropertyInfo_set_linear : Error processing new value"); + return true; +} +SE_BIND_PROP_SET(js_assets_IPropertyInfo_set_linear) + + +template<> +bool sevalue_to_native(const se::Value &from, cc::IPropertyInfo * to, se::Object *ctx) +{ + assert(from.isObject()); + se::Object *json = from.toObject(); + auto* data = reinterpret_cast(json->getPrivateData()); + if (data) { + *to = *data; + return true; + } + se::Value field; + bool ok = true; + json->getProperty("type", &field, true); + if(!field.isNullOrUndefined()) { + ok &= sevalue_to_native(field, &(to->type), ctx); + } + json->getProperty("handleInfo", &field, true); + if(!field.isNullOrUndefined()) { + ok &= sevalue_to_native(field, &(to->handleInfo), ctx); + } + json->getProperty("samplerHash", &field, true); + if(!field.isNullOrUndefined()) { + ok &= sevalue_to_native(field, &(to->samplerHash), ctx); + } + json->getProperty("value", &field, true); + if(!field.isNullOrUndefined()) { + ok &= sevalue_to_native(field, &(to->value), ctx); + } + json->getProperty("linear", &field, true); + if(!field.isNullOrUndefined()) { + ok &= sevalue_to_native(field, &(to->linear), ctx); + } + return ok; +} + +SE_DECLARE_FINALIZE_FUNC(js_cc_IPropertyInfo_finalize) + +static bool js_assets_IPropertyInfo_constructor(se::State& s) // NOLINT(readability-identifier-naming) +{ + CC_UNUSED bool ok = true; + const auto& args = s.args(); + size_t argc = args.size(); + + if(argc == 0) + { + auto *ptr = JSB_MAKE_PRIVATE_OBJECT(cc::IPropertyInfo); + s.thisObject()->setPrivateObject(ptr); + return true; + } + + if(argc == 1 && args[0].isObject()) + { + se::Object *json = args[0].toObject(); + se::Value field; + auto *ptr = JSB_MAKE_PRIVATE_OBJECT(cc::IPropertyInfo); + auto cobj = ptr->get(); + ok &= sevalue_to_native(args[0], cobj, s.thisObject()); + if(!ok) { + delete ptr; + SE_REPORT_ERROR("argument convertion error"); + return false; + } + s.thisObject()->setPrivateObject(ptr); + return true; + } + auto *ptr = JSB_MAKE_PRIVATE_OBJECT(cc::IPropertyInfo); + auto cobj = ptr->get(); + if (argc > 0 && !args[0].isUndefined()) { + ok &= sevalue_to_native(args[0], &(cobj->type), nullptr); + } + if (argc > 1 && !args[1].isUndefined()) { + ok &= sevalue_to_native(args[1], &(cobj->handleInfo), nullptr); + } + if (argc > 2 && !args[2].isUndefined()) { + ok &= sevalue_to_native(args[2], &(cobj->samplerHash), nullptr); + } + if (argc > 3 && !args[3].isUndefined()) { + ok &= sevalue_to_native(args[3], &(cobj->value), nullptr); + } + if (argc > 4 && !args[4].isUndefined()) { + ok &= sevalue_to_native(args[4], &(cobj->linear), nullptr); + } + + if(!ok) { + delete ptr; + SE_REPORT_ERROR("Argument convertion error"); + return false; + } + s.thisObject()->setPrivateObject(ptr); + return true; +} +SE_BIND_CTOR(js_assets_IPropertyInfo_constructor, __jsb_cc_IPropertyInfo_class, js_cc_IPropertyInfo_finalize) + +static bool js_cc_IPropertyInfo_finalize(se::State& s) // NOLINT(readability-identifier-naming) +{ + return true; +} +SE_BIND_FINALIZE_FUNC(js_cc_IPropertyInfo_finalize) + +bool js_register_assets_IPropertyInfo(se::Object* obj) // NOLINT(readability-identifier-naming) +{ + auto* cls = se::Class::create("IPropertyInfo", obj, nullptr, _SE(js_assets_IPropertyInfo_constructor)); + + cls->defineProperty("type", _SE(js_assets_IPropertyInfo_get_type), _SE(js_assets_IPropertyInfo_set_type)); + cls->defineProperty("handleInfo", _SE(js_assets_IPropertyInfo_get_handleInfo), _SE(js_assets_IPropertyInfo_set_handleInfo)); + cls->defineProperty("samplerHash", _SE(js_assets_IPropertyInfo_get_samplerHash), _SE(js_assets_IPropertyInfo_set_samplerHash)); + cls->defineProperty("value", _SE(js_assets_IPropertyInfo_get_value), _SE(js_assets_IPropertyInfo_set_value)); + cls->defineProperty("linear", _SE(js_assets_IPropertyInfo_get_linear), _SE(js_assets_IPropertyInfo_set_linear)); + cls->defineFinalizeFunction(_SE(js_cc_IPropertyInfo_finalize)); + cls->install(); + JSBClassType::registerClass(cls); + + __jsb_cc_IPropertyInfo_proto = cls->getProto(); + __jsb_cc_IPropertyInfo_class = cls; + + + se::ScriptEngine::getInstance()->clearException(); + return true; +} +se::Object* __jsb_cc_RasterizerStateInfo_proto = nullptr; // NOLINT +se::Class* __jsb_cc_RasterizerStateInfo_class = nullptr; // NOLINT + +static bool js_assets_RasterizerStateInfo_get_isDiscard(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_assets_RasterizerStateInfo_get_isDiscard : Invalid Native Object"); + + CC_UNUSED bool ok = true; + se::Value jsret; + ok &= nativevalue_to_se(cobj->isDiscard, jsret, s.thisObject() /*ctx*/); + s.rval() = jsret; + SE_HOLD_RETURN_VALUE(cobj->isDiscard, s.thisObject(), s.rval()); + return true; +} +SE_BIND_PROP_GET(js_assets_RasterizerStateInfo_get_isDiscard) + +static bool js_assets_RasterizerStateInfo_set_isDiscard(se::State& s) // NOLINT(readability-identifier-naming) +{ + const auto& args = s.args(); + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_assets_RasterizerStateInfo_set_isDiscard : Invalid Native Object"); + + CC_UNUSED bool ok = true; + ok &= sevalue_to_native(args[0], &cobj->isDiscard, s.thisObject()); + SE_PRECONDITION2(ok, false, "js_assets_RasterizerStateInfo_set_isDiscard : Error processing new value"); + return true; +} +SE_BIND_PROP_SET(js_assets_RasterizerStateInfo_set_isDiscard) + +static bool js_assets_RasterizerStateInfo_get_isFrontFaceCCW(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_assets_RasterizerStateInfo_get_isFrontFaceCCW : Invalid Native Object"); + + CC_UNUSED bool ok = true; + se::Value jsret; + ok &= nativevalue_to_se(cobj->isFrontFaceCCW, jsret, s.thisObject() /*ctx*/); + s.rval() = jsret; + SE_HOLD_RETURN_VALUE(cobj->isFrontFaceCCW, s.thisObject(), s.rval()); + return true; +} +SE_BIND_PROP_GET(js_assets_RasterizerStateInfo_get_isFrontFaceCCW) + +static bool js_assets_RasterizerStateInfo_set_isFrontFaceCCW(se::State& s) // NOLINT(readability-identifier-naming) +{ + const auto& args = s.args(); + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_assets_RasterizerStateInfo_set_isFrontFaceCCW : Invalid Native Object"); + + CC_UNUSED bool ok = true; + ok &= sevalue_to_native(args[0], &cobj->isFrontFaceCCW, s.thisObject()); + SE_PRECONDITION2(ok, false, "js_assets_RasterizerStateInfo_set_isFrontFaceCCW : Error processing new value"); + return true; +} +SE_BIND_PROP_SET(js_assets_RasterizerStateInfo_set_isFrontFaceCCW) + +static bool js_assets_RasterizerStateInfo_get_depthBiasEnabled(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_assets_RasterizerStateInfo_get_depthBiasEnabled : Invalid Native Object"); + + CC_UNUSED bool ok = true; + se::Value jsret; + ok &= nativevalue_to_se(cobj->depthBiasEnabled, jsret, s.thisObject() /*ctx*/); + s.rval() = jsret; + SE_HOLD_RETURN_VALUE(cobj->depthBiasEnabled, s.thisObject(), s.rval()); + return true; +} +SE_BIND_PROP_GET(js_assets_RasterizerStateInfo_get_depthBiasEnabled) + +static bool js_assets_RasterizerStateInfo_set_depthBiasEnabled(se::State& s) // NOLINT(readability-identifier-naming) +{ + const auto& args = s.args(); + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_assets_RasterizerStateInfo_set_depthBiasEnabled : Invalid Native Object"); + + CC_UNUSED bool ok = true; + ok &= sevalue_to_native(args[0], &cobj->depthBiasEnabled, s.thisObject()); + SE_PRECONDITION2(ok, false, "js_assets_RasterizerStateInfo_set_depthBiasEnabled : Error processing new value"); + return true; +} +SE_BIND_PROP_SET(js_assets_RasterizerStateInfo_set_depthBiasEnabled) + +static bool js_assets_RasterizerStateInfo_get_isDepthClip(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_assets_RasterizerStateInfo_get_isDepthClip : Invalid Native Object"); + + CC_UNUSED bool ok = true; + se::Value jsret; + ok &= nativevalue_to_se(cobj->isDepthClip, jsret, s.thisObject() /*ctx*/); + s.rval() = jsret; + SE_HOLD_RETURN_VALUE(cobj->isDepthClip, s.thisObject(), s.rval()); + return true; +} +SE_BIND_PROP_GET(js_assets_RasterizerStateInfo_get_isDepthClip) + +static bool js_assets_RasterizerStateInfo_set_isDepthClip(se::State& s) // NOLINT(readability-identifier-naming) +{ + const auto& args = s.args(); + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_assets_RasterizerStateInfo_set_isDepthClip : Invalid Native Object"); + + CC_UNUSED bool ok = true; + ok &= sevalue_to_native(args[0], &cobj->isDepthClip, s.thisObject()); + SE_PRECONDITION2(ok, false, "js_assets_RasterizerStateInfo_set_isDepthClip : Error processing new value"); + return true; +} +SE_BIND_PROP_SET(js_assets_RasterizerStateInfo_set_isDepthClip) + +static bool js_assets_RasterizerStateInfo_get_isMultisample(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_assets_RasterizerStateInfo_get_isMultisample : Invalid Native Object"); + + CC_UNUSED bool ok = true; + se::Value jsret; + ok &= nativevalue_to_se(cobj->isMultisample, jsret, s.thisObject() /*ctx*/); + s.rval() = jsret; + SE_HOLD_RETURN_VALUE(cobj->isMultisample, s.thisObject(), s.rval()); + return true; +} +SE_BIND_PROP_GET(js_assets_RasterizerStateInfo_get_isMultisample) + +static bool js_assets_RasterizerStateInfo_set_isMultisample(se::State& s) // NOLINT(readability-identifier-naming) +{ + const auto& args = s.args(); + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_assets_RasterizerStateInfo_set_isMultisample : Invalid Native Object"); + + CC_UNUSED bool ok = true; + ok &= sevalue_to_native(args[0], &cobj->isMultisample, s.thisObject()); + SE_PRECONDITION2(ok, false, "js_assets_RasterizerStateInfo_set_isMultisample : Error processing new value"); + return true; +} +SE_BIND_PROP_SET(js_assets_RasterizerStateInfo_set_isMultisample) + +static bool js_assets_RasterizerStateInfo_get_polygonMode(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_assets_RasterizerStateInfo_get_polygonMode : Invalid Native Object"); + + CC_UNUSED bool ok = true; + se::Value jsret; + ok &= nativevalue_to_se(cobj->polygonMode, jsret, s.thisObject() /*ctx*/); + s.rval() = jsret; + SE_HOLD_RETURN_VALUE(cobj->polygonMode, s.thisObject(), s.rval()); + return true; +} +SE_BIND_PROP_GET(js_assets_RasterizerStateInfo_get_polygonMode) + +static bool js_assets_RasterizerStateInfo_set_polygonMode(se::State& s) // NOLINT(readability-identifier-naming) +{ + const auto& args = s.args(); + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_assets_RasterizerStateInfo_set_polygonMode : Invalid Native Object"); + + CC_UNUSED bool ok = true; + ok &= sevalue_to_native(args[0], &cobj->polygonMode, s.thisObject()); + SE_PRECONDITION2(ok, false, "js_assets_RasterizerStateInfo_set_polygonMode : Error processing new value"); + return true; +} +SE_BIND_PROP_SET(js_assets_RasterizerStateInfo_set_polygonMode) + +static bool js_assets_RasterizerStateInfo_get_shadeModel(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_assets_RasterizerStateInfo_get_shadeModel : Invalid Native Object"); + + CC_UNUSED bool ok = true; + se::Value jsret; + ok &= nativevalue_to_se(cobj->shadeModel, jsret, s.thisObject() /*ctx*/); + s.rval() = jsret; + SE_HOLD_RETURN_VALUE(cobj->shadeModel, s.thisObject(), s.rval()); + return true; +} +SE_BIND_PROP_GET(js_assets_RasterizerStateInfo_get_shadeModel) + +static bool js_assets_RasterizerStateInfo_set_shadeModel(se::State& s) // NOLINT(readability-identifier-naming) +{ + const auto& args = s.args(); + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_assets_RasterizerStateInfo_set_shadeModel : Invalid Native Object"); + + CC_UNUSED bool ok = true; + ok &= sevalue_to_native(args[0], &cobj->shadeModel, s.thisObject()); + SE_PRECONDITION2(ok, false, "js_assets_RasterizerStateInfo_set_shadeModel : Error processing new value"); + return true; +} +SE_BIND_PROP_SET(js_assets_RasterizerStateInfo_set_shadeModel) + +static bool js_assets_RasterizerStateInfo_get_cullMode(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_assets_RasterizerStateInfo_get_cullMode : Invalid Native Object"); + + CC_UNUSED bool ok = true; + se::Value jsret; + ok &= nativevalue_to_se(cobj->cullMode, jsret, s.thisObject() /*ctx*/); + s.rval() = jsret; + SE_HOLD_RETURN_VALUE(cobj->cullMode, s.thisObject(), s.rval()); + return true; +} +SE_BIND_PROP_GET(js_assets_RasterizerStateInfo_get_cullMode) + +static bool js_assets_RasterizerStateInfo_set_cullMode(se::State& s) // NOLINT(readability-identifier-naming) +{ + const auto& args = s.args(); + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_assets_RasterizerStateInfo_set_cullMode : Invalid Native Object"); + + CC_UNUSED bool ok = true; + ok &= sevalue_to_native(args[0], &cobj->cullMode, s.thisObject()); + SE_PRECONDITION2(ok, false, "js_assets_RasterizerStateInfo_set_cullMode : Error processing new value"); + return true; +} +SE_BIND_PROP_SET(js_assets_RasterizerStateInfo_set_cullMode) + +static bool js_assets_RasterizerStateInfo_get_depthBias(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_assets_RasterizerStateInfo_get_depthBias : Invalid Native Object"); + + CC_UNUSED bool ok = true; + se::Value jsret; + ok &= nativevalue_to_se(cobj->depthBias, jsret, s.thisObject() /*ctx*/); + s.rval() = jsret; + SE_HOLD_RETURN_VALUE(cobj->depthBias, s.thisObject(), s.rval()); + return true; +} +SE_BIND_PROP_GET(js_assets_RasterizerStateInfo_get_depthBias) + +static bool js_assets_RasterizerStateInfo_set_depthBias(se::State& s) // NOLINT(readability-identifier-naming) +{ + const auto& args = s.args(); + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_assets_RasterizerStateInfo_set_depthBias : Invalid Native Object"); + + CC_UNUSED bool ok = true; + ok &= sevalue_to_native(args[0], &cobj->depthBias, s.thisObject()); + SE_PRECONDITION2(ok, false, "js_assets_RasterizerStateInfo_set_depthBias : Error processing new value"); + return true; +} +SE_BIND_PROP_SET(js_assets_RasterizerStateInfo_set_depthBias) + +static bool js_assets_RasterizerStateInfo_get_depthBiasClamp(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_assets_RasterizerStateInfo_get_depthBiasClamp : Invalid Native Object"); + + CC_UNUSED bool ok = true; + se::Value jsret; + ok &= nativevalue_to_se(cobj->depthBiasClamp, jsret, s.thisObject() /*ctx*/); + s.rval() = jsret; + SE_HOLD_RETURN_VALUE(cobj->depthBiasClamp, s.thisObject(), s.rval()); + return true; +} +SE_BIND_PROP_GET(js_assets_RasterizerStateInfo_get_depthBiasClamp) + +static bool js_assets_RasterizerStateInfo_set_depthBiasClamp(se::State& s) // NOLINT(readability-identifier-naming) +{ + const auto& args = s.args(); + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_assets_RasterizerStateInfo_set_depthBiasClamp : Invalid Native Object"); + + CC_UNUSED bool ok = true; + ok &= sevalue_to_native(args[0], &cobj->depthBiasClamp, s.thisObject()); + SE_PRECONDITION2(ok, false, "js_assets_RasterizerStateInfo_set_depthBiasClamp : Error processing new value"); + return true; +} +SE_BIND_PROP_SET(js_assets_RasterizerStateInfo_set_depthBiasClamp) + +static bool js_assets_RasterizerStateInfo_get_depthBiasSlop(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_assets_RasterizerStateInfo_get_depthBiasSlop : Invalid Native Object"); + + CC_UNUSED bool ok = true; + se::Value jsret; + ok &= nativevalue_to_se(cobj->depthBiasSlop, jsret, s.thisObject() /*ctx*/); + s.rval() = jsret; + SE_HOLD_RETURN_VALUE(cobj->depthBiasSlop, s.thisObject(), s.rval()); + return true; +} +SE_BIND_PROP_GET(js_assets_RasterizerStateInfo_get_depthBiasSlop) + +static bool js_assets_RasterizerStateInfo_set_depthBiasSlop(se::State& s) // NOLINT(readability-identifier-naming) +{ + const auto& args = s.args(); + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_assets_RasterizerStateInfo_set_depthBiasSlop : Invalid Native Object"); + + CC_UNUSED bool ok = true; + ok &= sevalue_to_native(args[0], &cobj->depthBiasSlop, s.thisObject()); + SE_PRECONDITION2(ok, false, "js_assets_RasterizerStateInfo_set_depthBiasSlop : Error processing new value"); + return true; +} +SE_BIND_PROP_SET(js_assets_RasterizerStateInfo_set_depthBiasSlop) + +static bool js_assets_RasterizerStateInfo_get_lineWidth(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_assets_RasterizerStateInfo_get_lineWidth : Invalid Native Object"); + + CC_UNUSED bool ok = true; + se::Value jsret; + ok &= nativevalue_to_se(cobj->lineWidth, jsret, s.thisObject() /*ctx*/); + s.rval() = jsret; + SE_HOLD_RETURN_VALUE(cobj->lineWidth, s.thisObject(), s.rval()); + return true; +} +SE_BIND_PROP_GET(js_assets_RasterizerStateInfo_get_lineWidth) + +static bool js_assets_RasterizerStateInfo_set_lineWidth(se::State& s) // NOLINT(readability-identifier-naming) +{ + const auto& args = s.args(); + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_assets_RasterizerStateInfo_set_lineWidth : Invalid Native Object"); + + CC_UNUSED bool ok = true; + ok &= sevalue_to_native(args[0], &cobj->lineWidth, s.thisObject()); + SE_PRECONDITION2(ok, false, "js_assets_RasterizerStateInfo_set_lineWidth : Error processing new value"); + return true; +} +SE_BIND_PROP_SET(js_assets_RasterizerStateInfo_set_lineWidth) + + +template<> +bool sevalue_to_native(const se::Value &from, cc::RasterizerStateInfo * to, se::Object *ctx) +{ + assert(from.isObject()); + se::Object *json = from.toObject(); + auto* data = reinterpret_cast(json->getPrivateData()); + if (data) { + *to = *data; + return true; + } + se::Value field; + bool ok = true; + json->getProperty("isDiscard", &field, true); + if(!field.isNullOrUndefined()) { + ok &= sevalue_to_native(field, &(to->isDiscard), ctx); + } + json->getProperty("isFrontFaceCCW", &field, true); + if(!field.isNullOrUndefined()) { + ok &= sevalue_to_native(field, &(to->isFrontFaceCCW), ctx); + } + json->getProperty("depthBiasEnabled", &field, true); + if(!field.isNullOrUndefined()) { + ok &= sevalue_to_native(field, &(to->depthBiasEnabled), ctx); + } + json->getProperty("isDepthClip", &field, true); + if(!field.isNullOrUndefined()) { + ok &= sevalue_to_native(field, &(to->isDepthClip), ctx); + } + json->getProperty("isMultisample", &field, true); + if(!field.isNullOrUndefined()) { + ok &= sevalue_to_native(field, &(to->isMultisample), ctx); + } + json->getProperty("polygonMode", &field, true); + if(!field.isNullOrUndefined()) { + ok &= sevalue_to_native(field, &(to->polygonMode), ctx); + } + json->getProperty("shadeModel", &field, true); + if(!field.isNullOrUndefined()) { + ok &= sevalue_to_native(field, &(to->shadeModel), ctx); + } + json->getProperty("cullMode", &field, true); + if(!field.isNullOrUndefined()) { + ok &= sevalue_to_native(field, &(to->cullMode), ctx); + } + json->getProperty("depthBias", &field, true); + if(!field.isNullOrUndefined()) { + ok &= sevalue_to_native(field, &(to->depthBias), ctx); + } + json->getProperty("depthBiasClamp", &field, true); + if(!field.isNullOrUndefined()) { + ok &= sevalue_to_native(field, &(to->depthBiasClamp), ctx); + } + json->getProperty("depthBiasSlop", &field, true); + if(!field.isNullOrUndefined()) { + ok &= sevalue_to_native(field, &(to->depthBiasSlop), ctx); + } + json->getProperty("lineWidth", &field, true); + if(!field.isNullOrUndefined()) { + ok &= sevalue_to_native(field, &(to->lineWidth), ctx); + } + return ok; +} + +SE_DECLARE_FINALIZE_FUNC(js_cc_RasterizerStateInfo_finalize) + +static bool js_assets_RasterizerStateInfo_constructor(se::State& s) // NOLINT(readability-identifier-naming) +{ + CC_UNUSED bool ok = true; + const auto& args = s.args(); + size_t argc = args.size(); + + if(argc == 0) + { + auto *ptr = JSB_MAKE_PRIVATE_OBJECT(cc::RasterizerStateInfo); + s.thisObject()->setPrivateObject(ptr); + return true; + } + + if(argc == 1 && args[0].isObject()) + { + se::Object *json = args[0].toObject(); + se::Value field; + auto *ptr = JSB_MAKE_PRIVATE_OBJECT(cc::RasterizerStateInfo); + auto cobj = ptr->get(); + ok &= sevalue_to_native(args[0], cobj, s.thisObject()); + if(!ok) { + delete ptr; + SE_REPORT_ERROR("argument convertion error"); + return false; + } + s.thisObject()->setPrivateObject(ptr); + return true; + } + auto *ptr = JSB_MAKE_PRIVATE_OBJECT(cc::RasterizerStateInfo); + auto cobj = ptr->get(); + if (argc > 0 && !args[0].isUndefined()) { + ok &= sevalue_to_native(args[0], &(cobj->isDiscard), nullptr); + } + if (argc > 1 && !args[1].isUndefined()) { + ok &= sevalue_to_native(args[1], &(cobj->isFrontFaceCCW), nullptr); + } + if (argc > 2 && !args[2].isUndefined()) { + ok &= sevalue_to_native(args[2], &(cobj->depthBiasEnabled), nullptr); + } + if (argc > 3 && !args[3].isUndefined()) { + ok &= sevalue_to_native(args[3], &(cobj->isDepthClip), nullptr); + } + if (argc > 4 && !args[4].isUndefined()) { + ok &= sevalue_to_native(args[4], &(cobj->isMultisample), nullptr); + } + if (argc > 5 && !args[5].isUndefined()) { + ok &= sevalue_to_native(args[5], &(cobj->polygonMode), nullptr); + } + if (argc > 6 && !args[6].isUndefined()) { + ok &= sevalue_to_native(args[6], &(cobj->shadeModel), nullptr); + } + if (argc > 7 && !args[7].isUndefined()) { + ok &= sevalue_to_native(args[7], &(cobj->cullMode), nullptr); + } + if (argc > 8 && !args[8].isUndefined()) { + ok &= sevalue_to_native(args[8], &(cobj->depthBias), nullptr); + } + if (argc > 9 && !args[9].isUndefined()) { + ok &= sevalue_to_native(args[9], &(cobj->depthBiasClamp), nullptr); + } + if (argc > 10 && !args[10].isUndefined()) { + ok &= sevalue_to_native(args[10], &(cobj->depthBiasSlop), nullptr); + } + if (argc > 11 && !args[11].isUndefined()) { + ok &= sevalue_to_native(args[11], &(cobj->lineWidth), nullptr); + } + + if(!ok) { + delete ptr; + SE_REPORT_ERROR("Argument convertion error"); + return false; + } + s.thisObject()->setPrivateObject(ptr); + return true; +} +SE_BIND_CTOR(js_assets_RasterizerStateInfo_constructor, __jsb_cc_RasterizerStateInfo_class, js_cc_RasterizerStateInfo_finalize) + +static bool js_cc_RasterizerStateInfo_finalize(se::State& s) // NOLINT(readability-identifier-naming) +{ + return true; +} +SE_BIND_FINALIZE_FUNC(js_cc_RasterizerStateInfo_finalize) + +bool js_register_assets_RasterizerStateInfo(se::Object* obj) // NOLINT(readability-identifier-naming) +{ + auto* cls = se::Class::create("RasterizerStateInfo", obj, nullptr, _SE(js_assets_RasterizerStateInfo_constructor)); + + cls->defineProperty("isDiscard", _SE(js_assets_RasterizerStateInfo_get_isDiscard), _SE(js_assets_RasterizerStateInfo_set_isDiscard)); + cls->defineProperty("isFrontFaceCCW", _SE(js_assets_RasterizerStateInfo_get_isFrontFaceCCW), _SE(js_assets_RasterizerStateInfo_set_isFrontFaceCCW)); + cls->defineProperty("depthBiasEnabled", _SE(js_assets_RasterizerStateInfo_get_depthBiasEnabled), _SE(js_assets_RasterizerStateInfo_set_depthBiasEnabled)); + cls->defineProperty("isDepthClip", _SE(js_assets_RasterizerStateInfo_get_isDepthClip), _SE(js_assets_RasterizerStateInfo_set_isDepthClip)); + cls->defineProperty("isMultisample", _SE(js_assets_RasterizerStateInfo_get_isMultisample), _SE(js_assets_RasterizerStateInfo_set_isMultisample)); + cls->defineProperty("polygonMode", _SE(js_assets_RasterizerStateInfo_get_polygonMode), _SE(js_assets_RasterizerStateInfo_set_polygonMode)); + cls->defineProperty("shadeModel", _SE(js_assets_RasterizerStateInfo_get_shadeModel), _SE(js_assets_RasterizerStateInfo_set_shadeModel)); + cls->defineProperty("cullMode", _SE(js_assets_RasterizerStateInfo_get_cullMode), _SE(js_assets_RasterizerStateInfo_set_cullMode)); + cls->defineProperty("depthBias", _SE(js_assets_RasterizerStateInfo_get_depthBias), _SE(js_assets_RasterizerStateInfo_set_depthBias)); + cls->defineProperty("depthBiasClamp", _SE(js_assets_RasterizerStateInfo_get_depthBiasClamp), _SE(js_assets_RasterizerStateInfo_set_depthBiasClamp)); + cls->defineProperty("depthBiasSlop", _SE(js_assets_RasterizerStateInfo_get_depthBiasSlop), _SE(js_assets_RasterizerStateInfo_set_depthBiasSlop)); + cls->defineProperty("lineWidth", _SE(js_assets_RasterizerStateInfo_get_lineWidth), _SE(js_assets_RasterizerStateInfo_set_lineWidth)); + cls->defineFinalizeFunction(_SE(js_cc_RasterizerStateInfo_finalize)); + cls->install(); + JSBClassType::registerClass(cls); + + __jsb_cc_RasterizerStateInfo_proto = cls->getProto(); + __jsb_cc_RasterizerStateInfo_class = cls; + + + se::ScriptEngine::getInstance()->clearException(); + return true; +} +se::Object* __jsb_cc_DepthStencilStateInfo_proto = nullptr; // NOLINT +se::Class* __jsb_cc_DepthStencilStateInfo_class = nullptr; // NOLINT + +static bool js_assets_DepthStencilStateInfo_get_depthTest(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_assets_DepthStencilStateInfo_get_depthTest : Invalid Native Object"); + + CC_UNUSED bool ok = true; + se::Value jsret; + ok &= nativevalue_to_se(cobj->depthTest, jsret, s.thisObject() /*ctx*/); + s.rval() = jsret; + SE_HOLD_RETURN_VALUE(cobj->depthTest, s.thisObject(), s.rval()); + return true; +} +SE_BIND_PROP_GET(js_assets_DepthStencilStateInfo_get_depthTest) + +static bool js_assets_DepthStencilStateInfo_set_depthTest(se::State& s) // NOLINT(readability-identifier-naming) +{ + const auto& args = s.args(); + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_assets_DepthStencilStateInfo_set_depthTest : Invalid Native Object"); + + CC_UNUSED bool ok = true; + ok &= sevalue_to_native(args[0], &cobj->depthTest, s.thisObject()); + SE_PRECONDITION2(ok, false, "js_assets_DepthStencilStateInfo_set_depthTest : Error processing new value"); + return true; +} +SE_BIND_PROP_SET(js_assets_DepthStencilStateInfo_set_depthTest) + +static bool js_assets_DepthStencilStateInfo_get_depthWrite(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_assets_DepthStencilStateInfo_get_depthWrite : Invalid Native Object"); + + CC_UNUSED bool ok = true; + se::Value jsret; + ok &= nativevalue_to_se(cobj->depthWrite, jsret, s.thisObject() /*ctx*/); + s.rval() = jsret; + SE_HOLD_RETURN_VALUE(cobj->depthWrite, s.thisObject(), s.rval()); + return true; +} +SE_BIND_PROP_GET(js_assets_DepthStencilStateInfo_get_depthWrite) + +static bool js_assets_DepthStencilStateInfo_set_depthWrite(se::State& s) // NOLINT(readability-identifier-naming) +{ + const auto& args = s.args(); + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_assets_DepthStencilStateInfo_set_depthWrite : Invalid Native Object"); + + CC_UNUSED bool ok = true; + ok &= sevalue_to_native(args[0], &cobj->depthWrite, s.thisObject()); + SE_PRECONDITION2(ok, false, "js_assets_DepthStencilStateInfo_set_depthWrite : Error processing new value"); + return true; +} +SE_BIND_PROP_SET(js_assets_DepthStencilStateInfo_set_depthWrite) + +static bool js_assets_DepthStencilStateInfo_get_stencilTestFront(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_assets_DepthStencilStateInfo_get_stencilTestFront : Invalid Native Object"); + + CC_UNUSED bool ok = true; + se::Value jsret; + ok &= nativevalue_to_se(cobj->stencilTestFront, jsret, s.thisObject() /*ctx*/); + s.rval() = jsret; + SE_HOLD_RETURN_VALUE(cobj->stencilTestFront, s.thisObject(), s.rval()); + return true; +} +SE_BIND_PROP_GET(js_assets_DepthStencilStateInfo_get_stencilTestFront) + +static bool js_assets_DepthStencilStateInfo_set_stencilTestFront(se::State& s) // NOLINT(readability-identifier-naming) +{ + const auto& args = s.args(); + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_assets_DepthStencilStateInfo_set_stencilTestFront : Invalid Native Object"); + + CC_UNUSED bool ok = true; + ok &= sevalue_to_native(args[0], &cobj->stencilTestFront, s.thisObject()); + SE_PRECONDITION2(ok, false, "js_assets_DepthStencilStateInfo_set_stencilTestFront : Error processing new value"); + return true; +} +SE_BIND_PROP_SET(js_assets_DepthStencilStateInfo_set_stencilTestFront) + +static bool js_assets_DepthStencilStateInfo_get_stencilTestBack(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_assets_DepthStencilStateInfo_get_stencilTestBack : Invalid Native Object"); + + CC_UNUSED bool ok = true; + se::Value jsret; + ok &= nativevalue_to_se(cobj->stencilTestBack, jsret, s.thisObject() /*ctx*/); + s.rval() = jsret; + SE_HOLD_RETURN_VALUE(cobj->stencilTestBack, s.thisObject(), s.rval()); + return true; +} +SE_BIND_PROP_GET(js_assets_DepthStencilStateInfo_get_stencilTestBack) + +static bool js_assets_DepthStencilStateInfo_set_stencilTestBack(se::State& s) // NOLINT(readability-identifier-naming) +{ + const auto& args = s.args(); + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_assets_DepthStencilStateInfo_set_stencilTestBack : Invalid Native Object"); + + CC_UNUSED bool ok = true; + ok &= sevalue_to_native(args[0], &cobj->stencilTestBack, s.thisObject()); + SE_PRECONDITION2(ok, false, "js_assets_DepthStencilStateInfo_set_stencilTestBack : Error processing new value"); + return true; +} +SE_BIND_PROP_SET(js_assets_DepthStencilStateInfo_set_stencilTestBack) + +static bool js_assets_DepthStencilStateInfo_get_depthFunc(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_assets_DepthStencilStateInfo_get_depthFunc : Invalid Native Object"); + + CC_UNUSED bool ok = true; + se::Value jsret; + ok &= nativevalue_to_se(cobj->depthFunc, jsret, s.thisObject() /*ctx*/); + s.rval() = jsret; + SE_HOLD_RETURN_VALUE(cobj->depthFunc, s.thisObject(), s.rval()); + return true; +} +SE_BIND_PROP_GET(js_assets_DepthStencilStateInfo_get_depthFunc) + +static bool js_assets_DepthStencilStateInfo_set_depthFunc(se::State& s) // NOLINT(readability-identifier-naming) +{ + const auto& args = s.args(); + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_assets_DepthStencilStateInfo_set_depthFunc : Invalid Native Object"); + + CC_UNUSED bool ok = true; + ok &= sevalue_to_native(args[0], &cobj->depthFunc, s.thisObject()); + SE_PRECONDITION2(ok, false, "js_assets_DepthStencilStateInfo_set_depthFunc : Error processing new value"); + return true; +} +SE_BIND_PROP_SET(js_assets_DepthStencilStateInfo_set_depthFunc) + +static bool js_assets_DepthStencilStateInfo_get_stencilFuncFront(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_assets_DepthStencilStateInfo_get_stencilFuncFront : Invalid Native Object"); + + CC_UNUSED bool ok = true; + se::Value jsret; + ok &= nativevalue_to_se(cobj->stencilFuncFront, jsret, s.thisObject() /*ctx*/); + s.rval() = jsret; + SE_HOLD_RETURN_VALUE(cobj->stencilFuncFront, s.thisObject(), s.rval()); + return true; +} +SE_BIND_PROP_GET(js_assets_DepthStencilStateInfo_get_stencilFuncFront) + +static bool js_assets_DepthStencilStateInfo_set_stencilFuncFront(se::State& s) // NOLINT(readability-identifier-naming) +{ + const auto& args = s.args(); + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_assets_DepthStencilStateInfo_set_stencilFuncFront : Invalid Native Object"); + + CC_UNUSED bool ok = true; + ok &= sevalue_to_native(args[0], &cobj->stencilFuncFront, s.thisObject()); + SE_PRECONDITION2(ok, false, "js_assets_DepthStencilStateInfo_set_stencilFuncFront : Error processing new value"); + return true; +} +SE_BIND_PROP_SET(js_assets_DepthStencilStateInfo_set_stencilFuncFront) + +static bool js_assets_DepthStencilStateInfo_get_stencilReadMaskFront(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_assets_DepthStencilStateInfo_get_stencilReadMaskFront : Invalid Native Object"); + + CC_UNUSED bool ok = true; + se::Value jsret; + ok &= nativevalue_to_se(cobj->stencilReadMaskFront, jsret, s.thisObject() /*ctx*/); + s.rval() = jsret; + SE_HOLD_RETURN_VALUE(cobj->stencilReadMaskFront, s.thisObject(), s.rval()); + return true; +} +SE_BIND_PROP_GET(js_assets_DepthStencilStateInfo_get_stencilReadMaskFront) + +static bool js_assets_DepthStencilStateInfo_set_stencilReadMaskFront(se::State& s) // NOLINT(readability-identifier-naming) +{ + const auto& args = s.args(); + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_assets_DepthStencilStateInfo_set_stencilReadMaskFront : Invalid Native Object"); + + CC_UNUSED bool ok = true; + ok &= sevalue_to_native(args[0], &cobj->stencilReadMaskFront, s.thisObject()); + SE_PRECONDITION2(ok, false, "js_assets_DepthStencilStateInfo_set_stencilReadMaskFront : Error processing new value"); + return true; +} +SE_BIND_PROP_SET(js_assets_DepthStencilStateInfo_set_stencilReadMaskFront) + +static bool js_assets_DepthStencilStateInfo_get_stencilWriteMaskFront(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_assets_DepthStencilStateInfo_get_stencilWriteMaskFront : Invalid Native Object"); + + CC_UNUSED bool ok = true; + se::Value jsret; + ok &= nativevalue_to_se(cobj->stencilWriteMaskFront, jsret, s.thisObject() /*ctx*/); + s.rval() = jsret; + SE_HOLD_RETURN_VALUE(cobj->stencilWriteMaskFront, s.thisObject(), s.rval()); + return true; +} +SE_BIND_PROP_GET(js_assets_DepthStencilStateInfo_get_stencilWriteMaskFront) + +static bool js_assets_DepthStencilStateInfo_set_stencilWriteMaskFront(se::State& s) // NOLINT(readability-identifier-naming) +{ + const auto& args = s.args(); + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_assets_DepthStencilStateInfo_set_stencilWriteMaskFront : Invalid Native Object"); + + CC_UNUSED bool ok = true; + ok &= sevalue_to_native(args[0], &cobj->stencilWriteMaskFront, s.thisObject()); + SE_PRECONDITION2(ok, false, "js_assets_DepthStencilStateInfo_set_stencilWriteMaskFront : Error processing new value"); + return true; +} +SE_BIND_PROP_SET(js_assets_DepthStencilStateInfo_set_stencilWriteMaskFront) + +static bool js_assets_DepthStencilStateInfo_get_stencilFailOpFront(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_assets_DepthStencilStateInfo_get_stencilFailOpFront : Invalid Native Object"); + + CC_UNUSED bool ok = true; + se::Value jsret; + ok &= nativevalue_to_se(cobj->stencilFailOpFront, jsret, s.thisObject() /*ctx*/); + s.rval() = jsret; + SE_HOLD_RETURN_VALUE(cobj->stencilFailOpFront, s.thisObject(), s.rval()); + return true; +} +SE_BIND_PROP_GET(js_assets_DepthStencilStateInfo_get_stencilFailOpFront) + +static bool js_assets_DepthStencilStateInfo_set_stencilFailOpFront(se::State& s) // NOLINT(readability-identifier-naming) +{ + const auto& args = s.args(); + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_assets_DepthStencilStateInfo_set_stencilFailOpFront : Invalid Native Object"); + + CC_UNUSED bool ok = true; + ok &= sevalue_to_native(args[0], &cobj->stencilFailOpFront, s.thisObject()); + SE_PRECONDITION2(ok, false, "js_assets_DepthStencilStateInfo_set_stencilFailOpFront : Error processing new value"); + return true; +} +SE_BIND_PROP_SET(js_assets_DepthStencilStateInfo_set_stencilFailOpFront) + +static bool js_assets_DepthStencilStateInfo_get_stencilZFailOpFront(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_assets_DepthStencilStateInfo_get_stencilZFailOpFront : Invalid Native Object"); + + CC_UNUSED bool ok = true; + se::Value jsret; + ok &= nativevalue_to_se(cobj->stencilZFailOpFront, jsret, s.thisObject() /*ctx*/); + s.rval() = jsret; + SE_HOLD_RETURN_VALUE(cobj->stencilZFailOpFront, s.thisObject(), s.rval()); + return true; +} +SE_BIND_PROP_GET(js_assets_DepthStencilStateInfo_get_stencilZFailOpFront) + +static bool js_assets_DepthStencilStateInfo_set_stencilZFailOpFront(se::State& s) // NOLINT(readability-identifier-naming) +{ + const auto& args = s.args(); + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_assets_DepthStencilStateInfo_set_stencilZFailOpFront : Invalid Native Object"); + + CC_UNUSED bool ok = true; + ok &= sevalue_to_native(args[0], &cobj->stencilZFailOpFront, s.thisObject()); + SE_PRECONDITION2(ok, false, "js_assets_DepthStencilStateInfo_set_stencilZFailOpFront : Error processing new value"); + return true; +} +SE_BIND_PROP_SET(js_assets_DepthStencilStateInfo_set_stencilZFailOpFront) + +static bool js_assets_DepthStencilStateInfo_get_stencilPassOpFront(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_assets_DepthStencilStateInfo_get_stencilPassOpFront : Invalid Native Object"); + + CC_UNUSED bool ok = true; + se::Value jsret; + ok &= nativevalue_to_se(cobj->stencilPassOpFront, jsret, s.thisObject() /*ctx*/); + s.rval() = jsret; + SE_HOLD_RETURN_VALUE(cobj->stencilPassOpFront, s.thisObject(), s.rval()); + return true; +} +SE_BIND_PROP_GET(js_assets_DepthStencilStateInfo_get_stencilPassOpFront) + +static bool js_assets_DepthStencilStateInfo_set_stencilPassOpFront(se::State& s) // NOLINT(readability-identifier-naming) +{ + const auto& args = s.args(); + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_assets_DepthStencilStateInfo_set_stencilPassOpFront : Invalid Native Object"); + + CC_UNUSED bool ok = true; + ok &= sevalue_to_native(args[0], &cobj->stencilPassOpFront, s.thisObject()); + SE_PRECONDITION2(ok, false, "js_assets_DepthStencilStateInfo_set_stencilPassOpFront : Error processing new value"); + return true; +} +SE_BIND_PROP_SET(js_assets_DepthStencilStateInfo_set_stencilPassOpFront) + +static bool js_assets_DepthStencilStateInfo_get_stencilRefFront(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_assets_DepthStencilStateInfo_get_stencilRefFront : Invalid Native Object"); + + CC_UNUSED bool ok = true; + se::Value jsret; + ok &= nativevalue_to_se(cobj->stencilRefFront, jsret, s.thisObject() /*ctx*/); + s.rval() = jsret; + SE_HOLD_RETURN_VALUE(cobj->stencilRefFront, s.thisObject(), s.rval()); + return true; +} +SE_BIND_PROP_GET(js_assets_DepthStencilStateInfo_get_stencilRefFront) + +static bool js_assets_DepthStencilStateInfo_set_stencilRefFront(se::State& s) // NOLINT(readability-identifier-naming) +{ + const auto& args = s.args(); + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_assets_DepthStencilStateInfo_set_stencilRefFront : Invalid Native Object"); + + CC_UNUSED bool ok = true; + ok &= sevalue_to_native(args[0], &cobj->stencilRefFront, s.thisObject()); + SE_PRECONDITION2(ok, false, "js_assets_DepthStencilStateInfo_set_stencilRefFront : Error processing new value"); + return true; +} +SE_BIND_PROP_SET(js_assets_DepthStencilStateInfo_set_stencilRefFront) + +static bool js_assets_DepthStencilStateInfo_get_stencilFuncBack(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_assets_DepthStencilStateInfo_get_stencilFuncBack : Invalid Native Object"); + + CC_UNUSED bool ok = true; + se::Value jsret; + ok &= nativevalue_to_se(cobj->stencilFuncBack, jsret, s.thisObject() /*ctx*/); + s.rval() = jsret; + SE_HOLD_RETURN_VALUE(cobj->stencilFuncBack, s.thisObject(), s.rval()); + return true; +} +SE_BIND_PROP_GET(js_assets_DepthStencilStateInfo_get_stencilFuncBack) + +static bool js_assets_DepthStencilStateInfo_set_stencilFuncBack(se::State& s) // NOLINT(readability-identifier-naming) +{ + const auto& args = s.args(); + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_assets_DepthStencilStateInfo_set_stencilFuncBack : Invalid Native Object"); + + CC_UNUSED bool ok = true; + ok &= sevalue_to_native(args[0], &cobj->stencilFuncBack, s.thisObject()); + SE_PRECONDITION2(ok, false, "js_assets_DepthStencilStateInfo_set_stencilFuncBack : Error processing new value"); + return true; +} +SE_BIND_PROP_SET(js_assets_DepthStencilStateInfo_set_stencilFuncBack) + +static bool js_assets_DepthStencilStateInfo_get_stencilReadMaskBack(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_assets_DepthStencilStateInfo_get_stencilReadMaskBack : Invalid Native Object"); + + CC_UNUSED bool ok = true; + se::Value jsret; + ok &= nativevalue_to_se(cobj->stencilReadMaskBack, jsret, s.thisObject() /*ctx*/); + s.rval() = jsret; + SE_HOLD_RETURN_VALUE(cobj->stencilReadMaskBack, s.thisObject(), s.rval()); + return true; +} +SE_BIND_PROP_GET(js_assets_DepthStencilStateInfo_get_stencilReadMaskBack) + +static bool js_assets_DepthStencilStateInfo_set_stencilReadMaskBack(se::State& s) // NOLINT(readability-identifier-naming) +{ + const auto& args = s.args(); + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_assets_DepthStencilStateInfo_set_stencilReadMaskBack : Invalid Native Object"); + + CC_UNUSED bool ok = true; + ok &= sevalue_to_native(args[0], &cobj->stencilReadMaskBack, s.thisObject()); + SE_PRECONDITION2(ok, false, "js_assets_DepthStencilStateInfo_set_stencilReadMaskBack : Error processing new value"); + return true; +} +SE_BIND_PROP_SET(js_assets_DepthStencilStateInfo_set_stencilReadMaskBack) + +static bool js_assets_DepthStencilStateInfo_get_stencilWriteMaskBack(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_assets_DepthStencilStateInfo_get_stencilWriteMaskBack : Invalid Native Object"); + + CC_UNUSED bool ok = true; + se::Value jsret; + ok &= nativevalue_to_se(cobj->stencilWriteMaskBack, jsret, s.thisObject() /*ctx*/); + s.rval() = jsret; + SE_HOLD_RETURN_VALUE(cobj->stencilWriteMaskBack, s.thisObject(), s.rval()); + return true; +} +SE_BIND_PROP_GET(js_assets_DepthStencilStateInfo_get_stencilWriteMaskBack) + +static bool js_assets_DepthStencilStateInfo_set_stencilWriteMaskBack(se::State& s) // NOLINT(readability-identifier-naming) +{ + const auto& args = s.args(); + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_assets_DepthStencilStateInfo_set_stencilWriteMaskBack : Invalid Native Object"); + + CC_UNUSED bool ok = true; + ok &= sevalue_to_native(args[0], &cobj->stencilWriteMaskBack, s.thisObject()); + SE_PRECONDITION2(ok, false, "js_assets_DepthStencilStateInfo_set_stencilWriteMaskBack : Error processing new value"); + return true; +} +SE_BIND_PROP_SET(js_assets_DepthStencilStateInfo_set_stencilWriteMaskBack) + +static bool js_assets_DepthStencilStateInfo_get_stencilFailOpBack(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_assets_DepthStencilStateInfo_get_stencilFailOpBack : Invalid Native Object"); + + CC_UNUSED bool ok = true; + se::Value jsret; + ok &= nativevalue_to_se(cobj->stencilFailOpBack, jsret, s.thisObject() /*ctx*/); + s.rval() = jsret; + SE_HOLD_RETURN_VALUE(cobj->stencilFailOpBack, s.thisObject(), s.rval()); + return true; +} +SE_BIND_PROP_GET(js_assets_DepthStencilStateInfo_get_stencilFailOpBack) + +static bool js_assets_DepthStencilStateInfo_set_stencilFailOpBack(se::State& s) // NOLINT(readability-identifier-naming) +{ + const auto& args = s.args(); + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_assets_DepthStencilStateInfo_set_stencilFailOpBack : Invalid Native Object"); + + CC_UNUSED bool ok = true; + ok &= sevalue_to_native(args[0], &cobj->stencilFailOpBack, s.thisObject()); + SE_PRECONDITION2(ok, false, "js_assets_DepthStencilStateInfo_set_stencilFailOpBack : Error processing new value"); + return true; +} +SE_BIND_PROP_SET(js_assets_DepthStencilStateInfo_set_stencilFailOpBack) + +static bool js_assets_DepthStencilStateInfo_get_stencilZFailOpBack(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_assets_DepthStencilStateInfo_get_stencilZFailOpBack : Invalid Native Object"); + + CC_UNUSED bool ok = true; + se::Value jsret; + ok &= nativevalue_to_se(cobj->stencilZFailOpBack, jsret, s.thisObject() /*ctx*/); + s.rval() = jsret; + SE_HOLD_RETURN_VALUE(cobj->stencilZFailOpBack, s.thisObject(), s.rval()); + return true; +} +SE_BIND_PROP_GET(js_assets_DepthStencilStateInfo_get_stencilZFailOpBack) + +static bool js_assets_DepthStencilStateInfo_set_stencilZFailOpBack(se::State& s) // NOLINT(readability-identifier-naming) +{ + const auto& args = s.args(); + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_assets_DepthStencilStateInfo_set_stencilZFailOpBack : Invalid Native Object"); + + CC_UNUSED bool ok = true; + ok &= sevalue_to_native(args[0], &cobj->stencilZFailOpBack, s.thisObject()); + SE_PRECONDITION2(ok, false, "js_assets_DepthStencilStateInfo_set_stencilZFailOpBack : Error processing new value"); + return true; +} +SE_BIND_PROP_SET(js_assets_DepthStencilStateInfo_set_stencilZFailOpBack) + +static bool js_assets_DepthStencilStateInfo_get_stencilPassOpBack(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_assets_DepthStencilStateInfo_get_stencilPassOpBack : Invalid Native Object"); + + CC_UNUSED bool ok = true; + se::Value jsret; + ok &= nativevalue_to_se(cobj->stencilPassOpBack, jsret, s.thisObject() /*ctx*/); + s.rval() = jsret; + SE_HOLD_RETURN_VALUE(cobj->stencilPassOpBack, s.thisObject(), s.rval()); + return true; +} +SE_BIND_PROP_GET(js_assets_DepthStencilStateInfo_get_stencilPassOpBack) + +static bool js_assets_DepthStencilStateInfo_set_stencilPassOpBack(se::State& s) // NOLINT(readability-identifier-naming) +{ + const auto& args = s.args(); + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_assets_DepthStencilStateInfo_set_stencilPassOpBack : Invalid Native Object"); + + CC_UNUSED bool ok = true; + ok &= sevalue_to_native(args[0], &cobj->stencilPassOpBack, s.thisObject()); + SE_PRECONDITION2(ok, false, "js_assets_DepthStencilStateInfo_set_stencilPassOpBack : Error processing new value"); + return true; +} +SE_BIND_PROP_SET(js_assets_DepthStencilStateInfo_set_stencilPassOpBack) + +static bool js_assets_DepthStencilStateInfo_get_stencilRefBack(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_assets_DepthStencilStateInfo_get_stencilRefBack : Invalid Native Object"); + + CC_UNUSED bool ok = true; + se::Value jsret; + ok &= nativevalue_to_se(cobj->stencilRefBack, jsret, s.thisObject() /*ctx*/); + s.rval() = jsret; + SE_HOLD_RETURN_VALUE(cobj->stencilRefBack, s.thisObject(), s.rval()); + return true; +} +SE_BIND_PROP_GET(js_assets_DepthStencilStateInfo_get_stencilRefBack) + +static bool js_assets_DepthStencilStateInfo_set_stencilRefBack(se::State& s) // NOLINT(readability-identifier-naming) +{ + const auto& args = s.args(); + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_assets_DepthStencilStateInfo_set_stencilRefBack : Invalid Native Object"); + + CC_UNUSED bool ok = true; + ok &= sevalue_to_native(args[0], &cobj->stencilRefBack, s.thisObject()); + SE_PRECONDITION2(ok, false, "js_assets_DepthStencilStateInfo_set_stencilRefBack : Error processing new value"); + return true; +} +SE_BIND_PROP_SET(js_assets_DepthStencilStateInfo_set_stencilRefBack) + + +template<> +bool sevalue_to_native(const se::Value &from, cc::DepthStencilStateInfo * to, se::Object *ctx) +{ + assert(from.isObject()); + se::Object *json = from.toObject(); + auto* data = reinterpret_cast(json->getPrivateData()); + if (data) { + *to = *data; + return true; + } + se::Value field; + bool ok = true; + json->getProperty("depthTest", &field, true); + if(!field.isNullOrUndefined()) { + ok &= sevalue_to_native(field, &(to->depthTest), ctx); + } + json->getProperty("depthWrite", &field, true); + if(!field.isNullOrUndefined()) { + ok &= sevalue_to_native(field, &(to->depthWrite), ctx); + } + json->getProperty("stencilTestFront", &field, true); + if(!field.isNullOrUndefined()) { + ok &= sevalue_to_native(field, &(to->stencilTestFront), ctx); + } + json->getProperty("stencilTestBack", &field, true); + if(!field.isNullOrUndefined()) { + ok &= sevalue_to_native(field, &(to->stencilTestBack), ctx); + } + json->getProperty("depthFunc", &field, true); + if(!field.isNullOrUndefined()) { + ok &= sevalue_to_native(field, &(to->depthFunc), ctx); + } + json->getProperty("stencilFuncFront", &field, true); + if(!field.isNullOrUndefined()) { + ok &= sevalue_to_native(field, &(to->stencilFuncFront), ctx); + } + json->getProperty("stencilReadMaskFront", &field, true); + if(!field.isNullOrUndefined()) { + ok &= sevalue_to_native(field, &(to->stencilReadMaskFront), ctx); + } + json->getProperty("stencilWriteMaskFront", &field, true); + if(!field.isNullOrUndefined()) { + ok &= sevalue_to_native(field, &(to->stencilWriteMaskFront), ctx); + } + json->getProperty("stencilFailOpFront", &field, true); + if(!field.isNullOrUndefined()) { + ok &= sevalue_to_native(field, &(to->stencilFailOpFront), ctx); + } + json->getProperty("stencilZFailOpFront", &field, true); + if(!field.isNullOrUndefined()) { + ok &= sevalue_to_native(field, &(to->stencilZFailOpFront), ctx); + } + json->getProperty("stencilPassOpFront", &field, true); + if(!field.isNullOrUndefined()) { + ok &= sevalue_to_native(field, &(to->stencilPassOpFront), ctx); + } + json->getProperty("stencilRefFront", &field, true); + if(!field.isNullOrUndefined()) { + ok &= sevalue_to_native(field, &(to->stencilRefFront), ctx); + } + json->getProperty("stencilFuncBack", &field, true); + if(!field.isNullOrUndefined()) { + ok &= sevalue_to_native(field, &(to->stencilFuncBack), ctx); + } + json->getProperty("stencilReadMaskBack", &field, true); + if(!field.isNullOrUndefined()) { + ok &= sevalue_to_native(field, &(to->stencilReadMaskBack), ctx); + } + json->getProperty("stencilWriteMaskBack", &field, true); + if(!field.isNullOrUndefined()) { + ok &= sevalue_to_native(field, &(to->stencilWriteMaskBack), ctx); + } + json->getProperty("stencilFailOpBack", &field, true); + if(!field.isNullOrUndefined()) { + ok &= sevalue_to_native(field, &(to->stencilFailOpBack), ctx); + } + json->getProperty("stencilZFailOpBack", &field, true); + if(!field.isNullOrUndefined()) { + ok &= sevalue_to_native(field, &(to->stencilZFailOpBack), ctx); + } + json->getProperty("stencilPassOpBack", &field, true); + if(!field.isNullOrUndefined()) { + ok &= sevalue_to_native(field, &(to->stencilPassOpBack), ctx); + } + json->getProperty("stencilRefBack", &field, true); + if(!field.isNullOrUndefined()) { + ok &= sevalue_to_native(field, &(to->stencilRefBack), ctx); + } + return ok; +} + +SE_DECLARE_FINALIZE_FUNC(js_cc_DepthStencilStateInfo_finalize) + +static bool js_assets_DepthStencilStateInfo_constructor(se::State& s) // NOLINT(readability-identifier-naming) +{ + CC_UNUSED bool ok = true; + const auto& args = s.args(); + size_t argc = args.size(); + + if(argc == 0) + { + auto *ptr = JSB_MAKE_PRIVATE_OBJECT(cc::DepthStencilStateInfo); + s.thisObject()->setPrivateObject(ptr); + return true; + } + + if(argc == 1 && args[0].isObject()) + { + se::Object *json = args[0].toObject(); + se::Value field; + auto *ptr = JSB_MAKE_PRIVATE_OBJECT(cc::DepthStencilStateInfo); + auto cobj = ptr->get(); + ok &= sevalue_to_native(args[0], cobj, s.thisObject()); + if(!ok) { + delete ptr; + SE_REPORT_ERROR("argument convertion error"); + return false; + } + s.thisObject()->setPrivateObject(ptr); + return true; + } + auto *ptr = JSB_MAKE_PRIVATE_OBJECT(cc::DepthStencilStateInfo); + auto cobj = ptr->get(); + if (argc > 0 && !args[0].isUndefined()) { + ok &= sevalue_to_native(args[0], &(cobj->depthTest), nullptr); + } + if (argc > 1 && !args[1].isUndefined()) { + ok &= sevalue_to_native(args[1], &(cobj->depthWrite), nullptr); + } + if (argc > 2 && !args[2].isUndefined()) { + ok &= sevalue_to_native(args[2], &(cobj->stencilTestFront), nullptr); + } + if (argc > 3 && !args[3].isUndefined()) { + ok &= sevalue_to_native(args[3], &(cobj->stencilTestBack), nullptr); + } + if (argc > 4 && !args[4].isUndefined()) { + ok &= sevalue_to_native(args[4], &(cobj->depthFunc), nullptr); + } + if (argc > 5 && !args[5].isUndefined()) { + ok &= sevalue_to_native(args[5], &(cobj->stencilFuncFront), nullptr); + } + if (argc > 6 && !args[6].isUndefined()) { + ok &= sevalue_to_native(args[6], &(cobj->stencilReadMaskFront), nullptr); + } + if (argc > 7 && !args[7].isUndefined()) { + ok &= sevalue_to_native(args[7], &(cobj->stencilWriteMaskFront), nullptr); + } + if (argc > 8 && !args[8].isUndefined()) { + ok &= sevalue_to_native(args[8], &(cobj->stencilFailOpFront), nullptr); + } + if (argc > 9 && !args[9].isUndefined()) { + ok &= sevalue_to_native(args[9], &(cobj->stencilZFailOpFront), nullptr); + } + if (argc > 10 && !args[10].isUndefined()) { + ok &= sevalue_to_native(args[10], &(cobj->stencilPassOpFront), nullptr); + } + if (argc > 11 && !args[11].isUndefined()) { + ok &= sevalue_to_native(args[11], &(cobj->stencilRefFront), nullptr); + } + if (argc > 12 && !args[12].isUndefined()) { + ok &= sevalue_to_native(args[12], &(cobj->stencilFuncBack), nullptr); + } + if (argc > 13 && !args[13].isUndefined()) { + ok &= sevalue_to_native(args[13], &(cobj->stencilReadMaskBack), nullptr); + } + if (argc > 14 && !args[14].isUndefined()) { + ok &= sevalue_to_native(args[14], &(cobj->stencilWriteMaskBack), nullptr); + } + if (argc > 15 && !args[15].isUndefined()) { + ok &= sevalue_to_native(args[15], &(cobj->stencilFailOpBack), nullptr); + } + if (argc > 16 && !args[16].isUndefined()) { + ok &= sevalue_to_native(args[16], &(cobj->stencilZFailOpBack), nullptr); + } + if (argc > 17 && !args[17].isUndefined()) { + ok &= sevalue_to_native(args[17], &(cobj->stencilPassOpBack), nullptr); + } + if (argc > 18 && !args[18].isUndefined()) { + ok &= sevalue_to_native(args[18], &(cobj->stencilRefBack), nullptr); + } + + if(!ok) { + delete ptr; + SE_REPORT_ERROR("Argument convertion error"); + return false; + } + s.thisObject()->setPrivateObject(ptr); + return true; +} +SE_BIND_CTOR(js_assets_DepthStencilStateInfo_constructor, __jsb_cc_DepthStencilStateInfo_class, js_cc_DepthStencilStateInfo_finalize) + +static bool js_cc_DepthStencilStateInfo_finalize(se::State& s) // NOLINT(readability-identifier-naming) +{ + return true; +} +SE_BIND_FINALIZE_FUNC(js_cc_DepthStencilStateInfo_finalize) + +bool js_register_assets_DepthStencilStateInfo(se::Object* obj) // NOLINT(readability-identifier-naming) +{ + auto* cls = se::Class::create("DepthStencilStateInfo", obj, nullptr, _SE(js_assets_DepthStencilStateInfo_constructor)); + + cls->defineProperty("depthTest", _SE(js_assets_DepthStencilStateInfo_get_depthTest), _SE(js_assets_DepthStencilStateInfo_set_depthTest)); + cls->defineProperty("depthWrite", _SE(js_assets_DepthStencilStateInfo_get_depthWrite), _SE(js_assets_DepthStencilStateInfo_set_depthWrite)); + cls->defineProperty("stencilTestFront", _SE(js_assets_DepthStencilStateInfo_get_stencilTestFront), _SE(js_assets_DepthStencilStateInfo_set_stencilTestFront)); + cls->defineProperty("stencilTestBack", _SE(js_assets_DepthStencilStateInfo_get_stencilTestBack), _SE(js_assets_DepthStencilStateInfo_set_stencilTestBack)); + cls->defineProperty("depthFunc", _SE(js_assets_DepthStencilStateInfo_get_depthFunc), _SE(js_assets_DepthStencilStateInfo_set_depthFunc)); + cls->defineProperty("stencilFuncFront", _SE(js_assets_DepthStencilStateInfo_get_stencilFuncFront), _SE(js_assets_DepthStencilStateInfo_set_stencilFuncFront)); + cls->defineProperty("stencilReadMaskFront", _SE(js_assets_DepthStencilStateInfo_get_stencilReadMaskFront), _SE(js_assets_DepthStencilStateInfo_set_stencilReadMaskFront)); + cls->defineProperty("stencilWriteMaskFront", _SE(js_assets_DepthStencilStateInfo_get_stencilWriteMaskFront), _SE(js_assets_DepthStencilStateInfo_set_stencilWriteMaskFront)); + cls->defineProperty("stencilFailOpFront", _SE(js_assets_DepthStencilStateInfo_get_stencilFailOpFront), _SE(js_assets_DepthStencilStateInfo_set_stencilFailOpFront)); + cls->defineProperty("stencilZFailOpFront", _SE(js_assets_DepthStencilStateInfo_get_stencilZFailOpFront), _SE(js_assets_DepthStencilStateInfo_set_stencilZFailOpFront)); + cls->defineProperty("stencilPassOpFront", _SE(js_assets_DepthStencilStateInfo_get_stencilPassOpFront), _SE(js_assets_DepthStencilStateInfo_set_stencilPassOpFront)); + cls->defineProperty("stencilRefFront", _SE(js_assets_DepthStencilStateInfo_get_stencilRefFront), _SE(js_assets_DepthStencilStateInfo_set_stencilRefFront)); + cls->defineProperty("stencilFuncBack", _SE(js_assets_DepthStencilStateInfo_get_stencilFuncBack), _SE(js_assets_DepthStencilStateInfo_set_stencilFuncBack)); + cls->defineProperty("stencilReadMaskBack", _SE(js_assets_DepthStencilStateInfo_get_stencilReadMaskBack), _SE(js_assets_DepthStencilStateInfo_set_stencilReadMaskBack)); + cls->defineProperty("stencilWriteMaskBack", _SE(js_assets_DepthStencilStateInfo_get_stencilWriteMaskBack), _SE(js_assets_DepthStencilStateInfo_set_stencilWriteMaskBack)); + cls->defineProperty("stencilFailOpBack", _SE(js_assets_DepthStencilStateInfo_get_stencilFailOpBack), _SE(js_assets_DepthStencilStateInfo_set_stencilFailOpBack)); + cls->defineProperty("stencilZFailOpBack", _SE(js_assets_DepthStencilStateInfo_get_stencilZFailOpBack), _SE(js_assets_DepthStencilStateInfo_set_stencilZFailOpBack)); + cls->defineProperty("stencilPassOpBack", _SE(js_assets_DepthStencilStateInfo_get_stencilPassOpBack), _SE(js_assets_DepthStencilStateInfo_set_stencilPassOpBack)); + cls->defineProperty("stencilRefBack", _SE(js_assets_DepthStencilStateInfo_get_stencilRefBack), _SE(js_assets_DepthStencilStateInfo_set_stencilRefBack)); + cls->defineFinalizeFunction(_SE(js_cc_DepthStencilStateInfo_finalize)); + cls->install(); + JSBClassType::registerClass(cls); + + __jsb_cc_DepthStencilStateInfo_proto = cls->getProto(); + __jsb_cc_DepthStencilStateInfo_class = cls; + + + se::ScriptEngine::getInstance()->clearException(); + return true; +} +se::Object* __jsb_cc_BlendTargetInfo_proto = nullptr; // NOLINT +se::Class* __jsb_cc_BlendTargetInfo_class = nullptr; // NOLINT + +static bool js_assets_BlendTargetInfo_get_blend(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_assets_BlendTargetInfo_get_blend : Invalid Native Object"); + + CC_UNUSED bool ok = true; + se::Value jsret; + ok &= nativevalue_to_se(cobj->blend, jsret, s.thisObject() /*ctx*/); + s.rval() = jsret; + SE_HOLD_RETURN_VALUE(cobj->blend, s.thisObject(), s.rval()); + return true; +} +SE_BIND_PROP_GET(js_assets_BlendTargetInfo_get_blend) + +static bool js_assets_BlendTargetInfo_set_blend(se::State& s) // NOLINT(readability-identifier-naming) +{ + const auto& args = s.args(); + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_assets_BlendTargetInfo_set_blend : Invalid Native Object"); + + CC_UNUSED bool ok = true; + ok &= sevalue_to_native(args[0], &cobj->blend, s.thisObject()); + SE_PRECONDITION2(ok, false, "js_assets_BlendTargetInfo_set_blend : Error processing new value"); + return true; +} +SE_BIND_PROP_SET(js_assets_BlendTargetInfo_set_blend) + +static bool js_assets_BlendTargetInfo_get_blendSrc(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_assets_BlendTargetInfo_get_blendSrc : Invalid Native Object"); + + CC_UNUSED bool ok = true; + se::Value jsret; + ok &= nativevalue_to_se(cobj->blendSrc, jsret, s.thisObject() /*ctx*/); + s.rval() = jsret; + SE_HOLD_RETURN_VALUE(cobj->blendSrc, s.thisObject(), s.rval()); + return true; +} +SE_BIND_PROP_GET(js_assets_BlendTargetInfo_get_blendSrc) + +static bool js_assets_BlendTargetInfo_set_blendSrc(se::State& s) // NOLINT(readability-identifier-naming) +{ + const auto& args = s.args(); + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_assets_BlendTargetInfo_set_blendSrc : Invalid Native Object"); + + CC_UNUSED bool ok = true; + ok &= sevalue_to_native(args[0], &cobj->blendSrc, s.thisObject()); + SE_PRECONDITION2(ok, false, "js_assets_BlendTargetInfo_set_blendSrc : Error processing new value"); + return true; +} +SE_BIND_PROP_SET(js_assets_BlendTargetInfo_set_blendSrc) + +static bool js_assets_BlendTargetInfo_get_blendDst(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_assets_BlendTargetInfo_get_blendDst : Invalid Native Object"); + + CC_UNUSED bool ok = true; + se::Value jsret; + ok &= nativevalue_to_se(cobj->blendDst, jsret, s.thisObject() /*ctx*/); + s.rval() = jsret; + SE_HOLD_RETURN_VALUE(cobj->blendDst, s.thisObject(), s.rval()); + return true; +} +SE_BIND_PROP_GET(js_assets_BlendTargetInfo_get_blendDst) + +static bool js_assets_BlendTargetInfo_set_blendDst(se::State& s) // NOLINT(readability-identifier-naming) +{ + const auto& args = s.args(); + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_assets_BlendTargetInfo_set_blendDst : Invalid Native Object"); + + CC_UNUSED bool ok = true; + ok &= sevalue_to_native(args[0], &cobj->blendDst, s.thisObject()); + SE_PRECONDITION2(ok, false, "js_assets_BlendTargetInfo_set_blendDst : Error processing new value"); + return true; +} +SE_BIND_PROP_SET(js_assets_BlendTargetInfo_set_blendDst) + +static bool js_assets_BlendTargetInfo_get_blendEq(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_assets_BlendTargetInfo_get_blendEq : Invalid Native Object"); + + CC_UNUSED bool ok = true; + se::Value jsret; + ok &= nativevalue_to_se(cobj->blendEq, jsret, s.thisObject() /*ctx*/); + s.rval() = jsret; + SE_HOLD_RETURN_VALUE(cobj->blendEq, s.thisObject(), s.rval()); + return true; +} +SE_BIND_PROP_GET(js_assets_BlendTargetInfo_get_blendEq) + +static bool js_assets_BlendTargetInfo_set_blendEq(se::State& s) // NOLINT(readability-identifier-naming) +{ + const auto& args = s.args(); + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_assets_BlendTargetInfo_set_blendEq : Invalid Native Object"); + + CC_UNUSED bool ok = true; + ok &= sevalue_to_native(args[0], &cobj->blendEq, s.thisObject()); + SE_PRECONDITION2(ok, false, "js_assets_BlendTargetInfo_set_blendEq : Error processing new value"); + return true; +} +SE_BIND_PROP_SET(js_assets_BlendTargetInfo_set_blendEq) + +static bool js_assets_BlendTargetInfo_get_blendSrcAlpha(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_assets_BlendTargetInfo_get_blendSrcAlpha : Invalid Native Object"); + + CC_UNUSED bool ok = true; + se::Value jsret; + ok &= nativevalue_to_se(cobj->blendSrcAlpha, jsret, s.thisObject() /*ctx*/); + s.rval() = jsret; + SE_HOLD_RETURN_VALUE(cobj->blendSrcAlpha, s.thisObject(), s.rval()); + return true; +} +SE_BIND_PROP_GET(js_assets_BlendTargetInfo_get_blendSrcAlpha) + +static bool js_assets_BlendTargetInfo_set_blendSrcAlpha(se::State& s) // NOLINT(readability-identifier-naming) +{ + const auto& args = s.args(); + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_assets_BlendTargetInfo_set_blendSrcAlpha : Invalid Native Object"); + + CC_UNUSED bool ok = true; + ok &= sevalue_to_native(args[0], &cobj->blendSrcAlpha, s.thisObject()); + SE_PRECONDITION2(ok, false, "js_assets_BlendTargetInfo_set_blendSrcAlpha : Error processing new value"); + return true; +} +SE_BIND_PROP_SET(js_assets_BlendTargetInfo_set_blendSrcAlpha) + +static bool js_assets_BlendTargetInfo_get_blendDstAlpha(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_assets_BlendTargetInfo_get_blendDstAlpha : Invalid Native Object"); + + CC_UNUSED bool ok = true; + se::Value jsret; + ok &= nativevalue_to_se(cobj->blendDstAlpha, jsret, s.thisObject() /*ctx*/); + s.rval() = jsret; + SE_HOLD_RETURN_VALUE(cobj->blendDstAlpha, s.thisObject(), s.rval()); + return true; +} +SE_BIND_PROP_GET(js_assets_BlendTargetInfo_get_blendDstAlpha) + +static bool js_assets_BlendTargetInfo_set_blendDstAlpha(se::State& s) // NOLINT(readability-identifier-naming) +{ + const auto& args = s.args(); + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_assets_BlendTargetInfo_set_blendDstAlpha : Invalid Native Object"); + + CC_UNUSED bool ok = true; + ok &= sevalue_to_native(args[0], &cobj->blendDstAlpha, s.thisObject()); + SE_PRECONDITION2(ok, false, "js_assets_BlendTargetInfo_set_blendDstAlpha : Error processing new value"); + return true; +} +SE_BIND_PROP_SET(js_assets_BlendTargetInfo_set_blendDstAlpha) + +static bool js_assets_BlendTargetInfo_get_blendAlphaEq(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_assets_BlendTargetInfo_get_blendAlphaEq : Invalid Native Object"); + + CC_UNUSED bool ok = true; + se::Value jsret; + ok &= nativevalue_to_se(cobj->blendAlphaEq, jsret, s.thisObject() /*ctx*/); + s.rval() = jsret; + SE_HOLD_RETURN_VALUE(cobj->blendAlphaEq, s.thisObject(), s.rval()); + return true; +} +SE_BIND_PROP_GET(js_assets_BlendTargetInfo_get_blendAlphaEq) + +static bool js_assets_BlendTargetInfo_set_blendAlphaEq(se::State& s) // NOLINT(readability-identifier-naming) +{ + const auto& args = s.args(); + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_assets_BlendTargetInfo_set_blendAlphaEq : Invalid Native Object"); + + CC_UNUSED bool ok = true; + ok &= sevalue_to_native(args[0], &cobj->blendAlphaEq, s.thisObject()); + SE_PRECONDITION2(ok, false, "js_assets_BlendTargetInfo_set_blendAlphaEq : Error processing new value"); + return true; +} +SE_BIND_PROP_SET(js_assets_BlendTargetInfo_set_blendAlphaEq) + +static bool js_assets_BlendTargetInfo_get_blendColorMask(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_assets_BlendTargetInfo_get_blendColorMask : Invalid Native Object"); + + CC_UNUSED bool ok = true; + se::Value jsret; + ok &= nativevalue_to_se(cobj->blendColorMask, jsret, s.thisObject() /*ctx*/); + s.rval() = jsret; + SE_HOLD_RETURN_VALUE(cobj->blendColorMask, s.thisObject(), s.rval()); + return true; +} +SE_BIND_PROP_GET(js_assets_BlendTargetInfo_get_blendColorMask) + +static bool js_assets_BlendTargetInfo_set_blendColorMask(se::State& s) // NOLINT(readability-identifier-naming) +{ + const auto& args = s.args(); + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_assets_BlendTargetInfo_set_blendColorMask : Invalid Native Object"); + + CC_UNUSED bool ok = true; + ok &= sevalue_to_native(args[0], &cobj->blendColorMask, s.thisObject()); + SE_PRECONDITION2(ok, false, "js_assets_BlendTargetInfo_set_blendColorMask : Error processing new value"); + return true; +} +SE_BIND_PROP_SET(js_assets_BlendTargetInfo_set_blendColorMask) + + +template<> +bool sevalue_to_native(const se::Value &from, cc::BlendTargetInfo * to, se::Object *ctx) +{ + assert(from.isObject()); + se::Object *json = from.toObject(); + auto* data = reinterpret_cast(json->getPrivateData()); + if (data) { + *to = *data; + return true; + } + se::Value field; + bool ok = true; + json->getProperty("blend", &field, true); + if(!field.isNullOrUndefined()) { + ok &= sevalue_to_native(field, &(to->blend), ctx); + } + json->getProperty("blendSrc", &field, true); + if(!field.isNullOrUndefined()) { + ok &= sevalue_to_native(field, &(to->blendSrc), ctx); + } + json->getProperty("blendDst", &field, true); + if(!field.isNullOrUndefined()) { + ok &= sevalue_to_native(field, &(to->blendDst), ctx); + } + json->getProperty("blendEq", &field, true); + if(!field.isNullOrUndefined()) { + ok &= sevalue_to_native(field, &(to->blendEq), ctx); + } + json->getProperty("blendSrcAlpha", &field, true); + if(!field.isNullOrUndefined()) { + ok &= sevalue_to_native(field, &(to->blendSrcAlpha), ctx); + } + json->getProperty("blendDstAlpha", &field, true); + if(!field.isNullOrUndefined()) { + ok &= sevalue_to_native(field, &(to->blendDstAlpha), ctx); + } + json->getProperty("blendAlphaEq", &field, true); + if(!field.isNullOrUndefined()) { + ok &= sevalue_to_native(field, &(to->blendAlphaEq), ctx); + } + json->getProperty("blendColorMask", &field, true); + if(!field.isNullOrUndefined()) { + ok &= sevalue_to_native(field, &(to->blendColorMask), ctx); + } + return ok; +} + +SE_DECLARE_FINALIZE_FUNC(js_cc_BlendTargetInfo_finalize) + +static bool js_assets_BlendTargetInfo_constructor(se::State& s) // NOLINT(readability-identifier-naming) +{ + CC_UNUSED bool ok = true; + const auto& args = s.args(); + size_t argc = args.size(); + + if(argc == 0) + { + auto *ptr = JSB_MAKE_PRIVATE_OBJECT(cc::BlendTargetInfo); + s.thisObject()->setPrivateObject(ptr); + return true; + } + + if(argc == 1 && args[0].isObject()) + { + se::Object *json = args[0].toObject(); + se::Value field; + auto *ptr = JSB_MAKE_PRIVATE_OBJECT(cc::BlendTargetInfo); + auto cobj = ptr->get(); + ok &= sevalue_to_native(args[0], cobj, s.thisObject()); + if(!ok) { + delete ptr; + SE_REPORT_ERROR("argument convertion error"); + return false; + } + s.thisObject()->setPrivateObject(ptr); + return true; + } + auto *ptr = JSB_MAKE_PRIVATE_OBJECT(cc::BlendTargetInfo); + auto cobj = ptr->get(); + if (argc > 0 && !args[0].isUndefined()) { + ok &= sevalue_to_native(args[0], &(cobj->blend), nullptr); + } + if (argc > 1 && !args[1].isUndefined()) { + ok &= sevalue_to_native(args[1], &(cobj->blendSrc), nullptr); + } + if (argc > 2 && !args[2].isUndefined()) { + ok &= sevalue_to_native(args[2], &(cobj->blendDst), nullptr); + } + if (argc > 3 && !args[3].isUndefined()) { + ok &= sevalue_to_native(args[3], &(cobj->blendEq), nullptr); + } + if (argc > 4 && !args[4].isUndefined()) { + ok &= sevalue_to_native(args[4], &(cobj->blendSrcAlpha), nullptr); + } + if (argc > 5 && !args[5].isUndefined()) { + ok &= sevalue_to_native(args[5], &(cobj->blendDstAlpha), nullptr); + } + if (argc > 6 && !args[6].isUndefined()) { + ok &= sevalue_to_native(args[6], &(cobj->blendAlphaEq), nullptr); + } + if (argc > 7 && !args[7].isUndefined()) { + ok &= sevalue_to_native(args[7], &(cobj->blendColorMask), nullptr); + } + + if(!ok) { + delete ptr; + SE_REPORT_ERROR("Argument convertion error"); + return false; + } + s.thisObject()->setPrivateObject(ptr); + return true; +} +SE_BIND_CTOR(js_assets_BlendTargetInfo_constructor, __jsb_cc_BlendTargetInfo_class, js_cc_BlendTargetInfo_finalize) + +static bool js_cc_BlendTargetInfo_finalize(se::State& s) // NOLINT(readability-identifier-naming) +{ + return true; +} +SE_BIND_FINALIZE_FUNC(js_cc_BlendTargetInfo_finalize) + +bool js_register_assets_BlendTargetInfo(se::Object* obj) // NOLINT(readability-identifier-naming) +{ + auto* cls = se::Class::create("BlendTargetInfo", obj, nullptr, _SE(js_assets_BlendTargetInfo_constructor)); + + cls->defineProperty("blend", _SE(js_assets_BlendTargetInfo_get_blend), _SE(js_assets_BlendTargetInfo_set_blend)); + cls->defineProperty("blendSrc", _SE(js_assets_BlendTargetInfo_get_blendSrc), _SE(js_assets_BlendTargetInfo_set_blendSrc)); + cls->defineProperty("blendDst", _SE(js_assets_BlendTargetInfo_get_blendDst), _SE(js_assets_BlendTargetInfo_set_blendDst)); + cls->defineProperty("blendEq", _SE(js_assets_BlendTargetInfo_get_blendEq), _SE(js_assets_BlendTargetInfo_set_blendEq)); + cls->defineProperty("blendSrcAlpha", _SE(js_assets_BlendTargetInfo_get_blendSrcAlpha), _SE(js_assets_BlendTargetInfo_set_blendSrcAlpha)); + cls->defineProperty("blendDstAlpha", _SE(js_assets_BlendTargetInfo_get_blendDstAlpha), _SE(js_assets_BlendTargetInfo_set_blendDstAlpha)); + cls->defineProperty("blendAlphaEq", _SE(js_assets_BlendTargetInfo_get_blendAlphaEq), _SE(js_assets_BlendTargetInfo_set_blendAlphaEq)); + cls->defineProperty("blendColorMask", _SE(js_assets_BlendTargetInfo_get_blendColorMask), _SE(js_assets_BlendTargetInfo_set_blendColorMask)); + cls->defineFinalizeFunction(_SE(js_cc_BlendTargetInfo_finalize)); + cls->install(); + JSBClassType::registerClass(cls); + + __jsb_cc_BlendTargetInfo_proto = cls->getProto(); + __jsb_cc_BlendTargetInfo_class = cls; + + + se::ScriptEngine::getInstance()->clearException(); + return true; +} +se::Object* __jsb_cc_BlendStateInfo_proto = nullptr; // NOLINT +se::Class* __jsb_cc_BlendStateInfo_class = nullptr; // NOLINT + +static bool js_assets_BlendStateInfo_get_isA2C(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_assets_BlendStateInfo_get_isA2C : Invalid Native Object"); + + CC_UNUSED bool ok = true; + se::Value jsret; + ok &= nativevalue_to_se(cobj->isA2C, jsret, s.thisObject() /*ctx*/); + s.rval() = jsret; + SE_HOLD_RETURN_VALUE(cobj->isA2C, s.thisObject(), s.rval()); + return true; +} +SE_BIND_PROP_GET(js_assets_BlendStateInfo_get_isA2C) + +static bool js_assets_BlendStateInfo_set_isA2C(se::State& s) // NOLINT(readability-identifier-naming) +{ + const auto& args = s.args(); + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_assets_BlendStateInfo_set_isA2C : Invalid Native Object"); + + CC_UNUSED bool ok = true; + ok &= sevalue_to_native(args[0], &cobj->isA2C, s.thisObject()); + SE_PRECONDITION2(ok, false, "js_assets_BlendStateInfo_set_isA2C : Error processing new value"); + return true; +} +SE_BIND_PROP_SET(js_assets_BlendStateInfo_set_isA2C) + +static bool js_assets_BlendStateInfo_get_isIndepend(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_assets_BlendStateInfo_get_isIndepend : Invalid Native Object"); + + CC_UNUSED bool ok = true; + se::Value jsret; + ok &= nativevalue_to_se(cobj->isIndepend, jsret, s.thisObject() /*ctx*/); + s.rval() = jsret; + SE_HOLD_RETURN_VALUE(cobj->isIndepend, s.thisObject(), s.rval()); + return true; +} +SE_BIND_PROP_GET(js_assets_BlendStateInfo_get_isIndepend) + +static bool js_assets_BlendStateInfo_set_isIndepend(se::State& s) // NOLINT(readability-identifier-naming) +{ + const auto& args = s.args(); + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_assets_BlendStateInfo_set_isIndepend : Invalid Native Object"); + + CC_UNUSED bool ok = true; + ok &= sevalue_to_native(args[0], &cobj->isIndepend, s.thisObject()); + SE_PRECONDITION2(ok, false, "js_assets_BlendStateInfo_set_isIndepend : Error processing new value"); + return true; +} +SE_BIND_PROP_SET(js_assets_BlendStateInfo_set_isIndepend) + +static bool js_assets_BlendStateInfo_get_blendColor(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_assets_BlendStateInfo_get_blendColor : Invalid Native Object"); + + CC_UNUSED bool ok = true; + se::Value jsret; + ok &= nativevalue_to_se(cobj->blendColor, jsret, s.thisObject() /*ctx*/); + s.rval() = jsret; + SE_HOLD_RETURN_VALUE(cobj->blendColor, s.thisObject(), s.rval()); + return true; +} +SE_BIND_PROP_GET(js_assets_BlendStateInfo_get_blendColor) + +static bool js_assets_BlendStateInfo_set_blendColor(se::State& s) // NOLINT(readability-identifier-naming) +{ + const auto& args = s.args(); + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_assets_BlendStateInfo_set_blendColor : Invalid Native Object"); + + CC_UNUSED bool ok = true; + ok &= sevalue_to_native(args[0], &cobj->blendColor, s.thisObject()); + SE_PRECONDITION2(ok, false, "js_assets_BlendStateInfo_set_blendColor : Error processing new value"); + return true; +} +SE_BIND_PROP_SET(js_assets_BlendStateInfo_set_blendColor) + +static bool js_assets_BlendStateInfo_get_targets(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_assets_BlendStateInfo_get_targets : Invalid Native Object"); + + CC_UNUSED bool ok = true; + se::Value jsret; + ok &= nativevalue_to_se(cobj->targets, jsret, s.thisObject() /*ctx*/); + s.rval() = jsret; + SE_HOLD_RETURN_VALUE(cobj->targets, s.thisObject(), s.rval()); + return true; +} +SE_BIND_PROP_GET(js_assets_BlendStateInfo_get_targets) + +static bool js_assets_BlendStateInfo_set_targets(se::State& s) // NOLINT(readability-identifier-naming) +{ + const auto& args = s.args(); + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_assets_BlendStateInfo_set_targets : Invalid Native Object"); + + CC_UNUSED bool ok = true; + ok &= sevalue_to_native(args[0], &cobj->targets, s.thisObject()); + SE_PRECONDITION2(ok, false, "js_assets_BlendStateInfo_set_targets : Error processing new value"); + return true; +} +SE_BIND_PROP_SET(js_assets_BlendStateInfo_set_targets) + + +template<> +bool sevalue_to_native(const se::Value &from, cc::BlendStateInfo * to, se::Object *ctx) +{ + assert(from.isObject()); + se::Object *json = from.toObject(); + auto* data = reinterpret_cast(json->getPrivateData()); + if (data) { + *to = *data; + return true; + } + se::Value field; + bool ok = true; + json->getProperty("isA2C", &field, true); + if(!field.isNullOrUndefined()) { + ok &= sevalue_to_native(field, &(to->isA2C), ctx); + } + json->getProperty("isIndepend", &field, true); + if(!field.isNullOrUndefined()) { + ok &= sevalue_to_native(field, &(to->isIndepend), ctx); + } + json->getProperty("blendColor", &field, true); + if(!field.isNullOrUndefined()) { + ok &= sevalue_to_native(field, &(to->blendColor), ctx); + } + json->getProperty("targets", &field, true); + if(!field.isNullOrUndefined()) { + ok &= sevalue_to_native(field, &(to->targets), ctx); + } + return ok; +} + +SE_DECLARE_FINALIZE_FUNC(js_cc_BlendStateInfo_finalize) + +static bool js_assets_BlendStateInfo_constructor(se::State& s) // NOLINT(readability-identifier-naming) +{ + CC_UNUSED bool ok = true; + const auto& args = s.args(); + size_t argc = args.size(); + + if(argc == 0) + { + auto *ptr = JSB_MAKE_PRIVATE_OBJECT(cc::BlendStateInfo); + s.thisObject()->setPrivateObject(ptr); + return true; + } + + if(argc == 1 && args[0].isObject()) + { + se::Object *json = args[0].toObject(); + se::Value field; + auto *ptr = JSB_MAKE_PRIVATE_OBJECT(cc::BlendStateInfo); + auto cobj = ptr->get(); + ok &= sevalue_to_native(args[0], cobj, s.thisObject()); + if(!ok) { + delete ptr; + SE_REPORT_ERROR("argument convertion error"); + return false; + } + s.thisObject()->setPrivateObject(ptr); + return true; + } + auto *ptr = JSB_MAKE_PRIVATE_OBJECT(cc::BlendStateInfo); + auto cobj = ptr->get(); + if (argc > 0 && !args[0].isUndefined()) { + ok &= sevalue_to_native(args[0], &(cobj->isA2C), nullptr); + } + if (argc > 1 && !args[1].isUndefined()) { + ok &= sevalue_to_native(args[1], &(cobj->isIndepend), nullptr); + } + if (argc > 2 && !args[2].isUndefined()) { + ok &= sevalue_to_native(args[2], &(cobj->blendColor), nullptr); + } + if (argc > 3 && !args[3].isUndefined()) { + ok &= sevalue_to_native(args[3], &(cobj->targets), nullptr); + } + + if(!ok) { + delete ptr; + SE_REPORT_ERROR("Argument convertion error"); + return false; + } + s.thisObject()->setPrivateObject(ptr); + return true; +} +SE_BIND_CTOR(js_assets_BlendStateInfo_constructor, __jsb_cc_BlendStateInfo_class, js_cc_BlendStateInfo_finalize) + +static bool js_cc_BlendStateInfo_finalize(se::State& s) // NOLINT(readability-identifier-naming) +{ + return true; +} +SE_BIND_FINALIZE_FUNC(js_cc_BlendStateInfo_finalize) + +bool js_register_assets_BlendStateInfo(se::Object* obj) // NOLINT(readability-identifier-naming) +{ + auto* cls = se::Class::create("BlendStateInfo", obj, nullptr, _SE(js_assets_BlendStateInfo_constructor)); + + cls->defineProperty("isA2C", _SE(js_assets_BlendStateInfo_get_isA2C), _SE(js_assets_BlendStateInfo_set_isA2C)); + cls->defineProperty("isIndepend", _SE(js_assets_BlendStateInfo_get_isIndepend), _SE(js_assets_BlendStateInfo_set_isIndepend)); + cls->defineProperty("blendColor", _SE(js_assets_BlendStateInfo_get_blendColor), _SE(js_assets_BlendStateInfo_set_blendColor)); + cls->defineProperty("targets", _SE(js_assets_BlendStateInfo_get_targets), _SE(js_assets_BlendStateInfo_set_targets)); + cls->defineFinalizeFunction(_SE(js_cc_BlendStateInfo_finalize)); + cls->install(); + JSBClassType::registerClass(cls); + + __jsb_cc_BlendStateInfo_proto = cls->getProto(); + __jsb_cc_BlendStateInfo_class = cls; + + + se::ScriptEngine::getInstance()->clearException(); + return true; +} +se::Object* __jsb_cc_IPassStates_proto = nullptr; // NOLINT +se::Class* __jsb_cc_IPassStates_class = nullptr; // NOLINT + +static bool js_assets_IPassStates_overrides(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_assets_IPassStates_overrides : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 1) { + HolderType arg0 = {}; + ok &= sevalue_to_native(args[0], &arg0, s.thisObject()); + SE_PRECONDITION2(ok, false, "js_assets_IPassStates_overrides : Error processing arguments"); + cobj->overrides(arg0.value()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 1); + return false; +} +SE_BIND_FUNC(js_assets_IPassStates_overrides) + +static bool js_assets_IPassStates_get_priority(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_assets_IPassStates_get_priority : Invalid Native Object"); + + CC_UNUSED bool ok = true; + se::Value jsret; + ok &= nativevalue_to_se(cobj->priority, jsret, s.thisObject() /*ctx*/); + s.rval() = jsret; + SE_HOLD_RETURN_VALUE(cobj->priority, s.thisObject(), s.rval()); + return true; +} +SE_BIND_PROP_GET(js_assets_IPassStates_get_priority) + +static bool js_assets_IPassStates_set_priority(se::State& s) // NOLINT(readability-identifier-naming) +{ + const auto& args = s.args(); + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_assets_IPassStates_set_priority : Invalid Native Object"); + + CC_UNUSED bool ok = true; + ok &= sevalue_to_native(args[0], &cobj->priority, s.thisObject()); + SE_PRECONDITION2(ok, false, "js_assets_IPassStates_set_priority : Error processing new value"); + return true; +} +SE_BIND_PROP_SET(js_assets_IPassStates_set_priority) + +static bool js_assets_IPassStates_get_primitive(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_assets_IPassStates_get_primitive : Invalid Native Object"); + + CC_UNUSED bool ok = true; + se::Value jsret; + ok &= nativevalue_to_se(cobj->primitive, jsret, s.thisObject() /*ctx*/); + s.rval() = jsret; + SE_HOLD_RETURN_VALUE(cobj->primitive, s.thisObject(), s.rval()); + return true; +} +SE_BIND_PROP_GET(js_assets_IPassStates_get_primitive) + +static bool js_assets_IPassStates_set_primitive(se::State& s) // NOLINT(readability-identifier-naming) +{ + const auto& args = s.args(); + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_assets_IPassStates_set_primitive : Invalid Native Object"); + + CC_UNUSED bool ok = true; + ok &= sevalue_to_native(args[0], &cobj->primitive, s.thisObject()); + SE_PRECONDITION2(ok, false, "js_assets_IPassStates_set_primitive : Error processing new value"); + return true; +} +SE_BIND_PROP_SET(js_assets_IPassStates_set_primitive) + +static bool js_assets_IPassStates_get_stage(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_assets_IPassStates_get_stage : Invalid Native Object"); + + CC_UNUSED bool ok = true; + se::Value jsret; + ok &= nativevalue_to_se(cobj->stage, jsret, s.thisObject() /*ctx*/); + s.rval() = jsret; + SE_HOLD_RETURN_VALUE(cobj->stage, s.thisObject(), s.rval()); + return true; +} +SE_BIND_PROP_GET(js_assets_IPassStates_get_stage) + +static bool js_assets_IPassStates_set_stage(se::State& s) // NOLINT(readability-identifier-naming) +{ + const auto& args = s.args(); + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_assets_IPassStates_set_stage : Invalid Native Object"); + + CC_UNUSED bool ok = true; + ok &= sevalue_to_native(args[0], &cobj->stage, s.thisObject()); + SE_PRECONDITION2(ok, false, "js_assets_IPassStates_set_stage : Error processing new value"); + return true; +} +SE_BIND_PROP_SET(js_assets_IPassStates_set_stage) + +static bool js_assets_IPassStates_get_rasterizerState(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_assets_IPassStates_get_rasterizerState : Invalid Native Object"); + + CC_UNUSED bool ok = true; + se::Value jsret; + ok &= nativevalue_to_se(cobj->rasterizerState, jsret, s.thisObject() /*ctx*/); + s.rval() = jsret; + SE_HOLD_RETURN_VALUE(cobj->rasterizerState, s.thisObject(), s.rval()); + return true; +} +SE_BIND_PROP_GET(js_assets_IPassStates_get_rasterizerState) + +static bool js_assets_IPassStates_set_rasterizerState(se::State& s) // NOLINT(readability-identifier-naming) +{ + const auto& args = s.args(); + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_assets_IPassStates_set_rasterizerState : Invalid Native Object"); + + CC_UNUSED bool ok = true; + ok &= sevalue_to_native(args[0], &cobj->rasterizerState, s.thisObject()); + SE_PRECONDITION2(ok, false, "js_assets_IPassStates_set_rasterizerState : Error processing new value"); + return true; +} +SE_BIND_PROP_SET(js_assets_IPassStates_set_rasterizerState) + +static bool js_assets_IPassStates_get_depthStencilState(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_assets_IPassStates_get_depthStencilState : Invalid Native Object"); + + CC_UNUSED bool ok = true; + se::Value jsret; + ok &= nativevalue_to_se(cobj->depthStencilState, jsret, s.thisObject() /*ctx*/); + s.rval() = jsret; + SE_HOLD_RETURN_VALUE(cobj->depthStencilState, s.thisObject(), s.rval()); + return true; +} +SE_BIND_PROP_GET(js_assets_IPassStates_get_depthStencilState) + +static bool js_assets_IPassStates_set_depthStencilState(se::State& s) // NOLINT(readability-identifier-naming) +{ + const auto& args = s.args(); + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_assets_IPassStates_set_depthStencilState : Invalid Native Object"); + + CC_UNUSED bool ok = true; + ok &= sevalue_to_native(args[0], &cobj->depthStencilState, s.thisObject()); + SE_PRECONDITION2(ok, false, "js_assets_IPassStates_set_depthStencilState : Error processing new value"); + return true; +} +SE_BIND_PROP_SET(js_assets_IPassStates_set_depthStencilState) + +static bool js_assets_IPassStates_get_blendState(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_assets_IPassStates_get_blendState : Invalid Native Object"); + + CC_UNUSED bool ok = true; + se::Value jsret; + ok &= nativevalue_to_se(cobj->blendState, jsret, s.thisObject() /*ctx*/); + s.rval() = jsret; + SE_HOLD_RETURN_VALUE(cobj->blendState, s.thisObject(), s.rval()); + return true; +} +SE_BIND_PROP_GET(js_assets_IPassStates_get_blendState) + +static bool js_assets_IPassStates_set_blendState(se::State& s) // NOLINT(readability-identifier-naming) +{ + const auto& args = s.args(); + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_assets_IPassStates_set_blendState : Invalid Native Object"); + + CC_UNUSED bool ok = true; + ok &= sevalue_to_native(args[0], &cobj->blendState, s.thisObject()); + SE_PRECONDITION2(ok, false, "js_assets_IPassStates_set_blendState : Error processing new value"); + return true; +} +SE_BIND_PROP_SET(js_assets_IPassStates_set_blendState) + +static bool js_assets_IPassStates_get_dynamicStates(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_assets_IPassStates_get_dynamicStates : Invalid Native Object"); + + CC_UNUSED bool ok = true; + se::Value jsret; + ok &= nativevalue_to_se(cobj->dynamicStates, jsret, s.thisObject() /*ctx*/); + s.rval() = jsret; + SE_HOLD_RETURN_VALUE(cobj->dynamicStates, s.thisObject(), s.rval()); + return true; +} +SE_BIND_PROP_GET(js_assets_IPassStates_get_dynamicStates) + +static bool js_assets_IPassStates_set_dynamicStates(se::State& s) // NOLINT(readability-identifier-naming) +{ + const auto& args = s.args(); + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_assets_IPassStates_set_dynamicStates : Invalid Native Object"); + + CC_UNUSED bool ok = true; + ok &= sevalue_to_native(args[0], &cobj->dynamicStates, s.thisObject()); + SE_PRECONDITION2(ok, false, "js_assets_IPassStates_set_dynamicStates : Error processing new value"); + return true; +} +SE_BIND_PROP_SET(js_assets_IPassStates_set_dynamicStates) + +static bool js_assets_IPassStates_get_phase(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_assets_IPassStates_get_phase : Invalid Native Object"); + + CC_UNUSED bool ok = true; + se::Value jsret; + ok &= nativevalue_to_se(cobj->phase, jsret, s.thisObject() /*ctx*/); + s.rval() = jsret; + SE_HOLD_RETURN_VALUE(cobj->phase, s.thisObject(), s.rval()); + return true; +} +SE_BIND_PROP_GET(js_assets_IPassStates_get_phase) + +static bool js_assets_IPassStates_set_phase(se::State& s) // NOLINT(readability-identifier-naming) +{ + const auto& args = s.args(); + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_assets_IPassStates_set_phase : Invalid Native Object"); + + CC_UNUSED bool ok = true; + ok &= sevalue_to_native(args[0], &cobj->phase, s.thisObject()); + SE_PRECONDITION2(ok, false, "js_assets_IPassStates_set_phase : Error processing new value"); + return true; +} +SE_BIND_PROP_SET(js_assets_IPassStates_set_phase) + + +template<> +bool sevalue_to_native(const se::Value &from, cc::IPassStates * to, se::Object *ctx) +{ + assert(from.isObject()); + se::Object *json = from.toObject(); + auto* data = reinterpret_cast(json->getPrivateData()); + if (data) { + *to = *data; + return true; + } + se::Value field; + bool ok = true; + json->getProperty("priority", &field, true); + if(!field.isNullOrUndefined()) { + ok &= sevalue_to_native(field, &(to->priority), ctx); + } + json->getProperty("primitive", &field, true); + if(!field.isNullOrUndefined()) { + ok &= sevalue_to_native(field, &(to->primitive), ctx); + } + json->getProperty("stage", &field, true); + if(!field.isNullOrUndefined()) { + ok &= sevalue_to_native(field, &(to->stage), ctx); + } + json->getProperty("rasterizerState", &field, true); + if(!field.isNullOrUndefined()) { + ok &= sevalue_to_native(field, &(to->rasterizerState), ctx); + } + json->getProperty("depthStencilState", &field, true); + if(!field.isNullOrUndefined()) { + ok &= sevalue_to_native(field, &(to->depthStencilState), ctx); + } + json->getProperty("blendState", &field, true); + if(!field.isNullOrUndefined()) { + ok &= sevalue_to_native(field, &(to->blendState), ctx); + } + json->getProperty("dynamicStates", &field, true); + if(!field.isNullOrUndefined()) { + ok &= sevalue_to_native(field, &(to->dynamicStates), ctx); + } + json->getProperty("phase", &field, true); + if(!field.isNullOrUndefined()) { + ok &= sevalue_to_native(field, &(to->phase), ctx); + } + return ok; +} + +SE_DECLARE_FINALIZE_FUNC(js_cc_IPassStates_finalize) + +static bool js_assets_IPassStates_constructor(se::State& s) // NOLINT(readability-identifier-naming) +{ + CC_UNUSED bool ok = true; + const auto& args = s.args(); + size_t argc = args.size(); + + if(argc == 0) + { + auto *ptr = JSB_MAKE_PRIVATE_OBJECT(cc::IPassStates); + s.thisObject()->setPrivateObject(ptr); + return true; + } + + if(argc == 1 && args[0].isObject()) + { + se::Object *json = args[0].toObject(); + se::Value field; + auto *ptr = JSB_MAKE_PRIVATE_OBJECT(cc::IPassStates); + auto cobj = ptr->get(); + ok &= sevalue_to_native(args[0], cobj, s.thisObject()); + if(!ok) { + delete ptr; + SE_REPORT_ERROR("argument convertion error"); + return false; + } + s.thisObject()->setPrivateObject(ptr); + return true; + } + auto *ptr = JSB_MAKE_PRIVATE_OBJECT(cc::IPassStates); + auto cobj = ptr->get(); + if (argc > 0 && !args[0].isUndefined()) { + ok &= sevalue_to_native(args[0], &(cobj->priority), nullptr); + } + if (argc > 1 && !args[1].isUndefined()) { + ok &= sevalue_to_native(args[1], &(cobj->primitive), nullptr); + } + if (argc > 2 && !args[2].isUndefined()) { + ok &= sevalue_to_native(args[2], &(cobj->stage), nullptr); + } + if (argc > 3 && !args[3].isUndefined()) { + ok &= sevalue_to_native(args[3], &(cobj->rasterizerState), nullptr); + } + if (argc > 4 && !args[4].isUndefined()) { + ok &= sevalue_to_native(args[4], &(cobj->depthStencilState), nullptr); + } + if (argc > 5 && !args[5].isUndefined()) { + ok &= sevalue_to_native(args[5], &(cobj->blendState), nullptr); + } + if (argc > 6 && !args[6].isUndefined()) { + ok &= sevalue_to_native(args[6], &(cobj->dynamicStates), nullptr); + } + if (argc > 7 && !args[7].isUndefined()) { + ok &= sevalue_to_native(args[7], &(cobj->phase), nullptr); + } + + if(!ok) { + delete ptr; + SE_REPORT_ERROR("Argument convertion error"); + return false; + } + s.thisObject()->setPrivateObject(ptr); + return true; +} +SE_BIND_CTOR(js_assets_IPassStates_constructor, __jsb_cc_IPassStates_class, js_cc_IPassStates_finalize) + +static bool js_cc_IPassStates_finalize(se::State& s) // NOLINT(readability-identifier-naming) +{ + return true; +} +SE_BIND_FINALIZE_FUNC(js_cc_IPassStates_finalize) + +bool js_register_assets_IPassStates(se::Object* obj) // NOLINT(readability-identifier-naming) +{ + auto* cls = se::Class::create("IPassStates", obj, nullptr, _SE(js_assets_IPassStates_constructor)); + + cls->defineProperty("priority", _SE(js_assets_IPassStates_get_priority), _SE(js_assets_IPassStates_set_priority)); + cls->defineProperty("primitive", _SE(js_assets_IPassStates_get_primitive), _SE(js_assets_IPassStates_set_primitive)); + cls->defineProperty("stage", _SE(js_assets_IPassStates_get_stage), _SE(js_assets_IPassStates_set_stage)); + cls->defineProperty("rasterizerState", _SE(js_assets_IPassStates_get_rasterizerState), _SE(js_assets_IPassStates_set_rasterizerState)); + cls->defineProperty("depthStencilState", _SE(js_assets_IPassStates_get_depthStencilState), _SE(js_assets_IPassStates_set_depthStencilState)); + cls->defineProperty("blendState", _SE(js_assets_IPassStates_get_blendState), _SE(js_assets_IPassStates_set_blendState)); + cls->defineProperty("dynamicStates", _SE(js_assets_IPassStates_get_dynamicStates), _SE(js_assets_IPassStates_set_dynamicStates)); + cls->defineProperty("phase", _SE(js_assets_IPassStates_get_phase), _SE(js_assets_IPassStates_set_phase)); + cls->defineFunction("overrides", _SE(js_assets_IPassStates_overrides)); + cls->defineFinalizeFunction(_SE(js_cc_IPassStates_finalize)); + cls->install(); + JSBClassType::registerClass(cls); + + __jsb_cc_IPassStates_proto = cls->getProto(); + __jsb_cc_IPassStates_class = cls; + + + se::ScriptEngine::getInstance()->clearException(); + return true; +} +se::Object* __jsb_cc_IPassInfoFull_proto = nullptr; // NOLINT +se::Class* __jsb_cc_IPassInfoFull_class = nullptr; // NOLINT + +static bool js_assets_IPassInfoFull_get_priority(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_assets_IPassInfoFull_get_priority : Invalid Native Object"); + + CC_UNUSED bool ok = true; + se::Value jsret; + ok &= nativevalue_to_se(cobj->priority, jsret, s.thisObject() /*ctx*/); + s.rval() = jsret; + SE_HOLD_RETURN_VALUE(cobj->priority, s.thisObject(), s.rval()); + return true; +} +SE_BIND_PROP_GET(js_assets_IPassInfoFull_get_priority) + +static bool js_assets_IPassInfoFull_set_priority(se::State& s) // NOLINT(readability-identifier-naming) +{ + const auto& args = s.args(); + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_assets_IPassInfoFull_set_priority : Invalid Native Object"); + + CC_UNUSED bool ok = true; + ok &= sevalue_to_native(args[0], &cobj->priority, s.thisObject()); + SE_PRECONDITION2(ok, false, "js_assets_IPassInfoFull_set_priority : Error processing new value"); + return true; +} +SE_BIND_PROP_SET(js_assets_IPassInfoFull_set_priority) + +static bool js_assets_IPassInfoFull_get_primitive(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_assets_IPassInfoFull_get_primitive : Invalid Native Object"); + + CC_UNUSED bool ok = true; + se::Value jsret; + ok &= nativevalue_to_se(cobj->primitive, jsret, s.thisObject() /*ctx*/); + s.rval() = jsret; + SE_HOLD_RETURN_VALUE(cobj->primitive, s.thisObject(), s.rval()); + return true; +} +SE_BIND_PROP_GET(js_assets_IPassInfoFull_get_primitive) + +static bool js_assets_IPassInfoFull_set_primitive(se::State& s) // NOLINT(readability-identifier-naming) +{ + const auto& args = s.args(); + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_assets_IPassInfoFull_set_primitive : Invalid Native Object"); + + CC_UNUSED bool ok = true; + ok &= sevalue_to_native(args[0], &cobj->primitive, s.thisObject()); + SE_PRECONDITION2(ok, false, "js_assets_IPassInfoFull_set_primitive : Error processing new value"); + return true; +} +SE_BIND_PROP_SET(js_assets_IPassInfoFull_set_primitive) + +static bool js_assets_IPassInfoFull_get_stage(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_assets_IPassInfoFull_get_stage : Invalid Native Object"); + + CC_UNUSED bool ok = true; + se::Value jsret; + ok &= nativevalue_to_se(cobj->stage, jsret, s.thisObject() /*ctx*/); + s.rval() = jsret; + SE_HOLD_RETURN_VALUE(cobj->stage, s.thisObject(), s.rval()); + return true; +} +SE_BIND_PROP_GET(js_assets_IPassInfoFull_get_stage) + +static bool js_assets_IPassInfoFull_set_stage(se::State& s) // NOLINT(readability-identifier-naming) +{ + const auto& args = s.args(); + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_assets_IPassInfoFull_set_stage : Invalid Native Object"); + + CC_UNUSED bool ok = true; + ok &= sevalue_to_native(args[0], &cobj->stage, s.thisObject()); + SE_PRECONDITION2(ok, false, "js_assets_IPassInfoFull_set_stage : Error processing new value"); + return true; +} +SE_BIND_PROP_SET(js_assets_IPassInfoFull_set_stage) + +static bool js_assets_IPassInfoFull_get_rasterizerState(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_assets_IPassInfoFull_get_rasterizerState : Invalid Native Object"); + + CC_UNUSED bool ok = true; + se::Value jsret; + ok &= nativevalue_to_se(cobj->rasterizerState, jsret, s.thisObject() /*ctx*/); + s.rval() = jsret; + SE_HOLD_RETURN_VALUE(cobj->rasterizerState, s.thisObject(), s.rval()); + return true; +} +SE_BIND_PROP_GET(js_assets_IPassInfoFull_get_rasterizerState) + +static bool js_assets_IPassInfoFull_set_rasterizerState(se::State& s) // NOLINT(readability-identifier-naming) +{ + const auto& args = s.args(); + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_assets_IPassInfoFull_set_rasterizerState : Invalid Native Object"); + + CC_UNUSED bool ok = true; + ok &= sevalue_to_native(args[0], &cobj->rasterizerState, s.thisObject()); + SE_PRECONDITION2(ok, false, "js_assets_IPassInfoFull_set_rasterizerState : Error processing new value"); + return true; +} +SE_BIND_PROP_SET(js_assets_IPassInfoFull_set_rasterizerState) + +static bool js_assets_IPassInfoFull_get_depthStencilState(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_assets_IPassInfoFull_get_depthStencilState : Invalid Native Object"); + + CC_UNUSED bool ok = true; + se::Value jsret; + ok &= nativevalue_to_se(cobj->depthStencilState, jsret, s.thisObject() /*ctx*/); + s.rval() = jsret; + SE_HOLD_RETURN_VALUE(cobj->depthStencilState, s.thisObject(), s.rval()); + return true; +} +SE_BIND_PROP_GET(js_assets_IPassInfoFull_get_depthStencilState) + +static bool js_assets_IPassInfoFull_set_depthStencilState(se::State& s) // NOLINT(readability-identifier-naming) +{ + const auto& args = s.args(); + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_assets_IPassInfoFull_set_depthStencilState : Invalid Native Object"); + + CC_UNUSED bool ok = true; + ok &= sevalue_to_native(args[0], &cobj->depthStencilState, s.thisObject()); + SE_PRECONDITION2(ok, false, "js_assets_IPassInfoFull_set_depthStencilState : Error processing new value"); + return true; +} +SE_BIND_PROP_SET(js_assets_IPassInfoFull_set_depthStencilState) + +static bool js_assets_IPassInfoFull_get_blendState(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_assets_IPassInfoFull_get_blendState : Invalid Native Object"); + + CC_UNUSED bool ok = true; + se::Value jsret; + ok &= nativevalue_to_se(cobj->blendState, jsret, s.thisObject() /*ctx*/); + s.rval() = jsret; + SE_HOLD_RETURN_VALUE(cobj->blendState, s.thisObject(), s.rval()); + return true; +} +SE_BIND_PROP_GET(js_assets_IPassInfoFull_get_blendState) + +static bool js_assets_IPassInfoFull_set_blendState(se::State& s) // NOLINT(readability-identifier-naming) +{ + const auto& args = s.args(); + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_assets_IPassInfoFull_set_blendState : Invalid Native Object"); + + CC_UNUSED bool ok = true; + ok &= sevalue_to_native(args[0], &cobj->blendState, s.thisObject()); + SE_PRECONDITION2(ok, false, "js_assets_IPassInfoFull_set_blendState : Error processing new value"); + return true; +} +SE_BIND_PROP_SET(js_assets_IPassInfoFull_set_blendState) + +static bool js_assets_IPassInfoFull_get_dynamicStates(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_assets_IPassInfoFull_get_dynamicStates : Invalid Native Object"); + + CC_UNUSED bool ok = true; + se::Value jsret; + ok &= nativevalue_to_se(cobj->dynamicStates, jsret, s.thisObject() /*ctx*/); + s.rval() = jsret; + SE_HOLD_RETURN_VALUE(cobj->dynamicStates, s.thisObject(), s.rval()); + return true; +} +SE_BIND_PROP_GET(js_assets_IPassInfoFull_get_dynamicStates) + +static bool js_assets_IPassInfoFull_set_dynamicStates(se::State& s) // NOLINT(readability-identifier-naming) +{ + const auto& args = s.args(); + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_assets_IPassInfoFull_set_dynamicStates : Invalid Native Object"); + + CC_UNUSED bool ok = true; + ok &= sevalue_to_native(args[0], &cobj->dynamicStates, s.thisObject()); + SE_PRECONDITION2(ok, false, "js_assets_IPassInfoFull_set_dynamicStates : Error processing new value"); + return true; +} +SE_BIND_PROP_SET(js_assets_IPassInfoFull_set_dynamicStates) + +static bool js_assets_IPassInfoFull_get_phase(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_assets_IPassInfoFull_get_phase : Invalid Native Object"); + + CC_UNUSED bool ok = true; + se::Value jsret; + ok &= nativevalue_to_se(cobj->phase, jsret, s.thisObject() /*ctx*/); + s.rval() = jsret; + SE_HOLD_RETURN_VALUE(cobj->phase, s.thisObject(), s.rval()); + return true; +} +SE_BIND_PROP_GET(js_assets_IPassInfoFull_get_phase) + +static bool js_assets_IPassInfoFull_set_phase(se::State& s) // NOLINT(readability-identifier-naming) +{ + const auto& args = s.args(); + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_assets_IPassInfoFull_set_phase : Invalid Native Object"); + + CC_UNUSED bool ok = true; + ok &= sevalue_to_native(args[0], &cobj->phase, s.thisObject()); + SE_PRECONDITION2(ok, false, "js_assets_IPassInfoFull_set_phase : Error processing new value"); + return true; +} +SE_BIND_PROP_SET(js_assets_IPassInfoFull_set_phase) + +static bool js_assets_IPassInfoFull_get_program(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_assets_IPassInfoFull_get_program : Invalid Native Object"); + + CC_UNUSED bool ok = true; + se::Value jsret; + ok &= nativevalue_to_se(cobj->program, jsret, s.thisObject() /*ctx*/); + s.rval() = jsret; + SE_HOLD_RETURN_VALUE(cobj->program, s.thisObject(), s.rval()); + return true; +} +SE_BIND_PROP_GET(js_assets_IPassInfoFull_get_program) + +static bool js_assets_IPassInfoFull_set_program(se::State& s) // NOLINT(readability-identifier-naming) +{ + const auto& args = s.args(); + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_assets_IPassInfoFull_set_program : Invalid Native Object"); + + CC_UNUSED bool ok = true; + ok &= sevalue_to_native(args[0], &cobj->program, s.thisObject()); + SE_PRECONDITION2(ok, false, "js_assets_IPassInfoFull_set_program : Error processing new value"); + return true; +} +SE_BIND_PROP_SET(js_assets_IPassInfoFull_set_program) + +static bool js_assets_IPassInfoFull_get_embeddedMacros(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_assets_IPassInfoFull_get_embeddedMacros : Invalid Native Object"); + + CC_UNUSED bool ok = true; + se::Value jsret; + ok &= nativevalue_to_se(cobj->embeddedMacros, jsret, s.thisObject() /*ctx*/); + s.rval() = jsret; + SE_HOLD_RETURN_VALUE(cobj->embeddedMacros, s.thisObject(), s.rval()); + return true; +} +SE_BIND_PROP_GET(js_assets_IPassInfoFull_get_embeddedMacros) + +static bool js_assets_IPassInfoFull_set_embeddedMacros(se::State& s) // NOLINT(readability-identifier-naming) +{ + const auto& args = s.args(); + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_assets_IPassInfoFull_set_embeddedMacros : Invalid Native Object"); + + CC_UNUSED bool ok = true; + ok &= sevalue_to_native(args[0], &cobj->embeddedMacros, s.thisObject()); + SE_PRECONDITION2(ok, false, "js_assets_IPassInfoFull_set_embeddedMacros : Error processing new value"); + return true; +} +SE_BIND_PROP_SET(js_assets_IPassInfoFull_set_embeddedMacros) + +static bool js_assets_IPassInfoFull_get_propertyIndex(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_assets_IPassInfoFull_get_propertyIndex : Invalid Native Object"); + + CC_UNUSED bool ok = true; + se::Value jsret; + ok &= nativevalue_to_se(cobj->propertyIndex, jsret, s.thisObject() /*ctx*/); + s.rval() = jsret; + SE_HOLD_RETURN_VALUE(cobj->propertyIndex, s.thisObject(), s.rval()); + return true; +} +SE_BIND_PROP_GET(js_assets_IPassInfoFull_get_propertyIndex) + +static bool js_assets_IPassInfoFull_set_propertyIndex(se::State& s) // NOLINT(readability-identifier-naming) +{ + const auto& args = s.args(); + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_assets_IPassInfoFull_set_propertyIndex : Invalid Native Object"); + + CC_UNUSED bool ok = true; + ok &= sevalue_to_native(args[0], &cobj->propertyIndex, s.thisObject()); + SE_PRECONDITION2(ok, false, "js_assets_IPassInfoFull_set_propertyIndex : Error processing new value"); + return true; +} +SE_BIND_PROP_SET(js_assets_IPassInfoFull_set_propertyIndex) + +static bool js_assets_IPassInfoFull_get_switch_(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_assets_IPassInfoFull_get_switch_ : Invalid Native Object"); + + CC_UNUSED bool ok = true; + se::Value jsret; + ok &= nativevalue_to_se(cobj->switch_, jsret, s.thisObject() /*ctx*/); + s.rval() = jsret; + SE_HOLD_RETURN_VALUE(cobj->switch_, s.thisObject(), s.rval()); + return true; +} +SE_BIND_PROP_GET(js_assets_IPassInfoFull_get_switch_) + +static bool js_assets_IPassInfoFull_set_switch_(se::State& s) // NOLINT(readability-identifier-naming) +{ + const auto& args = s.args(); + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_assets_IPassInfoFull_set_switch_ : Invalid Native Object"); + + CC_UNUSED bool ok = true; + ok &= sevalue_to_native(args[0], &cobj->switch_, s.thisObject()); + SE_PRECONDITION2(ok, false, "js_assets_IPassInfoFull_set_switch_ : Error processing new value"); + return true; +} +SE_BIND_PROP_SET(js_assets_IPassInfoFull_set_switch_) + +static bool js_assets_IPassInfoFull_get_properties(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_assets_IPassInfoFull_get_properties : Invalid Native Object"); + + CC_UNUSED bool ok = true; + se::Value jsret; + ok &= nativevalue_to_se(cobj->properties, jsret, s.thisObject() /*ctx*/); + s.rval() = jsret; + SE_HOLD_RETURN_VALUE(cobj->properties, s.thisObject(), s.rval()); + return true; +} +SE_BIND_PROP_GET(js_assets_IPassInfoFull_get_properties) + +static bool js_assets_IPassInfoFull_set_properties(se::State& s) // NOLINT(readability-identifier-naming) +{ + const auto& args = s.args(); + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_assets_IPassInfoFull_set_properties : Invalid Native Object"); + + CC_UNUSED bool ok = true; + ok &= sevalue_to_native(args[0], &cobj->properties, s.thisObject()); + SE_PRECONDITION2(ok, false, "js_assets_IPassInfoFull_set_properties : Error processing new value"); + return true; +} +SE_BIND_PROP_SET(js_assets_IPassInfoFull_set_properties) + +static bool js_assets_IPassInfoFull_get_passIndex(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_assets_IPassInfoFull_get_passIndex : Invalid Native Object"); + + CC_UNUSED bool ok = true; + se::Value jsret; + ok &= nativevalue_to_se(cobj->passIndex, jsret, s.thisObject() /*ctx*/); + s.rval() = jsret; + SE_HOLD_RETURN_VALUE(cobj->passIndex, s.thisObject(), s.rval()); + return true; +} +SE_BIND_PROP_GET(js_assets_IPassInfoFull_get_passIndex) + +static bool js_assets_IPassInfoFull_set_passIndex(se::State& s) // NOLINT(readability-identifier-naming) +{ + const auto& args = s.args(); + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_assets_IPassInfoFull_set_passIndex : Invalid Native Object"); + + CC_UNUSED bool ok = true; + ok &= sevalue_to_native(args[0], &cobj->passIndex, s.thisObject()); + SE_PRECONDITION2(ok, false, "js_assets_IPassInfoFull_set_passIndex : Error processing new value"); + return true; +} +SE_BIND_PROP_SET(js_assets_IPassInfoFull_set_passIndex) + +static bool js_assets_IPassInfoFull_get_defines(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_assets_IPassInfoFull_get_defines : Invalid Native Object"); + + CC_UNUSED bool ok = true; + se::Value jsret; + ok &= nativevalue_to_se(cobj->defines, jsret, s.thisObject() /*ctx*/); + s.rval() = jsret; + SE_HOLD_RETURN_VALUE(cobj->defines, s.thisObject(), s.rval()); + return true; +} +SE_BIND_PROP_GET(js_assets_IPassInfoFull_get_defines) + +static bool js_assets_IPassInfoFull_set_defines(se::State& s) // NOLINT(readability-identifier-naming) +{ + const auto& args = s.args(); + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_assets_IPassInfoFull_set_defines : Invalid Native Object"); + + CC_UNUSED bool ok = true; + ok &= sevalue_to_native(args[0], &cobj->defines, s.thisObject()); + SE_PRECONDITION2(ok, false, "js_assets_IPassInfoFull_set_defines : Error processing new value"); + return true; +} +SE_BIND_PROP_SET(js_assets_IPassInfoFull_set_defines) + +static bool js_assets_IPassInfoFull_get_stateOverrides(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_assets_IPassInfoFull_get_stateOverrides : Invalid Native Object"); + + CC_UNUSED bool ok = true; + se::Value jsret; + ok &= nativevalue_to_se(cobj->stateOverrides, jsret, s.thisObject() /*ctx*/); + s.rval() = jsret; + SE_HOLD_RETURN_VALUE(cobj->stateOverrides, s.thisObject(), s.rval()); + return true; +} +SE_BIND_PROP_GET(js_assets_IPassInfoFull_get_stateOverrides) + +static bool js_assets_IPassInfoFull_set_stateOverrides(se::State& s) // NOLINT(readability-identifier-naming) +{ + const auto& args = s.args(); + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_assets_IPassInfoFull_set_stateOverrides : Invalid Native Object"); + + CC_UNUSED bool ok = true; + ok &= sevalue_to_native(args[0], &cobj->stateOverrides, s.thisObject()); + SE_PRECONDITION2(ok, false, "js_assets_IPassInfoFull_set_stateOverrides : Error processing new value"); + return true; +} +SE_BIND_PROP_SET(js_assets_IPassInfoFull_set_stateOverrides) + + +template<> +bool sevalue_to_native(const se::Value &from, cc::IPassInfoFull * to, se::Object *ctx) +{ + assert(from.isObject()); + se::Object *json = from.toObject(); + auto* data = reinterpret_cast(json->getPrivateData()); + if (data) { + *to = *data; + return true; + } + se::Value field; + bool ok = true; + json->getProperty("priority", &field, true); + if(!field.isNullOrUndefined()) { + ok &= sevalue_to_native(field, &(to->priority), ctx); + } + json->getProperty("primitive", &field, true); + if(!field.isNullOrUndefined()) { + ok &= sevalue_to_native(field, &(to->primitive), ctx); + } + json->getProperty("stage", &field, true); + if(!field.isNullOrUndefined()) { + ok &= sevalue_to_native(field, &(to->stage), ctx); + } + json->getProperty("rasterizerState", &field, true); + if(!field.isNullOrUndefined()) { + ok &= sevalue_to_native(field, &(to->rasterizerState), ctx); + } + json->getProperty("depthStencilState", &field, true); + if(!field.isNullOrUndefined()) { + ok &= sevalue_to_native(field, &(to->depthStencilState), ctx); + } + json->getProperty("blendState", &field, true); + if(!field.isNullOrUndefined()) { + ok &= sevalue_to_native(field, &(to->blendState), ctx); + } + json->getProperty("dynamicStates", &field, true); + if(!field.isNullOrUndefined()) { + ok &= sevalue_to_native(field, &(to->dynamicStates), ctx); + } + json->getProperty("phase", &field, true); + if(!field.isNullOrUndefined()) { + ok &= sevalue_to_native(field, &(to->phase), ctx); + } + json->getProperty("program", &field, true); + if(!field.isNullOrUndefined()) { + ok &= sevalue_to_native(field, &(to->program), ctx); + } + json->getProperty("embeddedMacros", &field, true); + if(!field.isNullOrUndefined()) { + ok &= sevalue_to_native(field, &(to->embeddedMacros), ctx); + } + json->getProperty("propertyIndex", &field, true); + if(!field.isNullOrUndefined()) { + ok &= sevalue_to_native(field, &(to->propertyIndex), ctx); + } + json->getProperty("switch", &field, true); + if(!field.isNullOrUndefined()) { + ok &= sevalue_to_native(field, &(to->switch_), ctx); + } + json->getProperty("properties", &field, true); + if(!field.isNullOrUndefined()) { + ok &= sevalue_to_native(field, &(to->properties), ctx); + } + json->getProperty("passIndex", &field, true); + if(!field.isNullOrUndefined()) { + ok &= sevalue_to_native(field, &(to->passIndex), ctx); + } + json->getProperty("defines", &field, true); + if(!field.isNullOrUndefined()) { + ok &= sevalue_to_native(field, &(to->defines), ctx); + } + json->getProperty("stateOverrides", &field, true); + if(!field.isNullOrUndefined()) { + ok &= sevalue_to_native(field, &(to->stateOverrides), ctx); + } + return ok; +} + +SE_DECLARE_FINALIZE_FUNC(js_cc_IPassInfoFull_finalize) + +static bool js_assets_IPassInfoFull_constructor(se::State& s) // NOLINT(readability-identifier-naming) +{ + CC_UNUSED bool ok = true; + const auto& args = s.args(); + size_t argc = args.size(); + + if(argc == 0) + { + auto *ptr = JSB_MAKE_PRIVATE_OBJECT(cc::IPassInfoFull); + s.thisObject()->setPrivateObject(ptr); + return true; + } + + if(argc == 1 && args[0].isObject()) + { + se::Object *json = args[0].toObject(); + se::Value field; + auto *ptr = JSB_MAKE_PRIVATE_OBJECT(cc::IPassInfoFull); + auto cobj = ptr->get(); + ok &= sevalue_to_native(args[0], cobj, s.thisObject()); + if(!ok) { + delete ptr; + SE_REPORT_ERROR("argument convertion error"); + return false; + } + s.thisObject()->setPrivateObject(ptr); + return true; + } + auto *ptr = JSB_MAKE_PRIVATE_OBJECT(cc::IPassInfoFull); + auto cobj = ptr->get(); + if (argc > 0 && !args[0].isUndefined()) { + ok &= sevalue_to_native(args[0], &(cobj->priority), nullptr); + } + if (argc > 1 && !args[1].isUndefined()) { + ok &= sevalue_to_native(args[1], &(cobj->primitive), nullptr); + } + if (argc > 2 && !args[2].isUndefined()) { + ok &= sevalue_to_native(args[2], &(cobj->stage), nullptr); + } + if (argc > 3 && !args[3].isUndefined()) { + ok &= sevalue_to_native(args[3], &(cobj->rasterizerState), nullptr); + } + if (argc > 4 && !args[4].isUndefined()) { + ok &= sevalue_to_native(args[4], &(cobj->depthStencilState), nullptr); + } + if (argc > 5 && !args[5].isUndefined()) { + ok &= sevalue_to_native(args[5], &(cobj->blendState), nullptr); + } + if (argc > 6 && !args[6].isUndefined()) { + ok &= sevalue_to_native(args[6], &(cobj->dynamicStates), nullptr); + } + if (argc > 7 && !args[7].isUndefined()) { + ok &= sevalue_to_native(args[7], &(cobj->phase), nullptr); + } + if (argc > 8 && !args[8].isUndefined()) { + ok &= sevalue_to_native(args[8], &(cobj->program), nullptr); + } + if (argc > 9 && !args[9].isUndefined()) { + ok &= sevalue_to_native(args[9], &(cobj->embeddedMacros), nullptr); + } + if (argc > 10 && !args[10].isUndefined()) { + ok &= sevalue_to_native(args[10], &(cobj->propertyIndex), nullptr); + } + if (argc > 11 && !args[11].isUndefined()) { + ok &= sevalue_to_native(args[11], &(cobj->switch_), nullptr); + } + if (argc > 12 && !args[12].isUndefined()) { + ok &= sevalue_to_native(args[12], &(cobj->properties), nullptr); + } + if (argc > 13 && !args[13].isUndefined()) { + ok &= sevalue_to_native(args[13], &(cobj->passIndex), nullptr); + } + if (argc > 14 && !args[14].isUndefined()) { + ok &= sevalue_to_native(args[14], &(cobj->defines), nullptr); + } + if (argc > 15 && !args[15].isUndefined()) { + ok &= sevalue_to_native(args[15], &(cobj->stateOverrides), nullptr); + } + + if(!ok) { + delete ptr; + SE_REPORT_ERROR("Argument convertion error"); + return false; + } + s.thisObject()->setPrivateObject(ptr); + return true; +} +SE_BIND_CTOR(js_assets_IPassInfoFull_constructor, __jsb_cc_IPassInfoFull_class, js_cc_IPassInfoFull_finalize) + +static bool js_cc_IPassInfoFull_finalize(se::State& s) // NOLINT(readability-identifier-naming) +{ + return true; +} +SE_BIND_FINALIZE_FUNC(js_cc_IPassInfoFull_finalize) + +bool js_register_assets_IPassInfoFull(se::Object* obj) // NOLINT(readability-identifier-naming) +{ + auto* cls = se::Class::create("IPassInfoFull", obj, nullptr, _SE(js_assets_IPassInfoFull_constructor)); + + cls->defineProperty("priority", _SE(js_assets_IPassInfoFull_get_priority), _SE(js_assets_IPassInfoFull_set_priority)); + cls->defineProperty("primitive", _SE(js_assets_IPassInfoFull_get_primitive), _SE(js_assets_IPassInfoFull_set_primitive)); + cls->defineProperty("stage", _SE(js_assets_IPassInfoFull_get_stage), _SE(js_assets_IPassInfoFull_set_stage)); + cls->defineProperty("rasterizerState", _SE(js_assets_IPassInfoFull_get_rasterizerState), _SE(js_assets_IPassInfoFull_set_rasterizerState)); + cls->defineProperty("depthStencilState", _SE(js_assets_IPassInfoFull_get_depthStencilState), _SE(js_assets_IPassInfoFull_set_depthStencilState)); + cls->defineProperty("blendState", _SE(js_assets_IPassInfoFull_get_blendState), _SE(js_assets_IPassInfoFull_set_blendState)); + cls->defineProperty("dynamicStates", _SE(js_assets_IPassInfoFull_get_dynamicStates), _SE(js_assets_IPassInfoFull_set_dynamicStates)); + cls->defineProperty("phase", _SE(js_assets_IPassInfoFull_get_phase), _SE(js_assets_IPassInfoFull_set_phase)); + cls->defineProperty("program", _SE(js_assets_IPassInfoFull_get_program), _SE(js_assets_IPassInfoFull_set_program)); + cls->defineProperty("embeddedMacros", _SE(js_assets_IPassInfoFull_get_embeddedMacros), _SE(js_assets_IPassInfoFull_set_embeddedMacros)); + cls->defineProperty("propertyIndex", _SE(js_assets_IPassInfoFull_get_propertyIndex), _SE(js_assets_IPassInfoFull_set_propertyIndex)); + cls->defineProperty("switch", _SE(js_assets_IPassInfoFull_get_switch_), _SE(js_assets_IPassInfoFull_set_switch_)); + cls->defineProperty("properties", _SE(js_assets_IPassInfoFull_get_properties), _SE(js_assets_IPassInfoFull_set_properties)); + cls->defineProperty("passIndex", _SE(js_assets_IPassInfoFull_get_passIndex), _SE(js_assets_IPassInfoFull_set_passIndex)); + cls->defineProperty("defines", _SE(js_assets_IPassInfoFull_get_defines), _SE(js_assets_IPassInfoFull_set_defines)); + cls->defineProperty("stateOverrides", _SE(js_assets_IPassInfoFull_get_stateOverrides), _SE(js_assets_IPassInfoFull_set_stateOverrides)); + cls->defineFinalizeFunction(_SE(js_cc_IPassInfoFull_finalize)); + cls->install(); + JSBClassType::registerClass(cls); + + __jsb_cc_IPassInfoFull_proto = cls->getProto(); + __jsb_cc_IPassInfoFull_class = cls; + + + se::ScriptEngine::getInstance()->clearException(); + return true; +} +se::Object* __jsb_cc_ITechniqueInfo_proto = nullptr; // NOLINT +se::Class* __jsb_cc_ITechniqueInfo_class = nullptr; // NOLINT + +static bool js_assets_ITechniqueInfo_get_passes(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_assets_ITechniqueInfo_get_passes : Invalid Native Object"); + + CC_UNUSED bool ok = true; + se::Value jsret; + ok &= nativevalue_to_se(cobj->passes, jsret, s.thisObject() /*ctx*/); + s.rval() = jsret; + SE_HOLD_RETURN_VALUE(cobj->passes, s.thisObject(), s.rval()); + return true; +} +SE_BIND_PROP_GET(js_assets_ITechniqueInfo_get_passes) + +static bool js_assets_ITechniqueInfo_set_passes(se::State& s) // NOLINT(readability-identifier-naming) +{ + const auto& args = s.args(); + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_assets_ITechniqueInfo_set_passes : Invalid Native Object"); + + CC_UNUSED bool ok = true; + ok &= sevalue_to_native(args[0], &cobj->passes, s.thisObject()); + SE_PRECONDITION2(ok, false, "js_assets_ITechniqueInfo_set_passes : Error processing new value"); + return true; +} +SE_BIND_PROP_SET(js_assets_ITechniqueInfo_set_passes) + +static bool js_assets_ITechniqueInfo_get_name(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_assets_ITechniqueInfo_get_name : Invalid Native Object"); + + CC_UNUSED bool ok = true; + se::Value jsret; + ok &= nativevalue_to_se(cobj->name, jsret, s.thisObject() /*ctx*/); + s.rval() = jsret; + SE_HOLD_RETURN_VALUE(cobj->name, s.thisObject(), s.rval()); + return true; +} +SE_BIND_PROP_GET(js_assets_ITechniqueInfo_get_name) + +static bool js_assets_ITechniqueInfo_set_name(se::State& s) // NOLINT(readability-identifier-naming) +{ + const auto& args = s.args(); + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_assets_ITechniqueInfo_set_name : Invalid Native Object"); + + CC_UNUSED bool ok = true; + ok &= sevalue_to_native(args[0], &cobj->name, s.thisObject()); + SE_PRECONDITION2(ok, false, "js_assets_ITechniqueInfo_set_name : Error processing new value"); + return true; +} +SE_BIND_PROP_SET(js_assets_ITechniqueInfo_set_name) + + +template<> +bool sevalue_to_native(const se::Value &from, cc::ITechniqueInfo * to, se::Object *ctx) +{ + assert(from.isObject()); + se::Object *json = from.toObject(); + auto* data = reinterpret_cast(json->getPrivateData()); + if (data) { + *to = *data; + return true; + } + se::Value field; + bool ok = true; + json->getProperty("passes", &field, true); + if(!field.isNullOrUndefined()) { + ok &= sevalue_to_native(field, &(to->passes), ctx); + } + json->getProperty("name", &field, true); + if(!field.isNullOrUndefined()) { + ok &= sevalue_to_native(field, &(to->name), ctx); + } + return ok; +} + +SE_DECLARE_FINALIZE_FUNC(js_cc_ITechniqueInfo_finalize) + +static bool js_assets_ITechniqueInfo_constructor(se::State& s) // NOLINT(readability-identifier-naming) +{ + CC_UNUSED bool ok = true; + const auto& args = s.args(); + size_t argc = args.size(); + + if(argc == 0) + { + auto *ptr = JSB_MAKE_PRIVATE_OBJECT(cc::ITechniqueInfo); + s.thisObject()->setPrivateObject(ptr); + return true; + } + + if(argc == 1 && args[0].isObject()) + { + se::Object *json = args[0].toObject(); + se::Value field; + auto *ptr = JSB_MAKE_PRIVATE_OBJECT(cc::ITechniqueInfo); + auto cobj = ptr->get(); + ok &= sevalue_to_native(args[0], cobj, s.thisObject()); + if(!ok) { + delete ptr; + SE_REPORT_ERROR("argument convertion error"); + return false; + } + s.thisObject()->setPrivateObject(ptr); + return true; + } + auto *ptr = JSB_MAKE_PRIVATE_OBJECT(cc::ITechniqueInfo); + auto cobj = ptr->get(); + if (argc > 0 && !args[0].isUndefined()) { + ok &= sevalue_to_native(args[0], &(cobj->passes), nullptr); + } + if (argc > 1 && !args[1].isUndefined()) { + ok &= sevalue_to_native(args[1], &(cobj->name), nullptr); + } + + if(!ok) { + delete ptr; + SE_REPORT_ERROR("Argument convertion error"); + return false; + } + s.thisObject()->setPrivateObject(ptr); + return true; +} +SE_BIND_CTOR(js_assets_ITechniqueInfo_constructor, __jsb_cc_ITechniqueInfo_class, js_cc_ITechniqueInfo_finalize) + +static bool js_cc_ITechniqueInfo_finalize(se::State& s) // NOLINT(readability-identifier-naming) +{ + return true; +} +SE_BIND_FINALIZE_FUNC(js_cc_ITechniqueInfo_finalize) + +bool js_register_assets_ITechniqueInfo(se::Object* obj) // NOLINT(readability-identifier-naming) +{ + auto* cls = se::Class::create("ITechniqueInfo", obj, nullptr, _SE(js_assets_ITechniqueInfo_constructor)); + + cls->defineProperty("passes", _SE(js_assets_ITechniqueInfo_get_passes), _SE(js_assets_ITechniqueInfo_set_passes)); + cls->defineProperty("name", _SE(js_assets_ITechniqueInfo_get_name), _SE(js_assets_ITechniqueInfo_set_name)); + cls->defineFinalizeFunction(_SE(js_cc_ITechniqueInfo_finalize)); + cls->install(); + JSBClassType::registerClass(cls); + + __jsb_cc_ITechniqueInfo_proto = cls->getProto(); + __jsb_cc_ITechniqueInfo_class = cls; + + + se::ScriptEngine::getInstance()->clearException(); + return true; +} +se::Object* __jsb_cc_IBlockInfo_proto = nullptr; // NOLINT +se::Class* __jsb_cc_IBlockInfo_class = nullptr; // NOLINT + +static bool js_assets_IBlockInfo_get_binding(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_assets_IBlockInfo_get_binding : Invalid Native Object"); + + CC_UNUSED bool ok = true; + se::Value jsret; + ok &= nativevalue_to_se(cobj->binding, jsret, s.thisObject() /*ctx*/); + s.rval() = jsret; + SE_HOLD_RETURN_VALUE(cobj->binding, s.thisObject(), s.rval()); + return true; +} +SE_BIND_PROP_GET(js_assets_IBlockInfo_get_binding) + +static bool js_assets_IBlockInfo_set_binding(se::State& s) // NOLINT(readability-identifier-naming) +{ + const auto& args = s.args(); + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_assets_IBlockInfo_set_binding : Invalid Native Object"); + + CC_UNUSED bool ok = true; + ok &= sevalue_to_native(args[0], &cobj->binding, s.thisObject()); + SE_PRECONDITION2(ok, false, "js_assets_IBlockInfo_set_binding : Error processing new value"); + return true; +} +SE_BIND_PROP_SET(js_assets_IBlockInfo_set_binding) + +static bool js_assets_IBlockInfo_get_name(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_assets_IBlockInfo_get_name : Invalid Native Object"); + + CC_UNUSED bool ok = true; + se::Value jsret; + ok &= nativevalue_to_se(cobj->name, jsret, s.thisObject() /*ctx*/); + s.rval() = jsret; + SE_HOLD_RETURN_VALUE(cobj->name, s.thisObject(), s.rval()); + return true; +} +SE_BIND_PROP_GET(js_assets_IBlockInfo_get_name) + +static bool js_assets_IBlockInfo_set_name(se::State& s) // NOLINT(readability-identifier-naming) +{ + const auto& args = s.args(); + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_assets_IBlockInfo_set_name : Invalid Native Object"); + + CC_UNUSED bool ok = true; + ok &= sevalue_to_native(args[0], &cobj->name, s.thisObject()); + SE_PRECONDITION2(ok, false, "js_assets_IBlockInfo_set_name : Error processing new value"); + return true; +} +SE_BIND_PROP_SET(js_assets_IBlockInfo_set_name) + +static bool js_assets_IBlockInfo_get_members(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_assets_IBlockInfo_get_members : Invalid Native Object"); + + CC_UNUSED bool ok = true; + se::Value jsret; + ok &= nativevalue_to_se(cobj->members, jsret, s.thisObject() /*ctx*/); + s.rval() = jsret; + SE_HOLD_RETURN_VALUE(cobj->members, s.thisObject(), s.rval()); + return true; +} +SE_BIND_PROP_GET(js_assets_IBlockInfo_get_members) + +static bool js_assets_IBlockInfo_set_members(se::State& s) // NOLINT(readability-identifier-naming) +{ + const auto& args = s.args(); + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_assets_IBlockInfo_set_members : Invalid Native Object"); + + CC_UNUSED bool ok = true; + ok &= sevalue_to_native(args[0], &cobj->members, s.thisObject()); + SE_PRECONDITION2(ok, false, "js_assets_IBlockInfo_set_members : Error processing new value"); + return true; +} +SE_BIND_PROP_SET(js_assets_IBlockInfo_set_members) + +static bool js_assets_IBlockInfo_get_stageFlags(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_assets_IBlockInfo_get_stageFlags : Invalid Native Object"); + + CC_UNUSED bool ok = true; + se::Value jsret; + ok &= nativevalue_to_se(cobj->stageFlags, jsret, s.thisObject() /*ctx*/); + s.rval() = jsret; + SE_HOLD_RETURN_VALUE(cobj->stageFlags, s.thisObject(), s.rval()); + return true; +} +SE_BIND_PROP_GET(js_assets_IBlockInfo_get_stageFlags) + +static bool js_assets_IBlockInfo_set_stageFlags(se::State& s) // NOLINT(readability-identifier-naming) +{ + const auto& args = s.args(); + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_assets_IBlockInfo_set_stageFlags : Invalid Native Object"); + + CC_UNUSED bool ok = true; + ok &= sevalue_to_native(args[0], &cobj->stageFlags, s.thisObject()); + SE_PRECONDITION2(ok, false, "js_assets_IBlockInfo_set_stageFlags : Error processing new value"); + return true; +} +SE_BIND_PROP_SET(js_assets_IBlockInfo_set_stageFlags) + + +template<> +bool sevalue_to_native(const se::Value &from, cc::IBlockInfo * to, se::Object *ctx) +{ + assert(from.isObject()); + se::Object *json = from.toObject(); + auto* data = reinterpret_cast(json->getPrivateData()); + if (data) { + *to = *data; + return true; + } + se::Value field; + bool ok = true; + json->getProperty("binding", &field, true); + if(!field.isNullOrUndefined()) { + ok &= sevalue_to_native(field, &(to->binding), ctx); + } + json->getProperty("name", &field, true); + if(!field.isNullOrUndefined()) { + ok &= sevalue_to_native(field, &(to->name), ctx); + } + json->getProperty("members", &field, true); + if(!field.isNullOrUndefined()) { + ok &= sevalue_to_native(field, &(to->members), ctx); + } + json->getProperty("stageFlags", &field, true); + if(!field.isNullOrUndefined()) { + ok &= sevalue_to_native(field, &(to->stageFlags), ctx); + } + return ok; +} + +SE_DECLARE_FINALIZE_FUNC(js_cc_IBlockInfo_finalize) + +static bool js_assets_IBlockInfo_constructor(se::State& s) // NOLINT(readability-identifier-naming) +{ + CC_UNUSED bool ok = true; + const auto& args = s.args(); + size_t argc = args.size(); + + if(argc == 0) + { + auto *ptr = JSB_MAKE_PRIVATE_OBJECT(cc::IBlockInfo); + s.thisObject()->setPrivateObject(ptr); + return true; + } + + if(argc == 1 && args[0].isObject()) + { + se::Object *json = args[0].toObject(); + se::Value field; + auto *ptr = JSB_MAKE_PRIVATE_OBJECT(cc::IBlockInfo); + auto cobj = ptr->get(); + ok &= sevalue_to_native(args[0], cobj, s.thisObject()); + if(!ok) { + delete ptr; + SE_REPORT_ERROR("argument convertion error"); + return false; + } + s.thisObject()->setPrivateObject(ptr); + return true; + } + auto *ptr = JSB_MAKE_PRIVATE_OBJECT(cc::IBlockInfo); + auto cobj = ptr->get(); + if (argc > 0 && !args[0].isUndefined()) { + ok &= sevalue_to_native(args[0], &(cobj->binding), nullptr); + } + if (argc > 1 && !args[1].isUndefined()) { + ok &= sevalue_to_native(args[1], &(cobj->name), nullptr); + } + if (argc > 2 && !args[2].isUndefined()) { + ok &= sevalue_to_native(args[2], &(cobj->members), nullptr); + } + if (argc > 3 && !args[3].isUndefined()) { + ok &= sevalue_to_native(args[3], &(cobj->stageFlags), nullptr); + } + + if(!ok) { + delete ptr; + SE_REPORT_ERROR("Argument convertion error"); + return false; + } + s.thisObject()->setPrivateObject(ptr); + return true; +} +SE_BIND_CTOR(js_assets_IBlockInfo_constructor, __jsb_cc_IBlockInfo_class, js_cc_IBlockInfo_finalize) + +static bool js_cc_IBlockInfo_finalize(se::State& s) // NOLINT(readability-identifier-naming) +{ + return true; +} +SE_BIND_FINALIZE_FUNC(js_cc_IBlockInfo_finalize) + +bool js_register_assets_IBlockInfo(se::Object* obj) // NOLINT(readability-identifier-naming) +{ + auto* cls = se::Class::create("IBlockInfo", obj, nullptr, _SE(js_assets_IBlockInfo_constructor)); + + cls->defineProperty("binding", _SE(js_assets_IBlockInfo_get_binding), _SE(js_assets_IBlockInfo_set_binding)); + cls->defineProperty("name", _SE(js_assets_IBlockInfo_get_name), _SE(js_assets_IBlockInfo_set_name)); + cls->defineProperty("members", _SE(js_assets_IBlockInfo_get_members), _SE(js_assets_IBlockInfo_set_members)); + cls->defineProperty("stageFlags", _SE(js_assets_IBlockInfo_get_stageFlags), _SE(js_assets_IBlockInfo_set_stageFlags)); + cls->defineFinalizeFunction(_SE(js_cc_IBlockInfo_finalize)); + cls->install(); + JSBClassType::registerClass(cls); + + __jsb_cc_IBlockInfo_proto = cls->getProto(); + __jsb_cc_IBlockInfo_class = cls; + + + se::ScriptEngine::getInstance()->clearException(); + return true; +} +se::Object* __jsb_cc_ISamplerTextureInfo_proto = nullptr; // NOLINT +se::Class* __jsb_cc_ISamplerTextureInfo_class = nullptr; // NOLINT + +static bool js_assets_ISamplerTextureInfo_get_binding(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_assets_ISamplerTextureInfo_get_binding : Invalid Native Object"); + + CC_UNUSED bool ok = true; + se::Value jsret; + ok &= nativevalue_to_se(cobj->binding, jsret, s.thisObject() /*ctx*/); + s.rval() = jsret; + SE_HOLD_RETURN_VALUE(cobj->binding, s.thisObject(), s.rval()); + return true; +} +SE_BIND_PROP_GET(js_assets_ISamplerTextureInfo_get_binding) + +static bool js_assets_ISamplerTextureInfo_set_binding(se::State& s) // NOLINT(readability-identifier-naming) +{ + const auto& args = s.args(); + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_assets_ISamplerTextureInfo_set_binding : Invalid Native Object"); + + CC_UNUSED bool ok = true; + ok &= sevalue_to_native(args[0], &cobj->binding, s.thisObject()); + SE_PRECONDITION2(ok, false, "js_assets_ISamplerTextureInfo_set_binding : Error processing new value"); + return true; +} +SE_BIND_PROP_SET(js_assets_ISamplerTextureInfo_set_binding) + +static bool js_assets_ISamplerTextureInfo_get_name(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_assets_ISamplerTextureInfo_get_name : Invalid Native Object"); + + CC_UNUSED bool ok = true; + se::Value jsret; + ok &= nativevalue_to_se(cobj->name, jsret, s.thisObject() /*ctx*/); + s.rval() = jsret; + SE_HOLD_RETURN_VALUE(cobj->name, s.thisObject(), s.rval()); + return true; +} +SE_BIND_PROP_GET(js_assets_ISamplerTextureInfo_get_name) + +static bool js_assets_ISamplerTextureInfo_set_name(se::State& s) // NOLINT(readability-identifier-naming) +{ + const auto& args = s.args(); + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_assets_ISamplerTextureInfo_set_name : Invalid Native Object"); + + CC_UNUSED bool ok = true; + ok &= sevalue_to_native(args[0], &cobj->name, s.thisObject()); + SE_PRECONDITION2(ok, false, "js_assets_ISamplerTextureInfo_set_name : Error processing new value"); + return true; +} +SE_BIND_PROP_SET(js_assets_ISamplerTextureInfo_set_name) + +static bool js_assets_ISamplerTextureInfo_get_type(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_assets_ISamplerTextureInfo_get_type : Invalid Native Object"); + + CC_UNUSED bool ok = true; + se::Value jsret; + ok &= nativevalue_to_se(cobj->type, jsret, s.thisObject() /*ctx*/); + s.rval() = jsret; + SE_HOLD_RETURN_VALUE(cobj->type, s.thisObject(), s.rval()); + return true; +} +SE_BIND_PROP_GET(js_assets_ISamplerTextureInfo_get_type) + +static bool js_assets_ISamplerTextureInfo_set_type(se::State& s) // NOLINT(readability-identifier-naming) +{ + const auto& args = s.args(); + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_assets_ISamplerTextureInfo_set_type : Invalid Native Object"); + + CC_UNUSED bool ok = true; + ok &= sevalue_to_native(args[0], &cobj->type, s.thisObject()); + SE_PRECONDITION2(ok, false, "js_assets_ISamplerTextureInfo_set_type : Error processing new value"); + return true; +} +SE_BIND_PROP_SET(js_assets_ISamplerTextureInfo_set_type) + +static bool js_assets_ISamplerTextureInfo_get_count(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_assets_ISamplerTextureInfo_get_count : Invalid Native Object"); + + CC_UNUSED bool ok = true; + se::Value jsret; + ok &= nativevalue_to_se(cobj->count, jsret, s.thisObject() /*ctx*/); + s.rval() = jsret; + SE_HOLD_RETURN_VALUE(cobj->count, s.thisObject(), s.rval()); + return true; +} +SE_BIND_PROP_GET(js_assets_ISamplerTextureInfo_get_count) + +static bool js_assets_ISamplerTextureInfo_set_count(se::State& s) // NOLINT(readability-identifier-naming) +{ + const auto& args = s.args(); + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_assets_ISamplerTextureInfo_set_count : Invalid Native Object"); + + CC_UNUSED bool ok = true; + ok &= sevalue_to_native(args[0], &cobj->count, s.thisObject()); + SE_PRECONDITION2(ok, false, "js_assets_ISamplerTextureInfo_set_count : Error processing new value"); + return true; +} +SE_BIND_PROP_SET(js_assets_ISamplerTextureInfo_set_count) + +static bool js_assets_ISamplerTextureInfo_get_stageFlags(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_assets_ISamplerTextureInfo_get_stageFlags : Invalid Native Object"); + + CC_UNUSED bool ok = true; + se::Value jsret; + ok &= nativevalue_to_se(cobj->stageFlags, jsret, s.thisObject() /*ctx*/); + s.rval() = jsret; + SE_HOLD_RETURN_VALUE(cobj->stageFlags, s.thisObject(), s.rval()); + return true; +} +SE_BIND_PROP_GET(js_assets_ISamplerTextureInfo_get_stageFlags) + +static bool js_assets_ISamplerTextureInfo_set_stageFlags(se::State& s) // NOLINT(readability-identifier-naming) +{ + const auto& args = s.args(); + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_assets_ISamplerTextureInfo_set_stageFlags : Invalid Native Object"); + + CC_UNUSED bool ok = true; + ok &= sevalue_to_native(args[0], &cobj->stageFlags, s.thisObject()); + SE_PRECONDITION2(ok, false, "js_assets_ISamplerTextureInfo_set_stageFlags : Error processing new value"); + return true; +} +SE_BIND_PROP_SET(js_assets_ISamplerTextureInfo_set_stageFlags) + + +template<> +bool sevalue_to_native(const se::Value &from, cc::ISamplerTextureInfo * to, se::Object *ctx) +{ + assert(from.isObject()); + se::Object *json = from.toObject(); + auto* data = reinterpret_cast(json->getPrivateData()); + if (data) { + *to = *data; + return true; + } + se::Value field; + bool ok = true; + json->getProperty("binding", &field, true); + if(!field.isNullOrUndefined()) { + ok &= sevalue_to_native(field, &(to->binding), ctx); + } + json->getProperty("name", &field, true); + if(!field.isNullOrUndefined()) { + ok &= sevalue_to_native(field, &(to->name), ctx); + } + json->getProperty("type", &field, true); + if(!field.isNullOrUndefined()) { + ok &= sevalue_to_native(field, &(to->type), ctx); + } + json->getProperty("count", &field, true); + if(!field.isNullOrUndefined()) { + ok &= sevalue_to_native(field, &(to->count), ctx); + } + json->getProperty("stageFlags", &field, true); + if(!field.isNullOrUndefined()) { + ok &= sevalue_to_native(field, &(to->stageFlags), ctx); + } + return ok; +} + +SE_DECLARE_FINALIZE_FUNC(js_cc_ISamplerTextureInfo_finalize) + +static bool js_assets_ISamplerTextureInfo_constructor(se::State& s) // NOLINT(readability-identifier-naming) +{ + CC_UNUSED bool ok = true; + const auto& args = s.args(); + size_t argc = args.size(); + + if(argc == 0) + { + auto *ptr = JSB_MAKE_PRIVATE_OBJECT(cc::ISamplerTextureInfo); + s.thisObject()->setPrivateObject(ptr); + return true; + } + + if(argc == 1 && args[0].isObject()) + { + se::Object *json = args[0].toObject(); + se::Value field; + auto *ptr = JSB_MAKE_PRIVATE_OBJECT(cc::ISamplerTextureInfo); + auto cobj = ptr->get(); + ok &= sevalue_to_native(args[0], cobj, s.thisObject()); + if(!ok) { + delete ptr; + SE_REPORT_ERROR("argument convertion error"); + return false; + } + s.thisObject()->setPrivateObject(ptr); + return true; + } + auto *ptr = JSB_MAKE_PRIVATE_OBJECT(cc::ISamplerTextureInfo); + auto cobj = ptr->get(); + if (argc > 0 && !args[0].isUndefined()) { + ok &= sevalue_to_native(args[0], &(cobj->binding), nullptr); + } + if (argc > 1 && !args[1].isUndefined()) { + ok &= sevalue_to_native(args[1], &(cobj->name), nullptr); + } + if (argc > 2 && !args[2].isUndefined()) { + ok &= sevalue_to_native(args[2], &(cobj->type), nullptr); + } + if (argc > 3 && !args[3].isUndefined()) { + ok &= sevalue_to_native(args[3], &(cobj->count), nullptr); + } + if (argc > 4 && !args[4].isUndefined()) { + ok &= sevalue_to_native(args[4], &(cobj->stageFlags), nullptr); + } + + if(!ok) { + delete ptr; + SE_REPORT_ERROR("Argument convertion error"); + return false; + } + s.thisObject()->setPrivateObject(ptr); + return true; +} +SE_BIND_CTOR(js_assets_ISamplerTextureInfo_constructor, __jsb_cc_ISamplerTextureInfo_class, js_cc_ISamplerTextureInfo_finalize) + +static bool js_cc_ISamplerTextureInfo_finalize(se::State& s) // NOLINT(readability-identifier-naming) +{ + return true; +} +SE_BIND_FINALIZE_FUNC(js_cc_ISamplerTextureInfo_finalize) + +bool js_register_assets_ISamplerTextureInfo(se::Object* obj) // NOLINT(readability-identifier-naming) +{ + auto* cls = se::Class::create("ISamplerTextureInfo", obj, nullptr, _SE(js_assets_ISamplerTextureInfo_constructor)); + + cls->defineProperty("binding", _SE(js_assets_ISamplerTextureInfo_get_binding), _SE(js_assets_ISamplerTextureInfo_set_binding)); + cls->defineProperty("name", _SE(js_assets_ISamplerTextureInfo_get_name), _SE(js_assets_ISamplerTextureInfo_set_name)); + cls->defineProperty("type", _SE(js_assets_ISamplerTextureInfo_get_type), _SE(js_assets_ISamplerTextureInfo_set_type)); + cls->defineProperty("count", _SE(js_assets_ISamplerTextureInfo_get_count), _SE(js_assets_ISamplerTextureInfo_set_count)); + cls->defineProperty("stageFlags", _SE(js_assets_ISamplerTextureInfo_get_stageFlags), _SE(js_assets_ISamplerTextureInfo_set_stageFlags)); + cls->defineFinalizeFunction(_SE(js_cc_ISamplerTextureInfo_finalize)); + cls->install(); + JSBClassType::registerClass(cls); + + __jsb_cc_ISamplerTextureInfo_proto = cls->getProto(); + __jsb_cc_ISamplerTextureInfo_class = cls; + + + se::ScriptEngine::getInstance()->clearException(); + return true; +} +se::Object* __jsb_cc_ITextureInfo_proto = nullptr; // NOLINT +se::Class* __jsb_cc_ITextureInfo_class = nullptr; // NOLINT + +static bool js_assets_ITextureInfo_get_set(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_assets_ITextureInfo_get_set : Invalid Native Object"); + + CC_UNUSED bool ok = true; + se::Value jsret; + ok &= nativevalue_to_se(cobj->set, jsret, s.thisObject() /*ctx*/); + s.rval() = jsret; + SE_HOLD_RETURN_VALUE(cobj->set, s.thisObject(), s.rval()); + return true; +} +SE_BIND_PROP_GET(js_assets_ITextureInfo_get_set) + +static bool js_assets_ITextureInfo_set_set(se::State& s) // NOLINT(readability-identifier-naming) +{ + const auto& args = s.args(); + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_assets_ITextureInfo_set_set : Invalid Native Object"); + + CC_UNUSED bool ok = true; + ok &= sevalue_to_native(args[0], &cobj->set, s.thisObject()); + SE_PRECONDITION2(ok, false, "js_assets_ITextureInfo_set_set : Error processing new value"); + return true; +} +SE_BIND_PROP_SET(js_assets_ITextureInfo_set_set) + +static bool js_assets_ITextureInfo_get_binding(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_assets_ITextureInfo_get_binding : Invalid Native Object"); + + CC_UNUSED bool ok = true; + se::Value jsret; + ok &= nativevalue_to_se(cobj->binding, jsret, s.thisObject() /*ctx*/); + s.rval() = jsret; + SE_HOLD_RETURN_VALUE(cobj->binding, s.thisObject(), s.rval()); + return true; +} +SE_BIND_PROP_GET(js_assets_ITextureInfo_get_binding) + +static bool js_assets_ITextureInfo_set_binding(se::State& s) // NOLINT(readability-identifier-naming) +{ + const auto& args = s.args(); + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_assets_ITextureInfo_set_binding : Invalid Native Object"); + + CC_UNUSED bool ok = true; + ok &= sevalue_to_native(args[0], &cobj->binding, s.thisObject()); + SE_PRECONDITION2(ok, false, "js_assets_ITextureInfo_set_binding : Error processing new value"); + return true; +} +SE_BIND_PROP_SET(js_assets_ITextureInfo_set_binding) + +static bool js_assets_ITextureInfo_get_name(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_assets_ITextureInfo_get_name : Invalid Native Object"); + + CC_UNUSED bool ok = true; + se::Value jsret; + ok &= nativevalue_to_se(cobj->name, jsret, s.thisObject() /*ctx*/); + s.rval() = jsret; + SE_HOLD_RETURN_VALUE(cobj->name, s.thisObject(), s.rval()); + return true; +} +SE_BIND_PROP_GET(js_assets_ITextureInfo_get_name) + +static bool js_assets_ITextureInfo_set_name(se::State& s) // NOLINT(readability-identifier-naming) +{ + const auto& args = s.args(); + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_assets_ITextureInfo_set_name : Invalid Native Object"); + + CC_UNUSED bool ok = true; + ok &= sevalue_to_native(args[0], &cobj->name, s.thisObject()); + SE_PRECONDITION2(ok, false, "js_assets_ITextureInfo_set_name : Error processing new value"); + return true; +} +SE_BIND_PROP_SET(js_assets_ITextureInfo_set_name) + +static bool js_assets_ITextureInfo_get_type(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_assets_ITextureInfo_get_type : Invalid Native Object"); + + CC_UNUSED bool ok = true; + se::Value jsret; + ok &= nativevalue_to_se(cobj->type, jsret, s.thisObject() /*ctx*/); + s.rval() = jsret; + SE_HOLD_RETURN_VALUE(cobj->type, s.thisObject(), s.rval()); + return true; +} +SE_BIND_PROP_GET(js_assets_ITextureInfo_get_type) + +static bool js_assets_ITextureInfo_set_type(se::State& s) // NOLINT(readability-identifier-naming) +{ + const auto& args = s.args(); + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_assets_ITextureInfo_set_type : Invalid Native Object"); + + CC_UNUSED bool ok = true; + ok &= sevalue_to_native(args[0], &cobj->type, s.thisObject()); + SE_PRECONDITION2(ok, false, "js_assets_ITextureInfo_set_type : Error processing new value"); + return true; +} +SE_BIND_PROP_SET(js_assets_ITextureInfo_set_type) + +static bool js_assets_ITextureInfo_get_count(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_assets_ITextureInfo_get_count : Invalid Native Object"); + + CC_UNUSED bool ok = true; + se::Value jsret; + ok &= nativevalue_to_se(cobj->count, jsret, s.thisObject() /*ctx*/); + s.rval() = jsret; + SE_HOLD_RETURN_VALUE(cobj->count, s.thisObject(), s.rval()); + return true; +} +SE_BIND_PROP_GET(js_assets_ITextureInfo_get_count) + +static bool js_assets_ITextureInfo_set_count(se::State& s) // NOLINT(readability-identifier-naming) +{ + const auto& args = s.args(); + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_assets_ITextureInfo_set_count : Invalid Native Object"); + + CC_UNUSED bool ok = true; + ok &= sevalue_to_native(args[0], &cobj->count, s.thisObject()); + SE_PRECONDITION2(ok, false, "js_assets_ITextureInfo_set_count : Error processing new value"); + return true; +} +SE_BIND_PROP_SET(js_assets_ITextureInfo_set_count) + +static bool js_assets_ITextureInfo_get_stageFlags(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_assets_ITextureInfo_get_stageFlags : Invalid Native Object"); + + CC_UNUSED bool ok = true; + se::Value jsret; + ok &= nativevalue_to_se(cobj->stageFlags, jsret, s.thisObject() /*ctx*/); + s.rval() = jsret; + SE_HOLD_RETURN_VALUE(cobj->stageFlags, s.thisObject(), s.rval()); + return true; +} +SE_BIND_PROP_GET(js_assets_ITextureInfo_get_stageFlags) + +static bool js_assets_ITextureInfo_set_stageFlags(se::State& s) // NOLINT(readability-identifier-naming) +{ + const auto& args = s.args(); + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_assets_ITextureInfo_set_stageFlags : Invalid Native Object"); + + CC_UNUSED bool ok = true; + ok &= sevalue_to_native(args[0], &cobj->stageFlags, s.thisObject()); + SE_PRECONDITION2(ok, false, "js_assets_ITextureInfo_set_stageFlags : Error processing new value"); + return true; +} +SE_BIND_PROP_SET(js_assets_ITextureInfo_set_stageFlags) + + +template<> +bool sevalue_to_native(const se::Value &from, cc::ITextureInfo * to, se::Object *ctx) +{ + assert(from.isObject()); + se::Object *json = from.toObject(); + auto* data = reinterpret_cast(json->getPrivateData()); + if (data) { + *to = *data; + return true; + } + se::Value field; + bool ok = true; + json->getProperty("set", &field, true); + if(!field.isNullOrUndefined()) { + ok &= sevalue_to_native(field, &(to->set), ctx); + } + json->getProperty("binding", &field, true); + if(!field.isNullOrUndefined()) { + ok &= sevalue_to_native(field, &(to->binding), ctx); + } + json->getProperty("name", &field, true); + if(!field.isNullOrUndefined()) { + ok &= sevalue_to_native(field, &(to->name), ctx); + } + json->getProperty("type", &field, true); + if(!field.isNullOrUndefined()) { + ok &= sevalue_to_native(field, &(to->type), ctx); + } + json->getProperty("count", &field, true); + if(!field.isNullOrUndefined()) { + ok &= sevalue_to_native(field, &(to->count), ctx); + } + json->getProperty("stageFlags", &field, true); + if(!field.isNullOrUndefined()) { + ok &= sevalue_to_native(field, &(to->stageFlags), ctx); + } + return ok; +} + +SE_DECLARE_FINALIZE_FUNC(js_cc_ITextureInfo_finalize) + +static bool js_assets_ITextureInfo_constructor(se::State& s) // NOLINT(readability-identifier-naming) +{ + CC_UNUSED bool ok = true; + const auto& args = s.args(); + size_t argc = args.size(); + + if(argc == 0) + { + auto *ptr = JSB_MAKE_PRIVATE_OBJECT(cc::ITextureInfo); + s.thisObject()->setPrivateObject(ptr); + return true; + } + + if(argc == 1 && args[0].isObject()) + { + se::Object *json = args[0].toObject(); + se::Value field; + auto *ptr = JSB_MAKE_PRIVATE_OBJECT(cc::ITextureInfo); + auto cobj = ptr->get(); + ok &= sevalue_to_native(args[0], cobj, s.thisObject()); + if(!ok) { + delete ptr; + SE_REPORT_ERROR("argument convertion error"); + return false; + } + s.thisObject()->setPrivateObject(ptr); + return true; + } + auto *ptr = JSB_MAKE_PRIVATE_OBJECT(cc::ITextureInfo); + auto cobj = ptr->get(); + if (argc > 0 && !args[0].isUndefined()) { + ok &= sevalue_to_native(args[0], &(cobj->set), nullptr); + } + if (argc > 1 && !args[1].isUndefined()) { + ok &= sevalue_to_native(args[1], &(cobj->binding), nullptr); + } + if (argc > 2 && !args[2].isUndefined()) { + ok &= sevalue_to_native(args[2], &(cobj->name), nullptr); + } + if (argc > 3 && !args[3].isUndefined()) { + ok &= sevalue_to_native(args[3], &(cobj->type), nullptr); + } + if (argc > 4 && !args[4].isUndefined()) { + ok &= sevalue_to_native(args[4], &(cobj->count), nullptr); + } + if (argc > 5 && !args[5].isUndefined()) { + ok &= sevalue_to_native(args[5], &(cobj->stageFlags), nullptr); + } + + if(!ok) { + delete ptr; + SE_REPORT_ERROR("Argument convertion error"); + return false; + } + s.thisObject()->setPrivateObject(ptr); + return true; +} +SE_BIND_CTOR(js_assets_ITextureInfo_constructor, __jsb_cc_ITextureInfo_class, js_cc_ITextureInfo_finalize) + +static bool js_cc_ITextureInfo_finalize(se::State& s) // NOLINT(readability-identifier-naming) +{ + return true; +} +SE_BIND_FINALIZE_FUNC(js_cc_ITextureInfo_finalize) + +bool js_register_assets_ITextureInfo(se::Object* obj) // NOLINT(readability-identifier-naming) +{ + auto* cls = se::Class::create("ITextureInfo", obj, nullptr, _SE(js_assets_ITextureInfo_constructor)); + + cls->defineProperty("set", _SE(js_assets_ITextureInfo_get_set), _SE(js_assets_ITextureInfo_set_set)); + cls->defineProperty("binding", _SE(js_assets_ITextureInfo_get_binding), _SE(js_assets_ITextureInfo_set_binding)); + cls->defineProperty("name", _SE(js_assets_ITextureInfo_get_name), _SE(js_assets_ITextureInfo_set_name)); + cls->defineProperty("type", _SE(js_assets_ITextureInfo_get_type), _SE(js_assets_ITextureInfo_set_type)); + cls->defineProperty("count", _SE(js_assets_ITextureInfo_get_count), _SE(js_assets_ITextureInfo_set_count)); + cls->defineProperty("stageFlags", _SE(js_assets_ITextureInfo_get_stageFlags), _SE(js_assets_ITextureInfo_set_stageFlags)); + cls->defineFinalizeFunction(_SE(js_cc_ITextureInfo_finalize)); + cls->install(); + JSBClassType::registerClass(cls); + + __jsb_cc_ITextureInfo_proto = cls->getProto(); + __jsb_cc_ITextureInfo_class = cls; + + + se::ScriptEngine::getInstance()->clearException(); + return true; +} +se::Object* __jsb_cc_ISamplerInfo_proto = nullptr; // NOLINT +se::Class* __jsb_cc_ISamplerInfo_class = nullptr; // NOLINT + +static bool js_assets_ISamplerInfo_get_set(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_assets_ISamplerInfo_get_set : Invalid Native Object"); + + CC_UNUSED bool ok = true; + se::Value jsret; + ok &= nativevalue_to_se(cobj->set, jsret, s.thisObject() /*ctx*/); + s.rval() = jsret; + SE_HOLD_RETURN_VALUE(cobj->set, s.thisObject(), s.rval()); + return true; +} +SE_BIND_PROP_GET(js_assets_ISamplerInfo_get_set) + +static bool js_assets_ISamplerInfo_set_set(se::State& s) // NOLINT(readability-identifier-naming) +{ + const auto& args = s.args(); + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_assets_ISamplerInfo_set_set : Invalid Native Object"); + + CC_UNUSED bool ok = true; + ok &= sevalue_to_native(args[0], &cobj->set, s.thisObject()); + SE_PRECONDITION2(ok, false, "js_assets_ISamplerInfo_set_set : Error processing new value"); + return true; +} +SE_BIND_PROP_SET(js_assets_ISamplerInfo_set_set) + +static bool js_assets_ISamplerInfo_get_binding(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_assets_ISamplerInfo_get_binding : Invalid Native Object"); + + CC_UNUSED bool ok = true; + se::Value jsret; + ok &= nativevalue_to_se(cobj->binding, jsret, s.thisObject() /*ctx*/); + s.rval() = jsret; + SE_HOLD_RETURN_VALUE(cobj->binding, s.thisObject(), s.rval()); + return true; +} +SE_BIND_PROP_GET(js_assets_ISamplerInfo_get_binding) + +static bool js_assets_ISamplerInfo_set_binding(se::State& s) // NOLINT(readability-identifier-naming) +{ + const auto& args = s.args(); + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_assets_ISamplerInfo_set_binding : Invalid Native Object"); + + CC_UNUSED bool ok = true; + ok &= sevalue_to_native(args[0], &cobj->binding, s.thisObject()); + SE_PRECONDITION2(ok, false, "js_assets_ISamplerInfo_set_binding : Error processing new value"); + return true; +} +SE_BIND_PROP_SET(js_assets_ISamplerInfo_set_binding) + +static bool js_assets_ISamplerInfo_get_name(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_assets_ISamplerInfo_get_name : Invalid Native Object"); + + CC_UNUSED bool ok = true; + se::Value jsret; + ok &= nativevalue_to_se(cobj->name, jsret, s.thisObject() /*ctx*/); + s.rval() = jsret; + SE_HOLD_RETURN_VALUE(cobj->name, s.thisObject(), s.rval()); + return true; +} +SE_BIND_PROP_GET(js_assets_ISamplerInfo_get_name) + +static bool js_assets_ISamplerInfo_set_name(se::State& s) // NOLINT(readability-identifier-naming) +{ + const auto& args = s.args(); + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_assets_ISamplerInfo_set_name : Invalid Native Object"); + + CC_UNUSED bool ok = true; + ok &= sevalue_to_native(args[0], &cobj->name, s.thisObject()); + SE_PRECONDITION2(ok, false, "js_assets_ISamplerInfo_set_name : Error processing new value"); + return true; +} +SE_BIND_PROP_SET(js_assets_ISamplerInfo_set_name) + +static bool js_assets_ISamplerInfo_get_count(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_assets_ISamplerInfo_get_count : Invalid Native Object"); + + CC_UNUSED bool ok = true; + se::Value jsret; + ok &= nativevalue_to_se(cobj->count, jsret, s.thisObject() /*ctx*/); + s.rval() = jsret; + SE_HOLD_RETURN_VALUE(cobj->count, s.thisObject(), s.rval()); + return true; +} +SE_BIND_PROP_GET(js_assets_ISamplerInfo_get_count) + +static bool js_assets_ISamplerInfo_set_count(se::State& s) // NOLINT(readability-identifier-naming) +{ + const auto& args = s.args(); + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_assets_ISamplerInfo_set_count : Invalid Native Object"); + + CC_UNUSED bool ok = true; + ok &= sevalue_to_native(args[0], &cobj->count, s.thisObject()); + SE_PRECONDITION2(ok, false, "js_assets_ISamplerInfo_set_count : Error processing new value"); + return true; +} +SE_BIND_PROP_SET(js_assets_ISamplerInfo_set_count) + +static bool js_assets_ISamplerInfo_get_stageFlags(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_assets_ISamplerInfo_get_stageFlags : Invalid Native Object"); + + CC_UNUSED bool ok = true; + se::Value jsret; + ok &= nativevalue_to_se(cobj->stageFlags, jsret, s.thisObject() /*ctx*/); + s.rval() = jsret; + SE_HOLD_RETURN_VALUE(cobj->stageFlags, s.thisObject(), s.rval()); + return true; +} +SE_BIND_PROP_GET(js_assets_ISamplerInfo_get_stageFlags) + +static bool js_assets_ISamplerInfo_set_stageFlags(se::State& s) // NOLINT(readability-identifier-naming) +{ + const auto& args = s.args(); + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_assets_ISamplerInfo_set_stageFlags : Invalid Native Object"); + + CC_UNUSED bool ok = true; + ok &= sevalue_to_native(args[0], &cobj->stageFlags, s.thisObject()); + SE_PRECONDITION2(ok, false, "js_assets_ISamplerInfo_set_stageFlags : Error processing new value"); + return true; +} +SE_BIND_PROP_SET(js_assets_ISamplerInfo_set_stageFlags) + + +template<> +bool sevalue_to_native(const se::Value &from, cc::ISamplerInfo * to, se::Object *ctx) +{ + assert(from.isObject()); + se::Object *json = from.toObject(); + auto* data = reinterpret_cast(json->getPrivateData()); + if (data) { + *to = *data; + return true; + } + se::Value field; + bool ok = true; + json->getProperty("set", &field, true); + if(!field.isNullOrUndefined()) { + ok &= sevalue_to_native(field, &(to->set), ctx); + } + json->getProperty("binding", &field, true); + if(!field.isNullOrUndefined()) { + ok &= sevalue_to_native(field, &(to->binding), ctx); + } + json->getProperty("name", &field, true); + if(!field.isNullOrUndefined()) { + ok &= sevalue_to_native(field, &(to->name), ctx); + } + json->getProperty("count", &field, true); + if(!field.isNullOrUndefined()) { + ok &= sevalue_to_native(field, &(to->count), ctx); + } + json->getProperty("stageFlags", &field, true); + if(!field.isNullOrUndefined()) { + ok &= sevalue_to_native(field, &(to->stageFlags), ctx); + } + return ok; +} + +SE_DECLARE_FINALIZE_FUNC(js_cc_ISamplerInfo_finalize) + +static bool js_assets_ISamplerInfo_constructor(se::State& s) // NOLINT(readability-identifier-naming) +{ + CC_UNUSED bool ok = true; + const auto& args = s.args(); + size_t argc = args.size(); + + if(argc == 0) + { + auto *ptr = JSB_MAKE_PRIVATE_OBJECT(cc::ISamplerInfo); + s.thisObject()->setPrivateObject(ptr); + return true; + } + + if(argc == 1 && args[0].isObject()) + { + se::Object *json = args[0].toObject(); + se::Value field; + auto *ptr = JSB_MAKE_PRIVATE_OBJECT(cc::ISamplerInfo); + auto cobj = ptr->get(); + ok &= sevalue_to_native(args[0], cobj, s.thisObject()); + if(!ok) { + delete ptr; + SE_REPORT_ERROR("argument convertion error"); + return false; + } + s.thisObject()->setPrivateObject(ptr); + return true; + } + auto *ptr = JSB_MAKE_PRIVATE_OBJECT(cc::ISamplerInfo); + auto cobj = ptr->get(); + if (argc > 0 && !args[0].isUndefined()) { + ok &= sevalue_to_native(args[0], &(cobj->set), nullptr); + } + if (argc > 1 && !args[1].isUndefined()) { + ok &= sevalue_to_native(args[1], &(cobj->binding), nullptr); + } + if (argc > 2 && !args[2].isUndefined()) { + ok &= sevalue_to_native(args[2], &(cobj->name), nullptr); + } + if (argc > 3 && !args[3].isUndefined()) { + ok &= sevalue_to_native(args[3], &(cobj->count), nullptr); + } + if (argc > 4 && !args[4].isUndefined()) { + ok &= sevalue_to_native(args[4], &(cobj->stageFlags), nullptr); + } + + if(!ok) { + delete ptr; + SE_REPORT_ERROR("Argument convertion error"); + return false; + } + s.thisObject()->setPrivateObject(ptr); + return true; +} +SE_BIND_CTOR(js_assets_ISamplerInfo_constructor, __jsb_cc_ISamplerInfo_class, js_cc_ISamplerInfo_finalize) + +static bool js_cc_ISamplerInfo_finalize(se::State& s) // NOLINT(readability-identifier-naming) +{ + return true; +} +SE_BIND_FINALIZE_FUNC(js_cc_ISamplerInfo_finalize) + +bool js_register_assets_ISamplerInfo(se::Object* obj) // NOLINT(readability-identifier-naming) +{ + auto* cls = se::Class::create("ISamplerInfo", obj, nullptr, _SE(js_assets_ISamplerInfo_constructor)); + + cls->defineProperty("set", _SE(js_assets_ISamplerInfo_get_set), _SE(js_assets_ISamplerInfo_set_set)); + cls->defineProperty("binding", _SE(js_assets_ISamplerInfo_get_binding), _SE(js_assets_ISamplerInfo_set_binding)); + cls->defineProperty("name", _SE(js_assets_ISamplerInfo_get_name), _SE(js_assets_ISamplerInfo_set_name)); + cls->defineProperty("count", _SE(js_assets_ISamplerInfo_get_count), _SE(js_assets_ISamplerInfo_set_count)); + cls->defineProperty("stageFlags", _SE(js_assets_ISamplerInfo_get_stageFlags), _SE(js_assets_ISamplerInfo_set_stageFlags)); + cls->defineFinalizeFunction(_SE(js_cc_ISamplerInfo_finalize)); + cls->install(); + JSBClassType::registerClass(cls); + + __jsb_cc_ISamplerInfo_proto = cls->getProto(); + __jsb_cc_ISamplerInfo_class = cls; + + + se::ScriptEngine::getInstance()->clearException(); + return true; +} +se::Object* __jsb_cc_IBufferInfo_proto = nullptr; // NOLINT +se::Class* __jsb_cc_IBufferInfo_class = nullptr; // NOLINT + +static bool js_assets_IBufferInfo_get_binding(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_assets_IBufferInfo_get_binding : Invalid Native Object"); + + CC_UNUSED bool ok = true; + se::Value jsret; + ok &= nativevalue_to_se(cobj->binding, jsret, s.thisObject() /*ctx*/); + s.rval() = jsret; + SE_HOLD_RETURN_VALUE(cobj->binding, s.thisObject(), s.rval()); + return true; +} +SE_BIND_PROP_GET(js_assets_IBufferInfo_get_binding) + +static bool js_assets_IBufferInfo_set_binding(se::State& s) // NOLINT(readability-identifier-naming) +{ + const auto& args = s.args(); + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_assets_IBufferInfo_set_binding : Invalid Native Object"); + + CC_UNUSED bool ok = true; + ok &= sevalue_to_native(args[0], &cobj->binding, s.thisObject()); + SE_PRECONDITION2(ok, false, "js_assets_IBufferInfo_set_binding : Error processing new value"); + return true; +} +SE_BIND_PROP_SET(js_assets_IBufferInfo_set_binding) + +static bool js_assets_IBufferInfo_get_name(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_assets_IBufferInfo_get_name : Invalid Native Object"); + + CC_UNUSED bool ok = true; + se::Value jsret; + ok &= nativevalue_to_se(cobj->name, jsret, s.thisObject() /*ctx*/); + s.rval() = jsret; + SE_HOLD_RETURN_VALUE(cobj->name, s.thisObject(), s.rval()); + return true; +} +SE_BIND_PROP_GET(js_assets_IBufferInfo_get_name) + +static bool js_assets_IBufferInfo_set_name(se::State& s) // NOLINT(readability-identifier-naming) +{ + const auto& args = s.args(); + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_assets_IBufferInfo_set_name : Invalid Native Object"); + + CC_UNUSED bool ok = true; + ok &= sevalue_to_native(args[0], &cobj->name, s.thisObject()); + SE_PRECONDITION2(ok, false, "js_assets_IBufferInfo_set_name : Error processing new value"); + return true; +} +SE_BIND_PROP_SET(js_assets_IBufferInfo_set_name) + +static bool js_assets_IBufferInfo_get_memoryAccess(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_assets_IBufferInfo_get_memoryAccess : Invalid Native Object"); + + CC_UNUSED bool ok = true; + se::Value jsret; + ok &= nativevalue_to_se(cobj->memoryAccess, jsret, s.thisObject() /*ctx*/); + s.rval() = jsret; + SE_HOLD_RETURN_VALUE(cobj->memoryAccess, s.thisObject(), s.rval()); + return true; +} +SE_BIND_PROP_GET(js_assets_IBufferInfo_get_memoryAccess) + +static bool js_assets_IBufferInfo_set_memoryAccess(se::State& s) // NOLINT(readability-identifier-naming) +{ + const auto& args = s.args(); + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_assets_IBufferInfo_set_memoryAccess : Invalid Native Object"); + + CC_UNUSED bool ok = true; + ok &= sevalue_to_native(args[0], &cobj->memoryAccess, s.thisObject()); + SE_PRECONDITION2(ok, false, "js_assets_IBufferInfo_set_memoryAccess : Error processing new value"); + return true; +} +SE_BIND_PROP_SET(js_assets_IBufferInfo_set_memoryAccess) + +static bool js_assets_IBufferInfo_get_stageFlags(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_assets_IBufferInfo_get_stageFlags : Invalid Native Object"); + + CC_UNUSED bool ok = true; + se::Value jsret; + ok &= nativevalue_to_se(cobj->stageFlags, jsret, s.thisObject() /*ctx*/); + s.rval() = jsret; + SE_HOLD_RETURN_VALUE(cobj->stageFlags, s.thisObject(), s.rval()); + return true; +} +SE_BIND_PROP_GET(js_assets_IBufferInfo_get_stageFlags) + +static bool js_assets_IBufferInfo_set_stageFlags(se::State& s) // NOLINT(readability-identifier-naming) +{ + const auto& args = s.args(); + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_assets_IBufferInfo_set_stageFlags : Invalid Native Object"); + + CC_UNUSED bool ok = true; + ok &= sevalue_to_native(args[0], &cobj->stageFlags, s.thisObject()); + SE_PRECONDITION2(ok, false, "js_assets_IBufferInfo_set_stageFlags : Error processing new value"); + return true; +} +SE_BIND_PROP_SET(js_assets_IBufferInfo_set_stageFlags) + + +template<> +bool sevalue_to_native(const se::Value &from, cc::IBufferInfo * to, se::Object *ctx) +{ + assert(from.isObject()); + se::Object *json = from.toObject(); + auto* data = reinterpret_cast(json->getPrivateData()); + if (data) { + *to = *data; + return true; + } + se::Value field; + bool ok = true; + json->getProperty("binding", &field, true); + if(!field.isNullOrUndefined()) { + ok &= sevalue_to_native(field, &(to->binding), ctx); + } + json->getProperty("name", &field, true); + if(!field.isNullOrUndefined()) { + ok &= sevalue_to_native(field, &(to->name), ctx); + } + json->getProperty("memoryAccess", &field, true); + if(!field.isNullOrUndefined()) { + ok &= sevalue_to_native(field, &(to->memoryAccess), ctx); + } + json->getProperty("stageFlags", &field, true); + if(!field.isNullOrUndefined()) { + ok &= sevalue_to_native(field, &(to->stageFlags), ctx); + } + return ok; +} + +SE_DECLARE_FINALIZE_FUNC(js_cc_IBufferInfo_finalize) + +static bool js_assets_IBufferInfo_constructor(se::State& s) // NOLINT(readability-identifier-naming) +{ + CC_UNUSED bool ok = true; + const auto& args = s.args(); + size_t argc = args.size(); + + if(argc == 0) + { + auto *ptr = JSB_MAKE_PRIVATE_OBJECT(cc::IBufferInfo); + s.thisObject()->setPrivateObject(ptr); + return true; + } + + if(argc == 1 && args[0].isObject()) + { + se::Object *json = args[0].toObject(); + se::Value field; + auto *ptr = JSB_MAKE_PRIVATE_OBJECT(cc::IBufferInfo); + auto cobj = ptr->get(); + ok &= sevalue_to_native(args[0], cobj, s.thisObject()); + if(!ok) { + delete ptr; + SE_REPORT_ERROR("argument convertion error"); + return false; + } + s.thisObject()->setPrivateObject(ptr); + return true; + } + auto *ptr = JSB_MAKE_PRIVATE_OBJECT(cc::IBufferInfo); + auto cobj = ptr->get(); + if (argc > 0 && !args[0].isUndefined()) { + ok &= sevalue_to_native(args[0], &(cobj->binding), nullptr); + } + if (argc > 1 && !args[1].isUndefined()) { + ok &= sevalue_to_native(args[1], &(cobj->name), nullptr); + } + if (argc > 2 && !args[2].isUndefined()) { + ok &= sevalue_to_native(args[2], &(cobj->memoryAccess), nullptr); + } + if (argc > 3 && !args[3].isUndefined()) { + ok &= sevalue_to_native(args[3], &(cobj->stageFlags), nullptr); + } + + if(!ok) { + delete ptr; + SE_REPORT_ERROR("Argument convertion error"); + return false; + } + s.thisObject()->setPrivateObject(ptr); + return true; +} +SE_BIND_CTOR(js_assets_IBufferInfo_constructor, __jsb_cc_IBufferInfo_class, js_cc_IBufferInfo_finalize) + +static bool js_cc_IBufferInfo_finalize(se::State& s) // NOLINT(readability-identifier-naming) +{ + return true; +} +SE_BIND_FINALIZE_FUNC(js_cc_IBufferInfo_finalize) + +bool js_register_assets_IBufferInfo(se::Object* obj) // NOLINT(readability-identifier-naming) +{ + auto* cls = se::Class::create("IBufferInfo", obj, nullptr, _SE(js_assets_IBufferInfo_constructor)); + + cls->defineProperty("binding", _SE(js_assets_IBufferInfo_get_binding), _SE(js_assets_IBufferInfo_set_binding)); + cls->defineProperty("name", _SE(js_assets_IBufferInfo_get_name), _SE(js_assets_IBufferInfo_set_name)); + cls->defineProperty("memoryAccess", _SE(js_assets_IBufferInfo_get_memoryAccess), _SE(js_assets_IBufferInfo_set_memoryAccess)); + cls->defineProperty("stageFlags", _SE(js_assets_IBufferInfo_get_stageFlags), _SE(js_assets_IBufferInfo_set_stageFlags)); + cls->defineFinalizeFunction(_SE(js_cc_IBufferInfo_finalize)); + cls->install(); + JSBClassType::registerClass(cls); + + __jsb_cc_IBufferInfo_proto = cls->getProto(); + __jsb_cc_IBufferInfo_class = cls; + + + se::ScriptEngine::getInstance()->clearException(); + return true; +} +se::Object* __jsb_cc_IImageInfo_proto = nullptr; // NOLINT +se::Class* __jsb_cc_IImageInfo_class = nullptr; // NOLINT + +static bool js_assets_IImageInfo_get_binding(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_assets_IImageInfo_get_binding : Invalid Native Object"); + + CC_UNUSED bool ok = true; + se::Value jsret; + ok &= nativevalue_to_se(cobj->binding, jsret, s.thisObject() /*ctx*/); + s.rval() = jsret; + SE_HOLD_RETURN_VALUE(cobj->binding, s.thisObject(), s.rval()); + return true; +} +SE_BIND_PROP_GET(js_assets_IImageInfo_get_binding) + +static bool js_assets_IImageInfo_set_binding(se::State& s) // NOLINT(readability-identifier-naming) +{ + const auto& args = s.args(); + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_assets_IImageInfo_set_binding : Invalid Native Object"); + + CC_UNUSED bool ok = true; + ok &= sevalue_to_native(args[0], &cobj->binding, s.thisObject()); + SE_PRECONDITION2(ok, false, "js_assets_IImageInfo_set_binding : Error processing new value"); + return true; +} +SE_BIND_PROP_SET(js_assets_IImageInfo_set_binding) + +static bool js_assets_IImageInfo_get_name(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_assets_IImageInfo_get_name : Invalid Native Object"); + + CC_UNUSED bool ok = true; + se::Value jsret; + ok &= nativevalue_to_se(cobj->name, jsret, s.thisObject() /*ctx*/); + s.rval() = jsret; + SE_HOLD_RETURN_VALUE(cobj->name, s.thisObject(), s.rval()); + return true; +} +SE_BIND_PROP_GET(js_assets_IImageInfo_get_name) + +static bool js_assets_IImageInfo_set_name(se::State& s) // NOLINT(readability-identifier-naming) +{ + const auto& args = s.args(); + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_assets_IImageInfo_set_name : Invalid Native Object"); + + CC_UNUSED bool ok = true; + ok &= sevalue_to_native(args[0], &cobj->name, s.thisObject()); + SE_PRECONDITION2(ok, false, "js_assets_IImageInfo_set_name : Error processing new value"); + return true; +} +SE_BIND_PROP_SET(js_assets_IImageInfo_set_name) + +static bool js_assets_IImageInfo_get_type(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_assets_IImageInfo_get_type : Invalid Native Object"); + + CC_UNUSED bool ok = true; + se::Value jsret; + ok &= nativevalue_to_se(cobj->type, jsret, s.thisObject() /*ctx*/); + s.rval() = jsret; + SE_HOLD_RETURN_VALUE(cobj->type, s.thisObject(), s.rval()); + return true; +} +SE_BIND_PROP_GET(js_assets_IImageInfo_get_type) + +static bool js_assets_IImageInfo_set_type(se::State& s) // NOLINT(readability-identifier-naming) +{ + const auto& args = s.args(); + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_assets_IImageInfo_set_type : Invalid Native Object"); + + CC_UNUSED bool ok = true; + ok &= sevalue_to_native(args[0], &cobj->type, s.thisObject()); + SE_PRECONDITION2(ok, false, "js_assets_IImageInfo_set_type : Error processing new value"); + return true; +} +SE_BIND_PROP_SET(js_assets_IImageInfo_set_type) + +static bool js_assets_IImageInfo_get_count(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_assets_IImageInfo_get_count : Invalid Native Object"); + + CC_UNUSED bool ok = true; + se::Value jsret; + ok &= nativevalue_to_se(cobj->count, jsret, s.thisObject() /*ctx*/); + s.rval() = jsret; + SE_HOLD_RETURN_VALUE(cobj->count, s.thisObject(), s.rval()); + return true; +} +SE_BIND_PROP_GET(js_assets_IImageInfo_get_count) + +static bool js_assets_IImageInfo_set_count(se::State& s) // NOLINT(readability-identifier-naming) +{ + const auto& args = s.args(); + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_assets_IImageInfo_set_count : Invalid Native Object"); + + CC_UNUSED bool ok = true; + ok &= sevalue_to_native(args[0], &cobj->count, s.thisObject()); + SE_PRECONDITION2(ok, false, "js_assets_IImageInfo_set_count : Error processing new value"); + return true; +} +SE_BIND_PROP_SET(js_assets_IImageInfo_set_count) + +static bool js_assets_IImageInfo_get_memoryAccess(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_assets_IImageInfo_get_memoryAccess : Invalid Native Object"); + + CC_UNUSED bool ok = true; + se::Value jsret; + ok &= nativevalue_to_se(cobj->memoryAccess, jsret, s.thisObject() /*ctx*/); + s.rval() = jsret; + SE_HOLD_RETURN_VALUE(cobj->memoryAccess, s.thisObject(), s.rval()); + return true; +} +SE_BIND_PROP_GET(js_assets_IImageInfo_get_memoryAccess) + +static bool js_assets_IImageInfo_set_memoryAccess(se::State& s) // NOLINT(readability-identifier-naming) +{ + const auto& args = s.args(); + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_assets_IImageInfo_set_memoryAccess : Invalid Native Object"); + + CC_UNUSED bool ok = true; + ok &= sevalue_to_native(args[0], &cobj->memoryAccess, s.thisObject()); + SE_PRECONDITION2(ok, false, "js_assets_IImageInfo_set_memoryAccess : Error processing new value"); + return true; +} +SE_BIND_PROP_SET(js_assets_IImageInfo_set_memoryAccess) + +static bool js_assets_IImageInfo_get_stageFlags(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_assets_IImageInfo_get_stageFlags : Invalid Native Object"); + + CC_UNUSED bool ok = true; + se::Value jsret; + ok &= nativevalue_to_se(cobj->stageFlags, jsret, s.thisObject() /*ctx*/); + s.rval() = jsret; + SE_HOLD_RETURN_VALUE(cobj->stageFlags, s.thisObject(), s.rval()); + return true; +} +SE_BIND_PROP_GET(js_assets_IImageInfo_get_stageFlags) + +static bool js_assets_IImageInfo_set_stageFlags(se::State& s) // NOLINT(readability-identifier-naming) +{ + const auto& args = s.args(); + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_assets_IImageInfo_set_stageFlags : Invalid Native Object"); + + CC_UNUSED bool ok = true; + ok &= sevalue_to_native(args[0], &cobj->stageFlags, s.thisObject()); + SE_PRECONDITION2(ok, false, "js_assets_IImageInfo_set_stageFlags : Error processing new value"); + return true; +} +SE_BIND_PROP_SET(js_assets_IImageInfo_set_stageFlags) + + +template<> +bool sevalue_to_native(const se::Value &from, cc::IImageInfo * to, se::Object *ctx) +{ + assert(from.isObject()); + se::Object *json = from.toObject(); + auto* data = reinterpret_cast(json->getPrivateData()); + if (data) { + *to = *data; + return true; + } + se::Value field; + bool ok = true; + json->getProperty("binding", &field, true); + if(!field.isNullOrUndefined()) { + ok &= sevalue_to_native(field, &(to->binding), ctx); + } + json->getProperty("name", &field, true); + if(!field.isNullOrUndefined()) { + ok &= sevalue_to_native(field, &(to->name), ctx); + } + json->getProperty("type", &field, true); + if(!field.isNullOrUndefined()) { + ok &= sevalue_to_native(field, &(to->type), ctx); + } + json->getProperty("count", &field, true); + if(!field.isNullOrUndefined()) { + ok &= sevalue_to_native(field, &(to->count), ctx); + } + json->getProperty("memoryAccess", &field, true); + if(!field.isNullOrUndefined()) { + ok &= sevalue_to_native(field, &(to->memoryAccess), ctx); + } + json->getProperty("stageFlags", &field, true); + if(!field.isNullOrUndefined()) { + ok &= sevalue_to_native(field, &(to->stageFlags), ctx); + } + return ok; +} + +SE_DECLARE_FINALIZE_FUNC(js_cc_IImageInfo_finalize) + +static bool js_assets_IImageInfo_constructor(se::State& s) // NOLINT(readability-identifier-naming) +{ + CC_UNUSED bool ok = true; + const auto& args = s.args(); + size_t argc = args.size(); + + if(argc == 0) + { + auto *ptr = JSB_MAKE_PRIVATE_OBJECT(cc::IImageInfo); + s.thisObject()->setPrivateObject(ptr); + return true; + } + + if(argc == 1 && args[0].isObject()) + { + se::Object *json = args[0].toObject(); + se::Value field; + auto *ptr = JSB_MAKE_PRIVATE_OBJECT(cc::IImageInfo); + auto cobj = ptr->get(); + ok &= sevalue_to_native(args[0], cobj, s.thisObject()); + if(!ok) { + delete ptr; + SE_REPORT_ERROR("argument convertion error"); + return false; + } + s.thisObject()->setPrivateObject(ptr); + return true; + } + auto *ptr = JSB_MAKE_PRIVATE_OBJECT(cc::IImageInfo); + auto cobj = ptr->get(); + if (argc > 0 && !args[0].isUndefined()) { + ok &= sevalue_to_native(args[0], &(cobj->binding), nullptr); + } + if (argc > 1 && !args[1].isUndefined()) { + ok &= sevalue_to_native(args[1], &(cobj->name), nullptr); + } + if (argc > 2 && !args[2].isUndefined()) { + ok &= sevalue_to_native(args[2], &(cobj->type), nullptr); + } + if (argc > 3 && !args[3].isUndefined()) { + ok &= sevalue_to_native(args[3], &(cobj->count), nullptr); + } + if (argc > 4 && !args[4].isUndefined()) { + ok &= sevalue_to_native(args[4], &(cobj->memoryAccess), nullptr); + } + if (argc > 5 && !args[5].isUndefined()) { + ok &= sevalue_to_native(args[5], &(cobj->stageFlags), nullptr); + } + + if(!ok) { + delete ptr; + SE_REPORT_ERROR("Argument convertion error"); + return false; + } + s.thisObject()->setPrivateObject(ptr); + return true; +} +SE_BIND_CTOR(js_assets_IImageInfo_constructor, __jsb_cc_IImageInfo_class, js_cc_IImageInfo_finalize) + +static bool js_cc_IImageInfo_finalize(se::State& s) // NOLINT(readability-identifier-naming) +{ + return true; +} +SE_BIND_FINALIZE_FUNC(js_cc_IImageInfo_finalize) + +bool js_register_assets_IImageInfo(se::Object* obj) // NOLINT(readability-identifier-naming) +{ + auto* cls = se::Class::create("IImageInfo", obj, nullptr, _SE(js_assets_IImageInfo_constructor)); + + cls->defineProperty("binding", _SE(js_assets_IImageInfo_get_binding), _SE(js_assets_IImageInfo_set_binding)); + cls->defineProperty("name", _SE(js_assets_IImageInfo_get_name), _SE(js_assets_IImageInfo_set_name)); + cls->defineProperty("type", _SE(js_assets_IImageInfo_get_type), _SE(js_assets_IImageInfo_set_type)); + cls->defineProperty("count", _SE(js_assets_IImageInfo_get_count), _SE(js_assets_IImageInfo_set_count)); + cls->defineProperty("memoryAccess", _SE(js_assets_IImageInfo_get_memoryAccess), _SE(js_assets_IImageInfo_set_memoryAccess)); + cls->defineProperty("stageFlags", _SE(js_assets_IImageInfo_get_stageFlags), _SE(js_assets_IImageInfo_set_stageFlags)); + cls->defineFinalizeFunction(_SE(js_cc_IImageInfo_finalize)); + cls->install(); + JSBClassType::registerClass(cls); + + __jsb_cc_IImageInfo_proto = cls->getProto(); + __jsb_cc_IImageInfo_class = cls; + + + se::ScriptEngine::getInstance()->clearException(); + return true; +} +se::Object* __jsb_cc_IInputAttachmentInfo_proto = nullptr; // NOLINT +se::Class* __jsb_cc_IInputAttachmentInfo_class = nullptr; // NOLINT + +static bool js_assets_IInputAttachmentInfo_get_set(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_assets_IInputAttachmentInfo_get_set : Invalid Native Object"); + + CC_UNUSED bool ok = true; + se::Value jsret; + ok &= nativevalue_to_se(cobj->set, jsret, s.thisObject() /*ctx*/); + s.rval() = jsret; + SE_HOLD_RETURN_VALUE(cobj->set, s.thisObject(), s.rval()); + return true; +} +SE_BIND_PROP_GET(js_assets_IInputAttachmentInfo_get_set) + +static bool js_assets_IInputAttachmentInfo_set_set(se::State& s) // NOLINT(readability-identifier-naming) +{ + const auto& args = s.args(); + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_assets_IInputAttachmentInfo_set_set : Invalid Native Object"); + + CC_UNUSED bool ok = true; + ok &= sevalue_to_native(args[0], &cobj->set, s.thisObject()); + SE_PRECONDITION2(ok, false, "js_assets_IInputAttachmentInfo_set_set : Error processing new value"); + return true; +} +SE_BIND_PROP_SET(js_assets_IInputAttachmentInfo_set_set) + +static bool js_assets_IInputAttachmentInfo_get_binding(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_assets_IInputAttachmentInfo_get_binding : Invalid Native Object"); + + CC_UNUSED bool ok = true; + se::Value jsret; + ok &= nativevalue_to_se(cobj->binding, jsret, s.thisObject() /*ctx*/); + s.rval() = jsret; + SE_HOLD_RETURN_VALUE(cobj->binding, s.thisObject(), s.rval()); + return true; +} +SE_BIND_PROP_GET(js_assets_IInputAttachmentInfo_get_binding) + +static bool js_assets_IInputAttachmentInfo_set_binding(se::State& s) // NOLINT(readability-identifier-naming) +{ + const auto& args = s.args(); + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_assets_IInputAttachmentInfo_set_binding : Invalid Native Object"); + + CC_UNUSED bool ok = true; + ok &= sevalue_to_native(args[0], &cobj->binding, s.thisObject()); + SE_PRECONDITION2(ok, false, "js_assets_IInputAttachmentInfo_set_binding : Error processing new value"); + return true; +} +SE_BIND_PROP_SET(js_assets_IInputAttachmentInfo_set_binding) + +static bool js_assets_IInputAttachmentInfo_get_name(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_assets_IInputAttachmentInfo_get_name : Invalid Native Object"); + + CC_UNUSED bool ok = true; + se::Value jsret; + ok &= nativevalue_to_se(cobj->name, jsret, s.thisObject() /*ctx*/); + s.rval() = jsret; + SE_HOLD_RETURN_VALUE(cobj->name, s.thisObject(), s.rval()); + return true; +} +SE_BIND_PROP_GET(js_assets_IInputAttachmentInfo_get_name) + +static bool js_assets_IInputAttachmentInfo_set_name(se::State& s) // NOLINT(readability-identifier-naming) +{ + const auto& args = s.args(); + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_assets_IInputAttachmentInfo_set_name : Invalid Native Object"); + + CC_UNUSED bool ok = true; + ok &= sevalue_to_native(args[0], &cobj->name, s.thisObject()); + SE_PRECONDITION2(ok, false, "js_assets_IInputAttachmentInfo_set_name : Error processing new value"); + return true; +} +SE_BIND_PROP_SET(js_assets_IInputAttachmentInfo_set_name) + +static bool js_assets_IInputAttachmentInfo_get_count(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_assets_IInputAttachmentInfo_get_count : Invalid Native Object"); + + CC_UNUSED bool ok = true; + se::Value jsret; + ok &= nativevalue_to_se(cobj->count, jsret, s.thisObject() /*ctx*/); + s.rval() = jsret; + SE_HOLD_RETURN_VALUE(cobj->count, s.thisObject(), s.rval()); + return true; +} +SE_BIND_PROP_GET(js_assets_IInputAttachmentInfo_get_count) + +static bool js_assets_IInputAttachmentInfo_set_count(se::State& s) // NOLINT(readability-identifier-naming) +{ + const auto& args = s.args(); + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_assets_IInputAttachmentInfo_set_count : Invalid Native Object"); + + CC_UNUSED bool ok = true; + ok &= sevalue_to_native(args[0], &cobj->count, s.thisObject()); + SE_PRECONDITION2(ok, false, "js_assets_IInputAttachmentInfo_set_count : Error processing new value"); + return true; +} +SE_BIND_PROP_SET(js_assets_IInputAttachmentInfo_set_count) + +static bool js_assets_IInputAttachmentInfo_get_stageFlags(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_assets_IInputAttachmentInfo_get_stageFlags : Invalid Native Object"); + + CC_UNUSED bool ok = true; + se::Value jsret; + ok &= nativevalue_to_se(cobj->stageFlags, jsret, s.thisObject() /*ctx*/); + s.rval() = jsret; + SE_HOLD_RETURN_VALUE(cobj->stageFlags, s.thisObject(), s.rval()); + return true; +} +SE_BIND_PROP_GET(js_assets_IInputAttachmentInfo_get_stageFlags) + +static bool js_assets_IInputAttachmentInfo_set_stageFlags(se::State& s) // NOLINT(readability-identifier-naming) +{ + const auto& args = s.args(); + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_assets_IInputAttachmentInfo_set_stageFlags : Invalid Native Object"); + + CC_UNUSED bool ok = true; + ok &= sevalue_to_native(args[0], &cobj->stageFlags, s.thisObject()); + SE_PRECONDITION2(ok, false, "js_assets_IInputAttachmentInfo_set_stageFlags : Error processing new value"); + return true; +} +SE_BIND_PROP_SET(js_assets_IInputAttachmentInfo_set_stageFlags) + + +template<> +bool sevalue_to_native(const se::Value &from, cc::IInputAttachmentInfo * to, se::Object *ctx) +{ + assert(from.isObject()); + se::Object *json = from.toObject(); + auto* data = reinterpret_cast(json->getPrivateData()); + if (data) { + *to = *data; + return true; + } + se::Value field; + bool ok = true; + json->getProperty("set", &field, true); + if(!field.isNullOrUndefined()) { + ok &= sevalue_to_native(field, &(to->set), ctx); + } + json->getProperty("binding", &field, true); + if(!field.isNullOrUndefined()) { + ok &= sevalue_to_native(field, &(to->binding), ctx); + } + json->getProperty("name", &field, true); + if(!field.isNullOrUndefined()) { + ok &= sevalue_to_native(field, &(to->name), ctx); + } + json->getProperty("count", &field, true); + if(!field.isNullOrUndefined()) { + ok &= sevalue_to_native(field, &(to->count), ctx); + } + json->getProperty("stageFlags", &field, true); + if(!field.isNullOrUndefined()) { + ok &= sevalue_to_native(field, &(to->stageFlags), ctx); + } + return ok; +} + +SE_DECLARE_FINALIZE_FUNC(js_cc_IInputAttachmentInfo_finalize) + +static bool js_assets_IInputAttachmentInfo_constructor(se::State& s) // NOLINT(readability-identifier-naming) +{ + CC_UNUSED bool ok = true; + const auto& args = s.args(); + size_t argc = args.size(); + + if(argc == 0) + { + auto *ptr = JSB_MAKE_PRIVATE_OBJECT(cc::IInputAttachmentInfo); + s.thisObject()->setPrivateObject(ptr); + return true; + } + + if(argc == 1 && args[0].isObject()) + { + se::Object *json = args[0].toObject(); + se::Value field; + auto *ptr = JSB_MAKE_PRIVATE_OBJECT(cc::IInputAttachmentInfo); + auto cobj = ptr->get(); + ok &= sevalue_to_native(args[0], cobj, s.thisObject()); + if(!ok) { + delete ptr; + SE_REPORT_ERROR("argument convertion error"); + return false; + } + s.thisObject()->setPrivateObject(ptr); + return true; + } + auto *ptr = JSB_MAKE_PRIVATE_OBJECT(cc::IInputAttachmentInfo); + auto cobj = ptr->get(); + if (argc > 0 && !args[0].isUndefined()) { + ok &= sevalue_to_native(args[0], &(cobj->set), nullptr); + } + if (argc > 1 && !args[1].isUndefined()) { + ok &= sevalue_to_native(args[1], &(cobj->binding), nullptr); + } + if (argc > 2 && !args[2].isUndefined()) { + ok &= sevalue_to_native(args[2], &(cobj->name), nullptr); + } + if (argc > 3 && !args[3].isUndefined()) { + ok &= sevalue_to_native(args[3], &(cobj->count), nullptr); + } + if (argc > 4 && !args[4].isUndefined()) { + ok &= sevalue_to_native(args[4], &(cobj->stageFlags), nullptr); + } + + if(!ok) { + delete ptr; + SE_REPORT_ERROR("Argument convertion error"); + return false; + } + s.thisObject()->setPrivateObject(ptr); + return true; +} +SE_BIND_CTOR(js_assets_IInputAttachmentInfo_constructor, __jsb_cc_IInputAttachmentInfo_class, js_cc_IInputAttachmentInfo_finalize) + +static bool js_cc_IInputAttachmentInfo_finalize(se::State& s) // NOLINT(readability-identifier-naming) +{ + return true; +} +SE_BIND_FINALIZE_FUNC(js_cc_IInputAttachmentInfo_finalize) + +bool js_register_assets_IInputAttachmentInfo(se::Object* obj) // NOLINT(readability-identifier-naming) +{ + auto* cls = se::Class::create("IInputAttachmentInfo", obj, nullptr, _SE(js_assets_IInputAttachmentInfo_constructor)); + + cls->defineProperty("set", _SE(js_assets_IInputAttachmentInfo_get_set), _SE(js_assets_IInputAttachmentInfo_set_set)); + cls->defineProperty("binding", _SE(js_assets_IInputAttachmentInfo_get_binding), _SE(js_assets_IInputAttachmentInfo_set_binding)); + cls->defineProperty("name", _SE(js_assets_IInputAttachmentInfo_get_name), _SE(js_assets_IInputAttachmentInfo_set_name)); + cls->defineProperty("count", _SE(js_assets_IInputAttachmentInfo_get_count), _SE(js_assets_IInputAttachmentInfo_set_count)); + cls->defineProperty("stageFlags", _SE(js_assets_IInputAttachmentInfo_get_stageFlags), _SE(js_assets_IInputAttachmentInfo_set_stageFlags)); + cls->defineFinalizeFunction(_SE(js_cc_IInputAttachmentInfo_finalize)); + cls->install(); + JSBClassType::registerClass(cls); + + __jsb_cc_IInputAttachmentInfo_proto = cls->getProto(); + __jsb_cc_IInputAttachmentInfo_class = cls; + + + se::ScriptEngine::getInstance()->clearException(); + return true; +} +se::Object* __jsb_cc_IAttributeInfo_proto = nullptr; // NOLINT +se::Class* __jsb_cc_IAttributeInfo_class = nullptr; // NOLINT + +static bool js_assets_IAttributeInfo_get_name(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_assets_IAttributeInfo_get_name : Invalid Native Object"); + + CC_UNUSED bool ok = true; + se::Value jsret; + ok &= nativevalue_to_se(cobj->name, jsret, s.thisObject() /*ctx*/); + s.rval() = jsret; + SE_HOLD_RETURN_VALUE(cobj->name, s.thisObject(), s.rval()); + return true; +} +SE_BIND_PROP_GET(js_assets_IAttributeInfo_get_name) + +static bool js_assets_IAttributeInfo_set_name(se::State& s) // NOLINT(readability-identifier-naming) +{ + const auto& args = s.args(); + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_assets_IAttributeInfo_set_name : Invalid Native Object"); + + CC_UNUSED bool ok = true; + ok &= sevalue_to_native(args[0], &cobj->name, s.thisObject()); + SE_PRECONDITION2(ok, false, "js_assets_IAttributeInfo_set_name : Error processing new value"); + return true; +} +SE_BIND_PROP_SET(js_assets_IAttributeInfo_set_name) + +static bool js_assets_IAttributeInfo_get_format(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_assets_IAttributeInfo_get_format : Invalid Native Object"); + + CC_UNUSED bool ok = true; + se::Value jsret; + ok &= nativevalue_to_se(cobj->format, jsret, s.thisObject() /*ctx*/); + s.rval() = jsret; + SE_HOLD_RETURN_VALUE(cobj->format, s.thisObject(), s.rval()); + return true; +} +SE_BIND_PROP_GET(js_assets_IAttributeInfo_get_format) + +static bool js_assets_IAttributeInfo_set_format(se::State& s) // NOLINT(readability-identifier-naming) +{ + const auto& args = s.args(); + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_assets_IAttributeInfo_set_format : Invalid Native Object"); + + CC_UNUSED bool ok = true; + ok &= sevalue_to_native(args[0], &cobj->format, s.thisObject()); + SE_PRECONDITION2(ok, false, "js_assets_IAttributeInfo_set_format : Error processing new value"); + return true; +} +SE_BIND_PROP_SET(js_assets_IAttributeInfo_set_format) + +static bool js_assets_IAttributeInfo_get_isNormalized(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_assets_IAttributeInfo_get_isNormalized : Invalid Native Object"); + + CC_UNUSED bool ok = true; + se::Value jsret; + ok &= nativevalue_to_se(cobj->isNormalized, jsret, s.thisObject() /*ctx*/); + s.rval() = jsret; + SE_HOLD_RETURN_VALUE(cobj->isNormalized, s.thisObject(), s.rval()); + return true; +} +SE_BIND_PROP_GET(js_assets_IAttributeInfo_get_isNormalized) + +static bool js_assets_IAttributeInfo_set_isNormalized(se::State& s) // NOLINT(readability-identifier-naming) +{ + const auto& args = s.args(); + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_assets_IAttributeInfo_set_isNormalized : Invalid Native Object"); + + CC_UNUSED bool ok = true; + ok &= sevalue_to_native(args[0], &cobj->isNormalized, s.thisObject()); + SE_PRECONDITION2(ok, false, "js_assets_IAttributeInfo_set_isNormalized : Error processing new value"); + return true; +} +SE_BIND_PROP_SET(js_assets_IAttributeInfo_set_isNormalized) + +static bool js_assets_IAttributeInfo_get_stream(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_assets_IAttributeInfo_get_stream : Invalid Native Object"); + + CC_UNUSED bool ok = true; + se::Value jsret; + ok &= nativevalue_to_se(cobj->stream, jsret, s.thisObject() /*ctx*/); + s.rval() = jsret; + SE_HOLD_RETURN_VALUE(cobj->stream, s.thisObject(), s.rval()); + return true; +} +SE_BIND_PROP_GET(js_assets_IAttributeInfo_get_stream) + +static bool js_assets_IAttributeInfo_set_stream(se::State& s) // NOLINT(readability-identifier-naming) +{ + const auto& args = s.args(); + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_assets_IAttributeInfo_set_stream : Invalid Native Object"); + + CC_UNUSED bool ok = true; + ok &= sevalue_to_native(args[0], &cobj->stream, s.thisObject()); + SE_PRECONDITION2(ok, false, "js_assets_IAttributeInfo_set_stream : Error processing new value"); + return true; +} +SE_BIND_PROP_SET(js_assets_IAttributeInfo_set_stream) + +static bool js_assets_IAttributeInfo_get_isInstanced(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_assets_IAttributeInfo_get_isInstanced : Invalid Native Object"); + + CC_UNUSED bool ok = true; + se::Value jsret; + ok &= nativevalue_to_se(cobj->isInstanced, jsret, s.thisObject() /*ctx*/); + s.rval() = jsret; + SE_HOLD_RETURN_VALUE(cobj->isInstanced, s.thisObject(), s.rval()); + return true; +} +SE_BIND_PROP_GET(js_assets_IAttributeInfo_get_isInstanced) + +static bool js_assets_IAttributeInfo_set_isInstanced(se::State& s) // NOLINT(readability-identifier-naming) +{ + const auto& args = s.args(); + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_assets_IAttributeInfo_set_isInstanced : Invalid Native Object"); + + CC_UNUSED bool ok = true; + ok &= sevalue_to_native(args[0], &cobj->isInstanced, s.thisObject()); + SE_PRECONDITION2(ok, false, "js_assets_IAttributeInfo_set_isInstanced : Error processing new value"); + return true; +} +SE_BIND_PROP_SET(js_assets_IAttributeInfo_set_isInstanced) + +static bool js_assets_IAttributeInfo_get_location(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_assets_IAttributeInfo_get_location : Invalid Native Object"); + + CC_UNUSED bool ok = true; + se::Value jsret; + ok &= nativevalue_to_se(cobj->location, jsret, s.thisObject() /*ctx*/); + s.rval() = jsret; + SE_HOLD_RETURN_VALUE(cobj->location, s.thisObject(), s.rval()); + return true; +} +SE_BIND_PROP_GET(js_assets_IAttributeInfo_get_location) + +static bool js_assets_IAttributeInfo_set_location(se::State& s) // NOLINT(readability-identifier-naming) +{ + const auto& args = s.args(); + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_assets_IAttributeInfo_set_location : Invalid Native Object"); + + CC_UNUSED bool ok = true; + ok &= sevalue_to_native(args[0], &cobj->location, s.thisObject()); + SE_PRECONDITION2(ok, false, "js_assets_IAttributeInfo_set_location : Error processing new value"); + return true; +} +SE_BIND_PROP_SET(js_assets_IAttributeInfo_set_location) + +static bool js_assets_IAttributeInfo_get_defines(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_assets_IAttributeInfo_get_defines : Invalid Native Object"); + + CC_UNUSED bool ok = true; + se::Value jsret; + ok &= nativevalue_to_se(cobj->defines, jsret, s.thisObject() /*ctx*/); + s.rval() = jsret; + SE_HOLD_RETURN_VALUE(cobj->defines, s.thisObject(), s.rval()); + return true; +} +SE_BIND_PROP_GET(js_assets_IAttributeInfo_get_defines) + +static bool js_assets_IAttributeInfo_set_defines(se::State& s) // NOLINT(readability-identifier-naming) +{ + const auto& args = s.args(); + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_assets_IAttributeInfo_set_defines : Invalid Native Object"); + + CC_UNUSED bool ok = true; + ok &= sevalue_to_native(args[0], &cobj->defines, s.thisObject()); + SE_PRECONDITION2(ok, false, "js_assets_IAttributeInfo_set_defines : Error processing new value"); + return true; +} +SE_BIND_PROP_SET(js_assets_IAttributeInfo_set_defines) + + +template<> +bool sevalue_to_native(const se::Value &from, cc::IAttributeInfo * to, se::Object *ctx) +{ + assert(from.isObject()); + se::Object *json = from.toObject(); + auto* data = reinterpret_cast(json->getPrivateData()); + if (data) { + *to = *data; + return true; + } + se::Value field; + bool ok = true; + json->getProperty("name", &field, true); + if(!field.isNullOrUndefined()) { + ok &= sevalue_to_native(field, &(to->name), ctx); + } + json->getProperty("format", &field, true); + if(!field.isNullOrUndefined()) { + ok &= sevalue_to_native(field, &(to->format), ctx); + } + json->getProperty("isNormalized", &field, true); + if(!field.isNullOrUndefined()) { + ok &= sevalue_to_native(field, &(to->isNormalized), ctx); + } + json->getProperty("stream", &field, true); + if(!field.isNullOrUndefined()) { + ok &= sevalue_to_native(field, &(to->stream), ctx); + } + json->getProperty("isInstanced", &field, true); + if(!field.isNullOrUndefined()) { + ok &= sevalue_to_native(field, &(to->isInstanced), ctx); + } + json->getProperty("location", &field, true); + if(!field.isNullOrUndefined()) { + ok &= sevalue_to_native(field, &(to->location), ctx); + } + json->getProperty("defines", &field, true); + if(!field.isNullOrUndefined()) { + ok &= sevalue_to_native(field, &(to->defines), ctx); + } + return ok; +} + +SE_DECLARE_FINALIZE_FUNC(js_cc_IAttributeInfo_finalize) + +static bool js_assets_IAttributeInfo_constructor(se::State& s) // NOLINT(readability-identifier-naming) +{ + CC_UNUSED bool ok = true; + const auto& args = s.args(); + size_t argc = args.size(); + + if(argc == 0) + { + auto *ptr = JSB_MAKE_PRIVATE_OBJECT(cc::IAttributeInfo); + s.thisObject()->setPrivateObject(ptr); + return true; + } + + if(argc == 1 && args[0].isObject()) + { + se::Object *json = args[0].toObject(); + se::Value field; + auto *ptr = JSB_MAKE_PRIVATE_OBJECT(cc::IAttributeInfo); + auto cobj = ptr->get(); + ok &= sevalue_to_native(args[0], cobj, s.thisObject()); + if(!ok) { + delete ptr; + SE_REPORT_ERROR("argument convertion error"); + return false; + } + s.thisObject()->setPrivateObject(ptr); + return true; + } + auto *ptr = JSB_MAKE_PRIVATE_OBJECT(cc::IAttributeInfo); + auto cobj = ptr->get(); + if (argc > 0 && !args[0].isUndefined()) { + ok &= sevalue_to_native(args[0], &(cobj->name), nullptr); + } + if (argc > 1 && !args[1].isUndefined()) { + ok &= sevalue_to_native(args[1], &(cobj->format), nullptr); + } + if (argc > 2 && !args[2].isUndefined()) { + ok &= sevalue_to_native(args[2], &(cobj->isNormalized), nullptr); + } + if (argc > 3 && !args[3].isUndefined()) { + ok &= sevalue_to_native(args[3], &(cobj->stream), nullptr); + } + if (argc > 4 && !args[4].isUndefined()) { + ok &= sevalue_to_native(args[4], &(cobj->isInstanced), nullptr); + } + if (argc > 5 && !args[5].isUndefined()) { + ok &= sevalue_to_native(args[5], &(cobj->location), nullptr); + } + if (argc > 6 && !args[6].isUndefined()) { + ok &= sevalue_to_native(args[6], &(cobj->defines), nullptr); + } + + if(!ok) { + delete ptr; + SE_REPORT_ERROR("Argument convertion error"); + return false; + } + s.thisObject()->setPrivateObject(ptr); + return true; +} +SE_BIND_CTOR(js_assets_IAttributeInfo_constructor, __jsb_cc_IAttributeInfo_class, js_cc_IAttributeInfo_finalize) + +static bool js_cc_IAttributeInfo_finalize(se::State& s) // NOLINT(readability-identifier-naming) +{ + return true; +} +SE_BIND_FINALIZE_FUNC(js_cc_IAttributeInfo_finalize) + +bool js_register_assets_IAttributeInfo(se::Object* obj) // NOLINT(readability-identifier-naming) +{ + auto* cls = se::Class::create("IAttributeInfo", obj, nullptr, _SE(js_assets_IAttributeInfo_constructor)); + + cls->defineProperty("name", _SE(js_assets_IAttributeInfo_get_name), _SE(js_assets_IAttributeInfo_set_name)); + cls->defineProperty("format", _SE(js_assets_IAttributeInfo_get_format), _SE(js_assets_IAttributeInfo_set_format)); + cls->defineProperty("isNormalized", _SE(js_assets_IAttributeInfo_get_isNormalized), _SE(js_assets_IAttributeInfo_set_isNormalized)); + cls->defineProperty("stream", _SE(js_assets_IAttributeInfo_get_stream), _SE(js_assets_IAttributeInfo_set_stream)); + cls->defineProperty("isInstanced", _SE(js_assets_IAttributeInfo_get_isInstanced), _SE(js_assets_IAttributeInfo_set_isInstanced)); + cls->defineProperty("location", _SE(js_assets_IAttributeInfo_get_location), _SE(js_assets_IAttributeInfo_set_location)); + cls->defineProperty("defines", _SE(js_assets_IAttributeInfo_get_defines), _SE(js_assets_IAttributeInfo_set_defines)); + cls->defineFinalizeFunction(_SE(js_cc_IAttributeInfo_finalize)); + cls->install(); + JSBClassType::registerClass(cls); + + __jsb_cc_IAttributeInfo_proto = cls->getProto(); + __jsb_cc_IAttributeInfo_class = cls; + + + se::ScriptEngine::getInstance()->clearException(); + return true; +} +se::Object* __jsb_cc_IDefineInfo_proto = nullptr; // NOLINT +se::Class* __jsb_cc_IDefineInfo_class = nullptr; // NOLINT + +static bool js_assets_IDefineInfo_get_name(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_assets_IDefineInfo_get_name : Invalid Native Object"); + + CC_UNUSED bool ok = true; + se::Value jsret; + ok &= nativevalue_to_se(cobj->name, jsret, s.thisObject() /*ctx*/); + s.rval() = jsret; + SE_HOLD_RETURN_VALUE(cobj->name, s.thisObject(), s.rval()); + return true; +} +SE_BIND_PROP_GET(js_assets_IDefineInfo_get_name) + +static bool js_assets_IDefineInfo_set_name(se::State& s) // NOLINT(readability-identifier-naming) +{ + const auto& args = s.args(); + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_assets_IDefineInfo_set_name : Invalid Native Object"); + + CC_UNUSED bool ok = true; + ok &= sevalue_to_native(args[0], &cobj->name, s.thisObject()); + SE_PRECONDITION2(ok, false, "js_assets_IDefineInfo_set_name : Error processing new value"); + return true; +} +SE_BIND_PROP_SET(js_assets_IDefineInfo_set_name) + +static bool js_assets_IDefineInfo_get_type(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_assets_IDefineInfo_get_type : Invalid Native Object"); + + CC_UNUSED bool ok = true; + se::Value jsret; + ok &= nativevalue_to_se(cobj->type, jsret, s.thisObject() /*ctx*/); + s.rval() = jsret; + SE_HOLD_RETURN_VALUE(cobj->type, s.thisObject(), s.rval()); + return true; +} +SE_BIND_PROP_GET(js_assets_IDefineInfo_get_type) + +static bool js_assets_IDefineInfo_set_type(se::State& s) // NOLINT(readability-identifier-naming) +{ + const auto& args = s.args(); + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_assets_IDefineInfo_set_type : Invalid Native Object"); + + CC_UNUSED bool ok = true; + ok &= sevalue_to_native(args[0], &cobj->type, s.thisObject()); + SE_PRECONDITION2(ok, false, "js_assets_IDefineInfo_set_type : Error processing new value"); + return true; +} +SE_BIND_PROP_SET(js_assets_IDefineInfo_set_type) + +static bool js_assets_IDefineInfo_get_range(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_assets_IDefineInfo_get_range : Invalid Native Object"); + + CC_UNUSED bool ok = true; + se::Value jsret; + ok &= nativevalue_to_se(cobj->range, jsret, s.thisObject() /*ctx*/); + s.rval() = jsret; + SE_HOLD_RETURN_VALUE(cobj->range, s.thisObject(), s.rval()); + return true; +} +SE_BIND_PROP_GET(js_assets_IDefineInfo_get_range) + +static bool js_assets_IDefineInfo_set_range(se::State& s) // NOLINT(readability-identifier-naming) +{ + const auto& args = s.args(); + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_assets_IDefineInfo_set_range : Invalid Native Object"); + + CC_UNUSED bool ok = true; + ok &= sevalue_to_native(args[0], &cobj->range, s.thisObject()); + SE_PRECONDITION2(ok, false, "js_assets_IDefineInfo_set_range : Error processing new value"); + return true; +} +SE_BIND_PROP_SET(js_assets_IDefineInfo_set_range) + +static bool js_assets_IDefineInfo_get_options(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_assets_IDefineInfo_get_options : Invalid Native Object"); + + CC_UNUSED bool ok = true; + se::Value jsret; + ok &= nativevalue_to_se(cobj->options, jsret, s.thisObject() /*ctx*/); + s.rval() = jsret; + SE_HOLD_RETURN_VALUE(cobj->options, s.thisObject(), s.rval()); + return true; +} +SE_BIND_PROP_GET(js_assets_IDefineInfo_get_options) + +static bool js_assets_IDefineInfo_set_options(se::State& s) // NOLINT(readability-identifier-naming) +{ + const auto& args = s.args(); + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_assets_IDefineInfo_set_options : Invalid Native Object"); + + CC_UNUSED bool ok = true; + ok &= sevalue_to_native(args[0], &cobj->options, s.thisObject()); + SE_PRECONDITION2(ok, false, "js_assets_IDefineInfo_set_options : Error processing new value"); + return true; +} +SE_BIND_PROP_SET(js_assets_IDefineInfo_set_options) + +static bool js_assets_IDefineInfo_get_defaultVal(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_assets_IDefineInfo_get_defaultVal : Invalid Native Object"); + + CC_UNUSED bool ok = true; + se::Value jsret; + ok &= nativevalue_to_se(cobj->defaultVal, jsret, s.thisObject() /*ctx*/); + s.rval() = jsret; + SE_HOLD_RETURN_VALUE(cobj->defaultVal, s.thisObject(), s.rval()); + return true; +} +SE_BIND_PROP_GET(js_assets_IDefineInfo_get_defaultVal) + +static bool js_assets_IDefineInfo_set_defaultVal(se::State& s) // NOLINT(readability-identifier-naming) +{ + const auto& args = s.args(); + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_assets_IDefineInfo_set_defaultVal : Invalid Native Object"); + + CC_UNUSED bool ok = true; + ok &= sevalue_to_native(args[0], &cobj->defaultVal, s.thisObject()); + SE_PRECONDITION2(ok, false, "js_assets_IDefineInfo_set_defaultVal : Error processing new value"); + return true; +} +SE_BIND_PROP_SET(js_assets_IDefineInfo_set_defaultVal) + + +template<> +bool sevalue_to_native(const se::Value &from, cc::IDefineInfo * to, se::Object *ctx) +{ + assert(from.isObject()); + se::Object *json = from.toObject(); + auto* data = reinterpret_cast(json->getPrivateData()); + if (data) { + *to = *data; + return true; + } + se::Value field; + bool ok = true; + json->getProperty("name", &field, true); + if(!field.isNullOrUndefined()) { + ok &= sevalue_to_native(field, &(to->name), ctx); + } + json->getProperty("type", &field, true); + if(!field.isNullOrUndefined()) { + ok &= sevalue_to_native(field, &(to->type), ctx); + } + json->getProperty("range", &field, true); + if(!field.isNullOrUndefined()) { + ok &= sevalue_to_native(field, &(to->range), ctx); + } + json->getProperty("options", &field, true); + if(!field.isNullOrUndefined()) { + ok &= sevalue_to_native(field, &(to->options), ctx); + } + json->getProperty("defaultVal", &field, true); + if(!field.isNullOrUndefined()) { + ok &= sevalue_to_native(field, &(to->defaultVal), ctx); + } + return ok; +} + +SE_DECLARE_FINALIZE_FUNC(js_cc_IDefineInfo_finalize) + +static bool js_assets_IDefineInfo_constructor(se::State& s) // NOLINT(readability-identifier-naming) +{ + CC_UNUSED bool ok = true; + const auto& args = s.args(); + size_t argc = args.size(); + + if(argc == 0) + { + auto *ptr = JSB_MAKE_PRIVATE_OBJECT(cc::IDefineInfo); + s.thisObject()->setPrivateObject(ptr); + return true; + } + + if(argc == 1 && args[0].isObject()) + { + se::Object *json = args[0].toObject(); + se::Value field; + auto *ptr = JSB_MAKE_PRIVATE_OBJECT(cc::IDefineInfo); + auto cobj = ptr->get(); + ok &= sevalue_to_native(args[0], cobj, s.thisObject()); + if(!ok) { + delete ptr; + SE_REPORT_ERROR("argument convertion error"); + return false; + } + s.thisObject()->setPrivateObject(ptr); + return true; + } + auto *ptr = JSB_MAKE_PRIVATE_OBJECT(cc::IDefineInfo); + auto cobj = ptr->get(); + if (argc > 0 && !args[0].isUndefined()) { + ok &= sevalue_to_native(args[0], &(cobj->name), nullptr); + } + if (argc > 1 && !args[1].isUndefined()) { + ok &= sevalue_to_native(args[1], &(cobj->type), nullptr); + } + if (argc > 2 && !args[2].isUndefined()) { + ok &= sevalue_to_native(args[2], &(cobj->range), nullptr); + } + if (argc > 3 && !args[3].isUndefined()) { + ok &= sevalue_to_native(args[3], &(cobj->options), nullptr); + } + if (argc > 4 && !args[4].isUndefined()) { + ok &= sevalue_to_native(args[4], &(cobj->defaultVal), nullptr); + } + + if(!ok) { + delete ptr; + SE_REPORT_ERROR("Argument convertion error"); + return false; + } + s.thisObject()->setPrivateObject(ptr); + return true; +} +SE_BIND_CTOR(js_assets_IDefineInfo_constructor, __jsb_cc_IDefineInfo_class, js_cc_IDefineInfo_finalize) + +static bool js_cc_IDefineInfo_finalize(se::State& s) // NOLINT(readability-identifier-naming) +{ + return true; +} +SE_BIND_FINALIZE_FUNC(js_cc_IDefineInfo_finalize) + +bool js_register_assets_IDefineInfo(se::Object* obj) // NOLINT(readability-identifier-naming) +{ + auto* cls = se::Class::create("IDefineInfo", obj, nullptr, _SE(js_assets_IDefineInfo_constructor)); + + cls->defineProperty("name", _SE(js_assets_IDefineInfo_get_name), _SE(js_assets_IDefineInfo_set_name)); + cls->defineProperty("type", _SE(js_assets_IDefineInfo_get_type), _SE(js_assets_IDefineInfo_set_type)); + cls->defineProperty("range", _SE(js_assets_IDefineInfo_get_range), _SE(js_assets_IDefineInfo_set_range)); + cls->defineProperty("options", _SE(js_assets_IDefineInfo_get_options), _SE(js_assets_IDefineInfo_set_options)); + cls->defineProperty("defaultVal", _SE(js_assets_IDefineInfo_get_defaultVal), _SE(js_assets_IDefineInfo_set_defaultVal)); + cls->defineFinalizeFunction(_SE(js_cc_IDefineInfo_finalize)); + cls->install(); + JSBClassType::registerClass(cls); + + __jsb_cc_IDefineInfo_proto = cls->getProto(); + __jsb_cc_IDefineInfo_class = cls; + + + se::ScriptEngine::getInstance()->clearException(); + return true; +} +se::Object* __jsb_cc_IBuiltin_proto = nullptr; // NOLINT +se::Class* __jsb_cc_IBuiltin_class = nullptr; // NOLINT + +static bool js_assets_IBuiltin_get_name(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_assets_IBuiltin_get_name : Invalid Native Object"); + + CC_UNUSED bool ok = true; + se::Value jsret; + ok &= nativevalue_to_se(cobj->name, jsret, s.thisObject() /*ctx*/); + s.rval() = jsret; + SE_HOLD_RETURN_VALUE(cobj->name, s.thisObject(), s.rval()); + return true; +} +SE_BIND_PROP_GET(js_assets_IBuiltin_get_name) + +static bool js_assets_IBuiltin_set_name(se::State& s) // NOLINT(readability-identifier-naming) +{ + const auto& args = s.args(); + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_assets_IBuiltin_set_name : Invalid Native Object"); + + CC_UNUSED bool ok = true; + ok &= sevalue_to_native(args[0], &cobj->name, s.thisObject()); + SE_PRECONDITION2(ok, false, "js_assets_IBuiltin_set_name : Error processing new value"); + return true; +} +SE_BIND_PROP_SET(js_assets_IBuiltin_set_name) + +static bool js_assets_IBuiltin_get_defines(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_assets_IBuiltin_get_defines : Invalid Native Object"); + + CC_UNUSED bool ok = true; + se::Value jsret; + ok &= nativevalue_to_se(cobj->defines, jsret, s.thisObject() /*ctx*/); + s.rval() = jsret; + SE_HOLD_RETURN_VALUE(cobj->defines, s.thisObject(), s.rval()); + return true; +} +SE_BIND_PROP_GET(js_assets_IBuiltin_get_defines) + +static bool js_assets_IBuiltin_set_defines(se::State& s) // NOLINT(readability-identifier-naming) +{ + const auto& args = s.args(); + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_assets_IBuiltin_set_defines : Invalid Native Object"); + + CC_UNUSED bool ok = true; + ok &= sevalue_to_native(args[0], &cobj->defines, s.thisObject()); + SE_PRECONDITION2(ok, false, "js_assets_IBuiltin_set_defines : Error processing new value"); + return true; +} +SE_BIND_PROP_SET(js_assets_IBuiltin_set_defines) + + +template<> +bool sevalue_to_native(const se::Value &from, cc::IBuiltin * to, se::Object *ctx) +{ + assert(from.isObject()); + se::Object *json = from.toObject(); + auto* data = reinterpret_cast(json->getPrivateData()); + if (data) { + *to = *data; + return true; + } + se::Value field; + bool ok = true; + json->getProperty("name", &field, true); + if(!field.isNullOrUndefined()) { + ok &= sevalue_to_native(field, &(to->name), ctx); + } + json->getProperty("defines", &field, true); + if(!field.isNullOrUndefined()) { + ok &= sevalue_to_native(field, &(to->defines), ctx); + } + return ok; +} + +SE_DECLARE_FINALIZE_FUNC(js_cc_IBuiltin_finalize) + +static bool js_assets_IBuiltin_constructor(se::State& s) // NOLINT(readability-identifier-naming) +{ + CC_UNUSED bool ok = true; + const auto& args = s.args(); + size_t argc = args.size(); + + if(argc == 0) + { + auto *ptr = JSB_MAKE_PRIVATE_OBJECT(cc::IBuiltin); + s.thisObject()->setPrivateObject(ptr); + return true; + } + + if(argc == 1 && args[0].isObject()) + { + se::Object *json = args[0].toObject(); + se::Value field; + auto *ptr = JSB_MAKE_PRIVATE_OBJECT(cc::IBuiltin); + auto cobj = ptr->get(); + ok &= sevalue_to_native(args[0], cobj, s.thisObject()); + if(!ok) { + delete ptr; + SE_REPORT_ERROR("argument convertion error"); + return false; + } + s.thisObject()->setPrivateObject(ptr); + return true; + } + auto *ptr = JSB_MAKE_PRIVATE_OBJECT(cc::IBuiltin); + auto cobj = ptr->get(); + if (argc > 0 && !args[0].isUndefined()) { + ok &= sevalue_to_native(args[0], &(cobj->name), nullptr); + } + if (argc > 1 && !args[1].isUndefined()) { + ok &= sevalue_to_native(args[1], &(cobj->defines), nullptr); + } + + if(!ok) { + delete ptr; + SE_REPORT_ERROR("Argument convertion error"); + return false; + } + s.thisObject()->setPrivateObject(ptr); + return true; +} +SE_BIND_CTOR(js_assets_IBuiltin_constructor, __jsb_cc_IBuiltin_class, js_cc_IBuiltin_finalize) + +static bool js_cc_IBuiltin_finalize(se::State& s) // NOLINT(readability-identifier-naming) +{ + return true; +} +SE_BIND_FINALIZE_FUNC(js_cc_IBuiltin_finalize) + +bool js_register_assets_IBuiltin(se::Object* obj) // NOLINT(readability-identifier-naming) +{ + auto* cls = se::Class::create("IBuiltin", obj, nullptr, _SE(js_assets_IBuiltin_constructor)); + + cls->defineProperty("name", _SE(js_assets_IBuiltin_get_name), _SE(js_assets_IBuiltin_set_name)); + cls->defineProperty("defines", _SE(js_assets_IBuiltin_get_defines), _SE(js_assets_IBuiltin_set_defines)); + cls->defineFinalizeFunction(_SE(js_cc_IBuiltin_finalize)); + cls->install(); + JSBClassType::registerClass(cls); + + __jsb_cc_IBuiltin_proto = cls->getProto(); + __jsb_cc_IBuiltin_class = cls; + + + se::ScriptEngine::getInstance()->clearException(); + return true; +} +se::Object* __jsb_cc_IBuiltinInfo_proto = nullptr; // NOLINT +se::Class* __jsb_cc_IBuiltinInfo_class = nullptr; // NOLINT + +static bool js_assets_IBuiltinInfo_get_buffers(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_assets_IBuiltinInfo_get_buffers : Invalid Native Object"); + + CC_UNUSED bool ok = true; + se::Value jsret; + ok &= nativevalue_to_se(cobj->buffers, jsret, s.thisObject() /*ctx*/); + s.rval() = jsret; + SE_HOLD_RETURN_VALUE(cobj->buffers, s.thisObject(), s.rval()); + return true; +} +SE_BIND_PROP_GET(js_assets_IBuiltinInfo_get_buffers) + +static bool js_assets_IBuiltinInfo_set_buffers(se::State& s) // NOLINT(readability-identifier-naming) +{ + const auto& args = s.args(); + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_assets_IBuiltinInfo_set_buffers : Invalid Native Object"); + + CC_UNUSED bool ok = true; + ok &= sevalue_to_native(args[0], &cobj->buffers, s.thisObject()); + SE_PRECONDITION2(ok, false, "js_assets_IBuiltinInfo_set_buffers : Error processing new value"); + return true; +} +SE_BIND_PROP_SET(js_assets_IBuiltinInfo_set_buffers) + +static bool js_assets_IBuiltinInfo_get_blocks(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_assets_IBuiltinInfo_get_blocks : Invalid Native Object"); + + CC_UNUSED bool ok = true; + se::Value jsret; + ok &= nativevalue_to_se(cobj->blocks, jsret, s.thisObject() /*ctx*/); + s.rval() = jsret; + SE_HOLD_RETURN_VALUE(cobj->blocks, s.thisObject(), s.rval()); + return true; +} +SE_BIND_PROP_GET(js_assets_IBuiltinInfo_get_blocks) + +static bool js_assets_IBuiltinInfo_set_blocks(se::State& s) // NOLINT(readability-identifier-naming) +{ + const auto& args = s.args(); + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_assets_IBuiltinInfo_set_blocks : Invalid Native Object"); + + CC_UNUSED bool ok = true; + ok &= sevalue_to_native(args[0], &cobj->blocks, s.thisObject()); + SE_PRECONDITION2(ok, false, "js_assets_IBuiltinInfo_set_blocks : Error processing new value"); + return true; +} +SE_BIND_PROP_SET(js_assets_IBuiltinInfo_set_blocks) + +static bool js_assets_IBuiltinInfo_get_samplerTextures(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_assets_IBuiltinInfo_get_samplerTextures : Invalid Native Object"); + + CC_UNUSED bool ok = true; + se::Value jsret; + ok &= nativevalue_to_se(cobj->samplerTextures, jsret, s.thisObject() /*ctx*/); + s.rval() = jsret; + SE_HOLD_RETURN_VALUE(cobj->samplerTextures, s.thisObject(), s.rval()); + return true; +} +SE_BIND_PROP_GET(js_assets_IBuiltinInfo_get_samplerTextures) + +static bool js_assets_IBuiltinInfo_set_samplerTextures(se::State& s) // NOLINT(readability-identifier-naming) +{ + const auto& args = s.args(); + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_assets_IBuiltinInfo_set_samplerTextures : Invalid Native Object"); + + CC_UNUSED bool ok = true; + ok &= sevalue_to_native(args[0], &cobj->samplerTextures, s.thisObject()); + SE_PRECONDITION2(ok, false, "js_assets_IBuiltinInfo_set_samplerTextures : Error processing new value"); + return true; +} +SE_BIND_PROP_SET(js_assets_IBuiltinInfo_set_samplerTextures) + +static bool js_assets_IBuiltinInfo_get_images(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_assets_IBuiltinInfo_get_images : Invalid Native Object"); + + CC_UNUSED bool ok = true; + se::Value jsret; + ok &= nativevalue_to_se(cobj->images, jsret, s.thisObject() /*ctx*/); + s.rval() = jsret; + SE_HOLD_RETURN_VALUE(cobj->images, s.thisObject(), s.rval()); + return true; +} +SE_BIND_PROP_GET(js_assets_IBuiltinInfo_get_images) + +static bool js_assets_IBuiltinInfo_set_images(se::State& s) // NOLINT(readability-identifier-naming) +{ + const auto& args = s.args(); + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_assets_IBuiltinInfo_set_images : Invalid Native Object"); + + CC_UNUSED bool ok = true; + ok &= sevalue_to_native(args[0], &cobj->images, s.thisObject()); + SE_PRECONDITION2(ok, false, "js_assets_IBuiltinInfo_set_images : Error processing new value"); + return true; +} +SE_BIND_PROP_SET(js_assets_IBuiltinInfo_set_images) + + +template<> +bool sevalue_to_native(const se::Value &from, cc::IBuiltinInfo * to, se::Object *ctx) +{ + assert(from.isObject()); + se::Object *json = from.toObject(); + auto* data = reinterpret_cast(json->getPrivateData()); + if (data) { + *to = *data; + return true; + } + se::Value field; + bool ok = true; + json->getProperty("buffers", &field, true); + if(!field.isNullOrUndefined()) { + ok &= sevalue_to_native(field, &(to->buffers), ctx); + } + json->getProperty("blocks", &field, true); + if(!field.isNullOrUndefined()) { + ok &= sevalue_to_native(field, &(to->blocks), ctx); + } + json->getProperty("samplerTextures", &field, true); + if(!field.isNullOrUndefined()) { + ok &= sevalue_to_native(field, &(to->samplerTextures), ctx); + } + json->getProperty("images", &field, true); + if(!field.isNullOrUndefined()) { + ok &= sevalue_to_native(field, &(to->images), ctx); + } + return ok; +} + +SE_DECLARE_FINALIZE_FUNC(js_cc_IBuiltinInfo_finalize) + +static bool js_assets_IBuiltinInfo_constructor(se::State& s) // NOLINT(readability-identifier-naming) +{ + CC_UNUSED bool ok = true; + const auto& args = s.args(); + size_t argc = args.size(); + + if(argc == 0) + { + auto *ptr = JSB_MAKE_PRIVATE_OBJECT(cc::IBuiltinInfo); + s.thisObject()->setPrivateObject(ptr); + return true; + } + + if(argc == 1 && args[0].isObject()) + { + se::Object *json = args[0].toObject(); + se::Value field; + auto *ptr = JSB_MAKE_PRIVATE_OBJECT(cc::IBuiltinInfo); + auto cobj = ptr->get(); + ok &= sevalue_to_native(args[0], cobj, s.thisObject()); + if(!ok) { + delete ptr; + SE_REPORT_ERROR("argument convertion error"); + return false; + } + s.thisObject()->setPrivateObject(ptr); + return true; + } + auto *ptr = JSB_MAKE_PRIVATE_OBJECT(cc::IBuiltinInfo); + auto cobj = ptr->get(); + if (argc > 0 && !args[0].isUndefined()) { + ok &= sevalue_to_native(args[0], &(cobj->buffers), nullptr); + } + if (argc > 1 && !args[1].isUndefined()) { + ok &= sevalue_to_native(args[1], &(cobj->blocks), nullptr); + } + if (argc > 2 && !args[2].isUndefined()) { + ok &= sevalue_to_native(args[2], &(cobj->samplerTextures), nullptr); + } + if (argc > 3 && !args[3].isUndefined()) { + ok &= sevalue_to_native(args[3], &(cobj->images), nullptr); + } + + if(!ok) { + delete ptr; + SE_REPORT_ERROR("Argument convertion error"); + return false; + } + s.thisObject()->setPrivateObject(ptr); + return true; +} +SE_BIND_CTOR(js_assets_IBuiltinInfo_constructor, __jsb_cc_IBuiltinInfo_class, js_cc_IBuiltinInfo_finalize) + +static bool js_cc_IBuiltinInfo_finalize(se::State& s) // NOLINT(readability-identifier-naming) +{ + return true; +} +SE_BIND_FINALIZE_FUNC(js_cc_IBuiltinInfo_finalize) + +bool js_register_assets_IBuiltinInfo(se::Object* obj) // NOLINT(readability-identifier-naming) +{ + auto* cls = se::Class::create("IBuiltinInfo", obj, nullptr, _SE(js_assets_IBuiltinInfo_constructor)); + + cls->defineProperty("buffers", _SE(js_assets_IBuiltinInfo_get_buffers), _SE(js_assets_IBuiltinInfo_set_buffers)); + cls->defineProperty("blocks", _SE(js_assets_IBuiltinInfo_get_blocks), _SE(js_assets_IBuiltinInfo_set_blocks)); + cls->defineProperty("samplerTextures", _SE(js_assets_IBuiltinInfo_get_samplerTextures), _SE(js_assets_IBuiltinInfo_set_samplerTextures)); + cls->defineProperty("images", _SE(js_assets_IBuiltinInfo_get_images), _SE(js_assets_IBuiltinInfo_set_images)); + cls->defineFinalizeFunction(_SE(js_cc_IBuiltinInfo_finalize)); + cls->install(); + JSBClassType::registerClass(cls); + + __jsb_cc_IBuiltinInfo_proto = cls->getProto(); + __jsb_cc_IBuiltinInfo_class = cls; + + + se::ScriptEngine::getInstance()->clearException(); + return true; +} +se::Object* __jsb_cc_IBuiltins_proto = nullptr; // NOLINT +se::Class* __jsb_cc_IBuiltins_class = nullptr; // NOLINT + +static bool js_assets_IBuiltins_get_globals(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_assets_IBuiltins_get_globals : Invalid Native Object"); + + CC_UNUSED bool ok = true; + se::Value jsret; + ok &= nativevalue_to_se(cobj->globals, jsret, s.thisObject() /*ctx*/); + s.rval() = jsret; + SE_HOLD_RETURN_VALUE(cobj->globals, s.thisObject(), s.rval()); + return true; +} +SE_BIND_PROP_GET(js_assets_IBuiltins_get_globals) + +static bool js_assets_IBuiltins_set_globals(se::State& s) // NOLINT(readability-identifier-naming) +{ + const auto& args = s.args(); + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_assets_IBuiltins_set_globals : Invalid Native Object"); + + CC_UNUSED bool ok = true; + ok &= sevalue_to_native(args[0], &cobj->globals, s.thisObject()); + SE_PRECONDITION2(ok, false, "js_assets_IBuiltins_set_globals : Error processing new value"); + return true; +} +SE_BIND_PROP_SET(js_assets_IBuiltins_set_globals) + +static bool js_assets_IBuiltins_get_locals(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_assets_IBuiltins_get_locals : Invalid Native Object"); + + CC_UNUSED bool ok = true; + se::Value jsret; + ok &= nativevalue_to_se(cobj->locals, jsret, s.thisObject() /*ctx*/); + s.rval() = jsret; + SE_HOLD_RETURN_VALUE(cobj->locals, s.thisObject(), s.rval()); + return true; +} +SE_BIND_PROP_GET(js_assets_IBuiltins_get_locals) + +static bool js_assets_IBuiltins_set_locals(se::State& s) // NOLINT(readability-identifier-naming) +{ + const auto& args = s.args(); + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_assets_IBuiltins_set_locals : Invalid Native Object"); + + CC_UNUSED bool ok = true; + ok &= sevalue_to_native(args[0], &cobj->locals, s.thisObject()); + SE_PRECONDITION2(ok, false, "js_assets_IBuiltins_set_locals : Error processing new value"); + return true; +} +SE_BIND_PROP_SET(js_assets_IBuiltins_set_locals) + +static bool js_assets_IBuiltins_get_statistics(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_assets_IBuiltins_get_statistics : Invalid Native Object"); + + CC_UNUSED bool ok = true; + se::Value jsret; + ok &= nativevalue_to_se(cobj->statistics, jsret, s.thisObject() /*ctx*/); + s.rval() = jsret; + SE_HOLD_RETURN_VALUE(cobj->statistics, s.thisObject(), s.rval()); + return true; +} +SE_BIND_PROP_GET(js_assets_IBuiltins_get_statistics) + +static bool js_assets_IBuiltins_set_statistics(se::State& s) // NOLINT(readability-identifier-naming) +{ + const auto& args = s.args(); + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_assets_IBuiltins_set_statistics : Invalid Native Object"); + + CC_UNUSED bool ok = true; + ok &= sevalue_to_native(args[0], &cobj->statistics, s.thisObject()); + SE_PRECONDITION2(ok, false, "js_assets_IBuiltins_set_statistics : Error processing new value"); + return true; +} +SE_BIND_PROP_SET(js_assets_IBuiltins_set_statistics) + + +template<> +bool sevalue_to_native(const se::Value &from, cc::IBuiltins * to, se::Object *ctx) +{ + assert(from.isObject()); + se::Object *json = from.toObject(); + auto* data = reinterpret_cast(json->getPrivateData()); + if (data) { + *to = *data; + return true; + } + se::Value field; + bool ok = true; + json->getProperty("globals", &field, true); + if(!field.isNullOrUndefined()) { + ok &= sevalue_to_native(field, &(to->globals), ctx); + } + json->getProperty("locals", &field, true); + if(!field.isNullOrUndefined()) { + ok &= sevalue_to_native(field, &(to->locals), ctx); + } + json->getProperty("statistics", &field, true); + if(!field.isNullOrUndefined()) { + ok &= sevalue_to_native(field, &(to->statistics), ctx); + } + return ok; +} + +SE_DECLARE_FINALIZE_FUNC(js_cc_IBuiltins_finalize) + +static bool js_assets_IBuiltins_constructor(se::State& s) // NOLINT(readability-identifier-naming) +{ + CC_UNUSED bool ok = true; + const auto& args = s.args(); + size_t argc = args.size(); + + if(argc == 0) + { + auto *ptr = JSB_MAKE_PRIVATE_OBJECT(cc::IBuiltins); + s.thisObject()->setPrivateObject(ptr); + return true; + } + + if(argc == 1 && args[0].isObject()) + { + se::Object *json = args[0].toObject(); + se::Value field; + auto *ptr = JSB_MAKE_PRIVATE_OBJECT(cc::IBuiltins); + auto cobj = ptr->get(); + ok &= sevalue_to_native(args[0], cobj, s.thisObject()); + if(!ok) { + delete ptr; + SE_REPORT_ERROR("argument convertion error"); + return false; + } + s.thisObject()->setPrivateObject(ptr); + return true; + } + auto *ptr = JSB_MAKE_PRIVATE_OBJECT(cc::IBuiltins); + auto cobj = ptr->get(); + if (argc > 0 && !args[0].isUndefined()) { + ok &= sevalue_to_native(args[0], &(cobj->globals), nullptr); + } + if (argc > 1 && !args[1].isUndefined()) { + ok &= sevalue_to_native(args[1], &(cobj->locals), nullptr); + } + if (argc > 2 && !args[2].isUndefined()) { + ok &= sevalue_to_native(args[2], &(cobj->statistics), nullptr); + } + + if(!ok) { + delete ptr; + SE_REPORT_ERROR("Argument convertion error"); + return false; + } + s.thisObject()->setPrivateObject(ptr); + return true; +} +SE_BIND_CTOR(js_assets_IBuiltins_constructor, __jsb_cc_IBuiltins_class, js_cc_IBuiltins_finalize) + +static bool js_cc_IBuiltins_finalize(se::State& s) // NOLINT(readability-identifier-naming) +{ + return true; +} +SE_BIND_FINALIZE_FUNC(js_cc_IBuiltins_finalize) + +bool js_register_assets_IBuiltins(se::Object* obj) // NOLINT(readability-identifier-naming) +{ + auto* cls = se::Class::create("IBuiltins", obj, nullptr, _SE(js_assets_IBuiltins_constructor)); + + cls->defineProperty("globals", _SE(js_assets_IBuiltins_get_globals), _SE(js_assets_IBuiltins_set_globals)); + cls->defineProperty("locals", _SE(js_assets_IBuiltins_get_locals), _SE(js_assets_IBuiltins_set_locals)); + cls->defineProperty("statistics", _SE(js_assets_IBuiltins_get_statistics), _SE(js_assets_IBuiltins_set_statistics)); + cls->defineFinalizeFunction(_SE(js_cc_IBuiltins_finalize)); + cls->install(); + JSBClassType::registerClass(cls); + + __jsb_cc_IBuiltins_proto = cls->getProto(); + __jsb_cc_IBuiltins_class = cls; + + + se::ScriptEngine::getInstance()->clearException(); + return true; +} +se::Object* __jsb_cc_IShaderSource_proto = nullptr; // NOLINT +se::Class* __jsb_cc_IShaderSource_class = nullptr; // NOLINT + +static bool js_assets_IShaderSource_get_vert(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_assets_IShaderSource_get_vert : Invalid Native Object"); + + CC_UNUSED bool ok = true; + se::Value jsret; + ok &= nativevalue_to_se(cobj->vert, jsret, s.thisObject() /*ctx*/); + s.rval() = jsret; + SE_HOLD_RETURN_VALUE(cobj->vert, s.thisObject(), s.rval()); + return true; +} +SE_BIND_PROP_GET(js_assets_IShaderSource_get_vert) + +static bool js_assets_IShaderSource_set_vert(se::State& s) // NOLINT(readability-identifier-naming) +{ + const auto& args = s.args(); + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_assets_IShaderSource_set_vert : Invalid Native Object"); + + CC_UNUSED bool ok = true; + ok &= sevalue_to_native(args[0], &cobj->vert, s.thisObject()); + SE_PRECONDITION2(ok, false, "js_assets_IShaderSource_set_vert : Error processing new value"); + return true; +} +SE_BIND_PROP_SET(js_assets_IShaderSource_set_vert) + +static bool js_assets_IShaderSource_get_frag(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_assets_IShaderSource_get_frag : Invalid Native Object"); + + CC_UNUSED bool ok = true; + se::Value jsret; + ok &= nativevalue_to_se(cobj->frag, jsret, s.thisObject() /*ctx*/); + s.rval() = jsret; + SE_HOLD_RETURN_VALUE(cobj->frag, s.thisObject(), s.rval()); + return true; +} +SE_BIND_PROP_GET(js_assets_IShaderSource_get_frag) + +static bool js_assets_IShaderSource_set_frag(se::State& s) // NOLINT(readability-identifier-naming) +{ + const auto& args = s.args(); + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_assets_IShaderSource_set_frag : Invalid Native Object"); + + CC_UNUSED bool ok = true; + ok &= sevalue_to_native(args[0], &cobj->frag, s.thisObject()); + SE_PRECONDITION2(ok, false, "js_assets_IShaderSource_set_frag : Error processing new value"); + return true; +} +SE_BIND_PROP_SET(js_assets_IShaderSource_set_frag) + + +template<> +bool sevalue_to_native(const se::Value &from, cc::IShaderSource * to, se::Object *ctx) +{ + assert(from.isObject()); + se::Object *json = from.toObject(); + auto* data = reinterpret_cast(json->getPrivateData()); + if (data) { + *to = *data; + return true; + } + se::Value field; + bool ok = true; + json->getProperty("vert", &field, true); + if(!field.isNullOrUndefined()) { + ok &= sevalue_to_native(field, &(to->vert), ctx); + } + json->getProperty("frag", &field, true); + if(!field.isNullOrUndefined()) { + ok &= sevalue_to_native(field, &(to->frag), ctx); + } + return ok; +} + +SE_DECLARE_FINALIZE_FUNC(js_cc_IShaderSource_finalize) + +static bool js_assets_IShaderSource_constructor(se::State& s) // NOLINT(readability-identifier-naming) +{ + CC_UNUSED bool ok = true; + const auto& args = s.args(); + size_t argc = args.size(); + + if(argc == 0) + { + auto *ptr = JSB_MAKE_PRIVATE_OBJECT(cc::IShaderSource); + s.thisObject()->setPrivateObject(ptr); + return true; + } + + if(argc == 1 && args[0].isObject()) + { + se::Object *json = args[0].toObject(); + se::Value field; + auto *ptr = JSB_MAKE_PRIVATE_OBJECT(cc::IShaderSource); + auto cobj = ptr->get(); + ok &= sevalue_to_native(args[0], cobj, s.thisObject()); + if(!ok) { + delete ptr; + SE_REPORT_ERROR("argument convertion error"); + return false; + } + s.thisObject()->setPrivateObject(ptr); + return true; + } + auto *ptr = JSB_MAKE_PRIVATE_OBJECT(cc::IShaderSource); + auto cobj = ptr->get(); + if (argc > 0 && !args[0].isUndefined()) { + ok &= sevalue_to_native(args[0], &(cobj->vert), nullptr); + } + if (argc > 1 && !args[1].isUndefined()) { + ok &= sevalue_to_native(args[1], &(cobj->frag), nullptr); + } + + if(!ok) { + delete ptr; + SE_REPORT_ERROR("Argument convertion error"); + return false; + } + s.thisObject()->setPrivateObject(ptr); + return true; +} +SE_BIND_CTOR(js_assets_IShaderSource_constructor, __jsb_cc_IShaderSource_class, js_cc_IShaderSource_finalize) + +static bool js_cc_IShaderSource_finalize(se::State& s) // NOLINT(readability-identifier-naming) +{ + return true; +} +SE_BIND_FINALIZE_FUNC(js_cc_IShaderSource_finalize) + +bool js_register_assets_IShaderSource(se::Object* obj) // NOLINT(readability-identifier-naming) +{ + auto* cls = se::Class::create("IShaderSource", obj, nullptr, _SE(js_assets_IShaderSource_constructor)); + + cls->defineProperty("vert", _SE(js_assets_IShaderSource_get_vert), _SE(js_assets_IShaderSource_set_vert)); + cls->defineProperty("frag", _SE(js_assets_IShaderSource_get_frag), _SE(js_assets_IShaderSource_set_frag)); + cls->defineFinalizeFunction(_SE(js_cc_IShaderSource_finalize)); + cls->install(); + JSBClassType::registerClass(cls); + + __jsb_cc_IShaderSource_proto = cls->getProto(); + __jsb_cc_IShaderSource_class = cls; + + + se::ScriptEngine::getInstance()->clearException(); + return true; +} +se::Object* __jsb_cc_IShaderInfo_proto = nullptr; // NOLINT +se::Class* __jsb_cc_IShaderInfo_class = nullptr; // NOLINT + +static bool js_assets_IShaderInfo_getSource(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_assets_IShaderInfo_getSource : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 1) { + HolderType arg0 = {}; + ok &= sevalue_to_native(args[0], &arg0, s.thisObject()); + SE_PRECONDITION2(ok, false, "js_assets_IShaderInfo_getSource : Error processing arguments"); + const cc::IShaderSource* result = cobj->getSource(arg0.value()); + ok &= nativevalue_to_se(result, s.rval(), nullptr /*ctx*/); + SE_PRECONDITION2(ok, false, "js_assets_IShaderInfo_getSource : Error processing arguments"); + SE_HOLD_RETURN_VALUE(result, s.thisObject(), s.rval()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 1); + return false; +} +SE_BIND_FUNC(js_assets_IShaderInfo_getSource) + +static bool js_assets_IShaderInfo_get_name(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_assets_IShaderInfo_get_name : Invalid Native Object"); + + CC_UNUSED bool ok = true; + se::Value jsret; + ok &= nativevalue_to_se(cobj->name, jsret, s.thisObject() /*ctx*/); + s.rval() = jsret; + SE_HOLD_RETURN_VALUE(cobj->name, s.thisObject(), s.rval()); + return true; +} +SE_BIND_PROP_GET(js_assets_IShaderInfo_get_name) + +static bool js_assets_IShaderInfo_set_name(se::State& s) // NOLINT(readability-identifier-naming) +{ + const auto& args = s.args(); + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_assets_IShaderInfo_set_name : Invalid Native Object"); + + CC_UNUSED bool ok = true; + ok &= sevalue_to_native(args[0], &cobj->name, s.thisObject()); + SE_PRECONDITION2(ok, false, "js_assets_IShaderInfo_set_name : Error processing new value"); + return true; +} +SE_BIND_PROP_SET(js_assets_IShaderInfo_set_name) + +static bool js_assets_IShaderInfo_get_hash(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_assets_IShaderInfo_get_hash : Invalid Native Object"); + + CC_UNUSED bool ok = true; + se::Value jsret; + ok &= nativevalue_to_se(cobj->hash, jsret, s.thisObject() /*ctx*/); + s.rval() = jsret; + SE_HOLD_RETURN_VALUE(cobj->hash, s.thisObject(), s.rval()); + return true; +} +SE_BIND_PROP_GET(js_assets_IShaderInfo_get_hash) + +static bool js_assets_IShaderInfo_set_hash(se::State& s) // NOLINT(readability-identifier-naming) +{ + const auto& args = s.args(); + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_assets_IShaderInfo_set_hash : Invalid Native Object"); + + CC_UNUSED bool ok = true; + ok &= sevalue_to_native(args[0], &cobj->hash, s.thisObject()); + SE_PRECONDITION2(ok, false, "js_assets_IShaderInfo_set_hash : Error processing new value"); + return true; +} +SE_BIND_PROP_SET(js_assets_IShaderInfo_set_hash) + +static bool js_assets_IShaderInfo_get_glsl4(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_assets_IShaderInfo_get_glsl4 : Invalid Native Object"); + + CC_UNUSED bool ok = true; + se::Value jsret; + ok &= nativevalue_to_se(cobj->glsl4, jsret, s.thisObject() /*ctx*/); + s.rval() = jsret; + SE_HOLD_RETURN_VALUE(cobj->glsl4, s.thisObject(), s.rval()); + return true; +} +SE_BIND_PROP_GET(js_assets_IShaderInfo_get_glsl4) + +static bool js_assets_IShaderInfo_set_glsl4(se::State& s) // NOLINT(readability-identifier-naming) +{ + const auto& args = s.args(); + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_assets_IShaderInfo_set_glsl4 : Invalid Native Object"); + + CC_UNUSED bool ok = true; + ok &= sevalue_to_native(args[0], &cobj->glsl4, s.thisObject()); + SE_PRECONDITION2(ok, false, "js_assets_IShaderInfo_set_glsl4 : Error processing new value"); + return true; +} +SE_BIND_PROP_SET(js_assets_IShaderInfo_set_glsl4) + +static bool js_assets_IShaderInfo_get_glsl3(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_assets_IShaderInfo_get_glsl3 : Invalid Native Object"); + + CC_UNUSED bool ok = true; + se::Value jsret; + ok &= nativevalue_to_se(cobj->glsl3, jsret, s.thisObject() /*ctx*/); + s.rval() = jsret; + SE_HOLD_RETURN_VALUE(cobj->glsl3, s.thisObject(), s.rval()); + return true; +} +SE_BIND_PROP_GET(js_assets_IShaderInfo_get_glsl3) + +static bool js_assets_IShaderInfo_set_glsl3(se::State& s) // NOLINT(readability-identifier-naming) +{ + const auto& args = s.args(); + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_assets_IShaderInfo_set_glsl3 : Invalid Native Object"); + + CC_UNUSED bool ok = true; + ok &= sevalue_to_native(args[0], &cobj->glsl3, s.thisObject()); + SE_PRECONDITION2(ok, false, "js_assets_IShaderInfo_set_glsl3 : Error processing new value"); + return true; +} +SE_BIND_PROP_SET(js_assets_IShaderInfo_set_glsl3) + +static bool js_assets_IShaderInfo_get_glsl1(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_assets_IShaderInfo_get_glsl1 : Invalid Native Object"); + + CC_UNUSED bool ok = true; + se::Value jsret; + ok &= nativevalue_to_se(cobj->glsl1, jsret, s.thisObject() /*ctx*/); + s.rval() = jsret; + SE_HOLD_RETURN_VALUE(cobj->glsl1, s.thisObject(), s.rval()); + return true; +} +SE_BIND_PROP_GET(js_assets_IShaderInfo_get_glsl1) + +static bool js_assets_IShaderInfo_set_glsl1(se::State& s) // NOLINT(readability-identifier-naming) +{ + const auto& args = s.args(); + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_assets_IShaderInfo_set_glsl1 : Invalid Native Object"); + + CC_UNUSED bool ok = true; + ok &= sevalue_to_native(args[0], &cobj->glsl1, s.thisObject()); + SE_PRECONDITION2(ok, false, "js_assets_IShaderInfo_set_glsl1 : Error processing new value"); + return true; +} +SE_BIND_PROP_SET(js_assets_IShaderInfo_set_glsl1) + +static bool js_assets_IShaderInfo_get_builtins(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_assets_IShaderInfo_get_builtins : Invalid Native Object"); + + CC_UNUSED bool ok = true; + se::Value jsret; + ok &= nativevalue_to_se(cobj->builtins, jsret, s.thisObject() /*ctx*/); + s.rval() = jsret; + SE_HOLD_RETURN_VALUE(cobj->builtins, s.thisObject(), s.rval()); + return true; +} +SE_BIND_PROP_GET(js_assets_IShaderInfo_get_builtins) + +static bool js_assets_IShaderInfo_set_builtins(se::State& s) // NOLINT(readability-identifier-naming) +{ + const auto& args = s.args(); + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_assets_IShaderInfo_set_builtins : Invalid Native Object"); + + CC_UNUSED bool ok = true; + ok &= sevalue_to_native(args[0], &cobj->builtins, s.thisObject()); + SE_PRECONDITION2(ok, false, "js_assets_IShaderInfo_set_builtins : Error processing new value"); + return true; +} +SE_BIND_PROP_SET(js_assets_IShaderInfo_set_builtins) + +static bool js_assets_IShaderInfo_get_defines(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_assets_IShaderInfo_get_defines : Invalid Native Object"); + + CC_UNUSED bool ok = true; + se::Value jsret; + ok &= nativevalue_to_se(cobj->defines, jsret, s.thisObject() /*ctx*/); + s.rval() = jsret; + SE_HOLD_RETURN_VALUE(cobj->defines, s.thisObject(), s.rval()); + return true; +} +SE_BIND_PROP_GET(js_assets_IShaderInfo_get_defines) + +static bool js_assets_IShaderInfo_set_defines(se::State& s) // NOLINT(readability-identifier-naming) +{ + const auto& args = s.args(); + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_assets_IShaderInfo_set_defines : Invalid Native Object"); + + CC_UNUSED bool ok = true; + ok &= sevalue_to_native(args[0], &cobj->defines, s.thisObject()); + SE_PRECONDITION2(ok, false, "js_assets_IShaderInfo_set_defines : Error processing new value"); + return true; +} +SE_BIND_PROP_SET(js_assets_IShaderInfo_set_defines) + +static bool js_assets_IShaderInfo_get_attributes(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_assets_IShaderInfo_get_attributes : Invalid Native Object"); + + CC_UNUSED bool ok = true; + se::Value jsret; + ok &= nativevalue_to_se(cobj->attributes, jsret, s.thisObject() /*ctx*/); + s.rval() = jsret; + SE_HOLD_RETURN_VALUE(cobj->attributes, s.thisObject(), s.rval()); + return true; +} +SE_BIND_PROP_GET(js_assets_IShaderInfo_get_attributes) + +static bool js_assets_IShaderInfo_set_attributes(se::State& s) // NOLINT(readability-identifier-naming) +{ + const auto& args = s.args(); + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_assets_IShaderInfo_set_attributes : Invalid Native Object"); + + CC_UNUSED bool ok = true; + ok &= sevalue_to_native(args[0], &cobj->attributes, s.thisObject()); + SE_PRECONDITION2(ok, false, "js_assets_IShaderInfo_set_attributes : Error processing new value"); + return true; +} +SE_BIND_PROP_SET(js_assets_IShaderInfo_set_attributes) + +static bool js_assets_IShaderInfo_get_blocks(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_assets_IShaderInfo_get_blocks : Invalid Native Object"); + + CC_UNUSED bool ok = true; + se::Value jsret; + ok &= nativevalue_to_se(cobj->blocks, jsret, s.thisObject() /*ctx*/); + s.rval() = jsret; + SE_HOLD_RETURN_VALUE(cobj->blocks, s.thisObject(), s.rval()); + return true; +} +SE_BIND_PROP_GET(js_assets_IShaderInfo_get_blocks) + +static bool js_assets_IShaderInfo_set_blocks(se::State& s) // NOLINT(readability-identifier-naming) +{ + const auto& args = s.args(); + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_assets_IShaderInfo_set_blocks : Invalid Native Object"); + + CC_UNUSED bool ok = true; + ok &= sevalue_to_native(args[0], &cobj->blocks, s.thisObject()); + SE_PRECONDITION2(ok, false, "js_assets_IShaderInfo_set_blocks : Error processing new value"); + return true; +} +SE_BIND_PROP_SET(js_assets_IShaderInfo_set_blocks) + +static bool js_assets_IShaderInfo_get_samplerTextures(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_assets_IShaderInfo_get_samplerTextures : Invalid Native Object"); + + CC_UNUSED bool ok = true; + se::Value jsret; + ok &= nativevalue_to_se(cobj->samplerTextures, jsret, s.thisObject() /*ctx*/); + s.rval() = jsret; + SE_HOLD_RETURN_VALUE(cobj->samplerTextures, s.thisObject(), s.rval()); + return true; +} +SE_BIND_PROP_GET(js_assets_IShaderInfo_get_samplerTextures) + +static bool js_assets_IShaderInfo_set_samplerTextures(se::State& s) // NOLINT(readability-identifier-naming) +{ + const auto& args = s.args(); + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_assets_IShaderInfo_set_samplerTextures : Invalid Native Object"); + + CC_UNUSED bool ok = true; + ok &= sevalue_to_native(args[0], &cobj->samplerTextures, s.thisObject()); + SE_PRECONDITION2(ok, false, "js_assets_IShaderInfo_set_samplerTextures : Error processing new value"); + return true; +} +SE_BIND_PROP_SET(js_assets_IShaderInfo_set_samplerTextures) + +static bool js_assets_IShaderInfo_get_samplers(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_assets_IShaderInfo_get_samplers : Invalid Native Object"); + + CC_UNUSED bool ok = true; + se::Value jsret; + ok &= nativevalue_to_se(cobj->samplers, jsret, s.thisObject() /*ctx*/); + s.rval() = jsret; + SE_HOLD_RETURN_VALUE(cobj->samplers, s.thisObject(), s.rval()); + return true; +} +SE_BIND_PROP_GET(js_assets_IShaderInfo_get_samplers) + +static bool js_assets_IShaderInfo_set_samplers(se::State& s) // NOLINT(readability-identifier-naming) +{ + const auto& args = s.args(); + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_assets_IShaderInfo_set_samplers : Invalid Native Object"); + + CC_UNUSED bool ok = true; + ok &= sevalue_to_native(args[0], &cobj->samplers, s.thisObject()); + SE_PRECONDITION2(ok, false, "js_assets_IShaderInfo_set_samplers : Error processing new value"); + return true; +} +SE_BIND_PROP_SET(js_assets_IShaderInfo_set_samplers) + +static bool js_assets_IShaderInfo_get_textures(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_assets_IShaderInfo_get_textures : Invalid Native Object"); + + CC_UNUSED bool ok = true; + se::Value jsret; + ok &= nativevalue_to_se(cobj->textures, jsret, s.thisObject() /*ctx*/); + s.rval() = jsret; + SE_HOLD_RETURN_VALUE(cobj->textures, s.thisObject(), s.rval()); + return true; +} +SE_BIND_PROP_GET(js_assets_IShaderInfo_get_textures) + +static bool js_assets_IShaderInfo_set_textures(se::State& s) // NOLINT(readability-identifier-naming) +{ + const auto& args = s.args(); + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_assets_IShaderInfo_set_textures : Invalid Native Object"); + + CC_UNUSED bool ok = true; + ok &= sevalue_to_native(args[0], &cobj->textures, s.thisObject()); + SE_PRECONDITION2(ok, false, "js_assets_IShaderInfo_set_textures : Error processing new value"); + return true; +} +SE_BIND_PROP_SET(js_assets_IShaderInfo_set_textures) + +static bool js_assets_IShaderInfo_get_buffers(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_assets_IShaderInfo_get_buffers : Invalid Native Object"); + + CC_UNUSED bool ok = true; + se::Value jsret; + ok &= nativevalue_to_se(cobj->buffers, jsret, s.thisObject() /*ctx*/); + s.rval() = jsret; + SE_HOLD_RETURN_VALUE(cobj->buffers, s.thisObject(), s.rval()); + return true; +} +SE_BIND_PROP_GET(js_assets_IShaderInfo_get_buffers) + +static bool js_assets_IShaderInfo_set_buffers(se::State& s) // NOLINT(readability-identifier-naming) +{ + const auto& args = s.args(); + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_assets_IShaderInfo_set_buffers : Invalid Native Object"); + + CC_UNUSED bool ok = true; + ok &= sevalue_to_native(args[0], &cobj->buffers, s.thisObject()); + SE_PRECONDITION2(ok, false, "js_assets_IShaderInfo_set_buffers : Error processing new value"); + return true; +} +SE_BIND_PROP_SET(js_assets_IShaderInfo_set_buffers) + +static bool js_assets_IShaderInfo_get_images(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_assets_IShaderInfo_get_images : Invalid Native Object"); + + CC_UNUSED bool ok = true; + se::Value jsret; + ok &= nativevalue_to_se(cobj->images, jsret, s.thisObject() /*ctx*/); + s.rval() = jsret; + SE_HOLD_RETURN_VALUE(cobj->images, s.thisObject(), s.rval()); + return true; +} +SE_BIND_PROP_GET(js_assets_IShaderInfo_get_images) + +static bool js_assets_IShaderInfo_set_images(se::State& s) // NOLINT(readability-identifier-naming) +{ + const auto& args = s.args(); + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_assets_IShaderInfo_set_images : Invalid Native Object"); + + CC_UNUSED bool ok = true; + ok &= sevalue_to_native(args[0], &cobj->images, s.thisObject()); + SE_PRECONDITION2(ok, false, "js_assets_IShaderInfo_set_images : Error processing new value"); + return true; +} +SE_BIND_PROP_SET(js_assets_IShaderInfo_set_images) + +static bool js_assets_IShaderInfo_get_subpassInputs(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_assets_IShaderInfo_get_subpassInputs : Invalid Native Object"); + + CC_UNUSED bool ok = true; + se::Value jsret; + ok &= nativevalue_to_se(cobj->subpassInputs, jsret, s.thisObject() /*ctx*/); + s.rval() = jsret; + SE_HOLD_RETURN_VALUE(cobj->subpassInputs, s.thisObject(), s.rval()); + return true; +} +SE_BIND_PROP_GET(js_assets_IShaderInfo_get_subpassInputs) + +static bool js_assets_IShaderInfo_set_subpassInputs(se::State& s) // NOLINT(readability-identifier-naming) +{ + const auto& args = s.args(); + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_assets_IShaderInfo_set_subpassInputs : Invalid Native Object"); + + CC_UNUSED bool ok = true; + ok &= sevalue_to_native(args[0], &cobj->subpassInputs, s.thisObject()); + SE_PRECONDITION2(ok, false, "js_assets_IShaderInfo_set_subpassInputs : Error processing new value"); + return true; +} +SE_BIND_PROP_SET(js_assets_IShaderInfo_set_subpassInputs) + + +template<> +bool sevalue_to_native(const se::Value &from, cc::IShaderInfo * to, se::Object *ctx) +{ + assert(from.isObject()); + se::Object *json = from.toObject(); + auto* data = reinterpret_cast(json->getPrivateData()); + if (data) { + *to = *data; + return true; + } + se::Value field; + bool ok = true; + json->getProperty("name", &field, true); + if(!field.isNullOrUndefined()) { + ok &= sevalue_to_native(field, &(to->name), ctx); + } + json->getProperty("hash", &field, true); + if(!field.isNullOrUndefined()) { + ok &= sevalue_to_native(field, &(to->hash), ctx); + } + json->getProperty("glsl4", &field, true); + if(!field.isNullOrUndefined()) { + ok &= sevalue_to_native(field, &(to->glsl4), ctx); + } + json->getProperty("glsl3", &field, true); + if(!field.isNullOrUndefined()) { + ok &= sevalue_to_native(field, &(to->glsl3), ctx); + } + json->getProperty("glsl1", &field, true); + if(!field.isNullOrUndefined()) { + ok &= sevalue_to_native(field, &(to->glsl1), ctx); + } + json->getProperty("builtins", &field, true); + if(!field.isNullOrUndefined()) { + ok &= sevalue_to_native(field, &(to->builtins), ctx); + } + json->getProperty("defines", &field, true); + if(!field.isNullOrUndefined()) { + ok &= sevalue_to_native(field, &(to->defines), ctx); + } + json->getProperty("attributes", &field, true); + if(!field.isNullOrUndefined()) { + ok &= sevalue_to_native(field, &(to->attributes), ctx); + } + json->getProperty("blocks", &field, true); + if(!field.isNullOrUndefined()) { + ok &= sevalue_to_native(field, &(to->blocks), ctx); + } + json->getProperty("samplerTextures", &field, true); + if(!field.isNullOrUndefined()) { + ok &= sevalue_to_native(field, &(to->samplerTextures), ctx); + } + json->getProperty("samplers", &field, true); + if(!field.isNullOrUndefined()) { + ok &= sevalue_to_native(field, &(to->samplers), ctx); + } + json->getProperty("textures", &field, true); + if(!field.isNullOrUndefined()) { + ok &= sevalue_to_native(field, &(to->textures), ctx); + } + json->getProperty("buffers", &field, true); + if(!field.isNullOrUndefined()) { + ok &= sevalue_to_native(field, &(to->buffers), ctx); + } + json->getProperty("images", &field, true); + if(!field.isNullOrUndefined()) { + ok &= sevalue_to_native(field, &(to->images), ctx); + } + json->getProperty("subpassInputs", &field, true); + if(!field.isNullOrUndefined()) { + ok &= sevalue_to_native(field, &(to->subpassInputs), ctx); + } + return ok; +} + +SE_DECLARE_FINALIZE_FUNC(js_cc_IShaderInfo_finalize) + +static bool js_assets_IShaderInfo_constructor(se::State& s) // NOLINT(readability-identifier-naming) +{ + CC_UNUSED bool ok = true; + const auto& args = s.args(); + size_t argc = args.size(); + + if(argc == 0) + { + auto *ptr = JSB_MAKE_PRIVATE_OBJECT(cc::IShaderInfo); + s.thisObject()->setPrivateObject(ptr); + return true; + } + + if(argc == 1 && args[0].isObject()) + { + se::Object *json = args[0].toObject(); + se::Value field; + auto *ptr = JSB_MAKE_PRIVATE_OBJECT(cc::IShaderInfo); + auto cobj = ptr->get(); + ok &= sevalue_to_native(args[0], cobj, s.thisObject()); + if(!ok) { + delete ptr; + SE_REPORT_ERROR("argument convertion error"); + return false; + } + s.thisObject()->setPrivateObject(ptr); + return true; + } + auto *ptr = JSB_MAKE_PRIVATE_OBJECT(cc::IShaderInfo); + auto cobj = ptr->get(); + if (argc > 0 && !args[0].isUndefined()) { + ok &= sevalue_to_native(args[0], &(cobj->name), nullptr); + } + if (argc > 1 && !args[1].isUndefined()) { + ok &= sevalue_to_native(args[1], &(cobj->hash), nullptr); + } + if (argc > 2 && !args[2].isUndefined()) { + ok &= sevalue_to_native(args[2], &(cobj->glsl4), nullptr); + } + if (argc > 3 && !args[3].isUndefined()) { + ok &= sevalue_to_native(args[3], &(cobj->glsl3), nullptr); + } + if (argc > 4 && !args[4].isUndefined()) { + ok &= sevalue_to_native(args[4], &(cobj->glsl1), nullptr); + } + if (argc > 5 && !args[5].isUndefined()) { + ok &= sevalue_to_native(args[5], &(cobj->builtins), nullptr); + } + if (argc > 6 && !args[6].isUndefined()) { + ok &= sevalue_to_native(args[6], &(cobj->defines), nullptr); + } + if (argc > 7 && !args[7].isUndefined()) { + ok &= sevalue_to_native(args[7], &(cobj->attributes), nullptr); + } + if (argc > 8 && !args[8].isUndefined()) { + ok &= sevalue_to_native(args[8], &(cobj->blocks), nullptr); + } + if (argc > 9 && !args[9].isUndefined()) { + ok &= sevalue_to_native(args[9], &(cobj->samplerTextures), nullptr); + } + if (argc > 10 && !args[10].isUndefined()) { + ok &= sevalue_to_native(args[10], &(cobj->samplers), nullptr); + } + if (argc > 11 && !args[11].isUndefined()) { + ok &= sevalue_to_native(args[11], &(cobj->textures), nullptr); + } + if (argc > 12 && !args[12].isUndefined()) { + ok &= sevalue_to_native(args[12], &(cobj->buffers), nullptr); + } + if (argc > 13 && !args[13].isUndefined()) { + ok &= sevalue_to_native(args[13], &(cobj->images), nullptr); + } + if (argc > 14 && !args[14].isUndefined()) { + ok &= sevalue_to_native(args[14], &(cobj->subpassInputs), nullptr); + } + + if(!ok) { + delete ptr; + SE_REPORT_ERROR("Argument convertion error"); + return false; + } + s.thisObject()->setPrivateObject(ptr); + return true; +} +SE_BIND_CTOR(js_assets_IShaderInfo_constructor, __jsb_cc_IShaderInfo_class, js_cc_IShaderInfo_finalize) + +static bool js_cc_IShaderInfo_finalize(se::State& s) // NOLINT(readability-identifier-naming) +{ + return true; +} +SE_BIND_FINALIZE_FUNC(js_cc_IShaderInfo_finalize) + +bool js_register_assets_IShaderInfo(se::Object* obj) // NOLINT(readability-identifier-naming) +{ + auto* cls = se::Class::create("IShaderInfo", obj, nullptr, _SE(js_assets_IShaderInfo_constructor)); + + cls->defineProperty("name", _SE(js_assets_IShaderInfo_get_name), _SE(js_assets_IShaderInfo_set_name)); + cls->defineProperty("hash", _SE(js_assets_IShaderInfo_get_hash), _SE(js_assets_IShaderInfo_set_hash)); + cls->defineProperty("glsl4", _SE(js_assets_IShaderInfo_get_glsl4), _SE(js_assets_IShaderInfo_set_glsl4)); + cls->defineProperty("glsl3", _SE(js_assets_IShaderInfo_get_glsl3), _SE(js_assets_IShaderInfo_set_glsl3)); + cls->defineProperty("glsl1", _SE(js_assets_IShaderInfo_get_glsl1), _SE(js_assets_IShaderInfo_set_glsl1)); + cls->defineProperty("builtins", _SE(js_assets_IShaderInfo_get_builtins), _SE(js_assets_IShaderInfo_set_builtins)); + cls->defineProperty("defines", _SE(js_assets_IShaderInfo_get_defines), _SE(js_assets_IShaderInfo_set_defines)); + cls->defineProperty("attributes", _SE(js_assets_IShaderInfo_get_attributes), _SE(js_assets_IShaderInfo_set_attributes)); + cls->defineProperty("blocks", _SE(js_assets_IShaderInfo_get_blocks), _SE(js_assets_IShaderInfo_set_blocks)); + cls->defineProperty("samplerTextures", _SE(js_assets_IShaderInfo_get_samplerTextures), _SE(js_assets_IShaderInfo_set_samplerTextures)); + cls->defineProperty("samplers", _SE(js_assets_IShaderInfo_get_samplers), _SE(js_assets_IShaderInfo_set_samplers)); + cls->defineProperty("textures", _SE(js_assets_IShaderInfo_get_textures), _SE(js_assets_IShaderInfo_set_textures)); + cls->defineProperty("buffers", _SE(js_assets_IShaderInfo_get_buffers), _SE(js_assets_IShaderInfo_set_buffers)); + cls->defineProperty("images", _SE(js_assets_IShaderInfo_get_images), _SE(js_assets_IShaderInfo_set_images)); + cls->defineProperty("subpassInputs", _SE(js_assets_IShaderInfo_get_subpassInputs), _SE(js_assets_IShaderInfo_set_subpassInputs)); + cls->defineFunction("getSource", _SE(js_assets_IShaderInfo_getSource)); + cls->defineFinalizeFunction(_SE(js_cc_IShaderInfo_finalize)); + cls->install(); + JSBClassType::registerClass(cls); + + __jsb_cc_IShaderInfo_proto = cls->getProto(); + __jsb_cc_IShaderInfo_class = cls; + + + se::ScriptEngine::getInstance()->clearException(); + return true; +} +se::Object* __jsb_cc_EffectAsset_proto = nullptr; // NOLINT +se::Class* __jsb_cc_EffectAsset_class = nullptr; // NOLINT + +static bool js_assets_EffectAsset_getCombinations(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_assets_EffectAsset_getCombinations : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 0) { + const std::vector, std::vector, std::vector>>>& result = cobj->getCombinations(); + ok &= nativevalue_to_se(result, s.rval(), nullptr /*ctx*/); + SE_PRECONDITION2(ok, false, "js_assets_EffectAsset_getCombinations : Error processing arguments"); + SE_HOLD_RETURN_VALUE(result, s.thisObject(), s.rval()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 0); + return false; +} +SE_BIND_FUNC_AS_PROP_GET(js_assets_EffectAsset_getCombinations) + +static bool js_assets_EffectAsset_getShaders(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_assets_EffectAsset_getShaders : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 0) { + const std::vector& result = cobj->getShaders(); + ok &= nativevalue_to_se(result, s.rval(), nullptr /*ctx*/); + SE_PRECONDITION2(ok, false, "js_assets_EffectAsset_getShaders : Error processing arguments"); + SE_HOLD_RETURN_VALUE(result, s.thisObject(), s.rval()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 0); + return false; +} +SE_BIND_FUNC_AS_PROP_GET(js_assets_EffectAsset_getShaders) + +static bool js_assets_EffectAsset_getTechniques(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_assets_EffectAsset_getTechniques : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 0) { + const std::vector& result = cobj->getTechniques(); + ok &= nativevalue_to_se(result, s.rval(), nullptr /*ctx*/); + SE_PRECONDITION2(ok, false, "js_assets_EffectAsset_getTechniques : Error processing arguments"); + SE_HOLD_RETURN_VALUE(result, s.thisObject(), s.rval()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 0); + return false; +} +SE_BIND_FUNC_AS_PROP_GET(js_assets_EffectAsset_getTechniques) + +static bool js_assets_EffectAsset_setCombinations(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_assets_EffectAsset_setCombinations : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 1) { + HolderType, std::vector, std::vector>>>, true> arg0 = {}; + ok &= sevalue_to_native(args[0], &arg0, s.thisObject()); + SE_PRECONDITION2(ok, false, "js_assets_EffectAsset_setCombinations : Error processing arguments"); + cobj->setCombinations(arg0.value()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 1); + return false; +} +SE_BIND_FUNC_AS_PROP_SET(js_assets_EffectAsset_setCombinations) + +static bool js_assets_EffectAsset_setShaders(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_assets_EffectAsset_setShaders : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 1) { + HolderType, true> arg0 = {}; + ok &= sevalue_to_native(args[0], &arg0, s.thisObject()); + SE_PRECONDITION2(ok, false, "js_assets_EffectAsset_setShaders : Error processing arguments"); + cobj->setShaders(arg0.value()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 1); + return false; +} +SE_BIND_FUNC_AS_PROP_SET(js_assets_EffectAsset_setShaders) + +static bool js_assets_EffectAsset_setTechniques(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_assets_EffectAsset_setTechniques : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 1) { + HolderType, true> arg0 = {}; + ok &= sevalue_to_native(args[0], &arg0, s.thisObject()); + SE_PRECONDITION2(ok, false, "js_assets_EffectAsset_setTechniques : Error processing arguments"); + cobj->setTechniques(arg0.value()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 1); + return false; +} +SE_BIND_FUNC_AS_PROP_SET(js_assets_EffectAsset_setTechniques) + +static bool js_assets_EffectAsset_get_static(se::State& s) // NOLINT(readability-identifier-naming) +{ + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 1) { + HolderType arg0 = {}; + ok &= sevalue_to_native(args[0], &arg0, nullptr); + SE_PRECONDITION2(ok, false, "js_assets_EffectAsset_get_static : Error processing arguments"); + cc::EffectAsset* result = cc::EffectAsset::get(arg0.value()); + ok &= nativevalue_to_se(result, s.rval(), nullptr /*ctx*/); + SE_PRECONDITION2(ok, false, "js_assets_EffectAsset_get_static : Error processing arguments"); + SE_HOLD_RETURN_VALUE(result, s.thisObject(), s.rval()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 1); + return false; +} +SE_BIND_FUNC(js_assets_EffectAsset_get_static) + +static bool js_assets_EffectAsset_getAll_static(se::State& s) // NOLINT(readability-identifier-naming) +{ + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 0) { + std::unordered_map>& result = cc::EffectAsset::getAll(); + ok &= nativevalue_to_se(result, s.rval(), nullptr /*ctx*/); + SE_PRECONDITION2(ok, false, "js_assets_EffectAsset_getAll_static : Error processing arguments"); + SE_HOLD_RETURN_VALUE(result, s.thisObject(), s.rval()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 0); + return false; +} +SE_BIND_FUNC(js_assets_EffectAsset_getAll_static) + +static bool js_assets_EffectAsset_registerAsset_static(se::State& s) // NOLINT(readability-identifier-naming) +{ + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 1) { + HolderType arg0 = {}; + ok &= sevalue_to_native(args[0], &arg0, nullptr); + SE_PRECONDITION2(ok, false, "js_assets_EffectAsset_registerAsset_static : Error processing arguments"); + cc::EffectAsset::registerAsset(arg0.value()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 1); + return false; +} +SE_BIND_FUNC(js_assets_EffectAsset_registerAsset_static) + +static bool js_assets_EffectAsset_remove_static(se::State& s) // NOLINT(readability-identifier-naming) +{ + CC_UNUSED bool ok = true; + const auto& args = s.args(); + size_t argc = args.size(); + do { + if (argc == 1) { + HolderType arg0 = {}; + ok &= sevalue_to_native(args[0], &arg0, s.thisObject()); + if (!ok) { ok = true; break; } + cc::EffectAsset::remove(arg0.value()); + return true; + } + } while (false); + do { + if (argc == 1) { + HolderType arg0 = {}; + ok &= sevalue_to_native(args[0], &arg0, s.thisObject()); + if (!ok) { ok = true; break; } + cc::EffectAsset::remove(arg0.value()); + return true; + } + } while (false); + SE_REPORT_ERROR("wrong number of arguments: %d", (int)argc); + return false; +} +SE_BIND_FUNC(js_assets_EffectAsset_remove_static) + +SE_DECLARE_FINALIZE_FUNC(js_cc_EffectAsset_finalize) + +static bool js_assets_EffectAsset_constructor(se::State& s) // NOLINT(readability-identifier-naming) constructor.c +{ + auto *ptr = JSB_MAKE_PRIVATE_OBJECT(cc::EffectAsset); + s.thisObject()->setPrivateObject(ptr); + return true; +} +SE_BIND_CTOR(js_assets_EffectAsset_constructor, __jsb_cc_EffectAsset_class, js_cc_EffectAsset_finalize) + +static bool js_cc_EffectAsset_finalize(se::State& s) // NOLINT(readability-identifier-naming) +{ + return true; +} +SE_BIND_FINALIZE_FUNC(js_cc_EffectAsset_finalize) + +bool js_register_assets_EffectAsset(se::Object* obj) // NOLINT(readability-identifier-naming) +{ + auto* cls = se::Class::create("EffectAsset", obj, __jsb_cc_Asset_proto, _SE(js_assets_EffectAsset_constructor)); + + cls->defineProperty("combinations", _SE(js_assets_EffectAsset_getCombinations_asGetter), _SE(js_assets_EffectAsset_setCombinations_asSetter)); + cls->defineProperty("shaders", _SE(js_assets_EffectAsset_getShaders_asGetter), _SE(js_assets_EffectAsset_setShaders_asSetter)); + cls->defineProperty("techniques", _SE(js_assets_EffectAsset_getTechniques_asGetter), _SE(js_assets_EffectAsset_setTechniques_asSetter)); + cls->defineStaticFunction("get", _SE(js_assets_EffectAsset_get_static)); + cls->defineStaticFunction("getAll", _SE(js_assets_EffectAsset_getAll_static)); + cls->defineStaticFunction("register", _SE(js_assets_EffectAsset_registerAsset_static)); + cls->defineStaticFunction("remove", _SE(js_assets_EffectAsset_remove_static)); + cls->defineFinalizeFunction(_SE(js_cc_EffectAsset_finalize)); + cls->install(); + JSBClassType::registerClass(cls); + + __jsb_cc_EffectAsset_proto = cls->getProto(); + __jsb_cc_EffectAsset_class = cls; + + + se::ScriptEngine::getInstance()->clearException(); + return true; +} +se::Object* __jsb_cc_IMemoryImageSource_proto = nullptr; // NOLINT +se::Class* __jsb_cc_IMemoryImageSource_class = nullptr; // NOLINT + +static bool js_assets_IMemoryImageSource_get_data(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_assets_IMemoryImageSource_get_data : Invalid Native Object"); + + CC_UNUSED bool ok = true; + se::Value jsret; + ok &= nativevalue_to_se(cobj->data, jsret, s.thisObject() /*ctx*/); + s.rval() = jsret; + SE_HOLD_RETURN_VALUE(cobj->data, s.thisObject(), s.rval()); + return true; +} +SE_BIND_PROP_GET(js_assets_IMemoryImageSource_get_data) + +static bool js_assets_IMemoryImageSource_set_data(se::State& s) // NOLINT(readability-identifier-naming) +{ + const auto& args = s.args(); + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_assets_IMemoryImageSource_set_data : Invalid Native Object"); + + CC_UNUSED bool ok = true; + ok &= sevalue_to_native(args[0], &cobj->data, s.thisObject()); + SE_PRECONDITION2(ok, false, "js_assets_IMemoryImageSource_set_data : Error processing new value"); + return true; +} +SE_BIND_PROP_SET(js_assets_IMemoryImageSource_set_data) + +static bool js_assets_IMemoryImageSource_get_compressed(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_assets_IMemoryImageSource_get_compressed : Invalid Native Object"); + + CC_UNUSED bool ok = true; + se::Value jsret; + ok &= nativevalue_to_se(cobj->compressed, jsret, s.thisObject() /*ctx*/); + s.rval() = jsret; + SE_HOLD_RETURN_VALUE(cobj->compressed, s.thisObject(), s.rval()); + return true; +} +SE_BIND_PROP_GET(js_assets_IMemoryImageSource_get_compressed) + +static bool js_assets_IMemoryImageSource_set_compressed(se::State& s) // NOLINT(readability-identifier-naming) +{ + const auto& args = s.args(); + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_assets_IMemoryImageSource_set_compressed : Invalid Native Object"); + + CC_UNUSED bool ok = true; + ok &= sevalue_to_native(args[0], &cobj->compressed, s.thisObject()); + SE_PRECONDITION2(ok, false, "js_assets_IMemoryImageSource_set_compressed : Error processing new value"); + return true; +} +SE_BIND_PROP_SET(js_assets_IMemoryImageSource_set_compressed) + +static bool js_assets_IMemoryImageSource_get_width(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_assets_IMemoryImageSource_get_width : Invalid Native Object"); + + CC_UNUSED bool ok = true; + se::Value jsret; + ok &= nativevalue_to_se(cobj->width, jsret, s.thisObject() /*ctx*/); + s.rval() = jsret; + SE_HOLD_RETURN_VALUE(cobj->width, s.thisObject(), s.rval()); + return true; +} +SE_BIND_PROP_GET(js_assets_IMemoryImageSource_get_width) + +static bool js_assets_IMemoryImageSource_set_width(se::State& s) // NOLINT(readability-identifier-naming) +{ + const auto& args = s.args(); + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_assets_IMemoryImageSource_set_width : Invalid Native Object"); + + CC_UNUSED bool ok = true; + ok &= sevalue_to_native(args[0], &cobj->width, s.thisObject()); + SE_PRECONDITION2(ok, false, "js_assets_IMemoryImageSource_set_width : Error processing new value"); + return true; +} +SE_BIND_PROP_SET(js_assets_IMemoryImageSource_set_width) + +static bool js_assets_IMemoryImageSource_get_height(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_assets_IMemoryImageSource_get_height : Invalid Native Object"); + + CC_UNUSED bool ok = true; + se::Value jsret; + ok &= nativevalue_to_se(cobj->height, jsret, s.thisObject() /*ctx*/); + s.rval() = jsret; + SE_HOLD_RETURN_VALUE(cobj->height, s.thisObject(), s.rval()); + return true; +} +SE_BIND_PROP_GET(js_assets_IMemoryImageSource_get_height) + +static bool js_assets_IMemoryImageSource_set_height(se::State& s) // NOLINT(readability-identifier-naming) +{ + const auto& args = s.args(); + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_assets_IMemoryImageSource_set_height : Invalid Native Object"); + + CC_UNUSED bool ok = true; + ok &= sevalue_to_native(args[0], &cobj->height, s.thisObject()); + SE_PRECONDITION2(ok, false, "js_assets_IMemoryImageSource_set_height : Error processing new value"); + return true; +} +SE_BIND_PROP_SET(js_assets_IMemoryImageSource_set_height) + +static bool js_assets_IMemoryImageSource_get_format(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_assets_IMemoryImageSource_get_format : Invalid Native Object"); + + CC_UNUSED bool ok = true; + se::Value jsret; + ok &= nativevalue_to_se(cobj->format, jsret, s.thisObject() /*ctx*/); + s.rval() = jsret; + SE_HOLD_RETURN_VALUE(cobj->format, s.thisObject(), s.rval()); + return true; +} +SE_BIND_PROP_GET(js_assets_IMemoryImageSource_get_format) + +static bool js_assets_IMemoryImageSource_set_format(se::State& s) // NOLINT(readability-identifier-naming) +{ + const auto& args = s.args(); + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_assets_IMemoryImageSource_set_format : Invalid Native Object"); + + CC_UNUSED bool ok = true; + ok &= sevalue_to_native(args[0], &cobj->format, s.thisObject()); + SE_PRECONDITION2(ok, false, "js_assets_IMemoryImageSource_set_format : Error processing new value"); + return true; +} +SE_BIND_PROP_SET(js_assets_IMemoryImageSource_set_format) + + +template<> +bool sevalue_to_native(const se::Value &from, cc::IMemoryImageSource * to, se::Object *ctx) +{ + assert(from.isObject()); + se::Object *json = from.toObject(); + auto* data = reinterpret_cast(json->getPrivateData()); + if (data) { + *to = *data; + return true; + } + se::Value field; + bool ok = true; + json->getProperty("data", &field, true); + if(!field.isNullOrUndefined()) { + ok &= sevalue_to_native(field, &(to->data), ctx); + } + json->getProperty("compressed", &field, true); + if(!field.isNullOrUndefined()) { + ok &= sevalue_to_native(field, &(to->compressed), ctx); + } + json->getProperty("width", &field, true); + if(!field.isNullOrUndefined()) { + ok &= sevalue_to_native(field, &(to->width), ctx); + } + json->getProperty("height", &field, true); + if(!field.isNullOrUndefined()) { + ok &= sevalue_to_native(field, &(to->height), ctx); + } + json->getProperty("format", &field, true); + if(!field.isNullOrUndefined()) { + ok &= sevalue_to_native(field, &(to->format), ctx); + } + return ok; +} + +SE_DECLARE_FINALIZE_FUNC(js_cc_IMemoryImageSource_finalize) + +static bool js_assets_IMemoryImageSource_constructor(se::State& s) // NOLINT(readability-identifier-naming) +{ + CC_UNUSED bool ok = true; + const auto& args = s.args(); + size_t argc = args.size(); + + if(argc == 0) + { + auto *ptr = JSB_MAKE_PRIVATE_OBJECT(cc::IMemoryImageSource); + s.thisObject()->setPrivateObject(ptr); + return true; + } + + if(argc == 1 && args[0].isObject()) + { + se::Object *json = args[0].toObject(); + se::Value field; + auto *ptr = JSB_MAKE_PRIVATE_OBJECT(cc::IMemoryImageSource); + auto cobj = ptr->get(); + ok &= sevalue_to_native(args[0], cobj, s.thisObject()); + if(!ok) { + delete ptr; + SE_REPORT_ERROR("argument convertion error"); + return false; + } + s.thisObject()->setPrivateObject(ptr); + return true; + } + auto *ptr = JSB_MAKE_PRIVATE_OBJECT(cc::IMemoryImageSource); + auto cobj = ptr->get(); + if (argc > 0 && !args[0].isUndefined()) { + ok &= sevalue_to_native(args[0], &(cobj->data), nullptr); + } + if (argc > 1 && !args[1].isUndefined()) { + ok &= sevalue_to_native(args[1], &(cobj->compressed), nullptr); + } + if (argc > 2 && !args[2].isUndefined()) { + ok &= sevalue_to_native(args[2], &(cobj->width), nullptr); + } + if (argc > 3 && !args[3].isUndefined()) { + ok &= sevalue_to_native(args[3], &(cobj->height), nullptr); + } + if (argc > 4 && !args[4].isUndefined()) { + ok &= sevalue_to_native(args[4], &(cobj->format), nullptr); + } + + if(!ok) { + delete ptr; + SE_REPORT_ERROR("Argument convertion error"); + return false; + } + s.thisObject()->setPrivateObject(ptr); + return true; +} +SE_BIND_CTOR(js_assets_IMemoryImageSource_constructor, __jsb_cc_IMemoryImageSource_class, js_cc_IMemoryImageSource_finalize) + +static bool js_cc_IMemoryImageSource_finalize(se::State& s) // NOLINT(readability-identifier-naming) +{ + return true; +} +SE_BIND_FINALIZE_FUNC(js_cc_IMemoryImageSource_finalize) + +bool js_register_assets_IMemoryImageSource(se::Object* obj) // NOLINT(readability-identifier-naming) +{ + auto* cls = se::Class::create("IMemoryImageSource", obj, nullptr, _SE(js_assets_IMemoryImageSource_constructor)); + + cls->defineProperty("data", _SE(js_assets_IMemoryImageSource_get_data), _SE(js_assets_IMemoryImageSource_set_data)); + cls->defineProperty("compressed", _SE(js_assets_IMemoryImageSource_get_compressed), _SE(js_assets_IMemoryImageSource_set_compressed)); + cls->defineProperty("width", _SE(js_assets_IMemoryImageSource_get_width), _SE(js_assets_IMemoryImageSource_set_width)); + cls->defineProperty("height", _SE(js_assets_IMemoryImageSource_get_height), _SE(js_assets_IMemoryImageSource_set_height)); + cls->defineProperty("format", _SE(js_assets_IMemoryImageSource_get_format), _SE(js_assets_IMemoryImageSource_set_format)); + cls->defineFinalizeFunction(_SE(js_cc_IMemoryImageSource_finalize)); + cls->install(); + JSBClassType::registerClass(cls); + + __jsb_cc_IMemoryImageSource_proto = cls->getProto(); + __jsb_cc_IMemoryImageSource_class = cls; + + + se::ScriptEngine::getInstance()->clearException(); + return true; +} +se::Object* __jsb_cc_ImageAsset_proto = nullptr; // NOLINT +se::Class* __jsb_cc_ImageAsset_class = nullptr; // NOLINT + +static bool js_assets_ImageAsset_getData(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_assets_ImageAsset_getData : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 0) { + const unsigned char* result = cobj->getData(); + ok &= nativevalue_to_se(result, s.rval(), nullptr /*ctx*/); + SE_PRECONDITION2(ok, false, "js_assets_ImageAsset_getData : Error processing arguments"); + SE_HOLD_RETURN_VALUE(result, s.thisObject(), s.rval()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 0); + return false; +} +SE_BIND_FUNC(js_assets_ImageAsset_getData) + +static bool js_assets_ImageAsset_getFormat(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_assets_ImageAsset_getFormat : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 0) { + auto result = static_cast(cobj->getFormat()); + ok &= nativevalue_to_se(result, s.rval(), nullptr /*ctx*/); + SE_PRECONDITION2(ok, false, "js_assets_ImageAsset_getFormat : Error processing arguments"); + SE_HOLD_RETURN_VALUE(result, s.thisObject(), s.rval()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 0); + return false; +} +SE_BIND_FUNC_AS_PROP_GET(js_assets_ImageAsset_getFormat) + +static bool js_assets_ImageAsset_getHeight(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_assets_ImageAsset_getHeight : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 0) { + unsigned int result = cobj->getHeight(); + ok &= nativevalue_to_se(result, s.rval(), nullptr /*ctx*/); + SE_PRECONDITION2(ok, false, "js_assets_ImageAsset_getHeight : Error processing arguments"); + SE_HOLD_RETURN_VALUE(result, s.thisObject(), s.rval()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 0); + return false; +} +SE_BIND_FUNC(js_assets_ImageAsset_getHeight) + +static bool js_assets_ImageAsset_getUrl(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_assets_ImageAsset_getUrl : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 0) { + std::string result = cobj->getUrl(); + ok &= nativevalue_to_se(result, s.rval(), nullptr /*ctx*/); + SE_PRECONDITION2(ok, false, "js_assets_ImageAsset_getUrl : Error processing arguments"); + SE_HOLD_RETURN_VALUE(result, s.thisObject(), s.rval()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 0); + return false; +} +SE_BIND_FUNC_AS_PROP_GET(js_assets_ImageAsset_getUrl) +SE_BIND_FUNC(js_assets_ImageAsset_getUrl) + +static bool js_assets_ImageAsset_getWidth(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_assets_ImageAsset_getWidth : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 0) { + unsigned int result = cobj->getWidth(); + ok &= nativevalue_to_se(result, s.rval(), nullptr /*ctx*/); + SE_PRECONDITION2(ok, false, "js_assets_ImageAsset_getWidth : Error processing arguments"); + SE_HOLD_RETURN_VALUE(result, s.thisObject(), s.rval()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 0); + return false; +} +SE_BIND_FUNC(js_assets_ImageAsset_getWidth) + +static bool js_assets_ImageAsset_isCompressed(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_assets_ImageAsset_isCompressed : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 0) { + bool result = cobj->isCompressed(); + ok &= nativevalue_to_se(result, s.rval(), nullptr /*ctx*/); + SE_PRECONDITION2(ok, false, "js_assets_ImageAsset_isCompressed : Error processing arguments"); + SE_HOLD_RETURN_VALUE(result, s.thisObject(), s.rval()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 0); + return false; +} +SE_BIND_FUNC(js_assets_ImageAsset_isCompressed) + +static bool js_assets_ImageAsset_setFormat(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_assets_ImageAsset_setFormat : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 1) { + HolderType arg0 = {}; + ok &= sevalue_to_native(args[0], &arg0, s.thisObject()); + SE_PRECONDITION2(ok, false, "js_assets_ImageAsset_setFormat : Error processing arguments"); + cobj->setFormat(arg0.value()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 1); + return false; +} +SE_BIND_FUNC_AS_PROP_SET(js_assets_ImageAsset_setFormat) + +static bool js_assets_ImageAsset_setHeight(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_assets_ImageAsset_setHeight : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 1) { + HolderType arg0 = {}; + ok &= sevalue_to_native(args[0], &arg0, s.thisObject()); + SE_PRECONDITION2(ok, false, "js_assets_ImageAsset_setHeight : Error processing arguments"); + cobj->setHeight(arg0.value()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 1); + return false; +} +SE_BIND_FUNC(js_assets_ImageAsset_setHeight) + +static bool js_assets_ImageAsset_setUrl(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_assets_ImageAsset_setUrl : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 1) { + HolderType arg0 = {}; + ok &= sevalue_to_native(args[0], &arg0, s.thisObject()); + SE_PRECONDITION2(ok, false, "js_assets_ImageAsset_setUrl : Error processing arguments"); + cobj->setUrl(arg0.value()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 1); + return false; +} +SE_BIND_FUNC_AS_PROP_SET(js_assets_ImageAsset_setUrl) +SE_BIND_FUNC(js_assets_ImageAsset_setUrl) + +static bool js_assets_ImageAsset_setWidth(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_assets_ImageAsset_setWidth : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 1) { + HolderType arg0 = {}; + ok &= sevalue_to_native(args[0], &arg0, s.thisObject()); + SE_PRECONDITION2(ok, false, "js_assets_ImageAsset_setWidth : Error processing arguments"); + cobj->setWidth(arg0.value()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 1); + return false; +} +SE_BIND_FUNC(js_assets_ImageAsset_setWidth) + +SE_DECLARE_FINALIZE_FUNC(js_cc_ImageAsset_finalize) + +static bool js_assets_ImageAsset_constructor(se::State& s) // NOLINT(readability-identifier-naming) constructor.c +{ + auto *ptr = JSB_MAKE_PRIVATE_OBJECT(cc::ImageAsset); + s.thisObject()->setPrivateObject(ptr); + return true; +} +SE_BIND_CTOR(js_assets_ImageAsset_constructor, __jsb_cc_ImageAsset_class, js_cc_ImageAsset_finalize) + +static bool js_cc_ImageAsset_finalize(se::State& s) // NOLINT(readability-identifier-naming) +{ + return true; +} +SE_BIND_FINALIZE_FUNC(js_cc_ImageAsset_finalize) + +bool js_register_assets_ImageAsset(se::Object* obj) // NOLINT(readability-identifier-naming) +{ + auto* cls = se::Class::create("ImageAsset", obj, __jsb_cc_Asset_proto, _SE(js_assets_ImageAsset_constructor)); + + cls->defineProperty("url", _SE(js_assets_ImageAsset_getUrl_asGetter), _SE(js_assets_ImageAsset_setUrl_asSetter)); + cls->defineProperty("format", _SE(js_assets_ImageAsset_getFormat_asGetter), _SE(js_assets_ImageAsset_setFormat_asSetter)); + cls->defineFunction("getData", _SE(js_assets_ImageAsset_getData)); + cls->defineFunction("getHeight", _SE(js_assets_ImageAsset_getHeight)); + cls->defineFunction("getUrl", _SE(js_assets_ImageAsset_getUrl)); + cls->defineFunction("getWidth", _SE(js_assets_ImageAsset_getWidth)); + cls->defineFunction("isCompressed", _SE(js_assets_ImageAsset_isCompressed)); + cls->defineFunction("setHeight", _SE(js_assets_ImageAsset_setHeight)); + cls->defineFunction("setUrl", _SE(js_assets_ImageAsset_setUrl)); + cls->defineFunction("setWidth", _SE(js_assets_ImageAsset_setWidth)); + cls->defineFinalizeFunction(_SE(js_cc_ImageAsset_finalize)); + cls->install(); + JSBClassType::registerClass(cls); + + __jsb_cc_ImageAsset_proto = cls->getProto(); + __jsb_cc_ImageAsset_class = cls; + + + se::ScriptEngine::getInstance()->clearException(); + return true; +} +se::Object* __jsb_cc_IMaterialInfo_proto = nullptr; // NOLINT +se::Class* __jsb_cc_IMaterialInfo_class = nullptr; // NOLINT + +static bool js_assets_IMaterialInfo_get_effectAsset(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_assets_IMaterialInfo_get_effectAsset : Invalid Native Object"); + + CC_UNUSED bool ok = true; + se::Value jsret; + ok &= nativevalue_to_se(cobj->effectAsset, jsret, s.thisObject() /*ctx*/); + s.rval() = jsret; + SE_HOLD_RETURN_VALUE(cobj->effectAsset, s.thisObject(), s.rval()); + return true; +} +SE_BIND_PROP_GET(js_assets_IMaterialInfo_get_effectAsset) + +static bool js_assets_IMaterialInfo_set_effectAsset(se::State& s) // NOLINT(readability-identifier-naming) +{ + const auto& args = s.args(); + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_assets_IMaterialInfo_set_effectAsset : Invalid Native Object"); + + CC_UNUSED bool ok = true; + ok &= sevalue_to_native(args[0], &cobj->effectAsset, s.thisObject()); + SE_PRECONDITION2(ok, false, "js_assets_IMaterialInfo_set_effectAsset : Error processing new value"); + return true; +} +SE_BIND_PROP_SET(js_assets_IMaterialInfo_set_effectAsset) + +static bool js_assets_IMaterialInfo_get_effectName(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_assets_IMaterialInfo_get_effectName : Invalid Native Object"); + + CC_UNUSED bool ok = true; + se::Value jsret; + ok &= nativevalue_to_se(cobj->effectName, jsret, s.thisObject() /*ctx*/); + s.rval() = jsret; + SE_HOLD_RETURN_VALUE(cobj->effectName, s.thisObject(), s.rval()); + return true; +} +SE_BIND_PROP_GET(js_assets_IMaterialInfo_get_effectName) + +static bool js_assets_IMaterialInfo_set_effectName(se::State& s) // NOLINT(readability-identifier-naming) +{ + const auto& args = s.args(); + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_assets_IMaterialInfo_set_effectName : Invalid Native Object"); + + CC_UNUSED bool ok = true; + ok &= sevalue_to_native(args[0], &cobj->effectName, s.thisObject()); + SE_PRECONDITION2(ok, false, "js_assets_IMaterialInfo_set_effectName : Error processing new value"); + return true; +} +SE_BIND_PROP_SET(js_assets_IMaterialInfo_set_effectName) + +static bool js_assets_IMaterialInfo_get_technique(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_assets_IMaterialInfo_get_technique : Invalid Native Object"); + + CC_UNUSED bool ok = true; + se::Value jsret; + ok &= nativevalue_to_se(cobj->technique, jsret, s.thisObject() /*ctx*/); + s.rval() = jsret; + SE_HOLD_RETURN_VALUE(cobj->technique, s.thisObject(), s.rval()); + return true; +} +SE_BIND_PROP_GET(js_assets_IMaterialInfo_get_technique) + +static bool js_assets_IMaterialInfo_set_technique(se::State& s) // NOLINT(readability-identifier-naming) +{ + const auto& args = s.args(); + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_assets_IMaterialInfo_set_technique : Invalid Native Object"); + + CC_UNUSED bool ok = true; + ok &= sevalue_to_native(args[0], &cobj->technique, s.thisObject()); + SE_PRECONDITION2(ok, false, "js_assets_IMaterialInfo_set_technique : Error processing new value"); + return true; +} +SE_BIND_PROP_SET(js_assets_IMaterialInfo_set_technique) + +static bool js_assets_IMaterialInfo_get_defines(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_assets_IMaterialInfo_get_defines : Invalid Native Object"); + + CC_UNUSED bool ok = true; + se::Value jsret; + ok &= nativevalue_to_se(cobj->defines, jsret, s.thisObject() /*ctx*/); + s.rval() = jsret; + SE_HOLD_RETURN_VALUE(cobj->defines, s.thisObject(), s.rval()); + return true; +} +SE_BIND_PROP_GET(js_assets_IMaterialInfo_get_defines) + +static bool js_assets_IMaterialInfo_set_defines(se::State& s) // NOLINT(readability-identifier-naming) +{ + const auto& args = s.args(); + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_assets_IMaterialInfo_set_defines : Invalid Native Object"); + + CC_UNUSED bool ok = true; + ok &= sevalue_to_native(args[0], &cobj->defines, s.thisObject()); + SE_PRECONDITION2(ok, false, "js_assets_IMaterialInfo_set_defines : Error processing new value"); + return true; +} +SE_BIND_PROP_SET(js_assets_IMaterialInfo_set_defines) + +static bool js_assets_IMaterialInfo_get_states(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_assets_IMaterialInfo_get_states : Invalid Native Object"); + + CC_UNUSED bool ok = true; + se::Value jsret; + ok &= nativevalue_to_se(cobj->states, jsret, s.thisObject() /*ctx*/); + s.rval() = jsret; + SE_HOLD_RETURN_VALUE(cobj->states, s.thisObject(), s.rval()); + return true; +} +SE_BIND_PROP_GET(js_assets_IMaterialInfo_get_states) + +static bool js_assets_IMaterialInfo_set_states(se::State& s) // NOLINT(readability-identifier-naming) +{ + const auto& args = s.args(); + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_assets_IMaterialInfo_set_states : Invalid Native Object"); + + CC_UNUSED bool ok = true; + ok &= sevalue_to_native(args[0], &cobj->states, s.thisObject()); + SE_PRECONDITION2(ok, false, "js_assets_IMaterialInfo_set_states : Error processing new value"); + return true; +} +SE_BIND_PROP_SET(js_assets_IMaterialInfo_set_states) + + +template<> +bool sevalue_to_native(const se::Value &from, cc::IMaterialInfo * to, se::Object *ctx) +{ + assert(from.isObject()); + se::Object *json = from.toObject(); + auto* data = reinterpret_cast(json->getPrivateData()); + if (data) { + *to = *data; + return true; + } + se::Value field; + bool ok = true; + json->getProperty("effectAsset", &field, true); + if(!field.isNullOrUndefined()) { + ok &= sevalue_to_native(field, &(to->effectAsset), ctx); + } + json->getProperty("effectName", &field, true); + if(!field.isNullOrUndefined()) { + ok &= sevalue_to_native(field, &(to->effectName), ctx); + } + json->getProperty("technique", &field, true); + if(!field.isNullOrUndefined()) { + ok &= sevalue_to_native(field, &(to->technique), ctx); + } + json->getProperty("defines", &field, true); + if(!field.isNullOrUndefined()) { + ok &= sevalue_to_native(field, &(to->defines), ctx); + } + json->getProperty("states", &field, true); + if(!field.isNullOrUndefined()) { + ok &= sevalue_to_native(field, &(to->states), ctx); + } + return ok; +} + +SE_DECLARE_FINALIZE_FUNC(js_cc_IMaterialInfo_finalize) + +static bool js_assets_IMaterialInfo_constructor(se::State& s) // NOLINT(readability-identifier-naming) +{ + CC_UNUSED bool ok = true; + const auto& args = s.args(); + size_t argc = args.size(); + + if(argc == 0) + { + auto *ptr = JSB_MAKE_PRIVATE_OBJECT(cc::IMaterialInfo); + s.thisObject()->setPrivateObject(ptr); + return true; + } + + if(argc == 1 && args[0].isObject()) + { + se::Object *json = args[0].toObject(); + se::Value field; + auto *ptr = JSB_MAKE_PRIVATE_OBJECT(cc::IMaterialInfo); + auto cobj = ptr->get(); + ok &= sevalue_to_native(args[0], cobj, s.thisObject()); + if(!ok) { + delete ptr; + SE_REPORT_ERROR("argument convertion error"); + return false; + } + s.thisObject()->setPrivateObject(ptr); + return true; + } + auto *ptr = JSB_MAKE_PRIVATE_OBJECT(cc::IMaterialInfo); + auto cobj = ptr->get(); + if (argc > 0 && !args[0].isUndefined()) { + ok &= sevalue_to_native(args[0], &(cobj->effectAsset), nullptr); + } + if (argc > 1 && !args[1].isUndefined()) { + ok &= sevalue_to_native(args[1], &(cobj->effectName), nullptr); + } + if (argc > 2 && !args[2].isUndefined()) { + ok &= sevalue_to_native(args[2], &(cobj->technique), nullptr); + } + if (argc > 3 && !args[3].isUndefined()) { + ok &= sevalue_to_native(args[3], &(cobj->defines), nullptr); + } + if (argc > 4 && !args[4].isUndefined()) { + ok &= sevalue_to_native(args[4], &(cobj->states), nullptr); + } + + if(!ok) { + delete ptr; + SE_REPORT_ERROR("Argument convertion error"); + return false; + } + s.thisObject()->setPrivateObject(ptr); + return true; +} +SE_BIND_CTOR(js_assets_IMaterialInfo_constructor, __jsb_cc_IMaterialInfo_class, js_cc_IMaterialInfo_finalize) + +static bool js_cc_IMaterialInfo_finalize(se::State& s) // NOLINT(readability-identifier-naming) +{ + return true; +} +SE_BIND_FINALIZE_FUNC(js_cc_IMaterialInfo_finalize) + +bool js_register_assets_IMaterialInfo(se::Object* obj) // NOLINT(readability-identifier-naming) +{ + auto* cls = se::Class::create("IMaterialInfo", obj, nullptr, _SE(js_assets_IMaterialInfo_constructor)); + + cls->defineProperty("effectAsset", _SE(js_assets_IMaterialInfo_get_effectAsset), _SE(js_assets_IMaterialInfo_set_effectAsset)); + cls->defineProperty("effectName", _SE(js_assets_IMaterialInfo_get_effectName), _SE(js_assets_IMaterialInfo_set_effectName)); + cls->defineProperty("technique", _SE(js_assets_IMaterialInfo_get_technique), _SE(js_assets_IMaterialInfo_set_technique)); + cls->defineProperty("defines", _SE(js_assets_IMaterialInfo_get_defines), _SE(js_assets_IMaterialInfo_set_defines)); + cls->defineProperty("states", _SE(js_assets_IMaterialInfo_get_states), _SE(js_assets_IMaterialInfo_set_states)); + cls->defineFinalizeFunction(_SE(js_cc_IMaterialInfo_finalize)); + cls->install(); + JSBClassType::registerClass(cls); + + __jsb_cc_IMaterialInfo_proto = cls->getProto(); + __jsb_cc_IMaterialInfo_class = cls; + + + se::ScriptEngine::getInstance()->clearException(); + return true; +} +se::Object* __jsb_cc_Material_proto = nullptr; // NOLINT +se::Class* __jsb_cc_Material_class = nullptr; // NOLINT + +static bool js_assets_Material_copy(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_assets_Material_copy : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 1) { + HolderType arg0 = {}; + ok &= sevalue_to_native(args[0], &arg0, s.thisObject()); + SE_PRECONDITION2(ok, false, "js_assets_Material_copy : Error processing arguments"); + cobj->copy(arg0.value()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 1); + return false; +} +SE_BIND_FUNC(js_assets_Material_copy) + +static bool js_assets_Material_getEffectAsset(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_assets_Material_getEffectAsset : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 0) { + cc::EffectAsset* result = cobj->getEffectAsset(); + ok &= nativevalue_to_se(result, s.rval(), nullptr /*ctx*/); + SE_PRECONDITION2(ok, false, "js_assets_Material_getEffectAsset : Error processing arguments"); + SE_HOLD_RETURN_VALUE(result, s.thisObject(), s.rval()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 0); + return false; +} +SE_BIND_FUNC_AS_PROP_GET(js_assets_Material_getEffectAsset) + +static bool js_assets_Material_getEffectName(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_assets_Material_getEffectName : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 0) { + std::string result = cobj->getEffectName(); + ok &= nativevalue_to_se(result, s.rval(), nullptr /*ctx*/); + SE_PRECONDITION2(ok, false, "js_assets_Material_getEffectName : Error processing arguments"); + SE_HOLD_RETURN_VALUE(result, s.thisObject(), s.rval()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 0); + return false; +} +SE_BIND_FUNC_AS_PROP_GET(js_assets_Material_getEffectName) + +static bool js_assets_Material_getHashForJS(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_assets_Material_getHashForJS : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 0) { + double result = cobj->getHashForJS(); + ok &= nativevalue_to_se(result, s.rval(), nullptr /*ctx*/); + SE_PRECONDITION2(ok, false, "js_assets_Material_getHashForJS : Error processing arguments"); + SE_HOLD_RETURN_VALUE(result, s.thisObject(), s.rval()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 0); + return false; +} +SE_BIND_FUNC_AS_PROP_GET(js_assets_Material_getHashForJS) + +static bool js_assets_Material_getParent(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_assets_Material_getParent : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 0) { + cc::Material* result = cobj->getParent(); + ok &= nativevalue_to_se(result, s.rval(), nullptr /*ctx*/); + SE_PRECONDITION2(ok, false, "js_assets_Material_getParent : Error processing arguments"); + SE_HOLD_RETURN_VALUE(result, s.thisObject(), s.rval()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 0); + return false; +} +SE_BIND_FUNC_AS_PROP_GET(js_assets_Material_getParent) + +static bool js_assets_Material_getPasses(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_assets_Material_getPasses : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 0) { + std::shared_ptr>>& result = cobj->getPasses(); + ok &= nativevalue_to_se(result, s.rval(), nullptr /*ctx*/); + SE_PRECONDITION2(ok, false, "js_assets_Material_getPasses : Error processing arguments"); + SE_HOLD_RETURN_VALUE(result, s.thisObject(), s.rval()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 0); + return false; +} +SE_BIND_FUNC(js_assets_Material_getPasses) + +static bool js_assets_Material_getProperty(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_assets_Material_getProperty : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 1) { + HolderType arg0 = {}; + ok &= sevalue_to_native(args[0], &arg0, s.thisObject()); + SE_PRECONDITION2(ok, false, "js_assets_Material_getProperty : Error processing arguments"); + const boost::variant2::variant, std::vector>>* result = cobj->getProperty(arg0.value()); + ok &= nativevalue_to_se(result, s.rval(), nullptr /*ctx*/); + SE_PRECONDITION2(ok, false, "js_assets_Material_getProperty : Error processing arguments"); + SE_HOLD_RETURN_VALUE(result, s.thisObject(), s.rval()); + return true; + } + if (argc == 2) { + HolderType arg0 = {}; + HolderType arg1 = {}; + ok &= sevalue_to_native(args[0], &arg0, s.thisObject()); + ok &= sevalue_to_native(args[1], &arg1, s.thisObject()); + SE_PRECONDITION2(ok, false, "js_assets_Material_getProperty : Error processing arguments"); + const boost::variant2::variant, std::vector>>* result = cobj->getProperty(arg0.value(), arg1.value()); + ok &= nativevalue_to_se(result, s.rval(), nullptr /*ctx*/); + SE_PRECONDITION2(ok, false, "js_assets_Material_getProperty : Error processing arguments"); + SE_HOLD_RETURN_VALUE(result, s.thisObject(), s.rval()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 2); + return false; +} +SE_BIND_FUNC(js_assets_Material_getProperty) + +static bool js_assets_Material_getTechniqueIndex(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_assets_Material_getTechniqueIndex : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 0) { + unsigned int result = cobj->getTechniqueIndex(); + ok &= nativevalue_to_se(result, s.rval(), nullptr /*ctx*/); + SE_PRECONDITION2(ok, false, "js_assets_Material_getTechniqueIndex : Error processing arguments"); + SE_HOLD_RETURN_VALUE(result, s.thisObject(), s.rval()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 0); + return false; +} +SE_BIND_FUNC_AS_PROP_GET(js_assets_Material_getTechniqueIndex) + +static bool js_assets_Material_initialize(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_assets_Material_initialize : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 1) { + HolderType arg0 = {}; + ok &= sevalue_to_native(args[0], &arg0, s.thisObject()); + SE_PRECONDITION2(ok, false, "js_assets_Material_initialize : Error processing arguments"); + cobj->initialize(arg0.value()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 1); + return false; +} +SE_BIND_FUNC(js_assets_Material_initialize) + +static bool js_assets_Material_overridePipelineStates(se::State& s) // NOLINT(readability-identifier-naming) +{ + CC_UNUSED bool ok = true; + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2( cobj, false, "js_assets_Material_overridePipelineStates : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + do { + if (argc == 2) { + HolderType arg0 = {}; + HolderType arg1 = {}; + + ok &= sevalue_to_native(args[0], &arg0, s.thisObject()); + if (!ok) { ok = true; break; } + ok &= sevalue_to_native(args[1], &arg1, s.thisObject()); + if (!ok) { ok = true; break; } + cobj->overridePipelineStates(arg0.value(), arg1.value()); + return true; + } + } while(false); + + do { + if (argc == 1) { + HolderType arg0 = {}; + + ok &= sevalue_to_native(args[0], &arg0, s.thisObject()); + if (!ok) { ok = true; break; } + cobj->overridePipelineStates(arg0.value()); + return true; + } + } while(false); + + SE_REPORT_ERROR("wrong number of arguments: %d", (int)argc); + return false; +} +SE_BIND_FUNC(js_assets_Material_overridePipelineStates) + +static bool js_assets_Material_recompileShaders(se::State& s) // NOLINT(readability-identifier-naming) +{ + CC_UNUSED bool ok = true; + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2( cobj, false, "js_assets_Material_recompileShaders : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + do { + if (argc == 2) { + HolderType>, true> arg0 = {}; + HolderType arg1 = {}; + + ok &= sevalue_to_native(args[0], &arg0, s.thisObject()); + if (!ok) { ok = true; break; } + ok &= sevalue_to_native(args[1], &arg1, s.thisObject()); + if (!ok) { ok = true; break; } + cobj->recompileShaders(arg0.value(), arg1.value()); + return true; + } + } while(false); + + do { + if (argc == 1) { + HolderType>, true> arg0 = {}; + + ok &= sevalue_to_native(args[0], &arg0, s.thisObject()); + if (!ok) { ok = true; break; } + cobj->recompileShaders(arg0.value()); + return true; + } + } while(false); + + SE_REPORT_ERROR("wrong number of arguments: %d", (int)argc); + return false; +} +SE_BIND_FUNC(js_assets_Material_recompileShaders) + +static bool js_assets_Material_reset(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_assets_Material_reset : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 1) { + HolderType arg0 = {}; + ok &= sevalue_to_native(args[0], &arg0, s.thisObject()); + SE_PRECONDITION2(ok, false, "js_assets_Material_reset : Error processing arguments"); + cobj->reset(arg0.value()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 1); + return false; +} +SE_BIND_FUNC(js_assets_Material_reset) + +static bool js_assets_Material_resetUniforms(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_assets_Material_resetUniforms : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 0) { + cobj->resetUniforms(); + return true; + } + if (argc == 1) { + HolderType arg0 = {}; + ok &= sevalue_to_native(args[0], &arg0, s.thisObject()); + SE_PRECONDITION2(ok, false, "js_assets_Material_resetUniforms : Error processing arguments"); + cobj->resetUniforms(arg0.value()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 1); + return false; +} +SE_BIND_FUNC(js_assets_Material_resetUniforms) + +static bool js_assets_Material_setEffectAsset(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_assets_Material_setEffectAsset : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 1) { + HolderType arg0 = {}; + ok &= sevalue_to_native(args[0], &arg0, s.thisObject()); + SE_PRECONDITION2(ok, false, "js_assets_Material_setEffectAsset : Error processing arguments"); + cobj->setEffectAsset(arg0.value()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 1); + return false; +} +SE_BIND_FUNC_AS_PROP_SET(js_assets_Material_setEffectAsset) + +static bool js_assets_Material_setPropertyColor(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_assets_Material_setPropertyColor : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 2) { + HolderType arg0 = {}; + HolderType arg1 = {}; + ok &= sevalue_to_native(args[0], &arg0, s.thisObject()); + ok &= sevalue_to_native(args[1], &arg1, s.thisObject()); + SE_PRECONDITION2(ok, false, "js_assets_Material_setPropertyColor : Error processing arguments"); + cobj->setPropertyColor(arg0.value(), arg1.value()); + return true; + } + if (argc == 3) { + HolderType arg0 = {}; + HolderType arg1 = {}; + HolderType arg2 = {}; + ok &= sevalue_to_native(args[0], &arg0, s.thisObject()); + ok &= sevalue_to_native(args[1], &arg1, s.thisObject()); + ok &= sevalue_to_native(args[2], &arg2, s.thisObject()); + SE_PRECONDITION2(ok, false, "js_assets_Material_setPropertyColor : Error processing arguments"); + cobj->setPropertyColor(arg0.value(), arg1.value(), arg2.value()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 3); + return false; +} +SE_BIND_FUNC(js_assets_Material_setPropertyColor) + +static bool js_assets_Material_setPropertyColorArray(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_assets_Material_setPropertyColorArray : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 2) { + HolderType arg0 = {}; + HolderType, true> arg1 = {}; + ok &= sevalue_to_native(args[0], &arg0, s.thisObject()); + ok &= sevalue_to_native(args[1], &arg1, s.thisObject()); + SE_PRECONDITION2(ok, false, "js_assets_Material_setPropertyColorArray : Error processing arguments"); + cobj->setPropertyColorArray(arg0.value(), arg1.value()); + return true; + } + if (argc == 3) { + HolderType arg0 = {}; + HolderType, true> arg1 = {}; + HolderType arg2 = {}; + ok &= sevalue_to_native(args[0], &arg0, s.thisObject()); + ok &= sevalue_to_native(args[1], &arg1, s.thisObject()); + ok &= sevalue_to_native(args[2], &arg2, s.thisObject()); + SE_PRECONDITION2(ok, false, "js_assets_Material_setPropertyColorArray : Error processing arguments"); + cobj->setPropertyColorArray(arg0.value(), arg1.value(), arg2.value()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 3); + return false; +} +SE_BIND_FUNC(js_assets_Material_setPropertyColorArray) + +static bool js_assets_Material_setPropertyFloat32(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_assets_Material_setPropertyFloat32 : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 2) { + HolderType arg0 = {}; + HolderType arg1 = {}; + ok &= sevalue_to_native(args[0], &arg0, s.thisObject()); + ok &= sevalue_to_native(args[1], &arg1, s.thisObject()); + SE_PRECONDITION2(ok, false, "js_assets_Material_setPropertyFloat32 : Error processing arguments"); + cobj->setPropertyFloat32(arg0.value(), arg1.value()); + return true; + } + if (argc == 3) { + HolderType arg0 = {}; + HolderType arg1 = {}; + HolderType arg2 = {}; + ok &= sevalue_to_native(args[0], &arg0, s.thisObject()); + ok &= sevalue_to_native(args[1], &arg1, s.thisObject()); + ok &= sevalue_to_native(args[2], &arg2, s.thisObject()); + SE_PRECONDITION2(ok, false, "js_assets_Material_setPropertyFloat32 : Error processing arguments"); + cobj->setPropertyFloat32(arg0.value(), arg1.value(), arg2.value()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 3); + return false; +} +SE_BIND_FUNC(js_assets_Material_setPropertyFloat32) + +static bool js_assets_Material_setPropertyFloat32Array(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_assets_Material_setPropertyFloat32Array : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 2) { + HolderType arg0 = {}; + HolderType, true> arg1 = {}; + ok &= sevalue_to_native(args[0], &arg0, s.thisObject()); + ok &= sevalue_to_native(args[1], &arg1, s.thisObject()); + SE_PRECONDITION2(ok, false, "js_assets_Material_setPropertyFloat32Array : Error processing arguments"); + cobj->setPropertyFloat32Array(arg0.value(), arg1.value()); + return true; + } + if (argc == 3) { + HolderType arg0 = {}; + HolderType, true> arg1 = {}; + HolderType arg2 = {}; + ok &= sevalue_to_native(args[0], &arg0, s.thisObject()); + ok &= sevalue_to_native(args[1], &arg1, s.thisObject()); + ok &= sevalue_to_native(args[2], &arg2, s.thisObject()); + SE_PRECONDITION2(ok, false, "js_assets_Material_setPropertyFloat32Array : Error processing arguments"); + cobj->setPropertyFloat32Array(arg0.value(), arg1.value(), arg2.value()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 3); + return false; +} +SE_BIND_FUNC(js_assets_Material_setPropertyFloat32Array) + +static bool js_assets_Material_setPropertyGFXTexture(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_assets_Material_setPropertyGFXTexture : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 2) { + HolderType arg0 = {}; + HolderType arg1 = {}; + ok &= sevalue_to_native(args[0], &arg0, s.thisObject()); + ok &= sevalue_to_native(args[1], &arg1, s.thisObject()); + SE_PRECONDITION2(ok, false, "js_assets_Material_setPropertyGFXTexture : Error processing arguments"); + cobj->setPropertyGFXTexture(arg0.value(), arg1.value()); + return true; + } + if (argc == 3) { + HolderType arg0 = {}; + HolderType arg1 = {}; + HolderType arg2 = {}; + ok &= sevalue_to_native(args[0], &arg0, s.thisObject()); + ok &= sevalue_to_native(args[1], &arg1, s.thisObject()); + ok &= sevalue_to_native(args[2], &arg2, s.thisObject()); + SE_PRECONDITION2(ok, false, "js_assets_Material_setPropertyGFXTexture : Error processing arguments"); + cobj->setPropertyGFXTexture(arg0.value(), arg1.value(), arg2.value()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 3); + return false; +} +SE_BIND_FUNC(js_assets_Material_setPropertyGFXTexture) + +static bool js_assets_Material_setPropertyGFXTextureArray(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_assets_Material_setPropertyGFXTextureArray : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 2) { + HolderType arg0 = {}; + HolderType, true> arg1 = {}; + ok &= sevalue_to_native(args[0], &arg0, s.thisObject()); + ok &= sevalue_to_native(args[1], &arg1, s.thisObject()); + SE_PRECONDITION2(ok, false, "js_assets_Material_setPropertyGFXTextureArray : Error processing arguments"); + cobj->setPropertyGFXTextureArray(arg0.value(), arg1.value()); + return true; + } + if (argc == 3) { + HolderType arg0 = {}; + HolderType, true> arg1 = {}; + HolderType arg2 = {}; + ok &= sevalue_to_native(args[0], &arg0, s.thisObject()); + ok &= sevalue_to_native(args[1], &arg1, s.thisObject()); + ok &= sevalue_to_native(args[2], &arg2, s.thisObject()); + SE_PRECONDITION2(ok, false, "js_assets_Material_setPropertyGFXTextureArray : Error processing arguments"); + cobj->setPropertyGFXTextureArray(arg0.value(), arg1.value(), arg2.value()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 3); + return false; +} +SE_BIND_FUNC(js_assets_Material_setPropertyGFXTextureArray) + +static bool js_assets_Material_setPropertyInt32(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_assets_Material_setPropertyInt32 : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 2) { + HolderType arg0 = {}; + HolderType arg1 = {}; + ok &= sevalue_to_native(args[0], &arg0, s.thisObject()); + ok &= sevalue_to_native(args[1], &arg1, s.thisObject()); + SE_PRECONDITION2(ok, false, "js_assets_Material_setPropertyInt32 : Error processing arguments"); + cobj->setPropertyInt32(arg0.value(), arg1.value()); + return true; + } + if (argc == 3) { + HolderType arg0 = {}; + HolderType arg1 = {}; + HolderType arg2 = {}; + ok &= sevalue_to_native(args[0], &arg0, s.thisObject()); + ok &= sevalue_to_native(args[1], &arg1, s.thisObject()); + ok &= sevalue_to_native(args[2], &arg2, s.thisObject()); + SE_PRECONDITION2(ok, false, "js_assets_Material_setPropertyInt32 : Error processing arguments"); + cobj->setPropertyInt32(arg0.value(), arg1.value(), arg2.value()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 3); + return false; +} +SE_BIND_FUNC(js_assets_Material_setPropertyInt32) + +static bool js_assets_Material_setPropertyInt32Array(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_assets_Material_setPropertyInt32Array : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 2) { + HolderType arg0 = {}; + HolderType, true> arg1 = {}; + ok &= sevalue_to_native(args[0], &arg0, s.thisObject()); + ok &= sevalue_to_native(args[1], &arg1, s.thisObject()); + SE_PRECONDITION2(ok, false, "js_assets_Material_setPropertyInt32Array : Error processing arguments"); + cobj->setPropertyInt32Array(arg0.value(), arg1.value()); + return true; + } + if (argc == 3) { + HolderType arg0 = {}; + HolderType, true> arg1 = {}; + HolderType arg2 = {}; + ok &= sevalue_to_native(args[0], &arg0, s.thisObject()); + ok &= sevalue_to_native(args[1], &arg1, s.thisObject()); + ok &= sevalue_to_native(args[2], &arg2, s.thisObject()); + SE_PRECONDITION2(ok, false, "js_assets_Material_setPropertyInt32Array : Error processing arguments"); + cobj->setPropertyInt32Array(arg0.value(), arg1.value(), arg2.value()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 3); + return false; +} +SE_BIND_FUNC(js_assets_Material_setPropertyInt32Array) + +static bool js_assets_Material_setPropertyMat3(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_assets_Material_setPropertyMat3 : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 2) { + HolderType arg0 = {}; + HolderType arg1 = {}; + ok &= sevalue_to_native(args[0], &arg0, s.thisObject()); + ok &= sevalue_to_native(args[1], &arg1, s.thisObject()); + SE_PRECONDITION2(ok, false, "js_assets_Material_setPropertyMat3 : Error processing arguments"); + cobj->setPropertyMat3(arg0.value(), arg1.value()); + return true; + } + if (argc == 3) { + HolderType arg0 = {}; + HolderType arg1 = {}; + HolderType arg2 = {}; + ok &= sevalue_to_native(args[0], &arg0, s.thisObject()); + ok &= sevalue_to_native(args[1], &arg1, s.thisObject()); + ok &= sevalue_to_native(args[2], &arg2, s.thisObject()); + SE_PRECONDITION2(ok, false, "js_assets_Material_setPropertyMat3 : Error processing arguments"); + cobj->setPropertyMat3(arg0.value(), arg1.value(), arg2.value()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 3); + return false; +} +SE_BIND_FUNC(js_assets_Material_setPropertyMat3) + +static bool js_assets_Material_setPropertyMat3Array(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_assets_Material_setPropertyMat3Array : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 2) { + HolderType arg0 = {}; + HolderType, true> arg1 = {}; + ok &= sevalue_to_native(args[0], &arg0, s.thisObject()); + ok &= sevalue_to_native(args[1], &arg1, s.thisObject()); + SE_PRECONDITION2(ok, false, "js_assets_Material_setPropertyMat3Array : Error processing arguments"); + cobj->setPropertyMat3Array(arg0.value(), arg1.value()); + return true; + } + if (argc == 3) { + HolderType arg0 = {}; + HolderType, true> arg1 = {}; + HolderType arg2 = {}; + ok &= sevalue_to_native(args[0], &arg0, s.thisObject()); + ok &= sevalue_to_native(args[1], &arg1, s.thisObject()); + ok &= sevalue_to_native(args[2], &arg2, s.thisObject()); + SE_PRECONDITION2(ok, false, "js_assets_Material_setPropertyMat3Array : Error processing arguments"); + cobj->setPropertyMat3Array(arg0.value(), arg1.value(), arg2.value()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 3); + return false; +} +SE_BIND_FUNC(js_assets_Material_setPropertyMat3Array) + +static bool js_assets_Material_setPropertyMat4(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_assets_Material_setPropertyMat4 : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 2) { + HolderType arg0 = {}; + HolderType arg1 = {}; + ok &= sevalue_to_native(args[0], &arg0, s.thisObject()); + ok &= sevalue_to_native(args[1], &arg1, s.thisObject()); + SE_PRECONDITION2(ok, false, "js_assets_Material_setPropertyMat4 : Error processing arguments"); + cobj->setPropertyMat4(arg0.value(), arg1.value()); + return true; + } + if (argc == 3) { + HolderType arg0 = {}; + HolderType arg1 = {}; + HolderType arg2 = {}; + ok &= sevalue_to_native(args[0], &arg0, s.thisObject()); + ok &= sevalue_to_native(args[1], &arg1, s.thisObject()); + ok &= sevalue_to_native(args[2], &arg2, s.thisObject()); + SE_PRECONDITION2(ok, false, "js_assets_Material_setPropertyMat4 : Error processing arguments"); + cobj->setPropertyMat4(arg0.value(), arg1.value(), arg2.value()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 3); + return false; +} +SE_BIND_FUNC(js_assets_Material_setPropertyMat4) + +static bool js_assets_Material_setPropertyMat4Array(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_assets_Material_setPropertyMat4Array : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 2) { + HolderType arg0 = {}; + HolderType, true> arg1 = {}; + ok &= sevalue_to_native(args[0], &arg0, s.thisObject()); + ok &= sevalue_to_native(args[1], &arg1, s.thisObject()); + SE_PRECONDITION2(ok, false, "js_assets_Material_setPropertyMat4Array : Error processing arguments"); + cobj->setPropertyMat4Array(arg0.value(), arg1.value()); + return true; + } + if (argc == 3) { + HolderType arg0 = {}; + HolderType, true> arg1 = {}; + HolderType arg2 = {}; + ok &= sevalue_to_native(args[0], &arg0, s.thisObject()); + ok &= sevalue_to_native(args[1], &arg1, s.thisObject()); + ok &= sevalue_to_native(args[2], &arg2, s.thisObject()); + SE_PRECONDITION2(ok, false, "js_assets_Material_setPropertyMat4Array : Error processing arguments"); + cobj->setPropertyMat4Array(arg0.value(), arg1.value(), arg2.value()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 3); + return false; +} +SE_BIND_FUNC(js_assets_Material_setPropertyMat4Array) + +static bool js_assets_Material_setPropertyQuaternion(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_assets_Material_setPropertyQuaternion : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 2) { + HolderType arg0 = {}; + HolderType arg1 = {}; + ok &= sevalue_to_native(args[0], &arg0, s.thisObject()); + ok &= sevalue_to_native(args[1], &arg1, s.thisObject()); + SE_PRECONDITION2(ok, false, "js_assets_Material_setPropertyQuaternion : Error processing arguments"); + cobj->setPropertyQuaternion(arg0.value(), arg1.value()); + return true; + } + if (argc == 3) { + HolderType arg0 = {}; + HolderType arg1 = {}; + HolderType arg2 = {}; + ok &= sevalue_to_native(args[0], &arg0, s.thisObject()); + ok &= sevalue_to_native(args[1], &arg1, s.thisObject()); + ok &= sevalue_to_native(args[2], &arg2, s.thisObject()); + SE_PRECONDITION2(ok, false, "js_assets_Material_setPropertyQuaternion : Error processing arguments"); + cobj->setPropertyQuaternion(arg0.value(), arg1.value(), arg2.value()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 3); + return false; +} +SE_BIND_FUNC(js_assets_Material_setPropertyQuaternion) + +static bool js_assets_Material_setPropertyQuaternionArray(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_assets_Material_setPropertyQuaternionArray : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 2) { + HolderType arg0 = {}; + HolderType, true> arg1 = {}; + ok &= sevalue_to_native(args[0], &arg0, s.thisObject()); + ok &= sevalue_to_native(args[1], &arg1, s.thisObject()); + SE_PRECONDITION2(ok, false, "js_assets_Material_setPropertyQuaternionArray : Error processing arguments"); + cobj->setPropertyQuaternionArray(arg0.value(), arg1.value()); + return true; + } + if (argc == 3) { + HolderType arg0 = {}; + HolderType, true> arg1 = {}; + HolderType arg2 = {}; + ok &= sevalue_to_native(args[0], &arg0, s.thisObject()); + ok &= sevalue_to_native(args[1], &arg1, s.thisObject()); + ok &= sevalue_to_native(args[2], &arg2, s.thisObject()); + SE_PRECONDITION2(ok, false, "js_assets_Material_setPropertyQuaternionArray : Error processing arguments"); + cobj->setPropertyQuaternionArray(arg0.value(), arg1.value(), arg2.value()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 3); + return false; +} +SE_BIND_FUNC(js_assets_Material_setPropertyQuaternionArray) + +static bool js_assets_Material_setPropertyTextureBase(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_assets_Material_setPropertyTextureBase : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 2) { + HolderType arg0 = {}; + HolderType arg1 = {}; + ok &= sevalue_to_native(args[0], &arg0, s.thisObject()); + ok &= sevalue_to_native(args[1], &arg1, s.thisObject()); + SE_PRECONDITION2(ok, false, "js_assets_Material_setPropertyTextureBase : Error processing arguments"); + cobj->setPropertyTextureBase(arg0.value(), arg1.value()); + return true; + } + if (argc == 3) { + HolderType arg0 = {}; + HolderType arg1 = {}; + HolderType arg2 = {}; + ok &= sevalue_to_native(args[0], &arg0, s.thisObject()); + ok &= sevalue_to_native(args[1], &arg1, s.thisObject()); + ok &= sevalue_to_native(args[2], &arg2, s.thisObject()); + SE_PRECONDITION2(ok, false, "js_assets_Material_setPropertyTextureBase : Error processing arguments"); + cobj->setPropertyTextureBase(arg0.value(), arg1.value(), arg2.value()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 3); + return false; +} +SE_BIND_FUNC(js_assets_Material_setPropertyTextureBase) + +static bool js_assets_Material_setPropertyTextureBaseArray(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_assets_Material_setPropertyTextureBaseArray : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 2) { + HolderType arg0 = {}; + HolderType, true> arg1 = {}; + ok &= sevalue_to_native(args[0], &arg0, s.thisObject()); + ok &= sevalue_to_native(args[1], &arg1, s.thisObject()); + SE_PRECONDITION2(ok, false, "js_assets_Material_setPropertyTextureBaseArray : Error processing arguments"); + cobj->setPropertyTextureBaseArray(arg0.value(), arg1.value()); + return true; + } + if (argc == 3) { + HolderType arg0 = {}; + HolderType, true> arg1 = {}; + HolderType arg2 = {}; + ok &= sevalue_to_native(args[0], &arg0, s.thisObject()); + ok &= sevalue_to_native(args[1], &arg1, s.thisObject()); + ok &= sevalue_to_native(args[2], &arg2, s.thisObject()); + SE_PRECONDITION2(ok, false, "js_assets_Material_setPropertyTextureBaseArray : Error processing arguments"); + cobj->setPropertyTextureBaseArray(arg0.value(), arg1.value(), arg2.value()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 3); + return false; +} +SE_BIND_FUNC(js_assets_Material_setPropertyTextureBaseArray) + +static bool js_assets_Material_setPropertyVec2(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_assets_Material_setPropertyVec2 : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 2) { + HolderType arg0 = {}; + HolderType arg1 = {}; + ok &= sevalue_to_native(args[0], &arg0, s.thisObject()); + ok &= sevalue_to_native(args[1], &arg1, s.thisObject()); + SE_PRECONDITION2(ok, false, "js_assets_Material_setPropertyVec2 : Error processing arguments"); + cobj->setPropertyVec2(arg0.value(), arg1.value()); + return true; + } + if (argc == 3) { + HolderType arg0 = {}; + HolderType arg1 = {}; + HolderType arg2 = {}; + ok &= sevalue_to_native(args[0], &arg0, s.thisObject()); + ok &= sevalue_to_native(args[1], &arg1, s.thisObject()); + ok &= sevalue_to_native(args[2], &arg2, s.thisObject()); + SE_PRECONDITION2(ok, false, "js_assets_Material_setPropertyVec2 : Error processing arguments"); + cobj->setPropertyVec2(arg0.value(), arg1.value(), arg2.value()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 3); + return false; +} +SE_BIND_FUNC(js_assets_Material_setPropertyVec2) + +static bool js_assets_Material_setPropertyVec2Array(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_assets_Material_setPropertyVec2Array : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 2) { + HolderType arg0 = {}; + HolderType, true> arg1 = {}; + ok &= sevalue_to_native(args[0], &arg0, s.thisObject()); + ok &= sevalue_to_native(args[1], &arg1, s.thisObject()); + SE_PRECONDITION2(ok, false, "js_assets_Material_setPropertyVec2Array : Error processing arguments"); + cobj->setPropertyVec2Array(arg0.value(), arg1.value()); + return true; + } + if (argc == 3) { + HolderType arg0 = {}; + HolderType, true> arg1 = {}; + HolderType arg2 = {}; + ok &= sevalue_to_native(args[0], &arg0, s.thisObject()); + ok &= sevalue_to_native(args[1], &arg1, s.thisObject()); + ok &= sevalue_to_native(args[2], &arg2, s.thisObject()); + SE_PRECONDITION2(ok, false, "js_assets_Material_setPropertyVec2Array : Error processing arguments"); + cobj->setPropertyVec2Array(arg0.value(), arg1.value(), arg2.value()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 3); + return false; +} +SE_BIND_FUNC(js_assets_Material_setPropertyVec2Array) + +static bool js_assets_Material_setPropertyVec3(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_assets_Material_setPropertyVec3 : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 2) { + HolderType arg0 = {}; + HolderType arg1 = {}; + ok &= sevalue_to_native(args[0], &arg0, s.thisObject()); + ok &= sevalue_to_native(args[1], &arg1, s.thisObject()); + SE_PRECONDITION2(ok, false, "js_assets_Material_setPropertyVec3 : Error processing arguments"); + cobj->setPropertyVec3(arg0.value(), arg1.value()); + return true; + } + if (argc == 3) { + HolderType arg0 = {}; + HolderType arg1 = {}; + HolderType arg2 = {}; + ok &= sevalue_to_native(args[0], &arg0, s.thisObject()); + ok &= sevalue_to_native(args[1], &arg1, s.thisObject()); + ok &= sevalue_to_native(args[2], &arg2, s.thisObject()); + SE_PRECONDITION2(ok, false, "js_assets_Material_setPropertyVec3 : Error processing arguments"); + cobj->setPropertyVec3(arg0.value(), arg1.value(), arg2.value()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 3); + return false; +} +SE_BIND_FUNC(js_assets_Material_setPropertyVec3) + +static bool js_assets_Material_setPropertyVec3Array(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_assets_Material_setPropertyVec3Array : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 2) { + HolderType arg0 = {}; + HolderType, true> arg1 = {}; + ok &= sevalue_to_native(args[0], &arg0, s.thisObject()); + ok &= sevalue_to_native(args[1], &arg1, s.thisObject()); + SE_PRECONDITION2(ok, false, "js_assets_Material_setPropertyVec3Array : Error processing arguments"); + cobj->setPropertyVec3Array(arg0.value(), arg1.value()); + return true; + } + if (argc == 3) { + HolderType arg0 = {}; + HolderType, true> arg1 = {}; + HolderType arg2 = {}; + ok &= sevalue_to_native(args[0], &arg0, s.thisObject()); + ok &= sevalue_to_native(args[1], &arg1, s.thisObject()); + ok &= sevalue_to_native(args[2], &arg2, s.thisObject()); + SE_PRECONDITION2(ok, false, "js_assets_Material_setPropertyVec3Array : Error processing arguments"); + cobj->setPropertyVec3Array(arg0.value(), arg1.value(), arg2.value()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 3); + return false; +} +SE_BIND_FUNC(js_assets_Material_setPropertyVec3Array) + +static bool js_assets_Material_setPropertyVec4(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_assets_Material_setPropertyVec4 : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 2) { + HolderType arg0 = {}; + HolderType arg1 = {}; + ok &= sevalue_to_native(args[0], &arg0, s.thisObject()); + ok &= sevalue_to_native(args[1], &arg1, s.thisObject()); + SE_PRECONDITION2(ok, false, "js_assets_Material_setPropertyVec4 : Error processing arguments"); + cobj->setPropertyVec4(arg0.value(), arg1.value()); + return true; + } + if (argc == 3) { + HolderType arg0 = {}; + HolderType arg1 = {}; + HolderType arg2 = {}; + ok &= sevalue_to_native(args[0], &arg0, s.thisObject()); + ok &= sevalue_to_native(args[1], &arg1, s.thisObject()); + ok &= sevalue_to_native(args[2], &arg2, s.thisObject()); + SE_PRECONDITION2(ok, false, "js_assets_Material_setPropertyVec4 : Error processing arguments"); + cobj->setPropertyVec4(arg0.value(), arg1.value(), arg2.value()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 3); + return false; +} +SE_BIND_FUNC(js_assets_Material_setPropertyVec4) + +static bool js_assets_Material_setPropertyVec4Array(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_assets_Material_setPropertyVec4Array : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 2) { + HolderType arg0 = {}; + HolderType, true> arg1 = {}; + ok &= sevalue_to_native(args[0], &arg0, s.thisObject()); + ok &= sevalue_to_native(args[1], &arg1, s.thisObject()); + SE_PRECONDITION2(ok, false, "js_assets_Material_setPropertyVec4Array : Error processing arguments"); + cobj->setPropertyVec4Array(arg0.value(), arg1.value()); + return true; + } + if (argc == 3) { + HolderType arg0 = {}; + HolderType, true> arg1 = {}; + HolderType arg2 = {}; + ok &= sevalue_to_native(args[0], &arg0, s.thisObject()); + ok &= sevalue_to_native(args[1], &arg1, s.thisObject()); + ok &= sevalue_to_native(args[2], &arg2, s.thisObject()); + SE_PRECONDITION2(ok, false, "js_assets_Material_setPropertyVec4Array : Error processing arguments"); + cobj->setPropertyVec4Array(arg0.value(), arg1.value(), arg2.value()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 3); + return false; +} +SE_BIND_FUNC(js_assets_Material_setPropertyVec4Array) + +static bool js_assets_Material_update(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_assets_Material_update : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 0) { + cobj->update(); + return true; + } + if (argc == 1) { + HolderType arg0 = {}; + ok &= sevalue_to_native(args[0], &arg0, s.thisObject()); + SE_PRECONDITION2(ok, false, "js_assets_Material_update : Error processing arguments"); + cobj->update(arg0.value()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 1); + return false; +} +SE_BIND_FUNC(js_assets_Material_update) + +static bool js_assets_Material_getHashForMaterialForJS_static(se::State& s) // NOLINT(readability-identifier-naming) +{ + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 1) { + HolderType arg0 = {}; + ok &= sevalue_to_native(args[0], &arg0, nullptr); + SE_PRECONDITION2(ok, false, "js_assets_Material_getHashForMaterialForJS_static : Error processing arguments"); + double result = cc::Material::getHashForMaterialForJS(arg0.value()); + ok &= nativevalue_to_se(result, s.rval(), nullptr /*ctx*/); + SE_PRECONDITION2(ok, false, "js_assets_Material_getHashForMaterialForJS_static : Error processing arguments"); + SE_HOLD_RETURN_VALUE(result, s.thisObject(), s.rval()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 1); + return false; +} +SE_BIND_FUNC(js_assets_Material_getHashForMaterialForJS_static) + +static bool js_assets_Material_get__effectAsset(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_assets_Material_get__effectAsset : Invalid Native Object"); + + CC_UNUSED bool ok = true; + se::Value jsret; + ok &= nativevalue_to_se(cobj->_effectAsset, jsret, s.thisObject() /*ctx*/); + s.rval() = jsret; + SE_HOLD_RETURN_VALUE(cobj->_effectAsset, s.thisObject(), s.rval()); + return true; +} +SE_BIND_PROP_GET(js_assets_Material_get__effectAsset) + +static bool js_assets_Material_set__effectAsset(se::State& s) // NOLINT(readability-identifier-naming) +{ + const auto& args = s.args(); + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_assets_Material_set__effectAsset : Invalid Native Object"); + + CC_UNUSED bool ok = true; + ok &= sevalue_to_native(args[0], &cobj->_effectAsset, s.thisObject()); + SE_PRECONDITION2(ok, false, "js_assets_Material_set__effectAsset : Error processing new value"); + return true; +} +SE_BIND_PROP_SET(js_assets_Material_set__effectAsset) + +static bool js_assets_Material_get__techIdx(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_assets_Material_get__techIdx : Invalid Native Object"); + + CC_UNUSED bool ok = true; + se::Value jsret; + ok &= nativevalue_to_se(cobj->_techIdx, jsret, s.thisObject() /*ctx*/); + s.rval() = jsret; + SE_HOLD_RETURN_VALUE(cobj->_techIdx, s.thisObject(), s.rval()); + return true; +} +SE_BIND_PROP_GET(js_assets_Material_get__techIdx) + +static bool js_assets_Material_set__techIdx(se::State& s) // NOLINT(readability-identifier-naming) +{ + const auto& args = s.args(); + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_assets_Material_set__techIdx : Invalid Native Object"); + + CC_UNUSED bool ok = true; + ok &= sevalue_to_native(args[0], &cobj->_techIdx, s.thisObject()); + SE_PRECONDITION2(ok, false, "js_assets_Material_set__techIdx : Error processing new value"); + return true; +} +SE_BIND_PROP_SET(js_assets_Material_set__techIdx) + +static bool js_assets_Material_get__defines(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_assets_Material_get__defines : Invalid Native Object"); + + CC_UNUSED bool ok = true; + se::Value jsret; + ok &= nativevalue_to_se(cobj->_defines, jsret, s.thisObject() /*ctx*/); + s.rval() = jsret; + SE_HOLD_RETURN_VALUE(cobj->_defines, s.thisObject(), s.rval()); + return true; +} +SE_BIND_PROP_GET(js_assets_Material_get__defines) + +static bool js_assets_Material_set__defines(se::State& s) // NOLINT(readability-identifier-naming) +{ + const auto& args = s.args(); + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_assets_Material_set__defines : Invalid Native Object"); + + CC_UNUSED bool ok = true; + ok &= sevalue_to_native(args[0], &cobj->_defines, s.thisObject()); + SE_PRECONDITION2(ok, false, "js_assets_Material_set__defines : Error processing new value"); + return true; +} +SE_BIND_PROP_SET(js_assets_Material_set__defines) + +static bool js_assets_Material_get__states(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_assets_Material_get__states : Invalid Native Object"); + + CC_UNUSED bool ok = true; + se::Value jsret; + ok &= nativevalue_to_se(cobj->_states, jsret, s.thisObject() /*ctx*/); + s.rval() = jsret; + SE_HOLD_RETURN_VALUE(cobj->_states, s.thisObject(), s.rval()); + return true; +} +SE_BIND_PROP_GET(js_assets_Material_get__states) + +static bool js_assets_Material_set__states(se::State& s) // NOLINT(readability-identifier-naming) +{ + const auto& args = s.args(); + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_assets_Material_set__states : Invalid Native Object"); + + CC_UNUSED bool ok = true; + ok &= sevalue_to_native(args[0], &cobj->_states, s.thisObject()); + SE_PRECONDITION2(ok, false, "js_assets_Material_set__states : Error processing new value"); + return true; +} +SE_BIND_PROP_SET(js_assets_Material_set__states) + +static bool js_assets_Material_get__props(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_assets_Material_get__props : Invalid Native Object"); + + CC_UNUSED bool ok = true; + se::Value jsret; + ok &= nativevalue_to_se(cobj->_props, jsret, s.thisObject() /*ctx*/); + s.rval() = jsret; + SE_HOLD_RETURN_VALUE(cobj->_props, s.thisObject(), s.rval()); + return true; +} +SE_BIND_PROP_GET(js_assets_Material_get__props) + +static bool js_assets_Material_set__props(se::State& s) // NOLINT(readability-identifier-naming) +{ + const auto& args = s.args(); + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_assets_Material_set__props : Invalid Native Object"); + + CC_UNUSED bool ok = true; + ok &= sevalue_to_native(args[0], &cobj->_props, s.thisObject()); + SE_PRECONDITION2(ok, false, "js_assets_Material_set__props : Error processing new value"); + return true; +} +SE_BIND_PROP_SET(js_assets_Material_set__props) + +SE_DECLARE_FINALIZE_FUNC(js_cc_Material_finalize) + +static bool js_assets_Material_constructor(se::State& s) // NOLINT(readability-identifier-naming) constructor.c +{ + auto *ptr = JSB_MAKE_PRIVATE_OBJECT(cc::Material); + s.thisObject()->setPrivateObject(ptr); + return true; +} +SE_BIND_CTOR(js_assets_Material_constructor, __jsb_cc_Material_class, js_cc_Material_finalize) + +static bool js_cc_Material_finalize(se::State& s) // NOLINT(readability-identifier-naming) +{ + return true; +} +SE_BIND_FINALIZE_FUNC(js_cc_Material_finalize) + +bool js_register_assets_Material(se::Object* obj) // NOLINT(readability-identifier-naming) +{ + auto* cls = se::Class::create("Material", obj, __jsb_cc_Asset_proto, _SE(js_assets_Material_constructor)); + + cls->defineProperty("_effectAsset", _SE(js_assets_Material_get__effectAsset), _SE(js_assets_Material_set__effectAsset)); + cls->defineProperty("_techIdx", _SE(js_assets_Material_get__techIdx), _SE(js_assets_Material_set__techIdx)); + cls->defineProperty("_defines", _SE(js_assets_Material_get__defines), _SE(js_assets_Material_set__defines)); + cls->defineProperty("_states", _SE(js_assets_Material_get__states), _SE(js_assets_Material_set__states)); + cls->defineProperty("_propsInternal", _SE(js_assets_Material_get__props), _SE(js_assets_Material_set__props)); + cls->defineProperty("hash", _SE(js_assets_Material_getHashForJS_asGetter), nullptr); + cls->defineProperty("technique", _SE(js_assets_Material_getTechniqueIndex_asGetter), nullptr); + cls->defineProperty("effectName", _SE(js_assets_Material_getEffectName_asGetter), nullptr); + cls->defineProperty("parent", _SE(js_assets_Material_getParent_asGetter), nullptr); + cls->defineProperty("effectAsset", _SE(js_assets_Material_getEffectAsset_asGetter), _SE(js_assets_Material_setEffectAsset_asSetter)); + cls->defineFunction("copy", _SE(js_assets_Material_copy)); + cls->defineFunction("getPasses", _SE(js_assets_Material_getPasses)); + cls->defineFunction("_getProperty", _SE(js_assets_Material_getProperty)); + cls->defineFunction("initialize", _SE(js_assets_Material_initialize)); + cls->defineFunction("overridePipelineStates", _SE(js_assets_Material_overridePipelineStates)); + cls->defineFunction("recompileShaders", _SE(js_assets_Material_recompileShaders)); + cls->defineFunction("reset", _SE(js_assets_Material_reset)); + cls->defineFunction("resetUniforms", _SE(js_assets_Material_resetUniforms)); + cls->defineFunction("setPropertyColor", _SE(js_assets_Material_setPropertyColor)); + cls->defineFunction("setPropertyColorArray", _SE(js_assets_Material_setPropertyColorArray)); + cls->defineFunction("setPropertyFloat32", _SE(js_assets_Material_setPropertyFloat32)); + cls->defineFunction("setPropertyFloat32Array", _SE(js_assets_Material_setPropertyFloat32Array)); + cls->defineFunction("setPropertyGFXTexture", _SE(js_assets_Material_setPropertyGFXTexture)); + cls->defineFunction("setPropertyGFXTextureArray", _SE(js_assets_Material_setPropertyGFXTextureArray)); + cls->defineFunction("setPropertyInt32", _SE(js_assets_Material_setPropertyInt32)); + cls->defineFunction("setPropertyInt32Array", _SE(js_assets_Material_setPropertyInt32Array)); + cls->defineFunction("setPropertyMat3", _SE(js_assets_Material_setPropertyMat3)); + cls->defineFunction("setPropertyMat3Array", _SE(js_assets_Material_setPropertyMat3Array)); + cls->defineFunction("setPropertyMat4", _SE(js_assets_Material_setPropertyMat4)); + cls->defineFunction("setPropertyMat4Array", _SE(js_assets_Material_setPropertyMat4Array)); + cls->defineFunction("setPropertyQuaternion", _SE(js_assets_Material_setPropertyQuaternion)); + cls->defineFunction("setPropertyQuaternionArray", _SE(js_assets_Material_setPropertyQuaternionArray)); + cls->defineFunction("setPropertyTextureBase", _SE(js_assets_Material_setPropertyTextureBase)); + cls->defineFunction("setPropertyTextureBaseArray", _SE(js_assets_Material_setPropertyTextureBaseArray)); + cls->defineFunction("setPropertyVec2", _SE(js_assets_Material_setPropertyVec2)); + cls->defineFunction("setPropertyVec2Array", _SE(js_assets_Material_setPropertyVec2Array)); + cls->defineFunction("setPropertyVec3", _SE(js_assets_Material_setPropertyVec3)); + cls->defineFunction("setPropertyVec3Array", _SE(js_assets_Material_setPropertyVec3Array)); + cls->defineFunction("setPropertyVec4", _SE(js_assets_Material_setPropertyVec4)); + cls->defineFunction("setPropertyVec4Array", _SE(js_assets_Material_setPropertyVec4Array)); + cls->defineFunction("update", _SE(js_assets_Material_update)); + cls->defineStaticFunction("getHashForMaterial", _SE(js_assets_Material_getHashForMaterialForJS_static)); + cls->defineFinalizeFunction(_SE(js_cc_Material_finalize)); + cls->install(); + JSBClassType::registerClass(cls); + + __jsb_cc_Material_proto = cls->getProto(); + __jsb_cc_Material_class = cls; + + + se::ScriptEngine::getInstance()->clearException(); + return true; +} +se::Object* __jsb_cc_IRenderTextureCreateInfo_proto = nullptr; // NOLINT +se::Class* __jsb_cc_IRenderTextureCreateInfo_class = nullptr; // NOLINT + +static bool js_assets_IRenderTextureCreateInfo_get_name(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_assets_IRenderTextureCreateInfo_get_name : Invalid Native Object"); + + CC_UNUSED bool ok = true; + se::Value jsret; + ok &= nativevalue_to_se(cobj->name, jsret, s.thisObject() /*ctx*/); + s.rval() = jsret; + SE_HOLD_RETURN_VALUE(cobj->name, s.thisObject(), s.rval()); + return true; +} +SE_BIND_PROP_GET(js_assets_IRenderTextureCreateInfo_get_name) + +static bool js_assets_IRenderTextureCreateInfo_set_name(se::State& s) // NOLINT(readability-identifier-naming) +{ + const auto& args = s.args(); + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_assets_IRenderTextureCreateInfo_set_name : Invalid Native Object"); + + CC_UNUSED bool ok = true; + ok &= sevalue_to_native(args[0], &cobj->name, s.thisObject()); + SE_PRECONDITION2(ok, false, "js_assets_IRenderTextureCreateInfo_set_name : Error processing new value"); + return true; +} +SE_BIND_PROP_SET(js_assets_IRenderTextureCreateInfo_set_name) + +static bool js_assets_IRenderTextureCreateInfo_get_width(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_assets_IRenderTextureCreateInfo_get_width : Invalid Native Object"); + + CC_UNUSED bool ok = true; + se::Value jsret; + ok &= nativevalue_to_se(cobj->width, jsret, s.thisObject() /*ctx*/); + s.rval() = jsret; + SE_HOLD_RETURN_VALUE(cobj->width, s.thisObject(), s.rval()); + return true; +} +SE_BIND_PROP_GET(js_assets_IRenderTextureCreateInfo_get_width) + +static bool js_assets_IRenderTextureCreateInfo_set_width(se::State& s) // NOLINT(readability-identifier-naming) +{ + const auto& args = s.args(); + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_assets_IRenderTextureCreateInfo_set_width : Invalid Native Object"); + + CC_UNUSED bool ok = true; + ok &= sevalue_to_native(args[0], &cobj->width, s.thisObject()); + SE_PRECONDITION2(ok, false, "js_assets_IRenderTextureCreateInfo_set_width : Error processing new value"); + return true; +} +SE_BIND_PROP_SET(js_assets_IRenderTextureCreateInfo_set_width) + +static bool js_assets_IRenderTextureCreateInfo_get_height(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_assets_IRenderTextureCreateInfo_get_height : Invalid Native Object"); + + CC_UNUSED bool ok = true; + se::Value jsret; + ok &= nativevalue_to_se(cobj->height, jsret, s.thisObject() /*ctx*/); + s.rval() = jsret; + SE_HOLD_RETURN_VALUE(cobj->height, s.thisObject(), s.rval()); + return true; +} +SE_BIND_PROP_GET(js_assets_IRenderTextureCreateInfo_get_height) + +static bool js_assets_IRenderTextureCreateInfo_set_height(se::State& s) // NOLINT(readability-identifier-naming) +{ + const auto& args = s.args(); + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_assets_IRenderTextureCreateInfo_set_height : Invalid Native Object"); + + CC_UNUSED bool ok = true; + ok &= sevalue_to_native(args[0], &cobj->height, s.thisObject()); + SE_PRECONDITION2(ok, false, "js_assets_IRenderTextureCreateInfo_set_height : Error processing new value"); + return true; +} +SE_BIND_PROP_SET(js_assets_IRenderTextureCreateInfo_set_height) + +static bool js_assets_IRenderTextureCreateInfo_get_passInfo(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_assets_IRenderTextureCreateInfo_get_passInfo : Invalid Native Object"); + + CC_UNUSED bool ok = true; + se::Value jsret; + ok &= nativevalue_to_se(cobj->passInfo, jsret, s.thisObject() /*ctx*/); + s.rval() = jsret; + SE_HOLD_RETURN_VALUE(cobj->passInfo, s.thisObject(), s.rval()); + return true; +} +SE_BIND_PROP_GET(js_assets_IRenderTextureCreateInfo_get_passInfo) + +static bool js_assets_IRenderTextureCreateInfo_set_passInfo(se::State& s) // NOLINT(readability-identifier-naming) +{ + const auto& args = s.args(); + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_assets_IRenderTextureCreateInfo_set_passInfo : Invalid Native Object"); + + CC_UNUSED bool ok = true; + ok &= sevalue_to_native(args[0], &cobj->passInfo, s.thisObject()); + SE_PRECONDITION2(ok, false, "js_assets_IRenderTextureCreateInfo_set_passInfo : Error processing new value"); + return true; +} +SE_BIND_PROP_SET(js_assets_IRenderTextureCreateInfo_set_passInfo) + + +template<> +bool sevalue_to_native(const se::Value &from, cc::IRenderTextureCreateInfo * to, se::Object *ctx) +{ + assert(from.isObject()); + se::Object *json = from.toObject(); + auto* data = reinterpret_cast(json->getPrivateData()); + if (data) { + *to = *data; + return true; + } + se::Value field; + bool ok = true; + json->getProperty("name", &field, true); + if(!field.isNullOrUndefined()) { + ok &= sevalue_to_native(field, &(to->name), ctx); + } + json->getProperty("width", &field, true); + if(!field.isNullOrUndefined()) { + ok &= sevalue_to_native(field, &(to->width), ctx); + } + json->getProperty("height", &field, true); + if(!field.isNullOrUndefined()) { + ok &= sevalue_to_native(field, &(to->height), ctx); + } + json->getProperty("passInfo", &field, true); + if(!field.isNullOrUndefined()) { + ok &= sevalue_to_native(field, &(to->passInfo), ctx); + } + return ok; +} + +SE_DECLARE_FINALIZE_FUNC(js_cc_IRenderTextureCreateInfo_finalize) + +static bool js_assets_IRenderTextureCreateInfo_constructor(se::State& s) // NOLINT(readability-identifier-naming) +{ + CC_UNUSED bool ok = true; + const auto& args = s.args(); + size_t argc = args.size(); + + if(argc == 0) + { + auto *ptr = JSB_MAKE_PRIVATE_OBJECT(cc::IRenderTextureCreateInfo); + s.thisObject()->setPrivateObject(ptr); + return true; + } + + if(argc == 1 && args[0].isObject()) + { + se::Object *json = args[0].toObject(); + se::Value field; + auto *ptr = JSB_MAKE_PRIVATE_OBJECT(cc::IRenderTextureCreateInfo); + auto cobj = ptr->get(); + ok &= sevalue_to_native(args[0], cobj, s.thisObject()); + if(!ok) { + delete ptr; + SE_REPORT_ERROR("argument convertion error"); + return false; + } + s.thisObject()->setPrivateObject(ptr); + return true; + } + auto *ptr = JSB_MAKE_PRIVATE_OBJECT(cc::IRenderTextureCreateInfo); + auto cobj = ptr->get(); + if (argc > 0 && !args[0].isUndefined()) { + ok &= sevalue_to_native(args[0], &(cobj->name), nullptr); + } + if (argc > 1 && !args[1].isUndefined()) { + ok &= sevalue_to_native(args[1], &(cobj->width), nullptr); + } + if (argc > 2 && !args[2].isUndefined()) { + ok &= sevalue_to_native(args[2], &(cobj->height), nullptr); + } + if (argc > 3 && !args[3].isUndefined()) { + ok &= sevalue_to_native(args[3], &(cobj->passInfo), nullptr); + } + + if(!ok) { + delete ptr; + SE_REPORT_ERROR("Argument convertion error"); + return false; + } + s.thisObject()->setPrivateObject(ptr); + return true; +} +SE_BIND_CTOR(js_assets_IRenderTextureCreateInfo_constructor, __jsb_cc_IRenderTextureCreateInfo_class, js_cc_IRenderTextureCreateInfo_finalize) + +static bool js_cc_IRenderTextureCreateInfo_finalize(se::State& s) // NOLINT(readability-identifier-naming) +{ + return true; +} +SE_BIND_FINALIZE_FUNC(js_cc_IRenderTextureCreateInfo_finalize) + +bool js_register_assets_IRenderTextureCreateInfo(se::Object* obj) // NOLINT(readability-identifier-naming) +{ + auto* cls = se::Class::create("IRenderTextureCreateInfo", obj, nullptr, _SE(js_assets_IRenderTextureCreateInfo_constructor)); + + cls->defineProperty("name", _SE(js_assets_IRenderTextureCreateInfo_get_name), _SE(js_assets_IRenderTextureCreateInfo_set_name)); + cls->defineProperty("width", _SE(js_assets_IRenderTextureCreateInfo_get_width), _SE(js_assets_IRenderTextureCreateInfo_set_width)); + cls->defineProperty("height", _SE(js_assets_IRenderTextureCreateInfo_get_height), _SE(js_assets_IRenderTextureCreateInfo_set_height)); + cls->defineProperty("passInfo", _SE(js_assets_IRenderTextureCreateInfo_get_passInfo), _SE(js_assets_IRenderTextureCreateInfo_set_passInfo)); + cls->defineFinalizeFunction(_SE(js_cc_IRenderTextureCreateInfo_finalize)); + cls->install(); + JSBClassType::registerClass(cls); + + __jsb_cc_IRenderTextureCreateInfo_proto = cls->getProto(); + __jsb_cc_IRenderTextureCreateInfo_class = cls; + + + se::ScriptEngine::getInstance()->clearException(); + return true; +} +se::Object* __jsb_cc_RenderTexture_proto = nullptr; // NOLINT +se::Class* __jsb_cc_RenderTexture_class = nullptr; // NOLINT + +static bool js_assets_RenderTexture_getWindow(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_assets_RenderTexture_getWindow : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 0) { + cc::scene::RenderWindow* result = cobj->getWindow(); + ok &= nativevalue_to_se(result, s.rval(), nullptr /*ctx*/); + SE_PRECONDITION2(ok, false, "js_assets_RenderTexture_getWindow : Error processing arguments"); + SE_HOLD_RETURN_VALUE(result, s.thisObject(), s.rval()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 0); + return false; +} +SE_BIND_FUNC_AS_PROP_GET(js_assets_RenderTexture_getWindow) + +static bool js_assets_RenderTexture_initWindow(se::State& s) // NOLINT(readability-identifier-naming) +{ + CC_UNUSED bool ok = true; + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2( cobj, false, "js_assets_RenderTexture_initWindow : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + do { + if (argc == 1) { + HolderType arg0 = {}; + + ok &= sevalue_to_native(args[0], &arg0, s.thisObject()); + if (!ok) { ok = true; break; } + cobj->initWindow(arg0.value()); + return true; + } + } while(false); + + do { + if (argc == 0) { + + cobj->initWindow(); + return true; + } + } while(false); + + SE_REPORT_ERROR("wrong number of arguments: %d", (int)argc); + return false; +} +SE_BIND_FUNC(js_assets_RenderTexture_initWindow) + +static bool js_assets_RenderTexture_initialize(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_assets_RenderTexture_initialize : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 1) { + HolderType arg0 = {}; + ok &= sevalue_to_native(args[0], &arg0, s.thisObject()); + SE_PRECONDITION2(ok, false, "js_assets_RenderTexture_initialize : Error processing arguments"); + cobj->initialize(arg0.value()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 1); + return false; +} +SE_BIND_FUNC(js_assets_RenderTexture_initialize) + +static bool js_assets_RenderTexture_readPixels(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_assets_RenderTexture_readPixels : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 4) { + HolderType arg0 = {}; + HolderType arg1 = {}; + HolderType arg2 = {}; + HolderType arg3 = {}; + ok &= sevalue_to_native(args[0], &arg0, s.thisObject()); + ok &= sevalue_to_native(args[1], &arg1, s.thisObject()); + ok &= sevalue_to_native(args[2], &arg2, s.thisObject()); + ok &= sevalue_to_native(args[3], &arg3, s.thisObject()); + SE_PRECONDITION2(ok, false, "js_assets_RenderTexture_readPixels : Error processing arguments"); + std::vector result = cobj->readPixels(arg0.value(), arg1.value(), arg2.value(), arg3.value()); + ok &= nativevalue_to_se(result, s.rval(), nullptr /*ctx*/); + SE_PRECONDITION2(ok, false, "js_assets_RenderTexture_readPixels : Error processing arguments"); + SE_HOLD_RETURN_VALUE(result, s.thisObject(), s.rval()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 4); + return false; +} +SE_BIND_FUNC(js_assets_RenderTexture_readPixels) + +static bool js_assets_RenderTexture_reset(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_assets_RenderTexture_reset : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 1) { + HolderType arg0 = {}; + ok &= sevalue_to_native(args[0], &arg0, s.thisObject()); + SE_PRECONDITION2(ok, false, "js_assets_RenderTexture_reset : Error processing arguments"); + cobj->reset(arg0.value()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 1); + return false; +} +SE_BIND_FUNC(js_assets_RenderTexture_reset) + +static bool js_assets_RenderTexture_resize(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_assets_RenderTexture_resize : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 2) { + HolderType arg0 = {}; + HolderType arg1 = {}; + ok &= sevalue_to_native(args[0], &arg0, s.thisObject()); + ok &= sevalue_to_native(args[1], &arg1, s.thisObject()); + SE_PRECONDITION2(ok, false, "js_assets_RenderTexture_resize : Error processing arguments"); + cobj->resize(arg0.value(), arg1.value()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 2); + return false; +} +SE_BIND_FUNC(js_assets_RenderTexture_resize) + +SE_DECLARE_FINALIZE_FUNC(js_cc_RenderTexture_finalize) + +static bool js_assets_RenderTexture_constructor(se::State& s) // NOLINT(readability-identifier-naming) constructor.c +{ + auto *ptr = JSB_MAKE_PRIVATE_OBJECT(cc::RenderTexture); + s.thisObject()->setPrivateObject(ptr); + return true; +} +SE_BIND_CTOR(js_assets_RenderTexture_constructor, __jsb_cc_RenderTexture_class, js_cc_RenderTexture_finalize) + +static bool js_cc_RenderTexture_finalize(se::State& s) // NOLINT(readability-identifier-naming) +{ + return true; +} +SE_BIND_FINALIZE_FUNC(js_cc_RenderTexture_finalize) + +bool js_register_assets_RenderTexture(se::Object* obj) // NOLINT(readability-identifier-naming) +{ + auto* cls = se::Class::create("RenderTexture", obj, __jsb_cc_TextureBase_proto, _SE(js_assets_RenderTexture_constructor)); + + cls->defineProperty("window", _SE(js_assets_RenderTexture_getWindow_asGetter), nullptr); + cls->defineFunction("initWindow", _SE(js_assets_RenderTexture_initWindow)); + cls->defineFunction("initialize", _SE(js_assets_RenderTexture_initialize)); + cls->defineFunction("readPixels", _SE(js_assets_RenderTexture_readPixels)); + cls->defineFunction("reset", _SE(js_assets_RenderTexture_reset)); + cls->defineFunction("resize", _SE(js_assets_RenderTexture_resize)); + cls->defineFinalizeFunction(_SE(js_cc_RenderTexture_finalize)); + cls->install(); + JSBClassType::registerClass(cls); + + __jsb_cc_RenderTexture_proto = cls->getProto(); + __jsb_cc_RenderTexture_class = cls; + + + se::ScriptEngine::getInstance()->clearException(); + return true; +} +se::Object* __jsb_cc_IMeshBufferView_proto = nullptr; // NOLINT +se::Class* __jsb_cc_IMeshBufferView_class = nullptr; // NOLINT + +static bool js_assets_IMeshBufferView_get_offset(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_assets_IMeshBufferView_get_offset : Invalid Native Object"); + + CC_UNUSED bool ok = true; + se::Value jsret; + ok &= nativevalue_to_se(cobj->offset, jsret, s.thisObject() /*ctx*/); + s.rval() = jsret; + SE_HOLD_RETURN_VALUE(cobj->offset, s.thisObject(), s.rval()); + return true; +} +SE_BIND_PROP_GET(js_assets_IMeshBufferView_get_offset) + +static bool js_assets_IMeshBufferView_set_offset(se::State& s) // NOLINT(readability-identifier-naming) +{ + const auto& args = s.args(); + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_assets_IMeshBufferView_set_offset : Invalid Native Object"); + + CC_UNUSED bool ok = true; + ok &= sevalue_to_native(args[0], &cobj->offset, s.thisObject()); + SE_PRECONDITION2(ok, false, "js_assets_IMeshBufferView_set_offset : Error processing new value"); + return true; +} +SE_BIND_PROP_SET(js_assets_IMeshBufferView_set_offset) + +static bool js_assets_IMeshBufferView_get_length(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_assets_IMeshBufferView_get_length : Invalid Native Object"); + + CC_UNUSED bool ok = true; + se::Value jsret; + ok &= nativevalue_to_se(cobj->length, jsret, s.thisObject() /*ctx*/); + s.rval() = jsret; + SE_HOLD_RETURN_VALUE(cobj->length, s.thisObject(), s.rval()); + return true; +} +SE_BIND_PROP_GET(js_assets_IMeshBufferView_get_length) + +static bool js_assets_IMeshBufferView_set_length(se::State& s) // NOLINT(readability-identifier-naming) +{ + const auto& args = s.args(); + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_assets_IMeshBufferView_set_length : Invalid Native Object"); + + CC_UNUSED bool ok = true; + ok &= sevalue_to_native(args[0], &cobj->length, s.thisObject()); + SE_PRECONDITION2(ok, false, "js_assets_IMeshBufferView_set_length : Error processing new value"); + return true; +} +SE_BIND_PROP_SET(js_assets_IMeshBufferView_set_length) + +static bool js_assets_IMeshBufferView_get_count(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_assets_IMeshBufferView_get_count : Invalid Native Object"); + + CC_UNUSED bool ok = true; + se::Value jsret; + ok &= nativevalue_to_se(cobj->count, jsret, s.thisObject() /*ctx*/); + s.rval() = jsret; + SE_HOLD_RETURN_VALUE(cobj->count, s.thisObject(), s.rval()); + return true; +} +SE_BIND_PROP_GET(js_assets_IMeshBufferView_get_count) + +static bool js_assets_IMeshBufferView_set_count(se::State& s) // NOLINT(readability-identifier-naming) +{ + const auto& args = s.args(); + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_assets_IMeshBufferView_set_count : Invalid Native Object"); + + CC_UNUSED bool ok = true; + ok &= sevalue_to_native(args[0], &cobj->count, s.thisObject()); + SE_PRECONDITION2(ok, false, "js_assets_IMeshBufferView_set_count : Error processing new value"); + return true; +} +SE_BIND_PROP_SET(js_assets_IMeshBufferView_set_count) + +static bool js_assets_IMeshBufferView_get_stride(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_assets_IMeshBufferView_get_stride : Invalid Native Object"); + + CC_UNUSED bool ok = true; + se::Value jsret; + ok &= nativevalue_to_se(cobj->stride, jsret, s.thisObject() /*ctx*/); + s.rval() = jsret; + SE_HOLD_RETURN_VALUE(cobj->stride, s.thisObject(), s.rval()); + return true; +} +SE_BIND_PROP_GET(js_assets_IMeshBufferView_get_stride) + +static bool js_assets_IMeshBufferView_set_stride(se::State& s) // NOLINT(readability-identifier-naming) +{ + const auto& args = s.args(); + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_assets_IMeshBufferView_set_stride : Invalid Native Object"); + + CC_UNUSED bool ok = true; + ok &= sevalue_to_native(args[0], &cobj->stride, s.thisObject()); + SE_PRECONDITION2(ok, false, "js_assets_IMeshBufferView_set_stride : Error processing new value"); + return true; +} +SE_BIND_PROP_SET(js_assets_IMeshBufferView_set_stride) + + +template<> +bool sevalue_to_native(const se::Value &from, cc::IMeshBufferView * to, se::Object *ctx) +{ + assert(from.isObject()); + se::Object *json = from.toObject(); + auto* data = reinterpret_cast(json->getPrivateData()); + if (data) { + *to = *data; + return true; + } + se::Value field; + bool ok = true; + json->getProperty("offset", &field, true); + if(!field.isNullOrUndefined()) { + ok &= sevalue_to_native(field, &(to->offset), ctx); + } + json->getProperty("length", &field, true); + if(!field.isNullOrUndefined()) { + ok &= sevalue_to_native(field, &(to->length), ctx); + } + json->getProperty("count", &field, true); + if(!field.isNullOrUndefined()) { + ok &= sevalue_to_native(field, &(to->count), ctx); + } + json->getProperty("stride", &field, true); + if(!field.isNullOrUndefined()) { + ok &= sevalue_to_native(field, &(to->stride), ctx); + } + return ok; +} + +SE_DECLARE_FINALIZE_FUNC(js_cc_IMeshBufferView_finalize) + +static bool js_assets_IMeshBufferView_constructor(se::State& s) // NOLINT(readability-identifier-naming) +{ + CC_UNUSED bool ok = true; + const auto& args = s.args(); + size_t argc = args.size(); + + if(argc == 0) + { + auto *ptr = JSB_MAKE_PRIVATE_OBJECT(cc::IMeshBufferView); + s.thisObject()->setPrivateObject(ptr); + return true; + } + + if(argc == 1 && args[0].isObject()) + { + se::Object *json = args[0].toObject(); + se::Value field; + auto *ptr = JSB_MAKE_PRIVATE_OBJECT(cc::IMeshBufferView); + auto cobj = ptr->get(); + ok &= sevalue_to_native(args[0], cobj, s.thisObject()); + if(!ok) { + delete ptr; + SE_REPORT_ERROR("argument convertion error"); + return false; + } + s.thisObject()->setPrivateObject(ptr); + return true; + } + auto *ptr = JSB_MAKE_PRIVATE_OBJECT(cc::IMeshBufferView); + auto cobj = ptr->get(); + if (argc > 0 && !args[0].isUndefined()) { + ok &= sevalue_to_native(args[0], &(cobj->offset), nullptr); + } + if (argc > 1 && !args[1].isUndefined()) { + ok &= sevalue_to_native(args[1], &(cobj->length), nullptr); + } + if (argc > 2 && !args[2].isUndefined()) { + ok &= sevalue_to_native(args[2], &(cobj->count), nullptr); + } + if (argc > 3 && !args[3].isUndefined()) { + ok &= sevalue_to_native(args[3], &(cobj->stride), nullptr); + } + + if(!ok) { + delete ptr; + SE_REPORT_ERROR("Argument convertion error"); + return false; + } + s.thisObject()->setPrivateObject(ptr); + return true; +} +SE_BIND_CTOR(js_assets_IMeshBufferView_constructor, __jsb_cc_IMeshBufferView_class, js_cc_IMeshBufferView_finalize) + +static bool js_cc_IMeshBufferView_finalize(se::State& s) // NOLINT(readability-identifier-naming) +{ + return true; +} +SE_BIND_FINALIZE_FUNC(js_cc_IMeshBufferView_finalize) + +bool js_register_assets_IMeshBufferView(se::Object* obj) // NOLINT(readability-identifier-naming) +{ + auto* cls = se::Class::create("IMeshBufferView", obj, nullptr, _SE(js_assets_IMeshBufferView_constructor)); + + cls->defineProperty("offset", _SE(js_assets_IMeshBufferView_get_offset), _SE(js_assets_IMeshBufferView_set_offset)); + cls->defineProperty("length", _SE(js_assets_IMeshBufferView_get_length), _SE(js_assets_IMeshBufferView_set_length)); + cls->defineProperty("count", _SE(js_assets_IMeshBufferView_get_count), _SE(js_assets_IMeshBufferView_set_count)); + cls->defineProperty("stride", _SE(js_assets_IMeshBufferView_get_stride), _SE(js_assets_IMeshBufferView_set_stride)); + cls->defineFinalizeFunction(_SE(js_cc_IMeshBufferView_finalize)); + cls->install(); + JSBClassType::registerClass(cls); + + __jsb_cc_IMeshBufferView_proto = cls->getProto(); + __jsb_cc_IMeshBufferView_class = cls; + + + se::ScriptEngine::getInstance()->clearException(); + return true; +} +se::Object* __jsb_cc_MorphTarget_proto = nullptr; // NOLINT +se::Class* __jsb_cc_MorphTarget_class = nullptr; // NOLINT + +static bool js_assets_MorphTarget_get_displacements(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_assets_MorphTarget_get_displacements : Invalid Native Object"); + + CC_UNUSED bool ok = true; + se::Value jsret; + ok &= nativevalue_to_se(cobj->displacements, jsret, s.thisObject() /*ctx*/); + s.rval() = jsret; + SE_HOLD_RETURN_VALUE(cobj->displacements, s.thisObject(), s.rval()); + return true; +} +SE_BIND_PROP_GET(js_assets_MorphTarget_get_displacements) + +static bool js_assets_MorphTarget_set_displacements(se::State& s) // NOLINT(readability-identifier-naming) +{ + const auto& args = s.args(); + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_assets_MorphTarget_set_displacements : Invalid Native Object"); + + CC_UNUSED bool ok = true; + ok &= sevalue_to_native(args[0], &cobj->displacements, s.thisObject()); + SE_PRECONDITION2(ok, false, "js_assets_MorphTarget_set_displacements : Error processing new value"); + return true; +} +SE_BIND_PROP_SET(js_assets_MorphTarget_set_displacements) + + +template<> +bool sevalue_to_native(const se::Value &from, cc::MorphTarget * to, se::Object *ctx) +{ + assert(from.isObject()); + se::Object *json = from.toObject(); + auto* data = reinterpret_cast(json->getPrivateData()); + if (data) { + *to = *data; + return true; + } + se::Value field; + bool ok = true; + json->getProperty("displacements", &field, true); + if(!field.isNullOrUndefined()) { + ok &= sevalue_to_native(field, &(to->displacements), ctx); + } + return ok; +} + +SE_DECLARE_FINALIZE_FUNC(js_cc_MorphTarget_finalize) + +static bool js_assets_MorphTarget_constructor(se::State& s) // NOLINT(readability-identifier-naming) +{ + CC_UNUSED bool ok = true; + const auto& args = s.args(); + size_t argc = args.size(); + + if(argc == 0) + { + auto *ptr = JSB_MAKE_PRIVATE_OBJECT(cc::MorphTarget); + s.thisObject()->setPrivateObject(ptr); + return true; + } + auto *ptr = JSB_MAKE_PRIVATE_OBJECT(cc::MorphTarget); + auto cobj = ptr->get(); + if (argc > 0 && !args[0].isUndefined()) { + ok &= sevalue_to_native(args[0], &(cobj->displacements), nullptr); + } + + if(!ok) { + delete ptr; + SE_REPORT_ERROR("Argument convertion error"); + return false; + } + s.thisObject()->setPrivateObject(ptr); + return true; +} +SE_BIND_CTOR(js_assets_MorphTarget_constructor, __jsb_cc_MorphTarget_class, js_cc_MorphTarget_finalize) + +static bool js_cc_MorphTarget_finalize(se::State& s) // NOLINT(readability-identifier-naming) +{ + return true; +} +SE_BIND_FINALIZE_FUNC(js_cc_MorphTarget_finalize) + +bool js_register_assets_MorphTarget(se::Object* obj) // NOLINT(readability-identifier-naming) +{ + auto* cls = se::Class::create("MorphTarget", obj, nullptr, _SE(js_assets_MorphTarget_constructor)); + + cls->defineProperty("displacements", _SE(js_assets_MorphTarget_get_displacements), _SE(js_assets_MorphTarget_set_displacements)); + cls->defineFinalizeFunction(_SE(js_cc_MorphTarget_finalize)); + cls->install(); + JSBClassType::registerClass(cls); + + __jsb_cc_MorphTarget_proto = cls->getProto(); + __jsb_cc_MorphTarget_class = cls; + + + se::ScriptEngine::getInstance()->clearException(); + return true; +} +se::Object* __jsb_cc_SubMeshMorph_proto = nullptr; // NOLINT +se::Class* __jsb_cc_SubMeshMorph_class = nullptr; // NOLINT + +static bool js_assets_SubMeshMorph_get_attributes(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_assets_SubMeshMorph_get_attributes : Invalid Native Object"); + + CC_UNUSED bool ok = true; + se::Value jsret; + ok &= nativevalue_to_se(cobj->attributes, jsret, s.thisObject() /*ctx*/); + s.rval() = jsret; + SE_HOLD_RETURN_VALUE(cobj->attributes, s.thisObject(), s.rval()); + return true; +} +SE_BIND_PROP_GET(js_assets_SubMeshMorph_get_attributes) + +static bool js_assets_SubMeshMorph_set_attributes(se::State& s) // NOLINT(readability-identifier-naming) +{ + const auto& args = s.args(); + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_assets_SubMeshMorph_set_attributes : Invalid Native Object"); + + CC_UNUSED bool ok = true; + ok &= sevalue_to_native(args[0], &cobj->attributes, s.thisObject()); + SE_PRECONDITION2(ok, false, "js_assets_SubMeshMorph_set_attributes : Error processing new value"); + return true; +} +SE_BIND_PROP_SET(js_assets_SubMeshMorph_set_attributes) + +static bool js_assets_SubMeshMorph_get_targets(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_assets_SubMeshMorph_get_targets : Invalid Native Object"); + + CC_UNUSED bool ok = true; + se::Value jsret; + ok &= nativevalue_to_se(cobj->targets, jsret, s.thisObject() /*ctx*/); + s.rval() = jsret; + SE_HOLD_RETURN_VALUE(cobj->targets, s.thisObject(), s.rval()); + return true; +} +SE_BIND_PROP_GET(js_assets_SubMeshMorph_get_targets) + +static bool js_assets_SubMeshMorph_set_targets(se::State& s) // NOLINT(readability-identifier-naming) +{ + const auto& args = s.args(); + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_assets_SubMeshMorph_set_targets : Invalid Native Object"); + + CC_UNUSED bool ok = true; + ok &= sevalue_to_native(args[0], &cobj->targets, s.thisObject()); + SE_PRECONDITION2(ok, false, "js_assets_SubMeshMorph_set_targets : Error processing new value"); + return true; +} +SE_BIND_PROP_SET(js_assets_SubMeshMorph_set_targets) + +static bool js_assets_SubMeshMorph_get_weights(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_assets_SubMeshMorph_get_weights : Invalid Native Object"); + + CC_UNUSED bool ok = true; + se::Value jsret; + ok &= nativevalue_to_se(cobj->weights, jsret, s.thisObject() /*ctx*/); + s.rval() = jsret; + SE_HOLD_RETURN_VALUE(cobj->weights, s.thisObject(), s.rval()); + return true; +} +SE_BIND_PROP_GET(js_assets_SubMeshMorph_get_weights) + +static bool js_assets_SubMeshMorph_set_weights(se::State& s) // NOLINT(readability-identifier-naming) +{ + const auto& args = s.args(); + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_assets_SubMeshMorph_set_weights : Invalid Native Object"); + + CC_UNUSED bool ok = true; + ok &= sevalue_to_native(args[0], &cobj->weights, s.thisObject()); + SE_PRECONDITION2(ok, false, "js_assets_SubMeshMorph_set_weights : Error processing new value"); + return true; +} +SE_BIND_PROP_SET(js_assets_SubMeshMorph_set_weights) + + +template<> +bool sevalue_to_native(const se::Value &from, cc::SubMeshMorph * to, se::Object *ctx) +{ + assert(from.isObject()); + se::Object *json = from.toObject(); + auto* data = reinterpret_cast(json->getPrivateData()); + if (data) { + *to = *data; + return true; + } + se::Value field; + bool ok = true; + json->getProperty("attributes", &field, true); + if(!field.isNullOrUndefined()) { + ok &= sevalue_to_native(field, &(to->attributes), ctx); + } + json->getProperty("targets", &field, true); + if(!field.isNullOrUndefined()) { + ok &= sevalue_to_native(field, &(to->targets), ctx); + } + json->getProperty("weights", &field, true); + if(!field.isNullOrUndefined()) { + ok &= sevalue_to_native(field, &(to->weights), ctx); + } + return ok; +} + +SE_DECLARE_FINALIZE_FUNC(js_cc_SubMeshMorph_finalize) + +static bool js_assets_SubMeshMorph_constructor(se::State& s) // NOLINT(readability-identifier-naming) +{ + CC_UNUSED bool ok = true; + const auto& args = s.args(); + size_t argc = args.size(); + + if(argc == 0) + { + auto *ptr = JSB_MAKE_PRIVATE_OBJECT(cc::SubMeshMorph); + s.thisObject()->setPrivateObject(ptr); + return true; + } + + if(argc == 1 && args[0].isObject()) + { + se::Object *json = args[0].toObject(); + se::Value field; + auto *ptr = JSB_MAKE_PRIVATE_OBJECT(cc::SubMeshMorph); + auto cobj = ptr->get(); + ok &= sevalue_to_native(args[0], cobj, s.thisObject()); + if(!ok) { + delete ptr; + SE_REPORT_ERROR("argument convertion error"); + return false; + } + s.thisObject()->setPrivateObject(ptr); + return true; + } + auto *ptr = JSB_MAKE_PRIVATE_OBJECT(cc::SubMeshMorph); + auto cobj = ptr->get(); + if (argc > 0 && !args[0].isUndefined()) { + ok &= sevalue_to_native(args[0], &(cobj->attributes), nullptr); + } + if (argc > 1 && !args[1].isUndefined()) { + ok &= sevalue_to_native(args[1], &(cobj->targets), nullptr); + } + if (argc > 2 && !args[2].isUndefined()) { + ok &= sevalue_to_native(args[2], &(cobj->weights), nullptr); + } + + if(!ok) { + delete ptr; + SE_REPORT_ERROR("Argument convertion error"); + return false; + } + s.thisObject()->setPrivateObject(ptr); + return true; +} +SE_BIND_CTOR(js_assets_SubMeshMorph_constructor, __jsb_cc_SubMeshMorph_class, js_cc_SubMeshMorph_finalize) + +static bool js_cc_SubMeshMorph_finalize(se::State& s) // NOLINT(readability-identifier-naming) +{ + return true; +} +SE_BIND_FINALIZE_FUNC(js_cc_SubMeshMorph_finalize) + +bool js_register_assets_SubMeshMorph(se::Object* obj) // NOLINT(readability-identifier-naming) +{ + auto* cls = se::Class::create("SubMeshMorph", obj, nullptr, _SE(js_assets_SubMeshMorph_constructor)); + + cls->defineProperty("attributes", _SE(js_assets_SubMeshMorph_get_attributes), _SE(js_assets_SubMeshMorph_set_attributes)); + cls->defineProperty("targets", _SE(js_assets_SubMeshMorph_get_targets), _SE(js_assets_SubMeshMorph_set_targets)); + cls->defineProperty("weights", _SE(js_assets_SubMeshMorph_get_weights), _SE(js_assets_SubMeshMorph_set_weights)); + cls->defineFinalizeFunction(_SE(js_cc_SubMeshMorph_finalize)); + cls->install(); + JSBClassType::registerClass(cls); + + __jsb_cc_SubMeshMorph_proto = cls->getProto(); + __jsb_cc_SubMeshMorph_class = cls; + + + se::ScriptEngine::getInstance()->clearException(); + return true; +} +se::Object* __jsb_cc_Morph_proto = nullptr; // NOLINT +se::Class* __jsb_cc_Morph_class = nullptr; // NOLINT + +static bool js_assets_Morph_get_subMeshMorphs(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_assets_Morph_get_subMeshMorphs : Invalid Native Object"); + + CC_UNUSED bool ok = true; + se::Value jsret; + ok &= nativevalue_to_se(cobj->subMeshMorphs, jsret, s.thisObject() /*ctx*/); + s.rval() = jsret; + SE_HOLD_RETURN_VALUE(cobj->subMeshMorphs, s.thisObject(), s.rval()); + return true; +} +SE_BIND_PROP_GET(js_assets_Morph_get_subMeshMorphs) + +static bool js_assets_Morph_set_subMeshMorphs(se::State& s) // NOLINT(readability-identifier-naming) +{ + const auto& args = s.args(); + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_assets_Morph_set_subMeshMorphs : Invalid Native Object"); + + CC_UNUSED bool ok = true; + ok &= sevalue_to_native(args[0], &cobj->subMeshMorphs, s.thisObject()); + SE_PRECONDITION2(ok, false, "js_assets_Morph_set_subMeshMorphs : Error processing new value"); + return true; +} +SE_BIND_PROP_SET(js_assets_Morph_set_subMeshMorphs) + +static bool js_assets_Morph_get_weights(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_assets_Morph_get_weights : Invalid Native Object"); + + CC_UNUSED bool ok = true; + se::Value jsret; + ok &= nativevalue_to_se(cobj->weights, jsret, s.thisObject() /*ctx*/); + s.rval() = jsret; + SE_HOLD_RETURN_VALUE(cobj->weights, s.thisObject(), s.rval()); + return true; +} +SE_BIND_PROP_GET(js_assets_Morph_get_weights) + +static bool js_assets_Morph_set_weights(se::State& s) // NOLINT(readability-identifier-naming) +{ + const auto& args = s.args(); + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_assets_Morph_set_weights : Invalid Native Object"); + + CC_UNUSED bool ok = true; + ok &= sevalue_to_native(args[0], &cobj->weights, s.thisObject()); + SE_PRECONDITION2(ok, false, "js_assets_Morph_set_weights : Error processing new value"); + return true; +} +SE_BIND_PROP_SET(js_assets_Morph_set_weights) + +static bool js_assets_Morph_get_targetNames(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_assets_Morph_get_targetNames : Invalid Native Object"); + + CC_UNUSED bool ok = true; + se::Value jsret; + ok &= nativevalue_to_se(cobj->targetNames, jsret, s.thisObject() /*ctx*/); + s.rval() = jsret; + SE_HOLD_RETURN_VALUE(cobj->targetNames, s.thisObject(), s.rval()); + return true; +} +SE_BIND_PROP_GET(js_assets_Morph_get_targetNames) + +static bool js_assets_Morph_set_targetNames(se::State& s) // NOLINT(readability-identifier-naming) +{ + const auto& args = s.args(); + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_assets_Morph_set_targetNames : Invalid Native Object"); + + CC_UNUSED bool ok = true; + ok &= sevalue_to_native(args[0], &cobj->targetNames, s.thisObject()); + SE_PRECONDITION2(ok, false, "js_assets_Morph_set_targetNames : Error processing new value"); + return true; +} +SE_BIND_PROP_SET(js_assets_Morph_set_targetNames) + + +template<> +bool sevalue_to_native(const se::Value &from, cc::Morph * to, se::Object *ctx) +{ + assert(from.isObject()); + se::Object *json = from.toObject(); + auto* data = reinterpret_cast(json->getPrivateData()); + if (data) { + *to = *data; + return true; + } + se::Value field; + bool ok = true; + json->getProperty("subMeshMorphs", &field, true); + if(!field.isNullOrUndefined()) { + ok &= sevalue_to_native(field, &(to->subMeshMorphs), ctx); + } + json->getProperty("weights", &field, true); + if(!field.isNullOrUndefined()) { + ok &= sevalue_to_native(field, &(to->weights), ctx); + } + json->getProperty("targetNames", &field, true); + if(!field.isNullOrUndefined()) { + ok &= sevalue_to_native(field, &(to->targetNames), ctx); + } + return ok; +} + +SE_DECLARE_FINALIZE_FUNC(js_cc_Morph_finalize) + +static bool js_assets_Morph_constructor(se::State& s) // NOLINT(readability-identifier-naming) +{ + CC_UNUSED bool ok = true; + const auto& args = s.args(); + size_t argc = args.size(); + + if(argc == 0) + { + auto *ptr = JSB_MAKE_PRIVATE_OBJECT(cc::Morph); + s.thisObject()->setPrivateObject(ptr); + return true; + } + + if(argc == 1 && args[0].isObject()) + { + se::Object *json = args[0].toObject(); + se::Value field; + auto *ptr = JSB_MAKE_PRIVATE_OBJECT(cc::Morph); + auto cobj = ptr->get(); + ok &= sevalue_to_native(args[0], cobj, s.thisObject()); + if(!ok) { + delete ptr; + SE_REPORT_ERROR("argument convertion error"); + return false; + } + s.thisObject()->setPrivateObject(ptr); + return true; + } + auto *ptr = JSB_MAKE_PRIVATE_OBJECT(cc::Morph); + auto cobj = ptr->get(); + if (argc > 0 && !args[0].isUndefined()) { + ok &= sevalue_to_native(args[0], &(cobj->subMeshMorphs), nullptr); + } + if (argc > 1 && !args[1].isUndefined()) { + ok &= sevalue_to_native(args[1], &(cobj->weights), nullptr); + } + if (argc > 2 && !args[2].isUndefined()) { + ok &= sevalue_to_native(args[2], &(cobj->targetNames), nullptr); + } + + if(!ok) { + delete ptr; + SE_REPORT_ERROR("Argument convertion error"); + return false; + } + s.thisObject()->setPrivateObject(ptr); + return true; +} +SE_BIND_CTOR(js_assets_Morph_constructor, __jsb_cc_Morph_class, js_cc_Morph_finalize) + +static bool js_cc_Morph_finalize(se::State& s) // NOLINT(readability-identifier-naming) +{ + return true; +} +SE_BIND_FINALIZE_FUNC(js_cc_Morph_finalize) + +bool js_register_assets_Morph(se::Object* obj) // NOLINT(readability-identifier-naming) +{ + auto* cls = se::Class::create("Morph", obj, nullptr, _SE(js_assets_Morph_constructor)); + + cls->defineProperty("subMeshMorphs", _SE(js_assets_Morph_get_subMeshMorphs), _SE(js_assets_Morph_set_subMeshMorphs)); + cls->defineProperty("weights", _SE(js_assets_Morph_get_weights), _SE(js_assets_Morph_set_weights)); + cls->defineProperty("targetNames", _SE(js_assets_Morph_get_targetNames), _SE(js_assets_Morph_set_targetNames)); + cls->defineFinalizeFunction(_SE(js_cc_Morph_finalize)); + cls->install(); + JSBClassType::registerClass(cls); + + __jsb_cc_Morph_proto = cls->getProto(); + __jsb_cc_Morph_class = cls; + + + se::ScriptEngine::getInstance()->clearException(); + return true; +} +se::Object* __jsb_cc_IGeometricInfo_proto = nullptr; // NOLINT +se::Class* __jsb_cc_IGeometricInfo_class = nullptr; // NOLINT + +static bool js_assets_IGeometricInfo_get_positions(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_assets_IGeometricInfo_get_positions : Invalid Native Object"); + + CC_UNUSED bool ok = true; + se::Value jsret; + ok &= nativevalue_to_se(cobj->positions, jsret, s.thisObject() /*ctx*/); + s.rval() = jsret; + SE_HOLD_RETURN_VALUE(cobj->positions, s.thisObject(), s.rval()); + return true; +} +SE_BIND_PROP_GET(js_assets_IGeometricInfo_get_positions) + +static bool js_assets_IGeometricInfo_set_positions(se::State& s) // NOLINT(readability-identifier-naming) +{ + const auto& args = s.args(); + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_assets_IGeometricInfo_set_positions : Invalid Native Object"); + + CC_UNUSED bool ok = true; + ok &= sevalue_to_native(args[0], &cobj->positions, s.thisObject()); + SE_PRECONDITION2(ok, false, "js_assets_IGeometricInfo_set_positions : Error processing new value"); + return true; +} +SE_BIND_PROP_SET(js_assets_IGeometricInfo_set_positions) + +static bool js_assets_IGeometricInfo_get_indices(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_assets_IGeometricInfo_get_indices : Invalid Native Object"); + + CC_UNUSED bool ok = true; + se::Value jsret; + ok &= nativevalue_to_se(cobj->indices, jsret, s.thisObject() /*ctx*/); + s.rval() = jsret; + SE_HOLD_RETURN_VALUE(cobj->indices, s.thisObject(), s.rval()); + return true; +} +SE_BIND_PROP_GET(js_assets_IGeometricInfo_get_indices) + +static bool js_assets_IGeometricInfo_set_indices(se::State& s) // NOLINT(readability-identifier-naming) +{ + const auto& args = s.args(); + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_assets_IGeometricInfo_set_indices : Invalid Native Object"); + + CC_UNUSED bool ok = true; + ok &= sevalue_to_native(args[0], &cobj->indices, s.thisObject()); + SE_PRECONDITION2(ok, false, "js_assets_IGeometricInfo_set_indices : Error processing new value"); + return true; +} +SE_BIND_PROP_SET(js_assets_IGeometricInfo_set_indices) + +static bool js_assets_IGeometricInfo_get_doubleSided(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_assets_IGeometricInfo_get_doubleSided : Invalid Native Object"); + + CC_UNUSED bool ok = true; + se::Value jsret; + ok &= nativevalue_to_se(cobj->doubleSided, jsret, s.thisObject() /*ctx*/); + s.rval() = jsret; + SE_HOLD_RETURN_VALUE(cobj->doubleSided, s.thisObject(), s.rval()); + return true; +} +SE_BIND_PROP_GET(js_assets_IGeometricInfo_get_doubleSided) + +static bool js_assets_IGeometricInfo_set_doubleSided(se::State& s) // NOLINT(readability-identifier-naming) +{ + const auto& args = s.args(); + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_assets_IGeometricInfo_set_doubleSided : Invalid Native Object"); + + CC_UNUSED bool ok = true; + ok &= sevalue_to_native(args[0], &cobj->doubleSided, s.thisObject()); + SE_PRECONDITION2(ok, false, "js_assets_IGeometricInfo_set_doubleSided : Error processing new value"); + return true; +} +SE_BIND_PROP_SET(js_assets_IGeometricInfo_set_doubleSided) + +static bool js_assets_IGeometricInfo_get_boundingBox(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_assets_IGeometricInfo_get_boundingBox : Invalid Native Object"); + + CC_UNUSED bool ok = true; + se::Value jsret; + ok &= nativevalue_to_se(cobj->boundingBox, jsret, s.thisObject() /*ctx*/); + s.rval() = jsret; + SE_HOLD_RETURN_VALUE(cobj->boundingBox, s.thisObject(), s.rval()); + return true; +} +SE_BIND_PROP_GET(js_assets_IGeometricInfo_get_boundingBox) + +static bool js_assets_IGeometricInfo_set_boundingBox(se::State& s) // NOLINT(readability-identifier-naming) +{ + const auto& args = s.args(); + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_assets_IGeometricInfo_set_boundingBox : Invalid Native Object"); + + CC_UNUSED bool ok = true; + ok &= sevalue_to_native(args[0], &cobj->boundingBox, s.thisObject()); + SE_PRECONDITION2(ok, false, "js_assets_IGeometricInfo_set_boundingBox : Error processing new value"); + return true; +} +SE_BIND_PROP_SET(js_assets_IGeometricInfo_set_boundingBox) + + +template<> +bool sevalue_to_native(const se::Value &from, cc::IGeometricInfo * to, se::Object *ctx) +{ + assert(from.isObject()); + se::Object *json = from.toObject(); + auto* data = reinterpret_cast(json->getPrivateData()); + if (data) { + *to = *data; + return true; + } + se::Value field; + bool ok = true; + json->getProperty("positions", &field, true); + if(!field.isNullOrUndefined()) { + ok &= sevalue_to_native(field, &(to->positions), ctx); + } + json->getProperty("indices", &field, true); + if(!field.isNullOrUndefined()) { + ok &= sevalue_to_native(field, &(to->indices), ctx); + } + json->getProperty("doubleSided", &field, true); + if(!field.isNullOrUndefined()) { + ok &= sevalue_to_native(field, &(to->doubleSided), ctx); + } + json->getProperty("boundingBox", &field, true); + if(!field.isNullOrUndefined()) { + ok &= sevalue_to_native(field, &(to->boundingBox), ctx); + } + return ok; +} + +SE_DECLARE_FINALIZE_FUNC(js_cc_IGeometricInfo_finalize) + +static bool js_assets_IGeometricInfo_constructor(se::State& s) // NOLINT(readability-identifier-naming) +{ + CC_UNUSED bool ok = true; + const auto& args = s.args(); + size_t argc = args.size(); + + if(argc == 0) + { + auto *ptr = JSB_MAKE_PRIVATE_OBJECT(cc::IGeometricInfo); + s.thisObject()->setPrivateObject(ptr); + return true; + } + + if(argc == 1 && args[0].isObject()) + { + se::Object *json = args[0].toObject(); + se::Value field; + auto *ptr = JSB_MAKE_PRIVATE_OBJECT(cc::IGeometricInfo); + auto cobj = ptr->get(); + ok &= sevalue_to_native(args[0], cobj, s.thisObject()); + if(!ok) { + delete ptr; + SE_REPORT_ERROR("argument convertion error"); + return false; + } + s.thisObject()->setPrivateObject(ptr); + return true; + } + auto *ptr = JSB_MAKE_PRIVATE_OBJECT(cc::IGeometricInfo); + auto cobj = ptr->get(); + if (argc > 0 && !args[0].isUndefined()) { + ok &= sevalue_to_native(args[0], &(cobj->positions), nullptr); + } + if (argc > 1 && !args[1].isUndefined()) { + ok &= sevalue_to_native(args[1], &(cobj->indices), nullptr); + } + if (argc > 2 && !args[2].isUndefined()) { + ok &= sevalue_to_native(args[2], &(cobj->doubleSided), nullptr); + } + if (argc > 3 && !args[3].isUndefined()) { + ok &= sevalue_to_native(args[3], &(cobj->boundingBox), nullptr); + } + + if(!ok) { + delete ptr; + SE_REPORT_ERROR("Argument convertion error"); + return false; + } + s.thisObject()->setPrivateObject(ptr); + return true; +} +SE_BIND_CTOR(js_assets_IGeometricInfo_constructor, __jsb_cc_IGeometricInfo_class, js_cc_IGeometricInfo_finalize) + +static bool js_cc_IGeometricInfo_finalize(se::State& s) // NOLINT(readability-identifier-naming) +{ + return true; +} +SE_BIND_FINALIZE_FUNC(js_cc_IGeometricInfo_finalize) + +bool js_register_assets_IGeometricInfo(se::Object* obj) // NOLINT(readability-identifier-naming) +{ + auto* cls = se::Class::create("IGeometricInfo", obj, nullptr, _SE(js_assets_IGeometricInfo_constructor)); + + cls->defineProperty("positions", _SE(js_assets_IGeometricInfo_get_positions), _SE(js_assets_IGeometricInfo_set_positions)); + cls->defineProperty("indices", _SE(js_assets_IGeometricInfo_get_indices), _SE(js_assets_IGeometricInfo_set_indices)); + cls->defineProperty("doubleSided", _SE(js_assets_IGeometricInfo_get_doubleSided), _SE(js_assets_IGeometricInfo_set_doubleSided)); + cls->defineProperty("boundingBox", _SE(js_assets_IGeometricInfo_get_boundingBox), _SE(js_assets_IGeometricInfo_set_boundingBox)); + cls->defineFinalizeFunction(_SE(js_cc_IGeometricInfo_finalize)); + cls->install(); + JSBClassType::registerClass(cls); + + __jsb_cc_IGeometricInfo_proto = cls->getProto(); + __jsb_cc_IGeometricInfo_class = cls; + + + se::ScriptEngine::getInstance()->clearException(); + return true; +} +se::Object* __jsb_cc_IFlatBuffer_proto = nullptr; // NOLINT +se::Class* __jsb_cc_IFlatBuffer_class = nullptr; // NOLINT + +static bool js_assets_IFlatBuffer_get_stride(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_assets_IFlatBuffer_get_stride : Invalid Native Object"); + + CC_UNUSED bool ok = true; + se::Value jsret; + ok &= nativevalue_to_se(cobj->stride, jsret, s.thisObject() /*ctx*/); + s.rval() = jsret; + SE_HOLD_RETURN_VALUE(cobj->stride, s.thisObject(), s.rval()); + return true; +} +SE_BIND_PROP_GET(js_assets_IFlatBuffer_get_stride) + +static bool js_assets_IFlatBuffer_set_stride(se::State& s) // NOLINT(readability-identifier-naming) +{ + const auto& args = s.args(); + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_assets_IFlatBuffer_set_stride : Invalid Native Object"); + + CC_UNUSED bool ok = true; + ok &= sevalue_to_native(args[0], &cobj->stride, s.thisObject()); + SE_PRECONDITION2(ok, false, "js_assets_IFlatBuffer_set_stride : Error processing new value"); + return true; +} +SE_BIND_PROP_SET(js_assets_IFlatBuffer_set_stride) + +static bool js_assets_IFlatBuffer_get_count(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_assets_IFlatBuffer_get_count : Invalid Native Object"); + + CC_UNUSED bool ok = true; + se::Value jsret; + ok &= nativevalue_to_se(cobj->count, jsret, s.thisObject() /*ctx*/); + s.rval() = jsret; + SE_HOLD_RETURN_VALUE(cobj->count, s.thisObject(), s.rval()); + return true; +} +SE_BIND_PROP_GET(js_assets_IFlatBuffer_get_count) + +static bool js_assets_IFlatBuffer_set_count(se::State& s) // NOLINT(readability-identifier-naming) +{ + const auto& args = s.args(); + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_assets_IFlatBuffer_set_count : Invalid Native Object"); + + CC_UNUSED bool ok = true; + ok &= sevalue_to_native(args[0], &cobj->count, s.thisObject()); + SE_PRECONDITION2(ok, false, "js_assets_IFlatBuffer_set_count : Error processing new value"); + return true; +} +SE_BIND_PROP_SET(js_assets_IFlatBuffer_set_count) + +static bool js_assets_IFlatBuffer_get_buffer(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_assets_IFlatBuffer_get_buffer : Invalid Native Object"); + + CC_UNUSED bool ok = true; + se::Value jsret; + ok &= nativevalue_to_se(cobj->buffer, jsret, s.thisObject() /*ctx*/); + s.rval() = jsret; + SE_HOLD_RETURN_VALUE(cobj->buffer, s.thisObject(), s.rval()); + return true; +} +SE_BIND_PROP_GET(js_assets_IFlatBuffer_get_buffer) + +static bool js_assets_IFlatBuffer_set_buffer(se::State& s) // NOLINT(readability-identifier-naming) +{ + const auto& args = s.args(); + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_assets_IFlatBuffer_set_buffer : Invalid Native Object"); + + CC_UNUSED bool ok = true; + ok &= sevalue_to_native(args[0], &cobj->buffer, s.thisObject()); + SE_PRECONDITION2(ok, false, "js_assets_IFlatBuffer_set_buffer : Error processing new value"); + return true; +} +SE_BIND_PROP_SET(js_assets_IFlatBuffer_set_buffer) + + +template<> +bool sevalue_to_native(const se::Value &from, cc::IFlatBuffer * to, se::Object *ctx) +{ + assert(from.isObject()); + se::Object *json = from.toObject(); + auto* data = reinterpret_cast(json->getPrivateData()); + if (data) { + *to = *data; + return true; + } + se::Value field; + bool ok = true; + json->getProperty("stride", &field, true); + if(!field.isNullOrUndefined()) { + ok &= sevalue_to_native(field, &(to->stride), ctx); + } + json->getProperty("count", &field, true); + if(!field.isNullOrUndefined()) { + ok &= sevalue_to_native(field, &(to->count), ctx); + } + json->getProperty("buffer", &field, true); + if(!field.isNullOrUndefined()) { + ok &= sevalue_to_native(field, &(to->buffer), ctx); + } + return ok; +} + +SE_DECLARE_FINALIZE_FUNC(js_cc_IFlatBuffer_finalize) + +static bool js_assets_IFlatBuffer_constructor(se::State& s) // NOLINT(readability-identifier-naming) +{ + CC_UNUSED bool ok = true; + const auto& args = s.args(); + size_t argc = args.size(); + + if(argc == 0) + { + auto *ptr = JSB_MAKE_PRIVATE_OBJECT(cc::IFlatBuffer); + s.thisObject()->setPrivateObject(ptr); + return true; + } + + if(argc == 1 && args[0].isObject()) + { + se::Object *json = args[0].toObject(); + se::Value field; + auto *ptr = JSB_MAKE_PRIVATE_OBJECT(cc::IFlatBuffer); + auto cobj = ptr->get(); + ok &= sevalue_to_native(args[0], cobj, s.thisObject()); + if(!ok) { + delete ptr; + SE_REPORT_ERROR("argument convertion error"); + return false; + } + s.thisObject()->setPrivateObject(ptr); + return true; + } + auto *ptr = JSB_MAKE_PRIVATE_OBJECT(cc::IFlatBuffer); + auto cobj = ptr->get(); + if (argc > 0 && !args[0].isUndefined()) { + ok &= sevalue_to_native(args[0], &(cobj->stride), nullptr); + } + if (argc > 1 && !args[1].isUndefined()) { + ok &= sevalue_to_native(args[1], &(cobj->count), nullptr); + } + if (argc > 2 && !args[2].isUndefined()) { + ok &= sevalue_to_native(args[2], &(cobj->buffer), nullptr); + } + + if(!ok) { + delete ptr; + SE_REPORT_ERROR("Argument convertion error"); + return false; + } + s.thisObject()->setPrivateObject(ptr); + return true; +} +SE_BIND_CTOR(js_assets_IFlatBuffer_constructor, __jsb_cc_IFlatBuffer_class, js_cc_IFlatBuffer_finalize) + +static bool js_cc_IFlatBuffer_finalize(se::State& s) // NOLINT(readability-identifier-naming) +{ + return true; +} +SE_BIND_FINALIZE_FUNC(js_cc_IFlatBuffer_finalize) + +bool js_register_assets_IFlatBuffer(se::Object* obj) // NOLINT(readability-identifier-naming) +{ + auto* cls = se::Class::create("IFlatBuffer", obj, nullptr, _SE(js_assets_IFlatBuffer_constructor)); + + cls->defineProperty("stride", _SE(js_assets_IFlatBuffer_get_stride), _SE(js_assets_IFlatBuffer_set_stride)); + cls->defineProperty("count", _SE(js_assets_IFlatBuffer_get_count), _SE(js_assets_IFlatBuffer_set_count)); + cls->defineProperty("buffer", _SE(js_assets_IFlatBuffer_get_buffer), _SE(js_assets_IFlatBuffer_set_buffer)); + cls->defineFinalizeFunction(_SE(js_cc_IFlatBuffer_finalize)); + cls->install(); + JSBClassType::registerClass(cls); + + __jsb_cc_IFlatBuffer_proto = cls->getProto(); + __jsb_cc_IFlatBuffer_class = cls; + + + se::ScriptEngine::getInstance()->clearException(); + return true; +} +se::Object* __jsb_cc_RenderingSubMesh_proto = nullptr; // NOLINT +se::Class* __jsb_cc_RenderingSubMesh_class = nullptr; // NOLINT + +static bool js_assets_RenderingSubMesh_enableVertexIdChannel(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_assets_RenderingSubMesh_enableVertexIdChannel : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 1) { + HolderType arg0 = {}; + ok &= sevalue_to_native(args[0], &arg0, s.thisObject()); + SE_PRECONDITION2(ok, false, "js_assets_RenderingSubMesh_enableVertexIdChannel : Error processing arguments"); + cobj->enableVertexIdChannel(arg0.value()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 1); + return false; +} +SE_BIND_FUNC(js_assets_RenderingSubMesh_enableVertexIdChannel) + +static bool js_assets_RenderingSubMesh_genFlatBuffers(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_assets_RenderingSubMesh_genFlatBuffers : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + if (argc == 0) { + cobj->genFlatBuffers(); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 0); + return false; +} +SE_BIND_FUNC(js_assets_RenderingSubMesh_genFlatBuffers) + +static bool js_assets_RenderingSubMesh_getAttributes(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_assets_RenderingSubMesh_getAttributes : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 0) { + const std::vector& result = cobj->getAttributes(); + ok &= nativevalue_to_se(result, s.rval(), nullptr /*ctx*/); + SE_PRECONDITION2(ok, false, "js_assets_RenderingSubMesh_getAttributes : Error processing arguments"); + SE_HOLD_RETURN_VALUE(result, s.thisObject(), s.rval()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 0); + return false; +} +SE_BIND_FUNC(js_assets_RenderingSubMesh_getAttributes) + +static bool js_assets_RenderingSubMesh_getFlatBuffers(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_assets_RenderingSubMesh_getFlatBuffers : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 0) { + const std::vector& result = cobj->getFlatBuffers(); + ok &= nativevalue_to_se(result, s.rval(), nullptr /*ctx*/); + SE_PRECONDITION2(ok, false, "js_assets_RenderingSubMesh_getFlatBuffers : Error processing arguments"); + SE_HOLD_RETURN_VALUE(result, s.thisObject(), s.rval()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 0); + return false; +} +SE_BIND_FUNC_AS_PROP_GET(js_assets_RenderingSubMesh_getFlatBuffers) + +static bool js_assets_RenderingSubMesh_getGeometricInfo(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_assets_RenderingSubMesh_getGeometricInfo : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 0) { + const cc::IGeometricInfo& result = cobj->getGeometricInfo(); + ok &= nativevalue_to_se(result, s.rval(), nullptr /*ctx*/); + SE_PRECONDITION2(ok, false, "js_assets_RenderingSubMesh_getGeometricInfo : Error processing arguments"); + SE_HOLD_RETURN_VALUE(result, s.thisObject(), s.rval()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 0); + return false; +} +SE_BIND_FUNC(js_assets_RenderingSubMesh_getGeometricInfo) + +static bool js_assets_RenderingSubMesh_getIaInfo(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_assets_RenderingSubMesh_getIaInfo : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 0) { + const cc::gfx::InputAssemblerInfo& result = cobj->getIaInfo(); + ok &= nativevalue_to_se(result, s.rval(), nullptr /*ctx*/); + SE_PRECONDITION2(ok, false, "js_assets_RenderingSubMesh_getIaInfo : Error processing arguments"); + SE_HOLD_RETURN_VALUE(result, s.thisObject(), s.rval()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 0); + return false; +} +SE_BIND_FUNC_AS_PROP_GET(js_assets_RenderingSubMesh_getIaInfo) + +static bool js_assets_RenderingSubMesh_getIndexBuffer(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_assets_RenderingSubMesh_getIndexBuffer : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 0) { + cc::gfx::Buffer* result = cobj->getIndexBuffer(); + ok &= nativevalue_to_se(result, s.rval(), nullptr /*ctx*/); + SE_PRECONDITION2(ok, false, "js_assets_RenderingSubMesh_getIndexBuffer : Error processing arguments"); + SE_HOLD_RETURN_VALUE(result, s.thisObject(), s.rval()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 0); + return false; +} +SE_BIND_FUNC(js_assets_RenderingSubMesh_getIndexBuffer) + +static bool js_assets_RenderingSubMesh_getJointMappedBuffers(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_assets_RenderingSubMesh_getJointMappedBuffers : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 0) { + const std::vector& result = cobj->getJointMappedBuffers(); + ok &= nativevalue_to_se(result, s.rval(), nullptr /*ctx*/); + SE_PRECONDITION2(ok, false, "js_assets_RenderingSubMesh_getJointMappedBuffers : Error processing arguments"); + SE_HOLD_RETURN_VALUE(result, s.thisObject(), s.rval()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 0); + return false; +} +SE_BIND_FUNC_AS_PROP_GET(js_assets_RenderingSubMesh_getJointMappedBuffers) + +static bool js_assets_RenderingSubMesh_getMesh(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_assets_RenderingSubMesh_getMesh : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 0) { + cc::Mesh* result = cobj->getMesh(); + ok &= nativevalue_to_se(result, s.rval(), nullptr /*ctx*/); + SE_PRECONDITION2(ok, false, "js_assets_RenderingSubMesh_getMesh : Error processing arguments"); + SE_HOLD_RETURN_VALUE(result, s.thisObject(), s.rval()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 0); + return false; +} +SE_BIND_FUNC_AS_PROP_GET(js_assets_RenderingSubMesh_getMesh) + +static bool js_assets_RenderingSubMesh_getPrimitiveMode(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_assets_RenderingSubMesh_getPrimitiveMode : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 0) { + auto result = static_cast(cobj->getPrimitiveMode()); + ok &= nativevalue_to_se(result, s.rval(), nullptr /*ctx*/); + SE_PRECONDITION2(ok, false, "js_assets_RenderingSubMesh_getPrimitiveMode : Error processing arguments"); + SE_HOLD_RETURN_VALUE(result, s.thisObject(), s.rval()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 0); + return false; +} +SE_BIND_FUNC_AS_PROP_GET(js_assets_RenderingSubMesh_getPrimitiveMode) + +static bool js_assets_RenderingSubMesh_getSubMeshIdx(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_assets_RenderingSubMesh_getSubMeshIdx : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 0) { + const boost::optional& result = cobj->getSubMeshIdx(); + ok &= nativevalue_to_se(result, s.rval(), nullptr /*ctx*/); + SE_PRECONDITION2(ok, false, "js_assets_RenderingSubMesh_getSubMeshIdx : Error processing arguments"); + SE_HOLD_RETURN_VALUE(result, s.thisObject(), s.rval()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 0); + return false; +} +SE_BIND_FUNC_AS_PROP_GET(js_assets_RenderingSubMesh_getSubMeshIdx) + +static bool js_assets_RenderingSubMesh_getVertexBuffers(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_assets_RenderingSubMesh_getVertexBuffers : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 0) { + const std::vector& result = cobj->getVertexBuffers(); + ok &= nativevalue_to_se(result, s.rval(), nullptr /*ctx*/); + SE_PRECONDITION2(ok, false, "js_assets_RenderingSubMesh_getVertexBuffers : Error processing arguments"); + SE_HOLD_RETURN_VALUE(result, s.thisObject(), s.rval()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 0); + return false; +} +SE_BIND_FUNC(js_assets_RenderingSubMesh_getVertexBuffers) + +static bool js_assets_RenderingSubMesh_indirectBuffer(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_assets_RenderingSubMesh_indirectBuffer : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 0) { + cc::gfx::Buffer* result = cobj->indirectBuffer(); + ok &= nativevalue_to_se(result, s.rval(), nullptr /*ctx*/); + SE_PRECONDITION2(ok, false, "js_assets_RenderingSubMesh_indirectBuffer : Error processing arguments"); + SE_HOLD_RETURN_VALUE(result, s.thisObject(), s.rval()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 0); + return false; +} +SE_BIND_FUNC(js_assets_RenderingSubMesh_indirectBuffer) + +static bool js_assets_RenderingSubMesh_setFlatBuffers(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_assets_RenderingSubMesh_setFlatBuffers : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 1) { + HolderType, true> arg0 = {}; + ok &= sevalue_to_native(args[0], &arg0, s.thisObject()); + SE_PRECONDITION2(ok, false, "js_assets_RenderingSubMesh_setFlatBuffers : Error processing arguments"); + cobj->setFlatBuffers(arg0.value()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 1); + return false; +} +SE_BIND_FUNC_AS_PROP_SET(js_assets_RenderingSubMesh_setFlatBuffers) + +static bool js_assets_RenderingSubMesh_setMesh(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_assets_RenderingSubMesh_setMesh : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 1) { + HolderType arg0 = {}; + ok &= sevalue_to_native(args[0], &arg0, s.thisObject()); + SE_PRECONDITION2(ok, false, "js_assets_RenderingSubMesh_setMesh : Error processing arguments"); + cobj->setMesh(arg0.value()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 1); + return false; +} +SE_BIND_FUNC_AS_PROP_SET(js_assets_RenderingSubMesh_setMesh) + +static bool js_assets_RenderingSubMesh_setSubMeshIdx(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_assets_RenderingSubMesh_setSubMeshIdx : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 1) { + HolderType arg0 = {}; + ok &= sevalue_to_native(args[0], &arg0, s.thisObject()); + SE_PRECONDITION2(ok, false, "js_assets_RenderingSubMesh_setSubMeshIdx : Error processing arguments"); + cobj->setSubMeshIdx(arg0.value()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 1); + return false; +} +SE_BIND_FUNC_AS_PROP_SET(js_assets_RenderingSubMesh_setSubMeshIdx) + +SE_DECLARE_FINALIZE_FUNC(js_cc_RenderingSubMesh_finalize) + +static bool js_assets_RenderingSubMesh_constructor(se::State& s) // NOLINT(readability-identifier-naming) constructor_overloaded.c +{ + CC_UNUSED bool ok = true; + const auto& args = s.args(); + size_t argc = args.size(); + do { + if (argc == 4) { + HolderType, true> arg0 = {}; + ok &= sevalue_to_native(args[0], &arg0, s.thisObject()); + if (!ok) { ok = true; break; } + HolderType, true> arg1 = {}; + ok &= sevalue_to_native(args[1], &arg1, s.thisObject()); + if (!ok) { ok = true; break; } + HolderType arg2 = {}; + ok &= sevalue_to_native(args[2], &arg2, s.thisObject()); + if (!ok) { ok = true; break; } + HolderType arg3 = {}; + ok &= sevalue_to_native(args[3], &arg3, s.thisObject()); + if (!ok) { ok = true; break; } + auto *ptr = JSB_MAKE_PRIVATE_OBJECT(cc::RenderingSubMesh, arg0.value(), arg1.value(), arg2.value(), arg3.value()); + s.thisObject()->setPrivateObject(ptr); + return true; + } + } while(false); + do { + if (argc == 3) { + HolderType, true> arg0 = {}; + ok &= sevalue_to_native(args[0], &arg0, s.thisObject()); + if (!ok) { ok = true; break; } + HolderType, true> arg1 = {}; + ok &= sevalue_to_native(args[1], &arg1, s.thisObject()); + if (!ok) { ok = true; break; } + HolderType arg2 = {}; + ok &= sevalue_to_native(args[2], &arg2, s.thisObject()); + if (!ok) { ok = true; break; } + auto *ptr = JSB_MAKE_PRIVATE_OBJECT(cc::RenderingSubMesh, arg0.value(), arg1.value(), arg2.value()); + s.thisObject()->setPrivateObject(ptr); + return true; + } + } while(false); + do { + if (argc == 5) { + HolderType, true> arg0 = {}; + ok &= sevalue_to_native(args[0], &arg0, s.thisObject()); + if (!ok) { ok = true; break; } + HolderType, true> arg1 = {}; + ok &= sevalue_to_native(args[1], &arg1, s.thisObject()); + if (!ok) { ok = true; break; } + HolderType arg2 = {}; + ok &= sevalue_to_native(args[2], &arg2, s.thisObject()); + if (!ok) { ok = true; break; } + HolderType arg3 = {}; + ok &= sevalue_to_native(args[3], &arg3, s.thisObject()); + if (!ok) { ok = true; break; } + HolderType arg4 = {}; + ok &= sevalue_to_native(args[4], &arg4, s.thisObject()); + if (!ok) { ok = true; break; } + auto *ptr = JSB_MAKE_PRIVATE_OBJECT(cc::RenderingSubMesh, arg0.value(), arg1.value(), arg2.value(), arg3.value(), arg4.value()); + s.thisObject()->setPrivateObject(ptr); + return true; + } + } while(false); + SE_REPORT_ERROR("wrong number of arguments: %d", (int)argc); + return false; +} +SE_BIND_CTOR(js_assets_RenderingSubMesh_constructor, __jsb_cc_RenderingSubMesh_class, js_cc_RenderingSubMesh_finalize) + +static bool js_cc_RenderingSubMesh_finalize(se::State& s) // NOLINT(readability-identifier-naming) +{ + return true; +} +SE_BIND_FINALIZE_FUNC(js_cc_RenderingSubMesh_finalize) + +bool js_register_assets_RenderingSubMesh(se::Object* obj) // NOLINT(readability-identifier-naming) +{ + auto* cls = se::Class::create("RenderingSubMesh", obj, __jsb_cc_Asset_proto, _SE(js_assets_RenderingSubMesh_constructor)); + + cls->defineProperty("primitiveMode", _SE(js_assets_RenderingSubMesh_getPrimitiveMode_asGetter), nullptr); + cls->defineProperty({"iaInfo", "_iaInfo"}, _SE(js_assets_RenderingSubMesh_getIaInfo_asGetter), nullptr); + cls->defineProperty("jointMappedBuffers", _SE(js_assets_RenderingSubMesh_getJointMappedBuffers_asGetter), nullptr); + cls->defineProperty({"flatBuffers", "_flatBuffers"}, _SE(js_assets_RenderingSubMesh_getFlatBuffers_asGetter), _SE(js_assets_RenderingSubMesh_setFlatBuffers_asSetter)); + cls->defineProperty("mesh", _SE(js_assets_RenderingSubMesh_getMesh_asGetter), _SE(js_assets_RenderingSubMesh_setMesh_asSetter)); + cls->defineProperty("subMeshIdx", _SE(js_assets_RenderingSubMesh_getSubMeshIdx_asGetter), _SE(js_assets_RenderingSubMesh_setSubMeshIdx_asSetter)); + cls->defineFunction("enableVertexIdChannel", _SE(js_assets_RenderingSubMesh_enableVertexIdChannel)); + cls->defineFunction("genFlatBuffers", _SE(js_assets_RenderingSubMesh_genFlatBuffers)); + cls->defineFunction("getAttributes", _SE(js_assets_RenderingSubMesh_getAttributes)); + cls->defineFunction("getGeometricInfo", _SE(js_assets_RenderingSubMesh_getGeometricInfo)); + cls->defineFunction("getIndexBuffer", _SE(js_assets_RenderingSubMesh_getIndexBuffer)); + cls->defineFunction("getVertexBuffers", _SE(js_assets_RenderingSubMesh_getVertexBuffers)); + cls->defineFunction("indirectBuffer", _SE(js_assets_RenderingSubMesh_indirectBuffer)); + cls->defineFinalizeFunction(_SE(js_cc_RenderingSubMesh_finalize)); + cls->install(); + JSBClassType::registerClass(cls); + + __jsb_cc_RenderingSubMesh_proto = cls->getProto(); + __jsb_cc_RenderingSubMesh_class = cls; + + + se::ScriptEngine::getInstance()->clearException(); + return true; +} +se::Object* __jsb_cc_SceneAsset_proto = nullptr; // NOLINT +se::Class* __jsb_cc_SceneAsset_class = nullptr; // NOLINT + +static bool js_assets_SceneAsset_getScene(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_assets_SceneAsset_getScene : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 0) { + cc::Scene* result = cobj->getScene(); + ok &= nativevalue_to_se(result, s.rval(), nullptr /*ctx*/); + SE_PRECONDITION2(ok, false, "js_assets_SceneAsset_getScene : Error processing arguments"); + SE_HOLD_RETURN_VALUE(result, s.thisObject(), s.rval()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 0); + return false; +} +SE_BIND_FUNC(js_assets_SceneAsset_getScene) + +static bool js_assets_SceneAsset_setScene(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_assets_SceneAsset_setScene : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 1) { + HolderType arg0 = {}; + ok &= sevalue_to_native(args[0], &arg0, s.thisObject()); + SE_PRECONDITION2(ok, false, "js_assets_SceneAsset_setScene : Error processing arguments"); + cobj->setScene(arg0.value()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 1); + return false; +} +SE_BIND_FUNC(js_assets_SceneAsset_setScene) + +SE_DECLARE_FINALIZE_FUNC(js_cc_SceneAsset_finalize) + +static bool js_assets_SceneAsset_constructor(se::State& s) // NOLINT(readability-identifier-naming) constructor.c +{ + auto *ptr = JSB_MAKE_PRIVATE_OBJECT(cc::SceneAsset); + s.thisObject()->setPrivateObject(ptr); + return true; +} +SE_BIND_CTOR(js_assets_SceneAsset_constructor, __jsb_cc_SceneAsset_class, js_cc_SceneAsset_finalize) + +static bool js_cc_SceneAsset_finalize(se::State& s) // NOLINT(readability-identifier-naming) +{ + return true; +} +SE_BIND_FINALIZE_FUNC(js_cc_SceneAsset_finalize) + +bool js_register_assets_SceneAsset(se::Object* obj) // NOLINT(readability-identifier-naming) +{ + auto* cls = se::Class::create("SceneAsset", obj, __jsb_cc_Asset_proto, _SE(js_assets_SceneAsset_constructor)); + + cls->defineFunction("getScene", _SE(js_assets_SceneAsset_getScene)); + cls->defineFunction("setScene", _SE(js_assets_SceneAsset_setScene)); + cls->defineFinalizeFunction(_SE(js_cc_SceneAsset_finalize)); + cls->install(); + JSBClassType::registerClass(cls); + + __jsb_cc_SceneAsset_proto = cls->getProto(); + __jsb_cc_SceneAsset_class = cls; + + + se::ScriptEngine::getInstance()->clearException(); + return true; +} +se::Object* __jsb_cc_TextAsset_proto = nullptr; // NOLINT +se::Class* __jsb_cc_TextAsset_class = nullptr; // NOLINT + +static bool js_assets_TextAsset_get_text(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_assets_TextAsset_get_text : Invalid Native Object"); + + CC_UNUSED bool ok = true; + se::Value jsret; + ok &= nativevalue_to_se(cobj->text, jsret, s.thisObject() /*ctx*/); + s.rval() = jsret; + SE_HOLD_RETURN_VALUE(cobj->text, s.thisObject(), s.rval()); + return true; +} +SE_BIND_PROP_GET(js_assets_TextAsset_get_text) + +static bool js_assets_TextAsset_set_text(se::State& s) // NOLINT(readability-identifier-naming) +{ + const auto& args = s.args(); + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_assets_TextAsset_set_text : Invalid Native Object"); + + CC_UNUSED bool ok = true; + ok &= sevalue_to_native(args[0], &cobj->text, s.thisObject()); + SE_PRECONDITION2(ok, false, "js_assets_TextAsset_set_text : Error processing new value"); + return true; +} +SE_BIND_PROP_SET(js_assets_TextAsset_set_text) + +SE_DECLARE_FINALIZE_FUNC(js_cc_TextAsset_finalize) + +static bool js_assets_TextAsset_constructor(se::State& s) // NOLINT(readability-identifier-naming) constructor.c +{ + auto *ptr = JSB_MAKE_PRIVATE_OBJECT(cc::TextAsset); + s.thisObject()->setPrivateObject(ptr); + return true; +} +SE_BIND_CTOR(js_assets_TextAsset_constructor, __jsb_cc_TextAsset_class, js_cc_TextAsset_finalize) + +static bool js_cc_TextAsset_finalize(se::State& s) // NOLINT(readability-identifier-naming) +{ + return true; +} +SE_BIND_FINALIZE_FUNC(js_cc_TextAsset_finalize) + +bool js_register_assets_TextAsset(se::Object* obj) // NOLINT(readability-identifier-naming) +{ + auto* cls = se::Class::create("TextAsset", obj, __jsb_cc_Asset_proto, _SE(js_assets_TextAsset_constructor)); + + cls->defineProperty("text", _SE(js_assets_TextAsset_get_text), _SE(js_assets_TextAsset_set_text)); + cls->defineFinalizeFunction(_SE(js_cc_TextAsset_finalize)); + cls->install(); + JSBClassType::registerClass(cls); + + __jsb_cc_TextAsset_proto = cls->getProto(); + __jsb_cc_TextAsset_class = cls; + + + se::ScriptEngine::getInstance()->clearException(); + return true; +} +se::Object* __jsb_cc_SimpleTexture_proto = nullptr; // NOLINT +se::Class* __jsb_cc_SimpleTexture_class = nullptr; // NOLINT + +static bool js_assets_SimpleTexture_assignImage(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_assets_SimpleTexture_assignImage : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 2) { + HolderType arg0 = {}; + HolderType arg1 = {}; + ok &= sevalue_to_native(args[0], &arg0, s.thisObject()); + ok &= sevalue_to_native(args[1], &arg1, s.thisObject()); + SE_PRECONDITION2(ok, false, "js_assets_SimpleTexture_assignImage : Error processing arguments"); + cobj->assignImage(arg0.value(), arg1.value()); + return true; + } + if (argc == 3) { + HolderType arg0 = {}; + HolderType arg1 = {}; + HolderType arg2 = {}; + ok &= sevalue_to_native(args[0], &arg0, s.thisObject()); + ok &= sevalue_to_native(args[1], &arg1, s.thisObject()); + ok &= sevalue_to_native(args[2], &arg2, s.thisObject()); + SE_PRECONDITION2(ok, false, "js_assets_SimpleTexture_assignImage : Error processing arguments"); + cobj->assignImage(arg0.value(), arg1.value(), arg2.value()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 3); + return false; +} +SE_BIND_FUNC(js_assets_SimpleTexture_assignImage) + +static bool js_assets_SimpleTexture_checkTextureLoaded(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_assets_SimpleTexture_checkTextureLoaded : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + if (argc == 0) { + cobj->checkTextureLoaded(); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 0); + return false; +} +SE_BIND_FUNC(js_assets_SimpleTexture_checkTextureLoaded) + +static bool js_assets_SimpleTexture_mipmapLevel(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_assets_SimpleTexture_mipmapLevel : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 0) { + unsigned int result = cobj->mipmapLevel(); + ok &= nativevalue_to_se(result, s.rval(), nullptr /*ctx*/); + SE_PRECONDITION2(ok, false, "js_assets_SimpleTexture_mipmapLevel : Error processing arguments"); + SE_HOLD_RETURN_VALUE(result, s.thisObject(), s.rval()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 0); + return false; +} +SE_BIND_FUNC_AS_PROP_GET(js_assets_SimpleTexture_mipmapLevel) + +static bool js_assets_SimpleTexture_setMipmapLevel(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_assets_SimpleTexture_setMipmapLevel : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 1) { + HolderType arg0 = {}; + ok &= sevalue_to_native(args[0], &arg0, s.thisObject()); + SE_PRECONDITION2(ok, false, "js_assets_SimpleTexture_setMipmapLevel : Error processing arguments"); + cobj->setMipmapLevel(arg0.value()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 1); + return false; +} +SE_BIND_FUNC_AS_PROP_SET(js_assets_SimpleTexture_setMipmapLevel) + +static bool js_assets_SimpleTexture_updateImage(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_assets_SimpleTexture_updateImage : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + if (argc == 0) { + cobj->updateImage(); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 0); + return false; +} +SE_BIND_FUNC(js_assets_SimpleTexture_updateImage) + +static bool js_assets_SimpleTexture_updateMipmaps(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_assets_SimpleTexture_updateMipmaps : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 2) { + HolderType arg0 = {}; + HolderType arg1 = {}; + ok &= sevalue_to_native(args[0], &arg0, s.thisObject()); + ok &= sevalue_to_native(args[1], &arg1, s.thisObject()); + SE_PRECONDITION2(ok, false, "js_assets_SimpleTexture_updateMipmaps : Error processing arguments"); + cobj->updateMipmaps(arg0.value(), arg1.value()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 2); + return false; +} +SE_BIND_FUNC(js_assets_SimpleTexture_updateMipmaps) + +static bool js_assets_SimpleTexture_uploadData(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_assets_SimpleTexture_uploadData : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 1) { + HolderType arg0 = {}; + ok &= sevalue_to_native(args[0], &arg0, s.thisObject()); + SE_PRECONDITION2(ok, false, "js_assets_SimpleTexture_uploadData : Error processing arguments"); + cobj->uploadData(arg0.value()); + return true; + } + if (argc == 2) { + HolderType arg0 = {}; + HolderType arg1 = {}; + ok &= sevalue_to_native(args[0], &arg0, s.thisObject()); + ok &= sevalue_to_native(args[1], &arg1, s.thisObject()); + SE_PRECONDITION2(ok, false, "js_assets_SimpleTexture_uploadData : Error processing arguments"); + cobj->uploadData(arg0.value(), arg1.value()); + return true; + } + if (argc == 3) { + HolderType arg0 = {}; + HolderType arg1 = {}; + HolderType arg2 = {}; + ok &= sevalue_to_native(args[0], &arg0, s.thisObject()); + ok &= sevalue_to_native(args[1], &arg1, s.thisObject()); + ok &= sevalue_to_native(args[2], &arg2, s.thisObject()); + SE_PRECONDITION2(ok, false, "js_assets_SimpleTexture_uploadData : Error processing arguments"); + cobj->uploadData(arg0.value(), arg1.value(), arg2.value()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 3); + return false; +} +SE_BIND_FUNC(js_assets_SimpleTexture_uploadData) +static bool js_cc_SimpleTexture_finalize(se::State& s) // NOLINT(readability-identifier-naming) +{ + return true; +} +SE_BIND_FINALIZE_FUNC(js_cc_SimpleTexture_finalize) + +bool js_register_assets_SimpleTexture(se::Object* obj) // NOLINT(readability-identifier-naming) +{ + auto* cls = se::Class::create("SimpleTexture", obj, __jsb_cc_TextureBase_proto, nullptr); + + cls->defineProperty("mipmapLevel", _SE(js_assets_SimpleTexture_mipmapLevel_asGetter), _SE(js_assets_SimpleTexture_setMipmapLevel_asSetter)); + cls->defineFunction("assignImage", _SE(js_assets_SimpleTexture_assignImage)); + cls->defineFunction("checkTextureLoaded", _SE(js_assets_SimpleTexture_checkTextureLoaded)); + cls->defineFunction("updateImage", _SE(js_assets_SimpleTexture_updateImage)); + cls->defineFunction("updateMipmaps", _SE(js_assets_SimpleTexture_updateMipmaps)); + cls->defineFunction("uploadData", _SE(js_assets_SimpleTexture_uploadData)); + cls->defineFinalizeFunction(_SE(js_cc_SimpleTexture_finalize)); + cls->install(); + JSBClassType::registerClass(cls); + + __jsb_cc_SimpleTexture_proto = cls->getProto(); + __jsb_cc_SimpleTexture_class = cls; + + + se::ScriptEngine::getInstance()->clearException(); + return true; +} +se::Object* __jsb_cc_ITexture2DSerializeData_proto = nullptr; // NOLINT +se::Class* __jsb_cc_ITexture2DSerializeData_class = nullptr; // NOLINT + +static bool js_assets_ITexture2DSerializeData_get_base(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_assets_ITexture2DSerializeData_get_base : Invalid Native Object"); + + CC_UNUSED bool ok = true; + se::Value jsret; + ok &= nativevalue_to_se(cobj->base, jsret, s.thisObject() /*ctx*/); + s.rval() = jsret; + SE_HOLD_RETURN_VALUE(cobj->base, s.thisObject(), s.rval()); + return true; +} +SE_BIND_PROP_GET(js_assets_ITexture2DSerializeData_get_base) + +static bool js_assets_ITexture2DSerializeData_set_base(se::State& s) // NOLINT(readability-identifier-naming) +{ + const auto& args = s.args(); + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_assets_ITexture2DSerializeData_set_base : Invalid Native Object"); + + CC_UNUSED bool ok = true; + ok &= sevalue_to_native(args[0], &cobj->base, s.thisObject()); + SE_PRECONDITION2(ok, false, "js_assets_ITexture2DSerializeData_set_base : Error processing new value"); + return true; +} +SE_BIND_PROP_SET(js_assets_ITexture2DSerializeData_set_base) + +static bool js_assets_ITexture2DSerializeData_get_mipmaps(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_assets_ITexture2DSerializeData_get_mipmaps : Invalid Native Object"); + + CC_UNUSED bool ok = true; + se::Value jsret; + ok &= nativevalue_to_se(cobj->mipmaps, jsret, s.thisObject() /*ctx*/); + s.rval() = jsret; + SE_HOLD_RETURN_VALUE(cobj->mipmaps, s.thisObject(), s.rval()); + return true; +} +SE_BIND_PROP_GET(js_assets_ITexture2DSerializeData_get_mipmaps) + +static bool js_assets_ITexture2DSerializeData_set_mipmaps(se::State& s) // NOLINT(readability-identifier-naming) +{ + const auto& args = s.args(); + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_assets_ITexture2DSerializeData_set_mipmaps : Invalid Native Object"); + + CC_UNUSED bool ok = true; + ok &= sevalue_to_native(args[0], &cobj->mipmaps, s.thisObject()); + SE_PRECONDITION2(ok, false, "js_assets_ITexture2DSerializeData_set_mipmaps : Error processing new value"); + return true; +} +SE_BIND_PROP_SET(js_assets_ITexture2DSerializeData_set_mipmaps) + + +template<> +bool sevalue_to_native(const se::Value &from, cc::ITexture2DSerializeData * to, se::Object *ctx) +{ + assert(from.isObject()); + se::Object *json = from.toObject(); + auto* data = reinterpret_cast(json->getPrivateData()); + if (data) { + *to = *data; + return true; + } + se::Value field; + bool ok = true; + json->getProperty("base", &field, true); + if(!field.isNullOrUndefined()) { + ok &= sevalue_to_native(field, &(to->base), ctx); + } + json->getProperty("mipmaps", &field, true); + if(!field.isNullOrUndefined()) { + ok &= sevalue_to_native(field, &(to->mipmaps), ctx); + } + return ok; +} + +SE_DECLARE_FINALIZE_FUNC(js_cc_ITexture2DSerializeData_finalize) + +static bool js_assets_ITexture2DSerializeData_constructor(se::State& s) // NOLINT(readability-identifier-naming) +{ + CC_UNUSED bool ok = true; + const auto& args = s.args(); + size_t argc = args.size(); + + if(argc == 0) + { + auto *ptr = JSB_MAKE_PRIVATE_OBJECT(cc::ITexture2DSerializeData); + s.thisObject()->setPrivateObject(ptr); + return true; + } + + if(argc == 1 && args[0].isObject()) + { + se::Object *json = args[0].toObject(); + se::Value field; + auto *ptr = JSB_MAKE_PRIVATE_OBJECT(cc::ITexture2DSerializeData); + auto cobj = ptr->get(); + ok &= sevalue_to_native(args[0], cobj, s.thisObject()); + if(!ok) { + delete ptr; + SE_REPORT_ERROR("argument convertion error"); + return false; + } + s.thisObject()->setPrivateObject(ptr); + return true; + } + auto *ptr = JSB_MAKE_PRIVATE_OBJECT(cc::ITexture2DSerializeData); + auto cobj = ptr->get(); + if (argc > 0 && !args[0].isUndefined()) { + ok &= sevalue_to_native(args[0], &(cobj->base), nullptr); + } + if (argc > 1 && !args[1].isUndefined()) { + ok &= sevalue_to_native(args[1], &(cobj->mipmaps), nullptr); + } + + if(!ok) { + delete ptr; + SE_REPORT_ERROR("Argument convertion error"); + return false; + } + s.thisObject()->setPrivateObject(ptr); + return true; +} +SE_BIND_CTOR(js_assets_ITexture2DSerializeData_constructor, __jsb_cc_ITexture2DSerializeData_class, js_cc_ITexture2DSerializeData_finalize) + +static bool js_cc_ITexture2DSerializeData_finalize(se::State& s) // NOLINT(readability-identifier-naming) +{ + return true; +} +SE_BIND_FINALIZE_FUNC(js_cc_ITexture2DSerializeData_finalize) + +bool js_register_assets_ITexture2DSerializeData(se::Object* obj) // NOLINT(readability-identifier-naming) +{ + auto* cls = se::Class::create("ITexture2DSerializeData", obj, nullptr, _SE(js_assets_ITexture2DSerializeData_constructor)); + + cls->defineProperty("base", _SE(js_assets_ITexture2DSerializeData_get_base), _SE(js_assets_ITexture2DSerializeData_set_base)); + cls->defineProperty("mipmaps", _SE(js_assets_ITexture2DSerializeData_get_mipmaps), _SE(js_assets_ITexture2DSerializeData_set_mipmaps)); + cls->defineFinalizeFunction(_SE(js_cc_ITexture2DSerializeData_finalize)); + cls->install(); + JSBClassType::registerClass(cls); + + __jsb_cc_ITexture2DSerializeData_proto = cls->getProto(); + __jsb_cc_ITexture2DSerializeData_class = cls; + + + se::ScriptEngine::getInstance()->clearException(); + return true; +} +se::Object* __jsb_cc_ITexture2DCreateInfo_proto = nullptr; // NOLINT +se::Class* __jsb_cc_ITexture2DCreateInfo_class = nullptr; // NOLINT + +static bool js_assets_ITexture2DCreateInfo_get_width(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_assets_ITexture2DCreateInfo_get_width : Invalid Native Object"); + + CC_UNUSED bool ok = true; + se::Value jsret; + ok &= nativevalue_to_se(cobj->width, jsret, s.thisObject() /*ctx*/); + s.rval() = jsret; + SE_HOLD_RETURN_VALUE(cobj->width, s.thisObject(), s.rval()); + return true; +} +SE_BIND_PROP_GET(js_assets_ITexture2DCreateInfo_get_width) + +static bool js_assets_ITexture2DCreateInfo_set_width(se::State& s) // NOLINT(readability-identifier-naming) +{ + const auto& args = s.args(); + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_assets_ITexture2DCreateInfo_set_width : Invalid Native Object"); + + CC_UNUSED bool ok = true; + ok &= sevalue_to_native(args[0], &cobj->width, s.thisObject()); + SE_PRECONDITION2(ok, false, "js_assets_ITexture2DCreateInfo_set_width : Error processing new value"); + return true; +} +SE_BIND_PROP_SET(js_assets_ITexture2DCreateInfo_set_width) + +static bool js_assets_ITexture2DCreateInfo_get_height(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_assets_ITexture2DCreateInfo_get_height : Invalid Native Object"); + + CC_UNUSED bool ok = true; + se::Value jsret; + ok &= nativevalue_to_se(cobj->height, jsret, s.thisObject() /*ctx*/); + s.rval() = jsret; + SE_HOLD_RETURN_VALUE(cobj->height, s.thisObject(), s.rval()); + return true; +} +SE_BIND_PROP_GET(js_assets_ITexture2DCreateInfo_get_height) + +static bool js_assets_ITexture2DCreateInfo_set_height(se::State& s) // NOLINT(readability-identifier-naming) +{ + const auto& args = s.args(); + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_assets_ITexture2DCreateInfo_set_height : Invalid Native Object"); + + CC_UNUSED bool ok = true; + ok &= sevalue_to_native(args[0], &cobj->height, s.thisObject()); + SE_PRECONDITION2(ok, false, "js_assets_ITexture2DCreateInfo_set_height : Error processing new value"); + return true; +} +SE_BIND_PROP_SET(js_assets_ITexture2DCreateInfo_set_height) + +static bool js_assets_ITexture2DCreateInfo_get_format(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_assets_ITexture2DCreateInfo_get_format : Invalid Native Object"); + + CC_UNUSED bool ok = true; + se::Value jsret; + ok &= nativevalue_to_se(cobj->format, jsret, s.thisObject() /*ctx*/); + s.rval() = jsret; + SE_HOLD_RETURN_VALUE(cobj->format, s.thisObject(), s.rval()); + return true; +} +SE_BIND_PROP_GET(js_assets_ITexture2DCreateInfo_get_format) + +static bool js_assets_ITexture2DCreateInfo_set_format(se::State& s) // NOLINT(readability-identifier-naming) +{ + const auto& args = s.args(); + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_assets_ITexture2DCreateInfo_set_format : Invalid Native Object"); + + CC_UNUSED bool ok = true; + ok &= sevalue_to_native(args[0], &cobj->format, s.thisObject()); + SE_PRECONDITION2(ok, false, "js_assets_ITexture2DCreateInfo_set_format : Error processing new value"); + return true; +} +SE_BIND_PROP_SET(js_assets_ITexture2DCreateInfo_set_format) + +static bool js_assets_ITexture2DCreateInfo_get_mipmapLevel(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_assets_ITexture2DCreateInfo_get_mipmapLevel : Invalid Native Object"); + + CC_UNUSED bool ok = true; + se::Value jsret; + ok &= nativevalue_to_se(cobj->mipmapLevel, jsret, s.thisObject() /*ctx*/); + s.rval() = jsret; + SE_HOLD_RETURN_VALUE(cobj->mipmapLevel, s.thisObject(), s.rval()); + return true; +} +SE_BIND_PROP_GET(js_assets_ITexture2DCreateInfo_get_mipmapLevel) + +static bool js_assets_ITexture2DCreateInfo_set_mipmapLevel(se::State& s) // NOLINT(readability-identifier-naming) +{ + const auto& args = s.args(); + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_assets_ITexture2DCreateInfo_set_mipmapLevel : Invalid Native Object"); + + CC_UNUSED bool ok = true; + ok &= sevalue_to_native(args[0], &cobj->mipmapLevel, s.thisObject()); + SE_PRECONDITION2(ok, false, "js_assets_ITexture2DCreateInfo_set_mipmapLevel : Error processing new value"); + return true; +} +SE_BIND_PROP_SET(js_assets_ITexture2DCreateInfo_set_mipmapLevel) + + +template<> +bool sevalue_to_native(const se::Value &from, cc::ITexture2DCreateInfo * to, se::Object *ctx) +{ + assert(from.isObject()); + se::Object *json = from.toObject(); + auto* data = reinterpret_cast(json->getPrivateData()); + if (data) { + *to = *data; + return true; + } + se::Value field; + bool ok = true; + json->getProperty("width", &field, true); + if(!field.isNullOrUndefined()) { + ok &= sevalue_to_native(field, &(to->width), ctx); + } + json->getProperty("height", &field, true); + if(!field.isNullOrUndefined()) { + ok &= sevalue_to_native(field, &(to->height), ctx); + } + json->getProperty("format", &field, true); + if(!field.isNullOrUndefined()) { + ok &= sevalue_to_native(field, &(to->format), ctx); + } + json->getProperty("mipmapLevel", &field, true); + if(!field.isNullOrUndefined()) { + ok &= sevalue_to_native(field, &(to->mipmapLevel), ctx); + } + return ok; +} + +SE_DECLARE_FINALIZE_FUNC(js_cc_ITexture2DCreateInfo_finalize) + +static bool js_assets_ITexture2DCreateInfo_constructor(se::State& s) // NOLINT(readability-identifier-naming) +{ + CC_UNUSED bool ok = true; + const auto& args = s.args(); + size_t argc = args.size(); + + if(argc == 0) + { + auto *ptr = JSB_MAKE_PRIVATE_OBJECT(cc::ITexture2DCreateInfo); + s.thisObject()->setPrivateObject(ptr); + return true; + } + + if(argc == 1 && args[0].isObject()) + { + se::Object *json = args[0].toObject(); + se::Value field; + auto *ptr = JSB_MAKE_PRIVATE_OBJECT(cc::ITexture2DCreateInfo); + auto cobj = ptr->get(); + ok &= sevalue_to_native(args[0], cobj, s.thisObject()); + if(!ok) { + delete ptr; + SE_REPORT_ERROR("argument convertion error"); + return false; + } + s.thisObject()->setPrivateObject(ptr); + return true; + } + auto *ptr = JSB_MAKE_PRIVATE_OBJECT(cc::ITexture2DCreateInfo); + auto cobj = ptr->get(); + if (argc > 0 && !args[0].isUndefined()) { + ok &= sevalue_to_native(args[0], &(cobj->width), nullptr); + } + if (argc > 1 && !args[1].isUndefined()) { + ok &= sevalue_to_native(args[1], &(cobj->height), nullptr); + } + if (argc > 2 && !args[2].isUndefined()) { + ok &= sevalue_to_native(args[2], &(cobj->format), nullptr); + } + if (argc > 3 && !args[3].isUndefined()) { + ok &= sevalue_to_native(args[3], &(cobj->mipmapLevel), nullptr); + } + + if(!ok) { + delete ptr; + SE_REPORT_ERROR("Argument convertion error"); + return false; + } + s.thisObject()->setPrivateObject(ptr); + return true; +} +SE_BIND_CTOR(js_assets_ITexture2DCreateInfo_constructor, __jsb_cc_ITexture2DCreateInfo_class, js_cc_ITexture2DCreateInfo_finalize) + +static bool js_cc_ITexture2DCreateInfo_finalize(se::State& s) // NOLINT(readability-identifier-naming) +{ + return true; +} +SE_BIND_FINALIZE_FUNC(js_cc_ITexture2DCreateInfo_finalize) + +bool js_register_assets_ITexture2DCreateInfo(se::Object* obj) // NOLINT(readability-identifier-naming) +{ + auto* cls = se::Class::create("ITexture2DCreateInfo", obj, nullptr, _SE(js_assets_ITexture2DCreateInfo_constructor)); + + cls->defineProperty("width", _SE(js_assets_ITexture2DCreateInfo_get_width), _SE(js_assets_ITexture2DCreateInfo_set_width)); + cls->defineProperty("height", _SE(js_assets_ITexture2DCreateInfo_get_height), _SE(js_assets_ITexture2DCreateInfo_set_height)); + cls->defineProperty("format", _SE(js_assets_ITexture2DCreateInfo_get_format), _SE(js_assets_ITexture2DCreateInfo_set_format)); + cls->defineProperty("mipmapLevel", _SE(js_assets_ITexture2DCreateInfo_get_mipmapLevel), _SE(js_assets_ITexture2DCreateInfo_set_mipmapLevel)); + cls->defineFinalizeFunction(_SE(js_cc_ITexture2DCreateInfo_finalize)); + cls->install(); + JSBClassType::registerClass(cls); + + __jsb_cc_ITexture2DCreateInfo_proto = cls->getProto(); + __jsb_cc_ITexture2DCreateInfo_class = cls; + + + se::ScriptEngine::getInstance()->clearException(); + return true; +} +se::Object* __jsb_cc_Texture2D_proto = nullptr; // NOLINT +se::Class* __jsb_cc_Texture2D_class = nullptr; // NOLINT + +static bool js_assets_Texture2D_create(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_assets_Texture2D_create : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 2) { + HolderType arg0 = {}; + HolderType arg1 = {}; + ok &= sevalue_to_native(args[0], &arg0, s.thisObject()); + ok &= sevalue_to_native(args[1], &arg1, s.thisObject()); + SE_PRECONDITION2(ok, false, "js_assets_Texture2D_create : Error processing arguments"); + cobj->create(arg0.value(), arg1.value()); + return true; + } + if (argc == 3) { + HolderType arg0 = {}; + HolderType arg1 = {}; + HolderType arg2 = {}; + ok &= sevalue_to_native(args[0], &arg0, s.thisObject()); + ok &= sevalue_to_native(args[1], &arg1, s.thisObject()); + ok &= sevalue_to_native(args[2], &arg2, s.thisObject()); + SE_PRECONDITION2(ok, false, "js_assets_Texture2D_create : Error processing arguments"); + cobj->create(arg0.value(), arg1.value(), arg2.value()); + return true; + } + if (argc == 4) { + HolderType arg0 = {}; + HolderType arg1 = {}; + HolderType arg2 = {}; + HolderType arg3 = {}; + ok &= sevalue_to_native(args[0], &arg0, s.thisObject()); + ok &= sevalue_to_native(args[1], &arg1, s.thisObject()); + ok &= sevalue_to_native(args[2], &arg2, s.thisObject()); + ok &= sevalue_to_native(args[3], &arg3, s.thisObject()); + SE_PRECONDITION2(ok, false, "js_assets_Texture2D_create : Error processing arguments"); + cobj->create(arg0.value(), arg1.value(), arg2.value(), arg3.value()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 4); + return false; +} +SE_BIND_FUNC(js_assets_Texture2D_create) + +static bool js_assets_Texture2D_description(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_assets_Texture2D_description : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 0) { + std::string result = cobj->description(); + ok &= nativevalue_to_se(result, s.rval(), nullptr /*ctx*/); + SE_PRECONDITION2(ok, false, "js_assets_Texture2D_description : Error processing arguments"); + SE_HOLD_RETURN_VALUE(result, s.thisObject(), s.rval()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 0); + return false; +} +SE_BIND_FUNC(js_assets_Texture2D_description) + +static bool js_assets_Texture2D_getGfxTextureCreateInfo(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_assets_Texture2D_getGfxTextureCreateInfo : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 4) { + HolderType arg0 = {}; + HolderType arg1 = {}; + HolderType arg2 = {}; + HolderType arg3 = {}; + ok &= sevalue_to_native(args[0], &arg0, s.thisObject()); + ok &= sevalue_to_native(args[1], &arg1, s.thisObject()); + ok &= sevalue_to_native(args[2], &arg2, s.thisObject()); + ok &= sevalue_to_native(args[3], &arg3, s.thisObject()); + SE_PRECONDITION2(ok, false, "js_assets_Texture2D_getGfxTextureCreateInfo : Error processing arguments"); + cc::gfx::TextureInfo result = cobj->getGfxTextureCreateInfo(arg0.value(), arg1.value(), arg2.value(), arg3.value()); + ok &= nativevalue_to_se(result, s.rval(), nullptr /*ctx*/); + SE_PRECONDITION2(ok, false, "js_assets_Texture2D_getGfxTextureCreateInfo : Error processing arguments"); + SE_HOLD_RETURN_VALUE(result, s.thisObject(), s.rval()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 4); + return false; +} +SE_BIND_FUNC(js_assets_Texture2D_getGfxTextureCreateInfo) + +static bool js_assets_Texture2D_getHtmlElementObj(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_assets_Texture2D_getHtmlElementObj : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 0) { + void** result = cobj->getHtmlElementObj(); + ok &= nativevalue_to_se(result, s.rval(), nullptr /*ctx*/); + SE_PRECONDITION2(ok, false, "js_assets_Texture2D_getHtmlElementObj : Error processing arguments"); + SE_HOLD_RETURN_VALUE(result, s.thisObject(), s.rval()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 0); + return false; +} +SE_BIND_FUNC(js_assets_Texture2D_getHtmlElementObj) + +static bool js_assets_Texture2D_getImage(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_assets_Texture2D_getImage : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 0) { + cc::ImageAsset* result = cobj->getImage(); + ok &= nativevalue_to_se(result, s.rval(), nullptr /*ctx*/); + SE_PRECONDITION2(ok, false, "js_assets_Texture2D_getImage : Error processing arguments"); + SE_HOLD_RETURN_VALUE(result, s.thisObject(), s.rval()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 0); + return false; +} +SE_BIND_FUNC(js_assets_Texture2D_getImage) + +static bool js_assets_Texture2D_getMipmaps(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_assets_Texture2D_getMipmaps : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 0) { + const std::vector>& result = cobj->getMipmaps(); + ok &= nativevalue_to_se(result, s.rval(), nullptr /*ctx*/); + SE_PRECONDITION2(ok, false, "js_assets_Texture2D_getMipmaps : Error processing arguments"); + SE_HOLD_RETURN_VALUE(result, s.thisObject(), s.rval()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 0); + return false; +} +SE_BIND_FUNC(js_assets_Texture2D_getMipmaps) + +static bool js_assets_Texture2D_getMipmapsUuids(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_assets_Texture2D_getMipmapsUuids : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 0) { + const std::vector& result = cobj->getMipmapsUuids(); + ok &= nativevalue_to_se(result, s.rval(), nullptr /*ctx*/); + SE_PRECONDITION2(ok, false, "js_assets_Texture2D_getMipmapsUuids : Error processing arguments"); + SE_HOLD_RETURN_VALUE(result, s.thisObject(), s.rval()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 0); + return false; +} +SE_BIND_FUNC(js_assets_Texture2D_getMipmapsUuids) + +static bool js_assets_Texture2D_initialize(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_assets_Texture2D_initialize : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + if (argc == 0) { + cobj->initialize(); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 0); + return false; +} +SE_BIND_FUNC(js_assets_Texture2D_initialize) + +static bool js_assets_Texture2D_releaseTexture(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_assets_Texture2D_releaseTexture : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + if (argc == 0) { + cobj->releaseTexture(); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 0); + return false; +} +SE_BIND_FUNC(js_assets_Texture2D_releaseTexture) + +static bool js_assets_Texture2D_reset(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_assets_Texture2D_reset : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 1) { + HolderType arg0 = {}; + ok &= sevalue_to_native(args[0], &arg0, s.thisObject()); + SE_PRECONDITION2(ok, false, "js_assets_Texture2D_reset : Error processing arguments"); + cobj->reset(arg0.value()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 1); + return false; +} +SE_BIND_FUNC(js_assets_Texture2D_reset) + +static bool js_assets_Texture2D_setImage(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_assets_Texture2D_setImage : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 1) { + HolderType arg0 = {}; + ok &= sevalue_to_native(args[0], &arg0, s.thisObject()); + SE_PRECONDITION2(ok, false, "js_assets_Texture2D_setImage : Error processing arguments"); + cobj->setImage(arg0.value()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 1); + return false; +} +SE_BIND_FUNC(js_assets_Texture2D_setImage) + +static bool js_assets_Texture2D_setMipmaps(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_assets_Texture2D_setMipmaps : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 1) { + HolderType>, true> arg0 = {}; + ok &= sevalue_to_native(args[0], &arg0, s.thisObject()); + SE_PRECONDITION2(ok, false, "js_assets_Texture2D_setMipmaps : Error processing arguments"); + cobj->setMipmaps(arg0.value()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 1); + return false; +} +SE_BIND_FUNC(js_assets_Texture2D_setMipmaps) + +static bool js_assets_Texture2D_syncMipmapsForJS(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_assets_Texture2D_syncMipmapsForJS : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 1) { + HolderType>, true> arg0 = {}; + ok &= sevalue_to_native(args[0], &arg0, s.thisObject()); + SE_PRECONDITION2(ok, false, "js_assets_Texture2D_syncMipmapsForJS : Error processing arguments"); + cobj->syncMipmapsForJS(arg0.value()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 1); + return false; +} +SE_BIND_FUNC(js_assets_Texture2D_syncMipmapsForJS) + +SE_DECLARE_FINALIZE_FUNC(js_cc_Texture2D_finalize) + +static bool js_assets_Texture2D_constructor(se::State& s) // NOLINT(readability-identifier-naming) constructor.c +{ + auto *ptr = JSB_MAKE_PRIVATE_OBJECT(cc::Texture2D); + s.thisObject()->setPrivateObject(ptr); + return true; +} +SE_BIND_CTOR(js_assets_Texture2D_constructor, __jsb_cc_Texture2D_class, js_cc_Texture2D_finalize) + +static bool js_cc_Texture2D_finalize(se::State& s) // NOLINT(readability-identifier-naming) +{ + return true; +} +SE_BIND_FINALIZE_FUNC(js_cc_Texture2D_finalize) + +bool js_register_assets_Texture2D(se::Object* obj) // NOLINT(readability-identifier-naming) +{ + auto* cls = se::Class::create("Texture2D", obj, __jsb_cc_SimpleTexture_proto, _SE(js_assets_Texture2D_constructor)); + + cls->defineFunction("create", _SE(js_assets_Texture2D_create)); + cls->defineFunction("description", _SE(js_assets_Texture2D_description)); + cls->defineFunction("getGfxTextureCreateInfo", _SE(js_assets_Texture2D_getGfxTextureCreateInfo)); + cls->defineFunction("getHtmlElementObj", _SE(js_assets_Texture2D_getHtmlElementObj)); + cls->defineFunction("getImage", _SE(js_assets_Texture2D_getImage)); + cls->defineFunction("getMipmaps", _SE(js_assets_Texture2D_getMipmaps)); + cls->defineFunction("getMipmapsUuids", _SE(js_assets_Texture2D_getMipmapsUuids)); + cls->defineFunction("initialize", _SE(js_assets_Texture2D_initialize)); + cls->defineFunction("releaseTexture", _SE(js_assets_Texture2D_releaseTexture)); + cls->defineFunction("reset", _SE(js_assets_Texture2D_reset)); + cls->defineFunction("setImage", _SE(js_assets_Texture2D_setImage)); + cls->defineFunction("setMipmaps", _SE(js_assets_Texture2D_setMipmaps)); + cls->defineFunction("syncMipmapsForJS", _SE(js_assets_Texture2D_syncMipmapsForJS)); + cls->defineFinalizeFunction(_SE(js_cc_Texture2D_finalize)); + cls->install(); + JSBClassType::registerClass(cls); + + __jsb_cc_Texture2D_proto = cls->getProto(); + __jsb_cc_Texture2D_class = cls; + + + se::ScriptEngine::getInstance()->clearException(); + return true; +} +se::Object* __jsb_cc_ITextureCubeMipmap_proto = nullptr; // NOLINT +se::Class* __jsb_cc_ITextureCubeMipmap_class = nullptr; // NOLINT + +static bool js_assets_ITextureCubeMipmap_get_front(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_assets_ITextureCubeMipmap_get_front : Invalid Native Object"); + + CC_UNUSED bool ok = true; + se::Value jsret; + ok &= nativevalue_to_se(cobj->front, jsret, s.thisObject() /*ctx*/); + s.rval() = jsret; + SE_HOLD_RETURN_VALUE(cobj->front, s.thisObject(), s.rval()); + return true; +} +SE_BIND_PROP_GET(js_assets_ITextureCubeMipmap_get_front) + +static bool js_assets_ITextureCubeMipmap_set_front(se::State& s) // NOLINT(readability-identifier-naming) +{ + const auto& args = s.args(); + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_assets_ITextureCubeMipmap_set_front : Invalid Native Object"); + + CC_UNUSED bool ok = true; + ok &= sevalue_to_native(args[0], &cobj->front, s.thisObject()); + SE_PRECONDITION2(ok, false, "js_assets_ITextureCubeMipmap_set_front : Error processing new value"); + return true; +} +SE_BIND_PROP_SET(js_assets_ITextureCubeMipmap_set_front) + +static bool js_assets_ITextureCubeMipmap_get_back(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_assets_ITextureCubeMipmap_get_back : Invalid Native Object"); + + CC_UNUSED bool ok = true; + se::Value jsret; + ok &= nativevalue_to_se(cobj->back, jsret, s.thisObject() /*ctx*/); + s.rval() = jsret; + SE_HOLD_RETURN_VALUE(cobj->back, s.thisObject(), s.rval()); + return true; +} +SE_BIND_PROP_GET(js_assets_ITextureCubeMipmap_get_back) + +static bool js_assets_ITextureCubeMipmap_set_back(se::State& s) // NOLINT(readability-identifier-naming) +{ + const auto& args = s.args(); + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_assets_ITextureCubeMipmap_set_back : Invalid Native Object"); + + CC_UNUSED bool ok = true; + ok &= sevalue_to_native(args[0], &cobj->back, s.thisObject()); + SE_PRECONDITION2(ok, false, "js_assets_ITextureCubeMipmap_set_back : Error processing new value"); + return true; +} +SE_BIND_PROP_SET(js_assets_ITextureCubeMipmap_set_back) + +static bool js_assets_ITextureCubeMipmap_get_left(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_assets_ITextureCubeMipmap_get_left : Invalid Native Object"); + + CC_UNUSED bool ok = true; + se::Value jsret; + ok &= nativevalue_to_se(cobj->left, jsret, s.thisObject() /*ctx*/); + s.rval() = jsret; + SE_HOLD_RETURN_VALUE(cobj->left, s.thisObject(), s.rval()); + return true; +} +SE_BIND_PROP_GET(js_assets_ITextureCubeMipmap_get_left) + +static bool js_assets_ITextureCubeMipmap_set_left(se::State& s) // NOLINT(readability-identifier-naming) +{ + const auto& args = s.args(); + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_assets_ITextureCubeMipmap_set_left : Invalid Native Object"); + + CC_UNUSED bool ok = true; + ok &= sevalue_to_native(args[0], &cobj->left, s.thisObject()); + SE_PRECONDITION2(ok, false, "js_assets_ITextureCubeMipmap_set_left : Error processing new value"); + return true; +} +SE_BIND_PROP_SET(js_assets_ITextureCubeMipmap_set_left) + +static bool js_assets_ITextureCubeMipmap_get_right(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_assets_ITextureCubeMipmap_get_right : Invalid Native Object"); + + CC_UNUSED bool ok = true; + se::Value jsret; + ok &= nativevalue_to_se(cobj->right, jsret, s.thisObject() /*ctx*/); + s.rval() = jsret; + SE_HOLD_RETURN_VALUE(cobj->right, s.thisObject(), s.rval()); + return true; +} +SE_BIND_PROP_GET(js_assets_ITextureCubeMipmap_get_right) + +static bool js_assets_ITextureCubeMipmap_set_right(se::State& s) // NOLINT(readability-identifier-naming) +{ + const auto& args = s.args(); + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_assets_ITextureCubeMipmap_set_right : Invalid Native Object"); + + CC_UNUSED bool ok = true; + ok &= sevalue_to_native(args[0], &cobj->right, s.thisObject()); + SE_PRECONDITION2(ok, false, "js_assets_ITextureCubeMipmap_set_right : Error processing new value"); + return true; +} +SE_BIND_PROP_SET(js_assets_ITextureCubeMipmap_set_right) + +static bool js_assets_ITextureCubeMipmap_get_top(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_assets_ITextureCubeMipmap_get_top : Invalid Native Object"); + + CC_UNUSED bool ok = true; + se::Value jsret; + ok &= nativevalue_to_se(cobj->top, jsret, s.thisObject() /*ctx*/); + s.rval() = jsret; + SE_HOLD_RETURN_VALUE(cobj->top, s.thisObject(), s.rval()); + return true; +} +SE_BIND_PROP_GET(js_assets_ITextureCubeMipmap_get_top) + +static bool js_assets_ITextureCubeMipmap_set_top(se::State& s) // NOLINT(readability-identifier-naming) +{ + const auto& args = s.args(); + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_assets_ITextureCubeMipmap_set_top : Invalid Native Object"); + + CC_UNUSED bool ok = true; + ok &= sevalue_to_native(args[0], &cobj->top, s.thisObject()); + SE_PRECONDITION2(ok, false, "js_assets_ITextureCubeMipmap_set_top : Error processing new value"); + return true; +} +SE_BIND_PROP_SET(js_assets_ITextureCubeMipmap_set_top) + +static bool js_assets_ITextureCubeMipmap_get_bottom(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_assets_ITextureCubeMipmap_get_bottom : Invalid Native Object"); + + CC_UNUSED bool ok = true; + se::Value jsret; + ok &= nativevalue_to_se(cobj->bottom, jsret, s.thisObject() /*ctx*/); + s.rval() = jsret; + SE_HOLD_RETURN_VALUE(cobj->bottom, s.thisObject(), s.rval()); + return true; +} +SE_BIND_PROP_GET(js_assets_ITextureCubeMipmap_get_bottom) + +static bool js_assets_ITextureCubeMipmap_set_bottom(se::State& s) // NOLINT(readability-identifier-naming) +{ + const auto& args = s.args(); + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_assets_ITextureCubeMipmap_set_bottom : Invalid Native Object"); + + CC_UNUSED bool ok = true; + ok &= sevalue_to_native(args[0], &cobj->bottom, s.thisObject()); + SE_PRECONDITION2(ok, false, "js_assets_ITextureCubeMipmap_set_bottom : Error processing new value"); + return true; +} +SE_BIND_PROP_SET(js_assets_ITextureCubeMipmap_set_bottom) + + +template<> +bool sevalue_to_native(const se::Value &from, cc::ITextureCubeMipmap * to, se::Object *ctx) +{ + assert(from.isObject()); + se::Object *json = from.toObject(); + auto* data = reinterpret_cast(json->getPrivateData()); + if (data) { + *to = *data; + return true; + } + se::Value field; + bool ok = true; + json->getProperty("front", &field, true); + if(!field.isNullOrUndefined()) { + ok &= sevalue_to_native(field, &(to->front), ctx); + } + json->getProperty("back", &field, true); + if(!field.isNullOrUndefined()) { + ok &= sevalue_to_native(field, &(to->back), ctx); + } + json->getProperty("left", &field, true); + if(!field.isNullOrUndefined()) { + ok &= sevalue_to_native(field, &(to->left), ctx); + } + json->getProperty("right", &field, true); + if(!field.isNullOrUndefined()) { + ok &= sevalue_to_native(field, &(to->right), ctx); + } + json->getProperty("top", &field, true); + if(!field.isNullOrUndefined()) { + ok &= sevalue_to_native(field, &(to->top), ctx); + } + json->getProperty("bottom", &field, true); + if(!field.isNullOrUndefined()) { + ok &= sevalue_to_native(field, &(to->bottom), ctx); + } + return ok; +} + +SE_DECLARE_FINALIZE_FUNC(js_cc_ITextureCubeMipmap_finalize) + +static bool js_assets_ITextureCubeMipmap_constructor(se::State& s) // NOLINT(readability-identifier-naming) +{ + CC_UNUSED bool ok = true; + const auto& args = s.args(); + size_t argc = args.size(); + + if(argc == 0) + { + auto *ptr = JSB_MAKE_PRIVATE_OBJECT(cc::ITextureCubeMipmap); + s.thisObject()->setPrivateObject(ptr); + return true; + } + + if(argc == 1 && args[0].isObject()) + { + se::Object *json = args[0].toObject(); + se::Value field; + auto *ptr = JSB_MAKE_PRIVATE_OBJECT(cc::ITextureCubeMipmap); + auto cobj = ptr->get(); + ok &= sevalue_to_native(args[0], cobj, s.thisObject()); + if(!ok) { + delete ptr; + SE_REPORT_ERROR("argument convertion error"); + return false; + } + s.thisObject()->setPrivateObject(ptr); + return true; + } + auto *ptr = JSB_MAKE_PRIVATE_OBJECT(cc::ITextureCubeMipmap); + auto cobj = ptr->get(); + if (argc > 0 && !args[0].isUndefined()) { + ok &= sevalue_to_native(args[0], &(cobj->front), nullptr); + } + if (argc > 1 && !args[1].isUndefined()) { + ok &= sevalue_to_native(args[1], &(cobj->back), nullptr); + } + if (argc > 2 && !args[2].isUndefined()) { + ok &= sevalue_to_native(args[2], &(cobj->left), nullptr); + } + if (argc > 3 && !args[3].isUndefined()) { + ok &= sevalue_to_native(args[3], &(cobj->right), nullptr); + } + if (argc > 4 && !args[4].isUndefined()) { + ok &= sevalue_to_native(args[4], &(cobj->top), nullptr); + } + if (argc > 5 && !args[5].isUndefined()) { + ok &= sevalue_to_native(args[5], &(cobj->bottom), nullptr); + } + + if(!ok) { + delete ptr; + SE_REPORT_ERROR("Argument convertion error"); + return false; + } + s.thisObject()->setPrivateObject(ptr); + return true; +} +SE_BIND_CTOR(js_assets_ITextureCubeMipmap_constructor, __jsb_cc_ITextureCubeMipmap_class, js_cc_ITextureCubeMipmap_finalize) + +static bool js_cc_ITextureCubeMipmap_finalize(se::State& s) // NOLINT(readability-identifier-naming) +{ + return true; +} +SE_BIND_FINALIZE_FUNC(js_cc_ITextureCubeMipmap_finalize) + +bool js_register_assets_ITextureCubeMipmap(se::Object* obj) // NOLINT(readability-identifier-naming) +{ + auto* cls = se::Class::create("ITextureCubeMipmap", obj, nullptr, _SE(js_assets_ITextureCubeMipmap_constructor)); + + cls->defineProperty("front", _SE(js_assets_ITextureCubeMipmap_get_front), _SE(js_assets_ITextureCubeMipmap_set_front)); + cls->defineProperty("back", _SE(js_assets_ITextureCubeMipmap_get_back), _SE(js_assets_ITextureCubeMipmap_set_back)); + cls->defineProperty("left", _SE(js_assets_ITextureCubeMipmap_get_left), _SE(js_assets_ITextureCubeMipmap_set_left)); + cls->defineProperty("right", _SE(js_assets_ITextureCubeMipmap_get_right), _SE(js_assets_ITextureCubeMipmap_set_right)); + cls->defineProperty("top", _SE(js_assets_ITextureCubeMipmap_get_top), _SE(js_assets_ITextureCubeMipmap_set_top)); + cls->defineProperty("bottom", _SE(js_assets_ITextureCubeMipmap_get_bottom), _SE(js_assets_ITextureCubeMipmap_set_bottom)); + cls->defineFinalizeFunction(_SE(js_cc_ITextureCubeMipmap_finalize)); + cls->install(); + JSBClassType::registerClass(cls); + + __jsb_cc_ITextureCubeMipmap_proto = cls->getProto(); + __jsb_cc_ITextureCubeMipmap_class = cls; + + + se::ScriptEngine::getInstance()->clearException(); + return true; +} +se::Object* __jsb_cc_ITextureCubeSerializeMipmapData_proto = nullptr; // NOLINT +se::Class* __jsb_cc_ITextureCubeSerializeMipmapData_class = nullptr; // NOLINT + +static bool js_assets_ITextureCubeSerializeMipmapData_get_front(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_assets_ITextureCubeSerializeMipmapData_get_front : Invalid Native Object"); + + CC_UNUSED bool ok = true; + se::Value jsret; + ok &= nativevalue_to_se(cobj->front, jsret, s.thisObject() /*ctx*/); + s.rval() = jsret; + SE_HOLD_RETURN_VALUE(cobj->front, s.thisObject(), s.rval()); + return true; +} +SE_BIND_PROP_GET(js_assets_ITextureCubeSerializeMipmapData_get_front) + +static bool js_assets_ITextureCubeSerializeMipmapData_set_front(se::State& s) // NOLINT(readability-identifier-naming) +{ + const auto& args = s.args(); + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_assets_ITextureCubeSerializeMipmapData_set_front : Invalid Native Object"); + + CC_UNUSED bool ok = true; + ok &= sevalue_to_native(args[0], &cobj->front, s.thisObject()); + SE_PRECONDITION2(ok, false, "js_assets_ITextureCubeSerializeMipmapData_set_front : Error processing new value"); + return true; +} +SE_BIND_PROP_SET(js_assets_ITextureCubeSerializeMipmapData_set_front) + +static bool js_assets_ITextureCubeSerializeMipmapData_get_back(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_assets_ITextureCubeSerializeMipmapData_get_back : Invalid Native Object"); + + CC_UNUSED bool ok = true; + se::Value jsret; + ok &= nativevalue_to_se(cobj->back, jsret, s.thisObject() /*ctx*/); + s.rval() = jsret; + SE_HOLD_RETURN_VALUE(cobj->back, s.thisObject(), s.rval()); + return true; +} +SE_BIND_PROP_GET(js_assets_ITextureCubeSerializeMipmapData_get_back) + +static bool js_assets_ITextureCubeSerializeMipmapData_set_back(se::State& s) // NOLINT(readability-identifier-naming) +{ + const auto& args = s.args(); + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_assets_ITextureCubeSerializeMipmapData_set_back : Invalid Native Object"); + + CC_UNUSED bool ok = true; + ok &= sevalue_to_native(args[0], &cobj->back, s.thisObject()); + SE_PRECONDITION2(ok, false, "js_assets_ITextureCubeSerializeMipmapData_set_back : Error processing new value"); + return true; +} +SE_BIND_PROP_SET(js_assets_ITextureCubeSerializeMipmapData_set_back) + +static bool js_assets_ITextureCubeSerializeMipmapData_get_left(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_assets_ITextureCubeSerializeMipmapData_get_left : Invalid Native Object"); + + CC_UNUSED bool ok = true; + se::Value jsret; + ok &= nativevalue_to_se(cobj->left, jsret, s.thisObject() /*ctx*/); + s.rval() = jsret; + SE_HOLD_RETURN_VALUE(cobj->left, s.thisObject(), s.rval()); + return true; +} +SE_BIND_PROP_GET(js_assets_ITextureCubeSerializeMipmapData_get_left) + +static bool js_assets_ITextureCubeSerializeMipmapData_set_left(se::State& s) // NOLINT(readability-identifier-naming) +{ + const auto& args = s.args(); + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_assets_ITextureCubeSerializeMipmapData_set_left : Invalid Native Object"); + + CC_UNUSED bool ok = true; + ok &= sevalue_to_native(args[0], &cobj->left, s.thisObject()); + SE_PRECONDITION2(ok, false, "js_assets_ITextureCubeSerializeMipmapData_set_left : Error processing new value"); + return true; +} +SE_BIND_PROP_SET(js_assets_ITextureCubeSerializeMipmapData_set_left) + +static bool js_assets_ITextureCubeSerializeMipmapData_get_right(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_assets_ITextureCubeSerializeMipmapData_get_right : Invalid Native Object"); + + CC_UNUSED bool ok = true; + se::Value jsret; + ok &= nativevalue_to_se(cobj->right, jsret, s.thisObject() /*ctx*/); + s.rval() = jsret; + SE_HOLD_RETURN_VALUE(cobj->right, s.thisObject(), s.rval()); + return true; +} +SE_BIND_PROP_GET(js_assets_ITextureCubeSerializeMipmapData_get_right) + +static bool js_assets_ITextureCubeSerializeMipmapData_set_right(se::State& s) // NOLINT(readability-identifier-naming) +{ + const auto& args = s.args(); + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_assets_ITextureCubeSerializeMipmapData_set_right : Invalid Native Object"); + + CC_UNUSED bool ok = true; + ok &= sevalue_to_native(args[0], &cobj->right, s.thisObject()); + SE_PRECONDITION2(ok, false, "js_assets_ITextureCubeSerializeMipmapData_set_right : Error processing new value"); + return true; +} +SE_BIND_PROP_SET(js_assets_ITextureCubeSerializeMipmapData_set_right) + +static bool js_assets_ITextureCubeSerializeMipmapData_get_top(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_assets_ITextureCubeSerializeMipmapData_get_top : Invalid Native Object"); + + CC_UNUSED bool ok = true; + se::Value jsret; + ok &= nativevalue_to_se(cobj->top, jsret, s.thisObject() /*ctx*/); + s.rval() = jsret; + SE_HOLD_RETURN_VALUE(cobj->top, s.thisObject(), s.rval()); + return true; +} +SE_BIND_PROP_GET(js_assets_ITextureCubeSerializeMipmapData_get_top) + +static bool js_assets_ITextureCubeSerializeMipmapData_set_top(se::State& s) // NOLINT(readability-identifier-naming) +{ + const auto& args = s.args(); + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_assets_ITextureCubeSerializeMipmapData_set_top : Invalid Native Object"); + + CC_UNUSED bool ok = true; + ok &= sevalue_to_native(args[0], &cobj->top, s.thisObject()); + SE_PRECONDITION2(ok, false, "js_assets_ITextureCubeSerializeMipmapData_set_top : Error processing new value"); + return true; +} +SE_BIND_PROP_SET(js_assets_ITextureCubeSerializeMipmapData_set_top) + +static bool js_assets_ITextureCubeSerializeMipmapData_get_bottom(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_assets_ITextureCubeSerializeMipmapData_get_bottom : Invalid Native Object"); + + CC_UNUSED bool ok = true; + se::Value jsret; + ok &= nativevalue_to_se(cobj->bottom, jsret, s.thisObject() /*ctx*/); + s.rval() = jsret; + SE_HOLD_RETURN_VALUE(cobj->bottom, s.thisObject(), s.rval()); + return true; +} +SE_BIND_PROP_GET(js_assets_ITextureCubeSerializeMipmapData_get_bottom) + +static bool js_assets_ITextureCubeSerializeMipmapData_set_bottom(se::State& s) // NOLINT(readability-identifier-naming) +{ + const auto& args = s.args(); + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_assets_ITextureCubeSerializeMipmapData_set_bottom : Invalid Native Object"); + + CC_UNUSED bool ok = true; + ok &= sevalue_to_native(args[0], &cobj->bottom, s.thisObject()); + SE_PRECONDITION2(ok, false, "js_assets_ITextureCubeSerializeMipmapData_set_bottom : Error processing new value"); + return true; +} +SE_BIND_PROP_SET(js_assets_ITextureCubeSerializeMipmapData_set_bottom) + + +template<> +bool sevalue_to_native(const se::Value &from, cc::ITextureCubeSerializeMipmapData * to, se::Object *ctx) +{ + assert(from.isObject()); + se::Object *json = from.toObject(); + auto* data = reinterpret_cast(json->getPrivateData()); + if (data) { + *to = *data; + return true; + } + se::Value field; + bool ok = true; + json->getProperty("front", &field, true); + if(!field.isNullOrUndefined()) { + ok &= sevalue_to_native(field, &(to->front), ctx); + } + json->getProperty("back", &field, true); + if(!field.isNullOrUndefined()) { + ok &= sevalue_to_native(field, &(to->back), ctx); + } + json->getProperty("left", &field, true); + if(!field.isNullOrUndefined()) { + ok &= sevalue_to_native(field, &(to->left), ctx); + } + json->getProperty("right", &field, true); + if(!field.isNullOrUndefined()) { + ok &= sevalue_to_native(field, &(to->right), ctx); + } + json->getProperty("top", &field, true); + if(!field.isNullOrUndefined()) { + ok &= sevalue_to_native(field, &(to->top), ctx); + } + json->getProperty("bottom", &field, true); + if(!field.isNullOrUndefined()) { + ok &= sevalue_to_native(field, &(to->bottom), ctx); + } + return ok; +} + +SE_DECLARE_FINALIZE_FUNC(js_cc_ITextureCubeSerializeMipmapData_finalize) + +static bool js_assets_ITextureCubeSerializeMipmapData_constructor(se::State& s) // NOLINT(readability-identifier-naming) +{ + CC_UNUSED bool ok = true; + const auto& args = s.args(); + size_t argc = args.size(); + + if(argc == 0) + { + auto *ptr = JSB_MAKE_PRIVATE_OBJECT(cc::ITextureCubeSerializeMipmapData); + s.thisObject()->setPrivateObject(ptr); + return true; + } + + if(argc == 1 && args[0].isObject()) + { + se::Object *json = args[0].toObject(); + se::Value field; + auto *ptr = JSB_MAKE_PRIVATE_OBJECT(cc::ITextureCubeSerializeMipmapData); + auto cobj = ptr->get(); + ok &= sevalue_to_native(args[0], cobj, s.thisObject()); + if(!ok) { + delete ptr; + SE_REPORT_ERROR("argument convertion error"); + return false; + } + s.thisObject()->setPrivateObject(ptr); + return true; + } + auto *ptr = JSB_MAKE_PRIVATE_OBJECT(cc::ITextureCubeSerializeMipmapData); + auto cobj = ptr->get(); + if (argc > 0 && !args[0].isUndefined()) { + ok &= sevalue_to_native(args[0], &(cobj->front), nullptr); + } + if (argc > 1 && !args[1].isUndefined()) { + ok &= sevalue_to_native(args[1], &(cobj->back), nullptr); + } + if (argc > 2 && !args[2].isUndefined()) { + ok &= sevalue_to_native(args[2], &(cobj->left), nullptr); + } + if (argc > 3 && !args[3].isUndefined()) { + ok &= sevalue_to_native(args[3], &(cobj->right), nullptr); + } + if (argc > 4 && !args[4].isUndefined()) { + ok &= sevalue_to_native(args[4], &(cobj->top), nullptr); + } + if (argc > 5 && !args[5].isUndefined()) { + ok &= sevalue_to_native(args[5], &(cobj->bottom), nullptr); + } + + if(!ok) { + delete ptr; + SE_REPORT_ERROR("Argument convertion error"); + return false; + } + s.thisObject()->setPrivateObject(ptr); + return true; +} +SE_BIND_CTOR(js_assets_ITextureCubeSerializeMipmapData_constructor, __jsb_cc_ITextureCubeSerializeMipmapData_class, js_cc_ITextureCubeSerializeMipmapData_finalize) + +static bool js_cc_ITextureCubeSerializeMipmapData_finalize(se::State& s) // NOLINT(readability-identifier-naming) +{ + return true; +} +SE_BIND_FINALIZE_FUNC(js_cc_ITextureCubeSerializeMipmapData_finalize) + +bool js_register_assets_ITextureCubeSerializeMipmapData(se::Object* obj) // NOLINT(readability-identifier-naming) +{ + auto* cls = se::Class::create("ITextureCubeSerializeMipmapData", obj, nullptr, _SE(js_assets_ITextureCubeSerializeMipmapData_constructor)); + + cls->defineProperty("front", _SE(js_assets_ITextureCubeSerializeMipmapData_get_front), _SE(js_assets_ITextureCubeSerializeMipmapData_set_front)); + cls->defineProperty("back", _SE(js_assets_ITextureCubeSerializeMipmapData_get_back), _SE(js_assets_ITextureCubeSerializeMipmapData_set_back)); + cls->defineProperty("left", _SE(js_assets_ITextureCubeSerializeMipmapData_get_left), _SE(js_assets_ITextureCubeSerializeMipmapData_set_left)); + cls->defineProperty("right", _SE(js_assets_ITextureCubeSerializeMipmapData_get_right), _SE(js_assets_ITextureCubeSerializeMipmapData_set_right)); + cls->defineProperty("top", _SE(js_assets_ITextureCubeSerializeMipmapData_get_top), _SE(js_assets_ITextureCubeSerializeMipmapData_set_top)); + cls->defineProperty("bottom", _SE(js_assets_ITextureCubeSerializeMipmapData_get_bottom), _SE(js_assets_ITextureCubeSerializeMipmapData_set_bottom)); + cls->defineFinalizeFunction(_SE(js_cc_ITextureCubeSerializeMipmapData_finalize)); + cls->install(); + JSBClassType::registerClass(cls); + + __jsb_cc_ITextureCubeSerializeMipmapData_proto = cls->getProto(); + __jsb_cc_ITextureCubeSerializeMipmapData_class = cls; + + + se::ScriptEngine::getInstance()->clearException(); + return true; +} +se::Object* __jsb_cc_ITextureCubeSerializeData_proto = nullptr; // NOLINT +se::Class* __jsb_cc_ITextureCubeSerializeData_class = nullptr; // NOLINT + +static bool js_assets_ITextureCubeSerializeData_get_base(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_assets_ITextureCubeSerializeData_get_base : Invalid Native Object"); + + CC_UNUSED bool ok = true; + se::Value jsret; + ok &= nativevalue_to_se(cobj->base, jsret, s.thisObject() /*ctx*/); + s.rval() = jsret; + SE_HOLD_RETURN_VALUE(cobj->base, s.thisObject(), s.rval()); + return true; +} +SE_BIND_PROP_GET(js_assets_ITextureCubeSerializeData_get_base) + +static bool js_assets_ITextureCubeSerializeData_set_base(se::State& s) // NOLINT(readability-identifier-naming) +{ + const auto& args = s.args(); + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_assets_ITextureCubeSerializeData_set_base : Invalid Native Object"); + + CC_UNUSED bool ok = true; + ok &= sevalue_to_native(args[0], &cobj->base, s.thisObject()); + SE_PRECONDITION2(ok, false, "js_assets_ITextureCubeSerializeData_set_base : Error processing new value"); + return true; +} +SE_BIND_PROP_SET(js_assets_ITextureCubeSerializeData_set_base) + +static bool js_assets_ITextureCubeSerializeData_get_rgbe(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_assets_ITextureCubeSerializeData_get_rgbe : Invalid Native Object"); + + CC_UNUSED bool ok = true; + se::Value jsret; + ok &= nativevalue_to_se(cobj->rgbe, jsret, s.thisObject() /*ctx*/); + s.rval() = jsret; + SE_HOLD_RETURN_VALUE(cobj->rgbe, s.thisObject(), s.rval()); + return true; +} +SE_BIND_PROP_GET(js_assets_ITextureCubeSerializeData_get_rgbe) + +static bool js_assets_ITextureCubeSerializeData_set_rgbe(se::State& s) // NOLINT(readability-identifier-naming) +{ + const auto& args = s.args(); + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_assets_ITextureCubeSerializeData_set_rgbe : Invalid Native Object"); + + CC_UNUSED bool ok = true; + ok &= sevalue_to_native(args[0], &cobj->rgbe, s.thisObject()); + SE_PRECONDITION2(ok, false, "js_assets_ITextureCubeSerializeData_set_rgbe : Error processing new value"); + return true; +} +SE_BIND_PROP_SET(js_assets_ITextureCubeSerializeData_set_rgbe) + +static bool js_assets_ITextureCubeSerializeData_get_mipmaps(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_assets_ITextureCubeSerializeData_get_mipmaps : Invalid Native Object"); + + CC_UNUSED bool ok = true; + se::Value jsret; + ok &= nativevalue_to_se(cobj->mipmaps, jsret, s.thisObject() /*ctx*/); + s.rval() = jsret; + SE_HOLD_RETURN_VALUE(cobj->mipmaps, s.thisObject(), s.rval()); + return true; +} +SE_BIND_PROP_GET(js_assets_ITextureCubeSerializeData_get_mipmaps) + +static bool js_assets_ITextureCubeSerializeData_set_mipmaps(se::State& s) // NOLINT(readability-identifier-naming) +{ + const auto& args = s.args(); + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_assets_ITextureCubeSerializeData_set_mipmaps : Invalid Native Object"); + + CC_UNUSED bool ok = true; + ok &= sevalue_to_native(args[0], &cobj->mipmaps, s.thisObject()); + SE_PRECONDITION2(ok, false, "js_assets_ITextureCubeSerializeData_set_mipmaps : Error processing new value"); + return true; +} +SE_BIND_PROP_SET(js_assets_ITextureCubeSerializeData_set_mipmaps) + + +template<> +bool sevalue_to_native(const se::Value &from, cc::ITextureCubeSerializeData * to, se::Object *ctx) +{ + assert(from.isObject()); + se::Object *json = from.toObject(); + auto* data = reinterpret_cast(json->getPrivateData()); + if (data) { + *to = *data; + return true; + } + se::Value field; + bool ok = true; + json->getProperty("base", &field, true); + if(!field.isNullOrUndefined()) { + ok &= sevalue_to_native(field, &(to->base), ctx); + } + json->getProperty("rgbe", &field, true); + if(!field.isNullOrUndefined()) { + ok &= sevalue_to_native(field, &(to->rgbe), ctx); + } + json->getProperty("mipmaps", &field, true); + if(!field.isNullOrUndefined()) { + ok &= sevalue_to_native(field, &(to->mipmaps), ctx); + } + return ok; +} + +SE_DECLARE_FINALIZE_FUNC(js_cc_ITextureCubeSerializeData_finalize) + +static bool js_assets_ITextureCubeSerializeData_constructor(se::State& s) // NOLINT(readability-identifier-naming) +{ + CC_UNUSED bool ok = true; + const auto& args = s.args(); + size_t argc = args.size(); + + if(argc == 0) + { + auto *ptr = JSB_MAKE_PRIVATE_OBJECT(cc::ITextureCubeSerializeData); + s.thisObject()->setPrivateObject(ptr); + return true; + } + + if(argc == 1 && args[0].isObject()) + { + se::Object *json = args[0].toObject(); + se::Value field; + auto *ptr = JSB_MAKE_PRIVATE_OBJECT(cc::ITextureCubeSerializeData); + auto cobj = ptr->get(); + ok &= sevalue_to_native(args[0], cobj, s.thisObject()); + if(!ok) { + delete ptr; + SE_REPORT_ERROR("argument convertion error"); + return false; + } + s.thisObject()->setPrivateObject(ptr); + return true; + } + auto *ptr = JSB_MAKE_PRIVATE_OBJECT(cc::ITextureCubeSerializeData); + auto cobj = ptr->get(); + if (argc > 0 && !args[0].isUndefined()) { + ok &= sevalue_to_native(args[0], &(cobj->base), nullptr); + } + if (argc > 1 && !args[1].isUndefined()) { + ok &= sevalue_to_native(args[1], &(cobj->rgbe), nullptr); + } + if (argc > 2 && !args[2].isUndefined()) { + ok &= sevalue_to_native(args[2], &(cobj->mipmaps), nullptr); + } + + if(!ok) { + delete ptr; + SE_REPORT_ERROR("Argument convertion error"); + return false; + } + s.thisObject()->setPrivateObject(ptr); + return true; +} +SE_BIND_CTOR(js_assets_ITextureCubeSerializeData_constructor, __jsb_cc_ITextureCubeSerializeData_class, js_cc_ITextureCubeSerializeData_finalize) + +static bool js_cc_ITextureCubeSerializeData_finalize(se::State& s) // NOLINT(readability-identifier-naming) +{ + return true; +} +SE_BIND_FINALIZE_FUNC(js_cc_ITextureCubeSerializeData_finalize) + +bool js_register_assets_ITextureCubeSerializeData(se::Object* obj) // NOLINT(readability-identifier-naming) +{ + auto* cls = se::Class::create("ITextureCubeSerializeData", obj, nullptr, _SE(js_assets_ITextureCubeSerializeData_constructor)); + + cls->defineProperty("base", _SE(js_assets_ITextureCubeSerializeData_get_base), _SE(js_assets_ITextureCubeSerializeData_set_base)); + cls->defineProperty("rgbe", _SE(js_assets_ITextureCubeSerializeData_get_rgbe), _SE(js_assets_ITextureCubeSerializeData_set_rgbe)); + cls->defineProperty("mipmaps", _SE(js_assets_ITextureCubeSerializeData_get_mipmaps), _SE(js_assets_ITextureCubeSerializeData_set_mipmaps)); + cls->defineFinalizeFunction(_SE(js_cc_ITextureCubeSerializeData_finalize)); + cls->install(); + JSBClassType::registerClass(cls); + + __jsb_cc_ITextureCubeSerializeData_proto = cls->getProto(); + __jsb_cc_ITextureCubeSerializeData_class = cls; + + + se::ScriptEngine::getInstance()->clearException(); + return true; +} +se::Object* __jsb_cc_TextureCube_proto = nullptr; // NOLINT +se::Class* __jsb_cc_TextureCube_class = nullptr; // NOLINT + +static bool js_assets_TextureCube_getGfxTextureCreateInfo(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_assets_TextureCube_getGfxTextureCreateInfo : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 4) { + HolderType arg0 = {}; + HolderType arg1 = {}; + HolderType arg2 = {}; + HolderType arg3 = {}; + ok &= sevalue_to_native(args[0], &arg0, s.thisObject()); + ok &= sevalue_to_native(args[1], &arg1, s.thisObject()); + ok &= sevalue_to_native(args[2], &arg2, s.thisObject()); + ok &= sevalue_to_native(args[3], &arg3, s.thisObject()); + SE_PRECONDITION2(ok, false, "js_assets_TextureCube_getGfxTextureCreateInfo : Error processing arguments"); + cc::gfx::TextureInfo result = cobj->getGfxTextureCreateInfo(arg0.value(), arg1.value(), arg2.value(), arg3.value()); + ok &= nativevalue_to_se(result, s.rval(), nullptr /*ctx*/); + SE_PRECONDITION2(ok, false, "js_assets_TextureCube_getGfxTextureCreateInfo : Error processing arguments"); + SE_HOLD_RETURN_VALUE(result, s.thisObject(), s.rval()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 4); + return false; +} +SE_BIND_FUNC(js_assets_TextureCube_getGfxTextureCreateInfo) + +static bool js_assets_TextureCube_getImage(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_assets_TextureCube_getImage : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 0) { + const cc::ITextureCubeMipmap* result = cobj->getImage(); + ok &= nativevalue_to_se(result, s.rval(), nullptr /*ctx*/); + SE_PRECONDITION2(ok, false, "js_assets_TextureCube_getImage : Error processing arguments"); + SE_HOLD_RETURN_VALUE(result, s.thisObject(), s.rval()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 0); + return false; +} +SE_BIND_FUNC(js_assets_TextureCube_getImage) + +static bool js_assets_TextureCube_getMipmaps(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_assets_TextureCube_getMipmaps : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 0) { + const std::vector& result = cobj->getMipmaps(); + ok &= nativevalue_to_se(result, s.rval(), nullptr /*ctx*/); + SE_PRECONDITION2(ok, false, "js_assets_TextureCube_getMipmaps : Error processing arguments"); + SE_HOLD_RETURN_VALUE(result, s.thisObject(), s.rval()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 0); + return false; +} +SE_BIND_FUNC(js_assets_TextureCube_getMipmaps) + +static bool js_assets_TextureCube_initialize(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_assets_TextureCube_initialize : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + if (argc == 0) { + cobj->initialize(); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 0); + return false; +} +SE_BIND_FUNC(js_assets_TextureCube_initialize) + +static bool js_assets_TextureCube_releaseTexture(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_assets_TextureCube_releaseTexture : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + if (argc == 0) { + cobj->releaseTexture(); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 0); + return false; +} +SE_BIND_FUNC(js_assets_TextureCube_releaseTexture) + +static bool js_assets_TextureCube_reset(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_assets_TextureCube_reset : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 1) { + HolderType arg0 = {}; + ok &= sevalue_to_native(args[0], &arg0, s.thisObject()); + SE_PRECONDITION2(ok, false, "js_assets_TextureCube_reset : Error processing arguments"); + cobj->reset(arg0.value()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 1); + return false; +} +SE_BIND_FUNC(js_assets_TextureCube_reset) + +static bool js_assets_TextureCube_setImage(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_assets_TextureCube_setImage : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 1) { + HolderType arg0 = {}; + ok &= sevalue_to_native(args[0], &arg0, s.thisObject()); + SE_PRECONDITION2(ok, false, "js_assets_TextureCube_setImage : Error processing arguments"); + cobj->setImage(arg0.value()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 1); + return false; +} +SE_BIND_FUNC(js_assets_TextureCube_setImage) + +static bool js_assets_TextureCube_setMipmaps(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_assets_TextureCube_setMipmaps : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 1) { + HolderType, true> arg0 = {}; + ok &= sevalue_to_native(args[0], &arg0, s.thisObject()); + SE_PRECONDITION2(ok, false, "js_assets_TextureCube_setMipmaps : Error processing arguments"); + cobj->setMipmaps(arg0.value()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 1); + return false; +} +SE_BIND_FUNC(js_assets_TextureCube_setMipmaps) + +static bool js_assets_TextureCube_fromTexture2DArray_static(se::State& s) // NOLINT(readability-identifier-naming) +{ + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 1) { + HolderType, true> arg0 = {}; + ok &= sevalue_to_native(args[0], &arg0, nullptr); + SE_PRECONDITION2(ok, false, "js_assets_TextureCube_fromTexture2DArray_static : Error processing arguments"); + cc::TextureCube* result = cc::TextureCube::fromTexture2DArray(arg0.value()); + ok &= nativevalue_to_se(result, s.rval(), nullptr /*ctx*/); + SE_PRECONDITION2(ok, false, "js_assets_TextureCube_fromTexture2DArray_static : Error processing arguments"); + SE_HOLD_RETURN_VALUE(result, s.thisObject(), s.rval()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 1); + return false; +} +SE_BIND_FUNC(js_assets_TextureCube_fromTexture2DArray_static) + +SE_DECLARE_FINALIZE_FUNC(js_cc_TextureCube_finalize) + +static bool js_assets_TextureCube_constructor(se::State& s) // NOLINT(readability-identifier-naming) constructor.c +{ + auto *ptr = JSB_MAKE_PRIVATE_OBJECT(cc::TextureCube); + s.thisObject()->setPrivateObject(ptr); + return true; +} +SE_BIND_CTOR(js_assets_TextureCube_constructor, __jsb_cc_TextureCube_class, js_cc_TextureCube_finalize) + +static bool js_cc_TextureCube_finalize(se::State& s) // NOLINT(readability-identifier-naming) +{ + return true; +} +SE_BIND_FINALIZE_FUNC(js_cc_TextureCube_finalize) + +bool js_register_assets_TextureCube(se::Object* obj) // NOLINT(readability-identifier-naming) +{ + auto* cls = se::Class::create("TextureCube", obj, __jsb_cc_SimpleTexture_proto, _SE(js_assets_TextureCube_constructor)); + + cls->defineFunction("getGfxTextureCreateInfo", _SE(js_assets_TextureCube_getGfxTextureCreateInfo)); + cls->defineFunction("getImage", _SE(js_assets_TextureCube_getImage)); + cls->defineFunction("getMipmaps", _SE(js_assets_TextureCube_getMipmaps)); + cls->defineFunction("initialize", _SE(js_assets_TextureCube_initialize)); + cls->defineFunction("releaseTexture", _SE(js_assets_TextureCube_releaseTexture)); + cls->defineFunction("reset", _SE(js_assets_TextureCube_reset)); + cls->defineFunction("setImage", _SE(js_assets_TextureCube_setImage)); + cls->defineFunction("setMipmaps", _SE(js_assets_TextureCube_setMipmaps)); + cls->defineStaticFunction("fromTexture2DArray", _SE(js_assets_TextureCube_fromTexture2DArray_static)); + cls->defineFinalizeFunction(_SE(js_cc_TextureCube_finalize)); + cls->install(); + JSBClassType::registerClass(cls); + + __jsb_cc_TextureCube_proto = cls->getProto(); + __jsb_cc_TextureCube_class = cls; + + + se::ScriptEngine::getInstance()->clearException(); + return true; +} +se::Object* __jsb_cc_MorphRendering_proto = nullptr; // NOLINT +se::Class* __jsb_cc_MorphRendering_class = nullptr; // NOLINT + +static bool js_assets_MorphRendering_createInstance(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_assets_MorphRendering_createInstance : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 0) { + cc::MorphRenderingInstance* result = cobj->createInstance(); + ok &= nativevalue_to_se(result, s.rval(), nullptr /*ctx*/); + SE_PRECONDITION2(ok, false, "js_assets_MorphRendering_createInstance : Error processing arguments"); + SE_HOLD_RETURN_VALUE(result, s.thisObject(), s.rval()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 0); + return false; +} +SE_BIND_FUNC(js_assets_MorphRendering_createInstance) +static bool js_cc_MorphRendering_finalize(se::State& s) // NOLINT(readability-identifier-naming) +{ + return true; +} +SE_BIND_FINALIZE_FUNC(js_cc_MorphRendering_finalize) + +bool js_register_assets_MorphRendering(se::Object* obj) // NOLINT(readability-identifier-naming) +{ + auto* cls = se::Class::create("MorphRendering", obj, nullptr, nullptr); + + cls->defineFunction("createInstance", _SE(js_assets_MorphRendering_createInstance)); + cls->defineFinalizeFunction(_SE(js_cc_MorphRendering_finalize)); + cls->install(); + JSBClassType::registerClass(cls); + + __jsb_cc_MorphRendering_proto = cls->getProto(); + __jsb_cc_MorphRendering_class = cls; + + + se::ScriptEngine::getInstance()->clearException(); + return true; +} +se::Object* __jsb_cc_MorphRenderingInstance_proto = nullptr; // NOLINT +se::Class* __jsb_cc_MorphRenderingInstance_class = nullptr; // NOLINT + +static bool js_assets_MorphRenderingInstance_adaptPipelineState(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_assets_MorphRenderingInstance_adaptPipelineState : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 2) { + HolderType arg0 = {}; + HolderType arg1 = {}; + ok &= sevalue_to_native(args[0], &arg0, s.thisObject()); + ok &= sevalue_to_native(args[1], &arg1, s.thisObject()); + SE_PRECONDITION2(ok, false, "js_assets_MorphRenderingInstance_adaptPipelineState : Error processing arguments"); + cobj->adaptPipelineState(arg0.value(), arg1.value()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 2); + return false; +} +SE_BIND_FUNC(js_assets_MorphRenderingInstance_adaptPipelineState) + +static bool js_assets_MorphRenderingInstance_destroy(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_assets_MorphRenderingInstance_destroy : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + if (argc == 0) { + cobj->destroy(); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 0); + return false; +} +SE_BIND_FUNC(js_assets_MorphRenderingInstance_destroy) + +static bool js_assets_MorphRenderingInstance_requiredPatches(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_assets_MorphRenderingInstance_requiredPatches : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 1) { + HolderType arg0 = {}; + ok &= sevalue_to_native(args[0], &arg0, s.thisObject()); + SE_PRECONDITION2(ok, false, "js_assets_MorphRenderingInstance_requiredPatches : Error processing arguments"); + std::vector result = cobj->requiredPatches(arg0.value()); + ok &= nativevalue_to_se(result, s.rval(), nullptr /*ctx*/); + SE_PRECONDITION2(ok, false, "js_assets_MorphRenderingInstance_requiredPatches : Error processing arguments"); + SE_HOLD_RETURN_VALUE(result, s.thisObject(), s.rval()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 1); + return false; +} +SE_BIND_FUNC(js_assets_MorphRenderingInstance_requiredPatches) + +static bool js_assets_MorphRenderingInstance_setWeights(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_assets_MorphRenderingInstance_setWeights : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 2) { + HolderType arg0 = {}; + HolderType, true> arg1 = {}; + ok &= sevalue_to_native(args[0], &arg0, s.thisObject()); + ok &= sevalue_to_native(args[1], &arg1, s.thisObject()); + SE_PRECONDITION2(ok, false, "js_assets_MorphRenderingInstance_setWeights : Error processing arguments"); + cobj->setWeights(arg0.value(), arg1.value()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 2); + return false; +} +SE_BIND_FUNC(js_assets_MorphRenderingInstance_setWeights) +static bool js_cc_MorphRenderingInstance_finalize(se::State& s) // NOLINT(readability-identifier-naming) +{ + return true; +} +SE_BIND_FINALIZE_FUNC(js_cc_MorphRenderingInstance_finalize) + +bool js_register_assets_MorphRenderingInstance(se::Object* obj) // NOLINT(readability-identifier-naming) +{ + auto* cls = se::Class::create("MorphRenderingInstance", obj, nullptr, nullptr); + + cls->defineFunction("adaptPipelineState", _SE(js_assets_MorphRenderingInstance_adaptPipelineState)); + cls->defineFunction("destroy", _SE(js_assets_MorphRenderingInstance_destroy)); + cls->defineFunction("requiredPatches", _SE(js_assets_MorphRenderingInstance_requiredPatches)); + cls->defineFunction("setWeights", _SE(js_assets_MorphRenderingInstance_setWeights)); + cls->defineFinalizeFunction(_SE(js_cc_MorphRenderingInstance_finalize)); + cls->install(); + JSBClassType::registerClass(cls); + + __jsb_cc_MorphRenderingInstance_proto = cls->getProto(); + __jsb_cc_MorphRenderingInstance_class = cls; + + + se::ScriptEngine::getInstance()->clearException(); + return true; +} +se::Object* __jsb_cc_StdMorphRendering_proto = nullptr; // NOLINT +se::Class* __jsb_cc_StdMorphRendering_class = nullptr; // NOLINT + +SE_DECLARE_FINALIZE_FUNC(js_cc_StdMorphRendering_finalize) + +static bool js_assets_StdMorphRendering_constructor(se::State& s) // NOLINT(readability-identifier-naming) constructor.c +{ + CC_UNUSED bool ok = true; + const auto& args = s.args(); + cc::Mesh* arg0 = nullptr; + cc::gfx::Device* arg1 = nullptr; + ok &= sevalue_to_native(args[0], &arg0, s.thisObject()); + ok &= sevalue_to_native(args[1], &arg1, s.thisObject()); + SE_PRECONDITION2(ok, false, "js_assets_StdMorphRendering_constructor : Error processing arguments"); + auto *ptr = JSB_MAKE_PRIVATE_OBJECT(cc::StdMorphRendering, arg0, arg1); + s.thisObject()->setPrivateObject(ptr); + return true; +} +SE_BIND_CTOR(js_assets_StdMorphRendering_constructor, __jsb_cc_StdMorphRendering_class, js_cc_StdMorphRendering_finalize) + +static bool js_cc_StdMorphRendering_finalize(se::State& s) // NOLINT(readability-identifier-naming) +{ + return true; +} +SE_BIND_FINALIZE_FUNC(js_cc_StdMorphRendering_finalize) + +bool js_register_assets_StdMorphRendering(se::Object* obj) // NOLINT(readability-identifier-naming) +{ + auto* cls = se::Class::create("StdMorphRendering", obj, __jsb_cc_MorphRendering_proto, _SE(js_assets_StdMorphRendering_constructor)); + + cls->defineFinalizeFunction(_SE(js_cc_StdMorphRendering_finalize)); + cls->install(); + JSBClassType::registerClass(cls); + + __jsb_cc_StdMorphRendering_proto = cls->getProto(); + __jsb_cc_StdMorphRendering_class = cls; + + + se::ScriptEngine::getInstance()->clearException(); + return true; +} +se::Object* __jsb_cc_Mesh_IVertexBundle_proto = nullptr; // NOLINT +se::Class* __jsb_cc_Mesh_IVertexBundle_class = nullptr; // NOLINT + +static bool js_assets_IVertexBundle_get__padding(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_assets_IVertexBundle_get__padding : Invalid Native Object"); + + CC_UNUSED bool ok = true; + se::Value jsret; + ok &= nativevalue_to_se(cobj->_padding, jsret, s.thisObject() /*ctx*/); + s.rval() = jsret; + SE_HOLD_RETURN_VALUE(cobj->_padding, s.thisObject(), s.rval()); + return true; +} +SE_BIND_PROP_GET(js_assets_IVertexBundle_get__padding) + +static bool js_assets_IVertexBundle_set__padding(se::State& s) // NOLINT(readability-identifier-naming) +{ + const auto& args = s.args(); + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_assets_IVertexBundle_set__padding : Invalid Native Object"); + + CC_UNUSED bool ok = true; + ok &= sevalue_to_native(args[0], &cobj->_padding, s.thisObject()); + SE_PRECONDITION2(ok, false, "js_assets_IVertexBundle_set__padding : Error processing new value"); + return true; +} +SE_BIND_PROP_SET(js_assets_IVertexBundle_set__padding) + +static bool js_assets_IVertexBundle_get_view(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_assets_IVertexBundle_get_view : Invalid Native Object"); + + CC_UNUSED bool ok = true; + se::Value jsret; + ok &= nativevalue_to_se(cobj->view, jsret, s.thisObject() /*ctx*/); + s.rval() = jsret; + SE_HOLD_RETURN_VALUE(cobj->view, s.thisObject(), s.rval()); + return true; +} +SE_BIND_PROP_GET(js_assets_IVertexBundle_get_view) + +static bool js_assets_IVertexBundle_set_view(se::State& s) // NOLINT(readability-identifier-naming) +{ + const auto& args = s.args(); + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_assets_IVertexBundle_set_view : Invalid Native Object"); + + CC_UNUSED bool ok = true; + ok &= sevalue_to_native(args[0], &cobj->view, s.thisObject()); + SE_PRECONDITION2(ok, false, "js_assets_IVertexBundle_set_view : Error processing new value"); + return true; +} +SE_BIND_PROP_SET(js_assets_IVertexBundle_set_view) + +static bool js_assets_IVertexBundle_get_attributes(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_assets_IVertexBundle_get_attributes : Invalid Native Object"); + + CC_UNUSED bool ok = true; + se::Value jsret; + ok &= nativevalue_to_se(cobj->attributes, jsret, s.thisObject() /*ctx*/); + s.rval() = jsret; + SE_HOLD_RETURN_VALUE(cobj->attributes, s.thisObject(), s.rval()); + return true; +} +SE_BIND_PROP_GET(js_assets_IVertexBundle_get_attributes) + +static bool js_assets_IVertexBundle_set_attributes(se::State& s) // NOLINT(readability-identifier-naming) +{ + const auto& args = s.args(); + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_assets_IVertexBundle_set_attributes : Invalid Native Object"); + + CC_UNUSED bool ok = true; + ok &= sevalue_to_native(args[0], &cobj->attributes, s.thisObject()); + SE_PRECONDITION2(ok, false, "js_assets_IVertexBundle_set_attributes : Error processing new value"); + return true; +} +SE_BIND_PROP_SET(js_assets_IVertexBundle_set_attributes) + + +template<> +bool sevalue_to_native(const se::Value &from, cc::Mesh::IVertexBundle * to, se::Object *ctx) +{ + assert(from.isObject()); + se::Object *json = from.toObject(); + auto* data = reinterpret_cast(json->getPrivateData()); + if (data) { + *to = *data; + return true; + } + se::Value field; + bool ok = true; + json->getProperty("_padding", &field, true); + if(!field.isNullOrUndefined()) { + ok &= sevalue_to_native(field, &(to->_padding), ctx); + } + json->getProperty("view", &field, true); + if(!field.isNullOrUndefined()) { + ok &= sevalue_to_native(field, &(to->view), ctx); + } + json->getProperty("attributes", &field, true); + if(!field.isNullOrUndefined()) { + ok &= sevalue_to_native(field, &(to->attributes), ctx); + } + return ok; +} + +SE_DECLARE_FINALIZE_FUNC(js_cc_Mesh_IVertexBundle_finalize) + +static bool js_assets_IVertexBundle_constructor(se::State& s) // NOLINT(readability-identifier-naming) +{ + CC_UNUSED bool ok = true; + const auto& args = s.args(); + size_t argc = args.size(); + + if(argc == 0) + { + auto *ptr = JSB_MAKE_PRIVATE_OBJECT(cc::Mesh::IVertexBundle); + s.thisObject()->setPrivateObject(ptr); + return true; + } + + if(argc == 1 && args[0].isObject()) + { + se::Object *json = args[0].toObject(); + se::Value field; + auto *ptr = JSB_MAKE_PRIVATE_OBJECT(cc::Mesh::IVertexBundle); + auto cobj = ptr->get(); + ok &= sevalue_to_native(args[0], cobj, s.thisObject()); + if(!ok) { + delete ptr; + SE_REPORT_ERROR("argument convertion error"); + return false; + } + s.thisObject()->setPrivateObject(ptr); + return true; + } + auto *ptr = JSB_MAKE_PRIVATE_OBJECT(cc::Mesh::IVertexBundle); + auto cobj = ptr->get(); + if (argc > 0 && !args[0].isUndefined()) { + ok &= sevalue_to_native(args[0], &(cobj->_padding), nullptr); + } + if (argc > 1 && !args[1].isUndefined()) { + ok &= sevalue_to_native(args[1], &(cobj->view), nullptr); + } + if (argc > 2 && !args[2].isUndefined()) { + ok &= sevalue_to_native(args[2], &(cobj->attributes), nullptr); + } + + if(!ok) { + delete ptr; + SE_REPORT_ERROR("Argument convertion error"); + return false; + } + s.thisObject()->setPrivateObject(ptr); + return true; +} +SE_BIND_CTOR(js_assets_IVertexBundle_constructor, __jsb_cc_Mesh_IVertexBundle_class, js_cc_Mesh_IVertexBundle_finalize) + +static bool js_cc_Mesh_IVertexBundle_finalize(se::State& s) // NOLINT(readability-identifier-naming) +{ + return true; +} +SE_BIND_FINALIZE_FUNC(js_cc_Mesh_IVertexBundle_finalize) + +bool js_register_assets_Mesh_IVertexBundle(se::Object* obj) // NOLINT(readability-identifier-naming) +{ + auto* cls = se::Class::create({"Mesh","IVertexBundle"}, obj, nullptr, _SE(js_assets_IVertexBundle_constructor)); + + cls->defineProperty("_padding", _SE(js_assets_IVertexBundle_get__padding), _SE(js_assets_IVertexBundle_set__padding)); + cls->defineProperty("view", _SE(js_assets_IVertexBundle_get_view), _SE(js_assets_IVertexBundle_set_view)); + cls->defineProperty("attributes", _SE(js_assets_IVertexBundle_get_attributes), _SE(js_assets_IVertexBundle_set_attributes)); + cls->defineFinalizeFunction(_SE(js_cc_Mesh_IVertexBundle_finalize)); + cls->install(); + JSBClassType::registerClass(cls); + + __jsb_cc_Mesh_IVertexBundle_proto = cls->getProto(); + __jsb_cc_Mesh_IVertexBundle_class = cls; + + + se::ScriptEngine::getInstance()->clearException(); + return true; +} +se::Object* __jsb_cc_Mesh_ISubMesh_proto = nullptr; // NOLINT +se::Class* __jsb_cc_Mesh_ISubMesh_class = nullptr; // NOLINT + +static bool js_assets_ISubMesh_get_vertexBundelIndices(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_assets_ISubMesh_get_vertexBundelIndices : Invalid Native Object"); + + CC_UNUSED bool ok = true; + se::Value jsret; + ok &= nativevalue_to_se(cobj->vertexBundelIndices, jsret, s.thisObject() /*ctx*/); + s.rval() = jsret; + SE_HOLD_RETURN_VALUE(cobj->vertexBundelIndices, s.thisObject(), s.rval()); + return true; +} +SE_BIND_PROP_GET(js_assets_ISubMesh_get_vertexBundelIndices) + +static bool js_assets_ISubMesh_set_vertexBundelIndices(se::State& s) // NOLINT(readability-identifier-naming) +{ + const auto& args = s.args(); + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_assets_ISubMesh_set_vertexBundelIndices : Invalid Native Object"); + + CC_UNUSED bool ok = true; + ok &= sevalue_to_native(args[0], &cobj->vertexBundelIndices, s.thisObject()); + SE_PRECONDITION2(ok, false, "js_assets_ISubMesh_set_vertexBundelIndices : Error processing new value"); + return true; +} +SE_BIND_PROP_SET(js_assets_ISubMesh_set_vertexBundelIndices) + +static bool js_assets_ISubMesh_get_primitiveMode(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_assets_ISubMesh_get_primitiveMode : Invalid Native Object"); + + CC_UNUSED bool ok = true; + se::Value jsret; + ok &= nativevalue_to_se(cobj->primitiveMode, jsret, s.thisObject() /*ctx*/); + s.rval() = jsret; + SE_HOLD_RETURN_VALUE(cobj->primitiveMode, s.thisObject(), s.rval()); + return true; +} +SE_BIND_PROP_GET(js_assets_ISubMesh_get_primitiveMode) + +static bool js_assets_ISubMesh_set_primitiveMode(se::State& s) // NOLINT(readability-identifier-naming) +{ + const auto& args = s.args(); + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_assets_ISubMesh_set_primitiveMode : Invalid Native Object"); + + CC_UNUSED bool ok = true; + ok &= sevalue_to_native(args[0], &cobj->primitiveMode, s.thisObject()); + SE_PRECONDITION2(ok, false, "js_assets_ISubMesh_set_primitiveMode : Error processing new value"); + return true; +} +SE_BIND_PROP_SET(js_assets_ISubMesh_set_primitiveMode) + +static bool js_assets_ISubMesh_get_indexView(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_assets_ISubMesh_get_indexView : Invalid Native Object"); + + CC_UNUSED bool ok = true; + se::Value jsret; + ok &= nativevalue_to_se(cobj->indexView, jsret, s.thisObject() /*ctx*/); + s.rval() = jsret; + SE_HOLD_RETURN_VALUE(cobj->indexView, s.thisObject(), s.rval()); + return true; +} +SE_BIND_PROP_GET(js_assets_ISubMesh_get_indexView) + +static bool js_assets_ISubMesh_set_indexView(se::State& s) // NOLINT(readability-identifier-naming) +{ + const auto& args = s.args(); + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_assets_ISubMesh_set_indexView : Invalid Native Object"); + + CC_UNUSED bool ok = true; + ok &= sevalue_to_native(args[0], &cobj->indexView, s.thisObject()); + SE_PRECONDITION2(ok, false, "js_assets_ISubMesh_set_indexView : Error processing new value"); + return true; +} +SE_BIND_PROP_SET(js_assets_ISubMesh_set_indexView) + +static bool js_assets_ISubMesh_get_jointMapIndex(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_assets_ISubMesh_get_jointMapIndex : Invalid Native Object"); + + CC_UNUSED bool ok = true; + se::Value jsret; + ok &= nativevalue_to_se(cobj->jointMapIndex, jsret, s.thisObject() /*ctx*/); + s.rval() = jsret; + SE_HOLD_RETURN_VALUE(cobj->jointMapIndex, s.thisObject(), s.rval()); + return true; +} +SE_BIND_PROP_GET(js_assets_ISubMesh_get_jointMapIndex) + +static bool js_assets_ISubMesh_set_jointMapIndex(se::State& s) // NOLINT(readability-identifier-naming) +{ + const auto& args = s.args(); + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_assets_ISubMesh_set_jointMapIndex : Invalid Native Object"); + + CC_UNUSED bool ok = true; + ok &= sevalue_to_native(args[0], &cobj->jointMapIndex, s.thisObject()); + SE_PRECONDITION2(ok, false, "js_assets_ISubMesh_set_jointMapIndex : Error processing new value"); + return true; +} +SE_BIND_PROP_SET(js_assets_ISubMesh_set_jointMapIndex) + + +template<> +bool sevalue_to_native(const se::Value &from, cc::Mesh::ISubMesh * to, se::Object *ctx) +{ + assert(from.isObject()); + se::Object *json = from.toObject(); + auto* data = reinterpret_cast(json->getPrivateData()); + if (data) { + *to = *data; + return true; + } + se::Value field; + bool ok = true; + json->getProperty("vertexBundelIndices", &field, true); + if(!field.isNullOrUndefined()) { + ok &= sevalue_to_native(field, &(to->vertexBundelIndices), ctx); + } + json->getProperty("primitiveMode", &field, true); + if(!field.isNullOrUndefined()) { + ok &= sevalue_to_native(field, &(to->primitiveMode), ctx); + } + json->getProperty("indexView", &field, true); + if(!field.isNullOrUndefined()) { + ok &= sevalue_to_native(field, &(to->indexView), ctx); + } + json->getProperty("jointMapIndex", &field, true); + if(!field.isNullOrUndefined()) { + ok &= sevalue_to_native(field, &(to->jointMapIndex), ctx); + } + return ok; +} + +SE_DECLARE_FINALIZE_FUNC(js_cc_Mesh_ISubMesh_finalize) + +static bool js_assets_ISubMesh_constructor(se::State& s) // NOLINT(readability-identifier-naming) +{ + CC_UNUSED bool ok = true; + const auto& args = s.args(); + size_t argc = args.size(); + + if(argc == 0) + { + auto *ptr = JSB_MAKE_PRIVATE_OBJECT(cc::Mesh::ISubMesh); + s.thisObject()->setPrivateObject(ptr); + return true; + } + + if(argc == 1 && args[0].isObject()) + { + se::Object *json = args[0].toObject(); + se::Value field; + auto *ptr = JSB_MAKE_PRIVATE_OBJECT(cc::Mesh::ISubMesh); + auto cobj = ptr->get(); + ok &= sevalue_to_native(args[0], cobj, s.thisObject()); + if(!ok) { + delete ptr; + SE_REPORT_ERROR("argument convertion error"); + return false; + } + s.thisObject()->setPrivateObject(ptr); + return true; + } + auto *ptr = JSB_MAKE_PRIVATE_OBJECT(cc::Mesh::ISubMesh); + auto cobj = ptr->get(); + if (argc > 0 && !args[0].isUndefined()) { + ok &= sevalue_to_native(args[0], &(cobj->vertexBundelIndices), nullptr); + } + if (argc > 1 && !args[1].isUndefined()) { + ok &= sevalue_to_native(args[1], &(cobj->primitiveMode), nullptr); + } + if (argc > 2 && !args[2].isUndefined()) { + ok &= sevalue_to_native(args[2], &(cobj->indexView), nullptr); + } + if (argc > 3 && !args[3].isUndefined()) { + ok &= sevalue_to_native(args[3], &(cobj->jointMapIndex), nullptr); + } + + if(!ok) { + delete ptr; + SE_REPORT_ERROR("Argument convertion error"); + return false; + } + s.thisObject()->setPrivateObject(ptr); + return true; +} +SE_BIND_CTOR(js_assets_ISubMesh_constructor, __jsb_cc_Mesh_ISubMesh_class, js_cc_Mesh_ISubMesh_finalize) + +static bool js_cc_Mesh_ISubMesh_finalize(se::State& s) // NOLINT(readability-identifier-naming) +{ + return true; +} +SE_BIND_FINALIZE_FUNC(js_cc_Mesh_ISubMesh_finalize) + +bool js_register_assets_Mesh_ISubMesh(se::Object* obj) // NOLINT(readability-identifier-naming) +{ + auto* cls = se::Class::create({"Mesh","ISubMesh"}, obj, nullptr, _SE(js_assets_ISubMesh_constructor)); + + cls->defineProperty("vertexBundelIndices", _SE(js_assets_ISubMesh_get_vertexBundelIndices), _SE(js_assets_ISubMesh_set_vertexBundelIndices)); + cls->defineProperty("primitiveMode", _SE(js_assets_ISubMesh_get_primitiveMode), _SE(js_assets_ISubMesh_set_primitiveMode)); + cls->defineProperty("indexView", _SE(js_assets_ISubMesh_get_indexView), _SE(js_assets_ISubMesh_set_indexView)); + cls->defineProperty("jointMapIndex", _SE(js_assets_ISubMesh_get_jointMapIndex), _SE(js_assets_ISubMesh_set_jointMapIndex)); + cls->defineFinalizeFunction(_SE(js_cc_Mesh_ISubMesh_finalize)); + cls->install(); + JSBClassType::registerClass(cls); + + __jsb_cc_Mesh_ISubMesh_proto = cls->getProto(); + __jsb_cc_Mesh_ISubMesh_class = cls; + + + se::ScriptEngine::getInstance()->clearException(); + return true; +} +se::Object* __jsb_cc_Mesh_IStruct_proto = nullptr; // NOLINT +se::Class* __jsb_cc_Mesh_IStruct_class = nullptr; // NOLINT + +static bool js_assets_IStruct_get_vertexBundles(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_assets_IStruct_get_vertexBundles : Invalid Native Object"); + + CC_UNUSED bool ok = true; + se::Value jsret; + ok &= nativevalue_to_se(cobj->vertexBundles, jsret, s.thisObject() /*ctx*/); + s.rval() = jsret; + SE_HOLD_RETURN_VALUE(cobj->vertexBundles, s.thisObject(), s.rval()); + return true; +} +SE_BIND_PROP_GET(js_assets_IStruct_get_vertexBundles) + +static bool js_assets_IStruct_set_vertexBundles(se::State& s) // NOLINT(readability-identifier-naming) +{ + const auto& args = s.args(); + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_assets_IStruct_set_vertexBundles : Invalid Native Object"); + + CC_UNUSED bool ok = true; + ok &= sevalue_to_native(args[0], &cobj->vertexBundles, s.thisObject()); + SE_PRECONDITION2(ok, false, "js_assets_IStruct_set_vertexBundles : Error processing new value"); + return true; +} +SE_BIND_PROP_SET(js_assets_IStruct_set_vertexBundles) + +static bool js_assets_IStruct_get_primitives(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_assets_IStruct_get_primitives : Invalid Native Object"); + + CC_UNUSED bool ok = true; + se::Value jsret; + ok &= nativevalue_to_se(cobj->primitives, jsret, s.thisObject() /*ctx*/); + s.rval() = jsret; + SE_HOLD_RETURN_VALUE(cobj->primitives, s.thisObject(), s.rval()); + return true; +} +SE_BIND_PROP_GET(js_assets_IStruct_get_primitives) + +static bool js_assets_IStruct_set_primitives(se::State& s) // NOLINT(readability-identifier-naming) +{ + const auto& args = s.args(); + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_assets_IStruct_set_primitives : Invalid Native Object"); + + CC_UNUSED bool ok = true; + ok &= sevalue_to_native(args[0], &cobj->primitives, s.thisObject()); + SE_PRECONDITION2(ok, false, "js_assets_IStruct_set_primitives : Error processing new value"); + return true; +} +SE_BIND_PROP_SET(js_assets_IStruct_set_primitives) + +static bool js_assets_IStruct_get_minPosition(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_assets_IStruct_get_minPosition : Invalid Native Object"); + + CC_UNUSED bool ok = true; + se::Value jsret; + ok &= nativevalue_to_se(cobj->minPosition, jsret, s.thisObject() /*ctx*/); + s.rval() = jsret; + SE_HOLD_RETURN_VALUE(cobj->minPosition, s.thisObject(), s.rval()); + return true; +} +SE_BIND_PROP_GET(js_assets_IStruct_get_minPosition) + +static bool js_assets_IStruct_set_minPosition(se::State& s) // NOLINT(readability-identifier-naming) +{ + const auto& args = s.args(); + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_assets_IStruct_set_minPosition : Invalid Native Object"); + + CC_UNUSED bool ok = true; + ok &= sevalue_to_native(args[0], &cobj->minPosition, s.thisObject()); + SE_PRECONDITION2(ok, false, "js_assets_IStruct_set_minPosition : Error processing new value"); + return true; +} +SE_BIND_PROP_SET(js_assets_IStruct_set_minPosition) + +static bool js_assets_IStruct_get_maxPosition(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_assets_IStruct_get_maxPosition : Invalid Native Object"); + + CC_UNUSED bool ok = true; + se::Value jsret; + ok &= nativevalue_to_se(cobj->maxPosition, jsret, s.thisObject() /*ctx*/); + s.rval() = jsret; + SE_HOLD_RETURN_VALUE(cobj->maxPosition, s.thisObject(), s.rval()); + return true; +} +SE_BIND_PROP_GET(js_assets_IStruct_get_maxPosition) + +static bool js_assets_IStruct_set_maxPosition(se::State& s) // NOLINT(readability-identifier-naming) +{ + const auto& args = s.args(); + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_assets_IStruct_set_maxPosition : Invalid Native Object"); + + CC_UNUSED bool ok = true; + ok &= sevalue_to_native(args[0], &cobj->maxPosition, s.thisObject()); + SE_PRECONDITION2(ok, false, "js_assets_IStruct_set_maxPosition : Error processing new value"); + return true; +} +SE_BIND_PROP_SET(js_assets_IStruct_set_maxPosition) + +static bool js_assets_IStruct_get_jointMaps(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_assets_IStruct_get_jointMaps : Invalid Native Object"); + + CC_UNUSED bool ok = true; + se::Value jsret; + ok &= nativevalue_to_se(cobj->jointMaps, jsret, s.thisObject() /*ctx*/); + s.rval() = jsret; + SE_HOLD_RETURN_VALUE(cobj->jointMaps, s.thisObject(), s.rval()); + return true; +} +SE_BIND_PROP_GET(js_assets_IStruct_get_jointMaps) + +static bool js_assets_IStruct_set_jointMaps(se::State& s) // NOLINT(readability-identifier-naming) +{ + const auto& args = s.args(); + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_assets_IStruct_set_jointMaps : Invalid Native Object"); + + CC_UNUSED bool ok = true; + ok &= sevalue_to_native(args[0], &cobj->jointMaps, s.thisObject()); + SE_PRECONDITION2(ok, false, "js_assets_IStruct_set_jointMaps : Error processing new value"); + return true; +} +SE_BIND_PROP_SET(js_assets_IStruct_set_jointMaps) + +static bool js_assets_IStruct_get_morph(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_assets_IStruct_get_morph : Invalid Native Object"); + + CC_UNUSED bool ok = true; + se::Value jsret; + ok &= nativevalue_to_se(cobj->morph, jsret, s.thisObject() /*ctx*/); + s.rval() = jsret; + SE_HOLD_RETURN_VALUE(cobj->morph, s.thisObject(), s.rval()); + return true; +} +SE_BIND_PROP_GET(js_assets_IStruct_get_morph) + +static bool js_assets_IStruct_set_morph(se::State& s) // NOLINT(readability-identifier-naming) +{ + const auto& args = s.args(); + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_assets_IStruct_set_morph : Invalid Native Object"); + + CC_UNUSED bool ok = true; + ok &= sevalue_to_native(args[0], &cobj->morph, s.thisObject()); + SE_PRECONDITION2(ok, false, "js_assets_IStruct_set_morph : Error processing new value"); + return true; +} +SE_BIND_PROP_SET(js_assets_IStruct_set_morph) + + +template<> +bool sevalue_to_native(const se::Value &from, cc::Mesh::IStruct * to, se::Object *ctx) +{ + assert(from.isObject()); + se::Object *json = from.toObject(); + auto* data = reinterpret_cast(json->getPrivateData()); + if (data) { + *to = *data; + return true; + } + se::Value field; + bool ok = true; + json->getProperty("vertexBundles", &field, true); + if(!field.isNullOrUndefined()) { + ok &= sevalue_to_native(field, &(to->vertexBundles), ctx); + } + json->getProperty("primitives", &field, true); + if(!field.isNullOrUndefined()) { + ok &= sevalue_to_native(field, &(to->primitives), ctx); + } + json->getProperty("minPosition", &field, true); + if(!field.isNullOrUndefined()) { + ok &= sevalue_to_native(field, &(to->minPosition), ctx); + } + json->getProperty("maxPosition", &field, true); + if(!field.isNullOrUndefined()) { + ok &= sevalue_to_native(field, &(to->maxPosition), ctx); + } + json->getProperty("jointMaps", &field, true); + if(!field.isNullOrUndefined()) { + ok &= sevalue_to_native(field, &(to->jointMaps), ctx); + } + json->getProperty("morph", &field, true); + if(!field.isNullOrUndefined()) { + ok &= sevalue_to_native(field, &(to->morph), ctx); + } + return ok; +} + +SE_DECLARE_FINALIZE_FUNC(js_cc_Mesh_IStruct_finalize) + +static bool js_assets_IStruct_constructor(se::State& s) // NOLINT(readability-identifier-naming) +{ + CC_UNUSED bool ok = true; + const auto& args = s.args(); + size_t argc = args.size(); + + if(argc == 0) + { + auto *ptr = JSB_MAKE_PRIVATE_OBJECT(cc::Mesh::IStruct); + s.thisObject()->setPrivateObject(ptr); + return true; + } + + if(argc == 1 && args[0].isObject()) + { + se::Object *json = args[0].toObject(); + se::Value field; + auto *ptr = JSB_MAKE_PRIVATE_OBJECT(cc::Mesh::IStruct); + auto cobj = ptr->get(); + ok &= sevalue_to_native(args[0], cobj, s.thisObject()); + if(!ok) { + delete ptr; + SE_REPORT_ERROR("argument convertion error"); + return false; + } + s.thisObject()->setPrivateObject(ptr); + return true; + } + auto *ptr = JSB_MAKE_PRIVATE_OBJECT(cc::Mesh::IStruct); + auto cobj = ptr->get(); + if (argc > 0 && !args[0].isUndefined()) { + ok &= sevalue_to_native(args[0], &(cobj->vertexBundles), nullptr); + } + if (argc > 1 && !args[1].isUndefined()) { + ok &= sevalue_to_native(args[1], &(cobj->primitives), nullptr); + } + if (argc > 2 && !args[2].isUndefined()) { + ok &= sevalue_to_native(args[2], &(cobj->minPosition), nullptr); + } + if (argc > 3 && !args[3].isUndefined()) { + ok &= sevalue_to_native(args[3], &(cobj->maxPosition), nullptr); + } + if (argc > 4 && !args[4].isUndefined()) { + ok &= sevalue_to_native(args[4], &(cobj->jointMaps), nullptr); + } + if (argc > 5 && !args[5].isUndefined()) { + ok &= sevalue_to_native(args[5], &(cobj->morph), nullptr); + } + + if(!ok) { + delete ptr; + SE_REPORT_ERROR("Argument convertion error"); + return false; + } + s.thisObject()->setPrivateObject(ptr); + return true; +} +SE_BIND_CTOR(js_assets_IStruct_constructor, __jsb_cc_Mesh_IStruct_class, js_cc_Mesh_IStruct_finalize) + +static bool js_cc_Mesh_IStruct_finalize(se::State& s) // NOLINT(readability-identifier-naming) +{ + return true; +} +SE_BIND_FINALIZE_FUNC(js_cc_Mesh_IStruct_finalize) + +bool js_register_assets_Mesh_IStruct(se::Object* obj) // NOLINT(readability-identifier-naming) +{ + auto* cls = se::Class::create({"Mesh","IStruct"}, obj, nullptr, _SE(js_assets_IStruct_constructor)); + + cls->defineProperty("vertexBundles", _SE(js_assets_IStruct_get_vertexBundles), _SE(js_assets_IStruct_set_vertexBundles)); + cls->defineProperty("primitives", _SE(js_assets_IStruct_get_primitives), _SE(js_assets_IStruct_set_primitives)); + cls->defineProperty("minPosition", _SE(js_assets_IStruct_get_minPosition), _SE(js_assets_IStruct_set_minPosition)); + cls->defineProperty("maxPosition", _SE(js_assets_IStruct_get_maxPosition), _SE(js_assets_IStruct_set_maxPosition)); + cls->defineProperty("jointMaps", _SE(js_assets_IStruct_get_jointMaps), _SE(js_assets_IStruct_set_jointMaps)); + cls->defineProperty("morph", _SE(js_assets_IStruct_get_morph), _SE(js_assets_IStruct_set_morph)); + cls->defineFinalizeFunction(_SE(js_cc_Mesh_IStruct_finalize)); + cls->install(); + JSBClassType::registerClass(cls); + + __jsb_cc_Mesh_IStruct_proto = cls->getProto(); + __jsb_cc_Mesh_IStruct_class = cls; + + + se::ScriptEngine::getInstance()->clearException(); + return true; +} +se::Object* __jsb_cc_Mesh_ICreateInfo_proto = nullptr; // NOLINT +se::Class* __jsb_cc_Mesh_ICreateInfo_class = nullptr; // NOLINT + +static bool js_assets_ICreateInfo_get_structInfo(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_assets_ICreateInfo_get_structInfo : Invalid Native Object"); + + CC_UNUSED bool ok = true; + se::Value jsret; + ok &= nativevalue_to_se(cobj->structInfo, jsret, s.thisObject() /*ctx*/); + s.rval() = jsret; + SE_HOLD_RETURN_VALUE(cobj->structInfo, s.thisObject(), s.rval()); + return true; +} +SE_BIND_PROP_GET(js_assets_ICreateInfo_get_structInfo) + +static bool js_assets_ICreateInfo_set_structInfo(se::State& s) // NOLINT(readability-identifier-naming) +{ + const auto& args = s.args(); + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_assets_ICreateInfo_set_structInfo : Invalid Native Object"); + + CC_UNUSED bool ok = true; + ok &= sevalue_to_native(args[0], &cobj->structInfo, s.thisObject()); + SE_PRECONDITION2(ok, false, "js_assets_ICreateInfo_set_structInfo : Error processing new value"); + return true; +} +SE_BIND_PROP_SET(js_assets_ICreateInfo_set_structInfo) + +static bool js_assets_ICreateInfo_get_data(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_assets_ICreateInfo_get_data : Invalid Native Object"); + + CC_UNUSED bool ok = true; + se::Value jsret; + ok &= nativevalue_to_se(cobj->data, jsret, s.thisObject() /*ctx*/); + s.rval() = jsret; + SE_HOLD_RETURN_VALUE(cobj->data, s.thisObject(), s.rval()); + return true; +} +SE_BIND_PROP_GET(js_assets_ICreateInfo_get_data) + +static bool js_assets_ICreateInfo_set_data(se::State& s) // NOLINT(readability-identifier-naming) +{ + const auto& args = s.args(); + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_assets_ICreateInfo_set_data : Invalid Native Object"); + + CC_UNUSED bool ok = true; + ok &= sevalue_to_native(args[0], &cobj->data, s.thisObject()); + SE_PRECONDITION2(ok, false, "js_assets_ICreateInfo_set_data : Error processing new value"); + return true; +} +SE_BIND_PROP_SET(js_assets_ICreateInfo_set_data) + + +template<> +bool sevalue_to_native(const se::Value &from, cc::Mesh::ICreateInfo * to, se::Object *ctx) +{ + assert(from.isObject()); + se::Object *json = from.toObject(); + auto* data = reinterpret_cast(json->getPrivateData()); + if (data) { + *to = *data; + return true; + } + se::Value field; + bool ok = true; + json->getProperty("struct", &field, true); + if(!field.isNullOrUndefined()) { + ok &= sevalue_to_native(field, &(to->structInfo), ctx); + } + json->getProperty("data", &field, true); + if(!field.isNullOrUndefined()) { + ok &= sevalue_to_native(field, &(to->data), ctx); + } + return ok; +} + +SE_DECLARE_FINALIZE_FUNC(js_cc_Mesh_ICreateInfo_finalize) + +static bool js_assets_ICreateInfo_constructor(se::State& s) // NOLINT(readability-identifier-naming) +{ + CC_UNUSED bool ok = true; + const auto& args = s.args(); + size_t argc = args.size(); + + if(argc == 0) + { + auto *ptr = JSB_MAKE_PRIVATE_OBJECT(cc::Mesh::ICreateInfo); + s.thisObject()->setPrivateObject(ptr); + return true; + } + + if(argc == 1 && args[0].isObject()) + { + se::Object *json = args[0].toObject(); + se::Value field; + auto *ptr = JSB_MAKE_PRIVATE_OBJECT(cc::Mesh::ICreateInfo); + auto cobj = ptr->get(); + ok &= sevalue_to_native(args[0], cobj, s.thisObject()); + if(!ok) { + delete ptr; + SE_REPORT_ERROR("argument convertion error"); + return false; + } + s.thisObject()->setPrivateObject(ptr); + return true; + } + auto *ptr = JSB_MAKE_PRIVATE_OBJECT(cc::Mesh::ICreateInfo); + auto cobj = ptr->get(); + if (argc > 0 && !args[0].isUndefined()) { + ok &= sevalue_to_native(args[0], &(cobj->structInfo), nullptr); + } + if (argc > 1 && !args[1].isUndefined()) { + ok &= sevalue_to_native(args[1], &(cobj->data), nullptr); + } + + if(!ok) { + delete ptr; + SE_REPORT_ERROR("Argument convertion error"); + return false; + } + s.thisObject()->setPrivateObject(ptr); + return true; +} +SE_BIND_CTOR(js_assets_ICreateInfo_constructor, __jsb_cc_Mesh_ICreateInfo_class, js_cc_Mesh_ICreateInfo_finalize) + +static bool js_cc_Mesh_ICreateInfo_finalize(se::State& s) // NOLINT(readability-identifier-naming) +{ + return true; +} +SE_BIND_FINALIZE_FUNC(js_cc_Mesh_ICreateInfo_finalize) + +bool js_register_assets_Mesh_ICreateInfo(se::Object* obj) // NOLINT(readability-identifier-naming) +{ + auto* cls = se::Class::create({"Mesh","ICreateInfo"}, obj, nullptr, _SE(js_assets_ICreateInfo_constructor)); + + cls->defineProperty("struct", _SE(js_assets_ICreateInfo_get_structInfo), _SE(js_assets_ICreateInfo_set_structInfo)); + cls->defineProperty("data", _SE(js_assets_ICreateInfo_get_data), _SE(js_assets_ICreateInfo_set_data)); + cls->defineFinalizeFunction(_SE(js_cc_Mesh_ICreateInfo_finalize)); + cls->install(); + JSBClassType::registerClass(cls); + + __jsb_cc_Mesh_ICreateInfo_proto = cls->getProto(); + __jsb_cc_Mesh_ICreateInfo_class = cls; + + + se::ScriptEngine::getInstance()->clearException(); + return true; +} +se::Object* __jsb_cc_Mesh_proto = nullptr; // NOLINT +se::Class* __jsb_cc_Mesh_class = nullptr; // NOLINT + +static bool js_assets_Mesh_assign(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_assets_Mesh_assign : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 2) { + HolderType arg0 = {}; + HolderType, true> arg1 = {}; + ok &= sevalue_to_native(args[0], &arg0, s.thisObject()); + ok &= sevalue_to_native(args[1], &arg1, s.thisObject()); + SE_PRECONDITION2(ok, false, "js_assets_Mesh_assign : Error processing arguments"); + cobj->assign(arg0.value(), arg1.value()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 2); + return false; +} +SE_BIND_FUNC(js_assets_Mesh_assign) + +static bool js_assets_Mesh_copyAttribute(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_assets_Mesh_copyAttribute : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 5) { + HolderType arg0 = {}; + HolderType arg1 = {}; + HolderType arg2 = {}; + HolderType arg3 = {}; + HolderType arg4 = {}; + ok &= sevalue_to_native(args[0], &arg0, s.thisObject()); + ok &= sevalue_to_native(args[1], &arg1, s.thisObject()); + ok &= sevalue_to_native(args[2], &arg2, s.thisObject()); + ok &= sevalue_to_native(args[3], &arg3, s.thisObject()); + ok &= sevalue_to_native(args[4], &arg4, s.thisObject()); + SE_PRECONDITION2(ok, false, "js_assets_Mesh_copyAttribute : Error processing arguments"); + bool result = cobj->copyAttribute(arg0.value(), arg1.value(), arg2.value(), arg3.value(), arg4.value()); + ok &= nativevalue_to_se(result, s.rval(), nullptr /*ctx*/); + SE_PRECONDITION2(ok, false, "js_assets_Mesh_copyAttribute : Error processing arguments"); + SE_HOLD_RETURN_VALUE(result, s.thisObject(), s.rval()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 5); + return false; +} +SE_BIND_FUNC(js_assets_Mesh_copyAttribute) + +static bool js_assets_Mesh_copyIndices(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_assets_Mesh_copyIndices : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 2) { + HolderType arg0 = {}; + HolderType, cc::TypedArrayTemp, cc::TypedArrayTemp, cc::TypedArrayTemp, cc::TypedArrayTemp, cc::TypedArrayTemp, cc::TypedArrayTemp, cc::TypedArrayTemp>, true> arg1 = {}; + ok &= sevalue_to_native(args[0], &arg0, s.thisObject()); + ok &= sevalue_to_native(args[1], &arg1, s.thisObject()); + SE_PRECONDITION2(ok, false, "js_assets_Mesh_copyIndices : Error processing arguments"); + bool result = cobj->copyIndices(arg0.value(), arg1.value()); + ok &= nativevalue_to_se(result, s.rval(), nullptr /*ctx*/); + SE_PRECONDITION2(ok, false, "js_assets_Mesh_copyIndices : Error processing arguments"); + SE_HOLD_RETURN_VALUE(result, s.thisObject(), s.rval()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 2); + return false; +} +SE_BIND_FUNC(js_assets_Mesh_copyIndices) + +static bool js_assets_Mesh_destroyRenderingMesh(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_assets_Mesh_destroyRenderingMesh : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + if (argc == 0) { + cobj->destroyRenderingMesh(); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 0); + return false; +} +SE_BIND_FUNC(js_assets_Mesh_destroyRenderingMesh) + +static bool js_assets_Mesh_getAssetData(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_assets_Mesh_getAssetData : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 0) { + const cc::TypedArrayTemp& result = cobj->getAssetData(); + ok &= nativevalue_to_se(result, s.rval(), nullptr /*ctx*/); + SE_PRECONDITION2(ok, false, "js_assets_Mesh_getAssetData : Error processing arguments"); + SE_HOLD_RETURN_VALUE(result, s.thisObject(), s.rval()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 0); + return false; +} +SE_BIND_FUNC_AS_PROP_GET(js_assets_Mesh_getAssetData) + +static bool js_assets_Mesh_getBoneSpaceBounds(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_assets_Mesh_getBoneSpaceBounds : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 1) { + HolderType arg0 = {}; + ok &= sevalue_to_native(args[0], &arg0, s.thisObject()); + SE_PRECONDITION2(ok, false, "js_assets_Mesh_getBoneSpaceBounds : Error processing arguments"); + std::vector> result = cobj->getBoneSpaceBounds(arg0.value()); + ok &= nativevalue_to_se(result, s.rval(), nullptr /*ctx*/); + SE_PRECONDITION2(ok, false, "js_assets_Mesh_getBoneSpaceBounds : Error processing arguments"); + SE_HOLD_RETURN_VALUE(result, s.thisObject(), s.rval()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 1); + return false; +} +SE_BIND_FUNC(js_assets_Mesh_getBoneSpaceBounds) + +static bool js_assets_Mesh_getData(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_assets_Mesh_getData : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 0) { + cc::TypedArrayTemp& result = cobj->getData(); + ok &= nativevalue_to_se(result, s.rval(), nullptr /*ctx*/); + SE_PRECONDITION2(ok, false, "js_assets_Mesh_getData : Error processing arguments"); + SE_HOLD_RETURN_VALUE(result, s.thisObject(), s.rval()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 0); + return false; +} +SE_BIND_FUNC_AS_PROP_GET(js_assets_Mesh_getData) + +static bool js_assets_Mesh_getHashForJS(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_assets_Mesh_getHashForJS : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 0) { + double result = cobj->getHashForJS(); + ok &= nativevalue_to_se(result, s.rval(), nullptr /*ctx*/); + SE_PRECONDITION2(ok, false, "js_assets_Mesh_getHashForJS : Error processing arguments"); + SE_HOLD_RETURN_VALUE(result, s.thisObject(), s.rval()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 0); + return false; +} +SE_BIND_FUNC_AS_PROP_GET(js_assets_Mesh_getHashForJS) + +static bool js_assets_Mesh_getJointBufferIndices(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_assets_Mesh_getJointBufferIndices : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 0) { + const std::vector& result = cobj->getJointBufferIndices(); + ok &= nativevalue_to_se(result, s.rval(), nullptr /*ctx*/); + SE_PRECONDITION2(ok, false, "js_assets_Mesh_getJointBufferIndices : Error processing arguments"); + SE_HOLD_RETURN_VALUE(result, s.thisObject(), s.rval()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 0); + return false; +} +SE_BIND_FUNC_AS_PROP_GET(js_assets_Mesh_getJointBufferIndices) + +static bool js_assets_Mesh_getMaxPosition(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_assets_Mesh_getMaxPosition : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 0) { + const cc::Vec3& result = cobj->getMaxPosition(); + ok &= nativevalue_to_se(result, s.rval(), nullptr /*ctx*/); + SE_PRECONDITION2(ok, false, "js_assets_Mesh_getMaxPosition : Error processing arguments"); + SE_HOLD_RETURN_VALUE(result, s.thisObject(), s.rval()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 0); + return false; +} +SE_BIND_FUNC_AS_PROP_GET(js_assets_Mesh_getMaxPosition) + +static bool js_assets_Mesh_getMinPosition(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_assets_Mesh_getMinPosition : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 0) { + const cc::Vec3& result = cobj->getMinPosition(); + ok &= nativevalue_to_se(result, s.rval(), nullptr /*ctx*/); + SE_PRECONDITION2(ok, false, "js_assets_Mesh_getMinPosition : Error processing arguments"); + SE_HOLD_RETURN_VALUE(result, s.thisObject(), s.rval()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 0); + return false; +} +SE_BIND_FUNC_AS_PROP_GET(js_assets_Mesh_getMinPosition) + +static bool js_assets_Mesh_getRenderingSubMeshes(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_assets_Mesh_getRenderingSubMeshes : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 0) { + const std::vector>& result = cobj->getRenderingSubMeshes(); + ok &= nativevalue_to_se(result, s.rval(), nullptr /*ctx*/); + SE_PRECONDITION2(ok, false, "js_assets_Mesh_getRenderingSubMeshes : Error processing arguments"); + SE_HOLD_RETURN_VALUE(result, s.thisObject(), s.rval()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 0); + return false; +} +SE_BIND_FUNC_AS_PROP_GET(js_assets_Mesh_getRenderingSubMeshes) + +static bool js_assets_Mesh_getStruct(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_assets_Mesh_getStruct : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 0) { + const cc::Mesh::IStruct& result = cobj->getStruct(); + ok &= nativevalue_to_se(result, s.rval(), nullptr /*ctx*/); + SE_PRECONDITION2(ok, false, "js_assets_Mesh_getStruct : Error processing arguments"); + SE_HOLD_RETURN_VALUE(result, s.thisObject(), s.rval()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 0); + return false; +} +SE_BIND_FUNC(js_assets_Mesh_getStruct) + +static bool js_assets_Mesh_getSubMeshCount(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_assets_Mesh_getSubMeshCount : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 0) { + unsigned int result = cobj->getSubMeshCount(); + ok &= nativevalue_to_se(result, s.rval(), nullptr /*ctx*/); + SE_PRECONDITION2(ok, false, "js_assets_Mesh_getSubMeshCount : Error processing arguments"); + SE_HOLD_RETURN_VALUE(result, s.thisObject(), s.rval()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 0); + return false; +} +SE_BIND_FUNC_AS_PROP_GET(js_assets_Mesh_getSubMeshCount) + +static bool js_assets_Mesh_initialize(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_assets_Mesh_initialize : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + if (argc == 0) { + cobj->initialize(); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 0); + return false; +} +SE_BIND_FUNC(js_assets_Mesh_initialize) + +static bool js_assets_Mesh_merge(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_assets_Mesh_merge : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 1) { + HolderType arg0 = {}; + ok &= sevalue_to_native(args[0], &arg0, s.thisObject()); + SE_PRECONDITION2(ok, false, "js_assets_Mesh_merge : Error processing arguments"); + bool result = cobj->merge(arg0.value()); + ok &= nativevalue_to_se(result, s.rval(), nullptr /*ctx*/); + SE_PRECONDITION2(ok, false, "js_assets_Mesh_merge : Error processing arguments"); + SE_HOLD_RETURN_VALUE(result, s.thisObject(), s.rval()); + return true; + } + if (argc == 2) { + HolderType arg0 = {}; + HolderType arg1 = {}; + ok &= sevalue_to_native(args[0], &arg0, s.thisObject()); + ok &= sevalue_to_native(args[1], &arg1, s.thisObject()); + SE_PRECONDITION2(ok, false, "js_assets_Mesh_merge : Error processing arguments"); + bool result = cobj->merge(arg0.value(), arg1.value()); + ok &= nativevalue_to_se(result, s.rval(), nullptr /*ctx*/); + SE_PRECONDITION2(ok, false, "js_assets_Mesh_merge : Error processing arguments"); + SE_HOLD_RETURN_VALUE(result, s.thisObject(), s.rval()); + return true; + } + if (argc == 3) { + HolderType arg0 = {}; + HolderType arg1 = {}; + HolderType arg2 = {}; + ok &= sevalue_to_native(args[0], &arg0, s.thisObject()); + ok &= sevalue_to_native(args[1], &arg1, s.thisObject()); + ok &= sevalue_to_native(args[2], &arg2, s.thisObject()); + SE_PRECONDITION2(ok, false, "js_assets_Mesh_merge : Error processing arguments"); + bool result = cobj->merge(arg0.value(), arg1.value(), arg2.value()); + ok &= nativevalue_to_se(result, s.rval(), nullptr /*ctx*/); + SE_PRECONDITION2(ok, false, "js_assets_Mesh_merge : Error processing arguments"); + SE_HOLD_RETURN_VALUE(result, s.thisObject(), s.rval()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 3); + return false; +} +SE_BIND_FUNC(js_assets_Mesh_merge) + +static bool js_assets_Mesh_readAttribute(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_assets_Mesh_readAttribute : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 2) { + HolderType arg0 = {}; + HolderType arg1 = {}; + ok &= sevalue_to_native(args[0], &arg0, s.thisObject()); + ok &= sevalue_to_native(args[1], &arg1, s.thisObject()); + SE_PRECONDITION2(ok, false, "js_assets_Mesh_readAttribute : Error processing arguments"); + boost::variant2::variant, cc::TypedArrayTemp, cc::TypedArrayTemp, cc::TypedArrayTemp, cc::TypedArrayTemp, cc::TypedArrayTemp, cc::TypedArrayTemp, cc::TypedArrayTemp> result = cobj->readAttribute(arg0.value(), arg1.value()); + ok &= nativevalue_to_se(result, s.rval(), nullptr /*ctx*/); + SE_PRECONDITION2(ok, false, "js_assets_Mesh_readAttribute : Error processing arguments"); + SE_HOLD_RETURN_VALUE(result, s.thisObject(), s.rval()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 2); + return false; +} +SE_BIND_FUNC(js_assets_Mesh_readAttribute) + +static bool js_assets_Mesh_readIndices(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_assets_Mesh_readIndices : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 1) { + HolderType arg0 = {}; + ok &= sevalue_to_native(args[0], &arg0, s.thisObject()); + SE_PRECONDITION2(ok, false, "js_assets_Mesh_readIndices : Error processing arguments"); + boost::variant2::variant, cc::TypedArrayTemp, cc::TypedArrayTemp> result = cobj->readIndices(arg0.value()); + ok &= nativevalue_to_se(result, s.rval(), nullptr /*ctx*/); + SE_PRECONDITION2(ok, false, "js_assets_Mesh_readIndices : Error processing arguments"); + SE_HOLD_RETURN_VALUE(result, s.thisObject(), s.rval()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 1); + return false; +} +SE_BIND_FUNC(js_assets_Mesh_readIndices) + +static bool js_assets_Mesh_reset(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_assets_Mesh_reset : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 1) { + HolderType arg0 = {}; + ok &= sevalue_to_native(args[0], &arg0, s.thisObject()); + SE_PRECONDITION2(ok, false, "js_assets_Mesh_reset : Error processing arguments"); + cobj->reset(std::move(arg0.value())); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 1); + return false; +} +SE_BIND_FUNC(js_assets_Mesh_reset) + +static bool js_assets_Mesh_setAssetData(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_assets_Mesh_setAssetData : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 1) { + HolderType arg0 = {}; + ok &= sevalue_to_native(args[0], &arg0, s.thisObject()); + SE_PRECONDITION2(ok, false, "js_assets_Mesh_setAssetData : Error processing arguments"); + cobj->setAssetData(arg0.value()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 1); + return false; +} +SE_BIND_FUNC_AS_PROP_SET(js_assets_Mesh_setAssetData) + +static bool js_assets_Mesh_setData(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_assets_Mesh_setData : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 1) { + HolderType, true> arg0 = {}; + ok &= sevalue_to_native(args[0], &arg0, s.thisObject()); + SE_PRECONDITION2(ok, false, "js_assets_Mesh_setData : Error processing arguments"); + cobj->setData(arg0.value()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 1); + return false; +} +SE_BIND_FUNC_AS_PROP_SET(js_assets_Mesh_setData) + +static bool js_assets_Mesh_setHash(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_assets_Mesh_setHash : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 1) { + HolderType arg0 = {}; + ok &= sevalue_to_native(args[0], &arg0, s.thisObject()); + SE_PRECONDITION2(ok, false, "js_assets_Mesh_setHash : Error processing arguments"); + cobj->setHash(arg0.value()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 1); + return false; +} +SE_BIND_FUNC_AS_PROP_SET(js_assets_Mesh_setHash) + +static bool js_assets_Mesh_setStruct(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_assets_Mesh_setStruct : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 1) { + HolderType arg0 = {}; + ok &= sevalue_to_native(args[0], &arg0, s.thisObject()); + SE_PRECONDITION2(ok, false, "js_assets_Mesh_setStruct : Error processing arguments"); + cobj->setStruct(arg0.value()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 1); + return false; +} +SE_BIND_FUNC(js_assets_Mesh_setStruct) + +static bool js_assets_Mesh_validateMergingMesh(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_assets_Mesh_validateMergingMesh : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 1) { + HolderType arg0 = {}; + ok &= sevalue_to_native(args[0], &arg0, s.thisObject()); + SE_PRECONDITION2(ok, false, "js_assets_Mesh_validateMergingMesh : Error processing arguments"); + bool result = cobj->validateMergingMesh(arg0.value()); + ok &= nativevalue_to_se(result, s.rval(), nullptr /*ctx*/); + SE_PRECONDITION2(ok, false, "js_assets_Mesh_validateMergingMesh : Error processing arguments"); + SE_HOLD_RETURN_VALUE(result, s.thisObject(), s.rval()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 1); + return false; +} +SE_BIND_FUNC(js_assets_Mesh_validateMergingMesh) + +static bool js_assets_Mesh_get_morphRendering(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_assets_Mesh_get_morphRendering : Invalid Native Object"); + + CC_UNUSED bool ok = true; + se::Value jsret; + ok &= nativevalue_to_se(cobj->morphRendering, jsret, s.thisObject() /*ctx*/); + s.rval() = jsret; + SE_HOLD_RETURN_VALUE(cobj->morphRendering, s.thisObject(), s.rval()); + return true; +} +SE_BIND_PROP_GET(js_assets_Mesh_get_morphRendering) + +static bool js_assets_Mesh_set_morphRendering(se::State& s) // NOLINT(readability-identifier-naming) +{ + const auto& args = s.args(); + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_assets_Mesh_set_morphRendering : Invalid Native Object"); + + CC_UNUSED bool ok = true; + ok &= sevalue_to_native(args[0], &cobj->morphRendering, s.thisObject()); + SE_PRECONDITION2(ok, false, "js_assets_Mesh_set_morphRendering : Error processing new value"); + return true; +} +SE_BIND_PROP_SET(js_assets_Mesh_set_morphRendering) + +SE_DECLARE_FINALIZE_FUNC(js_cc_Mesh_finalize) + +static bool js_assets_Mesh_constructor(se::State& s) // NOLINT(readability-identifier-naming) constructor.c +{ + auto *ptr = JSB_MAKE_PRIVATE_OBJECT(cc::Mesh); + s.thisObject()->setPrivateObject(ptr); + return true; +} +SE_BIND_CTOR(js_assets_Mesh_constructor, __jsb_cc_Mesh_class, js_cc_Mesh_finalize) + +static bool js_cc_Mesh_finalize(se::State& s) // NOLINT(readability-identifier-naming) +{ + return true; +} +SE_BIND_FINALIZE_FUNC(js_cc_Mesh_finalize) + +bool js_register_assets_Mesh(se::Object* obj) // NOLINT(readability-identifier-naming) +{ + auto* cls = se::Class::create("Mesh", obj, __jsb_cc_Asset_proto, _SE(js_assets_Mesh_constructor)); + + cls->defineProperty("morphRendering", _SE(js_assets_Mesh_get_morphRendering), _SE(js_assets_Mesh_set_morphRendering)); + cls->defineProperty("subMeshCount", _SE(js_assets_Mesh_getSubMeshCount_asGetter), nullptr); + cls->defineProperty("maxPosition", _SE(js_assets_Mesh_getMaxPosition_asGetter), nullptr); + cls->defineProperty("renderingSubMeshes", _SE(js_assets_Mesh_getRenderingSubMeshes_asGetter), nullptr); + cls->defineProperty("_nativeAsset", _SE(js_assets_Mesh_getAssetData_asGetter), _SE(js_assets_Mesh_setAssetData_asSetter)); + cls->defineProperty({"_hash", "hash"}, _SE(js_assets_Mesh_getHashForJS_asGetter), _SE(js_assets_Mesh_setHash_asSetter)); + cls->defineProperty("jointBufferIndices", _SE(js_assets_Mesh_getJointBufferIndices_asGetter), nullptr); + cls->defineProperty({"data", "_data"}, _SE(js_assets_Mesh_getData_asGetter), _SE(js_assets_Mesh_setData_asSetter)); + cls->defineProperty("minPosition", _SE(js_assets_Mesh_getMinPosition_asGetter), nullptr); + cls->defineFunction("assign", _SE(js_assets_Mesh_assign)); + cls->defineFunction("copyAttribute", _SE(js_assets_Mesh_copyAttribute)); + cls->defineFunction("copyIndices", _SE(js_assets_Mesh_copyIndices)); + cls->defineFunction("destroyRenderingMesh", _SE(js_assets_Mesh_destroyRenderingMesh)); + cls->defineFunction("getBoneSpaceBounds", _SE(js_assets_Mesh_getBoneSpaceBounds)); + cls->defineFunction("getStruct", _SE(js_assets_Mesh_getStruct)); + cls->defineFunction("initialize", _SE(js_assets_Mesh_initialize)); + cls->defineFunction("merge", _SE(js_assets_Mesh_merge)); + cls->defineFunction("readAttribute", _SE(js_assets_Mesh_readAttribute)); + cls->defineFunction("readIndices", _SE(js_assets_Mesh_readIndices)); + cls->defineFunction("reset", _SE(js_assets_Mesh_reset)); + cls->defineFunction("setStruct", _SE(js_assets_Mesh_setStruct)); + cls->defineFunction("validateMergingMesh", _SE(js_assets_Mesh_validateMergingMesh)); + cls->defineFinalizeFunction(_SE(js_cc_Mesh_finalize)); + cls->install(); + JSBClassType::registerClass(cls); + + __jsb_cc_Mesh_proto = cls->getProto(); + __jsb_cc_Mesh_class = cls; + + + se::ScriptEngine::getInstance()->clearException(); + return true; +} +se::Object* __jsb_cc_Skeleton_proto = nullptr; // NOLINT +se::Class* __jsb_cc_Skeleton_class = nullptr; // NOLINT + +static bool js_assets_Skeleton_getBindposes(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_assets_Skeleton_getBindposes : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 0) { + const std::vector& result = cobj->getBindposes(); + ok &= nativevalue_to_se(result, s.rval(), nullptr /*ctx*/); + SE_PRECONDITION2(ok, false, "js_assets_Skeleton_getBindposes : Error processing arguments"); + SE_HOLD_RETURN_VALUE(result, s.thisObject(), s.rval()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 0); + return false; +} +SE_BIND_FUNC(js_assets_Skeleton_getBindposes) + +static bool js_assets_Skeleton_getHashForJS(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_assets_Skeleton_getHashForJS : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 0) { + double result = cobj->getHashForJS(); + ok &= nativevalue_to_se(result, s.rval(), nullptr /*ctx*/); + SE_PRECONDITION2(ok, false, "js_assets_Skeleton_getHashForJS : Error processing arguments"); + SE_HOLD_RETURN_VALUE(result, s.thisObject(), s.rval()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 0); + return false; +} +SE_BIND_FUNC_AS_PROP_GET(js_assets_Skeleton_getHashForJS) +SE_BIND_FUNC(js_assets_Skeleton_getHashForJS) + +static bool js_assets_Skeleton_getInverseBindposes(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_assets_Skeleton_getInverseBindposes : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 0) { + const std::vector& result = cobj->getInverseBindposes(); + ok &= nativevalue_to_se(result, s.rval(), nullptr /*ctx*/); + SE_PRECONDITION2(ok, false, "js_assets_Skeleton_getInverseBindposes : Error processing arguments"); + SE_HOLD_RETURN_VALUE(result, s.thisObject(), s.rval()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 0); + return false; +} +SE_BIND_FUNC(js_assets_Skeleton_getInverseBindposes) + +static bool js_assets_Skeleton_getJoints(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_assets_Skeleton_getJoints : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 0) { + const std::vector& result = cobj->getJoints(); + ok &= nativevalue_to_se(result, s.rval(), nullptr /*ctx*/); + SE_PRECONDITION2(ok, false, "js_assets_Skeleton_getJoints : Error processing arguments"); + SE_HOLD_RETURN_VALUE(result, s.thisObject(), s.rval()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 0); + return false; +} +SE_BIND_FUNC_AS_PROP_GET(js_assets_Skeleton_getJoints) +SE_BIND_FUNC(js_assets_Skeleton_getJoints) + +static bool js_assets_Skeleton_setBindposes(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_assets_Skeleton_setBindposes : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 1) { + HolderType, true> arg0 = {}; + ok &= sevalue_to_native(args[0], &arg0, s.thisObject()); + SE_PRECONDITION2(ok, false, "js_assets_Skeleton_setBindposes : Error processing arguments"); + cobj->setBindposes(arg0.value()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 1); + return false; +} +SE_BIND_FUNC(js_assets_Skeleton_setBindposes) + +static bool js_assets_Skeleton_setHash(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_assets_Skeleton_setHash : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 1) { + HolderType arg0 = {}; + ok &= sevalue_to_native(args[0], &arg0, s.thisObject()); + SE_PRECONDITION2(ok, false, "js_assets_Skeleton_setHash : Error processing arguments"); + cobj->setHash(arg0.value()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 1); + return false; +} +SE_BIND_FUNC_AS_PROP_SET(js_assets_Skeleton_setHash) +SE_BIND_FUNC(js_assets_Skeleton_setHash) + +static bool js_assets_Skeleton_setJoints(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_assets_Skeleton_setJoints : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 1) { + HolderType, true> arg0 = {}; + ok &= sevalue_to_native(args[0], &arg0, s.thisObject()); + SE_PRECONDITION2(ok, false, "js_assets_Skeleton_setJoints : Error processing arguments"); + cobj->setJoints(arg0.value()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 1); + return false; +} +SE_BIND_FUNC_AS_PROP_SET(js_assets_Skeleton_setJoints) +SE_BIND_FUNC(js_assets_Skeleton_setJoints) + +SE_DECLARE_FINALIZE_FUNC(js_cc_Skeleton_finalize) + +static bool js_assets_Skeleton_constructor(se::State& s) // NOLINT(readability-identifier-naming) constructor.c +{ + auto *ptr = JSB_MAKE_PRIVATE_OBJECT(cc::Skeleton); + s.thisObject()->setPrivateObject(ptr); + return true; +} +SE_BIND_CTOR(js_assets_Skeleton_constructor, __jsb_cc_Skeleton_class, js_cc_Skeleton_finalize) + +static bool js_cc_Skeleton_finalize(se::State& s) // NOLINT(readability-identifier-naming) +{ + return true; +} +SE_BIND_FINALIZE_FUNC(js_cc_Skeleton_finalize) + +bool js_register_assets_Skeleton(se::Object* obj) // NOLINT(readability-identifier-naming) +{ + auto* cls = se::Class::create("Skeleton", obj, __jsb_cc_Asset_proto, _SE(js_assets_Skeleton_constructor)); + + cls->defineProperty({"_joints", "joints"}, _SE(js_assets_Skeleton_getJoints_asGetter), _SE(js_assets_Skeleton_setJoints_asSetter)); + cls->defineProperty({"_hash", "hash"}, _SE(js_assets_Skeleton_getHashForJS_asGetter), _SE(js_assets_Skeleton_setHash_asSetter)); + cls->defineFunction("_getBindposes", _SE(js_assets_Skeleton_getBindposes)); + cls->defineFunction("getHash", _SE(js_assets_Skeleton_getHashForJS)); + cls->defineFunction("getInverseBindposes", _SE(js_assets_Skeleton_getInverseBindposes)); + cls->defineFunction("getJoints", _SE(js_assets_Skeleton_getJoints)); + cls->defineFunction("_setBindposes", _SE(js_assets_Skeleton_setBindposes)); + cls->defineFunction("setHash", _SE(js_assets_Skeleton_setHash)); + cls->defineFunction("setJoints", _SE(js_assets_Skeleton_setJoints)); + cls->defineFinalizeFunction(_SE(js_cc_Skeleton_finalize)); + cls->install(); + JSBClassType::registerClass(cls); + + __jsb_cc_Skeleton_proto = cls->getProto(); + __jsb_cc_Skeleton_class = cls; + + + se::ScriptEngine::getInstance()->clearException(); + return true; +} +bool register_all_assets(se::Object* obj) // NOLINT +{ + // Get the ns + se::Value nsVal; + if (!obj->getProperty("jsb", &nsVal, true)) + { + se::HandleObject jsobj(se::Object::createPlainObject()); + nsVal.setObject(jsobj); + obj->setProperty("jsb", nsVal); + } + se::Object* ns = nsVal.toObject(); + + js_register_assets_Asset(ns); + js_register_assets_BlendStateInfo(ns); + js_register_assets_BlendTargetInfo(ns); + js_register_assets_BoundingBox(ns); + js_register_assets_BufferAsset(ns); + js_register_assets_DepthStencilStateInfo(ns); + js_register_assets_EffectAsset(ns); + js_register_assets_Error(ns); + js_register_assets_IAttributeInfo(ns); + js_register_assets_IBlockInfo(ns); + js_register_assets_IBufferInfo(ns); + js_register_assets_IBuiltin(ns); + js_register_assets_IBuiltinInfo(ns); + js_register_assets_IBuiltins(ns); + js_register_assets_Mesh(ns); + js_register_assets_Mesh_ICreateInfo(ns); + js_register_assets_IDefineInfo(ns); + js_register_assets_IFlatBuffer(ns); + js_register_assets_IGeometricInfo(ns); + js_register_assets_IImageInfo(ns); + js_register_assets_IInputAttachmentInfo(ns); + js_register_assets_IMaterialInfo(ns); + js_register_assets_IMemoryImageSource(ns); + js_register_assets_IMeshBufferView(ns); + js_register_assets_IPassInfoFull(ns); + js_register_assets_IPassStates(ns); + js_register_assets_IPropertyInfo(ns); + js_register_assets_IRenderTextureCreateInfo(ns); + js_register_assets_ISamplerInfo(ns); + js_register_assets_ISamplerTextureInfo(ns); + js_register_assets_IShaderInfo(ns); + js_register_assets_IShaderSource(ns); + js_register_assets_Mesh_IStruct(ns); + js_register_assets_Mesh_ISubMesh(ns); + js_register_assets_ITechniqueInfo(ns); + js_register_assets_ITexture2DCreateInfo(ns); + js_register_assets_ITexture2DSerializeData(ns); + js_register_assets_ITextureCubeMipmap(ns); + js_register_assets_ITextureCubeSerializeData(ns); + js_register_assets_ITextureCubeSerializeMipmapData(ns); + js_register_assets_ITextureInfo(ns); + js_register_assets_Mesh_IVertexBundle(ns); + js_register_assets_ImageAsset(ns); + js_register_assets_Material(ns); + js_register_assets_Morph(ns); + js_register_assets_MorphRendering(ns); + js_register_assets_MorphRenderingInstance(ns); + js_register_assets_MorphTarget(ns); + js_register_assets_RasterizerStateInfo(ns); + js_register_assets_TextureBase(ns); + js_register_assets_RenderTexture(ns); + js_register_assets_RenderingSubMesh(ns); + js_register_assets_SceneAsset(ns); + js_register_assets_SimpleTexture(ns); + js_register_assets_Skeleton(ns); + js_register_assets_StdMorphRendering(ns); + js_register_assets_SubMeshMorph(ns); + js_register_assets_TextAsset(ns); + js_register_assets_Texture2D(ns); + js_register_assets_TextureCube(ns); + js_register_assets_VertexIdChannel(ns); + return true; +} + +// clang-format on \ No newline at end of file diff --git a/native/cocos/bindings/auto/jsb_assets_auto.h b/native/cocos/bindings/auto/jsb_assets_auto.h new file mode 100644 index 0000000000..fb27dc3394 --- /dev/null +++ b/native/cocos/bindings/auto/jsb_assets_auto.h @@ -0,0 +1,673 @@ +// clang-format off +#pragma once +#include "base/Config.h" +#include +#include "cocos/bindings/jswrapper/SeApi.h" +#include "cocos/bindings/manual/jsb_conversions.h" +#include "cocos/bindings/auto/jsb_gfx_auto.h" +#include "cocos/bindings/auto/jsb_pipeline_auto.h" +#include "cocos/core/assets/AssetsModuleHeader.h" +#include "cocos/3d/assets/Mesh.h" +#include "cocos/3d/assets/Morph.h" +#include "cocos/3d/assets/MorphRendering.h" +#include "cocos/3d/assets/Skeleton.h" + +bool register_all_assets(se::Object *obj); // NOLINT + +JSB_REGISTER_OBJECT_TYPE(cc::Error); +JSB_REGISTER_OBJECT_TYPE(cc::BoundingBox); +JSB_REGISTER_OBJECT_TYPE(cc::VertexIdChannel); +JSB_REGISTER_OBJECT_TYPE(cc::Asset); +JSB_REGISTER_OBJECT_TYPE(cc::BufferAsset); +JSB_REGISTER_OBJECT_TYPE(cc::TextureBase); +JSB_REGISTER_OBJECT_TYPE(cc::IPropertyInfo); +JSB_REGISTER_OBJECT_TYPE(cc::RasterizerStateInfo); +JSB_REGISTER_OBJECT_TYPE(cc::DepthStencilStateInfo); +JSB_REGISTER_OBJECT_TYPE(cc::BlendTargetInfo); +JSB_REGISTER_OBJECT_TYPE(cc::BlendStateInfo); +JSB_REGISTER_OBJECT_TYPE(cc::IPassStates); +JSB_REGISTER_OBJECT_TYPE(cc::IPassInfoFull); +JSB_REGISTER_OBJECT_TYPE(cc::ITechniqueInfo); +JSB_REGISTER_OBJECT_TYPE(cc::IBlockInfo); +JSB_REGISTER_OBJECT_TYPE(cc::ISamplerTextureInfo); +JSB_REGISTER_OBJECT_TYPE(cc::ITextureInfo); +JSB_REGISTER_OBJECT_TYPE(cc::ISamplerInfo); +JSB_REGISTER_OBJECT_TYPE(cc::IBufferInfo); +JSB_REGISTER_OBJECT_TYPE(cc::IImageInfo); +JSB_REGISTER_OBJECT_TYPE(cc::IInputAttachmentInfo); +JSB_REGISTER_OBJECT_TYPE(cc::IAttributeInfo); +JSB_REGISTER_OBJECT_TYPE(cc::IDefineInfo); +JSB_REGISTER_OBJECT_TYPE(cc::IBuiltin); +JSB_REGISTER_OBJECT_TYPE(cc::IBuiltinInfo); +JSB_REGISTER_OBJECT_TYPE(cc::IBuiltins); +JSB_REGISTER_OBJECT_TYPE(cc::IShaderSource); +JSB_REGISTER_OBJECT_TYPE(cc::IShaderInfo); +JSB_REGISTER_OBJECT_TYPE(cc::EffectAsset); +JSB_REGISTER_OBJECT_TYPE(cc::IMemoryImageSource); +JSB_REGISTER_OBJECT_TYPE(cc::ImageAsset); +JSB_REGISTER_OBJECT_TYPE(cc::IMaterialInfo); +JSB_REGISTER_OBJECT_TYPE(cc::Material); +JSB_REGISTER_OBJECT_TYPE(cc::IRenderTextureCreateInfo); +JSB_REGISTER_OBJECT_TYPE(cc::RenderTexture); +JSB_REGISTER_OBJECT_TYPE(cc::IMeshBufferView); +JSB_REGISTER_OBJECT_TYPE(cc::MorphTarget); +JSB_REGISTER_OBJECT_TYPE(cc::SubMeshMorph); +JSB_REGISTER_OBJECT_TYPE(cc::Morph); +JSB_REGISTER_OBJECT_TYPE(cc::IGeometricInfo); +JSB_REGISTER_OBJECT_TYPE(cc::IFlatBuffer); +JSB_REGISTER_OBJECT_TYPE(cc::RenderingSubMesh); +JSB_REGISTER_OBJECT_TYPE(cc::SceneAsset); +JSB_REGISTER_OBJECT_TYPE(cc::TextAsset); +JSB_REGISTER_OBJECT_TYPE(cc::SimpleTexture); +JSB_REGISTER_OBJECT_TYPE(cc::ITexture2DSerializeData); +JSB_REGISTER_OBJECT_TYPE(cc::ITexture2DCreateInfo); +JSB_REGISTER_OBJECT_TYPE(cc::Texture2D); +JSB_REGISTER_OBJECT_TYPE(cc::ITextureCubeMipmap); +JSB_REGISTER_OBJECT_TYPE(cc::ITextureCubeSerializeMipmapData); +JSB_REGISTER_OBJECT_TYPE(cc::ITextureCubeSerializeData); +JSB_REGISTER_OBJECT_TYPE(cc::TextureCube); +JSB_REGISTER_OBJECT_TYPE(cc::MorphRendering); +JSB_REGISTER_OBJECT_TYPE(cc::MorphRenderingInstance); +JSB_REGISTER_OBJECT_TYPE(cc::StdMorphRendering); +JSB_REGISTER_OBJECT_TYPE(cc::Mesh::IVertexBundle); +JSB_REGISTER_OBJECT_TYPE(cc::Mesh::ISubMesh); +JSB_REGISTER_OBJECT_TYPE(cc::Mesh::IStruct); +JSB_REGISTER_OBJECT_TYPE(cc::Mesh::ICreateInfo); +JSB_REGISTER_OBJECT_TYPE(cc::Mesh); +JSB_REGISTER_OBJECT_TYPE(cc::Skeleton); + + +extern se::Object *__jsb_cc_Error_proto; // NOLINT +extern se::Class * __jsb_cc_Error_class; // NOLINT + +bool js_register_cc_Error(se::Object *obj); // NOLINT + +template <> +bool sevalue_to_native(const se::Value &, cc::Error *, se::Object *ctx); //NOLINT + +extern se::Object *__jsb_cc_BoundingBox_proto; // NOLINT +extern se::Class * __jsb_cc_BoundingBox_class; // NOLINT + +bool js_register_cc_BoundingBox(se::Object *obj); // NOLINT + +template <> +bool sevalue_to_native(const se::Value &, cc::BoundingBox *, se::Object *ctx); //NOLINT + +extern se::Object *__jsb_cc_VertexIdChannel_proto; // NOLINT +extern se::Class * __jsb_cc_VertexIdChannel_class; // NOLINT + +bool js_register_cc_VertexIdChannel(se::Object *obj); // NOLINT + +template <> +bool sevalue_to_native(const se::Value &, cc::VertexIdChannel *, se::Object *ctx); //NOLINT + +extern se::Object *__jsb_cc_Asset_proto; // NOLINT +extern se::Class * __jsb_cc_Asset_class; // NOLINT + +bool js_register_cc_Asset(se::Object *obj); // NOLINT + +SE_DECLARE_FUNC(js_assets_Asset_addAssetRef); +SE_DECLARE_FUNC(js_assets_Asset_createNode); +SE_DECLARE_FUNC(js_assets_Asset_decAssetRef); +SE_DECLARE_FUNC(js_assets_Asset_deserialize); +SE_DECLARE_FUNC(js_assets_Asset_getNativeAsset); +SE_DECLARE_FUNC(js_assets_Asset_getRefCount); +SE_DECLARE_FUNC(js_assets_Asset_initDefault); +SE_DECLARE_FUNC(js_assets_Asset_onLoaded); +SE_DECLARE_FUNC(js_assets_Asset_serialize); +SE_DECLARE_FUNC(js_assets_Asset_setNativeAsset); +SE_DECLARE_FUNC(js_assets_Asset_validate); +SE_DECLARE_FUNC(js_assets_Asset_Asset); + +extern se::Object *__jsb_cc_BufferAsset_proto; // NOLINT +extern se::Class * __jsb_cc_BufferAsset_class; // NOLINT + +bool js_register_cc_BufferAsset(se::Object *obj); // NOLINT + +SE_DECLARE_FUNC(js_assets_BufferAsset_BufferAsset); + +extern se::Object *__jsb_cc_TextureBase_proto; // NOLINT +extern se::Class * __jsb_cc_TextureBase_class; // NOLINT + +bool js_register_cc_TextureBase(se::Object *obj); // NOLINT + +SE_DECLARE_FUNC(js_assets_TextureBase_getAnisotropy); +SE_DECLARE_FUNC(js_assets_TextureBase_getGFXSampler); +SE_DECLARE_FUNC(js_assets_TextureBase_getGFXTexture); +SE_DECLARE_FUNC(js_assets_TextureBase_getHashForJS); +SE_DECLARE_FUNC(js_assets_TextureBase_getId); +SE_DECLARE_FUNC(js_assets_TextureBase_getPixelFormat); +SE_DECLARE_FUNC(js_assets_TextureBase_getSamplerInfo); +SE_DECLARE_FUNC(js_assets_TextureBase_setAnisotropy); +SE_DECLARE_FUNC(js_assets_TextureBase_setFilters); +SE_DECLARE_FUNC(js_assets_TextureBase_setMipFilter); +SE_DECLARE_FUNC(js_assets_TextureBase_setWrapMode); + +extern se::Object *__jsb_cc_IPropertyInfo_proto; // NOLINT +extern se::Class * __jsb_cc_IPropertyInfo_class; // NOLINT + +bool js_register_cc_IPropertyInfo(se::Object *obj); // NOLINT + +template <> +bool sevalue_to_native(const se::Value &, cc::IPropertyInfo *, se::Object *ctx); //NOLINT + +extern se::Object *__jsb_cc_RasterizerStateInfo_proto; // NOLINT +extern se::Class * __jsb_cc_RasterizerStateInfo_class; // NOLINT + +bool js_register_cc_RasterizerStateInfo(se::Object *obj); // NOLINT + +template <> +bool sevalue_to_native(const se::Value &, cc::RasterizerStateInfo *, se::Object *ctx); //NOLINT + +extern se::Object *__jsb_cc_DepthStencilStateInfo_proto; // NOLINT +extern se::Class * __jsb_cc_DepthStencilStateInfo_class; // NOLINT + +bool js_register_cc_DepthStencilStateInfo(se::Object *obj); // NOLINT + +template <> +bool sevalue_to_native(const se::Value &, cc::DepthStencilStateInfo *, se::Object *ctx); //NOLINT + +extern se::Object *__jsb_cc_BlendTargetInfo_proto; // NOLINT +extern se::Class * __jsb_cc_BlendTargetInfo_class; // NOLINT + +bool js_register_cc_BlendTargetInfo(se::Object *obj); // NOLINT + +template <> +bool sevalue_to_native(const se::Value &, cc::BlendTargetInfo *, se::Object *ctx); //NOLINT + +extern se::Object *__jsb_cc_BlendStateInfo_proto; // NOLINT +extern se::Class * __jsb_cc_BlendStateInfo_class; // NOLINT + +bool js_register_cc_BlendStateInfo(se::Object *obj); // NOLINT + +template <> +bool sevalue_to_native(const se::Value &, cc::BlendStateInfo *, se::Object *ctx); //NOLINT + +extern se::Object *__jsb_cc_IPassStates_proto; // NOLINT +extern se::Class * __jsb_cc_IPassStates_class; // NOLINT + +bool js_register_cc_IPassStates(se::Object *obj); // NOLINT + +template <> +bool sevalue_to_native(const se::Value &, cc::IPassStates *, se::Object *ctx); //NOLINT +SE_DECLARE_FUNC(js_assets_IPassStates_overrides); + +extern se::Object *__jsb_cc_IPassInfoFull_proto; // NOLINT +extern se::Class * __jsb_cc_IPassInfoFull_class; // NOLINT + +bool js_register_cc_IPassInfoFull(se::Object *obj); // NOLINT + +template <> +bool sevalue_to_native(const se::Value &, cc::IPassInfoFull *, se::Object *ctx); //NOLINT + +extern se::Object *__jsb_cc_ITechniqueInfo_proto; // NOLINT +extern se::Class * __jsb_cc_ITechniqueInfo_class; // NOLINT + +bool js_register_cc_ITechniqueInfo(se::Object *obj); // NOLINT + +template <> +bool sevalue_to_native(const se::Value &, cc::ITechniqueInfo *, se::Object *ctx); //NOLINT + +extern se::Object *__jsb_cc_IBlockInfo_proto; // NOLINT +extern se::Class * __jsb_cc_IBlockInfo_class; // NOLINT + +bool js_register_cc_IBlockInfo(se::Object *obj); // NOLINT + +template <> +bool sevalue_to_native(const se::Value &, cc::IBlockInfo *, se::Object *ctx); //NOLINT + +extern se::Object *__jsb_cc_ISamplerTextureInfo_proto; // NOLINT +extern se::Class * __jsb_cc_ISamplerTextureInfo_class; // NOLINT + +bool js_register_cc_ISamplerTextureInfo(se::Object *obj); // NOLINT + +template <> +bool sevalue_to_native(const se::Value &, cc::ISamplerTextureInfo *, se::Object *ctx); //NOLINT + +extern se::Object *__jsb_cc_ITextureInfo_proto; // NOLINT +extern se::Class * __jsb_cc_ITextureInfo_class; // NOLINT + +bool js_register_cc_ITextureInfo(se::Object *obj); // NOLINT + +template <> +bool sevalue_to_native(const se::Value &, cc::ITextureInfo *, se::Object *ctx); //NOLINT + +extern se::Object *__jsb_cc_ISamplerInfo_proto; // NOLINT +extern se::Class * __jsb_cc_ISamplerInfo_class; // NOLINT + +bool js_register_cc_ISamplerInfo(se::Object *obj); // NOLINT + +template <> +bool sevalue_to_native(const se::Value &, cc::ISamplerInfo *, se::Object *ctx); //NOLINT + +extern se::Object *__jsb_cc_IBufferInfo_proto; // NOLINT +extern se::Class * __jsb_cc_IBufferInfo_class; // NOLINT + +bool js_register_cc_IBufferInfo(se::Object *obj); // NOLINT + +template <> +bool sevalue_to_native(const se::Value &, cc::IBufferInfo *, se::Object *ctx); //NOLINT + +extern se::Object *__jsb_cc_IImageInfo_proto; // NOLINT +extern se::Class * __jsb_cc_IImageInfo_class; // NOLINT + +bool js_register_cc_IImageInfo(se::Object *obj); // NOLINT + +template <> +bool sevalue_to_native(const se::Value &, cc::IImageInfo *, se::Object *ctx); //NOLINT + +extern se::Object *__jsb_cc_IInputAttachmentInfo_proto; // NOLINT +extern se::Class * __jsb_cc_IInputAttachmentInfo_class; // NOLINT + +bool js_register_cc_IInputAttachmentInfo(se::Object *obj); // NOLINT + +template <> +bool sevalue_to_native(const se::Value &, cc::IInputAttachmentInfo *, se::Object *ctx); //NOLINT + +extern se::Object *__jsb_cc_IAttributeInfo_proto; // NOLINT +extern se::Class * __jsb_cc_IAttributeInfo_class; // NOLINT + +bool js_register_cc_IAttributeInfo(se::Object *obj); // NOLINT + +template <> +bool sevalue_to_native(const se::Value &, cc::IAttributeInfo *, se::Object *ctx); //NOLINT + +extern se::Object *__jsb_cc_IDefineInfo_proto; // NOLINT +extern se::Class * __jsb_cc_IDefineInfo_class; // NOLINT + +bool js_register_cc_IDefineInfo(se::Object *obj); // NOLINT + +template <> +bool sevalue_to_native(const se::Value &, cc::IDefineInfo *, se::Object *ctx); //NOLINT + +extern se::Object *__jsb_cc_IBuiltin_proto; // NOLINT +extern se::Class * __jsb_cc_IBuiltin_class; // NOLINT + +bool js_register_cc_IBuiltin(se::Object *obj); // NOLINT + +template <> +bool sevalue_to_native(const se::Value &, cc::IBuiltin *, se::Object *ctx); //NOLINT + +extern se::Object *__jsb_cc_IBuiltinInfo_proto; // NOLINT +extern se::Class * __jsb_cc_IBuiltinInfo_class; // NOLINT + +bool js_register_cc_IBuiltinInfo(se::Object *obj); // NOLINT + +template <> +bool sevalue_to_native(const se::Value &, cc::IBuiltinInfo *, se::Object *ctx); //NOLINT + +extern se::Object *__jsb_cc_IBuiltins_proto; // NOLINT +extern se::Class * __jsb_cc_IBuiltins_class; // NOLINT + +bool js_register_cc_IBuiltins(se::Object *obj); // NOLINT + +template <> +bool sevalue_to_native(const se::Value &, cc::IBuiltins *, se::Object *ctx); //NOLINT + +extern se::Object *__jsb_cc_IShaderSource_proto; // NOLINT +extern se::Class * __jsb_cc_IShaderSource_class; // NOLINT + +bool js_register_cc_IShaderSource(se::Object *obj); // NOLINT + +template <> +bool sevalue_to_native(const se::Value &, cc::IShaderSource *, se::Object *ctx); //NOLINT + +extern se::Object *__jsb_cc_IShaderInfo_proto; // NOLINT +extern se::Class * __jsb_cc_IShaderInfo_class; // NOLINT + +bool js_register_cc_IShaderInfo(se::Object *obj); // NOLINT + +template <> +bool sevalue_to_native(const se::Value &, cc::IShaderInfo *, se::Object *ctx); //NOLINT +SE_DECLARE_FUNC(js_assets_IShaderInfo_getSource); + +extern se::Object *__jsb_cc_EffectAsset_proto; // NOLINT +extern se::Class * __jsb_cc_EffectAsset_class; // NOLINT + +bool js_register_cc_EffectAsset(se::Object *obj); // NOLINT + +SE_DECLARE_FUNC(js_assets_EffectAsset_get); +SE_DECLARE_FUNC(js_assets_EffectAsset_getAll); +SE_DECLARE_FUNC(js_assets_EffectAsset_registerAsset); +SE_DECLARE_FUNC(js_assets_EffectAsset_remove); +SE_DECLARE_FUNC(js_assets_EffectAsset_EffectAsset); + +extern se::Object *__jsb_cc_IMemoryImageSource_proto; // NOLINT +extern se::Class * __jsb_cc_IMemoryImageSource_class; // NOLINT + +bool js_register_cc_IMemoryImageSource(se::Object *obj); // NOLINT + +template <> +bool sevalue_to_native(const se::Value &, cc::IMemoryImageSource *, se::Object *ctx); //NOLINT + +extern se::Object *__jsb_cc_ImageAsset_proto; // NOLINT +extern se::Class * __jsb_cc_ImageAsset_class; // NOLINT + +bool js_register_cc_ImageAsset(se::Object *obj); // NOLINT + +SE_DECLARE_FUNC(js_assets_ImageAsset_getData); +SE_DECLARE_FUNC(js_assets_ImageAsset_getHeight); +SE_DECLARE_FUNC(js_assets_ImageAsset_getWidth); +SE_DECLARE_FUNC(js_assets_ImageAsset_isCompressed); +SE_DECLARE_FUNC(js_assets_ImageAsset_setHeight); +SE_DECLARE_FUNC(js_assets_ImageAsset_setWidth); +SE_DECLARE_FUNC(js_assets_ImageAsset_ImageAsset); + +extern se::Object *__jsb_cc_IMaterialInfo_proto; // NOLINT +extern se::Class * __jsb_cc_IMaterialInfo_class; // NOLINT + +bool js_register_cc_IMaterialInfo(se::Object *obj); // NOLINT + +template <> +bool sevalue_to_native(const se::Value &, cc::IMaterialInfo *, se::Object *ctx); //NOLINT + +extern se::Object *__jsb_cc_Material_proto; // NOLINT +extern se::Class * __jsb_cc_Material_class; // NOLINT + +bool js_register_cc_Material(se::Object *obj); // NOLINT + +SE_DECLARE_FUNC(js_assets_Material_copy); +SE_DECLARE_FUNC(js_assets_Material_getPasses); +SE_DECLARE_FUNC(js_assets_Material_getProperty); +SE_DECLARE_FUNC(js_assets_Material_initialize); +SE_DECLARE_FUNC(js_assets_Material_overridePipelineStates); +SE_DECLARE_FUNC(js_assets_Material_recompileShaders); +SE_DECLARE_FUNC(js_assets_Material_reset); +SE_DECLARE_FUNC(js_assets_Material_resetUniforms); +SE_DECLARE_FUNC(js_assets_Material_setPropertyColor); +SE_DECLARE_FUNC(js_assets_Material_setPropertyColorArray); +SE_DECLARE_FUNC(js_assets_Material_setPropertyFloat32); +SE_DECLARE_FUNC(js_assets_Material_setPropertyFloat32Array); +SE_DECLARE_FUNC(js_assets_Material_setPropertyGFXTexture); +SE_DECLARE_FUNC(js_assets_Material_setPropertyGFXTextureArray); +SE_DECLARE_FUNC(js_assets_Material_setPropertyInt32); +SE_DECLARE_FUNC(js_assets_Material_setPropertyInt32Array); +SE_DECLARE_FUNC(js_assets_Material_setPropertyMat3); +SE_DECLARE_FUNC(js_assets_Material_setPropertyMat3Array); +SE_DECLARE_FUNC(js_assets_Material_setPropertyMat4); +SE_DECLARE_FUNC(js_assets_Material_setPropertyMat4Array); +SE_DECLARE_FUNC(js_assets_Material_setPropertyQuaternion); +SE_DECLARE_FUNC(js_assets_Material_setPropertyQuaternionArray); +SE_DECLARE_FUNC(js_assets_Material_setPropertyTextureBase); +SE_DECLARE_FUNC(js_assets_Material_setPropertyTextureBaseArray); +SE_DECLARE_FUNC(js_assets_Material_setPropertyVec2); +SE_DECLARE_FUNC(js_assets_Material_setPropertyVec2Array); +SE_DECLARE_FUNC(js_assets_Material_setPropertyVec3); +SE_DECLARE_FUNC(js_assets_Material_setPropertyVec3Array); +SE_DECLARE_FUNC(js_assets_Material_setPropertyVec4); +SE_DECLARE_FUNC(js_assets_Material_setPropertyVec4Array); +SE_DECLARE_FUNC(js_assets_Material_update); +SE_DECLARE_FUNC(js_assets_Material_getHashForMaterialForJS); +SE_DECLARE_FUNC(js_assets_Material_Material); + +extern se::Object *__jsb_cc_IRenderTextureCreateInfo_proto; // NOLINT +extern se::Class * __jsb_cc_IRenderTextureCreateInfo_class; // NOLINT + +bool js_register_cc_IRenderTextureCreateInfo(se::Object *obj); // NOLINT + +template <> +bool sevalue_to_native(const se::Value &, cc::IRenderTextureCreateInfo *, se::Object *ctx); //NOLINT + +extern se::Object *__jsb_cc_RenderTexture_proto; // NOLINT +extern se::Class * __jsb_cc_RenderTexture_class; // NOLINT + +bool js_register_cc_RenderTexture(se::Object *obj); // NOLINT + +SE_DECLARE_FUNC(js_assets_RenderTexture_initWindow); +SE_DECLARE_FUNC(js_assets_RenderTexture_initialize); +SE_DECLARE_FUNC(js_assets_RenderTexture_readPixels); +SE_DECLARE_FUNC(js_assets_RenderTexture_reset); +SE_DECLARE_FUNC(js_assets_RenderTexture_resize); +SE_DECLARE_FUNC(js_assets_RenderTexture_RenderTexture); + +extern se::Object *__jsb_cc_IMeshBufferView_proto; // NOLINT +extern se::Class * __jsb_cc_IMeshBufferView_class; // NOLINT + +bool js_register_cc_IMeshBufferView(se::Object *obj); // NOLINT + +template <> +bool sevalue_to_native(const se::Value &, cc::IMeshBufferView *, se::Object *ctx); //NOLINT + +extern se::Object *__jsb_cc_MorphTarget_proto; // NOLINT +extern se::Class * __jsb_cc_MorphTarget_class; // NOLINT + +bool js_register_cc_MorphTarget(se::Object *obj); // NOLINT + +template <> +bool sevalue_to_native(const se::Value &, cc::MorphTarget *, se::Object *ctx); //NOLINT + +extern se::Object *__jsb_cc_SubMeshMorph_proto; // NOLINT +extern se::Class * __jsb_cc_SubMeshMorph_class; // NOLINT + +bool js_register_cc_SubMeshMorph(se::Object *obj); // NOLINT + +template <> +bool sevalue_to_native(const se::Value &, cc::SubMeshMorph *, se::Object *ctx); //NOLINT + +extern se::Object *__jsb_cc_Morph_proto; // NOLINT +extern se::Class * __jsb_cc_Morph_class; // NOLINT + +bool js_register_cc_Morph(se::Object *obj); // NOLINT + +template <> +bool sevalue_to_native(const se::Value &, cc::Morph *, se::Object *ctx); //NOLINT + +extern se::Object *__jsb_cc_IGeometricInfo_proto; // NOLINT +extern se::Class * __jsb_cc_IGeometricInfo_class; // NOLINT + +bool js_register_cc_IGeometricInfo(se::Object *obj); // NOLINT + +template <> +bool sevalue_to_native(const se::Value &, cc::IGeometricInfo *, se::Object *ctx); //NOLINT + +extern se::Object *__jsb_cc_IFlatBuffer_proto; // NOLINT +extern se::Class * __jsb_cc_IFlatBuffer_class; // NOLINT + +bool js_register_cc_IFlatBuffer(se::Object *obj); // NOLINT + +template <> +bool sevalue_to_native(const se::Value &, cc::IFlatBuffer *, se::Object *ctx); //NOLINT + +extern se::Object *__jsb_cc_RenderingSubMesh_proto; // NOLINT +extern se::Class * __jsb_cc_RenderingSubMesh_class; // NOLINT + +bool js_register_cc_RenderingSubMesh(se::Object *obj); // NOLINT + +SE_DECLARE_FUNC(js_assets_RenderingSubMesh_enableVertexIdChannel); +SE_DECLARE_FUNC(js_assets_RenderingSubMesh_genFlatBuffers); +SE_DECLARE_FUNC(js_assets_RenderingSubMesh_getAttributes); +SE_DECLARE_FUNC(js_assets_RenderingSubMesh_getGeometricInfo); +SE_DECLARE_FUNC(js_assets_RenderingSubMesh_getIndexBuffer); +SE_DECLARE_FUNC(js_assets_RenderingSubMesh_getVertexBuffers); +SE_DECLARE_FUNC(js_assets_RenderingSubMesh_indirectBuffer); +SE_DECLARE_FUNC(js_assets_RenderingSubMesh_RenderingSubMesh); + +extern se::Object *__jsb_cc_SceneAsset_proto; // NOLINT +extern se::Class * __jsb_cc_SceneAsset_class; // NOLINT + +bool js_register_cc_SceneAsset(se::Object *obj); // NOLINT + +SE_DECLARE_FUNC(js_assets_SceneAsset_getScene); +SE_DECLARE_FUNC(js_assets_SceneAsset_setScene); +SE_DECLARE_FUNC(js_assets_SceneAsset_SceneAsset); + +extern se::Object *__jsb_cc_TextAsset_proto; // NOLINT +extern se::Class * __jsb_cc_TextAsset_class; // NOLINT + +bool js_register_cc_TextAsset(se::Object *obj); // NOLINT + +SE_DECLARE_FUNC(js_assets_TextAsset_TextAsset); + +extern se::Object *__jsb_cc_SimpleTexture_proto; // NOLINT +extern se::Class * __jsb_cc_SimpleTexture_class; // NOLINT + +bool js_register_cc_SimpleTexture(se::Object *obj); // NOLINT + +SE_DECLARE_FUNC(js_assets_SimpleTexture_assignImage); +SE_DECLARE_FUNC(js_assets_SimpleTexture_checkTextureLoaded); +SE_DECLARE_FUNC(js_assets_SimpleTexture_updateImage); +SE_DECLARE_FUNC(js_assets_SimpleTexture_updateMipmaps); +SE_DECLARE_FUNC(js_assets_SimpleTexture_uploadData); + +extern se::Object *__jsb_cc_ITexture2DSerializeData_proto; // NOLINT +extern se::Class * __jsb_cc_ITexture2DSerializeData_class; // NOLINT + +bool js_register_cc_ITexture2DSerializeData(se::Object *obj); // NOLINT + +template <> +bool sevalue_to_native(const se::Value &, cc::ITexture2DSerializeData *, se::Object *ctx); //NOLINT + +extern se::Object *__jsb_cc_ITexture2DCreateInfo_proto; // NOLINT +extern se::Class * __jsb_cc_ITexture2DCreateInfo_class; // NOLINT + +bool js_register_cc_ITexture2DCreateInfo(se::Object *obj); // NOLINT + +template <> +bool sevalue_to_native(const se::Value &, cc::ITexture2DCreateInfo *, se::Object *ctx); //NOLINT + +extern se::Object *__jsb_cc_Texture2D_proto; // NOLINT +extern se::Class * __jsb_cc_Texture2D_class; // NOLINT + +bool js_register_cc_Texture2D(se::Object *obj); // NOLINT + +SE_DECLARE_FUNC(js_assets_Texture2D_create); +SE_DECLARE_FUNC(js_assets_Texture2D_description); +SE_DECLARE_FUNC(js_assets_Texture2D_getGfxTextureCreateInfo); +SE_DECLARE_FUNC(js_assets_Texture2D_getHtmlElementObj); +SE_DECLARE_FUNC(js_assets_Texture2D_getImage); +SE_DECLARE_FUNC(js_assets_Texture2D_getMipmaps); +SE_DECLARE_FUNC(js_assets_Texture2D_getMipmapsUuids); +SE_DECLARE_FUNC(js_assets_Texture2D_initialize); +SE_DECLARE_FUNC(js_assets_Texture2D_releaseTexture); +SE_DECLARE_FUNC(js_assets_Texture2D_reset); +SE_DECLARE_FUNC(js_assets_Texture2D_setImage); +SE_DECLARE_FUNC(js_assets_Texture2D_setMipmaps); +SE_DECLARE_FUNC(js_assets_Texture2D_syncMipmapsForJS); +SE_DECLARE_FUNC(js_assets_Texture2D_Texture2D); + +extern se::Object *__jsb_cc_ITextureCubeMipmap_proto; // NOLINT +extern se::Class * __jsb_cc_ITextureCubeMipmap_class; // NOLINT + +bool js_register_cc_ITextureCubeMipmap(se::Object *obj); // NOLINT + +template <> +bool sevalue_to_native(const se::Value &, cc::ITextureCubeMipmap *, se::Object *ctx); //NOLINT + +extern se::Object *__jsb_cc_ITextureCubeSerializeMipmapData_proto; // NOLINT +extern se::Class * __jsb_cc_ITextureCubeSerializeMipmapData_class; // NOLINT + +bool js_register_cc_ITextureCubeSerializeMipmapData(se::Object *obj); // NOLINT + +template <> +bool sevalue_to_native(const se::Value &, cc::ITextureCubeSerializeMipmapData *, se::Object *ctx); //NOLINT + +extern se::Object *__jsb_cc_ITextureCubeSerializeData_proto; // NOLINT +extern se::Class * __jsb_cc_ITextureCubeSerializeData_class; // NOLINT + +bool js_register_cc_ITextureCubeSerializeData(se::Object *obj); // NOLINT + +template <> +bool sevalue_to_native(const se::Value &, cc::ITextureCubeSerializeData *, se::Object *ctx); //NOLINT + +extern se::Object *__jsb_cc_TextureCube_proto; // NOLINT +extern se::Class * __jsb_cc_TextureCube_class; // NOLINT + +bool js_register_cc_TextureCube(se::Object *obj); // NOLINT + +SE_DECLARE_FUNC(js_assets_TextureCube_getGfxTextureCreateInfo); +SE_DECLARE_FUNC(js_assets_TextureCube_getImage); +SE_DECLARE_FUNC(js_assets_TextureCube_getMipmaps); +SE_DECLARE_FUNC(js_assets_TextureCube_initialize); +SE_DECLARE_FUNC(js_assets_TextureCube_releaseTexture); +SE_DECLARE_FUNC(js_assets_TextureCube_reset); +SE_DECLARE_FUNC(js_assets_TextureCube_setImage); +SE_DECLARE_FUNC(js_assets_TextureCube_setMipmaps); +SE_DECLARE_FUNC(js_assets_TextureCube_fromTexture2DArray); +SE_DECLARE_FUNC(js_assets_TextureCube_TextureCube); + +extern se::Object *__jsb_cc_MorphRendering_proto; // NOLINT +extern se::Class * __jsb_cc_MorphRendering_class; // NOLINT + +bool js_register_cc_MorphRendering(se::Object *obj); // NOLINT + +SE_DECLARE_FUNC(js_assets_MorphRendering_createInstance); + +extern se::Object *__jsb_cc_MorphRenderingInstance_proto; // NOLINT +extern se::Class * __jsb_cc_MorphRenderingInstance_class; // NOLINT + +bool js_register_cc_MorphRenderingInstance(se::Object *obj); // NOLINT + +SE_DECLARE_FUNC(js_assets_MorphRenderingInstance_adaptPipelineState); +SE_DECLARE_FUNC(js_assets_MorphRenderingInstance_destroy); +SE_DECLARE_FUNC(js_assets_MorphRenderingInstance_requiredPatches); +SE_DECLARE_FUNC(js_assets_MorphRenderingInstance_setWeights); + +extern se::Object *__jsb_cc_StdMorphRendering_proto; // NOLINT +extern se::Class * __jsb_cc_StdMorphRendering_class; // NOLINT + +bool js_register_cc_StdMorphRendering(se::Object *obj); // NOLINT + +SE_DECLARE_FUNC(js_assets_StdMorphRendering_StdMorphRendering); + +extern se::Object *__jsb_cc_Mesh_IVertexBundle_proto; // NOLINT +extern se::Class * __jsb_cc_Mesh_IVertexBundle_class; // NOLINT + +bool js_register_cc_Mesh_IVertexBundle(se::Object *obj); // NOLINT + +template <> +bool sevalue_to_native(const se::Value &, cc::Mesh::IVertexBundle *, se::Object *ctx); //NOLINT + +extern se::Object *__jsb_cc_Mesh_ISubMesh_proto; // NOLINT +extern se::Class * __jsb_cc_Mesh_ISubMesh_class; // NOLINT + +bool js_register_cc_Mesh_ISubMesh(se::Object *obj); // NOLINT + +template <> +bool sevalue_to_native(const se::Value &, cc::Mesh::ISubMesh *, se::Object *ctx); //NOLINT + +extern se::Object *__jsb_cc_Mesh_IStruct_proto; // NOLINT +extern se::Class * __jsb_cc_Mesh_IStruct_class; // NOLINT + +bool js_register_cc_Mesh_IStruct(se::Object *obj); // NOLINT + +template <> +bool sevalue_to_native(const se::Value &, cc::Mesh::IStruct *, se::Object *ctx); //NOLINT + +extern se::Object *__jsb_cc_Mesh_ICreateInfo_proto; // NOLINT +extern se::Class * __jsb_cc_Mesh_ICreateInfo_class; // NOLINT + +bool js_register_cc_Mesh_ICreateInfo(se::Object *obj); // NOLINT + +template <> +bool sevalue_to_native(const se::Value &, cc::Mesh::ICreateInfo *, se::Object *ctx); //NOLINT + +extern se::Object *__jsb_cc_Mesh_proto; // NOLINT +extern se::Class * __jsb_cc_Mesh_class; // NOLINT + +bool js_register_cc_Mesh(se::Object *obj); // NOLINT + +SE_DECLARE_FUNC(js_assets_Mesh_assign); +SE_DECLARE_FUNC(js_assets_Mesh_copyAttribute); +SE_DECLARE_FUNC(js_assets_Mesh_copyIndices); +SE_DECLARE_FUNC(js_assets_Mesh_destroyRenderingMesh); +SE_DECLARE_FUNC(js_assets_Mesh_getBoneSpaceBounds); +SE_DECLARE_FUNC(js_assets_Mesh_getStruct); +SE_DECLARE_FUNC(js_assets_Mesh_initialize); +SE_DECLARE_FUNC(js_assets_Mesh_merge); +SE_DECLARE_FUNC(js_assets_Mesh_readAttribute); +SE_DECLARE_FUNC(js_assets_Mesh_readIndices); +SE_DECLARE_FUNC(js_assets_Mesh_reset); +SE_DECLARE_FUNC(js_assets_Mesh_setStruct); +SE_DECLARE_FUNC(js_assets_Mesh_validateMergingMesh); +SE_DECLARE_FUNC(js_assets_Mesh_Mesh); + +extern se::Object *__jsb_cc_Skeleton_proto; // NOLINT +extern se::Class * __jsb_cc_Skeleton_class; // NOLINT + +bool js_register_cc_Skeleton(se::Object *obj); // NOLINT + +SE_DECLARE_FUNC(js_assets_Skeleton_getBindposes); +SE_DECLARE_FUNC(js_assets_Skeleton_getInverseBindposes); +SE_DECLARE_FUNC(js_assets_Skeleton_setBindposes); +SE_DECLARE_FUNC(js_assets_Skeleton_Skeleton); + // clang-format on \ No newline at end of file diff --git a/native/cocos/bindings/auto/jsb_audio_auto.cpp b/native/cocos/bindings/auto/jsb_audio_auto.cpp index 1788b4d570..e4a529c0f0 100644 --- a/native/cocos/bindings/auto/jsb_audio_auto.cpp +++ b/native/cocos/bindings/auto/jsb_audio_auto.cpp @@ -1,3 +1,5 @@ + +// clang-format off #include "cocos/bindings/auto/jsb_audio_auto.h" #if (USE_AUDIO > 0) #include "cocos/bindings/manual/jsb_conversions.h" @@ -11,8 +13,8 @@ #ifndef JSB_FREE #define JSB_FREE(ptr) delete ptr #endif -se::Object* __jsb_cc_AudioProfile_proto = nullptr; -se::Class* __jsb_cc_AudioProfile_class = nullptr; +se::Object* __jsb_cc_AudioProfile_proto = nullptr; // NOLINT +se::Class* __jsb_cc_AudioProfile_class = nullptr; // NOLINT static bool js_audio_AudioProfile_get_name(se::State& s) // NOLINT(readability-identifier-naming) { @@ -99,24 +101,14 @@ SE_DECLARE_FINALIZE_FUNC(js_cc_AudioProfile_finalize) static bool js_audio_AudioProfile_constructor(se::State& s) // NOLINT(readability-identifier-naming) constructor.c { - cc::AudioProfile* cobj = JSB_ALLOC(cc::AudioProfile); - s.thisObject()->setPrivateData(cobj); - se::NonRefNativePtrCreatedByCtorMap::emplace(cobj); + auto *ptr = JSB_MAKE_PRIVATE_OBJECT(cc::AudioProfile); + s.thisObject()->setPrivateObject(ptr); return true; } SE_BIND_CTOR(js_audio_AudioProfile_constructor, __jsb_cc_AudioProfile_class, js_cc_AudioProfile_finalize) - - static bool js_cc_AudioProfile_finalize(se::State& s) // NOLINT(readability-identifier-naming) { - auto iter = se::NonRefNativePtrCreatedByCtorMap::find(SE_THIS_OBJECT(s)); - if (iter != se::NonRefNativePtrCreatedByCtorMap::end()) - { - se::NonRefNativePtrCreatedByCtorMap::erase(iter); - auto* cobj = SE_THIS_OBJECT(s); - JSB_FREE(cobj); - } return true; } SE_BIND_FINALIZE_FUNC(js_cc_AudioProfile_finalize) @@ -135,30 +127,14 @@ bool js_register_audio_AudioProfile(se::Object* obj) // NOLINT(readability-ident __jsb_cc_AudioProfile_proto = cls->getProto(); __jsb_cc_AudioProfile_class = cls; + se::ScriptEngine::getInstance()->clearException(); return true; } -se::Object* __jsb_cc_AudioEngine_proto = nullptr; -se::Class* __jsb_cc_AudioEngine_class = nullptr; +se::Object* __jsb_cc_AudioEngine_proto = nullptr; // NOLINT +se::Class* __jsb_cc_AudioEngine_class = nullptr; // NOLINT -static bool js_audio_AudioEngine_lazyInit(se::State& s) // NOLINT(readability-identifier-naming) -{ - const auto& args = s.args(); - size_t argc = args.size(); - CC_UNUSED bool ok = true; - if (argc == 0) { - bool result = cc::AudioEngine::lazyInit(); - ok &= nativevalue_to_se(result, s.rval(), nullptr /*ctx*/); - SE_PRECONDITION2(ok, false, "js_audio_AudioEngine_lazyInit : Error processing arguments"); - SE_HOLD_RETURN_VALUE(result, s.thisObject(), s.rval()); - return true; - } - SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 0); - return false; -} -SE_BIND_FUNC(js_audio_AudioEngine_lazyInit) - -static bool js_audio_AudioEngine_end(se::State& s) // NOLINT(readability-identifier-naming) +static bool js_audio_AudioEngine_end_static(se::State& s) // NOLINT(readability-identifier-naming) { const auto& args = s.args(); size_t argc = args.size(); @@ -169,9 +145,29 @@ static bool js_audio_AudioEngine_end(se::State& s) // NOLINT(readability-identif SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 0); return false; } -SE_BIND_FUNC(js_audio_AudioEngine_end) +SE_BIND_FUNC(js_audio_AudioEngine_end_static) -static bool js_audio_AudioEngine_getDefaultProfile(se::State& s) // NOLINT(readability-identifier-naming) +static bool js_audio_AudioEngine_getCurrentTime_static(se::State& s) // NOLINT(readability-identifier-naming) +{ + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 1) { + HolderType arg0 = {}; + ok &= sevalue_to_native(args[0], &arg0, nullptr); + SE_PRECONDITION2(ok, false, "js_audio_AudioEngine_getCurrentTime_static : Error processing arguments"); + float result = cc::AudioEngine::getCurrentTime(arg0.value()); + ok &= nativevalue_to_se(result, s.rval(), nullptr /*ctx*/); + SE_PRECONDITION2(ok, false, "js_audio_AudioEngine_getCurrentTime_static : Error processing arguments"); + SE_HOLD_RETURN_VALUE(result, s.thisObject(), s.rval()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 1); + return false; +} +SE_BIND_FUNC(js_audio_AudioEngine_getCurrentTime_static) + +static bool js_audio_AudioEngine_getDefaultProfile_static(se::State& s) // NOLINT(readability-identifier-naming) { const auto& args = s.args(); size_t argc = args.size(); @@ -179,16 +175,36 @@ static bool js_audio_AudioEngine_getDefaultProfile(se::State& s) // NOLINT(reada if (argc == 0) { cc::AudioProfile* result = cc::AudioEngine::getDefaultProfile(); ok &= nativevalue_to_se(result, s.rval(), nullptr /*ctx*/); - SE_PRECONDITION2(ok, false, "js_audio_AudioEngine_getDefaultProfile : Error processing arguments"); + SE_PRECONDITION2(ok, false, "js_audio_AudioEngine_getDefaultProfile_static : Error processing arguments"); SE_HOLD_RETURN_VALUE(result, s.thisObject(), s.rval()); return true; } SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 0); return false; } -SE_BIND_FUNC(js_audio_AudioEngine_getDefaultProfile) +SE_BIND_FUNC(js_audio_AudioEngine_getDefaultProfile_static) -static bool js_audio_AudioEngine_play2d(se::State& s) // NOLINT(readability-identifier-naming) +static bool js_audio_AudioEngine_getDuration_static(se::State& s) // NOLINT(readability-identifier-naming) +{ + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 1) { + HolderType arg0 = {}; + ok &= sevalue_to_native(args[0], &arg0, nullptr); + SE_PRECONDITION2(ok, false, "js_audio_AudioEngine_getDuration_static : Error processing arguments"); + float result = cc::AudioEngine::getDuration(arg0.value()); + ok &= nativevalue_to_se(result, s.rval(), nullptr /*ctx*/); + SE_PRECONDITION2(ok, false, "js_audio_AudioEngine_getDuration_static : Error processing arguments"); + SE_HOLD_RETURN_VALUE(result, s.thisObject(), s.rval()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 1); + return false; +} +SE_BIND_FUNC(js_audio_AudioEngine_getDuration_static) + +static bool js_audio_AudioEngine_getDurationFromFile_static(se::State& s) // NOLINT(readability-identifier-naming) { const auto& args = s.args(); size_t argc = args.size(); @@ -196,10 +212,222 @@ static bool js_audio_AudioEngine_play2d(se::State& s) // NOLINT(readability-iden if (argc == 1) { HolderType arg0 = {}; ok &= sevalue_to_native(args[0], &arg0, nullptr); - SE_PRECONDITION2(ok, false, "js_audio_AudioEngine_play2d : Error processing arguments"); + SE_PRECONDITION2(ok, false, "js_audio_AudioEngine_getDurationFromFile_static : Error processing arguments"); + float result = cc::AudioEngine::getDurationFromFile(arg0.value()); + ok &= nativevalue_to_se(result, s.rval(), nullptr /*ctx*/); + SE_PRECONDITION2(ok, false, "js_audio_AudioEngine_getDurationFromFile_static : Error processing arguments"); + SE_HOLD_RETURN_VALUE(result, s.thisObject(), s.rval()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 1); + return false; +} +SE_BIND_FUNC(js_audio_AudioEngine_getDurationFromFile_static) + +static bool js_audio_AudioEngine_getMaxAudioInstance_static(se::State& s) // NOLINT(readability-identifier-naming) +{ + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 0) { + int result = cc::AudioEngine::getMaxAudioInstance(); + ok &= nativevalue_to_se(result, s.rval(), nullptr /*ctx*/); + SE_PRECONDITION2(ok, false, "js_audio_AudioEngine_getMaxAudioInstance_static : Error processing arguments"); + SE_HOLD_RETURN_VALUE(result, s.thisObject(), s.rval()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 0); + return false; +} +SE_BIND_FUNC(js_audio_AudioEngine_getMaxAudioInstance_static) + +static bool js_audio_AudioEngine_getPlayingAudioCount_static(se::State& s) // NOLINT(readability-identifier-naming) +{ + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 0) { + int result = cc::AudioEngine::getPlayingAudioCount(); + ok &= nativevalue_to_se(result, s.rval(), nullptr /*ctx*/); + SE_PRECONDITION2(ok, false, "js_audio_AudioEngine_getPlayingAudioCount_static : Error processing arguments"); + SE_HOLD_RETURN_VALUE(result, s.thisObject(), s.rval()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 0); + return false; +} +SE_BIND_FUNC(js_audio_AudioEngine_getPlayingAudioCount_static) + +static bool js_audio_AudioEngine_getProfile_static(se::State& s) // NOLINT(readability-identifier-naming) +{ + CC_UNUSED bool ok = true; + const auto& args = s.args(); + size_t argc = args.size(); + do { + if (argc == 1) { + HolderType arg0 = {}; + ok &= sevalue_to_native(args[0], &arg0, s.thisObject()); + if (!ok) { ok = true; break; } + cc::AudioProfile* result = cc::AudioEngine::getProfile(arg0.value()); + ok &= nativevalue_to_se(result, s.rval(), s.thisObject() /*ctx*/); + SE_PRECONDITION2(ok, false, "js_audio_AudioEngine_getProfile_static : Error processing arguments"); + SE_HOLD_RETURN_VALUE(result, s.thisObject(), s.rval()); + return true; + } + } while (false); + do { + if (argc == 1) { + HolderType arg0 = {}; + ok &= sevalue_to_native(args[0], &arg0, s.thisObject()); + if (!ok) { ok = true; break; } + cc::AudioProfile* result = cc::AudioEngine::getProfile(arg0.value()); + ok &= nativevalue_to_se(result, s.rval(), s.thisObject() /*ctx*/); + SE_PRECONDITION2(ok, false, "js_audio_AudioEngine_getProfile_static : Error processing arguments"); + SE_HOLD_RETURN_VALUE(result, s.thisObject(), s.rval()); + return true; + } + } while (false); + SE_REPORT_ERROR("wrong number of arguments: %d", (int)argc); + return false; +} +SE_BIND_FUNC(js_audio_AudioEngine_getProfile_static) + +static bool js_audio_AudioEngine_getState_static(se::State& s) // NOLINT(readability-identifier-naming) +{ + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 1) { + HolderType arg0 = {}; + ok &= sevalue_to_native(args[0], &arg0, nullptr); + SE_PRECONDITION2(ok, false, "js_audio_AudioEngine_getState_static : Error processing arguments"); + auto result = static_cast(cc::AudioEngine::getState(arg0.value())); + ok &= nativevalue_to_se(result, s.rval(), nullptr /*ctx*/); + SE_PRECONDITION2(ok, false, "js_audio_AudioEngine_getState_static : Error processing arguments"); + SE_HOLD_RETURN_VALUE(result, s.thisObject(), s.rval()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 1); + return false; +} +SE_BIND_FUNC(js_audio_AudioEngine_getState_static) + +static bool js_audio_AudioEngine_getVolume_static(se::State& s) // NOLINT(readability-identifier-naming) +{ + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 1) { + HolderType arg0 = {}; + ok &= sevalue_to_native(args[0], &arg0, nullptr); + SE_PRECONDITION2(ok, false, "js_audio_AudioEngine_getVolume_static : Error processing arguments"); + float result = cc::AudioEngine::getVolume(arg0.value()); + ok &= nativevalue_to_se(result, s.rval(), nullptr /*ctx*/); + SE_PRECONDITION2(ok, false, "js_audio_AudioEngine_getVolume_static : Error processing arguments"); + SE_HOLD_RETURN_VALUE(result, s.thisObject(), s.rval()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 1); + return false; +} +SE_BIND_FUNC(js_audio_AudioEngine_getVolume_static) + +static bool js_audio_AudioEngine_isEnabled_static(se::State& s) // NOLINT(readability-identifier-naming) +{ + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 0) { + bool result = cc::AudioEngine::isEnabled(); + ok &= nativevalue_to_se(result, s.rval(), nullptr /*ctx*/); + SE_PRECONDITION2(ok, false, "js_audio_AudioEngine_isEnabled_static : Error processing arguments"); + SE_HOLD_RETURN_VALUE(result, s.thisObject(), s.rval()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 0); + return false; +} +SE_BIND_FUNC(js_audio_AudioEngine_isEnabled_static) + +static bool js_audio_AudioEngine_isLoop_static(se::State& s) // NOLINT(readability-identifier-naming) +{ + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 1) { + HolderType arg0 = {}; + ok &= sevalue_to_native(args[0], &arg0, nullptr); + SE_PRECONDITION2(ok, false, "js_audio_AudioEngine_isLoop_static : Error processing arguments"); + bool result = cc::AudioEngine::isLoop(arg0.value()); + ok &= nativevalue_to_se(result, s.rval(), nullptr /*ctx*/); + SE_PRECONDITION2(ok, false, "js_audio_AudioEngine_isLoop_static : Error processing arguments"); + SE_HOLD_RETURN_VALUE(result, s.thisObject(), s.rval()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 1); + return false; +} +SE_BIND_FUNC(js_audio_AudioEngine_isLoop_static) + +static bool js_audio_AudioEngine_lazyInit_static(se::State& s) // NOLINT(readability-identifier-naming) +{ + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 0) { + bool result = cc::AudioEngine::lazyInit(); + ok &= nativevalue_to_se(result, s.rval(), nullptr /*ctx*/); + SE_PRECONDITION2(ok, false, "js_audio_AudioEngine_lazyInit_static : Error processing arguments"); + SE_HOLD_RETURN_VALUE(result, s.thisObject(), s.rval()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 0); + return false; +} +SE_BIND_FUNC(js_audio_AudioEngine_lazyInit_static) + +static bool js_audio_AudioEngine_pause_static(se::State& s) // NOLINT(readability-identifier-naming) +{ + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 1) { + HolderType arg0 = {}; + ok &= sevalue_to_native(args[0], &arg0, nullptr); + SE_PRECONDITION2(ok, false, "js_audio_AudioEngine_pause_static : Error processing arguments"); + cc::AudioEngine::pause(arg0.value()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 1); + return false; +} +SE_BIND_FUNC(js_audio_AudioEngine_pause_static) + +static bool js_audio_AudioEngine_pauseAll_static(se::State& s) // NOLINT(readability-identifier-naming) +{ + const auto& args = s.args(); + size_t argc = args.size(); + if (argc == 0) { + cc::AudioEngine::pauseAll(); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 0); + return false; +} +SE_BIND_FUNC(js_audio_AudioEngine_pauseAll_static) + +static bool js_audio_AudioEngine_play2d_static(se::State& s) // NOLINT(readability-identifier-naming) +{ + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 1) { + HolderType arg0 = {}; + ok &= sevalue_to_native(args[0], &arg0, nullptr); + SE_PRECONDITION2(ok, false, "js_audio_AudioEngine_play2d_static : Error processing arguments"); int result = cc::AudioEngine::play2d(arg0.value()); ok &= nativevalue_to_se(result, s.rval(), nullptr /*ctx*/); - SE_PRECONDITION2(ok, false, "js_audio_AudioEngine_play2d : Error processing arguments"); + SE_PRECONDITION2(ok, false, "js_audio_AudioEngine_play2d_static : Error processing arguments"); SE_HOLD_RETURN_VALUE(result, s.thisObject(), s.rval()); return true; } @@ -208,10 +436,10 @@ static bool js_audio_AudioEngine_play2d(se::State& s) // NOLINT(readability-iden HolderType arg1 = {}; ok &= sevalue_to_native(args[0], &arg0, nullptr); ok &= sevalue_to_native(args[1], &arg1, nullptr); - SE_PRECONDITION2(ok, false, "js_audio_AudioEngine_play2d : Error processing arguments"); + SE_PRECONDITION2(ok, false, "js_audio_AudioEngine_play2d_static : Error processing arguments"); int result = cc::AudioEngine::play2d(arg0.value(), arg1.value()); ok &= nativevalue_to_se(result, s.rval(), nullptr /*ctx*/); - SE_PRECONDITION2(ok, false, "js_audio_AudioEngine_play2d : Error processing arguments"); + SE_PRECONDITION2(ok, false, "js_audio_AudioEngine_play2d_static : Error processing arguments"); SE_HOLD_RETURN_VALUE(result, s.thisObject(), s.rval()); return true; } @@ -222,10 +450,10 @@ static bool js_audio_AudioEngine_play2d(se::State& s) // NOLINT(readability-iden ok &= sevalue_to_native(args[0], &arg0, nullptr); ok &= sevalue_to_native(args[1], &arg1, nullptr); ok &= sevalue_to_native(args[2], &arg2, nullptr); - SE_PRECONDITION2(ok, false, "js_audio_AudioEngine_play2d : Error processing arguments"); + SE_PRECONDITION2(ok, false, "js_audio_AudioEngine_play2d_static : Error processing arguments"); int result = cc::AudioEngine::play2d(arg0.value(), arg1.value(), arg2.value()); ok &= nativevalue_to_se(result, s.rval(), nullptr /*ctx*/); - SE_PRECONDITION2(ok, false, "js_audio_AudioEngine_play2d : Error processing arguments"); + SE_PRECONDITION2(ok, false, "js_audio_AudioEngine_play2d_static : Error processing arguments"); SE_HOLD_RETURN_VALUE(result, s.thisObject(), s.rval()); return true; } @@ -238,439 +466,19 @@ static bool js_audio_AudioEngine_play2d(se::State& s) // NOLINT(readability-iden ok &= sevalue_to_native(args[1], &arg1, nullptr); ok &= sevalue_to_native(args[2], &arg2, nullptr); ok &= sevalue_to_native(args[3], &arg3, nullptr); - SE_PRECONDITION2(ok, false, "js_audio_AudioEngine_play2d : Error processing arguments"); + SE_PRECONDITION2(ok, false, "js_audio_AudioEngine_play2d_static : Error processing arguments"); int result = cc::AudioEngine::play2d(arg0.value(), arg1.value(), arg2.value(), arg3.value()); ok &= nativevalue_to_se(result, s.rval(), nullptr /*ctx*/); - SE_PRECONDITION2(ok, false, "js_audio_AudioEngine_play2d : Error processing arguments"); + SE_PRECONDITION2(ok, false, "js_audio_AudioEngine_play2d_static : Error processing arguments"); SE_HOLD_RETURN_VALUE(result, s.thisObject(), s.rval()); return true; } SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 4); return false; } -SE_BIND_FUNC(js_audio_AudioEngine_play2d) +SE_BIND_FUNC(js_audio_AudioEngine_play2d_static) -static bool js_audio_AudioEngine_setLoop(se::State& s) // NOLINT(readability-identifier-naming) -{ - const auto& args = s.args(); - size_t argc = args.size(); - CC_UNUSED bool ok = true; - if (argc == 2) { - HolderType arg0 = {}; - HolderType arg1 = {}; - ok &= sevalue_to_native(args[0], &arg0, nullptr); - ok &= sevalue_to_native(args[1], &arg1, nullptr); - SE_PRECONDITION2(ok, false, "js_audio_AudioEngine_setLoop : Error processing arguments"); - cc::AudioEngine::setLoop(arg0.value(), arg1.value()); - return true; - } - SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 2); - return false; -} -SE_BIND_FUNC(js_audio_AudioEngine_setLoop) - -static bool js_audio_AudioEngine_isLoop(se::State& s) // NOLINT(readability-identifier-naming) -{ - const auto& args = s.args(); - size_t argc = args.size(); - CC_UNUSED bool ok = true; - if (argc == 1) { - HolderType arg0 = {}; - ok &= sevalue_to_native(args[0], &arg0, nullptr); - SE_PRECONDITION2(ok, false, "js_audio_AudioEngine_isLoop : Error processing arguments"); - bool result = cc::AudioEngine::isLoop(arg0.value()); - ok &= nativevalue_to_se(result, s.rval(), nullptr /*ctx*/); - SE_PRECONDITION2(ok, false, "js_audio_AudioEngine_isLoop : Error processing arguments"); - SE_HOLD_RETURN_VALUE(result, s.thisObject(), s.rval()); - return true; - } - SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 1); - return false; -} -SE_BIND_FUNC(js_audio_AudioEngine_isLoop) - -static bool js_audio_AudioEngine_setVolume(se::State& s) // NOLINT(readability-identifier-naming) -{ - const auto& args = s.args(); - size_t argc = args.size(); - CC_UNUSED bool ok = true; - if (argc == 2) { - HolderType arg0 = {}; - HolderType arg1 = {}; - ok &= sevalue_to_native(args[0], &arg0, nullptr); - ok &= sevalue_to_native(args[1], &arg1, nullptr); - SE_PRECONDITION2(ok, false, "js_audio_AudioEngine_setVolume : Error processing arguments"); - cc::AudioEngine::setVolume(arg0.value(), arg1.value()); - return true; - } - SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 2); - return false; -} -SE_BIND_FUNC(js_audio_AudioEngine_setVolume) - -static bool js_audio_AudioEngine_getVolume(se::State& s) // NOLINT(readability-identifier-naming) -{ - const auto& args = s.args(); - size_t argc = args.size(); - CC_UNUSED bool ok = true; - if (argc == 1) { - HolderType arg0 = {}; - ok &= sevalue_to_native(args[0], &arg0, nullptr); - SE_PRECONDITION2(ok, false, "js_audio_AudioEngine_getVolume : Error processing arguments"); - float result = cc::AudioEngine::getVolume(arg0.value()); - ok &= nativevalue_to_se(result, s.rval(), nullptr /*ctx*/); - SE_PRECONDITION2(ok, false, "js_audio_AudioEngine_getVolume : Error processing arguments"); - SE_HOLD_RETURN_VALUE(result, s.thisObject(), s.rval()); - return true; - } - SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 1); - return false; -} -SE_BIND_FUNC(js_audio_AudioEngine_getVolume) - -static bool js_audio_AudioEngine_pause(se::State& s) // NOLINT(readability-identifier-naming) -{ - const auto& args = s.args(); - size_t argc = args.size(); - CC_UNUSED bool ok = true; - if (argc == 1) { - HolderType arg0 = {}; - ok &= sevalue_to_native(args[0], &arg0, nullptr); - SE_PRECONDITION2(ok, false, "js_audio_AudioEngine_pause : Error processing arguments"); - cc::AudioEngine::pause(arg0.value()); - return true; - } - SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 1); - return false; -} -SE_BIND_FUNC(js_audio_AudioEngine_pause) - -static bool js_audio_AudioEngine_pauseAll(se::State& s) // NOLINT(readability-identifier-naming) -{ - const auto& args = s.args(); - size_t argc = args.size(); - if (argc == 0) { - cc::AudioEngine::pauseAll(); - return true; - } - SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 0); - return false; -} -SE_BIND_FUNC(js_audio_AudioEngine_pauseAll) - -static bool js_audio_AudioEngine_resume(se::State& s) // NOLINT(readability-identifier-naming) -{ - const auto& args = s.args(); - size_t argc = args.size(); - CC_UNUSED bool ok = true; - if (argc == 1) { - HolderType arg0 = {}; - ok &= sevalue_to_native(args[0], &arg0, nullptr); - SE_PRECONDITION2(ok, false, "js_audio_AudioEngine_resume : Error processing arguments"); - cc::AudioEngine::resume(arg0.value()); - return true; - } - SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 1); - return false; -} -SE_BIND_FUNC(js_audio_AudioEngine_resume) - -static bool js_audio_AudioEngine_resumeAll(se::State& s) // NOLINT(readability-identifier-naming) -{ - const auto& args = s.args(); - size_t argc = args.size(); - if (argc == 0) { - cc::AudioEngine::resumeAll(); - return true; - } - SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 0); - return false; -} -SE_BIND_FUNC(js_audio_AudioEngine_resumeAll) - -static bool js_audio_AudioEngine_stop(se::State& s) // NOLINT(readability-identifier-naming) -{ - const auto& args = s.args(); - size_t argc = args.size(); - CC_UNUSED bool ok = true; - if (argc == 1) { - HolderType arg0 = {}; - ok &= sevalue_to_native(args[0], &arg0, nullptr); - SE_PRECONDITION2(ok, false, "js_audio_AudioEngine_stop : Error processing arguments"); - cc::AudioEngine::stop(arg0.value()); - return true; - } - SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 1); - return false; -} -SE_BIND_FUNC(js_audio_AudioEngine_stop) - -static bool js_audio_AudioEngine_stopAll(se::State& s) // NOLINT(readability-identifier-naming) -{ - const auto& args = s.args(); - size_t argc = args.size(); - if (argc == 0) { - cc::AudioEngine::stopAll(); - return true; - } - SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 0); - return false; -} -SE_BIND_FUNC(js_audio_AudioEngine_stopAll) - -static bool js_audio_AudioEngine_setCurrentTime(se::State& s) // NOLINT(readability-identifier-naming) -{ - const auto& args = s.args(); - size_t argc = args.size(); - CC_UNUSED bool ok = true; - if (argc == 2) { - HolderType arg0 = {}; - HolderType arg1 = {}; - ok &= sevalue_to_native(args[0], &arg0, nullptr); - ok &= sevalue_to_native(args[1], &arg1, nullptr); - SE_PRECONDITION2(ok, false, "js_audio_AudioEngine_setCurrentTime : Error processing arguments"); - bool result = cc::AudioEngine::setCurrentTime(arg0.value(), arg1.value()); - ok &= nativevalue_to_se(result, s.rval(), nullptr /*ctx*/); - SE_PRECONDITION2(ok, false, "js_audio_AudioEngine_setCurrentTime : Error processing arguments"); - SE_HOLD_RETURN_VALUE(result, s.thisObject(), s.rval()); - return true; - } - SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 2); - return false; -} -SE_BIND_FUNC(js_audio_AudioEngine_setCurrentTime) - -static bool js_audio_AudioEngine_getCurrentTime(se::State& s) // NOLINT(readability-identifier-naming) -{ - const auto& args = s.args(); - size_t argc = args.size(); - CC_UNUSED bool ok = true; - if (argc == 1) { - HolderType arg0 = {}; - ok &= sevalue_to_native(args[0], &arg0, nullptr); - SE_PRECONDITION2(ok, false, "js_audio_AudioEngine_getCurrentTime : Error processing arguments"); - float result = cc::AudioEngine::getCurrentTime(arg0.value()); - ok &= nativevalue_to_se(result, s.rval(), nullptr /*ctx*/); - SE_PRECONDITION2(ok, false, "js_audio_AudioEngine_getCurrentTime : Error processing arguments"); - SE_HOLD_RETURN_VALUE(result, s.thisObject(), s.rval()); - return true; - } - SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 1); - return false; -} -SE_BIND_FUNC(js_audio_AudioEngine_getCurrentTime) - -static bool js_audio_AudioEngine_getDuration(se::State& s) // NOLINT(readability-identifier-naming) -{ - const auto& args = s.args(); - size_t argc = args.size(); - CC_UNUSED bool ok = true; - if (argc == 1) { - HolderType arg0 = {}; - ok &= sevalue_to_native(args[0], &arg0, nullptr); - SE_PRECONDITION2(ok, false, "js_audio_AudioEngine_getDuration : Error processing arguments"); - float result = cc::AudioEngine::getDuration(arg0.value()); - ok &= nativevalue_to_se(result, s.rval(), nullptr /*ctx*/); - SE_PRECONDITION2(ok, false, "js_audio_AudioEngine_getDuration : Error processing arguments"); - SE_HOLD_RETURN_VALUE(result, s.thisObject(), s.rval()); - return true; - } - SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 1); - return false; -} -SE_BIND_FUNC(js_audio_AudioEngine_getDuration) - -static bool js_audio_AudioEngine_getDurationFromFile(se::State& s) // NOLINT(readability-identifier-naming) -{ - const auto& args = s.args(); - size_t argc = args.size(); - CC_UNUSED bool ok = true; - if (argc == 1) { - HolderType arg0 = {}; - ok &= sevalue_to_native(args[0], &arg0, nullptr); - SE_PRECONDITION2(ok, false, "js_audio_AudioEngine_getDurationFromFile : Error processing arguments"); - float result = cc::AudioEngine::getDurationFromFile(arg0.value()); - ok &= nativevalue_to_se(result, s.rval(), nullptr /*ctx*/); - SE_PRECONDITION2(ok, false, "js_audio_AudioEngine_getDurationFromFile : Error processing arguments"); - SE_HOLD_RETURN_VALUE(result, s.thisObject(), s.rval()); - return true; - } - SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 1); - return false; -} -SE_BIND_FUNC(js_audio_AudioEngine_getDurationFromFile) - -static bool js_audio_AudioEngine_getState(se::State& s) // NOLINT(readability-identifier-naming) -{ - const auto& args = s.args(); - size_t argc = args.size(); - CC_UNUSED bool ok = true; - if (argc == 1) { - HolderType arg0 = {}; - ok &= sevalue_to_native(args[0], &arg0, nullptr); - SE_PRECONDITION2(ok, false, "js_audio_AudioEngine_getState : Error processing arguments"); - auto result = static_cast(cc::AudioEngine::getState(arg0.value())); - ok &= nativevalue_to_se(result, s.rval(), nullptr /*ctx*/); - SE_PRECONDITION2(ok, false, "js_audio_AudioEngine_getState : Error processing arguments"); - SE_HOLD_RETURN_VALUE(result, s.thisObject(), s.rval()); - return true; - } - SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 1); - return false; -} -SE_BIND_FUNC(js_audio_AudioEngine_getState) - -static bool js_audio_AudioEngine_setFinishCallback(se::State& s) // NOLINT(readability-identifier-naming) -{ - const auto& args = s.args(); - size_t argc = args.size(); - CC_UNUSED bool ok = true; - if (argc == 2) { - HolderType arg0 = {}; - HolderType, true> arg1 = {}; - ok &= sevalue_to_native(args[0], &arg0, nullptr); - do { - if (args[1].isObject() && args[1].toObject()->isFunction()) - { - se::Value jsThis(s.thisObject()); - se::Value jsFunc(args[1]); - jsFunc.toObject()->root(); - auto lambda = [=](int larg0, const std::string larg1) -> void { - se::ScriptEngine::getInstance()->clearException(); - se::AutoHandleScope hs; - - CC_UNUSED bool ok = true; - se::ValueArray args; - args.resize(2); - ok &= nativevalue_to_se(larg0, args[0], nullptr /*ctx*/); - ok &= nativevalue_to_se(larg1, args[1], nullptr /*ctx*/); - se::Value rval; - se::Object* thisObj = jsThis.isObject() ? jsThis.toObject() : nullptr; - se::Object* funcObj = jsFunc.toObject(); - bool succeed = funcObj->call(args, thisObj, &rval); - if (!succeed) { - se::ScriptEngine::getInstance()->clearException(); - } - }; - arg1.data = lambda; - } - else - { - arg1.data = nullptr; - } - } while(false) - ; - SE_PRECONDITION2(ok, false, "js_audio_AudioEngine_setFinishCallback : Error processing arguments"); - cc::AudioEngine::setFinishCallback(arg0.value(), arg1.value()); - return true; - } - SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 2); - return false; -} -SE_BIND_FUNC(js_audio_AudioEngine_setFinishCallback) - -static bool js_audio_AudioEngine_getMaxAudioInstance(se::State& s) // NOLINT(readability-identifier-naming) -{ - const auto& args = s.args(); - size_t argc = args.size(); - CC_UNUSED bool ok = true; - if (argc == 0) { - int result = cc::AudioEngine::getMaxAudioInstance(); - ok &= nativevalue_to_se(result, s.rval(), nullptr /*ctx*/); - SE_PRECONDITION2(ok, false, "js_audio_AudioEngine_getMaxAudioInstance : Error processing arguments"); - SE_HOLD_RETURN_VALUE(result, s.thisObject(), s.rval()); - return true; - } - SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 0); - return false; -} -SE_BIND_FUNC(js_audio_AudioEngine_getMaxAudioInstance) - -static bool js_audio_AudioEngine_setMaxAudioInstance(se::State& s) // NOLINT(readability-identifier-naming) -{ - const auto& args = s.args(); - size_t argc = args.size(); - CC_UNUSED bool ok = true; - if (argc == 1) { - HolderType arg0 = {}; - ok &= sevalue_to_native(args[0], &arg0, nullptr); - SE_PRECONDITION2(ok, false, "js_audio_AudioEngine_setMaxAudioInstance : Error processing arguments"); - bool result = cc::AudioEngine::setMaxAudioInstance(arg0.value()); - ok &= nativevalue_to_se(result, s.rval(), nullptr /*ctx*/); - SE_PRECONDITION2(ok, false, "js_audio_AudioEngine_setMaxAudioInstance : Error processing arguments"); - SE_HOLD_RETURN_VALUE(result, s.thisObject(), s.rval()); - return true; - } - SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 1); - return false; -} -SE_BIND_FUNC(js_audio_AudioEngine_setMaxAudioInstance) - -static bool js_audio_AudioEngine_uncache(se::State& s) // NOLINT(readability-identifier-naming) -{ - const auto& args = s.args(); - size_t argc = args.size(); - CC_UNUSED bool ok = true; - if (argc == 1) { - HolderType arg0 = {}; - ok &= sevalue_to_native(args[0], &arg0, nullptr); - SE_PRECONDITION2(ok, false, "js_audio_AudioEngine_uncache : Error processing arguments"); - cc::AudioEngine::uncache(arg0.value()); - return true; - } - SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 1); - return false; -} -SE_BIND_FUNC(js_audio_AudioEngine_uncache) - -static bool js_audio_AudioEngine_uncacheAll(se::State& s) // NOLINT(readability-identifier-naming) -{ - const auto& args = s.args(); - size_t argc = args.size(); - if (argc == 0) { - cc::AudioEngine::uncacheAll(); - return true; - } - SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 0); - return false; -} -SE_BIND_FUNC(js_audio_AudioEngine_uncacheAll) - -static bool js_audio_AudioEngine_getProfile(se::State& s) // NOLINT(readability-identifier-naming) -{ - CC_UNUSED bool ok = true; - const auto& args = s.args(); - size_t argc = args.size(); - do { - if (argc == 1) { - HolderType arg0 = {}; - ok &= sevalue_to_native(args[0], &arg0, s.thisObject()); - if (!ok) { ok = true; break; } - cc::AudioProfile* result = cc::AudioEngine::getProfile(arg0.value()); - ok &= nativevalue_to_se(result, s.rval(), s.thisObject() /*ctx*/); - SE_PRECONDITION2(ok, false, "js_audio_AudioEngine_getProfile : Error processing arguments"); - SE_HOLD_RETURN_VALUE(result, s.thisObject(), s.rval()); - return true; - } - } while (false); - do { - if (argc == 1) { - HolderType arg0 = {}; - ok &= sevalue_to_native(args[0], &arg0, s.thisObject()); - if (!ok) { ok = true; break; } - cc::AudioProfile* result = cc::AudioEngine::getProfile(arg0.value()); - ok &= nativevalue_to_se(result, s.rval(), s.thisObject() /*ctx*/); - SE_PRECONDITION2(ok, false, "js_audio_AudioEngine_getProfile : Error processing arguments"); - SE_HOLD_RETURN_VALUE(result, s.thisObject(), s.rval()); - return true; - } - } while (false); - SE_REPORT_ERROR("wrong number of arguments: %d", (int)argc); - return false; -} -SE_BIND_FUNC(js_audio_AudioEngine_getProfile) - -static bool js_audio_AudioEngine_preload(se::State& s) // NOLINT(readability-identifier-naming) +static bool js_audio_AudioEngine_preload_static(se::State& s) // NOLINT(readability-identifier-naming) { CC_UNUSED bool ok = true; const auto& args = s.args(); @@ -687,6 +495,7 @@ static bool js_audio_AudioEngine_preload(se::State& s) // NOLINT(readability-ide se::Value jsThis(s.thisObject()); se::Value jsFunc(args[1]); jsFunc.toObject()->root(); + auto * thisObj = s.thisObject(); auto lambda = [=](bool larg0) -> void { se::ScriptEngine::getInstance()->clearException(); se::AutoHandleScope hs; @@ -696,7 +505,6 @@ static bool js_audio_AudioEngine_preload(se::State& s) // NOLINT(readability-ide args.resize(1); ok &= nativevalue_to_se(larg0, args[0], nullptr /*ctx*/); se::Value rval; - se::Object* thisObj = jsThis.isObject() ? jsThis.toObject() : nullptr; se::Object* funcObj = jsFunc.toObject(); bool succeed = funcObj->call(args, thisObj, &rval); if (!succeed) { @@ -728,26 +536,61 @@ static bool js_audio_AudioEngine_preload(se::State& s) // NOLINT(readability-ide SE_REPORT_ERROR("wrong number of arguments: %d", (int)argc); return false; } -SE_BIND_FUNC(js_audio_AudioEngine_preload) +SE_BIND_FUNC(js_audio_AudioEngine_preload_static) -static bool js_audio_AudioEngine_getPlayingAudioCount(se::State& s) // NOLINT(readability-identifier-naming) +static bool js_audio_AudioEngine_resume_static(se::State& s) // NOLINT(readability-identifier-naming) { const auto& args = s.args(); size_t argc = args.size(); CC_UNUSED bool ok = true; + if (argc == 1) { + HolderType arg0 = {}; + ok &= sevalue_to_native(args[0], &arg0, nullptr); + SE_PRECONDITION2(ok, false, "js_audio_AudioEngine_resume_static : Error processing arguments"); + cc::AudioEngine::resume(arg0.value()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 1); + return false; +} +SE_BIND_FUNC(js_audio_AudioEngine_resume_static) + +static bool js_audio_AudioEngine_resumeAll_static(se::State& s) // NOLINT(readability-identifier-naming) +{ + const auto& args = s.args(); + size_t argc = args.size(); if (argc == 0) { - int result = cc::AudioEngine::getPlayingAudioCount(); - ok &= nativevalue_to_se(result, s.rval(), nullptr /*ctx*/); - SE_PRECONDITION2(ok, false, "js_audio_AudioEngine_getPlayingAudioCount : Error processing arguments"); - SE_HOLD_RETURN_VALUE(result, s.thisObject(), s.rval()); + cc::AudioEngine::resumeAll(); return true; } SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 0); return false; } -SE_BIND_FUNC(js_audio_AudioEngine_getPlayingAudioCount) +SE_BIND_FUNC(js_audio_AudioEngine_resumeAll_static) -static bool js_audio_AudioEngine_setEnabled(se::State& s) // NOLINT(readability-identifier-naming) +static bool js_audio_AudioEngine_setCurrentTime_static(se::State& s) // NOLINT(readability-identifier-naming) +{ + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 2) { + HolderType arg0 = {}; + HolderType arg1 = {}; + ok &= sevalue_to_native(args[0], &arg0, nullptr); + ok &= sevalue_to_native(args[1], &arg1, nullptr); + SE_PRECONDITION2(ok, false, "js_audio_AudioEngine_setCurrentTime_static : Error processing arguments"); + bool result = cc::AudioEngine::setCurrentTime(arg0.value(), arg1.value()); + ok &= nativevalue_to_se(result, s.rval(), nullptr /*ctx*/); + SE_PRECONDITION2(ok, false, "js_audio_AudioEngine_setCurrentTime_static : Error processing arguments"); + SE_HOLD_RETURN_VALUE(result, s.thisObject(), s.rval()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 2); + return false; +} +SE_BIND_FUNC(js_audio_AudioEngine_setCurrentTime_static) + +static bool js_audio_AudioEngine_setEnabled_static(se::State& s) // NOLINT(readability-identifier-naming) { const auto& args = s.args(); size_t argc = args.size(); @@ -755,81 +598,230 @@ static bool js_audio_AudioEngine_setEnabled(se::State& s) // NOLINT(readability- if (argc == 1) { HolderType arg0 = {}; ok &= sevalue_to_native(args[0], &arg0, nullptr); - SE_PRECONDITION2(ok, false, "js_audio_AudioEngine_setEnabled : Error processing arguments"); + SE_PRECONDITION2(ok, false, "js_audio_AudioEngine_setEnabled_static : Error processing arguments"); cc::AudioEngine::setEnabled(arg0.value()); return true; } SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 1); return false; } -SE_BIND_FUNC(js_audio_AudioEngine_setEnabled) +SE_BIND_FUNC(js_audio_AudioEngine_setEnabled_static) -static bool js_audio_AudioEngine_isEnabled(se::State& s) // NOLINT(readability-identifier-naming) +static bool js_audio_AudioEngine_setFinishCallback_static(se::State& s) // NOLINT(readability-identifier-naming) { const auto& args = s.args(); size_t argc = args.size(); CC_UNUSED bool ok = true; - if (argc == 0) { - bool result = cc::AudioEngine::isEnabled(); + if (argc == 2) { + HolderType arg0 = {}; + HolderType, true> arg1 = {}; + ok &= sevalue_to_native(args[0], &arg0, nullptr); + do { + if (args[1].isObject() && args[1].toObject()->isFunction()) + { + se::Value jsThis(s.thisObject()); + se::Value jsFunc(args[1]); + jsFunc.toObject()->root(); + auto * thisObj = s.thisObject(); + auto lambda = [=](int larg0, const std::string larg1) -> void { + se::ScriptEngine::getInstance()->clearException(); + se::AutoHandleScope hs; + + CC_UNUSED bool ok = true; + se::ValueArray args; + args.resize(2); + ok &= nativevalue_to_se(larg0, args[0], nullptr /*ctx*/); + ok &= nativevalue_to_se(larg1, args[1], nullptr /*ctx*/); + se::Value rval; + se::Object* funcObj = jsFunc.toObject(); + bool succeed = funcObj->call(args, thisObj, &rval); + if (!succeed) { + se::ScriptEngine::getInstance()->clearException(); + } + }; + arg1.data = lambda; + } + else + { + arg1.data = nullptr; + } + } while(false) + ; + SE_PRECONDITION2(ok, false, "js_audio_AudioEngine_setFinishCallback_static : Error processing arguments"); + cc::AudioEngine::setFinishCallback(arg0.value(), arg1.value()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 2); + return false; +} +SE_BIND_FUNC(js_audio_AudioEngine_setFinishCallback_static) + +static bool js_audio_AudioEngine_setLoop_static(se::State& s) // NOLINT(readability-identifier-naming) +{ + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 2) { + HolderType arg0 = {}; + HolderType arg1 = {}; + ok &= sevalue_to_native(args[0], &arg0, nullptr); + ok &= sevalue_to_native(args[1], &arg1, nullptr); + SE_PRECONDITION2(ok, false, "js_audio_AudioEngine_setLoop_static : Error processing arguments"); + cc::AudioEngine::setLoop(arg0.value(), arg1.value()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 2); + return false; +} +SE_BIND_FUNC(js_audio_AudioEngine_setLoop_static) + +static bool js_audio_AudioEngine_setMaxAudioInstance_static(se::State& s) // NOLINT(readability-identifier-naming) +{ + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 1) { + HolderType arg0 = {}; + ok &= sevalue_to_native(args[0], &arg0, nullptr); + SE_PRECONDITION2(ok, false, "js_audio_AudioEngine_setMaxAudioInstance_static : Error processing arguments"); + bool result = cc::AudioEngine::setMaxAudioInstance(arg0.value()); ok &= nativevalue_to_se(result, s.rval(), nullptr /*ctx*/); - SE_PRECONDITION2(ok, false, "js_audio_AudioEngine_isEnabled : Error processing arguments"); + SE_PRECONDITION2(ok, false, "js_audio_AudioEngine_setMaxAudioInstance_static : Error processing arguments"); SE_HOLD_RETURN_VALUE(result, s.thisObject(), s.rval()); return true; } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 1); + return false; +} +SE_BIND_FUNC(js_audio_AudioEngine_setMaxAudioInstance_static) + +static bool js_audio_AudioEngine_setVolume_static(se::State& s) // NOLINT(readability-identifier-naming) +{ + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 2) { + HolderType arg0 = {}; + HolderType arg1 = {}; + ok &= sevalue_to_native(args[0], &arg0, nullptr); + ok &= sevalue_to_native(args[1], &arg1, nullptr); + SE_PRECONDITION2(ok, false, "js_audio_AudioEngine_setVolume_static : Error processing arguments"); + cc::AudioEngine::setVolume(arg0.value(), arg1.value()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 2); + return false; +} +SE_BIND_FUNC(js_audio_AudioEngine_setVolume_static) + +static bool js_audio_AudioEngine_stop_static(se::State& s) // NOLINT(readability-identifier-naming) +{ + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 1) { + HolderType arg0 = {}; + ok &= sevalue_to_native(args[0], &arg0, nullptr); + SE_PRECONDITION2(ok, false, "js_audio_AudioEngine_stop_static : Error processing arguments"); + cc::AudioEngine::stop(arg0.value()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 1); + return false; +} +SE_BIND_FUNC(js_audio_AudioEngine_stop_static) + +static bool js_audio_AudioEngine_stopAll_static(se::State& s) // NOLINT(readability-identifier-naming) +{ + const auto& args = s.args(); + size_t argc = args.size(); + if (argc == 0) { + cc::AudioEngine::stopAll(); + return true; + } SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 0); return false; } -SE_BIND_FUNC(js_audio_AudioEngine_isEnabled) +SE_BIND_FUNC(js_audio_AudioEngine_stopAll_static) +static bool js_audio_AudioEngine_uncache_static(se::State& s) // NOLINT(readability-identifier-naming) +{ + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 1) { + HolderType arg0 = {}; + ok &= sevalue_to_native(args[0], &arg0, nullptr); + SE_PRECONDITION2(ok, false, "js_audio_AudioEngine_uncache_static : Error processing arguments"); + cc::AudioEngine::uncache(arg0.value()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 1); + return false; +} +SE_BIND_FUNC(js_audio_AudioEngine_uncache_static) +static bool js_audio_AudioEngine_uncacheAll_static(se::State& s) // NOLINT(readability-identifier-naming) +{ + const auto& args = s.args(); + size_t argc = args.size(); + if (argc == 0) { + cc::AudioEngine::uncacheAll(); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 0); + return false; +} +SE_BIND_FUNC(js_audio_AudioEngine_uncacheAll_static) bool js_register_audio_AudioEngine(se::Object* obj) // NOLINT(readability-identifier-naming) { auto* cls = se::Class::create("AudioEngine", obj, nullptr, nullptr); - cls->defineStaticFunction("lazyInit", _SE(js_audio_AudioEngine_lazyInit)); - cls->defineStaticFunction("end", _SE(js_audio_AudioEngine_end)); - cls->defineStaticFunction("getDefaultProfile", _SE(js_audio_AudioEngine_getDefaultProfile)); - cls->defineStaticFunction("play2d", _SE(js_audio_AudioEngine_play2d)); - cls->defineStaticFunction("setLoop", _SE(js_audio_AudioEngine_setLoop)); - cls->defineStaticFunction("isLoop", _SE(js_audio_AudioEngine_isLoop)); - cls->defineStaticFunction("setVolume", _SE(js_audio_AudioEngine_setVolume)); - cls->defineStaticFunction("getVolume", _SE(js_audio_AudioEngine_getVolume)); - cls->defineStaticFunction("pause", _SE(js_audio_AudioEngine_pause)); - cls->defineStaticFunction("pauseAll", _SE(js_audio_AudioEngine_pauseAll)); - cls->defineStaticFunction("resume", _SE(js_audio_AudioEngine_resume)); - cls->defineStaticFunction("resumeAll", _SE(js_audio_AudioEngine_resumeAll)); - cls->defineStaticFunction("stop", _SE(js_audio_AudioEngine_stop)); - cls->defineStaticFunction("stopAll", _SE(js_audio_AudioEngine_stopAll)); - cls->defineStaticFunction("setCurrentTime", _SE(js_audio_AudioEngine_setCurrentTime)); - cls->defineStaticFunction("getCurrentTime", _SE(js_audio_AudioEngine_getCurrentTime)); - cls->defineStaticFunction("getDuration", _SE(js_audio_AudioEngine_getDuration)); - cls->defineStaticFunction("getDurationFromFile", _SE(js_audio_AudioEngine_getDurationFromFile)); - cls->defineStaticFunction("getState", _SE(js_audio_AudioEngine_getState)); - cls->defineStaticFunction("setFinishCallback", _SE(js_audio_AudioEngine_setFinishCallback)); - cls->defineStaticFunction("getMaxAudioInstance", _SE(js_audio_AudioEngine_getMaxAudioInstance)); - cls->defineStaticFunction("setMaxAudioInstance", _SE(js_audio_AudioEngine_setMaxAudioInstance)); - cls->defineStaticFunction("uncache", _SE(js_audio_AudioEngine_uncache)); - cls->defineStaticFunction("uncacheAll", _SE(js_audio_AudioEngine_uncacheAll)); - cls->defineStaticFunction("getProfile", _SE(js_audio_AudioEngine_getProfile)); - cls->defineStaticFunction("preload", _SE(js_audio_AudioEngine_preload)); - cls->defineStaticFunction("getPlayingAudioCount", _SE(js_audio_AudioEngine_getPlayingAudioCount)); - cls->defineStaticFunction("setEnabled", _SE(js_audio_AudioEngine_setEnabled)); - cls->defineStaticFunction("isEnabled", _SE(js_audio_AudioEngine_isEnabled)); + cls->defineStaticFunction("end", _SE(js_audio_AudioEngine_end_static)); + cls->defineStaticFunction("getCurrentTime", _SE(js_audio_AudioEngine_getCurrentTime_static)); + cls->defineStaticFunction("getDefaultProfile", _SE(js_audio_AudioEngine_getDefaultProfile_static)); + cls->defineStaticFunction("getDuration", _SE(js_audio_AudioEngine_getDuration_static)); + cls->defineStaticFunction("getDurationFromFile", _SE(js_audio_AudioEngine_getDurationFromFile_static)); + cls->defineStaticFunction("getMaxAudioInstance", _SE(js_audio_AudioEngine_getMaxAudioInstance_static)); + cls->defineStaticFunction("getPlayingAudioCount", _SE(js_audio_AudioEngine_getPlayingAudioCount_static)); + cls->defineStaticFunction("getProfile", _SE(js_audio_AudioEngine_getProfile_static)); + cls->defineStaticFunction("getState", _SE(js_audio_AudioEngine_getState_static)); + cls->defineStaticFunction("getVolume", _SE(js_audio_AudioEngine_getVolume_static)); + cls->defineStaticFunction("isEnabled", _SE(js_audio_AudioEngine_isEnabled_static)); + cls->defineStaticFunction("isLoop", _SE(js_audio_AudioEngine_isLoop_static)); + cls->defineStaticFunction("lazyInit", _SE(js_audio_AudioEngine_lazyInit_static)); + cls->defineStaticFunction("pause", _SE(js_audio_AudioEngine_pause_static)); + cls->defineStaticFunction("pauseAll", _SE(js_audio_AudioEngine_pauseAll_static)); + cls->defineStaticFunction("play2d", _SE(js_audio_AudioEngine_play2d_static)); + cls->defineStaticFunction("preload", _SE(js_audio_AudioEngine_preload_static)); + cls->defineStaticFunction("resume", _SE(js_audio_AudioEngine_resume_static)); + cls->defineStaticFunction("resumeAll", _SE(js_audio_AudioEngine_resumeAll_static)); + cls->defineStaticFunction("setCurrentTime", _SE(js_audio_AudioEngine_setCurrentTime_static)); + cls->defineStaticFunction("setEnabled", _SE(js_audio_AudioEngine_setEnabled_static)); + cls->defineStaticFunction("setFinishCallback", _SE(js_audio_AudioEngine_setFinishCallback_static)); + cls->defineStaticFunction("setLoop", _SE(js_audio_AudioEngine_setLoop_static)); + cls->defineStaticFunction("setMaxAudioInstance", _SE(js_audio_AudioEngine_setMaxAudioInstance_static)); + cls->defineStaticFunction("setVolume", _SE(js_audio_AudioEngine_setVolume_static)); + cls->defineStaticFunction("stop", _SE(js_audio_AudioEngine_stop_static)); + cls->defineStaticFunction("stopAll", _SE(js_audio_AudioEngine_stopAll_static)); + cls->defineStaticFunction("uncache", _SE(js_audio_AudioEngine_uncache_static)); + cls->defineStaticFunction("uncacheAll", _SE(js_audio_AudioEngine_uncacheAll_static)); cls->install(); JSBClassType::registerClass(cls); __jsb_cc_AudioEngine_proto = cls->getProto(); __jsb_cc_AudioEngine_class = cls; + se::ScriptEngine::getInstance()->clearException(); return true; } -bool register_all_audio(se::Object* obj) +bool register_all_audio(se::Object* obj) // NOLINT { // Get the ns se::Value nsVal; - if (!obj->getProperty("jsb", &nsVal)) + if (!obj->getProperty("jsb", &nsVal, true)) { se::HandleObject jsobj(se::Object::createPlainObject()); nsVal.setObject(jsobj); @@ -837,9 +829,10 @@ bool register_all_audio(se::Object* obj) } se::Object* ns = nsVal.toObject(); - js_register_audio_AudioProfile(ns); js_register_audio_AudioEngine(ns); + js_register_audio_AudioProfile(ns); return true; } #endif //#if (USE_AUDIO > 0) +// clang-format on \ No newline at end of file diff --git a/native/cocos/bindings/auto/jsb_audio_auto.h b/native/cocos/bindings/auto/jsb_audio_auto.h index f4a1eb72dd..4b84596927 100644 --- a/native/cocos/bindings/auto/jsb_audio_auto.h +++ b/native/cocos/bindings/auto/jsb_audio_auto.h @@ -1,3 +1,4 @@ +// clang-format off #pragma once #include "base/Config.h" #if (USE_AUDIO > 0) @@ -6,50 +7,52 @@ #include "cocos/bindings/manual/jsb_conversions.h" #include "cocos/audio/include/AudioEngine.h" -extern se::Object* __jsb_cc_AudioProfile_proto; -extern se::Class* __jsb_cc_AudioProfile_class; - -bool js_register_cc_AudioProfile(se::Object* obj); -bool register_all_audio(se::Object* obj); +bool register_all_audio(se::Object *obj); // NOLINT JSB_REGISTER_OBJECT_TYPE(cc::AudioProfile); +JSB_REGISTER_OBJECT_TYPE(cc::AudioEngine); + + +extern se::Object *__jsb_cc_AudioProfile_proto; // NOLINT +extern se::Class * __jsb_cc_AudioProfile_class; // NOLINT + +bool js_register_cc_AudioProfile(se::Object *obj); // NOLINT + SE_DECLARE_FUNC(js_audio_AudioProfile_AudioProfile); -extern se::Object* __jsb_cc_AudioEngine_proto; -extern se::Class* __jsb_cc_AudioEngine_class; +extern se::Object *__jsb_cc_AudioEngine_proto; // NOLINT +extern se::Class * __jsb_cc_AudioEngine_class; // NOLINT -bool js_register_cc_AudioEngine(se::Object* obj); -bool register_all_audio(se::Object* obj); +bool js_register_cc_AudioEngine(se::Object *obj); // NOLINT -JSB_REGISTER_OBJECT_TYPE(cc::AudioEngine); -SE_DECLARE_FUNC(js_audio_AudioEngine_lazyInit); SE_DECLARE_FUNC(js_audio_AudioEngine_end); -SE_DECLARE_FUNC(js_audio_AudioEngine_getDefaultProfile); -SE_DECLARE_FUNC(js_audio_AudioEngine_play2d); -SE_DECLARE_FUNC(js_audio_AudioEngine_setLoop); -SE_DECLARE_FUNC(js_audio_AudioEngine_isLoop); -SE_DECLARE_FUNC(js_audio_AudioEngine_setVolume); -SE_DECLARE_FUNC(js_audio_AudioEngine_getVolume); -SE_DECLARE_FUNC(js_audio_AudioEngine_pause); -SE_DECLARE_FUNC(js_audio_AudioEngine_pauseAll); -SE_DECLARE_FUNC(js_audio_AudioEngine_resume); -SE_DECLARE_FUNC(js_audio_AudioEngine_resumeAll); -SE_DECLARE_FUNC(js_audio_AudioEngine_stop); -SE_DECLARE_FUNC(js_audio_AudioEngine_stopAll); -SE_DECLARE_FUNC(js_audio_AudioEngine_setCurrentTime); SE_DECLARE_FUNC(js_audio_AudioEngine_getCurrentTime); +SE_DECLARE_FUNC(js_audio_AudioEngine_getDefaultProfile); SE_DECLARE_FUNC(js_audio_AudioEngine_getDuration); SE_DECLARE_FUNC(js_audio_AudioEngine_getDurationFromFile); -SE_DECLARE_FUNC(js_audio_AudioEngine_getState); -SE_DECLARE_FUNC(js_audio_AudioEngine_setFinishCallback); SE_DECLARE_FUNC(js_audio_AudioEngine_getMaxAudioInstance); +SE_DECLARE_FUNC(js_audio_AudioEngine_getPlayingAudioCount); +SE_DECLARE_FUNC(js_audio_AudioEngine_getProfile); +SE_DECLARE_FUNC(js_audio_AudioEngine_getState); +SE_DECLARE_FUNC(js_audio_AudioEngine_getVolume); +SE_DECLARE_FUNC(js_audio_AudioEngine_isEnabled); +SE_DECLARE_FUNC(js_audio_AudioEngine_isLoop); +SE_DECLARE_FUNC(js_audio_AudioEngine_lazyInit); +SE_DECLARE_FUNC(js_audio_AudioEngine_pause); +SE_DECLARE_FUNC(js_audio_AudioEngine_pauseAll); +SE_DECLARE_FUNC(js_audio_AudioEngine_play2d); +SE_DECLARE_FUNC(js_audio_AudioEngine_preload); +SE_DECLARE_FUNC(js_audio_AudioEngine_resume); +SE_DECLARE_FUNC(js_audio_AudioEngine_resumeAll); +SE_DECLARE_FUNC(js_audio_AudioEngine_setCurrentTime); +SE_DECLARE_FUNC(js_audio_AudioEngine_setEnabled); +SE_DECLARE_FUNC(js_audio_AudioEngine_setFinishCallback); +SE_DECLARE_FUNC(js_audio_AudioEngine_setLoop); SE_DECLARE_FUNC(js_audio_AudioEngine_setMaxAudioInstance); +SE_DECLARE_FUNC(js_audio_AudioEngine_setVolume); +SE_DECLARE_FUNC(js_audio_AudioEngine_stop); +SE_DECLARE_FUNC(js_audio_AudioEngine_stopAll); SE_DECLARE_FUNC(js_audio_AudioEngine_uncache); SE_DECLARE_FUNC(js_audio_AudioEngine_uncacheAll); -SE_DECLARE_FUNC(js_audio_AudioEngine_getProfile); -SE_DECLARE_FUNC(js_audio_AudioEngine_preload); -SE_DECLARE_FUNC(js_audio_AudioEngine_getPlayingAudioCount); -SE_DECLARE_FUNC(js_audio_AudioEngine_setEnabled); -SE_DECLARE_FUNC(js_audio_AudioEngine_isEnabled); - #endif //#if (USE_AUDIO > 0) + // clang-format on \ No newline at end of file diff --git a/native/cocos/bindings/auto/jsb_cocos_auto.cpp b/native/cocos/bindings/auto/jsb_cocos_auto.cpp index 70ee0c6736..5e338765af 100644 --- a/native/cocos/bindings/auto/jsb_cocos_auto.cpp +++ b/native/cocos/bindings/auto/jsb_cocos_auto.cpp @@ -1,3 +1,5 @@ + +// clang-format off #include "cocos/bindings/auto/jsb_cocos_auto.h" #include "cocos/bindings/manual/jsb_conversions.h" #include "cocos/bindings/manual/jsb_global.h" @@ -6,6 +8,11 @@ #include "platform/interfaces/modules/canvas/CanvasRenderingContext2D.h" #include "platform/interfaces/modules/Device.h" #include "platform/SAXParser.h" +#include "math/Vec2.h" +#include "math/Vec3.h" +#include "math/Quaternion.h" +#include "math/Color.h" +#include "core/data/Object.h" #ifndef JSB_ALLOC #define JSB_ALLOC(kls, ...) new (std::nothrow) kls(__VA_ARGS__) @@ -14,8 +21,8 @@ #ifndef JSB_FREE #define JSB_FREE(ptr) delete ptr #endif -se::Object* __jsb_cc_FileUtils_proto = nullptr; -se::Class* __jsb_cc_FileUtils_class = nullptr; +se::Object* __jsb_cc_FileUtils_proto = nullptr; // NOLINT +se::Class* __jsb_cc_FileUtils_class = nullptr; // NOLINT static bool js_engine_FileUtils_addSearchPath(se::State& s) // NOLINT(readability-identifier-naming) { @@ -740,7 +747,27 @@ static bool js_engine_FileUtils_writeValueVectorToFile(se::State& s) // NOLINT(r } SE_BIND_FUNC(js_engine_FileUtils_writeValueVectorToFile) -static bool js_engine_FileUtils_getInstance(se::State& s) // NOLINT(readability-identifier-naming) +static bool js_engine_FileUtils_getFileDir_static(se::State& s) // NOLINT(readability-identifier-naming) +{ + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 1) { + HolderType arg0 = {}; + ok &= sevalue_to_native(args[0], &arg0, nullptr); + SE_PRECONDITION2(ok, false, "js_engine_FileUtils_getFileDir_static : Error processing arguments"); + std::string result = cc::FileUtils::getFileDir(arg0.value()); + ok &= nativevalue_to_se(result, s.rval(), nullptr /*ctx*/); + SE_PRECONDITION2(ok, false, "js_engine_FileUtils_getFileDir_static : Error processing arguments"); + SE_HOLD_RETURN_VALUE(result, s.thisObject(), s.rval()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 1); + return false; +} +SE_BIND_FUNC(js_engine_FileUtils_getFileDir_static) + +static bool js_engine_FileUtils_getInstance_static(se::State& s) // NOLINT(readability-identifier-naming) { const auto& args = s.args(); size_t argc = args.size(); @@ -748,33 +775,16 @@ static bool js_engine_FileUtils_getInstance(se::State& s) // NOLINT(readability- if (argc == 0) { cc::FileUtils* result = cc::FileUtils::getInstance(); ok &= nativevalue_to_se(result, s.rval(), nullptr /*ctx*/); - SE_PRECONDITION2(ok, false, "js_engine_FileUtils_getInstance : Error processing arguments"); + SE_PRECONDITION2(ok, false, "js_engine_FileUtils_getInstance_static : Error processing arguments"); SE_HOLD_RETURN_VALUE(result, s.thisObject(), s.rval()); return true; } SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 0); return false; } -SE_BIND_FUNC(js_engine_FileUtils_getInstance) +SE_BIND_FUNC(js_engine_FileUtils_getInstance_static) -static bool js_engine_FileUtils_setDelegate(se::State& s) // NOLINT(readability-identifier-naming) -{ - const auto& args = s.args(); - size_t argc = args.size(); - CC_UNUSED bool ok = true; - if (argc == 1) { - HolderType arg0 = {}; - ok &= sevalue_to_native(args[0], &arg0, nullptr); - SE_PRECONDITION2(ok, false, "js_engine_FileUtils_setDelegate : Error processing arguments"); - cc::FileUtils::setDelegate(arg0.value()); - return true; - } - SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 1); - return false; -} -SE_BIND_FUNC(js_engine_FileUtils_setDelegate) - -static bool js_engine_FileUtils_normalizePath(se::State& s) // NOLINT(readability-identifier-naming) +static bool js_engine_FileUtils_normalizePath_static(se::State& s) // NOLINT(readability-identifier-naming) { const auto& args = s.args(); size_t argc = args.size(); @@ -782,48 +792,19 @@ static bool js_engine_FileUtils_normalizePath(se::State& s) // NOLINT(readabilit if (argc == 1) { HolderType arg0 = {}; ok &= sevalue_to_native(args[0], &arg0, nullptr); - SE_PRECONDITION2(ok, false, "js_engine_FileUtils_normalizePath : Error processing arguments"); + SE_PRECONDITION2(ok, false, "js_engine_FileUtils_normalizePath_static : Error processing arguments"); std::string result = cc::FileUtils::normalizePath(arg0.value()); ok &= nativevalue_to_se(result, s.rval(), nullptr /*ctx*/); - SE_PRECONDITION2(ok, false, "js_engine_FileUtils_normalizePath : Error processing arguments"); + SE_PRECONDITION2(ok, false, "js_engine_FileUtils_normalizePath_static : Error processing arguments"); SE_HOLD_RETURN_VALUE(result, s.thisObject(), s.rval()); return true; } SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 1); return false; } -SE_BIND_FUNC(js_engine_FileUtils_normalizePath) - -static bool js_engine_FileUtils_getFileDir(se::State& s) // NOLINT(readability-identifier-naming) -{ - const auto& args = s.args(); - size_t argc = args.size(); - CC_UNUSED bool ok = true; - if (argc == 1) { - HolderType arg0 = {}; - ok &= sevalue_to_native(args[0], &arg0, nullptr); - SE_PRECONDITION2(ok, false, "js_engine_FileUtils_getFileDir : Error processing arguments"); - std::string result = cc::FileUtils::getFileDir(arg0.value()); - ok &= nativevalue_to_se(result, s.rval(), nullptr /*ctx*/); - SE_PRECONDITION2(ok, false, "js_engine_FileUtils_getFileDir : Error processing arguments"); - SE_HOLD_RETURN_VALUE(result, s.thisObject(), s.rval()); - return true; - } - SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 1); - return false; -} -SE_BIND_FUNC(js_engine_FileUtils_getFileDir) - - +SE_BIND_FUNC(js_engine_FileUtils_normalizePath_static) static bool js_cc_FileUtils_finalize(se::State& s) // NOLINT(readability-identifier-naming) { - auto iter = se::NonRefNativePtrCreatedByCtorMap::find(SE_THIS_OBJECT(s)); - if (iter != se::NonRefNativePtrCreatedByCtorMap::end()) - { - se::NonRefNativePtrCreatedByCtorMap::erase(iter); - auto* cobj = SE_THIS_OBJECT(s); - JSB_FREE(cobj); - } return true; } SE_BIND_FINALIZE_FUNC(js_cc_FileUtils_finalize) @@ -864,10 +845,9 @@ bool js_register_engine_FileUtils(se::Object* obj) // NOLINT(readability-identif cls->defineFunction("writeToFile", _SE(js_engine_FileUtils_writeToFile)); cls->defineFunction("writeValueMapToFile", _SE(js_engine_FileUtils_writeValueMapToFile)); cls->defineFunction("writeValueVectorToFile", _SE(js_engine_FileUtils_writeValueVectorToFile)); - cls->defineStaticFunction("getInstance", _SE(js_engine_FileUtils_getInstance)); - cls->defineStaticFunction("setDelegate", _SE(js_engine_FileUtils_setDelegate)); - cls->defineStaticFunction("normalizePath", _SE(js_engine_FileUtils_normalizePath)); - cls->defineStaticFunction("getFileDir", _SE(js_engine_FileUtils_getFileDir)); + cls->defineStaticFunction("getFileDir", _SE(js_engine_FileUtils_getFileDir_static)); + cls->defineStaticFunction("getInstance", _SE(js_engine_FileUtils_getInstance_static)); + cls->defineStaticFunction("normalizePath", _SE(js_engine_FileUtils_normalizePath_static)); cls->defineFinalizeFunction(_SE(js_cc_FileUtils_finalize)); cls->install(); JSBClassType::registerClass(cls); @@ -875,13 +855,12 @@ bool js_register_engine_FileUtils(se::Object* obj) // NOLINT(readability-identif __jsb_cc_FileUtils_proto = cls->getProto(); __jsb_cc_FileUtils_class = cls; + se::ScriptEngine::getInstance()->clearException(); return true; } -se::Object* __jsb_cc_OSInterface_proto = nullptr; -se::Class* __jsb_cc_OSInterface_class = nullptr; - - +se::Object* __jsb_cc_OSInterface_proto = nullptr; // NOLINT +se::Class* __jsb_cc_OSInterface_class = nullptr; // NOLINT bool js_register_engine_OSInterface(se::Object* obj) // NOLINT(readability-identifier-naming) { @@ -893,11 +872,147 @@ bool js_register_engine_OSInterface(se::Object* obj) // NOLINT(readability-ident __jsb_cc_OSInterface_proto = cls->getProto(); __jsb_cc_OSInterface_class = cls; + se::ScriptEngine::getInstance()->clearException(); return true; } -se::Object* __jsb_cc_ICanvasGradient_proto = nullptr; -se::Class* __jsb_cc_ICanvasGradient_class = nullptr; +se::Object* __jsb_cc_Vec2_proto = nullptr; // NOLINT +se::Class* __jsb_cc_Vec2_class = nullptr; // NOLINT + +static bool js_engine_Vec2_get_x(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_engine_Vec2_get_x : Invalid Native Object"); + + CC_UNUSED bool ok = true; + se::Value jsret; + ok &= nativevalue_to_se(cobj->x, jsret, s.thisObject() /*ctx*/); + s.rval() = jsret; + SE_HOLD_RETURN_VALUE(cobj->x, s.thisObject(), s.rval()); + return true; +} +SE_BIND_PROP_GET(js_engine_Vec2_get_x) + +static bool js_engine_Vec2_set_x(se::State& s) // NOLINT(readability-identifier-naming) +{ + const auto& args = s.args(); + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_engine_Vec2_set_x : Invalid Native Object"); + + CC_UNUSED bool ok = true; + ok &= sevalue_to_native(args[0], &cobj->x, s.thisObject()); + SE_PRECONDITION2(ok, false, "js_engine_Vec2_set_x : Error processing new value"); + return true; +} +SE_BIND_PROP_SET(js_engine_Vec2_set_x) + +static bool js_engine_Vec2_get_y(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_engine_Vec2_get_y : Invalid Native Object"); + + CC_UNUSED bool ok = true; + se::Value jsret; + ok &= nativevalue_to_se(cobj->y, jsret, s.thisObject() /*ctx*/); + s.rval() = jsret; + SE_HOLD_RETURN_VALUE(cobj->y, s.thisObject(), s.rval()); + return true; +} +SE_BIND_PROP_GET(js_engine_Vec2_get_y) + +static bool js_engine_Vec2_set_y(se::State& s) // NOLINT(readability-identifier-naming) +{ + const auto& args = s.args(); + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_engine_Vec2_set_y : Invalid Native Object"); + + CC_UNUSED bool ok = true; + ok &= sevalue_to_native(args[0], &cobj->y, s.thisObject()); + SE_PRECONDITION2(ok, false, "js_engine_Vec2_set_y : Error processing new value"); + return true; +} +SE_BIND_PROP_SET(js_engine_Vec2_set_y) + +SE_DECLARE_FINALIZE_FUNC(js_cc_Vec2_finalize) + +static bool js_engine_Vec2_constructor(se::State& s) // NOLINT(readability-identifier-naming) constructor_overloaded.c +{ + CC_UNUSED bool ok = true; + const auto& args = s.args(); + size_t argc = args.size(); + do { + if (argc == 2) { + HolderType arg0 = {}; + ok &= sevalue_to_native(args[0], &arg0, s.thisObject()); + if (!ok) { ok = true; break; } + HolderType arg1 = {}; + ok &= sevalue_to_native(args[1], &arg1, s.thisObject()); + if (!ok) { ok = true; break; } + auto *ptr = JSB_MAKE_PRIVATE_OBJECT(cc::Vec2, arg0.value(), arg1.value()); + s.thisObject()->setPrivateObject(ptr); + return true; + } + } while(false); + do { + if (argc == 0) { + auto *ptr = JSB_MAKE_PRIVATE_OBJECT(cc::Vec2); + s.thisObject()->setPrivateObject(ptr); + return true; + } + } while(false); + do { + if (argc == 1) { + HolderType arg0 = {}; + ok &= sevalue_to_native(args[0], &arg0, s.thisObject()); + if (!ok) { ok = true; break; } + auto *ptr = JSB_MAKE_PRIVATE_OBJECT(cc::Vec2, arg0.value()); + s.thisObject()->setPrivateObject(ptr); + return true; + } + } while(false); + do { + if (argc == 2) { + HolderType arg0 = {}; + ok &= sevalue_to_native(args[0], &arg0, s.thisObject()); + if (!ok) { ok = true; break; } + HolderType arg1 = {}; + ok &= sevalue_to_native(args[1], &arg1, s.thisObject()); + if (!ok) { ok = true; break; } + auto *ptr = JSB_MAKE_PRIVATE_OBJECT(cc::Vec2, arg0.value(), arg1.value()); + s.thisObject()->setPrivateObject(ptr); + return true; + } + } while(false); + SE_REPORT_ERROR("wrong number of arguments: %d", (int)argc); + return false; +} +SE_BIND_CTOR(js_engine_Vec2_constructor, __jsb_cc_Vec2_class, js_cc_Vec2_finalize) + +static bool js_cc_Vec2_finalize(se::State& s) // NOLINT(readability-identifier-naming) +{ + return true; +} +SE_BIND_FINALIZE_FUNC(js_cc_Vec2_finalize) + +bool js_register_engine_Vec2(se::Object* obj) // NOLINT(readability-identifier-naming) +{ + auto* cls = se::Class::create("Vec2", obj, nullptr, _SE(js_engine_Vec2_constructor)); + + cls->defineProperty("x", _SE(js_engine_Vec2_get_x), _SE(js_engine_Vec2_set_x)); + cls->defineProperty("y", _SE(js_engine_Vec2_get_y), _SE(js_engine_Vec2_set_y)); + cls->defineFinalizeFunction(_SE(js_cc_Vec2_finalize)); + cls->install(); + JSBClassType::registerClass(cls); + + __jsb_cc_Vec2_proto = cls->getProto(); + __jsb_cc_Vec2_class = cls; + + + se::ScriptEngine::getInstance()->clearException(); + return true; +} +se::Object* __jsb_cc_ICanvasGradient_proto = nullptr; // NOLINT +se::Class* __jsb_cc_ICanvasGradient_class = nullptr; // NOLINT static bool js_engine_ICanvasGradient_addColorStop(se::State& s) // NOLINT(readability-identifier-naming) { @@ -920,8 +1035,6 @@ static bool js_engine_ICanvasGradient_addColorStop(se::State& s) // NOLINT(reada } SE_BIND_FUNC(js_engine_ICanvasGradient_addColorStop) - - bool js_register_engine_ICanvasGradient(se::Object* obj) // NOLINT(readability-identifier-naming) { auto* cls = se::Class::create("ICanvasGradient", obj, nullptr, nullptr); @@ -933,11 +1046,12 @@ bool js_register_engine_ICanvasGradient(se::Object* obj) // NOLINT(readability-i __jsb_cc_ICanvasGradient_proto = cls->getProto(); __jsb_cc_ICanvasGradient_class = cls; + se::ScriptEngine::getInstance()->clearException(); return true; } -se::Object* __jsb_cc_ICanvasRenderingContext2D_proto = nullptr; -se::Class* __jsb_cc_ICanvasRenderingContext2D_class = nullptr; +se::Object* __jsb_cc_ICanvasRenderingContext2D_proto = nullptr; // NOLINT +se::Class* __jsb_cc_ICanvasRenderingContext2D_class = nullptr; // NOLINT static bool js_engine_ICanvasRenderingContext2D_beginPath(se::State& s) // NOLINT(readability-identifier-naming) { @@ -1288,6 +1402,7 @@ static bool js_engine_ICanvasRenderingContext2D_setCanvasBufferUpdatedCallback(s se::Value jsThis(s.thisObject()); se::Value jsFunc(args[0]); jsThis.toObject()->attachObject(jsFunc.toObject()); + auto * thisObj = s.thisObject(); auto lambda = [=](const cc::Data & larg0) -> void { se::ScriptEngine::getInstance()->clearException(); se::AutoHandleScope hs; @@ -1297,7 +1412,6 @@ static bool js_engine_ICanvasRenderingContext2D_setCanvasBufferUpdatedCallback(s args.resize(1); ok &= nativevalue_to_se(larg0, args[0], nullptr /*ctx*/); se::Value rval; - se::Object* thisObj = jsThis.isObject() ? jsThis.toObject() : nullptr; se::Object* funcObj = jsFunc.toObject(); bool succeed = funcObj->call(args, thisObj, &rval); if (!succeed) { @@ -1338,7 +1452,7 @@ static bool js_engine_ICanvasRenderingContext2D_setFillStyle(se::State& s) // NO SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 1); return false; } -SE_BIND_PROP_SET(js_engine_ICanvasRenderingContext2D_setFillStyle) +SE_BIND_FUNC_AS_PROP_SET(js_engine_ICanvasRenderingContext2D_setFillStyle) static bool js_engine_ICanvasRenderingContext2D_setFont(se::State& s) // NOLINT(readability-identifier-naming) { @@ -1357,7 +1471,7 @@ static bool js_engine_ICanvasRenderingContext2D_setFont(se::State& s) // NOLINT( SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 1); return false; } -SE_BIND_PROP_SET(js_engine_ICanvasRenderingContext2D_setFont) +SE_BIND_FUNC_AS_PROP_SET(js_engine_ICanvasRenderingContext2D_setFont) static bool js_engine_ICanvasRenderingContext2D_setGlobalCompositeOperation(se::State& s) // NOLINT(readability-identifier-naming) { @@ -1376,7 +1490,7 @@ static bool js_engine_ICanvasRenderingContext2D_setGlobalCompositeOperation(se:: SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 1); return false; } -SE_BIND_PROP_SET(js_engine_ICanvasRenderingContext2D_setGlobalCompositeOperation) +SE_BIND_FUNC_AS_PROP_SET(js_engine_ICanvasRenderingContext2D_setGlobalCompositeOperation) static bool js_engine_ICanvasRenderingContext2D_setHeight(se::State& s) // NOLINT(readability-identifier-naming) { @@ -1395,7 +1509,7 @@ static bool js_engine_ICanvasRenderingContext2D_setHeight(se::State& s) // NOLIN SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 1); return false; } -SE_BIND_PROP_SET(js_engine_ICanvasRenderingContext2D_setHeight) +SE_BIND_FUNC_AS_PROP_SET(js_engine_ICanvasRenderingContext2D_setHeight) static bool js_engine_ICanvasRenderingContext2D_setLineCap(se::State& s) // NOLINT(readability-identifier-naming) { @@ -1414,7 +1528,7 @@ static bool js_engine_ICanvasRenderingContext2D_setLineCap(se::State& s) // NOLI SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 1); return false; } -SE_BIND_PROP_SET(js_engine_ICanvasRenderingContext2D_setLineCap) +SE_BIND_FUNC_AS_PROP_SET(js_engine_ICanvasRenderingContext2D_setLineCap) static bool js_engine_ICanvasRenderingContext2D_setLineJoin(se::State& s) // NOLINT(readability-identifier-naming) { @@ -1433,7 +1547,7 @@ static bool js_engine_ICanvasRenderingContext2D_setLineJoin(se::State& s) // NOL SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 1); return false; } -SE_BIND_PROP_SET(js_engine_ICanvasRenderingContext2D_setLineJoin) +SE_BIND_FUNC_AS_PROP_SET(js_engine_ICanvasRenderingContext2D_setLineJoin) static bool js_engine_ICanvasRenderingContext2D_setLineWidth(se::State& s) // NOLINT(readability-identifier-naming) { @@ -1452,7 +1566,7 @@ static bool js_engine_ICanvasRenderingContext2D_setLineWidth(se::State& s) // NO SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 1); return false; } -SE_BIND_PROP_SET(js_engine_ICanvasRenderingContext2D_setLineWidth) +SE_BIND_FUNC_AS_PROP_SET(js_engine_ICanvasRenderingContext2D_setLineWidth) static bool js_engine_ICanvasRenderingContext2D_setStrokeStyle(se::State& s) // NOLINT(readability-identifier-naming) { @@ -1471,7 +1585,7 @@ static bool js_engine_ICanvasRenderingContext2D_setStrokeStyle(se::State& s) // SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 1); return false; } -SE_BIND_PROP_SET(js_engine_ICanvasRenderingContext2D_setStrokeStyle) +SE_BIND_FUNC_AS_PROP_SET(js_engine_ICanvasRenderingContext2D_setStrokeStyle) static bool js_engine_ICanvasRenderingContext2D_setTextAlign(se::State& s) // NOLINT(readability-identifier-naming) { @@ -1490,7 +1604,7 @@ static bool js_engine_ICanvasRenderingContext2D_setTextAlign(se::State& s) // NO SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 1); return false; } -SE_BIND_PROP_SET(js_engine_ICanvasRenderingContext2D_setTextAlign) +SE_BIND_FUNC_AS_PROP_SET(js_engine_ICanvasRenderingContext2D_setTextAlign) static bool js_engine_ICanvasRenderingContext2D_setTextBaseline(se::State& s) // NOLINT(readability-identifier-naming) { @@ -1509,7 +1623,7 @@ static bool js_engine_ICanvasRenderingContext2D_setTextBaseline(se::State& s) // SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 1); return false; } -SE_BIND_PROP_SET(js_engine_ICanvasRenderingContext2D_setTextBaseline) +SE_BIND_FUNC_AS_PROP_SET(js_engine_ICanvasRenderingContext2D_setTextBaseline) static bool js_engine_ICanvasRenderingContext2D_setTransform(se::State& s) // NOLINT(readability-identifier-naming) { @@ -1557,7 +1671,7 @@ static bool js_engine_ICanvasRenderingContext2D_setWidth(se::State& s) // NOLINT SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 1); return false; } -SE_BIND_PROP_SET(js_engine_ICanvasRenderingContext2D_setWidth) +SE_BIND_FUNC_AS_PROP_SET(js_engine_ICanvasRenderingContext2D_setWidth) static bool js_engine_ICanvasRenderingContext2D_stroke(se::State& s) // NOLINT(readability-identifier-naming) { @@ -1649,23 +1763,21 @@ static bool js_engine_ICanvasRenderingContext2D_translate(se::State& s) // NOLIN } SE_BIND_FUNC(js_engine_ICanvasRenderingContext2D_translate) - - bool js_register_engine_ICanvasRenderingContext2D(se::Object* obj) // NOLINT(readability-identifier-naming) { auto* cls = se::Class::create("ICanvasRenderingContext2D", obj, __jsb_cc_OSInterface_proto, nullptr); - cls->defineProperty("width", nullptr, _SE(js_engine_ICanvasRenderingContext2D_setWidth)); - cls->defineProperty("height", nullptr, _SE(js_engine_ICanvasRenderingContext2D_setHeight)); - cls->defineProperty("fillStyle", nullptr, _SE(js_engine_ICanvasRenderingContext2D_setFillStyle)); - cls->defineProperty("font", nullptr, _SE(js_engine_ICanvasRenderingContext2D_setFont)); - cls->defineProperty("globalCompositeOperation", nullptr, _SE(js_engine_ICanvasRenderingContext2D_setGlobalCompositeOperation)); - cls->defineProperty("lineCap", nullptr, _SE(js_engine_ICanvasRenderingContext2D_setLineCap)); - cls->defineProperty("lineJoin", nullptr, _SE(js_engine_ICanvasRenderingContext2D_setLineJoin)); - cls->defineProperty("lineWidth", nullptr, _SE(js_engine_ICanvasRenderingContext2D_setLineWidth)); - cls->defineProperty("strokeStyle", nullptr, _SE(js_engine_ICanvasRenderingContext2D_setStrokeStyle)); - cls->defineProperty("textAlign", nullptr, _SE(js_engine_ICanvasRenderingContext2D_setTextAlign)); - cls->defineProperty("textBaseline", nullptr, _SE(js_engine_ICanvasRenderingContext2D_setTextBaseline)); + cls->defineProperty("strokeStyle", nullptr, _SE(js_engine_ICanvasRenderingContext2D_setStrokeStyle_asSetter)); + cls->defineProperty("lineWidth", nullptr, _SE(js_engine_ICanvasRenderingContext2D_setLineWidth_asSetter)); + cls->defineProperty("lineCap", nullptr, _SE(js_engine_ICanvasRenderingContext2D_setLineCap_asSetter)); + cls->defineProperty("globalCompositeOperation", nullptr, _SE(js_engine_ICanvasRenderingContext2D_setGlobalCompositeOperation_asSetter)); + cls->defineProperty("fillStyle", nullptr, _SE(js_engine_ICanvasRenderingContext2D_setFillStyle_asSetter)); + cls->defineProperty("height", nullptr, _SE(js_engine_ICanvasRenderingContext2D_setHeight_asSetter)); + cls->defineProperty("width", nullptr, _SE(js_engine_ICanvasRenderingContext2D_setWidth_asSetter)); + cls->defineProperty("textBaseline", nullptr, _SE(js_engine_ICanvasRenderingContext2D_setTextBaseline_asSetter)); + cls->defineProperty("lineJoin", nullptr, _SE(js_engine_ICanvasRenderingContext2D_setLineJoin_asSetter)); + cls->defineProperty("font", nullptr, _SE(js_engine_ICanvasRenderingContext2D_setFont_asSetter)); + cls->defineProperty("textAlign", nullptr, _SE(js_engine_ICanvasRenderingContext2D_setTextAlign_asSetter)); cls->defineFunction("beginPath", _SE(js_engine_ICanvasRenderingContext2D_beginPath)); cls->defineFunction("clearRect", _SE(js_engine_ICanvasRenderingContext2D_clearRect)); cls->defineFunction("closePath", _SE(js_engine_ICanvasRenderingContext2D_closePath)); @@ -1694,34 +1806,25 @@ bool js_register_engine_ICanvasRenderingContext2D(se::Object* obj) // NOLINT(rea __jsb_cc_ICanvasRenderingContext2D_proto = cls->getProto(); __jsb_cc_ICanvasRenderingContext2D_class = cls; + se::ScriptEngine::getInstance()->clearException(); return true; } -se::Object* __jsb_cc_CanvasGradient_proto = nullptr; -se::Class* __jsb_cc_CanvasGradient_class = nullptr; +se::Object* __jsb_cc_CanvasGradient_proto = nullptr; // NOLINT +se::Class* __jsb_cc_CanvasGradient_class = nullptr; // NOLINT SE_DECLARE_FINALIZE_FUNC(js_cc_CanvasGradient_finalize) static bool js_engine_CanvasGradient_constructor(se::State& s) // NOLINT(readability-identifier-naming) constructor.c { - cc::CanvasGradient* cobj = JSB_ALLOC(cc::CanvasGradient); - s.thisObject()->setPrivateData(cobj); - se::NonRefNativePtrCreatedByCtorMap::emplace(cobj); + auto *ptr = JSB_MAKE_PRIVATE_OBJECT(cc::CanvasGradient); + s.thisObject()->setPrivateObject(ptr); return true; } SE_BIND_CTOR(js_engine_CanvasGradient_constructor, __jsb_cc_CanvasGradient_class, js_cc_CanvasGradient_finalize) - - static bool js_cc_CanvasGradient_finalize(se::State& s) // NOLINT(readability-identifier-naming) { - auto iter = se::NonRefNativePtrCreatedByCtorMap::find(SE_THIS_OBJECT(s)); - if (iter != se::NonRefNativePtrCreatedByCtorMap::end()) - { - se::NonRefNativePtrCreatedByCtorMap::erase(iter); - auto* cobj = SE_THIS_OBJECT(s); - JSB_FREE(cobj); - } return true; } SE_BIND_FINALIZE_FUNC(js_cc_CanvasGradient_finalize) @@ -1737,11 +1840,12 @@ bool js_register_engine_CanvasGradient(se::Object* obj) // NOLINT(readability-id __jsb_cc_CanvasGradient_proto = cls->getProto(); __jsb_cc_CanvasGradient_class = cls; + se::ScriptEngine::getInstance()->clearException(); return true; } -se::Object* __jsb_cc_CanvasRenderingContext2D_proto = nullptr; -se::Class* __jsb_cc_CanvasRenderingContext2D_class = nullptr; +se::Object* __jsb_cc_CanvasRenderingContext2D_proto = nullptr; // NOLINT +se::Class* __jsb_cc_CanvasRenderingContext2D_class = nullptr; // NOLINT SE_DECLARE_FINALIZE_FUNC(js_cc_CanvasRenderingContext2D_finalize) @@ -1754,24 +1858,14 @@ static bool js_engine_CanvasRenderingContext2D_constructor(se::State& s) // NOLI ok &= sevalue_to_native(args[0], &arg0, s.thisObject()); ok &= sevalue_to_native(args[1], &arg1, s.thisObject()); SE_PRECONDITION2(ok, false, "js_engine_CanvasRenderingContext2D_constructor : Error processing arguments"); - cc::CanvasRenderingContext2D* cobj = JSB_ALLOC(cc::CanvasRenderingContext2D, arg0, arg1); - s.thisObject()->setPrivateData(cobj); - se::NonRefNativePtrCreatedByCtorMap::emplace(cobj); + auto *ptr = JSB_MAKE_PRIVATE_OBJECT(cc::CanvasRenderingContext2D, arg0, arg1); + s.thisObject()->setPrivateObject(ptr); return true; } SE_BIND_CTOR(js_engine_CanvasRenderingContext2D_constructor, __jsb_cc_CanvasRenderingContext2D_class, js_cc_CanvasRenderingContext2D_finalize) - - static bool js_cc_CanvasRenderingContext2D_finalize(se::State& s) // NOLINT(readability-identifier-naming) { - auto iter = se::NonRefNativePtrCreatedByCtorMap::find(SE_THIS_OBJECT(s)); - if (iter != se::NonRefNativePtrCreatedByCtorMap::end()) - { - se::NonRefNativePtrCreatedByCtorMap::erase(iter); - auto* cobj = SE_THIS_OBJECT(s); - JSB_FREE(cobj); - } return true; } SE_BIND_FINALIZE_FUNC(js_cc_CanvasRenderingContext2D_finalize) @@ -1787,149 +1881,14 @@ bool js_register_engine_CanvasRenderingContext2D(se::Object* obj) // NOLINT(read __jsb_cc_CanvasRenderingContext2D_proto = cls->getProto(); __jsb_cc_CanvasRenderingContext2D_class = cls; + se::ScriptEngine::getInstance()->clearException(); return true; } -se::Object* __jsb_cc_Device_proto = nullptr; -se::Class* __jsb_cc_Device_class = nullptr; +se::Object* __jsb_cc_Device_proto = nullptr; // NOLINT +se::Class* __jsb_cc_Device_class = nullptr; // NOLINT -static bool js_engine_Device_getDPI(se::State& s) // NOLINT(readability-identifier-naming) -{ - const auto& args = s.args(); - size_t argc = args.size(); - CC_UNUSED bool ok = true; - if (argc == 0) { - int result = cc::Device::getDPI(); - ok &= nativevalue_to_se(result, s.rval(), nullptr /*ctx*/); - SE_PRECONDITION2(ok, false, "js_engine_Device_getDPI : Error processing arguments"); - SE_HOLD_RETURN_VALUE(result, s.thisObject(), s.rval()); - return true; - } - SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 0); - return false; -} -SE_BIND_FUNC(js_engine_Device_getDPI) - -static bool js_engine_Device_getDevicePixelRatio(se::State& s) // NOLINT(readability-identifier-naming) -{ - const auto& args = s.args(); - size_t argc = args.size(); - CC_UNUSED bool ok = true; - if (argc == 0) { - float result = cc::Device::getDevicePixelRatio(); - ok &= nativevalue_to_se(result, s.rval(), nullptr /*ctx*/); - SE_PRECONDITION2(ok, false, "js_engine_Device_getDevicePixelRatio : Error processing arguments"); - SE_HOLD_RETURN_VALUE(result, s.thisObject(), s.rval()); - return true; - } - SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 0); - return false; -} -SE_BIND_FUNC(js_engine_Device_getDevicePixelRatio) - -static bool js_engine_Device_setAccelerometerEnabled(se::State& s) // NOLINT(readability-identifier-naming) -{ - const auto& args = s.args(); - size_t argc = args.size(); - CC_UNUSED bool ok = true; - if (argc == 1) { - HolderType arg0 = {}; - ok &= sevalue_to_native(args[0], &arg0, nullptr); - SE_PRECONDITION2(ok, false, "js_engine_Device_setAccelerometerEnabled : Error processing arguments"); - cc::Device::setAccelerometerEnabled(arg0.value()); - return true; - } - SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 1); - return false; -} -SE_BIND_FUNC(js_engine_Device_setAccelerometerEnabled) - -static bool js_engine_Device_setAccelerometerInterval(se::State& s) // NOLINT(readability-identifier-naming) -{ - const auto& args = s.args(); - size_t argc = args.size(); - CC_UNUSED bool ok = true; - if (argc == 1) { - HolderType arg0 = {}; - ok &= sevalue_to_native(args[0], &arg0, nullptr); - SE_PRECONDITION2(ok, false, "js_engine_Device_setAccelerometerInterval : Error processing arguments"); - cc::Device::setAccelerometerInterval(arg0.value()); - return true; - } - SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 1); - return false; -} -SE_BIND_FUNC(js_engine_Device_setAccelerometerInterval) - -static bool js_engine_Device_getDeviceOrientation(se::State& s) // NOLINT(readability-identifier-naming) -{ - const auto& args = s.args(); - size_t argc = args.size(); - CC_UNUSED bool ok = true; - if (argc == 0) { - auto result = static_cast(cc::Device::getDeviceOrientation()); - ok &= nativevalue_to_se(result, s.rval(), nullptr /*ctx*/); - SE_PRECONDITION2(ok, false, "js_engine_Device_getDeviceOrientation : Error processing arguments"); - SE_HOLD_RETURN_VALUE(result, s.thisObject(), s.rval()); - return true; - } - SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 0); - return false; -} -SE_BIND_FUNC(js_engine_Device_getDeviceOrientation) - -static bool js_engine_Device_getDeviceModel(se::State& s) // NOLINT(readability-identifier-naming) -{ - const auto& args = s.args(); - size_t argc = args.size(); - CC_UNUSED bool ok = true; - if (argc == 0) { - std::string result = cc::Device::getDeviceModel(); - ok &= nativevalue_to_se(result, s.rval(), nullptr /*ctx*/); - SE_PRECONDITION2(ok, false, "js_engine_Device_getDeviceModel : Error processing arguments"); - SE_HOLD_RETURN_VALUE(result, s.thisObject(), s.rval()); - return true; - } - SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 0); - return false; -} -SE_BIND_FUNC(js_engine_Device_getDeviceModel) - -static bool js_engine_Device_setKeepScreenOn(se::State& s) // NOLINT(readability-identifier-naming) -{ - const auto& args = s.args(); - size_t argc = args.size(); - CC_UNUSED bool ok = true; - if (argc == 1) { - HolderType arg0 = {}; - ok &= sevalue_to_native(args[0], &arg0, nullptr); - SE_PRECONDITION2(ok, false, "js_engine_Device_setKeepScreenOn : Error processing arguments"); - cc::Device::setKeepScreenOn(arg0.value()); - return true; - } - SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 1); - return false; -} -SE_BIND_FUNC(js_engine_Device_setKeepScreenOn) - -static bool js_engine_Device_vibrate(se::State& s) // NOLINT(readability-identifier-naming) -{ - const auto& args = s.args(); - size_t argc = args.size(); - CC_UNUSED bool ok = true; - if (argc == 1) { - HolderType arg0 = {}; - ok &= sevalue_to_native(args[0], &arg0, nullptr); - SE_PRECONDITION2(ok, false, "js_engine_Device_vibrate : Error processing arguments"); - cc::Device::vibrate(arg0.value()); - return true; - } - SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 1); - return false; -} -SE_BIND_FUNC(js_engine_Device_vibrate) - -static bool js_engine_Device_getBatteryLevel(se::State& s) // NOLINT(readability-identifier-naming) +static bool js_engine_Device_getBatteryLevel_static(se::State& s) // NOLINT(readability-identifier-naming) { const auto& args = s.args(); size_t argc = args.size(); @@ -1937,16 +1896,84 @@ static bool js_engine_Device_getBatteryLevel(se::State& s) // NOLINT(readability if (argc == 0) { float result = cc::Device::getBatteryLevel(); ok &= nativevalue_to_se(result, s.rval(), nullptr /*ctx*/); - SE_PRECONDITION2(ok, false, "js_engine_Device_getBatteryLevel : Error processing arguments"); + SE_PRECONDITION2(ok, false, "js_engine_Device_getBatteryLevel_static : Error processing arguments"); SE_HOLD_RETURN_VALUE(result, s.thisObject(), s.rval()); return true; } SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 0); return false; } -SE_BIND_FUNC(js_engine_Device_getBatteryLevel) +SE_BIND_FUNC(js_engine_Device_getBatteryLevel_static) -static bool js_engine_Device_getNetworkType(se::State& s) // NOLINT(readability-identifier-naming) +static bool js_engine_Device_getDPI_static(se::State& s) // NOLINT(readability-identifier-naming) +{ + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 0) { + int result = cc::Device::getDPI(); + ok &= nativevalue_to_se(result, s.rval(), nullptr /*ctx*/); + SE_PRECONDITION2(ok, false, "js_engine_Device_getDPI_static : Error processing arguments"); + SE_HOLD_RETURN_VALUE(result, s.thisObject(), s.rval()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 0); + return false; +} +SE_BIND_FUNC(js_engine_Device_getDPI_static) + +static bool js_engine_Device_getDeviceModel_static(se::State& s) // NOLINT(readability-identifier-naming) +{ + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 0) { + std::string result = cc::Device::getDeviceModel(); + ok &= nativevalue_to_se(result, s.rval(), nullptr /*ctx*/); + SE_PRECONDITION2(ok, false, "js_engine_Device_getDeviceModel_static : Error processing arguments"); + SE_HOLD_RETURN_VALUE(result, s.thisObject(), s.rval()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 0); + return false; +} +SE_BIND_FUNC(js_engine_Device_getDeviceModel_static) + +static bool js_engine_Device_getDeviceOrientation_static(se::State& s) // NOLINT(readability-identifier-naming) +{ + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 0) { + auto result = static_cast(cc::Device::getDeviceOrientation()); + ok &= nativevalue_to_se(result, s.rval(), nullptr /*ctx*/); + SE_PRECONDITION2(ok, false, "js_engine_Device_getDeviceOrientation_static : Error processing arguments"); + SE_HOLD_RETURN_VALUE(result, s.thisObject(), s.rval()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 0); + return false; +} +SE_BIND_FUNC(js_engine_Device_getDeviceOrientation_static) + +static bool js_engine_Device_getDevicePixelRatio_static(se::State& s) // NOLINT(readability-identifier-naming) +{ + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 0) { + float result = cc::Device::getDevicePixelRatio(); + ok &= nativevalue_to_se(result, s.rval(), nullptr /*ctx*/); + SE_PRECONDITION2(ok, false, "js_engine_Device_getDevicePixelRatio_static : Error processing arguments"); + SE_HOLD_RETURN_VALUE(result, s.thisObject(), s.rval()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 0); + return false; +} +SE_BIND_FUNC(js_engine_Device_getDevicePixelRatio_static) + +static bool js_engine_Device_getNetworkType_static(se::State& s) // NOLINT(readability-identifier-naming) { const auto& args = s.args(); size_t argc = args.size(); @@ -1954,16 +1981,16 @@ static bool js_engine_Device_getNetworkType(se::State& s) // NOLINT(readability- if (argc == 0) { auto result = static_cast(cc::Device::getNetworkType()); ok &= nativevalue_to_se(result, s.rval(), nullptr /*ctx*/); - SE_PRECONDITION2(ok, false, "js_engine_Device_getNetworkType : Error processing arguments"); + SE_PRECONDITION2(ok, false, "js_engine_Device_getNetworkType_static : Error processing arguments"); SE_HOLD_RETURN_VALUE(result, s.thisObject(), s.rval()); return true; } SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 0); return false; } -SE_BIND_FUNC(js_engine_Device_getNetworkType) +SE_BIND_FUNC(js_engine_Device_getNetworkType_static) -static bool js_engine_Device_getSafeAreaEdge(se::State& s) // NOLINT(readability-identifier-naming) +static bool js_engine_Device_getSafeAreaEdge_static(se::State& s) // NOLINT(readability-identifier-naming) { const auto& args = s.args(); size_t argc = args.size(); @@ -1971,43 +1998,110 @@ static bool js_engine_Device_getSafeAreaEdge(se::State& s) // NOLINT(readability if (argc == 0) { cc::Vec4 result = cc::Device::getSafeAreaEdge(); ok &= nativevalue_to_se(result, s.rval(), nullptr /*ctx*/); - SE_PRECONDITION2(ok, false, "js_engine_Device_getSafeAreaEdge : Error processing arguments"); + SE_PRECONDITION2(ok, false, "js_engine_Device_getSafeAreaEdge_static : Error processing arguments"); SE_HOLD_RETURN_VALUE(result, s.thisObject(), s.rval()); return true; } SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 0); return false; } -SE_BIND_FUNC(js_engine_Device_getSafeAreaEdge) +SE_BIND_FUNC(js_engine_Device_getSafeAreaEdge_static) +static bool js_engine_Device_setAccelerometerEnabled_static(se::State& s) // NOLINT(readability-identifier-naming) +{ + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 1) { + HolderType arg0 = {}; + ok &= sevalue_to_native(args[0], &arg0, nullptr); + SE_PRECONDITION2(ok, false, "js_engine_Device_setAccelerometerEnabled_static : Error processing arguments"); + cc::Device::setAccelerometerEnabled(arg0.value()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 1); + return false; +} +SE_BIND_FUNC(js_engine_Device_setAccelerometerEnabled_static) +static bool js_engine_Device_setAccelerometerInterval_static(se::State& s) // NOLINT(readability-identifier-naming) +{ + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 1) { + HolderType arg0 = {}; + ok &= sevalue_to_native(args[0], &arg0, nullptr); + SE_PRECONDITION2(ok, false, "js_engine_Device_setAccelerometerInterval_static : Error processing arguments"); + cc::Device::setAccelerometerInterval(arg0.value()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 1); + return false; +} +SE_BIND_FUNC(js_engine_Device_setAccelerometerInterval_static) + +static bool js_engine_Device_setKeepScreenOn_static(se::State& s) // NOLINT(readability-identifier-naming) +{ + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 1) { + HolderType arg0 = {}; + ok &= sevalue_to_native(args[0], &arg0, nullptr); + SE_PRECONDITION2(ok, false, "js_engine_Device_setKeepScreenOn_static : Error processing arguments"); + cc::Device::setKeepScreenOn(arg0.value()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 1); + return false; +} +SE_BIND_FUNC(js_engine_Device_setKeepScreenOn_static) + +static bool js_engine_Device_vibrate_static(se::State& s) // NOLINT(readability-identifier-naming) +{ + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 1) { + HolderType arg0 = {}; + ok &= sevalue_to_native(args[0], &arg0, nullptr); + SE_PRECONDITION2(ok, false, "js_engine_Device_vibrate_static : Error processing arguments"); + cc::Device::vibrate(arg0.value()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 1); + return false; +} +SE_BIND_FUNC(js_engine_Device_vibrate_static) bool js_register_engine_Device(se::Object* obj) // NOLINT(readability-identifier-naming) { auto* cls = se::Class::create("Device", obj, nullptr, nullptr); - cls->defineStaticFunction("getDPI", _SE(js_engine_Device_getDPI)); - cls->defineStaticFunction("getDevicePixelRatio", _SE(js_engine_Device_getDevicePixelRatio)); - cls->defineStaticFunction("setAccelerometerEnabled", _SE(js_engine_Device_setAccelerometerEnabled)); - cls->defineStaticFunction("setAccelerometerInterval", _SE(js_engine_Device_setAccelerometerInterval)); - cls->defineStaticFunction("getDeviceOrientation", _SE(js_engine_Device_getDeviceOrientation)); - cls->defineStaticFunction("getDeviceModel", _SE(js_engine_Device_getDeviceModel)); - cls->defineStaticFunction("setKeepScreenOn", _SE(js_engine_Device_setKeepScreenOn)); - cls->defineStaticFunction("vibrate", _SE(js_engine_Device_vibrate)); - cls->defineStaticFunction("getBatteryLevel", _SE(js_engine_Device_getBatteryLevel)); - cls->defineStaticFunction("getNetworkType", _SE(js_engine_Device_getNetworkType)); - cls->defineStaticFunction("getSafeAreaEdge", _SE(js_engine_Device_getSafeAreaEdge)); + cls->defineStaticFunction("getBatteryLevel", _SE(js_engine_Device_getBatteryLevel_static)); + cls->defineStaticFunction("getDPI", _SE(js_engine_Device_getDPI_static)); + cls->defineStaticFunction("getDeviceModel", _SE(js_engine_Device_getDeviceModel_static)); + cls->defineStaticFunction("getDeviceOrientation", _SE(js_engine_Device_getDeviceOrientation_static)); + cls->defineStaticFunction("getDevicePixelRatio", _SE(js_engine_Device_getDevicePixelRatio_static)); + cls->defineStaticFunction("getNetworkType", _SE(js_engine_Device_getNetworkType_static)); + cls->defineStaticFunction("getSafeAreaEdge", _SE(js_engine_Device_getSafeAreaEdge_static)); + cls->defineStaticFunction("setAccelerometerEnabled", _SE(js_engine_Device_setAccelerometerEnabled_static)); + cls->defineStaticFunction("setAccelerometerInterval", _SE(js_engine_Device_setAccelerometerInterval_static)); + cls->defineStaticFunction("setKeepScreenOn", _SE(js_engine_Device_setKeepScreenOn_static)); + cls->defineStaticFunction("vibrate", _SE(js_engine_Device_vibrate_static)); cls->install(); JSBClassType::registerClass(cls); __jsb_cc_Device_proto = cls->getProto(); __jsb_cc_Device_class = cls; + se::ScriptEngine::getInstance()->clearException(); return true; } -se::Object* __jsb_cc_SAXParser_proto = nullptr; -se::Class* __jsb_cc_SAXParser_class = nullptr; +se::Object* __jsb_cc_SAXParser_proto = nullptr; // NOLINT +se::Class* __jsb_cc_SAXParser_class = nullptr; // NOLINT static bool js_engine_SAXParser_init(se::State& s) // NOLINT(readability-identifier-naming) { @@ -2031,8 +2125,6 @@ static bool js_engine_SAXParser_init(se::State& s) // NOLINT(readability-identif } SE_BIND_FUNC(js_engine_SAXParser_init) - - bool js_register_engine_SAXParser(se::Object* obj) // NOLINT(readability-identifier-naming) { auto* cls = se::Class::create("PlistParser", obj, nullptr, nullptr); @@ -2044,14 +2136,524 @@ bool js_register_engine_SAXParser(se::Object* obj) // NOLINT(readability-identif __jsb_cc_SAXParser_proto = cls->getProto(); __jsb_cc_SAXParser_class = cls; + se::ScriptEngine::getInstance()->clearException(); return true; } -bool register_all_engine(se::Object* obj) +se::Object* __jsb_cc_Color_proto = nullptr; // NOLINT +se::Class* __jsb_cc_Color_class = nullptr; // NOLINT + +static bool js_engine_Color_get_r(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_engine_Color_get_r : Invalid Native Object"); + + CC_UNUSED bool ok = true; + se::Value jsret; + ok &= nativevalue_to_se(cobj->r, jsret, s.thisObject() /*ctx*/); + s.rval() = jsret; + SE_HOLD_RETURN_VALUE(cobj->r, s.thisObject(), s.rval()); + return true; +} +SE_BIND_PROP_GET(js_engine_Color_get_r) + +static bool js_engine_Color_set_r(se::State& s) // NOLINT(readability-identifier-naming) +{ + const auto& args = s.args(); + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_engine_Color_set_r : Invalid Native Object"); + + CC_UNUSED bool ok = true; + ok &= sevalue_to_native(args[0], &cobj->r, s.thisObject()); + SE_PRECONDITION2(ok, false, "js_engine_Color_set_r : Error processing new value"); + return true; +} +SE_BIND_PROP_SET(js_engine_Color_set_r) + +static bool js_engine_Color_get_g(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_engine_Color_get_g : Invalid Native Object"); + + CC_UNUSED bool ok = true; + se::Value jsret; + ok &= nativevalue_to_se(cobj->g, jsret, s.thisObject() /*ctx*/); + s.rval() = jsret; + SE_HOLD_RETURN_VALUE(cobj->g, s.thisObject(), s.rval()); + return true; +} +SE_BIND_PROP_GET(js_engine_Color_get_g) + +static bool js_engine_Color_set_g(se::State& s) // NOLINT(readability-identifier-naming) +{ + const auto& args = s.args(); + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_engine_Color_set_g : Invalid Native Object"); + + CC_UNUSED bool ok = true; + ok &= sevalue_to_native(args[0], &cobj->g, s.thisObject()); + SE_PRECONDITION2(ok, false, "js_engine_Color_set_g : Error processing new value"); + return true; +} +SE_BIND_PROP_SET(js_engine_Color_set_g) + +static bool js_engine_Color_get_b(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_engine_Color_get_b : Invalid Native Object"); + + CC_UNUSED bool ok = true; + se::Value jsret; + ok &= nativevalue_to_se(cobj->b, jsret, s.thisObject() /*ctx*/); + s.rval() = jsret; + SE_HOLD_RETURN_VALUE(cobj->b, s.thisObject(), s.rval()); + return true; +} +SE_BIND_PROP_GET(js_engine_Color_get_b) + +static bool js_engine_Color_set_b(se::State& s) // NOLINT(readability-identifier-naming) +{ + const auto& args = s.args(); + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_engine_Color_set_b : Invalid Native Object"); + + CC_UNUSED bool ok = true; + ok &= sevalue_to_native(args[0], &cobj->b, s.thisObject()); + SE_PRECONDITION2(ok, false, "js_engine_Color_set_b : Error processing new value"); + return true; +} +SE_BIND_PROP_SET(js_engine_Color_set_b) + +static bool js_engine_Color_get_a(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_engine_Color_get_a : Invalid Native Object"); + + CC_UNUSED bool ok = true; + se::Value jsret; + ok &= nativevalue_to_se(cobj->a, jsret, s.thisObject() /*ctx*/); + s.rval() = jsret; + SE_HOLD_RETURN_VALUE(cobj->a, s.thisObject(), s.rval()); + return true; +} +SE_BIND_PROP_GET(js_engine_Color_get_a) + +static bool js_engine_Color_set_a(se::State& s) // NOLINT(readability-identifier-naming) +{ + const auto& args = s.args(); + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_engine_Color_set_a : Invalid Native Object"); + + CC_UNUSED bool ok = true; + ok &= sevalue_to_native(args[0], &cobj->a, s.thisObject()); + SE_PRECONDITION2(ok, false, "js_engine_Color_set_a : Error processing new value"); + return true; +} +SE_BIND_PROP_SET(js_engine_Color_set_a) + +SE_DECLARE_FINALIZE_FUNC(js_cc_Color_finalize) + +static bool js_engine_Color_constructor(se::State& s) // NOLINT(readability-identifier-naming) constructor_overloaded.c +{ + CC_UNUSED bool ok = true; + const auto& args = s.args(); + size_t argc = args.size(); + do { + if (argc == 4) { + HolderType arg0 = {}; + ok &= sevalue_to_native(args[0], &arg0, s.thisObject()); + if (!ok) { ok = true; break; } + HolderType arg1 = {}; + ok &= sevalue_to_native(args[1], &arg1, s.thisObject()); + if (!ok) { ok = true; break; } + HolderType arg2 = {}; + ok &= sevalue_to_native(args[2], &arg2, s.thisObject()); + if (!ok) { ok = true; break; } + HolderType arg3 = {}; + ok &= sevalue_to_native(args[3], &arg3, s.thisObject()); + if (!ok) { ok = true; break; } + auto *ptr = JSB_MAKE_PRIVATE_OBJECT(cc::Color, arg0.value(), arg1.value(), arg2.value(), arg3.value()); + s.thisObject()->setPrivateObject(ptr); + return true; + } + } while(false); + do { + if (argc == 0) { + auto *ptr = JSB_MAKE_PRIVATE_OBJECT(cc::Color); + s.thisObject()->setPrivateObject(ptr); + return true; + } + } while(false); + do { + if (argc == 1) { + HolderType arg0 = {}; + ok &= sevalue_to_native(args[0], &arg0, s.thisObject()); + if (!ok) { ok = true; break; } + auto *ptr = JSB_MAKE_PRIVATE_OBJECT(cc::Color, arg0.value()); + s.thisObject()->setPrivateObject(ptr); + return true; + } + } while(false); + do { + if (argc == 1) { + HolderType arg0 = {}; + ok &= sevalue_to_native(args[0], &arg0, s.thisObject()); + if (!ok) { ok = true; break; } + auto *ptr = JSB_MAKE_PRIVATE_OBJECT(cc::Color, arg0.value()); + s.thisObject()->setPrivateObject(ptr); + return true; + } + } while(false); + do { + if (argc == 2) { + HolderType arg0 = {}; + ok &= sevalue_to_native(args[0], &arg0, s.thisObject()); + if (!ok) { ok = true; break; } + HolderType arg1 = {}; + ok &= sevalue_to_native(args[1], &arg1, s.thisObject()); + if (!ok) { ok = true; break; } + auto *ptr = JSB_MAKE_PRIVATE_OBJECT(cc::Color, arg0.value(), arg1.value()); + s.thisObject()->setPrivateObject(ptr); + return true; + } + } while(false); + SE_REPORT_ERROR("wrong number of arguments: %d", (int)argc); + return false; +} +SE_BIND_CTOR(js_engine_Color_constructor, __jsb_cc_Color_class, js_cc_Color_finalize) + +static bool js_cc_Color_finalize(se::State& s) // NOLINT(readability-identifier-naming) +{ + return true; +} +SE_BIND_FINALIZE_FUNC(js_cc_Color_finalize) + +bool js_register_engine_Color(se::Object* obj) // NOLINT(readability-identifier-naming) +{ + auto* cls = se::Class::create("Color", obj, nullptr, _SE(js_engine_Color_constructor)); + + cls->defineProperty("r", _SE(js_engine_Color_get_r), _SE(js_engine_Color_set_r)); + cls->defineProperty("g", _SE(js_engine_Color_get_g), _SE(js_engine_Color_set_g)); + cls->defineProperty("b", _SE(js_engine_Color_get_b), _SE(js_engine_Color_set_b)); + cls->defineProperty("a", _SE(js_engine_Color_get_a), _SE(js_engine_Color_set_a)); + cls->defineFinalizeFunction(_SE(js_cc_Color_finalize)); + cls->install(); + JSBClassType::registerClass(cls); + + __jsb_cc_Color_proto = cls->getProto(); + __jsb_cc_Color_class = cls; + + + se::ScriptEngine::getInstance()->clearException(); + return true; +} +se::Object* __jsb_cc_CCObject_proto = nullptr; // NOLINT +se::Class* __jsb_cc_CCObject_class = nullptr; // NOLINT + +static bool js_engine_CCObject_destroy(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_engine_CCObject_destroy : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 0) { + bool result = cobj->destroy(); + ok &= nativevalue_to_se(result, s.rval(), nullptr /*ctx*/); + SE_PRECONDITION2(ok, false, "js_engine_CCObject_destroy : Error processing arguments"); + SE_HOLD_RETURN_VALUE(result, s.thisObject(), s.rval()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 0); + return false; +} +SE_BIND_FUNC(js_engine_CCObject_destroy) + +static bool js_engine_CCObject_destroyImmediate(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_engine_CCObject_destroyImmediate : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + if (argc == 0) { + cobj->destroyImmediate(); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 0); + return false; +} +SE_BIND_FUNC(js_engine_CCObject_destroyImmediate) + +static bool js_engine_CCObject_destruct(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_engine_CCObject_destruct : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + if (argc == 0) { + cobj->destruct(); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 0); + return false; +} +SE_BIND_FUNC(js_engine_CCObject_destruct) + +static bool js_engine_CCObject_getHideFlags(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_engine_CCObject_getHideFlags : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 0) { + auto result = static_cast(cobj->getHideFlags()); + ok &= nativevalue_to_se(result, s.rval(), nullptr /*ctx*/); + SE_PRECONDITION2(ok, false, "js_engine_CCObject_getHideFlags : Error processing arguments"); + SE_HOLD_RETURN_VALUE(result, s.thisObject(), s.rval()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 0); + return false; +} +SE_BIND_FUNC_AS_PROP_GET(js_engine_CCObject_getHideFlags) + +static bool js_engine_CCObject_getName(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_engine_CCObject_getName : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 0) { + const std::string& result = cobj->getName(); + ok &= nativevalue_to_se(result, s.rval(), nullptr /*ctx*/); + SE_PRECONDITION2(ok, false, "js_engine_CCObject_getName : Error processing arguments"); + SE_HOLD_RETURN_VALUE(result, s.thisObject(), s.rval()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 0); + return false; +} +SE_BIND_FUNC_AS_PROP_GET(js_engine_CCObject_getName) + +static bool js_engine_CCObject_isReplicated(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_engine_CCObject_isReplicated : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 0) { + bool result = cobj->isReplicated(); + ok &= nativevalue_to_se(result, s.rval(), nullptr /*ctx*/); + SE_PRECONDITION2(ok, false, "js_engine_CCObject_isReplicated : Error processing arguments"); + SE_HOLD_RETURN_VALUE(result, s.thisObject(), s.rval()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 0); + return false; +} +SE_BIND_FUNC_AS_PROP_GET(js_engine_CCObject_isReplicated) + +static bool js_engine_CCObject_isValid(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_engine_CCObject_isValid : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 0) { + bool result = cobj->isValid(); + ok &= nativevalue_to_se(result, s.rval(), nullptr /*ctx*/); + SE_PRECONDITION2(ok, false, "js_engine_CCObject_isValid : Error processing arguments"); + SE_HOLD_RETURN_VALUE(result, s.thisObject(), s.rval()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 0); + return false; +} +SE_BIND_FUNC_AS_PROP_GET(js_engine_CCObject_isValid) + +static bool js_engine_CCObject_setHideFlags(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_engine_CCObject_setHideFlags : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 1) { + HolderType arg0 = {}; + ok &= sevalue_to_native(args[0], &arg0, s.thisObject()); + SE_PRECONDITION2(ok, false, "js_engine_CCObject_setHideFlags : Error processing arguments"); + cobj->setHideFlags(arg0.value()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 1); + return false; +} +SE_BIND_FUNC_AS_PROP_SET(js_engine_CCObject_setHideFlags) + +static bool js_engine_CCObject_setName(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_engine_CCObject_setName : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 1) { + HolderType arg0 = {}; + ok &= sevalue_to_native(args[0], &arg0, s.thisObject()); + SE_PRECONDITION2(ok, false, "js_engine_CCObject_setName : Error processing arguments"); + cobj->setName(arg0.value()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 1); + return false; +} +SE_BIND_FUNC_AS_PROP_SET(js_engine_CCObject_setName) + +static bool js_engine_CCObject_setReplicated(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_engine_CCObject_setReplicated : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 1) { + HolderType arg0 = {}; + ok &= sevalue_to_native(args[0], &arg0, s.thisObject()); + SE_PRECONDITION2(ok, false, "js_engine_CCObject_setReplicated : Error processing arguments"); + cobj->setReplicated(arg0.value()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 1); + return false; +} +SE_BIND_FUNC_AS_PROP_SET(js_engine_CCObject_setReplicated) + +static bool js_engine_CCObject_toString(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_engine_CCObject_toString : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 0) { + std::string result = cobj->toString(); + ok &= nativevalue_to_se(result, s.rval(), nullptr /*ctx*/); + SE_PRECONDITION2(ok, false, "js_engine_CCObject_toString : Error processing arguments"); + SE_HOLD_RETURN_VALUE(result, s.thisObject(), s.rval()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 0); + return false; +} +SE_BIND_FUNC(js_engine_CCObject_toString) + +static bool js_engine_CCObject_deferredDestroy_static(se::State& s) // NOLINT(readability-identifier-naming) +{ + const auto& args = s.args(); + size_t argc = args.size(); + if (argc == 0) { + cc::CCObject::deferredDestroy(); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 0); + return false; +} +SE_BIND_FUNC(js_engine_CCObject_deferredDestroy_static) + +static bool js_engine_CCObject_get__objFlags(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_engine_CCObject_get__objFlags : Invalid Native Object"); + + CC_UNUSED bool ok = true; + se::Value jsret; + ok &= nativevalue_to_se(cobj->_objFlags, jsret, s.thisObject() /*ctx*/); + s.rval() = jsret; + SE_HOLD_RETURN_VALUE(cobj->_objFlags, s.thisObject(), s.rval()); + return true; +} +SE_BIND_PROP_GET(js_engine_CCObject_get__objFlags) + +static bool js_engine_CCObject_set__objFlags(se::State& s) // NOLINT(readability-identifier-naming) +{ + const auto& args = s.args(); + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_engine_CCObject_set__objFlags : Invalid Native Object"); + + CC_UNUSED bool ok = true; + ok &= sevalue_to_native(args[0], &cobj->_objFlags, s.thisObject()); + SE_PRECONDITION2(ok, false, "js_engine_CCObject_set__objFlags : Error processing new value"); + return true; +} +SE_BIND_PROP_SET(js_engine_CCObject_set__objFlags) + +static bool js_engine_CCObject_get__name(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_engine_CCObject_get__name : Invalid Native Object"); + + CC_UNUSED bool ok = true; + se::Value jsret; + ok &= nativevalue_to_se(cobj->_name, jsret, s.thisObject() /*ctx*/); + s.rval() = jsret; + SE_HOLD_RETURN_VALUE(cobj->_name, s.thisObject(), s.rval()); + return true; +} +SE_BIND_PROP_GET(js_engine_CCObject_get__name) + +static bool js_engine_CCObject_set__name(se::State& s) // NOLINT(readability-identifier-naming) +{ + const auto& args = s.args(); + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_engine_CCObject_set__name : Invalid Native Object"); + + CC_UNUSED bool ok = true; + ok &= sevalue_to_native(args[0], &cobj->_name, s.thisObject()); + SE_PRECONDITION2(ok, false, "js_engine_CCObject_set__name : Error processing new value"); + return true; +} +SE_BIND_PROP_SET(js_engine_CCObject_set__name) +static bool js_cc_CCObject_finalize(se::State& s) // NOLINT(readability-identifier-naming) +{ + return true; +} +SE_BIND_FINALIZE_FUNC(js_cc_CCObject_finalize) + +bool js_register_engine_CCObject(se::Object* obj) // NOLINT(readability-identifier-naming) +{ + auto* cls = se::Class::create("CCObject", obj, nullptr, nullptr); + + cls->defineProperty("_objFlags", _SE(js_engine_CCObject_get__objFlags), _SE(js_engine_CCObject_set__objFlags)); + cls->defineProperty("_name", _SE(js_engine_CCObject_get__name), _SE(js_engine_CCObject_set__name)); + cls->defineProperty("hideFlags", _SE(js_engine_CCObject_getHideFlags_asGetter), _SE(js_engine_CCObject_setHideFlags_asSetter)); + cls->defineProperty("replicated", _SE(js_engine_CCObject_isReplicated_asGetter), _SE(js_engine_CCObject_setReplicated_asSetter)); + cls->defineProperty("name", _SE(js_engine_CCObject_getName_asGetter), _SE(js_engine_CCObject_setName_asSetter)); + cls->defineProperty("isValid", _SE(js_engine_CCObject_isValid_asGetter), nullptr); + cls->defineFunction("destroy", _SE(js_engine_CCObject_destroy)); + cls->defineFunction("_destroyImmediate", _SE(js_engine_CCObject_destroyImmediate)); + cls->defineFunction("destruct", _SE(js_engine_CCObject_destruct)); + cls->defineFunction("toString", _SE(js_engine_CCObject_toString)); + cls->defineStaticFunction("deferredDestroy", _SE(js_engine_CCObject_deferredDestroy_static)); + cls->defineFinalizeFunction(_SE(js_cc_CCObject_finalize)); + cls->install(); + JSBClassType::registerClass(cls); + + __jsb_cc_CCObject_proto = cls->getProto(); + __jsb_cc_CCObject_class = cls; + + + se::ScriptEngine::getInstance()->clearException(); + return true; +} +bool register_all_engine(se::Object* obj) // NOLINT { // Get the ns se::Value nsVal; - if (!obj->getProperty("jsb", &nsVal)) + if (!obj->getProperty("jsb", &nsVal, true)) { se::HandleObject jsobj(se::Object::createPlainObject()); nsVal.setObject(jsobj); @@ -2059,14 +2661,18 @@ bool register_all_engine(se::Object* obj) } se::Object* ns = nsVal.toObject(); - js_register_engine_FileUtils(ns); - js_register_engine_OSInterface(ns); + js_register_engine_CCObject(ns); js_register_engine_ICanvasGradient(ns); - js_register_engine_ICanvasRenderingContext2D(ns); js_register_engine_CanvasGradient(ns); + js_register_engine_OSInterface(ns); + js_register_engine_ICanvasRenderingContext2D(ns); js_register_engine_CanvasRenderingContext2D(ns); + js_register_engine_Color(ns); js_register_engine_Device(ns); + js_register_engine_FileUtils(ns); js_register_engine_SAXParser(ns); + js_register_engine_Vec2(ns); return true; } +// clang-format on \ No newline at end of file diff --git a/native/cocos/bindings/auto/jsb_cocos_auto.h b/native/cocos/bindings/auto/jsb_cocos_auto.h index eff706f4e7..a22745905c 100644 --- a/native/cocos/bindings/auto/jsb_cocos_auto.h +++ b/native/cocos/bindings/auto/jsb_cocos_auto.h @@ -1,3 +1,4 @@ +// clang-format off #pragma once #include "base/Config.h" #include @@ -8,14 +9,32 @@ #include "cocos/platform/interfaces/modules/canvas/CanvasRenderingContext2D.h" #include "cocos/platform/interfaces/modules/Device.h" #include "cocos/platform/SAXParser.h" +#include "cocos/math/Vec2.h" +#include "cocos/math/Vec3.h" +#include "cocos/math/Quaternion.h" +#include "cocos/math/Color.h" +#include "cocos/core/data/Object.h" -extern se::Object* __jsb_cc_FileUtils_proto; -extern se::Class* __jsb_cc_FileUtils_class; - -bool js_register_cc_FileUtils(se::Object* obj); -bool register_all_engine(se::Object* obj); +bool register_all_engine(se::Object *obj); // NOLINT JSB_REGISTER_OBJECT_TYPE(cc::FileUtils); +JSB_REGISTER_OBJECT_TYPE(cc::OSInterface); +JSB_REGISTER_OBJECT_TYPE(cc::Vec2); +JSB_REGISTER_OBJECT_TYPE(cc::ICanvasGradient); +JSB_REGISTER_OBJECT_TYPE(cc::ICanvasRenderingContext2D); +JSB_REGISTER_OBJECT_TYPE(cc::CanvasGradient); +JSB_REGISTER_OBJECT_TYPE(cc::CanvasRenderingContext2D); +JSB_REGISTER_OBJECT_TYPE(cc::Device); +JSB_REGISTER_OBJECT_TYPE(cc::SAXParser); +JSB_REGISTER_OBJECT_TYPE(cc::Color); +JSB_REGISTER_OBJECT_TYPE(cc::CCObject); + + +extern se::Object *__jsb_cc_FileUtils_proto; // NOLINT +extern se::Class * __jsb_cc_FileUtils_class; // NOLINT + +bool js_register_cc_FileUtils(se::Object *obj); // NOLINT + SE_DECLARE_FUNC(js_engine_FileUtils_addSearchPath); SE_DECLARE_FUNC(js_engine_FileUtils_createDirectory); SE_DECLARE_FUNC(js_engine_FileUtils_fullPathForFilename); @@ -48,35 +67,35 @@ SE_DECLARE_FUNC(js_engine_FileUtils_writeStringToFile); SE_DECLARE_FUNC(js_engine_FileUtils_writeToFile); SE_DECLARE_FUNC(js_engine_FileUtils_writeValueMapToFile); SE_DECLARE_FUNC(js_engine_FileUtils_writeValueVectorToFile); -SE_DECLARE_FUNC(js_engine_FileUtils_getInstance); -SE_DECLARE_FUNC(js_engine_FileUtils_setDelegate); -SE_DECLARE_FUNC(js_engine_FileUtils_normalizePath); SE_DECLARE_FUNC(js_engine_FileUtils_getFileDir); +SE_DECLARE_FUNC(js_engine_FileUtils_getInstance); +SE_DECLARE_FUNC(js_engine_FileUtils_normalizePath); -extern se::Object* __jsb_cc_OSInterface_proto; -extern se::Class* __jsb_cc_OSInterface_class; +extern se::Object *__jsb_cc_OSInterface_proto; // NOLINT +extern se::Class * __jsb_cc_OSInterface_class; // NOLINT -bool js_register_cc_OSInterface(se::Object* obj); -bool register_all_engine(se::Object* obj); +bool js_register_cc_OSInterface(se::Object *obj); // NOLINT -JSB_REGISTER_OBJECT_TYPE(cc::OSInterface); -extern se::Object* __jsb_cc_ICanvasGradient_proto; -extern se::Class* __jsb_cc_ICanvasGradient_class; +extern se::Object *__jsb_cc_Vec2_proto; // NOLINT +extern se::Class * __jsb_cc_Vec2_class; // NOLINT -bool js_register_cc_ICanvasGradient(se::Object* obj); -bool register_all_engine(se::Object* obj); +bool js_register_cc_Vec2(se::Object *obj); // NOLINT + +SE_DECLARE_FUNC(js_engine_Vec2_Vec2); + +extern se::Object *__jsb_cc_ICanvasGradient_proto; // NOLINT +extern se::Class * __jsb_cc_ICanvasGradient_class; // NOLINT + +bool js_register_cc_ICanvasGradient(se::Object *obj); // NOLINT -JSB_REGISTER_OBJECT_TYPE(cc::ICanvasGradient); SE_DECLARE_FUNC(js_engine_ICanvasGradient_addColorStop); -extern se::Object* __jsb_cc_ICanvasRenderingContext2D_proto; -extern se::Class* __jsb_cc_ICanvasRenderingContext2D_class; +extern se::Object *__jsb_cc_ICanvasRenderingContext2D_proto; // NOLINT +extern se::Class * __jsb_cc_ICanvasRenderingContext2D_class; // NOLINT -bool js_register_cc_ICanvasRenderingContext2D(se::Object* obj); -bool register_all_engine(se::Object* obj); +bool js_register_cc_ICanvasRenderingContext2D(se::Object *obj); // NOLINT -JSB_REGISTER_OBJECT_TYPE(cc::ICanvasRenderingContext2D); SE_DECLARE_FUNC(js_engine_ICanvasRenderingContext2D_beginPath); SE_DECLARE_FUNC(js_engine_ICanvasRenderingContext2D_clearRect); SE_DECLARE_FUNC(js_engine_ICanvasRenderingContext2D_closePath); @@ -100,49 +119,59 @@ SE_DECLARE_FUNC(js_engine_ICanvasRenderingContext2D_strokeText); SE_DECLARE_FUNC(js_engine_ICanvasRenderingContext2D_transform); SE_DECLARE_FUNC(js_engine_ICanvasRenderingContext2D_translate); -extern se::Object* __jsb_cc_CanvasGradient_proto; -extern se::Class* __jsb_cc_CanvasGradient_class; +extern se::Object *__jsb_cc_CanvasGradient_proto; // NOLINT +extern se::Class * __jsb_cc_CanvasGradient_class; // NOLINT -bool js_register_cc_CanvasGradient(se::Object* obj); -bool register_all_engine(se::Object* obj); +bool js_register_cc_CanvasGradient(se::Object *obj); // NOLINT -JSB_REGISTER_OBJECT_TYPE(cc::CanvasGradient); SE_DECLARE_FUNC(js_engine_CanvasGradient_CanvasGradient); -extern se::Object* __jsb_cc_CanvasRenderingContext2D_proto; -extern se::Class* __jsb_cc_CanvasRenderingContext2D_class; +extern se::Object *__jsb_cc_CanvasRenderingContext2D_proto; // NOLINT +extern se::Class * __jsb_cc_CanvasRenderingContext2D_class; // NOLINT -bool js_register_cc_CanvasRenderingContext2D(se::Object* obj); -bool register_all_engine(se::Object* obj); +bool js_register_cc_CanvasRenderingContext2D(se::Object *obj); // NOLINT -JSB_REGISTER_OBJECT_TYPE(cc::CanvasRenderingContext2D); SE_DECLARE_FUNC(js_engine_CanvasRenderingContext2D_CanvasRenderingContext2D); -extern se::Object* __jsb_cc_Device_proto; -extern se::Class* __jsb_cc_Device_class; +extern se::Object *__jsb_cc_Device_proto; // NOLINT +extern se::Class * __jsb_cc_Device_class; // NOLINT -bool js_register_cc_Device(se::Object* obj); -bool register_all_engine(se::Object* obj); +bool js_register_cc_Device(se::Object *obj); // NOLINT -JSB_REGISTER_OBJECT_TYPE(cc::Device); -SE_DECLARE_FUNC(js_engine_Device_getDPI); -SE_DECLARE_FUNC(js_engine_Device_getDevicePixelRatio); -SE_DECLARE_FUNC(js_engine_Device_setAccelerometerEnabled); -SE_DECLARE_FUNC(js_engine_Device_setAccelerometerInterval); -SE_DECLARE_FUNC(js_engine_Device_getDeviceOrientation); -SE_DECLARE_FUNC(js_engine_Device_getDeviceModel); -SE_DECLARE_FUNC(js_engine_Device_setKeepScreenOn); -SE_DECLARE_FUNC(js_engine_Device_vibrate); SE_DECLARE_FUNC(js_engine_Device_getBatteryLevel); +SE_DECLARE_FUNC(js_engine_Device_getDPI); +SE_DECLARE_FUNC(js_engine_Device_getDeviceModel); +SE_DECLARE_FUNC(js_engine_Device_getDeviceOrientation); +SE_DECLARE_FUNC(js_engine_Device_getDevicePixelRatio); SE_DECLARE_FUNC(js_engine_Device_getNetworkType); SE_DECLARE_FUNC(js_engine_Device_getSafeAreaEdge); +SE_DECLARE_FUNC(js_engine_Device_setAccelerometerEnabled); +SE_DECLARE_FUNC(js_engine_Device_setAccelerometerInterval); +SE_DECLARE_FUNC(js_engine_Device_setKeepScreenOn); +SE_DECLARE_FUNC(js_engine_Device_vibrate); -extern se::Object* __jsb_cc_SAXParser_proto; -extern se::Class* __jsb_cc_SAXParser_class; +extern se::Object *__jsb_cc_SAXParser_proto; // NOLINT +extern se::Class * __jsb_cc_SAXParser_class; // NOLINT -bool js_register_cc_SAXParser(se::Object* obj); -bool register_all_engine(se::Object* obj); +bool js_register_cc_SAXParser(se::Object *obj); // NOLINT -JSB_REGISTER_OBJECT_TYPE(cc::SAXParser); SE_DECLARE_FUNC(js_engine_SAXParser_init); +extern se::Object *__jsb_cc_Color_proto; // NOLINT +extern se::Class * __jsb_cc_Color_class; // NOLINT + +bool js_register_cc_Color(se::Object *obj); // NOLINT + +SE_DECLARE_FUNC(js_engine_Color_Color); + +extern se::Object *__jsb_cc_CCObject_proto; // NOLINT +extern se::Class * __jsb_cc_CCObject_class; // NOLINT + +bool js_register_cc_CCObject(se::Object *obj); // NOLINT + +SE_DECLARE_FUNC(js_engine_CCObject_destroy); +SE_DECLARE_FUNC(js_engine_CCObject_destroyImmediate); +SE_DECLARE_FUNC(js_engine_CCObject_destruct); +SE_DECLARE_FUNC(js_engine_CCObject_toString); +SE_DECLARE_FUNC(js_engine_CCObject_deferredDestroy); + // clang-format on \ No newline at end of file diff --git a/native/cocos/bindings/auto/jsb_dragonbones_auto.cpp b/native/cocos/bindings/auto/jsb_dragonbones_auto.cpp index c88dfd71d1..a15bbd38fd 100644 --- a/native/cocos/bindings/auto/jsb_dragonbones_auto.cpp +++ b/native/cocos/bindings/auto/jsb_dragonbones_auto.cpp @@ -1,3 +1,5 @@ + +// clang-format off #include "cocos/bindings/auto/jsb_dragonbones_auto.h" #if USE_DRAGONBONES > 0 #include "cocos/bindings/manual/jsb_conversions.h" @@ -11,8 +13,8 @@ #ifndef JSB_FREE #define JSB_FREE(ptr) delete ptr #endif -se::Object* __jsb_dragonBones_BaseObject_proto = nullptr; -se::Class* __jsb_dragonBones_BaseObject_class = nullptr; +se::Object* __jsb_dragonBones_BaseObject_proto = nullptr; // NOLINT +se::Class* __jsb_dragonBones_BaseObject_class = nullptr; // NOLINT static bool js_dragonbones_BaseObject_returnToPool(se::State& s) // NOLINT(readability-identifier-naming) { @@ -29,26 +31,7 @@ static bool js_dragonbones_BaseObject_returnToPool(se::State& s) // NOLINT(reada } SE_BIND_FUNC(js_dragonbones_BaseObject_returnToPool) -static bool js_dragonbones_BaseObject_setMaxCount(se::State& s) // NOLINT(readability-identifier-naming) -{ - const auto& args = s.args(); - size_t argc = args.size(); - CC_UNUSED bool ok = true; - if (argc == 2) { - HolderType arg0 = {}; - HolderType arg1 = {}; - ok &= sevalue_to_native(args[0], &arg0, nullptr); - ok &= sevalue_to_native(args[1], &arg1, nullptr); - SE_PRECONDITION2(ok, false, "js_dragonbones_BaseObject_setMaxCount : Error processing arguments"); - dragonBones::BaseObject::setMaxCount(arg0.value(), arg1.value()); - return true; - } - SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 2); - return false; -} -SE_BIND_FUNC(js_dragonbones_BaseObject_setMaxCount) - -static bool js_dragonbones_BaseObject_clearPool(se::State& s) // NOLINT(readability-identifier-naming) +static bool js_dragonbones_BaseObject_clearPool_static(se::State& s) // NOLINT(readability-identifier-naming) { const auto& args = s.args(); size_t argc = args.size(); @@ -60,35 +43,53 @@ static bool js_dragonbones_BaseObject_clearPool(se::State& s) // NOLINT(readabil if (argc == 1) { HolderType arg0 = {}; ok &= sevalue_to_native(args[0], &arg0, nullptr); - SE_PRECONDITION2(ok, false, "js_dragonbones_BaseObject_clearPool : Error processing arguments"); + SE_PRECONDITION2(ok, false, "js_dragonbones_BaseObject_clearPool_static : Error processing arguments"); dragonBones::BaseObject::clearPool(arg0.value()); return true; } SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 1); return false; } -SE_BIND_FUNC(js_dragonbones_BaseObject_clearPool) - +SE_BIND_FUNC(js_dragonbones_BaseObject_clearPool_static) +static bool js_dragonbones_BaseObject_setMaxCount_static(se::State& s) // NOLINT(readability-identifier-naming) +{ + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 2) { + HolderType arg0 = {}; + HolderType arg1 = {}; + ok &= sevalue_to_native(args[0], &arg0, nullptr); + ok &= sevalue_to_native(args[1], &arg1, nullptr); + SE_PRECONDITION2(ok, false, "js_dragonbones_BaseObject_setMaxCount_static : Error processing arguments"); + dragonBones::BaseObject::setMaxCount(arg0.value(), arg1.value()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 2); + return false; +} +SE_BIND_FUNC(js_dragonbones_BaseObject_setMaxCount_static) bool js_register_dragonbones_BaseObject(se::Object* obj) // NOLINT(readability-identifier-naming) { auto* cls = se::Class::create("BaseObject", obj, nullptr, nullptr); cls->defineFunction("returnToPool", _SE(js_dragonbones_BaseObject_returnToPool)); - cls->defineStaticFunction("setMaxCount", _SE(js_dragonbones_BaseObject_setMaxCount)); - cls->defineStaticFunction("clearPool", _SE(js_dragonbones_BaseObject_clearPool)); + cls->defineStaticFunction("clearPool", _SE(js_dragonbones_BaseObject_clearPool_static)); + cls->defineStaticFunction("setMaxCount", _SE(js_dragonbones_BaseObject_setMaxCount_static)); cls->install(); JSBClassType::registerClass(cls); __jsb_dragonBones_BaseObject_proto = cls->getProto(); __jsb_dragonBones_BaseObject_class = cls; + se::ScriptEngine::getInstance()->clearException(); return true; } -se::Object* __jsb_dragonBones_Rectangle_proto = nullptr; -se::Class* __jsb_dragonBones_Rectangle_class = nullptr; +se::Object* __jsb_dragonBones_Rectangle_proto = nullptr; // NOLINT +se::Class* __jsb_dragonBones_Rectangle_class = nullptr; // NOLINT static bool js_dragonbones_Rectangle_clear(se::State& s) // NOLINT(readability-identifier-naming) { @@ -109,24 +110,14 @@ SE_DECLARE_FINALIZE_FUNC(js_dragonBones_Rectangle_finalize) static bool js_dragonbones_Rectangle_constructor(se::State& s) // NOLINT(readability-identifier-naming) constructor.c { - dragonBones::Rectangle* cobj = JSB_ALLOC(dragonBones::Rectangle); - s.thisObject()->setPrivateData(cobj); - se::NonRefNativePtrCreatedByCtorMap::emplace(cobj); + auto *ptr = JSB_MAKE_PRIVATE_OBJECT(dragonBones::Rectangle); + s.thisObject()->setPrivateObject(ptr); return true; } SE_BIND_CTOR(js_dragonbones_Rectangle_constructor, __jsb_dragonBones_Rectangle_class, js_dragonBones_Rectangle_finalize) - - static bool js_dragonBones_Rectangle_finalize(se::State& s) // NOLINT(readability-identifier-naming) { - auto iter = se::NonRefNativePtrCreatedByCtorMap::find(SE_THIS_OBJECT(s)); - if (iter != se::NonRefNativePtrCreatedByCtorMap::end()) - { - se::NonRefNativePtrCreatedByCtorMap::erase(iter); - auto* cobj = SE_THIS_OBJECT(s); - JSB_FREE(cobj); - } return true; } SE_BIND_FINALIZE_FUNC(js_dragonBones_Rectangle_finalize) @@ -143,11 +134,12 @@ bool js_register_dragonbones_Rectangle(se::Object* obj) // NOLINT(readability-id __jsb_dragonBones_Rectangle_proto = cls->getProto(); __jsb_dragonBones_Rectangle_class = cls; + se::ScriptEngine::getInstance()->clearException(); return true; } -se::Object* __jsb_dragonBones_Matrix_proto = nullptr; -se::Class* __jsb_dragonBones_Matrix_class = nullptr; +se::Object* __jsb_dragonBones_Matrix_proto = nullptr; // NOLINT +se::Class* __jsb_dragonBones_Matrix_class = nullptr; // NOLINT static bool js_dragonbones_Matrix_get_a(se::State& s) // NOLINT(readability-identifier-naming) { @@ -311,8 +303,6 @@ static bool js_dragonbones_Matrix_set_ty(se::State& s) // NOLINT(readability-ide } SE_BIND_PROP_SET(js_dragonbones_Matrix_set_ty) - - bool js_register_dragonbones_Matrix(se::Object* obj) // NOLINT(readability-identifier-naming) { auto* cls = se::Class::create("Matrix", obj, nullptr, nullptr); @@ -329,13 +319,14 @@ bool js_register_dragonbones_Matrix(se::Object* obj) // NOLINT(readability-ident __jsb_dragonBones_Matrix_proto = cls->getProto(); __jsb_dragonBones_Matrix_class = cls; + se::ScriptEngine::getInstance()->clearException(); return true; } -se::Object* __jsb_dragonBones_Transform_proto = nullptr; -se::Class* __jsb_dragonBones_Transform_class = nullptr; +se::Object* __jsb_dragonBones_Transform_proto = nullptr; // NOLINT +se::Class* __jsb_dragonBones_Transform_class = nullptr; // NOLINT -static bool js_dragonbones_Transform_normalizeRadian(se::State& s) // NOLINT(readability-identifier-naming) +static bool js_dragonbones_Transform_normalizeRadian_static(se::State& s) // NOLINT(readability-identifier-naming) { const auto& args = s.args(); size_t argc = args.size(); @@ -343,17 +334,17 @@ static bool js_dragonbones_Transform_normalizeRadian(se::State& s) // NOLINT(rea if (argc == 1) { HolderType arg0 = {}; ok &= sevalue_to_native(args[0], &arg0, nullptr); - SE_PRECONDITION2(ok, false, "js_dragonbones_Transform_normalizeRadian : Error processing arguments"); + SE_PRECONDITION2(ok, false, "js_dragonbones_Transform_normalizeRadian_static : Error processing arguments"); float result = dragonBones::Transform::normalizeRadian(arg0.value()); ok &= nativevalue_to_se(result, s.rval(), nullptr /*ctx*/); - SE_PRECONDITION2(ok, false, "js_dragonbones_Transform_normalizeRadian : Error processing arguments"); + SE_PRECONDITION2(ok, false, "js_dragonbones_Transform_normalizeRadian_static : Error processing arguments"); SE_HOLD_RETURN_VALUE(result, s.thisObject(), s.rval()); return true; } SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 1); return false; } -SE_BIND_FUNC(js_dragonbones_Transform_normalizeRadian) +SE_BIND_FUNC(js_dragonbones_Transform_normalizeRadian_static) static bool js_dragonbones_Transform_get_x(se::State& s) // NOLINT(readability-identifier-naming) { @@ -517,8 +508,6 @@ static bool js_dragonbones_Transform_set_scaleY(se::State& s) // NOLINT(readabil } SE_BIND_PROP_SET(js_dragonbones_Transform_set_scaleY) - - bool js_register_dragonbones_Transform(se::Object* obj) // NOLINT(readability-identifier-naming) { auto* cls = se::Class::create("Transform", obj, nullptr, nullptr); @@ -529,18 +518,19 @@ bool js_register_dragonbones_Transform(se::Object* obj) // NOLINT(readability-id cls->defineProperty("rotation", _SE(js_dragonbones_Transform_get_rotation), _SE(js_dragonbones_Transform_set_rotation)); cls->defineProperty("scaleX", _SE(js_dragonbones_Transform_get_scaleX), _SE(js_dragonbones_Transform_set_scaleX)); cls->defineProperty("scaleY", _SE(js_dragonbones_Transform_get_scaleY), _SE(js_dragonbones_Transform_set_scaleY)); - cls->defineStaticFunction("normalizeRadian", _SE(js_dragonbones_Transform_normalizeRadian)); + cls->defineStaticFunction("normalizeRadian", _SE(js_dragonbones_Transform_normalizeRadian_static)); cls->install(); JSBClassType::registerClass(cls); __jsb_dragonBones_Transform_proto = cls->getProto(); __jsb_dragonBones_Transform_class = cls; + se::ScriptEngine::getInstance()->clearException(); return true; } -se::Object* __jsb_dragonBones_TextureAtlasData_proto = nullptr; -se::Class* __jsb_dragonBones_TextureAtlasData_class = nullptr; +se::Object* __jsb_dragonBones_TextureAtlasData_proto = nullptr; // NOLINT +se::Class* __jsb_dragonBones_TextureAtlasData_class = nullptr; // NOLINT static bool js_dragonbones_TextureAtlasData_addTexture(se::State& s) // NOLINT(readability-identifier-naming) { @@ -629,8 +619,6 @@ static bool js_dragonbones_TextureAtlasData_set_name(se::State& s) // NOLINT(rea } SE_BIND_PROP_SET(js_dragonbones_TextureAtlasData_set_name) - - bool js_register_dragonbones_TextureAtlasData(se::Object* obj) // NOLINT(readability-identifier-naming) { auto* cls = se::Class::create("TextureAtlasData", obj, __jsb_dragonBones_BaseObject_proto, nullptr); @@ -645,11 +633,12 @@ bool js_register_dragonbones_TextureAtlasData(se::Object* obj) // NOLINT(readabi __jsb_dragonBones_TextureAtlasData_proto = cls->getProto(); __jsb_dragonBones_TextureAtlasData_class = cls; + se::ScriptEngine::getInstance()->clearException(); return true; } -se::Object* __jsb_dragonBones_TextureData_proto = nullptr; -se::Class* __jsb_dragonBones_TextureData_class = nullptr; +se::Object* __jsb_dragonBones_TextureData_proto = nullptr; // NOLINT +se::Class* __jsb_dragonBones_TextureData_class = nullptr; // NOLINT static bool js_dragonbones_TextureData_getFrame(se::State& s) // NOLINT(readability-identifier-naming) { @@ -746,7 +735,7 @@ static bool js_dragonbones_TextureData_setParent(se::State& s) // NOLINT(readabi } SE_BIND_FUNC(js_dragonbones_TextureData_setParent) -static bool js_dragonbones_TextureData_createRectangle(se::State& s) // NOLINT(readability-identifier-naming) +static bool js_dragonbones_TextureData_createRectangle_static(se::State& s) // NOLINT(readability-identifier-naming) { const auto& args = s.args(); size_t argc = args.size(); @@ -754,16 +743,14 @@ static bool js_dragonbones_TextureData_createRectangle(se::State& s) // NOLINT(r if (argc == 0) { dragonBones::Rectangle* result = dragonBones::TextureData::createRectangle(); ok &= nativevalue_to_se(result, s.rval(), nullptr /*ctx*/); - SE_PRECONDITION2(ok, false, "js_dragonbones_TextureData_createRectangle : Error processing arguments"); + SE_PRECONDITION2(ok, false, "js_dragonbones_TextureData_createRectangle_static : Error processing arguments"); SE_HOLD_RETURN_VALUE(result, s.thisObject(), s.rval()); return true; } SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 0); return false; } -SE_BIND_FUNC(js_dragonbones_TextureData_createRectangle) - - +SE_BIND_FUNC(js_dragonbones_TextureData_createRectangle_static) bool js_register_dragonbones_TextureData(se::Object* obj) // NOLINT(readability-identifier-naming) { @@ -774,18 +761,19 @@ bool js_register_dragonbones_TextureData(se::Object* obj) // NOLINT(readability- cls->defineFunction("getRegion", _SE(js_dragonbones_TextureData_getRegion)); cls->defineFunction("setFrame", _SE(js_dragonbones_TextureData_setFrame)); cls->defineFunction("setParent", _SE(js_dragonbones_TextureData_setParent)); - cls->defineStaticFunction("createRectangle", _SE(js_dragonbones_TextureData_createRectangle)); + cls->defineStaticFunction("createRectangle", _SE(js_dragonbones_TextureData_createRectangle_static)); cls->install(); JSBClassType::registerClass(cls); __jsb_dragonBones_TextureData_proto = cls->getProto(); __jsb_dragonBones_TextureData_class = cls; + se::ScriptEngine::getInstance()->clearException(); return true; } -se::Object* __jsb_dragonBones_ArmatureData_proto = nullptr; -se::Class* __jsb_dragonBones_ArmatureData_class = nullptr; +se::Object* __jsb_dragonBones_ArmatureData_proto = nullptr; // NOLINT +se::Class* __jsb_dragonBones_ArmatureData_class = nullptr; // NOLINT static bool js_dragonbones_ArmatureData_getAABB(se::State& s) // NOLINT(readability-identifier-naming) { @@ -1160,8 +1148,6 @@ static bool js_dragonbones_ArmatureData_set_name(se::State& s) // NOLINT(readabi } SE_BIND_PROP_SET(js_dragonbones_ArmatureData_set_name) - - bool js_register_dragonbones_ArmatureData(se::Object* obj) // NOLINT(readability-identifier-naming) { auto* cls = se::Class::create("ArmatureData", obj, __jsb_dragonBones_BaseObject_proto, nullptr); @@ -1190,11 +1176,12 @@ bool js_register_dragonbones_ArmatureData(se::Object* obj) // NOLINT(readability __jsb_dragonBones_ArmatureData_proto = cls->getProto(); __jsb_dragonBones_ArmatureData_class = cls; + se::ScriptEngine::getInstance()->clearException(); return true; } -se::Object* __jsb_dragonBones_BoneData_proto = nullptr; -se::Class* __jsb_dragonBones_BoneData_class = nullptr; +se::Object* __jsb_dragonBones_BoneData_proto = nullptr; // NOLINT +se::Class* __jsb_dragonBones_BoneData_class = nullptr; // NOLINT static bool js_dragonbones_BoneData_getParent(se::State& s) // NOLINT(readability-identifier-naming) { @@ -1307,8 +1294,6 @@ static bool js_dragonbones_BoneData_set_parent(se::State& s) // NOLINT(readabili } SE_BIND_PROP_SET(js_dragonbones_BoneData_set_parent) - - bool js_register_dragonbones_BoneData(se::Object* obj) // NOLINT(readability-identifier-naming) { auto* cls = se::Class::create("BoneData", obj, __jsb_dragonBones_BaseObject_proto, nullptr); @@ -1324,11 +1309,12 @@ bool js_register_dragonbones_BoneData(se::Object* obj) // NOLINT(readability-ide __jsb_dragonBones_BoneData_proto = cls->getProto(); __jsb_dragonBones_BoneData_class = cls; + se::ScriptEngine::getInstance()->clearException(); return true; } -se::Object* __jsb_dragonBones_SlotData_proto = nullptr; -se::Class* __jsb_dragonBones_SlotData_class = nullptr; +se::Object* __jsb_dragonBones_SlotData_proto = nullptr; // NOLINT +se::Class* __jsb_dragonBones_SlotData_class = nullptr; // NOLINT static bool js_dragonbones_SlotData_getBlendMode(se::State& s) // NOLINT(readability-identifier-naming) { @@ -1460,8 +1446,6 @@ static bool js_dragonbones_SlotData_set_parent(se::State& s) // NOLINT(readabili } SE_BIND_PROP_SET(js_dragonbones_SlotData_set_parent) - - bool js_register_dragonbones_SlotData(se::Object* obj) // NOLINT(readability-identifier-naming) { auto* cls = se::Class::create("SlotData", obj, __jsb_dragonBones_BaseObject_proto, nullptr); @@ -1478,11 +1462,12 @@ bool js_register_dragonbones_SlotData(se::Object* obj) // NOLINT(readability-ide __jsb_dragonBones_SlotData_proto = cls->getProto(); __jsb_dragonBones_SlotData_class = cls; + se::ScriptEngine::getInstance()->clearException(); return true; } -se::Object* __jsb_dragonBones_DragonBonesData_proto = nullptr; -se::Class* __jsb_dragonBones_DragonBonesData_class = nullptr; +se::Object* __jsb_dragonBones_DragonBonesData_proto = nullptr; // NOLINT +se::Class* __jsb_dragonBones_DragonBonesData_class = nullptr; // NOLINT static bool js_dragonbones_DragonBonesData_addArmature(se::State& s) // NOLINT(readability-identifier-naming) { @@ -1590,8 +1575,6 @@ static bool js_dragonbones_DragonBonesData_set_name(se::State& s) // NOLINT(read } SE_BIND_PROP_SET(js_dragonbones_DragonBonesData_set_name) - - bool js_register_dragonbones_DragonBonesData(se::Object* obj) // NOLINT(readability-identifier-naming) { auto* cls = se::Class::create("DragonBonesData", obj, __jsb_dragonBones_BaseObject_proto, nullptr); @@ -1607,11 +1590,12 @@ bool js_register_dragonbones_DragonBonesData(se::Object* obj) // NOLINT(readabil __jsb_dragonBones_DragonBonesData_proto = cls->getProto(); __jsb_dragonBones_DragonBonesData_class = cls; + se::ScriptEngine::getInstance()->clearException(); return true; } -se::Object* __jsb_dragonBones_SkinData_proto = nullptr; -se::Class* __jsb_dragonBones_SkinData_class = nullptr; +se::Object* __jsb_dragonBones_SkinData_proto = nullptr; // NOLINT +se::Class* __jsb_dragonBones_SkinData_class = nullptr; // NOLINT static bool js_dragonbones_SkinData_get_name(se::State& s) // NOLINT(readability-identifier-naming) { @@ -1640,8 +1624,6 @@ static bool js_dragonbones_SkinData_set_name(se::State& s) // NOLINT(readability } SE_BIND_PROP_SET(js_dragonbones_SkinData_set_name) - - bool js_register_dragonbones_SkinData(se::Object* obj) // NOLINT(readability-identifier-naming) { auto* cls = se::Class::create("SkinData", obj, __jsb_dragonBones_BaseObject_proto, nullptr); @@ -1653,11 +1635,12 @@ bool js_register_dragonbones_SkinData(se::Object* obj) // NOLINT(readability-ide __jsb_dragonBones_SkinData_proto = cls->getProto(); __jsb_dragonBones_SkinData_class = cls; + se::ScriptEngine::getInstance()->clearException(); return true; } -se::Object* __jsb_dragonBones_AnimationData_proto = nullptr; -se::Class* __jsb_dragonBones_AnimationData_class = nullptr; +se::Object* __jsb_dragonBones_AnimationData_proto = nullptr; // NOLINT +se::Class* __jsb_dragonBones_AnimationData_class = nullptr; // NOLINT static bool js_dragonbones_AnimationData_getBoneCachedFrameIndices(se::State& s) // NOLINT(readability-identifier-naming) { @@ -1895,8 +1878,6 @@ static bool js_dragonbones_AnimationData_set_name(se::State& s) // NOLINT(readab } SE_BIND_PROP_SET(js_dragonbones_AnimationData_set_name) - - bool js_register_dragonbones_AnimationData(se::Object* obj) // NOLINT(readability-identifier-naming) { auto* cls = se::Class::create("AnimationData", obj, nullptr, nullptr); @@ -1917,11 +1898,12 @@ bool js_register_dragonbones_AnimationData(se::Object* obj) // NOLINT(readabilit __jsb_dragonBones_AnimationData_proto = cls->getProto(); __jsb_dragonBones_AnimationData_class = cls; + se::ScriptEngine::getInstance()->clearException(); return true; } -se::Object* __jsb_dragonBones_Armature_proto = nullptr; -se::Class* __jsb_dragonBones_Armature_class = nullptr; +se::Object* __jsb_dragonBones_Armature_proto = nullptr; // NOLINT +se::Class* __jsb_dragonBones_Armature_class = nullptr; // NOLINT static bool js_dragonbones_Armature__addBone(se::State& s) // NOLINT(readability-identifier-naming) { @@ -2397,8 +2379,6 @@ static bool js_dragonbones_Armature_setFlipY(se::State& s) // NOLINT(readability } SE_BIND_FUNC(js_dragonbones_Armature_setFlipY) - - bool js_register_dragonbones_Armature(se::Object* obj) // NOLINT(readability-identifier-naming) { auto* cls = se::Class::create("Armature", obj, __jsb_dragonBones_BaseObject_proto, nullptr); @@ -2433,11 +2413,12 @@ bool js_register_dragonbones_Armature(se::Object* obj) // NOLINT(readability-ide __jsb_dragonBones_Armature_proto = cls->getProto(); __jsb_dragonBones_Armature_class = cls; + se::ScriptEngine::getInstance()->clearException(); return true; } -se::Object* __jsb_dragonBones_TransformObject_proto = nullptr; -se::Class* __jsb_dragonBones_TransformObject_class = nullptr; +se::Object* __jsb_dragonBones_TransformObject_proto = nullptr; // NOLINT +se::Class* __jsb_dragonBones_TransformObject_class = nullptr; // NOLINT static bool js_dragonbones_TransformObject_getArmature(se::State& s) // NOLINT(readability-identifier-naming) { @@ -2549,8 +2530,6 @@ static bool js_dragonbones_TransformObject_updateGlobalTransform(se::State& s) / } SE_BIND_FUNC(js_dragonbones_TransformObject_updateGlobalTransform) - - bool js_register_dragonbones_TransformObject(se::Object* obj) // NOLINT(readability-identifier-naming) { auto* cls = se::Class::create("TransformObject", obj, __jsb_dragonBones_BaseObject_proto, nullptr); @@ -2567,11 +2546,12 @@ bool js_register_dragonbones_TransformObject(se::Object* obj) // NOLINT(readabil __jsb_dragonBones_TransformObject_proto = cls->getProto(); __jsb_dragonBones_TransformObject_class = cls; + se::ScriptEngine::getInstance()->clearException(); return true; } -se::Object* __jsb_dragonBones_AnimationState_proto = nullptr; -se::Class* __jsb_dragonBones_AnimationState_class = nullptr; +se::Object* __jsb_dragonBones_AnimationState_proto = nullptr; // NOLINT +se::Class* __jsb_dragonBones_AnimationState_class = nullptr; // NOLINT static bool js_dragonbones_AnimationState_addBoneMask(se::State& s) // NOLINT(readability-identifier-naming) { @@ -3170,8 +3150,6 @@ static bool js_dragonbones_AnimationState_set_name(se::State& s) // NOLINT(reada } SE_BIND_PROP_SET(js_dragonbones_AnimationState_set_name) - - bool js_register_dragonbones_AnimationState(se::Object* obj) // NOLINT(readability-identifier-naming) { auto* cls = se::Class::create("AnimationState", obj, __jsb_dragonBones_BaseObject_proto, nullptr); @@ -3209,11 +3187,12 @@ bool js_register_dragonbones_AnimationState(se::Object* obj) // NOLINT(readabili __jsb_dragonBones_AnimationState_proto = cls->getProto(); __jsb_dragonBones_AnimationState_class = cls; + se::ScriptEngine::getInstance()->clearException(); return true; } -se::Object* __jsb_dragonBones_Bone_proto = nullptr; -se::Class* __jsb_dragonBones_Bone_class = nullptr; +se::Object* __jsb_dragonBones_Bone_proto = nullptr; // NOLINT +se::Class* __jsb_dragonBones_Bone_class = nullptr; // NOLINT static bool js_dragonbones_Bone_contains(se::State& s) // NOLINT(readability-identifier-naming) { @@ -3440,8 +3419,6 @@ static bool js_dragonbones_Bone_updateByConstraint(se::State& s) // NOLINT(reada } SE_BIND_FUNC(js_dragonbones_Bone_updateByConstraint) - - bool js_register_dragonbones_Bone(se::Object* obj) // NOLINT(readability-identifier-naming) { auto* cls = se::Class::create("Bone", obj, __jsb_dragonBones_TransformObject_proto, nullptr); @@ -3464,11 +3441,12 @@ bool js_register_dragonbones_Bone(se::Object* obj) // NOLINT(readability-identif __jsb_dragonBones_Bone_proto = cls->getProto(); __jsb_dragonBones_Bone_class = cls; + se::ScriptEngine::getInstance()->clearException(); return true; } -se::Object* __jsb_dragonBones_Slot_proto = nullptr; -se::Class* __jsb_dragonBones_Slot_class = nullptr; +se::Object* __jsb_dragonBones_Slot_proto = nullptr; // NOLINT +se::Class* __jsb_dragonBones_Slot_class = nullptr; // NOLINT static bool js_dragonbones_Slot__setZorder(se::State& s) // NOLINT(readability-identifier-naming) { @@ -3786,8 +3764,6 @@ static bool js_dragonbones_Slot_set__zOrder(se::State& s) // NOLINT(readability- } SE_BIND_PROP_SET(js_dragonbones_Slot_set__zOrder) - - bool js_register_dragonbones_Slot(se::Object* obj) // NOLINT(readability-identifier-naming) { auto* cls = se::Class::create("Slot", obj, __jsb_dragonBones_TransformObject_proto, nullptr); @@ -3814,11 +3790,12 @@ bool js_register_dragonbones_Slot(se::Object* obj) // NOLINT(readability-identif __jsb_dragonBones_Slot_proto = cls->getProto(); __jsb_dragonBones_Slot_class = cls; + se::ScriptEngine::getInstance()->clearException(); return true; } -se::Object* __jsb_dragonBones_WorldClock_proto = nullptr; -se::Class* __jsb_dragonBones_WorldClock_class = nullptr; +se::Object* __jsb_dragonBones_WorldClock_proto = nullptr; // NOLINT +se::Class* __jsb_dragonBones_WorldClock_class = nullptr; // NOLINT static bool js_dragonbones_WorldClock_advanceTime(se::State& s) // NOLINT(readability-identifier-naming) { @@ -3907,7 +3884,7 @@ static bool js_dragonbones_WorldClock_setClock(se::State& s) // NOLINT(readabili } SE_BIND_FUNC(js_dragonbones_WorldClock_setClock) -static bool js_dragonbones_WorldClock_getStaticClock(se::State& s) // NOLINT(readability-identifier-naming) +static bool js_dragonbones_WorldClock_getStaticClock_static(se::State& s) // NOLINT(readability-identifier-naming) { const auto& args = s.args(); size_t argc = args.size(); @@ -3915,16 +3892,14 @@ static bool js_dragonbones_WorldClock_getStaticClock(se::State& s) // NOLINT(rea if (argc == 0) { dragonBones::WorldClock* result = dragonBones::WorldClock::getStaticClock(); ok &= nativevalue_to_se(result, s.rval(), nullptr /*ctx*/); - SE_PRECONDITION2(ok, false, "js_dragonbones_WorldClock_getStaticClock : Error processing arguments"); + SE_PRECONDITION2(ok, false, "js_dragonbones_WorldClock_getStaticClock_static : Error processing arguments"); SE_HOLD_RETURN_VALUE(result, s.thisObject(), s.rval()); return true; } SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 0); return false; } -SE_BIND_FUNC(js_dragonbones_WorldClock_getStaticClock) - - +SE_BIND_FUNC(js_dragonbones_WorldClock_getStaticClock_static) bool js_register_dragonbones_WorldClock(se::Object* obj) // NOLINT(readability-identifier-naming) { @@ -3935,18 +3910,19 @@ bool js_register_dragonbones_WorldClock(se::Object* obj) // NOLINT(readability-i cls->defineFunction("getClock", _SE(js_dragonbones_WorldClock_getClock)); cls->defineFunction("render", _SE(js_dragonbones_WorldClock_render)); cls->defineFunction("setClock", _SE(js_dragonbones_WorldClock_setClock)); - cls->defineStaticFunction("getStaticClock", _SE(js_dragonbones_WorldClock_getStaticClock)); + cls->defineStaticFunction("getStaticClock", _SE(js_dragonbones_WorldClock_getStaticClock_static)); cls->install(); JSBClassType::registerClass(cls); __jsb_dragonBones_WorldClock_proto = cls->getProto(); __jsb_dragonBones_WorldClock_class = cls; + se::ScriptEngine::getInstance()->clearException(); return true; } -se::Object* __jsb_dragonBones_Animation_proto = nullptr; -se::Class* __jsb_dragonBones_Animation_class = nullptr; +se::Object* __jsb_dragonBones_Animation_proto = nullptr; // NOLINT +se::Class* __jsb_dragonBones_Animation_class = nullptr; // NOLINT static bool js_dragonbones_Animation_advanceTime(se::State& s) // NOLINT(readability-identifier-naming) { @@ -4575,8 +4551,6 @@ static bool js_dragonbones_Animation_set_timeScale(se::State& s) // NOLINT(reada } SE_BIND_PROP_SET(js_dragonbones_Animation_set_timeScale) - - bool js_register_dragonbones_Animation(se::Object* obj) // NOLINT(readability-identifier-naming) { auto* cls = se::Class::create("Animation", obj, __jsb_dragonBones_BaseObject_proto, nullptr); @@ -4607,11 +4581,12 @@ bool js_register_dragonbones_Animation(se::Object* obj) // NOLINT(readability-id __jsb_dragonBones_Animation_proto = cls->getProto(); __jsb_dragonBones_Animation_class = cls; + se::ScriptEngine::getInstance()->clearException(); return true; } -se::Object* __jsb_dragonBones_EventObject_proto = nullptr; -se::Class* __jsb_dragonBones_EventObject_class = nullptr; +se::Object* __jsb_dragonBones_EventObject_proto = nullptr; // NOLINT +se::Class* __jsb_dragonBones_EventObject_class = nullptr; // NOLINT static bool js_dragonbones_EventObject_getAnimationState(se::State& s) // NOLINT(readability-identifier-naming) { @@ -4851,8 +4826,6 @@ static bool js_dragonbones_EventObject_set_animationState(se::State& s) // NOLIN } SE_BIND_PROP_SET(js_dragonbones_EventObject_set_animationState) - - bool js_register_dragonbones_EventObject(se::Object* obj) // NOLINT(readability-identifier-naming) { auto* cls = se::Class::create("EventObject", obj, __jsb_dragonBones_BaseObject_proto, nullptr); @@ -4873,11 +4846,12 @@ bool js_register_dragonbones_EventObject(se::Object* obj) // NOLINT(readability- __jsb_dragonBones_EventObject_proto = cls->getProto(); __jsb_dragonBones_EventObject_class = cls; + se::ScriptEngine::getInstance()->clearException(); return true; } -se::Object* __jsb_dragonBones_BaseFactory_proto = nullptr; -se::Class* __jsb_dragonBones_BaseFactory_class = nullptr; +se::Object* __jsb_dragonBones_BaseFactory_proto = nullptr; // NOLINT +se::Class* __jsb_dragonBones_BaseFactory_class = nullptr; // NOLINT static bool js_dragonbones_BaseFactory_addDragonBonesData(se::State& s) // NOLINT(readability-identifier-naming) { @@ -5343,8 +5317,6 @@ static bool js_dragonbones_BaseFactory_replaceSlotDisplay(se::State& s) // NOLIN } SE_BIND_FUNC(js_dragonbones_BaseFactory_replaceSlotDisplay) - - bool js_register_dragonbones_BaseFactory(se::Object* obj) // NOLINT(readability-identifier-naming) { auto* cls = se::Class::create("BaseFactory", obj, nullptr, nullptr); @@ -5369,11 +5341,12 @@ bool js_register_dragonbones_BaseFactory(se::Object* obj) // NOLINT(readability- __jsb_dragonBones_BaseFactory_proto = cls->getProto(); __jsb_dragonBones_BaseFactory_class = cls; + se::ScriptEngine::getInstance()->clearException(); return true; } -se::Object* __jsb_dragonBones_CCSlot_proto = nullptr; -se::Class* __jsb_dragonBones_CCSlot_class = nullptr; +se::Object* __jsb_dragonBones_CCSlot_proto = nullptr; // NOLINT +se::Class* __jsb_dragonBones_CCSlot_class = nullptr; // NOLINT static bool js_dragonbones_CCSlot_updateWorldMatrix(se::State& s) // NOLINT(readability-identifier-naming) { @@ -5390,8 +5363,6 @@ static bool js_dragonbones_CCSlot_updateWorldMatrix(se::State& s) // NOLINT(read } SE_BIND_FUNC(js_dragonbones_CCSlot_updateWorldMatrix) - - bool js_register_dragonbones_CCSlot(se::Object* obj) // NOLINT(readability-identifier-naming) { auto* cls = se::Class::create("CCSlot", obj, __jsb_dragonBones_Slot_proto, nullptr); @@ -5403,11 +5374,12 @@ bool js_register_dragonbones_CCSlot(se::Object* obj) // NOLINT(readability-ident __jsb_dragonBones_CCSlot_proto = cls->getProto(); __jsb_dragonBones_CCSlot_class = cls; + se::ScriptEngine::getInstance()->clearException(); return true; } -se::Object* __jsb_dragonBones_CCArmatureDisplay_proto = nullptr; -se::Class* __jsb_dragonBones_CCArmatureDisplay_class = nullptr; +se::Object* __jsb_dragonBones_CCArmatureDisplay_proto = nullptr; // NOLINT +se::Class* __jsb_dragonBones_CCArmatureDisplay_class = nullptr; // NOLINT static bool js_dragonbones_CCArmatureDisplay_addDBEventListener(se::State& s) // NOLINT(readability-identifier-naming) { @@ -5426,6 +5398,7 @@ static bool js_dragonbones_CCArmatureDisplay_addDBEventListener(se::State& s) // se::Value jsThis(s.thisObject()); se::Value jsFunc(args[1]); jsThis.toObject()->attachObject(jsFunc.toObject()); + auto * thisObj = s.thisObject(); auto lambda = [=](dragonBones::EventObject* larg0) -> void { se::ScriptEngine::getInstance()->clearException(); se::AutoHandleScope hs; @@ -5435,7 +5408,6 @@ static bool js_dragonbones_CCArmatureDisplay_addDBEventListener(se::State& s) // args.resize(1); ok &= nativevalue_to_se(larg0, args[0], nullptr /*ctx*/); se::Value rval; - se::Object* thisObj = jsThis.isObject() ? jsThis.toObject() : nullptr; se::Object* funcObj = jsFunc.toObject(); bool succeed = funcObj->call(args, thisObj, &rval); if (!succeed) { @@ -5459,25 +5431,6 @@ static bool js_dragonbones_CCArmatureDisplay_addDBEventListener(se::State& s) // } SE_BIND_FUNC(js_dragonbones_CCArmatureDisplay_addDBEventListener) -static bool js_dragonbones_CCArmatureDisplay_getArmature(se::State& s) // NOLINT(readability-identifier-naming) -{ - auto* cobj = SE_THIS_OBJECT(s); - SE_PRECONDITION2(cobj, false, "js_dragonbones_CCArmatureDisplay_getArmature : Invalid Native Object"); - const auto& args = s.args(); - size_t argc = args.size(); - CC_UNUSED bool ok = true; - if (argc == 0) { - dragonBones::Armature* result = cobj->getArmature(); - ok &= nativevalue_to_se(result, s.rval(), nullptr /*ctx*/); - SE_PRECONDITION2(ok, false, "js_dragonbones_CCArmatureDisplay_getArmature : Error processing arguments"); - SE_HOLD_RETURN_VALUE(result, s.thisObject(), s.rval()); - return true; - } - SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 0); - return false; -} -SE_BIND_FUNC(js_dragonbones_CCArmatureDisplay_getArmature) - static bool js_dragonbones_CCArmatureDisplay_convertToRootSpace(se::State& s) // NOLINT(readability-identifier-naming) { auto* cobj = SE_THIS_OBJECT(s); @@ -5491,7 +5444,7 @@ static bool js_dragonbones_CCArmatureDisplay_convertToRootSpace(se::State& s) // ok &= sevalue_to_native(args[0], &arg0, s.thisObject()); ok &= sevalue_to_native(args[1], &arg1, s.thisObject()); SE_PRECONDITION2(ok, false, "js_dragonbones_CCArmatureDisplay_convertToRootSpace : Error processing arguments"); - cc::Vec2 result = cobj->convertToRootSpace(arg0.value(), arg1.value()); + const cc::Vec2& result = cobj->convertToRootSpace(arg0.value(), arg1.value()); ok &= nativevalue_to_se(result, s.rval(), nullptr /*ctx*/); SE_PRECONDITION2(ok, false, "js_dragonbones_CCArmatureDisplay_convertToRootSpace : Error processing arguments"); SE_HOLD_RETURN_VALUE(result, s.thisObject(), s.rval()); @@ -5594,10 +5547,6 @@ static bool js_dragonbones_CCArmatureDisplay_dispose(se::State& s) // NOLINT(rea const auto& args = s.args(); size_t argc = args.size(); CC_UNUSED bool ok = true; - if (argc == 0) { - cobj->dispose(); - return true; - } if (argc == 1) { HolderType arg0 = {}; ok &= sevalue_to_native(args[0], &arg0, s.thisObject()); @@ -5629,6 +5578,25 @@ static bool js_dragonbones_CCArmatureDisplay_getAnimation(se::State& s) // NOLIN } SE_BIND_FUNC(js_dragonbones_CCArmatureDisplay_getAnimation) +static bool js_dragonbones_CCArmatureDisplay_getArmature(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_dragonbones_CCArmatureDisplay_getArmature : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 0) { + dragonBones::Armature* result = cobj->getArmature(); + ok &= nativevalue_to_se(result, s.rval(), nullptr /*ctx*/); + SE_PRECONDITION2(ok, false, "js_dragonbones_CCArmatureDisplay_getArmature : Error processing arguments"); + SE_HOLD_RETURN_VALUE(result, s.thisObject(), s.rval()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 0); + return false; +} +SE_BIND_FUNC(js_dragonbones_CCArmatureDisplay_getArmature) + static bool js_dragonbones_CCArmatureDisplay_getDebugData(se::State& s) // NOLINT(readability-identifier-naming) { auto* cobj = SE_THIS_OBJECT(s); @@ -5744,6 +5712,7 @@ static bool js_dragonbones_CCArmatureDisplay_removeDBEventListener(se::State& s) se::Value jsThis(s.thisObject()); se::Value jsFunc(args[1]); jsThis.toObject()->attachObject(jsFunc.toObject()); + auto * thisObj = s.thisObject(); auto lambda = [=](dragonBones::EventObject* larg0) -> void { se::ScriptEngine::getInstance()->clearException(); se::AutoHandleScope hs; @@ -5753,7 +5722,6 @@ static bool js_dragonbones_CCArmatureDisplay_removeDBEventListener(se::State& s) args.resize(1); ok &= nativevalue_to_se(larg0, args[0], nullptr /*ctx*/); se::Value rval; - se::Object* thisObj = jsThis.isObject() ? jsThis.toObject() : nullptr; se::Object* funcObj = jsFunc.toObject(); bool succeed = funcObj->call(args, thisObj, &rval); if (!succeed) { @@ -5855,6 +5823,7 @@ static bool js_dragonbones_CCArmatureDisplay_setDBEventCallback(se::State& s) // se::Value jsThis(s.thisObject()); se::Value jsFunc(args[0]); jsThis.toObject()->attachObject(jsFunc.toObject()); + auto * thisObj = s.thisObject(); auto lambda = [=](dragonBones::EventObject* larg0) -> void { se::ScriptEngine::getInstance()->clearException(); se::AutoHandleScope hs; @@ -5864,7 +5833,6 @@ static bool js_dragonbones_CCArmatureDisplay_setDBEventCallback(se::State& s) // args.resize(1); ok &= nativevalue_to_se(larg0, args[0], nullptr /*ctx*/); se::Value rval; - se::Object* thisObj = jsThis.isObject() ? jsThis.toObject() : nullptr; se::Object* funcObj = jsFunc.toObject(); bool succeed = funcObj->call(args, thisObj, &rval); if (!succeed) { @@ -5926,40 +5894,35 @@ static bool js_dragonbones_CCArmatureDisplay_setOpacityModifyRGB(se::State& s) / } SE_BIND_FUNC(js_dragonbones_CCArmatureDisplay_setOpacityModifyRGB) -static bool js_dragonbones_CCArmatureDisplay_create(se::State& s) // NOLINT(readability-identifier-naming) +static bool js_dragonbones_CCArmatureDisplay_create_static(se::State& s) // NOLINT(readability-identifier-naming) { const auto& args = s.args(); size_t argc = args.size(); CC_UNUSED bool ok = true; if (argc == 0) { - auto result = dragonBones::CCArmatureDisplay::create(); - result->retain(); - auto obj = se::Object::createObjectWithClass(__jsb_dragonBones_CCArmatureDisplay_class); - obj->setPrivateData(result); - s.rval().setObject(obj); + dragonBones::CCArmatureDisplay* result = dragonBones::CCArmatureDisplay::create(); + ok &= nativevalue_to_se(result, s.rval(), nullptr /*ctx*/); + SE_PRECONDITION2(ok, false, "js_dragonbones_CCArmatureDisplay_create_static : Error processing arguments"); + SE_HOLD_RETURN_VALUE(result, s.thisObject(), s.rval()); return true; } SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 0); return false; } -SE_BIND_FUNC(js_dragonbones_CCArmatureDisplay_create) +SE_BIND_FUNC(js_dragonbones_CCArmatureDisplay_create_static) SE_DECLARE_FINALIZE_FUNC(js_dragonBones_CCArmatureDisplay_finalize) static bool js_dragonbones_CCArmatureDisplay_constructor(se::State& s) // NOLINT(readability-identifier-naming) constructor.c { - dragonBones::CCArmatureDisplay* cobj = JSB_ALLOC(dragonBones::CCArmatureDisplay); - s.thisObject()->setPrivateData(cobj); + auto *ptr = JSB_MAKE_PRIVATE_OBJECT(dragonBones::CCArmatureDisplay); + s.thisObject()->setPrivateObject(ptr); return true; } SE_BIND_CTOR(js_dragonbones_CCArmatureDisplay_constructor, __jsb_dragonBones_CCArmatureDisplay_class, js_dragonBones_CCArmatureDisplay_finalize) - - static bool js_dragonBones_CCArmatureDisplay_finalize(se::State& s) // NOLINT(readability-identifier-naming) { - auto* cobj =SE_THIS_OBJECT(s); - cobj->release(); return true; } SE_BIND_FINALIZE_FUNC(js_dragonBones_CCArmatureDisplay_finalize) @@ -5969,7 +5932,6 @@ bool js_register_dragonbones_CCArmatureDisplay(se::Object* obj) // NOLINT(readab auto* cls = se::Class::create("CCArmatureDisplay", obj, nullptr, _SE(js_dragonbones_CCArmatureDisplay_constructor)); cls->defineFunction("addDBEventListener", _SE(js_dragonbones_CCArmatureDisplay_addDBEventListener)); - cls->defineFunction("armature", _SE(js_dragonbones_CCArmatureDisplay_getArmature)); cls->defineFunction("convertToRootSpace", _SE(js_dragonbones_CCArmatureDisplay_convertToRootSpace)); cls->defineFunction("dbClear", _SE(js_dragonbones_CCArmatureDisplay_dbClear)); cls->defineFunction("dbInit", _SE(js_dragonbones_CCArmatureDisplay_dbInit)); @@ -5978,6 +5940,7 @@ bool js_register_dragonbones_CCArmatureDisplay(se::Object* obj) // NOLINT(readab cls->defineFunction("dispatchDBEvent", _SE(js_dragonbones_CCArmatureDisplay_dispatchDBEvent)); cls->defineFunction("dispose", _SE(js_dragonbones_CCArmatureDisplay_dispose)); cls->defineFunction("getAnimation", _SE(js_dragonbones_CCArmatureDisplay_getAnimation)); + cls->defineFunction("armature", _SE(js_dragonbones_CCArmatureDisplay_getArmature)); cls->defineFunction("getDebugData", _SE(js_dragonbones_CCArmatureDisplay_getDebugData)); cls->defineFunction("getParamsBuffer", _SE(js_dragonbones_CCArmatureDisplay_getParamsBuffer)); cls->defineFunction("getRootDisplay", _SE(js_dragonbones_CCArmatureDisplay_getRootDisplay)); @@ -5990,7 +5953,7 @@ bool js_register_dragonbones_CCArmatureDisplay(se::Object* obj) // NOLINT(readab cls->defineFunction("setDBEventCallback", _SE(js_dragonbones_CCArmatureDisplay_setDBEventCallback)); cls->defineFunction("setDebugBonesEnabled", _SE(js_dragonbones_CCArmatureDisplay_setDebugBonesEnabled)); cls->defineFunction("setOpacityModifyRGB", _SE(js_dragonbones_CCArmatureDisplay_setOpacityModifyRGB)); - cls->defineStaticFunction("create", _SE(js_dragonbones_CCArmatureDisplay_create)); + cls->defineStaticFunction("create", _SE(js_dragonbones_CCArmatureDisplay_create_static)); cls->defineFinalizeFunction(_SE(js_dragonBones_CCArmatureDisplay_finalize)); cls->install(); JSBClassType::registerClass(cls); @@ -5998,11 +5961,12 @@ bool js_register_dragonbones_CCArmatureDisplay(se::Object* obj) // NOLINT(readab __jsb_dragonBones_CCArmatureDisplay_proto = cls->getProto(); __jsb_dragonBones_CCArmatureDisplay_class = cls; + se::ScriptEngine::getInstance()->clearException(); return true; } -se::Object* __jsb_dragonBones_ArmatureCacheMgr_proto = nullptr; -se::Class* __jsb_dragonBones_ArmatureCacheMgr_class = nullptr; +se::Object* __jsb_dragonBones_ArmatureCacheMgr_proto = nullptr; // NOLINT +se::Class* __jsb_dragonBones_ArmatureCacheMgr_class = nullptr; // NOLINT static bool js_dragonbones_ArmatureCacheMgr_buildArmatureCache(se::State& s) // NOLINT(readability-identifier-naming) { @@ -6049,24 +6013,7 @@ static bool js_dragonbones_ArmatureCacheMgr_removeArmatureCache(se::State& s) // } SE_BIND_FUNC(js_dragonbones_ArmatureCacheMgr_removeArmatureCache) -static bool js_dragonbones_ArmatureCacheMgr_getInstance(se::State& s) // NOLINT(readability-identifier-naming) -{ - const auto& args = s.args(); - size_t argc = args.size(); - CC_UNUSED bool ok = true; - if (argc == 0) { - dragonBones::ArmatureCacheMgr* result = dragonBones::ArmatureCacheMgr::getInstance(); - ok &= nativevalue_to_se(result, s.rval(), nullptr /*ctx*/); - SE_PRECONDITION2(ok, false, "js_dragonbones_ArmatureCacheMgr_getInstance : Error processing arguments"); - SE_HOLD_RETURN_VALUE(result, s.thisObject(), s.rval()); - return true; - } - SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 0); - return false; -} -SE_BIND_FUNC(js_dragonbones_ArmatureCacheMgr_getInstance) - -static bool js_dragonbones_ArmatureCacheMgr_destroyInstance(se::State& s) // NOLINT(readability-identifier-naming) +static bool js_dragonbones_ArmatureCacheMgr_destroyInstance_static(se::State& s) // NOLINT(readability-identifier-naming) { const auto& args = s.args(); size_t argc = args.size(); @@ -6077,18 +6024,26 @@ static bool js_dragonbones_ArmatureCacheMgr_destroyInstance(se::State& s) // NOL SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 0); return false; } -SE_BIND_FUNC(js_dragonbones_ArmatureCacheMgr_destroyInstance) - +SE_BIND_FUNC(js_dragonbones_ArmatureCacheMgr_destroyInstance_static) +static bool js_dragonbones_ArmatureCacheMgr_getInstance_static(se::State& s) // NOLINT(readability-identifier-naming) +{ + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 0) { + dragonBones::ArmatureCacheMgr* result = dragonBones::ArmatureCacheMgr::getInstance(); + ok &= nativevalue_to_se(result, s.rval(), nullptr /*ctx*/); + SE_PRECONDITION2(ok, false, "js_dragonbones_ArmatureCacheMgr_getInstance_static : Error processing arguments"); + SE_HOLD_RETURN_VALUE(result, s.thisObject(), s.rval()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 0); + return false; +} +SE_BIND_FUNC(js_dragonbones_ArmatureCacheMgr_getInstance_static) static bool js_dragonBones_ArmatureCacheMgr_finalize(se::State& s) // NOLINT(readability-identifier-naming) { - auto iter = se::NonRefNativePtrCreatedByCtorMap::find(SE_THIS_OBJECT(s)); - if (iter != se::NonRefNativePtrCreatedByCtorMap::end()) - { - se::NonRefNativePtrCreatedByCtorMap::erase(iter); - auto* cobj = SE_THIS_OBJECT(s); - JSB_FREE(cobj); - } return true; } SE_BIND_FINALIZE_FUNC(js_dragonBones_ArmatureCacheMgr_finalize) @@ -6099,8 +6054,8 @@ bool js_register_dragonbones_ArmatureCacheMgr(se::Object* obj) // NOLINT(readabi cls->defineFunction("buildArmatureCache", _SE(js_dragonbones_ArmatureCacheMgr_buildArmatureCache)); cls->defineFunction("removeArmatureCache", _SE(js_dragonbones_ArmatureCacheMgr_removeArmatureCache)); - cls->defineStaticFunction("getInstance", _SE(js_dragonbones_ArmatureCacheMgr_getInstance)); - cls->defineStaticFunction("destroyInstance", _SE(js_dragonbones_ArmatureCacheMgr_destroyInstance)); + cls->defineStaticFunction("destroyInstance", _SE(js_dragonbones_ArmatureCacheMgr_destroyInstance_static)); + cls->defineStaticFunction("getInstance", _SE(js_dragonbones_ArmatureCacheMgr_getInstance_static)); cls->defineFinalizeFunction(_SE(js_dragonBones_ArmatureCacheMgr_finalize)); cls->install(); JSBClassType::registerClass(cls); @@ -6108,11 +6063,12 @@ bool js_register_dragonbones_ArmatureCacheMgr(se::Object* obj) // NOLINT(readabi __jsb_dragonBones_ArmatureCacheMgr_proto = cls->getProto(); __jsb_dragonBones_ArmatureCacheMgr_class = cls; + se::ScriptEngine::getInstance()->clearException(); return true; } -se::Object* __jsb_dragonBones_CCArmatureCacheDisplay_proto = nullptr; -se::Class* __jsb_dragonBones_CCArmatureCacheDisplay_class = nullptr; +se::Object* __jsb_dragonBones_CCArmatureCacheDisplay_proto = nullptr; // NOLINT +se::Class* __jsb_dragonBones_CCArmatureCacheDisplay_class = nullptr; // NOLINT static bool js_dragonbones_CCArmatureCacheDisplay_addDBEventListener(se::State& s) // NOLINT(readability-identifier-naming) { @@ -6133,25 +6089,6 @@ static bool js_dragonbones_CCArmatureCacheDisplay_addDBEventListener(se::State& } SE_BIND_FUNC(js_dragonbones_CCArmatureCacheDisplay_addDBEventListener) -static bool js_dragonbones_CCArmatureCacheDisplay_getArmature(se::State& s) // NOLINT(readability-identifier-naming) -{ - auto* cobj = SE_THIS_OBJECT(s); - SE_PRECONDITION2(cobj, false, "js_dragonbones_CCArmatureCacheDisplay_getArmature : Invalid Native Object"); - const auto& args = s.args(); - size_t argc = args.size(); - CC_UNUSED bool ok = true; - if (argc == 0) { - dragonBones::Armature* result = cobj->getArmature(); - ok &= nativevalue_to_se(result, s.rval(), nullptr /*ctx*/); - SE_PRECONDITION2(ok, false, "js_dragonbones_CCArmatureCacheDisplay_getArmature : Error processing arguments"); - SE_HOLD_RETURN_VALUE(result, s.thisObject(), s.rval()); - return true; - } - SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 0); - return false; -} -SE_BIND_FUNC(js_dragonbones_CCArmatureCacheDisplay_getArmature) - static bool js_dragonbones_CCArmatureCacheDisplay_beginSchedule(se::State& s) // NOLINT(readability-identifier-naming) { auto* cobj = SE_THIS_OBJECT(s); @@ -6222,6 +6159,25 @@ static bool js_dragonbones_CCArmatureCacheDisplay_getAnimation(se::State& s) // } SE_BIND_FUNC(js_dragonbones_CCArmatureCacheDisplay_getAnimation) +static bool js_dragonbones_CCArmatureCacheDisplay_getArmature(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_dragonbones_CCArmatureCacheDisplay_getArmature : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 0) { + dragonBones::Armature* result = cobj->getArmature(); + ok &= nativevalue_to_se(result, s.rval(), nullptr /*ctx*/); + SE_PRECONDITION2(ok, false, "js_dragonbones_CCArmatureCacheDisplay_getArmature : Error processing arguments"); + SE_HOLD_RETURN_VALUE(result, s.thisObject(), s.rval()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 0); + return false; +} +SE_BIND_FUNC(js_dragonbones_CCArmatureCacheDisplay_getArmature) + static bool js_dragonbones_CCArmatureCacheDisplay_getParamsBuffer(se::State& s) // NOLINT(readability-identifier-naming) { auto* cobj = SE_THIS_OBJECT(s); @@ -6446,6 +6402,7 @@ static bool js_dragonbones_CCArmatureCacheDisplay_setDBEventCallback(se::State& se::Value jsThis(s.thisObject()); se::Value jsFunc(args[0]); jsThis.toObject()->attachObject(jsFunc.toObject()); + auto * thisObj = s.thisObject(); auto lambda = [=](dragonBones::EventObject* larg0) -> void { se::ScriptEngine::getInstance()->clearException(); se::AutoHandleScope hs; @@ -6455,7 +6412,6 @@ static bool js_dragonbones_CCArmatureCacheDisplay_setDBEventCallback(se::State& args.resize(1); ok &= nativevalue_to_se(larg0, args[0], nullptr /*ctx*/); se::Value rval; - se::Object* thisObj = jsThis.isObject() ? jsThis.toObject() : nullptr; se::Object* funcObj = jsFunc.toObject(); bool succeed = funcObj->call(args, thisObj, &rval); if (!succeed) { @@ -6600,18 +6556,14 @@ static bool js_dragonbones_CCArmatureCacheDisplay_constructor(se::State& s) // N ok &= sevalue_to_native(args[2], &arg2, s.thisObject()); ok &= sevalue_to_native(args[3], &arg3, s.thisObject()); SE_PRECONDITION2(ok, false, "js_dragonbones_CCArmatureCacheDisplay_constructor : Error processing arguments"); - dragonBones::CCArmatureCacheDisplay* cobj = JSB_ALLOC(dragonBones::CCArmatureCacheDisplay, arg0, arg1, arg2, arg3); - s.thisObject()->setPrivateData(cobj); + auto *ptr = JSB_MAKE_PRIVATE_OBJECT(dragonBones::CCArmatureCacheDisplay, arg0, arg1, arg2, arg3); + s.thisObject()->setPrivateObject(ptr); return true; } SE_BIND_CTOR(js_dragonbones_CCArmatureCacheDisplay_constructor, __jsb_dragonBones_CCArmatureCacheDisplay_class, js_dragonBones_CCArmatureCacheDisplay_finalize) - - static bool js_dragonBones_CCArmatureCacheDisplay_finalize(se::State& s) // NOLINT(readability-identifier-naming) { - auto* cobj =SE_THIS_OBJECT(s); - cobj->release(); return true; } SE_BIND_FINALIZE_FUNC(js_dragonBones_CCArmatureCacheDisplay_finalize) @@ -6621,11 +6573,11 @@ bool js_register_dragonbones_CCArmatureCacheDisplay(se::Object* obj) // NOLINT(r auto* cls = se::Class::create("CCArmatureCacheDisplay", obj, nullptr, _SE(js_dragonbones_CCArmatureCacheDisplay_constructor)); cls->defineFunction("addDBEventListener", _SE(js_dragonbones_CCArmatureCacheDisplay_addDBEventListener)); - cls->defineFunction("armature", _SE(js_dragonbones_CCArmatureCacheDisplay_getArmature)); cls->defineFunction("beginSchedule", _SE(js_dragonbones_CCArmatureCacheDisplay_beginSchedule)); cls->defineFunction("dispatchDBEvent", _SE(js_dragonbones_CCArmatureCacheDisplay_dispatchDBEvent)); cls->defineFunction("dispose", _SE(js_dragonbones_CCArmatureCacheDisplay_dispose)); cls->defineFunction("getAnimation", _SE(js_dragonbones_CCArmatureCacheDisplay_getAnimation)); + cls->defineFunction("armature", _SE(js_dragonbones_CCArmatureCacheDisplay_getArmature)); cls->defineFunction("getParamsBuffer", _SE(js_dragonbones_CCArmatureCacheDisplay_getParamsBuffer)); cls->defineFunction("getSharedBufferOffset", _SE(js_dragonbones_CCArmatureCacheDisplay_getSharedBufferOffset)); cls->defineFunction("getTimeScale", _SE(js_dragonbones_CCArmatureCacheDisplay_getTimeScale)); @@ -6651,11 +6603,12 @@ bool js_register_dragonbones_CCArmatureCacheDisplay(se::Object* obj) // NOLINT(r __jsb_dragonBones_CCArmatureCacheDisplay_proto = cls->getProto(); __jsb_dragonBones_CCArmatureCacheDisplay_class = cls; + se::ScriptEngine::getInstance()->clearException(); return true; } -se::Object* __jsb_dragonBones_CCFactory_proto = nullptr; -se::Class* __jsb_dragonBones_CCFactory_class = nullptr; +se::Object* __jsb_dragonBones_CCFactory_proto = nullptr; // NOLINT +se::Class* __jsb_dragonBones_CCFactory_class = nullptr; // NOLINT static bool js_dragonbones_CCFactory_add(se::State& s) // NOLINT(readability-identifier-naming) { @@ -7009,41 +6962,7 @@ static bool js_dragonbones_CCFactory_update(se::State& s) // NOLINT(readability- } SE_BIND_FUNC(js_dragonbones_CCFactory_update) -static bool js_dragonbones_CCFactory_isInit(se::State& s) // NOLINT(readability-identifier-naming) -{ - const auto& args = s.args(); - size_t argc = args.size(); - CC_UNUSED bool ok = true; - if (argc == 0) { - bool result = dragonBones::CCFactory::isInit(); - ok &= nativevalue_to_se(result, s.rval(), nullptr /*ctx*/); - SE_PRECONDITION2(ok, false, "js_dragonbones_CCFactory_isInit : Error processing arguments"); - SE_HOLD_RETURN_VALUE(result, s.thisObject(), s.rval()); - return true; - } - SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 0); - return false; -} -SE_BIND_FUNC(js_dragonbones_CCFactory_isInit) - -static bool js_dragonbones_CCFactory_getFactory(se::State& s) // NOLINT(readability-identifier-naming) -{ - const auto& args = s.args(); - size_t argc = args.size(); - CC_UNUSED bool ok = true; - if (argc == 0) { - dragonBones::CCFactory* result = dragonBones::CCFactory::getFactory(); - ok &= nativevalue_to_se(result, s.rval(), nullptr /*ctx*/); - SE_PRECONDITION2(ok, false, "js_dragonbones_CCFactory_getFactory : Error processing arguments"); - SE_HOLD_RETURN_VALUE(result, s.thisObject(), s.rval()); - return true; - } - SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 0); - return false; -} -SE_BIND_FUNC(js_dragonbones_CCFactory_getFactory) - -static bool js_dragonbones_CCFactory_destroyFactory(se::State& s) // NOLINT(readability-identifier-naming) +static bool js_dragonbones_CCFactory_destroyFactory_static(se::State& s) // NOLINT(readability-identifier-naming) { const auto& args = s.args(); size_t argc = args.size(); @@ -7054,9 +6973,9 @@ static bool js_dragonbones_CCFactory_destroyFactory(se::State& s) // NOLINT(read SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 0); return false; } -SE_BIND_FUNC(js_dragonbones_CCFactory_destroyFactory) +SE_BIND_FUNC(js_dragonbones_CCFactory_destroyFactory_static) -static bool js_dragonbones_CCFactory_getClock(se::State& s) // NOLINT(readability-identifier-naming) +static bool js_dragonbones_CCFactory_getClock_static(se::State& s) // NOLINT(readability-identifier-naming) { const auto& args = s.args(); size_t argc = args.size(); @@ -7064,37 +6983,61 @@ static bool js_dragonbones_CCFactory_getClock(se::State& s) // NOLINT(readabilit if (argc == 0) { dragonBones::WorldClock* result = dragonBones::CCFactory::getClock(); ok &= nativevalue_to_se(result, s.rval(), nullptr /*ctx*/); - SE_PRECONDITION2(ok, false, "js_dragonbones_CCFactory_getClock : Error processing arguments"); + SE_PRECONDITION2(ok, false, "js_dragonbones_CCFactory_getClock_static : Error processing arguments"); SE_HOLD_RETURN_VALUE(result, s.thisObject(), s.rval()); return true; } SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 0); return false; } -SE_BIND_FUNC(js_dragonbones_CCFactory_getClock) +SE_BIND_FUNC(js_dragonbones_CCFactory_getClock_static) + +static bool js_dragonbones_CCFactory_getFactory_static(se::State& s) // NOLINT(readability-identifier-naming) +{ + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 0) { + dragonBones::CCFactory* result = dragonBones::CCFactory::getFactory(); + ok &= nativevalue_to_se(result, s.rval(), nullptr /*ctx*/); + SE_PRECONDITION2(ok, false, "js_dragonbones_CCFactory_getFactory_static : Error processing arguments"); + SE_HOLD_RETURN_VALUE(result, s.thisObject(), s.rval()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 0); + return false; +} +SE_BIND_FUNC(js_dragonbones_CCFactory_getFactory_static) + +static bool js_dragonbones_CCFactory_isInit_static(se::State& s) // NOLINT(readability-identifier-naming) +{ + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 0) { + bool result = dragonBones::CCFactory::isInit(); + ok &= nativevalue_to_se(result, s.rval(), nullptr /*ctx*/); + SE_PRECONDITION2(ok, false, "js_dragonbones_CCFactory_isInit_static : Error processing arguments"); + SE_HOLD_RETURN_VALUE(result, s.thisObject(), s.rval()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 0); + return false; +} +SE_BIND_FUNC(js_dragonbones_CCFactory_isInit_static) SE_DECLARE_FINALIZE_FUNC(js_dragonBones_CCFactory_finalize) static bool js_dragonbones_CCFactory_constructor(se::State& s) // NOLINT(readability-identifier-naming) constructor.c { - dragonBones::CCFactory* cobj = JSB_ALLOC(dragonBones::CCFactory); - s.thisObject()->setPrivateData(cobj); - se::NonRefNativePtrCreatedByCtorMap::emplace(cobj); + auto *ptr = JSB_MAKE_PRIVATE_OBJECT(dragonBones::CCFactory); + s.thisObject()->setPrivateObject(ptr); return true; } SE_BIND_CTOR(js_dragonbones_CCFactory_constructor, __jsb_dragonBones_CCFactory_class, js_dragonBones_CCFactory_finalize) - - static bool js_dragonBones_CCFactory_finalize(se::State& s) // NOLINT(readability-identifier-naming) { - auto iter = se::NonRefNativePtrCreatedByCtorMap::find(SE_THIS_OBJECT(s)); - if (iter != se::NonRefNativePtrCreatedByCtorMap::end()) - { - se::NonRefNativePtrCreatedByCtorMap::erase(iter); - auto* cobj = SE_THIS_OBJECT(s); - JSB_FREE(cobj); - } return true; } SE_BIND_FINALIZE_FUNC(js_dragonBones_CCFactory_finalize) @@ -7117,10 +7060,10 @@ bool js_register_dragonbones_CCFactory(se::Object* obj) // NOLINT(readability-id cls->defineFunction("setTimeScale", _SE(js_dragonbones_CCFactory_setTimeScale)); cls->defineFunction("stopSchedule", _SE(js_dragonbones_CCFactory_stopSchedule)); cls->defineFunction("update", _SE(js_dragonbones_CCFactory_update)); - cls->defineStaticFunction("isInit", _SE(js_dragonbones_CCFactory_isInit)); - cls->defineStaticFunction("getFactory", _SE(js_dragonbones_CCFactory_getFactory)); - cls->defineStaticFunction("destroyFactory", _SE(js_dragonbones_CCFactory_destroyFactory)); - cls->defineStaticFunction("getClock", _SE(js_dragonbones_CCFactory_getClock)); + cls->defineStaticFunction("destroyFactory", _SE(js_dragonbones_CCFactory_destroyFactory_static)); + cls->defineStaticFunction("getClock", _SE(js_dragonbones_CCFactory_getClock_static)); + cls->defineStaticFunction("getFactory", _SE(js_dragonbones_CCFactory_getFactory_static)); + cls->defineStaticFunction("isInit", _SE(js_dragonbones_CCFactory_isInit_static)); cls->defineFinalizeFunction(_SE(js_dragonBones_CCFactory_finalize)); cls->install(); JSBClassType::registerClass(cls); @@ -7128,13 +7071,12 @@ bool js_register_dragonbones_CCFactory(se::Object* obj) // NOLINT(readability-id __jsb_dragonBones_CCFactory_proto = cls->getProto(); __jsb_dragonBones_CCFactory_class = cls; + se::ScriptEngine::getInstance()->clearException(); return true; } -se::Object* __jsb_dragonBones_CCTextureAtlasData_proto = nullptr; -se::Class* __jsb_dragonBones_CCTextureAtlasData_class = nullptr; - - +se::Object* __jsb_dragonBones_CCTextureAtlasData_proto = nullptr; // NOLINT +se::Class* __jsb_dragonBones_CCTextureAtlasData_class = nullptr; // NOLINT bool js_register_dragonbones_CCTextureAtlasData(se::Object* obj) // NOLINT(readability-identifier-naming) { @@ -7146,13 +7088,12 @@ bool js_register_dragonbones_CCTextureAtlasData(se::Object* obj) // NOLINT(reada __jsb_dragonBones_CCTextureAtlasData_proto = cls->getProto(); __jsb_dragonBones_CCTextureAtlasData_class = cls; + se::ScriptEngine::getInstance()->clearException(); return true; } -se::Object* __jsb_dragonBones_CCTextureData_proto = nullptr; -se::Class* __jsb_dragonBones_CCTextureData_class = nullptr; - - +se::Object* __jsb_dragonBones_CCTextureData_proto = nullptr; // NOLINT +se::Class* __jsb_dragonBones_CCTextureData_class = nullptr; // NOLINT bool js_register_dragonbones_CCTextureData(se::Object* obj) // NOLINT(readability-identifier-naming) { @@ -7164,14 +7105,15 @@ bool js_register_dragonbones_CCTextureData(se::Object* obj) // NOLINT(readabilit __jsb_dragonBones_CCTextureData_proto = cls->getProto(); __jsb_dragonBones_CCTextureData_class = cls; + se::ScriptEngine::getInstance()->clearException(); return true; } -bool register_all_dragonbones(se::Object* obj) +bool register_all_dragonbones(se::Object* obj) // NOLINT { // Get the ns se::Value nsVal; - if (!obj->getProperty("dragonBones", &nsVal)) + if (!obj->getProperty("dragonBones", &nsVal, true)) { se::HandleObject jsobj(se::Object::createPlainObject()); nsVal.setObject(jsobj); @@ -7180,34 +7122,35 @@ bool register_all_dragonbones(se::Object* obj) se::Object* ns = nsVal.toObject(); js_register_dragonbones_BaseObject(ns); - js_register_dragonbones_Rectangle(ns); - js_register_dragonbones_Matrix(ns); - js_register_dragonbones_Transform(ns); - js_register_dragonbones_TextureAtlasData(ns); - js_register_dragonbones_TextureData(ns); - js_register_dragonbones_ArmatureData(ns); - js_register_dragonbones_BoneData(ns); - js_register_dragonbones_SlotData(ns); - js_register_dragonbones_DragonBonesData(ns); - js_register_dragonbones_SkinData(ns); - js_register_dragonbones_AnimationData(ns); - js_register_dragonbones_Armature(ns); - js_register_dragonbones_TransformObject(ns); - js_register_dragonbones_AnimationState(ns); - js_register_dragonbones_Bone(ns); - js_register_dragonbones_Slot(ns); - js_register_dragonbones_WorldClock(ns); js_register_dragonbones_Animation(ns); - js_register_dragonbones_EventObject(ns); - js_register_dragonbones_BaseFactory(ns); - js_register_dragonbones_CCSlot(ns); - js_register_dragonbones_CCArmatureDisplay(ns); + js_register_dragonbones_AnimationData(ns); + js_register_dragonbones_AnimationState(ns); + js_register_dragonbones_Armature(ns); js_register_dragonbones_ArmatureCacheMgr(ns); + js_register_dragonbones_ArmatureData(ns); + js_register_dragonbones_BaseFactory(ns); + js_register_dragonbones_TransformObject(ns); + js_register_dragonbones_Bone(ns); + js_register_dragonbones_BoneData(ns); js_register_dragonbones_CCArmatureCacheDisplay(ns); + js_register_dragonbones_CCArmatureDisplay(ns); js_register_dragonbones_CCFactory(ns); + js_register_dragonbones_Slot(ns); + js_register_dragonbones_CCSlot(ns); + js_register_dragonbones_TextureAtlasData(ns); js_register_dragonbones_CCTextureAtlasData(ns); + js_register_dragonbones_TextureData(ns); js_register_dragonbones_CCTextureData(ns); + js_register_dragonbones_DragonBonesData(ns); + js_register_dragonbones_EventObject(ns); + js_register_dragonbones_Matrix(ns); + js_register_dragonbones_Rectangle(ns); + js_register_dragonbones_SkinData(ns); + js_register_dragonbones_SlotData(ns); + js_register_dragonbones_Transform(ns); + js_register_dragonbones_WorldClock(ns); return true; } #endif //#if USE_DRAGONBONES > 0 +// clang-format on \ No newline at end of file diff --git a/native/cocos/bindings/auto/jsb_dragonbones_auto.h b/native/cocos/bindings/auto/jsb_dragonbones_auto.h index a78f747f96..38a59490a4 100644 --- a/native/cocos/bindings/auto/jsb_dragonbones_auto.h +++ b/native/cocos/bindings/auto/jsb_dragonbones_auto.h @@ -1,67 +1,89 @@ +// clang-format off #pragma once #include "base/Config.h" #if USE_DRAGONBONES > 0 #include #include "cocos/bindings/jswrapper/SeApi.h" #include "cocos/bindings/manual/jsb_conversions.h" +#include "cocos/bindings/auto/jsb_cocos_auto.h" #include "cocos/editor-support/dragonbones-creator-support/CCDragonBonesHeaders.h" -extern se::Object* __jsb_dragonBones_BaseObject_proto; -extern se::Class* __jsb_dragonBones_BaseObject_class; - -bool js_register_dragonBones_BaseObject(se::Object* obj); -bool register_all_dragonbones(se::Object* obj); +bool register_all_dragonbones(se::Object *obj); // NOLINT JSB_REGISTER_OBJECT_TYPE(dragonBones::BaseObject); -SE_DECLARE_FUNC(js_dragonbones_BaseObject_returnToPool); -SE_DECLARE_FUNC(js_dragonbones_BaseObject_setMaxCount); -SE_DECLARE_FUNC(js_dragonbones_BaseObject_clearPool); - -extern se::Object* __jsb_dragonBones_Rectangle_proto; -extern se::Class* __jsb_dragonBones_Rectangle_class; - -bool js_register_dragonBones_Rectangle(se::Object* obj); -bool register_all_dragonbones(se::Object* obj); - JSB_REGISTER_OBJECT_TYPE(dragonBones::Rectangle); +JSB_REGISTER_OBJECT_TYPE(dragonBones::Matrix); +JSB_REGISTER_OBJECT_TYPE(dragonBones::Transform); +JSB_REGISTER_OBJECT_TYPE(dragonBones::TextureAtlasData); +JSB_REGISTER_OBJECT_TYPE(dragonBones::TextureData); +JSB_REGISTER_OBJECT_TYPE(dragonBones::ArmatureData); +JSB_REGISTER_OBJECT_TYPE(dragonBones::BoneData); +JSB_REGISTER_OBJECT_TYPE(dragonBones::SlotData); +JSB_REGISTER_OBJECT_TYPE(dragonBones::DragonBonesData); +JSB_REGISTER_OBJECT_TYPE(dragonBones::SkinData); +JSB_REGISTER_OBJECT_TYPE(dragonBones::AnimationData); +JSB_REGISTER_OBJECT_TYPE(dragonBones::Armature); +JSB_REGISTER_OBJECT_TYPE(dragonBones::TransformObject); +JSB_REGISTER_OBJECT_TYPE(dragonBones::AnimationState); +JSB_REGISTER_OBJECT_TYPE(dragonBones::Bone); +JSB_REGISTER_OBJECT_TYPE(dragonBones::Slot); +JSB_REGISTER_OBJECT_TYPE(dragonBones::WorldClock); +JSB_REGISTER_OBJECT_TYPE(dragonBones::Animation); +JSB_REGISTER_OBJECT_TYPE(dragonBones::EventObject); +JSB_REGISTER_OBJECT_TYPE(dragonBones::BaseFactory); +JSB_REGISTER_OBJECT_TYPE(dragonBones::CCSlot); +JSB_REGISTER_OBJECT_TYPE(dragonBones::CCArmatureDisplay); +JSB_REGISTER_OBJECT_TYPE(dragonBones::ArmatureCacheMgr); +JSB_REGISTER_OBJECT_TYPE(dragonBones::CCArmatureCacheDisplay); +JSB_REGISTER_OBJECT_TYPE(dragonBones::CCFactory); +JSB_REGISTER_OBJECT_TYPE(dragonBones::CCTextureAtlasData); +JSB_REGISTER_OBJECT_TYPE(dragonBones::CCTextureData); + + +extern se::Object *__jsb_dragonBones_BaseObject_proto; // NOLINT +extern se::Class * __jsb_dragonBones_BaseObject_class; // NOLINT + +bool js_register_dragonBones_BaseObject(se::Object *obj); // NOLINT + +SE_DECLARE_FUNC(js_dragonbones_BaseObject_returnToPool); +SE_DECLARE_FUNC(js_dragonbones_BaseObject_clearPool); +SE_DECLARE_FUNC(js_dragonbones_BaseObject_setMaxCount); + +extern se::Object *__jsb_dragonBones_Rectangle_proto; // NOLINT +extern se::Class * __jsb_dragonBones_Rectangle_class; // NOLINT + +bool js_register_dragonBones_Rectangle(se::Object *obj); // NOLINT + SE_DECLARE_FUNC(js_dragonbones_Rectangle_clear); SE_DECLARE_FUNC(js_dragonbones_Rectangle_Rectangle); -extern se::Object* __jsb_dragonBones_Matrix_proto; -extern se::Class* __jsb_dragonBones_Matrix_class; +extern se::Object *__jsb_dragonBones_Matrix_proto; // NOLINT +extern se::Class * __jsb_dragonBones_Matrix_class; // NOLINT -bool js_register_dragonBones_Matrix(se::Object* obj); -bool register_all_dragonbones(se::Object* obj); +bool js_register_dragonBones_Matrix(se::Object *obj); // NOLINT -JSB_REGISTER_OBJECT_TYPE(dragonBones::Matrix); -extern se::Object* __jsb_dragonBones_Transform_proto; -extern se::Class* __jsb_dragonBones_Transform_class; +extern se::Object *__jsb_dragonBones_Transform_proto; // NOLINT +extern se::Class * __jsb_dragonBones_Transform_class; // NOLINT -bool js_register_dragonBones_Transform(se::Object* obj); -bool register_all_dragonbones(se::Object* obj); +bool js_register_dragonBones_Transform(se::Object *obj); // NOLINT -JSB_REGISTER_OBJECT_TYPE(dragonBones::Transform); SE_DECLARE_FUNC(js_dragonbones_Transform_normalizeRadian); -extern se::Object* __jsb_dragonBones_TextureAtlasData_proto; -extern se::Class* __jsb_dragonBones_TextureAtlasData_class; +extern se::Object *__jsb_dragonBones_TextureAtlasData_proto; // NOLINT +extern se::Class * __jsb_dragonBones_TextureAtlasData_class; // NOLINT -bool js_register_dragonBones_TextureAtlasData(se::Object* obj); -bool register_all_dragonbones(se::Object* obj); +bool js_register_dragonBones_TextureAtlasData(se::Object *obj); // NOLINT -JSB_REGISTER_OBJECT_TYPE(dragonBones::TextureAtlasData); SE_DECLARE_FUNC(js_dragonbones_TextureAtlasData_addTexture); SE_DECLARE_FUNC(js_dragonbones_TextureAtlasData_createTexture); SE_DECLARE_FUNC(js_dragonbones_TextureAtlasData_getTexture); -extern se::Object* __jsb_dragonBones_TextureData_proto; -extern se::Class* __jsb_dragonBones_TextureData_class; +extern se::Object *__jsb_dragonBones_TextureData_proto; // NOLINT +extern se::Class * __jsb_dragonBones_TextureData_class; // NOLINT -bool js_register_dragonBones_TextureData(se::Object* obj); -bool register_all_dragonbones(se::Object* obj); +bool js_register_dragonBones_TextureData(se::Object *obj); // NOLINT -JSB_REGISTER_OBJECT_TYPE(dragonBones::TextureData); SE_DECLARE_FUNC(js_dragonbones_TextureData_getFrame); SE_DECLARE_FUNC(js_dragonbones_TextureData_getParent); SE_DECLARE_FUNC(js_dragonbones_TextureData_getRegion); @@ -69,13 +91,11 @@ SE_DECLARE_FUNC(js_dragonbones_TextureData_setFrame); SE_DECLARE_FUNC(js_dragonbones_TextureData_setParent); SE_DECLARE_FUNC(js_dragonbones_TextureData_createRectangle); -extern se::Object* __jsb_dragonBones_ArmatureData_proto; -extern se::Class* __jsb_dragonBones_ArmatureData_class; +extern se::Object *__jsb_dragonBones_ArmatureData_proto; // NOLINT +extern se::Class * __jsb_dragonBones_ArmatureData_class; // NOLINT -bool js_register_dragonBones_ArmatureData(se::Object* obj); -bool register_all_dragonbones(se::Object* obj); +bool js_register_dragonBones_ArmatureData(se::Object *obj); // NOLINT -JSB_REGISTER_OBJECT_TYPE(dragonBones::ArmatureData); SE_DECLARE_FUNC(js_dragonbones_ArmatureData_getAABB); SE_DECLARE_FUNC(js_dragonbones_ArmatureData_getAnimation); SE_DECLARE_FUNC(js_dragonbones_ArmatureData_getAnimationNames); @@ -93,69 +113,57 @@ SE_DECLARE_FUNC(js_dragonbones_ArmatureData_setParent); SE_DECLARE_FUNC(js_dragonbones_ArmatureData_setType); SE_DECLARE_FUNC(js_dragonbones_ArmatureData_sortBones); -extern se::Object* __jsb_dragonBones_BoneData_proto; -extern se::Class* __jsb_dragonBones_BoneData_class; +extern se::Object *__jsb_dragonBones_BoneData_proto; // NOLINT +extern se::Class * __jsb_dragonBones_BoneData_class; // NOLINT -bool js_register_dragonBones_BoneData(se::Object* obj); -bool register_all_dragonbones(se::Object* obj); +bool js_register_dragonBones_BoneData(se::Object *obj); // NOLINT -JSB_REGISTER_OBJECT_TYPE(dragonBones::BoneData); SE_DECLARE_FUNC(js_dragonbones_BoneData_getParent); SE_DECLARE_FUNC(js_dragonbones_BoneData_getTransfrom); SE_DECLARE_FUNC(js_dragonbones_BoneData_setParent); -extern se::Object* __jsb_dragonBones_SlotData_proto; -extern se::Class* __jsb_dragonBones_SlotData_class; +extern se::Object *__jsb_dragonBones_SlotData_proto; // NOLINT +extern se::Class * __jsb_dragonBones_SlotData_class; // NOLINT -bool js_register_dragonBones_SlotData(se::Object* obj); -bool register_all_dragonbones(se::Object* obj); +bool js_register_dragonBones_SlotData(se::Object *obj); // NOLINT -JSB_REGISTER_OBJECT_TYPE(dragonBones::SlotData); SE_DECLARE_FUNC(js_dragonbones_SlotData_getBlendMode); SE_DECLARE_FUNC(js_dragonbones_SlotData_getParent); SE_DECLARE_FUNC(js_dragonbones_SlotData_setBlendMode); SE_DECLARE_FUNC(js_dragonbones_SlotData_setParent); -extern se::Object* __jsb_dragonBones_DragonBonesData_proto; -extern se::Class* __jsb_dragonBones_DragonBonesData_class; +extern se::Object *__jsb_dragonBones_DragonBonesData_proto; // NOLINT +extern se::Class * __jsb_dragonBones_DragonBonesData_class; // NOLINT -bool js_register_dragonBones_DragonBonesData(se::Object* obj); -bool register_all_dragonbones(se::Object* obj); +bool js_register_dragonBones_DragonBonesData(se::Object *obj); // NOLINT -JSB_REGISTER_OBJECT_TYPE(dragonBones::DragonBonesData); SE_DECLARE_FUNC(js_dragonbones_DragonBonesData_addArmature); SE_DECLARE_FUNC(js_dragonbones_DragonBonesData_getArmature); SE_DECLARE_FUNC(js_dragonbones_DragonBonesData_getArmatureNames); SE_DECLARE_FUNC(js_dragonbones_DragonBonesData_getFrameIndices); -extern se::Object* __jsb_dragonBones_SkinData_proto; -extern se::Class* __jsb_dragonBones_SkinData_class; +extern se::Object *__jsb_dragonBones_SkinData_proto; // NOLINT +extern se::Class * __jsb_dragonBones_SkinData_class; // NOLINT -bool js_register_dragonBones_SkinData(se::Object* obj); -bool register_all_dragonbones(se::Object* obj); +bool js_register_dragonBones_SkinData(se::Object *obj); // NOLINT -JSB_REGISTER_OBJECT_TYPE(dragonBones::SkinData); -extern se::Object* __jsb_dragonBones_AnimationData_proto; -extern se::Class* __jsb_dragonBones_AnimationData_class; +extern se::Object *__jsb_dragonBones_AnimationData_proto; // NOLINT +extern se::Class * __jsb_dragonBones_AnimationData_class; // NOLINT -bool js_register_dragonBones_AnimationData(se::Object* obj); -bool register_all_dragonbones(se::Object* obj); +bool js_register_dragonBones_AnimationData(se::Object *obj); // NOLINT -JSB_REGISTER_OBJECT_TYPE(dragonBones::AnimationData); SE_DECLARE_FUNC(js_dragonbones_AnimationData_getBoneCachedFrameIndices); SE_DECLARE_FUNC(js_dragonbones_AnimationData_getParent); SE_DECLARE_FUNC(js_dragonbones_AnimationData_getSlotCachedFrameIndices); SE_DECLARE_FUNC(js_dragonbones_AnimationData_getZOrderTimeline); SE_DECLARE_FUNC(js_dragonbones_AnimationData_setParent); -extern se::Object* __jsb_dragonBones_Armature_proto; -extern se::Class* __jsb_dragonBones_Armature_class; +extern se::Object *__jsb_dragonBones_Armature_proto; // NOLINT +extern se::Class * __jsb_dragonBones_Armature_class; // NOLINT -bool js_register_dragonBones_Armature(se::Object* obj); -bool register_all_dragonbones(se::Object* obj); +bool js_register_dragonBones_Armature(se::Object *obj); // NOLINT -JSB_REGISTER_OBJECT_TYPE(dragonBones::Armature); SE_DECLARE_FUNC(js_dragonbones_Armature__addBone); SE_DECLARE_FUNC(js_dragonbones_Armature__addSlot); SE_DECLARE_FUNC(js_dragonbones_Armature__bufferAction); @@ -181,13 +189,11 @@ SE_DECLARE_FUNC(js_dragonbones_Armature_setClock); SE_DECLARE_FUNC(js_dragonbones_Armature_setFlipX); SE_DECLARE_FUNC(js_dragonbones_Armature_setFlipY); -extern se::Object* __jsb_dragonBones_TransformObject_proto; -extern se::Class* __jsb_dragonBones_TransformObject_class; +extern se::Object *__jsb_dragonBones_TransformObject_proto; // NOLINT +extern se::Class * __jsb_dragonBones_TransformObject_class; // NOLINT -bool js_register_dragonBones_TransformObject(se::Object* obj); -bool register_all_dragonbones(se::Object* obj); +bool js_register_dragonBones_TransformObject(se::Object *obj); // NOLINT -JSB_REGISTER_OBJECT_TYPE(dragonBones::TransformObject); SE_DECLARE_FUNC(js_dragonbones_TransformObject_getArmature); SE_DECLARE_FUNC(js_dragonbones_TransformObject_getGlobal); SE_DECLARE_FUNC(js_dragonbones_TransformObject_getGlobalTransformMatrix); @@ -195,13 +201,11 @@ SE_DECLARE_FUNC(js_dragonbones_TransformObject_getOffset); SE_DECLARE_FUNC(js_dragonbones_TransformObject_getOrigin); SE_DECLARE_FUNC(js_dragonbones_TransformObject_updateGlobalTransform); -extern se::Object* __jsb_dragonBones_AnimationState_proto; -extern se::Class* __jsb_dragonBones_AnimationState_class; +extern se::Object *__jsb_dragonBones_AnimationState_proto; // NOLINT +extern se::Class * __jsb_dragonBones_AnimationState_class; // NOLINT -bool js_register_dragonBones_AnimationState(se::Object* obj); -bool register_all_dragonbones(se::Object* obj); +bool js_register_dragonBones_AnimationState(se::Object *obj); // NOLINT -JSB_REGISTER_OBJECT_TYPE(dragonBones::AnimationState); SE_DECLARE_FUNC(js_dragonbones_AnimationState_addBoneMask); SE_DECLARE_FUNC(js_dragonbones_AnimationState_advanceTime); SE_DECLARE_FUNC(js_dragonbones_AnimationState_containsBoneMask); @@ -222,13 +226,11 @@ SE_DECLARE_FUNC(js_dragonbones_AnimationState_removeBoneMask); SE_DECLARE_FUNC(js_dragonbones_AnimationState_setCurrentTime); SE_DECLARE_FUNC(js_dragonbones_AnimationState_stop); -extern se::Object* __jsb_dragonBones_Bone_proto; -extern se::Class* __jsb_dragonBones_Bone_class; +extern se::Object *__jsb_dragonBones_Bone_proto; // NOLINT +extern se::Class * __jsb_dragonBones_Bone_class; // NOLINT -bool js_register_dragonBones_Bone(se::Object* obj); -bool register_all_dragonbones(se::Object* obj); +bool js_register_dragonBones_Bone(se::Object *obj); // NOLINT -JSB_REGISTER_OBJECT_TYPE(dragonBones::Bone); SE_DECLARE_FUNC(js_dragonbones_Bone_contains); SE_DECLARE_FUNC(js_dragonbones_Bone_getBoneData); SE_DECLARE_FUNC(js_dragonbones_Bone_getName); @@ -242,13 +244,11 @@ SE_DECLARE_FUNC(js_dragonbones_Bone_setVisible); SE_DECLARE_FUNC(js_dragonbones_Bone_update); SE_DECLARE_FUNC(js_dragonbones_Bone_updateByConstraint); -extern se::Object* __jsb_dragonBones_Slot_proto; -extern se::Class* __jsb_dragonBones_Slot_class; +extern se::Object *__jsb_dragonBones_Slot_proto; // NOLINT +extern se::Class * __jsb_dragonBones_Slot_class; // NOLINT -bool js_register_dragonBones_Slot(se::Object* obj); -bool register_all_dragonbones(se::Object* obj); +bool js_register_dragonBones_Slot(se::Object *obj); // NOLINT -JSB_REGISTER_OBJECT_TYPE(dragonBones::Slot); SE_DECLARE_FUNC(js_dragonbones_Slot__setZorder); SE_DECLARE_FUNC(js_dragonbones_Slot__updateColor); SE_DECLARE_FUNC(js_dragonbones_Slot_containsPoint); @@ -264,13 +264,11 @@ SE_DECLARE_FUNC(js_dragonbones_Slot_setVisible); SE_DECLARE_FUNC(js_dragonbones_Slot_update); SE_DECLARE_FUNC(js_dragonbones_Slot_updateTransformAndMatrix); -extern se::Object* __jsb_dragonBones_WorldClock_proto; -extern se::Class* __jsb_dragonBones_WorldClock_class; +extern se::Object *__jsb_dragonBones_WorldClock_proto; // NOLINT +extern se::Class * __jsb_dragonBones_WorldClock_class; // NOLINT -bool js_register_dragonBones_WorldClock(se::Object* obj); -bool register_all_dragonbones(se::Object* obj); +bool js_register_dragonBones_WorldClock(se::Object *obj); // NOLINT -JSB_REGISTER_OBJECT_TYPE(dragonBones::WorldClock); SE_DECLARE_FUNC(js_dragonbones_WorldClock_advanceTime); SE_DECLARE_FUNC(js_dragonbones_WorldClock_clear); SE_DECLARE_FUNC(js_dragonbones_WorldClock_getClock); @@ -278,13 +276,11 @@ SE_DECLARE_FUNC(js_dragonbones_WorldClock_render); SE_DECLARE_FUNC(js_dragonbones_WorldClock_setClock); SE_DECLARE_FUNC(js_dragonbones_WorldClock_getStaticClock); -extern se::Object* __jsb_dragonBones_Animation_proto; -extern se::Class* __jsb_dragonBones_Animation_class; +extern se::Object *__jsb_dragonBones_Animation_proto; // NOLINT +extern se::Class * __jsb_dragonBones_Animation_class; // NOLINT -bool js_register_dragonBones_Animation(se::Object* obj); -bool register_all_dragonbones(se::Object* obj); +bool js_register_dragonBones_Animation(se::Object *obj); // NOLINT -JSB_REGISTER_OBJECT_TYPE(dragonBones::Animation); SE_DECLARE_FUNC(js_dragonbones_Animation_advanceTime); SE_DECLARE_FUNC(js_dragonbones_Animation_fadeIn); SE_DECLARE_FUNC(js_dragonbones_Animation_getAnimationNames); @@ -305,25 +301,21 @@ SE_DECLARE_FUNC(js_dragonbones_Animation_play); SE_DECLARE_FUNC(js_dragonbones_Animation_reset); SE_DECLARE_FUNC(js_dragonbones_Animation_stop); -extern se::Object* __jsb_dragonBones_EventObject_proto; -extern se::Class* __jsb_dragonBones_EventObject_class; +extern se::Object *__jsb_dragonBones_EventObject_proto; // NOLINT +extern se::Class * __jsb_dragonBones_EventObject_class; // NOLINT -bool js_register_dragonBones_EventObject(se::Object* obj); -bool register_all_dragonbones(se::Object* obj); +bool js_register_dragonBones_EventObject(se::Object *obj); // NOLINT -JSB_REGISTER_OBJECT_TYPE(dragonBones::EventObject); SE_DECLARE_FUNC(js_dragonbones_EventObject_getAnimationState); SE_DECLARE_FUNC(js_dragonbones_EventObject_getArmature); SE_DECLARE_FUNC(js_dragonbones_EventObject_getBone); SE_DECLARE_FUNC(js_dragonbones_EventObject_getSlot); -extern se::Object* __jsb_dragonBones_BaseFactory_proto; -extern se::Class* __jsb_dragonBones_BaseFactory_class; +extern se::Object *__jsb_dragonBones_BaseFactory_proto; // NOLINT +extern se::Class * __jsb_dragonBones_BaseFactory_class; // NOLINT -bool js_register_dragonBones_BaseFactory(se::Object* obj); -bool register_all_dragonbones(se::Object* obj); +bool js_register_dragonBones_BaseFactory(se::Object *obj); // NOLINT -JSB_REGISTER_OBJECT_TYPE(dragonBones::BaseFactory); SE_DECLARE_FUNC(js_dragonbones_BaseFactory_addDragonBonesData); SE_DECLARE_FUNC(js_dragonbones_BaseFactory_addTextureAtlasData); SE_DECLARE_FUNC(js_dragonbones_BaseFactory_buildArmature); @@ -339,24 +331,19 @@ SE_DECLARE_FUNC(js_dragonbones_BaseFactory_replaceAnimation); SE_DECLARE_FUNC(js_dragonbones_BaseFactory_replaceSkin); SE_DECLARE_FUNC(js_dragonbones_BaseFactory_replaceSlotDisplay); -extern se::Object* __jsb_dragonBones_CCSlot_proto; -extern se::Class* __jsb_dragonBones_CCSlot_class; +extern se::Object *__jsb_dragonBones_CCSlot_proto; // NOLINT +extern se::Class * __jsb_dragonBones_CCSlot_class; // NOLINT -bool js_register_dragonBones_CCSlot(se::Object* obj); -bool register_all_dragonbones(se::Object* obj); +bool js_register_dragonBones_CCSlot(se::Object *obj); // NOLINT -JSB_REGISTER_OBJECT_TYPE(dragonBones::CCSlot); SE_DECLARE_FUNC(js_dragonbones_CCSlot_updateWorldMatrix); -extern se::Object* __jsb_dragonBones_CCArmatureDisplay_proto; -extern se::Class* __jsb_dragonBones_CCArmatureDisplay_class; +extern se::Object *__jsb_dragonBones_CCArmatureDisplay_proto; // NOLINT +extern se::Class * __jsb_dragonBones_CCArmatureDisplay_class; // NOLINT -bool js_register_dragonBones_CCArmatureDisplay(se::Object* obj); -bool register_all_dragonbones(se::Object* obj); +bool js_register_dragonBones_CCArmatureDisplay(se::Object *obj); // NOLINT -JSB_REGISTER_OBJECT_TYPE(dragonBones::CCArmatureDisplay); SE_DECLARE_FUNC(js_dragonbones_CCArmatureDisplay_addDBEventListener); -SE_DECLARE_FUNC(js_dragonbones_CCArmatureDisplay_getArmature); SE_DECLARE_FUNC(js_dragonbones_CCArmatureDisplay_convertToRootSpace); SE_DECLARE_FUNC(js_dragonbones_CCArmatureDisplay_dbClear); SE_DECLARE_FUNC(js_dragonbones_CCArmatureDisplay_dbInit); @@ -365,6 +352,7 @@ SE_DECLARE_FUNC(js_dragonbones_CCArmatureDisplay_dbUpdate); SE_DECLARE_FUNC(js_dragonbones_CCArmatureDisplay_dispatchDBEvent); SE_DECLARE_FUNC(js_dragonbones_CCArmatureDisplay_dispose); SE_DECLARE_FUNC(js_dragonbones_CCArmatureDisplay_getAnimation); +SE_DECLARE_FUNC(js_dragonbones_CCArmatureDisplay_getArmature); SE_DECLARE_FUNC(js_dragonbones_CCArmatureDisplay_getDebugData); SE_DECLARE_FUNC(js_dragonbones_CCArmatureDisplay_getParamsBuffer); SE_DECLARE_FUNC(js_dragonbones_CCArmatureDisplay_getRootDisplay); @@ -380,31 +368,27 @@ SE_DECLARE_FUNC(js_dragonbones_CCArmatureDisplay_setOpacityModifyRGB); SE_DECLARE_FUNC(js_dragonbones_CCArmatureDisplay_create); SE_DECLARE_FUNC(js_dragonbones_CCArmatureDisplay_CCArmatureDisplay); -extern se::Object* __jsb_dragonBones_ArmatureCacheMgr_proto; -extern se::Class* __jsb_dragonBones_ArmatureCacheMgr_class; +extern se::Object *__jsb_dragonBones_ArmatureCacheMgr_proto; // NOLINT +extern se::Class * __jsb_dragonBones_ArmatureCacheMgr_class; // NOLINT -bool js_register_dragonBones_ArmatureCacheMgr(se::Object* obj); -bool register_all_dragonbones(se::Object* obj); +bool js_register_dragonBones_ArmatureCacheMgr(se::Object *obj); // NOLINT -JSB_REGISTER_OBJECT_TYPE(dragonBones::ArmatureCacheMgr); SE_DECLARE_FUNC(js_dragonbones_ArmatureCacheMgr_buildArmatureCache); SE_DECLARE_FUNC(js_dragonbones_ArmatureCacheMgr_removeArmatureCache); -SE_DECLARE_FUNC(js_dragonbones_ArmatureCacheMgr_getInstance); SE_DECLARE_FUNC(js_dragonbones_ArmatureCacheMgr_destroyInstance); +SE_DECLARE_FUNC(js_dragonbones_ArmatureCacheMgr_getInstance); -extern se::Object* __jsb_dragonBones_CCArmatureCacheDisplay_proto; -extern se::Class* __jsb_dragonBones_CCArmatureCacheDisplay_class; +extern se::Object *__jsb_dragonBones_CCArmatureCacheDisplay_proto; // NOLINT +extern se::Class * __jsb_dragonBones_CCArmatureCacheDisplay_class; // NOLINT -bool js_register_dragonBones_CCArmatureCacheDisplay(se::Object* obj); -bool register_all_dragonbones(se::Object* obj); +bool js_register_dragonBones_CCArmatureCacheDisplay(se::Object *obj); // NOLINT -JSB_REGISTER_OBJECT_TYPE(dragonBones::CCArmatureCacheDisplay); SE_DECLARE_FUNC(js_dragonbones_CCArmatureCacheDisplay_addDBEventListener); -SE_DECLARE_FUNC(js_dragonbones_CCArmatureCacheDisplay_getArmature); SE_DECLARE_FUNC(js_dragonbones_CCArmatureCacheDisplay_beginSchedule); SE_DECLARE_FUNC(js_dragonbones_CCArmatureCacheDisplay_dispatchDBEvent); SE_DECLARE_FUNC(js_dragonbones_CCArmatureCacheDisplay_dispose); SE_DECLARE_FUNC(js_dragonbones_CCArmatureCacheDisplay_getAnimation); +SE_DECLARE_FUNC(js_dragonbones_CCArmatureCacheDisplay_getArmature); SE_DECLARE_FUNC(js_dragonbones_CCArmatureCacheDisplay_getParamsBuffer); SE_DECLARE_FUNC(js_dragonbones_CCArmatureCacheDisplay_getSharedBufferOffset); SE_DECLARE_FUNC(js_dragonbones_CCArmatureCacheDisplay_getTimeScale); @@ -425,13 +409,11 @@ SE_DECLARE_FUNC(js_dragonbones_CCArmatureCacheDisplay_updateAllAnimationCache); SE_DECLARE_FUNC(js_dragonbones_CCArmatureCacheDisplay_updateAnimationCache); SE_DECLARE_FUNC(js_dragonbones_CCArmatureCacheDisplay_CCArmatureCacheDisplay); -extern se::Object* __jsb_dragonBones_CCFactory_proto; -extern se::Class* __jsb_dragonBones_CCFactory_class; +extern se::Object *__jsb_dragonBones_CCFactory_proto; // NOLINT +extern se::Class * __jsb_dragonBones_CCFactory_class; // NOLINT -bool js_register_dragonBones_CCFactory(se::Object* obj); -bool register_all_dragonbones(se::Object* obj); +bool js_register_dragonBones_CCFactory(se::Object *obj); // NOLINT -JSB_REGISTER_OBJECT_TYPE(dragonBones::CCFactory); SE_DECLARE_FUNC(js_dragonbones_CCFactory_add); SE_DECLARE_FUNC(js_dragonbones_CCFactory_buildArmatureDisplay); SE_DECLARE_FUNC(js_dragonbones_CCFactory_getDragonBones); @@ -446,26 +428,22 @@ SE_DECLARE_FUNC(js_dragonbones_CCFactory_render); SE_DECLARE_FUNC(js_dragonbones_CCFactory_setTimeScale); SE_DECLARE_FUNC(js_dragonbones_CCFactory_stopSchedule); SE_DECLARE_FUNC(js_dragonbones_CCFactory_update); -SE_DECLARE_FUNC(js_dragonbones_CCFactory_isInit); -SE_DECLARE_FUNC(js_dragonbones_CCFactory_getFactory); SE_DECLARE_FUNC(js_dragonbones_CCFactory_destroyFactory); SE_DECLARE_FUNC(js_dragonbones_CCFactory_getClock); +SE_DECLARE_FUNC(js_dragonbones_CCFactory_getFactory); +SE_DECLARE_FUNC(js_dragonbones_CCFactory_isInit); SE_DECLARE_FUNC(js_dragonbones_CCFactory_CCFactory); -extern se::Object* __jsb_dragonBones_CCTextureAtlasData_proto; -extern se::Class* __jsb_dragonBones_CCTextureAtlasData_class; +extern se::Object *__jsb_dragonBones_CCTextureAtlasData_proto; // NOLINT +extern se::Class * __jsb_dragonBones_CCTextureAtlasData_class; // NOLINT -bool js_register_dragonBones_CCTextureAtlasData(se::Object* obj); -bool register_all_dragonbones(se::Object* obj); +bool js_register_dragonBones_CCTextureAtlasData(se::Object *obj); // NOLINT -JSB_REGISTER_OBJECT_TYPE(dragonBones::CCTextureAtlasData); -extern se::Object* __jsb_dragonBones_CCTextureData_proto; -extern se::Class* __jsb_dragonBones_CCTextureData_class; +extern se::Object *__jsb_dragonBones_CCTextureData_proto; // NOLINT +extern se::Class * __jsb_dragonBones_CCTextureData_class; // NOLINT -bool js_register_dragonBones_CCTextureData(se::Object* obj); -bool register_all_dragonbones(se::Object* obj); - -JSB_REGISTER_OBJECT_TYPE(dragonBones::CCTextureData); +bool js_register_dragonBones_CCTextureData(se::Object *obj); // NOLINT #endif //#if USE_DRAGONBONES > 0 + // clang-format on \ No newline at end of file diff --git a/native/cocos/bindings/auto/jsb_editor_support_auto.cpp b/native/cocos/bindings/auto/jsb_editor_support_auto.cpp index ca19de70b0..11ae2bec6b 100644 --- a/native/cocos/bindings/auto/jsb_editor_support_auto.cpp +++ b/native/cocos/bindings/auto/jsb_editor_support_auto.cpp @@ -1,3 +1,5 @@ + +// clang-format off #include "cocos/bindings/auto/jsb_editor_support_auto.h" #include "cocos/bindings/manual/jsb_conversions.h" #include "cocos/bindings/manual/jsb_global.h" @@ -12,8 +14,8 @@ #ifndef JSB_FREE #define JSB_FREE(ptr) delete ptr #endif -se::Object* __jsb_cc_middleware_Texture2D_proto = nullptr; -se::Class* __jsb_cc_middleware_Texture2D_class = nullptr; +se::Object* __jsb_cc_middleware_Texture2D_proto = nullptr; // NOLINT +se::Class* __jsb_cc_middleware_Texture2D_class = nullptr; // NOLINT static bool js_editor_support_Texture2D_getPixelsHigh(se::State& s) // NOLINT(readability-identifier-naming) { @@ -144,6 +146,7 @@ static bool js_editor_support_Texture2D_setTexParamCallback(se::State& s) // NOL se::Value jsThis(s.thisObject()); se::Value jsFunc(args[0]); jsThis.toObject()->attachObject(jsFunc.toObject()); + auto * thisObj = s.thisObject(); auto lambda = [=](int larg0, unsigned int larg1, unsigned int larg2, unsigned int larg3, unsigned int larg4) -> void { se::ScriptEngine::getInstance()->clearException(); se::AutoHandleScope hs; @@ -157,7 +160,6 @@ static bool js_editor_support_Texture2D_setTexParamCallback(se::State& s) // NOL ok &= nativevalue_to_se(larg3, args[3], nullptr /*ctx*/); ok &= nativevalue_to_se(larg4, args[4], nullptr /*ctx*/); se::Value rval; - se::Object* thisObj = jsThis.isObject() ? jsThis.toObject() : nullptr; se::Object* funcObj = jsFunc.toObject(); bool succeed = funcObj->call(args, thisObj, &rval); if (!succeed) { @@ -185,18 +187,14 @@ SE_DECLARE_FINALIZE_FUNC(js_cc_middleware_Texture2D_finalize) static bool js_editor_support_Texture2D_constructor(se::State& s) // NOLINT(readability-identifier-naming) constructor.c { - cc::middleware::Texture2D* cobj = JSB_ALLOC(cc::middleware::Texture2D); - s.thisObject()->setPrivateData(cobj); + auto *ptr = JSB_MAKE_PRIVATE_OBJECT(cc::middleware::Texture2D); + s.thisObject()->setPrivateObject(ptr); return true; } SE_BIND_CTOR(js_editor_support_Texture2D_constructor, __jsb_cc_middleware_Texture2D_class, js_cc_middleware_Texture2D_finalize) - - static bool js_cc_middleware_Texture2D_finalize(se::State& s) // NOLINT(readability-identifier-naming) { - auto* cobj =SE_THIS_OBJECT(s); - cobj->release(); return true; } SE_BIND_FINALIZE_FUNC(js_cc_middleware_Texture2D_finalize) @@ -219,11 +217,12 @@ bool js_register_editor_support_Texture2D(se::Object* obj) // NOLINT(readability __jsb_cc_middleware_Texture2D_proto = cls->getProto(); __jsb_cc_middleware_Texture2D_class = cls; + se::ScriptEngine::getInstance()->clearException(); return true; } -se::Object* __jsb_cc_middleware_SharedBufferManager_proto = nullptr; -se::Class* __jsb_cc_middleware_SharedBufferManager_class = nullptr; +se::Object* __jsb_cc_middleware_SharedBufferManager_proto = nullptr; // NOLINT +se::Class* __jsb_cc_middleware_SharedBufferManager_class = nullptr; // NOLINT static bool js_editor_support_SharedBufferManager_getSharedBuffer(se::State& s) // NOLINT(readability-identifier-naming) { @@ -259,12 +258,12 @@ static bool js_editor_support_SharedBufferManager_setResizeCallback(se::State& s se::Value jsThis(s.thisObject()); se::Value jsFunc(args[0]); jsThis.toObject()->attachObject(jsFunc.toObject()); + auto * thisObj = s.thisObject(); auto lambda = [=]() -> void { se::ScriptEngine::getInstance()->clearException(); se::AutoHandleScope hs; se::Value rval; - se::Object* thisObj = jsThis.isObject() ? jsThis.toObject() : nullptr; se::Object* funcObj = jsFunc.toObject(); bool succeed = funcObj->call(se::EmptyValueArray, thisObj, &rval); if (!succeed) { @@ -297,24 +296,14 @@ static bool js_editor_support_SharedBufferManager_constructor(se::State& s) // N se::Object::TypedArrayType arg0; ok &= sevalue_to_native(args[0], &arg0, s.thisObject()); SE_PRECONDITION2(ok, false, "js_editor_support_SharedBufferManager_constructor : Error processing arguments"); - cc::middleware::SharedBufferManager* cobj = JSB_ALLOC(cc::middleware::SharedBufferManager, arg0); - s.thisObject()->setPrivateData(cobj); - se::NonRefNativePtrCreatedByCtorMap::emplace(cobj); + auto *ptr = JSB_MAKE_PRIVATE_OBJECT(cc::middleware::SharedBufferManager, arg0); + s.thisObject()->setPrivateObject(ptr); return true; } SE_BIND_CTOR(js_editor_support_SharedBufferManager_constructor, __jsb_cc_middleware_SharedBufferManager_class, js_cc_middleware_SharedBufferManager_finalize) - - static bool js_cc_middleware_SharedBufferManager_finalize(se::State& s) // NOLINT(readability-identifier-naming) { - auto iter = se::NonRefNativePtrCreatedByCtorMap::find(SE_THIS_OBJECT(s)); - if (iter != se::NonRefNativePtrCreatedByCtorMap::end()) - { - se::NonRefNativePtrCreatedByCtorMap::erase(iter); - auto* cobj = SE_THIS_OBJECT(s); - JSB_FREE(cobj); - } return true; } SE_BIND_FINALIZE_FUNC(js_cc_middleware_SharedBufferManager_finalize) @@ -332,11 +321,12 @@ bool js_register_editor_support_SharedBufferManager(se::Object* obj) // NOLINT(r __jsb_cc_middleware_SharedBufferManager_proto = cls->getProto(); __jsb_cc_middleware_SharedBufferManager_class = cls; + se::ScriptEngine::getInstance()->clearException(); return true; } -se::Object* __jsb_cc_middleware_MiddlewareManager_proto = nullptr; -se::Class* __jsb_cc_middleware_MiddlewareManager_class = nullptr; +se::Object* __jsb_cc_middleware_MiddlewareManager_proto = nullptr; // NOLINT +se::Class* __jsb_cc_middleware_MiddlewareManager_class = nullptr; // NOLINT static bool js_editor_support_MiddlewareManager_getAttachInfoMgr(se::State& s) // NOLINT(readability-identifier-naming) { @@ -532,24 +522,7 @@ static bool js_editor_support_MiddlewareManager_update(se::State& s) // NOLINT(r } SE_BIND_FUNC(js_editor_support_MiddlewareManager_update) -static bool js_editor_support_MiddlewareManager_getInstance(se::State& s) // NOLINT(readability-identifier-naming) -{ - const auto& args = s.args(); - size_t argc = args.size(); - CC_UNUSED bool ok = true; - if (argc == 0) { - cc::middleware::MiddlewareManager* result = cc::middleware::MiddlewareManager::getInstance(); - ok &= nativevalue_to_se(result, s.rval(), nullptr /*ctx*/); - SE_PRECONDITION2(ok, false, "js_editor_support_MiddlewareManager_getInstance : Error processing arguments"); - SE_HOLD_RETURN_VALUE(result, s.thisObject(), s.rval()); - return true; - } - SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 0); - return false; -} -SE_BIND_FUNC(js_editor_support_MiddlewareManager_getInstance) - -static bool js_editor_support_MiddlewareManager_destroyInstance(se::State& s) // NOLINT(readability-identifier-naming) +static bool js_editor_support_MiddlewareManager_destroyInstance_static(se::State& s) // NOLINT(readability-identifier-naming) { const auto& args = s.args(); size_t argc = args.size(); @@ -560,9 +533,9 @@ static bool js_editor_support_MiddlewareManager_destroyInstance(se::State& s) // SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 0); return false; } -SE_BIND_FUNC(js_editor_support_MiddlewareManager_destroyInstance) +SE_BIND_FUNC(js_editor_support_MiddlewareManager_destroyInstance_static) -static bool js_editor_support_MiddlewareManager_generateModuleID(se::State& s) // NOLINT(readability-identifier-naming) +static bool js_editor_support_MiddlewareManager_generateModuleID_static(se::State& s) // NOLINT(readability-identifier-naming) { const auto& args = s.args(); size_t argc = args.size(); @@ -570,37 +543,44 @@ static bool js_editor_support_MiddlewareManager_generateModuleID(se::State& s) / if (argc == 0) { uint8_t result = cc::middleware::MiddlewareManager::generateModuleID(); ok &= nativevalue_to_se(result, s.rval(), nullptr /*ctx*/); - SE_PRECONDITION2(ok, false, "js_editor_support_MiddlewareManager_generateModuleID : Error processing arguments"); + SE_PRECONDITION2(ok, false, "js_editor_support_MiddlewareManager_generateModuleID_static : Error processing arguments"); SE_HOLD_RETURN_VALUE(result, s.thisObject(), s.rval()); return true; } SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 0); return false; } -SE_BIND_FUNC(js_editor_support_MiddlewareManager_generateModuleID) +SE_BIND_FUNC(js_editor_support_MiddlewareManager_generateModuleID_static) + +static bool js_editor_support_MiddlewareManager_getInstance_static(se::State& s) // NOLINT(readability-identifier-naming) +{ + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 0) { + cc::middleware::MiddlewareManager* result = cc::middleware::MiddlewareManager::getInstance(); + ok &= nativevalue_to_se(result, s.rval(), nullptr /*ctx*/); + SE_PRECONDITION2(ok, false, "js_editor_support_MiddlewareManager_getInstance_static : Error processing arguments"); + SE_HOLD_RETURN_VALUE(result, s.thisObject(), s.rval()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 0); + return false; +} +SE_BIND_FUNC(js_editor_support_MiddlewareManager_getInstance_static) SE_DECLARE_FINALIZE_FUNC(js_cc_middleware_MiddlewareManager_finalize) static bool js_editor_support_MiddlewareManager_constructor(se::State& s) // NOLINT(readability-identifier-naming) constructor.c { - cc::middleware::MiddlewareManager* cobj = JSB_ALLOC(cc::middleware::MiddlewareManager); - s.thisObject()->setPrivateData(cobj); - se::NonRefNativePtrCreatedByCtorMap::emplace(cobj); + auto *ptr = JSB_MAKE_PRIVATE_OBJECT(cc::middleware::MiddlewareManager); + s.thisObject()->setPrivateObject(ptr); return true; } SE_BIND_CTOR(js_editor_support_MiddlewareManager_constructor, __jsb_cc_middleware_MiddlewareManager_class, js_cc_middleware_MiddlewareManager_finalize) - - static bool js_cc_middleware_MiddlewareManager_finalize(se::State& s) // NOLINT(readability-identifier-naming) { - auto iter = se::NonRefNativePtrCreatedByCtorMap::find(SE_THIS_OBJECT(s)); - if (iter != se::NonRefNativePtrCreatedByCtorMap::end()) - { - se::NonRefNativePtrCreatedByCtorMap::erase(iter); - auto* cobj = SE_THIS_OBJECT(s); - JSB_FREE(cobj); - } return true; } SE_BIND_FINALIZE_FUNC(js_cc_middleware_MiddlewareManager_finalize) @@ -618,9 +598,9 @@ bool js_register_editor_support_MiddlewareManager(se::Object* obj) // NOLINT(rea cls->defineFunction("getVBTypedArrayLength", _SE(js_editor_support_MiddlewareManager_getVBTypedArrayLength)); cls->defineFunction("render", _SE(js_editor_support_MiddlewareManager_render)); cls->defineFunction("update", _SE(js_editor_support_MiddlewareManager_update)); - cls->defineStaticFunction("getInstance", _SE(js_editor_support_MiddlewareManager_getInstance)); - cls->defineStaticFunction("destroyInstance", _SE(js_editor_support_MiddlewareManager_destroyInstance)); - cls->defineStaticFunction("generateModuleID", _SE(js_editor_support_MiddlewareManager_generateModuleID)); + cls->defineStaticFunction("destroyInstance", _SE(js_editor_support_MiddlewareManager_destroyInstance_static)); + cls->defineStaticFunction("generateModuleID", _SE(js_editor_support_MiddlewareManager_generateModuleID_static)); + cls->defineStaticFunction("getInstance", _SE(js_editor_support_MiddlewareManager_getInstance_static)); cls->defineFinalizeFunction(_SE(js_cc_middleware_MiddlewareManager_finalize)); cls->install(); JSBClassType::registerClass(cls); @@ -628,14 +608,15 @@ bool js_register_editor_support_MiddlewareManager(se::Object* obj) // NOLINT(rea __jsb_cc_middleware_MiddlewareManager_proto = cls->getProto(); __jsb_cc_middleware_MiddlewareManager_class = cls; + se::ScriptEngine::getInstance()->clearException(); return true; } -bool register_all_editor_support(se::Object* obj) +bool register_all_editor_support(se::Object* obj) // NOLINT { // Get the ns se::Value nsVal; - if (!obj->getProperty("middleware", &nsVal)) + if (!obj->getProperty("middleware", &nsVal, true)) { se::HandleObject jsobj(se::Object::createPlainObject()); nsVal.setObject(jsobj); @@ -643,9 +624,10 @@ bool register_all_editor_support(se::Object* obj) } se::Object* ns = nsVal.toObject(); - js_register_editor_support_Texture2D(ns); - js_register_editor_support_SharedBufferManager(ns); js_register_editor_support_MiddlewareManager(ns); + js_register_editor_support_SharedBufferManager(ns); + js_register_editor_support_Texture2D(ns); return true; } +// clang-format on \ No newline at end of file diff --git a/native/cocos/bindings/auto/jsb_editor_support_auto.h b/native/cocos/bindings/auto/jsb_editor_support_auto.h index 1e53355af5..17f74249de 100644 --- a/native/cocos/bindings/auto/jsb_editor_support_auto.h +++ b/native/cocos/bindings/auto/jsb_editor_support_auto.h @@ -1,3 +1,4 @@ +// clang-format off #pragma once #include "base/Config.h" #include @@ -7,13 +8,18 @@ #include "cocos/editor-support/MiddlewareManager.h" #include "cocos/editor-support/SharedBufferManager.h" -extern se::Object* __jsb_cc_middleware_Texture2D_proto; -extern se::Class* __jsb_cc_middleware_Texture2D_class; - -bool js_register_cc_middleware_Texture2D(se::Object* obj); -bool register_all_editor_support(se::Object* obj); +bool register_all_editor_support(se::Object *obj); // NOLINT JSB_REGISTER_OBJECT_TYPE(cc::middleware::Texture2D); +JSB_REGISTER_OBJECT_TYPE(cc::middleware::SharedBufferManager); +JSB_REGISTER_OBJECT_TYPE(cc::middleware::MiddlewareManager); + + +extern se::Object *__jsb_cc_middleware_Texture2D_proto; // NOLINT +extern se::Class * __jsb_cc_middleware_Texture2D_class; // NOLINT + +bool js_register_cc_middleware_Texture2D(se::Object *obj); // NOLINT + SE_DECLARE_FUNC(js_editor_support_Texture2D_getPixelsHigh); SE_DECLARE_FUNC(js_editor_support_Texture2D_getPixelsWide); SE_DECLARE_FUNC(js_editor_support_Texture2D_getRealTextureIndex); @@ -23,24 +29,20 @@ SE_DECLARE_FUNC(js_editor_support_Texture2D_setRealTextureIndex); SE_DECLARE_FUNC(js_editor_support_Texture2D_setTexParamCallback); SE_DECLARE_FUNC(js_editor_support_Texture2D_Texture2D); -extern se::Object* __jsb_cc_middleware_SharedBufferManager_proto; -extern se::Class* __jsb_cc_middleware_SharedBufferManager_class; +extern se::Object *__jsb_cc_middleware_SharedBufferManager_proto; // NOLINT +extern se::Class * __jsb_cc_middleware_SharedBufferManager_class; // NOLINT -bool js_register_cc_middleware_SharedBufferManager(se::Object* obj); -bool register_all_editor_support(se::Object* obj); +bool js_register_cc_middleware_SharedBufferManager(se::Object *obj); // NOLINT -JSB_REGISTER_OBJECT_TYPE(cc::middleware::SharedBufferManager); SE_DECLARE_FUNC(js_editor_support_SharedBufferManager_getSharedBuffer); SE_DECLARE_FUNC(js_editor_support_SharedBufferManager_setResizeCallback); SE_DECLARE_FUNC(js_editor_support_SharedBufferManager_SharedBufferManager); -extern se::Object* __jsb_cc_middleware_MiddlewareManager_proto; -extern se::Class* __jsb_cc_middleware_MiddlewareManager_class; +extern se::Object *__jsb_cc_middleware_MiddlewareManager_proto; // NOLINT +extern se::Class * __jsb_cc_middleware_MiddlewareManager_class; // NOLINT -bool js_register_cc_middleware_MiddlewareManager(se::Object* obj); -bool register_all_editor_support(se::Object* obj); +bool js_register_cc_middleware_MiddlewareManager(se::Object *obj); // NOLINT -JSB_REGISTER_OBJECT_TYPE(cc::middleware::MiddlewareManager); SE_DECLARE_FUNC(js_editor_support_MiddlewareManager_getAttachInfoMgr); SE_DECLARE_FUNC(js_editor_support_MiddlewareManager_getBufferCount); SE_DECLARE_FUNC(js_editor_support_MiddlewareManager_getIBTypedArray); @@ -50,8 +52,8 @@ SE_DECLARE_FUNC(js_editor_support_MiddlewareManager_getVBTypedArray); SE_DECLARE_FUNC(js_editor_support_MiddlewareManager_getVBTypedArrayLength); SE_DECLARE_FUNC(js_editor_support_MiddlewareManager_render); SE_DECLARE_FUNC(js_editor_support_MiddlewareManager_update); -SE_DECLARE_FUNC(js_editor_support_MiddlewareManager_getInstance); SE_DECLARE_FUNC(js_editor_support_MiddlewareManager_destroyInstance); SE_DECLARE_FUNC(js_editor_support_MiddlewareManager_generateModuleID); +SE_DECLARE_FUNC(js_editor_support_MiddlewareManager_getInstance); SE_DECLARE_FUNC(js_editor_support_MiddlewareManager_MiddlewareManager); - + // clang-format on \ No newline at end of file diff --git a/native/cocos/bindings/auto/jsb_extension_auto.cpp b/native/cocos/bindings/auto/jsb_extension_auto.cpp index e233425cc4..0eacb2f8ed 100644 --- a/native/cocos/bindings/auto/jsb_extension_auto.cpp +++ b/native/cocos/bindings/auto/jsb_extension_auto.cpp @@ -1,3 +1,5 @@ + +// clang-format off #include "cocos/bindings/auto/jsb_extension_auto.h" #include "cocos/bindings/manual/jsb_conversions.h" #include "cocos/bindings/manual/jsb_global.h" @@ -10,8 +12,8 @@ #ifndef JSB_FREE #define JSB_FREE(ptr) delete ptr #endif -se::Object* __jsb_cc_extension_EventAssetsManagerEx_proto = nullptr; -se::Class* __jsb_cc_extension_EventAssetsManagerEx_class = nullptr; +se::Object* __jsb_cc_extension_EventAssetsManagerEx_proto = nullptr; // NOLINT +se::Class* __jsb_cc_extension_EventAssetsManagerEx_class = nullptr; // NOLINT static bool js_extension_EventAssetsManagerEx_getAssetId(se::State& s) // NOLINT(readability-identifier-naming) { @@ -273,18 +275,14 @@ static bool js_extension_EventAssetsManagerEx_constructor(se::State& s) // NOLIN ok &= sevalue_to_native(args[1], &arg1, s.thisObject()); ok &= sevalue_to_native(args[2], &arg2, s.thisObject()); SE_PRECONDITION2(ok, false, "js_extension_EventAssetsManagerEx_constructor : Error processing arguments"); - cc::extension::EventAssetsManagerEx* cobj = JSB_ALLOC(cc::extension::EventAssetsManagerEx, arg0, arg1, arg2); - s.thisObject()->setPrivateData(cobj); + auto *ptr = JSB_MAKE_PRIVATE_OBJECT(cc::extension::EventAssetsManagerEx, arg0, arg1, arg2); + s.thisObject()->setPrivateObject(ptr); return true; } SE_BIND_CTOR(js_extension_EventAssetsManagerEx_constructor, __jsb_cc_extension_EventAssetsManagerEx_class, js_cc_extension_EventAssetsManagerEx_finalize) - - static bool js_cc_extension_EventAssetsManagerEx_finalize(se::State& s) // NOLINT(readability-identifier-naming) { - auto* cobj =SE_THIS_OBJECT(s); - cobj->release(); return true; } SE_BIND_FINALIZE_FUNC(js_cc_extension_EventAssetsManagerEx_finalize) @@ -313,11 +311,12 @@ bool js_register_extension_EventAssetsManagerEx(se::Object* obj) // NOLINT(reada __jsb_cc_extension_EventAssetsManagerEx_proto = cls->getProto(); __jsb_cc_extension_EventAssetsManagerEx_class = cls; + se::ScriptEngine::getInstance()->clearException(); return true; } -se::Object* __jsb_cc_extension_Manifest_proto = nullptr; -se::Class* __jsb_cc_extension_Manifest_class = nullptr; +se::Object* __jsb_cc_extension_Manifest_proto = nullptr; // NOLINT +se::Class* __jsb_cc_extension_Manifest_class = nullptr; // NOLINT static bool js_extension_Manifest_getManifestFileUrl(se::State& s) // NOLINT(readability-identifier-naming) { @@ -564,15 +563,15 @@ static bool js_extension_Manifest_constructor(se::State& s) // NOLINT(readabilit HolderType arg1 = {}; ok &= sevalue_to_native(args[1], &arg1, s.thisObject()); if (!ok) { ok = true; break; } - cc::extension::Manifest* cobj = JSB_ALLOC(cc::extension::Manifest, arg0.value(), arg1.value()); - s.thisObject()->setPrivateData(cobj); + auto *ptr = JSB_MAKE_PRIVATE_OBJECT(cc::extension::Manifest, arg0.value(), arg1.value()); + s.thisObject()->setPrivateObject(ptr); return true; } } while(false); do { if (argc == 0) { - cc::extension::Manifest* cobj = JSB_ALLOC(cc::extension::Manifest); - s.thisObject()->setPrivateData(cobj); + auto *ptr = JSB_MAKE_PRIVATE_OBJECT(cc::extension::Manifest); + s.thisObject()->setPrivateObject(ptr); return true; } } while(false); @@ -581,8 +580,8 @@ static bool js_extension_Manifest_constructor(se::State& s) // NOLINT(readabilit HolderType arg0 = {}; ok &= sevalue_to_native(args[0], &arg0, s.thisObject()); if (!ok) { ok = true; break; } - cc::extension::Manifest* cobj = JSB_ALLOC(cc::extension::Manifest, arg0.value()); - s.thisObject()->setPrivateData(cobj); + auto *ptr = JSB_MAKE_PRIVATE_OBJECT(cc::extension::Manifest, arg0.value()); + s.thisObject()->setPrivateObject(ptr); return true; } } while(false); @@ -591,12 +590,8 @@ static bool js_extension_Manifest_constructor(se::State& s) // NOLINT(readabilit } SE_BIND_CTOR(js_extension_Manifest_constructor, __jsb_cc_extension_Manifest_class, js_cc_extension_Manifest_finalize) - - static bool js_cc_extension_Manifest_finalize(se::State& s) // NOLINT(readability-identifier-naming) { - auto* cobj =SE_THIS_OBJECT(s); - cobj->release(); return true; } SE_BIND_FINALIZE_FUNC(js_cc_extension_Manifest_finalize) @@ -624,11 +619,12 @@ bool js_register_extension_Manifest(se::Object* obj) // NOLINT(readability-ident __jsb_cc_extension_Manifest_proto = cls->getProto(); __jsb_cc_extension_Manifest_class = cls; + se::ScriptEngine::getInstance()->clearException(); return true; } -se::Object* __jsb_cc_extension_AssetsManagerEx_proto = nullptr; -se::Class* __jsb_cc_extension_AssetsManagerEx_class = nullptr; +se::Object* __jsb_cc_extension_AssetsManagerEx_proto = nullptr; // NOLINT +se::Class* __jsb_cc_extension_AssetsManagerEx_class = nullptr; // NOLINT static bool js_extension_AssetsManagerEx_checkUpdate(se::State& s) // NOLINT(readability-identifier-naming) { @@ -725,7 +721,7 @@ static bool js_extension_AssetsManagerEx_getMaxConcurrentTask(se::State& s) // N size_t argc = args.size(); CC_UNUSED bool ok = true; if (argc == 0) { - const int result = cobj->getMaxConcurrentTask(); + int result = cobj->getMaxConcurrentTask(); ok &= nativevalue_to_se(result, s.rval(), nullptr /*ctx*/); SE_PRECONDITION2(ok, false, "js_extension_AssetsManagerEx_getMaxConcurrentTask : Error processing arguments"); SE_HOLD_RETURN_VALUE(result, s.thisObject(), s.rval()); @@ -945,6 +941,7 @@ static bool js_extension_AssetsManagerEx_setEventCallback(se::State& s) // NOLIN se::Value jsThis(s.thisObject()); se::Value jsFunc(args[0]); jsThis.toObject()->attachObject(jsFunc.toObject()); + auto * thisObj = s.thisObject(); auto lambda = [=](cc::extension::EventAssetsManagerEx* larg0) -> void { se::ScriptEngine::getInstance()->clearException(); se::AutoHandleScope hs; @@ -954,7 +951,6 @@ static bool js_extension_AssetsManagerEx_setEventCallback(se::State& s) // NOLIN args.resize(1); ok &= nativevalue_to_se(larg0, args[0], nullptr /*ctx*/); se::Value rval; - se::Object* thisObj = jsThis.isObject() ? jsThis.toObject() : nullptr; se::Object* funcObj = jsFunc.toObject(); bool succeed = funcObj->call(args, thisObj, &rval); if (!succeed) { @@ -1012,6 +1008,7 @@ static bool js_extension_AssetsManagerEx_setVerifyCallback(se::State& s) // NOLI se::Value jsThis(s.thisObject()); se::Value jsFunc(args[0]); jsThis.toObject()->attachObject(jsFunc.toObject()); + auto * thisObj = s.thisObject(); auto lambda = [=](const std::string larg0, cc::extension::ManifestAsset larg1) -> bool { se::ScriptEngine::getInstance()->clearException(); se::AutoHandleScope hs; @@ -1022,7 +1019,6 @@ static bool js_extension_AssetsManagerEx_setVerifyCallback(se::State& s) // NOLI ok &= nativevalue_to_se(larg0, args[0], nullptr /*ctx*/); ok &= nativevalue_to_se(larg1, args[1], nullptr /*ctx*/); se::Value rval; - se::Object* thisObj = jsThis.isObject() ? jsThis.toObject() : nullptr; se::Object* funcObj = jsFunc.toObject(); bool succeed = funcObj->call(args, thisObj, &rval); if (!succeed) { @@ -1065,6 +1061,7 @@ static bool js_extension_AssetsManagerEx_setVersionCompareHandle(se::State& s) / se::Value jsThis(s.thisObject()); se::Value jsFunc(args[0]); jsThis.toObject()->attachObject(jsFunc.toObject()); + auto * thisObj = s.thisObject(); auto lambda = [=](const std::string larg0, const std::string larg1) -> int { se::ScriptEngine::getInstance()->clearException(); se::AutoHandleScope hs; @@ -1075,7 +1072,6 @@ static bool js_extension_AssetsManagerEx_setVersionCompareHandle(se::State& s) / ok &= nativevalue_to_se(larg0, args[0], nullptr /*ctx*/); ok &= nativevalue_to_se(larg1, args[1], nullptr /*ctx*/); se::Value rval; - se::Object* thisObj = jsThis.isObject() ? jsThis.toObject() : nullptr; se::Object* funcObj = jsFunc.toObject(); bool succeed = funcObj->call(args, thisObj, &rval); if (!succeed) { @@ -1118,7 +1114,7 @@ static bool js_extension_AssetsManagerEx_update(se::State& s) // NOLINT(readabil } SE_BIND_FUNC(js_extension_AssetsManagerEx_update) -static bool js_extension_AssetsManagerEx_create(se::State& s) // NOLINT(readability-identifier-naming) +static bool js_extension_AssetsManagerEx_create_static(se::State& s) // NOLINT(readability-identifier-naming) { const auto& args = s.args(); size_t argc = args.size(); @@ -1128,18 +1124,17 @@ static bool js_extension_AssetsManagerEx_create(se::State& s) // NOLINT(readabil HolderType arg1 = {}; ok &= sevalue_to_native(args[0], &arg0, nullptr); ok &= sevalue_to_native(args[1], &arg1, nullptr); - SE_PRECONDITION2(ok, false, "js_extension_AssetsManagerEx_create : Error processing arguments"); - auto result = cc::extension::AssetsManagerEx::create(arg0.value(), arg1.value()); - result->retain(); - auto obj = se::Object::createObjectWithClass(__jsb_cc_extension_AssetsManagerEx_class); - obj->setPrivateData(result); - s.rval().setObject(obj); + SE_PRECONDITION2(ok, false, "js_extension_AssetsManagerEx_create_static : Error processing arguments"); + cc::extension::AssetsManagerEx* result = cc::extension::AssetsManagerEx::create(arg0.value(), arg1.value()); + ok &= nativevalue_to_se(result, s.rval(), nullptr /*ctx*/); + SE_PRECONDITION2(ok, false, "js_extension_AssetsManagerEx_create_static : Error processing arguments"); + SE_HOLD_RETURN_VALUE(result, s.thisObject(), s.rval()); return true; } SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 2); return false; } -SE_BIND_FUNC(js_extension_AssetsManagerEx_create) +SE_BIND_FUNC(js_extension_AssetsManagerEx_create_static) SE_DECLARE_FINALIZE_FUNC(js_cc_extension_AssetsManagerEx_finalize) @@ -1156,13 +1151,14 @@ static bool js_extension_AssetsManagerEx_constructor(se::State& s) // NOLINT(rea HolderType arg1 = {}; ok &= sevalue_to_native(args[1], &arg1, s.thisObject()); if (!ok) { ok = true; break; } - HolderType, true> arg2 = {}; + HolderType, false> arg2 = {}; do { if (args[2].isObject() && args[2].toObject()->isFunction()) { se::Value jsThis(s.thisObject()); se::Value jsFunc(args[2]); jsThis.toObject()->attachObject(jsFunc.toObject()); + auto * thisObj = s.thisObject(); auto lambda = [=](const std::string larg0, const std::string larg1) -> int { se::ScriptEngine::getInstance()->clearException(); se::AutoHandleScope hs; @@ -1173,7 +1169,6 @@ static bool js_extension_AssetsManagerEx_constructor(se::State& s) // NOLINT(rea ok &= nativevalue_to_se(larg0, args[0], nullptr /*ctx*/); ok &= nativevalue_to_se(larg1, args[1], nullptr /*ctx*/); se::Value rval; - se::Object* thisObj = jsThis.isObject() ? jsThis.toObject() : nullptr; se::Object* funcObj = jsFunc.toObject(); bool succeed = funcObj->call(args, thisObj, &rval); if (!succeed) { @@ -1193,8 +1188,8 @@ static bool js_extension_AssetsManagerEx_constructor(se::State& s) // NOLINT(rea } while(false) ; if (!ok) { ok = true; break; } - cc::extension::AssetsManagerEx* cobj = JSB_ALLOC(cc::extension::AssetsManagerEx, arg0.value(), arg1.value(), arg2.value()); - s.thisObject()->setPrivateData(cobj); + auto *ptr = JSB_MAKE_PRIVATE_OBJECT(cc::extension::AssetsManagerEx, arg0.value(), arg1.value(), arg2.value()); + s.thisObject()->setPrivateObject(ptr); return true; } } while(false); @@ -1206,8 +1201,8 @@ static bool js_extension_AssetsManagerEx_constructor(se::State& s) // NOLINT(rea HolderType arg1 = {}; ok &= sevalue_to_native(args[1], &arg1, s.thisObject()); if (!ok) { ok = true; break; } - cc::extension::AssetsManagerEx* cobj = JSB_ALLOC(cc::extension::AssetsManagerEx, arg0.value(), arg1.value()); - s.thisObject()->setPrivateData(cobj); + auto *ptr = JSB_MAKE_PRIVATE_OBJECT(cc::extension::AssetsManagerEx, arg0.value(), arg1.value()); + s.thisObject()->setPrivateObject(ptr); return true; } } while(false); @@ -1216,12 +1211,8 @@ static bool js_extension_AssetsManagerEx_constructor(se::State& s) // NOLINT(rea } SE_BIND_CTOR(js_extension_AssetsManagerEx_constructor, __jsb_cc_extension_AssetsManagerEx_class, js_cc_extension_AssetsManagerEx_finalize) - - static bool js_cc_extension_AssetsManagerEx_finalize(se::State& s) // NOLINT(readability-identifier-naming) { - auto* cobj =SE_THIS_OBJECT(s); - cobj->release(); return true; } SE_BIND_FINALIZE_FUNC(js_cc_extension_AssetsManagerEx_finalize) @@ -1250,7 +1241,7 @@ bool js_register_extension_AssetsManagerEx(se::Object* obj) // NOLINT(readabilit cls->defineFunction("setVerifyCallback", _SE(js_extension_AssetsManagerEx_setVerifyCallback)); cls->defineFunction("setVersionCompareHandle", _SE(js_extension_AssetsManagerEx_setVersionCompareHandle)); cls->defineFunction("update", _SE(js_extension_AssetsManagerEx_update)); - cls->defineStaticFunction("create", _SE(js_extension_AssetsManagerEx_create)); + cls->defineStaticFunction("create", _SE(js_extension_AssetsManagerEx_create_static)); cls->defineFinalizeFunction(_SE(js_cc_extension_AssetsManagerEx_finalize)); cls->install(); JSBClassType::registerClass(cls); @@ -1258,14 +1249,15 @@ bool js_register_extension_AssetsManagerEx(se::Object* obj) // NOLINT(readabilit __jsb_cc_extension_AssetsManagerEx_proto = cls->getProto(); __jsb_cc_extension_AssetsManagerEx_class = cls; + se::ScriptEngine::getInstance()->clearException(); return true; } -bool register_all_extension(se::Object* obj) +bool register_all_extension(se::Object* obj) // NOLINT { // Get the ns se::Value nsVal; - if (!obj->getProperty("jsb", &nsVal)) + if (!obj->getProperty("jsb", &nsVal, true)) { se::HandleObject jsobj(se::Object::createPlainObject()); nsVal.setObject(jsobj); @@ -1273,9 +1265,10 @@ bool register_all_extension(se::Object* obj) } se::Object* ns = nsVal.toObject(); + js_register_extension_AssetsManagerEx(ns); js_register_extension_EventAssetsManagerEx(ns); js_register_extension_Manifest(ns); - js_register_extension_AssetsManagerEx(ns); return true; } +// clang-format on \ No newline at end of file diff --git a/native/cocos/bindings/auto/jsb_extension_auto.h b/native/cocos/bindings/auto/jsb_extension_auto.h index dcfd3d411f..a4389621b9 100644 --- a/native/cocos/bindings/auto/jsb_extension_auto.h +++ b/native/cocos/bindings/auto/jsb_extension_auto.h @@ -1,3 +1,4 @@ +// clang-format off #pragma once #include "base/Config.h" #include @@ -5,13 +6,18 @@ #include "cocos/bindings/manual/jsb_conversions.h" #include "extensions/cocos-ext.h" -extern se::Object* __jsb_cc_extension_EventAssetsManagerEx_proto; -extern se::Class* __jsb_cc_extension_EventAssetsManagerEx_class; - -bool js_register_cc_extension_EventAssetsManagerEx(se::Object* obj); -bool register_all_extension(se::Object* obj); +bool register_all_extension(se::Object *obj); // NOLINT JSB_REGISTER_OBJECT_TYPE(cc::extension::EventAssetsManagerEx); +JSB_REGISTER_OBJECT_TYPE(cc::extension::Manifest); +JSB_REGISTER_OBJECT_TYPE(cc::extension::AssetsManagerEx); + + +extern se::Object *__jsb_cc_extension_EventAssetsManagerEx_proto; // NOLINT +extern se::Class * __jsb_cc_extension_EventAssetsManagerEx_class; // NOLINT + +bool js_register_cc_extension_EventAssetsManagerEx(se::Object *obj); // NOLINT + SE_DECLARE_FUNC(js_extension_EventAssetsManagerEx_getAssetId); SE_DECLARE_FUNC(js_extension_EventAssetsManagerEx_getAssetsManagerEx); SE_DECLARE_FUNC(js_extension_EventAssetsManagerEx_getCURLECode); @@ -27,13 +33,11 @@ SE_DECLARE_FUNC(js_extension_EventAssetsManagerEx_getTotalFiles); SE_DECLARE_FUNC(js_extension_EventAssetsManagerEx_isResuming); SE_DECLARE_FUNC(js_extension_EventAssetsManagerEx_EventAssetsManagerEx); -extern se::Object* __jsb_cc_extension_Manifest_proto; -extern se::Class* __jsb_cc_extension_Manifest_class; +extern se::Object *__jsb_cc_extension_Manifest_proto; // NOLINT +extern se::Class * __jsb_cc_extension_Manifest_class; // NOLINT -bool js_register_cc_extension_Manifest(se::Object* obj); -bool register_all_extension(se::Object* obj); +bool js_register_cc_extension_Manifest(se::Object *obj); // NOLINT -JSB_REGISTER_OBJECT_TYPE(cc::extension::Manifest); SE_DECLARE_FUNC(js_extension_Manifest_getManifestFileUrl); SE_DECLARE_FUNC(js_extension_Manifest_getManifestRoot); SE_DECLARE_FUNC(js_extension_Manifest_getPackageUrl); @@ -48,13 +52,11 @@ SE_DECLARE_FUNC(js_extension_Manifest_parseJSONString); SE_DECLARE_FUNC(js_extension_Manifest_setUpdating); SE_DECLARE_FUNC(js_extension_Manifest_Manifest); -extern se::Object* __jsb_cc_extension_AssetsManagerEx_proto; -extern se::Class* __jsb_cc_extension_AssetsManagerEx_class; +extern se::Object *__jsb_cc_extension_AssetsManagerEx_proto; // NOLINT +extern se::Class * __jsb_cc_extension_AssetsManagerEx_class; // NOLINT -bool js_register_cc_extension_AssetsManagerEx(se::Object* obj); -bool register_all_extension(se::Object* obj); +bool js_register_cc_extension_AssetsManagerEx(se::Object *obj); // NOLINT -JSB_REGISTER_OBJECT_TYPE(cc::extension::AssetsManagerEx); SE_DECLARE_FUNC(js_extension_AssetsManagerEx_checkUpdate); SE_DECLARE_FUNC(js_extension_AssetsManagerEx_downloadFailedAssets); SE_DECLARE_FUNC(js_extension_AssetsManagerEx_getDownloadedBytes); @@ -77,4 +79,4 @@ SE_DECLARE_FUNC(js_extension_AssetsManagerEx_setVersionCompareHandle); SE_DECLARE_FUNC(js_extension_AssetsManagerEx_update); SE_DECLARE_FUNC(js_extension_AssetsManagerEx_create); SE_DECLARE_FUNC(js_extension_AssetsManagerEx_AssetsManagerEx); - + // clang-format on \ No newline at end of file diff --git a/native/cocos/bindings/auto/jsb_geometry_auto.cpp b/native/cocos/bindings/auto/jsb_geometry_auto.cpp new file mode 100644 index 0000000000..9842ad3994 --- /dev/null +++ b/native/cocos/bindings/auto/jsb_geometry_auto.cpp @@ -0,0 +1,2890 @@ + +// clang-format off +#include "cocos/bindings/auto/jsb_geometry_auto.h" +#include "cocos/bindings/manual/jsb_conversions.h" +#include "cocos/bindings/manual/jsb_global.h" +#include "core/geometry/Geometry.h" + +#ifndef JSB_ALLOC +#define JSB_ALLOC(kls, ...) new (std::nothrow) kls(__VA_ARGS__) +#endif + +#ifndef JSB_FREE +#define JSB_FREE(ptr) delete ptr +#endif +se::Object* __jsb_cc_geometry_ShapeBase_proto = nullptr; // NOLINT +se::Class* __jsb_cc_geometry_ShapeBase_class = nullptr; // NOLINT + +static bool js_geometry_ShapeBase_getType(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_geometry_ShapeBase_getType : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 0) { + auto result = static_cast(cobj->getType()); + ok &= nativevalue_to_se(result, s.rval(), nullptr /*ctx*/); + SE_PRECONDITION2(ok, false, "js_geometry_ShapeBase_getType : Error processing arguments"); + SE_HOLD_RETURN_VALUE(result, s.thisObject(), s.rval()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 0); + return false; +} +SE_BIND_FUNC_AS_PROP_GET(js_geometry_ShapeBase_getType) + +static bool js_geometry_ShapeBase_setType(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_geometry_ShapeBase_setType : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 1) { + HolderType arg0 = {}; + ok &= sevalue_to_native(args[0], &arg0, s.thisObject()); + SE_PRECONDITION2(ok, false, "js_geometry_ShapeBase_setType : Error processing arguments"); + cobj->setType(arg0.value()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 1); + return false; +} +SE_BIND_FUNC_AS_PROP_SET(js_geometry_ShapeBase_setType) + +bool js_register_geometry_ShapeBase(se::Object* obj) // NOLINT(readability-identifier-naming) +{ + auto* cls = se::Class::create("ShapeBase", obj, nullptr, nullptr); + + cls->defineProperty("_type", _SE(js_geometry_ShapeBase_getType_asGetter), _SE(js_geometry_ShapeBase_setType_asSetter)); + cls->install(); + JSBClassType::registerClass(cls); + + __jsb_cc_geometry_ShapeBase_proto = cls->getProto(); + __jsb_cc_geometry_ShapeBase_class = cls; + + + se::ScriptEngine::getInstance()->clearException(); + return true; +} +se::Object* __jsb_cc_geometry_AABB_proto = nullptr; // NOLINT +se::Class* __jsb_cc_geometry_AABB_class = nullptr; // NOLINT + +static bool js_geometry_AABB_contain(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_geometry_AABB_contain : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 1) { + HolderType arg0 = {}; + ok &= sevalue_to_native(args[0], &arg0, s.thisObject()); + SE_PRECONDITION2(ok, false, "js_geometry_AABB_contain : Error processing arguments"); + bool result = cobj->contain(arg0.value()); + ok &= nativevalue_to_se(result, s.rval(), nullptr /*ctx*/); + SE_PRECONDITION2(ok, false, "js_geometry_AABB_contain : Error processing arguments"); + SE_HOLD_RETURN_VALUE(result, s.thisObject(), s.rval()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 1); + return false; +} +SE_BIND_FUNC(js_geometry_AABB_contain) + +static bool js_geometry_AABB_create_static(se::State& s) // NOLINT(readability-identifier-naming) +{ + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 6) { + HolderType arg0 = {}; + HolderType arg1 = {}; + HolderType arg2 = {}; + HolderType arg3 = {}; + HolderType arg4 = {}; + HolderType arg5 = {}; + ok &= sevalue_to_native(args[0], &arg0, nullptr); + ok &= sevalue_to_native(args[1], &arg1, nullptr); + ok &= sevalue_to_native(args[2], &arg2, nullptr); + ok &= sevalue_to_native(args[3], &arg3, nullptr); + ok &= sevalue_to_native(args[4], &arg4, nullptr); + ok &= sevalue_to_native(args[5], &arg5, nullptr); + SE_PRECONDITION2(ok, false, "js_geometry_AABB_create_static : Error processing arguments"); + cc::geometry::AABB* result = cc::geometry::AABB::create(arg0.value(), arg1.value(), arg2.value(), arg3.value(), arg4.value(), arg5.value()); + ok &= nativevalue_to_se(result, s.rval(), nullptr /*ctx*/); + SE_PRECONDITION2(ok, false, "js_geometry_AABB_create_static : Error processing arguments"); + SE_HOLD_RETURN_VALUE(result, s.thisObject(), s.rval()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 6); + return false; +} +SE_BIND_FUNC(js_geometry_AABB_create_static) + +static bool js_geometry_AABB_toBoundingSphere_static(se::State& s) // NOLINT(readability-identifier-naming) +{ + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 2) { + HolderType arg0 = {}; + HolderType arg1 = {}; + ok &= sevalue_to_native(args[0], &arg0, nullptr); + ok &= sevalue_to_native(args[1], &arg1, nullptr); + SE_PRECONDITION2(ok, false, "js_geometry_AABB_toBoundingSphere_static : Error processing arguments"); + cc::geometry::Sphere* result = cc::geometry::AABB::toBoundingSphere(arg0.value(), arg1.value()); + ok &= nativevalue_to_se(result, s.rval(), nullptr /*ctx*/); + SE_PRECONDITION2(ok, false, "js_geometry_AABB_toBoundingSphere_static : Error processing arguments"); + SE_HOLD_RETURN_VALUE(result, s.thisObject(), s.rval()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 2); + return false; +} +SE_BIND_FUNC(js_geometry_AABB_toBoundingSphere_static) + +static bool js_geometry_AABB_get_center(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_geometry_AABB_get_center : Invalid Native Object"); + + CC_UNUSED bool ok = true; + se::Value jsret; + ok &= nativevalue_to_se(cobj->center, jsret, s.thisObject() /*ctx*/); + s.rval() = jsret; + SE_HOLD_RETURN_VALUE(cobj->center, s.thisObject(), s.rval()); + return true; +} +SE_BIND_PROP_GET(js_geometry_AABB_get_center) + +static bool js_geometry_AABB_set_center(se::State& s) // NOLINT(readability-identifier-naming) +{ + const auto& args = s.args(); + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_geometry_AABB_set_center : Invalid Native Object"); + + CC_UNUSED bool ok = true; + ok &= sevalue_to_native(args[0], &cobj->center, s.thisObject()); + SE_PRECONDITION2(ok, false, "js_geometry_AABB_set_center : Error processing new value"); + return true; +} +SE_BIND_PROP_SET(js_geometry_AABB_set_center) + +static bool js_geometry_AABB_get_halfExtents(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_geometry_AABB_get_halfExtents : Invalid Native Object"); + + CC_UNUSED bool ok = true; + se::Value jsret; + ok &= nativevalue_to_se(cobj->halfExtents, jsret, s.thisObject() /*ctx*/); + s.rval() = jsret; + SE_HOLD_RETURN_VALUE(cobj->halfExtents, s.thisObject(), s.rval()); + return true; +} +SE_BIND_PROP_GET(js_geometry_AABB_get_halfExtents) + +static bool js_geometry_AABB_set_halfExtents(se::State& s) // NOLINT(readability-identifier-naming) +{ + const auto& args = s.args(); + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_geometry_AABB_set_halfExtents : Invalid Native Object"); + + CC_UNUSED bool ok = true; + ok &= sevalue_to_native(args[0], &cobj->halfExtents, s.thisObject()); + SE_PRECONDITION2(ok, false, "js_geometry_AABB_set_halfExtents : Error processing new value"); + return true; +} +SE_BIND_PROP_SET(js_geometry_AABB_set_halfExtents) + +SE_DECLARE_FINALIZE_FUNC(js_cc_geometry_AABB_finalize) + +static bool js_geometry_AABB_constructor(se::State& s) // NOLINT(readability-identifier-naming) constructor_overloaded.c +{ + CC_UNUSED bool ok = true; + const auto& args = s.args(); + size_t argc = args.size(); + do { + if (argc == 0) { + auto *ptr = JSB_MAKE_PRIVATE_OBJECT(cc::geometry::AABB); + s.thisObject()->setPrivateObject(ptr); + return true; + } + } while(false); + do { + if (argc == 6) { + HolderType arg0 = {}; + ok &= sevalue_to_native(args[0], &arg0, s.thisObject()); + if (!ok) { ok = true; break; } + HolderType arg1 = {}; + ok &= sevalue_to_native(args[1], &arg1, s.thisObject()); + if (!ok) { ok = true; break; } + HolderType arg2 = {}; + ok &= sevalue_to_native(args[2], &arg2, s.thisObject()); + if (!ok) { ok = true; break; } + HolderType arg3 = {}; + ok &= sevalue_to_native(args[3], &arg3, s.thisObject()); + if (!ok) { ok = true; break; } + HolderType arg4 = {}; + ok &= sevalue_to_native(args[4], &arg4, s.thisObject()); + if (!ok) { ok = true; break; } + HolderType arg5 = {}; + ok &= sevalue_to_native(args[5], &arg5, s.thisObject()); + if (!ok) { ok = true; break; } + auto *ptr = JSB_MAKE_PRIVATE_OBJECT(cc::geometry::AABB, arg0.value(), arg1.value(), arg2.value(), arg3.value(), arg4.value(), arg5.value()); + s.thisObject()->setPrivateObject(ptr); + return true; + } + } while(false); + SE_REPORT_ERROR("wrong number of arguments: %d", (int)argc); + return false; +} +SE_BIND_CTOR(js_geometry_AABB_constructor, __jsb_cc_geometry_AABB_class, js_cc_geometry_AABB_finalize) + +static bool js_cc_geometry_AABB_finalize(se::State& s) // NOLINT(readability-identifier-naming) +{ + return true; +} +SE_BIND_FINALIZE_FUNC(js_cc_geometry_AABB_finalize) + +bool js_register_geometry_AABB(se::Object* obj) // NOLINT(readability-identifier-naming) +{ + auto* cls = se::Class::create("AABB", obj, __jsb_cc_geometry_ShapeBase_proto, _SE(js_geometry_AABB_constructor)); + + cls->defineProperty("center", _SE(js_geometry_AABB_get_center), _SE(js_geometry_AABB_set_center)); + cls->defineProperty("halfExtents", _SE(js_geometry_AABB_get_halfExtents), _SE(js_geometry_AABB_set_halfExtents)); + cls->defineFunction("contain", _SE(js_geometry_AABB_contain)); + cls->defineStaticFunction("create", _SE(js_geometry_AABB_create_static)); + cls->defineStaticFunction("toBoundingSphere", _SE(js_geometry_AABB_toBoundingSphere_static)); + cls->defineFinalizeFunction(_SE(js_cc_geometry_AABB_finalize)); + cls->install(); + JSBClassType::registerClass(cls); + + __jsb_cc_geometry_AABB_proto = cls->getProto(); + __jsb_cc_geometry_AABB_class = cls; + + + se::ScriptEngine::getInstance()->clearException(); + return true; +} +se::Object* __jsb_cc_geometry_Capsule_proto = nullptr; // NOLINT +se::Class* __jsb_cc_geometry_Capsule_class = nullptr; // NOLINT + +static bool js_geometry_Capsule_transform(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_geometry_Capsule_transform : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 5) { + HolderType arg0 = {}; + HolderType arg1 = {}; + HolderType arg2 = {}; + HolderType arg3 = {}; + HolderType arg4 = {}; + ok &= sevalue_to_native(args[0], &arg0, s.thisObject()); + ok &= sevalue_to_native(args[1], &arg1, s.thisObject()); + ok &= sevalue_to_native(args[2], &arg2, s.thisObject()); + ok &= sevalue_to_native(args[3], &arg3, s.thisObject()); + ok &= sevalue_to_native(args[4], &arg4, s.thisObject()); + SE_PRECONDITION2(ok, false, "js_geometry_Capsule_transform : Error processing arguments"); + cobj->transform(arg0.value(), arg1.value(), arg2.value(), arg3.value(), arg4.value()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 5); + return false; +} +SE_BIND_FUNC(js_geometry_Capsule_transform) + +SE_DECLARE_FINALIZE_FUNC(js_cc_geometry_Capsule_finalize) + +static bool js_geometry_Capsule_constructor(se::State& s) // NOLINT(readability-identifier-naming) constructor_overloaded.c +{ + CC_UNUSED bool ok = true; + const auto& args = s.args(); + size_t argc = args.size(); + do { + if (argc == 1) { + HolderType arg0 = {}; + ok &= sevalue_to_native(args[0], &arg0, s.thisObject()); + if (!ok) { ok = true; break; } + auto *ptr = JSB_MAKE_PRIVATE_OBJECT(cc::geometry::Capsule, arg0.value()); + s.thisObject()->setPrivateObject(ptr); + return true; + } + } while(false); + do { + if (argc == 0) { + auto *ptr = JSB_MAKE_PRIVATE_OBJECT(cc::geometry::Capsule); + s.thisObject()->setPrivateObject(ptr); + return true; + } + } while(false); + do { + if (argc == 1) { + HolderType arg0 = {}; + ok &= sevalue_to_native(args[0], &arg0, s.thisObject()); + if (!ok) { ok = true; break; } + auto *ptr = JSB_MAKE_PRIVATE_OBJECT(cc::geometry::Capsule, arg0.value()); + s.thisObject()->setPrivateObject(ptr); + return true; + } + } while(false); + do { + if (argc == 2) { + HolderType arg0 = {}; + ok &= sevalue_to_native(args[0], &arg0, s.thisObject()); + if (!ok) { ok = true; break; } + HolderType arg1 = {}; + ok &= sevalue_to_native(args[1], &arg1, s.thisObject()); + if (!ok) { ok = true; break; } + auto *ptr = JSB_MAKE_PRIVATE_OBJECT(cc::geometry::Capsule, arg0.value(), arg1.value()); + s.thisObject()->setPrivateObject(ptr); + return true; + } + } while(false); + do { + if (argc == 3) { + HolderType arg0 = {}; + ok &= sevalue_to_native(args[0], &arg0, s.thisObject()); + if (!ok) { ok = true; break; } + HolderType arg1 = {}; + ok &= sevalue_to_native(args[1], &arg1, s.thisObject()); + if (!ok) { ok = true; break; } + HolderType arg2 = {}; + ok &= sevalue_to_native(args[2], &arg2, s.thisObject()); + if (!ok) { ok = true; break; } + auto *ptr = JSB_MAKE_PRIVATE_OBJECT(cc::geometry::Capsule, arg0.value(), arg1.value(), arg2.value()); + s.thisObject()->setPrivateObject(ptr); + return true; + } + } while(false); + SE_REPORT_ERROR("wrong number of arguments: %d", (int)argc); + return false; +} +SE_BIND_CTOR(js_geometry_Capsule_constructor, __jsb_cc_geometry_Capsule_class, js_cc_geometry_Capsule_finalize) + +static bool js_cc_geometry_Capsule_finalize(se::State& s) // NOLINT(readability-identifier-naming) +{ + return true; +} +SE_BIND_FINALIZE_FUNC(js_cc_geometry_Capsule_finalize) + +bool js_register_geometry_Capsule(se::Object* obj) // NOLINT(readability-identifier-naming) +{ + auto* cls = se::Class::create("Capsule", obj, __jsb_cc_geometry_ShapeBase_proto, _SE(js_geometry_Capsule_constructor)); + + cls->defineFunction("transform", _SE(js_geometry_Capsule_transform)); + cls->defineFinalizeFunction(_SE(js_cc_geometry_Capsule_finalize)); + cls->install(); + JSBClassType::registerClass(cls); + + __jsb_cc_geometry_Capsule_proto = cls->getProto(); + __jsb_cc_geometry_Capsule_class = cls; + + + se::ScriptEngine::getInstance()->clearException(); + return true; +} +se::Object* __jsb_cc_geometry_Plane_proto = nullptr; // NOLINT +se::Class* __jsb_cc_geometry_Plane_class = nullptr; // NOLINT + +static bool js_geometry_Plane_define(se::State& s) // NOLINT(readability-identifier-naming) +{ + CC_UNUSED bool ok = true; + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2( cobj, false, "js_geometry_Plane_define : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + do { + if (argc == 2) { + HolderType arg0 = {}; + HolderType arg1 = {}; + + ok &= sevalue_to_native(args[0], &arg0, s.thisObject()); + if (!ok) { ok = true; break; } + ok &= sevalue_to_native(args[1], &arg1, s.thisObject()); + if (!ok) { ok = true; break; } + cobj->define(arg0.value(), arg1.value()); + return true; + } + } while(false); + + do { + if (argc == 3) { + HolderType arg0 = {}; + HolderType arg1 = {}; + HolderType arg2 = {}; + + ok &= sevalue_to_native(args[0], &arg0, s.thisObject()); + if (!ok) { ok = true; break; } + ok &= sevalue_to_native(args[1], &arg1, s.thisObject()); + if (!ok) { ok = true; break; } + ok &= sevalue_to_native(args[2], &arg2, s.thisObject()); + if (!ok) { ok = true; break; } + cobj->define(arg0.value(), arg1.value(), arg2.value()); + return true; + } + } while(false); + + SE_REPORT_ERROR("wrong number of arguments: %d", (int)argc); + return false; +} +SE_BIND_FUNC(js_geometry_Plane_define) + +static bool js_geometry_Plane_distance(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_geometry_Plane_distance : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 1) { + HolderType arg0 = {}; + ok &= sevalue_to_native(args[0], &arg0, s.thisObject()); + SE_PRECONDITION2(ok, false, "js_geometry_Plane_distance : Error processing arguments"); + float result = cobj->distance(arg0.value()); + ok &= nativevalue_to_se(result, s.rval(), nullptr /*ctx*/); + SE_PRECONDITION2(ok, false, "js_geometry_Plane_distance : Error processing arguments"); + SE_HOLD_RETURN_VALUE(result, s.thisObject(), s.rval()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 1); + return false; +} +SE_BIND_FUNC(js_geometry_Plane_distance) + +static bool js_geometry_Plane_getW(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_geometry_Plane_getW : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 0) { + float result = cobj->getW(); + ok &= nativevalue_to_se(result, s.rval(), nullptr /*ctx*/); + SE_PRECONDITION2(ok, false, "js_geometry_Plane_getW : Error processing arguments"); + SE_HOLD_RETURN_VALUE(result, s.thisObject(), s.rval()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 0); + return false; +} +SE_BIND_FUNC(js_geometry_Plane_getW) + +static bool js_geometry_Plane_getX(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_geometry_Plane_getX : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 0) { + float result = cobj->getX(); + ok &= nativevalue_to_se(result, s.rval(), nullptr /*ctx*/); + SE_PRECONDITION2(ok, false, "js_geometry_Plane_getX : Error processing arguments"); + SE_HOLD_RETURN_VALUE(result, s.thisObject(), s.rval()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 0); + return false; +} +SE_BIND_FUNC(js_geometry_Plane_getX) + +static bool js_geometry_Plane_getY(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_geometry_Plane_getY : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 0) { + float result = cobj->getY(); + ok &= nativevalue_to_se(result, s.rval(), nullptr /*ctx*/); + SE_PRECONDITION2(ok, false, "js_geometry_Plane_getY : Error processing arguments"); + SE_HOLD_RETURN_VALUE(result, s.thisObject(), s.rval()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 0); + return false; +} +SE_BIND_FUNC(js_geometry_Plane_getY) + +static bool js_geometry_Plane_getZ(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_geometry_Plane_getZ : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 0) { + float result = cobj->getZ(); + ok &= nativevalue_to_se(result, s.rval(), nullptr /*ctx*/); + SE_PRECONDITION2(ok, false, "js_geometry_Plane_getZ : Error processing arguments"); + SE_HOLD_RETURN_VALUE(result, s.thisObject(), s.rval()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 0); + return false; +} +SE_BIND_FUNC(js_geometry_Plane_getZ) + +static bool js_geometry_Plane_transform(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_geometry_Plane_transform : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 1) { + HolderType arg0 = {}; + ok &= sevalue_to_native(args[0], &arg0, s.thisObject()); + SE_PRECONDITION2(ok, false, "js_geometry_Plane_transform : Error processing arguments"); + cobj->transform(arg0.value()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 1); + return false; +} +SE_BIND_FUNC(js_geometry_Plane_transform) + +static bool js_geometry_Plane_create_static(se::State& s) // NOLINT(readability-identifier-naming) +{ + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 4) { + HolderType arg0 = {}; + HolderType arg1 = {}; + HolderType arg2 = {}; + HolderType arg3 = {}; + ok &= sevalue_to_native(args[0], &arg0, nullptr); + ok &= sevalue_to_native(args[1], &arg1, nullptr); + ok &= sevalue_to_native(args[2], &arg2, nullptr); + ok &= sevalue_to_native(args[3], &arg3, nullptr); + SE_PRECONDITION2(ok, false, "js_geometry_Plane_create_static : Error processing arguments"); + cc::geometry::Plane* result = cc::geometry::Plane::create(arg0.value(), arg1.value(), arg2.value(), arg3.value()); + ok &= nativevalue_to_se(result, s.rval(), nullptr /*ctx*/); + SE_PRECONDITION2(ok, false, "js_geometry_Plane_create_static : Error processing arguments"); + SE_HOLD_RETURN_VALUE(result, s.thisObject(), s.rval()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 4); + return false; +} +SE_BIND_FUNC(js_geometry_Plane_create_static) + +static bool js_geometry_Plane_get_n(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_geometry_Plane_get_n : Invalid Native Object"); + + CC_UNUSED bool ok = true; + se::Value jsret; + ok &= nativevalue_to_se(cobj->n, jsret, s.thisObject() /*ctx*/); + s.rval() = jsret; + SE_HOLD_RETURN_VALUE(cobj->n, s.thisObject(), s.rval()); + return true; +} +SE_BIND_PROP_GET(js_geometry_Plane_get_n) + +static bool js_geometry_Plane_set_n(se::State& s) // NOLINT(readability-identifier-naming) +{ + const auto& args = s.args(); + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_geometry_Plane_set_n : Invalid Native Object"); + + CC_UNUSED bool ok = true; + ok &= sevalue_to_native(args[0], &cobj->n, s.thisObject()); + SE_PRECONDITION2(ok, false, "js_geometry_Plane_set_n : Error processing new value"); + return true; +} +SE_BIND_PROP_SET(js_geometry_Plane_set_n) + +static bool js_geometry_Plane_get_d(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_geometry_Plane_get_d : Invalid Native Object"); + + CC_UNUSED bool ok = true; + se::Value jsret; + ok &= nativevalue_to_se(cobj->d, jsret, s.thisObject() /*ctx*/); + s.rval() = jsret; + SE_HOLD_RETURN_VALUE(cobj->d, s.thisObject(), s.rval()); + return true; +} +SE_BIND_PROP_GET(js_geometry_Plane_get_d) + +static bool js_geometry_Plane_set_d(se::State& s) // NOLINT(readability-identifier-naming) +{ + const auto& args = s.args(); + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_geometry_Plane_set_d : Invalid Native Object"); + + CC_UNUSED bool ok = true; + ok &= sevalue_to_native(args[0], &cobj->d, s.thisObject()); + SE_PRECONDITION2(ok, false, "js_geometry_Plane_set_d : Error processing new value"); + return true; +} +SE_BIND_PROP_SET(js_geometry_Plane_set_d) + +SE_DECLARE_FINALIZE_FUNC(js_cc_geometry_Plane_finalize) + +static bool js_geometry_Plane_constructor(se::State& s) // NOLINT(readability-identifier-naming) constructor_overloaded.c +{ + CC_UNUSED bool ok = true; + const auto& args = s.args(); + size_t argc = args.size(); + do { + if (argc == 0) { + auto *ptr = JSB_MAKE_PRIVATE_OBJECT(cc::geometry::Plane); + s.thisObject()->setPrivateObject(ptr); + return true; + } + } while(false); + do { + if (argc == 4) { + HolderType arg0 = {}; + ok &= sevalue_to_native(args[0], &arg0, s.thisObject()); + if (!ok) { ok = true; break; } + HolderType arg1 = {}; + ok &= sevalue_to_native(args[1], &arg1, s.thisObject()); + if (!ok) { ok = true; break; } + HolderType arg2 = {}; + ok &= sevalue_to_native(args[2], &arg2, s.thisObject()); + if (!ok) { ok = true; break; } + HolderType arg3 = {}; + ok &= sevalue_to_native(args[3], &arg3, s.thisObject()); + if (!ok) { ok = true; break; } + auto *ptr = JSB_MAKE_PRIVATE_OBJECT(cc::geometry::Plane, arg0.value(), arg1.value(), arg2.value(), arg3.value()); + s.thisObject()->setPrivateObject(ptr); + return true; + } + } while(false); + SE_REPORT_ERROR("wrong number of arguments: %d", (int)argc); + return false; +} +SE_BIND_CTOR(js_geometry_Plane_constructor, __jsb_cc_geometry_Plane_class, js_cc_geometry_Plane_finalize) + +static bool js_cc_geometry_Plane_finalize(se::State& s) // NOLINT(readability-identifier-naming) +{ + return true; +} +SE_BIND_FINALIZE_FUNC(js_cc_geometry_Plane_finalize) + +bool js_register_geometry_Plane(se::Object* obj) // NOLINT(readability-identifier-naming) +{ + auto* cls = se::Class::create("Plane", obj, __jsb_cc_geometry_ShapeBase_proto, _SE(js_geometry_Plane_constructor)); + + cls->defineProperty("n", _SE(js_geometry_Plane_get_n), _SE(js_geometry_Plane_set_n)); + cls->defineProperty("d", _SE(js_geometry_Plane_get_d), _SE(js_geometry_Plane_set_d)); + cls->defineFunction("define", _SE(js_geometry_Plane_define)); + cls->defineFunction("distance", _SE(js_geometry_Plane_distance)); + cls->defineFunction("getW", _SE(js_geometry_Plane_getW)); + cls->defineFunction("getX", _SE(js_geometry_Plane_getX)); + cls->defineFunction("getY", _SE(js_geometry_Plane_getY)); + cls->defineFunction("getZ", _SE(js_geometry_Plane_getZ)); + cls->defineFunction("transform", _SE(js_geometry_Plane_transform)); + cls->defineStaticFunction("create", _SE(js_geometry_Plane_create_static)); + cls->defineFinalizeFunction(_SE(js_cc_geometry_Plane_finalize)); + cls->install(); + JSBClassType::registerClass(cls); + + __jsb_cc_geometry_Plane_proto = cls->getProto(); + __jsb_cc_geometry_Plane_class = cls; + + + se::ScriptEngine::getInstance()->clearException(); + return true; +} +se::Object* __jsb_cc_geometry_Frustum_proto = nullptr; // NOLINT +se::Class* __jsb_cc_geometry_Frustum_class = nullptr; // NOLINT + +static bool js_geometry_Frustum_clone(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_geometry_Frustum_clone : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 0) { + cc::geometry::Frustum result = cobj->clone(); + ok &= nativevalue_to_se(result, s.rval(), nullptr /*ctx*/); + SE_PRECONDITION2(ok, false, "js_geometry_Frustum_clone : Error processing arguments"); + SE_HOLD_RETURN_VALUE(result, s.thisObject(), s.rval()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 0); + return false; +} +SE_BIND_FUNC(js_geometry_Frustum_clone) + +static bool js_geometry_Frustum_createOrtho(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_geometry_Frustum_createOrtho : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 5) { + HolderType arg0 = {}; + HolderType arg1 = {}; + HolderType arg2 = {}; + HolderType arg3 = {}; + HolderType arg4 = {}; + ok &= sevalue_to_native(args[0], &arg0, s.thisObject()); + ok &= sevalue_to_native(args[1], &arg1, s.thisObject()); + ok &= sevalue_to_native(args[2], &arg2, s.thisObject()); + ok &= sevalue_to_native(args[3], &arg3, s.thisObject()); + ok &= sevalue_to_native(args[4], &arg4, s.thisObject()); + SE_PRECONDITION2(ok, false, "js_geometry_Frustum_createOrtho : Error processing arguments"); + cobj->createOrtho(arg0.value(), arg1.value(), arg2.value(), arg3.value(), arg4.value()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 5); + return false; +} +SE_BIND_FUNC(js_geometry_Frustum_createOrtho) + +static bool js_geometry_Frustum_setAccurate(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_geometry_Frustum_setAccurate : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 1) { + HolderType arg0 = {}; + ok &= sevalue_to_native(args[0], &arg0, s.thisObject()); + SE_PRECONDITION2(ok, false, "js_geometry_Frustum_setAccurate : Error processing arguments"); + cobj->setAccurate(arg0.value()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 1); + return false; +} +SE_BIND_FUNC(js_geometry_Frustum_setAccurate) + +static bool js_geometry_Frustum_transform(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_geometry_Frustum_transform : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 1) { + HolderType arg0 = {}; + ok &= sevalue_to_native(args[0], &arg0, s.thisObject()); + SE_PRECONDITION2(ok, false, "js_geometry_Frustum_transform : Error processing arguments"); + cobj->transform(arg0.value()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 1); + return false; +} +SE_BIND_FUNC(js_geometry_Frustum_transform) + +static bool js_geometry_Frustum_clone_static(se::State& s) // NOLINT(readability-identifier-naming) +{ + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 1) { + HolderType arg0 = {}; + ok &= sevalue_to_native(args[0], &arg0, nullptr); + SE_PRECONDITION2(ok, false, "js_geometry_Frustum_clone_static : Error processing arguments"); + cc::geometry::Frustum* result = cc::geometry::Frustum::clone(arg0.value()); + ok &= nativevalue_to_se(result, s.rval(), nullptr /*ctx*/); + SE_PRECONDITION2(ok, false, "js_geometry_Frustum_clone_static : Error processing arguments"); + SE_HOLD_RETURN_VALUE(result, s.thisObject(), s.rval()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 1); + return false; +} +SE_BIND_FUNC(js_geometry_Frustum_clone_static) + +static bool js_geometry_Frustum_copy_static(se::State& s) // NOLINT(readability-identifier-naming) +{ + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 2) { + HolderType arg0 = {}; + HolderType arg1 = {}; + ok &= sevalue_to_native(args[0], &arg0, nullptr); + ok &= sevalue_to_native(args[1], &arg1, nullptr); + SE_PRECONDITION2(ok, false, "js_geometry_Frustum_copy_static : Error processing arguments"); + cc::geometry::Frustum* result = cc::geometry::Frustum::copy(arg0.value(), arg1.value()); + ok &= nativevalue_to_se(result, s.rval(), nullptr /*ctx*/); + SE_PRECONDITION2(ok, false, "js_geometry_Frustum_copy_static : Error processing arguments"); + SE_HOLD_RETURN_VALUE(result, s.thisObject(), s.rval()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 2); + return false; +} +SE_BIND_FUNC(js_geometry_Frustum_copy_static) + +static bool js_geometry_Frustum_create_static(se::State& s) // NOLINT(readability-identifier-naming) +{ + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 0) { + cc::geometry::Frustum* result = cc::geometry::Frustum::create(); + ok &= nativevalue_to_se(result, s.rval(), nullptr /*ctx*/); + SE_PRECONDITION2(ok, false, "js_geometry_Frustum_create_static : Error processing arguments"); + SE_HOLD_RETURN_VALUE(result, s.thisObject(), s.rval()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 0); + return false; +} +SE_BIND_FUNC(js_geometry_Frustum_create_static) + +static bool js_geometry_Frustum_createFromAABB_static(se::State& s) // NOLINT(readability-identifier-naming) +{ + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 2) { + HolderType arg0 = {}; + HolderType arg1 = {}; + ok &= sevalue_to_native(args[0], &arg0, nullptr); + ok &= sevalue_to_native(args[1], &arg1, nullptr); + SE_PRECONDITION2(ok, false, "js_geometry_Frustum_createFromAABB_static : Error processing arguments"); + cc::geometry::Frustum* result = cc::geometry::Frustum::createFromAABB(arg0.value(), arg1.value()); + ok &= nativevalue_to_se(result, s.rval(), nullptr /*ctx*/); + SE_PRECONDITION2(ok, false, "js_geometry_Frustum_createFromAABB_static : Error processing arguments"); + SE_HOLD_RETURN_VALUE(result, s.thisObject(), s.rval()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 2); + return false; +} +SE_BIND_FUNC(js_geometry_Frustum_createFromAABB_static) + +static bool js_geometry_Frustum_createOrtho_static(se::State& s) // NOLINT(readability-identifier-naming) +{ + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 6) { + HolderType arg0 = {}; + HolderType arg1 = {}; + HolderType arg2 = {}; + HolderType arg3 = {}; + HolderType arg4 = {}; + HolderType arg5 = {}; + ok &= sevalue_to_native(args[0], &arg0, nullptr); + ok &= sevalue_to_native(args[1], &arg1, nullptr); + ok &= sevalue_to_native(args[2], &arg2, nullptr); + ok &= sevalue_to_native(args[3], &arg3, nullptr); + ok &= sevalue_to_native(args[4], &arg4, nullptr); + ok &= sevalue_to_native(args[5], &arg5, nullptr); + SE_PRECONDITION2(ok, false, "js_geometry_Frustum_createOrtho_static : Error processing arguments"); + cc::geometry::Frustum::createOrtho(arg0.value(), arg1.value(), arg2.value(), arg3.value(), arg4.value(), arg5.value()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 6); + return false; +} +SE_BIND_FUNC(js_geometry_Frustum_createOrtho_static) + +static bool js_geometry_Frustum_get_vertices(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_geometry_Frustum_get_vertices : Invalid Native Object"); + + CC_UNUSED bool ok = true; + se::Value jsret; + ok &= nativevalue_to_se(cobj->vertices, jsret, s.thisObject() /*ctx*/); + s.rval() = jsret; + SE_HOLD_RETURN_VALUE(cobj->vertices, s.thisObject(), s.rval()); + return true; +} +SE_BIND_PROP_GET(js_geometry_Frustum_get_vertices) + +static bool js_geometry_Frustum_set_vertices(se::State& s) // NOLINT(readability-identifier-naming) +{ + const auto& args = s.args(); + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_geometry_Frustum_set_vertices : Invalid Native Object"); + + CC_UNUSED bool ok = true; + ok &= sevalue_to_native(args[0], &cobj->vertices, s.thisObject()); + SE_PRECONDITION2(ok, false, "js_geometry_Frustum_set_vertices : Error processing new value"); + return true; +} +SE_BIND_PROP_SET(js_geometry_Frustum_set_vertices) + +static bool js_geometry_Frustum_get_planes(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_geometry_Frustum_get_planes : Invalid Native Object"); + + CC_UNUSED bool ok = true; + se::Value jsret; + ok &= nativevalue_to_se(cobj->planes, jsret, s.thisObject() /*ctx*/); + s.rval() = jsret; + SE_HOLD_RETURN_VALUE(cobj->planes, s.thisObject(), s.rval()); + return true; +} +SE_BIND_PROP_GET(js_geometry_Frustum_get_planes) + +static bool js_geometry_Frustum_set_planes(se::State& s) // NOLINT(readability-identifier-naming) +{ + const auto& args = s.args(); + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_geometry_Frustum_set_planes : Invalid Native Object"); + + CC_UNUSED bool ok = true; + ok &= sevalue_to_native(args[0], &cobj->planes, s.thisObject()); + SE_PRECONDITION2(ok, false, "js_geometry_Frustum_set_planes : Error processing new value"); + return true; +} +SE_BIND_PROP_SET(js_geometry_Frustum_set_planes) + +SE_DECLARE_FINALIZE_FUNC(js_cc_geometry_Frustum_finalize) + +static bool js_geometry_Frustum_constructor(se::State& s) // NOLINT(readability-identifier-naming) constructor.c +{ + auto *ptr = JSB_MAKE_PRIVATE_OBJECT(cc::geometry::Frustum); + s.thisObject()->setPrivateObject(ptr); + return true; +} +SE_BIND_CTOR(js_geometry_Frustum_constructor, __jsb_cc_geometry_Frustum_class, js_cc_geometry_Frustum_finalize) + +static bool js_cc_geometry_Frustum_finalize(se::State& s) // NOLINT(readability-identifier-naming) +{ + return true; +} +SE_BIND_FINALIZE_FUNC(js_cc_geometry_Frustum_finalize) + +bool js_register_geometry_Frustum(se::Object* obj) // NOLINT(readability-identifier-naming) +{ + auto* cls = se::Class::create("Frustum", obj, __jsb_cc_geometry_ShapeBase_proto, _SE(js_geometry_Frustum_constructor)); + + cls->defineProperty("vertices", _SE(js_geometry_Frustum_get_vertices), _SE(js_geometry_Frustum_set_vertices)); + cls->defineProperty("planes", _SE(js_geometry_Frustum_get_planes), _SE(js_geometry_Frustum_set_planes)); + cls->defineFunction("clone", _SE(js_geometry_Frustum_clone)); + cls->defineFunction("createOrtho", _SE(js_geometry_Frustum_createOrtho)); + cls->defineFunction("setAccurate", _SE(js_geometry_Frustum_setAccurate)); + cls->defineFunction("transform", _SE(js_geometry_Frustum_transform)); + cls->defineStaticFunction("clone", _SE(js_geometry_Frustum_clone_static)); + cls->defineStaticFunction("copy", _SE(js_geometry_Frustum_copy_static)); + cls->defineStaticFunction("create", _SE(js_geometry_Frustum_create_static)); + cls->defineStaticFunction("createFromAABB", _SE(js_geometry_Frustum_createFromAABB_static)); + cls->defineStaticFunction("createOrtho", _SE(js_geometry_Frustum_createOrtho_static)); + cls->defineFinalizeFunction(_SE(js_cc_geometry_Frustum_finalize)); + cls->install(); + JSBClassType::registerClass(cls); + + __jsb_cc_geometry_Frustum_proto = cls->getProto(); + __jsb_cc_geometry_Frustum_class = cls; + + + se::ScriptEngine::getInstance()->clearException(); + return true; +} +se::Object* __jsb_cc_geometry_Line_proto = nullptr; // NOLINT +se::Class* __jsb_cc_geometry_Line_class = nullptr; // NOLINT + +static bool js_geometry_Line_length(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_geometry_Line_length : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 0) { + float result = cobj->length(); + ok &= nativevalue_to_se(result, s.rval(), nullptr /*ctx*/); + SE_PRECONDITION2(ok, false, "js_geometry_Line_length : Error processing arguments"); + SE_HOLD_RETURN_VALUE(result, s.thisObject(), s.rval()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 0); + return false; +} +SE_BIND_FUNC(js_geometry_Line_length) + +static bool js_geometry_Line_clone_static(se::State& s) // NOLINT(readability-identifier-naming) +{ + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 1) { + HolderType arg0 = {}; + ok &= sevalue_to_native(args[0], &arg0, nullptr); + SE_PRECONDITION2(ok, false, "js_geometry_Line_clone_static : Error processing arguments"); + cc::geometry::Line* result = cc::geometry::Line::clone(arg0.value()); + ok &= nativevalue_to_se(result, s.rval(), nullptr /*ctx*/); + SE_PRECONDITION2(ok, false, "js_geometry_Line_clone_static : Error processing arguments"); + SE_HOLD_RETURN_VALUE(result, s.thisObject(), s.rval()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 1); + return false; +} +SE_BIND_FUNC(js_geometry_Line_clone_static) + +static bool js_geometry_Line_copy_static(se::State& s) // NOLINT(readability-identifier-naming) +{ + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 2) { + HolderType arg0 = {}; + HolderType arg1 = {}; + ok &= sevalue_to_native(args[0], &arg0, nullptr); + ok &= sevalue_to_native(args[1], &arg1, nullptr); + SE_PRECONDITION2(ok, false, "js_geometry_Line_copy_static : Error processing arguments"); + cc::geometry::Line* result = cc::geometry::Line::copy(arg0.value(), arg1.value()); + ok &= nativevalue_to_se(result, s.rval(), nullptr /*ctx*/); + SE_PRECONDITION2(ok, false, "js_geometry_Line_copy_static : Error processing arguments"); + SE_HOLD_RETURN_VALUE(result, s.thisObject(), s.rval()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 2); + return false; +} +SE_BIND_FUNC(js_geometry_Line_copy_static) + +static bool js_geometry_Line_create_static(se::State& s) // NOLINT(readability-identifier-naming) +{ + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 6) { + HolderType arg0 = {}; + HolderType arg1 = {}; + HolderType arg2 = {}; + HolderType arg3 = {}; + HolderType arg4 = {}; + HolderType arg5 = {}; + ok &= sevalue_to_native(args[0], &arg0, nullptr); + ok &= sevalue_to_native(args[1], &arg1, nullptr); + ok &= sevalue_to_native(args[2], &arg2, nullptr); + ok &= sevalue_to_native(args[3], &arg3, nullptr); + ok &= sevalue_to_native(args[4], &arg4, nullptr); + ok &= sevalue_to_native(args[5], &arg5, nullptr); + SE_PRECONDITION2(ok, false, "js_geometry_Line_create_static : Error processing arguments"); + cc::geometry::Line* result = cc::geometry::Line::create(arg0.value(), arg1.value(), arg2.value(), arg3.value(), arg4.value(), arg5.value()); + ok &= nativevalue_to_se(result, s.rval(), nullptr /*ctx*/); + SE_PRECONDITION2(ok, false, "js_geometry_Line_create_static : Error processing arguments"); + SE_HOLD_RETURN_VALUE(result, s.thisObject(), s.rval()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 6); + return false; +} +SE_BIND_FUNC(js_geometry_Line_create_static) + +static bool js_geometry_Line_fromPoints_static(se::State& s) // NOLINT(readability-identifier-naming) +{ + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 3) { + HolderType arg0 = {}; + HolderType arg1 = {}; + HolderType arg2 = {}; + ok &= sevalue_to_native(args[0], &arg0, nullptr); + ok &= sevalue_to_native(args[1], &arg1, nullptr); + ok &= sevalue_to_native(args[2], &arg2, nullptr); + SE_PRECONDITION2(ok, false, "js_geometry_Line_fromPoints_static : Error processing arguments"); + cc::geometry::Line* result = cc::geometry::Line::fromPoints(arg0.value(), arg1.value(), arg2.value()); + ok &= nativevalue_to_se(result, s.rval(), nullptr /*ctx*/); + SE_PRECONDITION2(ok, false, "js_geometry_Line_fromPoints_static : Error processing arguments"); + SE_HOLD_RETURN_VALUE(result, s.thisObject(), s.rval()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 3); + return false; +} +SE_BIND_FUNC(js_geometry_Line_fromPoints_static) + +static bool js_geometry_Line_len_static(se::State& s) // NOLINT(readability-identifier-naming) +{ + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 1) { + HolderType arg0 = {}; + ok &= sevalue_to_native(args[0], &arg0, nullptr); + SE_PRECONDITION2(ok, false, "js_geometry_Line_len_static : Error processing arguments"); + float result = cc::geometry::Line::len(arg0.value()); + ok &= nativevalue_to_se(result, s.rval(), nullptr /*ctx*/); + SE_PRECONDITION2(ok, false, "js_geometry_Line_len_static : Error processing arguments"); + SE_HOLD_RETURN_VALUE(result, s.thisObject(), s.rval()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 1); + return false; +} +SE_BIND_FUNC(js_geometry_Line_len_static) + +static bool js_geometry_Line_set_static(se::State& s) // NOLINT(readability-identifier-naming) +{ + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 7) { + HolderType arg0 = {}; + HolderType arg1 = {}; + HolderType arg2 = {}; + HolderType arg3 = {}; + HolderType arg4 = {}; + HolderType arg5 = {}; + HolderType arg6 = {}; + ok &= sevalue_to_native(args[0], &arg0, nullptr); + ok &= sevalue_to_native(args[1], &arg1, nullptr); + ok &= sevalue_to_native(args[2], &arg2, nullptr); + ok &= sevalue_to_native(args[3], &arg3, nullptr); + ok &= sevalue_to_native(args[4], &arg4, nullptr); + ok &= sevalue_to_native(args[5], &arg5, nullptr); + ok &= sevalue_to_native(args[6], &arg6, nullptr); + SE_PRECONDITION2(ok, false, "js_geometry_Line_set_static : Error processing arguments"); + cc::geometry::Line* result = cc::geometry::Line::set(arg0.value(), arg1.value(), arg2.value(), arg3.value(), arg4.value(), arg5.value(), arg6.value()); + ok &= nativevalue_to_se(result, s.rval(), nullptr /*ctx*/); + SE_PRECONDITION2(ok, false, "js_geometry_Line_set_static : Error processing arguments"); + SE_HOLD_RETURN_VALUE(result, s.thisObject(), s.rval()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 7); + return false; +} +SE_BIND_FUNC(js_geometry_Line_set_static) + +SE_DECLARE_FINALIZE_FUNC(js_cc_geometry_Line_finalize) + +static bool js_geometry_Line_constructor(se::State& s) // NOLINT(readability-identifier-naming) constructor_overloaded.c +{ + CC_UNUSED bool ok = true; + const auto& args = s.args(); + size_t argc = args.size(); + do { + if (argc == 1) { + HolderType arg0 = {}; + ok &= sevalue_to_native(args[0], &arg0, s.thisObject()); + if (!ok) { ok = true; break; } + auto *ptr = JSB_MAKE_PRIVATE_OBJECT(cc::geometry::Line, arg0.value()); + s.thisObject()->setPrivateObject(ptr); + return true; + } + } while(false); + do { + if (argc == 0) { + auto *ptr = JSB_MAKE_PRIVATE_OBJECT(cc::geometry::Line); + s.thisObject()->setPrivateObject(ptr); + return true; + } + } while(false); + do { + if (argc == 1) { + HolderType arg0 = {}; + ok &= sevalue_to_native(args[0], &arg0, s.thisObject()); + if (!ok) { ok = true; break; } + auto *ptr = JSB_MAKE_PRIVATE_OBJECT(cc::geometry::Line, arg0.value()); + s.thisObject()->setPrivateObject(ptr); + return true; + } + } while(false); + do { + if (argc == 2) { + HolderType arg0 = {}; + ok &= sevalue_to_native(args[0], &arg0, s.thisObject()); + if (!ok) { ok = true; break; } + HolderType arg1 = {}; + ok &= sevalue_to_native(args[1], &arg1, s.thisObject()); + if (!ok) { ok = true; break; } + auto *ptr = JSB_MAKE_PRIVATE_OBJECT(cc::geometry::Line, arg0.value(), arg1.value()); + s.thisObject()->setPrivateObject(ptr); + return true; + } + } while(false); + do { + if (argc == 3) { + HolderType arg0 = {}; + ok &= sevalue_to_native(args[0], &arg0, s.thisObject()); + if (!ok) { ok = true; break; } + HolderType arg1 = {}; + ok &= sevalue_to_native(args[1], &arg1, s.thisObject()); + if (!ok) { ok = true; break; } + HolderType arg2 = {}; + ok &= sevalue_to_native(args[2], &arg2, s.thisObject()); + if (!ok) { ok = true; break; } + auto *ptr = JSB_MAKE_PRIVATE_OBJECT(cc::geometry::Line, arg0.value(), arg1.value(), arg2.value()); + s.thisObject()->setPrivateObject(ptr); + return true; + } + } while(false); + do { + if (argc == 4) { + HolderType arg0 = {}; + ok &= sevalue_to_native(args[0], &arg0, s.thisObject()); + if (!ok) { ok = true; break; } + HolderType arg1 = {}; + ok &= sevalue_to_native(args[1], &arg1, s.thisObject()); + if (!ok) { ok = true; break; } + HolderType arg2 = {}; + ok &= sevalue_to_native(args[2], &arg2, s.thisObject()); + if (!ok) { ok = true; break; } + HolderType arg3 = {}; + ok &= sevalue_to_native(args[3], &arg3, s.thisObject()); + if (!ok) { ok = true; break; } + auto *ptr = JSB_MAKE_PRIVATE_OBJECT(cc::geometry::Line, arg0.value(), arg1.value(), arg2.value(), arg3.value()); + s.thisObject()->setPrivateObject(ptr); + return true; + } + } while(false); + do { + if (argc == 5) { + HolderType arg0 = {}; + ok &= sevalue_to_native(args[0], &arg0, s.thisObject()); + if (!ok) { ok = true; break; } + HolderType arg1 = {}; + ok &= sevalue_to_native(args[1], &arg1, s.thisObject()); + if (!ok) { ok = true; break; } + HolderType arg2 = {}; + ok &= sevalue_to_native(args[2], &arg2, s.thisObject()); + if (!ok) { ok = true; break; } + HolderType arg3 = {}; + ok &= sevalue_to_native(args[3], &arg3, s.thisObject()); + if (!ok) { ok = true; break; } + HolderType arg4 = {}; + ok &= sevalue_to_native(args[4], &arg4, s.thisObject()); + if (!ok) { ok = true; break; } + auto *ptr = JSB_MAKE_PRIVATE_OBJECT(cc::geometry::Line, arg0.value(), arg1.value(), arg2.value(), arg3.value(), arg4.value()); + s.thisObject()->setPrivateObject(ptr); + return true; + } + } while(false); + do { + if (argc == 6) { + HolderType arg0 = {}; + ok &= sevalue_to_native(args[0], &arg0, s.thisObject()); + if (!ok) { ok = true; break; } + HolderType arg1 = {}; + ok &= sevalue_to_native(args[1], &arg1, s.thisObject()); + if (!ok) { ok = true; break; } + HolderType arg2 = {}; + ok &= sevalue_to_native(args[2], &arg2, s.thisObject()); + if (!ok) { ok = true; break; } + HolderType arg3 = {}; + ok &= sevalue_to_native(args[3], &arg3, s.thisObject()); + if (!ok) { ok = true; break; } + HolderType arg4 = {}; + ok &= sevalue_to_native(args[4], &arg4, s.thisObject()); + if (!ok) { ok = true; break; } + HolderType arg5 = {}; + ok &= sevalue_to_native(args[5], &arg5, s.thisObject()); + if (!ok) { ok = true; break; } + auto *ptr = JSB_MAKE_PRIVATE_OBJECT(cc::geometry::Line, arg0.value(), arg1.value(), arg2.value(), arg3.value(), arg4.value(), arg5.value()); + s.thisObject()->setPrivateObject(ptr); + return true; + } + } while(false); + SE_REPORT_ERROR("wrong number of arguments: %d", (int)argc); + return false; +} +SE_BIND_CTOR(js_geometry_Line_constructor, __jsb_cc_geometry_Line_class, js_cc_geometry_Line_finalize) + +static bool js_cc_geometry_Line_finalize(se::State& s) // NOLINT(readability-identifier-naming) +{ + return true; +} +SE_BIND_FINALIZE_FUNC(js_cc_geometry_Line_finalize) + +bool js_register_geometry_Line(se::Object* obj) // NOLINT(readability-identifier-naming) +{ + auto* cls = se::Class::create("Line", obj, __jsb_cc_geometry_ShapeBase_proto, _SE(js_geometry_Line_constructor)); + + cls->defineFunction("length", _SE(js_geometry_Line_length)); + cls->defineStaticFunction("clone", _SE(js_geometry_Line_clone_static)); + cls->defineStaticFunction("copy", _SE(js_geometry_Line_copy_static)); + cls->defineStaticFunction("create", _SE(js_geometry_Line_create_static)); + cls->defineStaticFunction("fromPoints", _SE(js_geometry_Line_fromPoints_static)); + cls->defineStaticFunction("len", _SE(js_geometry_Line_len_static)); + cls->defineStaticFunction("set", _SE(js_geometry_Line_set_static)); + cls->defineFinalizeFunction(_SE(js_cc_geometry_Line_finalize)); + cls->install(); + JSBClassType::registerClass(cls); + + __jsb_cc_geometry_Line_proto = cls->getProto(); + __jsb_cc_geometry_Line_class = cls; + + + se::ScriptEngine::getInstance()->clearException(); + return true; +} +se::Object* __jsb_cc_geometry_Ray_proto = nullptr; // NOLINT +se::Class* __jsb_cc_geometry_Ray_class = nullptr; // NOLINT + +static bool js_geometry_Ray_clone_static(se::State& s) // NOLINT(readability-identifier-naming) +{ + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 1) { + HolderType arg0 = {}; + ok &= sevalue_to_native(args[0], &arg0, nullptr); + SE_PRECONDITION2(ok, false, "js_geometry_Ray_clone_static : Error processing arguments"); + cc::geometry::Ray* result = cc::geometry::Ray::clone(arg0.value()); + ok &= nativevalue_to_se(result, s.rval(), nullptr /*ctx*/); + SE_PRECONDITION2(ok, false, "js_geometry_Ray_clone_static : Error processing arguments"); + SE_HOLD_RETURN_VALUE(result, s.thisObject(), s.rval()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 1); + return false; +} +SE_BIND_FUNC(js_geometry_Ray_clone_static) + +static bool js_geometry_Ray_copy_static(se::State& s) // NOLINT(readability-identifier-naming) +{ + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 2) { + HolderType arg0 = {}; + HolderType arg1 = {}; + ok &= sevalue_to_native(args[0], &arg0, nullptr); + ok &= sevalue_to_native(args[1], &arg1, nullptr); + SE_PRECONDITION2(ok, false, "js_geometry_Ray_copy_static : Error processing arguments"); + cc::geometry::Ray* result = cc::geometry::Ray::copy(arg0.value(), arg1.value()); + ok &= nativevalue_to_se(result, s.rval(), nullptr /*ctx*/); + SE_PRECONDITION2(ok, false, "js_geometry_Ray_copy_static : Error processing arguments"); + SE_HOLD_RETURN_VALUE(result, s.thisObject(), s.rval()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 2); + return false; +} +SE_BIND_FUNC(js_geometry_Ray_copy_static) + +static bool js_geometry_Ray_create_static(se::State& s) // NOLINT(readability-identifier-naming) +{ + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 0) { + cc::geometry::Ray* result = cc::geometry::Ray::create(); + ok &= nativevalue_to_se(result, s.rval(), nullptr /*ctx*/); + SE_PRECONDITION2(ok, false, "js_geometry_Ray_create_static : Error processing arguments"); + SE_HOLD_RETURN_VALUE(result, s.thisObject(), s.rval()); + return true; + } + if (argc == 1) { + HolderType arg0 = {}; + ok &= sevalue_to_native(args[0], &arg0, nullptr); + SE_PRECONDITION2(ok, false, "js_geometry_Ray_create_static : Error processing arguments"); + cc::geometry::Ray* result = cc::geometry::Ray::create(arg0.value()); + ok &= nativevalue_to_se(result, s.rval(), nullptr /*ctx*/); + SE_PRECONDITION2(ok, false, "js_geometry_Ray_create_static : Error processing arguments"); + SE_HOLD_RETURN_VALUE(result, s.thisObject(), s.rval()); + return true; + } + if (argc == 2) { + HolderType arg0 = {}; + HolderType arg1 = {}; + ok &= sevalue_to_native(args[0], &arg0, nullptr); + ok &= sevalue_to_native(args[1], &arg1, nullptr); + SE_PRECONDITION2(ok, false, "js_geometry_Ray_create_static : Error processing arguments"); + cc::geometry::Ray* result = cc::geometry::Ray::create(arg0.value(), arg1.value()); + ok &= nativevalue_to_se(result, s.rval(), nullptr /*ctx*/); + SE_PRECONDITION2(ok, false, "js_geometry_Ray_create_static : Error processing arguments"); + SE_HOLD_RETURN_VALUE(result, s.thisObject(), s.rval()); + return true; + } + if (argc == 3) { + HolderType arg0 = {}; + HolderType arg1 = {}; + HolderType arg2 = {}; + ok &= sevalue_to_native(args[0], &arg0, nullptr); + ok &= sevalue_to_native(args[1], &arg1, nullptr); + ok &= sevalue_to_native(args[2], &arg2, nullptr); + SE_PRECONDITION2(ok, false, "js_geometry_Ray_create_static : Error processing arguments"); + cc::geometry::Ray* result = cc::geometry::Ray::create(arg0.value(), arg1.value(), arg2.value()); + ok &= nativevalue_to_se(result, s.rval(), nullptr /*ctx*/); + SE_PRECONDITION2(ok, false, "js_geometry_Ray_create_static : Error processing arguments"); + SE_HOLD_RETURN_VALUE(result, s.thisObject(), s.rval()); + return true; + } + if (argc == 4) { + HolderType arg0 = {}; + HolderType arg1 = {}; + HolderType arg2 = {}; + HolderType arg3 = {}; + ok &= sevalue_to_native(args[0], &arg0, nullptr); + ok &= sevalue_to_native(args[1], &arg1, nullptr); + ok &= sevalue_to_native(args[2], &arg2, nullptr); + ok &= sevalue_to_native(args[3], &arg3, nullptr); + SE_PRECONDITION2(ok, false, "js_geometry_Ray_create_static : Error processing arguments"); + cc::geometry::Ray* result = cc::geometry::Ray::create(arg0.value(), arg1.value(), arg2.value(), arg3.value()); + ok &= nativevalue_to_se(result, s.rval(), nullptr /*ctx*/); + SE_PRECONDITION2(ok, false, "js_geometry_Ray_create_static : Error processing arguments"); + SE_HOLD_RETURN_VALUE(result, s.thisObject(), s.rval()); + return true; + } + if (argc == 5) { + HolderType arg0 = {}; + HolderType arg1 = {}; + HolderType arg2 = {}; + HolderType arg3 = {}; + HolderType arg4 = {}; + ok &= sevalue_to_native(args[0], &arg0, nullptr); + ok &= sevalue_to_native(args[1], &arg1, nullptr); + ok &= sevalue_to_native(args[2], &arg2, nullptr); + ok &= sevalue_to_native(args[3], &arg3, nullptr); + ok &= sevalue_to_native(args[4], &arg4, nullptr); + SE_PRECONDITION2(ok, false, "js_geometry_Ray_create_static : Error processing arguments"); + cc::geometry::Ray* result = cc::geometry::Ray::create(arg0.value(), arg1.value(), arg2.value(), arg3.value(), arg4.value()); + ok &= nativevalue_to_se(result, s.rval(), nullptr /*ctx*/); + SE_PRECONDITION2(ok, false, "js_geometry_Ray_create_static : Error processing arguments"); + SE_HOLD_RETURN_VALUE(result, s.thisObject(), s.rval()); + return true; + } + if (argc == 6) { + HolderType arg0 = {}; + HolderType arg1 = {}; + HolderType arg2 = {}; + HolderType arg3 = {}; + HolderType arg4 = {}; + HolderType arg5 = {}; + ok &= sevalue_to_native(args[0], &arg0, nullptr); + ok &= sevalue_to_native(args[1], &arg1, nullptr); + ok &= sevalue_to_native(args[2], &arg2, nullptr); + ok &= sevalue_to_native(args[3], &arg3, nullptr); + ok &= sevalue_to_native(args[4], &arg4, nullptr); + ok &= sevalue_to_native(args[5], &arg5, nullptr); + SE_PRECONDITION2(ok, false, "js_geometry_Ray_create_static : Error processing arguments"); + cc::geometry::Ray* result = cc::geometry::Ray::create(arg0.value(), arg1.value(), arg2.value(), arg3.value(), arg4.value(), arg5.value()); + ok &= nativevalue_to_se(result, s.rval(), nullptr /*ctx*/); + SE_PRECONDITION2(ok, false, "js_geometry_Ray_create_static : Error processing arguments"); + SE_HOLD_RETURN_VALUE(result, s.thisObject(), s.rval()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 6); + return false; +} +SE_BIND_FUNC(js_geometry_Ray_create_static) + +static bool js_geometry_Ray_fromPoints_static(se::State& s) // NOLINT(readability-identifier-naming) +{ + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 3) { + HolderType arg0 = {}; + HolderType arg1 = {}; + HolderType arg2 = {}; + ok &= sevalue_to_native(args[0], &arg0, nullptr); + ok &= sevalue_to_native(args[1], &arg1, nullptr); + ok &= sevalue_to_native(args[2], &arg2, nullptr); + SE_PRECONDITION2(ok, false, "js_geometry_Ray_fromPoints_static : Error processing arguments"); + cc::geometry::Ray* result = cc::geometry::Ray::fromPoints(arg0.value(), arg1.value(), arg2.value()); + ok &= nativevalue_to_se(result, s.rval(), nullptr /*ctx*/); + SE_PRECONDITION2(ok, false, "js_geometry_Ray_fromPoints_static : Error processing arguments"); + SE_HOLD_RETURN_VALUE(result, s.thisObject(), s.rval()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 3); + return false; +} +SE_BIND_FUNC(js_geometry_Ray_fromPoints_static) + +static bool js_geometry_Ray_set_static(se::State& s) // NOLINT(readability-identifier-naming) +{ + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 7) { + HolderType arg0 = {}; + HolderType arg1 = {}; + HolderType arg2 = {}; + HolderType arg3 = {}; + HolderType arg4 = {}; + HolderType arg5 = {}; + HolderType arg6 = {}; + ok &= sevalue_to_native(args[0], &arg0, nullptr); + ok &= sevalue_to_native(args[1], &arg1, nullptr); + ok &= sevalue_to_native(args[2], &arg2, nullptr); + ok &= sevalue_to_native(args[3], &arg3, nullptr); + ok &= sevalue_to_native(args[4], &arg4, nullptr); + ok &= sevalue_to_native(args[5], &arg5, nullptr); + ok &= sevalue_to_native(args[6], &arg6, nullptr); + SE_PRECONDITION2(ok, false, "js_geometry_Ray_set_static : Error processing arguments"); + cc::geometry::Ray* result = cc::geometry::Ray::set(arg0.value(), arg1.value(), arg2.value(), arg3.value(), arg4.value(), arg5.value(), arg6.value()); + ok &= nativevalue_to_se(result, s.rval(), nullptr /*ctx*/); + SE_PRECONDITION2(ok, false, "js_geometry_Ray_set_static : Error processing arguments"); + SE_HOLD_RETURN_VALUE(result, s.thisObject(), s.rval()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 7); + return false; +} +SE_BIND_FUNC(js_geometry_Ray_set_static) + +SE_DECLARE_FINALIZE_FUNC(js_cc_geometry_Ray_finalize) + +static bool js_geometry_Ray_constructor(se::State& s) // NOLINT(readability-identifier-naming) constructor_overloaded.c +{ + CC_UNUSED bool ok = true; + const auto& args = s.args(); + size_t argc = args.size(); + do { + if (argc == 1) { + HolderType arg0 = {}; + ok &= sevalue_to_native(args[0], &arg0, s.thisObject()); + if (!ok) { ok = true; break; } + auto *ptr = JSB_MAKE_PRIVATE_OBJECT(cc::geometry::Ray, arg0.value()); + s.thisObject()->setPrivateObject(ptr); + return true; + } + } while(false); + do { + if (argc == 0) { + auto *ptr = JSB_MAKE_PRIVATE_OBJECT(cc::geometry::Ray); + s.thisObject()->setPrivateObject(ptr); + return true; + } + } while(false); + do { + if (argc == 1) { + HolderType arg0 = {}; + ok &= sevalue_to_native(args[0], &arg0, s.thisObject()); + if (!ok) { ok = true; break; } + auto *ptr = JSB_MAKE_PRIVATE_OBJECT(cc::geometry::Ray, arg0.value()); + s.thisObject()->setPrivateObject(ptr); + return true; + } + } while(false); + do { + if (argc == 2) { + HolderType arg0 = {}; + ok &= sevalue_to_native(args[0], &arg0, s.thisObject()); + if (!ok) { ok = true; break; } + HolderType arg1 = {}; + ok &= sevalue_to_native(args[1], &arg1, s.thisObject()); + if (!ok) { ok = true; break; } + auto *ptr = JSB_MAKE_PRIVATE_OBJECT(cc::geometry::Ray, arg0.value(), arg1.value()); + s.thisObject()->setPrivateObject(ptr); + return true; + } + } while(false); + do { + if (argc == 3) { + HolderType arg0 = {}; + ok &= sevalue_to_native(args[0], &arg0, s.thisObject()); + if (!ok) { ok = true; break; } + HolderType arg1 = {}; + ok &= sevalue_to_native(args[1], &arg1, s.thisObject()); + if (!ok) { ok = true; break; } + HolderType arg2 = {}; + ok &= sevalue_to_native(args[2], &arg2, s.thisObject()); + if (!ok) { ok = true; break; } + auto *ptr = JSB_MAKE_PRIVATE_OBJECT(cc::geometry::Ray, arg0.value(), arg1.value(), arg2.value()); + s.thisObject()->setPrivateObject(ptr); + return true; + } + } while(false); + do { + if (argc == 4) { + HolderType arg0 = {}; + ok &= sevalue_to_native(args[0], &arg0, s.thisObject()); + if (!ok) { ok = true; break; } + HolderType arg1 = {}; + ok &= sevalue_to_native(args[1], &arg1, s.thisObject()); + if (!ok) { ok = true; break; } + HolderType arg2 = {}; + ok &= sevalue_to_native(args[2], &arg2, s.thisObject()); + if (!ok) { ok = true; break; } + HolderType arg3 = {}; + ok &= sevalue_to_native(args[3], &arg3, s.thisObject()); + if (!ok) { ok = true; break; } + auto *ptr = JSB_MAKE_PRIVATE_OBJECT(cc::geometry::Ray, arg0.value(), arg1.value(), arg2.value(), arg3.value()); + s.thisObject()->setPrivateObject(ptr); + return true; + } + } while(false); + do { + if (argc == 5) { + HolderType arg0 = {}; + ok &= sevalue_to_native(args[0], &arg0, s.thisObject()); + if (!ok) { ok = true; break; } + HolderType arg1 = {}; + ok &= sevalue_to_native(args[1], &arg1, s.thisObject()); + if (!ok) { ok = true; break; } + HolderType arg2 = {}; + ok &= sevalue_to_native(args[2], &arg2, s.thisObject()); + if (!ok) { ok = true; break; } + HolderType arg3 = {}; + ok &= sevalue_to_native(args[3], &arg3, s.thisObject()); + if (!ok) { ok = true; break; } + HolderType arg4 = {}; + ok &= sevalue_to_native(args[4], &arg4, s.thisObject()); + if (!ok) { ok = true; break; } + auto *ptr = JSB_MAKE_PRIVATE_OBJECT(cc::geometry::Ray, arg0.value(), arg1.value(), arg2.value(), arg3.value(), arg4.value()); + s.thisObject()->setPrivateObject(ptr); + return true; + } + } while(false); + do { + if (argc == 6) { + HolderType arg0 = {}; + ok &= sevalue_to_native(args[0], &arg0, s.thisObject()); + if (!ok) { ok = true; break; } + HolderType arg1 = {}; + ok &= sevalue_to_native(args[1], &arg1, s.thisObject()); + if (!ok) { ok = true; break; } + HolderType arg2 = {}; + ok &= sevalue_to_native(args[2], &arg2, s.thisObject()); + if (!ok) { ok = true; break; } + HolderType arg3 = {}; + ok &= sevalue_to_native(args[3], &arg3, s.thisObject()); + if (!ok) { ok = true; break; } + HolderType arg4 = {}; + ok &= sevalue_to_native(args[4], &arg4, s.thisObject()); + if (!ok) { ok = true; break; } + HolderType arg5 = {}; + ok &= sevalue_to_native(args[5], &arg5, s.thisObject()); + if (!ok) { ok = true; break; } + auto *ptr = JSB_MAKE_PRIVATE_OBJECT(cc::geometry::Ray, arg0.value(), arg1.value(), arg2.value(), arg3.value(), arg4.value(), arg5.value()); + s.thisObject()->setPrivateObject(ptr); + return true; + } + } while(false); + SE_REPORT_ERROR("wrong number of arguments: %d", (int)argc); + return false; +} +SE_BIND_CTOR(js_geometry_Ray_constructor, __jsb_cc_geometry_Ray_class, js_cc_geometry_Ray_finalize) + +static bool js_cc_geometry_Ray_finalize(se::State& s) // NOLINT(readability-identifier-naming) +{ + return true; +} +SE_BIND_FINALIZE_FUNC(js_cc_geometry_Ray_finalize) + +bool js_register_geometry_Ray(se::Object* obj) // NOLINT(readability-identifier-naming) +{ + auto* cls = se::Class::create("Ray", obj, __jsb_cc_geometry_ShapeBase_proto, _SE(js_geometry_Ray_constructor)); + + cls->defineStaticFunction("clone", _SE(js_geometry_Ray_clone_static)); + cls->defineStaticFunction("copy", _SE(js_geometry_Ray_copy_static)); + cls->defineStaticFunction("create", _SE(js_geometry_Ray_create_static)); + cls->defineStaticFunction("fromPoints", _SE(js_geometry_Ray_fromPoints_static)); + cls->defineStaticFunction("set", _SE(js_geometry_Ray_set_static)); + cls->defineFinalizeFunction(_SE(js_cc_geometry_Ray_finalize)); + cls->install(); + JSBClassType::registerClass(cls); + + __jsb_cc_geometry_Ray_proto = cls->getProto(); + __jsb_cc_geometry_Ray_class = cls; + + + se::ScriptEngine::getInstance()->clearException(); + return true; +} +se::Object* __jsb_cc_geometry_Sphere_proto = nullptr; // NOLINT +se::Class* __jsb_cc_geometry_Sphere_class = nullptr; // NOLINT + +static bool js_geometry_Sphere_clone(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_geometry_Sphere_clone : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 0) { + cc::geometry::Sphere* result = cobj->clone(); + ok &= nativevalue_to_se(result, s.rval(), nullptr /*ctx*/); + SE_PRECONDITION2(ok, false, "js_geometry_Sphere_clone : Error processing arguments"); + SE_HOLD_RETURN_VALUE(result, s.thisObject(), s.rval()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 0); + return false; +} +SE_BIND_FUNC(js_geometry_Sphere_clone) + +static bool js_geometry_Sphere_copy(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_geometry_Sphere_copy : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 1) { + HolderType arg0 = {}; + ok &= sevalue_to_native(args[0], &arg0, s.thisObject()); + SE_PRECONDITION2(ok, false, "js_geometry_Sphere_copy : Error processing arguments"); + cc::geometry::Sphere* result = cobj->copy(arg0.value()); + ok &= nativevalue_to_se(result, s.rval(), nullptr /*ctx*/); + SE_PRECONDITION2(ok, false, "js_geometry_Sphere_copy : Error processing arguments"); + SE_HOLD_RETURN_VALUE(result, s.thisObject(), s.rval()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 1); + return false; +} +SE_BIND_FUNC(js_geometry_Sphere_copy) + +static bool js_geometry_Sphere_define(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_geometry_Sphere_define : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 1) { + HolderType arg0 = {}; + ok &= sevalue_to_native(args[0], &arg0, s.thisObject()); + SE_PRECONDITION2(ok, false, "js_geometry_Sphere_define : Error processing arguments"); + cobj->define(arg0.value()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 1); + return false; +} +SE_BIND_FUNC(js_geometry_Sphere_define) + +static bool js_geometry_Sphere_getCenter(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_geometry_Sphere_getCenter : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 0) { + const cc::Vec3& result = cobj->getCenter(); + ok &= nativevalue_to_se(result, s.rval(), nullptr /*ctx*/); + SE_PRECONDITION2(ok, false, "js_geometry_Sphere_getCenter : Error processing arguments"); + SE_HOLD_RETURN_VALUE(result, s.thisObject(), s.rval()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 0); + return false; +} +SE_BIND_FUNC(js_geometry_Sphere_getCenter) + +static bool js_geometry_Sphere_getRadius(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_geometry_Sphere_getRadius : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 0) { + float result = cobj->getRadius(); + ok &= nativevalue_to_se(result, s.rval(), nullptr /*ctx*/); + SE_PRECONDITION2(ok, false, "js_geometry_Sphere_getRadius : Error processing arguments"); + SE_HOLD_RETURN_VALUE(result, s.thisObject(), s.rval()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 0); + return false; +} +SE_BIND_FUNC(js_geometry_Sphere_getRadius) + +static bool js_geometry_Sphere_interset(se::State& s) // NOLINT(readability-identifier-naming) +{ + CC_UNUSED bool ok = true; + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2( cobj, false, "js_geometry_Sphere_interset : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + do { + if (argc == 1) { + HolderType arg0 = {}; + + ok &= sevalue_to_native(args[0], &arg0, s.thisObject()); + if (!ok) { ok = true; break; } + int result = cobj->interset(arg0.value()); + ok &= nativevalue_to_se(result, s.rval(), s.thisObject() /*ctx*/); + SE_PRECONDITION2(ok, false, "js_geometry_Sphere_interset : Error processing arguments"); + SE_HOLD_RETURN_VALUE(result, s.thisObject(), s.rval()); + return true; + } + } while(false); + + do { + if (argc == 1) { + HolderType arg0 = {}; + + ok &= sevalue_to_native(args[0], &arg0, s.thisObject()); + if (!ok) { ok = true; break; } + bool result = cobj->interset(arg0.value()); + ok &= nativevalue_to_se(result, s.rval(), s.thisObject() /*ctx*/); + SE_PRECONDITION2(ok, false, "js_geometry_Sphere_interset : Error processing arguments"); + SE_HOLD_RETURN_VALUE(result, s.thisObject(), s.rval()); + return true; + } + } while(false); + + SE_REPORT_ERROR("wrong number of arguments: %d", (int)argc); + return false; +} +SE_BIND_FUNC(js_geometry_Sphere_interset) + +static bool js_geometry_Sphere_merge(se::State& s) // NOLINT(readability-identifier-naming) +{ + CC_UNUSED bool ok = true; + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2( cobj, false, "js_geometry_Sphere_merge : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + do { + if (argc == 1) { + HolderType arg0 = {}; + + ok &= sevalue_to_native(args[0], &arg0, s.thisObject()); + if (!ok) { ok = true; break; } + cobj->merge(arg0.value()); + return true; + } + } while(false); + + do { + if (argc == 1) { + HolderType arg0 = {}; + + ok &= sevalue_to_native(args[0], &arg0, s.thisObject()); + if (!ok) { ok = true; break; } + cobj->merge(arg0.value()); + return true; + } + } while(false); + + do { + if (argc == 1) { + HolderType, true> arg0 = {}; + + ok &= sevalue_to_native(args[0], &arg0, s.thisObject()); + if (!ok) { ok = true; break; } + cobj->merge(arg0.value()); + return true; + } + } while(false); + + do { + if (argc == 1) { + HolderType arg0 = {}; + + ok &= sevalue_to_native(args[0], &arg0, s.thisObject()); + if (!ok) { ok = true; break; } + cobj->merge(arg0.value()); + return true; + } + } while(false); + + SE_REPORT_ERROR("wrong number of arguments: %d", (int)argc); + return false; +} +SE_BIND_FUNC(js_geometry_Sphere_merge) + +static bool js_geometry_Sphere_mergeAABB(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_geometry_Sphere_mergeAABB : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 1) { + HolderType arg0 = {}; + ok &= sevalue_to_native(args[0], &arg0, s.thisObject()); + SE_PRECONDITION2(ok, false, "js_geometry_Sphere_mergeAABB : Error processing arguments"); + cobj->mergeAABB(arg0.value()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 1); + return false; +} +SE_BIND_FUNC(js_geometry_Sphere_mergeAABB) + +static bool js_geometry_Sphere_mergeFrustum(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_geometry_Sphere_mergeFrustum : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 1) { + HolderType arg0 = {}; + ok &= sevalue_to_native(args[0], &arg0, s.thisObject()); + SE_PRECONDITION2(ok, false, "js_geometry_Sphere_mergeFrustum : Error processing arguments"); + cobj->mergeFrustum(arg0.value()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 1); + return false; +} +SE_BIND_FUNC(js_geometry_Sphere_mergeFrustum) + +static bool js_geometry_Sphere_mergePoint(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_geometry_Sphere_mergePoint : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 1) { + HolderType arg0 = {}; + ok &= sevalue_to_native(args[0], &arg0, s.thisObject()); + SE_PRECONDITION2(ok, false, "js_geometry_Sphere_mergePoint : Error processing arguments"); + cobj->mergePoint(arg0.value()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 1); + return false; +} +SE_BIND_FUNC(js_geometry_Sphere_mergePoint) + +static bool js_geometry_Sphere_setCenter(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_geometry_Sphere_setCenter : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 1) { + HolderType arg0 = {}; + ok &= sevalue_to_native(args[0], &arg0, s.thisObject()); + SE_PRECONDITION2(ok, false, "js_geometry_Sphere_setCenter : Error processing arguments"); + cobj->setCenter(arg0.value()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 1); + return false; +} +SE_BIND_FUNC(js_geometry_Sphere_setCenter) + +static bool js_geometry_Sphere_setRadius(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_geometry_Sphere_setRadius : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 1) { + HolderType arg0 = {}; + ok &= sevalue_to_native(args[0], &arg0, s.thisObject()); + SE_PRECONDITION2(ok, false, "js_geometry_Sphere_setRadius : Error processing arguments"); + cobj->setRadius(arg0.value()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 1); + return false; +} +SE_BIND_FUNC(js_geometry_Sphere_setRadius) + +static bool js_geometry_Sphere_setScale(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_geometry_Sphere_setScale : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 2) { + HolderType arg0 = {}; + HolderType arg1 = {}; + ok &= sevalue_to_native(args[0], &arg0, s.thisObject()); + ok &= sevalue_to_native(args[1], &arg1, s.thisObject()); + SE_PRECONDITION2(ok, false, "js_geometry_Sphere_setScale : Error processing arguments"); + cobj->setScale(arg0.value(), arg1.value()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 2); + return false; +} +SE_BIND_FUNC(js_geometry_Sphere_setScale) + +static bool js_geometry_Sphere_sphereFrustum(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_geometry_Sphere_sphereFrustum : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 1) { + HolderType arg0 = {}; + ok &= sevalue_to_native(args[0], &arg0, s.thisObject()); + SE_PRECONDITION2(ok, false, "js_geometry_Sphere_sphereFrustum : Error processing arguments"); + bool result = cobj->sphereFrustum(arg0.value()); + ok &= nativevalue_to_se(result, s.rval(), nullptr /*ctx*/); + SE_PRECONDITION2(ok, false, "js_geometry_Sphere_sphereFrustum : Error processing arguments"); + SE_HOLD_RETURN_VALUE(result, s.thisObject(), s.rval()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 1); + return false; +} +SE_BIND_FUNC(js_geometry_Sphere_sphereFrustum) + +static bool js_geometry_Sphere_spherePlane(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_geometry_Sphere_spherePlane : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 1) { + HolderType arg0 = {}; + ok &= sevalue_to_native(args[0], &arg0, s.thisObject()); + SE_PRECONDITION2(ok, false, "js_geometry_Sphere_spherePlane : Error processing arguments"); + int result = cobj->spherePlane(arg0.value()); + ok &= nativevalue_to_se(result, s.rval(), nullptr /*ctx*/); + SE_PRECONDITION2(ok, false, "js_geometry_Sphere_spherePlane : Error processing arguments"); + SE_HOLD_RETURN_VALUE(result, s.thisObject(), s.rval()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 1); + return false; +} +SE_BIND_FUNC(js_geometry_Sphere_spherePlane) + +static bool js_geometry_Sphere_transform(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_geometry_Sphere_transform : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 5) { + HolderType arg0 = {}; + HolderType arg1 = {}; + HolderType arg2 = {}; + HolderType arg3 = {}; + HolderType arg4 = {}; + ok &= sevalue_to_native(args[0], &arg0, s.thisObject()); + ok &= sevalue_to_native(args[1], &arg1, s.thisObject()); + ok &= sevalue_to_native(args[2], &arg2, s.thisObject()); + ok &= sevalue_to_native(args[3], &arg3, s.thisObject()); + ok &= sevalue_to_native(args[4], &arg4, s.thisObject()); + SE_PRECONDITION2(ok, false, "js_geometry_Sphere_transform : Error processing arguments"); + cobj->transform(arg0.value(), arg1.value(), arg2.value(), arg3.value(), arg4.value()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 5); + return false; +} +SE_BIND_FUNC(js_geometry_Sphere_transform) + +static bool js_geometry_Sphere_translateAndRotate(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_geometry_Sphere_translateAndRotate : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 3) { + HolderType arg0 = {}; + HolderType arg1 = {}; + HolderType arg2 = {}; + ok &= sevalue_to_native(args[0], &arg0, s.thisObject()); + ok &= sevalue_to_native(args[1], &arg1, s.thisObject()); + ok &= sevalue_to_native(args[2], &arg2, s.thisObject()); + SE_PRECONDITION2(ok, false, "js_geometry_Sphere_translateAndRotate : Error processing arguments"); + cobj->translateAndRotate(arg0.value(), arg1.value(), arg2.value()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 3); + return false; +} +SE_BIND_FUNC(js_geometry_Sphere_translateAndRotate) + +static bool js_geometry_Sphere_clone_static(se::State& s) // NOLINT(readability-identifier-naming) +{ + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 1) { + HolderType arg0 = {}; + ok &= sevalue_to_native(args[0], &arg0, nullptr); + SE_PRECONDITION2(ok, false, "js_geometry_Sphere_clone_static : Error processing arguments"); + cc::geometry::Sphere* result = cc::geometry::Sphere::clone(arg0.value()); + ok &= nativevalue_to_se(result, s.rval(), nullptr /*ctx*/); + SE_PRECONDITION2(ok, false, "js_geometry_Sphere_clone_static : Error processing arguments"); + SE_HOLD_RETURN_VALUE(result, s.thisObject(), s.rval()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 1); + return false; +} +SE_BIND_FUNC(js_geometry_Sphere_clone_static) + +static bool js_geometry_Sphere_copy_static(se::State& s) // NOLINT(readability-identifier-naming) +{ + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 2) { + HolderType arg0 = {}; + HolderType arg1 = {}; + ok &= sevalue_to_native(args[0], &arg0, nullptr); + ok &= sevalue_to_native(args[1], &arg1, nullptr); + SE_PRECONDITION2(ok, false, "js_geometry_Sphere_copy_static : Error processing arguments"); + cc::geometry::Sphere* result = cc::geometry::Sphere::copy(arg0.value(), arg1.value()); + ok &= nativevalue_to_se(result, s.rval(), nullptr /*ctx*/); + SE_PRECONDITION2(ok, false, "js_geometry_Sphere_copy_static : Error processing arguments"); + SE_HOLD_RETURN_VALUE(result, s.thisObject(), s.rval()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 2); + return false; +} +SE_BIND_FUNC(js_geometry_Sphere_copy_static) + +static bool js_geometry_Sphere_create_static(se::State& s) // NOLINT(readability-identifier-naming) +{ + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 4) { + HolderType arg0 = {}; + HolderType arg1 = {}; + HolderType arg2 = {}; + HolderType arg3 = {}; + ok &= sevalue_to_native(args[0], &arg0, nullptr); + ok &= sevalue_to_native(args[1], &arg1, nullptr); + ok &= sevalue_to_native(args[2], &arg2, nullptr); + ok &= sevalue_to_native(args[3], &arg3, nullptr); + SE_PRECONDITION2(ok, false, "js_geometry_Sphere_create_static : Error processing arguments"); + cc::geometry::Sphere* result = cc::geometry::Sphere::create(arg0.value(), arg1.value(), arg2.value(), arg3.value()); + ok &= nativevalue_to_se(result, s.rval(), nullptr /*ctx*/); + SE_PRECONDITION2(ok, false, "js_geometry_Sphere_create_static : Error processing arguments"); + SE_HOLD_RETURN_VALUE(result, s.thisObject(), s.rval()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 4); + return false; +} +SE_BIND_FUNC(js_geometry_Sphere_create_static) + +static bool js_geometry_Sphere_fromPoints_static(se::State& s) // NOLINT(readability-identifier-naming) +{ + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 3) { + HolderType arg0 = {}; + HolderType arg1 = {}; + HolderType arg2 = {}; + ok &= sevalue_to_native(args[0], &arg0, nullptr); + ok &= sevalue_to_native(args[1], &arg1, nullptr); + ok &= sevalue_to_native(args[2], &arg2, nullptr); + SE_PRECONDITION2(ok, false, "js_geometry_Sphere_fromPoints_static : Error processing arguments"); + cc::geometry::Sphere* result = cc::geometry::Sphere::fromPoints(arg0.value(), arg1.value(), arg2.value()); + ok &= nativevalue_to_se(result, s.rval(), nullptr /*ctx*/); + SE_PRECONDITION2(ok, false, "js_geometry_Sphere_fromPoints_static : Error processing arguments"); + SE_HOLD_RETURN_VALUE(result, s.thisObject(), s.rval()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 3); + return false; +} +SE_BIND_FUNC(js_geometry_Sphere_fromPoints_static) + +static bool js_geometry_Sphere_mergeAABB_static(se::State& s) // NOLINT(readability-identifier-naming) +{ + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 3) { + HolderType arg0 = {}; + HolderType arg1 = {}; + HolderType arg2 = {}; + ok &= sevalue_to_native(args[0], &arg0, nullptr); + ok &= sevalue_to_native(args[1], &arg1, nullptr); + ok &= sevalue_to_native(args[2], &arg2, nullptr); + SE_PRECONDITION2(ok, false, "js_geometry_Sphere_mergeAABB_static : Error processing arguments"); + cc::geometry::Sphere* result = cc::geometry::Sphere::mergeAABB(arg0.value(), arg1.value(), arg2.value()); + ok &= nativevalue_to_se(result, s.rval(), nullptr /*ctx*/); + SE_PRECONDITION2(ok, false, "js_geometry_Sphere_mergeAABB_static : Error processing arguments"); + SE_HOLD_RETURN_VALUE(result, s.thisObject(), s.rval()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 3); + return false; +} +SE_BIND_FUNC(js_geometry_Sphere_mergeAABB_static) + +static bool js_geometry_Sphere_mergePoint_static(se::State& s) // NOLINT(readability-identifier-naming) +{ + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 3) { + HolderType arg0 = {}; + HolderType arg1 = {}; + HolderType arg2 = {}; + ok &= sevalue_to_native(args[0], &arg0, nullptr); + ok &= sevalue_to_native(args[1], &arg1, nullptr); + ok &= sevalue_to_native(args[2], &arg2, nullptr); + SE_PRECONDITION2(ok, false, "js_geometry_Sphere_mergePoint_static : Error processing arguments"); + cc::geometry::Sphere* result = cc::geometry::Sphere::mergePoint(arg0.value(), arg1.value(), arg2.value()); + ok &= nativevalue_to_se(result, s.rval(), nullptr /*ctx*/); + SE_PRECONDITION2(ok, false, "js_geometry_Sphere_mergePoint_static : Error processing arguments"); + SE_HOLD_RETURN_VALUE(result, s.thisObject(), s.rval()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 3); + return false; +} +SE_BIND_FUNC(js_geometry_Sphere_mergePoint_static) + +static bool js_geometry_Sphere_set_static(se::State& s) // NOLINT(readability-identifier-naming) +{ + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 5) { + HolderType arg0 = {}; + HolderType arg1 = {}; + HolderType arg2 = {}; + HolderType arg3 = {}; + HolderType arg4 = {}; + ok &= sevalue_to_native(args[0], &arg0, nullptr); + ok &= sevalue_to_native(args[1], &arg1, nullptr); + ok &= sevalue_to_native(args[2], &arg2, nullptr); + ok &= sevalue_to_native(args[3], &arg3, nullptr); + ok &= sevalue_to_native(args[4], &arg4, nullptr); + SE_PRECONDITION2(ok, false, "js_geometry_Sphere_set_static : Error processing arguments"); + cc::geometry::Sphere* result = cc::geometry::Sphere::set(arg0.value(), arg1.value(), arg2.value(), arg3.value(), arg4.value()); + ok &= nativevalue_to_se(result, s.rval(), nullptr /*ctx*/); + SE_PRECONDITION2(ok, false, "js_geometry_Sphere_set_static : Error processing arguments"); + SE_HOLD_RETURN_VALUE(result, s.thisObject(), s.rval()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 5); + return false; +} +SE_BIND_FUNC(js_geometry_Sphere_set_static) + +SE_DECLARE_FINALIZE_FUNC(js_cc_geometry_Sphere_finalize) + +static bool js_geometry_Sphere_constructor(se::State& s) // NOLINT(readability-identifier-naming) constructor.c +{ + auto *ptr = JSB_MAKE_PRIVATE_OBJECT(cc::geometry::Sphere); + s.thisObject()->setPrivateObject(ptr); + return true; +} +SE_BIND_CTOR(js_geometry_Sphere_constructor, __jsb_cc_geometry_Sphere_class, js_cc_geometry_Sphere_finalize) + +static bool js_cc_geometry_Sphere_finalize(se::State& s) // NOLINT(readability-identifier-naming) +{ + return true; +} +SE_BIND_FINALIZE_FUNC(js_cc_geometry_Sphere_finalize) + +bool js_register_geometry_Sphere(se::Object* obj) // NOLINT(readability-identifier-naming) +{ + auto* cls = se::Class::create("Sphere", obj, __jsb_cc_geometry_ShapeBase_proto, _SE(js_geometry_Sphere_constructor)); + + cls->defineFunction("clone", _SE(js_geometry_Sphere_clone)); + cls->defineFunction("copy", _SE(js_geometry_Sphere_copy)); + cls->defineFunction("define", _SE(js_geometry_Sphere_define)); + cls->defineFunction("getCenter", _SE(js_geometry_Sphere_getCenter)); + cls->defineFunction("getRadius", _SE(js_geometry_Sphere_getRadius)); + cls->defineFunction("interset", _SE(js_geometry_Sphere_interset)); + cls->defineFunction("merge", _SE(js_geometry_Sphere_merge)); + cls->defineFunction("mergeAABB", _SE(js_geometry_Sphere_mergeAABB)); + cls->defineFunction("mergeFrustum", _SE(js_geometry_Sphere_mergeFrustum)); + cls->defineFunction("mergePoint", _SE(js_geometry_Sphere_mergePoint)); + cls->defineFunction("setCenter", _SE(js_geometry_Sphere_setCenter)); + cls->defineFunction("setRadius", _SE(js_geometry_Sphere_setRadius)); + cls->defineFunction("setScale", _SE(js_geometry_Sphere_setScale)); + cls->defineFunction("sphereFrustum", _SE(js_geometry_Sphere_sphereFrustum)); + cls->defineFunction("spherePlane", _SE(js_geometry_Sphere_spherePlane)); + cls->defineFunction("transform", _SE(js_geometry_Sphere_transform)); + cls->defineFunction("translateAndRotate", _SE(js_geometry_Sphere_translateAndRotate)); + cls->defineStaticFunction("clone", _SE(js_geometry_Sphere_clone_static)); + cls->defineStaticFunction("copy", _SE(js_geometry_Sphere_copy_static)); + cls->defineStaticFunction("create", _SE(js_geometry_Sphere_create_static)); + cls->defineStaticFunction("fromPoints", _SE(js_geometry_Sphere_fromPoints_static)); + cls->defineStaticFunction("mergeAABB", _SE(js_geometry_Sphere_mergeAABB_static)); + cls->defineStaticFunction("mergePoint", _SE(js_geometry_Sphere_mergePoint_static)); + cls->defineStaticFunction("set", _SE(js_geometry_Sphere_set_static)); + cls->defineFinalizeFunction(_SE(js_cc_geometry_Sphere_finalize)); + cls->install(); + JSBClassType::registerClass(cls); + + __jsb_cc_geometry_Sphere_proto = cls->getProto(); + __jsb_cc_geometry_Sphere_class = cls; + + + se::ScriptEngine::getInstance()->clearException(); + return true; +} +se::Object* __jsb_cc_geometry_Triangle_proto = nullptr; // NOLINT +se::Class* __jsb_cc_geometry_Triangle_class = nullptr; // NOLINT + +static bool js_geometry_Triangle_clone_static(se::State& s) // NOLINT(readability-identifier-naming) +{ + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 1) { + HolderType arg0 = {}; + ok &= sevalue_to_native(args[0], &arg0, nullptr); + SE_PRECONDITION2(ok, false, "js_geometry_Triangle_clone_static : Error processing arguments"); + cc::geometry::Triangle* result = cc::geometry::Triangle::clone(arg0.value()); + ok &= nativevalue_to_se(result, s.rval(), nullptr /*ctx*/); + SE_PRECONDITION2(ok, false, "js_geometry_Triangle_clone_static : Error processing arguments"); + SE_HOLD_RETURN_VALUE(result, s.thisObject(), s.rval()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 1); + return false; +} +SE_BIND_FUNC(js_geometry_Triangle_clone_static) + +static bool js_geometry_Triangle_copy_static(se::State& s) // NOLINT(readability-identifier-naming) +{ + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 2) { + HolderType arg0 = {}; + HolderType arg1 = {}; + ok &= sevalue_to_native(args[0], &arg0, nullptr); + ok &= sevalue_to_native(args[1], &arg1, nullptr); + SE_PRECONDITION2(ok, false, "js_geometry_Triangle_copy_static : Error processing arguments"); + cc::geometry::Triangle* result = cc::geometry::Triangle::copy(arg0.value(), arg1.value()); + ok &= nativevalue_to_se(result, s.rval(), nullptr /*ctx*/); + SE_PRECONDITION2(ok, false, "js_geometry_Triangle_copy_static : Error processing arguments"); + SE_HOLD_RETURN_VALUE(result, s.thisObject(), s.rval()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 2); + return false; +} +SE_BIND_FUNC(js_geometry_Triangle_copy_static) + +static bool js_geometry_Triangle_create_static(se::State& s) // NOLINT(readability-identifier-naming) +{ + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 0) { + cc::geometry::Triangle* result = cc::geometry::Triangle::create(); + ok &= nativevalue_to_se(result, s.rval(), nullptr /*ctx*/); + SE_PRECONDITION2(ok, false, "js_geometry_Triangle_create_static : Error processing arguments"); + SE_HOLD_RETURN_VALUE(result, s.thisObject(), s.rval()); + return true; + } + if (argc == 1) { + HolderType arg0 = {}; + ok &= sevalue_to_native(args[0], &arg0, nullptr); + SE_PRECONDITION2(ok, false, "js_geometry_Triangle_create_static : Error processing arguments"); + cc::geometry::Triangle* result = cc::geometry::Triangle::create(arg0.value()); + ok &= nativevalue_to_se(result, s.rval(), nullptr /*ctx*/); + SE_PRECONDITION2(ok, false, "js_geometry_Triangle_create_static : Error processing arguments"); + SE_HOLD_RETURN_VALUE(result, s.thisObject(), s.rval()); + return true; + } + if (argc == 2) { + HolderType arg0 = {}; + HolderType arg1 = {}; + ok &= sevalue_to_native(args[0], &arg0, nullptr); + ok &= sevalue_to_native(args[1], &arg1, nullptr); + SE_PRECONDITION2(ok, false, "js_geometry_Triangle_create_static : Error processing arguments"); + cc::geometry::Triangle* result = cc::geometry::Triangle::create(arg0.value(), arg1.value()); + ok &= nativevalue_to_se(result, s.rval(), nullptr /*ctx*/); + SE_PRECONDITION2(ok, false, "js_geometry_Triangle_create_static : Error processing arguments"); + SE_HOLD_RETURN_VALUE(result, s.thisObject(), s.rval()); + return true; + } + if (argc == 3) { + HolderType arg0 = {}; + HolderType arg1 = {}; + HolderType arg2 = {}; + ok &= sevalue_to_native(args[0], &arg0, nullptr); + ok &= sevalue_to_native(args[1], &arg1, nullptr); + ok &= sevalue_to_native(args[2], &arg2, nullptr); + SE_PRECONDITION2(ok, false, "js_geometry_Triangle_create_static : Error processing arguments"); + cc::geometry::Triangle* result = cc::geometry::Triangle::create(arg0.value(), arg1.value(), arg2.value()); + ok &= nativevalue_to_se(result, s.rval(), nullptr /*ctx*/); + SE_PRECONDITION2(ok, false, "js_geometry_Triangle_create_static : Error processing arguments"); + SE_HOLD_RETURN_VALUE(result, s.thisObject(), s.rval()); + return true; + } + if (argc == 4) { + HolderType arg0 = {}; + HolderType arg1 = {}; + HolderType arg2 = {}; + HolderType arg3 = {}; + ok &= sevalue_to_native(args[0], &arg0, nullptr); + ok &= sevalue_to_native(args[1], &arg1, nullptr); + ok &= sevalue_to_native(args[2], &arg2, nullptr); + ok &= sevalue_to_native(args[3], &arg3, nullptr); + SE_PRECONDITION2(ok, false, "js_geometry_Triangle_create_static : Error processing arguments"); + cc::geometry::Triangle* result = cc::geometry::Triangle::create(arg0.value(), arg1.value(), arg2.value(), arg3.value()); + ok &= nativevalue_to_se(result, s.rval(), nullptr /*ctx*/); + SE_PRECONDITION2(ok, false, "js_geometry_Triangle_create_static : Error processing arguments"); + SE_HOLD_RETURN_VALUE(result, s.thisObject(), s.rval()); + return true; + } + if (argc == 5) { + HolderType arg0 = {}; + HolderType arg1 = {}; + HolderType arg2 = {}; + HolderType arg3 = {}; + HolderType arg4 = {}; + ok &= sevalue_to_native(args[0], &arg0, nullptr); + ok &= sevalue_to_native(args[1], &arg1, nullptr); + ok &= sevalue_to_native(args[2], &arg2, nullptr); + ok &= sevalue_to_native(args[3], &arg3, nullptr); + ok &= sevalue_to_native(args[4], &arg4, nullptr); + SE_PRECONDITION2(ok, false, "js_geometry_Triangle_create_static : Error processing arguments"); + cc::geometry::Triangle* result = cc::geometry::Triangle::create(arg0.value(), arg1.value(), arg2.value(), arg3.value(), arg4.value()); + ok &= nativevalue_to_se(result, s.rval(), nullptr /*ctx*/); + SE_PRECONDITION2(ok, false, "js_geometry_Triangle_create_static : Error processing arguments"); + SE_HOLD_RETURN_VALUE(result, s.thisObject(), s.rval()); + return true; + } + if (argc == 6) { + HolderType arg0 = {}; + HolderType arg1 = {}; + HolderType arg2 = {}; + HolderType arg3 = {}; + HolderType arg4 = {}; + HolderType arg5 = {}; + ok &= sevalue_to_native(args[0], &arg0, nullptr); + ok &= sevalue_to_native(args[1], &arg1, nullptr); + ok &= sevalue_to_native(args[2], &arg2, nullptr); + ok &= sevalue_to_native(args[3], &arg3, nullptr); + ok &= sevalue_to_native(args[4], &arg4, nullptr); + ok &= sevalue_to_native(args[5], &arg5, nullptr); + SE_PRECONDITION2(ok, false, "js_geometry_Triangle_create_static : Error processing arguments"); + cc::geometry::Triangle* result = cc::geometry::Triangle::create(arg0.value(), arg1.value(), arg2.value(), arg3.value(), arg4.value(), arg5.value()); + ok &= nativevalue_to_se(result, s.rval(), nullptr /*ctx*/); + SE_PRECONDITION2(ok, false, "js_geometry_Triangle_create_static : Error processing arguments"); + SE_HOLD_RETURN_VALUE(result, s.thisObject(), s.rval()); + return true; + } + if (argc == 7) { + HolderType arg0 = {}; + HolderType arg1 = {}; + HolderType arg2 = {}; + HolderType arg3 = {}; + HolderType arg4 = {}; + HolderType arg5 = {}; + HolderType arg6 = {}; + ok &= sevalue_to_native(args[0], &arg0, nullptr); + ok &= sevalue_to_native(args[1], &arg1, nullptr); + ok &= sevalue_to_native(args[2], &arg2, nullptr); + ok &= sevalue_to_native(args[3], &arg3, nullptr); + ok &= sevalue_to_native(args[4], &arg4, nullptr); + ok &= sevalue_to_native(args[5], &arg5, nullptr); + ok &= sevalue_to_native(args[6], &arg6, nullptr); + SE_PRECONDITION2(ok, false, "js_geometry_Triangle_create_static : Error processing arguments"); + cc::geometry::Triangle* result = cc::geometry::Triangle::create(arg0.value(), arg1.value(), arg2.value(), arg3.value(), arg4.value(), arg5.value(), arg6.value()); + ok &= nativevalue_to_se(result, s.rval(), nullptr /*ctx*/); + SE_PRECONDITION2(ok, false, "js_geometry_Triangle_create_static : Error processing arguments"); + SE_HOLD_RETURN_VALUE(result, s.thisObject(), s.rval()); + return true; + } + if (argc == 8) { + HolderType arg0 = {}; + HolderType arg1 = {}; + HolderType arg2 = {}; + HolderType arg3 = {}; + HolderType arg4 = {}; + HolderType arg5 = {}; + HolderType arg6 = {}; + HolderType arg7 = {}; + ok &= sevalue_to_native(args[0], &arg0, nullptr); + ok &= sevalue_to_native(args[1], &arg1, nullptr); + ok &= sevalue_to_native(args[2], &arg2, nullptr); + ok &= sevalue_to_native(args[3], &arg3, nullptr); + ok &= sevalue_to_native(args[4], &arg4, nullptr); + ok &= sevalue_to_native(args[5], &arg5, nullptr); + ok &= sevalue_to_native(args[6], &arg6, nullptr); + ok &= sevalue_to_native(args[7], &arg7, nullptr); + SE_PRECONDITION2(ok, false, "js_geometry_Triangle_create_static : Error processing arguments"); + cc::geometry::Triangle* result = cc::geometry::Triangle::create(arg0.value(), arg1.value(), arg2.value(), arg3.value(), arg4.value(), arg5.value(), arg6.value(), arg7.value()); + ok &= nativevalue_to_se(result, s.rval(), nullptr /*ctx*/); + SE_PRECONDITION2(ok, false, "js_geometry_Triangle_create_static : Error processing arguments"); + SE_HOLD_RETURN_VALUE(result, s.thisObject(), s.rval()); + return true; + } + if (argc == 9) { + HolderType arg0 = {}; + HolderType arg1 = {}; + HolderType arg2 = {}; + HolderType arg3 = {}; + HolderType arg4 = {}; + HolderType arg5 = {}; + HolderType arg6 = {}; + HolderType arg7 = {}; + HolderType arg8 = {}; + ok &= sevalue_to_native(args[0], &arg0, nullptr); + ok &= sevalue_to_native(args[1], &arg1, nullptr); + ok &= sevalue_to_native(args[2], &arg2, nullptr); + ok &= sevalue_to_native(args[3], &arg3, nullptr); + ok &= sevalue_to_native(args[4], &arg4, nullptr); + ok &= sevalue_to_native(args[5], &arg5, nullptr); + ok &= sevalue_to_native(args[6], &arg6, nullptr); + ok &= sevalue_to_native(args[7], &arg7, nullptr); + ok &= sevalue_to_native(args[8], &arg8, nullptr); + SE_PRECONDITION2(ok, false, "js_geometry_Triangle_create_static : Error processing arguments"); + cc::geometry::Triangle* result = cc::geometry::Triangle::create(arg0.value(), arg1.value(), arg2.value(), arg3.value(), arg4.value(), arg5.value(), arg6.value(), arg7.value(), arg8.value()); + ok &= nativevalue_to_se(result, s.rval(), nullptr /*ctx*/); + SE_PRECONDITION2(ok, false, "js_geometry_Triangle_create_static : Error processing arguments"); + SE_HOLD_RETURN_VALUE(result, s.thisObject(), s.rval()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 9); + return false; +} +SE_BIND_FUNC(js_geometry_Triangle_create_static) + +static bool js_geometry_Triangle_fromPoints_static(se::State& s) // NOLINT(readability-identifier-naming) +{ + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 4) { + HolderType arg0 = {}; + HolderType arg1 = {}; + HolderType arg2 = {}; + HolderType arg3 = {}; + ok &= sevalue_to_native(args[0], &arg0, nullptr); + ok &= sevalue_to_native(args[1], &arg1, nullptr); + ok &= sevalue_to_native(args[2], &arg2, nullptr); + ok &= sevalue_to_native(args[3], &arg3, nullptr); + SE_PRECONDITION2(ok, false, "js_geometry_Triangle_fromPoints_static : Error processing arguments"); + cc::geometry::Triangle* result = cc::geometry::Triangle::fromPoints(arg0.value(), arg1.value(), arg2.value(), arg3.value()); + ok &= nativevalue_to_se(result, s.rval(), nullptr /*ctx*/); + SE_PRECONDITION2(ok, false, "js_geometry_Triangle_fromPoints_static : Error processing arguments"); + SE_HOLD_RETURN_VALUE(result, s.thisObject(), s.rval()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 4); + return false; +} +SE_BIND_FUNC(js_geometry_Triangle_fromPoints_static) + +static bool js_geometry_Triangle_set_static(se::State& s) // NOLINT(readability-identifier-naming) +{ + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 10) { + HolderType arg0 = {}; + HolderType arg1 = {}; + HolderType arg2 = {}; + HolderType arg3 = {}; + HolderType arg4 = {}; + HolderType arg5 = {}; + HolderType arg6 = {}; + HolderType arg7 = {}; + HolderType arg8 = {}; + HolderType arg9 = {}; + ok &= sevalue_to_native(args[0], &arg0, nullptr); + ok &= sevalue_to_native(args[1], &arg1, nullptr); + ok &= sevalue_to_native(args[2], &arg2, nullptr); + ok &= sevalue_to_native(args[3], &arg3, nullptr); + ok &= sevalue_to_native(args[4], &arg4, nullptr); + ok &= sevalue_to_native(args[5], &arg5, nullptr); + ok &= sevalue_to_native(args[6], &arg6, nullptr); + ok &= sevalue_to_native(args[7], &arg7, nullptr); + ok &= sevalue_to_native(args[8], &arg8, nullptr); + ok &= sevalue_to_native(args[9], &arg9, nullptr); + SE_PRECONDITION2(ok, false, "js_geometry_Triangle_set_static : Error processing arguments"); + cc::geometry::Triangle* result = cc::geometry::Triangle::set(arg0.value(), arg1.value(), arg2.value(), arg3.value(), arg4.value(), arg5.value(), arg6.value(), arg7.value(), arg8.value(), arg9.value()); + ok &= nativevalue_to_se(result, s.rval(), nullptr /*ctx*/); + SE_PRECONDITION2(ok, false, "js_geometry_Triangle_set_static : Error processing arguments"); + SE_HOLD_RETURN_VALUE(result, s.thisObject(), s.rval()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 10); + return false; +} +SE_BIND_FUNC(js_geometry_Triangle_set_static) + +SE_DECLARE_FINALIZE_FUNC(js_cc_geometry_Triangle_finalize) + +static bool js_geometry_Triangle_constructor(se::State& s) // NOLINT(readability-identifier-naming) constructor_overloaded.c +{ + CC_UNUSED bool ok = true; + const auto& args = s.args(); + size_t argc = args.size(); + do { + if (argc == 1) { + HolderType arg0 = {}; + ok &= sevalue_to_native(args[0], &arg0, s.thisObject()); + if (!ok) { ok = true; break; } + auto *ptr = JSB_MAKE_PRIVATE_OBJECT(cc::geometry::Triangle, arg0.value()); + s.thisObject()->setPrivateObject(ptr); + return true; + } + } while(false); + do { + if (argc == 0) { + auto *ptr = JSB_MAKE_PRIVATE_OBJECT(cc::geometry::Triangle); + s.thisObject()->setPrivateObject(ptr); + return true; + } + } while(false); + do { + if (argc == 1) { + HolderType arg0 = {}; + ok &= sevalue_to_native(args[0], &arg0, s.thisObject()); + if (!ok) { ok = true; break; } + auto *ptr = JSB_MAKE_PRIVATE_OBJECT(cc::geometry::Triangle, arg0.value()); + s.thisObject()->setPrivateObject(ptr); + return true; + } + } while(false); + do { + if (argc == 2) { + HolderType arg0 = {}; + ok &= sevalue_to_native(args[0], &arg0, s.thisObject()); + if (!ok) { ok = true; break; } + HolderType arg1 = {}; + ok &= sevalue_to_native(args[1], &arg1, s.thisObject()); + if (!ok) { ok = true; break; } + auto *ptr = JSB_MAKE_PRIVATE_OBJECT(cc::geometry::Triangle, arg0.value(), arg1.value()); + s.thisObject()->setPrivateObject(ptr); + return true; + } + } while(false); + do { + if (argc == 3) { + HolderType arg0 = {}; + ok &= sevalue_to_native(args[0], &arg0, s.thisObject()); + if (!ok) { ok = true; break; } + HolderType arg1 = {}; + ok &= sevalue_to_native(args[1], &arg1, s.thisObject()); + if (!ok) { ok = true; break; } + HolderType arg2 = {}; + ok &= sevalue_to_native(args[2], &arg2, s.thisObject()); + if (!ok) { ok = true; break; } + auto *ptr = JSB_MAKE_PRIVATE_OBJECT(cc::geometry::Triangle, arg0.value(), arg1.value(), arg2.value()); + s.thisObject()->setPrivateObject(ptr); + return true; + } + } while(false); + do { + if (argc == 4) { + HolderType arg0 = {}; + ok &= sevalue_to_native(args[0], &arg0, s.thisObject()); + if (!ok) { ok = true; break; } + HolderType arg1 = {}; + ok &= sevalue_to_native(args[1], &arg1, s.thisObject()); + if (!ok) { ok = true; break; } + HolderType arg2 = {}; + ok &= sevalue_to_native(args[2], &arg2, s.thisObject()); + if (!ok) { ok = true; break; } + HolderType arg3 = {}; + ok &= sevalue_to_native(args[3], &arg3, s.thisObject()); + if (!ok) { ok = true; break; } + auto *ptr = JSB_MAKE_PRIVATE_OBJECT(cc::geometry::Triangle, arg0.value(), arg1.value(), arg2.value(), arg3.value()); + s.thisObject()->setPrivateObject(ptr); + return true; + } + } while(false); + do { + if (argc == 5) { + HolderType arg0 = {}; + ok &= sevalue_to_native(args[0], &arg0, s.thisObject()); + if (!ok) { ok = true; break; } + HolderType arg1 = {}; + ok &= sevalue_to_native(args[1], &arg1, s.thisObject()); + if (!ok) { ok = true; break; } + HolderType arg2 = {}; + ok &= sevalue_to_native(args[2], &arg2, s.thisObject()); + if (!ok) { ok = true; break; } + HolderType arg3 = {}; + ok &= sevalue_to_native(args[3], &arg3, s.thisObject()); + if (!ok) { ok = true; break; } + HolderType arg4 = {}; + ok &= sevalue_to_native(args[4], &arg4, s.thisObject()); + if (!ok) { ok = true; break; } + auto *ptr = JSB_MAKE_PRIVATE_OBJECT(cc::geometry::Triangle, arg0.value(), arg1.value(), arg2.value(), arg3.value(), arg4.value()); + s.thisObject()->setPrivateObject(ptr); + return true; + } + } while(false); + do { + if (argc == 6) { + HolderType arg0 = {}; + ok &= sevalue_to_native(args[0], &arg0, s.thisObject()); + if (!ok) { ok = true; break; } + HolderType arg1 = {}; + ok &= sevalue_to_native(args[1], &arg1, s.thisObject()); + if (!ok) { ok = true; break; } + HolderType arg2 = {}; + ok &= sevalue_to_native(args[2], &arg2, s.thisObject()); + if (!ok) { ok = true; break; } + HolderType arg3 = {}; + ok &= sevalue_to_native(args[3], &arg3, s.thisObject()); + if (!ok) { ok = true; break; } + HolderType arg4 = {}; + ok &= sevalue_to_native(args[4], &arg4, s.thisObject()); + if (!ok) { ok = true; break; } + HolderType arg5 = {}; + ok &= sevalue_to_native(args[5], &arg5, s.thisObject()); + if (!ok) { ok = true; break; } + auto *ptr = JSB_MAKE_PRIVATE_OBJECT(cc::geometry::Triangle, arg0.value(), arg1.value(), arg2.value(), arg3.value(), arg4.value(), arg5.value()); + s.thisObject()->setPrivateObject(ptr); + return true; + } + } while(false); + do { + if (argc == 7) { + HolderType arg0 = {}; + ok &= sevalue_to_native(args[0], &arg0, s.thisObject()); + if (!ok) { ok = true; break; } + HolderType arg1 = {}; + ok &= sevalue_to_native(args[1], &arg1, s.thisObject()); + if (!ok) { ok = true; break; } + HolderType arg2 = {}; + ok &= sevalue_to_native(args[2], &arg2, s.thisObject()); + if (!ok) { ok = true; break; } + HolderType arg3 = {}; + ok &= sevalue_to_native(args[3], &arg3, s.thisObject()); + if (!ok) { ok = true; break; } + HolderType arg4 = {}; + ok &= sevalue_to_native(args[4], &arg4, s.thisObject()); + if (!ok) { ok = true; break; } + HolderType arg5 = {}; + ok &= sevalue_to_native(args[5], &arg5, s.thisObject()); + if (!ok) { ok = true; break; } + HolderType arg6 = {}; + ok &= sevalue_to_native(args[6], &arg6, s.thisObject()); + if (!ok) { ok = true; break; } + auto *ptr = JSB_MAKE_PRIVATE_OBJECT(cc::geometry::Triangle, arg0.value(), arg1.value(), arg2.value(), arg3.value(), arg4.value(), arg5.value(), arg6.value()); + s.thisObject()->setPrivateObject(ptr); + return true; + } + } while(false); + do { + if (argc == 8) { + HolderType arg0 = {}; + ok &= sevalue_to_native(args[0], &arg0, s.thisObject()); + if (!ok) { ok = true; break; } + HolderType arg1 = {}; + ok &= sevalue_to_native(args[1], &arg1, s.thisObject()); + if (!ok) { ok = true; break; } + HolderType arg2 = {}; + ok &= sevalue_to_native(args[2], &arg2, s.thisObject()); + if (!ok) { ok = true; break; } + HolderType arg3 = {}; + ok &= sevalue_to_native(args[3], &arg3, s.thisObject()); + if (!ok) { ok = true; break; } + HolderType arg4 = {}; + ok &= sevalue_to_native(args[4], &arg4, s.thisObject()); + if (!ok) { ok = true; break; } + HolderType arg5 = {}; + ok &= sevalue_to_native(args[5], &arg5, s.thisObject()); + if (!ok) { ok = true; break; } + HolderType arg6 = {}; + ok &= sevalue_to_native(args[6], &arg6, s.thisObject()); + if (!ok) { ok = true; break; } + HolderType arg7 = {}; + ok &= sevalue_to_native(args[7], &arg7, s.thisObject()); + if (!ok) { ok = true; break; } + auto *ptr = JSB_MAKE_PRIVATE_OBJECT(cc::geometry::Triangle, arg0.value(), arg1.value(), arg2.value(), arg3.value(), arg4.value(), arg5.value(), arg6.value(), arg7.value()); + s.thisObject()->setPrivateObject(ptr); + return true; + } + } while(false); + do { + if (argc == 9) { + HolderType arg0 = {}; + ok &= sevalue_to_native(args[0], &arg0, s.thisObject()); + if (!ok) { ok = true; break; } + HolderType arg1 = {}; + ok &= sevalue_to_native(args[1], &arg1, s.thisObject()); + if (!ok) { ok = true; break; } + HolderType arg2 = {}; + ok &= sevalue_to_native(args[2], &arg2, s.thisObject()); + if (!ok) { ok = true; break; } + HolderType arg3 = {}; + ok &= sevalue_to_native(args[3], &arg3, s.thisObject()); + if (!ok) { ok = true; break; } + HolderType arg4 = {}; + ok &= sevalue_to_native(args[4], &arg4, s.thisObject()); + if (!ok) { ok = true; break; } + HolderType arg5 = {}; + ok &= sevalue_to_native(args[5], &arg5, s.thisObject()); + if (!ok) { ok = true; break; } + HolderType arg6 = {}; + ok &= sevalue_to_native(args[6], &arg6, s.thisObject()); + if (!ok) { ok = true; break; } + HolderType arg7 = {}; + ok &= sevalue_to_native(args[7], &arg7, s.thisObject()); + if (!ok) { ok = true; break; } + HolderType arg8 = {}; + ok &= sevalue_to_native(args[8], &arg8, s.thisObject()); + if (!ok) { ok = true; break; } + auto *ptr = JSB_MAKE_PRIVATE_OBJECT(cc::geometry::Triangle, arg0.value(), arg1.value(), arg2.value(), arg3.value(), arg4.value(), arg5.value(), arg6.value(), arg7.value(), arg8.value()); + s.thisObject()->setPrivateObject(ptr); + return true; + } + } while(false); + SE_REPORT_ERROR("wrong number of arguments: %d", (int)argc); + return false; +} +SE_BIND_CTOR(js_geometry_Triangle_constructor, __jsb_cc_geometry_Triangle_class, js_cc_geometry_Triangle_finalize) + +static bool js_cc_geometry_Triangle_finalize(se::State& s) // NOLINT(readability-identifier-naming) +{ + return true; +} +SE_BIND_FINALIZE_FUNC(js_cc_geometry_Triangle_finalize) + +bool js_register_geometry_Triangle(se::Object* obj) // NOLINT(readability-identifier-naming) +{ + auto* cls = se::Class::create("Triangle", obj, __jsb_cc_geometry_ShapeBase_proto, _SE(js_geometry_Triangle_constructor)); + + cls->defineStaticFunction("clone", _SE(js_geometry_Triangle_clone_static)); + cls->defineStaticFunction("copy", _SE(js_geometry_Triangle_copy_static)); + cls->defineStaticFunction("create", _SE(js_geometry_Triangle_create_static)); + cls->defineStaticFunction("fromPoints", _SE(js_geometry_Triangle_fromPoints_static)); + cls->defineStaticFunction("set", _SE(js_geometry_Triangle_set_static)); + cls->defineFinalizeFunction(_SE(js_cc_geometry_Triangle_finalize)); + cls->install(); + JSBClassType::registerClass(cls); + + __jsb_cc_geometry_Triangle_proto = cls->getProto(); + __jsb_cc_geometry_Triangle_class = cls; + + + se::ScriptEngine::getInstance()->clearException(); + return true; +} +bool register_all_geometry(se::Object* obj) // NOLINT +{ + // Get the ns + se::Value nsVal; + if (!obj->getProperty("ns", &nsVal, true)) + { + se::HandleObject jsobj(se::Object::createPlainObject()); + nsVal.setObject(jsobj); + obj->setProperty("ns", nsVal); + } + se::Object* ns = nsVal.toObject(); + + js_register_geometry_ShapeBase(ns); + js_register_geometry_AABB(ns); + js_register_geometry_Capsule(ns); + js_register_geometry_Frustum(ns); + js_register_geometry_Line(ns); + js_register_geometry_Plane(ns); + js_register_geometry_Ray(ns); + js_register_geometry_Sphere(ns); + js_register_geometry_Triangle(ns); + return true; +} + +// clang-format on \ No newline at end of file diff --git a/native/cocos/bindings/auto/jsb_geometry_auto.h b/native/cocos/bindings/auto/jsb_geometry_auto.h new file mode 100644 index 0000000000..ca705a6b3d --- /dev/null +++ b/native/cocos/bindings/auto/jsb_geometry_auto.h @@ -0,0 +1,146 @@ +// clang-format off +#pragma once +#include "base/Config.h" +#include +#include "cocos/bindings/jswrapper/SeApi.h" +#include "cocos/bindings/manual/jsb_conversions.h" +#include "cocos/bindings/auto/jsb_cocos_auto.h" +#include "cocos/core/geometry/Geometry.h" + +bool register_all_geometry(se::Object *obj); // NOLINT + +JSB_REGISTER_OBJECT_TYPE(cc::geometry::ShapeBase); +JSB_REGISTER_OBJECT_TYPE(cc::geometry::AABB); +JSB_REGISTER_OBJECT_TYPE(cc::geometry::Capsule); +JSB_REGISTER_OBJECT_TYPE(cc::geometry::Plane); +JSB_REGISTER_OBJECT_TYPE(cc::geometry::Frustum); +JSB_REGISTER_OBJECT_TYPE(cc::geometry::Line); +JSB_REGISTER_OBJECT_TYPE(cc::geometry::Ray); +JSB_REGISTER_OBJECT_TYPE(cc::geometry::Sphere); +JSB_REGISTER_OBJECT_TYPE(cc::geometry::Triangle); + + +extern se::Object *__jsb_cc_geometry_ShapeBase_proto; // NOLINT +extern se::Class * __jsb_cc_geometry_ShapeBase_class; // NOLINT + +bool js_register_cc_geometry_ShapeBase(se::Object *obj); // NOLINT + + +extern se::Object *__jsb_cc_geometry_AABB_proto; // NOLINT +extern se::Class * __jsb_cc_geometry_AABB_class; // NOLINT + +bool js_register_cc_geometry_AABB(se::Object *obj); // NOLINT + +SE_DECLARE_FUNC(js_geometry_AABB_contain); +SE_DECLARE_FUNC(js_geometry_AABB_create); +SE_DECLARE_FUNC(js_geometry_AABB_toBoundingSphere); +SE_DECLARE_FUNC(js_geometry_AABB_AABB); + +extern se::Object *__jsb_cc_geometry_Capsule_proto; // NOLINT +extern se::Class * __jsb_cc_geometry_Capsule_class; // NOLINT + +bool js_register_cc_geometry_Capsule(se::Object *obj); // NOLINT + +SE_DECLARE_FUNC(js_geometry_Capsule_transform); +SE_DECLARE_FUNC(js_geometry_Capsule_Capsule); + +extern se::Object *__jsb_cc_geometry_Plane_proto; // NOLINT +extern se::Class * __jsb_cc_geometry_Plane_class; // NOLINT + +bool js_register_cc_geometry_Plane(se::Object *obj); // NOLINT + +SE_DECLARE_FUNC(js_geometry_Plane_define); +SE_DECLARE_FUNC(js_geometry_Plane_distance); +SE_DECLARE_FUNC(js_geometry_Plane_getW); +SE_DECLARE_FUNC(js_geometry_Plane_getX); +SE_DECLARE_FUNC(js_geometry_Plane_getY); +SE_DECLARE_FUNC(js_geometry_Plane_getZ); +SE_DECLARE_FUNC(js_geometry_Plane_transform); +SE_DECLARE_FUNC(js_geometry_Plane_create); +SE_DECLARE_FUNC(js_geometry_Plane_Plane); + +extern se::Object *__jsb_cc_geometry_Frustum_proto; // NOLINT +extern se::Class * __jsb_cc_geometry_Frustum_class; // NOLINT + +bool js_register_cc_geometry_Frustum(se::Object *obj); // NOLINT + +SE_DECLARE_FUNC(js_geometry_Frustum_clone); +SE_DECLARE_FUNC(js_geometry_Frustum_createOrtho); +SE_DECLARE_FUNC(js_geometry_Frustum_setAccurate); +SE_DECLARE_FUNC(js_geometry_Frustum_transform); +SE_DECLARE_FUNC(js_geometry_Frustum_clone); +SE_DECLARE_FUNC(js_geometry_Frustum_copy); +SE_DECLARE_FUNC(js_geometry_Frustum_create); +SE_DECLARE_FUNC(js_geometry_Frustum_createFromAABB); +SE_DECLARE_FUNC(js_geometry_Frustum_createOrtho); +SE_DECLARE_FUNC(js_geometry_Frustum_Frustum); + +extern se::Object *__jsb_cc_geometry_Line_proto; // NOLINT +extern se::Class * __jsb_cc_geometry_Line_class; // NOLINT + +bool js_register_cc_geometry_Line(se::Object *obj); // NOLINT + +SE_DECLARE_FUNC(js_geometry_Line_length); +SE_DECLARE_FUNC(js_geometry_Line_clone); +SE_DECLARE_FUNC(js_geometry_Line_copy); +SE_DECLARE_FUNC(js_geometry_Line_create); +SE_DECLARE_FUNC(js_geometry_Line_fromPoints); +SE_DECLARE_FUNC(js_geometry_Line_len); +SE_DECLARE_FUNC(js_geometry_Line_set); +SE_DECLARE_FUNC(js_geometry_Line_Line); + +extern se::Object *__jsb_cc_geometry_Ray_proto; // NOLINT +extern se::Class * __jsb_cc_geometry_Ray_class; // NOLINT + +bool js_register_cc_geometry_Ray(se::Object *obj); // NOLINT + +SE_DECLARE_FUNC(js_geometry_Ray_clone); +SE_DECLARE_FUNC(js_geometry_Ray_copy); +SE_DECLARE_FUNC(js_geometry_Ray_create); +SE_DECLARE_FUNC(js_geometry_Ray_fromPoints); +SE_DECLARE_FUNC(js_geometry_Ray_set); +SE_DECLARE_FUNC(js_geometry_Ray_Ray); + +extern se::Object *__jsb_cc_geometry_Sphere_proto; // NOLINT +extern se::Class * __jsb_cc_geometry_Sphere_class; // NOLINT + +bool js_register_cc_geometry_Sphere(se::Object *obj); // NOLINT + +SE_DECLARE_FUNC(js_geometry_Sphere_clone); +SE_DECLARE_FUNC(js_geometry_Sphere_copy); +SE_DECLARE_FUNC(js_geometry_Sphere_define); +SE_DECLARE_FUNC(js_geometry_Sphere_getCenter); +SE_DECLARE_FUNC(js_geometry_Sphere_getRadius); +SE_DECLARE_FUNC(js_geometry_Sphere_interset); +SE_DECLARE_FUNC(js_geometry_Sphere_merge); +SE_DECLARE_FUNC(js_geometry_Sphere_mergeAABB); +SE_DECLARE_FUNC(js_geometry_Sphere_mergeFrustum); +SE_DECLARE_FUNC(js_geometry_Sphere_mergePoint); +SE_DECLARE_FUNC(js_geometry_Sphere_setCenter); +SE_DECLARE_FUNC(js_geometry_Sphere_setRadius); +SE_DECLARE_FUNC(js_geometry_Sphere_setScale); +SE_DECLARE_FUNC(js_geometry_Sphere_sphereFrustum); +SE_DECLARE_FUNC(js_geometry_Sphere_spherePlane); +SE_DECLARE_FUNC(js_geometry_Sphere_transform); +SE_DECLARE_FUNC(js_geometry_Sphere_translateAndRotate); +SE_DECLARE_FUNC(js_geometry_Sphere_clone); +SE_DECLARE_FUNC(js_geometry_Sphere_copy); +SE_DECLARE_FUNC(js_geometry_Sphere_create); +SE_DECLARE_FUNC(js_geometry_Sphere_fromPoints); +SE_DECLARE_FUNC(js_geometry_Sphere_mergeAABB); +SE_DECLARE_FUNC(js_geometry_Sphere_mergePoint); +SE_DECLARE_FUNC(js_geometry_Sphere_set); +SE_DECLARE_FUNC(js_geometry_Sphere_Sphere); + +extern se::Object *__jsb_cc_geometry_Triangle_proto; // NOLINT +extern se::Class * __jsb_cc_geometry_Triangle_class; // NOLINT + +bool js_register_cc_geometry_Triangle(se::Object *obj); // NOLINT + +SE_DECLARE_FUNC(js_geometry_Triangle_clone); +SE_DECLARE_FUNC(js_geometry_Triangle_copy); +SE_DECLARE_FUNC(js_geometry_Triangle_create); +SE_DECLARE_FUNC(js_geometry_Triangle_fromPoints); +SE_DECLARE_FUNC(js_geometry_Triangle_set); +SE_DECLARE_FUNC(js_geometry_Triangle_Triangle); + // clang-format on \ No newline at end of file diff --git a/native/cocos/bindings/auto/jsb_gfx_auto.cpp b/native/cocos/bindings/auto/jsb_gfx_auto.cpp index 5803a4c144..2c4b4d16e2 100644 --- a/native/cocos/bindings/auto/jsb_gfx_auto.cpp +++ b/native/cocos/bindings/auto/jsb_gfx_auto.cpp @@ -1,3 +1,5 @@ + +// clang-format off #include "cocos/bindings/auto/jsb_gfx_auto.h" #include "cocos/bindings/manual/jsb_conversions.h" #include "cocos/bindings/manual/jsb_global.h" @@ -10,8 +12,8 @@ #ifndef JSB_FREE #define JSB_FREE(ptr) delete ptr #endif -se::Object* __jsb_cc_gfx_Size_proto = nullptr; -se::Class* __jsb_cc_gfx_Size_class = nullptr; +se::Object* __jsb_cc_gfx_Size_proto = nullptr; // NOLINT +se::Class* __jsb_cc_gfx_Size_class = nullptr; // NOLINT static bool js_gfx_Size_get_x(se::State& s) // NOLINT(readability-identifier-naming) { @@ -107,15 +109,15 @@ bool sevalue_to_native(const se::Value &from, cc::gfx::Size * to, se::Object *ct } se::Value field; bool ok = true; - json->getProperty("x", &field); + json->getProperty("x", &field, true); if(!field.isNullOrUndefined()) { ok &= sevalue_to_native(field, &(to->x), ctx); } - json->getProperty("y", &field); + json->getProperty("y", &field, true); if(!field.isNullOrUndefined()) { ok &= sevalue_to_native(field, &(to->y), ctx); } - json->getProperty("z", &field); + json->getProperty("z", &field, true); if(!field.isNullOrUndefined()) { ok &= sevalue_to_native(field, &(to->z), ctx); } @@ -132,9 +134,8 @@ static bool js_gfx_Size_constructor(se::State& s) // NOLINT(readability-identifi if(argc == 0) { - cc::gfx::Size* cobj = JSB_ALLOC(cc::gfx::Size); - s.thisObject()->setPrivateData(cobj); - se::NonRefNativePtrCreatedByCtorMap::emplace(cobj); + auto *ptr = JSB_MAKE_PRIVATE_OBJECT(cc::gfx::Size); + s.thisObject()->setPrivateObject(ptr); return true; } @@ -142,21 +143,19 @@ static bool js_gfx_Size_constructor(se::State& s) // NOLINT(readability-identifi { se::Object *json = args[0].toObject(); se::Value field; - - cc::gfx::Size* cobj = JSB_ALLOC(cc::gfx::Size); + auto *ptr = JSB_MAKE_PRIVATE_OBJECT(cc::gfx::Size); + auto cobj = ptr->get(); ok &= sevalue_to_native(args[0], cobj, s.thisObject()); if(!ok) { - JSB_FREE(cobj); + delete ptr; SE_REPORT_ERROR("argument convertion error"); return false; } - - s.thisObject()->setPrivateData(cobj); - se::NonRefNativePtrCreatedByCtorMap::emplace(cobj); + s.thisObject()->setPrivateObject(ptr); return true; } - - cc::gfx::Size* cobj = JSB_ALLOC(cc::gfx::Size); + auto *ptr = JSB_MAKE_PRIVATE_OBJECT(cc::gfx::Size); + auto cobj = ptr->get(); if (argc > 0 && !args[0].isUndefined()) { ok &= sevalue_to_native(args[0], &(cobj->x), nullptr); } @@ -168,28 +167,17 @@ static bool js_gfx_Size_constructor(se::State& s) // NOLINT(readability-identifi } if(!ok) { - JSB_FREE(cobj); + delete ptr; SE_REPORT_ERROR("Argument convertion error"); return false; } - - s.thisObject()->setPrivateData(cobj); - se::NonRefNativePtrCreatedByCtorMap::emplace(cobj); + s.thisObject()->setPrivateObject(ptr); return true; } SE_BIND_CTOR(js_gfx_Size_constructor, __jsb_cc_gfx_Size_class, js_cc_gfx_Size_finalize) - - static bool js_cc_gfx_Size_finalize(se::State& s) // NOLINT(readability-identifier-naming) { - auto iter = se::NonRefNativePtrCreatedByCtorMap::find(SE_THIS_OBJECT(s)); - if (iter != se::NonRefNativePtrCreatedByCtorMap::end()) - { - se::NonRefNativePtrCreatedByCtorMap::erase(iter); - auto* cobj = SE_THIS_OBJECT(s); - JSB_FREE(cobj); - } return true; } SE_BIND_FINALIZE_FUNC(js_cc_gfx_Size_finalize) @@ -208,11 +196,12 @@ bool js_register_gfx_Size(se::Object* obj) // NOLINT(readability-identifier-nami __jsb_cc_gfx_Size_proto = cls->getProto(); __jsb_cc_gfx_Size_class = cls; + se::ScriptEngine::getInstance()->clearException(); return true; } -se::Object* __jsb_cc_gfx_DeviceCaps_proto = nullptr; -se::Class* __jsb_cc_gfx_DeviceCaps_class = nullptr; +se::Object* __jsb_cc_gfx_DeviceCaps_proto = nullptr; // NOLINT +se::Class* __jsb_cc_gfx_DeviceCaps_class = nullptr; // NOLINT static bool js_gfx_DeviceCaps_get_maxVertexAttributes(se::State& s) // NOLINT(readability-identifier-naming) { @@ -821,91 +810,91 @@ bool sevalue_to_native(const se::Value &from, cc::gfx::DeviceCaps * to, se::Obje } se::Value field; bool ok = true; - json->getProperty("maxVertexAttributes", &field); + json->getProperty("maxVertexAttributes", &field, true); if(!field.isNullOrUndefined()) { ok &= sevalue_to_native(field, &(to->maxVertexAttributes), ctx); } - json->getProperty("maxVertexUniformVectors", &field); + json->getProperty("maxVertexUniformVectors", &field, true); if(!field.isNullOrUndefined()) { ok &= sevalue_to_native(field, &(to->maxVertexUniformVectors), ctx); } - json->getProperty("maxFragmentUniformVectors", &field); + json->getProperty("maxFragmentUniformVectors", &field, true); if(!field.isNullOrUndefined()) { ok &= sevalue_to_native(field, &(to->maxFragmentUniformVectors), ctx); } - json->getProperty("maxTextureUnits", &field); + json->getProperty("maxTextureUnits", &field, true); if(!field.isNullOrUndefined()) { ok &= sevalue_to_native(field, &(to->maxTextureUnits), ctx); } - json->getProperty("maxImageUnits", &field); + json->getProperty("maxImageUnits", &field, true); if(!field.isNullOrUndefined()) { ok &= sevalue_to_native(field, &(to->maxImageUnits), ctx); } - json->getProperty("maxVertexTextureUnits", &field); + json->getProperty("maxVertexTextureUnits", &field, true); if(!field.isNullOrUndefined()) { ok &= sevalue_to_native(field, &(to->maxVertexTextureUnits), ctx); } - json->getProperty("maxColorRenderTargets", &field); + json->getProperty("maxColorRenderTargets", &field, true); if(!field.isNullOrUndefined()) { ok &= sevalue_to_native(field, &(to->maxColorRenderTargets), ctx); } - json->getProperty("maxShaderStorageBufferBindings", &field); + json->getProperty("maxShaderStorageBufferBindings", &field, true); if(!field.isNullOrUndefined()) { ok &= sevalue_to_native(field, &(to->maxShaderStorageBufferBindings), ctx); } - json->getProperty("maxShaderStorageBlockSize", &field); + json->getProperty("maxShaderStorageBlockSize", &field, true); if(!field.isNullOrUndefined()) { ok &= sevalue_to_native(field, &(to->maxShaderStorageBlockSize), ctx); } - json->getProperty("maxUniformBufferBindings", &field); + json->getProperty("maxUniformBufferBindings", &field, true); if(!field.isNullOrUndefined()) { ok &= sevalue_to_native(field, &(to->maxUniformBufferBindings), ctx); } - json->getProperty("maxUniformBlockSize", &field); + json->getProperty("maxUniformBlockSize", &field, true); if(!field.isNullOrUndefined()) { ok &= sevalue_to_native(field, &(to->maxUniformBlockSize), ctx); } - json->getProperty("maxTextureSize", &field); + json->getProperty("maxTextureSize", &field, true); if(!field.isNullOrUndefined()) { ok &= sevalue_to_native(field, &(to->maxTextureSize), ctx); } - json->getProperty("maxCubeMapTextureSize", &field); + json->getProperty("maxCubeMapTextureSize", &field, true); if(!field.isNullOrUndefined()) { ok &= sevalue_to_native(field, &(to->maxCubeMapTextureSize), ctx); } - json->getProperty("uboOffsetAlignment", &field); + json->getProperty("uboOffsetAlignment", &field, true); if(!field.isNullOrUndefined()) { ok &= sevalue_to_native(field, &(to->uboOffsetAlignment), ctx); } - json->getProperty("maxComputeSharedMemorySize", &field); + json->getProperty("maxComputeSharedMemorySize", &field, true); if(!field.isNullOrUndefined()) { ok &= sevalue_to_native(field, &(to->maxComputeSharedMemorySize), ctx); } - json->getProperty("maxComputeWorkGroupInvocations", &field); + json->getProperty("maxComputeWorkGroupInvocations", &field, true); if(!field.isNullOrUndefined()) { ok &= sevalue_to_native(field, &(to->maxComputeWorkGroupInvocations), ctx); } - json->getProperty("maxComputeWorkGroupSize", &field); + json->getProperty("maxComputeWorkGroupSize", &field, true); if(!field.isNullOrUndefined()) { ok &= sevalue_to_native(field, &(to->maxComputeWorkGroupSize), ctx); } - json->getProperty("maxComputeWorkGroupCount", &field); + json->getProperty("maxComputeWorkGroupCount", &field, true); if(!field.isNullOrUndefined()) { ok &= sevalue_to_native(field, &(to->maxComputeWorkGroupCount), ctx); } - json->getProperty("supportQuery", &field); + json->getProperty("supportQuery", &field, true); if(!field.isNullOrUndefined()) { ok &= sevalue_to_native(field, &(to->supportQuery), ctx); } - json->getProperty("clipSpaceMinZ", &field); + json->getProperty("clipSpaceMinZ", &field, true); if(!field.isNullOrUndefined()) { ok &= sevalue_to_native(field, &(to->clipSpaceMinZ), ctx); } - json->getProperty("screenSpaceSignY", &field); + json->getProperty("screenSpaceSignY", &field, true); if(!field.isNullOrUndefined()) { ok &= sevalue_to_native(field, &(to->screenSpaceSignY), ctx); } - json->getProperty("clipSpaceSignY", &field); + json->getProperty("clipSpaceSignY", &field, true); if(!field.isNullOrUndefined()) { ok &= sevalue_to_native(field, &(to->clipSpaceSignY), ctx); } @@ -922,9 +911,8 @@ static bool js_gfx_DeviceCaps_constructor(se::State& s) // NOLINT(readability-id if(argc == 0) { - cc::gfx::DeviceCaps* cobj = JSB_ALLOC(cc::gfx::DeviceCaps); - s.thisObject()->setPrivateData(cobj); - se::NonRefNativePtrCreatedByCtorMap::emplace(cobj); + auto *ptr = JSB_MAKE_PRIVATE_OBJECT(cc::gfx::DeviceCaps); + s.thisObject()->setPrivateObject(ptr); return true; } @@ -932,21 +920,19 @@ static bool js_gfx_DeviceCaps_constructor(se::State& s) // NOLINT(readability-id { se::Object *json = args[0].toObject(); se::Value field; - - cc::gfx::DeviceCaps* cobj = JSB_ALLOC(cc::gfx::DeviceCaps); + auto *ptr = JSB_MAKE_PRIVATE_OBJECT(cc::gfx::DeviceCaps); + auto cobj = ptr->get(); ok &= sevalue_to_native(args[0], cobj, s.thisObject()); if(!ok) { - JSB_FREE(cobj); + delete ptr; SE_REPORT_ERROR("argument convertion error"); return false; } - - s.thisObject()->setPrivateData(cobj); - se::NonRefNativePtrCreatedByCtorMap::emplace(cobj); + s.thisObject()->setPrivateObject(ptr); return true; } - - cc::gfx::DeviceCaps* cobj = JSB_ALLOC(cc::gfx::DeviceCaps); + auto *ptr = JSB_MAKE_PRIVATE_OBJECT(cc::gfx::DeviceCaps); + auto cobj = ptr->get(); if (argc > 0 && !args[0].isUndefined()) { ok &= sevalue_to_native(args[0], &(cobj->maxVertexAttributes), nullptr); } @@ -1015,28 +1001,17 @@ static bool js_gfx_DeviceCaps_constructor(se::State& s) // NOLINT(readability-id } if(!ok) { - JSB_FREE(cobj); + delete ptr; SE_REPORT_ERROR("Argument convertion error"); return false; } - - s.thisObject()->setPrivateData(cobj); - se::NonRefNativePtrCreatedByCtorMap::emplace(cobj); + s.thisObject()->setPrivateObject(ptr); return true; } SE_BIND_CTOR(js_gfx_DeviceCaps_constructor, __jsb_cc_gfx_DeviceCaps_class, js_cc_gfx_DeviceCaps_finalize) - - static bool js_cc_gfx_DeviceCaps_finalize(se::State& s) // NOLINT(readability-identifier-naming) { - auto iter = se::NonRefNativePtrCreatedByCtorMap::find(SE_THIS_OBJECT(s)); - if (iter != se::NonRefNativePtrCreatedByCtorMap::end()) - { - se::NonRefNativePtrCreatedByCtorMap::erase(iter); - auto* cobj = SE_THIS_OBJECT(s); - JSB_FREE(cobj); - } return true; } SE_BIND_FINALIZE_FUNC(js_cc_gfx_DeviceCaps_finalize) @@ -1074,11 +1049,12 @@ bool js_register_gfx_DeviceCaps(se::Object* obj) // NOLINT(readability-identifie __jsb_cc_gfx_DeviceCaps_proto = cls->getProto(); __jsb_cc_gfx_DeviceCaps_class = cls; + se::ScriptEngine::getInstance()->clearException(); return true; } -se::Object* __jsb_cc_gfx_Offset_proto = nullptr; -se::Class* __jsb_cc_gfx_Offset_class = nullptr; +se::Object* __jsb_cc_gfx_Offset_proto = nullptr; // NOLINT +se::Class* __jsb_cc_gfx_Offset_class = nullptr; // NOLINT static bool js_gfx_Offset_get_x(se::State& s) // NOLINT(readability-identifier-naming) { @@ -1174,15 +1150,15 @@ bool sevalue_to_native(const se::Value &from, cc::gfx::Offset * to, se::Object * } se::Value field; bool ok = true; - json->getProperty("x", &field); + json->getProperty("x", &field, true); if(!field.isNullOrUndefined()) { ok &= sevalue_to_native(field, &(to->x), ctx); } - json->getProperty("y", &field); + json->getProperty("y", &field, true); if(!field.isNullOrUndefined()) { ok &= sevalue_to_native(field, &(to->y), ctx); } - json->getProperty("z", &field); + json->getProperty("z", &field, true); if(!field.isNullOrUndefined()) { ok &= sevalue_to_native(field, &(to->z), ctx); } @@ -1199,9 +1175,8 @@ static bool js_gfx_Offset_constructor(se::State& s) // NOLINT(readability-identi if(argc == 0) { - cc::gfx::Offset* cobj = JSB_ALLOC(cc::gfx::Offset); - s.thisObject()->setPrivateData(cobj); - se::NonRefNativePtrCreatedByCtorMap::emplace(cobj); + auto *ptr = JSB_MAKE_PRIVATE_OBJECT(cc::gfx::Offset); + s.thisObject()->setPrivateObject(ptr); return true; } @@ -1209,21 +1184,19 @@ static bool js_gfx_Offset_constructor(se::State& s) // NOLINT(readability-identi { se::Object *json = args[0].toObject(); se::Value field; - - cc::gfx::Offset* cobj = JSB_ALLOC(cc::gfx::Offset); + auto *ptr = JSB_MAKE_PRIVATE_OBJECT(cc::gfx::Offset); + auto cobj = ptr->get(); ok &= sevalue_to_native(args[0], cobj, s.thisObject()); if(!ok) { - JSB_FREE(cobj); + delete ptr; SE_REPORT_ERROR("argument convertion error"); return false; } - - s.thisObject()->setPrivateData(cobj); - se::NonRefNativePtrCreatedByCtorMap::emplace(cobj); + s.thisObject()->setPrivateObject(ptr); return true; } - - cc::gfx::Offset* cobj = JSB_ALLOC(cc::gfx::Offset); + auto *ptr = JSB_MAKE_PRIVATE_OBJECT(cc::gfx::Offset); + auto cobj = ptr->get(); if (argc > 0 && !args[0].isUndefined()) { ok &= sevalue_to_native(args[0], &(cobj->x), nullptr); } @@ -1235,28 +1208,17 @@ static bool js_gfx_Offset_constructor(se::State& s) // NOLINT(readability-identi } if(!ok) { - JSB_FREE(cobj); + delete ptr; SE_REPORT_ERROR("Argument convertion error"); return false; } - - s.thisObject()->setPrivateData(cobj); - se::NonRefNativePtrCreatedByCtorMap::emplace(cobj); + s.thisObject()->setPrivateObject(ptr); return true; } SE_BIND_CTOR(js_gfx_Offset_constructor, __jsb_cc_gfx_Offset_class, js_cc_gfx_Offset_finalize) - - static bool js_cc_gfx_Offset_finalize(se::State& s) // NOLINT(readability-identifier-naming) { - auto iter = se::NonRefNativePtrCreatedByCtorMap::find(SE_THIS_OBJECT(s)); - if (iter != se::NonRefNativePtrCreatedByCtorMap::end()) - { - se::NonRefNativePtrCreatedByCtorMap::erase(iter); - auto* cobj = SE_THIS_OBJECT(s); - JSB_FREE(cobj); - } return true; } SE_BIND_FINALIZE_FUNC(js_cc_gfx_Offset_finalize) @@ -1275,11 +1237,12 @@ bool js_register_gfx_Offset(se::Object* obj) // NOLINT(readability-identifier-na __jsb_cc_gfx_Offset_proto = cls->getProto(); __jsb_cc_gfx_Offset_class = cls; + se::ScriptEngine::getInstance()->clearException(); return true; } -se::Object* __jsb_cc_gfx_Rect_proto = nullptr; -se::Class* __jsb_cc_gfx_Rect_class = nullptr; +se::Object* __jsb_cc_gfx_Rect_proto = nullptr; // NOLINT +se::Class* __jsb_cc_gfx_Rect_class = nullptr; // NOLINT static bool js_gfx_Rect_get_x(se::State& s) // NOLINT(readability-identifier-naming) { @@ -1402,19 +1365,19 @@ bool sevalue_to_native(const se::Value &from, cc::gfx::Rect * to, se::Object *ct } se::Value field; bool ok = true; - json->getProperty("x", &field); + json->getProperty("x", &field, true); if(!field.isNullOrUndefined()) { ok &= sevalue_to_native(field, &(to->x), ctx); } - json->getProperty("y", &field); + json->getProperty("y", &field, true); if(!field.isNullOrUndefined()) { ok &= sevalue_to_native(field, &(to->y), ctx); } - json->getProperty("width", &field); + json->getProperty("width", &field, true); if(!field.isNullOrUndefined()) { ok &= sevalue_to_native(field, &(to->width), ctx); } - json->getProperty("height", &field); + json->getProperty("height", &field, true); if(!field.isNullOrUndefined()) { ok &= sevalue_to_native(field, &(to->height), ctx); } @@ -1431,9 +1394,8 @@ static bool js_gfx_Rect_constructor(se::State& s) // NOLINT(readability-identifi if(argc == 0) { - cc::gfx::Rect* cobj = JSB_ALLOC(cc::gfx::Rect); - s.thisObject()->setPrivateData(cobj); - se::NonRefNativePtrCreatedByCtorMap::emplace(cobj); + auto *ptr = JSB_MAKE_PRIVATE_OBJECT(cc::gfx::Rect); + s.thisObject()->setPrivateObject(ptr); return true; } @@ -1441,21 +1403,19 @@ static bool js_gfx_Rect_constructor(se::State& s) // NOLINT(readability-identifi { se::Object *json = args[0].toObject(); se::Value field; - - cc::gfx::Rect* cobj = JSB_ALLOC(cc::gfx::Rect); + auto *ptr = JSB_MAKE_PRIVATE_OBJECT(cc::gfx::Rect); + auto cobj = ptr->get(); ok &= sevalue_to_native(args[0], cobj, s.thisObject()); if(!ok) { - JSB_FREE(cobj); + delete ptr; SE_REPORT_ERROR("argument convertion error"); return false; } - - s.thisObject()->setPrivateData(cobj); - se::NonRefNativePtrCreatedByCtorMap::emplace(cobj); + s.thisObject()->setPrivateObject(ptr); return true; } - - cc::gfx::Rect* cobj = JSB_ALLOC(cc::gfx::Rect); + auto *ptr = JSB_MAKE_PRIVATE_OBJECT(cc::gfx::Rect); + auto cobj = ptr->get(); if (argc > 0 && !args[0].isUndefined()) { ok &= sevalue_to_native(args[0], &(cobj->x), nullptr); } @@ -1470,28 +1430,17 @@ static bool js_gfx_Rect_constructor(se::State& s) // NOLINT(readability-identifi } if(!ok) { - JSB_FREE(cobj); + delete ptr; SE_REPORT_ERROR("Argument convertion error"); return false; } - - s.thisObject()->setPrivateData(cobj); - se::NonRefNativePtrCreatedByCtorMap::emplace(cobj); + s.thisObject()->setPrivateObject(ptr); return true; } SE_BIND_CTOR(js_gfx_Rect_constructor, __jsb_cc_gfx_Rect_class, js_cc_gfx_Rect_finalize) - - static bool js_cc_gfx_Rect_finalize(se::State& s) // NOLINT(readability-identifier-naming) { - auto iter = se::NonRefNativePtrCreatedByCtorMap::find(SE_THIS_OBJECT(s)); - if (iter != se::NonRefNativePtrCreatedByCtorMap::end()) - { - se::NonRefNativePtrCreatedByCtorMap::erase(iter); - auto* cobj = SE_THIS_OBJECT(s); - JSB_FREE(cobj); - } return true; } SE_BIND_FINALIZE_FUNC(js_cc_gfx_Rect_finalize) @@ -1511,11 +1460,12 @@ bool js_register_gfx_Rect(se::Object* obj) // NOLINT(readability-identifier-nami __jsb_cc_gfx_Rect_proto = cls->getProto(); __jsb_cc_gfx_Rect_class = cls; + se::ScriptEngine::getInstance()->clearException(); return true; } -se::Object* __jsb_cc_gfx_Extent_proto = nullptr; -se::Class* __jsb_cc_gfx_Extent_class = nullptr; +se::Object* __jsb_cc_gfx_Extent_proto = nullptr; // NOLINT +se::Class* __jsb_cc_gfx_Extent_class = nullptr; // NOLINT static bool js_gfx_Extent_get_width(se::State& s) // NOLINT(readability-identifier-naming) { @@ -1611,15 +1561,15 @@ bool sevalue_to_native(const se::Value &from, cc::gfx::Extent * to, se::Object * } se::Value field; bool ok = true; - json->getProperty("width", &field); + json->getProperty("width", &field, true); if(!field.isNullOrUndefined()) { ok &= sevalue_to_native(field, &(to->width), ctx); } - json->getProperty("height", &field); + json->getProperty("height", &field, true); if(!field.isNullOrUndefined()) { ok &= sevalue_to_native(field, &(to->height), ctx); } - json->getProperty("depth", &field); + json->getProperty("depth", &field, true); if(!field.isNullOrUndefined()) { ok &= sevalue_to_native(field, &(to->depth), ctx); } @@ -1636,9 +1586,8 @@ static bool js_gfx_Extent_constructor(se::State& s) // NOLINT(readability-identi if(argc == 0) { - cc::gfx::Extent* cobj = JSB_ALLOC(cc::gfx::Extent); - s.thisObject()->setPrivateData(cobj); - se::NonRefNativePtrCreatedByCtorMap::emplace(cobj); + auto *ptr = JSB_MAKE_PRIVATE_OBJECT(cc::gfx::Extent); + s.thisObject()->setPrivateObject(ptr); return true; } @@ -1646,21 +1595,19 @@ static bool js_gfx_Extent_constructor(se::State& s) // NOLINT(readability-identi { se::Object *json = args[0].toObject(); se::Value field; - - cc::gfx::Extent* cobj = JSB_ALLOC(cc::gfx::Extent); + auto *ptr = JSB_MAKE_PRIVATE_OBJECT(cc::gfx::Extent); + auto cobj = ptr->get(); ok &= sevalue_to_native(args[0], cobj, s.thisObject()); if(!ok) { - JSB_FREE(cobj); + delete ptr; SE_REPORT_ERROR("argument convertion error"); return false; } - - s.thisObject()->setPrivateData(cobj); - se::NonRefNativePtrCreatedByCtorMap::emplace(cobj); + s.thisObject()->setPrivateObject(ptr); return true; } - - cc::gfx::Extent* cobj = JSB_ALLOC(cc::gfx::Extent); + auto *ptr = JSB_MAKE_PRIVATE_OBJECT(cc::gfx::Extent); + auto cobj = ptr->get(); if (argc > 0 && !args[0].isUndefined()) { ok &= sevalue_to_native(args[0], &(cobj->width), nullptr); } @@ -1672,28 +1619,17 @@ static bool js_gfx_Extent_constructor(se::State& s) // NOLINT(readability-identi } if(!ok) { - JSB_FREE(cobj); + delete ptr; SE_REPORT_ERROR("Argument convertion error"); return false; } - - s.thisObject()->setPrivateData(cobj); - se::NonRefNativePtrCreatedByCtorMap::emplace(cobj); + s.thisObject()->setPrivateObject(ptr); return true; } SE_BIND_CTOR(js_gfx_Extent_constructor, __jsb_cc_gfx_Extent_class, js_cc_gfx_Extent_finalize) - - static bool js_cc_gfx_Extent_finalize(se::State& s) // NOLINT(readability-identifier-naming) { - auto iter = se::NonRefNativePtrCreatedByCtorMap::find(SE_THIS_OBJECT(s)); - if (iter != se::NonRefNativePtrCreatedByCtorMap::end()) - { - se::NonRefNativePtrCreatedByCtorMap::erase(iter); - auto* cobj = SE_THIS_OBJECT(s); - JSB_FREE(cobj); - } return true; } SE_BIND_FINALIZE_FUNC(js_cc_gfx_Extent_finalize) @@ -1712,11 +1648,12 @@ bool js_register_gfx_Extent(se::Object* obj) // NOLINT(readability-identifier-na __jsb_cc_gfx_Extent_proto = cls->getProto(); __jsb_cc_gfx_Extent_class = cls; + se::ScriptEngine::getInstance()->clearException(); return true; } -se::Object* __jsb_cc_gfx_TextureSubresLayers_proto = nullptr; -se::Class* __jsb_cc_gfx_TextureSubresLayers_class = nullptr; +se::Object* __jsb_cc_gfx_TextureSubresLayers_proto = nullptr; // NOLINT +se::Class* __jsb_cc_gfx_TextureSubresLayers_class = nullptr; // NOLINT static bool js_gfx_TextureSubresLayers_get_mipLevel(se::State& s) // NOLINT(readability-identifier-naming) { @@ -1812,15 +1749,15 @@ bool sevalue_to_native(const se::Value &from, cc::gfx::TextureSubresLayers * to, } se::Value field; bool ok = true; - json->getProperty("mipLevel", &field); + json->getProperty("mipLevel", &field, true); if(!field.isNullOrUndefined()) { ok &= sevalue_to_native(field, &(to->mipLevel), ctx); } - json->getProperty("baseArrayLayer", &field); + json->getProperty("baseArrayLayer", &field, true); if(!field.isNullOrUndefined()) { ok &= sevalue_to_native(field, &(to->baseArrayLayer), ctx); } - json->getProperty("layerCount", &field); + json->getProperty("layerCount", &field, true); if(!field.isNullOrUndefined()) { ok &= sevalue_to_native(field, &(to->layerCount), ctx); } @@ -1837,9 +1774,8 @@ static bool js_gfx_TextureSubresLayers_constructor(se::State& s) // NOLINT(reada if(argc == 0) { - cc::gfx::TextureSubresLayers* cobj = JSB_ALLOC(cc::gfx::TextureSubresLayers); - s.thisObject()->setPrivateData(cobj); - se::NonRefNativePtrCreatedByCtorMap::emplace(cobj); + auto *ptr = JSB_MAKE_PRIVATE_OBJECT(cc::gfx::TextureSubresLayers); + s.thisObject()->setPrivateObject(ptr); return true; } @@ -1847,21 +1783,19 @@ static bool js_gfx_TextureSubresLayers_constructor(se::State& s) // NOLINT(reada { se::Object *json = args[0].toObject(); se::Value field; - - cc::gfx::TextureSubresLayers* cobj = JSB_ALLOC(cc::gfx::TextureSubresLayers); + auto *ptr = JSB_MAKE_PRIVATE_OBJECT(cc::gfx::TextureSubresLayers); + auto cobj = ptr->get(); ok &= sevalue_to_native(args[0], cobj, s.thisObject()); if(!ok) { - JSB_FREE(cobj); + delete ptr; SE_REPORT_ERROR("argument convertion error"); return false; } - - s.thisObject()->setPrivateData(cobj); - se::NonRefNativePtrCreatedByCtorMap::emplace(cobj); + s.thisObject()->setPrivateObject(ptr); return true; } - - cc::gfx::TextureSubresLayers* cobj = JSB_ALLOC(cc::gfx::TextureSubresLayers); + auto *ptr = JSB_MAKE_PRIVATE_OBJECT(cc::gfx::TextureSubresLayers); + auto cobj = ptr->get(); if (argc > 0 && !args[0].isUndefined()) { ok &= sevalue_to_native(args[0], &(cobj->mipLevel), nullptr); } @@ -1873,28 +1807,17 @@ static bool js_gfx_TextureSubresLayers_constructor(se::State& s) // NOLINT(reada } if(!ok) { - JSB_FREE(cobj); + delete ptr; SE_REPORT_ERROR("Argument convertion error"); return false; } - - s.thisObject()->setPrivateData(cobj); - se::NonRefNativePtrCreatedByCtorMap::emplace(cobj); + s.thisObject()->setPrivateObject(ptr); return true; } SE_BIND_CTOR(js_gfx_TextureSubresLayers_constructor, __jsb_cc_gfx_TextureSubresLayers_class, js_cc_gfx_TextureSubresLayers_finalize) - - static bool js_cc_gfx_TextureSubresLayers_finalize(se::State& s) // NOLINT(readability-identifier-naming) { - auto iter = se::NonRefNativePtrCreatedByCtorMap::find(SE_THIS_OBJECT(s)); - if (iter != se::NonRefNativePtrCreatedByCtorMap::end()) - { - se::NonRefNativePtrCreatedByCtorMap::erase(iter); - auto* cobj = SE_THIS_OBJECT(s); - JSB_FREE(cobj); - } return true; } SE_BIND_FINALIZE_FUNC(js_cc_gfx_TextureSubresLayers_finalize) @@ -1913,11 +1836,12 @@ bool js_register_gfx_TextureSubresLayers(se::Object* obj) // NOLINT(readability- __jsb_cc_gfx_TextureSubresLayers_proto = cls->getProto(); __jsb_cc_gfx_TextureSubresLayers_class = cls; + se::ScriptEngine::getInstance()->clearException(); return true; } -se::Object* __jsb_cc_gfx_TextureSubresRange_proto = nullptr; -se::Class* __jsb_cc_gfx_TextureSubresRange_class = nullptr; +se::Object* __jsb_cc_gfx_TextureSubresRange_proto = nullptr; // NOLINT +se::Class* __jsb_cc_gfx_TextureSubresRange_class = nullptr; // NOLINT static bool js_gfx_TextureSubresRange_get_baseMipLevel(se::State& s) // NOLINT(readability-identifier-naming) { @@ -2040,19 +1964,19 @@ bool sevalue_to_native(const se::Value &from, cc::gfx::TextureSubresRange * to, } se::Value field; bool ok = true; - json->getProperty("baseMipLevel", &field); + json->getProperty("baseMipLevel", &field, true); if(!field.isNullOrUndefined()) { ok &= sevalue_to_native(field, &(to->baseMipLevel), ctx); } - json->getProperty("levelCount", &field); + json->getProperty("levelCount", &field, true); if(!field.isNullOrUndefined()) { ok &= sevalue_to_native(field, &(to->levelCount), ctx); } - json->getProperty("baseArrayLayer", &field); + json->getProperty("baseArrayLayer", &field, true); if(!field.isNullOrUndefined()) { ok &= sevalue_to_native(field, &(to->baseArrayLayer), ctx); } - json->getProperty("layerCount", &field); + json->getProperty("layerCount", &field, true); if(!field.isNullOrUndefined()) { ok &= sevalue_to_native(field, &(to->layerCount), ctx); } @@ -2069,9 +1993,8 @@ static bool js_gfx_TextureSubresRange_constructor(se::State& s) // NOLINT(readab if(argc == 0) { - cc::gfx::TextureSubresRange* cobj = JSB_ALLOC(cc::gfx::TextureSubresRange); - s.thisObject()->setPrivateData(cobj); - se::NonRefNativePtrCreatedByCtorMap::emplace(cobj); + auto *ptr = JSB_MAKE_PRIVATE_OBJECT(cc::gfx::TextureSubresRange); + s.thisObject()->setPrivateObject(ptr); return true; } @@ -2079,21 +2002,19 @@ static bool js_gfx_TextureSubresRange_constructor(se::State& s) // NOLINT(readab { se::Object *json = args[0].toObject(); se::Value field; - - cc::gfx::TextureSubresRange* cobj = JSB_ALLOC(cc::gfx::TextureSubresRange); + auto *ptr = JSB_MAKE_PRIVATE_OBJECT(cc::gfx::TextureSubresRange); + auto cobj = ptr->get(); ok &= sevalue_to_native(args[0], cobj, s.thisObject()); if(!ok) { - JSB_FREE(cobj); + delete ptr; SE_REPORT_ERROR("argument convertion error"); return false; } - - s.thisObject()->setPrivateData(cobj); - se::NonRefNativePtrCreatedByCtorMap::emplace(cobj); + s.thisObject()->setPrivateObject(ptr); return true; } - - cc::gfx::TextureSubresRange* cobj = JSB_ALLOC(cc::gfx::TextureSubresRange); + auto *ptr = JSB_MAKE_PRIVATE_OBJECT(cc::gfx::TextureSubresRange); + auto cobj = ptr->get(); if (argc > 0 && !args[0].isUndefined()) { ok &= sevalue_to_native(args[0], &(cobj->baseMipLevel), nullptr); } @@ -2108,28 +2029,17 @@ static bool js_gfx_TextureSubresRange_constructor(se::State& s) // NOLINT(readab } if(!ok) { - JSB_FREE(cobj); + delete ptr; SE_REPORT_ERROR("Argument convertion error"); return false; } - - s.thisObject()->setPrivateData(cobj); - se::NonRefNativePtrCreatedByCtorMap::emplace(cobj); + s.thisObject()->setPrivateObject(ptr); return true; } SE_BIND_CTOR(js_gfx_TextureSubresRange_constructor, __jsb_cc_gfx_TextureSubresRange_class, js_cc_gfx_TextureSubresRange_finalize) - - static bool js_cc_gfx_TextureSubresRange_finalize(se::State& s) // NOLINT(readability-identifier-naming) { - auto iter = se::NonRefNativePtrCreatedByCtorMap::find(SE_THIS_OBJECT(s)); - if (iter != se::NonRefNativePtrCreatedByCtorMap::end()) - { - se::NonRefNativePtrCreatedByCtorMap::erase(iter); - auto* cobj = SE_THIS_OBJECT(s); - JSB_FREE(cobj); - } return true; } SE_BIND_FINALIZE_FUNC(js_cc_gfx_TextureSubresRange_finalize) @@ -2149,11 +2059,12 @@ bool js_register_gfx_TextureSubresRange(se::Object* obj) // NOLINT(readability-i __jsb_cc_gfx_TextureSubresRange_proto = cls->getProto(); __jsb_cc_gfx_TextureSubresRange_class = cls; + se::ScriptEngine::getInstance()->clearException(); return true; } -se::Object* __jsb_cc_gfx_TextureCopy_proto = nullptr; -se::Class* __jsb_cc_gfx_TextureCopy_class = nullptr; +se::Object* __jsb_cc_gfx_TextureCopy_proto = nullptr; // NOLINT +se::Class* __jsb_cc_gfx_TextureCopy_class = nullptr; // NOLINT static bool js_gfx_TextureCopy_get_srcSubres(se::State& s) // NOLINT(readability-identifier-naming) { @@ -2303,23 +2214,23 @@ bool sevalue_to_native(const se::Value &from, cc::gfx::TextureCopy * to, se::Obj } se::Value field; bool ok = true; - json->getProperty("srcSubres", &field); + json->getProperty("srcSubres", &field, true); if(!field.isNullOrUndefined()) { ok &= sevalue_to_native(field, &(to->srcSubres), ctx); } - json->getProperty("srcOffset", &field); + json->getProperty("srcOffset", &field, true); if(!field.isNullOrUndefined()) { ok &= sevalue_to_native(field, &(to->srcOffset), ctx); } - json->getProperty("dstSubres", &field); + json->getProperty("dstSubres", &field, true); if(!field.isNullOrUndefined()) { ok &= sevalue_to_native(field, &(to->dstSubres), ctx); } - json->getProperty("dstOffset", &field); + json->getProperty("dstOffset", &field, true); if(!field.isNullOrUndefined()) { ok &= sevalue_to_native(field, &(to->dstOffset), ctx); } - json->getProperty("extent", &field); + json->getProperty("extent", &field, true); if(!field.isNullOrUndefined()) { ok &= sevalue_to_native(field, &(to->extent), ctx); } @@ -2336,9 +2247,8 @@ static bool js_gfx_TextureCopy_constructor(se::State& s) // NOLINT(readability-i if(argc == 0) { - cc::gfx::TextureCopy* cobj = JSB_ALLOC(cc::gfx::TextureCopy); - s.thisObject()->setPrivateData(cobj); - se::NonRefNativePtrCreatedByCtorMap::emplace(cobj); + auto *ptr = JSB_MAKE_PRIVATE_OBJECT(cc::gfx::TextureCopy); + s.thisObject()->setPrivateObject(ptr); return true; } @@ -2346,21 +2256,19 @@ static bool js_gfx_TextureCopy_constructor(se::State& s) // NOLINT(readability-i { se::Object *json = args[0].toObject(); se::Value field; - - cc::gfx::TextureCopy* cobj = JSB_ALLOC(cc::gfx::TextureCopy); + auto *ptr = JSB_MAKE_PRIVATE_OBJECT(cc::gfx::TextureCopy); + auto cobj = ptr->get(); ok &= sevalue_to_native(args[0], cobj, s.thisObject()); if(!ok) { - JSB_FREE(cobj); + delete ptr; SE_REPORT_ERROR("argument convertion error"); return false; } - - s.thisObject()->setPrivateData(cobj); - se::NonRefNativePtrCreatedByCtorMap::emplace(cobj); + s.thisObject()->setPrivateObject(ptr); return true; } - - cc::gfx::TextureCopy* cobj = JSB_ALLOC(cc::gfx::TextureCopy); + auto *ptr = JSB_MAKE_PRIVATE_OBJECT(cc::gfx::TextureCopy); + auto cobj = ptr->get(); if (argc > 0 && !args[0].isUndefined()) { ok &= sevalue_to_native(args[0], &(cobj->srcSubres), nullptr); } @@ -2378,28 +2286,17 @@ static bool js_gfx_TextureCopy_constructor(se::State& s) // NOLINT(readability-i } if(!ok) { - JSB_FREE(cobj); + delete ptr; SE_REPORT_ERROR("Argument convertion error"); return false; } - - s.thisObject()->setPrivateData(cobj); - se::NonRefNativePtrCreatedByCtorMap::emplace(cobj); + s.thisObject()->setPrivateObject(ptr); return true; } SE_BIND_CTOR(js_gfx_TextureCopy_constructor, __jsb_cc_gfx_TextureCopy_class, js_cc_gfx_TextureCopy_finalize) - - static bool js_cc_gfx_TextureCopy_finalize(se::State& s) // NOLINT(readability-identifier-naming) { - auto iter = se::NonRefNativePtrCreatedByCtorMap::find(SE_THIS_OBJECT(s)); - if (iter != se::NonRefNativePtrCreatedByCtorMap::end()) - { - se::NonRefNativePtrCreatedByCtorMap::erase(iter); - auto* cobj = SE_THIS_OBJECT(s); - JSB_FREE(cobj); - } return true; } SE_BIND_FINALIZE_FUNC(js_cc_gfx_TextureCopy_finalize) @@ -2420,11 +2317,12 @@ bool js_register_gfx_TextureCopy(se::Object* obj) // NOLINT(readability-identifi __jsb_cc_gfx_TextureCopy_proto = cls->getProto(); __jsb_cc_gfx_TextureCopy_class = cls; + se::ScriptEngine::getInstance()->clearException(); return true; } -se::Object* __jsb_cc_gfx_TextureBlit_proto = nullptr; -se::Class* __jsb_cc_gfx_TextureBlit_class = nullptr; +se::Object* __jsb_cc_gfx_TextureBlit_proto = nullptr; // NOLINT +se::Class* __jsb_cc_gfx_TextureBlit_class = nullptr; // NOLINT static bool js_gfx_TextureBlit_get_srcSubres(se::State& s) // NOLINT(readability-identifier-naming) { @@ -2601,27 +2499,27 @@ bool sevalue_to_native(const se::Value &from, cc::gfx::TextureBlit * to, se::Obj } se::Value field; bool ok = true; - json->getProperty("srcSubres", &field); + json->getProperty("srcSubres", &field, true); if(!field.isNullOrUndefined()) { ok &= sevalue_to_native(field, &(to->srcSubres), ctx); } - json->getProperty("srcOffset", &field); + json->getProperty("srcOffset", &field, true); if(!field.isNullOrUndefined()) { ok &= sevalue_to_native(field, &(to->srcOffset), ctx); } - json->getProperty("srcExtent", &field); + json->getProperty("srcExtent", &field, true); if(!field.isNullOrUndefined()) { ok &= sevalue_to_native(field, &(to->srcExtent), ctx); } - json->getProperty("dstSubres", &field); + json->getProperty("dstSubres", &field, true); if(!field.isNullOrUndefined()) { ok &= sevalue_to_native(field, &(to->dstSubres), ctx); } - json->getProperty("dstOffset", &field); + json->getProperty("dstOffset", &field, true); if(!field.isNullOrUndefined()) { ok &= sevalue_to_native(field, &(to->dstOffset), ctx); } - json->getProperty("dstExtent", &field); + json->getProperty("dstExtent", &field, true); if(!field.isNullOrUndefined()) { ok &= sevalue_to_native(field, &(to->dstExtent), ctx); } @@ -2638,9 +2536,8 @@ static bool js_gfx_TextureBlit_constructor(se::State& s) // NOLINT(readability-i if(argc == 0) { - cc::gfx::TextureBlit* cobj = JSB_ALLOC(cc::gfx::TextureBlit); - s.thisObject()->setPrivateData(cobj); - se::NonRefNativePtrCreatedByCtorMap::emplace(cobj); + auto *ptr = JSB_MAKE_PRIVATE_OBJECT(cc::gfx::TextureBlit); + s.thisObject()->setPrivateObject(ptr); return true; } @@ -2648,21 +2545,19 @@ static bool js_gfx_TextureBlit_constructor(se::State& s) // NOLINT(readability-i { se::Object *json = args[0].toObject(); se::Value field; - - cc::gfx::TextureBlit* cobj = JSB_ALLOC(cc::gfx::TextureBlit); + auto *ptr = JSB_MAKE_PRIVATE_OBJECT(cc::gfx::TextureBlit); + auto cobj = ptr->get(); ok &= sevalue_to_native(args[0], cobj, s.thisObject()); if(!ok) { - JSB_FREE(cobj); + delete ptr; SE_REPORT_ERROR("argument convertion error"); return false; } - - s.thisObject()->setPrivateData(cobj); - se::NonRefNativePtrCreatedByCtorMap::emplace(cobj); + s.thisObject()->setPrivateObject(ptr); return true; } - - cc::gfx::TextureBlit* cobj = JSB_ALLOC(cc::gfx::TextureBlit); + auto *ptr = JSB_MAKE_PRIVATE_OBJECT(cc::gfx::TextureBlit); + auto cobj = ptr->get(); if (argc > 0 && !args[0].isUndefined()) { ok &= sevalue_to_native(args[0], &(cobj->srcSubres), nullptr); } @@ -2683,28 +2578,17 @@ static bool js_gfx_TextureBlit_constructor(se::State& s) // NOLINT(readability-i } if(!ok) { - JSB_FREE(cobj); + delete ptr; SE_REPORT_ERROR("Argument convertion error"); return false; } - - s.thisObject()->setPrivateData(cobj); - se::NonRefNativePtrCreatedByCtorMap::emplace(cobj); + s.thisObject()->setPrivateObject(ptr); return true; } SE_BIND_CTOR(js_gfx_TextureBlit_constructor, __jsb_cc_gfx_TextureBlit_class, js_cc_gfx_TextureBlit_finalize) - - static bool js_cc_gfx_TextureBlit_finalize(se::State& s) // NOLINT(readability-identifier-naming) { - auto iter = se::NonRefNativePtrCreatedByCtorMap::find(SE_THIS_OBJECT(s)); - if (iter != se::NonRefNativePtrCreatedByCtorMap::end()) - { - se::NonRefNativePtrCreatedByCtorMap::erase(iter); - auto* cobj = SE_THIS_OBJECT(s); - JSB_FREE(cobj); - } return true; } SE_BIND_FINALIZE_FUNC(js_cc_gfx_TextureBlit_finalize) @@ -2726,11 +2610,12 @@ bool js_register_gfx_TextureBlit(se::Object* obj) // NOLINT(readability-identifi __jsb_cc_gfx_TextureBlit_proto = cls->getProto(); __jsb_cc_gfx_TextureBlit_class = cls; + se::ScriptEngine::getInstance()->clearException(); return true; } -se::Object* __jsb_cc_gfx_BufferTextureCopy_proto = nullptr; -se::Class* __jsb_cc_gfx_BufferTextureCopy_class = nullptr; +se::Object* __jsb_cc_gfx_BufferTextureCopy_proto = nullptr; // NOLINT +se::Class* __jsb_cc_gfx_BufferTextureCopy_class = nullptr; // NOLINT static bool js_gfx_BufferTextureCopy_get_buffStride(se::State& s) // NOLINT(readability-identifier-naming) { @@ -2880,23 +2765,23 @@ bool sevalue_to_native(const se::Value &from, cc::gfx::BufferTextureCopy * to, s } se::Value field; bool ok = true; - json->getProperty("buffStride", &field); + json->getProperty("buffStride", &field, true); if(!field.isNullOrUndefined()) { ok &= sevalue_to_native(field, &(to->buffStride), ctx); } - json->getProperty("buffTexHeight", &field); + json->getProperty("buffTexHeight", &field, true); if(!field.isNullOrUndefined()) { ok &= sevalue_to_native(field, &(to->buffTexHeight), ctx); } - json->getProperty("texOffset", &field); + json->getProperty("texOffset", &field, true); if(!field.isNullOrUndefined()) { ok &= sevalue_to_native(field, &(to->texOffset), ctx); } - json->getProperty("texExtent", &field); + json->getProperty("texExtent", &field, true); if(!field.isNullOrUndefined()) { ok &= sevalue_to_native(field, &(to->texExtent), ctx); } - json->getProperty("texSubres", &field); + json->getProperty("texSubres", &field, true); if(!field.isNullOrUndefined()) { ok &= sevalue_to_native(field, &(to->texSubres), ctx); } @@ -2913,9 +2798,8 @@ static bool js_gfx_BufferTextureCopy_constructor(se::State& s) // NOLINT(readabi if(argc == 0) { - cc::gfx::BufferTextureCopy* cobj = JSB_ALLOC(cc::gfx::BufferTextureCopy); - s.thisObject()->setPrivateData(cobj); - se::NonRefNativePtrCreatedByCtorMap::emplace(cobj); + auto *ptr = JSB_MAKE_PRIVATE_OBJECT(cc::gfx::BufferTextureCopy); + s.thisObject()->setPrivateObject(ptr); return true; } @@ -2923,21 +2807,19 @@ static bool js_gfx_BufferTextureCopy_constructor(se::State& s) // NOLINT(readabi { se::Object *json = args[0].toObject(); se::Value field; - - cc::gfx::BufferTextureCopy* cobj = JSB_ALLOC(cc::gfx::BufferTextureCopy); + auto *ptr = JSB_MAKE_PRIVATE_OBJECT(cc::gfx::BufferTextureCopy); + auto cobj = ptr->get(); ok &= sevalue_to_native(args[0], cobj, s.thisObject()); if(!ok) { - JSB_FREE(cobj); + delete ptr; SE_REPORT_ERROR("argument convertion error"); return false; } - - s.thisObject()->setPrivateData(cobj); - se::NonRefNativePtrCreatedByCtorMap::emplace(cobj); + s.thisObject()->setPrivateObject(ptr); return true; } - - cc::gfx::BufferTextureCopy* cobj = JSB_ALLOC(cc::gfx::BufferTextureCopy); + auto *ptr = JSB_MAKE_PRIVATE_OBJECT(cc::gfx::BufferTextureCopy); + auto cobj = ptr->get(); if (argc > 0 && !args[0].isUndefined()) { ok &= sevalue_to_native(args[0], &(cobj->buffStride), nullptr); } @@ -2955,28 +2837,17 @@ static bool js_gfx_BufferTextureCopy_constructor(se::State& s) // NOLINT(readabi } if(!ok) { - JSB_FREE(cobj); + delete ptr; SE_REPORT_ERROR("Argument convertion error"); return false; } - - s.thisObject()->setPrivateData(cobj); - se::NonRefNativePtrCreatedByCtorMap::emplace(cobj); + s.thisObject()->setPrivateObject(ptr); return true; } SE_BIND_CTOR(js_gfx_BufferTextureCopy_constructor, __jsb_cc_gfx_BufferTextureCopy_class, js_cc_gfx_BufferTextureCopy_finalize) - - static bool js_cc_gfx_BufferTextureCopy_finalize(se::State& s) // NOLINT(readability-identifier-naming) { - auto iter = se::NonRefNativePtrCreatedByCtorMap::find(SE_THIS_OBJECT(s)); - if (iter != se::NonRefNativePtrCreatedByCtorMap::end()) - { - se::NonRefNativePtrCreatedByCtorMap::erase(iter); - auto* cobj = SE_THIS_OBJECT(s); - JSB_FREE(cobj); - } return true; } SE_BIND_FINALIZE_FUNC(js_cc_gfx_BufferTextureCopy_finalize) @@ -2997,11 +2868,12 @@ bool js_register_gfx_BufferTextureCopy(se::Object* obj) // NOLINT(readability-id __jsb_cc_gfx_BufferTextureCopy_proto = cls->getProto(); __jsb_cc_gfx_BufferTextureCopy_class = cls; + se::ScriptEngine::getInstance()->clearException(); return true; } -se::Object* __jsb_cc_gfx_Viewport_proto = nullptr; -se::Class* __jsb_cc_gfx_Viewport_class = nullptr; +se::Object* __jsb_cc_gfx_Viewport_proto = nullptr; // NOLINT +se::Class* __jsb_cc_gfx_Viewport_class = nullptr; // NOLINT static bool js_gfx_Viewport_get_left(se::State& s) // NOLINT(readability-identifier-naming) { @@ -3178,27 +3050,27 @@ bool sevalue_to_native(const se::Value &from, cc::gfx::Viewport * to, se::Object } se::Value field; bool ok = true; - json->getProperty("left", &field); + json->getProperty("left", &field, true); if(!field.isNullOrUndefined()) { ok &= sevalue_to_native(field, &(to->left), ctx); } - json->getProperty("top", &field); + json->getProperty("top", &field, true); if(!field.isNullOrUndefined()) { ok &= sevalue_to_native(field, &(to->top), ctx); } - json->getProperty("width", &field); + json->getProperty("width", &field, true); if(!field.isNullOrUndefined()) { ok &= sevalue_to_native(field, &(to->width), ctx); } - json->getProperty("height", &field); + json->getProperty("height", &field, true); if(!field.isNullOrUndefined()) { ok &= sevalue_to_native(field, &(to->height), ctx); } - json->getProperty("minDepth", &field); + json->getProperty("minDepth", &field, true); if(!field.isNullOrUndefined()) { ok &= sevalue_to_native(field, &(to->minDepth), ctx); } - json->getProperty("maxDepth", &field); + json->getProperty("maxDepth", &field, true); if(!field.isNullOrUndefined()) { ok &= sevalue_to_native(field, &(to->maxDepth), ctx); } @@ -3215,9 +3087,8 @@ static bool js_gfx_Viewport_constructor(se::State& s) // NOLINT(readability-iden if(argc == 0) { - cc::gfx::Viewport* cobj = JSB_ALLOC(cc::gfx::Viewport); - s.thisObject()->setPrivateData(cobj); - se::NonRefNativePtrCreatedByCtorMap::emplace(cobj); + auto *ptr = JSB_MAKE_PRIVATE_OBJECT(cc::gfx::Viewport); + s.thisObject()->setPrivateObject(ptr); return true; } @@ -3225,21 +3096,19 @@ static bool js_gfx_Viewport_constructor(se::State& s) // NOLINT(readability-iden { se::Object *json = args[0].toObject(); se::Value field; - - cc::gfx::Viewport* cobj = JSB_ALLOC(cc::gfx::Viewport); + auto *ptr = JSB_MAKE_PRIVATE_OBJECT(cc::gfx::Viewport); + auto cobj = ptr->get(); ok &= sevalue_to_native(args[0], cobj, s.thisObject()); if(!ok) { - JSB_FREE(cobj); + delete ptr; SE_REPORT_ERROR("argument convertion error"); return false; } - - s.thisObject()->setPrivateData(cobj); - se::NonRefNativePtrCreatedByCtorMap::emplace(cobj); + s.thisObject()->setPrivateObject(ptr); return true; } - - cc::gfx::Viewport* cobj = JSB_ALLOC(cc::gfx::Viewport); + auto *ptr = JSB_MAKE_PRIVATE_OBJECT(cc::gfx::Viewport); + auto cobj = ptr->get(); if (argc > 0 && !args[0].isUndefined()) { ok &= sevalue_to_native(args[0], &(cobj->left), nullptr); } @@ -3260,28 +3129,17 @@ static bool js_gfx_Viewport_constructor(se::State& s) // NOLINT(readability-iden } if(!ok) { - JSB_FREE(cobj); + delete ptr; SE_REPORT_ERROR("Argument convertion error"); return false; } - - s.thisObject()->setPrivateData(cobj); - se::NonRefNativePtrCreatedByCtorMap::emplace(cobj); + s.thisObject()->setPrivateObject(ptr); return true; } SE_BIND_CTOR(js_gfx_Viewport_constructor, __jsb_cc_gfx_Viewport_class, js_cc_gfx_Viewport_finalize) - - static bool js_cc_gfx_Viewport_finalize(se::State& s) // NOLINT(readability-identifier-naming) { - auto iter = se::NonRefNativePtrCreatedByCtorMap::find(SE_THIS_OBJECT(s)); - if (iter != se::NonRefNativePtrCreatedByCtorMap::end()) - { - se::NonRefNativePtrCreatedByCtorMap::erase(iter); - auto* cobj = SE_THIS_OBJECT(s); - JSB_FREE(cobj); - } return true; } SE_BIND_FINALIZE_FUNC(js_cc_gfx_Viewport_finalize) @@ -3303,11 +3161,12 @@ bool js_register_gfx_Viewport(se::Object* obj) // NOLINT(readability-identifier- __jsb_cc_gfx_Viewport_proto = cls->getProto(); __jsb_cc_gfx_Viewport_class = cls; + se::ScriptEngine::getInstance()->clearException(); return true; } -se::Object* __jsb_cc_gfx_Color_proto = nullptr; -se::Class* __jsb_cc_gfx_Color_class = nullptr; +se::Object* __jsb_cc_gfx_Color_proto = nullptr; // NOLINT +se::Class* __jsb_cc_gfx_Color_class = nullptr; // NOLINT static bool js_gfx_Color_get_x(se::State& s) // NOLINT(readability-identifier-naming) { @@ -3430,19 +3289,19 @@ bool sevalue_to_native(const se::Value &from, cc::gfx::Color * to, se::Object *c } se::Value field; bool ok = true; - json->getProperty("x", &field); + json->getProperty("x", &field, true); if(!field.isNullOrUndefined()) { ok &= sevalue_to_native(field, &(to->x), ctx); } - json->getProperty("y", &field); + json->getProperty("y", &field, true); if(!field.isNullOrUndefined()) { ok &= sevalue_to_native(field, &(to->y), ctx); } - json->getProperty("z", &field); + json->getProperty("z", &field, true); if(!field.isNullOrUndefined()) { ok &= sevalue_to_native(field, &(to->z), ctx); } - json->getProperty("w", &field); + json->getProperty("w", &field, true); if(!field.isNullOrUndefined()) { ok &= sevalue_to_native(field, &(to->w), ctx); } @@ -3459,9 +3318,8 @@ static bool js_gfx_Color_constructor(se::State& s) // NOLINT(readability-identif if(argc == 0) { - cc::gfx::Color* cobj = JSB_ALLOC(cc::gfx::Color); - s.thisObject()->setPrivateData(cobj); - se::NonRefNativePtrCreatedByCtorMap::emplace(cobj); + auto *ptr = JSB_MAKE_PRIVATE_OBJECT(cc::gfx::Color); + s.thisObject()->setPrivateObject(ptr); return true; } @@ -3469,21 +3327,19 @@ static bool js_gfx_Color_constructor(se::State& s) // NOLINT(readability-identif { se::Object *json = args[0].toObject(); se::Value field; - - cc::gfx::Color* cobj = JSB_ALLOC(cc::gfx::Color); + auto *ptr = JSB_MAKE_PRIVATE_OBJECT(cc::gfx::Color); + auto cobj = ptr->get(); ok &= sevalue_to_native(args[0], cobj, s.thisObject()); if(!ok) { - JSB_FREE(cobj); + delete ptr; SE_REPORT_ERROR("argument convertion error"); return false; } - - s.thisObject()->setPrivateData(cobj); - se::NonRefNativePtrCreatedByCtorMap::emplace(cobj); + s.thisObject()->setPrivateObject(ptr); return true; } - - cc::gfx::Color* cobj = JSB_ALLOC(cc::gfx::Color); + auto *ptr = JSB_MAKE_PRIVATE_OBJECT(cc::gfx::Color); + auto cobj = ptr->get(); if (argc > 0 && !args[0].isUndefined()) { ok &= sevalue_to_native(args[0], &(cobj->x), nullptr); } @@ -3498,28 +3354,17 @@ static bool js_gfx_Color_constructor(se::State& s) // NOLINT(readability-identif } if(!ok) { - JSB_FREE(cobj); + delete ptr; SE_REPORT_ERROR("Argument convertion error"); return false; } - - s.thisObject()->setPrivateData(cobj); - se::NonRefNativePtrCreatedByCtorMap::emplace(cobj); + s.thisObject()->setPrivateObject(ptr); return true; } SE_BIND_CTOR(js_gfx_Color_constructor, __jsb_cc_gfx_Color_class, js_cc_gfx_Color_finalize) - - static bool js_cc_gfx_Color_finalize(se::State& s) // NOLINT(readability-identifier-naming) { - auto iter = se::NonRefNativePtrCreatedByCtorMap::find(SE_THIS_OBJECT(s)); - if (iter != se::NonRefNativePtrCreatedByCtorMap::end()) - { - se::NonRefNativePtrCreatedByCtorMap::erase(iter); - auto* cobj = SE_THIS_OBJECT(s); - JSB_FREE(cobj); - } return true; } SE_BIND_FINALIZE_FUNC(js_cc_gfx_Color_finalize) @@ -3539,11 +3384,12 @@ bool js_register_gfx_Color(se::Object* obj) // NOLINT(readability-identifier-nam __jsb_cc_gfx_Color_proto = cls->getProto(); __jsb_cc_gfx_Color_class = cls; + se::ScriptEngine::getInstance()->clearException(); return true; } -se::Object* __jsb_cc_gfx_BindingMappingInfo_proto = nullptr; -se::Class* __jsb_cc_gfx_BindingMappingInfo_class = nullptr; +se::Object* __jsb_cc_gfx_BindingMappingInfo_proto = nullptr; // NOLINT +se::Class* __jsb_cc_gfx_BindingMappingInfo_class = nullptr; // NOLINT static bool js_gfx_BindingMappingInfo_get_bufferOffsets(se::State& s) // NOLINT(readability-identifier-naming) { @@ -3639,15 +3485,15 @@ bool sevalue_to_native(const se::Value &from, cc::gfx::BindingMappingInfo * to, } se::Value field; bool ok = true; - json->getProperty("bufferOffsets", &field); + json->getProperty("bufferOffsets", &field, true); if(!field.isNullOrUndefined()) { ok &= sevalue_to_native(field, &(to->bufferOffsets), ctx); } - json->getProperty("samplerOffsets", &field); + json->getProperty("samplerOffsets", &field, true); if(!field.isNullOrUndefined()) { ok &= sevalue_to_native(field, &(to->samplerOffsets), ctx); } - json->getProperty("flexibleSet", &field); + json->getProperty("flexibleSet", &field, true); if(!field.isNullOrUndefined()) { ok &= sevalue_to_native(field, &(to->flexibleSet), ctx); } @@ -3664,9 +3510,8 @@ static bool js_gfx_BindingMappingInfo_constructor(se::State& s) // NOLINT(readab if(argc == 0) { - cc::gfx::BindingMappingInfo* cobj = JSB_ALLOC(cc::gfx::BindingMappingInfo); - s.thisObject()->setPrivateData(cobj); - se::NonRefNativePtrCreatedByCtorMap::emplace(cobj); + auto *ptr = JSB_MAKE_PRIVATE_OBJECT(cc::gfx::BindingMappingInfo); + s.thisObject()->setPrivateObject(ptr); return true; } @@ -3674,21 +3519,19 @@ static bool js_gfx_BindingMappingInfo_constructor(se::State& s) // NOLINT(readab { se::Object *json = args[0].toObject(); se::Value field; - - cc::gfx::BindingMappingInfo* cobj = JSB_ALLOC(cc::gfx::BindingMappingInfo); + auto *ptr = JSB_MAKE_PRIVATE_OBJECT(cc::gfx::BindingMappingInfo); + auto cobj = ptr->get(); ok &= sevalue_to_native(args[0], cobj, s.thisObject()); if(!ok) { - JSB_FREE(cobj); + delete ptr; SE_REPORT_ERROR("argument convertion error"); return false; } - - s.thisObject()->setPrivateData(cobj); - se::NonRefNativePtrCreatedByCtorMap::emplace(cobj); + s.thisObject()->setPrivateObject(ptr); return true; } - - cc::gfx::BindingMappingInfo* cobj = JSB_ALLOC(cc::gfx::BindingMappingInfo); + auto *ptr = JSB_MAKE_PRIVATE_OBJECT(cc::gfx::BindingMappingInfo); + auto cobj = ptr->get(); if (argc > 0 && !args[0].isUndefined()) { ok &= sevalue_to_native(args[0], &(cobj->bufferOffsets), nullptr); } @@ -3700,28 +3543,17 @@ static bool js_gfx_BindingMappingInfo_constructor(se::State& s) // NOLINT(readab } if(!ok) { - JSB_FREE(cobj); + delete ptr; SE_REPORT_ERROR("Argument convertion error"); return false; } - - s.thisObject()->setPrivateData(cobj); - se::NonRefNativePtrCreatedByCtorMap::emplace(cobj); + s.thisObject()->setPrivateObject(ptr); return true; } SE_BIND_CTOR(js_gfx_BindingMappingInfo_constructor, __jsb_cc_gfx_BindingMappingInfo_class, js_cc_gfx_BindingMappingInfo_finalize) - - static bool js_cc_gfx_BindingMappingInfo_finalize(se::State& s) // NOLINT(readability-identifier-naming) { - auto iter = se::NonRefNativePtrCreatedByCtorMap::find(SE_THIS_OBJECT(s)); - if (iter != se::NonRefNativePtrCreatedByCtorMap::end()) - { - se::NonRefNativePtrCreatedByCtorMap::erase(iter); - auto* cobj = SE_THIS_OBJECT(s); - JSB_FREE(cobj); - } return true; } SE_BIND_FINALIZE_FUNC(js_cc_gfx_BindingMappingInfo_finalize) @@ -3740,11 +3572,12 @@ bool js_register_gfx_BindingMappingInfo(se::Object* obj) // NOLINT(readability-i __jsb_cc_gfx_BindingMappingInfo_proto = cls->getProto(); __jsb_cc_gfx_BindingMappingInfo_class = cls; + se::ScriptEngine::getInstance()->clearException(); return true; } -se::Object* __jsb_cc_gfx_SwapchainInfo_proto = nullptr; -se::Class* __jsb_cc_gfx_SwapchainInfo_class = nullptr; +se::Object* __jsb_cc_gfx_SwapchainInfo_proto = nullptr; // NOLINT +se::Class* __jsb_cc_gfx_SwapchainInfo_class = nullptr; // NOLINT static bool js_gfx_SwapchainInfo_get_windowHandle(se::State& s) // NOLINT(readability-identifier-naming) { @@ -3867,19 +3700,19 @@ bool sevalue_to_native(const se::Value &from, cc::gfx::SwapchainInfo * to, se::O } se::Value field; bool ok = true; - json->getProperty("windowHandle", &field); + json->getProperty("windowHandle", &field, true); if(!field.isNullOrUndefined()) { ok &= sevalue_to_native(field, &(to->windowHandle), ctx); } - json->getProperty("vsyncMode", &field); + json->getProperty("vsyncMode", &field, true); if(!field.isNullOrUndefined()) { ok &= sevalue_to_native(field, &(to->vsyncMode), ctx); } - json->getProperty("width", &field); + json->getProperty("width", &field, true); if(!field.isNullOrUndefined()) { ok &= sevalue_to_native(field, &(to->width), ctx); } - json->getProperty("height", &field); + json->getProperty("height", &field, true); if(!field.isNullOrUndefined()) { ok &= sevalue_to_native(field, &(to->height), ctx); } @@ -3896,9 +3729,8 @@ static bool js_gfx_SwapchainInfo_constructor(se::State& s) // NOLINT(readability if(argc == 0) { - cc::gfx::SwapchainInfo* cobj = JSB_ALLOC(cc::gfx::SwapchainInfo); - s.thisObject()->setPrivateData(cobj); - se::NonRefNativePtrCreatedByCtorMap::emplace(cobj); + auto *ptr = JSB_MAKE_PRIVATE_OBJECT(cc::gfx::SwapchainInfo); + s.thisObject()->setPrivateObject(ptr); return true; } @@ -3906,21 +3738,19 @@ static bool js_gfx_SwapchainInfo_constructor(se::State& s) // NOLINT(readability { se::Object *json = args[0].toObject(); se::Value field; - - cc::gfx::SwapchainInfo* cobj = JSB_ALLOC(cc::gfx::SwapchainInfo); + auto *ptr = JSB_MAKE_PRIVATE_OBJECT(cc::gfx::SwapchainInfo); + auto cobj = ptr->get(); ok &= sevalue_to_native(args[0], cobj, s.thisObject()); if(!ok) { - JSB_FREE(cobj); + delete ptr; SE_REPORT_ERROR("argument convertion error"); return false; } - - s.thisObject()->setPrivateData(cobj); - se::NonRefNativePtrCreatedByCtorMap::emplace(cobj); + s.thisObject()->setPrivateObject(ptr); return true; } - - cc::gfx::SwapchainInfo* cobj = JSB_ALLOC(cc::gfx::SwapchainInfo); + auto *ptr = JSB_MAKE_PRIVATE_OBJECT(cc::gfx::SwapchainInfo); + auto cobj = ptr->get(); if (argc > 0 && !args[0].isUndefined()) { ok &= sevalue_to_native(args[0], &(cobj->windowHandle), nullptr); } @@ -3935,28 +3765,17 @@ static bool js_gfx_SwapchainInfo_constructor(se::State& s) // NOLINT(readability } if(!ok) { - JSB_FREE(cobj); + delete ptr; SE_REPORT_ERROR("Argument convertion error"); return false; } - - s.thisObject()->setPrivateData(cobj); - se::NonRefNativePtrCreatedByCtorMap::emplace(cobj); + s.thisObject()->setPrivateObject(ptr); return true; } SE_BIND_CTOR(js_gfx_SwapchainInfo_constructor, __jsb_cc_gfx_SwapchainInfo_class, js_cc_gfx_SwapchainInfo_finalize) - - static bool js_cc_gfx_SwapchainInfo_finalize(se::State& s) // NOLINT(readability-identifier-naming) { - auto iter = se::NonRefNativePtrCreatedByCtorMap::find(SE_THIS_OBJECT(s)); - if (iter != se::NonRefNativePtrCreatedByCtorMap::end()) - { - se::NonRefNativePtrCreatedByCtorMap::erase(iter); - auto* cobj = SE_THIS_OBJECT(s); - JSB_FREE(cobj); - } return true; } SE_BIND_FINALIZE_FUNC(js_cc_gfx_SwapchainInfo_finalize) @@ -3976,11 +3795,12 @@ bool js_register_gfx_SwapchainInfo(se::Object* obj) // NOLINT(readability-identi __jsb_cc_gfx_SwapchainInfo_proto = cls->getProto(); __jsb_cc_gfx_SwapchainInfo_class = cls; + se::ScriptEngine::getInstance()->clearException(); return true; } -se::Object* __jsb_cc_gfx_DeviceInfo_proto = nullptr; -se::Class* __jsb_cc_gfx_DeviceInfo_class = nullptr; +se::Object* __jsb_cc_gfx_DeviceInfo_proto = nullptr; // NOLINT +se::Class* __jsb_cc_gfx_DeviceInfo_class = nullptr; // NOLINT static bool js_gfx_DeviceInfo_get_bindingMappingInfo(se::State& s) // NOLINT(readability-identifier-naming) { @@ -4022,7 +3842,7 @@ bool sevalue_to_native(const se::Value &from, cc::gfx::DeviceInfo * to, se::Obje } se::Value field; bool ok = true; - json->getProperty("bindingMappingInfo", &field); + json->getProperty("bindingMappingInfo", &field, true); if(!field.isNullOrUndefined()) { ok &= sevalue_to_native(field, &(to->bindingMappingInfo), ctx); } @@ -4039,40 +3859,28 @@ static bool js_gfx_DeviceInfo_constructor(se::State& s) // NOLINT(readability-id if(argc == 0) { - cc::gfx::DeviceInfo* cobj = JSB_ALLOC(cc::gfx::DeviceInfo); - s.thisObject()->setPrivateData(cobj); - se::NonRefNativePtrCreatedByCtorMap::emplace(cobj); + auto *ptr = JSB_MAKE_PRIVATE_OBJECT(cc::gfx::DeviceInfo); + s.thisObject()->setPrivateObject(ptr); return true; } - - cc::gfx::DeviceInfo* cobj = JSB_ALLOC(cc::gfx::DeviceInfo); + auto *ptr = JSB_MAKE_PRIVATE_OBJECT(cc::gfx::DeviceInfo); + auto cobj = ptr->get(); if (argc > 0 && !args[0].isUndefined()) { ok &= sevalue_to_native(args[0], &(cobj->bindingMappingInfo), nullptr); } if(!ok) { - JSB_FREE(cobj); + delete ptr; SE_REPORT_ERROR("Argument convertion error"); return false; } - - s.thisObject()->setPrivateData(cobj); - se::NonRefNativePtrCreatedByCtorMap::emplace(cobj); + s.thisObject()->setPrivateObject(ptr); return true; } SE_BIND_CTOR(js_gfx_DeviceInfo_constructor, __jsb_cc_gfx_DeviceInfo_class, js_cc_gfx_DeviceInfo_finalize) - - static bool js_cc_gfx_DeviceInfo_finalize(se::State& s) // NOLINT(readability-identifier-naming) { - auto iter = se::NonRefNativePtrCreatedByCtorMap::find(SE_THIS_OBJECT(s)); - if (iter != se::NonRefNativePtrCreatedByCtorMap::end()) - { - se::NonRefNativePtrCreatedByCtorMap::erase(iter); - auto* cobj = SE_THIS_OBJECT(s); - JSB_FREE(cobj); - } return true; } SE_BIND_FINALIZE_FUNC(js_cc_gfx_DeviceInfo_finalize) @@ -4089,11 +3897,12 @@ bool js_register_gfx_DeviceInfo(se::Object* obj) // NOLINT(readability-identifie __jsb_cc_gfx_DeviceInfo_proto = cls->getProto(); __jsb_cc_gfx_DeviceInfo_class = cls; + se::ScriptEngine::getInstance()->clearException(); return true; } -se::Object* __jsb_cc_gfx_BufferInfo_proto = nullptr; -se::Class* __jsb_cc_gfx_BufferInfo_class = nullptr; +se::Object* __jsb_cc_gfx_BufferInfo_proto = nullptr; // NOLINT +se::Class* __jsb_cc_gfx_BufferInfo_class = nullptr; // NOLINT static bool js_gfx_BufferInfo_get_usage(se::State& s) // NOLINT(readability-identifier-naming) { @@ -4243,23 +4052,23 @@ bool sevalue_to_native(const se::Value &from, cc::gfx::BufferInfo * to, se::Obje } se::Value field; bool ok = true; - json->getProperty("usage", &field); + json->getProperty("usage", &field, true); if(!field.isNullOrUndefined()) { ok &= sevalue_to_native(field, &(to->usage), ctx); } - json->getProperty("memUsage", &field); + json->getProperty("memUsage", &field, true); if(!field.isNullOrUndefined()) { ok &= sevalue_to_native(field, &(to->memUsage), ctx); } - json->getProperty("size", &field); + json->getProperty("size", &field, true); if(!field.isNullOrUndefined()) { ok &= sevalue_to_native(field, &(to->size), ctx); } - json->getProperty("stride", &field); + json->getProperty("stride", &field, true); if(!field.isNullOrUndefined()) { ok &= sevalue_to_native(field, &(to->stride), ctx); } - json->getProperty("flags", &field); + json->getProperty("flags", &field, true); if(!field.isNullOrUndefined()) { ok &= sevalue_to_native(field, &(to->flags), ctx); } @@ -4276,9 +4085,8 @@ static bool js_gfx_BufferInfo_constructor(se::State& s) // NOLINT(readability-id if(argc == 0) { - cc::gfx::BufferInfo* cobj = JSB_ALLOC(cc::gfx::BufferInfo); - s.thisObject()->setPrivateData(cobj); - se::NonRefNativePtrCreatedByCtorMap::emplace(cobj); + auto *ptr = JSB_MAKE_PRIVATE_OBJECT(cc::gfx::BufferInfo); + s.thisObject()->setPrivateObject(ptr); return true; } @@ -4286,21 +4094,19 @@ static bool js_gfx_BufferInfo_constructor(se::State& s) // NOLINT(readability-id { se::Object *json = args[0].toObject(); se::Value field; - - cc::gfx::BufferInfo* cobj = JSB_ALLOC(cc::gfx::BufferInfo); + auto *ptr = JSB_MAKE_PRIVATE_OBJECT(cc::gfx::BufferInfo); + auto cobj = ptr->get(); ok &= sevalue_to_native(args[0], cobj, s.thisObject()); if(!ok) { - JSB_FREE(cobj); + delete ptr; SE_REPORT_ERROR("argument convertion error"); return false; } - - s.thisObject()->setPrivateData(cobj); - se::NonRefNativePtrCreatedByCtorMap::emplace(cobj); + s.thisObject()->setPrivateObject(ptr); return true; } - - cc::gfx::BufferInfo* cobj = JSB_ALLOC(cc::gfx::BufferInfo); + auto *ptr = JSB_MAKE_PRIVATE_OBJECT(cc::gfx::BufferInfo); + auto cobj = ptr->get(); if (argc > 0 && !args[0].isUndefined()) { ok &= sevalue_to_native(args[0], &(cobj->usage), nullptr); } @@ -4318,28 +4124,17 @@ static bool js_gfx_BufferInfo_constructor(se::State& s) // NOLINT(readability-id } if(!ok) { - JSB_FREE(cobj); + delete ptr; SE_REPORT_ERROR("Argument convertion error"); return false; } - - s.thisObject()->setPrivateData(cobj); - se::NonRefNativePtrCreatedByCtorMap::emplace(cobj); + s.thisObject()->setPrivateObject(ptr); return true; } SE_BIND_CTOR(js_gfx_BufferInfo_constructor, __jsb_cc_gfx_BufferInfo_class, js_cc_gfx_BufferInfo_finalize) - - static bool js_cc_gfx_BufferInfo_finalize(se::State& s) // NOLINT(readability-identifier-naming) { - auto iter = se::NonRefNativePtrCreatedByCtorMap::find(SE_THIS_OBJECT(s)); - if (iter != se::NonRefNativePtrCreatedByCtorMap::end()) - { - se::NonRefNativePtrCreatedByCtorMap::erase(iter); - auto* cobj = SE_THIS_OBJECT(s); - JSB_FREE(cobj); - } return true; } SE_BIND_FINALIZE_FUNC(js_cc_gfx_BufferInfo_finalize) @@ -4360,11 +4155,12 @@ bool js_register_gfx_BufferInfo(se::Object* obj) // NOLINT(readability-identifie __jsb_cc_gfx_BufferInfo_proto = cls->getProto(); __jsb_cc_gfx_BufferInfo_class = cls; + se::ScriptEngine::getInstance()->clearException(); return true; } -se::Object* __jsb_cc_gfx_BufferViewInfo_proto = nullptr; -se::Class* __jsb_cc_gfx_BufferViewInfo_class = nullptr; +se::Object* __jsb_cc_gfx_BufferViewInfo_proto = nullptr; // NOLINT +se::Class* __jsb_cc_gfx_BufferViewInfo_class = nullptr; // NOLINT static bool js_gfx_BufferViewInfo_get_buffer(se::State& s) // NOLINT(readability-identifier-naming) { @@ -4460,15 +4256,15 @@ bool sevalue_to_native(const se::Value &from, cc::gfx::BufferViewInfo * to, se:: } se::Value field; bool ok = true; - json->getProperty("buffer", &field); + json->getProperty("buffer", &field, true); if(!field.isNullOrUndefined()) { ok &= sevalue_to_native(field, &(to->buffer), ctx); } - json->getProperty("offset", &field); + json->getProperty("offset", &field, true); if(!field.isNullOrUndefined()) { ok &= sevalue_to_native(field, &(to->offset), ctx); } - json->getProperty("range", &field); + json->getProperty("range", &field, true); if(!field.isNullOrUndefined()) { ok &= sevalue_to_native(field, &(to->range), ctx); } @@ -4485,9 +4281,8 @@ static bool js_gfx_BufferViewInfo_constructor(se::State& s) // NOLINT(readabilit if(argc == 0) { - cc::gfx::BufferViewInfo* cobj = JSB_ALLOC(cc::gfx::BufferViewInfo); - s.thisObject()->setPrivateData(cobj); - se::NonRefNativePtrCreatedByCtorMap::emplace(cobj); + auto *ptr = JSB_MAKE_PRIVATE_OBJECT(cc::gfx::BufferViewInfo); + s.thisObject()->setPrivateObject(ptr); return true; } @@ -4495,21 +4290,19 @@ static bool js_gfx_BufferViewInfo_constructor(se::State& s) // NOLINT(readabilit { se::Object *json = args[0].toObject(); se::Value field; - - cc::gfx::BufferViewInfo* cobj = JSB_ALLOC(cc::gfx::BufferViewInfo); + auto *ptr = JSB_MAKE_PRIVATE_OBJECT(cc::gfx::BufferViewInfo); + auto cobj = ptr->get(); ok &= sevalue_to_native(args[0], cobj, s.thisObject()); if(!ok) { - JSB_FREE(cobj); + delete ptr; SE_REPORT_ERROR("argument convertion error"); return false; } - - s.thisObject()->setPrivateData(cobj); - se::NonRefNativePtrCreatedByCtorMap::emplace(cobj); + s.thisObject()->setPrivateObject(ptr); return true; } - - cc::gfx::BufferViewInfo* cobj = JSB_ALLOC(cc::gfx::BufferViewInfo); + auto *ptr = JSB_MAKE_PRIVATE_OBJECT(cc::gfx::BufferViewInfo); + auto cobj = ptr->get(); if (argc > 0 && !args[0].isUndefined()) { ok &= sevalue_to_native(args[0], &(cobj->buffer), nullptr); } @@ -4521,28 +4314,17 @@ static bool js_gfx_BufferViewInfo_constructor(se::State& s) // NOLINT(readabilit } if(!ok) { - JSB_FREE(cobj); + delete ptr; SE_REPORT_ERROR("Argument convertion error"); return false; } - - s.thisObject()->setPrivateData(cobj); - se::NonRefNativePtrCreatedByCtorMap::emplace(cobj); + s.thisObject()->setPrivateObject(ptr); return true; } SE_BIND_CTOR(js_gfx_BufferViewInfo_constructor, __jsb_cc_gfx_BufferViewInfo_class, js_cc_gfx_BufferViewInfo_finalize) - - static bool js_cc_gfx_BufferViewInfo_finalize(se::State& s) // NOLINT(readability-identifier-naming) { - auto iter = se::NonRefNativePtrCreatedByCtorMap::find(SE_THIS_OBJECT(s)); - if (iter != se::NonRefNativePtrCreatedByCtorMap::end()) - { - se::NonRefNativePtrCreatedByCtorMap::erase(iter); - auto* cobj = SE_THIS_OBJECT(s); - JSB_FREE(cobj); - } return true; } SE_BIND_FINALIZE_FUNC(js_cc_gfx_BufferViewInfo_finalize) @@ -4561,11 +4343,12 @@ bool js_register_gfx_BufferViewInfo(se::Object* obj) // NOLINT(readability-ident __jsb_cc_gfx_BufferViewInfo_proto = cls->getProto(); __jsb_cc_gfx_BufferViewInfo_class = cls; + se::ScriptEngine::getInstance()->clearException(); return true; } -se::Object* __jsb_cc_gfx_DrawInfo_proto = nullptr; -se::Class* __jsb_cc_gfx_DrawInfo_class = nullptr; +se::Object* __jsb_cc_gfx_DrawInfo_proto = nullptr; // NOLINT +se::Class* __jsb_cc_gfx_DrawInfo_class = nullptr; // NOLINT static bool js_gfx_DrawInfo_get_vertexCount(se::State& s) // NOLINT(readability-identifier-naming) { @@ -4769,31 +4552,31 @@ bool sevalue_to_native(const se::Value &from, cc::gfx::DrawInfo * to, se::Object } se::Value field; bool ok = true; - json->getProperty("vertexCount", &field); + json->getProperty("vertexCount", &field, true); if(!field.isNullOrUndefined()) { ok &= sevalue_to_native(field, &(to->vertexCount), ctx); } - json->getProperty("firstVertex", &field); + json->getProperty("firstVertex", &field, true); if(!field.isNullOrUndefined()) { ok &= sevalue_to_native(field, &(to->firstVertex), ctx); } - json->getProperty("indexCount", &field); + json->getProperty("indexCount", &field, true); if(!field.isNullOrUndefined()) { ok &= sevalue_to_native(field, &(to->indexCount), ctx); } - json->getProperty("firstIndex", &field); + json->getProperty("firstIndex", &field, true); if(!field.isNullOrUndefined()) { ok &= sevalue_to_native(field, &(to->firstIndex), ctx); } - json->getProperty("vertexOffset", &field); + json->getProperty("vertexOffset", &field, true); if(!field.isNullOrUndefined()) { ok &= sevalue_to_native(field, &(to->vertexOffset), ctx); } - json->getProperty("instanceCount", &field); + json->getProperty("instanceCount", &field, true); if(!field.isNullOrUndefined()) { ok &= sevalue_to_native(field, &(to->instanceCount), ctx); } - json->getProperty("firstInstance", &field); + json->getProperty("firstInstance", &field, true); if(!field.isNullOrUndefined()) { ok &= sevalue_to_native(field, &(to->firstInstance), ctx); } @@ -4810,9 +4593,8 @@ static bool js_gfx_DrawInfo_constructor(se::State& s) // NOLINT(readability-iden if(argc == 0) { - cc::gfx::DrawInfo* cobj = JSB_ALLOC(cc::gfx::DrawInfo); - s.thisObject()->setPrivateData(cobj); - se::NonRefNativePtrCreatedByCtorMap::emplace(cobj); + auto *ptr = JSB_MAKE_PRIVATE_OBJECT(cc::gfx::DrawInfo); + s.thisObject()->setPrivateObject(ptr); return true; } @@ -4820,21 +4602,19 @@ static bool js_gfx_DrawInfo_constructor(se::State& s) // NOLINT(readability-iden { se::Object *json = args[0].toObject(); se::Value field; - - cc::gfx::DrawInfo* cobj = JSB_ALLOC(cc::gfx::DrawInfo); + auto *ptr = JSB_MAKE_PRIVATE_OBJECT(cc::gfx::DrawInfo); + auto cobj = ptr->get(); ok &= sevalue_to_native(args[0], cobj, s.thisObject()); if(!ok) { - JSB_FREE(cobj); + delete ptr; SE_REPORT_ERROR("argument convertion error"); return false; } - - s.thisObject()->setPrivateData(cobj); - se::NonRefNativePtrCreatedByCtorMap::emplace(cobj); + s.thisObject()->setPrivateObject(ptr); return true; } - - cc::gfx::DrawInfo* cobj = JSB_ALLOC(cc::gfx::DrawInfo); + auto *ptr = JSB_MAKE_PRIVATE_OBJECT(cc::gfx::DrawInfo); + auto cobj = ptr->get(); if (argc > 0 && !args[0].isUndefined()) { ok &= sevalue_to_native(args[0], &(cobj->vertexCount), nullptr); } @@ -4858,28 +4638,17 @@ static bool js_gfx_DrawInfo_constructor(se::State& s) // NOLINT(readability-iden } if(!ok) { - JSB_FREE(cobj); + delete ptr; SE_REPORT_ERROR("Argument convertion error"); return false; } - - s.thisObject()->setPrivateData(cobj); - se::NonRefNativePtrCreatedByCtorMap::emplace(cobj); + s.thisObject()->setPrivateObject(ptr); return true; } SE_BIND_CTOR(js_gfx_DrawInfo_constructor, __jsb_cc_gfx_DrawInfo_class, js_cc_gfx_DrawInfo_finalize) - - static bool js_cc_gfx_DrawInfo_finalize(se::State& s) // NOLINT(readability-identifier-naming) { - auto iter = se::NonRefNativePtrCreatedByCtorMap::find(SE_THIS_OBJECT(s)); - if (iter != se::NonRefNativePtrCreatedByCtorMap::end()) - { - se::NonRefNativePtrCreatedByCtorMap::erase(iter); - auto* cobj = SE_THIS_OBJECT(s); - JSB_FREE(cobj); - } return true; } SE_BIND_FINALIZE_FUNC(js_cc_gfx_DrawInfo_finalize) @@ -4902,11 +4671,12 @@ bool js_register_gfx_DrawInfo(se::Object* obj) // NOLINT(readability-identifier- __jsb_cc_gfx_DrawInfo_proto = cls->getProto(); __jsb_cc_gfx_DrawInfo_class = cls; + se::ScriptEngine::getInstance()->clearException(); return true; } -se::Object* __jsb_cc_gfx_DispatchInfo_proto = nullptr; -se::Class* __jsb_cc_gfx_DispatchInfo_class = nullptr; +se::Object* __jsb_cc_gfx_DispatchInfo_proto = nullptr; // NOLINT +se::Class* __jsb_cc_gfx_DispatchInfo_class = nullptr; // NOLINT static bool js_gfx_DispatchInfo_get_groupCountX(se::State& s) // NOLINT(readability-identifier-naming) { @@ -5056,23 +4826,23 @@ bool sevalue_to_native(const se::Value &from, cc::gfx::DispatchInfo * to, se::Ob } se::Value field; bool ok = true; - json->getProperty("groupCountX", &field); + json->getProperty("groupCountX", &field, true); if(!field.isNullOrUndefined()) { ok &= sevalue_to_native(field, &(to->groupCountX), ctx); } - json->getProperty("groupCountY", &field); + json->getProperty("groupCountY", &field, true); if(!field.isNullOrUndefined()) { ok &= sevalue_to_native(field, &(to->groupCountY), ctx); } - json->getProperty("groupCountZ", &field); + json->getProperty("groupCountZ", &field, true); if(!field.isNullOrUndefined()) { ok &= sevalue_to_native(field, &(to->groupCountZ), ctx); } - json->getProperty("indirectBuffer", &field); + json->getProperty("indirectBuffer", &field, true); if(!field.isNullOrUndefined()) { ok &= sevalue_to_native(field, &(to->indirectBuffer), ctx); } - json->getProperty("indirectOffset", &field); + json->getProperty("indirectOffset", &field, true); if(!field.isNullOrUndefined()) { ok &= sevalue_to_native(field, &(to->indirectOffset), ctx); } @@ -5089,9 +4859,8 @@ static bool js_gfx_DispatchInfo_constructor(se::State& s) // NOLINT(readability- if(argc == 0) { - cc::gfx::DispatchInfo* cobj = JSB_ALLOC(cc::gfx::DispatchInfo); - s.thisObject()->setPrivateData(cobj); - se::NonRefNativePtrCreatedByCtorMap::emplace(cobj); + auto *ptr = JSB_MAKE_PRIVATE_OBJECT(cc::gfx::DispatchInfo); + s.thisObject()->setPrivateObject(ptr); return true; } @@ -5099,21 +4868,19 @@ static bool js_gfx_DispatchInfo_constructor(se::State& s) // NOLINT(readability- { se::Object *json = args[0].toObject(); se::Value field; - - cc::gfx::DispatchInfo* cobj = JSB_ALLOC(cc::gfx::DispatchInfo); + auto *ptr = JSB_MAKE_PRIVATE_OBJECT(cc::gfx::DispatchInfo); + auto cobj = ptr->get(); ok &= sevalue_to_native(args[0], cobj, s.thisObject()); if(!ok) { - JSB_FREE(cobj); + delete ptr; SE_REPORT_ERROR("argument convertion error"); return false; } - - s.thisObject()->setPrivateData(cobj); - se::NonRefNativePtrCreatedByCtorMap::emplace(cobj); + s.thisObject()->setPrivateObject(ptr); return true; } - - cc::gfx::DispatchInfo* cobj = JSB_ALLOC(cc::gfx::DispatchInfo); + auto *ptr = JSB_MAKE_PRIVATE_OBJECT(cc::gfx::DispatchInfo); + auto cobj = ptr->get(); if (argc > 0 && !args[0].isUndefined()) { ok &= sevalue_to_native(args[0], &(cobj->groupCountX), nullptr); } @@ -5131,28 +4898,17 @@ static bool js_gfx_DispatchInfo_constructor(se::State& s) // NOLINT(readability- } if(!ok) { - JSB_FREE(cobj); + delete ptr; SE_REPORT_ERROR("Argument convertion error"); return false; } - - s.thisObject()->setPrivateData(cobj); - se::NonRefNativePtrCreatedByCtorMap::emplace(cobj); + s.thisObject()->setPrivateObject(ptr); return true; } SE_BIND_CTOR(js_gfx_DispatchInfo_constructor, __jsb_cc_gfx_DispatchInfo_class, js_cc_gfx_DispatchInfo_finalize) - - static bool js_cc_gfx_DispatchInfo_finalize(se::State& s) // NOLINT(readability-identifier-naming) { - auto iter = se::NonRefNativePtrCreatedByCtorMap::find(SE_THIS_OBJECT(s)); - if (iter != se::NonRefNativePtrCreatedByCtorMap::end()) - { - se::NonRefNativePtrCreatedByCtorMap::erase(iter); - auto* cobj = SE_THIS_OBJECT(s); - JSB_FREE(cobj); - } return true; } SE_BIND_FINALIZE_FUNC(js_cc_gfx_DispatchInfo_finalize) @@ -5173,11 +4929,12 @@ bool js_register_gfx_DispatchInfo(se::Object* obj) // NOLINT(readability-identif __jsb_cc_gfx_DispatchInfo_proto = cls->getProto(); __jsb_cc_gfx_DispatchInfo_class = cls; + se::ScriptEngine::getInstance()->clearException(); return true; } -se::Object* __jsb_cc_gfx_IndirectBuffer_proto = nullptr; -se::Class* __jsb_cc_gfx_IndirectBuffer_class = nullptr; +se::Object* __jsb_cc_gfx_IndirectBuffer_proto = nullptr; // NOLINT +se::Class* __jsb_cc_gfx_IndirectBuffer_class = nullptr; // NOLINT static bool js_gfx_IndirectBuffer_get_drawInfos(se::State& s) // NOLINT(readability-identifier-naming) { @@ -5219,7 +4976,7 @@ bool sevalue_to_native(const se::Value &from, cc::gfx::IndirectBuffer * to, se:: } se::Value field; bool ok = true; - json->getProperty("drawInfos", &field); + json->getProperty("drawInfos", &field, true); if(!field.isNullOrUndefined()) { ok &= sevalue_to_native(field, &(to->drawInfos), ctx); } @@ -5236,40 +4993,28 @@ static bool js_gfx_IndirectBuffer_constructor(se::State& s) // NOLINT(readabilit if(argc == 0) { - cc::gfx::IndirectBuffer* cobj = JSB_ALLOC(cc::gfx::IndirectBuffer); - s.thisObject()->setPrivateData(cobj); - se::NonRefNativePtrCreatedByCtorMap::emplace(cobj); + auto *ptr = JSB_MAKE_PRIVATE_OBJECT(cc::gfx::IndirectBuffer); + s.thisObject()->setPrivateObject(ptr); return true; } - - cc::gfx::IndirectBuffer* cobj = JSB_ALLOC(cc::gfx::IndirectBuffer); + auto *ptr = JSB_MAKE_PRIVATE_OBJECT(cc::gfx::IndirectBuffer); + auto cobj = ptr->get(); if (argc > 0 && !args[0].isUndefined()) { ok &= sevalue_to_native(args[0], &(cobj->drawInfos), nullptr); } if(!ok) { - JSB_FREE(cobj); + delete ptr; SE_REPORT_ERROR("Argument convertion error"); return false; } - - s.thisObject()->setPrivateData(cobj); - se::NonRefNativePtrCreatedByCtorMap::emplace(cobj); + s.thisObject()->setPrivateObject(ptr); return true; } SE_BIND_CTOR(js_gfx_IndirectBuffer_constructor, __jsb_cc_gfx_IndirectBuffer_class, js_cc_gfx_IndirectBuffer_finalize) - - static bool js_cc_gfx_IndirectBuffer_finalize(se::State& s) // NOLINT(readability-identifier-naming) { - auto iter = se::NonRefNativePtrCreatedByCtorMap::find(SE_THIS_OBJECT(s)); - if (iter != se::NonRefNativePtrCreatedByCtorMap::end()) - { - se::NonRefNativePtrCreatedByCtorMap::erase(iter); - auto* cobj = SE_THIS_OBJECT(s); - JSB_FREE(cobj); - } return true; } SE_BIND_FINALIZE_FUNC(js_cc_gfx_IndirectBuffer_finalize) @@ -5286,11 +5031,12 @@ bool js_register_gfx_IndirectBuffer(se::Object* obj) // NOLINT(readability-ident __jsb_cc_gfx_IndirectBuffer_proto = cls->getProto(); __jsb_cc_gfx_IndirectBuffer_class = cls; + se::ScriptEngine::getInstance()->clearException(); return true; } -se::Object* __jsb_cc_gfx_TextureInfo_proto = nullptr; -se::Class* __jsb_cc_gfx_TextureInfo_class = nullptr; +se::Object* __jsb_cc_gfx_TextureInfo_proto = nullptr; // NOLINT +se::Class* __jsb_cc_gfx_TextureInfo_class = nullptr; // NOLINT static bool js_gfx_TextureInfo_get_type(se::State& s) // NOLINT(readability-identifier-naming) { @@ -5602,47 +5348,47 @@ bool sevalue_to_native(const se::Value &from, cc::gfx::TextureInfo * to, se::Obj } se::Value field; bool ok = true; - json->getProperty("type", &field); + json->getProperty("type", &field, true); if(!field.isNullOrUndefined()) { ok &= sevalue_to_native(field, &(to->type), ctx); } - json->getProperty("usage", &field); + json->getProperty("usage", &field, true); if(!field.isNullOrUndefined()) { ok &= sevalue_to_native(field, &(to->usage), ctx); } - json->getProperty("format", &field); + json->getProperty("format", &field, true); if(!field.isNullOrUndefined()) { ok &= sevalue_to_native(field, &(to->format), ctx); } - json->getProperty("width", &field); + json->getProperty("width", &field, true); if(!field.isNullOrUndefined()) { ok &= sevalue_to_native(field, &(to->width), ctx); } - json->getProperty("height", &field); + json->getProperty("height", &field, true); if(!field.isNullOrUndefined()) { ok &= sevalue_to_native(field, &(to->height), ctx); } - json->getProperty("flags", &field); + json->getProperty("flags", &field, true); if(!field.isNullOrUndefined()) { ok &= sevalue_to_native(field, &(to->flags), ctx); } - json->getProperty("layerCount", &field); + json->getProperty("layerCount", &field, true); if(!field.isNullOrUndefined()) { ok &= sevalue_to_native(field, &(to->layerCount), ctx); } - json->getProperty("levelCount", &field); + json->getProperty("levelCount", &field, true); if(!field.isNullOrUndefined()) { ok &= sevalue_to_native(field, &(to->levelCount), ctx); } - json->getProperty("samples", &field); + json->getProperty("samples", &field, true); if(!field.isNullOrUndefined()) { ok &= sevalue_to_native(field, &(to->samples), ctx); } - json->getProperty("depth", &field); + json->getProperty("depth", &field, true); if(!field.isNullOrUndefined()) { ok &= sevalue_to_native(field, &(to->depth), ctx); } - json->getProperty("externalRes", &field); + json->getProperty("externalRes", &field, true); if(!field.isNullOrUndefined()) { ok &= sevalue_to_native(field, &(to->externalRes), ctx); } @@ -5659,9 +5405,8 @@ static bool js_gfx_TextureInfo_constructor(se::State& s) // NOLINT(readability-i if(argc == 0) { - cc::gfx::TextureInfo* cobj = JSB_ALLOC(cc::gfx::TextureInfo); - s.thisObject()->setPrivateData(cobj); - se::NonRefNativePtrCreatedByCtorMap::emplace(cobj); + auto *ptr = JSB_MAKE_PRIVATE_OBJECT(cc::gfx::TextureInfo); + s.thisObject()->setPrivateObject(ptr); return true; } @@ -5669,21 +5414,19 @@ static bool js_gfx_TextureInfo_constructor(se::State& s) // NOLINT(readability-i { se::Object *json = args[0].toObject(); se::Value field; - - cc::gfx::TextureInfo* cobj = JSB_ALLOC(cc::gfx::TextureInfo); + auto *ptr = JSB_MAKE_PRIVATE_OBJECT(cc::gfx::TextureInfo); + auto cobj = ptr->get(); ok &= sevalue_to_native(args[0], cobj, s.thisObject()); if(!ok) { - JSB_FREE(cobj); + delete ptr; SE_REPORT_ERROR("argument convertion error"); return false; } - - s.thisObject()->setPrivateData(cobj); - se::NonRefNativePtrCreatedByCtorMap::emplace(cobj); + s.thisObject()->setPrivateObject(ptr); return true; } - - cc::gfx::TextureInfo* cobj = JSB_ALLOC(cc::gfx::TextureInfo); + auto *ptr = JSB_MAKE_PRIVATE_OBJECT(cc::gfx::TextureInfo); + auto cobj = ptr->get(); if (argc > 0 && !args[0].isUndefined()) { ok &= sevalue_to_native(args[0], &(cobj->type), nullptr); } @@ -5719,28 +5462,17 @@ static bool js_gfx_TextureInfo_constructor(se::State& s) // NOLINT(readability-i } if(!ok) { - JSB_FREE(cobj); + delete ptr; SE_REPORT_ERROR("Argument convertion error"); return false; } - - s.thisObject()->setPrivateData(cobj); - se::NonRefNativePtrCreatedByCtorMap::emplace(cobj); + s.thisObject()->setPrivateObject(ptr); return true; } SE_BIND_CTOR(js_gfx_TextureInfo_constructor, __jsb_cc_gfx_TextureInfo_class, js_cc_gfx_TextureInfo_finalize) - - static bool js_cc_gfx_TextureInfo_finalize(se::State& s) // NOLINT(readability-identifier-naming) { - auto iter = se::NonRefNativePtrCreatedByCtorMap::find(SE_THIS_OBJECT(s)); - if (iter != se::NonRefNativePtrCreatedByCtorMap::end()) - { - se::NonRefNativePtrCreatedByCtorMap::erase(iter); - auto* cobj = SE_THIS_OBJECT(s); - JSB_FREE(cobj); - } return true; } SE_BIND_FINALIZE_FUNC(js_cc_gfx_TextureInfo_finalize) @@ -5767,11 +5499,12 @@ bool js_register_gfx_TextureInfo(se::Object* obj) // NOLINT(readability-identifi __jsb_cc_gfx_TextureInfo_proto = cls->getProto(); __jsb_cc_gfx_TextureInfo_class = cls; + se::ScriptEngine::getInstance()->clearException(); return true; } -se::Object* __jsb_cc_gfx_TextureViewInfo_proto = nullptr; -se::Class* __jsb_cc_gfx_TextureViewInfo_class = nullptr; +se::Object* __jsb_cc_gfx_TextureViewInfo_proto = nullptr; // NOLINT +se::Class* __jsb_cc_gfx_TextureViewInfo_class = nullptr; // NOLINT static bool js_gfx_TextureViewInfo_get_texture(se::State& s) // NOLINT(readability-identifier-naming) { @@ -5975,31 +5708,31 @@ bool sevalue_to_native(const se::Value &from, cc::gfx::TextureViewInfo * to, se: } se::Value field; bool ok = true; - json->getProperty("texture", &field); + json->getProperty("texture", &field, true); if(!field.isNullOrUndefined()) { ok &= sevalue_to_native(field, &(to->texture), ctx); } - json->getProperty("type", &field); + json->getProperty("type", &field, true); if(!field.isNullOrUndefined()) { ok &= sevalue_to_native(field, &(to->type), ctx); } - json->getProperty("format", &field); + json->getProperty("format", &field, true); if(!field.isNullOrUndefined()) { ok &= sevalue_to_native(field, &(to->format), ctx); } - json->getProperty("baseLevel", &field); + json->getProperty("baseLevel", &field, true); if(!field.isNullOrUndefined()) { ok &= sevalue_to_native(field, &(to->baseLevel), ctx); } - json->getProperty("levelCount", &field); + json->getProperty("levelCount", &field, true); if(!field.isNullOrUndefined()) { ok &= sevalue_to_native(field, &(to->levelCount), ctx); } - json->getProperty("baseLayer", &field); + json->getProperty("baseLayer", &field, true); if(!field.isNullOrUndefined()) { ok &= sevalue_to_native(field, &(to->baseLayer), ctx); } - json->getProperty("layerCount", &field); + json->getProperty("layerCount", &field, true); if(!field.isNullOrUndefined()) { ok &= sevalue_to_native(field, &(to->layerCount), ctx); } @@ -6016,9 +5749,8 @@ static bool js_gfx_TextureViewInfo_constructor(se::State& s) // NOLINT(readabili if(argc == 0) { - cc::gfx::TextureViewInfo* cobj = JSB_ALLOC(cc::gfx::TextureViewInfo); - s.thisObject()->setPrivateData(cobj); - se::NonRefNativePtrCreatedByCtorMap::emplace(cobj); + auto *ptr = JSB_MAKE_PRIVATE_OBJECT(cc::gfx::TextureViewInfo); + s.thisObject()->setPrivateObject(ptr); return true; } @@ -6026,21 +5758,19 @@ static bool js_gfx_TextureViewInfo_constructor(se::State& s) // NOLINT(readabili { se::Object *json = args[0].toObject(); se::Value field; - - cc::gfx::TextureViewInfo* cobj = JSB_ALLOC(cc::gfx::TextureViewInfo); + auto *ptr = JSB_MAKE_PRIVATE_OBJECT(cc::gfx::TextureViewInfo); + auto cobj = ptr->get(); ok &= sevalue_to_native(args[0], cobj, s.thisObject()); if(!ok) { - JSB_FREE(cobj); + delete ptr; SE_REPORT_ERROR("argument convertion error"); return false; } - - s.thisObject()->setPrivateData(cobj); - se::NonRefNativePtrCreatedByCtorMap::emplace(cobj); + s.thisObject()->setPrivateObject(ptr); return true; } - - cc::gfx::TextureViewInfo* cobj = JSB_ALLOC(cc::gfx::TextureViewInfo); + auto *ptr = JSB_MAKE_PRIVATE_OBJECT(cc::gfx::TextureViewInfo); + auto cobj = ptr->get(); if (argc > 0 && !args[0].isUndefined()) { ok &= sevalue_to_native(args[0], &(cobj->texture), nullptr); } @@ -6064,28 +5794,17 @@ static bool js_gfx_TextureViewInfo_constructor(se::State& s) // NOLINT(readabili } if(!ok) { - JSB_FREE(cobj); + delete ptr; SE_REPORT_ERROR("Argument convertion error"); return false; } - - s.thisObject()->setPrivateData(cobj); - se::NonRefNativePtrCreatedByCtorMap::emplace(cobj); + s.thisObject()->setPrivateObject(ptr); return true; } SE_BIND_CTOR(js_gfx_TextureViewInfo_constructor, __jsb_cc_gfx_TextureViewInfo_class, js_cc_gfx_TextureViewInfo_finalize) - - static bool js_cc_gfx_TextureViewInfo_finalize(se::State& s) // NOLINT(readability-identifier-naming) { - auto iter = se::NonRefNativePtrCreatedByCtorMap::find(SE_THIS_OBJECT(s)); - if (iter != se::NonRefNativePtrCreatedByCtorMap::end()) - { - se::NonRefNativePtrCreatedByCtorMap::erase(iter); - auto* cobj = SE_THIS_OBJECT(s); - JSB_FREE(cobj); - } return true; } SE_BIND_FINALIZE_FUNC(js_cc_gfx_TextureViewInfo_finalize) @@ -6108,11 +5827,12 @@ bool js_register_gfx_TextureViewInfo(se::Object* obj) // NOLINT(readability-iden __jsb_cc_gfx_TextureViewInfo_proto = cls->getProto(); __jsb_cc_gfx_TextureViewInfo_class = cls; + se::ScriptEngine::getInstance()->clearException(); return true; } -se::Object* __jsb_cc_gfx_SamplerInfo_proto = nullptr; -se::Class* __jsb_cc_gfx_SamplerInfo_class = nullptr; +se::Object* __jsb_cc_gfx_SamplerInfo_proto = nullptr; // NOLINT +se::Class* __jsb_cc_gfx_SamplerInfo_class = nullptr; // NOLINT static bool js_gfx_SamplerInfo_get_minFilter(se::State& s) // NOLINT(readability-identifier-naming) { @@ -6343,35 +6063,35 @@ bool sevalue_to_native(const se::Value &from, cc::gfx::SamplerInfo * to, se::Obj } se::Value field; bool ok = true; - json->getProperty("minFilter", &field); + json->getProperty("minFilter", &field, true); if(!field.isNullOrUndefined()) { ok &= sevalue_to_native(field, &(to->minFilter), ctx); } - json->getProperty("magFilter", &field); + json->getProperty("magFilter", &field, true); if(!field.isNullOrUndefined()) { ok &= sevalue_to_native(field, &(to->magFilter), ctx); } - json->getProperty("mipFilter", &field); + json->getProperty("mipFilter", &field, true); if(!field.isNullOrUndefined()) { ok &= sevalue_to_native(field, &(to->mipFilter), ctx); } - json->getProperty("addressU", &field); + json->getProperty("addressU", &field, true); if(!field.isNullOrUndefined()) { ok &= sevalue_to_native(field, &(to->addressU), ctx); } - json->getProperty("addressV", &field); + json->getProperty("addressV", &field, true); if(!field.isNullOrUndefined()) { ok &= sevalue_to_native(field, &(to->addressV), ctx); } - json->getProperty("addressW", &field); + json->getProperty("addressW", &field, true); if(!field.isNullOrUndefined()) { ok &= sevalue_to_native(field, &(to->addressW), ctx); } - json->getProperty("maxAnisotropy", &field); + json->getProperty("maxAnisotropy", &field, true); if(!field.isNullOrUndefined()) { ok &= sevalue_to_native(field, &(to->maxAnisotropy), ctx); } - json->getProperty("cmpFunc", &field); + json->getProperty("cmpFunc", &field, true); if(!field.isNullOrUndefined()) { ok &= sevalue_to_native(field, &(to->cmpFunc), ctx); } @@ -6388,9 +6108,8 @@ static bool js_gfx_SamplerInfo_constructor(se::State& s) // NOLINT(readability-i if(argc == 0) { - cc::gfx::SamplerInfo* cobj = JSB_ALLOC(cc::gfx::SamplerInfo); - s.thisObject()->setPrivateData(cobj); - se::NonRefNativePtrCreatedByCtorMap::emplace(cobj); + auto *ptr = JSB_MAKE_PRIVATE_OBJECT(cc::gfx::SamplerInfo); + s.thisObject()->setPrivateObject(ptr); return true; } @@ -6398,21 +6117,19 @@ static bool js_gfx_SamplerInfo_constructor(se::State& s) // NOLINT(readability-i { se::Object *json = args[0].toObject(); se::Value field; - - cc::gfx::SamplerInfo* cobj = JSB_ALLOC(cc::gfx::SamplerInfo); + auto *ptr = JSB_MAKE_PRIVATE_OBJECT(cc::gfx::SamplerInfo); + auto cobj = ptr->get(); ok &= sevalue_to_native(args[0], cobj, s.thisObject()); if(!ok) { - JSB_FREE(cobj); + delete ptr; SE_REPORT_ERROR("argument convertion error"); return false; } - - s.thisObject()->setPrivateData(cobj); - se::NonRefNativePtrCreatedByCtorMap::emplace(cobj); + s.thisObject()->setPrivateObject(ptr); return true; } - - cc::gfx::SamplerInfo* cobj = JSB_ALLOC(cc::gfx::SamplerInfo); + auto *ptr = JSB_MAKE_PRIVATE_OBJECT(cc::gfx::SamplerInfo); + auto cobj = ptr->get(); if (argc > 0 && !args[0].isUndefined()) { ok &= sevalue_to_native(args[0], &(cobj->minFilter), nullptr); } @@ -6439,28 +6156,17 @@ static bool js_gfx_SamplerInfo_constructor(se::State& s) // NOLINT(readability-i } if(!ok) { - JSB_FREE(cobj); + delete ptr; SE_REPORT_ERROR("Argument convertion error"); return false; } - - s.thisObject()->setPrivateData(cobj); - se::NonRefNativePtrCreatedByCtorMap::emplace(cobj); + s.thisObject()->setPrivateObject(ptr); return true; } SE_BIND_CTOR(js_gfx_SamplerInfo_constructor, __jsb_cc_gfx_SamplerInfo_class, js_cc_gfx_SamplerInfo_finalize) - - static bool js_cc_gfx_SamplerInfo_finalize(se::State& s) // NOLINT(readability-identifier-naming) { - auto iter = se::NonRefNativePtrCreatedByCtorMap::find(SE_THIS_OBJECT(s)); - if (iter != se::NonRefNativePtrCreatedByCtorMap::end()) - { - se::NonRefNativePtrCreatedByCtorMap::erase(iter); - auto* cobj = SE_THIS_OBJECT(s); - JSB_FREE(cobj); - } return true; } SE_BIND_FINALIZE_FUNC(js_cc_gfx_SamplerInfo_finalize) @@ -6484,11 +6190,12 @@ bool js_register_gfx_SamplerInfo(se::Object* obj) // NOLINT(readability-identifi __jsb_cc_gfx_SamplerInfo_proto = cls->getProto(); __jsb_cc_gfx_SamplerInfo_class = cls; + se::ScriptEngine::getInstance()->clearException(); return true; } -se::Object* __jsb_cc_gfx_Uniform_proto = nullptr; -se::Class* __jsb_cc_gfx_Uniform_class = nullptr; +se::Object* __jsb_cc_gfx_Uniform_proto = nullptr; // NOLINT +se::Class* __jsb_cc_gfx_Uniform_class = nullptr; // NOLINT static bool js_gfx_Uniform_get_name(se::State& s) // NOLINT(readability-identifier-naming) { @@ -6584,15 +6291,15 @@ bool sevalue_to_native(const se::Value &from, cc::gfx::Uniform * to, se::Object } se::Value field; bool ok = true; - json->getProperty("name", &field); + json->getProperty("name", &field, true); if(!field.isNullOrUndefined()) { ok &= sevalue_to_native(field, &(to->name), ctx); } - json->getProperty("type", &field); + json->getProperty("type", &field, true); if(!field.isNullOrUndefined()) { ok &= sevalue_to_native(field, &(to->type), ctx); } - json->getProperty("count", &field); + json->getProperty("count", &field, true); if(!field.isNullOrUndefined()) { ok &= sevalue_to_native(field, &(to->count), ctx); } @@ -6609,9 +6316,8 @@ static bool js_gfx_Uniform_constructor(se::State& s) // NOLINT(readability-ident if(argc == 0) { - cc::gfx::Uniform* cobj = JSB_ALLOC(cc::gfx::Uniform); - s.thisObject()->setPrivateData(cobj); - se::NonRefNativePtrCreatedByCtorMap::emplace(cobj); + auto *ptr = JSB_MAKE_PRIVATE_OBJECT(cc::gfx::Uniform); + s.thisObject()->setPrivateObject(ptr); return true; } @@ -6619,21 +6325,19 @@ static bool js_gfx_Uniform_constructor(se::State& s) // NOLINT(readability-ident { se::Object *json = args[0].toObject(); se::Value field; - - cc::gfx::Uniform* cobj = JSB_ALLOC(cc::gfx::Uniform); + auto *ptr = JSB_MAKE_PRIVATE_OBJECT(cc::gfx::Uniform); + auto cobj = ptr->get(); ok &= sevalue_to_native(args[0], cobj, s.thisObject()); if(!ok) { - JSB_FREE(cobj); + delete ptr; SE_REPORT_ERROR("argument convertion error"); return false; } - - s.thisObject()->setPrivateData(cobj); - se::NonRefNativePtrCreatedByCtorMap::emplace(cobj); + s.thisObject()->setPrivateObject(ptr); return true; } - - cc::gfx::Uniform* cobj = JSB_ALLOC(cc::gfx::Uniform); + auto *ptr = JSB_MAKE_PRIVATE_OBJECT(cc::gfx::Uniform); + auto cobj = ptr->get(); if (argc > 0 && !args[0].isUndefined()) { ok &= sevalue_to_native(args[0], &(cobj->name), nullptr); } @@ -6645,28 +6349,17 @@ static bool js_gfx_Uniform_constructor(se::State& s) // NOLINT(readability-ident } if(!ok) { - JSB_FREE(cobj); + delete ptr; SE_REPORT_ERROR("Argument convertion error"); return false; } - - s.thisObject()->setPrivateData(cobj); - se::NonRefNativePtrCreatedByCtorMap::emplace(cobj); + s.thisObject()->setPrivateObject(ptr); return true; } SE_BIND_CTOR(js_gfx_Uniform_constructor, __jsb_cc_gfx_Uniform_class, js_cc_gfx_Uniform_finalize) - - static bool js_cc_gfx_Uniform_finalize(se::State& s) // NOLINT(readability-identifier-naming) { - auto iter = se::NonRefNativePtrCreatedByCtorMap::find(SE_THIS_OBJECT(s)); - if (iter != se::NonRefNativePtrCreatedByCtorMap::end()) - { - se::NonRefNativePtrCreatedByCtorMap::erase(iter); - auto* cobj = SE_THIS_OBJECT(s); - JSB_FREE(cobj); - } return true; } SE_BIND_FINALIZE_FUNC(js_cc_gfx_Uniform_finalize) @@ -6685,11 +6378,12 @@ bool js_register_gfx_Uniform(se::Object* obj) // NOLINT(readability-identifier-n __jsb_cc_gfx_Uniform_proto = cls->getProto(); __jsb_cc_gfx_Uniform_class = cls; + se::ScriptEngine::getInstance()->clearException(); return true; } -se::Object* __jsb_cc_gfx_UniformBlock_proto = nullptr; -se::Class* __jsb_cc_gfx_UniformBlock_class = nullptr; +se::Object* __jsb_cc_gfx_UniformBlock_proto = nullptr; // NOLINT +se::Class* __jsb_cc_gfx_UniformBlock_class = nullptr; // NOLINT static bool js_gfx_UniformBlock_get_set(se::State& s) // NOLINT(readability-identifier-naming) { @@ -6839,23 +6533,23 @@ bool sevalue_to_native(const se::Value &from, cc::gfx::UniformBlock * to, se::Ob } se::Value field; bool ok = true; - json->getProperty("set", &field); + json->getProperty("set", &field, true); if(!field.isNullOrUndefined()) { ok &= sevalue_to_native(field, &(to->set), ctx); } - json->getProperty("binding", &field); + json->getProperty("binding", &field, true); if(!field.isNullOrUndefined()) { ok &= sevalue_to_native(field, &(to->binding), ctx); } - json->getProperty("name", &field); + json->getProperty("name", &field, true); if(!field.isNullOrUndefined()) { ok &= sevalue_to_native(field, &(to->name), ctx); } - json->getProperty("members", &field); + json->getProperty("members", &field, true); if(!field.isNullOrUndefined()) { ok &= sevalue_to_native(field, &(to->members), ctx); } - json->getProperty("count", &field); + json->getProperty("count", &field, true); if(!field.isNullOrUndefined()) { ok &= sevalue_to_native(field, &(to->count), ctx); } @@ -6872,9 +6566,8 @@ static bool js_gfx_UniformBlock_constructor(se::State& s) // NOLINT(readability- if(argc == 0) { - cc::gfx::UniformBlock* cobj = JSB_ALLOC(cc::gfx::UniformBlock); - s.thisObject()->setPrivateData(cobj); - se::NonRefNativePtrCreatedByCtorMap::emplace(cobj); + auto *ptr = JSB_MAKE_PRIVATE_OBJECT(cc::gfx::UniformBlock); + s.thisObject()->setPrivateObject(ptr); return true; } @@ -6882,21 +6575,19 @@ static bool js_gfx_UniformBlock_constructor(se::State& s) // NOLINT(readability- { se::Object *json = args[0].toObject(); se::Value field; - - cc::gfx::UniformBlock* cobj = JSB_ALLOC(cc::gfx::UniformBlock); + auto *ptr = JSB_MAKE_PRIVATE_OBJECT(cc::gfx::UniformBlock); + auto cobj = ptr->get(); ok &= sevalue_to_native(args[0], cobj, s.thisObject()); if(!ok) { - JSB_FREE(cobj); + delete ptr; SE_REPORT_ERROR("argument convertion error"); return false; } - - s.thisObject()->setPrivateData(cobj); - se::NonRefNativePtrCreatedByCtorMap::emplace(cobj); + s.thisObject()->setPrivateObject(ptr); return true; } - - cc::gfx::UniformBlock* cobj = JSB_ALLOC(cc::gfx::UniformBlock); + auto *ptr = JSB_MAKE_PRIVATE_OBJECT(cc::gfx::UniformBlock); + auto cobj = ptr->get(); if (argc > 0 && !args[0].isUndefined()) { ok &= sevalue_to_native(args[0], &(cobj->set), nullptr); } @@ -6914,28 +6605,17 @@ static bool js_gfx_UniformBlock_constructor(se::State& s) // NOLINT(readability- } if(!ok) { - JSB_FREE(cobj); + delete ptr; SE_REPORT_ERROR("Argument convertion error"); return false; } - - s.thisObject()->setPrivateData(cobj); - se::NonRefNativePtrCreatedByCtorMap::emplace(cobj); + s.thisObject()->setPrivateObject(ptr); return true; } SE_BIND_CTOR(js_gfx_UniformBlock_constructor, __jsb_cc_gfx_UniformBlock_class, js_cc_gfx_UniformBlock_finalize) - - static bool js_cc_gfx_UniformBlock_finalize(se::State& s) // NOLINT(readability-identifier-naming) { - auto iter = se::NonRefNativePtrCreatedByCtorMap::find(SE_THIS_OBJECT(s)); - if (iter != se::NonRefNativePtrCreatedByCtorMap::end()) - { - se::NonRefNativePtrCreatedByCtorMap::erase(iter); - auto* cobj = SE_THIS_OBJECT(s); - JSB_FREE(cobj); - } return true; } SE_BIND_FINALIZE_FUNC(js_cc_gfx_UniformBlock_finalize) @@ -6956,11 +6636,12 @@ bool js_register_gfx_UniformBlock(se::Object* obj) // NOLINT(readability-identif __jsb_cc_gfx_UniformBlock_proto = cls->getProto(); __jsb_cc_gfx_UniformBlock_class = cls; + se::ScriptEngine::getInstance()->clearException(); return true; } -se::Object* __jsb_cc_gfx_UniformSamplerTexture_proto = nullptr; -se::Class* __jsb_cc_gfx_UniformSamplerTexture_class = nullptr; +se::Object* __jsb_cc_gfx_UniformSamplerTexture_proto = nullptr; // NOLINT +se::Class* __jsb_cc_gfx_UniformSamplerTexture_class = nullptr; // NOLINT static bool js_gfx_UniformSamplerTexture_get_set(se::State& s) // NOLINT(readability-identifier-naming) { @@ -7110,23 +6791,23 @@ bool sevalue_to_native(const se::Value &from, cc::gfx::UniformSamplerTexture * t } se::Value field; bool ok = true; - json->getProperty("set", &field); + json->getProperty("set", &field, true); if(!field.isNullOrUndefined()) { ok &= sevalue_to_native(field, &(to->set), ctx); } - json->getProperty("binding", &field); + json->getProperty("binding", &field, true); if(!field.isNullOrUndefined()) { ok &= sevalue_to_native(field, &(to->binding), ctx); } - json->getProperty("name", &field); + json->getProperty("name", &field, true); if(!field.isNullOrUndefined()) { ok &= sevalue_to_native(field, &(to->name), ctx); } - json->getProperty("type", &field); + json->getProperty("type", &field, true); if(!field.isNullOrUndefined()) { ok &= sevalue_to_native(field, &(to->type), ctx); } - json->getProperty("count", &field); + json->getProperty("count", &field, true); if(!field.isNullOrUndefined()) { ok &= sevalue_to_native(field, &(to->count), ctx); } @@ -7143,9 +6824,8 @@ static bool js_gfx_UniformSamplerTexture_constructor(se::State& s) // NOLINT(rea if(argc == 0) { - cc::gfx::UniformSamplerTexture* cobj = JSB_ALLOC(cc::gfx::UniformSamplerTexture); - s.thisObject()->setPrivateData(cobj); - se::NonRefNativePtrCreatedByCtorMap::emplace(cobj); + auto *ptr = JSB_MAKE_PRIVATE_OBJECT(cc::gfx::UniformSamplerTexture); + s.thisObject()->setPrivateObject(ptr); return true; } @@ -7153,21 +6833,19 @@ static bool js_gfx_UniformSamplerTexture_constructor(se::State& s) // NOLINT(rea { se::Object *json = args[0].toObject(); se::Value field; - - cc::gfx::UniformSamplerTexture* cobj = JSB_ALLOC(cc::gfx::UniformSamplerTexture); + auto *ptr = JSB_MAKE_PRIVATE_OBJECT(cc::gfx::UniformSamplerTexture); + auto cobj = ptr->get(); ok &= sevalue_to_native(args[0], cobj, s.thisObject()); if(!ok) { - JSB_FREE(cobj); + delete ptr; SE_REPORT_ERROR("argument convertion error"); return false; } - - s.thisObject()->setPrivateData(cobj); - se::NonRefNativePtrCreatedByCtorMap::emplace(cobj); + s.thisObject()->setPrivateObject(ptr); return true; } - - cc::gfx::UniformSamplerTexture* cobj = JSB_ALLOC(cc::gfx::UniformSamplerTexture); + auto *ptr = JSB_MAKE_PRIVATE_OBJECT(cc::gfx::UniformSamplerTexture); + auto cobj = ptr->get(); if (argc > 0 && !args[0].isUndefined()) { ok &= sevalue_to_native(args[0], &(cobj->set), nullptr); } @@ -7185,28 +6863,17 @@ static bool js_gfx_UniformSamplerTexture_constructor(se::State& s) // NOLINT(rea } if(!ok) { - JSB_FREE(cobj); + delete ptr; SE_REPORT_ERROR("Argument convertion error"); return false; } - - s.thisObject()->setPrivateData(cobj); - se::NonRefNativePtrCreatedByCtorMap::emplace(cobj); + s.thisObject()->setPrivateObject(ptr); return true; } SE_BIND_CTOR(js_gfx_UniformSamplerTexture_constructor, __jsb_cc_gfx_UniformSamplerTexture_class, js_cc_gfx_UniformSamplerTexture_finalize) - - static bool js_cc_gfx_UniformSamplerTexture_finalize(se::State& s) // NOLINT(readability-identifier-naming) { - auto iter = se::NonRefNativePtrCreatedByCtorMap::find(SE_THIS_OBJECT(s)); - if (iter != se::NonRefNativePtrCreatedByCtorMap::end()) - { - se::NonRefNativePtrCreatedByCtorMap::erase(iter); - auto* cobj = SE_THIS_OBJECT(s); - JSB_FREE(cobj); - } return true; } SE_BIND_FINALIZE_FUNC(js_cc_gfx_UniformSamplerTexture_finalize) @@ -7227,11 +6894,12 @@ bool js_register_gfx_UniformSamplerTexture(se::Object* obj) // NOLINT(readabilit __jsb_cc_gfx_UniformSamplerTexture_proto = cls->getProto(); __jsb_cc_gfx_UniformSamplerTexture_class = cls; + se::ScriptEngine::getInstance()->clearException(); return true; } -se::Object* __jsb_cc_gfx_UniformSampler_proto = nullptr; -se::Class* __jsb_cc_gfx_UniformSampler_class = nullptr; +se::Object* __jsb_cc_gfx_UniformSampler_proto = nullptr; // NOLINT +se::Class* __jsb_cc_gfx_UniformSampler_class = nullptr; // NOLINT static bool js_gfx_UniformSampler_get_set(se::State& s) // NOLINT(readability-identifier-naming) { @@ -7354,19 +7022,19 @@ bool sevalue_to_native(const se::Value &from, cc::gfx::UniformSampler * to, se:: } se::Value field; bool ok = true; - json->getProperty("set", &field); + json->getProperty("set", &field, true); if(!field.isNullOrUndefined()) { ok &= sevalue_to_native(field, &(to->set), ctx); } - json->getProperty("binding", &field); + json->getProperty("binding", &field, true); if(!field.isNullOrUndefined()) { ok &= sevalue_to_native(field, &(to->binding), ctx); } - json->getProperty("name", &field); + json->getProperty("name", &field, true); if(!field.isNullOrUndefined()) { ok &= sevalue_to_native(field, &(to->name), ctx); } - json->getProperty("count", &field); + json->getProperty("count", &field, true); if(!field.isNullOrUndefined()) { ok &= sevalue_to_native(field, &(to->count), ctx); } @@ -7383,9 +7051,8 @@ static bool js_gfx_UniformSampler_constructor(se::State& s) // NOLINT(readabilit if(argc == 0) { - cc::gfx::UniformSampler* cobj = JSB_ALLOC(cc::gfx::UniformSampler); - s.thisObject()->setPrivateData(cobj); - se::NonRefNativePtrCreatedByCtorMap::emplace(cobj); + auto *ptr = JSB_MAKE_PRIVATE_OBJECT(cc::gfx::UniformSampler); + s.thisObject()->setPrivateObject(ptr); return true; } @@ -7393,21 +7060,19 @@ static bool js_gfx_UniformSampler_constructor(se::State& s) // NOLINT(readabilit { se::Object *json = args[0].toObject(); se::Value field; - - cc::gfx::UniformSampler* cobj = JSB_ALLOC(cc::gfx::UniformSampler); + auto *ptr = JSB_MAKE_PRIVATE_OBJECT(cc::gfx::UniformSampler); + auto cobj = ptr->get(); ok &= sevalue_to_native(args[0], cobj, s.thisObject()); if(!ok) { - JSB_FREE(cobj); + delete ptr; SE_REPORT_ERROR("argument convertion error"); return false; } - - s.thisObject()->setPrivateData(cobj); - se::NonRefNativePtrCreatedByCtorMap::emplace(cobj); + s.thisObject()->setPrivateObject(ptr); return true; } - - cc::gfx::UniformSampler* cobj = JSB_ALLOC(cc::gfx::UniformSampler); + auto *ptr = JSB_MAKE_PRIVATE_OBJECT(cc::gfx::UniformSampler); + auto cobj = ptr->get(); if (argc > 0 && !args[0].isUndefined()) { ok &= sevalue_to_native(args[0], &(cobj->set), nullptr); } @@ -7422,28 +7087,17 @@ static bool js_gfx_UniformSampler_constructor(se::State& s) // NOLINT(readabilit } if(!ok) { - JSB_FREE(cobj); + delete ptr; SE_REPORT_ERROR("Argument convertion error"); return false; } - - s.thisObject()->setPrivateData(cobj); - se::NonRefNativePtrCreatedByCtorMap::emplace(cobj); + s.thisObject()->setPrivateObject(ptr); return true; } SE_BIND_CTOR(js_gfx_UniformSampler_constructor, __jsb_cc_gfx_UniformSampler_class, js_cc_gfx_UniformSampler_finalize) - - static bool js_cc_gfx_UniformSampler_finalize(se::State& s) // NOLINT(readability-identifier-naming) { - auto iter = se::NonRefNativePtrCreatedByCtorMap::find(SE_THIS_OBJECT(s)); - if (iter != se::NonRefNativePtrCreatedByCtorMap::end()) - { - se::NonRefNativePtrCreatedByCtorMap::erase(iter); - auto* cobj = SE_THIS_OBJECT(s); - JSB_FREE(cobj); - } return true; } SE_BIND_FINALIZE_FUNC(js_cc_gfx_UniformSampler_finalize) @@ -7463,11 +7117,12 @@ bool js_register_gfx_UniformSampler(se::Object* obj) // NOLINT(readability-ident __jsb_cc_gfx_UniformSampler_proto = cls->getProto(); __jsb_cc_gfx_UniformSampler_class = cls; + se::ScriptEngine::getInstance()->clearException(); return true; } -se::Object* __jsb_cc_gfx_UniformTexture_proto = nullptr; -se::Class* __jsb_cc_gfx_UniformTexture_class = nullptr; +se::Object* __jsb_cc_gfx_UniformTexture_proto = nullptr; // NOLINT +se::Class* __jsb_cc_gfx_UniformTexture_class = nullptr; // NOLINT static bool js_gfx_UniformTexture_get_set(se::State& s) // NOLINT(readability-identifier-naming) { @@ -7617,23 +7272,23 @@ bool sevalue_to_native(const se::Value &from, cc::gfx::UniformTexture * to, se:: } se::Value field; bool ok = true; - json->getProperty("set", &field); + json->getProperty("set", &field, true); if(!field.isNullOrUndefined()) { ok &= sevalue_to_native(field, &(to->set), ctx); } - json->getProperty("binding", &field); + json->getProperty("binding", &field, true); if(!field.isNullOrUndefined()) { ok &= sevalue_to_native(field, &(to->binding), ctx); } - json->getProperty("name", &field); + json->getProperty("name", &field, true); if(!field.isNullOrUndefined()) { ok &= sevalue_to_native(field, &(to->name), ctx); } - json->getProperty("type", &field); + json->getProperty("type", &field, true); if(!field.isNullOrUndefined()) { ok &= sevalue_to_native(field, &(to->type), ctx); } - json->getProperty("count", &field); + json->getProperty("count", &field, true); if(!field.isNullOrUndefined()) { ok &= sevalue_to_native(field, &(to->count), ctx); } @@ -7650,9 +7305,8 @@ static bool js_gfx_UniformTexture_constructor(se::State& s) // NOLINT(readabilit if(argc == 0) { - cc::gfx::UniformTexture* cobj = JSB_ALLOC(cc::gfx::UniformTexture); - s.thisObject()->setPrivateData(cobj); - se::NonRefNativePtrCreatedByCtorMap::emplace(cobj); + auto *ptr = JSB_MAKE_PRIVATE_OBJECT(cc::gfx::UniformTexture); + s.thisObject()->setPrivateObject(ptr); return true; } @@ -7660,21 +7314,19 @@ static bool js_gfx_UniformTexture_constructor(se::State& s) // NOLINT(readabilit { se::Object *json = args[0].toObject(); se::Value field; - - cc::gfx::UniformTexture* cobj = JSB_ALLOC(cc::gfx::UniformTexture); + auto *ptr = JSB_MAKE_PRIVATE_OBJECT(cc::gfx::UniformTexture); + auto cobj = ptr->get(); ok &= sevalue_to_native(args[0], cobj, s.thisObject()); if(!ok) { - JSB_FREE(cobj); + delete ptr; SE_REPORT_ERROR("argument convertion error"); return false; } - - s.thisObject()->setPrivateData(cobj); - se::NonRefNativePtrCreatedByCtorMap::emplace(cobj); + s.thisObject()->setPrivateObject(ptr); return true; } - - cc::gfx::UniformTexture* cobj = JSB_ALLOC(cc::gfx::UniformTexture); + auto *ptr = JSB_MAKE_PRIVATE_OBJECT(cc::gfx::UniformTexture); + auto cobj = ptr->get(); if (argc > 0 && !args[0].isUndefined()) { ok &= sevalue_to_native(args[0], &(cobj->set), nullptr); } @@ -7692,28 +7344,17 @@ static bool js_gfx_UniformTexture_constructor(se::State& s) // NOLINT(readabilit } if(!ok) { - JSB_FREE(cobj); + delete ptr; SE_REPORT_ERROR("Argument convertion error"); return false; } - - s.thisObject()->setPrivateData(cobj); - se::NonRefNativePtrCreatedByCtorMap::emplace(cobj); + s.thisObject()->setPrivateObject(ptr); return true; } SE_BIND_CTOR(js_gfx_UniformTexture_constructor, __jsb_cc_gfx_UniformTexture_class, js_cc_gfx_UniformTexture_finalize) - - static bool js_cc_gfx_UniformTexture_finalize(se::State& s) // NOLINT(readability-identifier-naming) { - auto iter = se::NonRefNativePtrCreatedByCtorMap::find(SE_THIS_OBJECT(s)); - if (iter != se::NonRefNativePtrCreatedByCtorMap::end()) - { - se::NonRefNativePtrCreatedByCtorMap::erase(iter); - auto* cobj = SE_THIS_OBJECT(s); - JSB_FREE(cobj); - } return true; } SE_BIND_FINALIZE_FUNC(js_cc_gfx_UniformTexture_finalize) @@ -7734,11 +7375,12 @@ bool js_register_gfx_UniformTexture(se::Object* obj) // NOLINT(readability-ident __jsb_cc_gfx_UniformTexture_proto = cls->getProto(); __jsb_cc_gfx_UniformTexture_class = cls; + se::ScriptEngine::getInstance()->clearException(); return true; } -se::Object* __jsb_cc_gfx_UniformStorageImage_proto = nullptr; -se::Class* __jsb_cc_gfx_UniformStorageImage_class = nullptr; +se::Object* __jsb_cc_gfx_UniformStorageImage_proto = nullptr; // NOLINT +se::Class* __jsb_cc_gfx_UniformStorageImage_class = nullptr; // NOLINT static bool js_gfx_UniformStorageImage_get_set(se::State& s) // NOLINT(readability-identifier-naming) { @@ -7915,27 +7557,27 @@ bool sevalue_to_native(const se::Value &from, cc::gfx::UniformStorageImage * to, } se::Value field; bool ok = true; - json->getProperty("set", &field); + json->getProperty("set", &field, true); if(!field.isNullOrUndefined()) { ok &= sevalue_to_native(field, &(to->set), ctx); } - json->getProperty("binding", &field); + json->getProperty("binding", &field, true); if(!field.isNullOrUndefined()) { ok &= sevalue_to_native(field, &(to->binding), ctx); } - json->getProperty("name", &field); + json->getProperty("name", &field, true); if(!field.isNullOrUndefined()) { ok &= sevalue_to_native(field, &(to->name), ctx); } - json->getProperty("type", &field); + json->getProperty("type", &field, true); if(!field.isNullOrUndefined()) { ok &= sevalue_to_native(field, &(to->type), ctx); } - json->getProperty("count", &field); + json->getProperty("count", &field, true); if(!field.isNullOrUndefined()) { ok &= sevalue_to_native(field, &(to->count), ctx); } - json->getProperty("memoryAccess", &field); + json->getProperty("memoryAccess", &field, true); if(!field.isNullOrUndefined()) { ok &= sevalue_to_native(field, &(to->memoryAccess), ctx); } @@ -7952,9 +7594,8 @@ static bool js_gfx_UniformStorageImage_constructor(se::State& s) // NOLINT(reada if(argc == 0) { - cc::gfx::UniformStorageImage* cobj = JSB_ALLOC(cc::gfx::UniformStorageImage); - s.thisObject()->setPrivateData(cobj); - se::NonRefNativePtrCreatedByCtorMap::emplace(cobj); + auto *ptr = JSB_MAKE_PRIVATE_OBJECT(cc::gfx::UniformStorageImage); + s.thisObject()->setPrivateObject(ptr); return true; } @@ -7962,21 +7603,19 @@ static bool js_gfx_UniformStorageImage_constructor(se::State& s) // NOLINT(reada { se::Object *json = args[0].toObject(); se::Value field; - - cc::gfx::UniformStorageImage* cobj = JSB_ALLOC(cc::gfx::UniformStorageImage); + auto *ptr = JSB_MAKE_PRIVATE_OBJECT(cc::gfx::UniformStorageImage); + auto cobj = ptr->get(); ok &= sevalue_to_native(args[0], cobj, s.thisObject()); if(!ok) { - JSB_FREE(cobj); + delete ptr; SE_REPORT_ERROR("argument convertion error"); return false; } - - s.thisObject()->setPrivateData(cobj); - se::NonRefNativePtrCreatedByCtorMap::emplace(cobj); + s.thisObject()->setPrivateObject(ptr); return true; } - - cc::gfx::UniformStorageImage* cobj = JSB_ALLOC(cc::gfx::UniformStorageImage); + auto *ptr = JSB_MAKE_PRIVATE_OBJECT(cc::gfx::UniformStorageImage); + auto cobj = ptr->get(); if (argc > 0 && !args[0].isUndefined()) { ok &= sevalue_to_native(args[0], &(cobj->set), nullptr); } @@ -7997,28 +7636,17 @@ static bool js_gfx_UniformStorageImage_constructor(se::State& s) // NOLINT(reada } if(!ok) { - JSB_FREE(cobj); + delete ptr; SE_REPORT_ERROR("Argument convertion error"); return false; } - - s.thisObject()->setPrivateData(cobj); - se::NonRefNativePtrCreatedByCtorMap::emplace(cobj); + s.thisObject()->setPrivateObject(ptr); return true; } SE_BIND_CTOR(js_gfx_UniformStorageImage_constructor, __jsb_cc_gfx_UniformStorageImage_class, js_cc_gfx_UniformStorageImage_finalize) - - static bool js_cc_gfx_UniformStorageImage_finalize(se::State& s) // NOLINT(readability-identifier-naming) { - auto iter = se::NonRefNativePtrCreatedByCtorMap::find(SE_THIS_OBJECT(s)); - if (iter != se::NonRefNativePtrCreatedByCtorMap::end()) - { - se::NonRefNativePtrCreatedByCtorMap::erase(iter); - auto* cobj = SE_THIS_OBJECT(s); - JSB_FREE(cobj); - } return true; } SE_BIND_FINALIZE_FUNC(js_cc_gfx_UniformStorageImage_finalize) @@ -8040,11 +7668,12 @@ bool js_register_gfx_UniformStorageImage(se::Object* obj) // NOLINT(readability- __jsb_cc_gfx_UniformStorageImage_proto = cls->getProto(); __jsb_cc_gfx_UniformStorageImage_class = cls; + se::ScriptEngine::getInstance()->clearException(); return true; } -se::Object* __jsb_cc_gfx_UniformStorageBuffer_proto = nullptr; -se::Class* __jsb_cc_gfx_UniformStorageBuffer_class = nullptr; +se::Object* __jsb_cc_gfx_UniformStorageBuffer_proto = nullptr; // NOLINT +se::Class* __jsb_cc_gfx_UniformStorageBuffer_class = nullptr; // NOLINT static bool js_gfx_UniformStorageBuffer_get_set(se::State& s) // NOLINT(readability-identifier-naming) { @@ -8194,23 +7823,23 @@ bool sevalue_to_native(const se::Value &from, cc::gfx::UniformStorageBuffer * to } se::Value field; bool ok = true; - json->getProperty("set", &field); + json->getProperty("set", &field, true); if(!field.isNullOrUndefined()) { ok &= sevalue_to_native(field, &(to->set), ctx); } - json->getProperty("binding", &field); + json->getProperty("binding", &field, true); if(!field.isNullOrUndefined()) { ok &= sevalue_to_native(field, &(to->binding), ctx); } - json->getProperty("name", &field); + json->getProperty("name", &field, true); if(!field.isNullOrUndefined()) { ok &= sevalue_to_native(field, &(to->name), ctx); } - json->getProperty("count", &field); + json->getProperty("count", &field, true); if(!field.isNullOrUndefined()) { ok &= sevalue_to_native(field, &(to->count), ctx); } - json->getProperty("memoryAccess", &field); + json->getProperty("memoryAccess", &field, true); if(!field.isNullOrUndefined()) { ok &= sevalue_to_native(field, &(to->memoryAccess), ctx); } @@ -8227,9 +7856,8 @@ static bool js_gfx_UniformStorageBuffer_constructor(se::State& s) // NOLINT(read if(argc == 0) { - cc::gfx::UniformStorageBuffer* cobj = JSB_ALLOC(cc::gfx::UniformStorageBuffer); - s.thisObject()->setPrivateData(cobj); - se::NonRefNativePtrCreatedByCtorMap::emplace(cobj); + auto *ptr = JSB_MAKE_PRIVATE_OBJECT(cc::gfx::UniformStorageBuffer); + s.thisObject()->setPrivateObject(ptr); return true; } @@ -8237,21 +7865,19 @@ static bool js_gfx_UniformStorageBuffer_constructor(se::State& s) // NOLINT(read { se::Object *json = args[0].toObject(); se::Value field; - - cc::gfx::UniformStorageBuffer* cobj = JSB_ALLOC(cc::gfx::UniformStorageBuffer); + auto *ptr = JSB_MAKE_PRIVATE_OBJECT(cc::gfx::UniformStorageBuffer); + auto cobj = ptr->get(); ok &= sevalue_to_native(args[0], cobj, s.thisObject()); if(!ok) { - JSB_FREE(cobj); + delete ptr; SE_REPORT_ERROR("argument convertion error"); return false; } - - s.thisObject()->setPrivateData(cobj); - se::NonRefNativePtrCreatedByCtorMap::emplace(cobj); + s.thisObject()->setPrivateObject(ptr); return true; } - - cc::gfx::UniformStorageBuffer* cobj = JSB_ALLOC(cc::gfx::UniformStorageBuffer); + auto *ptr = JSB_MAKE_PRIVATE_OBJECT(cc::gfx::UniformStorageBuffer); + auto cobj = ptr->get(); if (argc > 0 && !args[0].isUndefined()) { ok &= sevalue_to_native(args[0], &(cobj->set), nullptr); } @@ -8269,28 +7895,17 @@ static bool js_gfx_UniformStorageBuffer_constructor(se::State& s) // NOLINT(read } if(!ok) { - JSB_FREE(cobj); + delete ptr; SE_REPORT_ERROR("Argument convertion error"); return false; } - - s.thisObject()->setPrivateData(cobj); - se::NonRefNativePtrCreatedByCtorMap::emplace(cobj); + s.thisObject()->setPrivateObject(ptr); return true; } SE_BIND_CTOR(js_gfx_UniformStorageBuffer_constructor, __jsb_cc_gfx_UniformStorageBuffer_class, js_cc_gfx_UniformStorageBuffer_finalize) - - static bool js_cc_gfx_UniformStorageBuffer_finalize(se::State& s) // NOLINT(readability-identifier-naming) { - auto iter = se::NonRefNativePtrCreatedByCtorMap::find(SE_THIS_OBJECT(s)); - if (iter != se::NonRefNativePtrCreatedByCtorMap::end()) - { - se::NonRefNativePtrCreatedByCtorMap::erase(iter); - auto* cobj = SE_THIS_OBJECT(s); - JSB_FREE(cobj); - } return true; } SE_BIND_FINALIZE_FUNC(js_cc_gfx_UniformStorageBuffer_finalize) @@ -8311,11 +7926,12 @@ bool js_register_gfx_UniformStorageBuffer(se::Object* obj) // NOLINT(readability __jsb_cc_gfx_UniformStorageBuffer_proto = cls->getProto(); __jsb_cc_gfx_UniformStorageBuffer_class = cls; + se::ScriptEngine::getInstance()->clearException(); return true; } -se::Object* __jsb_cc_gfx_UniformInputAttachment_proto = nullptr; -se::Class* __jsb_cc_gfx_UniformInputAttachment_class = nullptr; +se::Object* __jsb_cc_gfx_UniformInputAttachment_proto = nullptr; // NOLINT +se::Class* __jsb_cc_gfx_UniformInputAttachment_class = nullptr; // NOLINT static bool js_gfx_UniformInputAttachment_get_set(se::State& s) // NOLINT(readability-identifier-naming) { @@ -8438,19 +8054,19 @@ bool sevalue_to_native(const se::Value &from, cc::gfx::UniformInputAttachment * } se::Value field; bool ok = true; - json->getProperty("set", &field); + json->getProperty("set", &field, true); if(!field.isNullOrUndefined()) { ok &= sevalue_to_native(field, &(to->set), ctx); } - json->getProperty("binding", &field); + json->getProperty("binding", &field, true); if(!field.isNullOrUndefined()) { ok &= sevalue_to_native(field, &(to->binding), ctx); } - json->getProperty("name", &field); + json->getProperty("name", &field, true); if(!field.isNullOrUndefined()) { ok &= sevalue_to_native(field, &(to->name), ctx); } - json->getProperty("count", &field); + json->getProperty("count", &field, true); if(!field.isNullOrUndefined()) { ok &= sevalue_to_native(field, &(to->count), ctx); } @@ -8467,9 +8083,8 @@ static bool js_gfx_UniformInputAttachment_constructor(se::State& s) // NOLINT(re if(argc == 0) { - cc::gfx::UniformInputAttachment* cobj = JSB_ALLOC(cc::gfx::UniformInputAttachment); - s.thisObject()->setPrivateData(cobj); - se::NonRefNativePtrCreatedByCtorMap::emplace(cobj); + auto *ptr = JSB_MAKE_PRIVATE_OBJECT(cc::gfx::UniformInputAttachment); + s.thisObject()->setPrivateObject(ptr); return true; } @@ -8477,21 +8092,19 @@ static bool js_gfx_UniformInputAttachment_constructor(se::State& s) // NOLINT(re { se::Object *json = args[0].toObject(); se::Value field; - - cc::gfx::UniformInputAttachment* cobj = JSB_ALLOC(cc::gfx::UniformInputAttachment); + auto *ptr = JSB_MAKE_PRIVATE_OBJECT(cc::gfx::UniformInputAttachment); + auto cobj = ptr->get(); ok &= sevalue_to_native(args[0], cobj, s.thisObject()); if(!ok) { - JSB_FREE(cobj); + delete ptr; SE_REPORT_ERROR("argument convertion error"); return false; } - - s.thisObject()->setPrivateData(cobj); - se::NonRefNativePtrCreatedByCtorMap::emplace(cobj); + s.thisObject()->setPrivateObject(ptr); return true; } - - cc::gfx::UniformInputAttachment* cobj = JSB_ALLOC(cc::gfx::UniformInputAttachment); + auto *ptr = JSB_MAKE_PRIVATE_OBJECT(cc::gfx::UniformInputAttachment); + auto cobj = ptr->get(); if (argc > 0 && !args[0].isUndefined()) { ok &= sevalue_to_native(args[0], &(cobj->set), nullptr); } @@ -8506,28 +8119,17 @@ static bool js_gfx_UniformInputAttachment_constructor(se::State& s) // NOLINT(re } if(!ok) { - JSB_FREE(cobj); + delete ptr; SE_REPORT_ERROR("Argument convertion error"); return false; } - - s.thisObject()->setPrivateData(cobj); - se::NonRefNativePtrCreatedByCtorMap::emplace(cobj); + s.thisObject()->setPrivateObject(ptr); return true; } SE_BIND_CTOR(js_gfx_UniformInputAttachment_constructor, __jsb_cc_gfx_UniformInputAttachment_class, js_cc_gfx_UniformInputAttachment_finalize) - - static bool js_cc_gfx_UniformInputAttachment_finalize(se::State& s) // NOLINT(readability-identifier-naming) { - auto iter = se::NonRefNativePtrCreatedByCtorMap::find(SE_THIS_OBJECT(s)); - if (iter != se::NonRefNativePtrCreatedByCtorMap::end()) - { - se::NonRefNativePtrCreatedByCtorMap::erase(iter); - auto* cobj = SE_THIS_OBJECT(s); - JSB_FREE(cobj); - } return true; } SE_BIND_FINALIZE_FUNC(js_cc_gfx_UniformInputAttachment_finalize) @@ -8547,11 +8149,12 @@ bool js_register_gfx_UniformInputAttachment(se::Object* obj) // NOLINT(readabili __jsb_cc_gfx_UniformInputAttachment_proto = cls->getProto(); __jsb_cc_gfx_UniformInputAttachment_class = cls; + se::ScriptEngine::getInstance()->clearException(); return true; } -se::Object* __jsb_cc_gfx_ShaderStage_proto = nullptr; -se::Class* __jsb_cc_gfx_ShaderStage_class = nullptr; +se::Object* __jsb_cc_gfx_ShaderStage_proto = nullptr; // NOLINT +se::Class* __jsb_cc_gfx_ShaderStage_class = nullptr; // NOLINT static bool js_gfx_ShaderStage_get_stage(se::State& s) // NOLINT(readability-identifier-naming) { @@ -8620,11 +8223,11 @@ bool sevalue_to_native(const se::Value &from, cc::gfx::ShaderStage * to, se::Obj } se::Value field; bool ok = true; - json->getProperty("stage", &field); + json->getProperty("stage", &field, true); if(!field.isNullOrUndefined()) { ok &= sevalue_to_native(field, &(to->stage), ctx); } - json->getProperty("source", &field); + json->getProperty("source", &field, true); if(!field.isNullOrUndefined()) { ok &= sevalue_to_native(field, &(to->source), ctx); } @@ -8641,9 +8244,8 @@ static bool js_gfx_ShaderStage_constructor(se::State& s) // NOLINT(readability-i if(argc == 0) { - cc::gfx::ShaderStage* cobj = JSB_ALLOC(cc::gfx::ShaderStage); - s.thisObject()->setPrivateData(cobj); - se::NonRefNativePtrCreatedByCtorMap::emplace(cobj); + auto *ptr = JSB_MAKE_PRIVATE_OBJECT(cc::gfx::ShaderStage); + s.thisObject()->setPrivateObject(ptr); return true; } @@ -8651,21 +8253,19 @@ static bool js_gfx_ShaderStage_constructor(se::State& s) // NOLINT(readability-i { se::Object *json = args[0].toObject(); se::Value field; - - cc::gfx::ShaderStage* cobj = JSB_ALLOC(cc::gfx::ShaderStage); + auto *ptr = JSB_MAKE_PRIVATE_OBJECT(cc::gfx::ShaderStage); + auto cobj = ptr->get(); ok &= sevalue_to_native(args[0], cobj, s.thisObject()); if(!ok) { - JSB_FREE(cobj); + delete ptr; SE_REPORT_ERROR("argument convertion error"); return false; } - - s.thisObject()->setPrivateData(cobj); - se::NonRefNativePtrCreatedByCtorMap::emplace(cobj); + s.thisObject()->setPrivateObject(ptr); return true; } - - cc::gfx::ShaderStage* cobj = JSB_ALLOC(cc::gfx::ShaderStage); + auto *ptr = JSB_MAKE_PRIVATE_OBJECT(cc::gfx::ShaderStage); + auto cobj = ptr->get(); if (argc > 0 && !args[0].isUndefined()) { ok &= sevalue_to_native(args[0], &(cobj->stage), nullptr); } @@ -8674,28 +8274,17 @@ static bool js_gfx_ShaderStage_constructor(se::State& s) // NOLINT(readability-i } if(!ok) { - JSB_FREE(cobj); + delete ptr; SE_REPORT_ERROR("Argument convertion error"); return false; } - - s.thisObject()->setPrivateData(cobj); - se::NonRefNativePtrCreatedByCtorMap::emplace(cobj); + s.thisObject()->setPrivateObject(ptr); return true; } SE_BIND_CTOR(js_gfx_ShaderStage_constructor, __jsb_cc_gfx_ShaderStage_class, js_cc_gfx_ShaderStage_finalize) - - static bool js_cc_gfx_ShaderStage_finalize(se::State& s) // NOLINT(readability-identifier-naming) { - auto iter = se::NonRefNativePtrCreatedByCtorMap::find(SE_THIS_OBJECT(s)); - if (iter != se::NonRefNativePtrCreatedByCtorMap::end()) - { - se::NonRefNativePtrCreatedByCtorMap::erase(iter); - auto* cobj = SE_THIS_OBJECT(s); - JSB_FREE(cobj); - } return true; } SE_BIND_FINALIZE_FUNC(js_cc_gfx_ShaderStage_finalize) @@ -8713,11 +8302,12 @@ bool js_register_gfx_ShaderStage(se::Object* obj) // NOLINT(readability-identifi __jsb_cc_gfx_ShaderStage_proto = cls->getProto(); __jsb_cc_gfx_ShaderStage_class = cls; + se::ScriptEngine::getInstance()->clearException(); return true; } -se::Object* __jsb_cc_gfx_Attribute_proto = nullptr; -se::Class* __jsb_cc_gfx_Attribute_class = nullptr; +se::Object* __jsb_cc_gfx_Attribute_proto = nullptr; // NOLINT +se::Class* __jsb_cc_gfx_Attribute_class = nullptr; // NOLINT static bool js_gfx_Attribute_get_name(se::State& s) // NOLINT(readability-identifier-naming) { @@ -8894,27 +8484,27 @@ bool sevalue_to_native(const se::Value &from, cc::gfx::Attribute * to, se::Objec } se::Value field; bool ok = true; - json->getProperty("name", &field); + json->getProperty("name", &field, true); if(!field.isNullOrUndefined()) { ok &= sevalue_to_native(field, &(to->name), ctx); } - json->getProperty("format", &field); + json->getProperty("format", &field, true); if(!field.isNullOrUndefined()) { ok &= sevalue_to_native(field, &(to->format), ctx); } - json->getProperty("isNormalized", &field); + json->getProperty("isNormalized", &field, true); if(!field.isNullOrUndefined()) { ok &= sevalue_to_native(field, &(to->isNormalized), ctx); } - json->getProperty("stream", &field); + json->getProperty("stream", &field, true); if(!field.isNullOrUndefined()) { ok &= sevalue_to_native(field, &(to->stream), ctx); } - json->getProperty("isInstanced", &field); + json->getProperty("isInstanced", &field, true); if(!field.isNullOrUndefined()) { ok &= sevalue_to_native(field, &(to->isInstanced), ctx); } - json->getProperty("location", &field); + json->getProperty("location", &field, true); if(!field.isNullOrUndefined()) { ok &= sevalue_to_native(field, &(to->location), ctx); } @@ -8931,9 +8521,8 @@ static bool js_gfx_Attribute_constructor(se::State& s) // NOLINT(readability-ide if(argc == 0) { - cc::gfx::Attribute* cobj = JSB_ALLOC(cc::gfx::Attribute); - s.thisObject()->setPrivateData(cobj); - se::NonRefNativePtrCreatedByCtorMap::emplace(cobj); + auto *ptr = JSB_MAKE_PRIVATE_OBJECT(cc::gfx::Attribute); + s.thisObject()->setPrivateObject(ptr); return true; } @@ -8941,21 +8530,19 @@ static bool js_gfx_Attribute_constructor(se::State& s) // NOLINT(readability-ide { se::Object *json = args[0].toObject(); se::Value field; - - cc::gfx::Attribute* cobj = JSB_ALLOC(cc::gfx::Attribute); + auto *ptr = JSB_MAKE_PRIVATE_OBJECT(cc::gfx::Attribute); + auto cobj = ptr->get(); ok &= sevalue_to_native(args[0], cobj, s.thisObject()); if(!ok) { - JSB_FREE(cobj); + delete ptr; SE_REPORT_ERROR("argument convertion error"); return false; } - - s.thisObject()->setPrivateData(cobj); - se::NonRefNativePtrCreatedByCtorMap::emplace(cobj); + s.thisObject()->setPrivateObject(ptr); return true; } - - cc::gfx::Attribute* cobj = JSB_ALLOC(cc::gfx::Attribute); + auto *ptr = JSB_MAKE_PRIVATE_OBJECT(cc::gfx::Attribute); + auto cobj = ptr->get(); if (argc > 0 && !args[0].isUndefined()) { ok &= sevalue_to_native(args[0], &(cobj->name), nullptr); } @@ -8976,28 +8563,17 @@ static bool js_gfx_Attribute_constructor(se::State& s) // NOLINT(readability-ide } if(!ok) { - JSB_FREE(cobj); + delete ptr; SE_REPORT_ERROR("Argument convertion error"); return false; } - - s.thisObject()->setPrivateData(cobj); - se::NonRefNativePtrCreatedByCtorMap::emplace(cobj); + s.thisObject()->setPrivateObject(ptr); return true; } SE_BIND_CTOR(js_gfx_Attribute_constructor, __jsb_cc_gfx_Attribute_class, js_cc_gfx_Attribute_finalize) - - static bool js_cc_gfx_Attribute_finalize(se::State& s) // NOLINT(readability-identifier-naming) { - auto iter = se::NonRefNativePtrCreatedByCtorMap::find(SE_THIS_OBJECT(s)); - if (iter != se::NonRefNativePtrCreatedByCtorMap::end()) - { - se::NonRefNativePtrCreatedByCtorMap::erase(iter); - auto* cobj = SE_THIS_OBJECT(s); - JSB_FREE(cobj); - } return true; } SE_BIND_FINALIZE_FUNC(js_cc_gfx_Attribute_finalize) @@ -9019,11 +8595,12 @@ bool js_register_gfx_Attribute(se::Object* obj) // NOLINT(readability-identifier __jsb_cc_gfx_Attribute_proto = cls->getProto(); __jsb_cc_gfx_Attribute_class = cls; + se::ScriptEngine::getInstance()->clearException(); return true; } -se::Object* __jsb_cc_gfx_ShaderInfo_proto = nullptr; -se::Class* __jsb_cc_gfx_ShaderInfo_class = nullptr; +se::Object* __jsb_cc_gfx_ShaderInfo_proto = nullptr; // NOLINT +se::Class* __jsb_cc_gfx_ShaderInfo_class = nullptr; // NOLINT static bool js_gfx_ShaderInfo_get_name(se::State& s) // NOLINT(readability-identifier-naming) { @@ -9308,43 +8885,43 @@ bool sevalue_to_native(const se::Value &from, cc::gfx::ShaderInfo * to, se::Obje } se::Value field; bool ok = true; - json->getProperty("name", &field); + json->getProperty("name", &field, true); if(!field.isNullOrUndefined()) { ok &= sevalue_to_native(field, &(to->name), ctx); } - json->getProperty("stages", &field); + json->getProperty("stages", &field, true); if(!field.isNullOrUndefined()) { ok &= sevalue_to_native(field, &(to->stages), ctx); } - json->getProperty("attributes", &field); + json->getProperty("attributes", &field, true); if(!field.isNullOrUndefined()) { ok &= sevalue_to_native(field, &(to->attributes), ctx); } - json->getProperty("blocks", &field); + json->getProperty("blocks", &field, true); if(!field.isNullOrUndefined()) { ok &= sevalue_to_native(field, &(to->blocks), ctx); } - json->getProperty("buffers", &field); + json->getProperty("buffers", &field, true); if(!field.isNullOrUndefined()) { ok &= sevalue_to_native(field, &(to->buffers), ctx); } - json->getProperty("samplerTextures", &field); + json->getProperty("samplerTextures", &field, true); if(!field.isNullOrUndefined()) { ok &= sevalue_to_native(field, &(to->samplerTextures), ctx); } - json->getProperty("samplers", &field); + json->getProperty("samplers", &field, true); if(!field.isNullOrUndefined()) { ok &= sevalue_to_native(field, &(to->samplers), ctx); } - json->getProperty("textures", &field); + json->getProperty("textures", &field, true); if(!field.isNullOrUndefined()) { ok &= sevalue_to_native(field, &(to->textures), ctx); } - json->getProperty("images", &field); + json->getProperty("images", &field, true); if(!field.isNullOrUndefined()) { ok &= sevalue_to_native(field, &(to->images), ctx); } - json->getProperty("subpassInputs", &field); + json->getProperty("subpassInputs", &field, true); if(!field.isNullOrUndefined()) { ok &= sevalue_to_native(field, &(to->subpassInputs), ctx); } @@ -9361,9 +8938,8 @@ static bool js_gfx_ShaderInfo_constructor(se::State& s) // NOLINT(readability-id if(argc == 0) { - cc::gfx::ShaderInfo* cobj = JSB_ALLOC(cc::gfx::ShaderInfo); - s.thisObject()->setPrivateData(cobj); - se::NonRefNativePtrCreatedByCtorMap::emplace(cobj); + auto *ptr = JSB_MAKE_PRIVATE_OBJECT(cc::gfx::ShaderInfo); + s.thisObject()->setPrivateObject(ptr); return true; } @@ -9371,21 +8947,19 @@ static bool js_gfx_ShaderInfo_constructor(se::State& s) // NOLINT(readability-id { se::Object *json = args[0].toObject(); se::Value field; - - cc::gfx::ShaderInfo* cobj = JSB_ALLOC(cc::gfx::ShaderInfo); + auto *ptr = JSB_MAKE_PRIVATE_OBJECT(cc::gfx::ShaderInfo); + auto cobj = ptr->get(); ok &= sevalue_to_native(args[0], cobj, s.thisObject()); if(!ok) { - JSB_FREE(cobj); + delete ptr; SE_REPORT_ERROR("argument convertion error"); return false; } - - s.thisObject()->setPrivateData(cobj); - se::NonRefNativePtrCreatedByCtorMap::emplace(cobj); + s.thisObject()->setPrivateObject(ptr); return true; } - - cc::gfx::ShaderInfo* cobj = JSB_ALLOC(cc::gfx::ShaderInfo); + auto *ptr = JSB_MAKE_PRIVATE_OBJECT(cc::gfx::ShaderInfo); + auto cobj = ptr->get(); if (argc > 0 && !args[0].isUndefined()) { ok &= sevalue_to_native(args[0], &(cobj->name), nullptr); } @@ -9418,28 +8992,17 @@ static bool js_gfx_ShaderInfo_constructor(se::State& s) // NOLINT(readability-id } if(!ok) { - JSB_FREE(cobj); + delete ptr; SE_REPORT_ERROR("Argument convertion error"); return false; } - - s.thisObject()->setPrivateData(cobj); - se::NonRefNativePtrCreatedByCtorMap::emplace(cobj); + s.thisObject()->setPrivateObject(ptr); return true; } SE_BIND_CTOR(js_gfx_ShaderInfo_constructor, __jsb_cc_gfx_ShaderInfo_class, js_cc_gfx_ShaderInfo_finalize) - - static bool js_cc_gfx_ShaderInfo_finalize(se::State& s) // NOLINT(readability-identifier-naming) { - auto iter = se::NonRefNativePtrCreatedByCtorMap::find(SE_THIS_OBJECT(s)); - if (iter != se::NonRefNativePtrCreatedByCtorMap::end()) - { - se::NonRefNativePtrCreatedByCtorMap::erase(iter); - auto* cobj = SE_THIS_OBJECT(s); - JSB_FREE(cobj); - } return true; } SE_BIND_FINALIZE_FUNC(js_cc_gfx_ShaderInfo_finalize) @@ -9465,11 +9028,12 @@ bool js_register_gfx_ShaderInfo(se::Object* obj) // NOLINT(readability-identifie __jsb_cc_gfx_ShaderInfo_proto = cls->getProto(); __jsb_cc_gfx_ShaderInfo_class = cls; + se::ScriptEngine::getInstance()->clearException(); return true; } -se::Object* __jsb_cc_gfx_InputAssemblerInfo_proto = nullptr; -se::Class* __jsb_cc_gfx_InputAssemblerInfo_class = nullptr; +se::Object* __jsb_cc_gfx_InputAssemblerInfo_proto = nullptr; // NOLINT +se::Class* __jsb_cc_gfx_InputAssemblerInfo_class = nullptr; // NOLINT static bool js_gfx_InputAssemblerInfo_get_attributes(se::State& s) // NOLINT(readability-identifier-naming) { @@ -9592,19 +9156,19 @@ bool sevalue_to_native(const se::Value &from, cc::gfx::InputAssemblerInfo * to, } se::Value field; bool ok = true; - json->getProperty("attributes", &field); + json->getProperty("attributes", &field, true); if(!field.isNullOrUndefined()) { ok &= sevalue_to_native(field, &(to->attributes), ctx); } - json->getProperty("vertexBuffers", &field); + json->getProperty("vertexBuffers", &field, true); if(!field.isNullOrUndefined()) { ok &= sevalue_to_native(field, &(to->vertexBuffers), ctx); } - json->getProperty("indexBuffer", &field); + json->getProperty("indexBuffer", &field, true); if(!field.isNullOrUndefined()) { ok &= sevalue_to_native(field, &(to->indexBuffer), ctx); } - json->getProperty("indirectBuffer", &field); + json->getProperty("indirectBuffer", &field, true); if(!field.isNullOrUndefined()) { ok &= sevalue_to_native(field, &(to->indirectBuffer), ctx); } @@ -9621,9 +9185,8 @@ static bool js_gfx_InputAssemblerInfo_constructor(se::State& s) // NOLINT(readab if(argc == 0) { - cc::gfx::InputAssemblerInfo* cobj = JSB_ALLOC(cc::gfx::InputAssemblerInfo); - s.thisObject()->setPrivateData(cobj); - se::NonRefNativePtrCreatedByCtorMap::emplace(cobj); + auto *ptr = JSB_MAKE_PRIVATE_OBJECT(cc::gfx::InputAssemblerInfo); + s.thisObject()->setPrivateObject(ptr); return true; } @@ -9631,21 +9194,19 @@ static bool js_gfx_InputAssemblerInfo_constructor(se::State& s) // NOLINT(readab { se::Object *json = args[0].toObject(); se::Value field; - - cc::gfx::InputAssemblerInfo* cobj = JSB_ALLOC(cc::gfx::InputAssemblerInfo); + auto *ptr = JSB_MAKE_PRIVATE_OBJECT(cc::gfx::InputAssemblerInfo); + auto cobj = ptr->get(); ok &= sevalue_to_native(args[0], cobj, s.thisObject()); if(!ok) { - JSB_FREE(cobj); + delete ptr; SE_REPORT_ERROR("argument convertion error"); return false; } - - s.thisObject()->setPrivateData(cobj); - se::NonRefNativePtrCreatedByCtorMap::emplace(cobj); + s.thisObject()->setPrivateObject(ptr); return true; } - - cc::gfx::InputAssemblerInfo* cobj = JSB_ALLOC(cc::gfx::InputAssemblerInfo); + auto *ptr = JSB_MAKE_PRIVATE_OBJECT(cc::gfx::InputAssemblerInfo); + auto cobj = ptr->get(); if (argc > 0 && !args[0].isUndefined()) { ok &= sevalue_to_native(args[0], &(cobj->attributes), nullptr); } @@ -9660,28 +9221,17 @@ static bool js_gfx_InputAssemblerInfo_constructor(se::State& s) // NOLINT(readab } if(!ok) { - JSB_FREE(cobj); + delete ptr; SE_REPORT_ERROR("Argument convertion error"); return false; } - - s.thisObject()->setPrivateData(cobj); - se::NonRefNativePtrCreatedByCtorMap::emplace(cobj); + s.thisObject()->setPrivateObject(ptr); return true; } SE_BIND_CTOR(js_gfx_InputAssemblerInfo_constructor, __jsb_cc_gfx_InputAssemblerInfo_class, js_cc_gfx_InputAssemblerInfo_finalize) - - static bool js_cc_gfx_InputAssemblerInfo_finalize(se::State& s) // NOLINT(readability-identifier-naming) { - auto iter = se::NonRefNativePtrCreatedByCtorMap::find(SE_THIS_OBJECT(s)); - if (iter != se::NonRefNativePtrCreatedByCtorMap::end()) - { - se::NonRefNativePtrCreatedByCtorMap::erase(iter); - auto* cobj = SE_THIS_OBJECT(s); - JSB_FREE(cobj); - } return true; } SE_BIND_FINALIZE_FUNC(js_cc_gfx_InputAssemblerInfo_finalize) @@ -9701,11 +9251,12 @@ bool js_register_gfx_InputAssemblerInfo(se::Object* obj) // NOLINT(readability-i __jsb_cc_gfx_InputAssemblerInfo_proto = cls->getProto(); __jsb_cc_gfx_InputAssemblerInfo_class = cls; + se::ScriptEngine::getInstance()->clearException(); return true; } -se::Object* __jsb_cc_gfx_ColorAttachment_proto = nullptr; -se::Class* __jsb_cc_gfx_ColorAttachment_class = nullptr; +se::Object* __jsb_cc_gfx_ColorAttachment_proto = nullptr; // NOLINT +se::Class* __jsb_cc_gfx_ColorAttachment_class = nullptr; // NOLINT static bool js_gfx_ColorAttachment_get_format(se::State& s) // NOLINT(readability-identifier-naming) { @@ -9909,31 +9460,31 @@ bool sevalue_to_native(const se::Value &from, cc::gfx::ColorAttachment * to, se: } se::Value field; bool ok = true; - json->getProperty("format", &field); + json->getProperty("format", &field, true); if(!field.isNullOrUndefined()) { ok &= sevalue_to_native(field, &(to->format), ctx); } - json->getProperty("sampleCount", &field); + json->getProperty("sampleCount", &field, true); if(!field.isNullOrUndefined()) { ok &= sevalue_to_native(field, &(to->sampleCount), ctx); } - json->getProperty("loadOp", &field); + json->getProperty("loadOp", &field, true); if(!field.isNullOrUndefined()) { ok &= sevalue_to_native(field, &(to->loadOp), ctx); } - json->getProperty("storeOp", &field); + json->getProperty("storeOp", &field, true); if(!field.isNullOrUndefined()) { ok &= sevalue_to_native(field, &(to->storeOp), ctx); } - json->getProperty("beginAccesses", &field); + json->getProperty("beginAccesses", &field, true); if(!field.isNullOrUndefined()) { ok &= sevalue_to_native(field, &(to->beginAccesses), ctx); } - json->getProperty("endAccesses", &field); + json->getProperty("endAccesses", &field, true); if(!field.isNullOrUndefined()) { ok &= sevalue_to_native(field, &(to->endAccesses), ctx); } - json->getProperty("isGeneralLayout", &field); + json->getProperty("isGeneralLayout", &field, true); if(!field.isNullOrUndefined()) { ok &= sevalue_to_native(field, &(to->isGeneralLayout), ctx); } @@ -9950,9 +9501,8 @@ static bool js_gfx_ColorAttachment_constructor(se::State& s) // NOLINT(readabili if(argc == 0) { - cc::gfx::ColorAttachment* cobj = JSB_ALLOC(cc::gfx::ColorAttachment); - s.thisObject()->setPrivateData(cobj); - se::NonRefNativePtrCreatedByCtorMap::emplace(cobj); + auto *ptr = JSB_MAKE_PRIVATE_OBJECT(cc::gfx::ColorAttachment); + s.thisObject()->setPrivateObject(ptr); return true; } @@ -9960,21 +9510,19 @@ static bool js_gfx_ColorAttachment_constructor(se::State& s) // NOLINT(readabili { se::Object *json = args[0].toObject(); se::Value field; - - cc::gfx::ColorAttachment* cobj = JSB_ALLOC(cc::gfx::ColorAttachment); + auto *ptr = JSB_MAKE_PRIVATE_OBJECT(cc::gfx::ColorAttachment); + auto cobj = ptr->get(); ok &= sevalue_to_native(args[0], cobj, s.thisObject()); if(!ok) { - JSB_FREE(cobj); + delete ptr; SE_REPORT_ERROR("argument convertion error"); return false; } - - s.thisObject()->setPrivateData(cobj); - se::NonRefNativePtrCreatedByCtorMap::emplace(cobj); + s.thisObject()->setPrivateObject(ptr); return true; } - - cc::gfx::ColorAttachment* cobj = JSB_ALLOC(cc::gfx::ColorAttachment); + auto *ptr = JSB_MAKE_PRIVATE_OBJECT(cc::gfx::ColorAttachment); + auto cobj = ptr->get(); if (argc > 0 && !args[0].isUndefined()) { ok &= sevalue_to_native(args[0], &(cobj->format), nullptr); } @@ -9998,28 +9546,17 @@ static bool js_gfx_ColorAttachment_constructor(se::State& s) // NOLINT(readabili } if(!ok) { - JSB_FREE(cobj); + delete ptr; SE_REPORT_ERROR("Argument convertion error"); return false; } - - s.thisObject()->setPrivateData(cobj); - se::NonRefNativePtrCreatedByCtorMap::emplace(cobj); + s.thisObject()->setPrivateObject(ptr); return true; } SE_BIND_CTOR(js_gfx_ColorAttachment_constructor, __jsb_cc_gfx_ColorAttachment_class, js_cc_gfx_ColorAttachment_finalize) - - static bool js_cc_gfx_ColorAttachment_finalize(se::State& s) // NOLINT(readability-identifier-naming) { - auto iter = se::NonRefNativePtrCreatedByCtorMap::find(SE_THIS_OBJECT(s)); - if (iter != se::NonRefNativePtrCreatedByCtorMap::end()) - { - se::NonRefNativePtrCreatedByCtorMap::erase(iter); - auto* cobj = SE_THIS_OBJECT(s); - JSB_FREE(cobj); - } return true; } SE_BIND_FINALIZE_FUNC(js_cc_gfx_ColorAttachment_finalize) @@ -10042,11 +9579,12 @@ bool js_register_gfx_ColorAttachment(se::Object* obj) // NOLINT(readability-iden __jsb_cc_gfx_ColorAttachment_proto = cls->getProto(); __jsb_cc_gfx_ColorAttachment_class = cls; + se::ScriptEngine::getInstance()->clearException(); return true; } -se::Object* __jsb_cc_gfx_DepthStencilAttachment_proto = nullptr; -se::Class* __jsb_cc_gfx_DepthStencilAttachment_class = nullptr; +se::Object* __jsb_cc_gfx_DepthStencilAttachment_proto = nullptr; // NOLINT +se::Class* __jsb_cc_gfx_DepthStencilAttachment_class = nullptr; // NOLINT static bool js_gfx_DepthStencilAttachment_get_format(se::State& s) // NOLINT(readability-identifier-naming) { @@ -10304,39 +9842,39 @@ bool sevalue_to_native(const se::Value &from, cc::gfx::DepthStencilAttachment * } se::Value field; bool ok = true; - json->getProperty("format", &field); + json->getProperty("format", &field, true); if(!field.isNullOrUndefined()) { ok &= sevalue_to_native(field, &(to->format), ctx); } - json->getProperty("sampleCount", &field); + json->getProperty("sampleCount", &field, true); if(!field.isNullOrUndefined()) { ok &= sevalue_to_native(field, &(to->sampleCount), ctx); } - json->getProperty("depthLoadOp", &field); + json->getProperty("depthLoadOp", &field, true); if(!field.isNullOrUndefined()) { ok &= sevalue_to_native(field, &(to->depthLoadOp), ctx); } - json->getProperty("depthStoreOp", &field); + json->getProperty("depthStoreOp", &field, true); if(!field.isNullOrUndefined()) { ok &= sevalue_to_native(field, &(to->depthStoreOp), ctx); } - json->getProperty("stencilLoadOp", &field); + json->getProperty("stencilLoadOp", &field, true); if(!field.isNullOrUndefined()) { ok &= sevalue_to_native(field, &(to->stencilLoadOp), ctx); } - json->getProperty("stencilStoreOp", &field); + json->getProperty("stencilStoreOp", &field, true); if(!field.isNullOrUndefined()) { ok &= sevalue_to_native(field, &(to->stencilStoreOp), ctx); } - json->getProperty("beginAccesses", &field); + json->getProperty("beginAccesses", &field, true); if(!field.isNullOrUndefined()) { ok &= sevalue_to_native(field, &(to->beginAccesses), ctx); } - json->getProperty("endAccesses", &field); + json->getProperty("endAccesses", &field, true); if(!field.isNullOrUndefined()) { ok &= sevalue_to_native(field, &(to->endAccesses), ctx); } - json->getProperty("isGeneralLayout", &field); + json->getProperty("isGeneralLayout", &field, true); if(!field.isNullOrUndefined()) { ok &= sevalue_to_native(field, &(to->isGeneralLayout), ctx); } @@ -10353,9 +9891,8 @@ static bool js_gfx_DepthStencilAttachment_constructor(se::State& s) // NOLINT(re if(argc == 0) { - cc::gfx::DepthStencilAttachment* cobj = JSB_ALLOC(cc::gfx::DepthStencilAttachment); - s.thisObject()->setPrivateData(cobj); - se::NonRefNativePtrCreatedByCtorMap::emplace(cobj); + auto *ptr = JSB_MAKE_PRIVATE_OBJECT(cc::gfx::DepthStencilAttachment); + s.thisObject()->setPrivateObject(ptr); return true; } @@ -10363,21 +9900,19 @@ static bool js_gfx_DepthStencilAttachment_constructor(se::State& s) // NOLINT(re { se::Object *json = args[0].toObject(); se::Value field; - - cc::gfx::DepthStencilAttachment* cobj = JSB_ALLOC(cc::gfx::DepthStencilAttachment); + auto *ptr = JSB_MAKE_PRIVATE_OBJECT(cc::gfx::DepthStencilAttachment); + auto cobj = ptr->get(); ok &= sevalue_to_native(args[0], cobj, s.thisObject()); if(!ok) { - JSB_FREE(cobj); + delete ptr; SE_REPORT_ERROR("argument convertion error"); return false; } - - s.thisObject()->setPrivateData(cobj); - se::NonRefNativePtrCreatedByCtorMap::emplace(cobj); + s.thisObject()->setPrivateObject(ptr); return true; } - - cc::gfx::DepthStencilAttachment* cobj = JSB_ALLOC(cc::gfx::DepthStencilAttachment); + auto *ptr = JSB_MAKE_PRIVATE_OBJECT(cc::gfx::DepthStencilAttachment); + auto cobj = ptr->get(); if (argc > 0 && !args[0].isUndefined()) { ok &= sevalue_to_native(args[0], &(cobj->format), nullptr); } @@ -10407,28 +9942,17 @@ static bool js_gfx_DepthStencilAttachment_constructor(se::State& s) // NOLINT(re } if(!ok) { - JSB_FREE(cobj); + delete ptr; SE_REPORT_ERROR("Argument convertion error"); return false; } - - s.thisObject()->setPrivateData(cobj); - se::NonRefNativePtrCreatedByCtorMap::emplace(cobj); + s.thisObject()->setPrivateObject(ptr); return true; } SE_BIND_CTOR(js_gfx_DepthStencilAttachment_constructor, __jsb_cc_gfx_DepthStencilAttachment_class, js_cc_gfx_DepthStencilAttachment_finalize) - - static bool js_cc_gfx_DepthStencilAttachment_finalize(se::State& s) // NOLINT(readability-identifier-naming) { - auto iter = se::NonRefNativePtrCreatedByCtorMap::find(SE_THIS_OBJECT(s)); - if (iter != se::NonRefNativePtrCreatedByCtorMap::end()) - { - se::NonRefNativePtrCreatedByCtorMap::erase(iter); - auto* cobj = SE_THIS_OBJECT(s); - JSB_FREE(cobj); - } return true; } SE_BIND_FINALIZE_FUNC(js_cc_gfx_DepthStencilAttachment_finalize) @@ -10453,11 +9977,12 @@ bool js_register_gfx_DepthStencilAttachment(se::Object* obj) // NOLINT(readabili __jsb_cc_gfx_DepthStencilAttachment_proto = cls->getProto(); __jsb_cc_gfx_DepthStencilAttachment_class = cls; + se::ScriptEngine::getInstance()->clearException(); return true; } -se::Object* __jsb_cc_gfx_SubpassInfo_proto = nullptr; -se::Class* __jsb_cc_gfx_SubpassInfo_class = nullptr; +se::Object* __jsb_cc_gfx_SubpassInfo_proto = nullptr; // NOLINT +se::Class* __jsb_cc_gfx_SubpassInfo_class = nullptr; // NOLINT static bool js_gfx_SubpassInfo_get_inputs(se::State& s) // NOLINT(readability-identifier-naming) { @@ -10688,35 +10213,35 @@ bool sevalue_to_native(const se::Value &from, cc::gfx::SubpassInfo * to, se::Obj } se::Value field; bool ok = true; - json->getProperty("inputs", &field); + json->getProperty("inputs", &field, true); if(!field.isNullOrUndefined()) { ok &= sevalue_to_native(field, &(to->inputs), ctx); } - json->getProperty("colors", &field); + json->getProperty("colors", &field, true); if(!field.isNullOrUndefined()) { ok &= sevalue_to_native(field, &(to->colors), ctx); } - json->getProperty("resolves", &field); + json->getProperty("resolves", &field, true); if(!field.isNullOrUndefined()) { ok &= sevalue_to_native(field, &(to->resolves), ctx); } - json->getProperty("preserves", &field); + json->getProperty("preserves", &field, true); if(!field.isNullOrUndefined()) { ok &= sevalue_to_native(field, &(to->preserves), ctx); } - json->getProperty("depthStencil", &field); + json->getProperty("depthStencil", &field, true); if(!field.isNullOrUndefined()) { ok &= sevalue_to_native(field, &(to->depthStencil), ctx); } - json->getProperty("depthStencilResolve", &field); + json->getProperty("depthStencilResolve", &field, true); if(!field.isNullOrUndefined()) { ok &= sevalue_to_native(field, &(to->depthStencilResolve), ctx); } - json->getProperty("depthResolveMode", &field); + json->getProperty("depthResolveMode", &field, true); if(!field.isNullOrUndefined()) { ok &= sevalue_to_native(field, &(to->depthResolveMode), ctx); } - json->getProperty("stencilResolveMode", &field); + json->getProperty("stencilResolveMode", &field, true); if(!field.isNullOrUndefined()) { ok &= sevalue_to_native(field, &(to->stencilResolveMode), ctx); } @@ -10733,9 +10258,8 @@ static bool js_gfx_SubpassInfo_constructor(se::State& s) // NOLINT(readability-i if(argc == 0) { - cc::gfx::SubpassInfo* cobj = JSB_ALLOC(cc::gfx::SubpassInfo); - s.thisObject()->setPrivateData(cobj); - se::NonRefNativePtrCreatedByCtorMap::emplace(cobj); + auto *ptr = JSB_MAKE_PRIVATE_OBJECT(cc::gfx::SubpassInfo); + s.thisObject()->setPrivateObject(ptr); return true; } @@ -10743,21 +10267,19 @@ static bool js_gfx_SubpassInfo_constructor(se::State& s) // NOLINT(readability-i { se::Object *json = args[0].toObject(); se::Value field; - - cc::gfx::SubpassInfo* cobj = JSB_ALLOC(cc::gfx::SubpassInfo); + auto *ptr = JSB_MAKE_PRIVATE_OBJECT(cc::gfx::SubpassInfo); + auto cobj = ptr->get(); ok &= sevalue_to_native(args[0], cobj, s.thisObject()); if(!ok) { - JSB_FREE(cobj); + delete ptr; SE_REPORT_ERROR("argument convertion error"); return false; } - - s.thisObject()->setPrivateData(cobj); - se::NonRefNativePtrCreatedByCtorMap::emplace(cobj); + s.thisObject()->setPrivateObject(ptr); return true; } - - cc::gfx::SubpassInfo* cobj = JSB_ALLOC(cc::gfx::SubpassInfo); + auto *ptr = JSB_MAKE_PRIVATE_OBJECT(cc::gfx::SubpassInfo); + auto cobj = ptr->get(); if (argc > 0 && !args[0].isUndefined()) { ok &= sevalue_to_native(args[0], &(cobj->inputs), nullptr); } @@ -10784,28 +10306,17 @@ static bool js_gfx_SubpassInfo_constructor(se::State& s) // NOLINT(readability-i } if(!ok) { - JSB_FREE(cobj); + delete ptr; SE_REPORT_ERROR("Argument convertion error"); return false; } - - s.thisObject()->setPrivateData(cobj); - se::NonRefNativePtrCreatedByCtorMap::emplace(cobj); + s.thisObject()->setPrivateObject(ptr); return true; } SE_BIND_CTOR(js_gfx_SubpassInfo_constructor, __jsb_cc_gfx_SubpassInfo_class, js_cc_gfx_SubpassInfo_finalize) - - static bool js_cc_gfx_SubpassInfo_finalize(se::State& s) // NOLINT(readability-identifier-naming) { - auto iter = se::NonRefNativePtrCreatedByCtorMap::find(SE_THIS_OBJECT(s)); - if (iter != se::NonRefNativePtrCreatedByCtorMap::end()) - { - se::NonRefNativePtrCreatedByCtorMap::erase(iter); - auto* cobj = SE_THIS_OBJECT(s); - JSB_FREE(cobj); - } return true; } SE_BIND_FINALIZE_FUNC(js_cc_gfx_SubpassInfo_finalize) @@ -10829,11 +10340,12 @@ bool js_register_gfx_SubpassInfo(se::Object* obj) // NOLINT(readability-identifi __jsb_cc_gfx_SubpassInfo_proto = cls->getProto(); __jsb_cc_gfx_SubpassInfo_class = cls; + se::ScriptEngine::getInstance()->clearException(); return true; } -se::Object* __jsb_cc_gfx_SubpassDependency_proto = nullptr; -se::Class* __jsb_cc_gfx_SubpassDependency_class = nullptr; +se::Object* __jsb_cc_gfx_SubpassDependency_proto = nullptr; // NOLINT +se::Class* __jsb_cc_gfx_SubpassDependency_class = nullptr; // NOLINT static bool js_gfx_SubpassDependency_get_srcSubpass(se::State& s) // NOLINT(readability-identifier-naming) { @@ -10956,19 +10468,19 @@ bool sevalue_to_native(const se::Value &from, cc::gfx::SubpassDependency * to, s } se::Value field; bool ok = true; - json->getProperty("srcSubpass", &field); + json->getProperty("srcSubpass", &field, true); if(!field.isNullOrUndefined()) { ok &= sevalue_to_native(field, &(to->srcSubpass), ctx); } - json->getProperty("dstSubpass", &field); + json->getProperty("dstSubpass", &field, true); if(!field.isNullOrUndefined()) { ok &= sevalue_to_native(field, &(to->dstSubpass), ctx); } - json->getProperty("srcAccesses", &field); + json->getProperty("srcAccesses", &field, true); if(!field.isNullOrUndefined()) { ok &= sevalue_to_native(field, &(to->srcAccesses), ctx); } - json->getProperty("dstAccesses", &field); + json->getProperty("dstAccesses", &field, true); if(!field.isNullOrUndefined()) { ok &= sevalue_to_native(field, &(to->dstAccesses), ctx); } @@ -10985,9 +10497,8 @@ static bool js_gfx_SubpassDependency_constructor(se::State& s) // NOLINT(readabi if(argc == 0) { - cc::gfx::SubpassDependency* cobj = JSB_ALLOC(cc::gfx::SubpassDependency); - s.thisObject()->setPrivateData(cobj); - se::NonRefNativePtrCreatedByCtorMap::emplace(cobj); + auto *ptr = JSB_MAKE_PRIVATE_OBJECT(cc::gfx::SubpassDependency); + s.thisObject()->setPrivateObject(ptr); return true; } @@ -10995,21 +10506,19 @@ static bool js_gfx_SubpassDependency_constructor(se::State& s) // NOLINT(readabi { se::Object *json = args[0].toObject(); se::Value field; - - cc::gfx::SubpassDependency* cobj = JSB_ALLOC(cc::gfx::SubpassDependency); + auto *ptr = JSB_MAKE_PRIVATE_OBJECT(cc::gfx::SubpassDependency); + auto cobj = ptr->get(); ok &= sevalue_to_native(args[0], cobj, s.thisObject()); if(!ok) { - JSB_FREE(cobj); + delete ptr; SE_REPORT_ERROR("argument convertion error"); return false; } - - s.thisObject()->setPrivateData(cobj); - se::NonRefNativePtrCreatedByCtorMap::emplace(cobj); + s.thisObject()->setPrivateObject(ptr); return true; } - - cc::gfx::SubpassDependency* cobj = JSB_ALLOC(cc::gfx::SubpassDependency); + auto *ptr = JSB_MAKE_PRIVATE_OBJECT(cc::gfx::SubpassDependency); + auto cobj = ptr->get(); if (argc > 0 && !args[0].isUndefined()) { ok &= sevalue_to_native(args[0], &(cobj->srcSubpass), nullptr); } @@ -11024,28 +10533,17 @@ static bool js_gfx_SubpassDependency_constructor(se::State& s) // NOLINT(readabi } if(!ok) { - JSB_FREE(cobj); + delete ptr; SE_REPORT_ERROR("Argument convertion error"); return false; } - - s.thisObject()->setPrivateData(cobj); - se::NonRefNativePtrCreatedByCtorMap::emplace(cobj); + s.thisObject()->setPrivateObject(ptr); return true; } SE_BIND_CTOR(js_gfx_SubpassDependency_constructor, __jsb_cc_gfx_SubpassDependency_class, js_cc_gfx_SubpassDependency_finalize) - - static bool js_cc_gfx_SubpassDependency_finalize(se::State& s) // NOLINT(readability-identifier-naming) { - auto iter = se::NonRefNativePtrCreatedByCtorMap::find(SE_THIS_OBJECT(s)); - if (iter != se::NonRefNativePtrCreatedByCtorMap::end()) - { - se::NonRefNativePtrCreatedByCtorMap::erase(iter); - auto* cobj = SE_THIS_OBJECT(s); - JSB_FREE(cobj); - } return true; } SE_BIND_FINALIZE_FUNC(js_cc_gfx_SubpassDependency_finalize) @@ -11065,11 +10563,12 @@ bool js_register_gfx_SubpassDependency(se::Object* obj) // NOLINT(readability-id __jsb_cc_gfx_SubpassDependency_proto = cls->getProto(); __jsb_cc_gfx_SubpassDependency_class = cls; + se::ScriptEngine::getInstance()->clearException(); return true; } -se::Object* __jsb_cc_gfx_RenderPassInfo_proto = nullptr; -se::Class* __jsb_cc_gfx_RenderPassInfo_class = nullptr; +se::Object* __jsb_cc_gfx_RenderPassInfo_proto = nullptr; // NOLINT +se::Class* __jsb_cc_gfx_RenderPassInfo_class = nullptr; // NOLINT static bool js_gfx_RenderPassInfo_get_colorAttachments(se::State& s) // NOLINT(readability-identifier-naming) { @@ -11192,19 +10691,19 @@ bool sevalue_to_native(const se::Value &from, cc::gfx::RenderPassInfo * to, se:: } se::Value field; bool ok = true; - json->getProperty("colorAttachments", &field); + json->getProperty("colorAttachments", &field, true); if(!field.isNullOrUndefined()) { ok &= sevalue_to_native(field, &(to->colorAttachments), ctx); } - json->getProperty("depthStencilAttachment", &field); + json->getProperty("depthStencilAttachment", &field, true); if(!field.isNullOrUndefined()) { ok &= sevalue_to_native(field, &(to->depthStencilAttachment), ctx); } - json->getProperty("subpasses", &field); + json->getProperty("subpasses", &field, true); if(!field.isNullOrUndefined()) { ok &= sevalue_to_native(field, &(to->subpasses), ctx); } - json->getProperty("dependencies", &field); + json->getProperty("dependencies", &field, true); if(!field.isNullOrUndefined()) { ok &= sevalue_to_native(field, &(to->dependencies), ctx); } @@ -11221,9 +10720,8 @@ static bool js_gfx_RenderPassInfo_constructor(se::State& s) // NOLINT(readabilit if(argc == 0) { - cc::gfx::RenderPassInfo* cobj = JSB_ALLOC(cc::gfx::RenderPassInfo); - s.thisObject()->setPrivateData(cobj); - se::NonRefNativePtrCreatedByCtorMap::emplace(cobj); + auto *ptr = JSB_MAKE_PRIVATE_OBJECT(cc::gfx::RenderPassInfo); + s.thisObject()->setPrivateObject(ptr); return true; } @@ -11231,21 +10729,19 @@ static bool js_gfx_RenderPassInfo_constructor(se::State& s) // NOLINT(readabilit { se::Object *json = args[0].toObject(); se::Value field; - - cc::gfx::RenderPassInfo* cobj = JSB_ALLOC(cc::gfx::RenderPassInfo); + auto *ptr = JSB_MAKE_PRIVATE_OBJECT(cc::gfx::RenderPassInfo); + auto cobj = ptr->get(); ok &= sevalue_to_native(args[0], cobj, s.thisObject()); if(!ok) { - JSB_FREE(cobj); + delete ptr; SE_REPORT_ERROR("argument convertion error"); return false; } - - s.thisObject()->setPrivateData(cobj); - se::NonRefNativePtrCreatedByCtorMap::emplace(cobj); + s.thisObject()->setPrivateObject(ptr); return true; } - - cc::gfx::RenderPassInfo* cobj = JSB_ALLOC(cc::gfx::RenderPassInfo); + auto *ptr = JSB_MAKE_PRIVATE_OBJECT(cc::gfx::RenderPassInfo); + auto cobj = ptr->get(); if (argc > 0 && !args[0].isUndefined()) { ok &= sevalue_to_native(args[0], &(cobj->colorAttachments), nullptr); } @@ -11260,28 +10756,17 @@ static bool js_gfx_RenderPassInfo_constructor(se::State& s) // NOLINT(readabilit } if(!ok) { - JSB_FREE(cobj); + delete ptr; SE_REPORT_ERROR("Argument convertion error"); return false; } - - s.thisObject()->setPrivateData(cobj); - se::NonRefNativePtrCreatedByCtorMap::emplace(cobj); + s.thisObject()->setPrivateObject(ptr); return true; } SE_BIND_CTOR(js_gfx_RenderPassInfo_constructor, __jsb_cc_gfx_RenderPassInfo_class, js_cc_gfx_RenderPassInfo_finalize) - - static bool js_cc_gfx_RenderPassInfo_finalize(se::State& s) // NOLINT(readability-identifier-naming) { - auto iter = se::NonRefNativePtrCreatedByCtorMap::find(SE_THIS_OBJECT(s)); - if (iter != se::NonRefNativePtrCreatedByCtorMap::end()) - { - se::NonRefNativePtrCreatedByCtorMap::erase(iter); - auto* cobj = SE_THIS_OBJECT(s); - JSB_FREE(cobj); - } return true; } SE_BIND_FINALIZE_FUNC(js_cc_gfx_RenderPassInfo_finalize) @@ -11301,11 +10786,12 @@ bool js_register_gfx_RenderPassInfo(se::Object* obj) // NOLINT(readability-ident __jsb_cc_gfx_RenderPassInfo_proto = cls->getProto(); __jsb_cc_gfx_RenderPassInfo_class = cls; + se::ScriptEngine::getInstance()->clearException(); return true; } -se::Object* __jsb_cc_gfx_GlobalBarrierInfo_proto = nullptr; -se::Class* __jsb_cc_gfx_GlobalBarrierInfo_class = nullptr; +se::Object* __jsb_cc_gfx_GlobalBarrierInfo_proto = nullptr; // NOLINT +se::Class* __jsb_cc_gfx_GlobalBarrierInfo_class = nullptr; // NOLINT static bool js_gfx_GlobalBarrierInfo_get_prevAccesses(se::State& s) // NOLINT(readability-identifier-naming) { @@ -11374,11 +10860,11 @@ bool sevalue_to_native(const se::Value &from, cc::gfx::GlobalBarrierInfo * to, s } se::Value field; bool ok = true; - json->getProperty("prevAccesses", &field); + json->getProperty("prevAccesses", &field, true); if(!field.isNullOrUndefined()) { ok &= sevalue_to_native(field, &(to->prevAccesses), ctx); } - json->getProperty("nextAccesses", &field); + json->getProperty("nextAccesses", &field, true); if(!field.isNullOrUndefined()) { ok &= sevalue_to_native(field, &(to->nextAccesses), ctx); } @@ -11395,9 +10881,8 @@ static bool js_gfx_GlobalBarrierInfo_constructor(se::State& s) // NOLINT(readabi if(argc == 0) { - cc::gfx::GlobalBarrierInfo* cobj = JSB_ALLOC(cc::gfx::GlobalBarrierInfo); - s.thisObject()->setPrivateData(cobj); - se::NonRefNativePtrCreatedByCtorMap::emplace(cobj); + auto *ptr = JSB_MAKE_PRIVATE_OBJECT(cc::gfx::GlobalBarrierInfo); + s.thisObject()->setPrivateObject(ptr); return true; } @@ -11405,21 +10890,19 @@ static bool js_gfx_GlobalBarrierInfo_constructor(se::State& s) // NOLINT(readabi { se::Object *json = args[0].toObject(); se::Value field; - - cc::gfx::GlobalBarrierInfo* cobj = JSB_ALLOC(cc::gfx::GlobalBarrierInfo); + auto *ptr = JSB_MAKE_PRIVATE_OBJECT(cc::gfx::GlobalBarrierInfo); + auto cobj = ptr->get(); ok &= sevalue_to_native(args[0], cobj, s.thisObject()); if(!ok) { - JSB_FREE(cobj); + delete ptr; SE_REPORT_ERROR("argument convertion error"); return false; } - - s.thisObject()->setPrivateData(cobj); - se::NonRefNativePtrCreatedByCtorMap::emplace(cobj); + s.thisObject()->setPrivateObject(ptr); return true; } - - cc::gfx::GlobalBarrierInfo* cobj = JSB_ALLOC(cc::gfx::GlobalBarrierInfo); + auto *ptr = JSB_MAKE_PRIVATE_OBJECT(cc::gfx::GlobalBarrierInfo); + auto cobj = ptr->get(); if (argc > 0 && !args[0].isUndefined()) { ok &= sevalue_to_native(args[0], &(cobj->prevAccesses), nullptr); } @@ -11428,28 +10911,17 @@ static bool js_gfx_GlobalBarrierInfo_constructor(se::State& s) // NOLINT(readabi } if(!ok) { - JSB_FREE(cobj); + delete ptr; SE_REPORT_ERROR("Argument convertion error"); return false; } - - s.thisObject()->setPrivateData(cobj); - se::NonRefNativePtrCreatedByCtorMap::emplace(cobj); + s.thisObject()->setPrivateObject(ptr); return true; } SE_BIND_CTOR(js_gfx_GlobalBarrierInfo_constructor, __jsb_cc_gfx_GlobalBarrierInfo_class, js_cc_gfx_GlobalBarrierInfo_finalize) - - static bool js_cc_gfx_GlobalBarrierInfo_finalize(se::State& s) // NOLINT(readability-identifier-naming) { - auto iter = se::NonRefNativePtrCreatedByCtorMap::find(SE_THIS_OBJECT(s)); - if (iter != se::NonRefNativePtrCreatedByCtorMap::end()) - { - se::NonRefNativePtrCreatedByCtorMap::erase(iter); - auto* cobj = SE_THIS_OBJECT(s); - JSB_FREE(cobj); - } return true; } SE_BIND_FINALIZE_FUNC(js_cc_gfx_GlobalBarrierInfo_finalize) @@ -11467,11 +10939,12 @@ bool js_register_gfx_GlobalBarrierInfo(se::Object* obj) // NOLINT(readability-id __jsb_cc_gfx_GlobalBarrierInfo_proto = cls->getProto(); __jsb_cc_gfx_GlobalBarrierInfo_class = cls; + se::ScriptEngine::getInstance()->clearException(); return true; } -se::Object* __jsb_cc_gfx_TextureBarrierInfo_proto = nullptr; -se::Class* __jsb_cc_gfx_TextureBarrierInfo_class = nullptr; +se::Object* __jsb_cc_gfx_TextureBarrierInfo_proto = nullptr; // NOLINT +se::Class* __jsb_cc_gfx_TextureBarrierInfo_class = nullptr; // NOLINT static bool js_gfx_TextureBarrierInfo_get_prevAccesses(se::State& s) // NOLINT(readability-identifier-naming) { @@ -11621,23 +11094,23 @@ bool sevalue_to_native(const se::Value &from, cc::gfx::TextureBarrierInfo * to, } se::Value field; bool ok = true; - json->getProperty("prevAccesses", &field); + json->getProperty("prevAccesses", &field, true); if(!field.isNullOrUndefined()) { ok &= sevalue_to_native(field, &(to->prevAccesses), ctx); } - json->getProperty("nextAccesses", &field); + json->getProperty("nextAccesses", &field, true); if(!field.isNullOrUndefined()) { ok &= sevalue_to_native(field, &(to->nextAccesses), ctx); } - json->getProperty("discardContents", &field); + json->getProperty("discardContents", &field, true); if(!field.isNullOrUndefined()) { ok &= sevalue_to_native(field, &(to->discardContents), ctx); } - json->getProperty("srcQueue", &field); + json->getProperty("srcQueue", &field, true); if(!field.isNullOrUndefined()) { ok &= sevalue_to_native(field, &(to->srcQueue), ctx); } - json->getProperty("dstQueue", &field); + json->getProperty("dstQueue", &field, true); if(!field.isNullOrUndefined()) { ok &= sevalue_to_native(field, &(to->dstQueue), ctx); } @@ -11654,9 +11127,8 @@ static bool js_gfx_TextureBarrierInfo_constructor(se::State& s) // NOLINT(readab if(argc == 0) { - cc::gfx::TextureBarrierInfo* cobj = JSB_ALLOC(cc::gfx::TextureBarrierInfo); - s.thisObject()->setPrivateData(cobj); - se::NonRefNativePtrCreatedByCtorMap::emplace(cobj); + auto *ptr = JSB_MAKE_PRIVATE_OBJECT(cc::gfx::TextureBarrierInfo); + s.thisObject()->setPrivateObject(ptr); return true; } @@ -11664,21 +11136,19 @@ static bool js_gfx_TextureBarrierInfo_constructor(se::State& s) // NOLINT(readab { se::Object *json = args[0].toObject(); se::Value field; - - cc::gfx::TextureBarrierInfo* cobj = JSB_ALLOC(cc::gfx::TextureBarrierInfo); + auto *ptr = JSB_MAKE_PRIVATE_OBJECT(cc::gfx::TextureBarrierInfo); + auto cobj = ptr->get(); ok &= sevalue_to_native(args[0], cobj, s.thisObject()); if(!ok) { - JSB_FREE(cobj); + delete ptr; SE_REPORT_ERROR("argument convertion error"); return false; } - - s.thisObject()->setPrivateData(cobj); - se::NonRefNativePtrCreatedByCtorMap::emplace(cobj); + s.thisObject()->setPrivateObject(ptr); return true; } - - cc::gfx::TextureBarrierInfo* cobj = JSB_ALLOC(cc::gfx::TextureBarrierInfo); + auto *ptr = JSB_MAKE_PRIVATE_OBJECT(cc::gfx::TextureBarrierInfo); + auto cobj = ptr->get(); if (argc > 0 && !args[0].isUndefined()) { ok &= sevalue_to_native(args[0], &(cobj->prevAccesses), nullptr); } @@ -11696,28 +11166,17 @@ static bool js_gfx_TextureBarrierInfo_constructor(se::State& s) // NOLINT(readab } if(!ok) { - JSB_FREE(cobj); + delete ptr; SE_REPORT_ERROR("Argument convertion error"); return false; } - - s.thisObject()->setPrivateData(cobj); - se::NonRefNativePtrCreatedByCtorMap::emplace(cobj); + s.thisObject()->setPrivateObject(ptr); return true; } SE_BIND_CTOR(js_gfx_TextureBarrierInfo_constructor, __jsb_cc_gfx_TextureBarrierInfo_class, js_cc_gfx_TextureBarrierInfo_finalize) - - static bool js_cc_gfx_TextureBarrierInfo_finalize(se::State& s) // NOLINT(readability-identifier-naming) { - auto iter = se::NonRefNativePtrCreatedByCtorMap::find(SE_THIS_OBJECT(s)); - if (iter != se::NonRefNativePtrCreatedByCtorMap::end()) - { - se::NonRefNativePtrCreatedByCtorMap::erase(iter); - auto* cobj = SE_THIS_OBJECT(s); - JSB_FREE(cobj); - } return true; } SE_BIND_FINALIZE_FUNC(js_cc_gfx_TextureBarrierInfo_finalize) @@ -11738,11 +11197,12 @@ bool js_register_gfx_TextureBarrierInfo(se::Object* obj) // NOLINT(readability-i __jsb_cc_gfx_TextureBarrierInfo_proto = cls->getProto(); __jsb_cc_gfx_TextureBarrierInfo_class = cls; + se::ScriptEngine::getInstance()->clearException(); return true; } -se::Object* __jsb_cc_gfx_FramebufferInfo_proto = nullptr; -se::Class* __jsb_cc_gfx_FramebufferInfo_class = nullptr; +se::Object* __jsb_cc_gfx_FramebufferInfo_proto = nullptr; // NOLINT +se::Class* __jsb_cc_gfx_FramebufferInfo_class = nullptr; // NOLINT static bool js_gfx_FramebufferInfo_get_renderPass(se::State& s) // NOLINT(readability-identifier-naming) { @@ -11838,15 +11298,15 @@ bool sevalue_to_native(const se::Value &from, cc::gfx::FramebufferInfo * to, se: } se::Value field; bool ok = true; - json->getProperty("renderPass", &field); + json->getProperty("renderPass", &field, true); if(!field.isNullOrUndefined()) { ok &= sevalue_to_native(field, &(to->renderPass), ctx); } - json->getProperty("colorTextures", &field); + json->getProperty("colorTextures", &field, true); if(!field.isNullOrUndefined()) { ok &= sevalue_to_native(field, &(to->colorTextures), ctx); } - json->getProperty("depthStencilTexture", &field); + json->getProperty("depthStencilTexture", &field, true); if(!field.isNullOrUndefined()) { ok &= sevalue_to_native(field, &(to->depthStencilTexture), ctx); } @@ -11863,9 +11323,8 @@ static bool js_gfx_FramebufferInfo_constructor(se::State& s) // NOLINT(readabili if(argc == 0) { - cc::gfx::FramebufferInfo* cobj = JSB_ALLOC(cc::gfx::FramebufferInfo); - s.thisObject()->setPrivateData(cobj); - se::NonRefNativePtrCreatedByCtorMap::emplace(cobj); + auto *ptr = JSB_MAKE_PRIVATE_OBJECT(cc::gfx::FramebufferInfo); + s.thisObject()->setPrivateObject(ptr); return true; } @@ -11873,21 +11332,19 @@ static bool js_gfx_FramebufferInfo_constructor(se::State& s) // NOLINT(readabili { se::Object *json = args[0].toObject(); se::Value field; - - cc::gfx::FramebufferInfo* cobj = JSB_ALLOC(cc::gfx::FramebufferInfo); + auto *ptr = JSB_MAKE_PRIVATE_OBJECT(cc::gfx::FramebufferInfo); + auto cobj = ptr->get(); ok &= sevalue_to_native(args[0], cobj, s.thisObject()); if(!ok) { - JSB_FREE(cobj); + delete ptr; SE_REPORT_ERROR("argument convertion error"); return false; } - - s.thisObject()->setPrivateData(cobj); - se::NonRefNativePtrCreatedByCtorMap::emplace(cobj); + s.thisObject()->setPrivateObject(ptr); return true; } - - cc::gfx::FramebufferInfo* cobj = JSB_ALLOC(cc::gfx::FramebufferInfo); + auto *ptr = JSB_MAKE_PRIVATE_OBJECT(cc::gfx::FramebufferInfo); + auto cobj = ptr->get(); if (argc > 0 && !args[0].isUndefined()) { ok &= sevalue_to_native(args[0], &(cobj->renderPass), nullptr); } @@ -11899,28 +11356,17 @@ static bool js_gfx_FramebufferInfo_constructor(se::State& s) // NOLINT(readabili } if(!ok) { - JSB_FREE(cobj); + delete ptr; SE_REPORT_ERROR("Argument convertion error"); return false; } - - s.thisObject()->setPrivateData(cobj); - se::NonRefNativePtrCreatedByCtorMap::emplace(cobj); + s.thisObject()->setPrivateObject(ptr); return true; } SE_BIND_CTOR(js_gfx_FramebufferInfo_constructor, __jsb_cc_gfx_FramebufferInfo_class, js_cc_gfx_FramebufferInfo_finalize) - - static bool js_cc_gfx_FramebufferInfo_finalize(se::State& s) // NOLINT(readability-identifier-naming) { - auto iter = se::NonRefNativePtrCreatedByCtorMap::find(SE_THIS_OBJECT(s)); - if (iter != se::NonRefNativePtrCreatedByCtorMap::end()) - { - se::NonRefNativePtrCreatedByCtorMap::erase(iter); - auto* cobj = SE_THIS_OBJECT(s); - JSB_FREE(cobj); - } return true; } SE_BIND_FINALIZE_FUNC(js_cc_gfx_FramebufferInfo_finalize) @@ -11939,11 +11385,12 @@ bool js_register_gfx_FramebufferInfo(se::Object* obj) // NOLINT(readability-iden __jsb_cc_gfx_FramebufferInfo_proto = cls->getProto(); __jsb_cc_gfx_FramebufferInfo_class = cls; + se::ScriptEngine::getInstance()->clearException(); return true; } -se::Object* __jsb_cc_gfx_DescriptorSetLayoutBinding_proto = nullptr; -se::Class* __jsb_cc_gfx_DescriptorSetLayoutBinding_class = nullptr; +se::Object* __jsb_cc_gfx_DescriptorSetLayoutBinding_proto = nullptr; // NOLINT +se::Class* __jsb_cc_gfx_DescriptorSetLayoutBinding_class = nullptr; // NOLINT static bool js_gfx_DescriptorSetLayoutBinding_get_binding(se::State& s) // NOLINT(readability-identifier-naming) { @@ -12093,23 +11540,23 @@ bool sevalue_to_native(const se::Value &from, cc::gfx::DescriptorSetLayoutBindin } se::Value field; bool ok = true; - json->getProperty("binding", &field); + json->getProperty("binding", &field, true); if(!field.isNullOrUndefined()) { ok &= sevalue_to_native(field, &(to->binding), ctx); } - json->getProperty("descriptorType", &field); + json->getProperty("descriptorType", &field, true); if(!field.isNullOrUndefined()) { ok &= sevalue_to_native(field, &(to->descriptorType), ctx); } - json->getProperty("count", &field); + json->getProperty("count", &field, true); if(!field.isNullOrUndefined()) { ok &= sevalue_to_native(field, &(to->count), ctx); } - json->getProperty("stageFlags", &field); + json->getProperty("stageFlags", &field, true); if(!field.isNullOrUndefined()) { ok &= sevalue_to_native(field, &(to->stageFlags), ctx); } - json->getProperty("immutableSamplers", &field); + json->getProperty("immutableSamplers", &field, true); if(!field.isNullOrUndefined()) { ok &= sevalue_to_native(field, &(to->immutableSamplers), ctx); } @@ -12126,9 +11573,8 @@ static bool js_gfx_DescriptorSetLayoutBinding_constructor(se::State& s) // NOLIN if(argc == 0) { - cc::gfx::DescriptorSetLayoutBinding* cobj = JSB_ALLOC(cc::gfx::DescriptorSetLayoutBinding); - s.thisObject()->setPrivateData(cobj); - se::NonRefNativePtrCreatedByCtorMap::emplace(cobj); + auto *ptr = JSB_MAKE_PRIVATE_OBJECT(cc::gfx::DescriptorSetLayoutBinding); + s.thisObject()->setPrivateObject(ptr); return true; } @@ -12136,21 +11582,19 @@ static bool js_gfx_DescriptorSetLayoutBinding_constructor(se::State& s) // NOLIN { se::Object *json = args[0].toObject(); se::Value field; - - cc::gfx::DescriptorSetLayoutBinding* cobj = JSB_ALLOC(cc::gfx::DescriptorSetLayoutBinding); + auto *ptr = JSB_MAKE_PRIVATE_OBJECT(cc::gfx::DescriptorSetLayoutBinding); + auto cobj = ptr->get(); ok &= sevalue_to_native(args[0], cobj, s.thisObject()); if(!ok) { - JSB_FREE(cobj); + delete ptr; SE_REPORT_ERROR("argument convertion error"); return false; } - - s.thisObject()->setPrivateData(cobj); - se::NonRefNativePtrCreatedByCtorMap::emplace(cobj); + s.thisObject()->setPrivateObject(ptr); return true; } - - cc::gfx::DescriptorSetLayoutBinding* cobj = JSB_ALLOC(cc::gfx::DescriptorSetLayoutBinding); + auto *ptr = JSB_MAKE_PRIVATE_OBJECT(cc::gfx::DescriptorSetLayoutBinding); + auto cobj = ptr->get(); if (argc > 0 && !args[0].isUndefined()) { ok &= sevalue_to_native(args[0], &(cobj->binding), nullptr); } @@ -12168,28 +11612,17 @@ static bool js_gfx_DescriptorSetLayoutBinding_constructor(se::State& s) // NOLIN } if(!ok) { - JSB_FREE(cobj); + delete ptr; SE_REPORT_ERROR("Argument convertion error"); return false; } - - s.thisObject()->setPrivateData(cobj); - se::NonRefNativePtrCreatedByCtorMap::emplace(cobj); + s.thisObject()->setPrivateObject(ptr); return true; } SE_BIND_CTOR(js_gfx_DescriptorSetLayoutBinding_constructor, __jsb_cc_gfx_DescriptorSetLayoutBinding_class, js_cc_gfx_DescriptorSetLayoutBinding_finalize) - - static bool js_cc_gfx_DescriptorSetLayoutBinding_finalize(se::State& s) // NOLINT(readability-identifier-naming) { - auto iter = se::NonRefNativePtrCreatedByCtorMap::find(SE_THIS_OBJECT(s)); - if (iter != se::NonRefNativePtrCreatedByCtorMap::end()) - { - se::NonRefNativePtrCreatedByCtorMap::erase(iter); - auto* cobj = SE_THIS_OBJECT(s); - JSB_FREE(cobj); - } return true; } SE_BIND_FINALIZE_FUNC(js_cc_gfx_DescriptorSetLayoutBinding_finalize) @@ -12210,11 +11643,12 @@ bool js_register_gfx_DescriptorSetLayoutBinding(se::Object* obj) // NOLINT(reada __jsb_cc_gfx_DescriptorSetLayoutBinding_proto = cls->getProto(); __jsb_cc_gfx_DescriptorSetLayoutBinding_class = cls; + se::ScriptEngine::getInstance()->clearException(); return true; } -se::Object* __jsb_cc_gfx_DescriptorSetLayoutInfo_proto = nullptr; -se::Class* __jsb_cc_gfx_DescriptorSetLayoutInfo_class = nullptr; +se::Object* __jsb_cc_gfx_DescriptorSetLayoutInfo_proto = nullptr; // NOLINT +se::Class* __jsb_cc_gfx_DescriptorSetLayoutInfo_class = nullptr; // NOLINT static bool js_gfx_DescriptorSetLayoutInfo_get_bindings(se::State& s) // NOLINT(readability-identifier-naming) { @@ -12256,7 +11690,7 @@ bool sevalue_to_native(const se::Value &from, cc::gfx::DescriptorSetLayoutInfo * } se::Value field; bool ok = true; - json->getProperty("bindings", &field); + json->getProperty("bindings", &field, true); if(!field.isNullOrUndefined()) { ok &= sevalue_to_native(field, &(to->bindings), ctx); } @@ -12273,40 +11707,28 @@ static bool js_gfx_DescriptorSetLayoutInfo_constructor(se::State& s) // NOLINT(r if(argc == 0) { - cc::gfx::DescriptorSetLayoutInfo* cobj = JSB_ALLOC(cc::gfx::DescriptorSetLayoutInfo); - s.thisObject()->setPrivateData(cobj); - se::NonRefNativePtrCreatedByCtorMap::emplace(cobj); + auto *ptr = JSB_MAKE_PRIVATE_OBJECT(cc::gfx::DescriptorSetLayoutInfo); + s.thisObject()->setPrivateObject(ptr); return true; } - - cc::gfx::DescriptorSetLayoutInfo* cobj = JSB_ALLOC(cc::gfx::DescriptorSetLayoutInfo); + auto *ptr = JSB_MAKE_PRIVATE_OBJECT(cc::gfx::DescriptorSetLayoutInfo); + auto cobj = ptr->get(); if (argc > 0 && !args[0].isUndefined()) { ok &= sevalue_to_native(args[0], &(cobj->bindings), nullptr); } if(!ok) { - JSB_FREE(cobj); + delete ptr; SE_REPORT_ERROR("Argument convertion error"); return false; } - - s.thisObject()->setPrivateData(cobj); - se::NonRefNativePtrCreatedByCtorMap::emplace(cobj); + s.thisObject()->setPrivateObject(ptr); return true; } SE_BIND_CTOR(js_gfx_DescriptorSetLayoutInfo_constructor, __jsb_cc_gfx_DescriptorSetLayoutInfo_class, js_cc_gfx_DescriptorSetLayoutInfo_finalize) - - static bool js_cc_gfx_DescriptorSetLayoutInfo_finalize(se::State& s) // NOLINT(readability-identifier-naming) { - auto iter = se::NonRefNativePtrCreatedByCtorMap::find(SE_THIS_OBJECT(s)); - if (iter != se::NonRefNativePtrCreatedByCtorMap::end()) - { - se::NonRefNativePtrCreatedByCtorMap::erase(iter); - auto* cobj = SE_THIS_OBJECT(s); - JSB_FREE(cobj); - } return true; } SE_BIND_FINALIZE_FUNC(js_cc_gfx_DescriptorSetLayoutInfo_finalize) @@ -12323,11 +11745,12 @@ bool js_register_gfx_DescriptorSetLayoutInfo(se::Object* obj) // NOLINT(readabil __jsb_cc_gfx_DescriptorSetLayoutInfo_proto = cls->getProto(); __jsb_cc_gfx_DescriptorSetLayoutInfo_class = cls; + se::ScriptEngine::getInstance()->clearException(); return true; } -se::Object* __jsb_cc_gfx_DescriptorSetInfo_proto = nullptr; -se::Class* __jsb_cc_gfx_DescriptorSetInfo_class = nullptr; +se::Object* __jsb_cc_gfx_DescriptorSetInfo_proto = nullptr; // NOLINT +se::Class* __jsb_cc_gfx_DescriptorSetInfo_class = nullptr; // NOLINT static bool js_gfx_DescriptorSetInfo_get_layout(se::State& s) // NOLINT(readability-identifier-naming) { @@ -12369,7 +11792,7 @@ bool sevalue_to_native(const se::Value &from, cc::gfx::DescriptorSetInfo * to, s } se::Value field; bool ok = true; - json->getProperty("layout", &field); + json->getProperty("layout", &field, true); if(!field.isNullOrUndefined()) { ok &= sevalue_to_native(field, &(to->layout), ctx); } @@ -12386,40 +11809,28 @@ static bool js_gfx_DescriptorSetInfo_constructor(se::State& s) // NOLINT(readabi if(argc == 0) { - cc::gfx::DescriptorSetInfo* cobj = JSB_ALLOC(cc::gfx::DescriptorSetInfo); - s.thisObject()->setPrivateData(cobj); - se::NonRefNativePtrCreatedByCtorMap::emplace(cobj); + auto *ptr = JSB_MAKE_PRIVATE_OBJECT(cc::gfx::DescriptorSetInfo); + s.thisObject()->setPrivateObject(ptr); return true; } - - cc::gfx::DescriptorSetInfo* cobj = JSB_ALLOC(cc::gfx::DescriptorSetInfo); + auto *ptr = JSB_MAKE_PRIVATE_OBJECT(cc::gfx::DescriptorSetInfo); + auto cobj = ptr->get(); if (argc > 0 && !args[0].isUndefined()) { ok &= sevalue_to_native(args[0], &(cobj->layout), nullptr); } if(!ok) { - JSB_FREE(cobj); + delete ptr; SE_REPORT_ERROR("Argument convertion error"); return false; } - - s.thisObject()->setPrivateData(cobj); - se::NonRefNativePtrCreatedByCtorMap::emplace(cobj); + s.thisObject()->setPrivateObject(ptr); return true; } SE_BIND_CTOR(js_gfx_DescriptorSetInfo_constructor, __jsb_cc_gfx_DescriptorSetInfo_class, js_cc_gfx_DescriptorSetInfo_finalize) - - static bool js_cc_gfx_DescriptorSetInfo_finalize(se::State& s) // NOLINT(readability-identifier-naming) { - auto iter = se::NonRefNativePtrCreatedByCtorMap::find(SE_THIS_OBJECT(s)); - if (iter != se::NonRefNativePtrCreatedByCtorMap::end()) - { - se::NonRefNativePtrCreatedByCtorMap::erase(iter); - auto* cobj = SE_THIS_OBJECT(s); - JSB_FREE(cobj); - } return true; } SE_BIND_FINALIZE_FUNC(js_cc_gfx_DescriptorSetInfo_finalize) @@ -12436,11 +11847,12 @@ bool js_register_gfx_DescriptorSetInfo(se::Object* obj) // NOLINT(readability-id __jsb_cc_gfx_DescriptorSetInfo_proto = cls->getProto(); __jsb_cc_gfx_DescriptorSetInfo_class = cls; + se::ScriptEngine::getInstance()->clearException(); return true; } -se::Object* __jsb_cc_gfx_PipelineLayoutInfo_proto = nullptr; -se::Class* __jsb_cc_gfx_PipelineLayoutInfo_class = nullptr; +se::Object* __jsb_cc_gfx_PipelineLayoutInfo_proto = nullptr; // NOLINT +se::Class* __jsb_cc_gfx_PipelineLayoutInfo_class = nullptr; // NOLINT static bool js_gfx_PipelineLayoutInfo_get_setLayouts(se::State& s) // NOLINT(readability-identifier-naming) { @@ -12482,7 +11894,7 @@ bool sevalue_to_native(const se::Value &from, cc::gfx::PipelineLayoutInfo * to, } se::Value field; bool ok = true; - json->getProperty("setLayouts", &field); + json->getProperty("setLayouts", &field, true); if(!field.isNullOrUndefined()) { ok &= sevalue_to_native(field, &(to->setLayouts), ctx); } @@ -12499,40 +11911,28 @@ static bool js_gfx_PipelineLayoutInfo_constructor(se::State& s) // NOLINT(readab if(argc == 0) { - cc::gfx::PipelineLayoutInfo* cobj = JSB_ALLOC(cc::gfx::PipelineLayoutInfo); - s.thisObject()->setPrivateData(cobj); - se::NonRefNativePtrCreatedByCtorMap::emplace(cobj); + auto *ptr = JSB_MAKE_PRIVATE_OBJECT(cc::gfx::PipelineLayoutInfo); + s.thisObject()->setPrivateObject(ptr); return true; } - - cc::gfx::PipelineLayoutInfo* cobj = JSB_ALLOC(cc::gfx::PipelineLayoutInfo); + auto *ptr = JSB_MAKE_PRIVATE_OBJECT(cc::gfx::PipelineLayoutInfo); + auto cobj = ptr->get(); if (argc > 0 && !args[0].isUndefined()) { ok &= sevalue_to_native(args[0], &(cobj->setLayouts), nullptr); } if(!ok) { - JSB_FREE(cobj); + delete ptr; SE_REPORT_ERROR("Argument convertion error"); return false; } - - s.thisObject()->setPrivateData(cobj); - se::NonRefNativePtrCreatedByCtorMap::emplace(cobj); + s.thisObject()->setPrivateObject(ptr); return true; } SE_BIND_CTOR(js_gfx_PipelineLayoutInfo_constructor, __jsb_cc_gfx_PipelineLayoutInfo_class, js_cc_gfx_PipelineLayoutInfo_finalize) - - static bool js_cc_gfx_PipelineLayoutInfo_finalize(se::State& s) // NOLINT(readability-identifier-naming) { - auto iter = se::NonRefNativePtrCreatedByCtorMap::find(SE_THIS_OBJECT(s)); - if (iter != se::NonRefNativePtrCreatedByCtorMap::end()) - { - se::NonRefNativePtrCreatedByCtorMap::erase(iter); - auto* cobj = SE_THIS_OBJECT(s); - JSB_FREE(cobj); - } return true; } SE_BIND_FINALIZE_FUNC(js_cc_gfx_PipelineLayoutInfo_finalize) @@ -12549,11 +11949,12 @@ bool js_register_gfx_PipelineLayoutInfo(se::Object* obj) // NOLINT(readability-i __jsb_cc_gfx_PipelineLayoutInfo_proto = cls->getProto(); __jsb_cc_gfx_PipelineLayoutInfo_class = cls; + se::ScriptEngine::getInstance()->clearException(); return true; } -se::Object* __jsb_cc_gfx_InputState_proto = nullptr; -se::Class* __jsb_cc_gfx_InputState_class = nullptr; +se::Object* __jsb_cc_gfx_InputState_proto = nullptr; // NOLINT +se::Class* __jsb_cc_gfx_InputState_class = nullptr; // NOLINT static bool js_gfx_InputState_get_attributes(se::State& s) // NOLINT(readability-identifier-naming) { @@ -12595,7 +11996,7 @@ bool sevalue_to_native(const se::Value &from, cc::gfx::InputState * to, se::Obje } se::Value field; bool ok = true; - json->getProperty("attributes", &field); + json->getProperty("attributes", &field, true); if(!field.isNullOrUndefined()) { ok &= sevalue_to_native(field, &(to->attributes), ctx); } @@ -12612,40 +12013,28 @@ static bool js_gfx_InputState_constructor(se::State& s) // NOLINT(readability-id if(argc == 0) { - cc::gfx::InputState* cobj = JSB_ALLOC(cc::gfx::InputState); - s.thisObject()->setPrivateData(cobj); - se::NonRefNativePtrCreatedByCtorMap::emplace(cobj); + auto *ptr = JSB_MAKE_PRIVATE_OBJECT(cc::gfx::InputState); + s.thisObject()->setPrivateObject(ptr); return true; } - - cc::gfx::InputState* cobj = JSB_ALLOC(cc::gfx::InputState); + auto *ptr = JSB_MAKE_PRIVATE_OBJECT(cc::gfx::InputState); + auto cobj = ptr->get(); if (argc > 0 && !args[0].isUndefined()) { ok &= sevalue_to_native(args[0], &(cobj->attributes), nullptr); } if(!ok) { - JSB_FREE(cobj); + delete ptr; SE_REPORT_ERROR("Argument convertion error"); return false; } - - s.thisObject()->setPrivateData(cobj); - se::NonRefNativePtrCreatedByCtorMap::emplace(cobj); + s.thisObject()->setPrivateObject(ptr); return true; } SE_BIND_CTOR(js_gfx_InputState_constructor, __jsb_cc_gfx_InputState_class, js_cc_gfx_InputState_finalize) - - static bool js_cc_gfx_InputState_finalize(se::State& s) // NOLINT(readability-identifier-naming) { - auto iter = se::NonRefNativePtrCreatedByCtorMap::find(SE_THIS_OBJECT(s)); - if (iter != se::NonRefNativePtrCreatedByCtorMap::end()) - { - se::NonRefNativePtrCreatedByCtorMap::erase(iter); - auto* cobj = SE_THIS_OBJECT(s); - JSB_FREE(cobj); - } return true; } SE_BIND_FINALIZE_FUNC(js_cc_gfx_InputState_finalize) @@ -12662,11 +12051,27 @@ bool js_register_gfx_InputState(se::Object* obj) // NOLINT(readability-identifie __jsb_cc_gfx_InputState_proto = cls->getProto(); __jsb_cc_gfx_InputState_class = cls; + se::ScriptEngine::getInstance()->clearException(); return true; } -se::Object* __jsb_cc_gfx_RasterizerState_proto = nullptr; -se::Class* __jsb_cc_gfx_RasterizerState_class = nullptr; +se::Object* __jsb_cc_gfx_RasterizerState_proto = nullptr; // NOLINT +se::Class* __jsb_cc_gfx_RasterizerState_class = nullptr; // NOLINT + +static bool js_gfx_RasterizerState_reset(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_gfx_RasterizerState_reset : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + if (argc == 0) { + cobj->reset(); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 0); + return false; +} +SE_BIND_FUNC(js_gfx_RasterizerState_reset) static bool js_gfx_RasterizerState_get_isDiscard(se::State& s) // NOLINT(readability-identifier-naming) { @@ -13005,51 +12410,51 @@ bool sevalue_to_native(const se::Value &from, cc::gfx::RasterizerState * to, se: } se::Value field; bool ok = true; - json->getProperty("isDiscard", &field); + json->getProperty("isDiscard", &field, true); if(!field.isNullOrUndefined()) { ok &= sevalue_to_native(field, &(to->isDiscard), ctx); } - json->getProperty("polygonMode", &field); + json->getProperty("polygonMode", &field, true); if(!field.isNullOrUndefined()) { ok &= sevalue_to_native(field, &(to->polygonMode), ctx); } - json->getProperty("shadeModel", &field); + json->getProperty("shadeModel", &field, true); if(!field.isNullOrUndefined()) { ok &= sevalue_to_native(field, &(to->shadeModel), ctx); } - json->getProperty("cullMode", &field); + json->getProperty("cullMode", &field, true); if(!field.isNullOrUndefined()) { ok &= sevalue_to_native(field, &(to->cullMode), ctx); } - json->getProperty("isFrontFaceCCW", &field); + json->getProperty("isFrontFaceCCW", &field, true); if(!field.isNullOrUndefined()) { ok &= sevalue_to_native(field, &(to->isFrontFaceCCW), ctx); } - json->getProperty("depthBiasEnabled", &field); + json->getProperty("depthBiasEnabled", &field, true); if(!field.isNullOrUndefined()) { ok &= sevalue_to_native(field, &(to->depthBiasEnabled), ctx); } - json->getProperty("depthBias", &field); + json->getProperty("depthBias", &field, true); if(!field.isNullOrUndefined()) { ok &= sevalue_to_native(field, &(to->depthBias), ctx); } - json->getProperty("depthBiasClamp", &field); + json->getProperty("depthBiasClamp", &field, true); if(!field.isNullOrUndefined()) { ok &= sevalue_to_native(field, &(to->depthBiasClamp), ctx); } - json->getProperty("depthBiasSlop", &field); + json->getProperty("depthBiasSlop", &field, true); if(!field.isNullOrUndefined()) { ok &= sevalue_to_native(field, &(to->depthBiasSlop), ctx); } - json->getProperty("isDepthClip", &field); + json->getProperty("isDepthClip", &field, true); if(!field.isNullOrUndefined()) { ok &= sevalue_to_native(field, &(to->isDepthClip), ctx); } - json->getProperty("isMultisample", &field); + json->getProperty("isMultisample", &field, true); if(!field.isNullOrUndefined()) { ok &= sevalue_to_native(field, &(to->isMultisample), ctx); } - json->getProperty("lineWidth", &field); + json->getProperty("lineWidth", &field, true); if(!field.isNullOrUndefined()) { ok &= sevalue_to_native(field, &(to->lineWidth), ctx); } @@ -13066,9 +12471,8 @@ static bool js_gfx_RasterizerState_constructor(se::State& s) // NOLINT(readabili if(argc == 0) { - cc::gfx::RasterizerState* cobj = JSB_ALLOC(cc::gfx::RasterizerState); - s.thisObject()->setPrivateData(cobj); - se::NonRefNativePtrCreatedByCtorMap::emplace(cobj); + auto *ptr = JSB_MAKE_PRIVATE_OBJECT(cc::gfx::RasterizerState); + s.thisObject()->setPrivateObject(ptr); return true; } @@ -13076,21 +12480,19 @@ static bool js_gfx_RasterizerState_constructor(se::State& s) // NOLINT(readabili { se::Object *json = args[0].toObject(); se::Value field; - - cc::gfx::RasterizerState* cobj = JSB_ALLOC(cc::gfx::RasterizerState); + auto *ptr = JSB_MAKE_PRIVATE_OBJECT(cc::gfx::RasterizerState); + auto cobj = ptr->get(); ok &= sevalue_to_native(args[0], cobj, s.thisObject()); if(!ok) { - JSB_FREE(cobj); + delete ptr; SE_REPORT_ERROR("argument convertion error"); return false; } - - s.thisObject()->setPrivateData(cobj); - se::NonRefNativePtrCreatedByCtorMap::emplace(cobj); + s.thisObject()->setPrivateObject(ptr); return true; } - - cc::gfx::RasterizerState* cobj = JSB_ALLOC(cc::gfx::RasterizerState); + auto *ptr = JSB_MAKE_PRIVATE_OBJECT(cc::gfx::RasterizerState); + auto cobj = ptr->get(); if (argc > 0 && !args[0].isUndefined()) { ok &= sevalue_to_native(args[0], &(cobj->isDiscard), nullptr); } @@ -13129,28 +12531,17 @@ static bool js_gfx_RasterizerState_constructor(se::State& s) // NOLINT(readabili } if(!ok) { - JSB_FREE(cobj); + delete ptr; SE_REPORT_ERROR("Argument convertion error"); return false; } - - s.thisObject()->setPrivateData(cobj); - se::NonRefNativePtrCreatedByCtorMap::emplace(cobj); + s.thisObject()->setPrivateObject(ptr); return true; } SE_BIND_CTOR(js_gfx_RasterizerState_constructor, __jsb_cc_gfx_RasterizerState_class, js_cc_gfx_RasterizerState_finalize) - - static bool js_cc_gfx_RasterizerState_finalize(se::State& s) // NOLINT(readability-identifier-naming) { - auto iter = se::NonRefNativePtrCreatedByCtorMap::find(SE_THIS_OBJECT(s)); - if (iter != se::NonRefNativePtrCreatedByCtorMap::end()) - { - se::NonRefNativePtrCreatedByCtorMap::erase(iter); - auto* cobj = SE_THIS_OBJECT(s); - JSB_FREE(cobj); - } return true; } SE_BIND_FINALIZE_FUNC(js_cc_gfx_RasterizerState_finalize) @@ -13171,6 +12562,7 @@ bool js_register_gfx_RasterizerState(se::Object* obj) // NOLINT(readability-iden cls->defineProperty("isDepthClip", _SE(js_gfx_RasterizerState_get_isDepthClip), _SE(js_gfx_RasterizerState_set_isDepthClip)); cls->defineProperty("isMultisample", _SE(js_gfx_RasterizerState_get_isMultisample), _SE(js_gfx_RasterizerState_set_isMultisample)); cls->defineProperty("lineWidth", _SE(js_gfx_RasterizerState_get_lineWidth), _SE(js_gfx_RasterizerState_set_lineWidth)); + cls->defineFunction("reset", _SE(js_gfx_RasterizerState_reset)); cls->defineFinalizeFunction(_SE(js_cc_gfx_RasterizerState_finalize)); cls->install(); JSBClassType::registerClass(cls); @@ -13178,11 +12570,27 @@ bool js_register_gfx_RasterizerState(se::Object* obj) // NOLINT(readability-iden __jsb_cc_gfx_RasterizerState_proto = cls->getProto(); __jsb_cc_gfx_RasterizerState_class = cls; + se::ScriptEngine::getInstance()->clearException(); return true; } -se::Object* __jsb_cc_gfx_DepthStencilState_proto = nullptr; -se::Class* __jsb_cc_gfx_DepthStencilState_class = nullptr; +se::Object* __jsb_cc_gfx_DepthStencilState_proto = nullptr; // NOLINT +se::Class* __jsb_cc_gfx_DepthStencilState_class = nullptr; // NOLINT + +static bool js_gfx_DepthStencilState_reset(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_gfx_DepthStencilState_reset : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + if (argc == 0) { + cobj->reset(); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 0); + return false; +} +SE_BIND_FUNC(js_gfx_DepthStencilState_reset) static bool js_gfx_DepthStencilState_get_depthTest(se::State& s) // NOLINT(readability-identifier-naming) { @@ -13710,79 +13118,79 @@ bool sevalue_to_native(const se::Value &from, cc::gfx::DepthStencilState * to, s } se::Value field; bool ok = true; - json->getProperty("depthTest", &field); + json->getProperty("depthTest", &field, true); if(!field.isNullOrUndefined()) { ok &= sevalue_to_native(field, &(to->depthTest), ctx); } - json->getProperty("depthWrite", &field); + json->getProperty("depthWrite", &field, true); if(!field.isNullOrUndefined()) { ok &= sevalue_to_native(field, &(to->depthWrite), ctx); } - json->getProperty("depthFunc", &field); + json->getProperty("depthFunc", &field, true); if(!field.isNullOrUndefined()) { ok &= sevalue_to_native(field, &(to->depthFunc), ctx); } - json->getProperty("stencilTestFront", &field); + json->getProperty("stencilTestFront", &field, true); if(!field.isNullOrUndefined()) { ok &= sevalue_to_native(field, &(to->stencilTestFront), ctx); } - json->getProperty("stencilFuncFront", &field); + json->getProperty("stencilFuncFront", &field, true); if(!field.isNullOrUndefined()) { ok &= sevalue_to_native(field, &(to->stencilFuncFront), ctx); } - json->getProperty("stencilReadMaskFront", &field); + json->getProperty("stencilReadMaskFront", &field, true); if(!field.isNullOrUndefined()) { ok &= sevalue_to_native(field, &(to->stencilReadMaskFront), ctx); } - json->getProperty("stencilWriteMaskFront", &field); + json->getProperty("stencilWriteMaskFront", &field, true); if(!field.isNullOrUndefined()) { ok &= sevalue_to_native(field, &(to->stencilWriteMaskFront), ctx); } - json->getProperty("stencilFailOpFront", &field); + json->getProperty("stencilFailOpFront", &field, true); if(!field.isNullOrUndefined()) { ok &= sevalue_to_native(field, &(to->stencilFailOpFront), ctx); } - json->getProperty("stencilZFailOpFront", &field); + json->getProperty("stencilZFailOpFront", &field, true); if(!field.isNullOrUndefined()) { ok &= sevalue_to_native(field, &(to->stencilZFailOpFront), ctx); } - json->getProperty("stencilPassOpFront", &field); + json->getProperty("stencilPassOpFront", &field, true); if(!field.isNullOrUndefined()) { ok &= sevalue_to_native(field, &(to->stencilPassOpFront), ctx); } - json->getProperty("stencilRefFront", &field); + json->getProperty("stencilRefFront", &field, true); if(!field.isNullOrUndefined()) { ok &= sevalue_to_native(field, &(to->stencilRefFront), ctx); } - json->getProperty("stencilTestBack", &field); + json->getProperty("stencilTestBack", &field, true); if(!field.isNullOrUndefined()) { ok &= sevalue_to_native(field, &(to->stencilTestBack), ctx); } - json->getProperty("stencilFuncBack", &field); + json->getProperty("stencilFuncBack", &field, true); if(!field.isNullOrUndefined()) { ok &= sevalue_to_native(field, &(to->stencilFuncBack), ctx); } - json->getProperty("stencilReadMaskBack", &field); + json->getProperty("stencilReadMaskBack", &field, true); if(!field.isNullOrUndefined()) { ok &= sevalue_to_native(field, &(to->stencilReadMaskBack), ctx); } - json->getProperty("stencilWriteMaskBack", &field); + json->getProperty("stencilWriteMaskBack", &field, true); if(!field.isNullOrUndefined()) { ok &= sevalue_to_native(field, &(to->stencilWriteMaskBack), ctx); } - json->getProperty("stencilFailOpBack", &field); + json->getProperty("stencilFailOpBack", &field, true); if(!field.isNullOrUndefined()) { ok &= sevalue_to_native(field, &(to->stencilFailOpBack), ctx); } - json->getProperty("stencilZFailOpBack", &field); + json->getProperty("stencilZFailOpBack", &field, true); if(!field.isNullOrUndefined()) { ok &= sevalue_to_native(field, &(to->stencilZFailOpBack), ctx); } - json->getProperty("stencilPassOpBack", &field); + json->getProperty("stencilPassOpBack", &field, true); if(!field.isNullOrUndefined()) { ok &= sevalue_to_native(field, &(to->stencilPassOpBack), ctx); } - json->getProperty("stencilRefBack", &field); + json->getProperty("stencilRefBack", &field, true); if(!field.isNullOrUndefined()) { ok &= sevalue_to_native(field, &(to->stencilRefBack), ctx); } @@ -13799,9 +13207,8 @@ static bool js_gfx_DepthStencilState_constructor(se::State& s) // NOLINT(readabi if(argc == 0) { - cc::gfx::DepthStencilState* cobj = JSB_ALLOC(cc::gfx::DepthStencilState); - s.thisObject()->setPrivateData(cobj); - se::NonRefNativePtrCreatedByCtorMap::emplace(cobj); + auto *ptr = JSB_MAKE_PRIVATE_OBJECT(cc::gfx::DepthStencilState); + s.thisObject()->setPrivateObject(ptr); return true; } @@ -13809,21 +13216,19 @@ static bool js_gfx_DepthStencilState_constructor(se::State& s) // NOLINT(readabi { se::Object *json = args[0].toObject(); se::Value field; - - cc::gfx::DepthStencilState* cobj = JSB_ALLOC(cc::gfx::DepthStencilState); + auto *ptr = JSB_MAKE_PRIVATE_OBJECT(cc::gfx::DepthStencilState); + auto cobj = ptr->get(); ok &= sevalue_to_native(args[0], cobj, s.thisObject()); if(!ok) { - JSB_FREE(cobj); + delete ptr; SE_REPORT_ERROR("argument convertion error"); return false; } - - s.thisObject()->setPrivateData(cobj); - se::NonRefNativePtrCreatedByCtorMap::emplace(cobj); + s.thisObject()->setPrivateObject(ptr); return true; } - - cc::gfx::DepthStencilState* cobj = JSB_ALLOC(cc::gfx::DepthStencilState); + auto *ptr = JSB_MAKE_PRIVATE_OBJECT(cc::gfx::DepthStencilState); + auto cobj = ptr->get(); if (argc > 0 && !args[0].isUndefined()) { ok &= sevalue_to_native(args[0], &(cobj->depthTest), nullptr); } @@ -13883,28 +13288,17 @@ static bool js_gfx_DepthStencilState_constructor(se::State& s) // NOLINT(readabi } if(!ok) { - JSB_FREE(cobj); + delete ptr; SE_REPORT_ERROR("Argument convertion error"); return false; } - - s.thisObject()->setPrivateData(cobj); - se::NonRefNativePtrCreatedByCtorMap::emplace(cobj); + s.thisObject()->setPrivateObject(ptr); return true; } SE_BIND_CTOR(js_gfx_DepthStencilState_constructor, __jsb_cc_gfx_DepthStencilState_class, js_cc_gfx_DepthStencilState_finalize) - - static bool js_cc_gfx_DepthStencilState_finalize(se::State& s) // NOLINT(readability-identifier-naming) { - auto iter = se::NonRefNativePtrCreatedByCtorMap::find(SE_THIS_OBJECT(s)); - if (iter != se::NonRefNativePtrCreatedByCtorMap::end()) - { - se::NonRefNativePtrCreatedByCtorMap::erase(iter); - auto* cobj = SE_THIS_OBJECT(s); - JSB_FREE(cobj); - } return true; } SE_BIND_FINALIZE_FUNC(js_cc_gfx_DepthStencilState_finalize) @@ -13932,6 +13326,7 @@ bool js_register_gfx_DepthStencilState(se::Object* obj) // NOLINT(readability-id cls->defineProperty("stencilZFailOpBack", _SE(js_gfx_DepthStencilState_get_stencilZFailOpBack), _SE(js_gfx_DepthStencilState_set_stencilZFailOpBack)); cls->defineProperty("stencilPassOpBack", _SE(js_gfx_DepthStencilState_get_stencilPassOpBack), _SE(js_gfx_DepthStencilState_set_stencilPassOpBack)); cls->defineProperty("stencilRefBack", _SE(js_gfx_DepthStencilState_get_stencilRefBack), _SE(js_gfx_DepthStencilState_set_stencilRefBack)); + cls->defineFunction("reset", _SE(js_gfx_DepthStencilState_reset)); cls->defineFinalizeFunction(_SE(js_cc_gfx_DepthStencilState_finalize)); cls->install(); JSBClassType::registerClass(cls); @@ -13939,11 +13334,12 @@ bool js_register_gfx_DepthStencilState(se::Object* obj) // NOLINT(readability-id __jsb_cc_gfx_DepthStencilState_proto = cls->getProto(); __jsb_cc_gfx_DepthStencilState_class = cls; + se::ScriptEngine::getInstance()->clearException(); return true; } -se::Object* __jsb_cc_gfx_BlendTarget_proto = nullptr; -se::Class* __jsb_cc_gfx_BlendTarget_class = nullptr; +se::Object* __jsb_cc_gfx_BlendTarget_proto = nullptr; // NOLINT +se::Class* __jsb_cc_gfx_BlendTarget_class = nullptr; // NOLINT static bool js_gfx_BlendTarget_get_blend(se::State& s) // NOLINT(readability-identifier-naming) { @@ -14174,35 +13570,35 @@ bool sevalue_to_native(const se::Value &from, cc::gfx::BlendTarget * to, se::Obj } se::Value field; bool ok = true; - json->getProperty("blend", &field); + json->getProperty("blend", &field, true); if(!field.isNullOrUndefined()) { ok &= sevalue_to_native(field, &(to->blend), ctx); } - json->getProperty("blendSrc", &field); + json->getProperty("blendSrc", &field, true); if(!field.isNullOrUndefined()) { ok &= sevalue_to_native(field, &(to->blendSrc), ctx); } - json->getProperty("blendDst", &field); + json->getProperty("blendDst", &field, true); if(!field.isNullOrUndefined()) { ok &= sevalue_to_native(field, &(to->blendDst), ctx); } - json->getProperty("blendEq", &field); + json->getProperty("blendEq", &field, true); if(!field.isNullOrUndefined()) { ok &= sevalue_to_native(field, &(to->blendEq), ctx); } - json->getProperty("blendSrcAlpha", &field); + json->getProperty("blendSrcAlpha", &field, true); if(!field.isNullOrUndefined()) { ok &= sevalue_to_native(field, &(to->blendSrcAlpha), ctx); } - json->getProperty("blendDstAlpha", &field); + json->getProperty("blendDstAlpha", &field, true); if(!field.isNullOrUndefined()) { ok &= sevalue_to_native(field, &(to->blendDstAlpha), ctx); } - json->getProperty("blendAlphaEq", &field); + json->getProperty("blendAlphaEq", &field, true); if(!field.isNullOrUndefined()) { ok &= sevalue_to_native(field, &(to->blendAlphaEq), ctx); } - json->getProperty("blendColorMask", &field); + json->getProperty("blendColorMask", &field, true); if(!field.isNullOrUndefined()) { ok &= sevalue_to_native(field, &(to->blendColorMask), ctx); } @@ -14219,9 +13615,8 @@ static bool js_gfx_BlendTarget_constructor(se::State& s) // NOLINT(readability-i if(argc == 0) { - cc::gfx::BlendTarget* cobj = JSB_ALLOC(cc::gfx::BlendTarget); - s.thisObject()->setPrivateData(cobj); - se::NonRefNativePtrCreatedByCtorMap::emplace(cobj); + auto *ptr = JSB_MAKE_PRIVATE_OBJECT(cc::gfx::BlendTarget); + s.thisObject()->setPrivateObject(ptr); return true; } @@ -14229,21 +13624,19 @@ static bool js_gfx_BlendTarget_constructor(se::State& s) // NOLINT(readability-i { se::Object *json = args[0].toObject(); se::Value field; - - cc::gfx::BlendTarget* cobj = JSB_ALLOC(cc::gfx::BlendTarget); + auto *ptr = JSB_MAKE_PRIVATE_OBJECT(cc::gfx::BlendTarget); + auto cobj = ptr->get(); ok &= sevalue_to_native(args[0], cobj, s.thisObject()); if(!ok) { - JSB_FREE(cobj); + delete ptr; SE_REPORT_ERROR("argument convertion error"); return false; } - - s.thisObject()->setPrivateData(cobj); - se::NonRefNativePtrCreatedByCtorMap::emplace(cobj); + s.thisObject()->setPrivateObject(ptr); return true; } - - cc::gfx::BlendTarget* cobj = JSB_ALLOC(cc::gfx::BlendTarget); + auto *ptr = JSB_MAKE_PRIVATE_OBJECT(cc::gfx::BlendTarget); + auto cobj = ptr->get(); if (argc > 0 && !args[0].isUndefined()) { ok &= sevalue_to_native(args[0], &(cobj->blend), nullptr); } @@ -14270,28 +13663,17 @@ static bool js_gfx_BlendTarget_constructor(se::State& s) // NOLINT(readability-i } if(!ok) { - JSB_FREE(cobj); + delete ptr; SE_REPORT_ERROR("Argument convertion error"); return false; } - - s.thisObject()->setPrivateData(cobj); - se::NonRefNativePtrCreatedByCtorMap::emplace(cobj); + s.thisObject()->setPrivateObject(ptr); return true; } SE_BIND_CTOR(js_gfx_BlendTarget_constructor, __jsb_cc_gfx_BlendTarget_class, js_cc_gfx_BlendTarget_finalize) - - static bool js_cc_gfx_BlendTarget_finalize(se::State& s) // NOLINT(readability-identifier-naming) { - auto iter = se::NonRefNativePtrCreatedByCtorMap::find(SE_THIS_OBJECT(s)); - if (iter != se::NonRefNativePtrCreatedByCtorMap::end()) - { - se::NonRefNativePtrCreatedByCtorMap::erase(iter); - auto* cobj = SE_THIS_OBJECT(s); - JSB_FREE(cobj); - } return true; } SE_BIND_FINALIZE_FUNC(js_cc_gfx_BlendTarget_finalize) @@ -14315,11 +13697,63 @@ bool js_register_gfx_BlendTarget(se::Object* obj) // NOLINT(readability-identifi __jsb_cc_gfx_BlendTarget_proto = cls->getProto(); __jsb_cc_gfx_BlendTarget_class = cls; + se::ScriptEngine::getInstance()->clearException(); return true; } -se::Object* __jsb_cc_gfx_BlendState_proto = nullptr; -se::Class* __jsb_cc_gfx_BlendState_class = nullptr; +se::Object* __jsb_cc_gfx_BlendState_proto = nullptr; // NOLINT +se::Class* __jsb_cc_gfx_BlendState_class = nullptr; // NOLINT + +static bool js_gfx_BlendState_destroy(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_gfx_BlendState_destroy : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + if (argc == 0) { + cobj->destroy(); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 0); + return false; +} +SE_BIND_FUNC(js_gfx_BlendState_destroy) + +static bool js_gfx_BlendState_reset(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_gfx_BlendState_reset : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + if (argc == 0) { + cobj->reset(); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 0); + return false; +} +SE_BIND_FUNC(js_gfx_BlendState_reset) + +static bool js_gfx_BlendState_setTarget(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_gfx_BlendState_setTarget : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 2) { + HolderType arg0 = {}; + HolderType arg1 = {}; + ok &= sevalue_to_native(args[0], &arg0, s.thisObject()); + ok &= sevalue_to_native(args[1], &arg1, s.thisObject()); + SE_PRECONDITION2(ok, false, "js_gfx_BlendState_setTarget : Error processing arguments"); + cobj->setTarget(arg0.value(), arg1.value()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 2); + return false; +} +SE_BIND_FUNC(js_gfx_BlendState_setTarget) static bool js_gfx_BlendState_get_isA2C(se::State& s) // NOLINT(readability-identifier-naming) { @@ -14442,19 +13876,19 @@ bool sevalue_to_native(const se::Value &from, cc::gfx::BlendState * to, se::Obje } se::Value field; bool ok = true; - json->getProperty("isA2C", &field); + json->getProperty("isA2C", &field, true); if(!field.isNullOrUndefined()) { ok &= sevalue_to_native(field, &(to->isA2C), ctx); } - json->getProperty("isIndepend", &field); + json->getProperty("isIndepend", &field, true); if(!field.isNullOrUndefined()) { ok &= sevalue_to_native(field, &(to->isIndepend), ctx); } - json->getProperty("blendColor", &field); + json->getProperty("blendColor", &field, true); if(!field.isNullOrUndefined()) { ok &= sevalue_to_native(field, &(to->blendColor), ctx); } - json->getProperty("targets", &field); + json->getProperty("targets", &field, true); if(!field.isNullOrUndefined()) { ok &= sevalue_to_native(field, &(to->targets), ctx); } @@ -14471,9 +13905,8 @@ static bool js_gfx_BlendState_constructor(se::State& s) // NOLINT(readability-id if(argc == 0) { - cc::gfx::BlendState* cobj = JSB_ALLOC(cc::gfx::BlendState); - s.thisObject()->setPrivateData(cobj); - se::NonRefNativePtrCreatedByCtorMap::emplace(cobj); + auto *ptr = JSB_MAKE_PRIVATE_OBJECT(cc::gfx::BlendState); + s.thisObject()->setPrivateObject(ptr); return true; } @@ -14481,21 +13914,19 @@ static bool js_gfx_BlendState_constructor(se::State& s) // NOLINT(readability-id { se::Object *json = args[0].toObject(); se::Value field; - - cc::gfx::BlendState* cobj = JSB_ALLOC(cc::gfx::BlendState); + auto *ptr = JSB_MAKE_PRIVATE_OBJECT(cc::gfx::BlendState); + auto cobj = ptr->get(); ok &= sevalue_to_native(args[0], cobj, s.thisObject()); if(!ok) { - JSB_FREE(cobj); + delete ptr; SE_REPORT_ERROR("argument convertion error"); return false; } - - s.thisObject()->setPrivateData(cobj); - se::NonRefNativePtrCreatedByCtorMap::emplace(cobj); + s.thisObject()->setPrivateObject(ptr); return true; } - - cc::gfx::BlendState* cobj = JSB_ALLOC(cc::gfx::BlendState); + auto *ptr = JSB_MAKE_PRIVATE_OBJECT(cc::gfx::BlendState); + auto cobj = ptr->get(); if (argc > 0 && !args[0].isUndefined()) { ok &= sevalue_to_native(args[0], &(cobj->isA2C), nullptr); } @@ -14510,28 +13941,17 @@ static bool js_gfx_BlendState_constructor(se::State& s) // NOLINT(readability-id } if(!ok) { - JSB_FREE(cobj); + delete ptr; SE_REPORT_ERROR("Argument convertion error"); return false; } - - s.thisObject()->setPrivateData(cobj); - se::NonRefNativePtrCreatedByCtorMap::emplace(cobj); + s.thisObject()->setPrivateObject(ptr); return true; } SE_BIND_CTOR(js_gfx_BlendState_constructor, __jsb_cc_gfx_BlendState_class, js_cc_gfx_BlendState_finalize) - - static bool js_cc_gfx_BlendState_finalize(se::State& s) // NOLINT(readability-identifier-naming) { - auto iter = se::NonRefNativePtrCreatedByCtorMap::find(SE_THIS_OBJECT(s)); - if (iter != se::NonRefNativePtrCreatedByCtorMap::end()) - { - se::NonRefNativePtrCreatedByCtorMap::erase(iter); - auto* cobj = SE_THIS_OBJECT(s); - JSB_FREE(cobj); - } return true; } SE_BIND_FINALIZE_FUNC(js_cc_gfx_BlendState_finalize) @@ -14544,6 +13964,9 @@ bool js_register_gfx_BlendState(se::Object* obj) // NOLINT(readability-identifie cls->defineProperty("isIndepend", _SE(js_gfx_BlendState_get_isIndepend), _SE(js_gfx_BlendState_set_isIndepend)); cls->defineProperty("blendColor", _SE(js_gfx_BlendState_get_blendColor), _SE(js_gfx_BlendState_set_blendColor)); cls->defineProperty("targets", _SE(js_gfx_BlendState_get_targets), _SE(js_gfx_BlendState_set_targets)); + cls->defineFunction("destroy", _SE(js_gfx_BlendState_destroy)); + cls->defineFunction("reset", _SE(js_gfx_BlendState_reset)); + cls->defineFunction("setTarget", _SE(js_gfx_BlendState_setTarget)); cls->defineFinalizeFunction(_SE(js_cc_gfx_BlendState_finalize)); cls->install(); JSBClassType::registerClass(cls); @@ -14551,11 +13974,12 @@ bool js_register_gfx_BlendState(se::Object* obj) // NOLINT(readability-identifie __jsb_cc_gfx_BlendState_proto = cls->getProto(); __jsb_cc_gfx_BlendState_class = cls; + se::ScriptEngine::getInstance()->clearException(); return true; } -se::Object* __jsb_cc_gfx_PipelineStateInfo_proto = nullptr; -se::Class* __jsb_cc_gfx_PipelineStateInfo_class = nullptr; +se::Object* __jsb_cc_gfx_PipelineStateInfo_proto = nullptr; // NOLINT +se::Class* __jsb_cc_gfx_PipelineStateInfo_class = nullptr; // NOLINT static bool js_gfx_PipelineStateInfo_get_shader(se::State& s) // NOLINT(readability-identifier-naming) { @@ -14867,47 +14291,47 @@ bool sevalue_to_native(const se::Value &from, cc::gfx::PipelineStateInfo * to, s } se::Value field; bool ok = true; - json->getProperty("shader", &field); + json->getProperty("shader", &field, true); if(!field.isNullOrUndefined()) { ok &= sevalue_to_native(field, &(to->shader), ctx); } - json->getProperty("pipelineLayout", &field); + json->getProperty("pipelineLayout", &field, true); if(!field.isNullOrUndefined()) { ok &= sevalue_to_native(field, &(to->pipelineLayout), ctx); } - json->getProperty("renderPass", &field); + json->getProperty("renderPass", &field, true); if(!field.isNullOrUndefined()) { ok &= sevalue_to_native(field, &(to->renderPass), ctx); } - json->getProperty("inputState", &field); + json->getProperty("inputState", &field, true); if(!field.isNullOrUndefined()) { ok &= sevalue_to_native(field, &(to->inputState), ctx); } - json->getProperty("rasterizerState", &field); + json->getProperty("rasterizerState", &field, true); if(!field.isNullOrUndefined()) { ok &= sevalue_to_native(field, &(to->rasterizerState), ctx); } - json->getProperty("depthStencilState", &field); + json->getProperty("depthStencilState", &field, true); if(!field.isNullOrUndefined()) { ok &= sevalue_to_native(field, &(to->depthStencilState), ctx); } - json->getProperty("blendState", &field); + json->getProperty("blendState", &field, true); if(!field.isNullOrUndefined()) { ok &= sevalue_to_native(field, &(to->blendState), ctx); } - json->getProperty("primitive", &field); + json->getProperty("primitive", &field, true); if(!field.isNullOrUndefined()) { ok &= sevalue_to_native(field, &(to->primitive), ctx); } - json->getProperty("dynamicStates", &field); + json->getProperty("dynamicStates", &field, true); if(!field.isNullOrUndefined()) { ok &= sevalue_to_native(field, &(to->dynamicStates), ctx); } - json->getProperty("bindPoint", &field); + json->getProperty("bindPoint", &field, true); if(!field.isNullOrUndefined()) { ok &= sevalue_to_native(field, &(to->bindPoint), ctx); } - json->getProperty("subpass", &field); + json->getProperty("subpass", &field, true); if(!field.isNullOrUndefined()) { ok &= sevalue_to_native(field, &(to->subpass), ctx); } @@ -14924,9 +14348,8 @@ static bool js_gfx_PipelineStateInfo_constructor(se::State& s) // NOLINT(readabi if(argc == 0) { - cc::gfx::PipelineStateInfo* cobj = JSB_ALLOC(cc::gfx::PipelineStateInfo); - s.thisObject()->setPrivateData(cobj); - se::NonRefNativePtrCreatedByCtorMap::emplace(cobj); + auto *ptr = JSB_MAKE_PRIVATE_OBJECT(cc::gfx::PipelineStateInfo); + s.thisObject()->setPrivateObject(ptr); return true; } @@ -14934,21 +14357,19 @@ static bool js_gfx_PipelineStateInfo_constructor(se::State& s) // NOLINT(readabi { se::Object *json = args[0].toObject(); se::Value field; - - cc::gfx::PipelineStateInfo* cobj = JSB_ALLOC(cc::gfx::PipelineStateInfo); + auto *ptr = JSB_MAKE_PRIVATE_OBJECT(cc::gfx::PipelineStateInfo); + auto cobj = ptr->get(); ok &= sevalue_to_native(args[0], cobj, s.thisObject()); if(!ok) { - JSB_FREE(cobj); + delete ptr; SE_REPORT_ERROR("argument convertion error"); return false; } - - s.thisObject()->setPrivateData(cobj); - se::NonRefNativePtrCreatedByCtorMap::emplace(cobj); + s.thisObject()->setPrivateObject(ptr); return true; } - - cc::gfx::PipelineStateInfo* cobj = JSB_ALLOC(cc::gfx::PipelineStateInfo); + auto *ptr = JSB_MAKE_PRIVATE_OBJECT(cc::gfx::PipelineStateInfo); + auto cobj = ptr->get(); if (argc > 0 && !args[0].isUndefined()) { ok &= sevalue_to_native(args[0], &(cobj->shader), nullptr); } @@ -14984,28 +14405,17 @@ static bool js_gfx_PipelineStateInfo_constructor(se::State& s) // NOLINT(readabi } if(!ok) { - JSB_FREE(cobj); + delete ptr; SE_REPORT_ERROR("Argument convertion error"); return false; } - - s.thisObject()->setPrivateData(cobj); - se::NonRefNativePtrCreatedByCtorMap::emplace(cobj); + s.thisObject()->setPrivateObject(ptr); return true; } SE_BIND_CTOR(js_gfx_PipelineStateInfo_constructor, __jsb_cc_gfx_PipelineStateInfo_class, js_cc_gfx_PipelineStateInfo_finalize) - - static bool js_cc_gfx_PipelineStateInfo_finalize(se::State& s) // NOLINT(readability-identifier-naming) { - auto iter = se::NonRefNativePtrCreatedByCtorMap::find(SE_THIS_OBJECT(s)); - if (iter != se::NonRefNativePtrCreatedByCtorMap::end()) - { - se::NonRefNativePtrCreatedByCtorMap::erase(iter); - auto* cobj = SE_THIS_OBJECT(s); - JSB_FREE(cobj); - } return true; } SE_BIND_FINALIZE_FUNC(js_cc_gfx_PipelineStateInfo_finalize) @@ -15032,11 +14442,12 @@ bool js_register_gfx_PipelineStateInfo(se::Object* obj) // NOLINT(readability-id __jsb_cc_gfx_PipelineStateInfo_proto = cls->getProto(); __jsb_cc_gfx_PipelineStateInfo_class = cls; + se::ScriptEngine::getInstance()->clearException(); return true; } -se::Object* __jsb_cc_gfx_CommandBufferInfo_proto = nullptr; -se::Class* __jsb_cc_gfx_CommandBufferInfo_class = nullptr; +se::Object* __jsb_cc_gfx_CommandBufferInfo_proto = nullptr; // NOLINT +se::Class* __jsb_cc_gfx_CommandBufferInfo_class = nullptr; // NOLINT static bool js_gfx_CommandBufferInfo_get_queue(se::State& s) // NOLINT(readability-identifier-naming) { @@ -15105,11 +14516,11 @@ bool sevalue_to_native(const se::Value &from, cc::gfx::CommandBufferInfo * to, s } se::Value field; bool ok = true; - json->getProperty("queue", &field); + json->getProperty("queue", &field, true); if(!field.isNullOrUndefined()) { ok &= sevalue_to_native(field, &(to->queue), ctx); } - json->getProperty("type", &field); + json->getProperty("type", &field, true); if(!field.isNullOrUndefined()) { ok &= sevalue_to_native(field, &(to->type), ctx); } @@ -15126,9 +14537,8 @@ static bool js_gfx_CommandBufferInfo_constructor(se::State& s) // NOLINT(readabi if(argc == 0) { - cc::gfx::CommandBufferInfo* cobj = JSB_ALLOC(cc::gfx::CommandBufferInfo); - s.thisObject()->setPrivateData(cobj); - se::NonRefNativePtrCreatedByCtorMap::emplace(cobj); + auto *ptr = JSB_MAKE_PRIVATE_OBJECT(cc::gfx::CommandBufferInfo); + s.thisObject()->setPrivateObject(ptr); return true; } @@ -15136,21 +14546,19 @@ static bool js_gfx_CommandBufferInfo_constructor(se::State& s) // NOLINT(readabi { se::Object *json = args[0].toObject(); se::Value field; - - cc::gfx::CommandBufferInfo* cobj = JSB_ALLOC(cc::gfx::CommandBufferInfo); + auto *ptr = JSB_MAKE_PRIVATE_OBJECT(cc::gfx::CommandBufferInfo); + auto cobj = ptr->get(); ok &= sevalue_to_native(args[0], cobj, s.thisObject()); if(!ok) { - JSB_FREE(cobj); + delete ptr; SE_REPORT_ERROR("argument convertion error"); return false; } - - s.thisObject()->setPrivateData(cobj); - se::NonRefNativePtrCreatedByCtorMap::emplace(cobj); + s.thisObject()->setPrivateObject(ptr); return true; } - - cc::gfx::CommandBufferInfo* cobj = JSB_ALLOC(cc::gfx::CommandBufferInfo); + auto *ptr = JSB_MAKE_PRIVATE_OBJECT(cc::gfx::CommandBufferInfo); + auto cobj = ptr->get(); if (argc > 0 && !args[0].isUndefined()) { ok &= sevalue_to_native(args[0], &(cobj->queue), nullptr); } @@ -15159,28 +14567,17 @@ static bool js_gfx_CommandBufferInfo_constructor(se::State& s) // NOLINT(readabi } if(!ok) { - JSB_FREE(cobj); + delete ptr; SE_REPORT_ERROR("Argument convertion error"); return false; } - - s.thisObject()->setPrivateData(cobj); - se::NonRefNativePtrCreatedByCtorMap::emplace(cobj); + s.thisObject()->setPrivateObject(ptr); return true; } SE_BIND_CTOR(js_gfx_CommandBufferInfo_constructor, __jsb_cc_gfx_CommandBufferInfo_class, js_cc_gfx_CommandBufferInfo_finalize) - - static bool js_cc_gfx_CommandBufferInfo_finalize(se::State& s) // NOLINT(readability-identifier-naming) { - auto iter = se::NonRefNativePtrCreatedByCtorMap::find(SE_THIS_OBJECT(s)); - if (iter != se::NonRefNativePtrCreatedByCtorMap::end()) - { - se::NonRefNativePtrCreatedByCtorMap::erase(iter); - auto* cobj = SE_THIS_OBJECT(s); - JSB_FREE(cobj); - } return true; } SE_BIND_FINALIZE_FUNC(js_cc_gfx_CommandBufferInfo_finalize) @@ -15198,11 +14595,12 @@ bool js_register_gfx_CommandBufferInfo(se::Object* obj) // NOLINT(readability-id __jsb_cc_gfx_CommandBufferInfo_proto = cls->getProto(); __jsb_cc_gfx_CommandBufferInfo_class = cls; + se::ScriptEngine::getInstance()->clearException(); return true; } -se::Object* __jsb_cc_gfx_QueueInfo_proto = nullptr; -se::Class* __jsb_cc_gfx_QueueInfo_class = nullptr; +se::Object* __jsb_cc_gfx_QueueInfo_proto = nullptr; // NOLINT +se::Class* __jsb_cc_gfx_QueueInfo_class = nullptr; // NOLINT static bool js_gfx_QueueInfo_get_type(se::State& s) // NOLINT(readability-identifier-naming) { @@ -15244,7 +14642,7 @@ bool sevalue_to_native(const se::Value &from, cc::gfx::QueueInfo * to, se::Objec } se::Value field; bool ok = true; - json->getProperty("type", &field); + json->getProperty("type", &field, true); if(!field.isNullOrUndefined()) { ok &= sevalue_to_native(field, &(to->type), ctx); } @@ -15261,40 +14659,28 @@ static bool js_gfx_QueueInfo_constructor(se::State& s) // NOLINT(readability-ide if(argc == 0) { - cc::gfx::QueueInfo* cobj = JSB_ALLOC(cc::gfx::QueueInfo); - s.thisObject()->setPrivateData(cobj); - se::NonRefNativePtrCreatedByCtorMap::emplace(cobj); + auto *ptr = JSB_MAKE_PRIVATE_OBJECT(cc::gfx::QueueInfo); + s.thisObject()->setPrivateObject(ptr); return true; } - - cc::gfx::QueueInfo* cobj = JSB_ALLOC(cc::gfx::QueueInfo); + auto *ptr = JSB_MAKE_PRIVATE_OBJECT(cc::gfx::QueueInfo); + auto cobj = ptr->get(); if (argc > 0 && !args[0].isUndefined()) { ok &= sevalue_to_native(args[0], &(cobj->type), nullptr); } if(!ok) { - JSB_FREE(cobj); + delete ptr; SE_REPORT_ERROR("Argument convertion error"); return false; } - - s.thisObject()->setPrivateData(cobj); - se::NonRefNativePtrCreatedByCtorMap::emplace(cobj); + s.thisObject()->setPrivateObject(ptr); return true; } SE_BIND_CTOR(js_gfx_QueueInfo_constructor, __jsb_cc_gfx_QueueInfo_class, js_cc_gfx_QueueInfo_finalize) - - static bool js_cc_gfx_QueueInfo_finalize(se::State& s) // NOLINT(readability-identifier-naming) { - auto iter = se::NonRefNativePtrCreatedByCtorMap::find(SE_THIS_OBJECT(s)); - if (iter != se::NonRefNativePtrCreatedByCtorMap::end()) - { - se::NonRefNativePtrCreatedByCtorMap::erase(iter); - auto* cobj = SE_THIS_OBJECT(s); - JSB_FREE(cobj); - } return true; } SE_BIND_FINALIZE_FUNC(js_cc_gfx_QueueInfo_finalize) @@ -15311,11 +14697,12 @@ bool js_register_gfx_QueueInfo(se::Object* obj) // NOLINT(readability-identifier __jsb_cc_gfx_QueueInfo_proto = cls->getProto(); __jsb_cc_gfx_QueueInfo_class = cls; + se::ScriptEngine::getInstance()->clearException(); return true; } -se::Object* __jsb_cc_gfx_QueryPoolInfo_proto = nullptr; -se::Class* __jsb_cc_gfx_QueryPoolInfo_class = nullptr; +se::Object* __jsb_cc_gfx_QueryPoolInfo_proto = nullptr; // NOLINT +se::Class* __jsb_cc_gfx_QueryPoolInfo_class = nullptr; // NOLINT static bool js_gfx_QueryPoolInfo_get_type(se::State& s) // NOLINT(readability-identifier-naming) { @@ -15411,15 +14798,15 @@ bool sevalue_to_native(const se::Value &from, cc::gfx::QueryPoolInfo * to, se::O } se::Value field; bool ok = true; - json->getProperty("type", &field); + json->getProperty("type", &field, true); if(!field.isNullOrUndefined()) { ok &= sevalue_to_native(field, &(to->type), ctx); } - json->getProperty("maxQueryObjects", &field); + json->getProperty("maxQueryObjects", &field, true); if(!field.isNullOrUndefined()) { ok &= sevalue_to_native(field, &(to->maxQueryObjects), ctx); } - json->getProperty("forceWait", &field); + json->getProperty("forceWait", &field, true); if(!field.isNullOrUndefined()) { ok &= sevalue_to_native(field, &(to->forceWait), ctx); } @@ -15436,9 +14823,8 @@ static bool js_gfx_QueryPoolInfo_constructor(se::State& s) // NOLINT(readability if(argc == 0) { - cc::gfx::QueryPoolInfo* cobj = JSB_ALLOC(cc::gfx::QueryPoolInfo); - s.thisObject()->setPrivateData(cobj); - se::NonRefNativePtrCreatedByCtorMap::emplace(cobj); + auto *ptr = JSB_MAKE_PRIVATE_OBJECT(cc::gfx::QueryPoolInfo); + s.thisObject()->setPrivateObject(ptr); return true; } @@ -15446,21 +14832,19 @@ static bool js_gfx_QueryPoolInfo_constructor(se::State& s) // NOLINT(readability { se::Object *json = args[0].toObject(); se::Value field; - - cc::gfx::QueryPoolInfo* cobj = JSB_ALLOC(cc::gfx::QueryPoolInfo); + auto *ptr = JSB_MAKE_PRIVATE_OBJECT(cc::gfx::QueryPoolInfo); + auto cobj = ptr->get(); ok &= sevalue_to_native(args[0], cobj, s.thisObject()); if(!ok) { - JSB_FREE(cobj); + delete ptr; SE_REPORT_ERROR("argument convertion error"); return false; } - - s.thisObject()->setPrivateData(cobj); - se::NonRefNativePtrCreatedByCtorMap::emplace(cobj); + s.thisObject()->setPrivateObject(ptr); return true; } - - cc::gfx::QueryPoolInfo* cobj = JSB_ALLOC(cc::gfx::QueryPoolInfo); + auto *ptr = JSB_MAKE_PRIVATE_OBJECT(cc::gfx::QueryPoolInfo); + auto cobj = ptr->get(); if (argc > 0 && !args[0].isUndefined()) { ok &= sevalue_to_native(args[0], &(cobj->type), nullptr); } @@ -15472,28 +14856,17 @@ static bool js_gfx_QueryPoolInfo_constructor(se::State& s) // NOLINT(readability } if(!ok) { - JSB_FREE(cobj); + delete ptr; SE_REPORT_ERROR("Argument convertion error"); return false; } - - s.thisObject()->setPrivateData(cobj); - se::NonRefNativePtrCreatedByCtorMap::emplace(cobj); + s.thisObject()->setPrivateObject(ptr); return true; } SE_BIND_CTOR(js_gfx_QueryPoolInfo_constructor, __jsb_cc_gfx_QueryPoolInfo_class, js_cc_gfx_QueryPoolInfo_finalize) - - static bool js_cc_gfx_QueryPoolInfo_finalize(se::State& s) // NOLINT(readability-identifier-naming) { - auto iter = se::NonRefNativePtrCreatedByCtorMap::find(SE_THIS_OBJECT(s)); - if (iter != se::NonRefNativePtrCreatedByCtorMap::end()) - { - se::NonRefNativePtrCreatedByCtorMap::erase(iter); - auto* cobj = SE_THIS_OBJECT(s); - JSB_FREE(cobj); - } return true; } SE_BIND_FINALIZE_FUNC(js_cc_gfx_QueryPoolInfo_finalize) @@ -15512,11 +14885,12 @@ bool js_register_gfx_QueryPoolInfo(se::Object* obj) // NOLINT(readability-identi __jsb_cc_gfx_QueryPoolInfo_proto = cls->getProto(); __jsb_cc_gfx_QueryPoolInfo_class = cls; + se::ScriptEngine::getInstance()->clearException(); return true; } -se::Object* __jsb_cc_gfx_MemoryStatus_proto = nullptr; -se::Class* __jsb_cc_gfx_MemoryStatus_class = nullptr; +se::Object* __jsb_cc_gfx_MemoryStatus_proto = nullptr; // NOLINT +se::Class* __jsb_cc_gfx_MemoryStatus_class = nullptr; // NOLINT static bool js_gfx_MemoryStatus_get_bufferSize(se::State& s) // NOLINT(readability-identifier-naming) { @@ -15585,11 +14959,11 @@ bool sevalue_to_native(const se::Value &from, cc::gfx::MemoryStatus * to, se::Ob } se::Value field; bool ok = true; - json->getProperty("bufferSize", &field); + json->getProperty("bufferSize", &field, true); if(!field.isNullOrUndefined()) { ok &= sevalue_to_native(field, &(to->bufferSize), ctx); } - json->getProperty("textureSize", &field); + json->getProperty("textureSize", &field, true); if(!field.isNullOrUndefined()) { ok &= sevalue_to_native(field, &(to->textureSize), ctx); } @@ -15606,9 +14980,8 @@ static bool js_gfx_MemoryStatus_constructor(se::State& s) // NOLINT(readability- if(argc == 0) { - cc::gfx::MemoryStatus* cobj = JSB_ALLOC(cc::gfx::MemoryStatus); - s.thisObject()->setPrivateData(cobj); - se::NonRefNativePtrCreatedByCtorMap::emplace(cobj); + auto *ptr = JSB_MAKE_PRIVATE_OBJECT(cc::gfx::MemoryStatus); + s.thisObject()->setPrivateObject(ptr); return true; } @@ -15616,21 +14989,19 @@ static bool js_gfx_MemoryStatus_constructor(se::State& s) // NOLINT(readability- { se::Object *json = args[0].toObject(); se::Value field; - - cc::gfx::MemoryStatus* cobj = JSB_ALLOC(cc::gfx::MemoryStatus); + auto *ptr = JSB_MAKE_PRIVATE_OBJECT(cc::gfx::MemoryStatus); + auto cobj = ptr->get(); ok &= sevalue_to_native(args[0], cobj, s.thisObject()); if(!ok) { - JSB_FREE(cobj); + delete ptr; SE_REPORT_ERROR("argument convertion error"); return false; } - - s.thisObject()->setPrivateData(cobj); - se::NonRefNativePtrCreatedByCtorMap::emplace(cobj); + s.thisObject()->setPrivateObject(ptr); return true; } - - cc::gfx::MemoryStatus* cobj = JSB_ALLOC(cc::gfx::MemoryStatus); + auto *ptr = JSB_MAKE_PRIVATE_OBJECT(cc::gfx::MemoryStatus); + auto cobj = ptr->get(); if (argc > 0 && !args[0].isUndefined()) { ok &= sevalue_to_native(args[0], &(cobj->bufferSize), nullptr); } @@ -15639,28 +15010,17 @@ static bool js_gfx_MemoryStatus_constructor(se::State& s) // NOLINT(readability- } if(!ok) { - JSB_FREE(cobj); + delete ptr; SE_REPORT_ERROR("Argument convertion error"); return false; } - - s.thisObject()->setPrivateData(cobj); - se::NonRefNativePtrCreatedByCtorMap::emplace(cobj); + s.thisObject()->setPrivateObject(ptr); return true; } SE_BIND_CTOR(js_gfx_MemoryStatus_constructor, __jsb_cc_gfx_MemoryStatus_class, js_cc_gfx_MemoryStatus_finalize) - - static bool js_cc_gfx_MemoryStatus_finalize(se::State& s) // NOLINT(readability-identifier-naming) { - auto iter = se::NonRefNativePtrCreatedByCtorMap::find(SE_THIS_OBJECT(s)); - if (iter != se::NonRefNativePtrCreatedByCtorMap::end()) - { - se::NonRefNativePtrCreatedByCtorMap::erase(iter); - auto* cobj = SE_THIS_OBJECT(s); - JSB_FREE(cobj); - } return true; } SE_BIND_FINALIZE_FUNC(js_cc_gfx_MemoryStatus_finalize) @@ -15678,11 +15038,12 @@ bool js_register_gfx_MemoryStatus(se::Object* obj) // NOLINT(readability-identif __jsb_cc_gfx_MemoryStatus_proto = cls->getProto(); __jsb_cc_gfx_MemoryStatus_class = cls; + se::ScriptEngine::getInstance()->clearException(); return true; } -se::Object* __jsb_cc_gfx_GFXObject_proto = nullptr; -se::Class* __jsb_cc_gfx_GFXObject_class = nullptr; +se::Object* __jsb_cc_gfx_GFXObject_proto = nullptr; // NOLINT +se::Class* __jsb_cc_gfx_GFXObject_class = nullptr; // NOLINT static bool js_gfx_GFXObject_getObjectID(se::State& s) // NOLINT(readability-identifier-naming) { @@ -15701,7 +15062,7 @@ static bool js_gfx_GFXObject_getObjectID(se::State& s) // NOLINT(readability-ide SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 0); return false; } -SE_BIND_PROP_GET(js_gfx_GFXObject_getObjectID) +SE_BIND_FUNC_AS_PROP_GET(js_gfx_GFXObject_getObjectID) static bool js_gfx_GFXObject_getObjectType(se::State& s) // NOLINT(readability-identifier-naming) { @@ -15720,7 +15081,7 @@ static bool js_gfx_GFXObject_getObjectType(se::State& s) // NOLINT(readability-i SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 0); return false; } -SE_BIND_PROP_GET(js_gfx_GFXObject_getObjectType) +SE_BIND_FUNC_AS_PROP_GET(js_gfx_GFXObject_getObjectType) static bool js_gfx_GFXObject_getTypedID(se::State& s) // NOLINT(readability-identifier-naming) { @@ -15739,7 +15100,7 @@ static bool js_gfx_GFXObject_getTypedID(se::State& s) // NOLINT(readability-iden SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 0); return false; } -SE_BIND_PROP_GET(js_gfx_GFXObject_getTypedID) +SE_BIND_FUNC_AS_PROP_GET(js_gfx_GFXObject_getTypedID) SE_DECLARE_FINALIZE_FUNC(js_cc_gfx_GFXObject_finalize) @@ -15750,24 +15111,14 @@ static bool js_gfx_GFXObject_constructor(se::State& s) // NOLINT(readability-ide cc::gfx::ObjectType arg0; ok &= sevalue_to_native(args[0], &arg0, s.thisObject()); SE_PRECONDITION2(ok, false, "js_gfx_GFXObject_constructor : Error processing arguments"); - cc::gfx::GFXObject* cobj = JSB_ALLOC(cc::gfx::GFXObject, arg0); - s.thisObject()->setPrivateData(cobj); - se::NonRefNativePtrCreatedByCtorMap::emplace(cobj); + auto *ptr = JSB_MAKE_PRIVATE_OBJECT(cc::gfx::GFXObject, arg0); + s.thisObject()->setPrivateObject(ptr); return true; } SE_BIND_CTOR(js_gfx_GFXObject_constructor, __jsb_cc_gfx_GFXObject_class, js_cc_gfx_GFXObject_finalize) - - static bool js_cc_gfx_GFXObject_finalize(se::State& s) // NOLINT(readability-identifier-naming) { - auto iter = se::NonRefNativePtrCreatedByCtorMap::find(SE_THIS_OBJECT(s)); - if (iter != se::NonRefNativePtrCreatedByCtorMap::end()) - { - se::NonRefNativePtrCreatedByCtorMap::erase(iter); - auto* cobj = SE_THIS_OBJECT(s); - JSB_FREE(cobj); - } return true; } SE_BIND_FINALIZE_FUNC(js_cc_gfx_GFXObject_finalize) @@ -15776,9 +15127,9 @@ bool js_register_gfx_GFXObject(se::Object* obj) // NOLINT(readability-identifier { auto* cls = se::Class::create("GFXObject", obj, nullptr, _SE(js_gfx_GFXObject_constructor)); - cls->defineProperty("objectType", _SE(js_gfx_GFXObject_getObjectType), nullptr); - cls->defineProperty("objectID", _SE(js_gfx_GFXObject_getObjectID), nullptr); - cls->defineProperty("typedID", _SE(js_gfx_GFXObject_getTypedID), nullptr); + cls->defineProperty("typedID", _SE(js_gfx_GFXObject_getTypedID_asGetter), nullptr); + cls->defineProperty("objectID", _SE(js_gfx_GFXObject_getObjectID_asGetter), nullptr); + cls->defineProperty("objectType", _SE(js_gfx_GFXObject_getObjectType_asGetter), nullptr); cls->defineFinalizeFunction(_SE(js_cc_gfx_GFXObject_finalize)); cls->install(); JSBClassType::registerClass(cls); @@ -15786,11 +15137,12 @@ bool js_register_gfx_GFXObject(se::Object* obj) // NOLINT(readability-identifier __jsb_cc_gfx_GFXObject_proto = cls->getProto(); __jsb_cc_gfx_GFXObject_class = cls; + se::ScriptEngine::getInstance()->clearException(); return true; } -se::Object* __jsb_cc_gfx_Buffer_proto = nullptr; -se::Class* __jsb_cc_gfx_Buffer_class = nullptr; +se::Object* __jsb_cc_gfx_Buffer_proto = nullptr; // NOLINT +se::Class* __jsb_cc_gfx_Buffer_class = nullptr; // NOLINT static bool js_gfx_Buffer_destroy(se::State& s) // NOLINT(readability-identifier-naming) { @@ -15824,7 +15176,7 @@ static bool js_gfx_Buffer_getCount(se::State& s) // NOLINT(readability-identifie SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 0); return false; } -SE_BIND_PROP_GET(js_gfx_Buffer_getCount) +SE_BIND_FUNC_AS_PROP_GET(js_gfx_Buffer_getCount) static bool js_gfx_Buffer_getFlags(se::State& s) // NOLINT(readability-identifier-naming) { @@ -15843,7 +15195,7 @@ static bool js_gfx_Buffer_getFlags(se::State& s) // NOLINT(readability-identifie SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 0); return false; } -SE_BIND_PROP_GET(js_gfx_Buffer_getFlags) +SE_BIND_FUNC_AS_PROP_GET(js_gfx_Buffer_getFlags) static bool js_gfx_Buffer_getMemUsage(se::State& s) // NOLINT(readability-identifier-naming) { @@ -15862,7 +15214,7 @@ static bool js_gfx_Buffer_getMemUsage(se::State& s) // NOLINT(readability-identi SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 0); return false; } -SE_BIND_PROP_GET(js_gfx_Buffer_getMemUsage) +SE_BIND_FUNC_AS_PROP_GET(js_gfx_Buffer_getMemUsage) static bool js_gfx_Buffer_getSize(se::State& s) // NOLINT(readability-identifier-naming) { @@ -15881,7 +15233,7 @@ static bool js_gfx_Buffer_getSize(se::State& s) // NOLINT(readability-identifier SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 0); return false; } -SE_BIND_PROP_GET(js_gfx_Buffer_getSize) +SE_BIND_FUNC_AS_PROP_GET(js_gfx_Buffer_getSize) static bool js_gfx_Buffer_getStride(se::State& s) // NOLINT(readability-identifier-naming) { @@ -15900,7 +15252,7 @@ static bool js_gfx_Buffer_getStride(se::State& s) // NOLINT(readability-identifi SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 0); return false; } -SE_BIND_PROP_GET(js_gfx_Buffer_getStride) +SE_BIND_FUNC_AS_PROP_GET(js_gfx_Buffer_getStride) static bool js_gfx_Buffer_getUsage(se::State& s) // NOLINT(readability-identifier-naming) { @@ -15919,7 +15271,7 @@ static bool js_gfx_Buffer_getUsage(se::State& s) // NOLINT(readability-identifie SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 0); return false; } -SE_BIND_PROP_GET(js_gfx_Buffer_getUsage) +SE_BIND_FUNC_AS_PROP_GET(js_gfx_Buffer_getUsage) static bool js_gfx_Buffer_isBufferView(se::State& s) // NOLINT(readability-identifier-naming) { @@ -15959,7 +15311,7 @@ static bool js_gfx_Buffer_resize(se::State& s) // NOLINT(readability-identifier- } SE_BIND_FUNC(js_gfx_Buffer_resize) -static bool js_gfx_Buffer_computeHash(se::State& s) // NOLINT(readability-identifier-naming) +static bool js_gfx_Buffer_computeHash_static(se::State& s) // NOLINT(readability-identifier-naming) { const auto& args = s.args(); size_t argc = args.size(); @@ -15967,39 +15319,30 @@ static bool js_gfx_Buffer_computeHash(se::State& s) // NOLINT(readability-identi if (argc == 1) { HolderType arg0 = {}; ok &= sevalue_to_native(args[0], &arg0, nullptr); - SE_PRECONDITION2(ok, false, "js_gfx_Buffer_computeHash : Error processing arguments"); + SE_PRECONDITION2(ok, false, "js_gfx_Buffer_computeHash_static : Error processing arguments"); size_t result = cc::gfx::Buffer::computeHash(arg0.value()); ok &= nativevalue_to_se(result, s.rval(), nullptr /*ctx*/); - SE_PRECONDITION2(ok, false, "js_gfx_Buffer_computeHash : Error processing arguments"); + SE_PRECONDITION2(ok, false, "js_gfx_Buffer_computeHash_static : Error processing arguments"); SE_HOLD_RETURN_VALUE(result, s.thisObject(), s.rval()); return true; } SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 1); return false; } -SE_BIND_FUNC(js_gfx_Buffer_computeHash) +SE_BIND_FUNC(js_gfx_Buffer_computeHash_static) SE_DECLARE_FINALIZE_FUNC(js_cc_gfx_Buffer_finalize) static bool js_gfx_Buffer_constructor(se::State& /*s*/) // NOLINT(readability-identifier-naming) constructor.c { //#3 cc::gfx::Buffer: is_skip_construtor True - se::ScriptEngine::getInstance()->evalString("throw new Error(\"cc::gfx::Buffer constructor is skipped\")"); + se::ScriptEngine::getInstance()->throwException("cc::gfx::Buffer constructor is skipped"); return false; } SE_BIND_CTOR(js_gfx_Buffer_constructor, __jsb_cc_gfx_Buffer_class, js_cc_gfx_Buffer_finalize) - - static bool js_cc_gfx_Buffer_finalize(se::State& s) // NOLINT(readability-identifier-naming) { - auto iter = se::NonRefNativePtrCreatedByCtorMap::find(SE_THIS_OBJECT(s)); - if (iter != se::NonRefNativePtrCreatedByCtorMap::end()) - { - se::NonRefNativePtrCreatedByCtorMap::erase(iter); - auto* cobj = SE_THIS_OBJECT(s); - JSB_FREE(cobj); - } return true; } SE_BIND_FINALIZE_FUNC(js_cc_gfx_Buffer_finalize) @@ -16008,16 +15351,16 @@ bool js_register_gfx_Buffer(se::Object* obj) // NOLINT(readability-identifier-na { auto* cls = se::Class::create("Buffer", obj, __jsb_cc_gfx_GFXObject_proto, _SE(js_gfx_Buffer_constructor)); - cls->defineProperty("usage", _SE(js_gfx_Buffer_getUsage), nullptr); - cls->defineProperty("memUsage", _SE(js_gfx_Buffer_getMemUsage), nullptr); - cls->defineProperty("stride", _SE(js_gfx_Buffer_getStride), nullptr); - cls->defineProperty("count", _SE(js_gfx_Buffer_getCount), nullptr); - cls->defineProperty("size", _SE(js_gfx_Buffer_getSize), nullptr); - cls->defineProperty("flags", _SE(js_gfx_Buffer_getFlags), nullptr); + cls->defineProperty("count", _SE(js_gfx_Buffer_getCount_asGetter), nullptr); + cls->defineProperty("memUsage", _SE(js_gfx_Buffer_getMemUsage_asGetter), nullptr); + cls->defineProperty("stride", _SE(js_gfx_Buffer_getStride_asGetter), nullptr); + cls->defineProperty("flags", _SE(js_gfx_Buffer_getFlags_asGetter), nullptr); + cls->defineProperty("usage", _SE(js_gfx_Buffer_getUsage_asGetter), nullptr); + cls->defineProperty("size", _SE(js_gfx_Buffer_getSize_asGetter), nullptr); cls->defineFunction("destroy", _SE(js_gfx_Buffer_destroy)); cls->defineFunction("isBufferView", _SE(js_gfx_Buffer_isBufferView)); cls->defineFunction("resize", _SE(js_gfx_Buffer_resize)); - cls->defineStaticFunction("computeHash", _SE(js_gfx_Buffer_computeHash)); + cls->defineStaticFunction("computeHash", _SE(js_gfx_Buffer_computeHash_static)); cls->defineFinalizeFunction(_SE(js_cc_gfx_Buffer_finalize)); cls->install(); JSBClassType::registerClass(cls); @@ -16025,11 +15368,12 @@ bool js_register_gfx_Buffer(se::Object* obj) // NOLINT(readability-identifier-na __jsb_cc_gfx_Buffer_proto = cls->getProto(); __jsb_cc_gfx_Buffer_class = cls; + se::ScriptEngine::getInstance()->clearException(); return true; } -se::Object* __jsb_cc_gfx_InputAssembler_proto = nullptr; -se::Class* __jsb_cc_gfx_InputAssembler_class = nullptr; +se::Object* __jsb_cc_gfx_InputAssembler_proto = nullptr; // NOLINT +se::Class* __jsb_cc_gfx_InputAssembler_class = nullptr; // NOLINT static bool js_gfx_InputAssembler_destroy(se::State& s) // NOLINT(readability-identifier-naming) { @@ -16063,7 +15407,7 @@ static bool js_gfx_InputAssembler_getAttributes(se::State& s) // NOLINT(readabil SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 0); return false; } -SE_BIND_PROP_GET(js_gfx_InputAssembler_getAttributes) +SE_BIND_FUNC_AS_PROP_GET(js_gfx_InputAssembler_getAttributes) static bool js_gfx_InputAssembler_getAttributesHash(se::State& s) // NOLINT(readability-identifier-naming) { @@ -16082,7 +15426,7 @@ static bool js_gfx_InputAssembler_getAttributesHash(se::State& s) // NOLINT(read SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 0); return false; } -SE_BIND_PROP_GET(js_gfx_InputAssembler_getAttributesHash) +SE_BIND_FUNC_AS_PROP_GET(js_gfx_InputAssembler_getAttributesHash) static bool js_gfx_InputAssembler_getDrawInfo(se::State& s) // NOLINT(readability-identifier-naming) { @@ -16101,7 +15445,7 @@ static bool js_gfx_InputAssembler_getDrawInfo(se::State& s) // NOLINT(readabilit SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 0); return false; } -SE_BIND_PROP_GET(js_gfx_InputAssembler_getDrawInfo) +SE_BIND_FUNC_AS_PROP_GET(js_gfx_InputAssembler_getDrawInfo) static bool js_gfx_InputAssembler_getFirstIndex(se::State& s) // NOLINT(readability-identifier-naming) { @@ -16120,7 +15464,7 @@ static bool js_gfx_InputAssembler_getFirstIndex(se::State& s) // NOLINT(readabil SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 0); return false; } -SE_BIND_PROP_GET(js_gfx_InputAssembler_getFirstIndex) +SE_BIND_FUNC_AS_PROP_GET(js_gfx_InputAssembler_getFirstIndex) static bool js_gfx_InputAssembler_getFirstInstance(se::State& s) // NOLINT(readability-identifier-naming) { @@ -16139,7 +15483,7 @@ static bool js_gfx_InputAssembler_getFirstInstance(se::State& s) // NOLINT(reada SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 0); return false; } -SE_BIND_PROP_GET(js_gfx_InputAssembler_getFirstInstance) +SE_BIND_FUNC_AS_PROP_GET(js_gfx_InputAssembler_getFirstInstance) static bool js_gfx_InputAssembler_getFirstVertex(se::State& s) // NOLINT(readability-identifier-naming) { @@ -16158,7 +15502,7 @@ static bool js_gfx_InputAssembler_getFirstVertex(se::State& s) // NOLINT(readabi SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 0); return false; } -SE_BIND_PROP_GET(js_gfx_InputAssembler_getFirstVertex) +SE_BIND_FUNC_AS_PROP_GET(js_gfx_InputAssembler_getFirstVertex) static bool js_gfx_InputAssembler_getIndexBuffer(se::State& s) // NOLINT(readability-identifier-naming) { @@ -16177,7 +15521,7 @@ static bool js_gfx_InputAssembler_getIndexBuffer(se::State& s) // NOLINT(readabi SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 0); return false; } -SE_BIND_PROP_GET(js_gfx_InputAssembler_getIndexBuffer) +SE_BIND_FUNC_AS_PROP_GET(js_gfx_InputAssembler_getIndexBuffer) static bool js_gfx_InputAssembler_getIndexCount(se::State& s) // NOLINT(readability-identifier-naming) { @@ -16196,7 +15540,7 @@ static bool js_gfx_InputAssembler_getIndexCount(se::State& s) // NOLINT(readabil SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 0); return false; } -SE_BIND_PROP_GET(js_gfx_InputAssembler_getIndexCount) +SE_BIND_FUNC_AS_PROP_GET(js_gfx_InputAssembler_getIndexCount) static bool js_gfx_InputAssembler_getIndirectBuffer(se::State& s) // NOLINT(readability-identifier-naming) { @@ -16215,7 +15559,7 @@ static bool js_gfx_InputAssembler_getIndirectBuffer(se::State& s) // NOLINT(read SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 0); return false; } -SE_BIND_PROP_GET(js_gfx_InputAssembler_getIndirectBuffer) +SE_BIND_FUNC_AS_PROP_GET(js_gfx_InputAssembler_getIndirectBuffer) static bool js_gfx_InputAssembler_getInstanceCount(se::State& s) // NOLINT(readability-identifier-naming) { @@ -16234,7 +15578,7 @@ static bool js_gfx_InputAssembler_getInstanceCount(se::State& s) // NOLINT(reada SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 0); return false; } -SE_BIND_PROP_GET(js_gfx_InputAssembler_getInstanceCount) +SE_BIND_FUNC_AS_PROP_GET(js_gfx_InputAssembler_getInstanceCount) static bool js_gfx_InputAssembler_getVertexBuffers(se::State& s) // NOLINT(readability-identifier-naming) { @@ -16253,7 +15597,7 @@ static bool js_gfx_InputAssembler_getVertexBuffers(se::State& s) // NOLINT(reada SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 0); return false; } -SE_BIND_PROP_GET(js_gfx_InputAssembler_getVertexBuffers) +SE_BIND_FUNC_AS_PROP_GET(js_gfx_InputAssembler_getVertexBuffers) static bool js_gfx_InputAssembler_getVertexCount(se::State& s) // NOLINT(readability-identifier-naming) { @@ -16272,7 +15616,7 @@ static bool js_gfx_InputAssembler_getVertexCount(se::State& s) // NOLINT(readabi SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 0); return false; } -SE_BIND_PROP_GET(js_gfx_InputAssembler_getVertexCount) +SE_BIND_FUNC_AS_PROP_GET(js_gfx_InputAssembler_getVertexCount) static bool js_gfx_InputAssembler_getVertexOffset(se::State& s) // NOLINT(readability-identifier-naming) { @@ -16291,7 +15635,7 @@ static bool js_gfx_InputAssembler_getVertexOffset(se::State& s) // NOLINT(readab SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 0); return false; } -SE_BIND_PROP_GET(js_gfx_InputAssembler_getVertexOffset) +SE_BIND_FUNC_AS_PROP_GET(js_gfx_InputAssembler_getVertexOffset) static bool js_gfx_InputAssembler_initialize(se::State& s) // NOLINT(readability-identifier-naming) { @@ -16329,7 +15673,7 @@ static bool js_gfx_InputAssembler_setFirstIndex(se::State& s) // NOLINT(readabil SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 1); return false; } -SE_BIND_PROP_SET(js_gfx_InputAssembler_setFirstIndex) +SE_BIND_FUNC_AS_PROP_SET(js_gfx_InputAssembler_setFirstIndex) static bool js_gfx_InputAssembler_setFirstInstance(se::State& s) // NOLINT(readability-identifier-naming) { @@ -16348,7 +15692,7 @@ static bool js_gfx_InputAssembler_setFirstInstance(se::State& s) // NOLINT(reada SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 1); return false; } -SE_BIND_PROP_SET(js_gfx_InputAssembler_setFirstInstance) +SE_BIND_FUNC_AS_PROP_SET(js_gfx_InputAssembler_setFirstInstance) static bool js_gfx_InputAssembler_setFirstVertex(se::State& s) // NOLINT(readability-identifier-naming) { @@ -16367,7 +15711,7 @@ static bool js_gfx_InputAssembler_setFirstVertex(se::State& s) // NOLINT(readabi SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 1); return false; } -SE_BIND_PROP_SET(js_gfx_InputAssembler_setFirstVertex) +SE_BIND_FUNC_AS_PROP_SET(js_gfx_InputAssembler_setFirstVertex) static bool js_gfx_InputAssembler_setIndexCount(se::State& s) // NOLINT(readability-identifier-naming) { @@ -16386,7 +15730,7 @@ static bool js_gfx_InputAssembler_setIndexCount(se::State& s) // NOLINT(readabil SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 1); return false; } -SE_BIND_PROP_SET(js_gfx_InputAssembler_setIndexCount) +SE_BIND_FUNC_AS_PROP_SET(js_gfx_InputAssembler_setIndexCount) static bool js_gfx_InputAssembler_setInstanceCount(se::State& s) // NOLINT(readability-identifier-naming) { @@ -16405,7 +15749,7 @@ static bool js_gfx_InputAssembler_setInstanceCount(se::State& s) // NOLINT(reada SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 1); return false; } -SE_BIND_PROP_SET(js_gfx_InputAssembler_setInstanceCount) +SE_BIND_FUNC_AS_PROP_SET(js_gfx_InputAssembler_setInstanceCount) static bool js_gfx_InputAssembler_setVertexCount(se::State& s) // NOLINT(readability-identifier-naming) { @@ -16424,7 +15768,7 @@ static bool js_gfx_InputAssembler_setVertexCount(se::State& s) // NOLINT(readabi SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 1); return false; } -SE_BIND_PROP_SET(js_gfx_InputAssembler_setVertexCount) +SE_BIND_FUNC_AS_PROP_SET(js_gfx_InputAssembler_setVertexCount) static bool js_gfx_InputAssembler_setVertexOffset(se::State& s) // NOLINT(readability-identifier-naming) { @@ -16443,29 +15787,20 @@ static bool js_gfx_InputAssembler_setVertexOffset(se::State& s) // NOLINT(readab SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 1); return false; } -SE_BIND_PROP_SET(js_gfx_InputAssembler_setVertexOffset) +SE_BIND_FUNC_AS_PROP_SET(js_gfx_InputAssembler_setVertexOffset) SE_DECLARE_FINALIZE_FUNC(js_cc_gfx_InputAssembler_finalize) static bool js_gfx_InputAssembler_constructor(se::State& /*s*/) // NOLINT(readability-identifier-naming) constructor.c { //#3 cc::gfx::InputAssembler: is_skip_construtor True - se::ScriptEngine::getInstance()->evalString("throw new Error(\"cc::gfx::InputAssembler constructor is skipped\")"); + se::ScriptEngine::getInstance()->throwException("cc::gfx::InputAssembler constructor is skipped"); return false; } SE_BIND_CTOR(js_gfx_InputAssembler_constructor, __jsb_cc_gfx_InputAssembler_class, js_cc_gfx_InputAssembler_finalize) - - static bool js_cc_gfx_InputAssembler_finalize(se::State& s) // NOLINT(readability-identifier-naming) { - auto iter = se::NonRefNativePtrCreatedByCtorMap::find(SE_THIS_OBJECT(s)); - if (iter != se::NonRefNativePtrCreatedByCtorMap::end()) - { - se::NonRefNativePtrCreatedByCtorMap::erase(iter); - auto* cobj = SE_THIS_OBJECT(s); - JSB_FREE(cobj); - } return true; } SE_BIND_FINALIZE_FUNC(js_cc_gfx_InputAssembler_finalize) @@ -16474,19 +15809,19 @@ bool js_register_gfx_InputAssembler(se::Object* obj) // NOLINT(readability-ident { auto* cls = se::Class::create("InputAssembler", obj, __jsb_cc_gfx_GFXObject_proto, _SE(js_gfx_InputAssembler_constructor)); - cls->defineProperty("vertexBuffers", _SE(js_gfx_InputAssembler_getVertexBuffers), nullptr); - cls->defineProperty("attributes", _SE(js_gfx_InputAssembler_getAttributes), nullptr); - cls->defineProperty("indexBuffer", _SE(js_gfx_InputAssembler_getIndexBuffer), nullptr); - cls->defineProperty("indirectBuffer", _SE(js_gfx_InputAssembler_getIndirectBuffer), nullptr); - cls->defineProperty("attributesHash", _SE(js_gfx_InputAssembler_getAttributesHash), nullptr); - cls->defineProperty("drawInfo", _SE(js_gfx_InputAssembler_getDrawInfo), nullptr); - cls->defineProperty("vertexCount", _SE(js_gfx_InputAssembler_getVertexCount), _SE(js_gfx_InputAssembler_setVertexCount)); - cls->defineProperty("firstVertex", _SE(js_gfx_InputAssembler_getFirstVertex), _SE(js_gfx_InputAssembler_setFirstVertex)); - cls->defineProperty("indexCount", _SE(js_gfx_InputAssembler_getIndexCount), _SE(js_gfx_InputAssembler_setIndexCount)); - cls->defineProperty("firstIndex", _SE(js_gfx_InputAssembler_getFirstIndex), _SE(js_gfx_InputAssembler_setFirstIndex)); - cls->defineProperty("vertexOffset", _SE(js_gfx_InputAssembler_getVertexOffset), _SE(js_gfx_InputAssembler_setVertexOffset)); - cls->defineProperty("instanceCount", _SE(js_gfx_InputAssembler_getInstanceCount), _SE(js_gfx_InputAssembler_setInstanceCount)); - cls->defineProperty("firstInstance", _SE(js_gfx_InputAssembler_getFirstInstance), _SE(js_gfx_InputAssembler_setFirstInstance)); + cls->defineProperty("instanceCount", _SE(js_gfx_InputAssembler_getInstanceCount_asGetter), _SE(js_gfx_InputAssembler_setInstanceCount_asSetter)); + cls->defineProperty("vertexBuffers", _SE(js_gfx_InputAssembler_getVertexBuffers_asGetter), nullptr); + cls->defineProperty("attributesHash", _SE(js_gfx_InputAssembler_getAttributesHash_asGetter), nullptr); + cls->defineProperty("firstInstance", _SE(js_gfx_InputAssembler_getFirstInstance_asGetter), _SE(js_gfx_InputAssembler_setFirstInstance_asSetter)); + cls->defineProperty("vertexCount", _SE(js_gfx_InputAssembler_getVertexCount_asGetter), _SE(js_gfx_InputAssembler_setVertexCount_asSetter)); + cls->defineProperty("drawInfo", _SE(js_gfx_InputAssembler_getDrawInfo_asGetter), nullptr); + cls->defineProperty("indexBuffer", _SE(js_gfx_InputAssembler_getIndexBuffer_asGetter), nullptr); + cls->defineProperty("vertexOffset", _SE(js_gfx_InputAssembler_getVertexOffset_asGetter), _SE(js_gfx_InputAssembler_setVertexOffset_asSetter)); + cls->defineProperty("attributes", _SE(js_gfx_InputAssembler_getAttributes_asGetter), nullptr); + cls->defineProperty("indexCount", _SE(js_gfx_InputAssembler_getIndexCount_asGetter), _SE(js_gfx_InputAssembler_setIndexCount_asSetter)); + cls->defineProperty("firstIndex", _SE(js_gfx_InputAssembler_getFirstIndex_asGetter), _SE(js_gfx_InputAssembler_setFirstIndex_asSetter)); + cls->defineProperty("indirectBuffer", _SE(js_gfx_InputAssembler_getIndirectBuffer_asGetter), nullptr); + cls->defineProperty("firstVertex", _SE(js_gfx_InputAssembler_getFirstVertex_asGetter), _SE(js_gfx_InputAssembler_setFirstVertex_asSetter)); cls->defineFunction("destroy", _SE(js_gfx_InputAssembler_destroy)); cls->defineFunction("initialize", _SE(js_gfx_InputAssembler_initialize)); cls->defineFinalizeFunction(_SE(js_cc_gfx_InputAssembler_finalize)); @@ -16496,11 +15831,12 @@ bool js_register_gfx_InputAssembler(se::Object* obj) // NOLINT(readability-ident __jsb_cc_gfx_InputAssembler_proto = cls->getProto(); __jsb_cc_gfx_InputAssembler_class = cls; + se::ScriptEngine::getInstance()->clearException(); return true; } -se::Object* __jsb_cc_gfx_CommandBuffer_proto = nullptr; -se::Class* __jsb_cc_gfx_CommandBuffer_class = nullptr; +se::Object* __jsb_cc_gfx_CommandBuffer_proto = nullptr; // NOLINT +se::Class* __jsb_cc_gfx_CommandBuffer_class = nullptr; // NOLINT static bool js_gfx_CommandBuffer_begin(se::State& s) // NOLINT(readability-identifier-naming) { @@ -17381,22 +16717,13 @@ SE_DECLARE_FINALIZE_FUNC(js_cc_gfx_CommandBuffer_finalize) static bool js_gfx_CommandBuffer_constructor(se::State& /*s*/) // NOLINT(readability-identifier-naming) constructor.c { //#3 cc::gfx::CommandBuffer: is_skip_construtor True - se::ScriptEngine::getInstance()->evalString("throw new Error(\"cc::gfx::CommandBuffer constructor is skipped\")"); + se::ScriptEngine::getInstance()->throwException("cc::gfx::CommandBuffer constructor is skipped"); return false; } SE_BIND_CTOR(js_gfx_CommandBuffer_constructor, __jsb_cc_gfx_CommandBuffer_class, js_cc_gfx_CommandBuffer_finalize) - - static bool js_cc_gfx_CommandBuffer_finalize(se::State& s) // NOLINT(readability-identifier-naming) { - auto iter = se::NonRefNativePtrCreatedByCtorMap::find(SE_THIS_OBJECT(s)); - if (iter != se::NonRefNativePtrCreatedByCtorMap::end()) - { - se::NonRefNativePtrCreatedByCtorMap::erase(iter); - auto* cobj = SE_THIS_OBJECT(s); - JSB_FREE(cobj); - } return true; } SE_BIND_FINALIZE_FUNC(js_cc_gfx_CommandBuffer_finalize) @@ -17443,11 +16770,12 @@ bool js_register_gfx_CommandBuffer(se::Object* obj) // NOLINT(readability-identi __jsb_cc_gfx_CommandBuffer_proto = cls->getProto(); __jsb_cc_gfx_CommandBuffer_class = cls; + se::ScriptEngine::getInstance()->clearException(); return true; } -se::Object* __jsb_cc_gfx_DescriptorSet_proto = nullptr; -se::Class* __jsb_cc_gfx_DescriptorSet_class = nullptr; +se::Object* __jsb_cc_gfx_DescriptorSet_proto = nullptr; // NOLINT +se::Class* __jsb_cc_gfx_DescriptorSet_class = nullptr; // NOLINT static bool js_gfx_DescriptorSet_bindBuffer(se::State& s) // NOLINT(readability-identifier-naming) { @@ -17731,7 +17059,7 @@ static bool js_gfx_DescriptorSet_getLayout(se::State& s) // NOLINT(readability-i SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 0); return false; } -SE_BIND_PROP_GET(js_gfx_DescriptorSet_getLayout) +SE_BIND_FUNC_AS_PROP_GET(js_gfx_DescriptorSet_getLayout) static bool js_gfx_DescriptorSet_getSampler(se::State& s) // NOLINT(readability-identifier-naming) { @@ -17858,22 +17186,13 @@ SE_DECLARE_FINALIZE_FUNC(js_cc_gfx_DescriptorSet_finalize) static bool js_gfx_DescriptorSet_constructor(se::State& /*s*/) // NOLINT(readability-identifier-naming) constructor.c { //#3 cc::gfx::DescriptorSet: is_skip_construtor True - se::ScriptEngine::getInstance()->evalString("throw new Error(\"cc::gfx::DescriptorSet constructor is skipped\")"); + se::ScriptEngine::getInstance()->throwException("cc::gfx::DescriptorSet constructor is skipped"); return false; } SE_BIND_CTOR(js_gfx_DescriptorSet_constructor, __jsb_cc_gfx_DescriptorSet_class, js_cc_gfx_DescriptorSet_finalize) - - static bool js_cc_gfx_DescriptorSet_finalize(se::State& s) // NOLINT(readability-identifier-naming) { - auto iter = se::NonRefNativePtrCreatedByCtorMap::find(SE_THIS_OBJECT(s)); - if (iter != se::NonRefNativePtrCreatedByCtorMap::end()) - { - se::NonRefNativePtrCreatedByCtorMap::erase(iter); - auto* cobj = SE_THIS_OBJECT(s); - JSB_FREE(cobj); - } return true; } SE_BIND_FINALIZE_FUNC(js_cc_gfx_DescriptorSet_finalize) @@ -17882,7 +17201,7 @@ bool js_register_gfx_DescriptorSet(se::Object* obj) // NOLINT(readability-identi { auto* cls = se::Class::create("DescriptorSet", obj, __jsb_cc_gfx_GFXObject_proto, _SE(js_gfx_DescriptorSet_constructor)); - cls->defineProperty("layout", _SE(js_gfx_DescriptorSet_getLayout), nullptr); + cls->defineProperty("layout", _SE(js_gfx_DescriptorSet_getLayout_asGetter), nullptr); cls->defineFunction("bindBuffer", _SE(js_gfx_DescriptorSet_bindBuffer)); cls->defineFunction("bindBufferJSB", _SE(js_gfx_DescriptorSet_bindBufferJSB)); cls->defineFunction("bindSampler", _SE(js_gfx_DescriptorSet_bindSampler)); @@ -17902,11 +17221,12 @@ bool js_register_gfx_DescriptorSet(se::Object* obj) // NOLINT(readability-identi __jsb_cc_gfx_DescriptorSet_proto = cls->getProto(); __jsb_cc_gfx_DescriptorSet_class = cls; + se::ScriptEngine::getInstance()->clearException(); return true; } -se::Object* __jsb_cc_gfx_DescriptorSetLayout_proto = nullptr; -se::Class* __jsb_cc_gfx_DescriptorSetLayout_class = nullptr; +se::Object* __jsb_cc_gfx_DescriptorSetLayout_proto = nullptr; // NOLINT +se::Class* __jsb_cc_gfx_DescriptorSetLayout_class = nullptr; // NOLINT static bool js_gfx_DescriptorSetLayout_destroy(se::State& s) // NOLINT(readability-identifier-naming) { @@ -18004,22 +17324,13 @@ SE_DECLARE_FINALIZE_FUNC(js_cc_gfx_DescriptorSetLayout_finalize) static bool js_gfx_DescriptorSetLayout_constructor(se::State& /*s*/) // NOLINT(readability-identifier-naming) constructor.c { //#3 cc::gfx::DescriptorSetLayout: is_skip_construtor True - se::ScriptEngine::getInstance()->evalString("throw new Error(\"cc::gfx::DescriptorSetLayout constructor is skipped\")"); + se::ScriptEngine::getInstance()->throwException("cc::gfx::DescriptorSetLayout constructor is skipped"); return false; } SE_BIND_CTOR(js_gfx_DescriptorSetLayout_constructor, __jsb_cc_gfx_DescriptorSetLayout_class, js_cc_gfx_DescriptorSetLayout_finalize) - - static bool js_cc_gfx_DescriptorSetLayout_finalize(se::State& s) // NOLINT(readability-identifier-naming) { - auto iter = se::NonRefNativePtrCreatedByCtorMap::find(SE_THIS_OBJECT(s)); - if (iter != se::NonRefNativePtrCreatedByCtorMap::end()) - { - se::NonRefNativePtrCreatedByCtorMap::erase(iter); - auto* cobj = SE_THIS_OBJECT(s); - JSB_FREE(cobj); - } return true; } SE_BIND_FINALIZE_FUNC(js_cc_gfx_DescriptorSetLayout_finalize) @@ -18040,11 +17351,12 @@ bool js_register_gfx_DescriptorSetLayout(se::Object* obj) // NOLINT(readability- __jsb_cc_gfx_DescriptorSetLayout_proto = cls->getProto(); __jsb_cc_gfx_DescriptorSetLayout_class = cls; + se::ScriptEngine::getInstance()->clearException(); return true; } -se::Object* __jsb_cc_gfx_Framebuffer_proto = nullptr; -se::Class* __jsb_cc_gfx_Framebuffer_class = nullptr; +se::Object* __jsb_cc_gfx_Framebuffer_proto = nullptr; // NOLINT +se::Class* __jsb_cc_gfx_Framebuffer_class = nullptr; // NOLINT static bool js_gfx_Framebuffer_destroy(se::State& s) // NOLINT(readability-identifier-naming) { @@ -18078,7 +17390,7 @@ static bool js_gfx_Framebuffer_getColorTextures(se::State& s) // NOLINT(readabil SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 0); return false; } -SE_BIND_PROP_GET(js_gfx_Framebuffer_getColorTextures) +SE_BIND_FUNC_AS_PROP_GET(js_gfx_Framebuffer_getColorTextures) static bool js_gfx_Framebuffer_getDepthStencilTexture(se::State& s) // NOLINT(readability-identifier-naming) { @@ -18097,7 +17409,7 @@ static bool js_gfx_Framebuffer_getDepthStencilTexture(se::State& s) // NOLINT(re SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 0); return false; } -SE_BIND_PROP_GET(js_gfx_Framebuffer_getDepthStencilTexture) +SE_BIND_FUNC_AS_PROP_GET(js_gfx_Framebuffer_getDepthStencilTexture) static bool js_gfx_Framebuffer_getRenderPass(se::State& s) // NOLINT(readability-identifier-naming) { @@ -18116,7 +17428,7 @@ static bool js_gfx_Framebuffer_getRenderPass(se::State& s) // NOLINT(readability SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 0); return false; } -SE_BIND_PROP_GET(js_gfx_Framebuffer_getRenderPass) +SE_BIND_FUNC_AS_PROP_GET(js_gfx_Framebuffer_getRenderPass) static bool js_gfx_Framebuffer_initialize(se::State& s) // NOLINT(readability-identifier-naming) { @@ -18137,7 +17449,7 @@ static bool js_gfx_Framebuffer_initialize(se::State& s) // NOLINT(readability-id } SE_BIND_FUNC(js_gfx_Framebuffer_initialize) -static bool js_gfx_Framebuffer_computeHash(se::State& s) // NOLINT(readability-identifier-naming) +static bool js_gfx_Framebuffer_computeHash_static(se::State& s) // NOLINT(readability-identifier-naming) { const auto& args = s.args(); size_t argc = args.size(); @@ -18145,39 +17457,30 @@ static bool js_gfx_Framebuffer_computeHash(se::State& s) // NOLINT(readability-i if (argc == 1) { HolderType arg0 = {}; ok &= sevalue_to_native(args[0], &arg0, nullptr); - SE_PRECONDITION2(ok, false, "js_gfx_Framebuffer_computeHash : Error processing arguments"); + SE_PRECONDITION2(ok, false, "js_gfx_Framebuffer_computeHash_static : Error processing arguments"); size_t result = cc::gfx::Framebuffer::computeHash(arg0.value()); ok &= nativevalue_to_se(result, s.rval(), nullptr /*ctx*/); - SE_PRECONDITION2(ok, false, "js_gfx_Framebuffer_computeHash : Error processing arguments"); + SE_PRECONDITION2(ok, false, "js_gfx_Framebuffer_computeHash_static : Error processing arguments"); SE_HOLD_RETURN_VALUE(result, s.thisObject(), s.rval()); return true; } SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 1); return false; } -SE_BIND_FUNC(js_gfx_Framebuffer_computeHash) +SE_BIND_FUNC(js_gfx_Framebuffer_computeHash_static) SE_DECLARE_FINALIZE_FUNC(js_cc_gfx_Framebuffer_finalize) static bool js_gfx_Framebuffer_constructor(se::State& /*s*/) // NOLINT(readability-identifier-naming) constructor.c { //#3 cc::gfx::Framebuffer: is_skip_construtor True - se::ScriptEngine::getInstance()->evalString("throw new Error(\"cc::gfx::Framebuffer constructor is skipped\")"); + se::ScriptEngine::getInstance()->throwException("cc::gfx::Framebuffer constructor is skipped"); return false; } SE_BIND_CTOR(js_gfx_Framebuffer_constructor, __jsb_cc_gfx_Framebuffer_class, js_cc_gfx_Framebuffer_finalize) - - static bool js_cc_gfx_Framebuffer_finalize(se::State& s) // NOLINT(readability-identifier-naming) { - auto iter = se::NonRefNativePtrCreatedByCtorMap::find(SE_THIS_OBJECT(s)); - if (iter != se::NonRefNativePtrCreatedByCtorMap::end()) - { - se::NonRefNativePtrCreatedByCtorMap::erase(iter); - auto* cobj = SE_THIS_OBJECT(s); - JSB_FREE(cobj); - } return true; } SE_BIND_FINALIZE_FUNC(js_cc_gfx_Framebuffer_finalize) @@ -18186,12 +17489,12 @@ bool js_register_gfx_Framebuffer(se::Object* obj) // NOLINT(readability-identifi { auto* cls = se::Class::create("Framebuffer", obj, __jsb_cc_gfx_GFXObject_proto, _SE(js_gfx_Framebuffer_constructor)); - cls->defineProperty("renderPass", _SE(js_gfx_Framebuffer_getRenderPass), nullptr); - cls->defineProperty("colorTextures", _SE(js_gfx_Framebuffer_getColorTextures), nullptr); - cls->defineProperty("depthStencilTexture", _SE(js_gfx_Framebuffer_getDepthStencilTexture), nullptr); + cls->defineProperty("colorTextures", _SE(js_gfx_Framebuffer_getColorTextures_asGetter), nullptr); + cls->defineProperty("renderPass", _SE(js_gfx_Framebuffer_getRenderPass_asGetter), nullptr); + cls->defineProperty("depthStencilTexture", _SE(js_gfx_Framebuffer_getDepthStencilTexture_asGetter), nullptr); cls->defineFunction("destroy", _SE(js_gfx_Framebuffer_destroy)); cls->defineFunction("initialize", _SE(js_gfx_Framebuffer_initialize)); - cls->defineStaticFunction("computeHash", _SE(js_gfx_Framebuffer_computeHash)); + cls->defineStaticFunction("computeHash", _SE(js_gfx_Framebuffer_computeHash_static)); cls->defineFinalizeFunction(_SE(js_cc_gfx_Framebuffer_finalize)); cls->install(); JSBClassType::registerClass(cls); @@ -18199,11 +17502,12 @@ bool js_register_gfx_Framebuffer(se::Object* obj) // NOLINT(readability-identifi __jsb_cc_gfx_Framebuffer_proto = cls->getProto(); __jsb_cc_gfx_Framebuffer_class = cls; + se::ScriptEngine::getInstance()->clearException(); return true; } -se::Object* __jsb_cc_gfx_PipelineLayout_proto = nullptr; -se::Class* __jsb_cc_gfx_PipelineLayout_class = nullptr; +se::Object* __jsb_cc_gfx_PipelineLayout_proto = nullptr; // NOLINT +se::Class* __jsb_cc_gfx_PipelineLayout_class = nullptr; // NOLINT static bool js_gfx_PipelineLayout_destroy(se::State& s) // NOLINT(readability-identifier-naming) { @@ -18263,22 +17567,13 @@ SE_DECLARE_FINALIZE_FUNC(js_cc_gfx_PipelineLayout_finalize) static bool js_gfx_PipelineLayout_constructor(se::State& /*s*/) // NOLINT(readability-identifier-naming) constructor.c { //#3 cc::gfx::PipelineLayout: is_skip_construtor True - se::ScriptEngine::getInstance()->evalString("throw new Error(\"cc::gfx::PipelineLayout constructor is skipped\")"); + se::ScriptEngine::getInstance()->throwException("cc::gfx::PipelineLayout constructor is skipped"); return false; } SE_BIND_CTOR(js_gfx_PipelineLayout_constructor, __jsb_cc_gfx_PipelineLayout_class, js_cc_gfx_PipelineLayout_finalize) - - static bool js_cc_gfx_PipelineLayout_finalize(se::State& s) // NOLINT(readability-identifier-naming) { - auto iter = se::NonRefNativePtrCreatedByCtorMap::find(SE_THIS_OBJECT(s)); - if (iter != se::NonRefNativePtrCreatedByCtorMap::end()) - { - se::NonRefNativePtrCreatedByCtorMap::erase(iter); - auto* cobj = SE_THIS_OBJECT(s); - JSB_FREE(cobj); - } return true; } SE_BIND_FINALIZE_FUNC(js_cc_gfx_PipelineLayout_finalize) @@ -18297,11 +17592,12 @@ bool js_register_gfx_PipelineLayout(se::Object* obj) // NOLINT(readability-ident __jsb_cc_gfx_PipelineLayout_proto = cls->getProto(); __jsb_cc_gfx_PipelineLayout_class = cls; + se::ScriptEngine::getInstance()->clearException(); return true; } -se::Object* __jsb_cc_gfx_PipelineState_proto = nullptr; -se::Class* __jsb_cc_gfx_PipelineState_class = nullptr; +se::Object* __jsb_cc_gfx_PipelineState_proto = nullptr; // NOLINT +se::Class* __jsb_cc_gfx_PipelineState_class = nullptr; // NOLINT static bool js_gfx_PipelineState_destroy(se::State& s) // NOLINT(readability-identifier-naming) { @@ -18335,7 +17631,7 @@ static bool js_gfx_PipelineState_getBindPoint(se::State& s) // NOLINT(readabilit SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 0); return false; } -SE_BIND_PROP_GET(js_gfx_PipelineState_getBindPoint) +SE_BIND_FUNC_AS_PROP_GET(js_gfx_PipelineState_getBindPoint) static bool js_gfx_PipelineState_getBlendState(se::State& s) // NOLINT(readability-identifier-naming) { @@ -18354,7 +17650,7 @@ static bool js_gfx_PipelineState_getBlendState(se::State& s) // NOLINT(readabili SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 0); return false; } -SE_BIND_PROP_GET(js_gfx_PipelineState_getBlendState) +SE_BIND_FUNC_AS_PROP_GET(js_gfx_PipelineState_getBlendState) static bool js_gfx_PipelineState_getDepthStencilState(se::State& s) // NOLINT(readability-identifier-naming) { @@ -18373,7 +17669,7 @@ static bool js_gfx_PipelineState_getDepthStencilState(se::State& s) // NOLINT(re SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 0); return false; } -SE_BIND_PROP_GET(js_gfx_PipelineState_getDepthStencilState) +SE_BIND_FUNC_AS_PROP_GET(js_gfx_PipelineState_getDepthStencilState) static bool js_gfx_PipelineState_getDynamicStates(se::State& s) // NOLINT(readability-identifier-naming) { @@ -18411,7 +17707,7 @@ static bool js_gfx_PipelineState_getInputState(se::State& s) // NOLINT(readabili SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 0); return false; } -SE_BIND_PROP_GET(js_gfx_PipelineState_getInputState) +SE_BIND_FUNC_AS_PROP_GET(js_gfx_PipelineState_getInputState) static bool js_gfx_PipelineState_getPipelineLayout(se::State& s) // NOLINT(readability-identifier-naming) { @@ -18449,7 +17745,7 @@ static bool js_gfx_PipelineState_getPrimitive(se::State& s) // NOLINT(readabilit SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 0); return false; } -SE_BIND_PROP_GET(js_gfx_PipelineState_getPrimitive) +SE_BIND_FUNC_AS_PROP_GET(js_gfx_PipelineState_getPrimitive) static bool js_gfx_PipelineState_getRasterizerState(se::State& s) // NOLINT(readability-identifier-naming) { @@ -18468,7 +17764,7 @@ static bool js_gfx_PipelineState_getRasterizerState(se::State& s) // NOLINT(read SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 0); return false; } -SE_BIND_PROP_GET(js_gfx_PipelineState_getRasterizerState) +SE_BIND_FUNC_AS_PROP_GET(js_gfx_PipelineState_getRasterizerState) static bool js_gfx_PipelineState_getRenderPass(se::State& s) // NOLINT(readability-identifier-naming) { @@ -18487,7 +17783,7 @@ static bool js_gfx_PipelineState_getRenderPass(se::State& s) // NOLINT(readabili SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 0); return false; } -SE_BIND_PROP_GET(js_gfx_PipelineState_getRenderPass) +SE_BIND_FUNC_AS_PROP_GET(js_gfx_PipelineState_getRenderPass) static bool js_gfx_PipelineState_getShader(se::State& s) // NOLINT(readability-identifier-naming) { @@ -18506,7 +17802,7 @@ static bool js_gfx_PipelineState_getShader(se::State& s) // NOLINT(readability-i SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 0); return false; } -SE_BIND_PROP_GET(js_gfx_PipelineState_getShader) +SE_BIND_FUNC_AS_PROP_GET(js_gfx_PipelineState_getShader) static bool js_gfx_PipelineState_initialize(se::State& s) // NOLINT(readability-identifier-naming) { @@ -18532,22 +17828,13 @@ SE_DECLARE_FINALIZE_FUNC(js_cc_gfx_PipelineState_finalize) static bool js_gfx_PipelineState_constructor(se::State& /*s*/) // NOLINT(readability-identifier-naming) constructor.c { //#3 cc::gfx::PipelineState: is_skip_construtor True - se::ScriptEngine::getInstance()->evalString("throw new Error(\"cc::gfx::PipelineState constructor is skipped\")"); + se::ScriptEngine::getInstance()->throwException("cc::gfx::PipelineState constructor is skipped"); return false; } SE_BIND_CTOR(js_gfx_PipelineState_constructor, __jsb_cc_gfx_PipelineState_class, js_cc_gfx_PipelineState_finalize) - - static bool js_cc_gfx_PipelineState_finalize(se::State& s) // NOLINT(readability-identifier-naming) { - auto iter = se::NonRefNativePtrCreatedByCtorMap::find(SE_THIS_OBJECT(s)); - if (iter != se::NonRefNativePtrCreatedByCtorMap::end()) - { - se::NonRefNativePtrCreatedByCtorMap::erase(iter); - auto* cobj = SE_THIS_OBJECT(s); - JSB_FREE(cobj); - } return true; } SE_BIND_FINALIZE_FUNC(js_cc_gfx_PipelineState_finalize) @@ -18556,14 +17843,14 @@ bool js_register_gfx_PipelineState(se::Object* obj) // NOLINT(readability-identi { auto* cls = se::Class::create("PipelineState", obj, __jsb_cc_gfx_GFXObject_proto, _SE(js_gfx_PipelineState_constructor)); - cls->defineProperty("shader", _SE(js_gfx_PipelineState_getShader), nullptr); - cls->defineProperty("primitive", _SE(js_gfx_PipelineState_getPrimitive), nullptr); - cls->defineProperty("bindPoint", _SE(js_gfx_PipelineState_getBindPoint), nullptr); - cls->defineProperty("inputState", _SE(js_gfx_PipelineState_getInputState), nullptr); - cls->defineProperty("rasterizerState", _SE(js_gfx_PipelineState_getRasterizerState), nullptr); - cls->defineProperty("depthStencilState", _SE(js_gfx_PipelineState_getDepthStencilState), nullptr); - cls->defineProperty("blendState", _SE(js_gfx_PipelineState_getBlendState), nullptr); - cls->defineProperty("renderPass", _SE(js_gfx_PipelineState_getRenderPass), nullptr); + cls->defineProperty("primitive", _SE(js_gfx_PipelineState_getPrimitive_asGetter), nullptr); + cls->defineProperty("rasterizerState", _SE(js_gfx_PipelineState_getRasterizerState_asGetter), nullptr); + cls->defineProperty("shader", _SE(js_gfx_PipelineState_getShader_asGetter), nullptr); + cls->defineProperty("blendState", _SE(js_gfx_PipelineState_getBlendState_asGetter), nullptr); + cls->defineProperty("renderPass", _SE(js_gfx_PipelineState_getRenderPass_asGetter), nullptr); + cls->defineProperty("inputState", _SE(js_gfx_PipelineState_getInputState_asGetter), nullptr); + cls->defineProperty("bindPoint", _SE(js_gfx_PipelineState_getBindPoint_asGetter), nullptr); + cls->defineProperty("depthStencilState", _SE(js_gfx_PipelineState_getDepthStencilState_asGetter), nullptr); cls->defineFunction("destroy", _SE(js_gfx_PipelineState_destroy)); cls->defineFunction("getDynamicStates", _SE(js_gfx_PipelineState_getDynamicStates)); cls->defineFunction("getPipelineLayout", _SE(js_gfx_PipelineState_getPipelineLayout)); @@ -18575,11 +17862,12 @@ bool js_register_gfx_PipelineState(se::Object* obj) // NOLINT(readability-identi __jsb_cc_gfx_PipelineState_proto = cls->getProto(); __jsb_cc_gfx_PipelineState_class = cls; + se::ScriptEngine::getInstance()->clearException(); return true; } -se::Object* __jsb_cc_gfx_QueryPool_proto = nullptr; -se::Class* __jsb_cc_gfx_QueryPool_class = nullptr; +se::Object* __jsb_cc_gfx_QueryPool_proto = nullptr; // NOLINT +se::Class* __jsb_cc_gfx_QueryPool_class = nullptr; // NOLINT static bool js_gfx_QueryPool_destroy(se::State& s) // NOLINT(readability-identifier-naming) { @@ -18721,22 +18009,13 @@ SE_DECLARE_FINALIZE_FUNC(js_cc_gfx_QueryPool_finalize) static bool js_gfx_QueryPool_constructor(se::State& /*s*/) // NOLINT(readability-identifier-naming) constructor.c { //#3 cc::gfx::QueryPool: is_skip_construtor True - se::ScriptEngine::getInstance()->evalString("throw new Error(\"cc::gfx::QueryPool constructor is skipped\")"); + se::ScriptEngine::getInstance()->throwException("cc::gfx::QueryPool constructor is skipped"); return false; } SE_BIND_CTOR(js_gfx_QueryPool_constructor, __jsb_cc_gfx_QueryPool_class, js_cc_gfx_QueryPool_finalize) - - static bool js_cc_gfx_QueryPool_finalize(se::State& s) // NOLINT(readability-identifier-naming) { - auto iter = se::NonRefNativePtrCreatedByCtorMap::find(SE_THIS_OBJECT(s)); - if (iter != se::NonRefNativePtrCreatedByCtorMap::end()) - { - se::NonRefNativePtrCreatedByCtorMap::erase(iter); - auto* cobj = SE_THIS_OBJECT(s); - JSB_FREE(cobj); - } return true; } SE_BIND_FINALIZE_FUNC(js_cc_gfx_QueryPool_finalize) @@ -18759,11 +18038,12 @@ bool js_register_gfx_QueryPool(se::Object* obj) // NOLINT(readability-identifier __jsb_cc_gfx_QueryPool_proto = cls->getProto(); __jsb_cc_gfx_QueryPool_class = cls; + se::ScriptEngine::getInstance()->clearException(); return true; } -se::Object* __jsb_cc_gfx_Queue_proto = nullptr; -se::Class* __jsb_cc_gfx_Queue_class = nullptr; +se::Object* __jsb_cc_gfx_Queue_proto = nullptr; // NOLINT +se::Class* __jsb_cc_gfx_Queue_class = nullptr; // NOLINT static bool js_gfx_Queue_destroy(se::State& s) // NOLINT(readability-identifier-naming) { @@ -18797,7 +18077,7 @@ static bool js_gfx_Queue_getType(se::State& s) // NOLINT(readability-identifier- SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 0); return false; } -SE_BIND_PROP_GET(js_gfx_Queue_getType) +SE_BIND_FUNC_AS_PROP_GET(js_gfx_Queue_getType) static bool js_gfx_Queue_initialize(se::State& s) // NOLINT(readability-identifier-naming) { @@ -18860,22 +18140,13 @@ SE_DECLARE_FINALIZE_FUNC(js_cc_gfx_Queue_finalize) static bool js_gfx_Queue_constructor(se::State& /*s*/) // NOLINT(readability-identifier-naming) constructor.c { //#3 cc::gfx::Queue: is_skip_construtor True - se::ScriptEngine::getInstance()->evalString("throw new Error(\"cc::gfx::Queue constructor is skipped\")"); + se::ScriptEngine::getInstance()->throwException("cc::gfx::Queue constructor is skipped"); return false; } SE_BIND_CTOR(js_gfx_Queue_constructor, __jsb_cc_gfx_Queue_class, js_cc_gfx_Queue_finalize) - - static bool js_cc_gfx_Queue_finalize(se::State& s) // NOLINT(readability-identifier-naming) { - auto iter = se::NonRefNativePtrCreatedByCtorMap::find(SE_THIS_OBJECT(s)); - if (iter != se::NonRefNativePtrCreatedByCtorMap::end()) - { - se::NonRefNativePtrCreatedByCtorMap::erase(iter); - auto* cobj = SE_THIS_OBJECT(s); - JSB_FREE(cobj); - } return true; } SE_BIND_FINALIZE_FUNC(js_cc_gfx_Queue_finalize) @@ -18884,7 +18155,7 @@ bool js_register_gfx_Queue(se::Object* obj) // NOLINT(readability-identifier-nam { auto* cls = se::Class::create("Queue", obj, __jsb_cc_gfx_GFXObject_proto, _SE(js_gfx_Queue_constructor)); - cls->defineProperty("type", _SE(js_gfx_Queue_getType), nullptr); + cls->defineProperty("type", _SE(js_gfx_Queue_getType_asGetter), nullptr); cls->defineFunction("destroy", _SE(js_gfx_Queue_destroy)); cls->defineFunction("initialize", _SE(js_gfx_Queue_initialize)); cls->defineFunction("submit", _SE(js_gfx_Queue_submit)); @@ -18895,11 +18166,12 @@ bool js_register_gfx_Queue(se::Object* obj) // NOLINT(readability-identifier-nam __jsb_cc_gfx_Queue_proto = cls->getProto(); __jsb_cc_gfx_Queue_class = cls; + se::ScriptEngine::getInstance()->clearException(); return true; } -se::Object* __jsb_cc_gfx_RenderPass_proto = nullptr; -se::Class* __jsb_cc_gfx_RenderPass_class = nullptr; +se::Object* __jsb_cc_gfx_RenderPass_proto = nullptr; // NOLINT +se::Class* __jsb_cc_gfx_RenderPass_class = nullptr; // NOLINT static bool js_gfx_RenderPass_destroy(se::State& s) // NOLINT(readability-identifier-naming) { @@ -18971,7 +18243,7 @@ static bool js_gfx_RenderPass_getHash(se::State& s) // NOLINT(readability-identi SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 0); return false; } -SE_BIND_PROP_GET(js_gfx_RenderPass_getHash) +SE_BIND_FUNC_AS_PROP_GET(js_gfx_RenderPass_getHash) static bool js_gfx_RenderPass_getSubpasses(se::State& s) // NOLINT(readability-identifier-naming) { @@ -19011,7 +18283,7 @@ static bool js_gfx_RenderPass_initialize(se::State& s) // NOLINT(readability-ide } SE_BIND_FUNC(js_gfx_RenderPass_initialize) -static bool js_gfx_RenderPass_computeHash(se::State& s) // NOLINT(readability-identifier-naming) +static bool js_gfx_RenderPass_computeHash_static(se::State& s) // NOLINT(readability-identifier-naming) { const auto& args = s.args(); size_t argc = args.size(); @@ -19019,39 +18291,30 @@ static bool js_gfx_RenderPass_computeHash(se::State& s) // NOLINT(readability-id if (argc == 1) { HolderType arg0 = {}; ok &= sevalue_to_native(args[0], &arg0, nullptr); - SE_PRECONDITION2(ok, false, "js_gfx_RenderPass_computeHash : Error processing arguments"); + SE_PRECONDITION2(ok, false, "js_gfx_RenderPass_computeHash_static : Error processing arguments"); size_t result = cc::gfx::RenderPass::computeHash(arg0.value()); ok &= nativevalue_to_se(result, s.rval(), nullptr /*ctx*/); - SE_PRECONDITION2(ok, false, "js_gfx_RenderPass_computeHash : Error processing arguments"); + SE_PRECONDITION2(ok, false, "js_gfx_RenderPass_computeHash_static : Error processing arguments"); SE_HOLD_RETURN_VALUE(result, s.thisObject(), s.rval()); return true; } SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 1); return false; } -SE_BIND_FUNC(js_gfx_RenderPass_computeHash) +SE_BIND_FUNC(js_gfx_RenderPass_computeHash_static) SE_DECLARE_FINALIZE_FUNC(js_cc_gfx_RenderPass_finalize) static bool js_gfx_RenderPass_constructor(se::State& /*s*/) // NOLINT(readability-identifier-naming) constructor.c { //#3 cc::gfx::RenderPass: is_skip_construtor True - se::ScriptEngine::getInstance()->evalString("throw new Error(\"cc::gfx::RenderPass constructor is skipped\")"); + se::ScriptEngine::getInstance()->throwException("cc::gfx::RenderPass constructor is skipped"); return false; } SE_BIND_CTOR(js_gfx_RenderPass_constructor, __jsb_cc_gfx_RenderPass_class, js_cc_gfx_RenderPass_finalize) - - static bool js_cc_gfx_RenderPass_finalize(se::State& s) // NOLINT(readability-identifier-naming) { - auto iter = se::NonRefNativePtrCreatedByCtorMap::find(SE_THIS_OBJECT(s)); - if (iter != se::NonRefNativePtrCreatedByCtorMap::end()) - { - se::NonRefNativePtrCreatedByCtorMap::erase(iter); - auto* cobj = SE_THIS_OBJECT(s); - JSB_FREE(cobj); - } return true; } SE_BIND_FINALIZE_FUNC(js_cc_gfx_RenderPass_finalize) @@ -19060,13 +18323,13 @@ bool js_register_gfx_RenderPass(se::Object* obj) // NOLINT(readability-identifie { auto* cls = se::Class::create("RenderPass", obj, __jsb_cc_gfx_GFXObject_proto, _SE(js_gfx_RenderPass_constructor)); - cls->defineProperty("hash", _SE(js_gfx_RenderPass_getHash), nullptr); + cls->defineProperty("hash", _SE(js_gfx_RenderPass_getHash_asGetter), nullptr); cls->defineFunction("destroy", _SE(js_gfx_RenderPass_destroy)); cls->defineFunction("getDependencies", _SE(js_gfx_RenderPass_getDependencies)); cls->defineFunction("getDepthStencilAttachment", _SE(js_gfx_RenderPass_getDepthStencilAttachment)); cls->defineFunction("getSubpasses", _SE(js_gfx_RenderPass_getSubpasses)); cls->defineFunction("initialize", _SE(js_gfx_RenderPass_initialize)); - cls->defineStaticFunction("computeHash", _SE(js_gfx_RenderPass_computeHash)); + cls->defineStaticFunction("computeHash", _SE(js_gfx_RenderPass_computeHash_static)); cls->defineFinalizeFunction(_SE(js_cc_gfx_RenderPass_finalize)); cls->install(); JSBClassType::registerClass(cls); @@ -19074,11 +18337,12 @@ bool js_register_gfx_RenderPass(se::Object* obj) // NOLINT(readability-identifie __jsb_cc_gfx_RenderPass_proto = cls->getProto(); __jsb_cc_gfx_RenderPass_class = cls; + se::ScriptEngine::getInstance()->clearException(); return true; } -se::Object* __jsb_cc_gfx_Shader_proto = nullptr; -se::Class* __jsb_cc_gfx_Shader_class = nullptr; +se::Object* __jsb_cc_gfx_Shader_proto = nullptr; // NOLINT +se::Class* __jsb_cc_gfx_Shader_class = nullptr; // NOLINT static bool js_gfx_Shader_destroy(se::State& s) // NOLINT(readability-identifier-naming) { @@ -19112,7 +18376,7 @@ static bool js_gfx_Shader_getAttributes(se::State& s) // NOLINT(readability-iden SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 0); return false; } -SE_BIND_PROP_GET(js_gfx_Shader_getAttributes) +SE_BIND_FUNC_AS_PROP_GET(js_gfx_Shader_getAttributes) static bool js_gfx_Shader_getBlocks(se::State& s) // NOLINT(readability-identifier-naming) { @@ -19131,7 +18395,7 @@ static bool js_gfx_Shader_getBlocks(se::State& s) // NOLINT(readability-identifi SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 0); return false; } -SE_BIND_PROP_GET(js_gfx_Shader_getBlocks) +SE_BIND_FUNC_AS_PROP_GET(js_gfx_Shader_getBlocks) static bool js_gfx_Shader_getBuffers(se::State& s) // NOLINT(readability-identifier-naming) { @@ -19188,7 +18452,7 @@ static bool js_gfx_Shader_getName(se::State& s) // NOLINT(readability-identifier SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 0); return false; } -SE_BIND_PROP_GET(js_gfx_Shader_getName) +SE_BIND_FUNC_AS_PROP_GET(js_gfx_Shader_getName) static bool js_gfx_Shader_getSamplerTextures(se::State& s) // NOLINT(readability-identifier-naming) { @@ -19226,7 +18490,7 @@ static bool js_gfx_Shader_getSamplers(se::State& s) // NOLINT(readability-identi SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 0); return false; } -SE_BIND_PROP_GET(js_gfx_Shader_getSamplers) +SE_BIND_FUNC_AS_PROP_GET(js_gfx_Shader_getSamplers) static bool js_gfx_Shader_getStages(se::State& s) // NOLINT(readability-identifier-naming) { @@ -19245,7 +18509,7 @@ static bool js_gfx_Shader_getStages(se::State& s) // NOLINT(readability-identifi SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 0); return false; } -SE_BIND_PROP_GET(js_gfx_Shader_getStages) +SE_BIND_FUNC_AS_PROP_GET(js_gfx_Shader_getStages) static bool js_gfx_Shader_getSubpassInputs(se::State& s) // NOLINT(readability-identifier-naming) { @@ -19309,22 +18573,13 @@ SE_DECLARE_FINALIZE_FUNC(js_cc_gfx_Shader_finalize) static bool js_gfx_Shader_constructor(se::State& /*s*/) // NOLINT(readability-identifier-naming) constructor.c { //#3 cc::gfx::Shader: is_skip_construtor True - se::ScriptEngine::getInstance()->evalString("throw new Error(\"cc::gfx::Shader constructor is skipped\")"); + se::ScriptEngine::getInstance()->throwException("cc::gfx::Shader constructor is skipped"); return false; } SE_BIND_CTOR(js_gfx_Shader_constructor, __jsb_cc_gfx_Shader_class, js_cc_gfx_Shader_finalize) - - static bool js_cc_gfx_Shader_finalize(se::State& s) // NOLINT(readability-identifier-naming) { - auto iter = se::NonRefNativePtrCreatedByCtorMap::find(SE_THIS_OBJECT(s)); - if (iter != se::NonRefNativePtrCreatedByCtorMap::end()) - { - se::NonRefNativePtrCreatedByCtorMap::erase(iter); - auto* cobj = SE_THIS_OBJECT(s); - JSB_FREE(cobj); - } return true; } SE_BIND_FINALIZE_FUNC(js_cc_gfx_Shader_finalize) @@ -19333,11 +18588,11 @@ bool js_register_gfx_Shader(se::Object* obj) // NOLINT(readability-identifier-na { auto* cls = se::Class::create("Shader", obj, __jsb_cc_gfx_GFXObject_proto, _SE(js_gfx_Shader_constructor)); - cls->defineProperty("name", _SE(js_gfx_Shader_getName), nullptr); - cls->defineProperty("stages", _SE(js_gfx_Shader_getStages), nullptr); - cls->defineProperty("attributes", _SE(js_gfx_Shader_getAttributes), nullptr); - cls->defineProperty("blocks", _SE(js_gfx_Shader_getBlocks), nullptr); - cls->defineProperty("samplers", _SE(js_gfx_Shader_getSamplers), nullptr); + cls->defineProperty("attributes", _SE(js_gfx_Shader_getAttributes_asGetter), nullptr); + cls->defineProperty("stages", _SE(js_gfx_Shader_getStages_asGetter), nullptr); + cls->defineProperty("blocks", _SE(js_gfx_Shader_getBlocks_asGetter), nullptr); + cls->defineProperty("name", _SE(js_gfx_Shader_getName_asGetter), nullptr); + cls->defineProperty("samplers", _SE(js_gfx_Shader_getSamplers_asGetter), nullptr); cls->defineFunction("destroy", _SE(js_gfx_Shader_destroy)); cls->defineFunction("getBuffers", _SE(js_gfx_Shader_getBuffers)); cls->defineFunction("getImages", _SE(js_gfx_Shader_getImages)); @@ -19352,11 +18607,12 @@ bool js_register_gfx_Shader(se::Object* obj) // NOLINT(readability-identifier-na __jsb_cc_gfx_Shader_proto = cls->getProto(); __jsb_cc_gfx_Shader_class = cls; + se::ScriptEngine::getInstance()->clearException(); return true; } -se::Object* __jsb_cc_gfx_Texture_proto = nullptr; -se::Class* __jsb_cc_gfx_Texture_class = nullptr; +se::Object* __jsb_cc_gfx_Texture_proto = nullptr; // NOLINT +se::Class* __jsb_cc_gfx_Texture_class = nullptr; // NOLINT static bool js_gfx_Texture_destroy(se::State& s) // NOLINT(readability-identifier-naming) { @@ -19390,7 +18646,7 @@ static bool js_gfx_Texture_getFormat(se::State& s) // NOLINT(readability-identif SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 0); return false; } -SE_BIND_PROP_GET(js_gfx_Texture_getFormat) +SE_BIND_FUNC_AS_PROP_GET(js_gfx_Texture_getFormat) static bool js_gfx_Texture_getHash(se::State& s) // NOLINT(readability-identifier-naming) { @@ -19409,7 +18665,7 @@ static bool js_gfx_Texture_getHash(se::State& s) // NOLINT(readability-identifie SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 0); return false; } -SE_BIND_PROP_GET(js_gfx_Texture_getHash) +SE_BIND_FUNC_AS_PROP_GET(js_gfx_Texture_getHash) static bool js_gfx_Texture_getHeight(se::State& s) // NOLINT(readability-identifier-naming) { @@ -19428,7 +18684,7 @@ static bool js_gfx_Texture_getHeight(se::State& s) // NOLINT(readability-identif SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 0); return false; } -SE_BIND_PROP_GET(js_gfx_Texture_getHeight) +SE_BIND_FUNC_AS_PROP_GET(js_gfx_Texture_getHeight) static bool js_gfx_Texture_getInfo(se::State& s) // NOLINT(readability-identifier-naming) { @@ -19447,7 +18703,7 @@ static bool js_gfx_Texture_getInfo(se::State& s) // NOLINT(readability-identifie SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 0); return false; } -SE_BIND_PROP_GET(js_gfx_Texture_getInfo) +SE_BIND_FUNC_AS_PROP_GET(js_gfx_Texture_getInfo) static bool js_gfx_Texture_getSize(se::State& s) // NOLINT(readability-identifier-naming) { @@ -19466,7 +18722,7 @@ static bool js_gfx_Texture_getSize(se::State& s) // NOLINT(readability-identifie SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 0); return false; } -SE_BIND_PROP_GET(js_gfx_Texture_getSize) +SE_BIND_FUNC_AS_PROP_GET(js_gfx_Texture_getSize) static bool js_gfx_Texture_getViewInfo(se::State& s) // NOLINT(readability-identifier-naming) { @@ -19485,7 +18741,7 @@ static bool js_gfx_Texture_getViewInfo(se::State& s) // NOLINT(readability-ident SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 0); return false; } -SE_BIND_PROP_GET(js_gfx_Texture_getViewInfo) +SE_BIND_FUNC_AS_PROP_GET(js_gfx_Texture_getViewInfo) static bool js_gfx_Texture_getWidth(se::State& s) // NOLINT(readability-identifier-naming) { @@ -19504,7 +18760,7 @@ static bool js_gfx_Texture_getWidth(se::State& s) // NOLINT(readability-identifi SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 0); return false; } -SE_BIND_PROP_GET(js_gfx_Texture_getWidth) +SE_BIND_FUNC_AS_PROP_GET(js_gfx_Texture_getWidth) static bool js_gfx_Texture_isTextureView(se::State& s) // NOLINT(readability-identifier-naming) { @@ -19546,7 +18802,7 @@ static bool js_gfx_Texture_resize(se::State& s) // NOLINT(readability-identifier } SE_BIND_FUNC(js_gfx_Texture_resize) -static bool js_gfx_Texture_computeHash(se::State& s) // NOLINT(readability-identifier-naming) +static bool js_gfx_Texture_computeHash_static(se::State& s) // NOLINT(readability-identifier-naming) { CC_UNUSED bool ok = true; const auto& args = s.args(); @@ -19558,7 +18814,7 @@ static bool js_gfx_Texture_computeHash(se::State& s) // NOLINT(readability-ident if (!ok) { ok = true; break; } size_t result = cc::gfx::Texture::computeHash(arg0.value()); ok &= nativevalue_to_se(result, s.rval(), s.thisObject() /*ctx*/); - SE_PRECONDITION2(ok, false, "js_gfx_Texture_computeHash : Error processing arguments"); + SE_PRECONDITION2(ok, false, "js_gfx_Texture_computeHash_static : Error processing arguments"); SE_HOLD_RETURN_VALUE(result, s.thisObject(), s.rval()); return true; } @@ -19570,7 +18826,7 @@ static bool js_gfx_Texture_computeHash(se::State& s) // NOLINT(readability-ident if (!ok) { ok = true; break; } size_t result = cc::gfx::Texture::computeHash(arg0.value()); ok &= nativevalue_to_se(result, s.rval(), s.thisObject() /*ctx*/); - SE_PRECONDITION2(ok, false, "js_gfx_Texture_computeHash : Error processing arguments"); + SE_PRECONDITION2(ok, false, "js_gfx_Texture_computeHash_static : Error processing arguments"); SE_HOLD_RETURN_VALUE(result, s.thisObject(), s.rval()); return true; } @@ -19578,29 +18834,20 @@ static bool js_gfx_Texture_computeHash(se::State& s) // NOLINT(readability-ident SE_REPORT_ERROR("wrong number of arguments: %d", (int)argc); return false; } -SE_BIND_FUNC(js_gfx_Texture_computeHash) +SE_BIND_FUNC(js_gfx_Texture_computeHash_static) SE_DECLARE_FINALIZE_FUNC(js_cc_gfx_Texture_finalize) static bool js_gfx_Texture_constructor(se::State& /*s*/) // NOLINT(readability-identifier-naming) constructor.c { //#3 cc::gfx::Texture: is_skip_construtor True - se::ScriptEngine::getInstance()->evalString("throw new Error(\"cc::gfx::Texture constructor is skipped\")"); + se::ScriptEngine::getInstance()->throwException("cc::gfx::Texture constructor is skipped"); return false; } SE_BIND_CTOR(js_gfx_Texture_constructor, __jsb_cc_gfx_Texture_class, js_cc_gfx_Texture_finalize) - - static bool js_cc_gfx_Texture_finalize(se::State& s) // NOLINT(readability-identifier-naming) { - auto iter = se::NonRefNativePtrCreatedByCtorMap::find(SE_THIS_OBJECT(s)); - if (iter != se::NonRefNativePtrCreatedByCtorMap::end()) - { - se::NonRefNativePtrCreatedByCtorMap::erase(iter); - auto* cobj = SE_THIS_OBJECT(s); - JSB_FREE(cobj); - } return true; } SE_BIND_FINALIZE_FUNC(js_cc_gfx_Texture_finalize) @@ -19609,17 +18856,17 @@ bool js_register_gfx_Texture(se::Object* obj) // NOLINT(readability-identifier-n { auto* cls = se::Class::create("Texture", obj, __jsb_cc_gfx_GFXObject_proto, _SE(js_gfx_Texture_constructor)); - cls->defineProperty("info", _SE(js_gfx_Texture_getInfo), nullptr); - cls->defineProperty("viewInfo", _SE(js_gfx_Texture_getViewInfo), nullptr); - cls->defineProperty("width", _SE(js_gfx_Texture_getWidth), nullptr); - cls->defineProperty("height", _SE(js_gfx_Texture_getHeight), nullptr); - cls->defineProperty("format", _SE(js_gfx_Texture_getFormat), nullptr); - cls->defineProperty("size", _SE(js_gfx_Texture_getSize), nullptr); - cls->defineProperty("hash", _SE(js_gfx_Texture_getHash), nullptr); + cls->defineProperty("info", _SE(js_gfx_Texture_getInfo_asGetter), nullptr); + cls->defineProperty("hash", _SE(js_gfx_Texture_getHash_asGetter), nullptr); + cls->defineProperty("format", _SE(js_gfx_Texture_getFormat_asGetter), nullptr); + cls->defineProperty("height", _SE(js_gfx_Texture_getHeight_asGetter), nullptr); + cls->defineProperty("width", _SE(js_gfx_Texture_getWidth_asGetter), nullptr); + cls->defineProperty("viewInfo", _SE(js_gfx_Texture_getViewInfo_asGetter), nullptr); + cls->defineProperty("size", _SE(js_gfx_Texture_getSize_asGetter), nullptr); cls->defineFunction("destroy", _SE(js_gfx_Texture_destroy)); cls->defineFunction("isTextureView", _SE(js_gfx_Texture_isTextureView)); cls->defineFunction("resize", _SE(js_gfx_Texture_resize)); - cls->defineStaticFunction("computeHash", _SE(js_gfx_Texture_computeHash)); + cls->defineStaticFunction("computeHash", _SE(js_gfx_Texture_computeHash_static)); cls->defineFinalizeFunction(_SE(js_cc_gfx_Texture_finalize)); cls->install(); JSBClassType::registerClass(cls); @@ -19627,11 +18874,12 @@ bool js_register_gfx_Texture(se::Object* obj) // NOLINT(readability-identifier-n __jsb_cc_gfx_Texture_proto = cls->getProto(); __jsb_cc_gfx_Texture_class = cls; + se::ScriptEngine::getInstance()->clearException(); return true; } -se::Object* __jsb_cc_gfx_Swapchain_proto = nullptr; -se::Class* __jsb_cc_gfx_Swapchain_class = nullptr; +se::Object* __jsb_cc_gfx_Swapchain_proto = nullptr; // NOLINT +se::Class* __jsb_cc_gfx_Swapchain_class = nullptr; // NOLINT static bool js_gfx_Swapchain_createSurface(se::State& s) // NOLINT(readability-identifier-naming) { @@ -19699,7 +18947,7 @@ static bool js_gfx_Swapchain_getColorTexture(se::State& s) // NOLINT(readability SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 0); return false; } -SE_BIND_PROP_GET(js_gfx_Swapchain_getColorTexture) +SE_BIND_FUNC_AS_PROP_GET(js_gfx_Swapchain_getColorTexture) static bool js_gfx_Swapchain_getDepthStencilTexture(se::State& s) // NOLINT(readability-identifier-naming) { @@ -19718,7 +18966,7 @@ static bool js_gfx_Swapchain_getDepthStencilTexture(se::State& s) // NOLINT(read SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 0); return false; } -SE_BIND_PROP_GET(js_gfx_Swapchain_getDepthStencilTexture) +SE_BIND_FUNC_AS_PROP_GET(js_gfx_Swapchain_getDepthStencilTexture) static bool js_gfx_Swapchain_getHeight(se::State& s) // NOLINT(readability-identifier-naming) { @@ -19737,7 +18985,7 @@ static bool js_gfx_Swapchain_getHeight(se::State& s) // NOLINT(readability-ident SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 0); return false; } -SE_BIND_PROP_GET(js_gfx_Swapchain_getHeight) +SE_BIND_FUNC_AS_PROP_GET(js_gfx_Swapchain_getHeight) static bool js_gfx_Swapchain_getSurfaceTransform(se::State& s) // NOLINT(readability-identifier-naming) { @@ -19756,7 +19004,7 @@ static bool js_gfx_Swapchain_getSurfaceTransform(se::State& s) // NOLINT(readabi SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 0); return false; } -SE_BIND_PROP_GET(js_gfx_Swapchain_getSurfaceTransform) +SE_BIND_FUNC_AS_PROP_GET(js_gfx_Swapchain_getSurfaceTransform) static bool js_gfx_Swapchain_getVSyncMode(se::State& s) // NOLINT(readability-identifier-naming) { @@ -19794,7 +19042,7 @@ static bool js_gfx_Swapchain_getWidth(se::State& s) // NOLINT(readability-identi SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 0); return false; } -SE_BIND_PROP_GET(js_gfx_Swapchain_getWidth) +SE_BIND_FUNC_AS_PROP_GET(js_gfx_Swapchain_getWidth) static bool js_gfx_Swapchain_getWindowHandle(se::State& s) // NOLINT(readability-identifier-naming) { @@ -19862,22 +19110,13 @@ SE_DECLARE_FINALIZE_FUNC(js_cc_gfx_Swapchain_finalize) static bool js_gfx_Swapchain_constructor(se::State& /*s*/) // NOLINT(readability-identifier-naming) constructor.c { //#3 cc::gfx::Swapchain: is_skip_construtor True - se::ScriptEngine::getInstance()->evalString("throw new Error(\"cc::gfx::Swapchain constructor is skipped\")"); + se::ScriptEngine::getInstance()->throwException("cc::gfx::Swapchain constructor is skipped"); return false; } SE_BIND_CTOR(js_gfx_Swapchain_constructor, __jsb_cc_gfx_Swapchain_class, js_cc_gfx_Swapchain_finalize) - - static bool js_cc_gfx_Swapchain_finalize(se::State& s) // NOLINT(readability-identifier-naming) { - auto iter = se::NonRefNativePtrCreatedByCtorMap::find(SE_THIS_OBJECT(s)); - if (iter != se::NonRefNativePtrCreatedByCtorMap::end()) - { - se::NonRefNativePtrCreatedByCtorMap::erase(iter); - auto* cobj = SE_THIS_OBJECT(s); - JSB_FREE(cobj); - } return true; } SE_BIND_FINALIZE_FUNC(js_cc_gfx_Swapchain_finalize) @@ -19886,11 +19125,11 @@ bool js_register_gfx_Swapchain(se::Object* obj) // NOLINT(readability-identifier { auto* cls = se::Class::create("Swapchain", obj, __jsb_cc_gfx_GFXObject_proto, _SE(js_gfx_Swapchain_constructor)); - cls->defineProperty("width", _SE(js_gfx_Swapchain_getWidth), nullptr); - cls->defineProperty("height", _SE(js_gfx_Swapchain_getHeight), nullptr); - cls->defineProperty("surfaceTransform", _SE(js_gfx_Swapchain_getSurfaceTransform), nullptr); - cls->defineProperty("colorTexture", _SE(js_gfx_Swapchain_getColorTexture), nullptr); - cls->defineProperty("depthStencilTexture", _SE(js_gfx_Swapchain_getDepthStencilTexture), nullptr); + cls->defineProperty("width", _SE(js_gfx_Swapchain_getWidth_asGetter), nullptr); + cls->defineProperty("surfaceTransform", _SE(js_gfx_Swapchain_getSurfaceTransform_asGetter), nullptr); + cls->defineProperty("depthStencilTexture", _SE(js_gfx_Swapchain_getDepthStencilTexture_asGetter), nullptr); + cls->defineProperty("colorTexture", _SE(js_gfx_Swapchain_getColorTexture_asGetter), nullptr); + cls->defineProperty("height", _SE(js_gfx_Swapchain_getHeight_asGetter), nullptr); cls->defineFunction("createSurface", _SE(js_gfx_Swapchain_createSurface)); cls->defineFunction("destroy", _SE(js_gfx_Swapchain_destroy)); cls->defineFunction("destroySurface", _SE(js_gfx_Swapchain_destroySurface)); @@ -19905,11 +19144,12 @@ bool js_register_gfx_Swapchain(se::Object* obj) // NOLINT(readability-identifier __jsb_cc_gfx_Swapchain_proto = cls->getProto(); __jsb_cc_gfx_Swapchain_class = cls; + se::ScriptEngine::getInstance()->clearException(); return true; } -se::Object* __jsb_cc_gfx_GlobalBarrier_proto = nullptr; -se::Class* __jsb_cc_gfx_GlobalBarrier_class = nullptr; +se::Object* __jsb_cc_gfx_GlobalBarrier_proto = nullptr; // NOLINT +se::Class* __jsb_cc_gfx_GlobalBarrier_class = nullptr; // NOLINT static bool js_gfx_GlobalBarrier_getHash(se::State& s) // NOLINT(readability-identifier-naming) { @@ -19949,7 +19189,7 @@ static bool js_gfx_GlobalBarrier_getInfo(se::State& s) // NOLINT(readability-ide } SE_BIND_FUNC(js_gfx_GlobalBarrier_getInfo) -static bool js_gfx_GlobalBarrier_computeHash(se::State& s) // NOLINT(readability-identifier-naming) +static bool js_gfx_GlobalBarrier_computeHash_static(se::State& s) // NOLINT(readability-identifier-naming) { const auto& args = s.args(); size_t argc = args.size(); @@ -19957,39 +19197,30 @@ static bool js_gfx_GlobalBarrier_computeHash(se::State& s) // NOLINT(readability if (argc == 1) { HolderType arg0 = {}; ok &= sevalue_to_native(args[0], &arg0, nullptr); - SE_PRECONDITION2(ok, false, "js_gfx_GlobalBarrier_computeHash : Error processing arguments"); + SE_PRECONDITION2(ok, false, "js_gfx_GlobalBarrier_computeHash_static : Error processing arguments"); size_t result = cc::gfx::GlobalBarrier::computeHash(arg0.value()); ok &= nativevalue_to_se(result, s.rval(), nullptr /*ctx*/); - SE_PRECONDITION2(ok, false, "js_gfx_GlobalBarrier_computeHash : Error processing arguments"); + SE_PRECONDITION2(ok, false, "js_gfx_GlobalBarrier_computeHash_static : Error processing arguments"); SE_HOLD_RETURN_VALUE(result, s.thisObject(), s.rval()); return true; } SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 1); return false; } -SE_BIND_FUNC(js_gfx_GlobalBarrier_computeHash) +SE_BIND_FUNC(js_gfx_GlobalBarrier_computeHash_static) SE_DECLARE_FINALIZE_FUNC(js_cc_gfx_GlobalBarrier_finalize) static bool js_gfx_GlobalBarrier_constructor(se::State& /*s*/) // NOLINT(readability-identifier-naming) constructor.c { //#3 cc::gfx::GlobalBarrier: is_skip_construtor True - se::ScriptEngine::getInstance()->evalString("throw new Error(\"cc::gfx::GlobalBarrier constructor is skipped\")"); + se::ScriptEngine::getInstance()->throwException("cc::gfx::GlobalBarrier constructor is skipped"); return false; } SE_BIND_CTOR(js_gfx_GlobalBarrier_constructor, __jsb_cc_gfx_GlobalBarrier_class, js_cc_gfx_GlobalBarrier_finalize) - - static bool js_cc_gfx_GlobalBarrier_finalize(se::State& s) // NOLINT(readability-identifier-naming) { - auto iter = se::NonRefNativePtrCreatedByCtorMap::find(SE_THIS_OBJECT(s)); - if (iter != se::NonRefNativePtrCreatedByCtorMap::end()) - { - se::NonRefNativePtrCreatedByCtorMap::erase(iter); - auto* cobj = SE_THIS_OBJECT(s); - JSB_FREE(cobj); - } return true; } SE_BIND_FINALIZE_FUNC(js_cc_gfx_GlobalBarrier_finalize) @@ -20000,7 +19231,7 @@ bool js_register_gfx_GlobalBarrier(se::Object* obj) // NOLINT(readability-identi cls->defineFunction("getHash", _SE(js_gfx_GlobalBarrier_getHash)); cls->defineFunction("getInfo", _SE(js_gfx_GlobalBarrier_getInfo)); - cls->defineStaticFunction("computeHash", _SE(js_gfx_GlobalBarrier_computeHash)); + cls->defineStaticFunction("computeHash", _SE(js_gfx_GlobalBarrier_computeHash_static)); cls->defineFinalizeFunction(_SE(js_cc_gfx_GlobalBarrier_finalize)); cls->install(); JSBClassType::registerClass(cls); @@ -20008,11 +19239,12 @@ bool js_register_gfx_GlobalBarrier(se::Object* obj) // NOLINT(readability-identi __jsb_cc_gfx_GlobalBarrier_proto = cls->getProto(); __jsb_cc_gfx_GlobalBarrier_class = cls; + se::ScriptEngine::getInstance()->clearException(); return true; } -se::Object* __jsb_cc_gfx_Sampler_proto = nullptr; -se::Class* __jsb_cc_gfx_Sampler_class = nullptr; +se::Object* __jsb_cc_gfx_Sampler_proto = nullptr; // NOLINT +se::Class* __jsb_cc_gfx_Sampler_class = nullptr; // NOLINT static bool js_gfx_Sampler_getHash(se::State& s) // NOLINT(readability-identifier-naming) { @@ -20050,9 +19282,9 @@ static bool js_gfx_Sampler_getInfo(se::State& s) // NOLINT(readability-identifie SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 0); return false; } -SE_BIND_PROP_GET(js_gfx_Sampler_getInfo) +SE_BIND_FUNC_AS_PROP_GET(js_gfx_Sampler_getInfo) -static bool js_gfx_Sampler_computeHash(se::State& s) // NOLINT(readability-identifier-naming) +static bool js_gfx_Sampler_computeHash_static(se::State& s) // NOLINT(readability-identifier-naming) { const auto& args = s.args(); size_t argc = args.size(); @@ -20060,39 +19292,50 @@ static bool js_gfx_Sampler_computeHash(se::State& s) // NOLINT(readability-ident if (argc == 1) { HolderType arg0 = {}; ok &= sevalue_to_native(args[0], &arg0, nullptr); - SE_PRECONDITION2(ok, false, "js_gfx_Sampler_computeHash : Error processing arguments"); + SE_PRECONDITION2(ok, false, "js_gfx_Sampler_computeHash_static : Error processing arguments"); size_t result = cc::gfx::Sampler::computeHash(arg0.value()); ok &= nativevalue_to_se(result, s.rval(), nullptr /*ctx*/); - SE_PRECONDITION2(ok, false, "js_gfx_Sampler_computeHash : Error processing arguments"); + SE_PRECONDITION2(ok, false, "js_gfx_Sampler_computeHash_static : Error processing arguments"); SE_HOLD_RETURN_VALUE(result, s.thisObject(), s.rval()); return true; } SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 1); return false; } -SE_BIND_FUNC(js_gfx_Sampler_computeHash) +SE_BIND_FUNC(js_gfx_Sampler_computeHash_static) + +static bool js_gfx_Sampler_unpackFromHash_static(se::State& s) // NOLINT(readability-identifier-naming) +{ + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 1) { + HolderType arg0 = {}; + ok &= sevalue_to_native(args[0], &arg0, nullptr); + SE_PRECONDITION2(ok, false, "js_gfx_Sampler_unpackFromHash_static : Error processing arguments"); + cc::gfx::SamplerInfo result = cc::gfx::Sampler::unpackFromHash(arg0.value()); + ok &= nativevalue_to_se(result, s.rval(), nullptr /*ctx*/); + SE_PRECONDITION2(ok, false, "js_gfx_Sampler_unpackFromHash_static : Error processing arguments"); + SE_HOLD_RETURN_VALUE(result, s.thisObject(), s.rval()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 1); + return false; +} +SE_BIND_FUNC(js_gfx_Sampler_unpackFromHash_static) SE_DECLARE_FINALIZE_FUNC(js_cc_gfx_Sampler_finalize) static bool js_gfx_Sampler_constructor(se::State& /*s*/) // NOLINT(readability-identifier-naming) constructor.c { //#3 cc::gfx::Sampler: is_skip_construtor True - se::ScriptEngine::getInstance()->evalString("throw new Error(\"cc::gfx::Sampler constructor is skipped\")"); + se::ScriptEngine::getInstance()->throwException("cc::gfx::Sampler constructor is skipped"); return false; } SE_BIND_CTOR(js_gfx_Sampler_constructor, __jsb_cc_gfx_Sampler_class, js_cc_gfx_Sampler_finalize) - - static bool js_cc_gfx_Sampler_finalize(se::State& s) // NOLINT(readability-identifier-naming) { - auto iter = se::NonRefNativePtrCreatedByCtorMap::find(SE_THIS_OBJECT(s)); - if (iter != se::NonRefNativePtrCreatedByCtorMap::end()) - { - se::NonRefNativePtrCreatedByCtorMap::erase(iter); - auto* cobj = SE_THIS_OBJECT(s); - JSB_FREE(cobj); - } return true; } SE_BIND_FINALIZE_FUNC(js_cc_gfx_Sampler_finalize) @@ -20101,9 +19344,10 @@ bool js_register_gfx_Sampler(se::Object* obj) // NOLINT(readability-identifier-n { auto* cls = se::Class::create("Sampler", obj, __jsb_cc_gfx_GFXObject_proto, _SE(js_gfx_Sampler_constructor)); - cls->defineProperty("info", _SE(js_gfx_Sampler_getInfo), nullptr); + cls->defineProperty("info", _SE(js_gfx_Sampler_getInfo_asGetter), nullptr); cls->defineFunction("getHash", _SE(js_gfx_Sampler_getHash)); - cls->defineStaticFunction("computeHash", _SE(js_gfx_Sampler_computeHash)); + cls->defineStaticFunction("computeHash", _SE(js_gfx_Sampler_computeHash_static)); + cls->defineStaticFunction("unpackFromHash", _SE(js_gfx_Sampler_unpackFromHash_static)); cls->defineFinalizeFunction(_SE(js_cc_gfx_Sampler_finalize)); cls->install(); JSBClassType::registerClass(cls); @@ -20111,11 +19355,12 @@ bool js_register_gfx_Sampler(se::Object* obj) // NOLINT(readability-identifier-n __jsb_cc_gfx_Sampler_proto = cls->getProto(); __jsb_cc_gfx_Sampler_class = cls; + se::ScriptEngine::getInstance()->clearException(); return true; } -se::Object* __jsb_cc_gfx_TextureBarrier_proto = nullptr; -se::Class* __jsb_cc_gfx_TextureBarrier_class = nullptr; +se::Object* __jsb_cc_gfx_TextureBarrier_proto = nullptr; // NOLINT +se::Class* __jsb_cc_gfx_TextureBarrier_class = nullptr; // NOLINT static bool js_gfx_TextureBarrier_getHash(se::State& s) // NOLINT(readability-identifier-naming) { @@ -20155,7 +19400,7 @@ static bool js_gfx_TextureBarrier_getInfo(se::State& s) // NOLINT(readability-id } SE_BIND_FUNC(js_gfx_TextureBarrier_getInfo) -static bool js_gfx_TextureBarrier_computeHash(se::State& s) // NOLINT(readability-identifier-naming) +static bool js_gfx_TextureBarrier_computeHash_static(se::State& s) // NOLINT(readability-identifier-naming) { const auto& args = s.args(); size_t argc = args.size(); @@ -20163,39 +19408,30 @@ static bool js_gfx_TextureBarrier_computeHash(se::State& s) // NOLINT(readabilit if (argc == 1) { HolderType arg0 = {}; ok &= sevalue_to_native(args[0], &arg0, nullptr); - SE_PRECONDITION2(ok, false, "js_gfx_TextureBarrier_computeHash : Error processing arguments"); + SE_PRECONDITION2(ok, false, "js_gfx_TextureBarrier_computeHash_static : Error processing arguments"); size_t result = cc::gfx::TextureBarrier::computeHash(arg0.value()); ok &= nativevalue_to_se(result, s.rval(), nullptr /*ctx*/); - SE_PRECONDITION2(ok, false, "js_gfx_TextureBarrier_computeHash : Error processing arguments"); + SE_PRECONDITION2(ok, false, "js_gfx_TextureBarrier_computeHash_static : Error processing arguments"); SE_HOLD_RETURN_VALUE(result, s.thisObject(), s.rval()); return true; } SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 1); return false; } -SE_BIND_FUNC(js_gfx_TextureBarrier_computeHash) +SE_BIND_FUNC(js_gfx_TextureBarrier_computeHash_static) SE_DECLARE_FINALIZE_FUNC(js_cc_gfx_TextureBarrier_finalize) static bool js_gfx_TextureBarrier_constructor(se::State& /*s*/) // NOLINT(readability-identifier-naming) constructor.c { //#3 cc::gfx::TextureBarrier: is_skip_construtor True - se::ScriptEngine::getInstance()->evalString("throw new Error(\"cc::gfx::TextureBarrier constructor is skipped\")"); + se::ScriptEngine::getInstance()->throwException("cc::gfx::TextureBarrier constructor is skipped"); return false; } SE_BIND_CTOR(js_gfx_TextureBarrier_constructor, __jsb_cc_gfx_TextureBarrier_class, js_cc_gfx_TextureBarrier_finalize) - - static bool js_cc_gfx_TextureBarrier_finalize(se::State& s) // NOLINT(readability-identifier-naming) { - auto iter = se::NonRefNativePtrCreatedByCtorMap::find(SE_THIS_OBJECT(s)); - if (iter != se::NonRefNativePtrCreatedByCtorMap::end()) - { - se::NonRefNativePtrCreatedByCtorMap::erase(iter); - auto* cobj = SE_THIS_OBJECT(s); - JSB_FREE(cobj); - } return true; } SE_BIND_FINALIZE_FUNC(js_cc_gfx_TextureBarrier_finalize) @@ -20206,7 +19442,7 @@ bool js_register_gfx_TextureBarrier(se::Object* obj) // NOLINT(readability-ident cls->defineFunction("getHash", _SE(js_gfx_TextureBarrier_getHash)); cls->defineFunction("getInfo", _SE(js_gfx_TextureBarrier_getInfo)); - cls->defineStaticFunction("computeHash", _SE(js_gfx_TextureBarrier_computeHash)); + cls->defineStaticFunction("computeHash", _SE(js_gfx_TextureBarrier_computeHash_static)); cls->defineFinalizeFunction(_SE(js_cc_gfx_TextureBarrier_finalize)); cls->install(); JSBClassType::registerClass(cls); @@ -20214,11 +19450,12 @@ bool js_register_gfx_TextureBarrier(se::Object* obj) // NOLINT(readability-ident __jsb_cc_gfx_TextureBarrier_proto = cls->getProto(); __jsb_cc_gfx_TextureBarrier_class = cls; + se::ScriptEngine::getInstance()->clearException(); return true; } -se::Object* __jsb_cc_gfx_Device_proto = nullptr; -se::Class* __jsb_cc_gfx_Device_class = nullptr; +se::Object* __jsb_cc_gfx_Device_proto = nullptr; // NOLINT +se::Class* __jsb_cc_gfx_Device_class = nullptr; // NOLINT static bool js_gfx_Device_acquire(se::State& s) // NOLINT(readability-identifier-naming) { @@ -20290,7 +19527,7 @@ static bool js_gfx_Device_createCommandBuffer(se::State& s) // NOLINT(readabilit cc::gfx::CommandBuffer* result = cobj->createCommandBuffer(arg0.value()); ok &= nativevalue_to_se(result, s.rval(), nullptr /*ctx*/); SE_PRECONDITION2(ok, false, "js_gfx_Device_createCommandBuffer : Error processing arguments"); - se::NonRefNativePtrCreatedByCtorMap::emplace(result); + s.rval().toObject()->getPrivateObject()->tryAllowDestroyInGC(); SE_HOLD_RETURN_VALUE(result, s.thisObject(), s.rval()); return true; } @@ -20313,7 +19550,7 @@ static bool js_gfx_Device_createDescriptorSet(se::State& s) // NOLINT(readabilit cc::gfx::DescriptorSet* result = cobj->createDescriptorSet(arg0.value()); ok &= nativevalue_to_se(result, s.rval(), nullptr /*ctx*/); SE_PRECONDITION2(ok, false, "js_gfx_Device_createDescriptorSet : Error processing arguments"); - se::NonRefNativePtrCreatedByCtorMap::emplace(result); + s.rval().toObject()->getPrivateObject()->tryAllowDestroyInGC(); SE_HOLD_RETURN_VALUE(result, s.thisObject(), s.rval()); return true; } @@ -20336,7 +19573,7 @@ static bool js_gfx_Device_createDescriptorSetLayout(se::State& s) // NOLINT(read cc::gfx::DescriptorSetLayout* result = cobj->createDescriptorSetLayout(arg0.value()); ok &= nativevalue_to_se(result, s.rval(), nullptr /*ctx*/); SE_PRECONDITION2(ok, false, "js_gfx_Device_createDescriptorSetLayout : Error processing arguments"); - se::NonRefNativePtrCreatedByCtorMap::emplace(result); + s.rval().toObject()->getPrivateObject()->tryAllowDestroyInGC(); SE_HOLD_RETURN_VALUE(result, s.thisObject(), s.rval()); return true; } @@ -20359,7 +19596,7 @@ static bool js_gfx_Device_createFramebuffer(se::State& s) // NOLINT(readability- cc::gfx::Framebuffer* result = cobj->createFramebuffer(arg0.value()); ok &= nativevalue_to_se(result, s.rval(), nullptr /*ctx*/); SE_PRECONDITION2(ok, false, "js_gfx_Device_createFramebuffer : Error processing arguments"); - se::NonRefNativePtrCreatedByCtorMap::emplace(result); + s.rval().toObject()->getPrivateObject()->tryAllowDestroyInGC(); SE_HOLD_RETURN_VALUE(result, s.thisObject(), s.rval()); return true; } @@ -20382,7 +19619,7 @@ static bool js_gfx_Device_createInputAssembler(se::State& s) // NOLINT(readabili cc::gfx::InputAssembler* result = cobj->createInputAssembler(arg0.value()); ok &= nativevalue_to_se(result, s.rval(), nullptr /*ctx*/); SE_PRECONDITION2(ok, false, "js_gfx_Device_createInputAssembler : Error processing arguments"); - se::NonRefNativePtrCreatedByCtorMap::emplace(result); + s.rval().toObject()->getPrivateObject()->tryAllowDestroyInGC(); SE_HOLD_RETURN_VALUE(result, s.thisObject(), s.rval()); return true; } @@ -20405,7 +19642,7 @@ static bool js_gfx_Device_createPipelineLayout(se::State& s) // NOLINT(readabili cc::gfx::PipelineLayout* result = cobj->createPipelineLayout(arg0.value()); ok &= nativevalue_to_se(result, s.rval(), nullptr /*ctx*/); SE_PRECONDITION2(ok, false, "js_gfx_Device_createPipelineLayout : Error processing arguments"); - se::NonRefNativePtrCreatedByCtorMap::emplace(result); + s.rval().toObject()->getPrivateObject()->tryAllowDestroyInGC(); SE_HOLD_RETURN_VALUE(result, s.thisObject(), s.rval()); return true; } @@ -20428,7 +19665,7 @@ static bool js_gfx_Device_createPipelineState(se::State& s) // NOLINT(readabilit cc::gfx::PipelineState* result = cobj->createPipelineState(arg0.value()); ok &= nativevalue_to_se(result, s.rval(), nullptr /*ctx*/); SE_PRECONDITION2(ok, false, "js_gfx_Device_createPipelineState : Error processing arguments"); - se::NonRefNativePtrCreatedByCtorMap::emplace(result); + s.rval().toObject()->getPrivateObject()->tryAllowDestroyInGC(); SE_HOLD_RETURN_VALUE(result, s.thisObject(), s.rval()); return true; } @@ -20451,7 +19688,7 @@ static bool js_gfx_Device_createQueryPool(se::State& s) // NOLINT(readability-id cc::gfx::QueryPool* result = cobj->createQueryPool(arg0.value()); ok &= nativevalue_to_se(result, s.rval(), nullptr /*ctx*/); SE_PRECONDITION2(ok, false, "js_gfx_Device_createQueryPool : Error processing arguments"); - se::NonRefNativePtrCreatedByCtorMap::emplace(result); + s.rval().toObject()->getPrivateObject()->tryAllowDestroyInGC(); SE_HOLD_RETURN_VALUE(result, s.thisObject(), s.rval()); return true; } @@ -20474,7 +19711,7 @@ static bool js_gfx_Device_createQueue(se::State& s) // NOLINT(readability-identi cc::gfx::Queue* result = cobj->createQueue(arg0.value()); ok &= nativevalue_to_se(result, s.rval(), nullptr /*ctx*/); SE_PRECONDITION2(ok, false, "js_gfx_Device_createQueue : Error processing arguments"); - se::NonRefNativePtrCreatedByCtorMap::emplace(result); + s.rval().toObject()->getPrivateObject()->tryAllowDestroyInGC(); SE_HOLD_RETURN_VALUE(result, s.thisObject(), s.rval()); return true; } @@ -20497,7 +19734,7 @@ static bool js_gfx_Device_createRenderPass(se::State& s) // NOLINT(readability-i cc::gfx::RenderPass* result = cobj->createRenderPass(arg0.value()); ok &= nativevalue_to_se(result, s.rval(), nullptr /*ctx*/); SE_PRECONDITION2(ok, false, "js_gfx_Device_createRenderPass : Error processing arguments"); - se::NonRefNativePtrCreatedByCtorMap::emplace(result); + s.rval().toObject()->getPrivateObject()->tryAllowDestroyInGC(); SE_HOLD_RETURN_VALUE(result, s.thisObject(), s.rval()); return true; } @@ -20520,7 +19757,7 @@ static bool js_gfx_Device_createShader(se::State& s) // NOLINT(readability-ident cc::gfx::Shader* result = cobj->createShader(arg0.value()); ok &= nativevalue_to_se(result, s.rval(), nullptr /*ctx*/); SE_PRECONDITION2(ok, false, "js_gfx_Device_createShader : Error processing arguments"); - se::NonRefNativePtrCreatedByCtorMap::emplace(result); + s.rval().toObject()->getPrivateObject()->tryAllowDestroyInGC(); SE_HOLD_RETURN_VALUE(result, s.thisObject(), s.rval()); return true; } @@ -20543,7 +19780,7 @@ static bool js_gfx_Device_createSwapchain(se::State& s) // NOLINT(readability-id cc::gfx::Swapchain* result = cobj->createSwapchain(arg0.value()); ok &= nativevalue_to_se(result, s.rval(), nullptr /*ctx*/); SE_PRECONDITION2(ok, false, "js_gfx_Device_createSwapchain : Error processing arguments"); - se::NonRefNativePtrCreatedByCtorMap::emplace(result); + s.rval().toObject()->getPrivateObject()->tryAllowDestroyInGC(); SE_HOLD_RETURN_VALUE(result, s.thisObject(), s.rval()); return true; } @@ -20621,7 +19858,7 @@ static bool js_gfx_Device_getCapabilities(se::State& s) // NOLINT(readability-id SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 0); return false; } -SE_BIND_PROP_GET(js_gfx_Device_getCapabilities) +SE_BIND_FUNC_AS_PROP_GET(js_gfx_Device_getCapabilities) static bool js_gfx_Device_getCommandBuffer(se::State& s) // NOLINT(readability-identifier-naming) { @@ -20640,7 +19877,7 @@ static bool js_gfx_Device_getCommandBuffer(se::State& s) // NOLINT(readability-i SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 0); return false; } -SE_BIND_PROP_GET(js_gfx_Device_getCommandBuffer) +SE_BIND_FUNC_AS_PROP_GET(js_gfx_Device_getCommandBuffer) static bool js_gfx_Device_getDeviceName(se::State& s) // NOLINT(readability-identifier-naming) { @@ -20659,7 +19896,7 @@ static bool js_gfx_Device_getDeviceName(se::State& s) // NOLINT(readability-iden SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 0); return false; } -SE_BIND_PROP_GET(js_gfx_Device_getDeviceName) +SE_BIND_FUNC_AS_PROP_GET(js_gfx_Device_getDeviceName) static bool js_gfx_Device_getGfxAPI(se::State& s) // NOLINT(readability-identifier-naming) { @@ -20678,7 +19915,7 @@ static bool js_gfx_Device_getGfxAPI(se::State& s) // NOLINT(readability-identifi SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 0); return false; } -SE_BIND_PROP_GET(js_gfx_Device_getGfxAPI) +SE_BIND_FUNC_AS_PROP_GET(js_gfx_Device_getGfxAPI) static bool js_gfx_Device_getGlobalBarrier(se::State& s) // NOLINT(readability-identifier-naming) { @@ -20719,7 +19956,7 @@ static bool js_gfx_Device_getMemoryStatus(se::State& s) // NOLINT(readability-id SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 0); return false; } -SE_BIND_PROP_GET(js_gfx_Device_getMemoryStatus) +SE_BIND_FUNC_AS_PROP_GET(js_gfx_Device_getMemoryStatus) static bool js_gfx_Device_getNumDrawCalls(se::State& s) // NOLINT(readability-identifier-naming) { @@ -20738,7 +19975,7 @@ static bool js_gfx_Device_getNumDrawCalls(se::State& s) // NOLINT(readability-id SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 0); return false; } -SE_BIND_PROP_GET(js_gfx_Device_getNumDrawCalls) +SE_BIND_FUNC_AS_PROP_GET(js_gfx_Device_getNumDrawCalls) static bool js_gfx_Device_getNumInstances(se::State& s) // NOLINT(readability-identifier-naming) { @@ -20757,7 +19994,7 @@ static bool js_gfx_Device_getNumInstances(se::State& s) // NOLINT(readability-id SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 0); return false; } -SE_BIND_PROP_GET(js_gfx_Device_getNumInstances) +SE_BIND_FUNC_AS_PROP_GET(js_gfx_Device_getNumInstances) static bool js_gfx_Device_getNumTris(se::State& s) // NOLINT(readability-identifier-naming) { @@ -20776,7 +20013,7 @@ static bool js_gfx_Device_getNumTris(se::State& s) // NOLINT(readability-identif SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 0); return false; } -SE_BIND_PROP_GET(js_gfx_Device_getNumTris) +SE_BIND_FUNC_AS_PROP_GET(js_gfx_Device_getNumTris) static bool js_gfx_Device_getQueryPool(se::State& s) // NOLINT(readability-identifier-naming) { @@ -20833,7 +20070,7 @@ static bool js_gfx_Device_getQueue(se::State& s) // NOLINT(readability-identifie SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 0); return false; } -SE_BIND_PROP_GET(js_gfx_Device_getQueue) +SE_BIND_FUNC_AS_PROP_GET(js_gfx_Device_getQueue) static bool js_gfx_Device_getRenderer(se::State& s) // NOLINT(readability-identifier-naming) { @@ -20852,7 +20089,7 @@ static bool js_gfx_Device_getRenderer(se::State& s) // NOLINT(readability-identi SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 0); return false; } -SE_BIND_PROP_GET(js_gfx_Device_getRenderer) +SE_BIND_FUNC_AS_PROP_GET(js_gfx_Device_getRenderer) static bool js_gfx_Device_getSampler(se::State& s) // NOLINT(readability-identifier-naming) { @@ -20915,7 +20152,7 @@ static bool js_gfx_Device_getVendor(se::State& s) // NOLINT(readability-identifi SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 0); return false; } -SE_BIND_PROP_GET(js_gfx_Device_getVendor) +SE_BIND_FUNC_AS_PROP_GET(js_gfx_Device_getVendor) static bool js_gfx_Device_hasFeature(se::State& s) // NOLINT(readability-identifier-naming) { @@ -20976,23 +20213,21 @@ static bool js_gfx_Device_present(se::State& s) // NOLINT(readability-identifier } SE_BIND_FUNC(js_gfx_Device_present) - - bool js_register_gfx_Device(se::Object* obj) // NOLINT(readability-identifier-naming) { auto* cls = se::Class::create("Device", obj, nullptr, nullptr); - cls->defineProperty("gfxAPI", _SE(js_gfx_Device_getGfxAPI), nullptr); - cls->defineProperty("deviceName", _SE(js_gfx_Device_getDeviceName), nullptr); - cls->defineProperty("memoryStatus", _SE(js_gfx_Device_getMemoryStatus), nullptr); - cls->defineProperty("queue", _SE(js_gfx_Device_getQueue), nullptr); - cls->defineProperty("commandBuffer", _SE(js_gfx_Device_getCommandBuffer), nullptr); - cls->defineProperty("renderer", _SE(js_gfx_Device_getRenderer), nullptr); - cls->defineProperty("vendor", _SE(js_gfx_Device_getVendor), nullptr); - cls->defineProperty("numDrawCalls", _SE(js_gfx_Device_getNumDrawCalls), nullptr); - cls->defineProperty("numInstances", _SE(js_gfx_Device_getNumInstances), nullptr); - cls->defineProperty("numTris", _SE(js_gfx_Device_getNumTris), nullptr); - cls->defineProperty("capabilities", _SE(js_gfx_Device_getCapabilities), nullptr); + cls->defineProperty("deviceName", _SE(js_gfx_Device_getDeviceName_asGetter), nullptr); + cls->defineProperty("vendor", _SE(js_gfx_Device_getVendor_asGetter), nullptr); + cls->defineProperty("numDrawCalls", _SE(js_gfx_Device_getNumDrawCalls_asGetter), nullptr); + cls->defineProperty("memoryStatus", _SE(js_gfx_Device_getMemoryStatus_asGetter), nullptr); + cls->defineProperty("gfxAPI", _SE(js_gfx_Device_getGfxAPI_asGetter), nullptr); + cls->defineProperty("capabilities", _SE(js_gfx_Device_getCapabilities_asGetter), nullptr); + cls->defineProperty("numTris", _SE(js_gfx_Device_getNumTris_asGetter), nullptr); + cls->defineProperty("queue", _SE(js_gfx_Device_getQueue_asGetter), nullptr); + cls->defineProperty("renderer", _SE(js_gfx_Device_getRenderer_asGetter), nullptr); + cls->defineProperty("commandBuffer", _SE(js_gfx_Device_getCommandBuffer_asGetter), nullptr); + cls->defineProperty("numInstances", _SE(js_gfx_Device_getNumInstances_asGetter), nullptr); cls->defineFunction("acquire", _SE(js_gfx_Device_acquire)); cls->defineFunction("bindingMappingInfo", _SE(js_gfx_Device_bindingMappingInfo)); cls->defineFunction("createCommandBuffer", _SE(js_gfx_Device_createCommandBuffer)); @@ -21023,46 +20258,14 @@ bool js_register_gfx_Device(se::Object* obj) // NOLINT(readability-identifier-na __jsb_cc_gfx_Device_proto = cls->getProto(); __jsb_cc_gfx_Device_class = cls; + se::ScriptEngine::getInstance()->clearException(); return true; } -se::Object* __jsb_cc_gfx_DeviceManager_proto = nullptr; -se::Class* __jsb_cc_gfx_DeviceManager_class = nullptr; +se::Object* __jsb_cc_gfx_DeviceManager_proto = nullptr; // NOLINT +se::Class* __jsb_cc_gfx_DeviceManager_class = nullptr; // NOLINT -static bool js_gfx_DeviceManager_create(se::State& s) // NOLINT(readability-identifier-naming) -{ - const auto& args = s.args(); - size_t argc = args.size(); - CC_UNUSED bool ok = true; - if (argc == 1) { - HolderType arg0 = {}; - ok &= sevalue_to_native(args[0], &arg0, nullptr); - SE_PRECONDITION2(ok, false, "js_gfx_DeviceManager_create : Error processing arguments"); - cc::gfx::Device* result = cc::gfx::DeviceManager::create(arg0.value()); - ok &= nativevalue_to_se(result, s.rval(), nullptr /*ctx*/); - SE_PRECONDITION2(ok, false, "js_gfx_DeviceManager_create : Error processing arguments"); - SE_HOLD_RETURN_VALUE(result, s.thisObject(), s.rval()); - return true; - } - SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 1); - return false; -} -SE_BIND_FUNC(js_gfx_DeviceManager_create) - -static bool js_gfx_DeviceManager_destroy(se::State& s) // NOLINT(readability-identifier-naming) -{ - const auto& args = s.args(); - size_t argc = args.size(); - if (argc == 0) { - cc::gfx::DeviceManager::destroy(); - return true; - } - SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 0); - return false; -} -SE_BIND_FUNC(js_gfx_DeviceManager_destroy) - -static bool js_gfx_DeviceManager_addSurfaceEventListener(se::State& s) // NOLINT(readability-identifier-naming) +static bool js_gfx_DeviceManager_addSurfaceEventListener_static(se::State& s) // NOLINT(readability-identifier-naming) { const auto& args = s.args(); size_t argc = args.size(); @@ -21073,18 +20276,42 @@ static bool js_gfx_DeviceManager_addSurfaceEventListener(se::State& s) // NOLINT SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 0); return false; } -SE_BIND_FUNC(js_gfx_DeviceManager_addSurfaceEventListener) +SE_BIND_FUNC(js_gfx_DeviceManager_addSurfaceEventListener_static) +static bool js_gfx_DeviceManager_create_static(se::State& s) // NOLINT(readability-identifier-naming) +{ + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 1) { + HolderType arg0 = {}; + ok &= sevalue_to_native(args[0], &arg0, nullptr); + SE_PRECONDITION2(ok, false, "js_gfx_DeviceManager_create_static : Error processing arguments"); + cc::gfx::Device* result = cc::gfx::DeviceManager::create(arg0.value()); + ok &= nativevalue_to_se(result, s.rval(), nullptr /*ctx*/); + SE_PRECONDITION2(ok, false, "js_gfx_DeviceManager_create_static : Error processing arguments"); + SE_HOLD_RETURN_VALUE(result, s.thisObject(), s.rval()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 1); + return false; +} +SE_BIND_FUNC(js_gfx_DeviceManager_create_static) +static bool js_gfx_DeviceManager_destroy_static(se::State& s) // NOLINT(readability-identifier-naming) +{ + const auto& args = s.args(); + size_t argc = args.size(); + if (argc == 0) { + cc::gfx::DeviceManager::destroy(); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 0); + return false; +} +SE_BIND_FUNC(js_gfx_DeviceManager_destroy_static) static bool js_cc_gfx_DeviceManager_finalize(se::State& s) // NOLINT(readability-identifier-naming) { - auto iter = se::NonRefNativePtrCreatedByCtorMap::find(SE_THIS_OBJECT(s)); - if (iter != se::NonRefNativePtrCreatedByCtorMap::end()) - { - se::NonRefNativePtrCreatedByCtorMap::erase(iter); - auto* cobj = SE_THIS_OBJECT(s); - JSB_FREE(cobj); - } return true; } SE_BIND_FINALIZE_FUNC(js_cc_gfx_DeviceManager_finalize) @@ -21093,9 +20320,9 @@ bool js_register_gfx_DeviceManager(se::Object* obj) // NOLINT(readability-identi { auto* cls = se::Class::create("DeviceManager", obj, nullptr, nullptr); - cls->defineStaticFunction("create", _SE(js_gfx_DeviceManager_create)); - cls->defineStaticFunction("destroy", _SE(js_gfx_DeviceManager_destroy)); - cls->defineStaticFunction("addSurfaceEventListener", _SE(js_gfx_DeviceManager_addSurfaceEventListener)); + cls->defineStaticFunction("addSurfaceEventListener", _SE(js_gfx_DeviceManager_addSurfaceEventListener_static)); + cls->defineStaticFunction("create", _SE(js_gfx_DeviceManager_create_static)); + cls->defineStaticFunction("destroy", _SE(js_gfx_DeviceManager_destroy_static)); cls->defineFinalizeFunction(_SE(js_cc_gfx_DeviceManager_finalize)); cls->install(); JSBClassType::registerClass(cls); @@ -21103,14 +20330,15 @@ bool js_register_gfx_DeviceManager(se::Object* obj) // NOLINT(readability-identi __jsb_cc_gfx_DeviceManager_proto = cls->getProto(); __jsb_cc_gfx_DeviceManager_class = cls; + se::ScriptEngine::getInstance()->clearException(); return true; } -bool register_all_gfx(se::Object* obj) +bool register_all_gfx(se::Object* obj) // NOLINT { // Get the ns se::Value nsVal; - if (!obj->getProperty("gfx", &nsVal)) + if (!obj->getProperty("gfx", &nsVal, true)) { se::HandleObject jsobj(se::Object::createPlainObject()); nsVal.setObject(jsobj); @@ -21118,83 +20346,84 @@ bool register_all_gfx(se::Object* obj) } se::Object* ns = nsVal.toObject(); - js_register_gfx_Size(ns); - js_register_gfx_DeviceCaps(ns); - js_register_gfx_Offset(ns); - js_register_gfx_Rect(ns); - js_register_gfx_Extent(ns); - js_register_gfx_TextureSubresLayers(ns); - js_register_gfx_TextureSubresRange(ns); - js_register_gfx_TextureCopy(ns); - js_register_gfx_TextureBlit(ns); - js_register_gfx_BufferTextureCopy(ns); - js_register_gfx_Viewport(ns); - js_register_gfx_Color(ns); - js_register_gfx_BindingMappingInfo(ns); - js_register_gfx_SwapchainInfo(ns); - js_register_gfx_DeviceInfo(ns); - js_register_gfx_BufferInfo(ns); - js_register_gfx_BufferViewInfo(ns); - js_register_gfx_DrawInfo(ns); - js_register_gfx_DispatchInfo(ns); - js_register_gfx_IndirectBuffer(ns); - js_register_gfx_TextureInfo(ns); - js_register_gfx_TextureViewInfo(ns); - js_register_gfx_SamplerInfo(ns); - js_register_gfx_Uniform(ns); - js_register_gfx_UniformBlock(ns); - js_register_gfx_UniformSamplerTexture(ns); - js_register_gfx_UniformSampler(ns); - js_register_gfx_UniformTexture(ns); - js_register_gfx_UniformStorageImage(ns); - js_register_gfx_UniformStorageBuffer(ns); - js_register_gfx_UniformInputAttachment(ns); - js_register_gfx_ShaderStage(ns); js_register_gfx_Attribute(ns); - js_register_gfx_ShaderInfo(ns); - js_register_gfx_InputAssemblerInfo(ns); - js_register_gfx_ColorAttachment(ns); - js_register_gfx_DepthStencilAttachment(ns); - js_register_gfx_SubpassInfo(ns); - js_register_gfx_SubpassDependency(ns); - js_register_gfx_RenderPassInfo(ns); - js_register_gfx_GlobalBarrierInfo(ns); - js_register_gfx_TextureBarrierInfo(ns); - js_register_gfx_FramebufferInfo(ns); - js_register_gfx_DescriptorSetLayoutBinding(ns); - js_register_gfx_DescriptorSetLayoutInfo(ns); - js_register_gfx_DescriptorSetInfo(ns); - js_register_gfx_PipelineLayoutInfo(ns); - js_register_gfx_InputState(ns); - js_register_gfx_RasterizerState(ns); - js_register_gfx_DepthStencilState(ns); - js_register_gfx_BlendTarget(ns); + js_register_gfx_BindingMappingInfo(ns); js_register_gfx_BlendState(ns); - js_register_gfx_PipelineStateInfo(ns); - js_register_gfx_CommandBufferInfo(ns); - js_register_gfx_QueueInfo(ns); - js_register_gfx_QueryPoolInfo(ns); - js_register_gfx_MemoryStatus(ns); + js_register_gfx_BlendTarget(ns); js_register_gfx_GFXObject(ns); js_register_gfx_Buffer(ns); - js_register_gfx_InputAssembler(ns); + js_register_gfx_BufferInfo(ns); + js_register_gfx_BufferTextureCopy(ns); + js_register_gfx_BufferViewInfo(ns); + js_register_gfx_Color(ns); + js_register_gfx_ColorAttachment(ns); js_register_gfx_CommandBuffer(ns); + js_register_gfx_CommandBufferInfo(ns); + js_register_gfx_DepthStencilAttachment(ns); + js_register_gfx_DepthStencilState(ns); js_register_gfx_DescriptorSet(ns); + js_register_gfx_DescriptorSetInfo(ns); js_register_gfx_DescriptorSetLayout(ns); - js_register_gfx_Framebuffer(ns); - js_register_gfx_PipelineLayout(ns); - js_register_gfx_PipelineState(ns); - js_register_gfx_QueryPool(ns); - js_register_gfx_Queue(ns); - js_register_gfx_RenderPass(ns); - js_register_gfx_Shader(ns); - js_register_gfx_Texture(ns); - js_register_gfx_Swapchain(ns); - js_register_gfx_GlobalBarrier(ns); - js_register_gfx_Sampler(ns); - js_register_gfx_TextureBarrier(ns); + js_register_gfx_DescriptorSetLayoutBinding(ns); + js_register_gfx_DescriptorSetLayoutInfo(ns); js_register_gfx_Device(ns); + js_register_gfx_DeviceCaps(ns); + js_register_gfx_DeviceInfo(ns); js_register_gfx_DeviceManager(ns); + js_register_gfx_DispatchInfo(ns); + js_register_gfx_DrawInfo(ns); + js_register_gfx_Extent(ns); + js_register_gfx_Framebuffer(ns); + js_register_gfx_FramebufferInfo(ns); + js_register_gfx_GlobalBarrier(ns); + js_register_gfx_GlobalBarrierInfo(ns); + js_register_gfx_IndirectBuffer(ns); + js_register_gfx_InputAssembler(ns); + js_register_gfx_InputAssemblerInfo(ns); + js_register_gfx_InputState(ns); + js_register_gfx_MemoryStatus(ns); + js_register_gfx_Offset(ns); + js_register_gfx_PipelineLayout(ns); + js_register_gfx_PipelineLayoutInfo(ns); + js_register_gfx_PipelineState(ns); + js_register_gfx_PipelineStateInfo(ns); + js_register_gfx_QueryPool(ns); + js_register_gfx_QueryPoolInfo(ns); + js_register_gfx_Queue(ns); + js_register_gfx_QueueInfo(ns); + js_register_gfx_RasterizerState(ns); + js_register_gfx_Rect(ns); + js_register_gfx_RenderPass(ns); + js_register_gfx_RenderPassInfo(ns); + js_register_gfx_Sampler(ns); + js_register_gfx_SamplerInfo(ns); + js_register_gfx_Shader(ns); + js_register_gfx_ShaderInfo(ns); + js_register_gfx_ShaderStage(ns); + js_register_gfx_Size(ns); + js_register_gfx_SubpassDependency(ns); + js_register_gfx_SubpassInfo(ns); + js_register_gfx_Swapchain(ns); + js_register_gfx_SwapchainInfo(ns); + js_register_gfx_Texture(ns); + js_register_gfx_TextureBarrier(ns); + js_register_gfx_TextureBarrierInfo(ns); + js_register_gfx_TextureBlit(ns); + js_register_gfx_TextureCopy(ns); + js_register_gfx_TextureInfo(ns); + js_register_gfx_TextureSubresLayers(ns); + js_register_gfx_TextureSubresRange(ns); + js_register_gfx_TextureViewInfo(ns); + js_register_gfx_Uniform(ns); + js_register_gfx_UniformBlock(ns); + js_register_gfx_UniformInputAttachment(ns); + js_register_gfx_UniformSampler(ns); + js_register_gfx_UniformSamplerTexture(ns); + js_register_gfx_UniformStorageBuffer(ns); + js_register_gfx_UniformStorageImage(ns); + js_register_gfx_UniformTexture(ns); + js_register_gfx_Viewport(ns); return true; } +// clang-format on \ No newline at end of file diff --git a/native/cocos/bindings/auto/jsb_gfx_auto.h b/native/cocos/bindings/auto/jsb_gfx_auto.h index a1db6e319a..cec6897f32 100644 --- a/native/cocos/bindings/auto/jsb_gfx_auto.h +++ b/native/cocos/bindings/auto/jsb_gfx_auto.h @@ -1,3 +1,4 @@ +// clang-format off #pragma once #include "base/Config.h" #include @@ -5,616 +6,580 @@ #include "cocos/bindings/manual/jsb_conversions.h" #include "cocos/renderer/GFXDeviceManager.h" -extern se::Object* __jsb_cc_gfx_Size_proto; -extern se::Class* __jsb_cc_gfx_Size_class; +bool register_all_gfx(se::Object *obj); // NOLINT -bool js_register_cc_gfx_Size(se::Object* obj); -bool register_all_gfx(se::Object* obj); - -template<> -bool sevalue_to_native(const se::Value &, cc::gfx::Size *, se::Object *ctx); JSB_REGISTER_OBJECT_TYPE(cc::gfx::Size); - -extern se::Object* __jsb_cc_gfx_DeviceCaps_proto; -extern se::Class* __jsb_cc_gfx_DeviceCaps_class; - -bool js_register_cc_gfx_DeviceCaps(se::Object* obj); -bool register_all_gfx(se::Object* obj); - -template<> -bool sevalue_to_native(const se::Value &, cc::gfx::DeviceCaps *, se::Object *ctx); JSB_REGISTER_OBJECT_TYPE(cc::gfx::DeviceCaps); - -extern se::Object* __jsb_cc_gfx_Offset_proto; -extern se::Class* __jsb_cc_gfx_Offset_class; - -bool js_register_cc_gfx_Offset(se::Object* obj); -bool register_all_gfx(se::Object* obj); - -template<> -bool sevalue_to_native(const se::Value &, cc::gfx::Offset *, se::Object *ctx); JSB_REGISTER_OBJECT_TYPE(cc::gfx::Offset); - -extern se::Object* __jsb_cc_gfx_Rect_proto; -extern se::Class* __jsb_cc_gfx_Rect_class; - -bool js_register_cc_gfx_Rect(se::Object* obj); -bool register_all_gfx(se::Object* obj); - -template<> -bool sevalue_to_native(const se::Value &, cc::gfx::Rect *, se::Object *ctx); JSB_REGISTER_OBJECT_TYPE(cc::gfx::Rect); - -extern se::Object* __jsb_cc_gfx_Extent_proto; -extern se::Class* __jsb_cc_gfx_Extent_class; - -bool js_register_cc_gfx_Extent(se::Object* obj); -bool register_all_gfx(se::Object* obj); - -template<> -bool sevalue_to_native(const se::Value &, cc::gfx::Extent *, se::Object *ctx); JSB_REGISTER_OBJECT_TYPE(cc::gfx::Extent); - -extern se::Object* __jsb_cc_gfx_TextureSubresLayers_proto; -extern se::Class* __jsb_cc_gfx_TextureSubresLayers_class; - -bool js_register_cc_gfx_TextureSubresLayers(se::Object* obj); -bool register_all_gfx(se::Object* obj); - -template<> -bool sevalue_to_native(const se::Value &, cc::gfx::TextureSubresLayers *, se::Object *ctx); JSB_REGISTER_OBJECT_TYPE(cc::gfx::TextureSubresLayers); - -extern se::Object* __jsb_cc_gfx_TextureSubresRange_proto; -extern se::Class* __jsb_cc_gfx_TextureSubresRange_class; - -bool js_register_cc_gfx_TextureSubresRange(se::Object* obj); -bool register_all_gfx(se::Object* obj); - -template<> -bool sevalue_to_native(const se::Value &, cc::gfx::TextureSubresRange *, se::Object *ctx); JSB_REGISTER_OBJECT_TYPE(cc::gfx::TextureSubresRange); - -extern se::Object* __jsb_cc_gfx_TextureCopy_proto; -extern se::Class* __jsb_cc_gfx_TextureCopy_class; - -bool js_register_cc_gfx_TextureCopy(se::Object* obj); -bool register_all_gfx(se::Object* obj); - -template<> -bool sevalue_to_native(const se::Value &, cc::gfx::TextureCopy *, se::Object *ctx); JSB_REGISTER_OBJECT_TYPE(cc::gfx::TextureCopy); - -extern se::Object* __jsb_cc_gfx_TextureBlit_proto; -extern se::Class* __jsb_cc_gfx_TextureBlit_class; - -bool js_register_cc_gfx_TextureBlit(se::Object* obj); -bool register_all_gfx(se::Object* obj); - -template<> -bool sevalue_to_native(const se::Value &, cc::gfx::TextureBlit *, se::Object *ctx); JSB_REGISTER_OBJECT_TYPE(cc::gfx::TextureBlit); - -extern se::Object* __jsb_cc_gfx_BufferTextureCopy_proto; -extern se::Class* __jsb_cc_gfx_BufferTextureCopy_class; - -bool js_register_cc_gfx_BufferTextureCopy(se::Object* obj); -bool register_all_gfx(se::Object* obj); - -template<> -bool sevalue_to_native(const se::Value &, cc::gfx::BufferTextureCopy *, se::Object *ctx); JSB_REGISTER_OBJECT_TYPE(cc::gfx::BufferTextureCopy); - -extern se::Object* __jsb_cc_gfx_Viewport_proto; -extern se::Class* __jsb_cc_gfx_Viewport_class; - -bool js_register_cc_gfx_Viewport(se::Object* obj); -bool register_all_gfx(se::Object* obj); - -template<> -bool sevalue_to_native(const se::Value &, cc::gfx::Viewport *, se::Object *ctx); JSB_REGISTER_OBJECT_TYPE(cc::gfx::Viewport); - -extern se::Object* __jsb_cc_gfx_Color_proto; -extern se::Class* __jsb_cc_gfx_Color_class; - -bool js_register_cc_gfx_Color(se::Object* obj); -bool register_all_gfx(se::Object* obj); - -template<> -bool sevalue_to_native(const se::Value &, cc::gfx::Color *, se::Object *ctx); JSB_REGISTER_OBJECT_TYPE(cc::gfx::Color); - -extern se::Object* __jsb_cc_gfx_BindingMappingInfo_proto; -extern se::Class* __jsb_cc_gfx_BindingMappingInfo_class; - -bool js_register_cc_gfx_BindingMappingInfo(se::Object* obj); -bool register_all_gfx(se::Object* obj); - -template<> -bool sevalue_to_native(const se::Value &, cc::gfx::BindingMappingInfo *, se::Object *ctx); JSB_REGISTER_OBJECT_TYPE(cc::gfx::BindingMappingInfo); - -extern se::Object* __jsb_cc_gfx_SwapchainInfo_proto; -extern se::Class* __jsb_cc_gfx_SwapchainInfo_class; - -bool js_register_cc_gfx_SwapchainInfo(se::Object* obj); -bool register_all_gfx(se::Object* obj); - -template<> -bool sevalue_to_native(const se::Value &, cc::gfx::SwapchainInfo *, se::Object *ctx); JSB_REGISTER_OBJECT_TYPE(cc::gfx::SwapchainInfo); - -extern se::Object* __jsb_cc_gfx_DeviceInfo_proto; -extern se::Class* __jsb_cc_gfx_DeviceInfo_class; - -bool js_register_cc_gfx_DeviceInfo(se::Object* obj); -bool register_all_gfx(se::Object* obj); - -template<> -bool sevalue_to_native(const se::Value &, cc::gfx::DeviceInfo *, se::Object *ctx); JSB_REGISTER_OBJECT_TYPE(cc::gfx::DeviceInfo); - -extern se::Object* __jsb_cc_gfx_BufferInfo_proto; -extern se::Class* __jsb_cc_gfx_BufferInfo_class; - -bool js_register_cc_gfx_BufferInfo(se::Object* obj); -bool register_all_gfx(se::Object* obj); - -template<> -bool sevalue_to_native(const se::Value &, cc::gfx::BufferInfo *, se::Object *ctx); JSB_REGISTER_OBJECT_TYPE(cc::gfx::BufferInfo); - -extern se::Object* __jsb_cc_gfx_BufferViewInfo_proto; -extern se::Class* __jsb_cc_gfx_BufferViewInfo_class; - -bool js_register_cc_gfx_BufferViewInfo(se::Object* obj); -bool register_all_gfx(se::Object* obj); - -template<> -bool sevalue_to_native(const se::Value &, cc::gfx::BufferViewInfo *, se::Object *ctx); JSB_REGISTER_OBJECT_TYPE(cc::gfx::BufferViewInfo); - -extern se::Object* __jsb_cc_gfx_DrawInfo_proto; -extern se::Class* __jsb_cc_gfx_DrawInfo_class; - -bool js_register_cc_gfx_DrawInfo(se::Object* obj); -bool register_all_gfx(se::Object* obj); - -template<> -bool sevalue_to_native(const se::Value &, cc::gfx::DrawInfo *, se::Object *ctx); JSB_REGISTER_OBJECT_TYPE(cc::gfx::DrawInfo); - -extern se::Object* __jsb_cc_gfx_DispatchInfo_proto; -extern se::Class* __jsb_cc_gfx_DispatchInfo_class; - -bool js_register_cc_gfx_DispatchInfo(se::Object* obj); -bool register_all_gfx(se::Object* obj); - -template<> -bool sevalue_to_native(const se::Value &, cc::gfx::DispatchInfo *, se::Object *ctx); JSB_REGISTER_OBJECT_TYPE(cc::gfx::DispatchInfo); - -extern se::Object* __jsb_cc_gfx_IndirectBuffer_proto; -extern se::Class* __jsb_cc_gfx_IndirectBuffer_class; - -bool js_register_cc_gfx_IndirectBuffer(se::Object* obj); -bool register_all_gfx(se::Object* obj); - -template<> -bool sevalue_to_native(const se::Value &, cc::gfx::IndirectBuffer *, se::Object *ctx); JSB_REGISTER_OBJECT_TYPE(cc::gfx::IndirectBuffer); - -extern se::Object* __jsb_cc_gfx_TextureInfo_proto; -extern se::Class* __jsb_cc_gfx_TextureInfo_class; - -bool js_register_cc_gfx_TextureInfo(se::Object* obj); -bool register_all_gfx(se::Object* obj); - -template<> -bool sevalue_to_native(const se::Value &, cc::gfx::TextureInfo *, se::Object *ctx); JSB_REGISTER_OBJECT_TYPE(cc::gfx::TextureInfo); - -extern se::Object* __jsb_cc_gfx_TextureViewInfo_proto; -extern se::Class* __jsb_cc_gfx_TextureViewInfo_class; - -bool js_register_cc_gfx_TextureViewInfo(se::Object* obj); -bool register_all_gfx(se::Object* obj); - -template<> -bool sevalue_to_native(const se::Value &, cc::gfx::TextureViewInfo *, se::Object *ctx); JSB_REGISTER_OBJECT_TYPE(cc::gfx::TextureViewInfo); - -extern se::Object* __jsb_cc_gfx_SamplerInfo_proto; -extern se::Class* __jsb_cc_gfx_SamplerInfo_class; - -bool js_register_cc_gfx_SamplerInfo(se::Object* obj); -bool register_all_gfx(se::Object* obj); - -template<> -bool sevalue_to_native(const se::Value &, cc::gfx::SamplerInfo *, se::Object *ctx); JSB_REGISTER_OBJECT_TYPE(cc::gfx::SamplerInfo); - -extern se::Object* __jsb_cc_gfx_Uniform_proto; -extern se::Class* __jsb_cc_gfx_Uniform_class; - -bool js_register_cc_gfx_Uniform(se::Object* obj); -bool register_all_gfx(se::Object* obj); - -template<> -bool sevalue_to_native(const se::Value &, cc::gfx::Uniform *, se::Object *ctx); JSB_REGISTER_OBJECT_TYPE(cc::gfx::Uniform); - -extern se::Object* __jsb_cc_gfx_UniformBlock_proto; -extern se::Class* __jsb_cc_gfx_UniformBlock_class; - -bool js_register_cc_gfx_UniformBlock(se::Object* obj); -bool register_all_gfx(se::Object* obj); - -template<> -bool sevalue_to_native(const se::Value &, cc::gfx::UniformBlock *, se::Object *ctx); JSB_REGISTER_OBJECT_TYPE(cc::gfx::UniformBlock); - -extern se::Object* __jsb_cc_gfx_UniformSamplerTexture_proto; -extern se::Class* __jsb_cc_gfx_UniformSamplerTexture_class; - -bool js_register_cc_gfx_UniformSamplerTexture(se::Object* obj); -bool register_all_gfx(se::Object* obj); - -template<> -bool sevalue_to_native(const se::Value &, cc::gfx::UniformSamplerTexture *, se::Object *ctx); JSB_REGISTER_OBJECT_TYPE(cc::gfx::UniformSamplerTexture); - -extern se::Object* __jsb_cc_gfx_UniformSampler_proto; -extern se::Class* __jsb_cc_gfx_UniformSampler_class; - -bool js_register_cc_gfx_UniformSampler(se::Object* obj); -bool register_all_gfx(se::Object* obj); - -template<> -bool sevalue_to_native(const se::Value &, cc::gfx::UniformSampler *, se::Object *ctx); JSB_REGISTER_OBJECT_TYPE(cc::gfx::UniformSampler); - -extern se::Object* __jsb_cc_gfx_UniformTexture_proto; -extern se::Class* __jsb_cc_gfx_UniformTexture_class; - -bool js_register_cc_gfx_UniformTexture(se::Object* obj); -bool register_all_gfx(se::Object* obj); - -template<> -bool sevalue_to_native(const se::Value &, cc::gfx::UniformTexture *, se::Object *ctx); JSB_REGISTER_OBJECT_TYPE(cc::gfx::UniformTexture); - -extern se::Object* __jsb_cc_gfx_UniformStorageImage_proto; -extern se::Class* __jsb_cc_gfx_UniformStorageImage_class; - -bool js_register_cc_gfx_UniformStorageImage(se::Object* obj); -bool register_all_gfx(se::Object* obj); - -template<> -bool sevalue_to_native(const se::Value &, cc::gfx::UniformStorageImage *, se::Object *ctx); JSB_REGISTER_OBJECT_TYPE(cc::gfx::UniformStorageImage); - -extern se::Object* __jsb_cc_gfx_UniformStorageBuffer_proto; -extern se::Class* __jsb_cc_gfx_UniformStorageBuffer_class; - -bool js_register_cc_gfx_UniformStorageBuffer(se::Object* obj); -bool register_all_gfx(se::Object* obj); - -template<> -bool sevalue_to_native(const se::Value &, cc::gfx::UniformStorageBuffer *, se::Object *ctx); JSB_REGISTER_OBJECT_TYPE(cc::gfx::UniformStorageBuffer); - -extern se::Object* __jsb_cc_gfx_UniformInputAttachment_proto; -extern se::Class* __jsb_cc_gfx_UniformInputAttachment_class; - -bool js_register_cc_gfx_UniformInputAttachment(se::Object* obj); -bool register_all_gfx(se::Object* obj); - -template<> -bool sevalue_to_native(const se::Value &, cc::gfx::UniformInputAttachment *, se::Object *ctx); JSB_REGISTER_OBJECT_TYPE(cc::gfx::UniformInputAttachment); - -extern se::Object* __jsb_cc_gfx_ShaderStage_proto; -extern se::Class* __jsb_cc_gfx_ShaderStage_class; - -bool js_register_cc_gfx_ShaderStage(se::Object* obj); -bool register_all_gfx(se::Object* obj); - -template<> -bool sevalue_to_native(const se::Value &, cc::gfx::ShaderStage *, se::Object *ctx); JSB_REGISTER_OBJECT_TYPE(cc::gfx::ShaderStage); - -extern se::Object* __jsb_cc_gfx_Attribute_proto; -extern se::Class* __jsb_cc_gfx_Attribute_class; - -bool js_register_cc_gfx_Attribute(se::Object* obj); -bool register_all_gfx(se::Object* obj); - -template<> -bool sevalue_to_native(const se::Value &, cc::gfx::Attribute *, se::Object *ctx); JSB_REGISTER_OBJECT_TYPE(cc::gfx::Attribute); - -extern se::Object* __jsb_cc_gfx_ShaderInfo_proto; -extern se::Class* __jsb_cc_gfx_ShaderInfo_class; - -bool js_register_cc_gfx_ShaderInfo(se::Object* obj); -bool register_all_gfx(se::Object* obj); - -template<> -bool sevalue_to_native(const se::Value &, cc::gfx::ShaderInfo *, se::Object *ctx); JSB_REGISTER_OBJECT_TYPE(cc::gfx::ShaderInfo); - -extern se::Object* __jsb_cc_gfx_InputAssemblerInfo_proto; -extern se::Class* __jsb_cc_gfx_InputAssemblerInfo_class; - -bool js_register_cc_gfx_InputAssemblerInfo(se::Object* obj); -bool register_all_gfx(se::Object* obj); - -template<> -bool sevalue_to_native(const se::Value &, cc::gfx::InputAssemblerInfo *, se::Object *ctx); JSB_REGISTER_OBJECT_TYPE(cc::gfx::InputAssemblerInfo); - -extern se::Object* __jsb_cc_gfx_ColorAttachment_proto; -extern se::Class* __jsb_cc_gfx_ColorAttachment_class; - -bool js_register_cc_gfx_ColorAttachment(se::Object* obj); -bool register_all_gfx(se::Object* obj); - -template<> -bool sevalue_to_native(const se::Value &, cc::gfx::ColorAttachment *, se::Object *ctx); JSB_REGISTER_OBJECT_TYPE(cc::gfx::ColorAttachment); - -extern se::Object* __jsb_cc_gfx_DepthStencilAttachment_proto; -extern se::Class* __jsb_cc_gfx_DepthStencilAttachment_class; - -bool js_register_cc_gfx_DepthStencilAttachment(se::Object* obj); -bool register_all_gfx(se::Object* obj); - -template<> -bool sevalue_to_native(const se::Value &, cc::gfx::DepthStencilAttachment *, se::Object *ctx); JSB_REGISTER_OBJECT_TYPE(cc::gfx::DepthStencilAttachment); - -extern se::Object* __jsb_cc_gfx_SubpassInfo_proto; -extern se::Class* __jsb_cc_gfx_SubpassInfo_class; - -bool js_register_cc_gfx_SubpassInfo(se::Object* obj); -bool register_all_gfx(se::Object* obj); - -template<> -bool sevalue_to_native(const se::Value &, cc::gfx::SubpassInfo *, se::Object *ctx); JSB_REGISTER_OBJECT_TYPE(cc::gfx::SubpassInfo); - -extern se::Object* __jsb_cc_gfx_SubpassDependency_proto; -extern se::Class* __jsb_cc_gfx_SubpassDependency_class; - -bool js_register_cc_gfx_SubpassDependency(se::Object* obj); -bool register_all_gfx(se::Object* obj); - -template<> -bool sevalue_to_native(const se::Value &, cc::gfx::SubpassDependency *, se::Object *ctx); JSB_REGISTER_OBJECT_TYPE(cc::gfx::SubpassDependency); - -extern se::Object* __jsb_cc_gfx_RenderPassInfo_proto; -extern se::Class* __jsb_cc_gfx_RenderPassInfo_class; - -bool js_register_cc_gfx_RenderPassInfo(se::Object* obj); -bool register_all_gfx(se::Object* obj); - -template<> -bool sevalue_to_native(const se::Value &, cc::gfx::RenderPassInfo *, se::Object *ctx); JSB_REGISTER_OBJECT_TYPE(cc::gfx::RenderPassInfo); - -extern se::Object* __jsb_cc_gfx_GlobalBarrierInfo_proto; -extern se::Class* __jsb_cc_gfx_GlobalBarrierInfo_class; - -bool js_register_cc_gfx_GlobalBarrierInfo(se::Object* obj); -bool register_all_gfx(se::Object* obj); - -template<> -bool sevalue_to_native(const se::Value &, cc::gfx::GlobalBarrierInfo *, se::Object *ctx); JSB_REGISTER_OBJECT_TYPE(cc::gfx::GlobalBarrierInfo); - -extern se::Object* __jsb_cc_gfx_TextureBarrierInfo_proto; -extern se::Class* __jsb_cc_gfx_TextureBarrierInfo_class; - -bool js_register_cc_gfx_TextureBarrierInfo(se::Object* obj); -bool register_all_gfx(se::Object* obj); - -template<> -bool sevalue_to_native(const se::Value &, cc::gfx::TextureBarrierInfo *, se::Object *ctx); JSB_REGISTER_OBJECT_TYPE(cc::gfx::TextureBarrierInfo); - -extern se::Object* __jsb_cc_gfx_FramebufferInfo_proto; -extern se::Class* __jsb_cc_gfx_FramebufferInfo_class; - -bool js_register_cc_gfx_FramebufferInfo(se::Object* obj); -bool register_all_gfx(se::Object* obj); - -template<> -bool sevalue_to_native(const se::Value &, cc::gfx::FramebufferInfo *, se::Object *ctx); JSB_REGISTER_OBJECT_TYPE(cc::gfx::FramebufferInfo); - -extern se::Object* __jsb_cc_gfx_DescriptorSetLayoutBinding_proto; -extern se::Class* __jsb_cc_gfx_DescriptorSetLayoutBinding_class; - -bool js_register_cc_gfx_DescriptorSetLayoutBinding(se::Object* obj); -bool register_all_gfx(se::Object* obj); - -template<> -bool sevalue_to_native(const se::Value &, cc::gfx::DescriptorSetLayoutBinding *, se::Object *ctx); JSB_REGISTER_OBJECT_TYPE(cc::gfx::DescriptorSetLayoutBinding); - -extern se::Object* __jsb_cc_gfx_DescriptorSetLayoutInfo_proto; -extern se::Class* __jsb_cc_gfx_DescriptorSetLayoutInfo_class; - -bool js_register_cc_gfx_DescriptorSetLayoutInfo(se::Object* obj); -bool register_all_gfx(se::Object* obj); - -template<> -bool sevalue_to_native(const se::Value &, cc::gfx::DescriptorSetLayoutInfo *, se::Object *ctx); JSB_REGISTER_OBJECT_TYPE(cc::gfx::DescriptorSetLayoutInfo); - -extern se::Object* __jsb_cc_gfx_DescriptorSetInfo_proto; -extern se::Class* __jsb_cc_gfx_DescriptorSetInfo_class; - -bool js_register_cc_gfx_DescriptorSetInfo(se::Object* obj); -bool register_all_gfx(se::Object* obj); - -template<> -bool sevalue_to_native(const se::Value &, cc::gfx::DescriptorSetInfo *, se::Object *ctx); JSB_REGISTER_OBJECT_TYPE(cc::gfx::DescriptorSetInfo); - -extern se::Object* __jsb_cc_gfx_PipelineLayoutInfo_proto; -extern se::Class* __jsb_cc_gfx_PipelineLayoutInfo_class; - -bool js_register_cc_gfx_PipelineLayoutInfo(se::Object* obj); -bool register_all_gfx(se::Object* obj); - -template<> -bool sevalue_to_native(const se::Value &, cc::gfx::PipelineLayoutInfo *, se::Object *ctx); JSB_REGISTER_OBJECT_TYPE(cc::gfx::PipelineLayoutInfo); - -extern se::Object* __jsb_cc_gfx_InputState_proto; -extern se::Class* __jsb_cc_gfx_InputState_class; - -bool js_register_cc_gfx_InputState(se::Object* obj); -bool register_all_gfx(se::Object* obj); - -template<> -bool sevalue_to_native(const se::Value &, cc::gfx::InputState *, se::Object *ctx); JSB_REGISTER_OBJECT_TYPE(cc::gfx::InputState); - -extern se::Object* __jsb_cc_gfx_RasterizerState_proto; -extern se::Class* __jsb_cc_gfx_RasterizerState_class; - -bool js_register_cc_gfx_RasterizerState(se::Object* obj); -bool register_all_gfx(se::Object* obj); - -template<> -bool sevalue_to_native(const se::Value &, cc::gfx::RasterizerState *, se::Object *ctx); JSB_REGISTER_OBJECT_TYPE(cc::gfx::RasterizerState); - -extern se::Object* __jsb_cc_gfx_DepthStencilState_proto; -extern se::Class* __jsb_cc_gfx_DepthStencilState_class; - -bool js_register_cc_gfx_DepthStencilState(se::Object* obj); -bool register_all_gfx(se::Object* obj); - -template<> -bool sevalue_to_native(const se::Value &, cc::gfx::DepthStencilState *, se::Object *ctx); JSB_REGISTER_OBJECT_TYPE(cc::gfx::DepthStencilState); - -extern se::Object* __jsb_cc_gfx_BlendTarget_proto; -extern se::Class* __jsb_cc_gfx_BlendTarget_class; - -bool js_register_cc_gfx_BlendTarget(se::Object* obj); -bool register_all_gfx(se::Object* obj); - -template<> -bool sevalue_to_native(const se::Value &, cc::gfx::BlendTarget *, se::Object *ctx); JSB_REGISTER_OBJECT_TYPE(cc::gfx::BlendTarget); - -extern se::Object* __jsb_cc_gfx_BlendState_proto; -extern se::Class* __jsb_cc_gfx_BlendState_class; - -bool js_register_cc_gfx_BlendState(se::Object* obj); -bool register_all_gfx(se::Object* obj); - -template<> -bool sevalue_to_native(const se::Value &, cc::gfx::BlendState *, se::Object *ctx); JSB_REGISTER_OBJECT_TYPE(cc::gfx::BlendState); - -extern se::Object* __jsb_cc_gfx_PipelineStateInfo_proto; -extern se::Class* __jsb_cc_gfx_PipelineStateInfo_class; - -bool js_register_cc_gfx_PipelineStateInfo(se::Object* obj); -bool register_all_gfx(se::Object* obj); - -template<> -bool sevalue_to_native(const se::Value &, cc::gfx::PipelineStateInfo *, se::Object *ctx); JSB_REGISTER_OBJECT_TYPE(cc::gfx::PipelineStateInfo); - -extern se::Object* __jsb_cc_gfx_CommandBufferInfo_proto; -extern se::Class* __jsb_cc_gfx_CommandBufferInfo_class; - -bool js_register_cc_gfx_CommandBufferInfo(se::Object* obj); -bool register_all_gfx(se::Object* obj); - -template<> -bool sevalue_to_native(const se::Value &, cc::gfx::CommandBufferInfo *, se::Object *ctx); JSB_REGISTER_OBJECT_TYPE(cc::gfx::CommandBufferInfo); - -extern se::Object* __jsb_cc_gfx_QueueInfo_proto; -extern se::Class* __jsb_cc_gfx_QueueInfo_class; - -bool js_register_cc_gfx_QueueInfo(se::Object* obj); -bool register_all_gfx(se::Object* obj); - -template<> -bool sevalue_to_native(const se::Value &, cc::gfx::QueueInfo *, se::Object *ctx); JSB_REGISTER_OBJECT_TYPE(cc::gfx::QueueInfo); - -extern se::Object* __jsb_cc_gfx_QueryPoolInfo_proto; -extern se::Class* __jsb_cc_gfx_QueryPoolInfo_class; - -bool js_register_cc_gfx_QueryPoolInfo(se::Object* obj); -bool register_all_gfx(se::Object* obj); - -template<> -bool sevalue_to_native(const se::Value &, cc::gfx::QueryPoolInfo *, se::Object *ctx); JSB_REGISTER_OBJECT_TYPE(cc::gfx::QueryPoolInfo); - -extern se::Object* __jsb_cc_gfx_MemoryStatus_proto; -extern se::Class* __jsb_cc_gfx_MemoryStatus_class; - -bool js_register_cc_gfx_MemoryStatus(se::Object* obj); -bool register_all_gfx(se::Object* obj); - -template<> -bool sevalue_to_native(const se::Value &, cc::gfx::MemoryStatus *, se::Object *ctx); JSB_REGISTER_OBJECT_TYPE(cc::gfx::MemoryStatus); - -extern se::Object* __jsb_cc_gfx_GFXObject_proto; -extern se::Class* __jsb_cc_gfx_GFXObject_class; - -bool js_register_cc_gfx_GFXObject(se::Object* obj); -bool register_all_gfx(se::Object* obj); - JSB_REGISTER_OBJECT_TYPE(cc::gfx::GFXObject); +JSB_REGISTER_OBJECT_TYPE(cc::gfx::Buffer); +JSB_REGISTER_OBJECT_TYPE(cc::gfx::InputAssembler); +JSB_REGISTER_OBJECT_TYPE(cc::gfx::CommandBuffer); +JSB_REGISTER_OBJECT_TYPE(cc::gfx::DescriptorSet); +JSB_REGISTER_OBJECT_TYPE(cc::gfx::DescriptorSetLayout); +JSB_REGISTER_OBJECT_TYPE(cc::gfx::Framebuffer); +JSB_REGISTER_OBJECT_TYPE(cc::gfx::PipelineLayout); +JSB_REGISTER_OBJECT_TYPE(cc::gfx::PipelineState); +JSB_REGISTER_OBJECT_TYPE(cc::gfx::QueryPool); +JSB_REGISTER_OBJECT_TYPE(cc::gfx::Queue); +JSB_REGISTER_OBJECT_TYPE(cc::gfx::RenderPass); +JSB_REGISTER_OBJECT_TYPE(cc::gfx::Shader); +JSB_REGISTER_OBJECT_TYPE(cc::gfx::Texture); +JSB_REGISTER_OBJECT_TYPE(cc::gfx::Swapchain); +JSB_REGISTER_OBJECT_TYPE(cc::gfx::GlobalBarrier); +JSB_REGISTER_OBJECT_TYPE(cc::gfx::Sampler); +JSB_REGISTER_OBJECT_TYPE(cc::gfx::TextureBarrier); +JSB_REGISTER_OBJECT_TYPE(cc::gfx::Device); +JSB_REGISTER_OBJECT_TYPE(cc::gfx::DeviceManager); + + +extern se::Object *__jsb_cc_gfx_Size_proto; // NOLINT +extern se::Class * __jsb_cc_gfx_Size_class; // NOLINT + +bool js_register_cc_gfx_Size(se::Object *obj); // NOLINT + +template <> +bool sevalue_to_native(const se::Value &, cc::gfx::Size *, se::Object *ctx); //NOLINT + +extern se::Object *__jsb_cc_gfx_DeviceCaps_proto; // NOLINT +extern se::Class * __jsb_cc_gfx_DeviceCaps_class; // NOLINT + +bool js_register_cc_gfx_DeviceCaps(se::Object *obj); // NOLINT + +template <> +bool sevalue_to_native(const se::Value &, cc::gfx::DeviceCaps *, se::Object *ctx); //NOLINT + +extern se::Object *__jsb_cc_gfx_Offset_proto; // NOLINT +extern se::Class * __jsb_cc_gfx_Offset_class; // NOLINT + +bool js_register_cc_gfx_Offset(se::Object *obj); // NOLINT + +template <> +bool sevalue_to_native(const se::Value &, cc::gfx::Offset *, se::Object *ctx); //NOLINT + +extern se::Object *__jsb_cc_gfx_Rect_proto; // NOLINT +extern se::Class * __jsb_cc_gfx_Rect_class; // NOLINT + +bool js_register_cc_gfx_Rect(se::Object *obj); // NOLINT + +template <> +bool sevalue_to_native(const se::Value &, cc::gfx::Rect *, se::Object *ctx); //NOLINT + +extern se::Object *__jsb_cc_gfx_Extent_proto; // NOLINT +extern se::Class * __jsb_cc_gfx_Extent_class; // NOLINT + +bool js_register_cc_gfx_Extent(se::Object *obj); // NOLINT + +template <> +bool sevalue_to_native(const se::Value &, cc::gfx::Extent *, se::Object *ctx); //NOLINT + +extern se::Object *__jsb_cc_gfx_TextureSubresLayers_proto; // NOLINT +extern se::Class * __jsb_cc_gfx_TextureSubresLayers_class; // NOLINT + +bool js_register_cc_gfx_TextureSubresLayers(se::Object *obj); // NOLINT + +template <> +bool sevalue_to_native(const se::Value &, cc::gfx::TextureSubresLayers *, se::Object *ctx); //NOLINT + +extern se::Object *__jsb_cc_gfx_TextureSubresRange_proto; // NOLINT +extern se::Class * __jsb_cc_gfx_TextureSubresRange_class; // NOLINT + +bool js_register_cc_gfx_TextureSubresRange(se::Object *obj); // NOLINT + +template <> +bool sevalue_to_native(const se::Value &, cc::gfx::TextureSubresRange *, se::Object *ctx); //NOLINT + +extern se::Object *__jsb_cc_gfx_TextureCopy_proto; // NOLINT +extern se::Class * __jsb_cc_gfx_TextureCopy_class; // NOLINT + +bool js_register_cc_gfx_TextureCopy(se::Object *obj); // NOLINT + +template <> +bool sevalue_to_native(const se::Value &, cc::gfx::TextureCopy *, se::Object *ctx); //NOLINT + +extern se::Object *__jsb_cc_gfx_TextureBlit_proto; // NOLINT +extern se::Class * __jsb_cc_gfx_TextureBlit_class; // NOLINT + +bool js_register_cc_gfx_TextureBlit(se::Object *obj); // NOLINT + +template <> +bool sevalue_to_native(const se::Value &, cc::gfx::TextureBlit *, se::Object *ctx); //NOLINT + +extern se::Object *__jsb_cc_gfx_BufferTextureCopy_proto; // NOLINT +extern se::Class * __jsb_cc_gfx_BufferTextureCopy_class; // NOLINT + +bool js_register_cc_gfx_BufferTextureCopy(se::Object *obj); // NOLINT + +template <> +bool sevalue_to_native(const se::Value &, cc::gfx::BufferTextureCopy *, se::Object *ctx); //NOLINT + +extern se::Object *__jsb_cc_gfx_Viewport_proto; // NOLINT +extern se::Class * __jsb_cc_gfx_Viewport_class; // NOLINT + +bool js_register_cc_gfx_Viewport(se::Object *obj); // NOLINT + +template <> +bool sevalue_to_native(const se::Value &, cc::gfx::Viewport *, se::Object *ctx); //NOLINT + +extern se::Object *__jsb_cc_gfx_Color_proto; // NOLINT +extern se::Class * __jsb_cc_gfx_Color_class; // NOLINT + +bool js_register_cc_gfx_Color(se::Object *obj); // NOLINT + +template <> +bool sevalue_to_native(const se::Value &, cc::gfx::Color *, se::Object *ctx); //NOLINT + +extern se::Object *__jsb_cc_gfx_BindingMappingInfo_proto; // NOLINT +extern se::Class * __jsb_cc_gfx_BindingMappingInfo_class; // NOLINT + +bool js_register_cc_gfx_BindingMappingInfo(se::Object *obj); // NOLINT + +template <> +bool sevalue_to_native(const se::Value &, cc::gfx::BindingMappingInfo *, se::Object *ctx); //NOLINT + +extern se::Object *__jsb_cc_gfx_SwapchainInfo_proto; // NOLINT +extern se::Class * __jsb_cc_gfx_SwapchainInfo_class; // NOLINT + +bool js_register_cc_gfx_SwapchainInfo(se::Object *obj); // NOLINT + +template <> +bool sevalue_to_native(const se::Value &, cc::gfx::SwapchainInfo *, se::Object *ctx); //NOLINT + +extern se::Object *__jsb_cc_gfx_DeviceInfo_proto; // NOLINT +extern se::Class * __jsb_cc_gfx_DeviceInfo_class; // NOLINT + +bool js_register_cc_gfx_DeviceInfo(se::Object *obj); // NOLINT + +template <> +bool sevalue_to_native(const se::Value &, cc::gfx::DeviceInfo *, se::Object *ctx); //NOLINT + +extern se::Object *__jsb_cc_gfx_BufferInfo_proto; // NOLINT +extern se::Class * __jsb_cc_gfx_BufferInfo_class; // NOLINT + +bool js_register_cc_gfx_BufferInfo(se::Object *obj); // NOLINT + +template <> +bool sevalue_to_native(const se::Value &, cc::gfx::BufferInfo *, se::Object *ctx); //NOLINT + +extern se::Object *__jsb_cc_gfx_BufferViewInfo_proto; // NOLINT +extern se::Class * __jsb_cc_gfx_BufferViewInfo_class; // NOLINT + +bool js_register_cc_gfx_BufferViewInfo(se::Object *obj); // NOLINT + +template <> +bool sevalue_to_native(const se::Value &, cc::gfx::BufferViewInfo *, se::Object *ctx); //NOLINT + +extern se::Object *__jsb_cc_gfx_DrawInfo_proto; // NOLINT +extern se::Class * __jsb_cc_gfx_DrawInfo_class; // NOLINT + +bool js_register_cc_gfx_DrawInfo(se::Object *obj); // NOLINT + +template <> +bool sevalue_to_native(const se::Value &, cc::gfx::DrawInfo *, se::Object *ctx); //NOLINT + +extern se::Object *__jsb_cc_gfx_DispatchInfo_proto; // NOLINT +extern se::Class * __jsb_cc_gfx_DispatchInfo_class; // NOLINT + +bool js_register_cc_gfx_DispatchInfo(se::Object *obj); // NOLINT + +template <> +bool sevalue_to_native(const se::Value &, cc::gfx::DispatchInfo *, se::Object *ctx); //NOLINT + +extern se::Object *__jsb_cc_gfx_IndirectBuffer_proto; // NOLINT +extern se::Class * __jsb_cc_gfx_IndirectBuffer_class; // NOLINT + +bool js_register_cc_gfx_IndirectBuffer(se::Object *obj); // NOLINT + +template <> +bool sevalue_to_native(const se::Value &, cc::gfx::IndirectBuffer *, se::Object *ctx); //NOLINT + +extern se::Object *__jsb_cc_gfx_TextureInfo_proto; // NOLINT +extern se::Class * __jsb_cc_gfx_TextureInfo_class; // NOLINT + +bool js_register_cc_gfx_TextureInfo(se::Object *obj); // NOLINT + +template <> +bool sevalue_to_native(const se::Value &, cc::gfx::TextureInfo *, se::Object *ctx); //NOLINT + +extern se::Object *__jsb_cc_gfx_TextureViewInfo_proto; // NOLINT +extern se::Class * __jsb_cc_gfx_TextureViewInfo_class; // NOLINT + +bool js_register_cc_gfx_TextureViewInfo(se::Object *obj); // NOLINT + +template <> +bool sevalue_to_native(const se::Value &, cc::gfx::TextureViewInfo *, se::Object *ctx); //NOLINT + +extern se::Object *__jsb_cc_gfx_SamplerInfo_proto; // NOLINT +extern se::Class * __jsb_cc_gfx_SamplerInfo_class; // NOLINT + +bool js_register_cc_gfx_SamplerInfo(se::Object *obj); // NOLINT + +template <> +bool sevalue_to_native(const se::Value &, cc::gfx::SamplerInfo *, se::Object *ctx); //NOLINT + +extern se::Object *__jsb_cc_gfx_Uniform_proto; // NOLINT +extern se::Class * __jsb_cc_gfx_Uniform_class; // NOLINT + +bool js_register_cc_gfx_Uniform(se::Object *obj); // NOLINT + +template <> +bool sevalue_to_native(const se::Value &, cc::gfx::Uniform *, se::Object *ctx); //NOLINT + +extern se::Object *__jsb_cc_gfx_UniformBlock_proto; // NOLINT +extern se::Class * __jsb_cc_gfx_UniformBlock_class; // NOLINT + +bool js_register_cc_gfx_UniformBlock(se::Object *obj); // NOLINT + +template <> +bool sevalue_to_native(const se::Value &, cc::gfx::UniformBlock *, se::Object *ctx); //NOLINT + +extern se::Object *__jsb_cc_gfx_UniformSamplerTexture_proto; // NOLINT +extern se::Class * __jsb_cc_gfx_UniformSamplerTexture_class; // NOLINT + +bool js_register_cc_gfx_UniformSamplerTexture(se::Object *obj); // NOLINT + +template <> +bool sevalue_to_native(const se::Value &, cc::gfx::UniformSamplerTexture *, se::Object *ctx); //NOLINT + +extern se::Object *__jsb_cc_gfx_UniformSampler_proto; // NOLINT +extern se::Class * __jsb_cc_gfx_UniformSampler_class; // NOLINT + +bool js_register_cc_gfx_UniformSampler(se::Object *obj); // NOLINT + +template <> +bool sevalue_to_native(const se::Value &, cc::gfx::UniformSampler *, se::Object *ctx); //NOLINT + +extern se::Object *__jsb_cc_gfx_UniformTexture_proto; // NOLINT +extern se::Class * __jsb_cc_gfx_UniformTexture_class; // NOLINT + +bool js_register_cc_gfx_UniformTexture(se::Object *obj); // NOLINT + +template <> +bool sevalue_to_native(const se::Value &, cc::gfx::UniformTexture *, se::Object *ctx); //NOLINT + +extern se::Object *__jsb_cc_gfx_UniformStorageImage_proto; // NOLINT +extern se::Class * __jsb_cc_gfx_UniformStorageImage_class; // NOLINT + +bool js_register_cc_gfx_UniformStorageImage(se::Object *obj); // NOLINT + +template <> +bool sevalue_to_native(const se::Value &, cc::gfx::UniformStorageImage *, se::Object *ctx); //NOLINT + +extern se::Object *__jsb_cc_gfx_UniformStorageBuffer_proto; // NOLINT +extern se::Class * __jsb_cc_gfx_UniformStorageBuffer_class; // NOLINT + +bool js_register_cc_gfx_UniformStorageBuffer(se::Object *obj); // NOLINT + +template <> +bool sevalue_to_native(const se::Value &, cc::gfx::UniformStorageBuffer *, se::Object *ctx); //NOLINT + +extern se::Object *__jsb_cc_gfx_UniformInputAttachment_proto; // NOLINT +extern se::Class * __jsb_cc_gfx_UniformInputAttachment_class; // NOLINT + +bool js_register_cc_gfx_UniformInputAttachment(se::Object *obj); // NOLINT + +template <> +bool sevalue_to_native(const se::Value &, cc::gfx::UniformInputAttachment *, se::Object *ctx); //NOLINT + +extern se::Object *__jsb_cc_gfx_ShaderStage_proto; // NOLINT +extern se::Class * __jsb_cc_gfx_ShaderStage_class; // NOLINT + +bool js_register_cc_gfx_ShaderStage(se::Object *obj); // NOLINT + +template <> +bool sevalue_to_native(const se::Value &, cc::gfx::ShaderStage *, se::Object *ctx); //NOLINT + +extern se::Object *__jsb_cc_gfx_Attribute_proto; // NOLINT +extern se::Class * __jsb_cc_gfx_Attribute_class; // NOLINT + +bool js_register_cc_gfx_Attribute(se::Object *obj); // NOLINT + +template <> +bool sevalue_to_native(const se::Value &, cc::gfx::Attribute *, se::Object *ctx); //NOLINT + +extern se::Object *__jsb_cc_gfx_ShaderInfo_proto; // NOLINT +extern se::Class * __jsb_cc_gfx_ShaderInfo_class; // NOLINT + +bool js_register_cc_gfx_ShaderInfo(se::Object *obj); // NOLINT + +template <> +bool sevalue_to_native(const se::Value &, cc::gfx::ShaderInfo *, se::Object *ctx); //NOLINT + +extern se::Object *__jsb_cc_gfx_InputAssemblerInfo_proto; // NOLINT +extern se::Class * __jsb_cc_gfx_InputAssemblerInfo_class; // NOLINT + +bool js_register_cc_gfx_InputAssemblerInfo(se::Object *obj); // NOLINT + +template <> +bool sevalue_to_native(const se::Value &, cc::gfx::InputAssemblerInfo *, se::Object *ctx); //NOLINT + +extern se::Object *__jsb_cc_gfx_ColorAttachment_proto; // NOLINT +extern se::Class * __jsb_cc_gfx_ColorAttachment_class; // NOLINT + +bool js_register_cc_gfx_ColorAttachment(se::Object *obj); // NOLINT + +template <> +bool sevalue_to_native(const se::Value &, cc::gfx::ColorAttachment *, se::Object *ctx); //NOLINT + +extern se::Object *__jsb_cc_gfx_DepthStencilAttachment_proto; // NOLINT +extern se::Class * __jsb_cc_gfx_DepthStencilAttachment_class; // NOLINT + +bool js_register_cc_gfx_DepthStencilAttachment(se::Object *obj); // NOLINT + +template <> +bool sevalue_to_native(const se::Value &, cc::gfx::DepthStencilAttachment *, se::Object *ctx); //NOLINT + +extern se::Object *__jsb_cc_gfx_SubpassInfo_proto; // NOLINT +extern se::Class * __jsb_cc_gfx_SubpassInfo_class; // NOLINT + +bool js_register_cc_gfx_SubpassInfo(se::Object *obj); // NOLINT + +template <> +bool sevalue_to_native(const se::Value &, cc::gfx::SubpassInfo *, se::Object *ctx); //NOLINT + +extern se::Object *__jsb_cc_gfx_SubpassDependency_proto; // NOLINT +extern se::Class * __jsb_cc_gfx_SubpassDependency_class; // NOLINT + +bool js_register_cc_gfx_SubpassDependency(se::Object *obj); // NOLINT + +template <> +bool sevalue_to_native(const se::Value &, cc::gfx::SubpassDependency *, se::Object *ctx); //NOLINT + +extern se::Object *__jsb_cc_gfx_RenderPassInfo_proto; // NOLINT +extern se::Class * __jsb_cc_gfx_RenderPassInfo_class; // NOLINT + +bool js_register_cc_gfx_RenderPassInfo(se::Object *obj); // NOLINT + +template <> +bool sevalue_to_native(const se::Value &, cc::gfx::RenderPassInfo *, se::Object *ctx); //NOLINT + +extern se::Object *__jsb_cc_gfx_GlobalBarrierInfo_proto; // NOLINT +extern se::Class * __jsb_cc_gfx_GlobalBarrierInfo_class; // NOLINT + +bool js_register_cc_gfx_GlobalBarrierInfo(se::Object *obj); // NOLINT + +template <> +bool sevalue_to_native(const se::Value &, cc::gfx::GlobalBarrierInfo *, se::Object *ctx); //NOLINT + +extern se::Object *__jsb_cc_gfx_TextureBarrierInfo_proto; // NOLINT +extern se::Class * __jsb_cc_gfx_TextureBarrierInfo_class; // NOLINT + +bool js_register_cc_gfx_TextureBarrierInfo(se::Object *obj); // NOLINT + +template <> +bool sevalue_to_native(const se::Value &, cc::gfx::TextureBarrierInfo *, se::Object *ctx); //NOLINT + +extern se::Object *__jsb_cc_gfx_FramebufferInfo_proto; // NOLINT +extern se::Class * __jsb_cc_gfx_FramebufferInfo_class; // NOLINT + +bool js_register_cc_gfx_FramebufferInfo(se::Object *obj); // NOLINT + +template <> +bool sevalue_to_native(const se::Value &, cc::gfx::FramebufferInfo *, se::Object *ctx); //NOLINT + +extern se::Object *__jsb_cc_gfx_DescriptorSetLayoutBinding_proto; // NOLINT +extern se::Class * __jsb_cc_gfx_DescriptorSetLayoutBinding_class; // NOLINT + +bool js_register_cc_gfx_DescriptorSetLayoutBinding(se::Object *obj); // NOLINT + +template <> +bool sevalue_to_native(const se::Value &, cc::gfx::DescriptorSetLayoutBinding *, se::Object *ctx); //NOLINT + +extern se::Object *__jsb_cc_gfx_DescriptorSetLayoutInfo_proto; // NOLINT +extern se::Class * __jsb_cc_gfx_DescriptorSetLayoutInfo_class; // NOLINT + +bool js_register_cc_gfx_DescriptorSetLayoutInfo(se::Object *obj); // NOLINT + +template <> +bool sevalue_to_native(const se::Value &, cc::gfx::DescriptorSetLayoutInfo *, se::Object *ctx); //NOLINT + +extern se::Object *__jsb_cc_gfx_DescriptorSetInfo_proto; // NOLINT +extern se::Class * __jsb_cc_gfx_DescriptorSetInfo_class; // NOLINT + +bool js_register_cc_gfx_DescriptorSetInfo(se::Object *obj); // NOLINT + +template <> +bool sevalue_to_native(const se::Value &, cc::gfx::DescriptorSetInfo *, se::Object *ctx); //NOLINT + +extern se::Object *__jsb_cc_gfx_PipelineLayoutInfo_proto; // NOLINT +extern se::Class * __jsb_cc_gfx_PipelineLayoutInfo_class; // NOLINT + +bool js_register_cc_gfx_PipelineLayoutInfo(se::Object *obj); // NOLINT + +template <> +bool sevalue_to_native(const se::Value &, cc::gfx::PipelineLayoutInfo *, se::Object *ctx); //NOLINT + +extern se::Object *__jsb_cc_gfx_InputState_proto; // NOLINT +extern se::Class * __jsb_cc_gfx_InputState_class; // NOLINT + +bool js_register_cc_gfx_InputState(se::Object *obj); // NOLINT + +template <> +bool sevalue_to_native(const se::Value &, cc::gfx::InputState *, se::Object *ctx); //NOLINT + +extern se::Object *__jsb_cc_gfx_RasterizerState_proto; // NOLINT +extern se::Class * __jsb_cc_gfx_RasterizerState_class; // NOLINT + +bool js_register_cc_gfx_RasterizerState(se::Object *obj); // NOLINT + +template <> +bool sevalue_to_native(const se::Value &, cc::gfx::RasterizerState *, se::Object *ctx); //NOLINT +SE_DECLARE_FUNC(js_gfx_RasterizerState_reset); + +extern se::Object *__jsb_cc_gfx_DepthStencilState_proto; // NOLINT +extern se::Class * __jsb_cc_gfx_DepthStencilState_class; // NOLINT + +bool js_register_cc_gfx_DepthStencilState(se::Object *obj); // NOLINT + +template <> +bool sevalue_to_native(const se::Value &, cc::gfx::DepthStencilState *, se::Object *ctx); //NOLINT +SE_DECLARE_FUNC(js_gfx_DepthStencilState_reset); + +extern se::Object *__jsb_cc_gfx_BlendTarget_proto; // NOLINT +extern se::Class * __jsb_cc_gfx_BlendTarget_class; // NOLINT + +bool js_register_cc_gfx_BlendTarget(se::Object *obj); // NOLINT + +template <> +bool sevalue_to_native(const se::Value &, cc::gfx::BlendTarget *, se::Object *ctx); //NOLINT + +extern se::Object *__jsb_cc_gfx_BlendState_proto; // NOLINT +extern se::Class * __jsb_cc_gfx_BlendState_class; // NOLINT + +bool js_register_cc_gfx_BlendState(se::Object *obj); // NOLINT + +template <> +bool sevalue_to_native(const se::Value &, cc::gfx::BlendState *, se::Object *ctx); //NOLINT +SE_DECLARE_FUNC(js_gfx_BlendState_destroy); +SE_DECLARE_FUNC(js_gfx_BlendState_reset); +SE_DECLARE_FUNC(js_gfx_BlendState_setTarget); + +extern se::Object *__jsb_cc_gfx_PipelineStateInfo_proto; // NOLINT +extern se::Class * __jsb_cc_gfx_PipelineStateInfo_class; // NOLINT + +bool js_register_cc_gfx_PipelineStateInfo(se::Object *obj); // NOLINT + +template <> +bool sevalue_to_native(const se::Value &, cc::gfx::PipelineStateInfo *, se::Object *ctx); //NOLINT + +extern se::Object *__jsb_cc_gfx_CommandBufferInfo_proto; // NOLINT +extern se::Class * __jsb_cc_gfx_CommandBufferInfo_class; // NOLINT + +bool js_register_cc_gfx_CommandBufferInfo(se::Object *obj); // NOLINT + +template <> +bool sevalue_to_native(const se::Value &, cc::gfx::CommandBufferInfo *, se::Object *ctx); //NOLINT + +extern se::Object *__jsb_cc_gfx_QueueInfo_proto; // NOLINT +extern se::Class * __jsb_cc_gfx_QueueInfo_class; // NOLINT + +bool js_register_cc_gfx_QueueInfo(se::Object *obj); // NOLINT + +template <> +bool sevalue_to_native(const se::Value &, cc::gfx::QueueInfo *, se::Object *ctx); //NOLINT + +extern se::Object *__jsb_cc_gfx_QueryPoolInfo_proto; // NOLINT +extern se::Class * __jsb_cc_gfx_QueryPoolInfo_class; // NOLINT + +bool js_register_cc_gfx_QueryPoolInfo(se::Object *obj); // NOLINT + +template <> +bool sevalue_to_native(const se::Value &, cc::gfx::QueryPoolInfo *, se::Object *ctx); //NOLINT + +extern se::Object *__jsb_cc_gfx_MemoryStatus_proto; // NOLINT +extern se::Class * __jsb_cc_gfx_MemoryStatus_class; // NOLINT + +bool js_register_cc_gfx_MemoryStatus(se::Object *obj); // NOLINT + +template <> +bool sevalue_to_native(const se::Value &, cc::gfx::MemoryStatus *, se::Object *ctx); //NOLINT + +extern se::Object *__jsb_cc_gfx_GFXObject_proto; // NOLINT +extern se::Class * __jsb_cc_gfx_GFXObject_class; // NOLINT + +bool js_register_cc_gfx_GFXObject(se::Object *obj); // NOLINT + SE_DECLARE_FUNC(js_gfx_GFXObject_GFXObject); -extern se::Object* __jsb_cc_gfx_Buffer_proto; -extern se::Class* __jsb_cc_gfx_Buffer_class; +extern se::Object *__jsb_cc_gfx_Buffer_proto; // NOLINT +extern se::Class * __jsb_cc_gfx_Buffer_class; // NOLINT -bool js_register_cc_gfx_Buffer(se::Object* obj); -bool register_all_gfx(se::Object* obj); +bool js_register_cc_gfx_Buffer(se::Object *obj); // NOLINT -JSB_REGISTER_OBJECT_TYPE(cc::gfx::Buffer); SE_DECLARE_FUNC(js_gfx_Buffer_destroy); SE_DECLARE_FUNC(js_gfx_Buffer_isBufferView); SE_DECLARE_FUNC(js_gfx_Buffer_resize); SE_DECLARE_FUNC(js_gfx_Buffer_computeHash); SE_DECLARE_FUNC(js_gfx_Buffer_Buffer); -extern se::Object* __jsb_cc_gfx_InputAssembler_proto; -extern se::Class* __jsb_cc_gfx_InputAssembler_class; +extern se::Object *__jsb_cc_gfx_InputAssembler_proto; // NOLINT +extern se::Class * __jsb_cc_gfx_InputAssembler_class; // NOLINT -bool js_register_cc_gfx_InputAssembler(se::Object* obj); -bool register_all_gfx(se::Object* obj); +bool js_register_cc_gfx_InputAssembler(se::Object *obj); // NOLINT -JSB_REGISTER_OBJECT_TYPE(cc::gfx::InputAssembler); SE_DECLARE_FUNC(js_gfx_InputAssembler_destroy); SE_DECLARE_FUNC(js_gfx_InputAssembler_initialize); SE_DECLARE_FUNC(js_gfx_InputAssembler_InputAssembler); -extern se::Object* __jsb_cc_gfx_CommandBuffer_proto; -extern se::Class* __jsb_cc_gfx_CommandBuffer_class; +extern se::Object *__jsb_cc_gfx_CommandBuffer_proto; // NOLINT +extern se::Class * __jsb_cc_gfx_CommandBuffer_class; // NOLINT -bool js_register_cc_gfx_CommandBuffer(se::Object* obj); -bool register_all_gfx(se::Object* obj); +bool js_register_cc_gfx_CommandBuffer(se::Object *obj); // NOLINT -JSB_REGISTER_OBJECT_TYPE(cc::gfx::CommandBuffer); SE_DECLARE_FUNC(js_gfx_CommandBuffer_begin); SE_DECLARE_FUNC(js_gfx_CommandBuffer_beginQuery); SE_DECLARE_FUNC(js_gfx_CommandBuffer_beginRenderPass); @@ -648,13 +613,11 @@ SE_DECLARE_FUNC(js_gfx_CommandBuffer_setStencilWriteMask); SE_DECLARE_FUNC(js_gfx_CommandBuffer_setViewport); SE_DECLARE_FUNC(js_gfx_CommandBuffer_CommandBuffer); -extern se::Object* __jsb_cc_gfx_DescriptorSet_proto; -extern se::Class* __jsb_cc_gfx_DescriptorSet_class; +extern se::Object *__jsb_cc_gfx_DescriptorSet_proto; // NOLINT +extern se::Class * __jsb_cc_gfx_DescriptorSet_class; // NOLINT -bool js_register_cc_gfx_DescriptorSet(se::Object* obj); -bool register_all_gfx(se::Object* obj); +bool js_register_cc_gfx_DescriptorSet(se::Object *obj); // NOLINT -JSB_REGISTER_OBJECT_TYPE(cc::gfx::DescriptorSet); SE_DECLARE_FUNC(js_gfx_DescriptorSet_bindBuffer); SE_DECLARE_FUNC(js_gfx_DescriptorSet_bindBufferJSB); SE_DECLARE_FUNC(js_gfx_DescriptorSet_bindSampler); @@ -669,13 +632,11 @@ SE_DECLARE_FUNC(js_gfx_DescriptorSet_initialize); SE_DECLARE_FUNC(js_gfx_DescriptorSet_update); SE_DECLARE_FUNC(js_gfx_DescriptorSet_DescriptorSet); -extern se::Object* __jsb_cc_gfx_DescriptorSetLayout_proto; -extern se::Class* __jsb_cc_gfx_DescriptorSetLayout_class; +extern se::Object *__jsb_cc_gfx_DescriptorSetLayout_proto; // NOLINT +extern se::Class * __jsb_cc_gfx_DescriptorSetLayout_class; // NOLINT -bool js_register_cc_gfx_DescriptorSetLayout(se::Object* obj); -bool register_all_gfx(se::Object* obj); +bool js_register_cc_gfx_DescriptorSetLayout(se::Object *obj); // NOLINT -JSB_REGISTER_OBJECT_TYPE(cc::gfx::DescriptorSetLayout); SE_DECLARE_FUNC(js_gfx_DescriptorSetLayout_destroy); SE_DECLARE_FUNC(js_gfx_DescriptorSetLayout_getBindings); SE_DECLARE_FUNC(js_gfx_DescriptorSetLayout_getDescriptorCount); @@ -683,50 +644,42 @@ SE_DECLARE_FUNC(js_gfx_DescriptorSetLayout_getDynamicBindings); SE_DECLARE_FUNC(js_gfx_DescriptorSetLayout_initialize); SE_DECLARE_FUNC(js_gfx_DescriptorSetLayout_DescriptorSetLayout); -extern se::Object* __jsb_cc_gfx_Framebuffer_proto; -extern se::Class* __jsb_cc_gfx_Framebuffer_class; +extern se::Object *__jsb_cc_gfx_Framebuffer_proto; // NOLINT +extern se::Class * __jsb_cc_gfx_Framebuffer_class; // NOLINT -bool js_register_cc_gfx_Framebuffer(se::Object* obj); -bool register_all_gfx(se::Object* obj); +bool js_register_cc_gfx_Framebuffer(se::Object *obj); // NOLINT -JSB_REGISTER_OBJECT_TYPE(cc::gfx::Framebuffer); SE_DECLARE_FUNC(js_gfx_Framebuffer_destroy); SE_DECLARE_FUNC(js_gfx_Framebuffer_initialize); SE_DECLARE_FUNC(js_gfx_Framebuffer_computeHash); SE_DECLARE_FUNC(js_gfx_Framebuffer_Framebuffer); -extern se::Object* __jsb_cc_gfx_PipelineLayout_proto; -extern se::Class* __jsb_cc_gfx_PipelineLayout_class; +extern se::Object *__jsb_cc_gfx_PipelineLayout_proto; // NOLINT +extern se::Class * __jsb_cc_gfx_PipelineLayout_class; // NOLINT -bool js_register_cc_gfx_PipelineLayout(se::Object* obj); -bool register_all_gfx(se::Object* obj); +bool js_register_cc_gfx_PipelineLayout(se::Object *obj); // NOLINT -JSB_REGISTER_OBJECT_TYPE(cc::gfx::PipelineLayout); SE_DECLARE_FUNC(js_gfx_PipelineLayout_destroy); SE_DECLARE_FUNC(js_gfx_PipelineLayout_getSetLayouts); SE_DECLARE_FUNC(js_gfx_PipelineLayout_initialize); SE_DECLARE_FUNC(js_gfx_PipelineLayout_PipelineLayout); -extern se::Object* __jsb_cc_gfx_PipelineState_proto; -extern se::Class* __jsb_cc_gfx_PipelineState_class; +extern se::Object *__jsb_cc_gfx_PipelineState_proto; // NOLINT +extern se::Class * __jsb_cc_gfx_PipelineState_class; // NOLINT -bool js_register_cc_gfx_PipelineState(se::Object* obj); -bool register_all_gfx(se::Object* obj); +bool js_register_cc_gfx_PipelineState(se::Object *obj); // NOLINT -JSB_REGISTER_OBJECT_TYPE(cc::gfx::PipelineState); SE_DECLARE_FUNC(js_gfx_PipelineState_destroy); SE_DECLARE_FUNC(js_gfx_PipelineState_getDynamicStates); SE_DECLARE_FUNC(js_gfx_PipelineState_getPipelineLayout); SE_DECLARE_FUNC(js_gfx_PipelineState_initialize); SE_DECLARE_FUNC(js_gfx_PipelineState_PipelineState); -extern se::Object* __jsb_cc_gfx_QueryPool_proto; -extern se::Class* __jsb_cc_gfx_QueryPool_class; +extern se::Object *__jsb_cc_gfx_QueryPool_proto; // NOLINT +extern se::Class * __jsb_cc_gfx_QueryPool_class; // NOLINT -bool js_register_cc_gfx_QueryPool(se::Object* obj); -bool register_all_gfx(se::Object* obj); +bool js_register_cc_gfx_QueryPool(se::Object *obj); // NOLINT -JSB_REGISTER_OBJECT_TYPE(cc::gfx::QueryPool); SE_DECLARE_FUNC(js_gfx_QueryPool_destroy); SE_DECLARE_FUNC(js_gfx_QueryPool_getForceWait); SE_DECLARE_FUNC(js_gfx_QueryPool_getMaxQueryObjects); @@ -736,25 +689,21 @@ SE_DECLARE_FUNC(js_gfx_QueryPool_hasResult); SE_DECLARE_FUNC(js_gfx_QueryPool_initialize); SE_DECLARE_FUNC(js_gfx_QueryPool_QueryPool); -extern se::Object* __jsb_cc_gfx_Queue_proto; -extern se::Class* __jsb_cc_gfx_Queue_class; +extern se::Object *__jsb_cc_gfx_Queue_proto; // NOLINT +extern se::Class * __jsb_cc_gfx_Queue_class; // NOLINT -bool js_register_cc_gfx_Queue(se::Object* obj); -bool register_all_gfx(se::Object* obj); +bool js_register_cc_gfx_Queue(se::Object *obj); // NOLINT -JSB_REGISTER_OBJECT_TYPE(cc::gfx::Queue); SE_DECLARE_FUNC(js_gfx_Queue_destroy); SE_DECLARE_FUNC(js_gfx_Queue_initialize); SE_DECLARE_FUNC(js_gfx_Queue_submit); SE_DECLARE_FUNC(js_gfx_Queue_Queue); -extern se::Object* __jsb_cc_gfx_RenderPass_proto; -extern se::Class* __jsb_cc_gfx_RenderPass_class; +extern se::Object *__jsb_cc_gfx_RenderPass_proto; // NOLINT +extern se::Class * __jsb_cc_gfx_RenderPass_class; // NOLINT -bool js_register_cc_gfx_RenderPass(se::Object* obj); -bool register_all_gfx(se::Object* obj); +bool js_register_cc_gfx_RenderPass(se::Object *obj); // NOLINT -JSB_REGISTER_OBJECT_TYPE(cc::gfx::RenderPass); SE_DECLARE_FUNC(js_gfx_RenderPass_destroy); SE_DECLARE_FUNC(js_gfx_RenderPass_getDependencies); SE_DECLARE_FUNC(js_gfx_RenderPass_getDepthStencilAttachment); @@ -763,13 +712,11 @@ SE_DECLARE_FUNC(js_gfx_RenderPass_initialize); SE_DECLARE_FUNC(js_gfx_RenderPass_computeHash); SE_DECLARE_FUNC(js_gfx_RenderPass_RenderPass); -extern se::Object* __jsb_cc_gfx_Shader_proto; -extern se::Class* __jsb_cc_gfx_Shader_class; +extern se::Object *__jsb_cc_gfx_Shader_proto; // NOLINT +extern se::Class * __jsb_cc_gfx_Shader_class; // NOLINT -bool js_register_cc_gfx_Shader(se::Object* obj); -bool register_all_gfx(se::Object* obj); +bool js_register_cc_gfx_Shader(se::Object *obj); // NOLINT -JSB_REGISTER_OBJECT_TYPE(cc::gfx::Shader); SE_DECLARE_FUNC(js_gfx_Shader_destroy); SE_DECLARE_FUNC(js_gfx_Shader_getBuffers); SE_DECLARE_FUNC(js_gfx_Shader_getImages); @@ -779,26 +726,22 @@ SE_DECLARE_FUNC(js_gfx_Shader_getTextures); SE_DECLARE_FUNC(js_gfx_Shader_initialize); SE_DECLARE_FUNC(js_gfx_Shader_Shader); -extern se::Object* __jsb_cc_gfx_Texture_proto; -extern se::Class* __jsb_cc_gfx_Texture_class; +extern se::Object *__jsb_cc_gfx_Texture_proto; // NOLINT +extern se::Class * __jsb_cc_gfx_Texture_class; // NOLINT -bool js_register_cc_gfx_Texture(se::Object* obj); -bool register_all_gfx(se::Object* obj); +bool js_register_cc_gfx_Texture(se::Object *obj); // NOLINT -JSB_REGISTER_OBJECT_TYPE(cc::gfx::Texture); SE_DECLARE_FUNC(js_gfx_Texture_destroy); SE_DECLARE_FUNC(js_gfx_Texture_isTextureView); SE_DECLARE_FUNC(js_gfx_Texture_resize); SE_DECLARE_FUNC(js_gfx_Texture_computeHash); SE_DECLARE_FUNC(js_gfx_Texture_Texture); -extern se::Object* __jsb_cc_gfx_Swapchain_proto; -extern se::Class* __jsb_cc_gfx_Swapchain_class; +extern se::Object *__jsb_cc_gfx_Swapchain_proto; // NOLINT +extern se::Class * __jsb_cc_gfx_Swapchain_class; // NOLINT -bool js_register_cc_gfx_Swapchain(se::Object* obj); -bool register_all_gfx(se::Object* obj); +bool js_register_cc_gfx_Swapchain(se::Object *obj); // NOLINT -JSB_REGISTER_OBJECT_TYPE(cc::gfx::Swapchain); SE_DECLARE_FUNC(js_gfx_Swapchain_createSurface); SE_DECLARE_FUNC(js_gfx_Swapchain_destroy); SE_DECLARE_FUNC(js_gfx_Swapchain_destroySurface); @@ -808,48 +751,41 @@ SE_DECLARE_FUNC(js_gfx_Swapchain_initialize); SE_DECLARE_FUNC(js_gfx_Swapchain_resize); SE_DECLARE_FUNC(js_gfx_Swapchain_Swapchain); -extern se::Object* __jsb_cc_gfx_GlobalBarrier_proto; -extern se::Class* __jsb_cc_gfx_GlobalBarrier_class; +extern se::Object *__jsb_cc_gfx_GlobalBarrier_proto; // NOLINT +extern se::Class * __jsb_cc_gfx_GlobalBarrier_class; // NOLINT -bool js_register_cc_gfx_GlobalBarrier(se::Object* obj); -bool register_all_gfx(se::Object* obj); +bool js_register_cc_gfx_GlobalBarrier(se::Object *obj); // NOLINT -JSB_REGISTER_OBJECT_TYPE(cc::gfx::GlobalBarrier); SE_DECLARE_FUNC(js_gfx_GlobalBarrier_getHash); SE_DECLARE_FUNC(js_gfx_GlobalBarrier_getInfo); SE_DECLARE_FUNC(js_gfx_GlobalBarrier_computeHash); SE_DECLARE_FUNC(js_gfx_GlobalBarrier_GlobalBarrier); -extern se::Object* __jsb_cc_gfx_Sampler_proto; -extern se::Class* __jsb_cc_gfx_Sampler_class; +extern se::Object *__jsb_cc_gfx_Sampler_proto; // NOLINT +extern se::Class * __jsb_cc_gfx_Sampler_class; // NOLINT -bool js_register_cc_gfx_Sampler(se::Object* obj); -bool register_all_gfx(se::Object* obj); +bool js_register_cc_gfx_Sampler(se::Object *obj); // NOLINT -JSB_REGISTER_OBJECT_TYPE(cc::gfx::Sampler); SE_DECLARE_FUNC(js_gfx_Sampler_getHash); SE_DECLARE_FUNC(js_gfx_Sampler_computeHash); +SE_DECLARE_FUNC(js_gfx_Sampler_unpackFromHash); SE_DECLARE_FUNC(js_gfx_Sampler_Sampler); -extern se::Object* __jsb_cc_gfx_TextureBarrier_proto; -extern se::Class* __jsb_cc_gfx_TextureBarrier_class; +extern se::Object *__jsb_cc_gfx_TextureBarrier_proto; // NOLINT +extern se::Class * __jsb_cc_gfx_TextureBarrier_class; // NOLINT -bool js_register_cc_gfx_TextureBarrier(se::Object* obj); -bool register_all_gfx(se::Object* obj); +bool js_register_cc_gfx_TextureBarrier(se::Object *obj); // NOLINT -JSB_REGISTER_OBJECT_TYPE(cc::gfx::TextureBarrier); SE_DECLARE_FUNC(js_gfx_TextureBarrier_getHash); SE_DECLARE_FUNC(js_gfx_TextureBarrier_getInfo); SE_DECLARE_FUNC(js_gfx_TextureBarrier_computeHash); SE_DECLARE_FUNC(js_gfx_TextureBarrier_TextureBarrier); -extern se::Object* __jsb_cc_gfx_Device_proto; -extern se::Class* __jsb_cc_gfx_Device_class; +extern se::Object *__jsb_cc_gfx_Device_proto; // NOLINT +extern se::Class * __jsb_cc_gfx_Device_class; // NOLINT -bool js_register_cc_gfx_Device(se::Object* obj); -bool register_all_gfx(se::Object* obj); +bool js_register_cc_gfx_Device(se::Object *obj); // NOLINT -JSB_REGISTER_OBJECT_TYPE(cc::gfx::Device); SE_DECLARE_FUNC(js_gfx_Device_acquire); SE_DECLARE_FUNC(js_gfx_Device_bindingMappingInfo); SE_DECLARE_FUNC(js_gfx_Device_createCommandBuffer); @@ -875,14 +811,12 @@ SE_DECLARE_FUNC(js_gfx_Device_hasFeature); SE_DECLARE_FUNC(js_gfx_Device_initialize); SE_DECLARE_FUNC(js_gfx_Device_present); -extern se::Object* __jsb_cc_gfx_DeviceManager_proto; -extern se::Class* __jsb_cc_gfx_DeviceManager_class; +extern se::Object *__jsb_cc_gfx_DeviceManager_proto; // NOLINT +extern se::Class * __jsb_cc_gfx_DeviceManager_class; // NOLINT -bool js_register_cc_gfx_DeviceManager(se::Object* obj); -bool register_all_gfx(se::Object* obj); +bool js_register_cc_gfx_DeviceManager(se::Object *obj); // NOLINT -JSB_REGISTER_OBJECT_TYPE(cc::gfx::DeviceManager); +SE_DECLARE_FUNC(js_gfx_DeviceManager_addSurfaceEventListener); SE_DECLARE_FUNC(js_gfx_DeviceManager_create); SE_DECLARE_FUNC(js_gfx_DeviceManager_destroy); -SE_DECLARE_FUNC(js_gfx_DeviceManager_addSurfaceEventListener); - + // clang-format on \ No newline at end of file diff --git a/native/cocos/bindings/auto/jsb_network_auto.cpp b/native/cocos/bindings/auto/jsb_network_auto.cpp index 878bf794a7..eb5ddfa905 100644 --- a/native/cocos/bindings/auto/jsb_network_auto.cpp +++ b/native/cocos/bindings/auto/jsb_network_auto.cpp @@ -1,3 +1,5 @@ + +// clang-format off #include "cocos/bindings/auto/jsb_network_auto.h" #include "cocos/bindings/manual/jsb_conversions.h" #include "cocos/bindings/manual/jsb_global.h" @@ -10,8 +12,8 @@ #ifndef JSB_FREE #define JSB_FREE(ptr) delete ptr #endif -se::Object* __jsb_cc_network_DownloaderHints_proto = nullptr; -se::Class* __jsb_cc_network_DownloaderHints_class = nullptr; +se::Object* __jsb_cc_network_DownloaderHints_proto = nullptr; // NOLINT +se::Class* __jsb_cc_network_DownloaderHints_class = nullptr; // NOLINT static bool js_network_DownloaderHints_get_countOfMaxProcessingTasks(se::State& s) // NOLINT(readability-identifier-naming) { @@ -107,15 +109,15 @@ bool sevalue_to_native(const se::Value &from, cc::network::DownloaderHints * to, } se::Value field; bool ok = true; - json->getProperty("countOfMaxProcessingTasks", &field); + json->getProperty("countOfMaxProcessingTasks", &field, true); if(!field.isNullOrUndefined()) { ok &= sevalue_to_native(field, &(to->countOfMaxProcessingTasks), ctx); } - json->getProperty("timeoutInSeconds", &field); + json->getProperty("timeoutInSeconds", &field, true); if(!field.isNullOrUndefined()) { ok &= sevalue_to_native(field, &(to->timeoutInSeconds), ctx); } - json->getProperty("tempFileNameSuffix", &field); + json->getProperty("tempFileNameSuffix", &field, true); if(!field.isNullOrUndefined()) { ok &= sevalue_to_native(field, &(to->tempFileNameSuffix), ctx); } @@ -132,9 +134,8 @@ static bool js_network_DownloaderHints_constructor(se::State& s) // NOLINT(reada if(argc == 0) { - cc::network::DownloaderHints* cobj = JSB_ALLOC(cc::network::DownloaderHints); - s.thisObject()->setPrivateData(cobj); - se::NonRefNativePtrCreatedByCtorMap::emplace(cobj); + auto *ptr = JSB_MAKE_PRIVATE_OBJECT(cc::network::DownloaderHints); + s.thisObject()->setPrivateObject(ptr); return true; } @@ -142,21 +143,19 @@ static bool js_network_DownloaderHints_constructor(se::State& s) // NOLINT(reada { se::Object *json = args[0].toObject(); se::Value field; - - cc::network::DownloaderHints* cobj = JSB_ALLOC(cc::network::DownloaderHints); + auto *ptr = JSB_MAKE_PRIVATE_OBJECT(cc::network::DownloaderHints); + auto cobj = ptr->get(); ok &= sevalue_to_native(args[0], cobj, s.thisObject()); if(!ok) { - JSB_FREE(cobj); + delete ptr; SE_REPORT_ERROR("argument convertion error"); return false; } - - s.thisObject()->setPrivateData(cobj); - se::NonRefNativePtrCreatedByCtorMap::emplace(cobj); + s.thisObject()->setPrivateObject(ptr); return true; } - - cc::network::DownloaderHints* cobj = JSB_ALLOC(cc::network::DownloaderHints); + auto *ptr = JSB_MAKE_PRIVATE_OBJECT(cc::network::DownloaderHints); + auto cobj = ptr->get(); if (argc > 0 && !args[0].isUndefined()) { ok &= sevalue_to_native(args[0], &(cobj->countOfMaxProcessingTasks), nullptr); } @@ -168,28 +167,17 @@ static bool js_network_DownloaderHints_constructor(se::State& s) // NOLINT(reada } if(!ok) { - JSB_FREE(cobj); + delete ptr; SE_REPORT_ERROR("Argument convertion error"); return false; } - - s.thisObject()->setPrivateData(cobj); - se::NonRefNativePtrCreatedByCtorMap::emplace(cobj); + s.thisObject()->setPrivateObject(ptr); return true; } SE_BIND_CTOR(js_network_DownloaderHints_constructor, __jsb_cc_network_DownloaderHints_class, js_cc_network_DownloaderHints_finalize) - - static bool js_cc_network_DownloaderHints_finalize(se::State& s) // NOLINT(readability-identifier-naming) { - auto iter = se::NonRefNativePtrCreatedByCtorMap::find(SE_THIS_OBJECT(s)); - if (iter != se::NonRefNativePtrCreatedByCtorMap::end()) - { - se::NonRefNativePtrCreatedByCtorMap::erase(iter); - auto* cobj = SE_THIS_OBJECT(s); - JSB_FREE(cobj); - } return true; } SE_BIND_FINALIZE_FUNC(js_cc_network_DownloaderHints_finalize) @@ -208,11 +196,12 @@ bool js_register_network_DownloaderHints(se::Object* obj) // NOLINT(readability- __jsb_cc_network_DownloaderHints_proto = cls->getProto(); __jsb_cc_network_DownloaderHints_class = cls; + se::ScriptEngine::getInstance()->clearException(); return true; } -se::Object* __jsb_cc_network_Downloader_proto = nullptr; -se::Class* __jsb_cc_network_Downloader_class = nullptr; +se::Object* __jsb_cc_network_Downloader_proto = nullptr; // NOLINT +se::Class* __jsb_cc_network_Downloader_class = nullptr; // NOLINT static bool js_network_Downloader_setOnTaskProgress(se::State& s) // NOLINT(readability-identifier-naming) { @@ -229,6 +218,7 @@ static bool js_network_Downloader_setOnTaskProgress(se::State& s) // NOLINT(read se::Value jsThis(s.thisObject()); se::Value jsFunc(args[0]); jsThis.toObject()->attachObject(jsFunc.toObject()); + auto * thisObj = s.thisObject(); auto lambda = [=](const cc::network::DownloadTask & larg0, int64_t larg1, int64_t larg2, int64_t larg3) -> void { se::ScriptEngine::getInstance()->clearException(); se::AutoHandleScope hs; @@ -241,7 +231,6 @@ static bool js_network_Downloader_setOnTaskProgress(se::State& s) // NOLINT(read ok &= nativevalue_to_se(larg2, args[2], nullptr /*ctx*/); ok &= nativevalue_to_se(larg3, args[3], nullptr /*ctx*/); se::Value rval; - se::Object* thisObj = jsThis.isObject() ? jsThis.toObject() : nullptr; se::Object* funcObj = jsFunc.toObject(); bool succeed = funcObj->call(args, thisObj, &rval); if (!succeed) { @@ -277,17 +266,15 @@ static bool js_network_Downloader_constructor(se::State& s) // NOLINT(readabilit HolderType arg0 = {}; ok &= sevalue_to_native(args[0], &arg0, s.thisObject()); if (!ok) { ok = true; break; } - cc::network::Downloader* cobj = JSB_ALLOC(cc::network::Downloader, arg0.value()); - s.thisObject()->setPrivateData(cobj); - se::NonRefNativePtrCreatedByCtorMap::emplace(cobj); + auto *ptr = JSB_MAKE_PRIVATE_OBJECT(cc::network::Downloader, arg0.value()); + s.thisObject()->setPrivateObject(ptr); return true; } } while(false); do { if (argc == 0) { - cc::network::Downloader* cobj = JSB_ALLOC(cc::network::Downloader); - s.thisObject()->setPrivateData(cobj); - se::NonRefNativePtrCreatedByCtorMap::emplace(cobj); + auto *ptr = JSB_MAKE_PRIVATE_OBJECT(cc::network::Downloader); + s.thisObject()->setPrivateObject(ptr); return true; } } while(false); @@ -296,17 +283,8 @@ static bool js_network_Downloader_constructor(se::State& s) // NOLINT(readabilit } SE_BIND_CTOR(js_network_Downloader_constructor, __jsb_cc_network_Downloader_class, js_cc_network_Downloader_finalize) - - static bool js_cc_network_Downloader_finalize(se::State& s) // NOLINT(readability-identifier-naming) { - auto iter = se::NonRefNativePtrCreatedByCtorMap::find(SE_THIS_OBJECT(s)); - if (iter != se::NonRefNativePtrCreatedByCtorMap::end()) - { - se::NonRefNativePtrCreatedByCtorMap::erase(iter); - auto* cobj = SE_THIS_OBJECT(s); - JSB_FREE(cobj); - } return true; } SE_BIND_FINALIZE_FUNC(js_cc_network_Downloader_finalize) @@ -323,14 +301,15 @@ bool js_register_network_Downloader(se::Object* obj) // NOLINT(readability-ident __jsb_cc_network_Downloader_proto = cls->getProto(); __jsb_cc_network_Downloader_class = cls; + se::ScriptEngine::getInstance()->clearException(); return true; } -bool register_all_network(se::Object* obj) +bool register_all_network(se::Object* obj) // NOLINT { // Get the ns se::Value nsVal; - if (!obj->getProperty("jsb", &nsVal)) + if (!obj->getProperty("jsb", &nsVal, true)) { se::HandleObject jsobj(se::Object::createPlainObject()); nsVal.setObject(jsobj); @@ -338,8 +317,9 @@ bool register_all_network(se::Object* obj) } se::Object* ns = nsVal.toObject(); - js_register_network_DownloaderHints(ns); js_register_network_Downloader(ns); + js_register_network_DownloaderHints(ns); return true; } +// clang-format on \ No newline at end of file diff --git a/native/cocos/bindings/auto/jsb_network_auto.h b/native/cocos/bindings/auto/jsb_network_auto.h index ebca293de1..bc516d72a1 100644 --- a/native/cocos/bindings/auto/jsb_network_auto.h +++ b/native/cocos/bindings/auto/jsb_network_auto.h @@ -1,3 +1,4 @@ +// clang-format off #pragma once #include "base/Config.h" #include @@ -5,23 +6,25 @@ #include "cocos/bindings/manual/jsb_conversions.h" #include "cocos/network/Downloader.h" -extern se::Object* __jsb_cc_network_DownloaderHints_proto; -extern se::Class* __jsb_cc_network_DownloaderHints_class; +bool register_all_network(se::Object *obj); // NOLINT -bool js_register_cc_network_DownloaderHints(se::Object* obj); -bool register_all_network(se::Object* obj); - -template<> -bool sevalue_to_native(const se::Value &, cc::network::DownloaderHints *, se::Object *ctx); JSB_REGISTER_OBJECT_TYPE(cc::network::DownloaderHints); - -extern se::Object* __jsb_cc_network_Downloader_proto; -extern se::Class* __jsb_cc_network_Downloader_class; - -bool js_register_cc_network_Downloader(se::Object* obj); -bool register_all_network(se::Object* obj); - JSB_REGISTER_OBJECT_TYPE(cc::network::Downloader); + + +extern se::Object *__jsb_cc_network_DownloaderHints_proto; // NOLINT +extern se::Class * __jsb_cc_network_DownloaderHints_class; // NOLINT + +bool js_register_cc_network_DownloaderHints(se::Object *obj); // NOLINT + +template <> +bool sevalue_to_native(const se::Value &, cc::network::DownloaderHints *, se::Object *ctx); //NOLINT + +extern se::Object *__jsb_cc_network_Downloader_proto; // NOLINT +extern se::Class * __jsb_cc_network_Downloader_class; // NOLINT + +bool js_register_cc_network_Downloader(se::Object *obj); // NOLINT + SE_DECLARE_FUNC(js_network_Downloader_setOnTaskProgress); SE_DECLARE_FUNC(js_network_Downloader_Downloader); - + // clang-format on \ No newline at end of file diff --git a/native/cocos/bindings/auto/jsb_physics_auto.cpp b/native/cocos/bindings/auto/jsb_physics_auto.cpp index fedd1092fa..e7cb296bb8 100644 --- a/native/cocos/bindings/auto/jsb_physics_auto.cpp +++ b/native/cocos/bindings/auto/jsb_physics_auto.cpp @@ -1,3 +1,5 @@ + +// clang-format off #include "cocos/bindings/auto/jsb_physics_auto.h" #include "cocos/bindings/manual/jsb_conversions.h" #include "cocos/bindings/manual/jsb_global.h" @@ -10,8 +12,8 @@ #ifndef JSB_FREE #define JSB_FREE(ptr) delete ptr #endif -se::Object* __jsb_cc_physics_World_proto = nullptr; -se::Class* __jsb_cc_physics_World_class = nullptr; +se::Object* __jsb_cc_physics_World_proto = nullptr; // NOLINT +se::Class* __jsb_cc_physics_World_class = nullptr; // NOLINT static bool js_physics_World_createConvex(se::State& s) // NOLINT(readability-identifier-naming) { @@ -377,24 +379,14 @@ SE_DECLARE_FINALIZE_FUNC(js_cc_physics_World_finalize) static bool js_physics_World_constructor(se::State& s) // NOLINT(readability-identifier-naming) constructor.c { - cc::physics::World* cobj = JSB_ALLOC(cc::physics::World); - s.thisObject()->setPrivateData(cobj); - se::NonRefNativePtrCreatedByCtorMap::emplace(cobj); + auto *ptr = JSB_MAKE_PRIVATE_OBJECT(cc::physics::World); + s.thisObject()->setPrivateObject(ptr); return true; } SE_BIND_CTOR(js_physics_World_constructor, __jsb_cc_physics_World_class, js_cc_physics_World_finalize) - - static bool js_cc_physics_World_finalize(se::State& s) // NOLINT(readability-identifier-naming) { - auto iter = se::NonRefNativePtrCreatedByCtorMap::find(SE_THIS_OBJECT(s)); - if (iter != se::NonRefNativePtrCreatedByCtorMap::end()) - { - se::NonRefNativePtrCreatedByCtorMap::erase(iter); - auto* cobj = SE_THIS_OBJECT(s); - JSB_FREE(cobj); - } return true; } SE_BIND_FINALIZE_FUNC(js_cc_physics_World_finalize) @@ -428,11 +420,12 @@ bool js_register_physics_World(se::Object* obj) // NOLINT(readability-identifier __jsb_cc_physics_World_proto = cls->getProto(); __jsb_cc_physics_World_class = cls; + se::ScriptEngine::getInstance()->clearException(); return true; } -se::Object* __jsb_cc_physics_RigidBody_proto = nullptr; -se::Class* __jsb_cc_physics_RigidBody_class = nullptr; +se::Object* __jsb_cc_physics_RigidBody_proto = nullptr; // NOLINT +se::Class* __jsb_cc_physics_RigidBody_class = nullptr; // NOLINT static bool js_physics_RigidBody_applyForce(se::State& s) // NOLINT(readability-identifier-naming) { @@ -782,7 +775,7 @@ static bool js_physics_RigidBody_initialize(se::State& s) // NOLINT(readability- size_t argc = args.size(); CC_UNUSED bool ok = true; if (argc == 3) { - HolderType arg0 = {}; + HolderType arg0 = {}; HolderType arg1 = {}; HolderType arg2 = {}; ok &= sevalue_to_native(args[0], &arg0, s.thisObject()); @@ -1215,24 +1208,14 @@ SE_DECLARE_FINALIZE_FUNC(js_cc_physics_RigidBody_finalize) static bool js_physics_RigidBody_constructor(se::State& s) // NOLINT(readability-identifier-naming) constructor.c { - cc::physics::RigidBody* cobj = JSB_ALLOC(cc::physics::RigidBody); - s.thisObject()->setPrivateData(cobj); - se::NonRefNativePtrCreatedByCtorMap::emplace(cobj); + auto *ptr = JSB_MAKE_PRIVATE_OBJECT(cc::physics::RigidBody); + s.thisObject()->setPrivateObject(ptr); return true; } SE_BIND_CTOR(js_physics_RigidBody_constructor, __jsb_cc_physics_RigidBody_class, js_cc_physics_RigidBody_finalize) - - static bool js_cc_physics_RigidBody_finalize(se::State& s) // NOLINT(readability-identifier-naming) { - auto iter = se::NonRefNativePtrCreatedByCtorMap::find(SE_THIS_OBJECT(s)); - if (iter != se::NonRefNativePtrCreatedByCtorMap::end()) - { - se::NonRefNativePtrCreatedByCtorMap::erase(iter); - auto* cobj = SE_THIS_OBJECT(s); - JSB_FREE(cobj); - } return true; } SE_BIND_FINALIZE_FUNC(js_cc_physics_RigidBody_finalize) @@ -1287,11 +1270,12 @@ bool js_register_physics_RigidBody(se::Object* obj) // NOLINT(readability-identi __jsb_cc_physics_RigidBody_proto = cls->getProto(); __jsb_cc_physics_RigidBody_class = cls; + se::ScriptEngine::getInstance()->clearException(); return true; } -se::Object* __jsb_cc_physics_SphereShape_proto = nullptr; -se::Class* __jsb_cc_physics_SphereShape_class = nullptr; +se::Object* __jsb_cc_physics_SphereShape_proto = nullptr; // NOLINT +se::Class* __jsb_cc_physics_SphereShape_class = nullptr; // NOLINT static bool js_physics_SphereShape_getAABB(se::State& s) // NOLINT(readability-identifier-naming) { @@ -1301,7 +1285,7 @@ static bool js_physics_SphereShape_getAABB(se::State& s) // NOLINT(readability-i size_t argc = args.size(); CC_UNUSED bool ok = true; if (argc == 0) { - cc::scene::AABB& result = cobj->getAABB(); + cc::geometry::AABB& result = cobj->getAABB(); ok &= nativevalue_to_se(result, s.rval(), nullptr /*ctx*/); SE_PRECONDITION2(ok, false, "js_physics_SphereShape_getAABB : Error processing arguments"); SE_HOLD_RETURN_VALUE(result, s.thisObject(), s.rval()); @@ -1320,7 +1304,7 @@ static bool js_physics_SphereShape_getBoundingSphere(se::State& s) // NOLINT(rea size_t argc = args.size(); CC_UNUSED bool ok = true; if (argc == 0) { - cc::scene::Sphere& result = cobj->getBoundingSphere(); + cc::geometry::Sphere& result = cobj->getBoundingSphere(); ok &= nativevalue_to_se(result, s.rval(), nullptr /*ctx*/); SE_PRECONDITION2(ok, false, "js_physics_SphereShape_getBoundingSphere : Error processing arguments"); SE_HOLD_RETURN_VALUE(result, s.thisObject(), s.rval()); @@ -1396,7 +1380,7 @@ static bool js_physics_SphereShape_initialize(se::State& s) // NOLINT(readabilit size_t argc = args.size(); CC_UNUSED bool ok = true; if (argc == 1) { - HolderType arg0 = {}; + HolderType arg0 = {}; ok &= sevalue_to_native(args[0], &arg0, s.thisObject()); SE_PRECONDITION2(ok, false, "js_physics_SphereShape_initialize : Error processing arguments"); cobj->initialize(arg0.value()); @@ -1603,24 +1587,14 @@ SE_DECLARE_FINALIZE_FUNC(js_cc_physics_SphereShape_finalize) static bool js_physics_SphereShape_constructor(se::State& s) // NOLINT(readability-identifier-naming) constructor.c { - cc::physics::SphereShape* cobj = JSB_ALLOC(cc::physics::SphereShape); - s.thisObject()->setPrivateData(cobj); - se::NonRefNativePtrCreatedByCtorMap::emplace(cobj); + auto *ptr = JSB_MAKE_PRIVATE_OBJECT(cc::physics::SphereShape); + s.thisObject()->setPrivateObject(ptr); return true; } SE_BIND_CTOR(js_physics_SphereShape_constructor, __jsb_cc_physics_SphereShape_class, js_cc_physics_SphereShape_finalize) - - static bool js_cc_physics_SphereShape_finalize(se::State& s) // NOLINT(readability-identifier-naming) { - auto iter = se::NonRefNativePtrCreatedByCtorMap::find(SE_THIS_OBJECT(s)); - if (iter != se::NonRefNativePtrCreatedByCtorMap::end()) - { - se::NonRefNativePtrCreatedByCtorMap::erase(iter); - auto* cobj = SE_THIS_OBJECT(s); - JSB_FREE(cobj); - } return true; } SE_BIND_FINALIZE_FUNC(js_cc_physics_SphereShape_finalize) @@ -1652,11 +1626,12 @@ bool js_register_physics_SphereShape(se::Object* obj) // NOLINT(readability-iden __jsb_cc_physics_SphereShape_proto = cls->getProto(); __jsb_cc_physics_SphereShape_class = cls; + se::ScriptEngine::getInstance()->clearException(); return true; } -se::Object* __jsb_cc_physics_BoxShape_proto = nullptr; -se::Class* __jsb_cc_physics_BoxShape_class = nullptr; +se::Object* __jsb_cc_physics_BoxShape_proto = nullptr; // NOLINT +se::Class* __jsb_cc_physics_BoxShape_class = nullptr; // NOLINT static bool js_physics_BoxShape_getAABB(se::State& s) // NOLINT(readability-identifier-naming) { @@ -1666,7 +1641,7 @@ static bool js_physics_BoxShape_getAABB(se::State& s) // NOLINT(readability-iden size_t argc = args.size(); CC_UNUSED bool ok = true; if (argc == 0) { - cc::scene::AABB& result = cobj->getAABB(); + cc::geometry::AABB& result = cobj->getAABB(); ok &= nativevalue_to_se(result, s.rval(), nullptr /*ctx*/); SE_PRECONDITION2(ok, false, "js_physics_BoxShape_getAABB : Error processing arguments"); SE_HOLD_RETURN_VALUE(result, s.thisObject(), s.rval()); @@ -1685,7 +1660,7 @@ static bool js_physics_BoxShape_getBoundingSphere(se::State& s) // NOLINT(readab size_t argc = args.size(); CC_UNUSED bool ok = true; if (argc == 0) { - cc::scene::Sphere& result = cobj->getBoundingSphere(); + cc::geometry::Sphere& result = cobj->getBoundingSphere(); ok &= nativevalue_to_se(result, s.rval(), nullptr /*ctx*/); SE_PRECONDITION2(ok, false, "js_physics_BoxShape_getBoundingSphere : Error processing arguments"); SE_HOLD_RETURN_VALUE(result, s.thisObject(), s.rval()); @@ -1761,7 +1736,7 @@ static bool js_physics_BoxShape_initialize(se::State& s) // NOLINT(readability-i size_t argc = args.size(); CC_UNUSED bool ok = true; if (argc == 1) { - HolderType arg0 = {}; + HolderType arg0 = {}; ok &= sevalue_to_native(args[0], &arg0, s.thisObject()); SE_PRECONDITION2(ok, false, "js_physics_BoxShape_initialize : Error processing arguments"); cobj->initialize(arg0.value()); @@ -1972,24 +1947,14 @@ SE_DECLARE_FINALIZE_FUNC(js_cc_physics_BoxShape_finalize) static bool js_physics_BoxShape_constructor(se::State& s) // NOLINT(readability-identifier-naming) constructor.c { - cc::physics::BoxShape* cobj = JSB_ALLOC(cc::physics::BoxShape); - s.thisObject()->setPrivateData(cobj); - se::NonRefNativePtrCreatedByCtorMap::emplace(cobj); + auto *ptr = JSB_MAKE_PRIVATE_OBJECT(cc::physics::BoxShape); + s.thisObject()->setPrivateObject(ptr); return true; } SE_BIND_CTOR(js_physics_BoxShape_constructor, __jsb_cc_physics_BoxShape_class, js_cc_physics_BoxShape_finalize) - - static bool js_cc_physics_BoxShape_finalize(se::State& s) // NOLINT(readability-identifier-naming) { - auto iter = se::NonRefNativePtrCreatedByCtorMap::find(SE_THIS_OBJECT(s)); - if (iter != se::NonRefNativePtrCreatedByCtorMap::end()) - { - se::NonRefNativePtrCreatedByCtorMap::erase(iter); - auto* cobj = SE_THIS_OBJECT(s); - JSB_FREE(cobj); - } return true; } SE_BIND_FINALIZE_FUNC(js_cc_physics_BoxShape_finalize) @@ -2021,11 +1986,12 @@ bool js_register_physics_BoxShape(se::Object* obj) // NOLINT(readability-identif __jsb_cc_physics_BoxShape_proto = cls->getProto(); __jsb_cc_physics_BoxShape_class = cls; + se::ScriptEngine::getInstance()->clearException(); return true; } -se::Object* __jsb_cc_physics_CapsuleShape_proto = nullptr; -se::Class* __jsb_cc_physics_CapsuleShape_class = nullptr; +se::Object* __jsb_cc_physics_CapsuleShape_proto = nullptr; // NOLINT +se::Class* __jsb_cc_physics_CapsuleShape_class = nullptr; // NOLINT static bool js_physics_CapsuleShape_getAABB(se::State& s) // NOLINT(readability-identifier-naming) { @@ -2035,7 +2001,7 @@ static bool js_physics_CapsuleShape_getAABB(se::State& s) // NOLINT(readability- size_t argc = args.size(); CC_UNUSED bool ok = true; if (argc == 0) { - cc::scene::AABB& result = cobj->getAABB(); + cc::geometry::AABB& result = cobj->getAABB(); ok &= nativevalue_to_se(result, s.rval(), nullptr /*ctx*/); SE_PRECONDITION2(ok, false, "js_physics_CapsuleShape_getAABB : Error processing arguments"); SE_HOLD_RETURN_VALUE(result, s.thisObject(), s.rval()); @@ -2054,7 +2020,7 @@ static bool js_physics_CapsuleShape_getBoundingSphere(se::State& s) // NOLINT(re size_t argc = args.size(); CC_UNUSED bool ok = true; if (argc == 0) { - cc::scene::Sphere& result = cobj->getBoundingSphere(); + cc::geometry::Sphere& result = cobj->getBoundingSphere(); ok &= nativevalue_to_se(result, s.rval(), nullptr /*ctx*/); SE_PRECONDITION2(ok, false, "js_physics_CapsuleShape_getBoundingSphere : Error processing arguments"); SE_HOLD_RETURN_VALUE(result, s.thisObject(), s.rval()); @@ -2130,7 +2096,7 @@ static bool js_physics_CapsuleShape_initialize(se::State& s) // NOLINT(readabili size_t argc = args.size(); CC_UNUSED bool ok = true; if (argc == 1) { - HolderType arg0 = {}; + HolderType arg0 = {}; ok &= sevalue_to_native(args[0], &arg0, s.thisObject()); SE_PRECONDITION2(ok, false, "js_physics_CapsuleShape_initialize : Error processing arguments"); cobj->initialize(arg0.value()); @@ -2375,24 +2341,14 @@ SE_DECLARE_FINALIZE_FUNC(js_cc_physics_CapsuleShape_finalize) static bool js_physics_CapsuleShape_constructor(se::State& s) // NOLINT(readability-identifier-naming) constructor.c { - cc::physics::CapsuleShape* cobj = JSB_ALLOC(cc::physics::CapsuleShape); - s.thisObject()->setPrivateData(cobj); - se::NonRefNativePtrCreatedByCtorMap::emplace(cobj); + auto *ptr = JSB_MAKE_PRIVATE_OBJECT(cc::physics::CapsuleShape); + s.thisObject()->setPrivateObject(ptr); return true; } SE_BIND_CTOR(js_physics_CapsuleShape_constructor, __jsb_cc_physics_CapsuleShape_class, js_cc_physics_CapsuleShape_finalize) - - static bool js_cc_physics_CapsuleShape_finalize(se::State& s) // NOLINT(readability-identifier-naming) { - auto iter = se::NonRefNativePtrCreatedByCtorMap::find(SE_THIS_OBJECT(s)); - if (iter != se::NonRefNativePtrCreatedByCtorMap::end()) - { - se::NonRefNativePtrCreatedByCtorMap::erase(iter); - auto* cobj = SE_THIS_OBJECT(s); - JSB_FREE(cobj); - } return true; } SE_BIND_FINALIZE_FUNC(js_cc_physics_CapsuleShape_finalize) @@ -2426,11 +2382,12 @@ bool js_register_physics_CapsuleShape(se::Object* obj) // NOLINT(readability-ide __jsb_cc_physics_CapsuleShape_proto = cls->getProto(); __jsb_cc_physics_CapsuleShape_class = cls; + se::ScriptEngine::getInstance()->clearException(); return true; } -se::Object* __jsb_cc_physics_PlaneShape_proto = nullptr; -se::Class* __jsb_cc_physics_PlaneShape_class = nullptr; +se::Object* __jsb_cc_physics_PlaneShape_proto = nullptr; // NOLINT +se::Class* __jsb_cc_physics_PlaneShape_class = nullptr; // NOLINT static bool js_physics_PlaneShape_getAABB(se::State& s) // NOLINT(readability-identifier-naming) { @@ -2440,7 +2397,7 @@ static bool js_physics_PlaneShape_getAABB(se::State& s) // NOLINT(readability-id size_t argc = args.size(); CC_UNUSED bool ok = true; if (argc == 0) { - cc::scene::AABB& result = cobj->getAABB(); + cc::geometry::AABB& result = cobj->getAABB(); ok &= nativevalue_to_se(result, s.rval(), nullptr /*ctx*/); SE_PRECONDITION2(ok, false, "js_physics_PlaneShape_getAABB : Error processing arguments"); SE_HOLD_RETURN_VALUE(result, s.thisObject(), s.rval()); @@ -2459,7 +2416,7 @@ static bool js_physics_PlaneShape_getBoundingSphere(se::State& s) // NOLINT(read size_t argc = args.size(); CC_UNUSED bool ok = true; if (argc == 0) { - cc::scene::Sphere& result = cobj->getBoundingSphere(); + cc::geometry::Sphere& result = cobj->getBoundingSphere(); ok &= nativevalue_to_se(result, s.rval(), nullptr /*ctx*/); SE_PRECONDITION2(ok, false, "js_physics_PlaneShape_getBoundingSphere : Error processing arguments"); SE_HOLD_RETURN_VALUE(result, s.thisObject(), s.rval()); @@ -2535,7 +2492,7 @@ static bool js_physics_PlaneShape_initialize(se::State& s) // NOLINT(readability size_t argc = args.size(); CC_UNUSED bool ok = true; if (argc == 1) { - HolderType arg0 = {}; + HolderType arg0 = {}; ok &= sevalue_to_native(args[0], &arg0, s.thisObject()); SE_PRECONDITION2(ok, false, "js_physics_PlaneShape_initialize : Error processing arguments"); cobj->initialize(arg0.value()); @@ -2765,24 +2722,14 @@ SE_DECLARE_FINALIZE_FUNC(js_cc_physics_PlaneShape_finalize) static bool js_physics_PlaneShape_constructor(se::State& s) // NOLINT(readability-identifier-naming) constructor.c { - cc::physics::PlaneShape* cobj = JSB_ALLOC(cc::physics::PlaneShape); - s.thisObject()->setPrivateData(cobj); - se::NonRefNativePtrCreatedByCtorMap::emplace(cobj); + auto *ptr = JSB_MAKE_PRIVATE_OBJECT(cc::physics::PlaneShape); + s.thisObject()->setPrivateObject(ptr); return true; } SE_BIND_CTOR(js_physics_PlaneShape_constructor, __jsb_cc_physics_PlaneShape_class, js_cc_physics_PlaneShape_finalize) - - static bool js_cc_physics_PlaneShape_finalize(se::State& s) // NOLINT(readability-identifier-naming) { - auto iter = se::NonRefNativePtrCreatedByCtorMap::find(SE_THIS_OBJECT(s)); - if (iter != se::NonRefNativePtrCreatedByCtorMap::end()) - { - se::NonRefNativePtrCreatedByCtorMap::erase(iter); - auto* cobj = SE_THIS_OBJECT(s); - JSB_FREE(cobj); - } return true; } SE_BIND_FINALIZE_FUNC(js_cc_physics_PlaneShape_finalize) @@ -2815,11 +2762,12 @@ bool js_register_physics_PlaneShape(se::Object* obj) // NOLINT(readability-ident __jsb_cc_physics_PlaneShape_proto = cls->getProto(); __jsb_cc_physics_PlaneShape_class = cls; + se::ScriptEngine::getInstance()->clearException(); return true; } -se::Object* __jsb_cc_physics_TrimeshShape_proto = nullptr; -se::Class* __jsb_cc_physics_TrimeshShape_class = nullptr; +se::Object* __jsb_cc_physics_TrimeshShape_proto = nullptr; // NOLINT +se::Class* __jsb_cc_physics_TrimeshShape_class = nullptr; // NOLINT static bool js_physics_TrimeshShape_getAABB(se::State& s) // NOLINT(readability-identifier-naming) { @@ -2829,7 +2777,7 @@ static bool js_physics_TrimeshShape_getAABB(se::State& s) // NOLINT(readability- size_t argc = args.size(); CC_UNUSED bool ok = true; if (argc == 0) { - cc::scene::AABB& result = cobj->getAABB(); + cc::geometry::AABB& result = cobj->getAABB(); ok &= nativevalue_to_se(result, s.rval(), nullptr /*ctx*/); SE_PRECONDITION2(ok, false, "js_physics_TrimeshShape_getAABB : Error processing arguments"); SE_HOLD_RETURN_VALUE(result, s.thisObject(), s.rval()); @@ -2848,7 +2796,7 @@ static bool js_physics_TrimeshShape_getBoundingSphere(se::State& s) // NOLINT(re size_t argc = args.size(); CC_UNUSED bool ok = true; if (argc == 0) { - cc::scene::Sphere& result = cobj->getBoundingSphere(); + cc::geometry::Sphere& result = cobj->getBoundingSphere(); ok &= nativevalue_to_se(result, s.rval(), nullptr /*ctx*/); SE_PRECONDITION2(ok, false, "js_physics_TrimeshShape_getBoundingSphere : Error processing arguments"); SE_HOLD_RETURN_VALUE(result, s.thisObject(), s.rval()); @@ -2924,7 +2872,7 @@ static bool js_physics_TrimeshShape_initialize(se::State& s) // NOLINT(readabili size_t argc = args.size(); CC_UNUSED bool ok = true; if (argc == 1) { - HolderType arg0 = {}; + HolderType arg0 = {}; ok &= sevalue_to_native(args[0], &arg0, s.thisObject()); SE_PRECONDITION2(ok, false, "js_physics_TrimeshShape_initialize : Error processing arguments"); cobj->initialize(arg0.value()); @@ -3150,24 +3098,14 @@ SE_DECLARE_FINALIZE_FUNC(js_cc_physics_TrimeshShape_finalize) static bool js_physics_TrimeshShape_constructor(se::State& s) // NOLINT(readability-identifier-naming) constructor.c { - cc::physics::TrimeshShape* cobj = JSB_ALLOC(cc::physics::TrimeshShape); - s.thisObject()->setPrivateData(cobj); - se::NonRefNativePtrCreatedByCtorMap::emplace(cobj); + auto *ptr = JSB_MAKE_PRIVATE_OBJECT(cc::physics::TrimeshShape); + s.thisObject()->setPrivateObject(ptr); return true; } SE_BIND_CTOR(js_physics_TrimeshShape_constructor, __jsb_cc_physics_TrimeshShape_class, js_cc_physics_TrimeshShape_finalize) - - static bool js_cc_physics_TrimeshShape_finalize(se::State& s) // NOLINT(readability-identifier-naming) { - auto iter = se::NonRefNativePtrCreatedByCtorMap::find(SE_THIS_OBJECT(s)); - if (iter != se::NonRefNativePtrCreatedByCtorMap::end()) - { - se::NonRefNativePtrCreatedByCtorMap::erase(iter); - auto* cobj = SE_THIS_OBJECT(s); - JSB_FREE(cobj); - } return true; } SE_BIND_FINALIZE_FUNC(js_cc_physics_TrimeshShape_finalize) @@ -3200,11 +3138,12 @@ bool js_register_physics_TrimeshShape(se::Object* obj) // NOLINT(readability-ide __jsb_cc_physics_TrimeshShape_proto = cls->getProto(); __jsb_cc_physics_TrimeshShape_class = cls; + se::ScriptEngine::getInstance()->clearException(); return true; } -se::Object* __jsb_cc_physics_CylinderShape_proto = nullptr; -se::Class* __jsb_cc_physics_CylinderShape_class = nullptr; +se::Object* __jsb_cc_physics_CylinderShape_proto = nullptr; // NOLINT +se::Class* __jsb_cc_physics_CylinderShape_class = nullptr; // NOLINT static bool js_physics_CylinderShape_getAABB(se::State& s) // NOLINT(readability-identifier-naming) { @@ -3214,7 +3153,7 @@ static bool js_physics_CylinderShape_getAABB(se::State& s) // NOLINT(readability size_t argc = args.size(); CC_UNUSED bool ok = true; if (argc == 0) { - cc::scene::AABB& result = cobj->getAABB(); + cc::geometry::AABB& result = cobj->getAABB(); ok &= nativevalue_to_se(result, s.rval(), nullptr /*ctx*/); SE_PRECONDITION2(ok, false, "js_physics_CylinderShape_getAABB : Error processing arguments"); SE_HOLD_RETURN_VALUE(result, s.thisObject(), s.rval()); @@ -3233,7 +3172,7 @@ static bool js_physics_CylinderShape_getBoundingSphere(se::State& s) // NOLINT(r size_t argc = args.size(); CC_UNUSED bool ok = true; if (argc == 0) { - cc::scene::Sphere& result = cobj->getBoundingSphere(); + cc::geometry::Sphere& result = cobj->getBoundingSphere(); ok &= nativevalue_to_se(result, s.rval(), nullptr /*ctx*/); SE_PRECONDITION2(ok, false, "js_physics_CylinderShape_getBoundingSphere : Error processing arguments"); SE_HOLD_RETURN_VALUE(result, s.thisObject(), s.rval()); @@ -3309,7 +3248,7 @@ static bool js_physics_CylinderShape_initialize(se::State& s) // NOLINT(readabil size_t argc = args.size(); CC_UNUSED bool ok = true; if (argc == 1) { - HolderType arg0 = {}; + HolderType arg0 = {}; ok &= sevalue_to_native(args[0], &arg0, s.thisObject()); SE_PRECONDITION2(ok, false, "js_physics_CylinderShape_initialize : Error processing arguments"); cobj->initialize(arg0.value()); @@ -3539,24 +3478,14 @@ SE_DECLARE_FINALIZE_FUNC(js_cc_physics_CylinderShape_finalize) static bool js_physics_CylinderShape_constructor(se::State& s) // NOLINT(readability-identifier-naming) constructor.c { - cc::physics::CylinderShape* cobj = JSB_ALLOC(cc::physics::CylinderShape); - s.thisObject()->setPrivateData(cobj); - se::NonRefNativePtrCreatedByCtorMap::emplace(cobj); + auto *ptr = JSB_MAKE_PRIVATE_OBJECT(cc::physics::CylinderShape); + s.thisObject()->setPrivateObject(ptr); return true; } SE_BIND_CTOR(js_physics_CylinderShape_constructor, __jsb_cc_physics_CylinderShape_class, js_cc_physics_CylinderShape_finalize) - - static bool js_cc_physics_CylinderShape_finalize(se::State& s) // NOLINT(readability-identifier-naming) { - auto iter = se::NonRefNativePtrCreatedByCtorMap::find(SE_THIS_OBJECT(s)); - if (iter != se::NonRefNativePtrCreatedByCtorMap::end()) - { - se::NonRefNativePtrCreatedByCtorMap::erase(iter); - auto* cobj = SE_THIS_OBJECT(s); - JSB_FREE(cobj); - } return true; } SE_BIND_FINALIZE_FUNC(js_cc_physics_CylinderShape_finalize) @@ -3589,11 +3518,12 @@ bool js_register_physics_CylinderShape(se::Object* obj) // NOLINT(readability-id __jsb_cc_physics_CylinderShape_proto = cls->getProto(); __jsb_cc_physics_CylinderShape_class = cls; + se::ScriptEngine::getInstance()->clearException(); return true; } -se::Object* __jsb_cc_physics_ConeShape_proto = nullptr; -se::Class* __jsb_cc_physics_ConeShape_class = nullptr; +se::Object* __jsb_cc_physics_ConeShape_proto = nullptr; // NOLINT +se::Class* __jsb_cc_physics_ConeShape_class = nullptr; // NOLINT static bool js_physics_ConeShape_getAABB(se::State& s) // NOLINT(readability-identifier-naming) { @@ -3603,7 +3533,7 @@ static bool js_physics_ConeShape_getAABB(se::State& s) // NOLINT(readability-ide size_t argc = args.size(); CC_UNUSED bool ok = true; if (argc == 0) { - cc::scene::AABB& result = cobj->getAABB(); + cc::geometry::AABB& result = cobj->getAABB(); ok &= nativevalue_to_se(result, s.rval(), nullptr /*ctx*/); SE_PRECONDITION2(ok, false, "js_physics_ConeShape_getAABB : Error processing arguments"); SE_HOLD_RETURN_VALUE(result, s.thisObject(), s.rval()); @@ -3622,7 +3552,7 @@ static bool js_physics_ConeShape_getBoundingSphere(se::State& s) // NOLINT(reada size_t argc = args.size(); CC_UNUSED bool ok = true; if (argc == 0) { - cc::scene::Sphere& result = cobj->getBoundingSphere(); + cc::geometry::Sphere& result = cobj->getBoundingSphere(); ok &= nativevalue_to_se(result, s.rval(), nullptr /*ctx*/); SE_PRECONDITION2(ok, false, "js_physics_ConeShape_getBoundingSphere : Error processing arguments"); SE_HOLD_RETURN_VALUE(result, s.thisObject(), s.rval()); @@ -3698,7 +3628,7 @@ static bool js_physics_ConeShape_initialize(se::State& s) // NOLINT(readability- size_t argc = args.size(); CC_UNUSED bool ok = true; if (argc == 1) { - HolderType arg0 = {}; + HolderType arg0 = {}; ok &= sevalue_to_native(args[0], &arg0, s.thisObject()); SE_PRECONDITION2(ok, false, "js_physics_ConeShape_initialize : Error processing arguments"); cobj->initialize(arg0.value()); @@ -3928,24 +3858,14 @@ SE_DECLARE_FINALIZE_FUNC(js_cc_physics_ConeShape_finalize) static bool js_physics_ConeShape_constructor(se::State& s) // NOLINT(readability-identifier-naming) constructor.c { - cc::physics::ConeShape* cobj = JSB_ALLOC(cc::physics::ConeShape); - s.thisObject()->setPrivateData(cobj); - se::NonRefNativePtrCreatedByCtorMap::emplace(cobj); + auto *ptr = JSB_MAKE_PRIVATE_OBJECT(cc::physics::ConeShape); + s.thisObject()->setPrivateObject(ptr); return true; } SE_BIND_CTOR(js_physics_ConeShape_constructor, __jsb_cc_physics_ConeShape_class, js_cc_physics_ConeShape_finalize) - - static bool js_cc_physics_ConeShape_finalize(se::State& s) // NOLINT(readability-identifier-naming) { - auto iter = se::NonRefNativePtrCreatedByCtorMap::find(SE_THIS_OBJECT(s)); - if (iter != se::NonRefNativePtrCreatedByCtorMap::end()) - { - se::NonRefNativePtrCreatedByCtorMap::erase(iter); - auto* cobj = SE_THIS_OBJECT(s); - JSB_FREE(cobj); - } return true; } SE_BIND_FINALIZE_FUNC(js_cc_physics_ConeShape_finalize) @@ -3978,11 +3898,12 @@ bool js_register_physics_ConeShape(se::Object* obj) // NOLINT(readability-identi __jsb_cc_physics_ConeShape_proto = cls->getProto(); __jsb_cc_physics_ConeShape_class = cls; + se::ScriptEngine::getInstance()->clearException(); return true; } -se::Object* __jsb_cc_physics_TerrainShape_proto = nullptr; -se::Class* __jsb_cc_physics_TerrainShape_class = nullptr; +se::Object* __jsb_cc_physics_TerrainShape_proto = nullptr; // NOLINT +se::Class* __jsb_cc_physics_TerrainShape_class = nullptr; // NOLINT static bool js_physics_TerrainShape_getAABB(se::State& s) // NOLINT(readability-identifier-naming) { @@ -3992,7 +3913,7 @@ static bool js_physics_TerrainShape_getAABB(se::State& s) // NOLINT(readability- size_t argc = args.size(); CC_UNUSED bool ok = true; if (argc == 0) { - cc::scene::AABB& result = cobj->getAABB(); + cc::geometry::AABB& result = cobj->getAABB(); ok &= nativevalue_to_se(result, s.rval(), nullptr /*ctx*/); SE_PRECONDITION2(ok, false, "js_physics_TerrainShape_getAABB : Error processing arguments"); SE_HOLD_RETURN_VALUE(result, s.thisObject(), s.rval()); @@ -4011,7 +3932,7 @@ static bool js_physics_TerrainShape_getBoundingSphere(se::State& s) // NOLINT(re size_t argc = args.size(); CC_UNUSED bool ok = true; if (argc == 0) { - cc::scene::Sphere& result = cobj->getBoundingSphere(); + cc::geometry::Sphere& result = cobj->getBoundingSphere(); ok &= nativevalue_to_se(result, s.rval(), nullptr /*ctx*/); SE_PRECONDITION2(ok, false, "js_physics_TerrainShape_getBoundingSphere : Error processing arguments"); SE_HOLD_RETURN_VALUE(result, s.thisObject(), s.rval()); @@ -4087,7 +4008,7 @@ static bool js_physics_TerrainShape_initialize(se::State& s) // NOLINT(readabili size_t argc = args.size(); CC_UNUSED bool ok = true; if (argc == 1) { - HolderType arg0 = {}; + HolderType arg0 = {}; ok &= sevalue_to_native(args[0], &arg0, s.thisObject()); SE_PRECONDITION2(ok, false, "js_physics_TerrainShape_initialize : Error processing arguments"); cobj->initialize(arg0.value()); @@ -4300,24 +4221,14 @@ SE_DECLARE_FINALIZE_FUNC(js_cc_physics_TerrainShape_finalize) static bool js_physics_TerrainShape_constructor(se::State& s) // NOLINT(readability-identifier-naming) constructor.c { - cc::physics::TerrainShape* cobj = JSB_ALLOC(cc::physics::TerrainShape); - s.thisObject()->setPrivateData(cobj); - se::NonRefNativePtrCreatedByCtorMap::emplace(cobj); + auto *ptr = JSB_MAKE_PRIVATE_OBJECT(cc::physics::TerrainShape); + s.thisObject()->setPrivateObject(ptr); return true; } SE_BIND_CTOR(js_physics_TerrainShape_constructor, __jsb_cc_physics_TerrainShape_class, js_cc_physics_TerrainShape_finalize) - - static bool js_cc_physics_TerrainShape_finalize(se::State& s) // NOLINT(readability-identifier-naming) { - auto iter = se::NonRefNativePtrCreatedByCtorMap::find(SE_THIS_OBJECT(s)); - if (iter != se::NonRefNativePtrCreatedByCtorMap::end()) - { - se::NonRefNativePtrCreatedByCtorMap::erase(iter); - auto* cobj = SE_THIS_OBJECT(s); - JSB_FREE(cobj); - } return true; } SE_BIND_FINALIZE_FUNC(js_cc_physics_TerrainShape_finalize) @@ -4349,11 +4260,12 @@ bool js_register_physics_TerrainShape(se::Object* obj) // NOLINT(readability-ide __jsb_cc_physics_TerrainShape_proto = cls->getProto(); __jsb_cc_physics_TerrainShape_class = cls; + se::ScriptEngine::getInstance()->clearException(); return true; } -se::Object* __jsb_cc_physics_RevoluteJoint_proto = nullptr; -se::Class* __jsb_cc_physics_RevoluteJoint_class = nullptr; +se::Object* __jsb_cc_physics_RevoluteJoint_proto = nullptr; // NOLINT +se::Class* __jsb_cc_physics_RevoluteJoint_class = nullptr; // NOLINT static bool js_physics_RevoluteJoint_getImpl(se::State& s) // NOLINT(readability-identifier-naming) { @@ -4382,7 +4294,7 @@ static bool js_physics_RevoluteJoint_initialize(se::State& s) // NOLINT(readabil size_t argc = args.size(); CC_UNUSED bool ok = true; if (argc == 1) { - HolderType arg0 = {}; + HolderType arg0 = {}; ok &= sevalue_to_native(args[0], &arg0, s.thisObject()); SE_PRECONDITION2(ok, false, "js_physics_RevoluteJoint_initialize : Error processing arguments"); cobj->initialize(arg0.value()); @@ -4549,24 +4461,14 @@ SE_DECLARE_FINALIZE_FUNC(js_cc_physics_RevoluteJoint_finalize) static bool js_physics_RevoluteJoint_constructor(se::State& s) // NOLINT(readability-identifier-naming) constructor.c { - cc::physics::RevoluteJoint* cobj = JSB_ALLOC(cc::physics::RevoluteJoint); - s.thisObject()->setPrivateData(cobj); - se::NonRefNativePtrCreatedByCtorMap::emplace(cobj); + auto *ptr = JSB_MAKE_PRIVATE_OBJECT(cc::physics::RevoluteJoint); + s.thisObject()->setPrivateObject(ptr); return true; } SE_BIND_CTOR(js_physics_RevoluteJoint_constructor, __jsb_cc_physics_RevoluteJoint_class, js_cc_physics_RevoluteJoint_finalize) - - static bool js_cc_physics_RevoluteJoint_finalize(se::State& s) // NOLINT(readability-identifier-naming) { - auto iter = se::NonRefNativePtrCreatedByCtorMap::find(SE_THIS_OBJECT(s)); - if (iter != se::NonRefNativePtrCreatedByCtorMap::end()) - { - se::NonRefNativePtrCreatedByCtorMap::erase(iter); - auto* cobj = SE_THIS_OBJECT(s); - JSB_FREE(cobj); - } return true; } SE_BIND_FINALIZE_FUNC(js_cc_physics_RevoluteJoint_finalize) @@ -4592,11 +4494,12 @@ bool js_register_physics_RevoluteJoint(se::Object* obj) // NOLINT(readability-id __jsb_cc_physics_RevoluteJoint_proto = cls->getProto(); __jsb_cc_physics_RevoluteJoint_class = cls; + se::ScriptEngine::getInstance()->clearException(); return true; } -se::Object* __jsb_cc_physics_DistanceJoint_proto = nullptr; -se::Class* __jsb_cc_physics_DistanceJoint_class = nullptr; +se::Object* __jsb_cc_physics_DistanceJoint_proto = nullptr; // NOLINT +se::Class* __jsb_cc_physics_DistanceJoint_class = nullptr; // NOLINT static bool js_physics_DistanceJoint_getImpl(se::State& s) // NOLINT(readability-identifier-naming) { @@ -4625,7 +4528,7 @@ static bool js_physics_DistanceJoint_initialize(se::State& s) // NOLINT(readabil size_t argc = args.size(); CC_UNUSED bool ok = true; if (argc == 1) { - HolderType arg0 = {}; + HolderType arg0 = {}; ok &= sevalue_to_native(args[0], &arg0, s.thisObject()); SE_PRECONDITION2(ok, false, "js_physics_DistanceJoint_initialize : Error processing arguments"); cobj->initialize(arg0.value()); @@ -4769,24 +4672,14 @@ SE_DECLARE_FINALIZE_FUNC(js_cc_physics_DistanceJoint_finalize) static bool js_physics_DistanceJoint_constructor(se::State& s) // NOLINT(readability-identifier-naming) constructor.c { - cc::physics::DistanceJoint* cobj = JSB_ALLOC(cc::physics::DistanceJoint); - s.thisObject()->setPrivateData(cobj); - se::NonRefNativePtrCreatedByCtorMap::emplace(cobj); + auto *ptr = JSB_MAKE_PRIVATE_OBJECT(cc::physics::DistanceJoint); + s.thisObject()->setPrivateObject(ptr); return true; } SE_BIND_CTOR(js_physics_DistanceJoint_constructor, __jsb_cc_physics_DistanceJoint_class, js_cc_physics_DistanceJoint_finalize) - - static bool js_cc_physics_DistanceJoint_finalize(se::State& s) // NOLINT(readability-identifier-naming) { - auto iter = se::NonRefNativePtrCreatedByCtorMap::find(SE_THIS_OBJECT(s)); - if (iter != se::NonRefNativePtrCreatedByCtorMap::end()) - { - se::NonRefNativePtrCreatedByCtorMap::erase(iter); - auto* cobj = SE_THIS_OBJECT(s); - JSB_FREE(cobj); - } return true; } SE_BIND_FINALIZE_FUNC(js_cc_physics_DistanceJoint_finalize) @@ -4811,14 +4704,15 @@ bool js_register_physics_DistanceJoint(se::Object* obj) // NOLINT(readability-id __jsb_cc_physics_DistanceJoint_proto = cls->getProto(); __jsb_cc_physics_DistanceJoint_class = cls; + se::ScriptEngine::getInstance()->clearException(); return true; } -bool register_all_physics(se::Object* obj) +bool register_all_physics(se::Object* obj) // NOLINT { // Get the ns se::Value nsVal; - if (!obj->getProperty("jsb.physics", &nsVal)) + if (!obj->getProperty("jsb.physics", &nsVal, true)) { se::HandleObject jsobj(se::Object::createPlainObject()); nsVal.setObject(jsobj); @@ -4826,18 +4720,19 @@ bool register_all_physics(se::Object* obj) } se::Object* ns = nsVal.toObject(); - js_register_physics_World(ns); - js_register_physics_RigidBody(ns); - js_register_physics_SphereShape(ns); js_register_physics_BoxShape(ns); js_register_physics_CapsuleShape(ns); - js_register_physics_PlaneShape(ns); - js_register_physics_TrimeshShape(ns); - js_register_physics_CylinderShape(ns); js_register_physics_ConeShape(ns); - js_register_physics_TerrainShape(ns); - js_register_physics_RevoluteJoint(ns); + js_register_physics_CylinderShape(ns); js_register_physics_DistanceJoint(ns); + js_register_physics_PlaneShape(ns); + js_register_physics_RevoluteJoint(ns); + js_register_physics_RigidBody(ns); + js_register_physics_SphereShape(ns); + js_register_physics_TerrainShape(ns); + js_register_physics_TrimeshShape(ns); + js_register_physics_World(ns); return true; } +// clang-format on \ No newline at end of file diff --git a/native/cocos/bindings/auto/jsb_physics_auto.h b/native/cocos/bindings/auto/jsb_physics_auto.h index 9d029c2ffe..2d01908b11 100644 --- a/native/cocos/bindings/auto/jsb_physics_auto.h +++ b/native/cocos/bindings/auto/jsb_physics_auto.h @@ -1,3 +1,4 @@ +// clang-format off #pragma once #include "base/Config.h" #include @@ -7,13 +8,27 @@ #include "cocos/bindings/auto/jsb_scene_auto.h" #include "cocos/physics/PhysicsSDK.h" -extern se::Object* __jsb_cc_physics_World_proto; -extern se::Class* __jsb_cc_physics_World_class; - -bool js_register_cc_physics_World(se::Object* obj); -bool register_all_physics(se::Object* obj); +bool register_all_physics(se::Object *obj); // NOLINT JSB_REGISTER_OBJECT_TYPE(cc::physics::World); +JSB_REGISTER_OBJECT_TYPE(cc::physics::RigidBody); +JSB_REGISTER_OBJECT_TYPE(cc::physics::SphereShape); +JSB_REGISTER_OBJECT_TYPE(cc::physics::BoxShape); +JSB_REGISTER_OBJECT_TYPE(cc::physics::CapsuleShape); +JSB_REGISTER_OBJECT_TYPE(cc::physics::PlaneShape); +JSB_REGISTER_OBJECT_TYPE(cc::physics::TrimeshShape); +JSB_REGISTER_OBJECT_TYPE(cc::physics::CylinderShape); +JSB_REGISTER_OBJECT_TYPE(cc::physics::ConeShape); +JSB_REGISTER_OBJECT_TYPE(cc::physics::TerrainShape); +JSB_REGISTER_OBJECT_TYPE(cc::physics::RevoluteJoint); +JSB_REGISTER_OBJECT_TYPE(cc::physics::DistanceJoint); + + +extern se::Object *__jsb_cc_physics_World_proto; // NOLINT +extern se::Class * __jsb_cc_physics_World_class; // NOLINT + +bool js_register_cc_physics_World(se::Object *obj); // NOLINT + SE_DECLARE_FUNC(js_physics_World_createConvex); SE_DECLARE_FUNC(js_physics_World_createHeightField); SE_DECLARE_FUNC(js_physics_World_createMaterial); @@ -34,13 +49,11 @@ SE_DECLARE_FUNC(js_physics_World_syncSceneToPhysics); SE_DECLARE_FUNC(js_physics_World_syncSceneWithCheck); SE_DECLARE_FUNC(js_physics_World_World); -extern se::Object* __jsb_cc_physics_RigidBody_proto; -extern se::Class* __jsb_cc_physics_RigidBody_class; +extern se::Object *__jsb_cc_physics_RigidBody_proto; // NOLINT +extern se::Class * __jsb_cc_physics_RigidBody_class; // NOLINT -bool js_register_cc_physics_RigidBody(se::Object* obj); -bool register_all_physics(se::Object* obj); +bool js_register_cc_physics_RigidBody(se::Object *obj); // NOLINT -JSB_REGISTER_OBJECT_TYPE(cc::physics::RigidBody); SE_DECLARE_FUNC(js_physics_RigidBody_applyForce); SE_DECLARE_FUNC(js_physics_RigidBody_applyImpulse); SE_DECLARE_FUNC(js_physics_RigidBody_applyLocalForce); @@ -82,13 +95,11 @@ SE_DECLARE_FUNC(js_physics_RigidBody_useGravity); SE_DECLARE_FUNC(js_physics_RigidBody_wakeUp); SE_DECLARE_FUNC(js_physics_RigidBody_RigidBody); -extern se::Object* __jsb_cc_physics_SphereShape_proto; -extern se::Class* __jsb_cc_physics_SphereShape_class; +extern se::Object *__jsb_cc_physics_SphereShape_proto; // NOLINT +extern se::Class * __jsb_cc_physics_SphereShape_class; // NOLINT -bool js_register_cc_physics_SphereShape(se::Object* obj); -bool register_all_physics(se::Object* obj); +bool js_register_cc_physics_SphereShape(se::Object *obj); // NOLINT -JSB_REGISTER_OBJECT_TYPE(cc::physics::SphereShape); SE_DECLARE_FUNC(js_physics_SphereShape_getAABB); SE_DECLARE_FUNC(js_physics_SphereShape_getBoundingSphere); SE_DECLARE_FUNC(js_physics_SphereShape_getGroup); @@ -107,13 +118,11 @@ SE_DECLARE_FUNC(js_physics_SphereShape_setRadius); SE_DECLARE_FUNC(js_physics_SphereShape_updateEventListener); SE_DECLARE_FUNC(js_physics_SphereShape_SphereShape); -extern se::Object* __jsb_cc_physics_BoxShape_proto; -extern se::Class* __jsb_cc_physics_BoxShape_class; +extern se::Object *__jsb_cc_physics_BoxShape_proto; // NOLINT +extern se::Class * __jsb_cc_physics_BoxShape_class; // NOLINT -bool js_register_cc_physics_BoxShape(se::Object* obj); -bool register_all_physics(se::Object* obj); +bool js_register_cc_physics_BoxShape(se::Object *obj); // NOLINT -JSB_REGISTER_OBJECT_TYPE(cc::physics::BoxShape); SE_DECLARE_FUNC(js_physics_BoxShape_getAABB); SE_DECLARE_FUNC(js_physics_BoxShape_getBoundingSphere); SE_DECLARE_FUNC(js_physics_BoxShape_getGroup); @@ -132,13 +141,11 @@ SE_DECLARE_FUNC(js_physics_BoxShape_setSize); SE_DECLARE_FUNC(js_physics_BoxShape_updateEventListener); SE_DECLARE_FUNC(js_physics_BoxShape_BoxShape); -extern se::Object* __jsb_cc_physics_CapsuleShape_proto; -extern se::Class* __jsb_cc_physics_CapsuleShape_class; +extern se::Object *__jsb_cc_physics_CapsuleShape_proto; // NOLINT +extern se::Class * __jsb_cc_physics_CapsuleShape_class; // NOLINT -bool js_register_cc_physics_CapsuleShape(se::Object* obj); -bool register_all_physics(se::Object* obj); +bool js_register_cc_physics_CapsuleShape(se::Object *obj); // NOLINT -JSB_REGISTER_OBJECT_TYPE(cc::physics::CapsuleShape); SE_DECLARE_FUNC(js_physics_CapsuleShape_getAABB); SE_DECLARE_FUNC(js_physics_CapsuleShape_getBoundingSphere); SE_DECLARE_FUNC(js_physics_CapsuleShape_getGroup); @@ -159,13 +166,11 @@ SE_DECLARE_FUNC(js_physics_CapsuleShape_setRadius); SE_DECLARE_FUNC(js_physics_CapsuleShape_updateEventListener); SE_DECLARE_FUNC(js_physics_CapsuleShape_CapsuleShape); -extern se::Object* __jsb_cc_physics_PlaneShape_proto; -extern se::Class* __jsb_cc_physics_PlaneShape_class; +extern se::Object *__jsb_cc_physics_PlaneShape_proto; // NOLINT +extern se::Class * __jsb_cc_physics_PlaneShape_class; // NOLINT -bool js_register_cc_physics_PlaneShape(se::Object* obj); -bool register_all_physics(se::Object* obj); +bool js_register_cc_physics_PlaneShape(se::Object *obj); // NOLINT -JSB_REGISTER_OBJECT_TYPE(cc::physics::PlaneShape); SE_DECLARE_FUNC(js_physics_PlaneShape_getAABB); SE_DECLARE_FUNC(js_physics_PlaneShape_getBoundingSphere); SE_DECLARE_FUNC(js_physics_PlaneShape_getGroup); @@ -185,13 +190,11 @@ SE_DECLARE_FUNC(js_physics_PlaneShape_setNormal); SE_DECLARE_FUNC(js_physics_PlaneShape_updateEventListener); SE_DECLARE_FUNC(js_physics_PlaneShape_PlaneShape); -extern se::Object* __jsb_cc_physics_TrimeshShape_proto; -extern se::Class* __jsb_cc_physics_TrimeshShape_class; +extern se::Object *__jsb_cc_physics_TrimeshShape_proto; // NOLINT +extern se::Class * __jsb_cc_physics_TrimeshShape_class; // NOLINT -bool js_register_cc_physics_TrimeshShape(se::Object* obj); -bool register_all_physics(se::Object* obj); +bool js_register_cc_physics_TrimeshShape(se::Object *obj); // NOLINT -JSB_REGISTER_OBJECT_TYPE(cc::physics::TrimeshShape); SE_DECLARE_FUNC(js_physics_TrimeshShape_getAABB); SE_DECLARE_FUNC(js_physics_TrimeshShape_getBoundingSphere); SE_DECLARE_FUNC(js_physics_TrimeshShape_getGroup); @@ -211,13 +214,11 @@ SE_DECLARE_FUNC(js_physics_TrimeshShape_updateEventListener); SE_DECLARE_FUNC(js_physics_TrimeshShape_useConvex); SE_DECLARE_FUNC(js_physics_TrimeshShape_TrimeshShape); -extern se::Object* __jsb_cc_physics_CylinderShape_proto; -extern se::Class* __jsb_cc_physics_CylinderShape_class; +extern se::Object *__jsb_cc_physics_CylinderShape_proto; // NOLINT +extern se::Class * __jsb_cc_physics_CylinderShape_class; // NOLINT -bool js_register_cc_physics_CylinderShape(se::Object* obj); -bool register_all_physics(se::Object* obj); +bool js_register_cc_physics_CylinderShape(se::Object *obj); // NOLINT -JSB_REGISTER_OBJECT_TYPE(cc::physics::CylinderShape); SE_DECLARE_FUNC(js_physics_CylinderShape_getAABB); SE_DECLARE_FUNC(js_physics_CylinderShape_getBoundingSphere); SE_DECLARE_FUNC(js_physics_CylinderShape_getGroup); @@ -237,13 +238,11 @@ SE_DECLARE_FUNC(js_physics_CylinderShape_setMaterial); SE_DECLARE_FUNC(js_physics_CylinderShape_updateEventListener); SE_DECLARE_FUNC(js_physics_CylinderShape_CylinderShape); -extern se::Object* __jsb_cc_physics_ConeShape_proto; -extern se::Class* __jsb_cc_physics_ConeShape_class; +extern se::Object *__jsb_cc_physics_ConeShape_proto; // NOLINT +extern se::Class * __jsb_cc_physics_ConeShape_class; // NOLINT -bool js_register_cc_physics_ConeShape(se::Object* obj); -bool register_all_physics(se::Object* obj); +bool js_register_cc_physics_ConeShape(se::Object *obj); // NOLINT -JSB_REGISTER_OBJECT_TYPE(cc::physics::ConeShape); SE_DECLARE_FUNC(js_physics_ConeShape_getAABB); SE_DECLARE_FUNC(js_physics_ConeShape_getBoundingSphere); SE_DECLARE_FUNC(js_physics_ConeShape_getGroup); @@ -263,13 +262,11 @@ SE_DECLARE_FUNC(js_physics_ConeShape_setMaterial); SE_DECLARE_FUNC(js_physics_ConeShape_updateEventListener); SE_DECLARE_FUNC(js_physics_ConeShape_ConeShape); -extern se::Object* __jsb_cc_physics_TerrainShape_proto; -extern se::Class* __jsb_cc_physics_TerrainShape_class; +extern se::Object *__jsb_cc_physics_TerrainShape_proto; // NOLINT +extern se::Class * __jsb_cc_physics_TerrainShape_class; // NOLINT -bool js_register_cc_physics_TerrainShape(se::Object* obj); -bool register_all_physics(se::Object* obj); +bool js_register_cc_physics_TerrainShape(se::Object *obj); // NOLINT -JSB_REGISTER_OBJECT_TYPE(cc::physics::TerrainShape); SE_DECLARE_FUNC(js_physics_TerrainShape_getAABB); SE_DECLARE_FUNC(js_physics_TerrainShape_getBoundingSphere); SE_DECLARE_FUNC(js_physics_TerrainShape_getGroup); @@ -288,13 +285,11 @@ SE_DECLARE_FUNC(js_physics_TerrainShape_setTerrain); SE_DECLARE_FUNC(js_physics_TerrainShape_updateEventListener); SE_DECLARE_FUNC(js_physics_TerrainShape_TerrainShape); -extern se::Object* __jsb_cc_physics_RevoluteJoint_proto; -extern se::Class* __jsb_cc_physics_RevoluteJoint_class; +extern se::Object *__jsb_cc_physics_RevoluteJoint_proto; // NOLINT +extern se::Class * __jsb_cc_physics_RevoluteJoint_class; // NOLINT -bool js_register_cc_physics_RevoluteJoint(se::Object* obj); -bool register_all_physics(se::Object* obj); +bool js_register_cc_physics_RevoluteJoint(se::Object *obj); // NOLINT -JSB_REGISTER_OBJECT_TYPE(cc::physics::RevoluteJoint); SE_DECLARE_FUNC(js_physics_RevoluteJoint_getImpl); SE_DECLARE_FUNC(js_physics_RevoluteJoint_initialize); SE_DECLARE_FUNC(js_physics_RevoluteJoint_onDestroy); @@ -307,13 +302,11 @@ SE_DECLARE_FUNC(js_physics_RevoluteJoint_setPivotA); SE_DECLARE_FUNC(js_physics_RevoluteJoint_setPivotB); SE_DECLARE_FUNC(js_physics_RevoluteJoint_RevoluteJoint); -extern se::Object* __jsb_cc_physics_DistanceJoint_proto; -extern se::Class* __jsb_cc_physics_DistanceJoint_class; +extern se::Object *__jsb_cc_physics_DistanceJoint_proto; // NOLINT +extern se::Class * __jsb_cc_physics_DistanceJoint_class; // NOLINT -bool js_register_cc_physics_DistanceJoint(se::Object* obj); -bool register_all_physics(se::Object* obj); +bool js_register_cc_physics_DistanceJoint(se::Object *obj); // NOLINT -JSB_REGISTER_OBJECT_TYPE(cc::physics::DistanceJoint); SE_DECLARE_FUNC(js_physics_DistanceJoint_getImpl); SE_DECLARE_FUNC(js_physics_DistanceJoint_initialize); SE_DECLARE_FUNC(js_physics_DistanceJoint_onDestroy); @@ -324,4 +317,4 @@ SE_DECLARE_FUNC(js_physics_DistanceJoint_setEnableCollision); SE_DECLARE_FUNC(js_physics_DistanceJoint_setPivotA); SE_DECLARE_FUNC(js_physics_DistanceJoint_setPivotB); SE_DECLARE_FUNC(js_physics_DistanceJoint_DistanceJoint); - + // clang-format on \ No newline at end of file diff --git a/native/cocos/bindings/auto/jsb_pipeline_auto.cpp b/native/cocos/bindings/auto/jsb_pipeline_auto.cpp index 2a08ecde5e..5b01fbd145 100644 --- a/native/cocos/bindings/auto/jsb_pipeline_auto.cpp +++ b/native/cocos/bindings/auto/jsb_pipeline_auto.cpp @@ -1,3 +1,5 @@ + +// clang-format off #include "cocos/bindings/auto/jsb_pipeline_auto.h" #include "cocos/bindings/manual/jsb_conversions.h" #include "cocos/bindings/manual/jsb_global.h" @@ -18,6 +20,8 @@ #include "renderer/pipeline/deferred/LightingStage.h" #include "renderer/pipeline/deferred/BloomStage.h" #include "renderer/pipeline/deferred/PostProcessStage.h" +#include "renderer/pipeline/PipelineSceneData.h" +#include "renderer/pipeline/BatchedBuffer.h" #include "renderer/pipeline/GeometryRenderer.h" #include "cocos/renderer/gfx-base/GFXDevice.h" @@ -28,8 +32,161 @@ #ifndef JSB_FREE #define JSB_FREE(ptr) delete ptr #endif -se::Object* __jsb_cc_pipeline_RenderQueueDesc_proto = nullptr; -se::Class* __jsb_cc_pipeline_RenderQueueDesc_class = nullptr; +se::Object* __jsb_cc_pipeline_RenderObject_proto = nullptr; // NOLINT +se::Class* __jsb_cc_pipeline_RenderObject_class = nullptr; // NOLINT + +static bool js_pipeline_RenderObject_get_depth(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_pipeline_RenderObject_get_depth : Invalid Native Object"); + + CC_UNUSED bool ok = true; + se::Value jsret; + ok &= nativevalue_to_se(cobj->depth, jsret, s.thisObject() /*ctx*/); + s.rval() = jsret; + SE_HOLD_RETURN_VALUE(cobj->depth, s.thisObject(), s.rval()); + return true; +} +SE_BIND_PROP_GET(js_pipeline_RenderObject_get_depth) + +static bool js_pipeline_RenderObject_set_depth(se::State& s) // NOLINT(readability-identifier-naming) +{ + const auto& args = s.args(); + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_pipeline_RenderObject_set_depth : Invalid Native Object"); + + CC_UNUSED bool ok = true; + ok &= sevalue_to_native(args[0], &cobj->depth, s.thisObject()); + SE_PRECONDITION2(ok, false, "js_pipeline_RenderObject_set_depth : Error processing new value"); + return true; +} +SE_BIND_PROP_SET(js_pipeline_RenderObject_set_depth) + +static bool js_pipeline_RenderObject_get_model(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_pipeline_RenderObject_get_model : Invalid Native Object"); + + CC_UNUSED bool ok = true; + se::Value jsret; + ok &= nativevalue_to_se(cobj->model, jsret, s.thisObject() /*ctx*/); + s.rval() = jsret; + SE_HOLD_RETURN_VALUE(cobj->model, s.thisObject(), s.rval()); + return true; +} +SE_BIND_PROP_GET(js_pipeline_RenderObject_get_model) + +static bool js_pipeline_RenderObject_set_model(se::State& s) // NOLINT(readability-identifier-naming) +{ + const auto& args = s.args(); + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_pipeline_RenderObject_set_model : Invalid Native Object"); + + CC_UNUSED bool ok = true; + ok &= sevalue_to_native(args[0], &cobj->model, s.thisObject()); + SE_PRECONDITION2(ok, false, "js_pipeline_RenderObject_set_model : Error processing new value"); + return true; +} +SE_BIND_PROP_SET(js_pipeline_RenderObject_set_model) + + +template<> +bool sevalue_to_native(const se::Value &from, cc::pipeline::RenderObject * to, se::Object *ctx) +{ + assert(from.isObject()); + se::Object *json = from.toObject(); + auto* data = reinterpret_cast(json->getPrivateData()); + if (data) { + *to = *data; + return true; + } + se::Value field; + bool ok = true; + json->getProperty("depth", &field, true); + if(!field.isNullOrUndefined()) { + ok &= sevalue_to_native(field, &(to->depth), ctx); + } + json->getProperty("model", &field, true); + if(!field.isNullOrUndefined()) { + ok &= sevalue_to_native(field, &(to->model), ctx); + } + return ok; +} + +SE_DECLARE_FINALIZE_FUNC(js_cc_pipeline_RenderObject_finalize) + +static bool js_pipeline_RenderObject_constructor(se::State& s) // NOLINT(readability-identifier-naming) +{ + CC_UNUSED bool ok = true; + const auto& args = s.args(); + size_t argc = args.size(); + + if(argc == 0) + { + auto *ptr = JSB_MAKE_PRIVATE_OBJECT(cc::pipeline::RenderObject); + s.thisObject()->setPrivateObject(ptr); + return true; + } + + if(argc == 1 && args[0].isObject()) + { + se::Object *json = args[0].toObject(); + se::Value field; + auto *ptr = JSB_MAKE_PRIVATE_OBJECT(cc::pipeline::RenderObject); + auto cobj = ptr->get(); + ok &= sevalue_to_native(args[0], cobj, s.thisObject()); + if(!ok) { + delete ptr; + SE_REPORT_ERROR("argument convertion error"); + return false; + } + s.thisObject()->setPrivateObject(ptr); + return true; + } + auto *ptr = JSB_MAKE_PRIVATE_OBJECT(cc::pipeline::RenderObject); + auto cobj = ptr->get(); + if (argc > 0 && !args[0].isUndefined()) { + ok &= sevalue_to_native(args[0], &(cobj->depth), nullptr); + } + if (argc > 1 && !args[1].isUndefined()) { + ok &= sevalue_to_native(args[1], &(cobj->model), nullptr); + } + + if(!ok) { + delete ptr; + SE_REPORT_ERROR("Argument convertion error"); + return false; + } + s.thisObject()->setPrivateObject(ptr); + return true; +} +SE_BIND_CTOR(js_pipeline_RenderObject_constructor, __jsb_cc_pipeline_RenderObject_class, js_cc_pipeline_RenderObject_finalize) + +static bool js_cc_pipeline_RenderObject_finalize(se::State& s) // NOLINT(readability-identifier-naming) +{ + return true; +} +SE_BIND_FINALIZE_FUNC(js_cc_pipeline_RenderObject_finalize) + +bool js_register_pipeline_RenderObject(se::Object* obj) // NOLINT(readability-identifier-naming) +{ + auto* cls = se::Class::create("RenderObject", obj, nullptr, _SE(js_pipeline_RenderObject_constructor)); + + cls->defineProperty("depth", _SE(js_pipeline_RenderObject_get_depth), _SE(js_pipeline_RenderObject_set_depth)); + cls->defineProperty("model", _SE(js_pipeline_RenderObject_get_model), _SE(js_pipeline_RenderObject_set_model)); + cls->defineFinalizeFunction(_SE(js_cc_pipeline_RenderObject_finalize)); + cls->install(); + JSBClassType::registerClass(cls); + + __jsb_cc_pipeline_RenderObject_proto = cls->getProto(); + __jsb_cc_pipeline_RenderObject_class = cls; + + + se::ScriptEngine::getInstance()->clearException(); + return true; +} +se::Object* __jsb_cc_pipeline_RenderQueueDesc_proto = nullptr; // NOLINT +se::Class* __jsb_cc_pipeline_RenderQueueDesc_class = nullptr; // NOLINT static bool js_pipeline_RenderQueueDesc_get_isTransparent(se::State& s) // NOLINT(readability-identifier-naming) { @@ -125,15 +282,15 @@ bool sevalue_to_native(const se::Value &from, cc::pipeline::RenderQueueDesc * to } se::Value field; bool ok = true; - json->getProperty("isTransparent", &field); + json->getProperty("isTransparent", &field, true); if(!field.isNullOrUndefined()) { ok &= sevalue_to_native(field, &(to->isTransparent), ctx); } - json->getProperty("sortMode", &field); + json->getProperty("sortMode", &field, true); if(!field.isNullOrUndefined()) { ok &= sevalue_to_native(field, &(to->sortMode), ctx); } - json->getProperty("stages", &field); + json->getProperty("stages", &field, true); if(!field.isNullOrUndefined()) { ok &= sevalue_to_native(field, &(to->stages), ctx); } @@ -150,9 +307,8 @@ static bool js_pipeline_RenderQueueDesc_constructor(se::State& s) // NOLINT(read if(argc == 0) { - cc::pipeline::RenderQueueDesc* cobj = JSB_ALLOC(cc::pipeline::RenderQueueDesc); - s.thisObject()->setPrivateData(cobj); - se::NonRefNativePtrCreatedByCtorMap::emplace(cobj); + auto *ptr = JSB_MAKE_PRIVATE_OBJECT(cc::pipeline::RenderQueueDesc); + s.thisObject()->setPrivateObject(ptr); return true; } @@ -160,21 +316,19 @@ static bool js_pipeline_RenderQueueDesc_constructor(se::State& s) // NOLINT(read { se::Object *json = args[0].toObject(); se::Value field; - - cc::pipeline::RenderQueueDesc* cobj = JSB_ALLOC(cc::pipeline::RenderQueueDesc); + auto *ptr = JSB_MAKE_PRIVATE_OBJECT(cc::pipeline::RenderQueueDesc); + auto cobj = ptr->get(); ok &= sevalue_to_native(args[0], cobj, s.thisObject()); if(!ok) { - JSB_FREE(cobj); + delete ptr; SE_REPORT_ERROR("argument convertion error"); return false; } - - s.thisObject()->setPrivateData(cobj); - se::NonRefNativePtrCreatedByCtorMap::emplace(cobj); + s.thisObject()->setPrivateObject(ptr); return true; } - - cc::pipeline::RenderQueueDesc* cobj = JSB_ALLOC(cc::pipeline::RenderQueueDesc); + auto *ptr = JSB_MAKE_PRIVATE_OBJECT(cc::pipeline::RenderQueueDesc); + auto cobj = ptr->get(); if (argc > 0 && !args[0].isUndefined()) { ok &= sevalue_to_native(args[0], &(cobj->isTransparent), nullptr); } @@ -186,28 +340,17 @@ static bool js_pipeline_RenderQueueDesc_constructor(se::State& s) // NOLINT(read } if(!ok) { - JSB_FREE(cobj); + delete ptr; SE_REPORT_ERROR("Argument convertion error"); return false; } - - s.thisObject()->setPrivateData(cobj); - se::NonRefNativePtrCreatedByCtorMap::emplace(cobj); + s.thisObject()->setPrivateObject(ptr); return true; } SE_BIND_CTOR(js_pipeline_RenderQueueDesc_constructor, __jsb_cc_pipeline_RenderQueueDesc_class, js_cc_pipeline_RenderQueueDesc_finalize) - - static bool js_cc_pipeline_RenderQueueDesc_finalize(se::State& s) // NOLINT(readability-identifier-naming) { - auto iter = se::NonRefNativePtrCreatedByCtorMap::find(SE_THIS_OBJECT(s)); - if (iter != se::NonRefNativePtrCreatedByCtorMap::end()) - { - se::NonRefNativePtrCreatedByCtorMap::erase(iter); - auto* cobj = SE_THIS_OBJECT(s); - JSB_FREE(cobj); - } return true; } SE_BIND_FINALIZE_FUNC(js_cc_pipeline_RenderQueueDesc_finalize) @@ -226,11 +369,12 @@ bool js_register_pipeline_RenderQueueDesc(se::Object* obj) // NOLINT(readability __jsb_cc_pipeline_RenderQueueDesc_proto = cls->getProto(); __jsb_cc_pipeline_RenderQueueDesc_class = cls; + se::ScriptEngine::getInstance()->clearException(); return true; } -se::Object* __jsb_cc_pipeline_GlobalDSManager_proto = nullptr; -se::Class* __jsb_cc_pipeline_GlobalDSManager_class = nullptr; +se::Object* __jsb_cc_pipeline_GlobalDSManager_proto = nullptr; // NOLINT +se::Class* __jsb_cc_pipeline_GlobalDSManager_class = nullptr; // NOLINT static bool js_pipeline_GlobalDSManager_bindBuffer(se::State& s) // NOLINT(readability-identifier-naming) { @@ -427,28 +571,31 @@ static bool js_pipeline_GlobalDSManager_update(se::State& s) // NOLINT(readabili } SE_BIND_FUNC(js_pipeline_GlobalDSManager_update) +static bool js_pipeline_GlobalDSManager_setDescriptorSetLayout_static(se::State& s) // NOLINT(readability-identifier-naming) +{ + const auto& args = s.args(); + size_t argc = args.size(); + if (argc == 0) { + cc::pipeline::GlobalDSManager::setDescriptorSetLayout(); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 0); + return false; +} +SE_BIND_FUNC(js_pipeline_GlobalDSManager_setDescriptorSetLayout_static) + SE_DECLARE_FINALIZE_FUNC(js_cc_pipeline_GlobalDSManager_finalize) static bool js_pipeline_GlobalDSManager_constructor(se::State& s) // NOLINT(readability-identifier-naming) constructor.c { - cc::pipeline::GlobalDSManager* cobj = JSB_ALLOC(cc::pipeline::GlobalDSManager); - s.thisObject()->setPrivateData(cobj); - se::NonRefNativePtrCreatedByCtorMap::emplace(cobj); + auto *ptr = JSB_MAKE_PRIVATE_OBJECT(cc::pipeline::GlobalDSManager); + s.thisObject()->setPrivateObject(ptr); return true; } SE_BIND_CTOR(js_pipeline_GlobalDSManager_constructor, __jsb_cc_pipeline_GlobalDSManager_class, js_cc_pipeline_GlobalDSManager_finalize) - - static bool js_cc_pipeline_GlobalDSManager_finalize(se::State& s) // NOLINT(readability-identifier-naming) { - auto iter = se::NonRefNativePtrCreatedByCtorMap::find(SE_THIS_OBJECT(s)); - if (iter != se::NonRefNativePtrCreatedByCtorMap::end()) - { - se::NonRefNativePtrCreatedByCtorMap::erase(iter); - auto* cobj = SE_THIS_OBJECT(s); - JSB_FREE(cobj); - } return true; } SE_BIND_FINALIZE_FUNC(js_cc_pipeline_GlobalDSManager_finalize) @@ -467,6 +614,7 @@ bool js_register_pipeline_GlobalDSManager(se::Object* obj) // NOLINT(readability cls->defineFunction("getOrCreateDescriptorSet", _SE(js_pipeline_GlobalDSManager_getOrCreateDescriptorSet)); cls->defineFunction("getPointSampler", _SE(js_pipeline_GlobalDSManager_getPointSampler)); cls->defineFunction("update", _SE(js_pipeline_GlobalDSManager_update)); + cls->defineStaticFunction("setDescriptorSetLayout", _SE(js_pipeline_GlobalDSManager_setDescriptorSetLayout_static)); cls->defineFinalizeFunction(_SE(js_cc_pipeline_GlobalDSManager_finalize)); cls->install(); JSBClassType::registerClass(cls); @@ -474,11 +622,700 @@ bool js_register_pipeline_GlobalDSManager(se::Object* obj) // NOLINT(readability __jsb_cc_pipeline_GlobalDSManager_proto = cls->getProto(); __jsb_cc_pipeline_GlobalDSManager_class = cls; + se::ScriptEngine::getInstance()->clearException(); return true; } -se::Object* __jsb_cc_pipeline_RenderPipelineInfo_proto = nullptr; -se::Class* __jsb_cc_pipeline_RenderPipelineInfo_class = nullptr; +se::Object* __jsb_cc_pipeline_PipelineSceneData_proto = nullptr; // NOLINT +se::Class* __jsb_cc_pipeline_PipelineSceneData_class = nullptr; // NOLINT + +static bool js_pipeline_PipelineSceneData_activate(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_pipeline_PipelineSceneData_activate : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 2) { + HolderType arg0 = {}; + HolderType arg1 = {}; + ok &= sevalue_to_native(args[0], &arg0, s.thisObject()); + ok &= sevalue_to_native(args[1], &arg1, s.thisObject()); + SE_PRECONDITION2(ok, false, "js_pipeline_PipelineSceneData_activate : Error processing arguments"); + cobj->activate(arg0.value(), arg1.value()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 2); + return false; +} +SE_BIND_FUNC(js_pipeline_PipelineSceneData_activate) + +static bool js_pipeline_PipelineSceneData_destroy(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_pipeline_PipelineSceneData_destroy : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + if (argc == 0) { + cobj->destroy(); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 0); + return false; +} +SE_BIND_FUNC(js_pipeline_PipelineSceneData_destroy) + +static bool js_pipeline_PipelineSceneData_getAmbient(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_pipeline_PipelineSceneData_getAmbient : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 0) { + cc::scene::Ambient* result = cobj->getAmbient(); + ok &= nativevalue_to_se(result, s.rval(), nullptr /*ctx*/); + SE_PRECONDITION2(ok, false, "js_pipeline_PipelineSceneData_getAmbient : Error processing arguments"); + SE_HOLD_RETURN_VALUE(result, s.thisObject(), s.rval()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 0); + return false; +} +SE_BIND_FUNC_AS_PROP_GET(js_pipeline_PipelineSceneData_getAmbient) + +static bool js_pipeline_PipelineSceneData_getDirShadowObjects(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_pipeline_PipelineSceneData_getDirShadowObjects : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 0) { + const std::vector& result = cobj->getDirShadowObjects(); + ok &= nativevalue_to_se(result, s.rval(), nullptr /*ctx*/); + SE_PRECONDITION2(ok, false, "js_pipeline_PipelineSceneData_getDirShadowObjects : Error processing arguments"); + SE_HOLD_RETURN_VALUE(result, s.thisObject(), s.rval()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 0); + return false; +} +SE_BIND_FUNC(js_pipeline_PipelineSceneData_getDirShadowObjects) + +static bool js_pipeline_PipelineSceneData_getFog(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_pipeline_PipelineSceneData_getFog : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 0) { + cc::scene::Fog* result = cobj->getFog(); + ok &= nativevalue_to_se(result, s.rval(), nullptr /*ctx*/); + SE_PRECONDITION2(ok, false, "js_pipeline_PipelineSceneData_getFog : Error processing arguments"); + SE_HOLD_RETURN_VALUE(result, s.thisObject(), s.rval()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 0); + return false; +} +SE_BIND_FUNC_AS_PROP_GET(js_pipeline_PipelineSceneData_getFog) + +static bool js_pipeline_PipelineSceneData_getGeometryRendererMaterials(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_pipeline_PipelineSceneData_getGeometryRendererMaterials : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 0) { + const std::vector>& result = cobj->getGeometryRendererMaterials(); + ok &= nativevalue_to_se(result, s.rval(), nullptr /*ctx*/); + SE_PRECONDITION2(ok, false, "js_pipeline_PipelineSceneData_getGeometryRendererMaterials : Error processing arguments"); + SE_HOLD_RETURN_VALUE(result, s.thisObject(), s.rval()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 0); + return false; +} +SE_BIND_FUNC(js_pipeline_PipelineSceneData_getGeometryRendererMaterials) + +static bool js_pipeline_PipelineSceneData_getGeometryRendererPasses(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_pipeline_PipelineSceneData_getGeometryRendererPasses : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 0) { + const std::vector& result = cobj->getGeometryRendererPasses(); + ok &= nativevalue_to_se(result, s.rval(), nullptr /*ctx*/); + SE_PRECONDITION2(ok, false, "js_pipeline_PipelineSceneData_getGeometryRendererPasses : Error processing arguments"); + SE_HOLD_RETURN_VALUE(result, s.thisObject(), s.rval()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 0); + return false; +} +SE_BIND_FUNC(js_pipeline_PipelineSceneData_getGeometryRendererPasses) + +static bool js_pipeline_PipelineSceneData_getGeometryRendererShaders(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_pipeline_PipelineSceneData_getGeometryRendererShaders : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 0) { + const std::vector& result = cobj->getGeometryRendererShaders(); + ok &= nativevalue_to_se(result, s.rval(), nullptr /*ctx*/); + SE_PRECONDITION2(ok, false, "js_pipeline_PipelineSceneData_getGeometryRendererShaders : Error processing arguments"); + SE_HOLD_RETURN_VALUE(result, s.thisObject(), s.rval()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 0); + return false; +} +SE_BIND_FUNC(js_pipeline_PipelineSceneData_getGeometryRendererShaders) + +static bool js_pipeline_PipelineSceneData_getMatShadowProj(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_pipeline_PipelineSceneData_getMatShadowProj : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 0) { + cc::Mat4 result = cobj->getMatShadowProj(); + ok &= nativevalue_to_se(result, s.rval(), nullptr /*ctx*/); + SE_PRECONDITION2(ok, false, "js_pipeline_PipelineSceneData_getMatShadowProj : Error processing arguments"); + SE_HOLD_RETURN_VALUE(result, s.thisObject(), s.rval()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 0); + return false; +} +SE_BIND_FUNC(js_pipeline_PipelineSceneData_getMatShadowProj) + +static bool js_pipeline_PipelineSceneData_getMatShadowView(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_pipeline_PipelineSceneData_getMatShadowView : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 0) { + cc::Mat4 result = cobj->getMatShadowView(); + ok &= nativevalue_to_se(result, s.rval(), nullptr /*ctx*/); + SE_PRECONDITION2(ok, false, "js_pipeline_PipelineSceneData_getMatShadowView : Error processing arguments"); + SE_HOLD_RETURN_VALUE(result, s.thisObject(), s.rval()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 0); + return false; +} +SE_BIND_FUNC(js_pipeline_PipelineSceneData_getMatShadowView) + +static bool js_pipeline_PipelineSceneData_getMatShadowViewProj(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_pipeline_PipelineSceneData_getMatShadowViewProj : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 0) { + cc::Mat4 result = cobj->getMatShadowViewProj(); + ok &= nativevalue_to_se(result, s.rval(), nullptr /*ctx*/); + SE_PRECONDITION2(ok, false, "js_pipeline_PipelineSceneData_getMatShadowViewProj : Error processing arguments"); + SE_HOLD_RETURN_VALUE(result, s.thisObject(), s.rval()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 0); + return false; +} +SE_BIND_FUNC(js_pipeline_PipelineSceneData_getMatShadowViewProj) + +static bool js_pipeline_PipelineSceneData_getOcclusionQueryInputAssembler(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_pipeline_PipelineSceneData_getOcclusionQueryInputAssembler : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 0) { + cc::gfx::InputAssembler* result = cobj->getOcclusionQueryInputAssembler(); + ok &= nativevalue_to_se(result, s.rval(), nullptr /*ctx*/); + SE_PRECONDITION2(ok, false, "js_pipeline_PipelineSceneData_getOcclusionQueryInputAssembler : Error processing arguments"); + SE_HOLD_RETURN_VALUE(result, s.thisObject(), s.rval()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 0); + return false; +} +SE_BIND_FUNC(js_pipeline_PipelineSceneData_getOcclusionQueryInputAssembler) + +static bool js_pipeline_PipelineSceneData_getOcclusionQueryPass(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_pipeline_PipelineSceneData_getOcclusionQueryPass : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 0) { + cc::scene::Pass* result = cobj->getOcclusionQueryPass(); + ok &= nativevalue_to_se(result, s.rval(), nullptr /*ctx*/); + SE_PRECONDITION2(ok, false, "js_pipeline_PipelineSceneData_getOcclusionQueryPass : Error processing arguments"); + SE_HOLD_RETURN_VALUE(result, s.thisObject(), s.rval()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 0); + return false; +} +SE_BIND_FUNC(js_pipeline_PipelineSceneData_getOcclusionQueryPass) + +static bool js_pipeline_PipelineSceneData_getOcclusionQueryShader(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_pipeline_PipelineSceneData_getOcclusionQueryShader : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 0) { + cc::gfx::Shader* result = cobj->getOcclusionQueryShader(); + ok &= nativevalue_to_se(result, s.rval(), nullptr /*ctx*/); + SE_PRECONDITION2(ok, false, "js_pipeline_PipelineSceneData_getOcclusionQueryShader : Error processing arguments"); + SE_HOLD_RETURN_VALUE(result, s.thisObject(), s.rval()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 0); + return false; +} +SE_BIND_FUNC(js_pipeline_PipelineSceneData_getOcclusionQueryShader) + +static bool js_pipeline_PipelineSceneData_getOctree(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_pipeline_PipelineSceneData_getOctree : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 0) { + cc::scene::Octree* result = cobj->getOctree(); + ok &= nativevalue_to_se(result, s.rval(), nullptr /*ctx*/); + SE_PRECONDITION2(ok, false, "js_pipeline_PipelineSceneData_getOctree : Error processing arguments"); + SE_HOLD_RETURN_VALUE(result, s.thisObject(), s.rval()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 0); + return false; +} +SE_BIND_FUNC(js_pipeline_PipelineSceneData_getOctree) + +static bool js_pipeline_PipelineSceneData_getShadingScale(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_pipeline_PipelineSceneData_getShadingScale : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 0) { + float result = cobj->getShadingScale(); + ok &= nativevalue_to_se(result, s.rval(), nullptr /*ctx*/); + SE_PRECONDITION2(ok, false, "js_pipeline_PipelineSceneData_getShadingScale : Error processing arguments"); + SE_HOLD_RETURN_VALUE(result, s.thisObject(), s.rval()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 0); + return false; +} +SE_BIND_FUNC_AS_PROP_GET(js_pipeline_PipelineSceneData_getShadingScale) + +static bool js_pipeline_PipelineSceneData_getShadowCameraFar(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_pipeline_PipelineSceneData_getShadowCameraFar : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 0) { + float result = cobj->getShadowCameraFar(); + ok &= nativevalue_to_se(result, s.rval(), nullptr /*ctx*/); + SE_PRECONDITION2(ok, false, "js_pipeline_PipelineSceneData_getShadowCameraFar : Error processing arguments"); + SE_HOLD_RETURN_VALUE(result, s.thisObject(), s.rval()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 0); + return false; +} +SE_BIND_FUNC(js_pipeline_PipelineSceneData_getShadowCameraFar) + +static bool js_pipeline_PipelineSceneData_getShadows(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_pipeline_PipelineSceneData_getShadows : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 0) { + cc::scene::Shadows* result = cobj->getShadows(); + ok &= nativevalue_to_se(result, s.rval(), nullptr /*ctx*/); + SE_PRECONDITION2(ok, false, "js_pipeline_PipelineSceneData_getShadows : Error processing arguments"); + SE_HOLD_RETURN_VALUE(result, s.thisObject(), s.rval()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 0); + return false; +} +SE_BIND_FUNC_AS_PROP_GET(js_pipeline_PipelineSceneData_getShadows) + +static bool js_pipeline_PipelineSceneData_getSkybox(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_pipeline_PipelineSceneData_getSkybox : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 0) { + cc::scene::Skybox* result = cobj->getSkybox(); + ok &= nativevalue_to_se(result, s.rval(), nullptr /*ctx*/); + SE_PRECONDITION2(ok, false, "js_pipeline_PipelineSceneData_getSkybox : Error processing arguments"); + SE_HOLD_RETURN_VALUE(result, s.thisObject(), s.rval()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 0); + return false; +} +SE_BIND_FUNC_AS_PROP_GET(js_pipeline_PipelineSceneData_getSkybox) + +static bool js_pipeline_PipelineSceneData_getValidPunctualLights(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_pipeline_PipelineSceneData_getValidPunctualLights : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 0) { + const std::vector& result = cobj->getValidPunctualLights(); + ok &= nativevalue_to_se(result, s.rval(), nullptr /*ctx*/); + SE_PRECONDITION2(ok, false, "js_pipeline_PipelineSceneData_getValidPunctualLights : Error processing arguments"); + SE_HOLD_RETURN_VALUE(result, s.thisObject(), s.rval()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 0); + return false; +} +SE_BIND_FUNC(js_pipeline_PipelineSceneData_getValidPunctualLights) + +static bool js_pipeline_PipelineSceneData_isCastShadowObjects(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_pipeline_PipelineSceneData_isCastShadowObjects : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 0) { + const std::vector& result = cobj->isCastShadowObjects(); + ok &= nativevalue_to_se(result, s.rval(), nullptr /*ctx*/); + SE_PRECONDITION2(ok, false, "js_pipeline_PipelineSceneData_isCastShadowObjects : Error processing arguments"); + SE_HOLD_RETURN_VALUE(result, s.thisObject(), s.rval()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 0); + return false; +} +SE_BIND_FUNC(js_pipeline_PipelineSceneData_isCastShadowObjects) + +static bool js_pipeline_PipelineSceneData_isHDR(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_pipeline_PipelineSceneData_isHDR : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 0) { + bool result = cobj->isHDR(); + ok &= nativevalue_to_se(result, s.rval(), nullptr /*ctx*/); + SE_PRECONDITION2(ok, false, "js_pipeline_PipelineSceneData_isHDR : Error processing arguments"); + SE_HOLD_RETURN_VALUE(result, s.thisObject(), s.rval()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 0); + return false; +} +SE_BIND_FUNC_AS_PROP_GET(js_pipeline_PipelineSceneData_isHDR) + +static bool js_pipeline_PipelineSceneData_onGlobalPipelineStateChanged(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_pipeline_PipelineSceneData_onGlobalPipelineStateChanged : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + if (argc == 0) { + cobj->onGlobalPipelineStateChanged(); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 0); + return false; +} +SE_BIND_FUNC(js_pipeline_PipelineSceneData_onGlobalPipelineStateChanged) + +static bool js_pipeline_PipelineSceneData_setCastShadowObjects(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_pipeline_PipelineSceneData_setCastShadowObjects : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 1) { + HolderType, true> arg0 = {}; + ok &= sevalue_to_native(args[0], &arg0, s.thisObject()); + SE_PRECONDITION2(ok, false, "js_pipeline_PipelineSceneData_setCastShadowObjects : Error processing arguments"); + cobj->setCastShadowObjects(std::move(arg0.value())); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 1); + return false; +} +SE_BIND_FUNC(js_pipeline_PipelineSceneData_setCastShadowObjects) + +static bool js_pipeline_PipelineSceneData_setDirShadowObjects(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_pipeline_PipelineSceneData_setDirShadowObjects : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 1) { + HolderType, true> arg0 = {}; + ok &= sevalue_to_native(args[0], &arg0, s.thisObject()); + SE_PRECONDITION2(ok, false, "js_pipeline_PipelineSceneData_setDirShadowObjects : Error processing arguments"); + cobj->setDirShadowObjects(std::move(arg0.value())); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 1); + return false; +} +SE_BIND_FUNC(js_pipeline_PipelineSceneData_setDirShadowObjects) + +static bool js_pipeline_PipelineSceneData_setHDR(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_pipeline_PipelineSceneData_setHDR : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 1) { + HolderType arg0 = {}; + ok &= sevalue_to_native(args[0], &arg0, s.thisObject()); + SE_PRECONDITION2(ok, false, "js_pipeline_PipelineSceneData_setHDR : Error processing arguments"); + cobj->setHDR(arg0.value()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 1); + return false; +} +SE_BIND_FUNC_AS_PROP_SET(js_pipeline_PipelineSceneData_setHDR) + +static bool js_pipeline_PipelineSceneData_setMatShadowProj(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_pipeline_PipelineSceneData_setMatShadowProj : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 1) { + HolderType arg0 = {}; + ok &= sevalue_to_native(args[0], &arg0, s.thisObject()); + SE_PRECONDITION2(ok, false, "js_pipeline_PipelineSceneData_setMatShadowProj : Error processing arguments"); + cobj->setMatShadowProj(arg0.value()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 1); + return false; +} +SE_BIND_FUNC(js_pipeline_PipelineSceneData_setMatShadowProj) + +static bool js_pipeline_PipelineSceneData_setMatShadowView(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_pipeline_PipelineSceneData_setMatShadowView : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 1) { + HolderType arg0 = {}; + ok &= sevalue_to_native(args[0], &arg0, s.thisObject()); + SE_PRECONDITION2(ok, false, "js_pipeline_PipelineSceneData_setMatShadowView : Error processing arguments"); + cobj->setMatShadowView(arg0.value()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 1); + return false; +} +SE_BIND_FUNC(js_pipeline_PipelineSceneData_setMatShadowView) + +static bool js_pipeline_PipelineSceneData_setMatShadowViewProj(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_pipeline_PipelineSceneData_setMatShadowViewProj : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 1) { + HolderType arg0 = {}; + ok &= sevalue_to_native(args[0], &arg0, s.thisObject()); + SE_PRECONDITION2(ok, false, "js_pipeline_PipelineSceneData_setMatShadowViewProj : Error processing arguments"); + cobj->setMatShadowViewProj(arg0.value()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 1); + return false; +} +SE_BIND_FUNC(js_pipeline_PipelineSceneData_setMatShadowViewProj) + +static bool js_pipeline_PipelineSceneData_setShadingScale(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_pipeline_PipelineSceneData_setShadingScale : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 1) { + HolderType arg0 = {}; + ok &= sevalue_to_native(args[0], &arg0, s.thisObject()); + SE_PRECONDITION2(ok, false, "js_pipeline_PipelineSceneData_setShadingScale : Error processing arguments"); + cobj->setShadingScale(arg0.value()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 1); + return false; +} +SE_BIND_FUNC_AS_PROP_SET(js_pipeline_PipelineSceneData_setShadingScale) + +static bool js_pipeline_PipelineSceneData_setShadowCameraFar(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_pipeline_PipelineSceneData_setShadowCameraFar : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 1) { + HolderType arg0 = {}; + ok &= sevalue_to_native(args[0], &arg0, s.thisObject()); + SE_PRECONDITION2(ok, false, "js_pipeline_PipelineSceneData_setShadowCameraFar : Error processing arguments"); + cobj->setShadowCameraFar(arg0.value()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 1); + return false; +} +SE_BIND_FUNC(js_pipeline_PipelineSceneData_setShadowCameraFar) + +static bool js_pipeline_PipelineSceneData_setShadowFramebuffer(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_pipeline_PipelineSceneData_setShadowFramebuffer : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 2) { + HolderType arg0 = {}; + HolderType arg1 = {}; + ok &= sevalue_to_native(args[0], &arg0, s.thisObject()); + ok &= sevalue_to_native(args[1], &arg1, s.thisObject()); + SE_PRECONDITION2(ok, false, "js_pipeline_PipelineSceneData_setShadowFramebuffer : Error processing arguments"); + cobj->setShadowFramebuffer(arg0.value(), arg1.value()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 2); + return false; +} +SE_BIND_FUNC(js_pipeline_PipelineSceneData_setShadowFramebuffer) + +static bool js_pipeline_PipelineSceneData_setValidPunctualLights(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_pipeline_PipelineSceneData_setValidPunctualLights : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 1) { + HolderType, true> arg0 = {}; + ok &= sevalue_to_native(args[0], &arg0, s.thisObject()); + SE_PRECONDITION2(ok, false, "js_pipeline_PipelineSceneData_setValidPunctualLights : Error processing arguments"); + cobj->setValidPunctualLights(std::move(arg0.value())); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 1); + return false; +} +SE_BIND_FUNC(js_pipeline_PipelineSceneData_setValidPunctualLights) + +SE_DECLARE_FINALIZE_FUNC(js_cc_pipeline_PipelineSceneData_finalize) + +static bool js_pipeline_PipelineSceneData_constructor(se::State& s) // NOLINT(readability-identifier-naming) constructor.c +{ + auto *ptr = JSB_MAKE_PRIVATE_OBJECT(cc::pipeline::PipelineSceneData); + s.thisObject()->setPrivateObject(ptr); + return true; +} +SE_BIND_CTOR(js_pipeline_PipelineSceneData_constructor, __jsb_cc_pipeline_PipelineSceneData_class, js_cc_pipeline_PipelineSceneData_finalize) + +static bool js_cc_pipeline_PipelineSceneData_finalize(se::State& s) // NOLINT(readability-identifier-naming) +{ + return true; +} +SE_BIND_FINALIZE_FUNC(js_cc_pipeline_PipelineSceneData_finalize) + +bool js_register_pipeline_PipelineSceneData(se::Object* obj) // NOLINT(readability-identifier-naming) +{ + auto* cls = se::Class::create("PipelineSceneData", obj, nullptr, _SE(js_pipeline_PipelineSceneData_constructor)); + + cls->defineProperty("shadows", _SE(js_pipeline_PipelineSceneData_getShadows_asGetter), nullptr); + cls->defineProperty("isHDR", _SE(js_pipeline_PipelineSceneData_isHDR_asGetter), _SE(js_pipeline_PipelineSceneData_setHDR_asSetter)); + cls->defineProperty("shadingScale", _SE(js_pipeline_PipelineSceneData_getShadingScale_asGetter), _SE(js_pipeline_PipelineSceneData_setShadingScale_asSetter)); + cls->defineProperty("fog", _SE(js_pipeline_PipelineSceneData_getFog_asGetter), nullptr); + cls->defineProperty("ambient", _SE(js_pipeline_PipelineSceneData_getAmbient_asGetter), nullptr); + cls->defineProperty("skybox", _SE(js_pipeline_PipelineSceneData_getSkybox_asGetter), nullptr); + cls->defineFunction("activate", _SE(js_pipeline_PipelineSceneData_activate)); + cls->defineFunction("destroy", _SE(js_pipeline_PipelineSceneData_destroy)); + cls->defineFunction("getDirShadowObjects", _SE(js_pipeline_PipelineSceneData_getDirShadowObjects)); + cls->defineFunction("getGeometryRendererMaterials", _SE(js_pipeline_PipelineSceneData_getGeometryRendererMaterials)); + cls->defineFunction("getGeometryRendererPasses", _SE(js_pipeline_PipelineSceneData_getGeometryRendererPasses)); + cls->defineFunction("getGeometryRendererShaders", _SE(js_pipeline_PipelineSceneData_getGeometryRendererShaders)); + cls->defineFunction("getMatShadowProj", _SE(js_pipeline_PipelineSceneData_getMatShadowProj)); + cls->defineFunction("getMatShadowView", _SE(js_pipeline_PipelineSceneData_getMatShadowView)); + cls->defineFunction("getMatShadowViewProj", _SE(js_pipeline_PipelineSceneData_getMatShadowViewProj)); + cls->defineFunction("getOcclusionQueryInputAssembler", _SE(js_pipeline_PipelineSceneData_getOcclusionQueryInputAssembler)); + cls->defineFunction("getOcclusionQueryPass", _SE(js_pipeline_PipelineSceneData_getOcclusionQueryPass)); + cls->defineFunction("getOcclusionQueryShader", _SE(js_pipeline_PipelineSceneData_getOcclusionQueryShader)); + cls->defineFunction("getOctree", _SE(js_pipeline_PipelineSceneData_getOctree)); + cls->defineFunction("getShadowCameraFar", _SE(js_pipeline_PipelineSceneData_getShadowCameraFar)); + cls->defineFunction("getValidPunctualLights", _SE(js_pipeline_PipelineSceneData_getValidPunctualLights)); + cls->defineFunction("isCastShadowObjects", _SE(js_pipeline_PipelineSceneData_isCastShadowObjects)); + cls->defineFunction("onGlobalPipelineStateChanged", _SE(js_pipeline_PipelineSceneData_onGlobalPipelineStateChanged)); + cls->defineFunction("setCastShadowObjects", _SE(js_pipeline_PipelineSceneData_setCastShadowObjects)); + cls->defineFunction("setDirShadowObjects", _SE(js_pipeline_PipelineSceneData_setDirShadowObjects)); + cls->defineFunction("setMatShadowProj", _SE(js_pipeline_PipelineSceneData_setMatShadowProj)); + cls->defineFunction("setMatShadowView", _SE(js_pipeline_PipelineSceneData_setMatShadowView)); + cls->defineFunction("setMatShadowViewProj", _SE(js_pipeline_PipelineSceneData_setMatShadowViewProj)); + cls->defineFunction("setShadowCameraFar", _SE(js_pipeline_PipelineSceneData_setShadowCameraFar)); + cls->defineFunction("setShadowFramebuffer", _SE(js_pipeline_PipelineSceneData_setShadowFramebuffer)); + cls->defineFunction("setValidPunctualLights", _SE(js_pipeline_PipelineSceneData_setValidPunctualLights)); + cls->defineFinalizeFunction(_SE(js_cc_pipeline_PipelineSceneData_finalize)); + cls->install(); + JSBClassType::registerClass(cls); + + __jsb_cc_pipeline_PipelineSceneData_proto = cls->getProto(); + __jsb_cc_pipeline_PipelineSceneData_class = cls; + + + se::ScriptEngine::getInstance()->clearException(); + return true; +} +se::Object* __jsb_cc_pipeline_RenderPipelineInfo_proto = nullptr; // NOLINT +se::Class* __jsb_cc_pipeline_RenderPipelineInfo_class = nullptr; // NOLINT static bool js_pipeline_RenderPipelineInfo_get_tag(se::State& s) // NOLINT(readability-identifier-naming) { @@ -547,11 +1384,11 @@ bool sevalue_to_native(const se::Value &from, cc::pipeline::RenderPipelineInfo * } se::Value field; bool ok = true; - json->getProperty("tag", &field); + json->getProperty("tag", &field, true); if(!field.isNullOrUndefined()) { ok &= sevalue_to_native(field, &(to->tag), ctx); } - json->getProperty("flows", &field); + json->getProperty("flows", &field, true); if(!field.isNullOrUndefined()) { ok &= sevalue_to_native(field, &(to->flows), ctx); } @@ -568,9 +1405,8 @@ static bool js_pipeline_RenderPipelineInfo_constructor(se::State& s) // NOLINT(r if(argc == 0) { - cc::pipeline::RenderPipelineInfo* cobj = JSB_ALLOC(cc::pipeline::RenderPipelineInfo); - s.thisObject()->setPrivateData(cobj); - se::NonRefNativePtrCreatedByCtorMap::emplace(cobj); + auto *ptr = JSB_MAKE_PRIVATE_OBJECT(cc::pipeline::RenderPipelineInfo); + s.thisObject()->setPrivateObject(ptr); return true; } @@ -578,21 +1414,19 @@ static bool js_pipeline_RenderPipelineInfo_constructor(se::State& s) // NOLINT(r { se::Object *json = args[0].toObject(); se::Value field; - - cc::pipeline::RenderPipelineInfo* cobj = JSB_ALLOC(cc::pipeline::RenderPipelineInfo); + auto *ptr = JSB_MAKE_PRIVATE_OBJECT(cc::pipeline::RenderPipelineInfo); + auto cobj = ptr->get(); ok &= sevalue_to_native(args[0], cobj, s.thisObject()); if(!ok) { - JSB_FREE(cobj); + delete ptr; SE_REPORT_ERROR("argument convertion error"); return false; } - - s.thisObject()->setPrivateData(cobj); - se::NonRefNativePtrCreatedByCtorMap::emplace(cobj); + s.thisObject()->setPrivateObject(ptr); return true; } - - cc::pipeline::RenderPipelineInfo* cobj = JSB_ALLOC(cc::pipeline::RenderPipelineInfo); + auto *ptr = JSB_MAKE_PRIVATE_OBJECT(cc::pipeline::RenderPipelineInfo); + auto cobj = ptr->get(); if (argc > 0 && !args[0].isUndefined()) { ok &= sevalue_to_native(args[0], &(cobj->tag), nullptr); } @@ -601,28 +1435,17 @@ static bool js_pipeline_RenderPipelineInfo_constructor(se::State& s) // NOLINT(r } if(!ok) { - JSB_FREE(cobj); + delete ptr; SE_REPORT_ERROR("Argument convertion error"); return false; } - - s.thisObject()->setPrivateData(cobj); - se::NonRefNativePtrCreatedByCtorMap::emplace(cobj); + s.thisObject()->setPrivateObject(ptr); return true; } SE_BIND_CTOR(js_pipeline_RenderPipelineInfo_constructor, __jsb_cc_pipeline_RenderPipelineInfo_class, js_cc_pipeline_RenderPipelineInfo_finalize) - - static bool js_cc_pipeline_RenderPipelineInfo_finalize(se::State& s) // NOLINT(readability-identifier-naming) { - auto iter = se::NonRefNativePtrCreatedByCtorMap::find(SE_THIS_OBJECT(s)); - if (iter != se::NonRefNativePtrCreatedByCtorMap::end()) - { - se::NonRefNativePtrCreatedByCtorMap::erase(iter); - auto* cobj = SE_THIS_OBJECT(s); - JSB_FREE(cobj); - } return true; } SE_BIND_FINALIZE_FUNC(js_cc_pipeline_RenderPipelineInfo_finalize) @@ -640,11 +1463,12 @@ bool js_register_pipeline_RenderPipelineInfo(se::Object* obj) // NOLINT(readabil __jsb_cc_pipeline_RenderPipelineInfo_proto = cls->getProto(); __jsb_cc_pipeline_RenderPipelineInfo_class = cls; + se::ScriptEngine::getInstance()->clearException(); return true; } -se::Object* __jsb_cc_pipeline_RenderPipeline_proto = nullptr; -se::Class* __jsb_cc_pipeline_RenderPipeline_class = nullptr; +se::Object* __jsb_cc_pipeline_RenderPipeline_proto = nullptr; // NOLINT +se::Class* __jsb_cc_pipeline_RenderPipeline_class = nullptr; // NOLINT static bool js_pipeline_RenderPipeline_activate(se::State& s) // NOLINT(readability-identifier-naming) { @@ -694,21 +1518,6 @@ static bool js_pipeline_RenderPipeline_createQuadInputAssembler(se::State& s) // } SE_BIND_FUNC(js_pipeline_RenderPipeline_createQuadInputAssembler) -static bool js_pipeline_RenderPipeline_destroy(se::State& s) // NOLINT(readability-identifier-naming) -{ - auto* cobj = SE_THIS_OBJECT(s); - SE_PRECONDITION2(cobj, false, "js_pipeline_RenderPipeline_destroy : Invalid Native Object"); - const auto& args = s.args(); - size_t argc = args.size(); - if (argc == 0) { - cobj->destroy(); - return true; - } - SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 0); - return false; -} -SE_BIND_FUNC(js_pipeline_RenderPipeline_destroy) - static bool js_pipeline_RenderPipeline_ensureEnoughSize(se::State& s) // NOLINT(readability-identifier-naming) { auto* cobj = SE_THIS_OBJECT(s); @@ -749,25 +1558,6 @@ static bool js_pipeline_RenderPipeline_genQuadVertexData(se::State& s) // NOLINT } SE_BIND_FUNC(js_pipeline_RenderPipeline_genQuadVertexData) -static bool js_pipeline_RenderPipeline_getBloomEnabled(se::State& s) // NOLINT(readability-identifier-naming) -{ - auto* cobj = SE_THIS_OBJECT(s); - SE_PRECONDITION2(cobj, false, "js_pipeline_RenderPipeline_getBloomEnabled : Invalid Native Object"); - const auto& args = s.args(); - size_t argc = args.size(); - CC_UNUSED bool ok = true; - if (argc == 0) { - bool result = cobj->getBloomEnabled(); - ok &= nativevalue_to_se(result, s.rval(), nullptr /*ctx*/); - SE_PRECONDITION2(ok, false, "js_pipeline_RenderPipeline_getBloomEnabled : Error processing arguments"); - SE_HOLD_RETURN_VALUE(result, s.thisObject(), s.rval()); - return true; - } - SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 0); - return false; -} -SE_BIND_PROP_GET(js_pipeline_RenderPipeline_getBloomEnabled) - static bool js_pipeline_RenderPipeline_getClearcolor(se::State& s) // NOLINT(readability-identifier-naming) { auto* cobj = SE_THIS_OBJECT(s); @@ -790,25 +1580,6 @@ static bool js_pipeline_RenderPipeline_getClearcolor(se::State& s) // NOLINT(rea } SE_BIND_FUNC(js_pipeline_RenderPipeline_getClearcolor) -static bool js_pipeline_RenderPipeline_getClusterEnabled(se::State& s) // NOLINT(readability-identifier-naming) -{ - auto* cobj = SE_THIS_OBJECT(s); - SE_PRECONDITION2(cobj, false, "js_pipeline_RenderPipeline_getClusterEnabled : Invalid Native Object"); - const auto& args = s.args(); - size_t argc = args.size(); - CC_UNUSED bool ok = true; - if (argc == 0) { - bool result = cobj->getClusterEnabled(); - ok &= nativevalue_to_se(result, s.rval(), nullptr /*ctx*/); - SE_PRECONDITION2(ok, false, "js_pipeline_RenderPipeline_getClusterEnabled : Error processing arguments"); - SE_HOLD_RETURN_VALUE(result, s.thisObject(), s.rval()); - return true; - } - SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 0); - return false; -} -SE_BIND_PROP_GET(js_pipeline_RenderPipeline_getClusterEnabled) - static bool js_pipeline_RenderPipeline_getConstantMacros(se::State& s) // NOLINT(readability-identifier-naming) { auto* cobj = SE_THIS_OBJECT(s); @@ -826,7 +1597,7 @@ static bool js_pipeline_RenderPipeline_getConstantMacros(se::State& s) // NOLINT SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 0); return false; } -SE_BIND_PROP_GET(js_pipeline_RenderPipeline_getConstantMacros) +SE_BIND_FUNC_AS_PROP_GET(js_pipeline_RenderPipeline_getConstantMacros) static bool js_pipeline_RenderPipeline_getDescriptorSet(se::State& s) // NOLINT(readability-identifier-naming) { @@ -845,7 +1616,7 @@ static bool js_pipeline_RenderPipeline_getDescriptorSet(se::State& s) // NOLINT( SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 0); return false; } -SE_BIND_PROP_GET(js_pipeline_RenderPipeline_getDescriptorSet) +SE_BIND_FUNC_AS_PROP_GET(js_pipeline_RenderPipeline_getDescriptorSet) static bool js_pipeline_RenderPipeline_getDescriptorSetLayout(se::State& s) // NOLINT(readability-identifier-naming) { @@ -864,7 +1635,7 @@ static bool js_pipeline_RenderPipeline_getDescriptorSetLayout(se::State& s) // N SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 0); return false; } -SE_BIND_PROP_GET(js_pipeline_RenderPipeline_getDescriptorSetLayout) +SE_BIND_FUNC_AS_PROP_GET(js_pipeline_RenderPipeline_getDescriptorSetLayout) static bool js_pipeline_RenderPipeline_getDevice(se::State& s) // NOLINT(readability-identifier-naming) { @@ -885,25 +1656,6 @@ static bool js_pipeline_RenderPipeline_getDevice(se::State& s) // NOLINT(readabi } SE_BIND_FUNC(js_pipeline_RenderPipeline_getDevice) -static bool js_pipeline_RenderPipeline_getFrameGraph(se::State& s) // NOLINT(readability-identifier-naming) -{ - auto* cobj = SE_THIS_OBJECT(s); - SE_PRECONDITION2(cobj, false, "js_pipeline_RenderPipeline_getFrameGraph : Invalid Native Object"); - const auto& args = s.args(); - size_t argc = args.size(); - CC_UNUSED bool ok = true; - if (argc == 0) { - cc::framegraph::FrameGraph& result = cobj->getFrameGraph(); - ok &= nativevalue_to_se(result, s.rval(), nullptr /*ctx*/); - SE_PRECONDITION2(ok, false, "js_pipeline_RenderPipeline_getFrameGraph : Error processing arguments"); - SE_HOLD_RETURN_VALUE(result, s.thisObject(), s.rval()); - return true; - } - SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 0); - return false; -} -SE_BIND_FUNC(js_pipeline_RenderPipeline_getFrameGraph) - static bool js_pipeline_RenderPipeline_getGeometryRenderer(se::State& s) // NOLINT(readability-identifier-naming) { auto* cobj = SE_THIS_OBJECT(s); @@ -940,7 +1692,7 @@ static bool js_pipeline_RenderPipeline_getGlobalDSManager(se::State& s) // NOLIN SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 0); return false; } -SE_BIND_PROP_GET(js_pipeline_RenderPipeline_getGlobalDSManager) +SE_BIND_FUNC_AS_PROP_GET(js_pipeline_RenderPipeline_getGlobalDSManager) static bool js_pipeline_RenderPipeline_getHeight(se::State& s) // NOLINT(readability-identifier-naming) { @@ -983,24 +1735,24 @@ static bool js_pipeline_RenderPipeline_getIAByRenderArea(se::State& s) // NOLINT } SE_BIND_FUNC(js_pipeline_RenderPipeline_getIAByRenderArea) -static bool js_pipeline_RenderPipeline_getOcclusionQueryEnabled(se::State& s) // NOLINT(readability-identifier-naming) +static bool js_pipeline_RenderPipeline_getPipelineSceneData(se::State& s) // NOLINT(readability-identifier-naming) { auto* cobj = SE_THIS_OBJECT(s); - SE_PRECONDITION2(cobj, false, "js_pipeline_RenderPipeline_getOcclusionQueryEnabled : Invalid Native Object"); + SE_PRECONDITION2(cobj, false, "js_pipeline_RenderPipeline_getPipelineSceneData : Invalid Native Object"); const auto& args = s.args(); size_t argc = args.size(); CC_UNUSED bool ok = true; if (argc == 0) { - bool result = cobj->getOcclusionQueryEnabled(); + cc::pipeline::PipelineSceneData* result = cobj->getPipelineSceneData(); ok &= nativevalue_to_se(result, s.rval(), nullptr /*ctx*/); - SE_PRECONDITION2(ok, false, "js_pipeline_RenderPipeline_getOcclusionQueryEnabled : Error processing arguments"); + SE_PRECONDITION2(ok, false, "js_pipeline_RenderPipeline_getPipelineSceneData : Error processing arguments"); SE_HOLD_RETURN_VALUE(result, s.thisObject(), s.rval()); return true; } SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 0); return false; } -SE_BIND_FUNC(js_pipeline_RenderPipeline_getOcclusionQueryEnabled) +SE_BIND_FUNC_AS_PROP_GET(js_pipeline_RenderPipeline_getPipelineSceneData) static bool js_pipeline_RenderPipeline_getProfiler(se::State& s) // NOLINT(readability-identifier-naming) { @@ -1019,7 +1771,7 @@ static bool js_pipeline_RenderPipeline_getProfiler(se::State& s) // NOLINT(reada SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 0); return false; } -SE_BIND_FUNC(js_pipeline_RenderPipeline_getProfiler) +SE_BIND_FUNC_AS_PROP_GET(js_pipeline_RenderPipeline_getProfiler) static bool js_pipeline_RenderPipeline_getQueryPools(se::State& s) // NOLINT(readability-identifier-naming) { @@ -1147,6 +1899,44 @@ static bool js_pipeline_RenderPipeline_initialize(se::State& s) // NOLINT(readab } SE_BIND_FUNC(js_pipeline_RenderPipeline_initialize) +static bool js_pipeline_RenderPipeline_isBloomEnabled(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_pipeline_RenderPipeline_isBloomEnabled : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 0) { + bool result = cobj->isBloomEnabled(); + ok &= nativevalue_to_se(result, s.rval(), nullptr /*ctx*/); + SE_PRECONDITION2(ok, false, "js_pipeline_RenderPipeline_isBloomEnabled : Error processing arguments"); + SE_HOLD_RETURN_VALUE(result, s.thisObject(), s.rval()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 0); + return false; +} +SE_BIND_FUNC(js_pipeline_RenderPipeline_isBloomEnabled) + +static bool js_pipeline_RenderPipeline_isClusterEnabled(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_pipeline_RenderPipeline_isClusterEnabled : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 0) { + bool result = cobj->isClusterEnabled(); + ok &= nativevalue_to_se(result, s.rval(), nullptr /*ctx*/); + SE_PRECONDITION2(ok, false, "js_pipeline_RenderPipeline_isClusterEnabled : Error processing arguments"); + SE_HOLD_RETURN_VALUE(result, s.thisObject(), s.rval()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 0); + return false; +} +SE_BIND_FUNC(js_pipeline_RenderPipeline_isClusterEnabled) + static bool js_pipeline_RenderPipeline_isEnvmapEnabled(se::State& s) // NOLINT(readability-identifier-naming) { auto* cobj = SE_THIS_OBJECT(s); @@ -1190,6 +1980,25 @@ static bool js_pipeline_RenderPipeline_isOccluded(se::State& s) // NOLINT(readab } SE_BIND_FUNC(js_pipeline_RenderPipeline_isOccluded) +static bool js_pipeline_RenderPipeline_isOcclusionQueryEnabled(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_pipeline_RenderPipeline_isOcclusionQueryEnabled : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 0) { + bool result = cobj->isOcclusionQueryEnabled(); + ok &= nativevalue_to_se(result, s.rval(), nullptr /*ctx*/); + SE_PRECONDITION2(ok, false, "js_pipeline_RenderPipeline_isOcclusionQueryEnabled : Error processing arguments"); + SE_HOLD_RETURN_VALUE(result, s.thisObject(), s.rval()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 0); + return false; +} +SE_BIND_FUNC(js_pipeline_RenderPipeline_isOcclusionQueryEnabled) + static bool js_pipeline_RenderPipeline_render(se::State& s) // NOLINT(readability-identifier-naming) { auto* cobj = SE_THIS_OBJECT(s); @@ -1226,7 +2035,7 @@ static bool js_pipeline_RenderPipeline_setBloomEnabled(se::State& s) // NOLINT(r SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 1); return false; } -SE_BIND_PROP_SET(js_pipeline_RenderPipeline_setBloomEnabled) +SE_BIND_FUNC_AS_PROP_SET(js_pipeline_RenderPipeline_setBloomEnabled) static bool js_pipeline_RenderPipeline_setClusterEnabled(se::State& s) // NOLINT(readability-identifier-naming) { @@ -1245,7 +2054,7 @@ static bool js_pipeline_RenderPipeline_setClusterEnabled(se::State& s) // NOLINT SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 1); return false; } -SE_BIND_PROP_SET(js_pipeline_RenderPipeline_setClusterEnabled) +SE_BIND_FUNC_AS_PROP_SET(js_pipeline_RenderPipeline_setClusterEnabled) static bool js_pipeline_RenderPipeline_setGeometryRenderer(se::State& s) // NOLINT(readability-identifier-naming) { @@ -1285,25 +2094,6 @@ static bool js_pipeline_RenderPipeline_setOcclusionQueryEnabled(se::State& s) // } SE_BIND_FUNC(js_pipeline_RenderPipeline_setOcclusionQueryEnabled) -static bool js_pipeline_RenderPipeline_setPipelineSharedSceneData(se::State& s) // NOLINT(readability-identifier-naming) -{ - auto* cobj = SE_THIS_OBJECT(s); - SE_PRECONDITION2(cobj, false, "js_pipeline_RenderPipeline_setPipelineSharedSceneData : Invalid Native Object"); - const auto& args = s.args(); - size_t argc = args.size(); - CC_UNUSED bool ok = true; - if (argc == 1) { - HolderType arg0 = {}; - ok &= sevalue_to_native(args[0], &arg0, s.thisObject()); - SE_PRECONDITION2(ok, false, "js_pipeline_RenderPipeline_setPipelineSharedSceneData : Error processing arguments"); - cobj->setPipelineSharedSceneData(arg0.value()); - return true; - } - SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 1); - return false; -} -SE_BIND_FUNC(js_pipeline_RenderPipeline_setPipelineSharedSceneData) - static bool js_pipeline_RenderPipeline_setProfiler(se::State& s) // NOLINT(readability-identifier-naming) { auto* cobj = SE_THIS_OBJECT(s); @@ -1321,25 +2111,71 @@ static bool js_pipeline_RenderPipeline_setProfiler(se::State& s) // NOLINT(reada SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 1); return false; } -SE_BIND_FUNC(js_pipeline_RenderPipeline_setProfiler) +SE_BIND_FUNC_AS_PROP_SET(js_pipeline_RenderPipeline_setProfiler) static bool js_pipeline_RenderPipeline_setValue(se::State& s) // NOLINT(readability-identifier-naming) { + CC_UNUSED bool ok = true; auto* cobj = SE_THIS_OBJECT(s); - SE_PRECONDITION2(cobj, false, "js_pipeline_RenderPipeline_setValue : Invalid Native Object"); + SE_PRECONDITION2( cobj, false, "js_pipeline_RenderPipeline_setValue : Invalid Native Object"); const auto& args = s.args(); size_t argc = args.size(); - CC_UNUSED bool ok = true; - if (argc == 2) { - HolderType arg0 = {}; - HolderType arg1 = {}; - ok &= sevalue_to_native(args[0], &arg0, s.thisObject()); - ok &= sevalue_to_native(args[1], &arg1, s.thisObject()); - SE_PRECONDITION2(ok, false, "js_pipeline_RenderPipeline_setValue : Error processing arguments"); - cobj->setValue(arg0.value(), arg1.value()); - return true; - } - SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 2); + do { + if (argc == 2) { + HolderType arg0 = {}; + HolderType arg1 = {}; + + ok &= sevalue_to_native(args[0], &arg0, s.thisObject()); + if (!ok) { ok = true; break; } + ok &= sevalue_to_native(args[1], &arg1, s.thisObject()); + cobj->setValue(arg0.value(), arg1.value()); + return true; + } + } while(false); + + do { + if (argc == 2) { + HolderType arg0 = {}; + HolderType arg1 = {}; + + ok &= sevalue_to_native(args[0], &arg0, s.thisObject()); + if (!ok) { ok = true; break; } + ok &= sevalue_to_native(args[1], &arg1, s.thisObject()); + if (!ok) { ok = true; break; } + cobj->setValue(arg0.value(), arg1.value()); + return true; + } + } while(false); + + do { + if (argc == 2) { + HolderType arg0 = {}; + HolderType arg1 = {}; + + ok &= sevalue_to_native(args[0], &arg0, s.thisObject()); + if (!ok) { ok = true; break; } + ok &= sevalue_to_native(args[1], &arg1, s.thisObject()); + if (!ok) { ok = true; break; } + cobj->setValue(arg0.value(), arg1.value()); + return true; + } + } while(false); + + do { + if (argc == 2) { + HolderType arg0 = {}; + HolderType arg1 = {}; + + ok &= sevalue_to_native(args[0], &arg0, s.thisObject()); + if (!ok) { ok = true; break; } + ok &= sevalue_to_native(args[1], &arg1, s.thisObject()); + if (!ok) { ok = true; break; } + cobj->setValue(arg0.value(), arg1.value()); + return true; + } + } while(false); + + SE_REPORT_ERROR("wrong number of arguments: %d", (int)argc); return false; } SE_BIND_FUNC(js_pipeline_RenderPipeline_setValue) @@ -1365,7 +2201,7 @@ static bool js_pipeline_RenderPipeline_updateQuadVertexData(se::State& s) // NOL } SE_BIND_FUNC(js_pipeline_RenderPipeline_updateQuadVertexData) -static bool js_pipeline_RenderPipeline_getInstance(se::State& s) // NOLINT(readability-identifier-naming) +static bool js_pipeline_RenderPipeline_getInstance_static(se::State& s) // NOLINT(readability-identifier-naming) { const auto& args = s.args(); size_t argc = args.size(); @@ -1373,16 +2209,16 @@ static bool js_pipeline_RenderPipeline_getInstance(se::State& s) // NOLINT(reada if (argc == 0) { cc::pipeline::RenderPipeline* result = cc::pipeline::RenderPipeline::getInstance(); ok &= nativevalue_to_se(result, s.rval(), nullptr /*ctx*/); - SE_PRECONDITION2(ok, false, "js_pipeline_RenderPipeline_getInstance : Error processing arguments"); + SE_PRECONDITION2(ok, false, "js_pipeline_RenderPipeline_getInstance_static : Error processing arguments"); SE_HOLD_RETURN_VALUE(result, s.thisObject(), s.rval()); return true; } SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 0); return false; } -SE_BIND_FUNC(js_pipeline_RenderPipeline_getInstance) +SE_BIND_FUNC(js_pipeline_RenderPipeline_getInstance_static) -static bool js_pipeline_RenderPipeline_getRenderArea(se::State& s) // NOLINT(readability-identifier-naming) +static bool js_pipeline_RenderPipeline_getRenderArea_static(se::State& s) // NOLINT(readability-identifier-naming) { const auto& args = s.args(); size_t argc = args.size(); @@ -1390,94 +2226,82 @@ static bool js_pipeline_RenderPipeline_getRenderArea(se::State& s) // NOLINT(rea if (argc == 1) { HolderType arg0 = {}; ok &= sevalue_to_native(args[0], &arg0, nullptr); - SE_PRECONDITION2(ok, false, "js_pipeline_RenderPipeline_getRenderArea : Error processing arguments"); + SE_PRECONDITION2(ok, false, "js_pipeline_RenderPipeline_getRenderArea_static : Error processing arguments"); cc::gfx::Rect result = cc::pipeline::RenderPipeline::getRenderArea(arg0.value()); ok &= nativevalue_to_se(result, s.rval(), nullptr /*ctx*/); - SE_PRECONDITION2(ok, false, "js_pipeline_RenderPipeline_getRenderArea : Error processing arguments"); + SE_PRECONDITION2(ok, false, "js_pipeline_RenderPipeline_getRenderArea_static : Error processing arguments"); SE_HOLD_RETURN_VALUE(result, s.thisObject(), s.rval()); return true; } SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 1); return false; } -SE_BIND_FUNC(js_pipeline_RenderPipeline_getRenderArea) - - +SE_BIND_FUNC(js_pipeline_RenderPipeline_getRenderArea_static) bool js_register_pipeline_RenderPipeline(se::Object* obj) // NOLINT(readability-identifier-naming) { - auto* cls = se::Class::create("RenderPipeline", obj, nullptr, nullptr); + auto* cls = se::Class::create("RenderPipeline", obj, __jsb_cc_Asset_proto, nullptr); - cls->defineProperty("globalDSManager", _SE(js_pipeline_RenderPipeline_getGlobalDSManager), nullptr); - cls->defineProperty("descriptorSet", _SE(js_pipeline_RenderPipeline_getDescriptorSet), nullptr); - cls->defineProperty("descriptorSetLayout", _SE(js_pipeline_RenderPipeline_getDescriptorSetLayout), nullptr); - cls->defineProperty("constantMacros", _SE(js_pipeline_RenderPipeline_getConstantMacros), nullptr); - cls->defineProperty("clusterEnabled", _SE(js_pipeline_RenderPipeline_getClusterEnabled), _SE(js_pipeline_RenderPipeline_setClusterEnabled)); - cls->defineProperty("bloomEnabled", _SE(js_pipeline_RenderPipeline_getBloomEnabled), _SE(js_pipeline_RenderPipeline_setBloomEnabled)); + cls->defineProperty("descriptorSet", _SE(js_pipeline_RenderPipeline_getDescriptorSet_asGetter), nullptr); + cls->defineProperty("pipelineSceneData", _SE(js_pipeline_RenderPipeline_getPipelineSceneData_asGetter), nullptr); + cls->defineProperty("clusterEnabled", nullptr, _SE(js_pipeline_RenderPipeline_setClusterEnabled_asSetter)); + cls->defineProperty("bloomEnabled", nullptr, _SE(js_pipeline_RenderPipeline_setBloomEnabled_asSetter)); + cls->defineProperty("constantMacros", _SE(js_pipeline_RenderPipeline_getConstantMacros_asGetter), nullptr); + cls->defineProperty("profiler", _SE(js_pipeline_RenderPipeline_getProfiler_asGetter), _SE(js_pipeline_RenderPipeline_setProfiler_asSetter)); + cls->defineProperty("globalDSManager", _SE(js_pipeline_RenderPipeline_getGlobalDSManager_asGetter), nullptr); + cls->defineProperty("descriptorSetLayout", _SE(js_pipeline_RenderPipeline_getDescriptorSetLayout_asGetter), nullptr); cls->defineFunction("activate", _SE(js_pipeline_RenderPipeline_activate)); cls->defineFunction("createQuadInputAssembler", _SE(js_pipeline_RenderPipeline_createQuadInputAssembler)); - cls->defineFunction("destroy", _SE(js_pipeline_RenderPipeline_destroy)); cls->defineFunction("ensureEnoughSize", _SE(js_pipeline_RenderPipeline_ensureEnoughSize)); cls->defineFunction("genQuadVertexData", _SE(js_pipeline_RenderPipeline_genQuadVertexData)); cls->defineFunction("getClearcolor", _SE(js_pipeline_RenderPipeline_getClearcolor)); cls->defineFunction("getDevice", _SE(js_pipeline_RenderPipeline_getDevice)); - cls->defineFunction("getFrameGraph", _SE(js_pipeline_RenderPipeline_getFrameGraph)); cls->defineFunction("getGeometryRenderer", _SE(js_pipeline_RenderPipeline_getGeometryRenderer)); cls->defineFunction("getHeight", _SE(js_pipeline_RenderPipeline_getHeight)); cls->defineFunction("getIAByRenderArea", _SE(js_pipeline_RenderPipeline_getIAByRenderArea)); - cls->defineFunction("getOcclusionQueryEnabled", _SE(js_pipeline_RenderPipeline_getOcclusionQueryEnabled)); - cls->defineFunction("getProfiler", _SE(js_pipeline_RenderPipeline_getProfiler)); cls->defineFunction("getQueryPools", _SE(js_pipeline_RenderPipeline_getQueryPools)); cls->defineFunction("getRenderstageByName", _SE(js_pipeline_RenderPipeline_getRenderstageByName)); cls->defineFunction("getScissor", _SE(js_pipeline_RenderPipeline_getScissor)); cls->defineFunction("getViewport", _SE(js_pipeline_RenderPipeline_getViewport)); cls->defineFunction("getWidth", _SE(js_pipeline_RenderPipeline_getWidth)); cls->defineFunction("initialize", _SE(js_pipeline_RenderPipeline_initialize)); + cls->defineFunction("isBloomEnabled", _SE(js_pipeline_RenderPipeline_isBloomEnabled)); + cls->defineFunction("isClusterEnabled", _SE(js_pipeline_RenderPipeline_isClusterEnabled)); cls->defineFunction("isEnvmapEnabled", _SE(js_pipeline_RenderPipeline_isEnvmapEnabled)); cls->defineFunction("isOccluded", _SE(js_pipeline_RenderPipeline_isOccluded)); + cls->defineFunction("isOcclusionQueryEnabled", _SE(js_pipeline_RenderPipeline_isOcclusionQueryEnabled)); cls->defineFunction("render", _SE(js_pipeline_RenderPipeline_render)); cls->defineFunction("setGeometryRenderer", _SE(js_pipeline_RenderPipeline_setGeometryRenderer)); cls->defineFunction("setOcclusionQueryEnabled", _SE(js_pipeline_RenderPipeline_setOcclusionQueryEnabled)); - cls->defineFunction("setPipelineSharedSceneData", _SE(js_pipeline_RenderPipeline_setPipelineSharedSceneData)); - cls->defineFunction("setProfiler", _SE(js_pipeline_RenderPipeline_setProfiler)); cls->defineFunction("setValue", _SE(js_pipeline_RenderPipeline_setValue)); cls->defineFunction("updateQuadVertexData", _SE(js_pipeline_RenderPipeline_updateQuadVertexData)); - cls->defineStaticFunction("getInstance", _SE(js_pipeline_RenderPipeline_getInstance)); - cls->defineStaticFunction("getRenderArea", _SE(js_pipeline_RenderPipeline_getRenderArea)); + cls->defineStaticFunction("getInstance", _SE(js_pipeline_RenderPipeline_getInstance_static)); + cls->defineStaticFunction("getRenderArea", _SE(js_pipeline_RenderPipeline_getRenderArea_static)); cls->install(); JSBClassType::registerClass(cls); __jsb_cc_pipeline_RenderPipeline_proto = cls->getProto(); __jsb_cc_pipeline_RenderPipeline_class = cls; + se::ScriptEngine::getInstance()->clearException(); return true; } -se::Object* __jsb_cc_pipeline_ForwardPipeline_proto = nullptr; -se::Class* __jsb_cc_pipeline_ForwardPipeline_class = nullptr; +se::Object* __jsb_cc_pipeline_ForwardPipeline_proto = nullptr; // NOLINT +se::Class* __jsb_cc_pipeline_ForwardPipeline_class = nullptr; // NOLINT SE_DECLARE_FINALIZE_FUNC(js_cc_pipeline_ForwardPipeline_finalize) static bool js_pipeline_ForwardPipeline_constructor(se::State& s) // NOLINT(readability-identifier-naming) constructor.c { - cc::pipeline::ForwardPipeline* cobj = JSB_ALLOC(cc::pipeline::ForwardPipeline); - s.thisObject()->setPrivateData(cobj); - se::NonRefNativePtrCreatedByCtorMap::emplace(cobj); + auto *ptr = JSB_MAKE_PRIVATE_OBJECT(cc::pipeline::ForwardPipeline); + s.thisObject()->setPrivateObject(ptr); return true; } SE_BIND_CTOR(js_pipeline_ForwardPipeline_constructor, __jsb_cc_pipeline_ForwardPipeline_class, js_cc_pipeline_ForwardPipeline_finalize) - - static bool js_cc_pipeline_ForwardPipeline_finalize(se::State& s) // NOLINT(readability-identifier-naming) { - auto iter = se::NonRefNativePtrCreatedByCtorMap::find(SE_THIS_OBJECT(s)); - if (iter != se::NonRefNativePtrCreatedByCtorMap::end()) - { - se::NonRefNativePtrCreatedByCtorMap::erase(iter); - auto* cobj = SE_THIS_OBJECT(s); - JSB_FREE(cobj); - } return true; } SE_BIND_FINALIZE_FUNC(js_cc_pipeline_ForwardPipeline_finalize) @@ -1493,11 +2317,12 @@ bool js_register_pipeline_ForwardPipeline(se::Object* obj) // NOLINT(readability __jsb_cc_pipeline_ForwardPipeline_proto = cls->getProto(); __jsb_cc_pipeline_ForwardPipeline_class = cls; + se::ScriptEngine::getInstance()->clearException(); return true; } -se::Object* __jsb_cc_pipeline_RenderFlowInfo_proto = nullptr; -se::Class* __jsb_cc_pipeline_RenderFlowInfo_class = nullptr; +se::Object* __jsb_cc_pipeline_RenderFlowInfo_proto = nullptr; // NOLINT +se::Class* __jsb_cc_pipeline_RenderFlowInfo_class = nullptr; // NOLINT static bool js_pipeline_RenderFlowInfo_get_name(se::State& s) // NOLINT(readability-identifier-naming) { @@ -1620,19 +2445,19 @@ bool sevalue_to_native(const se::Value &from, cc::pipeline::RenderFlowInfo * to, } se::Value field; bool ok = true; - json->getProperty("name", &field); + json->getProperty("name", &field, true); if(!field.isNullOrUndefined()) { ok &= sevalue_to_native(field, &(to->name), ctx); } - json->getProperty("priority", &field); + json->getProperty("priority", &field, true); if(!field.isNullOrUndefined()) { ok &= sevalue_to_native(field, &(to->priority), ctx); } - json->getProperty("tag", &field); + json->getProperty("tag", &field, true); if(!field.isNullOrUndefined()) { ok &= sevalue_to_native(field, &(to->tag), ctx); } - json->getProperty("stages", &field); + json->getProperty("stages", &field, true); if(!field.isNullOrUndefined()) { ok &= sevalue_to_native(field, &(to->stages), ctx); } @@ -1649,9 +2474,8 @@ static bool js_pipeline_RenderFlowInfo_constructor(se::State& s) // NOLINT(reada if(argc == 0) { - cc::pipeline::RenderFlowInfo* cobj = JSB_ALLOC(cc::pipeline::RenderFlowInfo); - s.thisObject()->setPrivateData(cobj); - se::NonRefNativePtrCreatedByCtorMap::emplace(cobj); + auto *ptr = JSB_MAKE_PRIVATE_OBJECT(cc::pipeline::RenderFlowInfo); + s.thisObject()->setPrivateObject(ptr); return true; } @@ -1659,21 +2483,19 @@ static bool js_pipeline_RenderFlowInfo_constructor(se::State& s) // NOLINT(reada { se::Object *json = args[0].toObject(); se::Value field; - - cc::pipeline::RenderFlowInfo* cobj = JSB_ALLOC(cc::pipeline::RenderFlowInfo); + auto *ptr = JSB_MAKE_PRIVATE_OBJECT(cc::pipeline::RenderFlowInfo); + auto cobj = ptr->get(); ok &= sevalue_to_native(args[0], cobj, s.thisObject()); if(!ok) { - JSB_FREE(cobj); + delete ptr; SE_REPORT_ERROR("argument convertion error"); return false; } - - s.thisObject()->setPrivateData(cobj); - se::NonRefNativePtrCreatedByCtorMap::emplace(cobj); + s.thisObject()->setPrivateObject(ptr); return true; } - - cc::pipeline::RenderFlowInfo* cobj = JSB_ALLOC(cc::pipeline::RenderFlowInfo); + auto *ptr = JSB_MAKE_PRIVATE_OBJECT(cc::pipeline::RenderFlowInfo); + auto cobj = ptr->get(); if (argc > 0 && !args[0].isUndefined()) { ok &= sevalue_to_native(args[0], &(cobj->name), nullptr); } @@ -1688,28 +2510,17 @@ static bool js_pipeline_RenderFlowInfo_constructor(se::State& s) // NOLINT(reada } if(!ok) { - JSB_FREE(cobj); + delete ptr; SE_REPORT_ERROR("Argument convertion error"); return false; } - - s.thisObject()->setPrivateData(cobj); - se::NonRefNativePtrCreatedByCtorMap::emplace(cobj); + s.thisObject()->setPrivateObject(ptr); return true; } SE_BIND_CTOR(js_pipeline_RenderFlowInfo_constructor, __jsb_cc_pipeline_RenderFlowInfo_class, js_cc_pipeline_RenderFlowInfo_finalize) - - static bool js_cc_pipeline_RenderFlowInfo_finalize(se::State& s) // NOLINT(readability-identifier-naming) { - auto iter = se::NonRefNativePtrCreatedByCtorMap::find(SE_THIS_OBJECT(s)); - if (iter != se::NonRefNativePtrCreatedByCtorMap::end()) - { - se::NonRefNativePtrCreatedByCtorMap::erase(iter); - auto* cobj = SE_THIS_OBJECT(s); - JSB_FREE(cobj); - } return true; } SE_BIND_FINALIZE_FUNC(js_cc_pipeline_RenderFlowInfo_finalize) @@ -1729,11 +2540,12 @@ bool js_register_pipeline_RenderFlowInfo(se::Object* obj) // NOLINT(readability- __jsb_cc_pipeline_RenderFlowInfo_proto = cls->getProto(); __jsb_cc_pipeline_RenderFlowInfo_class = cls; + se::ScriptEngine::getInstance()->clearException(); return true; } -se::Object* __jsb_cc_pipeline_RenderFlow_proto = nullptr; -se::Class* __jsb_cc_pipeline_RenderFlow_class = nullptr; +se::Object* __jsb_cc_pipeline_RenderFlow_proto = nullptr; // NOLINT +se::Class* __jsb_cc_pipeline_RenderFlow_class = nullptr; // NOLINT static bool js_pipeline_RenderFlow_activate(se::State& s) // NOLINT(readability-identifier-naming) { @@ -1817,8 +2629,6 @@ static bool js_pipeline_RenderFlow_initialize(se::State& s) // NOLINT(readabilit } SE_BIND_FUNC(js_pipeline_RenderFlow_initialize) - - bool js_register_pipeline_RenderFlow(se::Object* obj) // NOLINT(readability-identifier-naming) { auto* cls = se::Class::create("RenderFlow", obj, nullptr, nullptr); @@ -1833,13 +2643,14 @@ bool js_register_pipeline_RenderFlow(se::Object* obj) // NOLINT(readability-iden __jsb_cc_pipeline_RenderFlow_proto = cls->getProto(); __jsb_cc_pipeline_RenderFlow_class = cls; + se::ScriptEngine::getInstance()->clearException(); return true; } -se::Object* __jsb_cc_pipeline_ForwardFlow_proto = nullptr; -se::Class* __jsb_cc_pipeline_ForwardFlow_class = nullptr; +se::Object* __jsb_cc_pipeline_ForwardFlow_proto = nullptr; // NOLINT +se::Class* __jsb_cc_pipeline_ForwardFlow_class = nullptr; // NOLINT -static bool js_pipeline_ForwardFlow_getInitializeInfo(se::State& s) // NOLINT(readability-identifier-naming) +static bool js_pipeline_ForwardFlow_getInitializeInfo_static(se::State& s) // NOLINT(readability-identifier-naming) { const auto& args = s.args(); size_t argc = args.size(); @@ -1847,37 +2658,27 @@ static bool js_pipeline_ForwardFlow_getInitializeInfo(se::State& s) // NOLINT(re if (argc == 0) { const cc::pipeline::RenderFlowInfo& result = cc::pipeline::ForwardFlow::getInitializeInfo(); ok &= nativevalue_to_se(result, s.rval(), nullptr /*ctx*/); - SE_PRECONDITION2(ok, false, "js_pipeline_ForwardFlow_getInitializeInfo : Error processing arguments"); + SE_PRECONDITION2(ok, false, "js_pipeline_ForwardFlow_getInitializeInfo_static : Error processing arguments"); SE_HOLD_RETURN_VALUE(result, s.thisObject(), s.rval()); return true; } SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 0); return false; } -SE_BIND_FUNC(js_pipeline_ForwardFlow_getInitializeInfo) +SE_BIND_FUNC(js_pipeline_ForwardFlow_getInitializeInfo_static) SE_DECLARE_FINALIZE_FUNC(js_cc_pipeline_ForwardFlow_finalize) static bool js_pipeline_ForwardFlow_constructor(se::State& s) // NOLINT(readability-identifier-naming) constructor.c { - cc::pipeline::ForwardFlow* cobj = JSB_ALLOC(cc::pipeline::ForwardFlow); - s.thisObject()->setPrivateData(cobj); - se::NonRefNativePtrCreatedByCtorMap::emplace(cobj); + auto *ptr = JSB_MAKE_PRIVATE_OBJECT(cc::pipeline::ForwardFlow); + s.thisObject()->setPrivateObject(ptr); return true; } SE_BIND_CTOR(js_pipeline_ForwardFlow_constructor, __jsb_cc_pipeline_ForwardFlow_class, js_cc_pipeline_ForwardFlow_finalize) - - static bool js_cc_pipeline_ForwardFlow_finalize(se::State& s) // NOLINT(readability-identifier-naming) { - auto iter = se::NonRefNativePtrCreatedByCtorMap::find(SE_THIS_OBJECT(s)); - if (iter != se::NonRefNativePtrCreatedByCtorMap::end()) - { - se::NonRefNativePtrCreatedByCtorMap::erase(iter); - auto* cobj = SE_THIS_OBJECT(s); - JSB_FREE(cobj); - } return true; } SE_BIND_FINALIZE_FUNC(js_cc_pipeline_ForwardFlow_finalize) @@ -1886,7 +2687,7 @@ bool js_register_pipeline_ForwardFlow(se::Object* obj) // NOLINT(readability-ide { auto* cls = se::Class::create("ForwardFlow", obj, __jsb_cc_pipeline_RenderFlow_proto, _SE(js_pipeline_ForwardFlow_constructor)); - cls->defineStaticFunction("getInitializeInfo", _SE(js_pipeline_ForwardFlow_getInitializeInfo)); + cls->defineStaticFunction("getInitializeInfo", _SE(js_pipeline_ForwardFlow_getInitializeInfo_static)); cls->defineFinalizeFunction(_SE(js_cc_pipeline_ForwardFlow_finalize)); cls->install(); JSBClassType::registerClass(cls); @@ -1894,11 +2695,12 @@ bool js_register_pipeline_ForwardFlow(se::Object* obj) // NOLINT(readability-ide __jsb_cc_pipeline_ForwardFlow_proto = cls->getProto(); __jsb_cc_pipeline_ForwardFlow_class = cls; + se::ScriptEngine::getInstance()->clearException(); return true; } -se::Object* __jsb_cc_pipeline_RenderStageInfo_proto = nullptr; -se::Class* __jsb_cc_pipeline_RenderStageInfo_class = nullptr; +se::Object* __jsb_cc_pipeline_RenderStageInfo_proto = nullptr; // NOLINT +se::Class* __jsb_cc_pipeline_RenderStageInfo_class = nullptr; // NOLINT static bool js_pipeline_RenderStageInfo_get_name(se::State& s) // NOLINT(readability-identifier-naming) { @@ -2021,19 +2823,19 @@ bool sevalue_to_native(const se::Value &from, cc::pipeline::RenderStageInfo * to } se::Value field; bool ok = true; - json->getProperty("name", &field); + json->getProperty("name", &field, true); if(!field.isNullOrUndefined()) { ok &= sevalue_to_native(field, &(to->name), ctx); } - json->getProperty("priority", &field); + json->getProperty("priority", &field, true); if(!field.isNullOrUndefined()) { ok &= sevalue_to_native(field, &(to->priority), ctx); } - json->getProperty("tag", &field); + json->getProperty("tag", &field, true); if(!field.isNullOrUndefined()) { ok &= sevalue_to_native(field, &(to->tag), ctx); } - json->getProperty("renderQueues", &field); + json->getProperty("renderQueues", &field, true); if(!field.isNullOrUndefined()) { ok &= sevalue_to_native(field, &(to->renderQueues), ctx); } @@ -2050,9 +2852,8 @@ static bool js_pipeline_RenderStageInfo_constructor(se::State& s) // NOLINT(read if(argc == 0) { - cc::pipeline::RenderStageInfo* cobj = JSB_ALLOC(cc::pipeline::RenderStageInfo); - s.thisObject()->setPrivateData(cobj); - se::NonRefNativePtrCreatedByCtorMap::emplace(cobj); + auto *ptr = JSB_MAKE_PRIVATE_OBJECT(cc::pipeline::RenderStageInfo); + s.thisObject()->setPrivateObject(ptr); return true; } @@ -2060,21 +2861,19 @@ static bool js_pipeline_RenderStageInfo_constructor(se::State& s) // NOLINT(read { se::Object *json = args[0].toObject(); se::Value field; - - cc::pipeline::RenderStageInfo* cobj = JSB_ALLOC(cc::pipeline::RenderStageInfo); + auto *ptr = JSB_MAKE_PRIVATE_OBJECT(cc::pipeline::RenderStageInfo); + auto cobj = ptr->get(); ok &= sevalue_to_native(args[0], cobj, s.thisObject()); if(!ok) { - JSB_FREE(cobj); + delete ptr; SE_REPORT_ERROR("argument convertion error"); return false; } - - s.thisObject()->setPrivateData(cobj); - se::NonRefNativePtrCreatedByCtorMap::emplace(cobj); + s.thisObject()->setPrivateObject(ptr); return true; } - - cc::pipeline::RenderStageInfo* cobj = JSB_ALLOC(cc::pipeline::RenderStageInfo); + auto *ptr = JSB_MAKE_PRIVATE_OBJECT(cc::pipeline::RenderStageInfo); + auto cobj = ptr->get(); if (argc > 0 && !args[0].isUndefined()) { ok &= sevalue_to_native(args[0], &(cobj->name), nullptr); } @@ -2089,28 +2888,17 @@ static bool js_pipeline_RenderStageInfo_constructor(se::State& s) // NOLINT(read } if(!ok) { - JSB_FREE(cobj); + delete ptr; SE_REPORT_ERROR("Argument convertion error"); return false; } - - s.thisObject()->setPrivateData(cobj); - se::NonRefNativePtrCreatedByCtorMap::emplace(cobj); + s.thisObject()->setPrivateObject(ptr); return true; } SE_BIND_CTOR(js_pipeline_RenderStageInfo_constructor, __jsb_cc_pipeline_RenderStageInfo_class, js_cc_pipeline_RenderStageInfo_finalize) - - static bool js_cc_pipeline_RenderStageInfo_finalize(se::State& s) // NOLINT(readability-identifier-naming) { - auto iter = se::NonRefNativePtrCreatedByCtorMap::find(SE_THIS_OBJECT(s)); - if (iter != se::NonRefNativePtrCreatedByCtorMap::end()) - { - se::NonRefNativePtrCreatedByCtorMap::erase(iter); - auto* cobj = SE_THIS_OBJECT(s); - JSB_FREE(cobj); - } return true; } SE_BIND_FINALIZE_FUNC(js_cc_pipeline_RenderStageInfo_finalize) @@ -2130,11 +2918,12 @@ bool js_register_pipeline_RenderStageInfo(se::Object* obj) // NOLINT(readability __jsb_cc_pipeline_RenderStageInfo_proto = cls->getProto(); __jsb_cc_pipeline_RenderStageInfo_class = cls; + se::ScriptEngine::getInstance()->clearException(); return true; } -se::Object* __jsb_cc_pipeline_RenderStage_proto = nullptr; -se::Class* __jsb_cc_pipeline_RenderStage_class = nullptr; +se::Object* __jsb_cc_pipeline_RenderStage_proto = nullptr; // NOLINT +se::Class* __jsb_cc_pipeline_RenderStage_class = nullptr; // NOLINT static bool js_pipeline_RenderStage_activate(se::State& s) // NOLINT(readability-identifier-naming) { @@ -2217,8 +3006,6 @@ static bool js_pipeline_RenderStage_initialize(se::State& s) // NOLINT(readabili } SE_BIND_FUNC(js_pipeline_RenderStage_initialize) - - bool js_register_pipeline_RenderStage(se::Object* obj) // NOLINT(readability-identifier-naming) { auto* cls = se::Class::create("RenderStage", obj, nullptr, nullptr); @@ -2233,13 +3020,14 @@ bool js_register_pipeline_RenderStage(se::Object* obj) // NOLINT(readability-ide __jsb_cc_pipeline_RenderStage_proto = cls->getProto(); __jsb_cc_pipeline_RenderStage_class = cls; + se::ScriptEngine::getInstance()->clearException(); return true; } -se::Object* __jsb_cc_pipeline_ForwardStage_proto = nullptr; -se::Class* __jsb_cc_pipeline_ForwardStage_class = nullptr; +se::Object* __jsb_cc_pipeline_ForwardStage_proto = nullptr; // NOLINT +se::Class* __jsb_cc_pipeline_ForwardStage_class = nullptr; // NOLINT -static bool js_pipeline_ForwardStage_getInitializeInfo(se::State& s) // NOLINT(readability-identifier-naming) +static bool js_pipeline_ForwardStage_getInitializeInfo_static(se::State& s) // NOLINT(readability-identifier-naming) { const auto& args = s.args(); size_t argc = args.size(); @@ -2247,37 +3035,27 @@ static bool js_pipeline_ForwardStage_getInitializeInfo(se::State& s) // NOLINT(r if (argc == 0) { const cc::pipeline::RenderStageInfo& result = cc::pipeline::ForwardStage::getInitializeInfo(); ok &= nativevalue_to_se(result, s.rval(), nullptr /*ctx*/); - SE_PRECONDITION2(ok, false, "js_pipeline_ForwardStage_getInitializeInfo : Error processing arguments"); + SE_PRECONDITION2(ok, false, "js_pipeline_ForwardStage_getInitializeInfo_static : Error processing arguments"); SE_HOLD_RETURN_VALUE(result, s.thisObject(), s.rval()); return true; } SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 0); return false; } -SE_BIND_FUNC(js_pipeline_ForwardStage_getInitializeInfo) +SE_BIND_FUNC(js_pipeline_ForwardStage_getInitializeInfo_static) SE_DECLARE_FINALIZE_FUNC(js_cc_pipeline_ForwardStage_finalize) static bool js_pipeline_ForwardStage_constructor(se::State& s) // NOLINT(readability-identifier-naming) constructor.c { - cc::pipeline::ForwardStage* cobj = JSB_ALLOC(cc::pipeline::ForwardStage); - s.thisObject()->setPrivateData(cobj); - se::NonRefNativePtrCreatedByCtorMap::emplace(cobj); + auto *ptr = JSB_MAKE_PRIVATE_OBJECT(cc::pipeline::ForwardStage); + s.thisObject()->setPrivateObject(ptr); return true; } SE_BIND_CTOR(js_pipeline_ForwardStage_constructor, __jsb_cc_pipeline_ForwardStage_class, js_cc_pipeline_ForwardStage_finalize) - - static bool js_cc_pipeline_ForwardStage_finalize(se::State& s) // NOLINT(readability-identifier-naming) { - auto iter = se::NonRefNativePtrCreatedByCtorMap::find(SE_THIS_OBJECT(s)); - if (iter != se::NonRefNativePtrCreatedByCtorMap::end()) - { - se::NonRefNativePtrCreatedByCtorMap::erase(iter); - auto* cobj = SE_THIS_OBJECT(s); - JSB_FREE(cobj); - } return true; } SE_BIND_FINALIZE_FUNC(js_cc_pipeline_ForwardStage_finalize) @@ -2286,7 +3064,7 @@ bool js_register_pipeline_ForwardStage(se::Object* obj) // NOLINT(readability-id { auto* cls = se::Class::create("ForwardStage", obj, __jsb_cc_pipeline_RenderStage_proto, _SE(js_pipeline_ForwardStage_constructor)); - cls->defineStaticFunction("getInitializeInfo", _SE(js_pipeline_ForwardStage_getInitializeInfo)); + cls->defineStaticFunction("getInitializeInfo", _SE(js_pipeline_ForwardStage_getInitializeInfo_static)); cls->defineFinalizeFunction(_SE(js_cc_pipeline_ForwardStage_finalize)); cls->install(); JSBClassType::registerClass(cls); @@ -2294,13 +3072,14 @@ bool js_register_pipeline_ForwardStage(se::Object* obj) // NOLINT(readability-id __jsb_cc_pipeline_ForwardStage_proto = cls->getProto(); __jsb_cc_pipeline_ForwardStage_class = cls; + se::ScriptEngine::getInstance()->clearException(); return true; } -se::Object* __jsb_cc_pipeline_ShadowFlow_proto = nullptr; -se::Class* __jsb_cc_pipeline_ShadowFlow_class = nullptr; +se::Object* __jsb_cc_pipeline_ShadowFlow_proto = nullptr; // NOLINT +se::Class* __jsb_cc_pipeline_ShadowFlow_class = nullptr; // NOLINT -static bool js_pipeline_ShadowFlow_getInitializeInfo(se::State& s) // NOLINT(readability-identifier-naming) +static bool js_pipeline_ShadowFlow_getInitializeInfo_static(se::State& s) // NOLINT(readability-identifier-naming) { const auto& args = s.args(); size_t argc = args.size(); @@ -2308,37 +3087,27 @@ static bool js_pipeline_ShadowFlow_getInitializeInfo(se::State& s) // NOLINT(rea if (argc == 0) { const cc::pipeline::RenderFlowInfo& result = cc::pipeline::ShadowFlow::getInitializeInfo(); ok &= nativevalue_to_se(result, s.rval(), nullptr /*ctx*/); - SE_PRECONDITION2(ok, false, "js_pipeline_ShadowFlow_getInitializeInfo : Error processing arguments"); + SE_PRECONDITION2(ok, false, "js_pipeline_ShadowFlow_getInitializeInfo_static : Error processing arguments"); SE_HOLD_RETURN_VALUE(result, s.thisObject(), s.rval()); return true; } SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 0); return false; } -SE_BIND_FUNC(js_pipeline_ShadowFlow_getInitializeInfo) +SE_BIND_FUNC(js_pipeline_ShadowFlow_getInitializeInfo_static) SE_DECLARE_FINALIZE_FUNC(js_cc_pipeline_ShadowFlow_finalize) static bool js_pipeline_ShadowFlow_constructor(se::State& s) // NOLINT(readability-identifier-naming) constructor.c { - cc::pipeline::ShadowFlow* cobj = JSB_ALLOC(cc::pipeline::ShadowFlow); - s.thisObject()->setPrivateData(cobj); - se::NonRefNativePtrCreatedByCtorMap::emplace(cobj); + auto *ptr = JSB_MAKE_PRIVATE_OBJECT(cc::pipeline::ShadowFlow); + s.thisObject()->setPrivateObject(ptr); return true; } SE_BIND_CTOR(js_pipeline_ShadowFlow_constructor, __jsb_cc_pipeline_ShadowFlow_class, js_cc_pipeline_ShadowFlow_finalize) - - static bool js_cc_pipeline_ShadowFlow_finalize(se::State& s) // NOLINT(readability-identifier-naming) { - auto iter = se::NonRefNativePtrCreatedByCtorMap::find(SE_THIS_OBJECT(s)); - if (iter != se::NonRefNativePtrCreatedByCtorMap::end()) - { - se::NonRefNativePtrCreatedByCtorMap::erase(iter); - auto* cobj = SE_THIS_OBJECT(s); - JSB_FREE(cobj); - } return true; } SE_BIND_FINALIZE_FUNC(js_cc_pipeline_ShadowFlow_finalize) @@ -2347,7 +3116,7 @@ bool js_register_pipeline_ShadowFlow(se::Object* obj) // NOLINT(readability-iden { auto* cls = se::Class::create("ShadowFlow", obj, __jsb_cc_pipeline_RenderFlow_proto, _SE(js_pipeline_ShadowFlow_constructor)); - cls->defineStaticFunction("getInitializeInfo", _SE(js_pipeline_ShadowFlow_getInitializeInfo)); + cls->defineStaticFunction("getInitializeInfo", _SE(js_pipeline_ShadowFlow_getInitializeInfo_static)); cls->defineFinalizeFunction(_SE(js_cc_pipeline_ShadowFlow_finalize)); cls->install(); JSBClassType::registerClass(cls); @@ -2355,11 +3124,12 @@ bool js_register_pipeline_ShadowFlow(se::Object* obj) // NOLINT(readability-iden __jsb_cc_pipeline_ShadowFlow_proto = cls->getProto(); __jsb_cc_pipeline_ShadowFlow_class = cls; + se::ScriptEngine::getInstance()->clearException(); return true; } -se::Object* __jsb_cc_pipeline_ShadowStage_proto = nullptr; -se::Class* __jsb_cc_pipeline_ShadowStage_class = nullptr; +se::Object* __jsb_cc_pipeline_ShadowStage_proto = nullptr; // NOLINT +se::Class* __jsb_cc_pipeline_ShadowStage_class = nullptr; // NOLINT static bool js_pipeline_ShadowStage_setFramebuffer(se::State& s) // NOLINT(readability-identifier-naming) { @@ -2403,7 +3173,7 @@ static bool js_pipeline_ShadowStage_setUsage(se::State& s) // NOLINT(readability } SE_BIND_FUNC(js_pipeline_ShadowStage_setUsage) -static bool js_pipeline_ShadowStage_getInitializeInfo(se::State& s) // NOLINT(readability-identifier-naming) +static bool js_pipeline_ShadowStage_getInitializeInfo_static(se::State& s) // NOLINT(readability-identifier-naming) { const auto& args = s.args(); size_t argc = args.size(); @@ -2411,37 +3181,27 @@ static bool js_pipeline_ShadowStage_getInitializeInfo(se::State& s) // NOLINT(re if (argc == 0) { const cc::pipeline::RenderStageInfo& result = cc::pipeline::ShadowStage::getInitializeInfo(); ok &= nativevalue_to_se(result, s.rval(), nullptr /*ctx*/); - SE_PRECONDITION2(ok, false, "js_pipeline_ShadowStage_getInitializeInfo : Error processing arguments"); + SE_PRECONDITION2(ok, false, "js_pipeline_ShadowStage_getInitializeInfo_static : Error processing arguments"); SE_HOLD_RETURN_VALUE(result, s.thisObject(), s.rval()); return true; } SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 0); return false; } -SE_BIND_FUNC(js_pipeline_ShadowStage_getInitializeInfo) +SE_BIND_FUNC(js_pipeline_ShadowStage_getInitializeInfo_static) SE_DECLARE_FINALIZE_FUNC(js_cc_pipeline_ShadowStage_finalize) static bool js_pipeline_ShadowStage_constructor(se::State& s) // NOLINT(readability-identifier-naming) constructor.c { - cc::pipeline::ShadowStage* cobj = JSB_ALLOC(cc::pipeline::ShadowStage); - s.thisObject()->setPrivateData(cobj); - se::NonRefNativePtrCreatedByCtorMap::emplace(cobj); + auto *ptr = JSB_MAKE_PRIVATE_OBJECT(cc::pipeline::ShadowStage); + s.thisObject()->setPrivateObject(ptr); return true; } SE_BIND_CTOR(js_pipeline_ShadowStage_constructor, __jsb_cc_pipeline_ShadowStage_class, js_cc_pipeline_ShadowStage_finalize) - - static bool js_cc_pipeline_ShadowStage_finalize(se::State& s) // NOLINT(readability-identifier-naming) { - auto iter = se::NonRefNativePtrCreatedByCtorMap::find(SE_THIS_OBJECT(s)); - if (iter != se::NonRefNativePtrCreatedByCtorMap::end()) - { - se::NonRefNativePtrCreatedByCtorMap::erase(iter); - auto* cobj = SE_THIS_OBJECT(s); - JSB_FREE(cobj); - } return true; } SE_BIND_FINALIZE_FUNC(js_cc_pipeline_ShadowStage_finalize) @@ -2452,7 +3212,7 @@ bool js_register_pipeline_ShadowStage(se::Object* obj) // NOLINT(readability-ide cls->defineFunction("setFramebuffer", _SE(js_pipeline_ShadowStage_setFramebuffer)); cls->defineFunction("setUsage", _SE(js_pipeline_ShadowStage_setUsage)); - cls->defineStaticFunction("getInitializeInfo", _SE(js_pipeline_ShadowStage_getInitializeInfo)); + cls->defineStaticFunction("getInitializeInfo", _SE(js_pipeline_ShadowStage_getInitializeInfo_static)); cls->defineFinalizeFunction(_SE(js_cc_pipeline_ShadowStage_finalize)); cls->install(); JSBClassType::registerClass(cls); @@ -2460,11 +3220,12 @@ bool js_register_pipeline_ShadowStage(se::Object* obj) // NOLINT(readability-ide __jsb_cc_pipeline_ShadowStage_proto = cls->getProto(); __jsb_cc_pipeline_ShadowStage_class = cls; + se::ScriptEngine::getInstance()->clearException(); return true; } -se::Object* __jsb_cc_pipeline_InstancedBuffer_proto = nullptr; -se::Class* __jsb_cc_pipeline_InstancedBuffer_class = nullptr; +se::Object* __jsb_cc_pipeline_InstancedBuffer_proto = nullptr; // NOLINT +se::Class* __jsb_cc_pipeline_InstancedBuffer_class = nullptr; // NOLINT static bool js_pipeline_InstancedBuffer_destroy(se::State& s) // NOLINT(readability-identifier-naming) { @@ -2502,7 +3263,20 @@ static bool js_pipeline_InstancedBuffer_setDynamicOffset(se::State& s) // NOLINT } SE_BIND_FUNC(js_pipeline_InstancedBuffer_setDynamicOffset) -static bool js_pipeline_InstancedBuffer_get(se::State& s) // NOLINT(readability-identifier-naming) +static bool js_pipeline_InstancedBuffer_destroyInstancedBuffer_static(se::State& s) // NOLINT(readability-identifier-naming) +{ + const auto& args = s.args(); + size_t argc = args.size(); + if (argc == 0) { + cc::pipeline::InstancedBuffer::destroyInstancedBuffer(); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 0); + return false; +} +SE_BIND_FUNC(js_pipeline_InstancedBuffer_destroyInstancedBuffer_static) + +static bool js_pipeline_InstancedBuffer_get_static(se::State& s) // NOLINT(readability-identifier-naming) { CC_UNUSED bool ok = true; const auto& args = s.args(); @@ -2517,7 +3291,7 @@ static bool js_pipeline_InstancedBuffer_get(se::State& s) // NOLINT(readability- if (!ok) { ok = true; break; } cc::pipeline::InstancedBuffer* result = cc::pipeline::InstancedBuffer::get(arg0.value(), arg1.value()); ok &= nativevalue_to_se(result, s.rval(), s.thisObject() /*ctx*/); - SE_PRECONDITION2(ok, false, "js_pipeline_InstancedBuffer_get : Error processing arguments"); + SE_PRECONDITION2(ok, false, "js_pipeline_InstancedBuffer_get_static : Error processing arguments"); SE_HOLD_RETURN_VALUE(result, s.thisObject(), s.rval()); return true; } @@ -2529,7 +3303,7 @@ static bool js_pipeline_InstancedBuffer_get(se::State& s) // NOLINT(readability- if (!ok) { ok = true; break; } cc::pipeline::InstancedBuffer* result = cc::pipeline::InstancedBuffer::get(arg0.value()); ok &= nativevalue_to_se(result, s.rval(), s.thisObject() /*ctx*/); - SE_PRECONDITION2(ok, false, "js_pipeline_InstancedBuffer_get : Error processing arguments"); + SE_PRECONDITION2(ok, false, "js_pipeline_InstancedBuffer_get_static : Error processing arguments"); SE_HOLD_RETURN_VALUE(result, s.thisObject(), s.rval()); return true; } @@ -2537,20 +3311,7 @@ static bool js_pipeline_InstancedBuffer_get(se::State& s) // NOLINT(readability- SE_REPORT_ERROR("wrong number of arguments: %d", (int)argc); return false; } -SE_BIND_FUNC(js_pipeline_InstancedBuffer_get) - -static bool js_pipeline_InstancedBuffer_destroyInstancedBuffer(se::State& s) // NOLINT(readability-identifier-naming) -{ - const auto& args = s.args(); - size_t argc = args.size(); - if (argc == 0) { - cc::pipeline::InstancedBuffer::destroyInstancedBuffer(); - return true; - } - SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 0); - return false; -} -SE_BIND_FUNC(js_pipeline_InstancedBuffer_destroyInstancedBuffer) +SE_BIND_FUNC(js_pipeline_InstancedBuffer_get_static) SE_DECLARE_FINALIZE_FUNC(js_cc_pipeline_InstancedBuffer_finalize) @@ -2561,24 +3322,14 @@ static bool js_pipeline_InstancedBuffer_constructor(se::State& s) // NOLINT(read const cc::scene::Pass* arg0 = nullptr; ok &= sevalue_to_native(args[0], &arg0, s.thisObject()); SE_PRECONDITION2(ok, false, "js_pipeline_InstancedBuffer_constructor : Error processing arguments"); - cc::pipeline::InstancedBuffer* cobj = JSB_ALLOC(cc::pipeline::InstancedBuffer, arg0); - s.thisObject()->setPrivateData(cobj); - se::NonRefNativePtrCreatedByCtorMap::emplace(cobj); + auto *ptr = JSB_MAKE_PRIVATE_OBJECT(cc::pipeline::InstancedBuffer, arg0); + s.thisObject()->setPrivateObject(ptr); return true; } SE_BIND_CTOR(js_pipeline_InstancedBuffer_constructor, __jsb_cc_pipeline_InstancedBuffer_class, js_cc_pipeline_InstancedBuffer_finalize) - - static bool js_cc_pipeline_InstancedBuffer_finalize(se::State& s) // NOLINT(readability-identifier-naming) { - auto iter = se::NonRefNativePtrCreatedByCtorMap::find(SE_THIS_OBJECT(s)); - if (iter != se::NonRefNativePtrCreatedByCtorMap::end()) - { - se::NonRefNativePtrCreatedByCtorMap::erase(iter); - auto* cobj = SE_THIS_OBJECT(s); - JSB_FREE(cobj); - } return true; } SE_BIND_FINALIZE_FUNC(js_cc_pipeline_InstancedBuffer_finalize) @@ -2589,8 +3340,8 @@ bool js_register_pipeline_InstancedBuffer(se::Object* obj) // NOLINT(readability cls->defineFunction("destroy", _SE(js_pipeline_InstancedBuffer_destroy)); cls->defineFunction("setDynamicOffset", _SE(js_pipeline_InstancedBuffer_setDynamicOffset)); - cls->defineStaticFunction("get", _SE(js_pipeline_InstancedBuffer_get)); - cls->defineStaticFunction("destroyInstancedBuffer", _SE(js_pipeline_InstancedBuffer_destroyInstancedBuffer)); + cls->defineStaticFunction("destroyInstancedBuffer", _SE(js_pipeline_InstancedBuffer_destroyInstancedBuffer_static)); + cls->defineStaticFunction("get", _SE(js_pipeline_InstancedBuffer_get_static)); cls->defineFinalizeFunction(_SE(js_cc_pipeline_InstancedBuffer_finalize)); cls->install(); JSBClassType::registerClass(cls); @@ -2598,34 +3349,25 @@ bool js_register_pipeline_InstancedBuffer(se::Object* obj) // NOLINT(readability __jsb_cc_pipeline_InstancedBuffer_proto = cls->getProto(); __jsb_cc_pipeline_InstancedBuffer_class = cls; + se::ScriptEngine::getInstance()->clearException(); return true; } -se::Object* __jsb_cc_pipeline_DeferredPipeline_proto = nullptr; -se::Class* __jsb_cc_pipeline_DeferredPipeline_class = nullptr; +se::Object* __jsb_cc_pipeline_DeferredPipeline_proto = nullptr; // NOLINT +se::Class* __jsb_cc_pipeline_DeferredPipeline_class = nullptr; // NOLINT SE_DECLARE_FINALIZE_FUNC(js_cc_pipeline_DeferredPipeline_finalize) static bool js_pipeline_DeferredPipeline_constructor(se::State& s) // NOLINT(readability-identifier-naming) constructor.c { - cc::pipeline::DeferredPipeline* cobj = JSB_ALLOC(cc::pipeline::DeferredPipeline); - s.thisObject()->setPrivateData(cobj); - se::NonRefNativePtrCreatedByCtorMap::emplace(cobj); + auto *ptr = JSB_MAKE_PRIVATE_OBJECT(cc::pipeline::DeferredPipeline); + s.thisObject()->setPrivateObject(ptr); return true; } SE_BIND_CTOR(js_pipeline_DeferredPipeline_constructor, __jsb_cc_pipeline_DeferredPipeline_class, js_cc_pipeline_DeferredPipeline_finalize) - - static bool js_cc_pipeline_DeferredPipeline_finalize(se::State& s) // NOLINT(readability-identifier-naming) { - auto iter = se::NonRefNativePtrCreatedByCtorMap::find(SE_THIS_OBJECT(s)); - if (iter != se::NonRefNativePtrCreatedByCtorMap::end()) - { - se::NonRefNativePtrCreatedByCtorMap::erase(iter); - auto* cobj = SE_THIS_OBJECT(s); - JSB_FREE(cobj); - } return true; } SE_BIND_FINALIZE_FUNC(js_cc_pipeline_DeferredPipeline_finalize) @@ -2641,13 +3383,14 @@ bool js_register_pipeline_DeferredPipeline(se::Object* obj) // NOLINT(readabilit __jsb_cc_pipeline_DeferredPipeline_proto = cls->getProto(); __jsb_cc_pipeline_DeferredPipeline_class = cls; + se::ScriptEngine::getInstance()->clearException(); return true; } -se::Object* __jsb_cc_pipeline_MainFlow_proto = nullptr; -se::Class* __jsb_cc_pipeline_MainFlow_class = nullptr; +se::Object* __jsb_cc_pipeline_MainFlow_proto = nullptr; // NOLINT +se::Class* __jsb_cc_pipeline_MainFlow_class = nullptr; // NOLINT -static bool js_pipeline_MainFlow_getInitializeInfo(se::State& s) // NOLINT(readability-identifier-naming) +static bool js_pipeline_MainFlow_getInitializeInfo_static(se::State& s) // NOLINT(readability-identifier-naming) { const auto& args = s.args(); size_t argc = args.size(); @@ -2655,37 +3398,27 @@ static bool js_pipeline_MainFlow_getInitializeInfo(se::State& s) // NOLINT(reada if (argc == 0) { const cc::pipeline::RenderFlowInfo& result = cc::pipeline::MainFlow::getInitializeInfo(); ok &= nativevalue_to_se(result, s.rval(), nullptr /*ctx*/); - SE_PRECONDITION2(ok, false, "js_pipeline_MainFlow_getInitializeInfo : Error processing arguments"); + SE_PRECONDITION2(ok, false, "js_pipeline_MainFlow_getInitializeInfo_static : Error processing arguments"); SE_HOLD_RETURN_VALUE(result, s.thisObject(), s.rval()); return true; } SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 0); return false; } -SE_BIND_FUNC(js_pipeline_MainFlow_getInitializeInfo) +SE_BIND_FUNC(js_pipeline_MainFlow_getInitializeInfo_static) SE_DECLARE_FINALIZE_FUNC(js_cc_pipeline_MainFlow_finalize) static bool js_pipeline_MainFlow_constructor(se::State& s) // NOLINT(readability-identifier-naming) constructor.c { - cc::pipeline::MainFlow* cobj = JSB_ALLOC(cc::pipeline::MainFlow); - s.thisObject()->setPrivateData(cobj); - se::NonRefNativePtrCreatedByCtorMap::emplace(cobj); + auto *ptr = JSB_MAKE_PRIVATE_OBJECT(cc::pipeline::MainFlow); + s.thisObject()->setPrivateObject(ptr); return true; } SE_BIND_CTOR(js_pipeline_MainFlow_constructor, __jsb_cc_pipeline_MainFlow_class, js_cc_pipeline_MainFlow_finalize) - - static bool js_cc_pipeline_MainFlow_finalize(se::State& s) // NOLINT(readability-identifier-naming) { - auto iter = se::NonRefNativePtrCreatedByCtorMap::find(SE_THIS_OBJECT(s)); - if (iter != se::NonRefNativePtrCreatedByCtorMap::end()) - { - se::NonRefNativePtrCreatedByCtorMap::erase(iter); - auto* cobj = SE_THIS_OBJECT(s); - JSB_FREE(cobj); - } return true; } SE_BIND_FINALIZE_FUNC(js_cc_pipeline_MainFlow_finalize) @@ -2694,7 +3427,7 @@ bool js_register_pipeline_MainFlow(se::Object* obj) // NOLINT(readability-identi { auto* cls = se::Class::create("MainFlow", obj, __jsb_cc_pipeline_RenderFlow_proto, _SE(js_pipeline_MainFlow_constructor)); - cls->defineStaticFunction("getInitializeInfo", _SE(js_pipeline_MainFlow_getInitializeInfo)); + cls->defineStaticFunction("getInitializeInfo", _SE(js_pipeline_MainFlow_getInitializeInfo_static)); cls->defineFinalizeFunction(_SE(js_cc_pipeline_MainFlow_finalize)); cls->install(); JSBClassType::registerClass(cls); @@ -2702,13 +3435,14 @@ bool js_register_pipeline_MainFlow(se::Object* obj) // NOLINT(readability-identi __jsb_cc_pipeline_MainFlow_proto = cls->getProto(); __jsb_cc_pipeline_MainFlow_class = cls; + se::ScriptEngine::getInstance()->clearException(); return true; } -se::Object* __jsb_cc_pipeline_GbufferStage_proto = nullptr; -se::Class* __jsb_cc_pipeline_GbufferStage_class = nullptr; +se::Object* __jsb_cc_pipeline_GbufferStage_proto = nullptr; // NOLINT +se::Class* __jsb_cc_pipeline_GbufferStage_class = nullptr; // NOLINT -static bool js_pipeline_GbufferStage_getInitializeInfo(se::State& s) // NOLINT(readability-identifier-naming) +static bool js_pipeline_GbufferStage_getInitializeInfo_static(se::State& s) // NOLINT(readability-identifier-naming) { const auto& args = s.args(); size_t argc = args.size(); @@ -2716,37 +3450,27 @@ static bool js_pipeline_GbufferStage_getInitializeInfo(se::State& s) // NOLINT(r if (argc == 0) { const cc::pipeline::RenderStageInfo& result = cc::pipeline::GbufferStage::getInitializeInfo(); ok &= nativevalue_to_se(result, s.rval(), nullptr /*ctx*/); - SE_PRECONDITION2(ok, false, "js_pipeline_GbufferStage_getInitializeInfo : Error processing arguments"); + SE_PRECONDITION2(ok, false, "js_pipeline_GbufferStage_getInitializeInfo_static : Error processing arguments"); SE_HOLD_RETURN_VALUE(result, s.thisObject(), s.rval()); return true; } SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 0); return false; } -SE_BIND_FUNC(js_pipeline_GbufferStage_getInitializeInfo) +SE_BIND_FUNC(js_pipeline_GbufferStage_getInitializeInfo_static) SE_DECLARE_FINALIZE_FUNC(js_cc_pipeline_GbufferStage_finalize) static bool js_pipeline_GbufferStage_constructor(se::State& s) // NOLINT(readability-identifier-naming) constructor.c { - cc::pipeline::GbufferStage* cobj = JSB_ALLOC(cc::pipeline::GbufferStage); - s.thisObject()->setPrivateData(cobj); - se::NonRefNativePtrCreatedByCtorMap::emplace(cobj); + auto *ptr = JSB_MAKE_PRIVATE_OBJECT(cc::pipeline::GbufferStage); + s.thisObject()->setPrivateObject(ptr); return true; } SE_BIND_CTOR(js_pipeline_GbufferStage_constructor, __jsb_cc_pipeline_GbufferStage_class, js_cc_pipeline_GbufferStage_finalize) - - static bool js_cc_pipeline_GbufferStage_finalize(se::State& s) // NOLINT(readability-identifier-naming) { - auto iter = se::NonRefNativePtrCreatedByCtorMap::find(SE_THIS_OBJECT(s)); - if (iter != se::NonRefNativePtrCreatedByCtorMap::end()) - { - se::NonRefNativePtrCreatedByCtorMap::erase(iter); - auto* cobj = SE_THIS_OBJECT(s); - JSB_FREE(cobj); - } return true; } SE_BIND_FINALIZE_FUNC(js_cc_pipeline_GbufferStage_finalize) @@ -2755,7 +3479,7 @@ bool js_register_pipeline_GbufferStage(se::Object* obj) // NOLINT(readability-id { auto* cls = se::Class::create("GbufferStage", obj, __jsb_cc_pipeline_RenderStage_proto, _SE(js_pipeline_GbufferStage_constructor)); - cls->defineStaticFunction("getInitializeInfo", _SE(js_pipeline_GbufferStage_getInitializeInfo)); + cls->defineStaticFunction("getInitializeInfo", _SE(js_pipeline_GbufferStage_getInitializeInfo_static)); cls->defineFinalizeFunction(_SE(js_cc_pipeline_GbufferStage_finalize)); cls->install(); JSBClassType::registerClass(cls); @@ -2763,13 +3487,14 @@ bool js_register_pipeline_GbufferStage(se::Object* obj) // NOLINT(readability-id __jsb_cc_pipeline_GbufferStage_proto = cls->getProto(); __jsb_cc_pipeline_GbufferStage_class = cls; + se::ScriptEngine::getInstance()->clearException(); return true; } -se::Object* __jsb_cc_pipeline_LightingStage_proto = nullptr; -se::Class* __jsb_cc_pipeline_LightingStage_class = nullptr; +se::Object* __jsb_cc_pipeline_LightingStage_proto = nullptr; // NOLINT +se::Class* __jsb_cc_pipeline_LightingStage_class = nullptr; // NOLINT -static bool js_pipeline_LightingStage_getInitializeInfo(se::State& s) // NOLINT(readability-identifier-naming) +static bool js_pipeline_LightingStage_getInitializeInfo_static(se::State& s) // NOLINT(readability-identifier-naming) { const auto& args = s.args(); size_t argc = args.size(); @@ -2777,37 +3502,27 @@ static bool js_pipeline_LightingStage_getInitializeInfo(se::State& s) // NOLINT( if (argc == 0) { const cc::pipeline::RenderStageInfo& result = cc::pipeline::LightingStage::getInitializeInfo(); ok &= nativevalue_to_se(result, s.rval(), nullptr /*ctx*/); - SE_PRECONDITION2(ok, false, "js_pipeline_LightingStage_getInitializeInfo : Error processing arguments"); + SE_PRECONDITION2(ok, false, "js_pipeline_LightingStage_getInitializeInfo_static : Error processing arguments"); SE_HOLD_RETURN_VALUE(result, s.thisObject(), s.rval()); return true; } SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 0); return false; } -SE_BIND_FUNC(js_pipeline_LightingStage_getInitializeInfo) +SE_BIND_FUNC(js_pipeline_LightingStage_getInitializeInfo_static) SE_DECLARE_FINALIZE_FUNC(js_cc_pipeline_LightingStage_finalize) static bool js_pipeline_LightingStage_constructor(se::State& s) // NOLINT(readability-identifier-naming) constructor.c { - cc::pipeline::LightingStage* cobj = JSB_ALLOC(cc::pipeline::LightingStage); - s.thisObject()->setPrivateData(cobj); - se::NonRefNativePtrCreatedByCtorMap::emplace(cobj); + auto *ptr = JSB_MAKE_PRIVATE_OBJECT(cc::pipeline::LightingStage); + s.thisObject()->setPrivateObject(ptr); return true; } SE_BIND_CTOR(js_pipeline_LightingStage_constructor, __jsb_cc_pipeline_LightingStage_class, js_cc_pipeline_LightingStage_finalize) - - static bool js_cc_pipeline_LightingStage_finalize(se::State& s) // NOLINT(readability-identifier-naming) { - auto iter = se::NonRefNativePtrCreatedByCtorMap::find(SE_THIS_OBJECT(s)); - if (iter != se::NonRefNativePtrCreatedByCtorMap::end()) - { - se::NonRefNativePtrCreatedByCtorMap::erase(iter); - auto* cobj = SE_THIS_OBJECT(s); - JSB_FREE(cobj); - } return true; } SE_BIND_FINALIZE_FUNC(js_cc_pipeline_LightingStage_finalize) @@ -2816,7 +3531,7 @@ bool js_register_pipeline_LightingStage(se::Object* obj) // NOLINT(readability-i { auto* cls = se::Class::create("LightingStage", obj, __jsb_cc_pipeline_RenderStage_proto, _SE(js_pipeline_LightingStage_constructor)); - cls->defineStaticFunction("getInitializeInfo", _SE(js_pipeline_LightingStage_getInitializeInfo)); + cls->defineStaticFunction("getInitializeInfo", _SE(js_pipeline_LightingStage_getInitializeInfo_static)); cls->defineFinalizeFunction(_SE(js_cc_pipeline_LightingStage_finalize)); cls->install(); JSBClassType::registerClass(cls); @@ -2824,11 +3539,12 @@ bool js_register_pipeline_LightingStage(se::Object* obj) // NOLINT(readability-i __jsb_cc_pipeline_LightingStage_proto = cls->getProto(); __jsb_cc_pipeline_LightingStage_class = cls; + se::ScriptEngine::getInstance()->clearException(); return true; } -se::Object* __jsb_cc_pipeline_BloomStage_proto = nullptr; -se::Class* __jsb_cc_pipeline_BloomStage_class = nullptr; +se::Object* __jsb_cc_pipeline_BloomStage_proto = nullptr; // NOLINT +se::Class* __jsb_cc_pipeline_BloomStage_class = nullptr; // NOLINT static bool js_pipeline_BloomStage_getCombineUBO(se::State& s) // NOLINT(readability-identifier-naming) { @@ -2849,24 +3565,24 @@ static bool js_pipeline_BloomStage_getCombineUBO(se::State& s) // NOLINT(readabi } SE_BIND_FUNC(js_pipeline_BloomStage_getCombineUBO) -static bool js_pipeline_BloomStage_getDownsampelUBO(se::State& s) // NOLINT(readability-identifier-naming) +static bool js_pipeline_BloomStage_getDownsampleUBO(se::State& s) // NOLINT(readability-identifier-naming) { auto* cobj = SE_THIS_OBJECT(s); - SE_PRECONDITION2(cobj, false, "js_pipeline_BloomStage_getDownsampelUBO : Invalid Native Object"); + SE_PRECONDITION2(cobj, false, "js_pipeline_BloomStage_getDownsampleUBO : Invalid Native Object"); const auto& args = s.args(); size_t argc = args.size(); CC_UNUSED bool ok = true; if (argc == 0) { - std::array& result = cobj->getDownsampelUBO(); + std::array& result = cobj->getDownsampleUBO(); ok &= nativevalue_to_se(result, s.rval(), nullptr /*ctx*/); - SE_PRECONDITION2(ok, false, "js_pipeline_BloomStage_getDownsampelUBO : Error processing arguments"); + SE_PRECONDITION2(ok, false, "js_pipeline_BloomStage_getDownsampleUBO : Error processing arguments"); SE_HOLD_RETURN_VALUE(result, s.thisObject(), s.rval()); return true; } SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 0); return false; } -SE_BIND_FUNC(js_pipeline_BloomStage_getDownsampelUBO) +SE_BIND_FUNC(js_pipeline_BloomStage_getDownsampleUBO) static bool js_pipeline_BloomStage_getIntensity(se::State& s) // NOLINT(readability-identifier-naming) { @@ -2885,7 +3601,7 @@ static bool js_pipeline_BloomStage_getIntensity(se::State& s) // NOLINT(readabil SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 0); return false; } -SE_BIND_PROP_GET(js_pipeline_BloomStage_getIntensity) +SE_BIND_FUNC_AS_PROP_GET(js_pipeline_BloomStage_getIntensity) static bool js_pipeline_BloomStage_getIterations(se::State& s) // NOLINT(readability-identifier-naming) { @@ -2904,7 +3620,7 @@ static bool js_pipeline_BloomStage_getIterations(se::State& s) // NOLINT(readabi SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 0); return false; } -SE_BIND_PROP_GET(js_pipeline_BloomStage_getIterations) +SE_BIND_FUNC_AS_PROP_GET(js_pipeline_BloomStage_getIterations) static bool js_pipeline_BloomStage_getPrefilterUBO(se::State& s) // NOLINT(readability-identifier-naming) { @@ -2961,7 +3677,7 @@ static bool js_pipeline_BloomStage_getThreshold(se::State& s) // NOLINT(readabil SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 0); return false; } -SE_BIND_PROP_GET(js_pipeline_BloomStage_getThreshold) +SE_BIND_FUNC_AS_PROP_GET(js_pipeline_BloomStage_getThreshold) static bool js_pipeline_BloomStage_getUpsampleUBO(se::State& s) // NOLINT(readability-identifier-naming) { @@ -2999,7 +3715,7 @@ static bool js_pipeline_BloomStage_setIntensity(se::State& s) // NOLINT(readabil SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 1); return false; } -SE_BIND_PROP_SET(js_pipeline_BloomStage_setIntensity) +SE_BIND_FUNC_AS_PROP_SET(js_pipeline_BloomStage_setIntensity) static bool js_pipeline_BloomStage_setIterations(se::State& s) // NOLINT(readability-identifier-naming) { @@ -3018,7 +3734,7 @@ static bool js_pipeline_BloomStage_setIterations(se::State& s) // NOLINT(readabi SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 1); return false; } -SE_BIND_PROP_SET(js_pipeline_BloomStage_setIterations) +SE_BIND_FUNC_AS_PROP_SET(js_pipeline_BloomStage_setIterations) static bool js_pipeline_BloomStage_setThreshold(se::State& s) // NOLINT(readability-identifier-naming) { @@ -3037,9 +3753,9 @@ static bool js_pipeline_BloomStage_setThreshold(se::State& s) // NOLINT(readabil SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 1); return false; } -SE_BIND_PROP_SET(js_pipeline_BloomStage_setThreshold) +SE_BIND_FUNC_AS_PROP_SET(js_pipeline_BloomStage_setThreshold) -static bool js_pipeline_BloomStage_getInitializeInfo(se::State& s) // NOLINT(readability-identifier-naming) +static bool js_pipeline_BloomStage_getInitializeInfo_static(se::State& s) // NOLINT(readability-identifier-naming) { const auto& args = s.args(); size_t argc = args.size(); @@ -3047,37 +3763,27 @@ static bool js_pipeline_BloomStage_getInitializeInfo(se::State& s) // NOLINT(rea if (argc == 0) { const cc::pipeline::RenderStageInfo& result = cc::pipeline::BloomStage::getInitializeInfo(); ok &= nativevalue_to_se(result, s.rval(), nullptr /*ctx*/); - SE_PRECONDITION2(ok, false, "js_pipeline_BloomStage_getInitializeInfo : Error processing arguments"); + SE_PRECONDITION2(ok, false, "js_pipeline_BloomStage_getInitializeInfo_static : Error processing arguments"); SE_HOLD_RETURN_VALUE(result, s.thisObject(), s.rval()); return true; } SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 0); return false; } -SE_BIND_FUNC(js_pipeline_BloomStage_getInitializeInfo) +SE_BIND_FUNC(js_pipeline_BloomStage_getInitializeInfo_static) SE_DECLARE_FINALIZE_FUNC(js_cc_pipeline_BloomStage_finalize) static bool js_pipeline_BloomStage_constructor(se::State& s) // NOLINT(readability-identifier-naming) constructor.c { - cc::pipeline::BloomStage* cobj = JSB_ALLOC(cc::pipeline::BloomStage); - s.thisObject()->setPrivateData(cobj); - se::NonRefNativePtrCreatedByCtorMap::emplace(cobj); + auto *ptr = JSB_MAKE_PRIVATE_OBJECT(cc::pipeline::BloomStage); + s.thisObject()->setPrivateObject(ptr); return true; } SE_BIND_CTOR(js_pipeline_BloomStage_constructor, __jsb_cc_pipeline_BloomStage_class, js_cc_pipeline_BloomStage_finalize) - - static bool js_cc_pipeline_BloomStage_finalize(se::State& s) // NOLINT(readability-identifier-naming) { - auto iter = se::NonRefNativePtrCreatedByCtorMap::find(SE_THIS_OBJECT(s)); - if (iter != se::NonRefNativePtrCreatedByCtorMap::end()) - { - se::NonRefNativePtrCreatedByCtorMap::erase(iter); - auto* cobj = SE_THIS_OBJECT(s); - JSB_FREE(cobj); - } return true; } SE_BIND_FINALIZE_FUNC(js_cc_pipeline_BloomStage_finalize) @@ -3086,15 +3792,15 @@ bool js_register_pipeline_BloomStage(se::Object* obj) // NOLINT(readability-iden { auto* cls = se::Class::create("BloomStage", obj, __jsb_cc_pipeline_RenderStage_proto, _SE(js_pipeline_BloomStage_constructor)); - cls->defineProperty("threshold", _SE(js_pipeline_BloomStage_getThreshold), _SE(js_pipeline_BloomStage_setThreshold)); - cls->defineProperty("intensity", _SE(js_pipeline_BloomStage_getIntensity), _SE(js_pipeline_BloomStage_setIntensity)); - cls->defineProperty("iterations", _SE(js_pipeline_BloomStage_getIterations), _SE(js_pipeline_BloomStage_setIterations)); + cls->defineProperty("threshold", _SE(js_pipeline_BloomStage_getThreshold_asGetter), _SE(js_pipeline_BloomStage_setThreshold_asSetter)); + cls->defineProperty("intensity", _SE(js_pipeline_BloomStage_getIntensity_asGetter), _SE(js_pipeline_BloomStage_setIntensity_asSetter)); + cls->defineProperty("iterations", _SE(js_pipeline_BloomStage_getIterations_asGetter), _SE(js_pipeline_BloomStage_setIterations_asSetter)); cls->defineFunction("getCombineUBO", _SE(js_pipeline_BloomStage_getCombineUBO)); - cls->defineFunction("getDownsampelUBO", _SE(js_pipeline_BloomStage_getDownsampelUBO)); + cls->defineFunction("getDownsampleUBO", _SE(js_pipeline_BloomStage_getDownsampleUBO)); cls->defineFunction("getPrefilterUBO", _SE(js_pipeline_BloomStage_getPrefilterUBO)); cls->defineFunction("getSampler", _SE(js_pipeline_BloomStage_getSampler)); cls->defineFunction("getUpsampleUBO", _SE(js_pipeline_BloomStage_getUpsampleUBO)); - cls->defineStaticFunction("getInitializeInfo", _SE(js_pipeline_BloomStage_getInitializeInfo)); + cls->defineStaticFunction("getInitializeInfo", _SE(js_pipeline_BloomStage_getInitializeInfo_static)); cls->defineFinalizeFunction(_SE(js_cc_pipeline_BloomStage_finalize)); cls->install(); JSBClassType::registerClass(cls); @@ -3102,13 +3808,14 @@ bool js_register_pipeline_BloomStage(se::Object* obj) // NOLINT(readability-iden __jsb_cc_pipeline_BloomStage_proto = cls->getProto(); __jsb_cc_pipeline_BloomStage_class = cls; + se::ScriptEngine::getInstance()->clearException(); return true; } -se::Object* __jsb_cc_pipeline_PostProcessStage_proto = nullptr; -se::Class* __jsb_cc_pipeline_PostProcessStage_class = nullptr; +se::Object* __jsb_cc_pipeline_PostProcessStage_proto = nullptr; // NOLINT +se::Class* __jsb_cc_pipeline_PostProcessStage_class = nullptr; // NOLINT -static bool js_pipeline_PostProcessStage_getInitializeInfo(se::State& s) // NOLINT(readability-identifier-naming) +static bool js_pipeline_PostProcessStage_getInitializeInfo_static(se::State& s) // NOLINT(readability-identifier-naming) { const auto& args = s.args(); size_t argc = args.size(); @@ -3116,37 +3823,27 @@ static bool js_pipeline_PostProcessStage_getInitializeInfo(se::State& s) // NOLI if (argc == 0) { const cc::pipeline::RenderStageInfo& result = cc::pipeline::PostProcessStage::getInitializeInfo(); ok &= nativevalue_to_se(result, s.rval(), nullptr /*ctx*/); - SE_PRECONDITION2(ok, false, "js_pipeline_PostProcessStage_getInitializeInfo : Error processing arguments"); + SE_PRECONDITION2(ok, false, "js_pipeline_PostProcessStage_getInitializeInfo_static : Error processing arguments"); SE_HOLD_RETURN_VALUE(result, s.thisObject(), s.rval()); return true; } SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 0); return false; } -SE_BIND_FUNC(js_pipeline_PostProcessStage_getInitializeInfo) +SE_BIND_FUNC(js_pipeline_PostProcessStage_getInitializeInfo_static) SE_DECLARE_FINALIZE_FUNC(js_cc_pipeline_PostProcessStage_finalize) static bool js_pipeline_PostProcessStage_constructor(se::State& s) // NOLINT(readability-identifier-naming) constructor.c { - cc::pipeline::PostProcessStage* cobj = JSB_ALLOC(cc::pipeline::PostProcessStage); - s.thisObject()->setPrivateData(cobj); - se::NonRefNativePtrCreatedByCtorMap::emplace(cobj); + auto *ptr = JSB_MAKE_PRIVATE_OBJECT(cc::pipeline::PostProcessStage); + s.thisObject()->setPrivateObject(ptr); return true; } SE_BIND_CTOR(js_pipeline_PostProcessStage_constructor, __jsb_cc_pipeline_PostProcessStage_class, js_cc_pipeline_PostProcessStage_finalize) - - static bool js_cc_pipeline_PostProcessStage_finalize(se::State& s) // NOLINT(readability-identifier-naming) { - auto iter = se::NonRefNativePtrCreatedByCtorMap::find(SE_THIS_OBJECT(s)); - if (iter != se::NonRefNativePtrCreatedByCtorMap::end()) - { - se::NonRefNativePtrCreatedByCtorMap::erase(iter); - auto* cobj = SE_THIS_OBJECT(s); - JSB_FREE(cobj); - } return true; } SE_BIND_FINALIZE_FUNC(js_cc_pipeline_PostProcessStage_finalize) @@ -3155,7 +3852,7 @@ bool js_register_pipeline_PostProcessStage(se::Object* obj) // NOLINT(readabilit { auto* cls = se::Class::create("PostProcessStage", obj, __jsb_cc_pipeline_RenderStage_proto, _SE(js_pipeline_PostProcessStage_constructor)); - cls->defineStaticFunction("getInitializeInfo", _SE(js_pipeline_PostProcessStage_getInitializeInfo)); + cls->defineStaticFunction("getInitializeInfo", _SE(js_pipeline_PostProcessStage_getInitializeInfo_static)); cls->defineFinalizeFunction(_SE(js_cc_pipeline_PostProcessStage_finalize)); cls->install(); JSBClassType::registerClass(cls); @@ -3163,34 +3860,757 @@ bool js_register_pipeline_PostProcessStage(se::Object* obj) // NOLINT(readabilit __jsb_cc_pipeline_PostProcessStage_proto = cls->getProto(); __jsb_cc_pipeline_PostProcessStage_class = cls; + se::ScriptEngine::getInstance()->clearException(); return true; } -se::Object* __jsb_cc_pipeline_GeometryRenderer_proto = nullptr; -se::Class* __jsb_cc_pipeline_GeometryRenderer_class = nullptr; +se::Object* __jsb_cc_pipeline_BatchedItem_proto = nullptr; // NOLINT +se::Class* __jsb_cc_pipeline_BatchedItem_class = nullptr; // NOLINT + +static bool js_pipeline_BatchedItem_get_vbs(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_pipeline_BatchedItem_get_vbs : Invalid Native Object"); + + CC_UNUSED bool ok = true; + se::Value jsret; + ok &= nativevalue_to_se(cobj->vbs, jsret, s.thisObject() /*ctx*/); + s.rval() = jsret; + SE_HOLD_RETURN_VALUE(cobj->vbs, s.thisObject(), s.rval()); + return true; +} +SE_BIND_PROP_GET(js_pipeline_BatchedItem_get_vbs) + +static bool js_pipeline_BatchedItem_set_vbs(se::State& s) // NOLINT(readability-identifier-naming) +{ + const auto& args = s.args(); + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_pipeline_BatchedItem_set_vbs : Invalid Native Object"); + + CC_UNUSED bool ok = true; + ok &= sevalue_to_native(args[0], &cobj->vbs, s.thisObject()); + SE_PRECONDITION2(ok, false, "js_pipeline_BatchedItem_set_vbs : Error processing new value"); + return true; +} +SE_BIND_PROP_SET(js_pipeline_BatchedItem_set_vbs) + +static bool js_pipeline_BatchedItem_get_vbDatas(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_pipeline_BatchedItem_get_vbDatas : Invalid Native Object"); + + CC_UNUSED bool ok = true; + se::Value jsret; + ok &= nativevalue_to_se(cobj->vbDatas, jsret, s.thisObject() /*ctx*/); + s.rval() = jsret; + SE_HOLD_RETURN_VALUE(cobj->vbDatas, s.thisObject(), s.rval()); + return true; +} +SE_BIND_PROP_GET(js_pipeline_BatchedItem_get_vbDatas) + +static bool js_pipeline_BatchedItem_set_vbDatas(se::State& s) // NOLINT(readability-identifier-naming) +{ + const auto& args = s.args(); + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_pipeline_BatchedItem_set_vbDatas : Invalid Native Object"); + + CC_UNUSED bool ok = true; + ok &= sevalue_to_native(args[0], &cobj->vbDatas, s.thisObject()); + SE_PRECONDITION2(ok, false, "js_pipeline_BatchedItem_set_vbDatas : Error processing new value"); + return true; +} +SE_BIND_PROP_SET(js_pipeline_BatchedItem_set_vbDatas) + +static bool js_pipeline_BatchedItem_get_indexBuffer(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_pipeline_BatchedItem_get_indexBuffer : Invalid Native Object"); + + CC_UNUSED bool ok = true; + se::Value jsret; + ok &= nativevalue_to_se(cobj->indexBuffer, jsret, s.thisObject() /*ctx*/); + s.rval() = jsret; + SE_HOLD_RETURN_VALUE(cobj->indexBuffer, s.thisObject(), s.rval()); + return true; +} +SE_BIND_PROP_GET(js_pipeline_BatchedItem_get_indexBuffer) + +static bool js_pipeline_BatchedItem_set_indexBuffer(se::State& s) // NOLINT(readability-identifier-naming) +{ + const auto& args = s.args(); + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_pipeline_BatchedItem_set_indexBuffer : Invalid Native Object"); + + CC_UNUSED bool ok = true; + ok &= sevalue_to_native(args[0], &cobj->indexBuffer, s.thisObject()); + SE_PRECONDITION2(ok, false, "js_pipeline_BatchedItem_set_indexBuffer : Error processing new value"); + return true; +} +SE_BIND_PROP_SET(js_pipeline_BatchedItem_set_indexBuffer) + +static bool js_pipeline_BatchedItem_get_indexData(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_pipeline_BatchedItem_get_indexData : Invalid Native Object"); + + CC_UNUSED bool ok = true; + se::Value jsret; + ok &= nativevalue_to_se(cobj->indexData, jsret, s.thisObject() /*ctx*/); + s.rval() = jsret; + SE_HOLD_RETURN_VALUE(cobj->indexData, s.thisObject(), s.rval()); + return true; +} +SE_BIND_PROP_GET(js_pipeline_BatchedItem_get_indexData) + +static bool js_pipeline_BatchedItem_set_indexData(se::State& s) // NOLINT(readability-identifier-naming) +{ + const auto& args = s.args(); + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_pipeline_BatchedItem_set_indexData : Invalid Native Object"); + + CC_UNUSED bool ok = true; + ok &= sevalue_to_native(args[0], &cobj->indexData, s.thisObject()); + SE_PRECONDITION2(ok, false, "js_pipeline_BatchedItem_set_indexData : Error processing new value"); + return true; +} +SE_BIND_PROP_SET(js_pipeline_BatchedItem_set_indexData) + +static bool js_pipeline_BatchedItem_get_vbCount(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_pipeline_BatchedItem_get_vbCount : Invalid Native Object"); + + CC_UNUSED bool ok = true; + se::Value jsret; + ok &= nativevalue_to_se(cobj->vbCount, jsret, s.thisObject() /*ctx*/); + s.rval() = jsret; + SE_HOLD_RETURN_VALUE(cobj->vbCount, s.thisObject(), s.rval()); + return true; +} +SE_BIND_PROP_GET(js_pipeline_BatchedItem_get_vbCount) + +static bool js_pipeline_BatchedItem_set_vbCount(se::State& s) // NOLINT(readability-identifier-naming) +{ + const auto& args = s.args(); + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_pipeline_BatchedItem_set_vbCount : Invalid Native Object"); + + CC_UNUSED bool ok = true; + ok &= sevalue_to_native(args[0], &cobj->vbCount, s.thisObject()); + SE_PRECONDITION2(ok, false, "js_pipeline_BatchedItem_set_vbCount : Error processing new value"); + return true; +} +SE_BIND_PROP_SET(js_pipeline_BatchedItem_set_vbCount) + +static bool js_pipeline_BatchedItem_get_mergeCount(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_pipeline_BatchedItem_get_mergeCount : Invalid Native Object"); + + CC_UNUSED bool ok = true; + se::Value jsret; + ok &= nativevalue_to_se(cobj->mergeCount, jsret, s.thisObject() /*ctx*/); + s.rval() = jsret; + SE_HOLD_RETURN_VALUE(cobj->mergeCount, s.thisObject(), s.rval()); + return true; +} +SE_BIND_PROP_GET(js_pipeline_BatchedItem_get_mergeCount) + +static bool js_pipeline_BatchedItem_set_mergeCount(se::State& s) // NOLINT(readability-identifier-naming) +{ + const auto& args = s.args(); + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_pipeline_BatchedItem_set_mergeCount : Invalid Native Object"); + + CC_UNUSED bool ok = true; + ok &= sevalue_to_native(args[0], &cobj->mergeCount, s.thisObject()); + SE_PRECONDITION2(ok, false, "js_pipeline_BatchedItem_set_mergeCount : Error processing new value"); + return true; +} +SE_BIND_PROP_SET(js_pipeline_BatchedItem_set_mergeCount) + +static bool js_pipeline_BatchedItem_get_ia(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_pipeline_BatchedItem_get_ia : Invalid Native Object"); + + CC_UNUSED bool ok = true; + se::Value jsret; + ok &= nativevalue_to_se(cobj->ia, jsret, s.thisObject() /*ctx*/); + s.rval() = jsret; + SE_HOLD_RETURN_VALUE(cobj->ia, s.thisObject(), s.rval()); + return true; +} +SE_BIND_PROP_GET(js_pipeline_BatchedItem_get_ia) + +static bool js_pipeline_BatchedItem_set_ia(se::State& s) // NOLINT(readability-identifier-naming) +{ + const auto& args = s.args(); + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_pipeline_BatchedItem_set_ia : Invalid Native Object"); + + CC_UNUSED bool ok = true; + ok &= sevalue_to_native(args[0], &cobj->ia, s.thisObject()); + SE_PRECONDITION2(ok, false, "js_pipeline_BatchedItem_set_ia : Error processing new value"); + return true; +} +SE_BIND_PROP_SET(js_pipeline_BatchedItem_set_ia) + +static bool js_pipeline_BatchedItem_get_ubo(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_pipeline_BatchedItem_get_ubo : Invalid Native Object"); + + CC_UNUSED bool ok = true; + se::Value jsret; + ok &= nativevalue_to_se(cobj->ubo, jsret, s.thisObject() /*ctx*/); + s.rval() = jsret; + SE_HOLD_RETURN_VALUE(cobj->ubo, s.thisObject(), s.rval()); + return true; +} +SE_BIND_PROP_GET(js_pipeline_BatchedItem_get_ubo) + +static bool js_pipeline_BatchedItem_set_ubo(se::State& s) // NOLINT(readability-identifier-naming) +{ + const auto& args = s.args(); + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_pipeline_BatchedItem_set_ubo : Invalid Native Object"); + + CC_UNUSED bool ok = true; + ok &= sevalue_to_native(args[0], &cobj->ubo, s.thisObject()); + SE_PRECONDITION2(ok, false, "js_pipeline_BatchedItem_set_ubo : Error processing new value"); + return true; +} +SE_BIND_PROP_SET(js_pipeline_BatchedItem_set_ubo) + +static bool js_pipeline_BatchedItem_get_uboData(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_pipeline_BatchedItem_get_uboData : Invalid Native Object"); + + CC_UNUSED bool ok = true; + se::Value jsret; + ok &= nativevalue_to_se(cobj->uboData, jsret, s.thisObject() /*ctx*/); + s.rval() = jsret; + SE_HOLD_RETURN_VALUE(cobj->uboData, s.thisObject(), s.rval()); + return true; +} +SE_BIND_PROP_GET(js_pipeline_BatchedItem_get_uboData) + +static bool js_pipeline_BatchedItem_set_uboData(se::State& s) // NOLINT(readability-identifier-naming) +{ + const auto& args = s.args(); + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_pipeline_BatchedItem_set_uboData : Invalid Native Object"); + + CC_UNUSED bool ok = true; + ok &= sevalue_to_native(args[0], &cobj->uboData, s.thisObject()); + SE_PRECONDITION2(ok, false, "js_pipeline_BatchedItem_set_uboData : Error processing new value"); + return true; +} +SE_BIND_PROP_SET(js_pipeline_BatchedItem_set_uboData) + +static bool js_pipeline_BatchedItem_get_descriptorSet(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_pipeline_BatchedItem_get_descriptorSet : Invalid Native Object"); + + CC_UNUSED bool ok = true; + se::Value jsret; + ok &= nativevalue_to_se(cobj->descriptorSet, jsret, s.thisObject() /*ctx*/); + s.rval() = jsret; + SE_HOLD_RETURN_VALUE(cobj->descriptorSet, s.thisObject(), s.rval()); + return true; +} +SE_BIND_PROP_GET(js_pipeline_BatchedItem_get_descriptorSet) + +static bool js_pipeline_BatchedItem_set_descriptorSet(se::State& s) // NOLINT(readability-identifier-naming) +{ + const auto& args = s.args(); + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_pipeline_BatchedItem_set_descriptorSet : Invalid Native Object"); + + CC_UNUSED bool ok = true; + ok &= sevalue_to_native(args[0], &cobj->descriptorSet, s.thisObject()); + SE_PRECONDITION2(ok, false, "js_pipeline_BatchedItem_set_descriptorSet : Error processing new value"); + return true; +} +SE_BIND_PROP_SET(js_pipeline_BatchedItem_set_descriptorSet) + +static bool js_pipeline_BatchedItem_get_pass(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_pipeline_BatchedItem_get_pass : Invalid Native Object"); + + CC_UNUSED bool ok = true; + se::Value jsret; + ok &= nativevalue_to_se(cobj->pass, jsret, s.thisObject() /*ctx*/); + s.rval() = jsret; + SE_HOLD_RETURN_VALUE(cobj->pass, s.thisObject(), s.rval()); + return true; +} +SE_BIND_PROP_GET(js_pipeline_BatchedItem_get_pass) + +static bool js_pipeline_BatchedItem_set_pass(se::State& s) // NOLINT(readability-identifier-naming) +{ + const auto& args = s.args(); + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_pipeline_BatchedItem_set_pass : Invalid Native Object"); + + CC_UNUSED bool ok = true; + ok &= sevalue_to_native(args[0], &cobj->pass, s.thisObject()); + SE_PRECONDITION2(ok, false, "js_pipeline_BatchedItem_set_pass : Error processing new value"); + return true; +} +SE_BIND_PROP_SET(js_pipeline_BatchedItem_set_pass) + +static bool js_pipeline_BatchedItem_get_shader(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_pipeline_BatchedItem_get_shader : Invalid Native Object"); + + CC_UNUSED bool ok = true; + se::Value jsret; + ok &= nativevalue_to_se(cobj->shader, jsret, s.thisObject() /*ctx*/); + s.rval() = jsret; + SE_HOLD_RETURN_VALUE(cobj->shader, s.thisObject(), s.rval()); + return true; +} +SE_BIND_PROP_GET(js_pipeline_BatchedItem_get_shader) + +static bool js_pipeline_BatchedItem_set_shader(se::State& s) // NOLINT(readability-identifier-naming) +{ + const auto& args = s.args(); + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_pipeline_BatchedItem_set_shader : Invalid Native Object"); + + CC_UNUSED bool ok = true; + ok &= sevalue_to_native(args[0], &cobj->shader, s.thisObject()); + SE_PRECONDITION2(ok, false, "js_pipeline_BatchedItem_set_shader : Error processing new value"); + return true; +} +SE_BIND_PROP_SET(js_pipeline_BatchedItem_set_shader) + + +template<> +bool sevalue_to_native(const se::Value &from, cc::pipeline::BatchedItem * to, se::Object *ctx) +{ + assert(from.isObject()); + se::Object *json = from.toObject(); + auto* data = reinterpret_cast(json->getPrivateData()); + if (data) { + *to = *data; + return true; + } + se::Value field; + bool ok = true; + json->getProperty("vbs", &field, true); + if(!field.isNullOrUndefined()) { + ok &= sevalue_to_native(field, &(to->vbs), ctx); + } + json->getProperty("vbDatas", &field, true); + if(!field.isNullOrUndefined()) { + ok &= sevalue_to_native(field, &(to->vbDatas), ctx); + } + json->getProperty("indexBuffer", &field, true); + if(!field.isNullOrUndefined()) { + ok &= sevalue_to_native(field, &(to->indexBuffer), ctx); + } + json->getProperty("indexData", &field, true); + if(!field.isNullOrUndefined()) { + ok &= sevalue_to_native(field, &(to->indexData), ctx); + } + json->getProperty("vbCount", &field, true); + if(!field.isNullOrUndefined()) { + ok &= sevalue_to_native(field, &(to->vbCount), ctx); + } + json->getProperty("mergeCount", &field, true); + if(!field.isNullOrUndefined()) { + ok &= sevalue_to_native(field, &(to->mergeCount), ctx); + } + json->getProperty("ia", &field, true); + if(!field.isNullOrUndefined()) { + ok &= sevalue_to_native(field, &(to->ia), ctx); + } + json->getProperty("ubo", &field, true); + if(!field.isNullOrUndefined()) { + ok &= sevalue_to_native(field, &(to->ubo), ctx); + } + json->getProperty("uboData", &field, true); + if(!field.isNullOrUndefined()) { + ok &= sevalue_to_native(field, &(to->uboData), ctx); + } + json->getProperty("descriptorSet", &field, true); + if(!field.isNullOrUndefined()) { + ok &= sevalue_to_native(field, &(to->descriptorSet), ctx); + } + json->getProperty("pass", &field, true); + if(!field.isNullOrUndefined()) { + ok &= sevalue_to_native(field, &(to->pass), ctx); + } + json->getProperty("shader", &field, true); + if(!field.isNullOrUndefined()) { + ok &= sevalue_to_native(field, &(to->shader), ctx); + } + return ok; +} + +SE_DECLARE_FINALIZE_FUNC(js_cc_pipeline_BatchedItem_finalize) + +static bool js_pipeline_BatchedItem_constructor(se::State& s) // NOLINT(readability-identifier-naming) +{ + CC_UNUSED bool ok = true; + const auto& args = s.args(); + size_t argc = args.size(); + + if(argc == 0) + { + auto *ptr = JSB_MAKE_PRIVATE_OBJECT(cc::pipeline::BatchedItem); + s.thisObject()->setPrivateObject(ptr); + return true; + } + + if(argc == 1 && args[0].isObject()) + { + se::Object *json = args[0].toObject(); + se::Value field; + auto *ptr = JSB_MAKE_PRIVATE_OBJECT(cc::pipeline::BatchedItem); + auto cobj = ptr->get(); + ok &= sevalue_to_native(args[0], cobj, s.thisObject()); + if(!ok) { + delete ptr; + SE_REPORT_ERROR("argument convertion error"); + return false; + } + s.thisObject()->setPrivateObject(ptr); + return true; + } + auto *ptr = JSB_MAKE_PRIVATE_OBJECT(cc::pipeline::BatchedItem); + auto cobj = ptr->get(); + if (argc > 0 && !args[0].isUndefined()) { + ok &= sevalue_to_native(args[0], &(cobj->vbs), nullptr); + } + if (argc > 1 && !args[1].isUndefined()) { + ok &= sevalue_to_native(args[1], &(cobj->vbDatas), nullptr); + } + if (argc > 2 && !args[2].isUndefined()) { + ok &= sevalue_to_native(args[2], &(cobj->indexBuffer), nullptr); + } + if (argc > 3 && !args[3].isUndefined()) { + ok &= sevalue_to_native(args[3], &(cobj->indexData), nullptr); + } + if (argc > 4 && !args[4].isUndefined()) { + ok &= sevalue_to_native(args[4], &(cobj->vbCount), nullptr); + } + if (argc > 5 && !args[5].isUndefined()) { + ok &= sevalue_to_native(args[5], &(cobj->mergeCount), nullptr); + } + if (argc > 6 && !args[6].isUndefined()) { + ok &= sevalue_to_native(args[6], &(cobj->ia), nullptr); + } + if (argc > 7 && !args[7].isUndefined()) { + ok &= sevalue_to_native(args[7], &(cobj->ubo), nullptr); + } + if (argc > 8 && !args[8].isUndefined()) { + ok &= sevalue_to_native(args[8], &(cobj->uboData), nullptr); + } + if (argc > 9 && !args[9].isUndefined()) { + ok &= sevalue_to_native(args[9], &(cobj->descriptorSet), nullptr); + } + if (argc > 10 && !args[10].isUndefined()) { + ok &= sevalue_to_native(args[10], &(cobj->pass), nullptr); + } + if (argc > 11 && !args[11].isUndefined()) { + ok &= sevalue_to_native(args[11], &(cobj->shader), nullptr); + } + + if(!ok) { + delete ptr; + SE_REPORT_ERROR("Argument convertion error"); + return false; + } + s.thisObject()->setPrivateObject(ptr); + return true; +} +SE_BIND_CTOR(js_pipeline_BatchedItem_constructor, __jsb_cc_pipeline_BatchedItem_class, js_cc_pipeline_BatchedItem_finalize) + +static bool js_cc_pipeline_BatchedItem_finalize(se::State& s) // NOLINT(readability-identifier-naming) +{ + return true; +} +SE_BIND_FINALIZE_FUNC(js_cc_pipeline_BatchedItem_finalize) + +bool js_register_pipeline_BatchedItem(se::Object* obj) // NOLINT(readability-identifier-naming) +{ + auto* cls = se::Class::create("BatchedItem", obj, nullptr, _SE(js_pipeline_BatchedItem_constructor)); + + cls->defineProperty("vbs", _SE(js_pipeline_BatchedItem_get_vbs), _SE(js_pipeline_BatchedItem_set_vbs)); + cls->defineProperty("vbDatas", _SE(js_pipeline_BatchedItem_get_vbDatas), _SE(js_pipeline_BatchedItem_set_vbDatas)); + cls->defineProperty("indexBuffer", _SE(js_pipeline_BatchedItem_get_indexBuffer), _SE(js_pipeline_BatchedItem_set_indexBuffer)); + cls->defineProperty("indexData", _SE(js_pipeline_BatchedItem_get_indexData), _SE(js_pipeline_BatchedItem_set_indexData)); + cls->defineProperty("vbCount", _SE(js_pipeline_BatchedItem_get_vbCount), _SE(js_pipeline_BatchedItem_set_vbCount)); + cls->defineProperty("mergeCount", _SE(js_pipeline_BatchedItem_get_mergeCount), _SE(js_pipeline_BatchedItem_set_mergeCount)); + cls->defineProperty("ia", _SE(js_pipeline_BatchedItem_get_ia), _SE(js_pipeline_BatchedItem_set_ia)); + cls->defineProperty("ubo", _SE(js_pipeline_BatchedItem_get_ubo), _SE(js_pipeline_BatchedItem_set_ubo)); + cls->defineProperty("uboData", _SE(js_pipeline_BatchedItem_get_uboData), _SE(js_pipeline_BatchedItem_set_uboData)); + cls->defineProperty("descriptorSet", _SE(js_pipeline_BatchedItem_get_descriptorSet), _SE(js_pipeline_BatchedItem_set_descriptorSet)); + cls->defineProperty("pass", _SE(js_pipeline_BatchedItem_get_pass), _SE(js_pipeline_BatchedItem_set_pass)); + cls->defineProperty("shader", _SE(js_pipeline_BatchedItem_get_shader), _SE(js_pipeline_BatchedItem_set_shader)); + cls->defineFinalizeFunction(_SE(js_cc_pipeline_BatchedItem_finalize)); + cls->install(); + JSBClassType::registerClass(cls); + + __jsb_cc_pipeline_BatchedItem_proto = cls->getProto(); + __jsb_cc_pipeline_BatchedItem_class = cls; + + + se::ScriptEngine::getInstance()->clearException(); + return true; +} +se::Object* __jsb_cc_pipeline_BatchedBuffer_proto = nullptr; // NOLINT +se::Class* __jsb_cc_pipeline_BatchedBuffer_class = nullptr; // NOLINT + +static bool js_pipeline_BatchedBuffer_clear(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_pipeline_BatchedBuffer_clear : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + if (argc == 0) { + cobj->clear(); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 0); + return false; +} +SE_BIND_FUNC(js_pipeline_BatchedBuffer_clear) + +static bool js_pipeline_BatchedBuffer_destroy(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_pipeline_BatchedBuffer_destroy : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + if (argc == 0) { + cobj->destroy(); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 0); + return false; +} +SE_BIND_FUNC(js_pipeline_BatchedBuffer_destroy) + +static bool js_pipeline_BatchedBuffer_getBatches(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_pipeline_BatchedBuffer_getBatches : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 0) { + const std::vector& result = cobj->getBatches(); + ok &= nativevalue_to_se(result, s.rval(), nullptr /*ctx*/); + SE_PRECONDITION2(ok, false, "js_pipeline_BatchedBuffer_getBatches : Error processing arguments"); + SE_HOLD_RETURN_VALUE(result, s.thisObject(), s.rval()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 0); + return false; +} +SE_BIND_FUNC(js_pipeline_BatchedBuffer_getBatches) + +static bool js_pipeline_BatchedBuffer_getDynamicOffset(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_pipeline_BatchedBuffer_getDynamicOffset : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 0) { + const std::vector& result = cobj->getDynamicOffset(); + ok &= nativevalue_to_se(result, s.rval(), nullptr /*ctx*/); + SE_PRECONDITION2(ok, false, "js_pipeline_BatchedBuffer_getDynamicOffset : Error processing arguments"); + SE_HOLD_RETURN_VALUE(result, s.thisObject(), s.rval()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 0); + return false; +} +SE_BIND_FUNC(js_pipeline_BatchedBuffer_getDynamicOffset) + +static bool js_pipeline_BatchedBuffer_getPass(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_pipeline_BatchedBuffer_getPass : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 0) { + const cc::scene::Pass* result = cobj->getPass(); + ok &= nativevalue_to_se(result, s.rval(), nullptr /*ctx*/); + SE_PRECONDITION2(ok, false, "js_pipeline_BatchedBuffer_getPass : Error processing arguments"); + SE_HOLD_RETURN_VALUE(result, s.thisObject(), s.rval()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 0); + return false; +} +SE_BIND_FUNC(js_pipeline_BatchedBuffer_getPass) + +static bool js_pipeline_BatchedBuffer_merge(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_pipeline_BatchedBuffer_merge : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 3) { + HolderType arg0 = {}; + HolderType arg1 = {}; + HolderType arg2 = {}; + ok &= sevalue_to_native(args[0], &arg0, s.thisObject()); + ok &= sevalue_to_native(args[1], &arg1, s.thisObject()); + ok &= sevalue_to_native(args[2], &arg2, s.thisObject()); + SE_PRECONDITION2(ok, false, "js_pipeline_BatchedBuffer_merge : Error processing arguments"); + cobj->merge(arg0.value(), arg1.value(), arg2.value()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 3); + return false; +} +SE_BIND_FUNC(js_pipeline_BatchedBuffer_merge) + +static bool js_pipeline_BatchedBuffer_setDynamicOffset(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_pipeline_BatchedBuffer_setDynamicOffset : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 2) { + HolderType arg0 = {}; + HolderType arg1 = {}; + ok &= sevalue_to_native(args[0], &arg0, s.thisObject()); + ok &= sevalue_to_native(args[1], &arg1, s.thisObject()); + SE_PRECONDITION2(ok, false, "js_pipeline_BatchedBuffer_setDynamicOffset : Error processing arguments"); + cobj->setDynamicOffset(arg0.value(), arg1.value()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 2); + return false; +} +SE_BIND_FUNC(js_pipeline_BatchedBuffer_setDynamicOffset) + +static bool js_pipeline_BatchedBuffer_destroyBatchedBuffer_static(se::State& s) // NOLINT(readability-identifier-naming) +{ + const auto& args = s.args(); + size_t argc = args.size(); + if (argc == 0) { + cc::pipeline::BatchedBuffer::destroyBatchedBuffer(); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 0); + return false; +} +SE_BIND_FUNC(js_pipeline_BatchedBuffer_destroyBatchedBuffer_static) + +static bool js_pipeline_BatchedBuffer_get_static(se::State& s) // NOLINT(readability-identifier-naming) +{ + CC_UNUSED bool ok = true; + const auto& args = s.args(); + size_t argc = args.size(); + do { + if (argc == 2) { + HolderType arg0 = {}; + ok &= sevalue_to_native(args[0], &arg0, s.thisObject()); + if (!ok) { ok = true; break; } + HolderType arg1 = {}; + ok &= sevalue_to_native(args[1], &arg1, s.thisObject()); + if (!ok) { ok = true; break; } + cc::pipeline::BatchedBuffer* result = cc::pipeline::BatchedBuffer::get(arg0.value(), arg1.value()); + ok &= nativevalue_to_se(result, s.rval(), s.thisObject() /*ctx*/); + SE_PRECONDITION2(ok, false, "js_pipeline_BatchedBuffer_get_static : Error processing arguments"); + SE_HOLD_RETURN_VALUE(result, s.thisObject(), s.rval()); + return true; + } + } while (false); + do { + if (argc == 1) { + HolderType arg0 = {}; + ok &= sevalue_to_native(args[0], &arg0, s.thisObject()); + if (!ok) { ok = true; break; } + cc::pipeline::BatchedBuffer* result = cc::pipeline::BatchedBuffer::get(arg0.value()); + ok &= nativevalue_to_se(result, s.rval(), s.thisObject() /*ctx*/); + SE_PRECONDITION2(ok, false, "js_pipeline_BatchedBuffer_get_static : Error processing arguments"); + SE_HOLD_RETURN_VALUE(result, s.thisObject(), s.rval()); + return true; + } + } while (false); + SE_REPORT_ERROR("wrong number of arguments: %d", (int)argc); + return false; +} +SE_BIND_FUNC(js_pipeline_BatchedBuffer_get_static) + +SE_DECLARE_FINALIZE_FUNC(js_cc_pipeline_BatchedBuffer_finalize) + +static bool js_pipeline_BatchedBuffer_constructor(se::State& s) // NOLINT(readability-identifier-naming) constructor.c +{ + CC_UNUSED bool ok = true; + const auto& args = s.args(); + const cc::scene::Pass* arg0 = nullptr; + ok &= sevalue_to_native(args[0], &arg0, s.thisObject()); + SE_PRECONDITION2(ok, false, "js_pipeline_BatchedBuffer_constructor : Error processing arguments"); + auto *ptr = JSB_MAKE_PRIVATE_OBJECT(cc::pipeline::BatchedBuffer, arg0); + s.thisObject()->setPrivateObject(ptr); + return true; +} +SE_BIND_CTOR(js_pipeline_BatchedBuffer_constructor, __jsb_cc_pipeline_BatchedBuffer_class, js_cc_pipeline_BatchedBuffer_finalize) + +static bool js_cc_pipeline_BatchedBuffer_finalize(se::State& s) // NOLINT(readability-identifier-naming) +{ + return true; +} +SE_BIND_FINALIZE_FUNC(js_cc_pipeline_BatchedBuffer_finalize) + +bool js_register_pipeline_BatchedBuffer(se::Object* obj) // NOLINT(readability-identifier-naming) +{ + auto* cls = se::Class::create("BatchedBuffer", obj, nullptr, _SE(js_pipeline_BatchedBuffer_constructor)); + + cls->defineFunction("clear", _SE(js_pipeline_BatchedBuffer_clear)); + cls->defineFunction("destroy", _SE(js_pipeline_BatchedBuffer_destroy)); + cls->defineFunction("getBatches", _SE(js_pipeline_BatchedBuffer_getBatches)); + cls->defineFunction("getDynamicOffset", _SE(js_pipeline_BatchedBuffer_getDynamicOffset)); + cls->defineFunction("getPass", _SE(js_pipeline_BatchedBuffer_getPass)); + cls->defineFunction("merge", _SE(js_pipeline_BatchedBuffer_merge)); + cls->defineFunction("setDynamicOffset", _SE(js_pipeline_BatchedBuffer_setDynamicOffset)); + cls->defineStaticFunction("destroyBatchedBuffer", _SE(js_pipeline_BatchedBuffer_destroyBatchedBuffer_static)); + cls->defineStaticFunction("get", _SE(js_pipeline_BatchedBuffer_get_static)); + cls->defineFinalizeFunction(_SE(js_cc_pipeline_BatchedBuffer_finalize)); + cls->install(); + JSBClassType::registerClass(cls); + + __jsb_cc_pipeline_BatchedBuffer_proto = cls->getProto(); + __jsb_cc_pipeline_BatchedBuffer_class = cls; + + + se::ScriptEngine::getInstance()->clearException(); + return true; +} +se::Object* __jsb_cc_pipeline_GeometryRenderer_proto = nullptr; // NOLINT +se::Class* __jsb_cc_pipeline_GeometryRenderer_class = nullptr; // NOLINT SE_DECLARE_FINALIZE_FUNC(js_cc_pipeline_GeometryRenderer_finalize) static bool js_pipeline_GeometryRenderer_constructor(se::State& s) // NOLINT(readability-identifier-naming) constructor.c { - cc::pipeline::GeometryRenderer* cobj = JSB_ALLOC(cc::pipeline::GeometryRenderer); - s.thisObject()->setPrivateData(cobj); - se::NonRefNativePtrCreatedByCtorMap::emplace(cobj); + auto *ptr = JSB_MAKE_PRIVATE_OBJECT(cc::pipeline::GeometryRenderer); + s.thisObject()->setPrivateObject(ptr); return true; } SE_BIND_CTOR(js_pipeline_GeometryRenderer_constructor, __jsb_cc_pipeline_GeometryRenderer_class, js_cc_pipeline_GeometryRenderer_finalize) - - static bool js_cc_pipeline_GeometryRenderer_finalize(se::State& s) // NOLINT(readability-identifier-naming) { - auto iter = se::NonRefNativePtrCreatedByCtorMap::find(SE_THIS_OBJECT(s)); - if (iter != se::NonRefNativePtrCreatedByCtorMap::end()) - { - se::NonRefNativePtrCreatedByCtorMap::erase(iter); - auto* cobj = SE_THIS_OBJECT(s); - JSB_FREE(cobj); - } return true; } SE_BIND_FINALIZE_FUNC(js_cc_pipeline_GeometryRenderer_finalize) @@ -3206,14 +4626,15 @@ bool js_register_pipeline_GeometryRenderer(se::Object* obj) // NOLINT(readabilit __jsb_cc_pipeline_GeometryRenderer_proto = cls->getProto(); __jsb_cc_pipeline_GeometryRenderer_class = cls; + se::ScriptEngine::getInstance()->clearException(); return true; } -bool register_all_pipeline(se::Object* obj) +bool register_all_pipeline(se::Object* obj) // NOLINT { // Get the ns se::Value nsVal; - if (!obj->getProperty("nr", &nsVal)) + if (!obj->getProperty("nr", &nsVal, true)) { se::HandleObject jsobj(se::Object::createPlainObject()); nsVal.setObject(jsobj); @@ -3221,27 +4642,32 @@ bool register_all_pipeline(se::Object* obj) } se::Object* ns = nsVal.toObject(); - js_register_pipeline_RenderQueueDesc(ns); - js_register_pipeline_GlobalDSManager(ns); - js_register_pipeline_RenderPipelineInfo(ns); + js_register_pipeline_BatchedBuffer(ns); + js_register_pipeline_BatchedItem(ns); + js_register_pipeline_RenderStage(ns); + js_register_pipeline_BloomStage(ns); js_register_pipeline_RenderPipeline(ns); - js_register_pipeline_ForwardPipeline(ns); - js_register_pipeline_RenderFlowInfo(ns); + js_register_pipeline_DeferredPipeline(ns); js_register_pipeline_RenderFlow(ns); js_register_pipeline_ForwardFlow(ns); - js_register_pipeline_RenderStageInfo(ns); - js_register_pipeline_RenderStage(ns); + js_register_pipeline_ForwardPipeline(ns); js_register_pipeline_ForwardStage(ns); + js_register_pipeline_GbufferStage(ns); + js_register_pipeline_GeometryRenderer(ns); + js_register_pipeline_GlobalDSManager(ns); + js_register_pipeline_InstancedBuffer(ns); + js_register_pipeline_LightingStage(ns); + js_register_pipeline_MainFlow(ns); + js_register_pipeline_PipelineSceneData(ns); + js_register_pipeline_PostProcessStage(ns); + js_register_pipeline_RenderFlowInfo(ns); + js_register_pipeline_RenderObject(ns); + js_register_pipeline_RenderPipelineInfo(ns); + js_register_pipeline_RenderQueueDesc(ns); + js_register_pipeline_RenderStageInfo(ns); js_register_pipeline_ShadowFlow(ns); js_register_pipeline_ShadowStage(ns); - js_register_pipeline_InstancedBuffer(ns); - js_register_pipeline_DeferredPipeline(ns); - js_register_pipeline_MainFlow(ns); - js_register_pipeline_GbufferStage(ns); - js_register_pipeline_LightingStage(ns); - js_register_pipeline_BloomStage(ns); - js_register_pipeline_PostProcessStage(ns); - js_register_pipeline_GeometryRenderer(ns); return true; } +// clang-format on \ No newline at end of file diff --git a/native/cocos/bindings/auto/jsb_pipeline_auto.h b/native/cocos/bindings/auto/jsb_pipeline_auto.h index 983c1a29d0..364223ec74 100644 --- a/native/cocos/bindings/auto/jsb_pipeline_auto.h +++ b/native/cocos/bindings/auto/jsb_pipeline_auto.h @@ -1,3 +1,4 @@ +// clang-format off #pragma once #include "base/Config.h" #include @@ -5,6 +6,7 @@ #include "cocos/bindings/manual/jsb_conversions.h" #include "cocos/bindings/auto/jsb_gfx_auto.h" #include "cocos/bindings/auto/jsb_scene_auto.h" +#include "cocos/bindings/auto/jsb_assets_auto.h" #include "cocos/renderer/pipeline/forward/ForwardPipeline.h" #include "cocos/renderer/pipeline/forward/ForwardFlow.h" #include "cocos/renderer/pipeline/forward/ForwardStage.h" @@ -22,25 +24,60 @@ #include "cocos/renderer/pipeline/deferred/LightingStage.h" #include "cocos/renderer/pipeline/deferred/BloomStage.h" #include "cocos/renderer/pipeline/deferred/PostProcessStage.h" +#include "cocos/renderer/pipeline/PipelineSceneData.h" +#include "cocos/renderer/pipeline/BatchedBuffer.h" #include "cocos/renderer/pipeline/GeometryRenderer.h" -extern se::Object* __jsb_cc_pipeline_RenderQueueDesc_proto; -extern se::Class* __jsb_cc_pipeline_RenderQueueDesc_class; +bool register_all_pipeline(se::Object *obj); // NOLINT -bool js_register_cc_pipeline_RenderQueueDesc(se::Object* obj); -bool register_all_pipeline(se::Object* obj); - -template<> -bool sevalue_to_native(const se::Value &, cc::pipeline::RenderQueueDesc *, se::Object *ctx); +JSB_REGISTER_OBJECT_TYPE(cc::pipeline::RenderObject); JSB_REGISTER_OBJECT_TYPE(cc::pipeline::RenderQueueDesc); - -extern se::Object* __jsb_cc_pipeline_GlobalDSManager_proto; -extern se::Class* __jsb_cc_pipeline_GlobalDSManager_class; - -bool js_register_cc_pipeline_GlobalDSManager(se::Object* obj); -bool register_all_pipeline(se::Object* obj); - JSB_REGISTER_OBJECT_TYPE(cc::pipeline::GlobalDSManager); +JSB_REGISTER_OBJECT_TYPE(cc::pipeline::PipelineSceneData); +JSB_REGISTER_OBJECT_TYPE(cc::pipeline::RenderPipelineInfo); +JSB_REGISTER_OBJECT_TYPE(cc::pipeline::RenderPipeline); +JSB_REGISTER_OBJECT_TYPE(cc::pipeline::ForwardPipeline); +JSB_REGISTER_OBJECT_TYPE(cc::pipeline::RenderFlowInfo); +JSB_REGISTER_OBJECT_TYPE(cc::pipeline::RenderFlow); +JSB_REGISTER_OBJECT_TYPE(cc::pipeline::ForwardFlow); +JSB_REGISTER_OBJECT_TYPE(cc::pipeline::RenderStageInfo); +JSB_REGISTER_OBJECT_TYPE(cc::pipeline::RenderStage); +JSB_REGISTER_OBJECT_TYPE(cc::pipeline::ForwardStage); +JSB_REGISTER_OBJECT_TYPE(cc::pipeline::ShadowFlow); +JSB_REGISTER_OBJECT_TYPE(cc::pipeline::ShadowStage); +JSB_REGISTER_OBJECT_TYPE(cc::pipeline::InstancedBuffer); +JSB_REGISTER_OBJECT_TYPE(cc::pipeline::DeferredPipeline); +JSB_REGISTER_OBJECT_TYPE(cc::pipeline::MainFlow); +JSB_REGISTER_OBJECT_TYPE(cc::pipeline::GbufferStage); +JSB_REGISTER_OBJECT_TYPE(cc::pipeline::LightingStage); +JSB_REGISTER_OBJECT_TYPE(cc::pipeline::BloomStage); +JSB_REGISTER_OBJECT_TYPE(cc::pipeline::PostProcessStage); +JSB_REGISTER_OBJECT_TYPE(cc::pipeline::BatchedItem); +JSB_REGISTER_OBJECT_TYPE(cc::pipeline::BatchedBuffer); +JSB_REGISTER_OBJECT_TYPE(cc::pipeline::GeometryRenderer); + + +extern se::Object *__jsb_cc_pipeline_RenderObject_proto; // NOLINT +extern se::Class * __jsb_cc_pipeline_RenderObject_class; // NOLINT + +bool js_register_cc_pipeline_RenderObject(se::Object *obj); // NOLINT + +template <> +bool sevalue_to_native(const se::Value &, cc::pipeline::RenderObject *, se::Object *ctx); //NOLINT + +extern se::Object *__jsb_cc_pipeline_RenderQueueDesc_proto; // NOLINT +extern se::Class * __jsb_cc_pipeline_RenderQueueDesc_class; // NOLINT + +bool js_register_cc_pipeline_RenderQueueDesc(se::Object *obj); // NOLINT + +template <> +bool sevalue_to_native(const se::Value &, cc::pipeline::RenderQueueDesc *, se::Object *ctx); //NOLINT + +extern se::Object *__jsb_cc_pipeline_GlobalDSManager_proto; // NOLINT +extern se::Class * __jsb_cc_pipeline_GlobalDSManager_class; // NOLINT + +bool js_register_cc_pipeline_GlobalDSManager(se::Object *obj); // NOLINT + SE_DECLARE_FUNC(js_pipeline_GlobalDSManager_bindBuffer); SE_DECLARE_FUNC(js_pipeline_GlobalDSManager_bindSampler); SE_DECLARE_FUNC(js_pipeline_GlobalDSManager_bindTexture); @@ -51,234 +88,250 @@ SE_DECLARE_FUNC(js_pipeline_GlobalDSManager_getLinearSampler); SE_DECLARE_FUNC(js_pipeline_GlobalDSManager_getOrCreateDescriptorSet); SE_DECLARE_FUNC(js_pipeline_GlobalDSManager_getPointSampler); SE_DECLARE_FUNC(js_pipeline_GlobalDSManager_update); +SE_DECLARE_FUNC(js_pipeline_GlobalDSManager_setDescriptorSetLayout); SE_DECLARE_FUNC(js_pipeline_GlobalDSManager_GlobalDSManager); -extern se::Object* __jsb_cc_pipeline_RenderPipelineInfo_proto; -extern se::Class* __jsb_cc_pipeline_RenderPipelineInfo_class; +extern se::Object *__jsb_cc_pipeline_PipelineSceneData_proto; // NOLINT +extern se::Class * __jsb_cc_pipeline_PipelineSceneData_class; // NOLINT -bool js_register_cc_pipeline_RenderPipelineInfo(se::Object* obj); -bool register_all_pipeline(se::Object* obj); +bool js_register_cc_pipeline_PipelineSceneData(se::Object *obj); // NOLINT -template<> -bool sevalue_to_native(const se::Value &, cc::pipeline::RenderPipelineInfo *, se::Object *ctx); -JSB_REGISTER_OBJECT_TYPE(cc::pipeline::RenderPipelineInfo); +SE_DECLARE_FUNC(js_pipeline_PipelineSceneData_activate); +SE_DECLARE_FUNC(js_pipeline_PipelineSceneData_destroy); +SE_DECLARE_FUNC(js_pipeline_PipelineSceneData_getDirShadowObjects); +SE_DECLARE_FUNC(js_pipeline_PipelineSceneData_getGeometryRendererMaterials); +SE_DECLARE_FUNC(js_pipeline_PipelineSceneData_getGeometryRendererPasses); +SE_DECLARE_FUNC(js_pipeline_PipelineSceneData_getGeometryRendererShaders); +SE_DECLARE_FUNC(js_pipeline_PipelineSceneData_getMatShadowProj); +SE_DECLARE_FUNC(js_pipeline_PipelineSceneData_getMatShadowView); +SE_DECLARE_FUNC(js_pipeline_PipelineSceneData_getMatShadowViewProj); +SE_DECLARE_FUNC(js_pipeline_PipelineSceneData_getOcclusionQueryInputAssembler); +SE_DECLARE_FUNC(js_pipeline_PipelineSceneData_getOcclusionQueryPass); +SE_DECLARE_FUNC(js_pipeline_PipelineSceneData_getOcclusionQueryShader); +SE_DECLARE_FUNC(js_pipeline_PipelineSceneData_getOctree); +SE_DECLARE_FUNC(js_pipeline_PipelineSceneData_getShadowCameraFar); +SE_DECLARE_FUNC(js_pipeline_PipelineSceneData_getValidPunctualLights); +SE_DECLARE_FUNC(js_pipeline_PipelineSceneData_isCastShadowObjects); +SE_DECLARE_FUNC(js_pipeline_PipelineSceneData_onGlobalPipelineStateChanged); +SE_DECLARE_FUNC(js_pipeline_PipelineSceneData_setCastShadowObjects); +SE_DECLARE_FUNC(js_pipeline_PipelineSceneData_setDirShadowObjects); +SE_DECLARE_FUNC(js_pipeline_PipelineSceneData_setMatShadowProj); +SE_DECLARE_FUNC(js_pipeline_PipelineSceneData_setMatShadowView); +SE_DECLARE_FUNC(js_pipeline_PipelineSceneData_setMatShadowViewProj); +SE_DECLARE_FUNC(js_pipeline_PipelineSceneData_setShadowCameraFar); +SE_DECLARE_FUNC(js_pipeline_PipelineSceneData_setShadowFramebuffer); +SE_DECLARE_FUNC(js_pipeline_PipelineSceneData_setValidPunctualLights); +SE_DECLARE_FUNC(js_pipeline_PipelineSceneData_PipelineSceneData); -extern se::Object* __jsb_cc_pipeline_RenderPipeline_proto; -extern se::Class* __jsb_cc_pipeline_RenderPipeline_class; +extern se::Object *__jsb_cc_pipeline_RenderPipelineInfo_proto; // NOLINT +extern se::Class * __jsb_cc_pipeline_RenderPipelineInfo_class; // NOLINT -bool js_register_cc_pipeline_RenderPipeline(se::Object* obj); -bool register_all_pipeline(se::Object* obj); +bool js_register_cc_pipeline_RenderPipelineInfo(se::Object *obj); // NOLINT + +template <> +bool sevalue_to_native(const se::Value &, cc::pipeline::RenderPipelineInfo *, se::Object *ctx); //NOLINT + +extern se::Object *__jsb_cc_pipeline_RenderPipeline_proto; // NOLINT +extern se::Class * __jsb_cc_pipeline_RenderPipeline_class; // NOLINT + +bool js_register_cc_pipeline_RenderPipeline(se::Object *obj); // NOLINT -JSB_REGISTER_OBJECT_TYPE(cc::pipeline::RenderPipeline); SE_DECLARE_FUNC(js_pipeline_RenderPipeline_activate); SE_DECLARE_FUNC(js_pipeline_RenderPipeline_createQuadInputAssembler); -SE_DECLARE_FUNC(js_pipeline_RenderPipeline_destroy); SE_DECLARE_FUNC(js_pipeline_RenderPipeline_ensureEnoughSize); SE_DECLARE_FUNC(js_pipeline_RenderPipeline_genQuadVertexData); SE_DECLARE_FUNC(js_pipeline_RenderPipeline_getClearcolor); SE_DECLARE_FUNC(js_pipeline_RenderPipeline_getDevice); -SE_DECLARE_FUNC(js_pipeline_RenderPipeline_getFrameGraph); SE_DECLARE_FUNC(js_pipeline_RenderPipeline_getGeometryRenderer); SE_DECLARE_FUNC(js_pipeline_RenderPipeline_getHeight); SE_DECLARE_FUNC(js_pipeline_RenderPipeline_getIAByRenderArea); -SE_DECLARE_FUNC(js_pipeline_RenderPipeline_getOcclusionQueryEnabled); -SE_DECLARE_FUNC(js_pipeline_RenderPipeline_getProfiler); SE_DECLARE_FUNC(js_pipeline_RenderPipeline_getQueryPools); SE_DECLARE_FUNC(js_pipeline_RenderPipeline_getRenderstageByName); SE_DECLARE_FUNC(js_pipeline_RenderPipeline_getScissor); SE_DECLARE_FUNC(js_pipeline_RenderPipeline_getViewport); SE_DECLARE_FUNC(js_pipeline_RenderPipeline_getWidth); SE_DECLARE_FUNC(js_pipeline_RenderPipeline_initialize); +SE_DECLARE_FUNC(js_pipeline_RenderPipeline_isBloomEnabled); +SE_DECLARE_FUNC(js_pipeline_RenderPipeline_isClusterEnabled); SE_DECLARE_FUNC(js_pipeline_RenderPipeline_isEnvmapEnabled); SE_DECLARE_FUNC(js_pipeline_RenderPipeline_isOccluded); +SE_DECLARE_FUNC(js_pipeline_RenderPipeline_isOcclusionQueryEnabled); SE_DECLARE_FUNC(js_pipeline_RenderPipeline_render); SE_DECLARE_FUNC(js_pipeline_RenderPipeline_setGeometryRenderer); SE_DECLARE_FUNC(js_pipeline_RenderPipeline_setOcclusionQueryEnabled); -SE_DECLARE_FUNC(js_pipeline_RenderPipeline_setPipelineSharedSceneData); -SE_DECLARE_FUNC(js_pipeline_RenderPipeline_setProfiler); SE_DECLARE_FUNC(js_pipeline_RenderPipeline_setValue); SE_DECLARE_FUNC(js_pipeline_RenderPipeline_updateQuadVertexData); SE_DECLARE_FUNC(js_pipeline_RenderPipeline_getInstance); SE_DECLARE_FUNC(js_pipeline_RenderPipeline_getRenderArea); -extern se::Object* __jsb_cc_pipeline_ForwardPipeline_proto; -extern se::Class* __jsb_cc_pipeline_ForwardPipeline_class; +extern se::Object *__jsb_cc_pipeline_ForwardPipeline_proto; // NOLINT +extern se::Class * __jsb_cc_pipeline_ForwardPipeline_class; // NOLINT -bool js_register_cc_pipeline_ForwardPipeline(se::Object* obj); -bool register_all_pipeline(se::Object* obj); +bool js_register_cc_pipeline_ForwardPipeline(se::Object *obj); // NOLINT -JSB_REGISTER_OBJECT_TYPE(cc::pipeline::ForwardPipeline); SE_DECLARE_FUNC(js_pipeline_ForwardPipeline_ForwardPipeline); -extern se::Object* __jsb_cc_pipeline_RenderFlowInfo_proto; -extern se::Class* __jsb_cc_pipeline_RenderFlowInfo_class; +extern se::Object *__jsb_cc_pipeline_RenderFlowInfo_proto; // NOLINT +extern se::Class * __jsb_cc_pipeline_RenderFlowInfo_class; // NOLINT -bool js_register_cc_pipeline_RenderFlowInfo(se::Object* obj); -bool register_all_pipeline(se::Object* obj); +bool js_register_cc_pipeline_RenderFlowInfo(se::Object *obj); // NOLINT -template<> -bool sevalue_to_native(const se::Value &, cc::pipeline::RenderFlowInfo *, se::Object *ctx); -JSB_REGISTER_OBJECT_TYPE(cc::pipeline::RenderFlowInfo); +template <> +bool sevalue_to_native(const se::Value &, cc::pipeline::RenderFlowInfo *, se::Object *ctx); //NOLINT -extern se::Object* __jsb_cc_pipeline_RenderFlow_proto; -extern se::Class* __jsb_cc_pipeline_RenderFlow_class; +extern se::Object *__jsb_cc_pipeline_RenderFlow_proto; // NOLINT +extern se::Class * __jsb_cc_pipeline_RenderFlow_class; // NOLINT -bool js_register_cc_pipeline_RenderFlow(se::Object* obj); -bool register_all_pipeline(se::Object* obj); +bool js_register_cc_pipeline_RenderFlow(se::Object *obj); // NOLINT -JSB_REGISTER_OBJECT_TYPE(cc::pipeline::RenderFlow); SE_DECLARE_FUNC(js_pipeline_RenderFlow_activate); SE_DECLARE_FUNC(js_pipeline_RenderFlow_getRenderstageByName); SE_DECLARE_FUNC(js_pipeline_RenderFlow_getTag); SE_DECLARE_FUNC(js_pipeline_RenderFlow_initialize); -extern se::Object* __jsb_cc_pipeline_ForwardFlow_proto; -extern se::Class* __jsb_cc_pipeline_ForwardFlow_class; +extern se::Object *__jsb_cc_pipeline_ForwardFlow_proto; // NOLINT +extern se::Class * __jsb_cc_pipeline_ForwardFlow_class; // NOLINT -bool js_register_cc_pipeline_ForwardFlow(se::Object* obj); -bool register_all_pipeline(se::Object* obj); +bool js_register_cc_pipeline_ForwardFlow(se::Object *obj); // NOLINT -JSB_REGISTER_OBJECT_TYPE(cc::pipeline::ForwardFlow); SE_DECLARE_FUNC(js_pipeline_ForwardFlow_getInitializeInfo); SE_DECLARE_FUNC(js_pipeline_ForwardFlow_ForwardFlow); -extern se::Object* __jsb_cc_pipeline_RenderStageInfo_proto; -extern se::Class* __jsb_cc_pipeline_RenderStageInfo_class; +extern se::Object *__jsb_cc_pipeline_RenderStageInfo_proto; // NOLINT +extern se::Class * __jsb_cc_pipeline_RenderStageInfo_class; // NOLINT -bool js_register_cc_pipeline_RenderStageInfo(se::Object* obj); -bool register_all_pipeline(se::Object* obj); +bool js_register_cc_pipeline_RenderStageInfo(se::Object *obj); // NOLINT -template<> -bool sevalue_to_native(const se::Value &, cc::pipeline::RenderStageInfo *, se::Object *ctx); -JSB_REGISTER_OBJECT_TYPE(cc::pipeline::RenderStageInfo); +template <> +bool sevalue_to_native(const se::Value &, cc::pipeline::RenderStageInfo *, se::Object *ctx); //NOLINT -extern se::Object* __jsb_cc_pipeline_RenderStage_proto; -extern se::Class* __jsb_cc_pipeline_RenderStage_class; +extern se::Object *__jsb_cc_pipeline_RenderStage_proto; // NOLINT +extern se::Class * __jsb_cc_pipeline_RenderStage_class; // NOLINT -bool js_register_cc_pipeline_RenderStage(se::Object* obj); -bool register_all_pipeline(se::Object* obj); +bool js_register_cc_pipeline_RenderStage(se::Object *obj); // NOLINT -JSB_REGISTER_OBJECT_TYPE(cc::pipeline::RenderStage); SE_DECLARE_FUNC(js_pipeline_RenderStage_activate); SE_DECLARE_FUNC(js_pipeline_RenderStage_getFlow); SE_DECLARE_FUNC(js_pipeline_RenderStage_getTag); SE_DECLARE_FUNC(js_pipeline_RenderStage_initialize); -extern se::Object* __jsb_cc_pipeline_ForwardStage_proto; -extern se::Class* __jsb_cc_pipeline_ForwardStage_class; +extern se::Object *__jsb_cc_pipeline_ForwardStage_proto; // NOLINT +extern se::Class * __jsb_cc_pipeline_ForwardStage_class; // NOLINT -bool js_register_cc_pipeline_ForwardStage(se::Object* obj); -bool register_all_pipeline(se::Object* obj); +bool js_register_cc_pipeline_ForwardStage(se::Object *obj); // NOLINT -JSB_REGISTER_OBJECT_TYPE(cc::pipeline::ForwardStage); SE_DECLARE_FUNC(js_pipeline_ForwardStage_getInitializeInfo); SE_DECLARE_FUNC(js_pipeline_ForwardStage_ForwardStage); -extern se::Object* __jsb_cc_pipeline_ShadowFlow_proto; -extern se::Class* __jsb_cc_pipeline_ShadowFlow_class; +extern se::Object *__jsb_cc_pipeline_ShadowFlow_proto; // NOLINT +extern se::Class * __jsb_cc_pipeline_ShadowFlow_class; // NOLINT -bool js_register_cc_pipeline_ShadowFlow(se::Object* obj); -bool register_all_pipeline(se::Object* obj); +bool js_register_cc_pipeline_ShadowFlow(se::Object *obj); // NOLINT -JSB_REGISTER_OBJECT_TYPE(cc::pipeline::ShadowFlow); SE_DECLARE_FUNC(js_pipeline_ShadowFlow_getInitializeInfo); SE_DECLARE_FUNC(js_pipeline_ShadowFlow_ShadowFlow); -extern se::Object* __jsb_cc_pipeline_ShadowStage_proto; -extern se::Class* __jsb_cc_pipeline_ShadowStage_class; +extern se::Object *__jsb_cc_pipeline_ShadowStage_proto; // NOLINT +extern se::Class * __jsb_cc_pipeline_ShadowStage_class; // NOLINT -bool js_register_cc_pipeline_ShadowStage(se::Object* obj); -bool register_all_pipeline(se::Object* obj); +bool js_register_cc_pipeline_ShadowStage(se::Object *obj); // NOLINT -JSB_REGISTER_OBJECT_TYPE(cc::pipeline::ShadowStage); SE_DECLARE_FUNC(js_pipeline_ShadowStage_setFramebuffer); SE_DECLARE_FUNC(js_pipeline_ShadowStage_setUsage); SE_DECLARE_FUNC(js_pipeline_ShadowStage_getInitializeInfo); SE_DECLARE_FUNC(js_pipeline_ShadowStage_ShadowStage); -extern se::Object* __jsb_cc_pipeline_InstancedBuffer_proto; -extern se::Class* __jsb_cc_pipeline_InstancedBuffer_class; +extern se::Object *__jsb_cc_pipeline_InstancedBuffer_proto; // NOLINT +extern se::Class * __jsb_cc_pipeline_InstancedBuffer_class; // NOLINT -bool js_register_cc_pipeline_InstancedBuffer(se::Object* obj); -bool register_all_pipeline(se::Object* obj); +bool js_register_cc_pipeline_InstancedBuffer(se::Object *obj); // NOLINT -JSB_REGISTER_OBJECT_TYPE(cc::pipeline::InstancedBuffer); SE_DECLARE_FUNC(js_pipeline_InstancedBuffer_destroy); SE_DECLARE_FUNC(js_pipeline_InstancedBuffer_setDynamicOffset); -SE_DECLARE_FUNC(js_pipeline_InstancedBuffer_get); SE_DECLARE_FUNC(js_pipeline_InstancedBuffer_destroyInstancedBuffer); +SE_DECLARE_FUNC(js_pipeline_InstancedBuffer_get); SE_DECLARE_FUNC(js_pipeline_InstancedBuffer_InstancedBuffer); -extern se::Object* __jsb_cc_pipeline_DeferredPipeline_proto; -extern se::Class* __jsb_cc_pipeline_DeferredPipeline_class; +extern se::Object *__jsb_cc_pipeline_DeferredPipeline_proto; // NOLINT +extern se::Class * __jsb_cc_pipeline_DeferredPipeline_class; // NOLINT -bool js_register_cc_pipeline_DeferredPipeline(se::Object* obj); -bool register_all_pipeline(se::Object* obj); +bool js_register_cc_pipeline_DeferredPipeline(se::Object *obj); // NOLINT -JSB_REGISTER_OBJECT_TYPE(cc::pipeline::DeferredPipeline); SE_DECLARE_FUNC(js_pipeline_DeferredPipeline_DeferredPipeline); -extern se::Object* __jsb_cc_pipeline_MainFlow_proto; -extern se::Class* __jsb_cc_pipeline_MainFlow_class; +extern se::Object *__jsb_cc_pipeline_MainFlow_proto; // NOLINT +extern se::Class * __jsb_cc_pipeline_MainFlow_class; // NOLINT -bool js_register_cc_pipeline_MainFlow(se::Object* obj); -bool register_all_pipeline(se::Object* obj); +bool js_register_cc_pipeline_MainFlow(se::Object *obj); // NOLINT -JSB_REGISTER_OBJECT_TYPE(cc::pipeline::MainFlow); SE_DECLARE_FUNC(js_pipeline_MainFlow_getInitializeInfo); SE_DECLARE_FUNC(js_pipeline_MainFlow_MainFlow); -extern se::Object* __jsb_cc_pipeline_GbufferStage_proto; -extern se::Class* __jsb_cc_pipeline_GbufferStage_class; +extern se::Object *__jsb_cc_pipeline_GbufferStage_proto; // NOLINT +extern se::Class * __jsb_cc_pipeline_GbufferStage_class; // NOLINT -bool js_register_cc_pipeline_GbufferStage(se::Object* obj); -bool register_all_pipeline(se::Object* obj); +bool js_register_cc_pipeline_GbufferStage(se::Object *obj); // NOLINT -JSB_REGISTER_OBJECT_TYPE(cc::pipeline::GbufferStage); SE_DECLARE_FUNC(js_pipeline_GbufferStage_getInitializeInfo); SE_DECLARE_FUNC(js_pipeline_GbufferStage_GbufferStage); -extern se::Object* __jsb_cc_pipeline_LightingStage_proto; -extern se::Class* __jsb_cc_pipeline_LightingStage_class; +extern se::Object *__jsb_cc_pipeline_LightingStage_proto; // NOLINT +extern se::Class * __jsb_cc_pipeline_LightingStage_class; // NOLINT -bool js_register_cc_pipeline_LightingStage(se::Object* obj); -bool register_all_pipeline(se::Object* obj); +bool js_register_cc_pipeline_LightingStage(se::Object *obj); // NOLINT -JSB_REGISTER_OBJECT_TYPE(cc::pipeline::LightingStage); SE_DECLARE_FUNC(js_pipeline_LightingStage_getInitializeInfo); SE_DECLARE_FUNC(js_pipeline_LightingStage_LightingStage); -extern se::Object* __jsb_cc_pipeline_BloomStage_proto; -extern se::Class* __jsb_cc_pipeline_BloomStage_class; +extern se::Object *__jsb_cc_pipeline_BloomStage_proto; // NOLINT +extern se::Class * __jsb_cc_pipeline_BloomStage_class; // NOLINT -bool js_register_cc_pipeline_BloomStage(se::Object* obj); -bool register_all_pipeline(se::Object* obj); +bool js_register_cc_pipeline_BloomStage(se::Object *obj); // NOLINT -JSB_REGISTER_OBJECT_TYPE(cc::pipeline::BloomStage); SE_DECLARE_FUNC(js_pipeline_BloomStage_getCombineUBO); -SE_DECLARE_FUNC(js_pipeline_BloomStage_getDownsampelUBO); +SE_DECLARE_FUNC(js_pipeline_BloomStage_getDownsampleUBO); SE_DECLARE_FUNC(js_pipeline_BloomStage_getPrefilterUBO); SE_DECLARE_FUNC(js_pipeline_BloomStage_getSampler); SE_DECLARE_FUNC(js_pipeline_BloomStage_getUpsampleUBO); SE_DECLARE_FUNC(js_pipeline_BloomStage_getInitializeInfo); SE_DECLARE_FUNC(js_pipeline_BloomStage_BloomStage); -extern se::Object* __jsb_cc_pipeline_PostProcessStage_proto; -extern se::Class* __jsb_cc_pipeline_PostProcessStage_class; +extern se::Object *__jsb_cc_pipeline_PostProcessStage_proto; // NOLINT +extern se::Class * __jsb_cc_pipeline_PostProcessStage_class; // NOLINT -bool js_register_cc_pipeline_PostProcessStage(se::Object* obj); -bool register_all_pipeline(se::Object* obj); +bool js_register_cc_pipeline_PostProcessStage(se::Object *obj); // NOLINT -JSB_REGISTER_OBJECT_TYPE(cc::pipeline::PostProcessStage); SE_DECLARE_FUNC(js_pipeline_PostProcessStage_getInitializeInfo); SE_DECLARE_FUNC(js_pipeline_PostProcessStage_PostProcessStage); -extern se::Object* __jsb_cc_pipeline_GeometryRenderer_proto; -extern se::Class* __jsb_cc_pipeline_GeometryRenderer_class; +extern se::Object *__jsb_cc_pipeline_BatchedItem_proto; // NOLINT +extern se::Class * __jsb_cc_pipeline_BatchedItem_class; // NOLINT -bool js_register_cc_pipeline_GeometryRenderer(se::Object* obj); -bool register_all_pipeline(se::Object* obj); +bool js_register_cc_pipeline_BatchedItem(se::Object *obj); // NOLINT + +template <> +bool sevalue_to_native(const se::Value &, cc::pipeline::BatchedItem *, se::Object *ctx); //NOLINT + +extern se::Object *__jsb_cc_pipeline_BatchedBuffer_proto; // NOLINT +extern se::Class * __jsb_cc_pipeline_BatchedBuffer_class; // NOLINT + +bool js_register_cc_pipeline_BatchedBuffer(se::Object *obj); // NOLINT + +SE_DECLARE_FUNC(js_pipeline_BatchedBuffer_clear); +SE_DECLARE_FUNC(js_pipeline_BatchedBuffer_destroy); +SE_DECLARE_FUNC(js_pipeline_BatchedBuffer_getBatches); +SE_DECLARE_FUNC(js_pipeline_BatchedBuffer_getDynamicOffset); +SE_DECLARE_FUNC(js_pipeline_BatchedBuffer_getPass); +SE_DECLARE_FUNC(js_pipeline_BatchedBuffer_merge); +SE_DECLARE_FUNC(js_pipeline_BatchedBuffer_setDynamicOffset); +SE_DECLARE_FUNC(js_pipeline_BatchedBuffer_destroyBatchedBuffer); +SE_DECLARE_FUNC(js_pipeline_BatchedBuffer_get); +SE_DECLARE_FUNC(js_pipeline_BatchedBuffer_BatchedBuffer); + +extern se::Object *__jsb_cc_pipeline_GeometryRenderer_proto; // NOLINT +extern se::Class * __jsb_cc_pipeline_GeometryRenderer_class; // NOLINT + +bool js_register_cc_pipeline_GeometryRenderer(se::Object *obj); // NOLINT -JSB_REGISTER_OBJECT_TYPE(cc::pipeline::GeometryRenderer); SE_DECLARE_FUNC(js_pipeline_GeometryRenderer_GeometryRenderer); - + // clang-format on \ No newline at end of file diff --git a/native/cocos/bindings/auto/jsb_scene_auto.cpp b/native/cocos/bindings/auto/jsb_scene_auto.cpp index 3eecebf436..61b3aba35c 100644 --- a/native/cocos/bindings/auto/jsb_scene_auto.cpp +++ b/native/cocos/bindings/auto/jsb_scene_auto.cpp @@ -1,10 +1,16 @@ + +// clang-format off #include "cocos/bindings/auto/jsb_scene_auto.h" #include "cocos/bindings/manual/jsb_conversions.h" #include "cocos/bindings/manual/jsb_global.h" -#include "scene/Node.h" -#include "scene/BaseNode.h" -#include "scene/Scene.h" +#include "core/data/Object.h" +#include "core/scene-graph/Node.h" +#include "core/scene-graph/Scene.h" +#include "core/scene-graph/SceneGlobals.h" #include "scene/Light.h" +#include "scene/Fog.h" +#include "scene/Shadow.h" +#include "scene/Skybox.h" #include "scene/DirectionalLight.h" #include "scene/SpotLight.h" #include "scene/SphereLight.h" @@ -13,12 +19,20 @@ #include "scene/Pass.h" #include "scene/RenderScene.h" #include "scene/DrawBatch2D.h" -#include "scene/Camera.h" #include "scene/RenderWindow.h" #include "scene/Camera.h" #include "scene/Define.h" -#include "scene/AABB.h" -#include "scene/Sphere.h" +#include "scene/Ambient.h" +#include "renderer/core/PassInstance.h" +#include "renderer/core/MaterialInstance.h" +#include "3d/models/MorphModel.h" +#include "3d/models/SkinningModel.h" +#include "3d/models/BakedSkinningModel.h" +#include "core/Root.h" +#include "renderer/core/ProgramLib.h" +#include "scene/Octree.h" +#include "cocos/bindings/auto/jsb_pipeline_auto.h" +#include "cocos/bindings/auto/jsb_cocos_auto.h" #ifndef JSB_ALLOC #define JSB_ALLOC(kls, ...) new (std::nothrow) kls(__VA_ARGS__) @@ -27,220 +41,2523 @@ #ifndef JSB_FREE #define JSB_FREE(ptr) delete ptr #endif -se::Object* __jsb_cc_scene_BaseNode_proto = nullptr; -se::Class* __jsb_cc_scene_BaseNode_class = nullptr; - -static bool js_scene_BaseNode_getChilds(se::State& s) // NOLINT(readability-identifier-naming) +se::Object* __jsb_cc_BaseNode_proto = nullptr; // NOLINT +se::Class* __jsb_cc_BaseNode_class = nullptr; // NOLINT +static bool js_cc_BaseNode_finalize(se::State& s) // NOLINT(readability-identifier-naming) { - auto* cobj = SE_THIS_OBJECT(s); - SE_PRECONDITION2(cobj, false, "js_scene_BaseNode_getChilds : Invalid Native Object"); - const auto& args = s.args(); - size_t argc = args.size(); - CC_UNUSED bool ok = true; - if (argc == 0) { - const std::vector& result = cobj->getChilds(); - ok &= nativevalue_to_se(result, s.rval(), nullptr /*ctx*/); - SE_PRECONDITION2(ok, false, "js_scene_BaseNode_getChilds : Error processing arguments"); - SE_HOLD_RETURN_VALUE(result, s.thisObject(), s.rval()); - return true; - } - SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 0); - return false; + return true; } -SE_BIND_FUNC(js_scene_BaseNode_getChilds) +SE_BIND_FINALIZE_FUNC(js_cc_BaseNode_finalize) -static bool js_scene_BaseNode_setParent(se::State& s) // NOLINT(readability-identifier-naming) +bool js_register_scene_BaseNode(se::Object* obj) // NOLINT(readability-identifier-naming) { - auto* cobj = SE_THIS_OBJECT(s); - SE_PRECONDITION2(cobj, false, "js_scene_BaseNode_setParent : Invalid Native Object"); + auto* cls = se::Class::create("BaseNode", obj, __jsb_cc_CCObject_proto, nullptr); + + cls->defineFinalizeFunction(_SE(js_cc_BaseNode_finalize)); + cls->install(); + JSBClassType::registerClass(cls); + + __jsb_cc_BaseNode_proto = cls->getProto(); + __jsb_cc_BaseNode_class = cls; + + + se::ScriptEngine::getInstance()->clearException(); + return true; +} +se::Object* __jsb_cc_Node_proto = nullptr; // NOLINT +se::Class* __jsb_cc_Node_class = nullptr; // NOLINT + +static bool js_scene_Node__setChildren(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_scene_Node__setChildren : Invalid Native Object"); const auto& args = s.args(); size_t argc = args.size(); CC_UNUSED bool ok = true; if (argc == 1) { - HolderType arg0 = {}; + HolderType>, true> arg0 = {}; ok &= sevalue_to_native(args[0], &arg0, s.thisObject()); - SE_PRECONDITION2(ok, false, "js_scene_BaseNode_setParent : Error processing arguments"); - cobj->setParent(arg0.value()); + SE_PRECONDITION2(ok, false, "js_scene_Node__setChildren : Error processing arguments"); + cobj->_setChildren(std::move(arg0.value())); return true; } SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 1); return false; } -SE_BIND_FUNC(js_scene_BaseNode_setParent) +SE_BIND_FUNC(js_scene_Node__setChildren) -SE_DECLARE_FINALIZE_FUNC(js_cc_scene_BaseNode_finalize) - -static bool js_scene_BaseNode_constructor(se::State& s) // NOLINT(readability-identifier-naming) constructor.c +static bool js_scene_Node_addChild(se::State& s) // NOLINT(readability-identifier-naming) { - cc::scene::BaseNode* cobj = JSB_ALLOC(cc::scene::BaseNode); - s.thisObject()->setPrivateData(cobj); - se::NonRefNativePtrCreatedByCtorMap::emplace(cobj); - return true; -} -SE_BIND_CTOR(js_scene_BaseNode_constructor, __jsb_cc_scene_BaseNode_class, js_cc_scene_BaseNode_finalize) - - - -static bool js_cc_scene_BaseNode_finalize(se::State& s) // NOLINT(readability-identifier-naming) -{ - auto iter = se::NonRefNativePtrCreatedByCtorMap::find(SE_THIS_OBJECT(s)); - if (iter != se::NonRefNativePtrCreatedByCtorMap::end()) - { - se::NonRefNativePtrCreatedByCtorMap::erase(iter); - auto* cobj = SE_THIS_OBJECT(s); - JSB_FREE(cobj); - } - return true; -} -SE_BIND_FINALIZE_FUNC(js_cc_scene_BaseNode_finalize) - -bool js_register_scene_BaseNode(se::Object* obj) // NOLINT(readability-identifier-naming) -{ - auto* cls = se::Class::create("BaseNode", obj, nullptr, _SE(js_scene_BaseNode_constructor)); - - cls->defineFunction("getChilds", _SE(js_scene_BaseNode_getChilds)); - cls->defineFunction("setParent", _SE(js_scene_BaseNode_setParent)); - cls->defineFinalizeFunction(_SE(js_cc_scene_BaseNode_finalize)); - cls->install(); - JSBClassType::registerClass(cls); - - __jsb_cc_scene_BaseNode_proto = cls->getProto(); - __jsb_cc_scene_BaseNode_class = cls; - - se::ScriptEngine::getInstance()->clearException(); - return true; -} -se::Object* __jsb_cc_scene_Scene_proto = nullptr; -se::Class* __jsb_cc_scene_Scene_class = nullptr; - -SE_DECLARE_FINALIZE_FUNC(js_cc_scene_Scene_finalize) - -static bool js_scene_Scene_constructor(se::State& s) // NOLINT(readability-identifier-naming) constructor.c -{ - cc::scene::Scene* cobj = JSB_ALLOC(cc::scene::Scene); - s.thisObject()->setPrivateData(cobj); - se::NonRefNativePtrCreatedByCtorMap::emplace(cobj); - return true; -} -SE_BIND_CTOR(js_scene_Scene_constructor, __jsb_cc_scene_Scene_class, js_cc_scene_Scene_finalize) - - - -static bool js_cc_scene_Scene_finalize(se::State& s) // NOLINT(readability-identifier-naming) -{ - auto iter = se::NonRefNativePtrCreatedByCtorMap::find(SE_THIS_OBJECT(s)); - if (iter != se::NonRefNativePtrCreatedByCtorMap::end()) - { - se::NonRefNativePtrCreatedByCtorMap::erase(iter); - auto* cobj = SE_THIS_OBJECT(s); - JSB_FREE(cobj); - } - return true; -} -SE_BIND_FINALIZE_FUNC(js_cc_scene_Scene_finalize) - -bool js_register_scene_Scene(se::Object* obj) // NOLINT(readability-identifier-naming) -{ - auto* cls = se::Class::create("Scene", obj, __jsb_cc_scene_BaseNode_proto, _SE(js_scene_Scene_constructor)); - - cls->defineFinalizeFunction(_SE(js_cc_scene_Scene_finalize)); - cls->install(); - JSBClassType::registerClass(cls); - - __jsb_cc_scene_Scene_proto = cls->getProto(); - __jsb_cc_scene_Scene_class = cls; - - se::ScriptEngine::getInstance()->clearException(); - return true; -} -se::Object* __jsb_cc_scene_Node_proto = nullptr; -se::Class* __jsb_cc_scene_Node_class = nullptr; - -static bool js_scene_Node_initWithData(se::State& s) // NOLINT(readability-identifier-naming) -{ - auto* cobj = SE_THIS_OBJECT(s); - SE_PRECONDITION2(cobj, false, "js_scene_Node_initWithData : Invalid Native Object"); + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_scene_Node_addChild : Invalid Native Object"); const auto& args = s.args(); size_t argc = args.size(); CC_UNUSED bool ok = true; - if (argc == 3) { - HolderType arg0 = {}; - HolderType arg1 = {}; - HolderType arg2 = {}; + if (argc == 1) { + HolderType arg0 = {}; ok &= sevalue_to_native(args[0], &arg0, s.thisObject()); - ok &= sevalue_to_native(args[1], &arg1, s.thisObject()); - ok &= sevalue_to_native(args[2], &arg2, s.thisObject()); - SE_PRECONDITION2(ok, false, "js_scene_Node_initWithData : Error processing arguments"); - cobj->initWithData(arg0.value(), arg1.value(), arg2.value()); + SE_PRECONDITION2(ok, false, "js_scene_Node_addChild : Error processing arguments"); + cobj->addChild(arg0.value()); return true; } - SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 3); + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 1); return false; } -SE_BIND_FUNC(js_scene_Node_initWithData) +SE_BIND_FUNC(js_scene_Node_addChild) -SE_DECLARE_FINALIZE_FUNC(js_cc_scene_Node_finalize) - -static bool js_scene_Node_constructor(se::State& s) // NOLINT(readability-identifier-naming) constructor.c +static bool js_scene_Node_destroyAllChildren(se::State& s) // NOLINT(readability-identifier-naming) { - cc::scene::Node* cobj = JSB_ALLOC(cc::scene::Node); - s.thisObject()->setPrivateData(cobj); - se::NonRefNativePtrCreatedByCtorMap::emplace(cobj); - return true; -} -SE_BIND_CTOR(js_scene_Node_constructor, __jsb_cc_scene_Node_class, js_cc_scene_Node_finalize) - - - -static bool js_cc_scene_Node_finalize(se::State& s) // NOLINT(readability-identifier-naming) -{ - auto iter = se::NonRefNativePtrCreatedByCtorMap::find(SE_THIS_OBJECT(s)); - if (iter != se::NonRefNativePtrCreatedByCtorMap::end()) - { - se::NonRefNativePtrCreatedByCtorMap::erase(iter); - auto* cobj = SE_THIS_OBJECT(s); - JSB_FREE(cobj); + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_scene_Node_destroyAllChildren : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + if (argc == 0) { + cobj->destroyAllChildren(); + return true; } - return true; + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 0); + return false; } -SE_BIND_FINALIZE_FUNC(js_cc_scene_Node_finalize) +SE_BIND_FUNC(js_scene_Node_destroyAllChildren) -bool js_register_scene_Node(se::Object* obj) // NOLINT(readability-identifier-naming) +static bool js_scene_Node_getAngle(se::State& s) // NOLINT(readability-identifier-naming) { - auto* cls = se::Class::create("Node", obj, __jsb_cc_scene_BaseNode_proto, _SE(js_scene_Node_constructor)); - - cls->defineFunction("initWithData", _SE(js_scene_Node_initWithData)); - cls->defineFinalizeFunction(_SE(js_cc_scene_Node_finalize)); - cls->install(); - JSBClassType::registerClass(cls); - - __jsb_cc_scene_Node_proto = cls->getProto(); - __jsb_cc_scene_Node_class = cls; - - se::ScriptEngine::getInstance()->clearException(); - return true; -} -se::Object* __jsb_cc_scene_Light_proto = nullptr; -se::Class* __jsb_cc_scene_Light_class = nullptr; - -static bool js_scene_Light_getBaked(se::State& s) // NOLINT(readability-identifier-naming) -{ - auto* cobj = SE_THIS_OBJECT(s); - SE_PRECONDITION2(cobj, false, "js_scene_Light_getBaked : Invalid Native Object"); + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_scene_Node_getAngle : Invalid Native Object"); const auto& args = s.args(); size_t argc = args.size(); CC_UNUSED bool ok = true; if (argc == 0) { - bool result = cobj->getBaked(); + float result = cobj->getAngle(); ok &= nativevalue_to_se(result, s.rval(), nullptr /*ctx*/); - SE_PRECONDITION2(ok, false, "js_scene_Light_getBaked : Error processing arguments"); + SE_PRECONDITION2(ok, false, "js_scene_Node_getAngle : Error processing arguments"); SE_HOLD_RETURN_VALUE(result, s.thisObject(), s.rval()); return true; } SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 0); return false; } -SE_BIND_FUNC(js_scene_Light_getBaked) +SE_BIND_FUNC_AS_PROP_GET(js_scene_Node_getAngle) + +static bool js_scene_Node_getChangedFlags(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_scene_Node_getChangedFlags : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 0) { + unsigned int result = cobj->getChangedFlags(); + ok &= nativevalue_to_se(result, s.rval(), nullptr /*ctx*/); + SE_PRECONDITION2(ok, false, "js_scene_Node_getChangedFlags : Error processing arguments"); + SE_HOLD_RETURN_VALUE(result, s.thisObject(), s.rval()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 0); + return false; +} +SE_BIND_FUNC_AS_PROP_GET(js_scene_Node_getChangedFlags) + +static bool js_scene_Node_getChildByName(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_scene_Node_getChildByName : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 1) { + HolderType arg0 = {}; + ok &= sevalue_to_native(args[0], &arg0, s.thisObject()); + SE_PRECONDITION2(ok, false, "js_scene_Node_getChildByName : Error processing arguments"); + cc::Node* result = cobj->getChildByName(arg0.value()); + ok &= nativevalue_to_se(result, s.rval(), nullptr /*ctx*/); + SE_PRECONDITION2(ok, false, "js_scene_Node_getChildByName : Error processing arguments"); + SE_HOLD_RETURN_VALUE(result, s.thisObject(), s.rval()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 1); + return false; +} +SE_BIND_FUNC(js_scene_Node_getChildByName) + +static bool js_scene_Node_getChildByPath(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_scene_Node_getChildByPath : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 1) { + HolderType arg0 = {}; + ok &= sevalue_to_native(args[0], &arg0, s.thisObject()); + SE_PRECONDITION2(ok, false, "js_scene_Node_getChildByPath : Error processing arguments"); + cc::Node* result = cobj->getChildByPath(arg0.value()); + ok &= nativevalue_to_se(result, s.rval(), nullptr /*ctx*/); + SE_PRECONDITION2(ok, false, "js_scene_Node_getChildByPath : Error processing arguments"); + SE_HOLD_RETURN_VALUE(result, s.thisObject(), s.rval()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 1); + return false; +} +SE_BIND_FUNC(js_scene_Node_getChildByPath) + +static bool js_scene_Node_getChildByUuid(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_scene_Node_getChildByUuid : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 1) { + HolderType arg0 = {}; + ok &= sevalue_to_native(args[0], &arg0, s.thisObject()); + SE_PRECONDITION2(ok, false, "js_scene_Node_getChildByUuid : Error processing arguments"); + cc::Node* result = cobj->getChildByUuid(arg0.value()); + ok &= nativevalue_to_se(result, s.rval(), nullptr /*ctx*/); + SE_PRECONDITION2(ok, false, "js_scene_Node_getChildByUuid : Error processing arguments"); + SE_HOLD_RETURN_VALUE(result, s.thisObject(), s.rval()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 1); + return false; +} +SE_BIND_FUNC(js_scene_Node_getChildByUuid) + +static bool js_scene_Node_getDirtyFlag(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_scene_Node_getDirtyFlag : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 0) { + unsigned int result = cobj->getDirtyFlag(); + ok &= nativevalue_to_se(result, s.rval(), nullptr /*ctx*/); + SE_PRECONDITION2(ok, false, "js_scene_Node_getDirtyFlag : Error processing arguments"); + SE_HOLD_RETURN_VALUE(result, s.thisObject(), s.rval()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 0); + return false; +} +SE_BIND_FUNC_AS_PROP_GET(js_scene_Node_getDirtyFlag) + +static bool js_scene_Node_getEventMask(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_scene_Node_getEventMask : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 0) { + unsigned int result = cobj->getEventMask(); + ok &= nativevalue_to_se(result, s.rval(), nullptr /*ctx*/); + SE_PRECONDITION2(ok, false, "js_scene_Node_getEventMask : Error processing arguments"); + SE_HOLD_RETURN_VALUE(result, s.thisObject(), s.rval()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 0); + return false; +} +SE_BIND_FUNC(js_scene_Node_getEventMask) + +static bool js_scene_Node_getLayer(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_scene_Node_getLayer : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 0) { + unsigned int result = cobj->getLayer(); + ok &= nativevalue_to_se(result, s.rval(), nullptr /*ctx*/); + SE_PRECONDITION2(ok, false, "js_scene_Node_getLayer : Error processing arguments"); + SE_HOLD_RETURN_VALUE(result, s.thisObject(), s.rval()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 0); + return false; +} +SE_BIND_FUNC(js_scene_Node_getLayer) + +static bool js_scene_Node_getParent(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_scene_Node_getParent : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 0) { + cc::Node* result = cobj->getParent(); + ok &= nativevalue_to_se(result, s.rval(), nullptr /*ctx*/); + SE_PRECONDITION2(ok, false, "js_scene_Node_getParent : Error processing arguments"); + SE_HOLD_RETURN_VALUE(result, s.thisObject(), s.rval()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 0); + return false; +} +SE_BIND_FUNC(js_scene_Node_getParent) + +static bool js_scene_Node_getScene(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_scene_Node_getScene : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 0) { + cc::Scene* result = cobj->getScene(); + ok &= nativevalue_to_se(result, s.rval(), nullptr /*ctx*/); + SE_PRECONDITION2(ok, false, "js_scene_Node_getScene : Error processing arguments"); + SE_HOLD_RETURN_VALUE(result, s.thisObject(), s.rval()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 0); + return false; +} +SE_BIND_FUNC(js_scene_Node_getScene) + +static bool js_scene_Node_getSiblingIndex(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_scene_Node_getSiblingIndex : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 0) { + int result = cobj->getSiblingIndex(); + ok &= nativevalue_to_se(result, s.rval(), nullptr /*ctx*/); + SE_PRECONDITION2(ok, false, "js_scene_Node_getSiblingIndex : Error processing arguments"); + SE_HOLD_RETURN_VALUE(result, s.thisObject(), s.rval()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 0); + return false; +} +SE_BIND_FUNC(js_scene_Node_getSiblingIndex) + +static bool js_scene_Node_getUuid(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_scene_Node_getUuid : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 0) { + const std::string& result = cobj->getUuid(); + ok &= nativevalue_to_se(result, s.rval(), nullptr /*ctx*/); + SE_PRECONDITION2(ok, false, "js_scene_Node_getUuid : Error processing arguments"); + SE_HOLD_RETURN_VALUE(result, s.thisObject(), s.rval()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 0); + return false; +} +SE_BIND_FUNC_AS_PROP_GET(js_scene_Node_getUuid) + +static bool js_scene_Node_insertChild(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_scene_Node_insertChild : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 2) { + HolderType arg0 = {}; + HolderType arg1 = {}; + ok &= sevalue_to_native(args[0], &arg0, s.thisObject()); + ok &= sevalue_to_native(args[1], &arg1, s.thisObject()); + SE_PRECONDITION2(ok, false, "js_scene_Node_insertChild : Error processing arguments"); + cobj->insertChild(arg0.value(), arg1.value()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 2); + return false; +} +SE_BIND_FUNC(js_scene_Node_insertChild) + +static bool js_scene_Node_invalidateChildren(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_scene_Node_invalidateChildren : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 1) { + HolderType arg0 = {}; + ok &= sevalue_to_native(args[0], &arg0, s.thisObject()); + SE_PRECONDITION2(ok, false, "js_scene_Node_invalidateChildren : Error processing arguments"); + cobj->invalidateChildren(arg0.value()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 1); + return false; +} +SE_BIND_FUNC(js_scene_Node_invalidateChildren) + +static bool js_scene_Node_inverseTransformPoint(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_scene_Node_inverseTransformPoint : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 2) { + HolderType arg0 = {}; + HolderType arg1 = {}; + ok &= sevalue_to_native(args[0], &arg0, s.thisObject()); + ok &= sevalue_to_native(args[1], &arg1, s.thisObject()); + SE_PRECONDITION2(ok, false, "js_scene_Node_inverseTransformPoint : Error processing arguments"); + cobj->inverseTransformPoint(arg0.value(), arg1.value()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 2); + return false; +} +SE_BIND_FUNC(js_scene_Node_inverseTransformPoint) + +static bool js_scene_Node_isActive(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_scene_Node_isActive : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 0) { + bool result = cobj->isActive(); + ok &= nativevalue_to_se(result, s.rval(), nullptr /*ctx*/); + SE_PRECONDITION2(ok, false, "js_scene_Node_isActive : Error processing arguments"); + SE_HOLD_RETURN_VALUE(result, s.thisObject(), s.rval()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 0); + return false; +} +SE_BIND_FUNC_AS_PROP_GET(js_scene_Node_isActive) + +static bool js_scene_Node_isChildOf(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_scene_Node_isChildOf : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 1) { + HolderType arg0 = {}; + ok &= sevalue_to_native(args[0], &arg0, s.thisObject()); + SE_PRECONDITION2(ok, false, "js_scene_Node_isChildOf : Error processing arguments"); + bool result = cobj->isChildOf(arg0.value()); + ok &= nativevalue_to_se(result, s.rval(), nullptr /*ctx*/); + SE_PRECONDITION2(ok, false, "js_scene_Node_isChildOf : Error processing arguments"); + SE_HOLD_RETURN_VALUE(result, s.thisObject(), s.rval()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 1); + return false; +} +SE_BIND_FUNC(js_scene_Node_isChildOf) + +static bool js_scene_Node_isPersistNode(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_scene_Node_isPersistNode : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 0) { + bool result = cobj->isPersistNode(); + ok &= nativevalue_to_se(result, s.rval(), nullptr /*ctx*/); + SE_PRECONDITION2(ok, false, "js_scene_Node_isPersistNode : Error processing arguments"); + SE_HOLD_RETURN_VALUE(result, s.thisObject(), s.rval()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 0); + return false; +} +SE_BIND_FUNC_AS_PROP_GET(js_scene_Node_isPersistNode) + +static bool js_scene_Node_lookAt(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_scene_Node_lookAt : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 1) { + HolderType arg0 = {}; + ok &= sevalue_to_native(args[0], &arg0, s.thisObject()); + SE_PRECONDITION2(ok, false, "js_scene_Node_lookAt : Error processing arguments"); + cobj->lookAt(arg0.value()); + return true; + } + if (argc == 2) { + HolderType arg0 = {}; + HolderType arg1 = {}; + ok &= sevalue_to_native(args[0], &arg0, s.thisObject()); + ok &= sevalue_to_native(args[1], &arg1, s.thisObject()); + SE_PRECONDITION2(ok, false, "js_scene_Node_lookAt : Error processing arguments"); + cobj->lookAt(arg0.value(), arg1.value()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 2); + return false; +} +SE_BIND_FUNC(js_scene_Node_lookAt) + +static bool js_scene_Node_off(se::State& s) // NOLINT(readability-identifier-naming) +{ + CC_UNUSED bool ok = true; + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2( cobj, false, "js_scene_Node_off : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + do { + if (argc == 2) { + HolderType arg0 = {}; + HolderType arg1 = {}; + + ok &= sevalue_to_native(args[0], &arg0, s.thisObject()); + if (!ok) { ok = true; break; } + ok &= sevalue_to_native(args[1], &arg1, s.thisObject()); + if (!ok) { ok = true; break; } + cobj->off(arg0.value(), arg1.value()); + return true; + } + } while(false); + + do { + if (argc == 3) { + HolderType arg0 = {}; + HolderType arg1 = {}; + HolderType arg2 = {}; + + ok &= sevalue_to_native(args[0], &arg0, s.thisObject()); + if (!ok) { ok = true; break; } + ok &= sevalue_to_native(args[1], &arg1, s.thisObject()); + if (!ok) { ok = true; break; } + ok &= sevalue_to_native(args[2], &arg2, s.thisObject()); + cobj->off(arg0.value(), arg1.value(), arg2.value()); + return true; + } + } while(false); + + do { + if (argc == 1) { + HolderType arg0 = {}; + + ok &= sevalue_to_native(args[0], &arg0, s.thisObject()); + if (!ok) { ok = true; break; } + cobj->off(arg0.value()); + return true; + } + } while(false); + + do { + if (argc == 2) { + HolderType arg0 = {}; + HolderType arg1 = {}; + + ok &= sevalue_to_native(args[0], &arg0, s.thisObject()); + if (!ok) { ok = true; break; } + ok &= sevalue_to_native(args[1], &arg1, s.thisObject()); + cobj->off(arg0.value(), arg1.value()); + return true; + } + } while(false); + + do { + if (argc == 2) { + HolderType arg0 = {}; + HolderType arg1 = {}; + + ok &= sevalue_to_native(args[0], &arg0, s.thisObject()); + if (!ok) { ok = true; break; } + ok &= sevalue_to_native(args[1], &arg1, s.thisObject()); + if (!ok) { ok = true; break; } + cobj->off(arg0.value(), arg1.value()); + return true; + } + } while(false); + + do { + if (argc == 3) { + HolderType arg0 = {}; + HolderType arg1 = {}; + HolderType arg2 = {}; + + ok &= sevalue_to_native(args[0], &arg0, s.thisObject()); + if (!ok) { ok = true; break; } + ok &= sevalue_to_native(args[1], &arg1, s.thisObject()); + if (!ok) { ok = true; break; } + ok &= sevalue_to_native(args[2], &arg2, s.thisObject()); + cobj->off(arg0.value(), arg1.value(), arg2.value()); + return true; + } + } while(false); + + SE_REPORT_ERROR("wrong number of arguments: %d", (int)argc); + return false; +} +SE_BIND_FUNC(js_scene_Node_off) + +static bool js_scene_Node_onPostActivated(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_scene_Node_onPostActivated : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 1) { + HolderType arg0 = {}; + ok &= sevalue_to_native(args[0], &arg0, s.thisObject()); + SE_PRECONDITION2(ok, false, "js_scene_Node_onPostActivated : Error processing arguments"); + cobj->onPostActivated(arg0.value()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 1); + return false; +} +SE_BIND_FUNC(js_scene_Node_onPostActivated) + +static bool js_scene_Node_pauseSystemEvents(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_scene_Node_pauseSystemEvents : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 1) { + HolderType arg0 = {}; + ok &= sevalue_to_native(args[0], &arg0, s.thisObject()); + SE_PRECONDITION2(ok, false, "js_scene_Node_pauseSystemEvents : Error processing arguments"); + cobj->pauseSystemEvents(arg0.value()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 1); + return false; +} +SE_BIND_FUNC(js_scene_Node_pauseSystemEvents) + +static bool js_scene_Node_removeAllChildren(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_scene_Node_removeAllChildren : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + if (argc == 0) { + cobj->removeAllChildren(); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 0); + return false; +} +SE_BIND_FUNC(js_scene_Node_removeAllChildren) + +static bool js_scene_Node_removeChild(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_scene_Node_removeChild : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 1) { + HolderType arg0 = {}; + ok &= sevalue_to_native(args[0], &arg0, s.thisObject()); + SE_PRECONDITION2(ok, false, "js_scene_Node_removeChild : Error processing arguments"); + cobj->removeChild(arg0.value()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 1); + return false; +} +SE_BIND_FUNC(js_scene_Node_removeChild) + +static bool js_scene_Node_removeFromParent(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_scene_Node_removeFromParent : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + if (argc == 0) { + cobj->removeFromParent(); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 0); + return false; +} +SE_BIND_FUNC(js_scene_Node_removeFromParent) + +static bool js_scene_Node_resumeSystemEvents(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_scene_Node_resumeSystemEvents : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 1) { + HolderType arg0 = {}; + ok &= sevalue_to_native(args[0], &arg0, s.thisObject()); + SE_PRECONDITION2(ok, false, "js_scene_Node_resumeSystemEvents : Error processing arguments"); + cobj->resumeSystemEvents(arg0.value()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 1); + return false; +} +SE_BIND_FUNC(js_scene_Node_resumeSystemEvents) + +static bool js_scene_Node_setActive(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_scene_Node_setActive : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 1) { + HolderType arg0 = {}; + ok &= sevalue_to_native(args[0], &arg0, s.thisObject()); + SE_PRECONDITION2(ok, false, "js_scene_Node_setActive : Error processing arguments"); + cobj->setActive(arg0.value()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 1); + return false; +} +SE_BIND_FUNC_AS_PROP_SET(js_scene_Node_setActive) + +static bool js_scene_Node_setAngle(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_scene_Node_setAngle : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 1) { + HolderType arg0 = {}; + ok &= sevalue_to_native(args[0], &arg0, s.thisObject()); + SE_PRECONDITION2(ok, false, "js_scene_Node_setAngle : Error processing arguments"); + cobj->setAngle(arg0.value()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 1); + return false; +} +SE_BIND_FUNC_AS_PROP_SET(js_scene_Node_setAngle) + +static bool js_scene_Node_setChangedFlags(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_scene_Node_setChangedFlags : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 1) { + HolderType arg0 = {}; + ok &= sevalue_to_native(args[0], &arg0, s.thisObject()); + SE_PRECONDITION2(ok, false, "js_scene_Node_setChangedFlags : Error processing arguments"); + cobj->setChangedFlags(arg0.value()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 1); + return false; +} +SE_BIND_FUNC_AS_PROP_SET(js_scene_Node_setChangedFlags) + +static bool js_scene_Node_setDirtyFlag(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_scene_Node_setDirtyFlag : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 1) { + HolderType arg0 = {}; + ok &= sevalue_to_native(args[0], &arg0, s.thisObject()); + SE_PRECONDITION2(ok, false, "js_scene_Node_setDirtyFlag : Error processing arguments"); + cobj->setDirtyFlag(arg0.value()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 1); + return false; +} +SE_BIND_FUNC_AS_PROP_SET(js_scene_Node_setDirtyFlag) + +static bool js_scene_Node_setEulerAngles(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_scene_Node_setEulerAngles : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 1) { + HolderType arg0 = {}; + ok &= sevalue_to_native(args[0], &arg0, s.thisObject()); + SE_PRECONDITION2(ok, false, "js_scene_Node_setEulerAngles : Error processing arguments"); + cobj->setEulerAngles(arg0.value()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 1); + return false; +} +SE_BIND_FUNC(js_scene_Node_setEulerAngles) + +static bool js_scene_Node_setEventMask(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_scene_Node_setEventMask : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 1) { + HolderType arg0 = {}; + ok &= sevalue_to_native(args[0], &arg0, s.thisObject()); + SE_PRECONDITION2(ok, false, "js_scene_Node_setEventMask : Error processing arguments"); + cobj->setEventMask(arg0.value()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 1); + return false; +} +SE_BIND_FUNC(js_scene_Node_setEventMask) + +static bool js_scene_Node_setForward(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_scene_Node_setForward : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 1) { + HolderType arg0 = {}; + ok &= sevalue_to_native(args[0], &arg0, s.thisObject()); + SE_PRECONDITION2(ok, false, "js_scene_Node_setForward : Error processing arguments"); + cobj->setForward(arg0.value()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 1); + return false; +} +SE_BIND_FUNC(js_scene_Node_setForward) + +static bool js_scene_Node_setLayer(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_scene_Node_setLayer : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 1) { + HolderType arg0 = {}; + ok &= sevalue_to_native(args[0], &arg0, s.thisObject()); + SE_PRECONDITION2(ok, false, "js_scene_Node_setLayer : Error processing arguments"); + cobj->setLayer(arg0.value()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 1); + return false; +} +SE_BIND_FUNC(js_scene_Node_setLayer) + +static bool js_scene_Node_setMatrix(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_scene_Node_setMatrix : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 1) { + HolderType arg0 = {}; + ok &= sevalue_to_native(args[0], &arg0, s.thisObject()); + SE_PRECONDITION2(ok, false, "js_scene_Node_setMatrix : Error processing arguments"); + cobj->setMatrix(arg0.value()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 1); + return false; +} +SE_BIND_FUNC_AS_PROP_SET(js_scene_Node_setMatrix) + +static bool js_scene_Node_setParent(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_scene_Node_setParent : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 1) { + HolderType arg0 = {}; + ok &= sevalue_to_native(args[0], &arg0, s.thisObject()); + SE_PRECONDITION2(ok, false, "js_scene_Node_setParent : Error processing arguments"); + cobj->setParent(arg0.value()); + return true; + } + if (argc == 2) { + HolderType arg0 = {}; + HolderType arg1 = {}; + ok &= sevalue_to_native(args[0], &arg0, s.thisObject()); + ok &= sevalue_to_native(args[1], &arg1, s.thisObject()); + SE_PRECONDITION2(ok, false, "js_scene_Node_setParent : Error processing arguments"); + cobj->setParent(arg0.value(), arg1.value()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 2); + return false; +} +SE_BIND_FUNC(js_scene_Node_setParent) + +static bool js_scene_Node_setPersistNode(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_scene_Node_setPersistNode : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 1) { + HolderType arg0 = {}; + ok &= sevalue_to_native(args[0], &arg0, s.thisObject()); + SE_PRECONDITION2(ok, false, "js_scene_Node_setPersistNode : Error processing arguments"); + cobj->setPersistNode(arg0.value()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 1); + return false; +} +SE_BIND_FUNC_AS_PROP_SET(js_scene_Node_setPersistNode) + +static bool js_scene_Node_setPositionForJS(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_scene_Node_setPositionForJS : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 3) { + HolderType arg0 = {}; + HolderType arg1 = {}; + HolderType arg2 = {}; + ok &= sevalue_to_native(args[0], &arg0, s.thisObject()); + ok &= sevalue_to_native(args[1], &arg1, s.thisObject()); + ok &= sevalue_to_native(args[2], &arg2, s.thisObject()); + SE_PRECONDITION2(ok, false, "js_scene_Node_setPositionForJS : Error processing arguments"); + cobj->setPositionForJS(arg0.value(), arg1.value(), arg2.value()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 3); + return false; +} +SE_BIND_FUNC(js_scene_Node_setPositionForJS) + +static bool js_scene_Node_setPositionInternal(se::State& s) // NOLINT(readability-identifier-naming) +{ + CC_UNUSED bool ok = true; + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2( cobj, false, "js_scene_Node_setPositionInternal : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + do { + if (argc == 4) { + HolderType arg0 = {}; + HolderType arg1 = {}; + HolderType arg2 = {}; + HolderType arg3 = {}; + + ok &= sevalue_to_native(args[0], &arg0, s.thisObject()); + if (!ok) { ok = true; break; } + ok &= sevalue_to_native(args[1], &arg1, s.thisObject()); + if (!ok) { ok = true; break; } + ok &= sevalue_to_native(args[2], &arg2, s.thisObject()); + if (!ok) { ok = true; break; } + ok &= sevalue_to_native(args[3], &arg3, s.thisObject()); + cobj->setPositionInternal(arg0.value(), arg1.value(), arg2.value(), arg3.value()); + return true; + } + } while(false); + + do { + if (argc == 3) { + HolderType arg0 = {}; + HolderType arg1 = {}; + HolderType arg2 = {}; + + ok &= sevalue_to_native(args[0], &arg0, s.thisObject()); + if (!ok) { ok = true; break; } + ok &= sevalue_to_native(args[1], &arg1, s.thisObject()); + if (!ok) { ok = true; break; } + ok &= sevalue_to_native(args[2], &arg2, s.thisObject()); + cobj->setPositionInternal(arg0.value(), arg1.value(), arg2.value()); + return true; + } + } while(false); + + SE_REPORT_ERROR("wrong number of arguments: %d", (int)argc); + return false; +} +SE_BIND_FUNC(js_scene_Node_setPositionInternal) + +static bool js_scene_Node_setRTSInternal(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_scene_Node_setRTSInternal : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 4) { + HolderType arg0 = {}; + HolderType arg1 = {}; + HolderType arg2 = {}; + HolderType arg3 = {}; + ok &= sevalue_to_native(args[0], &arg0, s.thisObject()); + ok &= sevalue_to_native(args[1], &arg1, s.thisObject()); + ok &= sevalue_to_native(args[2], &arg2, s.thisObject()); + ok &= sevalue_to_native(args[3], &arg3, s.thisObject()); + SE_PRECONDITION2(ok, false, "js_scene_Node_setRTSInternal : Error processing arguments"); + cobj->setRTSInternal(arg0.value(), arg1.value(), arg2.value(), arg3.value()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 4); + return false; +} +SE_BIND_FUNC(js_scene_Node_setRTSInternal) + +static bool js_scene_Node_setRotationForJS(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_scene_Node_setRotationForJS : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 4) { + HolderType arg0 = {}; + HolderType arg1 = {}; + HolderType arg2 = {}; + HolderType arg3 = {}; + ok &= sevalue_to_native(args[0], &arg0, s.thisObject()); + ok &= sevalue_to_native(args[1], &arg1, s.thisObject()); + ok &= sevalue_to_native(args[2], &arg2, s.thisObject()); + ok &= sevalue_to_native(args[3], &arg3, s.thisObject()); + SE_PRECONDITION2(ok, false, "js_scene_Node_setRotationForJS : Error processing arguments"); + cobj->setRotationForJS(arg0.value(), arg1.value(), arg2.value(), arg3.value()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 4); + return false; +} +SE_BIND_FUNC(js_scene_Node_setRotationForJS) + +static bool js_scene_Node_setRotationFromEulerForJS(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_scene_Node_setRotationFromEulerForJS : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 3) { + HolderType arg0 = {}; + HolderType arg1 = {}; + HolderType arg2 = {}; + ok &= sevalue_to_native(args[0], &arg0, s.thisObject()); + ok &= sevalue_to_native(args[1], &arg1, s.thisObject()); + ok &= sevalue_to_native(args[2], &arg2, s.thisObject()); + SE_PRECONDITION2(ok, false, "js_scene_Node_setRotationFromEulerForJS : Error processing arguments"); + cobj->setRotationFromEulerForJS(arg0.value(), arg1.value(), arg2.value()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 3); + return false; +} +SE_BIND_FUNC(js_scene_Node_setRotationFromEulerForJS) + +static bool js_scene_Node_setRotationInternal(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_scene_Node_setRotationInternal : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 5) { + HolderType arg0 = {}; + HolderType arg1 = {}; + HolderType arg2 = {}; + HolderType arg3 = {}; + HolderType arg4 = {}; + ok &= sevalue_to_native(args[0], &arg0, s.thisObject()); + ok &= sevalue_to_native(args[1], &arg1, s.thisObject()); + ok &= sevalue_to_native(args[2], &arg2, s.thisObject()); + ok &= sevalue_to_native(args[3], &arg3, s.thisObject()); + ok &= sevalue_to_native(args[4], &arg4, s.thisObject()); + SE_PRECONDITION2(ok, false, "js_scene_Node_setRotationInternal : Error processing arguments"); + cobj->setRotationInternal(arg0.value(), arg1.value(), arg2.value(), arg3.value(), arg4.value()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 5); + return false; +} +SE_BIND_FUNC(js_scene_Node_setRotationInternal) + +static bool js_scene_Node_setScaleForJS(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_scene_Node_setScaleForJS : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 3) { + HolderType arg0 = {}; + HolderType arg1 = {}; + HolderType arg2 = {}; + ok &= sevalue_to_native(args[0], &arg0, s.thisObject()); + ok &= sevalue_to_native(args[1], &arg1, s.thisObject()); + ok &= sevalue_to_native(args[2], &arg2, s.thisObject()); + SE_PRECONDITION2(ok, false, "js_scene_Node_setScaleForJS : Error processing arguments"); + cobj->setScaleForJS(arg0.value(), arg1.value(), arg2.value()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 3); + return false; +} +SE_BIND_FUNC(js_scene_Node_setScaleForJS) + +static bool js_scene_Node_setScaleInternal(se::State& s) // NOLINT(readability-identifier-naming) +{ + CC_UNUSED bool ok = true; + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2( cobj, false, "js_scene_Node_setScaleInternal : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + do { + if (argc == 4) { + HolderType arg0 = {}; + HolderType arg1 = {}; + HolderType arg2 = {}; + HolderType arg3 = {}; + + ok &= sevalue_to_native(args[0], &arg0, s.thisObject()); + if (!ok) { ok = true; break; } + ok &= sevalue_to_native(args[1], &arg1, s.thisObject()); + if (!ok) { ok = true; break; } + ok &= sevalue_to_native(args[2], &arg2, s.thisObject()); + if (!ok) { ok = true; break; } + ok &= sevalue_to_native(args[3], &arg3, s.thisObject()); + cobj->setScaleInternal(arg0.value(), arg1.value(), arg2.value(), arg3.value()); + return true; + } + } while(false); + + do { + if (argc == 3) { + HolderType arg0 = {}; + HolderType arg1 = {}; + HolderType arg2 = {}; + + ok &= sevalue_to_native(args[0], &arg0, s.thisObject()); + if (!ok) { ok = true; break; } + ok &= sevalue_to_native(args[1], &arg1, s.thisObject()); + if (!ok) { ok = true; break; } + ok &= sevalue_to_native(args[2], &arg2, s.thisObject()); + cobj->setScaleInternal(arg0.value(), arg1.value(), arg2.value()); + return true; + } + } while(false); + + SE_REPORT_ERROR("wrong number of arguments: %d", (int)argc); + return false; +} +SE_BIND_FUNC(js_scene_Node_setScaleInternal) + +static bool js_scene_Node_setSiblingIndex(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_scene_Node_setSiblingIndex : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 1) { + HolderType arg0 = {}; + ok &= sevalue_to_native(args[0], &arg0, s.thisObject()); + SE_PRECONDITION2(ok, false, "js_scene_Node_setSiblingIndex : Error processing arguments"); + cobj->setSiblingIndex(arg0.value()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 1); + return false; +} +SE_BIND_FUNC(js_scene_Node_setSiblingIndex) + +static bool js_scene_Node_setUIPropsTransformDirtyPtr(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_scene_Node_setUIPropsTransformDirtyPtr : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 1) { + HolderType arg0 = {}; + ok &= sevalue_to_native(args[0], &arg0, s.thisObject()); + SE_PRECONDITION2(ok, false, "js_scene_Node_setUIPropsTransformDirtyPtr : Error processing arguments"); + cobj->setUIPropsTransformDirtyPtr(arg0.value()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 1); + return false; +} +SE_BIND_FUNC(js_scene_Node_setUIPropsTransformDirtyPtr) + +static bool js_scene_Node_setWorldPosition(se::State& s) // NOLINT(readability-identifier-naming) +{ + CC_UNUSED bool ok = true; + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2( cobj, false, "js_scene_Node_setWorldPosition : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + do { + if (argc == 3) { + HolderType arg0 = {}; + HolderType arg1 = {}; + HolderType arg2 = {}; + + ok &= sevalue_to_native(args[0], &arg0, s.thisObject()); + if (!ok) { ok = true; break; } + ok &= sevalue_to_native(args[1], &arg1, s.thisObject()); + if (!ok) { ok = true; break; } + ok &= sevalue_to_native(args[2], &arg2, s.thisObject()); + if (!ok) { ok = true; break; } + cobj->setWorldPosition(arg0.value(), arg1.value(), arg2.value()); + return true; + } + } while(false); + + do { + if (argc == 1) { + HolderType arg0 = {}; + + ok &= sevalue_to_native(args[0], &arg0, s.thisObject()); + if (!ok) { ok = true; break; } + cobj->setWorldPosition(arg0.value()); + return true; + } + } while(false); + + SE_REPORT_ERROR("wrong number of arguments: %d", (int)argc); + return false; +} +SE_BIND_FUNC(js_scene_Node_setWorldPosition) + +static bool js_scene_Node_setWorldRotation(se::State& s) // NOLINT(readability-identifier-naming) +{ + CC_UNUSED bool ok = true; + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2( cobj, false, "js_scene_Node_setWorldRotation : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + do { + if (argc == 4) { + HolderType arg0 = {}; + HolderType arg1 = {}; + HolderType arg2 = {}; + HolderType arg3 = {}; + + ok &= sevalue_to_native(args[0], &arg0, s.thisObject()); + if (!ok) { ok = true; break; } + ok &= sevalue_to_native(args[1], &arg1, s.thisObject()); + if (!ok) { ok = true; break; } + ok &= sevalue_to_native(args[2], &arg2, s.thisObject()); + if (!ok) { ok = true; break; } + ok &= sevalue_to_native(args[3], &arg3, s.thisObject()); + if (!ok) { ok = true; break; } + cobj->setWorldRotation(arg0.value(), arg1.value(), arg2.value(), arg3.value()); + return true; + } + } while(false); + + do { + if (argc == 1) { + HolderType arg0 = {}; + + ok &= sevalue_to_native(args[0], &arg0, s.thisObject()); + if (!ok) { ok = true; break; } + cobj->setWorldRotation(arg0.value()); + return true; + } + } while(false); + + SE_REPORT_ERROR("wrong number of arguments: %d", (int)argc); + return false; +} +SE_BIND_FUNC(js_scene_Node_setWorldRotation) + +static bool js_scene_Node_setWorldRotationFromEuler(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_scene_Node_setWorldRotationFromEuler : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 3) { + HolderType arg0 = {}; + HolderType arg1 = {}; + HolderType arg2 = {}; + ok &= sevalue_to_native(args[0], &arg0, s.thisObject()); + ok &= sevalue_to_native(args[1], &arg1, s.thisObject()); + ok &= sevalue_to_native(args[2], &arg2, s.thisObject()); + SE_PRECONDITION2(ok, false, "js_scene_Node_setWorldRotationFromEuler : Error processing arguments"); + cobj->setWorldRotationFromEuler(arg0.value(), arg1.value(), arg2.value()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 3); + return false; +} +SE_BIND_FUNC(js_scene_Node_setWorldRotationFromEuler) + +static bool js_scene_Node_setWorldScale(se::State& s) // NOLINT(readability-identifier-naming) +{ + CC_UNUSED bool ok = true; + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2( cobj, false, "js_scene_Node_setWorldScale : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + do { + if (argc == 3) { + HolderType arg0 = {}; + HolderType arg1 = {}; + HolderType arg2 = {}; + + ok &= sevalue_to_native(args[0], &arg0, s.thisObject()); + if (!ok) { ok = true; break; } + ok &= sevalue_to_native(args[1], &arg1, s.thisObject()); + if (!ok) { ok = true; break; } + ok &= sevalue_to_native(args[2], &arg2, s.thisObject()); + if (!ok) { ok = true; break; } + cobj->setWorldScale(arg0.value(), arg1.value(), arg2.value()); + return true; + } + } while(false); + + do { + if (argc == 1) { + HolderType arg0 = {}; + + ok &= sevalue_to_native(args[0], &arg0, s.thisObject()); + if (!ok) { ok = true; break; } + cobj->setWorldScale(arg0.value()); + return true; + } + } while(false); + + SE_REPORT_ERROR("wrong number of arguments: %d", (int)argc); + return false; +} +SE_BIND_FUNC(js_scene_Node_setWorldScale) + +static bool js_scene_Node_targetOff(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_scene_Node_targetOff : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 1) { + HolderType arg0 = {}; + ok &= sevalue_to_native(args[0], &arg0, s.thisObject()); + SE_PRECONDITION2(ok, false, "js_scene_Node_targetOff : Error processing arguments"); + cobj->targetOff(arg0.value()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 1); + return false; +} +SE_BIND_FUNC(js_scene_Node_targetOff) + +static bool js_scene_Node_translate(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_scene_Node_translate : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 1) { + HolderType arg0 = {}; + ok &= sevalue_to_native(args[0], &arg0, s.thisObject()); + SE_PRECONDITION2(ok, false, "js_scene_Node_translate : Error processing arguments"); + cobj->translate(arg0.value()); + return true; + } + if (argc == 2) { + HolderType arg0 = {}; + HolderType arg1 = {}; + ok &= sevalue_to_native(args[0], &arg0, s.thisObject()); + ok &= sevalue_to_native(args[1], &arg1, s.thisObject()); + SE_PRECONDITION2(ok, false, "js_scene_Node_translate : Error processing arguments"); + cobj->translate(arg0.value(), arg1.value()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 2); + return false; +} +SE_BIND_FUNC(js_scene_Node_translate) + +static bool js_scene_Node_updateSiblingIndex(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_scene_Node_updateSiblingIndex : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + if (argc == 0) { + cobj->updateSiblingIndex(); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 0); + return false; +} +SE_BIND_FUNC(js_scene_Node_updateSiblingIndex) + +static bool js_scene_Node_updateWorldTransform(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_scene_Node_updateWorldTransform : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + if (argc == 0) { + cobj->updateWorldTransform(); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 0); + return false; +} +SE_BIND_FUNC(js_scene_Node_updateWorldTransform) + +static bool js_scene_Node_walk(se::State& s) // NOLINT(readability-identifier-naming) +{ + CC_UNUSED bool ok = true; + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2( cobj, false, "js_scene_Node_walk : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + do { + if (argc == 2) { + HolderType, true> arg0 = {}; + HolderType, true> arg1 = {}; + + do { + if (args[0].isObject() && args[0].toObject()->isFunction()) + { + se::Value jsThis(s.thisObject()); + se::Value jsFunc(args[0]); + jsThis.toObject()->attachObject(jsFunc.toObject()); + auto * thisObj = s.thisObject(); + auto lambda = [=](cc::Node* larg0) -> void { + se::ScriptEngine::getInstance()->clearException(); + se::AutoHandleScope hs; + + CC_UNUSED bool ok = true; + se::ValueArray args; + args.resize(1); + ok &= nativevalue_to_se(larg0, args[0], nullptr /*ctx*/); + se::Value rval; + se::Object* funcObj = jsFunc.toObject(); + bool succeed = funcObj->call(args, thisObj, &rval); + if (!succeed) { + se::ScriptEngine::getInstance()->clearException(); + } + }; + arg0.data = lambda; + } + else + { + arg0.data = nullptr; + } + } while(false) + ; + if (!ok) { ok = true; break; } + do { + if (args[1].isObject() && args[1].toObject()->isFunction()) + { + se::Value jsThis(s.thisObject()); + se::Value jsFunc(args[1]); + jsThis.toObject()->attachObject(jsFunc.toObject()); + auto * thisObj = s.thisObject(); + auto lambda = [=](cc::Node* larg0) -> void { + se::ScriptEngine::getInstance()->clearException(); + se::AutoHandleScope hs; + + CC_UNUSED bool ok = true; + se::ValueArray args; + args.resize(1); + ok &= nativevalue_to_se(larg0, args[0], nullptr /*ctx*/); + se::Value rval; + se::Object* funcObj = jsFunc.toObject(); + bool succeed = funcObj->call(args, thisObj, &rval); + if (!succeed) { + se::ScriptEngine::getInstance()->clearException(); + } + }; + arg1.data = lambda; + } + else + { + arg1.data = nullptr; + } + } while(false) + ; + if (!ok) { ok = true; break; } + cobj->walk(arg0.value(), arg1.value()); + return true; + } + } while(false); + + do { + if (argc == 1) { + HolderType, true> arg0 = {}; + + do { + if (args[0].isObject() && args[0].toObject()->isFunction()) + { + se::Value jsThis(s.thisObject()); + se::Value jsFunc(args[0]); + jsThis.toObject()->attachObject(jsFunc.toObject()); + auto * thisObj = s.thisObject(); + auto lambda = [=](cc::Node* larg0) -> void { + se::ScriptEngine::getInstance()->clearException(); + se::AutoHandleScope hs; + + CC_UNUSED bool ok = true; + se::ValueArray args; + args.resize(1); + ok &= nativevalue_to_se(larg0, args[0], nullptr /*ctx*/); + se::Value rval; + se::Object* funcObj = jsFunc.toObject(); + bool succeed = funcObj->call(args, thisObj, &rval); + if (!succeed) { + se::ScriptEngine::getInstance()->clearException(); + } + }; + arg0.data = lambda; + } + else + { + arg0.data = nullptr; + } + } while(false) + ; + if (!ok) { ok = true; break; } + cobj->walk(arg0.value()); + return true; + } + } while(false); + + SE_REPORT_ERROR("wrong number of arguments: %d", (int)argc); + return false; +} +SE_BIND_FUNC(js_scene_Node_walk) + +static bool js_scene_Node_clearNodeArray_static(se::State& s) // NOLINT(readability-identifier-naming) +{ + const auto& args = s.args(); + size_t argc = args.size(); + if (argc == 0) { + cc::Node::clearNodeArray(); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 0); + return false; +} +SE_BIND_FUNC(js_scene_Node_clearNodeArray_static) + +static bool js_scene_Node_getIdxOfChild_static(se::State& s) // NOLINT(readability-identifier-naming) +{ + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 2) { + HolderType>, true> arg0 = {}; + HolderType arg1 = {}; + ok &= sevalue_to_native(args[0], &arg0, nullptr); + ok &= sevalue_to_native(args[1], &arg1, nullptr); + SE_PRECONDITION2(ok, false, "js_scene_Node_getIdxOfChild_static : Error processing arguments"); + int result = cc::Node::getIdxOfChild(arg0.value(), arg1.value()); + ok &= nativevalue_to_se(result, s.rval(), nullptr /*ctx*/); + SE_PRECONDITION2(ok, false, "js_scene_Node_getIdxOfChild_static : Error processing arguments"); + SE_HOLD_RETURN_VALUE(result, s.thisObject(), s.rval()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 2); + return false; +} +SE_BIND_FUNC(js_scene_Node_getIdxOfChild_static) + +static bool js_scene_Node_instantiate_static(se::State& s) // NOLINT(readability-identifier-naming) +{ + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 2) { + HolderType arg0 = {}; + HolderType arg1 = {}; + ok &= sevalue_to_native(args[0], &arg0, nullptr); + ok &= sevalue_to_native(args[1], &arg1, nullptr); + SE_PRECONDITION2(ok, false, "js_scene_Node_instantiate_static : Error processing arguments"); + cc::Node* result = cc::Node::instantiate(arg0.value(), arg1.value()); + ok &= nativevalue_to_se(result, s.rval(), nullptr /*ctx*/); + SE_PRECONDITION2(ok, false, "js_scene_Node_instantiate_static : Error processing arguments"); + SE_HOLD_RETURN_VALUE(result, s.thisObject(), s.rval()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 2); + return false; +} +SE_BIND_FUNC(js_scene_Node_instantiate_static) + +static bool js_scene_Node_resetChangedFlags_static(se::State& s) // NOLINT(readability-identifier-naming) +{ + const auto& args = s.args(); + size_t argc = args.size(); + if (argc == 0) { + cc::Node::resetChangedFlags(); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 0); + return false; +} +SE_BIND_FUNC(js_scene_Node_resetChangedFlags_static) + +static bool js_scene_Node_setScene_static(se::State& s) // NOLINT(readability-identifier-naming) +{ + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 1) { + HolderType arg0 = {}; + ok &= sevalue_to_native(args[0], &arg0, nullptr); + SE_PRECONDITION2(ok, false, "js_scene_Node_setScene_static : Error processing arguments"); + cc::Node::setScene(arg0.value()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 1); + return false; +} +SE_BIND_FUNC(js_scene_Node_setScene_static) + +static bool js_scene_Node_get__siblingIndex(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_scene_Node_get__siblingIndex : Invalid Native Object"); + + CC_UNUSED bool ok = true; + se::Value jsret; + ok &= nativevalue_to_se(cobj->_siblingIndex, jsret, s.thisObject() /*ctx*/); + s.rval() = jsret; + SE_HOLD_RETURN_VALUE(cobj->_siblingIndex, s.thisObject(), s.rval()); + return true; +} +SE_BIND_PROP_GET(js_scene_Node_get__siblingIndex) + +static bool js_scene_Node_set__siblingIndex(se::State& s) // NOLINT(readability-identifier-naming) +{ + const auto& args = s.args(); + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_scene_Node_set__siblingIndex : Invalid Native Object"); + + CC_UNUSED bool ok = true; + ok &= sevalue_to_native(args[0], &cobj->_siblingIndex, s.thisObject()); + SE_PRECONDITION2(ok, false, "js_scene_Node_set__siblingIndex : Error processing new value"); + return true; +} +SE_BIND_PROP_SET(js_scene_Node_set__siblingIndex) + +static bool js_scene_Node_get__id(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_scene_Node_get__id : Invalid Native Object"); + + CC_UNUSED bool ok = true; + se::Value jsret; + ok &= nativevalue_to_se(cobj->_id, jsret, s.thisObject() /*ctx*/); + s.rval() = jsret; + SE_HOLD_RETURN_VALUE(cobj->_id, s.thisObject(), s.rval()); + return true; +} +SE_BIND_PROP_GET(js_scene_Node_get__id) + +static bool js_scene_Node_set__id(se::State& s) // NOLINT(readability-identifier-naming) +{ + const auto& args = s.args(); + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_scene_Node_set__id : Invalid Native Object"); + + CC_UNUSED bool ok = true; + ok &= sevalue_to_native(args[0], &cobj->_id, s.thisObject()); + SE_PRECONDITION2(ok, false, "js_scene_Node_set__id : Error processing new value"); + return true; +} +SE_BIND_PROP_SET(js_scene_Node_set__id) + +static bool js_scene_Node_get__parent(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_scene_Node_get__parent : Invalid Native Object"); + + CC_UNUSED bool ok = true; + se::Value jsret; + ok &= nativevalue_to_se(cobj->_parent, jsret, s.thisObject() /*ctx*/); + s.rval() = jsret; + SE_HOLD_RETURN_VALUE(cobj->_parent, s.thisObject(), s.rval()); + return true; +} +SE_BIND_PROP_GET(js_scene_Node_get__parent) + +static bool js_scene_Node_set__parent(se::State& s) // NOLINT(readability-identifier-naming) +{ + const auto& args = s.args(); + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_scene_Node_set__parent : Invalid Native Object"); + + CC_UNUSED bool ok = true; + ok &= sevalue_to_native(args[0], &cobj->_parent, s.thisObject()); + SE_PRECONDITION2(ok, false, "js_scene_Node_set__parent : Error processing new value"); + return true; +} +SE_BIND_PROP_SET(js_scene_Node_set__parent) + +static bool js_scene_Node_get__active(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_scene_Node_get__active : Invalid Native Object"); + + CC_UNUSED bool ok = true; + se::Value jsret; + ok &= nativevalue_to_se(cobj->_active, jsret, s.thisObject() /*ctx*/); + s.rval() = jsret; + SE_HOLD_RETURN_VALUE(cobj->_active, s.thisObject(), s.rval()); + return true; +} +SE_BIND_PROP_GET(js_scene_Node_get__active) + +static bool js_scene_Node_set__active(se::State& s) // NOLINT(readability-identifier-naming) +{ + const auto& args = s.args(); + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_scene_Node_set__active : Invalid Native Object"); + + CC_UNUSED bool ok = true; + ok &= sevalue_to_native(args[0], &cobj->_active, s.thisObject()); + SE_PRECONDITION2(ok, false, "js_scene_Node_set__active : Error processing new value"); + return true; +} +SE_BIND_PROP_SET(js_scene_Node_set__active) + +SE_DECLARE_FINALIZE_FUNC(js_cc_Node_finalize) + +static bool js_scene_Node_constructor(se::State& s) // NOLINT(readability-identifier-naming) constructor_overloaded.c +{ + CC_UNUSED bool ok = true; + const auto& args = s.args(); + size_t argc = args.size(); + do { + if (argc == 1) { + HolderType arg0 = {}; + ok &= sevalue_to_native(args[0], &arg0, s.thisObject()); + if (!ok) { ok = true; break; } + auto *ptr = JSB_MAKE_PRIVATE_OBJECT(cc::Node, arg0.value()); + s.thisObject()->setPrivateObject(ptr); + return true; + } + } while(false); + do { + if (argc == 0) { + auto *ptr = JSB_MAKE_PRIVATE_OBJECT(cc::Node); + s.thisObject()->setPrivateObject(ptr); + return true; + } + } while(false); + SE_REPORT_ERROR("wrong number of arguments: %d", (int)argc); + return false; +} +SE_BIND_CTOR(js_scene_Node_constructor, __jsb_cc_Node_class, js_cc_Node_finalize) + +static bool js_cc_Node_finalize(se::State& s) // NOLINT(readability-identifier-naming) +{ + return true; +} +SE_BIND_FINALIZE_FUNC(js_cc_Node_finalize) + +bool js_register_scene_Node(se::Object* obj) // NOLINT(readability-identifier-naming) +{ + auto* cls = se::Class::create("Node", obj, __jsb_cc_BaseNode_proto, _SE(js_scene_Node_constructor)); + + cls->defineProperty("_siblingIndex", _SE(js_scene_Node_get__siblingIndex), _SE(js_scene_Node_set__siblingIndex)); + cls->defineProperty("_id", _SE(js_scene_Node_get__id), _SE(js_scene_Node_set__id)); + cls->defineProperty("_parentInternal", _SE(js_scene_Node_get__parent), _SE(js_scene_Node_set__parent)); + cls->defineProperty("_active", _SE(js_scene_Node_get__active), _SE(js_scene_Node_set__active)); + cls->defineProperty("angle", _SE(js_scene_Node_getAngle_asGetter), _SE(js_scene_Node_setAngle_asSetter)); + cls->defineProperty("uuid", _SE(js_scene_Node_getUuid_asGetter), nullptr); + cls->defineProperty("hasChangedFlags", _SE(js_scene_Node_getChangedFlags_asGetter), _SE(js_scene_Node_setChangedFlags_asSetter)); + cls->defineProperty("_persistNode", _SE(js_scene_Node_isPersistNode_asGetter), _SE(js_scene_Node_setPersistNode_asSetter)); + cls->defineProperty("active", _SE(js_scene_Node_isActive_asGetter), _SE(js_scene_Node_setActive_asSetter)); + cls->defineProperty("_dirtyFlags", _SE(js_scene_Node_getDirtyFlag_asGetter), _SE(js_scene_Node_setDirtyFlag_asSetter)); + cls->defineProperty("matrix", nullptr, _SE(js_scene_Node_setMatrix_asSetter)); + cls->defineFunction("_setChildren", _SE(js_scene_Node__setChildren)); + cls->defineFunction("addChild", _SE(js_scene_Node_addChild)); + cls->defineFunction("destroyAllChildren", _SE(js_scene_Node_destroyAllChildren)); + cls->defineFunction("getChildByName", _SE(js_scene_Node_getChildByName)); + cls->defineFunction("getChildByPath", _SE(js_scene_Node_getChildByPath)); + cls->defineFunction("getChildByUuid", _SE(js_scene_Node_getChildByUuid)); + cls->defineFunction("getEventMask", _SE(js_scene_Node_getEventMask)); + cls->defineFunction("getLayer", _SE(js_scene_Node_getLayer)); + cls->defineFunction("getParent", _SE(js_scene_Node_getParent)); + cls->defineFunction("getScene", _SE(js_scene_Node_getScene)); + cls->defineFunction("getSiblingIndex", _SE(js_scene_Node_getSiblingIndex)); + cls->defineFunction("insertChild", _SE(js_scene_Node_insertChild)); + cls->defineFunction("invalidateChildren", _SE(js_scene_Node_invalidateChildren)); + cls->defineFunction("inverseTransformPoint", _SE(js_scene_Node_inverseTransformPoint)); + cls->defineFunction("isChildOf", _SE(js_scene_Node_isChildOf)); + cls->defineFunction("lookAt", _SE(js_scene_Node_lookAt)); + cls->defineFunction("off", _SE(js_scene_Node_off)); + cls->defineFunction("onPostActivated", _SE(js_scene_Node_onPostActivated)); + cls->defineFunction("pauseSystemEvents", _SE(js_scene_Node_pauseSystemEvents)); + cls->defineFunction("removeAllChildren", _SE(js_scene_Node_removeAllChildren)); + cls->defineFunction("removeChild", _SE(js_scene_Node_removeChild)); + cls->defineFunction("removeFromParent", _SE(js_scene_Node_removeFromParent)); + cls->defineFunction("resumeSystemEvents", _SE(js_scene_Node_resumeSystemEvents)); + cls->defineFunction("setEulerAngles", _SE(js_scene_Node_setEulerAngles)); + cls->defineFunction("setEventMask", _SE(js_scene_Node_setEventMask)); + cls->defineFunction("setForward", _SE(js_scene_Node_setForward)); + cls->defineFunction("setLayer", _SE(js_scene_Node_setLayer)); + cls->defineFunction("setParent", _SE(js_scene_Node_setParent)); + cls->defineFunction("setPositionForJS", _SE(js_scene_Node_setPositionForJS)); + cls->defineFunction("setPositionInternal", _SE(js_scene_Node_setPositionInternal)); + cls->defineFunction("setRTSInternal", _SE(js_scene_Node_setRTSInternal)); + cls->defineFunction("setRotationForJS", _SE(js_scene_Node_setRotationForJS)); + cls->defineFunction("setRotationFromEulerForJS", _SE(js_scene_Node_setRotationFromEulerForJS)); + cls->defineFunction("setRotationInternal", _SE(js_scene_Node_setRotationInternal)); + cls->defineFunction("setScaleForJS", _SE(js_scene_Node_setScaleForJS)); + cls->defineFunction("setScaleInternal", _SE(js_scene_Node_setScaleInternal)); + cls->defineFunction("setSiblingIndex", _SE(js_scene_Node_setSiblingIndex)); + cls->defineFunction("setUIPropsTransformDirtyPtr", _SE(js_scene_Node_setUIPropsTransformDirtyPtr)); + cls->defineFunction("setWorldPosition", _SE(js_scene_Node_setWorldPosition)); + cls->defineFunction("setWorldRotation", _SE(js_scene_Node_setWorldRotation)); + cls->defineFunction("setWorldRotationFromEuler", _SE(js_scene_Node_setWorldRotationFromEuler)); + cls->defineFunction("setWorldScale", _SE(js_scene_Node_setWorldScale)); + cls->defineFunction("targetOff", _SE(js_scene_Node_targetOff)); + cls->defineFunction("translate", _SE(js_scene_Node_translate)); + cls->defineFunction("_updateSiblingIndex", _SE(js_scene_Node_updateSiblingIndex)); + cls->defineFunction("updateWorldTransform", _SE(js_scene_Node_updateWorldTransform)); + cls->defineFunction("walk", _SE(js_scene_Node_walk)); + cls->defineStaticFunction("clearNodeArray", _SE(js_scene_Node_clearNodeArray_static)); + cls->defineStaticFunction("getIdxOfChild", _SE(js_scene_Node_getIdxOfChild_static)); + cls->defineStaticFunction("instantiate", _SE(js_scene_Node_instantiate_static)); + cls->defineStaticFunction("resetHasChangedFlags", _SE(js_scene_Node_resetChangedFlags_static)); + cls->defineStaticFunction("setScene", _SE(js_scene_Node_setScene_static)); + cls->defineFinalizeFunction(_SE(js_cc_Node_finalize)); + cls->install(); + JSBClassType::registerClass(cls); + + __jsb_cc_Node_proto = cls->getProto(); + __jsb_cc_Node_class = cls; + + + se::ScriptEngine::getInstance()->clearException(); + return true; +} +se::Object* __jsb_cc_SceneGlobals_proto = nullptr; // NOLINT +se::Class* __jsb_cc_SceneGlobals_class = nullptr; // NOLINT + +static bool js_scene_SceneGlobals_activate(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_scene_SceneGlobals_activate : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + if (argc == 0) { + cobj->activate(); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 0); + return false; +} +SE_BIND_FUNC(js_scene_SceneGlobals_activate) + +static bool js_scene_SceneGlobals_getAmbientInfo(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_scene_SceneGlobals_getAmbientInfo : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 0) { + cc::scene::AmbientInfo* result = cobj->getAmbientInfo(); + ok &= nativevalue_to_se(result, s.rval(), nullptr /*ctx*/); + SE_PRECONDITION2(ok, false, "js_scene_SceneGlobals_getAmbientInfo : Error processing arguments"); + SE_HOLD_RETURN_VALUE(result, s.thisObject(), s.rval()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 0); + return false; +} +SE_BIND_FUNC(js_scene_SceneGlobals_getAmbientInfo) + +static bool js_scene_SceneGlobals_getFogInfo(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_scene_SceneGlobals_getFogInfo : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 0) { + cc::scene::FogInfo* result = cobj->getFogInfo(); + ok &= nativevalue_to_se(result, s.rval(), nullptr /*ctx*/); + SE_PRECONDITION2(ok, false, "js_scene_SceneGlobals_getFogInfo : Error processing arguments"); + SE_HOLD_RETURN_VALUE(result, s.thisObject(), s.rval()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 0); + return false; +} +SE_BIND_FUNC(js_scene_SceneGlobals_getFogInfo) + +static bool js_scene_SceneGlobals_getOctreeInfo(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_scene_SceneGlobals_getOctreeInfo : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 0) { + cc::scene::OctreeInfo* result = cobj->getOctreeInfo(); + ok &= nativevalue_to_se(result, s.rval(), nullptr /*ctx*/); + SE_PRECONDITION2(ok, false, "js_scene_SceneGlobals_getOctreeInfo : Error processing arguments"); + SE_HOLD_RETURN_VALUE(result, s.thisObject(), s.rval()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 0); + return false; +} +SE_BIND_FUNC(js_scene_SceneGlobals_getOctreeInfo) + +static bool js_scene_SceneGlobals_getShadowsInfo(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_scene_SceneGlobals_getShadowsInfo : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 0) { + cc::scene::ShadowsInfo* result = cobj->getShadowsInfo(); + ok &= nativevalue_to_se(result, s.rval(), nullptr /*ctx*/); + SE_PRECONDITION2(ok, false, "js_scene_SceneGlobals_getShadowsInfo : Error processing arguments"); + SE_HOLD_RETURN_VALUE(result, s.thisObject(), s.rval()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 0); + return false; +} +SE_BIND_FUNC(js_scene_SceneGlobals_getShadowsInfo) + +static bool js_scene_SceneGlobals_getSkyboxInfo(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_scene_SceneGlobals_getSkyboxInfo : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 0) { + cc::scene::SkyboxInfo* result = cobj->getSkyboxInfo(); + ok &= nativevalue_to_se(result, s.rval(), nullptr /*ctx*/); + SE_PRECONDITION2(ok, false, "js_scene_SceneGlobals_getSkyboxInfo : Error processing arguments"); + SE_HOLD_RETURN_VALUE(result, s.thisObject(), s.rval()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 0); + return false; +} +SE_BIND_FUNC(js_scene_SceneGlobals_getSkyboxInfo) + +static bool js_scene_SceneGlobals_setAmbientInfo(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_scene_SceneGlobals_setAmbientInfo : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 1) { + HolderType arg0 = {}; + ok &= sevalue_to_native(args[0], &arg0, s.thisObject()); + SE_PRECONDITION2(ok, false, "js_scene_SceneGlobals_setAmbientInfo : Error processing arguments"); + cobj->setAmbientInfo(arg0.value()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 1); + return false; +} +SE_BIND_FUNC(js_scene_SceneGlobals_setAmbientInfo) + +static bool js_scene_SceneGlobals_setFogInfo(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_scene_SceneGlobals_setFogInfo : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 1) { + HolderType arg0 = {}; + ok &= sevalue_to_native(args[0], &arg0, s.thisObject()); + SE_PRECONDITION2(ok, false, "js_scene_SceneGlobals_setFogInfo : Error processing arguments"); + cobj->setFogInfo(arg0.value()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 1); + return false; +} +SE_BIND_FUNC(js_scene_SceneGlobals_setFogInfo) + +static bool js_scene_SceneGlobals_setOctreeInfo(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_scene_SceneGlobals_setOctreeInfo : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 1) { + HolderType arg0 = {}; + ok &= sevalue_to_native(args[0], &arg0, s.thisObject()); + SE_PRECONDITION2(ok, false, "js_scene_SceneGlobals_setOctreeInfo : Error processing arguments"); + cobj->setOctreeInfo(arg0.value()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 1); + return false; +} +SE_BIND_FUNC(js_scene_SceneGlobals_setOctreeInfo) + +static bool js_scene_SceneGlobals_setShadowsInfo(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_scene_SceneGlobals_setShadowsInfo : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 1) { + HolderType arg0 = {}; + ok &= sevalue_to_native(args[0], &arg0, s.thisObject()); + SE_PRECONDITION2(ok, false, "js_scene_SceneGlobals_setShadowsInfo : Error processing arguments"); + cobj->setShadowsInfo(arg0.value()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 1); + return false; +} +SE_BIND_FUNC(js_scene_SceneGlobals_setShadowsInfo) + +static bool js_scene_SceneGlobals_setSkyboxInfo(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_scene_SceneGlobals_setSkyboxInfo : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 1) { + HolderType arg0 = {}; + ok &= sevalue_to_native(args[0], &arg0, s.thisObject()); + SE_PRECONDITION2(ok, false, "js_scene_SceneGlobals_setSkyboxInfo : Error processing arguments"); + cobj->setSkyboxInfo(arg0.value()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 1); + return false; +} +SE_BIND_FUNC(js_scene_SceneGlobals_setSkyboxInfo) + +SE_DECLARE_FINALIZE_FUNC(js_cc_SceneGlobals_finalize) + +static bool js_scene_SceneGlobals_constructor(se::State& s) // NOLINT(readability-identifier-naming) constructor.c +{ + auto *ptr = JSB_MAKE_PRIVATE_OBJECT(cc::SceneGlobals); + s.thisObject()->setPrivateObject(ptr); + return true; +} +SE_BIND_CTOR(js_scene_SceneGlobals_constructor, __jsb_cc_SceneGlobals_class, js_cc_SceneGlobals_finalize) + +static bool js_cc_SceneGlobals_finalize(se::State& s) // NOLINT(readability-identifier-naming) +{ + return true; +} +SE_BIND_FINALIZE_FUNC(js_cc_SceneGlobals_finalize) + +bool js_register_scene_SceneGlobals(se::Object* obj) // NOLINT(readability-identifier-naming) +{ + auto* cls = se::Class::create("SceneGlobals", obj, nullptr, _SE(js_scene_SceneGlobals_constructor)); + + cls->defineFunction("activate", _SE(js_scene_SceneGlobals_activate)); + cls->defineFunction("getAmbientInfo", _SE(js_scene_SceneGlobals_getAmbientInfo)); + cls->defineFunction("getFogInfo", _SE(js_scene_SceneGlobals_getFogInfo)); + cls->defineFunction("getOctreeInfo", _SE(js_scene_SceneGlobals_getOctreeInfo)); + cls->defineFunction("getShadowsInfo", _SE(js_scene_SceneGlobals_getShadowsInfo)); + cls->defineFunction("getSkyboxInfo", _SE(js_scene_SceneGlobals_getSkyboxInfo)); + cls->defineFunction("setAmbientInfo", _SE(js_scene_SceneGlobals_setAmbientInfo)); + cls->defineFunction("setFogInfo", _SE(js_scene_SceneGlobals_setFogInfo)); + cls->defineFunction("setOctreeInfo", _SE(js_scene_SceneGlobals_setOctreeInfo)); + cls->defineFunction("setShadowsInfo", _SE(js_scene_SceneGlobals_setShadowsInfo)); + cls->defineFunction("setSkyboxInfo", _SE(js_scene_SceneGlobals_setSkyboxInfo)); + cls->defineFinalizeFunction(_SE(js_cc_SceneGlobals_finalize)); + cls->install(); + JSBClassType::registerClass(cls); + + __jsb_cc_SceneGlobals_proto = cls->getProto(); + __jsb_cc_SceneGlobals_class = cls; + + + se::ScriptEngine::getInstance()->clearException(); + return true; +} +se::Object* __jsb_cc_Scene_proto = nullptr; // NOLINT +se::Class* __jsb_cc_Scene_class = nullptr; // NOLINT + +static bool js_scene_Scene_activate(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_scene_Scene_activate : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 0) { + cobj->activate(); + return true; + } + if (argc == 1) { + HolderType arg0 = {}; + ok &= sevalue_to_native(args[0], &arg0, s.thisObject()); + SE_PRECONDITION2(ok, false, "js_scene_Scene_activate : Error processing arguments"); + cobj->activate(arg0.value()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 1); + return false; +} +SE_BIND_FUNC(js_scene_Scene_activate) + +static bool js_scene_Scene_getRenderScene(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_scene_Scene_getRenderScene : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 0) { + cc::scene::RenderScene* result = cobj->getRenderScene(); + ok &= nativevalue_to_se(result, s.rval(), nullptr /*ctx*/); + SE_PRECONDITION2(ok, false, "js_scene_Scene_getRenderScene : Error processing arguments"); + SE_HOLD_RETURN_VALUE(result, s.thisObject(), s.rval()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 0); + return false; +} +SE_BIND_FUNC(js_scene_Scene_getRenderScene) + +static bool js_scene_Scene_getSceneGlobals(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_scene_Scene_getSceneGlobals : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 0) { + cc::SceneGlobals* result = cobj->getSceneGlobals(); + ok &= nativevalue_to_se(result, s.rval(), nullptr /*ctx*/); + SE_PRECONDITION2(ok, false, "js_scene_Scene_getSceneGlobals : Error processing arguments"); + SE_HOLD_RETURN_VALUE(result, s.thisObject(), s.rval()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 0); + return false; +} +SE_BIND_FUNC(js_scene_Scene_getSceneGlobals) + +static bool js_scene_Scene_isAutoReleaseAssets(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_scene_Scene_isAutoReleaseAssets : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 0) { + bool result = cobj->isAutoReleaseAssets(); + ok &= nativevalue_to_se(result, s.rval(), nullptr /*ctx*/); + SE_PRECONDITION2(ok, false, "js_scene_Scene_isAutoReleaseAssets : Error processing arguments"); + SE_HOLD_RETURN_VALUE(result, s.thisObject(), s.rval()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 0); + return false; +} +SE_BIND_FUNC_AS_PROP_GET(js_scene_Scene_isAutoReleaseAssets) + +static bool js_scene_Scene_load(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_scene_Scene_load : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + if (argc == 0) { + cobj->load(); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 0); + return false; +} +SE_BIND_FUNC(js_scene_Scene_load) + +static bool js_scene_Scene_onBatchCreated(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_scene_Scene_onBatchCreated : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 1) { + HolderType arg0 = {}; + ok &= sevalue_to_native(args[0], &arg0, s.thisObject()); + SE_PRECONDITION2(ok, false, "js_scene_Scene_onBatchCreated : Error processing arguments"); + cobj->onBatchCreated(arg0.value()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 1); + return false; +} +SE_BIND_FUNC(js_scene_Scene_onBatchCreated) + +static bool js_scene_Scene_setAutoReleaseAssets(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_scene_Scene_setAutoReleaseAssets : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 1) { + HolderType arg0 = {}; + ok &= sevalue_to_native(args[0], &arg0, s.thisObject()); + SE_PRECONDITION2(ok, false, "js_scene_Scene_setAutoReleaseAssets : Error processing arguments"); + cobj->setAutoReleaseAssets(arg0.value()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 1); + return false; +} +SE_BIND_FUNC_AS_PROP_SET(js_scene_Scene_setAutoReleaseAssets) + +static bool js_scene_Scene_setSceneGlobals(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_scene_Scene_setSceneGlobals : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 1) { + HolderType arg0 = {}; + ok &= sevalue_to_native(args[0], &arg0, s.thisObject()); + SE_PRECONDITION2(ok, false, "js_scene_Scene_setSceneGlobals : Error processing arguments"); + cobj->setSceneGlobals(arg0.value()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 1); + return false; +} +SE_BIND_FUNC(js_scene_Scene_setSceneGlobals) + +SE_DECLARE_FINALIZE_FUNC(js_cc_Scene_finalize) + +static bool js_scene_Scene_constructor(se::State& s) // NOLINT(readability-identifier-naming) constructor_overloaded.c +{ + CC_UNUSED bool ok = true; + const auto& args = s.args(); + size_t argc = args.size(); + do { + if (argc == 0) { + auto *ptr = JSB_MAKE_PRIVATE_OBJECT(cc::Scene); + s.thisObject()->setPrivateObject(ptr); + return true; + } + } while(false); + do { + if (argc == 1) { + HolderType arg0 = {}; + ok &= sevalue_to_native(args[0], &arg0, s.thisObject()); + if (!ok) { ok = true; break; } + auto *ptr = JSB_MAKE_PRIVATE_OBJECT(cc::Scene, arg0.value()); + s.thisObject()->setPrivateObject(ptr); + return true; + } + } while(false); + SE_REPORT_ERROR("wrong number of arguments: %d", (int)argc); + return false; +} +SE_BIND_CTOR(js_scene_Scene_constructor, __jsb_cc_Scene_class, js_cc_Scene_finalize) + +static bool js_cc_Scene_finalize(se::State& s) // NOLINT(readability-identifier-naming) +{ + return true; +} +SE_BIND_FINALIZE_FUNC(js_cc_Scene_finalize) + +bool js_register_scene_Scene(se::Object* obj) // NOLINT(readability-identifier-naming) +{ + auto* cls = se::Class::create("Scene", obj, __jsb_cc_Node_proto, _SE(js_scene_Scene_constructor)); + + cls->defineProperty("autoReleaseAssets", _SE(js_scene_Scene_isAutoReleaseAssets_asGetter), _SE(js_scene_Scene_setAutoReleaseAssets_asSetter)); + cls->defineFunction("_activate", _SE(js_scene_Scene_activate)); + cls->defineFunction("getRenderScene", _SE(js_scene_Scene_getRenderScene)); + cls->defineFunction("getSceneGlobals", _SE(js_scene_Scene_getSceneGlobals)); + cls->defineFunction("_load", _SE(js_scene_Scene_load)); + cls->defineFunction("onBatchCreated", _SE(js_scene_Scene_onBatchCreated)); + cls->defineFunction("setSceneGlobals", _SE(js_scene_Scene_setSceneGlobals)); + cls->defineFinalizeFunction(_SE(js_cc_Scene_finalize)); + cls->install(); + JSBClassType::registerClass(cls); + + __jsb_cc_Scene_proto = cls->getProto(); + __jsb_cc_Scene_class = cls; + + + se::ScriptEngine::getInstance()->clearException(); + return true; +} +se::Object* __jsb_cc_scene_Light_proto = nullptr; // NOLINT +se::Class* __jsb_cc_scene_Light_class = nullptr; // NOLINT + +static bool js_scene_Light_attachToScene(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_scene_Light_attachToScene : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 1) { + HolderType arg0 = {}; + ok &= sevalue_to_native(args[0], &arg0, s.thisObject()); + SE_PRECONDITION2(ok, false, "js_scene_Light_attachToScene : Error processing arguments"); + cobj->attachToScene(arg0.value()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 1); + return false; +} +SE_BIND_FUNC(js_scene_Light_attachToScene) + +static bool js_scene_Light_destroy(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_scene_Light_destroy : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + if (argc == 0) { + cobj->destroy(); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 0); + return false; +} +SE_BIND_FUNC(js_scene_Light_destroy) + +static bool js_scene_Light_detachFromScene(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_scene_Light_detachFromScene : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + if (argc == 0) { + cobj->detachFromScene(); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 0); + return false; +} +SE_BIND_FUNC(js_scene_Light_detachFromScene) + +static bool js_scene_Light_getColor(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_scene_Light_getColor : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 0) { + const cc::Vec3& result = cobj->getColor(); + ok &= nativevalue_to_se(result, s.rval(), nullptr /*ctx*/); + SE_PRECONDITION2(ok, false, "js_scene_Light_getColor : Error processing arguments"); + SE_HOLD_RETURN_VALUE(result, s.thisObject(), s.rval()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 0); + return false; +} +SE_BIND_FUNC_AS_PROP_GET(js_scene_Light_getColor) + +static bool js_scene_Light_getColorTemperature(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_scene_Light_getColorTemperature : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 0) { + float result = cobj->getColorTemperature(); + ok &= nativevalue_to_se(result, s.rval(), nullptr /*ctx*/); + SE_PRECONDITION2(ok, false, "js_scene_Light_getColorTemperature : Error processing arguments"); + SE_HOLD_RETURN_VALUE(result, s.thisObject(), s.rval()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 0); + return false; +} +SE_BIND_FUNC_AS_PROP_GET(js_scene_Light_getColorTemperature) + +static bool js_scene_Light_getColorTemperatureRGB(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_scene_Light_getColorTemperatureRGB : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 0) { + const cc::Vec3& result = cobj->getColorTemperatureRGB(); + ok &= nativevalue_to_se(result, s.rval(), nullptr /*ctx*/); + SE_PRECONDITION2(ok, false, "js_scene_Light_getColorTemperatureRGB : Error processing arguments"); + SE_HOLD_RETURN_VALUE(result, s.thisObject(), s.rval()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 0); + return false; +} +SE_BIND_FUNC_AS_PROP_GET(js_scene_Light_getColorTemperatureRGB) + +static bool js_scene_Light_getName(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_scene_Light_getName : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 0) { + const std::string& result = cobj->getName(); + ok &= nativevalue_to_se(result, s.rval(), nullptr /*ctx*/); + SE_PRECONDITION2(ok, false, "js_scene_Light_getName : Error processing arguments"); + SE_HOLD_RETURN_VALUE(result, s.thisObject(), s.rval()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 0); + return false; +} +SE_BIND_FUNC_AS_PROP_GET(js_scene_Light_getName) + +static bool js_scene_Light_getNode(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_scene_Light_getNode : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 0) { + cc::Node* result = cobj->getNode(); + ok &= nativevalue_to_se(result, s.rval(), nullptr /*ctx*/); + SE_PRECONDITION2(ok, false, "js_scene_Light_getNode : Error processing arguments"); + SE_HOLD_RETURN_VALUE(result, s.thisObject(), s.rval()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 0); + return false; +} +SE_BIND_FUNC_AS_PROP_GET(js_scene_Light_getNode) + +static bool js_scene_Light_getScene(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_scene_Light_getScene : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 0) { + cc::scene::RenderScene* result = cobj->getScene(); + ok &= nativevalue_to_se(result, s.rval(), nullptr /*ctx*/); + SE_PRECONDITION2(ok, false, "js_scene_Light_getScene : Error processing arguments"); + SE_HOLD_RETURN_VALUE(result, s.thisObject(), s.rval()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 0); + return false; +} +SE_BIND_FUNC_AS_PROP_GET(js_scene_Light_getScene) + +static bool js_scene_Light_getType(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_scene_Light_getType : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 0) { + auto result = static_cast(cobj->getType()); + ok &= nativevalue_to_se(result, s.rval(), nullptr /*ctx*/); + SE_PRECONDITION2(ok, false, "js_scene_Light_getType : Error processing arguments"); + SE_HOLD_RETURN_VALUE(result, s.thisObject(), s.rval()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 0); + return false; +} +SE_BIND_FUNC_AS_PROP_GET(js_scene_Light_getType) + +static bool js_scene_Light_initialize(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_scene_Light_initialize : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + if (argc == 0) { + cobj->initialize(); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 0); + return false; +} +SE_BIND_FUNC(js_scene_Light_initialize) + +static bool js_scene_Light_isBaked(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_scene_Light_isBaked : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 0) { + bool result = cobj->isBaked(); + ok &= nativevalue_to_se(result, s.rval(), nullptr /*ctx*/); + SE_PRECONDITION2(ok, false, "js_scene_Light_isBaked : Error processing arguments"); + SE_HOLD_RETURN_VALUE(result, s.thisObject(), s.rval()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 0); + return false; +} +SE_BIND_FUNC_AS_PROP_GET(js_scene_Light_isBaked) + +static bool js_scene_Light_isUseColorTemperature(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_scene_Light_isUseColorTemperature : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 0) { + bool result = cobj->isUseColorTemperature(); + ok &= nativevalue_to_se(result, s.rval(), nullptr /*ctx*/); + SE_PRECONDITION2(ok, false, "js_scene_Light_isUseColorTemperature : Error processing arguments"); + SE_HOLD_RETURN_VALUE(result, s.thisObject(), s.rval()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 0); + return false; +} +SE_BIND_FUNC_AS_PROP_GET(js_scene_Light_isUseColorTemperature) static bool js_scene_Light_setBaked(se::State& s) // NOLINT(readability-identifier-naming) { @@ -259,7 +2576,7 @@ static bool js_scene_Light_setBaked(se::State& s) // NOLINT(readability-identifi SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 1); return false; } -SE_BIND_FUNC(js_scene_Light_setBaked) +SE_BIND_FUNC_AS_PROP_SET(js_scene_Light_setBaked) static bool js_scene_Light_setColor(se::State& s) // NOLINT(readability-identifier-naming) { @@ -278,7 +2595,26 @@ static bool js_scene_Light_setColor(se::State& s) // NOLINT(readability-identifi SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 1); return false; } -SE_BIND_FUNC(js_scene_Light_setColor) +SE_BIND_FUNC_AS_PROP_SET(js_scene_Light_setColor) + +static bool js_scene_Light_setColorTemperature(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_scene_Light_setColorTemperature : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 1) { + HolderType arg0 = {}; + ok &= sevalue_to_native(args[0], &arg0, s.thisObject()); + SE_PRECONDITION2(ok, false, "js_scene_Light_setColorTemperature : Error processing arguments"); + cobj->setColorTemperature(arg0.value()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 1); + return false; +} +SE_BIND_FUNC_AS_PROP_SET(js_scene_Light_setColorTemperature) static bool js_scene_Light_setColorTemperatureRGB(se::State& s) // NOLINT(readability-identifier-naming) { @@ -297,7 +2633,26 @@ static bool js_scene_Light_setColorTemperatureRGB(se::State& s) // NOLINT(readab SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 1); return false; } -SE_BIND_FUNC(js_scene_Light_setColorTemperatureRGB) +SE_BIND_FUNC_AS_PROP_SET(js_scene_Light_setColorTemperatureRGB) + +static bool js_scene_Light_setName(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_scene_Light_setName : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 1) { + HolderType arg0 = {}; + ok &= sevalue_to_native(args[0], &arg0, s.thisObject()); + SE_PRECONDITION2(ok, false, "js_scene_Light_setName : Error processing arguments"); + cobj->setName(arg0.value()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 1); + return false; +} +SE_BIND_FUNC_AS_PROP_SET(js_scene_Light_setName) static bool js_scene_Light_setNode(se::State& s) // NOLINT(readability-identifier-naming) { @@ -307,7 +2662,7 @@ static bool js_scene_Light_setNode(se::State& s) // NOLINT(readability-identifie size_t argc = args.size(); CC_UNUSED bool ok = true; if (argc == 1) { - HolderType arg0 = {}; + HolderType arg0 = {}; ok &= sevalue_to_native(args[0], &arg0, s.thisObject()); SE_PRECONDITION2(ok, false, "js_scene_Light_setNode : Error processing arguments"); cobj->setNode(arg0.value()); @@ -316,7 +2671,7 @@ static bool js_scene_Light_setNode(se::State& s) // NOLINT(readability-identifie SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 1); return false; } -SE_BIND_FUNC(js_scene_Light_setNode) +SE_BIND_FUNC_AS_PROP_SET(js_scene_Light_setNode) static bool js_scene_Light_setType(se::State& s) // NOLINT(readability-identifier-naming) { @@ -335,7 +2690,7 @@ static bool js_scene_Light_setType(se::State& s) // NOLINT(readability-identifie SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 1); return false; } -SE_BIND_FUNC(js_scene_Light_setType) +SE_BIND_FUNC_AS_PROP_SET(js_scene_Light_setType) static bool js_scene_Light_setUseColorTemperature(se::State& s) // NOLINT(readability-identifier-naming) { @@ -354,7 +2709,7 @@ static bool js_scene_Light_setUseColorTemperature(se::State& s) // NOLINT(readab SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 1); return false; } -SE_BIND_FUNC(js_scene_Light_setUseColorTemperature) +SE_BIND_FUNC_AS_PROP_SET(js_scene_Light_setUseColorTemperature) static bool js_scene_Light_update(se::State& s) // NOLINT(readability-identifier-naming) { @@ -371,188 +2726,2147 @@ static bool js_scene_Light_update(se::State& s) // NOLINT(readability-identifier } SE_BIND_FUNC(js_scene_Light_update) +static bool js_scene_Light_nt2lm_static(se::State& s) // NOLINT(readability-identifier-naming) +{ + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 1) { + HolderType arg0 = {}; + ok &= sevalue_to_native(args[0], &arg0, nullptr); + SE_PRECONDITION2(ok, false, "js_scene_Light_nt2lm_static : Error processing arguments"); + float result = cc::scene::Light::nt2lm(arg0.value()); + ok &= nativevalue_to_se(result, s.rval(), nullptr /*ctx*/); + SE_PRECONDITION2(ok, false, "js_scene_Light_nt2lm_static : Error processing arguments"); + SE_HOLD_RETURN_VALUE(result, s.thisObject(), s.rval()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 1); + return false; +} +SE_BIND_FUNC(js_scene_Light_nt2lm_static) +SE_DECLARE_FINALIZE_FUNC(js_cc_scene_Light_finalize) + +static bool js_scene_Light_constructor(se::State& s) // NOLINT(readability-identifier-naming) constructor.c +{ + auto *ptr = JSB_MAKE_PRIVATE_OBJECT(cc::scene::Light); + s.thisObject()->setPrivateObject(ptr); + return true; +} +SE_BIND_CTOR(js_scene_Light_constructor, __jsb_cc_scene_Light_class, js_cc_scene_Light_finalize) + +static bool js_cc_scene_Light_finalize(se::State& s) // NOLINT(readability-identifier-naming) +{ + return true; +} +SE_BIND_FINALIZE_FUNC(js_cc_scene_Light_finalize) bool js_register_scene_Light(se::Object* obj) // NOLINT(readability-identifier-naming) { - auto* cls = se::Class::create("Light", obj, nullptr, nullptr); + auto* cls = se::Class::create("Light", obj, nullptr, _SE(js_scene_Light_constructor)); - cls->defineFunction("getBaked", _SE(js_scene_Light_getBaked)); - cls->defineFunction("setBaked", _SE(js_scene_Light_setBaked)); - cls->defineFunction("setColor", _SE(js_scene_Light_setColor)); - cls->defineFunction("setColorTemperatureRGB", _SE(js_scene_Light_setColorTemperatureRGB)); - cls->defineFunction("setNode", _SE(js_scene_Light_setNode)); - cls->defineFunction("setType", _SE(js_scene_Light_setType)); - cls->defineFunction("setUseColorTemperature", _SE(js_scene_Light_setUseColorTemperature)); + cls->defineProperty("node", _SE(js_scene_Light_getNode_asGetter), _SE(js_scene_Light_setNode_asSetter)); + cls->defineProperty("name", _SE(js_scene_Light_getName_asGetter), _SE(js_scene_Light_setName_asSetter)); + cls->defineProperty("color", _SE(js_scene_Light_getColor_asGetter), _SE(js_scene_Light_setColor_asSetter)); + cls->defineProperty("type", _SE(js_scene_Light_getType_asGetter), _SE(js_scene_Light_setType_asSetter)); + cls->defineProperty("colorTemperatureRGB", _SE(js_scene_Light_getColorTemperatureRGB_asGetter), _SE(js_scene_Light_setColorTemperatureRGB_asSetter)); + cls->defineProperty("scene", _SE(js_scene_Light_getScene_asGetter), nullptr); + cls->defineProperty("colorTemperature", _SE(js_scene_Light_getColorTemperature_asGetter), _SE(js_scene_Light_setColorTemperature_asSetter)); + cls->defineProperty("useColorTemperature", _SE(js_scene_Light_isUseColorTemperature_asGetter), _SE(js_scene_Light_setUseColorTemperature_asSetter)); + cls->defineProperty("baked", _SE(js_scene_Light_isBaked_asGetter), _SE(js_scene_Light_setBaked_asSetter)); + cls->defineFunction("attachToScene", _SE(js_scene_Light_attachToScene)); + cls->defineFunction("destroy", _SE(js_scene_Light_destroy)); + cls->defineFunction("detachFromScene", _SE(js_scene_Light_detachFromScene)); + cls->defineFunction("initialize", _SE(js_scene_Light_initialize)); cls->defineFunction("update", _SE(js_scene_Light_update)); + cls->defineStaticFunction("nt2lm", _SE(js_scene_Light_nt2lm_static)); + cls->defineFinalizeFunction(_SE(js_cc_scene_Light_finalize)); cls->install(); JSBClassType::registerClass(cls); __jsb_cc_scene_Light_proto = cls->getProto(); __jsb_cc_scene_Light_class = cls; - se::ScriptEngine::getInstance()->clearException(); - return true; -} -se::Object* __jsb_cc_scene_DirectionalLight_proto = nullptr; -se::Class* __jsb_cc_scene_DirectionalLight_class = nullptr; - -static bool js_scene_DirectionalLight_setDirection(se::State& s) // NOLINT(readability-identifier-naming) -{ - auto* cobj = SE_THIS_OBJECT(s); - SE_PRECONDITION2(cobj, false, "js_scene_DirectionalLight_setDirection : Invalid Native Object"); - const auto& args = s.args(); - size_t argc = args.size(); - CC_UNUSED bool ok = true; - if (argc == 1) { - HolderType arg0 = {}; - ok &= sevalue_to_native(args[0], &arg0, s.thisObject()); - SE_PRECONDITION2(ok, false, "js_scene_DirectionalLight_setDirection : Error processing arguments"); - cobj->setDirection(arg0.value()); - return true; - } - SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 1); - return false; -} -SE_BIND_FUNC(js_scene_DirectionalLight_setDirection) - -static bool js_scene_DirectionalLight_setIlluminanceHDR(se::State& s) // NOLINT(readability-identifier-naming) -{ - auto* cobj = SE_THIS_OBJECT(s); - SE_PRECONDITION2(cobj, false, "js_scene_DirectionalLight_setIlluminanceHDR : Invalid Native Object"); - const auto& args = s.args(); - size_t argc = args.size(); - CC_UNUSED bool ok = true; - if (argc == 1) { - HolderType arg0 = {}; - ok &= sevalue_to_native(args[0], &arg0, s.thisObject()); - SE_PRECONDITION2(ok, false, "js_scene_DirectionalLight_setIlluminanceHDR : Error processing arguments"); - cobj->setIlluminanceHDR(arg0.value()); - return true; - } - SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 1); - return false; -} -SE_BIND_FUNC(js_scene_DirectionalLight_setIlluminanceHDR) - -static bool js_scene_DirectionalLight_setIlluminanceLDR(se::State& s) // NOLINT(readability-identifier-naming) -{ - auto* cobj = SE_THIS_OBJECT(s); - SE_PRECONDITION2(cobj, false, "js_scene_DirectionalLight_setIlluminanceLDR : Invalid Native Object"); - const auto& args = s.args(); - size_t argc = args.size(); - CC_UNUSED bool ok = true; - if (argc == 1) { - HolderType arg0 = {}; - ok &= sevalue_to_native(args[0], &arg0, s.thisObject()); - SE_PRECONDITION2(ok, false, "js_scene_DirectionalLight_setIlluminanceLDR : Error processing arguments"); - cobj->setIlluminanceLDR(arg0.value()); - return true; - } - SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 1); - return false; -} -SE_BIND_FUNC(js_scene_DirectionalLight_setIlluminanceLDR) - -SE_DECLARE_FINALIZE_FUNC(js_cc_scene_DirectionalLight_finalize) - -static bool js_scene_DirectionalLight_constructor(se::State& s) // NOLINT(readability-identifier-naming) constructor.c -{ - cc::scene::DirectionalLight* cobj = JSB_ALLOC(cc::scene::DirectionalLight); - s.thisObject()->setPrivateData(cobj); - se::NonRefNativePtrCreatedByCtorMap::emplace(cobj); - return true; -} -SE_BIND_CTOR(js_scene_DirectionalLight_constructor, __jsb_cc_scene_DirectionalLight_class, js_cc_scene_DirectionalLight_finalize) - - - -static bool js_cc_scene_DirectionalLight_finalize(se::State& s) // NOLINT(readability-identifier-naming) -{ - auto iter = se::NonRefNativePtrCreatedByCtorMap::find(SE_THIS_OBJECT(s)); - if (iter != se::NonRefNativePtrCreatedByCtorMap::end()) - { - se::NonRefNativePtrCreatedByCtorMap::erase(iter); - auto* cobj = SE_THIS_OBJECT(s); - JSB_FREE(cobj); - } - return true; -} -SE_BIND_FINALIZE_FUNC(js_cc_scene_DirectionalLight_finalize) - -bool js_register_scene_DirectionalLight(se::Object* obj) // NOLINT(readability-identifier-naming) -{ - auto* cls = se::Class::create("DirectionalLight", obj, __jsb_cc_scene_Light_proto, _SE(js_scene_DirectionalLight_constructor)); - - cls->defineFunction("setDirection", _SE(js_scene_DirectionalLight_setDirection)); - cls->defineFunction("setIlluminanceHDR", _SE(js_scene_DirectionalLight_setIlluminanceHDR)); - cls->defineFunction("setIlluminanceLDR", _SE(js_scene_DirectionalLight_setIlluminanceLDR)); - cls->defineFinalizeFunction(_SE(js_cc_scene_DirectionalLight_finalize)); - cls->install(); - JSBClassType::registerClass(cls); - - __jsb_cc_scene_DirectionalLight_proto = cls->getProto(); - __jsb_cc_scene_DirectionalLight_class = cls; se::ScriptEngine::getInstance()->clearException(); return true; } -se::Object* __jsb_cc_scene_Plane_proto = nullptr; -se::Class* __jsb_cc_scene_Plane_class = nullptr; +se::Object* __jsb_cc_scene_Fog_proto = nullptr; // NOLINT +se::Class* __jsb_cc_scene_Fog_class = nullptr; // NOLINT -static bool js_scene_Plane_clone(se::State& s) // NOLINT(readability-identifier-naming) +static bool js_scene_Fog_activate(se::State& s) // NOLINT(readability-identifier-naming) { - auto* cobj = SE_THIS_OBJECT(s); - SE_PRECONDITION2(cobj, false, "js_scene_Plane_clone : Invalid Native Object"); + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_scene_Fog_activate : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + if (argc == 0) { + cobj->activate(); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 0); + return false; +} +SE_BIND_FUNC(js_scene_Fog_activate) + +static bool js_scene_Fog_getColorArray(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_scene_Fog_getColorArray : Invalid Native Object"); const auto& args = s.args(); size_t argc = args.size(); CC_UNUSED bool ok = true; if (argc == 0) { - cc::scene::Plane result = cobj->clone(); + const cc::Vec4& result = cobj->getColorArray(); ok &= nativevalue_to_se(result, s.rval(), nullptr /*ctx*/); - SE_PRECONDITION2(ok, false, "js_scene_Plane_clone : Error processing arguments"); + SE_PRECONDITION2(ok, false, "js_scene_Fog_getColorArray : Error processing arguments"); SE_HOLD_RETURN_VALUE(result, s.thisObject(), s.rval()); return true; } SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 0); return false; } -SE_BIND_FUNC(js_scene_Plane_clone) +SE_BIND_FUNC_AS_PROP_GET(js_scene_Fog_getColorArray) -static bool js_scene_Plane_define(se::State& s) // NOLINT(readability-identifier-naming) +static bool js_scene_Fog_getFogAtten(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_scene_Fog_getFogAtten : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 0) { + float result = cobj->getFogAtten(); + ok &= nativevalue_to_se(result, s.rval(), nullptr /*ctx*/); + SE_PRECONDITION2(ok, false, "js_scene_Fog_getFogAtten : Error processing arguments"); + SE_HOLD_RETURN_VALUE(result, s.thisObject(), s.rval()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 0); + return false; +} +SE_BIND_FUNC_AS_PROP_GET(js_scene_Fog_getFogAtten) + +static bool js_scene_Fog_getFogColor(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_scene_Fog_getFogColor : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 0) { + const cc::Color& result = cobj->getFogColor(); + ok &= nativevalue_to_se(result, s.rval(), nullptr /*ctx*/); + SE_PRECONDITION2(ok, false, "js_scene_Fog_getFogColor : Error processing arguments"); + SE_HOLD_RETURN_VALUE(result, s.thisObject(), s.rval()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 0); + return false; +} +SE_BIND_FUNC_AS_PROP_GET(js_scene_Fog_getFogColor) + +static bool js_scene_Fog_getFogDensity(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_scene_Fog_getFogDensity : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 0) { + float result = cobj->getFogDensity(); + ok &= nativevalue_to_se(result, s.rval(), nullptr /*ctx*/); + SE_PRECONDITION2(ok, false, "js_scene_Fog_getFogDensity : Error processing arguments"); + SE_HOLD_RETURN_VALUE(result, s.thisObject(), s.rval()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 0); + return false; +} +SE_BIND_FUNC_AS_PROP_GET(js_scene_Fog_getFogDensity) + +static bool js_scene_Fog_getFogEnd(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_scene_Fog_getFogEnd : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 0) { + float result = cobj->getFogEnd(); + ok &= nativevalue_to_se(result, s.rval(), nullptr /*ctx*/); + SE_PRECONDITION2(ok, false, "js_scene_Fog_getFogEnd : Error processing arguments"); + SE_HOLD_RETURN_VALUE(result, s.thisObject(), s.rval()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 0); + return false; +} +SE_BIND_FUNC_AS_PROP_GET(js_scene_Fog_getFogEnd) + +static bool js_scene_Fog_getFogRange(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_scene_Fog_getFogRange : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 0) { + float result = cobj->getFogRange(); + ok &= nativevalue_to_se(result, s.rval(), nullptr /*ctx*/); + SE_PRECONDITION2(ok, false, "js_scene_Fog_getFogRange : Error processing arguments"); + SE_HOLD_RETURN_VALUE(result, s.thisObject(), s.rval()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 0); + return false; +} +SE_BIND_FUNC_AS_PROP_GET(js_scene_Fog_getFogRange) + +static bool js_scene_Fog_getFogStart(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_scene_Fog_getFogStart : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 0) { + float result = cobj->getFogStart(); + ok &= nativevalue_to_se(result, s.rval(), nullptr /*ctx*/); + SE_PRECONDITION2(ok, false, "js_scene_Fog_getFogStart : Error processing arguments"); + SE_HOLD_RETURN_VALUE(result, s.thisObject(), s.rval()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 0); + return false; +} +SE_BIND_FUNC_AS_PROP_GET(js_scene_Fog_getFogStart) + +static bool js_scene_Fog_getFogTop(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_scene_Fog_getFogTop : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 0) { + float result = cobj->getFogTop(); + ok &= nativevalue_to_se(result, s.rval(), nullptr /*ctx*/); + SE_PRECONDITION2(ok, false, "js_scene_Fog_getFogTop : Error processing arguments"); + SE_HOLD_RETURN_VALUE(result, s.thisObject(), s.rval()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 0); + return false; +} +SE_BIND_FUNC_AS_PROP_GET(js_scene_Fog_getFogTop) + +static bool js_scene_Fog_getType(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_scene_Fog_getType : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 0) { + auto result = static_cast(cobj->getType()); + ok &= nativevalue_to_se(result, s.rval(), nullptr /*ctx*/); + SE_PRECONDITION2(ok, false, "js_scene_Fog_getType : Error processing arguments"); + SE_HOLD_RETURN_VALUE(result, s.thisObject(), s.rval()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 0); + return false; +} +SE_BIND_FUNC_AS_PROP_GET(js_scene_Fog_getType) + +static bool js_scene_Fog_initialize(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_scene_Fog_initialize : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 1) { + HolderType arg0 = {}; + ok &= sevalue_to_native(args[0], &arg0, s.thisObject()); + SE_PRECONDITION2(ok, false, "js_scene_Fog_initialize : Error processing arguments"); + cobj->initialize(arg0.value()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 1); + return false; +} +SE_BIND_FUNC(js_scene_Fog_initialize) + +static bool js_scene_Fog_isAccurate(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_scene_Fog_isAccurate : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 0) { + bool result = cobj->isAccurate(); + ok &= nativevalue_to_se(result, s.rval(), nullptr /*ctx*/); + SE_PRECONDITION2(ok, false, "js_scene_Fog_isAccurate : Error processing arguments"); + SE_HOLD_RETURN_VALUE(result, s.thisObject(), s.rval()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 0); + return false; +} +SE_BIND_FUNC(js_scene_Fog_isAccurate) + +static bool js_scene_Fog_isEnabled(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_scene_Fog_isEnabled : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 0) { + bool result = cobj->isEnabled(); + ok &= nativevalue_to_se(result, s.rval(), nullptr /*ctx*/); + SE_PRECONDITION2(ok, false, "js_scene_Fog_isEnabled : Error processing arguments"); + SE_HOLD_RETURN_VALUE(result, s.thisObject(), s.rval()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 0); + return false; +} +SE_BIND_FUNC_AS_PROP_GET(js_scene_Fog_isEnabled) + +static bool js_scene_Fog_setAccurate(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_scene_Fog_setAccurate : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 1) { + HolderType arg0 = {}; + ok &= sevalue_to_native(args[0], &arg0, s.thisObject()); + SE_PRECONDITION2(ok, false, "js_scene_Fog_setAccurate : Error processing arguments"); + cobj->setAccurate(arg0.value()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 1); + return false; +} +SE_BIND_FUNC(js_scene_Fog_setAccurate) + +static bool js_scene_Fog_setEnabled(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_scene_Fog_setEnabled : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 1) { + HolderType arg0 = {}; + ok &= sevalue_to_native(args[0], &arg0, s.thisObject()); + SE_PRECONDITION2(ok, false, "js_scene_Fog_setEnabled : Error processing arguments"); + cobj->setEnabled(arg0.value()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 1); + return false; +} +SE_BIND_FUNC_AS_PROP_SET(js_scene_Fog_setEnabled) + +static bool js_scene_Fog_setFogAtten(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_scene_Fog_setFogAtten : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 1) { + HolderType arg0 = {}; + ok &= sevalue_to_native(args[0], &arg0, s.thisObject()); + SE_PRECONDITION2(ok, false, "js_scene_Fog_setFogAtten : Error processing arguments"); + cobj->setFogAtten(arg0.value()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 1); + return false; +} +SE_BIND_FUNC_AS_PROP_SET(js_scene_Fog_setFogAtten) + +static bool js_scene_Fog_setFogColor(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_scene_Fog_setFogColor : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 1) { + HolderType arg0 = {}; + ok &= sevalue_to_native(args[0], &arg0, s.thisObject()); + SE_PRECONDITION2(ok, false, "js_scene_Fog_setFogColor : Error processing arguments"); + cobj->setFogColor(arg0.value()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 1); + return false; +} +SE_BIND_FUNC_AS_PROP_SET(js_scene_Fog_setFogColor) + +static bool js_scene_Fog_setFogDensity(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_scene_Fog_setFogDensity : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 1) { + HolderType arg0 = {}; + ok &= sevalue_to_native(args[0], &arg0, s.thisObject()); + SE_PRECONDITION2(ok, false, "js_scene_Fog_setFogDensity : Error processing arguments"); + cobj->setFogDensity(arg0.value()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 1); + return false; +} +SE_BIND_FUNC_AS_PROP_SET(js_scene_Fog_setFogDensity) + +static bool js_scene_Fog_setFogEnd(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_scene_Fog_setFogEnd : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 1) { + HolderType arg0 = {}; + ok &= sevalue_to_native(args[0], &arg0, s.thisObject()); + SE_PRECONDITION2(ok, false, "js_scene_Fog_setFogEnd : Error processing arguments"); + cobj->setFogEnd(arg0.value()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 1); + return false; +} +SE_BIND_FUNC_AS_PROP_SET(js_scene_Fog_setFogEnd) + +static bool js_scene_Fog_setFogStart(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_scene_Fog_setFogStart : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 1) { + HolderType arg0 = {}; + ok &= sevalue_to_native(args[0], &arg0, s.thisObject()); + SE_PRECONDITION2(ok, false, "js_scene_Fog_setFogStart : Error processing arguments"); + cobj->setFogStart(arg0.value()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 1); + return false; +} +SE_BIND_FUNC_AS_PROP_SET(js_scene_Fog_setFogStart) + +static bool js_scene_Fog_setFogTop(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_scene_Fog_setFogTop : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 1) { + HolderType arg0 = {}; + ok &= sevalue_to_native(args[0], &arg0, s.thisObject()); + SE_PRECONDITION2(ok, false, "js_scene_Fog_setFogTop : Error processing arguments"); + cobj->setFogTop(arg0.value()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 1); + return false; +} +SE_BIND_FUNC_AS_PROP_SET(js_scene_Fog_setFogTop) + +static bool js_scene_Fog_setType(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_scene_Fog_setType : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 1) { + HolderType arg0 = {}; + ok &= sevalue_to_native(args[0], &arg0, s.thisObject()); + SE_PRECONDITION2(ok, false, "js_scene_Fog_setType : Error processing arguments"); + cobj->setType(arg0.value()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 1); + return false; +} +SE_BIND_FUNC_AS_PROP_SET(js_scene_Fog_setType) + +static bool js_scene_Fog_setfogRange(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_scene_Fog_setfogRange : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 1) { + HolderType arg0 = {}; + ok &= sevalue_to_native(args[0], &arg0, s.thisObject()); + SE_PRECONDITION2(ok, false, "js_scene_Fog_setfogRange : Error processing arguments"); + cobj->setfogRange(arg0.value()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 1); + return false; +} +SE_BIND_FUNC(js_scene_Fog_setfogRange) + +SE_DECLARE_FINALIZE_FUNC(js_cc_scene_Fog_finalize) + +static bool js_scene_Fog_constructor(se::State& s) // NOLINT(readability-identifier-naming) constructor.c +{ + auto *ptr = JSB_MAKE_PRIVATE_OBJECT(cc::scene::Fog); + s.thisObject()->setPrivateObject(ptr); + return true; +} +SE_BIND_CTOR(js_scene_Fog_constructor, __jsb_cc_scene_Fog_class, js_cc_scene_Fog_finalize) + +static bool js_cc_scene_Fog_finalize(se::State& s) // NOLINT(readability-identifier-naming) +{ + return true; +} +SE_BIND_FINALIZE_FUNC(js_cc_scene_Fog_finalize) + +bool js_register_scene_Fog(se::Object* obj) // NOLINT(readability-identifier-naming) +{ + auto* cls = se::Class::create("Fog", obj, nullptr, _SE(js_scene_Fog_constructor)); + + cls->defineProperty("enabled", _SE(js_scene_Fog_isEnabled_asGetter), _SE(js_scene_Fog_setEnabled_asSetter)); + cls->defineProperty("fogStart", _SE(js_scene_Fog_getFogStart_asGetter), _SE(js_scene_Fog_setFogStart_asSetter)); + cls->defineProperty("fogRange", _SE(js_scene_Fog_getFogRange_asGetter), nullptr); + cls->defineProperty("fogEnd", _SE(js_scene_Fog_getFogEnd_asGetter), _SE(js_scene_Fog_setFogEnd_asSetter)); + cls->defineProperty("fogAtten", _SE(js_scene_Fog_getFogAtten_asGetter), _SE(js_scene_Fog_setFogAtten_asSetter)); + cls->defineProperty("fogColor", _SE(js_scene_Fog_getFogColor_asGetter), _SE(js_scene_Fog_setFogColor_asSetter)); + cls->defineProperty("colorArray", _SE(js_scene_Fog_getColorArray_asGetter), nullptr); + cls->defineProperty("fogDensity", _SE(js_scene_Fog_getFogDensity_asGetter), _SE(js_scene_Fog_setFogDensity_asSetter)); + cls->defineProperty("type", _SE(js_scene_Fog_getType_asGetter), _SE(js_scene_Fog_setType_asSetter)); + cls->defineProperty("fogTop", _SE(js_scene_Fog_getFogTop_asGetter), _SE(js_scene_Fog_setFogTop_asSetter)); + cls->defineFunction("activate", _SE(js_scene_Fog_activate)); + cls->defineFunction("initialize", _SE(js_scene_Fog_initialize)); + cls->defineFunction("isAccurate", _SE(js_scene_Fog_isAccurate)); + cls->defineFunction("setAccurate", _SE(js_scene_Fog_setAccurate)); + cls->defineFunction("setfogRange", _SE(js_scene_Fog_setfogRange)); + cls->defineFinalizeFunction(_SE(js_cc_scene_Fog_finalize)); + cls->install(); + JSBClassType::registerClass(cls); + + __jsb_cc_scene_Fog_proto = cls->getProto(); + __jsb_cc_scene_Fog_class = cls; + + + se::ScriptEngine::getInstance()->clearException(); + return true; +} +se::Object* __jsb_cc_scene_FogInfo_proto = nullptr; // NOLINT +se::Class* __jsb_cc_scene_FogInfo_class = nullptr; // NOLINT + +static bool js_scene_FogInfo_activate(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_scene_FogInfo_activate : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 1) { + HolderType arg0 = {}; + ok &= sevalue_to_native(args[0], &arg0, s.thisObject()); + SE_PRECONDITION2(ok, false, "js_scene_FogInfo_activate : Error processing arguments"); + cobj->activate(arg0.value()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 1); + return false; +} +SE_BIND_FUNC(js_scene_FogInfo_activate) + +static bool js_scene_FogInfo_getFogAtten(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_scene_FogInfo_getFogAtten : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 0) { + float result = cobj->getFogAtten(); + ok &= nativevalue_to_se(result, s.rval(), nullptr /*ctx*/); + SE_PRECONDITION2(ok, false, "js_scene_FogInfo_getFogAtten : Error processing arguments"); + SE_HOLD_RETURN_VALUE(result, s.thisObject(), s.rval()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 0); + return false; +} +SE_BIND_FUNC_AS_PROP_GET(js_scene_FogInfo_getFogAtten) + +static bool js_scene_FogInfo_getFogColor(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_scene_FogInfo_getFogColor : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 0) { + const cc::Color& result = cobj->getFogColor(); + ok &= nativevalue_to_se(result, s.rval(), nullptr /*ctx*/); + SE_PRECONDITION2(ok, false, "js_scene_FogInfo_getFogColor : Error processing arguments"); + SE_HOLD_RETURN_VALUE(result, s.thisObject(), s.rval()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 0); + return false; +} +SE_BIND_FUNC_AS_PROP_GET(js_scene_FogInfo_getFogColor) + +static bool js_scene_FogInfo_getFogDensity(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_scene_FogInfo_getFogDensity : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 0) { + float result = cobj->getFogDensity(); + ok &= nativevalue_to_se(result, s.rval(), nullptr /*ctx*/); + SE_PRECONDITION2(ok, false, "js_scene_FogInfo_getFogDensity : Error processing arguments"); + SE_HOLD_RETURN_VALUE(result, s.thisObject(), s.rval()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 0); + return false; +} +SE_BIND_FUNC_AS_PROP_GET(js_scene_FogInfo_getFogDensity) + +static bool js_scene_FogInfo_getFogEnd(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_scene_FogInfo_getFogEnd : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 0) { + float result = cobj->getFogEnd(); + ok &= nativevalue_to_se(result, s.rval(), nullptr /*ctx*/); + SE_PRECONDITION2(ok, false, "js_scene_FogInfo_getFogEnd : Error processing arguments"); + SE_HOLD_RETURN_VALUE(result, s.thisObject(), s.rval()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 0); + return false; +} +SE_BIND_FUNC_AS_PROP_GET(js_scene_FogInfo_getFogEnd) + +static bool js_scene_FogInfo_getFogRange(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_scene_FogInfo_getFogRange : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 0) { + float result = cobj->getFogRange(); + ok &= nativevalue_to_se(result, s.rval(), nullptr /*ctx*/); + SE_PRECONDITION2(ok, false, "js_scene_FogInfo_getFogRange : Error processing arguments"); + SE_HOLD_RETURN_VALUE(result, s.thisObject(), s.rval()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 0); + return false; +} +SE_BIND_FUNC_AS_PROP_GET(js_scene_FogInfo_getFogRange) + +static bool js_scene_FogInfo_getFogStart(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_scene_FogInfo_getFogStart : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 0) { + float result = cobj->getFogStart(); + ok &= nativevalue_to_se(result, s.rval(), nullptr /*ctx*/); + SE_PRECONDITION2(ok, false, "js_scene_FogInfo_getFogStart : Error processing arguments"); + SE_HOLD_RETURN_VALUE(result, s.thisObject(), s.rval()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 0); + return false; +} +SE_BIND_FUNC_AS_PROP_GET(js_scene_FogInfo_getFogStart) + +static bool js_scene_FogInfo_getFogTop(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_scene_FogInfo_getFogTop : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 0) { + float result = cobj->getFogTop(); + ok &= nativevalue_to_se(result, s.rval(), nullptr /*ctx*/); + SE_PRECONDITION2(ok, false, "js_scene_FogInfo_getFogTop : Error processing arguments"); + SE_HOLD_RETURN_VALUE(result, s.thisObject(), s.rval()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 0); + return false; +} +SE_BIND_FUNC_AS_PROP_GET(js_scene_FogInfo_getFogTop) + +static bool js_scene_FogInfo_getType(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_scene_FogInfo_getType : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 0) { + auto result = static_cast(cobj->getType()); + ok &= nativevalue_to_se(result, s.rval(), nullptr /*ctx*/); + SE_PRECONDITION2(ok, false, "js_scene_FogInfo_getType : Error processing arguments"); + SE_HOLD_RETURN_VALUE(result, s.thisObject(), s.rval()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 0); + return false; +} +SE_BIND_FUNC_AS_PROP_GET(js_scene_FogInfo_getType) + +static bool js_scene_FogInfo_isAccurate(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_scene_FogInfo_isAccurate : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 0) { + bool result = cobj->isAccurate(); + ok &= nativevalue_to_se(result, s.rval(), nullptr /*ctx*/); + SE_PRECONDITION2(ok, false, "js_scene_FogInfo_isAccurate : Error processing arguments"); + SE_HOLD_RETURN_VALUE(result, s.thisObject(), s.rval()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 0); + return false; +} +SE_BIND_FUNC(js_scene_FogInfo_isAccurate) + +static bool js_scene_FogInfo_isEnabled(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_scene_FogInfo_isEnabled : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 0) { + bool result = cobj->isEnabled(); + ok &= nativevalue_to_se(result, s.rval(), nullptr /*ctx*/); + SE_PRECONDITION2(ok, false, "js_scene_FogInfo_isEnabled : Error processing arguments"); + SE_HOLD_RETURN_VALUE(result, s.thisObject(), s.rval()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 0); + return false; +} +SE_BIND_FUNC_AS_PROP_GET(js_scene_FogInfo_isEnabled) + +static bool js_scene_FogInfo_setAccurate(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_scene_FogInfo_setAccurate : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 1) { + HolderType arg0 = {}; + ok &= sevalue_to_native(args[0], &arg0, s.thisObject()); + SE_PRECONDITION2(ok, false, "js_scene_FogInfo_setAccurate : Error processing arguments"); + cobj->setAccurate(arg0.value()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 1); + return false; +} +SE_BIND_FUNC(js_scene_FogInfo_setAccurate) + +static bool js_scene_FogInfo_setEnabled(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_scene_FogInfo_setEnabled : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 1) { + HolderType arg0 = {}; + ok &= sevalue_to_native(args[0], &arg0, s.thisObject()); + SE_PRECONDITION2(ok, false, "js_scene_FogInfo_setEnabled : Error processing arguments"); + cobj->setEnabled(arg0.value()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 1); + return false; +} +SE_BIND_FUNC_AS_PROP_SET(js_scene_FogInfo_setEnabled) + +static bool js_scene_FogInfo_setFogAtten(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_scene_FogInfo_setFogAtten : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 1) { + HolderType arg0 = {}; + ok &= sevalue_to_native(args[0], &arg0, s.thisObject()); + SE_PRECONDITION2(ok, false, "js_scene_FogInfo_setFogAtten : Error processing arguments"); + cobj->setFogAtten(arg0.value()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 1); + return false; +} +SE_BIND_FUNC_AS_PROP_SET(js_scene_FogInfo_setFogAtten) + +static bool js_scene_FogInfo_setFogColor(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_scene_FogInfo_setFogColor : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 1) { + HolderType arg0 = {}; + ok &= sevalue_to_native(args[0], &arg0, s.thisObject()); + SE_PRECONDITION2(ok, false, "js_scene_FogInfo_setFogColor : Error processing arguments"); + cobj->setFogColor(arg0.value()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 1); + return false; +} +SE_BIND_FUNC_AS_PROP_SET(js_scene_FogInfo_setFogColor) + +static bool js_scene_FogInfo_setFogDensity(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_scene_FogInfo_setFogDensity : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 1) { + HolderType arg0 = {}; + ok &= sevalue_to_native(args[0], &arg0, s.thisObject()); + SE_PRECONDITION2(ok, false, "js_scene_FogInfo_setFogDensity : Error processing arguments"); + cobj->setFogDensity(arg0.value()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 1); + return false; +} +SE_BIND_FUNC_AS_PROP_SET(js_scene_FogInfo_setFogDensity) + +static bool js_scene_FogInfo_setFogEnd(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_scene_FogInfo_setFogEnd : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 1) { + HolderType arg0 = {}; + ok &= sevalue_to_native(args[0], &arg0, s.thisObject()); + SE_PRECONDITION2(ok, false, "js_scene_FogInfo_setFogEnd : Error processing arguments"); + cobj->setFogEnd(arg0.value()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 1); + return false; +} +SE_BIND_FUNC_AS_PROP_SET(js_scene_FogInfo_setFogEnd) + +static bool js_scene_FogInfo_setFogRange(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_scene_FogInfo_setFogRange : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 1) { + HolderType arg0 = {}; + ok &= sevalue_to_native(args[0], &arg0, s.thisObject()); + SE_PRECONDITION2(ok, false, "js_scene_FogInfo_setFogRange : Error processing arguments"); + cobj->setFogRange(arg0.value()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 1); + return false; +} +SE_BIND_FUNC_AS_PROP_SET(js_scene_FogInfo_setFogRange) + +static bool js_scene_FogInfo_setFogStart(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_scene_FogInfo_setFogStart : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 1) { + HolderType arg0 = {}; + ok &= sevalue_to_native(args[0], &arg0, s.thisObject()); + SE_PRECONDITION2(ok, false, "js_scene_FogInfo_setFogStart : Error processing arguments"); + cobj->setFogStart(arg0.value()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 1); + return false; +} +SE_BIND_FUNC_AS_PROP_SET(js_scene_FogInfo_setFogStart) + +static bool js_scene_FogInfo_setFogTop(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_scene_FogInfo_setFogTop : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 1) { + HolderType arg0 = {}; + ok &= sevalue_to_native(args[0], &arg0, s.thisObject()); + SE_PRECONDITION2(ok, false, "js_scene_FogInfo_setFogTop : Error processing arguments"); + cobj->setFogTop(arg0.value()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 1); + return false; +} +SE_BIND_FUNC_AS_PROP_SET(js_scene_FogInfo_setFogTop) + +static bool js_scene_FogInfo_setType(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_scene_FogInfo_setType : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 1) { + HolderType arg0 = {}; + ok &= sevalue_to_native(args[0], &arg0, s.thisObject()); + SE_PRECONDITION2(ok, false, "js_scene_FogInfo_setType : Error processing arguments"); + cobj->setType(arg0.value()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 1); + return false; +} +SE_BIND_FUNC_AS_PROP_SET(js_scene_FogInfo_setType) + +static bool js_scene_FogInfo_get__type(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_scene_FogInfo_get__type : Invalid Native Object"); + + CC_UNUSED bool ok = true; + se::Value jsret; + ok &= nativevalue_to_se(cobj->_type, jsret, s.thisObject() /*ctx*/); + s.rval() = jsret; + SE_HOLD_RETURN_VALUE(cobj->_type, s.thisObject(), s.rval()); + return true; +} +SE_BIND_PROP_GET(js_scene_FogInfo_get__type) + +static bool js_scene_FogInfo_set__type(se::State& s) // NOLINT(readability-identifier-naming) +{ + const auto& args = s.args(); + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_scene_FogInfo_set__type : Invalid Native Object"); + + CC_UNUSED bool ok = true; + ok &= sevalue_to_native(args[0], &cobj->_type, s.thisObject()); + SE_PRECONDITION2(ok, false, "js_scene_FogInfo_set__type : Error processing new value"); + return true; +} +SE_BIND_PROP_SET(js_scene_FogInfo_set__type) + +static bool js_scene_FogInfo_get__fogColor(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_scene_FogInfo_get__fogColor : Invalid Native Object"); + + CC_UNUSED bool ok = true; + se::Value jsret; + ok &= nativevalue_to_se(cobj->_fogColor, jsret, s.thisObject() /*ctx*/); + s.rval() = jsret; + SE_HOLD_RETURN_VALUE(cobj->_fogColor, s.thisObject(), s.rval()); + return true; +} +SE_BIND_PROP_GET(js_scene_FogInfo_get__fogColor) + +static bool js_scene_FogInfo_set__fogColor(se::State& s) // NOLINT(readability-identifier-naming) +{ + const auto& args = s.args(); + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_scene_FogInfo_set__fogColor : Invalid Native Object"); + + CC_UNUSED bool ok = true; + ok &= sevalue_to_native(args[0], &cobj->_fogColor, s.thisObject()); + SE_PRECONDITION2(ok, false, "js_scene_FogInfo_set__fogColor : Error processing new value"); + return true; +} +SE_BIND_PROP_SET(js_scene_FogInfo_set__fogColor) + +static bool js_scene_FogInfo_get__isEnabled(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_scene_FogInfo_get__isEnabled : Invalid Native Object"); + + CC_UNUSED bool ok = true; + se::Value jsret; + ok &= nativevalue_to_se(cobj->_isEnabled, jsret, s.thisObject() /*ctx*/); + s.rval() = jsret; + SE_HOLD_RETURN_VALUE(cobj->_isEnabled, s.thisObject(), s.rval()); + return true; +} +SE_BIND_PROP_GET(js_scene_FogInfo_get__isEnabled) + +static bool js_scene_FogInfo_set__isEnabled(se::State& s) // NOLINT(readability-identifier-naming) +{ + const auto& args = s.args(); + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_scene_FogInfo_set__isEnabled : Invalid Native Object"); + + CC_UNUSED bool ok = true; + ok &= sevalue_to_native(args[0], &cobj->_isEnabled, s.thisObject()); + SE_PRECONDITION2(ok, false, "js_scene_FogInfo_set__isEnabled : Error processing new value"); + return true; +} +SE_BIND_PROP_SET(js_scene_FogInfo_set__isEnabled) + +static bool js_scene_FogInfo_get__fogDensity(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_scene_FogInfo_get__fogDensity : Invalid Native Object"); + + CC_UNUSED bool ok = true; + se::Value jsret; + ok &= nativevalue_to_se(cobj->_fogDensity, jsret, s.thisObject() /*ctx*/); + s.rval() = jsret; + SE_HOLD_RETURN_VALUE(cobj->_fogDensity, s.thisObject(), s.rval()); + return true; +} +SE_BIND_PROP_GET(js_scene_FogInfo_get__fogDensity) + +static bool js_scene_FogInfo_set__fogDensity(se::State& s) // NOLINT(readability-identifier-naming) +{ + const auto& args = s.args(); + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_scene_FogInfo_set__fogDensity : Invalid Native Object"); + + CC_UNUSED bool ok = true; + ok &= sevalue_to_native(args[0], &cobj->_fogDensity, s.thisObject()); + SE_PRECONDITION2(ok, false, "js_scene_FogInfo_set__fogDensity : Error processing new value"); + return true; +} +SE_BIND_PROP_SET(js_scene_FogInfo_set__fogDensity) + +static bool js_scene_FogInfo_get__fogStart(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_scene_FogInfo_get__fogStart : Invalid Native Object"); + + CC_UNUSED bool ok = true; + se::Value jsret; + ok &= nativevalue_to_se(cobj->_fogStart, jsret, s.thisObject() /*ctx*/); + s.rval() = jsret; + SE_HOLD_RETURN_VALUE(cobj->_fogStart, s.thisObject(), s.rval()); + return true; +} +SE_BIND_PROP_GET(js_scene_FogInfo_get__fogStart) + +static bool js_scene_FogInfo_set__fogStart(se::State& s) // NOLINT(readability-identifier-naming) +{ + const auto& args = s.args(); + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_scene_FogInfo_set__fogStart : Invalid Native Object"); + + CC_UNUSED bool ok = true; + ok &= sevalue_to_native(args[0], &cobj->_fogStart, s.thisObject()); + SE_PRECONDITION2(ok, false, "js_scene_FogInfo_set__fogStart : Error processing new value"); + return true; +} +SE_BIND_PROP_SET(js_scene_FogInfo_set__fogStart) + +static bool js_scene_FogInfo_get__fogEnd(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_scene_FogInfo_get__fogEnd : Invalid Native Object"); + + CC_UNUSED bool ok = true; + se::Value jsret; + ok &= nativevalue_to_se(cobj->_fogEnd, jsret, s.thisObject() /*ctx*/); + s.rval() = jsret; + SE_HOLD_RETURN_VALUE(cobj->_fogEnd, s.thisObject(), s.rval()); + return true; +} +SE_BIND_PROP_GET(js_scene_FogInfo_get__fogEnd) + +static bool js_scene_FogInfo_set__fogEnd(se::State& s) // NOLINT(readability-identifier-naming) +{ + const auto& args = s.args(); + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_scene_FogInfo_set__fogEnd : Invalid Native Object"); + + CC_UNUSED bool ok = true; + ok &= sevalue_to_native(args[0], &cobj->_fogEnd, s.thisObject()); + SE_PRECONDITION2(ok, false, "js_scene_FogInfo_set__fogEnd : Error processing new value"); + return true; +} +SE_BIND_PROP_SET(js_scene_FogInfo_set__fogEnd) + +static bool js_scene_FogInfo_get__fogAtten(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_scene_FogInfo_get__fogAtten : Invalid Native Object"); + + CC_UNUSED bool ok = true; + se::Value jsret; + ok &= nativevalue_to_se(cobj->_fogAtten, jsret, s.thisObject() /*ctx*/); + s.rval() = jsret; + SE_HOLD_RETURN_VALUE(cobj->_fogAtten, s.thisObject(), s.rval()); + return true; +} +SE_BIND_PROP_GET(js_scene_FogInfo_get__fogAtten) + +static bool js_scene_FogInfo_set__fogAtten(se::State& s) // NOLINT(readability-identifier-naming) +{ + const auto& args = s.args(); + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_scene_FogInfo_set__fogAtten : Invalid Native Object"); + + CC_UNUSED bool ok = true; + ok &= sevalue_to_native(args[0], &cobj->_fogAtten, s.thisObject()); + SE_PRECONDITION2(ok, false, "js_scene_FogInfo_set__fogAtten : Error processing new value"); + return true; +} +SE_BIND_PROP_SET(js_scene_FogInfo_set__fogAtten) + +static bool js_scene_FogInfo_get__fogTop(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_scene_FogInfo_get__fogTop : Invalid Native Object"); + + CC_UNUSED bool ok = true; + se::Value jsret; + ok &= nativevalue_to_se(cobj->_fogTop, jsret, s.thisObject() /*ctx*/); + s.rval() = jsret; + SE_HOLD_RETURN_VALUE(cobj->_fogTop, s.thisObject(), s.rval()); + return true; +} +SE_BIND_PROP_GET(js_scene_FogInfo_get__fogTop) + +static bool js_scene_FogInfo_set__fogTop(se::State& s) // NOLINT(readability-identifier-naming) +{ + const auto& args = s.args(); + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_scene_FogInfo_set__fogTop : Invalid Native Object"); + + CC_UNUSED bool ok = true; + ok &= sevalue_to_native(args[0], &cobj->_fogTop, s.thisObject()); + SE_PRECONDITION2(ok, false, "js_scene_FogInfo_set__fogTop : Error processing new value"); + return true; +} +SE_BIND_PROP_SET(js_scene_FogInfo_set__fogTop) + +static bool js_scene_FogInfo_get__fogRange(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_scene_FogInfo_get__fogRange : Invalid Native Object"); + + CC_UNUSED bool ok = true; + se::Value jsret; + ok &= nativevalue_to_se(cobj->_fogRange, jsret, s.thisObject() /*ctx*/); + s.rval() = jsret; + SE_HOLD_RETURN_VALUE(cobj->_fogRange, s.thisObject(), s.rval()); + return true; +} +SE_BIND_PROP_GET(js_scene_FogInfo_get__fogRange) + +static bool js_scene_FogInfo_set__fogRange(se::State& s) // NOLINT(readability-identifier-naming) +{ + const auto& args = s.args(); + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_scene_FogInfo_set__fogRange : Invalid Native Object"); + + CC_UNUSED bool ok = true; + ok &= sevalue_to_native(args[0], &cobj->_fogRange, s.thisObject()); + SE_PRECONDITION2(ok, false, "js_scene_FogInfo_set__fogRange : Error processing new value"); + return true; +} +SE_BIND_PROP_SET(js_scene_FogInfo_set__fogRange) + +SE_DECLARE_FINALIZE_FUNC(js_cc_scene_FogInfo_finalize) + +static bool js_scene_FogInfo_constructor(se::State& s) // NOLINT(readability-identifier-naming) constructor.c +{ + auto *ptr = JSB_MAKE_PRIVATE_OBJECT(cc::scene::FogInfo); + s.thisObject()->setPrivateObject(ptr); + return true; +} +SE_BIND_CTOR(js_scene_FogInfo_constructor, __jsb_cc_scene_FogInfo_class, js_cc_scene_FogInfo_finalize) + +static bool js_cc_scene_FogInfo_finalize(se::State& s) // NOLINT(readability-identifier-naming) +{ + return true; +} +SE_BIND_FINALIZE_FUNC(js_cc_scene_FogInfo_finalize) + +bool js_register_scene_FogInfo(se::Object* obj) // NOLINT(readability-identifier-naming) +{ + auto* cls = se::Class::create("FogInfo", obj, nullptr, _SE(js_scene_FogInfo_constructor)); + + cls->defineProperty("_type", _SE(js_scene_FogInfo_get__type), _SE(js_scene_FogInfo_set__type)); + cls->defineProperty("_fogColor", _SE(js_scene_FogInfo_get__fogColor), _SE(js_scene_FogInfo_set__fogColor)); + cls->defineProperty("_enabled", _SE(js_scene_FogInfo_get__isEnabled), _SE(js_scene_FogInfo_set__isEnabled)); + cls->defineProperty("_fogDensity", _SE(js_scene_FogInfo_get__fogDensity), _SE(js_scene_FogInfo_set__fogDensity)); + cls->defineProperty("_fogStart", _SE(js_scene_FogInfo_get__fogStart), _SE(js_scene_FogInfo_set__fogStart)); + cls->defineProperty("_fogEnd", _SE(js_scene_FogInfo_get__fogEnd), _SE(js_scene_FogInfo_set__fogEnd)); + cls->defineProperty("_fogAtten", _SE(js_scene_FogInfo_get__fogAtten), _SE(js_scene_FogInfo_set__fogAtten)); + cls->defineProperty("_fogTop", _SE(js_scene_FogInfo_get__fogTop), _SE(js_scene_FogInfo_set__fogTop)); + cls->defineProperty("_fogRange", _SE(js_scene_FogInfo_get__fogRange), _SE(js_scene_FogInfo_set__fogRange)); + cls->defineProperty("enable", _SE(js_scene_FogInfo_isEnabled_asGetter), _SE(js_scene_FogInfo_setEnabled_asSetter)); + cls->defineProperty("fogStart", _SE(js_scene_FogInfo_getFogStart_asGetter), _SE(js_scene_FogInfo_setFogStart_asSetter)); + cls->defineProperty("fogRange", _SE(js_scene_FogInfo_getFogRange_asGetter), _SE(js_scene_FogInfo_setFogRange_asSetter)); + cls->defineProperty("fogEnd", _SE(js_scene_FogInfo_getFogEnd_asGetter), _SE(js_scene_FogInfo_setFogEnd_asSetter)); + cls->defineProperty("fogAtten", _SE(js_scene_FogInfo_getFogAtten_asGetter), _SE(js_scene_FogInfo_setFogAtten_asSetter)); + cls->defineProperty("fogColor", _SE(js_scene_FogInfo_getFogColor_asGetter), _SE(js_scene_FogInfo_setFogColor_asSetter)); + cls->defineProperty("fogDensity", _SE(js_scene_FogInfo_getFogDensity_asGetter), _SE(js_scene_FogInfo_setFogDensity_asSetter)); + cls->defineProperty("type", _SE(js_scene_FogInfo_getType_asGetter), _SE(js_scene_FogInfo_setType_asSetter)); + cls->defineProperty("fogTop", _SE(js_scene_FogInfo_getFogTop_asGetter), _SE(js_scene_FogInfo_setFogTop_asSetter)); + cls->defineFunction("activate", _SE(js_scene_FogInfo_activate)); + cls->defineFunction("isAccurate", _SE(js_scene_FogInfo_isAccurate)); + cls->defineFunction("setAccurate", _SE(js_scene_FogInfo_setAccurate)); + cls->defineFinalizeFunction(_SE(js_cc_scene_FogInfo_finalize)); + cls->install(); + JSBClassType::registerClass(cls); + + __jsb_cc_scene_FogInfo_proto = cls->getProto(); + __jsb_cc_scene_FogInfo_class = cls; + + + se::ScriptEngine::getInstance()->clearException(); + return true; +} +se::Object* __jsb_cc_scene_PassDynamicsValue_proto = nullptr; // NOLINT +se::Class* __jsb_cc_scene_PassDynamicsValue_class = nullptr; // NOLINT + +static bool js_scene_PassDynamicsValue_get_dirty(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_scene_PassDynamicsValue_get_dirty : Invalid Native Object"); + + CC_UNUSED bool ok = true; + se::Value jsret; + ok &= nativevalue_to_se(cobj->dirty, jsret, s.thisObject() /*ctx*/); + s.rval() = jsret; + SE_HOLD_RETURN_VALUE(cobj->dirty, s.thisObject(), s.rval()); + return true; +} +SE_BIND_PROP_GET(js_scene_PassDynamicsValue_get_dirty) + +static bool js_scene_PassDynamicsValue_set_dirty(se::State& s) // NOLINT(readability-identifier-naming) +{ + const auto& args = s.args(); + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_scene_PassDynamicsValue_set_dirty : Invalid Native Object"); + + CC_UNUSED bool ok = true; + ok &= sevalue_to_native(args[0], &cobj->dirty, s.thisObject()); + SE_PRECONDITION2(ok, false, "js_scene_PassDynamicsValue_set_dirty : Error processing new value"); + return true; +} +SE_BIND_PROP_SET(js_scene_PassDynamicsValue_set_dirty) + +static bool js_scene_PassDynamicsValue_get_value(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_scene_PassDynamicsValue_get_value : Invalid Native Object"); + + CC_UNUSED bool ok = true; + se::Value jsret; + ok &= nativevalue_to_se(cobj->value, jsret, s.thisObject() /*ctx*/); + s.rval() = jsret; + SE_HOLD_RETURN_VALUE(cobj->value, s.thisObject(), s.rval()); + return true; +} +SE_BIND_PROP_GET(js_scene_PassDynamicsValue_get_value) + +static bool js_scene_PassDynamicsValue_set_value(se::State& s) // NOLINT(readability-identifier-naming) +{ + const auto& args = s.args(); + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_scene_PassDynamicsValue_set_value : Invalid Native Object"); + + CC_UNUSED bool ok = true; + ok &= sevalue_to_native(args[0], &cobj->value, s.thisObject()); + SE_PRECONDITION2(ok, false, "js_scene_PassDynamicsValue_set_value : Error processing new value"); + return true; +} +SE_BIND_PROP_SET(js_scene_PassDynamicsValue_set_value) + + +template<> +bool sevalue_to_native(const se::Value &from, cc::scene::PassDynamicsValue * to, se::Object *ctx) +{ + assert(from.isObject()); + se::Object *json = from.toObject(); + auto* data = reinterpret_cast(json->getPrivateData()); + if (data) { + *to = *data; + return true; + } + se::Value field; + bool ok = true; + json->getProperty("dirty", &field, true); + if(!field.isNullOrUndefined()) { + ok &= sevalue_to_native(field, &(to->dirty), ctx); + } + json->getProperty("value", &field, true); + if(!field.isNullOrUndefined()) { + ok &= sevalue_to_native(field, &(to->value), ctx); + } + return ok; +} + +SE_DECLARE_FINALIZE_FUNC(js_cc_scene_PassDynamicsValue_finalize) + +static bool js_scene_PassDynamicsValue_constructor(se::State& s) // NOLINT(readability-identifier-naming) { CC_UNUSED bool ok = true; - auto* cobj = SE_THIS_OBJECT(s); - SE_PRECONDITION2( cobj, false, "js_scene_Plane_define : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + + if(argc == 0) + { + auto *ptr = JSB_MAKE_PRIVATE_OBJECT(cc::scene::PassDynamicsValue); + s.thisObject()->setPrivateObject(ptr); + return true; + } + + if(argc == 1 && args[0].isObject()) + { + se::Object *json = args[0].toObject(); + se::Value field; + auto *ptr = JSB_MAKE_PRIVATE_OBJECT(cc::scene::PassDynamicsValue); + auto cobj = ptr->get(); + ok &= sevalue_to_native(args[0], cobj, s.thisObject()); + if(!ok) { + delete ptr; + SE_REPORT_ERROR("argument convertion error"); + return false; + } + s.thisObject()->setPrivateObject(ptr); + return true; + } + auto *ptr = JSB_MAKE_PRIVATE_OBJECT(cc::scene::PassDynamicsValue); + auto cobj = ptr->get(); + if (argc > 0 && !args[0].isUndefined()) { + ok &= sevalue_to_native(args[0], &(cobj->dirty), nullptr); + } + if (argc > 1 && !args[1].isUndefined()) { + ok &= sevalue_to_native(args[1], &(cobj->value), nullptr); + } + + if(!ok) { + delete ptr; + SE_REPORT_ERROR("Argument convertion error"); + return false; + } + s.thisObject()->setPrivateObject(ptr); + return true; +} +SE_BIND_CTOR(js_scene_PassDynamicsValue_constructor, __jsb_cc_scene_PassDynamicsValue_class, js_cc_scene_PassDynamicsValue_finalize) + +static bool js_cc_scene_PassDynamicsValue_finalize(se::State& s) // NOLINT(readability-identifier-naming) +{ + return true; +} +SE_BIND_FINALIZE_FUNC(js_cc_scene_PassDynamicsValue_finalize) + +bool js_register_scene_PassDynamicsValue(se::Object* obj) // NOLINT(readability-identifier-naming) +{ + auto* cls = se::Class::create("PassDynamicsValue", obj, nullptr, _SE(js_scene_PassDynamicsValue_constructor)); + + cls->defineProperty("dirty", _SE(js_scene_PassDynamicsValue_get_dirty), _SE(js_scene_PassDynamicsValue_set_dirty)); + cls->defineProperty("value", _SE(js_scene_PassDynamicsValue_get_value), _SE(js_scene_PassDynamicsValue_set_value)); + cls->defineFinalizeFunction(_SE(js_cc_scene_PassDynamicsValue_finalize)); + cls->install(); + JSBClassType::registerClass(cls); + + __jsb_cc_scene_PassDynamicsValue_proto = cls->getProto(); + __jsb_cc_scene_PassDynamicsValue_class = cls; + + + se::ScriptEngine::getInstance()->clearException(); + return true; +} +se::Object* __jsb_cc_scene_Pass_proto = nullptr; // NOLINT +se::Class* __jsb_cc_scene_Pass_class = nullptr; // NOLINT + +static bool js_scene_Pass__setRootBufferDirty(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_scene_Pass__setRootBufferDirty : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 1) { + HolderType arg0 = {}; + ok &= sevalue_to_native(args[0], &arg0, s.thisObject()); + SE_PRECONDITION2(ok, false, "js_scene_Pass__setRootBufferDirty : Error processing arguments"); + cobj->_setRootBufferDirty(arg0.value()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 1); + return false; +} +SE_BIND_FUNC_AS_PROP_SET(js_scene_Pass__setRootBufferDirty) + +static bool js_scene_Pass_beginChangeStatesSilently(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_scene_Pass_beginChangeStatesSilently : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + if (argc == 0) { + cobj->beginChangeStatesSilently(); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 0); + return false; +} +SE_BIND_FUNC(js_scene_Pass_beginChangeStatesSilently) + +static bool js_scene_Pass_bindSampler(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_scene_Pass_bindSampler : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 2) { + HolderType arg0 = {}; + HolderType arg1 = {}; + ok &= sevalue_to_native(args[0], &arg0, s.thisObject()); + ok &= sevalue_to_native(args[1], &arg1, s.thisObject()); + SE_PRECONDITION2(ok, false, "js_scene_Pass_bindSampler : Error processing arguments"); + cobj->bindSampler(arg0.value(), arg1.value()); + return true; + } + if (argc == 3) { + HolderType arg0 = {}; + HolderType arg1 = {}; + HolderType arg2 = {}; + ok &= sevalue_to_native(args[0], &arg0, s.thisObject()); + ok &= sevalue_to_native(args[1], &arg1, s.thisObject()); + ok &= sevalue_to_native(args[2], &arg2, s.thisObject()); + SE_PRECONDITION2(ok, false, "js_scene_Pass_bindSampler : Error processing arguments"); + cobj->bindSampler(arg0.value(), arg1.value(), arg2.value()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 3); + return false; +} +SE_BIND_FUNC(js_scene_Pass_bindSampler) + +static bool js_scene_Pass_bindTexture(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_scene_Pass_bindTexture : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 2) { + HolderType arg0 = {}; + HolderType arg1 = {}; + ok &= sevalue_to_native(args[0], &arg0, s.thisObject()); + ok &= sevalue_to_native(args[1], &arg1, s.thisObject()); + SE_PRECONDITION2(ok, false, "js_scene_Pass_bindTexture : Error processing arguments"); + cobj->bindTexture(arg0.value(), arg1.value()); + return true; + } + if (argc == 3) { + HolderType arg0 = {}; + HolderType arg1 = {}; + HolderType arg2 = {}; + ok &= sevalue_to_native(args[0], &arg0, s.thisObject()); + ok &= sevalue_to_native(args[1], &arg1, s.thisObject()); + ok &= sevalue_to_native(args[2], &arg2, s.thisObject()); + SE_PRECONDITION2(ok, false, "js_scene_Pass_bindTexture : Error processing arguments"); + cobj->bindTexture(arg0.value(), arg1.value(), arg2.value()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 3); + return false; +} +SE_BIND_FUNC(js_scene_Pass_bindTexture) + +static bool js_scene_Pass_destroy(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_scene_Pass_destroy : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + if (argc == 0) { + cobj->destroy(); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 0); + return false; +} +SE_BIND_FUNC(js_scene_Pass_destroy) + +static bool js_scene_Pass_endChangeStatesSilently(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_scene_Pass_endChangeStatesSilently : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + if (argc == 0) { + cobj->endChangeStatesSilently(); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 0); + return false; +} +SE_BIND_FUNC(js_scene_Pass_endChangeStatesSilently) + +static bool js_scene_Pass_getBatchedBuffer(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_scene_Pass_getBatchedBuffer : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 0) { + cc::pipeline::BatchedBuffer* result = cobj->getBatchedBuffer(); + ok &= nativevalue_to_se(result, s.rval(), nullptr /*ctx*/); + SE_PRECONDITION2(ok, false, "js_scene_Pass_getBatchedBuffer : Error processing arguments"); + SE_HOLD_RETURN_VALUE(result, s.thisObject(), s.rval()); + return true; + } + if (argc == 1) { + HolderType arg0 = {}; + ok &= sevalue_to_native(args[0], &arg0, s.thisObject()); + SE_PRECONDITION2(ok, false, "js_scene_Pass_getBatchedBuffer : Error processing arguments"); + cc::pipeline::BatchedBuffer* result = cobj->getBatchedBuffer(arg0.value()); + ok &= nativevalue_to_se(result, s.rval(), nullptr /*ctx*/); + SE_PRECONDITION2(ok, false, "js_scene_Pass_getBatchedBuffer : Error processing arguments"); + SE_HOLD_RETURN_VALUE(result, s.thisObject(), s.rval()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 1); + return false; +} +SE_BIND_FUNC(js_scene_Pass_getBatchedBuffer) + +static bool js_scene_Pass_getBatchingScheme(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_scene_Pass_getBatchingScheme : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 0) { + auto result = static_cast(cobj->getBatchingScheme()); + ok &= nativevalue_to_se(result, s.rval(), nullptr /*ctx*/); + SE_PRECONDITION2(ok, false, "js_scene_Pass_getBatchingScheme : Error processing arguments"); + SE_HOLD_RETURN_VALUE(result, s.thisObject(), s.rval()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 0); + return false; +} +SE_BIND_FUNC_AS_PROP_GET(js_scene_Pass_getBatchingScheme) + +static bool js_scene_Pass_getBinding(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_scene_Pass_getBinding : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 1) { + HolderType arg0 = {}; + ok &= sevalue_to_native(args[0], &arg0, s.thisObject()); + SE_PRECONDITION2(ok, false, "js_scene_Pass_getBinding : Error processing arguments"); + unsigned int result = cobj->getBinding(arg0.value()); + ok &= nativevalue_to_se(result, s.rval(), nullptr /*ctx*/); + SE_PRECONDITION2(ok, false, "js_scene_Pass_getBinding : Error processing arguments"); + SE_HOLD_RETURN_VALUE(result, s.thisObject(), s.rval()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 1); + return false; +} +SE_BIND_FUNC(js_scene_Pass_getBinding) + +static bool js_scene_Pass_getBlendState(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_scene_Pass_getBlendState : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 0) { + const cc::gfx::BlendState* result = cobj->getBlendState(); + ok &= nativevalue_to_se(result, s.rval(), nullptr /*ctx*/); + SE_PRECONDITION2(ok, false, "js_scene_Pass_getBlendState : Error processing arguments"); + SE_HOLD_RETURN_VALUE(result, s.thisObject(), s.rval()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 0); + return false; +} +SE_BIND_FUNC_AS_PROP_GET(js_scene_Pass_getBlendState) + +static bool js_scene_Pass_getDefines(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_scene_Pass_getDefines : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 0) { + const std::unordered_map>& result = cobj->getDefines(); + ok &= nativevalue_to_se(result, s.rval(), nullptr /*ctx*/); + SE_PRECONDITION2(ok, false, "js_scene_Pass_getDefines : Error processing arguments"); + SE_HOLD_RETURN_VALUE(result, s.thisObject(), s.rval()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 0); + return false; +} +SE_BIND_FUNC_AS_PROP_GET(js_scene_Pass_getDefines) + +static bool js_scene_Pass_getDepthStencilState(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_scene_Pass_getDepthStencilState : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 0) { + const cc::gfx::DepthStencilState* result = cobj->getDepthStencilState(); + ok &= nativevalue_to_se(result, s.rval(), nullptr /*ctx*/); + SE_PRECONDITION2(ok, false, "js_scene_Pass_getDepthStencilState : Error processing arguments"); + SE_HOLD_RETURN_VALUE(result, s.thisObject(), s.rval()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 0); + return false; +} +SE_BIND_FUNC_AS_PROP_GET(js_scene_Pass_getDepthStencilState) + +static bool js_scene_Pass_getDescriptorSet(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_scene_Pass_getDescriptorSet : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 0) { + cc::gfx::DescriptorSet* result = cobj->getDescriptorSet(); + ok &= nativevalue_to_se(result, s.rval(), nullptr /*ctx*/); + SE_PRECONDITION2(ok, false, "js_scene_Pass_getDescriptorSet : Error processing arguments"); + SE_HOLD_RETURN_VALUE(result, s.thisObject(), s.rval()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 0); + return false; +} +SE_BIND_FUNC_AS_PROP_GET(js_scene_Pass_getDescriptorSet) + +static bool js_scene_Pass_getDevice(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_scene_Pass_getDevice : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 0) { + cc::gfx::Device* result = cobj->getDevice(); + ok &= nativevalue_to_se(result, s.rval(), nullptr /*ctx*/); + SE_PRECONDITION2(ok, false, "js_scene_Pass_getDevice : Error processing arguments"); + SE_HOLD_RETURN_VALUE(result, s.thisObject(), s.rval()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 0); + return false; +} +SE_BIND_FUNC_AS_PROP_GET(js_scene_Pass_getDevice) + +static bool js_scene_Pass_getDynamicStates(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_scene_Pass_getDynamicStates : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 0) { + auto result = static_cast(cobj->getDynamicStates()); + ok &= nativevalue_to_se(result, s.rval(), nullptr /*ctx*/); + SE_PRECONDITION2(ok, false, "js_scene_Pass_getDynamicStates : Error processing arguments"); + SE_HOLD_RETURN_VALUE(result, s.thisObject(), s.rval()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 0); + return false; +} +SE_BIND_FUNC_AS_PROP_GET(js_scene_Pass_getDynamicStates) + +static bool js_scene_Pass_getDynamics(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_scene_Pass_getDynamics : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 0) { + const std::unordered_map& result = cobj->getDynamics(); + ok &= nativevalue_to_se(result, s.rval(), nullptr /*ctx*/); + SE_PRECONDITION2(ok, false, "js_scene_Pass_getDynamics : Error processing arguments"); + SE_HOLD_RETURN_VALUE(result, s.thisObject(), s.rval()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 0); + return false; +} +SE_BIND_FUNC_AS_PROP_GET(js_scene_Pass_getDynamics) + +static bool js_scene_Pass_getHandle(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_scene_Pass_getHandle : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 1) { + HolderType arg0 = {}; + ok &= sevalue_to_native(args[0], &arg0, s.thisObject()); + SE_PRECONDITION2(ok, false, "js_scene_Pass_getHandle : Error processing arguments"); + unsigned int result = cobj->getHandle(arg0.value()); + ok &= nativevalue_to_se(result, s.rval(), nullptr /*ctx*/); + SE_PRECONDITION2(ok, false, "js_scene_Pass_getHandle : Error processing arguments"); + SE_HOLD_RETURN_VALUE(result, s.thisObject(), s.rval()); + return true; + } + if (argc == 2) { + HolderType arg0 = {}; + HolderType arg1 = {}; + ok &= sevalue_to_native(args[0], &arg0, s.thisObject()); + ok &= sevalue_to_native(args[1], &arg1, s.thisObject()); + SE_PRECONDITION2(ok, false, "js_scene_Pass_getHandle : Error processing arguments"); + unsigned int result = cobj->getHandle(arg0.value(), arg1.value()); + ok &= nativevalue_to_se(result, s.rval(), nullptr /*ctx*/); + SE_PRECONDITION2(ok, false, "js_scene_Pass_getHandle : Error processing arguments"); + SE_HOLD_RETURN_VALUE(result, s.thisObject(), s.rval()); + return true; + } + if (argc == 3) { + HolderType arg0 = {}; + HolderType arg1 = {}; + HolderType arg2 = {}; + ok &= sevalue_to_native(args[0], &arg0, s.thisObject()); + ok &= sevalue_to_native(args[1], &arg1, s.thisObject()); + ok &= sevalue_to_native(args[2], &arg2, s.thisObject()); + SE_PRECONDITION2(ok, false, "js_scene_Pass_getHandle : Error processing arguments"); + unsigned int result = cobj->getHandle(arg0.value(), arg1.value(), arg2.value()); + ok &= nativevalue_to_se(result, s.rval(), nullptr /*ctx*/); + SE_PRECONDITION2(ok, false, "js_scene_Pass_getHandle : Error processing arguments"); + SE_HOLD_RETURN_VALUE(result, s.thisObject(), s.rval()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 3); + return false; +} +SE_BIND_FUNC(js_scene_Pass_getHandle) + +static bool js_scene_Pass_getHash(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_scene_Pass_getHash : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 0) { + uint64_t result = cobj->getHash(); + ok &= nativevalue_to_se(result, s.rval(), nullptr /*ctx*/); + SE_PRECONDITION2(ok, false, "js_scene_Pass_getHash : Error processing arguments"); + SE_HOLD_RETURN_VALUE(result, s.thisObject(), s.rval()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 0); + return false; +} +SE_BIND_FUNC(js_scene_Pass_getHash) + +static bool js_scene_Pass_getHashForJS(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_scene_Pass_getHashForJS : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 0) { + double result = cobj->getHashForJS(); + ok &= nativevalue_to_se(result, s.rval(), nullptr /*ctx*/); + SE_PRECONDITION2(ok, false, "js_scene_Pass_getHashForJS : Error processing arguments"); + SE_HOLD_RETURN_VALUE(result, s.thisObject(), s.rval()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 0); + return false; +} +SE_BIND_FUNC_AS_PROP_GET(js_scene_Pass_getHashForJS) + +static bool js_scene_Pass_getInstancedBuffer(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_scene_Pass_getInstancedBuffer : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 0) { + cc::pipeline::InstancedBuffer* result = cobj->getInstancedBuffer(); + ok &= nativevalue_to_se(result, s.rval(), nullptr /*ctx*/); + SE_PRECONDITION2(ok, false, "js_scene_Pass_getInstancedBuffer : Error processing arguments"); + SE_HOLD_RETURN_VALUE(result, s.thisObject(), s.rval()); + return true; + } + if (argc == 1) { + HolderType arg0 = {}; + ok &= sevalue_to_native(args[0], &arg0, s.thisObject()); + SE_PRECONDITION2(ok, false, "js_scene_Pass_getInstancedBuffer : Error processing arguments"); + cc::pipeline::InstancedBuffer* result = cobj->getInstancedBuffer(arg0.value()); + ok &= nativevalue_to_se(result, s.rval(), nullptr /*ctx*/); + SE_PRECONDITION2(ok, false, "js_scene_Pass_getInstancedBuffer : Error processing arguments"); + SE_HOLD_RETURN_VALUE(result, s.thisObject(), s.rval()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 1); + return false; +} +SE_BIND_FUNC(js_scene_Pass_getInstancedBuffer) + +static bool js_scene_Pass_getLocalSetLayout(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_scene_Pass_getLocalSetLayout : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 0) { + cc::gfx::DescriptorSetLayout* result = cobj->getLocalSetLayout(); + ok &= nativevalue_to_se(result, s.rval(), nullptr /*ctx*/); + SE_PRECONDITION2(ok, false, "js_scene_Pass_getLocalSetLayout : Error processing arguments"); + SE_HOLD_RETURN_VALUE(result, s.thisObject(), s.rval()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 0); + return false; +} +SE_BIND_FUNC_AS_PROP_GET(js_scene_Pass_getLocalSetLayout) + +static bool js_scene_Pass_getPassIndex(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_scene_Pass_getPassIndex : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 0) { + int result = cobj->getPassIndex(); + ok &= nativevalue_to_se(result, s.rval(), nullptr /*ctx*/); + SE_PRECONDITION2(ok, false, "js_scene_Pass_getPassIndex : Error processing arguments"); + SE_HOLD_RETURN_VALUE(result, s.thisObject(), s.rval()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 0); + return false; +} +SE_BIND_FUNC_AS_PROP_GET(js_scene_Pass_getPassIndex) + +static bool js_scene_Pass_getPassInfoFull(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_scene_Pass_getPassInfoFull : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 0) { + cc::IPassInfoFull result = cobj->getPassInfoFull(); + ok &= nativevalue_to_se(result, s.rval(), nullptr /*ctx*/); + SE_PRECONDITION2(ok, false, "js_scene_Pass_getPassInfoFull : Error processing arguments"); + SE_HOLD_RETURN_VALUE(result, s.thisObject(), s.rval()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 0); + return false; +} +SE_BIND_FUNC(js_scene_Pass_getPassInfoFull) + +static bool js_scene_Pass_getPhase(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_scene_Pass_getPhase : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 0) { + unsigned int result = cobj->getPhase(); + ok &= nativevalue_to_se(result, s.rval(), nullptr /*ctx*/); + SE_PRECONDITION2(ok, false, "js_scene_Pass_getPhase : Error processing arguments"); + SE_HOLD_RETURN_VALUE(result, s.thisObject(), s.rval()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 0); + return false; +} +SE_BIND_FUNC_AS_PROP_GET(js_scene_Pass_getPhase) + +static bool js_scene_Pass_getPipelineLayout(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_scene_Pass_getPipelineLayout : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 0) { + cc::gfx::PipelineLayout* result = cobj->getPipelineLayout(); + ok &= nativevalue_to_se(result, s.rval(), nullptr /*ctx*/); + SE_PRECONDITION2(ok, false, "js_scene_Pass_getPipelineLayout : Error processing arguments"); + SE_HOLD_RETURN_VALUE(result, s.thisObject(), s.rval()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 0); + return false; +} +SE_BIND_FUNC_AS_PROP_GET(js_scene_Pass_getPipelineLayout) + +static bool js_scene_Pass_getPrimitive(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_scene_Pass_getPrimitive : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 0) { + auto result = static_cast(cobj->getPrimitive()); + ok &= nativevalue_to_se(result, s.rval(), nullptr /*ctx*/); + SE_PRECONDITION2(ok, false, "js_scene_Pass_getPrimitive : Error processing arguments"); + SE_HOLD_RETURN_VALUE(result, s.thisObject(), s.rval()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 0); + return false; +} +SE_BIND_FUNC_AS_PROP_GET(js_scene_Pass_getPrimitive) + +static bool js_scene_Pass_getPriority(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_scene_Pass_getPriority : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 0) { + auto result = static_cast(cobj->getPriority()); + ok &= nativevalue_to_se(result, s.rval(), nullptr /*ctx*/); + SE_PRECONDITION2(ok, false, "js_scene_Pass_getPriority : Error processing arguments"); + SE_HOLD_RETURN_VALUE(result, s.thisObject(), s.rval()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 0); + return false; +} +SE_BIND_FUNC_AS_PROP_GET(js_scene_Pass_getPriority) + +static bool js_scene_Pass_getProgram(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_scene_Pass_getProgram : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 0) { + const std::string& result = cobj->getProgram(); + ok &= nativevalue_to_se(result, s.rval(), nullptr /*ctx*/); + SE_PRECONDITION2(ok, false, "js_scene_Pass_getProgram : Error processing arguments"); + SE_HOLD_RETURN_VALUE(result, s.thisObject(), s.rval()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 0); + return false; +} +SE_BIND_FUNC_AS_PROP_GET(js_scene_Pass_getProgram) + +static bool js_scene_Pass_getProperties(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_scene_Pass_getProperties : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 0) { + const std::unordered_map& result = cobj->getProperties(); + ok &= nativevalue_to_se(result, s.rval(), nullptr /*ctx*/); + SE_PRECONDITION2(ok, false, "js_scene_Pass_getProperties : Error processing arguments"); + SE_HOLD_RETURN_VALUE(result, s.thisObject(), s.rval()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 0); + return false; +} +SE_BIND_FUNC_AS_PROP_GET(js_scene_Pass_getProperties) + +static bool js_scene_Pass_getPropertyIndex(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_scene_Pass_getPropertyIndex : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 0) { + int result = cobj->getPropertyIndex(); + ok &= nativevalue_to_se(result, s.rval(), nullptr /*ctx*/); + SE_PRECONDITION2(ok, false, "js_scene_Pass_getPropertyIndex : Error processing arguments"); + SE_HOLD_RETURN_VALUE(result, s.thisObject(), s.rval()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 0); + return false; +} +SE_BIND_FUNC_AS_PROP_GET(js_scene_Pass_getPropertyIndex) + +static bool js_scene_Pass_getRasterizerState(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_scene_Pass_getRasterizerState : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 0) { + const cc::gfx::RasterizerState* result = cobj->getRasterizerState(); + ok &= nativevalue_to_se(result, s.rval(), nullptr /*ctx*/); + SE_PRECONDITION2(ok, false, "js_scene_Pass_getRasterizerState : Error processing arguments"); + SE_HOLD_RETURN_VALUE(result, s.thisObject(), s.rval()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 0); + return false; +} +SE_BIND_FUNC_AS_PROP_GET(js_scene_Pass_getRasterizerState) + +static bool js_scene_Pass_getRoot(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_scene_Pass_getRoot : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 0) { + cc::Root* result = cobj->getRoot(); + ok &= nativevalue_to_se(result, s.rval(), nullptr /*ctx*/); + SE_PRECONDITION2(ok, false, "js_scene_Pass_getRoot : Error processing arguments"); + SE_HOLD_RETURN_VALUE(result, s.thisObject(), s.rval()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 0); + return false; +} +SE_BIND_FUNC_AS_PROP_GET(js_scene_Pass_getRoot) + +static bool js_scene_Pass_getRootBlock(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_scene_Pass_getRootBlock : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 0) { + cc::ArrayBuffer* result = cobj->getRootBlock(); + ok &= nativevalue_to_se(result, s.rval(), nullptr /*ctx*/); + SE_PRECONDITION2(ok, false, "js_scene_Pass_getRootBlock : Error processing arguments"); + SE_HOLD_RETURN_VALUE(result, s.thisObject(), s.rval()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 0); + return false; +} +SE_BIND_FUNC(js_scene_Pass_getRootBlock) + +static bool js_scene_Pass_getShaderInfo(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_scene_Pass_getShaderInfo : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 0) { + cc::IProgramInfo* result = cobj->getShaderInfo(); + ok &= nativevalue_to_se(result, s.rval(), nullptr /*ctx*/); + SE_PRECONDITION2(ok, false, "js_scene_Pass_getShaderInfo : Error processing arguments"); + SE_HOLD_RETURN_VALUE(result, s.thisObject(), s.rval()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 0); + return false; +} +SE_BIND_FUNC_AS_PROP_GET(js_scene_Pass_getShaderInfo) + +static bool js_scene_Pass_getShaderVariant(se::State& s) // NOLINT(readability-identifier-naming) +{ + CC_UNUSED bool ok = true; + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2( cobj, false, "js_scene_Pass_getShaderVariant : Invalid Native Object"); const auto& args = s.args(); size_t argc = args.size(); do { - if (argc == 2) { - HolderType arg0 = {}; - HolderType arg1 = {}; + if (argc == 1) { + HolderType, true> arg0 = {}; ok &= sevalue_to_native(args[0], &arg0, s.thisObject()); if (!ok) { ok = true; break; } - ok &= sevalue_to_native(args[1], &arg1, s.thisObject()); - if (!ok) { ok = true; break; } - cobj->define(arg0.value(), arg1.value()); + cc::gfx::Shader* result = cobj->getShaderVariant(arg0.value()); + ok &= nativevalue_to_se(result, s.rval(), s.thisObject() /*ctx*/); + SE_PRECONDITION2(ok, false, "js_scene_Pass_getShaderVariant : Error processing arguments"); + SE_HOLD_RETURN_VALUE(result, s.thisObject(), s.rval()); return true; } } while(false); do { - if (argc == 3) { - HolderType arg0 = {}; - HolderType arg1 = {}; - HolderType arg2 = {}; + if (argc == 0) { - ok &= sevalue_to_native(args[0], &arg0, s.thisObject()); - if (!ok) { ok = true; break; } - ok &= sevalue_to_native(args[1], &arg1, s.thisObject()); - if (!ok) { ok = true; break; } - ok &= sevalue_to_native(args[2], &arg2, s.thisObject()); - if (!ok) { ok = true; break; } - cobj->define(arg0.value(), arg1.value(), arg2.value()); + cc::gfx::Shader* result = cobj->getShaderVariant(); + ok &= nativevalue_to_se(result, s.rval(), s.thisObject() /*ctx*/); + SE_PRECONDITION2(ok, false, "js_scene_Pass_getShaderVariant : Error processing arguments"); + SE_HOLD_RETURN_VALUE(result, s.thisObject(), s.rval()); return true; } } while(false); @@ -560,111 +4874,636 @@ static bool js_scene_Plane_define(se::State& s) // NOLINT(readability-identifier SE_REPORT_ERROR("wrong number of arguments: %d", (int)argc); return false; } -SE_BIND_FUNC(js_scene_Plane_define) +SE_BIND_FUNC(js_scene_Pass_getShaderVariant) -static bool js_scene_Plane_distance(se::State& s) // NOLINT(readability-identifier-naming) +static bool js_scene_Pass_getStage(se::State& s) // NOLINT(readability-identifier-naming) { - auto* cobj = SE_THIS_OBJECT(s); - SE_PRECONDITION2(cobj, false, "js_scene_Plane_distance : Invalid Native Object"); + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_scene_Pass_getStage : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 0) { + auto result = static_cast(cobj->getStage()); + ok &= nativevalue_to_se(result, s.rval(), nullptr /*ctx*/); + SE_PRECONDITION2(ok, false, "js_scene_Pass_getStage : Error processing arguments"); + SE_HOLD_RETURN_VALUE(result, s.thisObject(), s.rval()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 0); + return false; +} +SE_BIND_FUNC_AS_PROP_GET(js_scene_Pass_getStage) + +static bool js_scene_Pass_getUniform(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_scene_Pass_getUniform : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 2) { + HolderType arg0 = {}; + HolderType, true> arg1 = {}; + ok &= sevalue_to_native(args[0], &arg0, s.thisObject()); + ok &= sevalue_to_native(args[1], &arg1, s.thisObject()); + SE_PRECONDITION2(ok, false, "js_scene_Pass_getUniform : Error processing arguments"); + boost::variant2::variant& result = cobj->getUniform(arg0.value(), arg1.value()); + ok &= nativevalue_to_se(result, s.rval(), nullptr /*ctx*/); + SE_PRECONDITION2(ok, false, "js_scene_Pass_getUniform : Error processing arguments"); + SE_HOLD_RETURN_VALUE(result, s.thisObject(), s.rval()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 2); + return false; +} +SE_BIND_FUNC(js_scene_Pass_getUniform) + +static bool js_scene_Pass_initPassFromTarget(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_scene_Pass_initPassFromTarget : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 4) { + HolderType arg0 = {}; + HolderType arg1 = {}; + HolderType arg2 = {}; + HolderType arg3 = {}; + ok &= sevalue_to_native(args[0], &arg0, s.thisObject()); + ok &= sevalue_to_native(args[1], &arg1, s.thisObject()); + ok &= sevalue_to_native(args[2], &arg2, s.thisObject()); + ok &= sevalue_to_native(args[3], &arg3, s.thisObject()); + SE_PRECONDITION2(ok, false, "js_scene_Pass_initPassFromTarget : Error processing arguments"); + cobj->initPassFromTarget(arg0.value(), arg1.value(), arg2.value(), arg3.value()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 4); + return false; +} +SE_BIND_FUNC(js_scene_Pass_initPassFromTarget) + +static bool js_scene_Pass_initialize(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_scene_Pass_initialize : Invalid Native Object"); const auto& args = s.args(); size_t argc = args.size(); CC_UNUSED bool ok = true; if (argc == 1) { - HolderType arg0 = {}; + HolderType arg0 = {}; ok &= sevalue_to_native(args[0], &arg0, s.thisObject()); - SE_PRECONDITION2(ok, false, "js_scene_Plane_distance : Error processing arguments"); - float result = cobj->distance(arg0.value()); + SE_PRECONDITION2(ok, false, "js_scene_Pass_initialize : Error processing arguments"); + cobj->initialize(arg0.value()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 1); + return false; +} +SE_BIND_FUNC(js_scene_Pass_initialize) + +static bool js_scene_Pass_isRootBufferDirty(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_scene_Pass_isRootBufferDirty : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 0) { + bool result = cobj->isRootBufferDirty(); ok &= nativevalue_to_se(result, s.rval(), nullptr /*ctx*/); - SE_PRECONDITION2(ok, false, "js_scene_Plane_distance : Error processing arguments"); + SE_PRECONDITION2(ok, false, "js_scene_Pass_isRootBufferDirty : Error processing arguments"); + SE_HOLD_RETURN_VALUE(result, s.thisObject(), s.rval()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 0); + return false; +} +SE_BIND_FUNC_AS_PROP_GET(js_scene_Pass_isRootBufferDirty) + +static bool js_scene_Pass_overridePipelineStates(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_scene_Pass_overridePipelineStates : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 2) { + HolderType arg0 = {}; + HolderType arg1 = {}; + ok &= sevalue_to_native(args[0], &arg0, s.thisObject()); + ok &= sevalue_to_native(args[1], &arg1, s.thisObject()); + SE_PRECONDITION2(ok, false, "js_scene_Pass_overridePipelineStates : Error processing arguments"); + cobj->overridePipelineStates(arg0.value(), arg1.value()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 2); + return false; +} +SE_BIND_FUNC(js_scene_Pass_overridePipelineStates) + +static bool js_scene_Pass_resetTexture(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_scene_Pass_resetTexture : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 1) { + HolderType arg0 = {}; + ok &= sevalue_to_native(args[0], &arg0, s.thisObject()); + SE_PRECONDITION2(ok, false, "js_scene_Pass_resetTexture : Error processing arguments"); + cobj->resetTexture(arg0.value()); + return true; + } + if (argc == 2) { + HolderType arg0 = {}; + HolderType arg1 = {}; + ok &= sevalue_to_native(args[0], &arg0, s.thisObject()); + ok &= sevalue_to_native(args[1], &arg1, s.thisObject()); + SE_PRECONDITION2(ok, false, "js_scene_Pass_resetTexture : Error processing arguments"); + cobj->resetTexture(arg0.value(), arg1.value()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 2); + return false; +} +SE_BIND_FUNC(js_scene_Pass_resetTexture) + +static bool js_scene_Pass_resetTextures(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_scene_Pass_resetTextures : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + if (argc == 0) { + cobj->resetTextures(); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 0); + return false; +} +SE_BIND_FUNC(js_scene_Pass_resetTextures) + +static bool js_scene_Pass_resetUBOs(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_scene_Pass_resetUBOs : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + if (argc == 0) { + cobj->resetUBOs(); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 0); + return false; +} +SE_BIND_FUNC(js_scene_Pass_resetUBOs) + +static bool js_scene_Pass_resetUniform(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_scene_Pass_resetUniform : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 1) { + HolderType arg0 = {}; + ok &= sevalue_to_native(args[0], &arg0, s.thisObject()); + SE_PRECONDITION2(ok, false, "js_scene_Pass_resetUniform : Error processing arguments"); + cobj->resetUniform(arg0.value()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 1); + return false; +} +SE_BIND_FUNC(js_scene_Pass_resetUniform) + +static bool js_scene_Pass_setDynamicState(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_scene_Pass_setDynamicState : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 2) { + HolderType arg0 = {}; + HolderType arg1 = {}; + ok &= sevalue_to_native(args[0], &arg0, s.thisObject()); + ok &= sevalue_to_native(args[1], &arg1, s.thisObject()); + SE_PRECONDITION2(ok, false, "js_scene_Pass_setDynamicState : Error processing arguments"); + cobj->setDynamicState(arg0.value(), arg1.value()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 2); + return false; +} +SE_BIND_FUNC(js_scene_Pass_setDynamicState) + +static bool js_scene_Pass_setUniform(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_scene_Pass_setUniform : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 2) { + HolderType arg0 = {}; + HolderType, true> arg1 = {}; + ok &= sevalue_to_native(args[0], &arg0, s.thisObject()); + ok &= sevalue_to_native(args[1], &arg1, s.thisObject()); + SE_PRECONDITION2(ok, false, "js_scene_Pass_setUniform : Error processing arguments"); + cobj->setUniform(arg0.value(), arg1.value()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 2); + return false; +} +SE_BIND_FUNC(js_scene_Pass_setUniform) + +static bool js_scene_Pass_setUniformArray(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_scene_Pass_setUniformArray : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 2) { + HolderType arg0 = {}; + HolderType>, true> arg1 = {}; + ok &= sevalue_to_native(args[0], &arg0, s.thisObject()); + ok &= sevalue_to_native(args[1], &arg1, s.thisObject()); + SE_PRECONDITION2(ok, false, "js_scene_Pass_setUniformArray : Error processing arguments"); + cobj->setUniformArray(arg0.value(), arg1.value()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 2); + return false; +} +SE_BIND_FUNC(js_scene_Pass_setUniformArray) + +static bool js_scene_Pass_tryCompile(se::State& s) // NOLINT(readability-identifier-naming) +{ + CC_UNUSED bool ok = true; + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2( cobj, false, "js_scene_Pass_tryCompile : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + do { + if (argc == 1) { + HolderType>>, true> arg0 = {}; + + ok &= sevalue_to_native(args[0], &arg0, s.thisObject()); + if (!ok) { ok = true; break; } + bool result = cobj->tryCompile(arg0.value()); + ok &= nativevalue_to_se(result, s.rval(), s.thisObject() /*ctx*/); + SE_PRECONDITION2(ok, false, "js_scene_Pass_tryCompile : Error processing arguments"); + SE_HOLD_RETURN_VALUE(result, s.thisObject(), s.rval()); + return true; + } + } while(false); + + do { + if (argc == 0) { + + bool result = cobj->tryCompile(); + ok &= nativevalue_to_se(result, s.rval(), s.thisObject() /*ctx*/); + SE_PRECONDITION2(ok, false, "js_scene_Pass_tryCompile : Error processing arguments"); + SE_HOLD_RETURN_VALUE(result, s.thisObject(), s.rval()); + return true; + } + } while(false); + + SE_REPORT_ERROR("wrong number of arguments: %d", (int)argc); + return false; +} +SE_BIND_FUNC(js_scene_Pass_tryCompile) + +static bool js_scene_Pass_update(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_scene_Pass_update : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + if (argc == 0) { + cobj->update(); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 0); + return false; +} +SE_BIND_FUNC(js_scene_Pass_update) + +static bool js_scene_Pass_fillPipelineInfo_static(se::State& s) // NOLINT(readability-identifier-naming) +{ + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 2) { + HolderType arg0 = {}; + HolderType arg1 = {}; + ok &= sevalue_to_native(args[0], &arg0, nullptr); + ok &= sevalue_to_native(args[1], &arg1, nullptr); + SE_PRECONDITION2(ok, false, "js_scene_Pass_fillPipelineInfo_static : Error processing arguments"); + cc::scene::Pass::fillPipelineInfo(arg0.value(), arg1.value()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 2); + return false; +} +SE_BIND_FUNC(js_scene_Pass_fillPipelineInfo_static) + +static bool js_scene_Pass_getBindingFromHandle_static(se::State& s) // NOLINT(readability-identifier-naming) +{ + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 1) { + HolderType arg0 = {}; + ok &= sevalue_to_native(args[0], &arg0, nullptr); + SE_PRECONDITION2(ok, false, "js_scene_Pass_getBindingFromHandle_static : Error processing arguments"); + unsigned int result = cc::scene::Pass::getBindingFromHandle(arg0.value()); + ok &= nativevalue_to_se(result, s.rval(), nullptr /*ctx*/); + SE_PRECONDITION2(ok, false, "js_scene_Pass_getBindingFromHandle_static : Error processing arguments"); SE_HOLD_RETURN_VALUE(result, s.thisObject(), s.rval()); return true; } SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 1); return false; } -SE_BIND_FUNC(js_scene_Plane_distance) +SE_BIND_FUNC(js_scene_Pass_getBindingFromHandle_static) -static bool js_scene_Plane_get_d(se::State& s) // NOLINT(readability-identifier-naming) +static bool js_scene_Pass_getCountFromHandle_static(se::State& s) // NOLINT(readability-identifier-naming) { - auto* cobj = SE_THIS_OBJECT(s); - SE_PRECONDITION2(cobj, false, "js_scene_Plane_get_d : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 1) { + HolderType arg0 = {}; + ok &= sevalue_to_native(args[0], &arg0, nullptr); + SE_PRECONDITION2(ok, false, "js_scene_Pass_getCountFromHandle_static : Error processing arguments"); + unsigned int result = cc::scene::Pass::getCountFromHandle(arg0.value()); + ok &= nativevalue_to_se(result, s.rval(), nullptr /*ctx*/); + SE_PRECONDITION2(ok, false, "js_scene_Pass_getCountFromHandle_static : Error processing arguments"); + SE_HOLD_RETURN_VALUE(result, s.thisObject(), s.rval()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 1); + return false; +} +SE_BIND_FUNC(js_scene_Pass_getCountFromHandle_static) + +static bool js_scene_Pass_getOffsetFromHandle_static(se::State& s) // NOLINT(readability-identifier-naming) +{ + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 1) { + HolderType arg0 = {}; + ok &= sevalue_to_native(args[0], &arg0, nullptr); + SE_PRECONDITION2(ok, false, "js_scene_Pass_getOffsetFromHandle_static : Error processing arguments"); + unsigned int result = cc::scene::Pass::getOffsetFromHandle(arg0.value()); + ok &= nativevalue_to_se(result, s.rval(), nullptr /*ctx*/); + SE_PRECONDITION2(ok, false, "js_scene_Pass_getOffsetFromHandle_static : Error processing arguments"); + SE_HOLD_RETURN_VALUE(result, s.thisObject(), s.rval()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 1); + return false; +} +SE_BIND_FUNC(js_scene_Pass_getOffsetFromHandle_static) + +static bool js_scene_Pass_getPassHash_static(se::State& s) // NOLINT(readability-identifier-naming) +{ + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 1) { + HolderType arg0 = {}; + ok &= sevalue_to_native(args[0], &arg0, nullptr); + SE_PRECONDITION2(ok, false, "js_scene_Pass_getPassHash_static : Error processing arguments"); + uint64_t result = cc::scene::Pass::getPassHash(arg0.value()); + ok &= nativevalue_to_se(result, s.rval(), nullptr /*ctx*/); + SE_PRECONDITION2(ok, false, "js_scene_Pass_getPassHash_static : Error processing arguments"); + SE_HOLD_RETURN_VALUE(result, s.thisObject(), s.rval()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 1); + return false; +} +SE_BIND_FUNC(js_scene_Pass_getPassHash_static) + +static bool js_scene_Pass_getTypeFromHandle_static(se::State& s) // NOLINT(readability-identifier-naming) +{ + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 1) { + HolderType arg0 = {}; + ok &= sevalue_to_native(args[0], &arg0, nullptr); + SE_PRECONDITION2(ok, false, "js_scene_Pass_getTypeFromHandle_static : Error processing arguments"); + auto result = static_cast(cc::scene::Pass::getTypeFromHandle(arg0.value())); + ok &= nativevalue_to_se(result, s.rval(), nullptr /*ctx*/); + SE_PRECONDITION2(ok, false, "js_scene_Pass_getTypeFromHandle_static : Error processing arguments"); + SE_HOLD_RETURN_VALUE(result, s.thisObject(), s.rval()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 1); + return false; +} +SE_BIND_FUNC(js_scene_Pass_getTypeFromHandle_static) + +SE_DECLARE_FINALIZE_FUNC(js_cc_scene_Pass_finalize) + +static bool js_scene_Pass_constructor(se::State& s) // NOLINT(readability-identifier-naming) constructor_overloaded.c +{ + CC_UNUSED bool ok = true; + const auto& args = s.args(); + size_t argc = args.size(); + do { + if (argc == 1) { + HolderType arg0 = {}; + ok &= sevalue_to_native(args[0], &arg0, s.thisObject()); + if (!ok) { ok = true; break; } + auto *ptr = JSB_MAKE_PRIVATE_OBJECT(cc::scene::Pass, arg0.value()); + s.thisObject()->setPrivateObject(ptr); + return true; + } + } while(false); + do { + if (argc == 0) { + auto *ptr = JSB_MAKE_PRIVATE_OBJECT(cc::scene::Pass); + s.thisObject()->setPrivateObject(ptr); + return true; + } + } while(false); + SE_REPORT_ERROR("wrong number of arguments: %d", (int)argc); + return false; +} +SE_BIND_CTOR(js_scene_Pass_constructor, __jsb_cc_scene_Pass_class, js_cc_scene_Pass_finalize) + +static bool js_cc_scene_Pass_finalize(se::State& s) // NOLINT(readability-identifier-naming) +{ + return true; +} +SE_BIND_FINALIZE_FUNC(js_cc_scene_Pass_finalize) + +bool js_register_scene_Pass(se::Object* obj) // NOLINT(readability-identifier-naming) +{ + auto* cls = se::Class::create("Pass", obj, nullptr, _SE(js_scene_Pass_constructor)); + + cls->defineProperty("primitive", _SE(js_scene_Pass_getPrimitive_asGetter), nullptr); + cls->defineProperty("passIndex", _SE(js_scene_Pass_getPassIndex_asGetter), nullptr); + cls->defineProperty("device", _SE(js_scene_Pass_getDevice_asGetter), nullptr); + cls->defineProperty("dynamics", _SE(js_scene_Pass_getDynamics_asGetter), nullptr); + cls->defineProperty("depthStencilState", _SE(js_scene_Pass_getDepthStencilState_asGetter), nullptr); + cls->defineProperty("defines", _SE(js_scene_Pass_getDefines_asGetter), nullptr); + cls->defineProperty("batchingScheme", _SE(js_scene_Pass_getBatchingScheme_asGetter), nullptr); + cls->defineProperty("propertyIndex", _SE(js_scene_Pass_getPropertyIndex_asGetter), nullptr); + cls->defineProperty("shaderInfo", _SE(js_scene_Pass_getShaderInfo_asGetter), nullptr); + cls->defineProperty("blendState", _SE(js_scene_Pass_getBlendState_asGetter), nullptr); + cls->defineProperty("localSetLayout", _SE(js_scene_Pass_getLocalSetLayout_asGetter), nullptr); + cls->defineProperty("priority", _SE(js_scene_Pass_getPriority_asGetter), nullptr); + cls->defineProperty("rootBufferDirty", _SE(js_scene_Pass_isRootBufferDirty_asGetter), nullptr); + cls->defineProperty("program", _SE(js_scene_Pass_getProgram_asGetter), nullptr); + cls->defineProperty("hash", _SE(js_scene_Pass_getHashForJS_asGetter), nullptr); + cls->defineProperty("rasterizerState", _SE(js_scene_Pass_getRasterizerState_asGetter), nullptr); + cls->defineProperty("_rootBufferDirty", _SE(js_scene_Pass_isRootBufferDirty_asGetter), _SE(js_scene_Pass__setRootBufferDirty_asSetter)); + cls->defineProperty("phase", _SE(js_scene_Pass_getPhase_asGetter), nullptr); + cls->defineProperty("properties", _SE(js_scene_Pass_getProperties_asGetter), nullptr); + cls->defineProperty("stage", _SE(js_scene_Pass_getStage_asGetter), nullptr); + cls->defineProperty("dynamicStates", _SE(js_scene_Pass_getDynamicStates_asGetter), nullptr); + cls->defineProperty("descriptorSet", _SE(js_scene_Pass_getDescriptorSet_asGetter), nullptr); + cls->defineProperty("pipelineLayout", _SE(js_scene_Pass_getPipelineLayout_asGetter), nullptr); + cls->defineProperty("root", _SE(js_scene_Pass_getRoot_asGetter), nullptr); + cls->defineFunction("beginChangeStatesSilently", _SE(js_scene_Pass_beginChangeStatesSilently)); + cls->defineFunction("bindSampler", _SE(js_scene_Pass_bindSampler)); + cls->defineFunction("bindTexture", _SE(js_scene_Pass_bindTexture)); + cls->defineFunction("destroy", _SE(js_scene_Pass_destroy)); + cls->defineFunction("endChangeStatesSilently", _SE(js_scene_Pass_endChangeStatesSilently)); + cls->defineFunction("getBatchedBuffer", _SE(js_scene_Pass_getBatchedBuffer)); + cls->defineFunction("getBinding", _SE(js_scene_Pass_getBinding)); + cls->defineFunction("getHandle", _SE(js_scene_Pass_getHandle)); + cls->defineFunction("getHash", _SE(js_scene_Pass_getHash)); + cls->defineFunction("getInstancedBuffer", _SE(js_scene_Pass_getInstancedBuffer)); + cls->defineFunction("getPassInfoFull", _SE(js_scene_Pass_getPassInfoFull)); + cls->defineFunction("getRootBlock", _SE(js_scene_Pass_getRootBlock)); + cls->defineFunction("getShaderVariant", _SE(js_scene_Pass_getShaderVariant)); + cls->defineFunction("getUniform", _SE(js_scene_Pass_getUniform)); + cls->defineFunction("_initPassFromTarget", _SE(js_scene_Pass_initPassFromTarget)); + cls->defineFunction("initialize", _SE(js_scene_Pass_initialize)); + cls->defineFunction("overridePipelineStates", _SE(js_scene_Pass_overridePipelineStates)); + cls->defineFunction("resetTexture", _SE(js_scene_Pass_resetTexture)); + cls->defineFunction("resetTextures", _SE(js_scene_Pass_resetTextures)); + cls->defineFunction("resetUBOs", _SE(js_scene_Pass_resetUBOs)); + cls->defineFunction("resetUniform", _SE(js_scene_Pass_resetUniform)); + cls->defineFunction("setDynamicState", _SE(js_scene_Pass_setDynamicState)); + cls->defineFunction("setUniform", _SE(js_scene_Pass_setUniform)); + cls->defineFunction("setUniformArray", _SE(js_scene_Pass_setUniformArray)); + cls->defineFunction("tryCompile", _SE(js_scene_Pass_tryCompile)); + cls->defineFunction("update", _SE(js_scene_Pass_update)); + cls->defineStaticFunction("fillPipelineInfo", _SE(js_scene_Pass_fillPipelineInfo_static)); + cls->defineStaticFunction("getBindingFromHandle", _SE(js_scene_Pass_getBindingFromHandle_static)); + cls->defineStaticFunction("getCountFromHandle", _SE(js_scene_Pass_getCountFromHandle_static)); + cls->defineStaticFunction("getOffsetFromHandle", _SE(js_scene_Pass_getOffsetFromHandle_static)); + cls->defineStaticFunction("getPassHash", _SE(js_scene_Pass_getPassHash_static)); + cls->defineStaticFunction("getTypeFromHandle", _SE(js_scene_Pass_getTypeFromHandle_static)); + cls->defineFinalizeFunction(_SE(js_cc_scene_Pass_finalize)); + cls->install(); + JSBClassType::registerClass(cls); + + __jsb_cc_scene_Pass_proto = cls->getProto(); + __jsb_cc_scene_Pass_class = cls; + + + se::ScriptEngine::getInstance()->clearException(); + return true; +} +se::Object* __jsb_cc_scene_IMacroPatch_proto = nullptr; // NOLINT +se::Class* __jsb_cc_scene_IMacroPatch_class = nullptr; // NOLINT + +static bool js_scene_IMacroPatch_get_name(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_scene_IMacroPatch_get_name : Invalid Native Object"); CC_UNUSED bool ok = true; se::Value jsret; - ok &= nativevalue_to_se(cobj->d, jsret, s.thisObject() /*ctx*/); + ok &= nativevalue_to_se(cobj->name, jsret, s.thisObject() /*ctx*/); s.rval() = jsret; - SE_HOLD_RETURN_VALUE(cobj->d, s.thisObject(), s.rval()); + SE_HOLD_RETURN_VALUE(cobj->name, s.thisObject(), s.rval()); return true; } -SE_BIND_PROP_GET(js_scene_Plane_get_d) +SE_BIND_PROP_GET(js_scene_IMacroPatch_get_name) -static bool js_scene_Plane_set_d(se::State& s) // NOLINT(readability-identifier-naming) +static bool js_scene_IMacroPatch_set_name(se::State& s) // NOLINT(readability-identifier-naming) { const auto& args = s.args(); - auto* cobj = SE_THIS_OBJECT(s); - SE_PRECONDITION2(cobj, false, "js_scene_Plane_set_d : Invalid Native Object"); + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_scene_IMacroPatch_set_name : Invalid Native Object"); CC_UNUSED bool ok = true; - ok &= sevalue_to_native(args[0], &cobj->d, s.thisObject()); - SE_PRECONDITION2(ok, false, "js_scene_Plane_set_d : Error processing new value"); + ok &= sevalue_to_native(args[0], &cobj->name, s.thisObject()); + SE_PRECONDITION2(ok, false, "js_scene_IMacroPatch_set_name : Error processing new value"); return true; } -SE_BIND_PROP_SET(js_scene_Plane_set_d) +SE_BIND_PROP_SET(js_scene_IMacroPatch_set_name) -static bool js_scene_Plane_get_n(se::State& s) // NOLINT(readability-identifier-naming) +static bool js_scene_IMacroPatch_get_value(se::State& s) // NOLINT(readability-identifier-naming) { - auto* cobj = SE_THIS_OBJECT(s); - SE_PRECONDITION2(cobj, false, "js_scene_Plane_get_n : Invalid Native Object"); + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_scene_IMacroPatch_get_value : Invalid Native Object"); CC_UNUSED bool ok = true; se::Value jsret; - ok &= nativevalue_to_se(cobj->n, jsret, s.thisObject() /*ctx*/); + ok &= nativevalue_to_se(cobj->value, jsret, s.thisObject() /*ctx*/); s.rval() = jsret; - SE_HOLD_RETURN_VALUE(cobj->n, s.thisObject(), s.rval()); + SE_HOLD_RETURN_VALUE(cobj->value, s.thisObject(), s.rval()); return true; } -SE_BIND_PROP_GET(js_scene_Plane_get_n) +SE_BIND_PROP_GET(js_scene_IMacroPatch_get_value) -static bool js_scene_Plane_set_n(se::State& s) // NOLINT(readability-identifier-naming) +static bool js_scene_IMacroPatch_set_value(se::State& s) // NOLINT(readability-identifier-naming) { const auto& args = s.args(); - auto* cobj = SE_THIS_OBJECT(s); - SE_PRECONDITION2(cobj, false, "js_scene_Plane_set_n : Invalid Native Object"); + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_scene_IMacroPatch_set_value : Invalid Native Object"); CC_UNUSED bool ok = true; - ok &= sevalue_to_native(args[0], &cobj->n, s.thisObject()); - SE_PRECONDITION2(ok, false, "js_scene_Plane_set_n : Error processing new value"); + ok &= sevalue_to_native(args[0], &cobj->value, s.thisObject()); + SE_PRECONDITION2(ok, false, "js_scene_IMacroPatch_set_value : Error processing new value"); return true; } -SE_BIND_PROP_SET(js_scene_Plane_set_n) +SE_BIND_PROP_SET(js_scene_IMacroPatch_set_value) template<> -bool sevalue_to_native(const se::Value &from, cc::scene::Plane * to, se::Object *ctx) +bool sevalue_to_native(const se::Value &from, cc::scene::IMacroPatch * to, se::Object *ctx) { assert(from.isObject()); se::Object *json = from.toObject(); - auto* data = reinterpret_cast(json->getPrivateData()); + auto* data = reinterpret_cast(json->getPrivateData()); if (data) { *to = *data; return true; } se::Value field; bool ok = true; - json->getProperty("d", &field); + json->getProperty("name", &field, true); if(!field.isNullOrUndefined()) { - ok &= sevalue_to_native(field, &(to->d), ctx); + ok &= sevalue_to_native(field, &(to->name), ctx); } - json->getProperty("n", &field); + json->getProperty("value", &field, true); if(!field.isNullOrUndefined()) { - ok &= sevalue_to_native(field, &(to->n), ctx); + ok &= sevalue_to_native(field, &(to->value), ctx); } return ok; } -SE_DECLARE_FINALIZE_FUNC(js_cc_scene_Plane_finalize) +SE_DECLARE_FINALIZE_FUNC(js_cc_scene_IMacroPatch_finalize) -static bool js_scene_Plane_constructor(se::State& s) // NOLINT(readability-identifier-naming) +static bool js_scene_IMacroPatch_constructor(se::State& s) // NOLINT(readability-identifier-naming) { CC_UNUSED bool ok = true; const auto& args = s.args(); @@ -672,9 +5511,8 @@ static bool js_scene_Plane_constructor(se::State& s) // NOLINT(readability-ident if(argc == 0) { - cc::scene::Plane* cobj = JSB_ALLOC(cc::scene::Plane); - s.thisObject()->setPrivateData(cobj); - se::NonRefNativePtrCreatedByCtorMap::emplace(cobj); + auto *ptr = JSB_MAKE_PRIVATE_OBJECT(cc::scene::IMacroPatch); + s.thisObject()->setPrivateObject(ptr); return true; } @@ -682,915 +5520,5074 @@ static bool js_scene_Plane_constructor(se::State& s) // NOLINT(readability-ident { se::Object *json = args[0].toObject(); se::Value field; - - cc::scene::Plane* cobj = JSB_ALLOC(cc::scene::Plane); + auto *ptr = JSB_MAKE_PRIVATE_OBJECT(cc::scene::IMacroPatch); + auto cobj = ptr->get(); ok &= sevalue_to_native(args[0], cobj, s.thisObject()); if(!ok) { - JSB_FREE(cobj); + delete ptr; SE_REPORT_ERROR("argument convertion error"); return false; } - - s.thisObject()->setPrivateData(cobj); - se::NonRefNativePtrCreatedByCtorMap::emplace(cobj); + s.thisObject()->setPrivateObject(ptr); return true; } - - cc::scene::Plane* cobj = JSB_ALLOC(cc::scene::Plane); + auto *ptr = JSB_MAKE_PRIVATE_OBJECT(cc::scene::IMacroPatch); + auto cobj = ptr->get(); if (argc > 0 && !args[0].isUndefined()) { - ok &= sevalue_to_native(args[0], &(cobj->d), nullptr); + ok &= sevalue_to_native(args[0], &(cobj->name), nullptr); } if (argc > 1 && !args[1].isUndefined()) { - ok &= sevalue_to_native(args[1], &(cobj->n), nullptr); + ok &= sevalue_to_native(args[1], &(cobj->value), nullptr); } if(!ok) { - JSB_FREE(cobj); + delete ptr; SE_REPORT_ERROR("Argument convertion error"); return false; } - - s.thisObject()->setPrivateData(cobj); - se::NonRefNativePtrCreatedByCtorMap::emplace(cobj); + s.thisObject()->setPrivateObject(ptr); return true; } -SE_BIND_CTOR(js_scene_Plane_constructor, __jsb_cc_scene_Plane_class, js_cc_scene_Plane_finalize) +SE_BIND_CTOR(js_scene_IMacroPatch_constructor, __jsb_cc_scene_IMacroPatch_class, js_cc_scene_IMacroPatch_finalize) - - -static bool js_cc_scene_Plane_finalize(se::State& s) // NOLINT(readability-identifier-naming) +static bool js_cc_scene_IMacroPatch_finalize(se::State& s) // NOLINT(readability-identifier-naming) { - auto iter = se::NonRefNativePtrCreatedByCtorMap::find(SE_THIS_OBJECT(s)); - if (iter != se::NonRefNativePtrCreatedByCtorMap::end()) - { - se::NonRefNativePtrCreatedByCtorMap::erase(iter); - auto* cobj = SE_THIS_OBJECT(s); - JSB_FREE(cobj); - } return true; } -SE_BIND_FINALIZE_FUNC(js_cc_scene_Plane_finalize) +SE_BIND_FINALIZE_FUNC(js_cc_scene_IMacroPatch_finalize) -bool js_register_scene_Plane(se::Object* obj) // NOLINT(readability-identifier-naming) +bool js_register_scene_IMacroPatch(se::Object* obj) // NOLINT(readability-identifier-naming) { - auto* cls = se::Class::create("Plane", obj, nullptr, _SE(js_scene_Plane_constructor)); + auto* cls = se::Class::create("IMacroPatch", obj, nullptr, _SE(js_scene_IMacroPatch_constructor)); - cls->defineProperty("d", _SE(js_scene_Plane_get_d), _SE(js_scene_Plane_set_d)); - cls->defineProperty("n", _SE(js_scene_Plane_get_n), _SE(js_scene_Plane_set_n)); - cls->defineFunction("clone", _SE(js_scene_Plane_clone)); - cls->defineFunction("define", _SE(js_scene_Plane_define)); - cls->defineFunction("distance", _SE(js_scene_Plane_distance)); - cls->defineFinalizeFunction(_SE(js_cc_scene_Plane_finalize)); + cls->defineProperty("name", _SE(js_scene_IMacroPatch_get_name), _SE(js_scene_IMacroPatch_set_name)); + cls->defineProperty("value", _SE(js_scene_IMacroPatch_get_value), _SE(js_scene_IMacroPatch_set_value)); + cls->defineFinalizeFunction(_SE(js_cc_scene_IMacroPatch_finalize)); cls->install(); - JSBClassType::registerClass(cls); + JSBClassType::registerClass(cls); + + __jsb_cc_scene_IMacroPatch_proto = cls->getProto(); + __jsb_cc_scene_IMacroPatch_class = cls; - __jsb_cc_scene_Plane_proto = cls->getProto(); - __jsb_cc_scene_Plane_class = cls; se::ScriptEngine::getInstance()->clearException(); return true; } -se::Object* __jsb_cc_scene_Frustum_proto = nullptr; -se::Class* __jsb_cc_scene_Frustum_class = nullptr; +se::Object* __jsb_cc_scene_ShadowsInfo_proto = nullptr; // NOLINT +se::Class* __jsb_cc_scene_ShadowsInfo_class = nullptr; // NOLINT -static bool js_scene_Frustum_clone(se::State& s) // NOLINT(readability-identifier-naming) +static bool js_scene_ShadowsInfo_activate(se::State& s) // NOLINT(readability-identifier-naming) { - auto* cobj = SE_THIS_OBJECT(s); - SE_PRECONDITION2(cobj, false, "js_scene_Frustum_clone : Invalid Native Object"); + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_scene_ShadowsInfo_activate : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 1) { + HolderType arg0 = {}; + ok &= sevalue_to_native(args[0], &arg0, s.thisObject()); + SE_PRECONDITION2(ok, false, "js_scene_ShadowsInfo_activate : Error processing arguments"); + cobj->activate(arg0.value()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 1); + return false; +} +SE_BIND_FUNC(js_scene_ShadowsInfo_activate) + +static bool js_scene_ShadowsInfo_getBias(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_scene_ShadowsInfo_getBias : Invalid Native Object"); const auto& args = s.args(); size_t argc = args.size(); CC_UNUSED bool ok = true; if (argc == 0) { - cc::scene::Frustum result = cobj->clone(); + float result = cobj->getBias(); ok &= nativevalue_to_se(result, s.rval(), nullptr /*ctx*/); - SE_PRECONDITION2(ok, false, "js_scene_Frustum_clone : Error processing arguments"); + SE_PRECONDITION2(ok, false, "js_scene_ShadowsInfo_getBias : Error processing arguments"); SE_HOLD_RETURN_VALUE(result, s.thisObject(), s.rval()); return true; } SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 0); return false; } -SE_BIND_FUNC(js_scene_Frustum_clone) +SE_BIND_FUNC_AS_PROP_GET(js_scene_ShadowsInfo_getBias) -static bool js_scene_Frustum_createOrtho(se::State& s) // NOLINT(readability-identifier-naming) +static bool js_scene_ShadowsInfo_getDistance(se::State& s) // NOLINT(readability-identifier-naming) { - auto* cobj = SE_THIS_OBJECT(s); - SE_PRECONDITION2(cobj, false, "js_scene_Frustum_createOrtho : Invalid Native Object"); - const auto& args = s.args(); - size_t argc = args.size(); - CC_UNUSED bool ok = true; - if (argc == 5) { - HolderType arg0 = {}; - HolderType arg1 = {}; - HolderType arg2 = {}; - HolderType arg3 = {}; - HolderType arg4 = {}; - ok &= sevalue_to_native(args[0], &arg0, s.thisObject()); - ok &= sevalue_to_native(args[1], &arg1, s.thisObject()); - ok &= sevalue_to_native(args[2], &arg2, s.thisObject()); - ok &= sevalue_to_native(args[3], &arg3, s.thisObject()); - ok &= sevalue_to_native(args[4], &arg4, s.thisObject()); - SE_PRECONDITION2(ok, false, "js_scene_Frustum_createOrtho : Error processing arguments"); - cobj->createOrtho(arg0.value(), arg1.value(), arg2.value(), arg3.value(), arg4.value()); - return true; - } - SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 5); - return false; -} -SE_BIND_FUNC(js_scene_Frustum_createOrtho) - -static bool js_scene_Frustum_split(se::State& s) // NOLINT(readability-identifier-naming) -{ - auto* cobj = SE_THIS_OBJECT(s); - SE_PRECONDITION2(cobj, false, "js_scene_Frustum_split : Invalid Native Object"); - const auto& args = s.args(); - size_t argc = args.size(); - CC_UNUSED bool ok = true; - if (argc == 5) { - HolderType arg0 = {}; - HolderType arg1 = {}; - HolderType arg2 = {}; - HolderType arg3 = {}; - HolderType arg4 = {}; - ok &= sevalue_to_native(args[0], &arg0, s.thisObject()); - ok &= sevalue_to_native(args[1], &arg1, s.thisObject()); - ok &= sevalue_to_native(args[2], &arg2, s.thisObject()); - ok &= sevalue_to_native(args[3], &arg3, s.thisObject()); - ok &= sevalue_to_native(args[4], &arg4, s.thisObject()); - SE_PRECONDITION2(ok, false, "js_scene_Frustum_split : Error processing arguments"); - cobj->split(arg0.value(), arg1.value(), arg2.value(), arg3.value(), arg4.value()); - return true; - } - SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 5); - return false; -} -SE_BIND_FUNC(js_scene_Frustum_split) - -static bool js_scene_Frustum_transform(se::State& s) // NOLINT(readability-identifier-naming) -{ - auto* cobj = SE_THIS_OBJECT(s); - SE_PRECONDITION2(cobj, false, "js_scene_Frustum_transform : Invalid Native Object"); - const auto& args = s.args(); - size_t argc = args.size(); - CC_UNUSED bool ok = true; - if (argc == 1) { - HolderType arg0 = {}; - ok &= sevalue_to_native(args[0], &arg0, s.thisObject()); - SE_PRECONDITION2(ok, false, "js_scene_Frustum_transform : Error processing arguments"); - cobj->transform(arg0.value()); - return true; - } - SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 1); - return false; -} -SE_BIND_FUNC(js_scene_Frustum_transform) - -static bool js_scene_Frustum_get_vertices(se::State& s) // NOLINT(readability-identifier-naming) -{ - auto* cobj = SE_THIS_OBJECT(s); - SE_PRECONDITION2(cobj, false, "js_scene_Frustum_get_vertices : Invalid Native Object"); - - CC_UNUSED bool ok = true; - se::Value jsret; - ok &= nativevalue_to_se(cobj->vertices, jsret, s.thisObject() /*ctx*/); - s.rval() = jsret; - SE_HOLD_RETURN_VALUE(cobj->vertices, s.thisObject(), s.rval()); - return true; -} -SE_BIND_PROP_GET(js_scene_Frustum_get_vertices) - -static bool js_scene_Frustum_set_vertices(se::State& s) // NOLINT(readability-identifier-naming) -{ - const auto& args = s.args(); - auto* cobj = SE_THIS_OBJECT(s); - SE_PRECONDITION2(cobj, false, "js_scene_Frustum_set_vertices : Invalid Native Object"); - - CC_UNUSED bool ok = true; - ok &= sevalue_to_native(args[0], &cobj->vertices, s.thisObject()); - SE_PRECONDITION2(ok, false, "js_scene_Frustum_set_vertices : Error processing new value"); - return true; -} -SE_BIND_PROP_SET(js_scene_Frustum_set_vertices) - -static bool js_scene_Frustum_get_planes(se::State& s) // NOLINT(readability-identifier-naming) -{ - auto* cobj = SE_THIS_OBJECT(s); - SE_PRECONDITION2(cobj, false, "js_scene_Frustum_get_planes : Invalid Native Object"); - - CC_UNUSED bool ok = true; - se::Value jsret; - ok &= nativevalue_to_se(cobj->planes, jsret, s.thisObject() /*ctx*/); - s.rval() = jsret; - SE_HOLD_RETURN_VALUE(cobj->planes, s.thisObject(), s.rval()); - return true; -} -SE_BIND_PROP_GET(js_scene_Frustum_get_planes) - -static bool js_scene_Frustum_set_planes(se::State& s) // NOLINT(readability-identifier-naming) -{ - const auto& args = s.args(); - auto* cobj = SE_THIS_OBJECT(s); - SE_PRECONDITION2(cobj, false, "js_scene_Frustum_set_planes : Invalid Native Object"); - - CC_UNUSED bool ok = true; - ok &= sevalue_to_native(args[0], &cobj->planes, s.thisObject()); - SE_PRECONDITION2(ok, false, "js_scene_Frustum_set_planes : Error processing new value"); - return true; -} -SE_BIND_PROP_SET(js_scene_Frustum_set_planes) - - -template<> -bool sevalue_to_native(const se::Value &from, cc::scene::Frustum * to, se::Object *ctx) -{ - assert(from.isObject()); - se::Object *json = from.toObject(); - auto* data = reinterpret_cast(json->getPrivateData()); - if (data) { - *to = *data; - return true; - } - se::Value field; - bool ok = true; - json->getProperty("vertices", &field); - if(!field.isNullOrUndefined()) { - ok &= sevalue_to_native(field, &(to->vertices), ctx); - } - json->getProperty("planes", &field); - if(!field.isNullOrUndefined()) { - ok &= sevalue_to_native(field, &(to->planes), ctx); - } - json->getProperty("type", &field); - if(!field.isNullOrUndefined()) { - ok &= sevalue_to_native(field, &(to->type), ctx); - } - return ok; -} - -SE_DECLARE_FINALIZE_FUNC(js_cc_scene_Frustum_finalize) - -static bool js_scene_Frustum_constructor(se::State& s) // NOLINT(readability-identifier-naming) -{ - CC_UNUSED bool ok = true; - const auto& args = s.args(); - size_t argc = args.size(); - - if(argc == 0) - { - cc::scene::Frustum* cobj = JSB_ALLOC(cc::scene::Frustum); - s.thisObject()->setPrivateData(cobj); - se::NonRefNativePtrCreatedByCtorMap::emplace(cobj); - return true; - } - - if(argc == 1 && args[0].isObject()) - { - se::Object *json = args[0].toObject(); - se::Value field; - - cc::scene::Frustum* cobj = JSB_ALLOC(cc::scene::Frustum); - ok &= sevalue_to_native(args[0], cobj, s.thisObject()); - if(!ok) { - JSB_FREE(cobj); - SE_REPORT_ERROR("argument convertion error"); - return false; - } - - s.thisObject()->setPrivateData(cobj); - se::NonRefNativePtrCreatedByCtorMap::emplace(cobj); - return true; - } - - cc::scene::Frustum* cobj = JSB_ALLOC(cc::scene::Frustum); - if (argc > 0 && !args[0].isUndefined()) { - ok &= sevalue_to_native(args[0], &(cobj->vertices), nullptr); - } - if (argc > 1 && !args[1].isUndefined()) { - ok &= sevalue_to_native(args[1], &(cobj->planes), nullptr); - } - if (argc > 2 && !args[2].isUndefined()) { - ok &= sevalue_to_native(args[2], &(cobj->type), nullptr); - } - - if(!ok) { - JSB_FREE(cobj); - SE_REPORT_ERROR("Argument convertion error"); - return false; - } - - s.thisObject()->setPrivateData(cobj); - se::NonRefNativePtrCreatedByCtorMap::emplace(cobj); - return true; -} -SE_BIND_CTOR(js_scene_Frustum_constructor, __jsb_cc_scene_Frustum_class, js_cc_scene_Frustum_finalize) - - - -static bool js_cc_scene_Frustum_finalize(se::State& s) // NOLINT(readability-identifier-naming) -{ - auto iter = se::NonRefNativePtrCreatedByCtorMap::find(SE_THIS_OBJECT(s)); - if (iter != se::NonRefNativePtrCreatedByCtorMap::end()) - { - se::NonRefNativePtrCreatedByCtorMap::erase(iter); - auto* cobj = SE_THIS_OBJECT(s); - JSB_FREE(cobj); - } - return true; -} -SE_BIND_FINALIZE_FUNC(js_cc_scene_Frustum_finalize) - -bool js_register_scene_Frustum(se::Object* obj) // NOLINT(readability-identifier-naming) -{ - auto* cls = se::Class::create("Frustum", obj, nullptr, _SE(js_scene_Frustum_constructor)); - - cls->defineProperty("vertices", _SE(js_scene_Frustum_get_vertices), _SE(js_scene_Frustum_set_vertices)); - cls->defineProperty("planes", _SE(js_scene_Frustum_get_planes), _SE(js_scene_Frustum_set_planes)); - cls->defineFunction("clone", _SE(js_scene_Frustum_clone)); - cls->defineFunction("createOrtho", _SE(js_scene_Frustum_createOrtho)); - cls->defineFunction("split", _SE(js_scene_Frustum_split)); - cls->defineFunction("transform", _SE(js_scene_Frustum_transform)); - cls->defineFinalizeFunction(_SE(js_cc_scene_Frustum_finalize)); - cls->install(); - JSBClassType::registerClass(cls); - - __jsb_cc_scene_Frustum_proto = cls->getProto(); - __jsb_cc_scene_Frustum_class = cls; - - se::ScriptEngine::getInstance()->clearException(); - return true; -} -se::Object* __jsb_cc_scene_AABB_proto = nullptr; -se::Class* __jsb_cc_scene_AABB_class = nullptr; - -static bool js_scene_AABB_contain(se::State& s) // NOLINT(readability-identifier-naming) -{ - auto* cobj = SE_THIS_OBJECT(s); - SE_PRECONDITION2(cobj, false, "js_scene_AABB_contain : Invalid Native Object"); - const auto& args = s.args(); - size_t argc = args.size(); - CC_UNUSED bool ok = true; - if (argc == 1) { - HolderType arg0 = {}; - ok &= sevalue_to_native(args[0], &arg0, s.thisObject()); - SE_PRECONDITION2(ok, false, "js_scene_AABB_contain : Error processing arguments"); - bool result = cobj->contain(arg0.value()); - ok &= nativevalue_to_se(result, s.rval(), nullptr /*ctx*/); - SE_PRECONDITION2(ok, false, "js_scene_AABB_contain : Error processing arguments"); - SE_HOLD_RETURN_VALUE(result, s.thisObject(), s.rval()); - return true; - } - SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 1); - return false; -} -SE_BIND_FUNC(js_scene_AABB_contain) - -static bool js_scene_AABB_getLayout(se::State& s) // NOLINT(readability-identifier-naming) -{ - auto* cobj = SE_THIS_OBJECT(s); - SE_PRECONDITION2(cobj, false, "js_scene_AABB_getLayout : Invalid Native Object"); + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_scene_ShadowsInfo_getDistance : Invalid Native Object"); const auto& args = s.args(); size_t argc = args.size(); CC_UNUSED bool ok = true; if (argc == 0) { - cc::scene::AABBLayout* result = cobj->getLayout(); + float result = cobj->getDistance(); ok &= nativevalue_to_se(result, s.rval(), nullptr /*ctx*/); - SE_PRECONDITION2(ok, false, "js_scene_AABB_getLayout : Error processing arguments"); + SE_PRECONDITION2(ok, false, "js_scene_ShadowsInfo_getDistance : Error processing arguments"); SE_HOLD_RETURN_VALUE(result, s.thisObject(), s.rval()); return true; } SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 0); return false; } -SE_BIND_FUNC(js_scene_AABB_getLayout) +SE_BIND_FUNC_AS_PROP_GET(js_scene_ShadowsInfo_getDistance) -static bool js_scene_AABB_initWithData(se::State& s) // NOLINT(readability-identifier-naming) +static bool js_scene_ShadowsInfo_getFar(se::State& s) // NOLINT(readability-identifier-naming) { - auto* cobj = SE_THIS_OBJECT(s); - SE_PRECONDITION2(cobj, false, "js_scene_AABB_initWithData : Invalid Native Object"); + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_scene_ShadowsInfo_getFar : Invalid Native Object"); const auto& args = s.args(); size_t argc = args.size(); CC_UNUSED bool ok = true; - if (argc == 1) { - HolderType arg0 = {}; - ok &= sevalue_to_native(args[0], &arg0, s.thisObject()); - SE_PRECONDITION2(ok, false, "js_scene_AABB_initWithData : Error processing arguments"); - cobj->initWithData(arg0.value()); + if (argc == 0) { + float result = cobj->getFar(); + ok &= nativevalue_to_se(result, s.rval(), nullptr /*ctx*/); + SE_PRECONDITION2(ok, false, "js_scene_ShadowsInfo_getFar : Error processing arguments"); + SE_HOLD_RETURN_VALUE(result, s.thisObject(), s.rval()); return true; } - SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 1); + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 0); return false; } -SE_BIND_FUNC(js_scene_AABB_initWithData) +SE_BIND_FUNC_AS_PROP_GET(js_scene_ShadowsInfo_getFar) -SE_DECLARE_FINALIZE_FUNC(js_cc_scene_AABB_finalize) - -static bool js_scene_AABB_constructor(se::State& s) // NOLINT(readability-identifier-naming) constructor.c +static bool js_scene_ShadowsInfo_getInvisibleOcclusionRange(se::State& s) // NOLINT(readability-identifier-naming) { - cc::scene::AABB* cobj = JSB_ALLOC(cc::scene::AABB); - s.thisObject()->setPrivateData(cobj); - se::NonRefNativePtrCreatedByCtorMap::emplace(cobj); - return true; -} -SE_BIND_CTOR(js_scene_AABB_constructor, __jsb_cc_scene_AABB_class, js_cc_scene_AABB_finalize) - - - -static bool js_cc_scene_AABB_finalize(se::State& s) // NOLINT(readability-identifier-naming) -{ - auto iter = se::NonRefNativePtrCreatedByCtorMap::find(SE_THIS_OBJECT(s)); - if (iter != se::NonRefNativePtrCreatedByCtorMap::end()) - { - se::NonRefNativePtrCreatedByCtorMap::erase(iter); - auto* cobj = SE_THIS_OBJECT(s); - JSB_FREE(cobj); - } - return true; -} -SE_BIND_FINALIZE_FUNC(js_cc_scene_AABB_finalize) - -bool js_register_scene_AABB(se::Object* obj) // NOLINT(readability-identifier-naming) -{ - auto* cls = se::Class::create("AABB", obj, nullptr, _SE(js_scene_AABB_constructor)); - - cls->defineFunction("contain", _SE(js_scene_AABB_contain)); - cls->defineFunction("getLayout", _SE(js_scene_AABB_getLayout)); - cls->defineFunction("initWithData", _SE(js_scene_AABB_initWithData)); - cls->defineFinalizeFunction(_SE(js_cc_scene_AABB_finalize)); - cls->install(); - JSBClassType::registerClass(cls); - - __jsb_cc_scene_AABB_proto = cls->getProto(); - __jsb_cc_scene_AABB_class = cls; - - se::ScriptEngine::getInstance()->clearException(); - return true; -} -se::Object* __jsb_cc_scene_SpotLight_proto = nullptr; -se::Class* __jsb_cc_scene_SpotLight_class = nullptr; - -static bool js_scene_SpotLight_setAABB(se::State& s) // NOLINT(readability-identifier-naming) -{ - auto* cobj = SE_THIS_OBJECT(s); - SE_PRECONDITION2(cobj, false, "js_scene_SpotLight_setAABB : Invalid Native Object"); + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_scene_ShadowsInfo_getInvisibleOcclusionRange : Invalid Native Object"); const auto& args = s.args(); size_t argc = args.size(); CC_UNUSED bool ok = true; - if (argc == 1) { - HolderType arg0 = {}; - ok &= sevalue_to_native(args[0], &arg0, s.thisObject()); - SE_PRECONDITION2(ok, false, "js_scene_SpotLight_setAABB : Error processing arguments"); - cobj->setAABB(arg0.value()); + if (argc == 0) { + float result = cobj->getInvisibleOcclusionRange(); + ok &= nativevalue_to_se(result, s.rval(), nullptr /*ctx*/); + SE_PRECONDITION2(ok, false, "js_scene_ShadowsInfo_getInvisibleOcclusionRange : Error processing arguments"); + SE_HOLD_RETURN_VALUE(result, s.thisObject(), s.rval()); return true; } - SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 1); + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 0); return false; } -SE_BIND_FUNC(js_scene_SpotLight_setAABB) +SE_BIND_FUNC_AS_PROP_GET(js_scene_ShadowsInfo_getInvisibleOcclusionRange) -static bool js_scene_SpotLight_setAngle(se::State& s) // NOLINT(readability-identifier-naming) +static bool js_scene_ShadowsInfo_getMaxReceived(se::State& s) // NOLINT(readability-identifier-naming) { - auto* cobj = SE_THIS_OBJECT(s); - SE_PRECONDITION2(cobj, false, "js_scene_SpotLight_setAngle : Invalid Native Object"); + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_scene_ShadowsInfo_getMaxReceived : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 0) { + unsigned int result = cobj->getMaxReceived(); + ok &= nativevalue_to_se(result, s.rval(), nullptr /*ctx*/); + SE_PRECONDITION2(ok, false, "js_scene_ShadowsInfo_getMaxReceived : Error processing arguments"); + SE_HOLD_RETURN_VALUE(result, s.thisObject(), s.rval()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 0); + return false; +} +SE_BIND_FUNC_AS_PROP_GET(js_scene_ShadowsInfo_getMaxReceived) + +static bool js_scene_ShadowsInfo_getNear(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_scene_ShadowsInfo_getNear : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 0) { + float result = cobj->getNear(); + ok &= nativevalue_to_se(result, s.rval(), nullptr /*ctx*/); + SE_PRECONDITION2(ok, false, "js_scene_ShadowsInfo_getNear : Error processing arguments"); + SE_HOLD_RETURN_VALUE(result, s.thisObject(), s.rval()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 0); + return false; +} +SE_BIND_FUNC_AS_PROP_GET(js_scene_ShadowsInfo_getNear) + +static bool js_scene_ShadowsInfo_getNormal(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_scene_ShadowsInfo_getNormal : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 0) { + const cc::Vec3& result = cobj->getNormal(); + ok &= nativevalue_to_se(result, s.rval(), nullptr /*ctx*/); + SE_PRECONDITION2(ok, false, "js_scene_ShadowsInfo_getNormal : Error processing arguments"); + SE_HOLD_RETURN_VALUE(result, s.thisObject(), s.rval()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 0); + return false; +} +SE_BIND_FUNC_AS_PROP_GET(js_scene_ShadowsInfo_getNormal) + +static bool js_scene_ShadowsInfo_getNormalBias(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_scene_ShadowsInfo_getNormalBias : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 0) { + float result = cobj->getNormalBias(); + ok &= nativevalue_to_se(result, s.rval(), nullptr /*ctx*/); + SE_PRECONDITION2(ok, false, "js_scene_ShadowsInfo_getNormalBias : Error processing arguments"); + SE_HOLD_RETURN_VALUE(result, s.thisObject(), s.rval()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 0); + return false; +} +SE_BIND_FUNC_AS_PROP_GET(js_scene_ShadowsInfo_getNormalBias) + +static bool js_scene_ShadowsInfo_getOrthoSize(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_scene_ShadowsInfo_getOrthoSize : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 0) { + float result = cobj->getOrthoSize(); + ok &= nativevalue_to_se(result, s.rval(), nullptr /*ctx*/); + SE_PRECONDITION2(ok, false, "js_scene_ShadowsInfo_getOrthoSize : Error processing arguments"); + SE_HOLD_RETURN_VALUE(result, s.thisObject(), s.rval()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 0); + return false; +} +SE_BIND_FUNC_AS_PROP_GET(js_scene_ShadowsInfo_getOrthoSize) + +static bool js_scene_ShadowsInfo_getPcf(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_scene_ShadowsInfo_getPcf : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 0) { + auto result = static_cast(cobj->getPcf()); + ok &= nativevalue_to_se(result, s.rval(), nullptr /*ctx*/); + SE_PRECONDITION2(ok, false, "js_scene_ShadowsInfo_getPcf : Error processing arguments"); + SE_HOLD_RETURN_VALUE(result, s.thisObject(), s.rval()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 0); + return false; +} +SE_BIND_FUNC_AS_PROP_GET(js_scene_ShadowsInfo_getPcf) + +static bool js_scene_ShadowsInfo_getSaturation(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_scene_ShadowsInfo_getSaturation : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 0) { + float result = cobj->getSaturation(); + ok &= nativevalue_to_se(result, s.rval(), nullptr /*ctx*/); + SE_PRECONDITION2(ok, false, "js_scene_ShadowsInfo_getSaturation : Error processing arguments"); + SE_HOLD_RETURN_VALUE(result, s.thisObject(), s.rval()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 0); + return false; +} +SE_BIND_FUNC_AS_PROP_GET(js_scene_ShadowsInfo_getSaturation) + +static bool js_scene_ShadowsInfo_getShadowColor(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_scene_ShadowsInfo_getShadowColor : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 0) { + const cc::Color& result = cobj->getShadowColor(); + ok &= nativevalue_to_se(result, s.rval(), nullptr /*ctx*/); + SE_PRECONDITION2(ok, false, "js_scene_ShadowsInfo_getShadowColor : Error processing arguments"); + SE_HOLD_RETURN_VALUE(result, s.thisObject(), s.rval()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 0); + return false; +} +SE_BIND_FUNC_AS_PROP_GET(js_scene_ShadowsInfo_getShadowColor) + +static bool js_scene_ShadowsInfo_getShadowDistance(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_scene_ShadowsInfo_getShadowDistance : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 0) { + float result = cobj->getShadowDistance(); + ok &= nativevalue_to_se(result, s.rval(), nullptr /*ctx*/); + SE_PRECONDITION2(ok, false, "js_scene_ShadowsInfo_getShadowDistance : Error processing arguments"); + SE_HOLD_RETURN_VALUE(result, s.thisObject(), s.rval()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 0); + return false; +} +SE_BIND_FUNC_AS_PROP_GET(js_scene_ShadowsInfo_getShadowDistance) + +static bool js_scene_ShadowsInfo_getShadowMapSize(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_scene_ShadowsInfo_getShadowMapSize : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 0) { + float result = cobj->getShadowMapSize(); + ok &= nativevalue_to_se(result, s.rval(), nullptr /*ctx*/); + SE_PRECONDITION2(ok, false, "js_scene_ShadowsInfo_getShadowMapSize : Error processing arguments"); + SE_HOLD_RETURN_VALUE(result, s.thisObject(), s.rval()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 0); + return false; +} +SE_BIND_FUNC(js_scene_ShadowsInfo_getShadowMapSize) + +static bool js_scene_ShadowsInfo_getSize(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_scene_ShadowsInfo_getSize : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 0) { + const cc::Vec2& result = cobj->getSize(); + ok &= nativevalue_to_se(result, s.rval(), nullptr /*ctx*/); + SE_PRECONDITION2(ok, false, "js_scene_ShadowsInfo_getSize : Error processing arguments"); + SE_HOLD_RETURN_VALUE(result, s.thisObject(), s.rval()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 0); + return false; +} +SE_BIND_FUNC_AS_PROP_GET(js_scene_ShadowsInfo_getSize) + +static bool js_scene_ShadowsInfo_getType(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_scene_ShadowsInfo_getType : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 0) { + auto result = static_cast(cobj->getType()); + ok &= nativevalue_to_se(result, s.rval(), nullptr /*ctx*/); + SE_PRECONDITION2(ok, false, "js_scene_ShadowsInfo_getType : Error processing arguments"); + SE_HOLD_RETURN_VALUE(result, s.thisObject(), s.rval()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 0); + return false; +} +SE_BIND_FUNC_AS_PROP_GET(js_scene_ShadowsInfo_getType) + +static bool js_scene_ShadowsInfo_isEnabled(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_scene_ShadowsInfo_isEnabled : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 0) { + bool result = cobj->isEnabled(); + ok &= nativevalue_to_se(result, s.rval(), nullptr /*ctx*/); + SE_PRECONDITION2(ok, false, "js_scene_ShadowsInfo_isEnabled : Error processing arguments"); + SE_HOLD_RETURN_VALUE(result, s.thisObject(), s.rval()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 0); + return false; +} +SE_BIND_FUNC_AS_PROP_GET(js_scene_ShadowsInfo_isEnabled) + +static bool js_scene_ShadowsInfo_isFixedArea(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_scene_ShadowsInfo_isFixedArea : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 0) { + bool result = cobj->isFixedArea(); + ok &= nativevalue_to_se(result, s.rval(), nullptr /*ctx*/); + SE_PRECONDITION2(ok, false, "js_scene_ShadowsInfo_isFixedArea : Error processing arguments"); + SE_HOLD_RETURN_VALUE(result, s.thisObject(), s.rval()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 0); + return false; +} +SE_BIND_FUNC_AS_PROP_GET(js_scene_ShadowsInfo_isFixedArea) +SE_BIND_FUNC_AS_PROP_SET(js_scene_ShadowsInfo_isFixedArea) + +static bool js_scene_ShadowsInfo_setBias(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_scene_ShadowsInfo_setBias : Invalid Native Object"); const auto& args = s.args(); size_t argc = args.size(); CC_UNUSED bool ok = true; if (argc == 1) { HolderType arg0 = {}; ok &= sevalue_to_native(args[0], &arg0, s.thisObject()); - SE_PRECONDITION2(ok, false, "js_scene_SpotLight_setAngle : Error processing arguments"); - cobj->setAngle(arg0.value()); + SE_PRECONDITION2(ok, false, "js_scene_ShadowsInfo_setBias : Error processing arguments"); + cobj->setBias(arg0.value()); return true; } SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 1); return false; } -SE_BIND_FUNC(js_scene_SpotLight_setAngle) +SE_BIND_FUNC_AS_PROP_SET(js_scene_ShadowsInfo_setBias) -static bool js_scene_SpotLight_setAspect(se::State& s) // NOLINT(readability-identifier-naming) +static bool js_scene_ShadowsInfo_setDistance(se::State& s) // NOLINT(readability-identifier-naming) { - auto* cobj = SE_THIS_OBJECT(s); - SE_PRECONDITION2(cobj, false, "js_scene_SpotLight_setAspect : Invalid Native Object"); + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_scene_ShadowsInfo_setDistance : Invalid Native Object"); const auto& args = s.args(); size_t argc = args.size(); CC_UNUSED bool ok = true; if (argc == 1) { HolderType arg0 = {}; ok &= sevalue_to_native(args[0], &arg0, s.thisObject()); - SE_PRECONDITION2(ok, false, "js_scene_SpotLight_setAspect : Error processing arguments"); - cobj->setAspect(arg0.value()); + SE_PRECONDITION2(ok, false, "js_scene_ShadowsInfo_setDistance : Error processing arguments"); + cobj->setDistance(arg0.value()); return true; } SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 1); return false; } -SE_BIND_FUNC(js_scene_SpotLight_setAspect) +SE_BIND_FUNC_AS_PROP_SET(js_scene_ShadowsInfo_setDistance) -static bool js_scene_SpotLight_setDirection(se::State& s) // NOLINT(readability-identifier-naming) +static bool js_scene_ShadowsInfo_setEnabled(se::State& s) // NOLINT(readability-identifier-naming) { - auto* cobj = SE_THIS_OBJECT(s); - SE_PRECONDITION2(cobj, false, "js_scene_SpotLight_setDirection : Invalid Native Object"); - const auto& args = s.args(); - size_t argc = args.size(); - CC_UNUSED bool ok = true; - if (argc == 1) { - HolderType arg0 = {}; - ok &= sevalue_to_native(args[0], &arg0, s.thisObject()); - SE_PRECONDITION2(ok, false, "js_scene_SpotLight_setDirection : Error processing arguments"); - cobj->setDirection(arg0.value()); - return true; - } - SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 1); - return false; -} -SE_BIND_FUNC(js_scene_SpotLight_setDirection) - -static bool js_scene_SpotLight_setFrustum(se::State& s) // NOLINT(readability-identifier-naming) -{ - auto* cobj = SE_THIS_OBJECT(s); - SE_PRECONDITION2(cobj, false, "js_scene_SpotLight_setFrustum : Invalid Native Object"); - const auto& args = s.args(); - size_t argc = args.size(); - CC_UNUSED bool ok = true; - if (argc == 1) { - HolderType arg0 = {}; - ok &= sevalue_to_native(args[0], &arg0, s.thisObject()); - SE_PRECONDITION2(ok, false, "js_scene_SpotLight_setFrustum : Error processing arguments"); - cobj->setFrustum(arg0.value()); - return true; - } - SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 1); - return false; -} -SE_BIND_FUNC(js_scene_SpotLight_setFrustum) - -static bool js_scene_SpotLight_setLuminanceHDR(se::State& s) // NOLINT(readability-identifier-naming) -{ - auto* cobj = SE_THIS_OBJECT(s); - SE_PRECONDITION2(cobj, false, "js_scene_SpotLight_setLuminanceHDR : Invalid Native Object"); - const auto& args = s.args(); - size_t argc = args.size(); - CC_UNUSED bool ok = true; - if (argc == 1) { - HolderType arg0 = {}; - ok &= sevalue_to_native(args[0], &arg0, s.thisObject()); - SE_PRECONDITION2(ok, false, "js_scene_SpotLight_setLuminanceHDR : Error processing arguments"); - cobj->setLuminanceHDR(arg0.value()); - return true; - } - SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 1); - return false; -} -SE_BIND_FUNC(js_scene_SpotLight_setLuminanceHDR) - -static bool js_scene_SpotLight_setLuminanceLDR(se::State& s) // NOLINT(readability-identifier-naming) -{ - auto* cobj = SE_THIS_OBJECT(s); - SE_PRECONDITION2(cobj, false, "js_scene_SpotLight_setLuminanceLDR : Invalid Native Object"); - const auto& args = s.args(); - size_t argc = args.size(); - CC_UNUSED bool ok = true; - if (argc == 1) { - HolderType arg0 = {}; - ok &= sevalue_to_native(args[0], &arg0, s.thisObject()); - SE_PRECONDITION2(ok, false, "js_scene_SpotLight_setLuminanceLDR : Error processing arguments"); - cobj->setLuminanceLDR(arg0.value()); - return true; - } - SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 1); - return false; -} -SE_BIND_FUNC(js_scene_SpotLight_setLuminanceLDR) - -static bool js_scene_SpotLight_setNeedUpdate(se::State& s) // NOLINT(readability-identifier-naming) -{ - auto* cobj = SE_THIS_OBJECT(s); - SE_PRECONDITION2(cobj, false, "js_scene_SpotLight_setNeedUpdate : Invalid Native Object"); + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_scene_ShadowsInfo_setEnabled : Invalid Native Object"); const auto& args = s.args(); size_t argc = args.size(); CC_UNUSED bool ok = true; if (argc == 1) { HolderType arg0 = {}; ok &= sevalue_to_native(args[0], &arg0, s.thisObject()); - SE_PRECONDITION2(ok, false, "js_scene_SpotLight_setNeedUpdate : Error processing arguments"); - cobj->setNeedUpdate(arg0.value()); + SE_PRECONDITION2(ok, false, "js_scene_ShadowsInfo_setEnabled : Error processing arguments"); + cobj->setEnabled(arg0.value()); return true; } SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 1); return false; } -SE_BIND_FUNC(js_scene_SpotLight_setNeedUpdate) +SE_BIND_FUNC_AS_PROP_SET(js_scene_ShadowsInfo_setEnabled) -static bool js_scene_SpotLight_setPosition(se::State& s) // NOLINT(readability-identifier-naming) +static bool js_scene_ShadowsInfo_setFar(se::State& s) // NOLINT(readability-identifier-naming) { - auto* cobj = SE_THIS_OBJECT(s); - SE_PRECONDITION2(cobj, false, "js_scene_SpotLight_setPosition : Invalid Native Object"); + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_scene_ShadowsInfo_setFar : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 1) { + HolderType arg0 = {}; + ok &= sevalue_to_native(args[0], &arg0, s.thisObject()); + SE_PRECONDITION2(ok, false, "js_scene_ShadowsInfo_setFar : Error processing arguments"); + cobj->setFar(arg0.value()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 1); + return false; +} +SE_BIND_FUNC_AS_PROP_SET(js_scene_ShadowsInfo_setFar) + +static bool js_scene_ShadowsInfo_setFixedArea(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_scene_ShadowsInfo_setFixedArea : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 1) { + HolderType arg0 = {}; + ok &= sevalue_to_native(args[0], &arg0, s.thisObject()); + SE_PRECONDITION2(ok, false, "js_scene_ShadowsInfo_setFixedArea : Error processing arguments"); + cobj->setFixedArea(arg0.value()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 1); + return false; +} +SE_BIND_FUNC(js_scene_ShadowsInfo_setFixedArea) + +static bool js_scene_ShadowsInfo_setInvisibleOcclusionRange(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_scene_ShadowsInfo_setInvisibleOcclusionRange : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 1) { + HolderType arg0 = {}; + ok &= sevalue_to_native(args[0], &arg0, s.thisObject()); + SE_PRECONDITION2(ok, false, "js_scene_ShadowsInfo_setInvisibleOcclusionRange : Error processing arguments"); + cobj->setInvisibleOcclusionRange(arg0.value()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 1); + return false; +} +SE_BIND_FUNC_AS_PROP_SET(js_scene_ShadowsInfo_setInvisibleOcclusionRange) + +static bool js_scene_ShadowsInfo_setMaxReceived(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_scene_ShadowsInfo_setMaxReceived : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 1) { + HolderType arg0 = {}; + ok &= sevalue_to_native(args[0], &arg0, s.thisObject()); + SE_PRECONDITION2(ok, false, "js_scene_ShadowsInfo_setMaxReceived : Error processing arguments"); + cobj->setMaxReceived(arg0.value()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 1); + return false; +} +SE_BIND_FUNC_AS_PROP_SET(js_scene_ShadowsInfo_setMaxReceived) + +static bool js_scene_ShadowsInfo_setNear(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_scene_ShadowsInfo_setNear : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 1) { + HolderType arg0 = {}; + ok &= sevalue_to_native(args[0], &arg0, s.thisObject()); + SE_PRECONDITION2(ok, false, "js_scene_ShadowsInfo_setNear : Error processing arguments"); + cobj->setNear(arg0.value()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 1); + return false; +} +SE_BIND_FUNC_AS_PROP_SET(js_scene_ShadowsInfo_setNear) + +static bool js_scene_ShadowsInfo_setNormal(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_scene_ShadowsInfo_setNormal : Invalid Native Object"); const auto& args = s.args(); size_t argc = args.size(); CC_UNUSED bool ok = true; if (argc == 1) { HolderType arg0 = {}; ok &= sevalue_to_native(args[0], &arg0, s.thisObject()); - SE_PRECONDITION2(ok, false, "js_scene_SpotLight_setPosition : Error processing arguments"); - cobj->setPosition(arg0.value()); + SE_PRECONDITION2(ok, false, "js_scene_ShadowsInfo_setNormal : Error processing arguments"); + cobj->setNormal(arg0.value()); return true; } SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 1); return false; } -SE_BIND_FUNC(js_scene_SpotLight_setPosition) +SE_BIND_FUNC_AS_PROP_SET(js_scene_ShadowsInfo_setNormal) -static bool js_scene_SpotLight_setRange(se::State& s) // NOLINT(readability-identifier-naming) +static bool js_scene_ShadowsInfo_setNormalBias(se::State& s) // NOLINT(readability-identifier-naming) { - auto* cobj = SE_THIS_OBJECT(s); - SE_PRECONDITION2(cobj, false, "js_scene_SpotLight_setRange : Invalid Native Object"); + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_scene_ShadowsInfo_setNormalBias : Invalid Native Object"); const auto& args = s.args(); size_t argc = args.size(); CC_UNUSED bool ok = true; if (argc == 1) { HolderType arg0 = {}; ok &= sevalue_to_native(args[0], &arg0, s.thisObject()); - SE_PRECONDITION2(ok, false, "js_scene_SpotLight_setRange : Error processing arguments"); - cobj->setRange(arg0.value()); + SE_PRECONDITION2(ok, false, "js_scene_ShadowsInfo_setNormalBias : Error processing arguments"); + cobj->setNormalBias(arg0.value()); return true; } SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 1); return false; } -SE_BIND_FUNC(js_scene_SpotLight_setRange) +SE_BIND_FUNC_AS_PROP_SET(js_scene_ShadowsInfo_setNormalBias) -static bool js_scene_SpotLight_setSize(se::State& s) // NOLINT(readability-identifier-naming) +static bool js_scene_ShadowsInfo_setOrthoSize(se::State& s) // NOLINT(readability-identifier-naming) { - auto* cobj = SE_THIS_OBJECT(s); - SE_PRECONDITION2(cobj, false, "js_scene_SpotLight_setSize : Invalid Native Object"); + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_scene_ShadowsInfo_setOrthoSize : Invalid Native Object"); const auto& args = s.args(); size_t argc = args.size(); CC_UNUSED bool ok = true; if (argc == 1) { HolderType arg0 = {}; ok &= sevalue_to_native(args[0], &arg0, s.thisObject()); - SE_PRECONDITION2(ok, false, "js_scene_SpotLight_setSize : Error processing arguments"); - cobj->setSize(arg0.value()); + SE_PRECONDITION2(ok, false, "js_scene_ShadowsInfo_setOrthoSize : Error processing arguments"); + cobj->setOrthoSize(arg0.value()); return true; } SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 1); return false; } -SE_BIND_FUNC(js_scene_SpotLight_setSize) +SE_BIND_FUNC_AS_PROP_SET(js_scene_ShadowsInfo_setOrthoSize) -SE_DECLARE_FINALIZE_FUNC(js_cc_scene_SpotLight_finalize) - -static bool js_scene_SpotLight_constructor(se::State& s) // NOLINT(readability-identifier-naming) constructor.c +static bool js_scene_ShadowsInfo_setPcf(se::State& s) // NOLINT(readability-identifier-naming) { - cc::scene::SpotLight* cobj = JSB_ALLOC(cc::scene::SpotLight); - s.thisObject()->setPrivateData(cobj); - se::NonRefNativePtrCreatedByCtorMap::emplace(cobj); - return true; -} -SE_BIND_CTOR(js_scene_SpotLight_constructor, __jsb_cc_scene_SpotLight_class, js_cc_scene_SpotLight_finalize) - - - -static bool js_cc_scene_SpotLight_finalize(se::State& s) // NOLINT(readability-identifier-naming) -{ - auto iter = se::NonRefNativePtrCreatedByCtorMap::find(SE_THIS_OBJECT(s)); - if (iter != se::NonRefNativePtrCreatedByCtorMap::end()) - { - se::NonRefNativePtrCreatedByCtorMap::erase(iter); - auto* cobj = SE_THIS_OBJECT(s); - JSB_FREE(cobj); + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_scene_ShadowsInfo_setPcf : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 1) { + HolderType arg0 = {}; + ok &= sevalue_to_native(args[0], &arg0, s.thisObject()); + SE_PRECONDITION2(ok, false, "js_scene_ShadowsInfo_setPcf : Error processing arguments"); + cobj->setPcf(arg0.value()); + return true; } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 1); + return false; +} +SE_BIND_FUNC_AS_PROP_SET(js_scene_ShadowsInfo_setPcf) + +static bool js_scene_ShadowsInfo_setPlaneFromNode(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_scene_ShadowsInfo_setPlaneFromNode : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 1) { + HolderType arg0 = {}; + ok &= sevalue_to_native(args[0], &arg0, s.thisObject()); + SE_PRECONDITION2(ok, false, "js_scene_ShadowsInfo_setPlaneFromNode : Error processing arguments"); + cobj->setPlaneFromNode(arg0.value()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 1); + return false; +} +SE_BIND_FUNC(js_scene_ShadowsInfo_setPlaneFromNode) + +static bool js_scene_ShadowsInfo_setSaturation(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_scene_ShadowsInfo_setSaturation : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 1) { + HolderType arg0 = {}; + ok &= sevalue_to_native(args[0], &arg0, s.thisObject()); + SE_PRECONDITION2(ok, false, "js_scene_ShadowsInfo_setSaturation : Error processing arguments"); + cobj->setSaturation(arg0.value()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 1); + return false; +} +SE_BIND_FUNC_AS_PROP_SET(js_scene_ShadowsInfo_setSaturation) + +static bool js_scene_ShadowsInfo_setShadowColor(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_scene_ShadowsInfo_setShadowColor : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 1) { + HolderType arg0 = {}; + ok &= sevalue_to_native(args[0], &arg0, s.thisObject()); + SE_PRECONDITION2(ok, false, "js_scene_ShadowsInfo_setShadowColor : Error processing arguments"); + cobj->setShadowColor(arg0.value()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 1); + return false; +} +SE_BIND_FUNC_AS_PROP_SET(js_scene_ShadowsInfo_setShadowColor) + +static bool js_scene_ShadowsInfo_setShadowDistance(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_scene_ShadowsInfo_setShadowDistance : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 1) { + HolderType arg0 = {}; + ok &= sevalue_to_native(args[0], &arg0, s.thisObject()); + SE_PRECONDITION2(ok, false, "js_scene_ShadowsInfo_setShadowDistance : Error processing arguments"); + cobj->setShadowDistance(arg0.value()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 1); + return false; +} +SE_BIND_FUNC_AS_PROP_SET(js_scene_ShadowsInfo_setShadowDistance) + +static bool js_scene_ShadowsInfo_setShadowMapSize(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_scene_ShadowsInfo_setShadowMapSize : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 1) { + HolderType arg0 = {}; + ok &= sevalue_to_native(args[0], &arg0, s.thisObject()); + SE_PRECONDITION2(ok, false, "js_scene_ShadowsInfo_setShadowMapSize : Error processing arguments"); + cobj->setShadowMapSize(arg0.value()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 1); + return false; +} +SE_BIND_FUNC(js_scene_ShadowsInfo_setShadowMapSize) + +static bool js_scene_ShadowsInfo_setType(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_scene_ShadowsInfo_setType : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 1) { + HolderType arg0 = {}; + ok &= sevalue_to_native(args[0], &arg0, s.thisObject()); + SE_PRECONDITION2(ok, false, "js_scene_ShadowsInfo_setType : Error processing arguments"); + cobj->setType(arg0.value()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 1); + return false; +} +SE_BIND_FUNC_AS_PROP_SET(js_scene_ShadowsInfo_setType) + +static bool js_scene_ShadowsInfo_get__distance(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_scene_ShadowsInfo_get__distance : Invalid Native Object"); + + CC_UNUSED bool ok = true; + se::Value jsret; + ok &= nativevalue_to_se(cobj->_distance, jsret, s.thisObject() /*ctx*/); + s.rval() = jsret; + SE_HOLD_RETURN_VALUE(cobj->_distance, s.thisObject(), s.rval()); return true; } -SE_BIND_FINALIZE_FUNC(js_cc_scene_SpotLight_finalize) +SE_BIND_PROP_GET(js_scene_ShadowsInfo_get__distance) -bool js_register_scene_SpotLight(se::Object* obj) // NOLINT(readability-identifier-naming) +static bool js_scene_ShadowsInfo_set__distance(se::State& s) // NOLINT(readability-identifier-naming) { - auto* cls = se::Class::create("SpotLight", obj, __jsb_cc_scene_Light_proto, _SE(js_scene_SpotLight_constructor)); + const auto& args = s.args(); + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_scene_ShadowsInfo_set__distance : Invalid Native Object"); - cls->defineFunction("setAABB", _SE(js_scene_SpotLight_setAABB)); - cls->defineFunction("setAngle", _SE(js_scene_SpotLight_setAngle)); - cls->defineFunction("setAspect", _SE(js_scene_SpotLight_setAspect)); - cls->defineFunction("setDirection", _SE(js_scene_SpotLight_setDirection)); - cls->defineFunction("setFrustum", _SE(js_scene_SpotLight_setFrustum)); - cls->defineFunction("setLuminanceHDR", _SE(js_scene_SpotLight_setLuminanceHDR)); - cls->defineFunction("setLuminanceLDR", _SE(js_scene_SpotLight_setLuminanceLDR)); - cls->defineFunction("setNeedUpdate", _SE(js_scene_SpotLight_setNeedUpdate)); - cls->defineFunction("setPosition", _SE(js_scene_SpotLight_setPosition)); - cls->defineFunction("setRange", _SE(js_scene_SpotLight_setRange)); - cls->defineFunction("setSize", _SE(js_scene_SpotLight_setSize)); - cls->defineFinalizeFunction(_SE(js_cc_scene_SpotLight_finalize)); + CC_UNUSED bool ok = true; + ok &= sevalue_to_native(args[0], &cobj->_distance, s.thisObject()); + SE_PRECONDITION2(ok, false, "js_scene_ShadowsInfo_set__distance : Error processing new value"); + return true; +} +SE_BIND_PROP_SET(js_scene_ShadowsInfo_set__distance) + +static bool js_scene_ShadowsInfo_get__bias(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_scene_ShadowsInfo_get__bias : Invalid Native Object"); + + CC_UNUSED bool ok = true; + se::Value jsret; + ok &= nativevalue_to_se(cobj->_bias, jsret, s.thisObject() /*ctx*/); + s.rval() = jsret; + SE_HOLD_RETURN_VALUE(cobj->_bias, s.thisObject(), s.rval()); + return true; +} +SE_BIND_PROP_GET(js_scene_ShadowsInfo_get__bias) + +static bool js_scene_ShadowsInfo_set__bias(se::State& s) // NOLINT(readability-identifier-naming) +{ + const auto& args = s.args(); + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_scene_ShadowsInfo_set__bias : Invalid Native Object"); + + CC_UNUSED bool ok = true; + ok &= sevalue_to_native(args[0], &cobj->_bias, s.thisObject()); + SE_PRECONDITION2(ok, false, "js_scene_ShadowsInfo_set__bias : Error processing new value"); + return true; +} +SE_BIND_PROP_SET(js_scene_ShadowsInfo_set__bias) + +static bool js_scene_ShadowsInfo_get__normalBias(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_scene_ShadowsInfo_get__normalBias : Invalid Native Object"); + + CC_UNUSED bool ok = true; + se::Value jsret; + ok &= nativevalue_to_se(cobj->_normalBias, jsret, s.thisObject() /*ctx*/); + s.rval() = jsret; + SE_HOLD_RETURN_VALUE(cobj->_normalBias, s.thisObject(), s.rval()); + return true; +} +SE_BIND_PROP_GET(js_scene_ShadowsInfo_get__normalBias) + +static bool js_scene_ShadowsInfo_set__normalBias(se::State& s) // NOLINT(readability-identifier-naming) +{ + const auto& args = s.args(); + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_scene_ShadowsInfo_set__normalBias : Invalid Native Object"); + + CC_UNUSED bool ok = true; + ok &= sevalue_to_native(args[0], &cobj->_normalBias, s.thisObject()); + SE_PRECONDITION2(ok, false, "js_scene_ShadowsInfo_set__normalBias : Error processing new value"); + return true; +} +SE_BIND_PROP_SET(js_scene_ShadowsInfo_set__normalBias) + +static bool js_scene_ShadowsInfo_get__near(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_scene_ShadowsInfo_get__near : Invalid Native Object"); + + CC_UNUSED bool ok = true; + se::Value jsret; + ok &= nativevalue_to_se(cobj->_near, jsret, s.thisObject() /*ctx*/); + s.rval() = jsret; + SE_HOLD_RETURN_VALUE(cobj->_near, s.thisObject(), s.rval()); + return true; +} +SE_BIND_PROP_GET(js_scene_ShadowsInfo_get__near) + +static bool js_scene_ShadowsInfo_set__near(se::State& s) // NOLINT(readability-identifier-naming) +{ + const auto& args = s.args(); + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_scene_ShadowsInfo_set__near : Invalid Native Object"); + + CC_UNUSED bool ok = true; + ok &= sevalue_to_native(args[0], &cobj->_near, s.thisObject()); + SE_PRECONDITION2(ok, false, "js_scene_ShadowsInfo_set__near : Error processing new value"); + return true; +} +SE_BIND_PROP_SET(js_scene_ShadowsInfo_set__near) + +static bool js_scene_ShadowsInfo_get__far(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_scene_ShadowsInfo_get__far : Invalid Native Object"); + + CC_UNUSED bool ok = true; + se::Value jsret; + ok &= nativevalue_to_se(cobj->_far, jsret, s.thisObject() /*ctx*/); + s.rval() = jsret; + SE_HOLD_RETURN_VALUE(cobj->_far, s.thisObject(), s.rval()); + return true; +} +SE_BIND_PROP_GET(js_scene_ShadowsInfo_get__far) + +static bool js_scene_ShadowsInfo_set__far(se::State& s) // NOLINT(readability-identifier-naming) +{ + const auto& args = s.args(); + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_scene_ShadowsInfo_set__far : Invalid Native Object"); + + CC_UNUSED bool ok = true; + ok &= sevalue_to_native(args[0], &cobj->_far, s.thisObject()); + SE_PRECONDITION2(ok, false, "js_scene_ShadowsInfo_set__far : Error processing new value"); + return true; +} +SE_BIND_PROP_SET(js_scene_ShadowsInfo_set__far) + +static bool js_scene_ShadowsInfo_get__shadowDistance(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_scene_ShadowsInfo_get__shadowDistance : Invalid Native Object"); + + CC_UNUSED bool ok = true; + se::Value jsret; + ok &= nativevalue_to_se(cobj->_shadowDistance, jsret, s.thisObject() /*ctx*/); + s.rval() = jsret; + SE_HOLD_RETURN_VALUE(cobj->_shadowDistance, s.thisObject(), s.rval()); + return true; +} +SE_BIND_PROP_GET(js_scene_ShadowsInfo_get__shadowDistance) + +static bool js_scene_ShadowsInfo_set__shadowDistance(se::State& s) // NOLINT(readability-identifier-naming) +{ + const auto& args = s.args(); + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_scene_ShadowsInfo_set__shadowDistance : Invalid Native Object"); + + CC_UNUSED bool ok = true; + ok &= sevalue_to_native(args[0], &cobj->_shadowDistance, s.thisObject()); + SE_PRECONDITION2(ok, false, "js_scene_ShadowsInfo_set__shadowDistance : Error processing new value"); + return true; +} +SE_BIND_PROP_SET(js_scene_ShadowsInfo_set__shadowDistance) + +static bool js_scene_ShadowsInfo_get__invisibleOcclusionRange(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_scene_ShadowsInfo_get__invisibleOcclusionRange : Invalid Native Object"); + + CC_UNUSED bool ok = true; + se::Value jsret; + ok &= nativevalue_to_se(cobj->_invisibleOcclusionRange, jsret, s.thisObject() /*ctx*/); + s.rval() = jsret; + SE_HOLD_RETURN_VALUE(cobj->_invisibleOcclusionRange, s.thisObject(), s.rval()); + return true; +} +SE_BIND_PROP_GET(js_scene_ShadowsInfo_get__invisibleOcclusionRange) + +static bool js_scene_ShadowsInfo_set__invisibleOcclusionRange(se::State& s) // NOLINT(readability-identifier-naming) +{ + const auto& args = s.args(); + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_scene_ShadowsInfo_set__invisibleOcclusionRange : Invalid Native Object"); + + CC_UNUSED bool ok = true; + ok &= sevalue_to_native(args[0], &cobj->_invisibleOcclusionRange, s.thisObject()); + SE_PRECONDITION2(ok, false, "js_scene_ShadowsInfo_set__invisibleOcclusionRange : Error processing new value"); + return true; +} +SE_BIND_PROP_SET(js_scene_ShadowsInfo_set__invisibleOcclusionRange) + +static bool js_scene_ShadowsInfo_get__orthoSize(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_scene_ShadowsInfo_get__orthoSize : Invalid Native Object"); + + CC_UNUSED bool ok = true; + se::Value jsret; + ok &= nativevalue_to_se(cobj->_orthoSize, jsret, s.thisObject() /*ctx*/); + s.rval() = jsret; + SE_HOLD_RETURN_VALUE(cobj->_orthoSize, s.thisObject(), s.rval()); + return true; +} +SE_BIND_PROP_GET(js_scene_ShadowsInfo_get__orthoSize) + +static bool js_scene_ShadowsInfo_set__orthoSize(se::State& s) // NOLINT(readability-identifier-naming) +{ + const auto& args = s.args(); + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_scene_ShadowsInfo_set__orthoSize : Invalid Native Object"); + + CC_UNUSED bool ok = true; + ok &= sevalue_to_native(args[0], &cobj->_orthoSize, s.thisObject()); + SE_PRECONDITION2(ok, false, "js_scene_ShadowsInfo_set__orthoSize : Error processing new value"); + return true; +} +SE_BIND_PROP_SET(js_scene_ShadowsInfo_set__orthoSize) + +static bool js_scene_ShadowsInfo_get__saturation(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_scene_ShadowsInfo_get__saturation : Invalid Native Object"); + + CC_UNUSED bool ok = true; + se::Value jsret; + ok &= nativevalue_to_se(cobj->_saturation, jsret, s.thisObject() /*ctx*/); + s.rval() = jsret; + SE_HOLD_RETURN_VALUE(cobj->_saturation, s.thisObject(), s.rval()); + return true; +} +SE_BIND_PROP_GET(js_scene_ShadowsInfo_get__saturation) + +static bool js_scene_ShadowsInfo_set__saturation(se::State& s) // NOLINT(readability-identifier-naming) +{ + const auto& args = s.args(); + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_scene_ShadowsInfo_set__saturation : Invalid Native Object"); + + CC_UNUSED bool ok = true; + ok &= sevalue_to_native(args[0], &cobj->_saturation, s.thisObject()); + SE_PRECONDITION2(ok, false, "js_scene_ShadowsInfo_set__saturation : Error processing new value"); + return true; +} +SE_BIND_PROP_SET(js_scene_ShadowsInfo_set__saturation) + +static bool js_scene_ShadowsInfo_get__maxReceived(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_scene_ShadowsInfo_get__maxReceived : Invalid Native Object"); + + CC_UNUSED bool ok = true; + se::Value jsret; + ok &= nativevalue_to_se(cobj->_maxReceived, jsret, s.thisObject() /*ctx*/); + s.rval() = jsret; + SE_HOLD_RETURN_VALUE(cobj->_maxReceived, s.thisObject(), s.rval()); + return true; +} +SE_BIND_PROP_GET(js_scene_ShadowsInfo_get__maxReceived) + +static bool js_scene_ShadowsInfo_set__maxReceived(se::State& s) // NOLINT(readability-identifier-naming) +{ + const auto& args = s.args(); + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_scene_ShadowsInfo_set__maxReceived : Invalid Native Object"); + + CC_UNUSED bool ok = true; + ok &= sevalue_to_native(args[0], &cobj->_maxReceived, s.thisObject()); + SE_PRECONDITION2(ok, false, "js_scene_ShadowsInfo_set__maxReceived : Error processing new value"); + return true; +} +SE_BIND_PROP_SET(js_scene_ShadowsInfo_set__maxReceived) + +static bool js_scene_ShadowsInfo_get__pcf(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_scene_ShadowsInfo_get__pcf : Invalid Native Object"); + + CC_UNUSED bool ok = true; + se::Value jsret; + ok &= nativevalue_to_se(cobj->_pcf, jsret, s.thisObject() /*ctx*/); + s.rval() = jsret; + SE_HOLD_RETURN_VALUE(cobj->_pcf, s.thisObject(), s.rval()); + return true; +} +SE_BIND_PROP_GET(js_scene_ShadowsInfo_get__pcf) + +static bool js_scene_ShadowsInfo_set__pcf(se::State& s) // NOLINT(readability-identifier-naming) +{ + const auto& args = s.args(); + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_scene_ShadowsInfo_set__pcf : Invalid Native Object"); + + CC_UNUSED bool ok = true; + ok &= sevalue_to_native(args[0], &cobj->_pcf, s.thisObject()); + SE_PRECONDITION2(ok, false, "js_scene_ShadowsInfo_set__pcf : Error processing new value"); + return true; +} +SE_BIND_PROP_SET(js_scene_ShadowsInfo_set__pcf) + +static bool js_scene_ShadowsInfo_get__type(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_scene_ShadowsInfo_get__type : Invalid Native Object"); + + CC_UNUSED bool ok = true; + se::Value jsret; + ok &= nativevalue_to_se(cobj->_type, jsret, s.thisObject() /*ctx*/); + s.rval() = jsret; + SE_HOLD_RETURN_VALUE(cobj->_type, s.thisObject(), s.rval()); + return true; +} +SE_BIND_PROP_GET(js_scene_ShadowsInfo_get__type) + +static bool js_scene_ShadowsInfo_set__type(se::State& s) // NOLINT(readability-identifier-naming) +{ + const auto& args = s.args(); + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_scene_ShadowsInfo_set__type : Invalid Native Object"); + + CC_UNUSED bool ok = true; + ok &= sevalue_to_native(args[0], &cobj->_type, s.thisObject()); + SE_PRECONDITION2(ok, false, "js_scene_ShadowsInfo_set__type : Error processing new value"); + return true; +} +SE_BIND_PROP_SET(js_scene_ShadowsInfo_set__type) + +static bool js_scene_ShadowsInfo_get__shadowColor(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_scene_ShadowsInfo_get__shadowColor : Invalid Native Object"); + + CC_UNUSED bool ok = true; + se::Value jsret; + ok &= nativevalue_to_se(cobj->_shadowColor, jsret, s.thisObject() /*ctx*/); + s.rval() = jsret; + SE_HOLD_RETURN_VALUE(cobj->_shadowColor, s.thisObject(), s.rval()); + return true; +} +SE_BIND_PROP_GET(js_scene_ShadowsInfo_get__shadowColor) + +static bool js_scene_ShadowsInfo_set__shadowColor(se::State& s) // NOLINT(readability-identifier-naming) +{ + const auto& args = s.args(); + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_scene_ShadowsInfo_set__shadowColor : Invalid Native Object"); + + CC_UNUSED bool ok = true; + ok &= sevalue_to_native(args[0], &cobj->_shadowColor, s.thisObject()); + SE_PRECONDITION2(ok, false, "js_scene_ShadowsInfo_set__shadowColor : Error processing new value"); + return true; +} +SE_BIND_PROP_SET(js_scene_ShadowsInfo_set__shadowColor) + +static bool js_scene_ShadowsInfo_get__normal(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_scene_ShadowsInfo_get__normal : Invalid Native Object"); + + CC_UNUSED bool ok = true; + se::Value jsret; + ok &= nativevalue_to_se(cobj->_normal, jsret, s.thisObject() /*ctx*/); + s.rval() = jsret; + SE_HOLD_RETURN_VALUE(cobj->_normal, s.thisObject(), s.rval()); + return true; +} +SE_BIND_PROP_GET(js_scene_ShadowsInfo_get__normal) + +static bool js_scene_ShadowsInfo_set__normal(se::State& s) // NOLINT(readability-identifier-naming) +{ + const auto& args = s.args(); + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_scene_ShadowsInfo_set__normal : Invalid Native Object"); + + CC_UNUSED bool ok = true; + ok &= sevalue_to_native(args[0], &cobj->_normal, s.thisObject()); + SE_PRECONDITION2(ok, false, "js_scene_ShadowsInfo_set__normal : Error processing new value"); + return true; +} +SE_BIND_PROP_SET(js_scene_ShadowsInfo_set__normal) + +static bool js_scene_ShadowsInfo_get__size(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_scene_ShadowsInfo_get__size : Invalid Native Object"); + + CC_UNUSED bool ok = true; + se::Value jsret; + ok &= nativevalue_to_se(cobj->_size, jsret, s.thisObject() /*ctx*/); + s.rval() = jsret; + SE_HOLD_RETURN_VALUE(cobj->_size, s.thisObject(), s.rval()); + return true; +} +SE_BIND_PROP_GET(js_scene_ShadowsInfo_get__size) + +static bool js_scene_ShadowsInfo_set__size(se::State& s) // NOLINT(readability-identifier-naming) +{ + const auto& args = s.args(); + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_scene_ShadowsInfo_set__size : Invalid Native Object"); + + CC_UNUSED bool ok = true; + ok &= sevalue_to_native(args[0], &cobj->_size, s.thisObject()); + SE_PRECONDITION2(ok, false, "js_scene_ShadowsInfo_set__size : Error processing new value"); + return true; +} +SE_BIND_PROP_SET(js_scene_ShadowsInfo_set__size) + +static bool js_scene_ShadowsInfo_get__firstSetCSM(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_scene_ShadowsInfo_get__firstSetCSM : Invalid Native Object"); + + CC_UNUSED bool ok = true; + se::Value jsret; + ok &= nativevalue_to_se(cobj->_firstSetCSM, jsret, s.thisObject() /*ctx*/); + s.rval() = jsret; + SE_HOLD_RETURN_VALUE(cobj->_firstSetCSM, s.thisObject(), s.rval()); + return true; +} +SE_BIND_PROP_GET(js_scene_ShadowsInfo_get__firstSetCSM) + +static bool js_scene_ShadowsInfo_set__firstSetCSM(se::State& s) // NOLINT(readability-identifier-naming) +{ + const auto& args = s.args(); + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_scene_ShadowsInfo_set__firstSetCSM : Invalid Native Object"); + + CC_UNUSED bool ok = true; + ok &= sevalue_to_native(args[0], &cobj->_firstSetCSM, s.thisObject()); + SE_PRECONDITION2(ok, false, "js_scene_ShadowsInfo_set__firstSetCSM : Error processing new value"); + return true; +} +SE_BIND_PROP_SET(js_scene_ShadowsInfo_set__firstSetCSM) + +static bool js_scene_ShadowsInfo_get__fixedArea(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_scene_ShadowsInfo_get__fixedArea : Invalid Native Object"); + + CC_UNUSED bool ok = true; + se::Value jsret; + ok &= nativevalue_to_se(cobj->_fixedArea, jsret, s.thisObject() /*ctx*/); + s.rval() = jsret; + SE_HOLD_RETURN_VALUE(cobj->_fixedArea, s.thisObject(), s.rval()); + return true; +} +SE_BIND_PROP_GET(js_scene_ShadowsInfo_get__fixedArea) + +static bool js_scene_ShadowsInfo_set__fixedArea(se::State& s) // NOLINT(readability-identifier-naming) +{ + const auto& args = s.args(); + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_scene_ShadowsInfo_set__fixedArea : Invalid Native Object"); + + CC_UNUSED bool ok = true; + ok &= sevalue_to_native(args[0], &cobj->_fixedArea, s.thisObject()); + SE_PRECONDITION2(ok, false, "js_scene_ShadowsInfo_set__fixedArea : Error processing new value"); + return true; +} +SE_BIND_PROP_SET(js_scene_ShadowsInfo_set__fixedArea) + +static bool js_scene_ShadowsInfo_get__enabled(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_scene_ShadowsInfo_get__enabled : Invalid Native Object"); + + CC_UNUSED bool ok = true; + se::Value jsret; + ok &= nativevalue_to_se(cobj->_enabled, jsret, s.thisObject() /*ctx*/); + s.rval() = jsret; + SE_HOLD_RETURN_VALUE(cobj->_enabled, s.thisObject(), s.rval()); + return true; +} +SE_BIND_PROP_GET(js_scene_ShadowsInfo_get__enabled) + +static bool js_scene_ShadowsInfo_set__enabled(se::State& s) // NOLINT(readability-identifier-naming) +{ + const auto& args = s.args(); + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_scene_ShadowsInfo_set__enabled : Invalid Native Object"); + + CC_UNUSED bool ok = true; + ok &= sevalue_to_native(args[0], &cobj->_enabled, s.thisObject()); + SE_PRECONDITION2(ok, false, "js_scene_ShadowsInfo_set__enabled : Error processing new value"); + return true; +} +SE_BIND_PROP_SET(js_scene_ShadowsInfo_set__enabled) + +SE_DECLARE_FINALIZE_FUNC(js_cc_scene_ShadowsInfo_finalize) + +static bool js_scene_ShadowsInfo_constructor(se::State& s) // NOLINT(readability-identifier-naming) constructor.c +{ + auto *ptr = JSB_MAKE_PRIVATE_OBJECT(cc::scene::ShadowsInfo); + s.thisObject()->setPrivateObject(ptr); + return true; +} +SE_BIND_CTOR(js_scene_ShadowsInfo_constructor, __jsb_cc_scene_ShadowsInfo_class, js_cc_scene_ShadowsInfo_finalize) + +static bool js_cc_scene_ShadowsInfo_finalize(se::State& s) // NOLINT(readability-identifier-naming) +{ + return true; +} +SE_BIND_FINALIZE_FUNC(js_cc_scene_ShadowsInfo_finalize) + +bool js_register_scene_ShadowsInfo(se::Object* obj) // NOLINT(readability-identifier-naming) +{ + auto* cls = se::Class::create("ShadowsInfo", obj, nullptr, _SE(js_scene_ShadowsInfo_constructor)); + + cls->defineProperty("_distance", _SE(js_scene_ShadowsInfo_get__distance), _SE(js_scene_ShadowsInfo_set__distance)); + cls->defineProperty("_bias", _SE(js_scene_ShadowsInfo_get__bias), _SE(js_scene_ShadowsInfo_set__bias)); + cls->defineProperty("_normalBias", _SE(js_scene_ShadowsInfo_get__normalBias), _SE(js_scene_ShadowsInfo_set__normalBias)); + cls->defineProperty("_near", _SE(js_scene_ShadowsInfo_get__near), _SE(js_scene_ShadowsInfo_set__near)); + cls->defineProperty("_far", _SE(js_scene_ShadowsInfo_get__far), _SE(js_scene_ShadowsInfo_set__far)); + cls->defineProperty("_shadowDistance", _SE(js_scene_ShadowsInfo_get__shadowDistance), _SE(js_scene_ShadowsInfo_set__shadowDistance)); + cls->defineProperty("_invisibleOcclusionRange", _SE(js_scene_ShadowsInfo_get__invisibleOcclusionRange), _SE(js_scene_ShadowsInfo_set__invisibleOcclusionRange)); + cls->defineProperty("_orthoSize", _SE(js_scene_ShadowsInfo_get__orthoSize), _SE(js_scene_ShadowsInfo_set__orthoSize)); + cls->defineProperty("_saturation", _SE(js_scene_ShadowsInfo_get__saturation), _SE(js_scene_ShadowsInfo_set__saturation)); + cls->defineProperty("_maxReceived", _SE(js_scene_ShadowsInfo_get__maxReceived), _SE(js_scene_ShadowsInfo_set__maxReceived)); + cls->defineProperty("_pcf", _SE(js_scene_ShadowsInfo_get__pcf), _SE(js_scene_ShadowsInfo_set__pcf)); + cls->defineProperty("_type", _SE(js_scene_ShadowsInfo_get__type), _SE(js_scene_ShadowsInfo_set__type)); + cls->defineProperty("_shadowColor", _SE(js_scene_ShadowsInfo_get__shadowColor), _SE(js_scene_ShadowsInfo_set__shadowColor)); + cls->defineProperty("_normal", _SE(js_scene_ShadowsInfo_get__normal), _SE(js_scene_ShadowsInfo_set__normal)); + cls->defineProperty("_size", _SE(js_scene_ShadowsInfo_get__size), _SE(js_scene_ShadowsInfo_set__size)); + cls->defineProperty("_firstSetCSM", _SE(js_scene_ShadowsInfo_get__firstSetCSM), _SE(js_scene_ShadowsInfo_set__firstSetCSM)); + cls->defineProperty("_fixedArea", _SE(js_scene_ShadowsInfo_get__fixedArea), _SE(js_scene_ShadowsInfo_set__fixedArea)); + cls->defineProperty("_enabled", _SE(js_scene_ShadowsInfo_get__enabled), _SE(js_scene_ShadowsInfo_set__enabled)); + cls->defineProperty("size", _SE(js_scene_ShadowsInfo_getSize_asGetter), nullptr); + cls->defineProperty("distance", _SE(js_scene_ShadowsInfo_getDistance_asGetter), _SE(js_scene_ShadowsInfo_setDistance_asSetter)); + cls->defineProperty("saturation", _SE(js_scene_ShadowsInfo_getSaturation_asGetter), _SE(js_scene_ShadowsInfo_setSaturation_asSetter)); + cls->defineProperty("invisibleOcclusionRange", _SE(js_scene_ShadowsInfo_getInvisibleOcclusionRange_asGetter), _SE(js_scene_ShadowsInfo_setInvisibleOcclusionRange_asSetter)); + cls->defineProperty("normal", _SE(js_scene_ShadowsInfo_getNormal_asGetter), _SE(js_scene_ShadowsInfo_setNormal_asSetter)); + cls->defineProperty("far", _SE(js_scene_ShadowsInfo_getFar_asGetter), _SE(js_scene_ShadowsInfo_setFar_asSetter)); + cls->defineProperty("fixedArea", _SE(js_scene_ShadowsInfo_isFixedArea_asGetter), _SE(js_scene_ShadowsInfo_isFixedArea_asSetter)); + cls->defineProperty("enabled", _SE(js_scene_ShadowsInfo_isEnabled_asGetter), _SE(js_scene_ShadowsInfo_setEnabled_asSetter)); + cls->defineProperty("near", _SE(js_scene_ShadowsInfo_getNear_asGetter), _SE(js_scene_ShadowsInfo_setNear_asSetter)); + cls->defineProperty("orthoSize", _SE(js_scene_ShadowsInfo_getOrthoSize_asGetter), _SE(js_scene_ShadowsInfo_setOrthoSize_asSetter)); + cls->defineProperty("shadowColor", _SE(js_scene_ShadowsInfo_getShadowColor_asGetter), _SE(js_scene_ShadowsInfo_setShadowColor_asSetter)); + cls->defineProperty("bias", _SE(js_scene_ShadowsInfo_getBias_asGetter), _SE(js_scene_ShadowsInfo_setBias_asSetter)); + cls->defineProperty("maxReceived", _SE(js_scene_ShadowsInfo_getMaxReceived_asGetter), _SE(js_scene_ShadowsInfo_setMaxReceived_asSetter)); + cls->defineProperty("normalBias", _SE(js_scene_ShadowsInfo_getNormalBias_asGetter), _SE(js_scene_ShadowsInfo_setNormalBias_asSetter)); + cls->defineProperty("shadowDistance", _SE(js_scene_ShadowsInfo_getShadowDistance_asGetter), _SE(js_scene_ShadowsInfo_setShadowDistance_asSetter)); + cls->defineProperty("type", _SE(js_scene_ShadowsInfo_getType_asGetter), _SE(js_scene_ShadowsInfo_setType_asSetter)); + cls->defineProperty("pcf", _SE(js_scene_ShadowsInfo_getPcf_asGetter), _SE(js_scene_ShadowsInfo_setPcf_asSetter)); + cls->defineFunction("activate", _SE(js_scene_ShadowsInfo_activate)); + cls->defineFunction("getShadowMapSize", _SE(js_scene_ShadowsInfo_getShadowMapSize)); + cls->defineFunction("setFixedArea", _SE(js_scene_ShadowsInfo_setFixedArea)); + cls->defineFunction("setPlaneFromNode", _SE(js_scene_ShadowsInfo_setPlaneFromNode)); + cls->defineFunction("setShadowMapSize", _SE(js_scene_ShadowsInfo_setShadowMapSize)); + cls->defineFinalizeFunction(_SE(js_cc_scene_ShadowsInfo_finalize)); cls->install(); - JSBClassType::registerClass(cls); + JSBClassType::registerClass(cls); + + __jsb_cc_scene_ShadowsInfo_proto = cls->getProto(); + __jsb_cc_scene_ShadowsInfo_class = cls; - __jsb_cc_scene_SpotLight_proto = cls->getProto(); - __jsb_cc_scene_SpotLight_class = cls; se::ScriptEngine::getInstance()->clearException(); return true; } -se::Object* __jsb_cc_scene_SphereLight_proto = nullptr; -se::Class* __jsb_cc_scene_SphereLight_class = nullptr; +se::Object* __jsb_cc_scene_Shadows_proto = nullptr; // NOLINT +se::Class* __jsb_cc_scene_Shadows_class = nullptr; // NOLINT -static bool js_scene_SphereLight_setAABB(se::State& s) // NOLINT(readability-identifier-naming) +static bool js_scene_Shadows_activate(se::State& s) // NOLINT(readability-identifier-naming) { - auto* cobj = SE_THIS_OBJECT(s); - SE_PRECONDITION2(cobj, false, "js_scene_SphereLight_setAABB : Invalid Native Object"); + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_scene_Shadows_activate : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + if (argc == 0) { + cobj->activate(); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 0); + return false; +} +SE_BIND_FUNC(js_scene_Shadows_activate) + +static bool js_scene_Shadows_destroy(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_scene_Shadows_destroy : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + if (argc == 0) { + cobj->destroy(); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 0); + return false; +} +SE_BIND_FUNC(js_scene_Shadows_destroy) + +static bool js_scene_Shadows_getBias(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_scene_Shadows_getBias : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 0) { + float result = cobj->getBias(); + ok &= nativevalue_to_se(result, s.rval(), nullptr /*ctx*/); + SE_PRECONDITION2(ok, false, "js_scene_Shadows_getBias : Error processing arguments"); + SE_HOLD_RETURN_VALUE(result, s.thisObject(), s.rval()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 0); + return false; +} +SE_BIND_FUNC_AS_PROP_GET(js_scene_Shadows_getBias) + +static bool js_scene_Shadows_getDistance(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_scene_Shadows_getDistance : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 0) { + float result = cobj->getDistance(); + ok &= nativevalue_to_se(result, s.rval(), nullptr /*ctx*/); + SE_PRECONDITION2(ok, false, "js_scene_Shadows_getDistance : Error processing arguments"); + SE_HOLD_RETURN_VALUE(result, s.thisObject(), s.rval()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 0); + return false; +} +SE_BIND_FUNC_AS_PROP_GET(js_scene_Shadows_getDistance) + +static bool js_scene_Shadows_getFar(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_scene_Shadows_getFar : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 0) { + float result = cobj->getFar(); + ok &= nativevalue_to_se(result, s.rval(), nullptr /*ctx*/); + SE_PRECONDITION2(ok, false, "js_scene_Shadows_getFar : Error processing arguments"); + SE_HOLD_RETURN_VALUE(result, s.thisObject(), s.rval()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 0); + return false; +} +SE_BIND_FUNC_AS_PROP_GET(js_scene_Shadows_getFar) + +static bool js_scene_Shadows_getInstancingMaterial(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_scene_Shadows_getInstancingMaterial : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 0) { + cc::Material* result = cobj->getInstancingMaterial(); + ok &= nativevalue_to_se(result, s.rval(), nullptr /*ctx*/); + SE_PRECONDITION2(ok, false, "js_scene_Shadows_getInstancingMaterial : Error processing arguments"); + SE_HOLD_RETURN_VALUE(result, s.thisObject(), s.rval()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 0); + return false; +} +SE_BIND_FUNC_AS_PROP_GET(js_scene_Shadows_getInstancingMaterial) + +static bool js_scene_Shadows_getInvisibleOcclusionRange(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_scene_Shadows_getInvisibleOcclusionRange : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 0) { + float result = cobj->getInvisibleOcclusionRange(); + ok &= nativevalue_to_se(result, s.rval(), nullptr /*ctx*/); + SE_PRECONDITION2(ok, false, "js_scene_Shadows_getInvisibleOcclusionRange : Error processing arguments"); + SE_HOLD_RETURN_VALUE(result, s.thisObject(), s.rval()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 0); + return false; +} +SE_BIND_FUNC_AS_PROP_GET(js_scene_Shadows_getInvisibleOcclusionRange) + +static bool js_scene_Shadows_getMatLight(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_scene_Shadows_getMatLight : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 0) { + const cc::Mat4& result = cobj->getMatLight(); + ok &= nativevalue_to_se(result, s.rval(), nullptr /*ctx*/); + SE_PRECONDITION2(ok, false, "js_scene_Shadows_getMatLight : Error processing arguments"); + SE_HOLD_RETURN_VALUE(result, s.thisObject(), s.rval()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 0); + return false; +} +SE_BIND_FUNC_AS_PROP_GET(js_scene_Shadows_getMatLight) + +static bool js_scene_Shadows_getMaterial(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_scene_Shadows_getMaterial : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 0) { + cc::Material* result = cobj->getMaterial(); + ok &= nativevalue_to_se(result, s.rval(), nullptr /*ctx*/); + SE_PRECONDITION2(ok, false, "js_scene_Shadows_getMaterial : Error processing arguments"); + SE_HOLD_RETURN_VALUE(result, s.thisObject(), s.rval()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 0); + return false; +} +SE_BIND_FUNC(js_scene_Shadows_getMaterial) + +static bool js_scene_Shadows_getMaxReceived(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_scene_Shadows_getMaxReceived : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 0) { + unsigned int result = cobj->getMaxReceived(); + ok &= nativevalue_to_se(result, s.rval(), nullptr /*ctx*/); + SE_PRECONDITION2(ok, false, "js_scene_Shadows_getMaxReceived : Error processing arguments"); + SE_HOLD_RETURN_VALUE(result, s.thisObject(), s.rval()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 0); + return false; +} +SE_BIND_FUNC(js_scene_Shadows_getMaxReceived) + +static bool js_scene_Shadows_getNear(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_scene_Shadows_getNear : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 0) { + float result = cobj->getNear(); + ok &= nativevalue_to_se(result, s.rval(), nullptr /*ctx*/); + SE_PRECONDITION2(ok, false, "js_scene_Shadows_getNear : Error processing arguments"); + SE_HOLD_RETURN_VALUE(result, s.thisObject(), s.rval()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 0); + return false; +} +SE_BIND_FUNC_AS_PROP_GET(js_scene_Shadows_getNear) + +static bool js_scene_Shadows_getNormal(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_scene_Shadows_getNormal : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 0) { + const cc::Vec3& result = cobj->getNormal(); + ok &= nativevalue_to_se(result, s.rval(), nullptr /*ctx*/); + SE_PRECONDITION2(ok, false, "js_scene_Shadows_getNormal : Error processing arguments"); + SE_HOLD_RETURN_VALUE(result, s.thisObject(), s.rval()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 0); + return false; +} +SE_BIND_FUNC_AS_PROP_GET(js_scene_Shadows_getNormal) + +static bool js_scene_Shadows_getNormalBias(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_scene_Shadows_getNormalBias : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 0) { + float result = cobj->getNormalBias(); + ok &= nativevalue_to_se(result, s.rval(), nullptr /*ctx*/); + SE_PRECONDITION2(ok, false, "js_scene_Shadows_getNormalBias : Error processing arguments"); + SE_HOLD_RETURN_VALUE(result, s.thisObject(), s.rval()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 0); + return false; +} +SE_BIND_FUNC_AS_PROP_GET(js_scene_Shadows_getNormalBias) + +static bool js_scene_Shadows_getOrthoSize(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_scene_Shadows_getOrthoSize : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 0) { + float result = cobj->getOrthoSize(); + ok &= nativevalue_to_se(result, s.rval(), nullptr /*ctx*/); + SE_PRECONDITION2(ok, false, "js_scene_Shadows_getOrthoSize : Error processing arguments"); + SE_HOLD_RETURN_VALUE(result, s.thisObject(), s.rval()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 0); + return false; +} +SE_BIND_FUNC_AS_PROP_GET(js_scene_Shadows_getOrthoSize) + +static bool js_scene_Shadows_getPcf(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_scene_Shadows_getPcf : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 0) { + auto result = static_cast(cobj->getPcf()); + ok &= nativevalue_to_se(result, s.rval(), nullptr /*ctx*/); + SE_PRECONDITION2(ok, false, "js_scene_Shadows_getPcf : Error processing arguments"); + SE_HOLD_RETURN_VALUE(result, s.thisObject(), s.rval()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 0); + return false; +} +SE_BIND_FUNC_AS_PROP_GET(js_scene_Shadows_getPcf) + +static bool js_scene_Shadows_getPlanarInstanceShader(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_scene_Shadows_getPlanarInstanceShader : Invalid Native Object"); const auto& args = s.args(); size_t argc = args.size(); CC_UNUSED bool ok = true; if (argc == 1) { - HolderType arg0 = {}; + HolderType, true> arg0 = {}; ok &= sevalue_to_native(args[0], &arg0, s.thisObject()); - SE_PRECONDITION2(ok, false, "js_scene_SphereLight_setAABB : Error processing arguments"); - cobj->setAABB(arg0.value()); + SE_PRECONDITION2(ok, false, "js_scene_Shadows_getPlanarInstanceShader : Error processing arguments"); + cc::gfx::Shader* result = cobj->getPlanarInstanceShader(arg0.value()); + ok &= nativevalue_to_se(result, s.rval(), nullptr /*ctx*/); + SE_PRECONDITION2(ok, false, "js_scene_Shadows_getPlanarInstanceShader : Error processing arguments"); + SE_HOLD_RETURN_VALUE(result, s.thisObject(), s.rval()); return true; } SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 1); return false; } -SE_BIND_FUNC(js_scene_SphereLight_setAABB) +SE_BIND_FUNC(js_scene_Shadows_getPlanarInstanceShader) -static bool js_scene_SphereLight_setLuminanceHDR(se::State& s) // NOLINT(readability-identifier-naming) +static bool js_scene_Shadows_getPlanarShader(se::State& s) // NOLINT(readability-identifier-naming) { - auto* cobj = SE_THIS_OBJECT(s); - SE_PRECONDITION2(cobj, false, "js_scene_SphereLight_setLuminanceHDR : Invalid Native Object"); + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_scene_Shadows_getPlanarShader : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 1) { + HolderType, true> arg0 = {}; + ok &= sevalue_to_native(args[0], &arg0, s.thisObject()); + SE_PRECONDITION2(ok, false, "js_scene_Shadows_getPlanarShader : Error processing arguments"); + cc::gfx::Shader* result = cobj->getPlanarShader(arg0.value()); + ok &= nativevalue_to_se(result, s.rval(), nullptr /*ctx*/); + SE_PRECONDITION2(ok, false, "js_scene_Shadows_getPlanarShader : Error processing arguments"); + SE_HOLD_RETURN_VALUE(result, s.thisObject(), s.rval()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 1); + return false; +} +SE_BIND_FUNC(js_scene_Shadows_getPlanarShader) + +static bool js_scene_Shadows_getSaturation(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_scene_Shadows_getSaturation : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 0) { + float result = cobj->getSaturation(); + ok &= nativevalue_to_se(result, s.rval(), nullptr /*ctx*/); + SE_PRECONDITION2(ok, false, "js_scene_Shadows_getSaturation : Error processing arguments"); + SE_HOLD_RETURN_VALUE(result, s.thisObject(), s.rval()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 0); + return false; +} +SE_BIND_FUNC_AS_PROP_GET(js_scene_Shadows_getSaturation) + +static bool js_scene_Shadows_getShadowColor(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_scene_Shadows_getShadowColor : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 0) { + const cc::Color& result = cobj->getShadowColor(); + ok &= nativevalue_to_se(result, s.rval(), nullptr /*ctx*/); + SE_PRECONDITION2(ok, false, "js_scene_Shadows_getShadowColor : Error processing arguments"); + SE_HOLD_RETURN_VALUE(result, s.thisObject(), s.rval()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 0); + return false; +} +SE_BIND_FUNC_AS_PROP_GET(js_scene_Shadows_getShadowColor) + +static bool js_scene_Shadows_getShadowColor4f(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_scene_Shadows_getShadowColor4f : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 0) { + const std::array& result = cobj->getShadowColor4f(); + ok &= nativevalue_to_se(result, s.rval(), nullptr /*ctx*/); + SE_PRECONDITION2(ok, false, "js_scene_Shadows_getShadowColor4f : Error processing arguments"); + SE_HOLD_RETURN_VALUE(result, s.thisObject(), s.rval()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 0); + return false; +} +SE_BIND_FUNC(js_scene_Shadows_getShadowColor4f) + +static bool js_scene_Shadows_getShadowDistance(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_scene_Shadows_getShadowDistance : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 0) { + float result = cobj->getShadowDistance(); + ok &= nativevalue_to_se(result, s.rval(), nullptr /*ctx*/); + SE_PRECONDITION2(ok, false, "js_scene_Shadows_getShadowDistance : Error processing arguments"); + SE_HOLD_RETURN_VALUE(result, s.thisObject(), s.rval()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 0); + return false; +} +SE_BIND_FUNC(js_scene_Shadows_getShadowDistance) + +static bool js_scene_Shadows_getShadowMapSize(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_scene_Shadows_getShadowMapSize : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 0) { + float result = cobj->getShadowMapSize(); + ok &= nativevalue_to_se(result, s.rval(), nullptr /*ctx*/); + SE_PRECONDITION2(ok, false, "js_scene_Shadows_getShadowMapSize : Error processing arguments"); + SE_HOLD_RETURN_VALUE(result, s.thisObject(), s.rval()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 0); + return false; +} +SE_BIND_FUNC(js_scene_Shadows_getShadowMapSize) + +static bool js_scene_Shadows_getSize(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_scene_Shadows_getSize : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 0) { + const cc::Vec2& result = cobj->getSize(); + ok &= nativevalue_to_se(result, s.rval(), nullptr /*ctx*/); + SE_PRECONDITION2(ok, false, "js_scene_Shadows_getSize : Error processing arguments"); + SE_HOLD_RETURN_VALUE(result, s.thisObject(), s.rval()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 0); + return false; +} +SE_BIND_FUNC_AS_PROP_GET(js_scene_Shadows_getSize) + +static bool js_scene_Shadows_getType(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_scene_Shadows_getType : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 0) { + auto result = static_cast(cobj->getType()); + ok &= nativevalue_to_se(result, s.rval(), nullptr /*ctx*/); + SE_PRECONDITION2(ok, false, "js_scene_Shadows_getType : Error processing arguments"); + SE_HOLD_RETURN_VALUE(result, s.thisObject(), s.rval()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 0); + return false; +} +SE_BIND_FUNC_AS_PROP_GET(js_scene_Shadows_getType) + +static bool js_scene_Shadows_initialize(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_scene_Shadows_initialize : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 1) { + HolderType arg0 = {}; + ok &= sevalue_to_native(args[0], &arg0, s.thisObject()); + SE_PRECONDITION2(ok, false, "js_scene_Shadows_initialize : Error processing arguments"); + cobj->initialize(arg0.value()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 1); + return false; +} +SE_BIND_FUNC(js_scene_Shadows_initialize) + +static bool js_scene_Shadows_isEnabled(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_scene_Shadows_isEnabled : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 0) { + bool result = cobj->isEnabled(); + ok &= nativevalue_to_se(result, s.rval(), nullptr /*ctx*/); + SE_PRECONDITION2(ok, false, "js_scene_Shadows_isEnabled : Error processing arguments"); + SE_HOLD_RETURN_VALUE(result, s.thisObject(), s.rval()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 0); + return false; +} +SE_BIND_FUNC_AS_PROP_GET(js_scene_Shadows_isEnabled) + +static bool js_scene_Shadows_isFixedArea(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_scene_Shadows_isFixedArea : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 0) { + bool result = cobj->isFixedArea(); + ok &= nativevalue_to_se(result, s.rval(), nullptr /*ctx*/); + SE_PRECONDITION2(ok, false, "js_scene_Shadows_isFixedArea : Error processing arguments"); + SE_HOLD_RETURN_VALUE(result, s.thisObject(), s.rval()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 0); + return false; +} +SE_BIND_FUNC(js_scene_Shadows_isFixedArea) + +static bool js_scene_Shadows_isShadowMapDirty(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_scene_Shadows_isShadowMapDirty : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 0) { + bool result = cobj->isShadowMapDirty(); + ok &= nativevalue_to_se(result, s.rval(), nullptr /*ctx*/); + SE_PRECONDITION2(ok, false, "js_scene_Shadows_isShadowMapDirty : Error processing arguments"); + SE_HOLD_RETURN_VALUE(result, s.thisObject(), s.rval()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 0); + return false; +} +SE_BIND_FUNC_AS_PROP_GET(js_scene_Shadows_isShadowMapDirty) + +static bool js_scene_Shadows_setBias(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_scene_Shadows_setBias : Invalid Native Object"); const auto& args = s.args(); size_t argc = args.size(); CC_UNUSED bool ok = true; if (argc == 1) { HolderType arg0 = {}; ok &= sevalue_to_native(args[0], &arg0, s.thisObject()); - SE_PRECONDITION2(ok, false, "js_scene_SphereLight_setLuminanceHDR : Error processing arguments"); - cobj->setLuminanceHDR(arg0.value()); + SE_PRECONDITION2(ok, false, "js_scene_Shadows_setBias : Error processing arguments"); + cobj->setBias(arg0.value()); return true; } SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 1); return false; } -SE_BIND_FUNC(js_scene_SphereLight_setLuminanceHDR) +SE_BIND_FUNC_AS_PROP_SET(js_scene_Shadows_setBias) -static bool js_scene_SphereLight_setLuminanceLDR(se::State& s) // NOLINT(readability-identifier-naming) +static bool js_scene_Shadows_setDistance(se::State& s) // NOLINT(readability-identifier-naming) { - auto* cobj = SE_THIS_OBJECT(s); - SE_PRECONDITION2(cobj, false, "js_scene_SphereLight_setLuminanceLDR : Invalid Native Object"); + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_scene_Shadows_setDistance : Invalid Native Object"); const auto& args = s.args(); size_t argc = args.size(); CC_UNUSED bool ok = true; if (argc == 1) { HolderType arg0 = {}; ok &= sevalue_to_native(args[0], &arg0, s.thisObject()); - SE_PRECONDITION2(ok, false, "js_scene_SphereLight_setLuminanceLDR : Error processing arguments"); - cobj->setLuminanceLDR(arg0.value()); + SE_PRECONDITION2(ok, false, "js_scene_Shadows_setDistance : Error processing arguments"); + cobj->setDistance(arg0.value()); return true; } SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 1); return false; } -SE_BIND_FUNC(js_scene_SphereLight_setLuminanceLDR) +SE_BIND_FUNC_AS_PROP_SET(js_scene_Shadows_setDistance) -static bool js_scene_SphereLight_setPosition(se::State& s) // NOLINT(readability-identifier-naming) +static bool js_scene_Shadows_setEnabled(se::State& s) // NOLINT(readability-identifier-naming) { - auto* cobj = SE_THIS_OBJECT(s); - SE_PRECONDITION2(cobj, false, "js_scene_SphereLight_setPosition : Invalid Native Object"); + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_scene_Shadows_setEnabled : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 1) { + HolderType arg0 = {}; + ok &= sevalue_to_native(args[0], &arg0, s.thisObject()); + SE_PRECONDITION2(ok, false, "js_scene_Shadows_setEnabled : Error processing arguments"); + cobj->setEnabled(arg0.value()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 1); + return false; +} +SE_BIND_FUNC_AS_PROP_SET(js_scene_Shadows_setEnabled) + +static bool js_scene_Shadows_setFar(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_scene_Shadows_setFar : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 1) { + HolderType arg0 = {}; + ok &= sevalue_to_native(args[0], &arg0, s.thisObject()); + SE_PRECONDITION2(ok, false, "js_scene_Shadows_setFar : Error processing arguments"); + cobj->setFar(arg0.value()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 1); + return false; +} +SE_BIND_FUNC_AS_PROP_SET(js_scene_Shadows_setFar) + +static bool js_scene_Shadows_setFixedArea(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_scene_Shadows_setFixedArea : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 1) { + HolderType arg0 = {}; + ok &= sevalue_to_native(args[0], &arg0, s.thisObject()); + SE_PRECONDITION2(ok, false, "js_scene_Shadows_setFixedArea : Error processing arguments"); + cobj->setFixedArea(arg0.value()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 1); + return false; +} +SE_BIND_FUNC_AS_PROP_SET(js_scene_Shadows_setFixedArea) + +static bool js_scene_Shadows_setInvisibleOcclusionRange(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_scene_Shadows_setInvisibleOcclusionRange : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 1) { + HolderType arg0 = {}; + ok &= sevalue_to_native(args[0], &arg0, s.thisObject()); + SE_PRECONDITION2(ok, false, "js_scene_Shadows_setInvisibleOcclusionRange : Error processing arguments"); + cobj->setInvisibleOcclusionRange(arg0.value()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 1); + return false; +} +SE_BIND_FUNC_AS_PROP_SET(js_scene_Shadows_setInvisibleOcclusionRange) + +static bool js_scene_Shadows_setMaxReceived(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_scene_Shadows_setMaxReceived : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 1) { + HolderType arg0 = {}; + ok &= sevalue_to_native(args[0], &arg0, s.thisObject()); + SE_PRECONDITION2(ok, false, "js_scene_Shadows_setMaxReceived : Error processing arguments"); + cobj->setMaxReceived(arg0.value()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 1); + return false; +} +SE_BIND_FUNC(js_scene_Shadows_setMaxReceived) + +static bool js_scene_Shadows_setNear(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_scene_Shadows_setNear : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 1) { + HolderType arg0 = {}; + ok &= sevalue_to_native(args[0], &arg0, s.thisObject()); + SE_PRECONDITION2(ok, false, "js_scene_Shadows_setNear : Error processing arguments"); + cobj->setNear(arg0.value()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 1); + return false; +} +SE_BIND_FUNC_AS_PROP_SET(js_scene_Shadows_setNear) + +static bool js_scene_Shadows_setNormal(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_scene_Shadows_setNormal : Invalid Native Object"); const auto& args = s.args(); size_t argc = args.size(); CC_UNUSED bool ok = true; if (argc == 1) { HolderType arg0 = {}; ok &= sevalue_to_native(args[0], &arg0, s.thisObject()); - SE_PRECONDITION2(ok, false, "js_scene_SphereLight_setPosition : Error processing arguments"); - cobj->setPosition(arg0.value()); + SE_PRECONDITION2(ok, false, "js_scene_Shadows_setNormal : Error processing arguments"); + cobj->setNormal(arg0.value()); return true; } SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 1); return false; } -SE_BIND_FUNC(js_scene_SphereLight_setPosition) +SE_BIND_FUNC_AS_PROP_SET(js_scene_Shadows_setNormal) -static bool js_scene_SphereLight_setRange(se::State& s) // NOLINT(readability-identifier-naming) +static bool js_scene_Shadows_setNormalBias(se::State& s) // NOLINT(readability-identifier-naming) { - auto* cobj = SE_THIS_OBJECT(s); - SE_PRECONDITION2(cobj, false, "js_scene_SphereLight_setRange : Invalid Native Object"); + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_scene_Shadows_setNormalBias : Invalid Native Object"); const auto& args = s.args(); size_t argc = args.size(); CC_UNUSED bool ok = true; if (argc == 1) { HolderType arg0 = {}; ok &= sevalue_to_native(args[0], &arg0, s.thisObject()); - SE_PRECONDITION2(ok, false, "js_scene_SphereLight_setRange : Error processing arguments"); - cobj->setRange(arg0.value()); + SE_PRECONDITION2(ok, false, "js_scene_Shadows_setNormalBias : Error processing arguments"); + cobj->setNormalBias(arg0.value()); return true; } SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 1); return false; } -SE_BIND_FUNC(js_scene_SphereLight_setRange) +SE_BIND_FUNC_AS_PROP_SET(js_scene_Shadows_setNormalBias) -static bool js_scene_SphereLight_setSize(se::State& s) // NOLINT(readability-identifier-naming) +static bool js_scene_Shadows_setOrthoSize(se::State& s) // NOLINT(readability-identifier-naming) { - auto* cobj = SE_THIS_OBJECT(s); - SE_PRECONDITION2(cobj, false, "js_scene_SphereLight_setSize : Invalid Native Object"); + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_scene_Shadows_setOrthoSize : Invalid Native Object"); const auto& args = s.args(); size_t argc = args.size(); CC_UNUSED bool ok = true; if (argc == 1) { HolderType arg0 = {}; ok &= sevalue_to_native(args[0], &arg0, s.thisObject()); - SE_PRECONDITION2(ok, false, "js_scene_SphereLight_setSize : Error processing arguments"); + SE_PRECONDITION2(ok, false, "js_scene_Shadows_setOrthoSize : Error processing arguments"); + cobj->setOrthoSize(arg0.value()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 1); + return false; +} +SE_BIND_FUNC_AS_PROP_SET(js_scene_Shadows_setOrthoSize) + +static bool js_scene_Shadows_setPcf(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_scene_Shadows_setPcf : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 1) { + HolderType arg0 = {}; + ok &= sevalue_to_native(args[0], &arg0, s.thisObject()); + SE_PRECONDITION2(ok, false, "js_scene_Shadows_setPcf : Error processing arguments"); + cobj->setPcf(arg0.value()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 1); + return false; +} +SE_BIND_FUNC_AS_PROP_SET(js_scene_Shadows_setPcf) + +static bool js_scene_Shadows_setSaturation(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_scene_Shadows_setSaturation : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 1) { + HolderType arg0 = {}; + ok &= sevalue_to_native(args[0], &arg0, s.thisObject()); + SE_PRECONDITION2(ok, false, "js_scene_Shadows_setSaturation : Error processing arguments"); + cobj->setSaturation(arg0.value()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 1); + return false; +} +SE_BIND_FUNC_AS_PROP_SET(js_scene_Shadows_setSaturation) + +static bool js_scene_Shadows_setShadowColor(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_scene_Shadows_setShadowColor : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 1) { + HolderType arg0 = {}; + ok &= sevalue_to_native(args[0], &arg0, s.thisObject()); + SE_PRECONDITION2(ok, false, "js_scene_Shadows_setShadowColor : Error processing arguments"); + cobj->setShadowColor(arg0.value()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 1); + return false; +} +SE_BIND_FUNC_AS_PROP_SET(js_scene_Shadows_setShadowColor) + +static bool js_scene_Shadows_setShadowDistance(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_scene_Shadows_setShadowDistance : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 1) { + HolderType arg0 = {}; + ok &= sevalue_to_native(args[0], &arg0, s.thisObject()); + SE_PRECONDITION2(ok, false, "js_scene_Shadows_setShadowDistance : Error processing arguments"); + cobj->setShadowDistance(arg0.value()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 1); + return false; +} +SE_BIND_FUNC(js_scene_Shadows_setShadowDistance) + +static bool js_scene_Shadows_setShadowMapDirty(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_scene_Shadows_setShadowMapDirty : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 1) { + HolderType arg0 = {}; + ok &= sevalue_to_native(args[0], &arg0, s.thisObject()); + SE_PRECONDITION2(ok, false, "js_scene_Shadows_setShadowMapDirty : Error processing arguments"); + cobj->setShadowMapDirty(arg0.value()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 1); + return false; +} +SE_BIND_FUNC_AS_PROP_SET(js_scene_Shadows_setShadowMapDirty) + +static bool js_scene_Shadows_setShadowMapSize(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_scene_Shadows_setShadowMapSize : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 1) { + HolderType arg0 = {}; + ok &= sevalue_to_native(args[0], &arg0, s.thisObject()); + SE_PRECONDITION2(ok, false, "js_scene_Shadows_setShadowMapSize : Error processing arguments"); + cobj->setShadowMapSize(arg0.value()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 1); + return false; +} +SE_BIND_FUNC(js_scene_Shadows_setShadowMapSize) + +static bool js_scene_Shadows_setSize(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_scene_Shadows_setSize : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 1) { + HolderType arg0 = {}; + ok &= sevalue_to_native(args[0], &arg0, s.thisObject()); + SE_PRECONDITION2(ok, false, "js_scene_Shadows_setSize : Error processing arguments"); cobj->setSize(arg0.value()); return true; } SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 1); return false; } -SE_BIND_FUNC(js_scene_SphereLight_setSize) +SE_BIND_FUNC_AS_PROP_SET(js_scene_Shadows_setSize) -SE_DECLARE_FINALIZE_FUNC(js_cc_scene_SphereLight_finalize) - -static bool js_scene_SphereLight_constructor(se::State& s) // NOLINT(readability-identifier-naming) constructor.c +static bool js_scene_Shadows_setType(se::State& s) // NOLINT(readability-identifier-naming) { - cc::scene::SphereLight* cobj = JSB_ALLOC(cc::scene::SphereLight); - s.thisObject()->setPrivateData(cobj); - se::NonRefNativePtrCreatedByCtorMap::emplace(cobj); - return true; -} -SE_BIND_CTOR(js_scene_SphereLight_constructor, __jsb_cc_scene_SphereLight_class, js_cc_scene_SphereLight_finalize) - - - -static bool js_cc_scene_SphereLight_finalize(se::State& s) // NOLINT(readability-identifier-naming) -{ - auto iter = se::NonRefNativePtrCreatedByCtorMap::find(SE_THIS_OBJECT(s)); - if (iter != se::NonRefNativePtrCreatedByCtorMap::end()) - { - se::NonRefNativePtrCreatedByCtorMap::erase(iter); - auto* cobj = SE_THIS_OBJECT(s); - JSB_FREE(cobj); + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_scene_Shadows_setType : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 1) { + HolderType arg0 = {}; + ok &= sevalue_to_native(args[0], &arg0, s.thisObject()); + SE_PRECONDITION2(ok, false, "js_scene_Shadows_setType : Error processing arguments"); + cobj->setType(arg0.value()); + return true; } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 1); + return false; +} +SE_BIND_FUNC_AS_PROP_SET(js_scene_Shadows_setType) + +static bool js_scene_Shadows_get_MAX_FAR(se::State& s) // NOLINT(readability-identifier-naming) +{ + CC_UNUSED bool ok = true; + se::Value jsret; + ok &= nativevalue_to_se(cc::scene::Shadows::MAX_FAR, jsret, s.thisObject() /*ctx*/); + s.rval() = jsret; + // SE_HOLD_RETURN_VALUE(cobj->MAX_FAR, s.thisObject(), s.rval()); return true; } -SE_BIND_FINALIZE_FUNC(js_cc_scene_SphereLight_finalize) +SE_BIND_PROP_GET(js_scene_Shadows_get_MAX_FAR) -bool js_register_scene_SphereLight(se::Object* obj) // NOLINT(readability-identifier-naming) + +static bool js_scene_Shadows_get_COEFFICIENT_OF_EXPANSION(se::State& s) // NOLINT(readability-identifier-naming) { - auto* cls = se::Class::create("SphereLight", obj, __jsb_cc_scene_Light_proto, _SE(js_scene_SphereLight_constructor)); + CC_UNUSED bool ok = true; + se::Value jsret; + ok &= nativevalue_to_se(cc::scene::Shadows::COEFFICIENT_OF_EXPANSION, jsret, s.thisObject() /*ctx*/); + s.rval() = jsret; + // SE_HOLD_RETURN_VALUE(cobj->COEFFICIENT_OF_EXPANSION, s.thisObject(), s.rval()); + return true; +} +SE_BIND_PROP_GET(js_scene_Shadows_get_COEFFICIENT_OF_EXPANSION) - cls->defineFunction("setAABB", _SE(js_scene_SphereLight_setAABB)); - cls->defineFunction("setLuminanceHDR", _SE(js_scene_SphereLight_setLuminanceHDR)); - cls->defineFunction("setLuminanceLDR", _SE(js_scene_SphereLight_setLuminanceLDR)); - cls->defineFunction("setPosition", _SE(js_scene_SphereLight_setPosition)); - cls->defineFunction("setRange", _SE(js_scene_SphereLight_setRange)); - cls->defineFunction("setSize", _SE(js_scene_SphereLight_setSize)); - cls->defineFinalizeFunction(_SE(js_cc_scene_SphereLight_finalize)); + +SE_DECLARE_FINALIZE_FUNC(js_cc_scene_Shadows_finalize) + +static bool js_scene_Shadows_constructor(se::State& s) // NOLINT(readability-identifier-naming) constructor.c +{ + auto *ptr = JSB_MAKE_PRIVATE_OBJECT(cc::scene::Shadows); + s.thisObject()->setPrivateObject(ptr); + return true; +} +SE_BIND_CTOR(js_scene_Shadows_constructor, __jsb_cc_scene_Shadows_class, js_cc_scene_Shadows_finalize) + +static bool js_cc_scene_Shadows_finalize(se::State& s) // NOLINT(readability-identifier-naming) +{ + return true; +} +SE_BIND_FINALIZE_FUNC(js_cc_scene_Shadows_finalize) + +bool js_register_scene_Shadows(se::Object* obj) // NOLINT(readability-identifier-naming) +{ + auto* cls = se::Class::create("Shadows", obj, nullptr, _SE(js_scene_Shadows_constructor)); + + cls->defineProperty("distance", _SE(js_scene_Shadows_getDistance_asGetter), _SE(js_scene_Shadows_setDistance_asSetter)); + cls->defineProperty("saturation", _SE(js_scene_Shadows_getSaturation_asGetter), _SE(js_scene_Shadows_setSaturation_asSetter)); + cls->defineProperty("normalBias", _SE(js_scene_Shadows_getNormalBias_asGetter), _SE(js_scene_Shadows_setNormalBias_asSetter)); + cls->defineProperty("instancingMaterial", _SE(js_scene_Shadows_getInstancingMaterial_asGetter), nullptr); + cls->defineProperty("normal", _SE(js_scene_Shadows_getNormal_asGetter), _SE(js_scene_Shadows_setNormal_asSetter)); + cls->defineProperty("far", _SE(js_scene_Shadows_getFar_asGetter), _SE(js_scene_Shadows_setFar_asSetter)); + cls->defineProperty("pcf", _SE(js_scene_Shadows_getPcf_asGetter), _SE(js_scene_Shadows_setPcf_asSetter)); + cls->defineProperty("matLight", _SE(js_scene_Shadows_getMatLight_asGetter), nullptr); + cls->defineProperty("enabled", _SE(js_scene_Shadows_isEnabled_asGetter), _SE(js_scene_Shadows_setEnabled_asSetter)); + cls->defineProperty("near", _SE(js_scene_Shadows_getNear_asGetter), _SE(js_scene_Shadows_setNear_asSetter)); + cls->defineProperty("orthoSize", _SE(js_scene_Shadows_getOrthoSize_asGetter), _SE(js_scene_Shadows_setOrthoSize_asSetter)); + cls->defineProperty("shadowColor", _SE(js_scene_Shadows_getShadowColor_asGetter), _SE(js_scene_Shadows_setShadowColor_asSetter)); + cls->defineProperty("bias", _SE(js_scene_Shadows_getBias_asGetter), _SE(js_scene_Shadows_setBias_asSetter)); + cls->defineProperty("shadowMapDirty", _SE(js_scene_Shadows_isShadowMapDirty_asGetter), _SE(js_scene_Shadows_setShadowMapDirty_asSetter)); + cls->defineProperty("invisibleOcclusionRange", _SE(js_scene_Shadows_getInvisibleOcclusionRange_asGetter), _SE(js_scene_Shadows_setInvisibleOcclusionRange_asSetter)); + cls->defineProperty("type", _SE(js_scene_Shadows_getType_asGetter), _SE(js_scene_Shadows_setType_asSetter)); + cls->defineProperty("fixedArea", nullptr, _SE(js_scene_Shadows_setFixedArea_asSetter)); + cls->defineProperty("size", _SE(js_scene_Shadows_getSize_asGetter), _SE(js_scene_Shadows_setSize_asSetter)); + cls->defineFunction("activate", _SE(js_scene_Shadows_activate)); + cls->defineFunction("destroy", _SE(js_scene_Shadows_destroy)); + cls->defineFunction("getMaterial", _SE(js_scene_Shadows_getMaterial)); + cls->defineFunction("getMaxReceived", _SE(js_scene_Shadows_getMaxReceived)); + cls->defineFunction("getPlanarInstanceShader", _SE(js_scene_Shadows_getPlanarInstanceShader)); + cls->defineFunction("getPlanarShader", _SE(js_scene_Shadows_getPlanarShader)); + cls->defineFunction("getShadowColor4f", _SE(js_scene_Shadows_getShadowColor4f)); + cls->defineFunction("getShadowDistance", _SE(js_scene_Shadows_getShadowDistance)); + cls->defineFunction("getShadowMapSize", _SE(js_scene_Shadows_getShadowMapSize)); + cls->defineFunction("initialize", _SE(js_scene_Shadows_initialize)); + cls->defineFunction("isFixedArea", _SE(js_scene_Shadows_isFixedArea)); + cls->defineFunction("setMaxReceived", _SE(js_scene_Shadows_setMaxReceived)); + cls->defineFunction("setShadowDistance", _SE(js_scene_Shadows_setShadowDistance)); + cls->defineFunction("setShadowMapSize", _SE(js_scene_Shadows_setShadowMapSize)); + // static fields + cls->defineStaticProperty("MAX_FAR", _SE(js_scene_Shadows_get_MAX_FAR), nullptr); + cls->defineStaticProperty("COEFFICIENT_OF_EXPANSION", _SE(js_scene_Shadows_get_COEFFICIENT_OF_EXPANSION), nullptr); + cls->defineFinalizeFunction(_SE(js_cc_scene_Shadows_finalize)); cls->install(); - JSBClassType::registerClass(cls); + JSBClassType::registerClass(cls); + + __jsb_cc_scene_Shadows_proto = cls->getProto(); + __jsb_cc_scene_Shadows_class = cls; - __jsb_cc_scene_SphereLight_proto = cls->getProto(); - __jsb_cc_scene_SphereLight_class = cls; se::ScriptEngine::getInstance()->clearException(); return true; } -se::Object* __jsb_cc_scene_Model_proto = nullptr; -se::Class* __jsb_cc_scene_Model_class = nullptr; +se::Object* __jsb_cc_scene_ICameraInfo_proto = nullptr; // NOLINT +se::Class* __jsb_cc_scene_ICameraInfo_class = nullptr; // NOLINT -static bool js_scene_Model_getCastShadow(se::State& s) // NOLINT(readability-identifier-naming) +static bool js_scene_ICameraInfo_get_name(se::State& s) // NOLINT(readability-identifier-naming) { - auto* cobj = SE_THIS_OBJECT(s); - SE_PRECONDITION2(cobj, false, "js_scene_Model_getCastShadow : Invalid Native Object"); + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_scene_ICameraInfo_get_name : Invalid Native Object"); + + CC_UNUSED bool ok = true; + se::Value jsret; + ok &= nativevalue_to_se(cobj->name, jsret, s.thisObject() /*ctx*/); + s.rval() = jsret; + SE_HOLD_RETURN_VALUE(cobj->name, s.thisObject(), s.rval()); + return true; +} +SE_BIND_PROP_GET(js_scene_ICameraInfo_get_name) + +static bool js_scene_ICameraInfo_set_name(se::State& s) // NOLINT(readability-identifier-naming) +{ + const auto& args = s.args(); + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_scene_ICameraInfo_set_name : Invalid Native Object"); + + CC_UNUSED bool ok = true; + ok &= sevalue_to_native(args[0], &cobj->name, s.thisObject()); + SE_PRECONDITION2(ok, false, "js_scene_ICameraInfo_set_name : Error processing new value"); + return true; +} +SE_BIND_PROP_SET(js_scene_ICameraInfo_set_name) + +static bool js_scene_ICameraInfo_get_node(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_scene_ICameraInfo_get_node : Invalid Native Object"); + + CC_UNUSED bool ok = true; + se::Value jsret; + ok &= nativevalue_to_se(cobj->node, jsret, s.thisObject() /*ctx*/); + s.rval() = jsret; + SE_HOLD_RETURN_VALUE(cobj->node, s.thisObject(), s.rval()); + return true; +} +SE_BIND_PROP_GET(js_scene_ICameraInfo_get_node) + +static bool js_scene_ICameraInfo_set_node(se::State& s) // NOLINT(readability-identifier-naming) +{ + const auto& args = s.args(); + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_scene_ICameraInfo_set_node : Invalid Native Object"); + + CC_UNUSED bool ok = true; + ok &= sevalue_to_native(args[0], &cobj->node, s.thisObject()); + SE_PRECONDITION2(ok, false, "js_scene_ICameraInfo_set_node : Error processing new value"); + return true; +} +SE_BIND_PROP_SET(js_scene_ICameraInfo_set_node) + +static bool js_scene_ICameraInfo_get_projection(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_scene_ICameraInfo_get_projection : Invalid Native Object"); + + CC_UNUSED bool ok = true; + se::Value jsret; + ok &= nativevalue_to_se(cobj->projection, jsret, s.thisObject() /*ctx*/); + s.rval() = jsret; + SE_HOLD_RETURN_VALUE(cobj->projection, s.thisObject(), s.rval()); + return true; +} +SE_BIND_PROP_GET(js_scene_ICameraInfo_get_projection) + +static bool js_scene_ICameraInfo_set_projection(se::State& s) // NOLINT(readability-identifier-naming) +{ + const auto& args = s.args(); + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_scene_ICameraInfo_set_projection : Invalid Native Object"); + + CC_UNUSED bool ok = true; + ok &= sevalue_to_native(args[0], &cobj->projection, s.thisObject()); + SE_PRECONDITION2(ok, false, "js_scene_ICameraInfo_set_projection : Error processing new value"); + return true; +} +SE_BIND_PROP_SET(js_scene_ICameraInfo_set_projection) + +static bool js_scene_ICameraInfo_get_targetDisplay(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_scene_ICameraInfo_get_targetDisplay : Invalid Native Object"); + + CC_UNUSED bool ok = true; + se::Value jsret; + ok &= nativevalue_to_se(cobj->targetDisplay, jsret, s.thisObject() /*ctx*/); + s.rval() = jsret; + SE_HOLD_RETURN_VALUE(cobj->targetDisplay, s.thisObject(), s.rval()); + return true; +} +SE_BIND_PROP_GET(js_scene_ICameraInfo_get_targetDisplay) + +static bool js_scene_ICameraInfo_set_targetDisplay(se::State& s) // NOLINT(readability-identifier-naming) +{ + const auto& args = s.args(); + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_scene_ICameraInfo_set_targetDisplay : Invalid Native Object"); + + CC_UNUSED bool ok = true; + ok &= sevalue_to_native(args[0], &cobj->targetDisplay, s.thisObject()); + SE_PRECONDITION2(ok, false, "js_scene_ICameraInfo_set_targetDisplay : Error processing new value"); + return true; +} +SE_BIND_PROP_SET(js_scene_ICameraInfo_set_targetDisplay) + +static bool js_scene_ICameraInfo_get_window(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_scene_ICameraInfo_get_window : Invalid Native Object"); + + CC_UNUSED bool ok = true; + se::Value jsret; + ok &= nativevalue_to_se(cobj->window, jsret, s.thisObject() /*ctx*/); + s.rval() = jsret; + SE_HOLD_RETURN_VALUE(cobj->window, s.thisObject(), s.rval()); + return true; +} +SE_BIND_PROP_GET(js_scene_ICameraInfo_get_window) + +static bool js_scene_ICameraInfo_set_window(se::State& s) // NOLINT(readability-identifier-naming) +{ + const auto& args = s.args(); + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_scene_ICameraInfo_set_window : Invalid Native Object"); + + CC_UNUSED bool ok = true; + ok &= sevalue_to_native(args[0], &cobj->window, s.thisObject()); + SE_PRECONDITION2(ok, false, "js_scene_ICameraInfo_set_window : Error processing new value"); + return true; +} +SE_BIND_PROP_SET(js_scene_ICameraInfo_set_window) + +static bool js_scene_ICameraInfo_get_priority(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_scene_ICameraInfo_get_priority : Invalid Native Object"); + + CC_UNUSED bool ok = true; + se::Value jsret; + ok &= nativevalue_to_se(cobj->priority, jsret, s.thisObject() /*ctx*/); + s.rval() = jsret; + SE_HOLD_RETURN_VALUE(cobj->priority, s.thisObject(), s.rval()); + return true; +} +SE_BIND_PROP_GET(js_scene_ICameraInfo_get_priority) + +static bool js_scene_ICameraInfo_set_priority(se::State& s) // NOLINT(readability-identifier-naming) +{ + const auto& args = s.args(); + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_scene_ICameraInfo_set_priority : Invalid Native Object"); + + CC_UNUSED bool ok = true; + ok &= sevalue_to_native(args[0], &cobj->priority, s.thisObject()); + SE_PRECONDITION2(ok, false, "js_scene_ICameraInfo_set_priority : Error processing new value"); + return true; +} +SE_BIND_PROP_SET(js_scene_ICameraInfo_set_priority) + +static bool js_scene_ICameraInfo_get_pipeline(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_scene_ICameraInfo_get_pipeline : Invalid Native Object"); + + CC_UNUSED bool ok = true; + se::Value jsret; + ok &= nativevalue_to_se(cobj->pipeline, jsret, s.thisObject() /*ctx*/); + s.rval() = jsret; + SE_HOLD_RETURN_VALUE(cobj->pipeline, s.thisObject(), s.rval()); + return true; +} +SE_BIND_PROP_GET(js_scene_ICameraInfo_get_pipeline) + +static bool js_scene_ICameraInfo_set_pipeline(se::State& s) // NOLINT(readability-identifier-naming) +{ + const auto& args = s.args(); + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_scene_ICameraInfo_set_pipeline : Invalid Native Object"); + + CC_UNUSED bool ok = true; + ok &= sevalue_to_native(args[0], &cobj->pipeline, s.thisObject()); + SE_PRECONDITION2(ok, false, "js_scene_ICameraInfo_set_pipeline : Error processing new value"); + return true; +} +SE_BIND_PROP_SET(js_scene_ICameraInfo_set_pipeline) + + +template<> +bool sevalue_to_native(const se::Value &from, cc::scene::ICameraInfo * to, se::Object *ctx) +{ + assert(from.isObject()); + se::Object *json = from.toObject(); + auto* data = reinterpret_cast(json->getPrivateData()); + if (data) { + *to = *data; + return true; + } + se::Value field; + bool ok = true; + json->getProperty("name", &field, true); + if(!field.isNullOrUndefined()) { + ok &= sevalue_to_native(field, &(to->name), ctx); + } + json->getProperty("node", &field, true); + if(!field.isNullOrUndefined()) { + ok &= sevalue_to_native(field, &(to->node), ctx); + } + json->getProperty("projection", &field, true); + if(!field.isNullOrUndefined()) { + ok &= sevalue_to_native(field, &(to->projection), ctx); + } + json->getProperty("targetDisplay", &field, true); + if(!field.isNullOrUndefined()) { + ok &= sevalue_to_native(field, &(to->targetDisplay), ctx); + } + json->getProperty("window", &field, true); + if(!field.isNullOrUndefined()) { + ok &= sevalue_to_native(field, &(to->window), ctx); + } + json->getProperty("priority", &field, true); + if(!field.isNullOrUndefined()) { + ok &= sevalue_to_native(field, &(to->priority), ctx); + } + json->getProperty("pipeline", &field, true); + if(!field.isNullOrUndefined()) { + ok &= sevalue_to_native(field, &(to->pipeline), ctx); + } + return ok; +} + +SE_DECLARE_FINALIZE_FUNC(js_cc_scene_ICameraInfo_finalize) + +static bool js_scene_ICameraInfo_constructor(se::State& s) // NOLINT(readability-identifier-naming) +{ + CC_UNUSED bool ok = true; + const auto& args = s.args(); + size_t argc = args.size(); + + if(argc == 0) + { + auto *ptr = JSB_MAKE_PRIVATE_OBJECT(cc::scene::ICameraInfo); + s.thisObject()->setPrivateObject(ptr); + return true; + } + + if(argc == 1 && args[0].isObject()) + { + se::Object *json = args[0].toObject(); + se::Value field; + auto *ptr = JSB_MAKE_PRIVATE_OBJECT(cc::scene::ICameraInfo); + auto cobj = ptr->get(); + ok &= sevalue_to_native(args[0], cobj, s.thisObject()); + if(!ok) { + delete ptr; + SE_REPORT_ERROR("argument convertion error"); + return false; + } + s.thisObject()->setPrivateObject(ptr); + return true; + } + auto *ptr = JSB_MAKE_PRIVATE_OBJECT(cc::scene::ICameraInfo); + auto cobj = ptr->get(); + if (argc > 0 && !args[0].isUndefined()) { + ok &= sevalue_to_native(args[0], &(cobj->name), nullptr); + } + if (argc > 1 && !args[1].isUndefined()) { + ok &= sevalue_to_native(args[1], &(cobj->node), nullptr); + } + if (argc > 2 && !args[2].isUndefined()) { + ok &= sevalue_to_native(args[2], &(cobj->projection), nullptr); + } + if (argc > 3 && !args[3].isUndefined()) { + ok &= sevalue_to_native(args[3], &(cobj->targetDisplay), nullptr); + } + if (argc > 4 && !args[4].isUndefined()) { + ok &= sevalue_to_native(args[4], &(cobj->window), nullptr); + } + if (argc > 5 && !args[5].isUndefined()) { + ok &= sevalue_to_native(args[5], &(cobj->priority), nullptr); + } + if (argc > 6 && !args[6].isUndefined()) { + ok &= sevalue_to_native(args[6], &(cobj->pipeline), nullptr); + } + + if(!ok) { + delete ptr; + SE_REPORT_ERROR("Argument convertion error"); + return false; + } + s.thisObject()->setPrivateObject(ptr); + return true; +} +SE_BIND_CTOR(js_scene_ICameraInfo_constructor, __jsb_cc_scene_ICameraInfo_class, js_cc_scene_ICameraInfo_finalize) + +static bool js_cc_scene_ICameraInfo_finalize(se::State& s) // NOLINT(readability-identifier-naming) +{ + return true; +} +SE_BIND_FINALIZE_FUNC(js_cc_scene_ICameraInfo_finalize) + +bool js_register_scene_ICameraInfo(se::Object* obj) // NOLINT(readability-identifier-naming) +{ + auto* cls = se::Class::create("ICameraInfo", obj, nullptr, _SE(js_scene_ICameraInfo_constructor)); + + cls->defineProperty("name", _SE(js_scene_ICameraInfo_get_name), _SE(js_scene_ICameraInfo_set_name)); + cls->defineProperty("node", _SE(js_scene_ICameraInfo_get_node), _SE(js_scene_ICameraInfo_set_node)); + cls->defineProperty("projection", _SE(js_scene_ICameraInfo_get_projection), _SE(js_scene_ICameraInfo_set_projection)); + cls->defineProperty("targetDisplay", _SE(js_scene_ICameraInfo_get_targetDisplay), _SE(js_scene_ICameraInfo_set_targetDisplay)); + cls->defineProperty("window", _SE(js_scene_ICameraInfo_get_window), _SE(js_scene_ICameraInfo_set_window)); + cls->defineProperty("priority", _SE(js_scene_ICameraInfo_get_priority), _SE(js_scene_ICameraInfo_set_priority)); + cls->defineProperty("pipeline", _SE(js_scene_ICameraInfo_get_pipeline), _SE(js_scene_ICameraInfo_set_pipeline)); + cls->defineFinalizeFunction(_SE(js_cc_scene_ICameraInfo_finalize)); + cls->install(); + JSBClassType::registerClass(cls); + + __jsb_cc_scene_ICameraInfo_proto = cls->getProto(); + __jsb_cc_scene_ICameraInfo_class = cls; + + + se::ScriptEngine::getInstance()->clearException(); + return true; +} +se::Object* __jsb_cc_scene_Camera_proto = nullptr; // NOLINT +se::Class* __jsb_cc_scene_Camera_class = nullptr; // NOLINT + +static bool js_scene_Camera_attachToScene(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_scene_Camera_attachToScene : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 1) { + HolderType arg0 = {}; + ok &= sevalue_to_native(args[0], &arg0, s.thisObject()); + SE_PRECONDITION2(ok, false, "js_scene_Camera_attachToScene : Error processing arguments"); + cobj->attachToScene(arg0.value()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 1); + return false; +} +SE_BIND_FUNC(js_scene_Camera_attachToScene) + +static bool js_scene_Camera_changeTargetWindow(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_scene_Camera_changeTargetWindow : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 1) { + HolderType arg0 = {}; + ok &= sevalue_to_native(args[0], &arg0, s.thisObject()); + SE_PRECONDITION2(ok, false, "js_scene_Camera_changeTargetWindow : Error processing arguments"); + cobj->changeTargetWindow(arg0.value()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 1); + return false; +} +SE_BIND_FUNC(js_scene_Camera_changeTargetWindow) + +static bool js_scene_Camera_destroy(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_scene_Camera_destroy : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + if (argc == 0) { + cobj->destroy(); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 0); + return false; +} +SE_BIND_FUNC(js_scene_Camera_destroy) + +static bool js_scene_Camera_detachCamera(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_scene_Camera_detachCamera : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + if (argc == 0) { + cobj->detachCamera(); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 0); + return false; +} +SE_BIND_FUNC(js_scene_Camera_detachCamera) + +static bool js_scene_Camera_detachFromScene(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_scene_Camera_detachFromScene : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + if (argc == 0) { + cobj->detachFromScene(); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 0); + return false; +} +SE_BIND_FUNC(js_scene_Camera_detachFromScene) + +static bool js_scene_Camera_getAperture(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_scene_Camera_getAperture : Invalid Native Object"); const auto& args = s.args(); size_t argc = args.size(); CC_UNUSED bool ok = true; if (argc == 0) { - bool result = cobj->getCastShadow(); + auto result = static_cast(cobj->getAperture()); ok &= nativevalue_to_se(result, s.rval(), nullptr /*ctx*/); - SE_PRECONDITION2(ok, false, "js_scene_Model_getCastShadow : Error processing arguments"); + SE_PRECONDITION2(ok, false, "js_scene_Camera_getAperture : Error processing arguments"); SE_HOLD_RETURN_VALUE(result, s.thisObject(), s.rval()); return true; } SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 0); return false; } -SE_BIND_FUNC(js_scene_Model_getCastShadow) +SE_BIND_FUNC_AS_PROP_GET(js_scene_Camera_getAperture) -static bool js_scene_Model_getEnabled(se::State& s) // NOLINT(readability-identifier-naming) +static bool js_scene_Camera_getApertureValue(se::State& s) // NOLINT(readability-identifier-naming) { - auto* cobj = SE_THIS_OBJECT(s); - SE_PRECONDITION2(cobj, false, "js_scene_Model_getEnabled : Invalid Native Object"); + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_scene_Camera_getApertureValue : Invalid Native Object"); const auto& args = s.args(); size_t argc = args.size(); CC_UNUSED bool ok = true; if (argc == 0) { - bool result = cobj->getEnabled(); + float result = cobj->getApertureValue(); ok &= nativevalue_to_se(result, s.rval(), nullptr /*ctx*/); - SE_PRECONDITION2(ok, false, "js_scene_Model_getEnabled : Error processing arguments"); + SE_PRECONDITION2(ok, false, "js_scene_Camera_getApertureValue : Error processing arguments"); SE_HOLD_RETURN_VALUE(result, s.thisObject(), s.rval()); return true; } SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 0); return false; } -SE_BIND_FUNC(js_scene_Model_getEnabled) +SE_BIND_FUNC_AS_PROP_GET(js_scene_Camera_getApertureValue) + +static bool js_scene_Camera_getAspect(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_scene_Camera_getAspect : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 0) { + float result = cobj->getAspect(); + ok &= nativevalue_to_se(result, s.rval(), nullptr /*ctx*/); + SE_PRECONDITION2(ok, false, "js_scene_Camera_getAspect : Error processing arguments"); + SE_HOLD_RETURN_VALUE(result, s.thisObject(), s.rval()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 0); + return false; +} +SE_BIND_FUNC_AS_PROP_GET(js_scene_Camera_getAspect) + +static bool js_scene_Camera_getClearColor(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_scene_Camera_getClearColor : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 0) { + const cc::gfx::Color& result = cobj->getClearColor(); + ok &= nativevalue_to_se(result, s.rval(), nullptr /*ctx*/); + SE_PRECONDITION2(ok, false, "js_scene_Camera_getClearColor : Error processing arguments"); + SE_HOLD_RETURN_VALUE(result, s.thisObject(), s.rval()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 0); + return false; +} +SE_BIND_FUNC_AS_PROP_GET(js_scene_Camera_getClearColor) + +static bool js_scene_Camera_getClearDepth(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_scene_Camera_getClearDepth : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 0) { + float result = cobj->getClearDepth(); + ok &= nativevalue_to_se(result, s.rval(), nullptr /*ctx*/); + SE_PRECONDITION2(ok, false, "js_scene_Camera_getClearDepth : Error processing arguments"); + SE_HOLD_RETURN_VALUE(result, s.thisObject(), s.rval()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 0); + return false; +} +SE_BIND_FUNC_AS_PROP_GET(js_scene_Camera_getClearDepth) + +static bool js_scene_Camera_getClearFlag(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_scene_Camera_getClearFlag : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 0) { + auto result = static_cast(cobj->getClearFlag()); + ok &= nativevalue_to_se(result, s.rval(), nullptr /*ctx*/); + SE_PRECONDITION2(ok, false, "js_scene_Camera_getClearFlag : Error processing arguments"); + SE_HOLD_RETURN_VALUE(result, s.thisObject(), s.rval()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 0); + return false; +} +SE_BIND_FUNC_AS_PROP_GET(js_scene_Camera_getClearFlag) + +static bool js_scene_Camera_getClearStencil(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_scene_Camera_getClearStencil : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 0) { + unsigned int result = cobj->getClearStencil(); + ok &= nativevalue_to_se(result, s.rval(), nullptr /*ctx*/); + SE_PRECONDITION2(ok, false, "js_scene_Camera_getClearStencil : Error processing arguments"); + SE_HOLD_RETURN_VALUE(result, s.thisObject(), s.rval()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 0); + return false; +} +SE_BIND_FUNC_AS_PROP_GET(js_scene_Camera_getClearStencil) + +static bool js_scene_Camera_getEc(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_scene_Camera_getEc : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 0) { + float result = cobj->getEc(); + ok &= nativevalue_to_se(result, s.rval(), nullptr /*ctx*/); + SE_PRECONDITION2(ok, false, "js_scene_Camera_getEc : Error processing arguments"); + SE_HOLD_RETURN_VALUE(result, s.thisObject(), s.rval()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 0); + return false; +} +SE_BIND_FUNC_AS_PROP_GET(js_scene_Camera_getEc) + +static bool js_scene_Camera_getExposure(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_scene_Camera_getExposure : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 0) { + float result = cobj->getExposure(); + ok &= nativevalue_to_se(result, s.rval(), nullptr /*ctx*/); + SE_PRECONDITION2(ok, false, "js_scene_Camera_getExposure : Error processing arguments"); + SE_HOLD_RETURN_VALUE(result, s.thisObject(), s.rval()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 0); + return false; +} +SE_BIND_FUNC_AS_PROP_GET(js_scene_Camera_getExposure) + +static bool js_scene_Camera_getFarClip(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_scene_Camera_getFarClip : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 0) { + float result = cobj->getFarClip(); + ok &= nativevalue_to_se(result, s.rval(), nullptr /*ctx*/); + SE_PRECONDITION2(ok, false, "js_scene_Camera_getFarClip : Error processing arguments"); + SE_HOLD_RETURN_VALUE(result, s.thisObject(), s.rval()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 0); + return false; +} +SE_BIND_FUNC_AS_PROP_GET(js_scene_Camera_getFarClip) + +static bool js_scene_Camera_getForward(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_scene_Camera_getForward : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 0) { + const cc::Vec3& result = cobj->getForward(); + ok &= nativevalue_to_se(result, s.rval(), nullptr /*ctx*/); + SE_PRECONDITION2(ok, false, "js_scene_Camera_getForward : Error processing arguments"); + SE_HOLD_RETURN_VALUE(result, s.thisObject(), s.rval()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 0); + return false; +} +SE_BIND_FUNC_AS_PROP_GET(js_scene_Camera_getForward) + +static bool js_scene_Camera_getFov(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_scene_Camera_getFov : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 0) { + float result = cobj->getFov(); + ok &= nativevalue_to_se(result, s.rval(), nullptr /*ctx*/); + SE_PRECONDITION2(ok, false, "js_scene_Camera_getFov : Error processing arguments"); + SE_HOLD_RETURN_VALUE(result, s.thisObject(), s.rval()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 0); + return false; +} +SE_BIND_FUNC_AS_PROP_GET(js_scene_Camera_getFov) + +static bool js_scene_Camera_getFovAxis(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_scene_Camera_getFovAxis : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 0) { + auto result = static_cast(cobj->getFovAxis()); + ok &= nativevalue_to_se(result, s.rval(), nullptr /*ctx*/); + SE_PRECONDITION2(ok, false, "js_scene_Camera_getFovAxis : Error processing arguments"); + SE_HOLD_RETURN_VALUE(result, s.thisObject(), s.rval()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 0); + return false; +} +SE_BIND_FUNC_AS_PROP_GET(js_scene_Camera_getFovAxis) + +static bool js_scene_Camera_getFrustum(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_scene_Camera_getFrustum : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 0) { + const cc::geometry::Frustum& result = cobj->getFrustum(); + ok &= nativevalue_to_se(result, s.rval(), nullptr /*ctx*/); + SE_PRECONDITION2(ok, false, "js_scene_Camera_getFrustum : Error processing arguments"); + SE_HOLD_RETURN_VALUE(result, s.thisObject(), s.rval()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 0); + return false; +} +SE_BIND_FUNC_AS_PROP_GET(js_scene_Camera_getFrustum) + +static bool js_scene_Camera_getHeight(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_scene_Camera_getHeight : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 0) { + unsigned int result = cobj->getHeight(); + ok &= nativevalue_to_se(result, s.rval(), nullptr /*ctx*/); + SE_PRECONDITION2(ok, false, "js_scene_Camera_getHeight : Error processing arguments"); + SE_HOLD_RETURN_VALUE(result, s.thisObject(), s.rval()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 0); + return false; +} +SE_BIND_FUNC_AS_PROP_GET(js_scene_Camera_getHeight) + +static bool js_scene_Camera_getIso(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_scene_Camera_getIso : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 0) { + auto result = static_cast(cobj->getIso()); + ok &= nativevalue_to_se(result, s.rval(), nullptr /*ctx*/); + SE_PRECONDITION2(ok, false, "js_scene_Camera_getIso : Error processing arguments"); + SE_HOLD_RETURN_VALUE(result, s.thisObject(), s.rval()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 0); + return false; +} +SE_BIND_FUNC_AS_PROP_GET(js_scene_Camera_getIso) + +static bool js_scene_Camera_getIsoValue(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_scene_Camera_getIsoValue : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 0) { + float result = cobj->getIsoValue(); + ok &= nativevalue_to_se(result, s.rval(), nullptr /*ctx*/); + SE_PRECONDITION2(ok, false, "js_scene_Camera_getIsoValue : Error processing arguments"); + SE_HOLD_RETURN_VALUE(result, s.thisObject(), s.rval()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 0); + return false; +} +SE_BIND_FUNC_AS_PROP_GET(js_scene_Camera_getIsoValue) + +static bool js_scene_Camera_getMatProj(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_scene_Camera_getMatProj : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 0) { + const cc::Mat4& result = cobj->getMatProj(); + ok &= nativevalue_to_se(result, s.rval(), nullptr /*ctx*/); + SE_PRECONDITION2(ok, false, "js_scene_Camera_getMatProj : Error processing arguments"); + SE_HOLD_RETURN_VALUE(result, s.thisObject(), s.rval()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 0); + return false; +} +SE_BIND_FUNC_AS_PROP_GET(js_scene_Camera_getMatProj) + +static bool js_scene_Camera_getMatProjInv(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_scene_Camera_getMatProjInv : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 0) { + const cc::Mat4& result = cobj->getMatProjInv(); + ok &= nativevalue_to_se(result, s.rval(), nullptr /*ctx*/); + SE_PRECONDITION2(ok, false, "js_scene_Camera_getMatProjInv : Error processing arguments"); + SE_HOLD_RETURN_VALUE(result, s.thisObject(), s.rval()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 0); + return false; +} +SE_BIND_FUNC_AS_PROP_GET(js_scene_Camera_getMatProjInv) + +static bool js_scene_Camera_getMatView(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_scene_Camera_getMatView : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 0) { + const cc::Mat4& result = cobj->getMatView(); + ok &= nativevalue_to_se(result, s.rval(), nullptr /*ctx*/); + SE_PRECONDITION2(ok, false, "js_scene_Camera_getMatView : Error processing arguments"); + SE_HOLD_RETURN_VALUE(result, s.thisObject(), s.rval()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 0); + return false; +} +SE_BIND_FUNC_AS_PROP_GET(js_scene_Camera_getMatView) + +static bool js_scene_Camera_getMatViewProj(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_scene_Camera_getMatViewProj : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 0) { + const cc::Mat4& result = cobj->getMatViewProj(); + ok &= nativevalue_to_se(result, s.rval(), nullptr /*ctx*/); + SE_PRECONDITION2(ok, false, "js_scene_Camera_getMatViewProj : Error processing arguments"); + SE_HOLD_RETURN_VALUE(result, s.thisObject(), s.rval()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 0); + return false; +} +SE_BIND_FUNC_AS_PROP_GET(js_scene_Camera_getMatViewProj) + +static bool js_scene_Camera_getMatViewProjInv(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_scene_Camera_getMatViewProjInv : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 0) { + const cc::Mat4& result = cobj->getMatViewProjInv(); + ok &= nativevalue_to_se(result, s.rval(), nullptr /*ctx*/); + SE_PRECONDITION2(ok, false, "js_scene_Camera_getMatViewProjInv : Error processing arguments"); + SE_HOLD_RETURN_VALUE(result, s.thisObject(), s.rval()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 0); + return false; +} +SE_BIND_FUNC_AS_PROP_GET(js_scene_Camera_getMatViewProjInv) + +static bool js_scene_Camera_getName(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_scene_Camera_getName : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 0) { + const std::string& result = cobj->getName(); + ok &= nativevalue_to_se(result, s.rval(), nullptr /*ctx*/); + SE_PRECONDITION2(ok, false, "js_scene_Camera_getName : Error processing arguments"); + SE_HOLD_RETURN_VALUE(result, s.thisObject(), s.rval()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 0); + return false; +} +SE_BIND_FUNC_AS_PROP_GET(js_scene_Camera_getName) + +static bool js_scene_Camera_getNearClip(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_scene_Camera_getNearClip : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 0) { + float result = cobj->getNearClip(); + ok &= nativevalue_to_se(result, s.rval(), nullptr /*ctx*/); + SE_PRECONDITION2(ok, false, "js_scene_Camera_getNearClip : Error processing arguments"); + SE_HOLD_RETURN_VALUE(result, s.thisObject(), s.rval()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 0); + return false; +} +SE_BIND_FUNC_AS_PROP_GET(js_scene_Camera_getNearClip) + +static bool js_scene_Camera_getNode(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_scene_Camera_getNode : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 0) { + cc::Node* result = cobj->getNode(); + ok &= nativevalue_to_se(result, s.rval(), nullptr /*ctx*/); + SE_PRECONDITION2(ok, false, "js_scene_Camera_getNode : Error processing arguments"); + SE_HOLD_RETURN_VALUE(result, s.thisObject(), s.rval()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 0); + return false; +} +SE_BIND_FUNC_AS_PROP_GET(js_scene_Camera_getNode) + +static bool js_scene_Camera_getOrthoHeight(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_scene_Camera_getOrthoHeight : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 0) { + float result = cobj->getOrthoHeight(); + ok &= nativevalue_to_se(result, s.rval(), nullptr /*ctx*/); + SE_PRECONDITION2(ok, false, "js_scene_Camera_getOrthoHeight : Error processing arguments"); + SE_HOLD_RETURN_VALUE(result, s.thisObject(), s.rval()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 0); + return false; +} +SE_BIND_FUNC_AS_PROP_GET(js_scene_Camera_getOrthoHeight) + +static bool js_scene_Camera_getPosition(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_scene_Camera_getPosition : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 0) { + const cc::Vec3& result = cobj->getPosition(); + ok &= nativevalue_to_se(result, s.rval(), nullptr /*ctx*/); + SE_PRECONDITION2(ok, false, "js_scene_Camera_getPosition : Error processing arguments"); + SE_HOLD_RETURN_VALUE(result, s.thisObject(), s.rval()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 0); + return false; +} +SE_BIND_FUNC_AS_PROP_GET(js_scene_Camera_getPosition) + +static bool js_scene_Camera_getPriority(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_scene_Camera_getPriority : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 0) { + unsigned int result = cobj->getPriority(); + ok &= nativevalue_to_se(result, s.rval(), nullptr /*ctx*/); + SE_PRECONDITION2(ok, false, "js_scene_Camera_getPriority : Error processing arguments"); + SE_HOLD_RETURN_VALUE(result, s.thisObject(), s.rval()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 0); + return false; +} +SE_BIND_FUNC_AS_PROP_GET(js_scene_Camera_getPriority) + +static bool js_scene_Camera_getProjectionType(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_scene_Camera_getProjectionType : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 0) { + auto result = static_cast(cobj->getProjectionType()); + ok &= nativevalue_to_se(result, s.rval(), nullptr /*ctx*/); + SE_PRECONDITION2(ok, false, "js_scene_Camera_getProjectionType : Error processing arguments"); + SE_HOLD_RETURN_VALUE(result, s.thisObject(), s.rval()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 0); + return false; +} +SE_BIND_FUNC_AS_PROP_GET(js_scene_Camera_getProjectionType) + +static bool js_scene_Camera_getScene(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_scene_Camera_getScene : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 0) { + cc::scene::RenderScene* result = cobj->getScene(); + ok &= nativevalue_to_se(result, s.rval(), nullptr /*ctx*/); + SE_PRECONDITION2(ok, false, "js_scene_Camera_getScene : Error processing arguments"); + SE_HOLD_RETURN_VALUE(result, s.thisObject(), s.rval()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 0); + return false; +} +SE_BIND_FUNC_AS_PROP_GET(js_scene_Camera_getScene) + +static bool js_scene_Camera_getScreenScale(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_scene_Camera_getScreenScale : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 0) { + float result = cobj->getScreenScale(); + ok &= nativevalue_to_se(result, s.rval(), nullptr /*ctx*/); + SE_PRECONDITION2(ok, false, "js_scene_Camera_getScreenScale : Error processing arguments"); + SE_HOLD_RETURN_VALUE(result, s.thisObject(), s.rval()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 0); + return false; +} +SE_BIND_FUNC_AS_PROP_GET(js_scene_Camera_getScreenScale) + +static bool js_scene_Camera_getShutter(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_scene_Camera_getShutter : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 0) { + auto result = static_cast(cobj->getShutter()); + ok &= nativevalue_to_se(result, s.rval(), nullptr /*ctx*/); + SE_PRECONDITION2(ok, false, "js_scene_Camera_getShutter : Error processing arguments"); + SE_HOLD_RETURN_VALUE(result, s.thisObject(), s.rval()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 0); + return false; +} +SE_BIND_FUNC_AS_PROP_GET(js_scene_Camera_getShutter) + +static bool js_scene_Camera_getShutterValue(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_scene_Camera_getShutterValue : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 0) { + float result = cobj->getShutterValue(); + ok &= nativevalue_to_se(result, s.rval(), nullptr /*ctx*/); + SE_PRECONDITION2(ok, false, "js_scene_Camera_getShutterValue : Error processing arguments"); + SE_HOLD_RETURN_VALUE(result, s.thisObject(), s.rval()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 0); + return false; +} +SE_BIND_FUNC_AS_PROP_GET(js_scene_Camera_getShutterValue) + +static bool js_scene_Camera_getViewport(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_scene_Camera_getViewport : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 0) { + const cc::Vec4& result = cobj->getViewport(); + ok &= nativevalue_to_se(result, s.rval(), nullptr /*ctx*/); + SE_PRECONDITION2(ok, false, "js_scene_Camera_getViewport : Error processing arguments"); + SE_HOLD_RETURN_VALUE(result, s.thisObject(), s.rval()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 0); + return false; +} +SE_BIND_FUNC_AS_PROP_GET(js_scene_Camera_getViewport) + +static bool js_scene_Camera_getVisibility(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_scene_Camera_getVisibility : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 0) { + unsigned int result = cobj->getVisibility(); + ok &= nativevalue_to_se(result, s.rval(), nullptr /*ctx*/); + SE_PRECONDITION2(ok, false, "js_scene_Camera_getVisibility : Error processing arguments"); + SE_HOLD_RETURN_VALUE(result, s.thisObject(), s.rval()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 0); + return false; +} +SE_BIND_FUNC_AS_PROP_GET(js_scene_Camera_getVisibility) + +static bool js_scene_Camera_getWidth(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_scene_Camera_getWidth : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 0) { + unsigned int result = cobj->getWidth(); + ok &= nativevalue_to_se(result, s.rval(), nullptr /*ctx*/); + SE_PRECONDITION2(ok, false, "js_scene_Camera_getWidth : Error processing arguments"); + SE_HOLD_RETURN_VALUE(result, s.thisObject(), s.rval()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 0); + return false; +} +SE_BIND_FUNC_AS_PROP_GET(js_scene_Camera_getWidth) + +static bool js_scene_Camera_getWindow(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_scene_Camera_getWindow : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 0) { + cc::scene::RenderWindow* result = cobj->getWindow(); + ok &= nativevalue_to_se(result, s.rval(), nullptr /*ctx*/); + SE_PRECONDITION2(ok, false, "js_scene_Camera_getWindow : Error processing arguments"); + SE_HOLD_RETURN_VALUE(result, s.thisObject(), s.rval()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 0); + return false; +} +SE_BIND_FUNC_AS_PROP_GET(js_scene_Camera_getWindow) + +static bool js_scene_Camera_initialize(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_scene_Camera_initialize : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 1) { + HolderType arg0 = {}; + ok &= sevalue_to_native(args[0], &arg0, s.thisObject()); + SE_PRECONDITION2(ok, false, "js_scene_Camera_initialize : Error processing arguments"); + bool result = cobj->initialize(arg0.value()); + ok &= nativevalue_to_se(result, s.rval(), nullptr /*ctx*/); + SE_PRECONDITION2(ok, false, "js_scene_Camera_initialize : Error processing arguments"); + SE_HOLD_RETURN_VALUE(result, s.thisObject(), s.rval()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 1); + return false; +} +SE_BIND_FUNC(js_scene_Camera_initialize) + +static bool js_scene_Camera_isEnabled(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_scene_Camera_isEnabled : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 0) { + bool result = cobj->isEnabled(); + ok &= nativevalue_to_se(result, s.rval(), nullptr /*ctx*/); + SE_PRECONDITION2(ok, false, "js_scene_Camera_isEnabled : Error processing arguments"); + SE_HOLD_RETURN_VALUE(result, s.thisObject(), s.rval()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 0); + return false; +} +SE_BIND_FUNC_AS_PROP_GET(js_scene_Camera_isEnabled) + +static bool js_scene_Camera_isWindowSize(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_scene_Camera_isWindowSize : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 0) { + bool result = cobj->isWindowSize(); + ok &= nativevalue_to_se(result, s.rval(), nullptr /*ctx*/); + SE_PRECONDITION2(ok, false, "js_scene_Camera_isWindowSize : Error processing arguments"); + SE_HOLD_RETURN_VALUE(result, s.thisObject(), s.rval()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 0); + return false; +} +SE_BIND_FUNC_AS_PROP_GET(js_scene_Camera_isWindowSize) + +static bool js_scene_Camera_resize(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_scene_Camera_resize : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 2) { + HolderType arg0 = {}; + HolderType arg1 = {}; + ok &= sevalue_to_native(args[0], &arg0, s.thisObject()); + ok &= sevalue_to_native(args[1], &arg1, s.thisObject()); + SE_PRECONDITION2(ok, false, "js_scene_Camera_resize : Error processing arguments"); + cobj->resize(arg0.value(), arg1.value()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 2); + return false; +} +SE_BIND_FUNC(js_scene_Camera_resize) + +static bool js_scene_Camera_setAperture(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_scene_Camera_setAperture : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 1) { + HolderType arg0 = {}; + ok &= sevalue_to_native(args[0], &arg0, s.thisObject()); + SE_PRECONDITION2(ok, false, "js_scene_Camera_setAperture : Error processing arguments"); + cobj->setAperture(arg0.value()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 1); + return false; +} +SE_BIND_FUNC_AS_PROP_SET(js_scene_Camera_setAperture) + +static bool js_scene_Camera_setClearColor(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_scene_Camera_setClearColor : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 1) { + HolderType arg0 = {}; + ok &= sevalue_to_native(args[0], &arg0, s.thisObject()); + SE_PRECONDITION2(ok, false, "js_scene_Camera_setClearColor : Error processing arguments"); + cobj->setClearColor(arg0.value()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 1); + return false; +} +SE_BIND_FUNC_AS_PROP_SET(js_scene_Camera_setClearColor) + +static bool js_scene_Camera_setClearDepth(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_scene_Camera_setClearDepth : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 1) { + HolderType arg0 = {}; + ok &= sevalue_to_native(args[0], &arg0, s.thisObject()); + SE_PRECONDITION2(ok, false, "js_scene_Camera_setClearDepth : Error processing arguments"); + cobj->setClearDepth(arg0.value()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 1); + return false; +} +SE_BIND_FUNC_AS_PROP_SET(js_scene_Camera_setClearDepth) + +static bool js_scene_Camera_setClearFlag(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_scene_Camera_setClearFlag : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 1) { + HolderType arg0 = {}; + ok &= sevalue_to_native(args[0], &arg0, s.thisObject()); + SE_PRECONDITION2(ok, false, "js_scene_Camera_setClearFlag : Error processing arguments"); + cobj->setClearFlag(arg0.value()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 1); + return false; +} +SE_BIND_FUNC_AS_PROP_SET(js_scene_Camera_setClearFlag) + +static bool js_scene_Camera_setClearStencil(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_scene_Camera_setClearStencil : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 1) { + HolderType arg0 = {}; + ok &= sevalue_to_native(args[0], &arg0, s.thisObject()); + SE_PRECONDITION2(ok, false, "js_scene_Camera_setClearStencil : Error processing arguments"); + cobj->setClearStencil(arg0.value()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 1); + return false; +} +SE_BIND_FUNC_AS_PROP_SET(js_scene_Camera_setClearStencil) + +static bool js_scene_Camera_setEc(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_scene_Camera_setEc : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 1) { + HolderType arg0 = {}; + ok &= sevalue_to_native(args[0], &arg0, s.thisObject()); + SE_PRECONDITION2(ok, false, "js_scene_Camera_setEc : Error processing arguments"); + cobj->setEc(arg0.value()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 1); + return false; +} +SE_BIND_FUNC_AS_PROP_SET(js_scene_Camera_setEc) + +static bool js_scene_Camera_setEnabled(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_scene_Camera_setEnabled : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 1) { + HolderType arg0 = {}; + ok &= sevalue_to_native(args[0], &arg0, s.thisObject()); + SE_PRECONDITION2(ok, false, "js_scene_Camera_setEnabled : Error processing arguments"); + cobj->setEnabled(arg0.value()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 1); + return false; +} +SE_BIND_FUNC_AS_PROP_SET(js_scene_Camera_setEnabled) + +static bool js_scene_Camera_setFarClip(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_scene_Camera_setFarClip : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 1) { + HolderType arg0 = {}; + ok &= sevalue_to_native(args[0], &arg0, s.thisObject()); + SE_PRECONDITION2(ok, false, "js_scene_Camera_setFarClip : Error processing arguments"); + cobj->setFarClip(arg0.value()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 1); + return false; +} +SE_BIND_FUNC_AS_PROP_SET(js_scene_Camera_setFarClip) + +static bool js_scene_Camera_setFixedSize(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_scene_Camera_setFixedSize : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 2) { + HolderType arg0 = {}; + HolderType arg1 = {}; + ok &= sevalue_to_native(args[0], &arg0, s.thisObject()); + ok &= sevalue_to_native(args[1], &arg1, s.thisObject()); + SE_PRECONDITION2(ok, false, "js_scene_Camera_setFixedSize : Error processing arguments"); + cobj->setFixedSize(arg0.value(), arg1.value()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 2); + return false; +} +SE_BIND_FUNC(js_scene_Camera_setFixedSize) + +static bool js_scene_Camera_setForward(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_scene_Camera_setForward : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 1) { + HolderType arg0 = {}; + ok &= sevalue_to_native(args[0], &arg0, s.thisObject()); + SE_PRECONDITION2(ok, false, "js_scene_Camera_setForward : Error processing arguments"); + cobj->setForward(arg0.value()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 1); + return false; +} +SE_BIND_FUNC_AS_PROP_SET(js_scene_Camera_setForward) + +static bool js_scene_Camera_setFov(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_scene_Camera_setFov : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 1) { + HolderType arg0 = {}; + ok &= sevalue_to_native(args[0], &arg0, s.thisObject()); + SE_PRECONDITION2(ok, false, "js_scene_Camera_setFov : Error processing arguments"); + cobj->setFov(arg0.value()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 1); + return false; +} +SE_BIND_FUNC_AS_PROP_SET(js_scene_Camera_setFov) + +static bool js_scene_Camera_setFovAxis(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_scene_Camera_setFovAxis : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 1) { + HolderType arg0 = {}; + ok &= sevalue_to_native(args[0], &arg0, s.thisObject()); + SE_PRECONDITION2(ok, false, "js_scene_Camera_setFovAxis : Error processing arguments"); + cobj->setFovAxis(arg0.value()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 1); + return false; +} +SE_BIND_FUNC_AS_PROP_SET(js_scene_Camera_setFovAxis) + +static bool js_scene_Camera_setFrustum(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_scene_Camera_setFrustum : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 1) { + HolderType arg0 = {}; + ok &= sevalue_to_native(args[0], &arg0, s.thisObject()); + SE_PRECONDITION2(ok, false, "js_scene_Camera_setFrustum : Error processing arguments"); + cobj->setFrustum(arg0.value()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 1); + return false; +} +SE_BIND_FUNC_AS_PROP_SET(js_scene_Camera_setFrustum) + +static bool js_scene_Camera_setIso(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_scene_Camera_setIso : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 1) { + HolderType arg0 = {}; + ok &= sevalue_to_native(args[0], &arg0, s.thisObject()); + SE_PRECONDITION2(ok, false, "js_scene_Camera_setIso : Error processing arguments"); + cobj->setIso(arg0.value()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 1); + return false; +} +SE_BIND_FUNC_AS_PROP_SET(js_scene_Camera_setIso) + +static bool js_scene_Camera_setNearClip(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_scene_Camera_setNearClip : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 1) { + HolderType arg0 = {}; + ok &= sevalue_to_native(args[0], &arg0, s.thisObject()); + SE_PRECONDITION2(ok, false, "js_scene_Camera_setNearClip : Error processing arguments"); + cobj->setNearClip(arg0.value()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 1); + return false; +} +SE_BIND_FUNC_AS_PROP_SET(js_scene_Camera_setNearClip) + +static bool js_scene_Camera_setNode(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_scene_Camera_setNode : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 1) { + HolderType arg0 = {}; + ok &= sevalue_to_native(args[0], &arg0, s.thisObject()); + SE_PRECONDITION2(ok, false, "js_scene_Camera_setNode : Error processing arguments"); + cobj->setNode(arg0.value()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 1); + return false; +} +SE_BIND_FUNC_AS_PROP_SET(js_scene_Camera_setNode) + +static bool js_scene_Camera_setOrthoHeight(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_scene_Camera_setOrthoHeight : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 1) { + HolderType arg0 = {}; + ok &= sevalue_to_native(args[0], &arg0, s.thisObject()); + SE_PRECONDITION2(ok, false, "js_scene_Camera_setOrthoHeight : Error processing arguments"); + cobj->setOrthoHeight(arg0.value()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 1); + return false; +} +SE_BIND_FUNC_AS_PROP_SET(js_scene_Camera_setOrthoHeight) + +static bool js_scene_Camera_setPosition(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_scene_Camera_setPosition : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 1) { + HolderType arg0 = {}; + ok &= sevalue_to_native(args[0], &arg0, s.thisObject()); + SE_PRECONDITION2(ok, false, "js_scene_Camera_setPosition : Error processing arguments"); + cobj->setPosition(arg0.value()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 1); + return false; +} +SE_BIND_FUNC_AS_PROP_SET(js_scene_Camera_setPosition) + +static bool js_scene_Camera_setPriority(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_scene_Camera_setPriority : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 1) { + HolderType arg0 = {}; + ok &= sevalue_to_native(args[0], &arg0, s.thisObject()); + SE_PRECONDITION2(ok, false, "js_scene_Camera_setPriority : Error processing arguments"); + cobj->setPriority(arg0.value()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 1); + return false; +} +SE_BIND_FUNC_AS_PROP_SET(js_scene_Camera_setPriority) + +static bool js_scene_Camera_setProjectionType(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_scene_Camera_setProjectionType : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 1) { + HolderType arg0 = {}; + ok &= sevalue_to_native(args[0], &arg0, s.thisObject()); + SE_PRECONDITION2(ok, false, "js_scene_Camera_setProjectionType : Error processing arguments"); + cobj->setProjectionType(arg0.value()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 1); + return false; +} +SE_BIND_FUNC_AS_PROP_SET(js_scene_Camera_setProjectionType) + +static bool js_scene_Camera_setScreenScale(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_scene_Camera_setScreenScale : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 1) { + HolderType arg0 = {}; + ok &= sevalue_to_native(args[0], &arg0, s.thisObject()); + SE_PRECONDITION2(ok, false, "js_scene_Camera_setScreenScale : Error processing arguments"); + cobj->setScreenScale(arg0.value()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 1); + return false; +} +SE_BIND_FUNC_AS_PROP_SET(js_scene_Camera_setScreenScale) + +static bool js_scene_Camera_setShutter(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_scene_Camera_setShutter : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 1) { + HolderType arg0 = {}; + ok &= sevalue_to_native(args[0], &arg0, s.thisObject()); + SE_PRECONDITION2(ok, false, "js_scene_Camera_setShutter : Error processing arguments"); + cobj->setShutter(arg0.value()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 1); + return false; +} +SE_BIND_FUNC_AS_PROP_SET(js_scene_Camera_setShutter) + +static bool js_scene_Camera_setViewport(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_scene_Camera_setViewport : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 1) { + HolderType arg0 = {}; + ok &= sevalue_to_native(args[0], &arg0, s.thisObject()); + SE_PRECONDITION2(ok, false, "js_scene_Camera_setViewport : Error processing arguments"); + cobj->setViewport(arg0.value()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 1); + return false; +} +SE_BIND_FUNC_AS_PROP_SET(js_scene_Camera_setViewport) + +static bool js_scene_Camera_setViewportInOrientedSpace(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_scene_Camera_setViewportInOrientedSpace : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 1) { + HolderType arg0 = {}; + ok &= sevalue_to_native(args[0], &arg0, s.thisObject()); + SE_PRECONDITION2(ok, false, "js_scene_Camera_setViewportInOrientedSpace : Error processing arguments"); + cobj->setViewportInOrientedSpace(arg0.value()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 1); + return false; +} +SE_BIND_FUNC(js_scene_Camera_setViewportInOrientedSpace) + +static bool js_scene_Camera_setVisibility(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_scene_Camera_setVisibility : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 1) { + HolderType arg0 = {}; + ok &= sevalue_to_native(args[0], &arg0, s.thisObject()); + SE_PRECONDITION2(ok, false, "js_scene_Camera_setVisibility : Error processing arguments"); + cobj->setVisibility(arg0.value()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 1); + return false; +} +SE_BIND_FUNC_AS_PROP_SET(js_scene_Camera_setVisibility) + +static bool js_scene_Camera_setWindow(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_scene_Camera_setWindow : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 1) { + HolderType arg0 = {}; + ok &= sevalue_to_native(args[0], &arg0, s.thisObject()); + SE_PRECONDITION2(ok, false, "js_scene_Camera_setWindow : Error processing arguments"); + cobj->setWindow(arg0.value()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 1); + return false; +} +SE_BIND_FUNC_AS_PROP_SET(js_scene_Camera_setWindow) + +static bool js_scene_Camera_setWindowSize(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_scene_Camera_setWindowSize : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 1) { + HolderType arg0 = {}; + ok &= sevalue_to_native(args[0], &arg0, s.thisObject()); + SE_PRECONDITION2(ok, false, "js_scene_Camera_setWindowSize : Error processing arguments"); + cobj->setWindowSize(arg0.value()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 1); + return false; +} +SE_BIND_FUNC_AS_PROP_SET(js_scene_Camera_setWindowSize) + +static bool js_scene_Camera_update(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_scene_Camera_update : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 0) { + cobj->update(); + return true; + } + if (argc == 1) { + HolderType arg0 = {}; + ok &= sevalue_to_native(args[0], &arg0, s.thisObject()); + SE_PRECONDITION2(ok, false, "js_scene_Camera_update : Error processing arguments"); + cobj->update(arg0.value()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 1); + return false; +} +SE_BIND_FUNC(js_scene_Camera_update) + +static bool js_scene_Camera_getStandardExposureValue_static(se::State& s) // NOLINT(readability-identifier-naming) +{ + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 0) { + float result = cc::scene::Camera::getStandardExposureValue(); + ok &= nativevalue_to_se(result, s.rval(), nullptr /*ctx*/); + SE_PRECONDITION2(ok, false, "js_scene_Camera_getStandardExposureValue_static : Error processing arguments"); + SE_HOLD_RETURN_VALUE(result, s.thisObject(), s.rval()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 0); + return false; +} +SE_BIND_FUNC(js_scene_Camera_getStandardExposureValue_static) + +static bool js_scene_Camera_getStandardLightMeterScale_static(se::State& s) // NOLINT(readability-identifier-naming) +{ + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 0) { + float result = cc::scene::Camera::getStandardLightMeterScale(); + ok &= nativevalue_to_se(result, s.rval(), nullptr /*ctx*/); + SE_PRECONDITION2(ok, false, "js_scene_Camera_getStandardLightMeterScale_static : Error processing arguments"); + SE_HOLD_RETURN_VALUE(result, s.thisObject(), s.rval()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 0); + return false; +} +SE_BIND_FUNC(js_scene_Camera_getStandardLightMeterScale_static) + +static bool js_scene_Camera_get_SKYBOX_FLAG(se::State& s) // NOLINT(readability-identifier-naming) +{ + CC_UNUSED bool ok = true; + se::Value jsret; + ok &= nativevalue_to_se(cc::scene::Camera::SKYBOX_FLAG, jsret, s.thisObject() /*ctx*/); + s.rval() = jsret; + // SE_HOLD_RETURN_VALUE(cobj->SKYBOX_FLAG, s.thisObject(), s.rval()); + return true; +} +SE_BIND_PROP_GET(js_scene_Camera_get_SKYBOX_FLAG) + + +SE_DECLARE_FINALIZE_FUNC(js_cc_scene_Camera_finalize) + +static bool js_scene_Camera_constructor(se::State& s) // NOLINT(readability-identifier-naming) constructor.c +{ + CC_UNUSED bool ok = true; + const auto& args = s.args(); + cc::gfx::Device* arg0 = nullptr; + ok &= sevalue_to_native(args[0], &arg0, s.thisObject()); + SE_PRECONDITION2(ok, false, "js_scene_Camera_constructor : Error processing arguments"); + auto *ptr = JSB_MAKE_PRIVATE_OBJECT(cc::scene::Camera, arg0); + s.thisObject()->setPrivateObject(ptr); + return true; +} +SE_BIND_CTOR(js_scene_Camera_constructor, __jsb_cc_scene_Camera_class, js_cc_scene_Camera_finalize) + +static bool js_cc_scene_Camera_finalize(se::State& s) // NOLINT(readability-identifier-naming) +{ + return true; +} +SE_BIND_FINALIZE_FUNC(js_cc_scene_Camera_finalize) + +bool js_register_scene_Camera(se::Object* obj) // NOLINT(readability-identifier-naming) +{ + auto* cls = se::Class::create("Camera", obj, nullptr, _SE(js_scene_Camera_constructor)); + + cls->defineProperty("apertureValue", _SE(js_scene_Camera_getApertureValue_asGetter), nullptr); + cls->defineProperty("scene", _SE(js_scene_Camera_getScene_asGetter), nullptr); + cls->defineProperty("ec", _SE(js_scene_Camera_getEc_asGetter), _SE(js_scene_Camera_setEc_asSetter)); + cls->defineProperty("height", _SE(js_scene_Camera_getHeight_asGetter), nullptr); + cls->defineProperty("farClip", _SE(js_scene_Camera_getFarClip_asGetter), _SE(js_scene_Camera_setFarClip_asSetter)); + cls->defineProperty("aspect", _SE(js_scene_Camera_getAspect_asGetter), nullptr); + cls->defineProperty("nearClip", _SE(js_scene_Camera_getNearClip_asGetter), _SE(js_scene_Camera_setNearClip_asSetter)); + cls->defineProperty("priority", _SE(js_scene_Camera_getPriority_asGetter), _SE(js_scene_Camera_setPriority_asSetter)); + cls->defineProperty("fov", _SE(js_scene_Camera_getFov_asGetter), _SE(js_scene_Camera_setFov_asSetter)); + cls->defineProperty("clearColor", _SE(js_scene_Camera_getClearColor_asGetter), _SE(js_scene_Camera_setClearColor_asSetter)); + cls->defineProperty("orthoHeight", _SE(js_scene_Camera_getOrthoHeight_asGetter), _SE(js_scene_Camera_setOrthoHeight_asSetter)); + cls->defineProperty("width", _SE(js_scene_Camera_getWidth_asGetter), nullptr); + cls->defineProperty("window", _SE(js_scene_Camera_getWindow_asGetter), _SE(js_scene_Camera_setWindow_asSetter)); + cls->defineProperty("isWindowSize", _SE(js_scene_Camera_isWindowSize_asGetter), _SE(js_scene_Camera_setWindowSize_asSetter)); + cls->defineProperty("matProj", _SE(js_scene_Camera_getMatProj_asGetter), nullptr); + cls->defineProperty("forward", _SE(js_scene_Camera_getForward_asGetter), _SE(js_scene_Camera_setForward_asSetter)); + cls->defineProperty("projectionType", _SE(js_scene_Camera_getProjectionType_asGetter), _SE(js_scene_Camera_setProjectionType_asSetter)); + cls->defineProperty("clearFlag", _SE(js_scene_Camera_getClearFlag_asGetter), _SE(js_scene_Camera_setClearFlag_asSetter)); + cls->defineProperty("node", _SE(js_scene_Camera_getNode_asGetter), _SE(js_scene_Camera_setNode_asSetter)); + cls->defineProperty("shutterValue", _SE(js_scene_Camera_getShutterValue_asGetter), nullptr); + cls->defineProperty("matViewProj", _SE(js_scene_Camera_getMatViewProj_asGetter), nullptr); + cls->defineProperty("frustum", _SE(js_scene_Camera_getFrustum_asGetter), _SE(js_scene_Camera_setFrustum_asSetter)); + cls->defineProperty("isoValue", _SE(js_scene_Camera_getIsoValue_asGetter), nullptr); + cls->defineProperty("clearStencil", _SE(js_scene_Camera_getClearStencil_asGetter), _SE(js_scene_Camera_setClearStencil_asSetter)); + cls->defineProperty("visibility", _SE(js_scene_Camera_getVisibility_asGetter), _SE(js_scene_Camera_setVisibility_asSetter)); + cls->defineProperty("aperture", _SE(js_scene_Camera_getAperture_asGetter), _SE(js_scene_Camera_setAperture_asSetter)); + cls->defineProperty("clearDepth", _SE(js_scene_Camera_getClearDepth_asGetter), _SE(js_scene_Camera_setClearDepth_asSetter)); + cls->defineProperty("viewport", _SE(js_scene_Camera_getViewport_asGetter), _SE(js_scene_Camera_setViewport_asSetter)); + cls->defineProperty("exposure", _SE(js_scene_Camera_getExposure_asGetter), nullptr); + cls->defineProperty("name", _SE(js_scene_Camera_getName_asGetter), nullptr); + cls->defineProperty("matProjInv", _SE(js_scene_Camera_getMatProjInv_asGetter), nullptr); + cls->defineProperty("enabled", _SE(js_scene_Camera_isEnabled_asGetter), _SE(js_scene_Camera_setEnabled_asSetter)); + cls->defineProperty("fovAxis", _SE(js_scene_Camera_getFovAxis_asGetter), _SE(js_scene_Camera_setFovAxis_asSetter)); + cls->defineProperty("matView", _SE(js_scene_Camera_getMatView_asGetter), nullptr); + cls->defineProperty("matViewProjInv", _SE(js_scene_Camera_getMatViewProjInv_asGetter), nullptr); + cls->defineProperty("shutter", _SE(js_scene_Camera_getShutter_asGetter), _SE(js_scene_Camera_setShutter_asSetter)); + cls->defineProperty("screenScale", _SE(js_scene_Camera_getScreenScale_asGetter), _SE(js_scene_Camera_setScreenScale_asSetter)); + cls->defineProperty("iso", _SE(js_scene_Camera_getIso_asGetter), _SE(js_scene_Camera_setIso_asSetter)); + cls->defineProperty("position", _SE(js_scene_Camera_getPosition_asGetter), _SE(js_scene_Camera_setPosition_asSetter)); + cls->defineFunction("attachToScene", _SE(js_scene_Camera_attachToScene)); + cls->defineFunction("changeTargetWindow", _SE(js_scene_Camera_changeTargetWindow)); + cls->defineFunction("destroy", _SE(js_scene_Camera_destroy)); + cls->defineFunction("detachCamera", _SE(js_scene_Camera_detachCamera)); + cls->defineFunction("detachFromScene", _SE(js_scene_Camera_detachFromScene)); + cls->defineFunction("initialize", _SE(js_scene_Camera_initialize)); + cls->defineFunction("resize", _SE(js_scene_Camera_resize)); + cls->defineFunction("setFixedSize", _SE(js_scene_Camera_setFixedSize)); + cls->defineFunction("setViewportInOrientedSpace", _SE(js_scene_Camera_setViewportInOrientedSpace)); + cls->defineFunction("update", _SE(js_scene_Camera_update)); + cls->defineStaticFunction("getStandardExposureValue", _SE(js_scene_Camera_getStandardExposureValue_static)); + cls->defineStaticFunction("getStandardLightMeterScale", _SE(js_scene_Camera_getStandardLightMeterScale_static)); + // static fields + cls->defineStaticProperty("SKYBOX_FLAG", _SE(js_scene_Camera_get_SKYBOX_FLAG), nullptr); + cls->defineFinalizeFunction(_SE(js_cc_scene_Camera_finalize)); + cls->install(); + JSBClassType::registerClass(cls); + + __jsb_cc_scene_Camera_proto = cls->getProto(); + __jsb_cc_scene_Camera_class = cls; + + + se::ScriptEngine::getInstance()->clearException(); + return true; +} +se::Object* __jsb_cc_scene_SubModel_proto = nullptr; // NOLINT +se::Class* __jsb_cc_scene_SubModel_class = nullptr; // NOLINT + +static bool js_scene_SubModel_destroy(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_scene_SubModel_destroy : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + if (argc == 0) { + cobj->destroy(); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 0); + return false; +} +SE_BIND_FUNC(js_scene_SubModel_destroy) + +static bool js_scene_SubModel_getDescriptorSet(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_scene_SubModel_getDescriptorSet : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 0) { + cc::gfx::DescriptorSet* result = cobj->getDescriptorSet(); + ok &= nativevalue_to_se(result, s.rval(), nullptr /*ctx*/); + SE_PRECONDITION2(ok, false, "js_scene_SubModel_getDescriptorSet : Error processing arguments"); + SE_HOLD_RETURN_VALUE(result, s.thisObject(), s.rval()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 0); + return false; +} +SE_BIND_FUNC_AS_PROP_GET(js_scene_SubModel_getDescriptorSet) + +static bool js_scene_SubModel_getId(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_scene_SubModel_getId : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 0) { + unsigned int result = cobj->getId(); + ok &= nativevalue_to_se(result, s.rval(), nullptr /*ctx*/); + SE_PRECONDITION2(ok, false, "js_scene_SubModel_getId : Error processing arguments"); + SE_HOLD_RETURN_VALUE(result, s.thisObject(), s.rval()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 0); + return false; +} +SE_BIND_FUNC(js_scene_SubModel_getId) + +static bool js_scene_SubModel_getInputAssembler(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_scene_SubModel_getInputAssembler : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 0) { + cc::gfx::InputAssembler* result = cobj->getInputAssembler(); + ok &= nativevalue_to_se(result, s.rval(), nullptr /*ctx*/); + SE_PRECONDITION2(ok, false, "js_scene_SubModel_getInputAssembler : Error processing arguments"); + SE_HOLD_RETURN_VALUE(result, s.thisObject(), s.rval()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 0); + return false; +} +SE_BIND_FUNC_AS_PROP_GET(js_scene_SubModel_getInputAssembler) + +static bool js_scene_SubModel_getOwner(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_scene_SubModel_getOwner : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 0) { + cc::scene::Model* result = cobj->getOwner(); + ok &= nativevalue_to_se(result, s.rval(), nullptr /*ctx*/); + SE_PRECONDITION2(ok, false, "js_scene_SubModel_getOwner : Error processing arguments"); + SE_HOLD_RETURN_VALUE(result, s.thisObject(), s.rval()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 0); + return false; +} +SE_BIND_FUNC(js_scene_SubModel_getOwner) + +static bool js_scene_SubModel_getPass(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_scene_SubModel_getPass : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 1) { + HolderType arg0 = {}; + ok &= sevalue_to_native(args[0], &arg0, s.thisObject()); + SE_PRECONDITION2(ok, false, "js_scene_SubModel_getPass : Error processing arguments"); + cc::scene::Pass* result = cobj->getPass(arg0.value()); + ok &= nativevalue_to_se(result, s.rval(), nullptr /*ctx*/); + SE_PRECONDITION2(ok, false, "js_scene_SubModel_getPass : Error processing arguments"); + SE_HOLD_RETURN_VALUE(result, s.thisObject(), s.rval()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 1); + return false; +} +SE_BIND_FUNC(js_scene_SubModel_getPass) + +static bool js_scene_SubModel_getPasses(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_scene_SubModel_getPasses : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 0) { + const std::vector>& result = cobj->getPasses(); + ok &= nativevalue_to_se(result, s.rval(), nullptr /*ctx*/); + SE_PRECONDITION2(ok, false, "js_scene_SubModel_getPasses : Error processing arguments"); + SE_HOLD_RETURN_VALUE(result, s.thisObject(), s.rval()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 0); + return false; +} +SE_BIND_FUNC_AS_PROP_GET(js_scene_SubModel_getPasses) + +static bool js_scene_SubModel_getPatches(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_scene_SubModel_getPatches : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 0) { + const std::vector& result = cobj->getPatches(); + ok &= nativevalue_to_se(result, s.rval(), nullptr /*ctx*/); + SE_PRECONDITION2(ok, false, "js_scene_SubModel_getPatches : Error processing arguments"); + SE_HOLD_RETURN_VALUE(result, s.thisObject(), s.rval()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 0); + return false; +} +SE_BIND_FUNC_AS_PROP_GET(js_scene_SubModel_getPatches) + +static bool js_scene_SubModel_getPlanarInstanceShader(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_scene_SubModel_getPlanarInstanceShader : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 0) { + cc::gfx::Shader* result = cobj->getPlanarInstanceShader(); + ok &= nativevalue_to_se(result, s.rval(), nullptr /*ctx*/); + SE_PRECONDITION2(ok, false, "js_scene_SubModel_getPlanarInstanceShader : Error processing arguments"); + SE_HOLD_RETURN_VALUE(result, s.thisObject(), s.rval()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 0); + return false; +} +SE_BIND_FUNC_AS_PROP_GET(js_scene_SubModel_getPlanarInstanceShader) + +static bool js_scene_SubModel_getPlanarShader(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_scene_SubModel_getPlanarShader : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 0) { + cc::gfx::Shader* result = cobj->getPlanarShader(); + ok &= nativevalue_to_se(result, s.rval(), nullptr /*ctx*/); + SE_PRECONDITION2(ok, false, "js_scene_SubModel_getPlanarShader : Error processing arguments"); + SE_HOLD_RETURN_VALUE(result, s.thisObject(), s.rval()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 0); + return false; +} +SE_BIND_FUNC_AS_PROP_GET(js_scene_SubModel_getPlanarShader) + +static bool js_scene_SubModel_getPriority(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_scene_SubModel_getPriority : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 0) { + auto result = static_cast(cobj->getPriority()); + ok &= nativevalue_to_se(result, s.rval(), nullptr /*ctx*/); + SE_PRECONDITION2(ok, false, "js_scene_SubModel_getPriority : Error processing arguments"); + SE_HOLD_RETURN_VALUE(result, s.thisObject(), s.rval()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 0); + return false; +} +SE_BIND_FUNC_AS_PROP_GET(js_scene_SubModel_getPriority) + +static bool js_scene_SubModel_getShader(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_scene_SubModel_getShader : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 1) { + HolderType arg0 = {}; + ok &= sevalue_to_native(args[0], &arg0, s.thisObject()); + SE_PRECONDITION2(ok, false, "js_scene_SubModel_getShader : Error processing arguments"); + cc::gfx::Shader* result = cobj->getShader(arg0.value()); + ok &= nativevalue_to_se(result, s.rval(), nullptr /*ctx*/); + SE_PRECONDITION2(ok, false, "js_scene_SubModel_getShader : Error processing arguments"); + SE_HOLD_RETURN_VALUE(result, s.thisObject(), s.rval()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 1); + return false; +} +SE_BIND_FUNC(js_scene_SubModel_getShader) + +static bool js_scene_SubModel_getShaders(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_scene_SubModel_getShaders : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 0) { + const std::vector>& result = cobj->getShaders(); + ok &= nativevalue_to_se(result, s.rval(), nullptr /*ctx*/); + SE_PRECONDITION2(ok, false, "js_scene_SubModel_getShaders : Error processing arguments"); + SE_HOLD_RETURN_VALUE(result, s.thisObject(), s.rval()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 0); + return false; +} +SE_BIND_FUNC_AS_PROP_GET(js_scene_SubModel_getShaders) + +static bool js_scene_SubModel_getSubMesh(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_scene_SubModel_getSubMesh : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 0) { + cc::RenderingSubMesh* result = cobj->getSubMesh(); + ok &= nativevalue_to_se(result, s.rval(), nullptr /*ctx*/); + SE_PRECONDITION2(ok, false, "js_scene_SubModel_getSubMesh : Error processing arguments"); + SE_HOLD_RETURN_VALUE(result, s.thisObject(), s.rval()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 0); + return false; +} +SE_BIND_FUNC_AS_PROP_GET(js_scene_SubModel_getSubMesh) + +static bool js_scene_SubModel_getWorldBoundDescriptorSet(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_scene_SubModel_getWorldBoundDescriptorSet : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 0) { + cc::gfx::DescriptorSet* result = cobj->getWorldBoundDescriptorSet(); + ok &= nativevalue_to_se(result, s.rval(), nullptr /*ctx*/); + SE_PRECONDITION2(ok, false, "js_scene_SubModel_getWorldBoundDescriptorSet : Error processing arguments"); + SE_HOLD_RETURN_VALUE(result, s.thisObject(), s.rval()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 0); + return false; +} +SE_BIND_FUNC(js_scene_SubModel_getWorldBoundDescriptorSet) + +static bool js_scene_SubModel_initPlanarShadowInstanceShader(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_scene_SubModel_initPlanarShadowInstanceShader : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + if (argc == 0) { + cobj->initPlanarShadowInstanceShader(); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 0); + return false; +} +SE_BIND_FUNC(js_scene_SubModel_initPlanarShadowInstanceShader) + +static bool js_scene_SubModel_initPlanarShadowShader(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_scene_SubModel_initPlanarShadowShader : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + if (argc == 0) { + cobj->initPlanarShadowShader(); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 0); + return false; +} +SE_BIND_FUNC(js_scene_SubModel_initPlanarShadowShader) + +static bool js_scene_SubModel_initialize(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_scene_SubModel_initialize : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 3) { + HolderType arg0 = {}; + HolderType>>, true> arg1 = {}; + HolderType, true> arg2 = {}; + ok &= sevalue_to_native(args[0], &arg0, s.thisObject()); + ok &= sevalue_to_native(args[1], &arg1, s.thisObject()); + ok &= sevalue_to_native(args[2], &arg2, s.thisObject()); + SE_PRECONDITION2(ok, false, "js_scene_SubModel_initialize : Error processing arguments"); + cobj->initialize(arg0.value(), arg1.value(), arg2.value()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 3); + return false; +} +SE_BIND_FUNC(js_scene_SubModel_initialize) + +static bool js_scene_SubModel_onMacroPatchesStateChanged(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_scene_SubModel_onMacroPatchesStateChanged : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 1) { + HolderType, true> arg0 = {}; + ok &= sevalue_to_native(args[0], &arg0, s.thisObject()); + SE_PRECONDITION2(ok, false, "js_scene_SubModel_onMacroPatchesStateChanged : Error processing arguments"); + cobj->onMacroPatchesStateChanged(arg0.value()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 1); + return false; +} +SE_BIND_FUNC(js_scene_SubModel_onMacroPatchesStateChanged) + +static bool js_scene_SubModel_onPipelineStateChanged(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_scene_SubModel_onPipelineStateChanged : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + if (argc == 0) { + cobj->onPipelineStateChanged(); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 0); + return false; +} +SE_BIND_FUNC(js_scene_SubModel_onPipelineStateChanged) + +static bool js_scene_SubModel_setDescriptorSet(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_scene_SubModel_setDescriptorSet : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 1) { + HolderType arg0 = {}; + ok &= sevalue_to_native(args[0], &arg0, s.thisObject()); + SE_PRECONDITION2(ok, false, "js_scene_SubModel_setDescriptorSet : Error processing arguments"); + cobj->setDescriptorSet(arg0.value()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 1); + return false; +} +SE_BIND_FUNC_AS_PROP_SET(js_scene_SubModel_setDescriptorSet) + +static bool js_scene_SubModel_setInputAssembler(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_scene_SubModel_setInputAssembler : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 1) { + HolderType arg0 = {}; + ok &= sevalue_to_native(args[0], &arg0, s.thisObject()); + SE_PRECONDITION2(ok, false, "js_scene_SubModel_setInputAssembler : Error processing arguments"); + cobj->setInputAssembler(arg0.value()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 1); + return false; +} +SE_BIND_FUNC_AS_PROP_SET(js_scene_SubModel_setInputAssembler) + +static bool js_scene_SubModel_setOwner(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_scene_SubModel_setOwner : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 1) { + HolderType arg0 = {}; + ok &= sevalue_to_native(args[0], &arg0, s.thisObject()); + SE_PRECONDITION2(ok, false, "js_scene_SubModel_setOwner : Error processing arguments"); + cobj->setOwner(arg0.value()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 1); + return false; +} +SE_BIND_FUNC(js_scene_SubModel_setOwner) + +static bool js_scene_SubModel_setPasses(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_scene_SubModel_setPasses : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 1) { + HolderType>>, true> arg0 = {}; + ok &= sevalue_to_native(args[0], &arg0, s.thisObject()); + SE_PRECONDITION2(ok, false, "js_scene_SubModel_setPasses : Error processing arguments"); + cobj->setPasses(arg0.value()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 1); + return false; +} +SE_BIND_FUNC_AS_PROP_SET(js_scene_SubModel_setPasses) + +static bool js_scene_SubModel_setPlanarInstanceShader(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_scene_SubModel_setPlanarInstanceShader : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 1) { + HolderType arg0 = {}; + ok &= sevalue_to_native(args[0], &arg0, s.thisObject()); + SE_PRECONDITION2(ok, false, "js_scene_SubModel_setPlanarInstanceShader : Error processing arguments"); + cobj->setPlanarInstanceShader(arg0.value()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 1); + return false; +} +SE_BIND_FUNC_AS_PROP_SET(js_scene_SubModel_setPlanarInstanceShader) + +static bool js_scene_SubModel_setPlanarShader(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_scene_SubModel_setPlanarShader : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 1) { + HolderType arg0 = {}; + ok &= sevalue_to_native(args[0], &arg0, s.thisObject()); + SE_PRECONDITION2(ok, false, "js_scene_SubModel_setPlanarShader : Error processing arguments"); + cobj->setPlanarShader(arg0.value()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 1); + return false; +} +SE_BIND_FUNC_AS_PROP_SET(js_scene_SubModel_setPlanarShader) + +static bool js_scene_SubModel_setPriority(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_scene_SubModel_setPriority : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 1) { + HolderType arg0 = {}; + ok &= sevalue_to_native(args[0], &arg0, s.thisObject()); + SE_PRECONDITION2(ok, false, "js_scene_SubModel_setPriority : Error processing arguments"); + cobj->setPriority(arg0.value()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 1); + return false; +} +SE_BIND_FUNC_AS_PROP_SET(js_scene_SubModel_setPriority) + +static bool js_scene_SubModel_setShaders(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_scene_SubModel_setShaders : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 1) { + HolderType>, true> arg0 = {}; + ok &= sevalue_to_native(args[0], &arg0, s.thisObject()); + SE_PRECONDITION2(ok, false, "js_scene_SubModel_setShaders : Error processing arguments"); + cobj->setShaders(arg0.value()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 1); + return false; +} +SE_BIND_FUNC_AS_PROP_SET(js_scene_SubModel_setShaders) + +static bool js_scene_SubModel_setSubMesh(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_scene_SubModel_setSubMesh : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 1) { + HolderType arg0 = {}; + ok &= sevalue_to_native(args[0], &arg0, s.thisObject()); + SE_PRECONDITION2(ok, false, "js_scene_SubModel_setSubMesh : Error processing arguments"); + cobj->setSubMesh(arg0.value()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 1); + return false; +} +SE_BIND_FUNC_AS_PROP_SET(js_scene_SubModel_setSubMesh) + +static bool js_scene_SubModel_setWorldBoundDescriptorSet(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_scene_SubModel_setWorldBoundDescriptorSet : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 1) { + HolderType arg0 = {}; + ok &= sevalue_to_native(args[0], &arg0, s.thisObject()); + SE_PRECONDITION2(ok, false, "js_scene_SubModel_setWorldBoundDescriptorSet : Error processing arguments"); + cobj->setWorldBoundDescriptorSet(arg0.value()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 1); + return false; +} +SE_BIND_FUNC(js_scene_SubModel_setWorldBoundDescriptorSet) + +static bool js_scene_SubModel_update(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_scene_SubModel_update : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + if (argc == 0) { + cobj->update(); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 0); + return false; +} +SE_BIND_FUNC(js_scene_SubModel_update) + +SE_DECLARE_FINALIZE_FUNC(js_cc_scene_SubModel_finalize) + +static bool js_scene_SubModel_constructor(se::State& s) // NOLINT(readability-identifier-naming) constructor.c +{ + auto *ptr = JSB_MAKE_PRIVATE_OBJECT(cc::scene::SubModel); + s.thisObject()->setPrivateObject(ptr); + return true; +} +SE_BIND_CTOR(js_scene_SubModel_constructor, __jsb_cc_scene_SubModel_class, js_cc_scene_SubModel_finalize) + +static bool js_cc_scene_SubModel_finalize(se::State& s) // NOLINT(readability-identifier-naming) +{ + return true; +} +SE_BIND_FINALIZE_FUNC(js_cc_scene_SubModel_finalize) + +bool js_register_scene_SubModel(se::Object* obj) // NOLINT(readability-identifier-naming) +{ + auto* cls = se::Class::create("SubModel", obj, nullptr, _SE(js_scene_SubModel_constructor)); + + cls->defineProperty("passes", _SE(js_scene_SubModel_getPasses_asGetter), _SE(js_scene_SubModel_setPasses_asSetter)); + cls->defineProperty("planarShader", _SE(js_scene_SubModel_getPlanarShader_asGetter), _SE(js_scene_SubModel_setPlanarShader_asSetter)); + cls->defineProperty("patches", _SE(js_scene_SubModel_getPatches_asGetter), nullptr); + cls->defineProperty("priority", _SE(js_scene_SubModel_getPriority_asGetter), _SE(js_scene_SubModel_setPriority_asSetter)); + cls->defineProperty("descriptorSet", _SE(js_scene_SubModel_getDescriptorSet_asGetter), _SE(js_scene_SubModel_setDescriptorSet_asSetter)); + cls->defineProperty("planarInstanceShader", _SE(js_scene_SubModel_getPlanarInstanceShader_asGetter), _SE(js_scene_SubModel_setPlanarInstanceShader_asSetter)); + cls->defineProperty("shaders", _SE(js_scene_SubModel_getShaders_asGetter), _SE(js_scene_SubModel_setShaders_asSetter)); + cls->defineProperty("inputAssembler", _SE(js_scene_SubModel_getInputAssembler_asGetter), _SE(js_scene_SubModel_setInputAssembler_asSetter)); + cls->defineProperty("subMesh", _SE(js_scene_SubModel_getSubMesh_asGetter), _SE(js_scene_SubModel_setSubMesh_asSetter)); + cls->defineFunction("destroy", _SE(js_scene_SubModel_destroy)); + cls->defineFunction("getId", _SE(js_scene_SubModel_getId)); + cls->defineFunction("getOwner", _SE(js_scene_SubModel_getOwner)); + cls->defineFunction("getPass", _SE(js_scene_SubModel_getPass)); + cls->defineFunction("getShader", _SE(js_scene_SubModel_getShader)); + cls->defineFunction("getWorldBoundDescriptorSet", _SE(js_scene_SubModel_getWorldBoundDescriptorSet)); + cls->defineFunction("initPlanarShadowInstanceShader", _SE(js_scene_SubModel_initPlanarShadowInstanceShader)); + cls->defineFunction("initPlanarShadowShader", _SE(js_scene_SubModel_initPlanarShadowShader)); + cls->defineFunction("initialize", _SE(js_scene_SubModel_initialize)); + cls->defineFunction("onMacroPatchesStateChanged", _SE(js_scene_SubModel_onMacroPatchesStateChanged)); + cls->defineFunction("onPipelineStateChanged", _SE(js_scene_SubModel_onPipelineStateChanged)); + cls->defineFunction("setOwner", _SE(js_scene_SubModel_setOwner)); + cls->defineFunction("setWorldBoundDescriptorSet", _SE(js_scene_SubModel_setWorldBoundDescriptorSet)); + cls->defineFunction("update", _SE(js_scene_SubModel_update)); + cls->defineFinalizeFunction(_SE(js_cc_scene_SubModel_finalize)); + cls->install(); + JSBClassType::registerClass(cls); + + __jsb_cc_scene_SubModel_proto = cls->getProto(); + __jsb_cc_scene_SubModel_class = cls; + + + se::ScriptEngine::getInstance()->clearException(); + return true; +} +se::Object* __jsb_cc_scene_InstancedAttributeBlock_proto = nullptr; // NOLINT +se::Class* __jsb_cc_scene_InstancedAttributeBlock_class = nullptr; // NOLINT + +static bool js_scene_InstancedAttributeBlock_get_buffer(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_scene_InstancedAttributeBlock_get_buffer : Invalid Native Object"); + + CC_UNUSED bool ok = true; + se::Value jsret; + ok &= nativevalue_to_se(cobj->buffer, jsret, s.thisObject() /*ctx*/); + s.rval() = jsret; + SE_HOLD_RETURN_VALUE(cobj->buffer, s.thisObject(), s.rval()); + return true; +} +SE_BIND_PROP_GET(js_scene_InstancedAttributeBlock_get_buffer) + +static bool js_scene_InstancedAttributeBlock_set_buffer(se::State& s) // NOLINT(readability-identifier-naming) +{ + const auto& args = s.args(); + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_scene_InstancedAttributeBlock_set_buffer : Invalid Native Object"); + + CC_UNUSED bool ok = true; + ok &= sevalue_to_native(args[0], &cobj->buffer, s.thisObject()); + SE_PRECONDITION2(ok, false, "js_scene_InstancedAttributeBlock_set_buffer : Error processing new value"); + return true; +} +SE_BIND_PROP_SET(js_scene_InstancedAttributeBlock_set_buffer) + +static bool js_scene_InstancedAttributeBlock_get_views(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_scene_InstancedAttributeBlock_get_views : Invalid Native Object"); + + CC_UNUSED bool ok = true; + se::Value jsret; + ok &= nativevalue_to_se(cobj->views, jsret, s.thisObject() /*ctx*/); + s.rval() = jsret; + SE_HOLD_RETURN_VALUE(cobj->views, s.thisObject(), s.rval()); + return true; +} +SE_BIND_PROP_GET(js_scene_InstancedAttributeBlock_get_views) + +static bool js_scene_InstancedAttributeBlock_set_views(se::State& s) // NOLINT(readability-identifier-naming) +{ + const auto& args = s.args(); + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_scene_InstancedAttributeBlock_set_views : Invalid Native Object"); + + CC_UNUSED bool ok = true; + ok &= sevalue_to_native(args[0], &cobj->views, s.thisObject()); + SE_PRECONDITION2(ok, false, "js_scene_InstancedAttributeBlock_set_views : Error processing new value"); + return true; +} +SE_BIND_PROP_SET(js_scene_InstancedAttributeBlock_set_views) + +static bool js_scene_InstancedAttributeBlock_get_attributes(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_scene_InstancedAttributeBlock_get_attributes : Invalid Native Object"); + + CC_UNUSED bool ok = true; + se::Value jsret; + ok &= nativevalue_to_se(cobj->attributes, jsret, s.thisObject() /*ctx*/); + s.rval() = jsret; + SE_HOLD_RETURN_VALUE(cobj->attributes, s.thisObject(), s.rval()); + return true; +} +SE_BIND_PROP_GET(js_scene_InstancedAttributeBlock_get_attributes) + +static bool js_scene_InstancedAttributeBlock_set_attributes(se::State& s) // NOLINT(readability-identifier-naming) +{ + const auto& args = s.args(); + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_scene_InstancedAttributeBlock_set_attributes : Invalid Native Object"); + + CC_UNUSED bool ok = true; + ok &= sevalue_to_native(args[0], &cobj->attributes, s.thisObject()); + SE_PRECONDITION2(ok, false, "js_scene_InstancedAttributeBlock_set_attributes : Error processing new value"); + return true; +} +SE_BIND_PROP_SET(js_scene_InstancedAttributeBlock_set_attributes) + + +template<> +bool sevalue_to_native(const se::Value &from, cc::scene::InstancedAttributeBlock * to, se::Object *ctx) +{ + assert(from.isObject()); + se::Object *json = from.toObject(); + auto* data = reinterpret_cast(json->getPrivateData()); + if (data) { + *to = *data; + return true; + } + se::Value field; + bool ok = true; + json->getProperty("buffer", &field, true); + if(!field.isNullOrUndefined()) { + ok &= sevalue_to_native(field, &(to->buffer), ctx); + } + json->getProperty("views", &field, true); + if(!field.isNullOrUndefined()) { + ok &= sevalue_to_native(field, &(to->views), ctx); + } + json->getProperty("attributes", &field, true); + if(!field.isNullOrUndefined()) { + ok &= sevalue_to_native(field, &(to->attributes), ctx); + } + return ok; +} + +SE_DECLARE_FINALIZE_FUNC(js_cc_scene_InstancedAttributeBlock_finalize) + +static bool js_scene_InstancedAttributeBlock_constructor(se::State& s) // NOLINT(readability-identifier-naming) +{ + CC_UNUSED bool ok = true; + const auto& args = s.args(); + size_t argc = args.size(); + + if(argc == 0) + { + auto *ptr = JSB_MAKE_PRIVATE_OBJECT(cc::scene::InstancedAttributeBlock); + s.thisObject()->setPrivateObject(ptr); + return true; + } + + if(argc == 1 && args[0].isObject()) + { + se::Object *json = args[0].toObject(); + se::Value field; + auto *ptr = JSB_MAKE_PRIVATE_OBJECT(cc::scene::InstancedAttributeBlock); + auto cobj = ptr->get(); + ok &= sevalue_to_native(args[0], cobj, s.thisObject()); + if(!ok) { + delete ptr; + SE_REPORT_ERROR("argument convertion error"); + return false; + } + s.thisObject()->setPrivateObject(ptr); + return true; + } + auto *ptr = JSB_MAKE_PRIVATE_OBJECT(cc::scene::InstancedAttributeBlock); + auto cobj = ptr->get(); + if (argc > 0 && !args[0].isUndefined()) { + ok &= sevalue_to_native(args[0], &(cobj->buffer), nullptr); + } + if (argc > 1 && !args[1].isUndefined()) { + ok &= sevalue_to_native(args[1], &(cobj->views), nullptr); + } + if (argc > 2 && !args[2].isUndefined()) { + ok &= sevalue_to_native(args[2], &(cobj->attributes), nullptr); + } + + if(!ok) { + delete ptr; + SE_REPORT_ERROR("Argument convertion error"); + return false; + } + s.thisObject()->setPrivateObject(ptr); + return true; +} +SE_BIND_CTOR(js_scene_InstancedAttributeBlock_constructor, __jsb_cc_scene_InstancedAttributeBlock_class, js_cc_scene_InstancedAttributeBlock_finalize) + +static bool js_cc_scene_InstancedAttributeBlock_finalize(se::State& s) // NOLINT(readability-identifier-naming) +{ + return true; +} +SE_BIND_FINALIZE_FUNC(js_cc_scene_InstancedAttributeBlock_finalize) + +bool js_register_scene_InstancedAttributeBlock(se::Object* obj) // NOLINT(readability-identifier-naming) +{ + auto* cls = se::Class::create("IInstancedAttributeBlock", obj, nullptr, _SE(js_scene_InstancedAttributeBlock_constructor)); + + cls->defineProperty("buffer", _SE(js_scene_InstancedAttributeBlock_get_buffer), _SE(js_scene_InstancedAttributeBlock_set_buffer)); + cls->defineProperty("views", _SE(js_scene_InstancedAttributeBlock_get_views), _SE(js_scene_InstancedAttributeBlock_set_views)); + cls->defineProperty("attributes", _SE(js_scene_InstancedAttributeBlock_get_attributes), _SE(js_scene_InstancedAttributeBlock_set_attributes)); + cls->defineFinalizeFunction(_SE(js_cc_scene_InstancedAttributeBlock_finalize)); + cls->install(); + JSBClassType::registerClass(cls); + + __jsb_cc_scene_InstancedAttributeBlock_proto = cls->getProto(); + __jsb_cc_scene_InstancedAttributeBlock_class = cls; + + + se::ScriptEngine::getInstance()->clearException(); + return true; +} +se::Object* __jsb_cc_scene_Model_proto = nullptr; // NOLINT +se::Class* __jsb_cc_scene_Model_class = nullptr; // NOLINT + +static bool js_scene_Model_attachToScene(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_scene_Model_attachToScene : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 1) { + HolderType arg0 = {}; + ok &= sevalue_to_native(args[0], &arg0, s.thisObject()); + SE_PRECONDITION2(ok, false, "js_scene_Model_attachToScene : Error processing arguments"); + cobj->attachToScene(arg0.value()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 1); + return false; +} +SE_BIND_FUNC(js_scene_Model_attachToScene) + +static bool js_scene_Model_createBoundingShape(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_scene_Model_createBoundingShape : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 2) { + HolderType, true> arg0 = {}; + HolderType, true> arg1 = {}; + ok &= sevalue_to_native(args[0], &arg0, s.thisObject()); + ok &= sevalue_to_native(args[1], &arg1, s.thisObject()); + SE_PRECONDITION2(ok, false, "js_scene_Model_createBoundingShape : Error processing arguments"); + cobj->createBoundingShape(arg0.value(), arg1.value()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 2); + return false; +} +SE_BIND_FUNC(js_scene_Model_createBoundingShape) + +static bool js_scene_Model_destroy(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_scene_Model_destroy : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + if (argc == 0) { + cobj->destroy(); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 0); + return false; +} +SE_BIND_FUNC(js_scene_Model_destroy) + +static bool js_scene_Model_detachFromScene(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_scene_Model_detachFromScene : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + if (argc == 0) { + cobj->detachFromScene(); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 0); + return false; +} +SE_BIND_FUNC(js_scene_Model_detachFromScene) static bool js_scene_Model_getInstMatWorldIdx(se::State& s) // NOLINT(readability-identifier-naming) { @@ -1647,7 +10644,29 @@ static bool js_scene_Model_getInstancedAttributeBlock(se::State& s) // NOLINT(re SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 0); return false; } -SE_BIND_FUNC(js_scene_Model_getInstancedAttributeBlock) +SE_BIND_FUNC_AS_PROP_GET(js_scene_Model_getInstancedAttributeBlock) + +static bool js_scene_Model_getInstancedAttributeIndex(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_scene_Model_getInstancedAttributeIndex : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 1) { + HolderType arg0 = {}; + ok &= sevalue_to_native(args[0], &arg0, s.thisObject()); + SE_PRECONDITION2(ok, false, "js_scene_Model_getInstancedAttributeIndex : Error processing arguments"); + int32_t result = cobj->getInstancedAttributeIndex(arg0.value()); + ok &= nativevalue_to_se(result, s.rval(), nullptr /*ctx*/); + SE_PRECONDITION2(ok, false, "js_scene_Model_getInstancedAttributeIndex : Error processing arguments"); + SE_HOLD_RETURN_VALUE(result, s.thisObject(), s.rval()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 1); + return false; +} +SE_BIND_FUNC(js_scene_Model_getInstancedAttributeIndex) static bool js_scene_Model_getInstancedBuffer(se::State& s) // NOLINT(readability-identifier-naming) { @@ -1657,7 +10676,7 @@ static bool js_scene_Model_getInstancedBuffer(se::State& s) // NOLINT(readabilit size_t argc = args.size(); CC_UNUSED bool ok = true; if (argc == 0) { - unsigned char* result = cobj->getInstancedBuffer(); + const unsigned char* result = cobj->getInstancedBuffer(); ok &= nativevalue_to_se(result, s.rval(), nullptr /*ctx*/); SE_PRECONDITION2(ok, false, "js_scene_Model_getInstancedBuffer : Error processing arguments"); SE_HOLD_RETURN_VALUE(result, s.thisObject(), s.rval()); @@ -1687,6 +10706,25 @@ static bool js_scene_Model_getInstancedBufferSize(se::State& s) // NOLINT(readab } SE_BIND_FUNC(js_scene_Model_getInstancedBufferSize) +static bool js_scene_Model_getLocalBuffer(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_scene_Model_getLocalBuffer : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 0) { + cc::gfx::Buffer* result = cobj->getLocalBuffer(); + ok &= nativevalue_to_se(result, s.rval(), nullptr /*ctx*/); + SE_PRECONDITION2(ok, false, "js_scene_Model_getLocalBuffer : Error processing arguments"); + SE_HOLD_RETURN_VALUE(result, s.thisObject(), s.rval()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 0); + return false; +} +SE_BIND_FUNC_AS_PROP_GET(js_scene_Model_getLocalBuffer) + static bool js_scene_Model_getLocalData(se::State& s) // NOLINT(readability-identifier-naming) { auto* cobj = SE_THIS_OBJECT(s); @@ -1695,7 +10733,7 @@ static bool js_scene_Model_getLocalData(se::State& s) // NOLINT(readability-iden size_t argc = args.size(); CC_UNUSED bool ok = true; if (argc == 0) { - float* result = cobj->getLocalData(); + cc::TypedArrayTemp result = cobj->getLocalData(); ok &= nativevalue_to_se(result, s.rval(), nullptr /*ctx*/); SE_PRECONDITION2(ok, false, "js_scene_Model_getLocalData : Error processing arguments"); SE_HOLD_RETURN_VALUE(result, s.thisObject(), s.rval()); @@ -1706,6 +10744,47 @@ static bool js_scene_Model_getLocalData(se::State& s) // NOLINT(readability-iden } SE_BIND_FUNC(js_scene_Model_getLocalData) +static bool js_scene_Model_getMacroPatches(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_scene_Model_getMacroPatches : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 1) { + HolderType arg0 = {}; + ok &= sevalue_to_native(args[0], &arg0, s.thisObject()); + SE_PRECONDITION2(ok, false, "js_scene_Model_getMacroPatches : Error processing arguments"); + std::vector& result = cobj->getMacroPatches(arg0.value()); + ok &= nativevalue_to_se(result, s.rval(), nullptr /*ctx*/); + SE_PRECONDITION2(ok, false, "js_scene_Model_getMacroPatches : Error processing arguments"); + SE_HOLD_RETURN_VALUE(result, s.thisObject(), s.rval()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 1); + return false; +} +SE_BIND_FUNC(js_scene_Model_getMacroPatches) + +static bool js_scene_Model_getModelBounds(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_scene_Model_getModelBounds : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 0) { + cc::geometry::AABB* result = cobj->getModelBounds(); + ok &= nativevalue_to_se(result, s.rval(), nullptr /*ctx*/); + SE_PRECONDITION2(ok, false, "js_scene_Model_getModelBounds : Error processing arguments"); + SE_HOLD_RETURN_VALUE(result, s.thisObject(), s.rval()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 0); + return false; +} +SE_BIND_FUNC_AS_PROP_GET(js_scene_Model_getModelBounds) + static bool js_scene_Model_getNode(se::State& s) // NOLINT(readability-identifier-naming) { auto* cobj = SE_THIS_OBJECT(s); @@ -1714,7 +10793,7 @@ static bool js_scene_Model_getNode(se::State& s) // NOLINT(readability-identifie size_t argc = args.size(); CC_UNUSED bool ok = true; if (argc == 0) { - cc::scene::Node* result = cobj->getNode(); + cc::Node* result = cobj->getNode(); ok &= nativevalue_to_se(result, s.rval(), nullptr /*ctx*/); SE_PRECONDITION2(ok, false, "js_scene_Model_getNode : Error processing arguments"); SE_HOLD_RETURN_VALUE(result, s.thisObject(), s.rval()); @@ -1723,26 +10802,26 @@ static bool js_scene_Model_getNode(se::State& s) // NOLINT(readability-identifie SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 0); return false; } -SE_BIND_FUNC(js_scene_Model_getNode) +SE_BIND_FUNC_AS_PROP_GET(js_scene_Model_getNode) -static bool js_scene_Model_getReceiveShadow(se::State& s) // NOLINT(readability-identifier-naming) +static bool js_scene_Model_getScene(se::State& s) // NOLINT(readability-identifier-naming) { auto* cobj = SE_THIS_OBJECT(s); - SE_PRECONDITION2(cobj, false, "js_scene_Model_getReceiveShadow : Invalid Native Object"); + SE_PRECONDITION2(cobj, false, "js_scene_Model_getScene : Invalid Native Object"); const auto& args = s.args(); size_t argc = args.size(); CC_UNUSED bool ok = true; if (argc == 0) { - bool result = cobj->getReceiveShadow(); + cc::scene::RenderScene* result = cobj->getScene(); ok &= nativevalue_to_se(result, s.rval(), nullptr /*ctx*/); - SE_PRECONDITION2(ok, false, "js_scene_Model_getReceiveShadow : Error processing arguments"); + SE_PRECONDITION2(ok, false, "js_scene_Model_getScene : Error processing arguments"); SE_HOLD_RETURN_VALUE(result, s.thisObject(), s.rval()); return true; } SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 0); return false; } -SE_BIND_FUNC(js_scene_Model_getReceiveShadow) +SE_BIND_FUNC_AS_PROP_GET(js_scene_Model_getScene) static bool js_scene_Model_getSubModels(se::State& s) // NOLINT(readability-identifier-naming) { @@ -1752,7 +10831,7 @@ static bool js_scene_Model_getSubModels(se::State& s) // NOLINT(readability-iden size_t argc = args.size(); CC_UNUSED bool ok = true; if (argc == 0) { - const std::vector& result = cobj->getSubModels(); + const std::vector>& result = cobj->getSubModels(); ok &= nativevalue_to_se(result, s.rval(), nullptr /*ctx*/); SE_PRECONDITION2(ok, false, "js_scene_Model_getSubModels : Error processing arguments"); SE_HOLD_RETURN_VALUE(result, s.thisObject(), s.rval()); @@ -1761,7 +10840,7 @@ static bool js_scene_Model_getSubModels(se::State& s) // NOLINT(readability-iden SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 0); return false; } -SE_BIND_FUNC(js_scene_Model_getSubModels) +SE_BIND_FUNC_AS_PROP_GET(js_scene_Model_getSubModels) static bool js_scene_Model_getTransform(se::State& s) // NOLINT(readability-identifier-naming) { @@ -1771,7 +10850,7 @@ static bool js_scene_Model_getTransform(se::State& s) // NOLINT(readability-iden size_t argc = args.size(); CC_UNUSED bool ok = true; if (argc == 0) { - cc::scene::Node* result = cobj->getTransform(); + cc::Node* result = cobj->getTransform(); ok &= nativevalue_to_se(result, s.rval(), nullptr /*ctx*/); SE_PRECONDITION2(ok, false, "js_scene_Model_getTransform : Error processing arguments"); SE_HOLD_RETURN_VALUE(result, s.thisObject(), s.rval()); @@ -1780,45 +10859,45 @@ static bool js_scene_Model_getTransform(se::State& s) // NOLINT(readability-iden SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 0); return false; } -SE_BIND_FUNC(js_scene_Model_getTransform) +SE_BIND_FUNC_AS_PROP_GET(js_scene_Model_getTransform) -static bool js_scene_Model_getTransformUpdated(se::State& s) // NOLINT(readability-identifier-naming) +static bool js_scene_Model_getType(se::State& s) // NOLINT(readability-identifier-naming) { auto* cobj = SE_THIS_OBJECT(s); - SE_PRECONDITION2(cobj, false, "js_scene_Model_getTransformUpdated : Invalid Native Object"); + SE_PRECONDITION2(cobj, false, "js_scene_Model_getType : Invalid Native Object"); const auto& args = s.args(); size_t argc = args.size(); CC_UNUSED bool ok = true; if (argc == 0) { - bool result = cobj->getTransformUpdated(); + auto result = static_cast(cobj->getType()); ok &= nativevalue_to_se(result, s.rval(), nullptr /*ctx*/); - SE_PRECONDITION2(ok, false, "js_scene_Model_getTransformUpdated : Error processing arguments"); + SE_PRECONDITION2(ok, false, "js_scene_Model_getType : Error processing arguments"); SE_HOLD_RETURN_VALUE(result, s.thisObject(), s.rval()); return true; } SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 0); return false; } -SE_BIND_FUNC(js_scene_Model_getTransformUpdated) +SE_BIND_FUNC_AS_PROP_GET(js_scene_Model_getType) -static bool js_scene_Model_getUpdatStamp(se::State& s) // NOLINT(readability-identifier-naming) +static bool js_scene_Model_getUpdateStamp(se::State& s) // NOLINT(readability-identifier-naming) { auto* cobj = SE_THIS_OBJECT(s); - SE_PRECONDITION2(cobj, false, "js_scene_Model_getUpdatStamp : Invalid Native Object"); + SE_PRECONDITION2(cobj, false, "js_scene_Model_getUpdateStamp : Invalid Native Object"); const auto& args = s.args(); size_t argc = args.size(); CC_UNUSED bool ok = true; if (argc == 0) { - int32_t result = cobj->getUpdatStamp(); + unsigned int result = cobj->getUpdateStamp(); ok &= nativevalue_to_se(result, s.rval(), nullptr /*ctx*/); - SE_PRECONDITION2(ok, false, "js_scene_Model_getUpdatStamp : Error processing arguments"); + SE_PRECONDITION2(ok, false, "js_scene_Model_getUpdateStamp : Error processing arguments"); SE_HOLD_RETURN_VALUE(result, s.thisObject(), s.rval()); return true; } SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 0); return false; } -SE_BIND_FUNC(js_scene_Model_getUpdatStamp) +SE_BIND_FUNC_AS_PROP_GET(js_scene_Model_getUpdateStamp) static bool js_scene_Model_getVisFlags(se::State& s) // NOLINT(readability-identifier-naming) { @@ -1828,7 +10907,7 @@ static bool js_scene_Model_getVisFlags(se::State& s) // NOLINT(readability-ident size_t argc = args.size(); CC_UNUSED bool ok = true; if (argc == 0) { - unsigned int result = cobj->getVisFlags(); + auto result = static_cast(cobj->getVisFlags()); ok &= nativevalue_to_se(result, s.rval(), nullptr /*ctx*/); SE_PRECONDITION2(ok, false, "js_scene_Model_getVisFlags : Error processing arguments"); SE_HOLD_RETURN_VALUE(result, s.thisObject(), s.rval()); @@ -1837,7 +10916,7 @@ static bool js_scene_Model_getVisFlags(se::State& s) // NOLINT(readability-ident SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 0); return false; } -SE_BIND_FUNC(js_scene_Model_getVisFlags) +SE_BIND_FUNC_AS_PROP_GET(js_scene_Model_getVisFlags) static bool js_scene_Model_getWorldBoundBuffer(se::State& s) // NOLINT(readability-identifier-naming) { @@ -1856,26 +10935,284 @@ static bool js_scene_Model_getWorldBoundBuffer(se::State& s) // NOLINT(readabili SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 0); return false; } -SE_BIND_FUNC(js_scene_Model_getWorldBoundBuffer) +SE_BIND_FUNC_AS_PROP_GET(js_scene_Model_getWorldBoundBuffer) -static bool js_scene_Model_seVisFlag(se::State& s) // NOLINT(readability-identifier-naming) +static bool js_scene_Model_getWorldBounds(se::State& s) // NOLINT(readability-identifier-naming) { auto* cobj = SE_THIS_OBJECT(s); - SE_PRECONDITION2(cobj, false, "js_scene_Model_seVisFlag : Invalid Native Object"); + SE_PRECONDITION2(cobj, false, "js_scene_Model_getWorldBounds : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 0) { + cc::geometry::AABB* result = cobj->getWorldBounds(); + ok &= nativevalue_to_se(result, s.rval(), nullptr /*ctx*/); + SE_PRECONDITION2(ok, false, "js_scene_Model_getWorldBounds : Error processing arguments"); + SE_HOLD_RETURN_VALUE(result, s.thisObject(), s.rval()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 0); + return false; +} +SE_BIND_FUNC_AS_PROP_GET(js_scene_Model_getWorldBounds) + +static bool js_scene_Model_initLocalDescriptors(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_scene_Model_initLocalDescriptors : Invalid Native Object"); const auto& args = s.args(); size_t argc = args.size(); CC_UNUSED bool ok = true; if (argc == 1) { - HolderType arg0 = {}; + HolderType arg0 = {}; ok &= sevalue_to_native(args[0], &arg0, s.thisObject()); - SE_PRECONDITION2(ok, false, "js_scene_Model_seVisFlag : Error processing arguments"); - cobj->seVisFlag(arg0.value()); + SE_PRECONDITION2(ok, false, "js_scene_Model_initLocalDescriptors : Error processing arguments"); + cobj->initLocalDescriptors(arg0.value()); return true; } SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 1); return false; } -SE_BIND_FUNC(js_scene_Model_seVisFlag) +SE_BIND_FUNC(js_scene_Model_initLocalDescriptors) + +static bool js_scene_Model_initSubModel(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_scene_Model_initSubModel : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 3) { + HolderType arg0 = {}; + HolderType arg1 = {}; + HolderType arg2 = {}; + ok &= sevalue_to_native(args[0], &arg0, s.thisObject()); + ok &= sevalue_to_native(args[1], &arg1, s.thisObject()); + ok &= sevalue_to_native(args[2], &arg2, s.thisObject()); + SE_PRECONDITION2(ok, false, "js_scene_Model_initSubModel : Error processing arguments"); + cobj->initSubModel(arg0.value(), arg1.value(), arg2.value()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 3); + return false; +} +SE_BIND_FUNC(js_scene_Model_initSubModel) + +static bool js_scene_Model_initWorldBoundDescriptors(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_scene_Model_initWorldBoundDescriptors : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 1) { + HolderType arg0 = {}; + ok &= sevalue_to_native(args[0], &arg0, s.thisObject()); + SE_PRECONDITION2(ok, false, "js_scene_Model_initWorldBoundDescriptors : Error processing arguments"); + cobj->initWorldBoundDescriptors(arg0.value()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 1); + return false; +} +SE_BIND_FUNC(js_scene_Model_initWorldBoundDescriptors) + +static bool js_scene_Model_initialize(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_scene_Model_initialize : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + if (argc == 0) { + cobj->initialize(); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 0); + return false; +} +SE_BIND_FUNC(js_scene_Model_initialize) + +static bool js_scene_Model_isCastShadow(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_scene_Model_isCastShadow : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 0) { + bool result = cobj->isCastShadow(); + ok &= nativevalue_to_se(result, s.rval(), nullptr /*ctx*/); + SE_PRECONDITION2(ok, false, "js_scene_Model_isCastShadow : Error processing arguments"); + SE_HOLD_RETURN_VALUE(result, s.thisObject(), s.rval()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 0); + return false; +} +SE_BIND_FUNC_AS_PROP_GET(js_scene_Model_isCastShadow) + +static bool js_scene_Model_isDynamicBatching(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_scene_Model_isDynamicBatching : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 0) { + bool result = cobj->isDynamicBatching(); + ok &= nativevalue_to_se(result, s.rval(), nullptr /*ctx*/); + SE_PRECONDITION2(ok, false, "js_scene_Model_isDynamicBatching : Error processing arguments"); + SE_HOLD_RETURN_VALUE(result, s.thisObject(), s.rval()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 0); + return false; +} +SE_BIND_FUNC_AS_PROP_GET(js_scene_Model_isDynamicBatching) + +static bool js_scene_Model_isEnabled(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_scene_Model_isEnabled : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 0) { + bool result = cobj->isEnabled(); + ok &= nativevalue_to_se(result, s.rval(), nullptr /*ctx*/); + SE_PRECONDITION2(ok, false, "js_scene_Model_isEnabled : Error processing arguments"); + SE_HOLD_RETURN_VALUE(result, s.thisObject(), s.rval()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 0); + return false; +} +SE_BIND_FUNC_AS_PROP_GET(js_scene_Model_isEnabled) + +static bool js_scene_Model_isInited(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_scene_Model_isInited : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 0) { + bool result = cobj->isInited(); + ok &= nativevalue_to_se(result, s.rval(), nullptr /*ctx*/); + SE_PRECONDITION2(ok, false, "js_scene_Model_isInited : Error processing arguments"); + SE_HOLD_RETURN_VALUE(result, s.thisObject(), s.rval()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 0); + return false; +} +SE_BIND_FUNC_AS_PROP_GET(js_scene_Model_isInited) + +static bool js_scene_Model_isInstancingEnabled(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_scene_Model_isInstancingEnabled : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 0) { + bool result = cobj->isInstancingEnabled(); + ok &= nativevalue_to_se(result, s.rval(), nullptr /*ctx*/); + SE_PRECONDITION2(ok, false, "js_scene_Model_isInstancingEnabled : Error processing arguments"); + SE_HOLD_RETURN_VALUE(result, s.thisObject(), s.rval()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 0); + return false; +} +SE_BIND_FUNC_AS_PROP_GET(js_scene_Model_isInstancingEnabled) + +static bool js_scene_Model_isLocalDataUpdated(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_scene_Model_isLocalDataUpdated : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 0) { + bool result = cobj->isLocalDataUpdated(); + ok &= nativevalue_to_se(result, s.rval(), nullptr /*ctx*/); + SE_PRECONDITION2(ok, false, "js_scene_Model_isLocalDataUpdated : Error processing arguments"); + SE_HOLD_RETURN_VALUE(result, s.thisObject(), s.rval()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 0); + return false; +} +SE_BIND_FUNC_AS_PROP_GET(js_scene_Model_isLocalDataUpdated) + +static bool js_scene_Model_isModelImplementedInJS(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_scene_Model_isModelImplementedInJS : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 0) { + bool result = cobj->isModelImplementedInJS(); + ok &= nativevalue_to_se(result, s.rval(), nullptr /*ctx*/); + SE_PRECONDITION2(ok, false, "js_scene_Model_isModelImplementedInJS : Error processing arguments"); + SE_HOLD_RETURN_VALUE(result, s.thisObject(), s.rval()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 0); + return false; +} +SE_BIND_FUNC(js_scene_Model_isModelImplementedInJS) + +static bool js_scene_Model_isReceiveShadow(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_scene_Model_isReceiveShadow : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 0) { + bool result = cobj->isReceiveShadow(); + ok &= nativevalue_to_se(result, s.rval(), nullptr /*ctx*/); + SE_PRECONDITION2(ok, false, "js_scene_Model_isReceiveShadow : Error processing arguments"); + SE_HOLD_RETURN_VALUE(result, s.thisObject(), s.rval()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 0); + return false; +} +SE_BIND_FUNC_AS_PROP_GET(js_scene_Model_isReceiveShadow) + +static bool js_scene_Model_onGlobalPipelineStateChanged(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_scene_Model_onGlobalPipelineStateChanged : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + if (argc == 0) { + cobj->onGlobalPipelineStateChanged(); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 0); + return false; +} +SE_BIND_FUNC(js_scene_Model_onGlobalPipelineStateChanged) + +static bool js_scene_Model_onMacroPatchesStateChanged(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_scene_Model_onMacroPatchesStateChanged : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + if (argc == 0) { + cobj->onMacroPatchesStateChanged(); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 0); + return false; +} +SE_BIND_FUNC(js_scene_Model_onMacroPatchesStateChanged) static bool js_scene_Model_setBounds(se::State& s) // NOLINT(readability-identifier-naming) { @@ -1885,7 +11222,7 @@ static bool js_scene_Model_setBounds(se::State& s) // NOLINT(readability-identif size_t argc = args.size(); CC_UNUSED bool ok = true; if (argc == 1) { - HolderType arg0 = {}; + HolderType arg0 = {}; ok &= sevalue_to_native(args[0], &arg0, s.thisObject()); SE_PRECONDITION2(ok, false, "js_scene_Model_setBounds : Error processing arguments"); cobj->setBounds(arg0.value()); @@ -1896,6 +11233,25 @@ static bool js_scene_Model_setBounds(se::State& s) // NOLINT(readability-identif } SE_BIND_FUNC(js_scene_Model_setBounds) +static bool js_scene_Model_setCalledFromJS(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_scene_Model_setCalledFromJS : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 1) { + HolderType arg0 = {}; + ok &= sevalue_to_native(args[0], &arg0, s.thisObject()); + SE_PRECONDITION2(ok, false, "js_scene_Model_setCalledFromJS : Error processing arguments"); + cobj->setCalledFromJS(arg0.value()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 1); + return false; +} +SE_BIND_FUNC(js_scene_Model_setCalledFromJS) + static bool js_scene_Model_setCastShadow(se::State& s) // NOLINT(readability-identifier-naming) { auto* cobj = SE_THIS_OBJECT(s); @@ -1913,7 +11269,26 @@ static bool js_scene_Model_setCastShadow(se::State& s) // NOLINT(readability-ide SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 1); return false; } -SE_BIND_FUNC(js_scene_Model_setCastShadow) +SE_BIND_FUNC_AS_PROP_SET(js_scene_Model_setCastShadow) + +static bool js_scene_Model_setDynamicBatching(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_scene_Model_setDynamicBatching : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 1) { + HolderType arg0 = {}; + ok &= sevalue_to_native(args[0], &arg0, s.thisObject()); + SE_PRECONDITION2(ok, false, "js_scene_Model_setDynamicBatching : Error processing arguments"); + cobj->setDynamicBatching(arg0.value()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 1); + return false; +} +SE_BIND_FUNC_AS_PROP_SET(js_scene_Model_setDynamicBatching) static bool js_scene_Model_setEnabled(se::State& s) // NOLINT(readability-identifier-naming) { @@ -1932,7 +11307,7 @@ static bool js_scene_Model_setEnabled(se::State& s) // NOLINT(readability-identi SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 1); return false; } -SE_BIND_FUNC(js_scene_Model_setEnabled) +SE_BIND_FUNC_AS_PROP_SET(js_scene_Model_setEnabled) static bool js_scene_Model_setInstMatWorldIdx(se::State& s) // NOLINT(readability-identifier-naming) { @@ -1953,6 +11328,48 @@ static bool js_scene_Model_setInstMatWorldIdx(se::State& s) // NOLINT(readabilit } SE_BIND_FUNC(js_scene_Model_setInstMatWorldIdx) +static bool js_scene_Model_setInstancedAttributeBlock(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_scene_Model_setInstancedAttributeBlock : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 1) { + HolderType arg0 = {}; + ok &= sevalue_to_native(args[0], &arg0, s.thisObject()); + SE_PRECONDITION2(ok, false, "js_scene_Model_setInstancedAttributeBlock : Error processing arguments"); + cobj->setInstancedAttributeBlock(arg0.value()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 1); + return false; +} +SE_BIND_FUNC_AS_PROP_SET(js_scene_Model_setInstancedAttributeBlock) + +static bool js_scene_Model_setInstancedAttributesViewData(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_scene_Model_setInstancedAttributesViewData : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 3) { + HolderType arg0 = {}; + HolderType arg1 = {}; + HolderType arg2 = {}; + ok &= sevalue_to_native(args[0], &arg0, s.thisObject()); + ok &= sevalue_to_native(args[1], &arg1, s.thisObject()); + ok &= sevalue_to_native(args[2], &arg2, s.thisObject()); + SE_PRECONDITION2(ok, false, "js_scene_Model_setInstancedAttributesViewData : Error processing arguments"); + cobj->setInstancedAttributesViewData(arg0.value(), arg1.value(), arg2.value()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 3); + return false; +} +SE_BIND_FUNC(js_scene_Model_setInstancedAttributesViewData) + static bool js_scene_Model_setLocalBuffer(se::State& s) // NOLINT(readability-identifier-naming) { auto* cobj = SE_THIS_OBJECT(s); @@ -1970,7 +11387,45 @@ static bool js_scene_Model_setLocalBuffer(se::State& s) // NOLINT(readability-id SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 1); return false; } -SE_BIND_FUNC(js_scene_Model_setLocalBuffer) +SE_BIND_FUNC_AS_PROP_SET(js_scene_Model_setLocalBuffer) + +static bool js_scene_Model_setLocalDataUpdated(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_scene_Model_setLocalDataUpdated : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 1) { + HolderType arg0 = {}; + ok &= sevalue_to_native(args[0], &arg0, s.thisObject()); + SE_PRECONDITION2(ok, false, "js_scene_Model_setLocalDataUpdated : Error processing arguments"); + cobj->setLocalDataUpdated(arg0.value()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 1); + return false; +} +SE_BIND_FUNC_AS_PROP_SET(js_scene_Model_setLocalDataUpdated) + +static bool js_scene_Model_setModelBounds(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_scene_Model_setModelBounds : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 1) { + HolderType arg0 = {}; + ok &= sevalue_to_native(args[0], &arg0, s.thisObject()); + SE_PRECONDITION2(ok, false, "js_scene_Model_setModelBounds : Error processing arguments"); + cobj->setModelBounds(arg0.value()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 1); + return false; +} +SE_BIND_FUNC_AS_PROP_SET(js_scene_Model_setModelBounds) static bool js_scene_Model_setNode(se::State& s) // NOLINT(readability-identifier-naming) { @@ -1980,7 +11435,7 @@ static bool js_scene_Model_setNode(se::State& s) // NOLINT(readability-identifie size_t argc = args.size(); CC_UNUSED bool ok = true; if (argc == 1) { - HolderType arg0 = {}; + HolderType arg0 = {}; ok &= sevalue_to_native(args[0], &arg0, s.thisObject()); SE_PRECONDITION2(ok, false, "js_scene_Model_setNode : Error processing arguments"); cobj->setNode(arg0.value()); @@ -1989,7 +11444,7 @@ static bool js_scene_Model_setNode(se::State& s) // NOLINT(readability-identifie SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 1); return false; } -SE_BIND_FUNC(js_scene_Model_setNode) +SE_BIND_FUNC_AS_PROP_SET(js_scene_Model_setNode) static bool js_scene_Model_setReceiveShadow(se::State& s) // NOLINT(readability-identifier-naming) { @@ -2008,28 +11463,68 @@ static bool js_scene_Model_setReceiveShadow(se::State& s) // NOLINT(readability- SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 1); return false; } -SE_BIND_FUNC(js_scene_Model_setReceiveShadow) +SE_BIND_FUNC_AS_PROP_SET(js_scene_Model_setReceiveShadow) -static bool js_scene_Model_setSubModel(se::State& s) // NOLINT(readability-identifier-naming) +static bool js_scene_Model_setScene(se::State& s) // NOLINT(readability-identifier-naming) { auto* cobj = SE_THIS_OBJECT(s); - SE_PRECONDITION2(cobj, false, "js_scene_Model_setSubModel : Invalid Native Object"); + SE_PRECONDITION2(cobj, false, "js_scene_Model_setScene : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 1) { + HolderType arg0 = {}; + ok &= sevalue_to_native(args[0], &arg0, s.thisObject()); + SE_PRECONDITION2(ok, false, "js_scene_Model_setScene : Error processing arguments"); + cobj->setScene(arg0.value()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 1); + return false; +} +SE_BIND_FUNC_AS_PROP_SET(js_scene_Model_setScene) + +static bool js_scene_Model_setSubModelMaterial(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_scene_Model_setSubModelMaterial : Invalid Native Object"); const auto& args = s.args(); size_t argc = args.size(); CC_UNUSED bool ok = true; if (argc == 2) { - HolderType arg0 = {}; - HolderType arg1 = {}; + HolderType arg0 = {}; + HolderType arg1 = {}; ok &= sevalue_to_native(args[0], &arg0, s.thisObject()); ok &= sevalue_to_native(args[1], &arg1, s.thisObject()); - SE_PRECONDITION2(ok, false, "js_scene_Model_setSubModel : Error processing arguments"); - cobj->setSubModel(arg0.value(), arg1.value()); + SE_PRECONDITION2(ok, false, "js_scene_Model_setSubModelMaterial : Error processing arguments"); + cobj->setSubModelMaterial(arg0.value(), arg1.value()); return true; } SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 2); return false; } -SE_BIND_FUNC(js_scene_Model_setSubModel) +SE_BIND_FUNC(js_scene_Model_setSubModelMaterial) + +static bool js_scene_Model_setSubModelMesh(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_scene_Model_setSubModelMesh : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 2) { + HolderType arg0 = {}; + HolderType arg1 = {}; + ok &= sevalue_to_native(args[0], &arg0, s.thisObject()); + ok &= sevalue_to_native(args[1], &arg1, s.thisObject()); + SE_PRECONDITION2(ok, false, "js_scene_Model_setSubModelMesh : Error processing arguments"); + cobj->setSubModelMesh(arg0.value(), arg1.value()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 2); + return false; +} +SE_BIND_FUNC(js_scene_Model_setSubModelMesh) static bool js_scene_Model_setTransform(se::State& s) // NOLINT(readability-identifier-naming) { @@ -2039,7 +11534,7 @@ static bool js_scene_Model_setTransform(se::State& s) // NOLINT(readability-iden size_t argc = args.size(); CC_UNUSED bool ok = true; if (argc == 1) { - HolderType arg0 = {}; + HolderType arg0 = {}; ok &= sevalue_to_native(args[0], &arg0, s.thisObject()); SE_PRECONDITION2(ok, false, "js_scene_Model_setTransform : Error processing arguments"); cobj->setTransform(arg0.value()); @@ -2048,7 +11543,45 @@ static bool js_scene_Model_setTransform(se::State& s) // NOLINT(readability-iden SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 1); return false; } -SE_BIND_FUNC(js_scene_Model_setTransform) +SE_BIND_FUNC_AS_PROP_SET(js_scene_Model_setTransform) + +static bool js_scene_Model_setType(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_scene_Model_setType : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 1) { + HolderType arg0 = {}; + ok &= sevalue_to_native(args[0], &arg0, s.thisObject()); + SE_PRECONDITION2(ok, false, "js_scene_Model_setType : Error processing arguments"); + cobj->setType(arg0.value()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 1); + return false; +} +SE_BIND_FUNC_AS_PROP_SET(js_scene_Model_setType) + +static bool js_scene_Model_setVisFlags(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_scene_Model_setVisFlags : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 1) { + HolderType arg0 = {}; + ok &= sevalue_to_native(args[0], &arg0, s.thisObject()); + SE_PRECONDITION2(ok, false, "js_scene_Model_setVisFlags : Error processing arguments"); + cobj->setVisFlags(arg0.value()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 1); + return false; +} +SE_BIND_FUNC_AS_PROP_SET(js_scene_Model_setVisFlags) static bool js_scene_Model_setWorldBoundBuffer(se::State& s) // NOLINT(readability-identifier-naming) { @@ -2067,7 +11600,89 @@ static bool js_scene_Model_setWorldBoundBuffer(se::State& s) // NOLINT(readabili SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 1); return false; } -SE_BIND_FUNC(js_scene_Model_setWorldBoundBuffer) +SE_BIND_FUNC_AS_PROP_SET(js_scene_Model_setWorldBoundBuffer) + +static bool js_scene_Model_setWorldBounds(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_scene_Model_setWorldBounds : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 1) { + HolderType arg0 = {}; + ok &= sevalue_to_native(args[0], &arg0, s.thisObject()); + SE_PRECONDITION2(ok, false, "js_scene_Model_setWorldBounds : Error processing arguments"); + cobj->setWorldBounds(arg0.value()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 1); + return false; +} +SE_BIND_FUNC_AS_PROP_SET(js_scene_Model_setWorldBounds) + +static bool js_scene_Model_updateInstancedAttributes(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_scene_Model_updateInstancedAttributes : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 2) { + HolderType, true> arg0 = {}; + HolderType arg1 = {}; + ok &= sevalue_to_native(args[0], &arg0, s.thisObject()); + ok &= sevalue_to_native(args[1], &arg1, s.thisObject()); + SE_PRECONDITION2(ok, false, "js_scene_Model_updateInstancedAttributes : Error processing arguments"); + cobj->updateInstancedAttributes(arg0.value(), arg1.value()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 2); + return false; +} +SE_BIND_FUNC(js_scene_Model_updateInstancedAttributes) + +static bool js_scene_Model_updateLightingmap(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_scene_Model_updateLightingmap : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 2) { + HolderType arg0 = {}; + HolderType arg1 = {}; + ok &= sevalue_to_native(args[0], &arg0, s.thisObject()); + ok &= sevalue_to_native(args[1], &arg1, s.thisObject()); + SE_PRECONDITION2(ok, false, "js_scene_Model_updateLightingmap : Error processing arguments"); + cobj->updateLightingmap(arg0.value(), arg1.value()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 2); + return false; +} +SE_BIND_FUNC(js_scene_Model_updateLightingmap) + +static bool js_scene_Model_updateLocalDescriptors(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_scene_Model_updateLocalDescriptors : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 2) { + HolderType arg0 = {}; + HolderType arg1 = {}; + ok &= sevalue_to_native(args[0], &arg0, s.thisObject()); + ok &= sevalue_to_native(args[1], &arg1, s.thisObject()); + SE_PRECONDITION2(ok, false, "js_scene_Model_updateLocalDescriptors : Error processing arguments"); + cobj->updateLocalDescriptors(arg0.value(), arg1.value()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 2); + return false; +} +SE_BIND_FUNC(js_scene_Model_updateLocalDescriptors) static bool js_scene_Model_updateTransform(se::State& s) // NOLINT(readability-identifier-naming) { @@ -2107,6 +11722,42 @@ static bool js_scene_Model_updateUBOs(se::State& s) // NOLINT(readability-identi } SE_BIND_FUNC(js_scene_Model_updateUBOs) +static bool js_scene_Model_updateWorldBound(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_scene_Model_updateWorldBound : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + if (argc == 0) { + cobj->updateWorldBound(); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 0); + return false; +} +SE_BIND_FUNC(js_scene_Model_updateWorldBound) + +static bool js_scene_Model_updateWorldBoundDescriptors(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_scene_Model_updateWorldBoundDescriptors : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 2) { + HolderType arg0 = {}; + HolderType arg1 = {}; + ok &= sevalue_to_native(args[0], &arg0, s.thisObject()); + ok &= sevalue_to_native(args[1], &arg1, s.thisObject()); + SE_PRECONDITION2(ok, false, "js_scene_Model_updateWorldBoundDescriptors : Error processing arguments"); + cobj->updateWorldBoundDescriptors(arg0.value(), arg1.value()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 2); + return false; +} +SE_BIND_FUNC(js_scene_Model_updateWorldBoundDescriptors) + static bool js_scene_Model_updateWorldBoundUBOs(se::State& s) // NOLINT(readability-identifier-naming) { auto* cobj = SE_THIS_OBJECT(s); @@ -2122,28 +11773,58 @@ static bool js_scene_Model_updateWorldBoundUBOs(se::State& s) // NOLINT(readabil } SE_BIND_FUNC(js_scene_Model_updateWorldBoundUBOs) +static bool js_scene_Model_updateWorldBoundsForJSBakedSkinningModel(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_scene_Model_updateWorldBoundsForJSBakedSkinningModel : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 1) { + HolderType arg0 = {}; + ok &= sevalue_to_native(args[0], &arg0, s.thisObject()); + SE_PRECONDITION2(ok, false, "js_scene_Model_updateWorldBoundsForJSBakedSkinningModel : Error processing arguments"); + cobj->updateWorldBoundsForJSBakedSkinningModel(arg0.value()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 1); + return false; +} +SE_BIND_FUNC(js_scene_Model_updateWorldBoundsForJSBakedSkinningModel) + +static bool js_scene_Model_updateWorldBoundsForJSSkinningModel(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_scene_Model_updateWorldBoundsForJSSkinningModel : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 2) { + HolderType arg0 = {}; + HolderType arg1 = {}; + ok &= sevalue_to_native(args[0], &arg0, s.thisObject()); + ok &= sevalue_to_native(args[1], &arg1, s.thisObject()); + SE_PRECONDITION2(ok, false, "js_scene_Model_updateWorldBoundsForJSSkinningModel : Error processing arguments"); + cobj->updateWorldBoundsForJSSkinningModel(arg0.value(), arg1.value()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 2); + return false; +} +SE_BIND_FUNC(js_scene_Model_updateWorldBoundsForJSSkinningModel) + SE_DECLARE_FINALIZE_FUNC(js_cc_scene_Model_finalize) static bool js_scene_Model_constructor(se::State& s) // NOLINT(readability-identifier-naming) constructor.c { - cc::scene::Model* cobj = JSB_ALLOC(cc::scene::Model); - s.thisObject()->setPrivateData(cobj); - se::NonRefNativePtrCreatedByCtorMap::emplace(cobj); + auto *ptr = JSB_MAKE_PRIVATE_OBJECT(cc::scene::Model); + s.thisObject()->setPrivateObject(ptr); return true; } SE_BIND_CTOR(js_scene_Model_constructor, __jsb_cc_scene_Model_class, js_cc_scene_Model_finalize) - - static bool js_cc_scene_Model_finalize(se::State& s) // NOLINT(readability-identifier-naming) { - auto iter = se::NonRefNativePtrCreatedByCtorMap::find(SE_THIS_OBJECT(s)); - if (iter != se::NonRefNativePtrCreatedByCtorMap::end()) - { - se::NonRefNativePtrCreatedByCtorMap::erase(iter); - auto* cobj = SE_THIS_OBJECT(s); - JSB_FREE(cobj); - } return true; } SE_BIND_FINALIZE_FUNC(js_cc_scene_Model_finalize) @@ -2152,36 +11833,59 @@ bool js_register_scene_Model(se::Object* obj) // NOLINT(readability-identifier-n { auto* cls = se::Class::create("Model", obj, nullptr, _SE(js_scene_Model_constructor)); - cls->defineFunction("getCastShadow", _SE(js_scene_Model_getCastShadow)); - cls->defineFunction("getEnabled", _SE(js_scene_Model_getEnabled)); + cls->defineProperty("node", _SE(js_scene_Model_getNode_asGetter), _SE(js_scene_Model_setNode_asSetter)); + cls->defineProperty("isInstancingEnabled", _SE(js_scene_Model_isInstancingEnabled_asGetter), nullptr); + cls->defineProperty("castShadow", _SE(js_scene_Model_isCastShadow_asGetter), _SE(js_scene_Model_setCastShadow_asSetter)); + cls->defineProperty("visFlags", _SE(js_scene_Model_getVisFlags_asGetter), _SE(js_scene_Model_setVisFlags_asSetter)); + cls->defineProperty("instancedAttributes", _SE(js_scene_Model_getInstancedAttributeBlock_asGetter), _SE(js_scene_Model_setInstancedAttributeBlock_asSetter)); + cls->defineProperty("type", _SE(js_scene_Model_getType_asGetter), _SE(js_scene_Model_setType_asSetter)); + cls->defineProperty("worldBoundBuffer", _SE(js_scene_Model_getWorldBoundBuffer_asGetter), _SE(js_scene_Model_setWorldBoundBuffer_asSetter)); + cls->defineProperty({"_subModels", "subModels"}, _SE(js_scene_Model_getSubModels_asGetter), nullptr); + cls->defineProperty("enabled", _SE(js_scene_Model_isEnabled_asGetter), _SE(js_scene_Model_setEnabled_asSetter)); + cls->defineProperty({"_modelBounds", "modelBounds"}, _SE(js_scene_Model_getModelBounds_asGetter), _SE(js_scene_Model_setModelBounds_asSetter)); + cls->defineProperty("transform", _SE(js_scene_Model_getTransform_asGetter), _SE(js_scene_Model_setTransform_asSetter)); + cls->defineProperty("scene", _SE(js_scene_Model_getScene_asGetter), _SE(js_scene_Model_setScene_asSetter)); + cls->defineProperty("localBuffer", _SE(js_scene_Model_getLocalBuffer_asGetter), _SE(js_scene_Model_setLocalBuffer_asSetter)); + cls->defineProperty("isDynamicBatching", _SE(js_scene_Model_isDynamicBatching_asGetter), _SE(js_scene_Model_setDynamicBatching_asSetter)); + cls->defineProperty("updateStamp", _SE(js_scene_Model_getUpdateStamp_asGetter), nullptr); + cls->defineProperty("receiveShadow", _SE(js_scene_Model_isReceiveShadow_asGetter), _SE(js_scene_Model_setReceiveShadow_asSetter)); + cls->defineProperty("inited", _SE(js_scene_Model_isInited_asGetter), nullptr); + cls->defineProperty("_localDataUpdated", _SE(js_scene_Model_isLocalDataUpdated_asGetter), _SE(js_scene_Model_setLocalDataUpdated_asSetter)); + cls->defineProperty({"_worldBounds", "worldBounds"}, _SE(js_scene_Model_getWorldBounds_asGetter), _SE(js_scene_Model_setWorldBounds_asSetter)); + cls->defineFunction("attachToScene", _SE(js_scene_Model_attachToScene)); + cls->defineFunction("createBoundingShape", _SE(js_scene_Model_createBoundingShape)); + cls->defineFunction("destroy", _SE(js_scene_Model_destroy)); + cls->defineFunction("detachFromScene", _SE(js_scene_Model_detachFromScene)); cls->defineFunction("getInstMatWorldIdx", _SE(js_scene_Model_getInstMatWorldIdx)); cls->defineFunction("getInstanceAttributes", _SE(js_scene_Model_getInstanceAttributes)); - cls->defineFunction("getInstancedAttributeBlock", _SE(js_scene_Model_getInstancedAttributeBlock)); + cls->defineFunction("_getInstancedAttributeIndex", _SE(js_scene_Model_getInstancedAttributeIndex)); cls->defineFunction("getInstancedBuffer", _SE(js_scene_Model_getInstancedBuffer)); cls->defineFunction("getInstancedBufferSize", _SE(js_scene_Model_getInstancedBufferSize)); cls->defineFunction("getLocalData", _SE(js_scene_Model_getLocalData)); - cls->defineFunction("getNode", _SE(js_scene_Model_getNode)); - cls->defineFunction("getReceiveShadow", _SE(js_scene_Model_getReceiveShadow)); - cls->defineFunction("getSubModels", _SE(js_scene_Model_getSubModels)); - cls->defineFunction("getTransform", _SE(js_scene_Model_getTransform)); - cls->defineFunction("getTransformUpdated", _SE(js_scene_Model_getTransformUpdated)); - cls->defineFunction("getUpdatStamp", _SE(js_scene_Model_getUpdatStamp)); - cls->defineFunction("getVisFlags", _SE(js_scene_Model_getVisFlags)); - cls->defineFunction("getWorldBoundBuffer", _SE(js_scene_Model_getWorldBoundBuffer)); - cls->defineFunction("seVisFlag", _SE(js_scene_Model_seVisFlag)); + cls->defineFunction("getMacroPatches", _SE(js_scene_Model_getMacroPatches)); + cls->defineFunction("_initLocalDescriptors", _SE(js_scene_Model_initLocalDescriptors)); + cls->defineFunction("initSubModel", _SE(js_scene_Model_initSubModel)); + cls->defineFunction("initWorldBoundDescriptors", _SE(js_scene_Model_initWorldBoundDescriptors)); + cls->defineFunction("initialize", _SE(js_scene_Model_initialize)); + cls->defineFunction("isModelImplementedInJS", _SE(js_scene_Model_isModelImplementedInJS)); + cls->defineFunction("onGlobalPipelineStateChanged", _SE(js_scene_Model_onGlobalPipelineStateChanged)); + cls->defineFunction("onMacroPatchesStateChanged", _SE(js_scene_Model_onMacroPatchesStateChanged)); cls->defineFunction("setBounds", _SE(js_scene_Model_setBounds)); - cls->defineFunction("setCastShadow", _SE(js_scene_Model_setCastShadow)); - cls->defineFunction("setEnabled", _SE(js_scene_Model_setEnabled)); + cls->defineFunction("setCalledFromJS", _SE(js_scene_Model_setCalledFromJS)); cls->defineFunction("setInstMatWorldIdx", _SE(js_scene_Model_setInstMatWorldIdx)); - cls->defineFunction("setLocalBuffer", _SE(js_scene_Model_setLocalBuffer)); - cls->defineFunction("setNode", _SE(js_scene_Model_setNode)); - cls->defineFunction("setReceiveShadow", _SE(js_scene_Model_setReceiveShadow)); - cls->defineFunction("setSubModel", _SE(js_scene_Model_setSubModel)); - cls->defineFunction("setTransform", _SE(js_scene_Model_setTransform)); - cls->defineFunction("setWorldBoundBuffer", _SE(js_scene_Model_setWorldBoundBuffer)); + cls->defineFunction("setInstancedAttributesViewData", _SE(js_scene_Model_setInstancedAttributesViewData)); + cls->defineFunction("setSubModelMaterial", _SE(js_scene_Model_setSubModelMaterial)); + cls->defineFunction("setSubModelMesh", _SE(js_scene_Model_setSubModelMesh)); + cls->defineFunction("_updateInstancedAttributes", _SE(js_scene_Model_updateInstancedAttributes)); + cls->defineFunction("updateLightingmap", _SE(js_scene_Model_updateLightingmap)); + cls->defineFunction("_updateLocalDescriptors", _SE(js_scene_Model_updateLocalDescriptors)); cls->defineFunction("updateTransform", _SE(js_scene_Model_updateTransform)); cls->defineFunction("updateUBOs", _SE(js_scene_Model_updateUBOs)); + cls->defineFunction("updateWorldBound", _SE(js_scene_Model_updateWorldBound)); + cls->defineFunction("updateWorldBoundDescriptors", _SE(js_scene_Model_updateWorldBoundDescriptors)); cls->defineFunction("updateWorldBoundUBOs", _SE(js_scene_Model_updateWorldBoundUBOs)); + cls->defineFunction("updateWorldBoundsForJSBakedSkinningModel", _SE(js_scene_Model_updateWorldBoundsForJSBakedSkinningModel)); + cls->defineFunction("updateWorldBoundsForJSSkinningModel", _SE(js_scene_Model_updateWorldBoundsForJSSkinningModel)); cls->defineFinalizeFunction(_SE(js_cc_scene_Model_finalize)); cls->install(); JSBClassType::registerClass(cls); @@ -2189,4558 +11893,147 @@ bool js_register_scene_Model(se::Object* obj) // NOLINT(readability-identifier-n __jsb_cc_scene_Model_proto = cls->getProto(); __jsb_cc_scene_Model_class = cls; - se::ScriptEngine::getInstance()->clearException(); - return true; -} -se::Object* __jsb_cc_scene_Fog_proto = nullptr; -se::Class* __jsb_cc_scene_Fog_class = nullptr; - -static bool js_scene_Fog_get_enabled(se::State& s) // NOLINT(readability-identifier-naming) -{ - auto* cobj = SE_THIS_OBJECT(s); - SE_PRECONDITION2(cobj, false, "js_scene_Fog_get_enabled : Invalid Native Object"); - - CC_UNUSED bool ok = true; - se::Value jsret; - ok &= nativevalue_to_se(cobj->enabled, jsret, s.thisObject() /*ctx*/); - s.rval() = jsret; - SE_HOLD_RETURN_VALUE(cobj->enabled, s.thisObject(), s.rval()); - return true; -} -SE_BIND_PROP_GET(js_scene_Fog_get_enabled) - -static bool js_scene_Fog_set_enabled(se::State& s) // NOLINT(readability-identifier-naming) -{ - const auto& args = s.args(); - auto* cobj = SE_THIS_OBJECT(s); - SE_PRECONDITION2(cobj, false, "js_scene_Fog_set_enabled : Invalid Native Object"); - - CC_UNUSED bool ok = true; - ok &= sevalue_to_native(args[0], &cobj->enabled, s.thisObject()); - SE_PRECONDITION2(ok, false, "js_scene_Fog_set_enabled : Error processing new value"); - return true; -} -SE_BIND_PROP_SET(js_scene_Fog_set_enabled) - -static bool js_scene_Fog_get_accurate(se::State& s) // NOLINT(readability-identifier-naming) -{ - auto* cobj = SE_THIS_OBJECT(s); - SE_PRECONDITION2(cobj, false, "js_scene_Fog_get_accurate : Invalid Native Object"); - - CC_UNUSED bool ok = true; - se::Value jsret; - ok &= nativevalue_to_se(cobj->accurate, jsret, s.thisObject() /*ctx*/); - s.rval() = jsret; - SE_HOLD_RETURN_VALUE(cobj->accurate, s.thisObject(), s.rval()); - return true; -} -SE_BIND_PROP_GET(js_scene_Fog_get_accurate) - -static bool js_scene_Fog_set_accurate(se::State& s) // NOLINT(readability-identifier-naming) -{ - const auto& args = s.args(); - auto* cobj = SE_THIS_OBJECT(s); - SE_PRECONDITION2(cobj, false, "js_scene_Fog_set_accurate : Invalid Native Object"); - - CC_UNUSED bool ok = true; - ok &= sevalue_to_native(args[0], &cobj->accurate, s.thisObject()); - SE_PRECONDITION2(ok, false, "js_scene_Fog_set_accurate : Error processing new value"); - return true; -} -SE_BIND_PROP_SET(js_scene_Fog_set_accurate) - -static bool js_scene_Fog_get_type(se::State& s) // NOLINT(readability-identifier-naming) -{ - auto* cobj = SE_THIS_OBJECT(s); - SE_PRECONDITION2(cobj, false, "js_scene_Fog_get_type : Invalid Native Object"); - - CC_UNUSED bool ok = true; - se::Value jsret; - ok &= nativevalue_to_se(cobj->type, jsret, s.thisObject() /*ctx*/); - s.rval() = jsret; - SE_HOLD_RETURN_VALUE(cobj->type, s.thisObject(), s.rval()); - return true; -} -SE_BIND_PROP_GET(js_scene_Fog_get_type) - -static bool js_scene_Fog_set_type(se::State& s) // NOLINT(readability-identifier-naming) -{ - const auto& args = s.args(); - auto* cobj = SE_THIS_OBJECT(s); - SE_PRECONDITION2(cobj, false, "js_scene_Fog_set_type : Invalid Native Object"); - - CC_UNUSED bool ok = true; - ok &= sevalue_to_native(args[0], &cobj->type, s.thisObject()); - SE_PRECONDITION2(ok, false, "js_scene_Fog_set_type : Error processing new value"); - return true; -} -SE_BIND_PROP_SET(js_scene_Fog_set_type) - -static bool js_scene_Fog_get_density(se::State& s) // NOLINT(readability-identifier-naming) -{ - auto* cobj = SE_THIS_OBJECT(s); - SE_PRECONDITION2(cobj, false, "js_scene_Fog_get_density : Invalid Native Object"); - - CC_UNUSED bool ok = true; - se::Value jsret; - ok &= nativevalue_to_se(cobj->density, jsret, s.thisObject() /*ctx*/); - s.rval() = jsret; - SE_HOLD_RETURN_VALUE(cobj->density, s.thisObject(), s.rval()); - return true; -} -SE_BIND_PROP_GET(js_scene_Fog_get_density) - -static bool js_scene_Fog_set_density(se::State& s) // NOLINT(readability-identifier-naming) -{ - const auto& args = s.args(); - auto* cobj = SE_THIS_OBJECT(s); - SE_PRECONDITION2(cobj, false, "js_scene_Fog_set_density : Invalid Native Object"); - - CC_UNUSED bool ok = true; - ok &= sevalue_to_native(args[0], &cobj->density, s.thisObject()); - SE_PRECONDITION2(ok, false, "js_scene_Fog_set_density : Error processing new value"); - return true; -} -SE_BIND_PROP_SET(js_scene_Fog_set_density) - -static bool js_scene_Fog_get_start(se::State& s) // NOLINT(readability-identifier-naming) -{ - auto* cobj = SE_THIS_OBJECT(s); - SE_PRECONDITION2(cobj, false, "js_scene_Fog_get_start : Invalid Native Object"); - - CC_UNUSED bool ok = true; - se::Value jsret; - ok &= nativevalue_to_se(cobj->start, jsret, s.thisObject() /*ctx*/); - s.rval() = jsret; - SE_HOLD_RETURN_VALUE(cobj->start, s.thisObject(), s.rval()); - return true; -} -SE_BIND_PROP_GET(js_scene_Fog_get_start) - -static bool js_scene_Fog_set_start(se::State& s) // NOLINT(readability-identifier-naming) -{ - const auto& args = s.args(); - auto* cobj = SE_THIS_OBJECT(s); - SE_PRECONDITION2(cobj, false, "js_scene_Fog_set_start : Invalid Native Object"); - - CC_UNUSED bool ok = true; - ok &= sevalue_to_native(args[0], &cobj->start, s.thisObject()); - SE_PRECONDITION2(ok, false, "js_scene_Fog_set_start : Error processing new value"); - return true; -} -SE_BIND_PROP_SET(js_scene_Fog_set_start) - -static bool js_scene_Fog_get_end(se::State& s) // NOLINT(readability-identifier-naming) -{ - auto* cobj = SE_THIS_OBJECT(s); - SE_PRECONDITION2(cobj, false, "js_scene_Fog_get_end : Invalid Native Object"); - - CC_UNUSED bool ok = true; - se::Value jsret; - ok &= nativevalue_to_se(cobj->end, jsret, s.thisObject() /*ctx*/); - s.rval() = jsret; - SE_HOLD_RETURN_VALUE(cobj->end, s.thisObject(), s.rval()); - return true; -} -SE_BIND_PROP_GET(js_scene_Fog_get_end) - -static bool js_scene_Fog_set_end(se::State& s) // NOLINT(readability-identifier-naming) -{ - const auto& args = s.args(); - auto* cobj = SE_THIS_OBJECT(s); - SE_PRECONDITION2(cobj, false, "js_scene_Fog_set_end : Invalid Native Object"); - - CC_UNUSED bool ok = true; - ok &= sevalue_to_native(args[0], &cobj->end, s.thisObject()); - SE_PRECONDITION2(ok, false, "js_scene_Fog_set_end : Error processing new value"); - return true; -} -SE_BIND_PROP_SET(js_scene_Fog_set_end) - -static bool js_scene_Fog_get_atten(se::State& s) // NOLINT(readability-identifier-naming) -{ - auto* cobj = SE_THIS_OBJECT(s); - SE_PRECONDITION2(cobj, false, "js_scene_Fog_get_atten : Invalid Native Object"); - - CC_UNUSED bool ok = true; - se::Value jsret; - ok &= nativevalue_to_se(cobj->atten, jsret, s.thisObject() /*ctx*/); - s.rval() = jsret; - SE_HOLD_RETURN_VALUE(cobj->atten, s.thisObject(), s.rval()); - return true; -} -SE_BIND_PROP_GET(js_scene_Fog_get_atten) - -static bool js_scene_Fog_set_atten(se::State& s) // NOLINT(readability-identifier-naming) -{ - const auto& args = s.args(); - auto* cobj = SE_THIS_OBJECT(s); - SE_PRECONDITION2(cobj, false, "js_scene_Fog_set_atten : Invalid Native Object"); - - CC_UNUSED bool ok = true; - ok &= sevalue_to_native(args[0], &cobj->atten, s.thisObject()); - SE_PRECONDITION2(ok, false, "js_scene_Fog_set_atten : Error processing new value"); - return true; -} -SE_BIND_PROP_SET(js_scene_Fog_set_atten) - -static bool js_scene_Fog_get_top(se::State& s) // NOLINT(readability-identifier-naming) -{ - auto* cobj = SE_THIS_OBJECT(s); - SE_PRECONDITION2(cobj, false, "js_scene_Fog_get_top : Invalid Native Object"); - - CC_UNUSED bool ok = true; - se::Value jsret; - ok &= nativevalue_to_se(cobj->top, jsret, s.thisObject() /*ctx*/); - s.rval() = jsret; - SE_HOLD_RETURN_VALUE(cobj->top, s.thisObject(), s.rval()); - return true; -} -SE_BIND_PROP_GET(js_scene_Fog_get_top) - -static bool js_scene_Fog_set_top(se::State& s) // NOLINT(readability-identifier-naming) -{ - const auto& args = s.args(); - auto* cobj = SE_THIS_OBJECT(s); - SE_PRECONDITION2(cobj, false, "js_scene_Fog_set_top : Invalid Native Object"); - - CC_UNUSED bool ok = true; - ok &= sevalue_to_native(args[0], &cobj->top, s.thisObject()); - SE_PRECONDITION2(ok, false, "js_scene_Fog_set_top : Error processing new value"); - return true; -} -SE_BIND_PROP_SET(js_scene_Fog_set_top) - -static bool js_scene_Fog_get_range(se::State& s) // NOLINT(readability-identifier-naming) -{ - auto* cobj = SE_THIS_OBJECT(s); - SE_PRECONDITION2(cobj, false, "js_scene_Fog_get_range : Invalid Native Object"); - - CC_UNUSED bool ok = true; - se::Value jsret; - ok &= nativevalue_to_se(cobj->range, jsret, s.thisObject() /*ctx*/); - s.rval() = jsret; - SE_HOLD_RETURN_VALUE(cobj->range, s.thisObject(), s.rval()); - return true; -} -SE_BIND_PROP_GET(js_scene_Fog_get_range) - -static bool js_scene_Fog_set_range(se::State& s) // NOLINT(readability-identifier-naming) -{ - const auto& args = s.args(); - auto* cobj = SE_THIS_OBJECT(s); - SE_PRECONDITION2(cobj, false, "js_scene_Fog_set_range : Invalid Native Object"); - - CC_UNUSED bool ok = true; - ok &= sevalue_to_native(args[0], &cobj->range, s.thisObject()); - SE_PRECONDITION2(ok, false, "js_scene_Fog_set_range : Error processing new value"); - return true; -} -SE_BIND_PROP_SET(js_scene_Fog_set_range) - -static bool js_scene_Fog_get_color(se::State& s) // NOLINT(readability-identifier-naming) -{ - auto* cobj = SE_THIS_OBJECT(s); - SE_PRECONDITION2(cobj, false, "js_scene_Fog_get_color : Invalid Native Object"); - - CC_UNUSED bool ok = true; - se::Value jsret; - ok &= nativevalue_to_se(cobj->color, jsret, s.thisObject() /*ctx*/); - s.rval() = jsret; - SE_HOLD_RETURN_VALUE(cobj->color, s.thisObject(), s.rval()); - return true; -} -SE_BIND_PROP_GET(js_scene_Fog_get_color) - -static bool js_scene_Fog_set_color(se::State& s) // NOLINT(readability-identifier-naming) -{ - const auto& args = s.args(); - auto* cobj = SE_THIS_OBJECT(s); - SE_PRECONDITION2(cobj, false, "js_scene_Fog_set_color : Invalid Native Object"); - - CC_UNUSED bool ok = true; - ok &= sevalue_to_native(args[0], &cobj->color, s.thisObject()); - SE_PRECONDITION2(ok, false, "js_scene_Fog_set_color : Error processing new value"); - return true; -} -SE_BIND_PROP_SET(js_scene_Fog_set_color) - - -template<> -bool sevalue_to_native(const se::Value &from, cc::scene::Fog * to, se::Object *ctx) -{ - assert(from.isObject()); - se::Object *json = from.toObject(); - auto* data = reinterpret_cast(json->getPrivateData()); - if (data) { - *to = *data; - return true; - } - se::Value field; - bool ok = true; - json->getProperty("enabled", &field); - if(!field.isNullOrUndefined()) { - ok &= sevalue_to_native(field, &(to->enabled), ctx); - } - json->getProperty("accurate", &field); - if(!field.isNullOrUndefined()) { - ok &= sevalue_to_native(field, &(to->accurate), ctx); - } - json->getProperty("type", &field); - if(!field.isNullOrUndefined()) { - ok &= sevalue_to_native(field, &(to->type), ctx); - } - json->getProperty("density", &field); - if(!field.isNullOrUndefined()) { - ok &= sevalue_to_native(field, &(to->density), ctx); - } - json->getProperty("start", &field); - if(!field.isNullOrUndefined()) { - ok &= sevalue_to_native(field, &(to->start), ctx); - } - json->getProperty("end", &field); - if(!field.isNullOrUndefined()) { - ok &= sevalue_to_native(field, &(to->end), ctx); - } - json->getProperty("atten", &field); - if(!field.isNullOrUndefined()) { - ok &= sevalue_to_native(field, &(to->atten), ctx); - } - json->getProperty("top", &field); - if(!field.isNullOrUndefined()) { - ok &= sevalue_to_native(field, &(to->top), ctx); - } - json->getProperty("range", &field); - if(!field.isNullOrUndefined()) { - ok &= sevalue_to_native(field, &(to->range), ctx); - } - json->getProperty("color", &field); - if(!field.isNullOrUndefined()) { - ok &= sevalue_to_native(field, &(to->color), ctx); - } - return ok; -} - -SE_DECLARE_FINALIZE_FUNC(js_cc_scene_Fog_finalize) - -static bool js_scene_Fog_constructor(se::State& s) // NOLINT(readability-identifier-naming) -{ - CC_UNUSED bool ok = true; - const auto& args = s.args(); - size_t argc = args.size(); - - if(argc == 0) - { - cc::scene::Fog* cobj = JSB_ALLOC(cc::scene::Fog); - s.thisObject()->setPrivateData(cobj); - se::NonRefNativePtrCreatedByCtorMap::emplace(cobj); - return true; - } - - if(argc == 1 && args[0].isObject()) - { - se::Object *json = args[0].toObject(); - se::Value field; - - cc::scene::Fog* cobj = JSB_ALLOC(cc::scene::Fog); - ok &= sevalue_to_native(args[0], cobj, s.thisObject()); - if(!ok) { - JSB_FREE(cobj); - SE_REPORT_ERROR("argument convertion error"); - return false; - } - - s.thisObject()->setPrivateData(cobj); - se::NonRefNativePtrCreatedByCtorMap::emplace(cobj); - return true; - } - - cc::scene::Fog* cobj = JSB_ALLOC(cc::scene::Fog); - if (argc > 0 && !args[0].isUndefined()) { - ok &= sevalue_to_native(args[0], &(cobj->enabled), nullptr); - } - if (argc > 1 && !args[1].isUndefined()) { - ok &= sevalue_to_native(args[1], &(cobj->accurate), nullptr); - } - if (argc > 2 && !args[2].isUndefined()) { - ok &= sevalue_to_native(args[2], &(cobj->type), nullptr); - } - if (argc > 3 && !args[3].isUndefined()) { - ok &= sevalue_to_native(args[3], &(cobj->density), nullptr); - } - if (argc > 4 && !args[4].isUndefined()) { - ok &= sevalue_to_native(args[4], &(cobj->start), nullptr); - } - if (argc > 5 && !args[5].isUndefined()) { - ok &= sevalue_to_native(args[5], &(cobj->end), nullptr); - } - if (argc > 6 && !args[6].isUndefined()) { - ok &= sevalue_to_native(args[6], &(cobj->atten), nullptr); - } - if (argc > 7 && !args[7].isUndefined()) { - ok &= sevalue_to_native(args[7], &(cobj->top), nullptr); - } - if (argc > 8 && !args[8].isUndefined()) { - ok &= sevalue_to_native(args[8], &(cobj->range), nullptr); - } - if (argc > 9 && !args[9].isUndefined()) { - ok &= sevalue_to_native(args[9], &(cobj->color), nullptr); - } - - if(!ok) { - JSB_FREE(cobj); - SE_REPORT_ERROR("Argument convertion error"); - return false; - } - - s.thisObject()->setPrivateData(cobj); - se::NonRefNativePtrCreatedByCtorMap::emplace(cobj); - return true; -} -SE_BIND_CTOR(js_scene_Fog_constructor, __jsb_cc_scene_Fog_class, js_cc_scene_Fog_finalize) - - - -static bool js_cc_scene_Fog_finalize(se::State& s) // NOLINT(readability-identifier-naming) -{ - auto iter = se::NonRefNativePtrCreatedByCtorMap::find(SE_THIS_OBJECT(s)); - if (iter != se::NonRefNativePtrCreatedByCtorMap::end()) - { - se::NonRefNativePtrCreatedByCtorMap::erase(iter); - auto* cobj = SE_THIS_OBJECT(s); - JSB_FREE(cobj); - } - return true; -} -SE_BIND_FINALIZE_FUNC(js_cc_scene_Fog_finalize) - -bool js_register_scene_Fog(se::Object* obj) // NOLINT(readability-identifier-naming) -{ - auto* cls = se::Class::create("Fog", obj, nullptr, _SE(js_scene_Fog_constructor)); - - cls->defineProperty("enabled", _SE(js_scene_Fog_get_enabled), _SE(js_scene_Fog_set_enabled)); - cls->defineProperty("accurate", _SE(js_scene_Fog_get_accurate), _SE(js_scene_Fog_set_accurate)); - cls->defineProperty("type", _SE(js_scene_Fog_get_type), _SE(js_scene_Fog_set_type)); - cls->defineProperty("density", _SE(js_scene_Fog_get_density), _SE(js_scene_Fog_set_density)); - cls->defineProperty("start", _SE(js_scene_Fog_get_start), _SE(js_scene_Fog_set_start)); - cls->defineProperty("end", _SE(js_scene_Fog_get_end), _SE(js_scene_Fog_set_end)); - cls->defineProperty("atten", _SE(js_scene_Fog_get_atten), _SE(js_scene_Fog_set_atten)); - cls->defineProperty("top", _SE(js_scene_Fog_get_top), _SE(js_scene_Fog_set_top)); - cls->defineProperty("range", _SE(js_scene_Fog_get_range), _SE(js_scene_Fog_set_range)); - cls->defineProperty("color", _SE(js_scene_Fog_get_color), _SE(js_scene_Fog_set_color)); - cls->defineFinalizeFunction(_SE(js_cc_scene_Fog_finalize)); - cls->install(); - JSBClassType::registerClass(cls); - - __jsb_cc_scene_Fog_proto = cls->getProto(); - __jsb_cc_scene_Fog_class = cls; se::ScriptEngine::getInstance()->clearException(); return true; } -se::Object* __jsb_cc_scene_Shadow_proto = nullptr; -se::Class* __jsb_cc_scene_Shadow_class = nullptr; +se::Object* __jsb_cc_scene_DrawBatch2D_proto = nullptr; // NOLINT +se::Class* __jsb_cc_scene_DrawBatch2D_class = nullptr; // NOLINT -static bool js_scene_Shadow_get_enabled(se::State& s) // NOLINT(readability-identifier-naming) +static bool js_scene_DrawBatch2D_get_visFlags(se::State& s) // NOLINT(readability-identifier-naming) { - auto* cobj = SE_THIS_OBJECT(s); - SE_PRECONDITION2(cobj, false, "js_scene_Shadow_get_enabled : Invalid Native Object"); + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_scene_DrawBatch2D_get_visFlags : Invalid Native Object"); CC_UNUSED bool ok = true; se::Value jsret; - ok &= nativevalue_to_se(cobj->enabled, jsret, s.thisObject() /*ctx*/); + ok &= nativevalue_to_se(cobj->visFlags, jsret, s.thisObject() /*ctx*/); s.rval() = jsret; - SE_HOLD_RETURN_VALUE(cobj->enabled, s.thisObject(), s.rval()); + SE_HOLD_RETURN_VALUE(cobj->visFlags, s.thisObject(), s.rval()); return true; } -SE_BIND_PROP_GET(js_scene_Shadow_get_enabled) +SE_BIND_PROP_GET(js_scene_DrawBatch2D_get_visFlags) -static bool js_scene_Shadow_set_enabled(se::State& s) // NOLINT(readability-identifier-naming) +static bool js_scene_DrawBatch2D_set_visFlags(se::State& s) // NOLINT(readability-identifier-naming) { const auto& args = s.args(); - auto* cobj = SE_THIS_OBJECT(s); - SE_PRECONDITION2(cobj, false, "js_scene_Shadow_set_enabled : Invalid Native Object"); + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_scene_DrawBatch2D_set_visFlags : Invalid Native Object"); CC_UNUSED bool ok = true; - ok &= sevalue_to_native(args[0], &cobj->enabled, s.thisObject()); - SE_PRECONDITION2(ok, false, "js_scene_Shadow_set_enabled : Error processing new value"); + ok &= sevalue_to_native(args[0], &cobj->visFlags, s.thisObject()); + SE_PRECONDITION2(ok, false, "js_scene_DrawBatch2D_set_visFlags : Error processing new value"); return true; } -SE_BIND_PROP_SET(js_scene_Shadow_set_enabled) +SE_BIND_PROP_SET(js_scene_DrawBatch2D_set_visFlags) -static bool js_scene_Shadow_get_dirty(se::State& s) // NOLINT(readability-identifier-naming) +static bool js_scene_DrawBatch2D_get_descriptorSet(se::State& s) // NOLINT(readability-identifier-naming) { - auto* cobj = SE_THIS_OBJECT(s); - SE_PRECONDITION2(cobj, false, "js_scene_Shadow_get_dirty : Invalid Native Object"); + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_scene_DrawBatch2D_get_descriptorSet : Invalid Native Object"); CC_UNUSED bool ok = true; se::Value jsret; - ok &= nativevalue_to_se(cobj->dirty, jsret, s.thisObject() /*ctx*/); + ok &= nativevalue_to_se(cobj->descriptorSet, jsret, s.thisObject() /*ctx*/); s.rval() = jsret; - SE_HOLD_RETURN_VALUE(cobj->dirty, s.thisObject(), s.rval()); + SE_HOLD_RETURN_VALUE(cobj->descriptorSet, s.thisObject(), s.rval()); return true; } -SE_BIND_PROP_GET(js_scene_Shadow_get_dirty) +SE_BIND_PROP_GET(js_scene_DrawBatch2D_get_descriptorSet) -static bool js_scene_Shadow_set_dirty(se::State& s) // NOLINT(readability-identifier-naming) +static bool js_scene_DrawBatch2D_set_descriptorSet(se::State& s) // NOLINT(readability-identifier-naming) { const auto& args = s.args(); - auto* cobj = SE_THIS_OBJECT(s); - SE_PRECONDITION2(cobj, false, "js_scene_Shadow_set_dirty : Invalid Native Object"); + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_scene_DrawBatch2D_set_descriptorSet : Invalid Native Object"); CC_UNUSED bool ok = true; - ok &= sevalue_to_native(args[0], &cobj->dirty, s.thisObject()); - SE_PRECONDITION2(ok, false, "js_scene_Shadow_set_dirty : Error processing new value"); + ok &= sevalue_to_native(args[0], &cobj->descriptorSet, s.thisObject()); + SE_PRECONDITION2(ok, false, "js_scene_DrawBatch2D_set_descriptorSet : Error processing new value"); return true; } -SE_BIND_PROP_SET(js_scene_Shadow_set_dirty) +SE_BIND_PROP_SET(js_scene_DrawBatch2D_set_descriptorSet) -static bool js_scene_Shadow_get_shadowMapDirty(se::State& s) // NOLINT(readability-identifier-naming) +static bool js_scene_DrawBatch2D_get_inputAssembler(se::State& s) // NOLINT(readability-identifier-naming) { - auto* cobj = SE_THIS_OBJECT(s); - SE_PRECONDITION2(cobj, false, "js_scene_Shadow_get_shadowMapDirty : Invalid Native Object"); + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_scene_DrawBatch2D_get_inputAssembler : Invalid Native Object"); CC_UNUSED bool ok = true; se::Value jsret; - ok &= nativevalue_to_se(cobj->shadowMapDirty, jsret, s.thisObject() /*ctx*/); + ok &= nativevalue_to_se(cobj->inputAssembler, jsret, s.thisObject() /*ctx*/); s.rval() = jsret; - SE_HOLD_RETURN_VALUE(cobj->shadowMapDirty, s.thisObject(), s.rval()); + SE_HOLD_RETURN_VALUE(cobj->inputAssembler, s.thisObject(), s.rval()); return true; } -SE_BIND_PROP_GET(js_scene_Shadow_get_shadowMapDirty) +SE_BIND_PROP_GET(js_scene_DrawBatch2D_get_inputAssembler) -static bool js_scene_Shadow_set_shadowMapDirty(se::State& s) // NOLINT(readability-identifier-naming) +static bool js_scene_DrawBatch2D_set_inputAssembler(se::State& s) // NOLINT(readability-identifier-naming) { const auto& args = s.args(); - auto* cobj = SE_THIS_OBJECT(s); - SE_PRECONDITION2(cobj, false, "js_scene_Shadow_set_shadowMapDirty : Invalid Native Object"); + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_scene_DrawBatch2D_set_inputAssembler : Invalid Native Object"); CC_UNUSED bool ok = true; - ok &= sevalue_to_native(args[0], &cobj->shadowMapDirty, s.thisObject()); - SE_PRECONDITION2(ok, false, "js_scene_Shadow_set_shadowMapDirty : Error processing new value"); + ok &= sevalue_to_native(args[0], &cobj->inputAssembler, s.thisObject()); + SE_PRECONDITION2(ok, false, "js_scene_DrawBatch2D_set_inputAssembler : Error processing new value"); return true; } -SE_BIND_PROP_SET(js_scene_Shadow_set_shadowMapDirty) +SE_BIND_PROP_SET(js_scene_DrawBatch2D_set_inputAssembler) -static bool js_scene_Shadow_get_fixedArea(se::State& s) // NOLINT(readability-identifier-naming) +static bool js_scene_DrawBatch2D_get_passes(se::State& s) // NOLINT(readability-identifier-naming) { - auto* cobj = SE_THIS_OBJECT(s); - SE_PRECONDITION2(cobj, false, "js_scene_Shadow_get_fixedArea : Invalid Native Object"); + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_scene_DrawBatch2D_get_passes : Invalid Native Object"); CC_UNUSED bool ok = true; se::Value jsret; - ok &= nativevalue_to_se(cobj->fixedArea, jsret, s.thisObject() /*ctx*/); + ok &= nativevalue_to_se(cobj->passes, jsret, s.thisObject() /*ctx*/); s.rval() = jsret; - SE_HOLD_RETURN_VALUE(cobj->fixedArea, s.thisObject(), s.rval()); + SE_HOLD_RETURN_VALUE(cobj->passes, s.thisObject(), s.rval()); return true; } -SE_BIND_PROP_GET(js_scene_Shadow_get_fixedArea) +SE_BIND_PROP_GET(js_scene_DrawBatch2D_get_passes) -static bool js_scene_Shadow_set_fixedArea(se::State& s) // NOLINT(readability-identifier-naming) +static bool js_scene_DrawBatch2D_set_passes(se::State& s) // NOLINT(readability-identifier-naming) { const auto& args = s.args(); - auto* cobj = SE_THIS_OBJECT(s); - SE_PRECONDITION2(cobj, false, "js_scene_Shadow_set_fixedArea : Invalid Native Object"); + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_scene_DrawBatch2D_set_passes : Invalid Native Object"); CC_UNUSED bool ok = true; - ok &= sevalue_to_native(args[0], &cobj->fixedArea, s.thisObject()); - SE_PRECONDITION2(ok, false, "js_scene_Shadow_set_fixedArea : Error processing new value"); + ok &= sevalue_to_native(args[0], &cobj->passes, s.thisObject()); + SE_PRECONDITION2(ok, false, "js_scene_DrawBatch2D_set_passes : Error processing new value"); return true; } -SE_BIND_PROP_SET(js_scene_Shadow_set_fixedArea) +SE_BIND_PROP_SET(js_scene_DrawBatch2D_set_passes) -static bool js_scene_Shadow_get_shadowType(se::State& s) // NOLINT(readability-identifier-naming) +static bool js_scene_DrawBatch2D_get_shaders(se::State& s) // NOLINT(readability-identifier-naming) { - auto* cobj = SE_THIS_OBJECT(s); - SE_PRECONDITION2(cobj, false, "js_scene_Shadow_get_shadowType : Invalid Native Object"); + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_scene_DrawBatch2D_get_shaders : Invalid Native Object"); CC_UNUSED bool ok = true; se::Value jsret; - ok &= nativevalue_to_se(cobj->shadowType, jsret, s.thisObject() /*ctx*/); + ok &= nativevalue_to_se(cobj->shaders, jsret, s.thisObject() /*ctx*/); s.rval() = jsret; - SE_HOLD_RETURN_VALUE(cobj->shadowType, s.thisObject(), s.rval()); + SE_HOLD_RETURN_VALUE(cobj->shaders, s.thisObject(), s.rval()); return true; } -SE_BIND_PROP_GET(js_scene_Shadow_get_shadowType) +SE_BIND_PROP_GET(js_scene_DrawBatch2D_get_shaders) -static bool js_scene_Shadow_set_shadowType(se::State& s) // NOLINT(readability-identifier-naming) +static bool js_scene_DrawBatch2D_set_shaders(se::State& s) // NOLINT(readability-identifier-naming) { const auto& args = s.args(); - auto* cobj = SE_THIS_OBJECT(s); - SE_PRECONDITION2(cobj, false, "js_scene_Shadow_set_shadowType : Invalid Native Object"); + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_scene_DrawBatch2D_set_shaders : Invalid Native Object"); CC_UNUSED bool ok = true; - ok &= sevalue_to_native(args[0], &cobj->shadowType, s.thisObject()); - SE_PRECONDITION2(ok, false, "js_scene_Shadow_set_shadowType : Error processing new value"); + ok &= sevalue_to_native(args[0], &cobj->shaders, s.thisObject()); + SE_PRECONDITION2(ok, false, "js_scene_DrawBatch2D_set_shaders : Error processing new value"); return true; } -SE_BIND_PROP_SET(js_scene_Shadow_set_shadowType) - -static bool js_scene_Shadow_get_invisibleOcclusionRange(se::State& s) // NOLINT(readability-identifier-naming) -{ - auto* cobj = SE_THIS_OBJECT(s); - SE_PRECONDITION2(cobj, false, "js_scene_Shadow_get_invisibleOcclusionRange : Invalid Native Object"); - - CC_UNUSED bool ok = true; - se::Value jsret; - ok &= nativevalue_to_se(cobj->invisibleOcclusionRange, jsret, s.thisObject() /*ctx*/); - s.rval() = jsret; - SE_HOLD_RETURN_VALUE(cobj->invisibleOcclusionRange, s.thisObject(), s.rval()); - return true; -} -SE_BIND_PROP_GET(js_scene_Shadow_get_invisibleOcclusionRange) - -static bool js_scene_Shadow_set_invisibleOcclusionRange(se::State& s) // NOLINT(readability-identifier-naming) -{ - const auto& args = s.args(); - auto* cobj = SE_THIS_OBJECT(s); - SE_PRECONDITION2(cobj, false, "js_scene_Shadow_set_invisibleOcclusionRange : Invalid Native Object"); - - CC_UNUSED bool ok = true; - ok &= sevalue_to_native(args[0], &cobj->invisibleOcclusionRange, s.thisObject()); - SE_PRECONDITION2(ok, false, "js_scene_Shadow_set_invisibleOcclusionRange : Error processing new value"); - return true; -} -SE_BIND_PROP_SET(js_scene_Shadow_set_invisibleOcclusionRange) - -static bool js_scene_Shadow_get_shadowDistance(se::State& s) // NOLINT(readability-identifier-naming) -{ - auto* cobj = SE_THIS_OBJECT(s); - SE_PRECONDITION2(cobj, false, "js_scene_Shadow_get_shadowDistance : Invalid Native Object"); - - CC_UNUSED bool ok = true; - se::Value jsret; - ok &= nativevalue_to_se(cobj->shadowDistance, jsret, s.thisObject() /*ctx*/); - s.rval() = jsret; - SE_HOLD_RETURN_VALUE(cobj->shadowDistance, s.thisObject(), s.rval()); - return true; -} -SE_BIND_PROP_GET(js_scene_Shadow_get_shadowDistance) - -static bool js_scene_Shadow_set_shadowDistance(se::State& s) // NOLINT(readability-identifier-naming) -{ - const auto& args = s.args(); - auto* cobj = SE_THIS_OBJECT(s); - SE_PRECONDITION2(cobj, false, "js_scene_Shadow_set_shadowDistance : Invalid Native Object"); - - CC_UNUSED bool ok = true; - ok &= sevalue_to_native(args[0], &cobj->shadowDistance, s.thisObject()); - SE_PRECONDITION2(ok, false, "js_scene_Shadow_set_shadowDistance : Error processing new value"); - return true; -} -SE_BIND_PROP_SET(js_scene_Shadow_set_shadowDistance) - -static bool js_scene_Shadow_get_distance(se::State& s) // NOLINT(readability-identifier-naming) -{ - auto* cobj = SE_THIS_OBJECT(s); - SE_PRECONDITION2(cobj, false, "js_scene_Shadow_get_distance : Invalid Native Object"); - - CC_UNUSED bool ok = true; - se::Value jsret; - ok &= nativevalue_to_se(cobj->distance, jsret, s.thisObject() /*ctx*/); - s.rval() = jsret; - SE_HOLD_RETURN_VALUE(cobj->distance, s.thisObject(), s.rval()); - return true; -} -SE_BIND_PROP_GET(js_scene_Shadow_get_distance) - -static bool js_scene_Shadow_set_distance(se::State& s) // NOLINT(readability-identifier-naming) -{ - const auto& args = s.args(); - auto* cobj = SE_THIS_OBJECT(s); - SE_PRECONDITION2(cobj, false, "js_scene_Shadow_set_distance : Invalid Native Object"); - - CC_UNUSED bool ok = true; - ok &= sevalue_to_native(args[0], &cobj->distance, s.thisObject()); - SE_PRECONDITION2(ok, false, "js_scene_Shadow_set_distance : Error processing new value"); - return true; -} -SE_BIND_PROP_SET(js_scene_Shadow_set_distance) - -static bool js_scene_Shadow_get_instancePass(se::State& s) // NOLINT(readability-identifier-naming) -{ - auto* cobj = SE_THIS_OBJECT(s); - SE_PRECONDITION2(cobj, false, "js_scene_Shadow_get_instancePass : Invalid Native Object"); - - CC_UNUSED bool ok = true; - se::Value jsret; - ok &= nativevalue_to_se(cobj->instancePass, jsret, s.thisObject() /*ctx*/); - s.rval() = jsret; - SE_HOLD_RETURN_VALUE(cobj->instancePass, s.thisObject(), s.rval()); - return true; -} -SE_BIND_PROP_GET(js_scene_Shadow_get_instancePass) - -static bool js_scene_Shadow_set_instancePass(se::State& s) // NOLINT(readability-identifier-naming) -{ - const auto& args = s.args(); - auto* cobj = SE_THIS_OBJECT(s); - SE_PRECONDITION2(cobj, false, "js_scene_Shadow_set_instancePass : Invalid Native Object"); - - CC_UNUSED bool ok = true; - ok &= sevalue_to_native(args[0], &cobj->instancePass, s.thisObject()); - SE_PRECONDITION2(ok, false, "js_scene_Shadow_set_instancePass : Error processing new value"); - return true; -} -SE_BIND_PROP_SET(js_scene_Shadow_set_instancePass) - -static bool js_scene_Shadow_get_planarPass(se::State& s) // NOLINT(readability-identifier-naming) -{ - auto* cobj = SE_THIS_OBJECT(s); - SE_PRECONDITION2(cobj, false, "js_scene_Shadow_get_planarPass : Invalid Native Object"); - - CC_UNUSED bool ok = true; - se::Value jsret; - ok &= nativevalue_to_se(cobj->planarPass, jsret, s.thisObject() /*ctx*/); - s.rval() = jsret; - SE_HOLD_RETURN_VALUE(cobj->planarPass, s.thisObject(), s.rval()); - return true; -} -SE_BIND_PROP_GET(js_scene_Shadow_get_planarPass) - -static bool js_scene_Shadow_set_planarPass(se::State& s) // NOLINT(readability-identifier-naming) -{ - const auto& args = s.args(); - auto* cobj = SE_THIS_OBJECT(s); - SE_PRECONDITION2(cobj, false, "js_scene_Shadow_set_planarPass : Invalid Native Object"); - - CC_UNUSED bool ok = true; - ok &= sevalue_to_native(args[0], &cobj->planarPass, s.thisObject()); - SE_PRECONDITION2(ok, false, "js_scene_Shadow_set_planarPass : Error processing new value"); - return true; -} -SE_BIND_PROP_SET(js_scene_Shadow_set_planarPass) - -static bool js_scene_Shadow_get_nearValue(se::State& s) // NOLINT(readability-identifier-naming) -{ - auto* cobj = SE_THIS_OBJECT(s); - SE_PRECONDITION2(cobj, false, "js_scene_Shadow_get_nearValue : Invalid Native Object"); - - CC_UNUSED bool ok = true; - se::Value jsret; - ok &= nativevalue_to_se(cobj->nearValue, jsret, s.thisObject() /*ctx*/); - s.rval() = jsret; - SE_HOLD_RETURN_VALUE(cobj->nearValue, s.thisObject(), s.rval()); - return true; -} -SE_BIND_PROP_GET(js_scene_Shadow_get_nearValue) - -static bool js_scene_Shadow_set_nearValue(se::State& s) // NOLINT(readability-identifier-naming) -{ - const auto& args = s.args(); - auto* cobj = SE_THIS_OBJECT(s); - SE_PRECONDITION2(cobj, false, "js_scene_Shadow_set_nearValue : Invalid Native Object"); - - CC_UNUSED bool ok = true; - ok &= sevalue_to_native(args[0], &cobj->nearValue, s.thisObject()); - SE_PRECONDITION2(ok, false, "js_scene_Shadow_set_nearValue : Error processing new value"); - return true; -} -SE_BIND_PROP_SET(js_scene_Shadow_set_nearValue) - -static bool js_scene_Shadow_get_farValue(se::State& s) // NOLINT(readability-identifier-naming) -{ - auto* cobj = SE_THIS_OBJECT(s); - SE_PRECONDITION2(cobj, false, "js_scene_Shadow_get_farValue : Invalid Native Object"); - - CC_UNUSED bool ok = true; - se::Value jsret; - ok &= nativevalue_to_se(cobj->farValue, jsret, s.thisObject() /*ctx*/); - s.rval() = jsret; - SE_HOLD_RETURN_VALUE(cobj->farValue, s.thisObject(), s.rval()); - return true; -} -SE_BIND_PROP_GET(js_scene_Shadow_get_farValue) - -static bool js_scene_Shadow_set_farValue(se::State& s) // NOLINT(readability-identifier-naming) -{ - const auto& args = s.args(); - auto* cobj = SE_THIS_OBJECT(s); - SE_PRECONDITION2(cobj, false, "js_scene_Shadow_set_farValue : Invalid Native Object"); - - CC_UNUSED bool ok = true; - ok &= sevalue_to_native(args[0], &cobj->farValue, s.thisObject()); - SE_PRECONDITION2(ok, false, "js_scene_Shadow_set_farValue : Error processing new value"); - return true; -} -SE_BIND_PROP_SET(js_scene_Shadow_set_farValue) - -static bool js_scene_Shadow_get_pcfType(se::State& s) // NOLINT(readability-identifier-naming) -{ - auto* cobj = SE_THIS_OBJECT(s); - SE_PRECONDITION2(cobj, false, "js_scene_Shadow_get_pcfType : Invalid Native Object"); - - CC_UNUSED bool ok = true; - se::Value jsret; - ok &= nativevalue_to_se(cobj->pcfType, jsret, s.thisObject() /*ctx*/); - s.rval() = jsret; - SE_HOLD_RETURN_VALUE(cobj->pcfType, s.thisObject(), s.rval()); - return true; -} -SE_BIND_PROP_GET(js_scene_Shadow_get_pcfType) - -static bool js_scene_Shadow_set_pcfType(se::State& s) // NOLINT(readability-identifier-naming) -{ - const auto& args = s.args(); - auto* cobj = SE_THIS_OBJECT(s); - SE_PRECONDITION2(cobj, false, "js_scene_Shadow_set_pcfType : Invalid Native Object"); - - CC_UNUSED bool ok = true; - ok &= sevalue_to_native(args[0], &cobj->pcfType, s.thisObject()); - SE_PRECONDITION2(ok, false, "js_scene_Shadow_set_pcfType : Error processing new value"); - return true; -} -SE_BIND_PROP_SET(js_scene_Shadow_set_pcfType) - -static bool js_scene_Shadow_get_bias(se::State& s) // NOLINT(readability-identifier-naming) -{ - auto* cobj = SE_THIS_OBJECT(s); - SE_PRECONDITION2(cobj, false, "js_scene_Shadow_get_bias : Invalid Native Object"); - - CC_UNUSED bool ok = true; - se::Value jsret; - ok &= nativevalue_to_se(cobj->bias, jsret, s.thisObject() /*ctx*/); - s.rval() = jsret; - SE_HOLD_RETURN_VALUE(cobj->bias, s.thisObject(), s.rval()); - return true; -} -SE_BIND_PROP_GET(js_scene_Shadow_get_bias) - -static bool js_scene_Shadow_set_bias(se::State& s) // NOLINT(readability-identifier-naming) -{ - const auto& args = s.args(); - auto* cobj = SE_THIS_OBJECT(s); - SE_PRECONDITION2(cobj, false, "js_scene_Shadow_set_bias : Invalid Native Object"); - - CC_UNUSED bool ok = true; - ok &= sevalue_to_native(args[0], &cobj->bias, s.thisObject()); - SE_PRECONDITION2(ok, false, "js_scene_Shadow_set_bias : Error processing new value"); - return true; -} -SE_BIND_PROP_SET(js_scene_Shadow_set_bias) - -static bool js_scene_Shadow_get_normalBias(se::State& s) // NOLINT(readability-identifier-naming) -{ - auto* cobj = SE_THIS_OBJECT(s); - SE_PRECONDITION2(cobj, false, "js_scene_Shadow_get_normalBias : Invalid Native Object"); - - CC_UNUSED bool ok = true; - se::Value jsret; - ok &= nativevalue_to_se(cobj->normalBias, jsret, s.thisObject() /*ctx*/); - s.rval() = jsret; - SE_HOLD_RETURN_VALUE(cobj->normalBias, s.thisObject(), s.rval()); - return true; -} -SE_BIND_PROP_GET(js_scene_Shadow_get_normalBias) - -static bool js_scene_Shadow_set_normalBias(se::State& s) // NOLINT(readability-identifier-naming) -{ - const auto& args = s.args(); - auto* cobj = SE_THIS_OBJECT(s); - SE_PRECONDITION2(cobj, false, "js_scene_Shadow_set_normalBias : Invalid Native Object"); - - CC_UNUSED bool ok = true; - ok &= sevalue_to_native(args[0], &cobj->normalBias, s.thisObject()); - SE_PRECONDITION2(ok, false, "js_scene_Shadow_set_normalBias : Error processing new value"); - return true; -} -SE_BIND_PROP_SET(js_scene_Shadow_set_normalBias) - -static bool js_scene_Shadow_get_saturation(se::State& s) // NOLINT(readability-identifier-naming) -{ - auto* cobj = SE_THIS_OBJECT(s); - SE_PRECONDITION2(cobj, false, "js_scene_Shadow_get_saturation : Invalid Native Object"); - - CC_UNUSED bool ok = true; - se::Value jsret; - ok &= nativevalue_to_se(cobj->saturation, jsret, s.thisObject() /*ctx*/); - s.rval() = jsret; - SE_HOLD_RETURN_VALUE(cobj->saturation, s.thisObject(), s.rval()); - return true; -} -SE_BIND_PROP_GET(js_scene_Shadow_get_saturation) - -static bool js_scene_Shadow_set_saturation(se::State& s) // NOLINT(readability-identifier-naming) -{ - const auto& args = s.args(); - auto* cobj = SE_THIS_OBJECT(s); - SE_PRECONDITION2(cobj, false, "js_scene_Shadow_set_saturation : Invalid Native Object"); - - CC_UNUSED bool ok = true; - ok &= sevalue_to_native(args[0], &cobj->saturation, s.thisObject()); - SE_PRECONDITION2(ok, false, "js_scene_Shadow_set_saturation : Error processing new value"); - return true; -} -SE_BIND_PROP_SET(js_scene_Shadow_set_saturation) - -static bool js_scene_Shadow_get_orthoSize(se::State& s) // NOLINT(readability-identifier-naming) -{ - auto* cobj = SE_THIS_OBJECT(s); - SE_PRECONDITION2(cobj, false, "js_scene_Shadow_get_orthoSize : Invalid Native Object"); - - CC_UNUSED bool ok = true; - se::Value jsret; - ok &= nativevalue_to_se(cobj->orthoSize, jsret, s.thisObject() /*ctx*/); - s.rval() = jsret; - SE_HOLD_RETURN_VALUE(cobj->orthoSize, s.thisObject(), s.rval()); - return true; -} -SE_BIND_PROP_GET(js_scene_Shadow_get_orthoSize) - -static bool js_scene_Shadow_set_orthoSize(se::State& s) // NOLINT(readability-identifier-naming) -{ - const auto& args = s.args(); - auto* cobj = SE_THIS_OBJECT(s); - SE_PRECONDITION2(cobj, false, "js_scene_Shadow_set_orthoSize : Invalid Native Object"); - - CC_UNUSED bool ok = true; - ok &= sevalue_to_native(args[0], &cobj->orthoSize, s.thisObject()); - SE_PRECONDITION2(ok, false, "js_scene_Shadow_set_orthoSize : Error processing new value"); - return true; -} -SE_BIND_PROP_SET(js_scene_Shadow_set_orthoSize) - -static bool js_scene_Shadow_get_color(se::State& s) // NOLINT(readability-identifier-naming) -{ - auto* cobj = SE_THIS_OBJECT(s); - SE_PRECONDITION2(cobj, false, "js_scene_Shadow_get_color : Invalid Native Object"); - - CC_UNUSED bool ok = true; - se::Value jsret; - ok &= nativevalue_to_se(cobj->color, jsret, s.thisObject() /*ctx*/); - s.rval() = jsret; - SE_HOLD_RETURN_VALUE(cobj->color, s.thisObject(), s.rval()); - return true; -} -SE_BIND_PROP_GET(js_scene_Shadow_get_color) - -static bool js_scene_Shadow_set_color(se::State& s) // NOLINT(readability-identifier-naming) -{ - const auto& args = s.args(); - auto* cobj = SE_THIS_OBJECT(s); - SE_PRECONDITION2(cobj, false, "js_scene_Shadow_set_color : Invalid Native Object"); - - CC_UNUSED bool ok = true; - ok &= sevalue_to_native(args[0], &cobj->color, s.thisObject()); - SE_PRECONDITION2(ok, false, "js_scene_Shadow_set_color : Error processing new value"); - return true; -} -SE_BIND_PROP_SET(js_scene_Shadow_set_color) - -static bool js_scene_Shadow_get_size(se::State& s) // NOLINT(readability-identifier-naming) -{ - auto* cobj = SE_THIS_OBJECT(s); - SE_PRECONDITION2(cobj, false, "js_scene_Shadow_get_size : Invalid Native Object"); - - CC_UNUSED bool ok = true; - se::Value jsret; - ok &= nativevalue_to_se(cobj->size, jsret, s.thisObject() /*ctx*/); - s.rval() = jsret; - SE_HOLD_RETURN_VALUE(cobj->size, s.thisObject(), s.rval()); - return true; -} -SE_BIND_PROP_GET(js_scene_Shadow_get_size) - -static bool js_scene_Shadow_set_size(se::State& s) // NOLINT(readability-identifier-naming) -{ - const auto& args = s.args(); - auto* cobj = SE_THIS_OBJECT(s); - SE_PRECONDITION2(cobj, false, "js_scene_Shadow_set_size : Invalid Native Object"); - - CC_UNUSED bool ok = true; - ok &= sevalue_to_native(args[0], &cobj->size, s.thisObject()); - SE_PRECONDITION2(ok, false, "js_scene_Shadow_set_size : Error processing new value"); - return true; -} -SE_BIND_PROP_SET(js_scene_Shadow_set_size) - -static bool js_scene_Shadow_get_normal(se::State& s) // NOLINT(readability-identifier-naming) -{ - auto* cobj = SE_THIS_OBJECT(s); - SE_PRECONDITION2(cobj, false, "js_scene_Shadow_get_normal : Invalid Native Object"); - - CC_UNUSED bool ok = true; - se::Value jsret; - ok &= nativevalue_to_se(cobj->normal, jsret, s.thisObject() /*ctx*/); - s.rval() = jsret; - SE_HOLD_RETURN_VALUE(cobj->normal, s.thisObject(), s.rval()); - return true; -} -SE_BIND_PROP_GET(js_scene_Shadow_get_normal) - -static bool js_scene_Shadow_set_normal(se::State& s) // NOLINT(readability-identifier-naming) -{ - const auto& args = s.args(); - auto* cobj = SE_THIS_OBJECT(s); - SE_PRECONDITION2(cobj, false, "js_scene_Shadow_set_normal : Invalid Native Object"); - - CC_UNUSED bool ok = true; - ok &= sevalue_to_native(args[0], &cobj->normal, s.thisObject()); - SE_PRECONDITION2(ok, false, "js_scene_Shadow_set_normal : Error processing new value"); - return true; -} -SE_BIND_PROP_SET(js_scene_Shadow_set_normal) - -static bool js_scene_Shadow_get_matLight(se::State& s) // NOLINT(readability-identifier-naming) -{ - auto* cobj = SE_THIS_OBJECT(s); - SE_PRECONDITION2(cobj, false, "js_scene_Shadow_get_matLight : Invalid Native Object"); - - CC_UNUSED bool ok = true; - se::Value jsret; - ok &= nativevalue_to_se(cobj->matLight, jsret, s.thisObject() /*ctx*/); - s.rval() = jsret; - SE_HOLD_RETURN_VALUE(cobj->matLight, s.thisObject(), s.rval()); - return true; -} -SE_BIND_PROP_GET(js_scene_Shadow_get_matLight) - -static bool js_scene_Shadow_set_matLight(se::State& s) // NOLINT(readability-identifier-naming) -{ - const auto& args = s.args(); - auto* cobj = SE_THIS_OBJECT(s); - SE_PRECONDITION2(cobj, false, "js_scene_Shadow_set_matLight : Invalid Native Object"); - - CC_UNUSED bool ok = true; - ok &= sevalue_to_native(args[0], &cobj->matLight, s.thisObject()); - SE_PRECONDITION2(ok, false, "js_scene_Shadow_set_matLight : Error processing new value"); - return true; -} -SE_BIND_PROP_SET(js_scene_Shadow_set_matLight) - - -template<> -bool sevalue_to_native(const se::Value &from, cc::scene::Shadow * to, se::Object *ctx) -{ - assert(from.isObject()); - se::Object *json = from.toObject(); - auto* data = reinterpret_cast(json->getPrivateData()); - if (data) { - *to = *data; - return true; - } - se::Value field; - bool ok = true; - json->getProperty("enabled", &field); - if(!field.isNullOrUndefined()) { - ok &= sevalue_to_native(field, &(to->enabled), ctx); - } - json->getProperty("dirty", &field); - if(!field.isNullOrUndefined()) { - ok &= sevalue_to_native(field, &(to->dirty), ctx); - } - json->getProperty("shadowMapDirty", &field); - if(!field.isNullOrUndefined()) { - ok &= sevalue_to_native(field, &(to->shadowMapDirty), ctx); - } - json->getProperty("fixedArea", &field); - if(!field.isNullOrUndefined()) { - ok &= sevalue_to_native(field, &(to->fixedArea), ctx); - } - json->getProperty("shadowType", &field); - if(!field.isNullOrUndefined()) { - ok &= sevalue_to_native(field, &(to->shadowType), ctx); - } - json->getProperty("invisibleOcclusionRange", &field); - if(!field.isNullOrUndefined()) { - ok &= sevalue_to_native(field, &(to->invisibleOcclusionRange), ctx); - } - json->getProperty("shadowDistance", &field); - if(!field.isNullOrUndefined()) { - ok &= sevalue_to_native(field, &(to->shadowDistance), ctx); - } - json->getProperty("distance", &field); - if(!field.isNullOrUndefined()) { - ok &= sevalue_to_native(field, &(to->distance), ctx); - } - json->getProperty("instancePass", &field); - if(!field.isNullOrUndefined()) { - ok &= sevalue_to_native(field, &(to->instancePass), ctx); - } - json->getProperty("planarPass", &field); - if(!field.isNullOrUndefined()) { - ok &= sevalue_to_native(field, &(to->planarPass), ctx); - } - json->getProperty("nearValue", &field); - if(!field.isNullOrUndefined()) { - ok &= sevalue_to_native(field, &(to->nearValue), ctx); - } - json->getProperty("farValue", &field); - if(!field.isNullOrUndefined()) { - ok &= sevalue_to_native(field, &(to->farValue), ctx); - } - json->getProperty("pcfType", &field); - if(!field.isNullOrUndefined()) { - ok &= sevalue_to_native(field, &(to->pcfType), ctx); - } - json->getProperty("bias", &field); - if(!field.isNullOrUndefined()) { - ok &= sevalue_to_native(field, &(to->bias), ctx); - } - json->getProperty("normalBias", &field); - if(!field.isNullOrUndefined()) { - ok &= sevalue_to_native(field, &(to->normalBias), ctx); - } - json->getProperty("saturation", &field); - if(!field.isNullOrUndefined()) { - ok &= sevalue_to_native(field, &(to->saturation), ctx); - } - json->getProperty("orthoSize", &field); - if(!field.isNullOrUndefined()) { - ok &= sevalue_to_native(field, &(to->orthoSize), ctx); - } - json->getProperty("color", &field); - if(!field.isNullOrUndefined()) { - ok &= sevalue_to_native(field, &(to->color), ctx); - } - json->getProperty("size", &field); - if(!field.isNullOrUndefined()) { - ok &= sevalue_to_native(field, &(to->size), ctx); - } - json->getProperty("normal", &field); - if(!field.isNullOrUndefined()) { - ok &= sevalue_to_native(field, &(to->normal), ctx); - } - json->getProperty("matLight", &field); - if(!field.isNullOrUndefined()) { - ok &= sevalue_to_native(field, &(to->matLight), ctx); - } - return ok; -} - -SE_DECLARE_FINALIZE_FUNC(js_cc_scene_Shadow_finalize) - -static bool js_scene_Shadow_constructor(se::State& s) // NOLINT(readability-identifier-naming) -{ - CC_UNUSED bool ok = true; - const auto& args = s.args(); - size_t argc = args.size(); - - if(argc == 0) - { - cc::scene::Shadow* cobj = JSB_ALLOC(cc::scene::Shadow); - s.thisObject()->setPrivateData(cobj); - se::NonRefNativePtrCreatedByCtorMap::emplace(cobj); - return true; - } - - if(argc == 1 && args[0].isObject()) - { - se::Object *json = args[0].toObject(); - se::Value field; - - cc::scene::Shadow* cobj = JSB_ALLOC(cc::scene::Shadow); - ok &= sevalue_to_native(args[0], cobj, s.thisObject()); - if(!ok) { - JSB_FREE(cobj); - SE_REPORT_ERROR("argument convertion error"); - return false; - } - - s.thisObject()->setPrivateData(cobj); - se::NonRefNativePtrCreatedByCtorMap::emplace(cobj); - return true; - } - - cc::scene::Shadow* cobj = JSB_ALLOC(cc::scene::Shadow); - if (argc > 0 && !args[0].isUndefined()) { - ok &= sevalue_to_native(args[0], &(cobj->enabled), nullptr); - } - if (argc > 1 && !args[1].isUndefined()) { - ok &= sevalue_to_native(args[1], &(cobj->dirty), nullptr); - } - if (argc > 2 && !args[2].isUndefined()) { - ok &= sevalue_to_native(args[2], &(cobj->shadowMapDirty), nullptr); - } - if (argc > 3 && !args[3].isUndefined()) { - ok &= sevalue_to_native(args[3], &(cobj->fixedArea), nullptr); - } - if (argc > 4 && !args[4].isUndefined()) { - ok &= sevalue_to_native(args[4], &(cobj->shadowType), nullptr); - } - if (argc > 5 && !args[5].isUndefined()) { - ok &= sevalue_to_native(args[5], &(cobj->invisibleOcclusionRange), nullptr); - } - if (argc > 6 && !args[6].isUndefined()) { - ok &= sevalue_to_native(args[6], &(cobj->shadowDistance), nullptr); - } - if (argc > 7 && !args[7].isUndefined()) { - ok &= sevalue_to_native(args[7], &(cobj->distance), nullptr); - } - if (argc > 8 && !args[8].isUndefined()) { - ok &= sevalue_to_native(args[8], &(cobj->instancePass), nullptr); - } - if (argc > 9 && !args[9].isUndefined()) { - ok &= sevalue_to_native(args[9], &(cobj->planarPass), nullptr); - } - if (argc > 10 && !args[10].isUndefined()) { - ok &= sevalue_to_native(args[10], &(cobj->nearValue), nullptr); - } - if (argc > 11 && !args[11].isUndefined()) { - ok &= sevalue_to_native(args[11], &(cobj->farValue), nullptr); - } - if (argc > 12 && !args[12].isUndefined()) { - ok &= sevalue_to_native(args[12], &(cobj->pcfType), nullptr); - } - if (argc > 13 && !args[13].isUndefined()) { - ok &= sevalue_to_native(args[13], &(cobj->bias), nullptr); - } - if (argc > 14 && !args[14].isUndefined()) { - ok &= sevalue_to_native(args[14], &(cobj->normalBias), nullptr); - } - if (argc > 15 && !args[15].isUndefined()) { - ok &= sevalue_to_native(args[15], &(cobj->saturation), nullptr); - } - if (argc > 16 && !args[16].isUndefined()) { - ok &= sevalue_to_native(args[16], &(cobj->orthoSize), nullptr); - } - if (argc > 17 && !args[17].isUndefined()) { - ok &= sevalue_to_native(args[17], &(cobj->color), nullptr); - } - if (argc > 18 && !args[18].isUndefined()) { - ok &= sevalue_to_native(args[18], &(cobj->size), nullptr); - } - if (argc > 19 && !args[19].isUndefined()) { - ok &= sevalue_to_native(args[19], &(cobj->normal), nullptr); - } - if (argc > 20 && !args[20].isUndefined()) { - ok &= sevalue_to_native(args[20], &(cobj->matLight), nullptr); - } - - if(!ok) { - JSB_FREE(cobj); - SE_REPORT_ERROR("Argument convertion error"); - return false; - } - - s.thisObject()->setPrivateData(cobj); - se::NonRefNativePtrCreatedByCtorMap::emplace(cobj); - return true; -} -SE_BIND_CTOR(js_scene_Shadow_constructor, __jsb_cc_scene_Shadow_class, js_cc_scene_Shadow_finalize) - - - -static bool js_cc_scene_Shadow_finalize(se::State& s) // NOLINT(readability-identifier-naming) -{ - auto iter = se::NonRefNativePtrCreatedByCtorMap::find(SE_THIS_OBJECT(s)); - if (iter != se::NonRefNativePtrCreatedByCtorMap::end()) - { - se::NonRefNativePtrCreatedByCtorMap::erase(iter); - auto* cobj = SE_THIS_OBJECT(s); - JSB_FREE(cobj); - } - return true; -} -SE_BIND_FINALIZE_FUNC(js_cc_scene_Shadow_finalize) - -bool js_register_scene_Shadow(se::Object* obj) // NOLINT(readability-identifier-naming) -{ - auto* cls = se::Class::create("Shadow", obj, nullptr, _SE(js_scene_Shadow_constructor)); - - cls->defineProperty("enabled", _SE(js_scene_Shadow_get_enabled), _SE(js_scene_Shadow_set_enabled)); - cls->defineProperty("dirty", _SE(js_scene_Shadow_get_dirty), _SE(js_scene_Shadow_set_dirty)); - cls->defineProperty("shadowMapDirty", _SE(js_scene_Shadow_get_shadowMapDirty), _SE(js_scene_Shadow_set_shadowMapDirty)); - cls->defineProperty("fixedArea", _SE(js_scene_Shadow_get_fixedArea), _SE(js_scene_Shadow_set_fixedArea)); - cls->defineProperty("shadowType", _SE(js_scene_Shadow_get_shadowType), _SE(js_scene_Shadow_set_shadowType)); - cls->defineProperty("invisibleOcclusionRange", _SE(js_scene_Shadow_get_invisibleOcclusionRange), _SE(js_scene_Shadow_set_invisibleOcclusionRange)); - cls->defineProperty("shadowDistance", _SE(js_scene_Shadow_get_shadowDistance), _SE(js_scene_Shadow_set_shadowDistance)); - cls->defineProperty("distance", _SE(js_scene_Shadow_get_distance), _SE(js_scene_Shadow_set_distance)); - cls->defineProperty("instancePass", _SE(js_scene_Shadow_get_instancePass), _SE(js_scene_Shadow_set_instancePass)); - cls->defineProperty("planarPass", _SE(js_scene_Shadow_get_planarPass), _SE(js_scene_Shadow_set_planarPass)); - cls->defineProperty("nearValue", _SE(js_scene_Shadow_get_nearValue), _SE(js_scene_Shadow_set_nearValue)); - cls->defineProperty("farValue", _SE(js_scene_Shadow_get_farValue), _SE(js_scene_Shadow_set_farValue)); - cls->defineProperty("pcfType", _SE(js_scene_Shadow_get_pcfType), _SE(js_scene_Shadow_set_pcfType)); - cls->defineProperty("bias", _SE(js_scene_Shadow_get_bias), _SE(js_scene_Shadow_set_bias)); - cls->defineProperty("normalBias", _SE(js_scene_Shadow_get_normalBias), _SE(js_scene_Shadow_set_normalBias)); - cls->defineProperty("saturation", _SE(js_scene_Shadow_get_saturation), _SE(js_scene_Shadow_set_saturation)); - cls->defineProperty("orthoSize", _SE(js_scene_Shadow_get_orthoSize), _SE(js_scene_Shadow_set_orthoSize)); - cls->defineProperty("color", _SE(js_scene_Shadow_get_color), _SE(js_scene_Shadow_set_color)); - cls->defineProperty("size", _SE(js_scene_Shadow_get_size), _SE(js_scene_Shadow_set_size)); - cls->defineProperty("normal", _SE(js_scene_Shadow_get_normal), _SE(js_scene_Shadow_set_normal)); - cls->defineProperty("matLight", _SE(js_scene_Shadow_get_matLight), _SE(js_scene_Shadow_set_matLight)); - cls->defineFinalizeFunction(_SE(js_cc_scene_Shadow_finalize)); - cls->install(); - JSBClassType::registerClass(cls); - - __jsb_cc_scene_Shadow_proto = cls->getProto(); - __jsb_cc_scene_Shadow_class = cls; - - se::ScriptEngine::getInstance()->clearException(); - return true; -} -se::Object* __jsb_cc_scene_Skybox_proto = nullptr; -se::Class* __jsb_cc_scene_Skybox_class = nullptr; - -static bool js_scene_Skybox_get_enabled(se::State& s) // NOLINT(readability-identifier-naming) -{ - auto* cobj = SE_THIS_OBJECT(s); - SE_PRECONDITION2(cobj, false, "js_scene_Skybox_get_enabled : Invalid Native Object"); - - CC_UNUSED bool ok = true; - se::Value jsret; - ok &= nativevalue_to_se(cobj->enabled, jsret, s.thisObject() /*ctx*/); - s.rval() = jsret; - SE_HOLD_RETURN_VALUE(cobj->enabled, s.thisObject(), s.rval()); - return true; -} -SE_BIND_PROP_GET(js_scene_Skybox_get_enabled) - -static bool js_scene_Skybox_set_enabled(se::State& s) // NOLINT(readability-identifier-naming) -{ - const auto& args = s.args(); - auto* cobj = SE_THIS_OBJECT(s); - SE_PRECONDITION2(cobj, false, "js_scene_Skybox_set_enabled : Invalid Native Object"); - - CC_UNUSED bool ok = true; - ok &= sevalue_to_native(args[0], &cobj->enabled, s.thisObject()); - SE_PRECONDITION2(ok, false, "js_scene_Skybox_set_enabled : Error processing new value"); - return true; -} -SE_BIND_PROP_SET(js_scene_Skybox_set_enabled) - -static bool js_scene_Skybox_get_isRGBE(se::State& s) // NOLINT(readability-identifier-naming) -{ - auto* cobj = SE_THIS_OBJECT(s); - SE_PRECONDITION2(cobj, false, "js_scene_Skybox_get_isRGBE : Invalid Native Object"); - - CC_UNUSED bool ok = true; - se::Value jsret; - ok &= nativevalue_to_se(cobj->isRGBE, jsret, s.thisObject() /*ctx*/); - s.rval() = jsret; - SE_HOLD_RETURN_VALUE(cobj->isRGBE, s.thisObject(), s.rval()); - return true; -} -SE_BIND_PROP_GET(js_scene_Skybox_get_isRGBE) - -static bool js_scene_Skybox_set_isRGBE(se::State& s) // NOLINT(readability-identifier-naming) -{ - const auto& args = s.args(); - auto* cobj = SE_THIS_OBJECT(s); - SE_PRECONDITION2(cobj, false, "js_scene_Skybox_set_isRGBE : Invalid Native Object"); - - CC_UNUSED bool ok = true; - ok &= sevalue_to_native(args[0], &cobj->isRGBE, s.thisObject()); - SE_PRECONDITION2(ok, false, "js_scene_Skybox_set_isRGBE : Error processing new value"); - return true; -} -SE_BIND_PROP_SET(js_scene_Skybox_set_isRGBE) - -static bool js_scene_Skybox_get_useIBL(se::State& s) // NOLINT(readability-identifier-naming) -{ - auto* cobj = SE_THIS_OBJECT(s); - SE_PRECONDITION2(cobj, false, "js_scene_Skybox_get_useIBL : Invalid Native Object"); - - CC_UNUSED bool ok = true; - se::Value jsret; - ok &= nativevalue_to_se(cobj->useIBL, jsret, s.thisObject() /*ctx*/); - s.rval() = jsret; - SE_HOLD_RETURN_VALUE(cobj->useIBL, s.thisObject(), s.rval()); - return true; -} -SE_BIND_PROP_GET(js_scene_Skybox_get_useIBL) - -static bool js_scene_Skybox_set_useIBL(se::State& s) // NOLINT(readability-identifier-naming) -{ - const auto& args = s.args(); - auto* cobj = SE_THIS_OBJECT(s); - SE_PRECONDITION2(cobj, false, "js_scene_Skybox_set_useIBL : Invalid Native Object"); - - CC_UNUSED bool ok = true; - ok &= sevalue_to_native(args[0], &cobj->useIBL, s.thisObject()); - SE_PRECONDITION2(ok, false, "js_scene_Skybox_set_useIBL : Error processing new value"); - return true; -} -SE_BIND_PROP_SET(js_scene_Skybox_set_useIBL) - -static bool js_scene_Skybox_get_useHDR(se::State& s) // NOLINT(readability-identifier-naming) -{ - auto* cobj = SE_THIS_OBJECT(s); - SE_PRECONDITION2(cobj, false, "js_scene_Skybox_get_useHDR : Invalid Native Object"); - - CC_UNUSED bool ok = true; - se::Value jsret; - ok &= nativevalue_to_se(cobj->useHDR, jsret, s.thisObject() /*ctx*/); - s.rval() = jsret; - SE_HOLD_RETURN_VALUE(cobj->useHDR, s.thisObject(), s.rval()); - return true; -} -SE_BIND_PROP_GET(js_scene_Skybox_get_useHDR) - -static bool js_scene_Skybox_set_useHDR(se::State& s) // NOLINT(readability-identifier-naming) -{ - const auto& args = s.args(); - auto* cobj = SE_THIS_OBJECT(s); - SE_PRECONDITION2(cobj, false, "js_scene_Skybox_set_useHDR : Invalid Native Object"); - - CC_UNUSED bool ok = true; - ok &= sevalue_to_native(args[0], &cobj->useHDR, s.thisObject()); - SE_PRECONDITION2(ok, false, "js_scene_Skybox_set_useHDR : Error processing new value"); - return true; -} -SE_BIND_PROP_SET(js_scene_Skybox_set_useHDR) - -static bool js_scene_Skybox_get_useDiffuseMap(se::State& s) // NOLINT(readability-identifier-naming) -{ - auto* cobj = SE_THIS_OBJECT(s); - SE_PRECONDITION2(cobj, false, "js_scene_Skybox_get_useDiffuseMap : Invalid Native Object"); - - CC_UNUSED bool ok = true; - se::Value jsret; - ok &= nativevalue_to_se(cobj->useDiffuseMap, jsret, s.thisObject() /*ctx*/); - s.rval() = jsret; - SE_HOLD_RETURN_VALUE(cobj->useDiffuseMap, s.thisObject(), s.rval()); - return true; -} -SE_BIND_PROP_GET(js_scene_Skybox_get_useDiffuseMap) - -static bool js_scene_Skybox_set_useDiffuseMap(se::State& s) // NOLINT(readability-identifier-naming) -{ - const auto& args = s.args(); - auto* cobj = SE_THIS_OBJECT(s); - SE_PRECONDITION2(cobj, false, "js_scene_Skybox_set_useDiffuseMap : Invalid Native Object"); - - CC_UNUSED bool ok = true; - ok &= sevalue_to_native(args[0], &cobj->useDiffuseMap, s.thisObject()); - SE_PRECONDITION2(ok, false, "js_scene_Skybox_set_useDiffuseMap : Error processing new value"); - return true; -} -SE_BIND_PROP_SET(js_scene_Skybox_set_useDiffuseMap) - -static bool js_scene_Skybox_get_model(se::State& s) // NOLINT(readability-identifier-naming) -{ - auto* cobj = SE_THIS_OBJECT(s); - SE_PRECONDITION2(cobj, false, "js_scene_Skybox_get_model : Invalid Native Object"); - - CC_UNUSED bool ok = true; - se::Value jsret; - ok &= nativevalue_to_se(cobj->model, jsret, s.thisObject() /*ctx*/); - s.rval() = jsret; - SE_HOLD_RETURN_VALUE(cobj->model, s.thisObject(), s.rval()); - return true; -} -SE_BIND_PROP_GET(js_scene_Skybox_get_model) - -static bool js_scene_Skybox_set_model(se::State& s) // NOLINT(readability-identifier-naming) -{ - const auto& args = s.args(); - auto* cobj = SE_THIS_OBJECT(s); - SE_PRECONDITION2(cobj, false, "js_scene_Skybox_set_model : Invalid Native Object"); - - CC_UNUSED bool ok = true; - ok &= sevalue_to_native(args[0], &cobj->model, s.thisObject()); - SE_PRECONDITION2(ok, false, "js_scene_Skybox_set_model : Error processing new value"); - return true; -} -SE_BIND_PROP_SET(js_scene_Skybox_set_model) - - -template<> -bool sevalue_to_native(const se::Value &from, cc::scene::Skybox * to, se::Object *ctx) -{ - assert(from.isObject()); - se::Object *json = from.toObject(); - auto* data = reinterpret_cast(json->getPrivateData()); - if (data) { - *to = *data; - return true; - } - se::Value field; - bool ok = true; - json->getProperty("enabled", &field); - if(!field.isNullOrUndefined()) { - ok &= sevalue_to_native(field, &(to->enabled), ctx); - } - json->getProperty("isRGBE", &field); - if(!field.isNullOrUndefined()) { - ok &= sevalue_to_native(field, &(to->isRGBE), ctx); - } - json->getProperty("useIBL", &field); - if(!field.isNullOrUndefined()) { - ok &= sevalue_to_native(field, &(to->useIBL), ctx); - } - json->getProperty("useHDR", &field); - if(!field.isNullOrUndefined()) { - ok &= sevalue_to_native(field, &(to->useHDR), ctx); - } - json->getProperty("useDiffuseMap", &field); - if(!field.isNullOrUndefined()) { - ok &= sevalue_to_native(field, &(to->useDiffuseMap), ctx); - } - json->getProperty("model", &field); - if(!field.isNullOrUndefined()) { - ok &= sevalue_to_native(field, &(to->model), ctx); - } - return ok; -} - -SE_DECLARE_FINALIZE_FUNC(js_cc_scene_Skybox_finalize) - -static bool js_scene_Skybox_constructor(se::State& s) // NOLINT(readability-identifier-naming) -{ - CC_UNUSED bool ok = true; - const auto& args = s.args(); - size_t argc = args.size(); - - if(argc == 0) - { - cc::scene::Skybox* cobj = JSB_ALLOC(cc::scene::Skybox); - s.thisObject()->setPrivateData(cobj); - se::NonRefNativePtrCreatedByCtorMap::emplace(cobj); - return true; - } - - if(argc == 1 && args[0].isObject()) - { - se::Object *json = args[0].toObject(); - se::Value field; - - cc::scene::Skybox* cobj = JSB_ALLOC(cc::scene::Skybox); - ok &= sevalue_to_native(args[0], cobj, s.thisObject()); - if(!ok) { - JSB_FREE(cobj); - SE_REPORT_ERROR("argument convertion error"); - return false; - } - - s.thisObject()->setPrivateData(cobj); - se::NonRefNativePtrCreatedByCtorMap::emplace(cobj); - return true; - } - - cc::scene::Skybox* cobj = JSB_ALLOC(cc::scene::Skybox); - if (argc > 0 && !args[0].isUndefined()) { - ok &= sevalue_to_native(args[0], &(cobj->enabled), nullptr); - } - if (argc > 1 && !args[1].isUndefined()) { - ok &= sevalue_to_native(args[1], &(cobj->isRGBE), nullptr); - } - if (argc > 2 && !args[2].isUndefined()) { - ok &= sevalue_to_native(args[2], &(cobj->useIBL), nullptr); - } - if (argc > 3 && !args[3].isUndefined()) { - ok &= sevalue_to_native(args[3], &(cobj->useHDR), nullptr); - } - if (argc > 4 && !args[4].isUndefined()) { - ok &= sevalue_to_native(args[4], &(cobj->useDiffuseMap), nullptr); - } - if (argc > 5 && !args[5].isUndefined()) { - ok &= sevalue_to_native(args[5], &(cobj->model), nullptr); - } - - if(!ok) { - JSB_FREE(cobj); - SE_REPORT_ERROR("Argument convertion error"); - return false; - } - - s.thisObject()->setPrivateData(cobj); - se::NonRefNativePtrCreatedByCtorMap::emplace(cobj); - return true; -} -SE_BIND_CTOR(js_scene_Skybox_constructor, __jsb_cc_scene_Skybox_class, js_cc_scene_Skybox_finalize) - - - -static bool js_cc_scene_Skybox_finalize(se::State& s) // NOLINT(readability-identifier-naming) -{ - auto iter = se::NonRefNativePtrCreatedByCtorMap::find(SE_THIS_OBJECT(s)); - if (iter != se::NonRefNativePtrCreatedByCtorMap::end()) - { - se::NonRefNativePtrCreatedByCtorMap::erase(iter); - auto* cobj = SE_THIS_OBJECT(s); - JSB_FREE(cobj); - } - return true; -} -SE_BIND_FINALIZE_FUNC(js_cc_scene_Skybox_finalize) - -bool js_register_scene_Skybox(se::Object* obj) // NOLINT(readability-identifier-naming) -{ - auto* cls = se::Class::create("Skybox", obj, nullptr, _SE(js_scene_Skybox_constructor)); - - cls->defineProperty("enabled", _SE(js_scene_Skybox_get_enabled), _SE(js_scene_Skybox_set_enabled)); - cls->defineProperty("isRGBE", _SE(js_scene_Skybox_get_isRGBE), _SE(js_scene_Skybox_set_isRGBE)); - cls->defineProperty("useIBL", _SE(js_scene_Skybox_get_useIBL), _SE(js_scene_Skybox_set_useIBL)); - cls->defineProperty("useHDR", _SE(js_scene_Skybox_get_useHDR), _SE(js_scene_Skybox_set_useHDR)); - cls->defineProperty("useDiffuseMap", _SE(js_scene_Skybox_get_useDiffuseMap), _SE(js_scene_Skybox_set_useDiffuseMap)); - cls->defineProperty("model", _SE(js_scene_Skybox_get_model), _SE(js_scene_Skybox_set_model)); - cls->defineFinalizeFunction(_SE(js_cc_scene_Skybox_finalize)); - cls->install(); - JSBClassType::registerClass(cls); - - __jsb_cc_scene_Skybox_proto = cls->getProto(); - __jsb_cc_scene_Skybox_class = cls; - - se::ScriptEngine::getInstance()->clearException(); - return true; -} -se::Object* __jsb_cc_scene_Ambient_proto = nullptr; -se::Class* __jsb_cc_scene_Ambient_class = nullptr; - -static bool js_scene_Ambient_get_enabled(se::State& s) // NOLINT(readability-identifier-naming) -{ - auto* cobj = SE_THIS_OBJECT(s); - SE_PRECONDITION2(cobj, false, "js_scene_Ambient_get_enabled : Invalid Native Object"); - - CC_UNUSED bool ok = true; - se::Value jsret; - ok &= nativevalue_to_se(cobj->enabled, jsret, s.thisObject() /*ctx*/); - s.rval() = jsret; - SE_HOLD_RETURN_VALUE(cobj->enabled, s.thisObject(), s.rval()); - return true; -} -SE_BIND_PROP_GET(js_scene_Ambient_get_enabled) - -static bool js_scene_Ambient_set_enabled(se::State& s) // NOLINT(readability-identifier-naming) -{ - const auto& args = s.args(); - auto* cobj = SE_THIS_OBJECT(s); - SE_PRECONDITION2(cobj, false, "js_scene_Ambient_set_enabled : Invalid Native Object"); - - CC_UNUSED bool ok = true; - ok &= sevalue_to_native(args[0], &cobj->enabled, s.thisObject()); - SE_PRECONDITION2(ok, false, "js_scene_Ambient_set_enabled : Error processing new value"); - return true; -} -SE_BIND_PROP_SET(js_scene_Ambient_set_enabled) - -static bool js_scene_Ambient_get_skyIllum(se::State& s) // NOLINT(readability-identifier-naming) -{ - auto* cobj = SE_THIS_OBJECT(s); - SE_PRECONDITION2(cobj, false, "js_scene_Ambient_get_skyIllum : Invalid Native Object"); - - CC_UNUSED bool ok = true; - se::Value jsret; - ok &= nativevalue_to_se(cobj->skyIllum, jsret, s.thisObject() /*ctx*/); - s.rval() = jsret; - SE_HOLD_RETURN_VALUE(cobj->skyIllum, s.thisObject(), s.rval()); - return true; -} -SE_BIND_PROP_GET(js_scene_Ambient_get_skyIllum) - -static bool js_scene_Ambient_set_skyIllum(se::State& s) // NOLINT(readability-identifier-naming) -{ - const auto& args = s.args(); - auto* cobj = SE_THIS_OBJECT(s); - SE_PRECONDITION2(cobj, false, "js_scene_Ambient_set_skyIllum : Invalid Native Object"); - - CC_UNUSED bool ok = true; - ok &= sevalue_to_native(args[0], &cobj->skyIllum, s.thisObject()); - SE_PRECONDITION2(ok, false, "js_scene_Ambient_set_skyIllum : Error processing new value"); - return true; -} -SE_BIND_PROP_SET(js_scene_Ambient_set_skyIllum) - -static bool js_scene_Ambient_get_skyColor(se::State& s) // NOLINT(readability-identifier-naming) -{ - auto* cobj = SE_THIS_OBJECT(s); - SE_PRECONDITION2(cobj, false, "js_scene_Ambient_get_skyColor : Invalid Native Object"); - - CC_UNUSED bool ok = true; - se::Value jsret; - ok &= nativevalue_to_se(cobj->skyColor, jsret, s.thisObject() /*ctx*/); - s.rval() = jsret; - SE_HOLD_RETURN_VALUE(cobj->skyColor, s.thisObject(), s.rval()); - return true; -} -SE_BIND_PROP_GET(js_scene_Ambient_get_skyColor) - -static bool js_scene_Ambient_set_skyColor(se::State& s) // NOLINT(readability-identifier-naming) -{ - const auto& args = s.args(); - auto* cobj = SE_THIS_OBJECT(s); - SE_PRECONDITION2(cobj, false, "js_scene_Ambient_set_skyColor : Invalid Native Object"); - - CC_UNUSED bool ok = true; - ok &= sevalue_to_native(args[0], &cobj->skyColor, s.thisObject()); - SE_PRECONDITION2(ok, false, "js_scene_Ambient_set_skyColor : Error processing new value"); - return true; -} -SE_BIND_PROP_SET(js_scene_Ambient_set_skyColor) - -static bool js_scene_Ambient_get_groundAlbedo(se::State& s) // NOLINT(readability-identifier-naming) -{ - auto* cobj = SE_THIS_OBJECT(s); - SE_PRECONDITION2(cobj, false, "js_scene_Ambient_get_groundAlbedo : Invalid Native Object"); - - CC_UNUSED bool ok = true; - se::Value jsret; - ok &= nativevalue_to_se(cobj->groundAlbedo, jsret, s.thisObject() /*ctx*/); - s.rval() = jsret; - SE_HOLD_RETURN_VALUE(cobj->groundAlbedo, s.thisObject(), s.rval()); - return true; -} -SE_BIND_PROP_GET(js_scene_Ambient_get_groundAlbedo) - -static bool js_scene_Ambient_set_groundAlbedo(se::State& s) // NOLINT(readability-identifier-naming) -{ - const auto& args = s.args(); - auto* cobj = SE_THIS_OBJECT(s); - SE_PRECONDITION2(cobj, false, "js_scene_Ambient_set_groundAlbedo : Invalid Native Object"); - - CC_UNUSED bool ok = true; - ok &= sevalue_to_native(args[0], &cobj->groundAlbedo, s.thisObject()); - SE_PRECONDITION2(ok, false, "js_scene_Ambient_set_groundAlbedo : Error processing new value"); - return true; -} -SE_BIND_PROP_SET(js_scene_Ambient_set_groundAlbedo) - - -template<> -bool sevalue_to_native(const se::Value &from, cc::scene::Ambient * to, se::Object *ctx) -{ - assert(from.isObject()); - se::Object *json = from.toObject(); - auto* data = reinterpret_cast(json->getPrivateData()); - if (data) { - *to = *data; - return true; - } - se::Value field; - bool ok = true; - json->getProperty("enabled", &field); - if(!field.isNullOrUndefined()) { - ok &= sevalue_to_native(field, &(to->enabled), ctx); - } - json->getProperty("skyIllum", &field); - if(!field.isNullOrUndefined()) { - ok &= sevalue_to_native(field, &(to->skyIllum), ctx); - } - json->getProperty("skyColor", &field); - if(!field.isNullOrUndefined()) { - ok &= sevalue_to_native(field, &(to->skyColor), ctx); - } - json->getProperty("groundAlbedo", &field); - if(!field.isNullOrUndefined()) { - ok &= sevalue_to_native(field, &(to->groundAlbedo), ctx); - } - return ok; -} - -SE_DECLARE_FINALIZE_FUNC(js_cc_scene_Ambient_finalize) - -static bool js_scene_Ambient_constructor(se::State& s) // NOLINT(readability-identifier-naming) -{ - CC_UNUSED bool ok = true; - const auto& args = s.args(); - size_t argc = args.size(); - - if(argc == 0) - { - cc::scene::Ambient* cobj = JSB_ALLOC(cc::scene::Ambient); - s.thisObject()->setPrivateData(cobj); - se::NonRefNativePtrCreatedByCtorMap::emplace(cobj); - return true; - } - - if(argc == 1 && args[0].isObject()) - { - se::Object *json = args[0].toObject(); - se::Value field; - - cc::scene::Ambient* cobj = JSB_ALLOC(cc::scene::Ambient); - ok &= sevalue_to_native(args[0], cobj, s.thisObject()); - if(!ok) { - JSB_FREE(cobj); - SE_REPORT_ERROR("argument convertion error"); - return false; - } - - s.thisObject()->setPrivateData(cobj); - se::NonRefNativePtrCreatedByCtorMap::emplace(cobj); - return true; - } - - cc::scene::Ambient* cobj = JSB_ALLOC(cc::scene::Ambient); - if (argc > 0 && !args[0].isUndefined()) { - ok &= sevalue_to_native(args[0], &(cobj->enabled), nullptr); - } - if (argc > 1 && !args[1].isUndefined()) { - ok &= sevalue_to_native(args[1], &(cobj->skyIllum), nullptr); - } - if (argc > 2 && !args[2].isUndefined()) { - ok &= sevalue_to_native(args[2], &(cobj->skyColor), nullptr); - } - if (argc > 3 && !args[3].isUndefined()) { - ok &= sevalue_to_native(args[3], &(cobj->groundAlbedo), nullptr); - } - - if(!ok) { - JSB_FREE(cobj); - SE_REPORT_ERROR("Argument convertion error"); - return false; - } - - s.thisObject()->setPrivateData(cobj); - se::NonRefNativePtrCreatedByCtorMap::emplace(cobj); - return true; -} -SE_BIND_CTOR(js_scene_Ambient_constructor, __jsb_cc_scene_Ambient_class, js_cc_scene_Ambient_finalize) - - - -static bool js_cc_scene_Ambient_finalize(se::State& s) // NOLINT(readability-identifier-naming) -{ - auto iter = se::NonRefNativePtrCreatedByCtorMap::find(SE_THIS_OBJECT(s)); - if (iter != se::NonRefNativePtrCreatedByCtorMap::end()) - { - se::NonRefNativePtrCreatedByCtorMap::erase(iter); - auto* cobj = SE_THIS_OBJECT(s); - JSB_FREE(cobj); - } - return true; -} -SE_BIND_FINALIZE_FUNC(js_cc_scene_Ambient_finalize) - -bool js_register_scene_Ambient(se::Object* obj) // NOLINT(readability-identifier-naming) -{ - auto* cls = se::Class::create("Ambient", obj, nullptr, _SE(js_scene_Ambient_constructor)); - - cls->defineProperty("enabled", _SE(js_scene_Ambient_get_enabled), _SE(js_scene_Ambient_set_enabled)); - cls->defineProperty("skyIllum", _SE(js_scene_Ambient_get_skyIllum), _SE(js_scene_Ambient_set_skyIllum)); - cls->defineProperty("skyColor", _SE(js_scene_Ambient_get_skyColor), _SE(js_scene_Ambient_set_skyColor)); - cls->defineProperty("groundAlbedo", _SE(js_scene_Ambient_get_groundAlbedo), _SE(js_scene_Ambient_set_groundAlbedo)); - cls->defineFinalizeFunction(_SE(js_cc_scene_Ambient_finalize)); - cls->install(); - JSBClassType::registerClass(cls); - - __jsb_cc_scene_Ambient_proto = cls->getProto(); - __jsb_cc_scene_Ambient_class = cls; - - se::ScriptEngine::getInstance()->clearException(); - return true; -} -se::Object* __jsb_cc_scene_OctreeInfo_proto = nullptr; -se::Class* __jsb_cc_scene_OctreeInfo_class = nullptr; - -static bool js_scene_OctreeInfo_get_enabled(se::State& s) // NOLINT(readability-identifier-naming) -{ - auto* cobj = SE_THIS_OBJECT(s); - SE_PRECONDITION2(cobj, false, "js_scene_OctreeInfo_get_enabled : Invalid Native Object"); - - CC_UNUSED bool ok = true; - se::Value jsret; - ok &= nativevalue_to_se(cobj->enabled, jsret, s.thisObject() /*ctx*/); - s.rval() = jsret; - SE_HOLD_RETURN_VALUE(cobj->enabled, s.thisObject(), s.rval()); - return true; -} -SE_BIND_PROP_GET(js_scene_OctreeInfo_get_enabled) - -static bool js_scene_OctreeInfo_set_enabled(se::State& s) // NOLINT(readability-identifier-naming) -{ - const auto& args = s.args(); - auto* cobj = SE_THIS_OBJECT(s); - SE_PRECONDITION2(cobj, false, "js_scene_OctreeInfo_set_enabled : Invalid Native Object"); - - CC_UNUSED bool ok = true; - ok &= sevalue_to_native(args[0], &cobj->enabled, s.thisObject()); - SE_PRECONDITION2(ok, false, "js_scene_OctreeInfo_set_enabled : Error processing new value"); - return true; -} -SE_BIND_PROP_SET(js_scene_OctreeInfo_set_enabled) - -static bool js_scene_OctreeInfo_get_minPos(se::State& s) // NOLINT(readability-identifier-naming) -{ - auto* cobj = SE_THIS_OBJECT(s); - SE_PRECONDITION2(cobj, false, "js_scene_OctreeInfo_get_minPos : Invalid Native Object"); - - CC_UNUSED bool ok = true; - se::Value jsret; - ok &= nativevalue_to_se(cobj->minPos, jsret, s.thisObject() /*ctx*/); - s.rval() = jsret; - SE_HOLD_RETURN_VALUE(cobj->minPos, s.thisObject(), s.rval()); - return true; -} -SE_BIND_PROP_GET(js_scene_OctreeInfo_get_minPos) - -static bool js_scene_OctreeInfo_set_minPos(se::State& s) // NOLINT(readability-identifier-naming) -{ - const auto& args = s.args(); - auto* cobj = SE_THIS_OBJECT(s); - SE_PRECONDITION2(cobj, false, "js_scene_OctreeInfo_set_minPos : Invalid Native Object"); - - CC_UNUSED bool ok = true; - ok &= sevalue_to_native(args[0], &cobj->minPos, s.thisObject()); - SE_PRECONDITION2(ok, false, "js_scene_OctreeInfo_set_minPos : Error processing new value"); - return true; -} -SE_BIND_PROP_SET(js_scene_OctreeInfo_set_minPos) - -static bool js_scene_OctreeInfo_get_maxPos(se::State& s) // NOLINT(readability-identifier-naming) -{ - auto* cobj = SE_THIS_OBJECT(s); - SE_PRECONDITION2(cobj, false, "js_scene_OctreeInfo_get_maxPos : Invalid Native Object"); - - CC_UNUSED bool ok = true; - se::Value jsret; - ok &= nativevalue_to_se(cobj->maxPos, jsret, s.thisObject() /*ctx*/); - s.rval() = jsret; - SE_HOLD_RETURN_VALUE(cobj->maxPos, s.thisObject(), s.rval()); - return true; -} -SE_BIND_PROP_GET(js_scene_OctreeInfo_get_maxPos) - -static bool js_scene_OctreeInfo_set_maxPos(se::State& s) // NOLINT(readability-identifier-naming) -{ - const auto& args = s.args(); - auto* cobj = SE_THIS_OBJECT(s); - SE_PRECONDITION2(cobj, false, "js_scene_OctreeInfo_set_maxPos : Invalid Native Object"); - - CC_UNUSED bool ok = true; - ok &= sevalue_to_native(args[0], &cobj->maxPos, s.thisObject()); - SE_PRECONDITION2(ok, false, "js_scene_OctreeInfo_set_maxPos : Error processing new value"); - return true; -} -SE_BIND_PROP_SET(js_scene_OctreeInfo_set_maxPos) - -static bool js_scene_OctreeInfo_get_depth(se::State& s) // NOLINT(readability-identifier-naming) -{ - auto* cobj = SE_THIS_OBJECT(s); - SE_PRECONDITION2(cobj, false, "js_scene_OctreeInfo_get_depth : Invalid Native Object"); - - CC_UNUSED bool ok = true; - se::Value jsret; - ok &= nativevalue_to_se(cobj->depth, jsret, s.thisObject() /*ctx*/); - s.rval() = jsret; - SE_HOLD_RETURN_VALUE(cobj->depth, s.thisObject(), s.rval()); - return true; -} -SE_BIND_PROP_GET(js_scene_OctreeInfo_get_depth) - -static bool js_scene_OctreeInfo_set_depth(se::State& s) // NOLINT(readability-identifier-naming) -{ - const auto& args = s.args(); - auto* cobj = SE_THIS_OBJECT(s); - SE_PRECONDITION2(cobj, false, "js_scene_OctreeInfo_set_depth : Invalid Native Object"); - - CC_UNUSED bool ok = true; - ok &= sevalue_to_native(args[0], &cobj->depth, s.thisObject()); - SE_PRECONDITION2(ok, false, "js_scene_OctreeInfo_set_depth : Error processing new value"); - return true; -} -SE_BIND_PROP_SET(js_scene_OctreeInfo_set_depth) - - -template<> -bool sevalue_to_native(const se::Value &from, cc::scene::OctreeInfo * to, se::Object *ctx) -{ - assert(from.isObject()); - se::Object *json = from.toObject(); - auto* data = reinterpret_cast(json->getPrivateData()); - if (data) { - *to = *data; - return true; - } - se::Value field; - bool ok = true; - json->getProperty("enabled", &field); - if(!field.isNullOrUndefined()) { - ok &= sevalue_to_native(field, &(to->enabled), ctx); - } - json->getProperty("minPos", &field); - if(!field.isNullOrUndefined()) { - ok &= sevalue_to_native(field, &(to->minPos), ctx); - } - json->getProperty("maxPos", &field); - if(!field.isNullOrUndefined()) { - ok &= sevalue_to_native(field, &(to->maxPos), ctx); - } - json->getProperty("depth", &field); - if(!field.isNullOrUndefined()) { - ok &= sevalue_to_native(field, &(to->depth), ctx); - } - return ok; -} - -SE_DECLARE_FINALIZE_FUNC(js_cc_scene_OctreeInfo_finalize) - -static bool js_scene_OctreeInfo_constructor(se::State& s) // NOLINT(readability-identifier-naming) -{ - CC_UNUSED bool ok = true; - const auto& args = s.args(); - size_t argc = args.size(); - - if(argc == 0) - { - cc::scene::OctreeInfo* cobj = JSB_ALLOC(cc::scene::OctreeInfo); - s.thisObject()->setPrivateData(cobj); - se::NonRefNativePtrCreatedByCtorMap::emplace(cobj); - return true; - } - - if(argc == 1 && args[0].isObject()) - { - se::Object *json = args[0].toObject(); - se::Value field; - - cc::scene::OctreeInfo* cobj = JSB_ALLOC(cc::scene::OctreeInfo); - ok &= sevalue_to_native(args[0], cobj, s.thisObject()); - if(!ok) { - JSB_FREE(cobj); - SE_REPORT_ERROR("argument convertion error"); - return false; - } - - s.thisObject()->setPrivateData(cobj); - se::NonRefNativePtrCreatedByCtorMap::emplace(cobj); - return true; - } - - cc::scene::OctreeInfo* cobj = JSB_ALLOC(cc::scene::OctreeInfo); - if (argc > 0 && !args[0].isUndefined()) { - ok &= sevalue_to_native(args[0], &(cobj->enabled), nullptr); - } - if (argc > 1 && !args[1].isUndefined()) { - ok &= sevalue_to_native(args[1], &(cobj->minPos), nullptr); - } - if (argc > 2 && !args[2].isUndefined()) { - ok &= sevalue_to_native(args[2], &(cobj->maxPos), nullptr); - } - if (argc > 3 && !args[3].isUndefined()) { - ok &= sevalue_to_native(args[3], &(cobj->depth), nullptr); - } - - if(!ok) { - JSB_FREE(cobj); - SE_REPORT_ERROR("Argument convertion error"); - return false; - } - - s.thisObject()->setPrivateData(cobj); - se::NonRefNativePtrCreatedByCtorMap::emplace(cobj); - return true; -} -SE_BIND_CTOR(js_scene_OctreeInfo_constructor, __jsb_cc_scene_OctreeInfo_class, js_cc_scene_OctreeInfo_finalize) - - - -static bool js_cc_scene_OctreeInfo_finalize(se::State& s) // NOLINT(readability-identifier-naming) -{ - auto iter = se::NonRefNativePtrCreatedByCtorMap::find(SE_THIS_OBJECT(s)); - if (iter != se::NonRefNativePtrCreatedByCtorMap::end()) - { - se::NonRefNativePtrCreatedByCtorMap::erase(iter); - auto* cobj = SE_THIS_OBJECT(s); - JSB_FREE(cobj); - } - return true; -} -SE_BIND_FINALIZE_FUNC(js_cc_scene_OctreeInfo_finalize) - -bool js_register_scene_OctreeInfo(se::Object* obj) // NOLINT(readability-identifier-naming) -{ - auto* cls = se::Class::create("OctreeInfo", obj, nullptr, _SE(js_scene_OctreeInfo_constructor)); - - cls->defineProperty("enabled", _SE(js_scene_OctreeInfo_get_enabled), _SE(js_scene_OctreeInfo_set_enabled)); - cls->defineProperty("minPos", _SE(js_scene_OctreeInfo_get_minPos), _SE(js_scene_OctreeInfo_set_minPos)); - cls->defineProperty("maxPos", _SE(js_scene_OctreeInfo_get_maxPos), _SE(js_scene_OctreeInfo_set_maxPos)); - cls->defineProperty("depth", _SE(js_scene_OctreeInfo_get_depth), _SE(js_scene_OctreeInfo_set_depth)); - cls->defineFinalizeFunction(_SE(js_cc_scene_OctreeInfo_finalize)); - cls->install(); - JSBClassType::registerClass(cls); - - __jsb_cc_scene_OctreeInfo_proto = cls->getProto(); - __jsb_cc_scene_OctreeInfo_class = cls; - - se::ScriptEngine::getInstance()->clearException(); - return true; -} -se::Object* __jsb_cc_scene_PipelineSharedSceneData_proto = nullptr; -se::Class* __jsb_cc_scene_PipelineSharedSceneData_class = nullptr; - -static bool js_scene_PipelineSharedSceneData_get_isHDR(se::State& s) // NOLINT(readability-identifier-naming) -{ - auto* cobj = SE_THIS_OBJECT(s); - SE_PRECONDITION2(cobj, false, "js_scene_PipelineSharedSceneData_get_isHDR : Invalid Native Object"); - - CC_UNUSED bool ok = true; - se::Value jsret; - ok &= nativevalue_to_se(cobj->isHDR, jsret, s.thisObject() /*ctx*/); - s.rval() = jsret; - SE_HOLD_RETURN_VALUE(cobj->isHDR, s.thisObject(), s.rval()); - return true; -} -SE_BIND_PROP_GET(js_scene_PipelineSharedSceneData_get_isHDR) - -static bool js_scene_PipelineSharedSceneData_set_isHDR(se::State& s) // NOLINT(readability-identifier-naming) -{ - const auto& args = s.args(); - auto* cobj = SE_THIS_OBJECT(s); - SE_PRECONDITION2(cobj, false, "js_scene_PipelineSharedSceneData_set_isHDR : Invalid Native Object"); - - CC_UNUSED bool ok = true; - ok &= sevalue_to_native(args[0], &cobj->isHDR, s.thisObject()); - SE_PRECONDITION2(ok, false, "js_scene_PipelineSharedSceneData_set_isHDR : Error processing new value"); - return true; -} -SE_BIND_PROP_SET(js_scene_PipelineSharedSceneData_set_isHDR) - -static bool js_scene_PipelineSharedSceneData_get_shadingScale(se::State& s) // NOLINT(readability-identifier-naming) -{ - auto* cobj = SE_THIS_OBJECT(s); - SE_PRECONDITION2(cobj, false, "js_scene_PipelineSharedSceneData_get_shadingScale : Invalid Native Object"); - - CC_UNUSED bool ok = true; - se::Value jsret; - ok &= nativevalue_to_se(cobj->shadingScale, jsret, s.thisObject() /*ctx*/); - s.rval() = jsret; - SE_HOLD_RETURN_VALUE(cobj->shadingScale, s.thisObject(), s.rval()); - return true; -} -SE_BIND_PROP_GET(js_scene_PipelineSharedSceneData_get_shadingScale) - -static bool js_scene_PipelineSharedSceneData_set_shadingScale(se::State& s) // NOLINT(readability-identifier-naming) -{ - const auto& args = s.args(); - auto* cobj = SE_THIS_OBJECT(s); - SE_PRECONDITION2(cobj, false, "js_scene_PipelineSharedSceneData_set_shadingScale : Invalid Native Object"); - - CC_UNUSED bool ok = true; - ok &= sevalue_to_native(args[0], &cobj->shadingScale, s.thisObject()); - SE_PRECONDITION2(ok, false, "js_scene_PipelineSharedSceneData_set_shadingScale : Error processing new value"); - return true; -} -SE_BIND_PROP_SET(js_scene_PipelineSharedSceneData_set_shadingScale) - -static bool js_scene_PipelineSharedSceneData_get_ambient(se::State& s) // NOLINT(readability-identifier-naming) -{ - auto* cobj = SE_THIS_OBJECT(s); - SE_PRECONDITION2(cobj, false, "js_scene_PipelineSharedSceneData_get_ambient : Invalid Native Object"); - - CC_UNUSED bool ok = true; - se::Value jsret; - ok &= nativevalue_to_se(cobj->ambient, jsret, s.thisObject() /*ctx*/); - s.rval() = jsret; - SE_HOLD_RETURN_VALUE(cobj->ambient, s.thisObject(), s.rval()); - return true; -} -SE_BIND_PROP_GET(js_scene_PipelineSharedSceneData_get_ambient) - -static bool js_scene_PipelineSharedSceneData_set_ambient(se::State& s) // NOLINT(readability-identifier-naming) -{ - const auto& args = s.args(); - auto* cobj = SE_THIS_OBJECT(s); - SE_PRECONDITION2(cobj, false, "js_scene_PipelineSharedSceneData_set_ambient : Invalid Native Object"); - - CC_UNUSED bool ok = true; - ok &= sevalue_to_native(args[0], &cobj->ambient, s.thisObject()); - SE_PRECONDITION2(ok, false, "js_scene_PipelineSharedSceneData_set_ambient : Error processing new value"); - return true; -} -SE_BIND_PROP_SET(js_scene_PipelineSharedSceneData_set_ambient) - -static bool js_scene_PipelineSharedSceneData_get_shadow(se::State& s) // NOLINT(readability-identifier-naming) -{ - auto* cobj = SE_THIS_OBJECT(s); - SE_PRECONDITION2(cobj, false, "js_scene_PipelineSharedSceneData_get_shadow : Invalid Native Object"); - - CC_UNUSED bool ok = true; - se::Value jsret; - ok &= nativevalue_to_se(cobj->shadow, jsret, s.thisObject() /*ctx*/); - s.rval() = jsret; - SE_HOLD_RETURN_VALUE(cobj->shadow, s.thisObject(), s.rval()); - return true; -} -SE_BIND_PROP_GET(js_scene_PipelineSharedSceneData_get_shadow) - -static bool js_scene_PipelineSharedSceneData_set_shadow(se::State& s) // NOLINT(readability-identifier-naming) -{ - const auto& args = s.args(); - auto* cobj = SE_THIS_OBJECT(s); - SE_PRECONDITION2(cobj, false, "js_scene_PipelineSharedSceneData_set_shadow : Invalid Native Object"); - - CC_UNUSED bool ok = true; - ok &= sevalue_to_native(args[0], &cobj->shadow, s.thisObject()); - SE_PRECONDITION2(ok, false, "js_scene_PipelineSharedSceneData_set_shadow : Error processing new value"); - return true; -} -SE_BIND_PROP_SET(js_scene_PipelineSharedSceneData_set_shadow) - -static bool js_scene_PipelineSharedSceneData_get_skybox(se::State& s) // NOLINT(readability-identifier-naming) -{ - auto* cobj = SE_THIS_OBJECT(s); - SE_PRECONDITION2(cobj, false, "js_scene_PipelineSharedSceneData_get_skybox : Invalid Native Object"); - - CC_UNUSED bool ok = true; - se::Value jsret; - ok &= nativevalue_to_se(cobj->skybox, jsret, s.thisObject() /*ctx*/); - s.rval() = jsret; - SE_HOLD_RETURN_VALUE(cobj->skybox, s.thisObject(), s.rval()); - return true; -} -SE_BIND_PROP_GET(js_scene_PipelineSharedSceneData_get_skybox) - -static bool js_scene_PipelineSharedSceneData_set_skybox(se::State& s) // NOLINT(readability-identifier-naming) -{ - const auto& args = s.args(); - auto* cobj = SE_THIS_OBJECT(s); - SE_PRECONDITION2(cobj, false, "js_scene_PipelineSharedSceneData_set_skybox : Invalid Native Object"); - - CC_UNUSED bool ok = true; - ok &= sevalue_to_native(args[0], &cobj->skybox, s.thisObject()); - SE_PRECONDITION2(ok, false, "js_scene_PipelineSharedSceneData_set_skybox : Error processing new value"); - return true; -} -SE_BIND_PROP_SET(js_scene_PipelineSharedSceneData_set_skybox) - -static bool js_scene_PipelineSharedSceneData_get_fog(se::State& s) // NOLINT(readability-identifier-naming) -{ - auto* cobj = SE_THIS_OBJECT(s); - SE_PRECONDITION2(cobj, false, "js_scene_PipelineSharedSceneData_get_fog : Invalid Native Object"); - - CC_UNUSED bool ok = true; - se::Value jsret; - ok &= nativevalue_to_se(cobj->fog, jsret, s.thisObject() /*ctx*/); - s.rval() = jsret; - SE_HOLD_RETURN_VALUE(cobj->fog, s.thisObject(), s.rval()); - return true; -} -SE_BIND_PROP_GET(js_scene_PipelineSharedSceneData_get_fog) - -static bool js_scene_PipelineSharedSceneData_set_fog(se::State& s) // NOLINT(readability-identifier-naming) -{ - const auto& args = s.args(); - auto* cobj = SE_THIS_OBJECT(s); - SE_PRECONDITION2(cobj, false, "js_scene_PipelineSharedSceneData_set_fog : Invalid Native Object"); - - CC_UNUSED bool ok = true; - ok &= sevalue_to_native(args[0], &cobj->fog, s.thisObject()); - SE_PRECONDITION2(ok, false, "js_scene_PipelineSharedSceneData_set_fog : Error processing new value"); - return true; -} -SE_BIND_PROP_SET(js_scene_PipelineSharedSceneData_set_fog) - -static bool js_scene_PipelineSharedSceneData_get_octree(se::State& s) // NOLINT(readability-identifier-naming) -{ - auto* cobj = SE_THIS_OBJECT(s); - SE_PRECONDITION2(cobj, false, "js_scene_PipelineSharedSceneData_get_octree : Invalid Native Object"); - - CC_UNUSED bool ok = true; - se::Value jsret; - ok &= nativevalue_to_se(cobj->octree, jsret, s.thisObject() /*ctx*/); - s.rval() = jsret; - SE_HOLD_RETURN_VALUE(cobj->octree, s.thisObject(), s.rval()); - return true; -} -SE_BIND_PROP_GET(js_scene_PipelineSharedSceneData_get_octree) - -static bool js_scene_PipelineSharedSceneData_set_octree(se::State& s) // NOLINT(readability-identifier-naming) -{ - const auto& args = s.args(); - auto* cobj = SE_THIS_OBJECT(s); - SE_PRECONDITION2(cobj, false, "js_scene_PipelineSharedSceneData_set_octree : Invalid Native Object"); - - CC_UNUSED bool ok = true; - ok &= sevalue_to_native(args[0], &cobj->octree, s.thisObject()); - SE_PRECONDITION2(ok, false, "js_scene_PipelineSharedSceneData_set_octree : Error processing new value"); - return true; -} -SE_BIND_PROP_SET(js_scene_PipelineSharedSceneData_set_octree) - -static bool js_scene_PipelineSharedSceneData_get_geometryRendererPasses(se::State& s) // NOLINT(readability-identifier-naming) -{ - auto* cobj = SE_THIS_OBJECT(s); - SE_PRECONDITION2(cobj, false, "js_scene_PipelineSharedSceneData_get_geometryRendererPasses : Invalid Native Object"); - - CC_UNUSED bool ok = true; - se::Value jsret; - ok &= nativevalue_to_se(cobj->geometryRendererPasses, jsret, s.thisObject() /*ctx*/); - s.rval() = jsret; - SE_HOLD_RETURN_VALUE(cobj->geometryRendererPasses, s.thisObject(), s.rval()); - return true; -} -SE_BIND_PROP_GET(js_scene_PipelineSharedSceneData_get_geometryRendererPasses) - -static bool js_scene_PipelineSharedSceneData_set_geometryRendererPasses(se::State& s) // NOLINT(readability-identifier-naming) -{ - const auto& args = s.args(); - auto* cobj = SE_THIS_OBJECT(s); - SE_PRECONDITION2(cobj, false, "js_scene_PipelineSharedSceneData_set_geometryRendererPasses : Invalid Native Object"); - - CC_UNUSED bool ok = true; - ok &= sevalue_to_native(args[0], &cobj->geometryRendererPasses, s.thisObject()); - SE_PRECONDITION2(ok, false, "js_scene_PipelineSharedSceneData_set_geometryRendererPasses : Error processing new value"); - return true; -} -SE_BIND_PROP_SET(js_scene_PipelineSharedSceneData_set_geometryRendererPasses) - -static bool js_scene_PipelineSharedSceneData_get_geometryRendererShaders(se::State& s) // NOLINT(readability-identifier-naming) -{ - auto* cobj = SE_THIS_OBJECT(s); - SE_PRECONDITION2(cobj, false, "js_scene_PipelineSharedSceneData_get_geometryRendererShaders : Invalid Native Object"); - - CC_UNUSED bool ok = true; - se::Value jsret; - ok &= nativevalue_to_se(cobj->geometryRendererShaders, jsret, s.thisObject() /*ctx*/); - s.rval() = jsret; - SE_HOLD_RETURN_VALUE(cobj->geometryRendererShaders, s.thisObject(), s.rval()); - return true; -} -SE_BIND_PROP_GET(js_scene_PipelineSharedSceneData_get_geometryRendererShaders) - -static bool js_scene_PipelineSharedSceneData_set_geometryRendererShaders(se::State& s) // NOLINT(readability-identifier-naming) -{ - const auto& args = s.args(); - auto* cobj = SE_THIS_OBJECT(s); - SE_PRECONDITION2(cobj, false, "js_scene_PipelineSharedSceneData_set_geometryRendererShaders : Invalid Native Object"); - - CC_UNUSED bool ok = true; - ok &= sevalue_to_native(args[0], &cobj->geometryRendererShaders, s.thisObject()); - SE_PRECONDITION2(ok, false, "js_scene_PipelineSharedSceneData_set_geometryRendererShaders : Error processing new value"); - return true; -} -SE_BIND_PROP_SET(js_scene_PipelineSharedSceneData_set_geometryRendererShaders) - -static bool js_scene_PipelineSharedSceneData_get_occlusionQueryInputAssembler(se::State& s) // NOLINT(readability-identifier-naming) -{ - auto* cobj = SE_THIS_OBJECT(s); - SE_PRECONDITION2(cobj, false, "js_scene_PipelineSharedSceneData_get_occlusionQueryInputAssembler : Invalid Native Object"); - - CC_UNUSED bool ok = true; - se::Value jsret; - ok &= nativevalue_to_se(cobj->occlusionQueryInputAssembler, jsret, s.thisObject() /*ctx*/); - s.rval() = jsret; - SE_HOLD_RETURN_VALUE(cobj->occlusionQueryInputAssembler, s.thisObject(), s.rval()); - return true; -} -SE_BIND_PROP_GET(js_scene_PipelineSharedSceneData_get_occlusionQueryInputAssembler) - -static bool js_scene_PipelineSharedSceneData_set_occlusionQueryInputAssembler(se::State& s) // NOLINT(readability-identifier-naming) -{ - const auto& args = s.args(); - auto* cobj = SE_THIS_OBJECT(s); - SE_PRECONDITION2(cobj, false, "js_scene_PipelineSharedSceneData_set_occlusionQueryInputAssembler : Invalid Native Object"); - - CC_UNUSED bool ok = true; - ok &= sevalue_to_native(args[0], &cobj->occlusionQueryInputAssembler, s.thisObject()); - SE_PRECONDITION2(ok, false, "js_scene_PipelineSharedSceneData_set_occlusionQueryInputAssembler : Error processing new value"); - return true; -} -SE_BIND_PROP_SET(js_scene_PipelineSharedSceneData_set_occlusionQueryInputAssembler) - -static bool js_scene_PipelineSharedSceneData_get_occlusionQueryPass(se::State& s) // NOLINT(readability-identifier-naming) -{ - auto* cobj = SE_THIS_OBJECT(s); - SE_PRECONDITION2(cobj, false, "js_scene_PipelineSharedSceneData_get_occlusionQueryPass : Invalid Native Object"); - - CC_UNUSED bool ok = true; - se::Value jsret; - ok &= nativevalue_to_se(cobj->occlusionQueryPass, jsret, s.thisObject() /*ctx*/); - s.rval() = jsret; - SE_HOLD_RETURN_VALUE(cobj->occlusionQueryPass, s.thisObject(), s.rval()); - return true; -} -SE_BIND_PROP_GET(js_scene_PipelineSharedSceneData_get_occlusionQueryPass) - -static bool js_scene_PipelineSharedSceneData_set_occlusionQueryPass(se::State& s) // NOLINT(readability-identifier-naming) -{ - const auto& args = s.args(); - auto* cobj = SE_THIS_OBJECT(s); - SE_PRECONDITION2(cobj, false, "js_scene_PipelineSharedSceneData_set_occlusionQueryPass : Invalid Native Object"); - - CC_UNUSED bool ok = true; - ok &= sevalue_to_native(args[0], &cobj->occlusionQueryPass, s.thisObject()); - SE_PRECONDITION2(ok, false, "js_scene_PipelineSharedSceneData_set_occlusionQueryPass : Error processing new value"); - return true; -} -SE_BIND_PROP_SET(js_scene_PipelineSharedSceneData_set_occlusionQueryPass) - -static bool js_scene_PipelineSharedSceneData_get_occlusionQueryShader(se::State& s) // NOLINT(readability-identifier-naming) -{ - auto* cobj = SE_THIS_OBJECT(s); - SE_PRECONDITION2(cobj, false, "js_scene_PipelineSharedSceneData_get_occlusionQueryShader : Invalid Native Object"); - - CC_UNUSED bool ok = true; - se::Value jsret; - ok &= nativevalue_to_se(cobj->occlusionQueryShader, jsret, s.thisObject() /*ctx*/); - s.rval() = jsret; - SE_HOLD_RETURN_VALUE(cobj->occlusionQueryShader, s.thisObject(), s.rval()); - return true; -} -SE_BIND_PROP_GET(js_scene_PipelineSharedSceneData_get_occlusionQueryShader) - -static bool js_scene_PipelineSharedSceneData_set_occlusionQueryShader(se::State& s) // NOLINT(readability-identifier-naming) -{ - const auto& args = s.args(); - auto* cobj = SE_THIS_OBJECT(s); - SE_PRECONDITION2(cobj, false, "js_scene_PipelineSharedSceneData_set_occlusionQueryShader : Invalid Native Object"); - - CC_UNUSED bool ok = true; - ok &= sevalue_to_native(args[0], &cobj->occlusionQueryShader, s.thisObject()); - SE_PRECONDITION2(ok, false, "js_scene_PipelineSharedSceneData_set_occlusionQueryShader : Error processing new value"); - return true; -} -SE_BIND_PROP_SET(js_scene_PipelineSharedSceneData_set_occlusionQueryShader) - -static bool js_scene_PipelineSharedSceneData_get_deferredLightPass(se::State& s) // NOLINT(readability-identifier-naming) -{ - auto* cobj = SE_THIS_OBJECT(s); - SE_PRECONDITION2(cobj, false, "js_scene_PipelineSharedSceneData_get_deferredLightPass : Invalid Native Object"); - - CC_UNUSED bool ok = true; - se::Value jsret; - ok &= nativevalue_to_se(cobj->deferredLightPass, jsret, s.thisObject() /*ctx*/); - s.rval() = jsret; - SE_HOLD_RETURN_VALUE(cobj->deferredLightPass, s.thisObject(), s.rval()); - return true; -} -SE_BIND_PROP_GET(js_scene_PipelineSharedSceneData_get_deferredLightPass) - -static bool js_scene_PipelineSharedSceneData_set_deferredLightPass(se::State& s) // NOLINT(readability-identifier-naming) -{ - const auto& args = s.args(); - auto* cobj = SE_THIS_OBJECT(s); - SE_PRECONDITION2(cobj, false, "js_scene_PipelineSharedSceneData_set_deferredLightPass : Invalid Native Object"); - - CC_UNUSED bool ok = true; - ok &= sevalue_to_native(args[0], &cobj->deferredLightPass, s.thisObject()); - SE_PRECONDITION2(ok, false, "js_scene_PipelineSharedSceneData_set_deferredLightPass : Error processing new value"); - return true; -} -SE_BIND_PROP_SET(js_scene_PipelineSharedSceneData_set_deferredLightPass) - -static bool js_scene_PipelineSharedSceneData_get_deferredLightPassShader(se::State& s) // NOLINT(readability-identifier-naming) -{ - auto* cobj = SE_THIS_OBJECT(s); - SE_PRECONDITION2(cobj, false, "js_scene_PipelineSharedSceneData_get_deferredLightPassShader : Invalid Native Object"); - - CC_UNUSED bool ok = true; - se::Value jsret; - ok &= nativevalue_to_se(cobj->deferredLightPassShader, jsret, s.thisObject() /*ctx*/); - s.rval() = jsret; - SE_HOLD_RETURN_VALUE(cobj->deferredLightPassShader, s.thisObject(), s.rval()); - return true; -} -SE_BIND_PROP_GET(js_scene_PipelineSharedSceneData_get_deferredLightPassShader) - -static bool js_scene_PipelineSharedSceneData_set_deferredLightPassShader(se::State& s) // NOLINT(readability-identifier-naming) -{ - const auto& args = s.args(); - auto* cobj = SE_THIS_OBJECT(s); - SE_PRECONDITION2(cobj, false, "js_scene_PipelineSharedSceneData_set_deferredLightPassShader : Invalid Native Object"); - - CC_UNUSED bool ok = true; - ok &= sevalue_to_native(args[0], &cobj->deferredLightPassShader, s.thisObject()); - SE_PRECONDITION2(ok, false, "js_scene_PipelineSharedSceneData_set_deferredLightPassShader : Error processing new value"); - return true; -} -SE_BIND_PROP_SET(js_scene_PipelineSharedSceneData_set_deferredLightPassShader) - -static bool js_scene_PipelineSharedSceneData_get_bloomPrefilterPass(se::State& s) // NOLINT(readability-identifier-naming) -{ - auto* cobj = SE_THIS_OBJECT(s); - SE_PRECONDITION2(cobj, false, "js_scene_PipelineSharedSceneData_get_bloomPrefilterPass : Invalid Native Object"); - - CC_UNUSED bool ok = true; - se::Value jsret; - ok &= nativevalue_to_se(cobj->bloomPrefilterPass, jsret, s.thisObject() /*ctx*/); - s.rval() = jsret; - SE_HOLD_RETURN_VALUE(cobj->bloomPrefilterPass, s.thisObject(), s.rval()); - return true; -} -SE_BIND_PROP_GET(js_scene_PipelineSharedSceneData_get_bloomPrefilterPass) - -static bool js_scene_PipelineSharedSceneData_set_bloomPrefilterPass(se::State& s) // NOLINT(readability-identifier-naming) -{ - const auto& args = s.args(); - auto* cobj = SE_THIS_OBJECT(s); - SE_PRECONDITION2(cobj, false, "js_scene_PipelineSharedSceneData_set_bloomPrefilterPass : Invalid Native Object"); - - CC_UNUSED bool ok = true; - ok &= sevalue_to_native(args[0], &cobj->bloomPrefilterPass, s.thisObject()); - SE_PRECONDITION2(ok, false, "js_scene_PipelineSharedSceneData_set_bloomPrefilterPass : Error processing new value"); - return true; -} -SE_BIND_PROP_SET(js_scene_PipelineSharedSceneData_set_bloomPrefilterPass) - -static bool js_scene_PipelineSharedSceneData_get_bloomPrefilterPassShader(se::State& s) // NOLINT(readability-identifier-naming) -{ - auto* cobj = SE_THIS_OBJECT(s); - SE_PRECONDITION2(cobj, false, "js_scene_PipelineSharedSceneData_get_bloomPrefilterPassShader : Invalid Native Object"); - - CC_UNUSED bool ok = true; - se::Value jsret; - ok &= nativevalue_to_se(cobj->bloomPrefilterPassShader, jsret, s.thisObject() /*ctx*/); - s.rval() = jsret; - SE_HOLD_RETURN_VALUE(cobj->bloomPrefilterPassShader, s.thisObject(), s.rval()); - return true; -} -SE_BIND_PROP_GET(js_scene_PipelineSharedSceneData_get_bloomPrefilterPassShader) - -static bool js_scene_PipelineSharedSceneData_set_bloomPrefilterPassShader(se::State& s) // NOLINT(readability-identifier-naming) -{ - const auto& args = s.args(); - auto* cobj = SE_THIS_OBJECT(s); - SE_PRECONDITION2(cobj, false, "js_scene_PipelineSharedSceneData_set_bloomPrefilterPassShader : Invalid Native Object"); - - CC_UNUSED bool ok = true; - ok &= sevalue_to_native(args[0], &cobj->bloomPrefilterPassShader, s.thisObject()); - SE_PRECONDITION2(ok, false, "js_scene_PipelineSharedSceneData_set_bloomPrefilterPassShader : Error processing new value"); - return true; -} -SE_BIND_PROP_SET(js_scene_PipelineSharedSceneData_set_bloomPrefilterPassShader) - -static bool js_scene_PipelineSharedSceneData_get_bloomDownsamplePass(se::State& s) // NOLINT(readability-identifier-naming) -{ - auto* cobj = SE_THIS_OBJECT(s); - SE_PRECONDITION2(cobj, false, "js_scene_PipelineSharedSceneData_get_bloomDownsamplePass : Invalid Native Object"); - - CC_UNUSED bool ok = true; - se::Value jsret; - ok &= nativevalue_to_se(cobj->bloomDownsamplePass, jsret, s.thisObject() /*ctx*/); - s.rval() = jsret; - SE_HOLD_RETURN_VALUE(cobj->bloomDownsamplePass, s.thisObject(), s.rval()); - return true; -} -SE_BIND_PROP_GET(js_scene_PipelineSharedSceneData_get_bloomDownsamplePass) - -static bool js_scene_PipelineSharedSceneData_set_bloomDownsamplePass(se::State& s) // NOLINT(readability-identifier-naming) -{ - const auto& args = s.args(); - auto* cobj = SE_THIS_OBJECT(s); - SE_PRECONDITION2(cobj, false, "js_scene_PipelineSharedSceneData_set_bloomDownsamplePass : Invalid Native Object"); - - CC_UNUSED bool ok = true; - ok &= sevalue_to_native(args[0], &cobj->bloomDownsamplePass, s.thisObject()); - SE_PRECONDITION2(ok, false, "js_scene_PipelineSharedSceneData_set_bloomDownsamplePass : Error processing new value"); - return true; -} -SE_BIND_PROP_SET(js_scene_PipelineSharedSceneData_set_bloomDownsamplePass) - -static bool js_scene_PipelineSharedSceneData_get_bloomDownsamplePassShader(se::State& s) // NOLINT(readability-identifier-naming) -{ - auto* cobj = SE_THIS_OBJECT(s); - SE_PRECONDITION2(cobj, false, "js_scene_PipelineSharedSceneData_get_bloomDownsamplePassShader : Invalid Native Object"); - - CC_UNUSED bool ok = true; - se::Value jsret; - ok &= nativevalue_to_se(cobj->bloomDownsamplePassShader, jsret, s.thisObject() /*ctx*/); - s.rval() = jsret; - SE_HOLD_RETURN_VALUE(cobj->bloomDownsamplePassShader, s.thisObject(), s.rval()); - return true; -} -SE_BIND_PROP_GET(js_scene_PipelineSharedSceneData_get_bloomDownsamplePassShader) - -static bool js_scene_PipelineSharedSceneData_set_bloomDownsamplePassShader(se::State& s) // NOLINT(readability-identifier-naming) -{ - const auto& args = s.args(); - auto* cobj = SE_THIS_OBJECT(s); - SE_PRECONDITION2(cobj, false, "js_scene_PipelineSharedSceneData_set_bloomDownsamplePassShader : Invalid Native Object"); - - CC_UNUSED bool ok = true; - ok &= sevalue_to_native(args[0], &cobj->bloomDownsamplePassShader, s.thisObject()); - SE_PRECONDITION2(ok, false, "js_scene_PipelineSharedSceneData_set_bloomDownsamplePassShader : Error processing new value"); - return true; -} -SE_BIND_PROP_SET(js_scene_PipelineSharedSceneData_set_bloomDownsamplePassShader) - -static bool js_scene_PipelineSharedSceneData_get_bloomUpsamplePass(se::State& s) // NOLINT(readability-identifier-naming) -{ - auto* cobj = SE_THIS_OBJECT(s); - SE_PRECONDITION2(cobj, false, "js_scene_PipelineSharedSceneData_get_bloomUpsamplePass : Invalid Native Object"); - - CC_UNUSED bool ok = true; - se::Value jsret; - ok &= nativevalue_to_se(cobj->bloomUpsamplePass, jsret, s.thisObject() /*ctx*/); - s.rval() = jsret; - SE_HOLD_RETURN_VALUE(cobj->bloomUpsamplePass, s.thisObject(), s.rval()); - return true; -} -SE_BIND_PROP_GET(js_scene_PipelineSharedSceneData_get_bloomUpsamplePass) - -static bool js_scene_PipelineSharedSceneData_set_bloomUpsamplePass(se::State& s) // NOLINT(readability-identifier-naming) -{ - const auto& args = s.args(); - auto* cobj = SE_THIS_OBJECT(s); - SE_PRECONDITION2(cobj, false, "js_scene_PipelineSharedSceneData_set_bloomUpsamplePass : Invalid Native Object"); - - CC_UNUSED bool ok = true; - ok &= sevalue_to_native(args[0], &cobj->bloomUpsamplePass, s.thisObject()); - SE_PRECONDITION2(ok, false, "js_scene_PipelineSharedSceneData_set_bloomUpsamplePass : Error processing new value"); - return true; -} -SE_BIND_PROP_SET(js_scene_PipelineSharedSceneData_set_bloomUpsamplePass) - -static bool js_scene_PipelineSharedSceneData_get_bloomUpsamplePassShader(se::State& s) // NOLINT(readability-identifier-naming) -{ - auto* cobj = SE_THIS_OBJECT(s); - SE_PRECONDITION2(cobj, false, "js_scene_PipelineSharedSceneData_get_bloomUpsamplePassShader : Invalid Native Object"); - - CC_UNUSED bool ok = true; - se::Value jsret; - ok &= nativevalue_to_se(cobj->bloomUpsamplePassShader, jsret, s.thisObject() /*ctx*/); - s.rval() = jsret; - SE_HOLD_RETURN_VALUE(cobj->bloomUpsamplePassShader, s.thisObject(), s.rval()); - return true; -} -SE_BIND_PROP_GET(js_scene_PipelineSharedSceneData_get_bloomUpsamplePassShader) - -static bool js_scene_PipelineSharedSceneData_set_bloomUpsamplePassShader(se::State& s) // NOLINT(readability-identifier-naming) -{ - const auto& args = s.args(); - auto* cobj = SE_THIS_OBJECT(s); - SE_PRECONDITION2(cobj, false, "js_scene_PipelineSharedSceneData_set_bloomUpsamplePassShader : Invalid Native Object"); - - CC_UNUSED bool ok = true; - ok &= sevalue_to_native(args[0], &cobj->bloomUpsamplePassShader, s.thisObject()); - SE_PRECONDITION2(ok, false, "js_scene_PipelineSharedSceneData_set_bloomUpsamplePassShader : Error processing new value"); - return true; -} -SE_BIND_PROP_SET(js_scene_PipelineSharedSceneData_set_bloomUpsamplePassShader) - -static bool js_scene_PipelineSharedSceneData_get_bloomCombinePass(se::State& s) // NOLINT(readability-identifier-naming) -{ - auto* cobj = SE_THIS_OBJECT(s); - SE_PRECONDITION2(cobj, false, "js_scene_PipelineSharedSceneData_get_bloomCombinePass : Invalid Native Object"); - - CC_UNUSED bool ok = true; - se::Value jsret; - ok &= nativevalue_to_se(cobj->bloomCombinePass, jsret, s.thisObject() /*ctx*/); - s.rval() = jsret; - SE_HOLD_RETURN_VALUE(cobj->bloomCombinePass, s.thisObject(), s.rval()); - return true; -} -SE_BIND_PROP_GET(js_scene_PipelineSharedSceneData_get_bloomCombinePass) - -static bool js_scene_PipelineSharedSceneData_set_bloomCombinePass(se::State& s) // NOLINT(readability-identifier-naming) -{ - const auto& args = s.args(); - auto* cobj = SE_THIS_OBJECT(s); - SE_PRECONDITION2(cobj, false, "js_scene_PipelineSharedSceneData_set_bloomCombinePass : Invalid Native Object"); - - CC_UNUSED bool ok = true; - ok &= sevalue_to_native(args[0], &cobj->bloomCombinePass, s.thisObject()); - SE_PRECONDITION2(ok, false, "js_scene_PipelineSharedSceneData_set_bloomCombinePass : Error processing new value"); - return true; -} -SE_BIND_PROP_SET(js_scene_PipelineSharedSceneData_set_bloomCombinePass) - -static bool js_scene_PipelineSharedSceneData_get_bloomCombinePassShader(se::State& s) // NOLINT(readability-identifier-naming) -{ - auto* cobj = SE_THIS_OBJECT(s); - SE_PRECONDITION2(cobj, false, "js_scene_PipelineSharedSceneData_get_bloomCombinePassShader : Invalid Native Object"); - - CC_UNUSED bool ok = true; - se::Value jsret; - ok &= nativevalue_to_se(cobj->bloomCombinePassShader, jsret, s.thisObject() /*ctx*/); - s.rval() = jsret; - SE_HOLD_RETURN_VALUE(cobj->bloomCombinePassShader, s.thisObject(), s.rval()); - return true; -} -SE_BIND_PROP_GET(js_scene_PipelineSharedSceneData_get_bloomCombinePassShader) - -static bool js_scene_PipelineSharedSceneData_set_bloomCombinePassShader(se::State& s) // NOLINT(readability-identifier-naming) -{ - const auto& args = s.args(); - auto* cobj = SE_THIS_OBJECT(s); - SE_PRECONDITION2(cobj, false, "js_scene_PipelineSharedSceneData_set_bloomCombinePassShader : Invalid Native Object"); - - CC_UNUSED bool ok = true; - ok &= sevalue_to_native(args[0], &cobj->bloomCombinePassShader, s.thisObject()); - SE_PRECONDITION2(ok, false, "js_scene_PipelineSharedSceneData_set_bloomCombinePassShader : Error processing new value"); - return true; -} -SE_BIND_PROP_SET(js_scene_PipelineSharedSceneData_set_bloomCombinePassShader) - -static bool js_scene_PipelineSharedSceneData_get_pipelinePostPass(se::State& s) // NOLINT(readability-identifier-naming) -{ - auto* cobj = SE_THIS_OBJECT(s); - SE_PRECONDITION2(cobj, false, "js_scene_PipelineSharedSceneData_get_pipelinePostPass : Invalid Native Object"); - - CC_UNUSED bool ok = true; - se::Value jsret; - ok &= nativevalue_to_se(cobj->pipelinePostPass, jsret, s.thisObject() /*ctx*/); - s.rval() = jsret; - SE_HOLD_RETURN_VALUE(cobj->pipelinePostPass, s.thisObject(), s.rval()); - return true; -} -SE_BIND_PROP_GET(js_scene_PipelineSharedSceneData_get_pipelinePostPass) - -static bool js_scene_PipelineSharedSceneData_set_pipelinePostPass(se::State& s) // NOLINT(readability-identifier-naming) -{ - const auto& args = s.args(); - auto* cobj = SE_THIS_OBJECT(s); - SE_PRECONDITION2(cobj, false, "js_scene_PipelineSharedSceneData_set_pipelinePostPass : Invalid Native Object"); - - CC_UNUSED bool ok = true; - ok &= sevalue_to_native(args[0], &cobj->pipelinePostPass, s.thisObject()); - SE_PRECONDITION2(ok, false, "js_scene_PipelineSharedSceneData_set_pipelinePostPass : Error processing new value"); - return true; -} -SE_BIND_PROP_SET(js_scene_PipelineSharedSceneData_set_pipelinePostPass) - -static bool js_scene_PipelineSharedSceneData_get_pipelinePostPassShader(se::State& s) // NOLINT(readability-identifier-naming) -{ - auto* cobj = SE_THIS_OBJECT(s); - SE_PRECONDITION2(cobj, false, "js_scene_PipelineSharedSceneData_get_pipelinePostPassShader : Invalid Native Object"); - - CC_UNUSED bool ok = true; - se::Value jsret; - ok &= nativevalue_to_se(cobj->pipelinePostPassShader, jsret, s.thisObject() /*ctx*/); - s.rval() = jsret; - SE_HOLD_RETURN_VALUE(cobj->pipelinePostPassShader, s.thisObject(), s.rval()); - return true; -} -SE_BIND_PROP_GET(js_scene_PipelineSharedSceneData_get_pipelinePostPassShader) - -static bool js_scene_PipelineSharedSceneData_set_pipelinePostPassShader(se::State& s) // NOLINT(readability-identifier-naming) -{ - const auto& args = s.args(); - auto* cobj = SE_THIS_OBJECT(s); - SE_PRECONDITION2(cobj, false, "js_scene_PipelineSharedSceneData_set_pipelinePostPassShader : Invalid Native Object"); - - CC_UNUSED bool ok = true; - ok &= sevalue_to_native(args[0], &cobj->pipelinePostPassShader, s.thisObject()); - SE_PRECONDITION2(ok, false, "js_scene_PipelineSharedSceneData_set_pipelinePostPassShader : Error processing new value"); - return true; -} -SE_BIND_PROP_SET(js_scene_PipelineSharedSceneData_set_pipelinePostPassShader) - - -template<> -bool sevalue_to_native(const se::Value &from, cc::scene::PipelineSharedSceneData * to, se::Object *ctx) -{ - assert(from.isObject()); - se::Object *json = from.toObject(); - auto* data = reinterpret_cast(json->getPrivateData()); - if (data) { - *to = *data; - return true; - } - se::Value field; - bool ok = true; - json->getProperty("isHDR", &field); - if(!field.isNullOrUndefined()) { - ok &= sevalue_to_native(field, &(to->isHDR), ctx); - } - json->getProperty("shadingScale", &field); - if(!field.isNullOrUndefined()) { - ok &= sevalue_to_native(field, &(to->shadingScale), ctx); - } - json->getProperty("ambient", &field); - if(!field.isNullOrUndefined()) { - ok &= sevalue_to_native(field, &(to->ambient), ctx); - } - json->getProperty("shadow", &field); - if(!field.isNullOrUndefined()) { - ok &= sevalue_to_native(field, &(to->shadow), ctx); - } - json->getProperty("skybox", &field); - if(!field.isNullOrUndefined()) { - ok &= sevalue_to_native(field, &(to->skybox), ctx); - } - json->getProperty("fog", &field); - if(!field.isNullOrUndefined()) { - ok &= sevalue_to_native(field, &(to->fog), ctx); - } - json->getProperty("octree", &field); - if(!field.isNullOrUndefined()) { - ok &= sevalue_to_native(field, &(to->octree), ctx); - } - json->getProperty("geometryRendererPasses", &field); - if(!field.isNullOrUndefined()) { - ok &= sevalue_to_native(field, &(to->geometryRendererPasses), ctx); - } - json->getProperty("geometryRendererShaders", &field); - if(!field.isNullOrUndefined()) { - ok &= sevalue_to_native(field, &(to->geometryRendererShaders), ctx); - } - json->getProperty("occlusionQueryInputAssembler", &field); - if(!field.isNullOrUndefined()) { - ok &= sevalue_to_native(field, &(to->occlusionQueryInputAssembler), ctx); - } - json->getProperty("occlusionQueryPass", &field); - if(!field.isNullOrUndefined()) { - ok &= sevalue_to_native(field, &(to->occlusionQueryPass), ctx); - } - json->getProperty("occlusionQueryShader", &field); - if(!field.isNullOrUndefined()) { - ok &= sevalue_to_native(field, &(to->occlusionQueryShader), ctx); - } - json->getProperty("deferredLightPass", &field); - if(!field.isNullOrUndefined()) { - ok &= sevalue_to_native(field, &(to->deferredLightPass), ctx); - } - json->getProperty("deferredLightPassShader", &field); - if(!field.isNullOrUndefined()) { - ok &= sevalue_to_native(field, &(to->deferredLightPassShader), ctx); - } - json->getProperty("bloomPrefilterPass", &field); - if(!field.isNullOrUndefined()) { - ok &= sevalue_to_native(field, &(to->bloomPrefilterPass), ctx); - } - json->getProperty("bloomPrefilterPassShader", &field); - if(!field.isNullOrUndefined()) { - ok &= sevalue_to_native(field, &(to->bloomPrefilterPassShader), ctx); - } - json->getProperty("bloomDownsamplePass", &field); - if(!field.isNullOrUndefined()) { - ok &= sevalue_to_native(field, &(to->bloomDownsamplePass), ctx); - } - json->getProperty("bloomDownsamplePassShader", &field); - if(!field.isNullOrUndefined()) { - ok &= sevalue_to_native(field, &(to->bloomDownsamplePassShader), ctx); - } - json->getProperty("bloomUpsamplePass", &field); - if(!field.isNullOrUndefined()) { - ok &= sevalue_to_native(field, &(to->bloomUpsamplePass), ctx); - } - json->getProperty("bloomUpsamplePassShader", &field); - if(!field.isNullOrUndefined()) { - ok &= sevalue_to_native(field, &(to->bloomUpsamplePassShader), ctx); - } - json->getProperty("bloomCombinePass", &field); - if(!field.isNullOrUndefined()) { - ok &= sevalue_to_native(field, &(to->bloomCombinePass), ctx); - } - json->getProperty("bloomCombinePassShader", &field); - if(!field.isNullOrUndefined()) { - ok &= sevalue_to_native(field, &(to->bloomCombinePassShader), ctx); - } - json->getProperty("pipelinePostPass", &field); - if(!field.isNullOrUndefined()) { - ok &= sevalue_to_native(field, &(to->pipelinePostPass), ctx); - } - json->getProperty("pipelinePostPassShader", &field); - if(!field.isNullOrUndefined()) { - ok &= sevalue_to_native(field, &(to->pipelinePostPassShader), ctx); - } - return ok; -} - -SE_DECLARE_FINALIZE_FUNC(js_cc_scene_PipelineSharedSceneData_finalize) - -static bool js_scene_PipelineSharedSceneData_constructor(se::State& s) // NOLINT(readability-identifier-naming) -{ - CC_UNUSED bool ok = true; - const auto& args = s.args(); - size_t argc = args.size(); - - if(argc == 0) - { - cc::scene::PipelineSharedSceneData* cobj = JSB_ALLOC(cc::scene::PipelineSharedSceneData); - s.thisObject()->setPrivateData(cobj); - se::NonRefNativePtrCreatedByCtorMap::emplace(cobj); - return true; - } - - if(argc == 1 && args[0].isObject()) - { - se::Object *json = args[0].toObject(); - se::Value field; - - cc::scene::PipelineSharedSceneData* cobj = JSB_ALLOC(cc::scene::PipelineSharedSceneData); - ok &= sevalue_to_native(args[0], cobj, s.thisObject()); - if(!ok) { - JSB_FREE(cobj); - SE_REPORT_ERROR("argument convertion error"); - return false; - } - - s.thisObject()->setPrivateData(cobj); - se::NonRefNativePtrCreatedByCtorMap::emplace(cobj); - return true; - } - - cc::scene::PipelineSharedSceneData* cobj = JSB_ALLOC(cc::scene::PipelineSharedSceneData); - if (argc > 0 && !args[0].isUndefined()) { - ok &= sevalue_to_native(args[0], &(cobj->isHDR), nullptr); - } - if (argc > 1 && !args[1].isUndefined()) { - ok &= sevalue_to_native(args[1], &(cobj->shadingScale), nullptr); - } - if (argc > 2 && !args[2].isUndefined()) { - ok &= sevalue_to_native(args[2], &(cobj->ambient), nullptr); - } - if (argc > 3 && !args[3].isUndefined()) { - ok &= sevalue_to_native(args[3], &(cobj->shadow), nullptr); - } - if (argc > 4 && !args[4].isUndefined()) { - ok &= sevalue_to_native(args[4], &(cobj->skybox), nullptr); - } - if (argc > 5 && !args[5].isUndefined()) { - ok &= sevalue_to_native(args[5], &(cobj->fog), nullptr); - } - if (argc > 6 && !args[6].isUndefined()) { - ok &= sevalue_to_native(args[6], &(cobj->octree), nullptr); - } - if (argc > 7 && !args[7].isUndefined()) { - ok &= sevalue_to_native(args[7], &(cobj->geometryRendererPasses), nullptr); - } - if (argc > 8 && !args[8].isUndefined()) { - ok &= sevalue_to_native(args[8], &(cobj->geometryRendererShaders), nullptr); - } - if (argc > 9 && !args[9].isUndefined()) { - ok &= sevalue_to_native(args[9], &(cobj->occlusionQueryInputAssembler), nullptr); - } - if (argc > 10 && !args[10].isUndefined()) { - ok &= sevalue_to_native(args[10], &(cobj->occlusionQueryPass), nullptr); - } - if (argc > 11 && !args[11].isUndefined()) { - ok &= sevalue_to_native(args[11], &(cobj->occlusionQueryShader), nullptr); - } - if (argc > 12 && !args[12].isUndefined()) { - ok &= sevalue_to_native(args[12], &(cobj->deferredLightPass), nullptr); - } - if (argc > 13 && !args[13].isUndefined()) { - ok &= sevalue_to_native(args[13], &(cobj->deferredLightPassShader), nullptr); - } - if (argc > 14 && !args[14].isUndefined()) { - ok &= sevalue_to_native(args[14], &(cobj->bloomPrefilterPass), nullptr); - } - if (argc > 15 && !args[15].isUndefined()) { - ok &= sevalue_to_native(args[15], &(cobj->bloomPrefilterPassShader), nullptr); - } - if (argc > 16 && !args[16].isUndefined()) { - ok &= sevalue_to_native(args[16], &(cobj->bloomDownsamplePass), nullptr); - } - if (argc > 17 && !args[17].isUndefined()) { - ok &= sevalue_to_native(args[17], &(cobj->bloomDownsamplePassShader), nullptr); - } - if (argc > 18 && !args[18].isUndefined()) { - ok &= sevalue_to_native(args[18], &(cobj->bloomUpsamplePass), nullptr); - } - if (argc > 19 && !args[19].isUndefined()) { - ok &= sevalue_to_native(args[19], &(cobj->bloomUpsamplePassShader), nullptr); - } - if (argc > 20 && !args[20].isUndefined()) { - ok &= sevalue_to_native(args[20], &(cobj->bloomCombinePass), nullptr); - } - if (argc > 21 && !args[21].isUndefined()) { - ok &= sevalue_to_native(args[21], &(cobj->bloomCombinePassShader), nullptr); - } - if (argc > 22 && !args[22].isUndefined()) { - ok &= sevalue_to_native(args[22], &(cobj->pipelinePostPass), nullptr); - } - if (argc > 23 && !args[23].isUndefined()) { - ok &= sevalue_to_native(args[23], &(cobj->pipelinePostPassShader), nullptr); - } - - if(!ok) { - JSB_FREE(cobj); - SE_REPORT_ERROR("Argument convertion error"); - return false; - } - - s.thisObject()->setPrivateData(cobj); - se::NonRefNativePtrCreatedByCtorMap::emplace(cobj); - return true; -} -SE_BIND_CTOR(js_scene_PipelineSharedSceneData_constructor, __jsb_cc_scene_PipelineSharedSceneData_class, js_cc_scene_PipelineSharedSceneData_finalize) - - - -static bool js_cc_scene_PipelineSharedSceneData_finalize(se::State& s) // NOLINT(readability-identifier-naming) -{ - auto iter = se::NonRefNativePtrCreatedByCtorMap::find(SE_THIS_OBJECT(s)); - if (iter != se::NonRefNativePtrCreatedByCtorMap::end()) - { - se::NonRefNativePtrCreatedByCtorMap::erase(iter); - auto* cobj = SE_THIS_OBJECT(s); - JSB_FREE(cobj); - } - return true; -} -SE_BIND_FINALIZE_FUNC(js_cc_scene_PipelineSharedSceneData_finalize) - -bool js_register_scene_PipelineSharedSceneData(se::Object* obj) // NOLINT(readability-identifier-naming) -{ - auto* cls = se::Class::create("PipelineSharedSceneData", obj, nullptr, _SE(js_scene_PipelineSharedSceneData_constructor)); - - cls->defineProperty("isHDR", _SE(js_scene_PipelineSharedSceneData_get_isHDR), _SE(js_scene_PipelineSharedSceneData_set_isHDR)); - cls->defineProperty("shadingScale", _SE(js_scene_PipelineSharedSceneData_get_shadingScale), _SE(js_scene_PipelineSharedSceneData_set_shadingScale)); - cls->defineProperty("ambient", _SE(js_scene_PipelineSharedSceneData_get_ambient), _SE(js_scene_PipelineSharedSceneData_set_ambient)); - cls->defineProperty("shadow", _SE(js_scene_PipelineSharedSceneData_get_shadow), _SE(js_scene_PipelineSharedSceneData_set_shadow)); - cls->defineProperty("skybox", _SE(js_scene_PipelineSharedSceneData_get_skybox), _SE(js_scene_PipelineSharedSceneData_set_skybox)); - cls->defineProperty("fog", _SE(js_scene_PipelineSharedSceneData_get_fog), _SE(js_scene_PipelineSharedSceneData_set_fog)); - cls->defineProperty("octree", _SE(js_scene_PipelineSharedSceneData_get_octree), _SE(js_scene_PipelineSharedSceneData_set_octree)); - cls->defineProperty("geometryRendererPasses", _SE(js_scene_PipelineSharedSceneData_get_geometryRendererPasses), _SE(js_scene_PipelineSharedSceneData_set_geometryRendererPasses)); - cls->defineProperty("geometryRendererShaders", _SE(js_scene_PipelineSharedSceneData_get_geometryRendererShaders), _SE(js_scene_PipelineSharedSceneData_set_geometryRendererShaders)); - cls->defineProperty("occlusionQueryInputAssembler", _SE(js_scene_PipelineSharedSceneData_get_occlusionQueryInputAssembler), _SE(js_scene_PipelineSharedSceneData_set_occlusionQueryInputAssembler)); - cls->defineProperty("occlusionQueryPass", _SE(js_scene_PipelineSharedSceneData_get_occlusionQueryPass), _SE(js_scene_PipelineSharedSceneData_set_occlusionQueryPass)); - cls->defineProperty("occlusionQueryShader", _SE(js_scene_PipelineSharedSceneData_get_occlusionQueryShader), _SE(js_scene_PipelineSharedSceneData_set_occlusionQueryShader)); - cls->defineProperty("deferredLightPass", _SE(js_scene_PipelineSharedSceneData_get_deferredLightPass), _SE(js_scene_PipelineSharedSceneData_set_deferredLightPass)); - cls->defineProperty("deferredLightPassShader", _SE(js_scene_PipelineSharedSceneData_get_deferredLightPassShader), _SE(js_scene_PipelineSharedSceneData_set_deferredLightPassShader)); - cls->defineProperty("bloomPrefilterPass", _SE(js_scene_PipelineSharedSceneData_get_bloomPrefilterPass), _SE(js_scene_PipelineSharedSceneData_set_bloomPrefilterPass)); - cls->defineProperty("bloomPrefilterPassShader", _SE(js_scene_PipelineSharedSceneData_get_bloomPrefilterPassShader), _SE(js_scene_PipelineSharedSceneData_set_bloomPrefilterPassShader)); - cls->defineProperty("bloomDownsamplePass", _SE(js_scene_PipelineSharedSceneData_get_bloomDownsamplePass), _SE(js_scene_PipelineSharedSceneData_set_bloomDownsamplePass)); - cls->defineProperty("bloomDownsamplePassShader", _SE(js_scene_PipelineSharedSceneData_get_bloomDownsamplePassShader), _SE(js_scene_PipelineSharedSceneData_set_bloomDownsamplePassShader)); - cls->defineProperty("bloomUpsamplePass", _SE(js_scene_PipelineSharedSceneData_get_bloomUpsamplePass), _SE(js_scene_PipelineSharedSceneData_set_bloomUpsamplePass)); - cls->defineProperty("bloomUpsamplePassShader", _SE(js_scene_PipelineSharedSceneData_get_bloomUpsamplePassShader), _SE(js_scene_PipelineSharedSceneData_set_bloomUpsamplePassShader)); - cls->defineProperty("bloomCombinePass", _SE(js_scene_PipelineSharedSceneData_get_bloomCombinePass), _SE(js_scene_PipelineSharedSceneData_set_bloomCombinePass)); - cls->defineProperty("bloomCombinePassShader", _SE(js_scene_PipelineSharedSceneData_get_bloomCombinePassShader), _SE(js_scene_PipelineSharedSceneData_set_bloomCombinePassShader)); - cls->defineProperty("pipelinePostPass", _SE(js_scene_PipelineSharedSceneData_get_pipelinePostPass), _SE(js_scene_PipelineSharedSceneData_set_pipelinePostPass)); - cls->defineProperty("pipelinePostPassShader", _SE(js_scene_PipelineSharedSceneData_get_pipelinePostPassShader), _SE(js_scene_PipelineSharedSceneData_set_pipelinePostPassShader)); - cls->defineFinalizeFunction(_SE(js_cc_scene_PipelineSharedSceneData_finalize)); - cls->install(); - JSBClassType::registerClass(cls); - - __jsb_cc_scene_PipelineSharedSceneData_proto = cls->getProto(); - __jsb_cc_scene_PipelineSharedSceneData_class = cls; - - se::ScriptEngine::getInstance()->clearException(); - return true; -} -se::Object* __jsb_cc_scene_Root_proto = nullptr; -se::Class* __jsb_cc_scene_Root_class = nullptr; - -static bool js_scene_Root_get_cumulativeTime(se::State& s) // NOLINT(readability-identifier-naming) -{ - auto* cobj = SE_THIS_OBJECT(s); - SE_PRECONDITION2(cobj, false, "js_scene_Root_get_cumulativeTime : Invalid Native Object"); - - CC_UNUSED bool ok = true; - se::Value jsret; - ok &= nativevalue_to_se(cobj->cumulativeTime, jsret, s.thisObject() /*ctx*/); - s.rval() = jsret; - SE_HOLD_RETURN_VALUE(cobj->cumulativeTime, s.thisObject(), s.rval()); - return true; -} -SE_BIND_PROP_GET(js_scene_Root_get_cumulativeTime) - -static bool js_scene_Root_set_cumulativeTime(se::State& s) // NOLINT(readability-identifier-naming) -{ - const auto& args = s.args(); - auto* cobj = SE_THIS_OBJECT(s); - SE_PRECONDITION2(cobj, false, "js_scene_Root_set_cumulativeTime : Invalid Native Object"); - - CC_UNUSED bool ok = true; - ok &= sevalue_to_native(args[0], &cobj->cumulativeTime, s.thisObject()); - SE_PRECONDITION2(ok, false, "js_scene_Root_set_cumulativeTime : Error processing new value"); - return true; -} -SE_BIND_PROP_SET(js_scene_Root_set_cumulativeTime) - -static bool js_scene_Root_get_frameTime(se::State& s) // NOLINT(readability-identifier-naming) -{ - auto* cobj = SE_THIS_OBJECT(s); - SE_PRECONDITION2(cobj, false, "js_scene_Root_get_frameTime : Invalid Native Object"); - - CC_UNUSED bool ok = true; - se::Value jsret; - ok &= nativevalue_to_se(cobj->frameTime, jsret, s.thisObject() /*ctx*/); - s.rval() = jsret; - SE_HOLD_RETURN_VALUE(cobj->frameTime, s.thisObject(), s.rval()); - return true; -} -SE_BIND_PROP_GET(js_scene_Root_get_frameTime) - -static bool js_scene_Root_set_frameTime(se::State& s) // NOLINT(readability-identifier-naming) -{ - const auto& args = s.args(); - auto* cobj = SE_THIS_OBJECT(s); - SE_PRECONDITION2(cobj, false, "js_scene_Root_set_frameTime : Invalid Native Object"); - - CC_UNUSED bool ok = true; - ok &= sevalue_to_native(args[0], &cobj->frameTime, s.thisObject()); - SE_PRECONDITION2(ok, false, "js_scene_Root_set_frameTime : Error processing new value"); - return true; -} -SE_BIND_PROP_SET(js_scene_Root_set_frameTime) - - -template<> -bool sevalue_to_native(const se::Value &from, cc::scene::Root * to, se::Object *ctx) -{ - assert(from.isObject()); - se::Object *json = from.toObject(); - auto* data = reinterpret_cast(json->getPrivateData()); - if (data) { - *to = *data; - return true; - } - se::Value field; - bool ok = true; - json->getProperty("cumulativeTime", &field); - if(!field.isNullOrUndefined()) { - ok &= sevalue_to_native(field, &(to->cumulativeTime), ctx); - } - json->getProperty("frameTime", &field); - if(!field.isNullOrUndefined()) { - ok &= sevalue_to_native(field, &(to->frameTime), ctx); - } - return ok; -} - -SE_DECLARE_FINALIZE_FUNC(js_cc_scene_Root_finalize) - -static bool js_scene_Root_constructor(se::State& s) // NOLINT(readability-identifier-naming) -{ - CC_UNUSED bool ok = true; - const auto& args = s.args(); - size_t argc = args.size(); - - if(argc == 0) - { - cc::scene::Root* cobj = JSB_ALLOC(cc::scene::Root); - s.thisObject()->setPrivateData(cobj); - se::NonRefNativePtrCreatedByCtorMap::emplace(cobj); - return true; - } - - if(argc == 1 && args[0].isObject()) - { - se::Object *json = args[0].toObject(); - se::Value field; - - cc::scene::Root* cobj = JSB_ALLOC(cc::scene::Root); - ok &= sevalue_to_native(args[0], cobj, s.thisObject()); - if(!ok) { - JSB_FREE(cobj); - SE_REPORT_ERROR("argument convertion error"); - return false; - } - - s.thisObject()->setPrivateData(cobj); - se::NonRefNativePtrCreatedByCtorMap::emplace(cobj); - return true; - } - - cc::scene::Root* cobj = JSB_ALLOC(cc::scene::Root); - if (argc > 0 && !args[0].isUndefined()) { - ok &= sevalue_to_native(args[0], &(cobj->cumulativeTime), nullptr); - } - if (argc > 1 && !args[1].isUndefined()) { - ok &= sevalue_to_native(args[1], &(cobj->frameTime), nullptr); - } - - if(!ok) { - JSB_FREE(cobj); - SE_REPORT_ERROR("Argument convertion error"); - return false; - } - - s.thisObject()->setPrivateData(cobj); - se::NonRefNativePtrCreatedByCtorMap::emplace(cobj); - return true; -} -SE_BIND_CTOR(js_scene_Root_constructor, __jsb_cc_scene_Root_class, js_cc_scene_Root_finalize) - - - -static bool js_cc_scene_Root_finalize(se::State& s) // NOLINT(readability-identifier-naming) -{ - auto iter = se::NonRefNativePtrCreatedByCtorMap::find(SE_THIS_OBJECT(s)); - if (iter != se::NonRefNativePtrCreatedByCtorMap::end()) - { - se::NonRefNativePtrCreatedByCtorMap::erase(iter); - auto* cobj = SE_THIS_OBJECT(s); - JSB_FREE(cobj); - } - return true; -} -SE_BIND_FINALIZE_FUNC(js_cc_scene_Root_finalize) - -bool js_register_scene_Root(se::Object* obj) // NOLINT(readability-identifier-naming) -{ - auto* cls = se::Class::create("Root", obj, nullptr, _SE(js_scene_Root_constructor)); - - cls->defineProperty("cumulativeTime", _SE(js_scene_Root_get_cumulativeTime), _SE(js_scene_Root_set_cumulativeTime)); - cls->defineProperty("frameTime", _SE(js_scene_Root_get_frameTime), _SE(js_scene_Root_set_frameTime)); - cls->defineFinalizeFunction(_SE(js_cc_scene_Root_finalize)); - cls->install(); - JSBClassType::registerClass(cls); - - __jsb_cc_scene_Root_proto = cls->getProto(); - __jsb_cc_scene_Root_class = cls; - - se::ScriptEngine::getInstance()->clearException(); - return true; -} -se::Object* __jsb_cc_scene_SubModel_proto = nullptr; -se::Class* __jsb_cc_scene_SubModel_class = nullptr; - -static bool js_scene_SubModel_getId(se::State& s) // NOLINT(readability-identifier-naming) -{ - auto* cobj = SE_THIS_OBJECT(s); - SE_PRECONDITION2(cobj, false, "js_scene_SubModel_getId : Invalid Native Object"); - const auto& args = s.args(); - size_t argc = args.size(); - CC_UNUSED bool ok = true; - if (argc == 0) { - unsigned int result = cobj->getId(); - ok &= nativevalue_to_se(result, s.rval(), nullptr /*ctx*/); - SE_PRECONDITION2(ok, false, "js_scene_SubModel_getId : Error processing arguments"); - SE_HOLD_RETURN_VALUE(result, s.thisObject(), s.rval()); - return true; - } - SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 0); - return false; -} -SE_BIND_FUNC(js_scene_SubModel_getId) - -static bool js_scene_SubModel_getOwner(se::State& s) // NOLINT(readability-identifier-naming) -{ - auto* cobj = SE_THIS_OBJECT(s); - SE_PRECONDITION2(cobj, false, "js_scene_SubModel_getOwner : Invalid Native Object"); - const auto& args = s.args(); - size_t argc = args.size(); - CC_UNUSED bool ok = true; - if (argc == 0) { - cc::scene::Model* result = cobj->getOwner(); - ok &= nativevalue_to_se(result, s.rval(), nullptr /*ctx*/); - SE_PRECONDITION2(ok, false, "js_scene_SubModel_getOwner : Error processing arguments"); - SE_HOLD_RETURN_VALUE(result, s.thisObject(), s.rval()); - return true; - } - SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 0); - return false; -} -SE_BIND_FUNC(js_scene_SubModel_getOwner) - -static bool js_scene_SubModel_getPass(se::State& s) // NOLINT(readability-identifier-naming) -{ - auto* cobj = SE_THIS_OBJECT(s); - SE_PRECONDITION2(cobj, false, "js_scene_SubModel_getPass : Invalid Native Object"); - const auto& args = s.args(); - size_t argc = args.size(); - CC_UNUSED bool ok = true; - if (argc == 1) { - HolderType arg0 = {}; - ok &= sevalue_to_native(args[0], &arg0, s.thisObject()); - SE_PRECONDITION2(ok, false, "js_scene_SubModel_getPass : Error processing arguments"); - cc::scene::Pass* result = cobj->getPass(arg0.value()); - ok &= nativevalue_to_se(result, s.rval(), nullptr /*ctx*/); - SE_PRECONDITION2(ok, false, "js_scene_SubModel_getPass : Error processing arguments"); - SE_HOLD_RETURN_VALUE(result, s.thisObject(), s.rval()); - return true; - } - SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 1); - return false; -} -SE_BIND_FUNC(js_scene_SubModel_getPass) - -static bool js_scene_SubModel_getPasses(se::State& s) // NOLINT(readability-identifier-naming) -{ - auto* cobj = SE_THIS_OBJECT(s); - SE_PRECONDITION2(cobj, false, "js_scene_SubModel_getPasses : Invalid Native Object"); - const auto& args = s.args(); - size_t argc = args.size(); - CC_UNUSED bool ok = true; - if (argc == 0) { - const std::vector& result = cobj->getPasses(); - ok &= nativevalue_to_se(result, s.rval(), nullptr /*ctx*/); - SE_PRECONDITION2(ok, false, "js_scene_SubModel_getPasses : Error processing arguments"); - SE_HOLD_RETURN_VALUE(result, s.thisObject(), s.rval()); - return true; - } - SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 0); - return false; -} -SE_BIND_FUNC(js_scene_SubModel_getPasses) - -static bool js_scene_SubModel_getPlanarInstanceShader(se::State& s) // NOLINT(readability-identifier-naming) -{ - auto* cobj = SE_THIS_OBJECT(s); - SE_PRECONDITION2(cobj, false, "js_scene_SubModel_getPlanarInstanceShader : Invalid Native Object"); - const auto& args = s.args(); - size_t argc = args.size(); - CC_UNUSED bool ok = true; - if (argc == 0) { - cc::gfx::Shader* result = cobj->getPlanarInstanceShader(); - ok &= nativevalue_to_se(result, s.rval(), nullptr /*ctx*/); - SE_PRECONDITION2(ok, false, "js_scene_SubModel_getPlanarInstanceShader : Error processing arguments"); - SE_HOLD_RETURN_VALUE(result, s.thisObject(), s.rval()); - return true; - } - SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 0); - return false; -} -SE_BIND_FUNC(js_scene_SubModel_getPlanarInstanceShader) - -static bool js_scene_SubModel_getPlanarShader(se::State& s) // NOLINT(readability-identifier-naming) -{ - auto* cobj = SE_THIS_OBJECT(s); - SE_PRECONDITION2(cobj, false, "js_scene_SubModel_getPlanarShader : Invalid Native Object"); - const auto& args = s.args(); - size_t argc = args.size(); - CC_UNUSED bool ok = true; - if (argc == 0) { - cc::gfx::Shader* result = cobj->getPlanarShader(); - ok &= nativevalue_to_se(result, s.rval(), nullptr /*ctx*/); - SE_PRECONDITION2(ok, false, "js_scene_SubModel_getPlanarShader : Error processing arguments"); - SE_HOLD_RETURN_VALUE(result, s.thisObject(), s.rval()); - return true; - } - SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 0); - return false; -} -SE_BIND_FUNC(js_scene_SubModel_getPlanarShader) - -static bool js_scene_SubModel_getPriority(se::State& s) // NOLINT(readability-identifier-naming) -{ - auto* cobj = SE_THIS_OBJECT(s); - SE_PRECONDITION2(cobj, false, "js_scene_SubModel_getPriority : Invalid Native Object"); - const auto& args = s.args(); - size_t argc = args.size(); - CC_UNUSED bool ok = true; - if (argc == 0) { - auto result = static_cast(cobj->getPriority()); - ok &= nativevalue_to_se(result, s.rval(), nullptr /*ctx*/); - SE_PRECONDITION2(ok, false, "js_scene_SubModel_getPriority : Error processing arguments"); - SE_HOLD_RETURN_VALUE(result, s.thisObject(), s.rval()); - return true; - } - SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 0); - return false; -} -SE_BIND_FUNC(js_scene_SubModel_getPriority) - -static bool js_scene_SubModel_getShader(se::State& s) // NOLINT(readability-identifier-naming) -{ - auto* cobj = SE_THIS_OBJECT(s); - SE_PRECONDITION2(cobj, false, "js_scene_SubModel_getShader : Invalid Native Object"); - const auto& args = s.args(); - size_t argc = args.size(); - CC_UNUSED bool ok = true; - if (argc == 1) { - HolderType arg0 = {}; - ok &= sevalue_to_native(args[0], &arg0, s.thisObject()); - SE_PRECONDITION2(ok, false, "js_scene_SubModel_getShader : Error processing arguments"); - cc::gfx::Shader* result = cobj->getShader(arg0.value()); - ok &= nativevalue_to_se(result, s.rval(), nullptr /*ctx*/); - SE_PRECONDITION2(ok, false, "js_scene_SubModel_getShader : Error processing arguments"); - SE_HOLD_RETURN_VALUE(result, s.thisObject(), s.rval()); - return true; - } - SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 1); - return false; -} -SE_BIND_FUNC(js_scene_SubModel_getShader) - -static bool js_scene_SubModel_getShaders(se::State& s) // NOLINT(readability-identifier-naming) -{ - auto* cobj = SE_THIS_OBJECT(s); - SE_PRECONDITION2(cobj, false, "js_scene_SubModel_getShaders : Invalid Native Object"); - const auto& args = s.args(); - size_t argc = args.size(); - CC_UNUSED bool ok = true; - if (argc == 0) { - std::vector& result = cobj->getShaders(); - ok &= nativevalue_to_se(result, s.rval(), nullptr /*ctx*/); - SE_PRECONDITION2(ok, false, "js_scene_SubModel_getShaders : Error processing arguments"); - SE_HOLD_RETURN_VALUE(result, s.thisObject(), s.rval()); - return true; - } - SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 0); - return false; -} -SE_BIND_FUNC(js_scene_SubModel_getShaders) - -static bool js_scene_SubModel_getWorldBoundDescriptorSet(se::State& s) // NOLINT(readability-identifier-naming) -{ - auto* cobj = SE_THIS_OBJECT(s); - SE_PRECONDITION2(cobj, false, "js_scene_SubModel_getWorldBoundDescriptorSet : Invalid Native Object"); - const auto& args = s.args(); - size_t argc = args.size(); - CC_UNUSED bool ok = true; - if (argc == 0) { - cc::gfx::DescriptorSet* result = cobj->getWorldBoundDescriptorSet(); - ok &= nativevalue_to_se(result, s.rval(), nullptr /*ctx*/); - SE_PRECONDITION2(ok, false, "js_scene_SubModel_getWorldBoundDescriptorSet : Error processing arguments"); - SE_HOLD_RETURN_VALUE(result, s.thisObject(), s.rval()); - return true; - } - SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 0); - return false; -} -SE_BIND_FUNC(js_scene_SubModel_getWorldBoundDescriptorSet) - -static bool js_scene_SubModel_setDescriptorSet(se::State& s) // NOLINT(readability-identifier-naming) -{ - auto* cobj = SE_THIS_OBJECT(s); - SE_PRECONDITION2(cobj, false, "js_scene_SubModel_setDescriptorSet : Invalid Native Object"); - const auto& args = s.args(); - size_t argc = args.size(); - CC_UNUSED bool ok = true; - if (argc == 1) { - HolderType arg0 = {}; - ok &= sevalue_to_native(args[0], &arg0, s.thisObject()); - SE_PRECONDITION2(ok, false, "js_scene_SubModel_setDescriptorSet : Error processing arguments"); - cobj->setDescriptorSet(arg0.value()); - return true; - } - SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 1); - return false; -} -SE_BIND_FUNC(js_scene_SubModel_setDescriptorSet) - -static bool js_scene_SubModel_setInputAssembler(se::State& s) // NOLINT(readability-identifier-naming) -{ - auto* cobj = SE_THIS_OBJECT(s); - SE_PRECONDITION2(cobj, false, "js_scene_SubModel_setInputAssembler : Invalid Native Object"); - const auto& args = s.args(); - size_t argc = args.size(); - CC_UNUSED bool ok = true; - if (argc == 1) { - HolderType arg0 = {}; - ok &= sevalue_to_native(args[0], &arg0, s.thisObject()); - SE_PRECONDITION2(ok, false, "js_scene_SubModel_setInputAssembler : Error processing arguments"); - cobj->setInputAssembler(arg0.value()); - return true; - } - SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 1); - return false; -} -SE_BIND_FUNC(js_scene_SubModel_setInputAssembler) - -static bool js_scene_SubModel_setOwner(se::State& s) // NOLINT(readability-identifier-naming) -{ - auto* cobj = SE_THIS_OBJECT(s); - SE_PRECONDITION2(cobj, false, "js_scene_SubModel_setOwner : Invalid Native Object"); - const auto& args = s.args(); - size_t argc = args.size(); - CC_UNUSED bool ok = true; - if (argc == 1) { - HolderType arg0 = {}; - ok &= sevalue_to_native(args[0], &arg0, s.thisObject()); - SE_PRECONDITION2(ok, false, "js_scene_SubModel_setOwner : Error processing arguments"); - cobj->setOwner(arg0.value()); - return true; - } - SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 1); - return false; -} -SE_BIND_FUNC(js_scene_SubModel_setOwner) - -static bool js_scene_SubModel_setPasses(se::State& s) // NOLINT(readability-identifier-naming) -{ - auto* cobj = SE_THIS_OBJECT(s); - SE_PRECONDITION2(cobj, false, "js_scene_SubModel_setPasses : Invalid Native Object"); - const auto& args = s.args(); - size_t argc = args.size(); - CC_UNUSED bool ok = true; - if (argc == 1) { - HolderType, true> arg0 = {}; - ok &= sevalue_to_native(args[0], &arg0, s.thisObject()); - SE_PRECONDITION2(ok, false, "js_scene_SubModel_setPasses : Error processing arguments"); - cobj->setPasses(arg0.value()); - return true; - } - SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 1); - return false; -} -SE_BIND_FUNC(js_scene_SubModel_setPasses) - -static bool js_scene_SubModel_setPlanarInstanceShader(se::State& s) // NOLINT(readability-identifier-naming) -{ - auto* cobj = SE_THIS_OBJECT(s); - SE_PRECONDITION2(cobj, false, "js_scene_SubModel_setPlanarInstanceShader : Invalid Native Object"); - const auto& args = s.args(); - size_t argc = args.size(); - CC_UNUSED bool ok = true; - if (argc == 1) { - HolderType arg0 = {}; - ok &= sevalue_to_native(args[0], &arg0, s.thisObject()); - SE_PRECONDITION2(ok, false, "js_scene_SubModel_setPlanarInstanceShader : Error processing arguments"); - cobj->setPlanarInstanceShader(arg0.value()); - return true; - } - SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 1); - return false; -} -SE_BIND_FUNC(js_scene_SubModel_setPlanarInstanceShader) - -static bool js_scene_SubModel_setPlanarShader(se::State& s) // NOLINT(readability-identifier-naming) -{ - auto* cobj = SE_THIS_OBJECT(s); - SE_PRECONDITION2(cobj, false, "js_scene_SubModel_setPlanarShader : Invalid Native Object"); - const auto& args = s.args(); - size_t argc = args.size(); - CC_UNUSED bool ok = true; - if (argc == 1) { - HolderType arg0 = {}; - ok &= sevalue_to_native(args[0], &arg0, s.thisObject()); - SE_PRECONDITION2(ok, false, "js_scene_SubModel_setPlanarShader : Error processing arguments"); - cobj->setPlanarShader(arg0.value()); - return true; - } - SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 1); - return false; -} -SE_BIND_FUNC(js_scene_SubModel_setPlanarShader) - -static bool js_scene_SubModel_setPriority(se::State& s) // NOLINT(readability-identifier-naming) -{ - auto* cobj = SE_THIS_OBJECT(s); - SE_PRECONDITION2(cobj, false, "js_scene_SubModel_setPriority : Invalid Native Object"); - const auto& args = s.args(); - size_t argc = args.size(); - CC_UNUSED bool ok = true; - if (argc == 1) { - HolderType arg0 = {}; - ok &= sevalue_to_native(args[0], &arg0, s.thisObject()); - SE_PRECONDITION2(ok, false, "js_scene_SubModel_setPriority : Error processing arguments"); - cobj->setPriority(arg0.value()); - return true; - } - SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 1); - return false; -} -SE_BIND_FUNC(js_scene_SubModel_setPriority) - -static bool js_scene_SubModel_setShaders(se::State& s) // NOLINT(readability-identifier-naming) -{ - auto* cobj = SE_THIS_OBJECT(s); - SE_PRECONDITION2(cobj, false, "js_scene_SubModel_setShaders : Invalid Native Object"); - const auto& args = s.args(); - size_t argc = args.size(); - CC_UNUSED bool ok = true; - if (argc == 1) { - HolderType, true> arg0 = {}; - ok &= sevalue_to_native(args[0], &arg0, s.thisObject()); - SE_PRECONDITION2(ok, false, "js_scene_SubModel_setShaders : Error processing arguments"); - cobj->setShaders(arg0.value()); - return true; - } - SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 1); - return false; -} -SE_BIND_FUNC(js_scene_SubModel_setShaders) - -static bool js_scene_SubModel_setWorldBoundDescriptorSet(se::State& s) // NOLINT(readability-identifier-naming) -{ - auto* cobj = SE_THIS_OBJECT(s); - SE_PRECONDITION2(cobj, false, "js_scene_SubModel_setWorldBoundDescriptorSet : Invalid Native Object"); - const auto& args = s.args(); - size_t argc = args.size(); - CC_UNUSED bool ok = true; - if (argc == 1) { - HolderType arg0 = {}; - ok &= sevalue_to_native(args[0], &arg0, s.thisObject()); - SE_PRECONDITION2(ok, false, "js_scene_SubModel_setWorldBoundDescriptorSet : Error processing arguments"); - cobj->setWorldBoundDescriptorSet(arg0.value()); - return true; - } - SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 1); - return false; -} -SE_BIND_FUNC(js_scene_SubModel_setWorldBoundDescriptorSet) - -static bool js_scene_SubModel_update(se::State& s) // NOLINT(readability-identifier-naming) -{ - auto* cobj = SE_THIS_OBJECT(s); - SE_PRECONDITION2(cobj, false, "js_scene_SubModel_update : Invalid Native Object"); - const auto& args = s.args(); - size_t argc = args.size(); - if (argc == 0) { - cobj->update(); - return true; - } - SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 0); - return false; -} -SE_BIND_FUNC(js_scene_SubModel_update) - -SE_DECLARE_FINALIZE_FUNC(js_cc_scene_SubModel_finalize) - -static bool js_scene_SubModel_constructor(se::State& s) // NOLINT(readability-identifier-naming) constructor.c -{ - cc::scene::SubModel* cobj = JSB_ALLOC(cc::scene::SubModel); - s.thisObject()->setPrivateData(cobj); - se::NonRefNativePtrCreatedByCtorMap::emplace(cobj); - return true; -} -SE_BIND_CTOR(js_scene_SubModel_constructor, __jsb_cc_scene_SubModel_class, js_cc_scene_SubModel_finalize) - - - -static bool js_cc_scene_SubModel_finalize(se::State& s) // NOLINT(readability-identifier-naming) -{ - auto iter = se::NonRefNativePtrCreatedByCtorMap::find(SE_THIS_OBJECT(s)); - if (iter != se::NonRefNativePtrCreatedByCtorMap::end()) - { - se::NonRefNativePtrCreatedByCtorMap::erase(iter); - auto* cobj = SE_THIS_OBJECT(s); - JSB_FREE(cobj); - } - return true; -} -SE_BIND_FINALIZE_FUNC(js_cc_scene_SubModel_finalize) - -bool js_register_scene_SubModel(se::Object* obj) // NOLINT(readability-identifier-naming) -{ - auto* cls = se::Class::create("SubModel", obj, nullptr, _SE(js_scene_SubModel_constructor)); - - cls->defineFunction("getId", _SE(js_scene_SubModel_getId)); - cls->defineFunction("getOwner", _SE(js_scene_SubModel_getOwner)); - cls->defineFunction("getPass", _SE(js_scene_SubModel_getPass)); - cls->defineFunction("getPasses", _SE(js_scene_SubModel_getPasses)); - cls->defineFunction("getPlanarInstanceShader", _SE(js_scene_SubModel_getPlanarInstanceShader)); - cls->defineFunction("getPlanarShader", _SE(js_scene_SubModel_getPlanarShader)); - cls->defineFunction("getPriority", _SE(js_scene_SubModel_getPriority)); - cls->defineFunction("getShader", _SE(js_scene_SubModel_getShader)); - cls->defineFunction("getShaders", _SE(js_scene_SubModel_getShaders)); - cls->defineFunction("getWorldBoundDescriptorSet", _SE(js_scene_SubModel_getWorldBoundDescriptorSet)); - cls->defineFunction("setDescriptorSet", _SE(js_scene_SubModel_setDescriptorSet)); - cls->defineFunction("setInputAssembler", _SE(js_scene_SubModel_setInputAssembler)); - cls->defineFunction("setOwner", _SE(js_scene_SubModel_setOwner)); - cls->defineFunction("setPasses", _SE(js_scene_SubModel_setPasses)); - cls->defineFunction("setPlanarInstanceShader", _SE(js_scene_SubModel_setPlanarInstanceShader)); - cls->defineFunction("setPlanarShader", _SE(js_scene_SubModel_setPlanarShader)); - cls->defineFunction("setPriority", _SE(js_scene_SubModel_setPriority)); - cls->defineFunction("setShaders", _SE(js_scene_SubModel_setShaders)); - cls->defineFunction("setWorldBoundDescriptorSet", _SE(js_scene_SubModel_setWorldBoundDescriptorSet)); - cls->defineFunction("update", _SE(js_scene_SubModel_update)); - cls->defineFinalizeFunction(_SE(js_cc_scene_SubModel_finalize)); - cls->install(); - JSBClassType::registerClass(cls); - - __jsb_cc_scene_SubModel_proto = cls->getProto(); - __jsb_cc_scene_SubModel_class = cls; - - se::ScriptEngine::getInstance()->clearException(); - return true; -} -se::Object* __jsb_cc_scene_Pass_proto = nullptr; -se::Class* __jsb_cc_scene_Pass_class = nullptr; - -static bool js_scene_Pass_getBatchingScheme(se::State& s) // NOLINT(readability-identifier-naming) -{ - auto* cobj = SE_THIS_OBJECT(s); - SE_PRECONDITION2(cobj, false, "js_scene_Pass_getBatchingScheme : Invalid Native Object"); - const auto& args = s.args(); - size_t argc = args.size(); - CC_UNUSED bool ok = true; - if (argc == 0) { - auto result = static_cast(cobj->getBatchingScheme()); - ok &= nativevalue_to_se(result, s.rval(), nullptr /*ctx*/); - SE_PRECONDITION2(ok, false, "js_scene_Pass_getBatchingScheme : Error processing arguments"); - SE_HOLD_RETURN_VALUE(result, s.thisObject(), s.rval()); - return true; - } - SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 0); - return false; -} -SE_BIND_FUNC(js_scene_Pass_getBatchingScheme) - -static bool js_scene_Pass_getBlendState(se::State& s) // NOLINT(readability-identifier-naming) -{ - auto* cobj = SE_THIS_OBJECT(s); - SE_PRECONDITION2(cobj, false, "js_scene_Pass_getBlendState : Invalid Native Object"); - const auto& args = s.args(); - size_t argc = args.size(); - CC_UNUSED bool ok = true; - if (argc == 0) { - cc::gfx::BlendState* result = cobj->getBlendState(); - ok &= nativevalue_to_se(result, s.rval(), nullptr /*ctx*/); - SE_PRECONDITION2(ok, false, "js_scene_Pass_getBlendState : Error processing arguments"); - SE_HOLD_RETURN_VALUE(result, s.thisObject(), s.rval()); - return true; - } - SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 0); - return false; -} -SE_BIND_FUNC(js_scene_Pass_getBlendState) - -static bool js_scene_Pass_getDepthStencilState(se::State& s) // NOLINT(readability-identifier-naming) -{ - auto* cobj = SE_THIS_OBJECT(s); - SE_PRECONDITION2(cobj, false, "js_scene_Pass_getDepthStencilState : Invalid Native Object"); - const auto& args = s.args(); - size_t argc = args.size(); - CC_UNUSED bool ok = true; - if (argc == 0) { - cc::gfx::DepthStencilState* result = cobj->getDepthStencilState(); - ok &= nativevalue_to_se(result, s.rval(), nullptr /*ctx*/); - SE_PRECONDITION2(ok, false, "js_scene_Pass_getDepthStencilState : Error processing arguments"); - SE_HOLD_RETURN_VALUE(result, s.thisObject(), s.rval()); - return true; - } - SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 0); - return false; -} -SE_BIND_FUNC(js_scene_Pass_getDepthStencilState) - -static bool js_scene_Pass_getDescriptorSet(se::State& s) // NOLINT(readability-identifier-naming) -{ - auto* cobj = SE_THIS_OBJECT(s); - SE_PRECONDITION2(cobj, false, "js_scene_Pass_getDescriptorSet : Invalid Native Object"); - const auto& args = s.args(); - size_t argc = args.size(); - CC_UNUSED bool ok = true; - if (argc == 0) { - cc::gfx::DescriptorSet* result = cobj->getDescriptorSet(); - ok &= nativevalue_to_se(result, s.rval(), nullptr /*ctx*/); - SE_PRECONDITION2(ok, false, "js_scene_Pass_getDescriptorSet : Error processing arguments"); - SE_HOLD_RETURN_VALUE(result, s.thisObject(), s.rval()); - return true; - } - SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 0); - return false; -} -SE_BIND_FUNC(js_scene_Pass_getDescriptorSet) - -static bool js_scene_Pass_getDynamicState(se::State& s) // NOLINT(readability-identifier-naming) -{ - auto* cobj = SE_THIS_OBJECT(s); - SE_PRECONDITION2(cobj, false, "js_scene_Pass_getDynamicState : Invalid Native Object"); - const auto& args = s.args(); - size_t argc = args.size(); - CC_UNUSED bool ok = true; - if (argc == 0) { - auto result = static_cast(cobj->getDynamicState()); - ok &= nativevalue_to_se(result, s.rval(), nullptr /*ctx*/); - SE_PRECONDITION2(ok, false, "js_scene_Pass_getDynamicState : Error processing arguments"); - SE_HOLD_RETURN_VALUE(result, s.thisObject(), s.rval()); - return true; - } - SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 0); - return false; -} -SE_BIND_FUNC(js_scene_Pass_getDynamicState) - -static bool js_scene_Pass_getHash(se::State& s) // NOLINT(readability-identifier-naming) -{ - auto* cobj = SE_THIS_OBJECT(s); - SE_PRECONDITION2(cobj, false, "js_scene_Pass_getHash : Invalid Native Object"); - const auto& args = s.args(); - size_t argc = args.size(); - CC_UNUSED bool ok = true; - if (argc == 0) { - unsigned int result = cobj->getHash(); - ok &= nativevalue_to_se(result, s.rval(), nullptr /*ctx*/); - SE_PRECONDITION2(ok, false, "js_scene_Pass_getHash : Error processing arguments"); - SE_HOLD_RETURN_VALUE(result, s.thisObject(), s.rval()); - return true; - } - SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 0); - return false; -} -SE_BIND_FUNC(js_scene_Pass_getHash) - -static bool js_scene_Pass_getPhase(se::State& s) // NOLINT(readability-identifier-naming) -{ - auto* cobj = SE_THIS_OBJECT(s); - SE_PRECONDITION2(cobj, false, "js_scene_Pass_getPhase : Invalid Native Object"); - const auto& args = s.args(); - size_t argc = args.size(); - CC_UNUSED bool ok = true; - if (argc == 0) { - unsigned int result = cobj->getPhase(); - ok &= nativevalue_to_se(result, s.rval(), nullptr /*ctx*/); - SE_PRECONDITION2(ok, false, "js_scene_Pass_getPhase : Error processing arguments"); - SE_HOLD_RETURN_VALUE(result, s.thisObject(), s.rval()); - return true; - } - SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 0); - return false; -} -SE_BIND_FUNC(js_scene_Pass_getPhase) - -static bool js_scene_Pass_getPipelineLayout(se::State& s) // NOLINT(readability-identifier-naming) -{ - auto* cobj = SE_THIS_OBJECT(s); - SE_PRECONDITION2(cobj, false, "js_scene_Pass_getPipelineLayout : Invalid Native Object"); - const auto& args = s.args(); - size_t argc = args.size(); - CC_UNUSED bool ok = true; - if (argc == 0) { - cc::gfx::PipelineLayout* result = cobj->getPipelineLayout(); - ok &= nativevalue_to_se(result, s.rval(), nullptr /*ctx*/); - SE_PRECONDITION2(ok, false, "js_scene_Pass_getPipelineLayout : Error processing arguments"); - SE_HOLD_RETURN_VALUE(result, s.thisObject(), s.rval()); - return true; - } - SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 0); - return false; -} -SE_BIND_FUNC(js_scene_Pass_getPipelineLayout) - -static bool js_scene_Pass_getPrimitive(se::State& s) // NOLINT(readability-identifier-naming) -{ - auto* cobj = SE_THIS_OBJECT(s); - SE_PRECONDITION2(cobj, false, "js_scene_Pass_getPrimitive : Invalid Native Object"); - const auto& args = s.args(); - size_t argc = args.size(); - CC_UNUSED bool ok = true; - if (argc == 0) { - auto result = static_cast(cobj->getPrimitive()); - ok &= nativevalue_to_se(result, s.rval(), nullptr /*ctx*/); - SE_PRECONDITION2(ok, false, "js_scene_Pass_getPrimitive : Error processing arguments"); - SE_HOLD_RETURN_VALUE(result, s.thisObject(), s.rval()); - return true; - } - SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 0); - return false; -} -SE_BIND_FUNC(js_scene_Pass_getPrimitive) - -static bool js_scene_Pass_getPriority(se::State& s) // NOLINT(readability-identifier-naming) -{ - auto* cobj = SE_THIS_OBJECT(s); - SE_PRECONDITION2(cobj, false, "js_scene_Pass_getPriority : Invalid Native Object"); - const auto& args = s.args(); - size_t argc = args.size(); - CC_UNUSED bool ok = true; - if (argc == 0) { - auto result = static_cast(cobj->getPriority()); - ok &= nativevalue_to_se(result, s.rval(), nullptr /*ctx*/); - SE_PRECONDITION2(ok, false, "js_scene_Pass_getPriority : Error processing arguments"); - SE_HOLD_RETURN_VALUE(result, s.thisObject(), s.rval()); - return true; - } - SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 0); - return false; -} -SE_BIND_FUNC(js_scene_Pass_getPriority) - -static bool js_scene_Pass_getRasterizerState(se::State& s) // NOLINT(readability-identifier-naming) -{ - auto* cobj = SE_THIS_OBJECT(s); - SE_PRECONDITION2(cobj, false, "js_scene_Pass_getRasterizerState : Invalid Native Object"); - const auto& args = s.args(); - size_t argc = args.size(); - CC_UNUSED bool ok = true; - if (argc == 0) { - cc::gfx::RasterizerState* result = cobj->getRasterizerState(); - ok &= nativevalue_to_se(result, s.rval(), nullptr /*ctx*/); - SE_PRECONDITION2(ok, false, "js_scene_Pass_getRasterizerState : Error processing arguments"); - SE_HOLD_RETURN_VALUE(result, s.thisObject(), s.rval()); - return true; - } - SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 0); - return false; -} -SE_BIND_FUNC(js_scene_Pass_getRasterizerState) - -static bool js_scene_Pass_getStage(se::State& s) // NOLINT(readability-identifier-naming) -{ - auto* cobj = SE_THIS_OBJECT(s); - SE_PRECONDITION2(cobj, false, "js_scene_Pass_getStage : Invalid Native Object"); - const auto& args = s.args(); - size_t argc = args.size(); - CC_UNUSED bool ok = true; - if (argc == 0) { - auto result = static_cast(cobj->getStage()); - ok &= nativevalue_to_se(result, s.rval(), nullptr /*ctx*/); - SE_PRECONDITION2(ok, false, "js_scene_Pass_getStage : Error processing arguments"); - SE_HOLD_RETURN_VALUE(result, s.thisObject(), s.rval()); - return true; - } - SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 0); - return false; -} -SE_BIND_FUNC(js_scene_Pass_getStage) - -static bool js_scene_Pass_initWithData(se::State& s) // NOLINT(readability-identifier-naming) -{ - auto* cobj = SE_THIS_OBJECT(s); - SE_PRECONDITION2(cobj, false, "js_scene_Pass_initWithData : Invalid Native Object"); - const auto& args = s.args(); - size_t argc = args.size(); - CC_UNUSED bool ok = true; - if (argc == 1) { - HolderType arg0 = {}; - ok &= sevalue_to_native(args[0], &arg0, s.thisObject()); - SE_PRECONDITION2(ok, false, "js_scene_Pass_initWithData : Error processing arguments"); - cobj->initWithData(arg0.value()); - return true; - } - SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 1); - return false; -} -SE_BIND_FUNC(js_scene_Pass_initWithData) - -static bool js_scene_Pass_setBatchingScheme(se::State& s) // NOLINT(readability-identifier-naming) -{ - auto* cobj = SE_THIS_OBJECT(s); - SE_PRECONDITION2(cobj, false, "js_scene_Pass_setBatchingScheme : Invalid Native Object"); - const auto& args = s.args(); - size_t argc = args.size(); - CC_UNUSED bool ok = true; - if (argc == 1) { - HolderType arg0 = {}; - ok &= sevalue_to_native(args[0], &arg0, s.thisObject()); - SE_PRECONDITION2(ok, false, "js_scene_Pass_setBatchingScheme : Error processing arguments"); - cobj->setBatchingScheme(arg0.value()); - return true; - } - SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 1); - return false; -} -SE_BIND_FUNC(js_scene_Pass_setBatchingScheme) - -static bool js_scene_Pass_setBlendState(se::State& s) // NOLINT(readability-identifier-naming) -{ - auto* cobj = SE_THIS_OBJECT(s); - SE_PRECONDITION2(cobj, false, "js_scene_Pass_setBlendState : Invalid Native Object"); - const auto& args = s.args(); - size_t argc = args.size(); - CC_UNUSED bool ok = true; - if (argc == 1) { - HolderType arg0 = {}; - ok &= sevalue_to_native(args[0], &arg0, s.thisObject()); - SE_PRECONDITION2(ok, false, "js_scene_Pass_setBlendState : Error processing arguments"); - cobj->setBlendState(arg0.value()); - return true; - } - SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 1); - return false; -} -SE_BIND_FUNC(js_scene_Pass_setBlendState) - -static bool js_scene_Pass_setDepthStencilState(se::State& s) // NOLINT(readability-identifier-naming) -{ - auto* cobj = SE_THIS_OBJECT(s); - SE_PRECONDITION2(cobj, false, "js_scene_Pass_setDepthStencilState : Invalid Native Object"); - const auto& args = s.args(); - size_t argc = args.size(); - CC_UNUSED bool ok = true; - if (argc == 1) { - HolderType arg0 = {}; - ok &= sevalue_to_native(args[0], &arg0, s.thisObject()); - SE_PRECONDITION2(ok, false, "js_scene_Pass_setDepthStencilState : Error processing arguments"); - cobj->setDepthStencilState(arg0.value()); - return true; - } - SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 1); - return false; -} -SE_BIND_FUNC(js_scene_Pass_setDepthStencilState) - -static bool js_scene_Pass_setDescriptorSet(se::State& s) // NOLINT(readability-identifier-naming) -{ - auto* cobj = SE_THIS_OBJECT(s); - SE_PRECONDITION2(cobj, false, "js_scene_Pass_setDescriptorSet : Invalid Native Object"); - const auto& args = s.args(); - size_t argc = args.size(); - CC_UNUSED bool ok = true; - if (argc == 1) { - HolderType arg0 = {}; - ok &= sevalue_to_native(args[0], &arg0, s.thisObject()); - SE_PRECONDITION2(ok, false, "js_scene_Pass_setDescriptorSet : Error processing arguments"); - cobj->setDescriptorSet(arg0.value()); - return true; - } - SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 1); - return false; -} -SE_BIND_FUNC(js_scene_Pass_setDescriptorSet) - -static bool js_scene_Pass_setDynamicState(se::State& s) // NOLINT(readability-identifier-naming) -{ - auto* cobj = SE_THIS_OBJECT(s); - SE_PRECONDITION2(cobj, false, "js_scene_Pass_setDynamicState : Invalid Native Object"); - const auto& args = s.args(); - size_t argc = args.size(); - CC_UNUSED bool ok = true; - if (argc == 1) { - HolderType arg0 = {}; - ok &= sevalue_to_native(args[0], &arg0, s.thisObject()); - SE_PRECONDITION2(ok, false, "js_scene_Pass_setDynamicState : Error processing arguments"); - cobj->setDynamicState(arg0.value()); - return true; - } - SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 1); - return false; -} -SE_BIND_FUNC(js_scene_Pass_setDynamicState) - -static bool js_scene_Pass_setHash(se::State& s) // NOLINT(readability-identifier-naming) -{ - auto* cobj = SE_THIS_OBJECT(s); - SE_PRECONDITION2(cobj, false, "js_scene_Pass_setHash : Invalid Native Object"); - const auto& args = s.args(); - size_t argc = args.size(); - CC_UNUSED bool ok = true; - if (argc == 1) { - HolderType arg0 = {}; - ok &= sevalue_to_native(args[0], &arg0, s.thisObject()); - SE_PRECONDITION2(ok, false, "js_scene_Pass_setHash : Error processing arguments"); - cobj->setHash(arg0.value()); - return true; - } - SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 1); - return false; -} -SE_BIND_FUNC(js_scene_Pass_setHash) - -static bool js_scene_Pass_setPhase(se::State& s) // NOLINT(readability-identifier-naming) -{ - auto* cobj = SE_THIS_OBJECT(s); - SE_PRECONDITION2(cobj, false, "js_scene_Pass_setPhase : Invalid Native Object"); - const auto& args = s.args(); - size_t argc = args.size(); - CC_UNUSED bool ok = true; - if (argc == 1) { - HolderType arg0 = {}; - ok &= sevalue_to_native(args[0], &arg0, s.thisObject()); - SE_PRECONDITION2(ok, false, "js_scene_Pass_setPhase : Error processing arguments"); - cobj->setPhase(arg0.value()); - return true; - } - SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 1); - return false; -} -SE_BIND_FUNC(js_scene_Pass_setPhase) - -static bool js_scene_Pass_setPipelineLayout(se::State& s) // NOLINT(readability-identifier-naming) -{ - auto* cobj = SE_THIS_OBJECT(s); - SE_PRECONDITION2(cobj, false, "js_scene_Pass_setPipelineLayout : Invalid Native Object"); - const auto& args = s.args(); - size_t argc = args.size(); - CC_UNUSED bool ok = true; - if (argc == 1) { - HolderType arg0 = {}; - ok &= sevalue_to_native(args[0], &arg0, s.thisObject()); - SE_PRECONDITION2(ok, false, "js_scene_Pass_setPipelineLayout : Error processing arguments"); - cobj->setPipelineLayout(arg0.value()); - return true; - } - SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 1); - return false; -} -SE_BIND_FUNC(js_scene_Pass_setPipelineLayout) - -static bool js_scene_Pass_setPrimitive(se::State& s) // NOLINT(readability-identifier-naming) -{ - auto* cobj = SE_THIS_OBJECT(s); - SE_PRECONDITION2(cobj, false, "js_scene_Pass_setPrimitive : Invalid Native Object"); - const auto& args = s.args(); - size_t argc = args.size(); - CC_UNUSED bool ok = true; - if (argc == 1) { - HolderType arg0 = {}; - ok &= sevalue_to_native(args[0], &arg0, s.thisObject()); - SE_PRECONDITION2(ok, false, "js_scene_Pass_setPrimitive : Error processing arguments"); - cobj->setPrimitive(arg0.value()); - return true; - } - SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 1); - return false; -} -SE_BIND_FUNC(js_scene_Pass_setPrimitive) - -static bool js_scene_Pass_setPriority(se::State& s) // NOLINT(readability-identifier-naming) -{ - auto* cobj = SE_THIS_OBJECT(s); - SE_PRECONDITION2(cobj, false, "js_scene_Pass_setPriority : Invalid Native Object"); - const auto& args = s.args(); - size_t argc = args.size(); - CC_UNUSED bool ok = true; - if (argc == 1) { - HolderType arg0 = {}; - ok &= sevalue_to_native(args[0], &arg0, s.thisObject()); - SE_PRECONDITION2(ok, false, "js_scene_Pass_setPriority : Error processing arguments"); - cobj->setPriority(arg0.value()); - return true; - } - SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 1); - return false; -} -SE_BIND_FUNC(js_scene_Pass_setPriority) - -static bool js_scene_Pass_setRasterizerState(se::State& s) // NOLINT(readability-identifier-naming) -{ - auto* cobj = SE_THIS_OBJECT(s); - SE_PRECONDITION2(cobj, false, "js_scene_Pass_setRasterizerState : Invalid Native Object"); - const auto& args = s.args(); - size_t argc = args.size(); - CC_UNUSED bool ok = true; - if (argc == 1) { - HolderType arg0 = {}; - ok &= sevalue_to_native(args[0], &arg0, s.thisObject()); - SE_PRECONDITION2(ok, false, "js_scene_Pass_setRasterizerState : Error processing arguments"); - cobj->setRasterizerState(arg0.value()); - return true; - } - SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 1); - return false; -} -SE_BIND_FUNC(js_scene_Pass_setRasterizerState) - -static bool js_scene_Pass_setRootBufferDirty(se::State& s) // NOLINT(readability-identifier-naming) -{ - auto* cobj = SE_THIS_OBJECT(s); - SE_PRECONDITION2(cobj, false, "js_scene_Pass_setRootBufferDirty : Invalid Native Object"); - const auto& args = s.args(); - size_t argc = args.size(); - CC_UNUSED bool ok = true; - if (argc == 1) { - HolderType arg0 = {}; - ok &= sevalue_to_native(args[0], &arg0, s.thisObject()); - SE_PRECONDITION2(ok, false, "js_scene_Pass_setRootBufferDirty : Error processing arguments"); - cobj->setRootBufferDirty(arg0.value()); - return true; - } - SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 1); - return false; -} -SE_BIND_FUNC(js_scene_Pass_setRootBufferDirty) - -static bool js_scene_Pass_setStage(se::State& s) // NOLINT(readability-identifier-naming) -{ - auto* cobj = SE_THIS_OBJECT(s); - SE_PRECONDITION2(cobj, false, "js_scene_Pass_setStage : Invalid Native Object"); - const auto& args = s.args(); - size_t argc = args.size(); - CC_UNUSED bool ok = true; - if (argc == 1) { - HolderType arg0 = {}; - ok &= sevalue_to_native(args[0], &arg0, s.thisObject()); - SE_PRECONDITION2(ok, false, "js_scene_Pass_setStage : Error processing arguments"); - cobj->setStage(arg0.value()); - return true; - } - SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 1); - return false; -} -SE_BIND_FUNC(js_scene_Pass_setStage) - -static bool js_scene_Pass_update(se::State& s) // NOLINT(readability-identifier-naming) -{ - auto* cobj = SE_THIS_OBJECT(s); - SE_PRECONDITION2(cobj, false, "js_scene_Pass_update : Invalid Native Object"); - const auto& args = s.args(); - size_t argc = args.size(); - if (argc == 0) { - cobj->update(); - return true; - } - SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 0); - return false; -} -SE_BIND_FUNC(js_scene_Pass_update) - -SE_DECLARE_FINALIZE_FUNC(js_cc_scene_Pass_finalize) - -static bool js_scene_Pass_constructor(se::State& s) // NOLINT(readability-identifier-naming) constructor.c -{ - cc::scene::Pass* cobj = JSB_ALLOC(cc::scene::Pass); - s.thisObject()->setPrivateData(cobj); - se::NonRefNativePtrCreatedByCtorMap::emplace(cobj); - return true; -} -SE_BIND_CTOR(js_scene_Pass_constructor, __jsb_cc_scene_Pass_class, js_cc_scene_Pass_finalize) - - - -static bool js_cc_scene_Pass_finalize(se::State& s) // NOLINT(readability-identifier-naming) -{ - auto iter = se::NonRefNativePtrCreatedByCtorMap::find(SE_THIS_OBJECT(s)); - if (iter != se::NonRefNativePtrCreatedByCtorMap::end()) - { - se::NonRefNativePtrCreatedByCtorMap::erase(iter); - auto* cobj = SE_THIS_OBJECT(s); - JSB_FREE(cobj); - } - return true; -} -SE_BIND_FINALIZE_FUNC(js_cc_scene_Pass_finalize) - -bool js_register_scene_Pass(se::Object* obj) // NOLINT(readability-identifier-naming) -{ - auto* cls = se::Class::create("Pass", obj, nullptr, _SE(js_scene_Pass_constructor)); - - cls->defineFunction("getBatchingScheme", _SE(js_scene_Pass_getBatchingScheme)); - cls->defineFunction("getBlendState", _SE(js_scene_Pass_getBlendState)); - cls->defineFunction("getDepthStencilState", _SE(js_scene_Pass_getDepthStencilState)); - cls->defineFunction("getDescriptorSet", _SE(js_scene_Pass_getDescriptorSet)); - cls->defineFunction("getDynamicState", _SE(js_scene_Pass_getDynamicState)); - cls->defineFunction("getHash", _SE(js_scene_Pass_getHash)); - cls->defineFunction("getPhase", _SE(js_scene_Pass_getPhase)); - cls->defineFunction("getPipelineLayout", _SE(js_scene_Pass_getPipelineLayout)); - cls->defineFunction("getPrimitive", _SE(js_scene_Pass_getPrimitive)); - cls->defineFunction("getPriority", _SE(js_scene_Pass_getPriority)); - cls->defineFunction("getRasterizerState", _SE(js_scene_Pass_getRasterizerState)); - cls->defineFunction("getStage", _SE(js_scene_Pass_getStage)); - cls->defineFunction("initWithData", _SE(js_scene_Pass_initWithData)); - cls->defineFunction("setBatchingScheme", _SE(js_scene_Pass_setBatchingScheme)); - cls->defineFunction("setBlendState", _SE(js_scene_Pass_setBlendState)); - cls->defineFunction("setDepthStencilState", _SE(js_scene_Pass_setDepthStencilState)); - cls->defineFunction("setDescriptorSet", _SE(js_scene_Pass_setDescriptorSet)); - cls->defineFunction("setDynamicState", _SE(js_scene_Pass_setDynamicState)); - cls->defineFunction("setHash", _SE(js_scene_Pass_setHash)); - cls->defineFunction("setPhase", _SE(js_scene_Pass_setPhase)); - cls->defineFunction("setPipelineLayout", _SE(js_scene_Pass_setPipelineLayout)); - cls->defineFunction("setPrimitive", _SE(js_scene_Pass_setPrimitive)); - cls->defineFunction("setPriority", _SE(js_scene_Pass_setPriority)); - cls->defineFunction("setRasterizerState", _SE(js_scene_Pass_setRasterizerState)); - cls->defineFunction("setRootBufferDirty", _SE(js_scene_Pass_setRootBufferDirty)); - cls->defineFunction("setStage", _SE(js_scene_Pass_setStage)); - cls->defineFunction("update", _SE(js_scene_Pass_update)); - cls->defineFinalizeFunction(_SE(js_cc_scene_Pass_finalize)); - cls->install(); - JSBClassType::registerClass(cls); - - __jsb_cc_scene_Pass_proto = cls->getProto(); - __jsb_cc_scene_Pass_class = cls; - - se::ScriptEngine::getInstance()->clearException(); - return true; -} -se::Object* __jsb_cc_scene_BakedAnimInfo_proto = nullptr; -se::Class* __jsb_cc_scene_BakedAnimInfo_class = nullptr; - -static bool js_scene_BakedAnimInfo_getDirty(se::State& s) // NOLINT(readability-identifier-naming) -{ - auto* cobj = SE_THIS_OBJECT(s); - SE_PRECONDITION2(cobj, false, "js_scene_BakedAnimInfo_getDirty : Invalid Native Object"); - const auto& args = s.args(); - size_t argc = args.size(); - CC_UNUSED bool ok = true; - if (argc == 0) { - bool result = cobj->getDirty(); - ok &= nativevalue_to_se(result, s.rval(), nullptr /*ctx*/); - SE_PRECONDITION2(ok, false, "js_scene_BakedAnimInfo_getDirty : Error processing arguments"); - SE_HOLD_RETURN_VALUE(result, s.thisObject(), s.rval()); - return true; - } - SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 0); - return false; -} -SE_BIND_FUNC(js_scene_BakedAnimInfo_getDirty) - - -template<> -bool sevalue_to_native(const se::Value &from, cc::scene::BakedAnimInfo * to, se::Object *ctx) -{ - assert(from.isObject()); - se::Object *json = from.toObject(); - auto* data = reinterpret_cast(json->getPrivateData()); - if (data) { - *to = *data; - return true; - } - se::Value field; - bool ok = true; - json->getProperty("buffer", &field); - if(!field.isNullOrUndefined()) { - ok &= sevalue_to_native(field, &(to->buffer), ctx); - } - json->getProperty("data", &field); - if(!field.isNullOrUndefined()) { - ok &= sevalue_to_native(field, &(to->data), ctx); - } - json->getProperty("dirty", &field); - if(!field.isNullOrUndefined()) { - ok &= sevalue_to_native(field, &(to->dirty), ctx); - } - return ok; -} - -SE_DECLARE_FINALIZE_FUNC(js_cc_scene_BakedAnimInfo_finalize) - -static bool js_scene_BakedAnimInfo_constructor(se::State& s) // NOLINT(readability-identifier-naming) -{ - CC_UNUSED bool ok = true; - const auto& args = s.args(); - size_t argc = args.size(); - - if(argc == 0) - { - cc::scene::BakedAnimInfo* cobj = JSB_ALLOC(cc::scene::BakedAnimInfo); - s.thisObject()->setPrivateData(cobj); - se::NonRefNativePtrCreatedByCtorMap::emplace(cobj); - return true; - } - - if(argc == 1 && args[0].isObject()) - { - se::Object *json = args[0].toObject(); - se::Value field; - - cc::scene::BakedAnimInfo* cobj = JSB_ALLOC(cc::scene::BakedAnimInfo); - ok &= sevalue_to_native(args[0], cobj, s.thisObject()); - if(!ok) { - JSB_FREE(cobj); - SE_REPORT_ERROR("argument convertion error"); - return false; - } - - s.thisObject()->setPrivateData(cobj); - se::NonRefNativePtrCreatedByCtorMap::emplace(cobj); - return true; - } - - cc::scene::BakedAnimInfo* cobj = JSB_ALLOC(cc::scene::BakedAnimInfo); - if (argc > 0 && !args[0].isUndefined()) { - ok &= sevalue_to_native(args[0], &(cobj->buffer), nullptr); - } - if (argc > 1 && !args[1].isUndefined()) { - ok &= sevalue_to_native(args[1], &(cobj->data), nullptr); - } - if (argc > 2 && !args[2].isUndefined()) { - ok &= sevalue_to_native(args[2], &(cobj->dirty), nullptr); - } - - if(!ok) { - JSB_FREE(cobj); - SE_REPORT_ERROR("Argument convertion error"); - return false; - } - - s.thisObject()->setPrivateData(cobj); - se::NonRefNativePtrCreatedByCtorMap::emplace(cobj); - return true; -} -SE_BIND_CTOR(js_scene_BakedAnimInfo_constructor, __jsb_cc_scene_BakedAnimInfo_class, js_cc_scene_BakedAnimInfo_finalize) - - - -static bool js_cc_scene_BakedAnimInfo_finalize(se::State& s) // NOLINT(readability-identifier-naming) -{ - auto iter = se::NonRefNativePtrCreatedByCtorMap::find(SE_THIS_OBJECT(s)); - if (iter != se::NonRefNativePtrCreatedByCtorMap::end()) - { - se::NonRefNativePtrCreatedByCtorMap::erase(iter); - auto* cobj = SE_THIS_OBJECT(s); - JSB_FREE(cobj); - } - return true; -} -SE_BIND_FINALIZE_FUNC(js_cc_scene_BakedAnimInfo_finalize) - -bool js_register_scene_BakedAnimInfo(se::Object* obj) // NOLINT(readability-identifier-naming) -{ - auto* cls = se::Class::create("BakedAnimInfo", obj, nullptr, _SE(js_scene_BakedAnimInfo_constructor)); - - cls->defineFunction("getDirty", _SE(js_scene_BakedAnimInfo_getDirty)); - cls->defineFinalizeFunction(_SE(js_cc_scene_BakedAnimInfo_finalize)); - cls->install(); - JSBClassType::registerClass(cls); - - __jsb_cc_scene_BakedAnimInfo_proto = cls->getProto(); - __jsb_cc_scene_BakedAnimInfo_class = cls; - - se::ScriptEngine::getInstance()->clearException(); - return true; -} -se::Object* __jsb_cc_scene_BakedJointInfo_proto = nullptr; -se::Class* __jsb_cc_scene_BakedJointInfo_class = nullptr; - - -template<> -bool sevalue_to_native(const se::Value &from, cc::scene::BakedJointInfo * to, se::Object *ctx) -{ - assert(from.isObject()); - se::Object *json = from.toObject(); - auto* data = reinterpret_cast(json->getPrivateData()); - if (data) { - *to = *data; - return true; - } - se::Value field; - bool ok = true; - json->getProperty("boundsInfo", &field); - if(!field.isNullOrUndefined()) { - ok &= sevalue_to_native(field, &(to->boundsInfo), ctx); - } - json->getProperty("jointTextureInfo", &field); - if(!field.isNullOrUndefined()) { - ok &= sevalue_to_native(field, &(to->jointTextureInfo), ctx); - } - json->getProperty("animInfo", &field); - if(!field.isNullOrUndefined()) { - ok &= sevalue_to_native(field, &(to->animInfo), ctx); - } - json->getProperty("buffer", &field); - if(!field.isNullOrUndefined()) { - ok &= sevalue_to_native(field, &(to->buffer), ctx); - } - return ok; -} - -SE_DECLARE_FINALIZE_FUNC(js_cc_scene_BakedJointInfo_finalize) - -static bool js_scene_BakedJointInfo_constructor(se::State& s) // NOLINT(readability-identifier-naming) -{ - CC_UNUSED bool ok = true; - const auto& args = s.args(); - size_t argc = args.size(); - - if(argc == 0) - { - cc::scene::BakedJointInfo* cobj = JSB_ALLOC(cc::scene::BakedJointInfo); - s.thisObject()->setPrivateData(cobj); - se::NonRefNativePtrCreatedByCtorMap::emplace(cobj); - return true; - } - - if(argc == 1 && args[0].isObject()) - { - se::Object *json = args[0].toObject(); - se::Value field; - - cc::scene::BakedJointInfo* cobj = JSB_ALLOC(cc::scene::BakedJointInfo); - ok &= sevalue_to_native(args[0], cobj, s.thisObject()); - if(!ok) { - JSB_FREE(cobj); - SE_REPORT_ERROR("argument convertion error"); - return false; - } - - s.thisObject()->setPrivateData(cobj); - se::NonRefNativePtrCreatedByCtorMap::emplace(cobj); - return true; - } - - cc::scene::BakedJointInfo* cobj = JSB_ALLOC(cc::scene::BakedJointInfo); - if (argc > 0 && !args[0].isUndefined()) { - ok &= sevalue_to_native(args[0], &(cobj->boundsInfo), nullptr); - } - if (argc > 1 && !args[1].isUndefined()) { - ok &= sevalue_to_native(args[1], &(cobj->jointTextureInfo), nullptr); - } - if (argc > 2 && !args[2].isUndefined()) { - ok &= sevalue_to_native(args[2], &(cobj->animInfo), nullptr); - } - if (argc > 3 && !args[3].isUndefined()) { - ok &= sevalue_to_native(args[3], &(cobj->buffer), nullptr); - } - - if(!ok) { - JSB_FREE(cobj); - SE_REPORT_ERROR("Argument convertion error"); - return false; - } - - s.thisObject()->setPrivateData(cobj); - se::NonRefNativePtrCreatedByCtorMap::emplace(cobj); - return true; -} -SE_BIND_CTOR(js_scene_BakedJointInfo_constructor, __jsb_cc_scene_BakedJointInfo_class, js_cc_scene_BakedJointInfo_finalize) - - - -static bool js_cc_scene_BakedJointInfo_finalize(se::State& s) // NOLINT(readability-identifier-naming) -{ - auto iter = se::NonRefNativePtrCreatedByCtorMap::find(SE_THIS_OBJECT(s)); - if (iter != se::NonRefNativePtrCreatedByCtorMap::end()) - { - se::NonRefNativePtrCreatedByCtorMap::erase(iter); - auto* cobj = SE_THIS_OBJECT(s); - JSB_FREE(cobj); - } - return true; -} -SE_BIND_FINALIZE_FUNC(js_cc_scene_BakedJointInfo_finalize) - -bool js_register_scene_BakedJointInfo(se::Object* obj) // NOLINT(readability-identifier-naming) -{ - auto* cls = se::Class::create("BakedJointInfo", obj, nullptr, _SE(js_scene_BakedJointInfo_constructor)); - - cls->defineFinalizeFunction(_SE(js_cc_scene_BakedJointInfo_finalize)); - cls->install(); - JSBClassType::registerClass(cls); - - __jsb_cc_scene_BakedJointInfo_proto = cls->getProto(); - __jsb_cc_scene_BakedJointInfo_class = cls; - - se::ScriptEngine::getInstance()->clearException(); - return true; -} -se::Object* __jsb_cc_scene_BakedSkinningModel_proto = nullptr; -se::Class* __jsb_cc_scene_BakedSkinningModel_class = nullptr; - -static bool js_scene_BakedSkinningModel_setAnimInfoIdx(se::State& s) // NOLINT(readability-identifier-naming) -{ - auto* cobj = SE_THIS_OBJECT(s); - SE_PRECONDITION2(cobj, false, "js_scene_BakedSkinningModel_setAnimInfoIdx : Invalid Native Object"); - const auto& args = s.args(); - size_t argc = args.size(); - CC_UNUSED bool ok = true; - if (argc == 1) { - HolderType arg0 = {}; - ok &= sevalue_to_native(args[0], &arg0, s.thisObject()); - SE_PRECONDITION2(ok, false, "js_scene_BakedSkinningModel_setAnimInfoIdx : Error processing arguments"); - cobj->setAnimInfoIdx(arg0.value()); - return true; - } - SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 1); - return false; -} -SE_BIND_FUNC(js_scene_BakedSkinningModel_setAnimInfoIdx) - -static bool js_scene_BakedSkinningModel_setJointMedium(se::State& s) // NOLINT(readability-identifier-naming) -{ - auto* cobj = SE_THIS_OBJECT(s); - SE_PRECONDITION2(cobj, false, "js_scene_BakedSkinningModel_setJointMedium : Invalid Native Object"); - const auto& args = s.args(); - size_t argc = args.size(); - CC_UNUSED bool ok = true; - if (argc == 2) { - HolderType arg0 = {}; - HolderType arg1 = {}; - ok &= sevalue_to_native(args[0], &arg0, s.thisObject()); - ok &= sevalue_to_native(args[1], &arg1, s.thisObject()); - SE_PRECONDITION2(ok, false, "js_scene_BakedSkinningModel_setJointMedium : Error processing arguments"); - cobj->setJointMedium(arg0.value(), std::move(arg1.value())); - return true; - } - SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 2); - return false; -} -SE_BIND_FUNC(js_scene_BakedSkinningModel_setJointMedium) - -static bool js_scene_BakedSkinningModel_updateModelBounds(se::State& s) // NOLINT(readability-identifier-naming) -{ - auto* cobj = SE_THIS_OBJECT(s); - SE_PRECONDITION2(cobj, false, "js_scene_BakedSkinningModel_updateModelBounds : Invalid Native Object"); - const auto& args = s.args(); - size_t argc = args.size(); - CC_UNUSED bool ok = true; - if (argc == 1) { - HolderType arg0 = {}; - ok &= sevalue_to_native(args[0], &arg0, s.thisObject()); - SE_PRECONDITION2(ok, false, "js_scene_BakedSkinningModel_updateModelBounds : Error processing arguments"); - cobj->updateModelBounds(arg0.value()); - return true; - } - SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 1); - return false; -} -SE_BIND_FUNC(js_scene_BakedSkinningModel_updateModelBounds) - -SE_DECLARE_FINALIZE_FUNC(js_cc_scene_BakedSkinningModel_finalize) - -static bool js_scene_BakedSkinningModel_constructor(se::State& s) // NOLINT(readability-identifier-naming) constructor.c -{ - cc::scene::BakedSkinningModel* cobj = JSB_ALLOC(cc::scene::BakedSkinningModel); - s.thisObject()->setPrivateData(cobj); - se::NonRefNativePtrCreatedByCtorMap::emplace(cobj); - return true; -} -SE_BIND_CTOR(js_scene_BakedSkinningModel_constructor, __jsb_cc_scene_BakedSkinningModel_class, js_cc_scene_BakedSkinningModel_finalize) - - - -static bool js_cc_scene_BakedSkinningModel_finalize(se::State& s) // NOLINT(readability-identifier-naming) -{ - auto iter = se::NonRefNativePtrCreatedByCtorMap::find(SE_THIS_OBJECT(s)); - if (iter != se::NonRefNativePtrCreatedByCtorMap::end()) - { - se::NonRefNativePtrCreatedByCtorMap::erase(iter); - auto* cobj = SE_THIS_OBJECT(s); - JSB_FREE(cobj); - } - return true; -} -SE_BIND_FINALIZE_FUNC(js_cc_scene_BakedSkinningModel_finalize) - -bool js_register_scene_BakedSkinningModel(se::Object* obj) // NOLINT(readability-identifier-naming) -{ - auto* cls = se::Class::create("BakedSkinningModel", obj, __jsb_cc_scene_Model_proto, _SE(js_scene_BakedSkinningModel_constructor)); - - cls->defineFunction("setAnimInfoIdx", _SE(js_scene_BakedSkinningModel_setAnimInfoIdx)); - cls->defineFunction("setJointMedium", _SE(js_scene_BakedSkinningModel_setJointMedium)); - cls->defineFunction("updateModelBounds", _SE(js_scene_BakedSkinningModel_updateModelBounds)); - cls->defineFinalizeFunction(_SE(js_cc_scene_BakedSkinningModel_finalize)); - cls->install(); - JSBClassType::registerClass(cls); - - __jsb_cc_scene_BakedSkinningModel_proto = cls->getProto(); - __jsb_cc_scene_BakedSkinningModel_class = cls; - - se::ScriptEngine::getInstance()->clearException(); - return true; -} -se::Object* __jsb_cc_scene_DrawBatch2D_proto = nullptr; -se::Class* __jsb_cc_scene_DrawBatch2D_class = nullptr; +SE_BIND_PROP_SET(js_scene_DrawBatch2D_set_shaders) template<> @@ -6755,23 +12048,23 @@ bool sevalue_to_native(const se::Value &from, cc::scene::DrawBatch2D * to, se::O } se::Value field; bool ok = true; - json->getProperty("visFlags", &field); + json->getProperty("visFlags", &field, true); if(!field.isNullOrUndefined()) { ok &= sevalue_to_native(field, &(to->visFlags), ctx); } - json->getProperty("descriptorSet", &field); + json->getProperty("descriptorSet", &field, true); if(!field.isNullOrUndefined()) { ok &= sevalue_to_native(field, &(to->descriptorSet), ctx); } - json->getProperty("inputAssembler", &field); + json->getProperty("inputAssembler", &field, true); if(!field.isNullOrUndefined()) { ok &= sevalue_to_native(field, &(to->inputAssembler), ctx); } - json->getProperty("passes", &field); + json->getProperty("passes", &field, true); if(!field.isNullOrUndefined()) { ok &= sevalue_to_native(field, &(to->passes), ctx); } - json->getProperty("shaders", &field); + json->getProperty("shaders", &field, true); if(!field.isNullOrUndefined()) { ok &= sevalue_to_native(field, &(to->shaders), ctx); } @@ -6788,9 +12081,8 @@ static bool js_scene_DrawBatch2D_constructor(se::State& s) // NOLINT(readability if(argc == 0) { - cc::scene::DrawBatch2D* cobj = JSB_ALLOC(cc::scene::DrawBatch2D); - s.thisObject()->setPrivateData(cobj); - se::NonRefNativePtrCreatedByCtorMap::emplace(cobj); + auto *ptr = JSB_MAKE_PRIVATE_OBJECT(cc::scene::DrawBatch2D); + s.thisObject()->setPrivateObject(ptr); return true; } @@ -6798,21 +12090,19 @@ static bool js_scene_DrawBatch2D_constructor(se::State& s) // NOLINT(readability { se::Object *json = args[0].toObject(); se::Value field; - - cc::scene::DrawBatch2D* cobj = JSB_ALLOC(cc::scene::DrawBatch2D); + auto *ptr = JSB_MAKE_PRIVATE_OBJECT(cc::scene::DrawBatch2D); + auto cobj = ptr->get(); ok &= sevalue_to_native(args[0], cobj, s.thisObject()); if(!ok) { - JSB_FREE(cobj); + delete ptr; SE_REPORT_ERROR("argument convertion error"); return false; } - - s.thisObject()->setPrivateData(cobj); - se::NonRefNativePtrCreatedByCtorMap::emplace(cobj); + s.thisObject()->setPrivateObject(ptr); return true; } - - cc::scene::DrawBatch2D* cobj = JSB_ALLOC(cc::scene::DrawBatch2D); + auto *ptr = JSB_MAKE_PRIVATE_OBJECT(cc::scene::DrawBatch2D); + auto cobj = ptr->get(); if (argc > 0 && !args[0].isUndefined()) { ok &= sevalue_to_native(args[0], &(cobj->visFlags), nullptr); } @@ -6830,28 +12120,17 @@ static bool js_scene_DrawBatch2D_constructor(se::State& s) // NOLINT(readability } if(!ok) { - JSB_FREE(cobj); + delete ptr; SE_REPORT_ERROR("Argument convertion error"); return false; } - - s.thisObject()->setPrivateData(cobj); - se::NonRefNativePtrCreatedByCtorMap::emplace(cobj); + s.thisObject()->setPrivateObject(ptr); return true; } SE_BIND_CTOR(js_scene_DrawBatch2D_constructor, __jsb_cc_scene_DrawBatch2D_class, js_cc_scene_DrawBatch2D_finalize) - - static bool js_cc_scene_DrawBatch2D_finalize(se::State& s) // NOLINT(readability-identifier-naming) { - auto iter = se::NonRefNativePtrCreatedByCtorMap::find(SE_THIS_OBJECT(s)); - if (iter != se::NonRefNativePtrCreatedByCtorMap::end()) - { - se::NonRefNativePtrCreatedByCtorMap::erase(iter); - auto* cobj = SE_THIS_OBJECT(s); - JSB_FREE(cobj); - } return true; } SE_BIND_FINALIZE_FUNC(js_cc_scene_DrawBatch2D_finalize) @@ -6860,6 +12139,11 @@ bool js_register_scene_DrawBatch2D(se::Object* obj) // NOLINT(readability-identi { auto* cls = se::Class::create("DrawBatch2D", obj, nullptr, _SE(js_scene_DrawBatch2D_constructor)); + cls->defineProperty("visFlags", _SE(js_scene_DrawBatch2D_get_visFlags), _SE(js_scene_DrawBatch2D_set_visFlags)); + cls->defineProperty("descriptorSet", _SE(js_scene_DrawBatch2D_get_descriptorSet), _SE(js_scene_DrawBatch2D_set_descriptorSet)); + cls->defineProperty("inputAssembler", _SE(js_scene_DrawBatch2D_get_inputAssembler), _SE(js_scene_DrawBatch2D_set_inputAssembler)); + cls->defineProperty("passes", _SE(js_scene_DrawBatch2D_get_passes), _SE(js_scene_DrawBatch2D_set_passes)); + cls->defineProperty("shaders", _SE(js_scene_DrawBatch2D_get_shaders), _SE(js_scene_DrawBatch2D_set_shaders)); cls->defineFinalizeFunction(_SE(js_cc_scene_DrawBatch2D_finalize)); cls->install(); JSBClassType::registerClass(cls); @@ -6867,47 +12151,63 @@ bool js_register_scene_DrawBatch2D(se::Object* obj) // NOLINT(readability-identi __jsb_cc_scene_DrawBatch2D_proto = cls->getProto(); __jsb_cc_scene_DrawBatch2D_class = cls; + se::ScriptEngine::getInstance()->clearException(); return true; } -se::Object* __jsb_cc_scene_JointTransform_proto = nullptr; -se::Class* __jsb_cc_scene_JointTransform_class = nullptr; +se::Object* __jsb_cc_scene_IRenderSceneInfo_proto = nullptr; // NOLINT +se::Class* __jsb_cc_scene_IRenderSceneInfo_class = nullptr; // NOLINT + +static bool js_scene_IRenderSceneInfo_get_name(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_scene_IRenderSceneInfo_get_name : Invalid Native Object"); + + CC_UNUSED bool ok = true; + se::Value jsret; + ok &= nativevalue_to_se(cobj->name, jsret, s.thisObject() /*ctx*/); + s.rval() = jsret; + SE_HOLD_RETURN_VALUE(cobj->name, s.thisObject(), s.rval()); + return true; +} +SE_BIND_PROP_GET(js_scene_IRenderSceneInfo_get_name) + +static bool js_scene_IRenderSceneInfo_set_name(se::State& s) // NOLINT(readability-identifier-naming) +{ + const auto& args = s.args(); + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_scene_IRenderSceneInfo_set_name : Invalid Native Object"); + + CC_UNUSED bool ok = true; + ok &= sevalue_to_native(args[0], &cobj->name, s.thisObject()); + SE_PRECONDITION2(ok, false, "js_scene_IRenderSceneInfo_set_name : Error processing new value"); + return true; +} +SE_BIND_PROP_SET(js_scene_IRenderSceneInfo_set_name) template<> -bool sevalue_to_native(const se::Value &from, cc::scene::JointTransform * to, se::Object *ctx) +bool sevalue_to_native(const se::Value &from, cc::scene::IRenderSceneInfo * to, se::Object *ctx) { assert(from.isObject()); se::Object *json = from.toObject(); - auto* data = reinterpret_cast(json->getPrivateData()); + auto* data = reinterpret_cast(json->getPrivateData()); if (data) { *to = *data; return true; } se::Value field; bool ok = true; - json->getProperty("node", &field); + json->getProperty("name", &field, true); if(!field.isNullOrUndefined()) { - ok &= sevalue_to_native(field, &(to->node), ctx); - } - json->getProperty("local", &field); - if(!field.isNullOrUndefined()) { - ok &= sevalue_to_native(field, &(to->local), ctx); - } - json->getProperty("world", &field); - if(!field.isNullOrUndefined()) { - ok &= sevalue_to_native(field, &(to->world), ctx); - } - json->getProperty("stamp", &field); - if(!field.isNullOrUndefined()) { - ok &= sevalue_to_native(field, &(to->stamp), ctx); + ok &= sevalue_to_native(field, &(to->name), ctx); } return ok; } -SE_DECLARE_FINALIZE_FUNC(js_cc_scene_JointTransform_finalize) +SE_DECLARE_FINALIZE_FUNC(js_cc_scene_IRenderSceneInfo_finalize) -static bool js_scene_JointTransform_constructor(se::State& s) // NOLINT(readability-identifier-naming) +static bool js_scene_IRenderSceneInfo_constructor(se::State& s) // NOLINT(readability-identifier-naming) { CC_UNUSED bool ok = true; const auto& args = s.args(); @@ -6915,359 +12215,50 @@ static bool js_scene_JointTransform_constructor(se::State& s) // NOLINT(readabil if(argc == 0) { - cc::scene::JointTransform* cobj = JSB_ALLOC(cc::scene::JointTransform); - s.thisObject()->setPrivateData(cobj); - se::NonRefNativePtrCreatedByCtorMap::emplace(cobj); + auto *ptr = JSB_MAKE_PRIVATE_OBJECT(cc::scene::IRenderSceneInfo); + s.thisObject()->setPrivateObject(ptr); return true; } - - if(argc == 1 && args[0].isObject()) - { - se::Object *json = args[0].toObject(); - se::Value field; - - cc::scene::JointTransform* cobj = JSB_ALLOC(cc::scene::JointTransform); - ok &= sevalue_to_native(args[0], cobj, s.thisObject()); - if(!ok) { - JSB_FREE(cobj); - SE_REPORT_ERROR("argument convertion error"); - return false; - } - - s.thisObject()->setPrivateData(cobj); - se::NonRefNativePtrCreatedByCtorMap::emplace(cobj); - return true; - } - - cc::scene::JointTransform* cobj = JSB_ALLOC(cc::scene::JointTransform); + auto *ptr = JSB_MAKE_PRIVATE_OBJECT(cc::scene::IRenderSceneInfo); + auto cobj = ptr->get(); if (argc > 0 && !args[0].isUndefined()) { - ok &= sevalue_to_native(args[0], &(cobj->node), nullptr); - } - if (argc > 1 && !args[1].isUndefined()) { - ok &= sevalue_to_native(args[1], &(cobj->local), nullptr); - } - if (argc > 2 && !args[2].isUndefined()) { - ok &= sevalue_to_native(args[2], &(cobj->world), nullptr); - } - if (argc > 3 && !args[3].isUndefined()) { - ok &= sevalue_to_native(args[3], &(cobj->stamp), nullptr); + ok &= sevalue_to_native(args[0], &(cobj->name), nullptr); } if(!ok) { - JSB_FREE(cobj); + delete ptr; SE_REPORT_ERROR("Argument convertion error"); return false; } - - s.thisObject()->setPrivateData(cobj); - se::NonRefNativePtrCreatedByCtorMap::emplace(cobj); + s.thisObject()->setPrivateObject(ptr); return true; } -SE_BIND_CTOR(js_scene_JointTransform_constructor, __jsb_cc_scene_JointTransform_class, js_cc_scene_JointTransform_finalize) +SE_BIND_CTOR(js_scene_IRenderSceneInfo_constructor, __jsb_cc_scene_IRenderSceneInfo_class, js_cc_scene_IRenderSceneInfo_finalize) - - -static bool js_cc_scene_JointTransform_finalize(se::State& s) // NOLINT(readability-identifier-naming) +static bool js_cc_scene_IRenderSceneInfo_finalize(se::State& s) // NOLINT(readability-identifier-naming) { - auto iter = se::NonRefNativePtrCreatedByCtorMap::find(SE_THIS_OBJECT(s)); - if (iter != se::NonRefNativePtrCreatedByCtorMap::end()) - { - se::NonRefNativePtrCreatedByCtorMap::erase(iter); - auto* cobj = SE_THIS_OBJECT(s); - JSB_FREE(cobj); - } return true; } -SE_BIND_FINALIZE_FUNC(js_cc_scene_JointTransform_finalize) +SE_BIND_FINALIZE_FUNC(js_cc_scene_IRenderSceneInfo_finalize) -bool js_register_scene_JointTransform(se::Object* obj) // NOLINT(readability-identifier-naming) +bool js_register_scene_IRenderSceneInfo(se::Object* obj) // NOLINT(readability-identifier-naming) { - auto* cls = se::Class::create("JointTransform", obj, nullptr, _SE(js_scene_JointTransform_constructor)); + auto* cls = se::Class::create("IRenderSceneInfo", obj, nullptr, _SE(js_scene_IRenderSceneInfo_constructor)); - cls->defineFinalizeFunction(_SE(js_cc_scene_JointTransform_finalize)); + cls->defineProperty("name", _SE(js_scene_IRenderSceneInfo_get_name), _SE(js_scene_IRenderSceneInfo_set_name)); + cls->defineFinalizeFunction(_SE(js_cc_scene_IRenderSceneInfo_finalize)); cls->install(); - JSBClassType::registerClass(cls); + JSBClassType::registerClass(cls); + + __jsb_cc_scene_IRenderSceneInfo_proto = cls->getProto(); + __jsb_cc_scene_IRenderSceneInfo_class = cls; - __jsb_cc_scene_JointTransform_proto = cls->getProto(); - __jsb_cc_scene_JointTransform_class = cls; se::ScriptEngine::getInstance()->clearException(); return true; } -se::Object* __jsb_cc_scene_JointInfo_proto = nullptr; -se::Class* __jsb_cc_scene_JointInfo_class = nullptr; - - -template<> -bool sevalue_to_native(const se::Value &from, cc::scene::JointInfo * to, se::Object *ctx) -{ - assert(from.isObject()); - se::Object *json = from.toObject(); - auto* data = reinterpret_cast(json->getPrivateData()); - if (data) { - *to = *data; - return true; - } - se::Value field; - bool ok = true; - json->getProperty("bound", &field); - if(!field.isNullOrUndefined()) { - ok &= sevalue_to_native(field, &(to->bound), ctx); - } - json->getProperty("target", &field); - if(!field.isNullOrUndefined()) { - ok &= sevalue_to_native(field, &(to->target), ctx); - } - json->getProperty("bindpose", &field); - if(!field.isNullOrUndefined()) { - ok &= sevalue_to_native(field, &(to->bindpose), ctx); - } - json->getProperty("transform", &field); - if(!field.isNullOrUndefined()) { - ok &= sevalue_to_native(field, &(to->transform), ctx); - } - json->getProperty("parents", &field); - if(!field.isNullOrUndefined()) { - ok &= sevalue_to_native(field, &(to->parents), ctx); - } - json->getProperty("buffers", &field); - if(!field.isNullOrUndefined()) { - ok &= sevalue_to_native(field, &(to->buffers), ctx); - } - json->getProperty("indices", &field); - if(!field.isNullOrUndefined()) { - ok &= sevalue_to_native(field, &(to->indices), ctx); - } - return ok; -} - -SE_DECLARE_FINALIZE_FUNC(js_cc_scene_JointInfo_finalize) - -static bool js_scene_JointInfo_constructor(se::State& s) // NOLINT(readability-identifier-naming) -{ - CC_UNUSED bool ok = true; - const auto& args = s.args(); - size_t argc = args.size(); - - if(argc == 0) - { - cc::scene::JointInfo* cobj = JSB_ALLOC(cc::scene::JointInfo); - s.thisObject()->setPrivateData(cobj); - se::NonRefNativePtrCreatedByCtorMap::emplace(cobj); - return true; - } - - if(argc == 1 && args[0].isObject()) - { - se::Object *json = args[0].toObject(); - se::Value field; - - cc::scene::JointInfo* cobj = JSB_ALLOC(cc::scene::JointInfo); - ok &= sevalue_to_native(args[0], cobj, s.thisObject()); - if(!ok) { - JSB_FREE(cobj); - SE_REPORT_ERROR("argument convertion error"); - return false; - } - - s.thisObject()->setPrivateData(cobj); - se::NonRefNativePtrCreatedByCtorMap::emplace(cobj); - return true; - } - - cc::scene::JointInfo* cobj = JSB_ALLOC(cc::scene::JointInfo); - if (argc > 0 && !args[0].isUndefined()) { - ok &= sevalue_to_native(args[0], &(cobj->bound), nullptr); - } - if (argc > 1 && !args[1].isUndefined()) { - ok &= sevalue_to_native(args[1], &(cobj->target), nullptr); - } - if (argc > 2 && !args[2].isUndefined()) { - ok &= sevalue_to_native(args[2], &(cobj->bindpose), nullptr); - } - if (argc > 3 && !args[3].isUndefined()) { - ok &= sevalue_to_native(args[3], &(cobj->transform), nullptr); - } - if (argc > 4 && !args[4].isUndefined()) { - ok &= sevalue_to_native(args[4], &(cobj->parents), nullptr); - } - if (argc > 5 && !args[5].isUndefined()) { - ok &= sevalue_to_native(args[5], &(cobj->buffers), nullptr); - } - if (argc > 6 && !args[6].isUndefined()) { - ok &= sevalue_to_native(args[6], &(cobj->indices), nullptr); - } - - if(!ok) { - JSB_FREE(cobj); - SE_REPORT_ERROR("Argument convertion error"); - return false; - } - - s.thisObject()->setPrivateData(cobj); - se::NonRefNativePtrCreatedByCtorMap::emplace(cobj); - return true; -} -SE_BIND_CTOR(js_scene_JointInfo_constructor, __jsb_cc_scene_JointInfo_class, js_cc_scene_JointInfo_finalize) - - - -static bool js_cc_scene_JointInfo_finalize(se::State& s) // NOLINT(readability-identifier-naming) -{ - auto iter = se::NonRefNativePtrCreatedByCtorMap::find(SE_THIS_OBJECT(s)); - if (iter != se::NonRefNativePtrCreatedByCtorMap::end()) - { - se::NonRefNativePtrCreatedByCtorMap::erase(iter); - auto* cobj = SE_THIS_OBJECT(s); - JSB_FREE(cobj); - } - return true; -} -SE_BIND_FINALIZE_FUNC(js_cc_scene_JointInfo_finalize) - -bool js_register_scene_JointInfo(se::Object* obj) // NOLINT(readability-identifier-naming) -{ - auto* cls = se::Class::create("JointInfo", obj, nullptr, _SE(js_scene_JointInfo_constructor)); - - cls->defineFinalizeFunction(_SE(js_cc_scene_JointInfo_finalize)); - cls->install(); - JSBClassType::registerClass(cls); - - __jsb_cc_scene_JointInfo_proto = cls->getProto(); - __jsb_cc_scene_JointInfo_class = cls; - - se::ScriptEngine::getInstance()->clearException(); - return true; -} -se::Object* __jsb_cc_scene_SkinningModel_proto = nullptr; -se::Class* __jsb_cc_scene_SkinningModel_class = nullptr; - -static bool js_scene_SkinningModel_setBuffers(se::State& s) // NOLINT(readability-identifier-naming) -{ - auto* cobj = SE_THIS_OBJECT(s); - SE_PRECONDITION2(cobj, false, "js_scene_SkinningModel_setBuffers : Invalid Native Object"); - const auto& args = s.args(); - size_t argc = args.size(); - CC_UNUSED bool ok = true; - if (argc == 1) { - HolderType, false> arg0 = {}; - ok &= sevalue_to_native(args[0], &arg0, s.thisObject()); - SE_PRECONDITION2(ok, false, "js_scene_SkinningModel_setBuffers : Error processing arguments"); - cobj->setBuffers(arg0.value()); - return true; - } - SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 1); - return false; -} -SE_BIND_FUNC(js_scene_SkinningModel_setBuffers) - -static bool js_scene_SkinningModel_setIndicesAndJoints(se::State& s) // NOLINT(readability-identifier-naming) -{ - auto* cobj = SE_THIS_OBJECT(s); - SE_PRECONDITION2(cobj, false, "js_scene_SkinningModel_setIndicesAndJoints : Invalid Native Object"); - const auto& args = s.args(); - size_t argc = args.size(); - CC_UNUSED bool ok = true; - if (argc == 2) { - HolderType, false> arg0 = {}; - HolderType, false> arg1 = {}; - ok &= sevalue_to_native(args[0], &arg0, s.thisObject()); - ok &= sevalue_to_native(args[1], &arg1, s.thisObject()); - SE_PRECONDITION2(ok, false, "js_scene_SkinningModel_setIndicesAndJoints : Error processing arguments"); - cobj->setIndicesAndJoints(arg0.value(), arg1.value()); - return true; - } - SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 2); - return false; -} -SE_BIND_FUNC(js_scene_SkinningModel_setIndicesAndJoints) - -static bool js_scene_SkinningModel_setNeedUpdate(se::State& s) // NOLINT(readability-identifier-naming) -{ - auto* cobj = SE_THIS_OBJECT(s); - SE_PRECONDITION2(cobj, false, "js_scene_SkinningModel_setNeedUpdate : Invalid Native Object"); - const auto& args = s.args(); - size_t argc = args.size(); - CC_UNUSED bool ok = true; - if (argc == 1) { - HolderType arg0 = {}; - ok &= sevalue_to_native(args[0], &arg0, s.thisObject()); - SE_PRECONDITION2(ok, false, "js_scene_SkinningModel_setNeedUpdate : Error processing arguments"); - cobj->setNeedUpdate(arg0.value()); - return true; - } - SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 1); - return false; -} -SE_BIND_FUNC(js_scene_SkinningModel_setNeedUpdate) - -static bool js_scene_SkinningModel_updateLocalDescriptors(se::State& s) // NOLINT(readability-identifier-naming) -{ - auto* cobj = SE_THIS_OBJECT(s); - SE_PRECONDITION2(cobj, false, "js_scene_SkinningModel_updateLocalDescriptors : Invalid Native Object"); - const auto& args = s.args(); - size_t argc = args.size(); - CC_UNUSED bool ok = true; - if (argc == 2) { - HolderType arg0 = {}; - HolderType arg1 = {}; - ok &= sevalue_to_native(args[0], &arg0, s.thisObject()); - ok &= sevalue_to_native(args[1], &arg1, s.thisObject()); - SE_PRECONDITION2(ok, false, "js_scene_SkinningModel_updateLocalDescriptors : Error processing arguments"); - cobj->updateLocalDescriptors(arg0.value(), arg1.value()); - return true; - } - SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 2); - return false; -} -SE_BIND_FUNC(js_scene_SkinningModel_updateLocalDescriptors) - -SE_DECLARE_FINALIZE_FUNC(js_cc_scene_SkinningModel_finalize) - -static bool js_scene_SkinningModel_constructor(se::State& s) // NOLINT(readability-identifier-naming) constructor.c -{ - cc::scene::SkinningModel* cobj = JSB_ALLOC(cc::scene::SkinningModel); - s.thisObject()->setPrivateData(cobj); - se::NonRefNativePtrCreatedByCtorMap::emplace(cobj); - return true; -} -SE_BIND_CTOR(js_scene_SkinningModel_constructor, __jsb_cc_scene_SkinningModel_class, js_cc_scene_SkinningModel_finalize) - - - -static bool js_cc_scene_SkinningModel_finalize(se::State& s) // NOLINT(readability-identifier-naming) -{ - auto iter = se::NonRefNativePtrCreatedByCtorMap::find(SE_THIS_OBJECT(s)); - if (iter != se::NonRefNativePtrCreatedByCtorMap::end()) - { - se::NonRefNativePtrCreatedByCtorMap::erase(iter); - auto* cobj = SE_THIS_OBJECT(s); - JSB_FREE(cobj); - } - return true; -} -SE_BIND_FINALIZE_FUNC(js_cc_scene_SkinningModel_finalize) - -bool js_register_scene_SkinningModel(se::Object* obj) // NOLINT(readability-identifier-naming) -{ - auto* cls = se::Class::create("SkinningModel", obj, __jsb_cc_scene_Model_proto, _SE(js_scene_SkinningModel_constructor)); - - cls->defineFunction("setBuffers", _SE(js_scene_SkinningModel_setBuffers)); - cls->defineFunction("setIndicesAndJoints", _SE(js_scene_SkinningModel_setIndicesAndJoints)); - cls->defineFunction("setNeedUpdate", _SE(js_scene_SkinningModel_setNeedUpdate)); - cls->defineFunction("updateLocalDescriptors", _SE(js_scene_SkinningModel_updateLocalDescriptors)); - cls->defineFinalizeFunction(_SE(js_cc_scene_SkinningModel_finalize)); - cls->install(); - JSBClassType::registerClass(cls); - - __jsb_cc_scene_SkinningModel_proto = cls->getProto(); - __jsb_cc_scene_SkinningModel_class = cls; - - se::ScriptEngine::getInstance()->clearException(); - return true; -} -se::Object* __jsb_cc_scene_RenderScene_proto = nullptr; -se::Class* __jsb_cc_scene_RenderScene_class = nullptr; +se::Object* __jsb_cc_scene_RenderScene_proto = nullptr; // NOLINT +se::Class* __jsb_cc_scene_RenderScene_class = nullptr; // NOLINT static bool js_scene_RenderScene_activate(se::State& s) // NOLINT(readability-identifier-naming) { @@ -7284,25 +12275,6 @@ static bool js_scene_RenderScene_activate(se::State& s) // NOLINT(readability-id } SE_BIND_FUNC(js_scene_RenderScene_activate) -static bool js_scene_RenderScene_addBakedSkinningModel(se::State& s) // NOLINT(readability-identifier-naming) -{ - auto* cobj = SE_THIS_OBJECT(s); - SE_PRECONDITION2(cobj, false, "js_scene_RenderScene_addBakedSkinningModel : Invalid Native Object"); - const auto& args = s.args(); - size_t argc = args.size(); - CC_UNUSED bool ok = true; - if (argc == 1) { - HolderType arg0 = {}; - ok &= sevalue_to_native(args[0], &arg0, s.thisObject()); - SE_PRECONDITION2(ok, false, "js_scene_RenderScene_addBakedSkinningModel : Error processing arguments"); - cobj->addBakedSkinningModel(arg0.value()); - return true; - } - SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 1); - return false; -} -SE_BIND_FUNC(js_scene_RenderScene_addBakedSkinningModel) - static bool js_scene_RenderScene_addBatch(se::State& s) // NOLINT(readability-identifier-naming) { auto* cobj = SE_THIS_OBJECT(s); @@ -7322,6 +12294,44 @@ static bool js_scene_RenderScene_addBatch(se::State& s) // NOLINT(readability-id } SE_BIND_FUNC(js_scene_RenderScene_addBatch) +static bool js_scene_RenderScene_addCamera(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_scene_RenderScene_addCamera : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 1) { + HolderType arg0 = {}; + ok &= sevalue_to_native(args[0], &arg0, s.thisObject()); + SE_PRECONDITION2(ok, false, "js_scene_RenderScene_addCamera : Error processing arguments"); + cobj->addCamera(arg0.value()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 1); + return false; +} +SE_BIND_FUNC(js_scene_RenderScene_addCamera) + +static bool js_scene_RenderScene_addDirectionalLight(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_scene_RenderScene_addDirectionalLight : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 1) { + HolderType arg0 = {}; + ok &= sevalue_to_native(args[0], &arg0, s.thisObject()); + SE_PRECONDITION2(ok, false, "js_scene_RenderScene_addDirectionalLight : Error processing arguments"); + cobj->addDirectionalLight(arg0.value()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 1); + return false; +} +SE_BIND_FUNC(js_scene_RenderScene_addDirectionalLight) + static bool js_scene_RenderScene_addModel(se::State& s) // NOLINT(readability-identifier-naming) { auto* cobj = SE_THIS_OBJECT(s); @@ -7341,25 +12351,6 @@ static bool js_scene_RenderScene_addModel(se::State& s) // NOLINT(readability-id } SE_BIND_FUNC(js_scene_RenderScene_addModel) -static bool js_scene_RenderScene_addSkinningModel(se::State& s) // NOLINT(readability-identifier-naming) -{ - auto* cobj = SE_THIS_OBJECT(s); - SE_PRECONDITION2(cobj, false, "js_scene_RenderScene_addSkinningModel : Invalid Native Object"); - const auto& args = s.args(); - size_t argc = args.size(); - CC_UNUSED bool ok = true; - if (argc == 1) { - HolderType arg0 = {}; - ok &= sevalue_to_native(args[0], &arg0, s.thisObject()); - SE_PRECONDITION2(ok, false, "js_scene_RenderScene_addSkinningModel : Error processing arguments"); - cobj->addSkinningModel(arg0.value()); - return true; - } - SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 1); - return false; -} -SE_BIND_FUNC(js_scene_RenderScene_addSkinningModel) - static bool js_scene_RenderScene_addSphereLight(se::State& s) // NOLINT(readability-identifier-naming) { auto* cobj = SE_THIS_OBJECT(s); @@ -7398,6 +12389,79 @@ static bool js_scene_RenderScene_addSpotLight(se::State& s) // NOLINT(readabilit } SE_BIND_FUNC(js_scene_RenderScene_addSpotLight) +static bool js_scene_RenderScene_destroy(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_scene_RenderScene_destroy : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + if (argc == 0) { + cobj->destroy(); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 0); + return false; +} +SE_BIND_FUNC(js_scene_RenderScene_destroy) + +static bool js_scene_RenderScene_generateModelId(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_scene_RenderScene_generateModelId : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 0) { + uint64_t result = cobj->generateModelId(); + ok &= nativevalue_to_se(result, s.rval(), nullptr /*ctx*/); + SE_PRECONDITION2(ok, false, "js_scene_RenderScene_generateModelId : Error processing arguments"); + SE_HOLD_RETURN_VALUE(result, s.thisObject(), s.rval()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 0); + return false; +} +SE_BIND_FUNC(js_scene_RenderScene_generateModelId) + +static bool js_scene_RenderScene_getBatches(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_scene_RenderScene_getBatches : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 0) { + const std::vector& result = cobj->getBatches(); + ok &= nativevalue_to_se(result, s.rval(), nullptr /*ctx*/); + SE_PRECONDITION2(ok, false, "js_scene_RenderScene_getBatches : Error processing arguments"); + SE_HOLD_RETURN_VALUE(result, s.thisObject(), s.rval()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 0); + return false; +} +SE_BIND_FUNC(js_scene_RenderScene_getBatches) + +static bool js_scene_RenderScene_getCameras(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_scene_RenderScene_getCameras : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 0) { + const std::vector>& result = cobj->getCameras(); + ok &= nativevalue_to_se(result, s.rval(), nullptr /*ctx*/); + SE_PRECONDITION2(ok, false, "js_scene_RenderScene_getCameras : Error processing arguments"); + SE_HOLD_RETURN_VALUE(result, s.thisObject(), s.rval()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 0); + return false; +} +SE_BIND_FUNC_AS_PROP_GET(js_scene_RenderScene_getCameras) +SE_BIND_FUNC(js_scene_RenderScene_getCameras) + static bool js_scene_RenderScene_getDrawBatch2Ds(se::State& s) // NOLINT(readability-identifier-naming) { auto* cobj = SE_THIS_OBJECT(s); @@ -7434,6 +12498,7 @@ static bool js_scene_RenderScene_getMainLight(se::State& s) // NOLINT(readabilit SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 0); return false; } +SE_BIND_FUNC_AS_PROP_GET(js_scene_RenderScene_getMainLight) SE_BIND_FUNC(js_scene_RenderScene_getMainLight) static bool js_scene_RenderScene_getModels(se::State& s) // NOLINT(readability-identifier-naming) @@ -7444,7 +12509,7 @@ static bool js_scene_RenderScene_getModels(se::State& s) // NOLINT(readability-i size_t argc = args.size(); CC_UNUSED bool ok = true; if (argc == 0) { - const std::vector& result = cobj->getModels(); + const std::vector>& result = cobj->getModels(); ok &= nativevalue_to_se(result, s.rval(), nullptr /*ctx*/); SE_PRECONDITION2(ok, false, "js_scene_RenderScene_getModels : Error processing arguments"); SE_HOLD_RETURN_VALUE(result, s.thisObject(), s.rval()); @@ -7453,7 +12518,45 @@ static bool js_scene_RenderScene_getModels(se::State& s) // NOLINT(readability-i SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 0); return false; } -SE_BIND_FUNC(js_scene_RenderScene_getModels) +SE_BIND_FUNC_AS_PROP_GET(js_scene_RenderScene_getModels) + +static bool js_scene_RenderScene_getName(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_scene_RenderScene_getName : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 0) { + const std::string& result = cobj->getName(); + ok &= nativevalue_to_se(result, s.rval(), nullptr /*ctx*/); + SE_PRECONDITION2(ok, false, "js_scene_RenderScene_getName : Error processing arguments"); + SE_HOLD_RETURN_VALUE(result, s.thisObject(), s.rval()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 0); + return false; +} +SE_BIND_FUNC_AS_PROP_GET(js_scene_RenderScene_getName) + +static bool js_scene_RenderScene_getOctree(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_scene_RenderScene_getOctree : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 0) { + cc::scene::Octree* result = cobj->getOctree(); + ok &= nativevalue_to_se(result, s.rval(), nullptr /*ctx*/); + SE_PRECONDITION2(ok, false, "js_scene_RenderScene_getOctree : Error processing arguments"); + SE_HOLD_RETURN_VALUE(result, s.thisObject(), s.rval()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 0); + return false; +} +SE_BIND_FUNC(js_scene_RenderScene_getOctree) static bool js_scene_RenderScene_getSphereLights(se::State& s) // NOLINT(readability-identifier-naming) { @@ -7463,7 +12566,7 @@ static bool js_scene_RenderScene_getSphereLights(se::State& s) // NOLINT(readabi size_t argc = args.size(); CC_UNUSED bool ok = true; if (argc == 0) { - const std::vector& result = cobj->getSphereLights(); + const std::vector>& result = cobj->getSphereLights(); ok &= nativevalue_to_se(result, s.rval(), nullptr /*ctx*/); SE_PRECONDITION2(ok, false, "js_scene_RenderScene_getSphereLights : Error processing arguments"); SE_HOLD_RETURN_VALUE(result, s.thisObject(), s.rval()); @@ -7472,6 +12575,7 @@ static bool js_scene_RenderScene_getSphereLights(se::State& s) // NOLINT(readabi SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 0); return false; } +SE_BIND_FUNC_AS_PROP_GET(js_scene_RenderScene_getSphereLights) SE_BIND_FUNC(js_scene_RenderScene_getSphereLights) static bool js_scene_RenderScene_getSpotLights(se::State& s) // NOLINT(readability-identifier-naming) @@ -7482,7 +12586,7 @@ static bool js_scene_RenderScene_getSpotLights(se::State& s) // NOLINT(readabili size_t argc = args.size(); CC_UNUSED bool ok = true; if (argc == 0) { - const std::vector& result = cobj->getSpotLights(); + const std::vector>& result = cobj->getSpotLights(); ok &= nativevalue_to_se(result, s.rval(), nullptr /*ctx*/); SE_PRECONDITION2(ok, false, "js_scene_RenderScene_getSpotLights : Error processing arguments"); SE_HOLD_RETURN_VALUE(result, s.thisObject(), s.rval()); @@ -7491,38 +12595,61 @@ static bool js_scene_RenderScene_getSpotLights(se::State& s) // NOLINT(readabili SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 0); return false; } +SE_BIND_FUNC_AS_PROP_GET(js_scene_RenderScene_getSpotLights) SE_BIND_FUNC(js_scene_RenderScene_getSpotLights) +static bool js_scene_RenderScene_initialize(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_scene_RenderScene_initialize : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 1) { + HolderType arg0 = {}; + ok &= sevalue_to_native(args[0], &arg0, s.thisObject()); + SE_PRECONDITION2(ok, false, "js_scene_RenderScene_initialize : Error processing arguments"); + bool result = cobj->initialize(arg0.value()); + ok &= nativevalue_to_se(result, s.rval(), nullptr /*ctx*/); + SE_PRECONDITION2(ok, false, "js_scene_RenderScene_initialize : Error processing arguments"); + SE_HOLD_RETURN_VALUE(result, s.thisObject(), s.rval()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 1); + return false; +} +SE_BIND_FUNC(js_scene_RenderScene_initialize) + +static bool js_scene_RenderScene_onGlobalPipelineStateChanged(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_scene_RenderScene_onGlobalPipelineStateChanged : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + if (argc == 0) { + cobj->onGlobalPipelineStateChanged(); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 0); + return false; +} +SE_BIND_FUNC(js_scene_RenderScene_onGlobalPipelineStateChanged) + static bool js_scene_RenderScene_removeBatch(se::State& s) // NOLINT(readability-identifier-naming) { - CC_UNUSED bool ok = true; auto* cobj = SE_THIS_OBJECT(s); - SE_PRECONDITION2( cobj, false, "js_scene_RenderScene_removeBatch : Invalid Native Object"); + SE_PRECONDITION2(cobj, false, "js_scene_RenderScene_removeBatch : Invalid Native Object"); const auto& args = s.args(); size_t argc = args.size(); - do { - if (argc == 1) { - HolderType arg0 = {}; - - ok &= sevalue_to_native(args[0], &arg0, s.thisObject()); - if (!ok) { ok = true; break; } - cobj->removeBatch(arg0.value()); - return true; - } - } while(false); - - do { - if (argc == 1) { - HolderType arg0 = {}; - - ok &= sevalue_to_native(args[0], &arg0, s.thisObject()); - if (!ok) { ok = true; break; } - cobj->removeBatch(arg0.value()); - return true; - } - } while(false); - - SE_REPORT_ERROR("wrong number of arguments: %d", (int)argc); + CC_UNUSED bool ok = true; + if (argc == 1) { + HolderType arg0 = {}; + ok &= sevalue_to_native(args[0], &arg0, s.thisObject()); + SE_PRECONDITION2(ok, false, "js_scene_RenderScene_removeBatch : Error processing arguments"); + cobj->removeBatch(arg0.value()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 1); return false; } SE_BIND_FUNC(js_scene_RenderScene_removeBatch) @@ -7542,23 +12669,91 @@ static bool js_scene_RenderScene_removeBatches(se::State& s) // NOLINT(readabili } SE_BIND_FUNC(js_scene_RenderScene_removeBatches) -static bool js_scene_RenderScene_removeModel(se::State& s) // NOLINT(readability-identifier-naming) +static bool js_scene_RenderScene_removeCamera(se::State& s) // NOLINT(readability-identifier-naming) { auto* cobj = SE_THIS_OBJECT(s); - SE_PRECONDITION2(cobj, false, "js_scene_RenderScene_removeModel : Invalid Native Object"); + SE_PRECONDITION2(cobj, false, "js_scene_RenderScene_removeCamera : Invalid Native Object"); const auto& args = s.args(); size_t argc = args.size(); CC_UNUSED bool ok = true; if (argc == 1) { - HolderType arg0 = {}; + HolderType arg0 = {}; ok &= sevalue_to_native(args[0], &arg0, s.thisObject()); - SE_PRECONDITION2(ok, false, "js_scene_RenderScene_removeModel : Error processing arguments"); - cobj->removeModel(arg0.value()); + SE_PRECONDITION2(ok, false, "js_scene_RenderScene_removeCamera : Error processing arguments"); + cobj->removeCamera(arg0.value()); return true; } SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 1); return false; } +SE_BIND_FUNC(js_scene_RenderScene_removeCamera) + +static bool js_scene_RenderScene_removeCameras(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_scene_RenderScene_removeCameras : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + if (argc == 0) { + cobj->removeCameras(); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 0); + return false; +} +SE_BIND_FUNC(js_scene_RenderScene_removeCameras) + +static bool js_scene_RenderScene_removeDirectionalLight(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_scene_RenderScene_removeDirectionalLight : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 1) { + HolderType arg0 = {}; + ok &= sevalue_to_native(args[0], &arg0, s.thisObject()); + SE_PRECONDITION2(ok, false, "js_scene_RenderScene_removeDirectionalLight : Error processing arguments"); + cobj->removeDirectionalLight(arg0.value()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 1); + return false; +} +SE_BIND_FUNC(js_scene_RenderScene_removeDirectionalLight) + +static bool js_scene_RenderScene_removeModel(se::State& s) // NOLINT(readability-identifier-naming) +{ + CC_UNUSED bool ok = true; + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2( cobj, false, "js_scene_RenderScene_removeModel : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + do { + if (argc == 1) { + HolderType arg0 = {}; + + ok &= sevalue_to_native(args[0], &arg0, s.thisObject()); + if (!ok) { ok = true; break; } + cobj->removeModel(arg0.value()); + return true; + } + } while(false); + + do { + if (argc == 1) { + HolderType arg0 = {}; + + ok &= sevalue_to_native(args[0], &arg0, s.thisObject()); + if (!ok) { ok = true; break; } + cobj->removeModel(arg0.value()); + return true; + } + } while(false); + + SE_REPORT_ERROR("wrong number of arguments: %d", (int)argc); + return false; +} SE_BIND_FUNC(js_scene_RenderScene_removeModel) static bool js_scene_RenderScene_removeModels(se::State& s) // NOLINT(readability-identifier-naming) @@ -7661,8 +12856,28 @@ static bool js_scene_RenderScene_setMainLight(se::State& s) // NOLINT(readabilit SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 1); return false; } +SE_BIND_FUNC_AS_PROP_SET(js_scene_RenderScene_setMainLight) SE_BIND_FUNC(js_scene_RenderScene_setMainLight) +static bool js_scene_RenderScene_unsetMainLight(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_scene_RenderScene_unsetMainLight : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 1) { + HolderType arg0 = {}; + ok &= sevalue_to_native(args[0], &arg0, s.thisObject()); + SE_PRECONDITION2(ok, false, "js_scene_RenderScene_unsetMainLight : Error processing arguments"); + cobj->unsetMainLight(arg0.value()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 1); + return false; +} +SE_BIND_FUNC(js_scene_RenderScene_unsetMainLight) + static bool js_scene_RenderScene_update(se::State& s) // NOLINT(readability-identifier-naming) { auto* cobj = SE_THIS_OBJECT(s); @@ -7682,28 +12897,37 @@ static bool js_scene_RenderScene_update(se::State& s) // NOLINT(readability-iden } SE_BIND_FUNC(js_scene_RenderScene_update) +static bool js_scene_RenderScene_updateOctree(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_scene_RenderScene_updateOctree : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 1) { + HolderType arg0 = {}; + ok &= sevalue_to_native(args[0], &arg0, s.thisObject()); + SE_PRECONDITION2(ok, false, "js_scene_RenderScene_updateOctree : Error processing arguments"); + cobj->updateOctree(arg0.value()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 1); + return false; +} +SE_BIND_FUNC(js_scene_RenderScene_updateOctree) + SE_DECLARE_FINALIZE_FUNC(js_cc_scene_RenderScene_finalize) static bool js_scene_RenderScene_constructor(se::State& s) // NOLINT(readability-identifier-naming) constructor.c { - cc::scene::RenderScene* cobj = JSB_ALLOC(cc::scene::RenderScene); - s.thisObject()->setPrivateData(cobj); - se::NonRefNativePtrCreatedByCtorMap::emplace(cobj); + auto *ptr = JSB_MAKE_PRIVATE_OBJECT(cc::scene::RenderScene); + s.thisObject()->setPrivateObject(ptr); return true; } SE_BIND_CTOR(js_scene_RenderScene_constructor, __jsb_cc_scene_RenderScene_class, js_cc_scene_RenderScene_finalize) - - static bool js_cc_scene_RenderScene_finalize(se::State& s) // NOLINT(readability-identifier-naming) { - auto iter = se::NonRefNativePtrCreatedByCtorMap::find(SE_THIS_OBJECT(s)); - if (iter != se::NonRefNativePtrCreatedByCtorMap::end()) - { - se::NonRefNativePtrCreatedByCtorMap::erase(iter); - auto* cobj = SE_THIS_OBJECT(s); - JSB_FREE(cobj); - } return true; } SE_BIND_FINALIZE_FUNC(js_cc_scene_RenderScene_finalize) @@ -7712,20 +12936,35 @@ bool js_register_scene_RenderScene(se::Object* obj) // NOLINT(readability-identi { auto* cls = se::Class::create("RenderScene", obj, nullptr, _SE(js_scene_RenderScene_constructor)); + cls->defineProperty("mainLight", _SE(js_scene_RenderScene_getMainLight_asGetter), _SE(js_scene_RenderScene_setMainLight_asSetter)); + cls->defineProperty("name", _SE(js_scene_RenderScene_getName_asGetter), nullptr); + cls->defineProperty("models", _SE(js_scene_RenderScene_getModels_asGetter), nullptr); + cls->defineProperty("cameras", _SE(js_scene_RenderScene_getCameras_asGetter), nullptr); + cls->defineProperty("sphereLights", _SE(js_scene_RenderScene_getSphereLights_asGetter), nullptr); + cls->defineProperty("spotLights", _SE(js_scene_RenderScene_getSpotLights_asGetter), nullptr); cls->defineFunction("activate", _SE(js_scene_RenderScene_activate)); - cls->defineFunction("addBakedSkinningModel", _SE(js_scene_RenderScene_addBakedSkinningModel)); cls->defineFunction("addBatch", _SE(js_scene_RenderScene_addBatch)); + cls->defineFunction("addCamera", _SE(js_scene_RenderScene_addCamera)); + cls->defineFunction("addDirectionalLight", _SE(js_scene_RenderScene_addDirectionalLight)); cls->defineFunction("addModel", _SE(js_scene_RenderScene_addModel)); - cls->defineFunction("addSkinningModel", _SE(js_scene_RenderScene_addSkinningModel)); cls->defineFunction("addSphereLight", _SE(js_scene_RenderScene_addSphereLight)); cls->defineFunction("addSpotLight", _SE(js_scene_RenderScene_addSpotLight)); + cls->defineFunction("destroy", _SE(js_scene_RenderScene_destroy)); + cls->defineFunction("generateModelId", _SE(js_scene_RenderScene_generateModelId)); + cls->defineFunction("getBatches", _SE(js_scene_RenderScene_getBatches)); + cls->defineFunction("getCameras", _SE(js_scene_RenderScene_getCameras)); cls->defineFunction("getDrawBatch2Ds", _SE(js_scene_RenderScene_getDrawBatch2Ds)); cls->defineFunction("getMainLight", _SE(js_scene_RenderScene_getMainLight)); - cls->defineFunction("getModels", _SE(js_scene_RenderScene_getModels)); + cls->defineFunction("getOctree", _SE(js_scene_RenderScene_getOctree)); cls->defineFunction("getSphereLights", _SE(js_scene_RenderScene_getSphereLights)); cls->defineFunction("getSpotLights", _SE(js_scene_RenderScene_getSpotLights)); + cls->defineFunction("initialize", _SE(js_scene_RenderScene_initialize)); + cls->defineFunction("onGlobalPipelineStateChanged", _SE(js_scene_RenderScene_onGlobalPipelineStateChanged)); cls->defineFunction("removeBatch", _SE(js_scene_RenderScene_removeBatch)); cls->defineFunction("removeBatches", _SE(js_scene_RenderScene_removeBatches)); + cls->defineFunction("removeCamera", _SE(js_scene_RenderScene_removeCamera)); + cls->defineFunction("removeCameras", _SE(js_scene_RenderScene_removeCameras)); + cls->defineFunction("removeDirectionalLight", _SE(js_scene_RenderScene_removeDirectionalLight)); cls->defineFunction("removeModel", _SE(js_scene_RenderScene_removeModel)); cls->defineFunction("removeModels", _SE(js_scene_RenderScene_removeModels)); cls->defineFunction("removeSphereLight", _SE(js_scene_RenderScene_removeSphereLight)); @@ -7733,7 +12972,9 @@ bool js_register_scene_RenderScene(se::Object* obj) // NOLINT(readability-identi cls->defineFunction("removeSpotLight", _SE(js_scene_RenderScene_removeSpotLight)); cls->defineFunction("removeSpotLights", _SE(js_scene_RenderScene_removeSpotLights)); cls->defineFunction("setMainLight", _SE(js_scene_RenderScene_setMainLight)); + cls->defineFunction("unsetMainLight", _SE(js_scene_RenderScene_unsetMainLight)); cls->defineFunction("update", _SE(js_scene_RenderScene_update)); + cls->defineFunction("updateOctree", _SE(js_scene_RenderScene_updateOctree)); cls->defineFinalizeFunction(_SE(js_cc_scene_RenderScene_finalize)); cls->install(); JSBClassType::registerClass(cls); @@ -7741,11 +12982,395 @@ bool js_register_scene_RenderScene(se::Object* obj) // NOLINT(readability-identi __jsb_cc_scene_RenderScene_proto = cls->getProto(); __jsb_cc_scene_RenderScene_class = cls; + se::ScriptEngine::getInstance()->clearException(); return true; } -se::Object* __jsb_cc_scene_RenderWindow_proto = nullptr; -se::Class* __jsb_cc_scene_RenderWindow_class = nullptr; +se::Object* __jsb_cc_scene_IRenderWindowInfo_proto = nullptr; // NOLINT +se::Class* __jsb_cc_scene_IRenderWindowInfo_class = nullptr; // NOLINT + +static bool js_scene_IRenderWindowInfo_get_title(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_scene_IRenderWindowInfo_get_title : Invalid Native Object"); + + CC_UNUSED bool ok = true; + se::Value jsret; + ok &= nativevalue_to_se(cobj->title, jsret, s.thisObject() /*ctx*/); + s.rval() = jsret; + SE_HOLD_RETURN_VALUE(cobj->title, s.thisObject(), s.rval()); + return true; +} +SE_BIND_PROP_GET(js_scene_IRenderWindowInfo_get_title) + +static bool js_scene_IRenderWindowInfo_set_title(se::State& s) // NOLINT(readability-identifier-naming) +{ + const auto& args = s.args(); + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_scene_IRenderWindowInfo_set_title : Invalid Native Object"); + + CC_UNUSED bool ok = true; + ok &= sevalue_to_native(args[0], &cobj->title, s.thisObject()); + SE_PRECONDITION2(ok, false, "js_scene_IRenderWindowInfo_set_title : Error processing new value"); + return true; +} +SE_BIND_PROP_SET(js_scene_IRenderWindowInfo_set_title) + +static bool js_scene_IRenderWindowInfo_get_width(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_scene_IRenderWindowInfo_get_width : Invalid Native Object"); + + CC_UNUSED bool ok = true; + se::Value jsret; + ok &= nativevalue_to_se(cobj->width, jsret, s.thisObject() /*ctx*/); + s.rval() = jsret; + SE_HOLD_RETURN_VALUE(cobj->width, s.thisObject(), s.rval()); + return true; +} +SE_BIND_PROP_GET(js_scene_IRenderWindowInfo_get_width) + +static bool js_scene_IRenderWindowInfo_set_width(se::State& s) // NOLINT(readability-identifier-naming) +{ + const auto& args = s.args(); + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_scene_IRenderWindowInfo_set_width : Invalid Native Object"); + + CC_UNUSED bool ok = true; + ok &= sevalue_to_native(args[0], &cobj->width, s.thisObject()); + SE_PRECONDITION2(ok, false, "js_scene_IRenderWindowInfo_set_width : Error processing new value"); + return true; +} +SE_BIND_PROP_SET(js_scene_IRenderWindowInfo_set_width) + +static bool js_scene_IRenderWindowInfo_get_height(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_scene_IRenderWindowInfo_get_height : Invalid Native Object"); + + CC_UNUSED bool ok = true; + se::Value jsret; + ok &= nativevalue_to_se(cobj->height, jsret, s.thisObject() /*ctx*/); + s.rval() = jsret; + SE_HOLD_RETURN_VALUE(cobj->height, s.thisObject(), s.rval()); + return true; +} +SE_BIND_PROP_GET(js_scene_IRenderWindowInfo_get_height) + +static bool js_scene_IRenderWindowInfo_set_height(se::State& s) // NOLINT(readability-identifier-naming) +{ + const auto& args = s.args(); + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_scene_IRenderWindowInfo_set_height : Invalid Native Object"); + + CC_UNUSED bool ok = true; + ok &= sevalue_to_native(args[0], &cobj->height, s.thisObject()); + SE_PRECONDITION2(ok, false, "js_scene_IRenderWindowInfo_set_height : Error processing new value"); + return true; +} +SE_BIND_PROP_SET(js_scene_IRenderWindowInfo_set_height) + +static bool js_scene_IRenderWindowInfo_get_renderPassInfo(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_scene_IRenderWindowInfo_get_renderPassInfo : Invalid Native Object"); + + CC_UNUSED bool ok = true; + se::Value jsret; + ok &= nativevalue_to_se(cobj->renderPassInfo, jsret, s.thisObject() /*ctx*/); + s.rval() = jsret; + SE_HOLD_RETURN_VALUE(cobj->renderPassInfo, s.thisObject(), s.rval()); + return true; +} +SE_BIND_PROP_GET(js_scene_IRenderWindowInfo_get_renderPassInfo) + +static bool js_scene_IRenderWindowInfo_set_renderPassInfo(se::State& s) // NOLINT(readability-identifier-naming) +{ + const auto& args = s.args(); + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_scene_IRenderWindowInfo_set_renderPassInfo : Invalid Native Object"); + + CC_UNUSED bool ok = true; + ok &= sevalue_to_native(args[0], &cobj->renderPassInfo, s.thisObject()); + SE_PRECONDITION2(ok, false, "js_scene_IRenderWindowInfo_set_renderPassInfo : Error processing new value"); + return true; +} +SE_BIND_PROP_SET(js_scene_IRenderWindowInfo_set_renderPassInfo) + +static bool js_scene_IRenderWindowInfo_get_swapchain(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_scene_IRenderWindowInfo_get_swapchain : Invalid Native Object"); + + CC_UNUSED bool ok = true; + se::Value jsret; + ok &= nativevalue_to_se(cobj->swapchain, jsret, s.thisObject() /*ctx*/); + s.rval() = jsret; + SE_HOLD_RETURN_VALUE(cobj->swapchain, s.thisObject(), s.rval()); + return true; +} +SE_BIND_PROP_GET(js_scene_IRenderWindowInfo_get_swapchain) + +static bool js_scene_IRenderWindowInfo_set_swapchain(se::State& s) // NOLINT(readability-identifier-naming) +{ + const auto& args = s.args(); + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_scene_IRenderWindowInfo_set_swapchain : Invalid Native Object"); + + CC_UNUSED bool ok = true; + ok &= sevalue_to_native(args[0], &cobj->swapchain, s.thisObject()); + SE_PRECONDITION2(ok, false, "js_scene_IRenderWindowInfo_set_swapchain : Error processing new value"); + return true; +} +SE_BIND_PROP_SET(js_scene_IRenderWindowInfo_set_swapchain) + + +template<> +bool sevalue_to_native(const se::Value &from, cc::scene::IRenderWindowInfo * to, se::Object *ctx) +{ + assert(from.isObject()); + se::Object *json = from.toObject(); + auto* data = reinterpret_cast(json->getPrivateData()); + if (data) { + *to = *data; + return true; + } + se::Value field; + bool ok = true; + json->getProperty("title", &field, true); + if(!field.isNullOrUndefined()) { + ok &= sevalue_to_native(field, &(to->title), ctx); + } + json->getProperty("width", &field, true); + if(!field.isNullOrUndefined()) { + ok &= sevalue_to_native(field, &(to->width), ctx); + } + json->getProperty("height", &field, true); + if(!field.isNullOrUndefined()) { + ok &= sevalue_to_native(field, &(to->height), ctx); + } + json->getProperty("renderPassInfo", &field, true); + if(!field.isNullOrUndefined()) { + ok &= sevalue_to_native(field, &(to->renderPassInfo), ctx); + } + json->getProperty("swapchain", &field, true); + if(!field.isNullOrUndefined()) { + ok &= sevalue_to_native(field, &(to->swapchain), ctx); + } + return ok; +} + +SE_DECLARE_FINALIZE_FUNC(js_cc_scene_IRenderWindowInfo_finalize) + +static bool js_scene_IRenderWindowInfo_constructor(se::State& s) // NOLINT(readability-identifier-naming) +{ + CC_UNUSED bool ok = true; + const auto& args = s.args(); + size_t argc = args.size(); + + if(argc == 0) + { + auto *ptr = JSB_MAKE_PRIVATE_OBJECT(cc::scene::IRenderWindowInfo); + s.thisObject()->setPrivateObject(ptr); + return true; + } + + if(argc == 1 && args[0].isObject()) + { + se::Object *json = args[0].toObject(); + se::Value field; + auto *ptr = JSB_MAKE_PRIVATE_OBJECT(cc::scene::IRenderWindowInfo); + auto cobj = ptr->get(); + ok &= sevalue_to_native(args[0], cobj, s.thisObject()); + if(!ok) { + delete ptr; + SE_REPORT_ERROR("argument convertion error"); + return false; + } + s.thisObject()->setPrivateObject(ptr); + return true; + } + auto *ptr = JSB_MAKE_PRIVATE_OBJECT(cc::scene::IRenderWindowInfo); + auto cobj = ptr->get(); + if (argc > 0 && !args[0].isUndefined()) { + ok &= sevalue_to_native(args[0], &(cobj->title), nullptr); + } + if (argc > 1 && !args[1].isUndefined()) { + ok &= sevalue_to_native(args[1], &(cobj->width), nullptr); + } + if (argc > 2 && !args[2].isUndefined()) { + ok &= sevalue_to_native(args[2], &(cobj->height), nullptr); + } + if (argc > 3 && !args[3].isUndefined()) { + ok &= sevalue_to_native(args[3], &(cobj->renderPassInfo), nullptr); + } + if (argc > 4 && !args[4].isUndefined()) { + ok &= sevalue_to_native(args[4], &(cobj->swapchain), nullptr); + } + + if(!ok) { + delete ptr; + SE_REPORT_ERROR("Argument convertion error"); + return false; + } + s.thisObject()->setPrivateObject(ptr); + return true; +} +SE_BIND_CTOR(js_scene_IRenderWindowInfo_constructor, __jsb_cc_scene_IRenderWindowInfo_class, js_cc_scene_IRenderWindowInfo_finalize) + +static bool js_cc_scene_IRenderWindowInfo_finalize(se::State& s) // NOLINT(readability-identifier-naming) +{ + return true; +} +SE_BIND_FINALIZE_FUNC(js_cc_scene_IRenderWindowInfo_finalize) + +bool js_register_scene_IRenderWindowInfo(se::Object* obj) // NOLINT(readability-identifier-naming) +{ + auto* cls = se::Class::create("IRenderWindowInfo", obj, nullptr, _SE(js_scene_IRenderWindowInfo_constructor)); + + cls->defineProperty("title", _SE(js_scene_IRenderWindowInfo_get_title), _SE(js_scene_IRenderWindowInfo_set_title)); + cls->defineProperty("width", _SE(js_scene_IRenderWindowInfo_get_width), _SE(js_scene_IRenderWindowInfo_set_width)); + cls->defineProperty("height", _SE(js_scene_IRenderWindowInfo_get_height), _SE(js_scene_IRenderWindowInfo_set_height)); + cls->defineProperty("renderPassInfo", _SE(js_scene_IRenderWindowInfo_get_renderPassInfo), _SE(js_scene_IRenderWindowInfo_set_renderPassInfo)); + cls->defineProperty("swapchain", _SE(js_scene_IRenderWindowInfo_get_swapchain), _SE(js_scene_IRenderWindowInfo_set_swapchain)); + cls->defineFinalizeFunction(_SE(js_cc_scene_IRenderWindowInfo_finalize)); + cls->install(); + JSBClassType::registerClass(cls); + + __jsb_cc_scene_IRenderWindowInfo_proto = cls->getProto(); + __jsb_cc_scene_IRenderWindowInfo_class = cls; + + + se::ScriptEngine::getInstance()->clearException(); + return true; +} +se::Object* __jsb_cc_scene_RenderWindow_proto = nullptr; // NOLINT +se::Class* __jsb_cc_scene_RenderWindow_class = nullptr; // NOLINT + +static bool js_scene_RenderWindow_attachCamera(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_scene_RenderWindow_attachCamera : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 1) { + HolderType arg0 = {}; + ok &= sevalue_to_native(args[0], &arg0, s.thisObject()); + SE_PRECONDITION2(ok, false, "js_scene_RenderWindow_attachCamera : Error processing arguments"); + cobj->attachCamera(arg0.value()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 1); + return false; +} +SE_BIND_FUNC(js_scene_RenderWindow_attachCamera) + +static bool js_scene_RenderWindow_clearCameras(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_scene_RenderWindow_clearCameras : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + if (argc == 0) { + cobj->clearCameras(); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 0); + return false; +} +SE_BIND_FUNC(js_scene_RenderWindow_clearCameras) + +static bool js_scene_RenderWindow_destroy(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_scene_RenderWindow_destroy : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + if (argc == 0) { + cobj->destroy(); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 0); + return false; +} +SE_BIND_FUNC(js_scene_RenderWindow_destroy) + +static bool js_scene_RenderWindow_detachCamera(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_scene_RenderWindow_detachCamera : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 1) { + HolderType arg0 = {}; + ok &= sevalue_to_native(args[0], &arg0, s.thisObject()); + SE_PRECONDITION2(ok, false, "js_scene_RenderWindow_detachCamera : Error processing arguments"); + cobj->detachCamera(arg0.value()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 1); + return false; +} +SE_BIND_FUNC(js_scene_RenderWindow_detachCamera) + +static bool js_scene_RenderWindow_extractRenderCameras(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_scene_RenderWindow_extractRenderCameras : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 1) { + HolderType, true> arg0 = {}; + ok &= sevalue_to_native(args[0], &arg0, s.thisObject()); + SE_PRECONDITION2(ok, false, "js_scene_RenderWindow_extractRenderCameras : Error processing arguments"); + cobj->extractRenderCameras(arg0.value()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 1); + return false; +} +SE_BIND_FUNC(js_scene_RenderWindow_extractRenderCameras) + +static bool js_scene_RenderWindow_getCameras(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_scene_RenderWindow_getCameras : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 0) { + const std::vector>& result = cobj->getCameras(); + ok &= nativevalue_to_se(result, s.rval(), nullptr /*ctx*/); + SE_PRECONDITION2(ok, false, "js_scene_RenderWindow_getCameras : Error processing arguments"); + SE_HOLD_RETURN_VALUE(result, s.thisObject(), s.rval()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 0); + return false; +} +SE_BIND_FUNC_AS_PROP_GET(js_scene_RenderWindow_getCameras) + +static bool js_scene_RenderWindow_getFramebuffer(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_scene_RenderWindow_getFramebuffer : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 0) { + cc::gfx::Framebuffer* result = cobj->getFramebuffer(); + ok &= nativevalue_to_se(result, s.rval(), nullptr /*ctx*/); + SE_PRECONDITION2(ok, false, "js_scene_RenderWindow_getFramebuffer : Error processing arguments"); + SE_HOLD_RETURN_VALUE(result, s.thisObject(), s.rval()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 0); + return false; +} +SE_BIND_FUNC_AS_PROP_GET(js_scene_RenderWindow_getFramebuffer) static bool js_scene_RenderWindow_getHeight(se::State& s) // NOLINT(readability-identifier-naming) { @@ -7764,7 +13389,26 @@ static bool js_scene_RenderWindow_getHeight(se::State& s) // NOLINT(readability- SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 0); return false; } -SE_BIND_FUNC(js_scene_RenderWindow_getHeight) +SE_BIND_FUNC_AS_PROP_GET(js_scene_RenderWindow_getHeight) + +static bool js_scene_RenderWindow_getSwapchain(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_scene_RenderWindow_getSwapchain : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 0) { + cc::gfx::Swapchain* result = cobj->getSwapchain(); + ok &= nativevalue_to_se(result, s.rval(), nullptr /*ctx*/); + SE_PRECONDITION2(ok, false, "js_scene_RenderWindow_getSwapchain : Error processing arguments"); + SE_HOLD_RETURN_VALUE(result, s.thisObject(), s.rval()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 0); + return false; +} +SE_BIND_FUNC_AS_PROP_GET(js_scene_RenderWindow_getSwapchain) static bool js_scene_RenderWindow_getWidth(se::State& s) // NOLINT(readability-identifier-naming) { @@ -7783,151 +13427,80 @@ static bool js_scene_RenderWindow_getWidth(se::State& s) // NOLINT(readability-i SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 0); return false; } -SE_BIND_FUNC(js_scene_RenderWindow_getWidth) +SE_BIND_FUNC_AS_PROP_GET(js_scene_RenderWindow_getWidth) -static bool js_scene_RenderWindow_get_swapchain(se::State& s) // NOLINT(readability-identifier-naming) +static bool js_scene_RenderWindow_initialize(se::State& s) // NOLINT(readability-identifier-naming) { auto* cobj = SE_THIS_OBJECT(s); - SE_PRECONDITION2(cobj, false, "js_scene_RenderWindow_get_swapchain : Invalid Native Object"); - - CC_UNUSED bool ok = true; - se::Value jsret; - ok &= nativevalue_to_se(cobj->swapchain, jsret, s.thisObject() /*ctx*/); - s.rval() = jsret; - SE_HOLD_RETURN_VALUE(cobj->swapchain, s.thisObject(), s.rval()); - return true; -} -SE_BIND_PROP_GET(js_scene_RenderWindow_get_swapchain) - -static bool js_scene_RenderWindow_set_swapchain(se::State& s) // NOLINT(readability-identifier-naming) -{ + SE_PRECONDITION2(cobj, false, "js_scene_RenderWindow_initialize : Invalid Native Object"); const auto& args = s.args(); - auto* cobj = SE_THIS_OBJECT(s); - SE_PRECONDITION2(cobj, false, "js_scene_RenderWindow_set_swapchain : Invalid Native Object"); - + size_t argc = args.size(); CC_UNUSED bool ok = true; - ok &= sevalue_to_native(args[0], &cobj->swapchain, s.thisObject()); - SE_PRECONDITION2(ok, false, "js_scene_RenderWindow_set_swapchain : Error processing new value"); - return true; -} -SE_BIND_PROP_SET(js_scene_RenderWindow_set_swapchain) - -static bool js_scene_RenderWindow_get_frameBuffer(se::State& s) // NOLINT(readability-identifier-naming) -{ - auto* cobj = SE_THIS_OBJECT(s); - SE_PRECONDITION2(cobj, false, "js_scene_RenderWindow_get_frameBuffer : Invalid Native Object"); - - CC_UNUSED bool ok = true; - se::Value jsret; - ok &= nativevalue_to_se(cobj->frameBuffer, jsret, s.thisObject() /*ctx*/); - s.rval() = jsret; - SE_HOLD_RETURN_VALUE(cobj->frameBuffer, s.thisObject(), s.rval()); - return true; -} -SE_BIND_PROP_GET(js_scene_RenderWindow_get_frameBuffer) - -static bool js_scene_RenderWindow_set_frameBuffer(se::State& s) // NOLINT(readability-identifier-naming) -{ - const auto& args = s.args(); - auto* cobj = SE_THIS_OBJECT(s); - SE_PRECONDITION2(cobj, false, "js_scene_RenderWindow_set_frameBuffer : Invalid Native Object"); - - CC_UNUSED bool ok = true; - ok &= sevalue_to_native(args[0], &cobj->frameBuffer, s.thisObject()); - SE_PRECONDITION2(ok, false, "js_scene_RenderWindow_set_frameBuffer : Error processing new value"); - return true; -} -SE_BIND_PROP_SET(js_scene_RenderWindow_set_frameBuffer) - - -template<> -bool sevalue_to_native(const se::Value &from, cc::scene::RenderWindow * to, se::Object *ctx) -{ - assert(from.isObject()); - se::Object *json = from.toObject(); - auto* data = reinterpret_cast(json->getPrivateData()); - if (data) { - *to = *data; + if (argc == 2) { + HolderType arg0 = {}; + HolderType arg1 = {}; + ok &= sevalue_to_native(args[0], &arg0, s.thisObject()); + ok &= sevalue_to_native(args[1], &arg1, s.thisObject()); + SE_PRECONDITION2(ok, false, "js_scene_RenderWindow_initialize : Error processing arguments"); + bool result = cobj->initialize(arg0.value(), arg1.value()); + ok &= nativevalue_to_se(result, s.rval(), nullptr /*ctx*/); + SE_PRECONDITION2(ok, false, "js_scene_RenderWindow_initialize : Error processing arguments"); + SE_HOLD_RETURN_VALUE(result, s.thisObject(), s.rval()); return true; } - se::Value field; - bool ok = true; - json->getProperty("swapchain", &field); - if(!field.isNullOrUndefined()) { - ok &= sevalue_to_native(field, &(to->swapchain), ctx); - } - json->getProperty("frameBuffer", &field); - if(!field.isNullOrUndefined()) { - ok &= sevalue_to_native(field, &(to->frameBuffer), ctx); - } - return ok; + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 2); + return false; } +SE_BIND_FUNC(js_scene_RenderWindow_initialize) + +static bool js_scene_RenderWindow_resize(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_scene_RenderWindow_resize : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 2) { + HolderType arg0 = {}; + HolderType arg1 = {}; + ok &= sevalue_to_native(args[0], &arg0, s.thisObject()); + ok &= sevalue_to_native(args[1], &arg1, s.thisObject()); + SE_PRECONDITION2(ok, false, "js_scene_RenderWindow_resize : Error processing arguments"); + cobj->resize(arg0.value(), arg1.value()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 2); + return false; +} +SE_BIND_FUNC(js_scene_RenderWindow_resize) + +static bool js_scene_RenderWindow_sortCameras(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_scene_RenderWindow_sortCameras : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + if (argc == 0) { + cobj->sortCameras(); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 0); + return false; +} +SE_BIND_FUNC(js_scene_RenderWindow_sortCameras) SE_DECLARE_FINALIZE_FUNC(js_cc_scene_RenderWindow_finalize) -static bool js_scene_RenderWindow_constructor(se::State& s) // NOLINT(readability-identifier-naming) +static bool js_scene_RenderWindow_constructor(se::State& s) // NOLINT(readability-identifier-naming) constructor.c { - CC_UNUSED bool ok = true; - const auto& args = s.args(); - size_t argc = args.size(); - - if(argc == 0) - { - cc::scene::RenderWindow* cobj = JSB_ALLOC(cc::scene::RenderWindow); - s.thisObject()->setPrivateData(cobj); - se::NonRefNativePtrCreatedByCtorMap::emplace(cobj); - return true; - } - - if(argc == 1 && args[0].isObject()) - { - se::Object *json = args[0].toObject(); - se::Value field; - - cc::scene::RenderWindow* cobj = JSB_ALLOC(cc::scene::RenderWindow); - ok &= sevalue_to_native(args[0], cobj, s.thisObject()); - if(!ok) { - JSB_FREE(cobj); - SE_REPORT_ERROR("argument convertion error"); - return false; - } - - s.thisObject()->setPrivateData(cobj); - se::NonRefNativePtrCreatedByCtorMap::emplace(cobj); - return true; - } - - cc::scene::RenderWindow* cobj = JSB_ALLOC(cc::scene::RenderWindow); - if (argc > 0 && !args[0].isUndefined()) { - ok &= sevalue_to_native(args[0], &(cobj->swapchain), nullptr); - } - if (argc > 1 && !args[1].isUndefined()) { - ok &= sevalue_to_native(args[1], &(cobj->frameBuffer), nullptr); - } - - if(!ok) { - JSB_FREE(cobj); - SE_REPORT_ERROR("Argument convertion error"); - return false; - } - - s.thisObject()->setPrivateData(cobj); - se::NonRefNativePtrCreatedByCtorMap::emplace(cobj); + auto *ptr = JSB_MAKE_PRIVATE_OBJECT(cc::scene::RenderWindow); + s.thisObject()->setPrivateObject(ptr); return true; } SE_BIND_CTOR(js_scene_RenderWindow_constructor, __jsb_cc_scene_RenderWindow_class, js_cc_scene_RenderWindow_finalize) - - static bool js_cc_scene_RenderWindow_finalize(se::State& s) // NOLINT(readability-identifier-naming) { - auto iter = se::NonRefNativePtrCreatedByCtorMap::find(SE_THIS_OBJECT(s)); - if (iter != se::NonRefNativePtrCreatedByCtorMap::end()) - { - se::NonRefNativePtrCreatedByCtorMap::erase(iter); - auto* cobj = SE_THIS_OBJECT(s); - JSB_FREE(cobj); - } return true; } SE_BIND_FINALIZE_FUNC(js_cc_scene_RenderWindow_finalize) @@ -7936,10 +13509,19 @@ bool js_register_scene_RenderWindow(se::Object* obj) // NOLINT(readability-ident { auto* cls = se::Class::create("RenderWindow", obj, nullptr, _SE(js_scene_RenderWindow_constructor)); - cls->defineProperty("swapchain", _SE(js_scene_RenderWindow_get_swapchain), _SE(js_scene_RenderWindow_set_swapchain)); - cls->defineProperty("frameBuffer", _SE(js_scene_RenderWindow_get_frameBuffer), _SE(js_scene_RenderWindow_set_frameBuffer)); - cls->defineFunction("getHeight", _SE(js_scene_RenderWindow_getHeight)); - cls->defineFunction("getWidth", _SE(js_scene_RenderWindow_getWidth)); + cls->defineProperty("width", _SE(js_scene_RenderWindow_getWidth_asGetter), nullptr); + cls->defineProperty("framebuffer", _SE(js_scene_RenderWindow_getFramebuffer_asGetter), nullptr); + cls->defineProperty("cameras", _SE(js_scene_RenderWindow_getCameras_asGetter), nullptr); + cls->defineProperty("swapchain", _SE(js_scene_RenderWindow_getSwapchain_asGetter), nullptr); + cls->defineProperty("height", _SE(js_scene_RenderWindow_getHeight_asGetter), nullptr); + cls->defineFunction("attachCamera", _SE(js_scene_RenderWindow_attachCamera)); + cls->defineFunction("clearCameras", _SE(js_scene_RenderWindow_clearCameras)); + cls->defineFunction("destroy", _SE(js_scene_RenderWindow_destroy)); + cls->defineFunction("detachCamera", _SE(js_scene_RenderWindow_detachCamera)); + cls->defineFunction("extractRenderCameras", _SE(js_scene_RenderWindow_extractRenderCameras)); + cls->defineFunction("initialize", _SE(js_scene_RenderWindow_initialize)); + cls->defineFunction("resize", _SE(js_scene_RenderWindow_resize)); + cls->defineFunction("sortCameras", _SE(js_scene_RenderWindow_sortCameras)); cls->defineFinalizeFunction(_SE(js_cc_scene_RenderWindow_finalize)); cls->install(); JSBClassType::registerClass(cls); @@ -7947,899 +13529,3374 @@ bool js_register_scene_RenderWindow(se::Object* obj) // NOLINT(readability-ident __jsb_cc_scene_RenderWindow_proto = cls->getProto(); __jsb_cc_scene_RenderWindow_class = cls; + se::ScriptEngine::getInstance()->clearException(); return true; } -se::Object* __jsb_cc_scene_Camera_proto = nullptr; -se::Class* __jsb_cc_scene_Camera_class = nullptr; +se::Object* __jsb_cc_scene_SphereLight_proto = nullptr; // NOLINT +se::Class* __jsb_cc_scene_SphereLight_class = nullptr; // NOLINT -static bool js_scene_Camera_get_width(se::State& s) // NOLINT(readability-identifier-naming) +static bool js_scene_SphereLight_getAABB(se::State& s) // NOLINT(readability-identifier-naming) { - auto* cobj = SE_THIS_OBJECT(s); - SE_PRECONDITION2(cobj, false, "js_scene_Camera_get_width : Invalid Native Object"); + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_scene_SphereLight_getAABB : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 0) { + const cc::geometry::AABB& result = cobj->getAABB(); + ok &= nativevalue_to_se(result, s.rval(), nullptr /*ctx*/); + SE_PRECONDITION2(ok, false, "js_scene_SphereLight_getAABB : Error processing arguments"); + SE_HOLD_RETURN_VALUE(result, s.thisObject(), s.rval()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 0); + return false; +} +SE_BIND_FUNC_AS_PROP_GET(js_scene_SphereLight_getAABB) + +static bool js_scene_SphereLight_getLuminance(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_scene_SphereLight_getLuminance : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 0) { + float result = cobj->getLuminance(); + ok &= nativevalue_to_se(result, s.rval(), nullptr /*ctx*/); + SE_PRECONDITION2(ok, false, "js_scene_SphereLight_getLuminance : Error processing arguments"); + SE_HOLD_RETURN_VALUE(result, s.thisObject(), s.rval()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 0); + return false; +} +SE_BIND_FUNC_AS_PROP_GET(js_scene_SphereLight_getLuminance) + +static bool js_scene_SphereLight_getLuminanceHDR(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_scene_SphereLight_getLuminanceHDR : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 0) { + float result = cobj->getLuminanceHDR(); + ok &= nativevalue_to_se(result, s.rval(), nullptr /*ctx*/); + SE_PRECONDITION2(ok, false, "js_scene_SphereLight_getLuminanceHDR : Error processing arguments"); + SE_HOLD_RETURN_VALUE(result, s.thisObject(), s.rval()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 0); + return false; +} +SE_BIND_FUNC_AS_PROP_GET(js_scene_SphereLight_getLuminanceHDR) + +static bool js_scene_SphereLight_getLuminanceLDR(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_scene_SphereLight_getLuminanceLDR : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 0) { + float result = cobj->getLuminanceLDR(); + ok &= nativevalue_to_se(result, s.rval(), nullptr /*ctx*/); + SE_PRECONDITION2(ok, false, "js_scene_SphereLight_getLuminanceLDR : Error processing arguments"); + SE_HOLD_RETURN_VALUE(result, s.thisObject(), s.rval()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 0); + return false; +} +SE_BIND_FUNC_AS_PROP_GET(js_scene_SphereLight_getLuminanceLDR) + +static bool js_scene_SphereLight_getPosition(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_scene_SphereLight_getPosition : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 0) { + const cc::Vec3& result = cobj->getPosition(); + ok &= nativevalue_to_se(result, s.rval(), nullptr /*ctx*/); + SE_PRECONDITION2(ok, false, "js_scene_SphereLight_getPosition : Error processing arguments"); + SE_HOLD_RETURN_VALUE(result, s.thisObject(), s.rval()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 0); + return false; +} +SE_BIND_FUNC_AS_PROP_GET(js_scene_SphereLight_getPosition) + +static bool js_scene_SphereLight_getRange(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_scene_SphereLight_getRange : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 0) { + float result = cobj->getRange(); + ok &= nativevalue_to_se(result, s.rval(), nullptr /*ctx*/); + SE_PRECONDITION2(ok, false, "js_scene_SphereLight_getRange : Error processing arguments"); + SE_HOLD_RETURN_VALUE(result, s.thisObject(), s.rval()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 0); + return false; +} +SE_BIND_FUNC_AS_PROP_GET(js_scene_SphereLight_getRange) + +static bool js_scene_SphereLight_getSize(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_scene_SphereLight_getSize : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 0) { + float result = cobj->getSize(); + ok &= nativevalue_to_se(result, s.rval(), nullptr /*ctx*/); + SE_PRECONDITION2(ok, false, "js_scene_SphereLight_getSize : Error processing arguments"); + SE_HOLD_RETURN_VALUE(result, s.thisObject(), s.rval()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 0); + return false; +} +SE_BIND_FUNC_AS_PROP_GET(js_scene_SphereLight_getSize) + +static bool js_scene_SphereLight_setLuminance(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_scene_SphereLight_setLuminance : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 1) { + HolderType arg0 = {}; + ok &= sevalue_to_native(args[0], &arg0, s.thisObject()); + SE_PRECONDITION2(ok, false, "js_scene_SphereLight_setLuminance : Error processing arguments"); + cobj->setLuminance(arg0.value()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 1); + return false; +} +SE_BIND_FUNC_AS_PROP_SET(js_scene_SphereLight_setLuminance) + +static bool js_scene_SphereLight_setLuminanceHDR(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_scene_SphereLight_setLuminanceHDR : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 1) { + HolderType arg0 = {}; + ok &= sevalue_to_native(args[0], &arg0, s.thisObject()); + SE_PRECONDITION2(ok, false, "js_scene_SphereLight_setLuminanceHDR : Error processing arguments"); + cobj->setLuminanceHDR(arg0.value()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 1); + return false; +} +SE_BIND_FUNC_AS_PROP_SET(js_scene_SphereLight_setLuminanceHDR) + +static bool js_scene_SphereLight_setLuminanceLDR(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_scene_SphereLight_setLuminanceLDR : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 1) { + HolderType arg0 = {}; + ok &= sevalue_to_native(args[0], &arg0, s.thisObject()); + SE_PRECONDITION2(ok, false, "js_scene_SphereLight_setLuminanceLDR : Error processing arguments"); + cobj->setLuminanceLDR(arg0.value()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 1); + return false; +} +SE_BIND_FUNC_AS_PROP_SET(js_scene_SphereLight_setLuminanceLDR) + +static bool js_scene_SphereLight_setPosition(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_scene_SphereLight_setPosition : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 1) { + HolderType arg0 = {}; + ok &= sevalue_to_native(args[0], &arg0, s.thisObject()); + SE_PRECONDITION2(ok, false, "js_scene_SphereLight_setPosition : Error processing arguments"); + cobj->setPosition(arg0.value()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 1); + return false; +} +SE_BIND_FUNC_AS_PROP_SET(js_scene_SphereLight_setPosition) + +static bool js_scene_SphereLight_setRange(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_scene_SphereLight_setRange : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 1) { + HolderType arg0 = {}; + ok &= sevalue_to_native(args[0], &arg0, s.thisObject()); + SE_PRECONDITION2(ok, false, "js_scene_SphereLight_setRange : Error processing arguments"); + cobj->setRange(arg0.value()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 1); + return false; +} +SE_BIND_FUNC_AS_PROP_SET(js_scene_SphereLight_setRange) + +static bool js_scene_SphereLight_setSize(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_scene_SphereLight_setSize : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 1) { + HolderType arg0 = {}; + ok &= sevalue_to_native(args[0], &arg0, s.thisObject()); + SE_PRECONDITION2(ok, false, "js_scene_SphereLight_setSize : Error processing arguments"); + cobj->setSize(arg0.value()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 1); + return false; +} +SE_BIND_FUNC_AS_PROP_SET(js_scene_SphereLight_setSize) + +SE_DECLARE_FINALIZE_FUNC(js_cc_scene_SphereLight_finalize) + +static bool js_scene_SphereLight_constructor(se::State& s) // NOLINT(readability-identifier-naming) constructor.c +{ + auto *ptr = JSB_MAKE_PRIVATE_OBJECT(cc::scene::SphereLight); + s.thisObject()->setPrivateObject(ptr); + return true; +} +SE_BIND_CTOR(js_scene_SphereLight_constructor, __jsb_cc_scene_SphereLight_class, js_cc_scene_SphereLight_finalize) + +static bool js_cc_scene_SphereLight_finalize(se::State& s) // NOLINT(readability-identifier-naming) +{ + return true; +} +SE_BIND_FINALIZE_FUNC(js_cc_scene_SphereLight_finalize) + +bool js_register_scene_SphereLight(se::Object* obj) // NOLINT(readability-identifier-naming) +{ + auto* cls = se::Class::create("SphereLight", obj, __jsb_cc_scene_Light_proto, _SE(js_scene_SphereLight_constructor)); + + cls->defineProperty("luminance", _SE(js_scene_SphereLight_getLuminance_asGetter), _SE(js_scene_SphereLight_setLuminance_asSetter)); + cls->defineProperty("luminanceLDR", _SE(js_scene_SphereLight_getLuminanceLDR_asGetter), _SE(js_scene_SphereLight_setLuminanceLDR_asSetter)); + cls->defineProperty("aabb", _SE(js_scene_SphereLight_getAABB_asGetter), nullptr); + cls->defineProperty("luminanceHDR", _SE(js_scene_SphereLight_getLuminanceHDR_asGetter), _SE(js_scene_SphereLight_setLuminanceHDR_asSetter)); + cls->defineProperty("range", _SE(js_scene_SphereLight_getRange_asGetter), _SE(js_scene_SphereLight_setRange_asSetter)); + cls->defineProperty("position", _SE(js_scene_SphereLight_getPosition_asGetter), _SE(js_scene_SphereLight_setPosition_asSetter)); + cls->defineProperty("size", _SE(js_scene_SphereLight_getSize_asGetter), _SE(js_scene_SphereLight_setSize_asSetter)); + cls->defineFinalizeFunction(_SE(js_cc_scene_SphereLight_finalize)); + cls->install(); + JSBClassType::registerClass(cls); + + __jsb_cc_scene_SphereLight_proto = cls->getProto(); + __jsb_cc_scene_SphereLight_class = cls; + + + se::ScriptEngine::getInstance()->clearException(); + return true; +} +se::Object* __jsb_cc_Root_proto = nullptr; // NOLINT +se::Class* __jsb_cc_Root_class = nullptr; // NOLINT + +static bool js_scene_Root_activeWindow(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_scene_Root_activeWindow : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 1) { + HolderType arg0 = {}; + ok &= sevalue_to_native(args[0], &arg0, s.thisObject()); + SE_PRECONDITION2(ok, false, "js_scene_Root_activeWindow : Error processing arguments"); + cobj->activeWindow(arg0.value()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 1); + return false; +} +SE_BIND_FUNC(js_scene_Root_activeWindow) + +static bool js_scene_Root_createCamera(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_scene_Root_createCamera : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 0) { + cc::scene::Camera* result = cobj->createCamera(); + ok &= nativevalue_to_se(result, s.rval(), nullptr /*ctx*/); + SE_PRECONDITION2(ok, false, "js_scene_Root_createCamera : Error processing arguments"); + SE_HOLD_RETURN_VALUE(result, s.thisObject(), s.rval()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 0); + return false; +} +SE_BIND_FUNC(js_scene_Root_createCamera) + +static bool js_scene_Root_createScene(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_scene_Root_createScene : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 1) { + HolderType arg0 = {}; + ok &= sevalue_to_native(args[0], &arg0, s.thisObject()); + SE_PRECONDITION2(ok, false, "js_scene_Root_createScene : Error processing arguments"); + cc::scene::RenderScene* result = cobj->createScene(arg0.value()); + ok &= nativevalue_to_se(result, s.rval(), nullptr /*ctx*/); + SE_PRECONDITION2(ok, false, "js_scene_Root_createScene : Error processing arguments"); + SE_HOLD_RETURN_VALUE(result, s.thisObject(), s.rval()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 1); + return false; +} +SE_BIND_FUNC(js_scene_Root_createScene) + +static bool js_scene_Root_createWindow(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_scene_Root_createWindow : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 1) { + HolderType arg0 = {}; + ok &= sevalue_to_native(args[0], &arg0, s.thisObject()); + SE_PRECONDITION2(ok, false, "js_scene_Root_createWindow : Error processing arguments"); + cc::scene::RenderWindow* result = cobj->createWindow(arg0.value()); + ok &= nativevalue_to_se(result, s.rval(), nullptr /*ctx*/); + SE_PRECONDITION2(ok, false, "js_scene_Root_createWindow : Error processing arguments"); + SE_HOLD_RETURN_VALUE(result, s.thisObject(), s.rval()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 1); + return false; +} +SE_BIND_FUNC(js_scene_Root_createWindow) + +static bool js_scene_Root_destroy(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_scene_Root_destroy : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + if (argc == 0) { + cobj->destroy(); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 0); + return false; +} +SE_BIND_FUNC(js_scene_Root_destroy) + +static bool js_scene_Root_destroyLight(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_scene_Root_destroyLight : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 1) { + HolderType arg0 = {}; + ok &= sevalue_to_native(args[0], &arg0, s.thisObject()); + SE_PRECONDITION2(ok, false, "js_scene_Root_destroyLight : Error processing arguments"); + cobj->destroyLight(arg0.value()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 1); + return false; +} +SE_BIND_FUNC(js_scene_Root_destroyLight) + +static bool js_scene_Root_destroyModel(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_scene_Root_destroyModel : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 1) { + HolderType arg0 = {}; + ok &= sevalue_to_native(args[0], &arg0, s.thisObject()); + SE_PRECONDITION2(ok, false, "js_scene_Root_destroyModel : Error processing arguments"); + cobj->destroyModel(arg0.value()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 1); + return false; +} +SE_BIND_FUNC(js_scene_Root_destroyModel) + +static bool js_scene_Root_destroyScene(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_scene_Root_destroyScene : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 1) { + HolderType arg0 = {}; + ok &= sevalue_to_native(args[0], &arg0, s.thisObject()); + SE_PRECONDITION2(ok, false, "js_scene_Root_destroyScene : Error processing arguments"); + cobj->destroyScene(arg0.value()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 1); + return false; +} +SE_BIND_FUNC(js_scene_Root_destroyScene) + +static bool js_scene_Root_destroyScenes(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_scene_Root_destroyScenes : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + if (argc == 0) { + cobj->destroyScenes(); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 0); + return false; +} +SE_BIND_FUNC(js_scene_Root_destroyScenes) + +static bool js_scene_Root_destroyWindow(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_scene_Root_destroyWindow : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 1) { + HolderType arg0 = {}; + ok &= sevalue_to_native(args[0], &arg0, s.thisObject()); + SE_PRECONDITION2(ok, false, "js_scene_Root_destroyWindow : Error processing arguments"); + cobj->destroyWindow(arg0.value()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 1); + return false; +} +SE_BIND_FUNC(js_scene_Root_destroyWindow) + +static bool js_scene_Root_destroyWindows(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_scene_Root_destroyWindows : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + if (argc == 0) { + cobj->destroyWindows(); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 0); + return false; +} +SE_BIND_FUNC(js_scene_Root_destroyWindows) + +static bool js_scene_Root_frameMove(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_scene_Root_frameMove : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 2) { + HolderType arg0 = {}; + HolderType arg1 = {}; + ok &= sevalue_to_native(args[0], &arg0, s.thisObject()); + ok &= sevalue_to_native(args[1], &arg1, s.thisObject()); + SE_PRECONDITION2(ok, false, "js_scene_Root_frameMove : Error processing arguments"); + cobj->frameMove(arg0.value(), arg1.value()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 2); + return false; +} +SE_BIND_FUNC(js_scene_Root_frameMove) + +static bool js_scene_Root_getBatcher2D(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_scene_Root_getBatcher2D : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 0) { + cc::scene::DrawBatch2D* result = cobj->getBatcher2D(); + ok &= nativevalue_to_se(result, s.rval(), nullptr /*ctx*/); + SE_PRECONDITION2(ok, false, "js_scene_Root_getBatcher2D : Error processing arguments"); + SE_HOLD_RETURN_VALUE(result, s.thisObject(), s.rval()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 0); + return false; +} +SE_BIND_FUNC(js_scene_Root_getBatcher2D) + +static bool js_scene_Root_getCumulativeTime(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_scene_Root_getCumulativeTime : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 0) { + float result = cobj->getCumulativeTime(); + ok &= nativevalue_to_se(result, s.rval(), nullptr /*ctx*/); + SE_PRECONDITION2(ok, false, "js_scene_Root_getCumulativeTime : Error processing arguments"); + SE_HOLD_RETURN_VALUE(result, s.thisObject(), s.rval()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 0); + return false; +} +SE_BIND_FUNC_AS_PROP_GET(js_scene_Root_getCumulativeTime) + +static bool js_scene_Root_getCurWindow(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_scene_Root_getCurWindow : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 0) { + cc::scene::RenderWindow* result = cobj->getCurWindow(); + ok &= nativevalue_to_se(result, s.rval(), nullptr /*ctx*/); + SE_PRECONDITION2(ok, false, "js_scene_Root_getCurWindow : Error processing arguments"); + SE_HOLD_RETURN_VALUE(result, s.thisObject(), s.rval()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 0); + return false; +} +SE_BIND_FUNC_AS_PROP_GET(js_scene_Root_getCurWindow) + +static bool js_scene_Root_getDevice(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_scene_Root_getDevice : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 0) { + cc::gfx::Device* result = cobj->getDevice(); + ok &= nativevalue_to_se(result, s.rval(), nullptr /*ctx*/); + SE_PRECONDITION2(ok, false, "js_scene_Root_getDevice : Error processing arguments"); + SE_HOLD_RETURN_VALUE(result, s.thisObject(), s.rval()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 0); + return false; +} +SE_BIND_FUNC_AS_PROP_GET(js_scene_Root_getDevice) + +static bool js_scene_Root_getEventProcessor(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_scene_Root_getEventProcessor : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 0) { + cc::CallbacksInvoker* result = cobj->getEventProcessor(); + ok &= nativevalue_to_se(result, s.rval(), nullptr /*ctx*/); + SE_PRECONDITION2(ok, false, "js_scene_Root_getEventProcessor : Error processing arguments"); + SE_HOLD_RETURN_VALUE(result, s.thisObject(), s.rval()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 0); + return false; +} +SE_BIND_FUNC(js_scene_Root_getEventProcessor) + +static bool js_scene_Root_getFixedFPS(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_scene_Root_getFixedFPS : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 0) { + unsigned int result = cobj->getFixedFPS(); + ok &= nativevalue_to_se(result, s.rval(), nullptr /*ctx*/); + SE_PRECONDITION2(ok, false, "js_scene_Root_getFixedFPS : Error processing arguments"); + SE_HOLD_RETURN_VALUE(result, s.thisObject(), s.rval()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 0); + return false; +} +SE_BIND_FUNC_AS_PROP_GET(js_scene_Root_getFixedFPS) + +static bool js_scene_Root_getFps(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_scene_Root_getFps : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 0) { + unsigned int result = cobj->getFps(); + ok &= nativevalue_to_se(result, s.rval(), nullptr /*ctx*/); + SE_PRECONDITION2(ok, false, "js_scene_Root_getFps : Error processing arguments"); + SE_HOLD_RETURN_VALUE(result, s.thisObject(), s.rval()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 0); + return false; +} +SE_BIND_FUNC_AS_PROP_GET(js_scene_Root_getFps) + +static bool js_scene_Root_getFrameCount(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_scene_Root_getFrameCount : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 0) { + unsigned int result = cobj->getFrameCount(); + ok &= nativevalue_to_se(result, s.rval(), nullptr /*ctx*/); + SE_PRECONDITION2(ok, false, "js_scene_Root_getFrameCount : Error processing arguments"); + SE_HOLD_RETURN_VALUE(result, s.thisObject(), s.rval()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 0); + return false; +} +SE_BIND_FUNC_AS_PROP_GET(js_scene_Root_getFrameCount) + +static bool js_scene_Root_getFrameTime(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_scene_Root_getFrameTime : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 0) { + float result = cobj->getFrameTime(); + ok &= nativevalue_to_se(result, s.rval(), nullptr /*ctx*/); + SE_PRECONDITION2(ok, false, "js_scene_Root_getFrameTime : Error processing arguments"); + SE_HOLD_RETURN_VALUE(result, s.thisObject(), s.rval()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 0); + return false; +} +SE_BIND_FUNC_AS_PROP_GET(js_scene_Root_getFrameTime) + +static bool js_scene_Root_getMainWindow(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_scene_Root_getMainWindow : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 0) { + cc::scene::RenderWindow* result = cobj->getMainWindow(); + ok &= nativevalue_to_se(result, s.rval(), nullptr /*ctx*/); + SE_PRECONDITION2(ok, false, "js_scene_Root_getMainWindow : Error processing arguments"); + SE_HOLD_RETURN_VALUE(result, s.thisObject(), s.rval()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 0); + return false; +} +SE_BIND_FUNC_AS_PROP_GET(js_scene_Root_getMainWindow) + +static bool js_scene_Root_getPipeline(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_scene_Root_getPipeline : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 0) { + cc::pipeline::RenderPipeline* result = cobj->getPipeline(); + ok &= nativevalue_to_se(result, s.rval(), nullptr /*ctx*/); + SE_PRECONDITION2(ok, false, "js_scene_Root_getPipeline : Error processing arguments"); + SE_HOLD_RETURN_VALUE(result, s.thisObject(), s.rval()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 0); + return false; +} +SE_BIND_FUNC(js_scene_Root_getPipeline) + +static bool js_scene_Root_getScenes(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_scene_Root_getScenes : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 0) { + const std::vector>& result = cobj->getScenes(); + ok &= nativevalue_to_se(result, s.rval(), nullptr /*ctx*/); + SE_PRECONDITION2(ok, false, "js_scene_Root_getScenes : Error processing arguments"); + SE_HOLD_RETURN_VALUE(result, s.thisObject(), s.rval()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 0); + return false; +} +SE_BIND_FUNC_AS_PROP_GET(js_scene_Root_getScenes) + +static bool js_scene_Root_getTempWindow(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_scene_Root_getTempWindow : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 0) { + cc::scene::RenderWindow* result = cobj->getTempWindow(); + ok &= nativevalue_to_se(result, s.rval(), nullptr /*ctx*/); + SE_PRECONDITION2(ok, false, "js_scene_Root_getTempWindow : Error processing arguments"); + SE_HOLD_RETURN_VALUE(result, s.thisObject(), s.rval()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 0); + return false; +} +SE_BIND_FUNC_AS_PROP_GET(js_scene_Root_getTempWindow) + +static bool js_scene_Root_getWindows(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_scene_Root_getWindows : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 0) { + const std::vector>& result = cobj->getWindows(); + ok &= nativevalue_to_se(result, s.rval(), nullptr /*ctx*/); + SE_PRECONDITION2(ok, false, "js_scene_Root_getWindows : Error processing arguments"); + SE_HOLD_RETURN_VALUE(result, s.thisObject(), s.rval()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 0); + return false; +} +SE_BIND_FUNC_AS_PROP_GET(js_scene_Root_getWindows) + +static bool js_scene_Root_initialize(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_scene_Root_initialize : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 1) { + HolderType arg0 = {}; + ok &= sevalue_to_native(args[0], &arg0, s.thisObject()); + SE_PRECONDITION2(ok, false, "js_scene_Root_initialize : Error processing arguments"); + cobj->initialize(arg0.value()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 1); + return false; +} +SE_BIND_FUNC(js_scene_Root_initialize) + +static bool js_scene_Root_isUsingDeferredPipeline(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_scene_Root_isUsingDeferredPipeline : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 0) { + bool result = cobj->isUsingDeferredPipeline(); + ok &= nativevalue_to_se(result, s.rval(), nullptr /*ctx*/); + SE_PRECONDITION2(ok, false, "js_scene_Root_isUsingDeferredPipeline : Error processing arguments"); + SE_HOLD_RETURN_VALUE(result, s.thisObject(), s.rval()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 0); + return false; +} +SE_BIND_FUNC_AS_PROP_GET(js_scene_Root_isUsingDeferredPipeline) + +static bool js_scene_Root_onGlobalPipelineStateChanged(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_scene_Root_onGlobalPipelineStateChanged : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + if (argc == 0) { + cobj->onGlobalPipelineStateChanged(); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 0); + return false; +} +SE_BIND_FUNC(js_scene_Root_onGlobalPipelineStateChanged) + +static bool js_scene_Root_resetCumulativeTime(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_scene_Root_resetCumulativeTime : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + if (argc == 0) { + cobj->resetCumulativeTime(); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 0); + return false; +} +SE_BIND_FUNC(js_scene_Root_resetCumulativeTime) + +static bool js_scene_Root_resize(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_scene_Root_resize : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 2) { + HolderType arg0 = {}; + HolderType arg1 = {}; + ok &= sevalue_to_native(args[0], &arg0, s.thisObject()); + ok &= sevalue_to_native(args[1], &arg1, s.thisObject()); + SE_PRECONDITION2(ok, false, "js_scene_Root_resize : Error processing arguments"); + cobj->resize(arg0.value(), arg1.value()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 2); + return false; +} +SE_BIND_FUNC(js_scene_Root_resize) + +static bool js_scene_Root_setCurWindow(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_scene_Root_setCurWindow : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 1) { + HolderType arg0 = {}; + ok &= sevalue_to_native(args[0], &arg0, s.thisObject()); + SE_PRECONDITION2(ok, false, "js_scene_Root_setCurWindow : Error processing arguments"); + cobj->setCurWindow(arg0.value()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 1); + return false; +} +SE_BIND_FUNC_AS_PROP_SET(js_scene_Root_setCurWindow) + +static bool js_scene_Root_setFixedFPS(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_scene_Root_setFixedFPS : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 1) { + HolderType arg0 = {}; + ok &= sevalue_to_native(args[0], &arg0, s.thisObject()); + SE_PRECONDITION2(ok, false, "js_scene_Root_setFixedFPS : Error processing arguments"); + cobj->setFixedFPS(arg0.value()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 1); + return false; +} +SE_BIND_FUNC_AS_PROP_SET(js_scene_Root_setFixedFPS) + +static bool js_scene_Root_setRenderPipeline(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_scene_Root_setRenderPipeline : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 0) { + bool result = cobj->setRenderPipeline(); + ok &= nativevalue_to_se(result, s.rval(), nullptr /*ctx*/); + SE_PRECONDITION2(ok, false, "js_scene_Root_setRenderPipeline : Error processing arguments"); + SE_HOLD_RETURN_VALUE(result, s.thisObject(), s.rval()); + return true; + } + if (argc == 1) { + HolderType arg0 = {}; + ok &= sevalue_to_native(args[0], &arg0, s.thisObject()); + SE_PRECONDITION2(ok, false, "js_scene_Root_setRenderPipeline : Error processing arguments"); + bool result = cobj->setRenderPipeline(arg0.value()); + ok &= nativevalue_to_se(result, s.rval(), nullptr /*ctx*/); + SE_PRECONDITION2(ok, false, "js_scene_Root_setRenderPipeline : Error processing arguments"); + SE_HOLD_RETURN_VALUE(result, s.thisObject(), s.rval()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 1); + return false; +} +SE_BIND_FUNC(js_scene_Root_setRenderPipeline) + +static bool js_scene_Root_setTempWindow(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_scene_Root_setTempWindow : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 1) { + HolderType arg0 = {}; + ok &= sevalue_to_native(args[0], &arg0, s.thisObject()); + SE_PRECONDITION2(ok, false, "js_scene_Root_setTempWindow : Error processing arguments"); + cobj->setTempWindow(arg0.value()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 1); + return false; +} +SE_BIND_FUNC_AS_PROP_SET(js_scene_Root_setTempWindow) + +static bool js_scene_Root_getInstance_static(se::State& s) // NOLINT(readability-identifier-naming) +{ + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 0) { + cc::Root* result = cc::Root::getInstance(); + ok &= nativevalue_to_se(result, s.rval(), nullptr /*ctx*/); + SE_PRECONDITION2(ok, false, "js_scene_Root_getInstance_static : Error processing arguments"); + SE_HOLD_RETURN_VALUE(result, s.thisObject(), s.rval()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 0); + return false; +} +SE_BIND_FUNC(js_scene_Root_getInstance_static) + +SE_DECLARE_FINALIZE_FUNC(js_cc_Root_finalize) + +static bool js_scene_Root_constructor(se::State& s) // NOLINT(readability-identifier-naming) constructor.c +{ + CC_UNUSED bool ok = true; + const auto& args = s.args(); + cc::gfx::Device* arg0 = nullptr; + ok &= sevalue_to_native(args[0], &arg0, s.thisObject()); + SE_PRECONDITION2(ok, false, "js_scene_Root_constructor : Error processing arguments"); + auto *ptr = JSB_MAKE_PRIVATE_OBJECT(cc::Root, arg0); + s.thisObject()->setPrivateObject(ptr); + return true; +} +SE_BIND_CTOR(js_scene_Root_constructor, __jsb_cc_Root_class, js_cc_Root_finalize) + +static bool js_cc_Root_finalize(se::State& s) // NOLINT(readability-identifier-naming) +{ + return true; +} +SE_BIND_FINALIZE_FUNC(js_cc_Root_finalize) + +bool js_register_scene_Root(se::Object* obj) // NOLINT(readability-identifier-naming) +{ + auto* cls = se::Class::create("Root", obj, nullptr, _SE(js_scene_Root_constructor)); + + cls->defineProperty("curWindow", _SE(js_scene_Root_getCurWindow_asGetter), _SE(js_scene_Root_setCurWindow_asSetter)); + cls->defineProperty("windows", _SE(js_scene_Root_getWindows_asGetter), nullptr); + cls->defineProperty("scenes", _SE(js_scene_Root_getScenes_asGetter), nullptr); + cls->defineProperty("frameTime", _SE(js_scene_Root_getFrameTime_asGetter), nullptr); + cls->defineProperty("cumulativeTime", _SE(js_scene_Root_getCumulativeTime_asGetter), nullptr); + cls->defineProperty("tempWindow", _SE(js_scene_Root_getTempWindow_asGetter), _SE(js_scene_Root_setTempWindow_asSetter)); + cls->defineProperty("fps", _SE(js_scene_Root_getFps_asGetter), nullptr); + cls->defineProperty("fixedFPS", _SE(js_scene_Root_getFixedFPS_asGetter), _SE(js_scene_Root_setFixedFPS_asSetter)); + cls->defineProperty({"device", "_device"}, _SE(js_scene_Root_getDevice_asGetter), nullptr); + cls->defineProperty("useDeferredPipeline", _SE(js_scene_Root_isUsingDeferredPipeline_asGetter), nullptr); + cls->defineProperty("mainWindow", _SE(js_scene_Root_getMainWindow_asGetter), nullptr); + cls->defineProperty("frameCount", _SE(js_scene_Root_getFrameCount_asGetter), nullptr); + cls->defineFunction("activeWindow", _SE(js_scene_Root_activeWindow)); + cls->defineFunction("createCamera", _SE(js_scene_Root_createCamera)); + cls->defineFunction("createScene", _SE(js_scene_Root_createScene)); + cls->defineFunction("createWindow", _SE(js_scene_Root_createWindow)); + cls->defineFunction("destroy", _SE(js_scene_Root_destroy)); + cls->defineFunction("destroyLight", _SE(js_scene_Root_destroyLight)); + cls->defineFunction("destroyModel", _SE(js_scene_Root_destroyModel)); + cls->defineFunction("destroyScene", _SE(js_scene_Root_destroyScene)); + cls->defineFunction("destroyScenes", _SE(js_scene_Root_destroyScenes)); + cls->defineFunction("destroyWindow", _SE(js_scene_Root_destroyWindow)); + cls->defineFunction("destroyWindows", _SE(js_scene_Root_destroyWindows)); + cls->defineFunction("frameMove", _SE(js_scene_Root_frameMove)); + cls->defineFunction("getBatcher2D", _SE(js_scene_Root_getBatcher2D)); + cls->defineFunction("getEventProcessor", _SE(js_scene_Root_getEventProcessor)); + cls->defineFunction("getPipeline", _SE(js_scene_Root_getPipeline)); + cls->defineFunction("_initialize", _SE(js_scene_Root_initialize)); + cls->defineFunction("onGlobalPipelineStateChanged", _SE(js_scene_Root_onGlobalPipelineStateChanged)); + cls->defineFunction("resetCumulativeTime", _SE(js_scene_Root_resetCumulativeTime)); + cls->defineFunction("resize", _SE(js_scene_Root_resize)); + cls->defineFunction("setRenderPipeline", _SE(js_scene_Root_setRenderPipeline)); + cls->defineStaticFunction("getInstance", _SE(js_scene_Root_getInstance_static)); + cls->defineFinalizeFunction(_SE(js_cc_Root_finalize)); + cls->install(); + JSBClassType::registerClass(cls); + + __jsb_cc_Root_proto = cls->getProto(); + __jsb_cc_Root_class = cls; + + + se::ScriptEngine::getInstance()->clearException(); + return true; +} +se::Object* __jsb_cc_scene_SkyboxInfo_proto = nullptr; // NOLINT +se::Class* __jsb_cc_scene_SkyboxInfo_class = nullptr; // NOLINT + +static bool js_scene_SkyboxInfo_activate(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_scene_SkyboxInfo_activate : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 1) { + HolderType arg0 = {}; + ok &= sevalue_to_native(args[0], &arg0, s.thisObject()); + SE_PRECONDITION2(ok, false, "js_scene_SkyboxInfo_activate : Error processing arguments"); + cobj->activate(arg0.value()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 1); + return false; +} +SE_BIND_FUNC(js_scene_SkyboxInfo_activate) + +static bool js_scene_SkyboxInfo_getDiffuseMap(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_scene_SkyboxInfo_getDiffuseMap : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 0) { + cc::TextureCube* result = cobj->getDiffuseMap(); + ok &= nativevalue_to_se(result, s.rval(), nullptr /*ctx*/); + SE_PRECONDITION2(ok, false, "js_scene_SkyboxInfo_getDiffuseMap : Error processing arguments"); + SE_HOLD_RETURN_VALUE(result, s.thisObject(), s.rval()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 0); + return false; +} +SE_BIND_FUNC_AS_PROP_GET(js_scene_SkyboxInfo_getDiffuseMap) + +static bool js_scene_SkyboxInfo_getEnvamp(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_scene_SkyboxInfo_getEnvamp : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 0) { + cc::TextureCube* result = cobj->getEnvamp(); + ok &= nativevalue_to_se(result, s.rval(), nullptr /*ctx*/); + SE_PRECONDITION2(ok, false, "js_scene_SkyboxInfo_getEnvamp : Error processing arguments"); + SE_HOLD_RETURN_VALUE(result, s.thisObject(), s.rval()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 0); + return false; +} +SE_BIND_FUNC(js_scene_SkyboxInfo_getEnvamp) + +static bool js_scene_SkyboxInfo_isApplyDiffuseMap(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_scene_SkyboxInfo_isApplyDiffuseMap : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 0) { + bool result = cobj->isApplyDiffuseMap(); + ok &= nativevalue_to_se(result, s.rval(), nullptr /*ctx*/); + SE_PRECONDITION2(ok, false, "js_scene_SkyboxInfo_isApplyDiffuseMap : Error processing arguments"); + SE_HOLD_RETURN_VALUE(result, s.thisObject(), s.rval()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 0); + return false; +} +SE_BIND_FUNC_AS_PROP_GET(js_scene_SkyboxInfo_isApplyDiffuseMap) + +static bool js_scene_SkyboxInfo_isEnabled(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_scene_SkyboxInfo_isEnabled : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 0) { + bool result = cobj->isEnabled(); + ok &= nativevalue_to_se(result, s.rval(), nullptr /*ctx*/); + SE_PRECONDITION2(ok, false, "js_scene_SkyboxInfo_isEnabled : Error processing arguments"); + SE_HOLD_RETURN_VALUE(result, s.thisObject(), s.rval()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 0); + return false; +} +SE_BIND_FUNC_AS_PROP_GET(js_scene_SkyboxInfo_isEnabled) + +static bool js_scene_SkyboxInfo_isUseHDR(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_scene_SkyboxInfo_isUseHDR : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 0) { + bool result = cobj->isUseHDR(); + ok &= nativevalue_to_se(result, s.rval(), nullptr /*ctx*/); + SE_PRECONDITION2(ok, false, "js_scene_SkyboxInfo_isUseHDR : Error processing arguments"); + SE_HOLD_RETURN_VALUE(result, s.thisObject(), s.rval()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 0); + return false; +} +SE_BIND_FUNC_AS_PROP_GET(js_scene_SkyboxInfo_isUseHDR) + +static bool js_scene_SkyboxInfo_isUseIBL(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_scene_SkyboxInfo_isUseIBL : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 0) { + bool result = cobj->isUseIBL(); + ok &= nativevalue_to_se(result, s.rval(), nullptr /*ctx*/); + SE_PRECONDITION2(ok, false, "js_scene_SkyboxInfo_isUseIBL : Error processing arguments"); + SE_HOLD_RETURN_VALUE(result, s.thisObject(), s.rval()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 0); + return false; +} +SE_BIND_FUNC_AS_PROP_GET(js_scene_SkyboxInfo_isUseIBL) + +static bool js_scene_SkyboxInfo_setApplyDiffuseMap(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_scene_SkyboxInfo_setApplyDiffuseMap : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 1) { + HolderType arg0 = {}; + ok &= sevalue_to_native(args[0], &arg0, s.thisObject()); + SE_PRECONDITION2(ok, false, "js_scene_SkyboxInfo_setApplyDiffuseMap : Error processing arguments"); + cobj->setApplyDiffuseMap(arg0.value()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 1); + return false; +} +SE_BIND_FUNC_AS_PROP_SET(js_scene_SkyboxInfo_setApplyDiffuseMap) + +static bool js_scene_SkyboxInfo_setDiffuseMap(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_scene_SkyboxInfo_setDiffuseMap : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 1) { + HolderType arg0 = {}; + ok &= sevalue_to_native(args[0], &arg0, s.thisObject()); + SE_PRECONDITION2(ok, false, "js_scene_SkyboxInfo_setDiffuseMap : Error processing arguments"); + cobj->setDiffuseMap(arg0.value()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 1); + return false; +} +SE_BIND_FUNC_AS_PROP_SET(js_scene_SkyboxInfo_setDiffuseMap) + +static bool js_scene_SkyboxInfo_setEnabled(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_scene_SkyboxInfo_setEnabled : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 1) { + HolderType arg0 = {}; + ok &= sevalue_to_native(args[0], &arg0, s.thisObject()); + SE_PRECONDITION2(ok, false, "js_scene_SkyboxInfo_setEnabled : Error processing arguments"); + cobj->setEnabled(arg0.value()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 1); + return false; +} +SE_BIND_FUNC_AS_PROP_SET(js_scene_SkyboxInfo_setEnabled) + +static bool js_scene_SkyboxInfo_setEnvmap(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_scene_SkyboxInfo_setEnvmap : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 1) { + HolderType arg0 = {}; + ok &= sevalue_to_native(args[0], &arg0, s.thisObject()); + SE_PRECONDITION2(ok, false, "js_scene_SkyboxInfo_setEnvmap : Error processing arguments"); + cobj->setEnvmap(arg0.value()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 1); + return false; +} +SE_BIND_FUNC_AS_PROP_SET(js_scene_SkyboxInfo_setEnvmap) + +static bool js_scene_SkyboxInfo_setUseHDR(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_scene_SkyboxInfo_setUseHDR : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 1) { + HolderType arg0 = {}; + ok &= sevalue_to_native(args[0], &arg0, s.thisObject()); + SE_PRECONDITION2(ok, false, "js_scene_SkyboxInfo_setUseHDR : Error processing arguments"); + cobj->setUseHDR(arg0.value()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 1); + return false; +} +SE_BIND_FUNC_AS_PROP_SET(js_scene_SkyboxInfo_setUseHDR) + +static bool js_scene_SkyboxInfo_setUseIBL(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_scene_SkyboxInfo_setUseIBL : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 1) { + HolderType arg0 = {}; + ok &= sevalue_to_native(args[0], &arg0, s.thisObject()); + SE_PRECONDITION2(ok, false, "js_scene_SkyboxInfo_setUseIBL : Error processing arguments"); + cobj->setUseIBL(arg0.value()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 1); + return false; +} +SE_BIND_FUNC_AS_PROP_SET(js_scene_SkyboxInfo_setUseIBL) + +static bool js_scene_SkyboxInfo_get__applyDiffuseMap(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_scene_SkyboxInfo_get__applyDiffuseMap : Invalid Native Object"); CC_UNUSED bool ok = true; se::Value jsret; - ok &= nativevalue_to_se(cobj->width, jsret, s.thisObject() /*ctx*/); + ok &= nativevalue_to_se(cobj->_applyDiffuseMap, jsret, s.thisObject() /*ctx*/); s.rval() = jsret; - SE_HOLD_RETURN_VALUE(cobj->width, s.thisObject(), s.rval()); + SE_HOLD_RETURN_VALUE(cobj->_applyDiffuseMap, s.thisObject(), s.rval()); return true; } -SE_BIND_PROP_GET(js_scene_Camera_get_width) +SE_BIND_PROP_GET(js_scene_SkyboxInfo_get__applyDiffuseMap) -static bool js_scene_Camera_set_width(se::State& s) // NOLINT(readability-identifier-naming) +static bool js_scene_SkyboxInfo_set__applyDiffuseMap(se::State& s) // NOLINT(readability-identifier-naming) { const auto& args = s.args(); - auto* cobj = SE_THIS_OBJECT(s); - SE_PRECONDITION2(cobj, false, "js_scene_Camera_set_width : Invalid Native Object"); + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_scene_SkyboxInfo_set__applyDiffuseMap : Invalid Native Object"); CC_UNUSED bool ok = true; - ok &= sevalue_to_native(args[0], &cobj->width, s.thisObject()); - SE_PRECONDITION2(ok, false, "js_scene_Camera_set_width : Error processing new value"); + ok &= sevalue_to_native(args[0], &cobj->_applyDiffuseMap, s.thisObject()); + SE_PRECONDITION2(ok, false, "js_scene_SkyboxInfo_set__applyDiffuseMap : Error processing new value"); return true; } -SE_BIND_PROP_SET(js_scene_Camera_set_width) +SE_BIND_PROP_SET(js_scene_SkyboxInfo_set__applyDiffuseMap) -static bool js_scene_Camera_get_height(se::State& s) // NOLINT(readability-identifier-naming) +static bool js_scene_SkyboxInfo_get__envmapHDR(se::State& s) // NOLINT(readability-identifier-naming) { - auto* cobj = SE_THIS_OBJECT(s); - SE_PRECONDITION2(cobj, false, "js_scene_Camera_get_height : Invalid Native Object"); + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_scene_SkyboxInfo_get__envmapHDR : Invalid Native Object"); CC_UNUSED bool ok = true; se::Value jsret; - ok &= nativevalue_to_se(cobj->height, jsret, s.thisObject() /*ctx*/); + ok &= nativevalue_to_se(cobj->_envmapHDR, jsret, s.thisObject() /*ctx*/); s.rval() = jsret; - SE_HOLD_RETURN_VALUE(cobj->height, s.thisObject(), s.rval()); + SE_HOLD_RETURN_VALUE(cobj->_envmapHDR, s.thisObject(), s.rval()); return true; } -SE_BIND_PROP_GET(js_scene_Camera_get_height) +SE_BIND_PROP_GET(js_scene_SkyboxInfo_get__envmapHDR) -static bool js_scene_Camera_set_height(se::State& s) // NOLINT(readability-identifier-naming) +static bool js_scene_SkyboxInfo_set__envmapHDR(se::State& s) // NOLINT(readability-identifier-naming) { const auto& args = s.args(); - auto* cobj = SE_THIS_OBJECT(s); - SE_PRECONDITION2(cobj, false, "js_scene_Camera_set_height : Invalid Native Object"); + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_scene_SkyboxInfo_set__envmapHDR : Invalid Native Object"); CC_UNUSED bool ok = true; - ok &= sevalue_to_native(args[0], &cobj->height, s.thisObject()); - SE_PRECONDITION2(ok, false, "js_scene_Camera_set_height : Error processing new value"); + ok &= sevalue_to_native(args[0], &cobj->_envmapHDR, s.thisObject()); + SE_PRECONDITION2(ok, false, "js_scene_SkyboxInfo_set__envmapHDR : Error processing new value"); return true; } -SE_BIND_PROP_SET(js_scene_Camera_set_height) +SE_BIND_PROP_SET(js_scene_SkyboxInfo_set__envmapHDR) -static bool js_scene_Camera_get_nearClip(se::State& s) // NOLINT(readability-identifier-naming) +static bool js_scene_SkyboxInfo_get__envmapLDR(se::State& s) // NOLINT(readability-identifier-naming) { - auto* cobj = SE_THIS_OBJECT(s); - SE_PRECONDITION2(cobj, false, "js_scene_Camera_get_nearClip : Invalid Native Object"); + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_scene_SkyboxInfo_get__envmapLDR : Invalid Native Object"); CC_UNUSED bool ok = true; se::Value jsret; - ok &= nativevalue_to_se(cobj->nearClip, jsret, s.thisObject() /*ctx*/); + ok &= nativevalue_to_se(cobj->_envmapLDR, jsret, s.thisObject() /*ctx*/); s.rval() = jsret; - SE_HOLD_RETURN_VALUE(cobj->nearClip, s.thisObject(), s.rval()); + SE_HOLD_RETURN_VALUE(cobj->_envmapLDR, s.thisObject(), s.rval()); return true; } -SE_BIND_PROP_GET(js_scene_Camera_get_nearClip) +SE_BIND_PROP_GET(js_scene_SkyboxInfo_get__envmapLDR) -static bool js_scene_Camera_set_nearClip(se::State& s) // NOLINT(readability-identifier-naming) +static bool js_scene_SkyboxInfo_set__envmapLDR(se::State& s) // NOLINT(readability-identifier-naming) { const auto& args = s.args(); - auto* cobj = SE_THIS_OBJECT(s); - SE_PRECONDITION2(cobj, false, "js_scene_Camera_set_nearClip : Invalid Native Object"); + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_scene_SkyboxInfo_set__envmapLDR : Invalid Native Object"); CC_UNUSED bool ok = true; - ok &= sevalue_to_native(args[0], &cobj->nearClip, s.thisObject()); - SE_PRECONDITION2(ok, false, "js_scene_Camera_set_nearClip : Error processing new value"); + ok &= sevalue_to_native(args[0], &cobj->_envmapLDR, s.thisObject()); + SE_PRECONDITION2(ok, false, "js_scene_SkyboxInfo_set__envmapLDR : Error processing new value"); return true; } -SE_BIND_PROP_SET(js_scene_Camera_set_nearClip) +SE_BIND_PROP_SET(js_scene_SkyboxInfo_set__envmapLDR) -static bool js_scene_Camera_get_farClip(se::State& s) // NOLINT(readability-identifier-naming) +static bool js_scene_SkyboxInfo_get__diffuseMapHDR(se::State& s) // NOLINT(readability-identifier-naming) { - auto* cobj = SE_THIS_OBJECT(s); - SE_PRECONDITION2(cobj, false, "js_scene_Camera_get_farClip : Invalid Native Object"); + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_scene_SkyboxInfo_get__diffuseMapHDR : Invalid Native Object"); CC_UNUSED bool ok = true; se::Value jsret; - ok &= nativevalue_to_se(cobj->farClip, jsret, s.thisObject() /*ctx*/); + ok &= nativevalue_to_se(cobj->_diffuseMapHDR, jsret, s.thisObject() /*ctx*/); s.rval() = jsret; - SE_HOLD_RETURN_VALUE(cobj->farClip, s.thisObject(), s.rval()); + SE_HOLD_RETURN_VALUE(cobj->_diffuseMapHDR, s.thisObject(), s.rval()); return true; } -SE_BIND_PROP_GET(js_scene_Camera_get_farClip) +SE_BIND_PROP_GET(js_scene_SkyboxInfo_get__diffuseMapHDR) -static bool js_scene_Camera_set_farClip(se::State& s) // NOLINT(readability-identifier-naming) +static bool js_scene_SkyboxInfo_set__diffuseMapHDR(se::State& s) // NOLINT(readability-identifier-naming) { const auto& args = s.args(); - auto* cobj = SE_THIS_OBJECT(s); - SE_PRECONDITION2(cobj, false, "js_scene_Camera_set_farClip : Invalid Native Object"); + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_scene_SkyboxInfo_set__diffuseMapHDR : Invalid Native Object"); CC_UNUSED bool ok = true; - ok &= sevalue_to_native(args[0], &cobj->farClip, s.thisObject()); - SE_PRECONDITION2(ok, false, "js_scene_Camera_set_farClip : Error processing new value"); + ok &= sevalue_to_native(args[0], &cobj->_diffuseMapHDR, s.thisObject()); + SE_PRECONDITION2(ok, false, "js_scene_SkyboxInfo_set__diffuseMapHDR : Error processing new value"); return true; } -SE_BIND_PROP_SET(js_scene_Camera_set_farClip) +SE_BIND_PROP_SET(js_scene_SkyboxInfo_set__diffuseMapHDR) -static bool js_scene_Camera_get_clearFlag(se::State& s) // NOLINT(readability-identifier-naming) +static bool js_scene_SkyboxInfo_get__diffuseMapLDR(se::State& s) // NOLINT(readability-identifier-naming) { - auto* cobj = SE_THIS_OBJECT(s); - SE_PRECONDITION2(cobj, false, "js_scene_Camera_get_clearFlag : Invalid Native Object"); + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_scene_SkyboxInfo_get__diffuseMapLDR : Invalid Native Object"); CC_UNUSED bool ok = true; se::Value jsret; - ok &= nativevalue_to_se(cobj->clearFlag, jsret, s.thisObject() /*ctx*/); + ok &= nativevalue_to_se(cobj->_diffuseMapLDR, jsret, s.thisObject() /*ctx*/); s.rval() = jsret; - SE_HOLD_RETURN_VALUE(cobj->clearFlag, s.thisObject(), s.rval()); + SE_HOLD_RETURN_VALUE(cobj->_diffuseMapLDR, s.thisObject(), s.rval()); return true; } -SE_BIND_PROP_GET(js_scene_Camera_get_clearFlag) +SE_BIND_PROP_GET(js_scene_SkyboxInfo_get__diffuseMapLDR) -static bool js_scene_Camera_set_clearFlag(se::State& s) // NOLINT(readability-identifier-naming) +static bool js_scene_SkyboxInfo_set__diffuseMapLDR(se::State& s) // NOLINT(readability-identifier-naming) { const auto& args = s.args(); - auto* cobj = SE_THIS_OBJECT(s); - SE_PRECONDITION2(cobj, false, "js_scene_Camera_set_clearFlag : Invalid Native Object"); + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_scene_SkyboxInfo_set__diffuseMapLDR : Invalid Native Object"); CC_UNUSED bool ok = true; - ok &= sevalue_to_native(args[0], &cobj->clearFlag, s.thisObject()); - SE_PRECONDITION2(ok, false, "js_scene_Camera_set_clearFlag : Error processing new value"); + ok &= sevalue_to_native(args[0], &cobj->_diffuseMapLDR, s.thisObject()); + SE_PRECONDITION2(ok, false, "js_scene_SkyboxInfo_set__diffuseMapLDR : Error processing new value"); return true; } -SE_BIND_PROP_SET(js_scene_Camera_set_clearFlag) +SE_BIND_PROP_SET(js_scene_SkyboxInfo_set__diffuseMapLDR) -static bool js_scene_Camera_get_exposure(se::State& s) // NOLINT(readability-identifier-naming) +static bool js_scene_SkyboxInfo_get__enabled(se::State& s) // NOLINT(readability-identifier-naming) { - auto* cobj = SE_THIS_OBJECT(s); - SE_PRECONDITION2(cobj, false, "js_scene_Camera_get_exposure : Invalid Native Object"); + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_scene_SkyboxInfo_get__enabled : Invalid Native Object"); CC_UNUSED bool ok = true; se::Value jsret; - ok &= nativevalue_to_se(cobj->exposure, jsret, s.thisObject() /*ctx*/); + ok &= nativevalue_to_se(cobj->_enabled, jsret, s.thisObject() /*ctx*/); s.rval() = jsret; - SE_HOLD_RETURN_VALUE(cobj->exposure, s.thisObject(), s.rval()); + SE_HOLD_RETURN_VALUE(cobj->_enabled, s.thisObject(), s.rval()); return true; } -SE_BIND_PROP_GET(js_scene_Camera_get_exposure) +SE_BIND_PROP_GET(js_scene_SkyboxInfo_get__enabled) -static bool js_scene_Camera_set_exposure(se::State& s) // NOLINT(readability-identifier-naming) +static bool js_scene_SkyboxInfo_set__enabled(se::State& s) // NOLINT(readability-identifier-naming) { const auto& args = s.args(); - auto* cobj = SE_THIS_OBJECT(s); - SE_PRECONDITION2(cobj, false, "js_scene_Camera_set_exposure : Invalid Native Object"); + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_scene_SkyboxInfo_set__enabled : Invalid Native Object"); CC_UNUSED bool ok = true; - ok &= sevalue_to_native(args[0], &cobj->exposure, s.thisObject()); - SE_PRECONDITION2(ok, false, "js_scene_Camera_set_exposure : Error processing new value"); + ok &= sevalue_to_native(args[0], &cobj->_enabled, s.thisObject()); + SE_PRECONDITION2(ok, false, "js_scene_SkyboxInfo_set__enabled : Error processing new value"); return true; } -SE_BIND_PROP_SET(js_scene_Camera_set_exposure) +SE_BIND_PROP_SET(js_scene_SkyboxInfo_set__enabled) -static bool js_scene_Camera_get_clearDepth(se::State& s) // NOLINT(readability-identifier-naming) +static bool js_scene_SkyboxInfo_get__useIBL(se::State& s) // NOLINT(readability-identifier-naming) { - auto* cobj = SE_THIS_OBJECT(s); - SE_PRECONDITION2(cobj, false, "js_scene_Camera_get_clearDepth : Invalid Native Object"); + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_scene_SkyboxInfo_get__useIBL : Invalid Native Object"); CC_UNUSED bool ok = true; se::Value jsret; - ok &= nativevalue_to_se(cobj->clearDepth, jsret, s.thisObject() /*ctx*/); + ok &= nativevalue_to_se(cobj->_useIBL, jsret, s.thisObject() /*ctx*/); s.rval() = jsret; - SE_HOLD_RETURN_VALUE(cobj->clearDepth, s.thisObject(), s.rval()); + SE_HOLD_RETURN_VALUE(cobj->_useIBL, s.thisObject(), s.rval()); return true; } -SE_BIND_PROP_GET(js_scene_Camera_get_clearDepth) +SE_BIND_PROP_GET(js_scene_SkyboxInfo_get__useIBL) -static bool js_scene_Camera_set_clearDepth(se::State& s) // NOLINT(readability-identifier-naming) +static bool js_scene_SkyboxInfo_set__useIBL(se::State& s) // NOLINT(readability-identifier-naming) { const auto& args = s.args(); - auto* cobj = SE_THIS_OBJECT(s); - SE_PRECONDITION2(cobj, false, "js_scene_Camera_set_clearDepth : Invalid Native Object"); + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_scene_SkyboxInfo_set__useIBL : Invalid Native Object"); CC_UNUSED bool ok = true; - ok &= sevalue_to_native(args[0], &cobj->clearDepth, s.thisObject()); - SE_PRECONDITION2(ok, false, "js_scene_Camera_set_clearDepth : Error processing new value"); + ok &= sevalue_to_native(args[0], &cobj->_useIBL, s.thisObject()); + SE_PRECONDITION2(ok, false, "js_scene_SkyboxInfo_set__useIBL : Error processing new value"); return true; } -SE_BIND_PROP_SET(js_scene_Camera_set_clearDepth) +SE_BIND_PROP_SET(js_scene_SkyboxInfo_set__useIBL) -static bool js_scene_Camera_get_fov(se::State& s) // NOLINT(readability-identifier-naming) +static bool js_scene_SkyboxInfo_get__useHDR(se::State& s) // NOLINT(readability-identifier-naming) { - auto* cobj = SE_THIS_OBJECT(s); - SE_PRECONDITION2(cobj, false, "js_scene_Camera_get_fov : Invalid Native Object"); + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_scene_SkyboxInfo_get__useHDR : Invalid Native Object"); CC_UNUSED bool ok = true; se::Value jsret; - ok &= nativevalue_to_se(cobj->fov, jsret, s.thisObject() /*ctx*/); + ok &= nativevalue_to_se(cobj->_useHDR, jsret, s.thisObject() /*ctx*/); s.rval() = jsret; - SE_HOLD_RETURN_VALUE(cobj->fov, s.thisObject(), s.rval()); + SE_HOLD_RETURN_VALUE(cobj->_useHDR, s.thisObject(), s.rval()); return true; } -SE_BIND_PROP_GET(js_scene_Camera_get_fov) +SE_BIND_PROP_GET(js_scene_SkyboxInfo_get__useHDR) -static bool js_scene_Camera_set_fov(se::State& s) // NOLINT(readability-identifier-naming) +static bool js_scene_SkyboxInfo_set__useHDR(se::State& s) // NOLINT(readability-identifier-naming) { const auto& args = s.args(); - auto* cobj = SE_THIS_OBJECT(s); - SE_PRECONDITION2(cobj, false, "js_scene_Camera_set_fov : Invalid Native Object"); + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_scene_SkyboxInfo_set__useHDR : Invalid Native Object"); CC_UNUSED bool ok = true; - ok &= sevalue_to_native(args[0], &cobj->fov, s.thisObject()); - SE_PRECONDITION2(ok, false, "js_scene_Camera_set_fov : Error processing new value"); + ok &= sevalue_to_native(args[0], &cobj->_useHDR, s.thisObject()); + SE_PRECONDITION2(ok, false, "js_scene_SkyboxInfo_set__useHDR : Error processing new value"); return true; } -SE_BIND_PROP_SET(js_scene_Camera_set_fov) +SE_BIND_PROP_SET(js_scene_SkyboxInfo_set__useHDR) -static bool js_scene_Camera_get_aspect(se::State& s) // NOLINT(readability-identifier-naming) +SE_DECLARE_FINALIZE_FUNC(js_cc_scene_SkyboxInfo_finalize) + +static bool js_scene_SkyboxInfo_constructor(se::State& s) // NOLINT(readability-identifier-naming) constructor.c { - auto* cobj = SE_THIS_OBJECT(s); - SE_PRECONDITION2(cobj, false, "js_scene_Camera_get_aspect : Invalid Native Object"); + auto *ptr = JSB_MAKE_PRIVATE_OBJECT(cc::scene::SkyboxInfo); + s.thisObject()->setPrivateObject(ptr); + return true; +} +SE_BIND_CTOR(js_scene_SkyboxInfo_constructor, __jsb_cc_scene_SkyboxInfo_class, js_cc_scene_SkyboxInfo_finalize) + +static bool js_cc_scene_SkyboxInfo_finalize(se::State& s) // NOLINT(readability-identifier-naming) +{ + return true; +} +SE_BIND_FINALIZE_FUNC(js_cc_scene_SkyboxInfo_finalize) + +bool js_register_scene_SkyboxInfo(se::Object* obj) // NOLINT(readability-identifier-naming) +{ + auto* cls = se::Class::create("SkyboxInfo", obj, nullptr, _SE(js_scene_SkyboxInfo_constructor)); + + cls->defineProperty("_applyDiffuseMap", _SE(js_scene_SkyboxInfo_get__applyDiffuseMap), _SE(js_scene_SkyboxInfo_set__applyDiffuseMap)); + cls->defineProperty("_envmapHDR", _SE(js_scene_SkyboxInfo_get__envmapHDR), _SE(js_scene_SkyboxInfo_set__envmapHDR)); + cls->defineProperty("_envmapLDR", _SE(js_scene_SkyboxInfo_get__envmapLDR), _SE(js_scene_SkyboxInfo_set__envmapLDR)); + cls->defineProperty("_diffuseMapHDR", _SE(js_scene_SkyboxInfo_get__diffuseMapHDR), _SE(js_scene_SkyboxInfo_set__diffuseMapHDR)); + cls->defineProperty("_diffuseMapLDR", _SE(js_scene_SkyboxInfo_get__diffuseMapLDR), _SE(js_scene_SkyboxInfo_set__diffuseMapLDR)); + cls->defineProperty("_enabled", _SE(js_scene_SkyboxInfo_get__enabled), _SE(js_scene_SkyboxInfo_set__enabled)); + cls->defineProperty("_useIBL", _SE(js_scene_SkyboxInfo_get__useIBL), _SE(js_scene_SkyboxInfo_set__useIBL)); + cls->defineProperty("_useHDR", _SE(js_scene_SkyboxInfo_get__useHDR), _SE(js_scene_SkyboxInfo_set__useHDR)); + cls->defineProperty("diffuseMap", _SE(js_scene_SkyboxInfo_getDiffuseMap_asGetter), _SE(js_scene_SkyboxInfo_setDiffuseMap_asSetter)); + cls->defineProperty("applyDiffuseMap", _SE(js_scene_SkyboxInfo_isApplyDiffuseMap_asGetter), _SE(js_scene_SkyboxInfo_setApplyDiffuseMap_asSetter)); + cls->defineProperty("enabled", _SE(js_scene_SkyboxInfo_isEnabled_asGetter), _SE(js_scene_SkyboxInfo_setEnabled_asSetter)); + cls->defineProperty("envmap", nullptr, _SE(js_scene_SkyboxInfo_setEnvmap_asSetter)); + cls->defineProperty("useHDR", _SE(js_scene_SkyboxInfo_isUseHDR_asGetter), _SE(js_scene_SkyboxInfo_setUseHDR_asSetter)); + cls->defineProperty("useIBL", _SE(js_scene_SkyboxInfo_isUseIBL_asGetter), _SE(js_scene_SkyboxInfo_setUseIBL_asSetter)); + cls->defineFunction("activate", _SE(js_scene_SkyboxInfo_activate)); + cls->defineFunction("getEnvamp", _SE(js_scene_SkyboxInfo_getEnvamp)); + cls->defineFinalizeFunction(_SE(js_cc_scene_SkyboxInfo_finalize)); + cls->install(); + JSBClassType::registerClass(cls); + + __jsb_cc_scene_SkyboxInfo_proto = cls->getProto(); + __jsb_cc_scene_SkyboxInfo_class = cls; + + + se::ScriptEngine::getInstance()->clearException(); + return true; +} +se::Object* __jsb_cc_scene_Skybox_proto = nullptr; // NOLINT +se::Class* __jsb_cc_scene_Skybox_class = nullptr; // NOLINT + +static bool js_scene_Skybox_activate(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_scene_Skybox_activate : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + if (argc == 0) { + cobj->activate(); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 0); + return false; +} +SE_BIND_FUNC(js_scene_Skybox_activate) + +static bool js_scene_Skybox_getDiffuseMap(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_scene_Skybox_getDiffuseMap : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 0) { + cc::TextureCube* result = cobj->getDiffuseMap(); + ok &= nativevalue_to_se(result, s.rval(), nullptr /*ctx*/); + SE_PRECONDITION2(ok, false, "js_scene_Skybox_getDiffuseMap : Error processing arguments"); + SE_HOLD_RETURN_VALUE(result, s.thisObject(), s.rval()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 0); + return false; +} +SE_BIND_FUNC(js_scene_Skybox_getDiffuseMap) + +static bool js_scene_Skybox_getEnvmap(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_scene_Skybox_getEnvmap : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 0) { + cc::TextureCube* result = cobj->getEnvmap(); + ok &= nativevalue_to_se(result, s.rval(), nullptr /*ctx*/); + SE_PRECONDITION2(ok, false, "js_scene_Skybox_getEnvmap : Error processing arguments"); + SE_HOLD_RETURN_VALUE(result, s.thisObject(), s.rval()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 0); + return false; +} +SE_BIND_FUNC_AS_PROP_GET(js_scene_Skybox_getEnvmap) + +static bool js_scene_Skybox_getModel(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_scene_Skybox_getModel : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 0) { + cc::scene::Model* result = cobj->getModel(); + ok &= nativevalue_to_se(result, s.rval(), nullptr /*ctx*/); + SE_PRECONDITION2(ok, false, "js_scene_Skybox_getModel : Error processing arguments"); + SE_HOLD_RETURN_VALUE(result, s.thisObject(), s.rval()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 0); + return false; +} +SE_BIND_FUNC_AS_PROP_GET(js_scene_Skybox_getModel) + +static bool js_scene_Skybox_initialize(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_scene_Skybox_initialize : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 1) { + HolderType arg0 = {}; + ok &= sevalue_to_native(args[0], &arg0, s.thisObject()); + SE_PRECONDITION2(ok, false, "js_scene_Skybox_initialize : Error processing arguments"); + cobj->initialize(arg0.value()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 1); + return false; +} +SE_BIND_FUNC(js_scene_Skybox_initialize) + +static bool js_scene_Skybox_isEnabled(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_scene_Skybox_isEnabled : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 0) { + bool result = cobj->isEnabled(); + ok &= nativevalue_to_se(result, s.rval(), nullptr /*ctx*/); + SE_PRECONDITION2(ok, false, "js_scene_Skybox_isEnabled : Error processing arguments"); + SE_HOLD_RETURN_VALUE(result, s.thisObject(), s.rval()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 0); + return false; +} +SE_BIND_FUNC_AS_PROP_GET(js_scene_Skybox_isEnabled) + +static bool js_scene_Skybox_isRGBE(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_scene_Skybox_isRGBE : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 0) { + bool result = cobj->isRGBE(); + ok &= nativevalue_to_se(result, s.rval(), nullptr /*ctx*/); + SE_PRECONDITION2(ok, false, "js_scene_Skybox_isRGBE : Error processing arguments"); + SE_HOLD_RETURN_VALUE(result, s.thisObject(), s.rval()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 0); + return false; +} +SE_BIND_FUNC_AS_PROP_GET(js_scene_Skybox_isRGBE) + +static bool js_scene_Skybox_isUseDiffuseMap(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_scene_Skybox_isUseDiffuseMap : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 0) { + bool result = cobj->isUseDiffuseMap(); + ok &= nativevalue_to_se(result, s.rval(), nullptr /*ctx*/); + SE_PRECONDITION2(ok, false, "js_scene_Skybox_isUseDiffuseMap : Error processing arguments"); + SE_HOLD_RETURN_VALUE(result, s.thisObject(), s.rval()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 0); + return false; +} +SE_BIND_FUNC(js_scene_Skybox_isUseDiffuseMap) + +static bool js_scene_Skybox_isUseHDR(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_scene_Skybox_isUseHDR : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 0) { + bool result = cobj->isUseHDR(); + ok &= nativevalue_to_se(result, s.rval(), nullptr /*ctx*/); + SE_PRECONDITION2(ok, false, "js_scene_Skybox_isUseHDR : Error processing arguments"); + SE_HOLD_RETURN_VALUE(result, s.thisObject(), s.rval()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 0); + return false; +} +SE_BIND_FUNC(js_scene_Skybox_isUseHDR) + +static bool js_scene_Skybox_isUseIBL(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_scene_Skybox_isUseIBL : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 0) { + bool result = cobj->isUseIBL(); + ok &= nativevalue_to_se(result, s.rval(), nullptr /*ctx*/); + SE_PRECONDITION2(ok, false, "js_scene_Skybox_isUseIBL : Error processing arguments"); + SE_HOLD_RETURN_VALUE(result, s.thisObject(), s.rval()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 0); + return false; +} +SE_BIND_FUNC_AS_PROP_GET(js_scene_Skybox_isUseIBL) + +static bool js_scene_Skybox_setDiffuseMap(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_scene_Skybox_setDiffuseMap : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 1) { + HolderType arg0 = {}; + ok &= sevalue_to_native(args[0], &arg0, s.thisObject()); + SE_PRECONDITION2(ok, false, "js_scene_Skybox_setDiffuseMap : Error processing arguments"); + cobj->setDiffuseMap(arg0.value()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 1); + return false; +} +SE_BIND_FUNC(js_scene_Skybox_setDiffuseMap) + +static bool js_scene_Skybox_setDiffuseMaps(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_scene_Skybox_setDiffuseMaps : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 2) { + HolderType arg0 = {}; + HolderType arg1 = {}; + ok &= sevalue_to_native(args[0], &arg0, s.thisObject()); + ok &= sevalue_to_native(args[1], &arg1, s.thisObject()); + SE_PRECONDITION2(ok, false, "js_scene_Skybox_setDiffuseMaps : Error processing arguments"); + cobj->setDiffuseMaps(arg0.value(), arg1.value()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 2); + return false; +} +SE_BIND_FUNC(js_scene_Skybox_setDiffuseMaps) + +static bool js_scene_Skybox_setEnabled(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_scene_Skybox_setEnabled : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 1) { + HolderType arg0 = {}; + ok &= sevalue_to_native(args[0], &arg0, s.thisObject()); + SE_PRECONDITION2(ok, false, "js_scene_Skybox_setEnabled : Error processing arguments"); + cobj->setEnabled(arg0.value()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 1); + return false; +} +SE_BIND_FUNC_AS_PROP_SET(js_scene_Skybox_setEnabled) + +static bool js_scene_Skybox_setEnvMaps(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_scene_Skybox_setEnvMaps : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 2) { + HolderType arg0 = {}; + HolderType arg1 = {}; + ok &= sevalue_to_native(args[0], &arg0, s.thisObject()); + ok &= sevalue_to_native(args[1], &arg1, s.thisObject()); + SE_PRECONDITION2(ok, false, "js_scene_Skybox_setEnvMaps : Error processing arguments"); + cobj->setEnvMaps(arg0.value(), arg1.value()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 2); + return false; +} +SE_BIND_FUNC(js_scene_Skybox_setEnvMaps) + +static bool js_scene_Skybox_setEnvmap(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_scene_Skybox_setEnvmap : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 1) { + HolderType arg0 = {}; + ok &= sevalue_to_native(args[0], &arg0, s.thisObject()); + SE_PRECONDITION2(ok, false, "js_scene_Skybox_setEnvmap : Error processing arguments"); + cobj->setEnvmap(arg0.value()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 1); + return false; +} +SE_BIND_FUNC_AS_PROP_SET(js_scene_Skybox_setEnvmap) + +static bool js_scene_Skybox_setUseDiffuseMap(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_scene_Skybox_setUseDiffuseMap : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 1) { + HolderType arg0 = {}; + ok &= sevalue_to_native(args[0], &arg0, s.thisObject()); + SE_PRECONDITION2(ok, false, "js_scene_Skybox_setUseDiffuseMap : Error processing arguments"); + cobj->setUseDiffuseMap(arg0.value()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 1); + return false; +} +SE_BIND_FUNC(js_scene_Skybox_setUseDiffuseMap) + +static bool js_scene_Skybox_setUseHDR(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_scene_Skybox_setUseHDR : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 1) { + HolderType arg0 = {}; + ok &= sevalue_to_native(args[0], &arg0, s.thisObject()); + SE_PRECONDITION2(ok, false, "js_scene_Skybox_setUseHDR : Error processing arguments"); + cobj->setUseHDR(arg0.value()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 1); + return false; +} +SE_BIND_FUNC(js_scene_Skybox_setUseHDR) + +static bool js_scene_Skybox_setUseIBL(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_scene_Skybox_setUseIBL : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 1) { + HolderType arg0 = {}; + ok &= sevalue_to_native(args[0], &arg0, s.thisObject()); + SE_PRECONDITION2(ok, false, "js_scene_Skybox_setUseIBL : Error processing arguments"); + cobj->setUseIBL(arg0.value()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 1); + return false; +} +SE_BIND_FUNC_AS_PROP_SET(js_scene_Skybox_setUseIBL) + +SE_DECLARE_FINALIZE_FUNC(js_cc_scene_Skybox_finalize) + +static bool js_scene_Skybox_constructor(se::State& s) // NOLINT(readability-identifier-naming) constructor.c +{ + auto *ptr = JSB_MAKE_PRIVATE_OBJECT(cc::scene::Skybox); + s.thisObject()->setPrivateObject(ptr); + return true; +} +SE_BIND_CTOR(js_scene_Skybox_constructor, __jsb_cc_scene_Skybox_class, js_cc_scene_Skybox_finalize) + +static bool js_cc_scene_Skybox_finalize(se::State& s) // NOLINT(readability-identifier-naming) +{ + return true; +} +SE_BIND_FINALIZE_FUNC(js_cc_scene_Skybox_finalize) + +bool js_register_scene_Skybox(se::Object* obj) // NOLINT(readability-identifier-naming) +{ + auto* cls = se::Class::create("Skybox", obj, nullptr, _SE(js_scene_Skybox_constructor)); + + cls->defineProperty("isRGBE", _SE(js_scene_Skybox_isRGBE_asGetter), nullptr); + cls->defineProperty("model", _SE(js_scene_Skybox_getModel_asGetter), nullptr); + cls->defineProperty("envmap", _SE(js_scene_Skybox_getEnvmap_asGetter), _SE(js_scene_Skybox_setEnvmap_asSetter)); + cls->defineProperty("enabled", _SE(js_scene_Skybox_isEnabled_asGetter), _SE(js_scene_Skybox_setEnabled_asSetter)); + cls->defineProperty("useIBL", _SE(js_scene_Skybox_isUseIBL_asGetter), _SE(js_scene_Skybox_setUseIBL_asSetter)); + cls->defineFunction("activate", _SE(js_scene_Skybox_activate)); + cls->defineFunction("getDiffuseMap", _SE(js_scene_Skybox_getDiffuseMap)); + cls->defineFunction("initialize", _SE(js_scene_Skybox_initialize)); + cls->defineFunction("isUseDiffuseMap", _SE(js_scene_Skybox_isUseDiffuseMap)); + cls->defineFunction("isUseHDR", _SE(js_scene_Skybox_isUseHDR)); + cls->defineFunction("setDiffuseMap", _SE(js_scene_Skybox_setDiffuseMap)); + cls->defineFunction("setDiffuseMaps", _SE(js_scene_Skybox_setDiffuseMaps)); + cls->defineFunction("setEnvMaps", _SE(js_scene_Skybox_setEnvMaps)); + cls->defineFunction("setUseDiffuseMap", _SE(js_scene_Skybox_setUseDiffuseMap)); + cls->defineFunction("setUseHDR", _SE(js_scene_Skybox_setUseHDR)); + cls->defineFinalizeFunction(_SE(js_cc_scene_Skybox_finalize)); + cls->install(); + JSBClassType::registerClass(cls); + + __jsb_cc_scene_Skybox_proto = cls->getProto(); + __jsb_cc_scene_Skybox_class = cls; + + + se::ScriptEngine::getInstance()->clearException(); + return true; +} +se::Object* __jsb_cc_scene_Ambient_proto = nullptr; // NOLINT +se::Class* __jsb_cc_scene_Ambient_class = nullptr; // NOLINT + +static bool js_scene_Ambient_getGroundAlbedo(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_scene_Ambient_getGroundAlbedo : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 0) { + cc::Vec4& result = cobj->getGroundAlbedo(); + ok &= nativevalue_to_se(result, s.rval(), nullptr /*ctx*/); + SE_PRECONDITION2(ok, false, "js_scene_Ambient_getGroundAlbedo : Error processing arguments"); + SE_HOLD_RETURN_VALUE(result, s.thisObject(), s.rval()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 0); + return false; +} +SE_BIND_FUNC_AS_PROP_GET(js_scene_Ambient_getGroundAlbedo) + +static bool js_scene_Ambient_getSkyColor(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_scene_Ambient_getSkyColor : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 0) { + cc::Vec4& result = cobj->getSkyColor(); + ok &= nativevalue_to_se(result, s.rval(), nullptr /*ctx*/); + SE_PRECONDITION2(ok, false, "js_scene_Ambient_getSkyColor : Error processing arguments"); + SE_HOLD_RETURN_VALUE(result, s.thisObject(), s.rval()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 0); + return false; +} +SE_BIND_FUNC_AS_PROP_GET(js_scene_Ambient_getSkyColor) + +static bool js_scene_Ambient_getSkyIllum(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_scene_Ambient_getSkyIllum : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 0) { + float result = cobj->getSkyIllum(); + ok &= nativevalue_to_se(result, s.rval(), nullptr /*ctx*/); + SE_PRECONDITION2(ok, false, "js_scene_Ambient_getSkyIllum : Error processing arguments"); + SE_HOLD_RETURN_VALUE(result, s.thisObject(), s.rval()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 0); + return false; +} +SE_BIND_FUNC_AS_PROP_GET(js_scene_Ambient_getSkyIllum) + +static bool js_scene_Ambient_initialize(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_scene_Ambient_initialize : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 1) { + HolderType arg0 = {}; + ok &= sevalue_to_native(args[0], &arg0, s.thisObject()); + SE_PRECONDITION2(ok, false, "js_scene_Ambient_initialize : Error processing arguments"); + cobj->initialize(arg0.value()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 1); + return false; +} +SE_BIND_FUNC(js_scene_Ambient_initialize) + +static bool js_scene_Ambient_isEnabled(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_scene_Ambient_isEnabled : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 0) { + bool result = cobj->isEnabled(); + ok &= nativevalue_to_se(result, s.rval(), nullptr /*ctx*/); + SE_PRECONDITION2(ok, false, "js_scene_Ambient_isEnabled : Error processing arguments"); + SE_HOLD_RETURN_VALUE(result, s.thisObject(), s.rval()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 0); + return false; +} +SE_BIND_FUNC_AS_PROP_GET(js_scene_Ambient_isEnabled) + +static bool js_scene_Ambient_setEnabled(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_scene_Ambient_setEnabled : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 1) { + HolderType arg0 = {}; + ok &= sevalue_to_native(args[0], &arg0, s.thisObject()); + SE_PRECONDITION2(ok, false, "js_scene_Ambient_setEnabled : Error processing arguments"); + cobj->setEnabled(arg0.value()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 1); + return false; +} +SE_BIND_FUNC_AS_PROP_SET(js_scene_Ambient_setEnabled) + +static bool js_scene_Ambient_setGroundAlbedo(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_scene_Ambient_setGroundAlbedo : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 1) { + HolderType arg0 = {}; + ok &= sevalue_to_native(args[0], &arg0, s.thisObject()); + SE_PRECONDITION2(ok, false, "js_scene_Ambient_setGroundAlbedo : Error processing arguments"); + cobj->setGroundAlbedo(arg0.value()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 1); + return false; +} +SE_BIND_FUNC_AS_PROP_SET(js_scene_Ambient_setGroundAlbedo) + +static bool js_scene_Ambient_setSkyColor(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_scene_Ambient_setSkyColor : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 1) { + HolderType arg0 = {}; + ok &= sevalue_to_native(args[0], &arg0, s.thisObject()); + SE_PRECONDITION2(ok, false, "js_scene_Ambient_setSkyColor : Error processing arguments"); + cobj->setSkyColor(arg0.value()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 1); + return false; +} +SE_BIND_FUNC_AS_PROP_SET(js_scene_Ambient_setSkyColor) + +static bool js_scene_Ambient_setSkyIllum(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_scene_Ambient_setSkyIllum : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 1) { + HolderType arg0 = {}; + ok &= sevalue_to_native(args[0], &arg0, s.thisObject()); + SE_PRECONDITION2(ok, false, "js_scene_Ambient_setSkyIllum : Error processing arguments"); + cobj->setSkyIllum(arg0.value()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 1); + return false; +} +SE_BIND_FUNC_AS_PROP_SET(js_scene_Ambient_setSkyIllum) + +static bool js_scene_Ambient_get_SUN_ILLUM(se::State& s) // NOLINT(readability-identifier-naming) +{ + CC_UNUSED bool ok = true; + se::Value jsret; + ok &= nativevalue_to_se(cc::scene::Ambient::SUN_ILLUM, jsret, s.thisObject() /*ctx*/); + s.rval() = jsret; + // SE_HOLD_RETURN_VALUE(cobj->SUN_ILLUM, s.thisObject(), s.rval()); + return true; +} +SE_BIND_PROP_GET(js_scene_Ambient_get_SUN_ILLUM) + + +static bool js_scene_Ambient_get_SKY_ILLUM(se::State& s) // NOLINT(readability-identifier-naming) +{ + CC_UNUSED bool ok = true; + se::Value jsret; + ok &= nativevalue_to_se(cc::scene::Ambient::SKY_ILLUM, jsret, s.thisObject() /*ctx*/); + s.rval() = jsret; + // SE_HOLD_RETURN_VALUE(cobj->SKY_ILLUM, s.thisObject(), s.rval()); + return true; +} +SE_BIND_PROP_GET(js_scene_Ambient_get_SKY_ILLUM) + + +SE_DECLARE_FINALIZE_FUNC(js_cc_scene_Ambient_finalize) + +static bool js_scene_Ambient_constructor(se::State& s) // NOLINT(readability-identifier-naming) constructor.c +{ + auto *ptr = JSB_MAKE_PRIVATE_OBJECT(cc::scene::Ambient); + s.thisObject()->setPrivateObject(ptr); + return true; +} +SE_BIND_CTOR(js_scene_Ambient_constructor, __jsb_cc_scene_Ambient_class, js_cc_scene_Ambient_finalize) + +static bool js_cc_scene_Ambient_finalize(se::State& s) // NOLINT(readability-identifier-naming) +{ + return true; +} +SE_BIND_FINALIZE_FUNC(js_cc_scene_Ambient_finalize) + +bool js_register_scene_Ambient(se::Object* obj) // NOLINT(readability-identifier-naming) +{ + auto* cls = se::Class::create("Ambient", obj, nullptr, _SE(js_scene_Ambient_constructor)); + + cls->defineProperty("skyColor", _SE(js_scene_Ambient_getSkyColor_asGetter), _SE(js_scene_Ambient_setSkyColor_asSetter)); + cls->defineProperty("enabled", _SE(js_scene_Ambient_isEnabled_asGetter), _SE(js_scene_Ambient_setEnabled_asSetter)); + cls->defineProperty("groundAlbedo", _SE(js_scene_Ambient_getGroundAlbedo_asGetter), _SE(js_scene_Ambient_setGroundAlbedo_asSetter)); + cls->defineProperty("skyIllum", _SE(js_scene_Ambient_getSkyIllum_asGetter), _SE(js_scene_Ambient_setSkyIllum_asSetter)); + cls->defineFunction("initialize", _SE(js_scene_Ambient_initialize)); + // static fields + cls->defineStaticProperty("SUN_ILLUM", _SE(js_scene_Ambient_get_SUN_ILLUM), nullptr); + cls->defineStaticProperty("SKY_ILLUM", _SE(js_scene_Ambient_get_SKY_ILLUM), nullptr); + cls->defineFinalizeFunction(_SE(js_cc_scene_Ambient_finalize)); + cls->install(); + JSBClassType::registerClass(cls); + + __jsb_cc_scene_Ambient_proto = cls->getProto(); + __jsb_cc_scene_Ambient_class = cls; + + + se::ScriptEngine::getInstance()->clearException(); + return true; +} +se::Object* __jsb_cc_scene_AmbientInfo_proto = nullptr; // NOLINT +se::Class* __jsb_cc_scene_AmbientInfo_class = nullptr; // NOLINT + +static bool js_scene_AmbientInfo_getGroundAlbedoHDR(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_scene_AmbientInfo_getGroundAlbedoHDR : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 0) { + const cc::Vec4& result = cobj->getGroundAlbedoHDR(); + ok &= nativevalue_to_se(result, s.rval(), nullptr /*ctx*/); + SE_PRECONDITION2(ok, false, "js_scene_AmbientInfo_getGroundAlbedoHDR : Error processing arguments"); + SE_HOLD_RETURN_VALUE(result, s.thisObject(), s.rval()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 0); + return false; +} +SE_BIND_FUNC(js_scene_AmbientInfo_getGroundAlbedoHDR) + +static bool js_scene_AmbientInfo_getGroundAlbedoLDR(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_scene_AmbientInfo_getGroundAlbedoLDR : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 0) { + const cc::Vec4& result = cobj->getGroundAlbedoLDR(); + ok &= nativevalue_to_se(result, s.rval(), nullptr /*ctx*/); + SE_PRECONDITION2(ok, false, "js_scene_AmbientInfo_getGroundAlbedoLDR : Error processing arguments"); + SE_HOLD_RETURN_VALUE(result, s.thisObject(), s.rval()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 0); + return false; +} +SE_BIND_FUNC(js_scene_AmbientInfo_getGroundAlbedoLDR) + +static bool js_scene_AmbientInfo_getGroundLightingColor(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_scene_AmbientInfo_getGroundLightingColor : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 0) { + const cc::Color& result = cobj->getGroundLightingColor(); + ok &= nativevalue_to_se(result, s.rval(), nullptr /*ctx*/); + SE_PRECONDITION2(ok, false, "js_scene_AmbientInfo_getGroundLightingColor : Error processing arguments"); + SE_HOLD_RETURN_VALUE(result, s.thisObject(), s.rval()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 0); + return false; +} +SE_BIND_FUNC(js_scene_AmbientInfo_getGroundLightingColor) + +static bool js_scene_AmbientInfo_getSkyColorHDR(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_scene_AmbientInfo_getSkyColorHDR : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 0) { + const cc::Vec4& result = cobj->getSkyColorHDR(); + ok &= nativevalue_to_se(result, s.rval(), nullptr /*ctx*/); + SE_PRECONDITION2(ok, false, "js_scene_AmbientInfo_getSkyColorHDR : Error processing arguments"); + SE_HOLD_RETURN_VALUE(result, s.thisObject(), s.rval()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 0); + return false; +} +SE_BIND_FUNC(js_scene_AmbientInfo_getSkyColorHDR) + +static bool js_scene_AmbientInfo_getSkyColorLDR(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_scene_AmbientInfo_getSkyColorLDR : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 0) { + const cc::Vec4& result = cobj->getSkyColorLDR(); + ok &= nativevalue_to_se(result, s.rval(), nullptr /*ctx*/); + SE_PRECONDITION2(ok, false, "js_scene_AmbientInfo_getSkyColorLDR : Error processing arguments"); + SE_HOLD_RETURN_VALUE(result, s.thisObject(), s.rval()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 0); + return false; +} +SE_BIND_FUNC(js_scene_AmbientInfo_getSkyColorLDR) + +static bool js_scene_AmbientInfo_getSkyIllum(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_scene_AmbientInfo_getSkyIllum : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 0) { + float result = cobj->getSkyIllum(); + ok &= nativevalue_to_se(result, s.rval(), nullptr /*ctx*/); + SE_PRECONDITION2(ok, false, "js_scene_AmbientInfo_getSkyIllum : Error processing arguments"); + SE_HOLD_RETURN_VALUE(result, s.thisObject(), s.rval()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 0); + return false; +} +SE_BIND_FUNC_AS_PROP_GET(js_scene_AmbientInfo_getSkyIllum) + +static bool js_scene_AmbientInfo_getSkyIllumHDR(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_scene_AmbientInfo_getSkyIllumHDR : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 0) { + const float& result = cobj->getSkyIllumHDR(); + ok &= nativevalue_to_se(result, s.rval(), nullptr /*ctx*/); + SE_PRECONDITION2(ok, false, "js_scene_AmbientInfo_getSkyIllumHDR : Error processing arguments"); + SE_HOLD_RETURN_VALUE(result, s.thisObject(), s.rval()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 0); + return false; +} +SE_BIND_FUNC(js_scene_AmbientInfo_getSkyIllumHDR) + +static bool js_scene_AmbientInfo_getSkyIllumLDR(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_scene_AmbientInfo_getSkyIllumLDR : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 0) { + const float& result = cobj->getSkyIllumLDR(); + ok &= nativevalue_to_se(result, s.rval(), nullptr /*ctx*/); + SE_PRECONDITION2(ok, false, "js_scene_AmbientInfo_getSkyIllumLDR : Error processing arguments"); + SE_HOLD_RETURN_VALUE(result, s.thisObject(), s.rval()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 0); + return false; +} +SE_BIND_FUNC(js_scene_AmbientInfo_getSkyIllumLDR) + +static bool js_scene_AmbientInfo_getSkyLightingColor(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_scene_AmbientInfo_getSkyLightingColor : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 0) { + const cc::Color& result = cobj->getSkyLightingColor(); + ok &= nativevalue_to_se(result, s.rval(), nullptr /*ctx*/); + SE_PRECONDITION2(ok, false, "js_scene_AmbientInfo_getSkyLightingColor : Error processing arguments"); + SE_HOLD_RETURN_VALUE(result, s.thisObject(), s.rval()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 0); + return false; +} +SE_BIND_FUNC(js_scene_AmbientInfo_getSkyLightingColor) + +static bool js_scene_AmbientInfo_setGroundAlbedo(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_scene_AmbientInfo_setGroundAlbedo : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 1) { + HolderType arg0 = {}; + ok &= sevalue_to_native(args[0], &arg0, s.thisObject()); + SE_PRECONDITION2(ok, false, "js_scene_AmbientInfo_setGroundAlbedo : Error processing arguments"); + cobj->setGroundAlbedo(arg0.value()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 1); + return false; +} +SE_BIND_FUNC_AS_PROP_SET(js_scene_AmbientInfo_setGroundAlbedo) + +static bool js_scene_AmbientInfo_setGroundLightingColor(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_scene_AmbientInfo_setGroundLightingColor : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 1) { + HolderType arg0 = {}; + ok &= sevalue_to_native(args[0], &arg0, s.thisObject()); + SE_PRECONDITION2(ok, false, "js_scene_AmbientInfo_setGroundLightingColor : Error processing arguments"); + cobj->setGroundLightingColor(arg0.value()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 1); + return false; +} +SE_BIND_FUNC(js_scene_AmbientInfo_setGroundLightingColor) + +static bool js_scene_AmbientInfo_setSkyColor(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_scene_AmbientInfo_setSkyColor : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 1) { + HolderType arg0 = {}; + ok &= sevalue_to_native(args[0], &arg0, s.thisObject()); + SE_PRECONDITION2(ok, false, "js_scene_AmbientInfo_setSkyColor : Error processing arguments"); + cobj->setSkyColor(arg0.value()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 1); + return false; +} +SE_BIND_FUNC_AS_PROP_SET(js_scene_AmbientInfo_setSkyColor) + +static bool js_scene_AmbientInfo_setSkyIllum(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_scene_AmbientInfo_setSkyIllum : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 1) { + HolderType arg0 = {}; + ok &= sevalue_to_native(args[0], &arg0, s.thisObject()); + SE_PRECONDITION2(ok, false, "js_scene_AmbientInfo_setSkyIllum : Error processing arguments"); + cobj->setSkyIllum(arg0.value()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 1); + return false; +} +SE_BIND_FUNC_AS_PROP_SET(js_scene_AmbientInfo_setSkyIllum) + +static bool js_scene_AmbientInfo_setSkyLightingColor(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_scene_AmbientInfo_setSkyLightingColor : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 1) { + HolderType arg0 = {}; + ok &= sevalue_to_native(args[0], &arg0, s.thisObject()); + SE_PRECONDITION2(ok, false, "js_scene_AmbientInfo_setSkyLightingColor : Error processing arguments"); + cobj->setSkyLightingColor(arg0.value()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 1); + return false; +} +SE_BIND_FUNC(js_scene_AmbientInfo_setSkyLightingColor) + +static bool js_scene_AmbientInfo_get__skyColorHDR(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_scene_AmbientInfo_get__skyColorHDR : Invalid Native Object"); CC_UNUSED bool ok = true; se::Value jsret; - ok &= nativevalue_to_se(cobj->aspect, jsret, s.thisObject() /*ctx*/); + ok &= nativevalue_to_se(cobj->_skyColorHDR, jsret, s.thisObject() /*ctx*/); s.rval() = jsret; - SE_HOLD_RETURN_VALUE(cobj->aspect, s.thisObject(), s.rval()); + SE_HOLD_RETURN_VALUE(cobj->_skyColorHDR, s.thisObject(), s.rval()); return true; } -SE_BIND_PROP_GET(js_scene_Camera_get_aspect) +SE_BIND_PROP_GET(js_scene_AmbientInfo_get__skyColorHDR) -static bool js_scene_Camera_set_aspect(se::State& s) // NOLINT(readability-identifier-naming) +static bool js_scene_AmbientInfo_set__skyColorHDR(se::State& s) // NOLINT(readability-identifier-naming) { const auto& args = s.args(); - auto* cobj = SE_THIS_OBJECT(s); - SE_PRECONDITION2(cobj, false, "js_scene_Camera_set_aspect : Invalid Native Object"); + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_scene_AmbientInfo_set__skyColorHDR : Invalid Native Object"); CC_UNUSED bool ok = true; - ok &= sevalue_to_native(args[0], &cobj->aspect, s.thisObject()); - SE_PRECONDITION2(ok, false, "js_scene_Camera_set_aspect : Error processing new value"); + ok &= sevalue_to_native(args[0], &cobj->_skyColorHDR, s.thisObject()); + SE_PRECONDITION2(ok, false, "js_scene_AmbientInfo_set__skyColorHDR : Error processing new value"); return true; } -SE_BIND_PROP_SET(js_scene_Camera_set_aspect) +SE_BIND_PROP_SET(js_scene_AmbientInfo_set__skyColorHDR) -static bool js_scene_Camera_get_viewPort(se::State& s) // NOLINT(readability-identifier-naming) +static bool js_scene_AmbientInfo_get__skyIllumHDR(se::State& s) // NOLINT(readability-identifier-naming) { - auto* cobj = SE_THIS_OBJECT(s); - SE_PRECONDITION2(cobj, false, "js_scene_Camera_get_viewPort : Invalid Native Object"); + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_scene_AmbientInfo_get__skyIllumHDR : Invalid Native Object"); CC_UNUSED bool ok = true; se::Value jsret; - ok &= nativevalue_to_se(cobj->viewPort, jsret, s.thisObject() /*ctx*/); + ok &= nativevalue_to_se(cobj->_skyIllumHDR, jsret, s.thisObject() /*ctx*/); s.rval() = jsret; - SE_HOLD_RETURN_VALUE(cobj->viewPort, s.thisObject(), s.rval()); + SE_HOLD_RETURN_VALUE(cobj->_skyIllumHDR, s.thisObject(), s.rval()); return true; } -SE_BIND_PROP_GET(js_scene_Camera_get_viewPort) +SE_BIND_PROP_GET(js_scene_AmbientInfo_get__skyIllumHDR) -static bool js_scene_Camera_set_viewPort(se::State& s) // NOLINT(readability-identifier-naming) +static bool js_scene_AmbientInfo_set__skyIllumHDR(se::State& s) // NOLINT(readability-identifier-naming) { const auto& args = s.args(); - auto* cobj = SE_THIS_OBJECT(s); - SE_PRECONDITION2(cobj, false, "js_scene_Camera_set_viewPort : Invalid Native Object"); + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_scene_AmbientInfo_set__skyIllumHDR : Invalid Native Object"); CC_UNUSED bool ok = true; - ok &= sevalue_to_native(args[0], &cobj->viewPort, s.thisObject()); - SE_PRECONDITION2(ok, false, "js_scene_Camera_set_viewPort : Error processing new value"); + ok &= sevalue_to_native(args[0], &cobj->_skyIllumHDR, s.thisObject()); + SE_PRECONDITION2(ok, false, "js_scene_AmbientInfo_set__skyIllumHDR : Error processing new value"); return true; } -SE_BIND_PROP_SET(js_scene_Camera_set_viewPort) +SE_BIND_PROP_SET(js_scene_AmbientInfo_set__skyIllumHDR) -static bool js_scene_Camera_get_clearStencil(se::State& s) // NOLINT(readability-identifier-naming) +static bool js_scene_AmbientInfo_get__groundAlbedoHDR(se::State& s) // NOLINT(readability-identifier-naming) { - auto* cobj = SE_THIS_OBJECT(s); - SE_PRECONDITION2(cobj, false, "js_scene_Camera_get_clearStencil : Invalid Native Object"); + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_scene_AmbientInfo_get__groundAlbedoHDR : Invalid Native Object"); CC_UNUSED bool ok = true; se::Value jsret; - ok &= nativevalue_to_se(cobj->clearStencil, jsret, s.thisObject() /*ctx*/); + ok &= nativevalue_to_se(cobj->_groundAlbedoHDR, jsret, s.thisObject() /*ctx*/); s.rval() = jsret; - SE_HOLD_RETURN_VALUE(cobj->clearStencil, s.thisObject(), s.rval()); + SE_HOLD_RETURN_VALUE(cobj->_groundAlbedoHDR, s.thisObject(), s.rval()); return true; } -SE_BIND_PROP_GET(js_scene_Camera_get_clearStencil) +SE_BIND_PROP_GET(js_scene_AmbientInfo_get__groundAlbedoHDR) -static bool js_scene_Camera_set_clearStencil(se::State& s) // NOLINT(readability-identifier-naming) +static bool js_scene_AmbientInfo_set__groundAlbedoHDR(se::State& s) // NOLINT(readability-identifier-naming) { const auto& args = s.args(); - auto* cobj = SE_THIS_OBJECT(s); - SE_PRECONDITION2(cobj, false, "js_scene_Camera_set_clearStencil : Invalid Native Object"); + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_scene_AmbientInfo_set__groundAlbedoHDR : Invalid Native Object"); CC_UNUSED bool ok = true; - ok &= sevalue_to_native(args[0], &cobj->clearStencil, s.thisObject()); - SE_PRECONDITION2(ok, false, "js_scene_Camera_set_clearStencil : Error processing new value"); + ok &= sevalue_to_native(args[0], &cobj->_groundAlbedoHDR, s.thisObject()); + SE_PRECONDITION2(ok, false, "js_scene_AmbientInfo_set__groundAlbedoHDR : Error processing new value"); return true; } -SE_BIND_PROP_SET(js_scene_Camera_set_clearStencil) +SE_BIND_PROP_SET(js_scene_AmbientInfo_set__groundAlbedoHDR) -static bool js_scene_Camera_get_visibility(se::State& s) // NOLINT(readability-identifier-naming) +static bool js_scene_AmbientInfo_get__skyColorLDR(se::State& s) // NOLINT(readability-identifier-naming) { - auto* cobj = SE_THIS_OBJECT(s); - SE_PRECONDITION2(cobj, false, "js_scene_Camera_get_visibility : Invalid Native Object"); + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_scene_AmbientInfo_get__skyColorLDR : Invalid Native Object"); CC_UNUSED bool ok = true; se::Value jsret; - ok &= nativevalue_to_se(cobj->visibility, jsret, s.thisObject() /*ctx*/); + ok &= nativevalue_to_se(cobj->_skyColorLDR, jsret, s.thisObject() /*ctx*/); s.rval() = jsret; - SE_HOLD_RETURN_VALUE(cobj->visibility, s.thisObject(), s.rval()); + SE_HOLD_RETURN_VALUE(cobj->_skyColorLDR, s.thisObject(), s.rval()); return true; } -SE_BIND_PROP_GET(js_scene_Camera_get_visibility) +SE_BIND_PROP_GET(js_scene_AmbientInfo_get__skyColorLDR) -static bool js_scene_Camera_set_visibility(se::State& s) // NOLINT(readability-identifier-naming) +static bool js_scene_AmbientInfo_set__skyColorLDR(se::State& s) // NOLINT(readability-identifier-naming) { const auto& args = s.args(); - auto* cobj = SE_THIS_OBJECT(s); - SE_PRECONDITION2(cobj, false, "js_scene_Camera_set_visibility : Invalid Native Object"); + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_scene_AmbientInfo_set__skyColorLDR : Invalid Native Object"); CC_UNUSED bool ok = true; - ok &= sevalue_to_native(args[0], &cobj->visibility, s.thisObject()); - SE_PRECONDITION2(ok, false, "js_scene_Camera_set_visibility : Error processing new value"); + ok &= sevalue_to_native(args[0], &cobj->_skyColorLDR, s.thisObject()); + SE_PRECONDITION2(ok, false, "js_scene_AmbientInfo_set__skyColorLDR : Error processing new value"); return true; } -SE_BIND_PROP_SET(js_scene_Camera_set_visibility) +SE_BIND_PROP_SET(js_scene_AmbientInfo_set__skyColorLDR) -static bool js_scene_Camera_get_node(se::State& s) // NOLINT(readability-identifier-naming) +static bool js_scene_AmbientInfo_get__skyIllumLDR(se::State& s) // NOLINT(readability-identifier-naming) { - auto* cobj = SE_THIS_OBJECT(s); - SE_PRECONDITION2(cobj, false, "js_scene_Camera_get_node : Invalid Native Object"); + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_scene_AmbientInfo_get__skyIllumLDR : Invalid Native Object"); CC_UNUSED bool ok = true; se::Value jsret; - ok &= nativevalue_to_se(cobj->node, jsret, s.thisObject() /*ctx*/); + ok &= nativevalue_to_se(cobj->_skyIllumLDR, jsret, s.thisObject() /*ctx*/); s.rval() = jsret; - SE_HOLD_RETURN_VALUE(cobj->node, s.thisObject(), s.rval()); + SE_HOLD_RETURN_VALUE(cobj->_skyIllumLDR, s.thisObject(), s.rval()); return true; } -SE_BIND_PROP_GET(js_scene_Camera_get_node) +SE_BIND_PROP_GET(js_scene_AmbientInfo_get__skyIllumLDR) -static bool js_scene_Camera_set_node(se::State& s) // NOLINT(readability-identifier-naming) +static bool js_scene_AmbientInfo_set__skyIllumLDR(se::State& s) // NOLINT(readability-identifier-naming) { const auto& args = s.args(); - auto* cobj = SE_THIS_OBJECT(s); - SE_PRECONDITION2(cobj, false, "js_scene_Camera_set_node : Invalid Native Object"); + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_scene_AmbientInfo_set__skyIllumLDR : Invalid Native Object"); CC_UNUSED bool ok = true; - ok &= sevalue_to_native(args[0], &cobj->node, s.thisObject()); - SE_PRECONDITION2(ok, false, "js_scene_Camera_set_node : Error processing new value"); + ok &= sevalue_to_native(args[0], &cobj->_skyIllumLDR, s.thisObject()); + SE_PRECONDITION2(ok, false, "js_scene_AmbientInfo_set__skyIllumLDR : Error processing new value"); return true; } -SE_BIND_PROP_SET(js_scene_Camera_set_node) +SE_BIND_PROP_SET(js_scene_AmbientInfo_set__skyIllumLDR) -static bool js_scene_Camera_get_scene(se::State& s) // NOLINT(readability-identifier-naming) +static bool js_scene_AmbientInfo_get__groundAlbedoLDR(se::State& s) // NOLINT(readability-identifier-naming) { - auto* cobj = SE_THIS_OBJECT(s); - SE_PRECONDITION2(cobj, false, "js_scene_Camera_get_scene : Invalid Native Object"); + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_scene_AmbientInfo_get__groundAlbedoLDR : Invalid Native Object"); CC_UNUSED bool ok = true; se::Value jsret; - ok &= nativevalue_to_se(cobj->scene, jsret, s.thisObject() /*ctx*/); + ok &= nativevalue_to_se(cobj->_groundAlbedoLDR, jsret, s.thisObject() /*ctx*/); s.rval() = jsret; - SE_HOLD_RETURN_VALUE(cobj->scene, s.thisObject(), s.rval()); + SE_HOLD_RETURN_VALUE(cobj->_groundAlbedoLDR, s.thisObject(), s.rval()); return true; } -SE_BIND_PROP_GET(js_scene_Camera_get_scene) +SE_BIND_PROP_GET(js_scene_AmbientInfo_get__groundAlbedoLDR) -static bool js_scene_Camera_set_scene(se::State& s) // NOLINT(readability-identifier-naming) +static bool js_scene_AmbientInfo_set__groundAlbedoLDR(se::State& s) // NOLINT(readability-identifier-naming) { const auto& args = s.args(); - auto* cobj = SE_THIS_OBJECT(s); - SE_PRECONDITION2(cobj, false, "js_scene_Camera_set_scene : Invalid Native Object"); + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_scene_AmbientInfo_set__groundAlbedoLDR : Invalid Native Object"); CC_UNUSED bool ok = true; - ok &= sevalue_to_native(args[0], &cobj->scene, s.thisObject()); - SE_PRECONDITION2(ok, false, "js_scene_Camera_set_scene : Error processing new value"); + ok &= sevalue_to_native(args[0], &cobj->_groundAlbedoLDR, s.thisObject()); + SE_PRECONDITION2(ok, false, "js_scene_AmbientInfo_set__groundAlbedoLDR : Error processing new value"); return true; } -SE_BIND_PROP_SET(js_scene_Camera_set_scene) +SE_BIND_PROP_SET(js_scene_AmbientInfo_set__groundAlbedoLDR) -static bool js_scene_Camera_get_window(se::State& s) // NOLINT(readability-identifier-naming) +SE_DECLARE_FINALIZE_FUNC(js_cc_scene_AmbientInfo_finalize) + +static bool js_scene_AmbientInfo_constructor(se::State& s) // NOLINT(readability-identifier-naming) constructor.c { - auto* cobj = SE_THIS_OBJECT(s); - SE_PRECONDITION2(cobj, false, "js_scene_Camera_get_window : Invalid Native Object"); + auto *ptr = JSB_MAKE_PRIVATE_OBJECT(cc::scene::AmbientInfo); + s.thisObject()->setPrivateObject(ptr); + return true; +} +SE_BIND_CTOR(js_scene_AmbientInfo_constructor, __jsb_cc_scene_AmbientInfo_class, js_cc_scene_AmbientInfo_finalize) + +static bool js_cc_scene_AmbientInfo_finalize(se::State& s) // NOLINT(readability-identifier-naming) +{ + return true; +} +SE_BIND_FINALIZE_FUNC(js_cc_scene_AmbientInfo_finalize) + +bool js_register_scene_AmbientInfo(se::Object* obj) // NOLINT(readability-identifier-naming) +{ + auto* cls = se::Class::create("AmbientInfo", obj, nullptr, _SE(js_scene_AmbientInfo_constructor)); + + cls->defineProperty("_skyColorHDR", _SE(js_scene_AmbientInfo_get__skyColorHDR), _SE(js_scene_AmbientInfo_set__skyColorHDR)); + cls->defineProperty("_skyIllumHDR", _SE(js_scene_AmbientInfo_get__skyIllumHDR), _SE(js_scene_AmbientInfo_set__skyIllumHDR)); + cls->defineProperty("_groundAlbedoHDR", _SE(js_scene_AmbientInfo_get__groundAlbedoHDR), _SE(js_scene_AmbientInfo_set__groundAlbedoHDR)); + cls->defineProperty("_skyColorLDR", _SE(js_scene_AmbientInfo_get__skyColorLDR), _SE(js_scene_AmbientInfo_set__skyColorLDR)); + cls->defineProperty("_skyIllumLDR", _SE(js_scene_AmbientInfo_get__skyIllumLDR), _SE(js_scene_AmbientInfo_set__skyIllumLDR)); + cls->defineProperty("_groundAlbedoLDR", _SE(js_scene_AmbientInfo_get__groundAlbedoLDR), _SE(js_scene_AmbientInfo_set__groundAlbedoLDR)); + cls->defineProperty("skyColor", nullptr, _SE(js_scene_AmbientInfo_setSkyColor_asSetter)); + cls->defineProperty("groundAlbedo", nullptr, _SE(js_scene_AmbientInfo_setGroundAlbedo_asSetter)); + cls->defineProperty("skyIllum", _SE(js_scene_AmbientInfo_getSkyIllum_asGetter), _SE(js_scene_AmbientInfo_setSkyIllum_asSetter)); + cls->defineFunction("getGroundAlbedoHDR", _SE(js_scene_AmbientInfo_getGroundAlbedoHDR)); + cls->defineFunction("getGroundAlbedoLDR", _SE(js_scene_AmbientInfo_getGroundAlbedoLDR)); + cls->defineFunction("getGroundLightingColor", _SE(js_scene_AmbientInfo_getGroundLightingColor)); + cls->defineFunction("getSkyColorHDR", _SE(js_scene_AmbientInfo_getSkyColorHDR)); + cls->defineFunction("getSkyColorLDR", _SE(js_scene_AmbientInfo_getSkyColorLDR)); + cls->defineFunction("getSkyIllumHDR", _SE(js_scene_AmbientInfo_getSkyIllumHDR)); + cls->defineFunction("getSkyIllumLDR", _SE(js_scene_AmbientInfo_getSkyIllumLDR)); + cls->defineFunction("getSkyLightingColor", _SE(js_scene_AmbientInfo_getSkyLightingColor)); + cls->defineFunction("setGroundLightingColor", _SE(js_scene_AmbientInfo_setGroundLightingColor)); + cls->defineFunction("setSkyLightingColor", _SE(js_scene_AmbientInfo_setSkyLightingColor)); + cls->defineFinalizeFunction(_SE(js_cc_scene_AmbientInfo_finalize)); + cls->install(); + JSBClassType::registerClass(cls); + + __jsb_cc_scene_AmbientInfo_proto = cls->getProto(); + __jsb_cc_scene_AmbientInfo_class = cls; + + + se::ScriptEngine::getInstance()->clearException(); + return true; +} +se::Object* __jsb_cc_scene_DirectionalLight_proto = nullptr; // NOLINT +se::Class* __jsb_cc_scene_DirectionalLight_class = nullptr; // NOLINT + +static bool js_scene_DirectionalLight_getDirection(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_scene_DirectionalLight_getDirection : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 0) { + const cc::Vec3& result = cobj->getDirection(); + ok &= nativevalue_to_se(result, s.rval(), nullptr /*ctx*/); + SE_PRECONDITION2(ok, false, "js_scene_DirectionalLight_getDirection : Error processing arguments"); + SE_HOLD_RETURN_VALUE(result, s.thisObject(), s.rval()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 0); + return false; +} +SE_BIND_FUNC_AS_PROP_GET(js_scene_DirectionalLight_getDirection) + +static bool js_scene_DirectionalLight_getIlluminance(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_scene_DirectionalLight_getIlluminance : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 0) { + float result = cobj->getIlluminance(); + ok &= nativevalue_to_se(result, s.rval(), nullptr /*ctx*/); + SE_PRECONDITION2(ok, false, "js_scene_DirectionalLight_getIlluminance : Error processing arguments"); + SE_HOLD_RETURN_VALUE(result, s.thisObject(), s.rval()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 0); + return false; +} +SE_BIND_FUNC_AS_PROP_GET(js_scene_DirectionalLight_getIlluminance) + +static bool js_scene_DirectionalLight_getIlluminanceHDR(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_scene_DirectionalLight_getIlluminanceHDR : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 0) { + float result = cobj->getIlluminanceHDR(); + ok &= nativevalue_to_se(result, s.rval(), nullptr /*ctx*/); + SE_PRECONDITION2(ok, false, "js_scene_DirectionalLight_getIlluminanceHDR : Error processing arguments"); + SE_HOLD_RETURN_VALUE(result, s.thisObject(), s.rval()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 0); + return false; +} +SE_BIND_FUNC_AS_PROP_GET(js_scene_DirectionalLight_getIlluminanceHDR) + +static bool js_scene_DirectionalLight_getIlluminanceLDR(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_scene_DirectionalLight_getIlluminanceLDR : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 0) { + float result = cobj->getIlluminanceLDR(); + ok &= nativevalue_to_se(result, s.rval(), nullptr /*ctx*/); + SE_PRECONDITION2(ok, false, "js_scene_DirectionalLight_getIlluminanceLDR : Error processing arguments"); + SE_HOLD_RETURN_VALUE(result, s.thisObject(), s.rval()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 0); + return false; +} +SE_BIND_FUNC_AS_PROP_GET(js_scene_DirectionalLight_getIlluminanceLDR) + +static bool js_scene_DirectionalLight_setDirection(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_scene_DirectionalLight_setDirection : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 1) { + HolderType arg0 = {}; + ok &= sevalue_to_native(args[0], &arg0, s.thisObject()); + SE_PRECONDITION2(ok, false, "js_scene_DirectionalLight_setDirection : Error processing arguments"); + cobj->setDirection(arg0.value()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 1); + return false; +} +SE_BIND_FUNC_AS_PROP_SET(js_scene_DirectionalLight_setDirection) + +static bool js_scene_DirectionalLight_setIlluminance(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_scene_DirectionalLight_setIlluminance : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 1) { + HolderType arg0 = {}; + ok &= sevalue_to_native(args[0], &arg0, s.thisObject()); + SE_PRECONDITION2(ok, false, "js_scene_DirectionalLight_setIlluminance : Error processing arguments"); + cobj->setIlluminance(arg0.value()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 1); + return false; +} +SE_BIND_FUNC_AS_PROP_SET(js_scene_DirectionalLight_setIlluminance) + +static bool js_scene_DirectionalLight_setIlluminanceHDR(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_scene_DirectionalLight_setIlluminanceHDR : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 1) { + HolderType arg0 = {}; + ok &= sevalue_to_native(args[0], &arg0, s.thisObject()); + SE_PRECONDITION2(ok, false, "js_scene_DirectionalLight_setIlluminanceHDR : Error processing arguments"); + cobj->setIlluminanceHDR(arg0.value()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 1); + return false; +} +SE_BIND_FUNC_AS_PROP_SET(js_scene_DirectionalLight_setIlluminanceHDR) + +static bool js_scene_DirectionalLight_setIlluminanceLDR(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_scene_DirectionalLight_setIlluminanceLDR : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 1) { + HolderType arg0 = {}; + ok &= sevalue_to_native(args[0], &arg0, s.thisObject()); + SE_PRECONDITION2(ok, false, "js_scene_DirectionalLight_setIlluminanceLDR : Error processing arguments"); + cobj->setIlluminanceLDR(arg0.value()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 1); + return false; +} +SE_BIND_FUNC_AS_PROP_SET(js_scene_DirectionalLight_setIlluminanceLDR) + +SE_DECLARE_FINALIZE_FUNC(js_cc_scene_DirectionalLight_finalize) + +static bool js_scene_DirectionalLight_constructor(se::State& s) // NOLINT(readability-identifier-naming) constructor.c +{ + auto *ptr = JSB_MAKE_PRIVATE_OBJECT(cc::scene::DirectionalLight); + s.thisObject()->setPrivateObject(ptr); + return true; +} +SE_BIND_CTOR(js_scene_DirectionalLight_constructor, __jsb_cc_scene_DirectionalLight_class, js_cc_scene_DirectionalLight_finalize) + +static bool js_cc_scene_DirectionalLight_finalize(se::State& s) // NOLINT(readability-identifier-naming) +{ + return true; +} +SE_BIND_FINALIZE_FUNC(js_cc_scene_DirectionalLight_finalize) + +bool js_register_scene_DirectionalLight(se::Object* obj) // NOLINT(readability-identifier-naming) +{ + auto* cls = se::Class::create("DirectionalLight", obj, __jsb_cc_scene_Light_proto, _SE(js_scene_DirectionalLight_constructor)); + + cls->defineProperty("illuminance", _SE(js_scene_DirectionalLight_getIlluminance_asGetter), _SE(js_scene_DirectionalLight_setIlluminance_asSetter)); + cls->defineProperty("illuminanceHDR", _SE(js_scene_DirectionalLight_getIlluminanceHDR_asGetter), _SE(js_scene_DirectionalLight_setIlluminanceHDR_asSetter)); + cls->defineProperty("direction", _SE(js_scene_DirectionalLight_getDirection_asGetter), _SE(js_scene_DirectionalLight_setDirection_asSetter)); + cls->defineProperty("illuminanceLDR", _SE(js_scene_DirectionalLight_getIlluminanceLDR_asGetter), _SE(js_scene_DirectionalLight_setIlluminanceLDR_asSetter)); + cls->defineFinalizeFunction(_SE(js_cc_scene_DirectionalLight_finalize)); + cls->install(); + JSBClassType::registerClass(cls); + + __jsb_cc_scene_DirectionalLight_proto = cls->getProto(); + __jsb_cc_scene_DirectionalLight_class = cls; + + + se::ScriptEngine::getInstance()->clearException(); + return true; +} +se::Object* __jsb_cc_scene_SpotLight_proto = nullptr; // NOLINT +se::Class* __jsb_cc_scene_SpotLight_class = nullptr; // NOLINT + +static bool js_scene_SpotLight_getAABB(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_scene_SpotLight_getAABB : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 0) { + const cc::geometry::AABB& result = cobj->getAABB(); + ok &= nativevalue_to_se(result, s.rval(), nullptr /*ctx*/); + SE_PRECONDITION2(ok, false, "js_scene_SpotLight_getAABB : Error processing arguments"); + SE_HOLD_RETURN_VALUE(result, s.thisObject(), s.rval()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 0); + return false; +} +SE_BIND_FUNC_AS_PROP_GET(js_scene_SpotLight_getAABB) + +static bool js_scene_SpotLight_getAngle(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_scene_SpotLight_getAngle : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 0) { + float result = cobj->getAngle(); + ok &= nativevalue_to_se(result, s.rval(), nullptr /*ctx*/); + SE_PRECONDITION2(ok, false, "js_scene_SpotLight_getAngle : Error processing arguments"); + SE_HOLD_RETURN_VALUE(result, s.thisObject(), s.rval()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 0); + return false; +} +SE_BIND_FUNC_AS_PROP_GET(js_scene_SpotLight_getAngle) + +static bool js_scene_SpotLight_getAspect(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_scene_SpotLight_getAspect : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 0) { + float result = cobj->getAspect(); + ok &= nativevalue_to_se(result, s.rval(), nullptr /*ctx*/); + SE_PRECONDITION2(ok, false, "js_scene_SpotLight_getAspect : Error processing arguments"); + SE_HOLD_RETURN_VALUE(result, s.thisObject(), s.rval()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 0); + return false; +} +SE_BIND_FUNC_AS_PROP_GET(js_scene_SpotLight_getAspect) + +static bool js_scene_SpotLight_getDirection(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_scene_SpotLight_getDirection : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 0) { + const cc::Vec3& result = cobj->getDirection(); + ok &= nativevalue_to_se(result, s.rval(), nullptr /*ctx*/); + SE_PRECONDITION2(ok, false, "js_scene_SpotLight_getDirection : Error processing arguments"); + SE_HOLD_RETURN_VALUE(result, s.thisObject(), s.rval()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 0); + return false; +} +SE_BIND_FUNC_AS_PROP_GET(js_scene_SpotLight_getDirection) + +static bool js_scene_SpotLight_getFrustum(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_scene_SpotLight_getFrustum : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 0) { + const cc::geometry::Frustum& result = cobj->getFrustum(); + ok &= nativevalue_to_se(result, s.rval(), nullptr /*ctx*/); + SE_PRECONDITION2(ok, false, "js_scene_SpotLight_getFrustum : Error processing arguments"); + SE_HOLD_RETURN_VALUE(result, s.thisObject(), s.rval()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 0); + return false; +} +SE_BIND_FUNC_AS_PROP_GET(js_scene_SpotLight_getFrustum) + +static bool js_scene_SpotLight_getLuminance(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_scene_SpotLight_getLuminance : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 0) { + float result = cobj->getLuminance(); + ok &= nativevalue_to_se(result, s.rval(), nullptr /*ctx*/); + SE_PRECONDITION2(ok, false, "js_scene_SpotLight_getLuminance : Error processing arguments"); + SE_HOLD_RETURN_VALUE(result, s.thisObject(), s.rval()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 0); + return false; +} +SE_BIND_FUNC_AS_PROP_GET(js_scene_SpotLight_getLuminance) + +static bool js_scene_SpotLight_getLuminanceHDR(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_scene_SpotLight_getLuminanceHDR : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 0) { + float result = cobj->getLuminanceHDR(); + ok &= nativevalue_to_se(result, s.rval(), nullptr /*ctx*/); + SE_PRECONDITION2(ok, false, "js_scene_SpotLight_getLuminanceHDR : Error processing arguments"); + SE_HOLD_RETURN_VALUE(result, s.thisObject(), s.rval()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 0); + return false; +} +SE_BIND_FUNC_AS_PROP_GET(js_scene_SpotLight_getLuminanceHDR) + +static bool js_scene_SpotLight_getLuminanceLDR(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_scene_SpotLight_getLuminanceLDR : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 0) { + float result = cobj->getLuminanceLDR(); + ok &= nativevalue_to_se(result, s.rval(), nullptr /*ctx*/); + SE_PRECONDITION2(ok, false, "js_scene_SpotLight_getLuminanceLDR : Error processing arguments"); + SE_HOLD_RETURN_VALUE(result, s.thisObject(), s.rval()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 0); + return false; +} +SE_BIND_FUNC_AS_PROP_GET(js_scene_SpotLight_getLuminanceLDR) + +static bool js_scene_SpotLight_getPosition(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_scene_SpotLight_getPosition : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 0) { + const cc::Vec3& result = cobj->getPosition(); + ok &= nativevalue_to_se(result, s.rval(), nullptr /*ctx*/); + SE_PRECONDITION2(ok, false, "js_scene_SpotLight_getPosition : Error processing arguments"); + SE_HOLD_RETURN_VALUE(result, s.thisObject(), s.rval()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 0); + return false; +} +SE_BIND_FUNC_AS_PROP_GET(js_scene_SpotLight_getPosition) + +static bool js_scene_SpotLight_getRange(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_scene_SpotLight_getRange : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 0) { + float result = cobj->getRange(); + ok &= nativevalue_to_se(result, s.rval(), nullptr /*ctx*/); + SE_PRECONDITION2(ok, false, "js_scene_SpotLight_getRange : Error processing arguments"); + SE_HOLD_RETURN_VALUE(result, s.thisObject(), s.rval()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 0); + return false; +} +SE_BIND_FUNC_AS_PROP_GET(js_scene_SpotLight_getRange) + +static bool js_scene_SpotLight_getSize(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_scene_SpotLight_getSize : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 0) { + float result = cobj->getSize(); + ok &= nativevalue_to_se(result, s.rval(), nullptr /*ctx*/); + SE_PRECONDITION2(ok, false, "js_scene_SpotLight_getSize : Error processing arguments"); + SE_HOLD_RETURN_VALUE(result, s.thisObject(), s.rval()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 0); + return false; +} +SE_BIND_FUNC_AS_PROP_GET(js_scene_SpotLight_getSize) + +static bool js_scene_SpotLight_getSpotAngle(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_scene_SpotLight_getSpotAngle : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 0) { + float result = cobj->getSpotAngle(); + ok &= nativevalue_to_se(result, s.rval(), nullptr /*ctx*/); + SE_PRECONDITION2(ok, false, "js_scene_SpotLight_getSpotAngle : Error processing arguments"); + SE_HOLD_RETURN_VALUE(result, s.thisObject(), s.rval()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 0); + return false; +} +SE_BIND_FUNC_AS_PROP_GET(js_scene_SpotLight_getSpotAngle) + +static bool js_scene_SpotLight_setAspect(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_scene_SpotLight_setAspect : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 1) { + HolderType arg0 = {}; + ok &= sevalue_to_native(args[0], &arg0, s.thisObject()); + SE_PRECONDITION2(ok, false, "js_scene_SpotLight_setAspect : Error processing arguments"); + cobj->setAspect(arg0.value()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 1); + return false; +} +SE_BIND_FUNC_AS_PROP_SET(js_scene_SpotLight_setAspect) + +static bool js_scene_SpotLight_setFrustum(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_scene_SpotLight_setFrustum : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 1) { + HolderType arg0 = {}; + ok &= sevalue_to_native(args[0], &arg0, s.thisObject()); + SE_PRECONDITION2(ok, false, "js_scene_SpotLight_setFrustum : Error processing arguments"); + cobj->setFrustum(arg0.value()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 1); + return false; +} +SE_BIND_FUNC_AS_PROP_SET(js_scene_SpotLight_setFrustum) + +static bool js_scene_SpotLight_setLuminance(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_scene_SpotLight_setLuminance : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 1) { + HolderType arg0 = {}; + ok &= sevalue_to_native(args[0], &arg0, s.thisObject()); + SE_PRECONDITION2(ok, false, "js_scene_SpotLight_setLuminance : Error processing arguments"); + cobj->setLuminance(arg0.value()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 1); + return false; +} +SE_BIND_FUNC_AS_PROP_SET(js_scene_SpotLight_setLuminance) + +static bool js_scene_SpotLight_setLuminanceHDR(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_scene_SpotLight_setLuminanceHDR : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 1) { + HolderType arg0 = {}; + ok &= sevalue_to_native(args[0], &arg0, s.thisObject()); + SE_PRECONDITION2(ok, false, "js_scene_SpotLight_setLuminanceHDR : Error processing arguments"); + cobj->setLuminanceHDR(arg0.value()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 1); + return false; +} +SE_BIND_FUNC_AS_PROP_SET(js_scene_SpotLight_setLuminanceHDR) + +static bool js_scene_SpotLight_setLuminanceLDR(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_scene_SpotLight_setLuminanceLDR : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 1) { + HolderType arg0 = {}; + ok &= sevalue_to_native(args[0], &arg0, s.thisObject()); + SE_PRECONDITION2(ok, false, "js_scene_SpotLight_setLuminanceLDR : Error processing arguments"); + cobj->setLuminanceLDR(arg0.value()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 1); + return false; +} +SE_BIND_FUNC_AS_PROP_SET(js_scene_SpotLight_setLuminanceLDR) + +static bool js_scene_SpotLight_setRange(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_scene_SpotLight_setRange : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 1) { + HolderType arg0 = {}; + ok &= sevalue_to_native(args[0], &arg0, s.thisObject()); + SE_PRECONDITION2(ok, false, "js_scene_SpotLight_setRange : Error processing arguments"); + cobj->setRange(arg0.value()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 1); + return false; +} +SE_BIND_FUNC_AS_PROP_SET(js_scene_SpotLight_setRange) + +static bool js_scene_SpotLight_setSize(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_scene_SpotLight_setSize : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 1) { + HolderType arg0 = {}; + ok &= sevalue_to_native(args[0], &arg0, s.thisObject()); + SE_PRECONDITION2(ok, false, "js_scene_SpotLight_setSize : Error processing arguments"); + cobj->setSize(arg0.value()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 1); + return false; +} +SE_BIND_FUNC_AS_PROP_SET(js_scene_SpotLight_setSize) + +static bool js_scene_SpotLight_setSpotAngle(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_scene_SpotLight_setSpotAngle : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 1) { + HolderType arg0 = {}; + ok &= sevalue_to_native(args[0], &arg0, s.thisObject()); + SE_PRECONDITION2(ok, false, "js_scene_SpotLight_setSpotAngle : Error processing arguments"); + cobj->setSpotAngle(arg0.value()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 1); + return false; +} +SE_BIND_FUNC_AS_PROP_SET(js_scene_SpotLight_setSpotAngle) + +SE_DECLARE_FINALIZE_FUNC(js_cc_scene_SpotLight_finalize) + +static bool js_scene_SpotLight_constructor(se::State& s) // NOLINT(readability-identifier-naming) constructor.c +{ + auto *ptr = JSB_MAKE_PRIVATE_OBJECT(cc::scene::SpotLight); + s.thisObject()->setPrivateObject(ptr); + return true; +} +SE_BIND_CTOR(js_scene_SpotLight_constructor, __jsb_cc_scene_SpotLight_class, js_cc_scene_SpotLight_finalize) + +static bool js_cc_scene_SpotLight_finalize(se::State& s) // NOLINT(readability-identifier-naming) +{ + return true; +} +SE_BIND_FINALIZE_FUNC(js_cc_scene_SpotLight_finalize) + +bool js_register_scene_SpotLight(se::Object* obj) // NOLINT(readability-identifier-naming) +{ + auto* cls = se::Class::create("SpotLight", obj, __jsb_cc_scene_Light_proto, _SE(js_scene_SpotLight_constructor)); + + cls->defineProperty("direction", _SE(js_scene_SpotLight_getDirection_asGetter), nullptr); + cls->defineProperty("luminance", _SE(js_scene_SpotLight_getLuminance_asGetter), _SE(js_scene_SpotLight_setLuminance_asSetter)); + cls->defineProperty("angle", _SE(js_scene_SpotLight_getAngle_asGetter), nullptr); + cls->defineProperty("frustum", _SE(js_scene_SpotLight_getFrustum_asGetter), _SE(js_scene_SpotLight_setFrustum_asSetter)); + cls->defineProperty("luminanceLDR", _SE(js_scene_SpotLight_getLuminanceLDR_asGetter), _SE(js_scene_SpotLight_setLuminanceLDR_asSetter)); + cls->defineProperty("aabb", _SE(js_scene_SpotLight_getAABB_asGetter), nullptr); + cls->defineProperty("luminanceHDR", _SE(js_scene_SpotLight_getLuminanceHDR_asGetter), _SE(js_scene_SpotLight_setLuminanceHDR_asSetter)); + cls->defineProperty("spotAngle", _SE(js_scene_SpotLight_getSpotAngle_asGetter), _SE(js_scene_SpotLight_setSpotAngle_asSetter)); + cls->defineProperty("range", _SE(js_scene_SpotLight_getRange_asGetter), _SE(js_scene_SpotLight_setRange_asSetter)); + cls->defineProperty("aspect", _SE(js_scene_SpotLight_getAspect_asGetter), _SE(js_scene_SpotLight_setAspect_asSetter)); + cls->defineProperty("position", _SE(js_scene_SpotLight_getPosition_asGetter), nullptr); + cls->defineProperty("size", _SE(js_scene_SpotLight_getSize_asGetter), _SE(js_scene_SpotLight_setSize_asSetter)); + cls->defineFinalizeFunction(_SE(js_cc_scene_SpotLight_finalize)); + cls->install(); + JSBClassType::registerClass(cls); + + __jsb_cc_scene_SpotLight_proto = cls->getProto(); + __jsb_cc_scene_SpotLight_class = cls; + + + se::ScriptEngine::getInstance()->clearException(); + return true; +} +se::Object* __jsb_cc_IMaterialInstanceInfo_proto = nullptr; // NOLINT +se::Class* __jsb_cc_IMaterialInstanceInfo_class = nullptr; // NOLINT + +static bool js_scene_IMaterialInstanceInfo_get_parent(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_scene_IMaterialInstanceInfo_get_parent : Invalid Native Object"); CC_UNUSED bool ok = true; se::Value jsret; - ok &= nativevalue_to_se(cobj->window, jsret, s.thisObject() /*ctx*/); + ok &= nativevalue_to_se(cobj->parent, jsret, s.thisObject() /*ctx*/); s.rval() = jsret; - SE_HOLD_RETURN_VALUE(cobj->window, s.thisObject(), s.rval()); + SE_HOLD_RETURN_VALUE(cobj->parent, s.thisObject(), s.rval()); return true; } -SE_BIND_PROP_GET(js_scene_Camera_get_window) +SE_BIND_PROP_GET(js_scene_IMaterialInstanceInfo_get_parent) -static bool js_scene_Camera_set_window(se::State& s) // NOLINT(readability-identifier-naming) +static bool js_scene_IMaterialInstanceInfo_set_parent(se::State& s) // NOLINT(readability-identifier-naming) { const auto& args = s.args(); - auto* cobj = SE_THIS_OBJECT(s); - SE_PRECONDITION2(cobj, false, "js_scene_Camera_set_window : Invalid Native Object"); + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_scene_IMaterialInstanceInfo_set_parent : Invalid Native Object"); CC_UNUSED bool ok = true; - ok &= sevalue_to_native(args[0], &cobj->window, s.thisObject()); - SE_PRECONDITION2(ok, false, "js_scene_Camera_set_window : Error processing new value"); + ok &= sevalue_to_native(args[0], &cobj->parent, s.thisObject()); + SE_PRECONDITION2(ok, false, "js_scene_IMaterialInstanceInfo_set_parent : Error processing new value"); return true; } -SE_BIND_PROP_SET(js_scene_Camera_set_window) +SE_BIND_PROP_SET(js_scene_IMaterialInstanceInfo_set_parent) -static bool js_scene_Camera_get_frustum(se::State& s) // NOLINT(readability-identifier-naming) +static bool js_scene_IMaterialInstanceInfo_get_subModelIdx(se::State& s) // NOLINT(readability-identifier-naming) { - auto* cobj = SE_THIS_OBJECT(s); - SE_PRECONDITION2(cobj, false, "js_scene_Camera_get_frustum : Invalid Native Object"); + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_scene_IMaterialInstanceInfo_get_subModelIdx : Invalid Native Object"); CC_UNUSED bool ok = true; se::Value jsret; - ok &= nativevalue_to_se(cobj->frustum, jsret, s.thisObject() /*ctx*/); + ok &= nativevalue_to_se(cobj->subModelIdx, jsret, s.thisObject() /*ctx*/); s.rval() = jsret; - SE_HOLD_RETURN_VALUE(cobj->frustum, s.thisObject(), s.rval()); + SE_HOLD_RETURN_VALUE(cobj->subModelIdx, s.thisObject(), s.rval()); return true; } -SE_BIND_PROP_GET(js_scene_Camera_get_frustum) +SE_BIND_PROP_GET(js_scene_IMaterialInstanceInfo_get_subModelIdx) -static bool js_scene_Camera_set_frustum(se::State& s) // NOLINT(readability-identifier-naming) +static bool js_scene_IMaterialInstanceInfo_set_subModelIdx(se::State& s) // NOLINT(readability-identifier-naming) { const auto& args = s.args(); - auto* cobj = SE_THIS_OBJECT(s); - SE_PRECONDITION2(cobj, false, "js_scene_Camera_set_frustum : Invalid Native Object"); + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_scene_IMaterialInstanceInfo_set_subModelIdx : Invalid Native Object"); CC_UNUSED bool ok = true; - ok &= sevalue_to_native(args[0], &cobj->frustum, s.thisObject()); - SE_PRECONDITION2(ok, false, "js_scene_Camera_set_frustum : Error processing new value"); + ok &= sevalue_to_native(args[0], &cobj->subModelIdx, s.thisObject()); + SE_PRECONDITION2(ok, false, "js_scene_IMaterialInstanceInfo_set_subModelIdx : Error processing new value"); return true; } -SE_BIND_PROP_SET(js_scene_Camera_set_frustum) - -static bool js_scene_Camera_get_forward(se::State& s) // NOLINT(readability-identifier-naming) -{ - auto* cobj = SE_THIS_OBJECT(s); - SE_PRECONDITION2(cobj, false, "js_scene_Camera_get_forward : Invalid Native Object"); - - CC_UNUSED bool ok = true; - se::Value jsret; - ok &= nativevalue_to_se(cobj->forward, jsret, s.thisObject() /*ctx*/); - s.rval() = jsret; - SE_HOLD_RETURN_VALUE(cobj->forward, s.thisObject(), s.rval()); - return true; -} -SE_BIND_PROP_GET(js_scene_Camera_get_forward) - -static bool js_scene_Camera_set_forward(se::State& s) // NOLINT(readability-identifier-naming) -{ - const auto& args = s.args(); - auto* cobj = SE_THIS_OBJECT(s); - SE_PRECONDITION2(cobj, false, "js_scene_Camera_set_forward : Invalid Native Object"); - - CC_UNUSED bool ok = true; - ok &= sevalue_to_native(args[0], &cobj->forward, s.thisObject()); - SE_PRECONDITION2(ok, false, "js_scene_Camera_set_forward : Error processing new value"); - return true; -} -SE_BIND_PROP_SET(js_scene_Camera_set_forward) - -static bool js_scene_Camera_get_position(se::State& s) // NOLINT(readability-identifier-naming) -{ - auto* cobj = SE_THIS_OBJECT(s); - SE_PRECONDITION2(cobj, false, "js_scene_Camera_get_position : Invalid Native Object"); - - CC_UNUSED bool ok = true; - se::Value jsret; - ok &= nativevalue_to_se(cobj->position, jsret, s.thisObject() /*ctx*/); - s.rval() = jsret; - SE_HOLD_RETURN_VALUE(cobj->position, s.thisObject(), s.rval()); - return true; -} -SE_BIND_PROP_GET(js_scene_Camera_get_position) - -static bool js_scene_Camera_set_position(se::State& s) // NOLINT(readability-identifier-naming) -{ - const auto& args = s.args(); - auto* cobj = SE_THIS_OBJECT(s); - SE_PRECONDITION2(cobj, false, "js_scene_Camera_set_position : Invalid Native Object"); - - CC_UNUSED bool ok = true; - ok &= sevalue_to_native(args[0], &cobj->position, s.thisObject()); - SE_PRECONDITION2(ok, false, "js_scene_Camera_set_position : Error processing new value"); - return true; -} -SE_BIND_PROP_SET(js_scene_Camera_set_position) - -static bool js_scene_Camera_get_clearColor(se::State& s) // NOLINT(readability-identifier-naming) -{ - auto* cobj = SE_THIS_OBJECT(s); - SE_PRECONDITION2(cobj, false, "js_scene_Camera_get_clearColor : Invalid Native Object"); - - CC_UNUSED bool ok = true; - se::Value jsret; - ok &= nativevalue_to_se(cobj->clearColor, jsret, s.thisObject() /*ctx*/); - s.rval() = jsret; - SE_HOLD_RETURN_VALUE(cobj->clearColor, s.thisObject(), s.rval()); - return true; -} -SE_BIND_PROP_GET(js_scene_Camera_get_clearColor) - -static bool js_scene_Camera_set_clearColor(se::State& s) // NOLINT(readability-identifier-naming) -{ - const auto& args = s.args(); - auto* cobj = SE_THIS_OBJECT(s); - SE_PRECONDITION2(cobj, false, "js_scene_Camera_set_clearColor : Invalid Native Object"); - - CC_UNUSED bool ok = true; - ok &= sevalue_to_native(args[0], &cobj->clearColor, s.thisObject()); - SE_PRECONDITION2(ok, false, "js_scene_Camera_set_clearColor : Error processing new value"); - return true; -} -SE_BIND_PROP_SET(js_scene_Camera_set_clearColor) - -static bool js_scene_Camera_get_matView(se::State& s) // NOLINT(readability-identifier-naming) -{ - auto* cobj = SE_THIS_OBJECT(s); - SE_PRECONDITION2(cobj, false, "js_scene_Camera_get_matView : Invalid Native Object"); - - CC_UNUSED bool ok = true; - se::Value jsret; - ok &= nativevalue_to_se(cobj->matView, jsret, s.thisObject() /*ctx*/); - s.rval() = jsret; - SE_HOLD_RETURN_VALUE(cobj->matView, s.thisObject(), s.rval()); - return true; -} -SE_BIND_PROP_GET(js_scene_Camera_get_matView) - -static bool js_scene_Camera_set_matView(se::State& s) // NOLINT(readability-identifier-naming) -{ - const auto& args = s.args(); - auto* cobj = SE_THIS_OBJECT(s); - SE_PRECONDITION2(cobj, false, "js_scene_Camera_set_matView : Invalid Native Object"); - - CC_UNUSED bool ok = true; - ok &= sevalue_to_native(args[0], &cobj->matView, s.thisObject()); - SE_PRECONDITION2(ok, false, "js_scene_Camera_set_matView : Error processing new value"); - return true; -} -SE_BIND_PROP_SET(js_scene_Camera_set_matView) - -static bool js_scene_Camera_get_matViewProj(se::State& s) // NOLINT(readability-identifier-naming) -{ - auto* cobj = SE_THIS_OBJECT(s); - SE_PRECONDITION2(cobj, false, "js_scene_Camera_get_matViewProj : Invalid Native Object"); - - CC_UNUSED bool ok = true; - se::Value jsret; - ok &= nativevalue_to_se(cobj->matViewProj, jsret, s.thisObject() /*ctx*/); - s.rval() = jsret; - SE_HOLD_RETURN_VALUE(cobj->matViewProj, s.thisObject(), s.rval()); - return true; -} -SE_BIND_PROP_GET(js_scene_Camera_get_matViewProj) - -static bool js_scene_Camera_set_matViewProj(se::State& s) // NOLINT(readability-identifier-naming) -{ - const auto& args = s.args(); - auto* cobj = SE_THIS_OBJECT(s); - SE_PRECONDITION2(cobj, false, "js_scene_Camera_set_matViewProj : Invalid Native Object"); - - CC_UNUSED bool ok = true; - ok &= sevalue_to_native(args[0], &cobj->matViewProj, s.thisObject()); - SE_PRECONDITION2(ok, false, "js_scene_Camera_set_matViewProj : Error processing new value"); - return true; -} -SE_BIND_PROP_SET(js_scene_Camera_set_matViewProj) - -static bool js_scene_Camera_get_matViewProjInv(se::State& s) // NOLINT(readability-identifier-naming) -{ - auto* cobj = SE_THIS_OBJECT(s); - SE_PRECONDITION2(cobj, false, "js_scene_Camera_get_matViewProjInv : Invalid Native Object"); - - CC_UNUSED bool ok = true; - se::Value jsret; - ok &= nativevalue_to_se(cobj->matViewProjInv, jsret, s.thisObject() /*ctx*/); - s.rval() = jsret; - SE_HOLD_RETURN_VALUE(cobj->matViewProjInv, s.thisObject(), s.rval()); - return true; -} -SE_BIND_PROP_GET(js_scene_Camera_get_matViewProjInv) - -static bool js_scene_Camera_set_matViewProjInv(se::State& s) // NOLINT(readability-identifier-naming) -{ - const auto& args = s.args(); - auto* cobj = SE_THIS_OBJECT(s); - SE_PRECONDITION2(cobj, false, "js_scene_Camera_set_matViewProjInv : Invalid Native Object"); - - CC_UNUSED bool ok = true; - ok &= sevalue_to_native(args[0], &cobj->matViewProjInv, s.thisObject()); - SE_PRECONDITION2(ok, false, "js_scene_Camera_set_matViewProjInv : Error processing new value"); - return true; -} -SE_BIND_PROP_SET(js_scene_Camera_set_matViewProjInv) - -static bool js_scene_Camera_get_matProj(se::State& s) // NOLINT(readability-identifier-naming) -{ - auto* cobj = SE_THIS_OBJECT(s); - SE_PRECONDITION2(cobj, false, "js_scene_Camera_get_matProj : Invalid Native Object"); - - CC_UNUSED bool ok = true; - se::Value jsret; - ok &= nativevalue_to_se(cobj->matProj, jsret, s.thisObject() /*ctx*/); - s.rval() = jsret; - SE_HOLD_RETURN_VALUE(cobj->matProj, s.thisObject(), s.rval()); - return true; -} -SE_BIND_PROP_GET(js_scene_Camera_get_matProj) - -static bool js_scene_Camera_set_matProj(se::State& s) // NOLINT(readability-identifier-naming) -{ - const auto& args = s.args(); - auto* cobj = SE_THIS_OBJECT(s); - SE_PRECONDITION2(cobj, false, "js_scene_Camera_set_matProj : Invalid Native Object"); - - CC_UNUSED bool ok = true; - ok &= sevalue_to_native(args[0], &cobj->matProj, s.thisObject()); - SE_PRECONDITION2(ok, false, "js_scene_Camera_set_matProj : Error processing new value"); - return true; -} -SE_BIND_PROP_SET(js_scene_Camera_set_matProj) - -static bool js_scene_Camera_get_matProjInv(se::State& s) // NOLINT(readability-identifier-naming) -{ - auto* cobj = SE_THIS_OBJECT(s); - SE_PRECONDITION2(cobj, false, "js_scene_Camera_get_matProjInv : Invalid Native Object"); - - CC_UNUSED bool ok = true; - se::Value jsret; - ok &= nativevalue_to_se(cobj->matProjInv, jsret, s.thisObject() /*ctx*/); - s.rval() = jsret; - SE_HOLD_RETURN_VALUE(cobj->matProjInv, s.thisObject(), s.rval()); - return true; -} -SE_BIND_PROP_GET(js_scene_Camera_get_matProjInv) - -static bool js_scene_Camera_set_matProjInv(se::State& s) // NOLINT(readability-identifier-naming) -{ - const auto& args = s.args(); - auto* cobj = SE_THIS_OBJECT(s); - SE_PRECONDITION2(cobj, false, "js_scene_Camera_set_matProjInv : Invalid Native Object"); - - CC_UNUSED bool ok = true; - ok &= sevalue_to_native(args[0], &cobj->matProjInv, s.thisObject()); - SE_PRECONDITION2(ok, false, "js_scene_Camera_set_matProjInv : Error processing new value"); - return true; -} -SE_BIND_PROP_SET(js_scene_Camera_set_matProjInv) - -static bool js_scene_Camera_get_matViewProjOffscreen(se::State& s) // NOLINT(readability-identifier-naming) -{ - auto* cobj = SE_THIS_OBJECT(s); - SE_PRECONDITION2(cobj, false, "js_scene_Camera_get_matViewProjOffscreen : Invalid Native Object"); - - CC_UNUSED bool ok = true; - se::Value jsret; - ok &= nativevalue_to_se(cobj->matViewProjOffscreen, jsret, s.thisObject() /*ctx*/); - s.rval() = jsret; - SE_HOLD_RETURN_VALUE(cobj->matViewProjOffscreen, s.thisObject(), s.rval()); - return true; -} -SE_BIND_PROP_GET(js_scene_Camera_get_matViewProjOffscreen) - -static bool js_scene_Camera_set_matViewProjOffscreen(se::State& s) // NOLINT(readability-identifier-naming) -{ - const auto& args = s.args(); - auto* cobj = SE_THIS_OBJECT(s); - SE_PRECONDITION2(cobj, false, "js_scene_Camera_set_matViewProjOffscreen : Invalid Native Object"); - - CC_UNUSED bool ok = true; - ok &= sevalue_to_native(args[0], &cobj->matViewProjOffscreen, s.thisObject()); - SE_PRECONDITION2(ok, false, "js_scene_Camera_set_matViewProjOffscreen : Error processing new value"); - return true; -} -SE_BIND_PROP_SET(js_scene_Camera_set_matViewProjOffscreen) - -static bool js_scene_Camera_get_matViewProjInvOffscreen(se::State& s) // NOLINT(readability-identifier-naming) -{ - auto* cobj = SE_THIS_OBJECT(s); - SE_PRECONDITION2(cobj, false, "js_scene_Camera_get_matViewProjInvOffscreen : Invalid Native Object"); - - CC_UNUSED bool ok = true; - se::Value jsret; - ok &= nativevalue_to_se(cobj->matViewProjInvOffscreen, jsret, s.thisObject() /*ctx*/); - s.rval() = jsret; - SE_HOLD_RETURN_VALUE(cobj->matViewProjInvOffscreen, s.thisObject(), s.rval()); - return true; -} -SE_BIND_PROP_GET(js_scene_Camera_get_matViewProjInvOffscreen) - -static bool js_scene_Camera_set_matViewProjInvOffscreen(se::State& s) // NOLINT(readability-identifier-naming) -{ - const auto& args = s.args(); - auto* cobj = SE_THIS_OBJECT(s); - SE_PRECONDITION2(cobj, false, "js_scene_Camera_set_matViewProjInvOffscreen : Invalid Native Object"); - - CC_UNUSED bool ok = true; - ok &= sevalue_to_native(args[0], &cobj->matViewProjInvOffscreen, s.thisObject()); - SE_PRECONDITION2(ok, false, "js_scene_Camera_set_matViewProjInvOffscreen : Error processing new value"); - return true; -} -SE_BIND_PROP_SET(js_scene_Camera_set_matViewProjInvOffscreen) - -static bool js_scene_Camera_get_matProjOffscreen(se::State& s) // NOLINT(readability-identifier-naming) -{ - auto* cobj = SE_THIS_OBJECT(s); - SE_PRECONDITION2(cobj, false, "js_scene_Camera_get_matProjOffscreen : Invalid Native Object"); - - CC_UNUSED bool ok = true; - se::Value jsret; - ok &= nativevalue_to_se(cobj->matProjOffscreen, jsret, s.thisObject() /*ctx*/); - s.rval() = jsret; - SE_HOLD_RETURN_VALUE(cobj->matProjOffscreen, s.thisObject(), s.rval()); - return true; -} -SE_BIND_PROP_GET(js_scene_Camera_get_matProjOffscreen) - -static bool js_scene_Camera_set_matProjOffscreen(se::State& s) // NOLINT(readability-identifier-naming) -{ - const auto& args = s.args(); - auto* cobj = SE_THIS_OBJECT(s); - SE_PRECONDITION2(cobj, false, "js_scene_Camera_set_matProjOffscreen : Invalid Native Object"); - - CC_UNUSED bool ok = true; - ok &= sevalue_to_native(args[0], &cobj->matProjOffscreen, s.thisObject()); - SE_PRECONDITION2(ok, false, "js_scene_Camera_set_matProjOffscreen : Error processing new value"); - return true; -} -SE_BIND_PROP_SET(js_scene_Camera_set_matProjOffscreen) - -static bool js_scene_Camera_get_matProjInvOffscreen(se::State& s) // NOLINT(readability-identifier-naming) -{ - auto* cobj = SE_THIS_OBJECT(s); - SE_PRECONDITION2(cobj, false, "js_scene_Camera_get_matProjInvOffscreen : Invalid Native Object"); - - CC_UNUSED bool ok = true; - se::Value jsret; - ok &= nativevalue_to_se(cobj->matProjInvOffscreen, jsret, s.thisObject() /*ctx*/); - s.rval() = jsret; - SE_HOLD_RETURN_VALUE(cobj->matProjInvOffscreen, s.thisObject(), s.rval()); - return true; -} -SE_BIND_PROP_GET(js_scene_Camera_get_matProjInvOffscreen) - -static bool js_scene_Camera_set_matProjInvOffscreen(se::State& s) // NOLINT(readability-identifier-naming) -{ - const auto& args = s.args(); - auto* cobj = SE_THIS_OBJECT(s); - SE_PRECONDITION2(cobj, false, "js_scene_Camera_set_matProjInvOffscreen : Invalid Native Object"); - - CC_UNUSED bool ok = true; - ok &= sevalue_to_native(args[0], &cobj->matProjInvOffscreen, s.thisObject()); - SE_PRECONDITION2(ok, false, "js_scene_Camera_set_matProjInvOffscreen : Error processing new value"); - return true; -} -SE_BIND_PROP_SET(js_scene_Camera_set_matProjInvOffscreen) +SE_BIND_PROP_SET(js_scene_IMaterialInstanceInfo_set_subModelIdx) template<> -bool sevalue_to_native(const se::Value &from, cc::scene::Camera * to, se::Object *ctx) +bool sevalue_to_native(const se::Value &from, cc::IMaterialInstanceInfo * to, se::Object *ctx) { assert(from.isObject()); se::Object *json = from.toObject(); - auto* data = reinterpret_cast(json->getPrivateData()); + auto* data = reinterpret_cast(json->getPrivateData()); if (data) { *to = *data; return true; } se::Value field; bool ok = true; - json->getProperty("width", &field); + json->getProperty("parent", &field, true); if(!field.isNullOrUndefined()) { - ok &= sevalue_to_native(field, &(to->width), ctx); + ok &= sevalue_to_native(field, &(to->parent), ctx); } - json->getProperty("height", &field); + json->getProperty("subModelIdx", &field, true); if(!field.isNullOrUndefined()) { - ok &= sevalue_to_native(field, &(to->height), ctx); - } - json->getProperty("nearClip", &field); - if(!field.isNullOrUndefined()) { - ok &= sevalue_to_native(field, &(to->nearClip), ctx); - } - json->getProperty("farClip", &field); - if(!field.isNullOrUndefined()) { - ok &= sevalue_to_native(field, &(to->farClip), ctx); - } - json->getProperty("clearFlag", &field); - if(!field.isNullOrUndefined()) { - ok &= sevalue_to_native(field, &(to->clearFlag), ctx); - } - json->getProperty("exposure", &field); - if(!field.isNullOrUndefined()) { - ok &= sevalue_to_native(field, &(to->exposure), ctx); - } - json->getProperty("clearDepth", &field); - if(!field.isNullOrUndefined()) { - ok &= sevalue_to_native(field, &(to->clearDepth), ctx); - } - json->getProperty("fov", &field); - if(!field.isNullOrUndefined()) { - ok &= sevalue_to_native(field, &(to->fov), ctx); - } - json->getProperty("aspect", &field); - if(!field.isNullOrUndefined()) { - ok &= sevalue_to_native(field, &(to->aspect), ctx); - } - json->getProperty("viewPort", &field); - if(!field.isNullOrUndefined()) { - ok &= sevalue_to_native(field, &(to->viewPort), ctx); - } - json->getProperty("clearStencil", &field); - if(!field.isNullOrUndefined()) { - ok &= sevalue_to_native(field, &(to->clearStencil), ctx); - } - json->getProperty("visibility", &field); - if(!field.isNullOrUndefined()) { - ok &= sevalue_to_native(field, &(to->visibility), ctx); - } - json->getProperty("node", &field); - if(!field.isNullOrUndefined()) { - ok &= sevalue_to_native(field, &(to->node), ctx); - } - json->getProperty("scene", &field); - if(!field.isNullOrUndefined()) { - ok &= sevalue_to_native(field, &(to->scene), ctx); - } - json->getProperty("window", &field); - if(!field.isNullOrUndefined()) { - ok &= sevalue_to_native(field, &(to->window), ctx); - } - json->getProperty("frustum", &field); - if(!field.isNullOrUndefined()) { - ok &= sevalue_to_native(field, &(to->frustum), ctx); - } - json->getProperty("forward", &field); - if(!field.isNullOrUndefined()) { - ok &= sevalue_to_native(field, &(to->forward), ctx); - } - json->getProperty("position", &field); - if(!field.isNullOrUndefined()) { - ok &= sevalue_to_native(field, &(to->position), ctx); - } - json->getProperty("clearColor", &field); - if(!field.isNullOrUndefined()) { - ok &= sevalue_to_native(field, &(to->clearColor), ctx); - } - json->getProperty("matView", &field); - if(!field.isNullOrUndefined()) { - ok &= sevalue_to_native(field, &(to->matView), ctx); - } - json->getProperty("matViewProj", &field); - if(!field.isNullOrUndefined()) { - ok &= sevalue_to_native(field, &(to->matViewProj), ctx); - } - json->getProperty("matViewProjInv", &field); - if(!field.isNullOrUndefined()) { - ok &= sevalue_to_native(field, &(to->matViewProjInv), ctx); - } - json->getProperty("matProj", &field); - if(!field.isNullOrUndefined()) { - ok &= sevalue_to_native(field, &(to->matProj), ctx); - } - json->getProperty("matProjInv", &field); - if(!field.isNullOrUndefined()) { - ok &= sevalue_to_native(field, &(to->matProjInv), ctx); - } - json->getProperty("matViewProjOffscreen", &field); - if(!field.isNullOrUndefined()) { - ok &= sevalue_to_native(field, &(to->matViewProjOffscreen), ctx); - } - json->getProperty("matViewProjInvOffscreen", &field); - if(!field.isNullOrUndefined()) { - ok &= sevalue_to_native(field, &(to->matViewProjInvOffscreen), ctx); - } - json->getProperty("matProjOffscreen", &field); - if(!field.isNullOrUndefined()) { - ok &= sevalue_to_native(field, &(to->matProjOffscreen), ctx); - } - json->getProperty("matProjInvOffscreen", &field); - if(!field.isNullOrUndefined()) { - ok &= sevalue_to_native(field, &(to->matProjInvOffscreen), ctx); + ok &= sevalue_to_native(field, &(to->subModelIdx), ctx); } return ok; } -SE_DECLARE_FINALIZE_FUNC(js_cc_scene_Camera_finalize) +SE_DECLARE_FINALIZE_FUNC(js_cc_IMaterialInstanceInfo_finalize) -static bool js_scene_Camera_constructor(se::State& s) // NOLINT(readability-identifier-naming) +static bool js_scene_IMaterialInstanceInfo_constructor(se::State& s) // NOLINT(readability-identifier-naming) { CC_UNUSED bool ok = true; const auto& args = s.args(); @@ -8847,9 +16904,8 @@ static bool js_scene_Camera_constructor(se::State& s) // NOLINT(readability-iden if(argc == 0) { - cc::scene::Camera* cobj = JSB_ALLOC(cc::scene::Camera); - s.thisObject()->setPrivateData(cobj); - se::NonRefNativePtrCreatedByCtorMap::emplace(cobj); + auto *ptr = JSB_MAKE_PRIVATE_OBJECT(cc::IMaterialInstanceInfo); + s.thisObject()->setPrivateObject(ptr); return true; } @@ -8857,341 +16913,1837 @@ static bool js_scene_Camera_constructor(se::State& s) // NOLINT(readability-iden { se::Object *json = args[0].toObject(); se::Value field; - - cc::scene::Camera* cobj = JSB_ALLOC(cc::scene::Camera); + auto *ptr = JSB_MAKE_PRIVATE_OBJECT(cc::IMaterialInstanceInfo); + auto cobj = ptr->get(); ok &= sevalue_to_native(args[0], cobj, s.thisObject()); if(!ok) { - JSB_FREE(cobj); + delete ptr; SE_REPORT_ERROR("argument convertion error"); return false; } - - s.thisObject()->setPrivateData(cobj); - se::NonRefNativePtrCreatedByCtorMap::emplace(cobj); + s.thisObject()->setPrivateObject(ptr); return true; } - - cc::scene::Camera* cobj = JSB_ALLOC(cc::scene::Camera); + auto *ptr = JSB_MAKE_PRIVATE_OBJECT(cc::IMaterialInstanceInfo); + auto cobj = ptr->get(); if (argc > 0 && !args[0].isUndefined()) { - ok &= sevalue_to_native(args[0], &(cobj->width), nullptr); + ok &= sevalue_to_native(args[0], &(cobj->parent), nullptr); } if (argc > 1 && !args[1].isUndefined()) { - ok &= sevalue_to_native(args[1], &(cobj->height), nullptr); - } - if (argc > 2 && !args[2].isUndefined()) { - ok &= sevalue_to_native(args[2], &(cobj->nearClip), nullptr); - } - if (argc > 3 && !args[3].isUndefined()) { - ok &= sevalue_to_native(args[3], &(cobj->farClip), nullptr); - } - if (argc > 4 && !args[4].isUndefined()) { - ok &= sevalue_to_native(args[4], &(cobj->clearFlag), nullptr); - } - if (argc > 5 && !args[5].isUndefined()) { - ok &= sevalue_to_native(args[5], &(cobj->exposure), nullptr); - } - if (argc > 6 && !args[6].isUndefined()) { - ok &= sevalue_to_native(args[6], &(cobj->clearDepth), nullptr); - } - if (argc > 7 && !args[7].isUndefined()) { - ok &= sevalue_to_native(args[7], &(cobj->fov), nullptr); - } - if (argc > 8 && !args[8].isUndefined()) { - ok &= sevalue_to_native(args[8], &(cobj->aspect), nullptr); - } - if (argc > 9 && !args[9].isUndefined()) { - ok &= sevalue_to_native(args[9], &(cobj->viewPort), nullptr); - } - if (argc > 10 && !args[10].isUndefined()) { - ok &= sevalue_to_native(args[10], &(cobj->clearStencil), nullptr); - } - if (argc > 11 && !args[11].isUndefined()) { - ok &= sevalue_to_native(args[11], &(cobj->visibility), nullptr); - } - if (argc > 12 && !args[12].isUndefined()) { - ok &= sevalue_to_native(args[12], &(cobj->node), nullptr); - } - if (argc > 13 && !args[13].isUndefined()) { - ok &= sevalue_to_native(args[13], &(cobj->scene), nullptr); - } - if (argc > 14 && !args[14].isUndefined()) { - ok &= sevalue_to_native(args[14], &(cobj->window), nullptr); - } - if (argc > 15 && !args[15].isUndefined()) { - ok &= sevalue_to_native(args[15], &(cobj->frustum), nullptr); - } - if (argc > 16 && !args[16].isUndefined()) { - ok &= sevalue_to_native(args[16], &(cobj->forward), nullptr); - } - if (argc > 17 && !args[17].isUndefined()) { - ok &= sevalue_to_native(args[17], &(cobj->position), nullptr); - } - if (argc > 18 && !args[18].isUndefined()) { - ok &= sevalue_to_native(args[18], &(cobj->clearColor), nullptr); - } - if (argc > 19 && !args[19].isUndefined()) { - ok &= sevalue_to_native(args[19], &(cobj->matView), nullptr); - } - if (argc > 20 && !args[20].isUndefined()) { - ok &= sevalue_to_native(args[20], &(cobj->matViewProj), nullptr); - } - if (argc > 21 && !args[21].isUndefined()) { - ok &= sevalue_to_native(args[21], &(cobj->matViewProjInv), nullptr); - } - if (argc > 22 && !args[22].isUndefined()) { - ok &= sevalue_to_native(args[22], &(cobj->matProj), nullptr); - } - if (argc > 23 && !args[23].isUndefined()) { - ok &= sevalue_to_native(args[23], &(cobj->matProjInv), nullptr); - } - if (argc > 24 && !args[24].isUndefined()) { - ok &= sevalue_to_native(args[24], &(cobj->matViewProjOffscreen), nullptr); - } - if (argc > 25 && !args[25].isUndefined()) { - ok &= sevalue_to_native(args[25], &(cobj->matViewProjInvOffscreen), nullptr); - } - if (argc > 26 && !args[26].isUndefined()) { - ok &= sevalue_to_native(args[26], &(cobj->matProjOffscreen), nullptr); - } - if (argc > 27 && !args[27].isUndefined()) { - ok &= sevalue_to_native(args[27], &(cobj->matProjInvOffscreen), nullptr); + ok &= sevalue_to_native(args[1], &(cobj->subModelIdx), nullptr); } if(!ok) { - JSB_FREE(cobj); + delete ptr; SE_REPORT_ERROR("Argument convertion error"); return false; } - - s.thisObject()->setPrivateData(cobj); - se::NonRefNativePtrCreatedByCtorMap::emplace(cobj); + s.thisObject()->setPrivateObject(ptr); return true; } -SE_BIND_CTOR(js_scene_Camera_constructor, __jsb_cc_scene_Camera_class, js_cc_scene_Camera_finalize) +SE_BIND_CTOR(js_scene_IMaterialInstanceInfo_constructor, __jsb_cc_IMaterialInstanceInfo_class, js_cc_IMaterialInstanceInfo_finalize) - - -static bool js_cc_scene_Camera_finalize(se::State& s) // NOLINT(readability-identifier-naming) +static bool js_cc_IMaterialInstanceInfo_finalize(se::State& s) // NOLINT(readability-identifier-naming) { - auto iter = se::NonRefNativePtrCreatedByCtorMap::find(SE_THIS_OBJECT(s)); - if (iter != se::NonRefNativePtrCreatedByCtorMap::end()) - { - se::NonRefNativePtrCreatedByCtorMap::erase(iter); - auto* cobj = SE_THIS_OBJECT(s); - JSB_FREE(cobj); - } return true; } -SE_BIND_FINALIZE_FUNC(js_cc_scene_Camera_finalize) +SE_BIND_FINALIZE_FUNC(js_cc_IMaterialInstanceInfo_finalize) -bool js_register_scene_Camera(se::Object* obj) // NOLINT(readability-identifier-naming) +bool js_register_scene_IMaterialInstanceInfo(se::Object* obj) // NOLINT(readability-identifier-naming) { - auto* cls = se::Class::create("Camera", obj, nullptr, _SE(js_scene_Camera_constructor)); + auto* cls = se::Class::create("IMaterialInstanceInfo", obj, nullptr, _SE(js_scene_IMaterialInstanceInfo_constructor)); - cls->defineProperty("width", _SE(js_scene_Camera_get_width), _SE(js_scene_Camera_set_width)); - cls->defineProperty("height", _SE(js_scene_Camera_get_height), _SE(js_scene_Camera_set_height)); - cls->defineProperty("nearClip", _SE(js_scene_Camera_get_nearClip), _SE(js_scene_Camera_set_nearClip)); - cls->defineProperty("farClip", _SE(js_scene_Camera_get_farClip), _SE(js_scene_Camera_set_farClip)); - cls->defineProperty("clearFlag", _SE(js_scene_Camera_get_clearFlag), _SE(js_scene_Camera_set_clearFlag)); - cls->defineProperty("exposure", _SE(js_scene_Camera_get_exposure), _SE(js_scene_Camera_set_exposure)); - cls->defineProperty("clearDepth", _SE(js_scene_Camera_get_clearDepth), _SE(js_scene_Camera_set_clearDepth)); - cls->defineProperty("fov", _SE(js_scene_Camera_get_fov), _SE(js_scene_Camera_set_fov)); - cls->defineProperty("aspect", _SE(js_scene_Camera_get_aspect), _SE(js_scene_Camera_set_aspect)); - cls->defineProperty("viewPort", _SE(js_scene_Camera_get_viewPort), _SE(js_scene_Camera_set_viewPort)); - cls->defineProperty("clearStencil", _SE(js_scene_Camera_get_clearStencil), _SE(js_scene_Camera_set_clearStencil)); - cls->defineProperty("visibility", _SE(js_scene_Camera_get_visibility), _SE(js_scene_Camera_set_visibility)); - cls->defineProperty("node", _SE(js_scene_Camera_get_node), _SE(js_scene_Camera_set_node)); - cls->defineProperty("scene", _SE(js_scene_Camera_get_scene), _SE(js_scene_Camera_set_scene)); - cls->defineProperty("window", _SE(js_scene_Camera_get_window), _SE(js_scene_Camera_set_window)); - cls->defineProperty("frustum", _SE(js_scene_Camera_get_frustum), _SE(js_scene_Camera_set_frustum)); - cls->defineProperty("forward", _SE(js_scene_Camera_get_forward), _SE(js_scene_Camera_set_forward)); - cls->defineProperty("position", _SE(js_scene_Camera_get_position), _SE(js_scene_Camera_set_position)); - cls->defineProperty("clearColor", _SE(js_scene_Camera_get_clearColor), _SE(js_scene_Camera_set_clearColor)); - cls->defineProperty("matView", _SE(js_scene_Camera_get_matView), _SE(js_scene_Camera_set_matView)); - cls->defineProperty("matViewProj", _SE(js_scene_Camera_get_matViewProj), _SE(js_scene_Camera_set_matViewProj)); - cls->defineProperty("matViewProjInv", _SE(js_scene_Camera_get_matViewProjInv), _SE(js_scene_Camera_set_matViewProjInv)); - cls->defineProperty("matProj", _SE(js_scene_Camera_get_matProj), _SE(js_scene_Camera_set_matProj)); - cls->defineProperty("matProjInv", _SE(js_scene_Camera_get_matProjInv), _SE(js_scene_Camera_set_matProjInv)); - cls->defineProperty("matViewProjOffscreen", _SE(js_scene_Camera_get_matViewProjOffscreen), _SE(js_scene_Camera_set_matViewProjOffscreen)); - cls->defineProperty("matViewProjInvOffscreen", _SE(js_scene_Camera_get_matViewProjInvOffscreen), _SE(js_scene_Camera_set_matViewProjInvOffscreen)); - cls->defineProperty("matProjOffscreen", _SE(js_scene_Camera_get_matProjOffscreen), _SE(js_scene_Camera_set_matProjOffscreen)); - cls->defineProperty("matProjInvOffscreen", _SE(js_scene_Camera_get_matProjInvOffscreen), _SE(js_scene_Camera_set_matProjInvOffscreen)); - cls->defineFinalizeFunction(_SE(js_cc_scene_Camera_finalize)); + cls->defineProperty("parent", _SE(js_scene_IMaterialInstanceInfo_get_parent), _SE(js_scene_IMaterialInstanceInfo_set_parent)); + cls->defineProperty("subModelIdx", _SE(js_scene_IMaterialInstanceInfo_get_subModelIdx), _SE(js_scene_IMaterialInstanceInfo_set_subModelIdx)); + cls->defineFinalizeFunction(_SE(js_cc_IMaterialInstanceInfo_finalize)); cls->install(); - JSBClassType::registerClass(cls); + JSBClassType::registerClass(cls); + + __jsb_cc_IMaterialInstanceInfo_proto = cls->getProto(); + __jsb_cc_IMaterialInstanceInfo_class = cls; - __jsb_cc_scene_Camera_proto = cls->getProto(); - __jsb_cc_scene_Camera_class = cls; se::ScriptEngine::getInstance()->clearException(); return true; } -se::Object* __jsb_cc_scene_Sphere_proto = nullptr; -se::Class* __jsb_cc_scene_Sphere_class = nullptr; +se::Object* __jsb_cc_MaterialInstance_proto = nullptr; // NOLINT +se::Class* __jsb_cc_MaterialInstance_class = nullptr; // NOLINT -static bool js_scene_Sphere_getCenter(se::State& s) // NOLINT(readability-identifier-naming) +static bool js_scene_MaterialInstance_onPassStateChange(se::State& s) // NOLINT(readability-identifier-naming) { - auto* cobj = SE_THIS_OBJECT(s); - SE_PRECONDITION2(cobj, false, "js_scene_Sphere_getCenter : Invalid Native Object"); + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_scene_MaterialInstance_onPassStateChange : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 1) { + HolderType arg0 = {}; + ok &= sevalue_to_native(args[0], &arg0, s.thisObject()); + SE_PRECONDITION2(ok, false, "js_scene_MaterialInstance_onPassStateChange : Error processing arguments"); + cobj->onPassStateChange(arg0.value()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 1); + return false; +} +SE_BIND_FUNC(js_scene_MaterialInstance_onPassStateChange) + +static bool js_scene_MaterialInstance_setRebuildPSOCallback(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_scene_MaterialInstance_setRebuildPSOCallback : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 1) { + HolderType, true> arg0 = {}; + do { + if (args[0].isObject() && args[0].toObject()->isFunction()) + { + se::Value jsThis(s.thisObject()); + se::Value jsFunc(args[0]); + jsThis.toObject()->attachObject(jsFunc.toObject()); + auto * thisObj = s.thisObject(); + auto lambda = [=](int larg0, cc::Material* larg1) -> void { + se::ScriptEngine::getInstance()->clearException(); + se::AutoHandleScope hs; + + CC_UNUSED bool ok = true; + se::ValueArray args; + args.resize(2); + ok &= nativevalue_to_se(larg0, args[0], nullptr /*ctx*/); + ok &= nativevalue_to_se(larg1, args[1], nullptr /*ctx*/); + se::Value rval; + se::Object* funcObj = jsFunc.toObject(); + bool succeed = funcObj->call(args, thisObj, &rval); + if (!succeed) { + se::ScriptEngine::getInstance()->clearException(); + } + }; + arg0.data = lambda; + } + else + { + arg0.data = nullptr; + } + } while(false) + ; + SE_PRECONDITION2(ok, false, "js_scene_MaterialInstance_setRebuildPSOCallback : Error processing arguments"); + cobj->setRebuildPSOCallback(arg0.value()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 1); + return false; +} +SE_BIND_FUNC(js_scene_MaterialInstance_setRebuildPSOCallback) + +SE_DECLARE_FINALIZE_FUNC(js_cc_MaterialInstance_finalize) + +static bool js_scene_MaterialInstance_constructor(se::State& s) // NOLINT(readability-identifier-naming) constructor.c +{ + CC_UNUSED bool ok = true; + const auto& args = s.args(); + cc::IMaterialInstanceInfo arg0; + ok &= sevalue_to_native(args[0], &arg0, s.thisObject()); + SE_PRECONDITION2(ok, false, "js_scene_MaterialInstance_constructor : Error processing arguments"); + auto *ptr = JSB_MAKE_PRIVATE_OBJECT(cc::MaterialInstance, arg0); + s.thisObject()->setPrivateObject(ptr); + return true; +} +SE_BIND_CTOR(js_scene_MaterialInstance_constructor, __jsb_cc_MaterialInstance_class, js_cc_MaterialInstance_finalize) + +static bool js_cc_MaterialInstance_finalize(se::State& s) // NOLINT(readability-identifier-naming) +{ + return true; +} +SE_BIND_FINALIZE_FUNC(js_cc_MaterialInstance_finalize) + +bool js_register_scene_MaterialInstance(se::Object* obj) // NOLINT(readability-identifier-naming) +{ + auto* cls = se::Class::create("MaterialInstance", obj, __jsb_cc_Material_proto, _SE(js_scene_MaterialInstance_constructor)); + + cls->defineFunction("onPassStateChange", _SE(js_scene_MaterialInstance_onPassStateChange)); + cls->defineFunction("setRebuildPSOCallback", _SE(js_scene_MaterialInstance_setRebuildPSOCallback)); + cls->defineFinalizeFunction(_SE(js_cc_MaterialInstance_finalize)); + cls->install(); + JSBClassType::registerClass(cls); + + __jsb_cc_MaterialInstance_proto = cls->getProto(); + __jsb_cc_MaterialInstance_class = cls; + + + se::ScriptEngine::getInstance()->clearException(); + return true; +} +se::Object* __jsb_cc_PassInstance_proto = nullptr; // NOLINT +se::Class* __jsb_cc_PassInstance_class = nullptr; // NOLINT + +static bool js_scene_PassInstance_getParent(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_scene_PassInstance_getParent : Invalid Native Object"); const auto& args = s.args(); size_t argc = args.size(); CC_UNUSED bool ok = true; if (argc == 0) { - const cc::Vec3& result = cobj->getCenter(); + cc::scene::Pass* result = cobj->getParent(); ok &= nativevalue_to_se(result, s.rval(), nullptr /*ctx*/); - SE_PRECONDITION2(ok, false, "js_scene_Sphere_getCenter : Error processing arguments"); + SE_PRECONDITION2(ok, false, "js_scene_PassInstance_getParent : Error processing arguments"); SE_HOLD_RETURN_VALUE(result, s.thisObject(), s.rval()); return true; } SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 0); return false; } -SE_BIND_FUNC(js_scene_Sphere_getCenter) +SE_BIND_FUNC_AS_PROP_GET(js_scene_PassInstance_getParent) -static bool js_scene_Sphere_getRadius(se::State& s) // NOLINT(readability-identifier-naming) +SE_DECLARE_FINALIZE_FUNC(js_cc_PassInstance_finalize) + +static bool js_scene_PassInstance_constructor(se::State& s) // NOLINT(readability-identifier-naming) constructor.c +{ + CC_UNUSED bool ok = true; + const auto& args = s.args(); + cc::scene::Pass* arg0 = nullptr; + cc::MaterialInstance* arg1 = nullptr; + ok &= sevalue_to_native(args[0], &arg0, s.thisObject()); + ok &= sevalue_to_native(args[1], &arg1, s.thisObject()); + SE_PRECONDITION2(ok, false, "js_scene_PassInstance_constructor : Error processing arguments"); + auto *ptr = JSB_MAKE_PRIVATE_OBJECT(cc::PassInstance, arg0, arg1); + s.thisObject()->setPrivateObject(ptr); + return true; +} +SE_BIND_CTOR(js_scene_PassInstance_constructor, __jsb_cc_PassInstance_class, js_cc_PassInstance_finalize) + +static bool js_cc_PassInstance_finalize(se::State& s) // NOLINT(readability-identifier-naming) +{ + return true; +} +SE_BIND_FINALIZE_FUNC(js_cc_PassInstance_finalize) + +bool js_register_scene_PassInstance(se::Object* obj) // NOLINT(readability-identifier-naming) +{ + auto* cls = se::Class::create("PassInstance", obj, __jsb_cc_scene_Pass_proto, _SE(js_scene_PassInstance_constructor)); + + cls->defineProperty("parent", _SE(js_scene_PassInstance_getParent_asGetter), nullptr); + cls->defineFinalizeFunction(_SE(js_cc_PassInstance_finalize)); + cls->install(); + JSBClassType::registerClass(cls); + + __jsb_cc_PassInstance_proto = cls->getProto(); + __jsb_cc_PassInstance_class = cls; + + + se::ScriptEngine::getInstance()->clearException(); + return true; +} +se::Object* __jsb_cc_MorphModel_proto = nullptr; // NOLINT +se::Class* __jsb_cc_MorphModel_class = nullptr; // NOLINT + +static bool js_scene_MorphModel_setMorphRendering(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_scene_MorphModel_setMorphRendering : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 1) { + HolderType arg0 = {}; + ok &= sevalue_to_native(args[0], &arg0, s.thisObject()); + SE_PRECONDITION2(ok, false, "js_scene_MorphModel_setMorphRendering : Error processing arguments"); + cobj->setMorphRendering(arg0.value()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 1); + return false; +} +SE_BIND_FUNC(js_scene_MorphModel_setMorphRendering) + +SE_DECLARE_FINALIZE_FUNC(js_cc_MorphModel_finalize) + +static bool js_scene_MorphModel_constructor(se::State& s) // NOLINT(readability-identifier-naming) constructor.c +{ + auto *ptr = JSB_MAKE_PRIVATE_OBJECT(cc::MorphModel); + s.thisObject()->setPrivateObject(ptr); + return true; +} +SE_BIND_CTOR(js_scene_MorphModel_constructor, __jsb_cc_MorphModel_class, js_cc_MorphModel_finalize) + +static bool js_cc_MorphModel_finalize(se::State& s) // NOLINT(readability-identifier-naming) +{ + return true; +} +SE_BIND_FINALIZE_FUNC(js_cc_MorphModel_finalize) + +bool js_register_scene_MorphModel(se::Object* obj) // NOLINT(readability-identifier-naming) +{ + auto* cls = se::Class::create("MorphModel", obj, __jsb_cc_scene_Model_proto, _SE(js_scene_MorphModel_constructor)); + + cls->defineFunction("setMorphRendering", _SE(js_scene_MorphModel_setMorphRendering)); + cls->defineFinalizeFunction(_SE(js_cc_MorphModel_finalize)); + cls->install(); + JSBClassType::registerClass(cls); + + __jsb_cc_MorphModel_proto = cls->getProto(); + __jsb_cc_MorphModel_class = cls; + + + se::ScriptEngine::getInstance()->clearException(); + return true; +} +se::Object* __jsb_cc_SkinningModel_proto = nullptr; // NOLINT +se::Class* __jsb_cc_SkinningModel_class = nullptr; // NOLINT + +static bool js_scene_SkinningModel_bindSkeleton(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_scene_SkinningModel_bindSkeleton : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 3) { + HolderType arg0 = {}; + HolderType arg1 = {}; + HolderType arg2 = {}; + ok &= sevalue_to_native(args[0], &arg0, s.thisObject()); + ok &= sevalue_to_native(args[1], &arg1, s.thisObject()); + ok &= sevalue_to_native(args[2], &arg2, s.thisObject()); + SE_PRECONDITION2(ok, false, "js_scene_SkinningModel_bindSkeleton : Error processing arguments"); + cobj->bindSkeleton(arg0.value(), arg1.value(), arg2.value()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 3); + return false; +} +SE_BIND_FUNC(js_scene_SkinningModel_bindSkeleton) + +SE_DECLARE_FINALIZE_FUNC(js_cc_SkinningModel_finalize) + +static bool js_scene_SkinningModel_constructor(se::State& s) // NOLINT(readability-identifier-naming) constructor.c +{ + auto *ptr = JSB_MAKE_PRIVATE_OBJECT(cc::SkinningModel); + s.thisObject()->setPrivateObject(ptr); + return true; +} +SE_BIND_CTOR(js_scene_SkinningModel_constructor, __jsb_cc_SkinningModel_class, js_cc_SkinningModel_finalize) + +static bool js_cc_SkinningModel_finalize(se::State& s) // NOLINT(readability-identifier-naming) +{ + return true; +} +SE_BIND_FINALIZE_FUNC(js_cc_SkinningModel_finalize) + +bool js_register_scene_SkinningModel(se::Object* obj) // NOLINT(readability-identifier-naming) +{ + auto* cls = se::Class::create("SkinningModel", obj, __jsb_cc_MorphModel_proto, _SE(js_scene_SkinningModel_constructor)); + + cls->defineFunction("bindSkeleton", _SE(js_scene_SkinningModel_bindSkeleton)); + cls->defineFinalizeFunction(_SE(js_cc_SkinningModel_finalize)); + cls->install(); + JSBClassType::registerClass(cls); + + __jsb_cc_SkinningModel_proto = cls->getProto(); + __jsb_cc_SkinningModel_class = cls; + + + se::ScriptEngine::getInstance()->clearException(); + return true; +} +se::Object* __jsb_cc_BakedSkinningModel_proto = nullptr; // NOLINT +se::Class* __jsb_cc_BakedSkinningModel_class = nullptr; // NOLINT + +static bool js_scene_BakedSkinningModel_bindSkeleton(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_scene_BakedSkinningModel_bindSkeleton : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 3) { + HolderType arg0 = {}; + HolderType arg1 = {}; + HolderType arg2 = {}; + ok &= sevalue_to_native(args[0], &arg0, s.thisObject()); + ok &= sevalue_to_native(args[1], &arg1, s.thisObject()); + ok &= sevalue_to_native(args[2], &arg2, s.thisObject()); + SE_PRECONDITION2(ok, false, "js_scene_BakedSkinningModel_bindSkeleton : Error processing arguments"); + cobj->bindSkeleton(arg0.value(), arg1.value(), arg2.value()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 3); + return false; +} +SE_BIND_FUNC(js_scene_BakedSkinningModel_bindSkeleton) + +static bool js_scene_BakedSkinningModel_setUploadedAnimForJS(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_scene_BakedSkinningModel_setUploadedAnimForJS : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 1) { + HolderType arg0 = {}; + ok &= sevalue_to_native(args[0], &arg0, s.thisObject()); + SE_PRECONDITION2(ok, false, "js_scene_BakedSkinningModel_setUploadedAnimForJS : Error processing arguments"); + cobj->setUploadedAnimForJS(arg0.value()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 1); + return false; +} +SE_BIND_FUNC(js_scene_BakedSkinningModel_setUploadedAnimForJS) + +static bool js_scene_BakedSkinningModel_syncAnimInfoForJS(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_scene_BakedSkinningModel_syncAnimInfoForJS : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 3) { + HolderType arg0 = {}; + HolderType, true> arg1 = {}; + HolderType, true> arg2 = {}; + ok &= sevalue_to_native(args[0], &arg0, s.thisObject()); + ok &= sevalue_to_native(args[1], &arg1, s.thisObject()); + ok &= sevalue_to_native(args[2], &arg2, s.thisObject()); + SE_PRECONDITION2(ok, false, "js_scene_BakedSkinningModel_syncAnimInfoForJS : Error processing arguments"); + cobj->syncAnimInfoForJS(arg0.value(), arg1.value(), arg2.value()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 3); + return false; +} +SE_BIND_FUNC(js_scene_BakedSkinningModel_syncAnimInfoForJS) + +static bool js_scene_BakedSkinningModel_syncDataForJS(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_scene_BakedSkinningModel_syncDataForJS : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 8) { + HolderType>, true> arg0 = {}; + HolderType, true> arg1 = {}; + HolderType arg2 = {}; + HolderType arg3 = {}; + HolderType arg4 = {}; + HolderType arg5 = {}; + HolderType arg6 = {}; + HolderType, true> arg7 = {}; + ok &= sevalue_to_native(args[0], &arg0, s.thisObject()); + ok &= sevalue_to_native(args[1], &arg1, s.thisObject()); + ok &= sevalue_to_native(args[2], &arg2, s.thisObject()); + ok &= sevalue_to_native(args[3], &arg3, s.thisObject()); + ok &= sevalue_to_native(args[4], &arg4, s.thisObject()); + ok &= sevalue_to_native(args[5], &arg5, s.thisObject()); + ok &= sevalue_to_native(args[6], &arg6, s.thisObject()); + ok &= sevalue_to_native(args[7], &arg7, s.thisObject()); + SE_PRECONDITION2(ok, false, "js_scene_BakedSkinningModel_syncDataForJS : Error processing arguments"); + cobj->syncDataForJS(arg0.value(), arg1.value(), arg2.value(), arg3.value(), arg4.value(), arg5.value(), arg6.value(), arg7.value()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 8); + return false; +} +SE_BIND_FUNC(js_scene_BakedSkinningModel_syncDataForJS) + +SE_DECLARE_FINALIZE_FUNC(js_cc_BakedSkinningModel_finalize) + +static bool js_scene_BakedSkinningModel_constructor(se::State& s) // NOLINT(readability-identifier-naming) constructor.c +{ + auto *ptr = JSB_MAKE_PRIVATE_OBJECT(cc::BakedSkinningModel); + s.thisObject()->setPrivateObject(ptr); + return true; +} +SE_BIND_CTOR(js_scene_BakedSkinningModel_constructor, __jsb_cc_BakedSkinningModel_class, js_cc_BakedSkinningModel_finalize) + +static bool js_cc_BakedSkinningModel_finalize(se::State& s) // NOLINT(readability-identifier-naming) +{ + return true; +} +SE_BIND_FINALIZE_FUNC(js_cc_BakedSkinningModel_finalize) + +bool js_register_scene_BakedSkinningModel(se::Object* obj) // NOLINT(readability-identifier-naming) +{ + auto* cls = se::Class::create("BakedSkinningModel", obj, __jsb_cc_MorphModel_proto, _SE(js_scene_BakedSkinningModel_constructor)); + + cls->defineFunction("bindSkeleton", _SE(js_scene_BakedSkinningModel_bindSkeleton)); + cls->defineFunction("setUploadedAnimForJS", _SE(js_scene_BakedSkinningModel_setUploadedAnimForJS)); + cls->defineFunction("syncAnimInfoForJS", _SE(js_scene_BakedSkinningModel_syncAnimInfoForJS)); + cls->defineFunction("syncDataForJS", _SE(js_scene_BakedSkinningModel_syncDataForJS)); + cls->defineFinalizeFunction(_SE(js_cc_BakedSkinningModel_finalize)); + cls->install(); + JSBClassType::registerClass(cls); + + __jsb_cc_BakedSkinningModel_proto = cls->getProto(); + __jsb_cc_BakedSkinningModel_class = cls; + + + se::ScriptEngine::getInstance()->clearException(); + return true; +} +se::Object* __jsb_cc_IDefineRecord_proto = nullptr; // NOLINT +se::Class* __jsb_cc_IDefineRecord_class = nullptr; // NOLINT + +static bool js_scene_IDefineRecord_get_offset(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_scene_IDefineRecord_get_offset : Invalid Native Object"); + + CC_UNUSED bool ok = true; + se::Value jsret; + ok &= nativevalue_to_se(cobj->offset, jsret, s.thisObject() /*ctx*/); + s.rval() = jsret; + SE_HOLD_RETURN_VALUE(cobj->offset, s.thisObject(), s.rval()); + return true; +} +SE_BIND_PROP_GET(js_scene_IDefineRecord_get_offset) + +static bool js_scene_IDefineRecord_set_offset(se::State& s) // NOLINT(readability-identifier-naming) +{ + const auto& args = s.args(); + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_scene_IDefineRecord_set_offset : Invalid Native Object"); + + CC_UNUSED bool ok = true; + ok &= sevalue_to_native(args[0], &cobj->offset, s.thisObject()); + SE_PRECONDITION2(ok, false, "js_scene_IDefineRecord_set_offset : Error processing new value"); + return true; +} +SE_BIND_PROP_SET(js_scene_IDefineRecord_set_offset) + + +template<> +bool sevalue_to_native(const se::Value &from, cc::IDefineRecord * to, se::Object *ctx) +{ + assert(from.isObject()); + se::Object *json = from.toObject(); + auto* data = reinterpret_cast(json->getPrivateData()); + if (data) { + *to = *data; + return true; + } + se::Value field; + bool ok = true; + ok &= sevalue_to_native(from, to, ctx); + json->getProperty("offset", &field, true); + if(!field.isNullOrUndefined()) { + ok &= sevalue_to_native(field, &(to->offset), ctx); + } + return ok; +} + +SE_DECLARE_FINALIZE_FUNC(js_cc_IDefineRecord_finalize) + +static bool js_scene_IDefineRecord_constructor(se::State& s) // NOLINT(readability-identifier-naming) +{ + CC_UNUSED bool ok = true; + const auto& args = s.args(); + size_t argc = args.size(); + + if(argc == 0) + { + auto *ptr = JSB_MAKE_PRIVATE_OBJECT(cc::IDefineRecord); + s.thisObject()->setPrivateObject(ptr); + return true; + } + + if(argc == 1 && args[0].isObject()) + { + se::Object *json = args[0].toObject(); + se::Value field; + auto *ptr = JSB_MAKE_PRIVATE_OBJECT(cc::IDefineRecord); + auto cobj = ptr->get(); + ok &= sevalue_to_native(args[0], cobj, s.thisObject()); + if(!ok) { + delete ptr; + SE_REPORT_ERROR("argument convertion error"); + return false; + } + sevalue_to_native(args[0], cobj, s.thisObject()); // skip ok + s.thisObject()->setPrivateObject(ptr); + return true; + } + auto *ptr = JSB_MAKE_PRIVATE_OBJECT(cc::IDefineRecord); + auto cobj = ptr->get(); + if (argc > 0 && !args[0].isUndefined()) { + ok &= sevalue_to_native(args[0], &(cobj->offset), nullptr); + } + + if(!ok) { + delete ptr; + SE_REPORT_ERROR("Argument convertion error"); + return false; + } + s.thisObject()->setPrivateObject(ptr); + return true; +} +SE_BIND_CTOR(js_scene_IDefineRecord_constructor, __jsb_cc_IDefineRecord_class, js_cc_IDefineRecord_finalize) + +static bool js_cc_IDefineRecord_finalize(se::State& s) // NOLINT(readability-identifier-naming) +{ + return true; +} +SE_BIND_FINALIZE_FUNC(js_cc_IDefineRecord_finalize) + +bool js_register_scene_IDefineRecord(se::Object* obj) // NOLINT(readability-identifier-naming) +{ + auto* cls = se::Class::create("IDefineRecord", obj, __jsb_cc_IDefineInfo_proto, _SE(js_scene_IDefineRecord_constructor)); + + cls->defineProperty("offset", _SE(js_scene_IDefineRecord_get_offset), _SE(js_scene_IDefineRecord_set_offset)); + cls->defineFinalizeFunction(_SE(js_cc_IDefineRecord_finalize)); + cls->install(); + JSBClassType::registerClass(cls); + + __jsb_cc_IDefineRecord_proto = cls->getProto(); + __jsb_cc_IDefineRecord_class = cls; + + + se::ScriptEngine::getInstance()->clearException(); + return true; +} +se::Object* __jsb_cc_IProgramInfo_proto = nullptr; // NOLINT +se::Class* __jsb_cc_IProgramInfo_class = nullptr; // NOLINT + +static bool js_scene_IProgramInfo_copyFrom(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_scene_IProgramInfo_copyFrom : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 1) { + HolderType arg0 = {}; + ok &= sevalue_to_native(args[0], &arg0, s.thisObject()); + SE_PRECONDITION2(ok, false, "js_scene_IProgramInfo_copyFrom : Error processing arguments"); + cobj->copyFrom(arg0.value()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 1); + return false; +} +SE_BIND_FUNC(js_scene_IProgramInfo_copyFrom) + +static bool js_scene_IProgramInfo_get_effectName(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_scene_IProgramInfo_get_effectName : Invalid Native Object"); + + CC_UNUSED bool ok = true; + se::Value jsret; + ok &= nativevalue_to_se(cobj->effectName, jsret, s.thisObject() /*ctx*/); + s.rval() = jsret; + SE_HOLD_RETURN_VALUE(cobj->effectName, s.thisObject(), s.rval()); + return true; +} +SE_BIND_PROP_GET(js_scene_IProgramInfo_get_effectName) + +static bool js_scene_IProgramInfo_set_effectName(se::State& s) // NOLINT(readability-identifier-naming) +{ + const auto& args = s.args(); + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_scene_IProgramInfo_set_effectName : Invalid Native Object"); + + CC_UNUSED bool ok = true; + ok &= sevalue_to_native(args[0], &cobj->effectName, s.thisObject()); + SE_PRECONDITION2(ok, false, "js_scene_IProgramInfo_set_effectName : Error processing new value"); + return true; +} +SE_BIND_PROP_SET(js_scene_IProgramInfo_set_effectName) + +static bool js_scene_IProgramInfo_get_defines(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_scene_IProgramInfo_get_defines : Invalid Native Object"); + + CC_UNUSED bool ok = true; + se::Value jsret; + ok &= nativevalue_to_se(cobj->defines, jsret, s.thisObject() /*ctx*/); + s.rval() = jsret; + SE_HOLD_RETURN_VALUE(cobj->defines, s.thisObject(), s.rval()); + return true; +} +SE_BIND_PROP_GET(js_scene_IProgramInfo_get_defines) + +static bool js_scene_IProgramInfo_set_defines(se::State& s) // NOLINT(readability-identifier-naming) +{ + const auto& args = s.args(); + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_scene_IProgramInfo_set_defines : Invalid Native Object"); + + CC_UNUSED bool ok = true; + ok &= sevalue_to_native(args[0], &cobj->defines, s.thisObject()); + SE_PRECONDITION2(ok, false, "js_scene_IProgramInfo_set_defines : Error processing new value"); + return true; +} +SE_BIND_PROP_SET(js_scene_IProgramInfo_set_defines) + +static bool js_scene_IProgramInfo_get_constantMacros(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_scene_IProgramInfo_get_constantMacros : Invalid Native Object"); + + CC_UNUSED bool ok = true; + se::Value jsret; + ok &= nativevalue_to_se(cobj->constantMacros, jsret, s.thisObject() /*ctx*/); + s.rval() = jsret; + SE_HOLD_RETURN_VALUE(cobj->constantMacros, s.thisObject(), s.rval()); + return true; +} +SE_BIND_PROP_GET(js_scene_IProgramInfo_get_constantMacros) + +static bool js_scene_IProgramInfo_set_constantMacros(se::State& s) // NOLINT(readability-identifier-naming) +{ + const auto& args = s.args(); + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_scene_IProgramInfo_set_constantMacros : Invalid Native Object"); + + CC_UNUSED bool ok = true; + ok &= sevalue_to_native(args[0], &cobj->constantMacros, s.thisObject()); + SE_PRECONDITION2(ok, false, "js_scene_IProgramInfo_set_constantMacros : Error processing new value"); + return true; +} +SE_BIND_PROP_SET(js_scene_IProgramInfo_set_constantMacros) + +static bool js_scene_IProgramInfo_get_uber(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_scene_IProgramInfo_get_uber : Invalid Native Object"); + + CC_UNUSED bool ok = true; + se::Value jsret; + ok &= nativevalue_to_se(cobj->uber, jsret, s.thisObject() /*ctx*/); + s.rval() = jsret; + SE_HOLD_RETURN_VALUE(cobj->uber, s.thisObject(), s.rval()); + return true; +} +SE_BIND_PROP_GET(js_scene_IProgramInfo_get_uber) + +static bool js_scene_IProgramInfo_set_uber(se::State& s) // NOLINT(readability-identifier-naming) +{ + const auto& args = s.args(); + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_scene_IProgramInfo_set_uber : Invalid Native Object"); + + CC_UNUSED bool ok = true; + ok &= sevalue_to_native(args[0], &cobj->uber, s.thisObject()); + SE_PRECONDITION2(ok, false, "js_scene_IProgramInfo_set_uber : Error processing new value"); + return true; +} +SE_BIND_PROP_SET(js_scene_IProgramInfo_set_uber) + + +template<> +bool sevalue_to_native(const se::Value &from, cc::IProgramInfo * to, se::Object *ctx) +{ + assert(from.isObject()); + se::Object *json = from.toObject(); + auto* data = reinterpret_cast(json->getPrivateData()); + if (data) { + *to = *data; + return true; + } + se::Value field; + bool ok = true; + ok &= sevalue_to_native(from, to, ctx); + json->getProperty("effectName", &field, true); + if(!field.isNullOrUndefined()) { + ok &= sevalue_to_native(field, &(to->effectName), ctx); + } + json->getProperty("defines", &field, true); + if(!field.isNullOrUndefined()) { + ok &= sevalue_to_native(field, &(to->defines), ctx); + } + json->getProperty("constantMacros", &field, true); + if(!field.isNullOrUndefined()) { + ok &= sevalue_to_native(field, &(to->constantMacros), ctx); + } + json->getProperty("uber", &field, true); + if(!field.isNullOrUndefined()) { + ok &= sevalue_to_native(field, &(to->uber), ctx); + } + return ok; +} + +SE_DECLARE_FINALIZE_FUNC(js_cc_IProgramInfo_finalize) + +static bool js_scene_IProgramInfo_constructor(se::State& s) // NOLINT(readability-identifier-naming) +{ + CC_UNUSED bool ok = true; + const auto& args = s.args(); + size_t argc = args.size(); + + if(argc == 0) + { + auto *ptr = JSB_MAKE_PRIVATE_OBJECT(cc::IProgramInfo); + s.thisObject()->setPrivateObject(ptr); + return true; + } + + if(argc == 1 && args[0].isObject()) + { + se::Object *json = args[0].toObject(); + se::Value field; + auto *ptr = JSB_MAKE_PRIVATE_OBJECT(cc::IProgramInfo); + auto cobj = ptr->get(); + ok &= sevalue_to_native(args[0], cobj, s.thisObject()); + if(!ok) { + delete ptr; + SE_REPORT_ERROR("argument convertion error"); + return false; + } + sevalue_to_native(args[0], cobj, s.thisObject()); // skip ok + s.thisObject()->setPrivateObject(ptr); + return true; + } + auto *ptr = JSB_MAKE_PRIVATE_OBJECT(cc::IProgramInfo); + auto cobj = ptr->get(); + if (argc > 0 && !args[0].isUndefined()) { + ok &= sevalue_to_native(args[0], &(cobj->effectName), nullptr); + } + if (argc > 1 && !args[1].isUndefined()) { + ok &= sevalue_to_native(args[1], &(cobj->defines), nullptr); + } + if (argc > 2 && !args[2].isUndefined()) { + ok &= sevalue_to_native(args[2], &(cobj->constantMacros), nullptr); + } + if (argc > 3 && !args[3].isUndefined()) { + ok &= sevalue_to_native(args[3], &(cobj->uber), nullptr); + } + + if(!ok) { + delete ptr; + SE_REPORT_ERROR("Argument convertion error"); + return false; + } + s.thisObject()->setPrivateObject(ptr); + return true; +} +SE_BIND_CTOR(js_scene_IProgramInfo_constructor, __jsb_cc_IProgramInfo_class, js_cc_IProgramInfo_finalize) + +static bool js_cc_IProgramInfo_finalize(se::State& s) // NOLINT(readability-identifier-naming) +{ + return true; +} +SE_BIND_FINALIZE_FUNC(js_cc_IProgramInfo_finalize) + +bool js_register_scene_IProgramInfo(se::Object* obj) // NOLINT(readability-identifier-naming) +{ + auto* cls = se::Class::create("IProgramInfo", obj, __jsb_cc_IShaderInfo_proto, _SE(js_scene_IProgramInfo_constructor)); + + cls->defineProperty("effectName", _SE(js_scene_IProgramInfo_get_effectName), _SE(js_scene_IProgramInfo_set_effectName)); + cls->defineProperty("defines", _SE(js_scene_IProgramInfo_get_defines), _SE(js_scene_IProgramInfo_set_defines)); + cls->defineProperty("constantMacros", _SE(js_scene_IProgramInfo_get_constantMacros), _SE(js_scene_IProgramInfo_set_constantMacros)); + cls->defineProperty("uber", _SE(js_scene_IProgramInfo_get_uber), _SE(js_scene_IProgramInfo_set_uber)); + cls->defineFunction("copyFrom", _SE(js_scene_IProgramInfo_copyFrom)); + cls->defineFinalizeFunction(_SE(js_cc_IProgramInfo_finalize)); + cls->install(); + JSBClassType::registerClass(cls); + + __jsb_cc_IProgramInfo_proto = cls->getProto(); + __jsb_cc_IProgramInfo_class = cls; + + + se::ScriptEngine::getInstance()->clearException(); + return true; +} +se::Object* __jsb_cc_ProgramLib_proto = nullptr; // NOLINT +se::Class* __jsb_cc_ProgramLib_class = nullptr; // NOLINT + +static bool js_scene_ProgramLib_define(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_scene_ProgramLib_define : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 1) { + HolderType arg0 = {}; + ok &= sevalue_to_native(args[0], &arg0, s.thisObject()); + SE_PRECONDITION2(ok, false, "js_scene_ProgramLib_define : Error processing arguments"); + cc::IProgramInfo* result = cobj->define(arg0.value()); + ok &= nativevalue_to_se(result, s.rval(), nullptr /*ctx*/); + SE_PRECONDITION2(ok, false, "js_scene_ProgramLib_define : Error processing arguments"); + SE_HOLD_RETURN_VALUE(result, s.thisObject(), s.rval()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 1); + return false; +} +SE_BIND_FUNC(js_scene_ProgramLib_define) + +static bool js_scene_ProgramLib_destroyShaderByDefines(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_scene_ProgramLib_destroyShaderByDefines : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 1) { + HolderType>, true> arg0 = {}; + ok &= sevalue_to_native(args[0], &arg0, s.thisObject()); + SE_PRECONDITION2(ok, false, "js_scene_ProgramLib_destroyShaderByDefines : Error processing arguments"); + cobj->destroyShaderByDefines(arg0.value()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 1); + return false; +} +SE_BIND_FUNC(js_scene_ProgramLib_destroyShaderByDefines) + +static bool js_scene_ProgramLib_getDescriptorSetLayout(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_scene_ProgramLib_getDescriptorSetLayout : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 2) { + HolderType arg0 = {}; + HolderType arg1 = {}; + ok &= sevalue_to_native(args[0], &arg0, s.thisObject()); + ok &= sevalue_to_native(args[1], &arg1, s.thisObject()); + SE_PRECONDITION2(ok, false, "js_scene_ProgramLib_getDescriptorSetLayout : Error processing arguments"); + cc::gfx::DescriptorSetLayout* result = cobj->getDescriptorSetLayout(arg0.value(), arg1.value()); + ok &= nativevalue_to_se(result, s.rval(), nullptr /*ctx*/); + SE_PRECONDITION2(ok, false, "js_scene_ProgramLib_getDescriptorSetLayout : Error processing arguments"); + SE_HOLD_RETURN_VALUE(result, s.thisObject(), s.rval()); + return true; + } + if (argc == 3) { + HolderType arg0 = {}; + HolderType arg1 = {}; + HolderType arg2 = {}; + ok &= sevalue_to_native(args[0], &arg0, s.thisObject()); + ok &= sevalue_to_native(args[1], &arg1, s.thisObject()); + ok &= sevalue_to_native(args[2], &arg2, s.thisObject()); + SE_PRECONDITION2(ok, false, "js_scene_ProgramLib_getDescriptorSetLayout : Error processing arguments"); + cc::gfx::DescriptorSetLayout* result = cobj->getDescriptorSetLayout(arg0.value(), arg1.value(), arg2.value()); + ok &= nativevalue_to_se(result, s.rval(), nullptr /*ctx*/); + SE_PRECONDITION2(ok, false, "js_scene_ProgramLib_getDescriptorSetLayout : Error processing arguments"); + SE_HOLD_RETURN_VALUE(result, s.thisObject(), s.rval()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 3); + return false; +} +SE_BIND_FUNC(js_scene_ProgramLib_getDescriptorSetLayout) + +static bool js_scene_ProgramLib_getGFXShader(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_scene_ProgramLib_getGFXShader : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 4) { + HolderType arg0 = {}; + HolderType arg1 = {}; + HolderType>, true> arg2 = {}; + HolderType arg3 = {}; + ok &= sevalue_to_native(args[0], &arg0, s.thisObject()); + ok &= sevalue_to_native(args[1], &arg1, s.thisObject()); + ok &= sevalue_to_native(args[2], &arg2, s.thisObject()); + ok &= sevalue_to_native(args[3], &arg3, s.thisObject()); + SE_PRECONDITION2(ok, false, "js_scene_ProgramLib_getGFXShader : Error processing arguments"); + cc::gfx::Shader* result = cobj->getGFXShader(arg0.value(), arg1.value(), arg2.value(), arg3.value()); + ok &= nativevalue_to_se(result, s.rval(), nullptr /*ctx*/); + SE_PRECONDITION2(ok, false, "js_scene_ProgramLib_getGFXShader : Error processing arguments"); + SE_HOLD_RETURN_VALUE(result, s.thisObject(), s.rval()); + return true; + } + if (argc == 5) { + HolderType arg0 = {}; + HolderType arg1 = {}; + HolderType>, true> arg2 = {}; + HolderType arg3 = {}; + HolderType arg4 = {}; + ok &= sevalue_to_native(args[0], &arg0, s.thisObject()); + ok &= sevalue_to_native(args[1], &arg1, s.thisObject()); + ok &= sevalue_to_native(args[2], &arg2, s.thisObject()); + ok &= sevalue_to_native(args[3], &arg3, s.thisObject()); + ok &= sevalue_to_native(args[4], &arg4, s.thisObject()); + SE_PRECONDITION2(ok, false, "js_scene_ProgramLib_getGFXShader : Error processing arguments"); + cc::gfx::Shader* result = cobj->getGFXShader(arg0.value(), arg1.value(), arg2.value(), arg3.value(), arg4.value()); + ok &= nativevalue_to_se(result, s.rval(), nullptr /*ctx*/); + SE_PRECONDITION2(ok, false, "js_scene_ProgramLib_getGFXShader : Error processing arguments"); + SE_HOLD_RETURN_VALUE(result, s.thisObject(), s.rval()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 5); + return false; +} +SE_BIND_FUNC(js_scene_ProgramLib_getGFXShader) + +static bool js_scene_ProgramLib_getKey(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_scene_ProgramLib_getKey : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 2) { + HolderType arg0 = {}; + HolderType>, true> arg1 = {}; + ok &= sevalue_to_native(args[0], &arg0, s.thisObject()); + ok &= sevalue_to_native(args[1], &arg1, s.thisObject()); + SE_PRECONDITION2(ok, false, "js_scene_ProgramLib_getKey : Error processing arguments"); + std::string result = cobj->getKey(arg0.value(), arg1.value()); + ok &= nativevalue_to_se(result, s.rval(), nullptr /*ctx*/); + SE_PRECONDITION2(ok, false, "js_scene_ProgramLib_getKey : Error processing arguments"); + SE_HOLD_RETURN_VALUE(result, s.thisObject(), s.rval()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 2); + return false; +} +SE_BIND_FUNC(js_scene_ProgramLib_getKey) + +static bool js_scene_ProgramLib_getTemplate(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_scene_ProgramLib_getTemplate : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 1) { + HolderType arg0 = {}; + ok &= sevalue_to_native(args[0], &arg0, s.thisObject()); + SE_PRECONDITION2(ok, false, "js_scene_ProgramLib_getTemplate : Error processing arguments"); + cc::IProgramInfo* result = cobj->getTemplate(arg0.value()); + ok &= nativevalue_to_se(result, s.rval(), nullptr /*ctx*/); + SE_PRECONDITION2(ok, false, "js_scene_ProgramLib_getTemplate : Error processing arguments"); + SE_HOLD_RETURN_VALUE(result, s.thisObject(), s.rval()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 1); + return false; +} +SE_BIND_FUNC(js_scene_ProgramLib_getTemplate) + +static bool js_scene_ProgramLib_getTemplateInfo(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_scene_ProgramLib_getTemplateInfo : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 1) { + HolderType arg0 = {}; + ok &= sevalue_to_native(args[0], &arg0, s.thisObject()); + SE_PRECONDITION2(ok, false, "js_scene_ProgramLib_getTemplateInfo : Error processing arguments"); + cc::ITemplateInfo* result = cobj->getTemplateInfo(arg0.value()); + ok &= nativevalue_to_se(result, s.rval(), nullptr /*ctx*/); + SE_PRECONDITION2(ok, false, "js_scene_ProgramLib_getTemplateInfo : Error processing arguments"); + SE_HOLD_RETURN_VALUE(result, s.thisObject(), s.rval()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 1); + return false; +} +SE_BIND_FUNC(js_scene_ProgramLib_getTemplateInfo) + +static bool js_scene_ProgramLib_hasProgram(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_scene_ProgramLib_hasProgram : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 1) { + HolderType arg0 = {}; + ok &= sevalue_to_native(args[0], &arg0, s.thisObject()); + SE_PRECONDITION2(ok, false, "js_scene_ProgramLib_hasProgram : Error processing arguments"); + bool result = cobj->hasProgram(arg0.value()); + ok &= nativevalue_to_se(result, s.rval(), nullptr /*ctx*/); + SE_PRECONDITION2(ok, false, "js_scene_ProgramLib_hasProgram : Error processing arguments"); + SE_HOLD_RETURN_VALUE(result, s.thisObject(), s.rval()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 1); + return false; +} +SE_BIND_FUNC(js_scene_ProgramLib_hasProgram) + +static bool js_scene_ProgramLib_registerEffect(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_scene_ProgramLib_registerEffect : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 1) { + HolderType arg0 = {}; + ok &= sevalue_to_native(args[0], &arg0, s.thisObject()); + SE_PRECONDITION2(ok, false, "js_scene_ProgramLib_registerEffect : Error processing arguments"); + cobj->registerEffect(arg0.value()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 1); + return false; +} +SE_BIND_FUNC(js_scene_ProgramLib_registerEffect) + +static bool js_scene_ProgramLib_getInstance_static(se::State& s) // NOLINT(readability-identifier-naming) { - auto* cobj = SE_THIS_OBJECT(s); - SE_PRECONDITION2(cobj, false, "js_scene_Sphere_getRadius : Invalid Native Object"); const auto& args = s.args(); size_t argc = args.size(); CC_UNUSED bool ok = true; if (argc == 0) { - float result = cobj->getRadius(); + cc::ProgramLib* result = cc::ProgramLib::getInstance(); ok &= nativevalue_to_se(result, s.rval(), nullptr /*ctx*/); - SE_PRECONDITION2(ok, false, "js_scene_Sphere_getRadius : Error processing arguments"); + SE_PRECONDITION2(ok, false, "js_scene_ProgramLib_getInstance_static : Error processing arguments"); SE_HOLD_RETURN_VALUE(result, s.thisObject(), s.rval()); return true; } SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 0); return false; } -SE_BIND_FUNC(js_scene_Sphere_getRadius) +SE_BIND_FUNC(js_scene_ProgramLib_getInstance_static) -static bool js_scene_Sphere_setCenter(se::State& s) // NOLINT(readability-identifier-naming) +SE_DECLARE_FINALIZE_FUNC(js_cc_ProgramLib_finalize) + +static bool js_scene_ProgramLib_constructor(se::State& s) // NOLINT(readability-identifier-naming) constructor.c { - auto* cobj = SE_THIS_OBJECT(s); - SE_PRECONDITION2(cobj, false, "js_scene_Sphere_setCenter : Invalid Native Object"); + auto *ptr = JSB_MAKE_PRIVATE_OBJECT(cc::ProgramLib); + s.thisObject()->setPrivateObject(ptr); + return true; +} +SE_BIND_CTOR(js_scene_ProgramLib_constructor, __jsb_cc_ProgramLib_class, js_cc_ProgramLib_finalize) + +static bool js_cc_ProgramLib_finalize(se::State& s) // NOLINT(readability-identifier-naming) +{ + return true; +} +SE_BIND_FINALIZE_FUNC(js_cc_ProgramLib_finalize) + +bool js_register_scene_ProgramLib(se::Object* obj) // NOLINT(readability-identifier-naming) +{ + auto* cls = se::Class::create("ProgramLib", obj, nullptr, _SE(js_scene_ProgramLib_constructor)); + + cls->defineFunction("define", _SE(js_scene_ProgramLib_define)); + cls->defineFunction("destroyShaderByDefines", _SE(js_scene_ProgramLib_destroyShaderByDefines)); + cls->defineFunction("getDescriptorSetLayout", _SE(js_scene_ProgramLib_getDescriptorSetLayout)); + cls->defineFunction("getGFXShader", _SE(js_scene_ProgramLib_getGFXShader)); + cls->defineFunction("getKey", _SE(js_scene_ProgramLib_getKey)); + cls->defineFunction("getTemplate", _SE(js_scene_ProgramLib_getTemplate)); + cls->defineFunction("getTemplateInfo", _SE(js_scene_ProgramLib_getTemplateInfo)); + cls->defineFunction("hasProgram", _SE(js_scene_ProgramLib_hasProgram)); + cls->defineFunction("register", _SE(js_scene_ProgramLib_registerEffect)); + cls->defineStaticFunction("getInstance", _SE(js_scene_ProgramLib_getInstance_static)); + cls->defineFinalizeFunction(_SE(js_cc_ProgramLib_finalize)); + cls->install(); + JSBClassType::registerClass(cls); + + __jsb_cc_ProgramLib_proto = cls->getProto(); + __jsb_cc_ProgramLib_class = cls; + + + se::ScriptEngine::getInstance()->clearException(); + return true; +} +se::Object* __jsb_cc_scene_OctreeInfo_proto = nullptr; // NOLINT +se::Class* __jsb_cc_scene_OctreeInfo_class = nullptr; // NOLINT + +static bool js_scene_OctreeInfo_activate(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_scene_OctreeInfo_activate : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 1) { + HolderType arg0 = {}; + ok &= sevalue_to_native(args[0], &arg0, s.thisObject()); + SE_PRECONDITION2(ok, false, "js_scene_OctreeInfo_activate : Error processing arguments"); + cobj->activate(arg0.value()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 1); + return false; +} +SE_BIND_FUNC(js_scene_OctreeInfo_activate) + +static bool js_scene_OctreeInfo_getDepth(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_scene_OctreeInfo_getDepth : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 0) { + unsigned int result = cobj->getDepth(); + ok &= nativevalue_to_se(result, s.rval(), nullptr /*ctx*/); + SE_PRECONDITION2(ok, false, "js_scene_OctreeInfo_getDepth : Error processing arguments"); + SE_HOLD_RETURN_VALUE(result, s.thisObject(), s.rval()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 0); + return false; +} +SE_BIND_FUNC_AS_PROP_GET(js_scene_OctreeInfo_getDepth) + +static bool js_scene_OctreeInfo_getMaxPos(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_scene_OctreeInfo_getMaxPos : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 0) { + const cc::Vec3& result = cobj->getMaxPos(); + ok &= nativevalue_to_se(result, s.rval(), nullptr /*ctx*/); + SE_PRECONDITION2(ok, false, "js_scene_OctreeInfo_getMaxPos : Error processing arguments"); + SE_HOLD_RETURN_VALUE(result, s.thisObject(), s.rval()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 0); + return false; +} +SE_BIND_FUNC_AS_PROP_GET(js_scene_OctreeInfo_getMaxPos) + +static bool js_scene_OctreeInfo_getMinPos(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_scene_OctreeInfo_getMinPos : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 0) { + const cc::Vec3& result = cobj->getMinPos(); + ok &= nativevalue_to_se(result, s.rval(), nullptr /*ctx*/); + SE_PRECONDITION2(ok, false, "js_scene_OctreeInfo_getMinPos : Error processing arguments"); + SE_HOLD_RETURN_VALUE(result, s.thisObject(), s.rval()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 0); + return false; +} +SE_BIND_FUNC_AS_PROP_GET(js_scene_OctreeInfo_getMinPos) + +static bool js_scene_OctreeInfo_isEnabled(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_scene_OctreeInfo_isEnabled : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 0) { + bool result = cobj->isEnabled(); + ok &= nativevalue_to_se(result, s.rval(), nullptr /*ctx*/); + SE_PRECONDITION2(ok, false, "js_scene_OctreeInfo_isEnabled : Error processing arguments"); + SE_HOLD_RETURN_VALUE(result, s.thisObject(), s.rval()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 0); + return false; +} +SE_BIND_FUNC_AS_PROP_GET(js_scene_OctreeInfo_isEnabled) + +static bool js_scene_OctreeInfo_setDepth(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_scene_OctreeInfo_setDepth : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 1) { + HolderType arg0 = {}; + ok &= sevalue_to_native(args[0], &arg0, s.thisObject()); + SE_PRECONDITION2(ok, false, "js_scene_OctreeInfo_setDepth : Error processing arguments"); + cobj->setDepth(arg0.value()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 1); + return false; +} +SE_BIND_FUNC_AS_PROP_SET(js_scene_OctreeInfo_setDepth) + +static bool js_scene_OctreeInfo_setEnabled(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_scene_OctreeInfo_setEnabled : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 1) { + HolderType arg0 = {}; + ok &= sevalue_to_native(args[0], &arg0, s.thisObject()); + SE_PRECONDITION2(ok, false, "js_scene_OctreeInfo_setEnabled : Error processing arguments"); + cobj->setEnabled(arg0.value()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 1); + return false; +} +SE_BIND_FUNC_AS_PROP_SET(js_scene_OctreeInfo_setEnabled) + +static bool js_scene_OctreeInfo_setMaxPos(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_scene_OctreeInfo_setMaxPos : Invalid Native Object"); const auto& args = s.args(); size_t argc = args.size(); CC_UNUSED bool ok = true; if (argc == 1) { HolderType arg0 = {}; ok &= sevalue_to_native(args[0], &arg0, s.thisObject()); - SE_PRECONDITION2(ok, false, "js_scene_Sphere_setCenter : Error processing arguments"); - cobj->setCenter(arg0.value()); + SE_PRECONDITION2(ok, false, "js_scene_OctreeInfo_setMaxPos : Error processing arguments"); + cobj->setMaxPos(arg0.value()); return true; } SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 1); return false; } -SE_BIND_FUNC(js_scene_Sphere_setCenter) +SE_BIND_FUNC_AS_PROP_SET(js_scene_OctreeInfo_setMaxPos) -static bool js_scene_Sphere_setRadius(se::State& s) // NOLINT(readability-identifier-naming) +static bool js_scene_OctreeInfo_setMinPos(se::State& s) // NOLINT(readability-identifier-naming) { - auto* cobj = SE_THIS_OBJECT(s); - SE_PRECONDITION2(cobj, false, "js_scene_Sphere_setRadius : Invalid Native Object"); + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_scene_OctreeInfo_setMinPos : Invalid Native Object"); const auto& args = s.args(); size_t argc = args.size(); CC_UNUSED bool ok = true; if (argc == 1) { - HolderType arg0 = {}; + HolderType arg0 = {}; ok &= sevalue_to_native(args[0], &arg0, s.thisObject()); - SE_PRECONDITION2(ok, false, "js_scene_Sphere_setRadius : Error processing arguments"); - cobj->setRadius(arg0.value()); + SE_PRECONDITION2(ok, false, "js_scene_OctreeInfo_setMinPos : Error processing arguments"); + cobj->setMinPos(arg0.value()); return true; } SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 1); return false; } -SE_BIND_FUNC(js_scene_Sphere_setRadius) +SE_BIND_FUNC_AS_PROP_SET(js_scene_OctreeInfo_setMinPos) -SE_DECLARE_FINALIZE_FUNC(js_cc_scene_Sphere_finalize) - -static bool js_scene_Sphere_constructor(se::State& s) // NOLINT(readability-identifier-naming) constructor.c +static bool js_scene_OctreeInfo_get__enabled(se::State& s) // NOLINT(readability-identifier-naming) { - cc::scene::Sphere* cobj = JSB_ALLOC(cc::scene::Sphere); - s.thisObject()->setPrivateData(cobj); - se::NonRefNativePtrCreatedByCtorMap::emplace(cobj); + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_scene_OctreeInfo_get__enabled : Invalid Native Object"); + + CC_UNUSED bool ok = true; + se::Value jsret; + ok &= nativevalue_to_se(cobj->_enabled, jsret, s.thisObject() /*ctx*/); + s.rval() = jsret; + SE_HOLD_RETURN_VALUE(cobj->_enabled, s.thisObject(), s.rval()); return true; } -SE_BIND_CTOR(js_scene_Sphere_constructor, __jsb_cc_scene_Sphere_class, js_cc_scene_Sphere_finalize) +SE_BIND_PROP_GET(js_scene_OctreeInfo_get__enabled) - - -static bool js_cc_scene_Sphere_finalize(se::State& s) // NOLINT(readability-identifier-naming) +static bool js_scene_OctreeInfo_set__enabled(se::State& s) // NOLINT(readability-identifier-naming) { - auto iter = se::NonRefNativePtrCreatedByCtorMap::find(SE_THIS_OBJECT(s)); - if (iter != se::NonRefNativePtrCreatedByCtorMap::end()) - { - se::NonRefNativePtrCreatedByCtorMap::erase(iter); - auto* cobj = SE_THIS_OBJECT(s); - JSB_FREE(cobj); - } + const auto& args = s.args(); + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_scene_OctreeInfo_set__enabled : Invalid Native Object"); + + CC_UNUSED bool ok = true; + ok &= sevalue_to_native(args[0], &cobj->_enabled, s.thisObject()); + SE_PRECONDITION2(ok, false, "js_scene_OctreeInfo_set__enabled : Error processing new value"); return true; } -SE_BIND_FINALIZE_FUNC(js_cc_scene_Sphere_finalize) +SE_BIND_PROP_SET(js_scene_OctreeInfo_set__enabled) -bool js_register_scene_Sphere(se::Object* obj) // NOLINT(readability-identifier-naming) +static bool js_scene_OctreeInfo_get__minPos(se::State& s) // NOLINT(readability-identifier-naming) { - auto* cls = se::Class::create("Sphere", obj, nullptr, _SE(js_scene_Sphere_constructor)); + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_scene_OctreeInfo_get__minPos : Invalid Native Object"); - cls->defineFunction("getCenter", _SE(js_scene_Sphere_getCenter)); - cls->defineFunction("getRadius", _SE(js_scene_Sphere_getRadius)); - cls->defineFunction("setCenter", _SE(js_scene_Sphere_setCenter)); - cls->defineFunction("setRadius", _SE(js_scene_Sphere_setRadius)); - cls->defineFinalizeFunction(_SE(js_cc_scene_Sphere_finalize)); + CC_UNUSED bool ok = true; + se::Value jsret; + ok &= nativevalue_to_se(cobj->_minPos, jsret, s.thisObject() /*ctx*/); + s.rval() = jsret; + SE_HOLD_RETURN_VALUE(cobj->_minPos, s.thisObject(), s.rval()); + return true; +} +SE_BIND_PROP_GET(js_scene_OctreeInfo_get__minPos) + +static bool js_scene_OctreeInfo_set__minPos(se::State& s) // NOLINT(readability-identifier-naming) +{ + const auto& args = s.args(); + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_scene_OctreeInfo_set__minPos : Invalid Native Object"); + + CC_UNUSED bool ok = true; + ok &= sevalue_to_native(args[0], &cobj->_minPos, s.thisObject()); + SE_PRECONDITION2(ok, false, "js_scene_OctreeInfo_set__minPos : Error processing new value"); + return true; +} +SE_BIND_PROP_SET(js_scene_OctreeInfo_set__minPos) + +static bool js_scene_OctreeInfo_get__maxPos(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_scene_OctreeInfo_get__maxPos : Invalid Native Object"); + + CC_UNUSED bool ok = true; + se::Value jsret; + ok &= nativevalue_to_se(cobj->_maxPos, jsret, s.thisObject() /*ctx*/); + s.rval() = jsret; + SE_HOLD_RETURN_VALUE(cobj->_maxPos, s.thisObject(), s.rval()); + return true; +} +SE_BIND_PROP_GET(js_scene_OctreeInfo_get__maxPos) + +static bool js_scene_OctreeInfo_set__maxPos(se::State& s) // NOLINT(readability-identifier-naming) +{ + const auto& args = s.args(); + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_scene_OctreeInfo_set__maxPos : Invalid Native Object"); + + CC_UNUSED bool ok = true; + ok &= sevalue_to_native(args[0], &cobj->_maxPos, s.thisObject()); + SE_PRECONDITION2(ok, false, "js_scene_OctreeInfo_set__maxPos : Error processing new value"); + return true; +} +SE_BIND_PROP_SET(js_scene_OctreeInfo_set__maxPos) + +static bool js_scene_OctreeInfo_get__depth(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_scene_OctreeInfo_get__depth : Invalid Native Object"); + + CC_UNUSED bool ok = true; + se::Value jsret; + ok &= nativevalue_to_se(cobj->_depth, jsret, s.thisObject() /*ctx*/); + s.rval() = jsret; + SE_HOLD_RETURN_VALUE(cobj->_depth, s.thisObject(), s.rval()); + return true; +} +SE_BIND_PROP_GET(js_scene_OctreeInfo_get__depth) + +static bool js_scene_OctreeInfo_set__depth(se::State& s) // NOLINT(readability-identifier-naming) +{ + const auto& args = s.args(); + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_scene_OctreeInfo_set__depth : Invalid Native Object"); + + CC_UNUSED bool ok = true; + ok &= sevalue_to_native(args[0], &cobj->_depth, s.thisObject()); + SE_PRECONDITION2(ok, false, "js_scene_OctreeInfo_set__depth : Error processing new value"); + return true; +} +SE_BIND_PROP_SET(js_scene_OctreeInfo_set__depth) + +SE_DECLARE_FINALIZE_FUNC(js_cc_scene_OctreeInfo_finalize) + +static bool js_scene_OctreeInfo_constructor(se::State& s) // NOLINT(readability-identifier-naming) constructor.c +{ + auto *ptr = JSB_MAKE_PRIVATE_OBJECT(cc::scene::OctreeInfo); + s.thisObject()->setPrivateObject(ptr); + return true; +} +SE_BIND_CTOR(js_scene_OctreeInfo_constructor, __jsb_cc_scene_OctreeInfo_class, js_cc_scene_OctreeInfo_finalize) + +static bool js_cc_scene_OctreeInfo_finalize(se::State& s) // NOLINT(readability-identifier-naming) +{ + return true; +} +SE_BIND_FINALIZE_FUNC(js_cc_scene_OctreeInfo_finalize) + +bool js_register_scene_OctreeInfo(se::Object* obj) // NOLINT(readability-identifier-naming) +{ + auto* cls = se::Class::create("OctreeInfo", obj, nullptr, _SE(js_scene_OctreeInfo_constructor)); + + cls->defineProperty("_enabled", _SE(js_scene_OctreeInfo_get__enabled), _SE(js_scene_OctreeInfo_set__enabled)); + cls->defineProperty("_minPos", _SE(js_scene_OctreeInfo_get__minPos), _SE(js_scene_OctreeInfo_set__minPos)); + cls->defineProperty("_maxPos", _SE(js_scene_OctreeInfo_get__maxPos), _SE(js_scene_OctreeInfo_set__maxPos)); + cls->defineProperty("_depth", _SE(js_scene_OctreeInfo_get__depth), _SE(js_scene_OctreeInfo_set__depth)); + cls->defineProperty("minPos", _SE(js_scene_OctreeInfo_getMinPos_asGetter), _SE(js_scene_OctreeInfo_setMinPos_asSetter)); + cls->defineProperty("maxPos", _SE(js_scene_OctreeInfo_getMaxPos_asGetter), _SE(js_scene_OctreeInfo_setMaxPos_asSetter)); + cls->defineProperty("enabled", _SE(js_scene_OctreeInfo_isEnabled_asGetter), _SE(js_scene_OctreeInfo_setEnabled_asSetter)); + cls->defineProperty("depth", _SE(js_scene_OctreeInfo_getDepth_asGetter), _SE(js_scene_OctreeInfo_setDepth_asSetter)); + cls->defineFunction("activate", _SE(js_scene_OctreeInfo_activate)); + cls->defineFinalizeFunction(_SE(js_cc_scene_OctreeInfo_finalize)); cls->install(); - JSBClassType::registerClass(cls); + JSBClassType::registerClass(cls); + + __jsb_cc_scene_OctreeInfo_proto = cls->getProto(); + __jsb_cc_scene_OctreeInfo_class = cls; - __jsb_cc_scene_Sphere_proto = cls->getProto(); - __jsb_cc_scene_Sphere_class = cls; se::ScriptEngine::getInstance()->clearException(); return true; } -bool register_all_scene(se::Object* obj) +se::Object* __jsb_cc_scene_Octree_proto = nullptr; // NOLINT +se::Class* __jsb_cc_scene_Octree_class = nullptr; // NOLINT + +static bool js_scene_Octree_getMaxDepth(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_scene_Octree_getMaxDepth : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 0) { + unsigned int result = cobj->getMaxDepth(); + ok &= nativevalue_to_se(result, s.rval(), nullptr /*ctx*/); + SE_PRECONDITION2(ok, false, "js_scene_Octree_getMaxDepth : Error processing arguments"); + SE_HOLD_RETURN_VALUE(result, s.thisObject(), s.rval()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 0); + return false; +} +SE_BIND_FUNC(js_scene_Octree_getMaxDepth) + +static bool js_scene_Octree_getMaxPos(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_scene_Octree_getMaxPos : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 0) { + const cc::Vec3& result = cobj->getMaxPos(); + ok &= nativevalue_to_se(result, s.rval(), nullptr /*ctx*/); + SE_PRECONDITION2(ok, false, "js_scene_Octree_getMaxPos : Error processing arguments"); + SE_HOLD_RETURN_VALUE(result, s.thisObject(), s.rval()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 0); + return false; +} +SE_BIND_FUNC(js_scene_Octree_getMaxPos) + +static bool js_scene_Octree_getMinPos(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_scene_Octree_getMinPos : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 0) { + const cc::Vec3& result = cobj->getMinPos(); + ok &= nativevalue_to_se(result, s.rval(), nullptr /*ctx*/); + SE_PRECONDITION2(ok, false, "js_scene_Octree_getMinPos : Error processing arguments"); + SE_HOLD_RETURN_VALUE(result, s.thisObject(), s.rval()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 0); + return false; +} +SE_BIND_FUNC(js_scene_Octree_getMinPos) + +static bool js_scene_Octree_initialize(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_scene_Octree_initialize : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 1) { + HolderType arg0 = {}; + ok &= sevalue_to_native(args[0], &arg0, s.thisObject()); + SE_PRECONDITION2(ok, false, "js_scene_Octree_initialize : Error processing arguments"); + cobj->initialize(arg0.value()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 1); + return false; +} +SE_BIND_FUNC(js_scene_Octree_initialize) + +static bool js_scene_Octree_insert(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_scene_Octree_insert : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 1) { + HolderType arg0 = {}; + ok &= sevalue_to_native(args[0], &arg0, s.thisObject()); + SE_PRECONDITION2(ok, false, "js_scene_Octree_insert : Error processing arguments"); + cobj->insert(arg0.value()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 1); + return false; +} +SE_BIND_FUNC(js_scene_Octree_insert) + +static bool js_scene_Octree_isEnabled(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_scene_Octree_isEnabled : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 0) { + bool result = cobj->isEnabled(); + ok &= nativevalue_to_se(result, s.rval(), nullptr /*ctx*/); + SE_PRECONDITION2(ok, false, "js_scene_Octree_isEnabled : Error processing arguments"); + SE_HOLD_RETURN_VALUE(result, s.thisObject(), s.rval()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 0); + return false; +} +SE_BIND_FUNC(js_scene_Octree_isEnabled) + +static bool js_scene_Octree_queryVisibility(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_scene_Octree_queryVisibility : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 4) { + HolderType arg0 = {}; + HolderType arg1 = {}; + HolderType arg2 = {}; + HolderType, true> arg3 = {}; + ok &= sevalue_to_native(args[0], &arg0, s.thisObject()); + ok &= sevalue_to_native(args[1], &arg1, s.thisObject()); + ok &= sevalue_to_native(args[2], &arg2, s.thisObject()); + ok &= sevalue_to_native(args[3], &arg3, s.thisObject()); + SE_PRECONDITION2(ok, false, "js_scene_Octree_queryVisibility : Error processing arguments"); + cobj->queryVisibility(arg0.value(), arg1.value(), arg2.value(), arg3.value()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 4); + return false; +} +SE_BIND_FUNC(js_scene_Octree_queryVisibility) + +static bool js_scene_Octree_remove(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_scene_Octree_remove : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 1) { + HolderType arg0 = {}; + ok &= sevalue_to_native(args[0], &arg0, s.thisObject()); + SE_PRECONDITION2(ok, false, "js_scene_Octree_remove : Error processing arguments"); + cobj->remove(arg0.value()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 1); + return false; +} +SE_BIND_FUNC(js_scene_Octree_remove) + +static bool js_scene_Octree_resize(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_scene_Octree_resize : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 3) { + HolderType arg0 = {}; + HolderType arg1 = {}; + HolderType arg2 = {}; + ok &= sevalue_to_native(args[0], &arg0, s.thisObject()); + ok &= sevalue_to_native(args[1], &arg1, s.thisObject()); + ok &= sevalue_to_native(args[2], &arg2, s.thisObject()); + SE_PRECONDITION2(ok, false, "js_scene_Octree_resize : Error processing arguments"); + cobj->resize(arg0.value(), arg1.value(), arg2.value()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 3); + return false; +} +SE_BIND_FUNC(js_scene_Octree_resize) + +static bool js_scene_Octree_setEnabled(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_scene_Octree_setEnabled : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 1) { + HolderType arg0 = {}; + ok &= sevalue_to_native(args[0], &arg0, s.thisObject()); + SE_PRECONDITION2(ok, false, "js_scene_Octree_setEnabled : Error processing arguments"); + cobj->setEnabled(arg0.value()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 1); + return false; +} +SE_BIND_FUNC(js_scene_Octree_setEnabled) + +static bool js_scene_Octree_setMaxDepth(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_scene_Octree_setMaxDepth : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 1) { + HolderType arg0 = {}; + ok &= sevalue_to_native(args[0], &arg0, s.thisObject()); + SE_PRECONDITION2(ok, false, "js_scene_Octree_setMaxDepth : Error processing arguments"); + cobj->setMaxDepth(arg0.value()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 1); + return false; +} +SE_BIND_FUNC(js_scene_Octree_setMaxDepth) + +static bool js_scene_Octree_setMaxPos(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_scene_Octree_setMaxPos : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 1) { + HolderType arg0 = {}; + ok &= sevalue_to_native(args[0], &arg0, s.thisObject()); + SE_PRECONDITION2(ok, false, "js_scene_Octree_setMaxPos : Error processing arguments"); + cobj->setMaxPos(arg0.value()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 1); + return false; +} +SE_BIND_FUNC(js_scene_Octree_setMaxPos) + +static bool js_scene_Octree_setMinPos(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_scene_Octree_setMinPos : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 1) { + HolderType arg0 = {}; + ok &= sevalue_to_native(args[0], &arg0, s.thisObject()); + SE_PRECONDITION2(ok, false, "js_scene_Octree_setMinPos : Error processing arguments"); + cobj->setMinPos(arg0.value()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 1); + return false; +} +SE_BIND_FUNC(js_scene_Octree_setMinPos) + +static bool js_scene_Octree_update(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_scene_Octree_update : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 1) { + HolderType arg0 = {}; + ok &= sevalue_to_native(args[0], &arg0, s.thisObject()); + SE_PRECONDITION2(ok, false, "js_scene_Octree_update : Error processing arguments"); + cobj->update(arg0.value()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 1); + return false; +} +SE_BIND_FUNC(js_scene_Octree_update) + +SE_DECLARE_FINALIZE_FUNC(js_cc_scene_Octree_finalize) + +static bool js_scene_Octree_constructor(se::State& s) // NOLINT(readability-identifier-naming) constructor.c +{ + auto *ptr = JSB_MAKE_PRIVATE_OBJECT(cc::scene::Octree); + s.thisObject()->setPrivateObject(ptr); + return true; +} +SE_BIND_CTOR(js_scene_Octree_constructor, __jsb_cc_scene_Octree_class, js_cc_scene_Octree_finalize) + +static bool js_cc_scene_Octree_finalize(se::State& s) // NOLINT(readability-identifier-naming) +{ + return true; +} +SE_BIND_FINALIZE_FUNC(js_cc_scene_Octree_finalize) + +bool js_register_scene_Octree(se::Object* obj) // NOLINT(readability-identifier-naming) +{ + auto* cls = se::Class::create("Octree", obj, nullptr, _SE(js_scene_Octree_constructor)); + + cls->defineFunction("getMaxDepth", _SE(js_scene_Octree_getMaxDepth)); + cls->defineFunction("getMaxPos", _SE(js_scene_Octree_getMaxPos)); + cls->defineFunction("getMinPos", _SE(js_scene_Octree_getMinPos)); + cls->defineFunction("initialize", _SE(js_scene_Octree_initialize)); + cls->defineFunction("insert", _SE(js_scene_Octree_insert)); + cls->defineFunction("isEnabled", _SE(js_scene_Octree_isEnabled)); + cls->defineFunction("queryVisibility", _SE(js_scene_Octree_queryVisibility)); + cls->defineFunction("remove", _SE(js_scene_Octree_remove)); + cls->defineFunction("resize", _SE(js_scene_Octree_resize)); + cls->defineFunction("setEnabled", _SE(js_scene_Octree_setEnabled)); + cls->defineFunction("setMaxDepth", _SE(js_scene_Octree_setMaxDepth)); + cls->defineFunction("setMaxPos", _SE(js_scene_Octree_setMaxPos)); + cls->defineFunction("setMinPos", _SE(js_scene_Octree_setMinPos)); + cls->defineFunction("update", _SE(js_scene_Octree_update)); + cls->defineFinalizeFunction(_SE(js_cc_scene_Octree_finalize)); + cls->install(); + JSBClassType::registerClass(cls); + + __jsb_cc_scene_Octree_proto = cls->getProto(); + __jsb_cc_scene_Octree_class = cls; + + + se::ScriptEngine::getInstance()->clearException(); + return true; +} +bool register_all_scene(se::Object* obj) // NOLINT { // Get the ns se::Value nsVal; - if (!obj->getProperty("ns", &nsVal)) + if (!obj->getProperty("jsb", &nsVal, true)) { se::HandleObject jsobj(se::Object::createPlainObject()); nsVal.setObject(jsobj); - obj->setProperty("ns", nsVal); + obj->setProperty("jsb", nsVal); } se::Object* ns = nsVal.toObject(); + js_register_scene_Ambient(ns); + js_register_scene_AmbientInfo(ns); + js_register_scene_Model(ns); + js_register_scene_MorphModel(ns); + js_register_scene_BakedSkinningModel(ns); js_register_scene_BaseNode(ns); - js_register_scene_Scene(ns); - js_register_scene_Node(ns); + js_register_scene_Camera(ns); js_register_scene_Light(ns); js_register_scene_DirectionalLight(ns); - js_register_scene_Plane(ns); - js_register_scene_Frustum(ns); - js_register_scene_AABB(ns); - js_register_scene_SpotLight(ns); - js_register_scene_SphereLight(ns); - js_register_scene_Model(ns); - js_register_scene_Fog(ns); - js_register_scene_Shadow(ns); - js_register_scene_Skybox(ns); - js_register_scene_Ambient(ns); - js_register_scene_OctreeInfo(ns); - js_register_scene_PipelineSharedSceneData(ns); - js_register_scene_Root(ns); - js_register_scene_SubModel(ns); - js_register_scene_Pass(ns); - js_register_scene_BakedAnimInfo(ns); - js_register_scene_BakedJointInfo(ns); - js_register_scene_BakedSkinningModel(ns); js_register_scene_DrawBatch2D(ns); - js_register_scene_JointTransform(ns); - js_register_scene_JointInfo(ns); - js_register_scene_SkinningModel(ns); + js_register_scene_Fog(ns); + js_register_scene_FogInfo(ns); + js_register_scene_ICameraInfo(ns); + js_register_scene_IDefineRecord(ns); + js_register_scene_IMacroPatch(ns); + js_register_scene_IMaterialInstanceInfo(ns); + js_register_scene_IProgramInfo(ns); + js_register_scene_IRenderSceneInfo(ns); + js_register_scene_IRenderWindowInfo(ns); + js_register_scene_InstancedAttributeBlock(ns); + js_register_scene_MaterialInstance(ns); + js_register_scene_Node(ns); + js_register_scene_Octree(ns); + js_register_scene_OctreeInfo(ns); + js_register_scene_Pass(ns); + js_register_scene_PassDynamicsValue(ns); + js_register_scene_PassInstance(ns); + js_register_scene_ProgramLib(ns); js_register_scene_RenderScene(ns); js_register_scene_RenderWindow(ns); - js_register_scene_Camera(ns); - js_register_scene_Sphere(ns); + js_register_scene_Root(ns); + js_register_scene_Scene(ns); + js_register_scene_SceneGlobals(ns); + js_register_scene_Shadows(ns); + js_register_scene_ShadowsInfo(ns); + js_register_scene_SkinningModel(ns); + js_register_scene_Skybox(ns); + js_register_scene_SkyboxInfo(ns); + js_register_scene_SphereLight(ns); + js_register_scene_SpotLight(ns); + js_register_scene_SubModel(ns); return true; } +// clang-format on \ No newline at end of file diff --git a/native/cocos/bindings/auto/jsb_scene_auto.h b/native/cocos/bindings/auto/jsb_scene_auto.h index 023424844d..915beb4068 100644 --- a/native/cocos/bindings/auto/jsb_scene_auto.h +++ b/native/cocos/bindings/auto/jsb_scene_auto.h @@ -1,13 +1,20 @@ +// clang-format off #pragma once #include "base/Config.h" #include #include "cocos/bindings/jswrapper/SeApi.h" #include "cocos/bindings/manual/jsb_conversions.h" #include "cocos/bindings/auto/jsb_gfx_auto.h" -#include "cocos/scene/Node.h" -#include "cocos/scene/BaseNode.h" -#include "cocos/scene/Scene.h" +#include "cocos/bindings/auto/jsb_geometry_auto.h" +#include "cocos/bindings/auto/jsb_assets_auto.h" +#include "cocos/core/data/Object.h" +#include "cocos/core/scene-graph/Node.h" +#include "cocos/core/scene-graph/Scene.h" +#include "cocos/core/scene-graph/SceneGlobals.h" #include "cocos/scene/Light.h" +#include "cocos/scene/Fog.h" +#include "cocos/scene/Shadow.h" +#include "cocos/scene/Skybox.h" #include "cocos/scene/DirectionalLight.h" #include "cocos/scene/SpotLight.h" #include "cocos/scene/SphereLight.h" @@ -16,458 +23,665 @@ #include "cocos/scene/Pass.h" #include "cocos/scene/RenderScene.h" #include "cocos/scene/DrawBatch2D.h" -#include "cocos/scene/Camera.h" #include "cocos/scene/RenderWindow.h" #include "cocos/scene/Camera.h" #include "cocos/scene/Define.h" -#include "cocos/scene/AABB.h" -#include "cocos/scene/Sphere.h" +#include "cocos/scene/Ambient.h" +#include "cocos/renderer/core/PassInstance.h" +#include "cocos/renderer/core/MaterialInstance.h" +#include "cocos/3d/models/MorphModel.h" +#include "cocos/3d/models/SkinningModel.h" +#include "cocos/3d/models/BakedSkinningModel.h" +#include "cocos/core/Root.h" +#include "cocos/renderer/core/ProgramLib.h" +#include "cocos/scene/Octree.h" -extern se::Object* __jsb_cc_scene_BaseNode_proto; -extern se::Class* __jsb_cc_scene_BaseNode_class; +bool register_all_scene(se::Object *obj); // NOLINT -bool js_register_cc_scene_BaseNode(se::Object* obj); -bool register_all_scene(se::Object* obj); +JSB_REGISTER_OBJECT_TYPE(cc::BaseNode); +JSB_REGISTER_OBJECT_TYPE(cc::Node); +JSB_REGISTER_OBJECT_TYPE(cc::SceneGlobals); +JSB_REGISTER_OBJECT_TYPE(cc::Scene); +JSB_REGISTER_OBJECT_TYPE(cc::scene::Light); +JSB_REGISTER_OBJECT_TYPE(cc::scene::Fog); +JSB_REGISTER_OBJECT_TYPE(cc::scene::FogInfo); +JSB_REGISTER_OBJECT_TYPE(cc::scene::PassDynamicsValue); +JSB_REGISTER_OBJECT_TYPE(cc::scene::Pass); +JSB_REGISTER_OBJECT_TYPE(cc::scene::IMacroPatch); +JSB_REGISTER_OBJECT_TYPE(cc::scene::ShadowsInfo); +JSB_REGISTER_OBJECT_TYPE(cc::scene::Shadows); +JSB_REGISTER_OBJECT_TYPE(cc::scene::ICameraInfo); +JSB_REGISTER_OBJECT_TYPE(cc::scene::Camera); +JSB_REGISTER_OBJECT_TYPE(cc::scene::SubModel); +JSB_REGISTER_OBJECT_TYPE(cc::scene::InstancedAttributeBlock); +JSB_REGISTER_OBJECT_TYPE(cc::scene::Model); +JSB_REGISTER_OBJECT_TYPE(cc::scene::DrawBatch2D); +JSB_REGISTER_OBJECT_TYPE(cc::scene::IRenderSceneInfo); +JSB_REGISTER_OBJECT_TYPE(cc::scene::RenderScene); +JSB_REGISTER_OBJECT_TYPE(cc::scene::IRenderWindowInfo); +JSB_REGISTER_OBJECT_TYPE(cc::scene::RenderWindow); +JSB_REGISTER_OBJECT_TYPE(cc::scene::SphereLight); +JSB_REGISTER_OBJECT_TYPE(cc::Root); +JSB_REGISTER_OBJECT_TYPE(cc::scene::SkyboxInfo); +JSB_REGISTER_OBJECT_TYPE(cc::scene::Skybox); +JSB_REGISTER_OBJECT_TYPE(cc::scene::Ambient); +JSB_REGISTER_OBJECT_TYPE(cc::scene::AmbientInfo); +JSB_REGISTER_OBJECT_TYPE(cc::scene::DirectionalLight); +JSB_REGISTER_OBJECT_TYPE(cc::scene::SpotLight); +JSB_REGISTER_OBJECT_TYPE(cc::IMaterialInstanceInfo); +JSB_REGISTER_OBJECT_TYPE(cc::MaterialInstance); +JSB_REGISTER_OBJECT_TYPE(cc::PassInstance); +JSB_REGISTER_OBJECT_TYPE(cc::MorphModel); +JSB_REGISTER_OBJECT_TYPE(cc::SkinningModel); +JSB_REGISTER_OBJECT_TYPE(cc::BakedSkinningModel); +JSB_REGISTER_OBJECT_TYPE(cc::IDefineRecord); +JSB_REGISTER_OBJECT_TYPE(cc::IProgramInfo); +JSB_REGISTER_OBJECT_TYPE(cc::ProgramLib); +JSB_REGISTER_OBJECT_TYPE(cc::scene::OctreeInfo); +JSB_REGISTER_OBJECT_TYPE(cc::scene::Octree); -JSB_REGISTER_OBJECT_TYPE(cc::scene::BaseNode); -SE_DECLARE_FUNC(js_scene_BaseNode_getChilds); -SE_DECLARE_FUNC(js_scene_BaseNode_setParent); -SE_DECLARE_FUNC(js_scene_BaseNode_BaseNode); -extern se::Object* __jsb_cc_scene_Scene_proto; -extern se::Class* __jsb_cc_scene_Scene_class; +extern se::Object *__jsb_cc_BaseNode_proto; // NOLINT +extern se::Class * __jsb_cc_BaseNode_class; // NOLINT -bool js_register_cc_scene_Scene(se::Object* obj); -bool register_all_scene(se::Object* obj); +bool js_register_cc_BaseNode(se::Object *obj); // NOLINT -JSB_REGISTER_OBJECT_TYPE(cc::scene::Scene); -SE_DECLARE_FUNC(js_scene_Scene_Scene); -extern se::Object* __jsb_cc_scene_Node_proto; -extern se::Class* __jsb_cc_scene_Node_class; +extern se::Object *__jsb_cc_Node_proto; // NOLINT +extern se::Class * __jsb_cc_Node_class; // NOLINT -bool js_register_cc_scene_Node(se::Object* obj); -bool register_all_scene(se::Object* obj); +bool js_register_cc_Node(se::Object *obj); // NOLINT -JSB_REGISTER_OBJECT_TYPE(cc::scene::Node); -SE_DECLARE_FUNC(js_scene_Node_initWithData); +SE_DECLARE_FUNC(js_scene_Node__setChildren); +SE_DECLARE_FUNC(js_scene_Node_addChild); +SE_DECLARE_FUNC(js_scene_Node_destroyAllChildren); +SE_DECLARE_FUNC(js_scene_Node_getChildByName); +SE_DECLARE_FUNC(js_scene_Node_getChildByPath); +SE_DECLARE_FUNC(js_scene_Node_getChildByUuid); +SE_DECLARE_FUNC(js_scene_Node_getEventMask); +SE_DECLARE_FUNC(js_scene_Node_getLayer); +SE_DECLARE_FUNC(js_scene_Node_getParent); +SE_DECLARE_FUNC(js_scene_Node_getScene); +SE_DECLARE_FUNC(js_scene_Node_getSiblingIndex); +SE_DECLARE_FUNC(js_scene_Node_insertChild); +SE_DECLARE_FUNC(js_scene_Node_invalidateChildren); +SE_DECLARE_FUNC(js_scene_Node_inverseTransformPoint); +SE_DECLARE_FUNC(js_scene_Node_isChildOf); +SE_DECLARE_FUNC(js_scene_Node_lookAt); +SE_DECLARE_FUNC(js_scene_Node_off); +SE_DECLARE_FUNC(js_scene_Node_onPostActivated); +SE_DECLARE_FUNC(js_scene_Node_pauseSystemEvents); +SE_DECLARE_FUNC(js_scene_Node_removeAllChildren); +SE_DECLARE_FUNC(js_scene_Node_removeChild); +SE_DECLARE_FUNC(js_scene_Node_removeFromParent); +SE_DECLARE_FUNC(js_scene_Node_resumeSystemEvents); +SE_DECLARE_FUNC(js_scene_Node_setEulerAngles); +SE_DECLARE_FUNC(js_scene_Node_setEventMask); +SE_DECLARE_FUNC(js_scene_Node_setForward); +SE_DECLARE_FUNC(js_scene_Node_setLayer); +SE_DECLARE_FUNC(js_scene_Node_setParent); +SE_DECLARE_FUNC(js_scene_Node_setPositionForJS); +SE_DECLARE_FUNC(js_scene_Node_setPositionInternal); +SE_DECLARE_FUNC(js_scene_Node_setRTSInternal); +SE_DECLARE_FUNC(js_scene_Node_setRotationForJS); +SE_DECLARE_FUNC(js_scene_Node_setRotationFromEulerForJS); +SE_DECLARE_FUNC(js_scene_Node_setRotationInternal); +SE_DECLARE_FUNC(js_scene_Node_setScaleForJS); +SE_DECLARE_FUNC(js_scene_Node_setScaleInternal); +SE_DECLARE_FUNC(js_scene_Node_setSiblingIndex); +SE_DECLARE_FUNC(js_scene_Node_setUIPropsTransformDirtyPtr); +SE_DECLARE_FUNC(js_scene_Node_setWorldPosition); +SE_DECLARE_FUNC(js_scene_Node_setWorldRotation); +SE_DECLARE_FUNC(js_scene_Node_setWorldRotationFromEuler); +SE_DECLARE_FUNC(js_scene_Node_setWorldScale); +SE_DECLARE_FUNC(js_scene_Node_targetOff); +SE_DECLARE_FUNC(js_scene_Node_translate); +SE_DECLARE_FUNC(js_scene_Node_updateSiblingIndex); +SE_DECLARE_FUNC(js_scene_Node_updateWorldTransform); +SE_DECLARE_FUNC(js_scene_Node_walk); +SE_DECLARE_FUNC(js_scene_Node_clearNodeArray); +SE_DECLARE_FUNC(js_scene_Node_getIdxOfChild); +SE_DECLARE_FUNC(js_scene_Node_instantiate); +SE_DECLARE_FUNC(js_scene_Node_resetChangedFlags); +SE_DECLARE_FUNC(js_scene_Node_setScene); SE_DECLARE_FUNC(js_scene_Node_Node); -extern se::Object* __jsb_cc_scene_Light_proto; -extern se::Class* __jsb_cc_scene_Light_class; +extern se::Object *__jsb_cc_SceneGlobals_proto; // NOLINT +extern se::Class * __jsb_cc_SceneGlobals_class; // NOLINT -bool js_register_cc_scene_Light(se::Object* obj); -bool register_all_scene(se::Object* obj); +bool js_register_cc_SceneGlobals(se::Object *obj); // NOLINT -JSB_REGISTER_OBJECT_TYPE(cc::scene::Light); -SE_DECLARE_FUNC(js_scene_Light_getBaked); -SE_DECLARE_FUNC(js_scene_Light_setBaked); -SE_DECLARE_FUNC(js_scene_Light_setColor); -SE_DECLARE_FUNC(js_scene_Light_setColorTemperatureRGB); -SE_DECLARE_FUNC(js_scene_Light_setNode); -SE_DECLARE_FUNC(js_scene_Light_setType); -SE_DECLARE_FUNC(js_scene_Light_setUseColorTemperature); +SE_DECLARE_FUNC(js_scene_SceneGlobals_activate); +SE_DECLARE_FUNC(js_scene_SceneGlobals_getAmbientInfo); +SE_DECLARE_FUNC(js_scene_SceneGlobals_getFogInfo); +SE_DECLARE_FUNC(js_scene_SceneGlobals_getOctreeInfo); +SE_DECLARE_FUNC(js_scene_SceneGlobals_getShadowsInfo); +SE_DECLARE_FUNC(js_scene_SceneGlobals_getSkyboxInfo); +SE_DECLARE_FUNC(js_scene_SceneGlobals_setAmbientInfo); +SE_DECLARE_FUNC(js_scene_SceneGlobals_setFogInfo); +SE_DECLARE_FUNC(js_scene_SceneGlobals_setOctreeInfo); +SE_DECLARE_FUNC(js_scene_SceneGlobals_setShadowsInfo); +SE_DECLARE_FUNC(js_scene_SceneGlobals_setSkyboxInfo); +SE_DECLARE_FUNC(js_scene_SceneGlobals_SceneGlobals); + +extern se::Object *__jsb_cc_Scene_proto; // NOLINT +extern se::Class * __jsb_cc_Scene_class; // NOLINT + +bool js_register_cc_Scene(se::Object *obj); // NOLINT + +SE_DECLARE_FUNC(js_scene_Scene_activate); +SE_DECLARE_FUNC(js_scene_Scene_getRenderScene); +SE_DECLARE_FUNC(js_scene_Scene_getSceneGlobals); +SE_DECLARE_FUNC(js_scene_Scene_load); +SE_DECLARE_FUNC(js_scene_Scene_onBatchCreated); +SE_DECLARE_FUNC(js_scene_Scene_setSceneGlobals); +SE_DECLARE_FUNC(js_scene_Scene_Scene); + +extern se::Object *__jsb_cc_scene_Light_proto; // NOLINT +extern se::Class * __jsb_cc_scene_Light_class; // NOLINT + +bool js_register_cc_scene_Light(se::Object *obj); // NOLINT + +SE_DECLARE_FUNC(js_scene_Light_attachToScene); +SE_DECLARE_FUNC(js_scene_Light_destroy); +SE_DECLARE_FUNC(js_scene_Light_detachFromScene); +SE_DECLARE_FUNC(js_scene_Light_initialize); SE_DECLARE_FUNC(js_scene_Light_update); +SE_DECLARE_FUNC(js_scene_Light_nt2lm); +SE_DECLARE_FUNC(js_scene_Light_Light); -extern se::Object* __jsb_cc_scene_DirectionalLight_proto; -extern se::Class* __jsb_cc_scene_DirectionalLight_class; +extern se::Object *__jsb_cc_scene_Fog_proto; // NOLINT +extern se::Class * __jsb_cc_scene_Fog_class; // NOLINT -bool js_register_cc_scene_DirectionalLight(se::Object* obj); -bool register_all_scene(se::Object* obj); +bool js_register_cc_scene_Fog(se::Object *obj); // NOLINT -JSB_REGISTER_OBJECT_TYPE(cc::scene::DirectionalLight); -SE_DECLARE_FUNC(js_scene_DirectionalLight_setDirection); -SE_DECLARE_FUNC(js_scene_DirectionalLight_setIlluminanceHDR); -SE_DECLARE_FUNC(js_scene_DirectionalLight_setIlluminanceLDR); -SE_DECLARE_FUNC(js_scene_DirectionalLight_DirectionalLight); +SE_DECLARE_FUNC(js_scene_Fog_activate); +SE_DECLARE_FUNC(js_scene_Fog_initialize); +SE_DECLARE_FUNC(js_scene_Fog_isAccurate); +SE_DECLARE_FUNC(js_scene_Fog_setAccurate); +SE_DECLARE_FUNC(js_scene_Fog_setfogRange); +SE_DECLARE_FUNC(js_scene_Fog_Fog); -extern se::Object* __jsb_cc_scene_Plane_proto; -extern se::Class* __jsb_cc_scene_Plane_class; +extern se::Object *__jsb_cc_scene_FogInfo_proto; // NOLINT +extern se::Class * __jsb_cc_scene_FogInfo_class; // NOLINT -bool js_register_cc_scene_Plane(se::Object* obj); -bool register_all_scene(se::Object* obj); +bool js_register_cc_scene_FogInfo(se::Object *obj); // NOLINT -template<> -bool sevalue_to_native(const se::Value &, cc::scene::Plane *, se::Object *ctx); -JSB_REGISTER_OBJECT_TYPE(cc::scene::Plane); -SE_DECLARE_FUNC(js_scene_Plane_clone); -SE_DECLARE_FUNC(js_scene_Plane_define); -SE_DECLARE_FUNC(js_scene_Plane_distance); +SE_DECLARE_FUNC(js_scene_FogInfo_activate); +SE_DECLARE_FUNC(js_scene_FogInfo_isAccurate); +SE_DECLARE_FUNC(js_scene_FogInfo_setAccurate); +SE_DECLARE_FUNC(js_scene_FogInfo_FogInfo); -extern se::Object* __jsb_cc_scene_Frustum_proto; -extern se::Class* __jsb_cc_scene_Frustum_class; +extern se::Object *__jsb_cc_scene_PassDynamicsValue_proto; // NOLINT +extern se::Class * __jsb_cc_scene_PassDynamicsValue_class; // NOLINT -bool js_register_cc_scene_Frustum(se::Object* obj); -bool register_all_scene(se::Object* obj); +bool js_register_cc_scene_PassDynamicsValue(se::Object *obj); // NOLINT -template<> -bool sevalue_to_native(const se::Value &, cc::scene::Frustum *, se::Object *ctx); -JSB_REGISTER_OBJECT_TYPE(cc::scene::Frustum); -SE_DECLARE_FUNC(js_scene_Frustum_clone); -SE_DECLARE_FUNC(js_scene_Frustum_createOrtho); -SE_DECLARE_FUNC(js_scene_Frustum_split); -SE_DECLARE_FUNC(js_scene_Frustum_transform); +template <> +bool sevalue_to_native(const se::Value &, cc::scene::PassDynamicsValue *, se::Object *ctx); //NOLINT -extern se::Object* __jsb_cc_scene_AABB_proto; -extern se::Class* __jsb_cc_scene_AABB_class; +extern se::Object *__jsb_cc_scene_Pass_proto; // NOLINT +extern se::Class * __jsb_cc_scene_Pass_class; // NOLINT -bool js_register_cc_scene_AABB(se::Object* obj); -bool register_all_scene(se::Object* obj); +bool js_register_cc_scene_Pass(se::Object *obj); // NOLINT -JSB_REGISTER_OBJECT_TYPE(cc::scene::AABB); -SE_DECLARE_FUNC(js_scene_AABB_contain); -SE_DECLARE_FUNC(js_scene_AABB_getLayout); -SE_DECLARE_FUNC(js_scene_AABB_initWithData); -SE_DECLARE_FUNC(js_scene_AABB_AABB); +SE_DECLARE_FUNC(js_scene_Pass_beginChangeStatesSilently); +SE_DECLARE_FUNC(js_scene_Pass_bindSampler); +SE_DECLARE_FUNC(js_scene_Pass_bindTexture); +SE_DECLARE_FUNC(js_scene_Pass_destroy); +SE_DECLARE_FUNC(js_scene_Pass_endChangeStatesSilently); +SE_DECLARE_FUNC(js_scene_Pass_getBatchedBuffer); +SE_DECLARE_FUNC(js_scene_Pass_getBinding); +SE_DECLARE_FUNC(js_scene_Pass_getHandle); +SE_DECLARE_FUNC(js_scene_Pass_getHash); +SE_DECLARE_FUNC(js_scene_Pass_getInstancedBuffer); +SE_DECLARE_FUNC(js_scene_Pass_getPassInfoFull); +SE_DECLARE_FUNC(js_scene_Pass_getRootBlock); +SE_DECLARE_FUNC(js_scene_Pass_getShaderVariant); +SE_DECLARE_FUNC(js_scene_Pass_getUniform); +SE_DECLARE_FUNC(js_scene_Pass_initPassFromTarget); +SE_DECLARE_FUNC(js_scene_Pass_initialize); +SE_DECLARE_FUNC(js_scene_Pass_overridePipelineStates); +SE_DECLARE_FUNC(js_scene_Pass_resetTexture); +SE_DECLARE_FUNC(js_scene_Pass_resetTextures); +SE_DECLARE_FUNC(js_scene_Pass_resetUBOs); +SE_DECLARE_FUNC(js_scene_Pass_resetUniform); +SE_DECLARE_FUNC(js_scene_Pass_setDynamicState); +SE_DECLARE_FUNC(js_scene_Pass_setUniform); +SE_DECLARE_FUNC(js_scene_Pass_setUniformArray); +SE_DECLARE_FUNC(js_scene_Pass_tryCompile); +SE_DECLARE_FUNC(js_scene_Pass_update); +SE_DECLARE_FUNC(js_scene_Pass_fillPipelineInfo); +SE_DECLARE_FUNC(js_scene_Pass_getBindingFromHandle); +SE_DECLARE_FUNC(js_scene_Pass_getCountFromHandle); +SE_DECLARE_FUNC(js_scene_Pass_getOffsetFromHandle); +SE_DECLARE_FUNC(js_scene_Pass_getPassHash); +SE_DECLARE_FUNC(js_scene_Pass_getTypeFromHandle); +SE_DECLARE_FUNC(js_scene_Pass_Pass); -extern se::Object* __jsb_cc_scene_SpotLight_proto; -extern se::Class* __jsb_cc_scene_SpotLight_class; +extern se::Object *__jsb_cc_scene_IMacroPatch_proto; // NOLINT +extern se::Class * __jsb_cc_scene_IMacroPatch_class; // NOLINT -bool js_register_cc_scene_SpotLight(se::Object* obj); -bool register_all_scene(se::Object* obj); +bool js_register_cc_scene_IMacroPatch(se::Object *obj); // NOLINT -JSB_REGISTER_OBJECT_TYPE(cc::scene::SpotLight); -SE_DECLARE_FUNC(js_scene_SpotLight_setAABB); -SE_DECLARE_FUNC(js_scene_SpotLight_setAngle); -SE_DECLARE_FUNC(js_scene_SpotLight_setAspect); -SE_DECLARE_FUNC(js_scene_SpotLight_setDirection); -SE_DECLARE_FUNC(js_scene_SpotLight_setFrustum); -SE_DECLARE_FUNC(js_scene_SpotLight_setLuminanceHDR); -SE_DECLARE_FUNC(js_scene_SpotLight_setLuminanceLDR); -SE_DECLARE_FUNC(js_scene_SpotLight_setNeedUpdate); -SE_DECLARE_FUNC(js_scene_SpotLight_setPosition); -SE_DECLARE_FUNC(js_scene_SpotLight_setRange); -SE_DECLARE_FUNC(js_scene_SpotLight_setSize); -SE_DECLARE_FUNC(js_scene_SpotLight_SpotLight); +template <> +bool sevalue_to_native(const se::Value &, cc::scene::IMacroPatch *, se::Object *ctx); //NOLINT -extern se::Object* __jsb_cc_scene_SphereLight_proto; -extern se::Class* __jsb_cc_scene_SphereLight_class; +extern se::Object *__jsb_cc_scene_ShadowsInfo_proto; // NOLINT +extern se::Class * __jsb_cc_scene_ShadowsInfo_class; // NOLINT -bool js_register_cc_scene_SphereLight(se::Object* obj); -bool register_all_scene(se::Object* obj); +bool js_register_cc_scene_ShadowsInfo(se::Object *obj); // NOLINT -JSB_REGISTER_OBJECT_TYPE(cc::scene::SphereLight); -SE_DECLARE_FUNC(js_scene_SphereLight_setAABB); -SE_DECLARE_FUNC(js_scene_SphereLight_setLuminanceHDR); -SE_DECLARE_FUNC(js_scene_SphereLight_setLuminanceLDR); -SE_DECLARE_FUNC(js_scene_SphereLight_setPosition); -SE_DECLARE_FUNC(js_scene_SphereLight_setRange); -SE_DECLARE_FUNC(js_scene_SphereLight_setSize); -SE_DECLARE_FUNC(js_scene_SphereLight_SphereLight); +SE_DECLARE_FUNC(js_scene_ShadowsInfo_activate); +SE_DECLARE_FUNC(js_scene_ShadowsInfo_getShadowMapSize); +SE_DECLARE_FUNC(js_scene_ShadowsInfo_setFixedArea); +SE_DECLARE_FUNC(js_scene_ShadowsInfo_setPlaneFromNode); +SE_DECLARE_FUNC(js_scene_ShadowsInfo_setShadowMapSize); +SE_DECLARE_FUNC(js_scene_ShadowsInfo_ShadowsInfo); -extern se::Object* __jsb_cc_scene_Model_proto; -extern se::Class* __jsb_cc_scene_Model_class; +extern se::Object *__jsb_cc_scene_Shadows_proto; // NOLINT +extern se::Class * __jsb_cc_scene_Shadows_class; // NOLINT -bool js_register_cc_scene_Model(se::Object* obj); -bool register_all_scene(se::Object* obj); +bool js_register_cc_scene_Shadows(se::Object *obj); // NOLINT -JSB_REGISTER_OBJECT_TYPE(cc::scene::Model); -SE_DECLARE_FUNC(js_scene_Model_getCastShadow); -SE_DECLARE_FUNC(js_scene_Model_getEnabled); -SE_DECLARE_FUNC(js_scene_Model_getInstMatWorldIdx); -SE_DECLARE_FUNC(js_scene_Model_getInstanceAttributes); -SE_DECLARE_FUNC(js_scene_Model_getInstancedAttributeBlock); -SE_DECLARE_FUNC(js_scene_Model_getInstancedBuffer); -SE_DECLARE_FUNC(js_scene_Model_getInstancedBufferSize); -SE_DECLARE_FUNC(js_scene_Model_getLocalData); -SE_DECLARE_FUNC(js_scene_Model_getNode); -SE_DECLARE_FUNC(js_scene_Model_getReceiveShadow); -SE_DECLARE_FUNC(js_scene_Model_getSubModels); -SE_DECLARE_FUNC(js_scene_Model_getTransform); -SE_DECLARE_FUNC(js_scene_Model_getTransformUpdated); -SE_DECLARE_FUNC(js_scene_Model_getUpdatStamp); -SE_DECLARE_FUNC(js_scene_Model_getVisFlags); -SE_DECLARE_FUNC(js_scene_Model_getWorldBoundBuffer); -SE_DECLARE_FUNC(js_scene_Model_seVisFlag); -SE_DECLARE_FUNC(js_scene_Model_setBounds); -SE_DECLARE_FUNC(js_scene_Model_setCastShadow); -SE_DECLARE_FUNC(js_scene_Model_setEnabled); -SE_DECLARE_FUNC(js_scene_Model_setInstMatWorldIdx); -SE_DECLARE_FUNC(js_scene_Model_setLocalBuffer); -SE_DECLARE_FUNC(js_scene_Model_setNode); -SE_DECLARE_FUNC(js_scene_Model_setReceiveShadow); -SE_DECLARE_FUNC(js_scene_Model_setSubModel); -SE_DECLARE_FUNC(js_scene_Model_setTransform); -SE_DECLARE_FUNC(js_scene_Model_setWorldBoundBuffer); -SE_DECLARE_FUNC(js_scene_Model_updateTransform); -SE_DECLARE_FUNC(js_scene_Model_updateUBOs); -SE_DECLARE_FUNC(js_scene_Model_updateWorldBoundUBOs); -SE_DECLARE_FUNC(js_scene_Model_Model); +SE_DECLARE_FUNC(js_scene_Shadows_activate); +SE_DECLARE_FUNC(js_scene_Shadows_destroy); +SE_DECLARE_FUNC(js_scene_Shadows_getMaterial); +SE_DECLARE_FUNC(js_scene_Shadows_getMaxReceived); +SE_DECLARE_FUNC(js_scene_Shadows_getPlanarInstanceShader); +SE_DECLARE_FUNC(js_scene_Shadows_getPlanarShader); +SE_DECLARE_FUNC(js_scene_Shadows_getShadowColor4f); +SE_DECLARE_FUNC(js_scene_Shadows_getShadowDistance); +SE_DECLARE_FUNC(js_scene_Shadows_getShadowMapSize); +SE_DECLARE_FUNC(js_scene_Shadows_initialize); +SE_DECLARE_FUNC(js_scene_Shadows_isFixedArea); +SE_DECLARE_FUNC(js_scene_Shadows_setMaxReceived); +SE_DECLARE_FUNC(js_scene_Shadows_setShadowDistance); +SE_DECLARE_FUNC(js_scene_Shadows_setShadowMapSize); +SE_DECLARE_FUNC(js_scene_Shadows_Shadows); -extern se::Object* __jsb_cc_scene_Fog_proto; -extern se::Class* __jsb_cc_scene_Fog_class; +extern se::Object *__jsb_cc_scene_ICameraInfo_proto; // NOLINT +extern se::Class * __jsb_cc_scene_ICameraInfo_class; // NOLINT -bool js_register_cc_scene_Fog(se::Object* obj); -bool register_all_scene(se::Object* obj); +bool js_register_cc_scene_ICameraInfo(se::Object *obj); // NOLINT -template<> -bool sevalue_to_native(const se::Value &, cc::scene::Fog *, se::Object *ctx); -JSB_REGISTER_OBJECT_TYPE(cc::scene::Fog); +template <> +bool sevalue_to_native(const se::Value &, cc::scene::ICameraInfo *, se::Object *ctx); //NOLINT -extern se::Object* __jsb_cc_scene_Shadow_proto; -extern se::Class* __jsb_cc_scene_Shadow_class; +extern se::Object *__jsb_cc_scene_Camera_proto; // NOLINT +extern se::Class * __jsb_cc_scene_Camera_class; // NOLINT -bool js_register_cc_scene_Shadow(se::Object* obj); -bool register_all_scene(se::Object* obj); +bool js_register_cc_scene_Camera(se::Object *obj); // NOLINT -template<> -bool sevalue_to_native(const se::Value &, cc::scene::Shadow *, se::Object *ctx); -JSB_REGISTER_OBJECT_TYPE(cc::scene::Shadow); +SE_DECLARE_FUNC(js_scene_Camera_attachToScene); +SE_DECLARE_FUNC(js_scene_Camera_changeTargetWindow); +SE_DECLARE_FUNC(js_scene_Camera_destroy); +SE_DECLARE_FUNC(js_scene_Camera_detachCamera); +SE_DECLARE_FUNC(js_scene_Camera_detachFromScene); +SE_DECLARE_FUNC(js_scene_Camera_initialize); +SE_DECLARE_FUNC(js_scene_Camera_resize); +SE_DECLARE_FUNC(js_scene_Camera_setFixedSize); +SE_DECLARE_FUNC(js_scene_Camera_setViewportInOrientedSpace); +SE_DECLARE_FUNC(js_scene_Camera_update); +SE_DECLARE_FUNC(js_scene_Camera_getStandardExposureValue); +SE_DECLARE_FUNC(js_scene_Camera_getStandardLightMeterScale); +SE_DECLARE_FUNC(js_scene_Camera_Camera); -extern se::Object* __jsb_cc_scene_Skybox_proto; -extern se::Class* __jsb_cc_scene_Skybox_class; +extern se::Object *__jsb_cc_scene_SubModel_proto; // NOLINT +extern se::Class * __jsb_cc_scene_SubModel_class; // NOLINT -bool js_register_cc_scene_Skybox(se::Object* obj); -bool register_all_scene(se::Object* obj); +bool js_register_cc_scene_SubModel(se::Object *obj); // NOLINT -template<> -bool sevalue_to_native(const se::Value &, cc::scene::Skybox *, se::Object *ctx); -JSB_REGISTER_OBJECT_TYPE(cc::scene::Skybox); - -extern se::Object* __jsb_cc_scene_Ambient_proto; -extern se::Class* __jsb_cc_scene_Ambient_class; - -bool js_register_cc_scene_Ambient(se::Object* obj); -bool register_all_scene(se::Object* obj); - -template<> -bool sevalue_to_native(const se::Value &, cc::scene::Ambient *, se::Object *ctx); -JSB_REGISTER_OBJECT_TYPE(cc::scene::Ambient); - -extern se::Object* __jsb_cc_scene_OctreeInfo_proto; -extern se::Class* __jsb_cc_scene_OctreeInfo_class; - -bool js_register_cc_scene_OctreeInfo(se::Object* obj); -bool register_all_scene(se::Object* obj); - -template<> -bool sevalue_to_native(const se::Value &, cc::scene::OctreeInfo *, se::Object *ctx); -JSB_REGISTER_OBJECT_TYPE(cc::scene::OctreeInfo); - -extern se::Object* __jsb_cc_scene_PipelineSharedSceneData_proto; -extern se::Class* __jsb_cc_scene_PipelineSharedSceneData_class; - -bool js_register_cc_scene_PipelineSharedSceneData(se::Object* obj); -bool register_all_scene(se::Object* obj); - -template<> -bool sevalue_to_native(const se::Value &, cc::scene::PipelineSharedSceneData *, se::Object *ctx); -JSB_REGISTER_OBJECT_TYPE(cc::scene::PipelineSharedSceneData); - -extern se::Object* __jsb_cc_scene_Root_proto; -extern se::Class* __jsb_cc_scene_Root_class; - -bool js_register_cc_scene_Root(se::Object* obj); -bool register_all_scene(se::Object* obj); - -template<> -bool sevalue_to_native(const se::Value &, cc::scene::Root *, se::Object *ctx); -JSB_REGISTER_OBJECT_TYPE(cc::scene::Root); - -extern se::Object* __jsb_cc_scene_SubModel_proto; -extern se::Class* __jsb_cc_scene_SubModel_class; - -bool js_register_cc_scene_SubModel(se::Object* obj); -bool register_all_scene(se::Object* obj); - -JSB_REGISTER_OBJECT_TYPE(cc::scene::SubModel); +SE_DECLARE_FUNC(js_scene_SubModel_destroy); SE_DECLARE_FUNC(js_scene_SubModel_getId); SE_DECLARE_FUNC(js_scene_SubModel_getOwner); SE_DECLARE_FUNC(js_scene_SubModel_getPass); -SE_DECLARE_FUNC(js_scene_SubModel_getPasses); -SE_DECLARE_FUNC(js_scene_SubModel_getPlanarInstanceShader); -SE_DECLARE_FUNC(js_scene_SubModel_getPlanarShader); -SE_DECLARE_FUNC(js_scene_SubModel_getPriority); SE_DECLARE_FUNC(js_scene_SubModel_getShader); -SE_DECLARE_FUNC(js_scene_SubModel_getShaders); SE_DECLARE_FUNC(js_scene_SubModel_getWorldBoundDescriptorSet); -SE_DECLARE_FUNC(js_scene_SubModel_setDescriptorSet); -SE_DECLARE_FUNC(js_scene_SubModel_setInputAssembler); +SE_DECLARE_FUNC(js_scene_SubModel_initPlanarShadowInstanceShader); +SE_DECLARE_FUNC(js_scene_SubModel_initPlanarShadowShader); +SE_DECLARE_FUNC(js_scene_SubModel_initialize); +SE_DECLARE_FUNC(js_scene_SubModel_onMacroPatchesStateChanged); +SE_DECLARE_FUNC(js_scene_SubModel_onPipelineStateChanged); SE_DECLARE_FUNC(js_scene_SubModel_setOwner); -SE_DECLARE_FUNC(js_scene_SubModel_setPasses); -SE_DECLARE_FUNC(js_scene_SubModel_setPlanarInstanceShader); -SE_DECLARE_FUNC(js_scene_SubModel_setPlanarShader); -SE_DECLARE_FUNC(js_scene_SubModel_setPriority); -SE_DECLARE_FUNC(js_scene_SubModel_setShaders); SE_DECLARE_FUNC(js_scene_SubModel_setWorldBoundDescriptorSet); SE_DECLARE_FUNC(js_scene_SubModel_update); SE_DECLARE_FUNC(js_scene_SubModel_SubModel); -extern se::Object* __jsb_cc_scene_Pass_proto; -extern se::Class* __jsb_cc_scene_Pass_class; +extern se::Object *__jsb_cc_scene_InstancedAttributeBlock_proto; // NOLINT +extern se::Class * __jsb_cc_scene_InstancedAttributeBlock_class; // NOLINT -bool js_register_cc_scene_Pass(se::Object* obj); -bool register_all_scene(se::Object* obj); +bool js_register_cc_scene_InstancedAttributeBlock(se::Object *obj); // NOLINT -JSB_REGISTER_OBJECT_TYPE(cc::scene::Pass); -SE_DECLARE_FUNC(js_scene_Pass_getBatchingScheme); -SE_DECLARE_FUNC(js_scene_Pass_getBlendState); -SE_DECLARE_FUNC(js_scene_Pass_getDepthStencilState); -SE_DECLARE_FUNC(js_scene_Pass_getDescriptorSet); -SE_DECLARE_FUNC(js_scene_Pass_getDynamicState); -SE_DECLARE_FUNC(js_scene_Pass_getHash); -SE_DECLARE_FUNC(js_scene_Pass_getPhase); -SE_DECLARE_FUNC(js_scene_Pass_getPipelineLayout); -SE_DECLARE_FUNC(js_scene_Pass_getPrimitive); -SE_DECLARE_FUNC(js_scene_Pass_getPriority); -SE_DECLARE_FUNC(js_scene_Pass_getRasterizerState); -SE_DECLARE_FUNC(js_scene_Pass_getStage); -SE_DECLARE_FUNC(js_scene_Pass_initWithData); -SE_DECLARE_FUNC(js_scene_Pass_setBatchingScheme); -SE_DECLARE_FUNC(js_scene_Pass_setBlendState); -SE_DECLARE_FUNC(js_scene_Pass_setDepthStencilState); -SE_DECLARE_FUNC(js_scene_Pass_setDescriptorSet); -SE_DECLARE_FUNC(js_scene_Pass_setDynamicState); -SE_DECLARE_FUNC(js_scene_Pass_setHash); -SE_DECLARE_FUNC(js_scene_Pass_setPhase); -SE_DECLARE_FUNC(js_scene_Pass_setPipelineLayout); -SE_DECLARE_FUNC(js_scene_Pass_setPrimitive); -SE_DECLARE_FUNC(js_scene_Pass_setPriority); -SE_DECLARE_FUNC(js_scene_Pass_setRasterizerState); -SE_DECLARE_FUNC(js_scene_Pass_setRootBufferDirty); -SE_DECLARE_FUNC(js_scene_Pass_setStage); -SE_DECLARE_FUNC(js_scene_Pass_update); -SE_DECLARE_FUNC(js_scene_Pass_Pass); +template <> +bool sevalue_to_native(const se::Value &, cc::scene::InstancedAttributeBlock *, se::Object *ctx); //NOLINT -extern se::Object* __jsb_cc_scene_BakedAnimInfo_proto; -extern se::Class* __jsb_cc_scene_BakedAnimInfo_class; +extern se::Object *__jsb_cc_scene_Model_proto; // NOLINT +extern se::Class * __jsb_cc_scene_Model_class; // NOLINT -bool js_register_cc_scene_BakedAnimInfo(se::Object* obj); -bool register_all_scene(se::Object* obj); +bool js_register_cc_scene_Model(se::Object *obj); // NOLINT -template<> -bool sevalue_to_native(const se::Value &, cc::scene::BakedAnimInfo *, se::Object *ctx); -JSB_REGISTER_OBJECT_TYPE(cc::scene::BakedAnimInfo); -SE_DECLARE_FUNC(js_scene_BakedAnimInfo_getDirty); +SE_DECLARE_FUNC(js_scene_Model_attachToScene); +SE_DECLARE_FUNC(js_scene_Model_createBoundingShape); +SE_DECLARE_FUNC(js_scene_Model_destroy); +SE_DECLARE_FUNC(js_scene_Model_detachFromScene); +SE_DECLARE_FUNC(js_scene_Model_getInstMatWorldIdx); +SE_DECLARE_FUNC(js_scene_Model_getInstanceAttributes); +SE_DECLARE_FUNC(js_scene_Model_getInstancedAttributeIndex); +SE_DECLARE_FUNC(js_scene_Model_getInstancedBuffer); +SE_DECLARE_FUNC(js_scene_Model_getInstancedBufferSize); +SE_DECLARE_FUNC(js_scene_Model_getLocalData); +SE_DECLARE_FUNC(js_scene_Model_getMacroPatches); +SE_DECLARE_FUNC(js_scene_Model_initLocalDescriptors); +SE_DECLARE_FUNC(js_scene_Model_initSubModel); +SE_DECLARE_FUNC(js_scene_Model_initWorldBoundDescriptors); +SE_DECLARE_FUNC(js_scene_Model_initialize); +SE_DECLARE_FUNC(js_scene_Model_isModelImplementedInJS); +SE_DECLARE_FUNC(js_scene_Model_onGlobalPipelineStateChanged); +SE_DECLARE_FUNC(js_scene_Model_onMacroPatchesStateChanged); +SE_DECLARE_FUNC(js_scene_Model_setBounds); +SE_DECLARE_FUNC(js_scene_Model_setCalledFromJS); +SE_DECLARE_FUNC(js_scene_Model_setInstMatWorldIdx); +SE_DECLARE_FUNC(js_scene_Model_setInstancedAttributesViewData); +SE_DECLARE_FUNC(js_scene_Model_setSubModelMaterial); +SE_DECLARE_FUNC(js_scene_Model_setSubModelMesh); +SE_DECLARE_FUNC(js_scene_Model_updateInstancedAttributes); +SE_DECLARE_FUNC(js_scene_Model_updateLightingmap); +SE_DECLARE_FUNC(js_scene_Model_updateLocalDescriptors); +SE_DECLARE_FUNC(js_scene_Model_updateTransform); +SE_DECLARE_FUNC(js_scene_Model_updateUBOs); +SE_DECLARE_FUNC(js_scene_Model_updateWorldBound); +SE_DECLARE_FUNC(js_scene_Model_updateWorldBoundDescriptors); +SE_DECLARE_FUNC(js_scene_Model_updateWorldBoundUBOs); +SE_DECLARE_FUNC(js_scene_Model_updateWorldBoundsForJSBakedSkinningModel); +SE_DECLARE_FUNC(js_scene_Model_updateWorldBoundsForJSSkinningModel); +SE_DECLARE_FUNC(js_scene_Model_Model); -extern se::Object* __jsb_cc_scene_BakedJointInfo_proto; -extern se::Class* __jsb_cc_scene_BakedJointInfo_class; +extern se::Object *__jsb_cc_scene_DrawBatch2D_proto; // NOLINT +extern se::Class * __jsb_cc_scene_DrawBatch2D_class; // NOLINT -bool js_register_cc_scene_BakedJointInfo(se::Object* obj); -bool register_all_scene(se::Object* obj); +bool js_register_cc_scene_DrawBatch2D(se::Object *obj); // NOLINT -template<> -bool sevalue_to_native(const se::Value &, cc::scene::BakedJointInfo *, se::Object *ctx); -JSB_REGISTER_OBJECT_TYPE(cc::scene::BakedJointInfo); +template <> +bool sevalue_to_native(const se::Value &, cc::scene::DrawBatch2D *, se::Object *ctx); //NOLINT -extern se::Object* __jsb_cc_scene_BakedSkinningModel_proto; -extern se::Class* __jsb_cc_scene_BakedSkinningModel_class; +extern se::Object *__jsb_cc_scene_IRenderSceneInfo_proto; // NOLINT +extern se::Class * __jsb_cc_scene_IRenderSceneInfo_class; // NOLINT -bool js_register_cc_scene_BakedSkinningModel(se::Object* obj); -bool register_all_scene(se::Object* obj); +bool js_register_cc_scene_IRenderSceneInfo(se::Object *obj); // NOLINT -JSB_REGISTER_OBJECT_TYPE(cc::scene::BakedSkinningModel); -SE_DECLARE_FUNC(js_scene_BakedSkinningModel_setAnimInfoIdx); -SE_DECLARE_FUNC(js_scene_BakedSkinningModel_setJointMedium); -SE_DECLARE_FUNC(js_scene_BakedSkinningModel_updateModelBounds); -SE_DECLARE_FUNC(js_scene_BakedSkinningModel_BakedSkinningModel); +template <> +bool sevalue_to_native(const se::Value &, cc::scene::IRenderSceneInfo *, se::Object *ctx); //NOLINT -extern se::Object* __jsb_cc_scene_DrawBatch2D_proto; -extern se::Class* __jsb_cc_scene_DrawBatch2D_class; +extern se::Object *__jsb_cc_scene_RenderScene_proto; // NOLINT +extern se::Class * __jsb_cc_scene_RenderScene_class; // NOLINT -bool js_register_cc_scene_DrawBatch2D(se::Object* obj); -bool register_all_scene(se::Object* obj); +bool js_register_cc_scene_RenderScene(se::Object *obj); // NOLINT -template<> -bool sevalue_to_native(const se::Value &, cc::scene::DrawBatch2D *, se::Object *ctx); -JSB_REGISTER_OBJECT_TYPE(cc::scene::DrawBatch2D); - -extern se::Object* __jsb_cc_scene_JointTransform_proto; -extern se::Class* __jsb_cc_scene_JointTransform_class; - -bool js_register_cc_scene_JointTransform(se::Object* obj); -bool register_all_scene(se::Object* obj); - -template<> -bool sevalue_to_native(const se::Value &, cc::scene::JointTransform *, se::Object *ctx); -JSB_REGISTER_OBJECT_TYPE(cc::scene::JointTransform); - -extern se::Object* __jsb_cc_scene_JointInfo_proto; -extern se::Class* __jsb_cc_scene_JointInfo_class; - -bool js_register_cc_scene_JointInfo(se::Object* obj); -bool register_all_scene(se::Object* obj); - -template<> -bool sevalue_to_native(const se::Value &, cc::scene::JointInfo *, se::Object *ctx); -JSB_REGISTER_OBJECT_TYPE(cc::scene::JointInfo); - -extern se::Object* __jsb_cc_scene_SkinningModel_proto; -extern se::Class* __jsb_cc_scene_SkinningModel_class; - -bool js_register_cc_scene_SkinningModel(se::Object* obj); -bool register_all_scene(se::Object* obj); - -JSB_REGISTER_OBJECT_TYPE(cc::scene::SkinningModel); -SE_DECLARE_FUNC(js_scene_SkinningModel_setBuffers); -SE_DECLARE_FUNC(js_scene_SkinningModel_setIndicesAndJoints); -SE_DECLARE_FUNC(js_scene_SkinningModel_setNeedUpdate); -SE_DECLARE_FUNC(js_scene_SkinningModel_updateLocalDescriptors); -SE_DECLARE_FUNC(js_scene_SkinningModel_SkinningModel); - -extern se::Object* __jsb_cc_scene_RenderScene_proto; -extern se::Class* __jsb_cc_scene_RenderScene_class; - -bool js_register_cc_scene_RenderScene(se::Object* obj); -bool register_all_scene(se::Object* obj); - -JSB_REGISTER_OBJECT_TYPE(cc::scene::RenderScene); SE_DECLARE_FUNC(js_scene_RenderScene_activate); -SE_DECLARE_FUNC(js_scene_RenderScene_addBakedSkinningModel); SE_DECLARE_FUNC(js_scene_RenderScene_addBatch); +SE_DECLARE_FUNC(js_scene_RenderScene_addCamera); +SE_DECLARE_FUNC(js_scene_RenderScene_addDirectionalLight); SE_DECLARE_FUNC(js_scene_RenderScene_addModel); -SE_DECLARE_FUNC(js_scene_RenderScene_addSkinningModel); SE_DECLARE_FUNC(js_scene_RenderScene_addSphereLight); SE_DECLARE_FUNC(js_scene_RenderScene_addSpotLight); +SE_DECLARE_FUNC(js_scene_RenderScene_destroy); +SE_DECLARE_FUNC(js_scene_RenderScene_generateModelId); +SE_DECLARE_FUNC(js_scene_RenderScene_getBatches); SE_DECLARE_FUNC(js_scene_RenderScene_getDrawBatch2Ds); -SE_DECLARE_FUNC(js_scene_RenderScene_getMainLight); -SE_DECLARE_FUNC(js_scene_RenderScene_getModels); -SE_DECLARE_FUNC(js_scene_RenderScene_getSphereLights); -SE_DECLARE_FUNC(js_scene_RenderScene_getSpotLights); +SE_DECLARE_FUNC(js_scene_RenderScene_getOctree); +SE_DECLARE_FUNC(js_scene_RenderScene_initialize); +SE_DECLARE_FUNC(js_scene_RenderScene_onGlobalPipelineStateChanged); SE_DECLARE_FUNC(js_scene_RenderScene_removeBatch); SE_DECLARE_FUNC(js_scene_RenderScene_removeBatches); +SE_DECLARE_FUNC(js_scene_RenderScene_removeCamera); +SE_DECLARE_FUNC(js_scene_RenderScene_removeCameras); +SE_DECLARE_FUNC(js_scene_RenderScene_removeDirectionalLight); SE_DECLARE_FUNC(js_scene_RenderScene_removeModel); SE_DECLARE_FUNC(js_scene_RenderScene_removeModels); SE_DECLARE_FUNC(js_scene_RenderScene_removeSphereLight); SE_DECLARE_FUNC(js_scene_RenderScene_removeSphereLights); SE_DECLARE_FUNC(js_scene_RenderScene_removeSpotLight); SE_DECLARE_FUNC(js_scene_RenderScene_removeSpotLights); -SE_DECLARE_FUNC(js_scene_RenderScene_setMainLight); +SE_DECLARE_FUNC(js_scene_RenderScene_unsetMainLight); SE_DECLARE_FUNC(js_scene_RenderScene_update); +SE_DECLARE_FUNC(js_scene_RenderScene_updateOctree); SE_DECLARE_FUNC(js_scene_RenderScene_RenderScene); -extern se::Object* __jsb_cc_scene_RenderWindow_proto; -extern se::Class* __jsb_cc_scene_RenderWindow_class; +extern se::Object *__jsb_cc_scene_IRenderWindowInfo_proto; // NOLINT +extern se::Class * __jsb_cc_scene_IRenderWindowInfo_class; // NOLINT -bool js_register_cc_scene_RenderWindow(se::Object* obj); -bool register_all_scene(se::Object* obj); +bool js_register_cc_scene_IRenderWindowInfo(se::Object *obj); // NOLINT -template<> -bool sevalue_to_native(const se::Value &, cc::scene::RenderWindow *, se::Object *ctx); -JSB_REGISTER_OBJECT_TYPE(cc::scene::RenderWindow); -SE_DECLARE_FUNC(js_scene_RenderWindow_getHeight); -SE_DECLARE_FUNC(js_scene_RenderWindow_getWidth); +template <> +bool sevalue_to_native(const se::Value &, cc::scene::IRenderWindowInfo *, se::Object *ctx); //NOLINT -extern se::Object* __jsb_cc_scene_Camera_proto; -extern se::Class* __jsb_cc_scene_Camera_class; +extern se::Object *__jsb_cc_scene_RenderWindow_proto; // NOLINT +extern se::Class * __jsb_cc_scene_RenderWindow_class; // NOLINT -bool js_register_cc_scene_Camera(se::Object* obj); -bool register_all_scene(se::Object* obj); +bool js_register_cc_scene_RenderWindow(se::Object *obj); // NOLINT -template<> -bool sevalue_to_native(const se::Value &, cc::scene::Camera *, se::Object *ctx); -JSB_REGISTER_OBJECT_TYPE(cc::scene::Camera); +SE_DECLARE_FUNC(js_scene_RenderWindow_attachCamera); +SE_DECLARE_FUNC(js_scene_RenderWindow_clearCameras); +SE_DECLARE_FUNC(js_scene_RenderWindow_destroy); +SE_DECLARE_FUNC(js_scene_RenderWindow_detachCamera); +SE_DECLARE_FUNC(js_scene_RenderWindow_extractRenderCameras); +SE_DECLARE_FUNC(js_scene_RenderWindow_initialize); +SE_DECLARE_FUNC(js_scene_RenderWindow_resize); +SE_DECLARE_FUNC(js_scene_RenderWindow_sortCameras); +SE_DECLARE_FUNC(js_scene_RenderWindow_RenderWindow); -extern se::Object* __jsb_cc_scene_Sphere_proto; -extern se::Class* __jsb_cc_scene_Sphere_class; +extern se::Object *__jsb_cc_scene_SphereLight_proto; // NOLINT +extern se::Class * __jsb_cc_scene_SphereLight_class; // NOLINT -bool js_register_cc_scene_Sphere(se::Object* obj); -bool register_all_scene(se::Object* obj); +bool js_register_cc_scene_SphereLight(se::Object *obj); // NOLINT -JSB_REGISTER_OBJECT_TYPE(cc::scene::Sphere); -SE_DECLARE_FUNC(js_scene_Sphere_getCenter); -SE_DECLARE_FUNC(js_scene_Sphere_getRadius); -SE_DECLARE_FUNC(js_scene_Sphere_setCenter); -SE_DECLARE_FUNC(js_scene_Sphere_setRadius); -SE_DECLARE_FUNC(js_scene_Sphere_Sphere); +SE_DECLARE_FUNC(js_scene_SphereLight_SphereLight); +extern se::Object *__jsb_cc_Root_proto; // NOLINT +extern se::Class * __jsb_cc_Root_class; // NOLINT + +bool js_register_cc_Root(se::Object *obj); // NOLINT + +SE_DECLARE_FUNC(js_scene_Root_activeWindow); +SE_DECLARE_FUNC(js_scene_Root_createCamera); +SE_DECLARE_FUNC(js_scene_Root_createScene); +SE_DECLARE_FUNC(js_scene_Root_createWindow); +SE_DECLARE_FUNC(js_scene_Root_destroy); +SE_DECLARE_FUNC(js_scene_Root_destroyLight); +SE_DECLARE_FUNC(js_scene_Root_destroyModel); +SE_DECLARE_FUNC(js_scene_Root_destroyScene); +SE_DECLARE_FUNC(js_scene_Root_destroyScenes); +SE_DECLARE_FUNC(js_scene_Root_destroyWindow); +SE_DECLARE_FUNC(js_scene_Root_destroyWindows); +SE_DECLARE_FUNC(js_scene_Root_frameMove); +SE_DECLARE_FUNC(js_scene_Root_getBatcher2D); +SE_DECLARE_FUNC(js_scene_Root_getEventProcessor); +SE_DECLARE_FUNC(js_scene_Root_getPipeline); +SE_DECLARE_FUNC(js_scene_Root_initialize); +SE_DECLARE_FUNC(js_scene_Root_onGlobalPipelineStateChanged); +SE_DECLARE_FUNC(js_scene_Root_resetCumulativeTime); +SE_DECLARE_FUNC(js_scene_Root_resize); +SE_DECLARE_FUNC(js_scene_Root_setRenderPipeline); +SE_DECLARE_FUNC(js_scene_Root_getInstance); +SE_DECLARE_FUNC(js_scene_Root_Root); + +extern se::Object *__jsb_cc_scene_SkyboxInfo_proto; // NOLINT +extern se::Class * __jsb_cc_scene_SkyboxInfo_class; // NOLINT + +bool js_register_cc_scene_SkyboxInfo(se::Object *obj); // NOLINT + +SE_DECLARE_FUNC(js_scene_SkyboxInfo_activate); +SE_DECLARE_FUNC(js_scene_SkyboxInfo_getEnvamp); +SE_DECLARE_FUNC(js_scene_SkyboxInfo_SkyboxInfo); + +extern se::Object *__jsb_cc_scene_Skybox_proto; // NOLINT +extern se::Class * __jsb_cc_scene_Skybox_class; // NOLINT + +bool js_register_cc_scene_Skybox(se::Object *obj); // NOLINT + +SE_DECLARE_FUNC(js_scene_Skybox_activate); +SE_DECLARE_FUNC(js_scene_Skybox_getDiffuseMap); +SE_DECLARE_FUNC(js_scene_Skybox_initialize); +SE_DECLARE_FUNC(js_scene_Skybox_isUseDiffuseMap); +SE_DECLARE_FUNC(js_scene_Skybox_isUseHDR); +SE_DECLARE_FUNC(js_scene_Skybox_setDiffuseMap); +SE_DECLARE_FUNC(js_scene_Skybox_setDiffuseMaps); +SE_DECLARE_FUNC(js_scene_Skybox_setEnvMaps); +SE_DECLARE_FUNC(js_scene_Skybox_setUseDiffuseMap); +SE_DECLARE_FUNC(js_scene_Skybox_setUseHDR); +SE_DECLARE_FUNC(js_scene_Skybox_Skybox); + +extern se::Object *__jsb_cc_scene_Ambient_proto; // NOLINT +extern se::Class * __jsb_cc_scene_Ambient_class; // NOLINT + +bool js_register_cc_scene_Ambient(se::Object *obj); // NOLINT + +SE_DECLARE_FUNC(js_scene_Ambient_initialize); +SE_DECLARE_FUNC(js_scene_Ambient_Ambient); + +extern se::Object *__jsb_cc_scene_AmbientInfo_proto; // NOLINT +extern se::Class * __jsb_cc_scene_AmbientInfo_class; // NOLINT + +bool js_register_cc_scene_AmbientInfo(se::Object *obj); // NOLINT + +SE_DECLARE_FUNC(js_scene_AmbientInfo_getGroundAlbedoHDR); +SE_DECLARE_FUNC(js_scene_AmbientInfo_getGroundAlbedoLDR); +SE_DECLARE_FUNC(js_scene_AmbientInfo_getGroundLightingColor); +SE_DECLARE_FUNC(js_scene_AmbientInfo_getSkyColorHDR); +SE_DECLARE_FUNC(js_scene_AmbientInfo_getSkyColorLDR); +SE_DECLARE_FUNC(js_scene_AmbientInfo_getSkyIllumHDR); +SE_DECLARE_FUNC(js_scene_AmbientInfo_getSkyIllumLDR); +SE_DECLARE_FUNC(js_scene_AmbientInfo_getSkyLightingColor); +SE_DECLARE_FUNC(js_scene_AmbientInfo_setGroundLightingColor); +SE_DECLARE_FUNC(js_scene_AmbientInfo_setSkyLightingColor); +SE_DECLARE_FUNC(js_scene_AmbientInfo_AmbientInfo); + +extern se::Object *__jsb_cc_scene_DirectionalLight_proto; // NOLINT +extern se::Class * __jsb_cc_scene_DirectionalLight_class; // NOLINT + +bool js_register_cc_scene_DirectionalLight(se::Object *obj); // NOLINT + +SE_DECLARE_FUNC(js_scene_DirectionalLight_DirectionalLight); + +extern se::Object *__jsb_cc_scene_SpotLight_proto; // NOLINT +extern se::Class * __jsb_cc_scene_SpotLight_class; // NOLINT + +bool js_register_cc_scene_SpotLight(se::Object *obj); // NOLINT + +SE_DECLARE_FUNC(js_scene_SpotLight_SpotLight); + +extern se::Object *__jsb_cc_IMaterialInstanceInfo_proto; // NOLINT +extern se::Class * __jsb_cc_IMaterialInstanceInfo_class; // NOLINT + +bool js_register_cc_IMaterialInstanceInfo(se::Object *obj); // NOLINT + +template <> +bool sevalue_to_native(const se::Value &, cc::IMaterialInstanceInfo *, se::Object *ctx); //NOLINT + +extern se::Object *__jsb_cc_MaterialInstance_proto; // NOLINT +extern se::Class * __jsb_cc_MaterialInstance_class; // NOLINT + +bool js_register_cc_MaterialInstance(se::Object *obj); // NOLINT + +SE_DECLARE_FUNC(js_scene_MaterialInstance_onPassStateChange); +SE_DECLARE_FUNC(js_scene_MaterialInstance_setRebuildPSOCallback); +SE_DECLARE_FUNC(js_scene_MaterialInstance_MaterialInstance); + +extern se::Object *__jsb_cc_PassInstance_proto; // NOLINT +extern se::Class * __jsb_cc_PassInstance_class; // NOLINT + +bool js_register_cc_PassInstance(se::Object *obj); // NOLINT + +SE_DECLARE_FUNC(js_scene_PassInstance_PassInstance); + +extern se::Object *__jsb_cc_MorphModel_proto; // NOLINT +extern se::Class * __jsb_cc_MorphModel_class; // NOLINT + +bool js_register_cc_MorphModel(se::Object *obj); // NOLINT + +SE_DECLARE_FUNC(js_scene_MorphModel_setMorphRendering); +SE_DECLARE_FUNC(js_scene_MorphModel_MorphModel); + +extern se::Object *__jsb_cc_SkinningModel_proto; // NOLINT +extern se::Class * __jsb_cc_SkinningModel_class; // NOLINT + +bool js_register_cc_SkinningModel(se::Object *obj); // NOLINT + +SE_DECLARE_FUNC(js_scene_SkinningModel_bindSkeleton); +SE_DECLARE_FUNC(js_scene_SkinningModel_SkinningModel); + +extern se::Object *__jsb_cc_BakedSkinningModel_proto; // NOLINT +extern se::Class * __jsb_cc_BakedSkinningModel_class; // NOLINT + +bool js_register_cc_BakedSkinningModel(se::Object *obj); // NOLINT + +SE_DECLARE_FUNC(js_scene_BakedSkinningModel_bindSkeleton); +SE_DECLARE_FUNC(js_scene_BakedSkinningModel_setUploadedAnimForJS); +SE_DECLARE_FUNC(js_scene_BakedSkinningModel_syncAnimInfoForJS); +SE_DECLARE_FUNC(js_scene_BakedSkinningModel_syncDataForJS); +SE_DECLARE_FUNC(js_scene_BakedSkinningModel_BakedSkinningModel); + +extern se::Object *__jsb_cc_IDefineRecord_proto; // NOLINT +extern se::Class * __jsb_cc_IDefineRecord_class; // NOLINT + +bool js_register_cc_IDefineRecord(se::Object *obj); // NOLINT + +template <> +bool sevalue_to_native(const se::Value &, cc::IDefineRecord *, se::Object *ctx); //NOLINT + +extern se::Object *__jsb_cc_IProgramInfo_proto; // NOLINT +extern se::Class * __jsb_cc_IProgramInfo_class; // NOLINT + +bool js_register_cc_IProgramInfo(se::Object *obj); // NOLINT + +template <> +bool sevalue_to_native(const se::Value &, cc::IProgramInfo *, se::Object *ctx); //NOLINT +SE_DECLARE_FUNC(js_scene_IProgramInfo_copyFrom); + +extern se::Object *__jsb_cc_ProgramLib_proto; // NOLINT +extern se::Class * __jsb_cc_ProgramLib_class; // NOLINT + +bool js_register_cc_ProgramLib(se::Object *obj); // NOLINT + +SE_DECLARE_FUNC(js_scene_ProgramLib_define); +SE_DECLARE_FUNC(js_scene_ProgramLib_destroyShaderByDefines); +SE_DECLARE_FUNC(js_scene_ProgramLib_getDescriptorSetLayout); +SE_DECLARE_FUNC(js_scene_ProgramLib_getGFXShader); +SE_DECLARE_FUNC(js_scene_ProgramLib_getKey); +SE_DECLARE_FUNC(js_scene_ProgramLib_getTemplate); +SE_DECLARE_FUNC(js_scene_ProgramLib_getTemplateInfo); +SE_DECLARE_FUNC(js_scene_ProgramLib_hasProgram); +SE_DECLARE_FUNC(js_scene_ProgramLib_registerEffect); +SE_DECLARE_FUNC(js_scene_ProgramLib_getInstance); +SE_DECLARE_FUNC(js_scene_ProgramLib_ProgramLib); + +extern se::Object *__jsb_cc_scene_OctreeInfo_proto; // NOLINT +extern se::Class * __jsb_cc_scene_OctreeInfo_class; // NOLINT + +bool js_register_cc_scene_OctreeInfo(se::Object *obj); // NOLINT + +SE_DECLARE_FUNC(js_scene_OctreeInfo_activate); +SE_DECLARE_FUNC(js_scene_OctreeInfo_OctreeInfo); + +extern se::Object *__jsb_cc_scene_Octree_proto; // NOLINT +extern se::Class * __jsb_cc_scene_Octree_class; // NOLINT + +bool js_register_cc_scene_Octree(se::Object *obj); // NOLINT + +SE_DECLARE_FUNC(js_scene_Octree_getMaxDepth); +SE_DECLARE_FUNC(js_scene_Octree_getMaxPos); +SE_DECLARE_FUNC(js_scene_Octree_getMinPos); +SE_DECLARE_FUNC(js_scene_Octree_initialize); +SE_DECLARE_FUNC(js_scene_Octree_insert); +SE_DECLARE_FUNC(js_scene_Octree_isEnabled); +SE_DECLARE_FUNC(js_scene_Octree_queryVisibility); +SE_DECLARE_FUNC(js_scene_Octree_remove); +SE_DECLARE_FUNC(js_scene_Octree_resize); +SE_DECLARE_FUNC(js_scene_Octree_setEnabled); +SE_DECLARE_FUNC(js_scene_Octree_setMaxDepth); +SE_DECLARE_FUNC(js_scene_Octree_setMaxPos); +SE_DECLARE_FUNC(js_scene_Octree_setMinPos); +SE_DECLARE_FUNC(js_scene_Octree_update); +SE_DECLARE_FUNC(js_scene_Octree_Octree); + // clang-format on \ No newline at end of file diff --git a/native/cocos/bindings/auto/jsb_spine_auto.cpp b/native/cocos/bindings/auto/jsb_spine_auto.cpp index c2e9323927..e53a3b5092 100644 --- a/native/cocos/bindings/auto/jsb_spine_auto.cpp +++ b/native/cocos/bindings/auto/jsb_spine_auto.cpp @@ -1,3 +1,5 @@ + +// clang-format off #include "cocos/bindings/auto/jsb_spine_auto.h" #include "cocos/bindings/manual/jsb_conversions.h" #include "cocos/bindings/manual/jsb_global.h" @@ -10,8 +12,8 @@ #ifndef JSB_FREE #define JSB_FREE(ptr) delete ptr #endif -se::Object* __jsb_spine_Animation_proto = nullptr; -se::Class* __jsb_spine_Animation_class = nullptr; +se::Object* __jsb_spine_Animation_proto = nullptr; // NOLINT +se::Class* __jsb_spine_Animation_class = nullptr; // NOLINT static bool js_spine_Animation_getDuration(se::State& s) // NOLINT(readability-identifier-naming) { @@ -111,8 +113,6 @@ static bool js_spine_Animation_setDuration(se::State& s) // NOLINT(readability-i } SE_BIND_FUNC(js_spine_Animation_setDuration) - - bool js_register_spine_Animation(se::Object* obj) // NOLINT(readability-identifier-naming) { auto* cls = se::Class::create("Animation", obj, nullptr, nullptr); @@ -128,11 +128,12 @@ bool js_register_spine_Animation(se::Object* obj) // NOLINT(readability-identifi __jsb_spine_Animation_proto = cls->getProto(); __jsb_spine_Animation_class = cls; + se::ScriptEngine::getInstance()->clearException(); return true; } -se::Object* __jsb_spine_TrackEntry_proto = nullptr; -se::Class* __jsb_spine_TrackEntry_class = nullptr; +se::Object* __jsb_spine_TrackEntry_proto = nullptr; // NOLINT +se::Class* __jsb_spine_TrackEntry_class = nullptr; // NOLINT static bool js_spine_TrackEntry_getAlpha(se::State& s) // NOLINT(readability-identifier-naming) { @@ -890,8 +891,6 @@ static bool js_spine_TrackEntry_setTrackTime(se::State& s) // NOLINT(readability } SE_BIND_FUNC(js_spine_TrackEntry_setTrackTime) - - bool js_register_spine_TrackEntry(se::Object* obj) // NOLINT(readability-identifier-naming) { auto* cls = se::Class::create("TrackEntry", obj, nullptr, nullptr); @@ -942,11 +941,12 @@ bool js_register_spine_TrackEntry(se::Object* obj) // NOLINT(readability-identif __jsb_spine_TrackEntry_proto = cls->getProto(); __jsb_spine_TrackEntry_class = cls; + se::ScriptEngine::getInstance()->clearException(); return true; } -se::Object* __jsb_spine_AnimationState_proto = nullptr; -se::Class* __jsb_spine_AnimationState_class = nullptr; +se::Object* __jsb_spine_AnimationState_proto = nullptr; // NOLINT +se::Class* __jsb_spine_AnimationState_class = nullptr; // NOLINT static bool js_spine_AnimationState_addAnimation(se::State& s) // NOLINT(readability-identifier-naming) { @@ -1304,8 +1304,6 @@ static bool js_spine_AnimationState_update(se::State& s) // NOLINT(readability-i } SE_BIND_FUNC(js_spine_AnimationState_update) - - bool js_register_spine_AnimationState(se::Object* obj) // NOLINT(readability-identifier-naming) { auto* cls = se::Class::create("AnimationState", obj, nullptr, nullptr); @@ -1331,11 +1329,12 @@ bool js_register_spine_AnimationState(se::Object* obj) // NOLINT(readability-ide __jsb_spine_AnimationState_proto = cls->getProto(); __jsb_spine_AnimationState_class = cls; + se::ScriptEngine::getInstance()->clearException(); return true; } -se::Object* __jsb_spine_AnimationStateData_proto = nullptr; -se::Class* __jsb_spine_AnimationStateData_class = nullptr; +se::Object* __jsb_spine_AnimationStateData_proto = nullptr; // NOLINT +se::Class* __jsb_spine_AnimationStateData_class = nullptr; // NOLINT static bool js_spine_AnimationStateData_getDefaultMix(se::State& s) // NOLINT(readability-identifier-naming) { @@ -1464,8 +1463,6 @@ static bool js_spine_AnimationStateData_setMix(se::State& s) // NOLINT(readabili } SE_BIND_FUNC(js_spine_AnimationStateData_setMix) - - bool js_register_spine_AnimationStateData(se::Object* obj) // NOLINT(readability-identifier-naming) { auto* cls = se::Class::create("AnimationStateData", obj, nullptr, nullptr); @@ -1481,11 +1478,12 @@ bool js_register_spine_AnimationStateData(se::Object* obj) // NOLINT(readability __jsb_spine_AnimationStateData_proto = cls->getProto(); __jsb_spine_AnimationStateData_class = cls; + se::ScriptEngine::getInstance()->clearException(); return true; } -se::Object* __jsb_spine_Attachment_proto = nullptr; -se::Class* __jsb_spine_Attachment_class = nullptr; +se::Object* __jsb_spine_Attachment_proto = nullptr; // NOLINT +se::Class* __jsb_spine_Attachment_class = nullptr; // NOLINT static bool js_spine_Attachment_copy(se::State& s) // NOLINT(readability-identifier-naming) { @@ -1574,8 +1572,6 @@ static bool js_spine_Attachment_reference(se::State& s) // NOLINT(readability-id } SE_BIND_FUNC(js_spine_Attachment_reference) - - bool js_register_spine_Attachment(se::Object* obj) // NOLINT(readability-identifier-naming) { auto* cls = se::Class::create("Attachment", obj, nullptr, nullptr); @@ -1591,11 +1587,12 @@ bool js_register_spine_Attachment(se::Object* obj) // NOLINT(readability-identif __jsb_spine_Attachment_proto = cls->getProto(); __jsb_spine_Attachment_class = cls; + se::ScriptEngine::getInstance()->clearException(); return true; } -se::Object* __jsb_spine_Timeline_proto = nullptr; -se::Class* __jsb_spine_Timeline_class = nullptr; +se::Object* __jsb_spine_Timeline_proto = nullptr; // NOLINT +se::Class* __jsb_spine_Timeline_class = nullptr; // NOLINT static bool js_spine_Timeline_getPropertyId(se::State& s) // NOLINT(readability-identifier-naming) { @@ -1616,8 +1613,6 @@ static bool js_spine_Timeline_getPropertyId(se::State& s) // NOLINT(readability- } SE_BIND_FUNC(js_spine_Timeline_getPropertyId) - - bool js_register_spine_Timeline(se::Object* obj) // NOLINT(readability-identifier-naming) { auto* cls = se::Class::create("Timeline", obj, nullptr, nullptr); @@ -1629,11 +1624,12 @@ bool js_register_spine_Timeline(se::Object* obj) // NOLINT(readability-identifie __jsb_spine_Timeline_proto = cls->getProto(); __jsb_spine_Timeline_class = cls; + se::ScriptEngine::getInstance()->clearException(); return true; } -se::Object* __jsb_spine_AttachmentTimeline_proto = nullptr; -se::Class* __jsb_spine_AttachmentTimeline_class = nullptr; +se::Object* __jsb_spine_AttachmentTimeline_proto = nullptr; // NOLINT +se::Class* __jsb_spine_AttachmentTimeline_class = nullptr; // NOLINT static bool js_spine_AttachmentTimeline_getAttachmentNames(se::State& s) // NOLINT(readability-identifier-naming) { @@ -1772,8 +1768,6 @@ static bool js_spine_AttachmentTimeline_setSlotIndex(se::State& s) // NOLINT(rea } SE_BIND_FUNC(js_spine_AttachmentTimeline_setSlotIndex) - - bool js_register_spine_AttachmentTimeline(se::Object* obj) // NOLINT(readability-identifier-naming) { auto* cls = se::Class::create("AttachmentTimeline", obj, __jsb_spine_Timeline_proto, nullptr); @@ -1791,11 +1785,12 @@ bool js_register_spine_AttachmentTimeline(se::Object* obj) // NOLINT(readability __jsb_spine_AttachmentTimeline_proto = cls->getProto(); __jsb_spine_AttachmentTimeline_class = cls; + se::ScriptEngine::getInstance()->clearException(); return true; } -se::Object* __jsb_spine_Bone_proto = nullptr; -se::Class* __jsb_spine_Bone_class = nullptr; +se::Object* __jsb_spine_Bone_proto = nullptr; // NOLINT +se::Class* __jsb_spine_Bone_class = nullptr; // NOLINT static bool js_spine_Bone_getA(se::State& s) // NOLINT(readability-identifier-naming) { @@ -2921,24 +2916,7 @@ static bool js_spine_Bone_updateWorldTransform(se::State& s) // NOLINT(readabili } SE_BIND_FUNC(js_spine_Bone_updateWorldTransform) -static bool js_spine_Bone_setYDown(se::State& s) // NOLINT(readability-identifier-naming) -{ - const auto& args = s.args(); - size_t argc = args.size(); - CC_UNUSED bool ok = true; - if (argc == 1) { - HolderType arg0 = {}; - ok &= sevalue_to_native(args[0], &arg0, nullptr); - SE_PRECONDITION2(ok, false, "js_spine_Bone_setYDown : Error processing arguments"); - spine::Bone::setYDown(arg0.value()); - return true; - } - SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 1); - return false; -} -SE_BIND_FUNC(js_spine_Bone_setYDown) - -static bool js_spine_Bone_isYDown(se::State& s) // NOLINT(readability-identifier-naming) +static bool js_spine_Bone_isYDown_static(se::State& s) // NOLINT(readability-identifier-naming) { const auto& args = s.args(); size_t argc = args.size(); @@ -2946,16 +2924,31 @@ static bool js_spine_Bone_isYDown(se::State& s) // NOLINT(readability-identifier if (argc == 0) { bool result = spine::Bone::isYDown(); ok &= nativevalue_to_se(result, s.rval(), nullptr /*ctx*/); - SE_PRECONDITION2(ok, false, "js_spine_Bone_isYDown : Error processing arguments"); + SE_PRECONDITION2(ok, false, "js_spine_Bone_isYDown_static : Error processing arguments"); SE_HOLD_RETURN_VALUE(result, s.thisObject(), s.rval()); return true; } SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 0); return false; } -SE_BIND_FUNC(js_spine_Bone_isYDown) - +SE_BIND_FUNC(js_spine_Bone_isYDown_static) +static bool js_spine_Bone_setYDown_static(se::State& s) // NOLINT(readability-identifier-naming) +{ + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 1) { + HolderType arg0 = {}; + ok &= sevalue_to_native(args[0], &arg0, nullptr); + SE_PRECONDITION2(ok, false, "js_spine_Bone_setYDown_static : Error processing arguments"); + spine::Bone::setYDown(arg0.value()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 1); + return false; +} +SE_BIND_FUNC(js_spine_Bone_setYDown_static) bool js_register_spine_Bone(se::Object* obj) // NOLINT(readability-identifier-naming) { @@ -3019,19 +3012,20 @@ bool js_register_spine_Bone(se::Object* obj) // NOLINT(readability-identifier-na cls->defineFunction("setY", _SE(js_spine_Bone_setY)); cls->defineFunction("update", _SE(js_spine_Bone_update)); cls->defineFunction("updateWorldTransform", _SE(js_spine_Bone_updateWorldTransform)); - cls->defineStaticFunction("setYDown", _SE(js_spine_Bone_setYDown)); - cls->defineStaticFunction("isYDown", _SE(js_spine_Bone_isYDown)); + cls->defineStaticFunction("isYDown", _SE(js_spine_Bone_isYDown_static)); + cls->defineStaticFunction("setYDown", _SE(js_spine_Bone_setYDown_static)); cls->install(); JSBClassType::registerClass(cls); __jsb_spine_Bone_proto = cls->getProto(); __jsb_spine_Bone_class = cls; + se::ScriptEngine::getInstance()->clearException(); return true; } -se::Object* __jsb_spine_BoneData_proto = nullptr; -se::Class* __jsb_spine_BoneData_class = nullptr; +se::Object* __jsb_spine_BoneData_proto = nullptr; // NOLINT +se::Class* __jsb_spine_BoneData_class = nullptr; // NOLINT static bool js_spine_BoneData_getIndex(se::State& s) // NOLINT(readability-identifier-naming) { @@ -3470,8 +3464,6 @@ static bool js_spine_BoneData_setY(se::State& s) // NOLINT(readability-identifie } SE_BIND_FUNC(js_spine_BoneData_setY) - - bool js_register_spine_BoneData(se::Object* obj) // NOLINT(readability-identifier-naming) { auto* cls = se::Class::create("BoneData", obj, nullptr, nullptr); @@ -3505,11 +3497,12 @@ bool js_register_spine_BoneData(se::Object* obj) // NOLINT(readability-identifie __jsb_spine_BoneData_proto = cls->getProto(); __jsb_spine_BoneData_class = cls; + se::ScriptEngine::getInstance()->clearException(); return true; } -se::Object* __jsb_spine_VertexAttachment_proto = nullptr; -se::Class* __jsb_spine_VertexAttachment_class = nullptr; +se::Object* __jsb_spine_VertexAttachment_proto = nullptr; // NOLINT +se::Class* __jsb_spine_VertexAttachment_class = nullptr; // NOLINT static bool js_spine_VertexAttachment_copyTo(se::State& s) // NOLINT(readability-identifier-naming) { @@ -3644,8 +3637,6 @@ static bool js_spine_VertexAttachment_setWorldVerticesLength(se::State& s) // NO } SE_BIND_FUNC(js_spine_VertexAttachment_setWorldVerticesLength) - - bool js_register_spine_VertexAttachment(se::Object* obj) // NOLINT(readability-identifier-naming) { auto* cls = se::Class::create("VertexAttachment", obj, __jsb_spine_Attachment_proto, nullptr); @@ -3663,11 +3654,12 @@ bool js_register_spine_VertexAttachment(se::Object* obj) // NOLINT(readability-i __jsb_spine_VertexAttachment_proto = cls->getProto(); __jsb_spine_VertexAttachment_class = cls; + se::ScriptEngine::getInstance()->clearException(); return true; } -se::Object* __jsb_spine_BoundingBoxAttachment_proto = nullptr; -se::Class* __jsb_spine_BoundingBoxAttachment_class = nullptr; +se::Object* __jsb_spine_BoundingBoxAttachment_proto = nullptr; // NOLINT +se::Class* __jsb_spine_BoundingBoxAttachment_class = nullptr; // NOLINT static bool js_spine_BoundingBoxAttachment_copy(se::State& s) // NOLINT(readability-identifier-naming) { @@ -3688,8 +3680,6 @@ static bool js_spine_BoundingBoxAttachment_copy(se::State& s) // NOLINT(readabil } SE_BIND_FUNC(js_spine_BoundingBoxAttachment_copy) - - bool js_register_spine_BoundingBoxAttachment(se::Object* obj) // NOLINT(readability-identifier-naming) { auto* cls = se::Class::create("BoundingBoxAttachment", obj, __jsb_spine_VertexAttachment_proto, nullptr); @@ -3701,11 +3691,12 @@ bool js_register_spine_BoundingBoxAttachment(se::Object* obj) // NOLINT(readabil __jsb_spine_BoundingBoxAttachment_proto = cls->getProto(); __jsb_spine_BoundingBoxAttachment_class = cls; + se::ScriptEngine::getInstance()->clearException(); return true; } -se::Object* __jsb_spine_ClippingAttachment_proto = nullptr; -se::Class* __jsb_spine_ClippingAttachment_class = nullptr; +se::Object* __jsb_spine_ClippingAttachment_proto = nullptr; // NOLINT +se::Class* __jsb_spine_ClippingAttachment_class = nullptr; // NOLINT static bool js_spine_ClippingAttachment_copy(se::State& s) // NOLINT(readability-identifier-naming) { @@ -3764,8 +3755,6 @@ static bool js_spine_ClippingAttachment_setEndSlot(se::State& s) // NOLINT(reada } SE_BIND_FUNC(js_spine_ClippingAttachment_setEndSlot) - - bool js_register_spine_ClippingAttachment(se::Object* obj) // NOLINT(readability-identifier-naming) { auto* cls = se::Class::create("ClippingAttachment", obj, __jsb_spine_VertexAttachment_proto, nullptr); @@ -3779,11 +3768,12 @@ bool js_register_spine_ClippingAttachment(se::Object* obj) // NOLINT(readability __jsb_spine_ClippingAttachment_proto = cls->getProto(); __jsb_spine_ClippingAttachment_class = cls; + se::ScriptEngine::getInstance()->clearException(); return true; } -se::Object* __jsb_spine_Color_proto = nullptr; -se::Class* __jsb_spine_Color_class = nullptr; +se::Object* __jsb_spine_Color_proto = nullptr; // NOLINT +se::Class* __jsb_spine_Color_class = nullptr; // NOLINT static bool js_spine_Color_clamp(se::State& s) // NOLINT(readability-identifier-naming) { @@ -3912,8 +3902,6 @@ static bool js_spine_Color_set_a(se::State& s) // NOLINT(readability-identifier- } SE_BIND_PROP_SET(js_spine_Color_set_a) - - bool js_register_spine_Color(se::Object* obj) // NOLINT(readability-identifier-naming) { auto* cls = se::Class::create("Color", obj, nullptr, nullptr); @@ -3929,11 +3917,12 @@ bool js_register_spine_Color(se::Object* obj) // NOLINT(readability-identifier-n __jsb_spine_Color_proto = cls->getProto(); __jsb_spine_Color_class = cls; + se::ScriptEngine::getInstance()->clearException(); return true; } -se::Object* __jsb_spine_CurveTimeline_proto = nullptr; -se::Class* __jsb_spine_CurveTimeline_class = nullptr; +se::Object* __jsb_spine_CurveTimeline_proto = nullptr; // NOLINT +se::Class* __jsb_spine_CurveTimeline_class = nullptr; // NOLINT static bool js_spine_CurveTimeline_getCurvePercent(se::State& s) // NOLINT(readability-identifier-naming) { @@ -4084,8 +4073,6 @@ static bool js_spine_CurveTimeline_setStepped(se::State& s) // NOLINT(readabilit } SE_BIND_FUNC(js_spine_CurveTimeline_setStepped) - - bool js_register_spine_CurveTimeline(se::Object* obj) // NOLINT(readability-identifier-naming) { auto* cls = se::Class::create("CurveTimeline", obj, __jsb_spine_Timeline_proto, nullptr); @@ -4103,11 +4090,12 @@ bool js_register_spine_CurveTimeline(se::Object* obj) // NOLINT(readability-iden __jsb_spine_CurveTimeline_proto = cls->getProto(); __jsb_spine_CurveTimeline_class = cls; + se::ScriptEngine::getInstance()->clearException(); return true; } -se::Object* __jsb_spine_ColorTimeline_proto = nullptr; -se::Class* __jsb_spine_ColorTimeline_class = nullptr; +se::Object* __jsb_spine_ColorTimeline_proto = nullptr; // NOLINT +se::Class* __jsb_spine_ColorTimeline_class = nullptr; // NOLINT static bool js_spine_ColorTimeline_getFrames(se::State& s) // NOLINT(readability-identifier-naming) { @@ -4214,8 +4202,6 @@ static bool js_spine_ColorTimeline_setSlotIndex(se::State& s) // NOLINT(readabil } SE_BIND_FUNC(js_spine_ColorTimeline_setSlotIndex) - - bool js_register_spine_ColorTimeline(se::Object* obj) // NOLINT(readability-identifier-naming) { auto* cls = se::Class::create("ColorTimeline", obj, __jsb_spine_CurveTimeline_proto, nullptr); @@ -4231,11 +4217,12 @@ bool js_register_spine_ColorTimeline(se::Object* obj) // NOLINT(readability-iden __jsb_spine_ColorTimeline_proto = cls->getProto(); __jsb_spine_ColorTimeline_class = cls; + se::ScriptEngine::getInstance()->clearException(); return true; } -se::Object* __jsb_spine_ConstraintData_proto = nullptr; -se::Class* __jsb_spine_ConstraintData_class = nullptr; +se::Object* __jsb_spine_ConstraintData_proto = nullptr; // NOLINT +se::Class* __jsb_spine_ConstraintData_class = nullptr; // NOLINT static bool js_spine_ConstraintData_getName(se::State& s) // NOLINT(readability-identifier-naming) { @@ -4332,8 +4319,6 @@ static bool js_spine_ConstraintData_setSkinRequired(se::State& s) // NOLINT(read } SE_BIND_FUNC(js_spine_ConstraintData_setSkinRequired) - - bool js_register_spine_ConstraintData(se::Object* obj) // NOLINT(readability-identifier-naming) { auto* cls = se::Class::create("ConstraintData", obj, nullptr, nullptr); @@ -4349,11 +4334,12 @@ bool js_register_spine_ConstraintData(se::Object* obj) // NOLINT(readability-ide __jsb_spine_ConstraintData_proto = cls->getProto(); __jsb_spine_ConstraintData_class = cls; + se::ScriptEngine::getInstance()->clearException(); return true; } -se::Object* __jsb_spine_DeformTimeline_proto = nullptr; -se::Class* __jsb_spine_DeformTimeline_class = nullptr; +se::Object* __jsb_spine_DeformTimeline_proto = nullptr; // NOLINT +se::Class* __jsb_spine_DeformTimeline_class = nullptr; // NOLINT static bool js_spine_DeformTimeline_getAttachment(se::State& s) // NOLINT(readability-identifier-naming) { @@ -4469,8 +4455,6 @@ static bool js_spine_DeformTimeline_setSlotIndex(se::State& s) // NOLINT(readabi } SE_BIND_FUNC(js_spine_DeformTimeline_setSlotIndex) - - bool js_register_spine_DeformTimeline(se::Object* obj) // NOLINT(readability-identifier-naming) { auto* cls = se::Class::create("DeformTimeline", obj, __jsb_spine_CurveTimeline_proto, nullptr); @@ -4487,11 +4471,12 @@ bool js_register_spine_DeformTimeline(se::Object* obj) // NOLINT(readability-ide __jsb_spine_DeformTimeline_proto = cls->getProto(); __jsb_spine_DeformTimeline_class = cls; + se::ScriptEngine::getInstance()->clearException(); return true; } -se::Object* __jsb_spine_DrawOrderTimeline_proto = nullptr; -se::Class* __jsb_spine_DrawOrderTimeline_class = nullptr; +se::Object* __jsb_spine_DrawOrderTimeline_proto = nullptr; // NOLINT +se::Class* __jsb_spine_DrawOrderTimeline_class = nullptr; // NOLINT static bool js_spine_DrawOrderTimeline_getFrameCount(se::State& s) // NOLINT(readability-identifier-naming) { @@ -4550,8 +4535,6 @@ static bool js_spine_DrawOrderTimeline_getPropertyId(se::State& s) // NOLINT(rea } SE_BIND_FUNC(js_spine_DrawOrderTimeline_getPropertyId) - - bool js_register_spine_DrawOrderTimeline(se::Object* obj) // NOLINT(readability-identifier-naming) { auto* cls = se::Class::create("DrawOrderTimeline", obj, __jsb_spine_Timeline_proto, nullptr); @@ -4565,11 +4548,12 @@ bool js_register_spine_DrawOrderTimeline(se::Object* obj) // NOLINT(readability- __jsb_spine_DrawOrderTimeline_proto = cls->getProto(); __jsb_spine_DrawOrderTimeline_class = cls; + se::ScriptEngine::getInstance()->clearException(); return true; } -se::Object* __jsb_spine_Event_proto = nullptr; -se::Class* __jsb_spine_Event_class = nullptr; +se::Object* __jsb_spine_Event_proto = nullptr; // NOLINT +se::Class* __jsb_spine_Event_class = nullptr; // NOLINT static bool js_spine_Event_getBalance(se::State& s) // NOLINT(readability-identifier-naming) { @@ -4799,8 +4783,6 @@ static bool js_spine_Event_setVolume(se::State& s) // NOLINT(readability-identif } SE_BIND_FUNC(js_spine_Event_setVolume) - - bool js_register_spine_Event(se::Object* obj) // NOLINT(readability-identifier-naming) { auto* cls = se::Class::create("Event", obj, nullptr, nullptr); @@ -4823,11 +4805,12 @@ bool js_register_spine_Event(se::Object* obj) // NOLINT(readability-identifier-n __jsb_spine_Event_proto = cls->getProto(); __jsb_spine_Event_class = cls; + se::ScriptEngine::getInstance()->clearException(); return true; } -se::Object* __jsb_spine_EventData_proto = nullptr; -se::Class* __jsb_spine_EventData_class = nullptr; +se::Object* __jsb_spine_EventData_proto = nullptr; // NOLINT +se::Class* __jsb_spine_EventData_class = nullptr; // NOLINT static bool js_spine_EventData_getAudioPath(se::State& s) // NOLINT(readability-identifier-naming) { @@ -5076,8 +5059,6 @@ static bool js_spine_EventData_setVolume(se::State& s) // NOLINT(readability-ide } SE_BIND_FUNC(js_spine_EventData_setVolume) - - bool js_register_spine_EventData(se::Object* obj) // NOLINT(readability-identifier-naming) { auto* cls = se::Class::create("EventData", obj, nullptr, nullptr); @@ -5101,11 +5082,12 @@ bool js_register_spine_EventData(se::Object* obj) // NOLINT(readability-identifi __jsb_spine_EventData_proto = cls->getProto(); __jsb_spine_EventData_class = cls; + se::ScriptEngine::getInstance()->clearException(); return true; } -se::Object* __jsb_spine_EventTimeline_proto = nullptr; -se::Class* __jsb_spine_EventTimeline_class = nullptr; +se::Object* __jsb_spine_EventTimeline_proto = nullptr; // NOLINT +se::Class* __jsb_spine_EventTimeline_class = nullptr; // NOLINT static bool js_spine_EventTimeline_getEvents(se::State& s) // NOLINT(readability-identifier-naming) { @@ -5204,8 +5186,6 @@ static bool js_spine_EventTimeline_setFrame(se::State& s) // NOLINT(readability- } SE_BIND_FUNC(js_spine_EventTimeline_setFrame) - - bool js_register_spine_EventTimeline(se::Object* obj) // NOLINT(readability-identifier-naming) { auto* cls = se::Class::create("EventTimeline", obj, __jsb_spine_Timeline_proto, nullptr); @@ -5221,11 +5201,12 @@ bool js_register_spine_EventTimeline(se::Object* obj) // NOLINT(readability-iden __jsb_spine_EventTimeline_proto = cls->getProto(); __jsb_spine_EventTimeline_class = cls; + se::ScriptEngine::getInstance()->clearException(); return true; } -se::Object* __jsb_spine_IkConstraint_proto = nullptr; -se::Class* __jsb_spine_IkConstraint_class = nullptr; +se::Object* __jsb_spine_IkConstraint_proto = nullptr; // NOLINT +se::Class* __jsb_spine_IkConstraint_class = nullptr; // NOLINT static bool js_spine_IkConstraint_getBendDirection(se::State& s) // NOLINT(readability-identifier-naming) { @@ -5565,8 +5546,6 @@ static bool js_spine_IkConstraint_update(se::State& s) // NOLINT(readability-ide } SE_BIND_FUNC(js_spine_IkConstraint_update) - - bool js_register_spine_IkConstraint(se::Object* obj) // NOLINT(readability-identifier-naming) { auto* cls = se::Class::create("IkConstraint", obj, nullptr, nullptr); @@ -5595,11 +5574,12 @@ bool js_register_spine_IkConstraint(se::Object* obj) // NOLINT(readability-ident __jsb_spine_IkConstraint_proto = cls->getProto(); __jsb_spine_IkConstraint_class = cls; + se::ScriptEngine::getInstance()->clearException(); return true; } -se::Object* __jsb_spine_IkConstraintData_proto = nullptr; -se::Class* __jsb_spine_IkConstraintData_class = nullptr; +se::Object* __jsb_spine_IkConstraintData_proto = nullptr; // NOLINT +se::Class* __jsb_spine_IkConstraintData_class = nullptr; // NOLINT static bool js_spine_IkConstraintData_getBendDirection(se::State& s) // NOLINT(readability-identifier-naming) { @@ -5886,8 +5866,6 @@ static bool js_spine_IkConstraintData_setUniform(se::State& s) // NOLINT(readabi } SE_BIND_FUNC(js_spine_IkConstraintData_setUniform) - - bool js_register_spine_IkConstraintData(se::Object* obj) // NOLINT(readability-identifier-naming) { auto* cls = se::Class::create("IkConstraintData", obj, __jsb_spine_ConstraintData_proto, nullptr); @@ -5913,11 +5891,12 @@ bool js_register_spine_IkConstraintData(se::Object* obj) // NOLINT(readability-i __jsb_spine_IkConstraintData_proto = cls->getProto(); __jsb_spine_IkConstraintData_class = cls; + se::ScriptEngine::getInstance()->clearException(); return true; } -se::Object* __jsb_spine_IkConstraintTimeline_proto = nullptr; -se::Class* __jsb_spine_IkConstraintTimeline_class = nullptr; +se::Object* __jsb_spine_IkConstraintTimeline_proto = nullptr; // NOLINT +se::Class* __jsb_spine_IkConstraintTimeline_class = nullptr; // NOLINT static bool js_spine_IkConstraintTimeline_getPropertyId(se::State& s) // NOLINT(readability-identifier-naming) { @@ -5969,8 +5948,6 @@ static bool js_spine_IkConstraintTimeline_setFrame(se::State& s) // NOLINT(reada } SE_BIND_FUNC(js_spine_IkConstraintTimeline_setFrame) - - bool js_register_spine_IkConstraintTimeline(se::Object* obj) // NOLINT(readability-identifier-naming) { auto* cls = se::Class::create("IkConstraintTimeline", obj, __jsb_spine_CurveTimeline_proto, nullptr); @@ -5983,11 +5960,12 @@ bool js_register_spine_IkConstraintTimeline(se::Object* obj) // NOLINT(readabili __jsb_spine_IkConstraintTimeline_proto = cls->getProto(); __jsb_spine_IkConstraintTimeline_class = cls; + se::ScriptEngine::getInstance()->clearException(); return true; } -se::Object* __jsb_spine_MeshAttachment_proto = nullptr; -se::Class* __jsb_spine_MeshAttachment_class = nullptr; +se::Object* __jsb_spine_MeshAttachment_proto = nullptr; // NOLINT +se::Class* __jsb_spine_MeshAttachment_class = nullptr; // NOLINT static bool js_spine_MeshAttachment_copy(se::State& s) // NOLINT(readability-identifier-naming) { @@ -6783,8 +6761,6 @@ static bool js_spine_MeshAttachment_updateUVs(se::State& s) // NOLINT(readabilit } SE_BIND_FUNC(js_spine_MeshAttachment_updateUVs) - - bool js_register_spine_MeshAttachment(se::Object* obj) // NOLINT(readability-identifier-naming) { auto* cls = se::Class::create("MeshAttachment", obj, __jsb_spine_VertexAttachment_proto, nullptr); @@ -6837,11 +6813,12 @@ bool js_register_spine_MeshAttachment(se::Object* obj) // NOLINT(readability-ide __jsb_spine_MeshAttachment_proto = cls->getProto(); __jsb_spine_MeshAttachment_class = cls; + se::ScriptEngine::getInstance()->clearException(); return true; } -se::Object* __jsb_spine_PathAttachment_proto = nullptr; -se::Class* __jsb_spine_PathAttachment_class = nullptr; +se::Object* __jsb_spine_PathAttachment_proto = nullptr; // NOLINT +se::Class* __jsb_spine_PathAttachment_class = nullptr; // NOLINT static bool js_spine_PathAttachment_copy(se::State& s) // NOLINT(readability-identifier-naming) { @@ -6957,8 +6934,6 @@ static bool js_spine_PathAttachment_setConstantSpeed(se::State& s) // NOLINT(rea } SE_BIND_FUNC(js_spine_PathAttachment_setConstantSpeed) - - bool js_register_spine_PathAttachment(se::Object* obj) // NOLINT(readability-identifier-naming) { auto* cls = se::Class::create("PathAttachment", obj, __jsb_spine_VertexAttachment_proto, nullptr); @@ -6975,11 +6950,12 @@ bool js_register_spine_PathAttachment(se::Object* obj) // NOLINT(readability-ide __jsb_spine_PathAttachment_proto = cls->getProto(); __jsb_spine_PathAttachment_class = cls; + se::ScriptEngine::getInstance()->clearException(); return true; } -se::Object* __jsb_spine_PathConstraint_proto = nullptr; -se::Class* __jsb_spine_PathConstraint_class = nullptr; +se::Object* __jsb_spine_PathConstraint_proto = nullptr; // NOLINT +se::Class* __jsb_spine_PathConstraint_class = nullptr; // NOLINT static bool js_spine_PathConstraint_apply(se::State& s) // NOLINT(readability-identifier-naming) { @@ -7296,8 +7272,6 @@ static bool js_spine_PathConstraint_update(se::State& s) // NOLINT(readability-i } SE_BIND_FUNC(js_spine_PathConstraint_update) - - bool js_register_spine_PathConstraint(se::Object* obj) // NOLINT(readability-identifier-naming) { auto* cls = se::Class::create("PathConstraint", obj, nullptr, nullptr); @@ -7325,11 +7299,12 @@ bool js_register_spine_PathConstraint(se::Object* obj) // NOLINT(readability-ide __jsb_spine_PathConstraint_proto = cls->getProto(); __jsb_spine_PathConstraint_class = cls; + se::ScriptEngine::getInstance()->clearException(); return true; } -se::Object* __jsb_spine_PathConstraintData_proto = nullptr; -se::Class* __jsb_spine_PathConstraintData_class = nullptr; +se::Object* __jsb_spine_PathConstraintData_proto = nullptr; // NOLINT +se::Class* __jsb_spine_PathConstraintData_class = nullptr; // NOLINT static bool js_spine_PathConstraintData_getBones(se::State& s) // NOLINT(readability-identifier-naming) { @@ -7692,8 +7667,6 @@ static bool js_spine_PathConstraintData_setTranslateMix(se::State& s) // NOLINT( } SE_BIND_FUNC(js_spine_PathConstraintData_setTranslateMix) - - bool js_register_spine_PathConstraintData(se::Object* obj) // NOLINT(readability-identifier-naming) { auto* cls = se::Class::create("PathConstraintData", obj, __jsb_spine_ConstraintData_proto, nullptr); @@ -7723,11 +7696,12 @@ bool js_register_spine_PathConstraintData(se::Object* obj) // NOLINT(readability __jsb_spine_PathConstraintData_proto = cls->getProto(); __jsb_spine_PathConstraintData_class = cls; + se::ScriptEngine::getInstance()->clearException(); return true; } -se::Object* __jsb_spine_PathConstraintMixTimeline_proto = nullptr; -se::Class* __jsb_spine_PathConstraintMixTimeline_class = nullptr; +se::Object* __jsb_spine_PathConstraintMixTimeline_proto = nullptr; // NOLINT +se::Class* __jsb_spine_PathConstraintMixTimeline_class = nullptr; // NOLINT static bool js_spine_PathConstraintMixTimeline_getPropertyId(se::State& s) // NOLINT(readability-identifier-naming) { @@ -7748,8 +7722,6 @@ static bool js_spine_PathConstraintMixTimeline_getPropertyId(se::State& s) // NO } SE_BIND_FUNC(js_spine_PathConstraintMixTimeline_getPropertyId) - - bool js_register_spine_PathConstraintMixTimeline(se::Object* obj) // NOLINT(readability-identifier-naming) { auto* cls = se::Class::create("PathConstraintMixTimeline", obj, __jsb_spine_CurveTimeline_proto, nullptr); @@ -7761,11 +7733,12 @@ bool js_register_spine_PathConstraintMixTimeline(se::Object* obj) // NOLINT(read __jsb_spine_PathConstraintMixTimeline_proto = cls->getProto(); __jsb_spine_PathConstraintMixTimeline_class = cls; + se::ScriptEngine::getInstance()->clearException(); return true; } -se::Object* __jsb_spine_PathConstraintPositionTimeline_proto = nullptr; -se::Class* __jsb_spine_PathConstraintPositionTimeline_class = nullptr; +se::Object* __jsb_spine_PathConstraintPositionTimeline_proto = nullptr; // NOLINT +se::Class* __jsb_spine_PathConstraintPositionTimeline_class = nullptr; // NOLINT static bool js_spine_PathConstraintPositionTimeline_getPropertyId(se::State& s) // NOLINT(readability-identifier-naming) { @@ -7809,8 +7782,6 @@ static bool js_spine_PathConstraintPositionTimeline_setFrame(se::State& s) // NO } SE_BIND_FUNC(js_spine_PathConstraintPositionTimeline_setFrame) - - bool js_register_spine_PathConstraintPositionTimeline(se::Object* obj) // NOLINT(readability-identifier-naming) { auto* cls = se::Class::create("PathConstraintPositionTimeline", obj, __jsb_spine_CurveTimeline_proto, nullptr); @@ -7823,11 +7794,12 @@ bool js_register_spine_PathConstraintPositionTimeline(se::Object* obj) // NOLINT __jsb_spine_PathConstraintPositionTimeline_proto = cls->getProto(); __jsb_spine_PathConstraintPositionTimeline_class = cls; + se::ScriptEngine::getInstance()->clearException(); return true; } -se::Object* __jsb_spine_PathConstraintSpacingTimeline_proto = nullptr; -se::Class* __jsb_spine_PathConstraintSpacingTimeline_class = nullptr; +se::Object* __jsb_spine_PathConstraintSpacingTimeline_proto = nullptr; // NOLINT +se::Class* __jsb_spine_PathConstraintSpacingTimeline_class = nullptr; // NOLINT static bool js_spine_PathConstraintSpacingTimeline_getPropertyId(se::State& s) // NOLINT(readability-identifier-naming) { @@ -7848,8 +7820,6 @@ static bool js_spine_PathConstraintSpacingTimeline_getPropertyId(se::State& s) / } SE_BIND_FUNC(js_spine_PathConstraintSpacingTimeline_getPropertyId) - - bool js_register_spine_PathConstraintSpacingTimeline(se::Object* obj) // NOLINT(readability-identifier-naming) { auto* cls = se::Class::create("PathConstraintSpacingTimeline", obj, __jsb_spine_PathConstraintPositionTimeline_proto, nullptr); @@ -7861,11 +7831,12 @@ bool js_register_spine_PathConstraintSpacingTimeline(se::Object* obj) // NOLINT( __jsb_spine_PathConstraintSpacingTimeline_proto = cls->getProto(); __jsb_spine_PathConstraintSpacingTimeline_class = cls; + se::ScriptEngine::getInstance()->clearException(); return true; } -se::Object* __jsb_spine_PointAttachment_proto = nullptr; -se::Class* __jsb_spine_PointAttachment_class = nullptr; +se::Object* __jsb_spine_PointAttachment_proto = nullptr; // NOLINT +se::Class* __jsb_spine_PointAttachment_class = nullptr; // NOLINT static bool js_spine_PointAttachment_copy(se::State& s) // NOLINT(readability-identifier-naming) { @@ -8000,8 +7971,6 @@ static bool js_spine_PointAttachment_setY(se::State& s) // NOLINT(readability-id } SE_BIND_FUNC(js_spine_PointAttachment_setY) - - bool js_register_spine_PointAttachment(se::Object* obj) // NOLINT(readability-identifier-naming) { auto* cls = se::Class::create("PointAttachment", obj, __jsb_spine_Attachment_proto, nullptr); @@ -8019,11 +7988,12 @@ bool js_register_spine_PointAttachment(se::Object* obj) // NOLINT(readability-id __jsb_spine_PointAttachment_proto = cls->getProto(); __jsb_spine_PointAttachment_class = cls; + se::ScriptEngine::getInstance()->clearException(); return true; } -se::Object* __jsb_spine_RegionAttachment_proto = nullptr; -se::Class* __jsb_spine_RegionAttachment_class = nullptr; +se::Object* __jsb_spine_RegionAttachment_proto = nullptr; // NOLINT +se::Class* __jsb_spine_RegionAttachment_class = nullptr; // NOLINT static bool js_spine_RegionAttachment_copy(se::State& s) // NOLINT(readability-identifier-naming) { @@ -8675,8 +8645,6 @@ static bool js_spine_RegionAttachment_updateOffset(se::State& s) // NOLINT(reada } SE_BIND_FUNC(js_spine_RegionAttachment_updateOffset) - - bool js_register_spine_RegionAttachment(se::Object* obj) // NOLINT(readability-identifier-naming) { auto* cls = se::Class::create("RegionAttachment", obj, __jsb_spine_Attachment_proto, nullptr); @@ -8721,11 +8689,12 @@ bool js_register_spine_RegionAttachment(se::Object* obj) // NOLINT(readability-i __jsb_spine_RegionAttachment_proto = cls->getProto(); __jsb_spine_RegionAttachment_class = cls; + se::ScriptEngine::getInstance()->clearException(); return true; } -se::Object* __jsb_spine_RotateTimeline_proto = nullptr; -se::Class* __jsb_spine_RotateTimeline_class = nullptr; +se::Object* __jsb_spine_RotateTimeline_proto = nullptr; // NOLINT +se::Class* __jsb_spine_RotateTimeline_class = nullptr; // NOLINT static bool js_spine_RotateTimeline_getBoneIndex(se::State& s) // NOLINT(readability-identifier-naming) { @@ -8826,8 +8795,6 @@ static bool js_spine_RotateTimeline_setFrame(se::State& s) // NOLINT(readability } SE_BIND_FUNC(js_spine_RotateTimeline_setFrame) - - bool js_register_spine_RotateTimeline(se::Object* obj) // NOLINT(readability-identifier-naming) { auto* cls = se::Class::create("RotateTimeline", obj, __jsb_spine_CurveTimeline_proto, nullptr); @@ -8843,11 +8810,12 @@ bool js_register_spine_RotateTimeline(se::Object* obj) // NOLINT(readability-ide __jsb_spine_RotateTimeline_proto = cls->getProto(); __jsb_spine_RotateTimeline_class = cls; + se::ScriptEngine::getInstance()->clearException(); return true; } -se::Object* __jsb_spine_TranslateTimeline_proto = nullptr; -se::Class* __jsb_spine_TranslateTimeline_class = nullptr; +se::Object* __jsb_spine_TranslateTimeline_proto = nullptr; // NOLINT +se::Class* __jsb_spine_TranslateTimeline_class = nullptr; // NOLINT static bool js_spine_TranslateTimeline_getPropertyId(se::State& s) // NOLINT(readability-identifier-naming) { @@ -8893,8 +8861,6 @@ static bool js_spine_TranslateTimeline_setFrame(se::State& s) // NOLINT(readabil } SE_BIND_FUNC(js_spine_TranslateTimeline_setFrame) - - bool js_register_spine_TranslateTimeline(se::Object* obj) // NOLINT(readability-identifier-naming) { auto* cls = se::Class::create("TranslateTimeline", obj, __jsb_spine_CurveTimeline_proto, nullptr); @@ -8907,11 +8873,12 @@ bool js_register_spine_TranslateTimeline(se::Object* obj) // NOLINT(readability- __jsb_spine_TranslateTimeline_proto = cls->getProto(); __jsb_spine_TranslateTimeline_class = cls; + se::ScriptEngine::getInstance()->clearException(); return true; } -se::Object* __jsb_spine_ScaleTimeline_proto = nullptr; -se::Class* __jsb_spine_ScaleTimeline_class = nullptr; +se::Object* __jsb_spine_ScaleTimeline_proto = nullptr; // NOLINT +se::Class* __jsb_spine_ScaleTimeline_class = nullptr; // NOLINT static bool js_spine_ScaleTimeline_getPropertyId(se::State& s) // NOLINT(readability-identifier-naming) { @@ -8932,8 +8899,6 @@ static bool js_spine_ScaleTimeline_getPropertyId(se::State& s) // NOLINT(readabi } SE_BIND_FUNC(js_spine_ScaleTimeline_getPropertyId) - - bool js_register_spine_ScaleTimeline(se::Object* obj) // NOLINT(readability-identifier-naming) { auto* cls = se::Class::create("ScaleTimeline", obj, __jsb_spine_TranslateTimeline_proto, nullptr); @@ -8945,11 +8910,12 @@ bool js_register_spine_ScaleTimeline(se::Object* obj) // NOLINT(readability-iden __jsb_spine_ScaleTimeline_proto = cls->getProto(); __jsb_spine_ScaleTimeline_class = cls; + se::ScriptEngine::getInstance()->clearException(); return true; } -se::Object* __jsb_spine_ShearTimeline_proto = nullptr; -se::Class* __jsb_spine_ShearTimeline_class = nullptr; +se::Object* __jsb_spine_ShearTimeline_proto = nullptr; // NOLINT +se::Class* __jsb_spine_ShearTimeline_class = nullptr; // NOLINT static bool js_spine_ShearTimeline_getPropertyId(se::State& s) // NOLINT(readability-identifier-naming) { @@ -8970,8 +8936,6 @@ static bool js_spine_ShearTimeline_getPropertyId(se::State& s) // NOLINT(readabi } SE_BIND_FUNC(js_spine_ShearTimeline_getPropertyId) - - bool js_register_spine_ShearTimeline(se::Object* obj) // NOLINT(readability-identifier-naming) { auto* cls = se::Class::create("ShearTimeline", obj, __jsb_spine_TranslateTimeline_proto, nullptr); @@ -8983,11 +8947,12 @@ bool js_register_spine_ShearTimeline(se::Object* obj) // NOLINT(readability-iden __jsb_spine_ShearTimeline_proto = cls->getProto(); __jsb_spine_ShearTimeline_class = cls; + se::ScriptEngine::getInstance()->clearException(); return true; } -se::Object* __jsb_spine_Skeleton_proto = nullptr; -se::Class* __jsb_spine_Skeleton_class = nullptr; +se::Object* __jsb_spine_Skeleton_proto = nullptr; // NOLINT +se::Class* __jsb_spine_Skeleton_class = nullptr; // NOLINT static bool js_spine_Skeleton_findBone(se::State& s) // NOLINT(readability-identifier-naming) { @@ -9773,8 +9738,6 @@ static bool js_spine_Skeleton_updateWorldTransform(se::State& s) // NOLINT(reada } SE_BIND_FUNC(js_spine_Skeleton_updateWorldTransform) - - bool js_register_spine_Skeleton(se::Object* obj) // NOLINT(readability-identifier-naming) { auto* cls = se::Class::create("Skeleton", obj, nullptr, nullptr); @@ -9824,11 +9787,12 @@ bool js_register_spine_Skeleton(se::Object* obj) // NOLINT(readability-identifie __jsb_spine_Skeleton_proto = cls->getProto(); __jsb_spine_Skeleton_class = cls; + se::ScriptEngine::getInstance()->clearException(); return true; } -se::Object* __jsb_spine_SkeletonBounds_proto = nullptr; -se::Class* __jsb_spine_SkeletonBounds_class = nullptr; +se::Object* __jsb_spine_SkeletonBounds_proto = nullptr; // NOLINT +se::Class* __jsb_spine_SkeletonBounds_class = nullptr; // NOLINT static bool js_spine_SkeletonBounds_aabbcontainsPoint(se::State& s) // NOLINT(readability-identifier-naming) { @@ -10052,8 +10016,6 @@ static bool js_spine_SkeletonBounds_intersectsSegment(se::State& s) // NOLINT(re } SE_BIND_FUNC(js_spine_SkeletonBounds_intersectsSegment) - - bool js_register_spine_SkeletonBounds(se::Object* obj) // NOLINT(readability-identifier-naming) { auto* cls = se::Class::create("SkeletonBounds", obj, nullptr, nullptr); @@ -10071,13 +10033,12 @@ bool js_register_spine_SkeletonBounds(se::Object* obj) // NOLINT(readability-ide __jsb_spine_SkeletonBounds_proto = cls->getProto(); __jsb_spine_SkeletonBounds_class = cls; + se::ScriptEngine::getInstance()->clearException(); return true; } -se::Object* __jsb_spine_Polygon_proto = nullptr; -se::Class* __jsb_spine_Polygon_class = nullptr; - - +se::Object* __jsb_spine_Polygon_proto = nullptr; // NOLINT +se::Class* __jsb_spine_Polygon_class = nullptr; // NOLINT bool js_register_spine_Polygon(se::Object* obj) // NOLINT(readability-identifier-naming) { @@ -10089,11 +10050,12 @@ bool js_register_spine_Polygon(se::Object* obj) // NOLINT(readability-identifier __jsb_spine_Polygon_proto = cls->getProto(); __jsb_spine_Polygon_class = cls; + se::ScriptEngine::getInstance()->clearException(); return true; } -se::Object* __jsb_spine_SkeletonData_proto = nullptr; -se::Class* __jsb_spine_SkeletonData_class = nullptr; +se::Object* __jsb_spine_SkeletonData_proto = nullptr; // NOLINT +se::Class* __jsb_spine_SkeletonData_class = nullptr; // NOLINT static bool js_spine_SkeletonData_findAnimation(se::State& s) // NOLINT(readability-identifier-naming) { @@ -10907,8 +10869,6 @@ static bool js_spine_SkeletonData_setY(se::State& s) // NOLINT(readability-ident } SE_BIND_FUNC(js_spine_SkeletonData_setY) - - bool js_register_spine_SkeletonData(se::Object* obj) // NOLINT(readability-identifier-naming) { auto* cls = se::Class::create("SkeletonData", obj, nullptr, nullptr); @@ -10960,11 +10920,12 @@ bool js_register_spine_SkeletonData(se::Object* obj) // NOLINT(readability-ident __jsb_spine_SkeletonData_proto = cls->getProto(); __jsb_spine_SkeletonData_class = cls; + se::ScriptEngine::getInstance()->clearException(); return true; } -se::Object* __jsb_spine_Skin_proto = nullptr; -se::Class* __jsb_spine_Skin_class = nullptr; +se::Object* __jsb_spine_Skin_proto = nullptr; // NOLINT +se::Class* __jsb_spine_Skin_class = nullptr; // NOLINT static bool js_spine_Skin_addSkin(se::State& s) // NOLINT(readability-identifier-naming) { @@ -11129,8 +11090,6 @@ static bool js_spine_Skin_setAttachment(se::State& s) // NOLINT(readability-iden } SE_BIND_FUNC(js_spine_Skin_setAttachment) - - bool js_register_spine_Skin(se::Object* obj) // NOLINT(readability-identifier-naming) { auto* cls = se::Class::create("Skin", obj, nullptr, nullptr); @@ -11149,11 +11108,12 @@ bool js_register_spine_Skin(se::Object* obj) // NOLINT(readability-identifier-na __jsb_spine_Skin_proto = cls->getProto(); __jsb_spine_Skin_class = cls; + se::ScriptEngine::getInstance()->clearException(); return true; } -se::Object* __jsb_spine_Slot_proto = nullptr; -se::Class* __jsb_spine_Slot_class = nullptr; +se::Object* __jsb_spine_Slot_proto = nullptr; // NOLINT +se::Class* __jsb_spine_Slot_class = nullptr; // NOLINT static bool js_spine_Slot_getAttachment(se::State& s) // NOLINT(readability-identifier-naming) { @@ -11379,8 +11339,6 @@ static bool js_spine_Slot_setToSetupPose(se::State& s) // NOLINT(readability-ide } SE_BIND_FUNC(js_spine_Slot_setToSetupPose) - - bool js_register_spine_Slot(se::Object* obj) // NOLINT(readability-identifier-naming) { auto* cls = se::Class::create("Slot", obj, nullptr, nullptr); @@ -11403,11 +11361,12 @@ bool js_register_spine_Slot(se::Object* obj) // NOLINT(readability-identifier-na __jsb_spine_Slot_proto = cls->getProto(); __jsb_spine_Slot_class = cls; + se::ScriptEngine::getInstance()->clearException(); return true; } -se::Object* __jsb_spine_SlotData_proto = nullptr; -se::Class* __jsb_spine_SlotData_class = nullptr; +se::Object* __jsb_spine_SlotData_proto = nullptr; // NOLINT +se::Class* __jsb_spine_SlotData_class = nullptr; // NOLINT static bool js_spine_SlotData_getAttachmentName(se::State& s) // NOLINT(readability-identifier-naming) { @@ -11618,8 +11577,6 @@ static bool js_spine_SlotData_setHasDarkColor(se::State& s) // NOLINT(readabilit } SE_BIND_FUNC(js_spine_SlotData_setHasDarkColor) - - bool js_register_spine_SlotData(se::Object* obj) // NOLINT(readability-identifier-naming) { auto* cls = se::Class::create("SlotData", obj, nullptr, nullptr); @@ -11641,11 +11598,12 @@ bool js_register_spine_SlotData(se::Object* obj) // NOLINT(readability-identifie __jsb_spine_SlotData_proto = cls->getProto(); __jsb_spine_SlotData_class = cls; + se::ScriptEngine::getInstance()->clearException(); return true; } -se::Object* __jsb_spine_TransformConstraint_proto = nullptr; -se::Class* __jsb_spine_TransformConstraint_class = nullptr; +se::Object* __jsb_spine_TransformConstraint_proto = nullptr; // NOLINT +se::Class* __jsb_spine_TransformConstraint_class = nullptr; // NOLINT static bool js_spine_TransformConstraint_apply(se::State& s) // NOLINT(readability-identifier-naming) { @@ -11962,8 +11920,6 @@ static bool js_spine_TransformConstraint_update(se::State& s) // NOLINT(readabil } SE_BIND_FUNC(js_spine_TransformConstraint_update) - - bool js_register_spine_TransformConstraint(se::Object* obj) // NOLINT(readability-identifier-naming) { auto* cls = se::Class::create("TransformConstraint", obj, nullptr, nullptr); @@ -11991,11 +11947,12 @@ bool js_register_spine_TransformConstraint(se::Object* obj) // NOLINT(readabilit __jsb_spine_TransformConstraint_proto = cls->getProto(); __jsb_spine_TransformConstraint_class = cls; + se::ScriptEngine::getInstance()->clearException(); return true; } -se::Object* __jsb_spine_TransformConstraintData_proto = nullptr; -se::Class* __jsb_spine_TransformConstraintData_class = nullptr; +se::Object* __jsb_spine_TransformConstraintData_proto = nullptr; // NOLINT +se::Class* __jsb_spine_TransformConstraintData_class = nullptr; // NOLINT static bool js_spine_TransformConstraintData_getBones(se::State& s) // NOLINT(readability-identifier-naming) { @@ -12263,8 +12220,6 @@ static bool js_spine_TransformConstraintData_isRelative(se::State& s) // NOLINT( } SE_BIND_FUNC(js_spine_TransformConstraintData_isRelative) - - bool js_register_spine_TransformConstraintData(se::Object* obj) // NOLINT(readability-identifier-naming) { auto* cls = se::Class::create("TransformConstraintData", obj, __jsb_spine_ConstraintData_proto, nullptr); @@ -12289,11 +12244,12 @@ bool js_register_spine_TransformConstraintData(se::Object* obj) // NOLINT(readab __jsb_spine_TransformConstraintData_proto = cls->getProto(); __jsb_spine_TransformConstraintData_class = cls; + se::ScriptEngine::getInstance()->clearException(); return true; } -se::Object* __jsb_spine_TransformConstraintTimeline_proto = nullptr; -se::Class* __jsb_spine_TransformConstraintTimeline_class = nullptr; +se::Object* __jsb_spine_TransformConstraintTimeline_proto = nullptr; // NOLINT +se::Class* __jsb_spine_TransformConstraintTimeline_class = nullptr; // NOLINT static bool js_spine_TransformConstraintTimeline_getPropertyId(se::State& s) // NOLINT(readability-identifier-naming) { @@ -12343,8 +12299,6 @@ static bool js_spine_TransformConstraintTimeline_setFrame(se::State& s) // NOLIN } SE_BIND_FUNC(js_spine_TransformConstraintTimeline_setFrame) - - bool js_register_spine_TransformConstraintTimeline(se::Object* obj) // NOLINT(readability-identifier-naming) { auto* cls = se::Class::create("TransformConstraintTimeline", obj, __jsb_spine_CurveTimeline_proto, nullptr); @@ -12357,11 +12311,12 @@ bool js_register_spine_TransformConstraintTimeline(se::Object* obj) // NOLINT(re __jsb_spine_TransformConstraintTimeline_proto = cls->getProto(); __jsb_spine_TransformConstraintTimeline_class = cls; + se::ScriptEngine::getInstance()->clearException(); return true; } -se::Object* __jsb_spine_TwoColorTimeline_proto = nullptr; -se::Class* __jsb_spine_TwoColorTimeline_class = nullptr; +se::Object* __jsb_spine_TwoColorTimeline_proto = nullptr; // NOLINT +se::Class* __jsb_spine_TwoColorTimeline_class = nullptr; // NOLINT static bool js_spine_TwoColorTimeline_getPropertyId(se::State& s) // NOLINT(readability-identifier-naming) { @@ -12455,8 +12410,6 @@ static bool js_spine_TwoColorTimeline_setSlotIndex(se::State& s) // NOLINT(reada } SE_BIND_FUNC(js_spine_TwoColorTimeline_setSlotIndex) - - bool js_register_spine_TwoColorTimeline(se::Object* obj) // NOLINT(readability-identifier-naming) { auto* cls = se::Class::create("TwoColorTimeline", obj, __jsb_spine_CurveTimeline_proto, nullptr); @@ -12471,13 +12424,12 @@ bool js_register_spine_TwoColorTimeline(se::Object* obj) // NOLINT(readability-i __jsb_spine_TwoColorTimeline_proto = cls->getProto(); __jsb_spine_TwoColorTimeline_class = cls; + se::ScriptEngine::getInstance()->clearException(); return true; } -se::Object* __jsb_spine_VertexEffect_proto = nullptr; -se::Class* __jsb_spine_VertexEffect_class = nullptr; - - +se::Object* __jsb_spine_VertexEffect_proto = nullptr; // NOLINT +se::Class* __jsb_spine_VertexEffect_class = nullptr; // NOLINT bool js_register_spine_VertexEffect(se::Object* obj) // NOLINT(readability-identifier-naming) { @@ -12489,11 +12441,12 @@ bool js_register_spine_VertexEffect(se::Object* obj) // NOLINT(readability-ident __jsb_spine_VertexEffect_proto = cls->getProto(); __jsb_spine_VertexEffect_class = cls; + se::ScriptEngine::getInstance()->clearException(); return true; } -se::Object* __jsb_spine_JitterVertexEffect_proto = nullptr; -se::Class* __jsb_spine_JitterVertexEffect_class = nullptr; +se::Object* __jsb_spine_JitterVertexEffect_proto = nullptr; // NOLINT +se::Class* __jsb_spine_JitterVertexEffect_class = nullptr; // NOLINT static bool js_spine_JitterVertexEffect_getJitterX(se::State& s) // NOLINT(readability-identifier-naming) { @@ -12571,8 +12524,6 @@ static bool js_spine_JitterVertexEffect_setJitterY(se::State& s) // NOLINT(reada } SE_BIND_FUNC(js_spine_JitterVertexEffect_setJitterY) - - bool js_register_spine_JitterVertexEffect(se::Object* obj) // NOLINT(readability-identifier-naming) { auto* cls = se::Class::create("JitterVertexEffect", obj, __jsb_spine_VertexEffect_proto, nullptr); @@ -12587,11 +12538,12 @@ bool js_register_spine_JitterVertexEffect(se::Object* obj) // NOLINT(readability __jsb_spine_JitterVertexEffect_proto = cls->getProto(); __jsb_spine_JitterVertexEffect_class = cls; + se::ScriptEngine::getInstance()->clearException(); return true; } -se::Object* __jsb_spine_SwirlVertexEffect_proto = nullptr; -se::Class* __jsb_spine_SwirlVertexEffect_class = nullptr; +se::Object* __jsb_spine_SwirlVertexEffect_proto = nullptr; // NOLINT +se::Class* __jsb_spine_SwirlVertexEffect_class = nullptr; // NOLINT static bool js_spine_SwirlVertexEffect_getAngle(se::State& s) // NOLINT(readability-identifier-naming) { @@ -12821,8 +12773,6 @@ static bool js_spine_SwirlVertexEffect_setWorldY(se::State& s) // NOLINT(readabi } SE_BIND_FUNC(js_spine_SwirlVertexEffect_setWorldY) - - bool js_register_spine_SwirlVertexEffect(se::Object* obj) // NOLINT(readability-identifier-naming) { auto* cls = se::Class::create("SwirlVertexEffect", obj, __jsb_spine_VertexEffect_proto, nullptr); @@ -12845,11 +12795,12 @@ bool js_register_spine_SwirlVertexEffect(se::Object* obj) // NOLINT(readability- __jsb_spine_SwirlVertexEffect_proto = cls->getProto(); __jsb_spine_SwirlVertexEffect_class = cls; + se::ScriptEngine::getInstance()->clearException(); return true; } -se::Object* __jsb_spine_VertexEffectDelegate_proto = nullptr; -se::Class* __jsb_spine_VertexEffectDelegate_class = nullptr; +se::Object* __jsb_spine_VertexEffectDelegate_proto = nullptr; // NOLINT +se::Class* __jsb_spine_VertexEffectDelegate_class = nullptr; // NOLINT static bool js_spine_VertexEffectDelegate_clear(se::State& s) // NOLINT(readability-identifier-naming) { @@ -13018,18 +12969,14 @@ SE_DECLARE_FINALIZE_FUNC(js_spine_VertexEffectDelegate_finalize) static bool js_spine_VertexEffectDelegate_constructor(se::State& s) // NOLINT(readability-identifier-naming) constructor.c { - spine::VertexEffectDelegate* cobj = JSB_ALLOC(spine::VertexEffectDelegate); - s.thisObject()->setPrivateData(cobj); + auto *ptr = JSB_MAKE_PRIVATE_OBJECT(spine::VertexEffectDelegate); + s.thisObject()->setPrivateObject(ptr); return true; } SE_BIND_CTOR(js_spine_VertexEffectDelegate_constructor, __jsb_spine_VertexEffectDelegate_class, js_spine_VertexEffectDelegate_finalize) - - static bool js_spine_VertexEffectDelegate_finalize(se::State& s) // NOLINT(readability-identifier-naming) { - auto* cobj =SE_THIS_OBJECT(s); - cobj->release(); return true; } SE_BIND_FINALIZE_FUNC(js_spine_VertexEffectDelegate_finalize) @@ -13053,11 +13000,12 @@ bool js_register_spine_VertexEffectDelegate(se::Object* obj) // NOLINT(readabili __jsb_spine_VertexEffectDelegate_proto = cls->getProto(); __jsb_spine_VertexEffectDelegate_class = cls; + se::ScriptEngine::getInstance()->clearException(); return true; } -se::Object* __jsb_spine_SkeletonRenderer_proto = nullptr; -se::Class* __jsb_spine_SkeletonRenderer_class = nullptr; +se::Object* __jsb_spine_SkeletonRenderer_proto = nullptr; // NOLINT +se::Class* __jsb_spine_SkeletonRenderer_class = nullptr; // NOLINT static bool js_spine_SkeletonRenderer_beginSchedule(se::State& s) // NOLINT(readability-identifier-naming) { @@ -13832,8 +13780,8 @@ static bool js_spine_SkeletonRenderer_constructor(se::State& s) // NOLINT(readab HolderType arg0 = {}; ok &= sevalue_to_native(args[0], &arg0, s.thisObject()); if (!ok) { ok = true; break; } - spine::SkeletonRenderer* cobj = JSB_ALLOC(spine::SkeletonRenderer, arg0.value()); - s.thisObject()->setPrivateData(cobj); + auto *ptr = JSB_MAKE_PRIVATE_OBJECT(spine::SkeletonRenderer, arg0.value()); + s.thisObject()->setPrivateObject(ptr); return true; } } while(false); @@ -13845,8 +13793,8 @@ static bool js_spine_SkeletonRenderer_constructor(se::State& s) // NOLINT(readab HolderType arg1 = {}; ok &= sevalue_to_native(args[1], &arg1, s.thisObject()); if (!ok) { ok = true; break; } - spine::SkeletonRenderer* cobj = JSB_ALLOC(spine::SkeletonRenderer, arg0.value(), arg1.value()); - s.thisObject()->setPrivateData(cobj); + auto *ptr = JSB_MAKE_PRIVATE_OBJECT(spine::SkeletonRenderer, arg0.value(), arg1.value()); + s.thisObject()->setPrivateObject(ptr); return true; } } while(false); @@ -13861,8 +13809,8 @@ static bool js_spine_SkeletonRenderer_constructor(se::State& s) // NOLINT(readab HolderType arg2 = {}; ok &= sevalue_to_native(args[2], &arg2, s.thisObject()); if (!ok) { ok = true; break; } - spine::SkeletonRenderer* cobj = JSB_ALLOC(spine::SkeletonRenderer, arg0.value(), arg1.value(), arg2.value()); - s.thisObject()->setPrivateData(cobj); + auto *ptr = JSB_MAKE_PRIVATE_OBJECT(spine::SkeletonRenderer, arg0.value(), arg1.value(), arg2.value()); + s.thisObject()->setPrivateObject(ptr); return true; } } while(false); @@ -13880,15 +13828,15 @@ static bool js_spine_SkeletonRenderer_constructor(se::State& s) // NOLINT(readab HolderType arg3 = {}; ok &= sevalue_to_native(args[3], &arg3, s.thisObject()); if (!ok) { ok = true; break; } - spine::SkeletonRenderer* cobj = JSB_ALLOC(spine::SkeletonRenderer, arg0.value(), arg1.value(), arg2.value(), arg3.value()); - s.thisObject()->setPrivateData(cobj); + auto *ptr = JSB_MAKE_PRIVATE_OBJECT(spine::SkeletonRenderer, arg0.value(), arg1.value(), arg2.value(), arg3.value()); + s.thisObject()->setPrivateObject(ptr); return true; } } while(false); do { if (argc == 0) { - spine::SkeletonRenderer* cobj = JSB_ALLOC(spine::SkeletonRenderer); - s.thisObject()->setPrivateData(cobj); + auto *ptr = JSB_MAKE_PRIVATE_OBJECT(spine::SkeletonRenderer); + s.thisObject()->setPrivateObject(ptr); return true; } } while(false); @@ -13897,8 +13845,8 @@ static bool js_spine_SkeletonRenderer_constructor(se::State& s) // NOLINT(readab HolderType arg0 = {}; ok &= sevalue_to_native(args[0], &arg0, s.thisObject()); if (!ok) { ok = true; break; } - spine::SkeletonRenderer* cobj = JSB_ALLOC(spine::SkeletonRenderer, arg0.value()); - s.thisObject()->setPrivateData(cobj); + auto *ptr = JSB_MAKE_PRIVATE_OBJECT(spine::SkeletonRenderer, arg0.value()); + s.thisObject()->setPrivateObject(ptr); return true; } } while(false); @@ -13910,8 +13858,8 @@ static bool js_spine_SkeletonRenderer_constructor(se::State& s) // NOLINT(readab HolderType arg1 = {}; ok &= sevalue_to_native(args[1], &arg1, s.thisObject()); if (!ok) { ok = true; break; } - spine::SkeletonRenderer* cobj = JSB_ALLOC(spine::SkeletonRenderer, arg0.value(), arg1.value()); - s.thisObject()->setPrivateData(cobj); + auto *ptr = JSB_MAKE_PRIVATE_OBJECT(spine::SkeletonRenderer, arg0.value(), arg1.value()); + s.thisObject()->setPrivateObject(ptr); return true; } } while(false); @@ -13923,8 +13871,8 @@ static bool js_spine_SkeletonRenderer_constructor(se::State& s) // NOLINT(readab HolderType arg1 = {}; ok &= sevalue_to_native(args[1], &arg1, s.thisObject()); if (!ok) { ok = true; break; } - spine::SkeletonRenderer* cobj = JSB_ALLOC(spine::SkeletonRenderer, arg0.value(), arg1.value()); - s.thisObject()->setPrivateData(cobj); + auto *ptr = JSB_MAKE_PRIVATE_OBJECT(spine::SkeletonRenderer, arg0.value(), arg1.value()); + s.thisObject()->setPrivateObject(ptr); return true; } } while(false); @@ -13939,8 +13887,8 @@ static bool js_spine_SkeletonRenderer_constructor(se::State& s) // NOLINT(readab HolderType arg2 = {}; ok &= sevalue_to_native(args[2], &arg2, s.thisObject()); if (!ok) { ok = true; break; } - spine::SkeletonRenderer* cobj = JSB_ALLOC(spine::SkeletonRenderer, arg0.value(), arg1.value(), arg2.value()); - s.thisObject()->setPrivateData(cobj); + auto *ptr = JSB_MAKE_PRIVATE_OBJECT(spine::SkeletonRenderer, arg0.value(), arg1.value(), arg2.value()); + s.thisObject()->setPrivateObject(ptr); return true; } } while(false); @@ -13949,12 +13897,8 @@ static bool js_spine_SkeletonRenderer_constructor(se::State& s) // NOLINT(readab } SE_BIND_CTOR(js_spine_SkeletonRenderer_constructor, __jsb_spine_SkeletonRenderer_class, js_spine_SkeletonRenderer_finalize) - - static bool js_spine_SkeletonRenderer_finalize(se::State& s) // NOLINT(readability-identifier-naming) { - auto* cobj =SE_THIS_OBJECT(s); - cobj->release(); return true; } SE_BIND_FINALIZE_FUNC(js_spine_SkeletonRenderer_finalize) @@ -14007,11 +13951,12 @@ bool js_register_spine_SkeletonRenderer(se::Object* obj) // NOLINT(readability-i __jsb_spine_SkeletonRenderer_proto = cls->getProto(); __jsb_spine_SkeletonRenderer_class = cls; + se::ScriptEngine::getInstance()->clearException(); return true; } -se::Object* __jsb_spine_SkeletonAnimation_proto = nullptr; -se::Class* __jsb_spine_SkeletonAnimation_class = nullptr; +se::Object* __jsb_spine_SkeletonAnimation_proto = nullptr; // NOLINT +se::Class* __jsb_spine_SkeletonAnimation_class = nullptr; // NOLINT static bool js_spine_SkeletonAnimation_addAnimation(se::State& s) // NOLINT(readability-identifier-naming) { @@ -14261,6 +14206,7 @@ static bool js_spine_SkeletonAnimation_setCompleteListener(se::State& s) // NOLI se::Value jsThis(s.thisObject()); se::Value jsFunc(args[0]); jsThis.toObject()->attachObject(jsFunc.toObject()); + auto * thisObj = s.thisObject(); auto lambda = [=](spine::TrackEntry* larg0) -> void { se::ScriptEngine::getInstance()->clearException(); se::AutoHandleScope hs; @@ -14270,7 +14216,6 @@ static bool js_spine_SkeletonAnimation_setCompleteListener(se::State& s) // NOLI args.resize(1); ok &= nativevalue_to_se(larg0, args[0], nullptr /*ctx*/); se::Value rval; - se::Object* thisObj = jsThis.isObject() ? jsThis.toObject() : nullptr; se::Object* funcObj = jsFunc.toObject(); bool succeed = funcObj->call(args, thisObj, &rval); if (!succeed) { @@ -14309,6 +14254,7 @@ static bool js_spine_SkeletonAnimation_setDisposeListener(se::State& s) // NOLIN se::Value jsThis(s.thisObject()); se::Value jsFunc(args[0]); jsThis.toObject()->attachObject(jsFunc.toObject()); + auto * thisObj = s.thisObject(); auto lambda = [=](spine::TrackEntry* larg0) -> void { se::ScriptEngine::getInstance()->clearException(); se::AutoHandleScope hs; @@ -14318,7 +14264,6 @@ static bool js_spine_SkeletonAnimation_setDisposeListener(se::State& s) // NOLIN args.resize(1); ok &= nativevalue_to_se(larg0, args[0], nullptr /*ctx*/); se::Value rval; - se::Object* thisObj = jsThis.isObject() ? jsThis.toObject() : nullptr; se::Object* funcObj = jsFunc.toObject(); bool succeed = funcObj->call(args, thisObj, &rval); if (!succeed) { @@ -14400,6 +14345,7 @@ static bool js_spine_SkeletonAnimation_setEndListener(se::State& s) // NOLINT(re se::Value jsThis(s.thisObject()); se::Value jsFunc(args[0]); jsThis.toObject()->attachObject(jsFunc.toObject()); + auto * thisObj = s.thisObject(); auto lambda = [=](spine::TrackEntry* larg0) -> void { se::ScriptEngine::getInstance()->clearException(); se::AutoHandleScope hs; @@ -14409,7 +14355,6 @@ static bool js_spine_SkeletonAnimation_setEndListener(se::State& s) // NOLINT(re args.resize(1); ok &= nativevalue_to_se(larg0, args[0], nullptr /*ctx*/); se::Value rval; - se::Object* thisObj = jsThis.isObject() ? jsThis.toObject() : nullptr; se::Object* funcObj = jsFunc.toObject(); bool succeed = funcObj->call(args, thisObj, &rval); if (!succeed) { @@ -14448,6 +14393,7 @@ static bool js_spine_SkeletonAnimation_setEventListener(se::State& s) // NOLINT( se::Value jsThis(s.thisObject()); se::Value jsFunc(args[0]); jsThis.toObject()->attachObject(jsFunc.toObject()); + auto * thisObj = s.thisObject(); auto lambda = [=](spine::TrackEntry* larg0, spine::Event* larg1) -> void { se::ScriptEngine::getInstance()->clearException(); se::AutoHandleScope hs; @@ -14458,7 +14404,6 @@ static bool js_spine_SkeletonAnimation_setEventListener(se::State& s) // NOLINT( ok &= nativevalue_to_se(larg0, args[0], nullptr /*ctx*/); ok &= nativevalue_to_se(larg1, args[1], nullptr /*ctx*/); se::Value rval; - se::Object* thisObj = jsThis.isObject() ? jsThis.toObject() : nullptr; se::Object* funcObj = jsFunc.toObject(); bool succeed = funcObj->call(args, thisObj, &rval); if (!succeed) { @@ -14497,6 +14442,7 @@ static bool js_spine_SkeletonAnimation_setInterruptListener(se::State& s) // NOL se::Value jsThis(s.thisObject()); se::Value jsFunc(args[0]); jsThis.toObject()->attachObject(jsFunc.toObject()); + auto * thisObj = s.thisObject(); auto lambda = [=](spine::TrackEntry* larg0) -> void { se::ScriptEngine::getInstance()->clearException(); se::AutoHandleScope hs; @@ -14506,7 +14452,6 @@ static bool js_spine_SkeletonAnimation_setInterruptListener(se::State& s) // NOL args.resize(1); ok &= nativevalue_to_se(larg0, args[0], nullptr /*ctx*/); se::Value rval; - se::Object* thisObj = jsThis.isObject() ? jsThis.toObject() : nullptr; se::Object* funcObj = jsFunc.toObject(); bool succeed = funcObj->call(args, thisObj, &rval); if (!succeed) { @@ -14568,6 +14513,7 @@ static bool js_spine_SkeletonAnimation_setStartListener(se::State& s) // NOLINT( se::Value jsThis(s.thisObject()); se::Value jsFunc(args[0]); jsThis.toObject()->attachObject(jsFunc.toObject()); + auto * thisObj = s.thisObject(); auto lambda = [=](spine::TrackEntry* larg0) -> void { se::ScriptEngine::getInstance()->clearException(); se::AutoHandleScope hs; @@ -14577,7 +14523,6 @@ static bool js_spine_SkeletonAnimation_setStartListener(se::State& s) // NOLINT( args.resize(1); ok &= nativevalue_to_se(larg0, args[0], nullptr /*ctx*/); se::Value rval; - se::Object* thisObj = jsThis.isObject() ? jsThis.toObject() : nullptr; se::Object* funcObj = jsFunc.toObject(); bool succeed = funcObj->call(args, thisObj, &rval); if (!succeed) { @@ -14618,6 +14563,7 @@ static bool js_spine_SkeletonAnimation_setTrackCompleteListener(se::State& s) // se::Value jsThis(s.thisObject()); se::Value jsFunc(args[1]); jsThis.toObject()->attachObject(jsFunc.toObject()); + auto * thisObj = s.thisObject(); auto lambda = [=](spine::TrackEntry* larg0) -> void { se::ScriptEngine::getInstance()->clearException(); se::AutoHandleScope hs; @@ -14627,7 +14573,6 @@ static bool js_spine_SkeletonAnimation_setTrackCompleteListener(se::State& s) // args.resize(1); ok &= nativevalue_to_se(larg0, args[0], nullptr /*ctx*/); se::Value rval; - se::Object* thisObj = jsThis.isObject() ? jsThis.toObject() : nullptr; se::Object* funcObj = jsFunc.toObject(); bool succeed = funcObj->call(args, thisObj, &rval); if (!succeed) { @@ -14668,6 +14613,7 @@ static bool js_spine_SkeletonAnimation_setTrackDisposeListener(se::State& s) // se::Value jsThis(s.thisObject()); se::Value jsFunc(args[1]); jsThis.toObject()->attachObject(jsFunc.toObject()); + auto * thisObj = s.thisObject(); auto lambda = [=](spine::TrackEntry* larg0) -> void { se::ScriptEngine::getInstance()->clearException(); se::AutoHandleScope hs; @@ -14677,7 +14623,6 @@ static bool js_spine_SkeletonAnimation_setTrackDisposeListener(se::State& s) // args.resize(1); ok &= nativevalue_to_se(larg0, args[0], nullptr /*ctx*/); se::Value rval; - se::Object* thisObj = jsThis.isObject() ? jsThis.toObject() : nullptr; se::Object* funcObj = jsFunc.toObject(); bool succeed = funcObj->call(args, thisObj, &rval); if (!succeed) { @@ -14718,6 +14663,7 @@ static bool js_spine_SkeletonAnimation_setTrackEndListener(se::State& s) // NOLI se::Value jsThis(s.thisObject()); se::Value jsFunc(args[1]); jsThis.toObject()->attachObject(jsFunc.toObject()); + auto * thisObj = s.thisObject(); auto lambda = [=](spine::TrackEntry* larg0) -> void { se::ScriptEngine::getInstance()->clearException(); se::AutoHandleScope hs; @@ -14727,7 +14673,6 @@ static bool js_spine_SkeletonAnimation_setTrackEndListener(se::State& s) // NOLI args.resize(1); ok &= nativevalue_to_se(larg0, args[0], nullptr /*ctx*/); se::Value rval; - se::Object* thisObj = jsThis.isObject() ? jsThis.toObject() : nullptr; se::Object* funcObj = jsFunc.toObject(); bool succeed = funcObj->call(args, thisObj, &rval); if (!succeed) { @@ -14768,6 +14713,7 @@ static bool js_spine_SkeletonAnimation_setTrackEventListener(se::State& s) // NO se::Value jsThis(s.thisObject()); se::Value jsFunc(args[1]); jsThis.toObject()->attachObject(jsFunc.toObject()); + auto * thisObj = s.thisObject(); auto lambda = [=](spine::TrackEntry* larg0, spine::Event* larg1) -> void { se::ScriptEngine::getInstance()->clearException(); se::AutoHandleScope hs; @@ -14778,7 +14724,6 @@ static bool js_spine_SkeletonAnimation_setTrackEventListener(se::State& s) // NO ok &= nativevalue_to_se(larg0, args[0], nullptr /*ctx*/); ok &= nativevalue_to_se(larg1, args[1], nullptr /*ctx*/); se::Value rval; - se::Object* thisObj = jsThis.isObject() ? jsThis.toObject() : nullptr; se::Object* funcObj = jsFunc.toObject(); bool succeed = funcObj->call(args, thisObj, &rval); if (!succeed) { @@ -14819,6 +14764,7 @@ static bool js_spine_SkeletonAnimation_setTrackInterruptListener(se::State& s) / se::Value jsThis(s.thisObject()); se::Value jsFunc(args[1]); jsThis.toObject()->attachObject(jsFunc.toObject()); + auto * thisObj = s.thisObject(); auto lambda = [=](spine::TrackEntry* larg0) -> void { se::ScriptEngine::getInstance()->clearException(); se::AutoHandleScope hs; @@ -14828,7 +14774,6 @@ static bool js_spine_SkeletonAnimation_setTrackInterruptListener(se::State& s) / args.resize(1); ok &= nativevalue_to_se(larg0, args[0], nullptr /*ctx*/); se::Value rval; - se::Object* thisObj = jsThis.isObject() ? jsThis.toObject() : nullptr; se::Object* funcObj = jsFunc.toObject(); bool succeed = funcObj->call(args, thisObj, &rval); if (!succeed) { @@ -14869,6 +14814,7 @@ static bool js_spine_SkeletonAnimation_setTrackStartListener(se::State& s) // NO se::Value jsThis(s.thisObject()); se::Value jsFunc(args[1]); jsThis.toObject()->attachObject(jsFunc.toObject()); + auto * thisObj = s.thisObject(); auto lambda = [=](spine::TrackEntry* larg0) -> void { se::ScriptEngine::getInstance()->clearException(); se::AutoHandleScope hs; @@ -14878,7 +14824,6 @@ static bool js_spine_SkeletonAnimation_setTrackStartListener(se::State& s) // NO args.resize(1); ok &= nativevalue_to_se(larg0, args[0], nullptr /*ctx*/); se::Value rval; - se::Object* thisObj = jsThis.isObject() ? jsThis.toObject() : nullptr; se::Object* funcObj = jsFunc.toObject(); bool succeed = funcObj->call(args, thisObj, &rval); if (!succeed) { @@ -14902,25 +14847,24 @@ static bool js_spine_SkeletonAnimation_setTrackStartListener(se::State& s) // NO } SE_BIND_FUNC(js_spine_SkeletonAnimation_setTrackStartListener) -static bool js_spine_SkeletonAnimation_create(se::State& s) // NOLINT(readability-identifier-naming) +static bool js_spine_SkeletonAnimation_create_static(se::State& s) // NOLINT(readability-identifier-naming) { const auto& args = s.args(); size_t argc = args.size(); CC_UNUSED bool ok = true; if (argc == 0) { - auto result = spine::SkeletonAnimation::create(); - result->retain(); - auto obj = se::Object::createObjectWithClass(__jsb_spine_SkeletonAnimation_class); - obj->setPrivateData(result); - s.rval().setObject(obj); + spine::SkeletonAnimation* result = spine::SkeletonAnimation::create(); + ok &= nativevalue_to_se(result, s.rval(), nullptr /*ctx*/); + SE_PRECONDITION2(ok, false, "js_spine_SkeletonAnimation_create_static : Error processing arguments"); + SE_HOLD_RETURN_VALUE(result, s.thisObject(), s.rval()); return true; } SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 0); return false; } -SE_BIND_FUNC(js_spine_SkeletonAnimation_create) +SE_BIND_FUNC(js_spine_SkeletonAnimation_create_static) -static bool js_spine_SkeletonAnimation_createWithJsonFile(se::State& s) // NOLINT(readability-identifier-naming) +static bool js_spine_SkeletonAnimation_createWithBinaryFile_static(se::State& s) // NOLINT(readability-identifier-naming) { const auto& args = s.args(); size_t argc = args.size(); @@ -14930,12 +14874,11 @@ static bool js_spine_SkeletonAnimation_createWithJsonFile(se::State& s) // NOLIN HolderType arg1 = {}; ok &= sevalue_to_native(args[0], &arg0, nullptr); ok &= sevalue_to_native(args[1], &arg1, nullptr); - SE_PRECONDITION2(ok, false, "js_spine_SkeletonAnimation_createWithJsonFile : Error processing arguments"); - auto result = spine::SkeletonAnimation::createWithJsonFile(arg0.value(), arg1.value()); - result->retain(); - auto obj = se::Object::createObjectWithClass(__jsb_spine_SkeletonAnimation_class); - obj->setPrivateData(result); - s.rval().setObject(obj); + SE_PRECONDITION2(ok, false, "js_spine_SkeletonAnimation_createWithBinaryFile_static : Error processing arguments"); + spine::SkeletonAnimation* result = spine::SkeletonAnimation::createWithBinaryFile(arg0.value(), arg1.value()); + ok &= nativevalue_to_se(result, s.rval(), nullptr /*ctx*/); + SE_PRECONDITION2(ok, false, "js_spine_SkeletonAnimation_createWithBinaryFile_static : Error processing arguments"); + SE_HOLD_RETURN_VALUE(result, s.thisObject(), s.rval()); return true; } if (argc == 3) { @@ -14945,20 +14888,19 @@ static bool js_spine_SkeletonAnimation_createWithJsonFile(se::State& s) // NOLIN ok &= sevalue_to_native(args[0], &arg0, nullptr); ok &= sevalue_to_native(args[1], &arg1, nullptr); ok &= sevalue_to_native(args[2], &arg2, nullptr); - SE_PRECONDITION2(ok, false, "js_spine_SkeletonAnimation_createWithJsonFile : Error processing arguments"); - auto result = spine::SkeletonAnimation::createWithJsonFile(arg0.value(), arg1.value(), arg2.value()); - result->retain(); - auto obj = se::Object::createObjectWithClass(__jsb_spine_SkeletonAnimation_class); - obj->setPrivateData(result); - s.rval().setObject(obj); + SE_PRECONDITION2(ok, false, "js_spine_SkeletonAnimation_createWithBinaryFile_static : Error processing arguments"); + spine::SkeletonAnimation* result = spine::SkeletonAnimation::createWithBinaryFile(arg0.value(), arg1.value(), arg2.value()); + ok &= nativevalue_to_se(result, s.rval(), nullptr /*ctx*/); + SE_PRECONDITION2(ok, false, "js_spine_SkeletonAnimation_createWithBinaryFile_static : Error processing arguments"); + SE_HOLD_RETURN_VALUE(result, s.thisObject(), s.rval()); return true; } SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 3); return false; } -SE_BIND_FUNC(js_spine_SkeletonAnimation_createWithJsonFile) +SE_BIND_FUNC(js_spine_SkeletonAnimation_createWithBinaryFile_static) -static bool js_spine_SkeletonAnimation_createWithBinaryFile(se::State& s) // NOLINT(readability-identifier-naming) +static bool js_spine_SkeletonAnimation_createWithJsonFile_static(se::State& s) // NOLINT(readability-identifier-naming) { const auto& args = s.args(); size_t argc = args.size(); @@ -14968,12 +14910,11 @@ static bool js_spine_SkeletonAnimation_createWithBinaryFile(se::State& s) // NOL HolderType arg1 = {}; ok &= sevalue_to_native(args[0], &arg0, nullptr); ok &= sevalue_to_native(args[1], &arg1, nullptr); - SE_PRECONDITION2(ok, false, "js_spine_SkeletonAnimation_createWithBinaryFile : Error processing arguments"); - auto result = spine::SkeletonAnimation::createWithBinaryFile(arg0.value(), arg1.value()); - result->retain(); - auto obj = se::Object::createObjectWithClass(__jsb_spine_SkeletonAnimation_class); - obj->setPrivateData(result); - s.rval().setObject(obj); + SE_PRECONDITION2(ok, false, "js_spine_SkeletonAnimation_createWithJsonFile_static : Error processing arguments"); + spine::SkeletonAnimation* result = spine::SkeletonAnimation::createWithJsonFile(arg0.value(), arg1.value()); + ok &= nativevalue_to_se(result, s.rval(), nullptr /*ctx*/); + SE_PRECONDITION2(ok, false, "js_spine_SkeletonAnimation_createWithJsonFile_static : Error processing arguments"); + SE_HOLD_RETURN_VALUE(result, s.thisObject(), s.rval()); return true; } if (argc == 3) { @@ -14983,20 +14924,19 @@ static bool js_spine_SkeletonAnimation_createWithBinaryFile(se::State& s) // NOL ok &= sevalue_to_native(args[0], &arg0, nullptr); ok &= sevalue_to_native(args[1], &arg1, nullptr); ok &= sevalue_to_native(args[2], &arg2, nullptr); - SE_PRECONDITION2(ok, false, "js_spine_SkeletonAnimation_createWithBinaryFile : Error processing arguments"); - auto result = spine::SkeletonAnimation::createWithBinaryFile(arg0.value(), arg1.value(), arg2.value()); - result->retain(); - auto obj = se::Object::createObjectWithClass(__jsb_spine_SkeletonAnimation_class); - obj->setPrivateData(result); - s.rval().setObject(obj); + SE_PRECONDITION2(ok, false, "js_spine_SkeletonAnimation_createWithJsonFile_static : Error processing arguments"); + spine::SkeletonAnimation* result = spine::SkeletonAnimation::createWithJsonFile(arg0.value(), arg1.value(), arg2.value()); + ok &= nativevalue_to_se(result, s.rval(), nullptr /*ctx*/); + SE_PRECONDITION2(ok, false, "js_spine_SkeletonAnimation_createWithJsonFile_static : Error processing arguments"); + SE_HOLD_RETURN_VALUE(result, s.thisObject(), s.rval()); return true; } SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 3); return false; } -SE_BIND_FUNC(js_spine_SkeletonAnimation_createWithBinaryFile) +SE_BIND_FUNC(js_spine_SkeletonAnimation_createWithJsonFile_static) -static bool js_spine_SkeletonAnimation_setGlobalTimeScale(se::State& s) // NOLINT(readability-identifier-naming) +static bool js_spine_SkeletonAnimation_setGlobalTimeScale_static(se::State& s) // NOLINT(readability-identifier-naming) { const auto& args = s.args(); size_t argc = args.size(); @@ -15004,40 +14944,36 @@ static bool js_spine_SkeletonAnimation_setGlobalTimeScale(se::State& s) // NOLIN if (argc == 1) { HolderType arg0 = {}; ok &= sevalue_to_native(args[0], &arg0, nullptr); - SE_PRECONDITION2(ok, false, "js_spine_SkeletonAnimation_setGlobalTimeScale : Error processing arguments"); + SE_PRECONDITION2(ok, false, "js_spine_SkeletonAnimation_setGlobalTimeScale_static : Error processing arguments"); spine::SkeletonAnimation::setGlobalTimeScale(arg0.value()); return true; } SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 1); return false; } -SE_BIND_FUNC(js_spine_SkeletonAnimation_setGlobalTimeScale) +SE_BIND_FUNC(js_spine_SkeletonAnimation_setGlobalTimeScale_static) SE_DECLARE_FINALIZE_FUNC(js_spine_SkeletonAnimation_finalize) static bool js_spine_SkeletonAnimation_constructor(se::State& s) // NOLINT(readability-identifier-naming) constructor.c { - spine::SkeletonAnimation* cobj = JSB_ALLOC(spine::SkeletonAnimation); - s.thisObject()->setPrivateData(cobj); + auto *ptr = JSB_MAKE_PRIVATE_OBJECT(spine::SkeletonAnimation); + s.thisObject()->setPrivateObject(ptr); return true; } SE_BIND_CTOR(js_spine_SkeletonAnimation_constructor, __jsb_spine_SkeletonAnimation_class, js_spine_SkeletonAnimation_finalize) static bool js_spine_SkeletonAnimation_ctor(se::State& s) // NOLINT(readability-identifier-naming) { - spine::SkeletonAnimation* cobj = JSB_ALLOC(spine::SkeletonAnimation); - s.thisObject()->setPrivateData(cobj); + auto *ptr = JSB_MAKE_PRIVATE_OBJECT(spine::SkeletonAnimation); + s.thisObject()->setPrivateObject(ptr); return true; } SE_BIND_SUB_CLS_CTOR(js_spine_SkeletonAnimation_ctor, __jsb_spine_SkeletonAnimation_class, js_spine_SkeletonAnimation_finalize) - - static bool js_spine_SkeletonAnimation_finalize(se::State& s) // NOLINT(readability-identifier-naming) { - auto* cobj =SE_THIS_OBJECT(s); - cobj->release(); return true; } SE_BIND_FINALIZE_FUNC(js_spine_SkeletonAnimation_finalize) @@ -15071,10 +15007,10 @@ bool js_register_spine_SkeletonAnimation(se::Object* obj) // NOLINT(readability- cls->defineFunction("setTrackInterruptListener", _SE(js_spine_SkeletonAnimation_setTrackInterruptListener)); cls->defineFunction("setTrackStartListener", _SE(js_spine_SkeletonAnimation_setTrackStartListener)); cls->defineFunction("ctor", _SE(js_spine_SkeletonAnimation_ctor)); - cls->defineStaticFunction("create", _SE(js_spine_SkeletonAnimation_create)); - cls->defineStaticFunction("createWithJsonFile", _SE(js_spine_SkeletonAnimation_createWithJsonFile)); - cls->defineStaticFunction("createWithBinaryFile", _SE(js_spine_SkeletonAnimation_createWithBinaryFile)); - cls->defineStaticFunction("setGlobalTimeScale", _SE(js_spine_SkeletonAnimation_setGlobalTimeScale)); + cls->defineStaticFunction("create", _SE(js_spine_SkeletonAnimation_create_static)); + cls->defineStaticFunction("createWithBinaryFile", _SE(js_spine_SkeletonAnimation_createWithBinaryFile_static)); + cls->defineStaticFunction("createWithJsonFile", _SE(js_spine_SkeletonAnimation_createWithJsonFile_static)); + cls->defineStaticFunction("setGlobalTimeScale", _SE(js_spine_SkeletonAnimation_setGlobalTimeScale_static)); cls->defineFinalizeFunction(_SE(js_spine_SkeletonAnimation_finalize)); cls->install(); JSBClassType::registerClass(cls); @@ -15083,11 +15019,12 @@ bool js_register_spine_SkeletonAnimation(se::Object* obj) // NOLINT(readability- __jsb_spine_SkeletonAnimation_class = cls; jsb_set_extend_property("spine", "SkeletonAnimation"); + se::ScriptEngine::getInstance()->clearException(); return true; } -se::Object* __jsb_spine_SkeletonCacheAnimation_proto = nullptr; -se::Class* __jsb_spine_SkeletonCacheAnimation_class = nullptr; +se::Object* __jsb_spine_SkeletonCacheAnimation_proto = nullptr; // NOLINT +se::Class* __jsb_spine_SkeletonCacheAnimation_class = nullptr; // NOLINT static bool js_spine_SkeletonCacheAnimation_addAnimation(se::State& s) // NOLINT(readability-identifier-naming) { @@ -15530,6 +15467,7 @@ static bool js_spine_SkeletonCacheAnimation_setCompleteListener(se::State& s) // se::Value jsThis(s.thisObject()); se::Value jsFunc(args[0]); jsThis.toObject()->attachObject(jsFunc.toObject()); + auto * thisObj = s.thisObject(); auto lambda = [=](std::string larg0) -> void { se::ScriptEngine::getInstance()->clearException(); se::AutoHandleScope hs; @@ -15539,7 +15477,6 @@ static bool js_spine_SkeletonCacheAnimation_setCompleteListener(se::State& s) // args.resize(1); ok &= nativevalue_to_se(larg0, args[0], nullptr /*ctx*/); se::Value rval; - se::Object* thisObj = jsThis.isObject() ? jsThis.toObject() : nullptr; se::Object* funcObj = jsFunc.toObject(); bool succeed = funcObj->call(args, thisObj, &rval); if (!succeed) { @@ -15578,6 +15515,7 @@ static bool js_spine_SkeletonCacheAnimation_setEndListener(se::State& s) // NOLI se::Value jsThis(s.thisObject()); se::Value jsFunc(args[0]); jsThis.toObject()->attachObject(jsFunc.toObject()); + auto * thisObj = s.thisObject(); auto lambda = [=](std::string larg0) -> void { se::ScriptEngine::getInstance()->clearException(); se::AutoHandleScope hs; @@ -15587,7 +15525,6 @@ static bool js_spine_SkeletonCacheAnimation_setEndListener(se::State& s) // NOLI args.resize(1); ok &= nativevalue_to_se(larg0, args[0], nullptr /*ctx*/); se::Value rval; - se::Object* thisObj = jsThis.isObject() ? jsThis.toObject() : nullptr; se::Object* funcObj = jsFunc.toObject(); bool succeed = funcObj->call(args, thisObj, &rval); if (!succeed) { @@ -15694,6 +15631,7 @@ static bool js_spine_SkeletonCacheAnimation_setStartListener(se::State& s) // NO se::Value jsThis(s.thisObject()); se::Value jsFunc(args[0]); jsThis.toObject()->attachObject(jsFunc.toObject()); + auto * thisObj = s.thisObject(); auto lambda = [=](std::string larg0) -> void { se::ScriptEngine::getInstance()->clearException(); se::AutoHandleScope hs; @@ -15703,7 +15641,6 @@ static bool js_spine_SkeletonCacheAnimation_setStartListener(se::State& s) // NO args.resize(1); ok &= nativevalue_to_se(larg0, args[0], nullptr /*ctx*/); se::Value rval; - se::Object* thisObj = jsThis.isObject() ? jsThis.toObject() : nullptr; se::Object* funcObj = jsFunc.toObject(); bool succeed = funcObj->call(args, thisObj, &rval); if (!succeed) { @@ -15859,18 +15796,14 @@ static bool js_spine_SkeletonCacheAnimation_constructor(se::State& s) // NOLINT( ok &= sevalue_to_native(args[0], &arg0, s.thisObject()); ok &= sevalue_to_native(args[1], &arg1, s.thisObject()); SE_PRECONDITION2(ok, false, "js_spine_SkeletonCacheAnimation_constructor : Error processing arguments"); - spine::SkeletonCacheAnimation* cobj = JSB_ALLOC(spine::SkeletonCacheAnimation, arg0, arg1); - s.thisObject()->setPrivateData(cobj); + auto *ptr = JSB_MAKE_PRIVATE_OBJECT(spine::SkeletonCacheAnimation, arg0, arg1); + s.thisObject()->setPrivateObject(ptr); return true; } SE_BIND_CTOR(js_spine_SkeletonCacheAnimation_constructor, __jsb_spine_SkeletonCacheAnimation_class, js_spine_SkeletonCacheAnimation_finalize) - - static bool js_spine_SkeletonCacheAnimation_finalize(se::State& s) // NOLINT(readability-identifier-naming) { - auto* cobj =SE_THIS_OBJECT(s); - cobj->release(); return true; } SE_BIND_FINALIZE_FUNC(js_spine_SkeletonCacheAnimation_finalize) @@ -15919,11 +15852,12 @@ bool js_register_spine_SkeletonCacheAnimation(se::Object* obj) // NOLINT(readabi __jsb_spine_SkeletonCacheAnimation_proto = cls->getProto(); __jsb_spine_SkeletonCacheAnimation_class = cls; + se::ScriptEngine::getInstance()->clearException(); return true; } -se::Object* __jsb_spine_SkeletonCacheMgr_proto = nullptr; -se::Class* __jsb_spine_SkeletonCacheMgr_class = nullptr; +se::Object* __jsb_spine_SkeletonCacheMgr_proto = nullptr; // NOLINT +se::Class* __jsb_spine_SkeletonCacheMgr_class = nullptr; // NOLINT static bool js_spine_SkeletonCacheMgr_buildSkeletonCache(se::State& s) // NOLINT(readability-identifier-naming) { @@ -15966,24 +15900,7 @@ static bool js_spine_SkeletonCacheMgr_removeSkeletonCache(se::State& s) // NOLIN } SE_BIND_FUNC(js_spine_SkeletonCacheMgr_removeSkeletonCache) -static bool js_spine_SkeletonCacheMgr_getInstance(se::State& s) // NOLINT(readability-identifier-naming) -{ - const auto& args = s.args(); - size_t argc = args.size(); - CC_UNUSED bool ok = true; - if (argc == 0) { - spine::SkeletonCacheMgr* result = spine::SkeletonCacheMgr::getInstance(); - ok &= nativevalue_to_se(result, s.rval(), nullptr /*ctx*/); - SE_PRECONDITION2(ok, false, "js_spine_SkeletonCacheMgr_getInstance : Error processing arguments"); - SE_HOLD_RETURN_VALUE(result, s.thisObject(), s.rval()); - return true; - } - SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 0); - return false; -} -SE_BIND_FUNC(js_spine_SkeletonCacheMgr_getInstance) - -static bool js_spine_SkeletonCacheMgr_destroyInstance(se::State& s) // NOLINT(readability-identifier-naming) +static bool js_spine_SkeletonCacheMgr_destroyInstance_static(se::State& s) // NOLINT(readability-identifier-naming) { const auto& args = s.args(); size_t argc = args.size(); @@ -15994,18 +15911,26 @@ static bool js_spine_SkeletonCacheMgr_destroyInstance(se::State& s) // NOLINT(re SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 0); return false; } -SE_BIND_FUNC(js_spine_SkeletonCacheMgr_destroyInstance) - +SE_BIND_FUNC(js_spine_SkeletonCacheMgr_destroyInstance_static) +static bool js_spine_SkeletonCacheMgr_getInstance_static(se::State& s) // NOLINT(readability-identifier-naming) +{ + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 0) { + spine::SkeletonCacheMgr* result = spine::SkeletonCacheMgr::getInstance(); + ok &= nativevalue_to_se(result, s.rval(), nullptr /*ctx*/); + SE_PRECONDITION2(ok, false, "js_spine_SkeletonCacheMgr_getInstance_static : Error processing arguments"); + SE_HOLD_RETURN_VALUE(result, s.thisObject(), s.rval()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 0); + return false; +} +SE_BIND_FUNC(js_spine_SkeletonCacheMgr_getInstance_static) static bool js_spine_SkeletonCacheMgr_finalize(se::State& s) // NOLINT(readability-identifier-naming) { - auto iter = se::NonRefNativePtrCreatedByCtorMap::find(SE_THIS_OBJECT(s)); - if (iter != se::NonRefNativePtrCreatedByCtorMap::end()) - { - se::NonRefNativePtrCreatedByCtorMap::erase(iter); - auto* cobj = SE_THIS_OBJECT(s); - JSB_FREE(cobj); - } return true; } SE_BIND_FINALIZE_FUNC(js_spine_SkeletonCacheMgr_finalize) @@ -16016,8 +15941,8 @@ bool js_register_spine_SkeletonCacheMgr(se::Object* obj) // NOLINT(readability-i cls->defineFunction("buildSkeletonCache", _SE(js_spine_SkeletonCacheMgr_buildSkeletonCache)); cls->defineFunction("removeSkeletonCache", _SE(js_spine_SkeletonCacheMgr_removeSkeletonCache)); - cls->defineStaticFunction("getInstance", _SE(js_spine_SkeletonCacheMgr_getInstance)); - cls->defineStaticFunction("destroyInstance", _SE(js_spine_SkeletonCacheMgr_destroyInstance)); + cls->defineStaticFunction("destroyInstance", _SE(js_spine_SkeletonCacheMgr_destroyInstance_static)); + cls->defineStaticFunction("getInstance", _SE(js_spine_SkeletonCacheMgr_getInstance_static)); cls->defineFinalizeFunction(_SE(js_spine_SkeletonCacheMgr_finalize)); cls->install(); JSBClassType::registerClass(cls); @@ -16025,11 +15950,12 @@ bool js_register_spine_SkeletonCacheMgr(se::Object* obj) // NOLINT(readability-i __jsb_spine_SkeletonCacheMgr_proto = cls->getProto(); __jsb_spine_SkeletonCacheMgr_class = cls; + se::ScriptEngine::getInstance()->clearException(); return true; } -se::Object* __jsb_spine_SkeletonDataMgr_proto = nullptr; -se::Class* __jsb_spine_SkeletonDataMgr_class = nullptr; +se::Object* __jsb_spine_SkeletonDataMgr_proto = nullptr; // NOLINT +se::Class* __jsb_spine_SkeletonDataMgr_class = nullptr; // NOLINT static bool js_spine_SkeletonDataMgr_setDestroyCallback(se::State& s) // NOLINT(readability-identifier-naming) { @@ -16046,6 +15972,7 @@ static bool js_spine_SkeletonDataMgr_setDestroyCallback(se::State& s) // NOLINT( se::Value jsThis(s.thisObject()); se::Value jsFunc(args[0]); jsThis.toObject()->attachObject(jsFunc.toObject()); + auto * thisObj = s.thisObject(); auto lambda = [=](int larg0) -> void { se::ScriptEngine::getInstance()->clearException(); se::AutoHandleScope hs; @@ -16055,7 +15982,6 @@ static bool js_spine_SkeletonDataMgr_setDestroyCallback(se::State& s) // NOLINT( args.resize(1); ok &= nativevalue_to_se(larg0, args[0], nullptr /*ctx*/); se::Value rval; - se::Object* thisObj = jsThis.isObject() ? jsThis.toObject() : nullptr; se::Object* funcObj = jsFunc.toObject(); bool succeed = funcObj->call(args, thisObj, &rval); if (!succeed) { @@ -16079,7 +16005,7 @@ static bool js_spine_SkeletonDataMgr_setDestroyCallback(se::State& s) // NOLINT( } SE_BIND_FUNC(js_spine_SkeletonDataMgr_setDestroyCallback) -static bool js_spine_SkeletonDataMgr_getInstance(se::State& s) // NOLINT(readability-identifier-naming) +static bool js_spine_SkeletonDataMgr_getInstance_static(se::State& s) // NOLINT(readability-identifier-naming) { const auto& args = s.args(); size_t argc = args.size(); @@ -16087,37 +16013,27 @@ static bool js_spine_SkeletonDataMgr_getInstance(se::State& s) // NOLINT(readabi if (argc == 0) { spine::SkeletonDataMgr* result = spine::SkeletonDataMgr::getInstance(); ok &= nativevalue_to_se(result, s.rval(), nullptr /*ctx*/); - SE_PRECONDITION2(ok, false, "js_spine_SkeletonDataMgr_getInstance : Error processing arguments"); + SE_PRECONDITION2(ok, false, "js_spine_SkeletonDataMgr_getInstance_static : Error processing arguments"); SE_HOLD_RETURN_VALUE(result, s.thisObject(), s.rval()); return true; } SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 0); return false; } -SE_BIND_FUNC(js_spine_SkeletonDataMgr_getInstance) +SE_BIND_FUNC(js_spine_SkeletonDataMgr_getInstance_static) SE_DECLARE_FINALIZE_FUNC(js_spine_SkeletonDataMgr_finalize) static bool js_spine_SkeletonDataMgr_constructor(se::State& s) // NOLINT(readability-identifier-naming) constructor.c { - spine::SkeletonDataMgr* cobj = JSB_ALLOC(spine::SkeletonDataMgr); - s.thisObject()->setPrivateData(cobj); - se::NonRefNativePtrCreatedByCtorMap::emplace(cobj); + auto *ptr = JSB_MAKE_PRIVATE_OBJECT(spine::SkeletonDataMgr); + s.thisObject()->setPrivateObject(ptr); return true; } SE_BIND_CTOR(js_spine_SkeletonDataMgr_constructor, __jsb_spine_SkeletonDataMgr_class, js_spine_SkeletonDataMgr_finalize) - - static bool js_spine_SkeletonDataMgr_finalize(se::State& s) // NOLINT(readability-identifier-naming) { - auto iter = se::NonRefNativePtrCreatedByCtorMap::find(SE_THIS_OBJECT(s)); - if (iter != se::NonRefNativePtrCreatedByCtorMap::end()) - { - se::NonRefNativePtrCreatedByCtorMap::erase(iter); - auto* cobj = SE_THIS_OBJECT(s); - JSB_FREE(cobj); - } return true; } SE_BIND_FINALIZE_FUNC(js_spine_SkeletonDataMgr_finalize) @@ -16127,7 +16043,7 @@ bool js_register_spine_SkeletonDataMgr(se::Object* obj) // NOLINT(readability-id auto* cls = se::Class::create("SkeletonDataMgr", obj, nullptr, _SE(js_spine_SkeletonDataMgr_constructor)); cls->defineFunction("setDestroyCallback", _SE(js_spine_SkeletonDataMgr_setDestroyCallback)); - cls->defineStaticFunction("getInstance", _SE(js_spine_SkeletonDataMgr_getInstance)); + cls->defineStaticFunction("getInstance", _SE(js_spine_SkeletonDataMgr_getInstance_static)); cls->defineFinalizeFunction(_SE(js_spine_SkeletonDataMgr_finalize)); cls->install(); JSBClassType::registerClass(cls); @@ -16135,14 +16051,15 @@ bool js_register_spine_SkeletonDataMgr(se::Object* obj) // NOLINT(readability-id __jsb_spine_SkeletonDataMgr_proto = cls->getProto(); __jsb_spine_SkeletonDataMgr_class = cls; + se::ScriptEngine::getInstance()->clearException(); return true; } -bool register_all_spine(se::Object* obj) +bool register_all_spine(se::Object* obj) // NOLINT { // Get the ns se::Value nsVal; - if (!obj->getProperty("spine", &nsVal)) + if (!obj->getProperty("spine", &nsVal, true)) { se::HandleObject jsobj(se::Object::createPlainObject()); nsVal.setObject(jsobj); @@ -16151,7 +16068,6 @@ bool register_all_spine(se::Object* obj) se::Object* ns = nsVal.toObject(); js_register_spine_Animation(ns); - js_register_spine_TrackEntry(ns); js_register_spine_AnimationState(ns); js_register_spine_AnimationStateData(ns); js_register_spine_Attachment(ns); @@ -16174,6 +16090,8 @@ bool register_all_spine(se::Object* obj) js_register_spine_IkConstraint(ns); js_register_spine_IkConstraintData(ns); js_register_spine_IkConstraintTimeline(ns); + js_register_spine_VertexEffect(ns); + js_register_spine_JitterVertexEffect(ns); js_register_spine_MeshAttachment(ns); js_register_spine_PathAttachment(ns); js_register_spine_PathConstraint(ns); @@ -16182,31 +16100,31 @@ bool register_all_spine(se::Object* obj) js_register_spine_PathConstraintPositionTimeline(ns); js_register_spine_PathConstraintSpacingTimeline(ns); js_register_spine_PointAttachment(ns); + js_register_spine_Polygon(ns); js_register_spine_RegionAttachment(ns); js_register_spine_RotateTimeline(ns); js_register_spine_TranslateTimeline(ns); js_register_spine_ScaleTimeline(ns); js_register_spine_ShearTimeline(ns); js_register_spine_Skeleton(ns); + js_register_spine_SkeletonRenderer(ns); + js_register_spine_SkeletonAnimation(ns); js_register_spine_SkeletonBounds(ns); - js_register_spine_Polygon(ns); + js_register_spine_SkeletonCacheAnimation(ns); + js_register_spine_SkeletonCacheMgr(ns); js_register_spine_SkeletonData(ns); + js_register_spine_SkeletonDataMgr(ns); js_register_spine_Skin(ns); js_register_spine_Slot(ns); js_register_spine_SlotData(ns); + js_register_spine_SwirlVertexEffect(ns); + js_register_spine_TrackEntry(ns); js_register_spine_TransformConstraint(ns); js_register_spine_TransformConstraintData(ns); js_register_spine_TransformConstraintTimeline(ns); js_register_spine_TwoColorTimeline(ns); - js_register_spine_VertexEffect(ns); - js_register_spine_JitterVertexEffect(ns); - js_register_spine_SwirlVertexEffect(ns); js_register_spine_VertexEffectDelegate(ns); - js_register_spine_SkeletonRenderer(ns); - js_register_spine_SkeletonAnimation(ns); - js_register_spine_SkeletonCacheAnimation(ns); - js_register_spine_SkeletonCacheMgr(ns); - js_register_spine_SkeletonDataMgr(ns); return true; } +// clang-format on \ No newline at end of file diff --git a/native/cocos/bindings/auto/jsb_spine_auto.h b/native/cocos/bindings/auto/jsb_spine_auto.h index f93e49071a..ecb6d19564 100644 --- a/native/cocos/bindings/auto/jsb_spine_auto.h +++ b/native/cocos/bindings/auto/jsb_spine_auto.h @@ -1,3 +1,4 @@ +// clang-format off #pragma once #include "base/Config.h" #include @@ -5,26 +6,83 @@ #include "cocos/bindings/manual/jsb_conversions.h" #include "cocos/editor-support/spine-creator-support/spine-cocos2dx.h" -extern se::Object* __jsb_spine_Animation_proto; -extern se::Class* __jsb_spine_Animation_class; - -bool js_register_spine_Animation(se::Object* obj); -bool register_all_spine(se::Object* obj); +bool register_all_spine(se::Object *obj); // NOLINT JSB_REGISTER_OBJECT_TYPE(spine::Animation); +JSB_REGISTER_OBJECT_TYPE(spine::TrackEntry); +JSB_REGISTER_OBJECT_TYPE(spine::AnimationState); +JSB_REGISTER_OBJECT_TYPE(spine::AnimationStateData); +JSB_REGISTER_OBJECT_TYPE(spine::Attachment); +JSB_REGISTER_OBJECT_TYPE(spine::Timeline); +JSB_REGISTER_OBJECT_TYPE(spine::AttachmentTimeline); +JSB_REGISTER_OBJECT_TYPE(spine::Bone); +JSB_REGISTER_OBJECT_TYPE(spine::BoneData); +JSB_REGISTER_OBJECT_TYPE(spine::VertexAttachment); +JSB_REGISTER_OBJECT_TYPE(spine::BoundingBoxAttachment); +JSB_REGISTER_OBJECT_TYPE(spine::ClippingAttachment); +JSB_REGISTER_OBJECT_TYPE(spine::Color); +JSB_REGISTER_OBJECT_TYPE(spine::CurveTimeline); +JSB_REGISTER_OBJECT_TYPE(spine::ColorTimeline); +JSB_REGISTER_OBJECT_TYPE(spine::ConstraintData); +JSB_REGISTER_OBJECT_TYPE(spine::DeformTimeline); +JSB_REGISTER_OBJECT_TYPE(spine::DrawOrderTimeline); +JSB_REGISTER_OBJECT_TYPE(spine::Event); +JSB_REGISTER_OBJECT_TYPE(spine::EventData); +JSB_REGISTER_OBJECT_TYPE(spine::EventTimeline); +JSB_REGISTER_OBJECT_TYPE(spine::IkConstraint); +JSB_REGISTER_OBJECT_TYPE(spine::IkConstraintData); +JSB_REGISTER_OBJECT_TYPE(spine::IkConstraintTimeline); +JSB_REGISTER_OBJECT_TYPE(spine::MeshAttachment); +JSB_REGISTER_OBJECT_TYPE(spine::PathAttachment); +JSB_REGISTER_OBJECT_TYPE(spine::PathConstraint); +JSB_REGISTER_OBJECT_TYPE(spine::PathConstraintData); +JSB_REGISTER_OBJECT_TYPE(spine::PathConstraintMixTimeline); +JSB_REGISTER_OBJECT_TYPE(spine::PathConstraintPositionTimeline); +JSB_REGISTER_OBJECT_TYPE(spine::PathConstraintSpacingTimeline); +JSB_REGISTER_OBJECT_TYPE(spine::PointAttachment); +JSB_REGISTER_OBJECT_TYPE(spine::RegionAttachment); +JSB_REGISTER_OBJECT_TYPE(spine::RotateTimeline); +JSB_REGISTER_OBJECT_TYPE(spine::TranslateTimeline); +JSB_REGISTER_OBJECT_TYPE(spine::ScaleTimeline); +JSB_REGISTER_OBJECT_TYPE(spine::ShearTimeline); +JSB_REGISTER_OBJECT_TYPE(spine::Skeleton); +JSB_REGISTER_OBJECT_TYPE(spine::SkeletonBounds); +JSB_REGISTER_OBJECT_TYPE(spine::Polygon); +JSB_REGISTER_OBJECT_TYPE(spine::SkeletonData); +JSB_REGISTER_OBJECT_TYPE(spine::Skin); +JSB_REGISTER_OBJECT_TYPE(spine::Slot); +JSB_REGISTER_OBJECT_TYPE(spine::SlotData); +JSB_REGISTER_OBJECT_TYPE(spine::TransformConstraint); +JSB_REGISTER_OBJECT_TYPE(spine::TransformConstraintData); +JSB_REGISTER_OBJECT_TYPE(spine::TransformConstraintTimeline); +JSB_REGISTER_OBJECT_TYPE(spine::TwoColorTimeline); +JSB_REGISTER_OBJECT_TYPE(spine::VertexEffect); +JSB_REGISTER_OBJECT_TYPE(spine::JitterVertexEffect); +JSB_REGISTER_OBJECT_TYPE(spine::SwirlVertexEffect); +JSB_REGISTER_OBJECT_TYPE(spine::VertexEffectDelegate); +JSB_REGISTER_OBJECT_TYPE(spine::SkeletonRenderer); +JSB_REGISTER_OBJECT_TYPE(spine::SkeletonAnimation); +JSB_REGISTER_OBJECT_TYPE(spine::SkeletonCacheAnimation); +JSB_REGISTER_OBJECT_TYPE(spine::SkeletonCacheMgr); +JSB_REGISTER_OBJECT_TYPE(spine::SkeletonDataMgr); + + +extern se::Object *__jsb_spine_Animation_proto; // NOLINT +extern se::Class * __jsb_spine_Animation_class; // NOLINT + +bool js_register_spine_Animation(se::Object *obj); // NOLINT + SE_DECLARE_FUNC(js_spine_Animation_getDuration); SE_DECLARE_FUNC(js_spine_Animation_getName); SE_DECLARE_FUNC(js_spine_Animation_getTimelines); SE_DECLARE_FUNC(js_spine_Animation_hasTimeline); SE_DECLARE_FUNC(js_spine_Animation_setDuration); -extern se::Object* __jsb_spine_TrackEntry_proto; -extern se::Class* __jsb_spine_TrackEntry_class; +extern se::Object *__jsb_spine_TrackEntry_proto; // NOLINT +extern se::Class * __jsb_spine_TrackEntry_class; // NOLINT -bool js_register_spine_TrackEntry(se::Object* obj); -bool register_all_spine(se::Object* obj); +bool js_register_spine_TrackEntry(se::Object *obj); // NOLINT -JSB_REGISTER_OBJECT_TYPE(spine::TrackEntry); SE_DECLARE_FUNC(js_spine_TrackEntry_getAlpha); SE_DECLARE_FUNC(js_spine_TrackEntry_getAnimation); SE_DECLARE_FUNC(js_spine_TrackEntry_getAnimationEnd); @@ -66,13 +124,11 @@ SE_DECLARE_FUNC(js_spine_TrackEntry_setTimeScale); SE_DECLARE_FUNC(js_spine_TrackEntry_setTrackEnd); SE_DECLARE_FUNC(js_spine_TrackEntry_setTrackTime); -extern se::Object* __jsb_spine_AnimationState_proto; -extern se::Class* __jsb_spine_AnimationState_class; +extern se::Object *__jsb_spine_AnimationState_proto; // NOLINT +extern se::Class * __jsb_spine_AnimationState_class; // NOLINT -bool js_register_spine_AnimationState(se::Object* obj); -bool register_all_spine(se::Object* obj); +bool js_register_spine_AnimationState(se::Object *obj); // NOLINT -JSB_REGISTER_OBJECT_TYPE(spine::AnimationState); SE_DECLARE_FUNC(js_spine_AnimationState_addAnimation); SE_DECLARE_FUNC(js_spine_AnimationState_addEmptyAnimation); SE_DECLARE_FUNC(js_spine_AnimationState_clearTrack); @@ -89,48 +145,40 @@ SE_DECLARE_FUNC(js_spine_AnimationState_setEmptyAnimations); SE_DECLARE_FUNC(js_spine_AnimationState_setTimeScale); SE_DECLARE_FUNC(js_spine_AnimationState_update); -extern se::Object* __jsb_spine_AnimationStateData_proto; -extern se::Class* __jsb_spine_AnimationStateData_class; +extern se::Object *__jsb_spine_AnimationStateData_proto; // NOLINT +extern se::Class * __jsb_spine_AnimationStateData_class; // NOLINT -bool js_register_spine_AnimationStateData(se::Object* obj); -bool register_all_spine(se::Object* obj); +bool js_register_spine_AnimationStateData(se::Object *obj); // NOLINT -JSB_REGISTER_OBJECT_TYPE(spine::AnimationStateData); SE_DECLARE_FUNC(js_spine_AnimationStateData_getDefaultMix); SE_DECLARE_FUNC(js_spine_AnimationStateData_getMix); SE_DECLARE_FUNC(js_spine_AnimationStateData_getSkeletonData); SE_DECLARE_FUNC(js_spine_AnimationStateData_setDefaultMix); SE_DECLARE_FUNC(js_spine_AnimationStateData_setMix); -extern se::Object* __jsb_spine_Attachment_proto; -extern se::Class* __jsb_spine_Attachment_class; +extern se::Object *__jsb_spine_Attachment_proto; // NOLINT +extern se::Class * __jsb_spine_Attachment_class; // NOLINT -bool js_register_spine_Attachment(se::Object* obj); -bool register_all_spine(se::Object* obj); +bool js_register_spine_Attachment(se::Object *obj); // NOLINT -JSB_REGISTER_OBJECT_TYPE(spine::Attachment); SE_DECLARE_FUNC(js_spine_Attachment_copy); SE_DECLARE_FUNC(js_spine_Attachment_dereference); SE_DECLARE_FUNC(js_spine_Attachment_getName); SE_DECLARE_FUNC(js_spine_Attachment_getRefCount); SE_DECLARE_FUNC(js_spine_Attachment_reference); -extern se::Object* __jsb_spine_Timeline_proto; -extern se::Class* __jsb_spine_Timeline_class; +extern se::Object *__jsb_spine_Timeline_proto; // NOLINT +extern se::Class * __jsb_spine_Timeline_class; // NOLINT -bool js_register_spine_Timeline(se::Object* obj); -bool register_all_spine(se::Object* obj); +bool js_register_spine_Timeline(se::Object *obj); // NOLINT -JSB_REGISTER_OBJECT_TYPE(spine::Timeline); SE_DECLARE_FUNC(js_spine_Timeline_getPropertyId); -extern se::Object* __jsb_spine_AttachmentTimeline_proto; -extern se::Class* __jsb_spine_AttachmentTimeline_class; +extern se::Object *__jsb_spine_AttachmentTimeline_proto; // NOLINT +extern se::Class * __jsb_spine_AttachmentTimeline_class; // NOLINT -bool js_register_spine_AttachmentTimeline(se::Object* obj); -bool register_all_spine(se::Object* obj); +bool js_register_spine_AttachmentTimeline(se::Object *obj); // NOLINT -JSB_REGISTER_OBJECT_TYPE(spine::AttachmentTimeline); SE_DECLARE_FUNC(js_spine_AttachmentTimeline_getAttachmentNames); SE_DECLARE_FUNC(js_spine_AttachmentTimeline_getFrameCount); SE_DECLARE_FUNC(js_spine_AttachmentTimeline_getFrames); @@ -139,13 +187,11 @@ SE_DECLARE_FUNC(js_spine_AttachmentTimeline_getSlotIndex); SE_DECLARE_FUNC(js_spine_AttachmentTimeline_setFrame); SE_DECLARE_FUNC(js_spine_AttachmentTimeline_setSlotIndex); -extern se::Object* __jsb_spine_Bone_proto; -extern se::Class* __jsb_spine_Bone_class; +extern se::Object *__jsb_spine_Bone_proto; // NOLINT +extern se::Class * __jsb_spine_Bone_class; // NOLINT -bool js_register_spine_Bone(se::Object* obj); -bool register_all_spine(se::Object* obj); +bool js_register_spine_Bone(se::Object *obj); // NOLINT -JSB_REGISTER_OBJECT_TYPE(spine::Bone); SE_DECLARE_FUNC(js_spine_Bone_getA); SE_DECLARE_FUNC(js_spine_Bone_getAScaleX); SE_DECLARE_FUNC(js_spine_Bone_getAScaleY); @@ -204,16 +250,14 @@ SE_DECLARE_FUNC(js_spine_Bone_setX); SE_DECLARE_FUNC(js_spine_Bone_setY); SE_DECLARE_FUNC(js_spine_Bone_update); SE_DECLARE_FUNC(js_spine_Bone_updateWorldTransform); -SE_DECLARE_FUNC(js_spine_Bone_setYDown); SE_DECLARE_FUNC(js_spine_Bone_isYDown); +SE_DECLARE_FUNC(js_spine_Bone_setYDown); -extern se::Object* __jsb_spine_BoneData_proto; -extern se::Class* __jsb_spine_BoneData_class; +extern se::Object *__jsb_spine_BoneData_proto; // NOLINT +extern se::Class * __jsb_spine_BoneData_class; // NOLINT -bool js_register_spine_BoneData(se::Object* obj); -bool register_all_spine(se::Object* obj); +bool js_register_spine_BoneData(se::Object *obj); // NOLINT -JSB_REGISTER_OBJECT_TYPE(spine::BoneData); SE_DECLARE_FUNC(js_spine_BoneData_getIndex); SE_DECLARE_FUNC(js_spine_BoneData_getLength); SE_DECLARE_FUNC(js_spine_BoneData_getName); @@ -238,13 +282,11 @@ SE_DECLARE_FUNC(js_spine_BoneData_setTransformMode); SE_DECLARE_FUNC(js_spine_BoneData_setX); SE_DECLARE_FUNC(js_spine_BoneData_setY); -extern se::Object* __jsb_spine_VertexAttachment_proto; -extern se::Class* __jsb_spine_VertexAttachment_class; +extern se::Object *__jsb_spine_VertexAttachment_proto; // NOLINT +extern se::Class * __jsb_spine_VertexAttachment_class; // NOLINT -bool js_register_spine_VertexAttachment(se::Object* obj); -bool register_all_spine(se::Object* obj); +bool js_register_spine_VertexAttachment(se::Object *obj); // NOLINT -JSB_REGISTER_OBJECT_TYPE(spine::VertexAttachment); SE_DECLARE_FUNC(js_spine_VertexAttachment_copyTo); SE_DECLARE_FUNC(js_spine_VertexAttachment_getDeformAttachment); SE_DECLARE_FUNC(js_spine_VertexAttachment_getId); @@ -253,42 +295,34 @@ SE_DECLARE_FUNC(js_spine_VertexAttachment_getWorldVerticesLength); SE_DECLARE_FUNC(js_spine_VertexAttachment_setDeformAttachment); SE_DECLARE_FUNC(js_spine_VertexAttachment_setWorldVerticesLength); -extern se::Object* __jsb_spine_BoundingBoxAttachment_proto; -extern se::Class* __jsb_spine_BoundingBoxAttachment_class; +extern se::Object *__jsb_spine_BoundingBoxAttachment_proto; // NOLINT +extern se::Class * __jsb_spine_BoundingBoxAttachment_class; // NOLINT -bool js_register_spine_BoundingBoxAttachment(se::Object* obj); -bool register_all_spine(se::Object* obj); +bool js_register_spine_BoundingBoxAttachment(se::Object *obj); // NOLINT -JSB_REGISTER_OBJECT_TYPE(spine::BoundingBoxAttachment); SE_DECLARE_FUNC(js_spine_BoundingBoxAttachment_copy); -extern se::Object* __jsb_spine_ClippingAttachment_proto; -extern se::Class* __jsb_spine_ClippingAttachment_class; +extern se::Object *__jsb_spine_ClippingAttachment_proto; // NOLINT +extern se::Class * __jsb_spine_ClippingAttachment_class; // NOLINT -bool js_register_spine_ClippingAttachment(se::Object* obj); -bool register_all_spine(se::Object* obj); +bool js_register_spine_ClippingAttachment(se::Object *obj); // NOLINT -JSB_REGISTER_OBJECT_TYPE(spine::ClippingAttachment); SE_DECLARE_FUNC(js_spine_ClippingAttachment_copy); SE_DECLARE_FUNC(js_spine_ClippingAttachment_getEndSlot); SE_DECLARE_FUNC(js_spine_ClippingAttachment_setEndSlot); -extern se::Object* __jsb_spine_Color_proto; -extern se::Class* __jsb_spine_Color_class; +extern se::Object *__jsb_spine_Color_proto; // NOLINT +extern se::Class * __jsb_spine_Color_class; // NOLINT -bool js_register_spine_Color(se::Object* obj); -bool register_all_spine(se::Object* obj); +bool js_register_spine_Color(se::Object *obj); // NOLINT -JSB_REGISTER_OBJECT_TYPE(spine::Color); SE_DECLARE_FUNC(js_spine_Color_clamp); -extern se::Object* __jsb_spine_CurveTimeline_proto; -extern se::Class* __jsb_spine_CurveTimeline_class; +extern se::Object *__jsb_spine_CurveTimeline_proto; // NOLINT +extern se::Class * __jsb_spine_CurveTimeline_class; // NOLINT -bool js_register_spine_CurveTimeline(se::Object* obj); -bool register_all_spine(se::Object* obj); +bool js_register_spine_CurveTimeline(se::Object *obj); // NOLINT -JSB_REGISTER_OBJECT_TYPE(spine::CurveTimeline); SE_DECLARE_FUNC(js_spine_CurveTimeline_getCurvePercent); SE_DECLARE_FUNC(js_spine_CurveTimeline_getCurveType); SE_DECLARE_FUNC(js_spine_CurveTimeline_getFrameCount); @@ -297,39 +331,33 @@ SE_DECLARE_FUNC(js_spine_CurveTimeline_setCurve); SE_DECLARE_FUNC(js_spine_CurveTimeline_setLinear); SE_DECLARE_FUNC(js_spine_CurveTimeline_setStepped); -extern se::Object* __jsb_spine_ColorTimeline_proto; -extern se::Class* __jsb_spine_ColorTimeline_class; +extern se::Object *__jsb_spine_ColorTimeline_proto; // NOLINT +extern se::Class * __jsb_spine_ColorTimeline_class; // NOLINT -bool js_register_spine_ColorTimeline(se::Object* obj); -bool register_all_spine(se::Object* obj); +bool js_register_spine_ColorTimeline(se::Object *obj); // NOLINT -JSB_REGISTER_OBJECT_TYPE(spine::ColorTimeline); SE_DECLARE_FUNC(js_spine_ColorTimeline_getFrames); SE_DECLARE_FUNC(js_spine_ColorTimeline_getPropertyId); SE_DECLARE_FUNC(js_spine_ColorTimeline_getSlotIndex); SE_DECLARE_FUNC(js_spine_ColorTimeline_setFrame); SE_DECLARE_FUNC(js_spine_ColorTimeline_setSlotIndex); -extern se::Object* __jsb_spine_ConstraintData_proto; -extern se::Class* __jsb_spine_ConstraintData_class; +extern se::Object *__jsb_spine_ConstraintData_proto; // NOLINT +extern se::Class * __jsb_spine_ConstraintData_class; // NOLINT -bool js_register_spine_ConstraintData(se::Object* obj); -bool register_all_spine(se::Object* obj); +bool js_register_spine_ConstraintData(se::Object *obj); // NOLINT -JSB_REGISTER_OBJECT_TYPE(spine::ConstraintData); SE_DECLARE_FUNC(js_spine_ConstraintData_getName); SE_DECLARE_FUNC(js_spine_ConstraintData_getOrder); SE_DECLARE_FUNC(js_spine_ConstraintData_isSkinRequired); SE_DECLARE_FUNC(js_spine_ConstraintData_setOrder); SE_DECLARE_FUNC(js_spine_ConstraintData_setSkinRequired); -extern se::Object* __jsb_spine_DeformTimeline_proto; -extern se::Class* __jsb_spine_DeformTimeline_class; +extern se::Object *__jsb_spine_DeformTimeline_proto; // NOLINT +extern se::Class * __jsb_spine_DeformTimeline_class; // NOLINT -bool js_register_spine_DeformTimeline(se::Object* obj); -bool register_all_spine(se::Object* obj); +bool js_register_spine_DeformTimeline(se::Object *obj); // NOLINT -JSB_REGISTER_OBJECT_TYPE(spine::DeformTimeline); SE_DECLARE_FUNC(js_spine_DeformTimeline_getAttachment); SE_DECLARE_FUNC(js_spine_DeformTimeline_getFrames); SE_DECLARE_FUNC(js_spine_DeformTimeline_getPropertyId); @@ -337,24 +365,20 @@ SE_DECLARE_FUNC(js_spine_DeformTimeline_getSlotIndex); SE_DECLARE_FUNC(js_spine_DeformTimeline_setAttachment); SE_DECLARE_FUNC(js_spine_DeformTimeline_setSlotIndex); -extern se::Object* __jsb_spine_DrawOrderTimeline_proto; -extern se::Class* __jsb_spine_DrawOrderTimeline_class; +extern se::Object *__jsb_spine_DrawOrderTimeline_proto; // NOLINT +extern se::Class * __jsb_spine_DrawOrderTimeline_class; // NOLINT -bool js_register_spine_DrawOrderTimeline(se::Object* obj); -bool register_all_spine(se::Object* obj); +bool js_register_spine_DrawOrderTimeline(se::Object *obj); // NOLINT -JSB_REGISTER_OBJECT_TYPE(spine::DrawOrderTimeline); SE_DECLARE_FUNC(js_spine_DrawOrderTimeline_getFrameCount); SE_DECLARE_FUNC(js_spine_DrawOrderTimeline_getFrames); SE_DECLARE_FUNC(js_spine_DrawOrderTimeline_getPropertyId); -extern se::Object* __jsb_spine_Event_proto; -extern se::Class* __jsb_spine_Event_class; +extern se::Object *__jsb_spine_Event_proto; // NOLINT +extern se::Class * __jsb_spine_Event_class; // NOLINT -bool js_register_spine_Event(se::Object* obj); -bool register_all_spine(se::Object* obj); +bool js_register_spine_Event(se::Object *obj); // NOLINT -JSB_REGISTER_OBJECT_TYPE(spine::Event); SE_DECLARE_FUNC(js_spine_Event_getBalance); SE_DECLARE_FUNC(js_spine_Event_getData); SE_DECLARE_FUNC(js_spine_Event_getFloatValue); @@ -368,13 +392,11 @@ SE_DECLARE_FUNC(js_spine_Event_setIntValue); SE_DECLARE_FUNC(js_spine_Event_setStringValue); SE_DECLARE_FUNC(js_spine_Event_setVolume); -extern se::Object* __jsb_spine_EventData_proto; -extern se::Class* __jsb_spine_EventData_class; +extern se::Object *__jsb_spine_EventData_proto; // NOLINT +extern se::Class * __jsb_spine_EventData_class; // NOLINT -bool js_register_spine_EventData(se::Object* obj); -bool register_all_spine(se::Object* obj); +bool js_register_spine_EventData(se::Object *obj); // NOLINT -JSB_REGISTER_OBJECT_TYPE(spine::EventData); SE_DECLARE_FUNC(js_spine_EventData_getAudioPath); SE_DECLARE_FUNC(js_spine_EventData_getBalance); SE_DECLARE_FUNC(js_spine_EventData_getFloatValue); @@ -389,26 +411,22 @@ SE_DECLARE_FUNC(js_spine_EventData_setIntValue); SE_DECLARE_FUNC(js_spine_EventData_setStringValue); SE_DECLARE_FUNC(js_spine_EventData_setVolume); -extern se::Object* __jsb_spine_EventTimeline_proto; -extern se::Class* __jsb_spine_EventTimeline_class; +extern se::Object *__jsb_spine_EventTimeline_proto; // NOLINT +extern se::Class * __jsb_spine_EventTimeline_class; // NOLINT -bool js_register_spine_EventTimeline(se::Object* obj); -bool register_all_spine(se::Object* obj); +bool js_register_spine_EventTimeline(se::Object *obj); // NOLINT -JSB_REGISTER_OBJECT_TYPE(spine::EventTimeline); SE_DECLARE_FUNC(js_spine_EventTimeline_getEvents); SE_DECLARE_FUNC(js_spine_EventTimeline_getFrameCount); SE_DECLARE_FUNC(js_spine_EventTimeline_getFrames); SE_DECLARE_FUNC(js_spine_EventTimeline_getPropertyId); SE_DECLARE_FUNC(js_spine_EventTimeline_setFrame); -extern se::Object* __jsb_spine_IkConstraint_proto; -extern se::Class* __jsb_spine_IkConstraint_class; +extern se::Object *__jsb_spine_IkConstraint_proto; // NOLINT +extern se::Class * __jsb_spine_IkConstraint_class; // NOLINT -bool js_register_spine_IkConstraint(se::Object* obj); -bool register_all_spine(se::Object* obj); +bool js_register_spine_IkConstraint(se::Object *obj); // NOLINT -JSB_REGISTER_OBJECT_TYPE(spine::IkConstraint); SE_DECLARE_FUNC(js_spine_IkConstraint_getBendDirection); SE_DECLARE_FUNC(js_spine_IkConstraint_getBones); SE_DECLARE_FUNC(js_spine_IkConstraint_getCompress); @@ -428,13 +446,11 @@ SE_DECLARE_FUNC(js_spine_IkConstraint_setStretch); SE_DECLARE_FUNC(js_spine_IkConstraint_setTarget); SE_DECLARE_FUNC(js_spine_IkConstraint_update); -extern se::Object* __jsb_spine_IkConstraintData_proto; -extern se::Class* __jsb_spine_IkConstraintData_class; +extern se::Object *__jsb_spine_IkConstraintData_proto; // NOLINT +extern se::Class * __jsb_spine_IkConstraintData_class; // NOLINT -bool js_register_spine_IkConstraintData(se::Object* obj); -bool register_all_spine(se::Object* obj); +bool js_register_spine_IkConstraintData(se::Object *obj); // NOLINT -JSB_REGISTER_OBJECT_TYPE(spine::IkConstraintData); SE_DECLARE_FUNC(js_spine_IkConstraintData_getBendDirection); SE_DECLARE_FUNC(js_spine_IkConstraintData_getBones); SE_DECLARE_FUNC(js_spine_IkConstraintData_getCompress); @@ -451,23 +467,19 @@ SE_DECLARE_FUNC(js_spine_IkConstraintData_setStretch); SE_DECLARE_FUNC(js_spine_IkConstraintData_setTarget); SE_DECLARE_FUNC(js_spine_IkConstraintData_setUniform); -extern se::Object* __jsb_spine_IkConstraintTimeline_proto; -extern se::Class* __jsb_spine_IkConstraintTimeline_class; +extern se::Object *__jsb_spine_IkConstraintTimeline_proto; // NOLINT +extern se::Class * __jsb_spine_IkConstraintTimeline_class; // NOLINT -bool js_register_spine_IkConstraintTimeline(se::Object* obj); -bool register_all_spine(se::Object* obj); +bool js_register_spine_IkConstraintTimeline(se::Object *obj); // NOLINT -JSB_REGISTER_OBJECT_TYPE(spine::IkConstraintTimeline); SE_DECLARE_FUNC(js_spine_IkConstraintTimeline_getPropertyId); SE_DECLARE_FUNC(js_spine_IkConstraintTimeline_setFrame); -extern se::Object* __jsb_spine_MeshAttachment_proto; -extern se::Class* __jsb_spine_MeshAttachment_class; +extern se::Object *__jsb_spine_MeshAttachment_proto; // NOLINT +extern se::Class * __jsb_spine_MeshAttachment_class; // NOLINT -bool js_register_spine_MeshAttachment(se::Object* obj); -bool register_all_spine(se::Object* obj); +bool js_register_spine_MeshAttachment(se::Object *obj); // NOLINT -JSB_REGISTER_OBJECT_TYPE(spine::MeshAttachment); SE_DECLARE_FUNC(js_spine_MeshAttachment_copy); SE_DECLARE_FUNC(js_spine_MeshAttachment_getColor); SE_DECLARE_FUNC(js_spine_MeshAttachment_getEdges); @@ -511,13 +523,11 @@ SE_DECLARE_FUNC(js_spine_MeshAttachment_setRegionWidth); SE_DECLARE_FUNC(js_spine_MeshAttachment_setWidth); SE_DECLARE_FUNC(js_spine_MeshAttachment_updateUVs); -extern se::Object* __jsb_spine_PathAttachment_proto; -extern se::Class* __jsb_spine_PathAttachment_class; +extern se::Object *__jsb_spine_PathAttachment_proto; // NOLINT +extern se::Class * __jsb_spine_PathAttachment_class; // NOLINT -bool js_register_spine_PathAttachment(se::Object* obj); -bool register_all_spine(se::Object* obj); +bool js_register_spine_PathAttachment(se::Object *obj); // NOLINT -JSB_REGISTER_OBJECT_TYPE(spine::PathAttachment); SE_DECLARE_FUNC(js_spine_PathAttachment_copy); SE_DECLARE_FUNC(js_spine_PathAttachment_getLengths); SE_DECLARE_FUNC(js_spine_PathAttachment_isClosed); @@ -525,13 +535,11 @@ SE_DECLARE_FUNC(js_spine_PathAttachment_isConstantSpeed); SE_DECLARE_FUNC(js_spine_PathAttachment_setClosed); SE_DECLARE_FUNC(js_spine_PathAttachment_setConstantSpeed); -extern se::Object* __jsb_spine_PathConstraint_proto; -extern se::Class* __jsb_spine_PathConstraint_class; +extern se::Object *__jsb_spine_PathConstraint_proto; // NOLINT +extern se::Class * __jsb_spine_PathConstraint_class; // NOLINT -bool js_register_spine_PathConstraint(se::Object* obj); -bool register_all_spine(se::Object* obj); +bool js_register_spine_PathConstraint(se::Object *obj); // NOLINT -JSB_REGISTER_OBJECT_TYPE(spine::PathConstraint); SE_DECLARE_FUNC(js_spine_PathConstraint_apply); SE_DECLARE_FUNC(js_spine_PathConstraint_getBones); SE_DECLARE_FUNC(js_spine_PathConstraint_getData); @@ -550,13 +558,11 @@ SE_DECLARE_FUNC(js_spine_PathConstraint_setTarget); SE_DECLARE_FUNC(js_spine_PathConstraint_setTranslateMix); SE_DECLARE_FUNC(js_spine_PathConstraint_update); -extern se::Object* __jsb_spine_PathConstraintData_proto; -extern se::Class* __jsb_spine_PathConstraintData_class; +extern se::Object *__jsb_spine_PathConstraintData_proto; // NOLINT +extern se::Class * __jsb_spine_PathConstraintData_class; // NOLINT -bool js_register_spine_PathConstraintData(se::Object* obj); -bool register_all_spine(se::Object* obj); +bool js_register_spine_PathConstraintData(se::Object *obj); // NOLINT -JSB_REGISTER_OBJECT_TYPE(spine::PathConstraintData); SE_DECLARE_FUNC(js_spine_PathConstraintData_getBones); SE_DECLARE_FUNC(js_spine_PathConstraintData_getOffsetRotation); SE_DECLARE_FUNC(js_spine_PathConstraintData_getPosition); @@ -577,41 +583,33 @@ SE_DECLARE_FUNC(js_spine_PathConstraintData_setSpacingMode); SE_DECLARE_FUNC(js_spine_PathConstraintData_setTarget); SE_DECLARE_FUNC(js_spine_PathConstraintData_setTranslateMix); -extern se::Object* __jsb_spine_PathConstraintMixTimeline_proto; -extern se::Class* __jsb_spine_PathConstraintMixTimeline_class; +extern se::Object *__jsb_spine_PathConstraintMixTimeline_proto; // NOLINT +extern se::Class * __jsb_spine_PathConstraintMixTimeline_class; // NOLINT -bool js_register_spine_PathConstraintMixTimeline(se::Object* obj); -bool register_all_spine(se::Object* obj); +bool js_register_spine_PathConstraintMixTimeline(se::Object *obj); // NOLINT -JSB_REGISTER_OBJECT_TYPE(spine::PathConstraintMixTimeline); SE_DECLARE_FUNC(js_spine_PathConstraintMixTimeline_getPropertyId); -extern se::Object* __jsb_spine_PathConstraintPositionTimeline_proto; -extern se::Class* __jsb_spine_PathConstraintPositionTimeline_class; +extern se::Object *__jsb_spine_PathConstraintPositionTimeline_proto; // NOLINT +extern se::Class * __jsb_spine_PathConstraintPositionTimeline_class; // NOLINT -bool js_register_spine_PathConstraintPositionTimeline(se::Object* obj); -bool register_all_spine(se::Object* obj); +bool js_register_spine_PathConstraintPositionTimeline(se::Object *obj); // NOLINT -JSB_REGISTER_OBJECT_TYPE(spine::PathConstraintPositionTimeline); SE_DECLARE_FUNC(js_spine_PathConstraintPositionTimeline_getPropertyId); SE_DECLARE_FUNC(js_spine_PathConstraintPositionTimeline_setFrame); -extern se::Object* __jsb_spine_PathConstraintSpacingTimeline_proto; -extern se::Class* __jsb_spine_PathConstraintSpacingTimeline_class; +extern se::Object *__jsb_spine_PathConstraintSpacingTimeline_proto; // NOLINT +extern se::Class * __jsb_spine_PathConstraintSpacingTimeline_class; // NOLINT -bool js_register_spine_PathConstraintSpacingTimeline(se::Object* obj); -bool register_all_spine(se::Object* obj); +bool js_register_spine_PathConstraintSpacingTimeline(se::Object *obj); // NOLINT -JSB_REGISTER_OBJECT_TYPE(spine::PathConstraintSpacingTimeline); SE_DECLARE_FUNC(js_spine_PathConstraintSpacingTimeline_getPropertyId); -extern se::Object* __jsb_spine_PointAttachment_proto; -extern se::Class* __jsb_spine_PointAttachment_class; +extern se::Object *__jsb_spine_PointAttachment_proto; // NOLINT +extern se::Class * __jsb_spine_PointAttachment_class; // NOLINT -bool js_register_spine_PointAttachment(se::Object* obj); -bool register_all_spine(se::Object* obj); +bool js_register_spine_PointAttachment(se::Object *obj); // NOLINT -JSB_REGISTER_OBJECT_TYPE(spine::PointAttachment); SE_DECLARE_FUNC(js_spine_PointAttachment_copy); SE_DECLARE_FUNC(js_spine_PointAttachment_getRotation); SE_DECLARE_FUNC(js_spine_PointAttachment_getX); @@ -620,13 +618,11 @@ SE_DECLARE_FUNC(js_spine_PointAttachment_setRotation); SE_DECLARE_FUNC(js_spine_PointAttachment_setX); SE_DECLARE_FUNC(js_spine_PointAttachment_setY); -extern se::Object* __jsb_spine_RegionAttachment_proto; -extern se::Class* __jsb_spine_RegionAttachment_class; +extern se::Object *__jsb_spine_RegionAttachment_proto; // NOLINT +extern se::Class * __jsb_spine_RegionAttachment_class; // NOLINT -bool js_register_spine_RegionAttachment(se::Object* obj); -bool register_all_spine(se::Object* obj); +bool js_register_spine_RegionAttachment(se::Object *obj); // NOLINT -JSB_REGISTER_OBJECT_TYPE(spine::RegionAttachment); SE_DECLARE_FUNC(js_spine_RegionAttachment_copy); SE_DECLARE_FUNC(js_spine_RegionAttachment_getColor); SE_DECLARE_FUNC(js_spine_RegionAttachment_getHeight); @@ -662,54 +658,44 @@ SE_DECLARE_FUNC(js_spine_RegionAttachment_setX); SE_DECLARE_FUNC(js_spine_RegionAttachment_setY); SE_DECLARE_FUNC(js_spine_RegionAttachment_updateOffset); -extern se::Object* __jsb_spine_RotateTimeline_proto; -extern se::Class* __jsb_spine_RotateTimeline_class; +extern se::Object *__jsb_spine_RotateTimeline_proto; // NOLINT +extern se::Class * __jsb_spine_RotateTimeline_class; // NOLINT -bool js_register_spine_RotateTimeline(se::Object* obj); -bool register_all_spine(se::Object* obj); +bool js_register_spine_RotateTimeline(se::Object *obj); // NOLINT -JSB_REGISTER_OBJECT_TYPE(spine::RotateTimeline); SE_DECLARE_FUNC(js_spine_RotateTimeline_getBoneIndex); SE_DECLARE_FUNC(js_spine_RotateTimeline_getFrames); SE_DECLARE_FUNC(js_spine_RotateTimeline_getPropertyId); SE_DECLARE_FUNC(js_spine_RotateTimeline_setBoneIndex); SE_DECLARE_FUNC(js_spine_RotateTimeline_setFrame); -extern se::Object* __jsb_spine_TranslateTimeline_proto; -extern se::Class* __jsb_spine_TranslateTimeline_class; +extern se::Object *__jsb_spine_TranslateTimeline_proto; // NOLINT +extern se::Class * __jsb_spine_TranslateTimeline_class; // NOLINT -bool js_register_spine_TranslateTimeline(se::Object* obj); -bool register_all_spine(se::Object* obj); +bool js_register_spine_TranslateTimeline(se::Object *obj); // NOLINT -JSB_REGISTER_OBJECT_TYPE(spine::TranslateTimeline); SE_DECLARE_FUNC(js_spine_TranslateTimeline_getPropertyId); SE_DECLARE_FUNC(js_spine_TranslateTimeline_setFrame); -extern se::Object* __jsb_spine_ScaleTimeline_proto; -extern se::Class* __jsb_spine_ScaleTimeline_class; +extern se::Object *__jsb_spine_ScaleTimeline_proto; // NOLINT +extern se::Class * __jsb_spine_ScaleTimeline_class; // NOLINT -bool js_register_spine_ScaleTimeline(se::Object* obj); -bool register_all_spine(se::Object* obj); +bool js_register_spine_ScaleTimeline(se::Object *obj); // NOLINT -JSB_REGISTER_OBJECT_TYPE(spine::ScaleTimeline); SE_DECLARE_FUNC(js_spine_ScaleTimeline_getPropertyId); -extern se::Object* __jsb_spine_ShearTimeline_proto; -extern se::Class* __jsb_spine_ShearTimeline_class; +extern se::Object *__jsb_spine_ShearTimeline_proto; // NOLINT +extern se::Class * __jsb_spine_ShearTimeline_class; // NOLINT -bool js_register_spine_ShearTimeline(se::Object* obj); -bool register_all_spine(se::Object* obj); +bool js_register_spine_ShearTimeline(se::Object *obj); // NOLINT -JSB_REGISTER_OBJECT_TYPE(spine::ShearTimeline); SE_DECLARE_FUNC(js_spine_ShearTimeline_getPropertyId); -extern se::Object* __jsb_spine_Skeleton_proto; -extern se::Class* __jsb_spine_Skeleton_class; +extern se::Object *__jsb_spine_Skeleton_proto; // NOLINT +extern se::Class * __jsb_spine_Skeleton_class; // NOLINT -bool js_register_spine_Skeleton(se::Object* obj); -bool register_all_spine(se::Object* obj); +bool js_register_spine_Skeleton(se::Object *obj); // NOLINT -JSB_REGISTER_OBJECT_TYPE(spine::Skeleton); SE_DECLARE_FUNC(js_spine_Skeleton_findBone); SE_DECLARE_FUNC(js_spine_Skeleton_findBoneIndex); SE_DECLARE_FUNC(js_spine_Skeleton_findIkConstraint); @@ -750,13 +736,11 @@ SE_DECLARE_FUNC(js_spine_Skeleton_update); SE_DECLARE_FUNC(js_spine_Skeleton_updateCache); SE_DECLARE_FUNC(js_spine_Skeleton_updateWorldTransform); -extern se::Object* __jsb_spine_SkeletonBounds_proto; -extern se::Class* __jsb_spine_SkeletonBounds_class; +extern se::Object *__jsb_spine_SkeletonBounds_proto; // NOLINT +extern se::Class * __jsb_spine_SkeletonBounds_class; // NOLINT -bool js_register_spine_SkeletonBounds(se::Object* obj); -bool register_all_spine(se::Object* obj); +bool js_register_spine_SkeletonBounds(se::Object *obj); // NOLINT -JSB_REGISTER_OBJECT_TYPE(spine::SkeletonBounds); SE_DECLARE_FUNC(js_spine_SkeletonBounds_aabbcontainsPoint); SE_DECLARE_FUNC(js_spine_SkeletonBounds_aabbintersectsSegment); SE_DECLARE_FUNC(js_spine_SkeletonBounds_containsPoint); @@ -765,21 +749,17 @@ SE_DECLARE_FUNC(js_spine_SkeletonBounds_getPolygon); SE_DECLARE_FUNC(js_spine_SkeletonBounds_getWidth); SE_DECLARE_FUNC(js_spine_SkeletonBounds_intersectsSegment); -extern se::Object* __jsb_spine_Polygon_proto; -extern se::Class* __jsb_spine_Polygon_class; +extern se::Object *__jsb_spine_Polygon_proto; // NOLINT +extern se::Class * __jsb_spine_Polygon_class; // NOLINT -bool js_register_spine_Polygon(se::Object* obj); -bool register_all_spine(se::Object* obj); +bool js_register_spine_Polygon(se::Object *obj); // NOLINT -JSB_REGISTER_OBJECT_TYPE(spine::Polygon); -extern se::Object* __jsb_spine_SkeletonData_proto; -extern se::Class* __jsb_spine_SkeletonData_class; +extern se::Object *__jsb_spine_SkeletonData_proto; // NOLINT +extern se::Class * __jsb_spine_SkeletonData_class; // NOLINT -bool js_register_spine_SkeletonData(se::Object* obj); -bool register_all_spine(se::Object* obj); +bool js_register_spine_SkeletonData(se::Object *obj); // NOLINT -JSB_REGISTER_OBJECT_TYPE(spine::SkeletonData); SE_DECLARE_FUNC(js_spine_SkeletonData_findAnimation); SE_DECLARE_FUNC(js_spine_SkeletonData_findBone); SE_DECLARE_FUNC(js_spine_SkeletonData_findBoneIndex); @@ -822,13 +802,11 @@ SE_DECLARE_FUNC(js_spine_SkeletonData_setWidth); SE_DECLARE_FUNC(js_spine_SkeletonData_setX); SE_DECLARE_FUNC(js_spine_SkeletonData_setY); -extern se::Object* __jsb_spine_Skin_proto; -extern se::Class* __jsb_spine_Skin_class; +extern se::Object *__jsb_spine_Skin_proto; // NOLINT +extern se::Class * __jsb_spine_Skin_class; // NOLINT -bool js_register_spine_Skin(se::Object* obj); -bool register_all_spine(se::Object* obj); +bool js_register_spine_Skin(se::Object *obj); // NOLINT -JSB_REGISTER_OBJECT_TYPE(spine::Skin); SE_DECLARE_FUNC(js_spine_Skin_addSkin); SE_DECLARE_FUNC(js_spine_Skin_copySkin); SE_DECLARE_FUNC(js_spine_Skin_getAttachment); @@ -838,13 +816,11 @@ SE_DECLARE_FUNC(js_spine_Skin_getName); SE_DECLARE_FUNC(js_spine_Skin_removeAttachment); SE_DECLARE_FUNC(js_spine_Skin_setAttachment); -extern se::Object* __jsb_spine_Slot_proto; -extern se::Class* __jsb_spine_Slot_class; +extern se::Object *__jsb_spine_Slot_proto; // NOLINT +extern se::Class * __jsb_spine_Slot_class; // NOLINT -bool js_register_spine_Slot(se::Object* obj); -bool register_all_spine(se::Object* obj); +bool js_register_spine_Slot(se::Object *obj); // NOLINT -JSB_REGISTER_OBJECT_TYPE(spine::Slot); SE_DECLARE_FUNC(js_spine_Slot_getAttachment); SE_DECLARE_FUNC(js_spine_Slot_getAttachmentTime); SE_DECLARE_FUNC(js_spine_Slot_getBone); @@ -858,13 +834,11 @@ SE_DECLARE_FUNC(js_spine_Slot_setAttachment); SE_DECLARE_FUNC(js_spine_Slot_setAttachmentTime); SE_DECLARE_FUNC(js_spine_Slot_setToSetupPose); -extern se::Object* __jsb_spine_SlotData_proto; -extern se::Class* __jsb_spine_SlotData_class; +extern se::Object *__jsb_spine_SlotData_proto; // NOLINT +extern se::Class * __jsb_spine_SlotData_class; // NOLINT -bool js_register_spine_SlotData(se::Object* obj); -bool register_all_spine(se::Object* obj); +bool js_register_spine_SlotData(se::Object *obj); // NOLINT -JSB_REGISTER_OBJECT_TYPE(spine::SlotData); SE_DECLARE_FUNC(js_spine_SlotData_getAttachmentName); SE_DECLARE_FUNC(js_spine_SlotData_getBlendMode); SE_DECLARE_FUNC(js_spine_SlotData_getBoneData); @@ -877,13 +851,11 @@ SE_DECLARE_FUNC(js_spine_SlotData_setAttachmentName); SE_DECLARE_FUNC(js_spine_SlotData_setBlendMode); SE_DECLARE_FUNC(js_spine_SlotData_setHasDarkColor); -extern se::Object* __jsb_spine_TransformConstraint_proto; -extern se::Class* __jsb_spine_TransformConstraint_class; +extern se::Object *__jsb_spine_TransformConstraint_proto; // NOLINT +extern se::Class * __jsb_spine_TransformConstraint_class; // NOLINT -bool js_register_spine_TransformConstraint(se::Object* obj); -bool register_all_spine(se::Object* obj); +bool js_register_spine_TransformConstraint(se::Object *obj); // NOLINT -JSB_REGISTER_OBJECT_TYPE(spine::TransformConstraint); SE_DECLARE_FUNC(js_spine_TransformConstraint_apply); SE_DECLARE_FUNC(js_spine_TransformConstraint_getBones); SE_DECLARE_FUNC(js_spine_TransformConstraint_getData); @@ -902,13 +874,11 @@ SE_DECLARE_FUNC(js_spine_TransformConstraint_setTarget); SE_DECLARE_FUNC(js_spine_TransformConstraint_setTranslateMix); SE_DECLARE_FUNC(js_spine_TransformConstraint_update); -extern se::Object* __jsb_spine_TransformConstraintData_proto; -extern se::Class* __jsb_spine_TransformConstraintData_class; +extern se::Object *__jsb_spine_TransformConstraintData_proto; // NOLINT +extern se::Class * __jsb_spine_TransformConstraintData_class; // NOLINT -bool js_register_spine_TransformConstraintData(se::Object* obj); -bool register_all_spine(se::Object* obj); +bool js_register_spine_TransformConstraintData(se::Object *obj); // NOLINT -JSB_REGISTER_OBJECT_TYPE(spine::TransformConstraintData); SE_DECLARE_FUNC(js_spine_TransformConstraintData_getBones); SE_DECLARE_FUNC(js_spine_TransformConstraintData_getOffsetRotation); SE_DECLARE_FUNC(js_spine_TransformConstraintData_getOffsetScaleX); @@ -924,55 +894,45 @@ SE_DECLARE_FUNC(js_spine_TransformConstraintData_getTranslateMix); SE_DECLARE_FUNC(js_spine_TransformConstraintData_isLocal); SE_DECLARE_FUNC(js_spine_TransformConstraintData_isRelative); -extern se::Object* __jsb_spine_TransformConstraintTimeline_proto; -extern se::Class* __jsb_spine_TransformConstraintTimeline_class; +extern se::Object *__jsb_spine_TransformConstraintTimeline_proto; // NOLINT +extern se::Class * __jsb_spine_TransformConstraintTimeline_class; // NOLINT -bool js_register_spine_TransformConstraintTimeline(se::Object* obj); -bool register_all_spine(se::Object* obj); +bool js_register_spine_TransformConstraintTimeline(se::Object *obj); // NOLINT -JSB_REGISTER_OBJECT_TYPE(spine::TransformConstraintTimeline); SE_DECLARE_FUNC(js_spine_TransformConstraintTimeline_getPropertyId); SE_DECLARE_FUNC(js_spine_TransformConstraintTimeline_setFrame); -extern se::Object* __jsb_spine_TwoColorTimeline_proto; -extern se::Class* __jsb_spine_TwoColorTimeline_class; +extern se::Object *__jsb_spine_TwoColorTimeline_proto; // NOLINT +extern se::Class * __jsb_spine_TwoColorTimeline_class; // NOLINT -bool js_register_spine_TwoColorTimeline(se::Object* obj); -bool register_all_spine(se::Object* obj); +bool js_register_spine_TwoColorTimeline(se::Object *obj); // NOLINT -JSB_REGISTER_OBJECT_TYPE(spine::TwoColorTimeline); SE_DECLARE_FUNC(js_spine_TwoColorTimeline_getPropertyId); SE_DECLARE_FUNC(js_spine_TwoColorTimeline_getSlotIndex); SE_DECLARE_FUNC(js_spine_TwoColorTimeline_setFrame); SE_DECLARE_FUNC(js_spine_TwoColorTimeline_setSlotIndex); -extern se::Object* __jsb_spine_VertexEffect_proto; -extern se::Class* __jsb_spine_VertexEffect_class; +extern se::Object *__jsb_spine_VertexEffect_proto; // NOLINT +extern se::Class * __jsb_spine_VertexEffect_class; // NOLINT -bool js_register_spine_VertexEffect(se::Object* obj); -bool register_all_spine(se::Object* obj); +bool js_register_spine_VertexEffect(se::Object *obj); // NOLINT -JSB_REGISTER_OBJECT_TYPE(spine::VertexEffect); -extern se::Object* __jsb_spine_JitterVertexEffect_proto; -extern se::Class* __jsb_spine_JitterVertexEffect_class; +extern se::Object *__jsb_spine_JitterVertexEffect_proto; // NOLINT +extern se::Class * __jsb_spine_JitterVertexEffect_class; // NOLINT -bool js_register_spine_JitterVertexEffect(se::Object* obj); -bool register_all_spine(se::Object* obj); +bool js_register_spine_JitterVertexEffect(se::Object *obj); // NOLINT -JSB_REGISTER_OBJECT_TYPE(spine::JitterVertexEffect); SE_DECLARE_FUNC(js_spine_JitterVertexEffect_getJitterX); SE_DECLARE_FUNC(js_spine_JitterVertexEffect_getJitterY); SE_DECLARE_FUNC(js_spine_JitterVertexEffect_setJitterX); SE_DECLARE_FUNC(js_spine_JitterVertexEffect_setJitterY); -extern se::Object* __jsb_spine_SwirlVertexEffect_proto; -extern se::Class* __jsb_spine_SwirlVertexEffect_class; +extern se::Object *__jsb_spine_SwirlVertexEffect_proto; // NOLINT +extern se::Class * __jsb_spine_SwirlVertexEffect_class; // NOLINT -bool js_register_spine_SwirlVertexEffect(se::Object* obj); -bool register_all_spine(se::Object* obj); +bool js_register_spine_SwirlVertexEffect(se::Object *obj); // NOLINT -JSB_REGISTER_OBJECT_TYPE(spine::SwirlVertexEffect); SE_DECLARE_FUNC(js_spine_SwirlVertexEffect_getAngle); SE_DECLARE_FUNC(js_spine_SwirlVertexEffect_getCenterX); SE_DECLARE_FUNC(js_spine_SwirlVertexEffect_getCenterY); @@ -986,13 +946,11 @@ SE_DECLARE_FUNC(js_spine_SwirlVertexEffect_setRadius); SE_DECLARE_FUNC(js_spine_SwirlVertexEffect_setWorldX); SE_DECLARE_FUNC(js_spine_SwirlVertexEffect_setWorldY); -extern se::Object* __jsb_spine_VertexEffectDelegate_proto; -extern se::Class* __jsb_spine_VertexEffectDelegate_class; +extern se::Object *__jsb_spine_VertexEffectDelegate_proto; // NOLINT +extern se::Class * __jsb_spine_VertexEffectDelegate_class; // NOLINT -bool js_register_spine_VertexEffectDelegate(se::Object* obj); -bool register_all_spine(se::Object* obj); +bool js_register_spine_VertexEffectDelegate(se::Object *obj); // NOLINT -JSB_REGISTER_OBJECT_TYPE(spine::VertexEffectDelegate); SE_DECLARE_FUNC(js_spine_VertexEffectDelegate_clear); SE_DECLARE_FUNC(js_spine_VertexEffectDelegate_getEffectType); SE_DECLARE_FUNC(js_spine_VertexEffectDelegate_getJitterVertexEffect); @@ -1003,13 +961,11 @@ SE_DECLARE_FUNC(js_spine_VertexEffectDelegate_initSwirlWithPow); SE_DECLARE_FUNC(js_spine_VertexEffectDelegate_initSwirlWithPowOut); SE_DECLARE_FUNC(js_spine_VertexEffectDelegate_VertexEffectDelegate); -extern se::Object* __jsb_spine_SkeletonRenderer_proto; -extern se::Class* __jsb_spine_SkeletonRenderer_class; +extern se::Object *__jsb_spine_SkeletonRenderer_proto; // NOLINT +extern se::Class * __jsb_spine_SkeletonRenderer_class; // NOLINT -bool js_register_spine_SkeletonRenderer(se::Object* obj); -bool register_all_spine(se::Object* obj); +bool js_register_spine_SkeletonRenderer(se::Object *obj); // NOLINT -JSB_REGISTER_OBJECT_TYPE(spine::SkeletonRenderer); SE_DECLARE_FUNC(js_spine_SkeletonRenderer_beginSchedule); SE_DECLARE_FUNC(js_spine_SkeletonRenderer_findBone); SE_DECLARE_FUNC(js_spine_SkeletonRenderer_findSlot); @@ -1049,13 +1005,11 @@ SE_DECLARE_FUNC(js_spine_SkeletonRenderer_update); SE_DECLARE_FUNC(js_spine_SkeletonRenderer_updateWorldTransform); SE_DECLARE_FUNC(js_spine_SkeletonRenderer_SkeletonRenderer); -extern se::Object* __jsb_spine_SkeletonAnimation_proto; -extern se::Class* __jsb_spine_SkeletonAnimation_class; +extern se::Object *__jsb_spine_SkeletonAnimation_proto; // NOLINT +extern se::Class * __jsb_spine_SkeletonAnimation_class; // NOLINT -bool js_register_spine_SkeletonAnimation(se::Object* obj); -bool register_all_spine(se::Object* obj); +bool js_register_spine_SkeletonAnimation(se::Object *obj); // NOLINT -JSB_REGISTER_OBJECT_TYPE(spine::SkeletonAnimation); SE_DECLARE_FUNC(js_spine_SkeletonAnimation_addAnimation); SE_DECLARE_FUNC(js_spine_SkeletonAnimation_addEmptyAnimation); SE_DECLARE_FUNC(js_spine_SkeletonAnimation_clearTrack); @@ -1081,18 +1035,16 @@ SE_DECLARE_FUNC(js_spine_SkeletonAnimation_setTrackEventListener); SE_DECLARE_FUNC(js_spine_SkeletonAnimation_setTrackInterruptListener); SE_DECLARE_FUNC(js_spine_SkeletonAnimation_setTrackStartListener); SE_DECLARE_FUNC(js_spine_SkeletonAnimation_create); -SE_DECLARE_FUNC(js_spine_SkeletonAnimation_createWithJsonFile); SE_DECLARE_FUNC(js_spine_SkeletonAnimation_createWithBinaryFile); +SE_DECLARE_FUNC(js_spine_SkeletonAnimation_createWithJsonFile); SE_DECLARE_FUNC(js_spine_SkeletonAnimation_setGlobalTimeScale); SE_DECLARE_FUNC(js_spine_SkeletonAnimation_SkeletonAnimation); -extern se::Object* __jsb_spine_SkeletonCacheAnimation_proto; -extern se::Class* __jsb_spine_SkeletonCacheAnimation_class; +extern se::Object *__jsb_spine_SkeletonCacheAnimation_proto; // NOLINT +extern se::Class * __jsb_spine_SkeletonCacheAnimation_class; // NOLINT -bool js_register_spine_SkeletonCacheAnimation(se::Object* obj); -bool register_all_spine(se::Object* obj); +bool js_register_spine_SkeletonCacheAnimation(se::Object *obj); // NOLINT -JSB_REGISTER_OBJECT_TYPE(spine::SkeletonCacheAnimation); SE_DECLARE_FUNC(js_spine_SkeletonCacheAnimation_addAnimation); SE_DECLARE_FUNC(js_spine_SkeletonCacheAnimation_beginSchedule); SE_DECLARE_FUNC(js_spine_SkeletonCacheAnimation_findAnimation); @@ -1128,26 +1080,22 @@ SE_DECLARE_FUNC(js_spine_SkeletonCacheAnimation_updateAllAnimationCache); SE_DECLARE_FUNC(js_spine_SkeletonCacheAnimation_updateAnimationCache); SE_DECLARE_FUNC(js_spine_SkeletonCacheAnimation_SkeletonCacheAnimation); -extern se::Object* __jsb_spine_SkeletonCacheMgr_proto; -extern se::Class* __jsb_spine_SkeletonCacheMgr_class; +extern se::Object *__jsb_spine_SkeletonCacheMgr_proto; // NOLINT +extern se::Class * __jsb_spine_SkeletonCacheMgr_class; // NOLINT -bool js_register_spine_SkeletonCacheMgr(se::Object* obj); -bool register_all_spine(se::Object* obj); +bool js_register_spine_SkeletonCacheMgr(se::Object *obj); // NOLINT -JSB_REGISTER_OBJECT_TYPE(spine::SkeletonCacheMgr); SE_DECLARE_FUNC(js_spine_SkeletonCacheMgr_buildSkeletonCache); SE_DECLARE_FUNC(js_spine_SkeletonCacheMgr_removeSkeletonCache); -SE_DECLARE_FUNC(js_spine_SkeletonCacheMgr_getInstance); SE_DECLARE_FUNC(js_spine_SkeletonCacheMgr_destroyInstance); +SE_DECLARE_FUNC(js_spine_SkeletonCacheMgr_getInstance); -extern se::Object* __jsb_spine_SkeletonDataMgr_proto; -extern se::Class* __jsb_spine_SkeletonDataMgr_class; +extern se::Object *__jsb_spine_SkeletonDataMgr_proto; // NOLINT +extern se::Class * __jsb_spine_SkeletonDataMgr_class; // NOLINT -bool js_register_spine_SkeletonDataMgr(se::Object* obj); -bool register_all_spine(se::Object* obj); +bool js_register_spine_SkeletonDataMgr(se::Object *obj); // NOLINT -JSB_REGISTER_OBJECT_TYPE(spine::SkeletonDataMgr); SE_DECLARE_FUNC(js_spine_SkeletonDataMgr_setDestroyCallback); SE_DECLARE_FUNC(js_spine_SkeletonDataMgr_getInstance); SE_DECLARE_FUNC(js_spine_SkeletonDataMgr_SkeletonDataMgr); - + // clang-format on \ No newline at end of file diff --git a/native/cocos/bindings/auto/jsb_video_auto.cpp b/native/cocos/bindings/auto/jsb_video_auto.cpp index 979b9d617f..91359b2a4b 100644 --- a/native/cocos/bindings/auto/jsb_video_auto.cpp +++ b/native/cocos/bindings/auto/jsb_video_auto.cpp @@ -1,3 +1,5 @@ + +// clang-format off #include "cocos/bindings/auto/jsb_video_auto.h" #if (USE_VIDEO > 0) #include "cocos/bindings/manual/jsb_conversions.h" @@ -11,8 +13,8 @@ #ifndef JSB_FREE #define JSB_FREE(ptr) delete ptr #endif -se::Object* __jsb_cc_VideoPlayer_proto = nullptr; -se::Class* __jsb_cc_VideoPlayer_class = nullptr; +se::Object* __jsb_cc_VideoPlayer_proto = nullptr; // NOLINT +se::Class* __jsb_cc_VideoPlayer_class = nullptr; // NOLINT static bool js_video_VideoPlayer_addEventListener(se::State& s) // NOLINT(readability-identifier-naming) { @@ -31,12 +33,12 @@ static bool js_video_VideoPlayer_addEventListener(se::State& s) // NOLINT(readab se::Value jsThis(s.thisObject()); se::Value jsFunc(args[1]); jsThis.toObject()->attachObject(jsFunc.toObject()); + auto * thisObj = s.thisObject(); auto lambda = [=]() -> void { se::ScriptEngine::getInstance()->clearException(); se::AutoHandleScope hs; se::Value rval; - se::Object* thisObj = jsThis.isObject() ? jsThis.toObject() : nullptr; se::Object* funcObj = jsFunc.toObject(); bool succeed = funcObj->call(se::EmptyValueArray, thisObj, &rval); if (!succeed) { @@ -305,29 +307,24 @@ SE_DECLARE_FINALIZE_FUNC(js_cc_VideoPlayer_finalize) static bool js_video_VideoPlayer_constructor(se::State& s) // NOLINT(readability-identifier-naming) constructor.c { - cc::VideoPlayer* cobj = JSB_ALLOC(cc::VideoPlayer); - s.thisObject()->setPrivateData(cobj); + auto *ptr = JSB_MAKE_PRIVATE_OBJECT(cc::VideoPlayer); + s.thisObject()->setPrivateObject(ptr); return true; } SE_BIND_CTOR(js_video_VideoPlayer_constructor, __jsb_cc_VideoPlayer_class, js_cc_VideoPlayer_finalize) - - static bool js_cc_VideoPlayer_finalize(se::State& s) // NOLINT(readability-identifier-naming) { - // destructor is skipped return true; } SE_BIND_FINALIZE_FUNC(js_cc_VideoPlayer_finalize) - static bool js_cc_VideoPlayer_destroy(se::State& s) // NOLINT(readability-identifier-naming) { - auto* cobj = SE_THIS_OBJECT(s); - cobj->release(); auto objIter = se::NativePtrToObjectMap::find(SE_THIS_OBJECT(s)); if(objIter != se::NativePtrToObjectMap::end()) { objIter->second->clearPrivateData(true); + objIter->second->decRef(); } return true; } @@ -359,14 +356,15 @@ bool js_register_video_VideoPlayer(se::Object* obj) // NOLINT(readability-identi __jsb_cc_VideoPlayer_proto = cls->getProto(); __jsb_cc_VideoPlayer_class = cls; + se::ScriptEngine::getInstance()->clearException(); return true; } -bool register_all_video(se::Object* obj) +bool register_all_video(se::Object* obj) // NOLINT { // Get the ns se::Value nsVal; - if (!obj->getProperty("jsb", &nsVal)) + if (!obj->getProperty("jsb", &nsVal, true)) { se::HandleObject jsobj(se::Object::createPlainObject()); nsVal.setObject(jsobj); @@ -379,3 +377,4 @@ bool register_all_video(se::Object* obj) } #endif //#if (USE_VIDEO > 0) +// clang-format on \ No newline at end of file diff --git a/native/cocos/bindings/auto/jsb_video_auto.h b/native/cocos/bindings/auto/jsb_video_auto.h index 7409e55cb1..378126e825 100644 --- a/native/cocos/bindings/auto/jsb_video_auto.h +++ b/native/cocos/bindings/auto/jsb_video_auto.h @@ -1,3 +1,4 @@ +// clang-format off #pragma once #include "base/Config.h" #if (USE_VIDEO > 0) @@ -6,13 +7,16 @@ #include "cocos/bindings/manual/jsb_conversions.h" #include "cocos/ui/videoplayer/VideoPlayer.h" -extern se::Object* __jsb_cc_VideoPlayer_proto; -extern se::Class* __jsb_cc_VideoPlayer_class; - -bool js_register_cc_VideoPlayer(se::Object* obj); -bool register_all_video(se::Object* obj); +bool register_all_video(se::Object *obj); // NOLINT JSB_REGISTER_OBJECT_TYPE(cc::VideoPlayer); + + +extern se::Object *__jsb_cc_VideoPlayer_proto; // NOLINT +extern se::Class * __jsb_cc_VideoPlayer_class; // NOLINT + +bool js_register_cc_VideoPlayer(se::Object *obj); // NOLINT + SE_DECLARE_FUNC(js_video_VideoPlayer_addEventListener); SE_DECLARE_FUNC(js_video_VideoPlayer_currentTime); SE_DECLARE_FUNC(js_video_VideoPlayer_duration); @@ -28,5 +32,5 @@ SE_DECLARE_FUNC(js_video_VideoPlayer_setURL); SE_DECLARE_FUNC(js_video_VideoPlayer_setVisible); SE_DECLARE_FUNC(js_video_VideoPlayer_stop); SE_DECLARE_FUNC(js_video_VideoPlayer_VideoPlayer); - #endif //#if (USE_VIDEO > 0) + // clang-format on \ No newline at end of file diff --git a/native/cocos/bindings/auto/jsb_webview_auto.cpp b/native/cocos/bindings/auto/jsb_webview_auto.cpp index 57f2044559..510b31ef9d 100644 --- a/native/cocos/bindings/auto/jsb_webview_auto.cpp +++ b/native/cocos/bindings/auto/jsb_webview_auto.cpp @@ -1,3 +1,5 @@ + +// clang-format off #include "cocos/bindings/auto/jsb_webview_auto.h" #if USE_WEBVIEW > 0 #include "cocos/bindings/manual/jsb_conversions.h" @@ -11,8 +13,8 @@ #ifndef JSB_FREE #define JSB_FREE(ptr) delete ptr #endif -se::Object* __jsb_cc_WebView_proto = nullptr; -se::Class* __jsb_cc_WebView_class = nullptr; +se::Object* __jsb_cc_WebView_proto = nullptr; // NOLINT +se::Class* __jsb_cc_WebView_class = nullptr; // NOLINT static bool js_webview_WebView_canGoBack(se::State& s) // NOLINT(readability-identifier-naming) { @@ -380,6 +382,7 @@ static bool js_webview_WebView_setOnDidFailLoading(se::State& s) // NOLINT(reada se::Value jsThis(s.thisObject()); se::Value jsFunc(args[0]); jsThis.toObject()->attachObject(jsFunc.toObject()); + auto * thisObj = s.thisObject(); auto lambda = [=](cc::WebView* larg0, const std::string larg1) -> void { se::ScriptEngine::getInstance()->clearException(); se::AutoHandleScope hs; @@ -390,7 +393,6 @@ static bool js_webview_WebView_setOnDidFailLoading(se::State& s) // NOLINT(reada ok &= nativevalue_to_se(larg0, args[0], nullptr /*ctx*/); ok &= nativevalue_to_se(larg1, args[1], nullptr /*ctx*/); se::Value rval; - se::Object* thisObj = jsThis.isObject() ? jsThis.toObject() : nullptr; se::Object* funcObj = jsFunc.toObject(); bool succeed = funcObj->call(args, thisObj, &rval); if (!succeed) { @@ -429,6 +431,7 @@ static bool js_webview_WebView_setOnDidFinishLoading(se::State& s) // NOLINT(rea se::Value jsThis(s.thisObject()); se::Value jsFunc(args[0]); jsThis.toObject()->attachObject(jsFunc.toObject()); + auto * thisObj = s.thisObject(); auto lambda = [=](cc::WebView* larg0, const std::string larg1) -> void { se::ScriptEngine::getInstance()->clearException(); se::AutoHandleScope hs; @@ -439,7 +442,6 @@ static bool js_webview_WebView_setOnDidFinishLoading(se::State& s) // NOLINT(rea ok &= nativevalue_to_se(larg0, args[0], nullptr /*ctx*/); ok &= nativevalue_to_se(larg1, args[1], nullptr /*ctx*/); se::Value rval; - se::Object* thisObj = jsThis.isObject() ? jsThis.toObject() : nullptr; se::Object* funcObj = jsFunc.toObject(); bool succeed = funcObj->call(args, thisObj, &rval); if (!succeed) { @@ -478,6 +480,7 @@ static bool js_webview_WebView_setOnJSCallback(se::State& s) // NOLINT(readabili se::Value jsThis(s.thisObject()); se::Value jsFunc(args[0]); jsThis.toObject()->attachObject(jsFunc.toObject()); + auto * thisObj = s.thisObject(); auto lambda = [=](cc::WebView* larg0, const std::string larg1) -> void { se::ScriptEngine::getInstance()->clearException(); se::AutoHandleScope hs; @@ -488,7 +491,6 @@ static bool js_webview_WebView_setOnJSCallback(se::State& s) // NOLINT(readabili ok &= nativevalue_to_se(larg0, args[0], nullptr /*ctx*/); ok &= nativevalue_to_se(larg1, args[1], nullptr /*ctx*/); se::Value rval; - se::Object* thisObj = jsThis.isObject() ? jsThis.toObject() : nullptr; se::Object* funcObj = jsFunc.toObject(); bool succeed = funcObj->call(args, thisObj, &rval); if (!succeed) { @@ -527,6 +529,7 @@ static bool js_webview_WebView_setOnShouldStartLoading(se::State& s) // NOLINT(r se::Value jsThis(s.thisObject()); se::Value jsFunc(args[0]); jsThis.toObject()->attachObject(jsFunc.toObject()); + auto * thisObj = s.thisObject(); auto lambda = [=](cc::WebView* larg0, const std::string larg1) -> bool { se::ScriptEngine::getInstance()->clearException(); se::AutoHandleScope hs; @@ -537,7 +540,6 @@ static bool js_webview_WebView_setOnShouldStartLoading(se::State& s) // NOLINT(r ok &= nativevalue_to_se(larg0, args[0], nullptr /*ctx*/); ok &= nativevalue_to_se(larg1, args[1], nullptr /*ctx*/); se::Value rval; - se::Object* thisObj = jsThis.isObject() ? jsThis.toObject() : nullptr; se::Object* funcObj = jsFunc.toObject(); bool succeed = funcObj->call(args, thisObj, &rval); if (!succeed) { @@ -618,40 +620,34 @@ static bool js_webview_WebView_stopLoading(se::State& s) // NOLINT(readability-i } SE_BIND_FUNC(js_webview_WebView_stopLoading) -static bool js_webview_WebView_create(se::State& s) // NOLINT(readability-identifier-naming) +static bool js_webview_WebView_create_static(se::State& s) // NOLINT(readability-identifier-naming) { const auto& args = s.args(); size_t argc = args.size(); CC_UNUSED bool ok = true; if (argc == 0) { - auto result = cc::WebView::create(); - result->retain(); - auto obj = se::Object::createObjectWithClass(__jsb_cc_WebView_class); - obj->setPrivateData(result); - s.rval().setObject(obj); + cc::WebView* result = cc::WebView::create(); + ok &= nativevalue_to_se(result, s.rval(), nullptr /*ctx*/); + SE_PRECONDITION2(ok, false, "js_webview_WebView_create_static : Error processing arguments"); + SE_HOLD_RETURN_VALUE(result, s.thisObject(), s.rval()); return true; } SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 0); return false; } -SE_BIND_FUNC(js_webview_WebView_create) - - +SE_BIND_FUNC(js_webview_WebView_create_static) static bool js_cc_WebView_finalize(se::State& s) // NOLINT(readability-identifier-naming) { - // destructor is skipped return true; } SE_BIND_FINALIZE_FUNC(js_cc_WebView_finalize) - static bool js_cc_WebView_destroy(se::State& s) // NOLINT(readability-identifier-naming) { - auto* cobj = SE_THIS_OBJECT(s); - cobj->release(); auto objIter = se::NativePtrToObjectMap::find(SE_THIS_OBJECT(s)); if(objIter != se::NativePtrToObjectMap::end()) { objIter->second->clearPrivateData(true); + objIter->second->decRef(); } return true; } @@ -687,7 +683,7 @@ bool js_register_webview_WebView(se::Object* obj) // NOLINT(readability-identifi cls->defineFunction("setVisible", _SE(js_webview_WebView_setVisible)); cls->defineFunction("stopLoading", _SE(js_webview_WebView_stopLoading)); cls->defineFunction("destroy", _SE(js_cc_WebView_destroy)); - cls->defineStaticFunction("create", _SE(js_webview_WebView_create)); + cls->defineStaticFunction("create", _SE(js_webview_WebView_create_static)); cls->defineFinalizeFunction(_SE(js_cc_WebView_finalize)); cls->install(); JSBClassType::registerClass(cls); @@ -695,14 +691,15 @@ bool js_register_webview_WebView(se::Object* obj) // NOLINT(readability-identifi __jsb_cc_WebView_proto = cls->getProto(); __jsb_cc_WebView_class = cls; + se::ScriptEngine::getInstance()->clearException(); return true; } -bool register_all_webview(se::Object* obj) +bool register_all_webview(se::Object* obj) // NOLINT { // Get the ns se::Value nsVal; - if (!obj->getProperty("jsb", &nsVal)) + if (!obj->getProperty("jsb", &nsVal, true)) { se::HandleObject jsobj(se::Object::createPlainObject()); nsVal.setObject(jsobj); @@ -715,3 +712,4 @@ bool register_all_webview(se::Object* obj) } #endif //#if USE_WEBVIEW > 0 +// clang-format on \ No newline at end of file diff --git a/native/cocos/bindings/auto/jsb_webview_auto.h b/native/cocos/bindings/auto/jsb_webview_auto.h index 6ed2a2ef48..cc83c650b4 100644 --- a/native/cocos/bindings/auto/jsb_webview_auto.h +++ b/native/cocos/bindings/auto/jsb_webview_auto.h @@ -1,3 +1,4 @@ +// clang-format off #pragma once #include "base/Config.h" #if USE_WEBVIEW > 0 @@ -6,13 +7,16 @@ #include "cocos/bindings/manual/jsb_conversions.h" #include "cocos/ui/webview/WebView.h" -extern se::Object* __jsb_cc_WebView_proto; -extern se::Class* __jsb_cc_WebView_class; - -bool js_register_cc_WebView(se::Object* obj); -bool register_all_webview(se::Object* obj); +bool register_all_webview(se::Object *obj); // NOLINT JSB_REGISTER_OBJECT_TYPE(cc::WebView); + + +extern se::Object *__jsb_cc_WebView_proto; // NOLINT +extern se::Class * __jsb_cc_WebView_class; // NOLINT + +bool js_register_cc_WebView(se::Object *obj); // NOLINT + SE_DECLARE_FUNC(js_webview_WebView_canGoBack); SE_DECLARE_FUNC(js_webview_WebView_canGoForward); SE_DECLARE_FUNC(js_webview_WebView_evaluateJS); @@ -39,5 +43,5 @@ SE_DECLARE_FUNC(js_webview_WebView_setScalesPageToFit); SE_DECLARE_FUNC(js_webview_WebView_setVisible); SE_DECLARE_FUNC(js_webview_WebView_stopLoading); SE_DECLARE_FUNC(js_webview_WebView_create); - #endif //#if USE_WEBVIEW > 0 + // clang-format on \ No newline at end of file diff --git a/native/cocos/bindings/dop/jsb_dop.cpp b/native/cocos/bindings/dop/jsb_dop.cpp index e0440af432..c523f102b8 100644 --- a/native/cocos/bindings/dop/jsb_dop.cpp +++ b/native/cocos/bindings/dop/jsb_dop.cpp @@ -55,9 +55,9 @@ static bool jsb_BufferPool_constructor(se::State &s) { // NOLINT uint bytesPerEntry = 0; bool ok = true; - ok &= seval_to_uint32(args[0], &poolType); - ok &= seval_to_uint32(args[1], &entryBits); - ok &= seval_to_uint32(args[2], &bytesPerEntry); + ok &= sevalue_to_native(args[0], &poolType); + ok &= sevalue_to_native(args[1], &entryBits); + ok &= sevalue_to_native(args[2], &bytesPerEntry); if (!ok) { SE_REPORT_ERROR("jsb_BufferPool_constructor: argument convertion error"); return false; @@ -65,7 +65,6 @@ static bool jsb_BufferPool_constructor(se::State &s) { // NOLINT se::BufferPool *pool = JSB_ALLOC(se::BufferPool, (se::PoolType)poolType, entryBits, bytesPerEntry); s.thisObject()->setPrivateData(pool); - se::NonRefNativePtrCreatedByCtorMap::emplace(pool); return true; } @@ -75,12 +74,6 @@ static bool jsb_BufferPool_constructor(se::State &s) { // NOLINT SE_BIND_CTOR(jsb_BufferPool_constructor, jsb_BufferPool_class, jsb_BufferPool_finalize) // NOLINT static bool jsb_BufferPool_finalize(se::State &s) { // NOLINT - auto iter = se::NonRefNativePtrCreatedByCtorMap::find(s.nativeThisObject()); - if (iter != se::NonRefNativePtrCreatedByCtorMap::end()) { - se::NonRefNativePtrCreatedByCtorMap::erase(iter); - auto *cobj = static_cast(s.nativeThisObject()); - JSB_FREE(cobj); - } return true; } SE_BIND_FINALIZE_FUNC(jsb_BufferPool_finalize) @@ -113,7 +106,6 @@ static bool jsb_BufferAllocator_constructor(se::State &s) { // NOLINT se::BufferAllocator *bufferAllocator = JSB_ALLOC(se::BufferAllocator, static_cast(type)); s.thisObject()->setPrivateData(bufferAllocator); - se::NonRefNativePtrCreatedByCtorMap::emplace(bufferAllocator); return true; } @@ -123,12 +115,6 @@ static bool jsb_BufferAllocator_constructor(se::State &s) { // NOLINT SE_BIND_CTOR(jsb_BufferAllocator_constructor, jsb_BufferAllocator_class, jsb_BufferAllocator_finalize) static bool jsb_BufferAllocator_finalize(se::State &s) { // NOLINT - auto iter = se::NonRefNativePtrCreatedByCtorMap::find(s.nativeThisObject()); - if (iter != se::NonRefNativePtrCreatedByCtorMap::end()) { - se::NonRefNativePtrCreatedByCtorMap::erase(iter); - auto *cobj = static_cast(s.nativeThisObject()); - JSB_FREE(cobj); - } return true; } SE_BIND_FINALIZE_FUNC(jsb_BufferAllocator_finalize) @@ -141,9 +127,9 @@ static bool jsb_BufferAllocator_alloc(se::State &s) { // NOLINT size_t argc = args.size(); if (argc == 2) { uint index = 0; - seval_to_uint32(args[0], &index); + sevalue_to_native(args[0], &index); uint bytes = 0; - seval_to_uint32(args[1], &bytes); + sevalue_to_native(args[1], &bytes); s.rval().setObject(bufferAllocator->alloc(index, bytes)); return true; } @@ -161,7 +147,7 @@ static bool jsb_BufferAllocator_free(se::State &s) { // NOLINT size_t argc = args.size(); if (argc == 1) { uint index = 0; - seval_to_uint32(args[0], &index); + sevalue_to_native(args[0], &index); bufferAllocator->free(index); return true; } diff --git a/native/cocos/bindings/event/EventDispatcher.cpp b/native/cocos/bindings/event/EventDispatcher.cpp index 64622bf949..7015ec0c8d 100644 --- a/native/cocos/bindings/event/EventDispatcher.cpp +++ b/native/cocos/bindings/event/EventDispatcher.cpp @@ -33,6 +33,7 @@ #endif namespace { se::Value tickVal; +se::ValueArray tickArgsValArr(1); std::vector jsTouchObjPool; se::Object * jsTouchObjArray = nullptr; se::Object * jsMouseEventObj = nullptr; @@ -243,11 +244,12 @@ void EventDispatcher::dispatchTickEvent(float /*dt*/) { static std::chrono::steady_clock::time_point prevTime; prevTime = std::chrono::steady_clock::now(); - se::ValueArray args; - int64_t milliSeconds = std::chrono::duration_cast(prevTime - se::ScriptEngine::getInstance()->getStartTime()).count(); - args.push_back(se::Value(static_cast(milliSeconds))); + int64_t milliSeconds = std::chrono::duration_cast(prevTime - se::ScriptEngine::getInstance()->getStartTime()).count(); + tickArgsValArr[0].setDouble(static_cast(milliSeconds)); - tickVal.toObject()->call(args, nullptr); + if (!tickVal.isUndefined()) { + tickVal.toObject()->call(tickArgsValArr, nullptr); + } } void EventDispatcher::dispatchResizeEvent(int width, int height) { diff --git a/native/cocos/bindings/event/EventDispatcher.h b/native/cocos/bindings/event/EventDispatcher.h index ff9f0c5394..8fd50c7bf1 100644 --- a/native/cocos/bindings/event/EventDispatcher.h +++ b/native/cocos/bindings/event/EventDispatcher.h @@ -236,7 +236,7 @@ public: int16_t shortVal; char charVal; bool boolVal; - } args[10]; + } args[10] = {0}; virtual ~CustomEvent() = default; }; @@ -256,7 +256,7 @@ public: int16_t shortVal; char charVal; bool boolVal; - } args[3]; + } args[3] = {0}; Type type = Type::DEVICE_MEMORY; }; diff --git a/native/cocos/bindings/jswrapper/MappingUtils.cpp b/native/cocos/bindings/jswrapper/MappingUtils.cpp index 8247b5989c..7be7eeb51d 100644 --- a/native/cocos/bindings/jswrapper/MappingUtils.cpp +++ b/native/cocos/bindings/jswrapper/MappingUtils.cpp @@ -80,59 +80,4 @@ NativePtrToObjectMap::Map::iterator NativePtrToObjectMap::begin() { NativePtrToObjectMap::Map::iterator NativePtrToObjectMap::end() { return __nativePtrToObjectMap->end(); } - -// NonRefNativePtrCreatedByCtorMap - -NonRefNativePtrCreatedByCtorMap::Map *NonRefNativePtrCreatedByCtorMap::__nonRefNativeObjectCreatedByCtorMap = nullptr; - -bool NonRefNativePtrCreatedByCtorMap::init() { - if (__nonRefNativeObjectCreatedByCtorMap == nullptr) - __nonRefNativeObjectCreatedByCtorMap = new (std::nothrow) NonRefNativePtrCreatedByCtorMap::Map(); - - return __nonRefNativeObjectCreatedByCtorMap != nullptr; -} - -void NonRefNativePtrCreatedByCtorMap::destroy() { - if (__nonRefNativeObjectCreatedByCtorMap != nullptr) { - delete __nonRefNativeObjectCreatedByCtorMap; - __nonRefNativeObjectCreatedByCtorMap = nullptr; - } -} - -void NonRefNativePtrCreatedByCtorMap::emplace(void *nativeObj) { - __nonRefNativeObjectCreatedByCtorMap->emplace(nativeObj, true); -} - -NonRefNativePtrCreatedByCtorMap::Map::iterator NonRefNativePtrCreatedByCtorMap::find(void *nativeObj) { - return __nonRefNativeObjectCreatedByCtorMap->find(nativeObj); -} - -NonRefNativePtrCreatedByCtorMap::Map::iterator NonRefNativePtrCreatedByCtorMap::erase(Map::iterator iter) { - return __nonRefNativeObjectCreatedByCtorMap->erase(iter); -} - -void NonRefNativePtrCreatedByCtorMap::erase(void *nativeObj) { - __nonRefNativeObjectCreatedByCtorMap->erase(nativeObj); -} - -void NonRefNativePtrCreatedByCtorMap::clear() { - __nonRefNativeObjectCreatedByCtorMap->clear(); -} - -size_t NonRefNativePtrCreatedByCtorMap::size() { - return __nonRefNativeObjectCreatedByCtorMap->size(); -} - -const NonRefNativePtrCreatedByCtorMap::Map &NonRefNativePtrCreatedByCtorMap::instance() { - return *__nonRefNativeObjectCreatedByCtorMap; -} - -NonRefNativePtrCreatedByCtorMap::Map::iterator NonRefNativePtrCreatedByCtorMap::begin() { - return __nonRefNativeObjectCreatedByCtorMap->begin(); -} - -NonRefNativePtrCreatedByCtorMap::Map::iterator NonRefNativePtrCreatedByCtorMap::end() { - return __nonRefNativeObjectCreatedByCtorMap->end(); -} - } // namespace se diff --git a/native/cocos/bindings/jswrapper/MappingUtils.h b/native/cocos/bindings/jswrapper/MappingUtils.h index 90b70f9d38..f62df47fb7 100644 --- a/native/cocos/bindings/jswrapper/MappingUtils.h +++ b/native/cocos/bindings/jswrapper/MappingUtils.h @@ -42,9 +42,9 @@ public: static Map::iterator find(void *nativeObj); static Map::iterator erase(Map::iterator iter); - static void erase(void *nativeObj); - static void clear(); - static size_t size(); + static void erase(void *nativeObj); + static void clear(); + static size_t size(); static const Map &instance(); @@ -57,29 +57,4 @@ private: friend class Object; }; - -class NonRefNativePtrCreatedByCtorMap { -public: - // key: native ptr, value: non-ref object created by ctor - using Map = std::unordered_map; - - static bool init(); - static void destroy(); - - static void emplace(void *nativeObj); - static Map::iterator find(void *nativeObj); - static Map::iterator erase(Map::iterator iter); - static void erase(void *nativeObj); - static void clear(); - static size_t size(); - - static const Map &instance(); - - static Map::iterator begin(); - static Map::iterator end(); - -private: - static Map *__nonRefNativeObjectCreatedByCtorMap; -}; - } // namespace se diff --git a/native/cocos/bindings/jswrapper/PrivateObject.h b/native/cocos/bindings/jswrapper/PrivateObject.h new file mode 100644 index 0000000000..a6facba1ed --- /dev/null +++ b/native/cocos/bindings/jswrapper/PrivateObject.h @@ -0,0 +1,229 @@ +/**************************************************************************** + 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 +#include +#include +#include "base/Ptr.h" +#include "base/RefCounted.h" + +namespace se { + +class Object; +class State; +class ScriptEngine; + +template +class TypedPrivateObject; + +class PrivateObjectBase { +public: + virtual ~PrivateObjectBase() = default; + + template + inline T *get() const { + return reinterpret_cast(getRaw()); + } + + template + inline TypedPrivateObject *typed() { + return reinterpret_cast *>(this); + } + virtual const char *getName() const = 0; + virtual void * getRaw() const = 0; + virtual void allowDestroyInGC() const { + assert(false); + } + virtual void tryAllowDestroyInGC() const {} + + virtual bool isSharedPtr() const { return false; } + virtual bool isCCShared() const { return false; } + + friend se::Object; + friend se::State; + friend se::ScriptEngine; +}; + +template +class TypedPrivateObject : public PrivateObjectBase { +public: + inline std::shared_ptr share(); + inline cc::IntrusivePtr &ccShared(); + inline const char * getName() const override { + static_assert(!std::is_base_of::value, ""); // NOLINT // remove after using c++17 + return typeid(T).name(); + } +}; + +template +class SharedPrivateObject final : public TypedPrivateObject { +public: + SharedPrivateObject() = default; + explicit SharedPrivateObject(const std::shared_ptr &ptr) : _data(ptr) {} + explicit SharedPrivateObject(std::shared_ptr &&ptr) : _data(std::move(ptr)) {} + inline std::shared_ptr getData() const { + return _data; + } + + constexpr bool isSharedPtr() const override { return true; } + + void *getRaw() const override { return _data.get(); } + +private: + std::shared_ptr _data{nullptr}; +}; + +template +class CCSharedPtrPrivateObject final : public TypedPrivateObject { +public: + CCSharedPtrPrivateObject() = default; + explicit CCSharedPtrPrivateObject(const cc::IntrusivePtr &p) : _ptr(p) {} + explicit CCSharedPtrPrivateObject(cc::IntrusivePtr &&p) : _ptr(std::move(p)) {} + ~CCSharedPtrPrivateObject() override = default; + + inline void *getRaw() const override { + return _ptr.get(); + } + inline bool isCCShared() const override { return true; } + +private: + cc::IntrusivePtr _ptr; + + friend TypedPrivateObject; +}; + +template +class RawRefPrivateObject final : public TypedPrivateObject { +public: + RawRefPrivateObject() = default; + explicit RawRefPrivateObject(T *p) : _ptr(p) {} + ~RawRefPrivateObject() override { + static_assert(!std::is_same::value, "void is not allowed!"); + if (_allowGC) { + delete _ptr; + } + _ptr = nullptr; + } + + //bool *getValidAddr() { return &_validate; } + + void allowDestroyInGC() const override { + _allowGC = true; + } + void tryAllowDestroyInGC() const override { + allowDestroyInGC(); + } + + void *getRaw() const override { + //assert(_validate); + return _ptr; + } + +private: + T *_ptr = nullptr; + //bool _validate = true; + mutable bool _allowGC = false; +}; + +template +inline std::shared_ptr TypedPrivateObject::share() { + if (isSharedPtr()) { + return reinterpret_cast *>(this)->getData(); + } + assert(false); + return std::shared_ptr(nullptr); +} +template +inline cc::IntrusivePtr &TypedPrivateObject::ccShared() { + assert(isCCShared()); + return reinterpret_cast *>(this)->_ptr; +} + +#if CC_DEBUG +inline void inHeap(void *ptr) { + constexpr size_t r = 4 * 1024; // 4K + char a; + auto anchor = reinterpret_cast(&a); + auto p = reinterpret_cast(ptr); + // must be in heaps + assert(abs(anchor - p) > r); +} +#endif + +template +typename std::enable_if::value, PrivateObjectBase *>::type +cc_tmp_new_ptr(T *cobj) { + return new CCSharedPtrPrivateObject(cc::IntrusivePtr(cobj)); +} +template +typename std::enable_if::value, PrivateObjectBase *>::type +cc_tmp_new_ptr(T *cobj) { + return new SharedPrivateObject(std::shared_ptr(cobj)); +} + +template +inline PrivateObjectBase *make_shared_private_object(T *cobj) { // NOLINT + static_assert(!std::is_same::value, "void * is not allowed"); +// static_assert(!std::is_pointer_v && !std::is_null_pointer_v, "bad pointer"); +#if CC_DEBUG + inHeap(cobj); +#endif + return cc_tmp_new_ptr(cobj); +} +template +inline PrivateObjectBase *shared_private_object(std::shared_ptr &&ptr) { // NOLINT + static_assert(!std::is_base_of::value, "cc::RefCounted is not acceptable for shared_ptr"); + return new SharedPrivateObject(std::forward>(ptr)); +} + +template +inline PrivateObjectBase *shared_private_object(const std::shared_ptr &ptr) { // NOLINT + static_assert(!std::is_base_of::value, "cc::RefCounted is not acceptable for shared_ptr"); + return new SharedPrivateObject(ptr); +} + +template +inline PrivateObjectBase *rawref_private_object(T *ptr) { // NOLINT + // static_assert(false, "always fail"); + static_assert(!std::is_base_of::value, "cc::RefCounted is not acceptable for shared_ptr"); +#if CC_DEBUG + inHeap(ptr); +#endif + return new RawRefPrivateObject(ptr); +} + +template +inline PrivateObjectBase *ccshared_private_object(const cc::IntrusivePtr &ptr) { // NOLINT + static_assert(std::is_base_of::value, "cc::RefCounted expected!"); + return new CCSharedPtrPrivateObject(ptr); +} +template +inline PrivateObjectBase *ccshared_private_object(T *cobj) { // NOLINT + static_assert(std::is_base_of::value, "cc::RefCounted expected!"); + return new CCSharedPtrPrivateObject(cc::IntrusivePtr(cobj)); +} +} // namespace se diff --git a/native/cocos/bindings/jswrapper/State.cpp b/native/cocos/bindings/jswrapper/State.cpp index 497ac03b3f..07050caf96 100644 --- a/native/cocos/bindings/jswrapper/State.cpp +++ b/native/cocos/bindings/jswrapper/State.cpp @@ -29,30 +29,38 @@ namespace se { -State::State() -: _nativeThisObject(nullptr), - _thisObject(nullptr), - _args(nullptr) { -} +State::State() = default; State::~State() { SAFE_DEC_REF(_thisObject); } -State::State(void *nativeThisObject) -: _nativeThisObject(nativeThisObject), - _thisObject(nullptr), - _args(nullptr) { -} +State::State(PrivateObjectBase *privateObject) +: _privateObject(privateObject) {} -State::State(void *nativeThisObject, const ValueArray &args) -: _nativeThisObject(nativeThisObject), - _thisObject(nullptr), +State::State(PrivateObjectBase *privateObject, const ValueArray &args) +: _privateObject(privateObject), _args(&args) { } State::State(Object *thisObject, const ValueArray &args) -: _nativeThisObject(nullptr), +: _thisObject(thisObject), + _args(&args) { + if (_thisObject != nullptr) { + _thisObject->incRef(); + } +} + +State::State(Object *thisObject, PrivateObjectBase *privateObject) +: _privateObject(privateObject), + _thisObject(thisObject) { + if (_thisObject != nullptr) { + _thisObject->incRef(); + } +} + +State::State(Object *thisObject, PrivateObjectBase *privateObject, const ValueArray &args) +: _privateObject(privateObject), _thisObject(thisObject), _args(&args) { if (_thisObject != nullptr) { @@ -61,7 +69,16 @@ State::State(Object *thisObject, const ValueArray &args) } void *State::nativeThisObject() const { - return _nativeThisObject; + return _privateObject ? _privateObject->getRaw() : nullptr; +} + +Object *State::thisObject() { + if (nullptr == _thisObject && nullptr != _privateObject) { + _thisObject = se::Object::getObjectWithPtr(_privateObject->getRaw()); + } + // _nativeThisObject in Static method will be nullptr + // assert(_thisObject != nullptr); + return _thisObject; } const ValueArray &State::args() const { @@ -71,15 +88,6 @@ const ValueArray &State::args() const { return EmptyValueArray; } -Object *State::thisObject() { - if (nullptr == _thisObject && nullptr != _nativeThisObject) { - _thisObject = se::Object::getObjectWithPtr(_nativeThisObject); - } - // _nativeThisObject in Static method will be nullptr - // assert(_thisObject != nullptr); - return _thisObject; -} - Value &State::rval() { return _retVal; } diff --git a/native/cocos/bindings/jswrapper/State.h b/native/cocos/bindings/jswrapper/State.h index b98b69ca1b..5fbd434ccb 100644 --- a/native/cocos/bindings/jswrapper/State.h +++ b/native/cocos/bindings/jswrapper/State.h @@ -26,6 +26,7 @@ #pragma once +#include "PrivateObject.h" #include "Value.h" namespace se { @@ -76,19 +77,10 @@ public: */ ~State(); - /** - * @brief - * @param[in] - * @return - */ - State(void *nativeThisObject); - - /** - * @brief - * @param[in] - * @return - */ - State(void *nativeThisObject, const ValueArray &args); + explicit State(PrivateObjectBase *privateObject); + State(PrivateObjectBase *privateObject, const ValueArray &args); + State(Object *thisObject, PrivateObjectBase *privateObject); + State(Object *thisObject, PrivateObjectBase *privateObject, const ValueArray &args); /** * @brief @@ -100,13 +92,13 @@ public: private: // Disable copy/move constructor, copy/move assigment State(const State &); - State(State &&); + State(State &&) noexcept; State &operator=(const State &); - State &operator=(State &&); + State &operator=(State &&) noexcept; - void *_nativeThisObject; //weak ref - Object *_thisObject; //weak ref - const ValueArray *_args; //weak ref - Value _retVal; //weak ref + PrivateObjectBase *_privateObject{nullptr}; + Object * _thisObject{nullptr}; //weak ref + const ValueArray * _args{nullptr}; //weak ref + Value _retVal; //weak ref }; } // namespace se diff --git a/native/cocos/bindings/jswrapper/Value.cpp b/native/cocos/bindings/jswrapper/Value.cpp index 2d70118671..11d6f25be2 100644 --- a/native/cocos/bindings/jswrapper/Value.cpp +++ b/native/cocos/bindings/jswrapper/Value.cpp @@ -25,6 +25,7 @@ ****************************************************************************/ #include "Value.h" +#include #include #include #include @@ -57,6 +58,19 @@ inline #define CONVERT_TO_TYPE(type) fromDoubleToIntegral(toDouble()) +namespace { + +bool isInteger(const std::string &str) { + for (const char &c : str) { // NOLINT //remvoe after using c++20 + if (std::isdigit(c) == 0) { + return false; + } + } + return true; +} + +} // namespace + ValueArray EmptyValueArray; // NOLINT(readability-identifier-naming) Value Value::Null = Value(Type::Null); //NOLINT(readability-identifier-naming) @@ -442,14 +456,20 @@ float Value::toFloat() const { } double Value::toDouble() const { - assert(_type == Type::Number || _type == Type::Boolean || _type == Type::BigInt); - if(LIKELY(_type == Type::Number)) { + assert(_type == Type::Number || _type == Type::Boolean || _type == Type::BigInt || (_type == Type::String && isInteger(*_u._string))); + if (LIKELY(_type == Type::Number)) { return _u._number; } if (_type == Type::BigInt) { // CC_LOG_WARNING("convert int64 to double"); return static_cast(_u._bigint); } + + // TODO(): Only supports to convert integer string to integer now. + if (_type == Type::String && isInteger(*_u._string)) { + return atoi(_u._string->c_str()); + } + return _u._boolean ? 1.0 : 0.0; } @@ -550,11 +570,11 @@ unsigned int Value::toUint() const { return CONVERT_TO_TYPE(unsigned int); } -long Value::toLong() const { // NOLINT(google-runtime-int) +long Value::toLong() const { // NOLINT(google-runtime-int) return CONVERT_TO_TYPE(long); } -unsigned long Value::toUlong() const { // NOLINT(google-runtime-int) +unsigned long Value::toUlong() const { // NOLINT(google-runtime-int) return CONVERT_TO_TYPE(unsigned long); } diff --git a/native/cocos/bindings/jswrapper/ValueArrayPool.cpp b/native/cocos/bindings/jswrapper/ValueArrayPool.cpp new file mode 100644 index 0000000000..f5d6cb2a0f --- /dev/null +++ b/native/cocos/bindings/jswrapper/ValueArrayPool.cpp @@ -0,0 +1,67 @@ +/**************************************************************************** + Copyright (c) 2016 Chukong Technologies Inc. + Copyright (c) 2017-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 "ValueArrayPool.h" +#include +#include "config.h" + +namespace se { + +ValueArrayPool gValueArrayPool; + +#define SE_DEFAULT_MAX_DEPTH (5) + +ValueArrayPool::ValueArrayPool() { + _pools.resize(SE_DEFAULT_MAX_DEPTH); + for (uint32_t i = 0; i < SE_DEFAULT_MAX_DEPTH; ++i) { + initPool(i); + } +} + +ValueArray &ValueArrayPool::get(uint32_t argc) { + if (SE_UNLIKELY(_depth >= _pools.size())) { + auto *ptr = _pools.data(); + _pools.resize(_depth + 1); + assert(_pools.data() == ptr); + initPool(_depth); + } + + assert(argc <= MAX_ARGS); + auto &ret = _pools[_depth][argc]; + assert(ret.size() == argc); + return ret; +} + +void ValueArrayPool::initPool(uint32_t index) { + auto & pool = _pools[index]; + uint32_t i = 0; + for (auto &arr : pool) { + arr.resize(i); + ++i; + } +} + +} // namespace se diff --git a/native/cocos/bindings/jswrapper/ValueArrayPool.h b/native/cocos/bindings/jswrapper/ValueArrayPool.h new file mode 100644 index 0000000000..16bf40a224 --- /dev/null +++ b/native/cocos/bindings/jswrapper/ValueArrayPool.h @@ -0,0 +1,70 @@ +/**************************************************************************** + Copyright (c) 2016 Chukong Technologies Inc. + Copyright (c) 2017-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 "Value.h" + +namespace se { + +class CallbackDepthGuard final { +public: + CallbackDepthGuard(ValueArray &arr, uint32_t &depth) + : _arr(arr), _depth(depth) { + ++_depth; + } + + ~CallbackDepthGuard() { + --_depth; + for (auto &e : _arr) { + e.setUndefined(); + } + } + +private: + ValueArray &_arr; + uint32_t & _depth; +}; + +class ValueArrayPool final { +public: + static const uint32_t MAX_ARGS = 20; + + ValueArrayPool(); + + ValueArray &get(uint32_t argc); + + uint32_t _depth{0}; + +private: + void initPool(uint32_t index); + std::vector> _pools; +}; + +extern ValueArrayPool gValueArrayPool; + +} // namespace se diff --git a/native/cocos/bindings/jswrapper/config.h b/native/cocos/bindings/jswrapper/config.h index db19dc3c10..61209108d2 100644 --- a/native/cocos/bindings/jswrapper/config.h +++ b/native/cocos/bindings/jswrapper/config.h @@ -131,3 +131,11 @@ typedef SSIZE_T ssize_t; #else #define SE_DEPRECATED_ATTRIBUTE #endif // SE_DEPRECATED_ATTRIBUTE + +#if defined(__GNUC__) && __GNUC__ >= 4 + #define SE_LIKELY(x) (__builtin_expect((x), 1)) + #define SE_UNLIKELY(x) (__builtin_expect((x), 0)) +#else + #define SE_LIKELY(x) (x) + #define SE_UNLIKELY(x) (x) +#endif diff --git a/native/cocos/bindings/jswrapper/v8/Base.h b/native/cocos/bindings/jswrapper/v8/Base.h index 3ca1c92e5d..665a813e06 100644 --- a/native/cocos/bindings/jswrapper/v8/Base.h +++ b/native/cocos/bindings/jswrapper/v8/Base.h @@ -34,17 +34,18 @@ #include "v8.h" -#include -#include // Resolves that memset, memcpy aren't found while APP_PLATFORM >= 22 on Android -#include -#include -#include +#include +#include // Resolves that memset, memcpy aren't found while APP_PLATFORM >= 22 on Android #include // for std::find #include -#include +#include +#include +#include +#include +#include "../PrivateObject.h" #include "HelperMacros.h" namespace se { -using V8FinalizeFunc = void (*)(void *nativeObj); -} +using V8FinalizeFunc = void (*)(PrivateObjectBase *nativeObj); +} // namespace se diff --git a/native/cocos/bindings/jswrapper/v8/Class.cpp b/native/cocos/bindings/jswrapper/v8/Class.cpp index e9f1ceaf84..78f063ba3a 100644 --- a/native/cocos/bindings/jswrapper/v8/Class.cpp +++ b/native/cocos/bindings/jswrapper/v8/Class.cpp @@ -25,20 +25,23 @@ ****************************************************************************/ #include "Class.h" +#include +#include "Value.h" +#include "base/Macros.h" #if SCRIPT_ENGINE_TYPE == SCRIPT_ENGINE_V8 #include "Object.h" - #include "Utils.h" #include "ScriptEngine.h" + #include "Utils.h" namespace se { // ------------------------------------------------------- Object namespace { // std::unordered_map __clsMap; -v8::Isolate *__isolate = nullptr; -std::vector __allClasses; +v8::Isolate * __isolate = nullptr; // NOLINT +std::vector __allClasses; // NOLINT } // namespace Class::Class() @@ -51,12 +54,11 @@ Class::Class() __allClasses.push_back(this); } -Class::~Class() { -} +Class::~Class() = default; /* static */ Class *Class::create(const std::string &clsName, se::Object *parent, Object *parentProto, v8::FunctionCallback ctor) { - Class *cls = new Class(); + auto *cls = new Class(); if (cls != nullptr && !cls->init(clsName, parent, parentProto, ctor)) { delete cls; cls = nullptr; @@ -64,26 +66,41 @@ Class *Class::create(const std::string &clsName, se::Object *parent, Object *par return cls; } +Class *Class::create(const std::initializer_list &classPath, se::Object *parent, Object *parentProto, v8::FunctionCallback ctor) { + se::AutoHandleScope scope; + se::Object * currentParent = parent; + se::Value tmp; + for (auto i = 0; i < classPath.size() - 1; i++) { + bool ok = currentParent->getProperty(*(classPath.begin() + i), &tmp); + CCASSERT(ok, "class or namespace in path is not defined"); + currentParent = tmp.toObject(); + } + return create(*(classPath.end() - 1), currentParent, parentProto, ctor); +} + bool Class::init(const std::string &clsName, Object *parent, Object *parentProto, v8::FunctionCallback ctor) { _name = clsName; _parent = parent; - if (_parent != nullptr) + if (_parent != nullptr) { _parent->incRef(); + } _parentProto = parentProto; - if (_parentProto != nullptr) + if (_parentProto != nullptr) { _parentProto->incRef(); + } _ctor = ctor; _ctorTemplate.Reset(__isolate, v8::FunctionTemplate::New(__isolate, _ctor)); v8::MaybeLocal jsNameVal = v8::String::NewFromUtf8(__isolate, _name.c_str(), v8::NewStringType::kNormal); - if (jsNameVal.IsEmpty()) + if (jsNameVal.IsEmpty()) { return false; + } _ctorTemplate.Get(__isolate)->SetClassName(jsNameVal.ToLocalChecked()); - _ctorTemplate.Get(__isolate)->InstanceTemplate()->SetInternalFieldCount(1); + _ctorTemplate.Get(__isolate)->InstanceTemplate()->SetInternalFieldCount(2); return true; } @@ -121,27 +138,32 @@ bool Class::install() { _ctorTemplate.Get(__isolate)->Inherit(_parentProto->_getClass()->_ctorTemplate.Get(__isolate)); } - v8::Local context = __isolate->GetCurrentContext(); - v8::MaybeLocal ctor = _ctorTemplate.Get(__isolate)->GetFunction(context); - if (ctor.IsEmpty()) + v8::Local context = __isolate->GetCurrentContext(); + v8::MaybeLocal ctor = _ctorTemplate.Get(__isolate)->GetFunction(context); + if (ctor.IsEmpty()) { return false; + } - v8::Local ctorChecked = ctor.ToLocalChecked(); - v8::MaybeLocal name = v8::String::NewFromUtf8(__isolate, _name.c_str(), v8::NewStringType::kNormal); - if (name.IsEmpty()) + v8::Local ctorChecked = ctor.ToLocalChecked(); + v8::MaybeLocal name = v8::String::NewFromUtf8(__isolate, _name.c_str(), v8::NewStringType::kNormal); + if (name.IsEmpty()) { return false; + } v8::Maybe result = _parent->_getJSObject()->Set(context, name.ToLocalChecked(), ctorChecked); - if (result.IsNothing()) + if (result.IsNothing()) { return false; + } v8::MaybeLocal prototypeName = v8::String::NewFromUtf8(__isolate, "prototype", v8::NewStringType::kNormal); - if (prototypeName.IsEmpty()) + if (prototypeName.IsEmpty()) { return false; + } v8::MaybeLocal prototypeObj = ctorChecked->Get(context, prototypeName.ToLocalChecked()); - if (prototypeObj.IsEmpty()) + if (prototypeObj.IsEmpty()) { return false; + } if (_createProto) { // Proto object is released in Class::destroy. @@ -153,32 +175,44 @@ bool Class::install() { bool Class::defineFunction(const char *name, v8::FunctionCallback func) { v8::MaybeLocal jsName = v8::String::NewFromUtf8(__isolate, name, v8::NewStringType::kNormal); - if (jsName.IsEmpty()) + if (jsName.IsEmpty()) { return false; + } _ctorTemplate.Get(__isolate)->PrototypeTemplate()->Set(jsName.ToLocalChecked(), v8::FunctionTemplate::New(__isolate, func)); return true; } bool Class::defineProperty(const char *name, v8::AccessorNameGetterCallback getter, v8::AccessorNameSetterCallback setter) { v8::MaybeLocal jsName = v8::String::NewFromUtf8(__isolate, name, v8::NewStringType::kNormal); - if (jsName.IsEmpty()) + if (jsName.IsEmpty()) { return false; + } _ctorTemplate.Get(__isolate)->PrototypeTemplate()->SetAccessor(jsName.ToLocalChecked(), getter, setter); return true; } +bool Class::defineProperty(const std::initializer_list &names, v8::AccessorNameGetterCallback getter, v8::AccessorNameSetterCallback setter) { + bool ret = true; + for (auto name : names) { + ret &= defineProperty(name, getter, setter); + } + return ret; +} + bool Class::defineStaticFunction(const char *name, v8::FunctionCallback func) { v8::MaybeLocal jsName = v8::String::NewFromUtf8(__isolate, name, v8::NewStringType::kNormal); - if (jsName.IsEmpty()) + if (jsName.IsEmpty()) { return false; + } _ctorTemplate.Get(__isolate)->Set(jsName.ToLocalChecked(), v8::FunctionTemplate::New(__isolate, func)); return true; } bool Class::defineStaticProperty(const char *name, v8::AccessorNameGetterCallback getter, v8::AccessorNameSetterCallback setter) { v8::MaybeLocal jsName = v8::String::NewFromUtf8(__isolate, name, v8::NewStringType::kNormal); - if (jsName.IsEmpty()) + if (jsName.IsEmpty()) { return false; + } _ctorTemplate.Get(__isolate)->SetNativeDataProperty(jsName.ToLocalChecked(), getter, setter); return true; } @@ -202,7 +236,7 @@ bool Class::defineFinalizeFunction(V8FinalizeFunc finalizeFunc) { // return _createJSObjectWithClass(iter->second); // } -v8::Local Class::_createJSObjectWithClass(Class *cls) { +v8::Local Class::_createJSObjectWithClass(Class *cls) { //NOLINT v8::MaybeLocal ret = cls->_ctorTemplate.Get(__isolate)->InstanceTemplate()->NewInstance(__isolate->GetCurrentContext()); assert(!ret.IsEmpty()); return ret.ToLocalChecked(); @@ -212,7 +246,7 @@ Object *Class::getProto() const { return _proto; } -V8FinalizeFunc Class::_getFinalizeFunction() const { +V8FinalizeFunc Class::_getFinalizeFunction() const { //NOLINT return _finalizeFunc; } diff --git a/native/cocos/bindings/jswrapper/v8/Class.h b/native/cocos/bindings/jswrapper/v8/Class.h index c703463781..699b308ba1 100644 --- a/native/cocos/bindings/jswrapper/v8/Class.h +++ b/native/cocos/bindings/jswrapper/v8/Class.h @@ -30,6 +30,7 @@ #if SCRIPT_ENGINE_TYPE == SCRIPT_ENGINE_V8 + #include #include "Base.h" namespace se { @@ -52,6 +53,8 @@ public: */ static Class *create(const std::string &className, Object *obj, Object *parentProto, v8::FunctionCallback ctor); + static Class *create(const std::initializer_list &classPath, Object *obj, Object *parentProto, v8::FunctionCallback ctor); + /** * @brief Defines a member function with a callback. Each objects created by class will have this function property. * @param[in] name A null-terminated UTF8 string containing the function name. @@ -69,6 +72,8 @@ public: */ bool defineProperty(const char *name, v8::AccessorNameGetterCallback getter, v8::AccessorNameSetterCallback setter); + bool defineProperty(const std::initializer_list &names, v8::AccessorNameGetterCallback getter, v8::AccessorNameSetterCallback setter); + /** * @brief Defines a static function with a callback. Only JavaScript constructor object will have this function. * @param[in] name A null-terminated UTF8 string containing the function name. @@ -128,17 +133,17 @@ private: static void cleanup(); // static v8::Local _createJSObject(const std::string &clsName, Class** outCls); static v8::Local _createJSObjectWithClass(Class *cls); - static void setIsolate(v8::Isolate *isolate); + static void setIsolate(v8::Isolate *isolate); std::string _name; - Object *_parent; - Object *_parentProto; - Object *_proto; + Object * _parent; + Object * _parentProto; + Object * _proto; - v8::FunctionCallback _ctor; + v8::FunctionCallback _ctor; v8::UniquePersistent _ctorTemplate; - V8FinalizeFunc _finalizeFunc; - bool _createProto; + V8FinalizeFunc _finalizeFunc; + bool _createProto; friend class ScriptEngine; friend class Object; diff --git a/native/cocos/bindings/jswrapper/v8/HelperMacros.h b/native/cocos/bindings/jswrapper/v8/HelperMacros.h index df047ae248..66f66e9ef9 100644 --- a/native/cocos/bindings/jswrapper/v8/HelperMacros.h +++ b/native/cocos/bindings/jswrapper/v8/HelperMacros.h @@ -31,9 +31,10 @@ #include #include #include -#include #include #include +#include +#include "../ValueArrayPool.h" #include "../config.h" #include "base/Log.h" @@ -105,32 +106,39 @@ void printJSBInvokeAtFrame(int n); #define SE_DECLARE_FUNC(funcName) \ void funcName##Registry(const v8::FunctionCallbackInfo &v8args) - #define SE_BIND_FUNC(funcName) \ - void funcName##Registry(const v8::FunctionCallbackInfo &_v8args) { \ - JsbInvokeScope(#funcName); \ - bool ret = false; \ - v8::Isolate * _isolate = _v8args.GetIsolate(); \ - v8::HandleScope _hs(_isolate); \ - se::ValueArray args; \ - args.reserve(10); \ - se::internal::jsToSeArgs(_v8args, &args); \ - void * nativeThisObject = se::internal::getPrivate(_isolate, _v8args.This()); \ - se::State state(nativeThisObject, args); \ - ret = funcName(state); \ - if (!ret) { \ - SE_LOGE("[ERROR] Failed to invoke %s, location: %s:%d\n", #funcName, __FILE__, __LINE__); \ - } \ - se::internal::setReturnValue(state.rval(), _v8args); \ + #define SE_BIND_FUNC(funcName) \ + void funcName##Registry(const v8::FunctionCallbackInfo &_v8args) { \ + JsbInvokeScope(#funcName); \ + bool ret = false; \ + v8::Isolate * _isolate = _v8args.GetIsolate(); \ + v8::HandleScope _hs(_isolate); \ + se::ValueArray & args = se::gValueArrayPool.get(_v8args.Length()); \ + se::CallbackDepthGuard depthGuard{args, se::gValueArrayPool._depth}; \ + se::internal::jsToSeArgs(_v8args, args); \ + se::PrivateObjectBase *privateObject = static_cast(se::internal::getPrivate(_isolate, _v8args.This(), 0)); \ + se::Object * thisObject = reinterpret_cast(se::internal::getPrivate(_isolate, _v8args.This(), 1)); \ + se::State state(thisObject, privateObject, args); \ + ret = funcName(state); \ + if (!ret) { \ + SE_LOGE("[ERROR] Failed to invoke %s, location: %s:%d\n", #funcName, __FILE__, __LINE__); \ + } \ + se::internal::setReturnValue(state.rval(), _v8args); \ + } + + #define SE_BIND_FUNC_FAST(funcName) \ + void funcName##Registry(const v8::FunctionCallbackInfo &_v8args) { \ + auto *privateObject = static_cast(_v8args.This()->GetAlignedPointerFromInternalField(0)); \ + funcName(privateObject->getRaw()); \ } #define SE_BIND_FINALIZE_FUNC(funcName) \ - void funcName##Registry(void *nativeThisObject) { \ + void funcName##Registry(se::PrivateObjectBase *privateObject) { \ JsbInvokeScope(#funcName); \ - if (nativeThisObject == nullptr) \ + if (privateObject == nullptr) \ return; \ auto se = se::ScriptEngine::getInstance(); \ se->_setGarbageCollecting(true); \ - se::State state(nativeThisObject); \ + se::State state(privateObject); \ bool ret = funcName(state); \ if (!ret) { \ SE_LOGE("[ERROR] Failed to invoke %s, location: %s:%d\n", #funcName, __FILE__, __LINE__); \ @@ -139,18 +147,18 @@ void printJSBInvokeAtFrame(int n); } #define SE_DECLARE_FINALIZE_FUNC(funcName) \ - void funcName##Registry(void *nativeThisObject); + void funcName##Registry(se::PrivateObjectBase *nativeThisObject); // v8 doesn't need to create a new JSObject in SE_BIND_CTOR while SpiderMonkey needs. #define SE_BIND_CTOR(funcName, cls, finalizeCb) \ void funcName##Registry(const v8::FunctionCallbackInfo &_v8args) { \ JsbInvokeScope(#funcName); \ - v8::Isolate * _isolate = _v8args.GetIsolate(); \ - v8::HandleScope _hs(_isolate); \ - bool ret = true; \ - se::ValueArray args; \ - args.reserve(10); \ - se::internal::jsToSeArgs(_v8args, &args); \ + v8::Isolate * _isolate = _v8args.GetIsolate(); \ + v8::HandleScope _hs(_isolate); \ + bool ret = true; \ + se::ValueArray & args = se::gValueArrayPool.get(_v8args.Length()); \ + se::CallbackDepthGuard depthGuard{args, se::gValueArrayPool._depth}; \ + se::internal::jsToSeArgs(_v8args, args); \ se::Object *thisObject = se::Object::_createJSObject(cls, _v8args.This()); \ thisObject->_setFinalizeCallback(_SE(finalizeCb)); \ se::State state(thisObject, args); \ @@ -166,40 +174,47 @@ void printJSBInvokeAtFrame(int n); #define SE_BIND_SUB_CLS_CTOR SE_BIND_CTOR - #define SE_BIND_PROP_GET(funcName) \ - void funcName##Registry(v8::Local /*_property*/, const v8::PropertyCallbackInfo &_v8args) { \ - JsbInvokeScope(#funcName); \ - v8::Isolate * _isolate = _v8args.GetIsolate(); \ - v8::HandleScope _hs(_isolate); \ - bool ret = true; \ - void * nativeThisObject = se::internal::getPrivate(_isolate, _v8args.This()); \ - se::State state(nativeThisObject); \ - ret = funcName(state); \ - if (!ret) { \ - SE_LOGE("[ERROR] Failed to invoke %s, location: %s:%d\n", #funcName, __FILE__, __LINE__); \ - } \ - se::internal::setReturnValue(state.rval(), _v8args); \ + #define SE_BIND_PROP_GET_IMPL(funcName, postFix) \ + void funcName##postFix##Registry(v8::Local /*_property*/, const v8::PropertyCallbackInfo &_v8args) { \ + JsbInvokeScope(#funcName); \ + v8::Isolate * _isolate = _v8args.GetIsolate(); \ + v8::HandleScope _hs(_isolate); \ + bool ret = true; \ + se::PrivateObjectBase *privateObject = static_cast(se::internal::getPrivate(_isolate, _v8args.This(), 0)); \ + se::Object * thisObject = reinterpret_cast(se::internal::getPrivate(_isolate, _v8args.This(), 1)); \ + se::State state(thisObject, privateObject); \ + ret = funcName(state); \ + if (!ret) { \ + SE_LOGE("[ERROR] Failed to invoke %s, location: %s:%d\n", #funcName, __FILE__, __LINE__); \ + } \ + se::internal::setReturnValue(state.rval(), _v8args); \ } - #define SE_BIND_PROP_SET(funcName) \ - void funcName##Registry(v8::Local /*_property*/, v8::Local _value, const v8::PropertyCallbackInfo &_v8args) { \ - JsbInvokeScope(#funcName); \ - v8::Isolate * _isolate = _v8args.GetIsolate(); \ - v8::HandleScope _hs(_isolate); \ - bool ret = true; \ - void * nativeThisObject = se::internal::getPrivate(_isolate, _v8args.This()); \ - se::Value data; \ - se::internal::jsToSeValue(_isolate, _value, &data); \ - se::ValueArray args; \ - args.reserve(10); \ - args.push_back(std::move(data)); \ - se::State state(nativeThisObject, args); \ - ret = funcName(state); \ - if (!ret) { \ - SE_LOGE("[ERROR] Failed to invoke %s, location: %s:%d\n", #funcName, __FILE__, __LINE__); \ - } \ + #define SE_BIND_PROP_GET(funcName) SE_BIND_PROP_GET_IMPL(funcName, ) + #define SE_BIND_FUNC_AS_PROP_GET(funcName) SE_BIND_PROP_GET_IMPL(funcName, _asGetter) + + #define SE_BIND_PROP_SET_IMPL(funcName, postFix) \ + void funcName##postFix##Registry(v8::Local /*_property*/, v8::Local _value, const v8::PropertyCallbackInfo &_v8args) { \ + JsbInvokeScope(#funcName); \ + v8::Isolate * _isolate = _v8args.GetIsolate(); \ + v8::HandleScope _hs(_isolate); \ + bool ret = true; \ + se::PrivateObjectBase *privateObject = static_cast(se::internal::getPrivate(_isolate, _v8args.This(), 0)); \ + se::Object * thisObject = reinterpret_cast(se::internal::getPrivate(_isolate, _v8args.This(), 1)); \ + se::ValueArray & args = se::gValueArrayPool.get(1); \ + se::CallbackDepthGuard depthGuard{args, se::gValueArrayPool._depth}; \ + se::Value & data{args[0]}; \ + se::internal::jsToSeValue(_isolate, _value, &data); \ + se::State state(thisObject, privateObject, args); \ + ret = funcName(state); \ + if (!ret) { \ + SE_LOGE("[ERROR] Failed to invoke %s, location: %s:%d\n", #funcName, __FILE__, __LINE__); \ + } \ } + #define SE_BIND_PROP_SET(funcName) SE_BIND_PROP_SET_IMPL(funcName, ) + #define SE_BIND_FUNC_AS_PROP_SET(funcName) SE_BIND_PROP_SET_IMPL(funcName, _asSetter) + #define SE_TYPE_NAME(t) typeid(t).name() #define SE_QUOTEME_(x) #x // NOLINT(readability-identifier-naming) diff --git a/native/cocos/bindings/jswrapper/v8/Object.cpp b/native/cocos/bindings/jswrapper/v8/Object.cpp index 072981c307..085a9e21cc 100644 --- a/native/cocos/bindings/jswrapper/v8/Object.cpp +++ b/native/cocos/bindings/jswrapper/v8/Object.cpp @@ -32,9 +32,13 @@ #include "ScriptEngine.h" #include "Utils.h" + #include #include + #include #include + #define JSB_FUNC_DEFAULT_MAX_ARG_COUNT (10) + namespace se { //NOLINTNEXTLINE std::unique_ptr> __objectMap; // Currently, the value `void*` is always nullptr @@ -49,9 +53,12 @@ uint32_t nativeObjectId = 0; Object::Object() : _cls(nullptr), _rootCount(0), - _privateData(nullptr), + _privateObject(nullptr), _finalizeCb(nullptr), _internalData(nullptr) { + #if JSB_TRACK_OBJECT_CREATION + _objectCreationStackFrame = se::ScriptEngine::getInstance()->getCurrentStackTrace(); + #endif } Object::~Object() { @@ -62,23 +69,24 @@ Object::~Object() { if (__objectMap) { __objectMap->erase(this); } + delete _privateObject; + _privateObject = nullptr; } -/*static*/ -void Object::nativeObjectFinalizeHook(void *nativeObj) { - if (nativeObj == nullptr) { +void Object::nativeObjectFinalizeHook(PrivateObjectBase *privateObj) { + if (privateObj == nullptr) { return; } - - auto iter = NativePtrToObjectMap::find(nativeObj); + void *nativeObj = privateObj->getRaw(); + auto iter = NativePtrToObjectMap::find(nativeObj); if (iter != NativePtrToObjectMap::end()) { Object *obj = iter->second; if (obj->_finalizeCb != nullptr) { - obj->_finalizeCb(nativeObj); + obj->_finalizeCb(privateObj); } else { assert(obj->_getClass() != nullptr); if (obj->_getClass()->_finalizeFunc != nullptr) { - obj->_getClass()->_finalizeFunc(nativeObj); + obj->_getClass()->_finalizeFunc(privateObj); } } obj->decRef(); @@ -97,7 +105,6 @@ void Object::setup() { __objectMap = std::make_unique>(); } -/* static */ void Object::cleanup() { void * nativeObj = nullptr; Object *obj = nullptr; @@ -105,15 +112,15 @@ void Object::cleanup() { const auto &nativePtrToObjectMap = NativePtrToObjectMap::instance(); for (const auto &e : nativePtrToObjectMap) { - nativeObj = e.first; - obj = e.second; - + nativeObj = e.first; + obj = e.second; + PrivateObjectBase *privateObject = obj->getPrivateObject(); if (obj->_finalizeCb != nullptr) { - obj->_finalizeCb(nativeObj); + obj->_finalizeCb(privateObject); } else { if (obj->_getClass() != nullptr) { if (obj->_getClass()->_finalizeFunc != nullptr) { - obj->_getClass()->_finalizeFunc(nativeObj); + obj->_getClass()->_finalizeFunc(privateObject); } } } @@ -126,7 +133,6 @@ void Object::cleanup() { } NativePtrToObjectMap::clear(); - NonRefNativePtrCreatedByCtorMap::clear(); if (__objectMap) { std::vector toReleaseObjects; @@ -186,7 +192,7 @@ Object *Object::createArrayObject(size_t length) { return obj; } -Object *Object::createArrayBufferObject(void *data, size_t byteLength) { +Object *Object::createArrayBufferObject(const void *data, size_t byteLength) { v8::Local jsobj = v8::ArrayBuffer::New(__isolate, byteLength); if (data) { memcpy(jsobj->GetBackingStore()->Data(), data, byteLength); @@ -251,6 +257,64 @@ Object *Object::createTypedArray(TypedArrayType type, const void *data, size_t b return obj; } +Object *Object::createTypedArrayWithBuffer(TypedArrayType type, const Object *obj) { + return Object::createTypedArrayWithBuffer(type, obj, 0); +} + +Object *Object::createTypedArrayWithBuffer(TypedArrayType type, const Object *obj, size_t offet) { + size_t byteLength{0}; + uint8_t *skip{nullptr}; + obj->getTypedArrayData(&skip, &byteLength); + return Object::createTypedArrayWithBuffer(type, obj, 0, byteLength); +} + +Object *Object::createTypedArrayWithBuffer(TypedArrayType type, const Object *obj, size_t offet, size_t byteLength) { + if (type == TypedArrayType::NONE) { + SE_LOGE("Don't pass se::Object::TypedArrayType::NONE to createTypedArray API!"); + return nullptr; + } + + if (type == TypedArrayType::UINT8_CLAMPED) { + SE_LOGE("Doesn't support to create Uint8ClampedArray with Object::createTypedArray API!"); + return nullptr; + } + + v8::Local typedArray; + assert(obj->isArrayBuffer()); + v8::Local jsobj = obj->_getJSObject().As(); + switch (type) { + case TypedArrayType::INT8: + typedArray = v8::Int8Array::New(jsobj, offet, byteLength); + break; + case TypedArrayType::INT16: + typedArray = v8::Int16Array::New(jsobj, offet, byteLength / 2); + break; + case TypedArrayType::INT32: + typedArray = v8::Int32Array::New(jsobj, offet, byteLength / 4); + break; + case TypedArrayType::UINT8: + typedArray = v8::Uint8Array::New(jsobj, offet, byteLength); + break; + case TypedArrayType::UINT16: + typedArray = v8::Uint16Array::New(jsobj, offet, byteLength / 2); + break; + case TypedArrayType::UINT32: + typedArray = v8::Uint32Array::New(jsobj, offet, byteLength / 4); + break; + case TypedArrayType::FLOAT32: + typedArray = v8::Float32Array::New(jsobj, offet, byteLength / 4); + break; + case TypedArrayType::FLOAT64: + typedArray = v8::Float64Array::New(jsobj, offet, byteLength / 8); + break; + default: + assert(false); // Should never go here. + break; + } + + return Object::_createJSObject(nullptr, typedArray); +} + Object *Object::createUint8TypedArray(uint8_t *bytes, size_t byteLength) { return createTypedArray(TypedArrayType::UINT8, bytes, byteLength); } @@ -282,15 +346,15 @@ bool Object::init(Class *cls, v8::Local obj) { } #if CC_DEBUG && CC_DEBUG_JS_OBJECT_ID - this->_objectId = ++nativeObjectId; - this->setProperty("__object_id__", se::Value(this->_objectId)); - this->setProperty("__native_class_name__", se::Value(cls ? cls->getName() : "[noname]")); + // this->_objectId = ++nativeObjectId; + // defineOwnProperty("__object_id__", se::Value(this->_objectId), false, false, false); + // defineOwnProperty("__native_class_name__", se::Value(cls ? cls->getName() : "[noname]"), false, false, false); #endif return true; } -bool Object::getProperty(const char *name, Value *data) { +bool Object::getProperty(const char *name, Value *data, bool cachePropertyName) { assert(data != nullptr); data->setUndefined(); @@ -300,14 +364,22 @@ bool Object::getProperty(const char *name, Value *data) { return false; } - v8::MaybeLocal nameValue = v8::String::NewFromUtf8(__isolate, name, v8::NewStringType::kNormal); + v8::MaybeLocal nameValue; + + if (cachePropertyName) { + nameValue = ScriptEngine::getInstance()->_getStringPool().get(__isolate, name); + } else { + nameValue = v8::String::NewFromUtf8(__isolate, name, v8::NewStringType::kNormal); + } + if (nameValue.IsEmpty()) { return false; } v8::Local nameValToLocal = nameValue.ToLocalChecked(); v8::Local context = __isolate->GetCurrentContext(); - v8::Maybe maybeExist = _obj.handle(__isolate)->Has(context, nameValToLocal); + v8::Local localObj = _obj.handle(__isolate); + v8::Maybe maybeExist = localObj->Has(context, nameValToLocal); if (maybeExist.IsNothing()) { return false; } @@ -316,7 +388,7 @@ bool Object::getProperty(const char *name, Value *data) { return false; } - v8::MaybeLocal result = _obj.handle(__isolate)->Get(context, nameValToLocal); + v8::MaybeLocal result = localObj->Get(context, nameValToLocal); if (result.IsEmpty()) { return false; } @@ -353,7 +425,7 @@ bool Object::deleteProperty(const char *name) { } bool Object::setProperty(const char *name, const Value &data) { - v8::MaybeLocal nameValue = v8::String::NewFromUtf8(__isolate, name, v8::NewStringType::kNormal); + v8::MaybeLocal nameValue = ScriptEngine::getInstance()->_getStringPool().get(__isolate, name); if (nameValue.IsEmpty()) { return false; } @@ -380,6 +452,32 @@ bool Object::defineProperty(const char *name, v8::AccessorNameGetterCallback get return ret.IsJust() && ret.FromJust(); } +bool Object::defineOwnProperty(const char *name, const se::Value &value, bool writable, bool enumerable, bool configurable) { + v8::MaybeLocal nameValue = v8::String::NewFromUtf8(__isolate, name, v8::NewStringType::kNormal); + if (nameValue.IsEmpty()) { + return false; + } + + int flag{v8::PropertyAttribute::None}; + if (!writable) { + flag |= v8::PropertyAttribute::ReadOnly; + } + if (!enumerable) { + flag |= v8::PropertyAttribute::DontEnum; + } + if (!configurable) { + flag |= v8::PropertyAttribute::DontDelete; + } + + v8::Local v8Value; + internal::seToJsValue(__isolate, value, &v8Value); + + v8::Local nameValChecked = nameValue.ToLocalChecked(); + v8::Local jsName = v8::Local::Cast(nameValChecked); + v8::Maybe ret = _obj.handle(__isolate)->DefineOwnProperty(__isolate->GetCurrentContext(), jsName, v8Value, static_cast(flag)); + return ret.IsJust() && ret.FromJust(); +} + bool Object::isFunction() const { return const_cast(this)->_obj.handle(__isolate)->IsCallable(); } @@ -454,30 +552,42 @@ bool Object::getArrayBufferData(uint8_t **ptr, size_t *length) const { return true; } -void Object::setPrivateData(void *data) { - assert(_privateData == nullptr); - assert(NativePtrToObjectMap::find(data) == NativePtrToObjectMap::end()); - internal::setPrivate(__isolate, _obj, data, &_internalData); - NativePtrToObjectMap::emplace(data, this); - _privateData = data; - setProperty("__native_ptr__", se::Value(static_cast(reinterpret_cast(data)))); +void Object::setPrivateObject(PrivateObjectBase *data) { + assert(_privateObject == nullptr); + #if CC_DEBUG + //assert(NativePtrToObjectMap::find(data->getRaw()) == NativePtrToObjectMap::end()); + auto it = NativePtrToObjectMap::find(data->getRaw()); + if (it != NativePtrToObjectMap::end()) { + auto *pri = it->second->getPrivateObject(); + SE_LOGE("Already exists object %s/[%s], trying to add %s/[%s]\n", pri->getName(), typeid(*pri).name(), data->getName(), typeid(*data).name()); + #if JSB_TRACK_OBJECT_CREATION + SE_LOGE(" previous object created at %s\n", it->second->_objectCreationStackFrame.c_str()); + #endif + assert(false); + } + #endif + internal::setPrivate(__isolate, _obj, data, this, &_internalData); + NativePtrToObjectMap::emplace(data->getRaw(), this); + _privateObject = data; + defineOwnProperty("__native_ptr__", se::Value(static_cast(reinterpret_cast(data->getRaw()))), false, false, false); } -void *Object::getPrivateData() const { - if (_privateData == nullptr) { - const_cast(this)->_privateData = internal::getPrivate(__isolate, const_cast(this)->_obj.handle(__isolate)); +PrivateObjectBase *Object::getPrivateObject() const { + if (_privateObject == nullptr) { + const_cast(this)->_privateObject = static_cast(internal::getPrivate(__isolate, const_cast(this)->_obj.handle(__isolate))); } - return _privateData; + return _privateObject; } void Object::clearPrivateData(bool clearMapping) { - if (_privateData != nullptr) { + if (_privateObject != nullptr) { if (clearMapping) { - NativePtrToObjectMap::erase(_privateData); + NativePtrToObjectMap::erase(_privateObject->getRaw()); } internal::clearPrivate(__isolate, _obj); - setProperty("__native_ptr__", se::Value(static_cast(reinterpret_cast(nullptr)))); - _privateData = nullptr; + defineOwnProperty("__native_ptr__", se::Value(static_cast(reinterpret_cast(nullptr))), false, false, false); + delete _privateObject; + _privateObject = nullptr; } } @@ -494,11 +604,19 @@ bool Object::call(const ValueArray &args, Object *thisObject, Value *rval /* = n SE_LOGD("Function object is released!\n"); return false; } - size_t argc = 0; - std::vector> argv; - argv.reserve(10); - argc = args.size(); - internal::seToJsArgs(__isolate, args, &argv); + size_t argc = args.size(); + + std::array, JSB_FUNC_DEFAULT_MAX_ARG_COUNT> argv; + std::unique_ptr>> vecArgs; + v8::Local * pArgv = argv.data(); + + if (argc > JSB_FUNC_DEFAULT_MAX_ARG_COUNT) { + vecArgs = std::make_unique>>(); + vecArgs->resize(argc); + pArgv = vecArgs->data(); + } + + internal::seToJsArgs(__isolate, args, pArgv); v8::Local thiz = v8::Local::Cast(v8::Undefined(__isolate)); if (thisObject != nullptr) { @@ -510,14 +628,24 @@ bool Object::call(const ValueArray &args, Object *thisObject, Value *rval /* = n } for (size_t i = 0; i < argc; ++i) { - if (argv[i].IsEmpty()) { + if (pArgv[i].IsEmpty()) { SE_LOGD("%s argv[%d] is released!\n", __FUNCTION__, (int)i); return false; } } - v8::Local context = se::ScriptEngine::getInstance()->_getContext(); - v8::MaybeLocal result = _obj.handle(__isolate)->CallAsFunction(context, thiz, static_cast(argc), argv.data()); + v8::Local context = se::ScriptEngine::getInstance()->_getContext(); + #if CC_DEBUG + v8::TryCatch tryCatch(__isolate); + #endif + v8::MaybeLocal result = _obj.handle(__isolate)->CallAsFunction(context, thiz, static_cast(argc), pArgv); + + #if CC_DEBUG + if (tryCatch.HasCaught()) { + v8::String::Utf8Value stack(__isolate, tryCatch.StackTrace(__isolate->GetCurrentContext()).ToLocalChecked()); + SE_REPORT_ERROR("Invoking function failed, %s", *stack); + } + #endif if (!result.IsEmpty()) { if (rval != nullptr) { @@ -561,7 +689,7 @@ bool Object::getArrayLength(uint32_t *length) const { assert(length != nullptr); auto *thiz = const_cast(this); - v8::MaybeLocal lengthStr = v8::String::NewFromUtf8(__isolate, "length", v8::NewStringType::kNormal); + v8::MaybeLocal lengthStr = ScriptEngine::getInstance()->_getStringPool().get(__isolate, "length"); if (lengthStr.IsEmpty()) { *length = 0; return false; @@ -735,6 +863,23 @@ std::string Object::toString() const { return ret; } +std::string Object::toStringExt() const { + if (isFunction()) return "[function]"; + if (isArray()) return "[array]"; + if (isArrayBuffer()) return "[arraybuffer]"; + if (isTypedArray()) return "[typedarray]"; + + std::vector keys; + getAllKeys(&keys); + std::stringstream ss; + ss << "{"; + for (auto &k : keys) { + ss << k << ", "; + } + ss << "}"; + return ss.str(); +} + } // namespace se #endif // #if SCRIPT_ENGINE_TYPE == SCRIPT_ENGINE_V8 diff --git a/native/cocos/bindings/jswrapper/v8/Object.h b/native/cocos/bindings/jswrapper/v8/Object.h index ec2a3b5b1e..ad3af949c7 100644 --- a/native/cocos/bindings/jswrapper/v8/Object.h +++ b/native/cocos/bindings/jswrapper/v8/Object.h @@ -43,6 +43,8 @@ #define CC_DEBUG_JS_OBJECT_ID 0 #endif + #define JSB_TRACK_OBJECT_CREATION 0 + namespace se { class Class; @@ -106,6 +108,20 @@ public: */ static Object *createTypedArray(TypedArrayType type, const void *data, size_t byteLength); + /** + * @brief Creates a JavaScript Typed Array Object with a se::Object, which is a ArrayBuffer, + if provide a null pointer,then will create a empty JavaScript Typed Array Object. + * @param[in] type The format of typed array. + * @param[in] obj A ArrayBuffer to TypedArray. + * @param[in] offset Offset of ArrayBuffer to create with. + * @param[in] byteLength The number of bytes pointed to by the parameter bytes. + * @return A JavaScript Typed Array Object which refers to the ArrayBuffer Object, or nullptr if there is an error. + * @note The return value (non-null) has to be released manually. + */ + static Object *createTypedArrayWithBuffer(TypedArrayType type, const Object *obj); + static Object *createTypedArrayWithBuffer(TypedArrayType type, const Object *obj, size_t offet); + static Object *createTypedArrayWithBuffer(TypedArrayType type, const Object *obj, size_t offet, size_t byteLength); + /** * @brief Creates a JavaScript Array Buffer object from an existing pointer. * @param[in] bytes A pointer to the byte buffer to be used as the backing store of the Typed Array object. @@ -113,7 +129,7 @@ public: * @return A Array Buffer Object whose backing store is the same as the one pointed to data, or nullptr if there is an error. * @note The return value (non-null) has to be released manually. */ - static Object *createArrayBufferObject(void *data, size_t byteLength); + static Object *createArrayBufferObject(const void *data, size_t byteLength); /** * @brief Creates a JavaScript Object from a JSON formatted string. @@ -145,7 +161,11 @@ public: * @param[out] value The property's value if object has the property, otherwise the undefined value. * @return true if object has the property, otherwise false. */ - bool getProperty(const char *name, Value *data); + inline bool getProperty(const char *name, Value *data) { + return getProperty(name, data, false); + } + + bool getProperty(const char *name, Value *data, bool cachePropertyName); inline bool getProperty(const std::string &name, Value *value) { return getProperty(name.c_str(), value); @@ -179,6 +199,8 @@ public: */ bool defineProperty(const char *name, v8::AccessorNameGetterCallback getter, v8::AccessorNameSetterCallback setter); + bool defineOwnProperty(const char *name, const se::Value &value, bool writable = true, bool enumerable = true, bool configurable = true); + /** * @brief Defines a function with a native callback for an object. * @param[in] funcName A utf-8 string containing the function name. @@ -271,24 +293,38 @@ public: */ bool getAllKeys(std::vector *allKeys) const; - /** - * @brief Sets a pointer to private data on an object. - * @param[in] data A void* to set as the object's private data. - * @note This method will associate private data with se::Object by std::unordered_map::emplace. - * It's used for search a se::Object via a void* private data. - */ - void setPrivateData(void *data); + void setPrivateObject(PrivateObjectBase *data); + PrivateObjectBase *getPrivateObject() const; /** - * @brief Gets an object's private data. - * @return A void* that is the object's private data, if the object has private data, otherwise nullptr. - */ - void *getPrivateData() const; + * @brief Gets an object's private data. + * @return A void* that is the object's private data, if the object has private data, otherwise nullptr. + */ + inline void *getPrivateData() const { + return _privateObject ? _privateObject->getRaw() : nullptr; + } /** - * @brief Clears private data of an object. - * @param clearMapping Whether to clear the mapping of native object & se::Object. - */ + * @brief Sets a pointer to private data on an object. + * @param[in] data A void* to set as the object's private data. + * @note This method will associate private data with se::Object by std::unordered_map::emplace. + * It's used for search a se::Object via a void* private data. + */ + template + inline void setPrivateData(T *data) { + static_assert(!std::is_void::value, "void * is not allowed for private data"); + setPrivateObject(se::make_shared_private_object(data)); + } + + template + inline T *getTypedPrivateData() const { + return reinterpret_cast(getPrivateData()); + } + + /** + * @brief Clears private data of an object. + * @param clearMapping Whether to clear the mapping of native object & se::Object. + */ void clearPrivateData(bool clearMapping = true); /** @@ -383,6 +419,8 @@ public: */ std::string toString() const; + std::string toStringExt() const; + // Private API used in wrapper static Object * _createJSObject(Class *cls, v8::Local obj); // NOLINT(readability-identifier-naming) v8::Local _getJSObject() const; // NOLINT(readability-identifier-naming) @@ -398,7 +436,7 @@ public: #endif private: - static void nativeObjectFinalizeHook(void *nativeObj); + static void nativeObjectFinalizeHook(PrivateObjectBase *privateObject); static void setIsolate(v8::Isolate *isolate); static void cleanup(); static void setup(); @@ -412,13 +450,16 @@ private: ObjectWrap _obj; uint32_t _rootCount; - void * _privateData; + PrivateObjectBase * _privateObject{nullptr}; V8FinalizeFunc _finalizeCb; internal::PrivateData *_internalData; #if CC_DEBUG && CC_DEBUG_JS_OBJECT_ID uint32_t _objectId = 0; #endif + #if JSB_TRACK_OBJECT_CREATION + std::string _objectCreationStackFrame; + #endif friend class ScriptEngine; }; // NOLINTNEXTLINE diff --git a/native/cocos/bindings/jswrapper/v8/ObjectWrap.cpp b/native/cocos/bindings/jswrapper/v8/ObjectWrap.cpp index 814e1f5f45..968bcdd90c 100644 --- a/native/cocos/bindings/jswrapper/v8/ObjectWrap.cpp +++ b/native/cocos/bindings/jswrapper/v8/ObjectWrap.cpp @@ -50,9 +50,9 @@ namespace se { ObjectWrap::ObjectWrap() { - refs_ = 0; - _nativeObj = nullptr; - _finalizeCb = nullptr; + refs_ = 0; + _privateObject = nullptr; + _finalizeCb = nullptr; } bool ObjectWrap::init(v8::Local handle) { @@ -75,10 +75,21 @@ ObjectWrap::~ObjectWrap() { } /*static*/ -void *ObjectWrap::unwrap(v8::Local handle) { +void *ObjectWrap::unwrap(v8::Local handle, uint32_t fieldIndex) { assert(!handle.IsEmpty()); - assert(handle->InternalFieldCount() > 0); - return handle->GetAlignedPointerFromInternalField(0); + assert(handle->InternalFieldCount() > 1); + assert(fieldIndex >= 0 && fieldIndex < 2); + return handle->GetAlignedPointerFromInternalField(fieldIndex); +} +void ObjectWrap::wrap(void *nativeObj, uint32_t fieldIndex) { + assert(handle()->InternalFieldCount() > 1); + assert(fieldIndex >= 0 && fieldIndex < 2); + + if (fieldIndex == 0) { + delete _privateObject; + _privateObject = reinterpret_cast(nativeObj); + } + handle()->SetAlignedPointerInInternalField(fieldIndex, nativeObj); } v8::Local ObjectWrap::handle() { @@ -93,12 +104,6 @@ v8::Persistent &ObjectWrap::persistent() { return handle_; } -void ObjectWrap::wrap(void *nativeObj) { - assert(handle()->InternalFieldCount() > 0); - _nativeObj = nativeObj; - handle()->SetAlignedPointerInInternalField(0, nativeObj); -} - void ObjectWrap::makeWeak() { persistent().SetWeak(this, weakCallback, v8::WeakCallbackType::kFinalizer); // persistent().MarkIndependent(); @@ -125,7 +130,7 @@ void ObjectWrap::weakCallback(const v8::WeakCallbackInfo &data) { assert(wrap->refs_ == 0); wrap->handle_.Reset(); if (wrap->_finalizeCb != nullptr) { - wrap->_finalizeCb(wrap->_nativeObj); // wrap will be destroyed in wrap->_finalizeCb, should not use any wrap object after this line. + wrap->_finalizeCb(wrap->_privateObject); } else { assert(false); } diff --git a/native/cocos/bindings/jswrapper/v8/ObjectWrap.h b/native/cocos/bindings/jswrapper/v8/ObjectWrap.h index eb814a974c..c89940a0c2 100644 --- a/native/cocos/bindings/jswrapper/v8/ObjectWrap.h +++ b/native/cocos/bindings/jswrapper/v8/ObjectWrap.h @@ -51,6 +51,7 @@ #if SCRIPT_ENGINE_TYPE == SCRIPT_ENGINE_V8 + #include "../PrivateObject.h" #include "Base.h" namespace se { @@ -63,13 +64,12 @@ public: bool init(v8::Local handle); void setFinalizeCallback(V8FinalizeFunc finalizeCb); - v8::Local handle(); - v8::Local handle(v8::Isolate *isolate); + v8::Local handle(); + v8::Local handle(v8::Isolate *isolate); v8::Persistent &persistent(); - void wrap(void *nativeObj); - static void *unwrap(v8::Local handle); - + void wrap(void *privateData, uint32_t fieldIndex); + static void *unwrap(v8::Local handle, uint32_t fieldIndex); /* Ref() marks the object as being attached to an event loop. * Refed objects will not be garbage collected, even if * all references are lost. @@ -89,12 +89,12 @@ public: private: static void weakCallback(const v8::WeakCallbackInfo &data); - void makeWeak(); + void makeWeak(); - int refs_; // ro + int refs_; // ro v8::Persistent handle_; - void *_nativeObj; - V8FinalizeFunc _finalizeCb; + PrivateObjectBase * _privateObject; + V8FinalizeFunc _finalizeCb; }; } // namespace se diff --git a/native/cocos/bindings/jswrapper/v8/ScriptEngine.cpp b/native/cocos/bindings/jswrapper/v8/ScriptEngine.cpp index dbf97e996b..7cddf0fe6a 100644 --- a/native/cocos/bindings/jswrapper/v8/ScriptEngine.cpp +++ b/native/cocos/bindings/jswrapper/v8/ScriptEngine.cpp @@ -30,9 +30,9 @@ #include "../MappingUtils.h" #include "../State.h" #include "Class.h" + #include "MissingSymbols.h" #include "Object.h" #include "Utils.h" - #include "MissingSymbols.h" #include "platform/FileUtils.h" #include @@ -44,7 +44,7 @@ #endif - #include + #include #define EXPOSE_GC "__jsb_gc__" @@ -339,8 +339,8 @@ void ScriptEngine::onPromiseRejectCallback(v8::PromiseRejectMessage msg) { // prepend error object to stack message v8::MaybeLocal maybeStr = value->ToString(isolate->GetCurrentContext()); v8::Local str = maybeStr.IsEmpty() ? v8::String::NewFromUtf8(isolate, "[empty string]").ToLocalChecked() : maybeStr.ToLocalChecked(); - v8::String::Utf8Value valueUtf8(isolate, str); - auto * strp = *valueUtf8; + v8::String::Utf8Value valueUtf8(isolate, str); + auto * strp = *valueUtf8; if (strp == nullptr) { ss << "value: null" << std::endl; auto tn = value->TypeOf(isolate); @@ -398,8 +398,8 @@ void ScriptEngine::onPromiseRejectCallback(v8::PromiseRejectMessage msg) { getInstance()->callExceptionCallback("", eventName, ss.str().c_str()); } -void ScriptEngine::privateDataFinalize(void *nativeObj) { - auto *p = static_cast(nativeObj); +void ScriptEngine::privateDataFinalize(PrivateObjectBase *privateData) { + auto *p = static_cast(privateData->getRaw()); Object::nativeObjectFinalizeHook(p->data); @@ -478,7 +478,6 @@ bool ScriptEngine::init() { _context.Get(_isolate)->Enter(); NativePtrToObjectMap::init(); - NonRefNativePtrCreatedByCtorMap::init(); Object::setup(); Class::setIsolate(_isolate); @@ -551,6 +550,8 @@ void ScriptEngine::cleanup() { } _beforeCleanupHookArray.clear(); + _stringPool.clear(); + SAFE_DEC_REF(_globalObj); Object::cleanup(); Class::cleanup(); @@ -601,7 +602,6 @@ void ScriptEngine::cleanup() { _isInCleanup = false; NativePtrToObjectMap::destroy(); - NonRefNativePtrCreatedByCtorMap::destroy(); _gcFunc = nullptr; SE_LOGD("ScriptEngine::cleanup end ...\n"); } @@ -742,12 +742,6 @@ bool ScriptEngine::evalString(const char *script, ssize_t length /* = -1 */, Val sourceUrl = sourceUrl.substr(prefixPos + PREFIX_KEY.length()); } - #if CC_PLATFORM == CC_PLATFORM_MAC_OSX - if (strncmp("(no filename)", sourceUrl.c_str(), sizeof("(no filename)")) != 0) { - sourceUrl = cc::FileUtils::getInstance()->fullPathForFilename(sourceUrl); - } - #endif - // It is needed, or will crash if invoked from non C++ context, such as invoked from objective-c context(for example, handler of UIKit). v8::HandleScope handleScope(_isolate); @@ -894,8 +888,7 @@ bool ScriptEngine::runByteCodeFile(const std::string &pathBc, Value *ret /* = nu // setup ScriptOrigin v8::Local scriptPath = v8::String::NewFromUtf8(_isolate, pathBc.data(), v8::NewStringType::kNormal).ToLocalChecked(); - - v8::ScriptOrigin origin(_isolate, scriptPath, 0, 0, true); + v8::ScriptOrigin origin(_isolate, scriptPath, 0, 0, true); // restore CacheData auto * v8CacheData = new v8::ScriptCompiler::CachedData(cachedData.getBytes(), static_cast(cachedData.getSize())); @@ -1015,6 +1008,104 @@ void ScriptEngine::mainLoopUpdate() { // empty implementation } +bool ScriptEngine::callFunction(Object *targetObj, const char *funcName, uint32_t argc, Value *args, Value *rval /* = nullptr*/) { + v8::HandleScope handleScope(_isolate); + + v8::MaybeLocal nameValue = _getStringPool().get(_isolate, funcName); + + if (nameValue.IsEmpty()) { + if (rval != nullptr) { + rval->setUndefined(); + } + return false; + } + + v8::Local nameValToLocal = nameValue.ToLocalChecked(); + v8::Local context = _isolate->GetCurrentContext(); + v8::Local localObj = targetObj->_obj.handle(_isolate); + + v8::MaybeLocal funcVal = localObj->Get(context, nameValToLocal); + if (funcVal.IsEmpty()) { + if (rval != nullptr) { + rval->setUndefined(); + } + return false; + } + + SE_ASSERT(argc < 11, "Only support argument count that less than 11"); + std::array, 10> argv; + + for (size_t i = 0; i < argc; ++i) { + internal::seToJsValue(_isolate, args[i], &argv[i]); + } + + #if CC_DEBUG + v8::TryCatch tryCatch(_isolate); + #endif + + assert(!funcVal.IsEmpty()); + if (!funcVal.ToLocalChecked()->IsFunction()) { + v8::String::Utf8Value funcStr(_isolate, funcVal.ToLocalChecked()); + SE_REPORT_ERROR("%s is not a function: %s", funcName, *funcStr); + return false; + } + + v8::MaybeLocal funcObj = funcVal.ToLocalChecked()->ToObject(context); + v8::MaybeLocal result = funcObj.ToLocalChecked()->CallAsFunction(_getContext(), localObj, argc, argv.data()); + + #if CC_DEBUG + if (tryCatch.HasCaught()) { + v8::String::Utf8Value stack(_isolate, tryCatch.StackTrace(context).ToLocalChecked()); + SE_REPORT_ERROR("Invoking function failed, %s", *stack); + if (rval != nullptr) { + rval->setUndefined(); + } + tryCatch.ReThrow(); + return false; + } + #endif + + if (!result.IsEmpty()) { + if (rval != nullptr) { + internal::jsToSeValue(_isolate, result.ToLocalChecked(), rval); + } + } + return true; +} + +// VMStringPool +ScriptEngine::VMStringPool::VMStringPool() { +} + +ScriptEngine::VMStringPool::~VMStringPool() { +} + +v8::MaybeLocal ScriptEngine::VMStringPool::get(v8::Isolate *isolate, const char *name) { + v8::Local ret; + auto iter = _vmStringPoolMap.find(name); + if (iter == _vmStringPoolMap.end()) { + v8::MaybeLocal nameValue = v8::String::NewFromUtf8(isolate, name, v8::NewStringType::kNormal); + if (!nameValue.IsEmpty()) { + v8::Persistent *persistentName = new v8::Persistent(); + persistentName->Reset(isolate, nameValue.ToLocalChecked()); + _vmStringPoolMap.emplace(name, persistentName); + ret = v8::Local::New(isolate, *persistentName); + } + } else { + ret = v8::Local::New(isolate, *iter->second); + } + + return ret; +} + +void ScriptEngine::VMStringPool::clear() { + for (auto &e : _vmStringPoolMap) { + e.second->Reset(); + delete e.second; + } + _vmStringPoolMap.clear(); +} + } // namespace se #endif // #if SCRIPT_ENGINE_TYPE == SCRIPT_ENGINE_V8 diff --git a/native/cocos/bindings/jswrapper/v8/ScriptEngine.h b/native/cocos/bindings/jswrapper/v8/ScriptEngine.h index 1ce9e007be..4cfdad42a6 100644 --- a/native/cocos/bindings/jswrapper/v8/ScriptEngine.h +++ b/native/cocos/bindings/jswrapper/v8/ScriptEngine.h @@ -305,7 +305,24 @@ public: */ uint32_t getVMId() const { return _vmId; } + /** + * @brief Fast version of call script function, faster than Object::call + */ + bool callFunction(Object *targetObj, const char *funcName, uint32_t argc, Value *args, Value *rval = nullptr); + // Private API used in wrapper + class VMStringPool final { + public: + VMStringPool(); + ~VMStringPool(); + v8::MaybeLocal get(v8::Isolate *isolate, const char *name); + void clear(); + + private: + std::unordered_map *> _vmStringPoolMap; + }; + + inline VMStringPool & _getStringPool() { return _stringPool; } //NOLINT(readability-identifier-naming) void _retainScriptObject(void *owner, void *target); //NOLINT(readability-identifier-naming) void _releaseScriptObject(void *owner, void *target); //NOLINT(readability-identifier-naming) v8::Local _getContext() const; //NOLINT(readability-identifier-naming) @@ -314,8 +331,7 @@ public: private: ScriptEngine(); ~ScriptEngine(); - static void privateDataFinalize(void *nativeObj); - + static void privateDataFinalize(PrivateObjectBase *nativeObj); static void onFatalErrorCallback(const char *location, const char *message); static void onOOMErrorCallback(const char *location, bool isHeapOom); static void onMessageCallback(v8::Local message, v8::Local data); @@ -354,6 +370,7 @@ private: node::Environment *_env; node::IsolateData *_isolateData; #endif + VMStringPool _stringPool; std::thread::id _engineThreadId; diff --git a/native/cocos/bindings/jswrapper/v8/Utils.cpp b/native/cocos/bindings/jswrapper/v8/Utils.cpp index 44ea8c6422..d0510f5332 100644 --- a/native/cocos/bindings/jswrapper/v8/Utils.cpp +++ b/native/cocos/bindings/jswrapper/v8/Utils.cpp @@ -36,22 +36,20 @@ namespace se { namespace internal { -void jsToSeArgs(const v8::FunctionCallbackInfo &v8args, ValueArray *outArr) { - assert(outArr != nullptr); +void jsToSeArgs(const v8::FunctionCallbackInfo &v8args, ValueArray &outArr) { v8::Isolate *isolate = v8args.GetIsolate(); for (int i = 0; i < v8args.Length(); i++) { - Value v; - jsToSeValue(isolate, v8args[i], &v); - outArr->push_back(v); + jsToSeValue(isolate, v8args[i], &outArr[i]); } } -void seToJsArgs(v8::Isolate *isolate, const ValueArray &args, std::vector> *outArr) { +void seToJsArgs(v8::Isolate *isolate, const ValueArray &args, v8::Local *outArr) { assert(outArr != nullptr); + uint32_t i = 0; for (const auto &data : args) { - v8::Local jsval; + v8::Local &jsval = outArr[i]; seToJsValue(isolate, data, &jsval); - outArr->push_back(jsval); + ++i; } } @@ -126,8 +124,9 @@ void jsToSeValue(v8::Isolate *isolate, v8::Local jsval, Value *v) { } else if (jsval->IsObject()) { v8::MaybeLocal jsObj = jsval->ToObject(isolate->GetCurrentContext()); if (!jsObj.IsEmpty()) { - void * nativePtr = internal::getPrivate(isolate, jsObj.ToLocalChecked()); - Object *obj = nullptr; + PrivateObjectBase *privateObject = static_cast(internal::getPrivate(isolate, jsObj.ToLocalChecked(), 0)); + void * nativePtr = privateObject ? privateObject->getRaw() : nullptr; + Object * obj = nullptr; if (nativePtr != nullptr) { obj = Object::getObjectWithPtr(nativePtr); } @@ -193,30 +192,32 @@ bool hasPrivate(v8::Isolate *isolate, v8::Local value) { return ret.IsJust() && ret.FromJust(); } -void setPrivate(v8::Isolate *isolate, ObjectWrap &wrap, void *data, PrivateData **outInternalData) { +void setPrivate(v8::Isolate *isolate, ObjectWrap &wrap, PrivateObjectBase *data, Object *thizObj, PrivateData **outInternalData) { v8::Local obj = wrap.handle(isolate); int c = obj->InternalFieldCount(); - if (c > 0) { - wrap.wrap(data); + if (c > 1) { + wrap.wrap(data, 0); + wrap.wrap(thizObj, 1); // SE_LOGD("setPrivate1: %p\n", data); if (outInternalData != nullptr) { *outInternalData = nullptr; } } else { - Object *privateObj = Object::createObjectWithClass(__jsb_CCPrivateData_class); - auto * privateData = static_cast(malloc(sizeof(PrivateData))); - privateData->data = data; - privateData->seObj = privateObj; + Object *jsPrivateobj = Object::createObjectWithClass(__jsb_CCPrivateData_class); + auto * privateData = static_cast(malloc(sizeof(PrivateData))); + privateData->data = data; + privateData->seObj = jsPrivateobj; - privateObj->_getWrap().setFinalizeCallback(__jsb_CCPrivateData_class->_getFinalizeFunction()); - privateObj->_getWrap().wrap(privateData); + jsPrivateobj->_getWrap().setFinalizeCallback(__jsb_CCPrivateData_class->_getFinalizeFunction()); + jsPrivateobj->_getWrap().wrap(se::make_shared_private_object(privateData), 0); + jsPrivateobj->_getWrap().wrap(thizObj, 1); v8::MaybeLocal key = v8::String::NewFromUtf8(isolate, keyPrivateData, v8::NewStringType::kNormal); assert(!key.IsEmpty()); - v8::Maybe ret = obj->Set(isolate->GetCurrentContext(), key.ToLocalChecked(), privateObj->_getJSObject()); + v8::Maybe ret = obj->Set(isolate->GetCurrentContext(), key.ToLocalChecked(), jsPrivateobj->_getJSObject()); assert(!ret.IsNothing()); // SE_LOGD("setPrivate: native data: %p\n", privateData); - // privateObj->decRef(); // NOTE: it's released in ScriptEngine::privateDataFinalize + // jsPrivateobj->decRef(); // NOTE: it's released in ScriptEngine::privateDataFinalize if (outInternalData != nullptr) { *outInternalData = privateData; @@ -224,23 +225,31 @@ void setPrivate(v8::Isolate *isolate, ObjectWrap &wrap, void *data, PrivateData } } -void *getPrivate(v8::Isolate *isolate, v8::Local value) { +void *getPrivate(v8::Isolate *isolate, v8::Local value, uint32_t index /* = 0*/) { v8::Local context = isolate->GetCurrentContext(); v8::MaybeLocal obj = value->ToObject(context); if (obj.IsEmpty()) { return nullptr; } + assert(index >= 0 && index < 2); + if (index > 1) { + return nullptr; + } + v8::Local objChecked = obj.ToLocalChecked(); int c = objChecked->InternalFieldCount(); - if (c > 0) { - void *nativeObj = ObjectWrap::unwrap(objChecked); + if (c > 1) { + void *nativeObj = nullptr; + if (index >= 0 && index < 2) { + nativeObj = ObjectWrap::unwrap(objChecked, index); + } // SE_LOGD("getPrivate1: %p\n", nativeObj); return nativeObj; } // Pure JS subclass object doesn't have a internal field - v8::MaybeLocal key = v8::String::NewFromUtf8(isolate, keyPrivateData, v8::NewStringType::kNormal); + v8::MaybeLocal key = ScriptEngine::getInstance()->_getStringPool().get(isolate, keyPrivateData); if (key.IsEmpty()) { return nullptr; } @@ -256,11 +265,11 @@ void *getPrivate(v8::Isolate *isolate, v8::Local value) { return nullptr; } - v8::MaybeLocal privateObj = mbVal.ToLocalChecked()->ToObject(context); - if (privateObj.IsEmpty()) { + v8::MaybeLocal jsPrivateobj = mbVal.ToLocalChecked()->ToObject(context); + if (jsPrivateobj.IsEmpty()) { return nullptr; } - auto *privateData = static_cast(ObjectWrap::unwrap(privateObj.ToLocalChecked())); + auto *privateData = static_cast(static_cast(ObjectWrap::unwrap(jsPrivateobj.ToLocalChecked(), index))->getRaw()); // SE_LOGD("getPrivate: native data: %p\n", privateData); return privateData->data; } @@ -268,8 +277,9 @@ void *getPrivate(v8::Isolate *isolate, v8::Local value) { void clearPrivate(v8::Isolate *isolate, ObjectWrap &wrap) { v8::Local obj = wrap.handle(isolate); int c = obj->InternalFieldCount(); - if (c > 0) { - wrap.wrap(nullptr); + if (c > 1) { + wrap.wrap(nullptr, 0); + wrap.wrap(nullptr, 1); } else { v8::Local context = isolate->GetCurrentContext(); // Pure JS subclass object doesn't have a internal field @@ -289,12 +299,12 @@ void clearPrivate(v8::Isolate *isolate, ObjectWrap &wrap) { return; } - v8::MaybeLocal privateObj = mbVal.ToLocalChecked()->ToObject(context); - if (privateObj.IsEmpty()) { + v8::MaybeLocal jsPrivateobj = mbVal.ToLocalChecked()->ToObject(context); + if (jsPrivateobj.IsEmpty()) { return; } - auto *privateData = static_cast(ObjectWrap::unwrap(privateObj.ToLocalChecked())); + auto *privateData = static_cast(static_cast(ObjectWrap::unwrap(jsPrivateobj.ToLocalChecked(), 0))->getRaw()); free(privateData); v8::Maybe ok = obj->Delete(context, keyChecked); if (ok.IsNothing()) { @@ -307,5 +317,5 @@ void clearPrivate(v8::Isolate *isolate, ObjectWrap &wrap) { } // namespace internal } // namespace se -#endif // #if SCRIPT_ENGINE_TYPE == SCRIPT_ENGINE_V8 +#endif // #if SCRIPT_ENGINE_TYPE == SCRIPT_ENGINE_V8 diff --git a/native/cocos/bindings/jswrapper/v8/Utils.h b/native/cocos/bindings/jswrapper/v8/Utils.h index 77b3369506..b36548f8d8 100644 --- a/native/cocos/bindings/jswrapper/v8/Utils.h +++ b/native/cocos/bindings/jswrapper/v8/Utils.h @@ -30,8 +30,8 @@ #if SCRIPT_ENGINE_TYPE == SCRIPT_ENGINE_V8 - #include "Base.h" #include "../Value.h" + #include "Base.h" #include "ObjectWrap.h" namespace se { @@ -39,22 +39,22 @@ namespace se { namespace internal { struct PrivateData { - void *data; - Object *seObj; + PrivateObjectBase *data{nullptr}; + Object * seObj{nullptr}; }; -void jsToSeArgs(const v8::FunctionCallbackInfo &_v8args, ValueArray *outArr); +void jsToSeArgs(const v8::FunctionCallbackInfo &_v8args, ValueArray &outArr); void jsToSeValue(v8::Isolate *isolate, v8::Local jsval, Value *v); -void seToJsArgs(v8::Isolate *isolate, const ValueArray &args, std::vector> *outArr); +void seToJsArgs(v8::Isolate *isolate, const ValueArray &args, v8::Local *outArr); void seToJsValue(v8::Isolate *isolate, const Value &v, v8::Local *outJsVal); void setReturnValue(const Value &data, const v8::FunctionCallbackInfo &argv); void setReturnValue(const Value &data, const v8::PropertyCallbackInfo &argv); -bool hasPrivate(v8::Isolate *isolate, v8::Local value); -void setPrivate(v8::Isolate *isolate, ObjectWrap &wrap, void *data, PrivateData **outInternalData); -void *getPrivate(v8::Isolate *isolate, v8::Local value); -void clearPrivate(v8::Isolate *isolate, ObjectWrap &wrap); +bool hasPrivate(v8::Isolate *isolate, v8::Local value); +void setPrivate(v8::Isolate *isolate, ObjectWrap &wrap, PrivateObjectBase *data, Object *obj, PrivateData **outInternalData); +void *getPrivate(v8::Isolate *isolate, v8::Local value, uint32_t index = 0); +void clearPrivate(v8::Isolate *isolate, ObjectWrap &wrap); } // namespace internal } // namespace se diff --git a/native/cocos/bindings/jswrapper/v8/debugger/base64.h b/native/cocos/bindings/jswrapper/v8/debugger/base64.h index 26ef4f1d35..929a3a6dba 100644 --- a/native/cocos/bindings/jswrapper/v8/debugger/base64.h +++ b/native/cocos/bindings/jswrapper/v8/debugger/base64.h @@ -56,7 +56,7 @@ bool base64_decode_group_slow(char *const dst, const size_t dstlen, #define V(expr) \ for (;;) { \ const uint8_t c = src[*i]; \ - lo = unbase64(c); \ + lo = unbase64(c); \ *i += 1; \ if (lo < 64) \ break; /* Legal character. */ \ @@ -69,7 +69,7 @@ bool base64_decode_group_slow(char *const dst, const size_t dstlen, if (*k >= dstlen) \ return false; \ hi = lo; - V(/* Nothing. */); + V(do {} while (false) /* empty*/); V(dst[(*k)++] = ((hi & 0x3F) << 2) | ((lo & 0x30) >> 4)); V(dst[(*k)++] = ((hi & 0x0F) << 4) | ((lo & 0x3C) >> 2)); V(dst[(*k)++] = ((hi & 0x03) << 6) | ((lo & 0x3F) >> 0)); @@ -82,10 +82,10 @@ size_t base64_decode_fast(char *const dst, const size_t dstlen, const TypeName *const src, const size_t srclen, const size_t decoded_size) { const size_t available = dstlen < decoded_size ? dstlen : decoded_size; - const size_t max_k = available / 3 * 3; - size_t max_i = srclen / 4 * 4; - size_t i = 0; - size_t k = 0; + const size_t max_k = available / 3 * 3; + size_t max_i = srclen / 4 * 4; + size_t i = 0; + size_t k = 0; while (i < max_i && k < max_k) { const uint32_t v = unbase64(src[i + 0]) << 24 | @@ -119,9 +119,9 @@ size_t base64_decode(char *const dst, const size_t dstlen, } static size_t base64_encode(const char *src, - size_t slen, - char *dst, - size_t dlen) { + size_t slen, + char * dst, + size_t dlen) { // We know how much we'll write, just make sure that there's space. CHECK(dlen >= base64_encoded_size(slen) && "not enough space provided for base64 encode"); @@ -135,9 +135,10 @@ static size_t base64_encode(const char *src, unsigned k; unsigned n; - static const char table[] = "ABCDEFGHIJKLMNOPQRSTUVWXYZ" - "abcdefghijklmnopqrstuvwxyz" - "0123456789+/"; + static const char table[] = + "ABCDEFGHIJKLMNOPQRSTUVWXYZ" + "abcdefghijklmnopqrstuvwxyz" + "0123456789+/"; i = 0; k = 0; @@ -160,7 +161,7 @@ static size_t base64_encode(const char *src, if (n != slen) { switch (slen - n) { case 1: - a = src[i + 0] & 0xff; + a = src[i + 0] & 0xff; dst[k + 0] = table[a >> 2]; dst[k + 1] = table[(a & 3) << 4]; dst[k + 2] = '='; @@ -168,8 +169,8 @@ static size_t base64_encode(const char *src, break; case 2: - a = src[i + 0] & 0xff; - b = src[i + 1] & 0xff; + a = src[i + 0] & 0xff; + b = src[i + 1] & 0xff; dst[k + 0] = table[a >> 2]; dst[k + 1] = table[((a & 3) << 4) | (b >> 4)]; dst[k + 2] = table[(b & 0x0f) << 2]; diff --git a/native/cocos/bindings/manual/JavaScriptJavaBridge.cpp b/native/cocos/bindings/manual/JavaScriptJavaBridge.cpp index cd7c7fd79b..b1a024dc2e 100644 --- a/native/cocos/bindings/manual/JavaScriptJavaBridge.cpp +++ b/native/cocos/bindings/manual/JavaScriptJavaBridge.cpp @@ -24,9 +24,9 @@ ****************************************************************************/ #include "cocos/bindings/manual/JavaScriptJavaBridge.h" +#include "cocos/application/ApplicationManager.h" #include "cocos/base/UTF8.h" #include "cocos/bindings/manual/jsb_conversions.h" -#include "cocos/application/ApplicationManager.h" #if CC_PLATFORM == CC_PLATFORM_ANDROID #include @@ -44,7 +44,7 @@ #ifndef ORG_JAVABRIDGE_CLASS_NAME #define ORG_JAVABRIDGE_CLASS_NAME com_cocos_lib_CocosJavascriptJavaBridge #endif -#define JNI_JSJAVABRIDGE(FUNC) JNI_METHOD1(ORG_JAVABRIDGE_CLASS_NAME, FUNC) +#define JNI_JSJAVABRIDGE(FUNC) JNI_METHOD1(ORG_JAVABRIDGE_CLASS_NAME, FUNC) #define JSJ_ERR_OK (0) #define JSJ_ERR_TYPE_NOT_SUPPORT (-1) #define JSJ_ERR_INVALID_SIGNATURES (-2) @@ -81,10 +81,9 @@ public: class CallInfo { public: CallInfo(const char *className, const char *methodName, const char *methodSig) - : _mClassName(className), - _mMethodName(methodName), - _mMethodSig(methodSig) - { + : _mClassName(className), + _mMethodName(methodName), + _mMethodSig(methodSig) { memset(&_mRet, 0, sizeof(_mRet)); _mValid = validateMethodSig() && getMethodInfo(); } @@ -126,7 +125,7 @@ public: } } - JNIEnv *getEnv() const{ + JNIEnv *getEnv() const { return _mEnv; } @@ -173,17 +172,17 @@ public: }; static bool convertReturnValue(ReturnValue retValue, ValueType type, se::Value *ret); - }; -using JsCallback = std::function; -class ScriptNativeBridge{ +using JsCallback = std::function; +class ScriptNativeBridge { public: - void callByNative(const std::string& arg0, const std::string& arg1); - inline void setCallback(const JsCallback& cb){ + void callByNative(const std::string &arg0, const std::string &arg1); + inline void setCallback(const JsCallback &cb) { _callback = cb; } - static ScriptNativeBridge* bridgeCxxInstance; - se::Value jsCb; + static ScriptNativeBridge *bridgeCxxInstance; + se::Value jsCb; + private: JsCallback _callback{nullptr}; // NOLINT(readability-identifier-naming) }; @@ -216,7 +215,7 @@ Java_com_cocos_lib_JsbBridge_nativeSendToScript(JNIEnv *env, jclass clazz, jstri } } // extern "C" -ScriptNativeBridge* ScriptNativeBridge::bridgeCxxInstance{nullptr}; +ScriptNativeBridge *ScriptNativeBridge::bridgeCxxInstance{nullptr}; JavaScriptJavaBridge::CallInfo::~CallInfo() { if (_mReturnType == ValueType::STRING && _mRet.stringValue) { @@ -477,9 +476,7 @@ bool JavaScriptJavaBridge::convertReturnValue(ReturnValue retValue, ValueType ty se::Class *__jsb_JavaScriptJavaBridge_class = nullptr; // NOLINT -static bool JavaScriptJavaBridge_finalize(se::State &s) { //NOLINT(readability-identifier-naming) - auto *cobj = static_cast(s.nativeThisObject()); - delete cobj; +static bool JavaScriptJavaBridge_finalize(se::State &s) { //NOLINT(readability-identifier-naming, misc-unused-parameters) return true; } SE_BIND_FINALIZE_FUNC(JavaScriptJavaBridge_finalize) @@ -500,13 +497,13 @@ static bool JavaScriptJavaBridge_callStaticMethod(se::State &s) { //NOLINT(reada std::string clsName; std::string methodName; std::string methodSig; - ok = seval_to_std_string(args[0], &clsName); + ok = sevalue_to_native(args[0], &clsName); SE_PRECONDITION2(ok, false, "Converting class name failed!"); - ok = seval_to_std_string(args[1], &methodName); + ok = sevalue_to_native(args[1], &methodName); SE_PRECONDITION2(ok, false, "Converting method name failed!"); - ok = seval_to_std_string(args[2], &methodSig); + ok = sevalue_to_native(args[2], &methodSig); SE_PRECONDITION2(ok, false, "Converting method signature failed!"); JavaScriptJavaBridge::CallInfo call(clsName.c_str(), methodName.c_str(), methodSig.c_str()); @@ -531,13 +528,13 @@ static bool JavaScriptJavaBridge_callStaticMethod(se::State &s) { //NOLINT(reada std::string clsName; std::string methodName; std::string methodSig; - ok = seval_to_std_string(args[0], &clsName); + ok = sevalue_to_native(args[0], &clsName); SE_PRECONDITION2(ok, false, "Converting class name failed!"); - ok = seval_to_std_string(args[1], &methodName); + ok = sevalue_to_native(args[1], &methodName); SE_PRECONDITION2(ok, false, "Converting method name failed!"); - ok = seval_to_std_string(args[2], &methodSig); + ok = sevalue_to_native(args[2], &methodSig); SE_PRECONDITION2(ok, false, "Converting method signature failed!"); JavaScriptJavaBridge::CallInfo call(clsName.c_str(), methodName.c_str(), methodSig.c_str()); @@ -550,7 +547,7 @@ static bool JavaScriptJavaBridge_callStaticMethod(se::State &s) { //NOLINT(reada switch (call.argumentTypeAtIndex(i)) { case JavaScriptJavaBridge::ValueType::INTEGER: { int integer = 0; - seval_to_int32(args[index], &integer); + sevalue_to_native(args[index], &integer); jargs[i].i = integer; break; } @@ -562,7 +559,7 @@ static bool JavaScriptJavaBridge_callStaticMethod(se::State &s) { //NOLINT(reada } case JavaScriptJavaBridge::ValueType::FLOAT: { float floatNumber = 0.0F; - seval_to_float(args[index], &floatNumber); + sevalue_to_native(args[index], &floatNumber); jargs[i].f = floatNumber; break; } @@ -576,7 +573,7 @@ static bool JavaScriptJavaBridge_callStaticMethod(se::State &s) { //NOLINT(reada jargs[i].l = nullptr; } else { std::string str; - seval_to_std_string(args[index], &str); + sevalue_to_native(args[index], &str); jargs[i].l = call.getEnv()->NewStringUTF(str.c_str()); toReleaseObjects.push_back(jargs[i].l); } @@ -612,8 +609,7 @@ static bool JavaScriptJavaBridge_callStaticMethod(se::State &s) { //NOLINT(reada } SE_BIND_FUNC(JavaScriptJavaBridge_callStaticMethod) - -static bool ScriptNativeBridge_getCallback(se::State &s){ //NOLINT(readability-identifier-naming) +static bool ScriptNativeBridge_getCallback(se::State &s) { //NOLINT(readability-identifier-naming) auto *cobj = static_cast(s.nativeThisObject()); assert(cobj == ScriptNativeBridge::bridgeCxxInstance); s.rval() = cobj->jsCb; @@ -622,31 +618,30 @@ static bool ScriptNativeBridge_getCallback(se::State &s){ //NOLINT(readability-i } SE_BIND_PROP_GET(ScriptNativeBridge_getCallback) -static bool ScriptNativeBridge_setCallback(se::State &s){ //NOLINT(readability-identifier-naming) +static bool ScriptNativeBridge_setCallback(se::State &s) { //NOLINT(readability-identifier-naming) auto *cobj = static_cast(s.nativeThisObject()); assert(cobj == ScriptNativeBridge::bridgeCxxInstance); - const auto &args = s.args(); - se::Value jsFunc = args[0]; - cobj->jsCb = jsFunc; - if(jsFunc.isNullOrUndefined()) - { + const auto &args = s.args(); + se::Value jsFunc = args[0]; + cobj->jsCb = jsFunc; + if (jsFunc.isNullOrUndefined()) { cobj->setCallback(nullptr); - } - else{ + } else { assert(jsFunc.isObject() && jsFunc.toObject()->isFunction()); s.thisObject()->attachObject(jsFunc.toObject()); - cobj->setCallback([jsFunc](const std::string& arg0, const std::string& arg1){ + cobj->setCallback([jsFunc](const std::string &arg0, const std::string &arg1) { se::AutoHandleScope hs; - se::ValueArray args; + se::ValueArray args; args.push_back(se::Value(arg0)); - if(!arg1.empty()) { + if (!arg1.empty()) { args.push_back(se::Value(arg1)); } jsFunc.toObject()->call(args, nullptr); }); } return true; -}SE_BIND_PROP_SET(ScriptNativeBridge_setCallback) +} +SE_BIND_PROP_SET(ScriptNativeBridge_setCallback) static bool ScriptNativeBridge_sendToNative(se::State &s) { //NOLINT(readability-identifier-naming) const auto &args = s.args(); @@ -654,11 +649,11 @@ static bool ScriptNativeBridge_sendToNative(se::State &s) { //NOLINT(readability if (argc >= 1 && argc < 3) { bool ok = false; std::string arg0; - ok = seval_to_std_string(args[0], &arg0); + ok = sevalue_to_native(args[0], &arg0); SE_PRECONDITION2(ok, false, "Converting arg0 failed!"); std::string arg1; if (argc == 2) { - ok = seval_to_std_string(args[1], &arg1); + ok = sevalue_to_native(args[1], &arg1); SE_PRECONDITION2(ok, false, "Converting arg1 failed!"); } callPlatformStringMethod(arg0, arg1); @@ -716,12 +711,10 @@ bool register_script_native_bridge(se::Object *obj) { //NOLINT(readability-ident return true; } void callPlatformStringMethod(const std::string &arg0, const std::string &arg1) { - cc::JniHelper::callStaticVoidMethod( - "com/cocos/lib/JsbBridge", "callByScript", arg0, arg1); + cc::JniHelper::callStaticVoidMethod( + "com/cocos/lib/JsbBridge", "callByScript", arg0, arg1); } -void ScriptNativeBridge::callByNative(const std::string& arg0, const std::string& arg1){ +void ScriptNativeBridge::callByNative(const std::string &arg0, const std::string &arg1) { _callback(arg0, arg1); } - - diff --git a/native/cocos/bindings/manual/JavaScriptObjCBridge.mm b/native/cocos/bindings/manual/JavaScriptObjCBridge.mm index 84f50aa0d0..a22a602140 100644 --- a/native/cocos/bindings/manual/JavaScriptObjCBridge.mm +++ b/native/cocos/bindings/manual/JavaScriptObjCBridge.mm @@ -24,6 +24,7 @@ ****************************************************************************/ #include "JavaScriptObjCBridge.h" +#include "cocos/bindings/jswrapper/SeApi.h" #include "cocos/bindings/manual/jsb_conversions.h" #include "cocos/bindings/manual/jsb_global.h" @@ -106,7 +107,7 @@ private: }; ScriptNativeBridge* ScriptNativeBridge::bridgeCxxInstance{nullptr}; bool JavaScriptObjCBridge::CallInfo::execute(const se::ValueArray &argv, se::Value &rval) { - NSString *className = [NSString stringWithCString:_className.c_str() encoding:NSUTF8StringEncoding]; + NSString *className = [NSString stringWithCString:_className.c_str() encoding:NSUTF8StringEncoding]; NSString *methodName = [NSString stringWithCString:_methodName.c_str() encoding:NSUTF8StringEncoding]; if (!className || !methodName) { @@ -125,7 +126,7 @@ bool JavaScriptObjCBridge::CallInfo::execute(const se::ValueArray &argv, se::Val _error = JSO_ERR_METHOD_NOT_FOUND; return false; } - methodSel = NSSelectorFromString(methodName); + methodSel = NSSelectorFromString(methodName); NSMethodSignature *methodSig = [targetClass methodSignatureForSelector:(SEL)methodSel]; if (methodSig == nil) { _error = JSO_ERR_METHOD_NOT_FOUND; @@ -133,7 +134,7 @@ bool JavaScriptObjCBridge::CallInfo::execute(const se::ValueArray &argv, se::Val return false; } @try { - int argc = (int)argv.size(); + int argc = (int)argv.size(); NSUInteger argumentCount = [methodSig numberOfArguments]; if (argumentCount != argc) { _error = JSO_ERR_INVALID_ARGUMENTS; @@ -145,8 +146,8 @@ bool JavaScriptObjCBridge::CallInfo::execute(const se::ValueArray &argv, se::Val [invocation setSelector:methodSel]; for (int i = 2; i < argc; ++i) { - std::string argumentType = [methodSig getArgumentTypeAtIndex:i]; - const se::Value &arg = argv[i]; + std::string argumentType = [methodSig getArgumentTypeAtIndex:i]; + const se::Value &arg = argv[i]; /* - (void)setArgument:(void *)argumentLocation atIndex:(NSInteger)idx; * @@ -219,8 +220,8 @@ bool JavaScriptObjCBridge::CallInfo::execute(const se::ValueArray &argv, se::Val } } - NSUInteger returnLength = [methodSig methodReturnLength]; - std::string returnType = [methodSig methodReturnType]; + NSUInteger returnLength = [methodSig methodReturnLength]; + std::string returnType = [methodSig methodReturnType]; [invocation invoke]; if (returnLength > 0) { @@ -295,8 +296,6 @@ void ScriptNativeBridge::callByNative(const std::string& arg0, const std::string se::Class *__jsb_JavaScriptObjCBridge_class = nullptr; static bool JavaScriptObjCBridge_finalize(se::State &s) { - JavaScriptObjCBridge *cobj = (JavaScriptObjCBridge *)s.nativeThisObject(); - delete cobj; return true; } SE_BIND_FINALIZE_FUNC(JavaScriptObjCBridge_finalize) @@ -310,15 +309,15 @@ SE_BIND_CTOR(JavaScriptObjCBridge_constructor, __jsb_JavaScriptObjCBridge_class, static bool JavaScriptObjCBridge_callStaticMethod(se::State &s) { const auto &args = s.args(); - int argc = (int)args.size(); + int argc = (int)args.size(); if (argc >= 2) { - bool ok = false; + bool ok = false; std::string clsName, methodName; - ok = seval_to_std_string(args[0], &clsName); + ok = sevalue_to_native(args[0], &clsName); SE_PRECONDITION2(ok, false, "Converting class name failed!"); - ok = seval_to_std_string(args[1], &methodName); + ok = sevalue_to_native(args[1], &methodName); SE_PRECONDITION2(ok, false, "Converting method name failed!"); JavaScriptObjCBridge::CallInfo call(clsName.c_str(), methodName.c_str()); @@ -377,11 +376,11 @@ static bool ScriptNativeBridge_sendToNative(se::State &s) { //NOLINT if (argc >= 1 && argc < 3) { bool ok = false; std::string arg0; - ok = seval_to_std_string(args[0], &arg0); + ok = sevalue_to_native(args[0], &arg0); SE_PRECONDITION2(ok, false, "Converting first argument failed!"); std::string arg1; if (argc == 2) { - ok = seval_to_std_string(args[1], &arg1); + ok = sevalue_to_native(args[1], &arg1); SE_PRECONDITION2(ok, false, "Converting second argument failed!"); } ok = callPlatformStringMethod(arg0, arg1); diff --git a/native/cocos/bindings/manual/jsb_assets_manual.cpp b/native/cocos/bindings/manual/jsb_assets_manual.cpp new file mode 100644 index 0000000000..2dda65e8d5 --- /dev/null +++ b/native/cocos/bindings/manual/jsb_assets_manual.cpp @@ -0,0 +1,149 @@ +/**************************************************************************** + 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 "bindings/auto/jsb_assets_auto.h" +#include "core/event/EventTypesToJS.h" +#include "jsb_scene_manual.h" + +#ifndef JSB_ALLOC + #define JSB_ALLOC(kls, ...) new (std::nothrow) kls(__VA_ARGS__) +#endif + +#ifndef JSB_FREE + #define JSB_FREE(ptr) delete ptr +#endif + +static bool js_assets_Asset_getNativeDep(se::State &s) // NOLINT(readability-identifier-naming) +{ + auto *cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_assets_Asset_getNativeDep : Invalid Native Object"); + const auto & args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 0) { + ok = nativevalue_to_se(cobj->getNativeDep(), s.rval()); + SE_PRECONDITION2(ok, false, "js_assets_Asset_getNativeDep : Error processing arguments"); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 0); + return false; +} +SE_BIND_PROP_GET(js_assets_Asset_getNativeDep) // NOLINT(readability-identifier-naming) + +static bool js_assets_ImageAsset_getData(se::State &s) // NOLINT(readability-identifier-naming) +{ + auto *cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_assets_ImageAsset_getData : Invalid Native Object"); + + s.rval().setUint64(reinterpret_cast(cobj->getData())); + return false; +} +SE_BIND_PROP_GET(js_assets_ImageAsset_getData) // NOLINT(readability-identifier-naming) + +static bool js_assets_ImageAsset_setData(se::State &s) // NOLINT(readability-identifier-naming) +{ + auto *cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_assets_Asset_setData : Invalid Native Object"); + const auto &args = s.args(); + size_t argc = args.size(); + if (argc == 1) { + uint8_t *data{nullptr}; + if (args[0].isObject()) { + args[0].toObject()->getTypedArrayData(&data, nullptr); + } else { + data = reinterpret_cast(args[0].asPtr()); + } + cobj->setData(data); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 0); + return false; +} +SE_BIND_FUNC(js_assets_ImageAsset_setData) // NOLINT(readability-identifier-naming) + +static bool js_assets_SimpleTexture_registerGFXTextureUpdatedListener(se::State &s) // NOLINT(readability-identifier-naming) +{ + auto *cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_assets_SimpleTexture_registerGFXTextureUpdatedListener : Invalid Native Object"); + auto *thisObj = s.thisObject(); + cobj->on(cc::EventTypesToJS::SIMPLE_TEXTURE_GFX_TEXTURE_UPDATED, [thisObj](cc::gfx::Texture *texture) { + se::AutoHandleScope hs; + se::Value arg0; + nativevalue_to_se(texture, arg0, nullptr); + se::ScriptEngine::getInstance()->callFunction(thisObj, "_onGFXTextureUpdated", 1, &arg0); + }); + + return true; +} +SE_BIND_FUNC(js_assets_SimpleTexture_registerGFXTextureUpdatedListener) // NOLINT(readability-identifier-naming) + +static bool js_assets_TextureBase_registerGFXSamplerUpdatedListener(se::State &s) // NOLINT(readability-identifier-naming) +{ + auto *cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_assets_TextureBase_registerGFXSamplerUpdatedListener : Invalid Native Object"); + auto *thisObj = s.thisObject(); + cobj->on(cc::EventTypesToJS::TEXTURE_BASE_GFX_SAMPLER_UPDATED, [thisObj](cc::gfx::Sampler *sampler) { + se::AutoHandleScope hs; + se::Value arg0; + nativevalue_to_se(sampler, arg0, nullptr); + se::ScriptEngine::getInstance()->callFunction(thisObj, "_onGFXSamplerUpdated", 1, &arg0); + }); + + return true; +} +SE_BIND_FUNC(js_assets_TextureBase_registerGFXSamplerUpdatedListener) // NOLINT(readability-identifier-naming) + +static bool js_assets_Material_registerPassesUpdatedListener(se::State &s) // NOLINT(readability-identifier-naming) +{ + auto *cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_assets_Material_registerPassesUpdatedListener : Invalid Native Object"); + auto *thisObj = s.thisObject(); + cobj->on(cc::EventTypesToJS::MATERIAL_PASSES_UPDATED, [thisObj]() { + se::AutoHandleScope hs; + se::ScriptEngine::getInstance()->callFunction(thisObj, "_onPassesUpdated", 0, nullptr); + }); + + return true; +} +SE_BIND_FUNC(js_assets_Material_registerPassesUpdatedListener) // NOLINT(readability-identifier-naming) + +bool register_all_assets_manual(se::Object *obj) // NOLINT(readability-identifier-naming) +{ + // Get the ns + se::Value nsVal; + if (!obj->getProperty("jsb", &nsVal)) { + se::HandleObject jsobj(se::Object::createPlainObject()); + nsVal.setObject(jsobj); + obj->setProperty("jsb", nsVal); + } + + __jsb_cc_Asset_proto->defineProperty("_nativeDep", _SE(js_assets_Asset_getNativeDep), nullptr); + __jsb_cc_ImageAsset_proto->defineFunction("setData", _SE(js_assets_ImageAsset_setData)); + __jsb_cc_SimpleTexture_proto->defineFunction("_registerGFXTextureUpdatedListener", _SE(js_assets_SimpleTexture_registerGFXTextureUpdatedListener)); + __jsb_cc_TextureBase_proto->defineFunction("_registerGFXSamplerUpdatedListener", _SE(js_assets_TextureBase_registerGFXSamplerUpdatedListener)); + __jsb_cc_Material_proto->defineFunction("_registerPassesUpdatedListener", _SE(js_assets_Material_registerPassesUpdatedListener)); + + return true; +} diff --git a/native/cocos/bindings/manual/jsb_assets_manual.h b/native/cocos/bindings/manual/jsb_assets_manual.h new file mode 100644 index 0000000000..9780396556 --- /dev/null +++ b/native/cocos/bindings/manual/jsb_assets_manual.h @@ -0,0 +1,34 @@ +/**************************************************************************** + 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 "cocos/bindings/jswrapper/SeApi.h" + +namespace se { +class Object; +} + +bool register_all_assets_manual(se::Object *obj); // NOLINT(readability-identifier-naming) diff --git a/native/cocos/bindings/manual/jsb_cocos_manual.cpp b/native/cocos/bindings/manual/jsb_cocos_manual.cpp index 8bb2c14b45..173ed7d4c5 100644 --- a/native/cocos/bindings/manual/jsb_cocos_manual.cpp +++ b/native/cocos/bindings/manual/jsb_cocos_manual.cpp @@ -90,14 +90,14 @@ static bool js_PlistParser_parse(se::State &s) { // NOLINT(readability-identifie bool ok = true; if (argc == 1) { std::string arg0; - ok &= seval_to_std_string(args[0], &arg0); + ok &= sevalue_to_native(args[0], &arg0); SE_PRECONDITION2(ok, false, "Error processing arguments"); std::string parsedStr = delegator->parseText(arg0); std::replace(parsedStr.begin(), parsedStr.end(), '\n', ' '); se::Value strVal; - std_string_to_seval(parsedStr, &strVal); + nativevalue_to_se(parsedStr, strVal); se::HandleObject robj(se::Object::createJSONObject(strVal.toString())); s.rval().setObject(robj); @@ -206,7 +206,7 @@ static bool JSB_localStorageGetItem(se::State &s) { // NOLINT(readability-identi if (argc == 1) { bool ok = true; std::string key; - ok = seval_to_std_string(args[0], &key); + ok = sevalue_to_native(args[0], &key); SE_PRECONDITION2(ok, false, "Error processing arguments"); std::string value; ok = localStorageGetItem(key, &value); @@ -230,7 +230,7 @@ static bool JSB_localStorageRemoveItem(const se::State &s) { // NOLINT(readabili if (argc == 1) { bool ok = true; std::string key; - ok = seval_to_std_string(args[0], &key); + ok = sevalue_to_native(args[0], &key); SE_PRECONDITION2(ok, false, "Error processing arguments"); localStorageRemoveItem(key); return true; @@ -247,11 +247,11 @@ static bool JSB_localStorageSetItem(const se::State &s) { // NOLINT(readability- if (argc == 2) { bool ok = true; std::string key; - ok = seval_to_std_string(args[0], &key); + ok = sevalue_to_native(args[0], &key); SE_PRECONDITION2(ok, false, "Error processing arguments"); std::string value; - ok = seval_to_std_string(args[1], &value); + ok = sevalue_to_native(args[1], &value); SE_PRECONDITION2(ok, false, "Error processing arguments"); localStorageSetItem(key, value); return true; @@ -281,7 +281,7 @@ static bool JSB_localStorageKey(se::State &s) { // NOLINT(readability-identifier if (argc == 1) { bool ok = true; int nIndex = 0; - ok = seval_to_int32(args[0], &nIndex); + ok = sevalue_to_native(args[0], &nIndex); SE_PRECONDITION2(ok, false, "Error processing arguments"); std::string value; localStorageGetKey(nIndex, &value); @@ -329,8 +329,8 @@ static bool register_sys_localStorage(se::Object *obj) { // NOLINT(readability-i localStorageObj->defineProperty("length", _SE(JSB_localStorage_getLength), nullptr); std::string strFilePath = cc::FileUtils::getInstance()->getWritablePath(); -#if defined(__QNX__) - // In the QNX environment, the execution of this statement will not take effect. +#if defined(__QNX__) + // In the QNX environment, the execution of this statement will not take effect. // Not sure why // strFilePath += "/jsb.sqlite"; @@ -366,7 +366,8 @@ static bool js_CanvasRenderingContext2D_setCanvasBufferUpdatedCallback(se::State se::Value jsThis(s.thisObject()); se::Value jsFunc(args[0]); jsThis.toObject()->attachObject(jsFunc.toObject()); - auto lambda = [=](const cc::Data &larg0) -> void { + se::Object *thisObj = s.thisObject(); + auto lambda = [=](const cc::Data &larg0) -> void { se::ScriptEngine::getInstance()->clearException(); se::AutoHandleScope hs; @@ -375,7 +376,6 @@ static bool js_CanvasRenderingContext2D_setCanvasBufferUpdatedCallback(se::State args.resize(1); ok &= Data_to_seval(larg0, &args[0]); se::Value rval; - se::Object *thisObj = jsThis.isObject() ? jsThis.toObject() : nullptr; se::Object *funcObj = jsFunc.toObject(); bool succeed = funcObj->call(args, thisObj, &rval); if (!succeed) { @@ -383,8 +383,8 @@ static bool js_CanvasRenderingContext2D_setCanvasBufferUpdatedCallback(se::State } }; // Add an unroot to avoid the root of the copy constructor caused by the internal reference of Lambda. - if (jsThis.isObject()) { - jsThis.toObject()->unroot(); + if (thisObj) { + thisObj->unroot(); } jsFunc.toObject()->unroot(); arg0 = lambda; @@ -441,12 +441,12 @@ static bool js_engine_CanvasRenderingContext2D_measureText(se::State &s) { // NO CC_UNUSED bool ok = true; if (argc == 2) { std::string arg0; - ok &= seval_to_std_string(args[0], &arg0); + ok &= sevalue_to_native(args[0], &arg0); SE_PRECONDITION2(ok, false, "js_engine_CanvasRenderingContext2D_measureText : Error processing arguments"); SE_PRECONDITION2(args[1].isObject(), false, "js_engine_CanvasRenderingContext2D_fillText : no attributes set."); setCanvasRenderingContext2DProps(cobj, args[1]); cc::Size result = cobj->measureText(arg0); - ok &= Size_to_seval(result, &s.rval()); + ok &= nativevalue_to_se(result, s.rval()); SE_PRECONDITION2(ok, false, "js_engine_CanvasRenderingContext2D_measureText : Error processing arguments"); return true; } @@ -466,10 +466,10 @@ static bool js_engine_CanvasRenderingContext2D_fillRect(const se::State &s) { // float arg1 = 0; float arg2 = 0; float arg3 = 0; - ok &= seval_to_float(args[0], &arg0); - ok &= seval_to_float(args[1], &arg1); - ok &= seval_to_float(args[2], &arg2); - ok &= seval_to_float(args[3], &arg3); + ok &= sevalue_to_native(args[0], &arg0); + ok &= sevalue_to_native(args[1], &arg1); + ok &= sevalue_to_native(args[2], &arg2); + ok &= sevalue_to_native(args[3], &arg3); SE_PRECONDITION2(args[4].isObject(), false, "js_engine_CanvasRenderingContext2D_fillText : no attributes set."); setCanvasRenderingContext2DProps(cobj, args[4]); SE_PRECONDITION2(ok, false, "js_engine_CanvasRenderingContext2D_fillRect : Error processing arguments"); @@ -492,16 +492,16 @@ static bool js_engine_CanvasRenderingContext2D_fillText(const se::State &s) { // float arg1 = 0; float arg2 = 0; float arg3 = 0; - ok &= seval_to_std_string(args[0], &arg0); - ok &= seval_to_float(args[1], &arg1); - ok &= seval_to_float(args[2], &arg2); + ok &= sevalue_to_native(args[0], &arg0); + ok &= sevalue_to_native(args[1], &arg1); + ok &= sevalue_to_native(args[2], &arg2); SE_PRECONDITION2(args[4].isObject(), false, "js_engine_CanvasRenderingContext2D_fillText : no attributes set."); setCanvasRenderingContext2DProps(cobj, args[4]); if (args[3].isUndefined()) { SE_PRECONDITION2(ok, false, "js_engine_CanvasRenderingContext2D_fillText : Error processing arguments"); cobj->fillText(arg0, arg1, arg2, -1.0F); } else { - ok &= seval_to_float(args[3], &arg3); + ok &= sevalue_to_native(args[3], &arg3); SE_PRECONDITION2(ok, false, "js_engine_CanvasRenderingContext2D_fillText : Error processing arguments"); cobj->fillText(arg0, arg1, arg2, arg3); } @@ -523,13 +523,13 @@ static bool js_engine_CanvasRenderingContext2D_strokeText(const se::State &s) { float arg1 = 0; float arg2 = 0; float arg3 = 0; - ok &= seval_to_std_string(args[0], &arg0); - ok &= seval_to_float(args[1], &arg1); - ok &= seval_to_float(args[2], &arg2); + ok &= sevalue_to_native(args[0], &arg0); + ok &= sevalue_to_native(args[1], &arg1); + ok &= sevalue_to_native(args[2], &arg2); SE_PRECONDITION2(args[4].isObject(), false, "js_engine_CanvasRenderingContext2D_strokeText : no attributes set."); setCanvasRenderingContext2DProps(cobj, args[4]); if (!args[3].isUndefined()) { - ok &= seval_to_float(args[3], &arg3); + ok &= sevalue_to_native(args[3], &arg3); SE_PRECONDITION2(ok, false, "js_engine_CanvasRenderingContext2D_strokeText : Error processing arguments"); cobj->strokeText(arg0, arg1, arg2, arg3); } else { @@ -607,7 +607,7 @@ static bool js_engine_FileUtils_listFilesRecursively(const se::State &s) { // NO if (argc == 2) { std::string arg0; std::vector arg1; - ok &= seval_to_std_string(args[0], &arg0); + ok &= sevalue_to_native(args[0], &arg0); SE_PRECONDITION2(ok, false, "js_engine_FileUtils_listFilesRecursively : Error processing arguments"); cobj->listFilesRecursively(arg0, &arg1); se::Object *list = args[1].toObject(); @@ -643,7 +643,7 @@ static bool js_se_setExceptionCallback(se::State &s) { // NOLINT(readability-ide se::ScriptEngine::getInstance()->setJSExceptionCallback([objFunc](const char *location, const char *message, const char *stack) { se::AutoHandleScope scope; - se::ValueArray jsArgs; + se::ValueArray jsArgs; jsArgs.resize(3); jsArgs[0] = se::Value(location); jsArgs[1] = se::Value(message); @@ -671,12 +671,57 @@ static bool register_se_setExceptionCallback(se::Object *obj) { // NOLINT(readab return true; } +static bool js_engine_Color_get_val(se::State &s) // NOLINT(readability-identifier-naming) +{ + auto *cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_engine_Color_get_val : Invalid Native Object"); + + CC_UNUSED bool ok = true; + se::Value jsret; + uint32_t r = static_cast(cobj->r); + uint32_t g = static_cast(cobj->g); + uint32_t b = static_cast(cobj->b); + uint32_t a = static_cast(cobj->a); + uint32_t val = (a << 24) + (b << 16) + (g << 8) + r; + ok &= nativevalue_to_se(val, jsret, s.thisObject() /*ctx*/); + s.rval() = jsret; + return true; +} +SE_BIND_PROP_GET(js_engine_Color_get_val) + +static bool js_engine_Color_set_val(se::State &s) // NOLINT(readability-identifier-naming) +{ + const auto &args = s.args(); + auto * cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_engine_Color_set_val : Invalid Native Object"); + + CC_UNUSED bool ok = true; + uint32_t val{0}; + ok &= sevalue_to_native(args[0], &val, s.thisObject()); + cobj->r = val & 0x000000FF; + cobj->g = (val & 0x0000FF00) >> 8; + cobj->b = (val & 0x00FF0000) >> 16; + cobj->a = (val & 0xFF000000) >> 24; + SE_PRECONDITION2(ok, false, "js_engine_Color_set_val : Error processing new value"); + return true; +} +SE_BIND_PROP_SET(js_engine_Color_set_val) + +static bool register_engine_Color_manual(se::Object * /*obj*/) { // NOLINT(readability-identifier-naming) + __jsb_cc_Color_proto->defineProperty("_val", _SE(js_engine_Color_get_val), _SE(js_engine_Color_set_val)); + + se::ScriptEngine::getInstance()->clearException(); + + return true; +} + bool register_all_cocos_manual(se::Object *obj) { register_plist_parser(obj); register_sys_localStorage(obj); register_device(obj); register_canvas_context2d(obj); register_filetuils_ext(obj); + register_engine_Color_manual(obj); register_se_setExceptionCallback(obj); return true; } diff --git a/native/cocos/bindings/manual/jsb_conversions.cpp b/native/cocos/bindings/manual/jsb_conversions.cpp deleted file mode 100644 index 1e9130403e..0000000000 --- a/native/cocos/bindings/manual/jsb_conversions.cpp +++ /dev/null @@ -1,1356 +0,0 @@ -/**************************************************************************** - Copyright (c) 2017-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 "jsb_conversions.h" - -#include -#include - -#include "base/TypeDef.h" -#include "gfx-base/GFXDef.h" -#include "math/Math.h" - -// seval to native - -bool seval_to_int32(const se::Value &v, int32_t *ret) { - assert(ret != nullptr); - if (v.isNumber()) { - *ret = v.toInt32(); - return true; - } - if (v.isBoolean()) { - *ret = v.toBoolean() ? 1 : 0; - return true; - } - *ret = 0; - return false; -} - -bool seval_to_uint32(const se::Value &v, uint32_t *ret) { - assert(ret != nullptr); - if (v.isNumber()) { - *ret = v.toUint32(); - return true; - } - if (v.isBoolean()) { - *ret = v.toBoolean() ? 1 : 0; - return true; - } - *ret = 0; - return false; -} - -bool seval_to_int8(const se::Value &v, int8_t *ret) { - assert(ret != nullptr); - if (v.isNumber()) { - *ret = v.toInt8(); - return true; - } - if (v.isBoolean()) { - *ret = v.toBoolean() ? 1 : 0; - return true; - } - *ret = 0; - return false; -} - -bool seval_to_uint8(const se::Value &v, uint8_t *ret) { - assert(ret != nullptr); - if (v.isNumber()) { - *ret = v.toUint8(); - return true; - } - if (v.isBoolean()) { - *ret = v.toBoolean() ? 1 : 0; - return true; - } - *ret = 0; - return false; -} - -bool seval_to_int16(const se::Value &v, int16_t *ret) { - assert(ret != nullptr); - if (v.isNumber()) { - *ret = v.toInt16(); - return true; - } - if (v.isBoolean()) { - *ret = v.toBoolean() ? 1 : 0; - return true; - } - *ret = 0; - return false; -} - -bool seval_to_uint16(const se::Value &v, uint16_t *ret) { - assert(ret != nullptr); - if (v.isNumber()) { - *ret = v.toUint16(); - return true; - } - if (v.isBoolean()) { - *ret = v.toBoolean() ? 1 : 0; - return true; - } - *ret = 0; - return false; -} - -bool seval_to_boolean(const se::Value &v, bool *ret) { - assert(ret != nullptr); - if (v.isBoolean()) { - *ret = v.toBoolean(); - } else if (v.isNumber()) { - *ret = v.toInt32() != 0; - } else if (v.isNullOrUndefined()) { - *ret = false; - } else if (v.isObject()) { - *ret = true; - } else if (v.isString()) { - *ret = !v.toString().empty(); - } else { - *ret = false; - assert(false); - } - - return true; -} - -bool seval_to_float(const se::Value &v, float *ret) { - assert(ret != nullptr); - if (v.isNumber()) { - *ret = v.toFloat(); - if (!std::isnan(*ret)) { - return true; - } - } - *ret = 0.0F; - return false; -} - -bool seval_to_double(const se::Value &v, double *ret) { - if (v.isNumber()) { - *ret = v.toDouble(); - if (!std::isnan(*ret)) { - return true; - } - } - *ret = 0.0; - return false; -} - -bool seval_to_size(const se::Value &v, size_t *ret) { - assert(ret != nullptr); - if (v.isNumber()) { - *ret = v.toSize(); - return true; - } - *ret = 0; - return false; -} - -bool seval_to_std_string(const se::Value &v, std::string *ret) { - assert(ret != nullptr); - *ret = v.toStringForce(); - return true; -} - -bool seval_to_Vec2(const se::Value &v, cc::Vec2 *pt) { - assert(pt != nullptr); - SE_PRECONDITION2(v.isObject(), false, "Convert parameter to Vec2 failed!"); - se::Object *obj = v.toObject(); - se::Value x; - se::Value y; - bool ok = obj->getProperty("x", &x); - SE_PRECONDITION3(ok && x.isNumber(), false, *pt = cc::Vec2::ZERO); - ok = obj->getProperty("y", &y); - SE_PRECONDITION3(ok && y.isNumber(), false, *pt = cc::Vec2::ZERO); - pt->x = x.toFloat(); - pt->y = y.toFloat(); - return true; -} - -bool seval_to_mat(const se::Value &v, int length, float *out) { - assert(out != nullptr); - SE_PRECONDITION2(v.isObject(), false, "Convert parameter to Matrix failed!"); - se::Object *obj = v.toObject(); - - se::Value tmp; - char propName[3] = {0}; - for (int i = 0; i < length; ++i) { - snprintf(propName, 3, "m%2d", i); - obj->getProperty(propName, &tmp); - *(out + i) = tmp.toFloat(); - } - - return true; -} - -bool seval_to_Uint8Array(const se::Value &v, uint8_t *ret) { - assert(ret != nullptr); - SE_PRECONDITION2(v.isObject(), false, "Convert parameter to Array failed!"); - se::Object *obj = v.toObject(); - SE_PRECONDITION2(obj->isArray(), false, "Convert parameter to Array failed!"); - - CC_UNUSED bool ok = true; - uint32_t length = 0; - obj->getArrayLength(&length); - se::Value value; - uint8_t data = 0; - for (uint32_t i = 0; i < length; ++i) { - if (obj->getArrayElement(i, &value)) { - ok = seval_to_uint8(value, &data); - SE_PRECONDITION2(ok, false, "Convert parameter to Array failed!"); - ret[i] = data; - } - } - - return true; -} - -bool seval_to_uintptr_t(const se::Value &v, uintptr_t *ret) { - assert(ret != nullptr); - if (v.isNumber()) { - *ret = static_cast(v.toDouble()); - return true; - } - *ret = 0UL; - return false; -} - -bool seval_to_Size(const se::Value &v, cc::Size *size) { - assert(size != nullptr); - SE_PRECONDITION2(v.isObject(), false, "Convert parameter to Size failed!"); - se::Object *obj = v.toObject(); - se::Value width; - se::Value height; - - bool ok = obj->getProperty("width", &width); - SE_PRECONDITION3(ok && width.isNumber(), false, *size = cc::Size::ZERO); - ok = obj->getProperty("height", &height); - SE_PRECONDITION3(ok && height.isNumber(), false, *size = cc::Size::ZERO); - size->width = width.toFloat(); - size->height = height.toFloat(); - return true; -} - -bool seval_to_ccvalue(const se::Value &v, cc::Value *ret) { - assert(ret != nullptr); - bool ok = true; - if (v.isObject()) { - se::Object *jsobj = v.toObject(); - if (!jsobj->isArray()) { - // It's a normal js object. - cc::ValueMap dictVal; - ok = seval_to_ccvaluemap(v, &dictVal); - SE_PRECONDITION3(ok, false, *ret = cc::Value::VALUE_NULL); - *ret = cc::Value(dictVal); - } else { - // It's a js array object. - cc::ValueVector arrVal; - ok = seval_to_ccvaluevector(v, &arrVal); - SE_PRECONDITION3(ok, false, *ret = cc::Value::VALUE_NULL); - *ret = cc::Value(arrVal); - } - } else if (v.isString()) { - *ret = v.toString(); - } else if (v.isNumber()) { - *ret = v.toDouble(); - } else if (v.isBoolean()) { - *ret = v.toBoolean(); - } else if (v.isNullOrUndefined()) { - *ret = cc::Value::VALUE_NULL; - } else { - SE_PRECONDITION2(false, false, "type not supported!"); - } - - return ok; -} - -bool seval_to_ccvaluemap(const se::Value &v, cc::ValueMap *ret) { - assert(ret != nullptr); - - if (v.isNullOrUndefined()) { - ret->clear(); - return true; - } - - SE_PRECONDITION3(v.isObject(), false, ret->clear()); - SE_PRECONDITION3(!v.isNullOrUndefined(), false, ret->clear()); - - se::Object *obj = v.toObject(); - - cc::ValueMap &dict = *ret; - - std::vector allKeys; - SE_PRECONDITION3(obj->getAllKeys(&allKeys), false, ret->clear()); - - bool ok = false; - se::Value value; - cc::Value ccvalue; - for (const auto &key : allKeys) { - SE_PRECONDITION3(obj->getProperty(key.c_str(), &value), false, ret->clear()); - ok = seval_to_ccvalue(value, &ccvalue); - SE_PRECONDITION3(ok, false, ret->clear()); - dict.emplace(key, ccvalue); - } - - return true; -} - -static bool isNumberString(const std::string &str) { - for (const auto &c : str) { - if (!isdigit(c)) { - return false; - } - } - return true; -} - -bool seval_to_ccvaluemapintkey(const se::Value &v, cc::ValueMapIntKey *ret) { - assert(ret != nullptr); - if (v.isNullOrUndefined()) { - ret->clear(); - return true; - } - - SE_PRECONDITION3(v.isObject(), false, ret->clear()); - SE_PRECONDITION3(!v.isNullOrUndefined(), false, ret->clear()); - - se::Object *obj = v.toObject(); - - cc::ValueMapIntKey &dict = *ret; - - std::vector allKeys; - SE_PRECONDITION3(obj->getAllKeys(&allKeys), false, ret->clear()); - - bool ok = false; - se::Value value; - cc::Value ccvalue; - for (const auto &key : allKeys) { - SE_PRECONDITION3(obj->getProperty(key.c_str(), &value), false, ret->clear()); - - if (!isNumberString(key)) { - SE_LOGD("seval_to_ccvaluemapintkey, found not numeric key: %s", key.c_str()); - continue; - } - - int intKey = atoi(key.c_str()); - - ok = seval_to_ccvalue(value, &ccvalue); - SE_PRECONDITION3(ok, false, ret->clear()); - dict.emplace(intKey, ccvalue); - } - - return true; -} - -bool seval_to_ccvaluevector(const se::Value &v, cc::ValueVector *ret) { - assert(ret != nullptr); - - SE_PRECONDITION3(v.isObject(), false, ret->clear()); - - se::Object *obj = v.toObject(); - SE_PRECONDITION3(obj->isArray(), false, ret->clear()); - - uint32_t len = 0; - obj->getArrayLength(&len); - - bool ok = false; - se::Value value; - cc::Value ccvalue; - for (uint32_t i = 0; i < len; ++i) { - if (obj->getArrayElement(i, &value)) { - ok = seval_to_ccvalue(value, &ccvalue); - SE_PRECONDITION3(ok, false, ret->clear()); - ret->push_back(ccvalue); - } - } - - return true; -} - -bool sevals_variadic_to_ccvaluevector(const se::ValueArray &args, cc::ValueVector *ret) { - bool ok = false; - cc::Value ccvalue; - - for (const auto &arg : args) { - ok = seval_to_ccvalue(arg, &ccvalue); - SE_PRECONDITION3(ok, false, ret->clear()); - ret->push_back(ccvalue); - } - - return true; -} - -bool seval_to_std_vector_string(const se::Value &v, std::vector *ret) { - assert(ret != nullptr); - SE_PRECONDITION2(v.isObject(), false, "Convert parameter to vector of String failed!"); - se::Object *obj = v.toObject(); - SE_PRECONDITION2(obj->isArray(), false, "Convert parameter to vector of String failed!"); - uint32_t len = 0; - if (obj->getArrayLength(&len)) { - se::Value value; - for (uint32_t i = 0; i < len; ++i) { - SE_PRECONDITION3(obj->getArrayElement(i, &value) && value.isString(), false, ret->clear()); - ret->push_back(value.toString()); - } - return true; - } - - ret->clear(); - return true; -} - -bool seval_to_std_vector_int(const se::Value &v, std::vector *ret) { - assert(ret != nullptr); - SE_PRECONDITION2(v.isObject(), false, "Convert parameter to vector of int failed!"); - se::Object *obj = v.toObject(); - - if (obj->isArray()) { - uint32_t len = 0; - if (obj->getArrayLength(&len)) { - se::Value value; - for (uint32_t i = 0; i < len; ++i) { - SE_PRECONDITION3(obj->getArrayElement(i, &value) && value.isNumber(), false, ret->clear()); - ret->push_back(value.toInt32()); - } - return true; - } - } else if (obj->isTypedArray()) { - size_t bytesPerElements = 0; - uint8_t * data = nullptr; - size_t dataBytes = 0; - se::Object::TypedArrayType type = obj->getTypedArrayType(); - -#define SE_UINT8_PTR_TO_INT(ptr) (*((uint8_t *)(ptr))) -#define SE_UINT16_PTR_TO_INT(ptr) (*((uint16_t *)(ptr))) -#define SE_UINT32_PTR_TO_INT(ptr) (*((uint32_t *)(ptr))) - - if (obj->getTypedArrayData(&data, &dataBytes)) { - for (size_t i = 0; i < dataBytes; i += bytesPerElements) { - switch (type) { - case se::Object::TypedArrayType::INT8: - case se::Object::TypedArrayType::UINT8: - case se::Object::TypedArrayType::UINT8_CLAMPED: - ret->push_back(SE_UINT8_PTR_TO_INT(data + i)); - bytesPerElements = 1; - break; - case se::Object::TypedArrayType::INT16: - case se::Object::TypedArrayType::UINT16: - ret->push_back(SE_UINT16_PTR_TO_INT(data + i)); - bytesPerElements = 2; - break; - case se::Object::TypedArrayType::INT32: - case se::Object::TypedArrayType::UINT32: - ret->push_back(SE_UINT32_PTR_TO_INT(data + i)); - bytesPerElements = 4; - break; - default: - SE_LOGE("Unsupported typed array: %d\n", (int)type); - assert(false); - break; - } - } - } - -#undef SE_UINT8_PTR_TO_INT -#undef SE_UINT16_PTR_TO_INT -#undef SE_UINT32_PTR_TO_INT - - return true; - } else { - assert(false); - } - - ret->clear(); - return true; -} - -bool seval_to_std_vector_uint16(const se::Value &v, std::vector *ret) { - assert(ret != nullptr); - SE_PRECONDITION2(v.isObject(), false, "Convert parameter to vector of uint16 failed!"); - se::Object *obj = v.toObject(); - - if (obj->isArray()) { - uint32_t len = 0; - if (obj->getArrayLength(&len)) { - se::Value value; - for (uint32_t i = 0; i < len; ++i) { - SE_PRECONDITION3(obj->getArrayElement(i, &value) && value.isNumber(), false, ret->clear()); - ret->push_back(value.toUint16()); - } - return true; - } - } else if (obj->isTypedArray()) { - size_t bytesPerElements = 0; - uint8_t * data = nullptr; - size_t dataBytes = 0; - se::Object::TypedArrayType type = obj->getTypedArrayType(); - - if (obj->getTypedArrayData(&data, &dataBytes)) { - for (size_t i = 0; i < dataBytes; i += bytesPerElements) { - switch (type) { - case se::Object::TypedArrayType::INT16: - case se::Object::TypedArrayType::UINT16: - ret->push_back(*(reinterpret_cast(data + i))); - bytesPerElements = 2; - break; - default: - SE_LOGE("Unsupported typed array: %d\n", (int)type); - assert(false); - break; - } - } - } - return true; - } else { - assert(false); - } - ret->clear(); - return true; -} - -bool seval_to_std_vector_float(const se::Value &v, std::vector *ret) { - assert(ret != nullptr); - SE_PRECONDITION2(v.isObject(), false, "Convert parameter to vector of float failed!"); - se::Object *obj = v.toObject(); - SE_PRECONDITION2(obj->isArray(), false, "Convert parameter to vector of float failed!"); - uint32_t len = 0; - if (obj->getArrayLength(&len)) { - se::Value value; - for (uint32_t i = 0; i < len; ++i) { - SE_PRECONDITION3(obj->getArrayElement(i, &value) && value.isNumber(), false, ret->clear()); - ret->push_back(value.toFloat()); - } - return true; - } - - ret->clear(); - return true; -} - -bool seval_to_std_vector_Vec2(const se::Value &v, std::vector *ret) { - assert(ret != nullptr); - SE_PRECONDITION2(v.isObject(), false, "Convert parameter to vector of Vec2 failed!"); - se::Object *obj = v.toObject(); - SE_PRECONDITION2(obj->isArray(), false, "Convert parameter to vector of Vec2 failed!"); - uint32_t len = 0; - if (obj->getArrayLength(&len)) { - se::Value value; - cc::Vec2 pt; - for (uint32_t i = 0; i < len; ++i) { - SE_PRECONDITION3(obj->getArrayElement(i, &value) && seval_to_Vec2(value, &pt), false, ret->clear()); - ret->push_back(pt); - } - return true; - } - - ret->clear(); - return true; -} - -bool seval_to_std_map_string_string(const se::Value &v, std::map *ret) { - assert(ret != nullptr); - - if (v.isNullOrUndefined()) { - ret->clear(); - return true; - } - - SE_PRECONDITION2(v.isObject(), false, "Convert parameter to map of String to String failed!"); - SE_PRECONDITION3(!v.isNullOrUndefined(), false, ret->clear()); - - se::Object *obj = v.toObject(); - - std::vector allKeys; - SE_PRECONDITION3(obj->getAllKeys(&allKeys), false, ret->clear()); - - bool ok = false; - se::Value value; - std::string strValue; - for (const auto &key : allKeys) { - SE_PRECONDITION3(obj->getProperty(key.c_str(), &value), false, ret->clear()); - ok = seval_to_std_string(value, &strValue); - SE_PRECONDITION3(ok, false, ret->clear()); - ret->emplace(key, strValue); - } - - return true; -} - -bool seval_to_Data(const se::Value &v, cc::Data *ret) { - assert(ret != nullptr); - SE_PRECONDITION2(v.isObject() && v.toObject()->isTypedArray(), false, "Convert parameter to Data failed!"); - uint8_t *ptr = nullptr; - size_t length = 0; - bool ok = v.toObject()->getTypedArrayData(&ptr, &length); - if (ok) { - ret->copy(ptr, length); - } else { - ret->clear(); - } - - return ok; -} - -bool seval_to_DownloaderHints(const se::Value &v, cc::network::DownloaderHints *ret) { - const static cc::network::DownloaderHints ZERO{0, 0, ""}; - assert(ret != nullptr); - SE_PRECONDITION2(v.isObject(), false, "Convert parameter to DownloaderHints failed!"); - se::Value tmp; - se::Object *obj = v.toObject(); - bool ok = false; - - ok = obj->getProperty("countOfMaxProcessingTasks", &tmp); - SE_PRECONDITION3(ok && tmp.isNumber(), false, *ret = ZERO); - ret->countOfMaxProcessingTasks = tmp.toUint32(); - - ok = obj->getProperty("timeoutInSeconds", &tmp); - SE_PRECONDITION3(ok && tmp.isNumber(), false, *ret = ZERO); - ret->timeoutInSeconds = tmp.toUint32(); - - ok = obj->getProperty("tempFileNameSuffix", &tmp); - SE_PRECONDITION3(ok && tmp.isString(), false, *ret = ZERO); - ret->tempFileNameSuffix = tmp.toString(); - - return ok; -} - -////////////////////////////////////////////////////////////////////////////////// -// native to seval - -bool int32_to_seval(int32_t v, se::Value *ret) { - ret->setInt32(v); - return true; -} - -bool uint32_to_seval(uint32_t v, se::Value *ret) { - ret->setUint32(v); - return true; -} - -bool int16_to_seval(uint16_t v, se::Value *ret) { - ret->setInt16(v); - return true; -} - -bool uint16_to_seval(uint16_t v, se::Value *ret) { - ret->setUint16(v); - return true; -} - -bool int8_to_seval(int8_t v, se::Value *ret) { - ret->setInt8(v); - return true; -} - -bool uint8_to_seval(uint8_t v, se::Value *ret) { - ret->setUint8(v); - return true; -} - -bool boolean_to_seval(bool v, se::Value *ret) { - ret->setBoolean(v); - return true; -} - -bool float_to_seval(float v, se::Value *ret) { - ret->setFloat(v); - return true; -} - -bool double_to_seval(double v, se::Value *ret) { - ret->setDouble(v); - return true; -} - -bool uintptr_t_to_seval(uintptr_t v, se::Value *ret) { - ret->setDouble(v); - return true; -} - -bool size_to_seval(size_t v, se::Value *ret) { - ret->setSize(v); - return true; -} - -bool std_string_to_seval(const std::string &v, se::Value *ret) { - ret->setString(v); - return true; -} - -bool Vec2_to_seval(const cc::Vec2 &v, se::Value *ret) { - assert(ret != nullptr); - se::HandleObject obj(se::Object::createPlainObject()); - obj->setProperty("x", se::Value(v.x)); - obj->setProperty("y", se::Value(v.y)); - ret->setObject(obj); - - return true; -} - -bool Vec3_to_seval(const cc::Vec3 &v, se::Value *ret) { - assert(ret != nullptr); - se::HandleObject obj(se::Object::createPlainObject()); - obj->setProperty("x", se::Value(v.x)); - obj->setProperty("y", se::Value(v.y)); - obj->setProperty("z", se::Value(v.z)); - ret->setObject(obj); - - return true; -} - -bool Vec4_to_seval(const cc::Vec4 &v, se::Value *ret) { - assert(ret != nullptr); - se::HandleObject obj(se::Object::createPlainObject()); - obj->setProperty("x", se::Value(v.x)); - obj->setProperty("y", se::Value(v.y)); - obj->setProperty("z", se::Value(v.z)); - obj->setProperty("w", se::Value(v.w)); - ret->setObject(obj); - - return true; -} - -bool Mat4_to_seval(const cc::Mat4 &v, se::Value *ret) { - assert(ret != nullptr); - se::HandleObject obj(se::Object::createArrayObject(16)); - - for (uint8_t i = 0; i < 16; ++i) { - obj->setArrayElement(i, se::Value(v.m[i])); - } - - ret->setObject(obj); - return true; -} - -bool Size_to_seval(const cc::Size &v, se::Value *ret) { - assert(ret != nullptr); - se::HandleObject obj(se::Object::createPlainObject()); - obj->setProperty("width", se::Value(v.width)); - obj->setProperty("height", se::Value(v.height)); - ret->setObject(obj); - return true; -} - -bool Rect_to_seval(const cc::Rect &v, se::Value *ret) { - assert(ret != nullptr); - se::HandleObject obj(se::Object::createPlainObject()); - obj->setProperty("x", se::Value(v.origin.x)); - obj->setProperty("y", se::Value(v.origin.y)); - obj->setProperty("width", se::Value(v.size.width)); - obj->setProperty("height", se::Value(v.size.height)); - ret->setObject(obj); - - return true; -} - -bool ccvalue_to_seval(const cc::Value &v, se::Value *ret) { - assert(ret != nullptr); - bool ok = true; - switch (v.getType()) { - case cc::Value::Type::NONE: - ret->setNull(); - break; - case cc::Value::Type::UNSIGNED: - ret->setUint32(v.asUnsignedInt()); - break; - case cc::Value::Type::BOOLEAN: - ret->setBoolean(v.asBool()); - break; - case cc::Value::Type::FLOAT: - case cc::Value::Type::DOUBLE: - ret->setDouble(v.asDouble()); - break; - case cc::Value::Type::INTEGER: - ret->setInt32(v.asInt()); - break; - case cc::Value::Type::STRING: - ret->setString(v.asString()); - break; - case cc::Value::Type::VECTOR: - ok = ccvaluevector_to_seval(v.asValueVector(), ret); - break; - case cc::Value::Type::MAP: - ok = ccvaluemap_to_seval(v.asValueMap(), ret); - break; - case cc::Value::Type::INT_KEY_MAP: - ok = ccvaluemapintkey_to_seval(v.asIntKeyMap(), ret); - break; - default: - SE_LOGE("Could not the way to convert cc::Value::Type (%d) type!", (int)v.getType()); - ok = false; - break; - } - - return ok; -} - -bool ccvaluemap_to_seval(const cc::ValueMap &v, se::Value *ret) { - assert(ret != nullptr); - - se::HandleObject obj(se::Object::createPlainObject()); - bool ok = true; - for (const auto &e : v) { - const std::string &key = e.first; - const cc::Value & value = e.second; - - if (key.empty()) { - continue; - } - - se::Value tmp; - if (!ccvalue_to_seval(value, &tmp)) { - ok = false; - ret->setUndefined(); - break; - } - - obj->setProperty(key.c_str(), tmp); - } - if (ok) { - ret->setObject(obj); - } - - return ok; -} - -bool ccvaluemapintkey_to_seval(const cc::ValueMapIntKey &v, se::Value *ret) { - assert(ret != nullptr); - - se::HandleObject obj(se::Object::createPlainObject()); - bool ok = true; - for (const auto &e : v) { - std::stringstream keyss; - keyss << e.first; - std::string key = keyss.str(); - const cc::Value &value = e.second; - - if (key.empty()) { - continue; - } - - se::Value tmp; - if (!ccvalue_to_seval(value, &tmp)) { - ok = false; - ret->setUndefined(); - break; - } - - obj->setProperty(key.c_str(), tmp); - } - if (ok) { - ret->setObject(obj); - } - - return ok; -} - -bool ccvaluevector_to_seval(const cc::ValueVector &v, se::Value *ret) { - assert(ret != nullptr); - se::HandleObject obj(se::Object::createArrayObject(v.size())); - bool ok = true; - - uint32_t i = 0; - for (const auto &value : v) { - se::Value tmp; - if (!ccvalue_to_seval(value, &tmp)) { - ok = false; - ret->setUndefined(); - break; - } - - obj->setArrayElement(i, tmp); - ++i; - } - if (ok) { - ret->setObject(obj); - } - - return ok; -} - -namespace { - -template -bool std_vector_T_to_seval(const std::vector &v, se::Value *ret) { - assert(ret != nullptr); - se::HandleObject obj(se::Object::createArrayObject(v.size())); - bool ok = true; - - uint32_t i = 0; - for (const auto &value : v) { - if (!obj->setArrayElement(i, se::Value(value))) { - ok = false; - ret->setUndefined(); - break; - } - ++i; - } - - if (ok) { - ret->setObject(obj); - } - - return ok; -} - -} // namespace - -bool std_vector_string_to_seval(const std::vector &v, se::Value *ret) { - return std_vector_T_to_seval(v, ret); -} - -bool std_vector_int_to_seval(const std::vector &v, se::Value *ret) { - return std_vector_T_to_seval(v, ret); -} - -bool std_vector_uint16_to_seval(const std::vector &v, se::Value *ret) { - return std_vector_T_to_seval(v, ret); -} - -bool std_vector_float_to_seval(const std::vector &v, se::Value *ret) { - return std_vector_T_to_seval(v, ret); -} - -bool std_map_string_string_to_seval(const std::map &v, se::Value *ret) { - assert(ret != nullptr); - - se::HandleObject obj(se::Object::createPlainObject()); - bool ok = true; - for (const auto &e : v) { - const std::string &key = e.first; - const std::string &value = e.second; - - if (key.empty()) { - continue; - } - - se::Value tmp; - if (!std_string_to_seval(value, &tmp)) { - ok = false; - ret->setUndefined(); - break; - } - - obj->setProperty(key.c_str(), tmp); - } - - if (ok) { - ret->setObject(obj); - } - - return ok; -} - -namespace { -enum class DataType { - INT, - FLOAT -}; - -void toVec2(void *data, DataType type, se::Value *ret) { - auto * intptr = static_cast(data); - auto * floatptr = static_cast(data); - cc::Vec2 vec2; - if (DataType::INT == type) { - vec2.x = static_cast(intptr[0]); - vec2.y = static_cast(intptr[1]); - } else { - vec2.x = *floatptr; - vec2.y = *(floatptr + 1); - } - - Vec2_to_seval(vec2, ret); -} - -void toVec3(void *data, DataType type, se::Value *ret) { - auto * intptr = static_cast(data); - auto * floatptr = static_cast(data); - cc::Vec3 vec3; - if (DataType::INT == type) { - vec3.x = static_cast(intptr[0]); - vec3.y = static_cast(intptr[1]); - vec3.z = static_cast(intptr[2]); - } else { - vec3.x = floatptr[0]; - vec3.y = floatptr[1]; - vec3.z = floatptr[2]; - } - - Vec3_to_seval(vec3, ret); -} - -void toVec4(void *data, DataType type, se::Value *ret) { - auto * intptr = static_cast(data); - auto * floatptr = static_cast(data); - cc::Vec4 vec4; - if (DataType::INT == type) { - vec4.x = static_cast(intptr[0]); - vec4.y = static_cast(intptr[1]); - vec4.z = static_cast(intptr[2]); - vec4.w = static_cast(intptr[3]); - } else { - vec4.x = *floatptr; - vec4.y = *(floatptr + 1); - vec4.z = *(floatptr + 2); - vec4.w = *(floatptr + 3); - } - - Vec4_to_seval(vec4, ret); -} - -void toMat(float *data, int num, se::Value *ret) { - se::HandleObject obj(se::Object::createPlainObject()); - - char propName[4] = {0}; - for (int i = 0; i < num; ++i) { - if (i < 10) { - snprintf(propName, 3, "m0%d", i); - } - - else { - snprintf(propName, 3, "m%d", i); - } - - obj->setProperty(propName, se::Value(*(data + i))); - } - ret->setObject(obj); -} -} // namespace - -bool ManifestAsset_to_seval(const cc::extension::ManifestAsset &v, se::Value *ret) { - assert(ret != nullptr); - se::HandleObject obj(se::Object::createPlainObject()); - obj->setProperty("md5", se::Value(v.md5)); - obj->setProperty("path", se::Value(v.path)); - obj->setProperty("compressed", se::Value(v.compressed)); - obj->setProperty("size", se::Value(v.size)); - obj->setProperty("downloadState", se::Value(v.downloadState)); - ret->setObject(obj); - - return true; -} - -bool Data_to_seval(const cc::Data &v, se::Value *ret) { - assert(ret != nullptr); - if (v.isNull()) { - ret->setNull(); - } else { - se::HandleObject obj(se::Object::createTypedArray(se::Object::TypedArrayType::UINT8, v.getBytes(), v.getSize())); - ret->setObject(obj, true); - } - return true; -} - -bool DownloadTask_to_seval(const cc::network::DownloadTask &v, se::Value *ret) { - assert(ret != nullptr); - - se::HandleObject obj(se::Object::createPlainObject()); - obj->setProperty("identifier", se::Value(v.identifier)); - obj->setProperty("requestURL", se::Value(v.requestURL)); - obj->setProperty("storagePath", se::Value(v.storagePath)); - ret->setObject(obj); - - return true; -} - -////////////////// custom types - -template <> -bool nativevalue_to_se(const cc::Data &from, se::Value &to, se::Object * /*unused*/) { - se::Object *buffer = se::Object::createArrayBufferObject(from.getBytes(), from.getSize()); - to.setObject(buffer); - return true; -} - -template <> -bool nativevalue_to_se(const cc::Value &from, se::Value &to, se::Object * /*unused*/) { - return ccvalue_to_seval(from, &to); -} - -template <> -bool nativevalue_to_se(const std::unordered_map &from, se::Value &to, se::Object * /*unused*/) { - return ccvaluemap_to_seval(from, &to); -} - -template <> -bool nativevalue_to_se(const cc::Vec4 &from, se::Value &to, se::Object * /*unused*/) { - return Vec4_to_seval(from, &to); -} - -template <> -bool nativevalue_to_se(const cc::Vec2 &from, se::Value &to, se::Object * /*unused*/) { - return Vec2_to_seval(from, &to); -} - -template <> -bool nativevalue_to_se(const cc::Vec3 &from, se::Value &to, se::Object * /*unused*/) { - return Vec3_to_seval(from, &to); -} - -template <> -bool nativevalue_to_se(const cc::Size &from, se::Value &to, se::Object * /*unused*/) { - return Size_to_seval(from, &to); -} - -template <> -bool nativevalue_to_se(const cc::extension::ManifestAsset &from, se::Value &to, se::Object * /*unused*/) { - return ManifestAsset_to_seval(from, &to); -} - -template <> -bool nativevalue_to_se(const cc::Rect &from, se::Value &to, se::Object * /*unused*/) { - return Rect_to_seval(from, &to); -} - -template <> -bool sevalue_to_native(const se::Value &from, cc::Vec4 *to, se::Object * /*unused*/) { - SE_PRECONDITION2(from.isObject(), false, "Convert parameter to Vec4 failed!"); - se::Object *obj = from.toObject(); - se::Value x; - se::Value y; - se::Value z; - se::Value w; - bool ok = obj->getProperty("x", &x); - SE_PRECONDITION3(ok && x.isNumber(), false, *to = cc::Vec4::ZERO); - ok = obj->getProperty("y", &y); - SE_PRECONDITION3(ok && y.isNumber(), false, *to = cc::Vec4::ZERO); - ok = obj->getProperty("z", &z); - SE_PRECONDITION3(ok && z.isNumber(), false, *to = cc::Vec4::ZERO); - ok = obj->getProperty("w", &w); - SE_PRECONDITION3(ok && w.isNumber(), false, *to = cc::Vec4::ZERO); - to->x = x.toFloat(); - to->y = y.toFloat(); - to->z = z.toFloat(); - to->w = w.toFloat(); - return true; -} - -template <> -bool sevalue_to_native(const se::Value &from, cc::Mat4 *to, se::Object * /*unused*/) { - SE_PRECONDITION2(from.isObject(), false, "Convert parameter to Matrix4 failed!"); - se::Object *obj = from.toObject(); - - if (obj->isTypedArray()) { - // typed array - SE_PRECONDITION2(obj->isTypedArray(), false, "Convert parameter to Matrix4 failed!"); - - size_t length = 0; - uint8_t *ptr = nullptr; - obj->getTypedArrayData(&ptr, &length); - - memcpy(to->m, ptr, length); - } else { - bool ok = false; - se::Value tmp; - std::string prefix = "m"; - for (uint32_t i = 0; i < 16; ++i) { - std::string name; - if (i < 10) { - name = prefix + "0" + std::to_string(i); - } else { - name = prefix + std::to_string(i); - } - ok = obj->getProperty(name.c_str(), &tmp); - SE_PRECONDITION3(ok, false, *to = cc::Mat4::IDENTITY); - - if (tmp.isNumber()) { - to->m[i] = tmp.toFloat(); - } else { - SE_REPORT_ERROR("%u, not supported type in matrix", i); - *to = cc::Mat4::IDENTITY; - return false; - } - - tmp.setUndefined(); - } - } - - return true; -} - -template <> -bool sevalue_to_native(const se::Value &from, cc::Vec3 *to, se::Object * /*unused*/) { - SE_PRECONDITION2(from.isObject(), false, "Convert parameter to Vec3 failed!"); - if (!from.isObject()) { - } - se::Object *obj = from.toObject(); - se::Value x; - se::Value y; - se::Value z; - bool ok = obj->getProperty("x", &x); - SE_PRECONDITION3(ok && x.isNumber(), false, *to = cc::Vec3::ZERO); - ok = obj->getProperty("y", &y); - SE_PRECONDITION3(ok && y.isNumber(), false, *to = cc::Vec3::ZERO); - ok = obj->getProperty("z", &z); - SE_PRECONDITION3(ok && z.isNumber(), false, *to = cc::Vec3::ZERO); - to->x = x.toFloat(); - to->y = y.toFloat(); - to->z = z.toFloat(); - return true; -} - -template <> -bool sevalue_to_native(const se::Value &from, cc::Vec2 *to, se::Object * /*unused*/) { - SE_PRECONDITION2(from.isObject(), false, "Convert parameter to Vec2 failed!"); - if (!from.isObject()) { - } - se::Object *obj = from.toObject(); - se::Value x; - se::Value y; - bool ok = obj->getProperty("x", &x); - SE_PRECONDITION3(ok && x.isNumber(), false, *to = cc::Vec2::ZERO); - ok = obj->getProperty("y", &y); - SE_PRECONDITION3(ok && y.isNumber(), false, *to = cc::Vec2::ZERO); - to->x = x.toFloat(); - to->y = y.toFloat(); - return true; -} - -template <> -bool sevalue_to_native(const se::Value &from, cc::Quaternion *to, se::Object * /*unused*/) { - SE_PRECONDITION2(from.isObject(), false, "Convert parameter to Quaternion failed!"); - if (!from.isObject()) { - } - se::Object *obj = from.toObject(); - se::Value x; - se::Value y; - se::Value z; - se::Value w; - bool ok = obj->getProperty("x", &x); - SE_PRECONDITION3(ok && x.isNumber(), false, *to = cc::Quaternion::ZERO); - ok = obj->getProperty("y", &y); - SE_PRECONDITION3(ok && y.isNumber(), false, *to = cc::Quaternion::ZERO); - ok = obj->getProperty("z", &z); - SE_PRECONDITION3(ok && z.isNumber(), false, *to = cc::Quaternion::ZERO); - ok = obj->getProperty("w", &w); - SE_PRECONDITION3(ok && w.isNumber(), false, *to = cc::Quaternion::ZERO); - to->x = x.toFloat(); - to->y = y.toFloat(); - to->z = z.toFloat(); - to->w = w.toFloat(); - return true; -} - -#if USE_SPINE - -template <> -bool sevalue_to_native(const se::Value &val, spine::String *obj, se::Object * /*unused*/) { - *obj = val.toString().data(); - return true; -} - -template <> -bool sevalue_to_native(const se::Value &v, spine::Vector *ret, se::Object * /*unused*/) { - assert(v.isObject()); - se::Object *obj = v.toObject(); - assert(obj->isArray()); - - bool ok = true; - uint32_t len = 0; - ok = obj->getArrayLength(&len); - if (!ok) { - ret->clear(); - return false; - } - - se::Value tmp; - for (uint32_t i = 0; i < len; ++i) { - ok = obj->getArrayElement(i, &tmp); - if (!ok || !tmp.isObject()) { - ret->clear(); - return false; - } - - const char *str = tmp.toString().c_str(); - ret->add(str); - } - - return true; -} - -template <> -bool nativevalue_to_se(const spine::String &obj, se::Value &val, se::Object * /*unused*/) { - val.setString(obj.buffer()); - return true; -} - -template <> -bool nativevalue_to_se(const spine::Vector &v, se::Value &ret, se::Object * /*unused*/) { - se::HandleObject obj(se::Object::createArrayObject(v.size())); - bool ok = true; - - spine::Vector tmpv = v; - for (uint32_t i = 0, count = static_cast(tmpv.size()); i < count; i++) { - if (!obj->setArrayElement(i, se::Value(tmpv[i].buffer()))) { - ok = false; - ret.setUndefined(); - break; - } - } - - if (ok) { - ret.setObject(obj); - } - - return ok; -} - -template <> -bool seval_to_Map_string_key(const se::Value &v, cc::Map *ret) { - assert(ret != nullptr); - assert(v.isObject()); - se::Object *obj = v.toObject(); - - std::vector allKeys; - bool ok = obj->getAllKeys(&allKeys); - if (!ok) { - ret->clear(); - return false; - } - - se::Value tmp; - for (const auto &key : allKeys) { - auto pngPos = key.find(".png"); - if (pngPos == std::string::npos) { - continue; - } - - ok = obj->getProperty(key.c_str(), &tmp); - if (!ok || !tmp.isObject()) { - ret->clear(); - return false; - } - - auto *nativeObj = static_cast(tmp.toObject()->getPrivateData()); - ret->insert(key, nativeObj); - } - - return true; -} - -#endif diff --git a/native/cocos/bindings/manual/jsb_conversions.h b/native/cocos/bindings/manual/jsb_conversions.h index c261e5b2cb..53c010992d 100644 --- a/native/cocos/bindings/manual/jsb_conversions.h +++ b/native/cocos/bindings/manual/jsb_conversions.h @@ -27,77 +27,44 @@ #include #include +#include #include +#include +#include "base/Ptr.h" +#include "base/RefCounted.h" +#include "bindings/jswrapper/HandleObject.h" #include "bindings/jswrapper/SeApi.h" #include "bindings/manual/jsb_classtype.h" -#include "cocos/base/Map.h" -#include "cocos/base/Vector.h" -#include "cocos/math/Geometry.h" -#include "cocos/math/Quaternion.h" -#include "cocos/math/Vec2.h" -#include "cocos/math/Vec3.h" -#include "extensions/cocos-ext.h" -#include "network/Downloader.h" +#include "cocos/base/Any.h" +#include "cocos/base/Optional.h" +#include "cocos/base/Variant.h" + +#include "jsb_conversions_spec.h" #if USE_SPINE #include "cocos/editor-support/spine-creator-support/spine-cocos2dx.h" #endif -namespace cc { -namespace gfx { -struct Rect; -struct Viewport; -struct Color; -struct Offset; -struct Extent; -struct TextureSubres; -struct TextureCopy; -struct BufferTextureCopy; -struct BufferInfo; -struct BufferViewInfo; -struct TextureInfo; -struct DescriptorSetInfo; -struct BindingMappingInfo; -struct ShaderStage; -struct UniformSampler; -struct UniformBlock; -struct Uniform; -struct ShaderInfo; -struct DrawInfo; -struct IndirectBuffer; -struct SamplerInfo; -struct ColorAttachment; -struct DepthStencilAttachment; -struct SubPassInfo; -struct RenderPassInfo; -struct QueueInfo; -struct PipelineLayoutInfo; -struct DescriptorSetLayoutBinding; -struct DescriptorSetLayoutInfo; -struct FramebufferInfo; -struct CommandBufferInfo; -struct InputAssemblerInfo; -} // namespace gfx -} // namespace cc +#include "core/geometry/Geometry.h" +#include "math/Color.h" +#include "math/Math.h" -//#include "Box2D/Box2D.h" - -#define SE_PRECONDITION2_VOID(condition, ...) \ - do { \ - if (!(condition)) { \ - SE_LOGE("jsb: ERROR: File %s: Line: %d, Function: %s\n", __FILE__, __LINE__, __FUNCTION__); \ - SE_LOGE(__VA_ARGS__); \ - return; \ - } \ +#define SE_PRECONDITION2_VOID(condition, ...) \ + do { \ + if (!(condition)) { \ + CC_LOG_ERROR("jsb: ERROR: File %s: Line: %d, Function: %s\n", __FILE__, __LINE__, __FUNCTION__); \ + CC_LOG_ERROR(__VA_ARGS__); \ + return; \ + } \ } while (0) -#define SE_PRECONDITION2(condition, ret_value, ...) \ - do { \ - if (!(condition)) { \ - SE_LOGE("jsb: ERROR: File %s: Line: %d, Function: %s\n", __FILE__, __LINE__, __FUNCTION__); \ - SE_LOGE(__VA_ARGS__); \ - return (ret_value); \ - } \ +#define SE_PRECONDITION2(condition, ret_value, ...) \ + do { \ + if (!(condition)) { \ + CC_LOG_ERROR("jsb: ERROR: File %s: Line: %d, Function: %s\n", __FILE__, __LINE__, __FUNCTION__); \ + CC_LOG_ERROR(__VA_ARGS__); \ + return (ret_value); \ + } \ } while (0) #define SE_PRECONDITION3(condition, ret_value, failed_code) \ @@ -108,20 +75,20 @@ struct InputAssemblerInfo; } \ } while (0) -#define SE_PRECONDITION4(condition, ret_value, errorCode) \ - do { \ - if (!(condition)) { \ - SE_LOGE("jsb: ERROR: File %s: Line: %d, Function: %s\n", __FILE__, __LINE__, __FUNCTION__); \ - __glErrorCode = errorCode; \ - return (ret_value); \ - } \ +#define SE_PRECONDITION4(condition, ret_value, errorCode) \ + do { \ + if (!(condition)) { \ + CC_LOG_ERROR("jsb: ERROR: File %s: Line: %d, Function: %s\n", __FILE__, __LINE__, __FUNCTION__); \ + __glErrorCode = errorCode; \ + return (ret_value); \ + } \ } while (0) -#define SE_PRECONDITION_ERROR_BREAK(condition, ...) \ - if (!(condition)) { \ - SE_LOGE("jsb: ERROR: File %s: Line: %d, Function: %s\n", __FILE__, __LINE__, __FUNCTION__); \ - SE_LOGE(__VA_ARGS__); \ - break; \ +#define SE_PRECONDITION_ERROR_BREAK(condition, ...) \ + if (!(condition)) { \ + CC_LOG_ERROR("jsb: ERROR: File %s: Line: %d, Function: %s\n", __FILE__, __LINE__, __FUNCTION__); \ + CC_LOG_ERROR(__VA_ARGS__); \ + break; \ } #if CC_ENABLE_CACHE_JSB_FUNC_RESULT @@ -159,40 +126,6 @@ struct InputAssemblerInfo; #pragma clang diagnostic ignored "-Wc++17-extensions" #endif -// se value -> native value -bool seval_to_int32(const se::Value &v, int32_t *ret); // NOLINT(readability-identifier-naming) -bool seval_to_uint32(const se::Value &v, uint32_t *ret); // NOLINT(readability-identifier-naming) -bool seval_to_int8(const se::Value &v, int8_t *ret); // NOLINT(readability-identifier-naming) -bool seval_to_uint8(const se::Value &v, uint8_t *ret); // NOLINT(readability-identifier-naming) -bool seval_to_int16(const se::Value &v, int16_t *ret); // NOLINT(readability-identifier-naming) -bool seval_to_uint16(const se::Value &v, uint16_t *ret); // NOLINT(readability-identifier-naming) -bool seval_to_boolean(const se::Value &v, bool *ret); // NOLINT(readability-identifier-naming) -bool seval_to_float(const se::Value &v, float *ret); // NOLINT(readability-identifier-naming) -bool seval_to_double(const se::Value &v, double *ret); // NOLINT(readability-identifier-naming) -bool seval_to_size(const se::Value &v, size_t *ret); // NOLINT(readability-identifier-naming) -bool seval_to_std_string(const se::Value &v, std::string *ret); // NOLINT(readability-identifier-naming) -bool seval_to_Vec2(const se::Value &v, cc::Vec2 *pt); // NOLINT(readability-identifier-naming) -bool seval_to_Vec3(const se::Value &v, cc::Vec3 *pt); // NOLINT(readability-identifier-naming) -bool seval_to_Vec4(const se::Value &v, cc::Vec4 *pt); // NOLINT(readability-identifier-naming) -bool seval_to_Mat4(const se::Value &v, cc::Mat4 *mat); // NOLINT(readability-identifier-naming) -bool seval_to_Size(const se::Value &v, cc::Size *size); // NOLINT(readability-identifier-naming) -bool seval_to_ccvalue(const se::Value &v, cc::Value *ret); // NOLINT(readability-identifier-naming) -bool seval_to_ccvaluemap(const se::Value &v, cc::ValueMap *ret); // NOLINT(readability-identifier-naming) -bool seval_to_ccvaluemapintkey(const se::Value &v, cc::ValueMapIntKey *ret); // NOLINT(readability-identifier-naming) -bool seval_to_ccvaluevector(const se::Value &v, cc::ValueVector *ret); // NOLINT(readability-identifier-naming) -bool sevals_variadic_to_ccvaluevector(const se::ValueArray &args, cc::ValueVector *ret); // NOLINT(readability-identifier-naming) -bool seval_to_std_vector_string(const se::Value &v, std::vector *ret); // NOLINT(readability-identifier-naming) -bool seval_to_std_vector_int(const se::Value &v, std::vector *ret); // NOLINT(readability-identifier-naming) -bool seval_to_std_vector_uint16(const se::Value &v, std::vector *ret); // NOLINT(readability-identifier-naming) -bool seval_to_std_vector_float(const se::Value &v, std::vector *ret); // NOLINT(readability-identifier-naming) -bool seval_to_std_vector_Vec2(const se::Value &v, std::vector *ret); // NOLINT(readability-identifier-naming) -bool seval_to_Uint8Array(const se::Value &v, uint8_t *ret); // NOLINT(readability-identifier-naming) -bool seval_to_uintptr_t(const se::Value &v, uintptr_t *ret); // NOLINT(readability-identifier-naming) - -bool seval_to_std_map_string_string(const se::Value &v, std::map *ret); // NOLINT(readability-identifier-naming) -bool seval_to_Data(const se::Value &v, cc::Data *ret); // NOLINT(readability-identifier-naming) -bool seval_to_DownloaderHints(const se::Value &v, cc::network::DownloaderHints *ret); // NOLINT(readability-identifier-naming) - template bool seval_to_native_ptr(const se::Value &v, T *ret) { // NOLINT(readability-identifier-naming) assert(ret != nullptr); @@ -232,6 +165,7 @@ seval_to_type(const se::Value &v, bool &ok) { // NOLINT(readability-identifier-n ok = true; return *nativeObj; } + template typename std::enable_if::value, T>::type seval_to_type(const se::Value &v, bool &ok) { // NOLINT(readability-identifier-naming) @@ -378,88 +312,21 @@ bool seval_to_Map_string_key(const se::Value &v, cc::Map *ret) { return true; } -// native value -> se value -bool int8_to_seval(int8_t v, se::Value *ret); // NOLINT(readability-identifier-naming) -bool uint8_to_seval(uint8_t v, se::Value *ret); // NOLINT(readability-identifier-naming) -bool int32_to_seval(int32_t v, se::Value *ret); // NOLINT(readability-identifier-naming) -bool uint32_to_seval(uint32_t v, se::Value *ret); // NOLINT(readability-identifier-naming) -bool int16_to_seval(uint16_t v, se::Value *ret); // NOLINT(readability-identifier-naming) -bool uint16_to_seval(uint16_t v, se::Value *ret); // NOLINT(readability-identifier-naming) -bool boolean_to_seval(bool v, se::Value *ret); // NOLINT(readability-identifier-naming) -bool float_to_seval(float v, se::Value *ret); // NOLINT(readability-identifier-naming) -bool double_to_seval(double v, se::Value *ret); // NOLINT(readability-identifier-naming) -bool long_to_seval(long v, se::Value *ret); // NOLINT(readability-identifier-naming) -bool ulong_to_seval(unsigned long v, se::Value *ret); // NOLINT(readability-identifier-naming) -bool longlong_to_seval(long long v, se::Value *ret); // NOLINT(readability-identifier-naming) -bool uintptr_t_to_seval(uintptr_t v, se::Value *ret); // NOLINT(readability-identifier-naming) -bool size_to_seval(size_t v, se::Value *ret); // NOLINT(readability-identifier-naming) -bool std_string_to_seval(const std::string &v, se::Value *ret); // NOLINT(readability-identifier-naming) - -bool Vec2_to_seval(const cc::Vec2 &v, se::Value *ret); // NOLINT(readability-identifier-naming) -bool Vec3_to_seval(const cc::Vec3 &v, se::Value *ret); // NOLINT(readability-identifier-naming) -bool Vec4_to_seval(const cc::Vec4 &v, se::Value *ret); // NOLINT(readability-identifier-naming) -bool Mat4_to_seval(const cc::Mat4 &v, se::Value *ret); // NOLINT(readability-identifier-naming) -bool Size_to_seval(const cc::Size &v, se::Value *ret); // NOLINT(readability-identifier-naming) -bool Rect_to_seval(const cc::Rect &v, se::Value *ret); // NOLINT(readability-identifier-naming) -bool ccvalue_to_seval(const cc::Value &v, se::Value *ret); // NOLINT(readability-identifier-naming) -bool ccvaluemap_to_seval(const cc::ValueMap &v, se::Value *ret); // NOLINT(readability-identifier-naming) -bool ccvaluemapintkey_to_seval(const cc::ValueMapIntKey &v, se::Value *ret); // NOLINT(readability-identifier-naming) -bool ccvaluevector_to_seval(const cc::ValueVector &v, se::Value *ret); // NOLINT(readability-identifier-naming) -bool std_vector_string_to_seval(const std::vector &v, se::Value *ret); // NOLINT(readability-identifier-naming) -bool std_vector_int_to_seval(const std::vector &v, se::Value *ret); // NOLINT(readability-identifier-naming) -bool std_vector_uint16_to_seval(const std::vector &v, se::Value *ret); // NOLINT(readability-identifier-naming) -bool std_vector_float_to_seval(const std::vector &v, se::Value *ret); // NOLINT(readability-identifier-naming) -bool std_map_string_string_to_seval(const std::map &v, se::Value *ret); // NOLINT(readability-identifier-naming) - -bool ManifestAsset_to_seval(const cc::extension::ManifestAsset &v, se::Value *ret); // NOLINT(readability-identifier-naming) -bool Data_to_seval(const cc::Data &v, se::Value *ret); // NOLINT(readability-identifier-naming) -bool DownloadTask_to_seval(const cc::network::DownloadTask &v, se::Value *ret); // NOLINT(readability-identifier-naming) - -// TODO(minggo): should add these functions if only bind gfx. -// gfx_color_attachment_to_seval -// gfx_depth_stecil_attachment_to_seval -// sub_pass_info_to_seval - -#if USE_GFX_RENDERER -#endif +template +typename std::enable_if::value, void>::type +cc_tmp_set_private_data(se::Object *obj, T *v) { // NOLINT(readability-identifier-naming) + obj->setPrivateData(v); +} template -typename std::enable_if::value, bool>::type -native_ptr_to_seval(T *v_c, se::Value *ret, bool *isReturnCachedValue = nullptr) { // NOLINT(readability-identifier-naming) - using DecayT = typename std::decay::type>::type; - auto *v = const_cast(v_c); - assert(ret != nullptr); - if (v == nullptr) { - ret->setNull(); - return true; - } - - se::Object *obj = nullptr; - auto iter = se::NativePtrToObjectMap::find(v); - if (iter == se::NativePtrToObjectMap::end()) { // If we couldn't find native object in map, then the native object is created from native code. e.g. TMXLayer::getTileAt - // CC_LOG_DEBUGWARN("WARNING: non-Ref type: (%s) isn't catched!", typeid(*v).name()); - se::Class *cls = JSBClassType::findClass(v); - assert(cls != nullptr); - obj = se::Object::createObjectWithClass(cls); - ret->setObject(obj, true); - obj->setPrivateData(v); - if (isReturnCachedValue != nullptr) { - *isReturnCachedValue = false; - } - } else { - obj = iter->second; - if (isReturnCachedValue != nullptr) { - *isReturnCachedValue = true; - } - ret->setObject(obj); - } - - return true; +typename std::enable_if::value, void>::type +cc_tmp_set_private_data(se::Object *obj, T *v) { // NOLINT(readability-identifier-naming) + obj->setPrivateObject(se::rawref_private_object(v)); } //handle reference template -typename std::enable_if::value && !std::is_pointer::value, bool>::type +typename std::enable_if::value, bool>::type native_ptr_to_seval(T &v_ref, se::Value *ret, bool *isReturnCachedValue = nullptr) { // NOLINT(readability-identifier-naming) using DecayT = typename std::decay::type>::type; auto *v = const_cast(&v_ref); @@ -474,11 +341,11 @@ native_ptr_to_seval(T &v_ref, se::Value *ret, bool *isReturnCachedValue = nullpt auto iter = se::NativePtrToObjectMap::find(v); if (iter == se::NativePtrToObjectMap::end()) { // If we couldn't find native object in map, then the native object is created from native code. e.g. TMXLayer::getTileAt // CC_LOG_DEBUGWARN("WARNING: non-Ref type: (%s) isn't catched!", typeid(*v).name()); - se::Class *cls = JSBClassType::findClass(v); + se::Class *cls = JSBClassType::findClass(v); assert(cls != nullptr); obj = se::Object::createObjectWithClass(cls); ret->setObject(obj, true); - obj->setPrivateData(v); + cc_tmp_set_private_data(obj, v); if (isReturnCachedValue != nullptr) { *isReturnCachedValue = false; } @@ -495,7 +362,7 @@ native_ptr_to_seval(T &v_ref, se::Value *ret, bool *isReturnCachedValue = nullpt template bool native_ptr_to_rooted_seval( // NOLINT(readability-identifier-naming) - typename std::enable_if::value, T>::type *v, + typename std::enable_if::value, T>::type *v, se::Value *ret, bool *isReturnCachedValue = nullptr) { assert(ret != nullptr); if (v == nullptr) { @@ -506,12 +373,11 @@ bool native_ptr_to_rooted_seval( // NOLINT(readability-identifier-naming) se::Object *obj = nullptr; auto iter = se::NativePtrToObjectMap::find(reinterpret_cast(v)); if (iter == se::NativePtrToObjectMap::end()) { // If we couldn't find native object in map, then the native object is created from native code. e.g. TMXLayer::getTileAt - se::Class *cls = JSBClassType::findClass(v); + se::Class *cls = JSBClassType::findClass(v); assert(cls != nullptr); obj = se::Object::createObjectWithClass(cls); obj->root(); - obj->setPrivateData(reinterpret_cast(v)); - + obj->setPrivateObject(se::rawref_private_object(v)); if (isReturnCachedValue != nullptr) { *isReturnCachedValue = false; } @@ -530,8 +396,7 @@ bool native_ptr_to_rooted_seval( // NOLINT(readability-identifier-naming) } template -typename std::enable_if::value, bool>::type -native_ptr_to_seval(T *vp, se::Class *cls, se::Value *ret, bool *isReturnCachedValue = nullptr) { // NOLINT(readability-identifier-naming) +bool native_ptr_to_seval(T *vp, se::Class *cls, se::Value *ret, bool *isReturnCachedValue = nullptr) { // NOLINT(readability-identifier-naming) using DecayT = typename std::decay::type>::type; auto *v = const_cast(vp); assert(ret != nullptr); @@ -547,44 +412,7 @@ native_ptr_to_seval(T *vp, se::Class *cls, se::Value *ret, bool *isReturnCachedV assert(cls != nullptr); obj = se::Object::createObjectWithClass(cls); ret->setObject(obj, true); - obj->setPrivateData(v); - - if (isReturnCachedValue != nullptr) { - *isReturnCachedValue = false; - } - } else { - obj = iter->second; - if (isReturnCachedValue != nullptr) { - *isReturnCachedValue = true; - } - ret->setObject(obj); - } - - return true; -} - -//handle ref -template -typename std::enable_if::value, bool>::type -native_ptr_to_seval(T &v_ref, se::Class *cls, se::Value *ret, bool *isReturnCachedValue = nullptr) { // NOLINT(readability-identifier-naming) - using DecayT = typename std::decay::type>::type; - auto *v = const_cast(&v_ref); - - assert(ret != nullptr); - if (v == nullptr) { - ret->setNull(); - return true; - } - - se::Object *obj = nullptr; - auto iter = se::NativePtrToObjectMap::find(v); - if (iter == se::NativePtrToObjectMap::end()) { // If we couldn't find native object in map, then the native object is created from native code. e.g. TMXLayer::getTileAt - // CC_LOG_DEBUGWARN("WARNING: Ref type: (%s) isn't catched!", typeid(*v).name()); - assert(cls != nullptr); - obj = se::Object::createObjectWithClass(cls); - ret->setObject(obj, true); - obj->setPrivateData(v); - + cc_tmp_set_private_data(obj, v); if (isReturnCachedValue != nullptr) { *isReturnCachedValue = false; } @@ -601,7 +429,7 @@ native_ptr_to_seval(T &v_ref, se::Class *cls, se::Value *ret, bool *isReturnCach template bool native_ptr_to_rooted_seval( // NOLINT(readability-identifier-naming) - typename std::enable_if::value, T>::type *v, + typename std::enable_if::value, T>::type *v, se::Class *cls, se::Value *ret, bool *isReturnCachedValue = nullptr) { assert(ret != nullptr); if (v == nullptr) { @@ -615,8 +443,7 @@ bool native_ptr_to_rooted_seval( // NOLINT(readability-identifier-naming) assert(cls != nullptr); obj = se::Object::createObjectWithClass(cls); obj->root(); - obj->setPrivateData(v); - + obj->setPrivateObject(se::rawref_private_object(v)); if (isReturnCachedValue != nullptr) { *isReturnCachedValue = false; } @@ -635,8 +462,7 @@ bool native_ptr_to_rooted_seval( // NOLINT(readability-identifier-naming) } template -typename std::enable_if::value, bool>::type -native_ptr_to_seval(T *vp, se::Value *ret, bool *isReturnCachedValue = nullptr) { // NOLINT(readability-identifier-naming) +bool native_ptr_to_seval(T *vp, se::Value *ret, bool *isReturnCachedValue = nullptr) { // NOLINT(readability-identifier-naming) using DecayT = typename std::decay::type>::type; auto *v = const_cast(vp); assert(ret != nullptr); @@ -649,12 +475,11 @@ native_ptr_to_seval(T *vp, se::Value *ret, bool *isReturnCachedValue = nullptr) auto iter = se::NativePtrToObjectMap::find(v); if (iter == se::NativePtrToObjectMap::end()) { // If we couldn't find native object in map, then the native object is created from native code. e.g. TMXLayer::getTileAt // CC_LOG_DEBUGWARN("WARNING: Ref type: (%s) isn't catched!", typeid(*v).name()); - se::Class *cls = JSBClassType::findClass(v); + se::Class *cls = JSBClassType::findClass(v); assert(cls != nullptr); obj = se::Object::createObjectWithClass(cls); ret->setObject(obj, true); - obj->setPrivateData(v); - v->retain(); // Retain the native object to unify the logic in finalize method of js object. + cc_tmp_set_private_data(obj, v); if (isReturnCachedValue != nullptr) { *isReturnCachedValue = false; } @@ -669,41 +494,6 @@ native_ptr_to_seval(T *vp, se::Value *ret, bool *isReturnCachedValue = nullptr) return true; } - -template -typename std::enable_if::value, bool>::type -native_ptr_to_seval(T *vp, se::Class *cls, se::Value *ret, bool *isReturnCachedValue = nullptr) { // NOLINT(readability-identifier-naming) - using DecayT = typename std::decay::type>::type; - auto *v = const_cast(vp); - assert(ret != nullptr); - if (v == nullptr) { - ret->setNull(); - return true; - } - - se::Object *obj = nullptr; - auto iter = se::NativePtrToObjectMap::find(v); - if (iter == se::NativePtrToObjectMap::end()) { // If we couldn't find native object in map, then the native object is created from native code. e.g. TMXLayer::getTileAt - // CC_LOG_DEBUGWARN("WARNING: Ref type: (%s) isn't catched!", typeid(*v).name()); - assert(cls != nullptr); - obj = se::Object::createObjectWithClass(cls); - ret->setObject(obj, true); - obj->setPrivateData(v); - v->retain(); // Retain the native object to unify the logic in finalize method of js object. - if (isReturnCachedValue != nullptr) { - *isReturnCachedValue = false; - } - } else { - obj = iter->second; - if (isReturnCachedValue != nullptr) { - *isReturnCachedValue = true; - } - ret->setObject(obj); - } - - return true; -} - template bool std_vector_to_seval(const std::vector &v, se::Value *ret) { // NOLINT(readability-identifier-naming) assert(ret != nullptr); @@ -739,7 +529,7 @@ template struct is_jsb_object : std::false_type {}; // NOLINT(readability-identifier-naming) template -constexpr bool is_jsb_object_v = is_jsb_object::type>::value; // NOLINT(readability-identifier-naming) +constexpr bool is_jsb_object_v = is_jsb_object::type>::value; // NOLINT #define JSB_REGISTER_OBJECT_TYPE(T) \ template <> \ @@ -767,14 +557,21 @@ template struct HolderType { using type = typename std::remove_const::type; using local_type = typename std::conditional_t, std::add_pointer_t, type>; - local_type data; - type * ptr = nullptr; + local_type data; + type * ptr = nullptr; + struct alignas(T) EmbedField { + uint8_t inlineObject[is_reference && is_jsb_object_v ? sizeof(T) : 1]; + } inlineObject; + constexpr inline type &value() { if (ptr) return *ptr; return holder_convert_to(data); } ~HolderType() { - delete ptr; + //delete ptr; + if (ptr) { + ptr->~T(); + } } }; @@ -796,6 +593,32 @@ struct HolderType { inline type value() const { return data.c_str(); } }; +#define HOLD_UNBOUND_TYPE(FromType, IsReference) \ + template <> \ + struct HolderType { \ + using type = FromType; \ + using local_type = typename std::remove_pointer::type; \ + std::remove_const_t data; \ + std::remove_const_t * ptr = nullptr; \ + inline type value() { return &data; } \ + } + +HOLD_UNBOUND_TYPE(cc::Vec3 *, false); +HOLD_UNBOUND_TYPE(cc::Quaternion *, false); +HOLD_UNBOUND_TYPE(const cc::Mat4 *, false); +HOLD_UNBOUND_TYPE(cc::Color *, false); +HOLD_UNBOUND_TYPE(cc::geometry::Frustum *, false); +HOLD_UNBOUND_TYPE(cc::geometry::AABB *, false); + +template <> +struct HolderType { + using type = cc::ArrayBuffer; + using local_type = cc::ArrayBuffer; + local_type data; + std::remove_const_t *ptr = nullptr; + inline type & value() { return data; } +}; + template struct HolderType, true> { using type = std::function; @@ -805,19 +628,49 @@ struct HolderType, true> { inline type value() { return data; } }; +//template +//struct HolderType, true> { +// using NonconstT = typename std::remove_const::type; +// using type = cc::optional; +// using local_type = NonconstT; +// local_type data; +// std::remove_const_t *ptr = nullptr; +// inline type value() { return std::make_optional(data); } +//}; + ///////////////////////////////////convertion////////////////////////////////////////////////////////// +////////////////// optional +template +struct is_optional : std::false_type {}; // NOLINT + template -inline bool sevalue_to_native(const se::Value &from, T &&to) { // NOLINT(readability-identifier-naming) - return sevalue_to_native(from, std::forward(to), nullptr); +struct is_optional> : std::true_type {}; // NOLINT + +template +struct is_variant : std::false_type {}; // NOLINT +template +struct is_variant> : std::true_type {}; // NOLINT + +template +inline typename std::enable_if_t::value && !std::is_pointer::value && !is_jsb_object_v, bool> +sevalue_to_native(const se::Value & /*from*/, T * /*to*/, se::Object * /*unused*/) { // NOLINT(readability-identifier-naming) + SE_LOGE("Can not convert type ???\n - [[ %s ]]\n", typeid(T).name()); + CC_STATIC_ASSERT(!is_variant::value, "should not match cc::variant"); + CC_STATIC_ASSERT((std::is_same::value), "sevalue_to_native not implemented for T"); + return false; } template -inline typename std::enable_if_t::value && !std::is_pointer::value, bool> -sevalue_to_native(const se::Value & /*from*/, T * /*to*/, se::Object * /*unused*/) { // NOLINT(readability-identifier-naming) - SE_LOGE("Can not convert type ???\n - [[ %s ]]\n", typeid(T).name()); - CC_STATIC_ASSERT((std::is_same::value), "sevalue_to_native not implemented for T"); - return false; +inline typename std::enable_if_t::value && !std::is_pointer::value && is_jsb_object_v, bool> +sevalue_to_native(const se::Value &from, T *to, se::Object * /*unused*/) { // NOLINT(readability-identifier-naming) + auto *obj = from.toObject(); + if CC_CONSTEXPR (std::is_copy_assignable::value) { + *to = *static_cast(obj->getPrivateData()); + } else { + assert(false); // can not copy + } + return true; } template @@ -829,7 +682,36 @@ sevalue_to_native(const se::Value &from, T *to, se::Object *ctx) { // NOLINT(rea return ret; } -//////////////// vector type +//////////////////////////////// forward declaration : sevalue_to_native //////////////////////////////// + +// cc::variant<...>>ss +template +bool sevalue_to_native(const se::Value &from, cc::variant *to, se::Object *ctx); // NOLINT(readability-identifier-naming) + +template +bool sevalue_to_native(const se::Value &from, cc::optional *to, se::Object *ctx); // NOLINT(readability-identifier-naming) +/// std::unordered_map +template +bool sevalue_to_native(const se::Value &from, std::unordered_map *to, se::Object *ctx); //NOLINT(readability-identifier-naming) +// std::tuple +template +bool sevalue_to_native(const se::Value &from, std::tuple *to, se::Object *ctx); // NOLINT(readability-identifier-naming) +// std::shared_ptr +template +bool sevalue_to_native(const se::Value &from, std::shared_ptr> *out, se::Object *ctx); // NOLINT(readability-identifier-naming) +template +bool sevalue_to_native(const se::Value &from, std::shared_ptr *out, se::Object *ctx); // NOLINT(readability-identifier-naming) +// std::vector +template +bool sevalue_to_native(const se::Value &from, std::vector *to, se::Object *ctx); // NOLINT(readability-identifier-naming) +// std::vector +template +bool sevalue_to_native(const se::Value &from, std::array *to, se::Object *ctx); // NOLINT(readability-identifier-naming) + +template +bool sevalue_to_native(const se::Value &from, cc::IntrusivePtr *to, se::Object *ctx); // NOLINT(readability-identifier-naming) + +//////////////////// std::array template bool sevalue_to_native(const se::Value &from, std::array *to, se::Object *ctx) { // NOLINT(readability-identifier-naming) @@ -872,7 +754,7 @@ bool sevalue_to_native(const se::Value &from, std::array *to, se:: se::Value tmp; assert(len >= CNT); for (size_t i = 0; i < CNT; i++) { - array->getArrayElement(static_cast(i), &tmp); + array->getArrayElement(static_cast(i), &tmp); sevalue_to_native(tmp, &(*to)[i], ctx); } } else { @@ -881,185 +763,32 @@ bool sevalue_to_native(const se::Value &from, std::array *to, se:: return true; } -template <> -inline bool sevalue_to_native(const se::Value &from, std::string *to, se::Object * /*ctx*/) { - *to = from.toString(); - return true; -} - -///// integers -template <> -inline bool sevalue_to_native(const se::Value &from, bool *to, se::Object * /*ctx*/) { - *to = from.isNullOrUndefined() ? false : (from.isNumber() ? from.toDouble() != 0 : from.toBoolean()); - return true; -} - -template <> -inline bool sevalue_to_native(const se::Value &from, int32_t *to, se::Object * /*ctx*/) { - *to = from.toInt32(); - return true; -} -template <> -inline bool sevalue_to_native(const se::Value &from, uint32_t *to, se::Object * /*ctx*/) { - *to = from.toUint32(); - return true; -} - -template <> -inline bool sevalue_to_native(const se::Value &from, int16_t *to, se::Object * /*ctx*/) { - *to = from.toInt16(); - return true; -} -template <> -inline bool sevalue_to_native(const se::Value &from, uint16_t *to, se::Object * /*ctx*/) { - *to = from.toUint16(); - return true; -} - -template <> -inline bool sevalue_to_native(const se::Value &from, int8_t *to, se::Object * /*ctx*/) { - *to = from.toInt8(); - return true; -} -template <> -inline bool sevalue_to_native(const se::Value &from, uint8_t *to, se::Object * /*ctx*/) { - *to = from.toUint8(); - return true; -} - -template <> -inline bool sevalue_to_native(const se::Value &from, uint64_t *to, se::Object * /*ctx*/) { - *to = from.toUint64(); - return true; -} - -template <> -inline bool sevalue_to_native(const se::Value &from, int64_t *to, se::Object * /*ctx*/) { - *to = from.toInt64(); - return true; -} - -#if CC_PLATFORM == CC_PLATFORM_MAC_IOS || CC_PLATFORM == CC_PLATFORM_MAC_OSX -template <> -inline bool sevalue_to_native(const se::Value &from, unsigned long *to, se::Object * /*ctx*/) { - // on mac: unsiged long === uintptr_t - CC_STATIC_ASSERT(sizeof(*to) == 8); - *to = static_cast(from.toUint64()); - return true; -} -#endif - -template <> -inline bool sevalue_to_native(const se::Value &from, float *to, se::Object * /*ctx*/) { - *to = from.toFloat(); - return true; -} -inline bool sevalue_to_native(const se::Value &from, double *to, se::Object * /*unused*/) { // NOLINT(readability-identifier-naming) - *to = from.toDouble(); - return true; -} - -template <> -inline bool sevalue_to_native(const se::Value & /*from*/, void * /*to*/, se::Object * /*ctx*/) { - assert(false); // void not supported - return false; -} - -template <> -inline bool sevalue_to_native(const se::Value &from, cc::Data *to, se::Object * /*ctx*/) { - return seval_to_Data(from, to); -} - -template <> -inline bool sevalue_to_native(const se::Value &from, cc::Value *to, se::Object * /*unused*/) { - return seval_to_ccvalue(from, to); -} - -template <> -inline bool sevalue_to_native(const se::Value &from, se::Value *to, se::Object * /*unused*/) { - *to = from; - return true; -} - -template <> -bool sevalue_to_native(const se::Value &from, cc::Vec4 *to, se::Object * /*unused*/); - -template <> -bool sevalue_to_native(const se::Value &from, cc::Mat4 *to, se::Object * /*unused*/); - -template <> -bool sevalue_to_native(const se::Value &from, cc::Vec3 *to, se::Object * /*unused*/); - -template <> -bool sevalue_to_native(const se::Value &from, cc::Vec2 *to, se::Object * /*unused*/); - -template <> -bool sevalue_to_native(const se::Value &from, cc::Quaternion *to, se::Object * /*unused*/); - -template <> -inline bool sevalue_to_native(const se::Value &from, std::vector *to, se::Object * /*unused*/) { - assert(from.isObject() && from.toObject()->isArray()); - auto *array = from.toObject(); - to->clear(); - uint32_t size; - array->getArrayLength(&size); - for (uint32_t i = 0; i < size; i++) { - se::Value ele; - array->getArrayElement(i, &ele); - to->emplace_back(ele); +template +bool sevalue_to_native(const se::Value &from, cc::variant> *to, se::Object *ctx) { // NOLINT + se::Object *array = from.toObject(); + if (array->isArray()) { + std::vector result; + sevalue_to_native(from, &result, ctx); + *to = std::move(result); + } else { + T result; + sevalue_to_native(from, &result, ctx); + *to = result; } return true; } +////////////////// TypedArray + +template +inline typename std::enable_if::value, bool>::type +sevalue_to_native(const se::Value &from, cc::TypedArrayTemp *to, se::Object * /*ctx*/) { // NOLINT(readability-identifier-naming) + to->setJSTypedArray(from.toObject()); + return true; +} + ////////////////// pointer types -template -typename std::enable_if_t::value && !std::is_pointer::type>::value, bool> -sevalue_to_native(const se::Value &from, T to, se::Object * /*ctx*/) { // NOLINT(readability-identifier-naming) - CC_STATIC_ASSERT(is_jsb_object_v>, "Only JSB object are accepted!"); - if (from.isNullOrUndefined()) { - //const std::string stack = se::ScriptEngine::getInstance()->getCurrentStackTrace(); - //SE_LOGE("[ERROR] sevalue_to_native jsval is null/undefined: %s\nstack: %s", typeid(T).name(), stack.c_str()); - *to = nullptr; - return true; - } - *to = static_cast(from.toObject()->getPrivateData()); - return true; -} - -template -typename std::enable_if_t::value && std::is_pointer::type>::value, bool> -sevalue_to_native(const se::Value &from, T to, se::Object * /*ctx*/) { // NOLINT(readability-identifier-naming) - using Value = typename std::remove_pointer::type>::type; - CC_STATIC_ASSERT(is_jsb_object_v || std::is_arithmetic::value, "Only JSB object or arithmetic types are supported"); - - if CC_CONSTEXPR (is_jsb_object_v) { - if (from.isNullOrUndefined()) { - //const std::string stack = se::ScriptEngine::getInstance()->getCurrentStackTrace(); - //SE_LOGE("[ERROR] sevalue_to_native jsval is null/undefined: %s\nstack: %s", typeid(T).name(), stack.c_str()); - *to = nullptr; - return true; - } - *to = static_cast::type>(from.toObject()->getPrivateData()); - return true; - } else if CC_CONSTEXPR (std::is_arithmetic::value) { - se::Object *array = from.toObject(); - if (array->isTypedArray()) { - uint8_t *data = nullptr; - array->getTypedArrayData(&data, nullptr); - *to = reinterpret_cast(data); - } else if (array->isArrayBuffer()) { - uint8_t *data = nullptr; - array->getArrayBufferData(&data, nullptr); - *to = reinterpret_cast(data); - } else { - assert(false); - return false; - } - return true; - } -} - template typename std::enable_if_t::value && is_jsb_object_v, bool> sevalue_to_native(const se::Value &from, T **to, se::Object * /*ctx*/) { // NOLINT(readability-identifier-naming) @@ -1073,6 +802,23 @@ sevalue_to_native(const se::Value &from, T **to, se::Object * /*ctx*/) { // NOLI return true; } +template +typename std::enable_if_t::value && std::is_arithmetic::value, bool> +sevalue_to_native(const se::Value &from, T **to, se::Object * /*ctx*/) { // NOLINT(readability-identifier-naming) + se::Object *data = from.toObject(); + uint8_t * tmp; + if (data->isArrayBuffer()) { + data->getArrayBufferData(&tmp, nullptr); + } else if (data->isTypedArray()) { + data->getTypedArrayData(&tmp, nullptr); + } else { + assert(false); // bad type + return false; + } + *to = reinterpret_cast(tmp); + return true; +} + template typename std::enable_if_t::value && is_jsb_object_v, bool> sevalue_to_native(const se::Value &from, T ***to, se::Object * /*ctx*/) { // NOLINT(readability-identifier-naming) @@ -1088,6 +834,12 @@ sevalue_to_native(const se::Value &from, T ***to, se::Object * /*ctx*/) { // NOL template bool sevalue_to_native(const se::Value &from, std::vector *to, se::Object *ctx) { // NOLINT(readability-identifier-naming) + + if (from.isNullOrUndefined()) { + to->clear(); + return true; + } + assert(from.toObject()); se::Object *array = from.toObject(); @@ -1118,78 +870,7 @@ bool sevalue_to_native(const se::Value &from, std::vector *to, se: return false; } -//template<> -//bool sevalue_to_native(const se::Value &from, cc::gfx::Context **to, se::Object*) { -// assert(from.isObject()); -// *to = (cc::gfx::Context*)from.toObject()->getPrivateData(); -// return true; -//} - -template <> -inline bool sevalue_to_native(const se::Value &from, void **to, se::Object * /*ctx*/) { - assert(to != nullptr); - if (from.isNumber() || from.isBigInt()) { - // NOLINTNEXTLINE(performance-no-int-to-ptr) - *to = reinterpret_cast(from.toUint64()); - return true; - } - if (from.isObject()) { - *to = from.toObject()->getPrivateData(); - return true; - } - SE_LOGE("[warn] failed to convert to void *\n"); - return false; -} - -template <> -inline bool sevalue_to_native(const se::Value &from, std::string **to, se::Object * /*ctx*/) { - **to = from.toString(); - return true; -} - -template <> -inline bool sevalue_to_native(const se::Value &from, cc::ValueMap *to, se::Object * /*ctx*/) { - return seval_to_ccvaluemap(from, to); -} - -template <> -inline bool sevalue_to_native(const se::Value &from, std::vector *to, se::Object * /*ctx*/) { - assert(from.isObject()); - se::Object *in = from.toObject(); - - if (in->isTypedArray()) { - uint8_t *data = nullptr; - size_t dataLen = 0; - in->getTypedArrayData(&data, &dataLen); - to->resize(dataLen); - to->assign(data, data + dataLen); - return true; - } - - if (in->isArrayBuffer()) { - uint8_t *data = nullptr; - size_t dataLen = 0; - in->getArrayBufferData(&data, &dataLen); - to->resize(dataLen); - to->assign(data, data + dataLen); - return true; - } - - if (in->isArray()) { - uint32_t len = 0; - in->getArrayLength(&len); - to->resize(len); - se::Value ele; - for (uint32_t i = 0; i < len; i++) { - in->getArrayElement(i, &ele); - (*to)[i] = ele.toUint8(); - } - return true; - } - - SE_LOGE("type error, ArrayBuffer/TypedArray/Array expected!"); - return false; -} +///////////////////// function template inline bool sevalue_to_native(const se::Value &from, std::function *func, se::Object *self) { // NOLINT(readability-identifier-naming) @@ -1220,6 +901,15 @@ inline bool sevalue_to_native(const se::Value &from, std::function * return true; } +//////////////////////// cc::variant + +template +inline bool sevalue_to_native(const se::Value & /*from*/, cc::variant * /*to*/, se::Object * /*ctx*/) { // NOLINT(readability-identifier-naming) + static_assert(sizeof...(Args) == 0, ""); //TODO(PatriceJiang): should not pass variant from js -> native + assert(false); + return false; +} + #if HAS_CONSTEXPR template inline bool sevalue_to_native(const se::Value &from, HolderType *holder, se::Object *ctx) { // NOLINT(readability-identifier-naming) @@ -1229,7 +919,11 @@ inline bool sevalue_to_native(const se::Value &from, HolderType holder->data = static_cast(ptr); return true; } - holder->ptr = new T; + if CC_CONSTEXPR (std::is_constructible::value) { + holder->ptr = new (&holder->inlineObject) T; + } else { + assert(false); // default construtor not provided + } return sevalue_to_native(from, holder->ptr, ctx); } else if CC_CONSTEXPR (is_jsb_object_v) { @@ -1253,7 +947,8 @@ inline typename std::enable_if, bool>::type sevalue_to_native holder->data = static_cast(ptr); return true; } else { - holder->ptr = new T; + // holder->ptr = new T; + holder->ptr = new (&holder->inlineObject) T; return sevalue_to_native(from, holder->ptr, ctx); } } @@ -1315,11 +1010,139 @@ sevalue_to_native(const se::Value &from, HolderType, t #endif // HAS_CONSTEXPR +/////////////////// std::shared_ptr + +template +bool sevalue_to_native(const se::Value &from, std::shared_ptr> *out, se::Object *ctx) { + if (from.isNullOrUndefined()) { + out->reset(); + return true; + } + + *out = std::make_shared>(); + return sevalue_to_native(from, out->get(), ctx); +} + +template +bool sevalue_to_native(const se::Value &from, std::shared_ptr *out, se::Object * /*ctx*/) { + if (from.isNullOrUndefined()) { + out->reset(); + return true; + } + auto *privateObject = from.toObject()->getPrivateObject(); + assert(privateObject->isSharedPtr()); + *out = static_cast>(privateObject).share(); + return true; +} + +template +inline typename std::enable_if::value, bool>::type +sevalue_to_native(const se::Value &from, cc::IntrusivePtr> *out, se::Object *ctx) { // NOLINT(readability-identifier-naming) + *out = new cc::TypedArrayTemp(); + sevalue_to_native(from, out->get(), ctx); + return true; +} + +template +bool sevalue_to_native(const se::Value &from, cc::IntrusivePtr *to, se::Object *ctx) { + if (from.isNullOrUndefined()) { + to = nullptr; + return true; + } + + auto *privateObject = from.toObject()->getPrivateObject(); + if (!privateObject) { + T * tmp = nullptr; + bool ok = sevalue_to_native(from, &tmp, ctx); + *to = tmp; + return ok; + } + + assert(privateObject->isCCShared()); + *to = static_cast *>(privateObject)->ccShared(); + return true; +} + +/////////////////// std::tuple +template +void se_for_each_tuple_impl(Tuple &&tuple, F &&f, std::index_sequence /*seq*/) { // NOLINT(readability-identifier-naming) + using swallow = int[]; + (void)swallow{1, + (f(Indices, std::get(std::forward(tuple))), void(), int{})...}; +} + +template +void se_for_each_tuple(Tuple &&tuple, F &&f) { // NOLINT(readability-identifier-naming) + constexpr std::size_t n = std::tuple_size>::value; + se_for_each_tuple_impl(std::forward(tuple), std::forward(f), + std::make_index_sequence{}); +} + +template +bool sevalue_to_native(const se::Value &from, std::tuple *to, se::Object *ctx) { // NOLINT + constexpr size_t argsize = std::tuple_size>::value; + bool result = true; + se_for_each_tuple(*to, [&](auto i, auto ¶m) { + se::Value tmp; + from.toObject()->getArrayElement(i, &tmp); + result &= sevalue_to_native(tmp, ¶m, ctx); + }); + return result; +} + +////////////// std::unordered_map +template +bool sevalue_to_native(const se::Value &from, std::unordered_map *to, se::Object *ctx) { //NOLINT + se::Object * jsmap = from.toObject(); + std::vector allKeys; + jsmap->getAllKeys(&allKeys); + bool ret = true; + se::Value property; + for (auto &it : allKeys) { + if (jsmap->getProperty(it.c_str(), &property)) { + auto &output = (*to)[it]; + ret &= sevalue_to_native(property, &output, jsmap); + } + } + return true; +} + +///////////////// cc::optional +template +bool sevalue_to_native(const se::Value &from, cc::optional *to, se::Object *ctx) { //NOLINT + static_assert(!is_optional::value, "bad match ?"); + if (from.isNullOrUndefined()) { + to->reset(); + return true; + } + T tmp{}; + bool ret = sevalue_to_native(from, &tmp, ctx); + if CC_CONSTEXPR (std::is_move_assignable::value) { + *to = std::move(tmp); + } else { + *to = tmp; + } + return ret; +} +////////////////////// shoter form +template +inline bool sevalue_to_native(const se::Value &from, T &&to) { // NOLINT(readability-identifier-naming) + return sevalue_to_native(from, std::forward(to), static_cast(nullptr)); +} + +/////////////////////////////////////////////////////////////////// +////////////////// nativevalue_to_se /////////////////////////// /////////////////////////////////////////////////////////////////// template -inline bool nativevalue_to_se(T &&from, se::Value &to) { // NOLINT(readability-identifier-naming) - return nativevalue_to_se(std::forward(from), to, nullptr); +inline bool nativevalue_to_se(T &&from, se::Value &to); // NOLINT(readability-identifier-naming) + +template +bool nativevalue_to_se(const cc::variant &from, se::Value &to, se::Object *ctx); // NOLINT + +template +bool nativevalue_to_se(const cc::variant *from, se::Value &to, se::Object *ctx) { // NOLINT + return nativevalue_to_se(*from, to, ctx); } #if HAS_CONSTEXPR @@ -1340,6 +1163,7 @@ inline bool nativevalue_to_se(const T &from, se::Value &to, se::Object *ctx) { / to.setDouble(static_cast(from)); return true; } else { + static_assert(!std::is_const::value, "Only non-const value accepted here"); return nativevalue_to_se::value, T, typename std::add_const::type>>(from, to, ctx); } } @@ -1366,39 +1190,92 @@ nativevalue_to_se(const T &from, se::Value &to, se::Object *ctx) { } template -inline typename std::enable_if::value && !std::is_pointer::value && !is_jsb_object_v, bool>::type +inline typename std::enable_if::value, bool>::type nativevalue_to_se(const T &from, se::Value &to, se::Object *ctx) { - return nativevalue_to_se::value, T, typename std::add_const::type>>(from, to, ctx); + to.setDouble(static_cast(from)); + return true; } #endif // HAS_CONSTEXPR -template -inline bool nativevalue_to_se(const std::vector &from, se::Value &to, se::Object *ctx) { // NOLINT(readability-identifier-naming) - se::Object *array = se::Object::createArrayObject(from.size()); - se::Value tmp; +//////////////////////////////// forward declaration: nativevalue_to_se //////////////////////////////// + +template +inline bool nativevalue_to_se(const std::shared_ptr &from, se::Value &to, se::Object *ctx); // NOLINT + +template +inline bool nativevalue_to_se(const cc::IntrusivePtr &from, se::Value &to, se::Object *ctx); // NOLINT + +template +bool nativevalue_to_se(const std::reference_wrapper ref, se::Value &to, se::Object *ctx); // NOLINT + +template +bool nativevalue_to_se(const std::tuple &from, se::Value &to, se::Object *ctx); // NOLINT + +template +inline bool nativevalue_to_se(const std::vector &from, se::Value &to, se::Object *ctx); // NOLINT + +template +inline bool nativevalue_to_se(const std::unordered_map &from, se::Value &to, se::Object *ctx); // NOLINT + +/// nativevalue_to_se cc::optional +template +bool nativevalue_to_se(const cc::optional &from, se::Value &to, se::Object *ctx) { // NOLINT + if (!from.has_value()) { + to.setUndefined(); + return true; + } + return nativevalue_to_se(from.value(), to, ctx); +} + +template +inline bool nativevalue_to_se(const cc::TypedArrayTemp &typedArray, se::Value &to, se::Object *ctx) { // NOLINT + to.setObject(typedArray.getJSTypedArray()); + return true; +} + +template +inline bool nativevalue_to_se(const std::vector &from, se::Value &to, se::Object *ctx) { // NOLINT(readability-identifier-naming) + se::HandleObject array(se::Object::createArrayObject(from.size())); + se::Value tmp; for (size_t i = 0; i < from.size(); i++) { nativevalue_to_se(from[i], tmp, ctx); array->setArrayElement(static_cast(i), tmp); } - to.setObject(array); - array->decRef(); + to.setObject(array, true); return true; } -template <> -inline bool nativevalue_to_se(const std::vector &from, se::Value &to, se::Object * /*ctx*/) { - se::Object *array = se::Object::createTypedArray(se::Object::TypedArrayType::INT8, from.data(), from.size()); +template +inline bool nativevalue_to_se(const std::vector &from, se::Value &to, se::Object * /*ctx*/) { // NOLINT + se::HandleObject array(se::Object::createArrayObject(from.size())); + for (auto i = 0; i < from.size(); i++) { + array->setArrayElement(i, se::Value(from[i])); + } to.setObject(array); - array->decRef(); return true; } -template <> -inline bool nativevalue_to_se(const std::vector &from, se::Value &to, se::Object * /*ctx*/) { - se::Object *array = se::Object::createTypedArray(se::Object::TypedArrayType::UINT8, from.data(), from.size()); - to.setObject(array); - array->decRef(); +template +typename std::enable_if::value, void>::type cc_tmp_set_property(se::Object *obj, T &key, se::Value &value) { // NOLINT(readability-identifier-naming) + obj->setProperty(key, value); +} +template +typename std::enable_if::value, void>::type cc_tmp_set_property(se::Object *obj, T &str, se::Value &value) { // NOLINT(readability-identifier-naming) + obj->setProperty(std::to_string(str), value); +} + +template +inline bool nativevalue_to_se(const std::unordered_map &from, se::Value &to, se::Object *ctx) { // NOLINT + se::Object *ret = se::Object::createPlainObject(); + se::Value value; + bool ok = true; + for (auto &it : from) { + ok &= nativevalue_to_se(it.second, value, ctx); + cc_tmp_set_property(ret, it.first, value); + } + to.setObject(ret); + ret->decRef(); return true; } @@ -1439,73 +1316,6 @@ inline bool nativevalue_to_se(const std::array &from, se::Value &to, s return true; } -template <> -inline bool nativevalue_to_se(const int64_t &from, se::Value &to, se::Object * /*ctx*/) { - to.setInt64(from); - return true; -} - -template <> -inline bool nativevalue_to_se(const uint64_t &from, se::Value &to, se::Object * /*ctx*/) { - to.setUint64(from); - return true; -} - -template <> -inline bool nativevalue_to_se(const int32_t &from, se::Value &to, se::Object * /*ctx*/) { - to.setInt32(from); - return true; -} - -template <> -inline bool nativevalue_to_se(const uint32_t &from, se::Value &to, se::Object * /*ctx*/) { - to.setUint32(from); - return true; -} -template <> -inline bool nativevalue_to_se(const int16_t &from, se::Value &to, se::Object * /*ctx*/) { - to.setInt16(from); - return true; -} -template <> -inline bool nativevalue_to_se(const uint16_t &from, se::Value &to, se::Object * /*ctx*/) { - to.setUint16(from); - return true; -} - -template <> -inline bool nativevalue_to_se(const int8_t &from, se::Value &to, se::Object * /*ctx*/) { - to.setInt8(from); - return true; -} - -template <> -inline bool nativevalue_to_se(const uint8_t &from, se::Value &to, se::Object * /*ctx*/) { - to.setUint8(from); - return true; -} - -template <> -inline bool nativevalue_to_se(const std::string &from, se::Value &to, se::Object * /*ctx*/) { - to.setString(from); - return true; -} -template <> -inline bool nativevalue_to_se(const float &from, se::Value &to, se::Object * /*ctx*/) { - to.setFloat(from); - return true; -} -template <> -inline bool nativevalue_to_se(const double &from, se::Value &to, se::Object * /*ctx*/) { - to.setFloat(static_cast(from)); - return true; -} -template <> -inline bool nativevalue_to_se(const bool &from, se::Value &to, se::Object * /*ctx*/) { - to.setBoolean(from); - return true; -} - template inline bool nativevalue_to_se(std::function & /*from*/, se::Value & /*to*/, se::Object * /*ctx*/) { // NOLINT(readability-identifier-naming) SE_LOGE("Can not convert C++ lambda to JS object"); // TODO(jiangzhan) @@ -1534,61 +1344,9 @@ bool nativevalue_to_se_args_v(se::ValueArray &array, Args &...args) { // NOLINT( return nativevalue_to_se_args<0, Args...>(array, args...); } -/////////////////////// FIXME: remove all code bellow -///////////////// gfx type -namespace cc { -class GFXContext; -class Data; -class Value; -class Vec4; -class Size; -} // namespace cc -//template<> - -// JSB_REGISTER_OBJECT_TYPE(cc::network::DownloaderHints); - -template <> -bool nativevalue_to_se(const cc::Data &from, se::Value &to, se::Object *ctx); - -template <> -bool nativevalue_to_se(const cc::Value &from, se::Value &to, se::Object *ctx); - -template <> -bool nativevalue_to_se(const std::unordered_map &from, se::Value &to, se::Object *ctx); - -template <> -bool nativevalue_to_se(const cc::Vec2 &from, se::Value &to, se::Object *ctx); - -template <> -bool nativevalue_to_se(const cc::Vec3 &from, se::Value &to, se::Object *ctx); - -template <> -bool nativevalue_to_se(const cc::Vec4 &from, se::Value &to, se::Object *ctx); - -template <> -bool nativevalue_to_se(const cc::Size &from, se::Value &to, se::Object *ctx); - -template <> -bool nativevalue_to_se(const cc::extension::ManifestAsset &from, se::Value &to, se::Object *ctx); - -template <> -bool nativevalue_to_se(const cc::Rect &from, se::Value &to, se::Object *ctx); - -template <> -inline bool nativevalue_to_se(const cc::network::DownloadTask &from, se::Value &to, se::Object * /*ctx*/) { - return DownloadTask_to_seval(from, &to); -} - -#if __clang__ && defined(HAS_PUSH_DIAGNOSTI) - #pragma clang diagnostic pop -#endif - // Spine conversions #if USE_SPINE -template <> -bool sevalue_to_native(const se::Value &, spine::String *, se::Object *); - template bool nativevalue_to_se(const spine::Vector &v, se::Value &ret, se::Object * /*ctx*/) { // NOLINT(readability-identifier-naming) se::HandleObject obj(se::Object::createArrayObject(v.size())); @@ -1665,24 +1423,91 @@ bool sevalue_to_native(const se::Value &v, spine::Vector *ret, se::Object * return true; } - -template <> -bool nativevalue_to_se(const spine::Vector &v, se::Value &ret, se::Object *ctx); - -template <> -bool nativevalue_to_se(const spine::String &from, se::Value &to, se::Object *ctx); - -template <> -bool sevalue_to_native(const se::Value &v, spine::Vector *ret, se::Object *ctx); - -template <> -bool seval_to_Map_string_key(const se::Value &v, cc::Map *ret); #endif //USE_SPINE -#if USE_MIDDLEWARE -template <> -inline bool nativevalue_to_se(const se_object_ptr &from, se::Value &to, se::Object * /*ctx*/) { - to.setObject(const_cast(from)); +/////////////////// shorter form +template +inline bool nativevalue_to_se(T &&from, se::Value &to) { // NOLINT(readability-identifier-naming) + return nativevalue_to_se(std::forward::type>(from), to, nullptr); +} + +template +bool nativevalue_to_se(const cc::variant &from, se::Value &to, se::Object *ctx) { // NOLINT(readability-identifier-naming) + bool ok = false; + cc::visit( + [&](auto param) { + ok = nativevalue_to_se(param, to, ctx); + }, + from); + return ok; +} + +template +inline bool nativevalue_to_se(const std::shared_ptr> &from, se::Value &to, se::Object *ctx) { //NOLINT + return nativevalue_to_se(*from, to, ctx); +} + +template +inline bool nativevalue_to_se(const std::shared_ptr &from, se::Value &to, se::Object *ctx) { //NOLINT + + auto *nativePtr = from.get(); + if (!nativePtr) { + to.setNull(); + return true; + } + auto it = se::NativePtrToObjectMap::find(nativePtr); + if (it == se::NativePtrToObjectMap::end()) { + se::Class *cls = JSBClassType::findClass(nativePtr); + assert(cls); + se::Object *obj = se::Object::createObjectWithClass(cls); + to.setObject(obj, true); + obj->setPrivateObject(se::shared_private_object(from)); + } else { + to.setObject(it->second); + } return true; } -#endif //USE_MIDDLEWARE + +template +inline bool nativevalue_to_se(const cc::IntrusivePtr &from, se::Value &to, se::Object *ctx) { //NOLINT + + auto *nativePtr = from.get(); + if (!nativePtr) { + to.setNull(); + return true; + } + auto it = se::NativePtrToObjectMap::find(nativePtr); + if (it == se::NativePtrToObjectMap::end()) { + se::Class *cls = JSBClassType::findClass(nativePtr); + assert(cls); + se::Object *obj = se::Object::createObjectWithClass(cls); + to.setObject(obj, true); + obj->setPrivateObject(se::ccshared_private_object(from)); + } else { + to.setObject(it->second); + } + return true; +} + +template +bool nativevalue_to_se(const std::tuple &from, se::Value &to, se::Object *ctx) { // NOLINT(readability-identifier-naming) + bool ok = true; + se::Value tmp; + se::Object *array = se::Object::createArrayObject(sizeof...(ARGS)); + se_for_each_tuple( + from, [&](auto i, auto ¶m) { + ok &= nativevalue_to_se(param, tmp, ctx); + array->setArrayElement(i, tmp); + }); + to.setObject(array); + return ok; +} + +template +bool nativevalue_to_se(const std::reference_wrapper ref, se::Value &to, se::Object *ctx) { // NOLINT + return nativevalue_to_se(ref.get(), to, ctx); +} + +#if __clang__ && defined(HAS_PUSH_DIAGNOSTI) + #pragma clang diagnostic pop +#endif \ No newline at end of file diff --git a/native/cocos/bindings/manual/jsb_conversions_spec.cpp b/native/cocos/bindings/manual/jsb_conversions_spec.cpp new file mode 100644 index 0000000000..dcd4a46ecf --- /dev/null +++ b/native/cocos/bindings/manual/jsb_conversions_spec.cpp @@ -0,0 +1,1759 @@ +/**************************************************************************** + 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 +#include "jsb_conversions.h" + +#include "cocos/base/DeferredReleasePool.h" +#include "cocos/base/Map.h" +#include "cocos/base/Vector.h" +#include "cocos/core/TypedArray.h" +#include "cocos/math/Geometry.h" +#include "cocos/math/Quaternion.h" +#include "cocos/math/Vec2.h" +#include "cocos/math/Vec3.h" +#include "core/ArrayBuffer.h" +#include "core/geometry/AABB.h" +#include "extensions/cocos-ext.h" +#include "network/Downloader.h" + +#include "cocos/core/geometry/Geometry.h" +#include "scene/Fog.h" +#include "scene/Shadow.h" +#include "scene/Skybox.h" + +///////////////////////// utils ///////////////////////// + +template +struct overloaded; + +template +struct overloaded : F0, overloaded { + overloaded(F0 f0, Fs... rest) : F0(f0), overloaded(rest...) {} // NOLINT(google-explicit-constructor) + + using F0:: operator(); + using overloaded::operator(); +}; + +template +struct overloaded : F0 { + overloaded(F0 f0) : F0(f0) {} // NOLINT(google-explicit-constructor) + + using F0::operator(); +}; + +template +auto make_overloaded(Fs... fs) { // NOLINT(readability-identifier-naming) + return overloaded(fs...); +} + +template +typename std::enable_if::value, bool>::type +set_member_field(se::Object *obj, T *to, const std::string &property, F f, se::Value &tmp) { // NOLINT + bool ok = obj->getProperty(property.data(), &tmp, true); + SE_PRECONDITION2(ok, false, "Property '%s' is not set", property.data()); + + A m; + ok = sevalue_to_native(tmp, &m, obj); + SE_PRECONDITION2(ok, false, "Convert property '%s' failed", property.data()); + (to->*f)(m); + return true; +} + +template +typename std::enable_if::value, bool>::type +set_member_field(se::Object *obj, T *to, const std::string &property, F f, se::Value &tmp) { // NOLINT + bool ok = obj->getProperty(property.data(), &tmp, true); + SE_PRECONDITION2(ok, false, "Property '%s' is not set", property.data()); + + ok = sevalue_to_native(tmp, &(to->*f), obj); + SE_PRECONDITION2(ok, false, "Convert property '%s' failed", property.data()); + return true; +} + +static bool isNumberString(const std::string &str) { + for (const auto &c : str) { // NOLINT(readability-use-anyofallof) // remove after using c++20 + if (!isdigit(c)) { + return false; + } + } + return true; +} + +namespace { + +template +bool std_vector_T_to_seval(const std::vector &v, se::Value *ret) { // NOLINT(readability-identifier-naming) + assert(ret != nullptr); + se::HandleObject obj(se::Object::createArrayObject(v.size())); + bool ok = true; + + uint32_t i = 0; + for (const auto &value : v) { + if (!obj->setArrayElement(i, se::Value(value))) { + ok = false; + ret->setUndefined(); + break; + } + ++i; + } + + if (ok) { + ret->setObject(obj); + } + + return ok; +} + +} // namespace + +namespace { +enum class DataType { + INT, + FLOAT +}; +bool uintptr_t_to_seval(uintptr_t v, se::Value *ret) { // NOLINT(readability-identifier-naming) + ret->setDouble(v); + return true; +} + +bool size_to_seval(size_t v, se::Value *ret) { // NOLINT(readability-identifier-naming) + ret->setSize(v); + return true; +} + +bool Vec2_to_seval(const cc::Vec2 &v, se::Value *ret) { // NOLINT(readability-identifier-naming) + assert(ret != nullptr); + se::HandleObject obj(se::Object::createPlainObject()); + obj->setProperty("x", se::Value(v.x)); + obj->setProperty("y", se::Value(v.y)); + ret->setObject(obj); + + return true; +} + +bool Vec3_to_seval(const cc::Vec3 &v, se::Value *ret) { // NOLINT(readability-identifier-naming) + assert(ret != nullptr); + se::HandleObject obj(se::Object::createPlainObject()); + obj->setProperty("x", se::Value(v.x)); + obj->setProperty("y", se::Value(v.y)); + obj->setProperty("z", se::Value(v.z)); + ret->setObject(obj); + + return true; +} + +bool Vec4_to_seval(const cc::Vec4 &v, se::Value *ret) { // NOLINT(readability-identifier-naming) + assert(ret != nullptr); + se::HandleObject obj(se::Object::createPlainObject()); + obj->setProperty("x", se::Value(v.x)); + obj->setProperty("y", se::Value(v.y)); + obj->setProperty("z", se::Value(v.z)); + obj->setProperty("w", se::Value(v.w)); + ret->setObject(obj); + + return true; +} + +bool Quaternion_to_seval(const cc::Quaternion &v, se::Value *ret) { // NOLINT(readability-identifier-naming) + assert(ret != nullptr); + se::HandleObject obj(se::Object::createPlainObject()); + obj->setProperty("x", se::Value(v.x)); + obj->setProperty("y", se::Value(v.y)); + obj->setProperty("z", se::Value(v.z)); + obj->setProperty("w", se::Value(v.w)); + ret->setObject(obj); + + return true; +} + +bool Mat4_to_seval(const cc::Mat4 &v, se::Value *ret) { // NOLINT(readability-identifier-naming) + assert(ret != nullptr); + se::HandleObject obj(se::Object::createArrayObject(16)); + + for (uint8_t i = 0; i < 16; ++i) { + obj->setArrayElement(i, se::Value(v.m[i])); + } + + ret->setObject(obj); + return true; +} + +bool Size_to_seval(const cc::Size &v, se::Value *ret) { // NOLINT(readability-identifier-naming) + assert(ret != nullptr); + se::HandleObject obj(se::Object::createPlainObject()); + obj->setProperty("width", se::Value(v.width)); + obj->setProperty("height", se::Value(v.height)); + ret->setObject(obj); + return true; +} + +bool Rect_to_seval(const cc::Rect &v, se::Value *ret) { // NOLINT(readability-identifier-naming) + assert(ret != nullptr); + se::HandleObject obj(se::Object::createPlainObject()); + obj->setProperty("x", se::Value(v.origin.x)); + obj->setProperty("y", se::Value(v.origin.y)); + obj->setProperty("width", se::Value(v.size.width)); + obj->setProperty("height", se::Value(v.size.height)); + ret->setObject(obj); + + return true; +} +void toVec2(void *data, DataType type, se::Value *ret) { + auto * intptr = static_cast(data); + auto * floatptr = static_cast(data); + cc::Vec2 vec2; + if (DataType::INT == type) { + vec2.x = static_cast(intptr[0]); + vec2.y = static_cast(intptr[1]); + } else { + vec2.x = *floatptr; + vec2.y = *(floatptr + 1); + } + + Vec2_to_seval(vec2, ret); +} + +void toVec3(void *data, DataType type, se::Value *ret) { + auto * intptr = static_cast(data); + auto * floatptr = static_cast(data); + cc::Vec3 vec3; + if (DataType::INT == type) { + vec3.x = static_cast(intptr[0]); + vec3.y = static_cast(intptr[1]); + vec3.z = static_cast(intptr[2]); + } else { + vec3.x = floatptr[0]; + vec3.y = floatptr[1]; + vec3.z = floatptr[2]; + } + + Vec3_to_seval(vec3, ret); +} + +void toVec4(void *data, DataType type, se::Value *ret) { + auto * intptr = static_cast(data); + auto * floatptr = static_cast(data); + cc::Vec4 vec4; + if (DataType::INT == type) { + vec4.x = static_cast(intptr[0]); + vec4.y = static_cast(intptr[1]); + vec4.z = static_cast(intptr[2]); + vec4.w = static_cast(intptr[3]); + } else { + vec4.x = *floatptr; + vec4.y = *(floatptr + 1); + vec4.z = *(floatptr + 2); + vec4.w = *(floatptr + 3); + } + + Vec4_to_seval(vec4, ret); +} + +void toMat(const float *data, int num, se::Value *ret) { + se::HandleObject obj(se::Object::createPlainObject()); + + char propName[4] = {0}; + for (int i = 0; i < num; ++i) { + if (i < 10) { + snprintf(propName, 3, "m0%d", i); + } + + else { + snprintf(propName, 3, "m%d", i); + } + + obj->setProperty(propName, se::Value(*(data + i))); + } + ret->setObject(obj); +} +} // namespace + +//////////////////////////////////////////////////////////////////////////// +/////////////////sevalue to native////////////////////////////////////////// +//////////////////////////////////////////////////////////////////////////// + +// NOLINTNEXTLINE(readability-identifier-naming) +bool seval_to_ccvalue(const se::Value &v, cc::Value *ret) { + assert(ret != nullptr); + bool ok = true; + if (v.isObject()) { + se::Object *jsobj = v.toObject(); + if (!jsobj->isArray()) { + // It's a normal js object. + cc::ValueMap dictVal; + ok = seval_to_ccvaluemap(v, &dictVal); + SE_PRECONDITION3(ok, false, *ret = cc::Value::VALUE_NULL); + *ret = cc::Value(dictVal); + } else { + // It's a js array object. + cc::ValueVector arrVal; + ok = seval_to_ccvaluevector(v, &arrVal); + SE_PRECONDITION3(ok, false, *ret = cc::Value::VALUE_NULL); + *ret = cc::Value(arrVal); + } + } else if (v.isString()) { + *ret = v.toString(); + } else if (v.isNumber()) { + *ret = v.toDouble(); + } else if (v.isBoolean()) { + *ret = v.toBoolean(); + } else if (v.isNullOrUndefined()) { + *ret = cc::Value::VALUE_NULL; + } else { + SE_PRECONDITION2(false, false, "type not supported!"); + } + + return ok; +} + +// NOLINTNEXTLINE(readability-identifier-naming) +bool seval_to_ccvaluemap(const se::Value &v, cc::ValueMap *ret) { + assert(ret != nullptr); + + if (v.isNullOrUndefined()) { + ret->clear(); + return true; + } + + SE_PRECONDITION3(v.isObject(), false, ret->clear()); + SE_PRECONDITION3(!v.isNullOrUndefined(), false, ret->clear()); + + se::Object *obj = v.toObject(); + + cc::ValueMap &dict = *ret; + + std::vector allKeys; + SE_PRECONDITION3(obj->getAllKeys(&allKeys), false, ret->clear()); + + bool ok = false; + se::Value value; + cc::Value ccvalue; + for (const auto &key : allKeys) { + SE_PRECONDITION3(obj->getProperty(key.c_str(), &value), false, ret->clear()); + ok = seval_to_ccvalue(value, &ccvalue); + SE_PRECONDITION3(ok, false, ret->clear()); + dict.emplace(key, ccvalue); + } + + return true; +} + +// NOLINTNEXTLINE(readability-identifier-naming) +bool seval_to_ccvaluemapintkey(const se::Value &v, cc::ValueMapIntKey *ret) { + assert(ret != nullptr); + if (v.isNullOrUndefined()) { + ret->clear(); + return true; + } + + SE_PRECONDITION3(v.isObject(), false, ret->clear()); + SE_PRECONDITION3(!v.isNullOrUndefined(), false, ret->clear()); + + se::Object *obj = v.toObject(); + + cc::ValueMapIntKey &dict = *ret; + + std::vector allKeys; + SE_PRECONDITION3(obj->getAllKeys(&allKeys), false, ret->clear()); + + bool ok = false; + se::Value value; + cc::Value ccvalue; + for (const auto &key : allKeys) { + SE_PRECONDITION3(obj->getProperty(key.c_str(), &value), false, ret->clear()); + + if (!isNumberString(key)) { + SE_LOGD("seval_to_ccvaluemapintkey, found not numeric key: %s", key.c_str()); + continue; + } + + int intKey = atoi(key.c_str()); + + ok = seval_to_ccvalue(value, &ccvalue); + SE_PRECONDITION3(ok, false, ret->clear()); + dict.emplace(intKey, ccvalue); + } + + return true; +} + +// NOLINTNEXTLINE(readability-identifier-naming) +bool seval_to_ccvaluevector(const se::Value &v, cc::ValueVector *ret) { + assert(ret != nullptr); + + SE_PRECONDITION3(v.isObject(), false, ret->clear()); + + se::Object *obj = v.toObject(); + SE_PRECONDITION3(obj->isArray(), false, ret->clear()); + + uint32_t len = 0; + obj->getArrayLength(&len); + + bool ok = false; + se::Value value; + cc::Value ccvalue; + for (uint32_t i = 0; i < len; ++i) { + if (obj->getArrayElement(i, &value)) { + ok = seval_to_ccvalue(value, &ccvalue); + SE_PRECONDITION3(ok, false, ret->clear()); + ret->push_back(ccvalue); + } + } + + return true; +} + +// NOLINTNEXTLINE(readability-identifier-naming) +bool sevals_variadic_to_ccvaluevector(const se::ValueArray &args, cc::ValueVector *ret) { + bool ok = false; + cc::Value ccvalue; + + for (const auto &arg : args) { + ok = seval_to_ccvalue(arg, &ccvalue); + SE_PRECONDITION3(ok, false, ret->clear()); + ret->push_back(ccvalue); + } + + return true; +} + +// NOLINTNEXTLINE(readability-identifier-naming) +bool seval_to_Data(const se::Value &v, cc::Data *ret) { + assert(ret != nullptr); + SE_PRECONDITION2(v.isObject() && v.toObject()->isTypedArray(), false, "Convert parameter to Data failed!"); + uint8_t *ptr = nullptr; + size_t length = 0; + bool ok = v.toObject()->getTypedArrayData(&ptr, &length); + if (ok) { + ret->copy(ptr, static_cast(length)); + } else { + ret->clear(); + } + + return ok; +} + +// NOLINTNEXTLINE(readability-identifier-naming) +bool seval_to_DownloaderHints(const se::Value &v, cc::network::DownloaderHints *ret) { + const static cc::network::DownloaderHints ZERO{0, 0, ""}; + assert(ret != nullptr); + SE_PRECONDITION2(v.isObject(), false, "Convert parameter to DownloaderHints failed!"); + se::Value tmp; + se::Object *obj = v.toObject(); + bool ok = false; + + ok = obj->getProperty("countOfMaxProcessingTasks", &tmp); + SE_PRECONDITION3(ok && tmp.isNumber(), false, *ret = ZERO); + ret->countOfMaxProcessingTasks = tmp.toUint32(); + + ok = obj->getProperty("timeoutInSeconds", &tmp); + SE_PRECONDITION3(ok && tmp.isNumber(), false, *ret = ZERO); + ret->timeoutInSeconds = tmp.toUint32(); + + ok = obj->getProperty("tempFileNameSuffix", &tmp); + SE_PRECONDITION3(ok && tmp.isString(), false, *ret = ZERO); + ret->tempFileNameSuffix = tmp.toString(); + + return ok; +} + +// NOLINTNEXTLINE(readability-identifier-naming) +bool sevalue_to_native(const se::Value &from, cc::Vec4 *to, se::Object * /*unused*/) { + SE_PRECONDITION2(from.isObject(), false, "Convert parameter to Vec4 failed!"); + se::Object *obj = from.toObject(); + se::Value tmp; + set_member_field(obj, to, "x", &cc::Vec4::x, tmp); + set_member_field(obj, to, "y", &cc::Vec4::y, tmp); + set_member_field(obj, to, "z", &cc::Vec4::z, tmp); + set_member_field(obj, to, "w", &cc::Vec4::w, tmp); + return true; +} + +// NOLINTNEXTLINE(readability-identifier-naming) +bool sevalue_to_native(const se::Value &from, cc::Mat3 *to, se::Object * /*unused*/) { + SE_PRECONDITION2(from.isObject(), false, "Convert parameter to Matrix3 failed!"); + se::Object *obj = from.toObject(); + + if (obj->isTypedArray()) { + // typed array + SE_PRECONDITION2(obj->isTypedArray(), false, "Convert parameter to Matrix3 failed!"); + size_t length = 0; + uint8_t *ptr = nullptr; + obj->getTypedArrayData(&ptr, &length); + + memcpy(to->m, ptr, length); + } else { + bool ok = false; + se::Value tmp; + std::string prefix = "m"; + for (uint32_t i = 0; i < 9; ++i) { + std::string name; + if (i < 10) { + name = prefix + "0" + std::to_string(i); + } else { + name = prefix + std::to_string(i); + } + ok = obj->getProperty(name.c_str(), &tmp, true); + SE_PRECONDITION3(ok, false, *to = cc::Mat3::IDENTITY); + + if (tmp.isNumber()) { + to->m[i] = tmp.toFloat(); + } else { + SE_REPORT_ERROR("%u, not supported type in matrix", i); + *to = cc::Mat3::IDENTITY; + return false; + } + + tmp.setUndefined(); + } + } + + return true; +} + +// NOLINTNEXTLINE(readability-identifier-naming) +bool sevalue_to_native(const se::Value &from, cc::Mat4 *to, se::Object * /*unused*/) { + SE_PRECONDITION2(from.isObject(), false, "Convert parameter to Matrix4 failed!"); + se::Object *obj = from.toObject(); + + if (obj->isTypedArray()) { + // typed array + SE_PRECONDITION2(obj->isTypedArray(), false, "Convert parameter to Matrix4 failed!"); + + size_t length = 0; + uint8_t *ptr = nullptr; + obj->getTypedArrayData(&ptr, &length); + + memcpy(to->m, ptr, length); + } else { + bool ok = false; + se::Value tmp; + std::string prefix = "m"; + for (uint32_t i = 0; i < 16; ++i) { + std::string name; + if (i < 10) { + name = prefix + "0" + std::to_string(i); + } else { + name = prefix + std::to_string(i); + } + ok = obj->getProperty(name.c_str(), &tmp, true); + SE_PRECONDITION3(ok, false, *to = cc::Mat4::IDENTITY); + + if (tmp.isNumber()) { + to->m[i] = tmp.toFloat(); + } else { + SE_REPORT_ERROR("%u, not supported type in matrix", i); + *to = cc::Mat4::IDENTITY; + return false; + } + + tmp.setUndefined(); + } + } + + return true; +} + +// NOLINTNEXTLINE(readability-identifier-naming) +bool sevalue_to_native(const se::Value &from, cc::Vec3 *to, se::Object * /*unused*/) { + SE_PRECONDITION2(from.isObject(), false, "Convert parameter to Vec3 failed!"); + + se::Object *obj = from.toObject(); + se::Value tmp; + set_member_field(obj, to, "x", &cc::Vec3::x, tmp); + set_member_field(obj, to, "y", &cc::Vec3::y, tmp); + set_member_field(obj, to, "z", &cc::Vec3::z, tmp); + return true; +} + +// NOLINTNEXTLINE(readability-identifier-naming) +bool sevalue_to_native(const se::Value &from, cc::Color *to, se::Object * /*unused*/) { + SE_PRECONDITION2(from.isObject(), false, "Convert parameter to Color failed!"); + + se::Object *obj = from.toObject(); + se::Value t; + set_member_field(obj, to, "r", &cc::Color::r, t); + set_member_field(obj, to, "g", &cc::Color::g, t); + set_member_field(obj, to, "b", &cc::Color::b, t); + set_member_field(obj, to, "a", &cc::Color::a, t); + return true; +} + +// NOLINTNEXTLINE(readability-identifier-naming) +bool sevalue_to_native(const se::Value &from, cc::Vec2 *to, se::Object * /*unused*/) { + SE_PRECONDITION2(from.isObject(), false, "Convert parameter to Vec2 failed!"); + + se::Object *obj = from.toObject(); + se::Value tmp; + set_member_field(obj, to, "x", &cc::Vec2::x, tmp); + set_member_field(obj, to, "y", &cc::Vec2::y, tmp); + return true; +} + +// NOLINTNEXTLINE(readability-identifier-naming) +bool sevalue_to_native(const se::Value &from, cc::Size *to, se::Object * /*unused*/) { + SE_PRECONDITION2(from.isObject(), false, "Convert parameter to Size failed!"); + + se::Object *obj = from.toObject(); + se::Value tmp; + set_member_field(obj, to, "width", &cc::Size::width, tmp); + set_member_field(obj, to, "height", &cc::Size::height, tmp); + return true; +} + +// NOLINTNEXTLINE(readability-identifier-naming) +bool sevalue_to_native(const se::Value &from, cc::Quaternion *to, se::Object * /*unused*/) { + SE_PRECONDITION2(from.isObject(), false, "Convert parameter to Quaternion failed!"); + se::Object *obj = from.toObject(); + se::Value tmp; + set_member_field(obj, to, "x", &cc::Quaternion::x, tmp); + set_member_field(obj, to, "y", &cc::Quaternion::y, tmp); + set_member_field(obj, to, "z", &cc::Quaternion::z, tmp); + set_member_field(obj, to, "w", &cc::Quaternion::w, tmp); + return true; +} + +//////////////////// geometry + +// NOLINTNEXTLINE(readability-identifier-naming) +bool sevalue_to_native(const se::Value &from, cc::geometry::AABB *to, se::Object * /*ctx*/) { + SE_PRECONDITION2(from.isObject(), false, "Convert parameter to AABB failed!"); + se::Object *obj = from.toObject(); + se::Value tmp; + set_member_field(obj, to, "halfExtents", &cc::geometry::AABB::halfExtents, tmp); + set_member_field(obj, to, "center", &cc::geometry::AABB::center, tmp); + return true; +} + +// NOLINTNEXTLINE(readability-identifier-naming) +bool sevalue_to_native(const se::Value &from, cc::geometry::Capsule *to, se::Object * /*ctx*/) { + SE_PRECONDITION2(from.isObject(), false, "Convert parameter to Capsule failed!"); + se::Object *obj = from.toObject(); + se::Value tmp; + set_member_field(obj, to, "radius", &cc::geometry::Capsule::radius, tmp); + set_member_field(obj, to, "halfHeight", &cc::geometry::Capsule::halfHeight, tmp); + set_member_field(obj, to, "axis", &cc::geometry::Capsule::axis, tmp); + return true; +} + +// NOLINTNEXTLINE(readability-identifier-naming) +bool sevalue_to_native(const se::Value &from, cc::geometry::Line *to, se::Object * /*ctx*/) { + SE_PRECONDITION2(from.isObject(), false, "Convert parameter to Line failed!"); + se::Object *obj = from.toObject(); + se::Value tmp; + set_member_field(obj, to, "s", &cc::geometry::Line::s, tmp); + set_member_field(obj, to, "e", &cc::geometry::Line::e, tmp); + return true; +} + +// NOLINTNEXTLINE(readability-identifier-naming) +bool sevalue_to_native(const se::Value &from, cc::geometry::Ray *to, se::Object * /*ctx*/) { + SE_PRECONDITION2(from.isObject(), false, "Convert parameter to Sphere failed!"); + se::Object *obj = from.toObject(); + se::Value tmp; + set_member_field(obj, to, "o", &cc::geometry::Ray::o, tmp); + set_member_field(obj, to, "d", &cc::geometry::Ray::d, tmp); + return true; +} + +// NOLINTNEXTLINE(readability-identifier-naming) +bool sevalue_to_native(const se::Value &from, cc::geometry::Sphere *to, se::Object * /*ctx*/) { + SE_PRECONDITION2(from.isObject(), false, "Convert parameter to Sphere failed!"); + se::Object *obj = from.toObject(); + se::Value tmp; + set_member_field(obj, to, "radius", &cc::geometry::Sphere::setRadius, tmp); + set_member_field(obj, to, "center", &cc::geometry::Sphere::setCenter, tmp); + return true; +} + +// NOLINTNEXTLINE(readability-identifier-naming) +bool sevalue_to_native(const se::Value &from, cc::geometry::Triangle *to, se::Object * /*ctx*/) { + SE_PRECONDITION2(from.isObject(), false, "Convert parameter to Plane failed!"); + se::Object *obj = from.toObject(); + se::Value tmp; + set_member_field(obj, to, "a", &cc::geometry::Triangle::a, tmp); + set_member_field(obj, to, "b", &cc::geometry::Triangle::b, tmp); + set_member_field(obj, to, "c", &cc::geometry::Triangle::c, tmp); + return true; +} + +// NOLINTNEXTLINE(readability-identifier-naming) +bool sevalue_to_native(const se::Value &from, cc::geometry::Plane *to, se::Object * /*unused*/) { + SE_PRECONDITION2(from.isObject(), false, "Convert parameter to Plane failed!"); + se::Object *obj = from.toObject(); + se::Value tmp; + set_member_field(obj, to, "n", &cc::geometry::Plane::n, tmp); + set_member_field(obj, to, "d", &cc::geometry::Plane::d, tmp); + return true; +} + +// NOLINTNEXTLINE(readability-identifier-naming) +bool sevalue_to_native(const se::Value &from, cc::geometry::Plane **to, se::Object *ctx) { + return sevalue_to_native(from, *to, ctx); +} + +// NOLINTNEXTLINE(readability-identifier-naming) +bool sevalue_to_native(const se::Value &from, cc::geometry::Frustum *to, se::Object * /*unused*/) { + SE_PRECONDITION2(from.isObject(), false, "Convert parameter to Frustum failed!"); + se::Object *obj = from.toObject(); + se::Value tmp; + set_member_field>(obj, to, "planes", &cc::geometry::Frustum::planes, tmp); + set_member_field>(obj, to, "vertices", &cc::geometry::Frustum::vertices, tmp); + return true; +} + +////////////////////////// scene info + +// NOLINTNEXTLINE(readability-identifier-naming) +bool sevalue_to_native(const se::Value &from, cc::scene::FogInfo *to, se::Object * /*ctx*/) { + SE_PRECONDITION2(from.isObject(), false, "Convert parameter to FogInfo failed!"); + se::Object *obj = from.toObject(); + se::Value tmp; + set_member_field(obj, to, "type", &cc::scene::FogInfo::setType, tmp); + set_member_field(obj, to, "fogColor", &cc::scene::FogInfo::setFogColor, tmp); + set_member_field(obj, to, "enabled", &cc::scene::FogInfo::setEnabled, tmp); + set_member_field(obj, to, "fogDensity", &cc::scene::FogInfo::setFogDensity, tmp); + set_member_field(obj, to, "fogStart", &cc::scene::FogInfo::setFogStart, tmp); + set_member_field(obj, to, "fogEnd", &cc::scene::FogInfo::setFogEnd, tmp); + set_member_field(obj, to, "fogAtten", &cc::scene::FogInfo::setFogAtten, tmp); + set_member_field(obj, to, "fogTop", &cc::scene::FogInfo::setFogTop, tmp); + set_member_field(obj, to, "fogRange", &cc::scene::FogInfo::setFogRange, tmp); + // TODO(PatriceJiang): covnert resource ?? + // set_member_field(obj, to, "resource", &cc::scene::FogInfo::setResource, tmp); + return true; +} + +// NOLINTNEXTLINE(readability-identifier-naming) +bool sevalue_to_native(const se::Value &from, cc::scene::ShadowsInfo *to, se::Object * /*ctx*/) { + SE_PRECONDITION2(from.isObject(), false, "Convert parameter to ShadowInfo failed!"); + se::Object *obj = from.toObject(); + se::Value tmp; + set_member_field(obj, to, "type", &cc::scene::ShadowsInfo::setType, tmp); + set_member_field(obj, to, "enabled", &cc::scene::ShadowsInfo::setEnabled, tmp); + set_member_field(obj, to, "normal", &cc::scene::ShadowsInfo::setNormal, tmp); + set_member_field(obj, to, "distance", &cc::scene::ShadowsInfo::setDistance, tmp); + set_member_field(obj, to, "shadowColor", &cc::scene::ShadowsInfo::setShadowColor, tmp); + set_member_field(obj, to, "fixedArea", &cc::scene::ShadowsInfo::setFixedArea, tmp); + set_member_field(obj, to, "pcf", &cc::scene::ShadowsInfo::setPcf, tmp); + set_member_field(obj, to, "bias", &cc::scene::ShadowsInfo::setBias, tmp); + set_member_field(obj, to, "normalBias", &cc::scene::ShadowsInfo::setNormalBias, tmp); + set_member_field(obj, to, "near", &cc::scene::ShadowsInfo::setNear, tmp); + set_member_field(obj, to, "far", &cc::scene::ShadowsInfo::setFar, tmp); + set_member_field(obj, to, "orthoSize", &cc::scene::ShadowsInfo::setOrthoSize, tmp); + set_member_field(obj, to, "maxReceived", &cc::scene::ShadowsInfo::setMaxReceived, tmp); + set_member_field(obj, to, "size", &cc::scene::ShadowsInfo::setShadowMapSize, tmp); + set_member_field(obj, to, "saturation", &cc::scene::ShadowsInfo::setSaturation, tmp); + // TODO(PatriceJiang): covnert resource ?? + // set_member_field(obj, to, "resource", &cc::scene::ShadowInfo::setResource, tmp); + + return true; +} + +// NOLINTNEXTLINE(readability-identifier-naming) +bool sevalue_to_native(const se::Value &from, cc::scene::SkyboxInfo *to, se::Object * /*ctx*/) { + SE_PRECONDITION2(from.isObject(), false, "Convert parameter to ShadowInfo failed!"); + se::Object *obj = from.toObject(); + se::Value tmp; + // TODO(PatriceJiang): export TextureCube + // set_member_field(obj, to, "envmap", &cc::scene::SkyboxInfo::setEnvmap, tmp); + set_member_field(obj, to, "enabled", &cc::scene::SkyboxInfo::setEnabled, tmp); + set_member_field(obj, to, "useIBL", &cc::scene::SkyboxInfo::setUseIBL, tmp); + return true; +} + +// cc::variant; +// NOLINTNEXTLINE(readability-identifier-naming) +bool sevalue_to_native(const se::Value &from, cc::MacroValue *to, se::Object * /*ctx*/) { + if (from.isBoolean()) { + *to = from.toBoolean(); + } else if (from.isNumber()) { + // cjh TODO: how to check it's a int32_t or float? + *to = from.toInt32(); + } else if (from.isString()) { + *to = from.toString(); + } + + return true; +} + +// NOLINTNEXTLINE(readability-identifier-naming) +bool sevalue_to_native(const se::Value &from, std::vector *to, se::Object * /*ctx*/) { + if (from.isNullOrUndefined()) { + to->clear(); + return true; + } + + SE_PRECONDITION2(from.isObject(), false, "sevalue_to_native(std::vector), not an object"); + auto *fromObj = from.toObject(); + CC_ASSERT(fromObj->isArray()); + uint32_t len = 0; + bool ok = fromObj->getArrayLength(&len); + if (ok) { + to->resize(len); + se::Value arrElement; + for (uint32_t i = 0; i < len; ++i) { + ok = fromObj->getArrayElement(i, &arrElement); + if (!ok || !arrElement.isObject()) { + continue; + } + cc::MacroRecord macroRecord; + std::vector keys; + ok = arrElement.toObject()->getAllKeys(&keys); + if (ok) { + se::Value seMacroVal; + for (const auto &key : keys) { + ok = arrElement.toObject()->getProperty(key, &seMacroVal); + cc::MacroValue macroVal; + sevalue_to_native(seMacroVal, ¯oVal, nullptr); + macroRecord.emplace(key, std::move(macroVal)); + } + } + (*to)[i] = std::move(macroRecord); + } + } + + return true; +} + +// NOLINTNEXTLINE(readability-identifier-naming) +bool sevalue_to_native(const se::Value &from, cc::MaterialProperty *to, se::Object *ctx) { + if (from.isNullOrUndefined()) { + *to = cc::monostate(); + return true; + } + + // TODO(PatriceJiang): float/int32_t from js number + if (from.isNumber()) { + double v = from.toDouble(); + if (std::trunc(v) != v) { + *to = static_cast(v); + } else { + *to = static_cast(v); + } + return true; + } + + if (from.isObject()) { + auto *obj = const_cast(from.toObject()); + bool hasX; + bool hasY; + bool hasZ; + bool hasW; + bool hasEuler; + bool hasM01; + bool hasM08; + bool hasM15; + bool hasAssetID; + bool hasColorVal; + + se::Value tmp0; + se::Value tmp1; + se::Value tmp2; + se::Value tmp3; + se::Value tmp4; + + hasColorVal = obj->getProperty("_val", &tmp0, true); + if (hasColorVal) { + *to = cc::Color{tmp0.toUint32()}; + return true; + } + + hasX = obj->getProperty("x", &tmp0, true); + hasY = hasX && obj->getProperty("y", &tmp1, true); + hasZ = hasY && obj->getProperty("z", &tmp2, true); + hasW = hasZ && obj->getProperty("w", &tmp3, true); + hasEuler = hasW && obj->getProperty("getEulerAngles", &tmp4, true); + + if (hasW) { + if (hasEuler) { + *to = cc::Quaternion(tmp0.toFloat(), tmp1.toFloat(), tmp2.toFloat(), tmp3.toFloat()); + } else { + *to = cc::Vec4(tmp0.toFloat(), tmp1.toFloat(), tmp2.toFloat(), tmp3.toFloat()); + } + return true; + } + + if (hasZ) { + *to = cc::Vec3(tmp0.toFloat(), tmp1.toFloat(), tmp2.toFloat()); + return true; + } + + if (hasY) { + *to = cc::Vec2(tmp0.toFloat(), tmp1.toFloat()); + return true; + } + + hasM01 = obj->getProperty("m00", &tmp0, true); + hasM08 = hasM01 && obj->getProperty("m08", &tmp1, true); + hasM15 = hasM08 && obj->getProperty("m15", &tmp2, true); + + if (hasM15) { + cc::Mat4 m4; + sevalue_to_native(from, &m4, ctx); + *to = m4; + return true; + } + + if (hasM08) { + cc::Mat3 m3; + sevalue_to_native(from, &m3, ctx); + *to = m3; + return true; + } + + hasAssetID = obj->getProperty("_id", &tmp3, true); + if (hasAssetID) { + *to = reinterpret_cast(obj->getPrivateData()); + return true; + } + + // TODO(): optimize the the performance? + if (obj->_getClass() != nullptr) { + if (0 == strcmp(obj->_getClass()->getName(), "Texture2D")) { + *to = reinterpret_cast(obj->getPrivateData()); + return true; + } + + if (0 == strcmp(obj->_getClass()->getName(), "TextureCube")) { + *to = reinterpret_cast(obj->getPrivateData()); + return true; + } + + if (0 == strcmp(obj->_getClass()->getName(), "RenderTexture")) { + *to = reinterpret_cast(obj->getPrivateData()); + return true; + } + } + + // gfx::Texture? + *to = reinterpret_cast(obj->getPrivateData()); + return true; + } + + return false; +} + +// NOLINTNEXTLINE(readability-identifier-naming) +bool sevalue_to_native(const se::Value &from, cc::IPreCompileInfoValueType *to, se::Object *ctx) { + se::Object *obj = from.toObject(); + SE_PRECONDITION2(obj->isArray(), false, "faild to convert to IPreCompileInfoValueType"); + + uint32_t len; + obj->getArrayLength(&len); + if (len == 0) { + // TODO(PatriceJiang): judge type of empty array? + *to = std::vector{}; + return false; + } + + se::Value firstEle; + obj->getArrayElement(0, &firstEle); + if (firstEle.isBoolean()) { + std::vector result; + sevalue_to_native(from, &result, ctx); + return true; + } + if (firstEle.isNumber()) { + std::vector result; + sevalue_to_native(from, &result, ctx); + return true; + } + if (firstEle.isString()) { + std::vector result; + sevalue_to_native(from, &result, ctx); + return true; + } + + return false; +} + +// NOLINTNEXTLINE(readability-identifier-naming) +bool sevalue_to_native(const se::Value &from, cc::variant, std::string> *to, se::Object * /*ctx*/) { + if (from.isObject() && from.toObject()->isArray()) { + uint32_t len = 0; + bool ok = from.toObject()->getArrayLength(&len); + std::vector arr; + arr.resize(len); + for (uint32_t i = 0; i < len; ++i) { + se::Value e; + ok = from.toObject()->getArrayElement(i, &e); + if (ok) { + if (e.isNumber()) { + arr[i] = e.toFloat(); + } + } + } + *to = std::move(arr); + } else if (from.isString()) { + *to = from.toString(); + } else { + CC_ASSERT(false); + } + return true; +} + +// NOLINTNEXTLINE(readability-identifier-naming) +bool sevalue_to_native(const se::Value &from, cc::variant *to, se::Object *ctx) { + bool ok = false; + if (from.isObject() && from.toObject()->isArray()) { + cc::MaterialPropertyList propertyList{}; + ok = sevalue_to_native(from, &propertyList, ctx); + if (ok) { + *to = std::move(propertyList); + } + } else { + cc::MaterialProperty property; + ok = sevalue_to_native(from, &property, ctx); + if (ok) { + *to = std::move(property); + } + } + + return true; +} + +// NOLINTNEXTLINE(readability-identifier-naming) +bool sevalue_to_native(const se::Value &from, cc::ArrayBuffer *to, se::Object * /*ctx*/) { + assert(from.isObject()); + to->setJSArrayBuffer(from.toObject()); + return true; +} +bool sevalue_to_native(const se::Value &from, cc::ArrayBuffer **to, se::Object * /*ctx*/) { + assert(from.isObject()); + *to = new cc::ArrayBuffer(); + (*to)->addRef(); + (*to)->setJSArrayBuffer(from.toObject()); + cc::DeferredReleasePool::add(*to); + return true; +} + +// NOLINTNEXTLINE(readability-identifier-naming) +bool sevalue_to_native(const se::Value &from, std::vector *to, se::Object * /*ctx*/) { + if (from.isNullOrUndefined()) { + to->clear(); + return true; + } + + se::Object *arr = from.toObject(); + uint32_t size; + se::Value tmp; + arr->getArrayLength(&size); + to->resize(size); + for (uint32_t i = 0; i < size; i++) { + arr->getArrayElement(i, &tmp); + (*to)[i] = tmp.toBoolean(); + } + return true; +} + +// NOLINTNEXTLINE(readability-identifier-naming) +bool sevalue_to_native(const se::Value &from, std::vector *to, se::Object * /*ctx*/) { + if (from.isNullOrUndefined()) { + to->clear(); + return true; + } + + assert(from.isObject()); + se::Object *in = from.toObject(); + + if (in->isTypedArray()) { + uint8_t *data = nullptr; + size_t dataLen = 0; + in->getTypedArrayData(&data, &dataLen); + to->resize(dataLen); + to->assign(data, data + dataLen); + return true; + } + + if (in->isArrayBuffer()) { + uint8_t *data = nullptr; + size_t dataLen = 0; + in->getArrayBufferData(&data, &dataLen); + to->resize(dataLen); + to->assign(data, data + dataLen); + return true; + } + + if (in->isArray()) { + uint32_t len = 0; + in->getArrayLength(&len); + to->resize(len); + se::Value ele; + for (uint32_t i = 0; i < len; i++) { + in->getArrayElement(i, &ele); + (*to)[i] = ele.toUint8(); + } + return true; + } + + SE_LOGE("type error, ArrayBuffer/TypedArray/Array expected!"); + return false; +} + +// NOLINTNEXTLINE(readability-identifier-naming) +bool sevalue_to_native(const se::Value &from, cc::TypedArray *to, se::Object * /*ctx*/) { + CC_ASSERT(from.isObject()); + CC_ASSERT(from.toObject()->isTypedArray()); + if (to->index() == 0) { + se::Object::TypedArrayType type = from.toObject()->getTypedArrayType(); + switch (type) { + case se::Object::TypedArrayType::FLOAT32: + *to = cc::Float32Array(); + break; + case se::Object::TypedArrayType::UINT16: + *to = cc::Uint16Array(); + break; + case se::Object::TypedArrayType::UINT32: + *to = cc::Uint32Array(); + break; + case se::Object::TypedArrayType::UINT8: + *to = cc::Uint8Array(); + break; + case se::Object::TypedArrayType::INT32: + *to = cc::Int32Array(); + break; + case se::Object::TypedArrayType::INT16: + *to = cc::Int16Array(); + break; + case se::Object::TypedArrayType::INT8: + *to = cc::Int8Array(); + break; + case se::Object::TypedArrayType::FLOAT64: + *to = cc::Float64Array(); + break; + default: + CC_ASSERT(false); + } + } + + cc::visit(make_overloaded( + [&](auto &typedArray) { + typedArray.setJSTypedArray(from.toObject()); + }, + [](cc::monostate /*unused*/) {}), + *to); + return true; +} + +// NOLINTNEXTLINE(readability-identifier-naming) +bool sevalue_to_native(const se::Value &from, cc::IBArray *to, se::Object * /*ctx*/) { + cc::visit([&](auto &typedArray) { + typedArray.setJSTypedArray(from.toObject()); + }, + *to); + + return true; +} + +#if USE_SPINE + +// NOLINTNEXTLINE(readability-identifier-naming) +bool sevalue_to_native(const se::Value &val, spine::String *obj, se::Object * /*unused*/) { + *obj = val.toString().data(); + return true; +} + +// NOLINTNEXTLINE(readability-identifier-naming) +bool sevalue_to_native(const se::Value &v, spine::Vector *ret, se::Object * /*unused*/) { + assert(v.isObject()); + se::Object *obj = v.toObject(); + assert(obj->isArray()); + + bool ok = true; + uint32_t len = 0; + ok = obj->getArrayLength(&len); + if (!ok) { + ret->clear(); + return false; + } + + se::Value tmp; + for (uint32_t i = 0; i < len; ++i) { + ok = obj->getArrayElement(i, &tmp); + if (!ok || !tmp.isObject()) { + ret->clear(); + return false; + } + + const char *str = tmp.toString().c_str(); + ret->add(str); + } + + return true; +} + +// NOLINTNEXTLINE(readability-identifier-naming) +bool seval_to_Map_string_key(const se::Value &v, cc::Map *ret) { + assert(ret != nullptr); + assert(v.isObject()); + se::Object *obj = v.toObject(); + + std::vector allKeys; + bool ok = obj->getAllKeys(&allKeys); + if (!ok) { + ret->clear(); + return false; + } + + se::Value tmp; + for (const auto &key : allKeys) { + auto pngPos = key.find(".png"); + if (pngPos == std::string::npos) { + continue; + } + + ok = obj->getProperty(key.c_str(), &tmp); + if (!ok || !tmp.isObject()) { + ret->clear(); + return false; + } + auto *nativeObj = static_cast(tmp.toObject()->getPrivateData()); + ret->insert(key, nativeObj); + } + + return true; +} + +//////////////////////////////////////////////////////////////////////////// +/////////////////nativevalue_to_se////////////////////////////////////////// +//////////////////////////////////////////////////////////////////////////// + +// native to seval + +// NOLINTNEXTLINE(readability-identifier-naming) +bool ccvalue_to_seval(const cc::Value &v, se::Value *ret) { + assert(ret != nullptr); + bool ok = true; + switch (v.getType()) { + case cc::Value::Type::NONE: + ret->setNull(); + break; + case cc::Value::Type::UNSIGNED: + ret->setUint32(v.asUnsignedInt()); + break; + case cc::Value::Type::BOOLEAN: + ret->setBoolean(v.asBool()); + break; + case cc::Value::Type::FLOAT: + case cc::Value::Type::DOUBLE: + ret->setDouble(v.asDouble()); + break; + case cc::Value::Type::INTEGER: + ret->setInt32(v.asInt()); + break; + case cc::Value::Type::STRING: + ret->setString(v.asString()); + break; + case cc::Value::Type::VECTOR: + ok = ccvaluevector_to_seval(v.asValueVector(), ret); + break; + case cc::Value::Type::MAP: + ok = ccvaluemap_to_seval(v.asValueMap(), ret); + break; + case cc::Value::Type::INT_KEY_MAP: + ok = ccvaluemapintkey_to_seval(v.asIntKeyMap(), ret); + break; + default: + SE_LOGE("Could not the way to convert cc::Value::Type (%d) type!", (int)v.getType()); + ok = false; + break; + } + + return ok; +} + +// NOLINTNEXTLINE(readability-identifier-naming) +bool ccvaluemap_to_seval(const cc::ValueMap &v, se::Value *ret) { + assert(ret != nullptr); + + se::HandleObject obj(se::Object::createPlainObject()); + bool ok = true; + for (const auto &e : v) { + const std::string &key = e.first; + const cc::Value & value = e.second; + + if (key.empty()) { + continue; + } + + se::Value tmp; + if (!ccvalue_to_seval(value, &tmp)) { + ok = false; + ret->setUndefined(); + break; + } + + obj->setProperty(key.c_str(), tmp); + } + if (ok) { + ret->setObject(obj); + } + + return ok; +} + +// NOLINTNEXTLINE(readability-identifier-naming) +bool ccvaluemapintkey_to_seval(const cc::ValueMapIntKey &v, se::Value *ret) { + assert(ret != nullptr); + + se::HandleObject obj(se::Object::createPlainObject()); + bool ok = true; + for (const auto &e : v) { + std::stringstream keyss; + keyss << e.first; + std::string key = keyss.str(); + const cc::Value &value = e.second; + + if (key.empty()) { + continue; + } + + se::Value tmp; + if (!ccvalue_to_seval(value, &tmp)) { + ok = false; + ret->setUndefined(); + break; + } + + obj->setProperty(key.c_str(), tmp); + } + if (ok) { + ret->setObject(obj); + } + + return ok; +} + +// NOLINTNEXTLINE(readability-identifier-naming) +bool ccvaluevector_to_seval(const cc::ValueVector &v, se::Value *ret) { + assert(ret != nullptr); + se::HandleObject obj(se::Object::createArrayObject(v.size())); + bool ok = true; + + uint32_t i = 0; + for (const auto &value : v) { + se::Value tmp; + if (!ccvalue_to_seval(value, &tmp)) { + ok = false; + ret->setUndefined(); + break; + } + + obj->setArrayElement(i, tmp); + ++i; + } + if (ok) { + ret->setObject(obj); + } + + return ok; +} + +// NOLINTNEXTLINE(readability-identifier-naming) +bool ManifestAsset_to_seval(const cc::extension::ManifestAsset &v, se::Value *ret) { + assert(ret != nullptr); + se::HandleObject obj(se::Object::createPlainObject()); + obj->setProperty("md5", se::Value(v.md5)); + obj->setProperty("path", se::Value(v.path)); + obj->setProperty("compressed", se::Value(v.compressed)); + obj->setProperty("size", se::Value(v.size)); + obj->setProperty("downloadState", se::Value(v.downloadState)); + ret->setObject(obj); + + return true; +} + +// NOLINTNEXTLINE(readability-identifier-naming) +bool Data_to_seval(const cc::Data &v, se::Value *ret) { + assert(ret != nullptr); + if (v.isNull()) { + ret->setNull(); + } else { + se::HandleObject obj(se::Object::createTypedArray(se::Object::TypedArrayType::UINT8, v.getBytes(), v.getSize())); + ret->setObject(obj, true); + } + return true; +} + +// NOLINTNEXTLINE(readability-identifier-naming) +bool DownloadTask_to_seval(const cc::network::DownloadTask &v, se::Value *ret) { + assert(ret != nullptr); + + se::HandleObject obj(se::Object::createPlainObject()); + obj->setProperty("identifier", se::Value(v.identifier)); + obj->setProperty("requestURL", se::Value(v.requestURL)); + obj->setProperty("storagePath", se::Value(v.storagePath)); + ret->setObject(obj); + + return true; +} + +// NOLINTNEXTLINE(readability-identifier-naming) +bool nativevalue_to_se(const spine::String &obj, se::Value &val, se::Object * /*unused*/) { + val.setString(obj.buffer()); + return true; +} + +// NOLINTNEXTLINE(readability-identifier-naming) +bool nativevalue_to_se(const spine::Vector &v, se::Value &ret, se::Object * /*unused*/) { + se::HandleObject obj(se::Object::createArrayObject(v.size())); + bool ok = true; + + spine::Vector tmpv = v; + for (uint32_t i = 0, count = static_cast(tmpv.size()); i < count; i++) { + if (!obj->setArrayElement(i, se::Value(tmpv[i].buffer()))) { + ok = false; + ret.setUndefined(); + break; + } + } + + if (ok) { + ret.setObject(obj); + } + + return ok; +} +#endif + +////////////////// custom types + +// NOLINTNEXTLINE(readability-identifier-naming) +bool nativevalue_to_se(const cc::Data &from, se::Value &to, se::Object * /*unused*/) { + se::Object *buffer = se::Object::createArrayBufferObject(from.getBytes(), from.getSize()); + to.setObject(buffer); + return true; +} + +// NOLINTNEXTLINE(readability-identifier-naming) +bool nativevalue_to_se(const cc::Value &from, se::Value &to, se::Object * /*unused*/) { + return ccvalue_to_seval(from, &to); +} + +// NOLINTNEXTLINE(readability-identifier-naming) +bool nativevalue_to_se(const std::unordered_map &from, se::Value &to, se::Object * /*unused*/) { + return ccvaluemap_to_seval(from, &to); +} + +// NOLINTNEXTLINE(readability-identifier-naming) +bool nativevalue_to_se(const cc::Vec4 &from, se::Value &to, se::Object * /*unused*/) { + return Vec4_to_seval(from, &to); +} + +bool nativevalue_to_se(const cc::Vec2 &from, se::Value &to, se::Object * /*unused*/) { + return Vec2_to_seval(from, &to); +} + +// NOLINTNEXTLINE(readability-identifier-naming) +bool nativevalue_to_se(const cc::Vec3 &from, se::Value &to, se::Object * /*unused*/) { + return Vec3_to_seval(from, &to); +} + +// NOLINTNEXTLINE(readability-identifier-naming) +bool nativevalue_to_se(const cc::Size &from, se::Value &to, se::Object * /*unused*/) { + return Size_to_seval(from, &to); +} + +// NOLINTNEXTLINE(readability-identifier-naming) +bool nativevalue_to_se(const cc::extension::ManifestAsset &from, se::Value &to, se::Object * /*unused*/) { + return ManifestAsset_to_seval(from, &to); +} + +// NOLINTNEXTLINE(readability-identifier-naming) +bool nativevalue_to_se(const cc::Quaternion &from, se::Value &to, se::Object * /*ctx*/) { + return Quaternion_to_seval(from, &to); +} + +// NOLINTNEXTLINE(readability-identifier-naming) +bool nativevalue_to_se(const cc::Rect &from, se::Value &to, se::Object * /*unused*/) { + return Rect_to_seval(from, &to); +} + +// NOLINTNEXTLINE(readability-identifier-naming) +bool nativevalue_to_se(const cc::ArrayBuffer &arrayBuffer, se::Value &to, se::Object * /*ctx*/) { + to.setObject(arrayBuffer.getJSArrayBuffer()); + return true; +} + +//// NOLINTNEXTLINE(readability-identifier-naming) +// bool nativevalue_to_se(const cc::TypedArray &from, se::Value &to, se::Object * /*ctx*/) { +// std::visit([&](auto &typedArray) { +// to.setObject(typedArray.getJSTypedArray()); +// }, +// from); +// return true; +// } + +// NOLINTNEXTLINE(readability-identifier-naming) +bool nativevalue_to_se(const cc::NativeDep &from, se::Value &to, se::Object * /*ctx*/) { + se::HandleObject obj(se::Object::createPlainObject()); + obj->setProperty("uuid", se::Value(from.uuid)); + obj->setProperty("ext", se::Value(from.ext)); + obj->setProperty("__isNative__", se::Value(from.__isNative__)); + to.setObject(obj); + return true; +} + +// NOLINTNEXTLINE(readability-identifier-naming) +bool nativevalue_to_se(const cc::Mat3 &from, se::Value &to, se::Object * /*ctx*/) { + se::HandleObject obj(se::Object::createPlainObject()); + char keybuf[8] = {0}; + for (auto i = 0; i < 9; i++) { + snprintf(keybuf, sizeof(keybuf), "m%02d", i); + obj->setProperty(keybuf, se::Value(from.m[i])); + } + to.setObject(obj); + return true; +} + +// NOLINTNEXTLINE(readability-identifier-naming) +bool nativevalue_to_se(const cc::Mat4 &from, se::Value &to, se::Object * /*ctx*/) { + se::HandleObject obj(se::Object::createPlainObject()); + char keybuf[8] = {0}; + for (auto i = 0; i < 16; i++) { + snprintf(keybuf, sizeof(keybuf), "m%02d", i); + obj->setProperty(keybuf, se::Value(from.m[i])); + } + to.setObject(obj); + return true; +} + +#if USE_PHYSICS_PHYSX + +bool nativevalue_to_se(const std::vector> &from, se::Value &to, se::Object * /*ctx*/) { + se::HandleObject array(se::Object::createArrayObject(from.size() * cc::physics::TriggerEventPair::COUNT)); + for (size_t i = 0; i < from.size(); i++) { + auto t = i * cc::physics::TriggerEventPair::COUNT; + array->setArrayElement(static_cast(t + 0), se::Value(static_cast(from[i]->shapeA))); + array->setArrayElement(static_cast(t + 1), se::Value(static_cast(from[i]->shapeB))); + array->setArrayElement(static_cast(t + 2), se::Value(static_cast(from[i]->state))); + } + to.setObject(array); + return true; +} + +bool nativevalue_to_se(const std::vector &from, se::Value &to, se::Object * /*ctx*/) { + const auto contactCount = from.size(); + se::HandleObject array(se::Object::createArrayObject(contactCount)); + for (size_t i = 0; i < contactCount; i++) { + auto t = i * cc::physics::ContactPoint::COUNT; + uint32_t j = 0; + array->setArrayElement(static_cast(t + j++), se::Value(from[i].position.x)); + array->setArrayElement(static_cast(t + j++), se::Value(from[i].position.y)); + array->setArrayElement(static_cast(t + j++), se::Value(from[i].position.z)); + array->setArrayElement(static_cast(t + j++), se::Value(from[i].normal.x)); + array->setArrayElement(static_cast(t + j++), se::Value(from[i].normal.y)); + array->setArrayElement(static_cast(t + j++), se::Value(from[i].normal.z)); + array->setArrayElement(static_cast(t + j++), se::Value(from[i].impulse.x)); + array->setArrayElement(static_cast(t + j++), se::Value(from[i].impulse.y)); + array->setArrayElement(static_cast(t + j++), se::Value(from[i].impulse.z)); + array->setArrayElement(static_cast(t + j++), se::Value(from[i].separation)); + array->setArrayElement(static_cast(t + j++), se::Value(from[i].internalFaceIndex0)); + array->setArrayElement(static_cast(t + j++), se::Value(from[i].internalFaceIndex1)); + } + to.setObject(array); + return true; +} + +bool nativevalue_to_se(const std::vector> &from, se::Value &to, se::Object *ctx) { + se::HandleObject array(se::Object::createArrayObject(from.size() * cc::physics::ContactEventPair::COUNT)); + for (size_t i = 0; i < from.size(); i++) { + auto t = i * cc::physics::ContactEventPair::COUNT; + array->setArrayElement(static_cast(t + 0), se::Value(static_cast(from[i]->shapeA))); + array->setArrayElement(static_cast(t + 1), se::Value(static_cast(from[i]->shapeB))); + array->setArrayElement(static_cast(t + 2), se::Value(static_cast(from[i]->state))); + array->setArrayElement(static_cast(t + 3), [&]() -> se::Value { + auto obj = se::Value(); + nativevalue_to_se(from[i]->contacts, obj, ctx); + return obj; + }()); + } + to.setObject(array); + return true; +} + +bool nativevalue_to_se(const cc::physics::RaycastResult &from, se::Value &to, se::Object *ctx) { + se::HandleObject obj(se::Object::createPlainObject()); + obj->setProperty("shape", se::Value(static_cast(from.shape))); + obj->setProperty("distance", se::Value(from.distance)); + se::Value tmp; + if (nativevalue_to_se(from.hitPoint, tmp, ctx)) obj->setProperty("hitPoint", tmp); + if (nativevalue_to_se(from.hitNormal, tmp, ctx)) obj->setProperty("hitNormal", tmp); + to.setObject(obj); + return true; +} + +bool sevalue_to_native(const se::Value &from, cc::physics::ConvexDesc *to, se::Object *ctx) { + assert(from.isObject()); + se::Object *json = from.toObject(); + auto * data = static_cast(json->getPrivateData()); + if (data) { + *to = *data; + return true; + } + + se::Value field; + bool ok = true; + + json->getProperty("positionLength", &field); + if (!field.isNullOrUndefined()) ok &= sevalue_to_native(field, &to->positionLength, ctx); + + CC_UNUSED size_t dataLength = 0; + json->getProperty("positions", &field); + if (!field.isNullOrUndefined()) { + se::Object *obj = field.toObject(); + if (obj->isArrayBuffer()) { + ok &= obj->getArrayBufferData(reinterpret_cast(&to->positions), &dataLength); + SE_PRECONDITION2(ok, false, "getArrayBufferData failed!"); + } else if (obj->isTypedArray()) { + ok &= obj->getTypedArrayData(reinterpret_cast(&to->positions), &dataLength); + SE_PRECONDITION2(ok, false, "getTypedArrayData failed!"); + } else { + ok &= false; + } + } + return ok; +} + +bool sevalue_to_native(const se::Value &from, cc::physics::TrimeshDesc *to, se::Object *ctx) { + if (!sevalue_to_native(from, reinterpret_cast(to), ctx)) { + return false; + } + + assert(from.isObject()); + se::Object *json = from.toObject(); + auto * data = static_cast(json->getPrivateData()); + if (data) { + *to = *data; + return true; + } + se::Value field; + bool ok = true; + + json->getProperty("triangleLength", &field); + if (!field.isNullOrUndefined()) ok &= sevalue_to_native(field, &(to->triangleLength), ctx); + + json->getProperty("isU16", &field); + if (!field.isNullOrUndefined()) ok &= sevalue_to_native(field, &(to->isU16), ctx); + + CC_UNUSED size_t dataLength = 0; + json->getProperty("triangles", &field); + if (!field.isNullOrUndefined()) { + se::Object *obj = field.toObject(); + if (obj->isArrayBuffer()) { + ok &= obj->getArrayBufferData(reinterpret_cast(&to->triangles), &dataLength); + SE_PRECONDITION2(ok, false, "getArrayBufferData failed!"); + } else if (obj->isTypedArray()) { + ok &= obj->getTypedArrayData(reinterpret_cast(&to->triangles), &dataLength); + SE_PRECONDITION2(ok, false, "getTypedArrayData failed!"); + } else { + ok &= false; + } + } + + return ok; +} + +bool sevalue_to_native(const se::Value &from, cc::physics::HeightFieldDesc *to, se::Object *ctx) { + assert(from.isObject()); + se::Object *json = from.toObject(); + auto * data = static_cast(json->getPrivateData()); + if (data) { + *to = *data; + return true; + } + + se::Value field; + bool ok = true; + + json->getProperty("rows", &field); + if (!field.isNullOrUndefined()) ok &= sevalue_to_native(field, &to->rows, ctx); + + json->getProperty("columns", &field); + if (!field.isNullOrUndefined()) ok &= sevalue_to_native(field, &to->columns, ctx); + + CC_UNUSED size_t dataLength = 0; + json->getProperty("samples", &field); + if (!field.isNullOrUndefined()) { + se::Object *obj = field.toObject(); + if (obj->isArrayBuffer()) { + ok &= obj->getArrayBufferData(reinterpret_cast(&to->samples), &dataLength); + SE_PRECONDITION2(ok, false, "getArrayBufferData failed!"); + } else if (obj->isTypedArray()) { + ok &= obj->getTypedArrayData(reinterpret_cast(&to->samples), &dataLength); + SE_PRECONDITION2(ok, false, "getTypedArrayData failed!"); + } else { + ok &= false; + } + } + return ok; +} + +bool sevalue_to_native(const se::Value &from, cc::physics::RaycastOptions *to, se::Object *ctx) { + assert(from.isObject()); + se::Object *json = from.toObject(); + auto * data = static_cast(json->getPrivateData()); + if (data) { + *to = *data; + return true; + } + + se::Value field; + bool ok = true; + + json->getProperty("origin", &field); + if (!field.isNullOrUndefined()) ok &= sevalue_to_native(field, &to->origin, ctx); + + json->getProperty("unitDir", &field); + if (!field.isNullOrUndefined()) ok &= sevalue_to_native(field, &to->unitDir, ctx); + + json->getProperty("mask", &field); + if (!field.isNullOrUndefined()) ok &= sevalue_to_native(field, &to->mask, ctx); + + json->getProperty("distance", &field); + if (!field.isNullOrUndefined()) ok &= sevalue_to_native(field, &to->distance, ctx); + + json->getProperty("queryTrigger", &field); + if (!field.isNullOrUndefined()) ok &= sevalue_to_native(field, &to->queryTrigger, ctx); + + return ok; +} + +bool nativevalue_to_se(const cc::geometry::AABB &from, se::Value &to, se::Object *ctx) { + se::HandleObject obj(se::Object::createPlainObject()); + se::Value tmp; + if (nativevalue_to_se(from.getCenter(), tmp, ctx)) obj->setProperty("center", tmp); + if (nativevalue_to_se(from.getHalfExtents(), tmp, ctx)) obj->setProperty("halfExtents", tmp); + to.setObject(obj); + return true; +} + +bool nativevalue_to_se(const cc::geometry::Sphere &from, se::Value &to, se::Object *ctx) { + se::HandleObject obj(se::Object::createPlainObject()); + se::Value tmp(from.getRadius()); + obj->setProperty("radius", tmp); + if (nativevalue_to_se(from.getCenter(), tmp, ctx)) obj->setProperty("center", tmp); + to.setObject(obj); + return true; +} + +#endif //USE_PHYSICS_PHYSX diff --git a/native/cocos/bindings/manual/jsb_conversions_spec.h b/native/cocos/bindings/manual/jsb_conversions_spec.h new file mode 100644 index 0000000000..7f086309b6 --- /dev/null +++ b/native/cocos/bindings/manual/jsb_conversions_spec.h @@ -0,0 +1,537 @@ +/**************************************************************************** + 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 +#include +#include "base/Ptr.h" +#include "base/Value.h" +#include "bindings/jswrapper/SeApi.h" +#include "cocos/base/Any.h" +#include "cocos/base/Optional.h" +#include "cocos/base/Variant.h" +#include "cocos/core/assets/AssetsModuleHeader.h" +#include "core/TypedArray.h" +#include "core/assets/RenderingSubMesh.h" + +#if USE_PHYSICS_PHYSX + #include "physics/spec/IShape.h" + #include "physics/spec/IWorld.h" +#endif + +namespace cc { +class Data; +class Vec4; +class Vec2; +class Vec3; +class Size; +class Mat3; +class Mat4; +class Quaternion; +class Color; +class Rect; + +template +class Map; + +struct NativeDep; + +class ArrayBuffer; + +// class TypedArray; +// class IBArray; + +namespace network { +struct DownloaderHints; +class DownloadTask; +} // namespace network + +namespace scene { +class FogInfo; +class ShadowsInfo; +class SkyboxInfo; +} // namespace scene + +namespace geometry { +class AABB; +class Capsule; +class Line; +class Ray; +class Sphere; +class Triangle; +class Plane; +class Frustum; +} // namespace geometry + +namespace extension { +struct ManifestAsset; +} + +namespace middleware { +class Texture2D; +} + +namespace gfx { +struct Viewport; +struct Offset; +struct Extent; +struct TextureSubres; +struct TextureCopy; +struct BufferTextureCopy; +struct BufferInfo; +struct BufferViewInfo; +struct TextureInfo; +struct DescriptorSetInfo; +struct BindingMappingInfo; +struct ShaderStage; +struct UniformSampler; +struct UniformBlock; +struct Uniform; +struct ShaderInfo; +struct DrawInfo; +struct IndirectBuffer; +struct SamplerInfo; +struct ColorAttachment; +struct DepthStencilAttachment; +struct SubPassInfo; +struct RenderPassInfo; +struct QueueInfo; +struct PipelineLayoutInfo; +struct DescriptorSetLayoutBinding; +struct DescriptorSetLayoutInfo; +struct FramebufferInfo; +struct CommandBufferInfo; +struct InputAssemblerInfo; +} // namespace gfx +} // namespace cc + +#if USE_SPINE + +namespace spine { +class String; +template +class Vector; +template +class Map; +} // namespace spine + +#endif + +//////////////////////////////////////////////////////////////////////////// +/////////////////sevalue to native///////////////////////////// +//////////////////////////////////////////////////////////////////////////// + +// se value -> native value +bool seval_to_ccvalue(const se::Value &v, cc::Value *ret); // NOLINT(readability-identifier-naming) +bool seval_to_ccvaluemap(const se::Value &v, cc::ValueMap *ret); // NOLINT(readability-identifier-naming) +bool seval_to_ccvaluemapintkey(const se::Value &v, cc::ValueMapIntKey *ret); // NOLINT(readability-identifier-naming) +bool seval_to_ccvaluevector(const se::Value &v, cc::ValueVector *ret); // NOLINT(readability-identifier-naming) +bool sevals_variadic_to_ccvaluevector(const se::ValueArray &args, cc::ValueVector *ret); // NOLINT(readability-identifier-naming) + +bool seval_to_Data(const se::Value &v, cc::Data *ret); // NOLINT(readability-identifier-naming) +bool seval_to_DownloaderHints(const se::Value &v, cc::network::DownloaderHints *ret); // NOLINT(readability-identifier-naming) + +bool sevalue_to_native(const se::Value &from, cc::MacroValue *to, se::Object *ctx); // NOLINT(readability-identifier-naming) +bool sevalue_to_native(const se::Value &from, cc::IPreCompileInfoValueType *to, se::Object * /*ctx*/); // NOLINT(readability-identifier-naming) + +// cc::any +bool sevalue_to_native(const se::Value &from, cc::any *to, se::Object *ctx); //NOLINT(readability-identifier-naming) +////////////////// ArrayBuffer +bool sevalue_to_native(const se::Value &from, cc::ArrayBuffer *to, se::Object * /*ctx*/); // NOLINT(readability-identifier-naming) +bool sevalue_to_native(const se::Value &from, cc::ArrayBuffer **to, se::Object * /*ctx*/); // NOLINT(readability-identifier-naming) + +bool sevalue_to_native(const se::Value &from, std::vector *to, se::Object * /*ctx*/); // NOLINT(readability-identifier-naming) + +bool sevalue_to_native(const se::Value &from, cc::MaterialProperty *to, se::Object * /*ctx*/); // NOLINT(readability-identifier-naming) + +inline bool sevalue_to_native(const se::Value &from, std::string *to, se::Object * /*ctx*/) { // NOLINT(readability-identifier-naming) + if (!from.isNullOrUndefined()) { + *to = from.toString(); + } else { + to->clear(); + } + return true; +} + +///// integers +inline bool sevalue_to_native(const se::Value &from, bool *to, se::Object * /*ctx*/) { // NOLINT(readability-identifier-naming) + *to = from.isNullOrUndefined() ? false : (from.isNumber() ? from.toDouble() != 0 : from.toBoolean()); + return true; +} + +inline bool sevalue_to_native(const se::Value &from, int32_t *to, se::Object * /*ctx*/) { // NOLINT(readability-identifier-naming) + *to = from.toInt32(); + return true; +} +inline bool sevalue_to_native(const se::Value &from, uint32_t *to, se::Object * /*ctx*/) { // NOLINT(readability-identifier-naming) + *to = from.toUint32(); + return true; +} + +inline bool sevalue_to_native(const se::Value &from, int16_t *to, se::Object * /*ctx*/) { // NOLINT(readability-identifier-naming) + *to = from.toInt16(); + return true; +} +inline bool sevalue_to_native(const se::Value &from, uint16_t *to, se::Object * /*ctx*/) { // NOLINT(readability-identifier-naming) + *to = from.toUint16(); + return true; +} + +inline bool sevalue_to_native(const se::Value &from, int8_t *to, se::Object * /*ctx*/) { // NOLINT(readability-identifier-naming) + *to = from.toInt8(); + return true; +} +inline bool sevalue_to_native(const se::Value &from, uint8_t *to, se::Object * /*ctx*/) { // NOLINT(readability-identifier-naming) + *to = from.toUint8(); + return true; +} + +inline bool sevalue_to_native(const se::Value &from, uint64_t *to, se::Object * /*ctx*/) { // NOLINT(readability-identifier-naming) + *to = from.toUint64(); + return true; +} + +inline bool sevalue_to_native(const se::Value &from, int64_t *to, se::Object * /*ctx*/) { // NOLINT(readability-identifier-naming) + *to = from.toInt64(); + return true; +} + +#if CC_PLATFORM == CC_PLATFORM_MAC_IOS || CC_PLATFORM == CC_PLATFORM_MAC_OSX +inline bool sevalue_to_native(const se::Value &from, unsigned long *to, se::Object * /*ctx*/) { // NOLINT(readability-identifier-naming) + // on mac: unsiged long === uintptr_t + static_assert(sizeof(*to) == 8, ""); + *to = static_cast(from.toUint64()); + return true; +} +#endif + +inline bool sevalue_to_native(const se::Value &from, float *to, se::Object * /*ctx*/) { // NOLINT(readability-identifier-naming) + *to = from.toFloat(); + return true; +} +inline bool sevalue_to_native(const se::Value &from, double *to, se::Object * /*unused*/) { // NOLINT(readability-identifier-naming) + *to = from.toDouble(); + return true; +} + +//inline bool sevalue_to_native(const se::Value & /*from*/, void * /*to*/, se::Object * /*ctx*/) { // NOLINT(readability-identifier-naming) +// assert(false); // void not supported +// return false; +//} + +inline bool sevalue_to_native(const se::Value &from, cc::Data *to, se::Object * /*ctx*/) { // NOLINT(readability-identifier-naming) + return seval_to_Data(from, to); +} + +inline bool sevalue_to_native(const se::Value &from, cc::Value *to, se::Object * /*unused*/) { // NOLINT(readability-identifier-naming) + return seval_to_ccvalue(from, to); +} + +inline bool sevalue_to_native(const se::Value &from, se::Value *to, se::Object * /*unused*/) { // NOLINT(readability-identifier-naming) + *to = from; + return true; +} + +bool sevalue_to_native(const se::Value &from, cc::Vec4 *to, se::Object * /*unused*/); // NOLINT(readability-identifier-naming) + +bool sevalue_to_native(const se::Value &from, cc::Mat3 *to, se::Object * /*unused*/); // NOLINT(readability-identifier-naming) + +bool sevalue_to_native(const se::Value &from, cc::Mat4 *to, se::Object * /*unused*/); // NOLINT(readability-identifier-naming) + +bool sevalue_to_native(const se::Value &from, cc::Vec3 *to, se::Object * /*unused*/); // NOLINT(readability-identifier-naming) + +bool sevalue_to_native(const se::Value &from, cc::Vec2 *to, se::Object * /*unused*/); // NOLINT(readability-identifier-naming) + +bool sevalue_to_native(const se::Value &from, cc::Size *to, se::Object * /*unused*/); // NOLINT(readability-identifier-naming) + +bool sevalue_to_native(const se::Value &from, cc::Quaternion *to, se::Object * /*unused*/); // NOLINT(readability-identifier-naming) + +bool sevalue_to_native(const se::Value &from, cc::Color *to, se::Object * /*unused*/); // NOLINT(readability-identifier-naming) + +inline bool sevalue_to_native(const se::Value &from, std::vector *to, se::Object * /*unused*/) { // NOLINT(readability-identifier-naming) + if (from.isNullOrUndefined()) { + to->clear(); + return true; + } + assert(from.isObject() && from.toObject()->isArray()); + auto *array = from.toObject(); + to->clear(); + uint32_t size; + array->getArrayLength(&size); + for (uint32_t i = 0; i < size; i++) { + se::Value ele; + array->getArrayElement(i, &ele); + to->emplace_back(ele); + } + return true; +} + +////////////////// cc::any +inline bool sevalue_to_native(const se::Value & /*from*/, cc::any * /*to*/, se::Object * /*ctx*/) { // NOLINT(readability-identifier-naming) + assert(false); + //TODO(PatriceJiang): convert any to specific types + return false; +} + +bool sevalue_to_native(const se::Value &from, cc::TypedArray *to, se::Object * /*ctx*/); // NOLINT(readability-identifier-naming) + +bool sevalue_to_native(const se::Value &from, cc::IBArray *to, se::Object * /*ctx*/); // NOLINT(readability-identifier-naming) + +//bool sevalue_to_native(const se::Value &from, cc::gfx::Context **to, se::Object*) {// NOLINT(readability-identifier-naming) +// assert(from.isObject()); +// *to = (cc::gfx::Context*)from.toObject()->getPrivateData(); +// return true; +//} + +inline bool sevalue_to_native(const se::Value &from, void **to, se::Object * /*ctx*/) { // NOLINT(readability-identifier-naming) + assert(to != nullptr); + if (from.isNumber() || from.isBigInt()) { + // NOLINTNEXTLINE(performance-no-int-to-ptr) + *to = reinterpret_cast(from.toUint64()); + return true; + } + if (from.isObject()) { + *to = from.toObject()->getPrivateData(); + return true; + } + SE_LOGE("[warn] failed to convert to void *\n"); + return false; +} + +inline bool sevalue_to_native(const se::Value &from, std::string **to, se::Object * /*ctx*/) { // NOLINT(readability-identifier-naming) + **to = from.toString(); + return true; +} + +inline bool sevalue_to_native(const se::Value &from, cc::ValueMap *to, se::Object * /*ctx*/) { // NOLINT(readability-identifier-naming) + return seval_to_ccvaluemap(from, to); +} + +bool sevalue_to_native(const se::Value &from, std::vector *to, se::Object * /*ctx*/); // NOLINT(readability-identifier-naming) + +bool sevalue_to_native(const se::Value &from, std::vector *to, se::Object * /*ctx*/); // NOLINT(readability-identifier-naming) +bool sevalue_to_native(const se::Value &from, cc::variant, std::string> *to, se::Object *ctx); // NOLINT(readability-identifier-naming) +inline bool sevalue_to_native(const se::Value & /*from*/, cc::monostate * /*to*/, se::Object * /*ctx*/) { // NOLINT(readability-identifier-naming) + // nothing todo + return false; +} +bool sevalue_to_native(const se::Value &from, cc::variant *to, se::Object *ctx); // NOLINT(readability-identifier-naming) + +//////////////////////// scene info +bool sevalue_to_native(const se::Value &from, cc::scene::FogInfo *, se::Object * /*ctx*/); // NOLINT(readability-identifier-naming) +bool sevalue_to_native(const se::Value &from, cc::scene::ShadowsInfo *, se::Object * /*ctx*/); // NOLINT(readability-identifier-naming) +bool sevalue_to_native(const se::Value &from, cc::scene::SkyboxInfo *, se::Object * /*ctx*/); // NOLINT(readability-identifier-naming) + +/////////////////////// geometry + +bool sevalue_to_native(const se::Value &from, cc::geometry::AABB *, se::Object * /*ctx*/); // NOLINT(readability-identifier-naming) +bool sevalue_to_native(const se::Value &from, cc::geometry::Capsule *, se::Object * /*ctx*/); // NOLINT(readability-identifier-naming) +bool sevalue_to_native(const se::Value &from, cc::geometry::Line *, se::Object * /*ctx*/); // NOLINT(readability-identifier-naming) +bool sevalue_to_native(const se::Value &from, cc::geometry::Ray *, se::Object * /*ctx*/); // NOLINT(readability-identifier-naming) +bool sevalue_to_native(const se::Value &from, cc::geometry::Sphere *, se::Object * /*ctx*/); // NOLINT(readability-identifier-naming) +bool sevalue_to_native(const se::Value &from, cc::geometry::Triangle *, se::Object * /*ctx*/); // NOLINT(readability-identifier-naming) +bool sevalue_to_native(const se::Value &from, cc::geometry::Plane *to, se::Object * /*unused*/); // NOLINT(readability-identifier-naming) +bool sevalue_to_native(const se::Value &from, cc::geometry::Plane **to, se::Object * /*unused*/); // NOLINT(readability-identifier-naming) +bool sevalue_to_native(const se::Value &from, cc::geometry::Frustum *to, se::Object * /*unused*/); // NOLINT(readability-identifier-naming) + +//////////////////////////////////////////////////////////////////////////// +////////////////////nativevalue to se ///////////////////////////////////// +//////////////////////////////////////////////////////////////////////////// + +// native value -> se value +bool ccvalue_to_seval(const cc::Value &v, se::Value *ret); // NOLINT(readability-identifier-naming) +bool ccvaluemap_to_seval(const cc::ValueMap &v, se::Value *ret); // NOLINT(readability-identifier-naming) +bool ccvaluemapintkey_to_seval(const cc::ValueMapIntKey &v, se::Value *ret); // NOLINT(readability-identifier-naming) +bool ccvaluevector_to_seval(const cc::ValueVector &v, se::Value *ret); // NOLINT(readability-identifier-naming) + +bool ManifestAsset_to_seval(const cc::extension::ManifestAsset &v, se::Value *ret); // NOLINT(readability-identifier-naming) +bool Data_to_seval(const cc::Data &v, se::Value *ret); // NOLINT(readability-identifier-naming) +bool DownloadTask_to_seval(const cc::network::DownloadTask &v, se::Value *ret); // NOLINT(readability-identifier-naming) + +//bool nativevalue_to_se(const cc::TypedArray &typedArray, se::Value &to, se::Object * /*ctx*/); // NOLINT(readability-identifier-naming) // NOLINT + +bool nativevalue_to_se(const cc::ArrayBuffer &arrayBuffer, se::Value &to, se::Object * /*ctx*/); // NOLINT(readability-identifier-naming) // NOLINT + +inline bool nativevalue_to_se(const std::vector &from, se::Value &to, se::Object * /*ctx*/) { // NOLINT(readability-identifier-naming) + se::Object *array = se::Object::createTypedArray(se::Object::TypedArrayType::INT8, from.data(), from.size()); + to.setObject(array); + array->decRef(); + return true; +} + +inline bool nativevalue_to_se(const std::vector &from, se::Value &to, se::Object * /*ctx*/) { // NOLINT(readability-identifier-naming) + se::Object *array = se::Object::createTypedArray(se::Object::TypedArrayType::UINT8, from.data(), from.size()); + to.setObject(array); + array->decRef(); + return true; +} + +inline bool nativevalue_to_se(int64_t from, se::Value &to, se::Object * /*ctx*/) { // NOLINT(readability-identifier-naming) + to.setInt64(from); + return true; +} + +inline bool nativevalue_to_se(uint64_t from, se::Value &to, se::Object * /*ctx*/) { // NOLINT(readability-identifier-naming) + to.setUint64(from); + return true; +} + +inline bool nativevalue_to_se(int32_t from, se::Value &to, se::Object * /*ctx*/) { // NOLINT(readability-identifier-naming) + to.setInt32(from); + return true; +} + +inline bool nativevalue_to_se(uint32_t from, se::Value &to, se::Object * /*ctx*/) { // NOLINT(readability-identifier-naming) + to.setUint32(from); + return true; +} +inline bool nativevalue_to_se(int16_t from, se::Value &to, se::Object * /*ctx*/) { // NOLINT(readability-identifier-naming) + to.setInt16(from); + return true; +} +inline bool nativevalue_to_se(uint16_t from, se::Value &to, se::Object * /*ctx*/) { // NOLINT(readability-identifier-naming) + to.setUint16(from); + return true; +} + +inline bool nativevalue_to_se(int8_t from, se::Value &to, se::Object * /*ctx*/) { // NOLINT(readability-identifier-naming) + to.setInt8(from); + return true; +} + +inline bool nativevalue_to_se(uint8_t from, se::Value &to, se::Object * /*ctx*/) { // NOLINT(readability-identifier-naming) + to.setUint8(from); + return true; +} + +inline bool nativevalue_to_se(float from, se::Value &to, se::Object * /*ctx*/) { // NOLINT(readability-identifier-naming) + to.setFloat(from); + return true; +} +inline bool nativevalue_to_se(double from, se::Value &to, se::Object * /*ctx*/) { // NOLINT(readability-identifier-naming) + to.setDouble(from); + return true; +} +inline bool nativevalue_to_se(bool from, se::Value &to, se::Object * /*ctx*/) { // NOLINT(readability-identifier-naming) + to.setBoolean(from); + return true; +} + +inline bool nativevalue_to_se(const std::string &from, se::Value &to, se::Object * /*ctx*/) { // NOLINT(readability-identifier-naming) + to.setString(from); + return true; +} +// template <> +// bool nativevalue_to_se(const cc::Color &from, se::Value &to, se::Object *ctx); // NOLINT(readability-identifier-naming) + +bool nativevalue_to_se(const cc::NativeDep &from, se::Value &to, se::Object *ctx); // NOLINT(readability-identifier-naming) + +bool nativevalue_to_se(const cc::Mat3 &from, se::Value &to, se::Object *ctx); // NOLINT(readability-identifier-naming) + +bool nativevalue_to_se(const cc::Mat4 &from, se::Value &to, se::Object *ctx); // NOLINT(readability-identifier-naming) + +// JSB_REGISTER_OBJECT_TYPE(cc::network::DownloaderHints); + +bool nativevalue_to_se(const cc::Data &from, se::Value &to, se::Object *ctx); // NOLINT(readability-identifier-naming) + +bool nativevalue_to_se(const cc::Value &from, se::Value &to, se::Object *ctx); // NOLINT(readability-identifier-naming) + +bool nativevalue_to_se(const std::unordered_map &from, se::Value &to, se::Object *ctx); // NOLINT(readability-identifier-naming) + +bool nativevalue_to_se(const cc::Vec2 &from, se::Value &to, se::Object *ctx); // NOLINT(readability-identifier-naming) + +bool nativevalue_to_se(const cc::Vec3 &from, se::Value &to, se::Object *ctx); // NOLINT(readability-identifier-naming) + +bool nativevalue_to_se(const cc::Vec4 &from, se::Value &to, se::Object *ctx); // NOLINT(readability-identifier-naming) + +bool nativevalue_to_se(const cc::Size &from, se::Value &to, se::Object *ctx); // NOLINT(readability-identifier-naming) + +bool nativevalue_to_se(const cc::Quaternion &from, se::Value &to, se::Object *ctx); // NOLINT(readability-identifier-naming) + +bool nativevalue_to_se(const cc::extension::ManifestAsset &from, se::Value &to, se::Object *ctx); // NOLINT(readability-identifier-naming) + +bool nativevalue_to_se(const cc::Rect &from, se::Value &to, se::Object *ctx); // NOLINT(readability-identifier-naming) + +inline bool nativevalue_to_se(const cc::network::DownloadTask &from, se::Value &to, se::Object * /*ctx*/) { // NOLINT(readability-identifier-naming) + return DownloadTask_to_seval(from, &to); +} + +inline bool nativevalue_to_se(const cc::monostate & /*from*/, se::Value &to, se::Object * /*ctx*/) { // NOLINT(readability-identifier-naming) + to.setUndefined(); + return true; +} + +inline bool nativevalue_to_se(const cc::any &from, se::Value &to, se::Object *ctx) { //NOLINT + assert(false); + //TODO(PatriceJiang): // should not convert cc::any + return true; +} + +using void_p = void *; +inline bool nativevalue_to_se(const void_p &from, se::Value &to, se::Object * /*ctx*/) { // NOLINT(readability-identifier-naming) + if (!from) { + to.setUndefined(); + } else { + auto ptr = reinterpret_cast(from); + sizeof(from) == 8 ? to.setUint64(static_cast(ptr)) : to.setUint32(static_cast(ptr)); + } + return true; +} + +// Spine conversions +#if USE_SPINE + +bool sevalue_to_native(const se::Value &, spine::String *, se::Object *); // NOLINT(readability-identifier-naming) + +bool nativevalue_to_se(const spine::Vector &v, se::Value &ret, se::Object *ctx); // NOLINT(readability-identifier-naming) + +bool nativevalue_to_se(const spine::String &obj, se::Value &val, se::Object *ctx); // NOLINT(readability-identifier-naming) + +bool sevalue_to_native(const se::Value &v, spine::Vector *ret, se::Object *ctx); // NOLINT(readability-identifier-naming) + +bool seval_to_Map_string_key(const se::Value &v, cc::Map *ret); // NOLINT(readability-identifier-naming) + +#endif + +#if USE_MIDDLEWARE +inline bool nativevalue_to_se(const se_object_ptr &from, se::Value &to, se::Object * /*ctx*/) { // NOLINT(readability-identifier-naming) + to.setObject(const_cast(from)); + return true; +} +#endif //USE_MIDDLEWARE + +#if USE_PHYSICS_PHYSX + +bool nativevalue_to_se(const std::vector> &from, se::Value &to, se::Object * /*ctx*/); +bool nativevalue_to_se(const std::vector &from, se::Value &to, se::Object * /*ctx*/); +bool nativevalue_to_se(const std::vector> &from, se::Value &to, se::Object *ctx); +bool nativevalue_to_se(const cc::physics::RaycastResult &from, se::Value &to, se::Object *ctx); + +bool sevalue_to_native(const se::Value &from, cc::physics::ConvexDesc *to, se::Object *ctx); +bool sevalue_to_native(const se::Value &from, cc::physics::TrimeshDesc *to, se::Object *ctx); +bool sevalue_to_native(const se::Value &from, cc::physics::HeightFieldDesc *to, se::Object *ctx); +bool sevalue_to_native(const se::Value &from, cc::physics::RaycastOptions *to, se::Object *ctx); + +bool nativevalue_to_se(const cc::geometry::AABB &from, se::Value &to, se::Object *ctx); +bool nativevalue_to_se(const cc::geometry::Sphere &from, se::Value &to, se::Object *ctx); + +#endif //USE_PHYSICS_PHYSX diff --git a/native/cocos/bindings/manual/jsb_dragonbones_manual.cpp b/native/cocos/bindings/manual/jsb_dragonbones_manual.cpp index 2a599ef935..37f8b5bf6f 100644 --- a/native/cocos/bindings/manual/jsb_dragonbones_manual.cpp +++ b/native/cocos/bindings/manual/jsb_dragonbones_manual.cpp @@ -28,13 +28,13 @@ #if USE_DRAGONBONES > 0 -#include "cocos/bindings/auto/jsb_dragonbones_auto.h" -#include "cocos/bindings/auto/jsb_editor_support_auto.h" -#include "cocos/bindings/jswrapper/SeApi.h" -#include "cocos/bindings/manual/jsb_conversions.h" -#include "cocos/bindings/manual/jsb_global.h" -#include "cocos/bindings/manual/jsb_helper.h" -#include "cocos/editor-support/dragonbones-creator-support/CCDragonBonesHeaders.h" + #include "cocos/bindings/auto/jsb_dragonbones_auto.h" + #include "cocos/bindings/auto/jsb_editor_support_auto.h" + #include "cocos/bindings/jswrapper/SeApi.h" + #include "cocos/bindings/manual/jsb_conversions.h" + #include "cocos/bindings/manual/jsb_global.h" + #include "cocos/bindings/manual/jsb_helper.h" + #include "cocos/editor-support/dragonbones-creator-support/CCDragonBonesHeaders.h" using namespace cc; @@ -42,9 +42,9 @@ using namespace cc; static bool js_cocos2dx_dragonbones_Slot_get_globalTransformMatrix(se::State &s) { dragonBones::Slot *cobj = (dragonBones::Slot *)s.nativeThisObject(); SE_PRECONDITION2(cobj, false, "js_cocos2dx_dragonbones_Slot_get_globalTransformMatrix : Invalid Native Object"); - const auto &args = s.args(); - size_t argc = args.size(); - CC_UNUSED bool ok = true; + const auto & args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; if (argc == 0) { dragonBones::Matrix *result = cobj->getGlobalTransformMatrix(); ok &= native_ptr_to_seval((dragonBones::Matrix *)result, &s.rval()); @@ -59,9 +59,9 @@ SE_BIND_PROP_GET(js_cocos2dx_dragonbones_Slot_get_globalTransformMatrix) // add by fins static bool js_cocos2dx_dragonbones_Animation_get_animations(se::State &s) { dragonBones::Animation *cobj = (dragonBones::Animation *)s.nativeThisObject(); - se::HandleObject retObj(se::Object::createPlainObject()); - bool ok = false; - se::Value tmp; + se::HandleObject retObj(se::Object::createPlainObject()); + bool ok = false; + se::Value tmp; for (const auto &e : cobj->getAnimations()) { if (!e.first.empty()) { ok = native_ptr_to_seval(e.second, __jsb_dragonBones_AnimationData_class, &tmp); @@ -76,8 +76,8 @@ SE_BIND_PROP_GET(js_cocos2dx_dragonbones_Animation_get_animations) static bool js_cocos2dx_dragonbones_Armature_getDisplay(se::State &s) { if (s.args().size() == 0) { - dragonBones::Armature *cobj = (dragonBones::Armature *)s.nativeThisObject(); - dragonBones::CCArmatureDisplay *ret = (dragonBones::CCArmatureDisplay *)(cobj->getDisplay()); + dragonBones::Armature * cobj = (dragonBones::Armature *)s.nativeThisObject(); + dragonBones::CCArmatureDisplay *ret = (dragonBones::CCArmatureDisplay *)(cobj->getDisplay()); if (ret != nullptr) { bool ok = native_ptr_to_seval(ret, __jsb_dragonBones_CCArmatureDisplay_class, &s.rval()); SE_PRECONDITION2(ok, false, "Convert dragonBones::Animation to se::Value failed!"); @@ -93,13 +93,13 @@ static bool js_cocos2dx_dragonbones_Armature_getDisplay(se::State &s) { SE_BIND_FUNC(js_cocos2dx_dragonbones_Armature_getDisplay) static bool js_cocos2dx_dragonbones_Armature_getSlots(se::State &s) { - dragonBones::Armature *cobj = (dragonBones::Armature *)s.nativeThisObject(); - const auto &result = cobj->getSlots(); - se::HandleObject arr(se::Object::createArrayObject(result.size())); + dragonBones::Armature *cobj = (dragonBones::Armature *)s.nativeThisObject(); + const auto & result = cobj->getSlots(); + se::HandleObject arr(se::Object::createArrayObject(result.size())); - uint32_t i = 0; + uint32_t i = 0; se::Value tmp; - bool ok = true; + bool ok = true; for (const auto &slot : result) { if (!native_ptr_to_seval(slot, &tmp)) { ok = false; @@ -117,13 +117,13 @@ static bool js_cocos2dx_dragonbones_Armature_getSlots(se::State &s) { SE_BIND_FUNC(js_cocos2dx_dragonbones_Armature_getSlots) static bool js_cocos2dx_dragonbones_Armature_getBones(se::State &s) { - dragonBones::Armature *cobj = (dragonBones::Armature *)s.nativeThisObject(); - const auto &result = cobj->getBones(); - se::HandleObject arr(se::Object::createArrayObject(result.size())); + dragonBones::Armature *cobj = (dragonBones::Armature *)s.nativeThisObject(); + const auto & result = cobj->getBones(); + se::HandleObject arr(se::Object::createArrayObject(result.size())); - uint32_t i = 0; + uint32_t i = 0; se::Value tmp; - bool ok = true; + bool ok = true; for (const auto &bone : result) { if (!native_ptr_to_seval(bone, &tmp)) { ok = false; @@ -143,12 +143,12 @@ SE_BIND_FUNC(js_cocos2dx_dragonbones_Armature_getBones) static bool js_cocos2dx_dragonbones_Armature_getBoneByDisplay(se::State &s) { dragonBones::Armature *cobj = (dragonBones::Armature *)s.nativeThisObject(); SE_PRECONDITION2(cobj, false, "js_cocos2dx_dragonbones_Armature_getBoneByDisplay : Invalid Native Object"); - const auto &args = s.args(); - size_t argc = args.size(); - CC_UNUSED bool ok = true; + const auto & args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; if (argc == 1) { dragonBones::CCArmatureDisplay *display = nullptr; - ok = seval_to_native_ptr(args[0], &display); + ok = seval_to_native_ptr(args[0], &display); SE_PRECONDITION2(ok, false, "js_cocos2dx_dragonbones_Armature_getBoneByDisplay : Error processing arguments"); dragonBones::Bone *result = cobj->getBoneByDisplay(display); ok &= native_ptr_to_seval((dragonBones::Bone *)result, &s.rval()); @@ -163,12 +163,12 @@ SE_BIND_FUNC(js_cocos2dx_dragonbones_Armature_getBoneByDisplay) static bool js_cocos2dx_dragonbones_Armature_getSlotByDisplay(se::State &s) { dragonBones::Armature *cobj = (dragonBones::Armature *)s.nativeThisObject(); SE_PRECONDITION2(cobj, false, "js_cocos2dx_dragonbones_Armature_getSlotByDisplay : Invalid Native Object"); - const auto &args = s.args(); - size_t argc = args.size(); - CC_UNUSED bool ok = true; + const auto & args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; if (argc == 1) { dragonBones::CCArmatureDisplay *display = nullptr; - ok = seval_to_native_ptr(args[0], &display); + ok = seval_to_native_ptr(args[0], &display); SE_PRECONDITION2(ok, false, "js_cocos2dx_dragonbones_Armature_getSlotByDisplay : Error processing arguments"); dragonBones::Slot *result = cobj->getSlotByDisplay(display); ok &= native_ptr_to_seval((dragonBones::Slot *)result, &s.rval()); @@ -183,12 +183,12 @@ SE_BIND_FUNC(js_cocos2dx_dragonbones_Armature_getSlotByDisplay) static bool js_cocos2dx_dragonbones_Armature_setReplacedTexture(se::State &s) { dragonBones::Armature *cobj = (dragonBones::Armature *)s.nativeThisObject(); SE_PRECONDITION2(cobj, false, "js_cocos2dx_dragonbones_Armature_setReplacedTexture : Invalid Native Object"); - const auto &args = s.args(); - size_t argc = args.size(); - CC_UNUSED bool ok = true; + const auto & args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; if (argc == 1) { middleware::Texture2D *texture = nullptr; - ok = seval_to_native_ptr(args[0], &texture); + ok = seval_to_native_ptr(args[0], &texture); SE_PRECONDITION2(ok, false, "js_cocos2dx_dragonbones_Armature_setReplacedTexture : Error processing arguments"); cobj->setReplacedTexture(texture); return true; @@ -201,12 +201,12 @@ SE_BIND_FUNC(js_cocos2dx_dragonbones_Armature_setReplacedTexture) static bool js_cocos2dx_dragonbones_Armature_getReplacedTexture(se::State &s) { dragonBones::Armature *cobj = (dragonBones::Armature *)s.nativeThisObject(); SE_PRECONDITION2(cobj, false, "js_cocos2dx_dragonbones_Armature_getReplacedTexture : Invalid Native Object"); - const auto &args = s.args(); - size_t argc = args.size(); - CC_UNUSED bool ok = true; + const auto & args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; if (argc == 0) { middleware::Texture2D *result = (middleware::Texture2D *)cobj->getReplacedTexture(); - ok = native_ptr_to_seval(result, __jsb_cc_middleware_Texture2D_class, &s.rval()); + ok = native_ptr_to_seval(result, __jsb_cc_middleware_Texture2D_class, &s.rval()); SE_PRECONDITION2(ok, false, "js_cocos2dx_dragonbones_Armature_getReplacedTexture : Error processing arguments"); return true; } @@ -217,9 +217,9 @@ SE_BIND_FUNC(js_cocos2dx_dragonbones_Armature_getReplacedTexture) static bool js_cocos2dx_dragonbones_ArmatureData_get_animations(se::State &s) { dragonBones::ArmatureData *cobj = (dragonBones::ArmatureData *)s.nativeThisObject(); - se::HandleObject retObj(se::Object::createPlainObject()); - bool ok = false; - se::Value tmp; + se::HandleObject retObj(se::Object::createPlainObject()); + bool ok = false; + se::Value tmp; for (const auto &e : cobj->animations) { if (!e.first.empty()) { ok = native_ptr_to_seval(e.second, __jsb_dragonBones_AnimationData_class, &tmp); @@ -234,9 +234,9 @@ SE_BIND_PROP_GET(js_cocos2dx_dragonbones_ArmatureData_get_animations) static bool js_cocos2dx_dragonbones_ArmatureData_get_bones(se::State &s) { dragonBones::ArmatureData *cobj = (dragonBones::ArmatureData *)s.nativeThisObject(); - se::HandleObject retObj(se::Object::createPlainObject()); - bool ok = false; - se::Value tmp; + se::HandleObject retObj(se::Object::createPlainObject()); + bool ok = false; + se::Value tmp; for (const auto &e : cobj->bones) { if (!e.first.empty()) { ok = native_ptr_to_seval(e.second, __jsb_dragonBones_BoneData_class, &tmp); @@ -251,9 +251,9 @@ SE_BIND_PROP_GET(js_cocos2dx_dragonbones_ArmatureData_get_bones) static bool js_cocos2dx_dragonbones_ArmatureData_get_skins(se::State &s) { dragonBones::ArmatureData *cobj = (dragonBones::ArmatureData *)s.nativeThisObject(); - se::HandleObject retObj(se::Object::createPlainObject()); - bool ok = false; - se::Value tmp; + se::HandleObject retObj(se::Object::createPlainObject()); + bool ok = false; + se::Value tmp; for (const auto &e : cobj->skins) { if (!e.first.empty()) { ok = native_ptr_to_seval(e.second, __jsb_dragonBones_SkinData_class, &tmp); @@ -268,9 +268,9 @@ SE_BIND_PROP_GET(js_cocos2dx_dragonbones_ArmatureData_get_skins) static bool js_cocos2dx_dragonbones_ArmatureData_get_slots(se::State &s) { dragonBones::ArmatureData *cobj = (dragonBones::ArmatureData *)s.nativeThisObject(); - se::HandleObject retObj(se::Object::createPlainObject()); - bool ok = false; - se::Value tmp; + se::HandleObject retObj(se::Object::createPlainObject()); + bool ok = false; + se::Value tmp; for (const auto &e : cobj->slots) { if (!e.first.empty()) { ok = native_ptr_to_seval(e.second, __jsb_dragonBones_SlotData_class, &tmp); @@ -287,29 +287,29 @@ static bool js_cocos2dx_dragonbones_DragonBonesData_get_armatureNames(se::State dragonBones::DragonBonesData *cobj = (dragonBones::DragonBonesData *)s.nativeThisObject(); const auto &ret = cobj->getArmatureNames(); - bool ok = std_vector_string_to_seval(ret, &s.rval()); + bool ok = nativevalue_to_se(ret, s.rval()); SE_PRECONDITION2(ok, false, "Convert ArmatureNames to se::Value failed!"); return true; } SE_BIND_PROP_GET(js_cocos2dx_dragonbones_DragonBonesData_get_armatureNames) static bool js_cocos2dx_dragonbones_Slot_getDisplay(se::State &s) { - dragonBones::Slot *cobj = (dragonBones::Slot *)s.nativeThisObject(); - dragonBones::CCArmatureDisplay *ret = static_cast(cobj->getDisplay()); - bool ok = native_ptr_to_seval(ret, __jsb_dragonBones_CCArmatureDisplay_class, &s.rval()); + dragonBones::Slot * cobj = (dragonBones::Slot *)s.nativeThisObject(); + dragonBones::CCArmatureDisplay *ret = static_cast(cobj->getDisplay()); + bool ok = native_ptr_to_seval(ret, __jsb_dragonBones_CCArmatureDisplay_class, &s.rval()); SE_PRECONDITION2(ok, false, "Convert dragonBones::DBCCSprite to se::Value failed!"); return true; } SE_BIND_FUNC(js_cocos2dx_dragonbones_Slot_getDisplay) static bool js_cocos2dx_dragonbones_Slot_set_displayIndex(se::State &s) { - const auto &args = s.args(); + const auto & args = s.args(); dragonBones::Slot *cobj = (dragonBones::Slot *)s.nativeThisObject(); SE_PRECONDITION2(cobj, false, "js_cocos2dx_dragonbones_Slot_set_displayIndex : Invalid Native Object"); CC_UNUSED bool ok = true; - int32_t arg0; - ok &= seval_to_int32(args[0], &arg0); + int32_t arg0; + ok &= sevalue_to_native(args[0], &arg0); SE_PRECONDITION2(ok, false, "js_cocos2dx_dragonbones_Slot_set_displayIndex : Error processing new value"); cobj->setDisplayIndex(arg0); return true; @@ -321,7 +321,7 @@ static bool js_cocos2dx_dragonbones_Slot_get_displayIndex(se::State &s) { SE_PRECONDITION2(cobj, false, "js_cocos2dx_dragonbones_Slot_get_displayIndex : Invalid Native Object"); const int32_t ret = cobj->getDisplayIndex(); - bool ok = int32_to_seval(ret, &s.rval()); + bool ok = nativevalue_to_se(ret, s.rval()); SE_PRECONDITION2(ok, false, "js_cocos2dx_dragonbones_Slot_get_displayIndex to se::Value failed!"); return true; } @@ -329,15 +329,15 @@ SE_BIND_PROP_GET(js_cocos2dx_dragonbones_Slot_get_displayIndex) static bool js_cocos2dx_dragonbones_Slot_setDisplay(se::State &s) { const auto &args = s.args(); - int argc = (int)args.size(); + int argc = (int)args.size(); if (argc == 2) { - dragonBones::Slot *cobj = (dragonBones::Slot *)s.nativeThisObject(); + dragonBones::Slot * cobj = (dragonBones::Slot *)s.nativeThisObject(); dragonBones::CCArmatureDisplay *dbSprite = nullptr; - bool ok = seval_to_native_ptr(args[0], &dbSprite); + bool ok = seval_to_native_ptr(args[0], &dbSprite); SE_PRECONDITION2(ok, false, "Convert se::Value to dragonBones::DBCCSprite failed!"); dragonBones::DisplayType type; - ok = seval_to_int32(args[1], (int32_t *)&type); + ok = sevalue_to_native(args[1], (int32_t *)&type); SE_PRECONDITION2(ok, false, "Convert se::Value to dragonBones::DisplayType failed!"); cobj->setDisplay(dbSprite, type); return true; @@ -351,14 +351,14 @@ SE_BIND_FUNC(js_cocos2dx_dragonbones_Slot_setDisplay) static bool js_cocos2dx_dragonbones_BaseFactory_parseTextureAtlasData(se::State &s) { dragonBones::BaseFactory *cobj = (dragonBones::BaseFactory *)s.nativeThisObject(); SE_PRECONDITION2(cobj, false, "js_cocos2dx_dragonbones_BaseFactory_parseTextureAtlasData : Invalid Native Object"); - const auto &args = s.args(); - size_t argc = args.size(); - CC_UNUSED bool ok = true; + const auto & args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; if (argc == 2) { const char *arg0 = nullptr; - void *arg1 = nullptr; + void * arg1 = nullptr; std::string arg0_tmp; - ok &= seval_to_std_string(args[0], &arg0_tmp); + ok &= sevalue_to_native(args[0], &arg0_tmp); arg0 = arg0_tmp.c_str(); ok &= seval_to_native_ptr(args[1], &arg1); SE_PRECONDITION2(ok, false, "js_cocos2dx_dragonbones_BaseFactory_parseTextureAtlasData : Error processing arguments"); @@ -369,14 +369,14 @@ static bool js_cocos2dx_dragonbones_BaseFactory_parseTextureAtlasData(se::State } if (argc == 3) { const char *arg0 = nullptr; - void *arg1 = nullptr; + void * arg1 = nullptr; std::string arg2; std::string arg0_tmp; - ok &= seval_to_std_string(args[0], &arg0_tmp); + ok &= sevalue_to_native(args[0], &arg0_tmp); arg0 = arg0_tmp.c_str(); ok &= seval_to_native_ptr(args[1], &arg1); SE_PRECONDITION2(ok, false, "js_cocos2dx_dragonbones_BaseFactory_parseTextureAtlasData : Error processing arguments"); - ok &= seval_to_std_string(args[2], &arg2); + ok &= sevalue_to_native(args[2], &arg2); SE_PRECONDITION2(ok, false, "js_cocos2dx_dragonbones_BaseFactory_parseTextureAtlasData : Error processing arguments"); dragonBones::TextureAtlasData *result = cobj->parseTextureAtlasData(arg0, arg1, arg2); ok &= native_ptr_to_seval((dragonBones::TextureAtlasData *)result, &s.rval()); @@ -385,16 +385,16 @@ static bool js_cocos2dx_dragonbones_BaseFactory_parseTextureAtlasData(se::State } if (argc == 4) { const char *arg0 = nullptr; - void *arg1 = nullptr; + void * arg1 = nullptr; std::string arg2; - float arg3 = 0; + float arg3 = 0; std::string arg0_tmp; - ok &= seval_to_std_string(args[0], &arg0_tmp); + ok &= sevalue_to_native(args[0], &arg0_tmp); arg0 = arg0_tmp.c_str(); ok &= seval_to_native_ptr(args[1], &arg1); SE_PRECONDITION2(ok, false, "js_cocos2dx_dragonbones_BaseFactory_parseTextureAtlasData : Error processing arguments"); - ok &= seval_to_std_string(args[2], &arg2); - ok &= seval_to_float(args[3], &arg3); + ok &= sevalue_to_native(args[2], &arg2); + ok &= sevalue_to_native(args[3], &arg3); SE_PRECONDITION2(ok, false, "js_cocos2dx_dragonbones_BaseFactory_parseTextureAtlasData : Error processing arguments"); dragonBones::TextureAtlasData *result = cobj->parseTextureAtlasData(arg0, arg1, arg2, arg3); ok &= native_ptr_to_seval((dragonBones::TextureAtlasData *)result, &s.rval()); diff --git a/native/cocos/bindings/manual/jsb_gfx_manual.cpp b/native/cocos/bindings/manual/jsb_gfx_manual.cpp index 1515eb993e..671a7db43e 100644 --- a/native/cocos/bindings/manual/jsb_gfx_manual.cpp +++ b/native/cocos/bindings/manual/jsb_gfx_manual.cpp @@ -195,7 +195,7 @@ static bool js_gfx_Device_createBuffer(se::State &s) { // NOLINT(readability-ide cc::gfx::Buffer *buffer = nullptr; bool createBufferView = false; - seval_to_boolean(args[1], &createBufferView); + sevalue_to_native(args[1], &createBufferView); if (createBufferView) { cc::gfx::BufferViewInfo bufferViewInfo; @@ -206,9 +206,8 @@ static bool js_gfx_Device_createBuffer(se::State &s) { // NOLINT(readability-ide sevalue_to_native(args[0], &bufferInfo, s.thisObject()); buffer = cobj->createBuffer(bufferInfo); } - se::NonRefNativePtrCreatedByCtorMap::emplace(buffer); - CC_UNUSED bool ok = native_ptr_to_seval(buffer, &s.rval()); + s.rval().toObject()->getPrivateObject()->tryAllowDestroyInGC(); SE_PRECONDITION2(ok, false, "js_gfx_Device_createBuffer : Error processing arguments"); return true; } @@ -227,7 +226,7 @@ static bool js_gfx_Device_createTexture(se::State &s) { // NOLINT(readability-id if (argc == 2) { cc::gfx::Texture *texture = nullptr; bool createTextureView = false; - seval_to_boolean(args[1], &createTextureView); + sevalue_to_native(args[1], &createTextureView); if (createTextureView) { cc::gfx::TextureViewInfo textureViewInfo; sevalue_to_native(args[0], &textureViewInfo, s.thisObject()); @@ -237,9 +236,8 @@ static bool js_gfx_Device_createTexture(se::State &s) { // NOLINT(readability-id sevalue_to_native(args[0], &textureInfo, s.thisObject()); texture = cobj->createTexture(textureInfo); } - se::NonRefNativePtrCreatedByCtorMap::emplace(texture); - CC_UNUSED bool ok = native_ptr_to_seval(texture, &s.rval()); + s.rval().toObject()->getPrivateObject()->tryAllowDestroyInGC(); SE_PRECONDITION2(ok, false, "js_gfx_Device_createTexture : Error processing arguments"); return true; } @@ -258,7 +256,7 @@ static bool js_gfx_Buffer_initialize(se::State &s) { // NOLINT(readability-ident if (argc == 2) { bool initWithBufferViewInfo = false; - seval_to_boolean(args[1], &initWithBufferViewInfo); + sevalue_to_native(args[1], &initWithBufferViewInfo); if (initWithBufferViewInfo) { cc::gfx::BufferViewInfo bufferViewInfo; @@ -270,7 +268,7 @@ static bool js_gfx_Buffer_initialize(se::State &s) { // NOLINT(readability-ident cobj->initialize(bufferInfo); } - ok &= boolean_to_seval(ok, &s.rval()); + ok &= nativevalue_to_se(ok, s.rval()); SE_PRECONDITION2(ok, false, "js_gfx_Buffer_initialize : Error processing arguments"); return true; } @@ -289,7 +287,7 @@ static bool js_gfx_Texture_initialize(se::State &s) { // NOLINT(readability-iden if (argc == 2) { bool initWithTextureViewInfo = false; - seval_to_boolean(args[1], &initWithTextureViewInfo); + sevalue_to_native(args[1], &initWithTextureViewInfo); if (initWithTextureViewInfo) { cc::gfx::TextureViewInfo textureViewInfo; @@ -301,7 +299,7 @@ static bool js_gfx_Texture_initialize(se::State &s) { // NOLINT(readability-iden cobj->initialize(textureInfo); } - ok &= boolean_to_seval(ok, &s.rval()); + ok &= nativevalue_to_se(ok, s.rval()); SE_PRECONDITION2(ok, false, "js_gfx_Texture_initialize : Error processing arguments"); return true; } @@ -338,7 +336,7 @@ static bool js_gfx_GFXBuffer_update(se::State &s) { // NOLINT(readability-identi } if (argc == 2) { unsigned int arg1 = 0; - ok &= seval_to_uint32(args[1], &arg1); + ok &= sevalue_to_native(args[1], &arg1); SE_PRECONDITION2(ok, false, "js_gfx_GFXBuffer_update : Error processing arguments"); cobj->update(arg0, arg1); return true; @@ -357,7 +355,7 @@ static bool js_gfx_CommandBuffer_execute(se::State &s) { // NOLINT(readability-i if (argc == 2) { cc::gfx::CommandBufferList cmdBufs; unsigned int count = 0; - ok &= seval_to_uint32(args[1], &count); + ok &= sevalue_to_native(args[1], &count); se::Object *jsarr = args[0].toObject(); assert(jsarr->isArray()); @@ -376,7 +374,6 @@ static bool js_gfx_CommandBuffer_execute(se::State &s) { // NOLINT(readability-i cmdBufs.clear(); break; } - auto *cmdBuf = static_cast(tmp.toObject()->getPrivateData()); cmdBufs[i] = cmdBuf; } diff --git a/native/cocos/bindings/manual/jsb_global.cpp b/native/cocos/bindings/manual/jsb_global.cpp index a1974d22ed..314c660cac 100644 --- a/native/cocos/bindings/manual/jsb_global.cpp +++ b/native/cocos/bindings/manual/jsb_global.cpp @@ -25,14 +25,15 @@ #include "jsb_global.h" #include "application/ApplicationManager.h" -#include "base/AutoreleasePool.h" #include "base/CoreStd.h" +#include "base/DeferredReleasePool.h" #include "base/Scheduler.h" #include "base/ThreadPool.h" #include "base/ZipUtils.h" #include "base/base64.h" #include "gfx-base/GFXDef.h" #include "jsb_conversions.h" +#include "network/Downloader.h" #include "network/HttpClient.h" #include "platform/Image.h" #include "platform/interfaces/modules/ISystem.h" @@ -299,7 +300,7 @@ static bool jsc_dumpNativePtrToSeObjectMap(se::State &s) { //NOLINT for (const auto &e : namePtrArray) { CC_LOG_DEBUG("%s: %p", e.name, e.ptr); } - CC_LOG_DEBUG(">>> total: %d, nonRefMap: %d, Dump (native -> jsobj) map end", (int)se::NativePtrToObjectMap::size(), (int)se::NonRefNativePtrCreatedByCtorMap::size()); + CC_LOG_DEBUG(">>> total: %d, Dump (native -> jsobj) map end", (int)se::NativePtrToObjectMap::size()); return true; } SE_BIND_FUNC(jsc_dumpNativePtrToSeObjectMap) @@ -345,7 +346,7 @@ static bool JSBCore_os(se::State &s) { //NOLINT SE_BIND_FUNC(JSBCore_os) static bool JSBCore_getCurrentLanguage(se::State &s) { //NOLINT - ISystem * systemIntf = CC_GET_PLATFORM_INTERFACE(ISystem); + ISystem *systemIntf = CC_GET_PLATFORM_INTERFACE(ISystem); CCASSERT(systemIntf != nullptr, "System interface does not exist"); std::string languageStr = systemIntf->getCurrentLanguageToString(); s.rval().setString(languageStr); @@ -354,16 +355,16 @@ static bool JSBCore_getCurrentLanguage(se::State &s) { //NOLINT SE_BIND_FUNC(JSBCore_getCurrentLanguage) static bool JSBCore_getCurrentLanguageCode(se::State &s) { //NOLINT - ISystem * systemIntf = CC_GET_PLATFORM_INTERFACE(ISystem); + ISystem *systemIntf = CC_GET_PLATFORM_INTERFACE(ISystem); CCASSERT(systemIntf != nullptr, "System interface does not exist"); - std::string language = systemIntf->getCurrentLanguageCode(); + std::string language = systemIntf->getCurrentLanguageCode(); s.rval().setString(language); return true; } SE_BIND_FUNC(JSBCore_getCurrentLanguageCode) static bool JSB_getOSVersion(se::State &s) { //NOLINT - ISystem * systemIntf = CC_GET_PLATFORM_INTERFACE(ISystem); + ISystem *systemIntf = CC_GET_PLATFORM_INTERFACE(ISystem); CCASSERT(systemIntf != nullptr, "System interface does not exist"); std::string systemVersion = systemIntf->getSystemVersion(); s.rval().setString(systemVersion); @@ -405,7 +406,7 @@ static bool JSB_setCursorEnabled(se::State &s) { //NOLINT SE_PRECONDITION2(argc == 1, false, "Invalid number of arguments"); bool ok = true; bool value = true; - ok &= seval_to_boolean(args[0], &value); + ok &= sevalue_to_native(args[0], &value); SE_PRECONDITION2(ok, false, "Error processing arguments"); auto *systemWindowIntf = CC_GET_PLATFORM_INTERFACE(ISystemWindow); @@ -422,8 +423,8 @@ static bool JSB_saveByteCode(se::State &s) { //NOLINT bool ok = true; std::string srcfile; std::string dstfile; - ok &= seval_to_std_string(args[0], &srcfile); - ok &= seval_to_std_string(args[1], &dstfile); + ok &= sevalue_to_native(args[0], &srcfile); + ok &= sevalue_to_native(args[1], &dstfile); SE_PRECONDITION2(ok, false, "Error processing arguments"); ok = se::ScriptEngine::getInstance()->saveByteCodeToFile(srcfile, dstfile); s.rval().setBoolean(ok); @@ -571,7 +572,7 @@ bool jsb_global_load_image(const std::string &path, const se::Value &callbackVal loadSucceed = img->initWithImageFile(fullPath); } - struct ImageInfo *imgInfo = nullptr; + ImageInfo *imgInfo = nullptr; if (loadSucceed) { imgInfo = createImageInfo(img); } @@ -595,7 +596,7 @@ bool jsb_global_load_image(const std::string &path, const se::Value &callbackVal SE_REPORT_ERROR("initWithImageFile: %s failed!", path.c_str()); } callbackPtr->toObject()->call(seArgs, nullptr); - img->release(); + delete img; }); }); }; @@ -636,7 +637,7 @@ static bool js_loadImage(se::State &s) { //NOLINT CC_UNUSED bool ok = true; if (argc == 2) { std::string path; - ok &= seval_to_std_string(args[0], &path); + ok &= sevalue_to_native(args[0], &path); SE_PRECONDITION2(ok, false, "js_loadImage : Error processing arguments"); se::Value callbackVal = args[1]; @@ -671,7 +672,7 @@ static bool JSB_openURL(se::State &s) { //NOLINT CC_UNUSED bool ok = true; if (argc > 0) { std::string url; - ok = seval_to_std_string(args[0], &url); + ok = sevalue_to_native(args[0], &url); SE_PRECONDITION2(ok, false, "url is invalid!"); ISystem *systemIntf = CC_GET_PLATFORM_INTERFACE(ISystem); CCASSERT(systemIntf != nullptr, "System interface does not exist"); @@ -690,7 +691,7 @@ static bool JSB_copyTextToClipboard(se::State &s) { //NOLINT CC_UNUSED bool ok = true; if (argc > 0) { std::string text; - ok = seval_to_std_string(args[0], &text); + ok = sevalue_to_native(args[0], &text); SE_PRECONDITION2(ok, false, "text is invalid!"); ISystemWindow *systemWindowIntf = CC_GET_PLATFORM_INTERFACE(ISystemWindow); CCASSERT(systemWindowIntf != nullptr, "System window interface does not exist"); @@ -709,7 +710,7 @@ static bool JSB_setPreferredFramesPerSecond(se::State &s) { //NOLINT CC_UNUSED bool ok = true; if (argc > 0) { int32_t fps; - ok = seval_to_int32(args[0], &fps); + ok = sevalue_to_native(args[0], &fps); SE_PRECONDITION2(ok, false, "fps is invalid!"); // cc::log("EMPTY IMPLEMENTATION OF jsb.setPreferredFramesPerSecond"); CC_CURRENT_ENGINE()->setPreferredFramesPerSecond(fps); @@ -855,11 +856,11 @@ bool jsb_register_global_variables(se::Object *global) { //NOLINT delete gThreadPool; gThreadPool = nullptr; - PoolManager::getInstance()->getCurrentPool()->clear(); + DeferredReleasePool::clear(); }); se::ScriptEngine::getInstance()->addAfterCleanupHook([]() { - PoolManager::getInstance()->getCurrentPool()->clear(); + DeferredReleasePool::clear(); gModuleCache.clear(); diff --git a/native/cocos/bindings/manual/jsb_global.h b/native/cocos/bindings/manual/jsb_global.h index b1610e28d9..54e13c0e56 100644 --- a/native/cocos/bindings/manual/jsb_global.h +++ b/native/cocos/bindings/manual/jsb_global.h @@ -26,6 +26,7 @@ #pragma once #include "base/CoreStd.h" +#include "bindings/jswrapper/PrivateObject.h" #include "jsb_global_init.h" template @@ -56,9 +57,22 @@ jsb_override_delete(T *arg) { //NOLINT(readability-identifier-naming) delete (arg); } -#define JSB_ALLOC(kls, ...) jsb_override_new(__VA_ARGS__) -#define JSB_FREE(kls) jsb_override_delete(kls) +template +typename std::enable_if::value, se::PrivateObjectBase *>::type +jsb_make_private_object(ARGS &&...args) { //NOLINT(readability-identifier-naming) + //return se::raw_private_data(new T(std::forward(args)...)); + return se::ccshared_private_object(new T(std::forward(args)...)); +} +template +typename std::enable_if::value, se::PrivateObjectBase *>::type +jsb_make_private_object(ARGS &&...args) { //NOLINT(readability-identifier-naming) + return se::shared_private_object(std::make_shared(std::forward(args)...)); +} + +#define JSB_MAKE_PRIVATE_OBJECT(kls, ...) jsb_make_private_object(__VA_ARGS__) +#define JSB_ALLOC(kls, ...) jsb_override_new(__VA_ARGS__) +#define JSB_FREE(kls) jsb_override_delete(kls) namespace se { class Class; class Value; diff --git a/native/cocos/bindings/manual/jsb_helper.cpp b/native/cocos/bindings/manual/jsb_helper.cpp index 1160a5f5de..0f2a15531c 100644 --- a/native/cocos/bindings/manual/jsb_helper.cpp +++ b/native/cocos/bindings/manual/jsb_helper.cpp @@ -24,12 +24,13 @@ ****************************************************************************/ #include "jsb_helper.h" +#include "base/DeferredReleasePool.h" /* static */ void CleanupTask::pushTaskToAutoReleasePool(const std::function &cb) { - auto ret = new (std::nothrow) CleanupTask(); + auto *ret = new (std::nothrow) CleanupTask(); ret->_cb = cb; - ret->autorelease(); + cc::DeferredReleasePool::add(ret); } CleanupTask::CleanupTask() diff --git a/native/cocos/bindings/manual/jsb_helper.h b/native/cocos/bindings/manual/jsb_helper.h index 1e43edfb21..58716ce3b9 100644 --- a/native/cocos/bindings/manual/jsb_helper.h +++ b/native/cocos/bindings/manual/jsb_helper.h @@ -25,16 +25,16 @@ #pragma once -#include "base/Ref.h" +#include "base/RefCounted.h" #include -class CleanupTask : public cc::Ref { +class CleanupTask : public cc::RefCounted { public: static void pushTaskToAutoReleasePool(const std::function &cb); CleanupTask(); - virtual ~CleanupTask(); + ~CleanupTask() override; private: std::function _cb; diff --git a/native/cocos/bindings/manual/jsb_module_register.cpp b/native/cocos/bindings/manual/jsb_module_register.cpp index e29d1fbca5..22e46b97a1 100644 --- a/native/cocos/bindings/manual/jsb_module_register.cpp +++ b/native/cocos/bindings/manual/jsb_module_register.cpp @@ -24,15 +24,18 @@ ****************************************************************************/ #include "cocos/bindings/manual/jsb_module_register.h" -#include "cocos/base/AutoreleasePool.h" +#include "cocos/base/DeferredReleasePool.h" +#include "cocos/bindings/auto/jsb_assets_auto.h" #include "cocos/bindings/auto/jsb_cocos_auto.h" #include "cocos/bindings/auto/jsb_extension_auto.h" +#include "cocos/bindings/auto/jsb_geometry_auto.h" #include "cocos/bindings/auto/jsb_gfx_auto.h" #include "cocos/bindings/auto/jsb_network_auto.h" #include "cocos/bindings/auto/jsb_pipeline_auto.h" #include "cocos/bindings/auto/jsb_scene_auto.h" #include "cocos/bindings/dop/jsb_dop.h" #include "cocos/bindings/jswrapper/SeApi.h" +#include "cocos/bindings/manual/jsb_assets_manual.h" #include "cocos/bindings/manual/jsb_cocos_manual.h" #include "cocos/bindings/manual/jsb_conversions.h" #include "cocos/bindings/manual/jsb_gfx_manual.h" @@ -103,9 +106,9 @@ bool jsb_register_all_modules() { se->addBeforeCleanupHook([se]() { se->garbageCollect(); - cc::PoolManager::getInstance()->getCurrentPool()->clear(); + cc::DeferredReleasePool::clear(); se->garbageCollect(); - cc::PoolManager::getInstance()->getCurrentPool()->clear(); + cc::DeferredReleasePool::clear(); }); se->addRegisterCallback(jsb_register_global_variables); @@ -123,6 +126,9 @@ bool jsb_register_all_modules() { se->addRegisterCallback(register_all_dop_bindings); se->addRegisterCallback(register_all_pipeline); se->addRegisterCallback(register_all_pipeline_manual); + se->addRegisterCallback(register_all_geometry); + se->addRegisterCallback(register_all_assets); + se->addRegisterCallback(register_all_assets_manual); se->addRegisterCallback(register_all_scene); se->addRegisterCallback(register_all_scene_manual); @@ -180,7 +186,7 @@ bool jsb_register_all_modules() { se->addRegisterCallback(register_all_websocket_server); #endif se->addAfterCleanupHook([]() { - cc::PoolManager::getInstance()->getCurrentPool()->clear(); + cc::DeferredReleasePool::clear(); JSBClassType::cleanup(); }); return true; diff --git a/native/cocos/bindings/manual/jsb_network_manual.cpp b/native/cocos/bindings/manual/jsb_network_manual.cpp index 38479a2e69..368ed55ec8 100644 --- a/native/cocos/bindings/manual/jsb_network_manual.cpp +++ b/native/cocos/bindings/manual/jsb_network_manual.cpp @@ -23,25 +23,25 @@ THE SOFTWARE. ****************************************************************************/ -#include "base/Config.h" #include "jsb_network_manual.h" +#include "base/Config.h" +#include "bindings/auto/jsb_network_auto.h" #include "bindings/manual/jsb_conversions.h" #include "bindings/manual/jsb_global.h" #include "network/Downloader.h" -#include "bindings/auto/jsb_network_auto.h" static bool js_cocos2dx_network_Downloader_createDownloadFileTask(se::State &s) { // NOLINT(readability-identifier-naming) auto *cobj = static_cast(s.nativeThisObject()); SE_PRECONDITION2(cobj, false, "js_network_Downloader_createDownloadFileTask : Invalid Native Object"); - const auto &args = s.args(); - size_t argc = args.size(); - CC_UNUSED bool ok = true; + const auto & args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; if (argc == 2) { std::string arg0; std::string arg1; - ok &= seval_to_std_string(args[0], &arg0); - ok &= seval_to_std_string(args[1], &arg1); + ok &= sevalue_to_native(args[0], &arg0); + ok &= sevalue_to_native(args[1], &arg1); SE_PRECONDITION2(ok, false, "js_network_Downloader_createDownloadFileTask : Error processing arguments"); std::shared_ptr result = cobj->createDownloadFileTask( @@ -58,9 +58,9 @@ static bool js_cocos2dx_network_Downloader_createDownloadFileTask(se::State &s) std::string arg0; std::string arg1; std::string arg2; - ok &= seval_to_std_string(args[0], &arg0); - ok &= seval_to_std_string(args[1], &arg1); - ok &= seval_to_std_string(args[2], &arg2); + ok &= sevalue_to_native(args[0], &arg0); + ok &= sevalue_to_native(args[1], &arg1); + ok &= sevalue_to_native(args[2], &arg2); SE_PRECONDITION2(ok, false, "js_network_Downloader_createDownloadFileTask : Error processing arguments"); std::shared_ptr result = cobj->createDownloadFileTask( @@ -82,9 +82,9 @@ SE_BIND_FUNC(js_cocos2dx_network_Downloader_createDownloadFileTask) static bool js_network_Downloader_setOnFileTaskSuccess(se::State &s) { // NOLINT(readability-identifier-naming) auto *cobj = static_cast(s.nativeThisObject()); SE_PRECONDITION2(cobj, false, "js_network_Downloader_setOnFileTaskSuccess : Invalid Native Object"); - const auto &args = s.args(); - size_t argc = args.size(); - CC_UNUSED bool ok = true; + const auto & args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; if (argc == 1) { std::function arg0; do { @@ -92,7 +92,8 @@ static bool js_network_Downloader_setOnFileTaskSuccess(se::State &s) { // NOLINT se::Value jsThis(s.thisObject()); se::Value jsFunc(args[0]); jsThis.toObject()->attachObject(jsFunc.toObject()); - auto lambda = [=](const cc::network::DownloadTask &larg0) -> void { + auto *thisObj = s.thisObject(); + auto lambda = [=](const cc::network::DownloadTask &larg0) -> void { se::ScriptEngine::getInstance()->clearException(); se::AutoHandleScope hs; @@ -100,10 +101,9 @@ static bool js_network_Downloader_setOnFileTaskSuccess(se::State &s) { // NOLINT se::ValueArray args; args.resize(1); ok &= DownloadTask_to_seval(larg0, &args[0]); - se::Value rval; + se::Value rval; se::Object *funcObj = jsFunc.toObject(); - se::Object *thisObj = jsThis.isObject() ? jsThis.toObject() : nullptr; - bool succeed = funcObj->call(args, thisObj, &rval); + bool succeed = funcObj->call(args, thisObj, &rval); if (!succeed) { se::ScriptEngine::getInstance()->clearException(); } @@ -128,9 +128,9 @@ SE_BIND_FUNC(js_network_Downloader_setOnFileTaskSuccess) // NOLINT(readability-i static bool js_network_Downloader_setOnTaskError(se::State &s) { // NOLINT(readability-identifier-naming) auto *cobj = static_cast(s.nativeThisObject()); SE_PRECONDITION2(cobj, false, "js_network_Downloader_setOnTaskError : Invalid Native Object"); - const auto &args = s.args(); - size_t argc = args.size(); - CC_UNUSED bool ok = true; + const auto & args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; if (argc == 1) { std::function arg0; do { @@ -138,7 +138,8 @@ static bool js_network_Downloader_setOnTaskError(se::State &s) { // NOLINT(reada se::Value jsThis(s.thisObject()); se::Value jsFunc(args[0]); jsThis.toObject()->attachObject(jsFunc.toObject()); - auto lambda = [=](const cc::network::DownloadTask &larg0, int larg1, int larg2, const std::string &larg3) -> void { + auto *thisObj = s.thisObject(); + auto lambda = [=](const cc::network::DownloadTask &larg0, int larg1, int larg2, const std::string &larg3) -> void { se::ScriptEngine::getInstance()->clearException(); se::AutoHandleScope hs; @@ -146,13 +147,12 @@ static bool js_network_Downloader_setOnTaskError(se::State &s) { // NOLINT(reada se::ValueArray args; args.resize(4); ok &= DownloadTask_to_seval(larg0, &args[0]); - ok &= int32_to_seval(larg1, &args[1]); - ok &= int32_to_seval(larg2, &args[2]); - ok &= std_string_to_seval(larg3, &args[3]); - se::Value rval; - se::Object *thisObj = jsThis.isObject() ? jsThis.toObject() : nullptr; + ok &= nativevalue_to_se(larg1, args[1]); + ok &= nativevalue_to_se(larg2, args[2]); + ok &= nativevalue_to_se(larg3, args[3]); + se::Value rval; se::Object *funcObj = jsFunc.toObject(); - bool succeed = funcObj->call(args, thisObj, &rval); + bool succeed = funcObj->call(args, thisObj, &rval); if (!succeed) { se::ScriptEngine::getInstance()->clearException(); } diff --git a/native/cocos/bindings/manual/jsb_pipeline_manual.cpp b/native/cocos/bindings/manual/jsb_pipeline_manual.cpp index efd832ba1c..9c946da525 100644 --- a/native/cocos/bindings/manual/jsb_pipeline_manual.cpp +++ b/native/cocos/bindings/manual/jsb_pipeline_manual.cpp @@ -33,22 +33,6 @@ #include "renderer/pipeline/PipelineStateManager.h" #include "renderer/pipeline/RenderPipeline.h" -static bool js_pipeline_RenderPipeline_getMacros(se::State &s) { // NOLINT(readability-identifier-naming) - auto *cobj = static_cast(s.nativeThisObject()); - SE_PRECONDITION2(cobj, false, "js_pipeline_RenderPipeline_getMacros : Invalid Native Object."); - const auto & args = s.args(); - size_t argc = args.size(); - CC_UNUSED bool ok = true; - if (argc == 0) { - s.rval().setObject(cobj->getMacros().getObject()); - SE_PRECONDITION2(ok, false, "js_pipeline_RenderPipeline_getMacros : Error processing arguments."); - return true; - } - SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 0); - return false; -} -SE_BIND_PROP_GET(js_pipeline_RenderPipeline_getMacros) - static bool JSB_getOrCreatePipelineState(se::State &s) { // NOLINT(readability-identifier-naming) const auto &args = s.args(); size_t argc = args.size(); @@ -118,8 +102,6 @@ bool register_all_pipeline_manual(se::Object *obj) { // NOLINT(readability-ident nr->setProperty("PipelineStateManager", psmVal); psmVal.toObject()->defineFunction("getOrCreatePipelineState", _SE(JSB_getOrCreatePipelineState)); - __jsb_cc_pipeline_RenderPipeline_proto->defineProperty("macros", _SE(js_pipeline_RenderPipeline_getMacros), nullptr); - __jsb_cc_pipeline_GeometryRenderer_proto->defineFunction("flushFromJSB", _SE(js_pipeline_GeometryRenderer_flushFromJSB)); return true; diff --git a/native/cocos/bindings/manual/jsb_platform_android.cpp b/native/cocos/bindings/manual/jsb_platform_android.cpp index e1e642d81c..b67b6346b1 100644 --- a/native/cocos/bindings/manual/jsb_platform_android.cpp +++ b/native/cocos/bindings/manual/jsb_platform_android.cpp @@ -46,22 +46,22 @@ const std::unordered_map &getFontFamilyNameMap() { } static bool JSB_loadFont(se::State &s) { - const auto &args = s.args(); - size_t argc = args.size(); - CC_UNUSED bool ok = true; + const auto & args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; if (argc >= 1) { s.rval().setNull(); std::string originalFamilyName; - ok &= seval_to_std_string(args[0], &originalFamilyName); + ok &= sevalue_to_native(args[0], &originalFamilyName); SE_PRECONDITION2(ok, false, "JSB_loadFont : Error processing argument: originalFamilyName"); std::string source; - ok &= seval_to_std_string(args[1], &source); + ok &= sevalue_to_native(args[1], &source); SE_PRECONDITION2(ok, false, "JSB_loadFont : Error processing argument: source"); - std::string fontFilePath; - std::regex re("url\\(\\s*'\\s*(.*?)\\s*'\\s*\\)"); + std::string fontFilePath; + std::regex re("url\\(\\s*'\\s*(.*?)\\s*'\\s*\\)"); std::match_results results; if (std::regex_search(source.cbegin(), source.cend(), results, re)) { fontFilePath = results[1].str(); diff --git a/native/cocos/bindings/manual/jsb_platform_ohos.cpp b/native/cocos/bindings/manual/jsb_platform_ohos.cpp index 3872131ade..5e84dc47bf 100644 --- a/native/cocos/bindings/manual/jsb_platform_ohos.cpp +++ b/native/cocos/bindings/manual/jsb_platform_ohos.cpp @@ -52,11 +52,11 @@ static bool JSB_loadFont(se::State &s) { //NOLINT s.rval().setNull(); std::string originalFamilyName; - ok &= seval_to_std_string(args[0], &originalFamilyName); + ok &= sevalue_to_native(args[0], &originalFamilyName); SE_PRECONDITION2(ok, false, "JSB_loadFont : Error processing argument: originalFamilyName"); std::string source; - ok &= seval_to_std_string(args[1], &source); + ok &= sevalue_to_native(args[1], &source); SE_PRECONDITION2(ok, false, "JSB_loadFont : Error processing argument: source"); std::string fontFilePath; diff --git a/native/cocos/bindings/manual/jsb_platfrom_apple.mm b/native/cocos/bindings/manual/jsb_platfrom_apple.mm index dc8dc7dcfc..64a4e19d8f 100644 --- a/native/cocos/bindings/manual/jsb_platfrom_apple.mm +++ b/native/cocos/bindings/manual/jsb_platfrom_apple.mm @@ -97,7 +97,7 @@ static bool JSB_loadFont(se::State &s) { s.rval().setNull(); std::string originalFamilyName; - ok &= seval_to_std_string(args[0], &originalFamilyName); + ok &= sevalue_to_native(args[0], &originalFamilyName); SE_PRECONDITION2(ok, false, "JSB_loadFont : Error processing argument: originalFamilyName"); // Don't reload font again to avoid memory leak. @@ -107,7 +107,7 @@ static bool JSB_loadFont(se::State &s) { } std::string source; - ok &= seval_to_std_string(args[1], &source); + ok &= sevalue_to_native(args[1], &source); SE_PRECONDITION2(ok, false, "JSB_loadFont : Error processing argument: source"); std::string fontFilePath; diff --git a/native/cocos/bindings/manual/jsb_platfrom_win32.cpp b/native/cocos/bindings/manual/jsb_platfrom_win32.cpp index 6bb9106432..8669cf6fdb 100644 --- a/native/cocos/bindings/manual/jsb_platfrom_win32.cpp +++ b/native/cocos/bindings/manual/jsb_platfrom_win32.cpp @@ -41,22 +41,22 @@ const std::unordered_map &getFontFamilyNameMap() { } static bool JSB_loadFont(se::State &s) { - const auto &args = s.args(); - size_t argc = args.size(); - CC_UNUSED bool ok = true; + const auto & args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; if (argc >= 1) { s.rval().setNull(); std::string originalFamilyName; - ok &= seval_to_std_string(args[0], &originalFamilyName); + ok &= sevalue_to_native(args[0], &originalFamilyName); SE_PRECONDITION2(ok, false, "JSB_loadFont : Error processing argument: originalFamilyName"); std::string source; - ok &= seval_to_std_string(args[1], &source); + ok &= sevalue_to_native(args[1], &source); SE_PRECONDITION2(ok, false, "JSB_loadFont : Error processing argument: source"); - std::string fontFilePath; - std::regex re("url\\(\\s*'\\s*(.*?)\\s*'\\s*\\)"); + std::string fontFilePath; + std::regex re("url\\(\\s*'\\s*(.*?)\\s*'\\s*\\)"); std::match_results results; if (std::regex_search(source.cbegin(), source.cend(), results, re)) { fontFilePath = results[1].str(); diff --git a/native/cocos/bindings/manual/jsb_scene_manual.cpp b/native/cocos/bindings/manual/jsb_scene_manual.cpp index dd5817b567..ac5495b7ee 100644 --- a/native/cocos/bindings/manual/jsb_scene_manual.cpp +++ b/native/cocos/bindings/manual/jsb_scene_manual.cpp @@ -25,8 +25,11 @@ #include "jsb_scene_manual.h" #include "bindings/auto/jsb_scene_auto.h" +#include "core/Root.h" +#include "core/event/EventTypesToJS.h" +#include "core/scene-graph/Node.h" +#include "core/scene-graph/NodeEvent.h" #include "scene/Model.h" -#include "scene/Node.h" #ifndef JSB_ALLOC #define JSB_ALLOC(kls, ...) new (std::nothrow) kls(__VA_ARGS__) @@ -36,151 +39,884 @@ #define JSB_FREE(ptr) delete ptr #endif -extern bool register_all_scene_ext_manual(se::Object* obj); //NOLINT +static se::Object *nodeVec3CacheObj{nullptr}; +static se::Object *nodeQuatCacheObj{nullptr}; +static se::Object *nodeMat4CacheObj{nullptr}; +static float * tempFloatArray{nullptr}; -static bool js_scene_Pass_setRootBufferAndBlock(se::State& s) // NOLINT(readability-identifier-naming) +static bool js_root_registerListeners(se::State &s) // NOLINT(readability-identifier-naming) { - auto* cobj = SE_THIS_OBJECT(s); - SE_PRECONDITION2(cobj, false, "js_scene_Pass_setRootBlock : Invalid Native Object"); - const auto& args = s.args(); + auto *cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_root_registerListeners : Invalid Native Object"); + +#define DISPATCH_EVENT_TO_JS_ARGS_0(eventType, jsFuncName) \ + cobj->getEventProcessor()->on(eventType, [](cc::Root *rootObj) { \ + se::AutoHandleScope hs; \ + se::Value rootVal; \ + bool ok = nativevalue_to_se(rootObj, rootVal); \ + SE_PRECONDITION2_VOID(ok, "js_root_registerListeners : Error processing arguments"); \ + if (rootVal.isObject()) { \ + se::ScriptEngine::getInstance()->callFunction(rootVal.toObject(), #jsFuncName, 0, nullptr); \ + } \ + }) + + DISPATCH_EVENT_TO_JS_ARGS_0(cc::EventTypesToJS::ROOT_BATCH2D_INIT, _onBatch2DInit); + DISPATCH_EVENT_TO_JS_ARGS_0(cc::EventTypesToJS::ROOT_BATCH2D_UPDATE, _onBatch2DUpdate); + DISPATCH_EVENT_TO_JS_ARGS_0(cc::EventTypesToJS::ROOT_BATCH2D_UPLOAD_BUFFERS, _onBatch2DUploadBuffers); + DISPATCH_EVENT_TO_JS_ARGS_0(cc::EventTypesToJS::ROOT_BATCH2D_RESET, _onBatch2DReset); + DISPATCH_EVENT_TO_JS_ARGS_0(cc::EventTypesToJS::DIRECTOR_BEFORE_COMMIT, _onDirectorBeforeCommit); + + return true; +} +SE_BIND_FUNC(js_root_registerListeners) // NOLINT(readability-identifier-naming) + +static void registerOnTransformChanged(cc::Node *node, se::Object *jsObject) { + node->on( + cc::NodeEventType::TRANSFORM_CHANGED, + [jsObject](cc::TransformBit transformBit) { + se::AutoHandleScope hs; + se::Value arg0; + nativevalue_to_se(transformBit, arg0); + se::ScriptEngine::getInstance()->callFunction(jsObject, "_onTransformChanged", 1, &arg0); + }); +} + +static void registerOnParentChanged(cc::Node *node, se::Object *jsObject) { + node->on( + cc::NodeEventType::PARENT_CHANGED, + [jsObject](cc::Node *oldParent) { + se::AutoHandleScope hs; + se::Value arg0; + nativevalue_to_se(oldParent, arg0); + se::ScriptEngine::getInstance()->callFunction(jsObject, "_onParentChanged", 1, &arg0); + }); +} + +static void registerOnLayerChanged(cc::Node *node, se::Object *jsObject) { + node->on( + cc::NodeEventType::LAYER_CHANGED, + [jsObject](uint32_t layer) { + se::AutoHandleScope hs; + se::Value arg0; + nativevalue_to_se(layer, arg0); + se::ScriptEngine::getInstance()->callFunction(jsObject, "_onLayerChanged", 1, &arg0); + }); +} + +static void registerOnChildRemoved(cc::Node *node, se::Object *jsObject) { + node->on( + cc::NodeEventType::CHILD_REMOVED, + [jsObject](cc::Node *child) { + se::AutoHandleScope hs; + se::Value arg0; + nativevalue_to_se(child, arg0); + se::ScriptEngine::getInstance()->callFunction(jsObject, "_onChildRemoved", 1, &arg0); + }); +} + +static void registerOnChildAdded(cc::Node *node, se::Object *jsObject) { + node->on( + cc::NodeEventType::CHILD_ADDED, + [jsObject](cc::Node *child) { + se::AutoHandleScope hs; + se::Value arg0; + nativevalue_to_se(child, arg0); + se::ScriptEngine::getInstance()->callFunction(jsObject, "_onChildAdded", 1, &arg0); + }); +} + +static void registerOnSiblingOrderChanged(cc::Node *node, se::Object *jsObject) { + node->on( + cc::NodeEventType::SIBLING_ORDER_CHANGED, + [jsObject]() { + se::AutoHandleScope hs; + se::ScriptEngine::getInstance()->callFunction(jsObject, "_onSiblingOrderChanged", 0, nullptr); + }); +} + +static void registerOnActiveNode(cc::Node *node, se::Object *jsObject) { + cc::CallbackInfoBase::ID skip; + node->on( + cc::EventTypesToJS::NODE_ACTIVE_NODE, + [jsObject](bool shouldActiveNow) { + se::AutoHandleScope hs; + se::Value arg0; + nativevalue_to_se(shouldActiveNow, arg0); + se::ScriptEngine::getInstance()->callFunction(jsObject, "_onActiveNode", 1, &arg0); + }, + skip); +} + +static void registerOnBatchCreated(cc::Node *node, se::Object *jsObject) { + cc::CallbackInfoBase::ID skip; + node->on( + cc::EventTypesToJS::NODE_ON_BATCH_CREATED, + [jsObject](bool dontChildPrefab) { + se::AutoHandleScope hs; + se::Value arg0; + nativevalue_to_se(dontChildPrefab, arg0); + se::ScriptEngine::getInstance()->callFunction(jsObject, "_onBatchCreated", 1, &arg0); + }, + skip); +} + +static void registerOnUiTransformDirty(cc::Node *node, se::Object *jsObject) { + se::Value uiPropsVal; + jsObject->getProperty("_uiProps", &uiPropsVal, true); + SE_PRECONDITION2_VOID(uiPropsVal.isObject(), "Not property named _uiProps."); + se::Value uiTransformDirtyVal; + uiPropsVal.toObject()->getProperty("_uiTransformDirty", &uiTransformDirtyVal, true); + SE_PRECONDITION2_VOID(uiTransformDirtyVal.isObject() && uiTransformDirtyVal.toObject()->isTypedArray() && uiTransformDirtyVal.toObject()->getTypedArrayType() == se::Object::TypedArrayType::UINT32, + "_uiTransformDirtyVal is not a TypedArray"); + uint8_t *pDirty{nullptr}; + size_t dirtyArrBytes{0}; + bool ok = uiTransformDirtyVal.toObject()->getTypedArrayData(&pDirty, &dirtyArrBytes); + CC_ASSERT(ok && pDirty != nullptr && dirtyArrBytes == 4); + node->setUIPropsTransformDirtyPtr(reinterpret_cast(pDirty)); +} + +static void registerActiveInHierarchyArr(cc::Node *node, se::Object *jsObject) { + se::Value activeInHierarchyArrVal; + bool ok = jsObject->getProperty("_activeInHierarchyArr", &activeInHierarchyArrVal); + CC_ASSERT(ok && activeInHierarchyArrVal.isObject() && activeInHierarchyArrVal.toObject()->isTypedArray() && activeInHierarchyArrVal.toObject()->getTypedArrayType() == se::Object::TypedArrayType::UINT8); + + uint8_t *pActiveInHierarchyArrData = nullptr; + ok = activeInHierarchyArrVal.toObject()->getTypedArrayData(&pActiveInHierarchyArrData, nullptr); + CC_ASSERT(ok); + node->setActiveInHierarchyPtr(pActiveInHierarchyArrData); +} + +static void registerLayerArr(cc::Node *node, se::Object *jsObject) { + se::Value layerArrVal; + bool ok = jsObject->getProperty("_layerArr", &layerArrVal); + CC_ASSERT(ok && layerArrVal.isObject() && layerArrVal.toObject()->isTypedArray() && layerArrVal.toObject()->getTypedArrayType() == se::Object::TypedArrayType::UINT32); + + uint8_t *pLayerArrValData = nullptr; + ok = layerArrVal.toObject()->getTypedArrayData(&pLayerArrValData, nullptr); + CC_ASSERT(ok); + node->setLayerPtr(reinterpret_cast(pLayerArrValData)); +} + +static void registerLocalPositionRotationScaleUpdated(cc::Node *node, se::Object *jsObject) { + node->on(cc::EventTypesToJS::NODE_LOCAL_POSITION_UPDATED, [jsObject](float x, float y, float z) { + se::AutoHandleScope hs; + std::array args; + nativevalue_to_se(x, args[0]); + nativevalue_to_se(y, args[1]); + nativevalue_to_se(z, args[2]); + se::ScriptEngine::getInstance()->callFunction(jsObject, "_onLocalPositionUpdated", static_cast(args.size()), args.data()); + }); + + node->on(cc::EventTypesToJS::NODE_LOCAL_ROTATION_UPDATED, [jsObject](float x, float y, float z, float w) { + se::AutoHandleScope hs; + std::array args; + nativevalue_to_se(x, args[0]); + nativevalue_to_se(y, args[1]); + nativevalue_to_se(z, args[2]); + nativevalue_to_se(w, args[3]); + se::ScriptEngine::getInstance()->callFunction(jsObject, "_onLocalRotationUpdated", static_cast(args.size()), args.data()); + }); + + node->on(cc::EventTypesToJS::NODE_LOCAL_SCALE_UPDATED, [jsObject](float x, float y, float z) { + se::AutoHandleScope hs; + std::array args; + nativevalue_to_se(x, args[0]); + nativevalue_to_se(y, args[1]); + nativevalue_to_se(z, args[2]); + se::ScriptEngine::getInstance()->callFunction(jsObject, "_onLocalScaleUpdated", static_cast(args.size()), args.data()); + }); + + node->on(cc::EventTypesToJS::NODE_LOCAL_POSITION_ROTATION_SCALE_UPDATED, [jsObject](float px, float py, float pz, float rx, float ry, float rz, float rw, float sx, float sy, float sz) { + se::AutoHandleScope hs; + std::array args; + nativevalue_to_se(px, args[0]); + nativevalue_to_se(py, args[1]); + nativevalue_to_se(pz, args[2]); + + nativevalue_to_se(rx, args[3]); + nativevalue_to_se(ry, args[4]); + nativevalue_to_se(rz, args[5]); + nativevalue_to_se(rw, args[6]); + + nativevalue_to_se(sx, args[7]); + nativevalue_to_se(sy, args[8]); + nativevalue_to_se(sz, args[9]); + + se::ScriptEngine::getInstance()->callFunction(jsObject, "_onLocalPositionRotationScaleUpdated", static_cast(args.size()), args.data()); + }); +} + +static bool js_scene_Node_registerListeners(se::State &s) // NOLINT(readability-identifier-naming) +{ + auto *cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_scene_Node_registerListeners : Invalid Native Object"); + + auto *jsObject = s.thisObject(); + registerActiveInHierarchyArr(cobj, jsObject); + registerLayerArr(cobj, jsObject); + +#define NODE_DISPATCH_EVENT_TO_JS(eventType, jsFuncName) \ + cobj->on( \ + eventType, [jsObject]() { \ + se::AutoHandleScope hs; \ + se::ScriptEngine::getInstance()->callFunction(jsObject, #jsFuncName, 0, nullptr); \ + }); + + registerOnActiveNode(cobj, jsObject); + registerOnBatchCreated(cobj, jsObject); + + NODE_DISPATCH_EVENT_TO_JS(cc::EventTypesToJS::NODE_REATTACH, _onReAttach); + NODE_DISPATCH_EVENT_TO_JS(cc::EventTypesToJS::NODE_REMOVE_PERSIST_ROOT_NODE, _onRemovePersistRootNode); + NODE_DISPATCH_EVENT_TO_JS(cc::EventTypesToJS::NODE_DESTROY_COMPONENTS, _onDestroyComponents); + // NODE_DISPATCH_EVENT_TO_JS(cc::EventTypesToJS::NODE_UI_TRANSFORM_DIRTY, _onUiTransformDirty); + // NODE_DISPATCH_EVENT_TO_JS(cc::NodeEventType::SIBLING_ORDER_CHANGED, _onSiblingOrderChanged); + registerOnUiTransformDirty(cobj, jsObject); + + cobj->on( + cc::NodeEventType::NODE_DESTROYED, + [](cc::Node *node) { + se::AutoHandleScope hs; + se::Value nodeVal; + nativevalue_to_se(node, nodeVal); + se::ScriptEngine::getInstance()->callFunction(nodeVal.toObject(), "_onNodeDestroyed", 1, &nodeVal); + }); + + cobj->onSiblingIndexChanged = [jsObject](index_t newIndex) { + se::AutoHandleScope hs; + se::Value arg0; + nativevalue_to_se(newIndex, arg0); + se::ScriptEngine::getInstance()->callFunction(jsObject, "_onSiblingIndexChanged", 1, &arg0); + }; + + cobj->on(cc::EventTypesToJS::NODE_SCENE_UPDATED, [jsObject](cc::Scene *scene) { + se::AutoHandleScope hs; + se::Value arg0; + nativevalue_to_se(scene, arg0); + se::ScriptEngine::getInstance()->callFunction(jsObject, "_onSceneUpdated", 1, &arg0); + }); + + registerLocalPositionRotationScaleUpdated(cobj, jsObject); + + return true; +} +SE_BIND_FUNC(js_scene_Node_registerListeners) // NOLINT(readability-identifier-naming) + +static bool js_scene_Node_registerOnTransformChanged(se::State &s) // NOLINT(readability-identifier-naming) +{ + auto *cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_scene_Node_registerOnTransformChanged : Invalid Native Object"); + + auto *jsObject = s.thisObject(); + + registerOnTransformChanged(cobj, jsObject); + return true; +} +SE_BIND_FUNC(js_scene_Node_registerOnTransformChanged) // NOLINT(readability-identifier-naming) + +static bool js_scene_Node_registerOnParentChanged(se::State &s) // NOLINT(readability-identifier-naming) +{ + auto *cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_scene_Node_registerOnParentChanged : Invalid Native Object"); + + auto *jsObject = s.thisObject(); + + registerOnParentChanged(cobj, jsObject); + return true; +} +SE_BIND_FUNC(js_scene_Node_registerOnParentChanged) // NOLINT(readability-identifier-naming) + +static bool js_scene_Node_registerOnLayerChanged(se::State &s) // NOLINT(readability-identifier-naming) +{ + auto *cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_scene_Node_registerOnLayerChanged : Invalid Native Object"); + + auto *jsObject = s.thisObject(); + + registerOnLayerChanged(cobj, jsObject); + return true; +} +SE_BIND_FUNC(js_scene_Node_registerOnLayerChanged) // NOLINT(readability-identifier-naming) + +static bool js_scene_Node_registerOnChildRemoved(se::State &s) // NOLINT(readability-identifier-naming) +{ + auto *cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_scene_Node_registerOnChildRemoved : Invalid Native Object"); + + auto *jsObject = s.thisObject(); + + registerOnChildRemoved(cobj, jsObject); + return true; +} +SE_BIND_FUNC(js_scene_Node_registerOnChildRemoved) // NOLINT(readability-identifier-naming) + +static bool js_scene_Node_registerOnChildAdded(se::State &s) // NOLINT(readability-identifier-naming) +{ + auto *cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_scene_Node_registerOnChildAdded : Invalid Native Object"); + + auto *jsObject = s.thisObject(); + + registerOnChildAdded(cobj, jsObject); + return true; +} +SE_BIND_FUNC(js_scene_Node_registerOnChildAdded) // NOLINT(readability-identifier-naming) + +static bool js_scene_Node_registerOnSiblingOrderChanged(se::State &s) // NOLINT(readability-identifier-naming) +{ + auto *cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_scene_Node_registerOnSiblingOrderChanged : Invalid Native Object"); + + auto *jsObject = s.thisObject(); + registerOnSiblingOrderChanged(cobj, jsObject); + return true; +} +SE_BIND_FUNC(js_scene_Node_registerOnSiblingOrderChanged) // NOLINT(readability-identifier-naming) + +static bool scene_Vec3_to_seval(const cc::Vec3 &v, se::Value *ret) { // NOLINT(readability-identifier-naming) + assert(ret != nullptr); + if (!nodeVec3CacheObj) { + nodeVec3CacheObj = se::Object::createPlainObject(); + nodeVec3CacheObj->root(); + } + se::Object *obj(nodeVec3CacheObj); + obj->setProperty("x", se::Value(v.x)); + obj->setProperty("y", se::Value(v.y)); + obj->setProperty("z", se::Value(v.z)); + ret->setObject(obj); + + return true; +} + +static bool scene_Quaternion_to_seval(const cc::Quaternion &v, se::Value *ret) { // NOLINT(readability-identifier-naming) + assert(ret != nullptr); + if (!nodeQuatCacheObj) { + nodeQuatCacheObj = se::Object::createPlainObject(); + nodeQuatCacheObj->root(); + } + se::Object *obj(nodeQuatCacheObj); + obj->setProperty("x", se::Value(v.x)); + obj->setProperty("y", se::Value(v.y)); + obj->setProperty("z", se::Value(v.z)); + obj->setProperty("w", se::Value(v.w)); + ret->setObject(obj); + + return true; +} + +static bool scene_Mat4_to_seval(const cc::Mat4 &v, se::Value *ret) { // NOLINT(readability-identifier-naming) + assert(ret != nullptr); + if (!nodeMat4CacheObj) { + nodeMat4CacheObj = se::Object::createPlainObject(); + nodeMat4CacheObj->root(); + } + se::Object *obj(nodeMat4CacheObj); + + char keybuf[8] = {0}; + for (auto i = 0; i < 16; i++) { + snprintf(keybuf, sizeof(keybuf), "m%02d", i); + obj->setProperty(keybuf, se::Value(v.m[i])); + } + ret->setObject(obj); + + return true; +} + +static bool js_scene_Camera_screenPointToRay(void *nativeObject) // NOLINT(readability-identifier-naming) +{ + auto * cobj = reinterpret_cast(nativeObject); + cc::geometry::Ray ray = cobj->screenPointToRay(tempFloatArray[0], tempFloatArray[1]); + tempFloatArray[0] = ray.o.x; + tempFloatArray[1] = ray.o.y; + tempFloatArray[2] = ray.o.z; + tempFloatArray[3] = ray.d.x; + tempFloatArray[4] = ray.d.y; + tempFloatArray[5] = ray.d.z; + return true; +} +SE_BIND_FUNC_FAST(js_scene_Camera_screenPointToRay) + +static bool js_scene_Camera_screenToWorld(void *nativeObject) // NOLINT(readability-identifier-naming) +{ + auto * cobj = reinterpret_cast(nativeObject); + cc::Vec3 ret = cobj->screenToWorld(cc::Vec3{tempFloatArray[0], tempFloatArray[1], tempFloatArray[2]}); + tempFloatArray[0] = ret.x; + tempFloatArray[1] = ret.y; + tempFloatArray[2] = ret.z; + return true; +} +SE_BIND_FUNC_FAST(js_scene_Camera_screenToWorld) + +static bool js_scene_Camera_worldToScreen(void *nativeObject) // NOLINT(readability-identifier-naming) +{ + auto * cobj = reinterpret_cast(nativeObject); + cc::Vec3 ret = cobj->worldToScreen(cc::Vec3{tempFloatArray[0], tempFloatArray[1], tempFloatArray[2]}); + tempFloatArray[0] = ret.x; + tempFloatArray[1] = ret.y; + tempFloatArray[2] = ret.z; + return true; +} +SE_BIND_FUNC_FAST(js_scene_Camera_worldToScreen) + +static bool js_scene_Camera_worldMatrixToScreen(void *nativeObject) // NOLINT(readability-identifier-naming) +{ + auto *cobj = reinterpret_cast(nativeObject); + + cc::Mat4 worldMatrix; + memcpy(worldMatrix.m, tempFloatArray, sizeof(float) * 16); + cc::Mat4 ret = cobj->worldMatrixToScreen(worldMatrix, static_cast(tempFloatArray[16]), static_cast(tempFloatArray[17])); + memcpy(tempFloatArray, ret.m, sizeof(float) * 16); + return true; +} +SE_BIND_FUNC_FAST(js_scene_Camera_worldMatrixToScreen) + +static bool js_scene_Node_getPosition(void *nativeObj) // NOLINT(readability-identifier-naming) +{ + auto * cobj = reinterpret_cast(nativeObj); + const cc::Vec3 &result = cobj->getPosition(); + tempFloatArray[0] = result.x; + tempFloatArray[1] = result.y; + tempFloatArray[2] = result.z; + return true; +} +SE_BIND_FUNC_FAST(js_scene_Node_getPosition) + +static bool js_scene_Node_setTempFloatArray(se::State &s) // NOLINT(readability-identifier-naming) +{ + const auto & args = s.args(); size_t argc = args.size(); CC_UNUSED bool ok = true; + if (argc == 1) { + uint8_t *buffer = nullptr; + args[0].toObject()->getArrayBufferData(&buffer, nullptr); + tempFloatArray = reinterpret_cast(buffer); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 1); + return false; +} +SE_BIND_FUNC(js_scene_Node_setTempFloatArray) + +static bool js_scene_Node_getRight(se::State &s) // NOLINT(readability-identifier-naming) +{ + auto *cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_scene_Node_getRight : Invalid Native Object"); + const auto & args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 0) { + cc::Vec3 result = cobj->getRight(); + ok &= scene_Vec3_to_seval(result, &s.rval()); + SE_PRECONDITION2(ok, false, "js_scene_Node_getRight : Error processing arguments"); + SE_HOLD_RETURN_VALUE(result, s.thisObject(), s.rval()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 0); + return false; +} +SE_BIND_FUNC(js_scene_Node_getRight) + +static bool js_scene_Node_getRotation(se::State &s) // NOLINT(readability-identifier-naming) +{ + auto *cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_scene_Node_getRotation : Invalid Native Object"); + const auto & args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 0) { + const cc::Quaternion &result = cobj->getRotation(); + ok &= scene_Quaternion_to_seval(result, &s.rval()); + SE_PRECONDITION2(ok, false, "js_scene_Node_getRotation : Error processing arguments"); + SE_HOLD_RETURN_VALUE(result, s.thisObject(), s.rval()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 0); + return false; +} +SE_BIND_FUNC(js_scene_Node_getRotation) + +static bool js_scene_Node_getScale(se::State &s) // NOLINT(readability-identifier-naming) +{ + auto *cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_scene_Node_getScale : Invalid Native Object"); + const auto & args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 0) { + const cc::Vec3 &result = cobj->getScale(); + ok &= scene_Vec3_to_seval(result, &s.rval()); + SE_PRECONDITION2(ok, false, "js_scene_Node_getScale : Error processing arguments"); + SE_HOLD_RETURN_VALUE(result, s.thisObject(), s.rval()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 0); + return false; +} +SE_BIND_FUNC(js_scene_Node_getScale) + +static bool js_scene_Node_setPosition(void *s) // NOLINT(readability-identifier-naming) +{ + auto *cobj = reinterpret_cast(s); + auto argc = static_cast(tempFloatArray[0]); if (argc == 2) { - HolderType arg0 = {}; - uint8_t* rootBlock{nullptr}; - ok &= sevalue_to_native(args[0], &arg0, s.thisObject()); - args[1].toObject()->getArrayBufferData(&rootBlock, nullptr); - cobj->setRootBufferAndBlock(arg0.value(), rootBlock); - return true; - } - SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 1); - return false; -} -SE_BIND_FUNC(js_scene_Pass_setRootBufferAndBlock) // NOLINT(readability-identifier-naming) + cobj->setPositionInternal(tempFloatArray[1], tempFloatArray[2], true); -static bool js_scene_RenderScene_updateBatches(se::State& s) // NOLINT(readability-identifier-naming) + } else { + cobj->setPositionInternal(tempFloatArray[1], tempFloatArray[2], tempFloatArray[3], true); + } + return true; +} +SE_BIND_FUNC_FAST(js_scene_Node_setPosition) + +static bool js_scene_Node_setRotation(void *s) // NOLINT(readability-identifier-naming) { - auto* cobj = SE_THIS_OBJECT(s); - SE_PRECONDITION2(cobj, false, "js_scene_RenderScene_updateBatches : Invalid Native Object"); - const auto& args = s.args(); + auto *cobj = reinterpret_cast(s); + cobj->setRotationInternal(tempFloatArray[0], tempFloatArray[1], tempFloatArray[2], tempFloatArray[3], true); + return true; +} +SE_BIND_FUNC_FAST(js_scene_Node_setRotation) + +static bool js_scene_Node_setRotationFromEuler(void *s) // NOLINT(readability-identifier-naming) +{ + auto *cobj = reinterpret_cast(s); + cobj->setRotationFromEuler(tempFloatArray[0], tempFloatArray[1], tempFloatArray[2]); + return true; +} +SE_BIND_FUNC_FAST(js_scene_Node_setRotationFromEuler) + +static bool js_scene_Node_setScale(void *s) // NOLINT(readability-identifier-naming) +{ + auto *cobj = reinterpret_cast(s); + auto argc = static_cast(tempFloatArray[0]); + if (argc == 2) { + cobj->setScaleInternal(tempFloatArray[1], tempFloatArray[2], true); + + } else { + cobj->setScaleInternal(tempFloatArray[1], tempFloatArray[2], tempFloatArray[3], true); + } + return true; +} +SE_BIND_FUNC_FAST(js_scene_Node_setScale) + +static bool js_scene_Node_setRTS(void *s) // NOLINT(readability-identifier-naming) +{ + auto * cobj = reinterpret_cast(s); + cc::Quaternion qt; + auto rotSize = static_cast(tempFloatArray[0]); + if (rotSize > 0) { + qt.set(tempFloatArray[1], tempFloatArray[2], tempFloatArray[3], tempFloatArray[4]); + } + + auto posSize = static_cast(tempFloatArray[5]); + cc::Vec3 pos; + if (posSize > 0) { + pos.set(tempFloatArray[6], tempFloatArray[7], tempFloatArray[8]); + } + + auto scaleSize = static_cast(tempFloatArray[9]); + cc::Vec3 scale; + if (scaleSize > 0) { + scale.set(tempFloatArray[10], tempFloatArray[11], tempFloatArray[12]); + } + cobj->setRTSInternal(rotSize > 0 ? &qt : nullptr, posSize > 0 ? &pos : nullptr, scaleSize > 0 ? &scale : nullptr, true); + return true; +} +SE_BIND_FUNC_FAST(js_scene_Node_setRTS) + +static bool js_scene_Node_rotateForJS(void *s) // NOLINT(readability-identifier-naming) +{ + auto *cobj = reinterpret_cast(s); + auto argc = static_cast(tempFloatArray[0]); + if (argc == 4) { + cobj->rotateForJS(tempFloatArray[1], tempFloatArray[2], tempFloatArray[3], tempFloatArray[4]); + } else { + auto size = static_cast(tempFloatArray[5]); + cobj->rotateForJS(tempFloatArray[1], tempFloatArray[2], tempFloatArray[3], tempFloatArray[4], size == 0 ? cc::NodeSpace::LOCAL : static_cast(static_cast(std::roundf(tempFloatArray[5])))); + } + + const auto &lrot = cobj->getRotation(); + tempFloatArray[0] = lrot.x; + tempFloatArray[1] = lrot.y; + tempFloatArray[2] = lrot.z; + tempFloatArray[3] = lrot.w; + return true; +} +SE_BIND_FUNC_FAST(js_scene_Node_rotateForJS) + +static bool js_scene_Node_getUp(se::State &s) // NOLINT(readability-identifier-naming) +{ + auto *cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_scene_Node_getUp : Invalid Native Object"); + const auto & args = s.args(); size_t argc = args.size(); CC_UNUSED bool ok = true; - if (argc == 1) { - HolderType, false> arg0 = {}; - ok &= sevalue_to_native(args[0], &arg0, s.thisObject()); - SE_PRECONDITION2(ok, false, "js_scene_RenderScene_updateBatches : Error processing arguments"); - cobj->updateBatches(std::move(arg0.value())); + if (argc == 0) { + cc::Vec3 result = cobj->getUp(); + ok &= scene_Vec3_to_seval(result, &s.rval()); + SE_PRECONDITION2(ok, false, "js_scene_Node_getUp : Error processing arguments"); + SE_HOLD_RETURN_VALUE(result, s.thisObject(), s.rval()); return true; } - SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 1); + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 0); return false; } -SE_BIND_FUNC(js_scene_RenderScene_updateBatches) // NOLINT(readability-identifier-naming) +SE_BIND_FUNC(js_scene_Node_getUp) -static bool js_scene_Model_setInstancedAttrBlock(se::State& s) // NOLINT(readability-identifier-naming) +static bool js_scene_Node_getWorldMatrix(void *nativeObject) // NOLINT(readability-identifier-naming) { - auto* cobj = static_cast(s.nativeThisObject()); - SE_PRECONDITION2(cobj, false, "js_scene_Model_setInstancedAttrBlock : Invalid Native Object"); - const auto& args = s.args(); - size_t argc = args.size(); + auto * cobj = reinterpret_cast(nativeObject); + const cc::Mat4 &result = cobj->getWorldMatrix(); + memcpy(tempFloatArray, result.m, sizeof(result.m)); + return true; +} +SE_BIND_FUNC_FAST(js_scene_Node_getWorldMatrix) - if (argc == 3) { - SE_PRECONDITION2(args[0].isObject() && args[0].toObject()->isArrayBuffer(), false, "js_gfx_Device_createBuffer: expected Array Buffer!"); +static bool js_scene_Node_getWorldPosition(se::State &s) // NOLINT(readability-identifier-naming) +{ + auto *cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_scene_Node_getWorldPosition : Invalid Native Object"); + const auto & args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 0) { + const cc::Vec3 &result = cobj->getWorldPosition(); + ok &= scene_Vec3_to_seval(result, &s.rval()); + SE_PRECONDITION2(ok, false, "js_scene_Node_getWorldPosition : Error processing arguments"); + SE_HOLD_RETURN_VALUE(result, s.thisObject(), s.rval()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 0); + return false; +} +SE_BIND_FUNC(js_scene_Node_getWorldPosition) - // instanced buffer - uint8_t* instanceBuff{nullptr}; - size_t instanceBufferSize; - args[0].toObject()->getArrayBufferData(&instanceBuff, &instanceBufferSize); +static bool js_scene_Node_getWorldRS(se::State &s) // NOLINT(readability-identifier-naming) +{ + auto *cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_scene_Node_getWorldRS : Invalid Native Object"); + const auto & args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 0) { + cc::Mat4 result = cobj->getWorldRS(); + ok &= scene_Mat4_to_seval(result, &s.rval()); + SE_PRECONDITION2(ok, false, "js_scene_Node_getWorldRS : Error processing arguments"); + SE_HOLD_RETURN_VALUE(result, s.thisObject(), s.rval()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 0); + return false; +} +SE_BIND_FUNC(js_scene_Node_getWorldRS) - // views - se::Object* dataObj = args[1].toObject(); - if (!dataObj->isArray()) { - return false; - } - std::vector viewsData; - uint32_t length = 0; - dataObj->getArrayLength(&length); - viewsData.resize(length); - se::Value value; - for (uint32_t i = 0; i < length; i++) { - dataObj->getArrayElement(i, &value); - uint8_t* viewBuff{nullptr}; - value.toObject()->getTypedArrayData(&viewBuff, nullptr); - viewsData[i] = viewBuff; - } +static bool js_scene_Node_getWorldRT(se::State &s) // NOLINT(readability-identifier-naming) +{ + auto *cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_scene_Node_getWorldRT : Invalid Native Object"); + const auto & args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 0) { + cc::Mat4 result = cobj->getWorldRT(); + ok &= scene_Mat4_to_seval(result, &s.rval()); + SE_PRECONDITION2(ok, false, "js_scene_Node_getWorldRT : Error processing arguments"); + SE_HOLD_RETURN_VALUE(result, s.thisObject(), s.rval()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 0); + return false; +} +SE_BIND_FUNC(js_scene_Node_getWorldRT) - cc::scene::InstancedAttributeBlock attrBlock; - attrBlock.views = std::move(viewsData); +static bool js_scene_Node_getWorldRotation(se::State &s) // NOLINT(readability-identifier-naming) +{ + auto *cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_scene_Node_getWorldRotation : Invalid Native Object"); + const auto & args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 0) { + const cc::Quaternion &result = cobj->getWorldRotation(); + ok &= scene_Quaternion_to_seval(result, &s.rval()); + SE_PRECONDITION2(ok, false, "js_scene_Node_getWorldRotation : Error processing arguments"); + SE_HOLD_RETURN_VALUE(result, s.thisObject(), s.rval()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 0); + return false; +} +SE_BIND_FUNC(js_scene_Node_getWorldRotation) - // attrs - CC_UNUSED bool ok = true; - HolderType, true> arg2 = {}; - ok &= sevalue_to_native(args[2], &arg2, s.thisObject()); - SE_PRECONDITION2(ok, false, "js_scene_Model_setInstancedAttrBlock : Error processing arguments"); - cobj->setInstancedAttrBlock(instanceBuff, static_cast(instanceBufferSize), std::move(attrBlock), arg2.value()); +static bool js_scene_Node_getWorldScale(se::State &s) // NOLINT(readability-identifier-naming) +{ + auto *cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_scene_Node_getWorldScale : Invalid Native Object"); + const auto & args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 0) { + const cc::Vec3 &result = cobj->getWorldScale(); + ok &= scene_Vec3_to_seval(result, &s.rval()); + SE_PRECONDITION2(ok, false, "js_scene_Node_getWorldScale : Error processing arguments"); + SE_HOLD_RETURN_VALUE(result, s.thisObject(), s.rval()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 0); + return false; +} +SE_BIND_FUNC(js_scene_Node_getWorldScale) +static bool js_scene_Node_getEulerAngles(se::State &s) // NOLINT(readability-identifier-naming) +{ + auto *cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_scene_Node_getEulerAngles : Invalid Native Object"); + const auto & args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 0) { + const cc::Vec3 &result = cobj->getEulerAngles(); + ok &= scene_Vec3_to_seval(result, &s.rval()); + SE_PRECONDITION2(ok, false, "js_scene_Node_getEulerAngles : Error processing arguments"); + SE_HOLD_RETURN_VALUE(result, s.thisObject(), s.rval()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 0); + return false; +} +SE_BIND_FUNC(js_scene_Node_getEulerAngles) + +static bool js_scene_Node_getForward(se::State &s) // NOLINT(readability-identifier-naming) +{ + auto *cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_scene_Node_getForward : Invalid Native Object"); + const auto & args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 0) { + cc::Vec3 result = cobj->getForward(); + ok &= scene_Vec3_to_seval(result, &s.rval()); + SE_PRECONDITION2(ok, false, "js_scene_Node_getForward : Error processing arguments"); + SE_HOLD_RETURN_VALUE(result, s.thisObject(), s.rval()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 0); + return false; +} +SE_BIND_FUNC(js_scene_Node_getForward) + +static bool js_scene_Pass_blocks_getter(se::State &s) { // NOLINT(readability-identifier-naming) + auto *cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_scene_Node_registerListeners : Invalid Native Object"); + auto *thiz = s.thisObject(); + + se::Value blocksVal; + if (thiz->getProperty("_blocks", &blocksVal, true) && blocksVal.isObject() && blocksVal.toObject()->isArray()) { + s.rval() = blocksVal; return true; } - SE_REPORT_ERROR("wrong number of arguments: %d", (int)argc); - return false; -} -SE_BIND_FUNC(js_scene_Model_setInstancedAttrBlock) // NOLINT(readability-identifier-naming) + const auto & blocks = cobj->getBlocks(); + const uint8_t *blockDataBase = cobj->getRootBlock()->getData(); -static bool js_scene_SubModel_setSubMeshBuffers(se::State& s) // NOLINT(readability-identifier-naming) -{ - auto* cobj = static_cast(s.nativeThisObject()); - SE_PRECONDITION2(cobj, false, "js_scene_SubModel_setSubMeshBuffers : Invalid Native Object"); - const auto& args = s.args(); - size_t argc = args.size(); - - if (argc == 1) { - if (args[0].isObject()) { - se::Object* dataObj = args[0].toObject(); - if (!dataObj->isArray()) { - return false; - } - uint32_t length = 0; - dataObj->getArrayLength(&length); - std::vector flatBuffers; - flatBuffers.resize(length); - se::Value value; - for (uint32_t i = 0; i < length; ++i) { - if (dataObj->getArrayElement(i, &value)) { - if (value.isObject()) { - cc::scene::FlatBuffer currBuffer; - se::Value bufferVal; - se::Object* valObj = value.toObject(); - valObj->getProperty("buffer", &bufferVal); - // data - CC_UNUSED size_t bufferLength = 0; - uint8_t* address = nullptr; - bufferVal.toObject()->getTypedArrayData(&address, &bufferLength); - currBuffer.data = address; - currBuffer.size = bufferLength; - // stride - se::Value strideVal; - valObj->getProperty("stride", &strideVal); - currBuffer.stride = strideVal.toUint32(); - // count - se::Value countVal; - valObj->getProperty("count", &countVal); - currBuffer.count = countVal.toUint32(); - flatBuffers[i] = currBuffer; - } - } - } - cobj->setSubMeshBuffers(flatBuffers); - return true; - } + se::HandleObject jsBlocks{se::Object::createArrayObject(blocks.size())}; + int32_t i = 0; + for (const auto &block : blocks) { + se::HandleObject jsBlock{ + se::Object::createTypedArrayWithBuffer( + se::Object::TypedArrayType::FLOAT32, + cobj->getRootBlock()->getJSArrayBuffer(), + reinterpret_cast(block.data) - blockDataBase, + block.count * 4)}; + jsBlocks->setArrayElement(i, se::Value(jsBlock)); + ++i; } - - SE_REPORT_ERROR("wrong number of arguments: %d", (int)argc); - return false; + thiz->setProperty("_blocks", se::Value(jsBlocks)); + s.rval().setObject(jsBlocks); + return true; } -SE_BIND_FUNC(js_scene_SubModel_setSubMeshBuffers) // NOLINT(readability-identifier-naming) +SE_BIND_PROP_GET(js_scene_Pass_blocks_getter) -bool register_all_scene_manual(se::Object* obj) // NOLINT(readability-identifier-naming) +static bool js_scene_RenderScene_root_getter(se::State &s) { // NOLINT(readability-identifier-naming) + nativevalue_to_se(cc::Root::getInstance(), s.rval()); + return true; +} +SE_BIND_PROP_GET(js_scene_RenderScene_root_getter) + +static bool js_Model_registerListeners(se::State &s) // NOLINT(readability-identifier-naming) +{ + auto *cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_Model_registerListeners : Invalid Native Object"); + auto *thiz = s.thisObject(); + +#define MODEL_DISPATCH_EVENT_TO_JS(eventType, jsFuncName) \ + cobj->getEventProcessor().on(eventType, [=](uint32_t stamp) { \ + cobj->setCalledFromJS(true); \ + se::AutoHandleScope hs; \ + se::Value stampVal{stamp}; \ + se::ScriptEngine::getInstance()->callFunction(thiz, #jsFuncName, 1, &stampVal); \ + }) + + MODEL_DISPATCH_EVENT_TO_JS(cc::EventTypesToJS::MODEL_UPDATE_TRANSFORM, updateTransform); + MODEL_DISPATCH_EVENT_TO_JS(cc::EventTypesToJS::MODEL_UPDATE_UBO, updateUBOs); + +#undef MODEL_DISPATCH_EVENT_TO_JS + + cobj->getEventProcessor().on(cc::EventTypesToJS::MODEL_UPDATE_LOCAL_DESCRIPTORS, [=](index_t subModelIndex, cc::gfx::DescriptorSet *descriptorSet) { + cobj->setCalledFromJS(true); + se::AutoHandleScope hs; + + std::array args; + nativevalue_to_se(subModelIndex, args[0]); + nativevalue_to_se(descriptorSet, args[1]); + se::ScriptEngine::getInstance()->callFunction(thiz, "_updateLocalDescriptors", static_cast(args.size()), args.data()); + }); + + cobj->getEventProcessor().on(cc::EventTypesToJS::MODEL_UPDATE_INSTANCED_ATTRIBUTES, [=](const std::vector &attributes, cc::scene::Pass *pass) { + cobj->setCalledFromJS(true); + se::AutoHandleScope hs; + + std::array args; + nativevalue_to_se(attributes, args[0]); + nativevalue_to_se(pass, args[1]); + se::ScriptEngine::getInstance()->callFunction(thiz, "_updateInstancedAttributes", static_cast(args.size()), args.data()); + }); + + cobj->getEventProcessor().on(cc::EventTypesToJS::MODEL_GET_MACRO_PATCHES, [=](index_t subModelIndex, std::vector *pPatches) { + cobj->setCalledFromJS(true); + se::AutoHandleScope hs; + + se::Value rval; + std::array args; + nativevalue_to_se(subModelIndex, args[0]); + bool ok = se::ScriptEngine::getInstance()->callFunction(thiz, "getMacroPatches", static_cast(args.size()), args.data(), &rval); + + if (ok) { + sevalue_to_native(rval, pPatches); + } + }); + + return true; +} +SE_BIND_FUNC(js_Model_registerListeners) // NOLINT(readability-identifier-naming) + +static bool js_assets_MaterialInstance_registerListeners(se::State &s) // NOLINT(readability-identifier-naming) +{ + auto *cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "js_assets_MaterialInstance_registerListeners : Invalid Native Object"); + cobj->setRebuildPSOCallback([](index_t /*index*/, cc::Material *material) { + se::AutoHandleScope hs; + se::Value matVal; + bool ok = nativevalue_to_se(material, matVal); + if (!ok) { + return; + } + se::ScriptEngine::getInstance()->callFunction(matVal.toObject(), "_onRebuildPSO", 0, nullptr); + }); + + return true; +} +SE_BIND_FUNC(js_assets_MaterialInstance_registerListeners) // NOLINT(readability-identifier-naming) + +bool register_all_scene_manual(se::Object *obj) // NOLINT(readability-identifier-naming) { // Get the ns se::Value nsVal; @@ -189,15 +925,72 @@ bool register_all_scene_manual(se::Object* obj) // NOLINT(readability-identifier nsVal.setObject(jsobj); obj->setProperty("ns", nsVal); } + se::ScriptEngine::getInstance()->addBeforeCleanupHook([]() { - __jsb_cc_scene_Model_proto->defineFunction("setInstancedAttrBlock", _SE(js_scene_Model_setInstancedAttrBlock)); +// NOLINTNEXTLINE(readability-identifier-naming, bugprone-reserved-identifier) +#define _SAFE_UNROOT_AND_DEC(obj) \ + if ((obj) != nullptr) { \ + (obj)->unroot(); \ + (obj)->decRef(); \ + (obj) = nullptr; \ + } + _SAFE_UNROOT_AND_DEC(nodeVec3CacheObj); + _SAFE_UNROOT_AND_DEC(nodeQuatCacheObj); + _SAFE_UNROOT_AND_DEC(nodeMat4CacheObj); - __jsb_cc_scene_SubModel_proto->defineFunction("setSubMeshBuffers", _SE(js_scene_SubModel_setSubMeshBuffers)); - __jsb_cc_scene_Pass_proto->defineFunction("setRootBufferAndBlock", _SE(js_scene_Pass_setRootBufferAndBlock)); - __jsb_cc_scene_RenderScene_proto->defineFunction("updateBatches", _SE(js_scene_RenderScene_updateBatches)); +#undef _SAFE_UNROOT_AND_DEC + }); - // Impl MQ for DrawBatch2D - register_all_scene_ext_manual(obj); + __jsb_cc_Root_proto->defineFunction("_registerListeners", _SE(js_root_registerListeners)); + + __jsb_cc_scene_Camera_proto->defineFunction("screenPointToRay", _SE(js_scene_Camera_screenPointToRay)); + __jsb_cc_scene_Camera_proto->defineFunction("screenToWorld", _SE(js_scene_Camera_screenToWorld)); + __jsb_cc_scene_Camera_proto->defineFunction("worldToScreen", _SE(js_scene_Camera_worldToScreen)); + __jsb_cc_scene_Camera_proto->defineFunction("worldMatrixToScreen", _SE(js_scene_Camera_worldMatrixToScreen)); + + // Node TS wrapper will invoke this function to let native object listen some events. + __jsb_cc_Node_proto->defineFunction("_registerListeners", _SE(js_scene_Node_registerListeners)); + + __jsb_cc_Node_proto->defineFunction("_registerOnTransformChanged", _SE(js_scene_Node_registerOnTransformChanged)); + __jsb_cc_Node_proto->defineFunction("_registerOnParentChanged", _SE(js_scene_Node_registerOnParentChanged)); + __jsb_cc_Node_proto->defineFunction("_registerOnLayerChanged", _SE(js_scene_Node_registerOnLayerChanged)); + __jsb_cc_Node_proto->defineFunction("_registerOnChildRemoved", _SE(js_scene_Node_registerOnChildRemoved)); + __jsb_cc_Node_proto->defineFunction("_registerOnChildAdded", _SE(js_scene_Node_registerOnChildAdded)); + __jsb_cc_Node_proto->defineFunction("_registerOnSiblingOrderChanged", _SE(js_scene_Node_registerOnSiblingOrderChanged)); + + se::Value jsbVal; + obj->getProperty("jsb", &jsbVal); + se::Value nodeVal; + jsbVal.toObject()->getProperty("Node", &nodeVal); + + nodeVal.toObject()->defineFunction("_setTempFloatArray", _SE(js_scene_Node_setTempFloatArray)); + + __jsb_cc_Node_proto->defineFunction("getPosition", _SE(js_scene_Node_getPosition)); + __jsb_cc_Node_proto->defineFunction("getRotation", _SE(js_scene_Node_getRotation)); + __jsb_cc_Node_proto->defineFunction("setRotation", _SE(js_scene_Node_setRotation)); + __jsb_cc_Node_proto->defineFunction("setRotationFromEuler", _SE(js_scene_Node_setRotationFromEuler)); + __jsb_cc_Node_proto->defineFunction("getScale", _SE(js_scene_Node_getScale)); + __jsb_cc_Node_proto->defineFunction("getEulerAngles", _SE(js_scene_Node_getEulerAngles)); + __jsb_cc_Node_proto->defineFunction("getForward", _SE(js_scene_Node_getForward)); + __jsb_cc_Node_proto->defineFunction("getUp", _SE(js_scene_Node_getUp)); + __jsb_cc_Node_proto->defineFunction("getRight", _SE(js_scene_Node_getRight)); + __jsb_cc_Node_proto->defineFunction("getWorldMatrix", _SE(js_scene_Node_getWorldMatrix)); + __jsb_cc_Node_proto->defineFunction("getWorldPosition", _SE(js_scene_Node_getWorldPosition)); + __jsb_cc_Node_proto->defineFunction("getWorldRS", _SE(js_scene_Node_getWorldRS)); + __jsb_cc_Node_proto->defineFunction("getWorldRT", _SE(js_scene_Node_getWorldRT)); + __jsb_cc_Node_proto->defineFunction("getWorldRotation", _SE(js_scene_Node_getWorldRotation)); + __jsb_cc_Node_proto->defineFunction("getWorldScale", _SE(js_scene_Node_getWorldScale)); + __jsb_cc_Node_proto->defineFunction("setPosition", _SE(js_scene_Node_setPosition)); + __jsb_cc_Node_proto->defineFunction("setScale", _SE(js_scene_Node_setScale)); + __jsb_cc_Node_proto->defineFunction("rotateForJS", _SE(js_scene_Node_rotateForJS)); + __jsb_cc_Node_proto->defineFunction("setRTS", _SE(js_scene_Node_setRTS)); + + __jsb_cc_scene_Pass_proto->defineProperty("blocks", _SE(js_scene_Pass_blocks_getter), nullptr); + + __jsb_cc_scene_RenderScene_proto->defineProperty("root", _SE(js_scene_RenderScene_root_getter), nullptr); + + __jsb_cc_scene_Model_proto->defineFunction("_registerListeners", _SE(js_Model_registerListeners)); + __jsb_cc_MaterialInstance_proto->defineFunction("_registerListeners", _SE(js_assets_MaterialInstance_registerListeners)); return true; } diff --git a/native/cocos/bindings/manual/jsb_scene_manual_ext.cpp b/native/cocos/bindings/manual/jsb_scene_manual_ext.cpp deleted file mode 100644 index 3fb560e3e4..0000000000 --- a/native/cocos/bindings/manual/jsb_scene_manual_ext.cpp +++ /dev/null @@ -1,241 +0,0 @@ - -#include "bindings/auto/jsb_scene_auto.h" -#include "jsb_scene_manual.h" -#include "scene/Model.h" -#include "scene/Node.h" - -namespace { - -template -struct alignas(uint32_t) AlignedPtr { - char _data[8]; - T * get() { - return reinterpret_cast(static_cast(*reinterpret_cast(this))); - } -}; - -void fastSetFlag(void *buffer) { - struct Heap { - AlignedPtr selfPtr; - uint32_t flags; - }; - Heap *heap = reinterpret_cast(buffer); - heap->selfPtr.get()->visFlags = heap->flags; -} - -void fastSetDescriptorSet(void *buffer) { - struct Heap { - AlignedPtr selfPtr; - AlignedPtr dsPtr; - }; - Heap *heap = reinterpret_cast(buffer); - heap->selfPtr.get()->descriptorSet = heap->dsPtr.get(); -} - -void fastSetInputAssembler(void *buffer) { - struct Heap { - AlignedPtr selfPtr; - AlignedPtr inputAssemblerPtr; - }; - Heap *heap = reinterpret_cast(buffer); - heap->selfPtr.get()->inputAssembler = heap->inputAssemblerPtr.get(); -} - -void fastSetPasses(void *buffer) { - struct Heap { - AlignedPtr selfPtr; - uint32_t passSize; - AlignedPtr passes[0]; - }; - - Heap *heap = reinterpret_cast(buffer); - auto &passes = heap->selfPtr.get()->passes; - passes.resize(heap->passSize); - for (size_t i = 0; i < heap->passSize; i++) { - passes[i] = heap->passes[i].get(); - } -} - -void fastSetShaders(void *buffer) { - struct Heap { - AlignedPtr selfPtr; - uint32_t shaderSize; - AlignedPtr shaders[0]; - }; - Heap *heap = reinterpret_cast(buffer); - auto &shaders = heap->selfPtr.get()->shaders; - shaders.resize(heap->shaderSize); - for (size_t i = 0; i < heap->shaderSize; i++) { - shaders[i] = heap->shaders[i].get(); - } -} - -// for pass message -void fastSetPassBlendState(void *buffer) { - struct Heap { - AlignedPtr selfPtr; - AlignedPtr bsPtr; - }; - Heap *heap = reinterpret_cast(buffer); - heap->selfPtr.get()->setBlendState(heap->bsPtr.get()); -} - -void fastSetPassDepthStencilState(void *buffer) { - struct Heap { - AlignedPtr selfPtr; - AlignedPtr dsPtr; - }; - Heap *heap = reinterpret_cast(buffer); - heap->selfPtr.get()->setDepthStencilState(heap->dsPtr.get()); -} - -void fastSetPassRasterizerState(void *buffer) { - struct Heap { - AlignedPtr selfPtr; - AlignedPtr rsPtr; - }; - Heap *heap = reinterpret_cast(buffer); - heap->selfPtr.get()->setRasterizerState(heap->rsPtr.get()); -} - -void fastSetPassDescriptorSet(void *buffer) { - struct Heap { - AlignedPtr selfPtr; - AlignedPtr dsPtr; - }; - Heap *heap = reinterpret_cast(buffer); - heap->selfPtr.get()->setDescriptorSet(heap->dsPtr.get()); -} - -template -uint64_t convertPtr(F *in) { - return static_cast(reinterpret_cast(in)); -} -bool mqInitialized{false}; -se::Object * msgQueue{nullptr}; -se::Object * globalThis{nullptr}; -constexpr size_t BUFFER_SIZE{1 * 1024 * 1024}; // 1MB; -se::Object * msgQueueInfo{nullptr}; -uint32_t * msgInfoPtr{nullptr}; -std::vector msgQueuePtrs; -} // namespace - -/** - * Run all commands in __fastMQ__. This function should be call before render logic, - * which sync data to native objects. - */ -void jsbFlushFastMQ() { - if (!mqInitialized || !msgInfoPtr || msgInfoPtr[1] == 0) { - return; - } - - uint8_t * mqPtr{nullptr}; - const auto minSize = msgInfoPtr[0] + 1; - if (minSize > msgQueuePtrs.size()) { - se::AutoHandleScope scope; - se::Value maxIdx; - se::Value currentArrayBuffer; - se::Object * arrayBufferObj; - auto oldSize = msgQueuePtrs.size(); - msgQueuePtrs.resize(minSize); - for (auto i = oldSize; i < minSize; i++) { - msgQueue->getArrayElement(i, ¤tArrayBuffer); - arrayBufferObj = currentArrayBuffer.toObject(); - arrayBufferObj->getArrayBufferData(&mqPtr, nullptr); - msgQueuePtrs[i] = mqPtr; - } - } - - for (auto i = 0; i < minSize; i++) { - mqPtr = msgQueuePtrs[i]; - auto *u32Ptr = reinterpret_cast(mqPtr); - auto offset = u32Ptr[0]; - auto commands = u32Ptr[1]; - assert(offset < BUFFER_SIZE); - if (commands == 0) return; - - using FastFunction = void (*)(void *); - - uint8_t *p = mqPtr + 8; - for (uint32_t i = 0; i < commands; i++) { - auto *base = reinterpret_cast(p); - auto len = base[0]; - auto *fnAddr = reinterpret_cast(base + 1); - auto *fn = reinterpret_cast(fnAddr); - (*fn)(p + 12); - p += len; - } - // reset - u32Ptr[0] = 8; - u32Ptr[1] = 0; - } - msgInfoPtr[0] = 0; - msgInfoPtr[1] = 0; -} - -void registerDrawBatch2DFunction(se::Object *cls) { - // register function table of DrawBatch2D - se::Value jsValue; - cls->getProperty("DrawBatch2D", &jsValue); - se::Object *jsObj = jsValue.toObject(); - se::Object *fnTable = se::Object::createPlainObject(); - fnTable->setProperty("visFlags", se::Value(convertPtr(fastSetFlag))); - fnTable->setProperty("descriptorSet", se::Value(convertPtr(fastSetDescriptorSet))); - fnTable->setProperty("inputAssembler", se::Value(convertPtr(fastSetInputAssembler))); - fnTable->setProperty("passes", se::Value(convertPtr(fastSetPasses))); - fnTable->setProperty("shaders", se::Value(convertPtr(fastSetShaders))); - jsObj->setProperty("fnTable", se::Value(fnTable)); -} - -void registerPassFunction(se::Object *cls) { - // register function table of DrawBatch2D - se::Value jsValue; - cls->getProperty("Pass", &jsValue); - se::Object *jsObj = jsValue.toObject(); - se::Object *fnTable = se::Object::createPlainObject(); - fnTable->setProperty("blendState", se::Value(convertPtr(fastSetPassBlendState))); - fnTable->setProperty("depthStencilState", se::Value(convertPtr(fastSetPassDepthStencilState))); - fnTable->setProperty("rasterizerState", se::Value(convertPtr(fastSetPassRasterizerState))); - fnTable->setProperty("descriptorSet", se::Value(convertPtr(fastSetPassDescriptorSet))); - jsObj->setProperty("fnTable", se::Value(fnTable)); -} - -bool register_all_scene_ext_manual(se::Object *obj) { //NOLINT - // allocate global message queue - - se::AutoHandleScope scope; - auto * msgArrayBuffer = se::Object::createArrayBufferObject(nullptr, BUFFER_SIZE); - globalThis = se::ScriptEngine::getInstance()->getGlobalObject(); - msgQueue = se::Object::createArrayObject(1); - msgQueueInfo = se::Object::createTypedArray(se::Object::TypedArrayType::UINT32, nullptr, sizeof(uint32_t) * 2); - msgQueuePtrs.clear(); - - { - uint8_t *data{nullptr}; - msgArrayBuffer->getArrayBufferData(&data, nullptr); - auto *int32Data = reinterpret_cast(data); - int32Data[0] = 8; - int32Data[1] = 0; - msgQueueInfo->getTypedArrayData(&data, nullptr); - msgInfoPtr = reinterpret_cast(data); - msgInfoPtr[0] = 0; // current queue index - msgInfoPtr[1] = 0; // total message count - } - msgQueue->setArrayElement(0, se::Value(msgArrayBuffer)); - globalThis->setProperty("__fastMQ__", se::Value(msgQueue)); - globalThis->setProperty("__fastMQInfo__", se::Value(msgQueueInfo)); - - mqInitialized = true; - - // register function table, serialize to queue - se::Object *nsObj{nullptr}; - - se::Value nsValue; - obj->getProperty("ns", &nsValue); - nsObj = nsValue.toObject(); - - registerDrawBatch2DFunction(nsObj); - registerPassFunction(nsObj); - - return true; -} diff --git a/native/cocos/bindings/manual/jsb_socketio.cpp b/native/cocos/bindings/manual/jsb_socketio.cpp index a4ac511d98..ae3ec877ee 100644 --- a/native/cocos/bindings/manual/jsb_socketio.cpp +++ b/native/cocos/bindings/manual/jsb_socketio.cpp @@ -24,13 +24,12 @@ ****************************************************************************/ #include "jsb_socketio.h" - +#include "application/ApplicationManager.h" +#include "base/UTF8.h" +#include "cocos/base/DeferredReleasePool.h" #include "cocos/bindings/jswrapper/SeApi.h" #include "cocos/bindings/manual/jsb_conversions.h" #include "cocos/bindings/manual/jsb_global.h" - -#include "application/ApplicationManager.h" -#include "base/UTF8.h" #include "cocos/network/SocketIO.h" // using namespace cc; @@ -38,7 +37,7 @@ se::Class *__jsb_SocketIO_class = nullptr; // NOLINT -class JSB_SocketIODelegate : public cc::Ref, public cc::network::SocketIO::SIODelegate { // NOLINT(readability-identifier-naming) +class JSB_SocketIODelegate : public cc::RefCounted, public cc::network::SocketIO::SIODelegate { public: //c++11 map to callbacks using JSB_SIOCallbackRegistry = std::unordered_map; @@ -64,14 +63,14 @@ public: iter->second->unroot(); } - if (getReferenceCount() == 1) { - autorelease(); + if (getRefCount() == 1) { + cc::DeferredReleasePool::add(this); } else { release(); } } - void onError(cc::network::SIOClient *client, const std::string &data) override {// NOLINT + void onError(cc::network::SIOClient *client, const std::string &data) override { // NOLINT CC_LOG_DEBUG("JSB SocketIO::SIODelegate->onError method called from native with data: %s", data.c_str()); this->fireEventToScript(client, "error", data); @@ -81,7 +80,7 @@ public: } } - void fireEventToScript(cc::network::SIOClient * client, const std::string & eventName, const std::string & data) override { // NOLINT + void fireEventToScript(cc::network::SIOClient *client, const std::string &eventName, const std::string &data) override { // NOLINT CC_LOG_DEBUG("JSB SocketIO::SIODelegate->fireEventToScript method called from native with name '%s' data: %s", eventName.c_str(), data.c_str()); se::ScriptEngine::getInstance()->clearException(); @@ -140,12 +139,11 @@ static bool SocketIO_finalize(se::State &s) { // NOLINT(readability-identifier-n CC_LOG_INFO("jsbindings: finalizing JS object %p (SocketIO)", cobj); cobj->disconnect(); auto *delegate = static_cast(cobj->getDelegate()); - if (delegate->getReferenceCount() == 1) { - delegate->autorelease(); + if (delegate->getRefCount() == 1) { + cc::DeferredReleasePool::add(delegate); } else { delegate->release(); } - cobj->release(); return true; } SE_BIND_FINALIZE_FUNC(SocketIO_finalize) // NOLINT(readability-identifier-naming) @@ -171,7 +169,7 @@ static bool SocketIO_send(se::State &s) { // NOLINT(readability-identifier-namin if (argc == 1) { std::string payload; - bool ok = seval_to_std_string(args[0], &payload); + bool ok = sevalue_to_native(args[0], &payload); SE_PRECONDITION2(ok, false, "Converting payload failed!"); cobj->send(payload); @@ -191,7 +189,7 @@ static bool SocketIO_emit(se::State &s) { // NOLINT(readability-identifier-namin if (argc >= 1) { bool ok = false; std::string eventName; - ok = seval_to_std_string(args[0], &eventName); + ok = sevalue_to_native(args[0], &eventName); SE_PRECONDITION2(ok, false, "Converting eventName failed!"); std::string payload; @@ -202,7 +200,7 @@ static bool SocketIO_emit(se::State &s) { // NOLINT(readability-identifier-namin // while seval_to_std_string since 1.7.2 follows JS standard to return "null" or "undefined". // Therefore, we need a workaround to make it be compatible with versions lower than v1.7. if (!arg1.isNullOrUndefined()) { - ok = seval_to_std_string(arg1, &payload); + ok = sevalue_to_native(arg1, &payload); SE_PRECONDITION2(ok, false, "Converting payload failed!"); } } @@ -239,7 +237,7 @@ static bool SocketIO_on(se::State &s) { // NOLINT(readability-identifier-naming) if (argc == 2) { bool ok = false; std::string eventName; - ok = seval_to_std_string(args[0], &eventName); + ok = sevalue_to_native(args[0], &eventName); SE_PRECONDITION2(ok, false, "Converting eventName failed!"); CC_LOG_DEBUG("JSB SocketIO eventName to: '%s'", eventName.c_str()); @@ -264,7 +262,7 @@ static bool SocketIO_connect(se::State &s) { // NOLINT(readability-identifier-na std::string caFilePath; bool ok = false; - ok = seval_to_std_string(args[0], &url); + ok = sevalue_to_native(args[0], &url); SE_PRECONDITION2(ok, false, "Error processing arguments"); if (argc == 2) { @@ -272,7 +270,7 @@ static bool SocketIO_connect(se::State &s) { // NOLINT(readability-identifier-na // Just ignore the option argument } else if (args[1].isString()) { // Assume it's CA root file path - ok = seval_to_std_string(args[1], &caFilePath); + ok = sevalue_to_native(args[1], &caFilePath); SE_PRECONDITION2(ok, false, "Error processing arguments"); } } @@ -282,7 +280,7 @@ static bool SocketIO_connect(se::State &s) { // NOLINT(readability-identifier-na if (args[2].isString()) { // Assume it's CA root file path - ok = seval_to_std_string(args[2], &caFilePath); + ok = sevalue_to_native(args[2], &caFilePath); SE_PRECONDITION2(ok, false, "Error processing arguments"); } } @@ -292,8 +290,8 @@ static bool SocketIO_connect(se::State &s) { // NOLINT(readability-identifier-na CC_LOG_DEBUG("Calling native SocketIO.connect method"); cc::network::SIOClient *ret = cc::network::SocketIO::connect(url, *siodelegate, caFilePath); if (ret != nullptr) { - ret->retain(); - siodelegate->retain(); + ret->addRef(); + siodelegate->addRef(); se::Object *obj = se::Object::createObjectWithClass(__jsb_SocketIO_class); obj->setPrivateData(ret); diff --git a/native/cocos/bindings/manual/jsb_spine_manual.cpp b/native/cocos/bindings/manual/jsb_spine_manual.cpp index 0a06f5b3c3..516509bef8 100644 --- a/native/cocos/bindings/manual/jsb_spine_manual.cpp +++ b/native/cocos/bindings/manual/jsb_spine_manual.cpp @@ -25,28 +25,30 @@ #include "jsb_spine_manual.h" #include "base/Config.h" +#include "platform/FileUtils.h" #if USE_SPINE > 0 -#include "cocos/bindings/auto/jsb_spine_auto.h" -#include "cocos/bindings/jswrapper/SeApi.h" -#include "cocos/bindings/manual/jsb_conversions.h" -#include "cocos/bindings/manual/jsb_global.h" -#include "cocos/bindings/manual/jsb_helper.h" + #include "base/Data.h" + #include "cocos/bindings/auto/jsb_spine_auto.h" + #include "cocos/bindings/jswrapper/SeApi.h" + #include "cocos/bindings/manual/jsb_conversions.h" + #include "cocos/bindings/manual/jsb_global.h" + #include "cocos/bindings/manual/jsb_helper.h" -#include "middleware-adapter.h" -#include "spine-creator-support/SkeletonDataMgr.h" -#include "spine-creator-support/SkeletonRenderer.h" -#include "spine-creator-support/spine-cocos2dx.h" + #include "middleware-adapter.h" + #include "spine-creator-support/SkeletonDataMgr.h" + #include "spine-creator-support/SkeletonRenderer.h" + #include "spine-creator-support/spine-cocos2dx.h" -#include "cocos/editor-support/spine-creator-support/spine-cocos2dx.h" -#include "cocos/editor-support/spine/spine.h" + #include "cocos/editor-support/spine-creator-support/spine-cocos2dx.h" + #include "cocos/editor-support/spine/spine.h" using namespace cc; -static spine::Cocos2dTextureLoader textureLoader; +static spine::Cocos2dTextureLoader textureLoader; static cc::Map *_preloadedAtlasTextures = nullptr; -static middleware::Texture2D *_getPreloadedAtlasTexture(const char *path) { +static middleware::Texture2D * _getPreloadedAtlasTexture(const char *path) { assert(_preloadedAtlasTextures); auto it = _preloadedAtlasTextures->find(path); return it != _preloadedAtlasTextures->end() ? it->second : nullptr; @@ -54,7 +56,7 @@ static middleware::Texture2D *_getPreloadedAtlasTexture(const char *path) { static bool js_register_spine_initSkeletonData(se::State &s) { const auto &args = s.args(); - int argc = (int)args.size(); + int argc = (int)args.size(); if (argc != 5) { SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", argc, 5); return false; @@ -62,10 +64,10 @@ static bool js_register_spine_initSkeletonData(se::State &s) { bool ok = false; std::string uuid; - ok = seval_to_std_string(args[0], &uuid); + ok = sevalue_to_native(args[0], &uuid); SE_PRECONDITION2(ok, false, "js_register_spine_initSkeletonData: Invalid uuid content!"); - auto mgr = spine::SkeletonDataMgr::getInstance(); + auto mgr = spine::SkeletonDataMgr::getInstance(); bool hasSkeletonData = mgr->hasSkeletonData(uuid); if (hasSkeletonData) { spine::SkeletonData *skeletonData = mgr->retainByUUID(uuid); @@ -74,11 +76,11 @@ static bool js_register_spine_initSkeletonData(se::State &s) { } std::string skeletonDataFile; - ok = seval_to_std_string(args[1], &skeletonDataFile); + ok = sevalue_to_native(args[1], &skeletonDataFile); SE_PRECONDITION2(ok, false, "js_register_spine_initSkeletonData: Invalid json path!"); std::string atlasText; - ok = seval_to_std_string(args[2], &atlasText); + ok = sevalue_to_native(args[2], &atlasText); SE_PRECONDITION2(ok, false, "js_register_spine_initSkeletonData: Invalid atlas content!"); cc::Map textures; @@ -86,7 +88,7 @@ static bool js_register_spine_initSkeletonData(se::State &s) { SE_PRECONDITION2(ok, false, "js_register_spine_initSkeletonData: Invalid textures!"); float scale = 1.0f; - ok = seval_to_float(args[4], &scale); + ok = sevalue_to_native(args[4], &scale); SE_PRECONDITION2(ok, false, "js_register_spine_initSkeletonData: Invalid scale!"); // create atlas from preloaded texture @@ -100,16 +102,16 @@ static bool js_register_spine_initSkeletonData(se::State &s) { spine::spAtlasPage_setCustomTextureLoader(nullptr); spine::AttachmentLoader *attachmentLoader = new (__FILE__, __LINE__) spine::Cocos2dAtlasAttachmentLoader(atlas); - spine::SkeletonData *skeletonData = nullptr; + spine::SkeletonData * skeletonData = nullptr; std::size_t length = skeletonDataFile.length(); - auto binPos = skeletonDataFile.find(".skel", length - 5); + auto binPos = skeletonDataFile.find(".skel", length - 5); if (binPos == std::string::npos) binPos = skeletonDataFile.find(".bin", length - 4); if (binPos != std::string::npos) { auto fileUtils = cc::FileUtils::getInstance(); if (fileUtils->isFileExist(skeletonDataFile)) { - cc::Data cocos2dData; + cc::Data cocos2dData; const auto fullpath = fileUtils->fullPathForFilename(skeletonDataFile); fileUtils->getContents(fullpath, &cocos2dData); @@ -148,7 +150,7 @@ SE_BIND_FUNC(js_register_spine_initSkeletonData) static bool js_register_spine_disposeSkeletonData(se::State &s) { const auto &args = s.args(); - int argc = (int)args.size(); + int argc = (int)args.size(); if (argc != 1) { SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", argc, 5); return false; @@ -156,10 +158,10 @@ static bool js_register_spine_disposeSkeletonData(se::State &s) { bool ok = false; std::string uuid; - ok = seval_to_std_string(args[0], &uuid); + ok = sevalue_to_native(args[0], &uuid); SE_PRECONDITION2(ok, false, "js_register_spine_disposeSkeletonData: Invalid uuid content!"); - auto mgr = spine::SkeletonDataMgr::getInstance(); + auto mgr = spine::SkeletonDataMgr::getInstance(); bool hasSkeletonData = mgr->hasSkeletonData(uuid); if (!hasSkeletonData) return true; mgr->releaseByUUID(uuid); @@ -170,7 +172,7 @@ SE_BIND_FUNC(js_register_spine_disposeSkeletonData) static bool js_register_spine_initSkeletonRenderer(se::State &s) { // renderer, jsonPath, atlasText, textures, scale const auto &args = s.args(); - int argc = (int)args.size(); + int argc = (int)args.size(); if (argc != 2) { SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", argc, 5); return false; @@ -178,14 +180,14 @@ static bool js_register_spine_initSkeletonRenderer(se::State &s) { bool ok = false; spine::SkeletonRenderer *node = nullptr; - ok = seval_to_native_ptr(args[0], &node); + ok = seval_to_native_ptr(args[0], &node); SE_PRECONDITION2(ok, false, "js_register_spine_initSkeletonData: Converting SpineRenderer failed!"); std::string uuid; - ok = seval_to_std_string(args[1], &uuid); + ok = sevalue_to_native(args[1], &uuid); SE_PRECONDITION2(ok, false, "js_register_spine_initSkeletonData: Invalid uuid content!"); - auto mgr = spine::SkeletonDataMgr::getInstance(); + auto mgr = spine::SkeletonDataMgr::getInstance(); bool hasSkeletonData = mgr->hasSkeletonData(uuid); if (hasSkeletonData) { node->initWithUUID(uuid); @@ -196,7 +198,7 @@ SE_BIND_FUNC(js_register_spine_initSkeletonRenderer) static bool js_register_spine_retainSkeletonData(se::State &s) { const auto &args = s.args(); - int argc = (int)args.size(); + int argc = (int)args.size(); if (argc != 1) { SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", argc, 1); return false; @@ -204,10 +206,10 @@ static bool js_register_spine_retainSkeletonData(se::State &s) { bool ok = false; std::string uuid; - ok = seval_to_std_string(args[0], &uuid); + ok = sevalue_to_native(args[0], &uuid); SE_PRECONDITION2(ok, false, "js_register_spine_hasSkeletonData: Invalid uuid content!"); - auto mgr = spine::SkeletonDataMgr::getInstance(); + auto mgr = spine::SkeletonDataMgr::getInstance(); bool hasSkeletonData = mgr->hasSkeletonData(uuid); if (hasSkeletonData) { spine::SkeletonData *skeletonData = mgr->retainByUUID(uuid); diff --git a/native/cocos/bindings/manual/jsb_websocket.cpp b/native/cocos/bindings/manual/jsb_websocket.cpp index 5b447ad3e6..9cf8b0f80b 100644 --- a/native/cocos/bindings/manual/jsb_websocket.cpp +++ b/native/cocos/bindings/manual/jsb_websocket.cpp @@ -26,12 +26,13 @@ #include "jsb_websocket.h" #include "base/Config.h" #if (USE_SOCKET > 0) + #include "cocos/base/DeferredReleasePool.h" #include "cocos/bindings/jswrapper/SeApi.h" #include "cocos/bindings/manual/jsb_conversions.h" #include "cocos/bindings/manual/jsb_global.h" - #include "base/UTF8.h" #include "application/ApplicationManager.h" + #include "base/UTF8.h" /* [Constructor(in DOMString url, in optional DOMString protocols)] @@ -245,11 +246,6 @@ static bool webSocketFinalize(const se::State &s) { } static_cast(cobj->getDelegate())->release(); - if (cobj->getReferenceCount() == 1) { - cobj->autorelease(); - } else { - cobj->release(); - } return true; } SE_BIND_FINALIZE_FUNC(webSocketFinalize) @@ -261,7 +257,7 @@ static bool webSocketConstructor(se::State &s) { if (argc == 1 || argc == 2 || argc == 3) { std::string url; - bool ok = seval_to_std_string(args[0], &url); + bool ok = sevalue_to_native(args[0], &url); SE_PRECONDITION2(ok, false, "Error processing url argument"); se::Object * obj = s.thisObject(); @@ -272,7 +268,7 @@ static bool webSocketConstructor(se::State &s) { if (args[1].isString()) { std::string protocol; - ok = seval_to_std_string(args[1], &protocol); + ok = sevalue_to_native(args[1], &protocol); SE_PRECONDITION2(ok, false, "Error processing protocol string"); protocols.push_back(protocol); } else if (args[1].isObject() && args[1].toObject()->isArray()) { @@ -288,23 +284,24 @@ static bool webSocketConstructor(se::State &s) { } std::string protocol; - ok = seval_to_std_string(tmp, &protocol); + ok = sevalue_to_native(tmp, &protocol); SE_PRECONDITION2(ok, false, "Error processing protocol object"); protocols.push_back(protocol); } } if (argc > 2) { - ok = seval_to_std_string(args[2], &caFilePath); + ok = sevalue_to_native(args[2], &caFilePath); SE_PRECONDITION2(ok, false, "Error processing caFilePath"); } cobj = new (std::nothrow) cc::network::WebSocket(); auto *delegate = new (std::nothrow) JsbWebSocketDelegate(); + delegate->addRef(); if (cobj->init(*delegate, url, &protocols, caFilePath)) { delegate->setJSDelegate(se::Value(obj, true)); - cobj->retain(); // release in finalize function and onClose delegate method - delegate->retain(); // release in finalize function and onClose delegate method + cobj->addRef(); // release in finalize function and onClose delegate method + delegate->addRef(); // release in finalize function and onClose delegate method } else { cobj->release(); delegate->release(); @@ -314,10 +311,11 @@ static bool webSocketConstructor(se::State &s) { } else { cobj = new (std::nothrow) cc::network::WebSocket(); auto *delegate = new (std::nothrow) JsbWebSocketDelegate(); + delegate->addRef(); if (cobj->init(*delegate, url)) { delegate->setJSDelegate(se::Value(obj, true)); - cobj->retain(); // release in finalize function and onClose delegate method - delegate->retain(); // release in finalize function and onClose delegate method + cobj->addRef(); // release in finalize function and onClose delegate method + delegate->addRef(); // release in finalize function and onClose delegate method } else { cobj->release(); delegate->release(); @@ -355,7 +353,7 @@ static bool webSocketSend(const se::State &s) { bool ok = false; if (args[0].isString()) { std::string data; - ok = seval_to_std_string(args[0], &data); + ok = sevalue_to_native(args[0], &data); SE_PRECONDITION2(ok, false, "Convert string failed"); //IDEA: We didn't find a way to get the JS string length in JSB2.0. // if (data.empty() && len > 0) @@ -402,12 +400,12 @@ static bool webSocketClose(se::State &s) { cobj->closeAsync(); } else if (argc == 1) { if (args[0].isNumber()) { - int reason; - seval_to_int32(args[0], &reason); + int reason{0}; + sevalue_to_native(args[0], &reason); cobj->closeAsync(reason, "no_reason"); } else if (args[0].isString()) { std::string reason; - seval_to_std_string(args[0], &reason); + sevalue_to_native(args[0], &reason); cobj->closeAsync(1005, reason); } else { assert(false); @@ -415,10 +413,10 @@ static bool webSocketClose(se::State &s) { } else if (argc == 2) { assert(args[0].isNumber()); assert(args[1].isString()); - int reasonCode; + int reasonCode{0}; std::string reasonString; - seval_to_int32(args[0], &reasonCode); - seval_to_std_string(args[1], &reasonString); + sevalue_to_native(args[0], &reasonCode); + sevalue_to_native(args[1], &reasonString); cobj->closeAsync(reasonCode, reasonString); } else { assert(false); diff --git a/native/cocos/bindings/manual/jsb_websocket.h b/native/cocos/bindings/manual/jsb_websocket.h index 1bdc20dd22..a7dde6881e 100644 --- a/native/cocos/bindings/manual/jsb_websocket.h +++ b/native/cocos/bindings/manual/jsb_websocket.h @@ -33,7 +33,7 @@ class Object; class Value; } // namespace se -class JsbWebSocketDelegate : public cc::Ref, public cc::network::WebSocket::Delegate { +class JsbWebSocketDelegate : public cc::RefCounted, public cc::network::WebSocket::Delegate { public: JsbWebSocketDelegate() = default; diff --git a/native/cocos/bindings/manual/jsb_websocket_server.cpp b/native/cocos/bindings/manual/jsb_websocket_server.cpp index 25e5fc1697..67d9be32bc 100644 --- a/native/cocos/bindings/manual/jsb_websocket_server.cpp +++ b/native/cocos/bindings/manual/jsb_websocket_server.cpp @@ -56,7 +56,6 @@ static std::string gen_send_index() { static bool WebSocketServer_finalize(se::State &s) { WSSPTR cobj = (WSSPTR)s.nativeThisObject(); CC_LOG_INFO("jsbindings: finalizing JS object %p (WebSocketServer)", cobj); - delete cobj; return true; } SE_BIND_FINALIZE_FUNC(WebSocketServer_finalize) @@ -102,12 +101,12 @@ static bool WebSocketServer_listen(se::State &s) { bool ok; if (argc >= 1) { // port - ok = seval_to_int32(args[0], &arg_port); + ok = sevalue_to_native(args[0], &arg_port); SE_PRECONDITION2(ok, false, "Convert args[0] to port failed"); } if (argc >= 2) { // host or callback if (args[1].isString()) { //to host - ok = seval_to_std_string(args[1], &arg_host); + ok = sevalue_to_native(args[1], &arg_host); SE_PRECONDITION2(ok, false, "Convert args[1] to host failed"); } se::Object *funObj = nullptr; @@ -339,7 +338,6 @@ SE_BIND_PROP_GET(WebSocketServer_connections) static bool WebSocketServer_Connection_finalize(se::State &s) { WSCONNPTR cobj = (WSCONNPTR)s.nativeThisObject(); CC_LOG_INFO("jsbindings: finalizing JS object %p (WebSocketServer_Connection)", cobj); - delete cobj; return true; } SE_BIND_FINALIZE_FUNC(WebSocketServer_Connection_finalize) @@ -406,7 +404,7 @@ static bool WebSocketServer_Connection_send(se::State &s) { bool ok = false; if (args[0].isString()) { std::string data; - ok = seval_to_std_string(args[0], &data); + ok = sevalue_to_native(args[0], &data); SE_PRECONDITION2(ok, false, "Convert string failed"); (*cobj)->sendTextAsync(data, callback); } else if (args[0].isObject()) { @@ -456,11 +454,11 @@ static bool WebSocketServer_Connection_close(se::State &s) { bool ok; if (argc >= 1) { - ok = seval_to_int32(args[0], &arg_code); + ok = sevalue_to_native(args[0], &arg_code); SE_PRECONDITION2(ok, false, "Convert args[0] should be a number"); if (argc >= 2) { - ok = seval_to_std_string(args[1], &arg_reason); + ok = sevalue_to_native(args[1], &arg_reason); SE_PRECONDITION2(ok, false, "Convert args[1] should be a string"); } } diff --git a/native/cocos/bindings/manual/jsb_xmlhttprequest.cpp b/native/cocos/bindings/manual/jsb_xmlhttprequest.cpp index 45316df31d..d70bc97a5b 100644 --- a/native/cocos/bindings/manual/jsb_xmlhttprequest.cpp +++ b/native/cocos/bindings/manual/jsb_xmlhttprequest.cpp @@ -38,6 +38,7 @@ #include #include "base/Config.h" #include "cocos/base/Data.h" +#include "cocos/base/DeferredReleasePool.h" #include "cocos/bindings/jswrapper/SeApi.h" #include "cocos/bindings/manual/jsb_conversions.h" #include "cocos/network/HttpClient.h" @@ -115,7 +116,7 @@ std::unordered_map _httpStatusCodeMap = { {599, "Network Connect Timeout Error"}}; } // namespace -class XMLHttpRequest : public Ref { +class XMLHttpRequest : public RefCounted { public: // Ready States: https://developer.mozilla.org/en-US/docs/Web/API/XMLHttpRequest/readyState enum class ReadyState : char { @@ -285,11 +286,11 @@ void XMLHttpRequest::sendBinary(const Data &data) { void XMLHttpRequest::setTimeout(uint32_t timeoutInMilliseconds) { _timeoutInMilliseconds = timeoutInMilliseconds; - _httpRequest->setTimeout(timeoutInMilliseconds / 1000.0F + 2.0F); // Add 2 seconds more to ensure the timeout scheduler is invoked before http response. + _httpRequest->setTimeout(static_cast(timeoutInMilliseconds) / 1000.0F + 2.0F); // Add 2 seconds more to ensure the timeout scheduler is invoked before http response. } uint32_t XMLHttpRequest::getTimeout() const { - return _httpRequest->getTimeout() * 1000; + return static_cast(_httpRequest->getTimeout() * 1000); } void XMLHttpRequest::abort() { @@ -439,7 +440,7 @@ void XMLHttpRequest::onResponse(HttpClient * /*client*/, HttpResponse *response) if (_responseType == ResponseType::STRING || _responseType == ResponseType::JSON) { _responseText.append(buffer->data(), buffer->size()); } else { - _responseData.copy(reinterpret_cast(buffer->data()), buffer->size()); + _responseData.copy(reinterpret_cast(buffer->data()), static_cast(buffer->size())); } _status = statusCode; @@ -484,7 +485,7 @@ void XMLHttpRequest::sendRequest() { _isTimeout = true; _readyState = ReadyState::UNSENT; }, - this, _timeoutInMilliseconds / 1000.0F, 0, 0.0F, false, "XMLHttpRequest"); + this, static_cast(_timeoutInMilliseconds) / 1000.0F, 0, 0.0F, false, "XMLHttpRequest"); } setHttpRequestHeader(); @@ -575,11 +576,6 @@ se::Class *__jsb_XMLHttpRequest_class = nullptr; //NOLINT(readability-identifier static bool XMLHttpRequest_finalize(se::State &s) { //NOLINT(readability-identifier-naming, google-runtime-references) auto *request = static_cast(s.nativeThisObject()); SE_LOGD("XMLHttpRequest_finalize, %p ... \n", request); - if (request->getReferenceCount() == 1) { - request->autorelease(); - } else { - request->release(); - } return true; } SE_BIND_FINALIZE_FUNC(XMLHttpRequest_finalize) @@ -654,10 +650,10 @@ static bool XMLHttpRequest_open(se::State &s) { //NOLINT(readability-identifier- auto * request = static_cast(s.nativeThisObject()); bool ok = false; std::string method; - ok = seval_to_std_string(args[0], &method); + ok = sevalue_to_native(args[0], &method); SE_PRECONDITION2(ok, false, "args[0] isn't a string."); std::string url; - ok = seval_to_std_string(args[1], &url); + ok = sevalue_to_native(args[1], &url); SE_PRECONDITION2(ok, false, "args[1] isn't a string."); bool ret = request->open(method, url); s.rval().setBoolean(ret); @@ -697,7 +693,7 @@ static bool XMLHttpRequest_send(se::State &s) { //NOLINT(readability-identifier- size_t len = 0; if (obj->getTypedArrayData(&ptr, &len)) { Data data; - data.copy(ptr, len); + data.copy(ptr, static_cast(len)); request->sendBinary(data); } else { SE_REPORT_ERROR("Failed to get data of TypedArray!"); @@ -708,7 +704,7 @@ static bool XMLHttpRequest_send(se::State &s) { //NOLINT(readability-identifier- size_t len = 0; if (obj->getArrayBufferData(&ptr, &len)) { Data data; - data.copy(ptr, len); + data.copy(ptr, static_cast(len)); request->sendBinary(data); } else { SE_REPORT_ERROR("Failed to get data of ArrayBufferObject!"); @@ -742,10 +738,10 @@ static bool XMLHttpRequest_setRequestHeader(se::State &s) { //NOLINT(readability if (argc >= 2) { auto * xhr = static_cast(s.nativeThisObject()); std::string key; - bool ok = seval_to_std_string(args[0], &key); + bool ok = sevalue_to_native(args[0], &key); SE_PRECONDITION2(ok, false, "args[0] couldn't be converted to string."); std::string value; - ok = seval_to_std_string(args[1], &value); + ok = sevalue_to_native(args[1], &value); SE_PRECONDITION2(ok, false, "args[1] couldn't be converted to string."); xhr->setRequestHeader(key, value); return true; @@ -770,7 +766,7 @@ static bool XMLHttpRequest_getResonpseHeader(se::State &s) { //NOLINT(readabilit if (argc > 0) { auto * xhr = static_cast(s.nativeThisObject()); std::string key; - bool ok = seval_to_std_string(args[0], &key); + bool ok = sevalue_to_native(args[0], &key); SE_PRECONDITION2(ok, false, "args[0] couldn't be converted to string."); std::string header = xhr->getResponseHeader(key); s.rval().setString(header); @@ -787,7 +783,7 @@ static bool XMLHttpRequest_overrideMimeType(se::State &s) { //NOLINT(readability int argc = static_cast(args.size()); if (argc > 0 && args[0].isString()) { std::string mimeType; - seval_to_std_string(args[0], &mimeType); + sevalue_to_native(args[0], &mimeType); auto *xhr = static_cast(s.nativeThisObject()); xhr->overrideMimeType(mimeType); } @@ -888,7 +884,7 @@ static bool XMLHttpRequest_setTimeout(se::State &s) { //NOLINT(readability-ident if (argc > 0) { auto * cobj = static_cast(s.nativeThisObject()); uint32_t timeoutInMilliseconds = 0; - bool ok = seval_to_uint32(args[0], &timeoutInMilliseconds); + bool ok = sevalue_to_native(args[0], &timeoutInMilliseconds); SE_PRECONDITION2(ok, false, "args[0] isn't a number"); if (timeoutInMilliseconds < 50) { SE_LOGE("The timeout value (%u ms) is too small, please note that timeout unit is milliseconds!", timeoutInMilliseconds); @@ -927,7 +923,7 @@ static bool XMLHttpRequest_setResponseType(se::State &s) { //NOLINT(readability- if (argc > 0) { std::string type; - bool ok = seval_to_std_string(args[0], &type); + bool ok = sevalue_to_native(args[0], &type); SE_PRECONDITION2(ok, false, "args[0] couldn't be converted to string!"); auto *xhr = static_cast(s.nativeThisObject()); diff --git a/native/cocos/core/Any.h b/native/cocos/core/Any.h new file mode 100644 index 0000000000..4b0afa2842 --- /dev/null +++ b/native/cocos/core/Any.h @@ -0,0 +1,34 @@ +/**************************************************************************** + 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 + +namespace cc { + +class Any { +public: +}; + +} // namespace cc diff --git a/native/cocos/core/ArrayBuffer.h b/native/cocos/core/ArrayBuffer.h new file mode 100644 index 0000000000..3162b7cf58 --- /dev/null +++ b/native/cocos/core/ArrayBuffer.h @@ -0,0 +1,116 @@ +/**************************************************************************** + 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/Macros.h" +#include "base/Ptr.h" +#include "base/RefCounted.h" +#include "bindings/jswrapper/Object.h" + +namespace cc { + +class ArrayBuffer : public RefCounted { +public: + using Ptr = IntrusivePtr; + + explicit ArrayBuffer(uint32_t length) : _byteLength{length} { + _jsArrayBuffer = se::Object::createArrayBufferObject(nullptr, length); + _jsArrayBuffer->root(); + _jsArrayBuffer->getArrayBufferData(static_cast(&_data), nullptr); + memset(_data, 0x00, _byteLength); + } + + ArrayBuffer(const uint8_t *data, uint32_t length) { + reset(data, length); + } + + ArrayBuffer() = default; + + ~ArrayBuffer() override { + if (_jsArrayBuffer) { + _jsArrayBuffer->unroot(); + _jsArrayBuffer->decRef(); + } + } + + inline void setJSArrayBuffer(se::Object *arrayBuffer) { + if (_jsArrayBuffer) { + _jsArrayBuffer->unroot(); + _jsArrayBuffer->decRef(); + } + + _jsArrayBuffer = arrayBuffer; + _jsArrayBuffer->incRef(); + _jsArrayBuffer->root(); + size_t length{0}; + _jsArrayBuffer->getArrayBufferData(static_cast(&_data), &length); + _byteLength = static_cast(length); + } + inline se::Object *getJSArrayBuffer() const { return _jsArrayBuffer; } + + inline uint32_t byteLength() const { return _byteLength; } + + Ptr slice(uint32_t begin) { + return slice(begin, _byteLength); + } + + Ptr slice(uint32_t begin, uint32_t end) { + CC_ASSERT(end > begin); + CC_ASSERT(begin < _byteLength); + CC_ASSERT(end <= _byteLength); + uint32_t newBufByteLength = (end - begin); + Ptr buffer = new ArrayBuffer(newBufByteLength); + memcpy(buffer->getData(), _data + begin, newBufByteLength); + return buffer; + } + + // Just use it to copy data. Use TypedArray to get/set data. + inline const uint8_t *getData() const { return _data; } + inline uint8_t * getData() { return _data; } + + inline void reset(const uint8_t *data, uint32_t length) { + if (_jsArrayBuffer != nullptr) { + _jsArrayBuffer->unroot(); + _jsArrayBuffer->decRef(); + } + _jsArrayBuffer = se::Object::createArrayBufferObject(data, length); + _jsArrayBuffer->getArrayBufferData(static_cast(&_data), nullptr); + _byteLength = length; + } + +private: + se::Object *_jsArrayBuffer{nullptr}; + uint8_t * _data{nullptr}; + uint32_t _byteLength{0}; + + template + friend class TypedArrayTemp; + friend class DataView; + + CC_DISALLOW_COPY_MOVE_ASSIGN(ArrayBuffer); +}; + +} // namespace cc diff --git a/native/cocos/core/CoreModuleHeader.h b/native/cocos/core/CoreModuleHeader.h new file mode 100644 index 0000000000..e69de29bb2 diff --git a/native/cocos/core/DataView.cpp b/native/cocos/core/DataView.cpp new file mode 100644 index 0000000000..5f59ee831c --- /dev/null +++ b/native/cocos/core/DataView.cpp @@ -0,0 +1,184 @@ +/**************************************************************************** + 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/DataView.h" + +namespace cc { + +#include "base/Macros.h" +#include "core/ArrayBuffer.h" + +std::unordered_map DataView::intReaderMap{ + {"getUint8", &DataView::getUint8}, + {"getUint16", &DataView::getUint16}, + {"getUint32", &DataView::getUint32}, + {"getInt8", &DataView::getInt8}, + {"getInt16", &DataView::getInt16}, + {"getInt32", &DataView::getInt32}, +}; + +std::unordered_map DataView::intWritterMap{ + {"setUint8", reinterpret_cast(&DataView::setUint8)}, + {"setUint16", reinterpret_cast(&DataView::setUint16)}, + {"setUint32", reinterpret_cast(&DataView::setUint32)}, + {"setInt8", reinterpret_cast(&DataView::setInt8)}, + {"setInt16", reinterpret_cast(&DataView::setInt16)}, + {"setInt32", reinterpret_cast(&DataView::setInt32)}, +}; + +int32_t DataView::readInt(ReaderVariant &readerVariant, uint32_t offset) { + return cc::visit([offset, this](auto &reader) { + return static_cast((this->*reader)(offset)); + }, + readerVariant); +} + +DataView::DataView(ArrayBuffer *buffer) : DataView(buffer, 0) {} + +DataView::DataView(ArrayBuffer *buffer, uint32_t byteOffset) +: DataView(buffer, byteOffset, buffer ? (buffer->byteLength() - byteOffset) : 0) {} + +DataView::DataView(ArrayBuffer *buffer, uint32_t byteOffset, uint32_t byteLength) { + assign(buffer, byteOffset, byteLength); +} + +void DataView::assign(ArrayBuffer *buffer) { + assign(buffer, 0); +} + +void DataView::assign(ArrayBuffer *buffer, uint32_t byteOffset) { + assign(buffer, byteOffset, buffer ? buffer->byteLength() : 0); +} + +void DataView::assign(ArrayBuffer *buffer, uint32_t byteOffset, uint32_t byteLength) { + CC_ASSERT(buffer != nullptr); + CC_ASSERT(byteLength > 0); + _buffer = buffer; + _byteOffset = byteOffset; + _byteEndPos = byteLength + byteOffset; + CC_ASSERT(_byteEndPos <= buffer->_byteLength); + + _data = buffer->_data; +} + +uint8_t DataView::getUint8(uint32_t offset) const { + offset += _byteOffset; + CC_ASSERT(offset < _byteEndPos); + + return _data[offset]; +} + +uint16_t DataView::getUint16(uint32_t offset) const { + offset += _byteOffset; + CC_ASSERT(offset < (_byteEndPos - 1)); + + return *reinterpret_cast(_data + offset); +} + +uint32_t DataView::getUint32(uint32_t offset) const { + offset += _byteOffset; + CC_ASSERT(offset < (_byteEndPos - 3)); + + return *reinterpret_cast(_data + offset); +} + +int8_t DataView::getInt8(uint32_t offset) const { + offset += _byteOffset; + CC_ASSERT(offset < _byteEndPos); + + return static_cast(_data[offset]); +} + +int16_t DataView::getInt16(uint32_t offset) const { + offset += _byteOffset; + CC_ASSERT(offset < (_byteEndPos - 1)); + + return *reinterpret_cast(_data + offset); +} + +int32_t DataView::getInt32(uint32_t offset) const { + offset += _byteOffset; + CC_ASSERT(offset < (_byteEndPos - 3)); + + return *reinterpret_cast(_data + offset); +} + +float DataView::getFloat32(uint32_t offset) const { + offset += _byteOffset; + CC_ASSERT(offset < (_byteEndPos - 3)); + + return *reinterpret_cast(_data + offset); +} + +void DataView::setUint8(uint32_t offset, uint8_t value) { + offset += _byteOffset; + CC_ASSERT(offset < _byteEndPos); + + _data[offset] = value; +} + +void DataView::setUint16(uint32_t offset, uint16_t value) { + offset += _byteOffset; + CC_ASSERT(offset < _byteEndPos - 1); + + *reinterpret_cast(_data + offset) = value; +} + +void DataView::setUint32(uint32_t offset, uint32_t value) { + offset += _byteOffset; + CC_ASSERT(offset < _byteEndPos - 3); + + *reinterpret_cast(_data + offset) = value; +} + +void DataView::setInt8(uint32_t offset, int8_t value) { + offset += _byteOffset; + CC_ASSERT(offset < _byteEndPos); + + *reinterpret_cast(_data + offset) = value; +} + +void DataView::setInt16(uint32_t offset, int16_t value) { + offset += _byteOffset; + CC_ASSERT(offset < _byteEndPos - 1); + + *reinterpret_cast(_data + offset) = value; +} + +void DataView::setInt32(uint32_t offset, int32_t value) { + offset += _byteOffset; + CC_ASSERT(offset < _byteEndPos - 3); + + *reinterpret_cast(_data + offset) = value; +} + +void DataView::setFloat32(uint32_t offset, float value) { + offset += _byteOffset; + CC_ASSERT(offset < _byteEndPos - 3); + + *(reinterpret_cast(_data + offset)) = value; +} + +} // namespace cc diff --git a/native/cocos/core/DataView.h b/native/cocos/core/DataView.h new file mode 100644 index 0000000000..71e0dd051a --- /dev/null +++ b/native/cocos/core/DataView.h @@ -0,0 +1,90 @@ +/**************************************************************************** + 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/Macros.h" +#include "base/TypeDef.h" +#include "base/Variant.h" +#include "core/ArrayBuffer.h" + +namespace cc { + +class DataView final { +public: + DataView() = default; + explicit DataView(ArrayBuffer *buffer); + DataView(ArrayBuffer *buffer, uint32_t byteOffset); + DataView(ArrayBuffer *buffer, uint32_t byteOffset, uint32_t byteLength); + ~DataView() = default; + + void assign(ArrayBuffer *buffer); + void assign(ArrayBuffer *buffer, uint32_t byteOffset); + void assign(ArrayBuffer *buffer, uint32_t byteOffset, uint32_t byteLength); + + uint8_t getUint8(uint32_t offset) const; + uint16_t getUint16(uint32_t offset) const; + uint32_t getUint32(uint32_t offset) const; + int8_t getInt8(uint32_t offset) const; + int16_t getInt16(uint32_t offset) const; + int32_t getInt32(uint32_t offset) const; + float getFloat32(uint32_t offset) const; + + void setUint8(uint32_t offset, uint8_t value); + void setUint16(uint32_t offset, uint16_t value); + void setUint32(uint32_t offset, uint32_t value); + void setInt8(uint32_t offset, int8_t value); + void setInt16(uint32_t offset, int16_t value); + void setInt32(uint32_t offset, int32_t value); + void setFloat32(uint32_t offset, float value); + + inline const ArrayBuffer *buffer() const { return _buffer; } + inline ArrayBuffer * buffer() { return _buffer; } + inline uint32_t byteOffset() const { return _byteOffset; } + inline uint32_t byteLength() const { + return _byteEndPos - _byteOffset; + } + + using Int32Reader = int32_t (DataView::*)(uint32_t) const; + using UInt32Reader = uint32_t (DataView::*)(uint32_t) const; + using Int16Reader = int16_t (DataView::*)(uint32_t) const; + using UInt16Reader = uint16_t (DataView::*)(uint32_t) const; + using Int8Reader = int8_t (DataView::*)(uint32_t) const; + using UInt8Reader = uint8_t (DataView::*)(uint32_t) const; + using ReaderVariant = cc::variant; + static std::unordered_map intReaderMap; + int32_t readInt(ReaderVariant &readerVariant, uint32_t offset); + + using IntWritter = void (DataView::*)(uint32_t, uint32_t); + static std::unordered_map intWritterMap; + +private: + ArrayBuffer::Ptr _buffer; + uint8_t * _data{nullptr}; + uint32_t _byteOffset{0}; + uint32_t _byteEndPos{0}; +}; + +} // namespace cc diff --git a/native/cocos/core/Root.cpp b/native/cocos/core/Root.cpp new file mode 100644 index 0000000000..6d5464dfbc --- /dev/null +++ b/native/cocos/core/Root.cpp @@ -0,0 +1,309 @@ +/**************************************************************************** + 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/Root.h" +// #include "core/Director.h" +#include "core/event/CallbacksInvoker.h" +#include "core/event/EventTypesToJS.h" +#include "renderer/gfx-base/GFXDef.h" +#include "renderer/gfx-base/GFXSwapchain.h" +#include "renderer/pipeline/deferred/DeferredPipeline.h" +#include "renderer/pipeline/forward/ForwardPipeline.h" +#include "scene/DirectionalLight.h" +#include "scene/SpotLight.h" + +namespace cc { + +namespace { +Root *instance = nullptr; +} + +Root *Root::getInstance() { + return instance; +} + +Root::Root(gfx::Device *device) +: _device(device) { + instance = this; + _eventProcessor = new CallbacksInvoker(); + // TODO(minggo): + // this._dataPoolMgr = legacyCC.internal.DataPoolManager && new legacyCC.internal.DataPoolManager(device) as DataPoolManager; + _cameraPool = new memop::Pool([this]() { return new scene::Camera(_device); }, + 4); + + _cameraList.reserve(6); + _swapchains.reserve(2); +} + +Root::~Root() { + instance = nullptr; + delete _cameraPool; + CC_SAFE_DELETE(_eventProcessor); +} + +void Root::initialize(gfx::Swapchain *swapchain) { + _swapchain = swapchain; + + gfx::RenderPassInfo renderPassInfo; + + gfx::ColorAttachment colorAttachment; + colorAttachment.format = swapchain->getColorTexture()->getFormat(); + renderPassInfo.colorAttachments.emplace_back(colorAttachment); + + auto &depthStencilAttachment = renderPassInfo.depthStencilAttachment; + depthStencilAttachment.format = swapchain->getDepthStencilTexture()->getFormat(); + depthStencilAttachment.depthStoreOp = gfx::StoreOp::DISCARD; + depthStencilAttachment.stencilStoreOp = gfx::StoreOp::DISCARD; + + scene::IRenderWindowInfo info; + info.title = std::string{"rootMainWindow"}; + info.width = swapchain->getWidth(); + info.height = swapchain->getHeight(); + info.renderPassInfo = renderPassInfo; + info.swapchain = swapchain; + _mainWindow = createWindow(info); + + _curWindow = _mainWindow; + + // TODO(minggo): + // return Promise.resolve(builtinResMgr.initBuiltinRes(this._device)); +} + +void Root::destroy() { + destroyScenes(); + + CC_SAFE_DESTROY_NULL(_pipeline); + // TODO(minggo): + // CC_SAFE_DESTROY(_batcher2D); + + // TODO(minggo): + // this.dataPoolManager.clear(); +} + +void Root::resize(uint32_t width, uint32_t height) { + for (const auto &window : _windows) { + if (window->getSwapchain()) { + window->resize(width, height); + } + } +} + +bool Root::setRenderPipeline(pipeline::RenderPipeline *rppl /* = nullptr*/) { + if (rppl != nullptr && dynamic_cast(rppl) != nullptr) { + _useDeferredPipeline = true; + } + + bool isCreateDefaultPipeline{false}; + if (!rppl) { + rppl = new pipeline::ForwardPipeline(); + rppl->initialize({}); + isCreateDefaultPipeline = true; + } + + _pipeline = rppl; + + // now cluster just enabled in deferred pipeline + if (!_useDeferredPipeline || !_device->hasFeature(gfx::Feature::COMPUTE_SHADER)) { + // disable cluster + _pipeline->setClusterEnabled(false); + } + _pipeline->setBloomEnabled(false); + + if (!_pipeline->activate(_mainWindow->getSwapchain())) { + if (isCreateDefaultPipeline) { + CC_SAFE_DESTROY_AND_DELETE(_pipeline); + } + + _pipeline = nullptr; + return false; + } + + // TODO(minggo): + // auto *scene = Director::getInstance()->getScene(); + // if (scene) { + // scene->getSceneGlobals()->activate(); + // } + + onGlobalPipelineStateChanged(); + + _eventProcessor->emit(EventTypesToJS::ROOT_BATCH2D_INIT, this); + // TODO(minggo): + // if (!_batcher) { + // _batcher = new Batcher2D(this); + // if (!this._batcher.initialize()) { + // this.destroy(); + // return false; + // } + // } + + return true; +} + +void Root::onGlobalPipelineStateChanged() { + for (const auto &scene : _scenes) { + scene->onGlobalPipelineStateChanged(); + } + + _pipeline->getPipelineSceneData()->onGlobalPipelineStateChanged(); +} + +void Root::activeWindow(scene::RenderWindow *window) { + _curWindow = window; +} + +void Root::resetCumulativeTime() { + _cumulativeTime = 0; +} + +void Root::frameMove(float deltaTime, int32_t totalFrames) { + _frameTime = deltaTime; + + ++_frameCount; + _cumulativeTime += deltaTime; + _fpsTime += deltaTime; + if (_fpsTime > 1.0F) { + _fps = _frameCount; + _frameCount = 0; + _fpsTime = 0.0; + } + + for (const auto &scene : _scenes) { + scene->removeBatches(); + } + + _eventProcessor->emit(EventTypesToJS::ROOT_BATCH2D_UPDATE, this); // cjh added for sync logic in ts. + + // TODO(minggo): + // if (_batcher) { + // _batcher.update(); + // } + + // + _cameraList.clear(); + for (const auto &window : _windows) { + window->extractRenderCameras(_cameraList); + } + + if (_pipeline != nullptr && !_cameraList.empty()) { + _swapchains.clear(); + _swapchains.emplace_back(_swapchain); + _device->acquire(_swapchains); + // cjh TODO: const stamp = legacyCC.director.getTotalFrames(); + uint32_t stamp = totalFrames; + + _eventProcessor->emit(EventTypesToJS::ROOT_BATCH2D_UPLOAD_BUFFERS, this); + // if (_batcher != nullptr) { + // _batcher->uploadBuffers(); + // } + + for (const auto &scene : _scenes) { + scene->update(stamp); + } + + _eventProcessor->emit(EventTypesToJS::DIRECTOR_BEFORE_COMMIT, this); + + std::stable_sort(_cameraList.begin(), _cameraList.end(), [](const auto *a, const auto *b) { + return a->getPriority() < b->getPriority(); + }); + _pipeline->render(_cameraList); + _device->present(); + } + + _eventProcessor->emit(EventTypesToJS::ROOT_BATCH2D_RESET, this); + // cjh TODO: if (this._batcher) this._batcher.reset(); +} + +scene::RenderWindow *Root::createWindow(scene::IRenderWindowInfo &info) { + IntrusivePtr window = new scene::RenderWindow(); + + window->initialize(_device, info); + _windows.emplace_back(window); + return window; +} + +void Root::destroyWindow(scene::RenderWindow *window) { + auto it = std::find(_windows.begin(), _windows.end(), window); + if (it != _windows.end()) { + CC_SAFE_DESTROY(*it); + _windows.erase(it); + } +} + +void Root::destroyWindows() { + for (const auto &window : _windows) { + CC_SAFE_DESTROY(window); + } + _windows.clear(); +} + +scene::RenderScene *Root::createScene(const scene::IRenderSceneInfo &info) { + IntrusivePtr scene = new scene::RenderScene(); + scene->initialize(info); + _scenes.emplace_back(scene); + return scene.get(); +} + +void Root::destroyScene(scene::RenderScene *scene) { + auto it = std::find(_scenes.begin(), _scenes.end(), scene); + if (it != _scenes.end()) { + CC_SAFE_DESTROY(*it); + _scenes.erase(it); + } +} + +void Root::destroyModel(scene::Model *model) { // NOLINT(readability-convert-member-functions-to-static) + if (model == nullptr) { + return; + } + model->destroy(); + if (model->getScene() != nullptr) { + model->getScene()->removeModel(model); + } +} + +void Root::destroyLight(scene::Light *light) { // NOLINT(readability-convert-member-functions-to-static) + if (light == nullptr) { + return; + } + light->destroy(); + if (light->getScene() != nullptr) { + if (light->getType() == scene::LightType::DIRECTIONAL) { + light->getScene()->removeDirectionalLight(static_cast(light)); + } else if (light->getType() == scene::LightType::SPHERE) { + light->getScene()->removeSphereLight(static_cast(light)); + } else if (light->getType() == scene::LightType::SPOT) { + light->getScene()->removeSpotLight(static_cast(light)); + } + } +} + +void Root::destroyScenes() { + for (const auto &scene : _scenes) { + CC_SAFE_DESTROY(scene); + } + _scenes.clear(); +} + +} // namespace cc diff --git a/native/cocos/core/Root.h b/native/cocos/core/Root.h new file mode 100644 index 0000000000..64eeb5ace1 --- /dev/null +++ b/native/cocos/core/Root.h @@ -0,0 +1,272 @@ +/**************************************************************************** + 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 +#include +//#include "3d/skeletal-animation/DataPoolManager.h" +#include "core/memop/Pool.h" +#include "renderer/gfx-base/GFXDevice.h" +#include "renderer/pipeline/RenderPipeline.h" +#include "scene/Camera.h" +#include "scene/DrawBatch2D.h" +#include "scene/Light.h" +#include "scene/Model.h" +#include "scene/RenderScene.h" +#include "scene/RenderWindow.h" +#include "scene/SphereLight.h" + +namespace cc { + +namespace gfx { +class SwapChain; +} + +class CallbacksInvoker; + +class Root final { +public: + static Root *getInstance(); //cjh todo: put Root Managerment to Director class. + explicit Root(gfx::Device *device); + ~Root(); + + // @minggo IRootInfo seems is not use, and how to return Promise? + void initialize(gfx::Swapchain *swapchain); + void destroy(); + + /** + * @zh + * 重置大小 + * @param width 屏幕宽度 + * @param height 屏幕高度 + */ + void resize(uint32_t width, uint32_t height); + + bool setRenderPipeline(pipeline::RenderPipeline *rppl = nullptr); + void onGlobalPipelineStateChanged(); + + /** + * @zh + * 激活指定窗口为当前窗口 + * @param window GFX 窗口 + */ + void activeWindow(scene::RenderWindow *); + + /** + * @zh + * 重置累计时间 + */ + void resetCumulativeTime(); + + /** + * @zh + * 每帧执行函数 + * @param deltaTime 间隔时间 + */ + void frameMove(float deltaTime, int32_t totalFrames); // TODO(): c++ doesn't have a Director, so totalFrames need to be set from JS + + /** + * @zh + * 创建窗口 + * @param info GFX 窗口描述信息 + */ + scene::RenderWindow *createWindow(scene::IRenderWindowInfo &); + + /** + * @zh + * 销毁指定的窗口 + * @param window GFX 窗口 + */ + void destroyWindow(scene::RenderWindow *); + + /** + * @zh + * 销毁全部窗口 + */ + void destroyWindows(); + + /** + * @zh + * 创建渲染场景 + * @param info 渲染场景描述信息 + */ + scene::RenderScene *createScene(const scene::IRenderSceneInfo &); + + /** + * @zh + * 销毁指定的渲染场景 + * @param scene 渲染场景 + */ + void destroyScene(scene::RenderScene *); + + /** + * @zh + * 销毁全部场景 + */ + void destroyScenes(); + + template ::value>> + T *createModel() { + //cjh TODO: need use model pool? + T *model = new T(); + model->initialize(); + return model; + } + + void destroyModel(scene::Model *model); + + template ::value>> + T *createLight() { + //TODO(xwx): need use model pool? + T *light = new T(); + light->initialize(); + return light; + } + + void destroyLight(scene::Light *light); + + inline scene::Camera *createCamera() const { + return new scene::Camera(_device); + } + + /** + * @zh + * GFX 设备 + */ + inline gfx::Device *getDevice() const { return _device; } + + /** + * @zh + * 主窗口 + */ + inline scene::RenderWindow *getMainWindow() const { return _mainWindow.get(); } + + /** + * @zh + * 当前窗口 + */ + inline void setCurWindow(scene::RenderWindow *window) { _curWindow = window; } + + inline scene::RenderWindow *getCurWindow() const { return _curWindow.get(); } + + /** + * @zh + * 临时窗口(用于数据传输) + */ + void setTempWindow(scene::RenderWindow *window) { _tempWindow = window; } + + inline scene::RenderWindow *getTempWindow() const { return _tempWindow.get(); } + + /** + * @zh + * 窗口列表 + */ + inline const std::vector> &getWindows() const { return _windows; } + + /** + * @zh + * 渲染管线 + */ + inline pipeline::RenderPipeline *getPipeline() const { return _pipeline.get(); } + + /** + * @zh + * UI实例 + * 引擎内部使用,用户无需调用此接口 + */ + inline scene::DrawBatch2D *getBatcher2D() const { return _batcher2D; } + + /** + * @zh + * 场景列表 + */ + inline const std::vector> &getScenes() const { return _scenes; } + + /** + * @zh + * 累计时间(秒) + */ + inline float getCumulativeTime() const { return _cumulativeTime; } + + /** + * @zh + * 帧时间(秒) + */ + inline float getFrameTime() const { return _frameTime; } + + /** + * @zh + * 一秒内的累计帧数 + */ + inline uint32_t getFrameCount() const { return _frameCount; } + + /** + * @zh + * 每秒帧率 + */ + inline uint32_t getFps() const { return _fps; } + + /** + * @zh + * 每秒固定帧率 + */ + void setFixedFPS(uint32_t fps) { _fixedFPS = fps; } + + inline uint32_t getFixedFPS() const { return _fixedFPS; } + + // inline DataPoolManager *getDataPoolManager() { return _dataPoolMgr.get(); } + + inline bool isUsingDeferredPipeline() const { return _useDeferredPipeline; } + + inline CallbacksInvoker *getEventProcessor() const { return _eventProcessor; } + +private: + gfx::Device * _device{nullptr}; + gfx::Swapchain * _swapchain{nullptr}; + IntrusivePtr _mainWindow; + IntrusivePtr _curWindow; + IntrusivePtr _tempWindow; + std::vector> _windows; + IntrusivePtr _pipeline{nullptr}; + scene::DrawBatch2D * _batcher2D{nullptr}; + // IntrusivePtr _dataPoolMgr; + std::vector> _scenes; + memop::Pool * _cameraPool{nullptr}; + float _cumulativeTime{0.F}; + float _frameTime{0.F}; + float _fpsTime{0.F}; + uint32_t _frameCount{0}; + uint32_t _fps{0}; + uint32_t _fixedFPS{0}; + bool _useDeferredPipeline{false}; + CallbacksInvoker * _eventProcessor{nullptr}; + + // Cache std::vector to avoid allocate every frame in frameMove + std::vector _cameraList; + std::vector _swapchains; + // +}; + +} // namespace cc diff --git a/native/cocos/core/System.h b/native/cocos/core/System.h new file mode 100644 index 0000000000..655d690d6c --- /dev/null +++ b/native/cocos/core/System.h @@ -0,0 +1,101 @@ +/**************************************************************************** + 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 +#include "base/Macros.h" + +namespace cc { + +namespace core { + +struct ISchedulable { + std::string id; + std::string uuid; +}; + +enum struct Priority : uint32_t { + LOW = 0, + MEDIUM = 100, + HIGH = 200, + SCHEDULER = UINT32_MAX, +}; + +class System : public ISchedulable { +private: + /* data */ +protected: + Priority _priority{Priority::LOW}; + bool _executeInEditMode{false}; + +public: + /** + * @en Sorting between different systems. + * @zh 不同系统间排序。 + * @param a System a + * @param b System b + */ + static int32_t sortByPriority(System *a, System *b) { + if (a->_priority < b->_priority) return 1; + if (a->_priority > b->_priority) return -1; + return 0; + } + + System() = default; + virtual ~System() = default; + + inline const std::string &getId() { return id; } + inline void setId(std::string &s) { id = s; } + + inline Priority getPriority() const { return _priority; } + inline void setPriority(Priority i) { _priority = i; } + + inline bool getExecuteInEditMode() const { return _executeInEditMode; } + inline void setExecuteInEditMode(bool b) { _executeInEditMode = b; } + + /** + * @en Init the system, will be invoked by [[Director]] when registered, should be implemented if needed. + * @zh 系统初始化函数,会在注册时被 [[Director]] 调用,如果需要的话应该由子类实现 + */ + virtual void init() = 0; + + /** + * @en Update function of the system, it will be invoked between all components update phase and late update phase. + * @zh 系统的帧更新函数,它会在所有组件的 update 和 lateUpdate 之间被调用 + * @param dt Delta time after the last frame + */ + virtual void update(float dt) = 0; + + /** + * @en Post update function of the system, it will be invoked after all components late update phase and before the rendering process. + * @zh 系统的帧后处理函数,它会在所有组件的 lateUpdate 之后以及渲染之前被调用 + * @param dt Delta time after the last frame + */ + virtual void postUpdate(float dt) = 0; +}; + +} // namespace core + +} // namespace cc diff --git a/native/cocos/core/TypedArray.cpp b/native/cocos/core/TypedArray.cpp new file mode 100644 index 0000000000..649d027e4c --- /dev/null +++ b/native/cocos/core/TypedArray.cpp @@ -0,0 +1,125 @@ +/**************************************************************************** + 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/TypedArray.h" + +namespace cc { + +uint32_t getTypedArrayLength(const TypedArray &arr) { +#define TYPEDARRAY_GET_SIZE(type) \ + do { \ + auto *p = cc::get_if(&arr); \ + if (p != nullptr) { \ + return p->length(); \ + } \ + } while (false) + + TYPEDARRAY_GET_SIZE(Float32Array); + TYPEDARRAY_GET_SIZE(Uint32Array); + TYPEDARRAY_GET_SIZE(Uint16Array); + TYPEDARRAY_GET_SIZE(Uint8Array); + TYPEDARRAY_GET_SIZE(Int32Array); + TYPEDARRAY_GET_SIZE(Int16Array); + TYPEDARRAY_GET_SIZE(Int8Array); + TYPEDARRAY_GET_SIZE(Float64Array); + +#undef TYPEDARRAY_GET_SIZE + return 0; +} + +uint32_t getTypedArrayBytesPerElement(const TypedArray &arr) { +#define TYPEDARRAY_GET_BYTES_PER_ELEMENT(type) \ + do { \ + auto *p = cc::get_if(&arr); \ + if (p != nullptr) { \ + return type::BYTES_PER_ELEMENT; \ + } \ + } while (false) + + TYPEDARRAY_GET_BYTES_PER_ELEMENT(Float32Array); + TYPEDARRAY_GET_BYTES_PER_ELEMENT(Uint32Array); + TYPEDARRAY_GET_BYTES_PER_ELEMENT(Uint16Array); + TYPEDARRAY_GET_BYTES_PER_ELEMENT(Uint8Array); + TYPEDARRAY_GET_BYTES_PER_ELEMENT(Int32Array); + TYPEDARRAY_GET_BYTES_PER_ELEMENT(Int16Array); + TYPEDARRAY_GET_BYTES_PER_ELEMENT(Int8Array); + TYPEDARRAY_GET_BYTES_PER_ELEMENT(Float64Array); + +#undef TYPEDARRAY_GET_BYPES_PER_ELEMENT + return 0; +} + +void setTypedArrayValue(TypedArray &arr, uint32_t idx, const TypedArrayElementType &value) { +#define TYPEDARRAY_SET_VALUE(type, elemType) \ + do { \ + auto *p = cc::get_if(&value); \ + if (p != nullptr) { \ + if (cc::holds_alternative(arr)) { \ + cc::get(arr)[idx] = static_cast(*p); \ + return; \ + } \ + if (cc::holds_alternative(arr)) { \ + cc::get(arr)[idx] = static_cast(*p); \ + return; \ + } \ + if (cc::holds_alternative(arr)) { \ + cc::get(arr)[idx] = static_cast(*p); \ + return; \ + } \ + if (cc::holds_alternative(arr)) { \ + cc::get(arr)[idx] = static_cast(*p); \ + return; \ + } \ + if (cc::holds_alternative(arr)) { \ + cc::get(arr)[idx] = static_cast(*p); \ + return; \ + } \ + if (cc::holds_alternative(arr)) { \ + cc::get(arr)[idx] = static_cast(*p); \ + return; \ + } \ + if (cc::holds_alternative(arr)) { \ + cc::get(arr)[idx] = static_cast(*p); \ + return; \ + } \ + if (cc::holds_alternative(arr)) { \ + cc::get(arr)[idx] = static_cast(*p); \ + return; \ + } \ + } \ + } while (false) + + TYPEDARRAY_SET_VALUE(Float32Array, float); + TYPEDARRAY_SET_VALUE(Uint32Array, uint32_t); + TYPEDARRAY_SET_VALUE(Uint16Array, uint16_t); + TYPEDARRAY_SET_VALUE(Uint8Array, uint8_t); + TYPEDARRAY_SET_VALUE(Int32Array, int32_t); + TYPEDARRAY_SET_VALUE(Int16Array, int16_t); + TYPEDARRAY_SET_VALUE(Int8Array, int8_t); // NOLINT + TYPEDARRAY_SET_VALUE(Float64Array, double); +#undef TYPEDARRAY_SET_VALUE +} + +} // namespace cc diff --git a/native/cocos/core/TypedArray.h b/native/cocos/core/TypedArray.h new file mode 100644 index 0000000000..94aba34cec --- /dev/null +++ b/native/cocos/core/TypedArray.h @@ -0,0 +1,382 @@ +/**************************************************************************** + 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 +#include +#include +#include "base/TypeDef.h" +#include "bindings/jswrapper/Object.h" +#include "cocos/base/Variant.h" +#include "core/ArrayBuffer.h" + +namespace cc { + +template +se::Object::TypedArrayType toTypedArrayType() { + return se::Object::TypedArrayType::NONE; +} + +template <> +inline se::Object::TypedArrayType toTypedArrayType() { + return se::Object::TypedArrayType::INT8; +} + +template <> +inline se::Object::TypedArrayType toTypedArrayType() { + return se::Object::TypedArrayType::INT16; +} + +template <> +inline se::Object::TypedArrayType toTypedArrayType() { + return se::Object::TypedArrayType::INT32; +} + +template <> +inline se::Object::TypedArrayType toTypedArrayType() { + return se::Object::TypedArrayType::UINT8; +} + +template <> +inline se::Object::TypedArrayType toTypedArrayType() { + return se::Object::TypedArrayType::UINT16; +} + +template <> +inline se::Object::TypedArrayType toTypedArrayType() { + return se::Object::TypedArrayType::UINT32; +} + +template <> +inline se::Object::TypedArrayType toTypedArrayType() { + return se::Object::TypedArrayType::FLOAT32; +} + +template <> +inline se::Object::TypedArrayType toTypedArrayType() { + return se::Object::TypedArrayType::FLOAT64; +} + +template +class TypedArrayTemp { +public: + static constexpr uint32_t BYTES_PER_ELEMENT{sizeof(T)}; + using value_type = T; + + TypedArrayTemp() = default; + + explicit TypedArrayTemp(uint32_t length) { + reset(length); + } + + explicit TypedArrayTemp(ArrayBuffer *buffer) + : TypedArrayTemp(buffer, 0) {} + + TypedArrayTemp(ArrayBuffer *buffer, uint32_t byteOffset) + : TypedArrayTemp(buffer, byteOffset, (buffer->byteLength() - byteOffset) / BYTES_PER_ELEMENT) {} + + TypedArrayTemp(ArrayBuffer *buffer, uint32_t byteOffset, uint32_t length) + : _buffer(buffer), + _byteOffset(byteOffset), + _byteLength(length * BYTES_PER_ELEMENT), + _byteEndPos(byteOffset + length * BYTES_PER_ELEMENT) { + CC_ASSERT(_byteEndPos <= _buffer->byteLength()); + _jsTypedArray = se::Object::createTypedArrayWithBuffer(toTypedArrayType(), buffer->getJSArrayBuffer(), byteOffset, _byteLength); + _jsTypedArray->root(); + } + + TypedArrayTemp(const TypedArrayTemp &o) { + *this = o; + } + + TypedArrayTemp(TypedArrayTemp &&o) noexcept { + *this = std::move(o); + } + + ~TypedArrayTemp() { + if (_jsTypedArray != nullptr) { + _jsTypedArray->unroot(); + _jsTypedArray->decRef(); + } + } + + TypedArrayTemp &operator=(const TypedArrayTemp &o) { + if (this != &o) { + setJSTypedArray(o._jsTypedArray); + } + return *this; + } + + TypedArrayTemp &operator=(TypedArrayTemp &&o) noexcept { + if (this != &o) { + _buffer = o._buffer; + _byteOffset = o._byteOffset; + _byteLength = o._byteLength; + _byteEndPos = o._byteEndPos; + _jsTypedArray = o._jsTypedArray; + + o._buffer = nullptr; + o._byteOffset = 0; + o._byteLength = 0; + o._byteEndPos = 0; + o._jsTypedArray = nullptr; + } + return *this; + } + + T &operator[](uint32_t idx) { + CC_ASSERT(idx < length()); + return *((reinterpret_cast(_buffer->_data + _byteOffset)) + idx); + } + + const T &operator[](uint32_t idx) const { + CC_ASSERT(idx < length()); + return *((reinterpret_cast(_buffer->_data + _byteOffset)) + idx); + } + + TypedArrayTemp subarray(uint32_t begin, uint32_t end) { + return TypedArrayTemp(_buffer, begin * BYTES_PER_ELEMENT, end - begin); + } + + TypedArrayTemp subarray(uint32_t begin) { + return TypedArrayTemp(_buffer, begin * BYTES_PER_ELEMENT); + } + + TypedArrayTemp slice() { + return slice(0); + } + + TypedArrayTemp slice(uint32_t start) { + return slice(start, _byteLength / BYTES_PER_ELEMENT); + } + + TypedArrayTemp slice(uint32_t start, uint32_t end) { + CC_ASSERT(end > start); + CC_ASSERT(start < (_byteLength / BYTES_PER_ELEMENT)); + CC_ASSERT(end <= (_byteLength / BYTES_PER_ELEMENT)); + uint32_t newBufByteLength = (end - start) * BYTES_PER_ELEMENT; + auto * buffer = new ArrayBuffer(newBufByteLength); + memcpy(buffer->getData(), _buffer->getData() + start * BYTES_PER_ELEMENT + _byteOffset, newBufByteLength); + return TypedArrayTemp(buffer); + } + + void set(ArrayBuffer *buffer) { + set(buffer, 0); + } + + void set(ArrayBuffer *buffer, uint32_t offset) { + CC_ASSERT(buffer->byteLength() + offset <= _byteEndPos); + CC_ASSERT(_buffer); + memcpy(_buffer->_data + offset, buffer->_data, buffer->byteLength()); + } + + template + void set(const TypedArrayTemp &array) { + set(array, 0); + } + + template + typename std::enable_if_t::value, void> + set(const TypedArrayTemp &array, uint32_t offset); + + template + typename std::enable_if_t::value, void> + set(const TypedArrayTemp &array, uint32_t offset); + + void reset(uint32_t length) { + if (_jsTypedArray != nullptr) { + _jsTypedArray->unroot(); + _jsTypedArray->decRef(); + _jsTypedArray = nullptr; + } + const uint32_t byteLength = length * BYTES_PER_ELEMENT; + _buffer = new ArrayBuffer(byteLength); + _byteLength = _buffer->byteLength(); + _byteOffset = 0; + _byteEndPos = byteLength; + _jsTypedArray = se::Object::createTypedArrayWithBuffer(toTypedArrayType(), _buffer->getJSArrayBuffer(), 0, byteLength); + _jsTypedArray->root(); + } + + inline ArrayBuffer *buffer() const { return _buffer; } + inline uint32_t byteLength() const { return _byteLength; } + inline uint32_t length() const { return _byteLength / BYTES_PER_ELEMENT; } + inline uint32_t byteOffset() const { return _byteOffset; } + inline bool empty() const { return _byteLength == 0; } + inline se::Object * getJSTypedArray() const { return _jsTypedArray; } + inline void setJSTypedArray(se::Object *typedArray) { + if (_jsTypedArray != nullptr) { + _jsTypedArray->unroot(); + _jsTypedArray->decRef(); + } + _jsTypedArray = typedArray; + + if (_jsTypedArray != nullptr) { + _jsTypedArray->root(); + _jsTypedArray->incRef(); + + se::Value tmpVal; + _jsTypedArray->getProperty("buffer", &tmpVal); + assert(tmpVal.isObject()); + assert(tmpVal.toObject()->isArrayBuffer()); + + _buffer = new ArrayBuffer(); + _buffer->setJSArrayBuffer(tmpVal.toObject()); + + _jsTypedArray->getProperty("byteOffset", &tmpVal); + assert(tmpVal.isNumber()); + _byteOffset = tmpVal.toUint32(); + + _jsTypedArray->getProperty("byteLength", &tmpVal); + assert(tmpVal.isNumber()); + _byteLength = tmpVal.toUint32(); + + _byteEndPos = _buffer->byteLength(); + } else { + _buffer = nullptr; + _byteOffset = 0; + _byteLength = 0; + _byteEndPos = 0; + } + } + +private: + ArrayBuffer::Ptr _buffer; + uint32_t _byteOffset{0}; + uint32_t _byteLength{0}; + uint32_t _byteEndPos{0}; + se::Object * _jsTypedArray{nullptr}; +}; + +template +template +typename std::enable_if_t::value, void> TypedArrayTemp::set(const TypedArrayTemp &array, uint32_t offset) { + CC_ASSERT(_buffer); + uint32_t dstByteOffset = offset * BYTES_PER_ELEMENT; + uint32_t srcByteOffset = array.byteOffset(); + uint32_t srcCount = array.length(); + CC_ASSERT(dstByteOffset + srcCount * TypedArrayTemp::BYTES_PER_ELEMENT <= _byteEndPos); + memcpy(_buffer->_data + dstByteOffset, array._buffer->_data + srcByteOffset, array.byteLength()); +} + +template +template +typename std::enable_if_t::value, void> TypedArrayTemp::set(const TypedArrayTemp &array, uint32_t offset) { + CC_ASSERT(_buffer); + uint32_t dstByteOffset = offset * BYTES_PER_ELEMENT; + uint32_t srcByteOffset = array.byteOffset(); + uint32_t srcCount = array.length(); + uint32_t remainCount = (_byteEndPos - dstByteOffset) / BYTES_PER_ELEMENT; + CC_ASSERT(srcCount <= remainCount); + for (uint32_t i = 0; i < srcCount; ++i) { + (*this)[offset + i] = reinterpret_cast(array[i]); + } +} + +using Int8Array = TypedArrayTemp; +using Int16Array = TypedArrayTemp; +using Int32Array = TypedArrayTemp; +using Uint8Array = TypedArrayTemp; +using Uint16Array = TypedArrayTemp; +using Uint32Array = TypedArrayTemp; +using Float32Array = TypedArrayTemp; +using Float64Array = TypedArrayTemp; +using TypedArray = cc::variant; +using TypedArrayElementType = cc::variant; + +uint32_t getTypedArrayLength(const TypedArray &arr); +uint32_t getTypedArrayBytesPerElement(const TypedArray &arr); + +template +T getTypedArrayValue(const TypedArray &arr, uint32_t idx) { +#define TYPEDARRAY_GET_VALUE(type) \ + do { \ + auto *p = cc::get_if(&arr); \ + if (p != nullptr) { \ + return static_cast((*p)[idx]); \ + } \ + } while (false) + + TYPEDARRAY_GET_VALUE(Float32Array); + TYPEDARRAY_GET_VALUE(Uint32Array); + TYPEDARRAY_GET_VALUE(Uint16Array); + TYPEDARRAY_GET_VALUE(Uint8Array); + TYPEDARRAY_GET_VALUE(Int32Array); + TYPEDARRAY_GET_VALUE(Int16Array); + TYPEDARRAY_GET_VALUE(Int8Array); + TYPEDARRAY_GET_VALUE(Float64Array); +#undef TYPEDARRAY_GET_VALUE + + return 0; +} + +void setTypedArrayValue(TypedArray &arr, uint32_t idx, const TypedArrayElementType &value); + +template +T &getTypedArrayValueRef(const TypedArray &arr, uint32_t idx) { +#define TYPEDARRAY_GET_VALUE_REF(type) \ + do { \ + auto *p = cc::get_if(&arr); \ + if (p != nullptr) { \ + return (*p)[idx]; \ + } \ + } while (false) + + TYPEDARRAY_GET_VALUE_REF(Float32Array); + TYPEDARRAY_GET_VALUE_REF(Uint32Array); + TYPEDARRAY_GET_VALUE_REF(Uint16Array); + TYPEDARRAY_GET_VALUE_REF(Uint8Array); + TYPEDARRAY_GET_VALUE_REF(Int32Array); + TYPEDARRAY_GET_VALUE_REF(Int16Array); + TYPEDARRAY_GET_VALUE_REF(Int8Array); + TYPEDARRAY_GET_VALUE_REF(Float64Array); +#undef TYPEDARRAY_GET_VALUE_REF +} + +template +T getTypedArrayElementValue(const TypedArrayElementType &element) { +#define CAST_TO_T(type) \ + do { \ + auto *p = cc::get_if(&element); \ + if (p != nullptr) { \ + return static_cast(*p); \ + } \ + } while (false) + + CAST_TO_T(float); + CAST_TO_T(uint32_t); + CAST_TO_T(uint16_t); + CAST_TO_T(uint8_t); + CAST_TO_T(int32_t); + CAST_TO_T(int16_t); + CAST_TO_T(int8_t); + CAST_TO_T(double); +#undef CAST_TO_T + + return 0; +} + +} // namespace cc diff --git a/native/cocos/core/Types.cpp b/native/cocos/core/Types.cpp new file mode 100644 index 0000000000..1c19e79558 --- /dev/null +++ b/native/cocos/core/Types.cpp @@ -0,0 +1,33 @@ +/**************************************************************************** + 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/Types.h" + +namespace cc { + +namespace typedarray { +} // namespace typedarray + +} // namespace cc diff --git a/native/cocos/core/Types.h b/native/cocos/core/Types.h new file mode 100644 index 0000000000..c6bf553fa0 --- /dev/null +++ b/native/cocos/core/Types.h @@ -0,0 +1,74 @@ +/**************************************************************************** + 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 +#include +#include +#include +#include "cocos/base/Optional.h" + +#include + +#include "base/TypeDef.h" +#include "base/Value.h" +#include "math/Vec3.h" + +namespace cc { + +struct Error { + cc::optional msg; +}; + +using HTMLElement = void *; + +struct BoundingBox { + Vec3 min; + Vec3 max; +}; + +struct VertexIdChannel { + uint32_t stream{0}; + uint32_t index{0}; +}; + +struct NativeDep { + std::string uuid; + std::string ext; + bool __isNative__{false}; // NOLINT(bugprone-reserved-identifier) + + explicit NativeDep() = default; + + explicit NativeDep(bool isNative, std::string uuid, std::string ext) + : uuid(std::move(uuid)), ext(std::move(ext)), __isNative__(isNative), _isValid(true) {} + + inline bool isValid() const { return _isValid; } + +private: + bool _isValid{false}; +}; + +} // namespace cc diff --git a/native/cocos/core/animation/SkeletalAnimationUtils.cpp b/native/cocos/core/animation/SkeletalAnimationUtils.cpp new file mode 100644 index 0000000000..dda70388d5 --- /dev/null +++ b/native/cocos/core/animation/SkeletalAnimationUtils.cpp @@ -0,0 +1,116 @@ +/**************************************************************************** + 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/animation/SkeletalAnimationUtils.h" +#include "core/scene-graph/Node.h" + +namespace cc { + +namespace { +std::vector stack; //cjh TODO: how to release ? +std::unordered_map pool; +} // namespace + +Mat4 getWorldMatrix(IJointTransform *transform, int32_t stamp) { + uint32_t i = 0; + Mat4 * res = nullptr; + while (transform != nullptr) { + if ((transform->stamp == stamp || transform->stamp + 1 == stamp) && !transform->node->getChangedFlags()) { + res = &transform->world; + transform->stamp = stamp; + break; + } + transform->stamp = stamp; + stack.resize(i + 1); + stack[i++] = transform; + transform = transform->parent; + } + while (i > 0) { + transform = stack[--i]; + stack[i] = nullptr; + const auto *node = transform->node; + CC_ASSERT(node != nullptr); + Mat4::fromRTS(node->getRotation(), node->getPosition(), node->getScale(), &transform->local); + if (res != nullptr) { + Mat4::multiply(*res, transform->local, &transform->world); + } else { + transform->world = transform->local; + } + res = &transform->world; + } + return res != nullptr ? *res : Mat4::IDENTITY; +} + +IJointTransform *getTransform(Node *node, Node *root) { + IJointTransform *joint = nullptr; + uint32_t i = 0; + while (node != root) { + const std::string &id = node->getUuid(); + auto iter = pool.find(id); + if (iter != pool.end()) { + joint = iter->second; + break; + } + // TODO(): object reuse + joint = pool[id] = new IJointTransform{ + node, + Mat4(), + Mat4(), + -1, + nullptr}; + + stack.resize(i + 1); + stack[i++] = joint; + node = node->getParent(); + joint = nullptr; + } + IJointTransform *child; + while (i > 0) { + child = stack[--i]; + stack[i] = nullptr; + child->parent = joint; + joint = child; + } + return joint; +} + +void deleteTransform(Node *node) { + IJointTransform *transform = nullptr; + auto iter = pool.find(node->getUuid()); + if (iter != pool.end()) { + transform = iter->second; + } + + while (transform != nullptr) { + iter = pool.find(transform->node->getUuid()); + if (iter != pool.end()) { + // delete iter->second; + pool.erase(iter); + } + transform = transform->parent; + } +} + +} // namespace cc diff --git a/native/cocos/core/animation/SkeletalAnimationUtils.h b/native/cocos/core/animation/SkeletalAnimationUtils.h new file mode 100644 index 0000000000..32bd833962 --- /dev/null +++ b/native/cocos/core/animation/SkeletalAnimationUtils.h @@ -0,0 +1,48 @@ +/**************************************************************************** + 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 "math/Mat4.h" + +namespace cc { + +class Node; + +struct IJointTransform { + Node * node{nullptr}; + Mat4 local; + Mat4 world; + int stamp{-1}; + struct IJointTransform *parent{nullptr}; +}; + +Mat4 getWorldMatrix(IJointTransform *transform, int32_t stamp); + +IJointTransform *getTransform(Node *node, Node *root); + +void deleteTransform(Node *node); + +} // namespace cc diff --git a/native/cocos/core/assets/Asset.cpp b/native/cocos/core/assets/Asset.cpp new file mode 100644 index 0000000000..6e9479088c --- /dev/null +++ b/native/cocos/core/assets/Asset.cpp @@ -0,0 +1,103 @@ +/**************************************************************************** + 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/assets/Asset.h" +#include "base/Macros.h" +#include "core/utils/Path.h" + +namespace cc { + +//cjh TODO: +std::string getAssetUrlWithUuid(const std::string &uuid, bool isNative, const std::string &nativeExt, const std::string &nativeName = "") { //NOLINT + return ""; +} + +std::string Asset::getNativeUrl() const { + if (_nativeUrl.empty()) { + if (_native.empty()) { + return ""; + } + const auto &name = _native; + if (name[0] == 47) { // '/' + // remove library tag + // not imported in library, just created on-the-fly + return name.substr(1); + } + + if (name[0] == 46) { // '.' + // imported in dir where json exist + const_cast(this)->_nativeUrl = getAssetUrlWithUuid(_uuid, true, name); + } else { + // imported in an independent dir + const_cast(this)->_nativeUrl = getAssetUrlWithUuid(_uuid, true, extname(name), name); + } + } + return _nativeUrl; +} + +NativeDep Asset::getNativeDep() const { + if (!_native.empty()) { + return NativeDep(true, _uuid, _native); + } + return NativeDep(); +} + +void Asset::setRawAsset(const std::string &filename, bool inLibrary /* = true*/) { + if (inLibrary) { + _native = filename; + } else { + _native = "/" + filename; // simply use '/' to tag location where is not in the library + } +} + +Asset *Asset::addAssetRef() { + ++_ref; + return this; +} + +Asset *Asset::decAssetRef(bool autoRelease /* = true*/) { + if (_ref > 0) { + --_ref; + } + + if (autoRelease) { + //cjh TODO: + } + return this; +} + +void Asset::initDefault(const cc::optional &uuid) { + if (uuid.has_value()) { + _uuid = uuid.value(); + } + _isDefault = true; +} + +bool Asset::destroy() { + //cjh TODO: debug(getError(12101, this._uuid)); + return Super::destroy(); +} + +} // namespace cc diff --git a/native/cocos/core/assets/Asset.h b/native/cocos/core/assets/Asset.h new file mode 100644 index 0000000000..6c79e4b84c --- /dev/null +++ b/native/cocos/core/assets/Asset.h @@ -0,0 +1,155 @@ +/**************************************************************************** + 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 +#include "cocos/base/Any.h" +#include "cocos/base/Optional.h" + +#include "base/Macros.h" +#include "core/Types.h" +#include "core/data/Object.h" +#include "core/event/CallbacksInvoker.h" + +namespace cc { + +class Node; + +class Asset : public CCObject, public EventTarget { +public: + using Super = CCObject; + + Asset() = default; + ~Asset() override = default; + + /** + * @en + * Returns the url of this asset's native object, if none it will returns an empty string. + * @zh + * 返回该资源对应的目标平台资源的 URL,如果没有将返回一个空字符串。 + * @readOnly + */ + std::string getNativeUrl() const; + + NativeDep getNativeDep() const; + + inline const std::string &getUuid() const { return _uuid; } + inline void setUuid(const std::string &uuid) { _uuid = uuid; } + + /** + * @en + * The underlying native asset of this asset if one is available.
+ * This property can be used to access additional details or functionality related to the asset.
+ * This property will be initialized by the loader if `_native` is available. + * @zh + * 此资源的基础资源(如果有)。 此属性可用于访问与资源相关的其他详细信息或功能。
+ * 如果`_native`可用,则此属性将由加载器初始化。 + * @default null + * @private + */ + virtual cc::any getNativeAsset() const { + return _file; + } + + virtual void setNativeAsset(const cc::any &obj) { + _file = obj; + } + + /** + * @param error - null or the error info + * @param node - the created node or null + */ + using CreateNodeCallback = std::function; + /** + * @en + * Create a new node using this asset in the scene.
+ * If this type of asset don't have its corresponding node type, this method should be null. + * @zh + * 使用该资源在场景中创建一个新节点。
+ * 如果这类资源没有相应的节点类型,该方法应该是空的。 + */ + virtual void createNode(const CreateNodeCallback &cb) {} + + Asset * addAssetRef(); + Asset * decAssetRef(bool autoRelease = true); + inline uint32_t getRefCount() const { return _ref; } + + virtual void onLoaded() {} + + virtual void initDefault(const cc::optional &uuid); + virtual bool validate() const { return true; } + + bool isDefault() const { return _isDefault; } + + bool destroy() override; + + // SERIALIZATION + + /** + * @return + */ + virtual cc::any serialize(const cc::any & /*ctxForExporting*/) { return cc::any{}; }; + + /** + * + * @param data + */ + virtual void deserialize(const cc::any &serializedData, const cc::any &handle) {} + + std::string toString() const override { return _nativeUrl; } + +protected: + /** + * @en + * Set native file name for this asset. + * @zh + * 为此资源设置原始文件名。 + * @seealso nativeUrl + * + * @param filename + * @param inLibrary + * @private + */ + void setRawAsset(const std::string &filename, bool inLibrary = true); + + // Make _native, _nativeUrl public for deserialization +public: + std::string _native; + std::string _nativeUrl; + +protected: + std::string _uuid; + + cc::any _file; + uint32_t _ref{0}; + + bool _loaded{true}; + bool _isDefault{false}; + + CC_DISALLOW_COPY_MOVE_ASSIGN(Asset); +}; + +} // namespace cc diff --git a/native/cocos/core/assets/AssetEnum.cpp b/native/cocos/core/assets/AssetEnum.cpp new file mode 100644 index 0000000000..a6e370d3e9 --- /dev/null +++ b/native/cocos/core/assets/AssetEnum.cpp @@ -0,0 +1,26 @@ +/**************************************************************************** + 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/assets/AssetEnum.h" diff --git a/native/cocos/core/assets/AssetEnum.h b/native/cocos/core/assets/AssetEnum.h new file mode 100644 index 0000000000..3817415a51 --- /dev/null +++ b/native/cocos/core/assets/AssetEnum.h @@ -0,0 +1,306 @@ +/**************************************************************************** + 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 "renderer/gfx-base/GFXDef.h" + +namespace cc { + +// define a specified number for the pixel format which gfx do not have a standard definition. +#define CUSTOM_PIXEL_FORMAT (1024) + +/** + * @en + * The texture pixel format, default value is RGBA8888,
+ * you should note that textures loaded by normal image files (png, jpg) can only support RGBA8888 format,
+ * other formats are supported by compressed file types or raw data. + * @zh + * 纹理像素格式,默认值为RGBA8888,
+ * 你应该注意到普通图像文件(png,jpg)加载的纹理只能支持RGBA8888格式,
+ * 压缩文件类型或原始数据支持其他格式。 + */ +enum class PixelFormat : uint32_t { + /** + * @en + * 16-bit pixel format containing red, green and blue channels + * @zh + * 包含 RGB 通道的 16 位纹理。 + */ + RGB565 = static_cast(gfx::Format::R5G6B5), + /** + * @en + * 16-bit pixel format containing red, green, blue channels with 5 bits per channel and one bit alpha channel: RGB5A1 + * @zh + * 包含 RGB(分别占 5 bits)和 1 bit 的 alpha 通道的 16 位纹理:RGB5A1。 + */ + RGB5A1 = static_cast(gfx::Format::RGB5A1), + /** + * @en + * 16-bit pixel format containing red, green, blue and alpha channels: RGBA4444 + * @zh + * 包含 RGBA 通道的 16 位纹理:RGBA4444。 + */ + RGBA4444 = static_cast(gfx::Format::RGBA4), + /** + * @en + * 24-bit pixel format containing red, green and blue channels: RGB888 + * @zh + * 包含 RGB 通道的 24 位纹理:RGB888。 + */ + RGB888 = static_cast(gfx::Format::RGB8), + /** + * @en + * 32-bit float pixel format containing red, green and blue channels: RGBA32F + * @zh + * 包含 RGB 通道的 32 位浮点数像素格式:RGBA32F。 + */ + RGB32F = static_cast(gfx::Format::RGB32F), + /** + * @en + * 32-bit pixel format containing red, green, blue and alpha channels: RGBA8888 + * @zh + * 包含 RGBA 四通道的 32 位整形像素格式:RGBA8888。 + */ + RGBA8888 = static_cast(gfx::Format::RGBA8), + /** + * @en + * 32-bit float pixel format containing red, green, blue and alpha channels: RGBA32F + * @zh + * 32位浮点数像素格式:RGBA32F。 + */ + RGBA32F = static_cast(gfx::Format::RGBA32F), + /** + * @en + * 8-bit pixel format used as masks + * @zh + * 用作蒙版的8位纹理。 + */ + A8 = static_cast(gfx::Format::A8), + /** + * @en + * 8-bit intensity pixel format + * @zh + * 8位强度纹理。 + */ + I8 = static_cast(gfx::Format::L8), + /** + * @en + * 16-bit pixel format used as masks + * @zh + * 用作蒙版的16位纹理。 + */ + AI8 = static_cast(gfx::Format::LA8), + /** + * @en A pixel format containing red, green, and blue channels that is PVR 2bpp compressed. + * @zh 包含 RGB 通道的 PVR 2BPP 压缩纹理格式 + */ + RGB_PVRTC_2BPPV1 = static_cast(gfx::Format::PVRTC_RGB2), + /** + * @en A pixel format containing red, green, blue, and alpha channels that is PVR 2bpp compressed. + * @zh 包含 RGBA 通道的 PVR 2BPP 压缩纹理格式 + */ + RGBA_PVRTC_2BPPV1 = static_cast(gfx::Format::PVRTC_RGBA2), + /** + * @en A pixel format containing red, green, blue, and alpha channels that is PVR 2bpp compressed. + * RGB_A_PVRTC_2BPPV1 texture is a 2x height RGB_PVRTC_2BPPV1 format texture. + * It separate the origin alpha channel to the bottom half atlas, the origin rgb channel to the top half atlas. + * @zh 包含 RGBA 通道的 PVR 2BPP 压缩纹理格式 + * 这种压缩纹理格式贴图的高度是普通 RGB_PVRTC_2BPPV1 贴图高度的两倍,使用上半部分作为原始 RGB 通道数据,下半部分用来存储透明通道数据。 + */ + RGB_A_PVRTC_2BPPV1 = CUSTOM_PIXEL_FORMAT + 1, + /** + * @en A pixel format containing red, green, and blue channels that is PVR 4bpp compressed. + * @zh 包含 RGB 通道的 PVR 4BPP 压缩纹理格式 + */ + RGB_PVRTC_4BPPV1 = static_cast(gfx::Format::PVRTC_RGB4), + /** + * @en A pixel format containing red, green, blue and alpha channels that is PVR 4bpp compressed. + * @zh 包含 RGBA 通道的 PVR 4BPP 压缩纹理格式 + */ + RGBA_PVRTC_4BPPV1 = static_cast(gfx::Format::PVRTC_RGBA4), + /** + * @en A pixel format containing red, green, blue, and alpha channels that is PVR 4bpp compressed. + * RGB_A_PVRTC_4BPPV1 texture is a 2x height RGB_PVRTC_4BPPV1 format texture. + * It separate the origin alpha channel to the bottom half atlas, the origin rgb channel to the top half atlas. + * @zh 包含 RGBA 通道的 PVR 4BPP 压缩纹理格式 + * 这种压缩纹理格式贴图的高度是普通 RGB_PVRTC_4BPPV1 贴图高度的两倍,使用上半部分作为原始 RGB 通道数据,下半部分用来存储透明通道数据。 + */ + RGB_A_PVRTC_4BPPV1 = CUSTOM_PIXEL_FORMAT + 2, + /** + * @en A pixel format containing red, green, and blue channels that is ETC1 compressed. + * @zh 包含 RGB 通道的 ETC1 压缩纹理格式 + */ + RGB_ETC1 = static_cast(gfx::Format::ETC_RGB8), + /** + * @en A pixel format containing red, green, blue, and alpha channels that is ETC1 compressed. + * @zh 包含 RGBA 通道的 ETC1 压缩纹理格式 + */ + RGBA_ETC1 = CUSTOM_PIXEL_FORMAT + 3, + /** + * @en A pixel format containing red, green, and blue channels that is ETC2 compressed. + * @zh 包含 RGB 通道的 ETC2 压缩纹理格式 + */ + RGB_ETC2 = static_cast(gfx::Format::ETC2_RGB8), + /** + * @en A pixel format containing red, green, blue, and alpha channels that is ETC2 compressed. + * @zh 包含 RGBA 通道的 ETC2 压缩纹理格式 + */ + RGBA_ETC2 = static_cast(gfx::Format::ETC2_RGBA8), + + /** + * @en A pixel format containing red, green, blue, and alpha channels that is ASTC compressed with 4x4 block size. + * @zh 包含 RGBA 通道的 ASTC 压缩纹理格式,压缩分块大小为 4x4 + */ + RGBA_ASTC_4X4 = static_cast(gfx::Format::ASTC_RGBA_4X4), + /** + * @en A pixel format containing red, green, blue, and alpha channels that is ASTC compressed with 5x4 block size. + * @zh 包含 RGBA 通道的 ASTC 压缩纹理格式,压缩分块大小为 5x4 + */ + RGBA_ASTC_5X4 = static_cast(gfx::Format::ASTC_RGBA_5X4), + /** + * @en A pixel format containing red, green, blue, and alpha channels that is ASTC compressed with 5x5 block size. + * @zh 包含 RGBA 通道的 ASTC 压缩纹理格式,压缩分块大小为 5x5 + */ + RGBA_ASTC_5X5 = static_cast(gfx::Format::ASTC_RGBA_5X5), + /** + * @en A pixel format containing red, green, blue, and alpha channels that is ASTC compressed with 6x5 block size. + * @zh 包含 RGBA 通道的 ASTC 压缩纹理格式,压缩分块大小为 6x5 + */ + RGBA_ASTC_6X5 = static_cast(gfx::Format::ASTC_RGBA_6X5), + /** + * @en A pixel format containing red, green, blue, and alpha channels that is ASTC compressed with 6x6 block size. + * @zh 包含 RGBA 通道的 ASTC 压缩纹理格式,压缩分块大小为 6x6 + */ + RGBA_ASTC_6X6 = static_cast(gfx::Format::ASTC_RGBA_6X6), + /** + * @en A pixel format containing red, green, blue, and alpha channels that is ASTC compressed with 8x5 block size. + * @zh 包含 RGBA 通道的 ASTC 压缩纹理格式,压缩分块大小为 8x5 + */ + RGBA_ASTC_8X5 = static_cast(gfx::Format::ASTC_RGBA_8X5), + /** + * @en A pixel format containing red, green, blue, and alpha channels that is ASTC compressed with 8x6 block size. + * @zh 包含 RGBA 通道的 ASTC 压缩纹理格式,压缩分块大小为 8x6 + */ + RGBA_ASTC_8X6 = static_cast(gfx::Format::ASTC_RGBA_8X6), + /** + * @en A pixel format containing red, green, blue, and alpha channels that is ASTC compressed with 8x8 block size. + * @zh 包含 RGBA 通道的 ASTC 压缩纹理格式,压缩分块大小为 8x8 + */ + RGBA_ASTC_8X8 = static_cast(gfx::Format::ASTC_RGBA_8X8), + /** + * @en A pixel format containing red, green, blue, and alpha channels that is ASTC compressed with 10x5 block size. + * @zh 包含 RGBA 通道的 ASTC 压缩纹理格式,压缩分块大小为 10x5 + */ + RGBA_ASTC_10X5 = static_cast(gfx::Format::ASTC_RGBA_10X5), + /** + * @en A pixel format containing red, green, blue, and alpha channels that is ASTC compressed with 10x6 block size. + * @zh 包含 RGBA 通道的 ASTC 压缩纹理格式,压缩分块大小为 10x6 + */ + RGBA_ASTC_10X6 = static_cast(gfx::Format::ASTC_RGBA_10X6), + /** + * @en A pixel format containing red, green, blue, and alpha channels that is ASTC compressed with 10x8 block size. + * @zh 包含 RGBA 通道的 ASTC 压缩纹理格式,压缩分块大小为 10x8 + */ + RGBA_ASTC_10X8 = static_cast(gfx::Format::ASTC_RGBA_10X8), + /** + * @en A pixel format containing red, green, blue, and alpha channels that is ASTC compressed with 10x10 block size. + * @zh 包含 RGBA 通道的 ASTC 压缩纹理格式,压缩分块大小为 10x10 + */ + RGBA_ASTC_10X10 = static_cast(gfx::Format::ASTC_RGBA_10X10), + /** + * @en A pixel format containing red, green, blue, and alpha channels that is ASTC compressed with 12x10 block size. + * @zh 包含 RGBA 通道的 ASTC 压缩纹理格式,压缩分块大小为 12x10 + */ + RGBA_ASTC_12X10 = static_cast(gfx::Format::ASTC_RGBA_12X10), + /** + * @en A pixel format containing red, green, blue, and alpha channels that is ASTC compressed with 12x12 block size. + * @zh 包含 RGBA 通道的 ASTC 压缩纹理格式,压缩分块大小为 12x12 + */ + RGBA_ASTC_12X12 = static_cast(gfx::Format::ASTC_RGBA_12X12), +}; + +/** + * @en + * The texture wrap mode. + * @zh + * 纹理环绕方式。 + */ +enum class WrapMode : uint32_t { + /** + * @en + * Specifies that the repeat warp mode will be used. + * @zh + * 指定环绕模式:重复纹理图像。 + */ + REPEAT = static_cast(gfx::Address::WRAP), + /** + * @en + * Specifies that the clamp to edge warp mode will be used. + * @zh + * 指定环绕模式:纹理边缘拉伸效果。 + */ + CLAMP_TO_EDGE = static_cast(gfx::Address::CLAMP), + /** + * @en + * Specifies that the mirrored repeat warp mode will be used. + * @zh + * 指定环绕模式:以镜像模式重复纹理图像。 + */ + MIRRORED_REPEAT = static_cast(gfx::Address::MIRROR), + /** + * @en + * Specifies that the clamp to border wrap mode will be used. + * @zh + * 指定环绕模式:超出纹理坐标部分以用户指定颜色填充。 + */ + CLAMP_TO_BORDER = static_cast(gfx::Address::BORDER), +}; + +/** + * @en + * The texture filter mode + * @zh + * 纹理过滤模式。 + */ +enum class Filter : uint32_t { + NONE = static_cast(gfx::Filter::NONE), + /** + * @en + * Specifies linear filtering. + * @zh + * 线性过滤模式。 + */ + LINEAR = static_cast(gfx::Filter::LINEAR), + /** + * @en + * Specifies nearest filtering. + * @zh + * 临近过滤模式。 + */ + NEAREST = static_cast(gfx::Filter::POINT), +}; + +} // namespace cc diff --git a/native/cocos/core/assets/AssetsModuleHeader.h b/native/cocos/core/assets/AssetsModuleHeader.h new file mode 100644 index 0000000000..e64a89466f --- /dev/null +++ b/native/cocos/core/assets/AssetsModuleHeader.h @@ -0,0 +1,40 @@ +/**************************************************************************** + 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 "core/assets/Asset.h" +#include "core/assets/BufferAsset.h" +#include "core/assets/EffectAsset.h" +#include "core/assets/ImageAsset.h" +//#include "core/assets/JsonAsset.h" +#include "core/assets/Material.h" +//#include "core/assets/Prefab.h" +#include "core/assets/RenderTexture.h" +#include "core/assets/RenderingSubMesh.h" +#include "core/assets/SceneAsset.h" +#include "core/assets/TextAsset.h" +#include "core/assets/Texture2D.h" +#include "core/assets/TextureCube.h" diff --git a/native/cocos/renderer/pipeline/helper/DefineMap.cpp b/native/cocos/core/assets/BufferAsset.cpp similarity index 77% rename from native/cocos/renderer/pipeline/helper/DefineMap.cpp rename to native/cocos/core/assets/BufferAsset.cpp index da98818eb6..74ab9fa7fd 100644 --- a/native/cocos/renderer/pipeline/helper/DefineMap.cpp +++ b/native/cocos/core/assets/BufferAsset.cpp @@ -1,5 +1,5 @@ /**************************************************************************** - Copyright (c) 2020-2021 Xiamen Yaji Software Co., Ltd. + Copyright (c) 2021 Xiamen Yaji Software Co., Ltd. http://www.cocos.com @@ -23,23 +23,16 @@ THE SOFTWARE. ****************************************************************************/ -#include "DefineMap.h" -#include "scene/Camera.h" +#include "core/assets/BufferAsset.h" namespace cc { -namespace pipeline { -DefineMap::DefineMap() { - _jsbMacros = se::Object::createPlainObject(); - _jsbMacros->root(); - _jsbMacros->incRef(); + +cc::any BufferAsset::getNativeAsset() const { + return _buffer; } -DefineMap::~DefineMap() { - _jsbMacros->decRef(); - _jsbMacros->unroot(); +void BufferAsset::setNativeAsset(const cc::any &obj) { + _buffer = cc::any_cast(obj); } -const scene::Camera *profilerCamera = nullptr; - -} // namespace pipeline } // namespace cc diff --git a/native/cocos/core/assets/BufferAsset.h b/native/cocos/core/assets/BufferAsset.h new file mode 100644 index 0000000000..a3084b0c9f --- /dev/null +++ b/native/cocos/core/assets/BufferAsset.h @@ -0,0 +1,50 @@ +/**************************************************************************** + 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 "core/ArrayBuffer.h" +#include "core/assets/Asset.h" + +namespace cc { + +class BufferAsset final : public Asset { +public: + BufferAsset() = default; + ~BufferAsset() override = default; + + inline ArrayBuffer *getBuffer() const { return _buffer; } + + cc::any getNativeAsset() const override; + void setNativeAsset(const cc::any &obj) override; + bool validate() const override { return _buffer != nullptr; } + +private: + ArrayBuffer::Ptr _buffer; + + CC_DISALLOW_COPY_MOVE_ASSIGN(BufferAsset); +}; + +} // namespace cc diff --git a/native/cocos/core/assets/EffectAsset.cpp b/native/cocos/core/assets/EffectAsset.cpp new file mode 100644 index 0000000000..9a78aa1512 --- /dev/null +++ b/native/cocos/core/assets/EffectAsset.cpp @@ -0,0 +1,292 @@ +/**************************************************************************** + 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/assets/EffectAsset.h" +#include "core/Root.h" +#include "renderer/core/ProgramLib.h" + +namespace cc { + +IPassStates::IPassStates(const IPassInfoFull &o) { + *this = o; +} + +IPassStates &IPassStates::operator=(const IPassInfoFull &o) { + priority = o.priority; + primitive = o.primitive; + stage = o.stage; + rasterizerState = o.rasterizerState; + depthStencilState = o.depthStencilState; + blendState = o.blendState; + dynamicStates = o.dynamicStates; + phase = o.phase; + return *this; +} + +void IPassStates::overrides(const IPassInfoFull &o) { + if (o.priority.has_value()) { + this->priority = o.priority.value(); + } + if (o.primitive.has_value()) { + this->primitive = o.primitive.value(); + } + if (o.stage.has_value()) { + this->stage = o.stage.value(); + } + if (o.rasterizerState.has_value()) { + this->rasterizerState = o.rasterizerState.value(); + } + if (o.depthStencilState.has_value()) { + this->depthStencilState = o.depthStencilState.value(); + } + if (o.blendState.has_value()) { + this->blendState = o.blendState.value(); + } + if (o.dynamicStates.has_value()) { + this->dynamicStates = o.dynamicStates.value(); + } + if (o.phase.has_value()) { + this->phase = o.phase.value(); + } +} + +EffectAsset::RegisteredEffectAssetMap EffectAsset::effects; + +/* static */ +void EffectAsset::registerAsset(EffectAsset *asset) { + if (asset == nullptr) { + return; + } + + EffectAsset::effects.emplace(asset->getName(), asset); +} + +/* static */ +void EffectAsset::remove(const std::string &name) { + auto iter = EffectAsset::effects.find(name); + if (iter != EffectAsset::effects.end() && iter->second->getName() == name) { + EffectAsset::effects.erase(iter); + return; + } + + iter = EffectAsset::effects.begin(); + for (; iter != EffectAsset::effects.end(); ++iter) { + if (iter->second->getUuid() == name) { + break; + } + } + + if (iter != EffectAsset::effects.end()) { + EffectAsset::effects.erase(iter); + } +} + +/* static */ +void EffectAsset::remove(EffectAsset *asset) { + if (asset == nullptr) { + return; + } + + auto iter = EffectAsset::effects.find(asset->getName()); + if (iter != EffectAsset::effects.end() && iter->second == asset) { + EffectAsset::effects.erase(iter); + } +} + +/* static */ +EffectAsset *EffectAsset::get(const std::string &name) { + auto iter = EffectAsset::effects.find(name); + if (iter != EffectAsset::effects.end()) { + return iter->second; + } + + iter = EffectAsset::effects.begin(); + for (; iter != EffectAsset::effects.end(); ++iter) { + if (iter->second->getUuid() == name) { + return iter->second; + } + } + return nullptr; +} + +void EffectAsset::onLoaded() { + ProgramLib::getInstance()->registerEffect(this); + EffectAsset::registerAsset(this); + //cjh TODO: if (!EDITOR){ + //cjh legacyCC.game.once(legacyCC.Game.EVENT_ENGINE_INITED, this._precompile, this); + // } +} + +bool EffectAsset::destroy() { + EffectAsset::remove(this); + return Super::destroy(); +} + +void EffectAsset::initDefault(const cc::optional &uuid) { + Super::initDefault(uuid); + const auto *effect = EffectAsset::get("unlit"); + _name = "unlit"; + _shaders = effect->_shaders; + _combinations = effect->_combinations; + _techniques = effect->_techniques; //cjh TODO: shared_ptr ? +} + +bool EffectAsset::validate() const { + return !_techniques.empty() && !_shaders.empty(); +} + +void EffectAsset::precompile() { + Root *root = Root::getInstance(); + for (index_t i = 0; i < _shaders.size(); ++i) { + auto shader = _shaders[i]; + if (i >= _combinations.size()) { + continue; + } + + auto combination = _combinations[i]; + if (combination.empty()) { + continue; + } + + // TODO(minggo): do unit test + std::vector defines = EffectAsset::doCombine(std::vector(), combination, combination.begin()); + for (auto &define : defines) { + ProgramLib::getInstance()->getGFXShader(root->getDevice(), shader.name, define, root->getPipeline()); + } + } +} + +/* +// input + +const combination = { +USE_TEXTURE: [true, false], +COLOR_MODE: [0, 1, 2, 3], +ROUGHNESS_CHANNEL: ['r', 'g', 'b'], +}; + +// output + +const defines = [ + { + USE_TEXTURE: true, + COLOR_MODE: 0, + ROUGHNESS_CHANNEL: 'r' + }, + { + USE_TEXTURE: true, + COLOR_MODE: 0, + ROUGHNESS_CHANNEL: 'g' + }, + { + USE_TEXTURE: true, + COLOR_MODE: 0, + ROUGHNESS_CHANNEL: 'b' + }, + { + USE_TEXTURE: true, + COLOR_MODE: 1, + ROUGHNESS_CHANNEL: 'r' + }, + // ... all the combinations (2x4x3 in this case) + ]; + */ +std::vector EffectAsset::doCombine(const std::vector &cur, const IPreCompileInfo &info, IPreCompileInfo::iterator iter) { //NOLINT(misc-no-recursion) + if (iter == info.end()) { + return cur; + } + + const IPreCompileInfoValueType &values = iter->second; + const std::string & key = iter->first; + + std::vector records; + if (cur.empty()) { + records = EffectAsset::generateRecords(key, values); + } else { + records = EffectAsset::insertInfoValue(cur, key, values); + } + + return EffectAsset::doCombine(records, info, ++iter); +} + +std::vector EffectAsset::generateRecords(const std::string &key, const IPreCompileInfoValueType &value) { + std::vector ret; + if (const auto *boolValues = cc::get_if>(&value)) { + for (const bool value : *boolValues) { + MacroRecord record; + record[key] = value; + ret.emplace_back(record); + } + } else if (const auto *floatValues = cc::get_if>(&value)) { + for (const float value : *floatValues) { + MacroRecord record; + record[key] = value; + ret.emplace_back(record); + } + } else if (const auto *stringValues = cc::get_if>(&value)) { + for (const std::string &value : *stringValues) { + MacroRecord record; + record[key] = value; + ret.emplace_back(record); + } + } else { + CC_ASSERT(false); + } + + return ret; +} + +std::vector EffectAsset::insertInfoValue(const std::vector &records, + const std::string & key, + const IPreCompileInfoValueType &value) { + std::vector ret; + for (const auto &record : records) { + if (const auto *boolValues = cc::get_if>(&value)) { + for (const bool value : *boolValues) { + MacroRecord tmpRecord = record; + tmpRecord[key] = value; + ret.emplace_back(tmpRecord); + } + } else if (const auto *floatValues = cc::get_if>(&value)) { + for (const float value : *floatValues) { + MacroRecord tmpRecord = record; + tmpRecord[key] = value; + ret.emplace_back(tmpRecord); + } + } else if (const auto *stringValues = cc::get_if>(&value)) { + for (const std::string &value : *stringValues) { + MacroRecord tmpRecord = record; + tmpRecord[key] = value; + ret.emplace_back(tmpRecord); + } + } else { + CC_ASSERT(false); + } + } + + return ret; +} + +} // namespace cc diff --git a/native/cocos/core/assets/EffectAsset.h b/native/cocos/core/assets/EffectAsset.h new file mode 100644 index 0000000000..069ed1b7f2 --- /dev/null +++ b/native/cocos/core/assets/EffectAsset.h @@ -0,0 +1,631 @@ +/**************************************************************************** + 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 +#include +#include +#include "cocos/base/Optional.h" + +#include "base/Value.h" +#include "core/Types.h" +#include "core/assets/Asset.h" +#include "gfx-base/GFXDef-common.h" +#include "gfx-base/GFXShader.h" +#include "renderer/core/PassUtils.h" +#include "renderer/gfx-base/GFXDef.h" +#include "renderer/pipeline/Define.h" +//#include "scene/Define.h" + +namespace cc { + +using IPropertyHandleInfo = std::tuple; + +using IPropertyValue = cc::optional, std::string>>; + +struct IPropertyInfo { + int32_t type; // auto-extracted from shader + cc::optional handleInfo; // auto-generated from 'target' + cc::optional samplerHash; // auto-generated from 'sampler' + IPropertyValue value; // default value + cc::optional linear; // whether to convert the input to linear space first before applying +}; + +struct IPassInfoFull; + +struct RasterizerStateInfo { + cc::optional isDiscard; + cc::optional isFrontFaceCCW; + cc::optional depthBiasEnabled; + cc::optional isDepthClip; + cc::optional isMultisample; + + cc::optional polygonMode; + cc::optional shadeModel; + cc::optional cullMode; + + cc::optional depthBias; + cc::optional depthBiasClamp; + cc::optional depthBiasSlop; + cc::optional lineWidth; + + void fromGFXRasterizerState(const gfx::RasterizerState &rs) { + isDiscard = rs.isDiscard; + isFrontFaceCCW = rs.isFrontFaceCCW; + depthBiasEnabled = rs.depthBiasEnabled; + isDepthClip = rs.isDepthClip; + isMultisample = rs.isMultisample; + + polygonMode = rs.polygonMode; + shadeModel = rs.shadeModel; + cullMode = rs.cullMode; + + depthBias = rs.depthBias; + depthBiasClamp = rs.depthBiasClamp; + depthBiasSlop = rs.depthBiasSlop; + lineWidth = rs.lineWidth; + } + + void assignToGFXRasterizerState(gfx::RasterizerState &rs) const { + if (isDiscard.has_value()) { + rs.isDiscard = isDiscard.value(); + } + if (isFrontFaceCCW.has_value()) { + rs.isFrontFaceCCW = isFrontFaceCCW.value(); + } + if (depthBiasEnabled.has_value()) { + rs.depthBiasEnabled = depthBiasEnabled.value(); + } + if (isDepthClip.has_value()) { + rs.isDepthClip = isDepthClip.value(); + } + if (isMultisample.has_value()) { + rs.isMultisample = isMultisample.value(); + } + if (polygonMode.has_value()) { + rs.polygonMode = polygonMode.value(); + } + if (shadeModel.has_value()) { + rs.shadeModel = shadeModel.value(); + } + if (cullMode.has_value()) { + rs.cullMode = cullMode.value(); + } + if (depthBias.has_value()) { + rs.depthBias = depthBias.value(); + } + if (depthBiasClamp.has_value()) { + rs.depthBiasClamp = depthBiasClamp.value(); + } + if (depthBiasSlop.has_value()) { + rs.depthBiasSlop = depthBiasSlop.value(); + } + if (lineWidth.has_value()) { + rs.lineWidth = lineWidth.value(); + } + } +}; + +struct DepthStencilStateInfo { + cc::optional depthTest; + cc::optional depthWrite; + cc::optional stencilTestFront; + cc::optional stencilTestBack; + + cc::optional depthFunc; + cc::optional stencilFuncFront; + cc::optional stencilReadMaskFront; + cc::optional stencilWriteMaskFront; + cc::optional stencilFailOpFront; + cc::optional stencilZFailOpFront; + cc::optional stencilPassOpFront; + cc::optional stencilRefFront; + + cc::optional stencilFuncBack; + cc::optional stencilReadMaskBack; + cc::optional stencilWriteMaskBack; + cc::optional stencilFailOpBack; + cc::optional stencilZFailOpBack; + cc::optional stencilPassOpBack; + cc::optional stencilRefBack; + + void fromGFXDepthStencilState(const gfx::DepthStencilState &ds) { + depthTest = ds.depthTest; + depthWrite = ds.depthWrite; + stencilTestFront = ds.stencilTestFront; + stencilTestBack = ds.stencilTestBack; + + depthFunc = ds.depthFunc; + stencilFuncFront = ds.stencilFuncFront; + stencilReadMaskFront = ds.stencilReadMaskFront; + stencilWriteMaskFront = ds.stencilWriteMaskFront; + stencilFailOpFront = ds.stencilFailOpFront; + stencilZFailOpFront = ds.stencilZFailOpFront; + stencilPassOpFront = ds.stencilPassOpFront; + stencilRefFront = ds.stencilRefFront; + + stencilFuncBack = ds.stencilFuncBack; + stencilReadMaskBack = ds.stencilReadMaskBack; + stencilWriteMaskBack = ds.stencilWriteMaskBack; + stencilFailOpBack = ds.stencilFailOpBack; + stencilZFailOpBack = ds.stencilZFailOpBack; + stencilPassOpBack = ds.stencilPassOpBack; + stencilRefBack = ds.stencilRefBack; + } + + void assignToGFXDepthStencilState(gfx::DepthStencilState &ds) const { + if (depthTest.has_value()) { + ds.depthTest = depthTest.value(); + } + if (depthWrite.has_value()) { + ds.depthWrite = depthWrite.value(); + } + if (stencilTestFront.has_value()) { + ds.stencilTestFront = stencilTestFront.value(); + } + if (stencilTestBack.has_value()) { + ds.stencilTestBack = stencilTestBack.value(); + } + if (depthFunc.has_value()) { + ds.depthFunc = depthFunc.value(); + } + if (stencilFuncFront.has_value()) { + ds.stencilFuncFront = stencilFuncFront.value(); + } + if (stencilReadMaskFront.has_value()) { + ds.stencilReadMaskFront = stencilReadMaskFront.value(); + } + if (stencilWriteMaskFront.has_value()) { + ds.stencilWriteMaskFront = stencilWriteMaskFront.value(); + } + if (stencilFailOpFront.has_value()) { + ds.stencilFailOpFront = stencilFailOpFront.value(); + } + if (stencilZFailOpFront.has_value()) { + ds.stencilZFailOpFront = stencilZFailOpFront.value(); + } + if (stencilPassOpFront.has_value()) { + ds.stencilPassOpFront = stencilPassOpFront.value(); + } + if (stencilRefFront.has_value()) { + ds.stencilRefFront = stencilRefFront.value(); + } + if (stencilFuncBack.has_value()) { + ds.stencilFuncBack = stencilFuncBack.value(); + } + if (stencilReadMaskBack.has_value()) { + ds.stencilReadMaskBack = stencilReadMaskBack.value(); + } + if (stencilWriteMaskBack.has_value()) { + ds.stencilWriteMaskBack = stencilWriteMaskBack.value(); + } + if (stencilFailOpBack.has_value()) { + ds.stencilFailOpBack = stencilFailOpBack.value(); + } + if (stencilZFailOpBack.has_value()) { + ds.stencilZFailOpBack = stencilZFailOpBack.value(); + } + if (stencilPassOpBack.has_value()) { + ds.stencilPassOpBack = stencilPassOpBack.value(); + } + if (stencilRefBack.has_value()) { + ds.stencilRefBack = stencilRefBack.value(); + } + } +}; + +struct BlendTargetInfo { + cc::optional blend; + cc::optional blendSrc; + cc::optional blendDst; + cc::optional blendEq; + cc::optional blendSrcAlpha; + cc::optional blendDstAlpha; + cc::optional blendAlphaEq; + cc::optional blendColorMask; + + void fromGFXBlendTarget(const gfx::BlendTarget &target) { + blend = target.blend; + blendSrc = target.blendSrc; + blendDst = target.blendDst; + blendEq = target.blendEq; + blendSrcAlpha = target.blendSrcAlpha; + blendDstAlpha = target.blendDstAlpha; + blendAlphaEq = target.blendAlphaEq; + blendColorMask = target.blendColorMask; + } + + void assignToGFXBlendTarget(gfx::BlendTarget &target) const { + if (blend.has_value()) { + target.blend = blend.value(); + } + if (blendSrc.has_value()) { + target.blendSrc = blendSrc.value(); + } + if (blendDst.has_value()) { + target.blendDst = blendDst.value(); + } + if (blendEq.has_value()) { + target.blendEq = blendEq.value(); + } + if (blendSrcAlpha.has_value()) { + target.blendSrcAlpha = blendSrcAlpha.value(); + } + if (blendDstAlpha.has_value()) { + target.blendDstAlpha = blendDstAlpha.value(); + } + if (blendAlphaEq.has_value()) { + target.blendAlphaEq = blendAlphaEq.value(); + } + if (blendColorMask.has_value()) { + target.blendColorMask = blendColorMask.value(); + } + } +}; + +using BlendTargetInfoList = std::vector; + +struct BlendStateInfo { + cc::optional isA2C; + cc::optional isIndepend; + cc::optional blendColor; + cc::optional targets; + + void fromGFXBlendState(const gfx::BlendState &bs) { + isA2C = bs.isA2C; + isIndepend = bs.isIndepend; + blendColor = bs.blendColor; + size_t len = bs.targets.size(); + if (len > 0) { + BlendTargetInfoList targetsList(len); + for (size_t i = 0; i < len; ++i) { + targetsList[i].fromGFXBlendTarget(bs.targets[i]); + } + targets = targetsList; + } + } + + void assignToGFXBlendState(gfx::BlendState &bs) const { + if (targets.has_value()) { + const auto &targetsVal = targets.value(); + bs.targets.resize(targetsVal.size()); + for (size_t i = 0, len = targetsVal.size(); i < len; ++i) { + targetsVal[i].assignToGFXBlendTarget(bs.targets[i]); + } + } + + if (isA2C.has_value()) { + bs.isA2C = isA2C.value(); + } + + if (isIndepend.has_value()) { + bs.isIndepend = isIndepend.value(); + } + + if (blendColor.has_value()) { + bs.blendColor = blendColor.value(); + } + } +}; + +// Pass instance itself are compliant to IPassStates too +struct IPassStates { + cc::optional priority; + cc::optional primitive; + cc::optional stage; + cc::optional rasterizerState; + cc::optional depthStencilState; + cc::optional blendState; + cc::optional dynamicStates; + cc::optional phase; + + IPassStates() = default; + explicit IPassStates(const IPassInfoFull &o); + IPassStates &operator=(const IPassInfoFull &o); + void overrides(const IPassInfoFull &o); +}; +using PassOverrides = IPassStates; + +using PassPropertyInfoMap = std::unordered_map; + +struct IPassInfoFull final { //cjh } : public IPassInfo { + // IPassStates + cc::optional priority; + cc::optional primitive; + cc::optional stage; + cc::optional rasterizerState; + cc::optional depthStencilState; + cc::optional blendState; + cc::optional dynamicStates; + cc::optional phase; + // IPassInfo + std::string program; // auto-generated from 'vert' and 'frag' + cc::optional embeddedMacros; + index_t propertyIndex{CC_INVALID_INDEX}; + cc::optional switch_; + cc::optional properties; + + // IPassInfoFull + // generated part + index_t passIndex{0}; + MacroRecord defines; + cc::optional stateOverrides; + + IPassInfoFull() = default; + explicit IPassInfoFull(const IPassStates &o) { + *this = o; + } + IPassInfoFull &operator=(const IPassStates &o) { + priority = o.priority; + primitive = o.primitive; + stage = o.stage; + rasterizerState = o.rasterizerState; + depthStencilState = o.depthStencilState; + blendState = o.blendState; + dynamicStates = o.dynamicStates; + phase = o.phase; + return *this; + } +}; + +using IPassInfo = IPassInfoFull; + +struct ITechniqueInfo { + std::vector passes; + cc::optional name; +}; + +struct IBlockInfo { + int32_t binding{-1}; + std::string name; + std::vector members; + gfx::ShaderStageFlags stageFlags{gfx::ShaderStageFlags::NONE}; +}; + +struct ISamplerTextureInfo { + int32_t binding{-1}; + std::string name; + gfx::Type type{gfx::Type::UNKNOWN}; + uint32_t count{0}; + gfx::ShaderStageFlags stageFlags{gfx::ShaderStageFlags::NONE}; +}; + +struct ITextureInfo { + uint32_t set{0}; + int32_t binding{-1}; + std::string name; + gfx::Type type{gfx::Type::UNKNOWN}; + uint32_t count{0}; + gfx::ShaderStageFlags stageFlags{gfx::ShaderStageFlags::NONE}; +}; + +struct ISamplerInfo { + uint32_t set{0}; + int32_t binding{-1}; + std::string name; + uint32_t count{0}; + gfx::ShaderStageFlags stageFlags{gfx::ShaderStageFlags::NONE}; +}; + +struct IBufferInfo { + int32_t binding{-1}; + std::string name; + gfx::MemoryAccess memoryAccess{gfx::MemoryAccess::NONE}; + gfx::ShaderStageFlags stageFlags{gfx::ShaderStageFlags::NONE}; +}; + +struct IImageInfo { + int32_t binding{-1}; + std::string name; + gfx::Type type{gfx::Type::UNKNOWN}; + uint32_t count{0}; + gfx::MemoryAccess memoryAccess{gfx::MemoryAccess::NONE}; + gfx::ShaderStageFlags stageFlags{gfx::ShaderStageFlags::NONE}; +}; + +struct IInputAttachmentInfo { + uint32_t set{0}; + int32_t binding{-1}; + std::string name; + uint32_t count{0}; + gfx::ShaderStageFlags stageFlags{gfx::ShaderStageFlags::NONE}; +}; + +struct IAttributeInfo { + std::string name; + gfx::Format format{gfx::Format::UNKNOWN}; + bool isNormalized{false}; + uint32_t stream{0U}; + bool isInstanced{false}; + uint32_t location{0U}; + + std::vector defines; +}; + +struct IDefineInfo { + std::string name; + std::string type; + cc::optional> range; //cjh number is float? ?: number[]; + cc::optional> options; + cc::optional defaultVal; +}; + +struct IBuiltin { + std::string name; + std::vector defines; +}; + +struct IBuiltinInfo { + std::vector buffers; + std::vector blocks; + std::vector samplerTextures; + std::vector images; +}; + +using BuiltinsStatisticsType = std::unordered_map; + +struct IBuiltins { + IBuiltinInfo globals; + IBuiltinInfo locals; + BuiltinsStatisticsType statistics; +}; + +struct IShaderSource { + std::string vert; + std::string frag; +}; + +struct IShaderInfo { + std::string name; + uint64_t hash{0xFFFFFFFFFFFFFFFFULL}; //cjh hash is 64 bit? + IShaderSource glsl4; + IShaderSource glsl3; + IShaderSource glsl1; + IBuiltins builtins; + std::vector defines; + std::vector attributes; + std::vector blocks; + std::vector samplerTextures; + std::vector samplers; + std::vector textures; + std::vector buffers; + std::vector images; + std::vector subpassInputs; + + const IShaderSource *getSource(const std::string &version) const { + if (version == "glsl1") return &glsl1; + if (version == "glsl3") return &glsl3; + if (version == "glsl4") return &glsl4; + return nullptr; + } +}; + +using IPreCompileInfoValueType = cc::variant, std::vector, std::vector>; //cjh number is float? +using IPreCompileInfo = std::unordered_map; + +class EffectAsset final : public Asset { +public: + using Super = Asset; + + EffectAsset() = default; + ~EffectAsset() override = default; + /** + * @en Register the effect asset to the static map + * @zh 将指定 effect 注册到全局管理器。 + */ + static void registerAsset(EffectAsset *asset); + + /** + * @en Unregister the effect asset from the static map + * @zh 将指定 effect 从全局管理器移除。 + */ + static void remove(const std::string &name); + static void remove(EffectAsset *asset); + + /** + * @en Get the effect asset by the given name. + * @zh 获取指定名字的 effect 资源。 + */ + static EffectAsset *get(const std::string &name); + + using RegisteredEffectAssetMap = std::unordered_map>; + /** + * @en Get all registered effect assets. + * @zh 获取所有已注册的 effect 资源。 + */ + static RegisteredEffectAssetMap &getAll() { return EffectAsset::effects; } + + inline void setTechniques(const std::vector &val) { _techniques = val; } + inline void setShaders(const std::vector &val) { _shaders = val; } + inline void setCombinations(const std::vector &val) { _combinations = val; } + + inline const std::vector & getTechniques() const { return _techniques; } + inline const std::vector & getShaders() const { return _shaders; } + inline const std::vector &getCombinations() const { return _combinations; } + + /* + @serializable + @editorOnly + */ + bool hideInEditor = false; + + /** + * @en The loaded callback which should be invoked by the [[Loader]], will automatically register the effect. + * @zh 通过 [[Loader]] 加载完成时的回调,将自动注册 effect 资源。 + */ + void onLoaded() override; + bool destroy() override; + void initDefault(const cc::optional &uuid) override; + bool validate() const override; + +protected: + static std::vector doCombine(const std::vector &cur, const IPreCompileInfo &info, IPreCompileInfo::iterator iter); + static std::vector generateRecords(const std::string &key, const IPreCompileInfoValueType &value); + static std::vector insertInfoValue(const std::vector &records, + const std::string & key, + const IPreCompileInfoValueType &value); + + void precompile(); + + // We need make it to public for deserialization +public: + /** + * @en The techniques used by the current effect. + * @zh 当前 effect 的所有可用 technique。 + + @serializable + @editable*/ + std::vector _techniques; + + /** + * @en The shaders used by the current effect. + * @zh 当前 effect 使用的所有 shader。 + + @serializable + @editable*/ + std::vector _shaders; + + /** + * @en The preprocess macro combinations for the shader + * @zh 每个 shader 需要预编译的宏定义组合。 + + @serializable + @editable*/ + std::vector _combinations; + // +protected: + static RegisteredEffectAssetMap effects; //cjh TODO: how to clear when game exits. + + CC_DISALLOW_COPY_MOVE_ASSIGN(EffectAsset); + + friend class EffectAssetDeserializer; + friend class Material; + friend class ProgramLib; + friend class MaterialInstance; + friend class BuiltinResMgr; +}; + +} // namespace cc diff --git a/native/cocos/core/assets/ImageAsset.cpp b/native/cocos/core/assets/ImageAsset.cpp new file mode 100644 index 0000000000..acc1e454a4 --- /dev/null +++ b/native/cocos/core/assets/ImageAsset.cpp @@ -0,0 +1,91 @@ +/**************************************************************************** + 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/assets/ImageAsset.h" + +#include "platform/Image.h" + +#include "base/Log.h" + +namespace cc { + +ImageAsset::~ImageAsset() { + if (_needFreeData && _data) { + free(_data); + } +} + +void ImageAsset::setNativeAsset(const cc::any &obj) { + if (obj.has_value()) { + auto **pImage = const_cast(cc::any_cast(&obj)); + if (pImage != nullptr) { + Image *image = *pImage; + image->takeData(&_data); + _needFreeData = true; + + _width = image->getWidth(); + _height = image->getHeight(); + _format = static_cast(image->getRenderFormat()); + _url = image->getFilePath(); + } else { + const auto *imageSource = cc::any_cast(&obj); + if (imageSource != nullptr) { + _arrayBuffer = imageSource->data; + _data = const_cast(_arrayBuffer->getData()); + _width = imageSource->width; + _height = imageSource->height; + _format = imageSource->format; + } else { + CC_LOG_WARNING("ImageAsset::setNativeAsset, unknown type!"); + } + } + } +} + +const uint8_t *ImageAsset::getData() const { + return _data; +} + +uint32_t ImageAsset::getWidth() const { + return _width; +} + +uint32_t ImageAsset::getHeight() const { + return _height; +} + +PixelFormat ImageAsset::getFormat() const { + return _format; +} + +bool ImageAsset::isCompressed() const { + return (_format >= PixelFormat::RGB_ETC1 && _format <= PixelFormat::RGBA_ASTC_12X12) || (_format >= PixelFormat::RGB_A_PVRTC_2BPPV1 && _format <= PixelFormat::RGBA_ETC1); +} + +std::string ImageAsset::getUrl() const { + return _url; +} + +} // namespace cc diff --git a/native/cocos/core/assets/ImageAsset.h b/native/cocos/core/assets/ImageAsset.h new file mode 100644 index 0000000000..e54e1636b3 --- /dev/null +++ b/native/cocos/core/assets/ImageAsset.h @@ -0,0 +1,120 @@ +/**************************************************************************** + 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 "core/assets/Asset.h" +#include "core/assets/AssetEnum.h" + +#include "core/ArrayBuffer.h" + +namespace cc { + +class Image; + +/** + * @en Image source in memory + * @zh 内存图像源。 + */ +struct IMemoryImageSource { + ArrayBuffer::Ptr data; + bool compressed{false}; + uint32_t width{0}; + uint32_t height{0}; + PixelFormat format{PixelFormat::RGBA8888}; +}; + +/** + * @en Image Asset. + * @zh 图像资源。 + */ +class ImageAsset final : public Asset { +public: + using Super = Asset; + + ImageAsset() = default; + ~ImageAsset() override; + + //minggo: do not need it in c++. + // cc::any getNativeAsset() const override { return cc::any(_nativeData); } + void setNativeAsset(const cc::any &obj) override; + + /** + * @en Image data. + * @zh 此图像资源的图像数据。 + */ + const uint8_t *getData() const; + + /** + * @en The pixel width of the image. + * @zh 此图像资源的像素宽度。 + */ + uint32_t getWidth() const; + + /** + * @en The pixel height of the image. + * @zh 此图像资源的像素高度。 + */ + uint32_t getHeight() const; + + /** + * @en The pixel format of the image. + * @zh 此图像资源的像素格式。 + */ + PixelFormat getFormat() const; + + /** + * @en Whether the image is in compressed texture format. + * @zh 此图像资源是否为压缩像素格式。 + */ + bool isCompressed() const; + + /** + * @en The original source image URL, it could be empty. + * @zh 此图像资源的原始图像源的 URL。当原始图像元不是 HTML 文件时可能为空。 + * @deprecated Please use [[nativeUrl]] + */ + std::string getUrl() const; + + // Functions for TS. + inline void setWidth(uint32_t width) { _width = width; } + inline void setHeight(uint32_t height) { _height = height; } + inline void setFormat(PixelFormat format) { _format = format; } + inline void setData(uint8_t *data) { _data = data; } + inline void setUrl(const std::string &url) { _url = url; } + +private: + uint32_t _width{0}; + uint32_t _height{0}; + PixelFormat _format{PixelFormat::RGBA8888}; + uint8_t * _data{nullptr}; + bool _needFreeData{false}; // Should free data if the data is assigned in C++. + ArrayBuffer::Ptr _arrayBuffer; //minggo: hold the data from ImageSource. + std::string _url; + + CC_DISALLOW_COPY_MOVE_ASSIGN(ImageAsset); +}; + +} // namespace cc diff --git a/native/cocos/core/assets/Material.cpp b/native/cocos/core/assets/Material.cpp new file mode 100644 index 0000000000..e27dcf1141 --- /dev/null +++ b/native/cocos/core/assets/Material.cpp @@ -0,0 +1,440 @@ +/**************************************************************************** + 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/assets/Material.h" +#include "cocos/base/Variant.h" + +#include "base/Utils.h" +#include "core/Root.h" +#include "core/assets/EffectAsset.h" +#include "core/builtin/BuiltinResMgr.h" +#include "core/event/EventTypesToJS.h" +#include "math/Color.h" +#include "renderer/pipeline/helper/Utils.h" +#include "scene/Pass.h" + +namespace cc { + +/* static */ +uint64_t Material::getHashForMaterial(Material *material) { + if (material == nullptr) { + return 0; + } + + uint64_t hash = 0; + const auto &passes = *material->_passes; + for (const auto &pass : passes) { + hash ^= pass->getHash(); + } + return hash; +} + +Material::Material() { + _passes = std::make_shared>>(); +} + +void Material::initialize(const IMaterialInfo &info) { + // cjh FIXME: remove hacking code here + BuiltinResMgr::getInstance(); + // + auto &passes = *_passes; + if (!passes.empty()) { + // cjh TODO: warnID(12005); + return; + } + + if (!_defines.empty()) { + _defines.clear(); + } + if (!_states.empty()) { + _states.clear(); + } + if (!_props.empty()) { + _props.clear(); + } + + if (info.technique != cc::nullopt) { + _techIdx = info.technique.value(); + } + + if (info.effectAsset != nullptr) { + _effectAsset = info.effectAsset; + } else if (info.effectName != cc::nullopt) { + _effectAsset = EffectAsset::get(info.effectName.value()); + } + + if (info.defines != cc::nullopt) { + prepareInfo(info.defines.value(), _defines); + } + + if (info.states != cc::nullopt) { + prepareInfo(info.states.value(), _states); + } + update(); +} + +void Material::reset(const IMaterialInfo &info) { // to be consistent with other assets + initialize(info); +} + +bool Material::destroy() { + doDestroy(); + return Super::destroy(); +} + +void Material::doDestroy() { + auto &passes = *_passes; + if (!passes.empty()) { + for (const auto &pass : passes) { + pass->destroy(); + } + } + passes.clear(); + emit(EventTypesToJS::MATERIAL_PASSES_UPDATED); +} + +void Material::recompileShaders(const MacroRecord & /*overrides*/, index_t /*passIdx*/) { + assert(false); + CC_LOG_WARNING("Shaders in material asset '%s' cannot be modified at runtime, please instantiate the material first.", _name.c_str()); +} + +void Material::overridePipelineStates(const PassOverrides & /*overrides*/, index_t /*passIdx*/) { + assert(false); + CC_LOG_WARNING("Pipeline states in material asset '%s' cannot be modified at runtime, please instantiate the material first.", _name.c_str()); +} + +void Material::onLoaded() { + update(); +} + +void Material::resetUniforms(bool clearPasses /* = true */) { + const auto &passes = *_passes; + _props.resize(passes.size()); + + if (!clearPasses) { + return; + } + + for (const auto &pass : passes) { + pass->resetUBOs(); + pass->resetTextures(); + } +} + +void Material::setProperty(const std::string &name, const MaterialPropertyVariant &val, index_t passIdx /* = CC_INVALID_INDEX */) { + const auto &passes = *_passes; + bool success = false; + if (passIdx == CC_INVALID_INDEX) { // try set property for all applicable passes + size_t len = passes.size(); + for (size_t i = 0; i < len; i++) { + const auto &pass = passes[i]; + if (uploadProperty(pass, name, val)) { + _props[pass->getPropertyIndex()][name] = val; + success = true; + } + } + } else { + if (passIdx >= passes.size()) { + CC_LOG_WARNING("illegal pass index: %d.", passIdx); + return; + } + + const auto &pass = passes[passIdx]; + if (uploadProperty(pass, name, val)) { + _props[pass->getPropertyIndex()][name] = val; + success = true; + } + } + + if (!success) { + CC_LOG_WARNING("illegal property name: %s.", name.c_str()); + } +} + +#define CC_MATERIAL_SETPROPERTY_IMPL(funcNameSuffix, type) \ + void Material::setProperty##funcNameSuffix(const std::string &name, type val, index_t passIdx /* = CC_INVALID_INDEX*/) { \ + setProperty(name, val, passIdx); \ + } + +CC_MATERIAL_SETPROPERTY_IMPL(Float32, float) +CC_MATERIAL_SETPROPERTY_IMPL(Int32, int32_t) +CC_MATERIAL_SETPROPERTY_IMPL(Vec2, const Vec2 &) +CC_MATERIAL_SETPROPERTY_IMPL(Vec3, const Vec3 &) +CC_MATERIAL_SETPROPERTY_IMPL(Vec4, const Vec4 &) +CC_MATERIAL_SETPROPERTY_IMPL(Color, const cc::Color &) +CC_MATERIAL_SETPROPERTY_IMPL(Mat3, const Mat3 &) +CC_MATERIAL_SETPROPERTY_IMPL(Mat4, const Mat4 &) +CC_MATERIAL_SETPROPERTY_IMPL(Quaternion, const Quaternion &) +CC_MATERIAL_SETPROPERTY_IMPL(TextureBase, TextureBase *) +CC_MATERIAL_SETPROPERTY_IMPL(GFXTexture, gfx::Texture *) + +#undef CC_MATERIAL_SETPROPERTY_IMPL + +#define CC_MATERIAL_SETPROPERTY_ARRAY_IMPL(funcNameSuffix, type) \ + void Material::setProperty##funcNameSuffix##Array(const std::string &name, const std::vector &val, index_t /*passIdx = CC_INVALID_INDEX*/) { \ + MaterialPropertyList propertyArr; \ + propertyArr.reserve(val.size()); \ + for (const auto &e : val) { \ + propertyArr.emplace_back(e); \ + } \ + setProperty(name, propertyArr); \ + } + +CC_MATERIAL_SETPROPERTY_ARRAY_IMPL(Float32, float) +CC_MATERIAL_SETPROPERTY_ARRAY_IMPL(Int32, int32_t) +CC_MATERIAL_SETPROPERTY_ARRAY_IMPL(Vec2, Vec2) +CC_MATERIAL_SETPROPERTY_ARRAY_IMPL(Vec3, Vec3) +CC_MATERIAL_SETPROPERTY_ARRAY_IMPL(Vec4, Vec4) +CC_MATERIAL_SETPROPERTY_ARRAY_IMPL(Color, Color) +CC_MATERIAL_SETPROPERTY_ARRAY_IMPL(Mat3, Mat3) +CC_MATERIAL_SETPROPERTY_ARRAY_IMPL(Mat4, Mat4) +CC_MATERIAL_SETPROPERTY_ARRAY_IMPL(Quaternion, Quaternion) +CC_MATERIAL_SETPROPERTY_ARRAY_IMPL(TextureBase, TextureBase *) +CC_MATERIAL_SETPROPERTY_ARRAY_IMPL(GFXTexture, gfx::Texture *) + +#undef CC_MATERIAL_SETPROPERTY_ARRAY_IMPL + +const MaterialPropertyVariant *Material::getProperty(const std::string &name, index_t passIdx) const { + if (passIdx == CC_INVALID_INDEX) { // try get property in all possible passes + const auto &propsArray = _props; + size_t len = propsArray.size(); + for (size_t i = 0; i < len; i++) { + const auto &props = propsArray[i]; + auto iter = props.find(name); + if (iter != props.end()) { + return &iter->second; + } + } + } else { + if (passIdx >= _props.size()) { + CC_LOG_WARNING("illegal pass index: %d.", passIdx); + return nullptr; + } + + const auto &passes = *_passes; + const auto &props = _props[passes[passIdx]->getPropertyIndex()]; + auto iter = props.find(name); + if (iter != props.end()) { + return &iter->second; + } + } + return nullptr; +} + +void Material::copy(const Material *mat) { + if (mat == nullptr) { + return; + } + + _techIdx = mat->_techIdx; + _props.resize(mat->_props.size()); + for (size_t i = 0, len = mat->_props.size(); i < len; ++i) { + _props[i] = mat->_props[i]; + } + _defines.resize(mat->_defines.size()); + for (size_t i = 0, len = mat->_defines.size(); i < len; ++i) { + _defines[i] = mat->_defines[i]; + } + _states.resize(mat->_states.size()); + for (size_t i = 0, len = mat->_states.size(); i < len; ++i) { + _states[i] = mat->_states[i]; + } + _effectAsset = mat->_effectAsset; + update(); +} + +void Material::update(bool keepProps /* = true*/) { + if (_effectAsset) { + *_passes = createPasses(); + CC_ASSERT(!_effectAsset->_techniques.empty()); + // handle property values + size_t totalPasses = _effectAsset->_techniques[_techIdx].passes.size(); + _props.resize(totalPasses); + if (keepProps) { + auto cb = [this](auto *pass, size_t i) { + if (i >= _props.size()) { + _props.resize(i + 1); + } + + auto &props = _props[i]; + + if (pass->getPropertyIndex() != CC_INVALID_INDEX) { + props = _props[pass->getPropertyIndex()]; + } + + for (const auto &prop : props) { + uploadProperty(pass, prop.first, prop.second); + } + }; + + const auto &passes = *_passes; + for (size_t i = 0, len = passes.size(); i < len; ++i) { + cb(passes[i].get(), i); + } + } + + emit(EventTypesToJS::MATERIAL_PASSES_UPDATED); + } + _hash = Material::getHashForMaterial(this); +} + +std::vector> Material::createPasses() { + std::vector> passes; + ITechniqueInfo * tech = nullptr; + if (_techIdx < _effectAsset->_techniques.size()) { + tech = &_effectAsset->_techniques[_techIdx]; + } + + if (tech == nullptr) { + return passes; + } + + size_t passNum = tech->passes.size(); + for (size_t k = 0; k < passNum; ++k) { + auto & passInfo = tech->passes[k]; + index_t propIdx = passInfo.passIndex = static_cast(k); + + if (propIdx >= _defines.size()) { + _defines.resize(propIdx + 1); + } + passInfo.defines = _defines[propIdx]; + auto &defines = passInfo.defines; + + if (propIdx >= _states.size()) { + _states.resize(propIdx + 1); + } + passInfo.stateOverrides = _states[propIdx]; + + if (passInfo.propertyIndex != CC_INVALID_INDEX) { + utils::mergeToMap(defines, _defines[passInfo.propertyIndex]); + } + + if (passInfo.embeddedMacros.has_value()) { + utils::mergeToMap(defines, passInfo.embeddedMacros.value()); + } + + if (passInfo.switch_.has_value() && defines.find(passInfo.switch_.value()) == defines.end()) { + continue; + } + + auto *pass = new scene::Pass(Root::getInstance()); + pass->initialize(passInfo); + passes.emplace_back(pass); + } + return passes; +} + +bool Material::uploadProperty(scene::Pass *pass, const std::string &name, const MaterialPropertyVariant &val) { + uint32_t handle = pass->getHandle(name); + if (!handle) { + return false; + } + + const auto type = scene::Pass::getTypeFromHandle(handle); + if (type < gfx::Type::SAMPLER1D) { + if (val.index() == MATERIAL_PROPERTY_INDEX_LIST) { + pass->setUniformArray(handle, cc::get(val)); + } else if (val.index() == MATERIAL_PROPERTY_INDEX_SINGLE) { + const auto &passProps = pass->getProperties(); + auto iter = passProps.find(name); + if (iter != passProps.end() && iter->second.linear.has_value()) { + CC_ASSERT(cc::holds_alternative(val)); + const auto &prop = cc::get(val); + Vec4 srgb; + if (cc::holds_alternative(prop)) { + srgb = cc::get(prop).toVec4(); + } else if (cc::holds_alternative(prop)) { + srgb = cc::get(prop); + } else { + CC_ASSERT(false); + } + + Vec4 linear; + pipeline::srgbToLinear(&linear, srgb); + linear.w = srgb.w; + pass->setUniform(handle, linear); + } else { + pass->setUniform(handle, cc::get(val)); + } + } else { + pass->resetUniform(name); + } + } else if (val.index() == MATERIAL_PROPERTY_INDEX_LIST) { + const auto &textureArray = cc::get(val); + for (size_t i = 0; i < textureArray.size(); i++) { + bindTexture(pass, handle, textureArray[i], static_cast(i)); + } + } else if (val.index() == MATERIAL_PROPERTY_INDEX_SINGLE) { + bindTexture(pass, handle, cc::get(val)); + } else { + pass->resetTexture(name); + } + return true; +} + +void Material::bindTexture(scene::Pass *pass, uint32_t handle, const MaterialProperty &val, index_t index /* = CC_INVALID_INDEX*/) { + if (pass == nullptr) { + return; + } + + const uint32_t binding = scene::Pass::getBindingFromHandle(handle); + if (const auto *pTexture = cc::get_if(&val)) { + pass->bindTexture(binding, const_cast(*pTexture), index); + } else if (const auto *pTextureBase = cc::get_if(&val)) { + auto * textureBase = *pTextureBase; + gfx::Texture *texture = nullptr; + if (textureBase != nullptr) { + texture = textureBase->getGFXTexture(); + } + + if (texture == nullptr) { + CC_LOG_WARNING("Material(%p, %s)::bindTexture failed, texture is nullptr", this, _uuid.c_str()); + return; + } + + if (texture->getWidth() == 0 || texture->getHeight() == 0) { + CC_LOG_WARNING("Material(%p, %s)::bindTexture failed, texture size is 0", this, _uuid.c_str()); + return; + } + pass->bindTexture(binding, texture, index); + pass->bindSampler(binding, textureBase->getGFXSampler(), index); + } +} + +void Material::initDefault(const cc::optional &uuid) { + Super::initDefault(uuid); + MacroRecord defines{{"USE_COLOR", true}}; + IMaterialInfo info; + info.effectName = std::string{"unlit"}; + info.defines = IMaterialInfo::DefinesType{defines}; + initialize(info); + setProperty("mainColor", Color{0xFF, 0x00, 0xFF, 0xFF}); +} + +bool Material::validate() const { + return _effectAsset != nullptr && !_effectAsset->isDefault() && !_passes->empty(); +} + +} // namespace cc diff --git a/native/cocos/core/assets/Material.h b/native/cocos/core/assets/Material.h new file mode 100644 index 0000000000..c231dae2a9 --- /dev/null +++ b/native/cocos/core/assets/Material.h @@ -0,0 +1,362 @@ +/**************************************************************************** + 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 "core/assets/Asset.h" + +#include +#include +#include +#include "base/Ptr.h" +#include "cocos/base/Optional.h" +#include "cocos/base/Variant.h" +#include "core/Types.h" +#include "core/assets/EffectAsset.h" +#include "core/assets/TextureBase.h" +#include "renderer/core/PassUtils.h" +#include "renderer/gfx-base/GFXTexture.h" +#include "scene/Pass.h" + +namespace cc { + +//class RenderableComponent; + +/** + * @en The basic infos for material initialization. + * @zh 用来初始化材质的基本信息。 + */ +struct IMaterialInfo { + /** + * @en The EffectAsset to use. Must provide if `effectName` is not specified. + * @zh + * 这个材质将使用的 EffectAsset,直接提供资源引用,和 `effectName` 至少要指定一个。 + */ + EffectAsset *effectAsset{nullptr}; + /** + * @en + * The name of the EffectAsset to use. Must provide if `effectAsset` is not specified. + * @zh + * 这个材质将使用的 EffectAsset,通过 effect 名指定,和 `effectAsset` 至少要指定一个。 + */ + cc::optional effectName; + /** + * @en + * The index of the technique to use. + * @zh + * 这个材质将使用第几个 technique,默认为 0。 + */ + cc::optional technique; + + using DefinesType = cc::variant>; + /** + * @en + * The shader macro definitions. Default to 0 or the specified value in [[EffectAsset]]. + * @zh + * 这个材质定义的预处理宏,默认全为 0,或 [[EffectAsset]] 中的指定值。 + */ + cc::optional defines; + + using PassOverridesType = cc::variant>; + /** + * @en + * The override values on top of the pipeline states specified in [[EffectAsset]]. + * @zh + * 这个材质的自定义管线状态,将覆盖 effect 中的属性。
+ * 注意在可能的情况下请尽量少的自定义管线状态,以减小对渲染效率的影响。 + */ + cc::optional states; +}; + +class Material : public Asset { +public: + using Super = Asset; + /** + * @en Get hash for a material + * @zh 获取一个材质的哈希值 + * @param material + */ + static uint64_t getHashForMaterial(Material *material); + inline static double getHashForMaterialForJS(Material *material) { + return static_cast(getHashForMaterial(material)); + } + + Material(); + ~Material() override = default; + + /** + * @en Initialize this material with the given information. + * @zh 根据所给信息初始化这个材质,初始化正常结束后材质即可立即用于渲染。 + * @param info Material description info. + */ + void initialize(const IMaterialInfo &info); + void reset(const IMaterialInfo &info); + + void initDefault(const cc::optional &uuid) override; + bool validate() const override; + + /** + * @en + * Destroy the material definitively.
+ * Cannot re-initialize after destroy.
+ * For re-initialize purposes, call [[Material.initialize]] directly. + * @zh + * 彻底销毁材质,注意销毁后无法重新初始化。
+ * 如需重新初始化材质,不必先调用 destroy。 + */ + bool destroy() override; + + /** + * @en Recompile the shader with the specified macro overrides. Allowed only on material instances. + * @zh 使用指定预处理宏重新编译当前 pass(数组)中的 shader。只允许对材质实例执行。 + * @param overrides The shader macro override values. + * @param passIdx The pass to apply to. Will apply to all passes if not specified. + */ + virtual void recompileShaders(const MacroRecord &overrides) { + Material::recompileShaders(overrides, CC_INVALID_INDEX); + } + virtual void recompileShaders(const MacroRecord &overrides, index_t passIdx); + + /** + * @en Override the passes with the specified pipeline states. Allowed only on material instances. + * @zh 使用指定管线状态重载当前的 pass(数组)。只允许对材质实例执行。 + * @param overrides The pipeline state override values. + * @param passIdx The pass to apply to. Will apply to all passes if not specified. + */ + virtual void overridePipelineStates(const PassOverrides &overrides) { + Material::overridePipelineStates(overrides, CC_INVALID_INDEX); + } + virtual void overridePipelineStates(const PassOverrides &overrides, index_t passIdx); + + /** + * @en Callback function after material is loaded in [[Loader]]. Initialize the resources automatically. + * @zh 通过 [[Loader]] 加载完成时的回调,将自动初始化材质资源。 + */ + void onLoaded() override; + + /** + * @en Reset all the uniforms to the default value specified in [[EffectAsset]]. + * @zh 重置材质的所有 uniform 参数数据为 [[EffectAsset]] 中的默认初始值。 + * @param clearPasses Will the rendering data be cleared too? + */ + void resetUniforms(bool clearPasses = true); + + /** + * @en + * Convenient property setter provided for quick material setup.
+ * [[Pass.setUniform]] should be used instead if you need to do per-frame uniform update. + * @zh + * 设置材质 uniform 参数的统一入口。
+ * 注意如果需要每帧更新 uniform,建议使用 [[Pass.setUniform]] 以获得更好的性能。 + * @param name The target uniform name. + * @param val The target value. + * @param passIdx The pass to apply to. Will apply to all passes if not specified. + */ + void setProperty(const std::string &name, const MaterialPropertyVariant &val, index_t passIdx = CC_INVALID_INDEX); + + void setPropertyFloat32(const std::string &name, float val, index_t passIdx = CC_INVALID_INDEX); + void setPropertyInt32(const std::string &name, int32_t val, index_t passIdx = CC_INVALID_INDEX); + void setPropertyVec2(const std::string &name, const Vec2 &val, index_t passIdx = CC_INVALID_INDEX); + void setPropertyVec3(const std::string &name, const Vec3 &val, index_t passIdx = CC_INVALID_INDEX); + void setPropertyVec4(const std::string &name, const Vec4 &val, index_t passIdx = CC_INVALID_INDEX); + void setPropertyColor(const std::string &name, const Color &val, index_t passIdx = CC_INVALID_INDEX); + void setPropertyMat3(const std::string &name, const Mat3 &val, index_t passIdx = CC_INVALID_INDEX); + void setPropertyMat4(const std::string &name, const Mat4 &val, index_t passIdx = CC_INVALID_INDEX); + void setPropertyQuaternion(const std::string &name, const Quaternion &val, index_t passIdx = CC_INVALID_INDEX); + void setPropertyTextureBase(const std::string &name, TextureBase *val, index_t passIdx = CC_INVALID_INDEX); + void setPropertyGFXTexture(const std::string &name, gfx::Texture *val, index_t passIdx = CC_INVALID_INDEX); + + void setPropertyFloat32Array(const std::string &name, const std::vector &val, index_t passIdx = CC_INVALID_INDEX); + void setPropertyInt32Array(const std::string &name, const std::vector &val, index_t passIdx = CC_INVALID_INDEX); + void setPropertyVec2Array(const std::string &name, const std::vector &val, index_t passIdx = CC_INVALID_INDEX); + void setPropertyVec3Array(const std::string &name, const std::vector &val, index_t passIdx = CC_INVALID_INDEX); + void setPropertyVec4Array(const std::string &name, const std::vector &val, index_t passIdx = CC_INVALID_INDEX); + void setPropertyColorArray(const std::string &name, const std::vector &val, index_t passIdx = CC_INVALID_INDEX); + void setPropertyMat3Array(const std::string &name, const std::vector &val, index_t passIdx = CC_INVALID_INDEX); + void setPropertyMat4Array(const std::string &name, const std::vector &val, index_t passIdx = CC_INVALID_INDEX); + void setPropertyQuaternionArray(const std::string &name, const std::vector &val, index_t passIdx = CC_INVALID_INDEX); + void setPropertyTextureBaseArray(const std::string &name, const std::vector &val, index_t passIdx = CC_INVALID_INDEX); + void setPropertyGFXTextureArray(const std::string &name, const std::vector &val, index_t passIdx = CC_INVALID_INDEX); + + /** + * @en + * Get the specified uniform value for this material.
+ * Note that only uniforms set through [[Material.setProperty]] can be acquired here.
+ * For the complete rendering data, use [[Pass.getUniform]] instead. + * @zh + * 获取当前材质的指定 uniform 参数的值。
+ * 注意只有通过 [[Material.setProperty]] 函数设置的参数才能从此函数取出,
+ * 如需取出完整的渲染数据,请使用 [[Pass.getUniform]]。 + * @param name The property or uniform name. + * @param passIdx The target pass index. If not specified, return the first found value in all passes. + */ + const MaterialPropertyVariant *getProperty(const std::string &name, index_t passIdx = CC_INVALID_INDEX) const; + + /** + * @en Copy the target material. + * @zh 复制目标材质到当前实例。 + * @param mat The material to be copied. + */ + void copy(const Material *mat); + + // For deserialization, we need to make the following properties public + /* @type(EffectAsset) */ + IntrusivePtr _effectAsset; + + /* @serializable */ + uint32_t _techIdx{0}; + + /* @serializable */ + std::vector _defines; + + /* @serializable */ + std::vector _states; + + /* @serializable */ + std::vector> _props; + // + +protected: + std::shared_ptr>> _passes; + + uint64_t _hash{0}; + +public: + /** + * @en Set current [[EffectAsset]]. + * @zh 设置使用的 [[EffectAsset]] 资源。 + */ + inline void setEffectAsset(EffectAsset *val) { + _effectAsset = val; + } + + /** + * @en The current [[EffectAsset]]. + * @zh 当前使用的 [[EffectAsset]] 资源。 + */ + inline EffectAsset *getEffectAsset() const { + return _effectAsset.get(); + } + + /** + * @en Name of the current [[EffectAsset]]. + * @zh 当前使用的 [[EffectAsset]] 资源名。 + */ + inline std::string getEffectName() const { + return _effectAsset ? _effectAsset->getName() : ""; + } + + /** + * @en The current technique index. + * @zh 当前的 technique 索引。 + */ + inline uint32_t getTechniqueIndex() const { + return _techIdx; + } + + /** + * @en The passes defined in this material. + * @zh 当前正在使用的 pass 数组。 + */ + std::shared_ptr>> &getPasses() { + return _passes; + } + + /** + * @en The hash value of this material. + * @zh 材质的 hash。 + */ + inline uint64_t getHash() const { + return _hash; + } + + inline double getHashForJS() const { + return static_cast(getHash()); + } + + /** + * @en The parent material + * @zh 父材质 + */ + virtual Material *getParent() const { + return nullptr; + } + + /** + * @en The owner render component + * @zh 该材质所归属的渲染组件 + */ + // virtual RenderableComponent *getOwner() const { + // return nullptr; + // } + + void update(bool keepProps = true); // TODO(xwx): temporary use as public by demo + +protected: + bool uploadProperty(scene::Pass *pass, const std::string &name, const MaterialPropertyVariant &val); + void bindTexture(scene::Pass *pass, uint32_t handle, const MaterialProperty &val, index_t index = CC_INVALID_INDEX); + + template + void prepareInfo(const T1 &patch, std::vector &cur) { + auto *pOneElement = cc::get_if(&patch); + if (pOneElement != nullptr) { + size_t len = _effectAsset != nullptr ? _effectAsset->_techniques[_techIdx].passes.size() : 1; + + std::vector patchArray; + patchArray.reserve(len); + for (size_t i = 0; i < len; ++i) { + patchArray.emplace_back(*pOneElement); + } + + cur.resize(patchArray.size()); + + for (size_t i = 0; i < len; ++i) { + cur[i] = patchArray[i]; + } + } else { + auto *pPatchArray = cc::get_if>(&patch); + if (pPatchArray != nullptr) { + const auto &patchArray = *pPatchArray; + size_t len = patchArray.size(); + cur.resize(len); + + for (size_t i = 0; i < len; ++i) { + cur[i] = patchArray[i]; + } + } + } + } + + virtual void doDestroy(); + + virtual std::vector> createPasses(); + +private: + friend class MaterialDeserializer; + + CC_DISALLOW_COPY_MOVE_ASSIGN(Material); +}; + +} // namespace cc diff --git a/native/cocos/core/assets/RenderTexture.cpp b/native/cocos/core/assets/RenderTexture.cpp new file mode 100644 index 0000000000..c7e5c34435 --- /dev/null +++ b/native/cocos/core/assets/RenderTexture.cpp @@ -0,0 +1,155 @@ +/**************************************************************************** + 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/assets/RenderTexture.h" +#include "core/Root.h" +#include "core/utils/IDGenerator.h" +#include "renderer/gfx-base/GFXDef-common.h" + +namespace cc { + +namespace { + +gfx::ColorAttachment colorAttachment = { + gfx::Format::RGBA8, + gfx::SampleCount::ONE, + gfx::LoadOp::CLEAR, + gfx::StoreOp::STORE, + {cc::gfx::AccessType::FRAGMENT_SHADER_READ_TEXTURE}, + {cc::gfx::AccessType::FRAGMENT_SHADER_READ_TEXTURE}}; + +gfx::RenderPassInfo passInfo{ + std::vector{colorAttachment}, + gfx::DepthStencilAttachment{gfx::Format::DEPTH_STENCIL}}; + +cc::scene::IRenderWindowInfo windowInfo{ + cc::nullopt, + 1, + 1, + passInfo}; + +} // namespace + +void RenderTexture::initialize(const IRenderTextureCreateInfo &info) { + _name = info.name.has_value() ? info.name.value() : ""; + _width = info.width; + _height = info.height; + initWindow(info); +} + +void RenderTexture::reset(const IRenderTextureCreateInfo &info) { + initialize(info); +} + +bool RenderTexture::destroy() { + if (_window != nullptr) { + Root::getInstance()->destroyWindow(_window); + _window = nullptr; + } + return Super::destroy(); +} + +void RenderTexture::resize(uint32_t width, uint32_t height) { + _width = std::floor(clampf(static_cast(width), 1.F, 2048.F)); + _height = std::floor(clampf(static_cast(height), 1.F, 2048.F)); + if (_window != nullptr) { + _window->resize(_width, _height); + } + // emit(std::string("resize"), _window); //TODO(xwx): not inherit form Eventify in Asset base class +} + +gfx::Texture *RenderTexture::getGFXTexture() const { + return _window ? _window->getFramebuffer()->getColorTextures()[0] : nullptr; +} + +void RenderTexture::onLoaded() { + initWindow(); +} + +void RenderTexture::initWindow() { + windowInfo.title = _name; + windowInfo.width = _width; + windowInfo.height = _height; + windowInfo.renderPassInfo = passInfo; + + if (_window != nullptr) { + _window->destroy(); + _window->initialize(Root::getInstance()->getDevice(), windowInfo); + } else { + _window = Root::getInstance()->createWindow(windowInfo); + } +} + +void RenderTexture::initWindow(const IRenderTextureCreateInfo &info) { + windowInfo.title = _name; + windowInfo.width = _width; + windowInfo.height = _height; + if (info.passInfo.has_value()) { + windowInfo.renderPassInfo = info.passInfo.value(); + } else { + windowInfo.renderPassInfo = passInfo; + } + if (_window != nullptr) { + _window->destroy(); + _window->initialize(Root::getInstance()->getDevice(), windowInfo); + } else { + _window = Root::getInstance()->createWindow(windowInfo); + } +} + +void RenderTexture::initDefault(const cc::optional &uuid) { + Super::initDefault(uuid); + _width = 1; + _height = 1; + initWindow(); +} + +bool RenderTexture::validate() const { + return _width >= 1 && _width <= 2048 && _height >= 1 && _height <= 2048; +} + +std::vector RenderTexture::readPixels(uint32_t x, uint32_t y, uint32_t width, uint32_t height) const { + auto *gfxTexture = getGFXTexture(); + if (!gfxTexture) { + return {}; + } + + auto *gfxDevice = getGFXDevice(); + + gfx::BufferTextureCopy region0{}; + region0.texOffset.x = static_cast(x); + region0.texOffset.y = static_cast(y); + region0.texExtent.width = width; + region0.texExtent.height = height; + + std::vector buffer; + buffer.resize(width * height * 4); + uint8_t *pBuffer = buffer.data(); + gfxDevice->copyTextureToBuffers(gfxTexture, &pBuffer, ®ion0, 1); + + return buffer; +} + +} // namespace cc diff --git a/native/cocos/core/assets/RenderTexture.h b/native/cocos/core/assets/RenderTexture.h new file mode 100644 index 0000000000..764568893a --- /dev/null +++ b/native/cocos/core/assets/RenderTexture.h @@ -0,0 +1,122 @@ +/**************************************************************************** + 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 "core/assets/TextureBase.h" +#include "renderer/gfx-base/GFXDef.h" +#include "scene/RenderWindow.h" + +namespace cc { + +struct IRenderTextureCreateInfo { + cc::optional name; + uint32_t width; + uint32_t height; + cc::optional passInfo; +}; +namespace scene { +class RenderWindow; +} + +namespace gfx { +class Texture; +class Sampler; +} // namespace gfx + +/** + * @en Render texture is a render target for [[Camera]] or [[Canvas]] component, + * the render pipeline will use its [[RenderWindow]] as the target of the rendering process. + * @zh 渲染贴图是 [[Camera]] 或 [[Canvas]] 组件的渲染目标对象,渲染管线会使用它的 [[RenderWindow]] 作为渲染的目标窗口。 + */ +class RenderTexture final : public TextureBase { +public: + using Super = TextureBase; + + explicit RenderTexture() = default; + ~RenderTexture() override = default; + + /** + * @en The render window for the render pipeline, it's created internally and cannot be modified. + * @zh 渲染管线所使用的渲染窗口,内部逻辑创建,无法被修改。 + */ + inline scene::RenderWindow *getWindow() const { return _window; } + + void initialize(const IRenderTextureCreateInfo &info); + void reset(const IRenderTextureCreateInfo &info); // to be consistent with other assets + + bool destroy() override; + + /** + * @en Resize the render texture + * @zh 修改渲染贴图的尺寸 + * @param width The pixel width, the range is from 1 to 2048 + * @param height The pixel height, the range is from 1 to 2048 + */ + void resize(uint32_t width, uint32_t height); + + // TODO(minggo): migration with TextureBase data + // @ts-expect-error Hack + // get _serialize () { return null; } + // @ts-expect-error Hack + // get _deserialize () { return null; } + + // To be compatible with material property interface + /** + * @en Gets the related [[Texture]] resource, it's also the color attachment for the render window + * @zh 获取渲染贴图的 GFX 资源,同时也是渲染窗口所指向的颜色缓冲贴图资源 + */ + gfx::Texture *getGFXTexture() const override; + + void onLoaded() override; + + void initWindow(); + void initWindow(const IRenderTextureCreateInfo &info); + + void initDefault(const cc::optional &uuid) override; + + bool validate() const override; + + /** + * @en Read pixel buffer from render texture + * @param x The location on x axis + * @param y The location on y axis + * @param width The pixel width + * @param height The pixel height + * @zh 从 render texture 读取像素数据 + * @param x 起始位置X轴坐标 + * @param y 起始位置Y轴坐标 + * @param width 像素宽度 + * @param height 像素高度 + */ + std::vector readPixels(uint32_t x, uint32_t y, uint32_t width, uint32_t height) const; + +private: + scene::RenderWindow *_window{nullptr}; + + CC_DISALLOW_COPY_MOVE_ASSIGN(RenderTexture); +}; + +} // namespace cc diff --git a/native/cocos/core/assets/RenderingSubMesh.cpp b/native/cocos/core/assets/RenderingSubMesh.cpp new file mode 100644 index 0000000000..c55ae25858 --- /dev/null +++ b/native/cocos/core/assets/RenderingSubMesh.cpp @@ -0,0 +1,312 @@ +/**************************************************************************** + 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/assets/RenderingSubMesh.h" +#include +#include "3d/assets/Mesh.h" +#include "3d/misc/Buffer.h" +#include "core/DataView.h" +#include "core/TypedArray.h" +#include "math/Vec3.h" +#include "renderer/gfx-base/GFXBuffer.h" +#include "renderer/gfx-base/GFXDevice.h" + +namespace cc { + +RenderingSubMesh::RenderingSubMesh(const gfx::BufferList & vertexBuffers, + const gfx::AttributeList &attributes, + gfx::PrimitiveMode primitiveMode) +: RenderingSubMesh(vertexBuffers, attributes, primitiveMode, nullptr, nullptr) { +} + +RenderingSubMesh::RenderingSubMesh(const gfx::BufferList & vertexBuffers, + const gfx::AttributeList &attributes, + gfx::PrimitiveMode primitiveMode, + gfx::Buffer * indexBuffer) +: RenderingSubMesh(vertexBuffers, attributes, primitiveMode, indexBuffer, nullptr) { +} + +RenderingSubMesh::RenderingSubMesh(const gfx::BufferList & vertexBuffers, + const gfx::AttributeList &attributes, + gfx::PrimitiveMode primitiveMode, + gfx::Buffer * indexBuffer /* = nullptr*/, + gfx::Buffer * indirectBuffer /* = nullptr*/) +: _vertexBuffers(vertexBuffers), + _attributes(attributes), + _primitiveMode(primitiveMode), + _indexBuffer(indexBuffer), + _indirectBuffer(indirectBuffer) { + _iaInfo.attributes = attributes; + _iaInfo.vertexBuffers = vertexBuffers; + _iaInfo.indexBuffer = indexBuffer; + _iaInfo.indirectBuffer = indirectBuffer; +} + +RenderingSubMesh::~RenderingSubMesh() = default; + +const IGeometricInfo &RenderingSubMesh::getGeometricInfo() { + if (_geometricInfo.has_value()) { + return _geometricInfo.value(); + } + // NOLINTNEXTLINE + static const IGeometricInfo EMPTY_GEOMETRIC_INFO; + if (_mesh == nullptr) { + return EMPTY_GEOMETRIC_INFO; + } + + if (!_subMeshIdx.has_value()) { + return EMPTY_GEOMETRIC_INFO; + } + + auto index = static_cast(_subMeshIdx.value()); + + const auto &positionsVar = _mesh->readAttribute(index, gfx::ATTR_NAME_POSITION); + const auto *pPositions = cc::get_if(&positionsVar); + if (pPositions != nullptr) { + const auto &positions = *pPositions; + const auto &indicesVar = _mesh->readIndices(index); + + Vec3 max; + Vec3 min; + + auto iter = std::find_if(_attributes.cbegin(), _attributes.cend(), [](const gfx::Attribute &element) -> bool { + return element.name == gfx::ATTR_NAME_POSITION; + }); + if (iter != _attributes.cend()) { + const auto & attri = *iter; + const uint32_t count = gfx::GFX_FORMAT_INFOS[static_cast(attri.format)].count; + if (count == 2) { + max.set(positions[0], positions[1], 0); + min.set(positions[0], positions[1], 0); + } else { + max.set(positions[0], positions[1], positions[2]); + min.set(positions[0], positions[1], positions[2]); + } + + for (int i = 0; i < positions.length(); i += static_cast(count)) { + if (count == 2) { + max.x = positions[i] > max.x ? positions[i] : max.x; + max.y = positions[i + 1] > max.y ? positions[i + 1] : max.y; + min.x = positions[i] < min.x ? positions[i] : min.x; + min.y = positions[i + 1] < min.y ? positions[i + 1] : min.y; + } else { + max.x = positions[i] > max.x ? positions[i] : max.x; + max.y = positions[i + 1] > max.y ? positions[i + 1] : max.y; + max.z = positions[i + 2] > max.z ? positions[i + 2] : max.z; + min.x = positions[i] < min.x ? positions[i] : min.x; + min.y = positions[i + 1] < min.y ? positions[i + 1] : min.y; + min.z = positions[i + 2] < min.z ? positions[i + 2] : min.z; + } + } + + IGeometricInfo info; + info.positions = positions; + info.indices = indicesVar; + info.boundingBox.max = max; + info.boundingBox.min = min; + + _geometricInfo = info; + return _geometricInfo.value(); + } + } + + return EMPTY_GEOMETRIC_INFO; +} + +void RenderingSubMesh::genFlatBuffers() { + if (!_flatBuffers.empty() || _mesh == nullptr || !_subMeshIdx.has_value()) { + return; + } + + uint32_t idxCount = 0; + const auto &prim = _mesh->getStruct().primitives[_subMeshIdx.value()]; + if (prim.indexView.has_value()) { + idxCount = prim.indexView.value().count; + } + for (size_t i = 0; i < prim.vertexBundelIndices.size(); i++) { + const uint32_t bundleIdx = prim.vertexBundelIndices[i]; + const Mesh::IVertexBundle &vertexBundle = _mesh->getStruct().vertexBundles[bundleIdx]; + const uint32_t vbCount = prim.indexView.has_value() ? prim.indexView.value().count : vertexBundle.view.count; + const uint32_t vbStride = vertexBundle.view.stride; + const uint32_t vbSize = vbStride * vbCount; + Uint8Array view(_mesh->getData().buffer(), vertexBundle.view.offset, vertexBundle.view.length); + Uint8Array sharedView(prim.indexView.has_value() ? vbSize : vertexBundle.view.length); + + if (!prim.indexView.has_value()) { + sharedView.set(_mesh->getData().subarray(vertexBundle.view.offset, vertexBundle.view.offset + vertexBundle.view.length)); + _flatBuffers.emplace_back(IFlatBuffer{vbStride, vbCount, sharedView}); + continue; + } + + IBArray ibView = _mesh->readIndices(static_cast(_subMeshIdx.value())); + // transform to flat buffer + for (uint32_t n = 0; n < idxCount; ++n) { + auto idx = getIBArrayValue(ibView, static_cast(n)); + uint32_t offset = n * vbStride; + uint32_t srcOffset = idx * vbStride; + for (uint32_t m = 0; m < vbStride; ++m) { + sharedView[static_cast(offset + m)] = view[static_cast(srcOffset + m)]; + } + } + _flatBuffers.emplace_back(IFlatBuffer{vbStride, vbCount, std::move(sharedView)}); + } +} + +void RenderingSubMesh::enableVertexIdChannel(gfx::Device *device) { + if (_vertexIdChannel.has_value()) { + return; + } + + const auto streamIndex = static_cast(_vertexBuffers.size()); + const auto attributeIndex = static_cast(_attributes.size()); + + gfx::Buffer *vertexIdBuffer = allocVertexIdBuffer(device); + _vertexBuffers.pushBack(vertexIdBuffer); + _attributes.push_back({"a_vertexId", gfx::Format::R32F, false, streamIndex, false, 0}); + + _iaInfo.attributes = _attributes; + _iaInfo.vertexBuffers = _vertexBuffers.get(); + + _vertexIdChannel = VertexIdChannel{ + streamIndex, + attributeIndex, + }; +} + +bool RenderingSubMesh::destroy() { + for (auto *vertexBuffer : _vertexBuffers) { + vertexBuffer->destroy(); + } + _vertexBuffers.clear(); + + CC_SAFE_DESTROY_NULL(_indexBuffer); + + if (!_jointMappedBuffers.empty() && !_jointMappedBufferIndices.empty()) { + for (uint32_t index : _jointMappedBufferIndices) { + _jointMappedBuffers.at(static_cast(index))->destroy(); + } + _jointMappedBuffers.clear(); + _jointMappedBufferIndices.clear(); + } + + CC_SAFE_DESTROY_NULL(_indirectBuffer); + return true; +} + +const gfx::BufferList &RenderingSubMesh::getJointMappedBuffers() { + if (!_jointMappedBuffers.empty()) { + return _jointMappedBuffers.get(); + } + + auto &buffers = _jointMappedBuffers; + auto &indices = _jointMappedBufferIndices; + + if (!_mesh || !_subMeshIdx.has_value()) { + _jointMappedBuffers = _vertexBuffers; + return _jointMappedBuffers.get(); + } + + const auto &structInfo = _mesh->getStruct(); + const auto &prim = structInfo.primitives[_subMeshIdx.value()]; + if (!structInfo.jointMaps.has_value() || !prim.jointMapIndex.has_value() || structInfo.jointMaps.value()[prim.jointMapIndex.value()].empty()) { + _jointMappedBuffers = _vertexBuffers; + return _jointMappedBuffers.get(); + } + gfx::Format jointFormat = gfx::Format::UNKNOWN; + int32_t jointOffset = 0; + gfx::Device *device = gfx::Device::getInstance(); + for (size_t i = 0; i < prim.vertexBundelIndices.size(); i++) { + const auto &bundle = structInfo.vertexBundles[prim.vertexBundelIndices[i]]; + jointOffset = 0; + jointFormat = gfx::Format::UNKNOWN; + for (const auto &attr : bundle.attributes) { + if (attr.name == gfx::ATTR_NAME_JOINTS) { + jointFormat = attr.format; + break; + } + jointOffset += static_cast(gfx::GFX_FORMAT_INFOS[static_cast(attr.format)].size); + } + if (jointFormat != gfx::Format::UNKNOWN) { + Uint8Array data{_mesh->getData().buffer(), bundle.view.offset, bundle.view.length}; + DataView dataView(data.slice().buffer()); + const auto &idxMap = structInfo.jointMaps.value()[prim.jointMapIndex.value()]; + + mapBuffer( + dataView, [&](const DataVariant &cur, uint32_t /*idx*/, const DataView & /*view*/) -> DataVariant { + auto iter = std::find(idxMap.begin(), idxMap.end(), cc::get<0>(cur)); + if (iter != idxMap.end()) { + return static_cast(iter - idxMap.begin()); + } + CC_ASSERT(false); + return -1; + }, + jointFormat, jointOffset, bundle.view.length, bundle.view.stride, &dataView); + + auto *buffer = device->createBuffer(gfx::BufferInfo{ + gfx::BufferUsageBit::VERTEX | gfx::BufferUsageBit::TRANSFER_DST, + gfx::MemoryUsageBit::DEVICE, + bundle.view.length, + bundle.view.stride}); + + buffer->update(dataView.buffer()->getData()); + buffers.pushBack(buffer); + indices.emplace_back(i); + } else { + buffers.pushBack(_vertexBuffers.at(static_cast(prim.vertexBundelIndices[i]))); + } + } + + if (_vertexIdChannel) { + buffers.pushBack(allocVertexIdBuffer(device)); + } + return buffers.get(); +} + +gfx::Buffer *RenderingSubMesh::allocVertexIdBuffer(gfx::Device *device) { + const uint32_t vertexCount = (_vertexBuffers.empty() || _vertexBuffers.at(0)->getStride() == 0) + ? 0 + // TODO(minggo): This depends on how stride of a vertex buffer is defined; Consider padding problem. + : _vertexBuffers.at(0)->getSize() / _vertexBuffers.at(0)->getStride(); + + std::vector vertexIds(vertexCount); + for (int iVertex = 0; iVertex < vertexCount; ++iVertex) { + // `+0.5` because on some platforms, the "fetched integer" may have small error. + // For example `26` may yield `25.99999`, which is convert to `25` instead of `26` using `int()`. + vertexIds[iVertex] = static_cast(iVertex) + 0.5F; + } + + uint32_t vertexIdxByteLength = sizeof(float) * vertexCount; + gfx::Buffer *vertexIdBuffer = device->createBuffer({ + gfx::BufferUsageBit::VERTEX | gfx::BufferUsageBit::TRANSFER_DST, + gfx::MemoryUsageBit::DEVICE, + vertexIdxByteLength, + sizeof(float), + }); + vertexIdBuffer->update(vertexIds.data(), vertexIdxByteLength); + + return vertexIdBuffer; +} + +} // namespace cc diff --git a/native/cocos/core/assets/RenderingSubMesh.h b/native/cocos/core/assets/RenderingSubMesh.h new file mode 100644 index 0000000000..81c3679ca7 --- /dev/null +++ b/native/cocos/core/assets/RenderingSubMesh.h @@ -0,0 +1,210 @@ +/**************************************************************************** + 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 "3d/assets/Types.h" +#include "base/Vector.h" +#include "cocos/base/Variant.h" +#include "core/TypedArray.h" +#include "core/assets/Asset.h" +#include "renderer/gfx-base/GFXDef.h" + +namespace cc { + +class Mesh; + +/** + * @en The interface of geometric information + * @zh 几何信息。 + */ +struct IGeometricInfo { + /** + * @en Vertex positions + * @zh 顶点位置。 + */ + Float32Array positions; + + /** + * @en Indices data + * @zh 索引数据。 + */ + cc::optional indices; + + /** + * @en Whether the geometry is treated as double sided + * @zh 是否将图元按双面对待。 + */ + cc::optional doubleSided; + + /** + * @en The bounding box + * @zh 此几何体的轴对齐包围盒。 + */ + BoundingBox boundingBox; +}; + +/** + * @en Flat vertex buffer + * @zh 扁平化顶点缓冲区 + */ +struct IFlatBuffer { + uint32_t stride{0}; + uint32_t count{0}; + Uint8Array buffer; +}; + +namespace gfx { +class Buffer; +} +/** + * @en Sub mesh for rendering which contains all geometry data, it can be used to create [[InputAssembler]]. + * @zh 包含所有顶点数据的渲染子网格,可以用来创建 [[InputAssembler]]。 + */ +class RenderingSubMesh final : public Asset { +public: + RenderingSubMesh(const gfx::BufferList & vertexBuffers, + const gfx::AttributeList &attributes, + gfx::PrimitiveMode primitiveMode); + + RenderingSubMesh(const gfx::BufferList & vertexBuffers, + const gfx::AttributeList &attributes, + gfx::PrimitiveMode primitiveMode, + gfx::Buffer * indexBuffer); + + RenderingSubMesh(const gfx::BufferList & vertexBuffers, + const gfx::AttributeList &attributes, + gfx::PrimitiveMode primitiveMode, + gfx::Buffer * indexBuffer, + gfx::Buffer * indirectBuffer); + + ~RenderingSubMesh() override; + + /** + * @en All vertex attributes used by the sub mesh + * @zh 所有顶点属性。 + */ + inline const gfx::AttributeList &getAttributes() const { return _attributes; } + + /** + * @en All vertex buffers used by the sub mesh + * @zh 使用的所有顶点缓冲区。 + */ + inline const gfx::BufferList &getVertexBuffers() const { return _vertexBuffers.get(); } + + /** + * @en Index buffer used by the sub mesh + * @zh 使用的索引缓冲区,若未使用则无需指定。 + */ + inline gfx::Buffer *getIndexBuffer() const { return _indexBuffer; } + + /** + * @en Indirect buffer used by the sub mesh + * @zh 间接绘制缓冲区。 + */ + inline gfx::Buffer *indirectBuffer() const { return _indirectBuffer; } + + /** + * @en The geometric info of the sub mesh, used for raycast. + * @zh (用于射线检测的)几何信息。 + */ + const IGeometricInfo &getGeometricInfo(); + + /** + * @en Primitive mode used by the sub mesh + * @zh 图元类型。 + */ + inline gfx::PrimitiveMode getPrimitiveMode() const { return _primitiveMode; } + + /** + * @en Flatted vertex buffers + * @zh 扁平化的顶点缓冲区。 + */ + inline const std::vector &getFlatBuffers() const { return _flatBuffers; } + inline void setFlatBuffers(const std::vector &flatBuffers) { _flatBuffers = flatBuffers; } + + void genFlatBuffers(); + + inline const gfx::InputAssemblerInfo &getIaInfo() const { return _iaInfo; } + inline gfx::InputAssemblerInfo & getIaInfo() { return _iaInfo; } + + /** + * @en The vertex buffer for joint after mapping + * @zh 骨骼索引按映射表处理后的顶点缓冲。 + */ + const gfx::BufferList &getJointMappedBuffers(); + + bool destroy() override; + + /** + * @en Adds a vertex attribute input called 'a_vertexId' into this sub-mesh. + * This is useful if you want to simulate `gl_VertexId` in WebGL context prior to 2.0. + * Once you call this function, the vertex attribute is permanently added. + * Subsequent calls to this function take no effect. + * @param device Device used to create related rendering resources. + */ + void enableVertexIdChannel(gfx::Device *device); + + inline void setMesh(Mesh *mesh) { _mesh = mesh; } + inline Mesh *getMesh() const { return _mesh; } + + inline void setSubMeshIdx(uint32_t idx) { _subMeshIdx = idx; } + inline const cc::optional &getSubMeshIdx() const { return _subMeshIdx; } + +private: + gfx::Buffer *allocVertexIdBuffer(gfx::Device *device); + + // Mesh will includes RenderingSubMesh, so use Mesh* here. + Mesh * _mesh{nullptr}; + cc::optional _subMeshIdx; + + std::vector _flatBuffers; + + // As gfx::InputAssemblerInfo needs the data structure, so not use IntrusivePtr. + Vector _jointMappedBuffers; + + std::vector _jointMappedBufferIndices; + + cc::optional _vertexIdChannel; + + cc::optional _geometricInfo; + + // As gfx::InputAssemblerInfo needs the data structure, so not use IntrusivePtr. + Vector _vertexBuffers; + + gfx::AttributeList _attributes; + + IntrusivePtr _indexBuffer; + + IntrusivePtr _indirectBuffer; + + gfx::PrimitiveMode _primitiveMode{gfx::PrimitiveMode::TRIANGLE_LIST}; + + gfx::InputAssemblerInfo _iaInfo; + + CC_DISALLOW_COPY_MOVE_ASSIGN(RenderingSubMesh); +}; + +} // namespace cc diff --git a/native/cocos/core/assets/SceneAsset.cpp b/native/cocos/core/assets/SceneAsset.cpp new file mode 100644 index 0000000000..b872e82670 --- /dev/null +++ b/native/cocos/core/assets/SceneAsset.cpp @@ -0,0 +1,36 @@ +/**************************************************************************** + 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/assets/SceneAsset.h" +#include "core/scene-graph/Scene.h" + +namespace cc { + +void SceneAsset::initDefault(const cc::optional &uuid) { + Super::initDefault(uuid); + _scene = new Scene("New Scene"); +} + +} // namespace cc diff --git a/native/cocos/core/assets/SceneAsset.h b/native/cocos/core/assets/SceneAsset.h new file mode 100644 index 0000000000..224cd32409 --- /dev/null +++ b/native/cocos/core/assets/SceneAsset.h @@ -0,0 +1,63 @@ +/**************************************************************************** + 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 "core/assets/Asset.h" +#include "core/scene-graph/Scene.h" + +namespace cc { + +class Scene; + +class SceneAsset final : public Asset { +public: + using Super = Asset; + SceneAsset() = default; + ~SceneAsset() override = default; + + void initDefault(const cc::optional &uuid) override; + + bool validate() const override { + return _scene.get() != nullptr; + } + + inline Scene *getScene() const { return _scene.get(); } + inline void setScene(Scene *scene) { _scene = scene; }; + +private: + /** + * @en The scene node + * @zh 场景节点。 + + @editable + @serializable*/ + IntrusivePtr _scene; + + CC_DISALLOW_COPY_MOVE_ASSIGN(SceneAsset); +}; + +} // namespace cc diff --git a/native/cocos/core/assets/SimpleTexture.cpp b/native/cocos/core/assets/SimpleTexture.cpp new file mode 100644 index 0000000000..d41e88d0f4 --- /dev/null +++ b/native/cocos/core/assets/SimpleTexture.cpp @@ -0,0 +1,174 @@ +/**************************************************************************** + 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/assets/SimpleTexture.h" +#include "core/assets/ImageAsset.h" +#include "core/event/EventTypesToJS.h" +#include "core/platform/Macro.h" +#include "renderer/gfx-base/GFXDevice.h" + +namespace cc { + +namespace { + +uint32_t getMipLevel(uint32_t width, uint32_t height) { + uint32_t size = std::max(width, height); + uint32_t level = 0; + while (size) { + size >>= 1; + level++; + } + return level; +} + +bool isPOT(uint32_t n) { return n && (n & (n - 1)) == 0; } + +bool canGenerateMipmap(uint32_t w, uint32_t h) { + return isPOT(w) && isPOT(h); +} + +} // namespace + +bool SimpleTexture::destroy() { + tryDestroyTexture(); + return Super::destroy(); +} + +void SimpleTexture::updateImage() { + updateMipmaps(0, 0); +} + +void SimpleTexture::uploadDataWithArrayBuffer(const ArrayBuffer &source, uint32_t level /* = 0 */, uint32_t arrayIndex /* = 0 */) { + uploadData(source.getData(), level, arrayIndex); +} + +void SimpleTexture::uploadData(const uint8_t *source, uint32_t level /* = 0 */, uint32_t arrayIndex /* = 0 */) { + if (!_gfxTexture || _mipmapLevel <= level) { + return; + } + + auto *gfxDevice = getGFXDevice(); + if (!gfxDevice) { + return; + } + + gfx::BufferTextureCopy region; + region.texExtent.width = _textureWidth >> level; + region.texExtent.height = _textureHeight >> level; + region.texSubres.mipLevel = level; + region.texSubres.baseArrayLayer = arrayIndex; + + const uint8_t *buffers[1]{source}; + gfxDevice->copyBuffersToTexture(buffers, _gfxTexture, ®ion, 1); +} + +void SimpleTexture::assignImage(ImageAsset *image, uint32_t level, uint32_t arrayIndex /* = 0 */) { + const uint8_t *data = image->getData(); + if (!data) { + return; + } + + uploadData(data, level, arrayIndex); + checkTextureLoaded(); + + if (macro::CLEANUP_IMAGE_CACHE) { + //cjh how to handle dependUtils which is in asset-manager module? const deps = dependUtil.getDeps(_uuid); + // const index = deps.indexOf(image._uuid); + // if (index !== -1) { + // fastRemoveAt(deps, index); + // image.decAssetRef(); + // } + } +} + +void SimpleTexture::checkTextureLoaded() { + textureReady(); +} + +void SimpleTexture::textureReady() { + _loaded = true; + //cjh this.emit('load'); +} + +void SimpleTexture::setMipmapLevel(uint32_t value) { + _mipmapLevel = value < 1 ? 1 : value; +} + +void SimpleTexture::tryReset() { + tryDestroyTexture(); + if (_mipmapLevel == 0) { + return; + } + auto *device = getGFXDevice(); + if (!device) { + return; + } + createTexture(device); +} + +void SimpleTexture::createTexture(gfx::Device *device) { + if (_width == 0 || _height == 0) { + return; + } + + auto flags = gfx::TextureFlagBit::NONE; + if (_mipFilter != Filter::NONE && canGenerateMipmap(_width, _height)) { + _mipmapLevel = getMipLevel(_width, _height); + flags = gfx::TextureFlagBit::GEN_MIPMAP; + } + + auto textureCreateInfo = getGfxTextureCreateInfo( + gfx::TextureUsageBit::SAMPLED | gfx::TextureUsageBit::TRANSFER_DST, + getGFXFormat(), + _mipmapLevel, + flags); + + //cjh if (!textureCreateInfo) { + // return; + // } + + auto *texture = device->createTexture(textureCreateInfo); + _textureWidth = textureCreateInfo.width; + _textureHeight = textureCreateInfo.height; + + _gfxTexture = texture; + + notifyTextureUpdated(); +} + +void SimpleTexture::tryDestroyTexture() { + if (_gfxTexture != nullptr) { + _gfxTexture->destroy(); + _gfxTexture = nullptr; + + notifyTextureUpdated(); + } +} + +void SimpleTexture::notifyTextureUpdated() { + emit(EventTypesToJS::SIMPLE_TEXTURE_GFX_TEXTURE_UPDATED, _gfxTexture.get()); +} + +} // namespace cc diff --git a/native/cocos/core/assets/SimpleTexture.h b/native/cocos/core/assets/SimpleTexture.h new file mode 100644 index 0000000000..fb904e357f --- /dev/null +++ b/native/cocos/core/assets/SimpleTexture.h @@ -0,0 +1,143 @@ +/**************************************************************************** + 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 "core/ArrayBuffer.h" +#include "core/assets/Asset.h" +#include "core/assets/TextureBase.h" +#include "renderer/gfx-base/GFXTexture.h" + +namespace cc { + +class ImageAsset; + +/** + * @en The simple texture base class. + * It create the GFX Texture and can set mipmap levels. + * @zh 简单贴图基类。 + * 简单贴图内部创建了 GFX 贴图和该贴图上的 GFX 贴图视图。 + * 简单贴图允许指定不同的 Mipmap 层级。 + */ +class SimpleTexture : public TextureBase { +public: + ~SimpleTexture() override = default; + + using Super = TextureBase; + /** + * @en The mipmap level of the texture + * @zh 贴图中的 Mipmap 层级数量 + */ + inline uint32_t mipmapLevel() const { + return _mipmapLevel; + } + + /** + * @en The GFX Texture resource + * @zh 获取此贴图底层的 GFX 贴图对象。 + */ + gfx::Texture *getGFXTexture() const override { + return _gfxTexture.get(); + } + + bool destroy() override; + + /** + * @en Update the level 0 mipmap image. + * @zh 更新 0 级 Mipmap。 + */ + void updateImage(); + + /** + * @en Update the given level mipmap image. + * @zh 更新指定层级范围内的 Mipmap。当 Mipmap 数据发生了改变时应调用此方法提交更改。 + * 若指定的层级范围超出了实际已有的层级范围,只有覆盖的那些层级范围会被更新。 + * @param firstLevel First level to be updated + * @param count Mipmap level count to be updated + */ + virtual void updateMipmaps(uint32_t firstLevel, uint32_t count) {} + + /** + * @en Upload data to the given mipmap level. + * The size of the image will affect how the mipmap is updated. + * - When the image is an ArrayBuffer, the size of the image must match the mipmap size. + * - If the image size matches the mipmap size, the mipmap data will be updated entirely. + * - If the image size is smaller than the mipmap size, the mipmap will be updated from top left corner. + * - If the image size is larger, an error will be raised + * @zh 上传图像数据到指定层级的 Mipmap 中。 + * 图像的尺寸影响 Mipmap 的更新范围: + * - 当图像是 `ArrayBuffer` 时,图像的尺寸必须和 Mipmap 的尺寸一致;否则, + * - 若图像的尺寸与 Mipmap 的尺寸相同,上传后整个 Mipmap 的数据将与图像数据一致; + * - 若图像的尺寸小于指定层级 Mipmap 的尺寸(不管是长或宽),则从贴图左上角开始,图像尺寸范围内的 Mipmap 会被更新; + * - 若图像的尺寸超出了指定层级 Mipmap 的尺寸(不管是长或宽),都将引起错误。 + * @param source The source image or image data + * @param level Mipmap level to upload the image to + * @param arrayIndex The array index + */ + void uploadDataWithArrayBuffer(const ArrayBuffer &source, uint32_t level = 0, uint32_t arrayIndex = 0); + void uploadData(const uint8_t *source, uint32_t level = 0, uint32_t arrayIndex = 0); + + void assignImage(ImageAsset *image, uint32_t level, uint32_t arrayIndex = 0); + + void checkTextureLoaded(); + + /** + * Set mipmap level of this texture. + * The value is passes as presumed info to `this._getGfxTextureCreateInfo()`. + * @param value The mipmap level. + * @warn As it is invoked by subclass(TextureCube) in TS, so should make it as public. + */ + void setMipmapLevel(uint32_t value); + +protected: + explicit SimpleTexture() = default; + + void textureReady(); + + /** + * @en This method is overrided by derived classes to provide GFX texture info. + * @zh 这个方法被派生类重写以提供 GFX 纹理信息。 + * @param presumed The presumed GFX texture info. + */ + virtual gfx::TextureInfo getGfxTextureCreateInfo(gfx::TextureUsageBit usage, gfx::Format format, uint32_t levelCount, gfx::TextureFlagBit flags) = 0; + + void tryReset(); + + void createTexture(gfx::Device *device); + + void tryDestroyTexture(); + void notifyTextureUpdated(); + + IntrusivePtr _gfxTexture{nullptr}; + + uint32_t _mipmapLevel{1}; + // Cache these data to reduce JSB invoking. + uint32_t _textureWidth{0}; + uint32_t _textureHeight{0}; + + CC_DISALLOW_COPY_MOVE_ASSIGN(SimpleTexture); +}; + +} // namespace cc diff --git a/native/cocos/core/assets/TextAsset.cpp b/native/cocos/core/assets/TextAsset.cpp new file mode 100644 index 0000000000..b0309363e9 --- /dev/null +++ b/native/cocos/core/assets/TextAsset.cpp @@ -0,0 +1,26 @@ +/**************************************************************************** + 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/assets/TextAsset.h" diff --git a/native/cocos/core/assets/TextAsset.h b/native/cocos/core/assets/TextAsset.h new file mode 100644 index 0000000000..273a3a797a --- /dev/null +++ b/native/cocos/core/assets/TextAsset.h @@ -0,0 +1,56 @@ +/**************************************************************************** + 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 "core/assets/Asset.h" + +namespace cc { + +/** + * @en Class for text file. + * @zh 文本资源。 + */ +class TextAsset final : public Asset { +public: + explicit TextAsset() = default; + ~TextAsset() override = default; + /** + * @en The text content. + * @zh 此资源包含的文本。 + + @serializable + @editable*/ + std::string text; + + std::string toString() const override { + return text; + } + +private: + CC_DISALLOW_COPY_MOVE_ASSIGN(TextAsset); +}; + +} // namespace cc diff --git a/native/cocos/core/assets/Texture2D.cpp b/native/cocos/core/assets/Texture2D.cpp new file mode 100644 index 0000000000..6f595e456d --- /dev/null +++ b/native/cocos/core/assets/Texture2D.cpp @@ -0,0 +1,197 @@ +/**************************************************************************** + 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/assets/Texture2D.h" + +#include + +#include "base/Log.h" +#include "core/assets/ImageAsset.h" + +namespace cc { + +void Texture2D::syncMipmapsForJS(const std::vector> &value) { + _mipmaps = value; +} + +void Texture2D::setMipmaps(const std::vector> &value) { + _mipmaps = value; + setMipmapLevel(static_cast(_mipmaps.size())); + if (!_mipmaps.empty()) { + ImageAsset * imageAsset = _mipmaps[0]; + ITexture2DCreateInfo info; + info.width = imageAsset->getWidth(); + info.height = imageAsset->getHeight(); + info.format = imageAsset->getFormat(); + info.mipmapLevel = static_cast(_mipmaps.size()); + reset(info); + + for (size_t i = 0, len = _mipmaps.size(); i < len; ++i) { + assignImage(_mipmaps[i], static_cast(i)); + } + + } else { + ITexture2DCreateInfo info; + info.width = 0; + info.height = 0; + info.mipmapLevel = static_cast(_mipmaps.size()); + reset(info); + } +} + +void Texture2D::initialize() { + setMipmaps(_mipmaps); +} + +void Texture2D::onLoaded() { + initialize(); +} + +void Texture2D::reset(const ITexture2DCreateInfo &info) { + _width = info.width; + _height = info.height; + setGFXFormat(info.format); + setMipmapLevel(info.mipmapLevel.has_value() ? info.mipmapLevel.value() : 1); + tryReset(); +} + +void Texture2D::create(uint32_t width, uint32_t height, PixelFormat format /* = PixelFormat::RGBA8888*/, uint32_t mipmapLevel /* = 1*/) { + reset({ + width, + height, + format, + mipmapLevel, + }); +} + +std::string Texture2D::toString() const { + std::string ret; + if (!_mipmaps.empty()) { + ret = _mipmaps[0]->getUrl(); + } + return ret; +} + +void Texture2D::updateMipmaps(uint32_t firstLevel, uint32_t count) { + if (firstLevel >= _mipmaps.size()) { + return; + } + + const auto nUpdate = static_cast(std::min( + (count == 0 ? _mipmaps.size() : count), + (_mipmaps.size() - firstLevel))); + + for (uint32_t i = 0; i < nUpdate; ++i) { + uint32_t level = firstLevel + i; + assignImage(_mipmaps[level], level); + } +} + +HTMLElement *Texture2D::getHtmlElementObj() { //NOLINT + return nullptr; //cjh TODO: remove this? +} + +bool Texture2D::destroy() { + _mipmaps.clear(); + return Super::destroy(); +} + +std::string Texture2D::description() const { + std::stringstream ret; + std::string url; + if (!_mipmaps.empty()) { + url = _mipmaps[0]->getUrl(); + } + ret << ""; + return ret.str(); +} + +void Texture2D::releaseTexture() { + destroy(); +} + +cc::any Texture2D::serialize(const cc::any & /*ctxForExporting*/) { + // if (EDITOR || TEST) { + // return { + // base: super._serialize(ctxForExporting), + // mipmaps: this._mipmaps.map((mipmap) => { + // if (!mipmap || !mipmap._uuid) { + // return null; + // } + // if (ctxForExporting && ctxForExporting._compressUuid) { + // // ctxForExporting.dependsOn('_textureSource', texture); TODO + // return EditorExtends.UuidUtils.compressUuid(mipmap._uuid, true); + // } + // return mipmap._uuid; + // }), + // }; + // } + return nullptr; +} + +void Texture2D::deserialize(const cc::any &serializedData, const cc::any &handle) { + const auto *data = cc::any_cast(&serializedData); + if (data == nullptr) { + CC_LOG_WARNING("serializedData is not ITexture2DSerializeData"); + return; + } + Super::deserialize(data->base, handle); + + _mipmaps.resize(data->mipmaps.size()); + for (size_t i = 0; i < data->mipmaps.size(); ++i) { + // Prevent resource load failed + _mipmaps[i] = new ImageAsset(); + if (data->mipmaps[i].empty()) { + continue; + } + std::string mipmapUUID = data->mipmaps[i]; + //cjh TODO: handle.result.push(this._mipmaps, `${i}`, mipmapUUID, js._getClassId(ImageAsset)); + } +} + +gfx::TextureInfo Texture2D::getGfxTextureCreateInfo(gfx::TextureUsageBit usage, gfx::Format format, uint32_t levelCount, gfx::TextureFlagBit flags) { + gfx::TextureInfo texInfo; + texInfo.type = gfx::TextureType::TEX2D; + texInfo.width = _width; + texInfo.height = _height; + texInfo.usage = usage; + texInfo.format = format; + texInfo.levelCount = levelCount; + texInfo.flags = flags; + return texInfo; +} + +void Texture2D::initDefault(const cc::optional &uuid) { + Super::initDefault(uuid); + auto *imageAsset = new ImageAsset(); + imageAsset->initDefault(cc::nullopt); + setImage(imageAsset); +} + +bool Texture2D::validate() const { + return !_mipmaps.empty(); +} + +} // namespace cc diff --git a/native/cocos/core/assets/Texture2D.h b/native/cocos/core/assets/Texture2D.h new file mode 100644 index 0000000000..4d61fba9e5 --- /dev/null +++ b/native/cocos/core/assets/Texture2D.h @@ -0,0 +1,212 @@ +/**************************************************************************** + 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 "cocos/base/Optional.h" +#include "core/assets/Asset.h" +#include "core/assets/AssetEnum.h" +#include "core/assets/ImageAsset.h" +#include "core/assets/SimpleTexture.h" + +namespace cc { + +struct ITexture2DSerializeData { + std::string base; + std::vector mipmaps; +}; + +/** + * @en The create information for [[Texture2D]] + * @zh 用来创建贴图的信息。 + */ +struct ITexture2DCreateInfo { + /** + * @en The pixel width + * @zh 像素宽度。 + */ + uint32_t width{0}; + + /** + * @en The pixel height + * @zh 像素高度。 + */ + uint32_t height{0}; + + /** + * @en The pixel format + * @zh 像素格式。 + * @default PixelFormat.RGBA8888 + */ + cc::optional format; + + /** + * @en The mipmap level count + * @zh mipmap 层级。 + * @default 1 + */ + cc::optional mipmapLevel; +}; + +/** + * @en The 2D texture asset. It supports mipmap, each level of mipmap use an [[ImageAsset]]. + * @zh 二维贴图资源。二维贴图资源的每个 Mipmap 层级都为一张 [[ImageAsset]]。 + */ +class Texture2D final : public SimpleTexture { +public: + using Super = SimpleTexture; + + explicit Texture2D() = default; + ~Texture2D() override = default; + + /** + * @en All levels of mipmap images, be noted, automatically generated mipmaps are not included. + * When setup mipmap, the size of the texture and pixel format could be modified. + * @zh 所有层级 Mipmap,注意,这里不包含自动生成的 Mipmap。 + * 当设置 Mipmap 时,贴图的尺寸以及像素格式可能会改变。 + */ + const std::vector> &getMipmaps() const { + return _mipmaps; + } + + const std::vector &getMipmapsUuids() const { // TODO(xwx): temporary use _mipmaps as string array + return _mipmapsUuids; + } + + //cjh TODO: TextureCube also needs this method. + void syncMipmapsForJS(const std::vector> &value); + + void setMipmaps(const std::vector> &value); + + /** + * @en Level 0 mipmap image. + * Be noted, `this.image = img` equals `this.mipmaps = [img]`, + * sets image will clear all previous mipmaps. + * @zh 0 级 Mipmap。 + * 注意,`this.image = img` 等价于 `this.mipmaps = [img]`, + * 也就是说,通过 `this.image` 设置 0 级 Mipmap 时将隐式地清除之前的所有 Mipmap。 + */ + inline ImageAsset *getImage() const { + return _mipmaps.empty() ? nullptr : _mipmaps[0].get(); + } + + void setImage(ImageAsset *value) { + value->addAssetRef(); + std::vector> mipmaps; + if (value != nullptr) { + mipmaps.emplace_back(value); + } + setMipmaps(mipmaps); + } + + void initialize(); + + void onLoaded() override; + + /** + * @en Reset the current texture with given size, pixel format and mipmap images. + * After reset, the gfx resource will become invalid, you must use [[uploadData]] explicitly to upload the new mipmaps to GPU resources. + * @zh 将当前贴图重置为指定尺寸、像素格式以及指定 mipmap 层级。重置后,贴图的像素数据将变为未定义。 + * mipmap 图像的数据不会自动更新到贴图中,你必须显式调用 [[uploadData]] 来上传贴图数据。 + * @param info The create information + */ + void reset(const ITexture2DCreateInfo &info); + + /** + * @en Reset the current texture with given size, pixel format and mipmap images. + * After reset, the gfx resource will become invalid, you must use [[uploadData]] explicitly to upload the new mipmaps to GPU resources. + * @zh 将当前贴图重置为指定尺寸、像素格式以及指定 mipmap 层级。重置后,贴图的像素数据将变为未定义。 + * mipmap 图像的数据不会自动更新到贴图中,你必须显式调用 [[uploadData]] 来上传贴图数据。 + * @param width Pixel width + * @param height Pixel height + * @param format Pixel format + * @param mipmapLevel Mipmap level count + * @deprecated since v1.0 please use [[reset]] instead + */ + void create(uint32_t width, uint32_t height, PixelFormat format = PixelFormat::RGBA8888, uint32_t mipmapLevel = 1); + + std::string toString() const override; + + void updateMipmaps(uint32_t firstLevel, uint32_t count) override; + + /** + * @en If the level 0 mipmap image is a HTML element, then return it, otherwise return null. + * @zh 若此贴图 0 级 Mipmap 的图像资源的实际源存在并为 HTML 元素则返回它,否则返回 `null`。 + * @returns HTML element or `null` + * @deprecated Please use [[image.data]] instead + */ + HTMLElement *getHtmlElementObj(); + + /** + * @en Destroy the current 2d texture, clear up all mipmap levels and the related GPU resources. + * @zh 销毁此贴图,清空所有 Mipmap 并释放占用的 GPU 资源。 + */ + bool destroy() override; + + /** + * @en Gets the description of the 2d texture + * @zh 返回此贴图的描述。 + * @returns The description + */ + std::string description() const; + + /** + * @en Release used GPU resources. + * @zh 释放占用的 GPU 资源。 + * @deprecated please use [[destroy]] instead + */ + void releaseTexture(); + + // SERIALIZATION + + /** + * @return + */ + cc::any serialize(const cc::any &ctxForExporting) override; + + /** + * + * @param data + */ + void deserialize(const cc::any &serializedData, const cc::any &handle) override; + + gfx::TextureInfo getGfxTextureCreateInfo(gfx::TextureUsageBit usage, gfx::Format format, uint32_t levelCount, gfx::TextureFlagBit flags) override; + + void initDefault(const cc::optional &uuid) override; + + bool validate() const override; + +private: + std::vector> _mipmaps; + + std::vector _mipmapsUuids; // TODO(xwx): temporary use _mipmaps as UUIDs string array + + friend class Texture2DDeserializer; + + CC_DISALLOW_COPY_MOVE_ASSIGN(Texture2D); +}; + +} // namespace cc diff --git a/native/cocos/core/assets/TextureBase.cpp b/native/cocos/core/assets/TextureBase.cpp new file mode 100644 index 0000000000..720cd58a8c --- /dev/null +++ b/native/cocos/core/assets/TextureBase.cpp @@ -0,0 +1,186 @@ +/**************************************************************************** + 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/assets/TextureBase.h" +#include "base/StringUtil.h" +#include "core/event/EventTypesToJS.h" +#include "core/utils/IDGenerator.h" + +#include "renderer/gfx-base/GFXDevice.h" +#include "renderer/pipeline/Define.h" + +#include "MurmurHash2/MurmurHash2.h" + +namespace cc { + +namespace { +IDGenerator idGenerator("Tex"); +} + +TextureBase::TextureBase() { + // Id for generate hash in material + _id = idGenerator.getNewId(); + _gfxDevice = getGFXDevice(); + _textureHash = murmurhash2::MurmurHash2(_id.data(), static_cast(_id.length()), 666); //cjh TODO: How about using boost hash functionality? +} + +void TextureBase::setWrapMode(WrapMode wrapS, WrapMode wrapT, WrapMode wrapR) { + _wrapS = wrapS; + _samplerInfo.addressU = static_cast(wrapS), + + _wrapT = wrapT; + _samplerInfo.addressV = static_cast(wrapT), + + _wrapR = wrapR; + _samplerInfo.addressW = static_cast(wrapR); + + if (_gfxDevice != nullptr) { + _gfxSampler = _gfxDevice->getSampler(_samplerInfo); + } + + notifySamplerUpdated(); +} + +void TextureBase::setWrapMode(WrapMode wrapS, WrapMode wrapT) { + setWrapMode(wrapS, wrapT, wrapS); // wrap modes should be as consistent as possible for performance +} + +void TextureBase::setFilters(Filter minFilter, Filter magFilter) { + _minFilter = minFilter; + _samplerInfo.minFilter = static_cast(minFilter); + _magFilter = magFilter; + _samplerInfo.magFilter = static_cast(magFilter); + + if (_gfxDevice != nullptr) { + _gfxSampler = _gfxDevice->getSampler(_samplerInfo); + } + + notifySamplerUpdated(); +} + +void TextureBase::setMipFilter(Filter mipFilter) { + _mipFilter = mipFilter; + _samplerInfo.mipFilter = static_cast(mipFilter); + + if (_gfxDevice != nullptr) { + _gfxSampler = _gfxDevice->getSampler(_samplerInfo); + } + + notifySamplerUpdated(); +} + +void TextureBase::setAnisotropy(uint32_t anisotropy) { + _anisotropy = anisotropy; + _samplerInfo.maxAnisotropy = anisotropy; + + if (_gfxDevice != nullptr) { + _gfxSampler = _gfxDevice->getSampler(_samplerInfo); + } + + notifySamplerUpdated(); +} + +bool TextureBase::destroy() { + const bool destroyed = Super::destroy(); + //cjh TODO: if (destroyed && legacyCC.director.root?.batcher2D) { + // legacyCC.director.root.batcher2D._releaseDescriptorSetCache(this._textureHash); + // } + return destroyed; +} + +gfx::Sampler *TextureBase::getGFXSampler() const { + if (_gfxSampler == nullptr) { + if (_gfxDevice != nullptr) { + const_cast(this)->_gfxSampler = _gfxDevice->getSampler(_samplerInfo); + } else { + //cjh errorID(9302); + } + } + return _gfxSampler.get(); +} + +cc::any TextureBase::serialize(const cc::any & /*ctxForExporting*/) { + //cjh TODO: if (EDITOR || TEST) { + // return `${this._minFilter},${this._magFilter},${ + // this._wrapS},${this._wrapT},${ + // this._mipFilter},${this._anisotropy}`; + // } + return std::string(""); +} + +void TextureBase::deserialize(const cc::any &serializedData, const cc::any & /*handle*/) { + const auto *pData = cc::any_cast(&serializedData); + if (pData == nullptr) { + return; + } + const std::string &data = *pData; + auto fields = StringUtil::split(data, ","); + fields.insert(fields.begin(), ""); + + if (fields.size() >= 5) { + // decode filters + setFilters(static_cast(atoi(fields[1].c_str())), static_cast(atoi(fields[2].c_str()))); + // decode wraps + setWrapMode(static_cast(atoi(fields[3].c_str())), static_cast(atoi(fields[4].c_str()))); + } + + if (fields.size() >= 7) { + setMipFilter(static_cast(atoi(fields[5].c_str()))); + setAnisotropy(atoi(fields[6].c_str())); + } +} + +gfx::Device *TextureBase::getGFXDevice() { + return gfx::Device::getInstance(); +} + +gfx::Format TextureBase::getGFXFormat() const { + return getGFXPixelFormat(_format); +} + +void TextureBase::setGFXFormat(const cc::optional &format) { + _format = format.has_value() ? format.value() : PixelFormat::RGBA8888; +} + +gfx::Format TextureBase::getGFXPixelFormat(PixelFormat format) { + if (format == PixelFormat::RGBA_ETC1) { + format = PixelFormat::RGB_ETC1; + } else if (format == PixelFormat::RGB_A_PVRTC_4BPPV1) { + format = PixelFormat::RGB_PVRTC_4BPPV1; + } else if (format == PixelFormat::RGB_A_PVRTC_2BPPV1) { + format = PixelFormat::RGB_PVRTC_2BPPV1; + } + return static_cast(format); +} + +bool TextureBase::isCompressed() const { + return (_format >= PixelFormat::RGB_ETC1 && _format <= PixelFormat::RGBA_ASTC_12X12) || (_format >= PixelFormat::RGB_A_PVRTC_2BPPV1 && _format <= PixelFormat::RGBA_ETC1); +} + +void TextureBase::notifySamplerUpdated() { + emit(EventTypesToJS::TEXTURE_BASE_GFX_SAMPLER_UPDATED, _gfxSampler.get()); +} + +} // namespace cc diff --git a/native/cocos/core/assets/TextureBase.h b/native/cocos/core/assets/TextureBase.h new file mode 100644 index 0000000000..ec7723253a --- /dev/null +++ b/native/cocos/core/assets/TextureBase.h @@ -0,0 +1,263 @@ +/**************************************************************************** + 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 +#include "base/Ptr.h" +#include "core/assets/Asset.h" +#include "core/assets/AssetEnum.h" +#include "renderer/gfx-base/GFXDef.h" + +#include "cocos/base/Any.h" + +namespace cc { + +namespace gfx { +class Sampler; +class Device; +class Texture; +} // namespace gfx +/** + * @en The base texture class, it defines features shared by all textures. + * @zh 贴图资源基类。它定义了所有贴图共用的概念。 + */ +class TextureBase : public Asset { +public: + using Super = Asset; + + /** + * @en The pixel format enum. + * @zh 像素格式枚举类型 + */ + using PixelFormat = PixelFormat; + + /** + * @en The wrap mode enum. + * @zh 环绕模式枚举类型 + */ + using WrapMode = WrapMode; + + /** + * @en The texture filter mode enum + * @zh 纹理过滤模式枚举类型 + */ + using Filter = Filter; + + ~TextureBase() override = default; + /** + * @en Whether the pixel data is compressed. + * @zh 此贴图是否为压缩的像素格式。 + */ + bool isCompressed() const; + + /** + * @en Pixel width of the texture + * @zh 此贴图的像素宽度。 + */ + uint32_t getWidth() const { + return _width; + } + + /** + * @en Pixel height of the texture + * @zh 此贴图的像素高度。 + */ + uint32_t getHeight() const { + return _height; + } + + // Functions for TS deserialization. + inline void setWidth(uint32_t width) { _width = width; } + inline void setHeight(uint32_t height) { _height = height; } + + /** + * @en Gets the id of the texture + * @zh 获取标识符。 + * @returns The id + */ + inline const std::string &getId() const { + return _id; + } + + /** + * @en Gets the pixel format + * @zh 获取像素格式。 + * @returns The pixel format + */ + inline PixelFormat getPixelFormat() const { + return _format; + } + + /** + * @en Gets the anisotropy + * @zh 获取各向异性。 + * @returns The anisotropy + */ + inline uint32_t getAnisotropy() const { + return _anisotropy; + } + + /** + * @en Sets the wrap mode of the texture. + * Be noted, if the size of the texture is not power of two, only [[WrapMode.CLAMP_TO_EDGE]] is allowed. + * @zh 设置此贴图的缠绕模式。 + * 注意,若贴图尺寸不是 2 的整数幂,缠绕模式仅允许 [[WrapMode.CLAMP_TO_EDGE]]。 + * @param wrapS S(U) coordinate wrap mode + * @param wrapT T(V) coordinate wrap mode + * @param wrapR R(W) coordinate wrap mode + */ + void setWrapMode(WrapMode wrapS, WrapMode wrapT, WrapMode wrapR); + void setWrapMode(WrapMode wrapS, WrapMode wrapT); + + /** + * @en Sets the texture's filter mode + * @zh 设置此贴图的过滤算法。 + * @param minFilter Filter mode for scale down + * @param magFilter Filter mode for scale up + */ + void setFilters(Filter minFilter, Filter magFilter); + + /** + * @en Sets the texture's mip filter + * @zh 设置此贴图的缩小过滤算法。 + * @param mipFilter Filter mode for scale down + */ + void setMipFilter(Filter mipFilter); + + /** + * @en Sets the texture's anisotropy + * @zh 设置此贴图的各向异性。 + * @param anisotropy + */ + void setAnisotropy(uint32_t anisotropy); + + /** + * @en Destroy the current texture, clear up the related GPU resources. + * @zh 销毁此贴图,并释放占用的 GPU 资源。 + */ + bool destroy() override; + + /** + * @en Gets the texture hash. + * @zh 获取此贴图的哈希值。 + */ + inline uint64_t getHash() const { + return _textureHash; + } + + inline double getHashForJS() const { + return static_cast(getHash()); + } + + /** + * @en Gets the GFX Texture resource + * @zh 获取此贴图底层的 GFX 贴图对象。 + */ + virtual gfx::Texture *getGFXTexture() const { + return nullptr; + } + + /** + * @en Gets the internal GFX sampler hash. + * @zh 获取此贴图内部使用的 GFX 采样器信息。 + * @private + */ + virtual const gfx::SamplerInfo &getSamplerInfo() const { + return _samplerInfo; + } + + /** + * @en Gets the sampler resource for the texture + * @zh 获取此贴图底层的 GFX 采样信息。 + */ + virtual gfx::Sampler *getGFXSampler() const; + + // SERIALIZATION + /** + * @return + */ + cc::any serialize(const cc::any &ctxForExporting) override; + + /** + * + * @param data + */ + void deserialize(const cc::any &serializedData, const cc::any &handle) override; + +protected: + static gfx::Device *getGFXDevice(); + static gfx::Format getGFXPixelFormat(PixelFormat format); + + TextureBase(); + + gfx::Format getGFXFormat() const; + + void setGFXFormat(const cc::optional &format); + +private: + void notifySamplerUpdated(); + +public: + /*@serializable*/ + PixelFormat _format{PixelFormat::RGBA8888}; + + /*@serializable*/ + Filter _minFilter{Filter::LINEAR}; + + /*@serializable*/ + Filter _magFilter{Filter::LINEAR}; + + /*@serializable*/ + Filter _mipFilter{Filter::NONE}; + + /*@serializable*/ + WrapMode _wrapS{WrapMode::REPEAT}; + + /*@serializable*/ + WrapMode _wrapT{WrapMode::REPEAT}; + + /*@serializable*/ + WrapMode _wrapR{WrapMode::REPEAT}; + + /*@serializable*/ + uint32_t _anisotropy{0}; + + uint32_t _width{1}; + uint32_t _height{1}; + +protected: + std::string _id; + gfx::SamplerInfo _samplerInfo; + IntrusivePtr _gfxSampler; + gfx::Device * _gfxDevice{nullptr}; + + uint64_t _textureHash{0}; + +private: + CC_DISALLOW_COPY_MOVE_ASSIGN(TextureBase); +}; + +} // namespace cc diff --git a/native/cocos/core/assets/TextureCube.cpp b/native/cocos/core/assets/TextureCube.cpp new file mode 100644 index 0000000000..9b0571c9ba --- /dev/null +++ b/native/cocos/core/assets/TextureCube.cpp @@ -0,0 +1,241 @@ +/**************************************************************************** + 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/assets/TextureCube.h" +#include "core/assets/ImageAsset.h" +#include "renderer/gfx-base/GFXTexture.h" + +namespace cc { + +namespace { + +using ForEachFaceCallback = std::function; +/** + * @param {Mipmap} mipmap + * @param {(face: ImageAsset) => void} callback + */ +void forEachFace(const ITextureCubeMipmap &mipmap, const ForEachFaceCallback &callback) { + callback(mipmap.front, TextureCube::FaceIndex::FRONT); + callback(mipmap.back, TextureCube::FaceIndex::BACK); + callback(mipmap.left, TextureCube::FaceIndex::LEFT); + callback(mipmap.right, TextureCube::FaceIndex::RIGHT); + callback(mipmap.top, TextureCube::FaceIndex::TOP); + callback(mipmap.bottom, TextureCube::FaceIndex::BOTTOM); +} + +} // namespace + +/* static */ +TextureCube *TextureCube::fromTexture2DArray(const std::vector &textures) { + size_t nMipmaps = textures.size() / 6; + std::vector mipmaps; + mipmaps.reserve(nMipmaps); + for (size_t i = 0; i < nMipmaps; i++) { + size_t x = i * 6; + + ITextureCubeMipmap mipmap; + mipmap.front = textures[x + static_cast(FaceIndex::FRONT)]->getImage(), + mipmap.back = textures[x + static_cast(FaceIndex::BACK)]->getImage(), + mipmap.left = textures[x + static_cast(FaceIndex::LEFT)]->getImage(), + mipmap.right = textures[x + static_cast(FaceIndex::RIGHT)]->getImage(), + mipmap.top = textures[x + static_cast(FaceIndex::TOP)]->getImage(), + mipmap.bottom = textures[x + static_cast(FaceIndex::BOTTOM)]->getImage(), + + mipmaps.emplace_back(mipmap); + } + auto *out = new TextureCube(); + out->setMipmaps(mipmaps); + return out; +} + +void TextureCube::setMipmaps(const std::vector &value) { + _mipmaps = value; + setMipmapLevel(static_cast(_mipmaps.size())); + if (!_mipmaps.empty()) { + ImageAsset *imageAsset = _mipmaps[0].front; + reset({ + imageAsset->getWidth(), + imageAsset->getHeight(), + imageAsset->getFormat(), + static_cast(_mipmaps.size()), + }); + + for (size_t level = 0, len = _mipmaps.size(); level < len; ++level) { + forEachFace(_mipmaps[level], [this, level](ImageAsset *face, TextureCube::FaceIndex faceIndex) { + assignImage(face, static_cast(level), static_cast(faceIndex)); + }); + ; + } + + } else { + reset({ + 0, + 0, + cc::nullopt, + static_cast(_mipmaps.size()), + }); + } +} + +void TextureCube::reset(const ITextureCubeCreateInfo &info) { + _width = info.width; + _height = info.height; + setGFXFormat(info.format); + setMipmapLevel(info.mipmapLevel.has_value() ? info.mipmapLevel.value() : 1); + tryReset(); +} + +void TextureCube::releaseTexture() { + _mipmaps.clear(); +} + +void TextureCube::updateMipmaps(uint32_t firstLevel, uint32_t count) { + if (firstLevel >= _mipmaps.size()) { + return; + } + + auto nUpdate = static_cast(std::min( + count == 0 ? _mipmaps.size() : count, + _mipmaps.size() - firstLevel)); + + for (uint32_t i = 0; i < nUpdate; ++i) { + uint32_t level = firstLevel + i; + forEachFace(_mipmaps[level], [this, level](auto face, auto faceIndex) { + assignImage(face, level, static_cast(faceIndex)); + }); + } +} + +void TextureCube::initialize() { + setMipmaps(_mipmaps); +} + +void TextureCube::onLoaded() { + initialize(); +} + +bool TextureCube::destroy() { + _mipmaps.clear(); + return Super::destroy(); +} + +cc::any TextureCube::serialize(const cc::any & /*ctxForExporting*/) { + //cjh TODO: if (EDITOR || TEST) { + // return { + // base: super._serialize(ctxForExporting), + // rgbe: this.isRGBE, + // mipmaps: this._mipmaps.map((mipmap) => ((ctxForExporting && ctxForExporting._compressUuid) ? { + // front: EditorExtends.UuidUtils.compressUuid(mipmap.front._uuid, true), + // back: EditorExtends.UuidUtils.compressUuid(mipmap.back._uuid, true), + // left: EditorExtends.UuidUtils.compressUuid(mipmap.left._uuid, true), + // right: EditorExtends.UuidUtils.compressUuid(mipmap.right._uuid, true), + // top: EditorExtends.UuidUtils.compressUuid(mipmap.top._uuid, true), + // bottom: EditorExtends.UuidUtils.compressUuid(mipmap.bottom._uuid, true), + // } : { + // front: mipmap.front._uuid, + // back: mipmap.back._uuid, + // left: mipmap.left._uuid, + // right: mipmap.right._uuid, + // top: mipmap.top._uuid, + // bottom: mipmap.bottom._uuid, + // })), + // }; + // } + return nullptr; +} + +void TextureCube::deserialize(const cc::any &serializedData, const cc::any &handle) { + const auto *data = cc::any_cast(&serializedData); + if (data == nullptr) { + return; + } + Super::deserialize(data->base, handle); + isRGBE = data->rgbe; + + _mipmaps.resize(data->mipmaps.size()); + for (size_t i = 0; i < data->mipmaps.size(); ++i) { + // Prevent resource load failed + ITextureCubeMipmap mipmap; + mipmap.front = new ImageAsset(), + mipmap.back = new ImageAsset(), + mipmap.left = new ImageAsset(), + mipmap.right = new ImageAsset(), + mipmap.top = new ImageAsset(), + mipmap.bottom = new ImageAsset(); + _mipmaps[i] = mipmap; + // auto* mipmap = data->mipmaps[i]; + + //cjh TODO: what's handle.result?? const imageAssetClassId = js._getClassId(ImageAsset); + // + // handle.result.push(this._mipmaps[i], `front`, mipmap.front, imageAssetClassId); + // handle.result.push(this._mipmaps[i], `back`, mipmap.back, imageAssetClassId); + // handle.result.push(this._mipmaps[i], `left`, mipmap.left, imageAssetClassId); + // handle.result.push(this._mipmaps[i], `right`, mipmap.right, imageAssetClassId); + // handle.result.push(this._mipmaps[i], `top`, mipmap.top, imageAssetClassId); + // handle.result.push(this._mipmaps[i], `bottom`, mipmap.bottom, imageAssetClassId); + } +} + +gfx::TextureInfo TextureCube::getGfxTextureCreateInfo(gfx::TextureUsageBit usage, gfx::Format format, uint32_t levelCount, gfx::TextureFlagBit flags) { + gfx::TextureInfo texInfo; + texInfo.type = gfx::TextureType::CUBE; + texInfo.width = _width; + texInfo.height = _height; + texInfo.layerCount = 6; + texInfo.usage = usage; + texInfo.format = format; + texInfo.levelCount = levelCount; + texInfo.flags = flags; + return texInfo; +} + +void TextureCube::initDefault(const cc::optional &uuid) { + Super::initDefault(uuid); + + auto *imageAsset = new ImageAsset(); + imageAsset->initDefault(cc::nullopt); + + ITextureCubeMipmap mipmap; + + mipmap.front = imageAsset; + mipmap.back = imageAsset; + mipmap.top = imageAsset; + mipmap.bottom = imageAsset; + mipmap.left = imageAsset; + mipmap.right = imageAsset; + + setMipmaps({mipmap}); +} + +bool TextureCube::validate() const { + if (_mipmaps.empty()) { + return false; + } + + //cjh TODO: return !_mipmaps.empty() && !_mipmaps.find((x) => !(x.top && x.bottom && x.front && x.back && x.left && x.right)); + return false; +} + +} // namespace cc diff --git a/native/cocos/core/assets/TextureCube.h b/native/cocos/core/assets/TextureCube.h new file mode 100644 index 0000000000..e256002e4b --- /dev/null +++ b/native/cocos/core/assets/TextureCube.h @@ -0,0 +1,188 @@ +/**************************************************************************** + 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 "core/assets/Asset.h" +#include "core/assets/SimpleTexture.h" +#include "core/assets/Texture2D.h" + +namespace cc { + +class ImageAsset; + +using ITextureCubeCreateInfo = ITexture2DCreateInfo; + +/** + * @en The texture cube mipmap interface + * @zh 立方体贴图的 Mipmap 接口。 + */ +struct ITextureCubeMipmap { + IntrusivePtr front; + IntrusivePtr back; + IntrusivePtr left; + IntrusivePtr right; + IntrusivePtr top; + IntrusivePtr bottom; +}; + +struct ITextureCubeSerializeMipmapData { + std::string front; + std::string back; + std::string left; + std::string right; + std::string top; + std::string bottom; +}; + +struct ITextureCubeSerializeData { + std::string base; + bool rgbe{false}; + std::vector mipmaps; +}; + +/** + * @en The texture cube asset. + * Each mipmap level of a texture cube have 6 [[ImageAsset]], represents 6 faces of the cube. + * @zh 立方体贴图资源。 + * 立方体贴图资源的每个 Mipmap 层级都为 6 张 [[ImageAsset]],分别代表了立方体贴图的 6 个面。 + */ +class TextureCube final : public SimpleTexture { +public: + using Super = SimpleTexture; + + explicit TextureCube() = default; + ~TextureCube() override = default; + + /** + * @en The index for all faces of the cube + * @zh 立方体每个面的约定索引。 + */ + enum class FaceIndex { + RIGHT = 0, + LEFT = 1, + TOP = 2, + BOTTOM = 3, + FRONT = 4, + BACK = 5, + }; + + /** + * @en Create a texture cube with an array of [[Texture2D]] which represents 6 faces of the texture cube. + * @zh 通过二维贴图数组指定每个 Mipmap 的每个面创建立方体贴图。 + * @param textures Texture array, the texture count must be multiple of 6. Every 6 textures are 6 faces of a mipmap level. + * The order should obey [[FaceIndex]] order. + * @param out Output texture cube, if not given, will create a new texture cube. + * @returns The created texture cube. + * @example + * ```ts + * const textures = new Array(6); + * textures[TextureCube.FaceIndex.front] = frontImage; + * textures[TextureCube.FaceIndex.back] = backImage; + * textures[TextureCube.FaceIndex.left] = leftImage; + * textures[TextureCube.FaceIndex.right] = rightImage; + * textures[TextureCube.FaceIndex.top] = topImage; + * textures[TextureCube.FaceIndex.bottom] = bottomImage; + * const textureCube = TextureCube.fromTexture2DArray(textures); + * ``` + */ + static TextureCube *fromTexture2DArray(const std::vector &textures); + + /** + * @en All levels of mipmap images, be noted, automatically generated mipmaps are not included. + * When setup mipmap, the size of the texture and pixel format could be modified. + * @zh 所有层级 Mipmap,注意,这里不包含自动生成的 Mipmap。 + * 当设置 Mipmap 时,贴图的尺寸以及像素格式可能会改变。 + */ + const std::vector &getMipmaps() const { + return _mipmaps; + } + + void setMipmaps(const std::vector &value); + + /** + * @en Level 0 mipmap image. + * Be noted, `this.image = img` equals `this.mipmaps = [img]`, + * sets image will clear all previous mipmaps. + * @zh 0 级 Mipmap。 + * 注意,`this.image = img` 等价于 `this.mipmaps = [img]`, + * 也就是说,通过 `this.image` 设置 0 级 Mipmap 时将隐式地清除之前的所有 Mipmap。 + */ + const ITextureCubeMipmap *getImage() const { + return _mipmaps.empty() ? nullptr : &_mipmaps[0]; + } + + void setImage(const ITextureCubeMipmap &value) { + _mipmaps.clear(); + _mipmaps.emplace_back(value); + } + + /** + * @en Reset the current texture with given size, pixel format and mipmap images. + * After reset, the gfx resource will become invalid, you must use [[uploadData]] explicitly to upload the new mipmaps to GPU resources. + * @zh 将当前贴图重置为指定尺寸、像素格式以及指定 mipmap 层级。重置后,贴图的像素数据将变为未定义。 + * mipmap 图像的数据不会自动更新到贴图中,你必须显式调用 [[uploadData]] 来上传贴图数据。 + * @param info The create information + */ + void reset(const ITextureCubeCreateInfo &info); + + /** + * @en Release used GPU resources. + * @zh 释放占用的 GPU 资源。 + * @deprecated please use [[destroy]] instead + */ + void releaseTexture(); + + // Override functions + void updateMipmaps(uint32_t firstLevel, uint32_t count) override; + + void initialize(); + void onLoaded() override; + /** + * 销毁此贴图,清空所有 Mipmap 并释放占用的 GPU 资源。 + */ + bool destroy() override; + + cc::any serialize(const cc::any &ctxForExporting) override; + void deserialize(const cc::any &serializedData, const cc::any &handle) override; + + gfx::TextureInfo getGfxTextureCreateInfo(gfx::TextureUsageBit usage, gfx::Format format, uint32_t levelCount, gfx::TextureFlagBit flags) override; + + void initDefault(const cc::optional &uuid) override; + + bool validate() const override; + // + + /*@serializable*/ + bool isRGBE{false}; + + /*@serializable*/ + std::vector _mipmaps; + +private: + CC_DISALLOW_COPY_MOVE_ASSIGN(TextureCube); +}; + +} // namespace cc diff --git a/native/cocos/core/builtin/.gitignore b/native/cocos/core/builtin/.gitignore new file mode 100644 index 0000000000..387e8ad7dd --- /dev/null +++ b/native/cocos/core/builtin/.gitignore @@ -0,0 +1,7 @@ +# generated files +Effects.cpp +shader-sources/glsl1.cpp +shader-sources/glsl3.cpp +shader-sources/glsl4.cpp +shader-sources/*.js +*.js diff --git a/native/cocos/core/builtin/BuiltinResMgr.cpp b/native/cocos/core/builtin/BuiltinResMgr.cpp new file mode 100644 index 0000000000..b38a06e931 --- /dev/null +++ b/native/cocos/core/builtin/BuiltinResMgr.cpp @@ -0,0 +1,511 @@ +#include "core/builtin/BuiltinResMgr.h" +#include "core/assets/EffectAsset.h" +#include "core/assets/ImageAsset.h" +#include "core/assets/Material.h" +#include "core/assets/Texture2D.h" +#include "core/assets/TextureCube.h" +#include "core/builtin/Effects.h" +#include "core/builtin/ShaderSourceAssembly.h" +#include "core/data/deserializer/AssetDeserializerFactory.h" +#include "math/Color.h" +#include "platform/Image.h" +#include "rapidjson/document.h" +#include "renderer/core/ProgramLib.h" +#include "scene/Pass.h" + +namespace cc { + +namespace { +BuiltinResMgr *instance = nullptr; + +constexpr uint8_t BLACK_IMAGE_RGBA_DATA_2X2[2 * 2 * 4] = { + // r, g, b, a + 0x00, 0x00, 0x00, 0xFF, + 0x00, 0x00, 0x00, 0xFF, + 0x00, 0x00, 0x00, 0xFF, + 0x00, 0x00, 0x00, 0xFF}; + +constexpr uint8_t GREY_IMAGE_RGBA_DATA_2X2[2 * 2 * 4] = { + 0x77, 0x77, 0x77, 0xFF, + 0x77, 0x77, 0x77, 0xFF, + 0x77, 0x77, 0x77, 0xFF, + 0x77, 0x77, 0x77, 0xFF}; + +constexpr uint8_t WHITE_IMAGE_RGBA_DATA_2X2[2 * 2 * 4] = { + 0xFF, 0xFF, 0xFF, 0xFF, + 0xFF, 0xFF, 0xFF, 0xFF, + 0xFF, 0xFF, 0xFF, 0xFF, + 0xFF, 0xFF, 0xFF, 0xFF}; + +constexpr uint8_t NORMAL_IMAGE_RGBA_DATA_2X2[2 * 2 * 4] = { + 0x7F, 0x7F, 0xFF, 0xFF, + 0x7F, 0x7F, 0xFF, 0xFF, + 0x7F, 0x7F, 0xFF, 0xFF, + 0x7F, 0x7F, 0xFF, 0xFF}; + +constexpr uint8_t EMPTY_IMAGE_RGBA_DATA_2X2[2 * 2 * 4] = { + 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00}; + +const uint8_t DEFAULT_IMAGE_RGBA_DATA_16X16[16 * 16 * 4] = { + 0x55, 0x55, 0x55, 0xFF, 0x55, 0x55, 0x55, 0xFF, 0x55, 0x55, 0x55, 0xFF, 0x55, 0x55, 0x55, 0xFF, + 0x55, 0x55, 0x55, 0xFF, 0x55, 0x55, 0x55, 0xFF, 0x55, 0x55, 0x55, 0xFF, 0x55, 0x55, 0x55, 0xFF, + 0xDD, 0xDD, 0xDD, 0xFF, 0xDD, 0xDD, 0xDD, 0xFF, 0xDD, 0xDD, 0xDD, 0xFF, 0xDD, 0xDD, 0xDD, 0xFF, + 0xDD, 0xDD, 0xDD, 0xFF, 0xDD, 0xDD, 0xDD, 0xFF, 0xDD, 0xDD, 0xDD, 0xFF, 0xDD, 0xDD, 0xDD, 0xFF, + 0x55, 0x55, 0x55, 0xFF, 0x55, 0x55, 0x55, 0xFF, 0x55, 0x55, 0x55, 0xFF, 0x55, 0x55, 0x55, 0xFF, + 0x55, 0x55, 0x55, 0xFF, 0x55, 0x55, 0x55, 0xFF, 0x55, 0x55, 0x55, 0xFF, 0x55, 0x55, 0x55, 0xFF, + 0xDD, 0xDD, 0xDD, 0xFF, 0xDD, 0xDD, 0xDD, 0xFF, 0xDD, 0xDD, 0xDD, 0xFF, 0xDD, 0xDD, 0xDD, 0xFF, + 0xDD, 0xDD, 0xDD, 0xFF, 0xDD, 0xDD, 0xDD, 0xFF, 0xDD, 0xDD, 0xDD, 0xFF, 0xDD, 0xDD, 0xDD, 0xFF, + 0x55, 0x55, 0x55, 0xFF, 0x55, 0x55, 0x55, 0xFF, 0x55, 0x55, 0x55, 0xFF, 0x55, 0x55, 0x55, 0xFF, + 0x55, 0x55, 0x55, 0xFF, 0x55, 0x55, 0x55, 0xFF, 0x55, 0x55, 0x55, 0xFF, 0x55, 0x55, 0x55, 0xFF, + 0xDD, 0xDD, 0xDD, 0xFF, 0xDD, 0xDD, 0xDD, 0xFF, 0xDD, 0xDD, 0xDD, 0xFF, 0xDD, 0xDD, 0xDD, 0xFF, + 0xDD, 0xDD, 0xDD, 0xFF, 0xDD, 0xDD, 0xDD, 0xFF, 0xDD, 0xDD, 0xDD, 0xFF, 0xDD, 0xDD, 0xDD, 0xFF, + 0x55, 0x55, 0x55, 0xFF, 0x55, 0x55, 0x55, 0xFF, 0x55, 0x55, 0x55, 0xFF, 0x55, 0x55, 0x55, 0xFF, + 0x55, 0x55, 0x55, 0xFF, 0x55, 0x55, 0x55, 0xFF, 0x55, 0x55, 0x55, 0xFF, 0x55, 0x55, 0x55, 0xFF, + 0xDD, 0xDD, 0xDD, 0xFF, 0xDD, 0xDD, 0xDD, 0xFF, 0xDD, 0xDD, 0xDD, 0xFF, 0xDD, 0xDD, 0xDD, 0xFF, + 0xDD, 0xDD, 0xDD, 0xFF, 0xDD, 0xDD, 0xDD, 0xFF, 0xDD, 0xDD, 0xDD, 0xFF, 0xDD, 0xDD, 0xDD, 0xFF, + 0x55, 0x55, 0x55, 0xFF, 0x55, 0x55, 0x55, 0xFF, 0x55, 0x55, 0x55, 0xFF, 0x55, 0x55, 0x55, 0xFF, + 0x55, 0x55, 0x55, 0xFF, 0x55, 0x55, 0x55, 0xFF, 0x55, 0x55, 0x55, 0xFF, 0x55, 0x55, 0x55, 0xFF, + 0xDD, 0xDD, 0xDD, 0xFF, 0xDD, 0xDD, 0xDD, 0xFF, 0xDD, 0xDD, 0xDD, 0xFF, 0xDD, 0xDD, 0xDD, 0xFF, + 0xDD, 0xDD, 0xDD, 0xFF, 0xDD, 0xDD, 0xDD, 0xFF, 0xDD, 0xDD, 0xDD, 0xFF, 0xDD, 0xDD, 0xDD, 0xFF, + 0x55, 0x55, 0x55, 0xFF, 0x55, 0x55, 0x55, 0xFF, 0x55, 0x55, 0x55, 0xFF, 0x55, 0x55, 0x55, 0xFF, + 0x55, 0x55, 0x55, 0xFF, 0x55, 0x55, 0x55, 0xFF, 0x55, 0x55, 0x55, 0xFF, 0x55, 0x55, 0x55, 0xFF, + 0xDD, 0xDD, 0xDD, 0xFF, 0xDD, 0xDD, 0xDD, 0xFF, 0xDD, 0xDD, 0xDD, 0xFF, 0xDD, 0xDD, 0xDD, 0xFF, + 0xDD, 0xDD, 0xDD, 0xFF, 0xDD, 0xDD, 0xDD, 0xFF, 0xDD, 0xDD, 0xDD, 0xFF, 0xDD, 0xDD, 0xDD, 0xFF, + 0x55, 0x55, 0x55, 0xFF, 0x55, 0x55, 0x55, 0xFF, 0x55, 0x55, 0x55, 0xFF, 0x55, 0x55, 0x55, 0xFF, + 0x55, 0x55, 0x55, 0xFF, 0x55, 0x55, 0x55, 0xFF, 0x55, 0x55, 0x55, 0xFF, 0x55, 0x55, 0x55, 0xFF, + 0xDD, 0xDD, 0xDD, 0xFF, 0xDD, 0xDD, 0xDD, 0xFF, 0xDD, 0xDD, 0xDD, 0xFF, 0xDD, 0xDD, 0xDD, 0xFF, + 0xDD, 0xDD, 0xDD, 0xFF, 0xDD, 0xDD, 0xDD, 0xFF, 0xDD, 0xDD, 0xDD, 0xFF, 0xDD, 0xDD, 0xDD, 0xFF, + 0x55, 0x55, 0x55, 0xFF, 0x55, 0x55, 0x55, 0xFF, 0x55, 0x55, 0x55, 0xFF, 0x55, 0x55, 0x55, 0xFF, + 0x55, 0x55, 0x55, 0xFF, 0x55, 0x55, 0x55, 0xFF, 0x55, 0x55, 0x55, 0xFF, 0x55, 0x55, 0x55, 0xFF, + 0xDD, 0xDD, 0xDD, 0xFF, 0xDD, 0xDD, 0xDD, 0xFF, 0xDD, 0xDD, 0xDD, 0xFF, 0xDD, 0xDD, 0xDD, 0xFF, + 0xDD, 0xDD, 0xDD, 0xFF, 0xDD, 0xDD, 0xDD, 0xFF, 0xDD, 0xDD, 0xDD, 0xFF, 0xDD, 0xDD, 0xDD, 0xFF, + 0xDD, 0xDD, 0xDD, 0xFF, 0xDD, 0xDD, 0xDD, 0xFF, 0xDD, 0xDD, 0xDD, 0xFF, 0xDD, 0xDD, 0xDD, 0xFF, + 0xDD, 0xDD, 0xDD, 0xFF, 0xDD, 0xDD, 0xDD, 0xFF, 0xDD, 0xDD, 0xDD, 0xFF, 0xDD, 0xDD, 0xDD, 0xFF, + 0x55, 0x55, 0x55, 0xFF, 0x55, 0x55, 0x55, 0xFF, 0x55, 0x55, 0x55, 0xFF, 0x55, 0x55, 0x55, 0xFF, + 0x55, 0x55, 0x55, 0xFF, 0x55, 0x55, 0x55, 0xFF, 0x55, 0x55, 0x55, 0xFF, 0x55, 0x55, 0x55, 0xFF, + 0xDD, 0xDD, 0xDD, 0xFF, 0xDD, 0xDD, 0xDD, 0xFF, 0xDD, 0xDD, 0xDD, 0xFF, 0xDD, 0xDD, 0xDD, 0xFF, + 0xDD, 0xDD, 0xDD, 0xFF, 0xDD, 0xDD, 0xDD, 0xFF, 0xDD, 0xDD, 0xDD, 0xFF, 0xDD, 0xDD, 0xDD, 0xFF, + 0x55, 0x55, 0x55, 0xFF, 0x55, 0x55, 0x55, 0xFF, 0x55, 0x55, 0x55, 0xFF, 0x55, 0x55, 0x55, 0xFF, + 0x55, 0x55, 0x55, 0xFF, 0x55, 0x55, 0x55, 0xFF, 0x55, 0x55, 0x55, 0xFF, 0x55, 0x55, 0x55, 0xFF, + 0xDD, 0xDD, 0xDD, 0xFF, 0xDD, 0xDD, 0xDD, 0xFF, 0xDD, 0xDD, 0xDD, 0xFF, 0xDD, 0xDD, 0xDD, 0xFF, + 0xDD, 0xDD, 0xDD, 0xFF, 0xDD, 0xDD, 0xDD, 0xFF, 0xDD, 0xDD, 0xDD, 0xFF, 0xDD, 0xDD, 0xDD, 0xFF, + 0x55, 0x55, 0x55, 0xFF, 0x55, 0x55, 0x55, 0xFF, 0x55, 0x55, 0x55, 0xFF, 0x55, 0x55, 0x55, 0xFF, + 0x55, 0x55, 0x55, 0xFF, 0x55, 0x55, 0x55, 0xFF, 0x55, 0x55, 0x55, 0xFF, 0x55, 0x55, 0x55, 0xFF, + 0xDD, 0xDD, 0xDD, 0xFF, 0xDD, 0xDD, 0xDD, 0xFF, 0xDD, 0xDD, 0xDD, 0xFF, 0xDD, 0xDD, 0xDD, 0xFF, + 0xDD, 0xDD, 0xDD, 0xFF, 0xDD, 0xDD, 0xDD, 0xFF, 0xDD, 0xDD, 0xDD, 0xFF, 0xDD, 0xDD, 0xDD, 0xFF, + 0x55, 0x55, 0x55, 0xFF, 0x55, 0x55, 0x55, 0xFF, 0x55, 0x55, 0x55, 0xFF, 0x55, 0x55, 0x55, 0xFF, + 0x55, 0x55, 0x55, 0xFF, 0x55, 0x55, 0x55, 0xFF, 0x55, 0x55, 0x55, 0xFF, 0x55, 0x55, 0x55, 0xFF, + 0xDD, 0xDD, 0xDD, 0xFF, 0xDD, 0xDD, 0xDD, 0xFF, 0xDD, 0xDD, 0xDD, 0xFF, 0xDD, 0xDD, 0xDD, 0xFF, + 0xDD, 0xDD, 0xDD, 0xFF, 0xDD, 0xDD, 0xDD, 0xFF, 0xDD, 0xDD, 0xDD, 0xFF, 0xDD, 0xDD, 0xDD, 0xFF, + 0x55, 0x55, 0x55, 0xFF, 0x55, 0x55, 0x55, 0xFF, 0x55, 0x55, 0x55, 0xFF, 0x55, 0x55, 0x55, 0xFF, + 0x55, 0x55, 0x55, 0xFF, 0x55, 0x55, 0x55, 0xFF, 0x55, 0x55, 0x55, 0xFF, 0x55, 0x55, 0x55, 0xFF, + 0xDD, 0xDD, 0xDD, 0xFF, 0xDD, 0xDD, 0xDD, 0xFF, 0xDD, 0xDD, 0xDD, 0xFF, 0xDD, 0xDD, 0xDD, 0xFF, + 0xDD, 0xDD, 0xDD, 0xFF, 0xDD, 0xDD, 0xDD, 0xFF, 0xDD, 0xDD, 0xDD, 0xFF, 0xDD, 0xDD, 0xDD, 0xFF, + 0x55, 0x55, 0x55, 0xFF, 0x55, 0x55, 0x55, 0xFF, 0x55, 0x55, 0x55, 0xFF, 0x55, 0x55, 0x55, 0xFF, + 0x55, 0x55, 0x55, 0xFF, 0x55, 0x55, 0x55, 0xFF, 0x55, 0x55, 0x55, 0xFF, 0x55, 0x55, 0x55, 0xFF, + 0xDD, 0xDD, 0xDD, 0xFF, 0xDD, 0xDD, 0xDD, 0xFF, 0xDD, 0xDD, 0xDD, 0xFF, 0xDD, 0xDD, 0xDD, 0xFF, + 0xDD, 0xDD, 0xDD, 0xFF, 0xDD, 0xDD, 0xDD, 0xFF, 0xDD, 0xDD, 0xDD, 0xFF, 0xDD, 0xDD, 0xDD, 0xFF, + 0x55, 0x55, 0x55, 0xFF, 0x55, 0x55, 0x55, 0xFF, 0x55, 0x55, 0x55, 0xFF, 0x55, 0x55, 0x55, 0xFF, + 0x55, 0x55, 0x55, 0xFF, 0x55, 0x55, 0x55, 0xFF, 0x55, 0x55, 0x55, 0xFF, 0x55, 0x55, 0x55, 0xFF, + 0xDD, 0xDD, 0xDD, 0xFF, 0xDD, 0xDD, 0xDD, 0xFF, 0xDD, 0xDD, 0xDD, 0xFF, 0xDD, 0xDD, 0xDD, 0xFF, + 0xDD, 0xDD, 0xDD, 0xFF, 0xDD, 0xDD, 0xDD, 0xFF, 0xDD, 0xDD, 0xDD, 0xFF, 0xDD, 0xDD, 0xDD, 0xFF, + 0x55, 0x55, 0x55, 0xFF, 0x55, 0x55, 0x55, 0xFF, 0x55, 0x55, 0x55, 0xFF, 0x55, 0x55, 0x55, 0xFF, + 0x55, 0x55, 0x55, 0xFF, 0x55, 0x55, 0x55, 0xFF, 0x55, 0x55, 0x55, 0xFF, 0x55, 0x55, 0x55, 0xFF}; + +} // namespace + +/* static */ +BuiltinResMgr *BuiltinResMgr::getInstance() { + if (instance == nullptr) { + instance = new BuiltinResMgr(); //cjh how to release it? + //cjh FIXME: hacking code +#if !defined(CC_RUN_IN_CPP_MODE) || !CC_RUN_IN_CPP_MODE + instance->initBuiltinRes(gfx::Device::getInstance()); + instance->tryCompileAllPasses(); +#endif + // + } + return instance; +} + +bool BuiltinResMgr::initBuiltinRes(gfx::Device *device) { + // black texture + initTexture2DWithUuid("black-texture", BLACK_IMAGE_RGBA_DATA_2X2, sizeof(BLACK_IMAGE_RGBA_DATA_2X2), 2, 2, 4); + + // empty texture + initTexture2DWithUuid("empty-texture", EMPTY_IMAGE_RGBA_DATA_2X2, sizeof(EMPTY_IMAGE_RGBA_DATA_2X2), 2, 2, 4); + + // grey texture + initTexture2DWithUuid("grey-texture", GREY_IMAGE_RGBA_DATA_2X2, sizeof(GREY_IMAGE_RGBA_DATA_2X2), 2, 2, 4); + + // white texture + initTexture2DWithUuid("white-texture", WHITE_IMAGE_RGBA_DATA_2X2, sizeof(WHITE_IMAGE_RGBA_DATA_2X2), 2, 2, 4); + + // normal texture + initTexture2DWithUuid("normal-texture", NORMAL_IMAGE_RGBA_DATA_2X2, sizeof(NORMAL_IMAGE_RGBA_DATA_2X2), 2, 2, 4); + + // default texture + initTexture2DWithUuid("default-texture", DEFAULT_IMAGE_RGBA_DATA_16X16, sizeof(DEFAULT_IMAGE_RGBA_DATA_16X16), 16, 16, 4); + + // white cube texture + initTextureCubeWithUuid("white-cube-texture", WHITE_IMAGE_RGBA_DATA_2X2, sizeof(WHITE_IMAGE_RGBA_DATA_2X2), 2, 2, 4); + + // default cube texture + initTextureCubeWithUuid("default-cube-texture", DEFAULT_IMAGE_RGBA_DATA_16X16, sizeof(DEFAULT_IMAGE_RGBA_DATA_16X16), 16, 16, 4); + + //cjh TODO: if (SpriteFrame) { + // const spriteFrame = new SpriteFrame() as SpriteFrame; + // const image = imgAsset; + // const texture = new Texture2D(); + // texture.image = image; + // spriteFrame.texture = texture; + // spriteFrame._uuid = 'default-spriteframe"; + // resources[spriteFrame->getUuid()] = spriteFrame; + // } + // + const char *shaderVersionKey = getDeviceShaderVersion(device); + if (nullptr == shaderVersionKey || 0 == strlen(shaderVersionKey)) { + CC_LOG_ERROR("Failed to initialize builtin shaders: unknown device."); + return false; + } + // + const ShaderSource *shaderSources = nullptr; + const auto iter = ShaderSourceAssembly::get().find(shaderVersionKey); + if (iter != ShaderSourceAssembly::get().cend()) { + shaderSources = iter->second; + } + + if (nullptr == shaderSources) { + CC_LOG_ERROR("Current device is requiring builtin shaders of version %s, but shaders of that version are not assembled in this build.", shaderVersionKey); + return false; + } + // + // return Promise.resolve().then(() => { + + rapidjson::Document doc; + doc.Parse(BUILTIN_EFFECTS.value().c_str()); + + index_t effectIndex = 0; + rapidjson::Type type = doc.GetType(); + auto assetDeserializer = AssetDeserializerFactory::createAssetDeserializer(DeserializeAssetType::EFFECT); + for (const auto &e : doc.GetArray()) { + auto *effect = new EffectAsset(); + assetDeserializer->deserialize(e, effect); + + index_t shaderIndex = 0; + for (auto &shaderInfo : effect->_shaders) { + const auto &shaderSource = (*shaderSources)[effectIndex][shaderIndex]; + if (!shaderSource.empty()) { + if (0 == strcmp(shaderVersionKey, "glsl1")) { + shaderInfo.glsl1.vert = shaderSource.at("vert").value(); + shaderInfo.glsl1.frag = shaderSource.at("frag").value(); + } else if (0 == strcmp(shaderVersionKey, "glsl3")) { + shaderInfo.glsl3.vert = shaderSource.at("vert").value(); + shaderInfo.glsl3.frag = shaderSource.at("frag").value(); + } else if (0 == strcmp(shaderVersionKey, "glsl4")) { + shaderInfo.glsl4.vert = shaderSource.at("vert").value(); + shaderInfo.glsl4.frag = shaderSource.at("frag").value(); + } + } + ++shaderIndex; + } + + effect->hideInEditor = true; + effect->onLoaded(); + + delete effect; + + ++effectIndex; + } + + initMaterials(); + + return true; +} + +void BuiltinResMgr::initMaterials() { + auto &resources = _resources; + + // standard material + auto *standardMtl = new Material(); + standardMtl->setUuid("standard-material"); + IMaterialInfo standardInfo; + standardInfo.effectName = std::string{"standard"}; + standardMtl->initialize(standardInfo); + resources[standardMtl->getUuid()] = standardMtl; + _materialsToBeCompiled.emplace_back(standardMtl); + + // material indicating missing effect (yellow) + auto * missingEfxMtl = new Material(); + IMaterialInfo missingEfxInfo; + missingEfxInfo.effectName = std::string{"unlit"}; + missingEfxInfo.defines = IMaterialInfo::DefinesType{ + MacroRecord{ + {"USE_COLOR", true}}}; + missingEfxMtl->setUuid("missing-effect-material"); + missingEfxMtl->initialize(missingEfxInfo); + missingEfxMtl->setProperty("mainColor", Color{255, 255, 0, 255}); // #ffff00; + resources[missingEfxMtl->getUuid()] = missingEfxMtl; + _materialsToBeCompiled.emplace_back(missingEfxMtl); + + // material indicating missing material (purple) + auto * missingMtl = new Material(); + IMaterialInfo missingInfo; + missingInfo.effectName = std::string{"unlit"}, + missingInfo.defines = IMaterialInfo::DefinesType{MacroRecord{ + {"USE_COLOR", true}}}; + missingMtl->setUuid("missing-material"); + missingMtl->initialize(missingInfo); + missingMtl->setProperty("mainColor", Color{255, 0, 255, 255}); // #ff00ff + resources[missingMtl->getUuid()] = missingMtl; + _materialsToBeCompiled.emplace_back(missingMtl); + + auto * clearStencilMtl = new Material(); + IMaterialInfo clearStencilInfo; + clearStencilInfo.effectName = std::string{"clear-stencil"}, + clearStencilInfo.defines = IMaterialInfo::DefinesType{MacroRecord{ + {"USE_TEXTURE", false}}}; + clearStencilMtl->setUuid("default-clear-stencil"); + clearStencilMtl->initialize(clearStencilInfo); + resources[clearStencilMtl->getUuid()] = clearStencilMtl; + _materialsToBeCompiled.emplace_back(clearStencilMtl); + + // sprite material + auto *spriteMtl = new Material(); + spriteMtl->setUuid("ui-base-material"); + IMaterialInfo spriteInfo; + spriteInfo.effectName = std::string{"sprite"}, + spriteInfo.defines = IMaterialInfo::DefinesType{MacroRecord{{"USE_TEXTURE", false}}}; + spriteMtl->initialize(spriteInfo); + resources[spriteMtl->getUuid()] = spriteMtl; + _materialsToBeCompiled.emplace_back(spriteMtl); + + // sprite material + auto *spriteColorMtl = new Material(); + spriteColorMtl->setUuid("ui-sprite-material"); + IMaterialInfo spriteColorInfo; + spriteColorInfo.effectName = std::string{"sprite"}, + spriteColorInfo.defines = IMaterialInfo::DefinesType{MacroRecord{{"USE_TEXTURE", true}, {"CC_USE_EMBEDDED_ALPHA", false}, {"IS_GRAY", false}}}; + spriteColorMtl->initialize(spriteColorInfo); + resources[spriteColorMtl->getUuid()] = spriteColorMtl; + _materialsToBeCompiled.emplace_back(spriteColorMtl); + + // sprite alpha test material + auto * alphaTestMaskMtl = new Material(); + IMaterialInfo alphaTestMaskInfo; + alphaTestMaskInfo.effectName = std::string{"sprite"}, + alphaTestMaskInfo.defines = IMaterialInfo::DefinesType{MacroRecord{ + {"USE_TEXTURE", true}, {"USE_ALPHA_TEST", true}, {"CC_USE_EMBEDDED_ALPHA", false}, {"IS_GRAY", false}}}; + alphaTestMaskMtl->setUuid("ui-alpha-test-material"); + alphaTestMaskMtl->initialize(alphaTestMaskInfo); + resources[alphaTestMaskMtl->getUuid()] = alphaTestMaskMtl; + _materialsToBeCompiled.emplace_back(alphaTestMaskMtl); + + // sprite gray material + auto *spriteGrayMtl = new Material(); + spriteGrayMtl->setUuid("ui-sprite-gray-material"); + IMaterialInfo spriteGrayInfo; + spriteGrayInfo.effectName = std::string{"sprite"}, + spriteGrayInfo.defines = IMaterialInfo::DefinesType{MacroRecord{{"USE_TEXTURE", true}, {"CC_USE_EMBEDDED_ALPHA", false}, {"IS_GRAY", true}}}; + spriteGrayMtl->initialize(spriteGrayInfo); + resources[spriteGrayMtl->getUuid()] = spriteGrayMtl; + _materialsToBeCompiled.emplace_back(spriteGrayMtl); + + // sprite alpha material + auto *spriteAlphaMtl = new Material(); + spriteAlphaMtl->setUuid("ui-sprite-alpha-sep-material"); + IMaterialInfo spriteAlphaInfo; + spriteAlphaInfo.effectName = std::string{"sprite"}, + spriteAlphaInfo.defines = IMaterialInfo::DefinesType{MacroRecord{{"USE_TEXTURE", true}, {"CC_USE_EMBEDDED_ALPHA", true}, {"IS_GRAY", false}}}; + spriteAlphaMtl->initialize(spriteAlphaInfo); + resources[spriteAlphaMtl->getUuid()] = spriteAlphaMtl; + _materialsToBeCompiled.emplace_back(spriteAlphaMtl); + + // sprite alpha & gray material + auto * spriteAlphaGrayMtl = new Material(); + IMaterialInfo spriteAlphaGrayInfo; + spriteAlphaGrayInfo.effectName = std::string{"sprite"}, + spriteAlphaGrayInfo.defines = IMaterialInfo::DefinesType{MacroRecord{ + {"USE_TEXTURE", true}, {"CC_USE_EMBEDDED_ALPHA", true}, {"IS_GRAY", true}}}; + spriteAlphaGrayMtl->setUuid("ui-sprite-gray-alpha-sep-material"); + spriteAlphaGrayMtl->initialize(spriteAlphaGrayInfo); + resources[spriteAlphaGrayMtl->getUuid()] = spriteAlphaGrayMtl; + _materialsToBeCompiled.emplace_back(spriteAlphaGrayMtl); + + // ui graphics material + auto *defaultGraphicsMtl = new Material(); + defaultGraphicsMtl->setUuid("ui-graphics-material"); + IMaterialInfo defaultGraphicsInfo; + defaultGraphicsInfo.effectName = std::string{"graphics"}; + defaultGraphicsMtl->initialize(defaultGraphicsInfo); + resources[defaultGraphicsMtl->getUuid()] = defaultGraphicsMtl; + _materialsToBeCompiled.emplace_back(defaultGraphicsMtl); + +#if UI_GPU_DRIVEN + // sprite material + auto *spriteGPUMtl = new Material(); + spriteGPUMtl->setUuid("ui-base-gpu-material"); + IMaterialInfo spriteGPUMtlInfo{ + .defines = IMaterialInfo::DefinesType{MacroRecord{{"USE_TEXTURE", false}}}, + .effectName = std::string{"sprite-gpu"}}; + spriteGPUMtl->initialize(spriteGPUMtlInfo); + resources[spriteGPUMtl->getUuid()] = spriteGPUMtl; + _materialsToBeCompiled.emplace_back(spriteGPUMtl); + + // sprite material + auto *spriteColorGPUMtl = new Material(); + spriteColorGPUMtl->setUuid("ui-sprite-gpu-material"); + IMaterialInfo spriteColorGPUMtlInfo{ + .defines = IMaterialInfo::DefinesType{MacroRecord{{"USE_TEXTURE", true}, {"CC_USE_EMBEDDED_ALPHA", false}, {"IS_GRAY", false}}}, + .effectName = std::string{"sprite-gpu"}}; + spriteColorGPUMtl->initialize(spriteColorGPUMtlInfo); + resources[spriteColorGPUMtl->getUuid()] = spriteColorGPUMtl; + _materialsToBeCompiled.emplace_back(spriteColorGPUMtl); + + // sprite gray material + auto *spriteGrayGPUMtl = new Material(); + spriteGrayGPUMtl->setUuid("ui-sprite-gray-gpu-material"); + IMaterialInfo spriteGrayGPUMtlInfo{ + .defines = IMaterialInfo::DefinesType{MacroRecord{{"USE_TEXTURE", true}, {"CC_USE_EMBEDDED_ALPHA", false}, {"IS_GRAY", true}}}, + .effectName = std::string{"sprite-gpu"}}; + spriteGrayGPUMtl->initialize(spriteGrayGPUMtlInfo); + resources[spriteGrayGPUMtl->getUuid()] = spriteGrayGPUMtl; + _materialsToBeCompiled.emplace_back(spriteGrayGPUMtl); + + // sprite alpha material + auto *spriteAlphaGPUMtl = new Material(); + spriteAlphaGPUMtl->setUuid("ui-sprite-alpha-sep-gpu-material"); + + IMaterialInfo spriteAlphaGPUMtlInfo{ + .defines = IMaterialInfo::DefinesType{MacroRecord{{"USE_TEXTURE", true}, {"CC_USE_EMBEDDED_ALPHA", true}, {"IS_GRAY", false}}}, + .effectName = std::string{"sprite-gpu"}}; + spriteAlphaGPUMtl->initialize(spriteAlphaGPUMtlInfo); + resources[spriteAlphaGPUMtl->getUuid()] = spriteAlphaGPUMtl; + _materialsToBeCompiled.emplace_back(spriteAlphaGPUMtl); + + // sprite alpha & gray material + auto *spriteAlphaGrayGPUMtl = new Material(); + spriteAlphaGrayGPUMtl->setUuid("ui-sprite-gray-alpha-sep-gpu-material"); + spriteAlphaGrayGPUMtl->initialize({.defines = IMaterialInfo::DefinesType{MacroRecord{{"USE_TEXTURE", true}, {"CC_USE_EMBEDDED_ALPHA", true}, {"IS_GRAY", true}}}, + .effectName = std::string{"sprite-gpu"}}); + resources[spriteAlphaGrayGPUMtl->getUuid()] = spriteAlphaGrayGPUMtl; + _materialsToBeCompiled.emplace_back(spriteAlphaGrayGPUMtl); +#endif + + // default particle material + auto *defaultParticleMtl = new Material(); + defaultParticleMtl->setUuid("default-particle-material"); + IMaterialInfo defaultParticleInfo; + defaultParticleInfo.effectName = std::string{"particle"}; + defaultParticleMtl->initialize(defaultParticleInfo); + resources[defaultParticleMtl->getUuid()] = defaultParticleMtl; + _materialsToBeCompiled.emplace_back(defaultParticleMtl); + + // default particle gpu material + auto *defaultParticleGPUMtl = new Material(); + defaultParticleGPUMtl->setUuid("default-particle-gpu-material"); + IMaterialInfo defaultParticleGPUInfo; + defaultParticleGPUInfo.effectName = std::string{"particle-gpu"}; + defaultParticleGPUMtl->initialize(defaultParticleGPUInfo); + resources[defaultParticleGPUMtl->getUuid()] = defaultParticleGPUMtl; + _materialsToBeCompiled.emplace_back(defaultParticleGPUMtl); + + // default particle material + auto *defaultTrailMtl = new Material(); + defaultTrailMtl->setUuid("default-trail-material"); + IMaterialInfo defaultTrailInfo; + defaultTrailInfo.effectName = std::string{"particle-trail"}; + defaultTrailMtl->initialize(defaultTrailInfo); + resources[defaultTrailMtl->getUuid()] = defaultTrailMtl; + _materialsToBeCompiled.emplace_back(defaultTrailMtl); + + // default particle material + auto *defaultBillboardMtl = new Material(); + defaultBillboardMtl->setUuid("default-billboard-material"); + IMaterialInfo defaultBillboardInfo; + defaultBillboardInfo.effectName = std::string{"billboard"}; + defaultBillboardMtl->initialize(defaultBillboardInfo); + resources[defaultBillboardMtl->getUuid()] = defaultBillboardMtl; + _materialsToBeCompiled.emplace_back(defaultBillboardMtl); + + // ui spine two color material + auto *spineTwoColorMtl = new Material(); + spineTwoColorMtl->setUuid("default-spine-material"); + IMaterialInfo spineTwoColorInfo; + spineTwoColorInfo.effectName = std::string{"spine"}, + spineTwoColorInfo.defines = IMaterialInfo::DefinesType{MacroRecord{ + {"USE_TEXTURE", true}, + {"CC_USE_EMBEDDED_ALPHA", false}, + {"IS_GRAY", false}, + }}; + spineTwoColorMtl->initialize(spineTwoColorInfo); + resources[spineTwoColorMtl->getUuid()] = spineTwoColorMtl; + _materialsToBeCompiled.emplace_back(spineTwoColorMtl); + // + //cjh TODO: game.on(Game.EVENT_GAME_INITED, () => { + // tryCompileAllPasses(); + // }); +} + +void BuiltinResMgr::tryCompileAllPasses() { + for (auto &mat : _materialsToBeCompiled) { + auto &passes = *mat->getPasses(); + for (auto &pass : passes) { + pass->tryCompile(); + } + } +} + +void BuiltinResMgr::initTexture2DWithUuid(const std::string &uuid, const uint8_t *data, size_t dataBytes, uint32_t width, uint32_t height, uint32_t bytesPerPixel) { + auto *image = new (std::nothrow) Image(); + if (image != nullptr) { + image->initWithRawData(data, static_cast(dataBytes), static_cast(width), static_cast(height), static_cast(bytesPerPixel)); + auto *texture = new (std::nothrow) Texture2D(); + texture->setUuid(uuid); + + auto *imgAsset = new (std::nothrow) ImageAsset(); + imgAsset->setNativeAsset(image); + texture->setImage(imgAsset); + + texture->initialize(); + _resources.emplace(texture->getUuid(), texture); + + delete image; + } +} + +void BuiltinResMgr::initTextureCubeWithUuid(const std::string &uuid, const uint8_t *data, size_t dataBytes, uint32_t width, uint32_t height, uint32_t bytesPerPixel) { + auto *image = new (std::nothrow) Image(); + if (image != nullptr) { + image->initWithRawData(data, static_cast(dataBytes), static_cast(width), static_cast(height), static_cast(bytesPerPixel)); + auto *texture = new (std::nothrow) TextureCube(); + texture->setUuid(uuid); + texture->setMipFilter(TextureCube::Filter::NEAREST); + + ITextureCubeMipmap mipmap; + mipmap.front = new ImageAsset(); + mipmap.front->setNativeAsset(image); + mipmap.back = new ImageAsset(); + mipmap.back->setNativeAsset(image); + mipmap.left = new ImageAsset(); + mipmap.left->setNativeAsset(image); + mipmap.right = new ImageAsset(); + mipmap.right->setNativeAsset(image); + mipmap.top = new ImageAsset(); + mipmap.top->setNativeAsset(image); + mipmap.bottom = new ImageAsset(); + mipmap.bottom->setNativeAsset(image); + + texture->setImage(mipmap); + + texture->initialize(); + _resources.emplace(texture->getUuid(), texture); + + delete image; + } +} + +} // namespace cc diff --git a/native/cocos/core/builtin/BuiltinResMgr.h b/native/cocos/core/builtin/BuiltinResMgr.h new file mode 100644 index 0000000000..69f34a372f --- /dev/null +++ b/native/cocos/core/builtin/BuiltinResMgr.h @@ -0,0 +1,73 @@ +/**************************************************************************** + 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/Macros.h" +#include "base/Ptr.h" +#include "base/TypeDef.h" +#include "core/assets/Asset.h" +namespace cc { + +namespace gfx { +class Device; +} + +class Material; + +class BuiltinResMgr final { +public: + static BuiltinResMgr *getInstance(); + + explicit BuiltinResMgr() = default; + ~BuiltinResMgr() = default; + + bool initBuiltinRes(gfx::Device *device); + + template ::value>> + T *get(const std::string &uuid) { + auto iter = _resources.find(uuid); + if (iter != _resources.end()) { + return static_cast(iter->second.get()); + } + + return nullptr; + } + + void tryCompileAllPasses(); + +private: + void initMaterials(); + void initTexture2DWithUuid(const std::string &uuid, const uint8_t *data, size_t dataBytes, uint32_t width, uint32_t height, uint32_t bytesPerPixel); + void initTextureCubeWithUuid(const std::string &uuid, const uint8_t *data, size_t dataBytes, uint32_t width, uint32_t height, uint32_t bytesPerPixel); + + gfx::Device * _device{nullptr}; + Record> _resources; + std::vector> _materialsToBeCompiled; + + CC_DISALLOW_COPY_MOVE_ASSIGN(BuiltinResMgr); +}; + +} // namespace cc diff --git a/native/cocos/core/builtin/Effects.cpp b/native/cocos/core/builtin/Effects.cpp new file mode 100644 index 0000000000..a47339bd6d --- /dev/null +++ b/native/cocos/core/builtin/Effects.cpp @@ -0,0 +1,122 @@ +/**************************************************************************** + 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. +****************************************************************************/ + +// clang-format off +#include "core/builtin/Effects.h" +#include "base/StringUtil.h" +namespace cc { + +// absolute essential effects +const GzipedString BUILTIN_EFFECTS { +"H4sIAAAAAAAACu1dbXPiuLL+Pr9iNp8nW5i3hPlGwCTUIZACMjl7T225HDCJzzg21zaZzd7sf7+ywcYvsi3ZkjHQqdodsI3V3ZJarae71f/58vXr/6H/vn" +"690OU35eL714tnVdOeDdlcXnzb3rCVxauu/u9GsdDt/7jXvB+FfigvvZ+4l9eyZYV+Ev6Z+4wpW7Ziqn8r5syWbect4QfQI4uNpt0bS+deLXTvn2/hdz1r" +"ir5MfI0tmy+KHSUHR1Twdehx29wo3xIfmJkL9Ew9+YG+ZaMHhNQ3dLX1q5z5Gu8pIfbQP5Erf6bKaW0aL6b8Furqz3fFtL+/W9KbrOqftqrbyvJyZX0Pd6" +"n786Wytl9ntqIvVC1R2u5Dc8XlHSfA7QNPpur+fCVrlpJF8xpRqLrjKdaaQ/Rc+cvemDhi0APvsrZxh+iLqXxcxKV8YX+snfv168itf2KEu22pmqq/SJPV" +"ylLs9Bbjg+0rfjBgL9awF2PX/kzmSGhncuT0ds/QDJOek9rvLSyFtJeLcfQl6dv+szcjtld2b7+wXuWlYmZoNco5cvEqW6/OUOrUOteNeq0T6MOL542qoR" +"9GB/GFheaRatnqIj68L3o9SRwMxN5cepyJfemHOJ2L/5Yex8PBZHqPvvbmk+kM/azV+Jb6w8G0e3svjueYnzaDQyo0QC5eNOMZzc44Wc+asfiJU6eYIeSJ" +"ste7dV+Hm4FLZaXq2+Xiz6whm9pED30yZdomQt8jo+/Ckt/WmmLuVMz2BdHFZ7Na7YZS9Jb6Jr/EWw2LGQmToZRHztuqLwH/c0AWIRIDl2XbNtXnjZ1lUP" +"i2iLQ2LNVWDT2+fuEacG+tDPNNdhR6I7ISu/3jvixshIQ6MZESW/mrZxgmZiXNpqQuJFMiUFOycNV8DjKazWQy6niNG1R7uFGcQGTP0JE21JGlRk7ms6ov" +"0YLsdE503Npo5A00+cWKG2EXb8rbc1j942kL0Rdf/9OWKsy9hbHRbYwZR6PlVsh+UxAVivSuaCNFn6H5rhyCEOtQDetoRzA1bBkzw/O3H1aBlLNrt7bnGr" +"bRkcl+2C4WkoW2WZJZKZkNTPml2ISPKuqw5NosRLe3j/nLDKs+MYtvtmiDe6KIFPzNTuS6Ty95R6SLe99Njew1Ams+BE2HwFUbb4d4kopf3zw7aMRQX2/s" +"kB2y2w982Q3XCBKy0BTZvLS2e11SNIQE9uAIVcTu04EDLAGZANAQkuSntXY2/pfv1ndnS+V9RVsptK69FMYbXDSBGnDAD9DwMKHZNubj2Ns9Nlq1q1rjut" +"ZphKYIv91j1HAi3zwW2jtWcacFe5/wnaS9D16N48SYIcJK6n6kudavzpQ6DrWfhVCnANBbhLqZ+gYfeyZCqJvVXIS8Lv301PBprTgE7PngZFuo1YWG0KyH" +"ZiG/5aUZtTVLWl8ifQLYJGCTZ7M+Hw4RpAcml0jB5KFCSIFHaXDJIzdWjMVC21iI7UtkoJgfLG0WurW4HrpXhofeRWbuZetnzBLYi23/R+wZj0j0M/Ld38" +"lFr7MyKXI5zVlbFOyE4BkeQutK6FxdN+pl7WubUQUBhgd5EydleDwZpra8MTZ61A9XQTGcgPVx2gvuWjaRXtKUy5f1BsLkTj1MLtjbn/6Xd8v5/v1lDWFz" +"EDYXe9G5h80VnDO+wXgtNOrNdkNohlYEfgZjG8LowGI8Kagq2yREQ3wqjvviVLqf9MWEcIELfeMET0TvmrL+gtNzMR0cdgrQRor0JqPJVJqgaSvNh/eiQ+" +"jjSJTEcfdmlEjxs2FoiqxfULY1ncy78+FkXFJzs+H/iCU1hRRWr6y2foijSW84/6Ok5pA2nz9ORak7Ht5ve49na2jGoNVAeppMR31p9tDtUTWwX1+Z7OMk" +"tO6Ztq2+xSJ9igK59HiyG2S2eT88ouwFunEgpk5NDBeUvUFNxlI1JU1dMR8mTfreQRs6RckVEZ0G+beoCSGIzY4a/pHVMnXBJ8JN2rmpbhyS7CtqsnXntV" +"GLqlSar6lpdqeuwJvmtNnVyVw6IL4+cA/i608zvn7m7p2KDV/+cfYbabvHG+oroxpym6uLnzxj7NlI7ZfjnUED7hBjfSM5tnNf0Wws3lF+l7mwotdnNEtP" +"6iY5dSUKhOqX0Nvuoiq9Oe6KZIFjUE9O8vYUXQ6RZ2IFhFKPrv88pO5viSoj+BnaLeYQeipiQijwVhlLgbMZroywB4a5yCPtdNCIUNzR1CAe4l45DDKVN9" +"Uism3eWsuLavT3DwVtC1T7I0eXZ2J3hL1+VUKvv+/YPFzH+xRUp++7uvqWd0nLQlIJ+z4a8c2j72XEpqRWxtQuns7aSRXaGaezbi1G410xXWPdQcBqDPNa" +"GVrSqeM8sBWlxdZ96600IRSzbUnlQAvtu0ZVaTLIb2qS8k/rTdiaGaUJoID1RyoBWkeGv96WJoRi9hCpHGjdKLtYR3cV3KoGzmIoZBmQSoHWh1Otgw5CYV" +"bHc9KBH6BlmzL5UQcQ0Xr0Ea1uf3+Gv8I5kGcZ0Ip3eh07VxCmSxamm0sR+FG6zcbVVafWaJcVpduK+qQgSpeiiXQ7DaJ0IUrXkwylLY5I7E+7T9LTEO0S" +"0By8P+m4y8Nn7xc5WZRtuKVHSVqkVC6h0AdbeqTUWZNCH3DJJe6zmTmkIR4scA/iwU4zHqy4syU9GuyMnS3VgtQIznGpMKIGWNq5YGmhLFdNeZEXH981SA" +"4/SywNUCci1CnflPFPMbxqt5uNq05pueGAOgHqBKhT8KmqoE4FQCGCBlgmhGMN2HPFoNIoAQwKR0oVMShyMrjnUbLN/axEmi19dvDh02xDqcFYjQcQZeAe" +"QJQAUQZvAUSZRDlAlAwhSmuN+GZ5VnSVwcOU+hbVr1zh9lQlyyZRYYqyI+X5KxrZr4a2zAWNxa6moVqNyC3OqBZdL/mlnoROvdmqN2utkLqoZC2OxD0ZgF" +"hfTxTEwmlNB20ZTXrd0UXsbmGBkdPvlLR0JxfeDogyQkfZIaC2vVjZwlfzp4nkJrSJfcZvdijujh7uutJcnM0BBjuTIs/kZKThX1HrIDhMU+cm/el42NFG" +"A0HsB7nU7867FFxFpki60iEELZjs+yLGWJoZVe7mr/rbJteiozj5H/ZO278D7Z287tqb5u4h5GHz3L10QtUAC7Dt+9ebrZrQue6UltXRiB5/AMV6yJugNb" +"QrvTN5HJbiYCcniXKzgdOXjiWwy6Auum86xO5k1r1/GDlZHZN7aUpl6xNuJB6G/xZHyFYa3o6dSc4nc0S8vxH7faRLXJuMAxdeD7N983Am3U67f8AOqxI7" +"rGfZXrxKKvPjq8+oYuVWmYIBfTQGNHgfKu99oOomP3X76qrWaFy3mqVV5AT3Axj55+d+SGLkiHcEvPwVsNMg4iKf4wW2MaEnznkbw99RhO088LuA3yXXlt" +"GW9aXsTxzijFpjLaOHaJNqgxugXcOf3gdkXe8/r2KRnenbENuNFD6RPEcnDDNnniM5J/iLRJwgUSuymbiNT41vfUUdvCvkkmC/ydqzssSdPZ0g/ZhAMVZe" +"TMTbRrgfxkYmT09euJPMSeXlstLVl72NbaxWFNLDbL8JpFfypp+vYDCv/xpHGkgEYywW2sbartm0g6oEiayfzQcZ6d+oct3+4cdHHjGYxublFZkQOFWdOT" +"Sime3lCwI/lfMI4k2xZU1TF3nkgFFrJcsBi8DmksNsrSw2mmwOdVvR0Z7ho6o6I10g7BSF8qZalvqeY/HBWyDk85ntCk/M6EkstSFm3HHCeaHdJh3ObFPR" +"7ddqrimEMmE3dRieoVLArLiX1+R9HzuthbzvnXbSucQmpob5zGwLqb3shhgcSbNbDqeefVBGo75Nlt3Yr9e9+zRna950KIOz3U4J20zaHqzcDSQhGxE7vU" +"pMYU0Pkjm1MyX484KsZvxlzNvz8oNR9FXqpPwjL3Gqpq0T4WkcbelL0rc0DBntqS33lSvD/OWAYJgzzXYo2MdQXyp/YaBVBztdLpXlvbwwDSxS1utJg8n0" +"qTvtS91+f2fihemNArmHiwFJOZyO5vQ67KLM8/Q6WnCTPLJjsNGxwTHFD7KjHaVO/ITx63LhxsfQjlO6qBqBXu5B4vZxG6GrCVE2ADR7tw8ONAOQ7F+kkh" +"cAyZF3HB2QfC6bXNjCBO5VbgtzAPvY/1wkaJPc+vKzsq7bzY7QabfLCtisx6JOyCM224kHxZ1NyCZVEzPX7KtW2pNLEl6/ZgU4ugfL9cThD1Ga3XX7kyeC" +"MEcKebkhmIY9Ul9e0eB/qSqNiv6umob+psTKcBPS58QyDW9Iwl3pCFuqq9XGUnLLzaMLu2fd3e8PBwP07333ofwQ15C+YRu7fG+Y69f8UrufTB/u2PYnUh" +"4/VV1H8yB/QPKOutm/huPxcHyb2rE33X85wa1eKVhezPiV7E+DHV5c/FYOG27I/o2T/qZgQxczWPnN1Rjj2bw77iWysmVj3rtznuBBPy/Cf+NJ+WCLtLpr" +"Xb5BFMRSk2bC9jxrqTd6nM3FKRpJo+Ht3VzqPY5GZDxxNUUedkHcfdVaa/JCcVZUXPgDlRJOEoV7V5p3p7fiXLrrzqSHyWzIfk4htsauW/QwTI2RvU6USE" +"PH0tw5+V23D8MTmqS3TloHa6b+a6i6fQKLK2JFK2Qyu4k/jmJwrDoCVZi4YgVVUunWof+5SG2EpOHJIIkoNK57k8fkRCW66gsxh0wYDctRfWFL6QPaRk3u" +"Hx7nzI+ZS9XG/Jva6Uj+DXmKi3lLKXqH0dujCottI6nWF4uXJ6gqFq9OUJSM5D6YJNJchZos3V7vcdqdp9KZXwAR3IZ93+0wUfdUQg6v3yoWif3gcJTJDG" +"njcV96/MFe7sk7CSapp09ItSeXGqpiUnEiFsZqMtZD33NOxgAUV0UqHRKn4mAk9txaS31xPBnOOBQQ3+1x+8MpH8Wxk/Zdn4fK6I5uxP6Eg8rYvThZXVi2" +"GcevLoy1syHHZuC+S5v3mOnvXhUuCg2Undo8BlIfbqZHQad7KgKilf24cjdI4rw7Gg3Rgj15vL0bi7MZp4YmPQe5crQHn/eL98PZzLE42L/ef/WxDBdux0" +"8Ecv57d93xWExcVKkFEnfeXpjFJIGU/cPwQRwNx8hw+eOBV4FEoSiRyGTrib7h5qx7lLsd//OpnMORWSWt5KqFrM8DyVG0cAvasj4RhL5koRMBq/w1TBNJ" +"dBon+1VzncRIX3TPBYfTinwlUOzDMqlEFyq9+Etx0F5utBENglY+gTreXzf4Lz/tMY1PhFh9jYFOOWWgWkO3ANxCwWcSJJZNJBISavTJMLVljfJknHL5oq" +"+86fFFUzC0fL46ufmiqYtRPl8C/WoacCg9/sDl1lJwiJ2JPoxaBv/0q/jyQyc5FjjKWVZcQUowRK51TchZx4WyM0O4afHFQ6A3IQrVgk49Zi20/mKt4qrU" +"tr2K3M1ZHjSQRRQdnvs9A7eqrompMSW1nJlLwZ2OtIM+uDfun/5xwLZTz2uobonapMSUIgVqcco2AAmnqlrSYra0i9/+9Ae+fAa8ZUz4pF0KdydP8GXSA2" +"GZcEi7bGIPveDLbwI0zIR92p1y6PgNvmyHgWom3NLusIPHf/BlNoSaM+E1BM/gbbB9OFi2KJ6lxcINrLVu3J9F5YEMJ8P86C4W23PiKNjPCLulDbnNKy9a" +"YAEJBM0EWzFdqQzRaxDrJyobWnAiLJtbU12eqGA6mZOM93HA3kOpiZO5jk8IVL9o1oS6IJRVfFu4jjoPqphMmS8NkcK0r3C+ZvrcgWRK5jSmChyS/iDp7+" +"jZgaQ/SPrzKOe6vECCHCTIEfB0lglyjM0M/zNkjwW/QfYYZI/Rvx2yx5JezSl7jHOCEPfELEiDOJsgbP8zBB5D4HGMEAg8hsBjCDzGyQACjyHwGAKPqTjE" +"zkQIPD5Q4DG/EN6QYYC1LyGEd3cPQnghhJdB2xDCe7gQXryCq2CBb1sxTVn1dujl1ffetfu5+9c5gt37SFvc+/EH//oa2Iuxa8XKrbhWVcCkKrv2J/PyMf" +"mr21aLkQL1iis2xLbgQHbxwWdNXvxMWTUIqg8uUe+rToZCLaOt4oUO/aaE8pqql9dUg3tTfjZJVl+xKCbqN5bVW0wby+ovpo1l9RiLxjSymUw9OL4kfUvb" +"QEJtwmB7R12bkMowq0JhQrAVwVYscBFsRfcPbEV+TYGtWLgxsBVPz1bc5YvlMBXpygOHT8glMH1o0tuCTPufCxQnJDW//GS6mnB1fS20GwFgkmsyXbvzLf" +"WHabl0iZ5GKEyIawIKEx5FLh0djVCY8PQKE5IkO0ElsqK6B+onMcyAgRomPEPlt/knfM5D51vbBsppFKGylHIaHLNfuNaZOeYyIKPuHyLaw1RRY+5OMGMv" +"SThjH1Jdqp7qgu09mkDS+Y5KHoGkkZu54kg9h1UalI+5xyKOMOpjYkVCoSn/kBDVSdZf0S5Jj+3L1WG+J+sAPbZ3PvHvK+zMyxXwuXc04dV2noDPss4nDX" +"iuDk88be5dwBd2eOJpM90C3rXDE0+b8Bbw1x2eeNr0x4AH8PDE02bRBTyKhyeeNlUu4KE8PPG0+XABj+fhiadOetOqs0YJVJkG2ayd/Em81Hlw53QUL3Wd" +"j7M5i5eg6sgBD+PNE6wQaHMXPnBd6zSuO/V2PaQ8OEYPRJMryaMHIHiAqolyggdOzy1bvgT8zwk+PQAmTw+YzABNqp41utE11YtDKC9n1G310/2/v9Btv8" +"UXOO+3KbkAb2j59A7O5B01GzoOgGNkeDnB+khwPbdCXTVj3JGoFdkhDp+nQ8GpW4ePf8YIVf+0MPdeZX2pKe7ZSQnhL3tO0g5lSBhAQitOYabsZCc3af6K" +"lNGroS3p5Vf7HdNqilwaXOWCefvX8N5pRyHZmMKLg3jg5mJ1P23JOz46RYgZjIgUy24aOxyVCHZgpZqBodD2/coeXip3qyFRlDfNSuZt1RoNoSN0akInAD" +"XxLZvSyb9ZayaaZWezWwt9P/atFFThgCocedjhxQVU4SCnnxfhUIUDqnDkYAmqcCQyA1U4oAoHT2FAFQ7KlqAKR8bLj68Kx9nnPzmv3+35e5PRhHXigPN6" +"9O7545R13suse/8wQhKZTu6lKafJzj5z5KQqhsQuxTd4F89QV+REfZpklEBdEagrQk8b1BWBuiJQV4SOL6grksIhdiZCXZED1RVZYPzOWZ0Z2qQUXzwYVy" +"AhSRzFceXtjVIZKjPDlEulkjB3lMPFK+5S2RTPlEAK7jmeZAEr1c32DEbd4feqrAp8EM20XImheOVRwThNpNAMbw3NjNMkisb0Dm9033y5NlEXaHYcLQtE" +"bbpPfm6ff7c+/Z8UOk56d2C0exx0bLnLOjGaUB1FeF0av/Rt95Azu/8NcAvcArfALXDLktvNmpZX7xfAKXAKnAKnwGleThfGG9oeUTC6+0E1+Nxv4cIbqd" +"1eiSiKn2xn48Xv14Xr1nVdaAtlndQuNAvE70O2deg7xO9D/D7E77PjIn/8Pu20JOcaosghipyMJ4gihyhyiCKHKHKIIs94uf8Z4j0h3jNGCMR7QrwnxHvi" +"ZJA73hOrcGnCmm4cNOvxZpIr9iY9WIlJ7A2a4jP1b3bn4ScbX1hR5gp5MTb2emNPFWujVeUI2ewxc5hoFu+hbLQ1yWnpF8a8uq7VG0Kj1QlxBXArwK0Ypg" +"BuJaeuSvgkwK0AtwLcCnBrLqYAbgW4NS+lALcWbQjgVoBbsygBuDVGCcCtALfS0wZwK8Ct5wK3uhAh+xTDM8Za8SHK/sHUretas95qNFohngBpBaQVwxQg" +"reTUVQmaBKQVkFZAWgFpzcUUIK2AtOalFJDWog0B0gpIaxYlgLTGKAGkFZBWetoAaQWkFZBWQFrzIa3YMxJ8oLXZuhI67avyKgAC0ApAKwCtALQWYAeAVg" +"BaizEFQCs5UwC0AtCal1IAWos2BEArAK1ZlADQGqMEgFYAWulpA6AVgNZzAVorfoIAwcSqGFR8nOU8EOOKaSrLS69Q1k6SbEt7JLWyf3J/xG/s2U/vg4Nm" +"+5+LHPk72OgLR8PFFGXwQOC4gvMeKPE84DzC8LH9RrPWEZqdlhAag/yw/UbnW+oPU6D9VmIpvrOB9umgUDR4jF+8vQfkFC0WkuWSFF9KolTFbm4HylTsic" +"MfyNq56/YnT8xRLGtt2KN9LcBK0qjo76pp6G/xnQshfa6dd8Me11yqq9XGUnLLzaMrDfvrDwcD9G+skiKW/NSBXCkf18Awf8nm0h16+YQnjrs3I1HqjR5n" +"c3GK1KhbcVLqPY5GMWPeFUfRWV8RGDUy2bhAVPFBmRNArUW7th6Wej7yAnOiilQ6JE7FwQit4mjbKfXF8WQ4EzngfH6NVfav9muYMh9fyMJ56k7RvrzPAf" +"veKYX+cMptfjwMH0SkYURp/sdDYqcWHH9CofG3FXJP9EXtiIIbnH3Xn/J58WCSSHFB8TaTxet/BhAcQPAYIcQgOHYY7S2lDJQqARzJZu5ZWixck8q6cX8W" +"5fFNeTPMj+5ioVhWOtoTmTG0BldesIgW+kYMaxvLVkyX6yF6DWLtSHmnBdDDvN+a6vJIGW9nzhxOUGC2jF+200+StWdlaWDw4BwFk5FU++KPIVqfe92xdC" +"OOxcFwLg2mk3tpOH54nEvd+bzbu7uPBa3klS/touEx7S1iR8o27Rrlsb1dMY+Uadrl0GNaeVMtS33HYBlHwXbC4vsleCUJ6l9rsi6bl1YQOmQL829bwGKT" +"yChQ9GUiLG/L5osSU1a41oKvu8Cj9IH2TAfnj0U37R/ou1B/zBEQeqCrIQYja/b275/IlTD0EgHZgj6OUFd8hr5dvlvfnaiByNWV9X1lyjG/CXWZQ0KvRu" +"wRa9uG85aBaeiJr9o953hYvOdaSQ89oLE1WXuPxXrJe2yqrG7kxU9nYkT9eaGHvBelPiUv72XrJ8n7tk8SvNQVHNlb/UcDrw2PGZL5vZu6RA4kFiPNLzfZ" +"aTWFVqt9FUjh4OpQqguRsQMeJW5NlONRqjRWD/kokI+Sh53q5aNQsTFyJtGNbC9elShqRcLKb6mRuLuHQlA7D/p5Ef4bJeW0CpGcUcgEgkwgMp4gE6giLm" +"zIBIJMIMgEqm4mEOHLOcUI5I1s8D+D6xZctzFCIH8J8pcgfwkng9z5S0RCQo0+Gaa2rFEIqHy+EkHRTL6ESvPVyc1XvdJ8CfSrqbaPcn/88SA7HqfcHGJn" +"om+zlME//Sq+/NClZwfNklSaZSsLDUqBsHKtawJBvljBOKrKJJkhU9O+XJuGG5mzfR1jx3O8gYAUj9LxjN7gOZ7TX8PDPR0Q52fwi5N0FvpeJAtv55HG+5" +"vLTrTLybKfa1dvXF03r6+FZmgqVvMcvUbiank2rtFU/Q1+S1cqhboF/JbVZ6d6fkvaaUnONXjPwHtGxhN4z8B7Bt4z8J6B96z4y7vj+bA7Gjry55dE2gh9" +"hyxHejrAVRYjBFxl4CoDVxnro/5O8NS6Wjb7FUTkrZ8fz8ZfLLF4U3ZSdNW/FTMR9V1sNO3eWCoRqaVC0VtCP9E/frqK8zkhHWptqoap2h/OGGhGc0d45U" +"qFWcEPh3Cn0ADTxALwoeh2q3ElCEKtFhqDlTz2DZBovpAX+YliFTti63iOqTqCY6TYn1zjnvx0eyNKvcebtOOpIHwR9mR0hBz25JnK2GfIAlqpmq84mFho" +"RxoIwTDEgZON6nXWp/dhn1ntXSCwV1uF7dWKRFLkkYZnvApXHaFdF9pllSNsR0+HB9uVogla2/U8zchTsXMWhmbELNmiazpBgVWKQhE9w4WtUmHDvJUiIj" +"dzFYowVitLwW7FGNeJIOjQB8UcoAVMyUAqk8UVlQh7cS3VFxXv+ScRV71GLi/syMuFUL7Jqg5FKbzrOdHJtYbMgUtrYSqKTmoCB0omyBstOMnAOt79HcQ6" +"DnXmZ+jbHtEMXWV11lU+ezjOyRqRqCpxQ+NreLbHb6MH3mVt4w7LF1P5SNFkkXOgMPbbBZp3hrbZrZspTeHCh9rNGLTk/HXaUR0Zs+OCRAqYgYgsd32pbV" +"eRhNCljbRVMtHUqO0fljAhPpgzDdwL1E8LxdWklNKp/d6iEkMjpxg8AsnF0MghBgtZxRmjEUdfvYYloVUrc4hEs8y2f+yGiG3KuqXhdUeGfBp1LBnN68PL" +"B7uA5JLPfqpi5ZNmduVTP8TdjZEyATepKiFtOlOrC2LRCmxFmzxtcZdpBnGq9czez8nATPBdoMJ1p9Zp1q7LcoFGDXByFCkR5icBkQByqRzkkuZIoYdceL" +"l0+KAuFQVd0szPfLgLBbSatnCX0DjavfxXWSSlLHl7j9gJvdxAp4G8sKlARFK4iUkd1zQLPdVaOGglV0CcKBGnL3/+P0TfWxgvWQIA" +}; +} // namespace cc diff --git a/native/cocos/core/builtin/Effects.cpp.in b/native/cocos/core/builtin/Effects.cpp.in new file mode 100644 index 0000000000..a21346cd9c --- /dev/null +++ b/native/cocos/core/builtin/Effects.cpp.in @@ -0,0 +1,35 @@ +/**************************************************************************** + 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. +****************************************************************************/ + +// clang-format off +#include "core/builtin/Effects.h" +#include "base/StringUtil.h" +namespace cc { + +// absolute essential effects +const GzipedString BUILTIN_EFFECTS { +${PLACE_HOLDER} +}; +} // namespace cc diff --git a/native/cocos/core/builtin/Effects.h b/native/cocos/core/builtin/Effects.h new file mode 100644 index 0000000000..8ddbcd097d --- /dev/null +++ b/native/cocos/core/builtin/Effects.h @@ -0,0 +1,33 @@ +/**************************************************************************** + 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 "cocos/base/StringUtil.h" +namespace cc { + +extern const GzipedString BUILTIN_EFFECTS; + +} diff --git a/native/cocos/core/builtin/ShaderSourceAssembly.cpp b/native/cocos/core/builtin/ShaderSourceAssembly.cpp new file mode 100644 index 0000000000..853621c7b9 --- /dev/null +++ b/native/cocos/core/builtin/ShaderSourceAssembly.cpp @@ -0,0 +1,48 @@ +/**************************************************************************** + 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/builtin/ShaderSourceAssembly.h" +#include "core/builtin/shader-sources/glsl1.h" +#include "core/builtin/shader-sources/glsl3.h" +#include "core/builtin/shader-sources/glsl4.h" + +namespace cc { + +namespace { +ShaderSourceMap assembly; +} + +/*static*/ +const ShaderSourceMap &ShaderSourceAssembly::get() { + if (assembly.empty()) { + assembly["glsl1"] = &builtinGLSL1; + assembly["glsl3"] = &builtinGLSL3; + assembly["glsl4"] = &builtinGLSL4; + } + + return assembly; +} + +} // namespace cc diff --git a/native/cocos/core/builtin/ShaderSourceAssembly.h b/native/cocos/core/builtin/ShaderSourceAssembly.h new file mode 100644 index 0000000000..d681dfea34 --- /dev/null +++ b/native/cocos/core/builtin/ShaderSourceAssembly.h @@ -0,0 +1,43 @@ +/**************************************************************************** + 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 +#include +#include +#include "base/StringUtil.h" +namespace cc { + +using ShaderInfo = std::unordered_map; +using ShaderSource = std::vector>; +using ShaderSourceMap = std::unordered_map; + +class ShaderSourceAssembly final { +public: + static const ShaderSourceMap &get(); +}; + +} // namespace cc diff --git a/native/cocos/core/builtin/effects.ts b/native/cocos/core/builtin/effects.ts new file mode 100644 index 0000000000..b3cadccc82 --- /dev/null +++ b/native/cocos/core/builtin/effects.ts @@ -0,0 +1,1216 @@ +/* eslint-disable */ +// absolute essential effects +export const effects = [ + { + "name": "billboard", + "techniques": [ + { "name": "add", "passes": [{ "rasterizerState": { "cullMode": 0 }, "blendState": { "targets": [{ "blend": true, "blendSrc": 2, "blendDst": 1, "blendSrcAlpha": 2, "blendDstAlpha": 1 }] }, "program": "billboard|vert:vs_main|tinted-fs:add", "depthStencilState": { "depthTest": true, "depthWrite": false }, "properties": { "mainTexture": { "value": "grey", "type": 28 }, "mainTiling_Offset": { "value": [1, 1, 0, 0], "type": 16 }, "tintColor": { "value": [0.5, 0.5, 0.5, 0.5], "type": 16 } } }] } + ], + "shaders": [ + { + "name": "billboard|vert:vs_main|tinted-fs:add", + "hash": 2909832090, + "builtins": { + "statistics": { "CC_EFFECT_USED_VERTEX_UNIFORM_VECTORS": 53, "CC_EFFECT_USED_FRAGMENT_UNIFORM_VECTORS": 40 }, + "globals": { "blocks": [{ "name": "CCGlobal", "defines": [] }, { "name": "CCCamera", "defines": [] }], "samplerTextures": [], "buffers": [], "images": [] }, + "locals": { "blocks": [{ "name": "CCLocal", "defines": [] }], "samplerTextures": [], "buffers": [], "images": [] } + }, + "defines": [], + "attributes": [ + { "name": "a_position", "defines": [], "format": 32, "location": 0 }, + { "name": "a_texCoord", "defines": [], "format": 21, "location": 1 }, + { "name": "a_color", "defines": [], "format": 44, "location": 2 } + ], + "blocks": [ + {"name": "Constants", "defines": [], "binding": 0, "stageFlags": 1, "members": [ + { "name": "mainTiling_Offset", "type": 16, "count": 1 }, + { "name": "frameTile_velLenScale", "type": 16, "count": 1 }, + { "name": "scale", "type": 16, "count": 1 }, + { "name": "nodeRotation", "type": 16, "count": 1 } + ]}, + {"name": "builtin", "defines": [], "binding": 1, "stageFlags": 1, "members": [ + { "name": "cc_size_rotation", "type": 16, "count": 1 } + ]}, + {"name": "FragConstants", "defines": [], "binding": 2, "stageFlags": 16, "members": [ + { "name": "tintColor", "type": 16, "count": 1 } + ]} + ], + "samplerTextures": [ + { "name": "mainTexture", "type": 28, "count": 1, "defines": [], "stageFlags": 16, "binding": 3 } + ], + "buffers": [], + "images": [], + "textures": [], + "samplers": [], + "subpassInputs": [] + } + ] + }, + { + "name": "clear-stencil", + "techniques": [ + { "passes": [{ "blendState": { "targets": [{ "blend": true }] }, "rasterizerState": { "cullMode": 0 }, "program": "clear-stencil|sprite-vs:vert|sprite-fs:frag", "depthStencilState": { "depthTest": false, "depthWrite": false } }] } + ], + "shaders": [ + { + "name": "clear-stencil|sprite-vs:vert|sprite-fs:frag", + "hash": 3507038093, + "builtins": { + "statistics": { "CC_EFFECT_USED_VERTEX_UNIFORM_VECTORS": 0, "CC_EFFECT_USED_FRAGMENT_UNIFORM_VECTORS": 0 }, + "globals": { "blocks": [], "samplerTextures": [], "buffers": [], "images": [] }, + "locals": { "blocks": [], "samplerTextures": [], "buffers": [], "images": [] } + }, + "defines": [], + "attributes": [ + { "name": "a_position", "defines": [], "format": 32, "location": 0 } + ], + "blocks": [], + "samplerTextures": [], + "buffers": [], + "images": [], + "textures": [], + "samplers": [], + "subpassInputs": [] + } + ] + }, + { + "name": "graphics", + "techniques": [ + { "passes": [{ "blendState": { "targets": [{ "blend": true, "blendSrc": 1, "blendDst": 4, "blendSrcAlpha": 1, "blendDstAlpha": 4 }] }, "rasterizerState": { "cullMode": 0 }, "program": "graphics|vs:vert|fs:frag", "depthStencilState": { "depthTest": false, "depthWrite": false } }] } + ], + "shaders": [ + { + "name": "graphics|vs:vert|fs:frag", + "hash": 2610213142, + "builtins": { + "statistics": { "CC_EFFECT_USED_VERTEX_UNIFORM_VECTORS": 48, "CC_EFFECT_USED_FRAGMENT_UNIFORM_VECTORS": 0 }, + "globals": { "blocks": [{ "name": "CCGlobal", "defines": [] }, { "name": "CCCamera", "defines": [] }], "samplerTextures": [], "buffers": [], "images": [] }, + "locals": { "blocks": [{ "name": "CCLocal", "defines": [] }], "samplerTextures": [], "buffers": [], "images": [] } + }, + "defines": [], + "attributes": [ + { "name": "a_position", "defines": [], "format": 32, "location": 0 }, + { "name": "a_color", "defines": [], "format": 44, "location": 1 }, + { "name": "a_dist", "defines": [], "format": 11, "location": 2 } + ], + "blocks": [], + "samplerTextures": [], + "buffers": [], + "images": [], + "textures": [], + "samplers": [], + "subpassInputs": [] + } + ] + }, + { + "name": "occlusion-query", + "techniques": [ + { "passes": [{ "rasterizerState": { "cullMode": 2 }, "blendState": { "targets": [{ "blendColorMask": 0 }] }, "program": "occlusion-query|occlusion-query-vs:vert|occlusion-query-fs:frag", "depthStencilState": { "depthTest": true, "depthWrite": false } }] } + ], + "shaders": [ + { + "name": "occlusion-query|occlusion-query-vs:vert|occlusion-query-fs:frag", + "hash": 1571978323, + "builtins": { + "statistics": { "CC_EFFECT_USED_VERTEX_UNIFORM_VECTORS": 41, "CC_EFFECT_USED_FRAGMENT_UNIFORM_VECTORS": 0 }, + "globals": { "blocks": [{ "name": "CCGlobal", "defines": [] }, { "name": "CCCamera", "defines": [] }], "samplerTextures": [], "buffers": [], "images": [] }, + "locals": { "blocks": [{ "name": "CCWorldBound", "defines": [] }], "samplerTextures": [], "buffers": [], "images": [] } + }, + "defines": [], + "attributes": [ + { "name": "a_position", "defines": [], "format": 32, "location": 0 } + ], + "blocks": [], + "samplerTextures": [], + "buffers": [], + "images": [], + "textures": [], + "samplers": [], + "subpassInputs": [] + } + ] + }, + { + "name": "particle-gpu", + "techniques": [ + { "name": "add", "passes": [{ "rasterizerState": { "cullMode": 0 }, "blendState": { "targets": [{ "blend": true, "blendSrc": 2, "blendDst": 1, "blendSrcAlpha": 2, "blendDstAlpha": 1 }] }, "program": "particle-gpu|particle-vs-gpu:gpvs_main|tinted-fs:add", "depthStencilState": { "depthTest": true, "depthWrite": false }, "properties": { "mainTexture": { "value": "grey", "type": 28 }, "mainTiling_Offset": { "value": [1, 1, 0, 0], "type": 16 }, "tintColor": { "value": [0.5, 0.5, 0.5, 0.5], "type": 16 } } }] } + ], + "shaders": [ + { + "name": "particle-gpu|particle-vs-gpu:gpvs_main|tinted-fs:add", + "hash": 1813246314, + "builtins": { + "statistics": { "CC_EFFECT_USED_VERTEX_UNIFORM_VECTORS": 63, "CC_EFFECT_USED_FRAGMENT_UNIFORM_VECTORS": 40 }, + "globals": { "blocks": [{ "name": "CCGlobal", "defines": [] }, { "name": "CCCamera", "defines": [] }], "samplerTextures": [], "buffers": [], "images": [] }, + "locals": { "blocks": [{ "name": "CCLocal", "defines": [] }], "samplerTextures": [], "buffers": [], "images": [] } + }, + "defines": [ + { "name": "CC_RENDER_MODE", "type": "number", "range": [0, 4] }, + { "name": "COLOR_OVER_TIME_MODULE_ENABLE", "type": "boolean" }, + { "name": "ROTATION_OVER_TIME_MODULE_ENABLE", "type": "boolean" }, + { "name": "SIZE_OVER_TIME_MODULE_ENABLE", "type": "boolean" }, + { "name": "FORCE_OVER_TIME_MODULE_ENABLE", "type": "boolean" }, + { "name": "VELOCITY_OVER_TIME_MODULE_ENABLE", "type": "boolean" }, + { "name": "TEXTURE_ANIMATION_MODULE_ENABLE", "type": "boolean" }, + { "name": "CC_USE_WORLD_SPACE", "type": "boolean" } + ], + "attributes": [ + { "name": "a_position_starttime", "defines": [], "format": 44, "location": 0 }, + { "name": "a_size_uv", "defines": [], "format": 44, "location": 1 }, + { "name": "a_rotation_uv", "defines": [], "format": 44, "location": 2 }, + { "name": "a_color", "defines": [], "format": 44, "location": 3 }, + { "name": "a_dir_life", "defines": [], "format": 44, "location": 4 }, + { "name": "a_rndSeed", "defines": [], "format": 11, "location": 5 }, + { "name": "a_texCoord", "defines": ["CC_RENDER_MODE"], "format": 32, "location": 6 }, + { "name": "a_texCoord3", "defines": ["CC_RENDER_MODE"], "format": 32, "location": 7 }, + { "name": "a_normal", "defines": ["CC_RENDER_MODE"], "format": 32, "location": 8 }, + { "name": "a_color1", "defines": ["CC_RENDER_MODE"], "format": 44, "location": 9 } + ], + "blocks": [ + {"name": "Constants", "defines": [], "binding": 0, "stageFlags": 1, "members": [ + { "name": "mainTiling_Offset", "type": 16, "count": 1 }, + { "name": "frameTile_velLenScale", "type": 16, "count": 1 }, + { "name": "scale", "type": 16, "count": 1 }, + { "name": "nodeRotation", "type": 16, "count": 1 } + ]}, + {"name": "SampleConstants", "defines": [], "binding": 1, "stageFlags": 1, "members": [ + { "name": "u_sampleInfo", "type": 16, "count": 1 } + ]}, + {"name": "TickConstants", "defines": [], "binding": 2, "stageFlags": 1, "members": [ + { "name": "u_worldRot", "type": 16, "count": 1 }, + { "name": "u_timeDelta", "type": 16, "count": 1 } + ]}, + {"name": "ColorConstant", "defines": ["COLOR_OVER_TIME_MODULE_ENABLE"], "binding": 3, "stageFlags": 1, "members": [ + { "name": "u_color_mode", "type": 5, "count": 1 } + ]}, + {"name": "RotationConstant", "defines": ["ROTATION_OVER_TIME_MODULE_ENABLE"], "binding": 4, "stageFlags": 1, "members": [ + { "name": "u_rotation_mode", "type": 5, "count": 1 } + ]}, + {"name": "SizeConstant", "defines": ["SIZE_OVER_TIME_MODULE_ENABLE"], "binding": 5, "stageFlags": 1, "members": [ + { "name": "u_size_mode", "type": 5, "count": 1 } + ]}, + {"name": "ForceConstant", "defines": ["FORCE_OVER_TIME_MODULE_ENABLE"], "binding": 6, "stageFlags": 1, "members": [ + { "name": "u_force_mode", "type": 5, "count": 1 }, + { "name": "u_force_space", "type": 5, "count": 1 } + ]}, + {"name": "VelocityConstant", "defines": ["VELOCITY_OVER_TIME_MODULE_ENABLE"], "binding": 7, "stageFlags": 1, "members": [ + { "name": "u_velocity_mode", "type": 5, "count": 1 }, + { "name": "u_velocity_space", "type": 5, "count": 1 } + ]}, + {"name": "AnimationConstant", "defines": ["TEXTURE_ANIMATION_MODULE_ENABLE"], "binding": 8, "stageFlags": 1, "members": [ + { "name": "u_anim_info", "type": 16, "count": 1 } + ]}, + {"name": "FragConstants", "defines": [], "binding": 9, "stageFlags": 16, "members": [ + { "name": "tintColor", "type": 16, "count": 1 } + ]} + ], + "samplerTextures": [ + { "name": "color_over_time_tex0", "type": 28, "count": 1, "defines": ["COLOR_OVER_TIME_MODULE_ENABLE"], "stageFlags": 1, "binding": 10 }, + { "name": "rotation_over_time_tex0", "type": 28, "count": 1, "defines": ["ROTATION_OVER_TIME_MODULE_ENABLE"], "stageFlags": 1, "binding": 11 }, + { "name": "size_over_time_tex0", "type": 28, "count": 1, "defines": ["SIZE_OVER_TIME_MODULE_ENABLE"], "stageFlags": 1, "binding": 12 }, + { "name": "force_over_time_tex0", "type": 28, "count": 1, "defines": ["FORCE_OVER_TIME_MODULE_ENABLE"], "stageFlags": 1, "binding": 13 }, + { "name": "velocity_over_time_tex0", "type": 28, "count": 1, "defines": ["VELOCITY_OVER_TIME_MODULE_ENABLE"], "stageFlags": 1, "binding": 14 }, + { "name": "texture_animation_tex0", "type": 28, "count": 1, "defines": ["TEXTURE_ANIMATION_MODULE_ENABLE"], "stageFlags": 1, "binding": 15 }, + { "name": "mainTexture", "type": 28, "count": 1, "defines": [], "stageFlags": 16, "binding": 16 } + ], + "buffers": [], + "images": [], + "textures": [], + "samplers": [], + "subpassInputs": [] + } + ] + }, + { + "name": "particle-trail", + "techniques": [ + { "name": "add", "passes": [{ "rasterizerState": { "cullMode": 0 }, "blendState": { "targets": [{ "blend": true, "blendSrc": 2, "blendDst": 1, "blendSrcAlpha": 2, "blendDstAlpha": 1 }] }, "program": "particle-trail|particle-trail:vs_main|tinted-fs:add", "depthStencilState": { "depthTest": true, "depthWrite": false }, "properties": { "mainTexture": { "value": "grey", "type": 28 }, "mainTiling_Offset": { "value": [1, 1, 0, 0], "type": 16 }, "frameTile_velLenScale": { "value": [1, 1, 0, 0], "type": 16 }, "tintColor": { "value": [0.5, 0.5, 0.5, 0.5], "type": 16 } } }] } + ], + "shaders": [ + { + "name": "particle-trail|particle-trail:vs_main|tinted-fs:add", + "hash": 1437790364, + "builtins": { + "statistics": { "CC_EFFECT_USED_VERTEX_UNIFORM_VECTORS": 52, "CC_EFFECT_USED_FRAGMENT_UNIFORM_VECTORS": 40 }, + "globals": { "blocks": [{ "name": "CCGlobal", "defines": [] }, { "name": "CCCamera", "defines": [] }], "samplerTextures": [], "buffers": [], "images": [] }, + "locals": { "blocks": [{ "name": "CCLocal", "defines": [] }], "samplerTextures": [], "buffers": [], "images": [] } + }, + "defines": [ + { "name": "CC_RENDER_MODE", "type": "number", "range": [0, 4] }, + { "name": "CC_DRAW_WIRE_FRAME", "type": "boolean" }, + { "name": "CC_USE_WORLD_SPACE", "type": "boolean" } + ], + "attributes": [ + { "name": "a_position", "defines": [], "format": 32, "location": 0 }, + { "name": "a_texCoord", "defines": [], "format": 44, "location": 1 }, + { "name": "a_texCoord1", "defines": [], "format": 32, "location": 2 }, + { "name": "a_texCoord2", "defines": [], "format": 32, "location": 3 }, + { "name": "a_color", "defines": [], "format": 44, "location": 4 } + ], + "blocks": [ + {"name": "Constants", "defines": [], "binding": 0, "stageFlags": 1, "members": [ + { "name": "mainTiling_Offset", "type": 16, "count": 1 }, + { "name": "frameTile_velLenScale", "type": 16, "count": 1 }, + { "name": "scale", "type": 16, "count": 1 }, + { "name": "nodeRotation", "type": 16, "count": 1 } + ]}, + {"name": "FragConstants", "defines": [], "binding": 1, "stageFlags": 16, "members": [ + { "name": "tintColor", "type": 16, "count": 1 } + ]} + ], + "samplerTextures": [ + { "name": "mainTexture", "type": 28, "count": 1, "defines": [], "stageFlags": 16, "binding": 2 } + ], + "buffers": [], + "images": [], + "textures": [], + "samplers": [], + "subpassInputs": [] + } + ] + }, + { + "name": "particle", + "techniques": [ + { "name": "add", "passes": [{ "rasterizerState": { "cullMode": 0 }, "blendState": { "targets": [{ "blend": true, "blendSrc": 2, "blendDst": 1, "blendSrcAlpha": 2, "blendDstAlpha": 1 }] }, "program": "particle|particle-vs-legacy:lpvs_main|tinted-fs:add", "depthStencilState": { "depthTest": true, "depthWrite": false }, "properties": { "mainTexture": { "value": "grey", "type": 28 }, "mainTiling_Offset": { "value": [1, 1, 0, 0], "type": 16 }, "tintColor": { "value": [0.5, 0.5, 0.5, 0.5], "type": 16 } } }] } + ], + "shaders": [ + { + "name": "particle|particle-vs-legacy:lpvs_main|tinted-fs:add", + "hash": 2766437914, + "builtins": { + "statistics": { "CC_EFFECT_USED_VERTEX_UNIFORM_VECTORS": 52, "CC_EFFECT_USED_FRAGMENT_UNIFORM_VECTORS": 40 }, + "globals": { "blocks": [{ "name": "CCGlobal", "defines": [] }, { "name": "CCCamera", "defines": [] }], "samplerTextures": [], "buffers": [], "images": [] }, + "locals": { "blocks": [{ "name": "CCLocal", "defines": [] }], "samplerTextures": [], "buffers": [], "images": [] } + }, + "defines": [ + { "name": "CC_RENDER_MODE", "type": "number", "range": [0, 4] }, + { "name": "CC_USE_WORLD_SPACE", "type": "boolean" }, + { "name": "ROTATION_OVER_TIME_MODULE_ENABLE", "type": "boolean" } + ], + "attributes": [ + { "name": "a_position", "defines": [], "format": 32, "location": 0 }, + { "name": "a_texCoord", "defines": [], "format": 32, "location": 1 }, + { "name": "a_texCoord1", "defines": [], "format": 32, "location": 2 }, + { "name": "a_texCoord2", "defines": [], "format": 32, "location": 3 }, + { "name": "a_color", "defines": [], "format": 44, "location": 4 }, + { "name": "a_color1", "defines": ["CC_RENDER_MODE"], "format": 32, "location": 8 }, + { "name": "a_texCoord3", "defines": ["CC_RENDER_MODE"], "format": 32, "location": 6 }, + { "name": "a_normal", "defines": ["CC_RENDER_MODE"], "format": 32, "location": 7 } + ], + "blocks": [ + {"name": "Constants", "defines": [], "binding": 0, "stageFlags": 1, "members": [ + { "name": "mainTiling_Offset", "type": 16, "count": 1 }, + { "name": "frameTile_velLenScale", "type": 16, "count": 1 }, + { "name": "scale", "type": 16, "count": 1 }, + { "name": "nodeRotation", "type": 16, "count": 1 } + ]}, + {"name": "FragConstants", "defines": [], "binding": 1, "stageFlags": 16, "members": [ + { "name": "tintColor", "type": 16, "count": 1 } + ]} + ], + "samplerTextures": [ + { "name": "mainTexture", "type": 28, "count": 1, "defines": [], "stageFlags": 16, "binding": 2 } + ], + "buffers": [], + "images": [], + "textures": [], + "samplers": [], + "subpassInputs": [] + } + ] + }, + { + "name": "spine", + "techniques": [ + { "passes": [{ "blendState": { "targets": [{ "blend": true, "blendSrc": 2, "blendDst": 4, "blendDstAlpha": 4 }] }, "rasterizerState": { "cullMode": 0 }, "program": "spine|sprite-vs:vert|sprite-fs:frag", "depthStencilState": { "depthTest": false, "depthWrite": false }, "properties": { "alphaThreshold": { "value": [0.5], "type": 13 } } }] } + ], + "shaders": [ + { + "name": "spine|sprite-vs:vert|sprite-fs:frag", + "hash": 3192452405, + "builtins": { + "statistics": { "CC_EFFECT_USED_VERTEX_UNIFORM_VECTORS": 48, "CC_EFFECT_USED_FRAGMENT_UNIFORM_VECTORS": 1 }, + "globals": { "blocks": [{ "name": "CCGlobal", "defines": [] }, { "name": "CCCamera", "defines": [] }], "samplerTextures": [], "buffers": [], "images": [] }, + "locals": { "blocks": [{ "name": "CCLocal", "defines": ["USE_LOCAL"] }], "samplerTextures": [{ "name": "cc_spriteTexture", "defines": [] }], "buffers": [], "images": [] } + }, + "defines": [ + { "name": "USE_LOCAL", "type": "boolean" }, + { "name": "TWO_COLORED", "type": "boolean" }, + { "name": "USE_ALPHA_TEST", "type": "boolean" } + ], + "attributes": [ + { "name": "a_position", "defines": [], "format": 32, "location": 0 }, + { "name": "a_texCoord", "defines": [], "format": 21, "location": 1 }, + { "name": "a_color", "defines": [], "format": 44, "location": 2 }, + { "name": "a_color2", "defines": ["TWO_COLORED"], "format": 44, "location": 3 } + ], + "blocks": [ + {"name": "ALPHA_TEST_DATA", "defines": ["USE_ALPHA_TEST"], "binding": 0, "stageFlags": 16, "members": [ + { "name": "alphaThreshold", "type": 13, "count": 1 } + ]} + ], + "samplerTextures": [], + "buffers": [], + "images": [], + "textures": [], + "samplers": [], + "subpassInputs": [] + } + ] + }, + { + "name": "sprite-gpu", + "techniques": [ + { "passes": [{ "blendState": { "targets": [{ "blend": true, "blendSrc": 2, "blendDst": 4, "blendDstAlpha": 4 }] }, "rasterizerState": { "cullMode": 0 }, "program": "sprite-gpu|sprite-vs-gpu:vert|sprite-fs-gpu:frag", "depthStencilState": { "depthTest": false, "depthWrite": false } }] } + ], + "shaders": [ + { + "name": "sprite-gpu|sprite-vs-gpu:vert|sprite-fs-gpu:frag", + "hash": 2450198964, + "builtins": { + "statistics": { "CC_EFFECT_USED_VERTEX_UNIFORM_VECTORS": 39, "CC_EFFECT_USED_FRAGMENT_UNIFORM_VECTORS": 0 }, + "globals": { "blocks": [{ "name": "CCGlobal", "defines": [] }, { "name": "CCCamera", "defines": [] }], "samplerTextures": [], "buffers": [], "images": [] }, + "locals": { "blocks": [{ "name": "CCUILocal", "defines": [] }], "samplerTextures": [{ "name": "cc_spriteTexture", "defines": ["USE_TEXTURE"] }], "buffers": [], "images": [] } + }, + "defines": [ + { "name": "SAMPLE_FROM_RT", "type": "boolean" }, + { "name": "USE_PIXEL_ALIGNMENT", "type": "boolean" }, + { "name": "CC_USE_EMBEDDED_ALPHA", "type": "boolean" }, + { "name": "USE_TEXTURE", "type": "boolean" }, + { "name": "IS_GRAY", "type": "boolean" } + ], + "attributes": [ + { "name": "a_position", "defines": [], "format": 32, "location": 0 }, + { "name": "a_texCoord", "defines": [], "format": 21, "location": 1 }, + { "name": "a_batch_id", "defines": [], "format": 11, "location": 2 } + ], + "blocks": [], + "samplerTextures": [], + "buffers": [], + "images": [], + "textures": [], + "samplers": [], + "subpassInputs": [] + } + ] + }, + { + "name": "sprite", + "techniques": [ + { "passes": [{ "blendState": { "targets": [{ "blend": true, "blendSrc": 2, "blendDst": 4, "blendDstAlpha": 4 }] }, "rasterizerState": { "cullMode": 0 }, "program": "sprite|sprite-vs:vert|sprite-fs:frag", "depthStencilState": { "depthTest": false, "depthWrite": false }, "properties": { "alphaThreshold": { "value": [0.5], "type": 13 } } }] } + ], + "shaders": [ + { + "name": "sprite|sprite-vs:vert|sprite-fs:frag", + "hash": 1770338543, + "builtins": { + "statistics": { "CC_EFFECT_USED_VERTEX_UNIFORM_VECTORS": 48, "CC_EFFECT_USED_FRAGMENT_UNIFORM_VECTORS": 1 }, + "globals": { "blocks": [{ "name": "CCGlobal", "defines": [] }, { "name": "CCCamera", "defines": [] }], "samplerTextures": [], "buffers": [], "images": [] }, + "locals": { "blocks": [{ "name": "CCLocal", "defines": ["USE_LOCAL"] }], "samplerTextures": [{ "name": "cc_spriteTexture", "defines": ["USE_TEXTURE"] }], "buffers": [], "images": [] } + }, + "defines": [ + { "name": "USE_LOCAL", "type": "boolean" }, + { "name": "SAMPLE_FROM_RT", "type": "boolean" }, + { "name": "USE_PIXEL_ALIGNMENT", "type": "boolean" }, + { "name": "CC_USE_EMBEDDED_ALPHA", "type": "boolean" }, + { "name": "USE_ALPHA_TEST", "type": "boolean" }, + { "name": "USE_TEXTURE", "type": "boolean" }, + { "name": "IS_GRAY", "type": "boolean" } + ], + "attributes": [ + { "name": "a_position", "defines": [], "format": 32, "location": 0 }, + { "name": "a_texCoord", "defines": [], "format": 21, "location": 1 }, + { "name": "a_color", "defines": [], "format": 44, "location": 2 } + ], + "blocks": [ + {"name": "ALPHA_TEST_DATA", "defines": ["USE_ALPHA_TEST"], "binding": 0, "stageFlags": 16, "members": [ + { "name": "alphaThreshold", "type": 13, "count": 1 } + ]} + ], + "samplerTextures": [], + "buffers": [], + "images": [], + "textures": [], + "samplers": [], + "subpassInputs": [] + } + ] + }, + { + "name": "standard", + "techniques": [ + { "name": "opaque", "passes": [{ "program": "standard|standard-vs|standard-fs", "properties": { "tilingOffset": { "value": [1, 1, 0, 0], "type": 16 }, "mainColor": { "value": [1, 1, 1, 1], "linear": true, "type": 16, "handleInfo": ["albedo", 0, 16] }, "albedoScale": { "value": [1, 1, 1], "type": 15, "handleInfo": ["albedoScaleAndCutoff", 0, 15] }, "alphaThreshold": { "value": [0.5], "type": 13, "handleInfo": ["albedoScaleAndCutoff", 3, 13] }, "occlusion": { "value": [1], "type": 13, "handleInfo": ["pbrParams", 0, 13] }, "roughness": { "value": [0.8], "type": 13, "handleInfo": ["pbrParams", 1, 13] }, "metallic": { "value": [0.6], "type": 13, "handleInfo": ["pbrParams", 2, 13] }, "SpecularIntensity": { "value": [0.5], "type": 13, "handleInfo": ["pbrParams", 3, 13] }, "emissive": { "value": [0, 0, 0, 1], "linear": true, "type": 16 }, "emissiveScale": { "value": [1, 1, 1], "type": 15, "handleInfo": ["emissiveScaleParam", 0, 15] }, "normalStrenth": { "value": [1], "type": 13, "handleInfo": ["emissiveScaleParam", 3, 13] }, "mainTexture": { "value": "grey", "type": 28, "handleInfo": ["albedoMap", 0, 28] }, "normalMap": { "value": "normal", "type": 28 }, "pbrMap": { "value": "grey", "type": 28 }, "metallicRoughnessMap": { "value": "grey", "type": 28 }, "occlusionMap": { "value": "white", "type": 28 }, "emissiveMap": { "value": "grey", "type": 28 }, "albedo": { "type": 16, "value": [1, 1, 1, 1] }, "albedoScaleAndCutoff": { "type": 16, "value": [1, 1, 1, 0.5] }, "pbrParams": { "type": 16, "value": [1, 0.8, 0.6, 0.5] }, "emissiveScaleParam": { "type": 16, "value": [1, 1, 1, 1] }, "albedoMap": { "type": 28, "value": "grey" } } }, { "phase": "forward-add", "propertyIndex": 0, "embeddedMacros": { "CC_FORWARD_ADD": true }, "blendState": { "targets": [{ "blend": true, "blendSrc": 1, "blendDst": 1, "blendSrcAlpha": 0, "blendDstAlpha": 1 }] }, "program": "standard|standard-vs|standard-fs", "depthStencilState": { "depthFunc": 2, "depthTest": true, "depthWrite": false } }, { "phase": "shadow-caster", "propertyIndex": 0, "rasterizerState": { "cullMode": 1 }, "program": "standard|shadow-caster-vs:vert|shadow-caster-fs:frag", "properties": { "tilingOffset": { "value": [1, 1, 0, 0], "type": 16 }, "mainColor": { "value": [1, 1, 1, 1], "type": 16, "handleInfo": ["albedo", 0, 16] }, "albedoScale": { "value": [1, 1, 1], "type": 15, "handleInfo": ["albedoScaleAndCutoff", 0, 15] }, "alphaThreshold": { "value": [0.5], "type": 13, "handleInfo": ["albedoScaleAndCutoff", 3, 13] }, "mainTexture": { "value": "grey", "type": 28, "handleInfo": ["albedoMap", 0, 28] }, "albedo": { "type": 16, "value": [1, 1, 1, 1] }, "albedoScaleAndCutoff": { "type": 16, "value": [1, 1, 1, 0.5] }, "albedoMap": { "type": 28, "value": "grey" } } }] } + ], + "shaders": [ + { + "name": "standard|standard-vs|standard-fs", + "hash": 2864919663, + "builtins": { + "statistics": { "CC_EFFECT_USED_VERTEX_UNIFORM_VECTORS": 221, "CC_EFFECT_USED_FRAGMENT_UNIFORM_VECTORS": 64 }, + "globals": { "blocks": [{ "name": "CCGlobal", "defines": [] }, { "name": "CCCamera", "defines": [] }, { "name": "CCShadow", "defines": [] }], "samplerTextures": [{ "name": "cc_shadowMap", "defines": ["CC_RECEIVE_SHADOW"] }, { "name": "cc_spotLightingMap", "defines": ["CC_RECEIVE_SHADOW"] }, { "name": "cc_environment", "defines": ["CC_USE_IBL"] }, { "name": "cc_diffuseMap", "defines": ["CC_USE_IBL", "CC_USE_DIFFUSEMAP"] }], "buffers": [], "images": [] }, + "locals": { "blocks": [{ "name": "CCMorph", "defines": ["CC_USE_MORPH"] }, { "name": "CCSkinningTexture", "defines": ["CC_USE_SKINNING", "CC_USE_BAKED_ANIMATION"] }, { "name": "CCSkinningAnimation", "defines": ["CC_USE_SKINNING", "CC_USE_BAKED_ANIMATION"] }, { "name": "CCSkinning", "defines": ["CC_USE_SKINNING", "!CC_USE_BAKED_ANIMATION"] }, { "name": "CCLocalBatched", "defines": ["!USE_INSTANCING", "USE_BATCHING"] }, { "name": "CCLocal", "defines": ["!USE_INSTANCING", "!USE_BATCHING"] }, { "name": "CCForwardLight", "defines": ["CC_FORWARD_ADD", "CC_ENABLE_CLUSTERED_LIGHT_CULLING"] }], "samplerTextures": [{ "name": "cc_PositionDisplacements", "defines": ["CC_USE_MORPH", "CC_MORPH_TARGET_HAS_POSITION"] }, { "name": "cc_NormalDisplacements", "defines": ["CC_USE_MORPH", "CC_MORPH_TARGET_HAS_NORMAL"] }, { "name": "cc_TangentDisplacements", "defines": ["CC_USE_MORPH", "CC_MORPH_TARGET_HAS_TANGENT"] }, { "name": "cc_jointTexture", "defines": ["CC_USE_SKINNING", "CC_USE_BAKED_ANIMATION"] }, { "name": "cc_lightingMap", "defines": ["USE_LIGHTMAP", "!USE_BATCHING", "!CC_FORWARD_ADD"] }], "buffers": [], "images": [] } + }, + "defines": [ + { "name": "CC_USE_MORPH", "type": "boolean" }, + { "name": "CC_MORPH_TARGET_COUNT", "type": "number", "range": [2, 8] }, + { "name": "CC_MORPH_PRECOMPUTED", "type": "boolean" }, + { "name": "CC_MORPH_TARGET_HAS_POSITION", "type": "boolean" }, + { "name": "CC_MORPH_TARGET_HAS_NORMAL", "type": "boolean" }, + { "name": "CC_MORPH_TARGET_HAS_TANGENT", "type": "boolean" }, + { "name": "CC_USE_SKINNING", "type": "boolean" }, + { "name": "CC_USE_BAKED_ANIMATION", "type": "boolean" }, + { "name": "USE_INSTANCING", "type": "boolean" }, + { "name": "USE_BATCHING", "type": "boolean" }, + { "name": "USE_LIGHTMAP", "type": "boolean" }, + { "name": "CC_USE_FOG", "type": "number", "range": [0, 4] }, + { "name": "CC_USE_ACCURATE_FOG", "type": "boolean" }, + { "name": "CC_RECEIVE_SHADOW", "type": "boolean" }, + { "name": "USE_VERTEX_COLOR", "type": "boolean" }, + { "name": "USE_NORMAL_MAP", "type": "boolean" }, + { "name": "HAS_SECOND_UV", "type": "boolean" }, + { "name": "CC_FORWARD_ADD", "type": "boolean" }, + { "name": "USE_TWOSIDE", "type": "boolean" }, + { "name": "SAMPLE_FROM_RT", "type": "boolean" }, + { "name": "CC_USE_IBL", "type": "number", "range": [0, 2] }, + { "name": "CC_USE_DIFFUSEMAP", "type": "number", "range": [0, 2] }, + { "name": "USE_REFLECTION_DENOISE", "type": "boolean" }, + { "name": "CC_ENABLE_DIR_SHADOW", "type": "boolean" }, + { "name": "CC_USE_HDR", "type": "boolean" }, + { "name": "USE_ALBEDO_MAP", "type": "boolean" }, + { "name": "ALBEDO_UV", "type": "string", "options": ["v_uv", "v_uv1"] }, + { "name": "NORMAL_UV", "type": "string", "options": ["v_uv", "v_uv1"] }, + { "name": "PBR_UV", "type": "string", "options": ["v_uv", "v_uv1"] }, + { "name": "USE_PBR_MAP", "type": "boolean" }, + { "name": "USE_METALLIC_ROUGHNESS_MAP", "type": "boolean" }, + { "name": "USE_OCCLUSION_MAP", "type": "boolean" }, + { "name": "USE_EMISSIVE_MAP", "type": "boolean" }, + { "name": "EMISSIVE_UV", "type": "string", "options": ["v_uv", "v_uv1"] }, + { "name": "USE_ALPHA_TEST", "type": "boolean" }, + { "name": "ALPHA_TEST_CHANNEL", "type": "string", "options": ["a", "r"] }, + { "name": "CC_PIPELINE_TYPE", "type": "number", "range": [0, 1] }, + { "name": "CC_FORCE_FORWARD_SHADING", "type": "boolean" } + ], + "attributes": [ + { "name": "a_position", "defines": [], "format": 32, "location": 0 }, + { "name": "a_normal", "defines": [], "format": 32, "location": 1 }, + { "name": "a_texCoord", "defines": [], "format": 21, "location": 2 }, + { "name": "a_tangent", "defines": [], "format": 44, "location": 3 }, + { "name": "a_vertexId", "defines": ["CC_USE_MORPH"], "format": 11, "location": 6 }, + { "name": "a_joints", "defines": ["CC_USE_SKINNING"], "location": 4 }, + { "name": "a_weights", "defines": ["CC_USE_SKINNING"], "format": 44, "location": 5 }, + { "name": "a_jointAnimInfo", "defines": ["CC_USE_SKINNING", "CC_USE_BAKED_ANIMATION", "USE_INSTANCING"], "format": 44, "isInstanced": true, "location": 7 }, + { "name": "a_matWorld0", "defines": ["USE_INSTANCING"], "format": 44, "isInstanced": true, "location": 8 }, + { "name": "a_matWorld1", "defines": ["USE_INSTANCING"], "format": 44, "isInstanced": true, "location": 9 }, + { "name": "a_matWorld2", "defines": ["USE_INSTANCING"], "format": 44, "isInstanced": true, "location": 10 }, + { "name": "a_lightingMapUVParam", "defines": ["USE_INSTANCING", "USE_LIGHTMAP"], "format": 44, "isInstanced": true, "location": 11 }, + { "name": "a_dyn_batch_id", "defines": ["!USE_INSTANCING", "USE_BATCHING"], "format": 11, "location": 12 }, + { "name": "a_color", "defines": ["USE_VERTEX_COLOR"], "format": 44, "location": 13 }, + { "name": "a_texCoord1", "defines": [], "format": 21, "location": 14 } + ], + "blocks": [ + {"name": "Constants", "defines": [], "binding": 0, "stageFlags": 17, "members": [ + { "name": "tilingOffset", "type": 16, "count": 1 }, + { "name": "albedo", "type": 16, "count": 1 }, + { "name": "albedoScaleAndCutoff", "type": 16, "count": 1 }, + { "name": "pbrParams", "type": 16, "count": 1 }, + { "name": "emissive", "type": 16, "count": 1 }, + { "name": "emissiveScaleParam", "type": 16, "count": 1 } + ]} + ], + "samplerTextures": [ + { "name": "albedoMap", "type": 28, "count": 1, "defines": ["USE_ALBEDO_MAP"], "stageFlags": 16, "binding": 1 }, + { "name": "normalMap", "type": 28, "count": 1, "defines": ["USE_NORMAL_MAP"], "stageFlags": 16, "binding": 2 }, + { "name": "pbrMap", "type": 28, "count": 1, "defines": ["USE_PBR_MAP"], "stageFlags": 16, "binding": 3 }, + { "name": "metallicRoughnessMap", "type": 28, "count": 1, "defines": ["USE_METALLIC_ROUGHNESS_MAP"], "stageFlags": 16, "binding": 4 }, + { "name": "occlusionMap", "type": 28, "count": 1, "defines": ["USE_OCCLUSION_MAP"], "stageFlags": 16, "binding": 5 }, + { "name": "emissiveMap", "type": 28, "count": 1, "defines": ["USE_EMISSIVE_MAP"], "stageFlags": 16, "binding": 6 } + ], + "buffers": [ + { "name": "b_ccLightsBuffer", "memoryAccess": 1, "defines": ["CC_FORWARD_ADD", "CC_ENABLE_CLUSTERED_LIGHT_CULLING"], "stageFlags": 16, "binding": 7 }, + { "name": "b_clusterLightIndicesBuffer", "memoryAccess": 1, "defines": ["CC_FORWARD_ADD", "CC_ENABLE_CLUSTERED_LIGHT_CULLING"], "stageFlags": 16, "binding": 8 }, + { "name": "b_clusterLightGridBuffer", "memoryAccess": 1, "defines": ["CC_FORWARD_ADD", "CC_ENABLE_CLUSTERED_LIGHT_CULLING"], "stageFlags": 16, "binding": 9 } + ], + "images": [], + "textures": [], + "samplers": [], + "subpassInputs": [] + }, + { + "name": "standard|shadow-caster-vs:vert|shadow-caster-fs:frag", + "hash": 1774012115, + "builtins": { + "statistics": { "CC_EFFECT_USED_VERTEX_UNIFORM_VECTORS": 182, "CC_EFFECT_USED_FRAGMENT_UNIFORM_VECTORS": 64 }, + "globals": { "blocks": [{ "name": "CCShadow", "defines": [] }, { "name": "CCGlobal", "defines": [] }, { "name": "CCCamera", "defines": [] }], "samplerTextures": [{ "name": "cc_shadowMap", "defines": ["CC_RECEIVE_SHADOW"] }, { "name": "cc_spotLightingMap", "defines": ["CC_RECEIVE_SHADOW"] }], "buffers": [], "images": [] }, + "locals": { "blocks": [{ "name": "CCMorph", "defines": ["CC_USE_MORPH"] }, { "name": "CCSkinningTexture", "defines": ["CC_USE_SKINNING", "CC_USE_BAKED_ANIMATION"] }, { "name": "CCSkinningAnimation", "defines": ["CC_USE_SKINNING", "CC_USE_BAKED_ANIMATION"] }, { "name": "CCSkinning", "defines": ["CC_USE_SKINNING", "!CC_USE_BAKED_ANIMATION"] }, { "name": "CCLocalBatched", "defines": ["!USE_INSTANCING", "USE_BATCHING"] }, { "name": "CCLocal", "defines": ["!USE_INSTANCING", "!USE_BATCHING"] }], "samplerTextures": [{ "name": "cc_PositionDisplacements", "defines": ["CC_USE_MORPH", "CC_MORPH_TARGET_HAS_POSITION"] }, { "name": "cc_NormalDisplacements", "defines": ["CC_USE_MORPH", "CC_MORPH_TARGET_HAS_NORMAL"] }, { "name": "cc_TangentDisplacements", "defines": ["CC_USE_MORPH", "CC_MORPH_TARGET_HAS_TANGENT"] }, { "name": "cc_jointTexture", "defines": ["CC_USE_SKINNING", "CC_USE_BAKED_ANIMATION"] }], "buffers": [], "images": [] } + }, + "defines": [ + { "name": "CC_USE_MORPH", "type": "boolean" }, + { "name": "CC_MORPH_TARGET_COUNT", "type": "number", "range": [2, 8] }, + { "name": "CC_MORPH_PRECOMPUTED", "type": "boolean" }, + { "name": "CC_MORPH_TARGET_HAS_POSITION", "type": "boolean" }, + { "name": "CC_MORPH_TARGET_HAS_NORMAL", "type": "boolean" }, + { "name": "CC_MORPH_TARGET_HAS_TANGENT", "type": "boolean" }, + { "name": "CC_USE_SKINNING", "type": "boolean" }, + { "name": "CC_USE_BAKED_ANIMATION", "type": "boolean" }, + { "name": "USE_INSTANCING", "type": "boolean" }, + { "name": "USE_BATCHING", "type": "boolean" }, + { "name": "USE_LIGHTMAP", "type": "boolean" }, + { "name": "HAS_SECOND_UV", "type": "boolean" }, + { "name": "CC_RECEIVE_SHADOW", "type": "boolean" }, + { "name": "USE_ALBEDO_MAP", "type": "boolean" }, + { "name": "ALBEDO_UV", "type": "string", "options": ["v_uv", "v_uv1"] }, + { "name": "USE_ALPHA_TEST", "type": "boolean" }, + { "name": "ALPHA_TEST_CHANNEL", "type": "string", "options": ["a", "r"] } + ], + "attributes": [ + { "name": "a_position", "defines": [], "format": 32, "location": 0 }, + { "name": "a_normal", "defines": [], "format": 32, "location": 1 }, + { "name": "a_texCoord", "defines": [], "format": 21, "location": 2 }, + { "name": "a_tangent", "defines": [], "format": 44, "location": 3 }, + { "name": "a_vertexId", "defines": ["CC_USE_MORPH"], "format": 11, "location": 6 }, + { "name": "a_joints", "defines": ["CC_USE_SKINNING"], "location": 4 }, + { "name": "a_weights", "defines": ["CC_USE_SKINNING"], "format": 44, "location": 5 }, + { "name": "a_jointAnimInfo", "defines": ["CC_USE_SKINNING", "CC_USE_BAKED_ANIMATION", "USE_INSTANCING"], "format": 44, "isInstanced": true, "location": 7 }, + { "name": "a_matWorld0", "defines": ["USE_INSTANCING"], "format": 44, "isInstanced": true, "location": 8 }, + { "name": "a_matWorld1", "defines": ["USE_INSTANCING"], "format": 44, "isInstanced": true, "location": 9 }, + { "name": "a_matWorld2", "defines": ["USE_INSTANCING"], "format": 44, "isInstanced": true, "location": 10 }, + { "name": "a_lightingMapUVParam", "defines": ["USE_INSTANCING", "USE_LIGHTMAP"], "format": 44, "isInstanced": true, "location": 11 }, + { "name": "a_dyn_batch_id", "defines": ["!USE_INSTANCING", "USE_BATCHING"], "format": 11, "location": 12 }, + { "name": "a_texCoord1", "defines": [], "format": 21, "location": 13 } + ], + "blocks": [ + {"name": "Constants", "defines": [], "binding": 0, "stageFlags": 17, "members": [ + { "name": "tilingOffset", "type": 16, "count": 1 }, + { "name": "albedo", "type": 16, "count": 1 }, + { "name": "albedoScaleAndCutoff", "type": 16, "count": 1 }, + { "name": "pbrParams", "type": 16, "count": 1 }, + { "name": "emissive", "type": 16, "count": 1 }, + { "name": "emissiveScaleParam", "type": 16, "count": 1 } + ]} + ], + "samplerTextures": [ + { "name": "albedoMap", "type": 28, "count": 1, "defines": ["USE_ALBEDO_MAP"], "stageFlags": 16, "binding": 1 } + ], + "buffers": [], + "images": [], + "textures": [], + "samplers": [], + "subpassInputs": [] + } + ] + }, + { + "name": "terrain", + "techniques": [ + { "name": "opaque", "passes": [{ "program": "terrain|terrain-vs|terrain-fs", "properties": { "UVScale": { "value": [1, 1, 1, 1], "type": 16 }, "lightMapUVParam": { "value": [0, 0, 0, 0], "type": 16 }, "metallic": { "value": [0, 0, 0, 0], "type": 16 }, "roughness": { "value": [1, 1, 1, 1], "type": 16 }, "weightMap": { "value": "black", "type": 28 }, "detailMap0": { "value": "grey", "type": 28 }, "detailMap1": { "value": "grey", "type": 28 }, "detailMap2": { "value": "grey", "type": 28 }, "detailMap3": { "value": "grey", "type": 28 }, "normalMap0": { "value": "normal", "type": 28 }, "normalMap1": { "value": "normal", "type": 28 }, "normalMap2": { "value": "normal", "type": 28 }, "normalMap3": { "value": "normal", "type": 28 }, "lightMap": { "value": "grey", "type": 28 } } }, { "phase": "forward-add", "propertyIndex": 0, "embeddedMacros": { "CC_FORWARD_ADD": true }, "blendState": { "targets": [{ "blend": true, "blendSrc": 1, "blendDst": 1, "blendSrcAlpha": 0, "blendDstAlpha": 1 }] }, "program": "terrain|terrain-vs|terrain-fs", "depthStencilState": { "depthFunc": 2, "depthTest": true, "depthWrite": false }, "properties": { "UVScale": { "value": [1, 1, 1, 1], "type": 16 }, "lightMapUVParam": { "value": [0, 0, 0, 0], "type": 16 }, "metallic": { "value": [0, 0, 0, 0], "type": 16 }, "roughness": { "value": [1, 1, 1, 1], "type": 16 }, "weightMap": { "value": "black", "type": 28 }, "detailMap0": { "value": "grey", "type": 28 }, "detailMap1": { "value": "grey", "type": 28 }, "detailMap2": { "value": "grey", "type": 28 }, "detailMap3": { "value": "grey", "type": 28 }, "normalMap0": { "value": "normal", "type": 28 }, "normalMap1": { "value": "normal", "type": 28 }, "normalMap2": { "value": "normal", "type": 28 }, "normalMap3": { "value": "normal", "type": 28 }, "lightMap": { "value": "grey", "type": 28 } } }, { "phase": "shadow-add", "propertyIndex": 0, "rasterizerState": { "cullMode": 2 }, "program": "terrain|shadow-caster-vs:vert|shadow-caster-fs:frag" }] } + ], + "shaders": [ + { + "name": "terrain|terrain-vs|terrain-fs", + "hash": 1017881636, + "builtins": { + "statistics": { "CC_EFFECT_USED_VERTEX_UNIFORM_VECTORS": 69, "CC_EFFECT_USED_FRAGMENT_UNIFORM_VECTORS": 60 }, + "globals": { "blocks": [{ "name": "CCGlobal", "defines": [] }, { "name": "CCCamera", "defines": [] }, { "name": "CCShadow", "defines": [] }], "samplerTextures": [{ "name": "cc_shadowMap", "defines": ["CC_RECEIVE_SHADOW"] }, { "name": "cc_spotLightingMap", "defines": ["CC_RECEIVE_SHADOW"] }, { "name": "cc_environment", "defines": ["CC_USE_IBL"] }, { "name": "cc_diffuseMap", "defines": ["CC_USE_IBL", "CC_USE_DIFFUSEMAP"] }], "buffers": [], "images": [] }, + "locals": { "blocks": [{ "name": "CCLocal", "defines": [] }, { "name": "CCForwardLight", "defines": ["CC_FORWARD_ADD", "CC_ENABLE_CLUSTERED_LIGHT_CULLING"] }], "samplerTextures": [{ "name": "cc_lightingMap", "defines": ["USE_LIGHTMAP", "!USE_BATCHING", "!CC_FORWARD_ADD"] }], "buffers": [], "images": [] } + }, + "defines": [ + { "name": "CC_USE_FOG", "type": "number", "range": [0, 4] }, + { "name": "CC_USE_ACCURATE_FOG", "type": "boolean" }, + { "name": "CC_RECEIVE_SHADOW", "type": "boolean" }, + { "name": "USE_NORMALMAP", "type": "boolean" }, + { "name": "USE_LIGHTMAP", "type": "boolean" }, + { "name": "CC_USE_IBL", "type": "number", "range": [0, 2] }, + { "name": "CC_USE_DIFFUSEMAP", "type": "number", "range": [0, 2] }, + { "name": "USE_REFLECTION_DENOISE", "type": "boolean" }, + { "name": "USE_BATCHING", "type": "boolean" }, + { "name": "CC_FORWARD_ADD", "type": "boolean" }, + { "name": "CC_ENABLE_DIR_SHADOW", "type": "boolean" }, + { "name": "CC_USE_HDR", "type": "boolean" }, + { "name": "LAYERS", "type": "number", "range": [0, 4] }, + { "name": "USE_PBR", "type": "boolean" }, + { "name": "CC_PIPELINE_TYPE", "type": "number", "range": [0, 1] }, + { "name": "CC_FORCE_FORWARD_SHADING", "type": "boolean" } + ], + "attributes": [ + { "name": "a_position", "defines": [], "format": 32, "location": 0 }, + { "name": "a_normal", "defines": [], "format": 32, "location": 1 }, + { "name": "a_texCoord", "defines": [], "format": 21, "location": 2 } + ], + "blocks": [ + {"name": "TexCoords", "defines": [], "binding": 0, "stageFlags": 1, "members": [ + { "name": "UVScale", "type": 16, "count": 1 }, + { "name": "lightMapUVParam", "type": 16, "count": 1 } + ]}, + {"name": "PbrParams", "defines": [], "binding": 1, "stageFlags": 16, "members": [ + { "name": "metallic", "type": 16, "count": 1 }, + { "name": "roughness", "type": 16, "count": 1 } + ]} + ], + "samplerTextures": [ + { "name": "weightMap", "type": 28, "count": 1, "defines": [], "stageFlags": 16, "binding": 2 }, + { "name": "detailMap0", "type": 28, "count": 1, "defines": [], "stageFlags": 16, "binding": 3 }, + { "name": "detailMap1", "type": 28, "count": 1, "defines": [], "stageFlags": 16, "binding": 4 }, + { "name": "detailMap2", "type": 28, "count": 1, "defines": [], "stageFlags": 16, "binding": 5 }, + { "name": "detailMap3", "type": 28, "count": 1, "defines": [], "stageFlags": 16, "binding": 6 }, + { "name": "normalMap0", "type": 28, "count": 1, "defines": [], "stageFlags": 16, "binding": 7 }, + { "name": "normalMap1", "type": 28, "count": 1, "defines": [], "stageFlags": 16, "binding": 8 }, + { "name": "normalMap2", "type": 28, "count": 1, "defines": [], "stageFlags": 16, "binding": 9 }, + { "name": "normalMap3", "type": 28, "count": 1, "defines": [], "stageFlags": 16, "binding": 10 }, + { "name": "lightMap", "type": 28, "count": 1, "defines": [], "stageFlags": 16, "binding": 11 } + ], + "buffers": [ + { "name": "b_ccLightsBuffer", "memoryAccess": 1, "defines": ["CC_FORWARD_ADD", "CC_ENABLE_CLUSTERED_LIGHT_CULLING"], "stageFlags": 16, "binding": 12 }, + { "name": "b_clusterLightIndicesBuffer", "memoryAccess": 1, "defines": ["CC_FORWARD_ADD", "CC_ENABLE_CLUSTERED_LIGHT_CULLING"], "stageFlags": 16, "binding": 13 }, + { "name": "b_clusterLightGridBuffer", "memoryAccess": 1, "defines": ["CC_FORWARD_ADD", "CC_ENABLE_CLUSTERED_LIGHT_CULLING"], "stageFlags": 16, "binding": 14 } + ], + "images": [], + "textures": [], + "samplers": [], + "subpassInputs": [] + }, + { + "name": "terrain|shadow-caster-vs:vert|shadow-caster-fs:frag", + "hash": 809389262, + "builtins": { + "statistics": { "CC_EFFECT_USED_VERTEX_UNIFORM_VECTORS": 67, "CC_EFFECT_USED_FRAGMENT_UNIFORM_VECTORS": 0 }, + "globals": { "blocks": [{ "name": "CCGlobal", "defines": [] }, { "name": "CCCamera", "defines": [] }, { "name": "CCShadow", "defines": [] }], "samplerTextures": [], "buffers": [], "images": [] }, + "locals": { "blocks": [{ "name": "CCLocal", "defines": [] }], "samplerTextures": [], "buffers": [], "images": [] } + }, + "defines": [], + "attributes": [ + { "name": "a_position", "defines": [], "format": 32, "location": 0 }, + { "name": "a_normal", "defines": [], "format": 32, "location": 1 }, + { "name": "a_texCoord", "defines": [], "format": 21, "location": 2 } + ], + "blocks": [], + "samplerTextures": [], + "buffers": [], + "images": [], + "textures": [], + "samplers": [], + "subpassInputs": [] + } + ] + }, + { + "name": "unlit", + "techniques": [ + { "name": "opaque", "passes": [{ "program": "unlit|unlit-vs:vert|unlit-fs:frag", "properties": { "mainTexture": { "value": "grey", "type": 28 }, "tilingOffset": { "value": [1, 1, 0, 0], "type": 16 }, "mainColor": { "value": [1, 1, 1, 1], "linear": true, "type": 16 }, "colorScale": { "value": [1, 1, 1], "type": 15, "handleInfo": ["colorScaleAndCutoff", 0, 15] }, "alphaThreshold": { "value": [0.5], "type": 13, "handleInfo": ["colorScaleAndCutoff", 3, 13] }, "color": { "linear": true, "type": 16, "handleInfo": ["mainColor", 0, 16] }, "colorScaleAndCutoff": { "type": 16, "value": [1, 1, 1, 0.5] } } }] } + ], + "shaders": [ + { + "name": "unlit|unlit-vs:vert|unlit-fs:frag", + "hash": 3319190198, + "builtins": { + "statistics": { "CC_EFFECT_USED_VERTEX_UNIFORM_VECTORS": 197, "CC_EFFECT_USED_FRAGMENT_UNIFORM_VECTORS": 41 }, + "globals": { "blocks": [{ "name": "CCGlobal", "defines": [] }, { "name": "CCCamera", "defines": [] }], "samplerTextures": [], "buffers": [], "images": [] }, + "locals": { "blocks": [{ "name": "CCMorph", "defines": ["CC_USE_MORPH"] }, { "name": "CCSkinningTexture", "defines": ["CC_USE_SKINNING", "CC_USE_BAKED_ANIMATION"] }, { "name": "CCSkinningAnimation", "defines": ["CC_USE_SKINNING", "CC_USE_BAKED_ANIMATION"] }, { "name": "CCSkinning", "defines": ["CC_USE_SKINNING", "!CC_USE_BAKED_ANIMATION"] }, { "name": "CCLocalBatched", "defines": ["!USE_INSTANCING", "USE_BATCHING"] }, { "name": "CCLocal", "defines": ["!USE_INSTANCING", "!USE_BATCHING"] }], "samplerTextures": [{ "name": "cc_PositionDisplacements", "defines": ["CC_USE_MORPH", "CC_MORPH_TARGET_HAS_POSITION"] }, { "name": "cc_NormalDisplacements", "defines": ["CC_USE_MORPH", "CC_MORPH_TARGET_HAS_NORMAL"] }, { "name": "cc_TangentDisplacements", "defines": ["CC_USE_MORPH", "CC_MORPH_TARGET_HAS_TANGENT"] }, { "name": "cc_jointTexture", "defines": ["CC_USE_SKINNING", "CC_USE_BAKED_ANIMATION"] }], "buffers": [], "images": [] } + }, + "defines": [ + { "name": "CC_USE_MORPH", "type": "boolean" }, + { "name": "CC_MORPH_TARGET_COUNT", "type": "number", "range": [2, 8] }, + { "name": "CC_MORPH_PRECOMPUTED", "type": "boolean" }, + { "name": "CC_MORPH_TARGET_HAS_POSITION", "type": "boolean" }, + { "name": "CC_MORPH_TARGET_HAS_NORMAL", "type": "boolean" }, + { "name": "CC_MORPH_TARGET_HAS_TANGENT", "type": "boolean" }, + { "name": "CC_USE_SKINNING", "type": "boolean" }, + { "name": "CC_USE_BAKED_ANIMATION", "type": "boolean" }, + { "name": "USE_INSTANCING", "type": "boolean" }, + { "name": "USE_BATCHING", "type": "boolean" }, + { "name": "USE_LIGHTMAP", "type": "boolean" }, + { "name": "CC_USE_FOG", "type": "number", "range": [0, 4] }, + { "name": "CC_USE_ACCURATE_FOG", "type": "boolean" }, + { "name": "USE_VERTEX_COLOR", "type": "boolean" }, + { "name": "USE_TEXTURE", "type": "boolean" }, + { "name": "SAMPLE_FROM_RT", "type": "boolean" }, + { "name": "CC_USE_HDR", "type": "boolean" }, + { "name": "USE_ALPHA_TEST", "type": "boolean" }, + { "name": "ALPHA_TEST_CHANNEL", "type": "string", "options": ["a", "r", "g", "b"] } + ], + "attributes": [ + { "name": "a_position", "defines": [], "format": 32, "location": 0 }, + { "name": "a_normal", "defines": [], "format": 32, "location": 1 }, + { "name": "a_texCoord", "defines": [], "format": 21, "location": 2 }, + { "name": "a_tangent", "defines": [], "format": 44, "location": 3 }, + { "name": "a_vertexId", "defines": ["CC_USE_MORPH"], "format": 11, "location": 6 }, + { "name": "a_joints", "defines": ["CC_USE_SKINNING"], "location": 4 }, + { "name": "a_weights", "defines": ["CC_USE_SKINNING"], "format": 44, "location": 5 }, + { "name": "a_jointAnimInfo", "defines": ["CC_USE_SKINNING", "CC_USE_BAKED_ANIMATION", "USE_INSTANCING"], "format": 44, "isInstanced": true, "location": 7 }, + { "name": "a_matWorld0", "defines": ["USE_INSTANCING"], "format": 44, "isInstanced": true, "location": 8 }, + { "name": "a_matWorld1", "defines": ["USE_INSTANCING"], "format": 44, "isInstanced": true, "location": 9 }, + { "name": "a_matWorld2", "defines": ["USE_INSTANCING"], "format": 44, "isInstanced": true, "location": 10 }, + { "name": "a_lightingMapUVParam", "defines": ["USE_INSTANCING", "USE_LIGHTMAP"], "format": 44, "isInstanced": true, "location": 11 }, + { "name": "a_dyn_batch_id", "defines": ["!USE_INSTANCING", "USE_BATCHING"], "format": 11, "location": 12 }, + { "name": "a_color", "defines": ["USE_VERTEX_COLOR"], "format": 44, "location": 13 } + ], + "blocks": [ + {"name": "TexCoords", "defines": ["USE_TEXTURE"], "binding": 0, "stageFlags": 1, "members": [ + { "name": "tilingOffset", "type": 16, "count": 1 } + ]}, + {"name": "Constant", "defines": [], "binding": 1, "stageFlags": 16, "members": [ + { "name": "mainColor", "type": 16, "count": 1 }, + { "name": "colorScaleAndCutoff", "type": 16, "count": 1 } + ]} + ], + "samplerTextures": [ + { "name": "mainTexture", "type": 28, "count": 1, "defines": ["USE_TEXTURE"], "stageFlags": 16, "binding": 2 } + ], + "buffers": [], + "images": [], + "textures": [], + "samplers": [], + "subpassInputs": [] + } + ] + }, + { + "name": "bloom", + "techniques": [ + { "passes": [{ "phase": "bloom-prefilter", "program": "bloom|bloom-vs|prefilter-fs", "depthStencilState": { "depthTest": false, "depthWrite": false } }, { "phase": "bloom-downsample", "program": "bloom|bloom-vs|downsample-fs", "depthStencilState": { "depthTest": false, "depthWrite": false } }, { "phase": "bloom-downsample", "program": "bloom|bloom-vs|downsample-fs", "depthStencilState": { "depthTest": false, "depthWrite": false } }, { "phase": "bloom-downsample", "program": "bloom|bloom-vs|downsample-fs", "depthStencilState": { "depthTest": false, "depthWrite": false } }, { "phase": "bloom-downsample", "program": "bloom|bloom-vs|downsample-fs", "depthStencilState": { "depthTest": false, "depthWrite": false } }, { "phase": "bloom-downsample", "program": "bloom|bloom-vs|downsample-fs", "depthStencilState": { "depthTest": false, "depthWrite": false } }, { "phase": "bloom-downsample", "program": "bloom|bloom-vs|downsample-fs", "depthStencilState": { "depthTest": false, "depthWrite": false } }, { "phase": "bloom-upsample", "program": "bloom|bloom-vs|upsample-fs", "depthStencilState": { "depthTest": false, "depthWrite": false } }, { "phase": "bloom-upsample", "program": "bloom|bloom-vs|upsample-fs", "depthStencilState": { "depthTest": false, "depthWrite": false } }, { "phase": "bloom-upsample", "program": "bloom|bloom-vs|upsample-fs", "depthStencilState": { "depthTest": false, "depthWrite": false } }, { "phase": "bloom-upsample", "program": "bloom|bloom-vs|upsample-fs", "depthStencilState": { "depthTest": false, "depthWrite": false } }, { "phase": "bloom-upsample", "program": "bloom|bloom-vs|upsample-fs", "depthStencilState": { "depthTest": false, "depthWrite": false } }, { "phase": "bloom-upsample", "program": "bloom|bloom-vs|upsample-fs", "depthStencilState": { "depthTest": false, "depthWrite": false } }, { "phase": "bloom-combine", "program": "bloom|bloom-vs|combine-fs", "depthStencilState": { "depthTest": false, "depthWrite": false } }] } + ], + "shaders": [ + { + "name": "bloom|bloom-vs|prefilter-fs", + "hash": 2185821616, + "builtins": { + "statistics": { "CC_EFFECT_USED_VERTEX_UNIFORM_VECTORS": 147, "CC_EFFECT_USED_FRAGMENT_UNIFORM_VECTORS": 40 }, + "globals": { "blocks": [{ "name": "CCGlobal", "defines": [] }, { "name": "CCCamera", "defines": [] }], "samplerTextures": [], "buffers": [], "images": [] }, + "locals": { "blocks": [{ "name": "CCMorph", "defines": ["CC_USE_MORPH"] }, { "name": "CCSkinningTexture", "defines": ["CC_USE_SKINNING", "CC_USE_BAKED_ANIMATION"] }, { "name": "CCSkinningAnimation", "defines": ["CC_USE_SKINNING", "CC_USE_BAKED_ANIMATION"] }, { "name": "CCSkinning", "defines": ["CC_USE_SKINNING", "!CC_USE_BAKED_ANIMATION"] }], "samplerTextures": [{ "name": "cc_PositionDisplacements", "defines": ["CC_USE_MORPH", "CC_MORPH_TARGET_HAS_POSITION"] }, { "name": "cc_NormalDisplacements", "defines": ["CC_USE_MORPH", "CC_MORPH_TARGET_HAS_NORMAL"] }, { "name": "cc_TangentDisplacements", "defines": ["CC_USE_MORPH", "CC_MORPH_TARGET_HAS_TANGENT"] }, { "name": "cc_jointTexture", "defines": ["CC_USE_SKINNING", "CC_USE_BAKED_ANIMATION"] }], "buffers": [], "images": [] } + }, + "defines": [ + { "name": "CC_USE_MORPH", "type": "boolean" }, + { "name": "CC_MORPH_TARGET_COUNT", "type": "number", "range": [2, 8] }, + { "name": "CC_MORPH_PRECOMPUTED", "type": "boolean" }, + { "name": "CC_MORPH_TARGET_HAS_POSITION", "type": "boolean" }, + { "name": "CC_MORPH_TARGET_HAS_NORMAL", "type": "boolean" }, + { "name": "CC_MORPH_TARGET_HAS_TANGENT", "type": "boolean" }, + { "name": "CC_USE_SKINNING", "type": "boolean" }, + { "name": "CC_USE_BAKED_ANIMATION", "type": "boolean" }, + { "name": "USE_INSTANCING", "type": "boolean" } + ], + "attributes": [ + { "name": "a_position", "defines": [], "format": 32, "location": 0 }, + { "name": "a_normal", "defines": [], "format": 32, "location": 1 }, + { "name": "a_texCoord", "defines": [], "format": 21, "location": 2 }, + { "name": "a_tangent", "defines": [], "format": 44, "location": 3 }, + { "name": "a_vertexId", "defines": ["CC_USE_MORPH"], "format": 11, "location": 6 }, + { "name": "a_joints", "defines": ["CC_USE_SKINNING"], "location": 4 }, + { "name": "a_weights", "defines": ["CC_USE_SKINNING"], "format": 44, "location": 5 }, + { "name": "a_jointAnimInfo", "defines": ["CC_USE_SKINNING", "CC_USE_BAKED_ANIMATION", "USE_INSTANCING"], "format": 44, "isInstanced": true, "location": 7 } + ], + "blocks": [ + {"name": "BloomUBO", "defines": [], "binding": 0, "stageFlags": 16, "members": [ + { "name": "texSize", "type": 16, "count": 1 } + ]} + ], + "samplerTextures": [ + { "name": "outputResultMap", "type": 28, "count": 1, "defines": [], "stageFlags": 16, "binding": 1 } + ], + "buffers": [], + "images": [], + "textures": [], + "samplers": [], + "subpassInputs": [] + }, + { + "name": "bloom|bloom-vs|downsample-fs", + "hash": 1780231359, + "builtins": { + "statistics": { "CC_EFFECT_USED_VERTEX_UNIFORM_VECTORS": 147, "CC_EFFECT_USED_FRAGMENT_UNIFORM_VECTORS": 40 }, + "globals": { "blocks": [{ "name": "CCGlobal", "defines": [] }, { "name": "CCCamera", "defines": [] }], "samplerTextures": [], "buffers": [], "images": [] }, + "locals": { "blocks": [{ "name": "CCMorph", "defines": ["CC_USE_MORPH"] }, { "name": "CCSkinningTexture", "defines": ["CC_USE_SKINNING", "CC_USE_BAKED_ANIMATION"] }, { "name": "CCSkinningAnimation", "defines": ["CC_USE_SKINNING", "CC_USE_BAKED_ANIMATION"] }, { "name": "CCSkinning", "defines": ["CC_USE_SKINNING", "!CC_USE_BAKED_ANIMATION"] }], "samplerTextures": [{ "name": "cc_PositionDisplacements", "defines": ["CC_USE_MORPH", "CC_MORPH_TARGET_HAS_POSITION"] }, { "name": "cc_NormalDisplacements", "defines": ["CC_USE_MORPH", "CC_MORPH_TARGET_HAS_NORMAL"] }, { "name": "cc_TangentDisplacements", "defines": ["CC_USE_MORPH", "CC_MORPH_TARGET_HAS_TANGENT"] }, { "name": "cc_jointTexture", "defines": ["CC_USE_SKINNING", "CC_USE_BAKED_ANIMATION"] }], "buffers": [], "images": [] } + }, + "defines": [ + { "name": "CC_USE_MORPH", "type": "boolean" }, + { "name": "CC_MORPH_TARGET_COUNT", "type": "number", "range": [2, 8] }, + { "name": "CC_MORPH_PRECOMPUTED", "type": "boolean" }, + { "name": "CC_MORPH_TARGET_HAS_POSITION", "type": "boolean" }, + { "name": "CC_MORPH_TARGET_HAS_NORMAL", "type": "boolean" }, + { "name": "CC_MORPH_TARGET_HAS_TANGENT", "type": "boolean" }, + { "name": "CC_USE_SKINNING", "type": "boolean" }, + { "name": "CC_USE_BAKED_ANIMATION", "type": "boolean" }, + { "name": "USE_INSTANCING", "type": "boolean" } + ], + "attributes": [ + { "name": "a_position", "defines": [], "format": 32, "location": 0 }, + { "name": "a_normal", "defines": [], "format": 32, "location": 1 }, + { "name": "a_texCoord", "defines": [], "format": 21, "location": 2 }, + { "name": "a_tangent", "defines": [], "format": 44, "location": 3 }, + { "name": "a_vertexId", "defines": ["CC_USE_MORPH"], "format": 11, "location": 6 }, + { "name": "a_joints", "defines": ["CC_USE_SKINNING"], "location": 4 }, + { "name": "a_weights", "defines": ["CC_USE_SKINNING"], "format": 44, "location": 5 }, + { "name": "a_jointAnimInfo", "defines": ["CC_USE_SKINNING", "CC_USE_BAKED_ANIMATION", "USE_INSTANCING"], "format": 44, "isInstanced": true, "location": 7 } + ], + "blocks": [ + {"name": "BloomUBO", "defines": [], "binding": 0, "stageFlags": 16, "members": [ + { "name": "texSize", "type": 16, "count": 1 } + ]} + ], + "samplerTextures": [ + { "name": "bloomTexture", "type": 28, "count": 1, "defines": [], "stageFlags": 16, "binding": 1 } + ], + "buffers": [], + "images": [], + "textures": [], + "samplers": [], + "subpassInputs": [] + }, + { + "name": "bloom|bloom-vs|upsample-fs", + "hash": 3580425335, + "builtins": { + "statistics": { "CC_EFFECT_USED_VERTEX_UNIFORM_VECTORS": 147, "CC_EFFECT_USED_FRAGMENT_UNIFORM_VECTORS": 40 }, + "globals": { "blocks": [{ "name": "CCGlobal", "defines": [] }, { "name": "CCCamera", "defines": [] }], "samplerTextures": [], "buffers": [], "images": [] }, + "locals": { "blocks": [{ "name": "CCMorph", "defines": ["CC_USE_MORPH"] }, { "name": "CCSkinningTexture", "defines": ["CC_USE_SKINNING", "CC_USE_BAKED_ANIMATION"] }, { "name": "CCSkinningAnimation", "defines": ["CC_USE_SKINNING", "CC_USE_BAKED_ANIMATION"] }, { "name": "CCSkinning", "defines": ["CC_USE_SKINNING", "!CC_USE_BAKED_ANIMATION"] }], "samplerTextures": [{ "name": "cc_PositionDisplacements", "defines": ["CC_USE_MORPH", "CC_MORPH_TARGET_HAS_POSITION"] }, { "name": "cc_NormalDisplacements", "defines": ["CC_USE_MORPH", "CC_MORPH_TARGET_HAS_NORMAL"] }, { "name": "cc_TangentDisplacements", "defines": ["CC_USE_MORPH", "CC_MORPH_TARGET_HAS_TANGENT"] }, { "name": "cc_jointTexture", "defines": ["CC_USE_SKINNING", "CC_USE_BAKED_ANIMATION"] }], "buffers": [], "images": [] } + }, + "defines": [ + { "name": "CC_USE_MORPH", "type": "boolean" }, + { "name": "CC_MORPH_TARGET_COUNT", "type": "number", "range": [2, 8] }, + { "name": "CC_MORPH_PRECOMPUTED", "type": "boolean" }, + { "name": "CC_MORPH_TARGET_HAS_POSITION", "type": "boolean" }, + { "name": "CC_MORPH_TARGET_HAS_NORMAL", "type": "boolean" }, + { "name": "CC_MORPH_TARGET_HAS_TANGENT", "type": "boolean" }, + { "name": "CC_USE_SKINNING", "type": "boolean" }, + { "name": "CC_USE_BAKED_ANIMATION", "type": "boolean" }, + { "name": "USE_INSTANCING", "type": "boolean" } + ], + "attributes": [ + { "name": "a_position", "defines": [], "format": 32, "location": 0 }, + { "name": "a_normal", "defines": [], "format": 32, "location": 1 }, + { "name": "a_texCoord", "defines": [], "format": 21, "location": 2 }, + { "name": "a_tangent", "defines": [], "format": 44, "location": 3 }, + { "name": "a_vertexId", "defines": ["CC_USE_MORPH"], "format": 11, "location": 6 }, + { "name": "a_joints", "defines": ["CC_USE_SKINNING"], "location": 4 }, + { "name": "a_weights", "defines": ["CC_USE_SKINNING"], "format": 44, "location": 5 }, + { "name": "a_jointAnimInfo", "defines": ["CC_USE_SKINNING", "CC_USE_BAKED_ANIMATION", "USE_INSTANCING"], "format": 44, "isInstanced": true, "location": 7 } + ], + "blocks": [ + {"name": "BloomUBO", "defines": [], "binding": 0, "stageFlags": 16, "members": [ + { "name": "texSize", "type": 16, "count": 1 } + ]} + ], + "samplerTextures": [ + { "name": "bloomTexture", "type": 28, "count": 1, "defines": [], "stageFlags": 16, "binding": 1 } + ], + "buffers": [], + "images": [], + "textures": [], + "samplers": [], + "subpassInputs": [] + }, + { + "name": "bloom|bloom-vs|combine-fs", + "hash": 3457196798, + "builtins": { + "statistics": { "CC_EFFECT_USED_VERTEX_UNIFORM_VECTORS": 147, "CC_EFFECT_USED_FRAGMENT_UNIFORM_VECTORS": 40 }, + "globals": { "blocks": [{ "name": "CCGlobal", "defines": [] }, { "name": "CCCamera", "defines": [] }], "samplerTextures": [], "buffers": [], "images": [] }, + "locals": { "blocks": [{ "name": "CCMorph", "defines": ["CC_USE_MORPH"] }, { "name": "CCSkinningTexture", "defines": ["CC_USE_SKINNING", "CC_USE_BAKED_ANIMATION"] }, { "name": "CCSkinningAnimation", "defines": ["CC_USE_SKINNING", "CC_USE_BAKED_ANIMATION"] }, { "name": "CCSkinning", "defines": ["CC_USE_SKINNING", "!CC_USE_BAKED_ANIMATION"] }], "samplerTextures": [{ "name": "cc_PositionDisplacements", "defines": ["CC_USE_MORPH", "CC_MORPH_TARGET_HAS_POSITION"] }, { "name": "cc_NormalDisplacements", "defines": ["CC_USE_MORPH", "CC_MORPH_TARGET_HAS_NORMAL"] }, { "name": "cc_TangentDisplacements", "defines": ["CC_USE_MORPH", "CC_MORPH_TARGET_HAS_TANGENT"] }, { "name": "cc_jointTexture", "defines": ["CC_USE_SKINNING", "CC_USE_BAKED_ANIMATION"] }], "buffers": [], "images": [] } + }, + "defines": [ + { "name": "CC_USE_MORPH", "type": "boolean" }, + { "name": "CC_MORPH_TARGET_COUNT", "type": "number", "range": [2, 8] }, + { "name": "CC_MORPH_PRECOMPUTED", "type": "boolean" }, + { "name": "CC_MORPH_TARGET_HAS_POSITION", "type": "boolean" }, + { "name": "CC_MORPH_TARGET_HAS_NORMAL", "type": "boolean" }, + { "name": "CC_MORPH_TARGET_HAS_TANGENT", "type": "boolean" }, + { "name": "CC_USE_SKINNING", "type": "boolean" }, + { "name": "CC_USE_BAKED_ANIMATION", "type": "boolean" }, + { "name": "USE_INSTANCING", "type": "boolean" } + ], + "attributes": [ + { "name": "a_position", "defines": [], "format": 32, "location": 0 }, + { "name": "a_normal", "defines": [], "format": 32, "location": 1 }, + { "name": "a_texCoord", "defines": [], "format": 21, "location": 2 }, + { "name": "a_tangent", "defines": [], "format": 44, "location": 3 }, + { "name": "a_vertexId", "defines": ["CC_USE_MORPH"], "format": 11, "location": 6 }, + { "name": "a_joints", "defines": ["CC_USE_SKINNING"], "location": 4 }, + { "name": "a_weights", "defines": ["CC_USE_SKINNING"], "format": 44, "location": 5 }, + { "name": "a_jointAnimInfo", "defines": ["CC_USE_SKINNING", "CC_USE_BAKED_ANIMATION", "USE_INSTANCING"], "format": 44, "isInstanced": true, "location": 7 } + ], + "blocks": [ + {"name": "BloomUBO", "defines": [], "binding": 0, "stageFlags": 16, "members": [ + { "name": "texSize", "type": 16, "count": 1 } + ]} + ], + "samplerTextures": [ + { "name": "outputResultMap", "type": 28, "count": 1, "defines": [], "stageFlags": 16, "binding": 1 }, + { "name": "bloomTexture", "type": 28, "count": 1, "defines": [], "stageFlags": 16, "binding": 2 } + ], + "buffers": [], + "images": [], + "textures": [], + "samplers": [], + "subpassInputs": [] + } + ] + }, + { + "name": "deferred-lighting", + "techniques": [ + { "passes": [{ "phase": "deferred-lighting", "program": "deferred-lighting|lighting-vs|lighting-fs", "depthStencilState": { "depthFunc": 4, "depthTest": true, "depthWrite": false } }] } + ], + "shaders": [ + { + "name": "deferred-lighting|lighting-vs|lighting-fs", + "hash": 3340914951, + "builtins": { + "statistics": { "CC_EFFECT_USED_VERTEX_UNIFORM_VECTORS": 39, "CC_EFFECT_USED_FRAGMENT_UNIFORM_VECTORS": 58 }, + "globals": { "blocks": [{ "name": "CCGlobal", "defines": [] }, { "name": "CCCamera", "defines": [] }, { "name": "CCShadow", "defines": [] }], "samplerTextures": [{ "name": "cc_shadowMap", "defines": ["CC_RECEIVE_SHADOW"] }, { "name": "cc_spotLightingMap", "defines": ["CC_RECEIVE_SHADOW"] }, { "name": "cc_environment", "defines": ["CC_USE_IBL"] }, { "name": "cc_diffuseMap", "defines": ["CC_USE_IBL", "CC_USE_DIFFUSEMAP"] }], "buffers": [], "images": [] }, + "locals": { "blocks": [{ "name": "CCForwardLight", "defines": ["CC_ENABLE_CLUSTERED_LIGHT_CULLING"] }], "samplerTextures": [], "buffers": [], "images": [] } + }, + "defines": [ + { "name": "CC_RECEIVE_SHADOW", "type": "boolean" }, + { "name": "CC_USE_IBL", "type": "number", "range": [0, 2] }, + { "name": "CC_USE_DIFFUSEMAP", "type": "number", "range": [0, 2] }, + { "name": "USE_REFLECTION_DENOISE", "type": "boolean" }, + { "name": "USE_LIGHTMAP", "type": "boolean" }, + { "name": "USE_BATCHING", "type": "boolean" }, + { "name": "CC_FORWARD_ADD", "type": "boolean" }, + { "name": "CC_ENABLE_DIR_SHADOW", "type": "boolean" }, + { "name": "CC_PIPELINE_TYPE", "type": "number", "range": [0, 1] }, + { "name": "CC_FORCE_FORWARD_SHADING", "type": "boolean" }, + { "name": "CC_USE_HDR", "type": "boolean" }, + { "name": "CC_USE_FOG", "type": "number", "range": [0, 4] } + ], + "attributes": [ + { "name": "a_position", "defines": [], "format": 32, "location": 0 }, + { "name": "a_normal", "defines": [], "format": 32, "location": 1 }, + { "name": "a_texCoord", "defines": [], "format": 21, "location": 2 }, + { "name": "a_tangent", "defines": [], "format": 44, "location": 3 } + ], + "blocks": [], + "samplerTextures": [], + "buffers": [ + { "name": "b_ccLightsBuffer", "memoryAccess": 1, "defines": ["CC_ENABLE_CLUSTERED_LIGHT_CULLING"], "stageFlags": 16, "binding": 4 }, + { "name": "b_clusterLightIndicesBuffer", "memoryAccess": 1, "defines": ["CC_ENABLE_CLUSTERED_LIGHT_CULLING"], "stageFlags": 16, "binding": 5 }, + { "name": "b_clusterLightGridBuffer", "memoryAccess": 1, "defines": ["CC_ENABLE_CLUSTERED_LIGHT_CULLING"], "stageFlags": 16, "binding": 6 } + ], + "images": [], + "textures": [], + "samplers": [], + "subpassInputs": [ + { "name": "gbuffer_albedoMap", "count": 1, "defines": ["CC_DEVICE_CAN_BENEFIT_FROM_INPUT_ATTACHMENT"], "stageFlags": 16, "binding": 0 }, + { "name": "gbuffer_positionMap", "count": 1, "defines": ["CC_DEVICE_CAN_BENEFIT_FROM_INPUT_ATTACHMENT"], "stageFlags": 16, "binding": 1 }, + { "name": "gbuffer_normalMap", "count": 1, "defines": ["CC_DEVICE_CAN_BENEFIT_FROM_INPUT_ATTACHMENT"], "stageFlags": 16, "binding": 2 }, + { "name": "gbuffer_emissiveMap", "count": 1, "defines": ["CC_DEVICE_CAN_BENEFIT_FROM_INPUT_ATTACHMENT"], "stageFlags": 16, "binding": 3 } + ] + } + ] + }, + { + "name": "planar-shadow", + "techniques": [ + { "passes": [{ "phase": "planarShadow", "blendState": { "targets": [{ "blend": true, "blendSrc": 2, "blendDst": 4, "blendDstAlpha": 4 }] }, "program": "planar-shadow|planar-shadow-vs:vert|planar-shadow-fs:frag", "depthStencilState": { "depthTest": true, "depthWrite": false, "stencilTestFront": true, "stencilFuncFront": 5, "stencilPassOpFront": 2, "stencilRefBack": 128, "stencilRefFront": 128, "stencilReadMaskBack": 128, "stencilReadMaskFront": 128, "stencilWriteMaskBack": 128, "stencilWriteMaskFront": 128 } }] } + ], + "shaders": [ + { + "name": "planar-shadow|planar-shadow-vs:vert|planar-shadow-fs:frag", + "hash": 2954155677, + "builtins": { + "statistics": { "CC_EFFECT_USED_VERTEX_UNIFORM_VECTORS": 215, "CC_EFFECT_USED_FRAGMENT_UNIFORM_VECTORS": 58 }, + "globals": { "blocks": [{ "name": "CCGlobal", "defines": [] }, { "name": "CCCamera", "defines": [] }, { "name": "CCShadow", "defines": [] }], "samplerTextures": [], "buffers": [], "images": [] }, + "locals": { "blocks": [{ "name": "CCMorph", "defines": ["CC_USE_MORPH"] }, { "name": "CCSkinningTexture", "defines": ["CC_USE_SKINNING", "CC_USE_BAKED_ANIMATION"] }, { "name": "CCSkinningAnimation", "defines": ["CC_USE_SKINNING", "CC_USE_BAKED_ANIMATION"] }, { "name": "CCSkinning", "defines": ["CC_USE_SKINNING", "!CC_USE_BAKED_ANIMATION"] }, { "name": "CCLocalBatched", "defines": ["!USE_INSTANCING", "USE_BATCHING"] }, { "name": "CCLocal", "defines": ["!USE_INSTANCING", "!USE_BATCHING"] }], "samplerTextures": [{ "name": "cc_PositionDisplacements", "defines": ["CC_USE_MORPH", "CC_MORPH_TARGET_HAS_POSITION"] }, { "name": "cc_NormalDisplacements", "defines": ["CC_USE_MORPH", "CC_MORPH_TARGET_HAS_NORMAL"] }, { "name": "cc_TangentDisplacements", "defines": ["CC_USE_MORPH", "CC_MORPH_TARGET_HAS_TANGENT"] }, { "name": "cc_jointTexture", "defines": ["CC_USE_SKINNING", "CC_USE_BAKED_ANIMATION"] }], "buffers": [], "images": [] } + }, + "defines": [ + { "name": "CC_USE_MORPH", "type": "boolean" }, + { "name": "CC_MORPH_TARGET_COUNT", "type": "number", "range": [2, 8] }, + { "name": "CC_MORPH_PRECOMPUTED", "type": "boolean" }, + { "name": "CC_MORPH_TARGET_HAS_POSITION", "type": "boolean" }, + { "name": "CC_MORPH_TARGET_HAS_NORMAL", "type": "boolean" }, + { "name": "CC_MORPH_TARGET_HAS_TANGENT", "type": "boolean" }, + { "name": "CC_USE_SKINNING", "type": "boolean" }, + { "name": "CC_USE_BAKED_ANIMATION", "type": "boolean" }, + { "name": "USE_INSTANCING", "type": "boolean" }, + { "name": "USE_BATCHING", "type": "boolean" }, + { "name": "USE_LIGHTMAP", "type": "boolean" } + ], + "attributes": [ + { "name": "a_position", "defines": [], "format": 32, "location": 0 }, + { "name": "a_normal", "defines": [], "format": 32, "location": 1 }, + { "name": "a_texCoord", "defines": [], "format": 21, "location": 2 }, + { "name": "a_tangent", "defines": [], "format": 44, "location": 3 }, + { "name": "a_vertexId", "defines": ["CC_USE_MORPH"], "format": 11, "location": 6 }, + { "name": "a_joints", "defines": ["CC_USE_SKINNING"], "location": 4 }, + { "name": "a_weights", "defines": ["CC_USE_SKINNING"], "format": 44, "location": 5 }, + { "name": "a_jointAnimInfo", "defines": ["CC_USE_SKINNING", "CC_USE_BAKED_ANIMATION", "USE_INSTANCING"], "format": 44, "isInstanced": true, "location": 7 }, + { "name": "a_matWorld0", "defines": ["USE_INSTANCING"], "format": 44, "isInstanced": true, "location": 8 }, + { "name": "a_matWorld1", "defines": ["USE_INSTANCING"], "format": 44, "isInstanced": true, "location": 9 }, + { "name": "a_matWorld2", "defines": ["USE_INSTANCING"], "format": 44, "isInstanced": true, "location": 10 }, + { "name": "a_lightingMapUVParam", "defines": ["USE_INSTANCING", "USE_LIGHTMAP"], "format": 44, "isInstanced": true, "location": 11 }, + { "name": "a_dyn_batch_id", "defines": ["!USE_INSTANCING", "USE_BATCHING"], "format": 11, "location": 12 } + ], + "blocks": [], + "samplerTextures": [], + "buffers": [], + "images": [], + "textures": [], + "samplers": [], + "subpassInputs": [] + } + ] + }, + { + "name": "post-process", + "techniques": [ + { "passes": [{ "phase": "post-process", "blendState": { "targets": [{ "blend": true, "blendSrc": 2, "blendDst": 4, "blendSrcAlpha": 2, "blendDstAlpha": 4 }] }, "program": "post-process|post-process-vs|post-process-fs", "depthStencilState": { "depthTest": false, "depthWrite": false } }] } + ], + "shaders": [ + { + "name": "post-process|post-process-vs|post-process-fs", + "hash": 3237848814, + "builtins": { + "statistics": { "CC_EFFECT_USED_VERTEX_UNIFORM_VECTORS": 147, "CC_EFFECT_USED_FRAGMENT_UNIFORM_VECTORS": 39 }, + "globals": { "blocks": [{ "name": "CCGlobal", "defines": [] }, { "name": "CCCamera", "defines": [] }], "samplerTextures": [], "buffers": [], "images": [] }, + "locals": { "blocks": [{ "name": "CCMorph", "defines": ["CC_USE_MORPH"] }, { "name": "CCSkinningTexture", "defines": ["CC_USE_SKINNING", "CC_USE_BAKED_ANIMATION"] }, { "name": "CCSkinningAnimation", "defines": ["CC_USE_SKINNING", "CC_USE_BAKED_ANIMATION"] }, { "name": "CCSkinning", "defines": ["CC_USE_SKINNING", "!CC_USE_BAKED_ANIMATION"] }], "samplerTextures": [{ "name": "cc_PositionDisplacements", "defines": ["CC_USE_MORPH", "CC_MORPH_TARGET_HAS_POSITION"] }, { "name": "cc_NormalDisplacements", "defines": ["CC_USE_MORPH", "CC_MORPH_TARGET_HAS_NORMAL"] }, { "name": "cc_TangentDisplacements", "defines": ["CC_USE_MORPH", "CC_MORPH_TARGET_HAS_TANGENT"] }, { "name": "cc_jointTexture", "defines": ["CC_USE_SKINNING", "CC_USE_BAKED_ANIMATION"] }], "buffers": [], "images": [] } + }, + "defines": [ + { "name": "CC_USE_MORPH", "type": "boolean" }, + { "name": "CC_MORPH_TARGET_COUNT", "type": "number", "range": [2, 8] }, + { "name": "CC_MORPH_PRECOMPUTED", "type": "boolean" }, + { "name": "CC_MORPH_TARGET_HAS_POSITION", "type": "boolean" }, + { "name": "CC_MORPH_TARGET_HAS_NORMAL", "type": "boolean" }, + { "name": "CC_MORPH_TARGET_HAS_TANGENT", "type": "boolean" }, + { "name": "CC_USE_SKINNING", "type": "boolean" }, + { "name": "CC_USE_BAKED_ANIMATION", "type": "boolean" }, + { "name": "USE_INSTANCING", "type": "boolean" }, + { "name": "ANTIALIAS_TYPE", "type": "number", "range": [0, 3] } + ], + "attributes": [ + { "name": "a_position", "defines": [], "format": 32, "location": 0 }, + { "name": "a_normal", "defines": [], "format": 32, "location": 1 }, + { "name": "a_texCoord", "defines": [], "format": 21, "location": 2 }, + { "name": "a_tangent", "defines": [], "format": 44, "location": 3 }, + { "name": "a_vertexId", "defines": ["CC_USE_MORPH"], "format": 11, "location": 6 }, + { "name": "a_joints", "defines": ["CC_USE_SKINNING"], "location": 4 }, + { "name": "a_weights", "defines": ["CC_USE_SKINNING"], "format": 44, "location": 5 }, + { "name": "a_jointAnimInfo", "defines": ["CC_USE_SKINNING", "CC_USE_BAKED_ANIMATION", "USE_INSTANCING"], "format": 44, "isInstanced": true, "location": 7 } + ], + "blocks": [], + "samplerTextures": [ + { "name": "outputResultMap", "type": 28, "count": 1, "defines": [], "stageFlags": 16, "binding": 0 } + ], + "buffers": [], + "images": [], + "textures": [], + "samplers": [], + "subpassInputs": [] + } + ] + }, + { + "name": "skybox", + "techniques": [ + { "passes": [{ "rasterizerState": { "cullMode": 0 }, "program": "skybox|sky-vs:vert|sky-fs:frag", "priority": 245, "depthStencilState": { "depthTest": true, "depthWrite": false } }] } + ], + "shaders": [ + { + "name": "skybox|sky-vs:vert|sky-fs:frag", + "hash": 3653711100, + "builtins": { + "statistics": { "CC_EFFECT_USED_VERTEX_UNIFORM_VECTORS": 39, "CC_EFFECT_USED_FRAGMENT_UNIFORM_VECTORS": 39 }, + "globals": { "blocks": [{ "name": "CCGlobal", "defines": [] }, { "name": "CCCamera", "defines": [] }], "samplerTextures": [{ "name": "cc_environment", "defines": [] }], "buffers": [], "images": [] }, + "locals": { "blocks": [], "samplerTextures": [], "buffers": [], "images": [] } + }, + "defines": [ + { "name": "CC_USE_IBL", "type": "number", "range": [0, 2] }, + { "name": "CC_USE_HDR", "type": "boolean" }, + { "name": "USE_RGBE_CUBEMAP", "type": "boolean" } + ], + "attributes": [ + { "name": "a_position", "defines": [], "format": 32, "location": 0 }, + { "name": "a_normal", "defines": [], "format": 32, "location": 1 }, + { "name": "a_texCoord", "defines": [], "format": 21, "location": 2 }, + { "name": "a_tangent", "defines": [], "format": 44, "location": 3 } + ], + "blocks": [], + "samplerTextures": [], + "buffers": [], + "images": [], + "textures": [], + "samplers": [], + "subpassInputs": [] + } + ] + }, + { + "name": "profiler", + "techniques": [ + { "passes": [{ "blendState": { "targets": [{ "blend": true, "blendSrc": 2, "blendDst": 4, "blendDstAlpha": 4 }] }, "rasterizerState": { "cullMode": 0 }, "program": "profiler|profiler-vs:vert|profiler-fs:frag", "priority": 255, "depthStencilState": { "depthTest": false, "depthWrite": false } }] } + ], + "shaders": [ + { + "name": "profiler|profiler-vs:vert|profiler-fs:frag", + "hash": 179162168, + "builtins": { + "statistics": { "CC_EFFECT_USED_VERTEX_UNIFORM_VECTORS": 60, "CC_EFFECT_USED_FRAGMENT_UNIFORM_VECTORS": 39 }, + "globals": { "blocks": [{ "name": "CCGlobal", "defines": [] }, { "name": "CCCamera", "defines": [] }], "samplerTextures": [], "buffers": [], "images": [] }, + "locals": { "blocks": [], "samplerTextures": [], "buffers": [], "images": [] } + }, + "defines": [], + "attributes": [ + { "name": "a_position", "defines": [], "format": 32, "location": 0 }, + { "name": "a_color", "defines": [], "format": 44, "location": 1 } + ], + "blocks": [ + {"name": "Constants", "defines": [], "binding": 0, "stageFlags": 1, "members": [ + { "name": "offset", "type": 16, "count": 1 } + ]}, + {"name": "PerFrameInfo", "defines": [], "binding": 1, "stageFlags": 1, "members": [ + { "name": "digits", "type": 16, "count": 20 } + ]} + ], + "samplerTextures": [ + { "name": "mainTexture", "type": 28, "count": 1, "defines": [], "stageFlags": 16, "binding": 2 } + ], + "buffers": [], + "images": [], + "textures": [], + "samplers": [], + "subpassInputs": [] + } + ] + }, + { + "name": "splash-screen", + "techniques": [ + { "name": "default", "passes": [{ "blendState": { "targets": [{ "blend": true, "blendSrc": 2, "blendDst": 4, "blendDstAlpha": 4 }] }, "rasterizerState": { "cullMode": 0 }, "program": "splash-screen|splash-screen-vs:vert|splash-screen-fs:frag", "depthStencilState": { "depthTest": false, "depthWrite": false }, "properties": { "mainTexture": { "value": "grey", "type": 28 }, "resolution": { "value": [640, 960], "type": 14, "handleInfo": ["u_buffer0", 0, 14] }, "percent": { "value": [0.5], "type": 13, "handleInfo": ["u_percent", 0, 13] }, "scale": { "value": [200, 500], "type": 14, "handleInfo": ["u_buffer1", 0, 14] }, "translate": { "value": [320, 480], "type": 14, "handleInfo": ["u_buffer1", 2, 14] }, "u_buffer0": { "type": 16, "value": [640, 960, 0, 0] }, "u_percent": { "type": 13, "value": [0.5] }, "u_buffer1": { "type": 16, "value": [200, 500, 320, 480] } } }] } + ], + "shaders": [ + { + "name": "splash-screen|splash-screen-vs:vert|splash-screen-fs:frag", + "hash": 3189094080, + "builtins": { + "statistics": { "CC_EFFECT_USED_VERTEX_UNIFORM_VECTORS": 6, "CC_EFFECT_USED_FRAGMENT_UNIFORM_VECTORS": 1 }, + "globals": { "blocks": [], "samplerTextures": [], "buffers": [], "images": [] }, + "locals": { "blocks": [], "samplerTextures": [], "buffers": [], "images": [] } + }, + "defines": [], + "attributes": [ + { "name": "a_position", "defines": [], "format": 21, "location": 0 }, + { "name": "a_texCoord", "defines": [], "format": 21, "location": 1 } + ], + "blocks": [ + {"name": "Constant", "defines": [], "binding": 0, "stageFlags": 1, "members": [ + { "name": "u_buffer0", "type": 16, "count": 1 }, + { "name": "u_buffer1", "type": 16, "count": 1 }, + { "name": "u_projection", "type": 25, "count": 1 } + ]}, + {"name": "Factor", "defines": [], "binding": 1, "stageFlags": 16, "members": [ + { "name": "u_percent", "type": 13, "count": 1 } + ]} + ], + "samplerTextures": [ + { "name": "mainTexture", "type": 28, "count": 1, "defines": [], "stageFlags": 16, "binding": 2 } + ], + "buffers": [], + "images": [], + "textures": [], + "samplers": [], + "subpassInputs": [] + } + ] + } +]; diff --git a/native/cocos/core/builtin/shader-sources/glsl1.cpp b/native/cocos/core/builtin/shader-sources/glsl1.cpp new file mode 100644 index 0000000000..8932028f54 --- /dev/null +++ b/native/cocos/core/builtin/shader-sources/glsl1.cpp @@ -0,0 +1,132 @@ +/**************************************************************************** + 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. +****************************************************************************/ +// clang-format off +#include "glsl1.h" + +namespace cc { + +ShaderSource builtinGLSL1{ +{{ + {"vert", GzipedString("H4sIAAAAAAAACoVXbY+bRhD+zq/YTxGcMQf4+slKpKpqpUitelGltEl1sjgOX6gw+FiMYSP/98zMvoLpnWTZ49lnXp6Z2WXxjm2Rl7xsanYonsrT4cj2VZN1W+9Ul/umPbBv5fO3Iztk3R3L8x38fi6L8xvLH+v+DcR92/z3CuTvpq2etl5f5Hfs5ZR1RVtDir+1zeHnoeTMh4UNG1AOSRytKFAMvnvgZcMO7D263fgSK2ESsfWIKOvaLC8Q9m/8AB+2Ail5gA9J6QN8nES2XrlnvrT5wOIoYN+VHw4+4ugndsv4S9spyIolUQyh0DQ6EyIliFINoPIpCsRby8jpQ8BuDGKUiBj1hEgxSxchJCKh7NeSR6IRF1ZUvGCYtK8ZftAMA/buHZuoiW4wJZVGMfpCUkCGqhKbWInJXJo6VJd4TZlTMZaoJqYN8cRIuMVY2WLczqjqvCyltxhZHpbbEqOrPlz18pX0x2vOtnmWUTJj9EbqqUlp1pZZ6lcDspT6Ql3d3iznaZhYcheVc1XUoFdBbrSwYsrpjRaURmiN0Jqz1pzl1kOHeuNJ50mk9xz8DxxGJiroHRomtFULrRYT9Vmrz1p98dqiO7W1OgsuSyfUr6eqaNURldXPVRHoBmJSpIGsbqGV+ggajX6c6IXRi4meoyNe1v5gTrEcVXnDHRUfFWq0qFGhrIoLhRIWJRQKVYYg6FD2Y7fEHMubYzFz7FiOfzn+5cKpuFUTyhoZlNAopYYx5Y6R04/cjeii0Nf/NeePU9WVx2qkrtyxLCQq7BE645zshlVGU/MI8VYgn0keSB5JxsAZzcpjNDo89bprN5IslI+18e0y1+uunSB5UD7Wxvfg1EJjz47fwcGOTp4L1WnKJ9Y2Hczu5yLHyf2EbfbLujl1jMa3V4V6MSNc0saiuL3cyBSrp5q8UKwea6LQo4OmTa4QA6EHaWnQwkHTAaAQI6FlnMGgsQJrDRkcyOikAs576mlJxw+VuMQIZLnCDEnG9Esh5RFtMHNanNogCY3DmOQW7dEG86fFqQ1S0TjMTccc1IxuVBc+1r83eVb9dcSbgzw/jg0PmXPZYc5th9nrjtMmEnq4YX2Se/b69qTuQtqLvg2RISTi2Olt42t/IYSAOZrPjE9pKtvADBpoiWHWjmX9bO6XEChlJ7ggLizA/a+pmnYrhzNvDscTRmq7+4Y7k3lnCpPCV9v9ud/zotNVUJXhXiivlL28kXr4yJBjDQqqMnqW59rGt35opHg0hI5vGi0ejSE+erbSTZ4d/gHrGm6wWVWKwpd+ZDT5MA51cPn0tX/lA9bx9OVVT8nUUzL1lEw8fX3VUzr1lE49peQJihsNI4zt+4XJ9CfVC6kK9P2Fvr/KGbl4Wde15SO0T3Yj24HXsoM53E6XUljqiuGXpmmfZktwUu/UPOg3BTkj+Y4Dtx0lRx7l1HN4dYAnmeozDYl+atnwIUskRXyY2JcNaC/N62ym8JQ16UFRYPvCJX/rTUfTV+NoJ3HhSiBbEUc4QuEVh0gEgRxc/2ppkGMXTt+wZiz0W5UmcurnuWPWUExSq7LOdipuOl1C9lzt7lXNsIq6uFt2+QE1EtykNQ4AAA==")}, + {"frag", GzipedString("H4sIAAAAAAAACk2PywrDIBBF937FLLWUUiQ7ySqh2266LxJNEHwEo6Gl5N/rg7RZ6czcOfcOmr0c1KKcBSOFimaGUTseGFrl0EDX3Tyf7jHMMQAurcFp5wl8kJcheltrhja0cv9WdoKkohBXdmw0uyxaNTpvYOFm1tLTHgxX9iFfiSX/47ISlA1dXSs1FwJwdt6B0AK9XOFU4en9beR/ZdIeHxzOKRhhe/TjdTgxSDnDKVFCZSuY9DNrKrTNETBhsH0BdbB7qTcBAAA=")} +}}, +{{ + {"vert", GzipedString("H4sIAAAAAAAACkXLMQ7CMBAEwP5esaUt0SDSnfgDP4hMMMlJwbYulzRR/o4NSJS7O0tF4yCL5IRJxqngOedgTMFM5b5axBaHC0Jf8iJWGVMtutqqwXns31hXXBvt3J+ecPZMGm3V1ATTQVuWB15BUvtinPvbD3/uas4zjjdMZz6VlQAAAA==")}, + {"frag", GzipedString("H4sIAAAAAAAACuMqKEpNzizOzM9TyMhMzyhQSMvJTyyx5ipLTTZRSCtKTFfQ0FSohnDzFWwVQAwNQz0DTWuuotSS0qI8hXxrrlqusvzMFIXcxMw8kGqF9Jx4N6BW5/yc/CKgHpAxGprWCrUAuJ3Q6G0AAAA=")} +}}, +{{ + {"vert", GzipedString("H4sIAAAAAAAACn2Qsa7CMAxF93yFxxaxPMEW8Q9MvLEKaSh+KnHlukEI8e+YBFRgeFPk6xPfa5uBg8cRKcIRu+MAh56cWDNFPBCfnuLJyRq8b/TdYThvmf7+QX6J+9YaJ8K4nyRACn4FrhloRFGnr9ZaW556YmuS4wvGrqjppc50Dqd4i6PMdFHTS81/AwtUNVxLqc6wyVOrOcYSfmprSutzN1i8b6KVQjq45FF6zps9s1LMOcjEsfA3kwhbPQzGRxLo+mb7tM5hWKrawu0Ozo1ABYIBAAA=")}, + {"frag", GzipedString("H4sIAAAAAAAACo2PzU7DMBCE736KlXpJUBulElyIeqqACxIHHiDaxOt4JdeObGNAqO+OnVCVE+K2P9+MZsSGlSQFT8/9y8NrHyJaiV72kjwnjJwoiA19RLKBnf0LuweyOBjKuJWsxOxp5EWkedIzKOMwdiKh/2Q7QaLxFlI/OuP89bpA+Sw5FLYwyuMEVQ1f6+rgcJX9I/zqiJhl6p1l1NXqXmc1mUC/gbZp77pL/p+7mXV57RvYQTg5F3WINFc7xG3mt4BDuDhmYt+02dg1fhrg5gCuwbyVafHphKf45i24TpxFcizhhGxLOZhM/5ibHkuxkjXPVd3B+RsOOGqSoQEAAA==")} +}}, +{{ + {"vert", GzipedString("H4sIAAAAAAAACoWQzQ6CMAyA73uKHgGN0eiNcNGYePTklUwYUAMbKQVNDO8u4A/TGD2ta7+mXytKUhFWaDRkmGYlJLmR7ItaY2KoeCQLySuIorB7D6jOezKnT6RR0YCcDeXx2tQ63ijNiv5zO5kn2wt3dOULyUx4rFn14BJkWJoKudPzxdDZKGJwXLjev2P1GUEwjHDGziksZnPXIrzgh8CLmgTf17EGvV8EPEuHFNekrUQrGoNxd0nUvT6kebi3lYkd14f2Bu4pnHKQAQAA")}, + {"frag", GzipedString("H4sIAAAAAAAACuMqKEpNzizOzM9TyE1NySzNLVBIy8lPLLHmKktNNlFIK0pMV9DQVKjmKkotKS3KUwCJahjqKBiAkaGmNVctV1l+ZopCbmJmHkihQnpOvBtQl3N+Tn6Rgi3YBA1Na4VaAM8ftqBqAAAA")} +}}, +{{ + {"vert", GzipedString("H4sIAAAAAAAACtUba2/bRvK7fgWLAAElUwpJO6/TuYecrQIG7Di1nfRxCARFol22kiiTtESyzX+/eeyTpCT7XsUBiULOzszOa2dndpnOKo2mcRYnS2cRzeKHxcq5nSeTfNhZR9Mj5/5hkkfpEoa/S5PFuyLOHBcGDp0Cnz16LPVjhY/d3zuLSX7oLJxjBx9cxmU0xhh2aBInTyfTCNH+4X+GP84BPAWf4Q89hZ/hjyHIsBPfOi7TfOv4g67zu+CTAQ9/8NJ54WT3aS5QDpxg4MNUSDrYEEZIKAJUAMilWWC+Ps8cfu46PYVRMoaPcMIIUUoTo2KMgKTvsx6BxPjqRPMsclBoV2r4rdSw6zx/7lhgUrdrKxUOfOSFSoEyZBVfzRUoyZnUULVNL1tzMkabqoFyg28RVaYxDrQxXtRUlXJplfZppPXQurVp1PBDw5c7xC+bOmvnaY2CmkZ7RA+VSDW31ERvBEib6C12NX3TLqfSRCv3Vcg8j5YAF5P05MOBI5j25IOAVBJSSchGQja89JChXHjMPBjINQfvXUMjNSvADTXU1BpcSXBlgTcSvJHgr500yh/SpcgFX9sy1OhhHqUiRU2Wd/OoKx2IQhEEpHoBrpQpqFTw0oJXCl5Z8AwZZfHSLVQWmyJommQGKCsFVqmxSoGlQVklsCqNVQksBCkFAYbPrm+aOEPzTtGYU/TYFF8zfM0qw+IaTFiaSGFVEkuAIUwzg8jwx9Sc0cRCXjXnQOY/wvSfxgU65uqGvALqeA55Z6U9E6KrOTIHhfILQyk6B6XyCkMpQgeVhBaF4NADZgpYKmCpgZUCVgpYlmIqE7OsFFBjVpWY3gRuePaNNfumVEDNc1MpIJILi6Gl3A6spL7jlqhvVXU9FP8ACDwUuQ/sPMf3OgDsE5Cxi0Jil2iRTcFI9FwSsE9AA7ssu4S0GgB8NSjxB/l1uqbT2GPXNZfl4t/MWlT3yElY0HOEgTxnw6oOTSejALaDUUnbuSi87dgWt7Y4tcWlLQ5tcWeLM1tc2eLIjUXIeUHHL2cAHbm81geV7XbXdjsVDmBOV3hfv3MQyHdwoCtigUBgeNcOCQUWkSHfiZIDhEAVo/QlSmVzgnCRYKDM0dU5ujmnoOlaWfjiYZ7Hq3kpomZC0XLkfIFoMUo4lb4mtAq/wGo4gOcNPRf0XNIzCjWhpfYFragSmhw36Up6rgSPvuJtpjg5btJV9FwIHn3FuzCSnsTdGHwLA7c05GymwXUSz5w0yWGT+hRNcV19j/ncjZfJQ87LaS0Mda+WVawzylrkxZKe0SacftY6suLSwOZ8WQnKvsh1a50r48rA5jxaCMq+mkdFcYwW6EuUwkApDVGA+Zp8GlOdQSaOcYY+p/W45GcUP674uUQalJwGbRpUQuLhnMS2f8/zoPw0aNOgKhIPZZNzFiJGD4UXzpbnyXQyv15hi8CFwirJRGbjTsUx2hpH9zWGm+hhHUeb73lzbrZJoumRXGTbQ4QgiEEnl40r+XkwBcRRPWZcElPQdlWgAVRk7kNid5NcYM8lRHV+Z90XPpcQh7jR+GAermXZmWwwCWHTVl5HAgqBcqBQNu0olcGFUUpWGeYP1Px1tnUaYGuLWIjfHSKWAlwXsVDzh1vmb9KUTbZ1EYv9IpZKf53uD92F74Ep4G+oUycO3CTkYW6bwbuq7chTbqJ1fwzPqkOGZ9EjM/b9BmIHUvQ9ZOj7SrbLVLL7muc1bkTcJoseGWQFudWaX66vqbT3ofC9hkyoeucevXLDwnJw88NycN+L1IBUSqRQdj6sRGgiVRLJlx0gc/UNJKuJVob4Vhui+/x5Y6DeSiuVRd+m0PuGQfsG6SMsstcEhW220qBRrvRrNJVttoM2s5m9thLe1HuX2qaqpgmepvYupxaP0bO0bWOqHRhh3qL2Dt1CwxkN9z5atx2xqHXb4R4r9Lcpc19ZBlCtLXV5egnD343OFBE2tyJVUFYjgMrxEeYKAgFTf/ByaBTpUSqrdHgSZTo8VXb1+j/uav9vetmHZXybpAtH5Ot4eRPP4+Xd+PL2NosAwxq/TSeLCBCi8Tqan0fLa6g2ohpO1gJbJrPoCjd9qCL00C/x3S8r6hWc6XQM/36CKmHP8NlyvQfjQ5r8WkchIQBlCuKnkw9YVmzl8UOSzmfgyUlagh3UyTGwCJ2HdesAkCbzJB1yRTxNFqsHLG/SHGYyyuEjVY2F8JPmbGJZeskGtPMMst/Jyfhq9P50dDW+uDwdOcewoJw//mgBH3Y8Fn7Nxuk8i5az+HYLk6AjZonKqCMmBk8m0zgv4Z0DWgLIuQo6j5Z3+S82rDhbzqJCTomLdYvsvIhRRKpN0TSyZtGGoEojw7VswChqcVX7A1nvgBN/BOoleG8yj6vIZT6sPydHT5qDs5x+5fNHg9NPOzkFNqfA5hRYnH7eySm0OYU2p5A4QXQMCuxpj1vqedeynkdWoN+f6PdnrqyfRfMtjpdiXkG855ao0zTJMldO3sfY8FQQIIzbZOw2JJOPK3KfRsFWyQwbyGCmLQxeTs8MJfaupbqrhOw5ky+ZFSAkSHy3NIHYxfeFUD0RktsNEf43QpGoAzxGcPxabNGQT0P94N/yMXlJQ7q7HX74n9Kz2avVhLzfvS51YpZL04AEDUjrApVGDAz7JiQsbnY4bc/WlDpzIq4P2LGWiE3uGZZfPIBg00CMX9bA5VBmPapfQpn0P35yXM6NtFVSMBoZ33xXeyn33KEzWcZATtqGqC3wSVJX8wFdFA1G/bBDFFRj7MStUeKZDhGWNhZGUzOWvjl2jjpKdipV6AzNAClbiNLCFXJhW63Q8EqHNDNm9CyFGtXIwzibLFZz0Og2GdaHNrhNQ03RGMjjRXQazfMJ2CfP0/gLuIXHJmNwZYw1yDjLJ2mOmC1IGcTuGHf6xkgqSpj2UVEDNOCzOB3DIrWm4hgBjsvZdRTNWi1/jJa3uB0CRR4VJ+Dr2XD70GHLGK/KbVIHyoWE/rCE9fLbyUO6jk4n+cRx2Q9peOrkKn6nOJUo0IERxAWMgf+j8NQlLEYQNfGXLeMQIqabB0b1jWGdTqa5S4gUxRZqYRxAxIU7wUXt4QEm/jPtqrOxx2vjOVipiWPwP1s1LORZrw1qtWGd9ijM/FdZ9DBLribLWbIQ6ajQnXOCNwrDDqaNRTJz8WQHWkUPO8guP0s5b9Po/tMEW6/AHwSvXh35r18eHr3R1w6iGZJ4PZGHEm7SgBn8dpXaazrvKVwfZ4Np+ri9F5TsnR62jK/914H/6vWbIEQQ3mj8FY93nL85/bXzF2et1F+jrrRkLs8vr8aXn2DN3JxdjHDhfDwfjUfv3/39fKQyg3Y4Rfs4gaxEeQKXjK8zSLzMwQ+MA6aJhmY1fXV58+7m7PL9E2ZT+WL3hAqtMef12c+jJ8xHmWv3XITSmOe7y6uTp0wEr9N9MzEOT9U2kuGebEnxaXR+eXJ289MTBJGl5R5ZFFqbOGqwKdHN6Mebj1ej8bv3Zxfs/H0CiUQwhi1wwU615RGbFA6PY9rXxHS8RNJoFeEVijghtZsvXMJiAeSwtnit5bCvymFZWqtTFS7e+FaGG1B10C9PVmJcaFxc3nMmWXGdfiCOhOlVFF1phN+KrLh8EufBFm281jmKznuAQnI1TnvuVutsjIcNjqvzEuTDeA3FwAK/mjL2cb6Ratm79Q2sqjlngnw6B4+4BscXxkaMuVTmIE7ioYP8aPP0ZQVm89RVv4EbbMMNBu3F1DEXU7IanBWSgd68sSoy3squrE7byUSxgipZ9QlZW+/pus2Xn1sY5iD/SPXokEIjtVid0APVA6EEeJWoRKFw2Zu98IjXSEfUpGIsEDvYDWq7ttuS2zzDa13jEFWJNUZnPp2Rpg+eTB+o3e4Wog/2EVow5n6sij5YQYdv34Qv0ZJSa9zXWXJPSOApRrR8zDINew7uoo/51E104kg4fEReJyaUjN9BOlJ9FsrD3tEpXLnHRK9bpm1X2OkjJmhz0iNYGRza3LSHQ8NPt8Bju6PCIAxekadMA6C3hA6eFEX561anOxq6gYLvN7mwFBex8Ex70zZEx2bK4JJW53NXwz2jGxJzGgcz0LdqVLE2n7DlimPvFZjhIgGqOEp9agGHbUOBGOKzByHGluCy9mQVXzWiule37PdmaHg1aRtRBz/gn7I17v41/hbbtmDczzaosW3E53pXHgnevn7z6hWnZMt+GKFKX0/LqKIU9+uGdykLWcC6dBb9V3uHsQLdlMeKdbvqUuFeZ2JEvDW0N+gtbFnCmAeWxzU/qnVhnA/VjjhrZUbPqik4434DO/7H69H4h8ur89Px9Yd3J6MOb6jG7QJWVXgHse2Q3tirW/SvqS5Xs7Ex0F4t71tobzYrA7U/t5307DzABy78EeqxPYVMKzvPng1inQpUadM2jvHi1WaqamUNUDW+USE2ruRnzrIL35qn+7TWj0Pa6uOMjCZvM1sSw5YO0drq9geeunWUl6TiIjUS+vO3F3TOLJQXX9Lc8+c2PH6NBrDHU4owtpn5LQej9gTPRoZVWrWl2MeoPKzxacup+/k0cmi6M4eGL8O3oSprpccwF2p9PEMmlQPTR7iofV0dtl/qhZ3IXgm+aFgI3FgDf67nrRvHnccxvEr08YpaIgSiPMVPPeM8re3EZkdRKa5iKfKexMSgDZ5C2wiy6a4gexv4R9Q6NVXGQBOye1IQFWJTYWnMYzXS4Y4r329UvzlN0mWUXspLE+oeXdlNqnO6bRsSxwFt6DoYjRZaSGDffPNHfebEtHo83bc8/arb+hBg/123eeWPm1RHX2x2vPavGQbV1pFNxzPa3I2695YbDC0m0PBi0rqYaBi/hGiMm59H8KpjFIncE1xbFiQPMPcjp8AzpveJbArN/6LgkulFbWPhM6L4LN5CM1zFV5d4ckwkPXk+oO4c+JNp8bUHpkKJK8VRJDzMV3ki+I+bFxFm0SQ/65B1U/2Gjb43Gj7qxE40LZjFvkN6QcrNJDO8TRrdSrzMXePQDi+iVUNsENW3qPbDwN0tsWTXtnU+ip/Npm3n3MumkdPynTnNf/32iFpjwxTUGitdPEMgldO4brdcobDoPzKZFi8Ve/Y3H5RaTsEKXc9JH/Vq5l15KMfR9UCnnvLO1rUvaykpbksCBf3fgsaHUnzb2QRXm/rXzPSNECLi0adzNx9/EEdsIJE6F3W7Q+frPwGwUXV2wDoAAA==")}, + {"frag", GzipedString("H4sIAAAAAAAACk2PywrDIBBF937FLLWUUiQ7ySqh2266LxJNEHwEo6Gl5N/rg7RZ6czcOfcOmr0c1KKcBSOFimaGUTseGFrl0EDX3Tyf7jHMMQAurcFp5wl8kJcheltrhja0cv9WdoKkohBXdmw0uyxaNTpvYOFm1tLTHgxX9iFfiSX/47ISlA1dXSs1FwJwdt6B0AK9XOFU4en9beR/ZdIeHxzOKRhhe/TjdTgxSDnDKVFCZSuY9DNrKrTNETBhsH0BdbB7qTcBAAA=")} +}}, +{{ + {"vert", GzipedString("H4sIAAAAAAAACoVSy27CMBC8+yu26oUARbx6inqgQKVKrUBQytFKHQdcJXHkOOFR8e/dJCQYiugp8c7ueGY9JFKciVjIEALuiiSIwPOlo22ShMKTKoCUsz4Ejgg/hC/CFZ14XswNfC1W6wgbdB8Yo/j9FHwzVfL7siUnwhbmBFw5Uxnf4FhK5bs2SR21wzsraUjRhSS9CuCo9KWyiaO1El+J5lm1Bw6NZCw0OryA+ghpvh1KqdwrUyXUuYF1r1AeVdwLD4ZDOpoNlnT5OhvTl9ngfVwJz4nSZzwxHiIDwwkeusIjOU0a02zlNQt+iLE9dAJP+W/tZKsJHcs+jnFfMqF3p6bKRWu72zehbRXK7lDaYj6my8nsbUTn08FwTApyY/9Qzy7MqCvWc7QEKu15dLCsdJESnDA0tLbwAO3Wo4WjRnWXi+8B5mIR4USIiXB8sec1pmQc11BDJh5nzfAUfkoF2clCb2Vv4+lIVzfU2GcWy5iWLpMUIUPWfoPIn9wjOzSulPcb2yb50+cs/4TAePezS7vVJhXXiQoLZQeSSuFCGQhY+XR6fPvsocuo2HD4BQjthZzOAwAA")}, + {"frag", GzipedString("H4sIAAAAAAAACnWRwYrDIBCG7z7FwF7MEko221vooZu00MOyEAo9BklMKiQajIaWpe++o7YhlxVEZ/zH+X4lo+a1mISSMPBG2GGEtlfMZGTm9Rby/KhZ92PNaA1Qn6pVr3QEv0RzY7UMcUYeZGb6LmQHqErBztk6sX3J3kSLl1ZFub9Ul1N5qI7l/vuwln7C/IVRzaXRosYKLhvREitFq/QAExvGnuu0gIEJeeY3hODZcux7GSFNHvr5mDUNUIf8IoEdpJsE3gMVrkuF24c704KuOsToKPoXH7OUyTvt+TSdr0zStYXYu6LJJkkjHIgRCBwMZmP4WGbk3vFp+Pm86x+gWOglsxKN9+9cQddXThP4d84tjTJ4/AFT6U2J2wEAAA==")} +}}, +{{ + {"vert", GzipedString("H4sIAAAAAAAACrUZa2/bRvK7fsUWAQJKJhWKdj8JDpBLXCBAEqe2k157CARFph0eJFImKYnL1P+989gnRcnpPYDEXs7Oe2ZnZ9aDdZkusiorcvEtu/+2FnfLYl5PB9t0cSYeNvM6LXPY/KUsVq+arBIBbJyKBtchLaVdtrgcfh+s5vWpWIlzgYuAcRmNMaYDEiLqcr5IEe1f8Rf4J05gNfkC/2iVfIF/jiLTQXYnAqZ5KeLxUHxXfCrgEY9/Fi9E9VDWCuVETMYxiELS8Y4wEkJRoAZAAUkBeRFLTr4MxchgSMaIEU4YCWrpYrSMMSHtI7ZjojEeRbqsUoFKB9rCl9rCoXj+XHhgMnfoG5WMY+SFRoEx5JXYyJoYzZnUMbXPLt9yckafqRMThtgjal1nnFhnvOiYqvWyJj1lkbXD2tZn0V4c9mJ5RH25b7MNnrVo0rHoCdUTo1InLB3V9xKkT/Uev7qx6dfTWGKNe1Q6L9Mc4ErISC9OhGI60gsFaTWk1ZCdhuz46CFDffCY+WSszxx8Dx2LjFSAO2YY0RbcanDrgXcavNPgx0GZ1psyV7Xgsa9CXWyWaalK1Dy/X6ZDHUBUiiCg1QsIpS5B0sClB28NvPXgFTKqsjxoTBVbIGhRVA6okgpLWiypsCyoahVWa7FahYUgYyDAcB3ErosrdO8CnbnAiC3ws8LPqnU8bsGEZYkMVquxFBjStHKInHgsXIkuFvLqBAcq/xmW/zJrMDBXNxQVMCcUFJ21jUyCoebMHDcmLgyl7BxLExWGUoaOWw1tGsVhBMwMUBqgtMDWAFsDlFKJcjFla4AWs22VeBe4Y+k7T/pOGqDluWsNEMmVx9BTwQBOUiQCifa27TBE9U+AIESVI2AXijgcADAiIGM3jcaW6JFdw0i0lgSMCOhgSzkkpPUY4OuxxB/IbzB0g8YRu+6ErFa/K+9QPSAn5cFQKAeFYsemTt0gowJ+gNFIP7iovB/YnrD2BLUnpD0B7QlnTzB7QtkTyJ1HyHXB5i9XAJu5fNbHrR/2wA87NQ7gzkBF335zEuhvCGCgcoFA4PjATwkDVpmhv4mSE4RALaNEGqX1OUG6aDBQ1hjqGsNcU9IMvSr8frOss/VSqqyZU7acia+QLU4LZ8rXnE7hVzgNJ7De0bqhtaQ1KjWno/YVvWgKmt536SStW8UjMrzdEqf3XbqW1o3iERnejVP0NO7O4ds4uNLRc78MbovsVpRFDZfU53SB5+pXrOdBlhebmo/TVjnqwRyrzFaUraqLktboEy4/W5tZmXSwuV62ijJStW5ra2XWOthcRxtFGRk5Josz9ECkURoHRTqqAPMtxTSjPoNcnKGEiMt6JnmN6mctryXSoOa06dOgERoPZRLb6IHloP606dOgKRoPddMyG5WjpyoKb/N3xWK+vF7jiMCNwrqoVGXjSUU4Y42wc40TJlpss3T3K1/O+2OSGno0Fz32ECEo4tDpYxNofiGIgDzq5kxAairaoUk0gKrKfUrsbor3OHMpVcV3tn0VcwtxihdNDO7hXpaDyQ7TEHZtGw40oFEoJwZl14/SOlwYRbLJIH9i5HfZdmmAra9io34eUVEqcFfFxshPDsjfp5H7bLsqNk+rKI39ttyfBqs4BFfA/8SWTty4KSjCPDZDdM3YUZc8RNv5GNZmQoa1mpEZ+2EHuQMl+gEq9EOrx2Vq2WPL8xovIh6T1YwMuoLe5szn22tq7WNofK+hEprZeUSfPLCwHjz8sB489yI1IEmNlOjJh41IXKRWI8V6AmSusYPkDdHGES+tI4bPn+9tdEdpY7Ka2wx65Dg0ckh/wCNPuqDx3SYdGhPKuEPT+m476XObO2sb5V27j5ntmuq64O+ZfSyozY/YKX3fuGZPnDTvMfuIbYkTjL3w/rBtR3LR2nYkPF7qHzLmofUcYEZbmvLsEYb/O6oUmzy7K8qVUBUjy2+yZZbfzy7v7qoUGg1v/66cr1JASGfbdPkuza/hvks7OFUPLC9u0yu8duAes1v8KEiTwWIxg9+f4Z56Yvttvn0C42NZ/LuLQkoAygLUL+cf8WI7yOO3olzeQnGflxL8IFbpbbZZEYtEbLa9G0BaLItyyj3ZolitN3jBljVIchqyM9MPJPCjrNnF+vLXI9DgGZy/169nVxcf3lxczd5fvrkQ5xBS8eefPeDTQcjKb9k5g2dpfpvdHWAyGSgpqUwHSjBEslhktYRvTmANoOAa6DLN7+tvPqx5m9+mjRaJ1eGA7nxVoorUHaFr9K1pHUF3XYWDgAOjNwCcC+KxvnEhiP8E6hyiN19mbRowH7afj2eo3cHnzH7yC5jD6fejnCY+p4nPaeJx+uMop8TnlPicEuIE2TFucKo67+koA897IXmBfv5OP//g3u5ZujwQeK3mFeR77am6KIuqCrTwCHMjNEmAMB7UsN/VTD6tKXwWBZt1N22gNrm+cHiJkZtKHF3P9MAoORLzr5WXIKRIdp+7QJwjI6XUSKXkYUck/49UJOoJDrIi7uQWbcW0FU3+qxhTlCxkeDzgp/8rO/enhY6SD8fPpS3M+mg6kMkepPeAaidOHP8WpCw+HaLYkW8pzYZE3N3wc61Ql9wzbAB4A8GugxhfdsByqqse9dqJLvqfPouAayNdlZSMTsV3v81dylNfIuZ5BuRkbYLWAp+iDCwfsMXQYNZPB0RB4/FR3A4lvioQofSxMJv2c+mnc3E2MLrTXE2vOA7I+EK1GoHSCwc7g4Z/VCDLHImhZxB2I/O6LrOv4Ei+puYzcH7GXcPeVp02r8Hq2yNbkyN7SWfvDPbUNX7o8tzjRfiT6fFL9+ywDqc9+vH5OaScFUbQ5XpbzbBrE4GZyDEVubieczOmCrTnFt2O6Pd/62l+fTvkAq9lsMSsGwriI+o45Cdg8+n6Yvbb5dW7N7Prj69eXwxYsNNvgXr03HBYrJHoU+kNK9JKvrq8eXXz9vLD7PIzMLt5+/4COX56dzG7+PDqH+8uzOPNzQrvMy81+BCvNstf5ou6KLmh57mXCeBUvRSTmIbyePwzet9sROe0Mx249BExeDQPNdp5TBXSJE3llt4GLaXzd8EI6eg482/+lupbqu9WfbdDXdgOHeuj3Rqw4L95dTzzRIvhkHHZHhs1Duyj6aErQ2lus5y91fP3uEBzc2Ucw3ekDPtSpr/4UX0v87S81JcOVTKH25jezDEPDp6dgw28Py/wY5wrjp7mQnusQ38cOtr1/Ue8zZTE51kfsbB//MP3+v6NnRtVvl9I0eRvq2VjRYWGUlLXago7vW8BzXvz+KleKwEGxLSNQ+jevjuZ8vFjFI08Ulxpi1/M9JsabzD3M9HgNPmh0IXX/ftkQMaotsPDZ0T1NzEPzTee6yWTjHTNNZcIV2w1aOPloXG1OoaEt7lEdzxJF0Tnitls6U/GqrNx0731Q3swNxr6W9DeswL3Bvvgdjf17gY9z+vrwX+ZpmkbmeDdJ+6Xs4/qCgN6czEGw6l4/Avm+cvZiiQAAA==")}, + {"frag", GzipedString("H4sIAAAAAAAACk2PywrDIBBF937FLLWUUiQ7ySqh2266LxJNEHwEo6Gl5N/rg7RZ6czcOfcOmr0c1KKcBSOFimaGUTseGFrl0EDX3Tyf7jHMMQAurcFp5wl8kJcheltrhja0cv9WdoKkohBXdmw0uyxaNTpvYOFm1tLTHgxX9iFfiSX/47ISlA1dXSs1FwJwdt6B0AK9XOFU4en9beR/ZdIeHxzOKRhhe/TjdTgxSDnDKVFCZSuY9DNrKrTNETBhsH0BdbB7qTcBAAA=")} +}}, +{{ + {"vert", GzipedString("H4sIAAAAAAAACnVRy26DMBC8+ytW6gWqHlqaG+qhorkhEfWVo+WCIdsSG20W2qrKv9fBJCFEOVmeGe/OjEVDOscNWgMrrFYNlLVVHIvWYGlpPYBrxTPIc+nOd9TfC7KfsbjCEt5e5jLNksf08oOlpbpwam0KLIViJvxoWUOn83tQsrEbZLc+PqUiR7H+SaylYkLNHJXb2lIsOkW/aCqPdrJ2u/kEjaDtbr3V12UmkyzNnudPF+ZFZwMLRV8H6x7TxBCE8Oevzj089OrgGOUG7sJpPV44agSud48Pw8f8vuK9xEVw3LiPIWqPDlVMI3rzR0V0WEWaWzJ+9FZ0Fgv3XWh2oaCq5WJI0eciDsIYtv8sH9lTJgIAAA==")}, + {"frag", GzipedString("H4sIAAAAAAAACo1SwW6CQBC98xWT9LKoNWp6ox6M2PRgYlNpeiRbWGDTdZcsSGwa/70zqICGNCZcZt6beY836+RWRLKQRkMm0yyHRBlees6DTOBjuwoX67fXRRistoGz1zIxdndiAFd5xoPMiiIzKsYBoWOZOJWRMbRDwKSGSkRPEBllrAu/fZuxw2p8zOH5ZrMLsSwibluJY69Ix9U/KjV+nwa3P1KnJ/NVqDCccyzB5yZcbtab95V/y4q5/W6jaLEZ7KuJ1yRY8F2uhJ35EEVhkVtZikAcyr0VnlNvSixPgdF/1KWBea3ApiM4f26PF6KW4rCkJHsnGnAwJyIJznx262FEZpFt8BrzZiEWg0sOY06oTb8QZ6zDeITpeOLWRIoCO0PqYL8h4VSHQDuGV2BHBSsKUxXCMXdaJlp7rNMd2ifADHKswAkNxrs8pB2XmrKGVIUvGPwlPzoCcz04/gGmbLGyJAMAAA==")} +}}, +{{ + {"vert", GzipedString("H4sIAAAAAAAACqVWbW/qNhT+zq+w1C/JBlkIVJqW2ztVFCak0jLgskrTVWSCoZ5CQh0nvEz97zu248QB2ou0Ly0+L/ZznvOS09gyEtKUJjF6pevXLVpFCeZ+I+UsCzmabhnlZE4YJ/sHzDH6t5GTsIu2SUo5OPnqGCZRwvzG+4nfgOH1hsS88vRQlku7LKarhG2KRzeYwyVhAP/nlOw+UY9Z8s8PvC+ZKJRhEOINYXicpH4Dc87oIuNEKDsIB1VMNZUHKoi+lyRsaaokUaBbYB6+BhR0OWYHGq+VUx5kuVvJlLUQjpIlqdl2pXhKj+R5tUoJv6AcY4Y3qfuhpn0xYcOYExbjyEwcSzguE9dBnOE4jUxJGuKIFGmto1IhlAEoA/W+Vq5oFPHDltRSrLmPErg6WAKYv61eL3joz4e9fjC6fwnm/cms/xJ8exoOnicjOPZmz5MpaiEw6w8GcAy+TfsPH9jZ6Bd0i35Ct9+LEOYk5AmbidAEgD8zQGZJTd5UaN5s4IMRnrEY5ehn5DkuXBCyJE2tN2d/ODbrh9wGozdnB0a5DcE18oQuAZ1iexhvM24l2YV2oa6tmReBu+juhAkac6uqIbsKQzm0r3EAbG3TybvSyTOdOlc6dUyn7pVO3e+6QtgaXCQVzq6UgQh+Jcxia1sLF7gw9JxjKSsNFxgMP6x1Cv1A246u9eIiJTQqvkQCOZY6WfsgFbViqbf3hyZqO64t9WY/FM4dqdB1L/AxHPLCeSfib7uOW3iLzimj2hVC1UGFuAtC19GTSEHpWhcK2qrmFbyhsTeREbao2XrAZSiuIye2vp/BFRaooJG821swaYo8tRBrAuVnKshMCy1sX8/zvyh/nZRjha6QdUKVs0dfELAgWuFcdYfwIj13gfvrVyuwngTTMmayAxkyTsLxHZEoJfDa2Q3mKH+vsMrEfL1DHQVSzm6wPo2tPqfB4AS1siiGtSbXSLKsJqNcmkhmQ6EoawhweBWOYsDrx/S8LUK84Ns+9S2RKOYMhaOK+0S4b9aOx52cePUHK8q8zyhTpWmErxiCh1FLt4ppcLCvIfkjKO3/nT252pSkneGzaybtchqZJqJR3O6voucvpGCrOQbmi1vgt+2fpLpme9xVtioZurw/J93spoOaBTXhcSe/ZEE5l0oy/cYNkDu9H40f+8Fg8jwKJrPyMXOLgi/iV1lBv6veVMndm1UFubbRb3oduiHxkq7Es/VFplgg1QkGOrJEJs8/p36j/tGlkjo9zKhj3gPzUcqqvU5EBYtEMB6+9B+D+8fhH0+j/tOsoSyrDRIY3IoVEf6Ib0OZ5+Js+zUPsW9qjxuRmbP76haSgWL5kKJindhgGouw0ToKxuYXgHHL9tH7f8pGXbirCwAA")}, + {"frag", GzipedString("H4sIAAAAAAAACqVW207bQBB991eshFStwbi2QwuVoRKQtEVq1YoAbZ+iJdmEFb51vQkJFf/emd11fEngoeTF2bmcmTkze3EKyceiFHlG7sTsriDTJGcqdkol52NFhoUUit9wqfiyzxQjf50FHx+QIi+FAqfYLMd5ksvYeer4fZJslvJM1Z4RmS+0nXY7Px+ytEj4T6HuTpPijg15wSRTfEJLrZBRn0Bkj1hXF1B2xBQcR9fDwWjw7WzQ7w/6o9OvP76cOpKruczQ9oCCFyx41KfaH1x9Obv1yIac7GlwGviBRwL/nQuGbuzs8KTkFeImGBpkEzF1npwFkyuRzUyKi9F8EcRrmSZTC7/lEx43bQ+0eCge+ffptORqi/IHcJGWwbOaMDaU8gVLhokY88n1DW0wZToVkBOSiiXVtECVrtcE90ipeEEbEn+5Wq6wSP3HhVLXEMT8iqAJEW5AhJsQJpWwmUrYSaXCsV4tVZ1K2Ekl3FbNFoigmUpE7gGGFqH/+ED2oR74uuStlixXRgLG1vbW2oJm19hWFrgOn/O1s3MPRnrKbmHuHTMQ2LBPIkmaDfPssKQwKNg8s2K4KyA+kBU7MPgU1eTjCYmAvbVVqZhUYNViLLZKybIZ7yhXtrSJkKCB9PZb6seHyhl8E3Tehx2cUTD3gVX8LF2oK/B74VEv+HB09B6+RyZDE++YBCZDg7BnuqY32X7kV43SiXsmCvamKrdWAnEasDICEgluza3INbDWeYaYDeCmssJH4Aq6yXNoqkARTNUKRa2hIm/eEK04bitWuvZm9+q8rTTQ0lpuYyyfi7F8RYxqGrUcJYtcTPD81ef0RVbMFc3nW89tUR26eOJeDX5dXV8OIFdanWqYbs+y5MMomRwDGI/2AYe7Y68rw0lrsN7EjFqYU8nGSusD99XQYQu6fXz+X4R27UhwfT/Ym04za+67F243bZ0D0At3Y30JdQuzfch9RnZPOscMJtY+ER/10NvJyGOTa48MLz+fXeVfRcaZJFSLZixNGSJbY70GkvQ3bl+CeEPZ90B3auaZmOYyJXX54/Go1MRcmSt2fa9qIGj6jFCMu20uY6c9v8LdjFi/TnRvzL/dbju6WXgEu7l+BWwDWSeKES+Go8+Xp78drcF3Btg1WaRrBWA2jZBcOslVbeAZWeBHYfQeHySH4bsIv8FhFLlux7/8I1UL3CZl21Q9y8xuT5nIkEwyS0bI5LmtCFmmbkye/gHKH9/1DAoAAA==")} +}}, +{{ + {"vert", GzipedString("H4sIAAAAAAAACoVSTW+CQBC98ysm6QUaS9R6KmkbY2hjgkrUftzIFhbdBlmzLKht/O+dXTCC2vbCZue9t2/mDcZa0JBljKewZIvlGuKEE+kYecpiLlZVcUVkD8IwwPOV0c0fsC/45z/qS5SChpoSkhUVxOeZY1yxGF5mbuBNBn3v9xffuEgiZNM0YrEWzfoj33ODp+lkFEznB4RIKdhHLqnyugUSrHnGJM7tNKEuQpJuB5yL6ATqIRTyhAvHKIjYsXRR9X1W60JetLGi0IIKCaYF3+UVbeFe68xjDy3oWKcTl8TakHCtxI1RFdsfvrte0PeGz+ORO543dCrugww/9nb3hRiumAuzultOQ6GWczRKMnr2XpOhW8FhkVLP7cIeSlJ9x/YGHqBjt+FRZ2Yiw962dOVGBWjvLLgrk6yMdNLaqspcUJmLtGxmbxScRfhvsFTFDYsk8Kt8deJCmpYD+x/FwgRO8gIAAA==")}, + {"frag", GzipedString("H4sIAAAAAAAACo1SXWuDMBR9z6+4sJfYFbHSrg+uD666D9hgVMu2J0k1asAaibasjP73JdHa0o4ykMjNvefcc88NqgSNWc14CTnL8grSgpPGQVsaj2E+D8i6KugHa3K3qHIS0IoI0tAE1zohbA8a+j0EWW7DZmvAD7phqQRGy8CP/LcH3/N8L3Jf359dJGizEaWqHWOJkgG1PazxEmqKbDWEi3u41eTYMq0hWObEkIWGg25oUdMD4yWZKigTlqK91qPEaA1R6Ach2pQs5WLdzgpETRbmgtY5L5IeueUsgSMIMGulQ8wLLg6TnjHLG6zzJoH7M2YDElbHRCQn4v5qcqLqShed/18PInaszE7EOz1p6H+Gy4V/WqP2aDm9R8dFx3FUV4I1NGztPjqliFNBMsBKsA45zNpFj4bQfcZlWw6D2bVXdt5S7dbqeF6C6GnhfqHWrkyQHcielmmP7DsYADeFfDqWOR1NbB1mOrSmdhuuHKRKZjqjzpU8FUs/VvfTGjvbjjvAXMronh93DptcE1YqDyArokdpyFzBJK8yBxsO7H8B+NoyZG8DAAA=")} +}}, +{{ + {"vert", GzipedString("H4sIAAAAAAAACuUa/XPaxvJ3/orLdKYjbEwR2Gla2veGAE54tcED2OmbjEejgGwrBYlI4rP1//5270N3J50wznP6S2cyDrrd2+/b27270iLyJn7shwF58O8fFuRuFrpJs6R8kKk3Cadeo04sNrryJqckuv/klsmfJfyf/Eo/yRGpn51Va/rskX8fAIJdrZETYsWJt7Ds+ptqrUIsnPSxcVsmx6RWPSuXkUB2enezCAMvSIAEwADDmodTi8IsP0isHJEKoeTLOGBgV1fYnQDqj1mGl26Q+HGMShlZ1U2sjsjrs7PGaxDwmJrio31LraGM1G7h15vGmzeva2+QZ+Qlyyhg5jki3mZRt1JdT0i9AXRhXEjTLD2W4iRaTsCgiRtM3Wh640VJL1gsE/CC4phFGPsJ+LNZgs8GCcJo7s7oxymBmfdAH4g1S26SRP6nZeIRiuc6cmIOJIhogDoAEm/TDsNomgGdIkjw+s6/I+22cz3qOpeD4dV7BZVZ3HVWoIq36QEZsDO595IbPmDREGOWQhdI1DJaZBn4dyAaYzmZOFM/XszciTcHxh88sEkSf7TPbpt7EcfeBuh7veAupGaqowBX/sabXYQTFy1i0dGE4Q29OJwtcbiCIpEFYvaCqbdBWZlGcuwcwohFkILX5GgbAGKIKeiVPJuqnLBl1MJInUJ+KJjD7YbCW5sK2VKTaQpS351H4VzXdMa/KsSsuOIUOsESE6rAJv29xXUCy8QkH0rC46LTvem1u87o+upqMBw75xeD1tgZd38fXw+7LGrvvGTycAOR2Ioid4vicpdZsTtfzLyo3kEOzB3ejDo1dYjuIrCfisD9LUQGaM71xcFS3WwrRPMqJbZcKWTyBpa23UtZuo/brt6xqI7LFXXjd94s9r61eSD/nH4LE20OshBEDw2uGiZv+FN+2mSU+vZZ1O1nUt89i3r9cOpytZ5aJbHlWhnvb2DTKQRu9wF3CARlSzx8gql/x7MKqNPJJU7c8SBilDD5sgxxF6ZjsKZPWbKOvLmLQ1EKOmGYNHZgiVsKxq+kpuSOgoSNs2+rsDYfCQY5ydGwD6WxLaZRP5TGLqVxGP4azfvI9l66kU0aqnGfWJ58dxNm5ymSbpvO1bDbHlxeXY+7HSFJ8dKnFFVqVShCmjJtNMBx8XKGDsUvC8MU/pWZUwPcf/2JF1OnJvtW+A43pzAiLF7GbgRKw6xaM/34Raowbg3fdcdOe3DdHzfJ8TFHYb6g4hxD1fWEVlK4o5THcU5XABbENedJ1wG3I2PeFMviUTc8l/p9a+RcDUa9cW/QTwsK6UOw0RWvoFSucTONBRPYUrw+VWLyidApYlYhWn3E9SnSpj8YXrYuzLr0aclXoEke+PV6GBg9T4txq/+u2x+b1RizKrRADwP06xUxsTJrsgr9KXEXi9n2MowWD7h2wqWpsMdKWaRfQYjtP7JAbj4drEimKsp72G1wD8uPHRfGqKLDYRFFibOmQWWnjBwXhNHhrITbKWXebKjM1KHjImfn2T0WeUdrrnLJ2WT2jMUPNLbmXFUu3R7YTo1+6/X7vf67fPP1OfRpoOcAa7ZZaV3Z29Zv3Y7T6vcuW1RuBOF4rz8CI7d1Bkqnydm0An/OmicuoViICiosD4qr9Vp78CRNHUlb2ypFsbXtoRl//Kl2mw2rIv2fakzmbnKKLvwPUr50wTobwo4KiC+CI2ND9ZDhM8RDgx1nZKxYxao7O7aFePGxncoCdkLvAuJZe1LqBmdIDibgLrWaysYPViN/5wEz05y1fqoiO9fPuG2zqWUdZ6PgnMAMs6TYRSA1a8uPYSQ9fsqxsgEsy98MEdbUWtYmN51W0IJG/VAadjGNxqE06iYafOPBSLNoV7CyMXWIfoIN1fNDjfyQXV3Dzzr928C/Np5ayT7yBaLZrn/LcBbU/7nxXNgXPi+8zR3i88L72TQM4f1sGg0DjZK2Wr/GQqcvINnZC9B4/QI0ftxrocZXWujNC0j200vE4YsEsymaS39frmWVx0Epl7bT0w1vwP2ymgtkRYMYR6Rxq66DHBQVv1XjwIRRv/17rUD1j//wA6E7Kk1FZKKJcBW1rHSSbjSLgSGN0o2G17fVTem4AHGrI24LEXc64q4Qca0j0hMg2kS02yNQsLCBoCaYg6LSDNjOCRS8HADC8lrGSLW4aSwgrzV+nIc21lTbN3oLBhjMF3KcebuMjm+aWrDMJAWozXw09wxUdIhS+P/G99bZLkABX0Xh56JOYuLOvciFJksizL2pv5xLlLvw/q0be3sRWtNpc39PxLshEOdDGM2mNUPfJWD2HlhdsrnovXs/vmxd5ZFnGGR+cH/pLq5vrtzInTeVxMKnv22N2+91GcVV23QbOJ/cZPLg+NM9dqUCxR9t1jHlO6ss6lOkeuMiL+1RSLu1S/wZYA3u7mIvEfdhF37gudF5eG+JxZVmkTX4nTXdAhnCAU8xYRD+QkBO6KlNGiQVOiW9agPHw9KKEpYueZzgqXQK7gZTHbhNU9RkBn2qZXGkE8Ear8LkoOBQxhWBCZKmx/TW+0CtMECTxAtSUSBcscA9VIuOF8Cy3+oIu7zN5u7G2mc3RSG2wkHXVLYjKLRSnnjJtFlYJ4L2kSKGzPJ3mjFGX5Zu5E3/QTYxWedpU124W++l7OQAlXG40IAbFTjEpK6Bt/xoFYSnqx6zM0NITcPyvopQRUPXqnzqmg6HMZ+6TqeogHQK16PjzRK3o65sFbuiyZNxAn1wopL5bwV/UBP3gsS7j/DhA94faVpsyb+EgWi1BvA1G/9FHeckcUMU5jxhOm1RDmlFIUiGM3aQnMSR8gtqYeVaSjKhJsmTwOFHiV8orGKFli6yrntedN2Ebw/Tt6lI7n6KLcH5RJApG7VB1BT3iMhftEM4IZYQ4ojIX/S9jtFmSO5ZipolKnBTmV0HptahU1k8CbxX6CAeLCLvWPGXKMG7aXzEZIn4/kHQxoLTMFqmL5Hy0atqLTiwmMiknztzbuFlpzMetvqj8+7QOR+8gxpj1E2TTIVgLcqpuZMkjMqlP9UzVphBr39LDAoM5d69oNsuq150dFui8x2xGLeu4SobRvGUhiKNTJwpPhQ9KdzG1aldD77itFrt9vWwNaZESys32kKVwi2xwrzoMBpN7fInY0wtWRcSN3qAGl9lpF1lcHGUimvlxA/uNFxrZXGuZrvAogxLb1Zfc0cOu+1u76brjN63OoMP+47mGQ8o6fYe4MeLkHFi5Z92No/a33SH4+7vTntwMRjmK+FJOEOzCh25dnxUGFsCGwBU3sbpgPSVnByuw/ByZRiyZZnOrrscLNQzBNPXb5nxT758FyeVxWujUbc96Hec6xvy1197egD11Z2ds5iYQ77/nrxSOwE6AC48Hww/tIYdp9XpZEWbUW1ZdCpeabuT2fWNJdbzq0wXROfBDs22+Xwxj6BjVWZ2DGpA3EGfx6jtComlB8QKW1NPZOJqxNOZmlHyd3DUSviahB1b5HvwHoRYL1DbbH6YIUbYgQhFShtt+c4SRnmY0OE9TynTa0qrF+TuTLU7QnZsoKGxEwLeoVWI2qsZ+l0BpoVvcmqVuEpp26ucAmVh9h5YfQ+shkdHKhntsy4OlvAIT0rPBORtqaEpVhTRml32wFRtkMu3++iyUzwDqcykTBssYoinfIUqBKkSNBiYSgAtRCEsshWMsR/+zrMshSM/eElDSzlxKUvPjj8MRr1Ol1XdK0j1HT/yJolGNVu4Q4EkZSorohxB6R0mlviuKATLUGQCf/JvcoL1zM/aVmpKpI4MfYN+inbmQyUqVppm0fxRGMeqaIJBmdlbkFlL1zj0EadMH4CoHj+w7KKNYB5BZUaty6sL2K6Hg0tnOBaUNDuuoXWwqUHowTSi4LtZ9kCefkHd+TPffYo2CUrZ1oS0/y8p7QPEtHU5bSmoshPt2cL57kyl1vfpbD3EajClVkmXkVaZsOPR/LHZQdufcZdLJbqfpS+sUt6cpSVPJuFLBGY5u3of/weXspq6XDEAAA==")}, + {"frag", GzipedString("H4sIAAAAAAAACu09a3PixrLf/SuUStUpgTEx2N7dxHFOYcCPKha7wN7s3tQWJYPw6kRIRBIGnPi/3+55z2iEsY2TPfeuPxg0093T09PT0z2tGba+D8Yjf+ycdgbtj1eDUeLNBzez8dhP0q3v/UXmR2kQR7bqnxw/8m5CH8CiUTDe0gmlX7yRnwwyIDFL/EEYjyzk8kAm0WniDwOC8iW4/TJ1xmHsZYdbsygYx8nEmfijYDaZOnf+cN8ZDgfpMPH9qB/c+xKGIk68jEDA54fAn5vVnMDQm/iJdxmnxW1MvCDqBFkrSB6FacZhvALKm9wEfpT1f18+CnOaxLNoVAw2jm8faQwgjr3UXwnQGK1oIvK95MRTWiAVXnjjj2JrYX/ohX4jGjVnWTweGyDTm+TSS7xJapT7kyBNgzu/oJjQJIiHW0QXnE5AGItvXUo3TkvOn1vk+xzG0TnCIg4MwzsYBVgI/zMvGvquOugVglLi0CCRfuYlGYBLAVYXSnU7GumVMJKJD8ocOcPQm0xdlwHt8KZLzg+OLOQtlCrObrXi1KrQ9gMj315M1+wVjlwGU0uwAuNYvV+/Fy2cldlSB7jPy2ziLdxVclM6hP3Zxb4K3srOflW0CcT8xdTd4bTLChslIcKxJoz+HzMv8Uf/j2Rik87joup4S39TchoAlat4qlUu1MqeF936WjXMAGhqD5n/NU7C0WUS/4cCCNFUF0toQQWooqB3qwx1TorjlKHOBYpaIVBYP1p+mHktdWar0BWNH2MQ6tVdncynCn4hIj6PMv828cLDrWDsaAMMDPzCBYQCxvo5Lf9ZLWckgTOXi3OH9mmJfEgpckaMlgGRkygr33arBzDmjh+mvtYIEUmeBBY/SPhCZhUpNHSW9b7nWddFeLxefw8Vzr2b1OUt73AyJWtvEFTAlh35DaSCU87lTJQd+Q3rSlaZIbknddTOUcEwEZv+IKVDUKk+cbjvcICYsnC746Z/JJlbq+462w7vbAsVl+KUgLilFP5o+4b2qr3mLVCdMMzP2G5b7uJg5DSbg6teo9s/afcGJxeng+NGvy2MTMWJZ5nDqHnDLE5KW3+iV4ho1/02YjhH0OoWrYUG5do9Jcvu936YA69JcLYiFsPWNVhlwShG2VO4kYZTwKe+rK/h7GR+qRRI4/Ky80lKI4hQCtRnQoesoksEBoAUAzmEcSfBwlXct2pye1OhiPQrQ+NlHtEllOl3rBuNZvO617gi/dm685JlEN2yJu+Q7IBSEIzn2M5xjDwWtpDvMOul2lhplZgsEtKMPm/e1roqysOtQm0Ulh89qt2SkKIYUYUMDoRNToUdFbQe6GLV750eX8VUkx2XFN16k4mH/WATiDzDrCSfiFgYmnSgYGV8ghFTPD+P7nAZa/nT7Mt5NI5XQz8RVIcK47kJ1D3p9B8F+vXs8vhRoM5lt0uB6JA0m6d+RkVJGD5J4glKoz/1YD0nsr2DR6YlFAeXexjE0I9usy8urxbGizhn1Kjr3FcXxBXPly8LoKWtNNl0cwpMuom8EMePOl3GCIM+aLqKHg7VV8H7I+JQyCOyMA2gur12s33+oT3onzVaF78aQ55CYBL6Sb0lu/nem5qKoUNNY8o5WBcCSzrYmE7DZZ8QIPwdB146OAHeukDGC+nKwBQLJ6MUEwXA9YHARNATDgaSEii4SLo5baneg+MFrvTubk1QQGFQoo9ImgJRV5yQl5hA92coB6IqPyBaZ/tIaQALyvkpYxQrzJZZLKi2RBjYrVVIezhwbMjVlpmJKZDzpZ+kU3+YQVCcEzSz/9BeiqoikJi46CwiWkSaUZ+wG8oIFHX2fm6g3WtY9yqSaa2qC/BoJOx8Jewyx949DofduJF2IyLi4J7NEAURPaO8UJgyD8NgKkWiPlGRmEKyq4CBeT83Me9NREUs0DPU1LpbALCUamszXGJa4MRAR0PjBBhZw56o0jL7gj6pUUJCFrCXaLaIniu1c0WtdeGuUuuLJPsSg8s6/RIMn6TXLDCP/fG44RQqiAheCeBxMeCSA6piGRAZqGq+wwjhWkLb1vV1cM+Nh1XpEj+dhZlu8mgZEbdBqcy7t81aFSsFxTFWKCraE+KvnHnJyDHkKRYqHB147vqorY+PijIgueW+Oi/x+J8SRQkL8mT2/qAWzGmIBD0i8SxRbFoLVgKt8a7z11+OLPoFVQ2KtnjRMg+1zEPd56HuKRQIwWFCRP/eeRA4i6W5bTEn8QiQ+TebpgKyuiBLN6qDLIPQ8SflmSsUFRgJv8S2wzCMUz/NiMB5jTbJxXKyzE1yDXMUZy7bTq+3XHV9ryislCp0RQSWKd8/OPWDA/nw5mC3rjzW3hy8q+29hRItfjaaXqNZnH4PW0IAaeZPhRDvK5oUpBdEwVfodj8eZ990+6vQ7Xg8Tn2hEYIdIrY6BDpTTM2oRlfIdrFkQHHkX3lTGm6DPBkOq2QUB7QdpQl00hgq5+UmjIe/gw6Tzxr7rLPPvXXnF6XClVXpX2XlXNNlKCfBsvSCuQfqRzvzInaY8DbOVX1TQuIMboSrvQ3LalPMCSu6QsGeoVwkTl2hJM9XEEnZPtDPH2RJ2T5YLx4oLXhHz+mj42DqJh6pjFHrgdsCZW51pLtIHayPiBUsXNO0EJolHfaTCivMjgmLT59y3CwFN0uVG5lcRMKMpQpvj5L+ZO5TmCtl/eO3tfL/+lrJnUp1Igw66nIJHHJ9LwDvaeDbj4FfK+BLSX1ZAN7SwLdz4KsXb/a5zz4P2Ocb9vmWfb77Gxd5IWXTAA2u//klP28WN8PVy5Z8oWmvw9xGVn5lPDfjj+x/Xa7kwYZHcDNcvXmlqdjaBHNvNz0VN8LVu1eaii9lblN+7kr7ugmv124jN+H1rrRzG3R+DVslKdttzouiC7vdeL7NkJTtc//F8142YJ+/z5+7krJ9Dr54/lnCl6cFLzTIWDfEKN6lfGEQpLhtHJa1sn2kRjSOJaSxNK14hZycpVHFR9xEo5Y+WBpVHNGVja7XpqULljaF0/ucNpWNVhKI1Q/MKJIngB9LKlje5lgztlQTmt9Cy78lxcDeoMiHoBvKPehvDfzNGYgVjdvyECNqrZ+Sg7DNCVsy4tuc+ArmxEhV/PUS6Bwl976PGElFFy2ziGvLDQyldSNnbt/HWbHj808nQEZFcYU52/6eBMiz2Hn1BMhLhfQ6CZANyeqVEyAjm9P8BOWyhIJPJrl2AuQlzK5OgGyA5xclQCwm6KtIheT5el5SpGjpzmdHvi3e3xbvlYv3t0zNP5apecmS9uqZmg15ARvO1LxIZK+dqdnQeG44U/N1+LwHGx7BDWdqNjwVN5up2dRU3GymZsNT8ZUyNc/1RNfO1GzAiS7I1Dyb9XUzNRuQTUGmZnNhkGk3XmozLJmaDaqIPVOzCRWxZ2o2qCLfMjXfMjX/VKZGXsHDz82eH3fEgT52lK85u/ExRvGjuyCJo4kfZewYyjjxbq/oFOjEI8eVZ/9gYlD9BxbiZMSP4ITxiJ3TXX3lD+NXTC+gDpAuocoIIil+MNcEtwLyg8UrGCc95azvbYJ1pPgk5hHhEfb3nFk09Ya/906P22zXIbm98ZWDw/iI58BhpKfxHNZ1mEmkDE8Tk6Udz17V35FDYQ/q8LfOT07g833jskgLgI3xLPXJaU6uPvSDyun09OP7+CYIfcdldiKe3X6J/FScw+rGZ0zA/LPLdkfg2+IM48YkTlO3W3HOhLW5iPz3QTRLAbn/R8KyRgBdQRQB5UGFaA/6Kr5zALyvBEhAlceLMLr28Eiv0cS2g3d8RHL2TFGcyoaQFw77U384C/EA99P6yg8Zq7zinCR7M/UDtNdCjq5ClJDDPstz5Me91kljOk3iBTtFnjKeOAsWnj7Q+wSilJ+nR6+NuIA7xAfcgSWh/vaAfDl4WyfHB+t1PNin4NQ4DkEBiP36AXER9ymB/RI/rGYMyhBvphjWxJjt7u4TMxe5SXWBg4bLnb+Y1t2dH6v1d1CCHJdoDaAmVb470jimPNQJ3/u0dQQkNBESz5s2jqtLp4y7EXia9gD3pspCStVbwrtxgprXAiBgY6NIhM8VnCi99kmn3bw6v+gOWu3uxXm/TYfj1M/a0V3PH4e4gxdHvwbZl/fB9CQIMz8Bx4COUa9wcCbBtBnPoow/j/woDlIfL+Sg12vo1xyguRaIhpw5KbkZFmY4QVycOqOT0cLtgecPX5bwhci3trurOAOAf0w3sXBxIUIiUQCVI6GmyI6PNu57+Xi7lW5jXX0BqaAIkOVt3gzHHxNJEQqqScyho1HU5EAv8qDNE+N3pNhJl5ajoWD08yC8RlhmjZZ6X4Mra/IUNUC1TppxZeNZUqo4KnAlP/LGgoGKREeF/1PXCfYlzZLZMHP6mReNvGTUnyVjb+jzvWh+CRvRyWkMrYDGskd6HJo9yNvVyGOIXu5EZgz5MyyEqVC3nO2d+JkXhsFQvMg+HIazlLT4wAa/2RScwsoK0wWvz3Jck326uZ4/irDnsNUJ3fQq7R1bB126ZZxWORd871xMdarmXKr7MDVUEhULahdw5KnxtEq/89oPWq15jxXhhYtcrF9dRMKrwfBaILLCVZwPpRIfXYVXafZdafDTqrpWfOCcdDROdobqXYTsxDZdojS4DszND5KzM8YZ4+pMMMXqO3p9R9QT0uMg8sImu8EGYMvmbYdsmMzS+aE2rs04ypIAZxkrOBQGuXN+enYFfovzr38532HBceOqeXbePSUFYCZOLnq/NnqtQaPVIpvGaVVTW3k3BF4RorIrAZFJ6jbjPDR4+uHI2avW9msHP9bfHOwd/CivzlHVTPZAWWNUV8LVB1Gu90wOCWFGknENNrbNpkq5gK9GLiSy3fiBsoLCdrdx3EFnsMdvAkGBwbD9Qq+i+5NfnzElSafH7vNQklhdwc10OLamPthbRFiNSaMfS5LvgnNJ7NYlsgslUXcfR1URiyHxbTUGKYDQUtAHsvgpyTmRV5qX6PVdTAnMgSsfiZeDFGUrH5kjLG5Ha0xuSKx+AJajiw4NzeIRrfAmNy3QAsbYUL0hlN0MZVwIytYboJlbRguiATLc0vfPr86yjo6ylQxdoyW7yuor8cVCJ+G0NVVC6quqOt16milLqDvm7nxA3kqHj3px4GoAgUd9uZ5hcnNinqMRfCM6RIQItCdEgI87SApxahsN6gU+kNIFRcC0XZUXDqRJl4JZJaso6vYRwVWZQmWbK541fq0qa7yVCBtiaf0NYnw9N2jpRNKq9E+kc7TvSihlLfdk6NRotvtXcUT02WURf6hftoZRiXLbmPuOero0DqIzE28NqVcPanrpMd1Y29NLmwR23yht0Yn9o17aJqW1fXklFWUKfJkGudKD9N45LtH7qHhdU6lrleBfuyRuTmk2T0DnLmbZdMZfNtSubmOKdNbqbYm75NC+Szm5olxqhwpK7h5UYfhFLvSS4Qdx1Zxyi9jdQCwQz1zOOVEyhneDcHZ3aG5f0PuoQuMuqj3nmkwQvm0Lmm+IhaoFt8I+y8Rv83v1UOLvqvwqGxjAKmoNEwBU+lh0K4puedGNKLqhRVxOyq6c0SvFP5cVdajA3uaKaocmPnfouYQ/tHtX7Y+D5kXnoqfC4oCw4VK2B8mdep3jdutiYNkcAunS6aVtCzG07kXvfaND0AyWMrwbk+wm6uU3gajJN0T7YWvo8rhXwNz0JrEhvG9fNTqdc/CCLq5Pz7rtfr8An3v+PW6ObdQums3OdR/XEjsRYb9syO335/0+OmJ2XG7gbKiNzuVZY3AFc1S7rDGFYMlx8c7EXPgkXka68dBxpKaOB4NW/RCA1FIbawZTGDblJayHkLzSW6VPhBvwKDgzcitX6FXFYfDXGJVwWFvQrdap/CA3vE4wwxcGICIAD7f06PHIejM5vVvYMgo0umAEZPmgedbodtsd52c7uXkJLyUcwkDlJPU0a4iyZD6kKU3dBlaoscRX27HLPMwBjLxZlAQ1WBo7HTFC94pYI36tXt70qBaB7DVMJlONTTHHwV+jsDDoLGxmEfoBYYM3suUiDbJ9mL/yHSWr3e/GDQ8sjwxxuSaisEyISjD1q+OUTQAhCG64iSi0XRZynT0UK5fam7bsjl33pYmHmrOKg0BkNkAB9v0IIasJfV7y51v6fM+fb+jznD/nJ2aBXSS85EyhxpnNUBp8Ej5ycJyrpb329hFrKwQgWVHNrWChqk58AUGHANOpqsdNC5dYyBliZfdYxtUFyvhX5sZaFEkzFZqtVwiZZlX2RTH/FUegk/6onphI5ajmgBVdnl+2O+fd9uDq02Wb3qf8vTPywUf2HWJe+oPLdm9w2ej3nRqLEYoBdo3UIdsxwCG5avfaLWqxBs1rUKMuu77ZfoEsMSTg+v1mtPHZ+CUHDkpM0LrAmPEmF3A3otvQXxerFdga0LJc/UkcZ19aQZo1soxnf/DK2P4fIvESRHfwBPU9bxTMlKtnxQ3CDAFUxoAVWzakmRMOT3fe6U4mI1JmX6xZDBW7rD3KNBYEuc/shofX4M88Ztr4C6r0Zw0IPnBUK+M/YEkFRj1X5ccxnEquMdEXBV/jnQwsYZ5udbIsW0g2N0XuNqBwZEKahRfkNQzZreGIZRc5jY5ML2o9pqMB4GW9AYgOdNq2sXE1gaiU1ZTsOtPKvnHeGI0CfIP8q908L9rRBSUytlH/q/batZ1jLg+oDKLMiWYT4lGlZJvRYpGdf+cs7U8wJTJXtUy7n8nGD5gtx0WqAe4THMLHzyYyFG5v85+YCJxfjiQHJecm8b3fGdP9zjXdixXGOPicE5yA1WQNqLzr/TOjRksg9M0MQb9jpBD6Zo6hbyYZuJ2g8xOaRirXJZmGYmZD6YyxAmC/cuCUpMQuy+8cNgjD2cQxdvhxZmhEqP3Tiiqc6ZJqRUT9OdmAk7azmG16iS8zpRo+hid6kdIS3cY0DG3FROBDGKJ+r5ub6GNyos+yE+w1fFWB5jJdwN9SS8+jyE+UUd5RNZsqndSMmnLGJ72YZQSzWEL3ysAq1lgVL7s8WzCyIyiXTOQLflJyRzRu2HkyEih9ZRkCpaw41k4Za5Cx+og9SS1u030eoETyT2tnc1YMCsaNxZKcq4meF6Zrik9MqXkhzT6vkckporqa5hpESLaniIiSz1HGyZ7K2T4iJq+sjmg5P6K4yU2NC3EC0KTkEnpkVpaUa7Fzu9u7/E2uJzrlNaAInEfh0qG/zufcDIZDukQc04I/qbcgy3/7fOg8HNoQIZiCaUKgzoGPoS9pzHClsoKsRe40CUaSFmfIAGCU2CsPEB5iBc9UKtPgcCsfUBhl+pQwKskv+CkNUTb4FfmTIDrG7EzKTCqYHf4scQTPgEVEQ98FPqQPXNIEg/XDufUz9tUlQAFeXs4rCV+HVCmrSldxU0sO3P4MlQ3fMZt9NoG5ybGB1/LguoAK8Op5PJBdAfAeAjP9Zt152BJywu6LByoANvwoBqoRt1B1R5Yvi26wAmhDoQn/Drfwf1Wci2dE0EsgFZxRpUqeHKUEHuioAYdIleu2v6BspvQn3JRRRo4ZAfuMICh4ZI6Af1ZbYMr2P7QB0m1xLlHY6pSte+TJre9jgiiMb3EpYD/GWF3S6wL440Isf+zY4o4rkcsm8mIdgoKiv/T5RRs77lD8kiaQFZzjKkJ6eE/6hXlL9HqJMwXNcArISsoiLOST2j0ZU1Fsi7gUaWHStUnfrM1JT2chJ23lACg/8UiqcS7g69xDPwjJOQDxY6LVBf7CFhFk7U3JhvfJjrcUeO8QbUYsSUDVA6VDAosZefNRdAgP0f7AzxxIxipacxjf0B6WuLGhtfgmSe0NTsZ3sxLZkCCNVfG3JWg5L8HDnPz7QvnZSkJGSTUy4X2LRzcQjxJXeMMRqTH65my5DQcn+lxxJdPilU/dmFIy0k5zE80aU+NfzbiyaHYmwtkZjWdru+Tbo0EsQQyF4aVsGMZYMfMVWDwP9bWTCYAtsJJUSYuQc+vr3xYkK7HQRsPkVav61x0pr+T8vyBYzuvSWvFyzp1aI2ReKaqvJ2ou6NpzAmeLb/uc2HnlGH2LjDcaGduG7FWCY/JyBL5k7Lg4jDl35JC8OeGm8uW6deJo+dYQEaLd+XHR15FvO+nvBUrkgq18G3buNyf522pydNgb3mw9b3mZ99vuZ9KOfBmMYjEp4Y+duvb96b/+YtnFZlvkGHG+gBhKTxHs6g7jS//5zr5CL22drD2lH7nmuJepV9U+O0d5F0pZHwxSdQU+Yj88qHmsKvCeAszzxBX1dUlF+f8Xi/Kcs7aBAAA=")} +} +,{ + {"vert", GzipedString("H4sIAAAAAAAACuVZ3W/aSBB/569YqS8mEIpN0qby9YES2nINHwpOelKELBecxDmwOduA4Zr//WZ21/auPwiJ0r6cVKV4Z/Y337M7dmXp21MncDyX3Dt390tyO/esUK8ID2RmT72Z3dKIwlbX9vSE+Hc/rCr5t4L/k4/0kRwR7fS00ZR3j507FxjURpMcEyUI7aWiameNZp0ouOmmNamSGmk2TqtVBMhu70ZLz7XdECCABhzKwpsplKY4bqjkQOqEwldxoUCcJog7Btb3WYF9yw2dIECjCkVpRaKOyLvT09Y7ULBGXXGjTqg3hJXmBH6dtc7O3jXPUKZvhyvfZe45Ina01JTE1mOitQAX1mNt9MpjJQj91RQcGlruzPJn17Yf9tzlKoQoCIFZeoETQjz1Cjy2iOv5C2tOH04I7LwDfADTK1YY+s6PVWgTymeZ6cYcKQaRCBoQQjvqeJ4/y5BOkBTLeuPckk7HvBp3zf7wcvRVYGUet8w1mGJHPYABP5M7O7zmCwpNMeYpDEHKWkWPrFznFlRjIqdTc+YEy7k1tRcg+LsNPgmDG/V0ou9lNOwI8O2ee+tRN2mowMiJ7PmFN7XQIwpdDRnfpR148xUu11ElskTOnjuzI9SVWZSufYY0Yhkk8OmcLQIippjAXs+LaaQbtgzN88Ut5G3JHu43VF6J6mRLXSYZSGP32fcWsqVz/lQnxYYLQaEblHhDA8Qkv7dYJ1AmRfqhJjwvzrvXvU7XHF+NRsNLw/x8MWwbptH9y7i67LKsvbXD6f01ZGLb960tqstDpgTWYjm3fe0cJbBw2HMa1CQgcojAfyIDj3esMlBzoS9Plka0rRMpqhRstRZg8g5OfbsXOQ0f9512rlAbV2saxjf2PLB/tXug/5z8ChdFB3kIsocmVxObN/ypPu0yir59Frr6TPTds9C1w9HTaj1RKvGRq2SiH8GhU0rc7iPukAjGVnj6uDPnlncVMOc81zjxxIOMEdLkn5WHpzBdg5o+Yc3atxcWLvkJ6Zhx0tyBElcEjo+kKfSOkoaNuycNqM1HgklOchjqoRjbcgztUIxdgnEY/wbd+8jOXnqQTVuic58oT366xW7nLZIem+bostsZ9kdXRvc81qS89CmiiNaAS4ieto0WBC5YzTGg+KRgmsK/Kguqi+evM7UDGtRwX4Xv8HDyfMLyxbB8MBp2NfXk4Y/UBKN9+aVrmJ3h1cDQSa3GWVgsqDo1uHU9YVWq3FEio5azFYglec1l0jrgfmTC9bgsHmXHc62/tsfmaDjuGb3hILlQpDEEH434DUqUGuhJLhSRFSHqMyEnn0idMmF1It2PuD1l1gyGl/32RbEtA3rlK7EkT3y5HQWCnmeF0R586Q6MYjMMdgstsaOA+nJDikQVW7L2nBmxlsv5tu/5y3usHW9VdLHHm3LcfmMgdv6kF2T96WRFmEZ8vYfTBs+w/FqtNEcFGw7LKArOhgZRnLBSK0mjw0XFYafIfNgQhYlLtbJg58U9lkVHGq5yzbnI7RmPH+hsKbiiXrI/cJwaf+sNBr3Bl/zw9eA5NNFzhA07rKSp7FP7W/fcbA96/TbVG0m43huMwckdWYAwaXIxbddZsOGJaxgXosAK5UF5pVlrD1+KKTNJtS0ixkfbHszg5kNzkk2rMvufGkwWVniCIfwTkfsWeCci7FUBceLkyPhQfMnwAPnQYq8zMl5s4K07u7aFfHFwnMoSdrHdJeBZf1L0gmCkEoqIu8RrohjHXY+dnQ3CivZs5Lcq6eT6gMc221qVeSKB5xh2FGuKUwSiKVv+GibF42851iqQ0+tvBoQNtYoS5bbTG3SMoR2KoZZjtA7F0Iow+MGDmabQqWCtYuuI5wm2pOWXWvkltbGBnxr928K/Kr61SufIV8hmVfuV6Ryj/3/zuXQufF56F0+Iz0vvZ2MUpPezMVoFGBWpWl/ioZNX0Oz0FTDevQLG+70ear3QQ2evoNmH18jDV0nmomyu/L5ey24eB7VcOk7PIj6AO1WxF6Q3GuQ4Iq2JWAc5Kho+EfOgiEOb/F4vUPuDvx03th2Npioy1eJ0je+yaZBkpymMDG2UHjT8ftuIKrUSxq3MuC1l3MmMu1LGjcxI3wDRIaLTGYOBpQMEdcECDE3dgONczIIfBwA4/SxTiFo+NJbAS4MflyGt6eL4Rr+CAQeLRbrOol3FwOtFI1hmk0CUdkpTTenMwacNMOi7589nzYK5Jqape2ianoi56H35avTbozzzHIPouHd9a3l1PbJ8a6ELhcu3f2obna+yjvGnrNnWNX9Y4fTedGbZ6YVGBIovVii4UdlEkp9csqxPQfWM3PjFvvg5czBmeHsb2OEejAu0+tqxNyPfe2BuwlF23O0MB+fm1TX5+XOP38QvgWqix9rytyCbMazN1VrPL6nSGrQnc4PWwGCcEphn1+Z07izNmb0M7+NeBinP+ka+CHqQxj1XzHPeTeIV1pEoU5Lp6YdOWOUpS5f3fMtM3hMoPTf30kIa0lndSmysRHkI60QKZr4gYjIWLbboCjcpqQuhDWdp6h6atofWxN4twkiPWtzZ8QxNtWcK8rwtqBrBEKka2BdesYKqk3247BgtgMpsKq6TNNcEXOhaQtrwRMPMY2wF1YJ9Tsxak34ATAsC6GIRgq/htJVWdpuCiqNAqoSkHggVm5cWDGrObGjsyNvk9wYA4VrFJoXkfOXU5LzBryZYZeRunrx0pvXkh3CekMf/AEsvBahDIgAA")}, + {"frag", GzipedString("H4sIAAAAAAAACoVUXW/aMBR951dYqlQ5Fc0KLd2mtJNSSEslSlFD2aPlJg5YC3FkQoBW/e+7tiFJCWN5IOb6fpxz77lppJIFfMFFgmZ8OktRFAuaOY1lwiMh5yhnwRWi8RsLxUGjH9CYuUnYXWYiipyGvkpp8KfH0mw2Fi8Pdy7COikKlclCH8ZJsgzd6lS4ZV80UbvTUa/rzkVbH1rXnR+ty+9wttCZiXUaJiiSNMgwnC1jOd/mgbO9eV810YUK+mZSapelTFRBp/FZkDB05zS7QkFA4D0AQzbhbFUSjcUqNWzBZTGjoVgN7wf+YxKJo06D0XBonAzzbveBQf6EUan7ci/FXFXyoVMMQ+wlyuHvSCxUe7bd4gvFNWbJNJvh3XXBBuv78zowe62o47p98w9v1ZTDMA2ylZBxuIWmaSosfkZlBkZAuNc9GJYexi7MXm/eYZowkQL7f9pRSa+CNcATHkEYefG63uPEI37f7T3/3pvlgs7TmMl2r6T5RFPnqFcqDHKeTLXvCUtCHjVyKjdgUkzaKCfL3KmbWl9s0Bayo1xemL7mJIh5SrYaVlRefY+4gzuv90ye3FGBsMRmtqsKqQwb9V0y9vxxAVZVh52YIlzM6I0uWFfEQsKAdut7oHDpdnaLMraG8bB2DxfVm2jr/DqxjiEBCy5y2eUF6fbd4dAboJuD3wt7ZSmdB1SGRXYe4doe2Wv0Sy21elro9LS+aeBxAyL7qR/VBYWorvb3Sh7ltRWkFmxd/aSqYUuLuPzRsvz8WqdAszlcZ+/DiKvC0PmqeKqXh2rngofw/eKJmjqaxuQeJLCbuZIDthz0+Rdkdr144QUAAA==")} +}}, +{{ + {"vert", GzipedString("H4sIAAAAAAAACuVXyW7bSBC96ys68IV0ZI6WzEmTAWRJTgzIsSDZDgZBQLSplswBRTJkaw3876lqshduGg8wt/HBJrpeVb161Uu5FSfM81M/CsmGLf3tJiarIKJ80NqG/ipKNuTFX7/EZEP5B+J5Lvx98tl+lkR/lyE75gmIRzcsobMo1QAZWkJW0fqapuwsYLhcniHxNUoCsAuuZOqHjCY30doS/nGU2uRnS3zvgQf5iEsSDPTcpY+L8JvT0GOWSbotXGyJBiILThMOcM3bORjmSbgsGo+DVsL4NgmJF9BNbFk56EqmtslvRC/KDHabdJw26TqQ+zUPPznEb6wKBeOchYoKyOec3l7FmIWpz49FwKmq2YYerHO6GQVhPR2sVXG7JB8clROCsUNsXcnYlwYNW0m4Koix+LGlCVv+jzSpU+efpZrSI/uvdHIhykMUF4wH0zin4ZoVzHACIFUfyYtzirdFBlDSOIcjZDABDgrdcXLXvViO0tx1r1xMg3LJ6xizgNOxebJNdLvAp9SEntMphvmrjR9C4tuQs3VCg0HLX5FCg4HAn1IgFBjt+2z9D3M9DwnMLCnnVVbTEXloFSWRUmZwlCEuja+O8zv0nLAgZYUkQpJqCFx+1fhGsoYKwyLlYu1V6kUJr99W78BgTp9TS2a+kmHs2moQqrCXRH+BKnjkLEnikugvtNm1mmG4f1VoPaOGNok7/VWrI1yz/SRx77BB+WaR946V/ki41XU65D2RxY5x42Y+NgSvWYWfLH9p95pVywzZnihdP6v6u2UX+UsyGrkP8+GXxc1k7t7cf3Kvh4uJumTaJNpykkejHo8Su/WzdQFlgtvjYoIe5CNkbWVWSKjf7lg8uxcsqMC7Gp6/iM3YXgFrPBjNLn2Djb44FT5l2t7F03nBwqW/AkGwsHd5rOFo9DgfPoigrR1Njn64zpXY4b3oZjGUd52Yhcu6MXhtB4T4ZiLb4CnpGHPazk1f6DLaF8a0ypQ1hQVj3ssbOZ+MJrdPE3fxeTi+/1ryTmHkCVjSG2OILMcdjcs5iqg4yjIBR4HNiVPOE/95yxkRTwJ1oUifw6g6qJpCiI17vGDogYGzwyiKEpgVKyr0QQUdUpqNURQBMjDWjq34cj+/G07vhrMmB46XRMgbAz77KmS+E6q4Htnu9rUR0NJptHQbLb1GS7+BabDdNViA9GprTu9iRz0+LTwalFcD7Cs09fFpRhO6GWT7fkP9kFj5SKIfe/26O4dsXpCT/rf+92+d73AL6k2AQ4iCH6vwbgl+NOCnKrxXgp8GLXkaAYyfapjAIb0D5yszFf8pgotXTFbQP3wRjO0HfRMrmv8JwLlqWAy07wzgiIDeGcAJAf0zgL3exNPbT58fcA9Dk2GsAqdSn3DxvUEfwpQRJ4iH7qca75Pe3IoMTnGqz/JcCbryPNTdhiXR7dqDKM9c1qg+Pphi0M6mbcwmD51EdBSiW0V4SZSmloraVhQFUOfKcNLYNs62bdSv7lm1Vwq3Kihbu7nWgTvTyok99foLd+7Yu60PAAA=")}, + {"frag", GzipedString("H4sIAAAAAAAACu09a2/iyLLf8yu8WunIEMICSWZnl5M9IkAeEpNEkHnd1Qg5YBifNTZrmxByNv/9VvW72zaQxJmdc2+k0QDdVdXV1dX16Fd2fvQmY3dinfaG3U/Xw3HkLIc3i8nEjeKdH927xA1iLwyyqn+13MC58V0AC8beZEcnFH91xm40TIDEInKHfjjOIJcGMonOI3fkEZSv3vTr3Jr4oZM0dxaBNwmjmTVzx95iNrdu3dGBNRoN41HkusHAu3clDEWcOQmBgM8Pnrs0qzmBkTNzI+cqjPPbmDle0POSjhdthGmHfrgGypndeG6QDP5YbYQ5jcJFMM4Hm4TTDY0BxLETu2sBWuM1TQSuE5040AIU7FuD/unxddjzsNSySdHUmc2ckvWfnciF4Qzob6tMP5s7D/kj0oOCtcOCihIuz4Pbqyj8d8edJ1/Pg0m4HvqRoDqUHy5NoIuT3mAj0Mezq+ONQL2riwsKRNTZardP3YSKkjB8EoUzlMZg7oxcKttb+AlaidKlOGMvTqwjy3eDafLV5tVNLnub1O+lua/elayfLDtdvsqBxoHLZpNytgwjf8xYI91EXgaJEyVQCBwaIwz6gFA2R6vere4rVr1ak7xvEIdCHpEJg2B7AG3Y77a75x+6w8FZq3P50Rjy2JnNfTdqdGQ33zlzUzF0qHlIOfeCKYElHWzN5/5qQAgQ/o49Jx6eAG8XQMbxbQLEFCuMK5YUEwUo7TBJBdATDgaSEijNHW9ip7Slem/9ZtWqtVqtLiigMCjRDZKmQBXELxHyEhPo/hPKgajKD4jW2j1SGsCCcnrKGMUKs1DqgzC1lggDtXqFtIcDx4ZcbRmL8+V8BZ5n7o4S79ZNCZqqKbYXo6oIJCYuOouIFpFm1F/YDWUE8jp7vzTQ7jWsexXJtFbVO2tXgV2uhV2l2LvH4cg2bqTdgIgYPJ9tIpZQE1JCYco88r25FIn6i4rEFFK2ChiY90sT895EVMQCPUNNbdg5ACuptlmGS0wLnBhghHROgJEt7IkqLbMvQME2SspWo1oDe4lmi+i5UrtU1FoX7jq1voySr+E0cuZfvdGj9JrWjUJ3MmlZuQpy11QBj/MBVxxQFcuQyEBV8z1GCH0JbVvX1+E9Nx6ZShe58cJPdJNHy4i4DUpl3r1d1qrwFBTH8FBUtGCPkzA6c6KxZchTOCocHfh94aK2bh4VZUBS7r66LLG4iBFFCQvyZPb+pBbg5K9VD6FH8D9TbFoLVgKtcc366y9LFv2GqgZFO7xolYZapaHu01D3FAqEYDEhwq+m9SBwyKxXI2Fg9uiIUP4Xm6YCsnpHXDeqgyxblaxfld9coajAgDYwJLTRD2M3TojAeY02yYU7WaUmuYY5DhObZRGNjq3694rCSqlCPSKwTPn+yWocHsofbw5rDeVn/c3h2/r+z1BSQl9luX7sppveolmcfg87QgBx4s6FEO8rmhRkFETB1+j2IJwkr7r9Xeh2OJnErtAIwQ4RWwMSnTlmpKrRFbJFGgQoDNxrZ24dMd1jOKySURzSdpQmMEhjqJyXGz8c/QE6TD7r7LPBPve3nV+UCldWpX+VtXNNl6GcBKvSM+YeqB/tzLPYYcIrnKtGUULiDBbC1X7BsiqKOWFF1yjYE5SL5KlrlOTpCiIpZw/00wdZUs4erGcPlJa8Y+T0ybKgpVk4Vhmj1gOXBcrc6shwkQZYnxDLu7NN00JolnTYzyqsMDsmLP76nOJmJbhZqdyshE9EwoylCm+Pkv5srlOYnrLx6dVX/l/3lTyoVCfCsKe6S+CQ63sOeF8D390E/l4BX0nqqxzwjga+mwJf77zZ5wH7PGSfb9jnz+zz7Td08kLKpgEavv/7XX7aLBbD1fNcvtC0l2GuEM+vjGcx8cjB9xVKHhY8gsVw9eaFpmKnCOZ+LnoqFsLV2xeais9lrqg4d619LSLqzbaRRUS9a+1cgcGvYask5Wyb86zsIttuPN1mSMrZc//Z8142kD1/nz53JeXsOfjs+ZeRvjwueaFJxrYpRv4q5TOTICVs47Csld0jNaOxMlKajKaVqJCTy2hUiRGLaDSjDxmNKoHo2ka3azOjCxltiqD3KW0qC60kEWscmlkk3wDetKmg7vI+LrdUNzRfU8tvssXATlCkU9CC9h70UwPfeAdiTeNZ+xBjaq0fsweRNSeyNiNe58R3MCfGquJvt4HOUVLnfcRIKrqYMYu4ttzAUGYu5Cyz13HWrPj83Rsg47y8wpxt32YD5EnsvPgGyHOF9DIbIAXJ6oU3QMZZQfMjlCsjFXw0ya03QJ7D7PoNkAJ4ftYGSIYJ+i62QtJ8PW1TJM91p3dHXp33q/Ne67xfd2r+tp2a57i0F9+pKSgKKHin5lkie+mdmoLGs+Cdmu8j5j0seAQL3qkpeCoWu1NT1FQsdqem4Kn4Qjs1T41Et96pKSCIztmpeTLr2+7UFCCbnJ2a4tIg024812Zk7NQUqCLZOzVFqEj2Tk2BKvK6U/O6U/N37dTIm8d4++/9oDs8P+6JC33sKl97ceNijuIGt14UBjM3SNg1lEnkTK/pFOiFY8uWd/9gYlD9BxbCaMyv4PjhGKPxjTedGb9iegF1gLQJVUYQSTWhA+B7UuCZgKSnD2sZJz3lrO8XwTpSfBTziLCB/X1rEcyd0R/90+MuW3WIpjeucnEYf1bhPxjpebgEvw4ziZThbWLi2vHuVeMtuRT2oA5/5/zkBD7fta7ytADYmCxil9zm5OpDP6icTk8/vQtvPN+1bGYnwsX0a+DG4h7WRXjGBMw/L9jqCHy7O8O8MQrj2L6oWGfC2lwG7jsvWMSAPPgzYrtGAF1BFAHlQIVoD/oqvnOAAACABFQ5vAizawev9BpN7AJw2Qrk7JmjOJUFIccfDebuaOHjBe7H9ZVfMlZ5xTlJ1mYah2ivhRxthSghh30uNbkuHPc7J635PArv2C3ymPHEWcjg6QPZhQuDOGEXqzFqIyHgHokB98AlNH4+JF8Of26Q64ONBl7sU3DqHIegAMRB45CEiAeUwEGJX1YzBgVa2wV0MWa12gExc4EdVe9w0NDduXfzhr33S7XxFkqQ4xKtAdSoyldHWseUhwbh+4C2joCEJkLifdPWcXVllXE1Am/THuLaVFlIqTolvBs3qHktAAI2NopE+FzBidLvnvS67evzy4thp3txeT7o0uE4dZNucNt3Jz6u4IXBRy/5+s6bn3h+4kYQGNAx6ucOzsybt8NFkPDfYzcIvdg9D8jLD8mK2SDVXAtEQ86clFwM8xOcIDZOnfHJ+M7uQ+QPX1bwhci3XqspwQDgH9NFLHQuREgkC6ByJNQU2fHRxnUvdwxIuo21dQdSQREgy7u8GY4/IZIiFFSTmEJHo6jJARcMGzu0eWL8jhQ7adNyNBSMfhqE1wjLrNFS32uwZU2aogao1kkzriw8S0oVSwWupEfecBioSHRU+H+qn2Bf4iRajBJrkDjB2InGg0U0cUYuX4t2/Bt3HLJF5HkIrYDGsp/0OjT74c68OPZuXfbTxyh3JncM+W9whLFQt5TtnbmJ4/veSBxkH438RUxafGCD324LTsGzwnTBFzcs22SfLq6nryLsW8w7YZhepb1jftCmS8ZxlXPB187FVKdqzqV6AFNDJVHJQL0AHHlrPK7S77z2g1arLW7j0jzywkUu/NcFIs2cO9u5ick0BR/4AfNzOroKr9Ls29Lgx1XVV3zgnPQ0Tva0J1jYjW3qojS4HszND5KzM8YZ4+pMMMXqe3p9T9QT0hMvcHzywAo64B7dkVEfeWHDZJYum9q4tsMgiTycZaygKQxy7/z07BriFusf/7B+wILj1nX77PzilBSAmTi57H9s9TvDVqdDFo3jqqa28m0IfCJEZVcCIpM0bMZ5aPD005G1X60f1A9/abw53D/8RUxGTc1kDxQfo4YStj6I0t8zOUSEGUnGNtjYNZsqpRI+3HzJfvEDZQWF3YvWcQ+DwT5/CQQFBsNGZIQCYgZkTjadNr3noWxiXQhu5qNJ5tYHO0WE1bhp9EtJ8p1zL8mek00ZsgolUWubUVXEfEg8rcYgBRBaCvqDOD9lc07sKy1JiCYMsTlw5SNxOEhRtvKROcJcXJPW7Ibk6odgOS4woKG7eEQrnNlNB7SAMaY9jERtl/kOEvM3QDPlRnOyATLcMvZPe2dZR0c5kwz10ZJdxftKfOHoJJzmUyWk7lXV6dbXTFlEwzF77wPyVmpujOIg1AACG2O5vmFyU2JeohF8IzpEhAi0Z0SAmwMkhTi1jQb1nBhI6YIiYNquygsH0qRLwTIlqyjq7hHBVZlCZVsqkTV+rSo+PpMIG2Jp/Q1i3J8btHQicVXGJzI4OrAllOLLHZk6tdrdwXUYEH22WcYPwDQ5orYfs5IRpUAig7c00qV5EJ2Z+GpIo3pY10uP6cLavl7aJrAHRmmHTuxf9NIuKa0fyCepKFMQy7TIkx6k99Zxib5HxevaSl2nBP91S+LllHb7BHTucpHMF/ywoeixokhnnT4VAItoFTnZolxqhwoa/xklGgx/yIW+rcZzZ6prJ+HU5m5EnI9gbznNQxE3QtwE1iUmTj+GSHCkR1MVi73cxQxlOCWvW1Hnwh5tkyulUNANxnqlPApCUxubAe3xpomERSFvgUQ4aP+Vxdvu3XzLXuFrcQmE9oKV1niMzm/bXnRoVqAD3KdlRmKyNXJTOkQjNuir4K1sHVRFm0AMsnKIHxntssKGHOmJJozBnwsHMpr/RzLJks5mUfWclVuUnIZA5Tqca5V3amXfCaauVr3iB4mc2UdyzCUK/22eyIFEAQyUAlBdEQvFUPnxGIa6FChqhUBh/ejgIkJHndkqdEXjxxiEhlyooGQ+V/ALETHmzNMIs1d2OkT2Ag+GMAGhgLF+yc82KeWMJMbXXJx7tE8r5ENKkTNitIzunZEoK99IyCY2TGUjRCRpElj8IOFzmVWk0NJZ1vueZl0X4fF2/W0qnGOiylve42RKmb1BUAFbtuQ3kApOOZszUbbkN6wrZcoMyT2qo9kc5QwTi96FdAgq1ScO9wMOEFMWbnds4gBxrWHX4p3toOJSHFxkyyilq29p7VV7zVugOmGYn0m2bbkNvTE69et+62Jw0u1DDnwKefGgK4xMxQoXPOCYkHQH30RTYgHAwKCytkNroUHpu2lSBOFkCrwuwZlHzIdtaLCKw8hH2Ve4kYZTwEN0K+pprit2T5hAWldXvc9SGl6AUpDxUEWXiBIPkriSJVn8yViWYsmvDI2XOWKT5QfWjVa7/b7fuib92bl1ohUkE/yROiQ7pBTkCoLJdopjHsFltpDuMA9plcZK68SUIaHU6VZFabTWVVE2d3K1UVh+upwspChGVCGDA5Elp9yOCloPQtzKM7a3Q7FC8cT1JE6UCOV26C9um+b+GX0Q1TceQ9233pMMjZ8bgNTLiMupX+Z22qUqTV7yI7qFBuVtlb+lCA66itJhygiVLhZNRdGUF92IohtaxCNgZVs4JSrsm7JMzKqVd44RgC8cc0FeXPbftXpkDSEbIUEjTfaUs+tvPEFS50uBa1iL22UmBayp5dbUc2sauTX7OZyKJcnMWk0nyBDL9XCtWFk3T6vQ0kVF0Z7dlZVjIOj5UFlbW1tfW9tYW7ufVUuHJ69dUZvZrqjNbFfUZrbrC1kQgxUvIvDOaKdS+wXcPvVan7v9AS4sstDaUm//CeFWUJtK6gLugXXj4Bqr4gVwz4X+Y8swjDhxfyq0bEAOELZQE95NYjYUzN11qDBpl1WwfJvA6whep+DTdHv7L9zeJvAGgjco+E2avYPvi71N4PsIvk/BHbGLuLUq0B07sStEvJw0txn2lOuleMF6O8UU4JIdOYXXayZD3V2Hq47FWvitdPMlW9wIv5V6fk8cboTPVdEtlUIusQezGa4xSFy2rcl2UDGD4lui1tEOQpPTHcoz29zzl6xdWr8y6rnnFwDGO91DseNK+yHbU+MQPq/oAjCfJfp+Pp+jZNWSHwZRlpzVXTOchFfH/R11dZ6dojRnmw4ivuNyTHp+qcC7GjTXnlyIVf4cKoJqLsR9/sz4Nu3mQix1DdcHQk0K5bZ+/iAqEPxr3hAK0F0VVnY5s37t8D2PYk792oF72RZz6lMDlhoWvheVM565GHJ7iM79jFMzT8r50PuyrVrTu/sikISwH1+OQPb4KQKATCd9kpAGS48mHBEy9+rxHppsq/ywoqvzq27v/KI7vP581aVLNz9C/D4BQ2eR/g2GV5B7X7UGA9BtKs18gJpxRJidDGj33g+uu/1uh4ps2H7f66GYSHPZfyiG9Agy7N+NNr4Y6Q8HJbLYFhhPtpO1vlYw9d1tsTpeVgPaadbBLAyTrx0vTlpJwk954mL14E+xSuQFt/AL6vsO5HvKn5gRixUMATTcgBVHM0gzJxyebkPRE0uMSJl9yTytqGKXtZ9yrfDUTZ7YDQdX3BdOItwguYhKd1AIPnBUL+N/wJIKXD7S5ccxrEqqMdEXBV/jnQwsYZ4eaWILUD45xCTOaHsUbjByfNcsvCTXLWS3RrgLiKeVOI2ePEas9ZiOBoCX9QasXYN21tjYmkBUyurR622mVfYBudZ47OFN8e/2kFzeyS1QIuO41H/VmTrthBiXB1R6QWIFixkx7TE5TpRhka1/pSztrzAlElu1TLUv5IAHmC3LRqoeurUmfPzTRIbC3V2+m+VZvx1JDkrWTeQ6f/C/OdZ7T3f1hDH2vqQEJ2A1WQMq7/rgzKjRDgoOzJOAg55xVHBgniUcmIcJuZ2g8xOaRirvRTXMOmo2lM4YHgD7lQKnJCV2WX7nsJ7vL2aWcZIPZ4ZGhNo/rajCmS6pVkTUn5ODNtJ25rNN/1gPM6UaPphTo0hpiR5XMgxtxUTgQ+ijfm97BnGAhxAH7BQi21BVFWgpjwXy22jxeRC4kTLKe6pmU6WTmlEXIgPMy0VCMPMldK8MrGKNVfGyP5IlGNkTlEsm8iV/EWlPNG7YeTISKH3FDYFSVqzMThk+yPA+4uyRFjjqMQ9QIudMtz61uWZQMHDNl+RSPdD5zGOZ+S+jqOc/Nfu8xYnNPKrraW5BhJzqzCOinNtUxin7yCbkMANyoFmFTI8opjfUuJAgAE1K6uAumZUl5c9fpU6x1fiNrUcG5XWgCJwH/sqif3zUuhmORtRFHNOC/9BoQZb//qVpPTSzEP1FDNOEQJ0DHyNX0ligp8oE2YrcaeSNJS3OkAHAKLGrDe02qeAnkpVp0NxJJxRGmT4ljEryB0qVhigb/E/hzbzgGE9hxsykgtnhvyWO4BmwiGjond8m/cElTTBYP6ypm7CvNgHycEOeVxK+mlQpq0pXcR1ODtzBApUN75ItvpjA3ORkgdfT4LqAcvAaaTyQXQ7wPgIz/WbdedgRcsLuix9UAGz4UQxUI6ZQdUvcV4ZusAJoQ6EJ/zV38P+qeP+OEcEogVRwRpUqeSyQEnigowYcIlWu2+4dZTOmp8WUUUaOGYHsGUFQ8GkcAv5FbYEp2//QBuheFd9rF7Y6Zn6P/LIbB3jqxQ+n6ArY35qtruizgPznnXB/7HmiPVsil03ku20ICoruyuUPau7ZI/GHgnFZh3OOXoT08J70CyDxl02CKWiGU0BWYpZhIZ/U7smcimJniEuRFh6ubtMbtCnp6SykpK089MRfNiLVOBfw2vbI9Xxy31/8reTqHR7mIYKsvyll4X3OxlsJvLeItiCWxKPqgdIhicWC3HAUHcLHsn7ibwtIxipac5jf0B6WuLGhtXhGqf4GJ+PbRYksSJDGqvg3JGk5L8FHm/j3O+WELCGjHClmwnvNRwvIR0koXHBGaoy+OVum/vBEnyu2ZFpc7dSNKSUj7TQ30awxNf/VjCvLZhcinV3QfLZeI982JrEE0ReGl7JhGGPFzFfAeTZ138kEwBysJFXSMuSUf/1mSbKSCxWaJq/z6t93pryW8/+CZDmtS1vly6lwaouUea2ovp+sOadrT0mcM2Lbp+TOa8foNTMuNDPOGrIXSY7JmTC8TGzZOIypcKRJDozZsbxEt00eLQ9nEiFmBz82xjryUKl+/08i5yzlZ2Gnjrfyk61ydNhNbubPO07i/F77QtqRl74oFpMSbvza2evTf/3FdhfbXbHHiPMFxFB6jGDXdxiv56Q7+wK9zOpk/TH9SDXHo0y9qv6Fny5RQyjFPxikGgo8jRWMiFUF3leA+YZ2Rb0WqSj//wKewf8AlYYAAA==")} +} +,{ + {"vert", GzipedString("H4sIAAAAAAAACn2Ru07DMBSGdz/FGVuQot42i4mVIRMMVRUZx01OldqRc3JFfXdOlBSZFDHZ/v/vXC1KbzRW6CzkmOUlnAunSIra4tn56yxeFR1A64TPD+eL9B//jQV6R9PG3l2kUEQeP2sy0Bi9B5WUrkLicn9YlhOqYmHs2CDTvTrnuWyjfI82m4wm0QWWSWpKytky+sC6J1it4Wt6tmOzsaukuN+iDl7CSY7703Fzguegs6gL8P4R3y7wPsCHR3y3wIcAbxnfRpu5+XEaVn9S/FolPAXThJOP+BQYDa0U3lDt7V2S4iYahyn/ENpxL5AVSTy3wpHjvlZrCbdvKFaE9ggCAAA=")}, + {"frag", GzipedString("H4sIAAAAAAAACl1Py07EIBTd8xVnCTrWtspo0rjwEd0b9w1hOpRYC8FarWb+XS50obOBk3PveVzmQ6ftu3Ujemt6j/3g1NSwudOX8Eq/PnR+6l/c89PdLXgaYkeUwE9eCt2EGxDkVVFuUEtJ31aWdQLVVl5XF1cRC5xkbcOyaB+UnnjEIjNnq0/ExfL9uUFJovNsmVY+wkiBDTuwWYXFjoYUNeZWD9a3q3vqFc0NONVcdUfX8L+a4ivG/COWWLYsJE7pFSnQ2R3elB3JFGZoH2PCvRtcyKcYLhocfgHXMvD2UQEAAA==")} +}}, +{{ + {"vert", GzipedString("H4sIAAAAAAAACuUa23LixvKdr5hUXoSNCQh744TknGIx9nJiLgWyk5TLpdKC8GoDEiuJa8r/frrnopnRBeMtb15SteVF0z19n57umSktQ3fiRV7gk0/e06clmc0DJ26WlA8ydSfB1G2YxGCja3dyTsKnj06Z/F3C/8mv9JOcEPPiolrTZ4+9Jx8Q6tUaOSNGFLtLo25eVmsVYuCkh8ZjmZySWvWiXEYC6emd7TLwXT8GEgADDGMRTA0KMzw/NjJEKoSSL+NADjtTYXcGqD+mGfYcP/aiCJXKZWXmsToh7y4uGu9AwFNqiof6I7WGMlJ7hF+XjcvLd7VL5Bm68Sr0mXlOiLtdmkai6xkxG0AXxoU0zdJzKYrD1QQMGjv+1Amn924Yd/3lKgYvKI5ZBpEXgz+bJfhsED8IF86cfpwTmPkE9IFYs+TEceh9XMUuoXiOLSdmQIKIBjABELvbdhCE0xToHEGC1/fejLTb9t24Y/cGo+EHBZVZ3LHXoIq77QIZsDN5cuN7PmDQEGOWQhdI1DJaZOV7MxCNsZxM7KkXLefOxF0A499dsEkcPdQvHpsHES13C/Tdrj8LqJlMFGDobd35bTBx0CIGHY0Z3siNgvkKhysoElkiZtefuluUlWkkx64hjFgEKXhNjrYFIIaYgl7JsqnKCTtGLQjVKeSHgjncbii8sa2QHTWZpiD13XUYLHRN5/yrQvIVV5xCJxhiQhXYJL93uE5gmeTJh5LwuLjq3HfbHXt8NxwORpZ9fTtoWbbV+cO6G3VY1M7cePLpHiKxFYbODsXlLjMiZ7Gcu6F5hRyYO9w5dWriEN1FYD8VgftbiAzQjOuLg6W63VWI5lVKbLVWyGQNLG17kLJ0H7edeWVQHVdr6sbv3XnkfmvzQP45/xYm2h5lIYgeGlw1TN7wp/yyySj13auo119Jff8q6ubx1OVqPTdKYss1Ut7fwqZTCNwdAu4RCMqWePj4U2/Gswqoc5VJnLjjQcQoYfJlFeAuTMdgTZ+zZB26CweHwgR0xjBp7MASNxSMX0lNyR0FCRtnP1ZhbT4TDHKSoVE/lsaumIZ5LI19QuM4/A2a95ntvXQjmzRU476wPPnuJszOUyTdNu3hqNMe9IZ3VudKSFK89ClFlVoVipCmTBsNcFy0mqND8cvAMIV/ZeZUH/dfb+JG1KnxoRW+x80pCAmLF8sJQWmYVWsmH79IFazW6KZj2e3BXd9qktNTjsJ8QcU5harrBa2kcCcJj9OMrgAsiGvOk64DbkfGvCmWxbNueC71h9bYHg7GXas76CcFhfQh2GjIKyiVa9RMYiEPbChenyox+ULoFDGrEK0+4voUadMfjHqt23xd+rTkK9AkC/x6PXIYvU4Lq9W/6fStfDUsVoUW6JED/XpF8ljla7IOvClxlsv5rheEy0+4doJVXmGPlbJIv4IQ239kgdx8OViRTFWU97Db4B6WHTstjFFFh+MiihJnTYPKThk5LQij41kJt1PKvNlQmalDp0XOzrJ7LvKO1lxlknOe2VMWP9LYmnNVuXR7YDs1/q3b73f7N9nm63Pg0UDPADZss9K6svet3zpXdqvf7bWo3AjC8W5/DEZu6wyUTpOzafnegjVPXEKxEBVUWB4UV+u1DuBJmjqStrZVimJrO0Azevip9pgOqyL9X2pMFk58ji78H1LuOWCdLWFHBcQTwZGyoXrI8BniocGOM1JWrGLVnR7bQbx42E6lAXuhdwHxtD0p9RxnSA55wH1iNZWN56/H3t4FZnlzNvqpiuxcP+O2zaaWdZytgnMGM/IlxS4CqRk7fgwj6fFTjnUdwLL8TRFhTa1hbDPTaQUtaJjH0qgX02gcS8PMo8E3How0g3YF6zqmDtFPsCEzO9TIDtWrG/hp0r8N/FvHUyvZR75BNNfNbxnOgvq/N54L+8LXhXd+h/i68H41jZzwfjWNRg6NkrZav8ZC528g2cUb0Hj3BjR+PGihxlda6PINJPvpLeLwTYI5L5pL/1yuZZXHUSmXttPTLW/AvbKaC2RFgxgnpPGoroMMFBV/VOMgD8N8/GetQPWP/vJ8oTsqTUVkoolwFbWsdJJuNIOBIY3SjYbXt9Vt6bQAcacj7goR9zrivhBxoyPSEyDaRLTbY1CwsIGgJliAotIM2M4JFLwcAMLyWiaXanHTWEBea/w4D22sqbZv9BYMMJgv5Djzdhkd38xrwVKTFKA28zm/Z6CiQ5TC//eeu0l3AQp4GAafizqJibNwQweaLImwcKfeaiFRZsHTeydyDyK0ptPm4Z6Id0Mgzu9BOJ/WcvouAasfgJmSzW335oPVaw2zyHMMMs9/6jnLu/uhEzqLppJY+PT3Lav9QZdRXLVNd7790Yknn2xvesCuVKDooc46pmxnlUZt6kfKt57vOuF18GSIqE+W9wYcwrphcasFfsLjRRiEvxApE3qcknivQqckd2DgEYj5MGZ5jDsQj4sTcMef6sBdkjsmc2ggDYMjnQnWeEclBwWHMoYqZi6at5Lr6CO1wsiJY9dPRIE4wsrzWC2uXB/W405H2GdttnC2xiG7KQqxpQe6JrKdQAWU8MTbn+3SOBO0TxQxZPqdacYYf1k5oTv9F9kkzzovm+rW2blvZScbqFjBUgNuVeAIs60G3vEzTxCeLldMmwwhMQ1LyCpCFQ1dq/KpGzocRHzqJpmiApIpXI8rdx47V+rKVrErmjwpJ9CXICqZPyv4g5q468fuU4gvEvBiR9NiR/4jDETLKIBv2Pgv6jgniTuVMOcZ02mHckgrCkFSnLG14yROlF9QpCr3RZIJNUmWBA4/S/xCYRUrtHSRdd2zousmfH+cvk1FcudjZAjOZ4JMOVcbRE1wT4j8RUv3M2IIIU6I/EUf0uTaDMm9StF8iQrcVGb3dIl16FQWTwLvO3QQDxaRd4zoSxjjpTG+LjJEfP8gaGMlmDNapk+EstGrai04sJhIpZ9Zfm7h9aBtjVr98XVnZF8PbmDzH3eSJFMhWCRyas4kDsJy6W/18BNm0HvZEoMCQ7l3L+m2y8oKHb0u0fmOWIxrarjKhlE8paFIIxNngg/VSAKv4+rU7u2+47Ra7fbdqGVRoqW1E+6gauKWWGNetBmNpnYrkzKmlqwLied6gBpfZVROyYlk7jsjq/OH3R7cDkZKsTYPNskZ+ySYo5BCAQlaC5Byoo00k7czfAZ9trC2V+vUM6jYmwN4MJtFrrz6ZJShl1AaMtkYKG0Db87ECGvw8h57JRcpRtL75B3CJ3cZrL3JQWb9jKw3sxW5ANIKAHrYEhcyKcyVPjUNqx+AmQdgNWxuVTLapyla31IS6Vp9rkis1d3srZtaq5eTQjx/TnEY2PRFknyrB5lIdT3oBrlMG9lvmHnHrd7wFkJ8NOjZI0tQ0jLxBrZbzIb/ZacsiIKPwNhrT/oFufpnHn5Jn6IJqq0BHtRUYD280yszMYNskWV2lM0hPzXmnSR8iXnlvN4aX4hg4JOneXLBToMdkn65SZ7/DyeT5+UvKwAA")}, + {"frag", GzipedString("H4sIAAAAAAAACuVXTW/jNhC9+1dwkYvkOqrtZIEW7haQZWVTwE0C22m7J4Fr0V4VsqiV5K8t8t87/CZtOU2B3pqDQs88zrx5pMhRp6zIMqszWqAv2fpLiVY5xc2osyPLGxRG8XxBC/IrLpHHLUua08pHf3X4AH1Am6zw+LiHGMD7Iej7/gjcRd2IWCgE2DB4P3CtY7D2g/6Na4049vbEOuHY9z+61phbB7ejTkWabVUgQQR1kRfCQ/z4Do19H31v+SLLN/HhEQPfF1HwfPZxvKDTrCC4khWv8WaDWcUyCf8NIfh/OfEWRdFdhdeP26bcNnzirZHqKluBP3mex8n9ZCaUC6r1Z6BvCexpO9C5IkWarRxo/bVqHIzkw02Mx7bIVrTayGUUFJbJEm9IhZ9oPdKADUmz7cZAVnQdiSCvIMa4Jq8CwjQddcTCCP3u6FoIUdKaycDHe2ACxZSMjwADwSTNmBGeDS6WxLNp9/gUX6Eh0bzBVQNwwys4WO64SF3n0UiV403peRJ0rVLz7aGNKoPfg83VQ4OA7w654w7lG6tigjQNKTQVkCf49vYqJqSos+boAr6da7bBB+813ayCWD19Vqvm1kW3gc4Jwcih9K5V7K5Fw+y2lSPG/OsWVyT9H2nSps4/SzXFR/Jf6ZRAlAUtHefBds5wsSaO+yiPcyD/O63y9KmifwqAliY4HCGDDQiO/HiVU/fcTGs5da+n2A49RdYxIXmDJ/abbaN7Dp+TRRgGfTfMpx4bcIl/KRqyrnA+6sDB6iwwEPhZCcQEZv69sP9k22VIYOYpOa9FTUfGw6ioiJxkhokqRNcawRUFa45IXhMnCZfkPAQzvxj8RbKWCqFL2a39nLor4fht9Y4s5vhz7anM1yqM31oNg2psF5kRqMJeOU+R6CIzYj6/VTMW7l8V2s7owjLxM/3FqMOniv2kcO/YAsnNos4dj1/Cg6APXYMqdsI2rpjjs/bi3Ap/Iv/J7rWrVhnEnjg5flbtZ8uOZilrLBaz8GF+F8+Su8ePyTicx/qQ6SG6Vd3SCi8b6Ec6Tj8CM9AHyNoRXkho7u6SX7tXJD+DDwxc3oiXsUMHa10Yl6fcWGzMwanxNTH+AXs7ZbNkBAmfnqafjBpZwVQwPVnPVcRqZhnG22QHz+qKWLfVQ0szlNOUDfO9xDR9J8sIo+h5Fi54PZ0dro5ZsZYpdyxsIiJo4me0zxirLrI1w3nBqh+3kvmvydSikHPonzSxTnZbylHn4m7UJz/rqPq+VlGvqBWGLUSbThcL1bHEOnCO06f7MFlAd61mK88i/mPxPIv1wgC7IeTb7kx3W0ObmJNqOIFWIisW5ADvHNE0FIrLxQAnzbORcb7EOQmLNNo2dAWvrKLwWzwDFkn0OH2caR453ct+epfInl7tD2ZcwecF8nTXQHmfo3NT/pHQ/dCWV9zTrbn1NPu7x5P55WcGDTBDKCMeXRSU8WrIIZIvUyN0G048S8UelxrCKqD8unEI2D7GgOVXtrP01kqz45sGxpBE9+HDQzyF+7RNl73PGpMlrtLWLeZRc97an3fcLt8iVhlbFLTOE4ZQtbPV8vwRevkbrk8NZV8PAAA=")} +}}, +{{ + {"vert", GzipedString("H4sIAAAAAAAACuVZbW/aSBD+zq9YqV9MID6wIU3PV504QluuDSAguZMihFzYJO6BTW1DDKf895vZXeNdbBOIaL+cVKV4Z/aZmWdmX8YuLHw6cQLHc8mj8/C4IPczzw6tgvRApnTiTalpEI2PruikRvyHr3aR/FvA/8l79kjOiFGv6xV19sB5cEGhqlfIOdGCkC60qnGpV8pEw0l35qhISqSi14tFBNid3ooWnkvdECBABhra3JtqTKY5bqilQMqEwRdxIMOcIZk7B9W3uwavbTd0ggCDyjRlZJk6Ixf1unkBDpYYFXfVEWNDGqmM4NeleXl5UblEmz4Nl77L6TkjNFoY2jbWc2KYgAvjsTdW4bkQhP5yAoSGtju1/ekt9cO2u1iGkAUpMQsvcELIp1WAR5O4nj+3Z+yhRmDmA+ADmFWww9B3vi5DSpiePU4mpkQxiCIwQBDSqOl5/nRHVENRbOuNc0+azfHNoDW+7vZ7nyRVzrg9XkEoNGoDDPBMHmh4KwY0VmKcKUxBolpERpaucw+ucZOTyXjqBIuZPaFzMPwXBU7C4K5aH1l7FYc0Anzadu89RpOBDvSciM6+eBMbGdHYaMj1+jTwZkscLqNLZIGabXdKI/SVR5SMfYAy4hUk6VlCLQIhlpikXk6b0ZMJa47m+fIU8kvOHMEbOq9FZbJmlCkBstx98L25GulMPJVJduBSUtgELZ6gg5nt7zWuE1gmWf6hJ6Iurlq37WZrPLjp9br94fjDl25jOB62/h7e9Fu8au9pOHm8hUps+L69RndFyrTAni9m1Deu0AJPB52xpG4ToqYI+JMVRL5jl0GaSn1+sejRukyUrDKw5UqCSROccLsXOUmf4M640liMyxVL4xs6C+iPpgf2n9qPoCg6iCGoHlZcFdy84U/xZcoY+voo9OqR6Juj0I3D0ZPVWtMK8ZGr7WQ/gkMnV7jeJ9ygEIItiPJxp8692FUgnKvUxoknHlSMVCbflx6ewmwM1nSNb9Y+nds45G9F51yT1Q4scU3SeE8q0t6Rs2Hj7JEOa/OZYJGTFEb1UIx1PoZxKMZmi3GY/hPS+8zPXnaQTUyZ3BeWpzjdYtrFFsmOzXGv32p2r3s3w9ZV7En+0meIMpoOlxAr2TZMSFywnGFC8UnDMoV/RZ5UF89fZ0IDltRw3wrf4OHk+YTXy9D2IWiYVbG2D78lIQwb/Y+t4bjZvekMLVIqCRWeC+ZOCW5dL0SVOHe2tVFKxQrCnLoWNtk6EDxy41a8LJ5V4oXXnxqDca87aA/b3c72QpHkEDjqiRuUbDWwtrWQJdakrE+lmnyhdPKMlYlyPxLx5EXT6favG1+yY+mwK19OJGnh6+PIMHRcFMNG52OrM8wOY8hvoTlxZEhfH0iWqexIVp4zJfZiMVtfe/7iEdeOt8y62ONNOd5+YyB+/iQXZOvlYkUYPb7ew2mDZ1h6rJRbo1IMh1UUA+dNg2xOGinllNHhpuK0M2TRbMjG5KFSXrLT5p7zsqM0V6nNOYv2HcYPJFtJruyXyge2U4PP7U6n3fmYbr6+eQ4r9JTgiR9WSlf2R+Nz62rc6LSvG8xvFOF4uzMAkpuqAanTFGYarjPnzZPwMF6IkiosD6ar9Fp79BJMVUlZ2zJifLTtwQzu3lVGu2WVF/9LjcncDmuYwj8R+doGdiLCXxUQJy6OHQ7llwzfoB5M/jpjh0Udb927Y2uoFwfbqV3BJo47B3yXT4aekYzEQpZws2VNNuO4q4GzoWAsa86T+lYl6Vy/4bHNpxZVnUjSOYcZ2Z5iF4Fo2lq8hknwxFuOVRXEyfV3B4Q3tZoWpaazG3SMYRyKUc3HMA/FMLIwxMGDlaaxrmBVxa0j7if4kJEeMtNDVf0Jfhrsr4l/q/jWKukjT1DNVeNHlnOM/v+t59y+8Ljyzu4QjyvvozEyyvtoDDMDo6Cs1tcwVDuBZ/UTYFycAOPtXobMVzJ0eQLP3p2iDk9SzFnVXPh5ey2/eRy05bJ2ehqJBtwpyntBcqNBjTNijuR1kJJi4CO5DrI0jNHPZYHFH/zjuHHsGDRzkbsWl2t8l02SpJKmcTFso+ygEfdbPSqUchTXquI6V3GjKm5yFZ9URfYGiDURzeYAAsxtIBgFcwg0oQHbuVgFPw4AcPJZJhM1v2nMgVcaP2FDGbPk9o19BQMNnotknGe7iIm3slqwnUmSUJn5vL9nmNhz6tvQJkH12v7acR/4F4nVeLmyOBv4To8XT5qJNsTSduVgRUnFI7wsmdI23ORrF4wKv9nwng9a22ZRa7upzlXp1HjyFDXJQyCFL89t4PoTe2sKt5/f+T6mauMHl/OdISjwX4k6ZhUeZtsXRmBBkioinb07l5+B5TH7oiF/63v+D//woug2HgAA")}, + {"frag", GzipedString("H4sIAAAAAAAACnWQPWvDMBCGd/2KG+VijK20zWDSoQ3t0i5J9yDssyPQh5Elk7jkvzeSHRwKXXToPt73uSOdxUr0wmg4ivbYQSMNdyUZsFrBfvfx+m0+hUZugcZUy5XiCfwQi85bPf3hYYoluZCB27PQLVy7GQwHP5TEa9EYq0BhLbzqQukRHJ72YsSl2nPVSbRsC8a7zrsd9l66L96VJDKB9EporiucSCojjb0jqY2jMZcGgxXNM1aw5xTybF08sRDzNWNJEiGNqEFxoWkQWORgE7iucsi29A9GGrdJstN5LIlogC4893eaGJIEXm4rZmMwaeXh3fL2bbYJN7jhFlkeqABlj/90XuHjBvMzT5DLL2WKdvy/AQAA")} +} +,{ + {"vert", GzipedString("H4sIAAAAAAAACuVZbW/aSBD+zq9YqV9MID6wIU3PV504QluuDSAguZMihFzYJO6BTW1DDKf895vZXeNdbBOIaL+cVKV4Z/aZmWdmX8YuLHw6cQLHc8mj8/C4IPczzw6tgvRApnTiTalpEI2PruikRvyHr3aR/FvA/8l79kjOiFGv6xV19sB5cEGhqlfIOdGCkC60qnGpV8pEw0l35qhISqSi14tFBNid3ooWnkvdECBABhra3JtqTKY5bqilQMqEwRdxIMOcIZk7B9W3uwavbTd0ggCDyjRlZJk6Ixf1unkBDpYYFXfVEWNDGqmM4NeleXl5UblEmz4Nl77L6TkjNFoY2jbWc2KYgAvjsTdW4bkQhP5yAoSGtju1/ekt9cO2u1iGkAUpMQsvcELIp1WAR5O4nj+3Z+yhRmDmA+ADmFWww9B3vi5DSpiePU4mpkQxiCIwQBDSqOl5/nRHVENRbOuNc0+azfHNoDW+7vZ7nyRVzrg9XkEoNGoDDPBMHmh4KwY0VmKcKUxBolpERpaucw+ucZOTyXjqBIuZPaFzMPwXBU7C4K5aH1l7FYc0Anzadu89RpOBDvSciM6+eBMbGdHYaMj1+jTwZkscLqNLZIGabXdKI/SVR5SMfYAy4hUk6VlCLQIhlpikXk6b0ZMJa47m+fIU8kvOHMEbOq9FZbJmlCkBstx98L25GulMPJVJduBSUtgELZ6gg5nt7zWuE1gmWf6hJ6Iurlq37WZrPLjp9br94fjDl25jOB62/h7e9Fu8au9pOHm8hUps+L69RndFyrTAni9m1Deu0AJPB52xpG4ToqYI+JMVRL5jl0GaSn1+sejRukyUrDKw5UqCSROccLsXOUmf4M640liMyxVL4xs6C+iPpgf2n9qPoCg6iCGoHlZcFdy84U/xZcoY+voo9OqR6Juj0I3D0ZPVWtMK8ZGr7WQ/gkMnV7jeJ9ygEIItiPJxp8692FUgnKvUxoknHlSMVCbflx6ewmwM1nSNb9Y+nds45G9F51yT1Q4scU3SeE8q0t6Rs2Hj7JEOa/OZYJGTFEb1UIx1PoZxKMZmi3GY/hPS+8zPXnaQTUyZ3BeWpzjdYtrFFsmOzXGv32p2r3s3w9ZV7En+0meIMpoOlxAr2TZMSFywnGFC8UnDMoV/RZ5UF89fZ0IDltRw3wrf4OHk+YTXy9D2IWiYVbG2D78lIQwb/Y+t4bjZvekMLVIqCRWeC+ZOCW5dL0SVOHe2tVFKxQrCnLoWNtk6EDxy41a8LJ5V4oXXnxqDca87aA/b3c72QpHkEDjqiRuUbDWwtrWQJdakrE+lmnyhdPKMlYlyPxLx5EXT6favG1+yY+mwK19OJGnh6+PIMHRcFMNG52OrM8wOY8hvoTlxZEhfH0iWqexIVp4zJfZiMVtfe/7iEdeOt8y62ONNOd5+YyB+/iQXZOvlYkUYPb7ew2mDZ1h6rJRbo1IMh1UUA+dNg2xOGinllNHhpuK0M2TRbMjG5KFSXrLT5p7zsqM0V6nNOYv2HcYPJFtJruyXyge2U4PP7U6n3fmYbr6+eQ4r9JTgiR9WSlf2R+Nz62rc6LSvG8xvFOF4uzMAkpuqAanTFGYarjPnzZPwMF6IkiosD6ar9Fp79BJMVUlZ2zJifLTtwQzu3lVGu2WVF/9LjcncDmuYwj8R+doGdiLCXxUQJy6OHQ7llwzfoB5M/jpjh0Udb927Y2uoFwfbqV3BJo47B3yXT4aekYzEQpZws2VNNuO4q4GzoWAsa86T+lYl6Vy/4bHNpxZVnUjSOYcZ2Z5iF4Fo2lq8hknwxFuOVRXEyfV3B4Q3tZoWpaazG3SMYRyKUc3HMA/FMLIwxMGDlaaxrmBVxa0j7if4kJEeMtNDVf0Jfhrsr4l/q/jWKukjT1DNVeNHlnOM/v+t59y+8Ljyzu4QjyvvozEyyvtoDDMDo6Cs1tcwVDuBZ/UTYFycAOPtXobMVzJ0eQLP3p2iDk9SzFnVXPh5ey2/eRy05bJ2ehqJBtwpyntBcqNBjTNijuR1kJJi4CO5DrI0jNHPZYHFH/zjuHHsGDRzkbsWl2t8l02SpJKmcTFso+ygEfdbPSqUchTXquI6V3GjKm5yFZ9URfYGiDURzeYAAsxtIBgFcwg0oQHbuVgFPw4AcPJZJhM1v2nMgVcaP2FDGbPk9o19BQMNnotknGe7iIm3slqwnUmSUJn5vL9nmNhz6tvQJkH12v7acR/4F4nVeLmyOBv4To8XT5qJNsTSduVgRUnFI7wsmdI23ORrF4wKv9nwng9a22ZRa7upzlXp1HjyFDXJQyCFL89t4PoTe2sKt5/f+T6mauMHl/OdISjwX4k6ZhUeZtsXRmBBkioinb07l5+B5TH7oiF/63v+D//woug2HgAA")}, + {"frag", GzipedString("H4sIAAAAAAAACrWRvU7DMBSFdz/FHWM1MSVkszpR8QKwR27jJJb8Jyc2ThHvjp1UFIkBJMR87vdd6RxkHT+LSRgNoxhGC700bKYoMLcIPUDg5xpC6wNFXoveOAWKd8Irm6MGZh6fxYXf0okpK7mrj3CSxqgXHmfvUp6uH6Azr3o7aGZmp2K1+1Bub0YmeysilxjetvvJKzjkH9lRH4uvyjKBsFvJovpESSxvHrJgTOJyoSiLdr8x/Y+o+oup+lHleGL02tYdNGRP0TsKRnSgmNAFRtc2HZ+8nFOh32Zo8wb3ZJ/w66BJjIkbThQNsn1ybHg00rjE5tWLzbQiOD37AHzybb5FAgAA")} +} +,{ + {"vert", GzipedString("H4sIAAAAAAAACuVZbW/aSBD+zq9YqV9MID6wIU3PV504QluuDSAguZMihFzYJO6BTW1DDKf895vZXeNdbBOIaL+cVKV4Z/aZmWdmX8YuLHw6cQLHc8mj8/C4IPczzw6tgvRApnTiTalpEI2PruikRvyHr3aR/FvA/8l79kjOiFGv6xV19sB5cEGhqlfIOdGCkC60qnGpV8pEw0l35qhISqSi14tFBNid3ooWnkvdECBABhra3JtqTKY5bqilQMqEwRdxIMOcIZk7B9W3uwavbTd0ggCDyjRlZJk6Ixf1unkBDpYYFXfVEWNDGqmM4NeleXl5UblEmz4Nl77L6TkjNFoY2jbWc2KYgAvjsTdW4bkQhP5yAoSGtju1/ekt9cO2u1iGkAUpMQsvcELIp1WAR5O4nj+3Z+yhRmDmA+ADmFWww9B3vi5DSpiePU4mpkQxiCIwQBDSqOl5/nRHVENRbOuNc0+azfHNoDW+7vZ7nyRVzrg9XkEoNGoDDPBMHmh4KwY0VmKcKUxBolpERpaucw+ucZOTyXjqBIuZPaFzMPwXBU7C4K5aH1l7FYc0Anzadu89RpOBDvSciM6+eBMbGdHYaMj1+jTwZkscLqNLZIGabXdKI/SVR5SMfYAy4hUk6VlCLQIhlpikXk6b0ZMJa47m+fIU8kvOHMEbOq9FZbJmlCkBstx98L25GulMPJVJduBSUtgELZ6gg5nt7zWuE1gmWf6hJ6Iurlq37WZrPLjp9br94fjDl25jOB62/h7e9Fu8au9pOHm8hUps+L69RndFyrTAni9m1Deu0AJPB52xpG4ToqYI+JMVRL5jl0GaSn1+sejRukyUrDKw5UqCSROccLsXOUmf4M640liMyxVL4xs6C+iPpgf2n9qPoCg6iCGoHlZcFdy84U/xZcoY+voo9OqR6Juj0I3D0ZPVWtMK8ZGr7WQ/gkMnV7jeJ9ygEIItiPJxp8692FUgnKvUxoknHlSMVCbflx6ewmwM1nSNb9Y+nds45G9F51yT1Q4scU3SeE8q0t6Rs2Hj7JEOa/OZYJGTFEb1UIx1PoZxKMZmi3GY/hPS+8zPXnaQTUyZ3BeWpzjdYtrFFsmOzXGv32p2r3s3w9ZV7En+0meIMpoOlxAr2TZMSFywnGFC8UnDMoV/RZ5UF89fZ0IDltRw3wrf4OHk+YTXy9D2IWiYVbG2D78lIQwb/Y+t4bjZvekMLVIqCRWeC+ZOCW5dL0SVOHe2tVFKxQrCnLoWNtk6EDxy41a8LJ5V4oXXnxqDca87aA/b3c72QpHkEDjqiRuUbDWwtrWQJdakrE+lmnyhdPKMlYlyPxLx5EXT6favG1+yY+mwK19OJGnh6+PIMHRcFMNG52OrM8wOY8hvoTlxZEhfH0iWqexIVp4zJfZiMVtfe/7iEdeOt8y62ONNOd5+YyB+/iQXZOvlYkUYPb7ew2mDZ1h6rJRbo1IMh1UUA+dNg2xOGinllNHhpuK0M2TRbMjG5KFSXrLT5p7zsqM0V6nNOYv2HcYPJFtJruyXyge2U4PP7U6n3fmYbr6+eQ4r9JTgiR9WSlf2R+Nz62rc6LSvG8xvFOF4uzMAkpuqAanTFGYarjPnzZPwMF6IkiosD6ar9Fp79BJMVUlZ2zJifLTtwQzu3lVGu2WVF/9LjcncDmuYwj8R+doGdiLCXxUQJy6OHQ7llwzfoB5M/jpjh0Udb927Y2uoFwfbqV3BJo47B3yXT4aekYzEQpZws2VNNuO4q4GzoWAsa86T+lYl6Vy/4bHNpxZVnUjSOYcZ2Z5iF4Fo2lq8hknwxFuOVRXEyfV3B4Q3tZoWpaazG3SMYRyKUc3HMA/FMLIwxMGDlaaxrmBVxa0j7if4kJEeMtNDVf0Jfhrsr4l/q/jWKukjT1DNVeNHlnOM/v+t59y+8Ljyzu4QjyvvozEyyvtoDDMDo6Cs1tcwVDuBZ/UTYFycAOPtXobMVzJ0eQLP3p2iDk9SzFnVXPh5ey2/eRy05bJ2ehqJBtwpyntBcqNBjTNijuR1kJJi4CO5DrI0jNHPZYHFH/zjuHHsGDRzkbsWl2t8l02SpJKmcTFso+ygEfdbPSqUchTXquI6V3GjKm5yFZ9URfYGiDURzeYAAsxtIBgFcwg0oQHbuVgFPw4AcPJZJhM1v2nMgVcaP2FDGbPk9o19BQMNnotknGe7iIm3slqwnUmSUJn5vL9nmNhz6tvQJkH12v7acR/4F4nVeLmyOBv4To8XT5qJNsTSduVgRUnFI7wsmdI23ORrF4wKv9nwng9a22ZRa7upzlXp1HjyFDXJQyCFL89t4PoTe2sKt5/f+T6mauMHl/OdISjwX4k6ZhUeZtsXRmBBkioinb07l5+B5TH7oiF/63v+D//woug2HgAA")}, + {"frag", GzipedString("H4sIAAAAAAAACrWRvU7DMBSFdz/FHR01MSGEyepExQvAHrmt41jyn5zYSop4d+wEtYgFJMR87vcd6R7kPD/JUVoDgxSDg15ZNlEUmV+kERD5qYHYhUhRMLK3XoPmZxm0y1ELE59f5IXf0pFpp7hvDnBU1upXPk/BpzxdP0BwW9xOzI14dYdYbiUDU72TM1cFvG3XY9Cwzw3Z0BzwV2GZQNitJK6uKJnLm4csRUHm5UJRFu1+Y/ofUfUXU/WjyvPEmPVbd9CSmqJ3FK08g2bS4Os3PR+DmtJDv43Q5QVq8pjgzzGTtiBeHCkSqnv2TDxZZX0i8+J485RwT+oiVX0Attgd8kECAAA=")} +} +,{ + {"vert", GzipedString("H4sIAAAAAAAACuVZbW/aSBD+zq9YqV9MID6wIU3PV504QluuDSAguZMihFzYJO6BTW1DDKf895vZXeNdbBOIaL+cVKV4Z/aZmWdmX8YuLHw6cQLHc8mj8/C4IPczzw6tgvRApnTiTalpEI2PruikRvyHr3aR/FvA/8l79kjOiFGv6xV19sB5cEGhqlfIOdGCkC60qnGpV8pEw0l35qhISqSi14tFBNid3ooWnkvdECBABhra3JtqTKY5bqilQMqEwRdxIMOcIZk7B9W3uwavbTd0ggCDyjRlZJk6Ixf1unkBDpYYFXfVEWNDGqmM4NeleXl5UblEmz4Nl77L6TkjNFoY2jbWc2KYgAvjsTdW4bkQhP5yAoSGtju1/ekt9cO2u1iGkAUpMQsvcELIp1WAR5O4nj+3Z+yhRmDmA+ADmFWww9B3vi5DSpiePU4mpkQxiCIwQBDSqOl5/nRHVENRbOuNc0+azfHNoDW+7vZ7nyRVzrg9XkEoNGoDDPBMHmh4KwY0VmKcKUxBolpERpaucw+ucZOTyXjqBIuZPaFzMPwXBU7C4K5aH1l7FYc0Anzadu89RpOBDvSciM6+eBMbGdHYaMj1+jTwZkscLqNLZIGabXdKI/SVR5SMfYAy4hUk6VlCLQIhlpikXk6b0ZMJa47m+fIU8kvOHMEbOq9FZbJmlCkBstx98L25GulMPJVJduBSUtgELZ6gg5nt7zWuE1gmWf6hJ6Iurlq37WZrPLjp9br94fjDl25jOB62/h7e9Fu8au9pOHm8hUps+L69RndFyrTAni9m1Deu0AJPB52xpG4ToqYI+JMVRL5jl0GaSn1+sejRukyUrDKw5UqCSROccLsXOUmf4M640liMyxVL4xs6C+iPpgf2n9qPoCg6iCGoHlZcFdy84U/xZcoY+voo9OqR6Juj0I3D0ZPVWtMK8ZGr7WQ/gkMnV7jeJ9ygEIItiPJxp8692FUgnKvUxoknHlSMVCbflx6ewmwM1nSNb9Y+nds45G9F51yT1Q4scU3SeE8q0t6Rs2Hj7JEOa/OZYJGTFEb1UIx1PoZxKMZmi3GY/hPS+8zPXnaQTUyZ3BeWpzjdYtrFFsmOzXGv32p2r3s3w9ZV7En+0meIMpoOlxAr2TZMSFywnGFC8UnDMoV/RZ5UF89fZ0IDltRw3wrf4OHk+YTXy9D2IWiYVbG2D78lIQwb/Y+t4bjZvekMLVIqCRWeC+ZOCW5dL0SVOHe2tVFKxQrCnLoWNtk6EDxy41a8LJ5V4oXXnxqDca87aA/b3c72QpHkEDjqiRuUbDWwtrWQJdakrE+lmnyhdPKMlYlyPxLx5EXT6favG1+yY+mwK19OJGnh6+PIMHRcFMNG52OrM8wOY8hvoTlxZEhfH0iWqexIVp4zJfZiMVtfe/7iEdeOt8y62ONNOd5+YyB+/iQXZOvlYkUYPb7ew2mDZ1h6rJRbo1IMh1UUA+dNg2xOGinllNHhpuK0M2TRbMjG5KFSXrLT5p7zsqM0V6nNOYv2HcYPJFtJruyXyge2U4PP7U6n3fmYbr6+eQ4r9JTgiR9WSlf2R+Nz62rc6LSvG8xvFOF4uzMAkpuqAanTFGYarjPnzZPwMF6IkiosD6ar9Fp79BJMVUlZ2zJifLTtwQzu3lVGu2WVF/9LjcncDmuYwj8R+doGdiLCXxUQJy6OHQ7llwzfoB5M/jpjh0Udb927Y2uoFwfbqV3BJo47B3yXT4aekYzEQpZws2VNNuO4q4GzoWAsa86T+lYl6Vy/4bHNpxZVnUjSOYcZ2Z5iF4Fo2lq8hknwxFuOVRXEyfV3B4Q3tZoWpaazG3SMYRyKUc3HMA/FMLIwxMGDlaaxrmBVxa0j7if4kJEeMtNDVf0Jfhrsr4l/q/jWKukjT1DNVeNHlnOM/v+t59y+8Ljyzu4QjyvvozEyyvtoDDMDo6Cs1tcwVDuBZ/UTYFycAOPtXobMVzJ0eQLP3p2iDk9SzFnVXPh5ey2/eRy05bJ2ehqJBtwpyntBcqNBjTNijuR1kJJi4CO5DrI0jNHPZYHFH/zjuHHsGDRzkbsWl2t8l02SpJKmcTFso+ygEfdbPSqUchTXquI6V3GjKm5yFZ9URfYGiDURzeYAAsxtIBgFcwg0oQHbuVgFPw4AcPJZJhM1v2nMgVcaP2FDGbPk9o19BQMNnotknGe7iIm3slqwnUmSUJn5vL9nmNhz6tvQJkH12v7acR/4F4nVeLmyOBv4To8XT5qJNsTSduVgRUnFI7wsmdI23ORrF4wKv9nwng9a22ZRa7upzlXp1HjyFDXJQyCFL89t4PoTe2sKt5/f+T6mauMHl/OdISjwX4k6ZhUeZtsXRmBBkioinb07l5+B5TH7oiF/63v+D//woug2HgAA")}, + {"frag", GzipedString("H4sIAAAAAAAACm2PsY7CMBBEe3/FluEOpchdF10FoqMBemSIcVays9bGNhyIfycO5C4CupVm5s2scKz22CI1UKOuHRwMSV+KKPkXGw1R7QuI2xBLERo8EFuwqsJgXZK+wavTGs/qX22ldUZxMQcK3gW/Um0wfindO8vOENmNOvnAHSISVmAlNtkELqLH1xXPyBDDT2pKtmKePYGn/b5JmRJfd+RrZtz0COSsd48Q96wuMPQlDT7HsI/h1fzY3X8+WQpttguWeuhMu7M7cDrydfuuN+jfGjNtAQAA")} +}}, +{{ + {"vert", GzipedString("H4sIAAAAAAAACmVQzWqEMBC+5ynmqGCDbT1VpIeeelso9CppzLoBTSROrFL23TubRZLaW2a+3wmbnJJ61tbARfeXCc6DFVizGZ2XCB8oTCdc96kcvpvJI/ywO29RsoLJzhpJWzMan8FYN4ohDBWQsleGrK41E4hOf3lUEHiijcJ/0G7yB3giANX6Zq3rDlB1g/Ysb/SZ9JB0lLKVYlROnOxM1YTbtOnvnkvrF1pZ3cEotIEsp/MOh+0vaIJdFrsX8MjLPDL4uhEpjePf0DRQ8hJeQ2CWUPlawEM6bzm8QLKoWT+0p0N6xIvI3UKTvc7tKKKn/3X9BVBGCNXmAQAA")}, + {"frag", GzipedString("H4sIAAAAAAAACu09aXPiSLLf/Ss0MREbAmMasOljWM8GBnxE0NgBbnf3TnQQMgisHSExkjDgXf/3zay7dAC21TO97/mLkaoys7KysvKoQ9772ZmM7Ylx1h12vlwPwztrbAfDSWDN7NvFZILPdjS62/vZXkW2Fzq+tw30F8P2rFvXBhRv7Ez2UhuIgNwisIeuP84mrQDFic4De+QQlDtnejc3Jq5vRY29hedM/GBmzOyxs5jNjXt7dGSMRsNwFNi2N3AebAlDEWdWRCDg98axl/FqTmAEnQysKz/MbmNmOV7XidpOsBWm5bv+BihrduvYXjT4fb0V5izwF944G2ziT7c0BhAnVmhvBGiONzTh2VZwakELUHBoDPpnJ9d+18FSwyRFU2s2swrGv/cCG4bTo+9Gkf429h6zR6QLBanDkgZzFfj/yho+VCh/eeHdI1Dbnkd3F97E3wz9RFAdyvWXcaDeaXewFejz+dXJVqDuVa9HgYjaG63WmR1RkROGTwN/hhIZzK2RTcfgHgXkhzgKFGfshJFxbLi2N43uTF7d4GNkkvqDJPflVcF4Y5jJ8nUGNA5wOpuUs6UfuGPGGukm8jKIrCCCQuAwNsqgNwhlcrTyav1QMqrliuR9izgU8ohMGAQbBWjDfqfVubjpDAfnzfbl59iQh9Zs7tpBrS27+dGaxxVDh5r7lHPHmxJY0sHmfO6uB4QA4e/EscLhKfDWAzKWaxIgplh+WDKkmChAYY9JyoOecDCQlEBp7DkTM6Et5QfjV6NSrlQqVUEBhUGJbpE0BSohfoGQl5hA9+9QDkRVfkC0xv6x0gAWFJNTJlasMAulLghTa4kwUKmWSHs4cGzI1ZaxOFvOV3YQzu1R5NzbCUFTNcX2QlQVgcTERWcR0SLSjPqG3VBGIKuzD8sY2oOG9aAixa1VeWXsK7DLjbDrBHsPOBzpxo206xERg4c044gF1ISEUJgyj1xnLkWivlGRxIWUrgIxzIdlHPMhjqiIBXqGmlozMwDWUm3TDJeYFjgxwAjpnAAjO9gTVVrxvgAFM1ZSNGrlCthLNFtEz5XapaLWunA3qfVlEN3508Ca3zmjJ+k1rRv59mTSNDIVZNVQAU+yAdccUBXLkMhAVfMDRgh9CW1b19fhAzceqUoX2OHCjXSTR8uIuGOUirx7+6xV4SkoTsxDUdGCPY784NwKxkZMnsJR4ejAe89Gbd0+KsqAJNx9eVlg8RMjihIW5MnsfaMW4OSvlOvQI/jLFJvWgpVAa1wx/vMfQxb9iqoGRXu8aJ2EWiehHpJQDxQKhGAwIcJbw3gUOGTWqxEzMHt8TCj/g01TAVleEdeN6iDL1gXjF+WdKxQVGNAGhoQ2un5ohxEROK/RJrlwJ+vEJNcwx35ksmyj1jZV/15SWCmUqEcElinfb4xavS5f3tYrNeW1+rb+vnr4DkoK6KsM2w3tZNM7NIvT73FPCCCM7LkQ4kNJk4KMgij4Bt0e+JPoVbd/CN32J5PQFhoh2CFiq0GyM8fMVTW6QrZIgwD5nn1tzY1jpnsMh1UyikPajtIEBmkMlfNy6/qj30GHyW+V/dbY7+Gu84tS4cqq9K+0ca7pMpSTYF14wdwD9aOdeRE7THi5c1XLS0icwVy4OsxZVnkxJ6zoBgV7hnKRPHWDkjxfQSTl9IF+/iBLyumD9eKB0pJ3jJy+GAa0NPPHKmPUeuCyQJFbHRku0gDrC2I5KzNuWgjNgg77VYUVZicOi29fE9ysBTdrlZu18IlImLFU4u1R0l/j6xRxT1n78uor/6/7Sh5UqhNh2FXdJXDI9T0DvK+B728D/6SAryX1dQZ4WwPfT4Bvdt7s94j91tnvW/b7jv2+/xOdvJBy3AANP/31Lj9pFvPh6mUuX2ja92EuF8+vjGc+8cjRjxVK1nMewXy4evudpmI7D+be5T0Vc+Hq/Xeaii9lLq84d6N9zSPqTbeReUS9G+1cjsFvzFZJyuk250XZRbrdeL7NkJTT5/6L571sIH3+Pn/uSsrpc/DF8y8lfXla8kKTjF1TjOxVyhcmQUrYxmFZK/vHakZjpKQ0KU0rUSEnl9KoEiPm0WhKH1IaVQLRjY3u1mZKF1LaFEHvc9pUFlpJIlarx7NIvgG8bVNB3eV9Wm6pbmi+ppZ/yhYDO0GRTEFz2nvQTw38yTsQGxpP24cYU2v9lD2ItDmRthnxOid+gDkxVhV/tw10jpI47yNGUtHFlFnEteUWhjJ1IWeZvo6zYcXnr94AGWflFfHZ9udsgDyLne++AfJSIX2fDZCcZPWdN0DGaUHzE5QrJRV8MsmdN0BewuzmDZAceH7RBkiKCfohtkKSfD1vUyTLdSd3R16d96vz3ui8X3dq/rKdmpe4tO++U5NTFJDzTs2LRPa9d2pyGs+cd2p+jJi3nvMI5rxTk/NUzHenJq+pmO9OTc5T8Tvt1Dw3Et15pyaHIDpjp+bZrO+6U5ODbDJ2avJLg+J246U2I2WnJkcVSd+pyUNF0ndqclSR152a152av2qnRt5Qxtt/nwad4cVJV1zoY1f5WotbG3MU27t3At+b2V7ErqFMAmt6TadA1x8bprz7BxOD6j+w4AdjfgXH9ccYjW+9Ec34FdMLqAOkSagygkiqAR0A35MATwUkPX3cyDjpKWf9MA/WkeKTmEeELewfGgtvbo1+75+ddNiqQzC9tZULxvhahj8w0nN/CX4dZhIpw1vHxLXj3avae3Ip7FEd/vbF6Sn8fmxeZWkBsDFZhDa5zcnVh/5QOZ2dffno3zqubZjMTviL6Z1nh+IeVs8/ZwLmvz22OgJPq3PMGwM/DM1eyTgX1ubSsz863iIE5MEfAds1AugSoggoCypEe9BX8cwBPAAAElBl8SLMri280htrYh+Ai4YnZ88cxaksCFnuaDC3RwsXL3o/ra/8krHKK85JsjZTq6O9FnI0FaKEHPa50OC6cNJvnzbn88BfsdvmIeOJs5DC0w3ZhfO9MGIXqzFqIyHgAYkBD8Al1N7VyUP9XY1cH6zV8GKfglPlOAQFII5qdRIiHlECRwV+WS02KNDaPqCLMatUjoiZ88ygvMJBQ3dnr+Y18+BDufYeSpDjAq0B1KDMV0eaJ5SHGuH7iLaOgIQmQuJ90+ZJeW0UcTUCb9PWcW2qKKRUnhLeYzeoeS0AAjY2ikT4XMGJ0u+cdjut64vL3rDd6V1eDDp0OM7sqOPd9+2Jiyt4vvfZie4+OvNTx43sAAIDOkb9zMGZOfOWv/Ai/j62Pd8J7QuPfCEiWjMbpJprgRiTMyclF8PcCCeIiVNnfDpemX2I/OFhDQ9EvtVKRQkGAP+ELmKhcyFCIlkAlSOhpsiOjzaue9ljQNJtrKk7kBKKAFne581w/AmRFKGgmsQEOhpFTQ64YFjbo80T43es2EmTlqOhYPSTILxGWGaNlvpdB1PWJClqgGqdNOPKwrOkVDJU4FJy5GMOAxWJjgr/o/oJ9hBGwWIUGYPI8sZWMB4sgok1svlatOXe2mOfLSLPfWgFNJa90uvQ7MWeOWHo3Nvs1cUodyZ3DPk7OMJQqFvC9s7syHJdZyQOso9G7iIkLT6ywW+1BKfgWWG64Jc5DDPOPl1cT15FODSYd8IwvUx7x/ygSZeMwzLngq+di6lO1ZxL9QimhkqilILaAxx5azws02dee6PVaovbuDSPvHCRC//VQ6SZtTKt25BMU/CBN5if09FVeJVm35QGPyyrvuKGc9LVODnQPtXCbmxTF6XBdWFu3kjOzhlnjKtzwRSr7+r1XVFPSE8cz3LJh1jQAXfpjoz6MRg2TPHSZUMb15bvRYGDs4wVNIRB7l6cnV9D3GL87W/GT1hw0rxunV/0zkgBmInTy/7nZr89bLbbZNE4LGtqK78NgZ8IUdmVgMgkDZtxHsZ4enNsHJarR9X6h9rb+mH9g5iMmprJHig+Rg0lTH0Qpb9ncggIM5KMGWNjP95UIZHw4eZL+hc/UFZQ2Ok1T7oYDPb5l0BQYDBsREYoIGZA5mTTadv3PJRNrJ7gZj6apG59sFNEWI2bRh8Kku+Me0nmnGzKkFUoiVrZjqoiZkPiaTUGKYDQUtAX4vyUzTmxr7QkIZowxPGBKx6Lw0GKshWP4yPMxTVpzm5Jrl4Hy9HDgIbu4hGtsGa3bdACxpj2ASVqu+LfS2L+Bmgm3GhGNkCGW8b+Se8s6+gop5KhPlqyq3hfiS8cnYTTfKqE1L2qOt36mikLaDhmHtwgb4XG1igOQg0gsDWW68dMbkLMSzSCb0WHiBCB9owIcHuApBCntjFGPSMGUrqgCJi2q/LCgTTpUrBUySqKun9McFWmUNmWSmSNj2XFx6cSYUMsrX+MGPfnMVo6kbAs4xMZHB2ZEkrx5Zaa8l5dXHW6F73O8PrrVQeFV9n7GQIvQLQN4lAGw6tOf3jVHAyMKhNcNkAltp7CzGir+2lw3el32tRHDVuful30S6S59K9qEQsABvO3WBvf5NeWNFDSyV2BcRmwb3lTu+lNXXtXLIgVUkC11H8w8/3oru2EUTOKeEqM39GCdJrnM453D29Q34f4bqF8j2tCjC3x7AQBhjwGK/wYaeaUw9N0hIZ3jEiRPaSmdip2UXuVuT3M/Gd2w4ogXF9YaC6UXfuVKfCBo2oR/wBLKjCYfk1+HMMoJRoTfVHwNd7JwBLmafzHlh5cEvGJBS2Hwg1GlmvHCy/J2rTs1mjMllw4ja5cc9F6TEcDwIt6AxCX6LTTxsbUBKJSViftLtMqPZtojscOHqv5YTOKrDAXlCgWW/5PJSBaOM3lAZWOFxneYkY2TUISe6VYZOMfCUv7C0yJyFQtU+Ub8YZgtgwTqToYKzXg5+9xZCjc38fRxVDRMX49lhwUjNvAtn7nH3LsfqIBqjDGzreE4ASsJmtA5V0fnMdqtKxqEE+bBt1YXjWIJ16DeObF7QSdn9A0UvlUkLk5MxtKZ2IeAPuVAKckJXZRPnNYx3UXMyOW9uDM0IhQ+6cVlTjTBdWKiPoLEpVI25nNNv2yGTOlGj6Y01iR0hKN7WKGthRH4EPoon7vmrANMGMbsJSNnU1SFWgpcyi+dRdeeJ4dKKN8oGo2VTqpGVXl4GN4uYgIZraEHpSBVayxKl72RUHByIGgXIgjX/Lj4wei8ZidJyOB0lfcEChlyUjtVMwHxbyPWOOWMY7SVxrzACWSlO+c4m4YFMx+syW5VLPfF+aw2cdI1WRZs887pLdZVDfT3IEISYGziChJrjJO6fktBOsDsvqjQiZHFCN/alxIEIAmJbHKQWZlQflWYCLkr/DtrScG5VWgCJx77tqgn3U2boejEXURJ7Tg3zRakOW/fWsYj400REhZYJoQqAvgY2RLGgv0VKkgO5E7C5yxpMUZigEwSmwduNUiFXz5RpkGjb1kQhEr06dErJJ89VlpiLLBvxs6c7wTTFlDZlLB7PB3iSN4BiwiGnpAokFfuKQJBuuHMbUj9mgSIAe/6MgrCV8NqpRlpaug6srAHS1Q2XDjbfEtDsxNThp4NQmuCygDr5bEA9llAB8iMNNv1p3HPSEn7L54oQJgw49ioBoxhap74r5SdIMVQBsKTfjT2MO/ZXFZiBHBKIFUcEaVKnmcnhJ4pKMGHCJVrtv2irIZ4veHS4YyysgxI5A+IwgKniMm4N/UFpiy/ZM2QLotDmsLWx0yv0fezNoRfnnT9afoCtgHvMtreoeKv66E+2NnuQ9MiVyMI692ISgo2mub3z48MEfi6+tAVnCOXoT08IH0CxdzMOolwRQ0wykgKyHLsJBPavdkTkWxU8SlSAtXolr0uEFCejoLCWkrp+L5MXBSjXMBz7iMbMclh6PEB+jLK5AKFWT1bSEN72s63lrgvUe0BbEkDlUPlA5JLBZkO1h0CG8WvOEHsSRjJa05zG9oDwvc2NBaXF6vvsXJ+H5RIAsSpLEyfnCXlvMSPOHOn1dC9oyM+HJtq8WE95qP5pCPklA454w0Nvrx2TJ1h6f6XDEl02IfXDemlIy009xEs8bU/FczriybXYh0dkHz2WqFPG1NYgmiKwwvZSNmjBUzXwLn2dB9JxMAc7CSVEHLkBP+9U9LkpVcKNc0eZNX/7Ez5Y2c/w8ky0ld2ilfToRTO6TMG0X142TNGV17TuKcEts+J3feOEavmXGumXHakH2X5JhoS7PVGVz7HtnfNdkJWACmhwWpDuEpvRGlQLzme+rx6LlAOvT4Ff1auV7VS0/I5nXlUC9tEdijWGmbbnR/0Es7pLR6JHcLRkxKZpN84p6I0Tgp0P/PwutaSl27AH86BSUeQ28OM3K+4B/fED1WNlbP230qAHbCS5GTKcrlbqkKGv4RRBoMjwxpfs33bOje66k/NfmxCnFfmP1vk7kvnAmETUMww2yrzPJGejBVMpZqPD7xp+S/vdDpyP7ZkfRiUNDxxnrlWglgcTfHZEAHvGkiYVHIWyDGFoOgguxYZzXfsVf4X5Zwv0ewAsGxtMPbe9Gmp+R0gIekzPhmXJbclA7RWYJZB+etaByVRZtAzF7NzQNOu6iwIUd6oglj8MfCCuzx/yOZpElnu6i61trOS05DoHLtz7XKlVpJHL9WveYX663ZZ5LgBv6/jNgNdfDDYKAUgPKaWCiGyhNjhroUKGqFQGH9aOOh2rY6s1XoksZPbBBq8uAuJfO1hA9ExHiGdBrgaU62+C17gRelmYB4PrHkd/2VckYSE2IuzgPapzXyIaXIGYm1jAsvjERReSJHmMQFQtkIEUmSBBY/SvhMZhUpNHWW9b4nWddFeLJbfxsK55in8pYPOJlCam8QVMAWDfkEUsEpZ3ImioZ8wrpCqsyQ3JM6ms5RxjCxcEZIh6BSfeJwP+EAMWXhdsckDhCj5n2Dd7aNiktxcFElpZSeRk9qr9pr3gLViZj5maTblnsf0nFw6tf9Zm9w2ukPTy/PhifNQUcYmZLhL3jAQc+Q4BqYEgsABj1hIM6rSN9NDwn+bLsJ8KoEZx4xG7amwSoOIxvlUOFGGk4BH9qyngb34jYRE0jz6qr7VUrD8VAKMh4q6RJR4kESV7JDh/xfLbIjh/KRofEyegLr3grWjjell8Tuh4t7kXO0OzcXrc6w1ewNTzq9zunF9fC0f/lxeNG7+nQ9bF5fN1vnHzu9a9a12D2lWtuYsv/GSde2tP9RlwTi8foWMLo6sQWIH0PTLkdBp356Qq/wuynD4U2nP8BTiUNc2zmqi5NlZMDwhLRh4jAklg2fLkTlIgA91zl1h10rjDAybluR9VvlW0Mc9uWSSgGrcjAhqRSgGgdSJJUCdvhNOzGpcifv+CVGuYRaVEhlNoml1Gt4KvdJLFGr4eidSWIp9RyPX89g669oe6WyyiSShjmcURo/qIdC9eolVnr8vxkKXjkaX9zV6ggOZxDNp+SV44lzl7HqpRJ+8QN0mcZVXycFWyCQuBSVf2UmHo3EP2Uk4VQxZemVk+GWKfUqiYkpulxS33/KpnDW4r1Okytu5tmzJDjRhKQR5pZXkZPsm8xbKVzh6ROfrWWzCYeSpjkp5V+sdLNDF7yOOo7/AlBhreU1eQAA")} +}}, +{{ + {"vert", GzipedString("H4sIAAAAAAAACuVZW2/aSBR+51eM1BcTCIsNSVN5+0AJTdiGi4KTrhQh5IKTOAs2tQ0xrPLf95yZsT22xwSitC8rRQTPOfOd2zeXY0pLz5ravu065NF+eFyS+7lrBnpJeCAza+rOrIZGFDa6tqZN4j38MMvk3xL+J5/pIzki2slJrZ6ePbIfHFBQa3VyTBQ/sJaKqp3V6lWi4KS7xrhMKqReOymXESA7vRMuXcdyAoAAGWgoC3emUJliO4GSA6kSCl/GAYk5TTB3DKofswZ7phPYvo9BSU1pMlNH5PTkpHEKDlZoKu7UMc2GMFIfw7ezxtnZaf0MbXpWsPIclp4jYoVLTYljPSZaA3BhPPJGL72U/MBbTSGhgenMTG92a3lB11muAqiCUJil69sB1FMvwWODOK63MOf0oUlg5gPgA5heMoPAs3+sAotQPXOSTMyJIpCUQANBYIVt1/VmGVETRZGtD/Y9abcnN6POpDe4Hl4Kqizj5mQNoVhhF2Agz+TBCm75gEIpxjKFJUhUy5iRlWPfg2vM5HQ6mdn+cm5OrQUY/m5BTgL/Tj0Z6zsVDSsEfKvr3Ls0TRo6MLRDa37lTk3MiEJHA6Z3bfnufIXDVXSJLFGz68ysEH1lESVjX4FGjEGCns7VQhAixQT1at5MLZmwYWiuJ04hfxTM4XlD55WwSjY0ZakAae2+eu4iHemcP1WJPHChKHSCEk2ogZn4+wbXCSwTmX/oCefFeee22+5MRjfD4eDamHy9GrSMidH527i57jDW3lvB9PEWmNjyPHOD7vKSKb65WM4tTztHC6wc1pwWNS5IukSQP1GB1ztyGaS50heTpRZuqiRVVQq2Wgsw+QQnud2JnJSP5047V2iMqzUt4wdr7lu/Oj2w/zR/RYrCvTIE7KHkquPmDR/l11NG0TcHoasHom8PQtf2R09Wa1MpRUeukql+CIdOoXCzS7hFIQRb4vRxZvY931UgnPPcxoknHjBGoMnPlYunMB2DNd1km7VnLUwc8mLRMdOk3IElrggan0ld2DsKNmycPa7B2nwhSHKSw1D3xdgUY2j7YmxjjP30nzG9L+zspQfZtCEm95XlyU+3KO18i6TH5mR43WkPesMbo3MeeVK89CmiiFaDS4iebBsNKJy/mmNB8UlBmsJfmRXVwfPXnlo+LWqwa4Vv8XByPcL4YpgeBA2z6nr88GcSgtG6vugYk/bgpm/opFLhKqwW1J0K3LpeiSpx7ii2UcnFCsICXnObdB3wPDLjerQsXtKJ515ftkaT4WDUNbqDfnyhSGoIORryG5Ro1ddjLsjEilD1mcDJV6hTZKxKUvcjHk9RNP3Bda91JY+lT698BZHkhW+PQ2LosCiMVv+i0zfkYRjsFloQh0T69kBkpuSRrF17Rszlcr7pud7yEdeOu5Jd7PGmHG2/ERA7f5ILsv46WRGmFl3v4bTBMyw/VinkqBDDfoyi4KxpEM0JI5UCGu1vKio7RebNhmhMHKoUFTtv7qWoOqnmKrc5y9KeyfieyU4VV/QrnQ9sp0bfuv1+t3+Rb76eXJsSPSd4ZodVqiv70vrWOZ+0+t1ei/qNIhzv9keQ5HbagNBpcjMtx16w5ol7GC1EQRWWB9VN9Vo79BLMtFJqbYuI0dG2A9O/+1QfZ2lVFP9rjcnCDJpYwr8QuWdCdkLCXhUQOyJHJofiS4Yn4EODvc7IZLGGt+7s2Ab4YmM7lRVso7gLwLP5pOiSYiQWZMJtnDXRjO2sR/bWAmOyOc/ptypJ5/qExzabWk7rhILOMcyQe4pdBKIpG/4aJsHjbznWKoiT628GhDW1ihLmptMbdISh7YuhFmM09sXQZBj84EGmKbQrWKu4dUT9BBvS8kON/JBae4avGv1s4KeKb62SPvId2Kxqv5LOEfr/l8+FfeFh9JZ3iIfR+2AMCb0PxmhIMEqp1fqWDDXfwbOTd8A4fQeMjzsz1Hhjhs7ewbNP78HDdyGzjM2l37fXspvHXlsubadnIW/A7bK4FyQ3GtQ4Io2xuA5yUgx8LPJApqGNf28WaPz+P7YTxY5BUxeZaxFdo7tsUqR00hQmhm2UHjT8flsLS5UCxU1acVOouE0rbgsVn9OK9A0QbSLa7REEWNhA0BQsINAkDdjORSr44wAAJz/LSFGLm8YC+FTjx22kxnSxfaO/goEGq0UyzqpdxsLrshYsM0kQpma+yHsG6jqwFP7f2tZztgsQxEPPfdJ3dyy8VwHl7643n9UlXVEkU3fItMTMVffi0ui1hnnlOVLAdh565vLmdmh65kIXlj2f/qVltC/TPkY/hM02zuSHGUwfJ/ZsR9TUIf9OZf1Mvu/Jqha0ZoLaFTo+nJuOxTLKNgvglLAwE4II9OGLNBphC132o1/cUCvxGpA1Y3FPy2guUWa8TiLL1z4SIrtxLytxJ2MKCPtVVqbukGk7ZHXc5ESY1KMWbYElGkeOCYLHqQqz3zxFVpTjksvnxGkSapQsFX6H5uuK3Uhz1YfhCK2c2oDiNxhbcvwZ01Cvq/G2nNun8G07koc8zOOXlZQwXgD7EHn5D/l/sXd7IAAA")}, + {"frag", GzipedString("H4sIAAAAAAAAClWNOw7DIBBEe06xJfTpUCpLaXMEC/FxVgIWrSEuIt89ARqn3Jn3ZkVhb3FHypC8w5YKhEimatEyBuIEkY4Cb29vYO26v4yjY6FIrMUIl+XBZnu2WloFObleK/gI9rVxnrcW5xTCDwd5qa8L8v+HGhahg2Qwdwm2uHZ81HAfa1JpOL+IyrsEyQAAAA==")} +}}, +{{ + {"vert", GzipedString("H4sIAAAAAAAACuVZbW/aSBD+zq9YqV9MID6wIU3PV504QluuDSAguZMihFzYJO6BTW1DDKf895vZXeNdbBOIaL+cVKV4Z/aZmWdmX8YuLHw6cQLHc8mj8/C4IPczzw6tgvRApnTiTalpEI2PruikRvyHr3aR/FvA/8l79kjOiFGv6xV19sB5cEGhqlfIOdGCkC60qnGpV8pEw0l35qhISqSi14tFBNid3ooWnkvdECBABhra3JtqTKY5bqilQMqEwRdxIMOcIZk7B9W3uwavbTd0ggCDyjRlZJk6Ixf1unkBDpYYFXfVEWNDGqmM4NeleXl5UblEmz4Nl77L6TkjNFoY2jbWc2KYgAvjsTdW4bkQhP5yAoSGtju1/ekt9cO2u1iGkAUpMQsvcELIp1WAR5O4nj+3Z+yhRmDmA+ADmFWww9B3vi5DSpiePU4mpkQxiCIwQBDSqOl5/nRHVENRbOuNc0+azfHNoDW+7vZ7nyRVzrg9XkEoNGoDDPBMHmh4KwY0VmKcKUxBolpERpaucw+ucZOTyXjqBIuZPaFzMPwXBU7C4K5aH1l7FYc0Anzadu89RpOBDvSciM6+eBMbGdHYaMj1+jTwZkscLqNLZIGabXdKI/SVR5SMfYAy4hUk6VlCLQIhlpikXk6b0ZMJa47m+fIU8kvOHMEbOq9FZbJmlCkBstx98L25GulMPJVJduBSUtgELZ6gg5nt7zWuE1gmWf6hJ6Iurlq37WZrPLjp9br94fjDl25jOB62/h7e9Fu8au9pOHm8hUps+L69RndFyrTAni9m1Deu0AJPB52xpG4ToqYI+JMVRL5jl0GaSn1+sejRukyUrDKw5UqCSROccLsXOUmf4M640liMyxVL4xs6C+iPpgf2n9qPoCg6iCGoHlZcFdy84U/xZcoY+voo9OqR6Juj0I3D0ZPVWtMK8ZGr7WQ/gkMnV7jeJ9ygEIItiPJxp8692FUgnKvUxoknHlSMVCbflx6ewmwM1nSNb9Y+nds45G9F51yT1Q4scU3SeE8q0t6Rs2Hj7JEOa/OZYJGTFEb1UIx1PoZxKMZmi3GY/hPS+8zPXnaQTUyZ3BeWpzjdYtrFFsmOzXGv32p2r3s3w9ZV7En+0meIMpoOlxAr2TZMSFywnGFC8UnDMoV/RZ5UF89fZ0IDltRw3wrf4OHk+YTXy9D2IWiYVbG2D78lIQwb/Y+t4bjZvekMLVIqCRWeC+ZOCW5dL0SVOHe2tVFKxQrCnLoWNtk6EDxy41a8LJ5V4oXXnxqDca87aA/b3c72QpHkEDjqiRuUbDWwtrWQJdakrE+lmnyhdPKMlYlyPxLx5EXT6favG1+yY+mwK19OJGnh6+PIMHRcFMNG52OrM8wOY8hvoTlxZEhfH0iWqexIVp4zJfZiMVtfe/7iEdeOt8y62ONNOd5+YyB+/iQXZOvlYkUYPb7ew2mDZ1h6rJRbo1IMh1UUA+dNg2xOGinllNHhpuK0M2TRbMjG5KFSXrLT5p7zsqM0V6nNOYv2HcYPJFtJruyXyge2U4PP7U6n3fmYbr6+eQ4r9JTgiR9WSlf2R+Nz62rc6LSvG8xvFOF4uzMAkpuqAanTFGYarjPnzZPwMF6IkiosD6ar9Fp79BJMVUlZ2zJifLTtwQzu3lVGu2WVF/9LjcncDmuYwj8R+doGdiLCXxUQJy6OHQ7llwzfoB5M/jpjh0Udb927Y2uoFwfbqV3BJo47B3yXT4aekYzEQpZws2VNNuO4q4GzoWAsa86T+lYl6Vy/4bHNpxZVnUjSOYcZ2Z5iF4Fo2lq8hknwxFuOVRXEyfV3B4Q3tZoWpaazG3SMYRyKUc3HMA/FMLIwxMGDlaaxrmBVxa0j7if4kJEeMtNDVf0Jfhrsr4l/q/jWKukjT1DNVeNHlnOM/v+t59y+8Ljyzu4QjyvvozEyyvtoDDMDo6Cs1tcwVDuBZ/UTYFycAOPtXobMVzJ0eQLP3p2iDk9SzFnVXPh5ey2/eRy05bJ2ehqJBtwpyntBcqNBjTNijuR1kJJi4CO5DrI0jNHPZYHFH/zjuHHsGDRzkbsWl2t8l02SpJKmcTFso+ygEfdbPSqUchTXquI6V3GjKm5yFZ9URfYGiDURzeYAAsxtIBgFcwg0oQHbuVgFPw4AcPJZJhM1v2nMgVcaP2FDGbPk9o19BQMNnotknGe7iIm3slqwnUmSUJn5vL9nmNhz6tvQJkH12v7acR/4F4nVeLmyOBv4To8XT5qJNsTSduVgRUnFI7wsmdI23ORrF4wKv9nwng9a22ZRa7upzlXp1HjyFDXJQyCFL89t4PoTe2sKt5/f+T6mauMHl/OdISjwX4k6ZhUeZtsXRmBBkioinb07l5+B5TH7oiF/63v+D//woug2HgAA")}, + {"frag", GzipedString("H4sIAAAAAAAACq1W227aQBB991eMlBcbDAGSqIloKkHiSpFKFGWjVn1CjlnISsZGaxtBLv/e2RteG0OVqi/gHZ85c9m52FlxGrGMpQm8sMXLCuZxGuZDp0jYPOVLWNIZK5YrWNPoHKJomkWc0oSwVzp0TtgcRvdPd6MfdyMyffr9EMD1NfQdiZ1vwtDNwuUqpnxwCznd+IJkAHMeLm7SlM/0mdMsjYscPfAdKVhP+eL5/pd+rU6B/Y5U3pHKu4kHb8qBKI1TPnSsAAbAkjXlGf35ANdS4Pa7PTi1XOiil3uyrTcUlGcg/UJVDCYvOB3cuios5bDX3WxfLWRwCBnUkOQQJ6lzkkOcxOI8F4gbEf0B8MSKZwIKJPGWsbhYhipJZ26vO7i68qHXvbj8Iv76/XNkkIUicTInszR39b0JWRUQWICgAUAsBtLEQCwG0sQg49CAiQ8NAJYgYskSV558+WiOxmu8Gn+HMY5gbr0qVbgRVOFmR4WP5lil0sIaVaUmZwyrFH+6grTjahJoGxbogObQMkGiNLaoATUNrBmjgWm3NVQAqPdIZ0VEdQh1ezuaUhdajqiBC2iBbpjLbs/D8MTpFPoDeTQGeLS6ZVylW6FlmsPnzJVRop553noeWtl5pKLStyTbE4l9acx3hK9S1pHCjpIKfKs0iXytssnLKh8hKZavCMCpdcRuHNmayqsy3jP87QgGT7YZtD/JMmhisbpwjP5JN1vSzTaYdH/OTkdw/4uDRq9S5uOyo8a7jsORr0pmDF9NX3nw/g5a+M10iOc5kZ5BYiYJlpFfThrBReOM7oHGNRCnGEZipvmHc0KTGZs765BvWbIwe6BYlyurXDppka+K/JFmRZxPwhXmO2UzQR+JTGTuX/cREkB1J9UkQR1D9jBkD2N2VHUf7a+iLTo8NTvHLW+wrXZXpy8boS+ar1b2U7N/9rWOK5Fjpg4qHbF0SGdiNnBjYXripuVlLUMcJK5IWGVo6rwMm6RBk5Q0YkkjdnL008auEAyi8k2k7qxSVSJOLE8xpXZqQ6esQav8rMqzPoJ0nVmfPrqqymW+iKffJY1qJfnpVat9H/6HoRPZsjVz5aTZsykil2qyZz/+AIV0zVNtCgAA")} +}}, +{{ + {"vert", GzipedString("H4sIAAAAAAAACn1STW+DMAy98yt8hKqLKHDYhLrLdtlp1Sb1MlVVBinNBAkKhn5M/e8zAUrbaeMQFL/n52c7TmlEIiupFWxlti1hk2uOsVMrudGm6IMFxwiSZE3/pRS7f+CF0V+xU6GpE4R35CrlJl0Kgy+qrBG+nS6jEUkEpa4kUuXYoWsIigR5bi8RUGYmFBk5xQ5HNPKzRgGWx9dj4i9oELkCAgJQ7J+0NukNFLXQUKvh5iBVBoVIZV30Lhtq+Fma3ldDrYDrUSN9HOaW5o6upjBjvhc7dir9xN40vqr8QOQ26tIRuuM8Pa9XJ4mOcpkzGS3IDbjjnD/CFdvBI/hUjgwN9VqIVC73YWdQJTwXnd3Aje6ZP4UgGpxaPX/F9lRv3lHH+OyPeLBix92geDe70govMd9C5+6sw0nbLe0XRF4Jst+ho+szoUXYkTCfPbRfBzB6hUZgbdRAa7RMSV2qdj2Q5etFvxDrwqDrxXD6AexaW+7wAgAA")}, + {"frag", GzipedString("H4sIAAAAAAAACo1TTXObMBC98yt2JhfRusT4YyYdJgcb0/bQTDNxcmZkWTCaIIkIsON28t+7krANPfUipKfdt7tPj6A2nIlGaAWS70UnaygqTdsk6JQotJEX+MDZAhjLqdwJrtrt6+ka01BZV9yk3Y7bEK4OwmglMSwJMG8Onaope336vs6AOCJT7ngIfwLD284od4xwgU9Q6yOJo3jiMYrIbLmMpvAF4tldNA2T4MNzbpHuWf8UilPjWOdQUinpgNadkcF9L4mrNNs+a8UfaN3nMV1pY/PcBu5BCkXcfmLnnhNbGCszrZrWCwQrDJtFy3iMrhGdRtP5GE1d7OIfdONil1/HaObQeJGch/CN4BRkhYs/fIZ1GMLt4C4d3G1CXLKzUgtI02+Glr+6tu7aXv/LxDeiwPv8ZZvlPzZPXgD3EvdDncgFR9YbrvaiGIU2b6YdxfS9O8j1Qc1JqHLspoPgx40wie+ywB6BnHuyDVm/5OnLOntYPfqnY1jr6iXS8ncsw63vyNh3kzN59H76Hbqmq4ZfSYbm+W+a8fz9iENxnbaE2acY/ijRcQKxdxAqocUeJEWD4ahQVrlNT3vfWQ1ImMDHX+tknNOYAwAA")} +}}, +{{ + {"vert", GzipedString("H4sIAAAAAAAACmWRzXKCMBDH73mKPYbKUERvlF76At4dh0EMuB1IMiHgR8d37yaCWnrKZve/X79l2ogSO1QSWnHAvtVQNaqwKeslVsq0cMT6qKEt7BrKMqd3Y9R3ygprDe57K2AQ5QqKXKsOLdWZhdYUKlWjTMqGwlxQ1s6bwJD3w7OJF6qq6oSdOQ9Yo+22SbxLmZ8MamG/VKuVFNJyrxnC+9CAAfwwrIAjfMAyiukLRtjeSBiicwo3JppOwKRIZorLP8Vqprg+FC/Ok3Pe2H0UYSxwNwaRSkATK8gcvYQ/6W3jXXS+hC88t0vnCVLmE94zKPYd11MAFjDZTuP5Tbipus95ezkBlaKUO06yKYNgk3C8hHe5Daf/FT4ziP2qI2NX9g/n8QxI5iMr2IWPkqdg7LLI/H352P1Kg8nQF0+J0cSMUPFpWh8N/bmcZFB4IGAoHUWom3zz3NTR5QHh/gXZdriptwIAAA==")}, + {"frag", GzipedString("H4sIAAAAAAAACk2OPQuDMBCG9/yKGxPoJN1CJ6Vrl+4S9JSDfHEmwVL879XYwfFe3vd5TkTGgRYKHhyOlF2EyQaTtCg43KFtn2zmV04xJ5A1GoINrOArGFNmf95abKIY/pCfYW81UPpctMiepsAOFuOiRW46cIb8G9d9iX/FtAtAXoBXp0xnt+nkZXmreKWqNdBYqQcCZtsf4/b4CR6VLZWG7QcpXInE5wAAAA==")} +}}, +{{ + {"vert", GzipedString("H4sIAAAAAAAACnVQS27DIBDdc4pZ2mnqkqg7lFUvEKkHsAgeR1Q2oDGQpFXuXrDb4EW7nDfzfsMcodKTtgZG7HQYHfSDlV4w6T3pU/AIEdUeZOvspH06/GPl8fpmLXWCRUk3bc7LIrYhChaM7i2NGXqF0J5C3yPxf/BdwUfpM+7IfqBajOfTiOShquGLzSYXS0N3tBMcVhlhUxSb6w2eVuPnRSxMNWj37qTCRH2ovJSImbiBfcPhGXYN/7GfFCGaxXCdLp3mffVQ3QJv+DYz60RNr5gTllcR+kCm6Al2Z9HqLhXXJveD89Aefwsd5t5VLeD+DbNlcPy0AQAA")}, + {"frag", GzipedString("H4sIAAAAAAAACk2OzYqDMBRG93mKb6mDiJXuQldT+gSzl5BeJZAfuTWhneK7N5rSmWXIud85YmbS5maCh6OriW7GaINapEiKH8ZPSKR7pCEmKaI3Y2BXCMRhJtbkl7+Pm3KzJe7PcMr4H7ovkSlPkT5iZDWhqvEsTx1sYJywFKg/V/9Oml1YS1FMb0+mtc2G6mNu0LVdg0PbZXZfbO+PX3yd8EljyoO+6KRYRQrmutdtKZjscMld3++YrbGqJdYX5dLZBhcBAAA=")} +}} +}; +} // namespace cc diff --git a/native/cocos/core/builtin/shader-sources/glsl1.cpp.in b/native/cocos/core/builtin/shader-sources/glsl1.cpp.in new file mode 100644 index 0000000000..272c695356 --- /dev/null +++ b/native/cocos/core/builtin/shader-sources/glsl1.cpp.in @@ -0,0 +1,33 @@ +/**************************************************************************** + 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. +****************************************************************************/ +// clang-format off +#include "glsl1.h" + +namespace cc { + +ShaderSource builtinGLSL1{ +${PLACE_HOLDER} +}; +} diff --git a/native/cocos/core/builtin/shader-sources/glsl1.h b/native/cocos/core/builtin/shader-sources/glsl1.h new file mode 100644 index 0000000000..8ef9cc8448 --- /dev/null +++ b/native/cocos/core/builtin/shader-sources/glsl1.h @@ -0,0 +1,34 @@ +/**************************************************************************** + 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 "core/builtin/ShaderSourceAssembly.h" + +namespace cc { + +extern ShaderSource builtinGLSL1; + +} diff --git a/native/cocos/core/builtin/shader-sources/glsl1.ts b/native/cocos/core/builtin/shader-sources/glsl1.ts new file mode 100644 index 0000000000..4ee18790eb --- /dev/null +++ b/native/cocos/core/builtin/shader-sources/glsl1.ts @@ -0,0 +1,143 @@ +/* eslint-disable */ +export const glsl1 = [ + [ + { + "vert": "\nprecision mediump float;\nuniform highp mat4 cc_matView;\nuniform highp mat4 cc_matViewInv;\nuniform highp mat4 cc_matViewProj;\nuniform highp mat4 cc_matWorld;\nvec4 quaternionFromAxis (vec3 xAxis,vec3 yAxis,vec3 zAxis){\nmat3 m = mat3(xAxis,yAxis,zAxis);\nfloat trace = m[0][0] + m[1][1] + m[2][2];\nvec4 quat;\nif (trace > 0.) {\nfloat s = 0.5 / sqrt(trace + 1.0);\nquat.w = 0.25 / s;\nquat.x = (m[2][1] - m[1][2]) * s;\nquat.y = (m[0][2] - m[2][0]) * s;\nquat.z = (m[1][0] - m[0][1]) * s;\n} else if ((m[0][0] > m[1][1]) && (m[0][0] > m[2][2])) {\nfloat s = 2.0 * sqrt(1.0 + m[0][0] - m[1][1] - m[2][2]);\nquat.w = (m[2][1] - m[1][2]) / s;\nquat.x = 0.25 * s;\nquat.y = (m[0][1] + m[1][0]) / s;\nquat.z = (m[0][2] + m[2][0]) / s;\n} else if (m[1][1] > m[2][2]) {\nfloat s = 2.0 * sqrt(1.0 + m[1][1] - m[0][0] - m[2][2]);\nquat.w = (m[0][2] - m[2][0]) / s;\nquat.x = (m[0][1] + m[1][0]) / s;\nquat.y = 0.25 * s;\nquat.z = (m[1][2] + m[2][1]) / s;\n} else {\nfloat s = 2.0 * sqrt(1.0 + m[2][2] - m[0][0] - m[1][1]);\nquat.w = (m[1][0] - m[0][1]) / s;\nquat.x = (m[0][2] + m[2][0]) / s;\nquat.y = (m[1][2] + m[2][1]) / s;\nquat.z = 0.25 * s;\n}\nfloat len = quat.x * quat.x + quat.y * quat.y + quat.z * quat.z + quat.w * quat.w;\nif (len > 0.) {\nlen = 1. / sqrt(len);\nquat.x = quat.x * len;\nquat.y = quat.y * len;\nquat.z = quat.z * len;\nquat.w = quat.w * len;\n}\nreturn quat;\n}\nvec4 quaternionFromEuler (vec3 angle){\nfloat x = angle.x / 2.;\nfloat y = angle.y / 2.;\nfloat z = angle.z / 2.;\nfloat sx = sin(x);\nfloat cx = cos(x);\nfloat sy = sin(y);\nfloat cy = cos(y);\nfloat sz = sin(z);\nfloat cz = cos(z);\nvec4 quat = vec4(0);\nquat.x = sx * cy * cz + cx * sy * sz;\nquat.y = cx * sy * cz + sx * cy * sz;\nquat.z = cx * cy * sz - sx * sy * cz;\nquat.w = cx * cy * cz - sx * sy * sz;\nreturn quat;\n}\nvec4 quatMultiply (vec4 a, vec4 b){\nvec4 quat;\nquat.x = a.x * b.w + a.w * b.x + a.y * b.z - a.z * b.y;\nquat.y = a.y * b.w + a.w * b.y + a.z * b.x - a.x * b.z;\nquat.z = a.z * b.w + a.w * b.z + a.x * b.y - a.y * b.x;\nquat.w = a.w * b.w - a.x * b.x - a.y * b.y - a.z * b.z;\nreturn quat;\n}\nvoid rotateVecFromQuat (inout vec3 v, vec4 q){\nfloat ix = q.w * v.x + q.y * v.z - q.z * v.y;\nfloat iy = q.w * v.y + q.z * v.x - q.x * v.z;\nfloat iz = q.w * v.z + q.x * v.y - q.y * v.x;\nfloat iw = -q.x * v.x - q.y * v.y - q.z * v.z;\nv.x = ix * q.w + iw * -q.x + iy * -q.z - iz * -q.y;\nv.y = iy * q.w + iw * -q.y + iz * -q.x - ix * -q.z;\nv.z = iz * q.w + iw * -q.z + ix * -q.y - iy * -q.x;\n}\nvec3 rotateInLocalSpace (vec3 pos, vec3 xAxis, vec3 yAxis, vec3 zAxis, vec4 q){\nvec4 viewQuat = quaternionFromAxis(xAxis, yAxis, zAxis);\nvec4 rotQuat = quatMultiply(viewQuat, q);\nrotateVecFromQuat(pos, rotQuat);\nreturn pos;\n}\nvarying mediump vec2 uv;\nvarying mediump vec4 color;\nvoid computeVertPos (inout vec4 pos, vec2 vertOffset, vec4 q, vec3 s\n, mat4 viewInv\n) {\nvec3 viewSpaceVert = vec3(vertOffset.x * s.x, vertOffset.y * s.y, 0.);\nvec3 camX = normalize(vec3(viewInv[0][0], viewInv[1][0], viewInv[2][0]));\nvec3 camY = normalize(vec3(viewInv[0][1], viewInv[1][1], viewInv[2][1]));\nvec3 camZ = normalize(vec3(viewInv[0][2], viewInv[1][2], viewInv[2][2]));\npos.xyz += rotateInLocalSpace(viewSpaceVert, camX, camY, camZ, q);\n}\nattribute vec3 a_position;\nattribute vec2 a_texCoord;\nattribute vec4 a_color;\nuniform vec4 cc_size_rotation;\nvec4 vs_main() {\nvec4 pos = vec4(a_position, 1);\npos = cc_matWorld * pos;\nvec2 vertOffset = a_texCoord.xy - 0.5;\ncomputeVertPos(pos, vertOffset, quaternionFromEuler(vec3(0., 0., cc_size_rotation.z)), vec3(cc_size_rotation.xy, 0.), cc_matViewInv);\npos = cc_matViewProj * pos;\nuv = a_texCoord.xy;\ncolor = a_color;\nreturn pos;\n}\nvoid main() { gl_Position = vs_main(); }", + "frag": "\nprecision mediump float;\nvec4 CCFragOutput (vec4 color) {\nreturn color;\n}\nvarying vec2 uv;\nvarying vec4 color;\nuniform sampler2D mainTexture;\nuniform vec4 tintColor;\nvec4 add () {\nvec4 col = 2.0 * color * tintColor * texture2D(mainTexture, uv);\nreturn CCFragOutput(col);\n}\nvoid main() { gl_FragColor = add(); }", + } + ], + [ + { + "vert": "\nprecision highp float;\nattribute vec3 a_position;\nvec4 vert () {\nvec4 pos = vec4(a_position, 1);\nreturn pos;\n}\nvoid main() { gl_Position = vert(); }", + "frag": "\nprecision highp float;\nvec4 frag () {\nvec4 o = vec4(1.0);\nreturn o;\n}\nvoid main() { gl_FragColor = frag(); }", + } + ], + [ + { + "vert": "\nprecision highp float;\nuniform highp mat4 cc_matViewProj;\nuniform highp mat4 cc_matWorld;\nattribute vec3 a_position;\nattribute vec4 a_color;\nvarying vec4 v_color;\nattribute float a_dist;\nvarying float v_dist;\nvec4 vert () {\nvec4 pos = vec4(a_position, 1);\npos = cc_matViewProj * cc_matWorld * pos;\nv_color = a_color;\nv_dist = a_dist;\nreturn pos;\n}\nvoid main() { gl_Position = vert(); }", + "frag": "\n#ifdef GL_OES_standard_derivatives\n#extension GL_OES_standard_derivatives: enable\n#endif\nprecision highp float;\nvarying vec4 v_color;\nvarying float v_dist;\nvec4 frag () {\nvec4 o = v_color;\n#ifdef GL_OES_standard_derivatives\nfloat aa = fwidth(v_dist);\n#else\nfloat aa = 0.05;\n#endif\nfloat alpha = 1. - smoothstep(-aa, 0., abs(v_dist) - 1.0);\no.rgb *= o.a;\no *= alpha;\nreturn o;\n}\nvoid main() { gl_FragColor = frag(); }", + } + ], + [ + { + "vert": "\nprecision highp float;\nuniform highp mat4 cc_matViewProj;\nuniform highp vec4 cc_worldBoundCenter;\nuniform highp vec4 cc_worldBoundHalfExtents;\nattribute vec3 a_position;\nvec4 vert () {\nvec4 position;\nposition = vec4(a_position, 1.0);\nposition *= cc_worldBoundHalfExtents;\nposition += cc_worldBoundCenter;\nposition = cc_matViewProj * position;\nreturn position;\n}\nvoid main() { gl_Position = vert(); }", + "frag": "\nprecision mediump float;\nvec4 frag () {\nreturn vec4(1, 0, 0, 1);\n}\nvoid main() { gl_FragColor = frag(); }", + } + ], + [ + { + "vert": "\nprecision mediump float;\nvec4 quaternionFromAxis (vec3 xAxis,vec3 yAxis,vec3 zAxis){\nmat3 m = mat3(xAxis,yAxis,zAxis);\nfloat trace = m[0][0] + m[1][1] + m[2][2];\nvec4 quat;\nif (trace > 0.) {\nfloat s = 0.5 / sqrt(trace + 1.0);\nquat.w = 0.25 / s;\nquat.x = (m[2][1] - m[1][2]) * s;\nquat.y = (m[0][2] - m[2][0]) * s;\nquat.z = (m[1][0] - m[0][1]) * s;\n} else if ((m[0][0] > m[1][1]) && (m[0][0] > m[2][2])) {\nfloat s = 2.0 * sqrt(1.0 + m[0][0] - m[1][1] - m[2][2]);\nquat.w = (m[2][1] - m[1][2]) / s;\nquat.x = 0.25 * s;\nquat.y = (m[0][1] + m[1][0]) / s;\nquat.z = (m[0][2] + m[2][0]) / s;\n} else if (m[1][1] > m[2][2]) {\nfloat s = 2.0 * sqrt(1.0 + m[1][1] - m[0][0] - m[2][2]);\nquat.w = (m[0][2] - m[2][0]) / s;\nquat.x = (m[0][1] + m[1][0]) / s;\nquat.y = 0.25 * s;\nquat.z = (m[1][2] + m[2][1]) / s;\n} else {\nfloat s = 2.0 * sqrt(1.0 + m[2][2] - m[0][0] - m[1][1]);\nquat.w = (m[1][0] - m[0][1]) / s;\nquat.x = (m[0][2] + m[2][0]) / s;\nquat.y = (m[1][2] + m[2][1]) / s;\nquat.z = 0.25 * s;\n}\nfloat len = quat.x * quat.x + quat.y * quat.y + quat.z * quat.z + quat.w * quat.w;\nif (len > 0.) {\nlen = 1. / sqrt(len);\nquat.x = quat.x * len;\nquat.y = quat.y * len;\nquat.z = quat.z * len;\nquat.w = quat.w * len;\n}\nreturn quat;\n}\nvec4 quaternionFromEuler (vec3 angle){\nfloat x = angle.x / 2.;\nfloat y = angle.y / 2.;\nfloat z = angle.z / 2.;\nfloat sx = sin(x);\nfloat cx = cos(x);\nfloat sy = sin(y);\nfloat cy = cos(y);\nfloat sz = sin(z);\nfloat cz = cos(z);\nvec4 quat = vec4(0);\nquat.x = sx * cy * cz + cx * sy * sz;\nquat.y = cx * sy * cz + sx * cy * sz;\nquat.z = cx * cy * sz - sx * sy * cz;\nquat.w = cx * cy * cz - sx * sy * sz;\nreturn quat;\n}\nmat4 matrixFromRT (vec4 q, vec3 p){\nfloat x2 = q.x + q.x;\nfloat y2 = q.y + q.y;\nfloat z2 = q.z + q.z;\nfloat xx = q.x * x2;\nfloat xy = q.x * y2;\nfloat xz = q.x * z2;\nfloat yy = q.y * y2;\nfloat yz = q.y * z2;\nfloat zz = q.z * z2;\nfloat wx = q.w * x2;\nfloat wy = q.w * y2;\nfloat wz = q.w * z2;\nreturn mat4(\n1. - (yy + zz), xy + wz, xz - wy, 0,\nxy - wz, 1. - (xx + zz), yz + wx, 0,\nxz + wy, yz - wx, 1. - (xx + yy), 0,\np.x, p.y, p.z, 1\n);\n}\nmat4 matFromRTS (vec4 q, vec3 t, vec3 s){\nfloat x = q.x, y = q.y, z = q.z, w = q.w;\nfloat x2 = x + x;\nfloat y2 = y + y;\nfloat z2 = z + z;\nfloat xx = x * x2;\nfloat xy = x * y2;\nfloat xz = x * z2;\nfloat yy = y * y2;\nfloat yz = y * z2;\nfloat zz = z * z2;\nfloat wx = w * x2;\nfloat wy = w * y2;\nfloat wz = w * z2;\nfloat sx = s.x;\nfloat sy = s.y;\nfloat sz = s.z;\nreturn mat4((1. - (yy + zz)) * sx, (xy + wz) * sx, (xz - wy) * sx, 0,\n(xy - wz) * sy, (1. - (xx + zz)) * sy, (yz + wx) * sy, 0,\n(xz + wy) * sz, (yz - wx) * sz, (1. - (xx + yy)) * sz, 0,\nt.x, t.y, t.z, 1);\n}\nvec4 quatMultiply (vec4 a, vec4 b){\nvec4 quat;\nquat.x = a.x * b.w + a.w * b.x + a.y * b.z - a.z * b.y;\nquat.y = a.y * b.w + a.w * b.y + a.z * b.x - a.x * b.z;\nquat.z = a.z * b.w + a.w * b.z + a.x * b.y - a.y * b.x;\nquat.w = a.w * b.w - a.x * b.x - a.y * b.y - a.z * b.z;\nreturn quat;\n}\nvoid rotateVecFromQuat (inout vec3 v, vec4 q){\nfloat ix = q.w * v.x + q.y * v.z - q.z * v.y;\nfloat iy = q.w * v.y + q.z * v.x - q.x * v.z;\nfloat iz = q.w * v.z + q.x * v.y - q.y * v.x;\nfloat iw = -q.x * v.x - q.y * v.y - q.z * v.z;\nv.x = ix * q.w + iw * -q.x + iy * -q.z - iz * -q.y;\nv.y = iy * q.w + iw * -q.y + iz * -q.x - ix * -q.z;\nv.z = iz * q.w + iw * -q.z + ix * -q.y - iy * -q.x;\n}\nvec3 rotateInLocalSpace (vec3 pos, vec3 xAxis, vec3 yAxis, vec3 zAxis, vec4 q){\nvec4 viewQuat = quaternionFromAxis(xAxis, yAxis, zAxis);\nvec4 rotQuat = quatMultiply(viewQuat, q);\nrotateVecFromQuat(pos, rotQuat);\nreturn pos;\n}\nmat3 quatToMat3(vec4 q) {\nvec3 m0 = vec3(\n1.0 - 2.0 * q.y * q.y - 2.0 * q.z * q.z,\n2.0 * q.x * q.y + 2.0 * q.w * q.z,\n2.0 * q.x * q.z - 2.0 * q.w * q.y);\nvec3 m1 = vec3(\n2.0 * q.x * q.y - 2.0 * q.w * q.z,\n1.0 - 2.0 * q.x * q.x - 2.0 * q.z * q.z,\n2.0 * q.y * q.z + 2.0 * q.w * q.x);\nvec3 m2 = vec3(\n2.0 * q.x * q.z + 2.0 * q.w * q.y,\n2.0 * q.y * q.z - 2.0 * q.w * q.x,\n1.0 - 2.0 * q.x * q.x - 2.0 * q.y * q.y);\nreturn mat3(m0, m1, m2);\n}\nvec4 mat3ToQuat(mat3 mat) {\nfloat tr = mat[0][0] + mat[1][1] + mat[2][2];\nfloat qw, qx, qy, qz;\nif (tr > 0.0) {\nfloat S = sqrt(tr + 1.0) * 2.0;\nfloat invS = 1.0 / S;\nqw = 0.25 * S;\nqx = (mat[1][2] - mat[2][1]) * invS;\nqy = (mat[2][0] - mat[0][2]) * invS;\nqz = (mat[0][1] - mat[1][0]) * invS;\n} else if ((mat[0][0] > mat[1][1])&&(mat[0][0] > mat[2][2])) {\nfloat S = sqrt(1.0 + mat[0][0] - mat[1][1] - mat[2][2]) * 2.0;\nfloat invS = 1.0 / S;\nqw = (mat[1][2] - mat[2][1]) * invS;\nqx = 0.25 * S;\nqy = (mat[1][0] + mat[0][1]) * invS;\nqz = (mat[2][0] + mat[0][2]) * invS;\n} else if (mat[1][1] > mat[2][2]) {\nfloat S = sqrt(1.0 + mat[1][1] - mat[0][0] - mat[2][2]) * 2.0;\nfloat invS = 1.0 / S;\nqw = (mat[2][0] - mat[0][2]) * invS;\nqx = (mat[1][0] + mat[0][1]) * invS;\nqy = 0.25 * S;\nqz = (mat[2][1] + mat[1][2]) * invS;\n} else {\nfloat S = sqrt(1.0 + mat[2][2] - mat[0][0] - mat[1][1]) * 2.0;\nfloat invS = 1.0 / S;\nqw = (mat[0][1] - mat[1][0]) * invS;\nqx = (mat[2][0] + mat[0][2]) * invS;\nqy = (mat[2][1] + mat[1][2]) * invS;\nqz = 0.25 * S;\n}\nreturn vec4(qx, qy, qz, qw);\n}\nvec4 eulerToQuat(vec3 euler) {\nvec3 er = euler * 0.5;\nfloat x = er.x, y = er.y, z = er.z;\nfloat sx = sin(x);\nfloat cx = cos(x);\nfloat sy = sin(y);\nfloat cy = cos(y);\nfloat sz = sin(z);\nfloat cz = cos(z);\nvec4 quat;\nquat.x = sx * cy * cz + cx * sy * sz;\nquat.y = cx * sy * cz + sx * cy * sz;\nquat.z = cx * cy * sz - sx * sy * cz;\nquat.w = cx * cy * cz - sx * sy * sz;\nreturn quat;\n}\nuniform vec4 mainTiling_Offset;\nuniform vec4 frameTile_velLenScale;\nuniform vec4 scale;\nuniform vec4 nodeRotation;\nuniform highp mat4 cc_matView;\nuniform highp mat4 cc_matViewInv;\nuniform highp mat4 cc_matViewProj;\nuniform highp vec4 cc_cameraPos;\nuniform highp mat4 cc_matWorld;\nvarying mediump vec2 uv;\nvarying mediump vec4 color;\nvoid computeVertPos (inout vec4 pos, vec2 vertOffset, vec4 q, vec3 s\n#if CC_RENDER_MODE == 0 || CC_RENDER_MODE == 3\n, mat4 viewInv\n#endif\n#if CC_RENDER_MODE == 1\n, vec3 eye\n, vec4 velocity\n, float velocityScale\n, float lengthScale\n, float xIndex\n#endif\n) {\n#if CC_RENDER_MODE == 0\nvec3 viewSpaceVert = vec3(vertOffset.x * s.x, vertOffset.y * s.y, 0.);\nvec3 camX = normalize(vec3(viewInv[0][0], viewInv[1][0], viewInv[2][0]));\nvec3 camY = normalize(vec3(viewInv[0][1], viewInv[1][1], viewInv[2][1]));\nvec3 camZ = normalize(vec3(viewInv[0][2], viewInv[1][2], viewInv[2][2]));\npos.xyz += rotateInLocalSpace(viewSpaceVert, camX, camY, camZ, q);\n#elif CC_RENDER_MODE == 1\nvec3 camRight = normalize(cross(pos.xyz - eye, velocity.xyz)) * s.x;\nvec3 camUp = velocity.xyz * velocityScale + normalize(velocity.xyz) * lengthScale * s.y;\npos.xyz += (camRight * abs(vertOffset.x) * sign(vertOffset.y)) - camUp * xIndex;\n#elif CC_RENDER_MODE == 2\nvec3 viewSpaceVert = vec3(vertOffset.x * s.x, vertOffset.y * s.y, 0.);\nvec3 camX = vec3(1, 0, 0);\nvec3 camY = vec3(0, 0, -1);\npos.xyz += rotateInLocalSpace(viewSpaceVert, camX, camY, cross(camX, camY), q);\n#elif CC_RENDER_MODE == 3\nvec3 viewSpaceVert = vec3(vertOffset.x * s.x, vertOffset.y * s.y, 0.);\nrotateVecFromQuat(viewSpaceVert, q);\nvec3 camX = normalize(vec3(cc_matView[0][0], cc_matView[1][0], cc_matView[2][0]));\nvec3 camY = vec3(0, 1, 0);\nvec3 offset = camX * viewSpaceVert.x + camY * viewSpaceVert.y;\npos.xyz += offset;\n#else\npos.x += vertOffset.x;\npos.y += vertOffset.y;\n#endif\n}\nvec2 computeUV (float frameIndex, vec2 vertIndex, vec2 frameTile){\nvec2 aniUV = vec2(0, floor(frameIndex * frameTile.y));\naniUV.x = floor(frameIndex * frameTile.x * frameTile.y - aniUV.y * frameTile.x);\n#if CC_RENDER_MODE != 4\nvertIndex.y = 1. - vertIndex.y;\n#endif\nreturn (aniUV.xy + vertIndex) / vec2(frameTile.x, frameTile.y);\n}\nuniform vec4 u_sampleInfo;\nuniform vec4 u_worldRot;\nuniform vec4 u_timeDelta;\nattribute vec4 a_position_starttime;\nattribute vec4 a_size_uv;\nattribute vec4 a_rotation_uv;\nattribute vec4 a_color;\nattribute vec4 a_dir_life;\nattribute float a_rndSeed;\n#if CC_RENDER_MODE == 4\nattribute vec3 a_texCoord;\nattribute vec3 a_texCoord3;\nattribute vec3 a_normal;\nattribute vec4 a_color1;\n#endif\nvec3 unpackCurveData (sampler2D tex, vec2 coord) {\nvec4 a = texture2D(tex, coord);\nvec4 b = texture2D(tex, coord + u_sampleInfo.y);\nfloat c = fract(coord.x * u_sampleInfo.x);\nreturn mix(a.xyz, b.xyz, c);\n}\nvec3 unpackCurveData (sampler2D tex, vec2 coord, out float w) {\nvec4 a = texture2D(tex, coord);\nvec4 b = texture2D(tex, coord + u_sampleInfo.y);\nfloat c = fract(coord.x * u_sampleInfo.x);\nw = mix(a.w, b.w, c);\nreturn mix(a.xyz, b.xyz, c);\n}\nfloat pseudoRandom(float x) {\nfloat o = x;\nx = mod(x - 1.0, 2.0) - 1.0;\nfloat freqVar = 10.16640753482;\nfloat y = sin(freqVar * floor(o * 0.5 - 0.5));\nfloat v = max(0.0, 1.0-abs(x));\nv *= 0.7071067812;\nv = y < 0.0 ? -v : v;\nreturn v;\n}\n#if COLOR_OVER_TIME_MODULE_ENABLE\nuniform sampler2D color_over_time_tex0;\nuniform int u_color_mode;\n#endif\n#if ROTATION_OVER_TIME_MODULE_ENABLE\nuniform sampler2D rotation_over_time_tex0;\nuniform int u_rotation_mode;\n#endif\n#if SIZE_OVER_TIME_MODULE_ENABLE\nuniform sampler2D size_over_time_tex0;\nuniform int u_size_mode;\n#endif\n#if FORCE_OVER_TIME_MODULE_ENABLE\nuniform sampler2D force_over_time_tex0;\nuniform int u_force_mode;\nuniform int u_force_space;\n#endif\n#if VELOCITY_OVER_TIME_MODULE_ENABLE\nuniform sampler2D velocity_over_time_tex0;\nuniform int u_velocity_mode;\nuniform int u_velocity_space;\n#endif\n#if TEXTURE_ANIMATION_MODULE_ENABLE\nuniform sampler2D texture_animation_tex0;\nuniform vec4 u_anim_info;\n#endif\nfloat repeat (float t, float length) {\nreturn t - floor(t / length) * length;\n}\nvec4 rotateQuat (vec4 p, vec4 q) {\nvec3 iv = cross(q.xyz, p.xyz) + q.w * p.xyz;\nvec3 res = p.xyz + 2.0 * cross(q.xyz, iv);\nreturn vec4(res.xyz, p.w);\n}\nvec4 gpvs_main () {\nfloat activeTime = u_timeDelta.x - a_position_starttime.w;\nfloat normalizedTime = clamp(activeTime / a_dir_life.w, 0.0, 1.0);\nvec2 timeCoord0 = vec2(normalizedTime, 0.);\nvec2 timeCoord1 = vec2(normalizedTime, 1.);\n#if CC_RENDER_MODE == 4\nvec2 vertIdx = vec2(a_texCoord.x, a_texCoord.y);\n#else\nvec2 vertIdx = vec2(a_size_uv.w, a_rotation_uv.w);\n#endif\nvec4 velocity = vec4(a_dir_life.xyz, 0.);\nvec4 pos = vec4(a_position_starttime.xyz, 1.);\nvec3 size = a_size_uv.xyz;\n#if SIZE_OVER_TIME_MODULE_ENABLE\nif (u_size_mode == 1) {\nsize *= unpackCurveData(size_over_time_tex0, timeCoord0);\n} else {\nvec3 size_0 = unpackCurveData(size_over_time_tex0, timeCoord0);\nvec3 size_1 = unpackCurveData(size_over_time_tex0, timeCoord1);\nfloat factor_s = pseudoRandom(a_rndSeed + 39825.);\nsize *= mix(size_0, size_1, factor_s);\n}\n#endif\nvec3 compScale = scale.xyz * size;\n#if FORCE_OVER_TIME_MODULE_ENABLE\nvec3 forceAnim = vec3(0.);\nif (u_force_mode == 1) {\nforceAnim = unpackCurveData(force_over_time_tex0, timeCoord0);\n} else {\nvec3 force_0 = unpackCurveData(force_over_time_tex0, timeCoord0);\nvec3 force_1 = unpackCurveData(force_over_time_tex0, timeCoord1);\nfloat factor_f = pseudoRandom(a_rndSeed + 212165.);\nforceAnim = mix(force_0, force_1, factor_f);\n}\nvec4 forceTrack = vec4(forceAnim, 0.);\nif (u_force_space == 0) {\nforceTrack = rotateQuat(forceTrack, u_worldRot);\n}\nvelocity.xyz += forceTrack.xyz;\n#endif\n#if VELOCITY_OVER_TIME_MODULE_ENABLE\nfloat speedModifier0 = 1.;\nfloat speedModifier1 = 1.;\nvec3 velocityAnim = vec3(0.);\nif (u_velocity_mode == 1) {\nvelocityAnim = unpackCurveData(velocity_over_time_tex0, timeCoord0, speedModifier0);\n} else {\nvec3 vectory_0 = unpackCurveData(velocity_over_time_tex0, timeCoord0, speedModifier0);\nvec3 vectory_1 = unpackCurveData(velocity_over_time_tex0, timeCoord1, speedModifier1);\nfloat factor_v = pseudoRandom(a_rndSeed + 197866.);\nvelocityAnim = mix(vectory_0, vectory_1, factor_v);\nspeedModifier0 = mix(speedModifier0, speedModifier1, factor_v);\n}\nvec4 velocityTrack = vec4(velocityAnim, 0.);\nif (u_velocity_space == 0) {\nvelocityTrack = rotateQuat(velocityTrack, u_worldRot);\n}\nvelocity.xyz += velocityTrack.xyz;\nvelocity.xyz *= speedModifier0;\n#endif\npos.xyz += velocity.xyz * normalizedTime * a_dir_life.w;\n#if !CC_USE_WORLD_SPACE\npos = cc_matWorld * pos;\n#if CC_RENDER_MODE == 1\nvelocity = rotateQuat(velocity, u_worldRot);\n#endif\n#endif\nvec3 startRotation = a_rotation_uv.xyz;\n#if CC_RENDER_MODE != 4\n#if CC_RENDER_MODE == 0\nvec3 rotEuler = startRotation.xyz;\n#elif CC_RENDER_MODE == 1\nvec3 rotEuler = vec3(0.);\n#else\nvec3 rotEuler = vec3(0., 0., startRotation.z);\n#endif\nvec4 rot = quaternionFromEuler(rotEuler);\n#else\nvec4 rot = quaternionFromEuler(startRotation);\n#endif\n#if ROTATION_OVER_TIME_MODULE_ENABLE\nif (u_rotation_mode == 1) {\nvec3 euler = unpackCurveData(rotation_over_time_tex0, timeCoord0) * normalizedTime * a_dir_life.w;\nvec4 quat = eulerToQuat(euler);\nmat3 mLocal = quatToMat3(quat);\nmat3 mStart = quatToMat3(rot);\nrot = mat3ToQuat(mStart * mLocal);\n} else {\nvec3 rotation_0 = unpackCurveData(rotation_over_time_tex0, timeCoord0);\nvec3 rotation_1 = unpackCurveData(rotation_over_time_tex0, timeCoord1);\nfloat factor_r = pseudoRandom(a_rndSeed + 125292.);\nvec3 euler = mix(rotation_0, rotation_1, factor_r) * normalizedTime * a_dir_life.w;\n#if CC_RENDER_MODE == 3 || CC_RENDER_MODE == 2\neuler = vec3(0.0, 0.0, euler.z);\n#endif\nvec4 quat = eulerToQuat(euler);\nmat3 mLocal = quatToMat3(quat);\nmat3 mStart = quatToMat3(rot);\nrot = mat3ToQuat(mStart * mLocal);\n}\n#endif\n#if COLOR_OVER_TIME_MODULE_ENABLE\nif (u_color_mode == 1) {\ncolor = a_color * texture2D(color_over_time_tex0, timeCoord0);\n} else {\nvec4 color_0 = texture2D(color_over_time_tex0, timeCoord0);\nvec4 color_1 = texture2D(color_over_time_tex0, timeCoord1);\nfloat factor_c = pseudoRandom(a_rndSeed + 91041.);\ncolor = a_color * mix(color_0, color_1, factor_c);\n}\n#else\ncolor = a_color;\n#endif\n#if CC_RENDER_MODE != 4\nvec2 cornerOffset = vec2((vertIdx - 0.5));\n#if CC_RENDER_MODE == 1\nrot = vec4(0.0, 0.0, 0.0, 1.0);\n#endif\ncomputeVertPos(pos, cornerOffset, rot, compScale\n#if CC_RENDER_MODE == 0 || CC_RENDER_MODE == 3\n, cc_matViewInv\n#endif\n#if CC_RENDER_MODE == 1\n, cc_cameraPos.xyz\n, velocity\n, frameTile_velLenScale.z\n, frameTile_velLenScale.w\n, a_size_uv.w\n#endif\n);\n#else\nmat3 rotMat = quatToMat3(rot);\nmat3 nodeMat = quatToMat3(nodeRotation);\nrotMat = nodeMat * rotMat;\nrot = mat3ToQuat(rotMat);\nmat4 xformNoScale = matrixFromRT(rot, pos.xyz);\nmat4 xform = matFromRTS(rot, pos.xyz, compScale);\npos = xform * vec4(a_texCoord3, 1);\nvec4 normal = xformNoScale * vec4(a_normal, 0);\ncolor *= a_color1;\n#endif\npos = cc_matViewProj * pos;\nfloat frameIndex = 0.;\n#if TEXTURE_ANIMATION_MODULE_ENABLE\nfloat startFrame = 0.;\nvec3 frameInfo = vec3(0.);\nif (int(u_anim_info.x) == 1) {\nframeInfo = unpackCurveData(texture_animation_tex0, timeCoord0);\n} else {\nvec3 frameInfo0 = unpackCurveData(texture_animation_tex0, timeCoord0);\nvec3 frameInfo1 = unpackCurveData(texture_animation_tex0, timeCoord1);\nfloat factor_t = pseudoRandom(a_rndSeed + 90794.);\nframeInfo = mix(frameInfo0, frameInfo1, factor_t);\n}\nstartFrame = frameInfo.x / u_anim_info.y;\nframeIndex = repeat(u_anim_info.z * (frameInfo.y + startFrame), 1.);\n#endif\nuv = computeUV(frameIndex, vertIdx, frameTile_velLenScale.xy) * mainTiling_Offset.xy + mainTiling_Offset.zw;\nreturn pos;\n}\nvoid main() { gl_Position = gpvs_main(); }", + "frag": "\nprecision mediump float;\nvec4 CCFragOutput (vec4 color) {\nreturn color;\n}\nvarying vec2 uv;\nvarying vec4 color;\nuniform sampler2D mainTexture;\nuniform vec4 tintColor;\nvec4 add () {\nvec4 col = 2.0 * color * tintColor * texture2D(mainTexture, uv);\nreturn CCFragOutput(col);\n}\nvoid main() { gl_FragColor = add(); }", + } + ], + [ + { + "vert": "\nprecision mediump float;\nuniform vec4 mainTiling_Offset;\nuniform highp mat4 cc_matViewProj;\nuniform highp vec4 cc_cameraPos;\nuniform highp mat4 cc_matWorld;\nvarying mediump vec2 uv;\nvarying mediump vec4 color;\nattribute vec3 a_position;\nattribute vec4 a_texCoord;\nattribute vec3 a_texCoord1;\nattribute vec3 a_texCoord2;\nattribute vec4 a_color;\n#if CC_DRAW_WIRE_FRAME\nvarying vec3 vBarycentric;\n#endif\nvec4 vs_main() {\nhighp vec4 pos = vec4(a_position, 1);\nvec4 velocity = vec4(a_texCoord1.xyz, 0);\n#if !CC_USE_WORLD_SPACE\npos = cc_matWorld * pos;\nvelocity = cc_matWorld * velocity;\n#endif\nfloat vertOffset = (a_texCoord.x - 0.5) * a_texCoord.y;\nvec3 camUp = normalize(cross(pos.xyz - cc_cameraPos.xyz, velocity.xyz));\npos.xyz += camUp * vertOffset;\npos = cc_matViewProj * pos;\nuv = a_texCoord.zw * mainTiling_Offset.xy + mainTiling_Offset.zw;;\ncolor = a_color;\n#if CC_DRAW_WIRE_FRAME\nvBarycentric = a_texCoord2;\n#endif\nreturn pos;\n}\nvoid main() { gl_Position = vs_main(); }", + "frag": "\nprecision mediump float;\nvec4 CCFragOutput (vec4 color) {\nreturn color;\n}\nvarying vec2 uv;\nvarying vec4 color;\n#if CC_DRAW_WIRE_FRAME\nvarying vec3 vBarycentric;\n#endif\nuniform sampler2D mainTexture;\nuniform vec4 tintColor;\nvec4 add () {\nvec4 col = 2.0 * color * tintColor * texture2D(mainTexture, uv);\n#if CC_DRAW_WIRE_FRAME\nif (any(lessThan(vBarycentric, vec3(0.02)))) {\ncol = vec4(0., 1., 1., 1.);\n}\n#endif\nreturn CCFragOutput(col);\n}\nvoid main() { gl_FragColor = add(); }", + } + ], + [ + { + "vert": "\nprecision highp float;\nvec4 quaternionFromAxis (vec3 xAxis,vec3 yAxis,vec3 zAxis){\nmat3 m = mat3(xAxis,yAxis,zAxis);\nfloat trace = m[0][0] + m[1][1] + m[2][2];\nvec4 quat;\nif (trace > 0.) {\nfloat s = 0.5 / sqrt(trace + 1.0);\nquat.w = 0.25 / s;\nquat.x = (m[2][1] - m[1][2]) * s;\nquat.y = (m[0][2] - m[2][0]) * s;\nquat.z = (m[1][0] - m[0][1]) * s;\n} else if ((m[0][0] > m[1][1]) && (m[0][0] > m[2][2])) {\nfloat s = 2.0 * sqrt(1.0 + m[0][0] - m[1][1] - m[2][2]);\nquat.w = (m[2][1] - m[1][2]) / s;\nquat.x = 0.25 * s;\nquat.y = (m[0][1] + m[1][0]) / s;\nquat.z = (m[0][2] + m[2][0]) / s;\n} else if (m[1][1] > m[2][2]) {\nfloat s = 2.0 * sqrt(1.0 + m[1][1] - m[0][0] - m[2][2]);\nquat.w = (m[0][2] - m[2][0]) / s;\nquat.x = (m[0][1] + m[1][0]) / s;\nquat.y = 0.25 * s;\nquat.z = (m[1][2] + m[2][1]) / s;\n} else {\nfloat s = 2.0 * sqrt(1.0 + m[2][2] - m[0][0] - m[1][1]);\nquat.w = (m[1][0] - m[0][1]) / s;\nquat.x = (m[0][2] + m[2][0]) / s;\nquat.y = (m[1][2] + m[2][1]) / s;\nquat.z = 0.25 * s;\n}\nfloat len = quat.x * quat.x + quat.y * quat.y + quat.z * quat.z + quat.w * quat.w;\nif (len > 0.) {\nlen = 1. / sqrt(len);\nquat.x = quat.x * len;\nquat.y = quat.y * len;\nquat.z = quat.z * len;\nquat.w = quat.w * len;\n}\nreturn quat;\n}\nvec4 quaternionFromEuler (vec3 angle){\nfloat x = angle.x / 2.;\nfloat y = angle.y / 2.;\nfloat z = angle.z / 2.;\nfloat sx = sin(x);\nfloat cx = cos(x);\nfloat sy = sin(y);\nfloat cy = cos(y);\nfloat sz = sin(z);\nfloat cz = cos(z);\nvec4 quat = vec4(0);\nquat.x = sx * cy * cz + cx * sy * sz;\nquat.y = cx * sy * cz + sx * cy * sz;\nquat.z = cx * cy * sz - sx * sy * cz;\nquat.w = cx * cy * cz - sx * sy * sz;\nreturn quat;\n}\nmat4 matrixFromRT (vec4 q, vec3 p){\nfloat x2 = q.x + q.x;\nfloat y2 = q.y + q.y;\nfloat z2 = q.z + q.z;\nfloat xx = q.x * x2;\nfloat xy = q.x * y2;\nfloat xz = q.x * z2;\nfloat yy = q.y * y2;\nfloat yz = q.y * z2;\nfloat zz = q.z * z2;\nfloat wx = q.w * x2;\nfloat wy = q.w * y2;\nfloat wz = q.w * z2;\nreturn mat4(\n1. - (yy + zz), xy + wz, xz - wy, 0,\nxy - wz, 1. - (xx + zz), yz + wx, 0,\nxz + wy, yz - wx, 1. - (xx + yy), 0,\np.x, p.y, p.z, 1\n);\n}\nmat4 matFromRTS (vec4 q, vec3 t, vec3 s){\nfloat x = q.x, y = q.y, z = q.z, w = q.w;\nfloat x2 = x + x;\nfloat y2 = y + y;\nfloat z2 = z + z;\nfloat xx = x * x2;\nfloat xy = x * y2;\nfloat xz = x * z2;\nfloat yy = y * y2;\nfloat yz = y * z2;\nfloat zz = z * z2;\nfloat wx = w * x2;\nfloat wy = w * y2;\nfloat wz = w * z2;\nfloat sx = s.x;\nfloat sy = s.y;\nfloat sz = s.z;\nreturn mat4((1. - (yy + zz)) * sx, (xy + wz) * sx, (xz - wy) * sx, 0,\n(xy - wz) * sy, (1. - (xx + zz)) * sy, (yz + wx) * sy, 0,\n(xz + wy) * sz, (yz - wx) * sz, (1. - (xx + yy)) * sz, 0,\nt.x, t.y, t.z, 1);\n}\nvec4 quatMultiply (vec4 a, vec4 b){\nvec4 quat;\nquat.x = a.x * b.w + a.w * b.x + a.y * b.z - a.z * b.y;\nquat.y = a.y * b.w + a.w * b.y + a.z * b.x - a.x * b.z;\nquat.z = a.z * b.w + a.w * b.z + a.x * b.y - a.y * b.x;\nquat.w = a.w * b.w - a.x * b.x - a.y * b.y - a.z * b.z;\nreturn quat;\n}\nvoid rotateVecFromQuat (inout vec3 v, vec4 q){\nfloat ix = q.w * v.x + q.y * v.z - q.z * v.y;\nfloat iy = q.w * v.y + q.z * v.x - q.x * v.z;\nfloat iz = q.w * v.z + q.x * v.y - q.y * v.x;\nfloat iw = -q.x * v.x - q.y * v.y - q.z * v.z;\nv.x = ix * q.w + iw * -q.x + iy * -q.z - iz * -q.y;\nv.y = iy * q.w + iw * -q.y + iz * -q.x - ix * -q.z;\nv.z = iz * q.w + iw * -q.z + ix * -q.y - iy * -q.x;\n}\nvec3 rotateInLocalSpace (vec3 pos, vec3 xAxis, vec3 yAxis, vec3 zAxis, vec4 q){\nvec4 viewQuat = quaternionFromAxis(xAxis, yAxis, zAxis);\nvec4 rotQuat = quatMultiply(viewQuat, q);\nrotateVecFromQuat(pos, rotQuat);\nreturn pos;\n}\nmat3 quatToMat3(vec4 q) {\nvec3 m0 = vec3(\n1.0 - 2.0 * q.y * q.y - 2.0 * q.z * q.z,\n2.0 * q.x * q.y + 2.0 * q.w * q.z,\n2.0 * q.x * q.z - 2.0 * q.w * q.y);\nvec3 m1 = vec3(\n2.0 * q.x * q.y - 2.0 * q.w * q.z,\n1.0 - 2.0 * q.x * q.x - 2.0 * q.z * q.z,\n2.0 * q.y * q.z + 2.0 * q.w * q.x);\nvec3 m2 = vec3(\n2.0 * q.x * q.z + 2.0 * q.w * q.y,\n2.0 * q.y * q.z - 2.0 * q.w * q.x,\n1.0 - 2.0 * q.x * q.x - 2.0 * q.y * q.y);\nreturn mat3(m0, m1, m2);\n}\nvec4 mat3ToQuat(mat3 mat) {\nfloat tr = mat[0][0] + mat[1][1] + mat[2][2];\nfloat qw, qx, qy, qz;\nif (tr > 0.0) {\nfloat S = sqrt(tr + 1.0) * 2.0;\nfloat invS = 1.0 / S;\nqw = 0.25 * S;\nqx = (mat[1][2] - mat[2][1]) * invS;\nqy = (mat[2][0] - mat[0][2]) * invS;\nqz = (mat[0][1] - mat[1][0]) * invS;\n} else if ((mat[0][0] > mat[1][1])&&(mat[0][0] > mat[2][2])) {\nfloat S = sqrt(1.0 + mat[0][0] - mat[1][1] - mat[2][2]) * 2.0;\nfloat invS = 1.0 / S;\nqw = (mat[1][2] - mat[2][1]) * invS;\nqx = 0.25 * S;\nqy = (mat[1][0] + mat[0][1]) * invS;\nqz = (mat[2][0] + mat[0][2]) * invS;\n} else if (mat[1][1] > mat[2][2]) {\nfloat S = sqrt(1.0 + mat[1][1] - mat[0][0] - mat[2][2]) * 2.0;\nfloat invS = 1.0 / S;\nqw = (mat[2][0] - mat[0][2]) * invS;\nqx = (mat[1][0] + mat[0][1]) * invS;\nqy = 0.25 * S;\nqz = (mat[2][1] + mat[1][2]) * invS;\n} else {\nfloat S = sqrt(1.0 + mat[2][2] - mat[0][0] - mat[1][1]) * 2.0;\nfloat invS = 1.0 / S;\nqw = (mat[0][1] - mat[1][0]) * invS;\nqx = (mat[2][0] + mat[0][2]) * invS;\nqy = (mat[2][1] + mat[1][2]) * invS;\nqz = 0.25 * S;\n}\nreturn vec4(qx, qy, qz, qw);\n}\nuniform vec4 mainTiling_Offset;\nuniform vec4 frameTile_velLenScale;\nuniform vec4 scale;\nuniform vec4 nodeRotation;\nuniform highp mat4 cc_matView;\nuniform highp mat4 cc_matViewInv;\nuniform highp mat4 cc_matViewProj;\nuniform highp vec4 cc_cameraPos;\nuniform highp mat4 cc_matWorld;\nvarying mediump vec2 uv;\nvarying mediump vec4 color;\nvoid computeVertPos (inout vec4 pos, vec2 vertOffset, vec4 q, vec3 s\n#if CC_RENDER_MODE == 0 || CC_RENDER_MODE == 3\n, mat4 viewInv\n#endif\n#if CC_RENDER_MODE == 1\n, vec3 eye\n, vec4 velocity\n, float velocityScale\n, float lengthScale\n, float xIndex\n#endif\n) {\n#if CC_RENDER_MODE == 0\nvec3 viewSpaceVert = vec3(vertOffset.x * s.x, vertOffset.y * s.y, 0.);\nvec3 camX = normalize(vec3(viewInv[0][0], viewInv[1][0], viewInv[2][0]));\nvec3 camY = normalize(vec3(viewInv[0][1], viewInv[1][1], viewInv[2][1]));\nvec3 camZ = normalize(vec3(viewInv[0][2], viewInv[1][2], viewInv[2][2]));\npos.xyz += rotateInLocalSpace(viewSpaceVert, camX, camY, camZ, q);\n#elif CC_RENDER_MODE == 1\nvec3 camRight = normalize(cross(pos.xyz - eye, velocity.xyz)) * s.x;\nvec3 camUp = velocity.xyz * velocityScale + normalize(velocity.xyz) * lengthScale * s.y;\npos.xyz += (camRight * abs(vertOffset.x) * sign(vertOffset.y)) - camUp * xIndex;\n#elif CC_RENDER_MODE == 2\nvec3 viewSpaceVert = vec3(vertOffset.x * s.x, vertOffset.y * s.y, 0.);\nvec3 camX = vec3(1, 0, 0);\nvec3 camY = vec3(0, 0, -1);\npos.xyz += rotateInLocalSpace(viewSpaceVert, camX, camY, cross(camX, camY), q);\n#elif CC_RENDER_MODE == 3\nvec3 viewSpaceVert = vec3(vertOffset.x * s.x, vertOffset.y * s.y, 0.);\nrotateVecFromQuat(viewSpaceVert, q);\nvec3 camX = normalize(vec3(cc_matView[0][0], cc_matView[1][0], cc_matView[2][0]));\nvec3 camY = vec3(0, 1, 0);\nvec3 offset = camX * viewSpaceVert.x + camY * viewSpaceVert.y;\npos.xyz += offset;\n#else\npos.x += vertOffset.x;\npos.y += vertOffset.y;\n#endif\n}\nvec2 computeUV (float frameIndex, vec2 vertIndex, vec2 frameTile){\nvec2 aniUV = vec2(0, floor(frameIndex * frameTile.y));\naniUV.x = floor(frameIndex * frameTile.x * frameTile.y - aniUV.y * frameTile.x);\n#if CC_RENDER_MODE != 4\nvertIndex.y = 1. - vertIndex.y;\n#endif\nreturn (aniUV.xy + vertIndex) / vec2(frameTile.x, frameTile.y);\n}\nattribute vec3 a_position;\nattribute vec3 a_texCoord;\nattribute vec3 a_texCoord1;\nattribute vec3 a_texCoord2;\nattribute vec4 a_color;\n#if CC_RENDER_MODE == 1\nattribute vec3 a_color1;\n#endif\n#if CC_RENDER_MODE == 4\nattribute vec3 a_texCoord3;\nattribute vec3 a_normal;\nattribute vec4 a_color1;\n#endif\nvec4 lpvs_main () {\nvec3 compScale = scale.xyz * a_texCoord1;\nvec4 pos = vec4(a_position, 1);\n#if CC_RENDER_MODE == 1\nvec4 velocity = vec4(a_color1.xyz, 0);\n#endif\n#if !CC_USE_WORLD_SPACE\npos = cc_matWorld * pos;\n#if CC_RENDER_MODE == 1\nvelocity = cc_matWorld * velocity;\n#endif\n#endif\n#if ROTATION_OVER_TIME_MODULE_ENABLE\nvec3 rotTmp = a_texCoord2;\nfloat mulFactor = 1.0;\nif (rotTmp.x > 10.0 * 0.5) {\nrotTmp.x -= 10.0;\nmulFactor = -1.0;\n}\nvec4 rot = vec4(rotTmp, 0.0);\nrot.w = mulFactor * sqrt(1.0 - rot.x * rot.x - rot.y * rot.y - rot.z * rot.z);\n#else\n#if CC_RENDER_MODE != 4\n#if CC_RENDER_MODE == 0\nvec3 rotEuler = a_texCoord2;\n#elif CC_RENDER_MODE == 1\nvec3 rotEuler = vec3(0.);\n#else\nvec3 rotEuler = vec3(0., 0., a_texCoord2.z);\n#endif\nvec4 rot = quaternionFromEuler(rotEuler);\n#else\nvec4 rot = quaternionFromEuler(a_texCoord2);\n#endif\n#endif\n#if CC_RENDER_MODE != 4\nvec2 cornerOffset = vec2((a_texCoord.xy - 0.5));\n#if CC_RENDER_MODE == 0 || CC_RENDER_MODE == 3\ncomputeVertPos(pos, cornerOffset, rot, compScale, cc_matViewInv);\n#elif CC_RENDER_MODE == 1\ncomputeVertPos(pos, cornerOffset, rot, compScale, cc_cameraPos.xyz, velocity, frameTile_velLenScale.z, frameTile_velLenScale.w, a_texCoord.x);\n#elif 2\ncomputeVertPos(pos, cornerOffset, rot, compScale);\n#endif\ncolor = a_color;\n#else\nmat3 rotMat = quatToMat3(rot);\nmat3 nodeMat = quatToMat3(nodeRotation);\nrotMat = nodeMat * rotMat;\nrot = mat3ToQuat(rotMat);\nmat4 xformNoScale = matrixFromRT(rot, pos.xyz);\nmat4 xform = matFromRTS(rot, pos.xyz, compScale);\npos = xform * vec4(a_texCoord3, 1);\nvec4 normal = xformNoScale * vec4(a_normal, 0);\ncolor = a_color * a_color1;\n#endif\nuv = computeUV(a_texCoord.z, a_texCoord.xy, frameTile_velLenScale.xy) * mainTiling_Offset.xy + mainTiling_Offset.zw;\npos = cc_matViewProj * pos;\nreturn pos;\n}\nvoid main() { gl_Position = lpvs_main(); }", + "frag": "\nprecision mediump float;\nvec4 CCFragOutput (vec4 color) {\nreturn color;\n}\nvarying vec2 uv;\nvarying vec4 color;\nuniform sampler2D mainTexture;\nuniform vec4 tintColor;\nvec4 add () {\nvec4 col = 2.0 * color * tintColor * texture2D(mainTexture, uv);\nreturn CCFragOutput(col);\n}\nvoid main() { gl_FragColor = add(); }", + } + ], + [ + { + "vert": "\nprecision highp float;\nuniform highp mat4 cc_matViewProj;\n#if USE_LOCAL\nuniform highp mat4 cc_matWorld;\n#endif\nattribute vec3 a_position;\nattribute vec2 a_texCoord;\nattribute vec4 a_color;\nvarying vec4 v_light;\nvarying vec2 uv0;\n#if TWO_COLORED\nattribute vec4 a_color2;\nvarying vec4 v_dark;\n#endif\nvec4 vert () {\nvec4 pos = vec4(a_position, 1);\n#if USE_LOCAL\npos = cc_matWorld * pos;\n#endif\npos = cc_matViewProj * pos;\nuv0 = a_texCoord;\nv_light = a_color;\n#if TWO_COLORED\nv_dark = a_color2;\n#endif\nreturn pos;\n}\nvoid main() { gl_Position = vert(); }", + "frag": "\nprecision highp float;\n#if USE_ALPHA_TEST\nuniform float alphaThreshold;\n#endif\nvoid ALPHA_TEST (in vec4 color) {\n#if USE_ALPHA_TEST\nif (color.a < alphaThreshold) discard;\n#endif\n}\nvoid ALPHA_TEST (in float alpha) {\n#if USE_ALPHA_TEST\nif (alpha < alphaThreshold) discard;\n#endif\n}\nvarying vec4 v_light;\n#if TWO_COLORED\nvarying vec4 v_dark;\n#endif\nvarying vec2 uv0;\nuniform sampler2D cc_spriteTexture;\nvec4 frag () {\nvec4 o = vec4(1, 1, 1, 1);\n#if TWO_COLORED\nvec4 texColor = vec4(1, 1, 1, 1);\ntexColor *= texture2D(cc_spriteTexture, uv0);\no.a = texColor.a * v_light.a;\no.rgb = ((texColor.a - 1.0) * v_dark.a + 1.0 - texColor.rgb) * v_dark.rgb + texColor.rgb * v_light.rgb;\n#else\no *= texture2D(cc_spriteTexture, uv0);\no *= v_light;\n#endif\nALPHA_TEST(o);\nreturn o;\n}\nvoid main() { gl_FragColor = frag(); }", + } + ], + [ + { + "vert": "\nprecision highp float;\nstruct SpriteVertexData {\nvec4 position;\nvec4 color;\n};\nstruct SpriteFragmentData {\nvec2 uv;\n};\nuniform highp mat4 cc_matView;\nuniform highp mat4 cc_matProj;\nuniform highp mat4 cc_matViewProj;\nuniform highp vec4 cc_cameraPos;\nattribute vec3 a_position;\nattribute vec2 a_texCoord;\nattribute float a_batch_id;\nvarying vec2 v_uv0;\nvarying float v_uvMode;\nvarying vec4 v_uvSizeOffset;\nvarying vec4 v_uvParams0;\nvarying vec4 v_uvParams1;\nstruct SpriteVertexInternalData {\nvec4 rotation;\nvec3 translation;\nvec3 scale;\nvec4 uvSizeOffset;\nfloat uvMode;\nvec4 uvParams;\nfloat filltype;\n};\nuniform vec4 cc_local_data[(CC_DEVICE_MAX_VERTEX_UNIFORM_VECTORS - CC_EFFECT_USED_VERTEX_UNIFORM_VECTORS) / 5 * 5];\nvec3 VectorTransformQuat (vec3 v, vec4 q) {\nreturn v + 2.0 * cross(q.xyz, cross(q.xyz, v) + q.w * v);\n}\nvoid CCSpriteInput(out SpriteVertexData i0) {\nvec4 data0 = cc_local_data[int(a_batch_id) * 5];\nvec4 data1 = cc_local_data[int(a_batch_id) * 5 + 1];\nvec4 data2 = cc_local_data[int(a_batch_id) * 5 + 2];\nvec4 data3 = cc_local_data[int(a_batch_id) * 5 + 3];\nvec4 data4 = cc_local_data[int(a_batch_id) * 5 + 4];\nfloat rg = data0.w;\nfloat r = floor(rg);\nfloat ba = data2.z;\nfloat b = floor(ba);\nSpriteVertexInternalData i1;\ni1.rotation = data1;\ni1.translation = data0.xyz;\ni1.scale = vec3(data2.xy, 1.0);\ni1.uvSizeOffset = data3;\ni1.filltype = fract(data2.w) * 10.0;\ni1.uvMode = data2.w;\ni1.uvParams = data4;\ni0.position = vec4(VectorTransformQuat(a_position * i1.scale, i1.rotation) + i1.translation, 1.0);\ni0.color = vec4(r * (1.0 / 255.0), rg - r, b * (1.0 / 255.0), ba - b);\nvec2 uvWithRotation;\nif (i1.uvSizeOffset.x < 0.0) {\ni1.uvSizeOffset.x = abs(i1.uvSizeOffset.x);\nuvWithRotation = vec2(1.0 - a_texCoord.y, a_texCoord.x);\n} else {\nuvWithRotation = a_texCoord;\n}\nif (i1.uvMode >= 3.0) {\nv_uv0 = uvWithRotation;\nv_uvSizeOffset = i1.uvSizeOffset;\nv_uvParams0 = vec4(i1.uvParams.xy, i1.filltype, 0);\nif (i1.filltype >= 2.0) {\nv_uvParams1 = i1.uvParams;\n} else if (i1.filltype >= 1.0) {\nv_uvParams0 = vec4(1.0 - v_uvParams0.y, 1.0 - v_uvParams0.x, v_uvParams0.zw);\n}\n} else if (i1.uvMode >= 2.0) {\nv_uv0 = uvWithRotation * i1.uvParams.xy;\nv_uv0.y -= fract(i1.uvParams.y);\nv_uvSizeOffset = i1.uvSizeOffset;\n} else if (i1.uvMode >= 1.0) {\nv_uv0 = uvWithRotation;\nv_uvSizeOffset = i1.uvSizeOffset;\nvec4 params0 = fract(i1.uvParams);\nvec4 params1 = floor(i1.uvParams) / 2048.0;\nv_uvParams0 = vec4(params0.xy, params1.xy);\nv_uvParams1 = vec4(params0.zw, params1.zw);\n} else {\nv_uv0 = uvWithRotation * i1.uvSizeOffset.xy + i1.uvSizeOffset.zw;\n}\nv_uvMode = i1.uvMode;\n#if SAMPLE_FROM_RT\nv_uv0 = cc_cameraPos.w > 1.0 ? vec2(v_uv0.x, 1.0 - v_uv0.y) : v_uv0;\n#endif\n}\nvarying vec4 v_color;\nvec4 vert () {\nSpriteVertexData i;\nCCSpriteInput(i);\nv_color = i.color;\nvec4 pos = i.position;\n#if USE_PIXEL_ALIGNMENT\npos = cc_matView * pos;\npos.xyz = floor(pos.xyz);\npos = cc_matProj * pos;\n#else\npos = cc_matViewProj * pos;\n#endif\nreturn pos;\n}\nvoid main() { gl_Position = vert(); }", + "frag": "\nprecision highp float;\nstruct SpriteVertexData {\nvec4 position;\nvec4 color;\n};\nstruct SpriteFragmentData {\nvec2 uv;\n};\nvec4 CCSampleWithAlphaSeparated(sampler2D tex, vec2 uv) {\n#if CC_USE_EMBEDDED_ALPHA\nreturn vec4(texture2D(tex, uv).rgb, texture2D(tex, uv + vec2(0.0, 0.5)).r);\n#else\nreturn texture2D(tex, uv);\n#endif\n}\nvarying vec2 v_uv0;\nvarying float v_uvMode;\nvarying vec4 v_uvSizeOffset;\nvarying vec4 v_uvParams0;\nvarying vec4 v_uvParams1;\nvec2 evalSlicedUV(vec2 uv) {\nvec4 p0 = mix(vec4(0.0), v_uvParams0, step(v_uvParams0.xyxy, uv.xyxy));\np0 = mix( p0, v_uvParams1, step(v_uvParams1.xyxy, uv.xyxy));\nvec4 p1 = mix(vec4(1.0), v_uvParams1, step(uv.xyxy, v_uvParams1.xyxy));\np1 = mix( p1, v_uvParams0, step(uv.xyxy, v_uvParams0.xyxy));\nvec2 k = (p1.zw - p0.zw) / (p1.xy - p0.xy);\nvec2 b = (p1.xy * p0.zw - p0.xy * p1.zw) / (p1.xy - p0.xy);\nreturn k * uv + b;\n}\nfloat evalFilledUV(vec2 uv, float mode) {\nfloat alpha = 1.0;\nif (mode >= 2.0) {\nfloat start = v_uvParams1.x;\nfloat range = v_uvParams1.y;\nvec2 dir = uv - v_uvParams1.zw;\nfloat angle = -atan(dir.y, dir.x) * 0.3183098861838;\nif (range < 0.0) {\nangle += mix(0.0, -2.0, step(start, angle));\nalpha = step(start + range, angle);\n} else {\nangle += mix(0.0, 2.0, step(angle, start));\nalpha = step(angle, start + range);\n}\n} else if (mode >= 1.0) {\nif (uv.y >= v_uvParams0.x && uv.y <= v_uvParams0.y) {\nalpha = 1.0;\n} else {\nalpha = 0.0;\n}\n} else {\nif (uv.x >= v_uvParams0.x && uv.x <= v_uvParams0.y) {\nalpha = 1.0;\n} else {\nalpha = 0.0;\n}\n}\nreturn alpha;\n}\nvoid CCSpriteInput(out SpriteFragmentData i) {\n#if USE_TEXTURE\nif(v_uvMode >= 3.0) {\ni.uv = v_uv0 * v_uvSizeOffset.xy + v_uvSizeOffset.zw;\n} else if (v_uvMode >= 2.0) {\ni.uv = fract(v_uv0) * v_uvSizeOffset.xy + v_uvSizeOffset.zw;\n} else if (v_uvMode >= 1.0) {\ni.uv = evalSlicedUV(v_uv0) * v_uvSizeOffset.xy + v_uvSizeOffset.zw;\n} else {\ni.uv = v_uv0;\n}\n#endif\n}\nvec4 CCSpriteSample(sampler2D tex, vec2 uv) {\nvec4 o = CCSampleWithAlphaSeparated(tex, uv);\nif (v_uvMode >= 3.0) {\no.a *= evalFilledUV(v_uv0, v_uvParams0.z);\n}\nreturn o;\n}\nvec3 SRGBToLinear (vec3 gamma) {\nreturn gamma * gamma;\n}\nvarying vec4 v_color;\n#if USE_TEXTURE\nuniform sampler2D cc_spriteTexture;\n#endif\nvec4 frag () {\nSpriteFragmentData i;\nCCSpriteInput(i);\n#if USE_TEXTURE\nvec4 color = v_color * CCSpriteSample(cc_spriteTexture, i.uv);\n#else\nvec4 color = v_color;\n#endif\n#if IS_GRAY\ncolor.rgb = SRGBToLinear(color.rgb);\ncolor.rgb = vec3(dot(color.rgb, vec3(0.2126, 0.7152, 0.0722)));\ncolor.rgb = sqrt(color.rgb);\n#endif\nreturn color;\n}\nvoid main() { gl_FragColor = frag(); }", + } + ], + [ + { + "vert": "\nprecision highp float;\nuniform highp mat4 cc_matView;\nuniform highp mat4 cc_matProj;\nuniform highp mat4 cc_matViewProj;\nuniform highp vec4 cc_cameraPos;\n#if USE_LOCAL\nuniform highp mat4 cc_matWorld;\n#endif\n#if SAMPLE_FROM_RT\n#endif\nattribute vec3 a_position;\nattribute vec2 a_texCoord;\nattribute vec4 a_color;\nvarying vec4 color;\nvarying vec2 uv0;\nvec4 vert () {\nvec4 pos = vec4(a_position, 1);\n#if USE_LOCAL\npos = cc_matWorld * pos;\n#endif\n#if USE_PIXEL_ALIGNMENT\npos = cc_matView * pos;\npos.xyz = floor(pos.xyz);\npos = cc_matProj * pos;\n#else\npos = cc_matViewProj * pos;\n#endif\nuv0 = a_texCoord;\n#if SAMPLE_FROM_RT\nuv0 = cc_cameraPos.w > 1.0 ? vec2(uv0.x, 1.0 - uv0.y) : uv0;\n#endif\ncolor = a_color;\nreturn pos;\n}\nvoid main() { gl_Position = vert(); }", + "frag": "\nprecision highp float;\nvec4 CCSampleWithAlphaSeparated(sampler2D tex, vec2 uv) {\n#if CC_USE_EMBEDDED_ALPHA\nreturn vec4(texture2D(tex, uv).rgb, texture2D(tex, uv + vec2(0.0, 0.5)).r);\n#else\nreturn texture2D(tex, uv);\n#endif\n}\n#if USE_ALPHA_TEST\nuniform float alphaThreshold;\n#endif\nvoid ALPHA_TEST (in vec4 color) {\n#if USE_ALPHA_TEST\nif (color.a < alphaThreshold) discard;\n#endif\n}\nvoid ALPHA_TEST (in float alpha) {\n#if USE_ALPHA_TEST\nif (alpha < alphaThreshold) discard;\n#endif\n}\nvarying vec4 color;\n#if USE_TEXTURE\nvarying vec2 uv0;\nuniform sampler2D cc_spriteTexture;\n#endif\nvec4 frag () {\nvec4 o = vec4(1, 1, 1, 1);\n#if USE_TEXTURE\no *= CCSampleWithAlphaSeparated(cc_spriteTexture, uv0);\n#if IS_GRAY\nfloat gray = 0.2126 * o.r + 0.7152 * o.g + 0.0722 * o.b;\no.r = o.g = o.b = gray;\n#endif\n#endif\no *= color;\nALPHA_TEST(o);\nreturn o;\n}\nvoid main() { gl_FragColor = frag(); }", + } + ], + [ + { + "vert": "\nprecision highp float;\nhighp float decode32 (highp vec4 rgba) {\nrgba = rgba * 255.0;\nhighp float Sign = 1.0 - (step(128.0, (rgba[3]) + 0.5)) * 2.0;\nhighp float Exponent = 2.0 * (mod(float(int((rgba[3]) + 0.5)), 128.0)) + (step(128.0, (rgba[2]) + 0.5)) - 127.0;\nhighp float Mantissa = (mod(float(int((rgba[2]) + 0.5)), 128.0)) * 65536.0 + rgba[1] * 256.0 + rgba[0] + 8388608.0;\nreturn Sign * exp2(Exponent - 23.0) * Mantissa;\n}\nstruct StandardVertInput {\nhighp vec4 position;\nvec3 normal;\nvec4 tangent;\n};\nattribute vec3 a_position;\nattribute vec3 a_normal;\nattribute vec2 a_texCoord;\nattribute vec4 a_tangent;\n#if CC_USE_MORPH\nattribute float a_vertexId;\nint getVertexId() {\nreturn int(a_vertexId);\n}\nuniform vec4 cc_displacementWeights[15];\nuniform vec4 cc_displacementTextureInfo;\nvec2 getPixelLocation(vec2 textureResolution, int pixelIndex) {\nfloat pixelIndexF = float(pixelIndex);\nfloat x = mod(pixelIndexF, textureResolution.x);\nfloat y = floor(pixelIndexF / textureResolution.x);\nreturn vec2(x, y);\n}\nvec2 getPixelCoordFromLocation(vec2 location, vec2 textureResolution) {\nreturn (vec2(location.x, location.y) + .5) / textureResolution;\n}\n#if CC_DEVICE_SUPPORT_FLOAT_TEXTURE\nvec4 fetchVec3ArrayFromTexture(sampler2D tex, int elementIndex) {\nint pixelIndex = elementIndex;\nvec2 location = getPixelLocation(cc_displacementTextureInfo.xy, pixelIndex);\nvec2 uv = getPixelCoordFromLocation(location, cc_displacementTextureInfo.xy);\nreturn texture2D(tex, uv);\n}\n#else\nvec4 fetchVec3ArrayFromTexture(sampler2D tex, int elementIndex) {\nint pixelIndex = elementIndex * 4;\nvec2 location = getPixelLocation(cc_displacementTextureInfo.xy, pixelIndex);\nvec2 x = getPixelCoordFromLocation(location + vec2(0.0, 0.0), cc_displacementTextureInfo.xy);\nvec2 y = getPixelCoordFromLocation(location + vec2(1.0, 0.0), cc_displacementTextureInfo.xy);\nvec2 z = getPixelCoordFromLocation(location + vec2(2.0, 0.0), cc_displacementTextureInfo.xy);\nreturn vec4(\ndecode32(texture2D(tex, x)),\ndecode32(texture2D(tex, y)),\ndecode32(texture2D(tex, z)),\n1.0\n);\n}\n#endif\nfloat getDisplacementWeight(int index) {\nint quot = index / 4;\nint remainder = index - quot * 4;\nif (remainder == 0) {\nreturn cc_displacementWeights[quot].x;\n} else if (remainder == 1) {\nreturn cc_displacementWeights[quot].y;\n} else if (remainder == 2) {\nreturn cc_displacementWeights[quot].z;\n} else {\nreturn cc_displacementWeights[quot].w;\n}\n}\nvec3 getVec3DisplacementFromTexture(sampler2D tex, int vertexIndex) {\n#if CC_MORPH_PRECOMPUTED\nreturn fetchVec3ArrayFromTexture(tex, vertexIndex).rgb;\n#else\nvec3 result = vec3(0, 0, 0);\nint nVertices = int(cc_displacementTextureInfo.z);\nfor (int iTarget = 0; iTarget < CC_MORPH_TARGET_COUNT; ++iTarget) {\nresult += (fetchVec3ArrayFromTexture(tex, nVertices * iTarget + vertexIndex).rgb * getDisplacementWeight(iTarget));\n}\nreturn result;\n#endif\n}\n#if CC_MORPH_TARGET_HAS_POSITION\nuniform sampler2D cc_PositionDisplacements;\nvec3 getPositionDisplacement(int vertexId) {\nreturn getVec3DisplacementFromTexture(cc_PositionDisplacements, vertexId);\n}\n#endif\n#if CC_MORPH_TARGET_HAS_NORMAL\nuniform sampler2D cc_NormalDisplacements;\nvec3 getNormalDisplacement(int vertexId) {\nreturn getVec3DisplacementFromTexture(cc_NormalDisplacements, vertexId);\n}\n#endif\n#if CC_MORPH_TARGET_HAS_TANGENT\nuniform sampler2D cc_TangentDisplacements;\nvec3 getTangentDisplacement(int vertexId) {\nreturn getVec3DisplacementFromTexture(cc_TangentDisplacements, vertexId);\n}\n#endif\nvoid applyMorph (inout StandardVertInput attr) {\nint vertexId = getVertexId();\n#if CC_MORPH_TARGET_HAS_POSITION\nattr.position.xyz = attr.position.xyz + getPositionDisplacement(vertexId);\n#endif\n#if CC_MORPH_TARGET_HAS_NORMAL\nattr.normal.xyz = attr.normal.xyz + getNormalDisplacement(vertexId);\n#endif\n#if CC_MORPH_TARGET_HAS_TANGENT\nattr.tangent.xyz = attr.tangent.xyz + getTangentDisplacement(vertexId);\n#endif\n}\nvoid applyMorph (inout vec4 position) {\n#if CC_MORPH_TARGET_HAS_POSITION\nposition.xyz = position.xyz + getPositionDisplacement(getVertexId());\n#endif\n}\n#endif\n#if CC_USE_SKINNING\nattribute vec4 a_joints;\nattribute vec4 a_weights;\n#if CC_USE_BAKED_ANIMATION\n#if USE_INSTANCING\nattribute highp vec4 a_jointAnimInfo;\n#endif\nuniform highp vec4 cc_jointTextureInfo;\nuniform highp vec4 cc_jointAnimInfo;\nuniform highp sampler2D cc_jointTexture;\n#else\nuniform highp vec4 cc_joints[90];\n#endif\n#if CC_USE_BAKED_ANIMATION\n#if CC_DEVICE_SUPPORT_FLOAT_TEXTURE\nmat4 getJointMatrix (float i) {\n#if USE_INSTANCING\nhighp float j = 3.0 * (a_jointAnimInfo.x * a_jointAnimInfo.y + i) + a_jointAnimInfo.z;\n#else\nhighp float j = 3.0 * (cc_jointAnimInfo.x * cc_jointTextureInfo.y + i) + cc_jointTextureInfo.z;\n#endif\nhighp float invSize = cc_jointTextureInfo.w;\nhighp float y = floor(j * invSize);\nhighp float x = floor(j - y * cc_jointTextureInfo.x);\ny = (y + 0.5) * invSize;\nvec4 v1 = texture2D(cc_jointTexture, vec2((x + 0.5) * invSize, y));\nvec4 v2 = texture2D(cc_jointTexture, vec2((x + 1.5) * invSize, y));\nvec4 v3 = texture2D(cc_jointTexture, vec2((x + 2.5) * invSize, y));\nreturn mat4(vec4(v1.xyz, 0.0), vec4(v2.xyz, 0.0), vec4(v3.xyz, 0.0), vec4(v1.w, v2.w, v3.w, 1.0));\n}\n#else\nmat4 getJointMatrix (float i) {\n#if USE_INSTANCING\nhighp float j = 12.0 * (a_jointAnimInfo.x * a_jointAnimInfo.y + i) + a_jointAnimInfo.z;\n#else\nhighp float j = 12.0 * (cc_jointAnimInfo.x * cc_jointTextureInfo.y + i) + cc_jointTextureInfo.z;\n#endif\nhighp float invSize = cc_jointTextureInfo.w;\nhighp float y = floor(j * invSize);\nhighp float x = floor(j - y * cc_jointTextureInfo.x);\ny = (y + 0.5) * invSize;\nvec4 v1 = vec4(\ndecode32(texture2D(cc_jointTexture, vec2((x + 0.5) * invSize, y))),\ndecode32(texture2D(cc_jointTexture, vec2((x + 1.5) * invSize, y))),\ndecode32(texture2D(cc_jointTexture, vec2((x + 2.5) * invSize, y))),\ndecode32(texture2D(cc_jointTexture, vec2((x + 3.5) * invSize, y)))\n);\nvec4 v2 = vec4(\ndecode32(texture2D(cc_jointTexture, vec2((x + 4.5) * invSize, y))),\ndecode32(texture2D(cc_jointTexture, vec2((x + 5.5) * invSize, y))),\ndecode32(texture2D(cc_jointTexture, vec2((x + 6.5) * invSize, y))),\ndecode32(texture2D(cc_jointTexture, vec2((x + 7.5) * invSize, y)))\n);\nvec4 v3 = vec4(\ndecode32(texture2D(cc_jointTexture, vec2((x + 8.5) * invSize, y))),\ndecode32(texture2D(cc_jointTexture, vec2((x + 9.5) * invSize, y))),\ndecode32(texture2D(cc_jointTexture, vec2((x + 10.5) * invSize, y))),\ndecode32(texture2D(cc_jointTexture, vec2((x + 11.5) * invSize, y)))\n);\nreturn mat4(vec4(v1.xyz, 0.0), vec4(v2.xyz, 0.0), vec4(v3.xyz, 0.0), vec4(v1.w, v2.w, v3.w, 1.0));\n}\n#endif\n#else\nmat4 getJointMatrix (float i) {\nint idx = int(i);\nvec4 v1 = cc_joints[idx * 3];\nvec4 v2 = cc_joints[idx * 3 + 1];\nvec4 v3 = cc_joints[idx * 3 + 2];\nreturn mat4(vec4(v1.xyz, 0.0), vec4(v2.xyz, 0.0), vec4(v3.xyz, 0.0), vec4(v1.w, v2.w, v3.w, 1.0));\n}\n#endif\nmat4 skinMatrix () {\nvec4 joints = vec4(a_joints);\nreturn getJointMatrix(joints.x) * a_weights.x\n+ getJointMatrix(joints.y) * a_weights.y\n+ getJointMatrix(joints.z) * a_weights.z\n+ getJointMatrix(joints.w) * a_weights.w;\n}\nvoid CCSkin (inout vec4 position) {\nmat4 m = skinMatrix();\nposition = m * position;\n}\nvoid CCSkin (inout StandardVertInput attr) {\nmat4 m = skinMatrix();\nattr.position = m * attr.position;\nattr.normal = (m * vec4(attr.normal, 0.0)).xyz;\nattr.tangent.xyz = (m * vec4(attr.tangent.xyz, 0.0)).xyz;\n}\n#endif\nuniform highp mat4 cc_matView;\nuniform highp mat4 cc_matProj;\nuniform highp vec4 cc_cameraPos;\nuniform mediump vec4 cc_fogBase;\nuniform mediump vec4 cc_fogAdd;\n#if USE_INSTANCING\nattribute vec4 a_matWorld0;\nattribute vec4 a_matWorld1;\nattribute vec4 a_matWorld2;\n#if USE_LIGHTMAP\nattribute vec4 a_lightingMapUVParam;\n#endif\n#elif USE_BATCHING\nattribute float a_dyn_batch_id;\nuniform highp mat4 cc_matWorlds[10];\n#else\nuniform highp mat4 cc_matWorld;\nuniform highp mat4 cc_matWorldIT;\nuniform highp vec4 cc_lightingMapUVParam;\n#endif\nuniform vec4 tilingOffset;\nfloat LinearFog(vec4 pos) {\nvec4 wPos = pos;\nfloat cam_dis = distance(cc_cameraPos, wPos);\nfloat fogStart = cc_fogBase.x;\nfloat fogEnd = cc_fogBase.y;\nreturn clamp((fogEnd - cam_dis) / (fogEnd - fogStart), 0., 1.);\n}\nfloat ExpFog(vec4 pos) {\nvec4 wPos = pos;\nfloat fogAtten = cc_fogAdd.z;\nfloat fogStart = cc_fogBase.x;\nfloat fogDensity = cc_fogBase.z;\nfloat cam_dis = max(distance(cc_cameraPos, wPos) - fogStart, 0.0) / fogAtten * 4.;\nfloat f = exp(-cam_dis * fogDensity);\nreturn f;\n}\nfloat ExpSquaredFog(vec4 pos) {\nvec4 wPos = pos;\nfloat fogAtten = cc_fogAdd.z;\nfloat fogStart = cc_fogBase.x;\nfloat fogDensity = cc_fogBase.z;\nfloat cam_dis = max(distance(cc_cameraPos, wPos) - fogStart, 0.0) / fogAtten * 4.;\nfloat f = exp(-cam_dis * cam_dis * fogDensity * fogDensity);\nreturn f;\n}\nfloat LayeredFog(vec4 pos) {\nvec4 wPos = pos;\nfloat fogAtten = cc_fogAdd.z;\nfloat _FogTop = cc_fogAdd.x;\nfloat _FogRange = cc_fogAdd.y;\nvec3 camWorldProj = cc_cameraPos.xyz;\ncamWorldProj.y = 0.;\nvec3 worldPosProj = wPos.xyz;\nworldPosProj.y = 0.;\nfloat fDeltaD = distance(worldPosProj, camWorldProj) / fogAtten * 2.0;\nfloat fDeltaY, fDensityIntegral;\nif (cc_cameraPos.y > _FogTop) {\nif (wPos.y < _FogTop) {\nfDeltaY = (_FogTop - wPos.y) / _FogRange * 2.0;\nfDensityIntegral = fDeltaY * fDeltaY * 0.5;\n} else {\nfDeltaY = 0.;\nfDensityIntegral = 0.;\n}\n} else {\nif (wPos.y < _FogTop) {\nfloat fDeltaA = (_FogTop - cc_cameraPos.y) / _FogRange * 2.;\nfloat fDeltaB = (_FogTop - wPos.y) / _FogRange * 2.;\nfDeltaY = abs(fDeltaA - fDeltaB);\nfDensityIntegral = abs((fDeltaA * fDeltaA * 0.5) - (fDeltaB * fDeltaB * 0.5));\n} else {\nfDeltaY = abs(_FogTop - cc_cameraPos.y) / _FogRange * 2.;\nfDensityIntegral = abs(fDeltaY * fDeltaY * 0.5);\n}\n}\nfloat fDensity;\nif (fDeltaY != 0.) {\nfDensity = (sqrt(1.0 + ((fDeltaD / fDeltaY) * (fDeltaD / fDeltaY)))) * fDensityIntegral;\n} else {\nfDensity = 0.;\n}\nfloat f = exp(-fDensity);\nreturn f;\n}\nvoid CC_TRANSFER_FOG_BASE(vec4 pos, out float factor)\n{\n#if CC_USE_FOG == 0\nfactor = LinearFog(pos);\n#elif CC_USE_FOG == 1\nfactor = ExpFog(pos);\n#elif CC_USE_FOG == 2\nfactor = ExpSquaredFog(pos);\n#elif CC_USE_FOG == 3\nfactor = LayeredFog(pos);\n#else\nfactor = 1.0;\n#endif\n}\n#if !CC_USE_ACCURATE_FOG\nvarying float v_fog_factor;\n#endif\nvoid CC_TRANSFER_FOG(vec4 pos) {\n#if !CC_USE_ACCURATE_FOG\nCC_TRANSFER_FOG_BASE(pos, v_fog_factor);\n#endif\n}\nvarying highp vec4 v_shadowPos;\nuniform highp mat4 cc_matLightViewProj;\n#if CC_RECEIVE_SHADOW\nuniform highp sampler2D cc_shadowMap;\nuniform highp sampler2D cc_spotLightingMap;\n#endif\n#if USE_VERTEX_COLOR\nattribute vec4 a_color;\nvarying vec4 v_color;\n#endif\nvarying vec3 v_position;\nvarying vec3 v_normal;\nvarying vec2 v_uv;\nvarying vec2 v_uv1;\n#if USE_NORMAL_MAP\nvarying vec3 v_tangent;\nvarying vec3 v_bitangent;\n#endif\n#if HAS_SECOND_UV || USE_LIGHTMAP\nattribute vec2 a_texCoord1;\n#endif\n#if USE_LIGHTMAP && !USE_BATCHING && !CC_FORWARD_ADD\nvarying vec3 v_luv;\nvoid CCLightingMapCaclUV()\n{\n#if !USE_INSTANCING\nv_luv.xy = cc_lightingMapUVParam.xy + a_texCoord1 * cc_lightingMapUVParam.zw;\nv_luv.z = cc_lightingMapUVParam.z;\n#else\nv_luv.xy = a_lightingMapUVParam.xy + a_texCoord1 * a_lightingMapUVParam.zw;\nv_luv.z = a_lightingMapUVParam.z;\n#endif\n}\n#endif\nvoid main () {\nStandardVertInput In;\nIn.position = vec4(a_position, 1.0);\nIn.normal = a_normal;\nIn.tangent = a_tangent;\n#if CC_USE_MORPH\napplyMorph(In);\n#endif\n#if CC_USE_SKINNING\nCCSkin(In);\n#endif\nmat4 matWorld, matWorldIT;\n#if USE_INSTANCING\nmatWorld = mat4(\nvec4(a_matWorld0.xyz, 0.0),\nvec4(a_matWorld1.xyz, 0.0),\nvec4(a_matWorld2.xyz, 0.0),\nvec4(a_matWorld0.w, a_matWorld1.w, a_matWorld2.w, 1.0)\n);\nmatWorldIT = matWorld;\n#elif USE_BATCHING\nmatWorld = cc_matWorlds[int(a_dyn_batch_id)];\nmatWorldIT = matWorld;\n#else\nmatWorld = cc_matWorld;\nmatWorldIT = cc_matWorldIT;\n#endif\nvec4 pos = matWorld * In.position;\nv_position = pos.xyz;\nv_normal = normalize((matWorldIT * vec4(In.normal, 0.0)).xyz);\n#if USE_TWOSIDE\nvec3 viewDirect = normalize(cc_cameraPos.xyz - v_position);\nv_normal *= dot(v_normal, viewDirect) < 0.0 ? -1.0 : 1.0;\n#endif\n#if USE_NORMAL_MAP\nv_tangent = normalize((matWorld * vec4(In.tangent.xyz, 0.0)).xyz);\nv_bitangent = cross(v_normal, v_tangent) * In.tangent.w;\n#endif\nv_uv = a_texCoord * tilingOffset.xy + tilingOffset.zw;\n#if SAMPLE_FROM_RT\nv_uv = cc_cameraPos.w > 1.0 ? vec2(v_uv.x, 1.0 - v_uv.y) : v_uv;\n#endif\n#if HAS_SECOND_UV\nv_uv1 = a_texCoord1 * tilingOffset.xy + tilingOffset.zw;\n#if SAMPLE_FROM_RT\nv_uv1 = cc_cameraPos.w > 1.0 ? vec2(v_uv1.x, 1.0 - v_uv1.y) : v_uv1;\n#endif\n#endif\n#if USE_VERTEX_COLOR\nv_color = a_color;\n#endif\nCC_TRANSFER_FOG(pos);\nv_shadowPos = cc_matLightViewProj * pos;\n#if USE_LIGHTMAP && !USE_BATCHING && !CC_FORWARD_ADD\nCCLightingMapCaclUV();\n#endif\ngl_Position = cc_matProj * (cc_matView * matWorld) * In.position;\n}", + "frag": "\n#ifdef GL_EXT_draw_buffers\n#extension GL_EXT_draw_buffers: enable\n#endif\n#ifdef GL_EXT_shader_texture_lod\n#extension GL_EXT_shader_texture_lod: enable\n#endif\nprecision highp float;\nuniform mediump vec4 cc_screenSize;\nuniform highp mat4 cc_matView;\nuniform highp vec4 cc_cameraPos;\nuniform mediump vec4 cc_mainLitDir;\nuniform mediump vec4 cc_mainLitColor;\nuniform mediump vec4 cc_ambientSky;\nuniform mediump vec4 cc_ambientGround;\nuniform mediump vec4 cc_fogColor;\nuniform mediump vec4 cc_fogBase;\nuniform mediump vec4 cc_fogAdd;\nuniform mediump vec4 cc_nearFar;\nuniform vec4 albedo;\nuniform vec4 albedoScaleAndCutoff;\nuniform vec4 pbrParams;\nuniform vec4 emissive;\nuniform vec4 emissiveScaleParam;\nfloat LinearFog(vec4 pos) {\nvec4 wPos = pos;\nfloat cam_dis = distance(cc_cameraPos, wPos);\nfloat fogStart = cc_fogBase.x;\nfloat fogEnd = cc_fogBase.y;\nreturn clamp((fogEnd - cam_dis) / (fogEnd - fogStart), 0., 1.);\n}\nfloat ExpFog(vec4 pos) {\nvec4 wPos = pos;\nfloat fogAtten = cc_fogAdd.z;\nfloat fogStart = cc_fogBase.x;\nfloat fogDensity = cc_fogBase.z;\nfloat cam_dis = max(distance(cc_cameraPos, wPos) - fogStart, 0.0) / fogAtten * 4.;\nfloat f = exp(-cam_dis * fogDensity);\nreturn f;\n}\nfloat ExpSquaredFog(vec4 pos) {\nvec4 wPos = pos;\nfloat fogAtten = cc_fogAdd.z;\nfloat fogStart = cc_fogBase.x;\nfloat fogDensity = cc_fogBase.z;\nfloat cam_dis = max(distance(cc_cameraPos, wPos) - fogStart, 0.0) / fogAtten * 4.;\nfloat f = exp(-cam_dis * cam_dis * fogDensity * fogDensity);\nreturn f;\n}\nfloat LayeredFog(vec4 pos) {\nvec4 wPos = pos;\nfloat fogAtten = cc_fogAdd.z;\nfloat _FogTop = cc_fogAdd.x;\nfloat _FogRange = cc_fogAdd.y;\nvec3 camWorldProj = cc_cameraPos.xyz;\ncamWorldProj.y = 0.;\nvec3 worldPosProj = wPos.xyz;\nworldPosProj.y = 0.;\nfloat fDeltaD = distance(worldPosProj, camWorldProj) / fogAtten * 2.0;\nfloat fDeltaY, fDensityIntegral;\nif (cc_cameraPos.y > _FogTop) {\nif (wPos.y < _FogTop) {\nfDeltaY = (_FogTop - wPos.y) / _FogRange * 2.0;\nfDensityIntegral = fDeltaY * fDeltaY * 0.5;\n} else {\nfDeltaY = 0.;\nfDensityIntegral = 0.;\n}\n} else {\nif (wPos.y < _FogTop) {\nfloat fDeltaA = (_FogTop - cc_cameraPos.y) / _FogRange * 2.;\nfloat fDeltaB = (_FogTop - wPos.y) / _FogRange * 2.;\nfDeltaY = abs(fDeltaA - fDeltaB);\nfDensityIntegral = abs((fDeltaA * fDeltaA * 0.5) - (fDeltaB * fDeltaB * 0.5));\n} else {\nfDeltaY = abs(_FogTop - cc_cameraPos.y) / _FogRange * 2.;\nfDensityIntegral = abs(fDeltaY * fDeltaY * 0.5);\n}\n}\nfloat fDensity;\nif (fDeltaY != 0.) {\nfDensity = (sqrt(1.0 + ((fDeltaD / fDeltaY) * (fDeltaD / fDeltaY)))) * fDensityIntegral;\n} else {\nfDensity = 0.;\n}\nfloat f = exp(-fDensity);\nreturn f;\n}\nvoid CC_TRANSFER_FOG_BASE(vec4 pos, out float factor)\n{\n#if CC_USE_FOG == 0\nfactor = LinearFog(pos);\n#elif CC_USE_FOG == 1\nfactor = ExpFog(pos);\n#elif CC_USE_FOG == 2\nfactor = ExpSquaredFog(pos);\n#elif CC_USE_FOG == 3\nfactor = LayeredFog(pos);\n#else\nfactor = 1.0;\n#endif\n}\nvoid CC_APPLY_FOG_BASE(inout vec4 color, float factor) {\ncolor = vec4(mix(cc_fogColor.rgb, color.rgb, factor), color.a);\n}\n#if !CC_USE_ACCURATE_FOG\nvarying float v_fog_factor;\n#endif\nvoid CC_APPLY_FOG(inout vec4 color) {\n#if !CC_USE_ACCURATE_FOG\nCC_APPLY_FOG_BASE(color, v_fog_factor);\n#endif\n}\nvoid CC_APPLY_FOG(inout vec4 color, vec3 worldPos) {\n#if CC_USE_ACCURATE_FOG\nfloat factor;\nCC_TRANSFER_FOG_BASE(vec4(worldPos, 1.0), factor);\n#else\nfloat factor = v_fog_factor;\n#endif\nCC_APPLY_FOG_BASE(color, factor);\n}\nvec3 SRGBToLinear (vec3 gamma) {\nreturn gamma * gamma;\n}\nuniform highp mat4 cc_matLightView;\nuniform highp vec4 cc_shadowInvProjDepthInfo;\nuniform highp vec4 cc_shadowProjDepthInfo;\nuniform highp vec4 cc_shadowProjInfo;\nuniform lowp vec4 cc_shadowNFLSInfo;\nuniform lowp vec4 cc_shadowWHPBInfo;\nuniform lowp vec4 cc_shadowLPNNInfo;\nfloat CCGetLinearDepthFromViewSpace(vec3 viewPos) {\nfloat dist = length(viewPos);\nreturn (dist - cc_shadowNFLSInfo.x) / (cc_shadowNFLSInfo.y - cc_shadowNFLSInfo.x);\n}\nfloat CCGetLinearDepth(vec3 worldPos) {\nvec4 viewStartPos = cc_matLightView * vec4(worldPos.xyz, 1.0);\nreturn CCGetLinearDepthFromViewSpace(viewStartPos.xyz);\n}\n#if CC_RECEIVE_SHADOW\nuniform highp sampler2D cc_shadowMap;\nuniform highp sampler2D cc_spotLightingMap;\nvec4 ApplyShadowDepthBias_FaceNormal(vec4 shadowPos, vec3 worldNormal)\n{\nvec4 newShadowPos = shadowPos;\nif(cc_shadowLPNNInfo.z > 0.0001)\n{\nvec4 viewNormal = cc_matLightView * vec4(worldNormal, 0.0);\nif(viewNormal.z < 0.1)\nnewShadowPos.xy += viewNormal.xy * cc_shadowProjInfo.xy * cc_shadowLPNNInfo.z * clamp(viewNormal.z, 0.001, 0.1);\n}\nreturn newShadowPos;\n}\nvec4 ApplyShadowDepthBias_Perspective(vec4 shadowPos, float viewspaceDepthBias)\n{\nvec3 viewSpacePos;\nviewSpacePos.xy = shadowPos.xy * cc_shadowProjInfo.zw;\nviewSpacePos.z = shadowPos.z * cc_shadowInvProjDepthInfo.x + shadowPos.w * cc_shadowInvProjDepthInfo.y;\nviewSpacePos.xyz += cc_shadowProjDepthInfo.z * normalize(viewSpacePos.xyz) * viewspaceDepthBias;\nvec4 clipSpacePos;\nclipSpacePos.xy = viewSpacePos.xy * cc_shadowProjInfo.xy;\nclipSpacePos.zw = viewSpacePos.z * cc_shadowProjDepthInfo.xz + vec2(cc_shadowProjDepthInfo.y, 0.0);\nif (cc_shadowNFLSInfo.z > 0.000001) {\nclipSpacePos.z = CCGetLinearDepthFromViewSpace(viewSpacePos.xyz);\nclipSpacePos.z = (clipSpacePos.z * 2.0 - 1.0) * clipSpacePos.w;\n}\nreturn clipSpacePos;\n}\nvec4 ApplyShadowDepthBias_Orthographic(vec4 shadowPos, float viewspaceDepthBias)\n{\nfloat coeffA = cc_shadowProjDepthInfo.x;\nfloat coeffB = cc_shadowProjDepthInfo.y;\nfloat viewSpacePos_z = (shadowPos.z - coeffB) / coeffA;\nviewSpacePos_z += viewspaceDepthBias;\nvec4 result = shadowPos;\nresult.z = viewSpacePos_z * coeffA + coeffB;\nreturn result;\n}\nfloat CCGetShadowFactorHard (vec4 shadowPos) {\nvec4 clipPosNew = ApplyShadowDepthBias_Orthographic(shadowPos, cc_shadowWHPBInfo.w);\nvec3 clipPos = clipPosNew.xyz / clipPosNew.w * 0.5 + 0.5;\nif (clipPos.x < 0.0 || clipPos.x > 1.0 ||\nclipPos.y < 0.0 || clipPos.y > 1.0 ||\nclipPos.z < 0.0 || clipPos.z > 1.0) { return 1.0; }\nclipPos.xy = cc_cameraPos.w == 1.0 ? vec2(clipPos.xy.x, 1.0 - clipPos.xy.y) : clipPos.xy;\nfloat shadow = 0.0;\nfloat closestDepth = 0.0;\nif (cc_shadowLPNNInfo.y > 0.000001) {\nclosestDepth = dot(texture2D(cc_shadowMap, clipPos.xy), vec4(1.0, 1.0 / 255.0, 1.0 / 65025.0, 1.0 / 16581375.0));\n} else {\nclosestDepth = texture2D(cc_shadowMap, clipPos.xy).x;\n}\nshadow = step(clipPos.z, closestDepth);\nreturn shadow;\n}\nfloat CCGetShadowFactorSoft (vec4 shadowPos) {\nvec4 clipPosNew = ApplyShadowDepthBias_Orthographic(shadowPos, cc_shadowWHPBInfo.w);\nvec3 clipPos = clipPosNew.xyz / clipPosNew.w * 0.5 + 0.5;\nif (clipPos.x < 0.0 || clipPos.x > 1.0 ||\nclipPos.y < 0.0 || clipPos.y > 1.0 ||\nclipPos.z < 0.0 || clipPos.z > 1.0) { return 1.0; }\nclipPos.xy = cc_cameraPos.w == 1.0 ? vec2(clipPos.xy.x, 1.0 - clipPos.xy.y) : clipPos.xy;\nfloat offsetDepth = clipPos.z;\nvec2 mapSize = cc_shadowWHPBInfo.xy;\nvec2 oneTap = 1.0 / mapSize;\nvec2 clipPos_offset = clipPos.xy + oneTap;\nfloat block0, block1, block2, block3;\nif (cc_shadowLPNNInfo.y > 0.000001) {\nblock0 = step(offsetDepth, dot(texture2D(cc_shadowMap, vec2(clipPos.x, clipPos.y)), vec4(1.0, 1.0 / 255.0, 1.0 / 65025.0, 1.0 / 16581375.0)));\nblock1 = step(offsetDepth, dot(texture2D(cc_shadowMap, vec2(clipPos_offset.x, clipPos.y)), vec4(1.0, 1.0 / 255.0, 1.0 / 65025.0, 1.0 / 16581375.0)));\nblock2 = step(offsetDepth, dot(texture2D(cc_shadowMap, vec2(clipPos.x, clipPos_offset.y)), vec4(1.0, 1.0 / 255.0, 1.0 / 65025.0, 1.0 / 16581375.0)));\nblock3 = step(offsetDepth, dot(texture2D(cc_shadowMap, vec2(clipPos_offset.x, clipPos_offset.y)), vec4(1.0, 1.0 / 255.0, 1.0 / 65025.0, 1.0 / 16581375.0)));\n} else {\nblock0 = step(offsetDepth, texture2D(cc_shadowMap, vec2(clipPos.x, clipPos.y)).x);\nblock1 = step(offsetDepth, texture2D(cc_shadowMap, vec2(clipPos_offset.x, clipPos.y)).x);\nblock2 = step(offsetDepth, texture2D(cc_shadowMap, vec2(clipPos.x, clipPos_offset.y)).x);\nblock3 = step(offsetDepth, texture2D(cc_shadowMap, vec2(clipPos_offset.x, clipPos_offset.y)).x);\n}\nfloat coefX = mod(clipPos.x, oneTap.x) * mapSize.x;\nfloat resultX = mix(block0, block1, coefX);\nfloat resultY = mix(block2, block3, coefX);\nfloat coefY = mod(clipPos.y, oneTap.y) * mapSize.y;\nreturn mix(resultX, resultY, coefY);\n}\nfloat CCGetShadowFactorSoft2X (vec4 shadowPos) {\nvec4 clipPosNew = ApplyShadowDepthBias_Orthographic(shadowPos, cc_shadowWHPBInfo.w);\nvec3 clipPos = clipPosNew.xyz / clipPosNew.w * 0.5 + 0.5;\nif (clipPos.x < 0.0 || clipPos.x > 1.0 ||\nclipPos.y < 0.0 || clipPos.y > 1.0 ||\nclipPos.z < 0.0 || clipPos.z > 1.0) { return 1.0; }\nclipPos.xy = cc_cameraPos.w == 1.0 ? vec2(clipPos.xy.x, 1.0 - clipPos.xy.y) : clipPos.xy;\nfloat offsetDepth = clipPos.z;\nvec2 mapSize = cc_shadowWHPBInfo.xy;\nvec2 oneTap = 1.0 / mapSize;\nfloat clipPos_offset_L = clipPos.x - oneTap.x;\nfloat clipPos_offset_R = clipPos.x + oneTap.x;\nfloat clipPos_offset_U = clipPos.y - oneTap.y;\nfloat clipPos_offset_D = clipPos.y + oneTap.y;\nfloat block0, block1, block2, block3, block4, block5, block6, block7, block8;\nif (cc_shadowLPNNInfo.y > 0.000001) {\nblock0 = step(offsetDepth, dot(texture2D(cc_shadowMap, vec2(clipPos_offset_L, clipPos_offset_U)), vec4(1.0, 1.0 / 255.0, 1.0 / 65025.0, 1.0 / 16581375.0)));\nblock1 = step(offsetDepth, dot(texture2D(cc_shadowMap, vec2(clipPos.x, clipPos_offset_U)), vec4(1.0, 1.0 / 255.0, 1.0 / 65025.0, 1.0 / 16581375.0)));\nblock2 = step(offsetDepth, dot(texture2D(cc_shadowMap, vec2(clipPos_offset_R, clipPos_offset_U)), vec4(1.0, 1.0 / 255.0, 1.0 / 65025.0, 1.0 / 16581375.0)));\nblock3 = step(offsetDepth, dot(texture2D(cc_shadowMap, vec2(clipPos_offset_L, clipPos.y)), vec4(1.0, 1.0 / 255.0, 1.0 / 65025.0, 1.0 / 16581375.0)));\nblock4 = step(offsetDepth, dot(texture2D(cc_shadowMap, vec2(clipPos.x, clipPos.y)), vec4(1.0, 1.0 / 255.0, 1.0 / 65025.0, 1.0 / 16581375.0)));\nblock5 = step(offsetDepth, dot(texture2D(cc_shadowMap, vec2(clipPos_offset_R, clipPos.y)), vec4(1.0, 1.0 / 255.0, 1.0 / 65025.0, 1.0 / 16581375.0)));\nblock6 = step(offsetDepth, dot(texture2D(cc_shadowMap, vec2(clipPos_offset_L, clipPos_offset_D)), vec4(1.0, 1.0 / 255.0, 1.0 / 65025.0, 1.0 / 16581375.0)));\nblock7 = step(offsetDepth, dot(texture2D(cc_shadowMap, vec2(clipPos.x, clipPos_offset_D)), vec4(1.0, 1.0 / 255.0, 1.0 / 65025.0, 1.0 / 16581375.0)));\nblock8 = step(offsetDepth, dot(texture2D(cc_shadowMap, vec2(clipPos_offset_R, clipPos_offset_D)), vec4(1.0, 1.0 / 255.0, 1.0 / 65025.0, 1.0 / 16581375.0)));\n} else {\nblock0 = step(offsetDepth, texture2D(cc_shadowMap, vec2(clipPos_offset_L, clipPos_offset_U)).x);\nblock1 = step(offsetDepth, texture2D(cc_shadowMap, vec2(clipPos.x, clipPos_offset_U)).x);\nblock2 = step(offsetDepth, texture2D(cc_shadowMap, vec2(clipPos_offset_R, clipPos_offset_U)).x);\nblock3 = step(offsetDepth, texture2D(cc_shadowMap, vec2(clipPos_offset_L, clipPos.y)).x);\nblock4 = step(offsetDepth, texture2D(cc_shadowMap, vec2(clipPos.x, clipPos.y)).x);\nblock5 = step(offsetDepth, texture2D(cc_shadowMap, vec2(clipPos_offset_R, clipPos.y)).x);\nblock6 = step(offsetDepth, texture2D(cc_shadowMap, vec2(clipPos_offset_L, clipPos_offset_D)).x);\nblock7 = step(offsetDepth, texture2D(cc_shadowMap, vec2(clipPos.x, clipPos_offset_D)).x);\nblock8 = step(offsetDepth, texture2D(cc_shadowMap, vec2(clipPos_offset_R, clipPos_offset_D)).x);\n}\nfloat coefX = mod(clipPos.x, oneTap.x) * mapSize.x;\nfloat coefY = mod(clipPos.y, oneTap.y) * mapSize.y;\nfloat shadow = 0.0;\nfloat resultX = mix(block0, block1, coefX);\nfloat resultY = mix(block3, block4, coefX);\nshadow += mix(resultX , resultY, coefY);\nresultX = mix(block1, block2, coefX);\nresultY = mix(block4, block5, coefX);\nshadow += mix(resultX , resultY, coefY);\nresultX = mix(block3, block4, coefX);\nresultY = mix(block6, block7, coefX);\nshadow += mix(resultX, resultY, coefY);\nresultX = mix(block4, block5, coefX);\nresultY = mix(block7, block8, coefX);\nshadow += mix(resultX, resultY, coefY);\nreturn shadow * 0.25;\n}\nfloat CCGetSpotLightShadowFactorHard (vec4 shadowPos, vec3 worldPos) {\nvec4 clipPosNew = ApplyShadowDepthBias_Perspective(shadowPos, cc_shadowWHPBInfo.w);\nvec3 clipPos = clipPosNew.xyz / clipPosNew.w * 0.5 + 0.5;\nif (clipPos.x < 0.0 || clipPos.x > 1.0 ||\nclipPos.y < 0.0 || clipPos.y > 1.0 ||\nclipPos.z < 0.0 || clipPos.z > 1.0) { return 1.0; }\nclipPos.xy = cc_cameraPos.w == 1.0 ? vec2(clipPos.xy.x, 1.0 - clipPos.xy.y) : clipPos.xy;\nfloat shadow = 0.0;\nfloat closestDepth = 0.0;\nfloat depth = clipPos.z;\nif (cc_shadowLPNNInfo.y > 0.000001) {\nclosestDepth = dot(texture2D(cc_spotLightingMap, clipPos.xy), vec4(1.0, 1.0 / 255.0, 1.0 / 65025.0, 1.0 / 16581375.0));\n} else {\nclosestDepth = texture2D(cc_spotLightingMap, clipPos.xy).x;\n}\nshadow = step(depth, closestDepth);\nreturn shadow;\n}\nfloat CCGetSpotLightShadowFactorSoft (vec4 shadowPos, vec3 worldPos) {\nvec4 clipPosNew = ApplyShadowDepthBias_Perspective(shadowPos, cc_shadowWHPBInfo.w);\nvec3 clipPos = clipPosNew.xyz / clipPosNew.w * 0.5 + 0.5;\nif (clipPos.x < 0.0 || clipPos.x > 1.0 ||\nclipPos.y < 0.0 || clipPos.y > 1.0 ||\nclipPos.z < 0.0 || clipPos.z > 1.0) { return 1.0; }\nclipPos.xy = cc_cameraPos.w == 1.0 ? vec2(clipPos.xy.x, 1.0 - clipPos.xy.y) : clipPos.xy;\nfloat depth = 0.0;\nif (cc_shadowNFLSInfo.z > 0.000001) {\ndepth = CCGetLinearDepth(worldPos);\n} else {\ndepth = clipPos.z;\n}\nfloat bias = cc_shadowWHPBInfo.w;\nvec2 oneTap = 1.0 / cc_shadowWHPBInfo.xy;\nvec2 clipPos_offset = clipPos.xy + oneTap;\nfloat block0, block1, block2, block3;\nif (cc_shadowLPNNInfo.y > 0.000001) {\nblock0 = step(depth, dot(texture2D(cc_spotLightingMap, vec2(clipPos.x, clipPos.y)), vec4(1.0, 1.0 / 255.0, 1.0 / 65025.0, 1.0 / 16581375.0)));\nblock1 = step(depth, dot(texture2D(cc_spotLightingMap, vec2(clipPos_offset.x, clipPos.y)), vec4(1.0, 1.0 / 255.0, 1.0 / 65025.0, 1.0 / 16581375.0)));\nblock2 = step(depth, dot(texture2D(cc_spotLightingMap, vec2(clipPos.x, clipPos_offset.y)), vec4(1.0, 1.0 / 255.0, 1.0 / 65025.0, 1.0 / 16581375.0)));\nblock3 = step(depth, dot(texture2D(cc_spotLightingMap, vec2(clipPos_offset.x, clipPos_offset.y)), vec4(1.0, 1.0 / 255.0, 1.0 / 65025.0, 1.0 / 16581375.0)));\n} else {\nblock0 = step(depth, texture2D(cc_spotLightingMap, vec2(clipPos.x, clipPos.y)).x);\nblock1 = step(depth, texture2D(cc_spotLightingMap, vec2(clipPos_offset.x, clipPos.y)).x);\nblock2 = step(depth, texture2D(cc_spotLightingMap, vec2(clipPos.x, clipPos_offset.y)).x);\nblock3 = step(depth, texture2D(cc_spotLightingMap, vec2(clipPos_offset.x, clipPos_offset.y)).x);\n}\nfloat coefX = mod(clipPos.x, oneTap.x) * cc_shadowWHPBInfo.x;\nfloat resultX = mix(block0, block1, coefX);\nfloat resultY = mix(block2, block3, coefX);\nfloat coefY = mod(clipPos.y, oneTap.y) * cc_shadowWHPBInfo.y;\nreturn mix(resultX, resultY, coefY);\n}\nfloat CCGetSpotLightShadowFactorSoft2X (vec4 shadowPos, vec3 worldPos) {\nvec4 clipPosNew = ApplyShadowDepthBias_Perspective(shadowPos, cc_shadowWHPBInfo.w);\nvec3 clipPos = clipPosNew.xyz / clipPosNew.w * 0.5 + 0.5;\nif (clipPos.x < 0.0 || clipPos.x > 1.0 ||\nclipPos.y < 0.0 || clipPos.y > 1.0 ||\nclipPos.z < 0.0 || clipPos.z > 1.0) { return 1.0; }\nclipPos.xy = cc_cameraPos.w == 1.0 ? vec2(clipPos.xy.x, 1.0 - clipPos.xy.y) : clipPos.xy;\nfloat depth = 0.0;\nif (cc_shadowNFLSInfo.z > 0.000001) {\ndepth = CCGetLinearDepth(worldPos);\n} else {\ndepth = clipPos.z;\n}\nfloat bias = cc_shadowWHPBInfo.w;\nvec2 mapSize = cc_shadowWHPBInfo.xy;\nvec2 oneTap = 1.0 / mapSize;\nfloat clipPos_offset_L = clipPos.x - oneTap.x;\nfloat clipPos_offset_R = clipPos.x + oneTap.x;\nfloat clipPos_offset_U = clipPos.y - oneTap.y;\nfloat clipPos_offset_D = clipPos.y + oneTap.y;\nfloat block0, block1, block2, block3, block4, block5, block6, block7, block8;\nif (cc_shadowLPNNInfo.y > 0.000001) {\nblock0 = step(depth, dot(texture2D(cc_spotLightingMap, vec2(clipPos_offset_L, clipPos_offset_U)), vec4(1.0, 1.0 / 255.0, 1.0 / 65025.0, 1.0 / 16581375.0)));\nblock1 = step(depth, dot(texture2D(cc_spotLightingMap, vec2(clipPos.x, clipPos_offset_U)), vec4(1.0, 1.0 / 255.0, 1.0 / 65025.0, 1.0 / 16581375.0)));\nblock2 = step(depth, dot(texture2D(cc_spotLightingMap, vec2(clipPos_offset_R, clipPos_offset_U)), vec4(1.0, 1.0 / 255.0, 1.0 / 65025.0, 1.0 / 16581375.0)));\nblock3 = step(depth, dot(texture2D(cc_spotLightingMap, vec2(clipPos_offset_L, clipPos.y)), vec4(1.0, 1.0 / 255.0, 1.0 / 65025.0, 1.0 / 16581375.0)));\nblock4 = step(depth, dot(texture2D(cc_spotLightingMap, vec2(clipPos.x, clipPos.y)), vec4(1.0, 1.0 / 255.0, 1.0 / 65025.0, 1.0 / 16581375.0)));\nblock5 = step(depth, dot(texture2D(cc_spotLightingMap, vec2(clipPos_offset_R, clipPos.y)), vec4(1.0, 1.0 / 255.0, 1.0 / 65025.0, 1.0 / 16581375.0)));\nblock6 = step(depth, dot(texture2D(cc_spotLightingMap, vec2(clipPos_offset_L, clipPos_offset_D)), vec4(1.0, 1.0 / 255.0, 1.0 / 65025.0, 1.0 / 16581375.0)));\nblock7 = step(depth, dot(texture2D(cc_spotLightingMap, vec2(clipPos.x, clipPos_offset_D)), vec4(1.0, 1.0 / 255.0, 1.0 / 65025.0, 1.0 / 16581375.0)));\nblock8 = step(depth, dot(texture2D(cc_spotLightingMap, vec2(clipPos_offset_R, clipPos_offset_D)), vec4(1.0, 1.0 / 255.0, 1.0 / 65025.0, 1.0 / 16581375.0)));\n} else {\nblock0 = step(depth, texture2D(cc_spotLightingMap, vec2(clipPos_offset_L, clipPos_offset_U)).x);\nblock1 = step(depth, texture2D(cc_spotLightingMap, vec2(clipPos.x, clipPos_offset_U)).x);\nblock2 = step(depth, texture2D(cc_spotLightingMap, vec2(clipPos_offset_R, clipPos_offset_U)).x);\nblock3 = step(depth, texture2D(cc_spotLightingMap, vec2(clipPos_offset_L, clipPos.y)).x);\nblock4 = step(depth, texture2D(cc_spotLightingMap, vec2(clipPos.x, clipPos.y)).x);\nblock5 = step(depth, texture2D(cc_spotLightingMap, vec2(clipPos_offset_R, clipPos.y)).x);\nblock6 = step(depth, texture2D(cc_spotLightingMap, vec2(clipPos_offset_L, clipPos_offset_D)).x);\nblock7 = step(depth, texture2D(cc_spotLightingMap, vec2(clipPos.x, clipPos_offset_D)).x);\nblock8 = step(depth, texture2D(cc_spotLightingMap, vec2(clipPos_offset_R, clipPos_offset_D)).x);\n}\nfloat coefX = mod(clipPos.x, oneTap.x) * mapSize.x;\nfloat coefY = mod(clipPos.y, oneTap.y) * mapSize.y;\nfloat shadow = 0.0;\nfloat resultX = mix(block0, block1, coefX);\nfloat resultY = mix(block3, block4, coefX);\nshadow += mix(resultX , resultY, coefY);\nresultX = mix(block1, block2, coefX);\nresultY = mix(block4, block5, coefX);\nshadow += mix(resultX , resultY, coefY);\nresultX = mix(block3, block4, coefX);\nresultY = mix(block6, block7, coefX);\nshadow += mix(resultX, resultY, coefY);\nresultX = mix(block4, block5, coefX);\nresultY = mix(block7, block8, coefX);\nshadow += mix(resultX, resultY, coefY);\nreturn shadow * 0.25;\n}\n#endif\n#if CC_USE_IBL\nuniform samplerCube cc_environment;\nvec4 fragTextureLod (sampler2D tex, vec2 coord, float lod) {\n#ifdef GL_EXT_shader_texture_lod\nreturn texture2DLodEXT(tex, coord, lod);\n#else\nreturn texture2D(tex, coord, lod);\n#endif\n}\nvec4 fragTextureLod (samplerCube tex, vec3 coord, float lod) {\n#ifdef GL_EXT_shader_texture_lod\nreturn textureCubeLodEXT(tex, coord, lod);\n#else\nreturn textureCube(tex, coord, lod);\n#endif\n}\nvec3 unpackRGBE (vec4 rgbe) {\nreturn rgbe.rgb * pow(1.1, rgbe.a * 255.0 - 128.0);\n}\n#if CC_USE_DIFFUSEMAP\nuniform samplerCube cc_diffuseMap;\n#endif\n#endif\nfloat GGXMobile (float roughness, float NoH, vec3 H, vec3 N) {\nvec3 NxH = cross(N, H);\nfloat OneMinusNoHSqr = dot(NxH, NxH);\nfloat a = roughness * roughness;\nfloat n = NoH * a;\nfloat p = a / (OneMinusNoHSqr + n * n);\nreturn p * p;\n}\nfloat CalcSpecular (float roughness, float NoH, vec3 H, vec3 N) {\nreturn (roughness * 0.25 + 0.25) * GGXMobile(roughness, NoH, H, N);\n}\nvec3 BRDFApprox (vec3 specular, float roughness, float NoV) {\nconst vec4 c0 = vec4(-1.0, -0.0275, -0.572, 0.022);\nconst vec4 c1 = vec4(1.0, 0.0425, 1.04, -0.04);\nvec4 r = roughness * c0 + c1;\nfloat a004 = min(r.x * r.x, exp2(-9.28 * NoV)) * r.x + r.y;\nvec2 AB = vec2(-1.04, 1.04) * a004 + r.zw;\nAB.y *= clamp(50.0 * specular.g, 0.0, 1.0);\nreturn specular * AB.x + AB.y;\n}\n#if USE_REFLECTION_DENOISE\nvec3 GetEnvReflectionWithMipFiltering(vec3 R, float roughness, float mipCount, float denoiseIntensity) {\n#if CC_USE_IBL\nfloat mip = roughness * mipCount;\nfloat delta = (dot(dFdx(R), dFdy(R))) * 1000.0;\nfloat mipBias = mix(0.0, 5.0, clamp(delta, 0.0, 1.0));\nvec4 biased = fragTextureLod(cc_environment, R, mip + mipBias);\nvec4 filtered = textureCube(cc_environment, R);\n#if CC_USE_IBL == 2\nbiased.rgb = unpackRGBE(biased);\nfiltered.rgb = unpackRGBE(filtered);\n#else\nbiased.rgb = SRGBToLinear(biased.rgb);\nfiltered.rgb = SRGBToLinear(filtered.rgb);\n#endif\nreturn mix(biased.rgb, filtered.rgb, denoiseIntensity);\n#else\nreturn vec3(0.0, 0.0, 0.0);\n#endif\n}\n#endif\nstruct StandardSurface {\nvec4 albedo;\nvec3 position;\nvec3 normal;\nvec3 emissive;\nvec3 lightmap;\nfloat lightmap_test;\nfloat roughness;\nfloat metallic;\nfloat occlusion;\n};\nvec4 CCStandardShadingBase (StandardSurface s, vec4 shadowPos) {\nvec3 diffuse = s.albedo.rgb * (1.0 - s.metallic);\nvec3 specular = mix(vec3(0.04), s.albedo.rgb, s.metallic);\nvec3 N = normalize(s.normal);\nvec3 V = normalize(cc_cameraPos.xyz - s.position);\nfloat NV = max(abs(dot(N, V)), 0.0);\nspecular = BRDFApprox(specular, s.roughness, NV);\nvec3 L = normalize(-cc_mainLitDir.xyz);\nvec3 H = normalize(L + V);\nfloat NH = max(dot(N, H), 0.0);\nfloat NL = max(dot(N, L), 0.0);\nvec3 finalColor = NL * cc_mainLitColor.rgb * cc_mainLitColor.w;\nvec3 diffuseContrib = diffuse;\n#if USE_LIGHTMAP && !USE_BATCHING && !CC_FORWARD_ADD\nif (s.lightmap_test > 0.0001) {\nfinalColor = s.lightmap.rgb;\n}\n#else\ndiffuseContrib /= 3.14159265359;\n#endif\nvec3 specularContrib = specular * CalcSpecular(s.roughness, NH, H, N);\nvec3 dirlightContrib = (diffuseContrib + specularContrib);\nfloat shadow = 1.0;\n#if CC_RECEIVE_SHADOW && CC_ENABLE_DIR_SHADOW\nif (NL > 0.0) {\n{\nvec4 pos = ApplyShadowDepthBias_FaceNormal(shadowPos, N);\nfloat pcf = cc_shadowWHPBInfo.z;\nif (pcf > 1.9) shadow = CCGetShadowFactorSoft2X(pos);\nelse if (pcf > 0.9) shadow = CCGetShadowFactorSoft(pos);\nelse shadow = CCGetShadowFactorHard(pos);\nshadow = mix(shadow, 1.0, cc_shadowNFLSInfo.w);\n}\n}\n#endif\ndirlightContrib *= shadow;\nfinalColor *= dirlightContrib;\nfloat fAmb = 0.5 - N.y * 0.5;\nvec3 ambDiff = mix(cc_ambientSky.rgb, cc_ambientGround.rgb, fAmb);\n#if CC_USE_IBL\n#if CC_USE_DIFFUSEMAP\nvec4 diffuseMap = textureCube(cc_diffuseMap, N);\n#if CC_USE_DIFFUSEMAP == 2\nambDiff = unpackRGBE(diffuseMap);\n#else\nambDiff = SRGBToLinear(diffuseMap.rgb);\n#endif\n#endif\nvec3 R = normalize(reflect(-V, N));\n#if USE_REFLECTION_DENOISE\nvec3 env = GetEnvReflectionWithMipFiltering(R, s.roughness, cc_ambientGround.w, 0.6);\n#else\nvec4 envmap = fragTextureLod(cc_environment, R, s.roughness * cc_ambientGround.w);\n#if CC_USE_IBL == 2\nvec3 env = unpackRGBE(envmap);\n#else\nvec3 env = SRGBToLinear(envmap.rgb);\n#endif\n#endif\nfinalColor += env * cc_ambientSky.w * specular * s.occlusion;\n#endif\nfinalColor += ambDiff.rgb * cc_ambientSky.w * diffuse * s.occlusion;\nfinalColor += s.emissive;\nreturn vec4(finalColor, s.albedo.a);\n}\nvec3 ACESToneMap (vec3 color) {\ncolor = min(color, vec3(8.0));\nconst float A = 2.51;\nconst float B = 0.03;\nconst float C = 2.43;\nconst float D = 0.59;\nconst float E = 0.14;\nreturn (color * (A * color + B)) / (color * (C * color + D) + E);\n}\nvec4 CCFragOutput (vec4 color) {\n#if CC_USE_HDR\ncolor.rgb = ACESToneMap(color.rgb);\n#endif\ncolor.rgb = sqrt(color.rgb);\nreturn color;\n}\nvarying highp vec4 v_shadowPos;\n#if USE_LIGHTMAP && !USE_BATCHING && !CC_FORWARD_ADD\nvarying vec3 v_luv;\nuniform sampler2D cc_lightingMap;\nvec3 UnpackLightingmap(vec4 color) {\nvec3 c;\nfloat e = 1.0 + color.a * (8.0 - 1.0);\nc.r = color.r * e;\nc.g = color.g * e;\nc.b = color.b * e;\nreturn c;\n}\n#endif\nvarying vec3 v_position;\nvarying vec2 v_uv;\nvarying vec2 v_uv1;\nvarying vec3 v_normal;\n#if USE_VERTEX_COLOR\nvarying vec4 v_color;\n#endif\n#if USE_ALBEDO_MAP\nuniform sampler2D albedoMap;\n#endif\n#if USE_NORMAL_MAP\nvarying vec3 v_tangent;\nvarying vec3 v_bitangent;\nuniform sampler2D normalMap;\n#endif\n#if USE_PBR_MAP\nuniform sampler2D pbrMap;\n#endif\n#if USE_METALLIC_ROUGHNESS_MAP\nuniform sampler2D metallicRoughnessMap;\n#endif\n#if USE_OCCLUSION_MAP\nuniform sampler2D occlusionMap;\n#endif\n#if USE_EMISSIVE_MAP\nuniform sampler2D emissiveMap;\n#endif\n#if USE_ALPHA_TEST\n#endif\nvoid surf (out StandardSurface s) {\nvec4 baseColor = albedo;\n#if USE_VERTEX_COLOR\nbaseColor.rgb *= SRGBToLinear(v_color.rgb);\nbaseColor.a *= v_color.a;\n#endif\n#if USE_ALBEDO_MAP\nvec4 texColor = texture2D(albedoMap, ALBEDO_UV);\ntexColor.rgb = SRGBToLinear(texColor.rgb);\nbaseColor *= texColor;\n#endif\ns.albedo = baseColor;\ns.albedo.rgb *= albedoScaleAndCutoff.xyz;\n#if USE_ALPHA_TEST\nif (s.albedo.ALPHA_TEST_CHANNEL < albedoScaleAndCutoff.w) discard;\n#endif\n#if USE_LIGHTMAP && !USE_BATCHING && !CC_FORWARD_ADD\nvec4 lightColor = texture2D(cc_lightingMap, v_luv.xy);\ns.lightmap = UnpackLightingmap(lightColor);\ns.lightmap_test = v_luv.z;\n#endif\ns.normal = v_normal;\n#if USE_NORMAL_MAP\nvec3 nmmp = texture2D(normalMap, NORMAL_UV).xyz - vec3(0.5);\ns.normal =\n(nmmp.x * emissiveScaleParam.w) * normalize(v_tangent) +\n(nmmp.y * emissiveScaleParam.w) * normalize(v_bitangent) +\nnmmp.z * normalize(s.normal);\n#endif\ns.position = v_position;\nvec4 pbr = pbrParams;\n#if USE_PBR_MAP\nvec4 res = texture2D(pbrMap, PBR_UV);\npbr.x *= res.r;\npbr.y *= res.g;\npbr.z *= res.b;\npbr.w *= res.a;\n#endif\n#if USE_METALLIC_ROUGHNESS_MAP\nvec4 metallicRoughness = texture2D(metallicRoughnessMap, PBR_UV);\npbr.z *= metallicRoughness.b;\npbr.y *= metallicRoughness.g;\n#endif\n#if USE_OCCLUSION_MAP\npbr.x *= texture2D(occlusionMap, PBR_UV).r;\n#endif\ns.occlusion = pbr.x;\ns.roughness = pbr.y;\ns.metallic = pbr.z;\ns.emissive = emissive.rgb * emissiveScaleParam.xyz;\n#if USE_EMISSIVE_MAP\ns.emissive *= SRGBToLinear(texture2D(emissiveMap, EMISSIVE_UV).rgb);\n#endif\n}\n#if CC_FORWARD_ADD\n#if CC_PIPELINE_TYPE == 0\n# define LIGHTS_PER_PASS 1\n#else\n# define LIGHTS_PER_PASS 10\n#endif\n#if CC_ENABLE_CLUSTERED_LIGHT_CULLING == 0\nuniform highp vec4 cc_lightPos[LIGHTS_PER_PASS];\nuniform vec4 cc_lightColor[LIGHTS_PER_PASS];\nuniform vec4 cc_lightSizeRangeAngle[LIGHTS_PER_PASS];\nuniform vec4 cc_lightDir[LIGHTS_PER_PASS];\n#endif\nfloat SmoothDistAtt (float distSqr, float invSqrAttRadius) {\nfloat factor = distSqr * invSqrAttRadius;\nfloat smoothFactor = clamp(1.0 - factor * factor, 0.0, 1.0);\nreturn smoothFactor * smoothFactor;\n}\nfloat GetDistAtt (float distSqr, float invSqrAttRadius) {\nfloat attenuation = 1.0 / max(distSqr, 0.01*0.01);\nattenuation *= SmoothDistAtt(distSqr , invSqrAttRadius);\nreturn attenuation;\n}\nfloat GetAngleAtt (vec3 L, vec3 litDir, float litAngleScale, float litAngleOffset) {\nfloat cd = dot(litDir, L);\nfloat attenuation = clamp(cd * litAngleScale + litAngleOffset, 0.0, 1.0);\nreturn (attenuation * attenuation);\n}\n#if CC_ENABLE_CLUSTERED_LIGHT_CULLING == 0\nvec4 CCStandardShadingAdditive (StandardSurface s, vec4 shadowPos) {\nvec3 diffuse = s.albedo.rgb * (1.0 - s.metallic);\nvec3 specular = mix(vec3(0.04), s.albedo.rgb, s.metallic);\nvec3 diffuseContrib = diffuse / 3.14159265359;\nvec3 N = normalize(s.normal);\nvec3 V = normalize(cc_cameraPos.xyz - s.position);\nfloat NV = max(abs(dot(N, V)), 0.0);\nspecular = BRDFApprox(specular, s.roughness, NV);\nvec3 finalColor = vec3(0.0);\nint numLights = CC_PIPELINE_TYPE == 0 ? LIGHTS_PER_PASS : int(cc_lightDir[0].w);\nfor (int i = 0; i < LIGHTS_PER_PASS; i++) {\nif (i >= numLights) break;\nvec3 SLU = cc_lightPos[i].xyz - s.position;\nvec3 SL = normalize(SLU);\nvec3 SH = normalize(SL + V);\nfloat SNL = max(dot(N, SL), 0.0);\nfloat SNH = max(dot(N, SH), 0.0);\nfloat distSqr = dot(SLU, SLU);\nfloat litRadius = cc_lightSizeRangeAngle[i].x;\nfloat litRadiusSqr = litRadius * litRadius;\nfloat illum = 3.14159265359 * (litRadiusSqr / max(litRadiusSqr , distSqr));\nfloat attRadiusSqrInv = 1.0 / max(cc_lightSizeRangeAngle[i].y, 0.01);\nattRadiusSqrInv *= attRadiusSqrInv;\nfloat att = GetDistAtt(distSqr, attRadiusSqrInv);\nvec3 lspec = specular * CalcSpecular(s.roughness, SNH, SH, N);\nif (cc_lightPos[i].w > 0.0) {\nfloat cosInner = max(dot(-cc_lightDir[i].xyz, SL), 0.01);\nfloat cosOuter = cc_lightSizeRangeAngle[i].z;\nfloat litAngleScale = 1.0 / max(0.001, cosInner - cosOuter);\nfloat litAngleOffset = -cosOuter * litAngleScale;\natt *= GetAngleAtt(SL, -cc_lightDir[i].xyz, litAngleScale, litAngleOffset);\n}\nvec3 lightColor = cc_lightColor[i].rgb;\nfloat shadow = 1.0;\n#if CC_RECEIVE_SHADOW\nif (cc_lightPos[i].w > 0.0 && cc_lightSizeRangeAngle[i].w > 0.0) {\n{\nfloat pcf = cc_shadowWHPBInfo.z;\nif (pcf > 1.9) shadow = CCGetSpotLightShadowFactorSoft2X(shadowPos, s.position);\nelse if (pcf > 0.9) shadow = CCGetSpotLightShadowFactorSoft(shadowPos, s.position);\nelse shadow = CCGetSpotLightShadowFactorHard(shadowPos, s.position);\n}\n}\n#endif\nlightColor *= shadow;\nfinalColor += SNL * lightColor * cc_lightColor[i].w * illum * att * (diffuseContrib + lspec);\n}\nreturn vec4(finalColor, 0.0);\n}\n#endif\n#if CC_ENABLE_CLUSTERED_LIGHT_CULLING == 1\nreadonly buffer b_ccLightsBuffer { vec4 b_ccLights[]; };\nreadonly buffer b_clusterLightIndicesBuffer { uint b_clusterLightIndices[]; };\nreadonly buffer b_clusterLightGridBuffer { uvec4 b_clusterLightGrid[]; };\nstruct CCLight\n{\nvec4 cc_lightPos;\nvec4 cc_lightColor;\nvec4 cc_lightSizeRangeAngle;\nvec4 cc_lightDir;\n};\nstruct Cluster\n{\nvec3 minBounds;\nvec3 maxBounds;\n};\nstruct LightGrid\n{\nuint offset;\nuint ccLights;\n};\nCCLight getCCLight(uint i)\n{\nCCLight light;\nlight.cc_lightPos = b_ccLights[4u * i + 0u];\nlight.cc_lightColor = b_ccLights[4u * i + 1u];\nlight.cc_lightSizeRangeAngle = b_ccLights[4u * i + 2u];\nlight.cc_lightDir = b_ccLights[4u * i + 3u];\nreturn light;\n}\nLightGrid getLightGrid(uint cluster)\n{\nuvec4 gridvec = b_clusterLightGrid[cluster];\nLightGrid grid;\ngrid.offset = gridvec.x;\ngrid.ccLights = gridvec.y;\nreturn grid;\n}\nuint getGridLightIndex(uint start, uint offset)\n{\nreturn b_clusterLightIndices[start + offset];\n}\nuint getClusterZIndex(vec4 worldPos)\n{\nfloat scale = float(24) / log(cc_nearFar.y / cc_nearFar.x);\nfloat bias = -(float(24) * log(cc_nearFar.x) / log(cc_nearFar.y / cc_nearFar.x));\nfloat eyeDepth = -(cc_matView * worldPos).z;\nuint zIndex = uint(max(log(eyeDepth) * scale + bias, 0.0));\nreturn zIndex;\n}\nuint getClusterIndex(vec4 fragCoord, vec4 worldPos)\n{\nuint zIndex = getClusterZIndex(worldPos);\nfloat clusterSizeX = ceil(cc_screenSize.x / float(16));\nfloat clusterSizeY = ceil(cc_screenSize.y / float(8));\nuvec3 indices = uvec3(uvec2(fragCoord.xy / vec2(clusterSizeX, clusterSizeY)), zIndex);\nuint cluster = (16u * 8u) * indices.z + 16u * indices.y + indices.x;\nreturn cluster;\n}\nvec4 CCClusterShadingAdditive (StandardSurface s, vec4 shadowPos) {\nvec3 diffuse = s.albedo.rgb * (1.0 - s.metallic);\nvec3 specular = mix(vec3(0.04), s.albedo.rgb, s.metallic);\nvec3 diffuseContrib = diffuse / 3.14159265359;\nvec3 N = normalize(s.normal);\nvec3 V = normalize(cc_cameraPos.xyz - s.position);\nfloat NV = max(abs(dot(N, V)), 0.001);\nspecular = BRDFApprox(specular, s.roughness, NV);\nvec3 finalColor = vec3(0.0);\nuint cluster = getClusterIndex(gl_FragCoord, vec4(s.position, 1.0));\nLightGrid grid = getLightGrid(cluster);\nuint numLights = grid.ccLights;\nfor (uint i = 0u; i < 100u; i++) {\nif (i >= numLights) break;\nuint lightIndex = getGridLightIndex(grid.offset, i);\nCCLight light = getCCLight(lightIndex);\nvec3 SLU = light.cc_lightPos.xyz - s.position;\nvec3 SL = normalize(SLU);\nvec3 SH = normalize(SL + V);\nfloat SNL = max(dot(N, SL), 0.001);\nfloat SNH = max(dot(N, SH), 0.0);\nfloat distSqr = dot(SLU, SLU);\nfloat litRadius = light.cc_lightSizeRangeAngle.x;\nfloat litRadiusSqr = litRadius * litRadius;\nfloat illum = 3.14159265359 * (litRadiusSqr / max(litRadiusSqr , distSqr));\nfloat attRadiusSqrInv = 1.0 / max(light.cc_lightSizeRangeAngle.y, 0.01);\nattRadiusSqrInv *= attRadiusSqrInv;\nfloat att = GetDistAtt(distSqr, attRadiusSqrInv);\nvec3 lspec = specular * CalcSpecular(s.roughness, SNH, SH, N);\nif (light.cc_lightPos.w > 0.0) {\nfloat cosInner = max(dot(-light.cc_lightDir.xyz, SL), 0.01);\nfloat cosOuter = light.cc_lightSizeRangeAngle.z;\nfloat litAngleScale = 1.0 / max(0.001, cosInner - cosOuter);\nfloat litAngleOffset = -cosOuter * litAngleScale;\natt *= GetAngleAtt(SL, -light.cc_lightDir.xyz, litAngleScale, litAngleOffset);\n}\nvec3 lightColor = light.cc_lightColor.rgb;\nfloat shadow = 1.0;\n#if CC_RECEIVE_SHADOW\nif (light.cc_lightPos.w > 0.0) {\n{\nfloat pcf = cc_shadowWHPBInfo.z;\nif (pcf > 1.9) shadow = CCGetSpotLightShadowFactorSoft2X(shadowPos, s.position);\nelse if (pcf > 0.9) shadow = CCGetSpotLightShadowFactorSoft(shadowPos, s.position);\nelse shadow = CCGetSpotLightShadowFactorHard(shadowPos, s.position);\n}\n}\n#endif\nlightColor *= shadow;\nfinalColor += SNL * lightColor * light.cc_lightColor.w * illum * att * (diffuseContrib + lspec);\n}\nreturn vec4(finalColor, 0.0);\n}\n#endif\nvoid main () {\nStandardSurface s; surf(s);\n#if CC_ENABLE_CLUSTERED_LIGHT_CULLING == 1\nvec4 color = CCClusterShadingAdditive(s, v_shadowPos);\n#else\nvec4 color = CCStandardShadingAdditive(s, v_shadowPos);\n#endif\nCC_APPLY_FOG(color, s.position.xyz);\ngl_FragData[0] = CCFragOutput(color);\n}\n#elif (CC_PIPELINE_TYPE == 0 || CC_FORCE_FORWARD_SHADING)\nvoid main () {\nStandardSurface s; surf(s);\nvec4 color = CCStandardShadingBase(s, v_shadowPos);\nCC_APPLY_FOG(color, s.position.xyz);\ngl_FragData[0] = CCFragOutput(color);\n}\n#elif CC_PIPELINE_TYPE == 1\nvoid main () {\nStandardSurface s; surf(s);\ngl_FragData[0] = s.albedo;\ngl_FragData[1] = vec4(s.position, s.roughness);\ngl_FragData[2] = vec4(s.normal, s.metallic);\ngl_FragData[3] = vec4(s.emissive, s.occlusion);\n}\n#endif", + }, + { + "vert": "\nprecision highp float;\nhighp float decode32 (highp vec4 rgba) {\nrgba = rgba * 255.0;\nhighp float Sign = 1.0 - (step(128.0, (rgba[3]) + 0.5)) * 2.0;\nhighp float Exponent = 2.0 * (mod(float(int((rgba[3]) + 0.5)), 128.0)) + (step(128.0, (rgba[2]) + 0.5)) - 127.0;\nhighp float Mantissa = (mod(float(int((rgba[2]) + 0.5)), 128.0)) * 65536.0 + rgba[1] * 256.0 + rgba[0] + 8388608.0;\nreturn Sign * exp2(Exponent - 23.0) * Mantissa;\n}\nstruct StandardVertInput {\nhighp vec4 position;\nvec3 normal;\nvec4 tangent;\n};\nattribute vec3 a_position;\nattribute vec3 a_normal;\nattribute vec2 a_texCoord;\nattribute vec4 a_tangent;\n#if CC_USE_MORPH\nattribute float a_vertexId;\nint getVertexId() {\nreturn int(a_vertexId);\n}\nuniform vec4 cc_displacementWeights[15];\nuniform vec4 cc_displacementTextureInfo;\nvec2 getPixelLocation(vec2 textureResolution, int pixelIndex) {\nfloat pixelIndexF = float(pixelIndex);\nfloat x = mod(pixelIndexF, textureResolution.x);\nfloat y = floor(pixelIndexF / textureResolution.x);\nreturn vec2(x, y);\n}\nvec2 getPixelCoordFromLocation(vec2 location, vec2 textureResolution) {\nreturn (vec2(location.x, location.y) + .5) / textureResolution;\n}\n#if CC_DEVICE_SUPPORT_FLOAT_TEXTURE\nvec4 fetchVec3ArrayFromTexture(sampler2D tex, int elementIndex) {\nint pixelIndex = elementIndex;\nvec2 location = getPixelLocation(cc_displacementTextureInfo.xy, pixelIndex);\nvec2 uv = getPixelCoordFromLocation(location, cc_displacementTextureInfo.xy);\nreturn texture2D(tex, uv);\n}\n#else\nvec4 fetchVec3ArrayFromTexture(sampler2D tex, int elementIndex) {\nint pixelIndex = elementIndex * 4;\nvec2 location = getPixelLocation(cc_displacementTextureInfo.xy, pixelIndex);\nvec2 x = getPixelCoordFromLocation(location + vec2(0.0, 0.0), cc_displacementTextureInfo.xy);\nvec2 y = getPixelCoordFromLocation(location + vec2(1.0, 0.0), cc_displacementTextureInfo.xy);\nvec2 z = getPixelCoordFromLocation(location + vec2(2.0, 0.0), cc_displacementTextureInfo.xy);\nreturn vec4(\ndecode32(texture2D(tex, x)),\ndecode32(texture2D(tex, y)),\ndecode32(texture2D(tex, z)),\n1.0\n);\n}\n#endif\nfloat getDisplacementWeight(int index) {\nint quot = index / 4;\nint remainder = index - quot * 4;\nif (remainder == 0) {\nreturn cc_displacementWeights[quot].x;\n} else if (remainder == 1) {\nreturn cc_displacementWeights[quot].y;\n} else if (remainder == 2) {\nreturn cc_displacementWeights[quot].z;\n} else {\nreturn cc_displacementWeights[quot].w;\n}\n}\nvec3 getVec3DisplacementFromTexture(sampler2D tex, int vertexIndex) {\n#if CC_MORPH_PRECOMPUTED\nreturn fetchVec3ArrayFromTexture(tex, vertexIndex).rgb;\n#else\nvec3 result = vec3(0, 0, 0);\nint nVertices = int(cc_displacementTextureInfo.z);\nfor (int iTarget = 0; iTarget < CC_MORPH_TARGET_COUNT; ++iTarget) {\nresult += (fetchVec3ArrayFromTexture(tex, nVertices * iTarget + vertexIndex).rgb * getDisplacementWeight(iTarget));\n}\nreturn result;\n#endif\n}\n#if CC_MORPH_TARGET_HAS_POSITION\nuniform sampler2D cc_PositionDisplacements;\nvec3 getPositionDisplacement(int vertexId) {\nreturn getVec3DisplacementFromTexture(cc_PositionDisplacements, vertexId);\n}\n#endif\n#if CC_MORPH_TARGET_HAS_NORMAL\nuniform sampler2D cc_NormalDisplacements;\nvec3 getNormalDisplacement(int vertexId) {\nreturn getVec3DisplacementFromTexture(cc_NormalDisplacements, vertexId);\n}\n#endif\n#if CC_MORPH_TARGET_HAS_TANGENT\nuniform sampler2D cc_TangentDisplacements;\nvec3 getTangentDisplacement(int vertexId) {\nreturn getVec3DisplacementFromTexture(cc_TangentDisplacements, vertexId);\n}\n#endif\nvoid applyMorph (inout StandardVertInput attr) {\nint vertexId = getVertexId();\n#if CC_MORPH_TARGET_HAS_POSITION\nattr.position.xyz = attr.position.xyz + getPositionDisplacement(vertexId);\n#endif\n#if CC_MORPH_TARGET_HAS_NORMAL\nattr.normal.xyz = attr.normal.xyz + getNormalDisplacement(vertexId);\n#endif\n#if CC_MORPH_TARGET_HAS_TANGENT\nattr.tangent.xyz = attr.tangent.xyz + getTangentDisplacement(vertexId);\n#endif\n}\nvoid applyMorph (inout vec4 position) {\n#if CC_MORPH_TARGET_HAS_POSITION\nposition.xyz = position.xyz + getPositionDisplacement(getVertexId());\n#endif\n}\n#endif\n#if CC_USE_SKINNING\nattribute vec4 a_joints;\nattribute vec4 a_weights;\n#if CC_USE_BAKED_ANIMATION\n#if USE_INSTANCING\nattribute highp vec4 a_jointAnimInfo;\n#endif\nuniform highp vec4 cc_jointTextureInfo;\nuniform highp vec4 cc_jointAnimInfo;\nuniform highp sampler2D cc_jointTexture;\n#else\nuniform highp vec4 cc_joints[90];\n#endif\n#if CC_USE_BAKED_ANIMATION\n#if CC_DEVICE_SUPPORT_FLOAT_TEXTURE\nmat4 getJointMatrix (float i) {\n#if USE_INSTANCING\nhighp float j = 3.0 * (a_jointAnimInfo.x * a_jointAnimInfo.y + i) + a_jointAnimInfo.z;\n#else\nhighp float j = 3.0 * (cc_jointAnimInfo.x * cc_jointTextureInfo.y + i) + cc_jointTextureInfo.z;\n#endif\nhighp float invSize = cc_jointTextureInfo.w;\nhighp float y = floor(j * invSize);\nhighp float x = floor(j - y * cc_jointTextureInfo.x);\ny = (y + 0.5) * invSize;\nvec4 v1 = texture2D(cc_jointTexture, vec2((x + 0.5) * invSize, y));\nvec4 v2 = texture2D(cc_jointTexture, vec2((x + 1.5) * invSize, y));\nvec4 v3 = texture2D(cc_jointTexture, vec2((x + 2.5) * invSize, y));\nreturn mat4(vec4(v1.xyz, 0.0), vec4(v2.xyz, 0.0), vec4(v3.xyz, 0.0), vec4(v1.w, v2.w, v3.w, 1.0));\n}\n#else\nmat4 getJointMatrix (float i) {\n#if USE_INSTANCING\nhighp float j = 12.0 * (a_jointAnimInfo.x * a_jointAnimInfo.y + i) + a_jointAnimInfo.z;\n#else\nhighp float j = 12.0 * (cc_jointAnimInfo.x * cc_jointTextureInfo.y + i) + cc_jointTextureInfo.z;\n#endif\nhighp float invSize = cc_jointTextureInfo.w;\nhighp float y = floor(j * invSize);\nhighp float x = floor(j - y * cc_jointTextureInfo.x);\ny = (y + 0.5) * invSize;\nvec4 v1 = vec4(\ndecode32(texture2D(cc_jointTexture, vec2((x + 0.5) * invSize, y))),\ndecode32(texture2D(cc_jointTexture, vec2((x + 1.5) * invSize, y))),\ndecode32(texture2D(cc_jointTexture, vec2((x + 2.5) * invSize, y))),\ndecode32(texture2D(cc_jointTexture, vec2((x + 3.5) * invSize, y)))\n);\nvec4 v2 = vec4(\ndecode32(texture2D(cc_jointTexture, vec2((x + 4.5) * invSize, y))),\ndecode32(texture2D(cc_jointTexture, vec2((x + 5.5) * invSize, y))),\ndecode32(texture2D(cc_jointTexture, vec2((x + 6.5) * invSize, y))),\ndecode32(texture2D(cc_jointTexture, vec2((x + 7.5) * invSize, y)))\n);\nvec4 v3 = vec4(\ndecode32(texture2D(cc_jointTexture, vec2((x + 8.5) * invSize, y))),\ndecode32(texture2D(cc_jointTexture, vec2((x + 9.5) * invSize, y))),\ndecode32(texture2D(cc_jointTexture, vec2((x + 10.5) * invSize, y))),\ndecode32(texture2D(cc_jointTexture, vec2((x + 11.5) * invSize, y)))\n);\nreturn mat4(vec4(v1.xyz, 0.0), vec4(v2.xyz, 0.0), vec4(v3.xyz, 0.0), vec4(v1.w, v2.w, v3.w, 1.0));\n}\n#endif\n#else\nmat4 getJointMatrix (float i) {\nint idx = int(i);\nvec4 v1 = cc_joints[idx * 3];\nvec4 v2 = cc_joints[idx * 3 + 1];\nvec4 v3 = cc_joints[idx * 3 + 2];\nreturn mat4(vec4(v1.xyz, 0.0), vec4(v2.xyz, 0.0), vec4(v3.xyz, 0.0), vec4(v1.w, v2.w, v3.w, 1.0));\n}\n#endif\nmat4 skinMatrix () {\nvec4 joints = vec4(a_joints);\nreturn getJointMatrix(joints.x) * a_weights.x\n+ getJointMatrix(joints.y) * a_weights.y\n+ getJointMatrix(joints.z) * a_weights.z\n+ getJointMatrix(joints.w) * a_weights.w;\n}\nvoid CCSkin (inout vec4 position) {\nmat4 m = skinMatrix();\nposition = m * position;\n}\nvoid CCSkin (inout StandardVertInput attr) {\nmat4 m = skinMatrix();\nattr.position = m * attr.position;\nattr.normal = (m * vec4(attr.normal, 0.0)).xyz;\nattr.tangent.xyz = (m * vec4(attr.tangent.xyz, 0.0)).xyz;\n}\n#endif\n#if USE_INSTANCING\nattribute vec4 a_matWorld0;\nattribute vec4 a_matWorld1;\nattribute vec4 a_matWorld2;\n#if USE_LIGHTMAP\nattribute vec4 a_lightingMapUVParam;\n#endif\n#elif USE_BATCHING\nattribute float a_dyn_batch_id;\nuniform highp mat4 cc_matWorlds[10];\n#else\nuniform highp mat4 cc_matWorld;\nuniform highp mat4 cc_matWorldIT;\n#endif\nuniform vec4 tilingOffset;\nuniform highp mat4 cc_matLightViewProj;\n#if HAS_SECOND_UV || USE_LIGHTMAP\nattribute vec2 a_texCoord1;\n#endif\nvarying vec2 v_uv;\nvarying vec2 v_uv1;\nvarying vec4 v_worldPos;\nvarying float v_clip_depth;\nvec4 vert () {\nStandardVertInput In;\nIn.position = vec4(a_position, 1.0);\nIn.normal = a_normal;\nIn.tangent = a_tangent;\n#if CC_USE_MORPH\napplyMorph(In);\n#endif\n#if CC_USE_SKINNING\nCCSkin(In);\n#endif\nmat4 matWorld, matWorldIT;\n#if USE_INSTANCING\nmatWorld = mat4(\nvec4(a_matWorld0.xyz, 0.0),\nvec4(a_matWorld1.xyz, 0.0),\nvec4(a_matWorld2.xyz, 0.0),\nvec4(a_matWorld0.w, a_matWorld1.w, a_matWorld2.w, 1.0)\n);\nmatWorldIT = matWorld;\n#elif USE_BATCHING\nmatWorld = cc_matWorlds[int(a_dyn_batch_id)];\nmatWorldIT = matWorld;\n#else\nmatWorld = cc_matWorld;\nmatWorldIT = cc_matWorldIT;\n#endif\nv_worldPos = matWorld * In.position;\nvec4 clipPos = cc_matLightViewProj * v_worldPos;\nv_uv = a_texCoord * tilingOffset.xy + tilingOffset.zw;\n#if HAS_SECOND_UV\nv_uv1 = a_texCoord1 * tilingOffset.xy + tilingOffset.zw;\n#endif\nv_clip_depth = clipPos.z / clipPos.w * 0.5 + 0.5;\nreturn clipPos;\n}\nvoid main() { gl_Position = vert(); }", + "frag": "\nprecision highp float;\nuniform vec4 albedo;\nuniform vec4 albedoScaleAndCutoff;\nvec4 packDepthToRGBA (float depth) {\nvec4 ret = vec4(1.0, 255.0, 65025.0, 16581375.0) * depth;\nret = fract(ret);\nret -= vec4(ret.yzw, 0.0) / 255.0;\nreturn ret;\n}\nuniform highp mat4 cc_matLightView;\nuniform lowp vec4 cc_shadowNFLSInfo;\nuniform lowp vec4 cc_shadowLPNNInfo;\nfloat CCGetLinearDepthFromViewSpace(vec3 viewPos) {\nfloat dist = length(viewPos);\nreturn (dist - cc_shadowNFLSInfo.x) / (cc_shadowNFLSInfo.y - cc_shadowNFLSInfo.x);\n}\nfloat CCGetLinearDepth(vec3 worldPos) {\nvec4 viewStartPos = cc_matLightView * vec4(worldPos.xyz, 1.0);\nreturn CCGetLinearDepthFromViewSpace(viewStartPos.xyz);\n}\n#if CC_RECEIVE_SHADOW\nuniform highp sampler2D cc_shadowMap;\nuniform highp sampler2D cc_spotLightingMap;\n#endif\nvarying vec2 v_uv;\nvarying vec2 v_uv1;\nvarying vec4 v_worldPos;\nvarying float v_clip_depth;\n#if USE_ALBEDO_MAP\nuniform sampler2D albedoMap;\n#endif\n#if USE_ALPHA_TEST\n#endif\nvec4 frag () {\nvec4 baseColor = albedo;\n#if USE_ALBEDO_MAP\nbaseColor *= texture2D(albedoMap, ALBEDO_UV);\n#endif\n#if USE_ALPHA_TEST\nif (baseColor.ALPHA_TEST_CHANNEL < albedoScaleAndCutoff.w) discard;\n#endif\nif(cc_shadowLPNNInfo.x > 0.000001 && cc_shadowLPNNInfo.x < 1.999999) {\nif (cc_shadowNFLSInfo.z > 0.000001) {\nreturn vec4(CCGetLinearDepth(v_worldPos.xyz), 1.0, 1.0, 1.0);\n}\n}\nif (cc_shadowLPNNInfo.y > 0.000001) {\nreturn packDepthToRGBA(v_clip_depth);\n}\nreturn vec4(v_clip_depth, 1.0, 1.0, 1.0);\n}\nvoid main() { gl_FragColor = frag(); }", + } + ], + [ + { + "vert": "\nprecision mediump float;\nuniform highp mat4 cc_matViewProj;\nuniform highp vec4 cc_cameraPos;\nuniform mediump vec4 cc_fogBase;\nuniform mediump vec4 cc_fogAdd;\nuniform highp mat4 cc_matWorld;\nfloat LinearFog(vec4 pos) {\nvec4 wPos = pos;\nfloat cam_dis = distance(cc_cameraPos, wPos);\nfloat fogStart = cc_fogBase.x;\nfloat fogEnd = cc_fogBase.y;\nreturn clamp((fogEnd - cam_dis) / (fogEnd - fogStart), 0., 1.);\n}\nfloat ExpFog(vec4 pos) {\nvec4 wPos = pos;\nfloat fogAtten = cc_fogAdd.z;\nfloat fogStart = cc_fogBase.x;\nfloat fogDensity = cc_fogBase.z;\nfloat cam_dis = max(distance(cc_cameraPos, wPos) - fogStart, 0.0) / fogAtten * 4.;\nfloat f = exp(-cam_dis * fogDensity);\nreturn f;\n}\nfloat ExpSquaredFog(vec4 pos) {\nvec4 wPos = pos;\nfloat fogAtten = cc_fogAdd.z;\nfloat fogStart = cc_fogBase.x;\nfloat fogDensity = cc_fogBase.z;\nfloat cam_dis = max(distance(cc_cameraPos, wPos) - fogStart, 0.0) / fogAtten * 4.;\nfloat f = exp(-cam_dis * cam_dis * fogDensity * fogDensity);\nreturn f;\n}\nfloat LayeredFog(vec4 pos) {\nvec4 wPos = pos;\nfloat fogAtten = cc_fogAdd.z;\nfloat _FogTop = cc_fogAdd.x;\nfloat _FogRange = cc_fogAdd.y;\nvec3 camWorldProj = cc_cameraPos.xyz;\ncamWorldProj.y = 0.;\nvec3 worldPosProj = wPos.xyz;\nworldPosProj.y = 0.;\nfloat fDeltaD = distance(worldPosProj, camWorldProj) / fogAtten * 2.0;\nfloat fDeltaY, fDensityIntegral;\nif (cc_cameraPos.y > _FogTop) {\nif (wPos.y < _FogTop) {\nfDeltaY = (_FogTop - wPos.y) / _FogRange * 2.0;\nfDensityIntegral = fDeltaY * fDeltaY * 0.5;\n} else {\nfDeltaY = 0.;\nfDensityIntegral = 0.;\n}\n} else {\nif (wPos.y < _FogTop) {\nfloat fDeltaA = (_FogTop - cc_cameraPos.y) / _FogRange * 2.;\nfloat fDeltaB = (_FogTop - wPos.y) / _FogRange * 2.;\nfDeltaY = abs(fDeltaA - fDeltaB);\nfDensityIntegral = abs((fDeltaA * fDeltaA * 0.5) - (fDeltaB * fDeltaB * 0.5));\n} else {\nfDeltaY = abs(_FogTop - cc_cameraPos.y) / _FogRange * 2.;\nfDensityIntegral = abs(fDeltaY * fDeltaY * 0.5);\n}\n}\nfloat fDensity;\nif (fDeltaY != 0.) {\nfDensity = (sqrt(1.0 + ((fDeltaD / fDeltaY) * (fDeltaD / fDeltaY)))) * fDensityIntegral;\n} else {\nfDensity = 0.;\n}\nfloat f = exp(-fDensity);\nreturn f;\n}\nvoid CC_TRANSFER_FOG_BASE(vec4 pos, out float factor)\n{\n#if CC_USE_FOG == 0\nfactor = LinearFog(pos);\n#elif CC_USE_FOG == 1\nfactor = ExpFog(pos);\n#elif CC_USE_FOG == 2\nfactor = ExpSquaredFog(pos);\n#elif CC_USE_FOG == 3\nfactor = LayeredFog(pos);\n#else\nfactor = 1.0;\n#endif\n}\n#if !CC_USE_ACCURATE_FOG\nvarying float v_fog_factor;\n#endif\nvoid CC_TRANSFER_FOG(vec4 pos) {\n#if !CC_USE_ACCURATE_FOG\nCC_TRANSFER_FOG_BASE(pos, v_fog_factor);\n#endif\n}\nvarying highp vec4 v_shadowPos;\nuniform highp mat4 cc_matLightViewProj;\n#if CC_RECEIVE_SHADOW\nuniform highp sampler2D cc_shadowMap;\nuniform highp sampler2D cc_spotLightingMap;\n#endif\nattribute vec3 a_position;\nattribute vec3 a_normal;\nattribute vec2 a_texCoord;\nvarying highp vec3 v_position;\nvarying mediump vec3 v_normal;\n#if USE_NORMALMAP\nvarying mediump vec3 v_tangent;\nvarying mediump vec3 v_binormal;\n#endif\nvarying mediump vec2 uvw;\nvarying mediump vec2 uv0;\nvarying mediump vec2 uv1;\nvarying mediump vec2 uv2;\nvarying mediump vec2 uv3;\nvarying mediump vec3 luv;\nvarying mediump vec3 diffuse;\nuniform vec4 UVScale;\nuniform vec4 lightMapUVParam;\nvoid main () {\nvec3 worldPos;\nworldPos.x = cc_matWorld[3][0] + a_position.x;\nworldPos.y = cc_matWorld[3][1] + a_position.y;\nworldPos.z = cc_matWorld[3][2] + a_position.z;\nvec4 pos = vec4(worldPos, 1.0);\npos = cc_matViewProj * pos;\nuvw = a_texCoord;\nuv0 = a_position.xz * UVScale.x;\nuv1 = a_position.xz * UVScale.y;\nuv2 = a_position.xz * UVScale.z;\nuv3 = a_position.xz * UVScale.w;\n#if USE_LIGHTMAP\nluv.xy = lightMapUVParam.xy + a_texCoord * lightMapUVParam.zw;\nluv.z = lightMapUVParam.z;\n#endif\nv_position = worldPos;\nv_normal = a_normal;\nCC_TRANSFER_FOG(vec4(worldPos, 1.0));\n#if USE_NORMALMAP\nv_tangent = vec3(1.0, 0.0, 0.0);\nv_binormal = vec3(0.0, 0.0, 1.0);\nv_binormal = cross(v_tangent, a_normal);\nv_tangent = cross(a_normal, v_binormal);\n#endif\nv_shadowPos = cc_matLightViewProj * vec4(worldPos, 1.0);\ngl_Position = pos;\n}", + "frag": "\n#ifdef GL_EXT_draw_buffers\n#extension GL_EXT_draw_buffers: enable\n#endif\n#ifdef GL_EXT_shader_texture_lod\n#extension GL_EXT_shader_texture_lod: enable\n#endif\nprecision highp float;\nuniform mediump vec4 cc_screenSize;\nuniform highp mat4 cc_matView;\nuniform highp vec4 cc_cameraPos;\nuniform mediump vec4 cc_mainLitDir;\nuniform mediump vec4 cc_mainLitColor;\nuniform mediump vec4 cc_ambientSky;\nuniform mediump vec4 cc_ambientGround;\nuniform mediump vec4 cc_fogColor;\nuniform mediump vec4 cc_fogBase;\nuniform mediump vec4 cc_fogAdd;\nuniform mediump vec4 cc_nearFar;\nvec3 SRGBToLinear (vec3 gamma) {\nreturn gamma * gamma;\n}\nuniform highp mat4 cc_matLightView;\nuniform highp vec4 cc_shadowInvProjDepthInfo;\nuniform highp vec4 cc_shadowProjDepthInfo;\nuniform highp vec4 cc_shadowProjInfo;\nuniform lowp vec4 cc_shadowNFLSInfo;\nuniform lowp vec4 cc_shadowWHPBInfo;\nuniform lowp vec4 cc_shadowLPNNInfo;\nfloat CCGetLinearDepthFromViewSpace(vec3 viewPos) {\nfloat dist = length(viewPos);\nreturn (dist - cc_shadowNFLSInfo.x) / (cc_shadowNFLSInfo.y - cc_shadowNFLSInfo.x);\n}\nfloat CCGetLinearDepth(vec3 worldPos) {\nvec4 viewStartPos = cc_matLightView * vec4(worldPos.xyz, 1.0);\nreturn CCGetLinearDepthFromViewSpace(viewStartPos.xyz);\n}\n#if CC_RECEIVE_SHADOW\nuniform highp sampler2D cc_shadowMap;\nuniform highp sampler2D cc_spotLightingMap;\nvec4 ApplyShadowDepthBias_FaceNormal(vec4 shadowPos, vec3 worldNormal)\n{\nvec4 newShadowPos = shadowPos;\nif(cc_shadowLPNNInfo.z > 0.0001)\n{\nvec4 viewNormal = cc_matLightView * vec4(worldNormal, 0.0);\nif(viewNormal.z < 0.1)\nnewShadowPos.xy += viewNormal.xy * cc_shadowProjInfo.xy * cc_shadowLPNNInfo.z * clamp(viewNormal.z, 0.001, 0.1);\n}\nreturn newShadowPos;\n}\nvec4 ApplyShadowDepthBias_Perspective(vec4 shadowPos, float viewspaceDepthBias)\n{\nvec3 viewSpacePos;\nviewSpacePos.xy = shadowPos.xy * cc_shadowProjInfo.zw;\nviewSpacePos.z = shadowPos.z * cc_shadowInvProjDepthInfo.x + shadowPos.w * cc_shadowInvProjDepthInfo.y;\nviewSpacePos.xyz += cc_shadowProjDepthInfo.z * normalize(viewSpacePos.xyz) * viewspaceDepthBias;\nvec4 clipSpacePos;\nclipSpacePos.xy = viewSpacePos.xy * cc_shadowProjInfo.xy;\nclipSpacePos.zw = viewSpacePos.z * cc_shadowProjDepthInfo.xz + vec2(cc_shadowProjDepthInfo.y, 0.0);\nif (cc_shadowNFLSInfo.z > 0.000001) {\nclipSpacePos.z = CCGetLinearDepthFromViewSpace(viewSpacePos.xyz);\nclipSpacePos.z = (clipSpacePos.z * 2.0 - 1.0) * clipSpacePos.w;\n}\nreturn clipSpacePos;\n}\nvec4 ApplyShadowDepthBias_Orthographic(vec4 shadowPos, float viewspaceDepthBias)\n{\nfloat coeffA = cc_shadowProjDepthInfo.x;\nfloat coeffB = cc_shadowProjDepthInfo.y;\nfloat viewSpacePos_z = (shadowPos.z - coeffB) / coeffA;\nviewSpacePos_z += viewspaceDepthBias;\nvec4 result = shadowPos;\nresult.z = viewSpacePos_z * coeffA + coeffB;\nreturn result;\n}\nfloat CCGetShadowFactorHard (vec4 shadowPos) {\nvec4 clipPosNew = ApplyShadowDepthBias_Orthographic(shadowPos, cc_shadowWHPBInfo.w);\nvec3 clipPos = clipPosNew.xyz / clipPosNew.w * 0.5 + 0.5;\nif (clipPos.x < 0.0 || clipPos.x > 1.0 ||\nclipPos.y < 0.0 || clipPos.y > 1.0 ||\nclipPos.z < 0.0 || clipPos.z > 1.0) { return 1.0; }\nclipPos.xy = cc_cameraPos.w == 1.0 ? vec2(clipPos.xy.x, 1.0 - clipPos.xy.y) : clipPos.xy;\nfloat shadow = 0.0;\nfloat closestDepth = 0.0;\nif (cc_shadowLPNNInfo.y > 0.000001) {\nclosestDepth = dot(texture2D(cc_shadowMap, clipPos.xy), vec4(1.0, 1.0 / 255.0, 1.0 / 65025.0, 1.0 / 16581375.0));\n} else {\nclosestDepth = texture2D(cc_shadowMap, clipPos.xy).x;\n}\nshadow = step(clipPos.z, closestDepth);\nreturn shadow;\n}\nfloat CCGetShadowFactorSoft (vec4 shadowPos) {\nvec4 clipPosNew = ApplyShadowDepthBias_Orthographic(shadowPos, cc_shadowWHPBInfo.w);\nvec3 clipPos = clipPosNew.xyz / clipPosNew.w * 0.5 + 0.5;\nif (clipPos.x < 0.0 || clipPos.x > 1.0 ||\nclipPos.y < 0.0 || clipPos.y > 1.0 ||\nclipPos.z < 0.0 || clipPos.z > 1.0) { return 1.0; }\nclipPos.xy = cc_cameraPos.w == 1.0 ? vec2(clipPos.xy.x, 1.0 - clipPos.xy.y) : clipPos.xy;\nfloat offsetDepth = clipPos.z;\nvec2 mapSize = cc_shadowWHPBInfo.xy;\nvec2 oneTap = 1.0 / mapSize;\nvec2 clipPos_offset = clipPos.xy + oneTap;\nfloat block0, block1, block2, block3;\nif (cc_shadowLPNNInfo.y > 0.000001) {\nblock0 = step(offsetDepth, dot(texture2D(cc_shadowMap, vec2(clipPos.x, clipPos.y)), vec4(1.0, 1.0 / 255.0, 1.0 / 65025.0, 1.0 / 16581375.0)));\nblock1 = step(offsetDepth, dot(texture2D(cc_shadowMap, vec2(clipPos_offset.x, clipPos.y)), vec4(1.0, 1.0 / 255.0, 1.0 / 65025.0, 1.0 / 16581375.0)));\nblock2 = step(offsetDepth, dot(texture2D(cc_shadowMap, vec2(clipPos.x, clipPos_offset.y)), vec4(1.0, 1.0 / 255.0, 1.0 / 65025.0, 1.0 / 16581375.0)));\nblock3 = step(offsetDepth, dot(texture2D(cc_shadowMap, vec2(clipPos_offset.x, clipPos_offset.y)), vec4(1.0, 1.0 / 255.0, 1.0 / 65025.0, 1.0 / 16581375.0)));\n} else {\nblock0 = step(offsetDepth, texture2D(cc_shadowMap, vec2(clipPos.x, clipPos.y)).x);\nblock1 = step(offsetDepth, texture2D(cc_shadowMap, vec2(clipPos_offset.x, clipPos.y)).x);\nblock2 = step(offsetDepth, texture2D(cc_shadowMap, vec2(clipPos.x, clipPos_offset.y)).x);\nblock3 = step(offsetDepth, texture2D(cc_shadowMap, vec2(clipPos_offset.x, clipPos_offset.y)).x);\n}\nfloat coefX = mod(clipPos.x, oneTap.x) * mapSize.x;\nfloat resultX = mix(block0, block1, coefX);\nfloat resultY = mix(block2, block3, coefX);\nfloat coefY = mod(clipPos.y, oneTap.y) * mapSize.y;\nreturn mix(resultX, resultY, coefY);\n}\nfloat CCGetShadowFactorSoft2X (vec4 shadowPos) {\nvec4 clipPosNew = ApplyShadowDepthBias_Orthographic(shadowPos, cc_shadowWHPBInfo.w);\nvec3 clipPos = clipPosNew.xyz / clipPosNew.w * 0.5 + 0.5;\nif (clipPos.x < 0.0 || clipPos.x > 1.0 ||\nclipPos.y < 0.0 || clipPos.y > 1.0 ||\nclipPos.z < 0.0 || clipPos.z > 1.0) { return 1.0; }\nclipPos.xy = cc_cameraPos.w == 1.0 ? vec2(clipPos.xy.x, 1.0 - clipPos.xy.y) : clipPos.xy;\nfloat offsetDepth = clipPos.z;\nvec2 mapSize = cc_shadowWHPBInfo.xy;\nvec2 oneTap = 1.0 / mapSize;\nfloat clipPos_offset_L = clipPos.x - oneTap.x;\nfloat clipPos_offset_R = clipPos.x + oneTap.x;\nfloat clipPos_offset_U = clipPos.y - oneTap.y;\nfloat clipPos_offset_D = clipPos.y + oneTap.y;\nfloat block0, block1, block2, block3, block4, block5, block6, block7, block8;\nif (cc_shadowLPNNInfo.y > 0.000001) {\nblock0 = step(offsetDepth, dot(texture2D(cc_shadowMap, vec2(clipPos_offset_L, clipPos_offset_U)), vec4(1.0, 1.0 / 255.0, 1.0 / 65025.0, 1.0 / 16581375.0)));\nblock1 = step(offsetDepth, dot(texture2D(cc_shadowMap, vec2(clipPos.x, clipPos_offset_U)), vec4(1.0, 1.0 / 255.0, 1.0 / 65025.0, 1.0 / 16581375.0)));\nblock2 = step(offsetDepth, dot(texture2D(cc_shadowMap, vec2(clipPos_offset_R, clipPos_offset_U)), vec4(1.0, 1.0 / 255.0, 1.0 / 65025.0, 1.0 / 16581375.0)));\nblock3 = step(offsetDepth, dot(texture2D(cc_shadowMap, vec2(clipPos_offset_L, clipPos.y)), vec4(1.0, 1.0 / 255.0, 1.0 / 65025.0, 1.0 / 16581375.0)));\nblock4 = step(offsetDepth, dot(texture2D(cc_shadowMap, vec2(clipPos.x, clipPos.y)), vec4(1.0, 1.0 / 255.0, 1.0 / 65025.0, 1.0 / 16581375.0)));\nblock5 = step(offsetDepth, dot(texture2D(cc_shadowMap, vec2(clipPos_offset_R, clipPos.y)), vec4(1.0, 1.0 / 255.0, 1.0 / 65025.0, 1.0 / 16581375.0)));\nblock6 = step(offsetDepth, dot(texture2D(cc_shadowMap, vec2(clipPos_offset_L, clipPos_offset_D)), vec4(1.0, 1.0 / 255.0, 1.0 / 65025.0, 1.0 / 16581375.0)));\nblock7 = step(offsetDepth, dot(texture2D(cc_shadowMap, vec2(clipPos.x, clipPos_offset_D)), vec4(1.0, 1.0 / 255.0, 1.0 / 65025.0, 1.0 / 16581375.0)));\nblock8 = step(offsetDepth, dot(texture2D(cc_shadowMap, vec2(clipPos_offset_R, clipPos_offset_D)), vec4(1.0, 1.0 / 255.0, 1.0 / 65025.0, 1.0 / 16581375.0)));\n} else {\nblock0 = step(offsetDepth, texture2D(cc_shadowMap, vec2(clipPos_offset_L, clipPos_offset_U)).x);\nblock1 = step(offsetDepth, texture2D(cc_shadowMap, vec2(clipPos.x, clipPos_offset_U)).x);\nblock2 = step(offsetDepth, texture2D(cc_shadowMap, vec2(clipPos_offset_R, clipPos_offset_U)).x);\nblock3 = step(offsetDepth, texture2D(cc_shadowMap, vec2(clipPos_offset_L, clipPos.y)).x);\nblock4 = step(offsetDepth, texture2D(cc_shadowMap, vec2(clipPos.x, clipPos.y)).x);\nblock5 = step(offsetDepth, texture2D(cc_shadowMap, vec2(clipPos_offset_R, clipPos.y)).x);\nblock6 = step(offsetDepth, texture2D(cc_shadowMap, vec2(clipPos_offset_L, clipPos_offset_D)).x);\nblock7 = step(offsetDepth, texture2D(cc_shadowMap, vec2(clipPos.x, clipPos_offset_D)).x);\nblock8 = step(offsetDepth, texture2D(cc_shadowMap, vec2(clipPos_offset_R, clipPos_offset_D)).x);\n}\nfloat coefX = mod(clipPos.x, oneTap.x) * mapSize.x;\nfloat coefY = mod(clipPos.y, oneTap.y) * mapSize.y;\nfloat shadow = 0.0;\nfloat resultX = mix(block0, block1, coefX);\nfloat resultY = mix(block3, block4, coefX);\nshadow += mix(resultX , resultY, coefY);\nresultX = mix(block1, block2, coefX);\nresultY = mix(block4, block5, coefX);\nshadow += mix(resultX , resultY, coefY);\nresultX = mix(block3, block4, coefX);\nresultY = mix(block6, block7, coefX);\nshadow += mix(resultX, resultY, coefY);\nresultX = mix(block4, block5, coefX);\nresultY = mix(block7, block8, coefX);\nshadow += mix(resultX, resultY, coefY);\nreturn shadow * 0.25;\n}\nfloat CCGetSpotLightShadowFactorHard (vec4 shadowPos, vec3 worldPos) {\nvec4 clipPosNew = ApplyShadowDepthBias_Perspective(shadowPos, cc_shadowWHPBInfo.w);\nvec3 clipPos = clipPosNew.xyz / clipPosNew.w * 0.5 + 0.5;\nif (clipPos.x < 0.0 || clipPos.x > 1.0 ||\nclipPos.y < 0.0 || clipPos.y > 1.0 ||\nclipPos.z < 0.0 || clipPos.z > 1.0) { return 1.0; }\nclipPos.xy = cc_cameraPos.w == 1.0 ? vec2(clipPos.xy.x, 1.0 - clipPos.xy.y) : clipPos.xy;\nfloat shadow = 0.0;\nfloat closestDepth = 0.0;\nfloat depth = clipPos.z;\nif (cc_shadowLPNNInfo.y > 0.000001) {\nclosestDepth = dot(texture2D(cc_spotLightingMap, clipPos.xy), vec4(1.0, 1.0 / 255.0, 1.0 / 65025.0, 1.0 / 16581375.0));\n} else {\nclosestDepth = texture2D(cc_spotLightingMap, clipPos.xy).x;\n}\nshadow = step(depth, closestDepth);\nreturn shadow;\n}\nfloat CCGetSpotLightShadowFactorSoft (vec4 shadowPos, vec3 worldPos) {\nvec4 clipPosNew = ApplyShadowDepthBias_Perspective(shadowPos, cc_shadowWHPBInfo.w);\nvec3 clipPos = clipPosNew.xyz / clipPosNew.w * 0.5 + 0.5;\nif (clipPos.x < 0.0 || clipPos.x > 1.0 ||\nclipPos.y < 0.0 || clipPos.y > 1.0 ||\nclipPos.z < 0.0 || clipPos.z > 1.0) { return 1.0; }\nclipPos.xy = cc_cameraPos.w == 1.0 ? vec2(clipPos.xy.x, 1.0 - clipPos.xy.y) : clipPos.xy;\nfloat depth = 0.0;\nif (cc_shadowNFLSInfo.z > 0.000001) {\ndepth = CCGetLinearDepth(worldPos);\n} else {\ndepth = clipPos.z;\n}\nfloat bias = cc_shadowWHPBInfo.w;\nvec2 oneTap = 1.0 / cc_shadowWHPBInfo.xy;\nvec2 clipPos_offset = clipPos.xy + oneTap;\nfloat block0, block1, block2, block3;\nif (cc_shadowLPNNInfo.y > 0.000001) {\nblock0 = step(depth, dot(texture2D(cc_spotLightingMap, vec2(clipPos.x, clipPos.y)), vec4(1.0, 1.0 / 255.0, 1.0 / 65025.0, 1.0 / 16581375.0)));\nblock1 = step(depth, dot(texture2D(cc_spotLightingMap, vec2(clipPos_offset.x, clipPos.y)), vec4(1.0, 1.0 / 255.0, 1.0 / 65025.0, 1.0 / 16581375.0)));\nblock2 = step(depth, dot(texture2D(cc_spotLightingMap, vec2(clipPos.x, clipPos_offset.y)), vec4(1.0, 1.0 / 255.0, 1.0 / 65025.0, 1.0 / 16581375.0)));\nblock3 = step(depth, dot(texture2D(cc_spotLightingMap, vec2(clipPos_offset.x, clipPos_offset.y)), vec4(1.0, 1.0 / 255.0, 1.0 / 65025.0, 1.0 / 16581375.0)));\n} else {\nblock0 = step(depth, texture2D(cc_spotLightingMap, vec2(clipPos.x, clipPos.y)).x);\nblock1 = step(depth, texture2D(cc_spotLightingMap, vec2(clipPos_offset.x, clipPos.y)).x);\nblock2 = step(depth, texture2D(cc_spotLightingMap, vec2(clipPos.x, clipPos_offset.y)).x);\nblock3 = step(depth, texture2D(cc_spotLightingMap, vec2(clipPos_offset.x, clipPos_offset.y)).x);\n}\nfloat coefX = mod(clipPos.x, oneTap.x) * cc_shadowWHPBInfo.x;\nfloat resultX = mix(block0, block1, coefX);\nfloat resultY = mix(block2, block3, coefX);\nfloat coefY = mod(clipPos.y, oneTap.y) * cc_shadowWHPBInfo.y;\nreturn mix(resultX, resultY, coefY);\n}\nfloat CCGetSpotLightShadowFactorSoft2X (vec4 shadowPos, vec3 worldPos) {\nvec4 clipPosNew = ApplyShadowDepthBias_Perspective(shadowPos, cc_shadowWHPBInfo.w);\nvec3 clipPos = clipPosNew.xyz / clipPosNew.w * 0.5 + 0.5;\nif (clipPos.x < 0.0 || clipPos.x > 1.0 ||\nclipPos.y < 0.0 || clipPos.y > 1.0 ||\nclipPos.z < 0.0 || clipPos.z > 1.0) { return 1.0; }\nclipPos.xy = cc_cameraPos.w == 1.0 ? vec2(clipPos.xy.x, 1.0 - clipPos.xy.y) : clipPos.xy;\nfloat depth = 0.0;\nif (cc_shadowNFLSInfo.z > 0.000001) {\ndepth = CCGetLinearDepth(worldPos);\n} else {\ndepth = clipPos.z;\n}\nfloat bias = cc_shadowWHPBInfo.w;\nvec2 mapSize = cc_shadowWHPBInfo.xy;\nvec2 oneTap = 1.0 / mapSize;\nfloat clipPos_offset_L = clipPos.x - oneTap.x;\nfloat clipPos_offset_R = clipPos.x + oneTap.x;\nfloat clipPos_offset_U = clipPos.y - oneTap.y;\nfloat clipPos_offset_D = clipPos.y + oneTap.y;\nfloat block0, block1, block2, block3, block4, block5, block6, block7, block8;\nif (cc_shadowLPNNInfo.y > 0.000001) {\nblock0 = step(depth, dot(texture2D(cc_spotLightingMap, vec2(clipPos_offset_L, clipPos_offset_U)), vec4(1.0, 1.0 / 255.0, 1.0 / 65025.0, 1.0 / 16581375.0)));\nblock1 = step(depth, dot(texture2D(cc_spotLightingMap, vec2(clipPos.x, clipPos_offset_U)), vec4(1.0, 1.0 / 255.0, 1.0 / 65025.0, 1.0 / 16581375.0)));\nblock2 = step(depth, dot(texture2D(cc_spotLightingMap, vec2(clipPos_offset_R, clipPos_offset_U)), vec4(1.0, 1.0 / 255.0, 1.0 / 65025.0, 1.0 / 16581375.0)));\nblock3 = step(depth, dot(texture2D(cc_spotLightingMap, vec2(clipPos_offset_L, clipPos.y)), vec4(1.0, 1.0 / 255.0, 1.0 / 65025.0, 1.0 / 16581375.0)));\nblock4 = step(depth, dot(texture2D(cc_spotLightingMap, vec2(clipPos.x, clipPos.y)), vec4(1.0, 1.0 / 255.0, 1.0 / 65025.0, 1.0 / 16581375.0)));\nblock5 = step(depth, dot(texture2D(cc_spotLightingMap, vec2(clipPos_offset_R, clipPos.y)), vec4(1.0, 1.0 / 255.0, 1.0 / 65025.0, 1.0 / 16581375.0)));\nblock6 = step(depth, dot(texture2D(cc_spotLightingMap, vec2(clipPos_offset_L, clipPos_offset_D)), vec4(1.0, 1.0 / 255.0, 1.0 / 65025.0, 1.0 / 16581375.0)));\nblock7 = step(depth, dot(texture2D(cc_spotLightingMap, vec2(clipPos.x, clipPos_offset_D)), vec4(1.0, 1.0 / 255.0, 1.0 / 65025.0, 1.0 / 16581375.0)));\nblock8 = step(depth, dot(texture2D(cc_spotLightingMap, vec2(clipPos_offset_R, clipPos_offset_D)), vec4(1.0, 1.0 / 255.0, 1.0 / 65025.0, 1.0 / 16581375.0)));\n} else {\nblock0 = step(depth, texture2D(cc_spotLightingMap, vec2(clipPos_offset_L, clipPos_offset_U)).x);\nblock1 = step(depth, texture2D(cc_spotLightingMap, vec2(clipPos.x, clipPos_offset_U)).x);\nblock2 = step(depth, texture2D(cc_spotLightingMap, vec2(clipPos_offset_R, clipPos_offset_U)).x);\nblock3 = step(depth, texture2D(cc_spotLightingMap, vec2(clipPos_offset_L, clipPos.y)).x);\nblock4 = step(depth, texture2D(cc_spotLightingMap, vec2(clipPos.x, clipPos.y)).x);\nblock5 = step(depth, texture2D(cc_spotLightingMap, vec2(clipPos_offset_R, clipPos.y)).x);\nblock6 = step(depth, texture2D(cc_spotLightingMap, vec2(clipPos_offset_L, clipPos_offset_D)).x);\nblock7 = step(depth, texture2D(cc_spotLightingMap, vec2(clipPos.x, clipPos_offset_D)).x);\nblock8 = step(depth, texture2D(cc_spotLightingMap, vec2(clipPos_offset_R, clipPos_offset_D)).x);\n}\nfloat coefX = mod(clipPos.x, oneTap.x) * mapSize.x;\nfloat coefY = mod(clipPos.y, oneTap.y) * mapSize.y;\nfloat shadow = 0.0;\nfloat resultX = mix(block0, block1, coefX);\nfloat resultY = mix(block3, block4, coefX);\nshadow += mix(resultX , resultY, coefY);\nresultX = mix(block1, block2, coefX);\nresultY = mix(block4, block5, coefX);\nshadow += mix(resultX , resultY, coefY);\nresultX = mix(block3, block4, coefX);\nresultY = mix(block6, block7, coefX);\nshadow += mix(resultX, resultY, coefY);\nresultX = mix(block4, block5, coefX);\nresultY = mix(block7, block8, coefX);\nshadow += mix(resultX, resultY, coefY);\nreturn shadow * 0.25;\n}\n#endif\n#if CC_USE_IBL\nuniform samplerCube cc_environment;\nvec4 fragTextureLod (sampler2D tex, vec2 coord, float lod) {\n#ifdef GL_EXT_shader_texture_lod\nreturn texture2DLodEXT(tex, coord, lod);\n#else\nreturn texture2D(tex, coord, lod);\n#endif\n}\nvec4 fragTextureLod (samplerCube tex, vec3 coord, float lod) {\n#ifdef GL_EXT_shader_texture_lod\nreturn textureCubeLodEXT(tex, coord, lod);\n#else\nreturn textureCube(tex, coord, lod);\n#endif\n}\nvec3 unpackRGBE (vec4 rgbe) {\nreturn rgbe.rgb * pow(1.1, rgbe.a * 255.0 - 128.0);\n}\n#if CC_USE_DIFFUSEMAP\nuniform samplerCube cc_diffuseMap;\n#endif\n#endif\nfloat GGXMobile (float roughness, float NoH, vec3 H, vec3 N) {\nvec3 NxH = cross(N, H);\nfloat OneMinusNoHSqr = dot(NxH, NxH);\nfloat a = roughness * roughness;\nfloat n = NoH * a;\nfloat p = a / (OneMinusNoHSqr + n * n);\nreturn p * p;\n}\nfloat CalcSpecular (float roughness, float NoH, vec3 H, vec3 N) {\nreturn (roughness * 0.25 + 0.25) * GGXMobile(roughness, NoH, H, N);\n}\nvec3 BRDFApprox (vec3 specular, float roughness, float NoV) {\nconst vec4 c0 = vec4(-1.0, -0.0275, -0.572, 0.022);\nconst vec4 c1 = vec4(1.0, 0.0425, 1.04, -0.04);\nvec4 r = roughness * c0 + c1;\nfloat a004 = min(r.x * r.x, exp2(-9.28 * NoV)) * r.x + r.y;\nvec2 AB = vec2(-1.04, 1.04) * a004 + r.zw;\nAB.y *= clamp(50.0 * specular.g, 0.0, 1.0);\nreturn specular * AB.x + AB.y;\n}\n#if USE_REFLECTION_DENOISE\nvec3 GetEnvReflectionWithMipFiltering(vec3 R, float roughness, float mipCount, float denoiseIntensity) {\n#if CC_USE_IBL\nfloat mip = roughness * mipCount;\nfloat delta = (dot(dFdx(R), dFdy(R))) * 1000.0;\nfloat mipBias = mix(0.0, 5.0, clamp(delta, 0.0, 1.0));\nvec4 biased = fragTextureLod(cc_environment, R, mip + mipBias);\nvec4 filtered = textureCube(cc_environment, R);\n#if CC_USE_IBL == 2\nbiased.rgb = unpackRGBE(biased);\nfiltered.rgb = unpackRGBE(filtered);\n#else\nbiased.rgb = SRGBToLinear(biased.rgb);\nfiltered.rgb = SRGBToLinear(filtered.rgb);\n#endif\nreturn mix(biased.rgb, filtered.rgb, denoiseIntensity);\n#else\nreturn vec3(0.0, 0.0, 0.0);\n#endif\n}\n#endif\nstruct StandardSurface {\nvec4 albedo;\nvec3 position;\nvec3 normal;\nvec3 emissive;\nvec3 lightmap;\nfloat lightmap_test;\nfloat roughness;\nfloat metallic;\nfloat occlusion;\n};\nvec4 CCStandardShadingBase (StandardSurface s, vec4 shadowPos) {\nvec3 diffuse = s.albedo.rgb * (1.0 - s.metallic);\nvec3 specular = mix(vec3(0.04), s.albedo.rgb, s.metallic);\nvec3 N = normalize(s.normal);\nvec3 V = normalize(cc_cameraPos.xyz - s.position);\nfloat NV = max(abs(dot(N, V)), 0.0);\nspecular = BRDFApprox(specular, s.roughness, NV);\nvec3 L = normalize(-cc_mainLitDir.xyz);\nvec3 H = normalize(L + V);\nfloat NH = max(dot(N, H), 0.0);\nfloat NL = max(dot(N, L), 0.0);\nvec3 finalColor = NL * cc_mainLitColor.rgb * cc_mainLitColor.w;\nvec3 diffuseContrib = diffuse;\n#if USE_LIGHTMAP && !USE_BATCHING && !CC_FORWARD_ADD\nif (s.lightmap_test > 0.0001) {\nfinalColor = s.lightmap.rgb;\n}\n#else\ndiffuseContrib /= 3.14159265359;\n#endif\nvec3 specularContrib = specular * CalcSpecular(s.roughness, NH, H, N);\nvec3 dirlightContrib = (diffuseContrib + specularContrib);\nfloat shadow = 1.0;\n#if CC_RECEIVE_SHADOW && CC_ENABLE_DIR_SHADOW\nif (NL > 0.0) {\n{\nvec4 pos = ApplyShadowDepthBias_FaceNormal(shadowPos, N);\nfloat pcf = cc_shadowWHPBInfo.z;\nif (pcf > 1.9) shadow = CCGetShadowFactorSoft2X(pos);\nelse if (pcf > 0.9) shadow = CCGetShadowFactorSoft(pos);\nelse shadow = CCGetShadowFactorHard(pos);\nshadow = mix(shadow, 1.0, cc_shadowNFLSInfo.w);\n}\n}\n#endif\ndirlightContrib *= shadow;\nfinalColor *= dirlightContrib;\nfloat fAmb = 0.5 - N.y * 0.5;\nvec3 ambDiff = mix(cc_ambientSky.rgb, cc_ambientGround.rgb, fAmb);\n#if CC_USE_IBL\n#if CC_USE_DIFFUSEMAP\nvec4 diffuseMap = textureCube(cc_diffuseMap, N);\n#if CC_USE_DIFFUSEMAP == 2\nambDiff = unpackRGBE(diffuseMap);\n#else\nambDiff = SRGBToLinear(diffuseMap.rgb);\n#endif\n#endif\nvec3 R = normalize(reflect(-V, N));\n#if USE_REFLECTION_DENOISE\nvec3 env = GetEnvReflectionWithMipFiltering(R, s.roughness, cc_ambientGround.w, 0.6);\n#else\nvec4 envmap = fragTextureLod(cc_environment, R, s.roughness * cc_ambientGround.w);\n#if CC_USE_IBL == 2\nvec3 env = unpackRGBE(envmap);\n#else\nvec3 env = SRGBToLinear(envmap.rgb);\n#endif\n#endif\nfinalColor += env * cc_ambientSky.w * specular * s.occlusion;\n#endif\nfinalColor += ambDiff.rgb * cc_ambientSky.w * diffuse * s.occlusion;\nfinalColor += s.emissive;\nreturn vec4(finalColor, s.albedo.a);\n}\nvec3 ACESToneMap (vec3 color) {\ncolor = min(color, vec3(8.0));\nconst float A = 2.51;\nconst float B = 0.03;\nconst float C = 2.43;\nconst float D = 0.59;\nconst float E = 0.14;\nreturn (color * (A * color + B)) / (color * (C * color + D) + E);\n}\nvec4 CCFragOutput (vec4 color) {\n#if CC_USE_HDR\ncolor.rgb = ACESToneMap(color.rgb);\n#endif\ncolor.rgb = sqrt(color.rgb);\nreturn color;\n}\nfloat LinearFog(vec4 pos) {\nvec4 wPos = pos;\nfloat cam_dis = distance(cc_cameraPos, wPos);\nfloat fogStart = cc_fogBase.x;\nfloat fogEnd = cc_fogBase.y;\nreturn clamp((fogEnd - cam_dis) / (fogEnd - fogStart), 0., 1.);\n}\nfloat ExpFog(vec4 pos) {\nvec4 wPos = pos;\nfloat fogAtten = cc_fogAdd.z;\nfloat fogStart = cc_fogBase.x;\nfloat fogDensity = cc_fogBase.z;\nfloat cam_dis = max(distance(cc_cameraPos, wPos) - fogStart, 0.0) / fogAtten * 4.;\nfloat f = exp(-cam_dis * fogDensity);\nreturn f;\n}\nfloat ExpSquaredFog(vec4 pos) {\nvec4 wPos = pos;\nfloat fogAtten = cc_fogAdd.z;\nfloat fogStart = cc_fogBase.x;\nfloat fogDensity = cc_fogBase.z;\nfloat cam_dis = max(distance(cc_cameraPos, wPos) - fogStart, 0.0) / fogAtten * 4.;\nfloat f = exp(-cam_dis * cam_dis * fogDensity * fogDensity);\nreturn f;\n}\nfloat LayeredFog(vec4 pos) {\nvec4 wPos = pos;\nfloat fogAtten = cc_fogAdd.z;\nfloat _FogTop = cc_fogAdd.x;\nfloat _FogRange = cc_fogAdd.y;\nvec3 camWorldProj = cc_cameraPos.xyz;\ncamWorldProj.y = 0.;\nvec3 worldPosProj = wPos.xyz;\nworldPosProj.y = 0.;\nfloat fDeltaD = distance(worldPosProj, camWorldProj) / fogAtten * 2.0;\nfloat fDeltaY, fDensityIntegral;\nif (cc_cameraPos.y > _FogTop) {\nif (wPos.y < _FogTop) {\nfDeltaY = (_FogTop - wPos.y) / _FogRange * 2.0;\nfDensityIntegral = fDeltaY * fDeltaY * 0.5;\n} else {\nfDeltaY = 0.;\nfDensityIntegral = 0.;\n}\n} else {\nif (wPos.y < _FogTop) {\nfloat fDeltaA = (_FogTop - cc_cameraPos.y) / _FogRange * 2.;\nfloat fDeltaB = (_FogTop - wPos.y) / _FogRange * 2.;\nfDeltaY = abs(fDeltaA - fDeltaB);\nfDensityIntegral = abs((fDeltaA * fDeltaA * 0.5) - (fDeltaB * fDeltaB * 0.5));\n} else {\nfDeltaY = abs(_FogTop - cc_cameraPos.y) / _FogRange * 2.;\nfDensityIntegral = abs(fDeltaY * fDeltaY * 0.5);\n}\n}\nfloat fDensity;\nif (fDeltaY != 0.) {\nfDensity = (sqrt(1.0 + ((fDeltaD / fDeltaY) * (fDeltaD / fDeltaY)))) * fDensityIntegral;\n} else {\nfDensity = 0.;\n}\nfloat f = exp(-fDensity);\nreturn f;\n}\nvoid CC_TRANSFER_FOG_BASE(vec4 pos, out float factor)\n{\n#if CC_USE_FOG == 0\nfactor = LinearFog(pos);\n#elif CC_USE_FOG == 1\nfactor = ExpFog(pos);\n#elif CC_USE_FOG == 2\nfactor = ExpSquaredFog(pos);\n#elif CC_USE_FOG == 3\nfactor = LayeredFog(pos);\n#else\nfactor = 1.0;\n#endif\n}\nvoid CC_APPLY_FOG_BASE(inout vec4 color, float factor) {\ncolor = vec4(mix(cc_fogColor.rgb, color.rgb, factor), color.a);\n}\n#if !CC_USE_ACCURATE_FOG\nvarying float v_fog_factor;\n#endif\nvoid CC_APPLY_FOG(inout vec4 color) {\n#if !CC_USE_ACCURATE_FOG\nCC_APPLY_FOG_BASE(color, v_fog_factor);\n#endif\n}\nvoid CC_APPLY_FOG(inout vec4 color, vec3 worldPos) {\n#if CC_USE_ACCURATE_FOG\nfloat factor;\nCC_TRANSFER_FOG_BASE(vec4(worldPos, 1.0), factor);\n#else\nfloat factor = v_fog_factor;\n#endif\nCC_APPLY_FOG_BASE(color, factor);\n}\nvarying highp vec4 v_shadowPos;\n#if USE_LIGHTMAP && !USE_BATCHING && !CC_FORWARD_ADD\nvarying vec3 v_luv;\nuniform sampler2D cc_lightingMap;\nvec3 UnpackLightingmap(vec4 color) {\nvec3 c;\nfloat e = 1.0 + color.a * (8.0 - 1.0);\nc.r = color.r * e;\nc.g = color.g * e;\nc.b = color.b * e;\nreturn c;\n}\n#endif\nvarying highp vec3 v_position;\nvarying mediump vec3 v_normal;\n#if USE_NORMALMAP\nvarying mediump vec3 v_tangent;\nvarying mediump vec3 v_binormal;\n#endif\nvarying mediump vec2 uvw;\nvarying mediump vec2 uv0;\nvarying mediump vec2 uv1;\nvarying mediump vec2 uv2;\nvarying mediump vec2 uv3;\nvarying mediump vec3 diffuse;\nvarying mediump vec3 luv;\nuniform vec4 metallic;\nuniform vec4 roughness;\nuniform sampler2D weightMap;\nuniform sampler2D detailMap0;\nuniform sampler2D detailMap1;\nuniform sampler2D detailMap2;\nuniform sampler2D detailMap3;\nuniform sampler2D normalMap0;\nuniform sampler2D normalMap1;\nuniform sampler2D normalMap2;\nuniform sampler2D normalMap3;\nuniform sampler2D lightMap;\nvoid surf (out StandardSurface s) {\n#if LAYERS > 1\nvec4 w = texture2D(weightMap, uvw);\n#endif\nvec4 baseColor = vec4(0, 0, 0, 0);\n#if LAYERS == 1\nbaseColor = texture2D(detailMap0, uv0);\n#elif LAYERS == 2\nbaseColor += texture2D(detailMap0, uv0) * w.r;\nbaseColor += texture2D(detailMap1, uv1) * w.g;\n#elif LAYERS == 3\nbaseColor += texture2D(detailMap0, uv0) * w.r;\nbaseColor += texture2D(detailMap1, uv1) * w.g;\nbaseColor += texture2D(detailMap2, uv2) * w.b;\n#elif LAYERS == 4\nbaseColor += texture2D(detailMap0, uv0) * w.r;\nbaseColor += texture2D(detailMap1, uv1) * w.g;\nbaseColor += texture2D(detailMap2, uv2) * w.b;\nbaseColor += texture2D(detailMap3, uv3) * w.a;\n#else\nbaseColor = texture2D(detailMap0, uv0);\n#endif\ns.position = v_position;\n#if USE_NORMALMAP\nvec4 baseNormal = vec4(0, 0, 0, 0);\n#if LAYERS == 1\nbaseNormal = texture2D(normalMap0, uv0);\n#elif LAYERS == 2\nbaseNormal += texture2D(normalMap0, uv0) * w.r;\nbaseNormal += texture2D(normalMap1, uv1) * w.g;\n#elif LAYERS == 3\nbaseNormal += texture2D(normalMap0, uv0) * w.r;\nbaseNormal += texture2D(normalMap1, uv1) * w.g;\nbaseNormal += texture2D(normalMap2, uv2) * w.b;\n#elif LAYERS == 4\nbaseNormal += texture2D(normalMap0, uv0) * w.r;\nbaseNormal += texture2D(normalMap1, uv1) * w.g;\nbaseNormal += texture2D(normalMap2, uv2) * w.b;\nbaseNormal += texture2D(normalMap3, uv3) * w.a;\n#else\nbaseNormal = texture2D(normalMap0, uv0);\n#endif\nvec3 nmmp = baseNormal.xyz - vec3(0.5);\ns.normal =\nnmmp.x * normalize(v_tangent) +\nnmmp.y * normalize(v_binormal) +\nnmmp.z * normalize(v_normal);\n#else\ns.normal = v_normal;\n#endif\ns.albedo = vec4(SRGBToLinear(baseColor.rgb), 1.0);\ns.occlusion = 1.0;\n#if USE_PBR\ns.roughness = 0.0;\n#if LAYERS == 1\ns.roughness = roughness.x;\n#elif LAYERS == 2\ns.roughness += roughness.x * w.r;\ns.roughness += roughness.y * w.g;\n#elif LAYERS == 3\ns.roughness += roughness.x * w.r;\ns.roughness += roughness.y * w.g;\ns.roughness += roughness.z * w.b;\n#elif LAYERS == 4\ns.roughness += roughness.x * w.r;\ns.roughness += roughness.y * w.g;\ns.roughness += roughness.z * w.b;\ns.roughness += roughness.w * w.a;\n#else\ns.roughness = 1.0;\n#endif\ns.metallic = 0.0;\n#if LAYERS == 1\ns.metallic = metallic.x;\n#elif LAYERS == 2\ns.metallic += metallic.x * w.r;\ns.metallic += metallic.y * w.g;\n#elif LAYERS == 3\ns.metallic += metallic.x * w.r;\ns.metallic += metallic.y * w.g;\ns.metallic += metallic.z * w.b;\n#elif LAYERS == 4\ns.metallic += metallic.x * w.r;\ns.metallic += metallic.y * w.g;\ns.metallic += metallic.z * w.b;\ns.metallic += metallic.w * w.a;\n#else\ns.metallic = 0.0;\n#endif\n#else\ns.roughness = 1.0;\ns.metallic = 0.0;\n#endif\ns.emissive = vec3(0.0, 0.0, 0.0);\n#if USE_LIGHTMAP && !USE_BATCHING && !CC_FORWARD_ADD\nvec4 lightColor = texture2D(lightMap, luv.xy);\ns.lightmap = UnpackLightingmap(lightColor);\ns.lightmap_test = luv.z;\n#endif\n}\n#if CC_FORWARD_ADD\n#if CC_PIPELINE_TYPE == 0\n# define LIGHTS_PER_PASS 1\n#else\n# define LIGHTS_PER_PASS 10\n#endif\n#if CC_ENABLE_CLUSTERED_LIGHT_CULLING == 0\nuniform highp vec4 cc_lightPos[LIGHTS_PER_PASS];\nuniform vec4 cc_lightColor[LIGHTS_PER_PASS];\nuniform vec4 cc_lightSizeRangeAngle[LIGHTS_PER_PASS];\nuniform vec4 cc_lightDir[LIGHTS_PER_PASS];\n#endif\nfloat SmoothDistAtt (float distSqr, float invSqrAttRadius) {\nfloat factor = distSqr * invSqrAttRadius;\nfloat smoothFactor = clamp(1.0 - factor * factor, 0.0, 1.0);\nreturn smoothFactor * smoothFactor;\n}\nfloat GetDistAtt (float distSqr, float invSqrAttRadius) {\nfloat attenuation = 1.0 / max(distSqr, 0.01*0.01);\nattenuation *= SmoothDistAtt(distSqr , invSqrAttRadius);\nreturn attenuation;\n}\nfloat GetAngleAtt (vec3 L, vec3 litDir, float litAngleScale, float litAngleOffset) {\nfloat cd = dot(litDir, L);\nfloat attenuation = clamp(cd * litAngleScale + litAngleOffset, 0.0, 1.0);\nreturn (attenuation * attenuation);\n}\n#if CC_ENABLE_CLUSTERED_LIGHT_CULLING == 0\nvec4 CCStandardShadingAdditive (StandardSurface s, vec4 shadowPos) {\nvec3 diffuse = s.albedo.rgb * (1.0 - s.metallic);\nvec3 specular = mix(vec3(0.04), s.albedo.rgb, s.metallic);\nvec3 diffuseContrib = diffuse / 3.14159265359;\nvec3 N = normalize(s.normal);\nvec3 V = normalize(cc_cameraPos.xyz - s.position);\nfloat NV = max(abs(dot(N, V)), 0.0);\nspecular = BRDFApprox(specular, s.roughness, NV);\nvec3 finalColor = vec3(0.0);\nint numLights = CC_PIPELINE_TYPE == 0 ? LIGHTS_PER_PASS : int(cc_lightDir[0].w);\nfor (int i = 0; i < LIGHTS_PER_PASS; i++) {\nif (i >= numLights) break;\nvec3 SLU = cc_lightPos[i].xyz - s.position;\nvec3 SL = normalize(SLU);\nvec3 SH = normalize(SL + V);\nfloat SNL = max(dot(N, SL), 0.0);\nfloat SNH = max(dot(N, SH), 0.0);\nfloat distSqr = dot(SLU, SLU);\nfloat litRadius = cc_lightSizeRangeAngle[i].x;\nfloat litRadiusSqr = litRadius * litRadius;\nfloat illum = 3.14159265359 * (litRadiusSqr / max(litRadiusSqr , distSqr));\nfloat attRadiusSqrInv = 1.0 / max(cc_lightSizeRangeAngle[i].y, 0.01);\nattRadiusSqrInv *= attRadiusSqrInv;\nfloat att = GetDistAtt(distSqr, attRadiusSqrInv);\nvec3 lspec = specular * CalcSpecular(s.roughness, SNH, SH, N);\nif (cc_lightPos[i].w > 0.0) {\nfloat cosInner = max(dot(-cc_lightDir[i].xyz, SL), 0.01);\nfloat cosOuter = cc_lightSizeRangeAngle[i].z;\nfloat litAngleScale = 1.0 / max(0.001, cosInner - cosOuter);\nfloat litAngleOffset = -cosOuter * litAngleScale;\natt *= GetAngleAtt(SL, -cc_lightDir[i].xyz, litAngleScale, litAngleOffset);\n}\nvec3 lightColor = cc_lightColor[i].rgb;\nfloat shadow = 1.0;\n#if CC_RECEIVE_SHADOW\nif (cc_lightPos[i].w > 0.0 && cc_lightSizeRangeAngle[i].w > 0.0) {\n{\nfloat pcf = cc_shadowWHPBInfo.z;\nif (pcf > 1.9) shadow = CCGetSpotLightShadowFactorSoft2X(shadowPos, s.position);\nelse if (pcf > 0.9) shadow = CCGetSpotLightShadowFactorSoft(shadowPos, s.position);\nelse shadow = CCGetSpotLightShadowFactorHard(shadowPos, s.position);\n}\n}\n#endif\nlightColor *= shadow;\nfinalColor += SNL * lightColor * cc_lightColor[i].w * illum * att * (diffuseContrib + lspec);\n}\nreturn vec4(finalColor, 0.0);\n}\n#endif\n#if CC_ENABLE_CLUSTERED_LIGHT_CULLING == 1\nreadonly buffer b_ccLightsBuffer { vec4 b_ccLights[]; };\nreadonly buffer b_clusterLightIndicesBuffer { uint b_clusterLightIndices[]; };\nreadonly buffer b_clusterLightGridBuffer { uvec4 b_clusterLightGrid[]; };\nstruct CCLight\n{\nvec4 cc_lightPos;\nvec4 cc_lightColor;\nvec4 cc_lightSizeRangeAngle;\nvec4 cc_lightDir;\n};\nstruct Cluster\n{\nvec3 minBounds;\nvec3 maxBounds;\n};\nstruct LightGrid\n{\nuint offset;\nuint ccLights;\n};\nCCLight getCCLight(uint i)\n{\nCCLight light;\nlight.cc_lightPos = b_ccLights[4u * i + 0u];\nlight.cc_lightColor = b_ccLights[4u * i + 1u];\nlight.cc_lightSizeRangeAngle = b_ccLights[4u * i + 2u];\nlight.cc_lightDir = b_ccLights[4u * i + 3u];\nreturn light;\n}\nLightGrid getLightGrid(uint cluster)\n{\nuvec4 gridvec = b_clusterLightGrid[cluster];\nLightGrid grid;\ngrid.offset = gridvec.x;\ngrid.ccLights = gridvec.y;\nreturn grid;\n}\nuint getGridLightIndex(uint start, uint offset)\n{\nreturn b_clusterLightIndices[start + offset];\n}\nuint getClusterZIndex(vec4 worldPos)\n{\nfloat scale = float(24) / log(cc_nearFar.y / cc_nearFar.x);\nfloat bias = -(float(24) * log(cc_nearFar.x) / log(cc_nearFar.y / cc_nearFar.x));\nfloat eyeDepth = -(cc_matView * worldPos).z;\nuint zIndex = uint(max(log(eyeDepth) * scale + bias, 0.0));\nreturn zIndex;\n}\nuint getClusterIndex(vec4 fragCoord, vec4 worldPos)\n{\nuint zIndex = getClusterZIndex(worldPos);\nfloat clusterSizeX = ceil(cc_screenSize.x / float(16));\nfloat clusterSizeY = ceil(cc_screenSize.y / float(8));\nuvec3 indices = uvec3(uvec2(fragCoord.xy / vec2(clusterSizeX, clusterSizeY)), zIndex);\nuint cluster = (16u * 8u) * indices.z + 16u * indices.y + indices.x;\nreturn cluster;\n}\nvec4 CCClusterShadingAdditive (StandardSurface s, vec4 shadowPos) {\nvec3 diffuse = s.albedo.rgb * (1.0 - s.metallic);\nvec3 specular = mix(vec3(0.04), s.albedo.rgb, s.metallic);\nvec3 diffuseContrib = diffuse / 3.14159265359;\nvec3 N = normalize(s.normal);\nvec3 V = normalize(cc_cameraPos.xyz - s.position);\nfloat NV = max(abs(dot(N, V)), 0.001);\nspecular = BRDFApprox(specular, s.roughness, NV);\nvec3 finalColor = vec3(0.0);\nuint cluster = getClusterIndex(gl_FragCoord, vec4(s.position, 1.0));\nLightGrid grid = getLightGrid(cluster);\nuint numLights = grid.ccLights;\nfor (uint i = 0u; i < 100u; i++) {\nif (i >= numLights) break;\nuint lightIndex = getGridLightIndex(grid.offset, i);\nCCLight light = getCCLight(lightIndex);\nvec3 SLU = light.cc_lightPos.xyz - s.position;\nvec3 SL = normalize(SLU);\nvec3 SH = normalize(SL + V);\nfloat SNL = max(dot(N, SL), 0.001);\nfloat SNH = max(dot(N, SH), 0.0);\nfloat distSqr = dot(SLU, SLU);\nfloat litRadius = light.cc_lightSizeRangeAngle.x;\nfloat litRadiusSqr = litRadius * litRadius;\nfloat illum = 3.14159265359 * (litRadiusSqr / max(litRadiusSqr , distSqr));\nfloat attRadiusSqrInv = 1.0 / max(light.cc_lightSizeRangeAngle.y, 0.01);\nattRadiusSqrInv *= attRadiusSqrInv;\nfloat att = GetDistAtt(distSqr, attRadiusSqrInv);\nvec3 lspec = specular * CalcSpecular(s.roughness, SNH, SH, N);\nif (light.cc_lightPos.w > 0.0) {\nfloat cosInner = max(dot(-light.cc_lightDir.xyz, SL), 0.01);\nfloat cosOuter = light.cc_lightSizeRangeAngle.z;\nfloat litAngleScale = 1.0 / max(0.001, cosInner - cosOuter);\nfloat litAngleOffset = -cosOuter * litAngleScale;\natt *= GetAngleAtt(SL, -light.cc_lightDir.xyz, litAngleScale, litAngleOffset);\n}\nvec3 lightColor = light.cc_lightColor.rgb;\nfloat shadow = 1.0;\n#if CC_RECEIVE_SHADOW\nif (light.cc_lightPos.w > 0.0) {\n{\nfloat pcf = cc_shadowWHPBInfo.z;\nif (pcf > 1.9) shadow = CCGetSpotLightShadowFactorSoft2X(shadowPos, s.position);\nelse if (pcf > 0.9) shadow = CCGetSpotLightShadowFactorSoft(shadowPos, s.position);\nelse shadow = CCGetSpotLightShadowFactorHard(shadowPos, s.position);\n}\n}\n#endif\nlightColor *= shadow;\nfinalColor += SNL * lightColor * light.cc_lightColor.w * illum * att * (diffuseContrib + lspec);\n}\nreturn vec4(finalColor, 0.0);\n}\n#endif\nvoid main () {\nStandardSurface s; surf(s);\n#if CC_ENABLE_CLUSTERED_LIGHT_CULLING == 1\nvec4 color = CCClusterShadingAdditive(s, v_shadowPos);\n#else\nvec4 color = CCStandardShadingAdditive(s, v_shadowPos);\n#endif\nCC_APPLY_FOG(color, s.position.xyz);\ngl_FragData[0] = CCFragOutput(color);\n}\n#elif (CC_PIPELINE_TYPE == 0 || CC_FORCE_FORWARD_SHADING)\nvoid main () {\nStandardSurface s; surf(s);\nvec4 color = CCStandardShadingBase(s, v_shadowPos);\nCC_APPLY_FOG(color, s.position.xyz);\ngl_FragData[0] = CCFragOutput(color);\n}\n#elif CC_PIPELINE_TYPE == 1\nvoid main () {\nStandardSurface s; surf(s);\ngl_FragData[0] = s.albedo;\ngl_FragData[1] = vec4(s.position, s.roughness);\ngl_FragData[2] = vec4(s.normal, s.metallic);\ngl_FragData[3] = vec4(s.emissive, s.occlusion);\n}\n#endif", + }, + { + "vert": "\nprecision highp float;\nuniform highp mat4 cc_matWorld;\nuniform highp mat4 cc_matLightViewProj;\nattribute vec3 a_position;\nattribute vec3 a_normal;\nattribute vec2 a_texCoord;\nvarying vec2 v_clip_depth;\nvec4 vert () {\nvec4 worldPos;\nworldPos.x = cc_matWorld[3][0] + a_position.x;\nworldPos.y = cc_matWorld[3][1] + a_position.y;\nworldPos.z = cc_matWorld[3][2] + a_position.z;\nworldPos.w = 1.0;\nvec4 clipPos = cc_matLightViewProj * worldPos;\nv_clip_depth = clipPos.zw;\nreturn clipPos;\n}\nvoid main() { gl_Position = vert(); }", + "frag": "\nprecision highp float;\nvec4 packDepthToRGBA (float depth) {\nvec4 ret = vec4(1.0, 255.0, 65025.0, 16581375.0) * depth;\nret = fract(ret);\nret -= vec4(ret.yzw, 0.0) / 255.0;\nreturn ret;\n}\nvarying vec2 v_clip_depth;\nvec4 frag () {\nreturn packDepthToRGBA(v_clip_depth.x / v_clip_depth.y * 0.5 + 0.5);\n}\nvoid main() { gl_FragColor = frag(); }", + } + ], + [ + { + "vert": "\nprecision highp float;\nhighp float decode32 (highp vec4 rgba) {\nrgba = rgba * 255.0;\nhighp float Sign = 1.0 - (step(128.0, (rgba[3]) + 0.5)) * 2.0;\nhighp float Exponent = 2.0 * (mod(float(int((rgba[3]) + 0.5)), 128.0)) + (step(128.0, (rgba[2]) + 0.5)) - 127.0;\nhighp float Mantissa = (mod(float(int((rgba[2]) + 0.5)), 128.0)) * 65536.0 + rgba[1] * 256.0 + rgba[0] + 8388608.0;\nreturn Sign * exp2(Exponent - 23.0) * Mantissa;\n}\nstruct StandardVertInput {\nhighp vec4 position;\nvec3 normal;\nvec4 tangent;\n};\nattribute vec3 a_position;\nattribute vec3 a_normal;\nattribute vec2 a_texCoord;\nattribute vec4 a_tangent;\n#if CC_USE_MORPH\nattribute float a_vertexId;\nint getVertexId() {\nreturn int(a_vertexId);\n}\nuniform vec4 cc_displacementWeights[15];\nuniform vec4 cc_displacementTextureInfo;\nvec2 getPixelLocation(vec2 textureResolution, int pixelIndex) {\nfloat pixelIndexF = float(pixelIndex);\nfloat x = mod(pixelIndexF, textureResolution.x);\nfloat y = floor(pixelIndexF / textureResolution.x);\nreturn vec2(x, y);\n}\nvec2 getPixelCoordFromLocation(vec2 location, vec2 textureResolution) {\nreturn (vec2(location.x, location.y) + .5) / textureResolution;\n}\n#if CC_DEVICE_SUPPORT_FLOAT_TEXTURE\nvec4 fetchVec3ArrayFromTexture(sampler2D tex, int elementIndex) {\nint pixelIndex = elementIndex;\nvec2 location = getPixelLocation(cc_displacementTextureInfo.xy, pixelIndex);\nvec2 uv = getPixelCoordFromLocation(location, cc_displacementTextureInfo.xy);\nreturn texture2D(tex, uv);\n}\n#else\nvec4 fetchVec3ArrayFromTexture(sampler2D tex, int elementIndex) {\nint pixelIndex = elementIndex * 4;\nvec2 location = getPixelLocation(cc_displacementTextureInfo.xy, pixelIndex);\nvec2 x = getPixelCoordFromLocation(location + vec2(0.0, 0.0), cc_displacementTextureInfo.xy);\nvec2 y = getPixelCoordFromLocation(location + vec2(1.0, 0.0), cc_displacementTextureInfo.xy);\nvec2 z = getPixelCoordFromLocation(location + vec2(2.0, 0.0), cc_displacementTextureInfo.xy);\nreturn vec4(\ndecode32(texture2D(tex, x)),\ndecode32(texture2D(tex, y)),\ndecode32(texture2D(tex, z)),\n1.0\n);\n}\n#endif\nfloat getDisplacementWeight(int index) {\nint quot = index / 4;\nint remainder = index - quot * 4;\nif (remainder == 0) {\nreturn cc_displacementWeights[quot].x;\n} else if (remainder == 1) {\nreturn cc_displacementWeights[quot].y;\n} else if (remainder == 2) {\nreturn cc_displacementWeights[quot].z;\n} else {\nreturn cc_displacementWeights[quot].w;\n}\n}\nvec3 getVec3DisplacementFromTexture(sampler2D tex, int vertexIndex) {\n#if CC_MORPH_PRECOMPUTED\nreturn fetchVec3ArrayFromTexture(tex, vertexIndex).rgb;\n#else\nvec3 result = vec3(0, 0, 0);\nint nVertices = int(cc_displacementTextureInfo.z);\nfor (int iTarget = 0; iTarget < CC_MORPH_TARGET_COUNT; ++iTarget) {\nresult += (fetchVec3ArrayFromTexture(tex, nVertices * iTarget + vertexIndex).rgb * getDisplacementWeight(iTarget));\n}\nreturn result;\n#endif\n}\n#if CC_MORPH_TARGET_HAS_POSITION\nuniform sampler2D cc_PositionDisplacements;\nvec3 getPositionDisplacement(int vertexId) {\nreturn getVec3DisplacementFromTexture(cc_PositionDisplacements, vertexId);\n}\n#endif\n#if CC_MORPH_TARGET_HAS_NORMAL\nuniform sampler2D cc_NormalDisplacements;\nvec3 getNormalDisplacement(int vertexId) {\nreturn getVec3DisplacementFromTexture(cc_NormalDisplacements, vertexId);\n}\n#endif\n#if CC_MORPH_TARGET_HAS_TANGENT\nuniform sampler2D cc_TangentDisplacements;\nvec3 getTangentDisplacement(int vertexId) {\nreturn getVec3DisplacementFromTexture(cc_TangentDisplacements, vertexId);\n}\n#endif\nvoid applyMorph (inout StandardVertInput attr) {\nint vertexId = getVertexId();\n#if CC_MORPH_TARGET_HAS_POSITION\nattr.position.xyz = attr.position.xyz + getPositionDisplacement(vertexId);\n#endif\n#if CC_MORPH_TARGET_HAS_NORMAL\nattr.normal.xyz = attr.normal.xyz + getNormalDisplacement(vertexId);\n#endif\n#if CC_MORPH_TARGET_HAS_TANGENT\nattr.tangent.xyz = attr.tangent.xyz + getTangentDisplacement(vertexId);\n#endif\n}\nvoid applyMorph (inout vec4 position) {\n#if CC_MORPH_TARGET_HAS_POSITION\nposition.xyz = position.xyz + getPositionDisplacement(getVertexId());\n#endif\n}\n#endif\n#if CC_USE_SKINNING\nattribute vec4 a_joints;\nattribute vec4 a_weights;\n#if CC_USE_BAKED_ANIMATION\n#if USE_INSTANCING\nattribute highp vec4 a_jointAnimInfo;\n#endif\nuniform highp vec4 cc_jointTextureInfo;\nuniform highp vec4 cc_jointAnimInfo;\nuniform highp sampler2D cc_jointTexture;\n#else\nuniform highp vec4 cc_joints[90];\n#endif\n#if CC_USE_BAKED_ANIMATION\n#if CC_DEVICE_SUPPORT_FLOAT_TEXTURE\nmat4 getJointMatrix (float i) {\n#if USE_INSTANCING\nhighp float j = 3.0 * (a_jointAnimInfo.x * a_jointAnimInfo.y + i) + a_jointAnimInfo.z;\n#else\nhighp float j = 3.0 * (cc_jointAnimInfo.x * cc_jointTextureInfo.y + i) + cc_jointTextureInfo.z;\n#endif\nhighp float invSize = cc_jointTextureInfo.w;\nhighp float y = floor(j * invSize);\nhighp float x = floor(j - y * cc_jointTextureInfo.x);\ny = (y + 0.5) * invSize;\nvec4 v1 = texture2D(cc_jointTexture, vec2((x + 0.5) * invSize, y));\nvec4 v2 = texture2D(cc_jointTexture, vec2((x + 1.5) * invSize, y));\nvec4 v3 = texture2D(cc_jointTexture, vec2((x + 2.5) * invSize, y));\nreturn mat4(vec4(v1.xyz, 0.0), vec4(v2.xyz, 0.0), vec4(v3.xyz, 0.0), vec4(v1.w, v2.w, v3.w, 1.0));\n}\n#else\nmat4 getJointMatrix (float i) {\n#if USE_INSTANCING\nhighp float j = 12.0 * (a_jointAnimInfo.x * a_jointAnimInfo.y + i) + a_jointAnimInfo.z;\n#else\nhighp float j = 12.0 * (cc_jointAnimInfo.x * cc_jointTextureInfo.y + i) + cc_jointTextureInfo.z;\n#endif\nhighp float invSize = cc_jointTextureInfo.w;\nhighp float y = floor(j * invSize);\nhighp float x = floor(j - y * cc_jointTextureInfo.x);\ny = (y + 0.5) * invSize;\nvec4 v1 = vec4(\ndecode32(texture2D(cc_jointTexture, vec2((x + 0.5) * invSize, y))),\ndecode32(texture2D(cc_jointTexture, vec2((x + 1.5) * invSize, y))),\ndecode32(texture2D(cc_jointTexture, vec2((x + 2.5) * invSize, y))),\ndecode32(texture2D(cc_jointTexture, vec2((x + 3.5) * invSize, y)))\n);\nvec4 v2 = vec4(\ndecode32(texture2D(cc_jointTexture, vec2((x + 4.5) * invSize, y))),\ndecode32(texture2D(cc_jointTexture, vec2((x + 5.5) * invSize, y))),\ndecode32(texture2D(cc_jointTexture, vec2((x + 6.5) * invSize, y))),\ndecode32(texture2D(cc_jointTexture, vec2((x + 7.5) * invSize, y)))\n);\nvec4 v3 = vec4(\ndecode32(texture2D(cc_jointTexture, vec2((x + 8.5) * invSize, y))),\ndecode32(texture2D(cc_jointTexture, vec2((x + 9.5) * invSize, y))),\ndecode32(texture2D(cc_jointTexture, vec2((x + 10.5) * invSize, y))),\ndecode32(texture2D(cc_jointTexture, vec2((x + 11.5) * invSize, y)))\n);\nreturn mat4(vec4(v1.xyz, 0.0), vec4(v2.xyz, 0.0), vec4(v3.xyz, 0.0), vec4(v1.w, v2.w, v3.w, 1.0));\n}\n#endif\n#else\nmat4 getJointMatrix (float i) {\nint idx = int(i);\nvec4 v1 = cc_joints[idx * 3];\nvec4 v2 = cc_joints[idx * 3 + 1];\nvec4 v3 = cc_joints[idx * 3 + 2];\nreturn mat4(vec4(v1.xyz, 0.0), vec4(v2.xyz, 0.0), vec4(v3.xyz, 0.0), vec4(v1.w, v2.w, v3.w, 1.0));\n}\n#endif\nmat4 skinMatrix () {\nvec4 joints = vec4(a_joints);\nreturn getJointMatrix(joints.x) * a_weights.x\n+ getJointMatrix(joints.y) * a_weights.y\n+ getJointMatrix(joints.z) * a_weights.z\n+ getJointMatrix(joints.w) * a_weights.w;\n}\nvoid CCSkin (inout vec4 position) {\nmat4 m = skinMatrix();\nposition = m * position;\n}\nvoid CCSkin (inout StandardVertInput attr) {\nmat4 m = skinMatrix();\nattr.position = m * attr.position;\nattr.normal = (m * vec4(attr.normal, 0.0)).xyz;\nattr.tangent.xyz = (m * vec4(attr.tangent.xyz, 0.0)).xyz;\n}\n#endif\nuniform highp mat4 cc_matView;\nuniform highp mat4 cc_matProj;\nuniform highp vec4 cc_cameraPos;\nuniform mediump vec4 cc_fogBase;\nuniform mediump vec4 cc_fogAdd;\n#if USE_INSTANCING\nattribute vec4 a_matWorld0;\nattribute vec4 a_matWorld1;\nattribute vec4 a_matWorld2;\n#if USE_LIGHTMAP\nattribute vec4 a_lightingMapUVParam;\n#endif\n#elif USE_BATCHING\nattribute float a_dyn_batch_id;\nuniform highp mat4 cc_matWorlds[10];\n#else\nuniform highp mat4 cc_matWorld;\n#endif\nfloat LinearFog(vec4 pos) {\nvec4 wPos = pos;\nfloat cam_dis = distance(cc_cameraPos, wPos);\nfloat fogStart = cc_fogBase.x;\nfloat fogEnd = cc_fogBase.y;\nreturn clamp((fogEnd - cam_dis) / (fogEnd - fogStart), 0., 1.);\n}\nfloat ExpFog(vec4 pos) {\nvec4 wPos = pos;\nfloat fogAtten = cc_fogAdd.z;\nfloat fogStart = cc_fogBase.x;\nfloat fogDensity = cc_fogBase.z;\nfloat cam_dis = max(distance(cc_cameraPos, wPos) - fogStart, 0.0) / fogAtten * 4.;\nfloat f = exp(-cam_dis * fogDensity);\nreturn f;\n}\nfloat ExpSquaredFog(vec4 pos) {\nvec4 wPos = pos;\nfloat fogAtten = cc_fogAdd.z;\nfloat fogStart = cc_fogBase.x;\nfloat fogDensity = cc_fogBase.z;\nfloat cam_dis = max(distance(cc_cameraPos, wPos) - fogStart, 0.0) / fogAtten * 4.;\nfloat f = exp(-cam_dis * cam_dis * fogDensity * fogDensity);\nreturn f;\n}\nfloat LayeredFog(vec4 pos) {\nvec4 wPos = pos;\nfloat fogAtten = cc_fogAdd.z;\nfloat _FogTop = cc_fogAdd.x;\nfloat _FogRange = cc_fogAdd.y;\nvec3 camWorldProj = cc_cameraPos.xyz;\ncamWorldProj.y = 0.;\nvec3 worldPosProj = wPos.xyz;\nworldPosProj.y = 0.;\nfloat fDeltaD = distance(worldPosProj, camWorldProj) / fogAtten * 2.0;\nfloat fDeltaY, fDensityIntegral;\nif (cc_cameraPos.y > _FogTop) {\nif (wPos.y < _FogTop) {\nfDeltaY = (_FogTop - wPos.y) / _FogRange * 2.0;\nfDensityIntegral = fDeltaY * fDeltaY * 0.5;\n} else {\nfDeltaY = 0.;\nfDensityIntegral = 0.;\n}\n} else {\nif (wPos.y < _FogTop) {\nfloat fDeltaA = (_FogTop - cc_cameraPos.y) / _FogRange * 2.;\nfloat fDeltaB = (_FogTop - wPos.y) / _FogRange * 2.;\nfDeltaY = abs(fDeltaA - fDeltaB);\nfDensityIntegral = abs((fDeltaA * fDeltaA * 0.5) - (fDeltaB * fDeltaB * 0.5));\n} else {\nfDeltaY = abs(_FogTop - cc_cameraPos.y) / _FogRange * 2.;\nfDensityIntegral = abs(fDeltaY * fDeltaY * 0.5);\n}\n}\nfloat fDensity;\nif (fDeltaY != 0.) {\nfDensity = (sqrt(1.0 + ((fDeltaD / fDeltaY) * (fDeltaD / fDeltaY)))) * fDensityIntegral;\n} else {\nfDensity = 0.;\n}\nfloat f = exp(-fDensity);\nreturn f;\n}\nvoid CC_TRANSFER_FOG_BASE(vec4 pos, out float factor)\n{\n#if CC_USE_FOG == 0\nfactor = LinearFog(pos);\n#elif CC_USE_FOG == 1\nfactor = ExpFog(pos);\n#elif CC_USE_FOG == 2\nfactor = ExpSquaredFog(pos);\n#elif CC_USE_FOG == 3\nfactor = LayeredFog(pos);\n#else\nfactor = 1.0;\n#endif\n}\n#if !CC_USE_ACCURATE_FOG\nvarying float v_fog_factor;\n#endif\nvoid CC_TRANSFER_FOG(vec4 pos) {\n#if !CC_USE_ACCURATE_FOG\nCC_TRANSFER_FOG_BASE(pos, v_fog_factor);\n#endif\n}\n#if USE_VERTEX_COLOR\nattribute lowp vec4 a_color;\nvarying lowp vec4 v_color;\n#endif\n#if USE_TEXTURE\nvarying vec2 v_uv;\nuniform vec4 tilingOffset;\n#endif\nvec4 vert () {\nvec4 position;\nposition = vec4(a_position, 1.0);\n#if CC_USE_MORPH\napplyMorph(position);\n#endif\n#if CC_USE_SKINNING\nCCSkin(position);\n#endif\nmat4 matWorld;\n#if USE_INSTANCING\nmatWorld = mat4(\nvec4(a_matWorld0.xyz, 0.0),\nvec4(a_matWorld1.xyz, 0.0),\nvec4(a_matWorld2.xyz, 0.0),\nvec4(a_matWorld0.w, a_matWorld1.w, a_matWorld2.w, 1.0)\n);\n#elif USE_BATCHING\nmatWorld = cc_matWorlds[int(a_dyn_batch_id)];\n#else\nmatWorld = cc_matWorld;\n#endif\n#if USE_TEXTURE\nv_uv = a_texCoord * tilingOffset.xy + tilingOffset.zw;\n#if SAMPLE_FROM_RT\nv_uv = cc_cameraPos.w > 1.0 ? vec2(v_uv.x, 1.0 - v_uv.y) : v_uv;\n#endif\n#endif\n#if USE_VERTEX_COLOR\nv_color = a_color;\n#endif\nCC_TRANSFER_FOG(matWorld * position);\nreturn cc_matProj * (cc_matView * matWorld) * position;\n}\nvoid main() { gl_Position = vert(); }", + "frag": "\nprecision highp float;\nvec3 ACESToneMap (vec3 color) {\ncolor = min(color, vec3(8.0));\nconst float A = 2.51;\nconst float B = 0.03;\nconst float C = 2.43;\nconst float D = 0.59;\nconst float E = 0.14;\nreturn (color * (A * color + B)) / (color * (C * color + D) + E);\n}\nvec3 SRGBToLinear (vec3 gamma) {\nreturn gamma * gamma;\n}\nvec4 CCFragOutput (vec4 color) {\n#if CC_USE_HDR\ncolor.rgb = ACESToneMap(color.rgb);\n#endif\ncolor.rgb = sqrt(color.rgb);\nreturn color;\n}\nuniform highp vec4 cc_cameraPos;\nuniform mediump vec4 cc_fogColor;\nuniform mediump vec4 cc_fogBase;\nuniform mediump vec4 cc_fogAdd;\nfloat LinearFog(vec4 pos) {\nvec4 wPos = pos;\nfloat cam_dis = distance(cc_cameraPos, wPos);\nfloat fogStart = cc_fogBase.x;\nfloat fogEnd = cc_fogBase.y;\nreturn clamp((fogEnd - cam_dis) / (fogEnd - fogStart), 0., 1.);\n}\nfloat ExpFog(vec4 pos) {\nvec4 wPos = pos;\nfloat fogAtten = cc_fogAdd.z;\nfloat fogStart = cc_fogBase.x;\nfloat fogDensity = cc_fogBase.z;\nfloat cam_dis = max(distance(cc_cameraPos, wPos) - fogStart, 0.0) / fogAtten * 4.;\nfloat f = exp(-cam_dis * fogDensity);\nreturn f;\n}\nfloat ExpSquaredFog(vec4 pos) {\nvec4 wPos = pos;\nfloat fogAtten = cc_fogAdd.z;\nfloat fogStart = cc_fogBase.x;\nfloat fogDensity = cc_fogBase.z;\nfloat cam_dis = max(distance(cc_cameraPos, wPos) - fogStart, 0.0) / fogAtten * 4.;\nfloat f = exp(-cam_dis * cam_dis * fogDensity * fogDensity);\nreturn f;\n}\nfloat LayeredFog(vec4 pos) {\nvec4 wPos = pos;\nfloat fogAtten = cc_fogAdd.z;\nfloat _FogTop = cc_fogAdd.x;\nfloat _FogRange = cc_fogAdd.y;\nvec3 camWorldProj = cc_cameraPos.xyz;\ncamWorldProj.y = 0.;\nvec3 worldPosProj = wPos.xyz;\nworldPosProj.y = 0.;\nfloat fDeltaD = distance(worldPosProj, camWorldProj) / fogAtten * 2.0;\nfloat fDeltaY, fDensityIntegral;\nif (cc_cameraPos.y > _FogTop) {\nif (wPos.y < _FogTop) {\nfDeltaY = (_FogTop - wPos.y) / _FogRange * 2.0;\nfDensityIntegral = fDeltaY * fDeltaY * 0.5;\n} else {\nfDeltaY = 0.;\nfDensityIntegral = 0.;\n}\n} else {\nif (wPos.y < _FogTop) {\nfloat fDeltaA = (_FogTop - cc_cameraPos.y) / _FogRange * 2.;\nfloat fDeltaB = (_FogTop - wPos.y) / _FogRange * 2.;\nfDeltaY = abs(fDeltaA - fDeltaB);\nfDensityIntegral = abs((fDeltaA * fDeltaA * 0.5) - (fDeltaB * fDeltaB * 0.5));\n} else {\nfDeltaY = abs(_FogTop - cc_cameraPos.y) / _FogRange * 2.;\nfDensityIntegral = abs(fDeltaY * fDeltaY * 0.5);\n}\n}\nfloat fDensity;\nif (fDeltaY != 0.) {\nfDensity = (sqrt(1.0 + ((fDeltaD / fDeltaY) * (fDeltaD / fDeltaY)))) * fDensityIntegral;\n} else {\nfDensity = 0.;\n}\nfloat f = exp(-fDensity);\nreturn f;\n}\nvoid CC_TRANSFER_FOG_BASE(vec4 pos, out float factor)\n{\n#if CC_USE_FOG == 0\nfactor = LinearFog(pos);\n#elif CC_USE_FOG == 1\nfactor = ExpFog(pos);\n#elif CC_USE_FOG == 2\nfactor = ExpSquaredFog(pos);\n#elif CC_USE_FOG == 3\nfactor = LayeredFog(pos);\n#else\nfactor = 1.0;\n#endif\n}\nvoid CC_APPLY_FOG_BASE(inout vec4 color, float factor) {\ncolor = vec4(mix(cc_fogColor.rgb, color.rgb, factor), color.a);\n}\n#if !CC_USE_ACCURATE_FOG\nvarying float v_fog_factor;\n#endif\nvoid CC_APPLY_FOG(inout vec4 color) {\n#if !CC_USE_ACCURATE_FOG\nCC_APPLY_FOG_BASE(color, v_fog_factor);\n#endif\n}\nvoid CC_APPLY_FOG(inout vec4 color, vec3 worldPos) {\n#if CC_USE_ACCURATE_FOG\nfloat factor;\nCC_TRANSFER_FOG_BASE(vec4(worldPos, 1.0), factor);\n#else\nfloat factor = v_fog_factor;\n#endif\nCC_APPLY_FOG_BASE(color, factor);\n}\n#if USE_ALPHA_TEST\n#endif\n#if USE_TEXTURE\nvarying vec2 v_uv;\nuniform sampler2D mainTexture;\n#endif\nuniform vec4 mainColor;\nuniform vec4 colorScaleAndCutoff;\n#if USE_VERTEX_COLOR\nvarying lowp vec4 v_color;\n#endif\nvec4 frag () {\nvec4 o = mainColor;\no.rgb *= colorScaleAndCutoff.xyz;\n#if USE_VERTEX_COLOR\no.rgb *= SRGBToLinear(v_color.rgb);\no.a *= v_color.a;\n#endif\n#if USE_TEXTURE\nvec4 texColor = texture2D(mainTexture, v_uv);\ntexColor.rgb = SRGBToLinear(texColor.rgb);\no *= texColor;\n#endif\n#if USE_ALPHA_TEST\nif (o.ALPHA_TEST_CHANNEL < colorScaleAndCutoff.w) discard;\n#endif\nCC_APPLY_FOG(o);\nreturn CCFragOutput(o);\n}\nvoid main() { gl_FragColor = frag(); }", + } + ], + [ + { + "vert": "\nprecision highp float;\nhighp float decode32 (highp vec4 rgba) {\nrgba = rgba * 255.0;\nhighp float Sign = 1.0 - (step(128.0, (rgba[3]) + 0.5)) * 2.0;\nhighp float Exponent = 2.0 * (mod(float(int((rgba[3]) + 0.5)), 128.0)) + (step(128.0, (rgba[2]) + 0.5)) - 127.0;\nhighp float Mantissa = (mod(float(int((rgba[2]) + 0.5)), 128.0)) * 65536.0 + rgba[1] * 256.0 + rgba[0] + 8388608.0;\nreturn Sign * exp2(Exponent - 23.0) * Mantissa;\n}\nstruct StandardVertInput {\nhighp vec4 position;\nvec3 normal;\nvec4 tangent;\n};\nattribute vec3 a_position;\nattribute vec3 a_normal;\nattribute vec2 a_texCoord;\nattribute vec4 a_tangent;\n#if CC_USE_MORPH\nattribute float a_vertexId;\nint getVertexId() {\nreturn int(a_vertexId);\n}\nuniform vec4 cc_displacementWeights[15];\nuniform vec4 cc_displacementTextureInfo;\nvec2 getPixelLocation(vec2 textureResolution, int pixelIndex) {\nfloat pixelIndexF = float(pixelIndex);\nfloat x = mod(pixelIndexF, textureResolution.x);\nfloat y = floor(pixelIndexF / textureResolution.x);\nreturn vec2(x, y);\n}\nvec2 getPixelCoordFromLocation(vec2 location, vec2 textureResolution) {\nreturn (vec2(location.x, location.y) + .5) / textureResolution;\n}\n#if CC_DEVICE_SUPPORT_FLOAT_TEXTURE\nvec4 fetchVec3ArrayFromTexture(sampler2D tex, int elementIndex) {\nint pixelIndex = elementIndex;\nvec2 location = getPixelLocation(cc_displacementTextureInfo.xy, pixelIndex);\nvec2 uv = getPixelCoordFromLocation(location, cc_displacementTextureInfo.xy);\nreturn texture2D(tex, uv);\n}\n#else\nvec4 fetchVec3ArrayFromTexture(sampler2D tex, int elementIndex) {\nint pixelIndex = elementIndex * 4;\nvec2 location = getPixelLocation(cc_displacementTextureInfo.xy, pixelIndex);\nvec2 x = getPixelCoordFromLocation(location + vec2(0.0, 0.0), cc_displacementTextureInfo.xy);\nvec2 y = getPixelCoordFromLocation(location + vec2(1.0, 0.0), cc_displacementTextureInfo.xy);\nvec2 z = getPixelCoordFromLocation(location + vec2(2.0, 0.0), cc_displacementTextureInfo.xy);\nreturn vec4(\ndecode32(texture2D(tex, x)),\ndecode32(texture2D(tex, y)),\ndecode32(texture2D(tex, z)),\n1.0\n);\n}\n#endif\nfloat getDisplacementWeight(int index) {\nint quot = index / 4;\nint remainder = index - quot * 4;\nif (remainder == 0) {\nreturn cc_displacementWeights[quot].x;\n} else if (remainder == 1) {\nreturn cc_displacementWeights[quot].y;\n} else if (remainder == 2) {\nreturn cc_displacementWeights[quot].z;\n} else {\nreturn cc_displacementWeights[quot].w;\n}\n}\nvec3 getVec3DisplacementFromTexture(sampler2D tex, int vertexIndex) {\n#if CC_MORPH_PRECOMPUTED\nreturn fetchVec3ArrayFromTexture(tex, vertexIndex).rgb;\n#else\nvec3 result = vec3(0, 0, 0);\nint nVertices = int(cc_displacementTextureInfo.z);\nfor (int iTarget = 0; iTarget < CC_MORPH_TARGET_COUNT; ++iTarget) {\nresult += (fetchVec3ArrayFromTexture(tex, nVertices * iTarget + vertexIndex).rgb * getDisplacementWeight(iTarget));\n}\nreturn result;\n#endif\n}\n#if CC_MORPH_TARGET_HAS_POSITION\nuniform sampler2D cc_PositionDisplacements;\nvec3 getPositionDisplacement(int vertexId) {\nreturn getVec3DisplacementFromTexture(cc_PositionDisplacements, vertexId);\n}\n#endif\n#if CC_MORPH_TARGET_HAS_NORMAL\nuniform sampler2D cc_NormalDisplacements;\nvec3 getNormalDisplacement(int vertexId) {\nreturn getVec3DisplacementFromTexture(cc_NormalDisplacements, vertexId);\n}\n#endif\n#if CC_MORPH_TARGET_HAS_TANGENT\nuniform sampler2D cc_TangentDisplacements;\nvec3 getTangentDisplacement(int vertexId) {\nreturn getVec3DisplacementFromTexture(cc_TangentDisplacements, vertexId);\n}\n#endif\nvoid applyMorph (inout StandardVertInput attr) {\nint vertexId = getVertexId();\n#if CC_MORPH_TARGET_HAS_POSITION\nattr.position.xyz = attr.position.xyz + getPositionDisplacement(vertexId);\n#endif\n#if CC_MORPH_TARGET_HAS_NORMAL\nattr.normal.xyz = attr.normal.xyz + getNormalDisplacement(vertexId);\n#endif\n#if CC_MORPH_TARGET_HAS_TANGENT\nattr.tangent.xyz = attr.tangent.xyz + getTangentDisplacement(vertexId);\n#endif\n}\nvoid applyMorph (inout vec4 position) {\n#if CC_MORPH_TARGET_HAS_POSITION\nposition.xyz = position.xyz + getPositionDisplacement(getVertexId());\n#endif\n}\n#endif\n#if CC_USE_SKINNING\nattribute vec4 a_joints;\nattribute vec4 a_weights;\n#if CC_USE_BAKED_ANIMATION\n#if USE_INSTANCING\nattribute highp vec4 a_jointAnimInfo;\n#endif\nuniform highp vec4 cc_jointTextureInfo;\nuniform highp vec4 cc_jointAnimInfo;\nuniform highp sampler2D cc_jointTexture;\n#else\nuniform highp vec4 cc_joints[90];\n#endif\n#if CC_USE_BAKED_ANIMATION\n#if CC_DEVICE_SUPPORT_FLOAT_TEXTURE\nmat4 getJointMatrix (float i) {\n#if USE_INSTANCING\nhighp float j = 3.0 * (a_jointAnimInfo.x * a_jointAnimInfo.y + i) + a_jointAnimInfo.z;\n#else\nhighp float j = 3.0 * (cc_jointAnimInfo.x * cc_jointTextureInfo.y + i) + cc_jointTextureInfo.z;\n#endif\nhighp float invSize = cc_jointTextureInfo.w;\nhighp float y = floor(j * invSize);\nhighp float x = floor(j - y * cc_jointTextureInfo.x);\ny = (y + 0.5) * invSize;\nvec4 v1 = texture2D(cc_jointTexture, vec2((x + 0.5) * invSize, y));\nvec4 v2 = texture2D(cc_jointTexture, vec2((x + 1.5) * invSize, y));\nvec4 v3 = texture2D(cc_jointTexture, vec2((x + 2.5) * invSize, y));\nreturn mat4(vec4(v1.xyz, 0.0), vec4(v2.xyz, 0.0), vec4(v3.xyz, 0.0), vec4(v1.w, v2.w, v3.w, 1.0));\n}\n#else\nmat4 getJointMatrix (float i) {\n#if USE_INSTANCING\nhighp float j = 12.0 * (a_jointAnimInfo.x * a_jointAnimInfo.y + i) + a_jointAnimInfo.z;\n#else\nhighp float j = 12.0 * (cc_jointAnimInfo.x * cc_jointTextureInfo.y + i) + cc_jointTextureInfo.z;\n#endif\nhighp float invSize = cc_jointTextureInfo.w;\nhighp float y = floor(j * invSize);\nhighp float x = floor(j - y * cc_jointTextureInfo.x);\ny = (y + 0.5) * invSize;\nvec4 v1 = vec4(\ndecode32(texture2D(cc_jointTexture, vec2((x + 0.5) * invSize, y))),\ndecode32(texture2D(cc_jointTexture, vec2((x + 1.5) * invSize, y))),\ndecode32(texture2D(cc_jointTexture, vec2((x + 2.5) * invSize, y))),\ndecode32(texture2D(cc_jointTexture, vec2((x + 3.5) * invSize, y)))\n);\nvec4 v2 = vec4(\ndecode32(texture2D(cc_jointTexture, vec2((x + 4.5) * invSize, y))),\ndecode32(texture2D(cc_jointTexture, vec2((x + 5.5) * invSize, y))),\ndecode32(texture2D(cc_jointTexture, vec2((x + 6.5) * invSize, y))),\ndecode32(texture2D(cc_jointTexture, vec2((x + 7.5) * invSize, y)))\n);\nvec4 v3 = vec4(\ndecode32(texture2D(cc_jointTexture, vec2((x + 8.5) * invSize, y))),\ndecode32(texture2D(cc_jointTexture, vec2((x + 9.5) * invSize, y))),\ndecode32(texture2D(cc_jointTexture, vec2((x + 10.5) * invSize, y))),\ndecode32(texture2D(cc_jointTexture, vec2((x + 11.5) * invSize, y)))\n);\nreturn mat4(vec4(v1.xyz, 0.0), vec4(v2.xyz, 0.0), vec4(v3.xyz, 0.0), vec4(v1.w, v2.w, v3.w, 1.0));\n}\n#endif\n#else\nmat4 getJointMatrix (float i) {\nint idx = int(i);\nvec4 v1 = cc_joints[idx * 3];\nvec4 v2 = cc_joints[idx * 3 + 1];\nvec4 v3 = cc_joints[idx * 3 + 2];\nreturn mat4(vec4(v1.xyz, 0.0), vec4(v2.xyz, 0.0), vec4(v3.xyz, 0.0), vec4(v1.w, v2.w, v3.w, 1.0));\n}\n#endif\nmat4 skinMatrix () {\nvec4 joints = vec4(a_joints);\nreturn getJointMatrix(joints.x) * a_weights.x\n+ getJointMatrix(joints.y) * a_weights.y\n+ getJointMatrix(joints.z) * a_weights.z\n+ getJointMatrix(joints.w) * a_weights.w;\n}\nvoid CCSkin (inout vec4 position) {\nmat4 m = skinMatrix();\nposition = m * position;\n}\nvoid CCSkin (inout StandardVertInput attr) {\nmat4 m = skinMatrix();\nattr.position = m * attr.position;\nattr.normal = (m * vec4(attr.normal, 0.0)).xyz;\nattr.tangent.xyz = (m * vec4(attr.tangent.xyz, 0.0)).xyz;\n}\n#endif\nuniform highp vec4 cc_cameraPos;\nvarying vec2 v_uv;\nvoid main () {\nStandardVertInput In;\nIn.position = vec4(a_position, 1.0);\nIn.normal = a_normal;\nIn.tangent = a_tangent;\n#if CC_USE_MORPH\napplyMorph(In);\n#endif\n#if CC_USE_SKINNING\nCCSkin(In);\n#endif\nIn.position.xy = cc_cameraPos.w == 0.0 ? vec2(In.position.xy.x, -In.position.xy.y) : In.position.xy;\ngl_Position = In.position;\ngl_Position.y = gl_Position.y;\nv_uv = a_texCoord;\n}", + "frag": "\nprecision highp float;\nvec3 SRGBToLinear (vec3 gamma) {\nreturn gamma * gamma;\n}\nvarying vec2 v_uv;\nuniform mediump vec4 texSize;\nuniform sampler2D outputResultMap;\nfloat luminance(vec3 color) {\nreturn dot(color, vec3(0.2126, 0.7152, 0.0722));\n}\nvoid main() {\nvec3 color = texture2D(outputResultMap, v_uv).xyz;\nif (luminance(SRGBToLinear(color)) > texSize.z) {\ngl_FragColor = vec4(color, 1.0);\n} else {\ngl_FragColor = vec4(0.0, 0.0, 0.0, 1.0);\n}\n}", + }, + { + "vert": "\nprecision highp float;\nhighp float decode32 (highp vec4 rgba) {\nrgba = rgba * 255.0;\nhighp float Sign = 1.0 - (step(128.0, (rgba[3]) + 0.5)) * 2.0;\nhighp float Exponent = 2.0 * (mod(float(int((rgba[3]) + 0.5)), 128.0)) + (step(128.0, (rgba[2]) + 0.5)) - 127.0;\nhighp float Mantissa = (mod(float(int((rgba[2]) + 0.5)), 128.0)) * 65536.0 + rgba[1] * 256.0 + rgba[0] + 8388608.0;\nreturn Sign * exp2(Exponent - 23.0) * Mantissa;\n}\nstruct StandardVertInput {\nhighp vec4 position;\nvec3 normal;\nvec4 tangent;\n};\nattribute vec3 a_position;\nattribute vec3 a_normal;\nattribute vec2 a_texCoord;\nattribute vec4 a_tangent;\n#if CC_USE_MORPH\nattribute float a_vertexId;\nint getVertexId() {\nreturn int(a_vertexId);\n}\nuniform vec4 cc_displacementWeights[15];\nuniform vec4 cc_displacementTextureInfo;\nvec2 getPixelLocation(vec2 textureResolution, int pixelIndex) {\nfloat pixelIndexF = float(pixelIndex);\nfloat x = mod(pixelIndexF, textureResolution.x);\nfloat y = floor(pixelIndexF / textureResolution.x);\nreturn vec2(x, y);\n}\nvec2 getPixelCoordFromLocation(vec2 location, vec2 textureResolution) {\nreturn (vec2(location.x, location.y) + .5) / textureResolution;\n}\n#if CC_DEVICE_SUPPORT_FLOAT_TEXTURE\nvec4 fetchVec3ArrayFromTexture(sampler2D tex, int elementIndex) {\nint pixelIndex = elementIndex;\nvec2 location = getPixelLocation(cc_displacementTextureInfo.xy, pixelIndex);\nvec2 uv = getPixelCoordFromLocation(location, cc_displacementTextureInfo.xy);\nreturn texture2D(tex, uv);\n}\n#else\nvec4 fetchVec3ArrayFromTexture(sampler2D tex, int elementIndex) {\nint pixelIndex = elementIndex * 4;\nvec2 location = getPixelLocation(cc_displacementTextureInfo.xy, pixelIndex);\nvec2 x = getPixelCoordFromLocation(location + vec2(0.0, 0.0), cc_displacementTextureInfo.xy);\nvec2 y = getPixelCoordFromLocation(location + vec2(1.0, 0.0), cc_displacementTextureInfo.xy);\nvec2 z = getPixelCoordFromLocation(location + vec2(2.0, 0.0), cc_displacementTextureInfo.xy);\nreturn vec4(\ndecode32(texture2D(tex, x)),\ndecode32(texture2D(tex, y)),\ndecode32(texture2D(tex, z)),\n1.0\n);\n}\n#endif\nfloat getDisplacementWeight(int index) {\nint quot = index / 4;\nint remainder = index - quot * 4;\nif (remainder == 0) {\nreturn cc_displacementWeights[quot].x;\n} else if (remainder == 1) {\nreturn cc_displacementWeights[quot].y;\n} else if (remainder == 2) {\nreturn cc_displacementWeights[quot].z;\n} else {\nreturn cc_displacementWeights[quot].w;\n}\n}\nvec3 getVec3DisplacementFromTexture(sampler2D tex, int vertexIndex) {\n#if CC_MORPH_PRECOMPUTED\nreturn fetchVec3ArrayFromTexture(tex, vertexIndex).rgb;\n#else\nvec3 result = vec3(0, 0, 0);\nint nVertices = int(cc_displacementTextureInfo.z);\nfor (int iTarget = 0; iTarget < CC_MORPH_TARGET_COUNT; ++iTarget) {\nresult += (fetchVec3ArrayFromTexture(tex, nVertices * iTarget + vertexIndex).rgb * getDisplacementWeight(iTarget));\n}\nreturn result;\n#endif\n}\n#if CC_MORPH_TARGET_HAS_POSITION\nuniform sampler2D cc_PositionDisplacements;\nvec3 getPositionDisplacement(int vertexId) {\nreturn getVec3DisplacementFromTexture(cc_PositionDisplacements, vertexId);\n}\n#endif\n#if CC_MORPH_TARGET_HAS_NORMAL\nuniform sampler2D cc_NormalDisplacements;\nvec3 getNormalDisplacement(int vertexId) {\nreturn getVec3DisplacementFromTexture(cc_NormalDisplacements, vertexId);\n}\n#endif\n#if CC_MORPH_TARGET_HAS_TANGENT\nuniform sampler2D cc_TangentDisplacements;\nvec3 getTangentDisplacement(int vertexId) {\nreturn getVec3DisplacementFromTexture(cc_TangentDisplacements, vertexId);\n}\n#endif\nvoid applyMorph (inout StandardVertInput attr) {\nint vertexId = getVertexId();\n#if CC_MORPH_TARGET_HAS_POSITION\nattr.position.xyz = attr.position.xyz + getPositionDisplacement(vertexId);\n#endif\n#if CC_MORPH_TARGET_HAS_NORMAL\nattr.normal.xyz = attr.normal.xyz + getNormalDisplacement(vertexId);\n#endif\n#if CC_MORPH_TARGET_HAS_TANGENT\nattr.tangent.xyz = attr.tangent.xyz + getTangentDisplacement(vertexId);\n#endif\n}\nvoid applyMorph (inout vec4 position) {\n#if CC_MORPH_TARGET_HAS_POSITION\nposition.xyz = position.xyz + getPositionDisplacement(getVertexId());\n#endif\n}\n#endif\n#if CC_USE_SKINNING\nattribute vec4 a_joints;\nattribute vec4 a_weights;\n#if CC_USE_BAKED_ANIMATION\n#if USE_INSTANCING\nattribute highp vec4 a_jointAnimInfo;\n#endif\nuniform highp vec4 cc_jointTextureInfo;\nuniform highp vec4 cc_jointAnimInfo;\nuniform highp sampler2D cc_jointTexture;\n#else\nuniform highp vec4 cc_joints[90];\n#endif\n#if CC_USE_BAKED_ANIMATION\n#if CC_DEVICE_SUPPORT_FLOAT_TEXTURE\nmat4 getJointMatrix (float i) {\n#if USE_INSTANCING\nhighp float j = 3.0 * (a_jointAnimInfo.x * a_jointAnimInfo.y + i) + a_jointAnimInfo.z;\n#else\nhighp float j = 3.0 * (cc_jointAnimInfo.x * cc_jointTextureInfo.y + i) + cc_jointTextureInfo.z;\n#endif\nhighp float invSize = cc_jointTextureInfo.w;\nhighp float y = floor(j * invSize);\nhighp float x = floor(j - y * cc_jointTextureInfo.x);\ny = (y + 0.5) * invSize;\nvec4 v1 = texture2D(cc_jointTexture, vec2((x + 0.5) * invSize, y));\nvec4 v2 = texture2D(cc_jointTexture, vec2((x + 1.5) * invSize, y));\nvec4 v3 = texture2D(cc_jointTexture, vec2((x + 2.5) * invSize, y));\nreturn mat4(vec4(v1.xyz, 0.0), vec4(v2.xyz, 0.0), vec4(v3.xyz, 0.0), vec4(v1.w, v2.w, v3.w, 1.0));\n}\n#else\nmat4 getJointMatrix (float i) {\n#if USE_INSTANCING\nhighp float j = 12.0 * (a_jointAnimInfo.x * a_jointAnimInfo.y + i) + a_jointAnimInfo.z;\n#else\nhighp float j = 12.0 * (cc_jointAnimInfo.x * cc_jointTextureInfo.y + i) + cc_jointTextureInfo.z;\n#endif\nhighp float invSize = cc_jointTextureInfo.w;\nhighp float y = floor(j * invSize);\nhighp float x = floor(j - y * cc_jointTextureInfo.x);\ny = (y + 0.5) * invSize;\nvec4 v1 = vec4(\ndecode32(texture2D(cc_jointTexture, vec2((x + 0.5) * invSize, y))),\ndecode32(texture2D(cc_jointTexture, vec2((x + 1.5) * invSize, y))),\ndecode32(texture2D(cc_jointTexture, vec2((x + 2.5) * invSize, y))),\ndecode32(texture2D(cc_jointTexture, vec2((x + 3.5) * invSize, y)))\n);\nvec4 v2 = vec4(\ndecode32(texture2D(cc_jointTexture, vec2((x + 4.5) * invSize, y))),\ndecode32(texture2D(cc_jointTexture, vec2((x + 5.5) * invSize, y))),\ndecode32(texture2D(cc_jointTexture, vec2((x + 6.5) * invSize, y))),\ndecode32(texture2D(cc_jointTexture, vec2((x + 7.5) * invSize, y)))\n);\nvec4 v3 = vec4(\ndecode32(texture2D(cc_jointTexture, vec2((x + 8.5) * invSize, y))),\ndecode32(texture2D(cc_jointTexture, vec2((x + 9.5) * invSize, y))),\ndecode32(texture2D(cc_jointTexture, vec2((x + 10.5) * invSize, y))),\ndecode32(texture2D(cc_jointTexture, vec2((x + 11.5) * invSize, y)))\n);\nreturn mat4(vec4(v1.xyz, 0.0), vec4(v2.xyz, 0.0), vec4(v3.xyz, 0.0), vec4(v1.w, v2.w, v3.w, 1.0));\n}\n#endif\n#else\nmat4 getJointMatrix (float i) {\nint idx = int(i);\nvec4 v1 = cc_joints[idx * 3];\nvec4 v2 = cc_joints[idx * 3 + 1];\nvec4 v3 = cc_joints[idx * 3 + 2];\nreturn mat4(vec4(v1.xyz, 0.0), vec4(v2.xyz, 0.0), vec4(v3.xyz, 0.0), vec4(v1.w, v2.w, v3.w, 1.0));\n}\n#endif\nmat4 skinMatrix () {\nvec4 joints = vec4(a_joints);\nreturn getJointMatrix(joints.x) * a_weights.x\n+ getJointMatrix(joints.y) * a_weights.y\n+ getJointMatrix(joints.z) * a_weights.z\n+ getJointMatrix(joints.w) * a_weights.w;\n}\nvoid CCSkin (inout vec4 position) {\nmat4 m = skinMatrix();\nposition = m * position;\n}\nvoid CCSkin (inout StandardVertInput attr) {\nmat4 m = skinMatrix();\nattr.position = m * attr.position;\nattr.normal = (m * vec4(attr.normal, 0.0)).xyz;\nattr.tangent.xyz = (m * vec4(attr.tangent.xyz, 0.0)).xyz;\n}\n#endif\nuniform highp vec4 cc_cameraPos;\nvarying vec2 v_uv;\nvoid main () {\nStandardVertInput In;\nIn.position = vec4(a_position, 1.0);\nIn.normal = a_normal;\nIn.tangent = a_tangent;\n#if CC_USE_MORPH\napplyMorph(In);\n#endif\n#if CC_USE_SKINNING\nCCSkin(In);\n#endif\nIn.position.xy = cc_cameraPos.w == 0.0 ? vec2(In.position.xy.x, -In.position.xy.y) : In.position.xy;\ngl_Position = In.position;\ngl_Position.y = gl_Position.y;\nv_uv = a_texCoord;\n}", + "frag": "\nprecision highp float;\nvarying vec2 v_uv;\nuniform mediump vec4 texSize;\nuniform sampler2D bloomTexture;\nvec3 downsample4taps(vec2 uv, vec2 halfpixel) {\nvec3 sum = texture2D(bloomTexture, uv + vec2(-halfpixel.x, halfpixel.y)).xyz;\nsum += texture2D(bloomTexture, uv + vec2(halfpixel.x, halfpixel.y)).xyz;\nsum += texture2D(bloomTexture, uv + vec2(halfpixel.x, -halfpixel.y)).xyz;\nsum += texture2D(bloomTexture, uv + vec2(-halfpixel.x, -halfpixel.y)).xyz;\nreturn sum / 4.0;\n}\nvoid main()\n{\nvec3 result = downsample4taps(v_uv, 1.0 / texSize.xy).rgb;\ngl_FragColor = vec4(result, 1.0);\n}", + }, + { + "vert": "\nprecision highp float;\nhighp float decode32 (highp vec4 rgba) {\nrgba = rgba * 255.0;\nhighp float Sign = 1.0 - (step(128.0, (rgba[3]) + 0.5)) * 2.0;\nhighp float Exponent = 2.0 * (mod(float(int((rgba[3]) + 0.5)), 128.0)) + (step(128.0, (rgba[2]) + 0.5)) - 127.0;\nhighp float Mantissa = (mod(float(int((rgba[2]) + 0.5)), 128.0)) * 65536.0 + rgba[1] * 256.0 + rgba[0] + 8388608.0;\nreturn Sign * exp2(Exponent - 23.0) * Mantissa;\n}\nstruct StandardVertInput {\nhighp vec4 position;\nvec3 normal;\nvec4 tangent;\n};\nattribute vec3 a_position;\nattribute vec3 a_normal;\nattribute vec2 a_texCoord;\nattribute vec4 a_tangent;\n#if CC_USE_MORPH\nattribute float a_vertexId;\nint getVertexId() {\nreturn int(a_vertexId);\n}\nuniform vec4 cc_displacementWeights[15];\nuniform vec4 cc_displacementTextureInfo;\nvec2 getPixelLocation(vec2 textureResolution, int pixelIndex) {\nfloat pixelIndexF = float(pixelIndex);\nfloat x = mod(pixelIndexF, textureResolution.x);\nfloat y = floor(pixelIndexF / textureResolution.x);\nreturn vec2(x, y);\n}\nvec2 getPixelCoordFromLocation(vec2 location, vec2 textureResolution) {\nreturn (vec2(location.x, location.y) + .5) / textureResolution;\n}\n#if CC_DEVICE_SUPPORT_FLOAT_TEXTURE\nvec4 fetchVec3ArrayFromTexture(sampler2D tex, int elementIndex) {\nint pixelIndex = elementIndex;\nvec2 location = getPixelLocation(cc_displacementTextureInfo.xy, pixelIndex);\nvec2 uv = getPixelCoordFromLocation(location, cc_displacementTextureInfo.xy);\nreturn texture2D(tex, uv);\n}\n#else\nvec4 fetchVec3ArrayFromTexture(sampler2D tex, int elementIndex) {\nint pixelIndex = elementIndex * 4;\nvec2 location = getPixelLocation(cc_displacementTextureInfo.xy, pixelIndex);\nvec2 x = getPixelCoordFromLocation(location + vec2(0.0, 0.0), cc_displacementTextureInfo.xy);\nvec2 y = getPixelCoordFromLocation(location + vec2(1.0, 0.0), cc_displacementTextureInfo.xy);\nvec2 z = getPixelCoordFromLocation(location + vec2(2.0, 0.0), cc_displacementTextureInfo.xy);\nreturn vec4(\ndecode32(texture2D(tex, x)),\ndecode32(texture2D(tex, y)),\ndecode32(texture2D(tex, z)),\n1.0\n);\n}\n#endif\nfloat getDisplacementWeight(int index) {\nint quot = index / 4;\nint remainder = index - quot * 4;\nif (remainder == 0) {\nreturn cc_displacementWeights[quot].x;\n} else if (remainder == 1) {\nreturn cc_displacementWeights[quot].y;\n} else if (remainder == 2) {\nreturn cc_displacementWeights[quot].z;\n} else {\nreturn cc_displacementWeights[quot].w;\n}\n}\nvec3 getVec3DisplacementFromTexture(sampler2D tex, int vertexIndex) {\n#if CC_MORPH_PRECOMPUTED\nreturn fetchVec3ArrayFromTexture(tex, vertexIndex).rgb;\n#else\nvec3 result = vec3(0, 0, 0);\nint nVertices = int(cc_displacementTextureInfo.z);\nfor (int iTarget = 0; iTarget < CC_MORPH_TARGET_COUNT; ++iTarget) {\nresult += (fetchVec3ArrayFromTexture(tex, nVertices * iTarget + vertexIndex).rgb * getDisplacementWeight(iTarget));\n}\nreturn result;\n#endif\n}\n#if CC_MORPH_TARGET_HAS_POSITION\nuniform sampler2D cc_PositionDisplacements;\nvec3 getPositionDisplacement(int vertexId) {\nreturn getVec3DisplacementFromTexture(cc_PositionDisplacements, vertexId);\n}\n#endif\n#if CC_MORPH_TARGET_HAS_NORMAL\nuniform sampler2D cc_NormalDisplacements;\nvec3 getNormalDisplacement(int vertexId) {\nreturn getVec3DisplacementFromTexture(cc_NormalDisplacements, vertexId);\n}\n#endif\n#if CC_MORPH_TARGET_HAS_TANGENT\nuniform sampler2D cc_TangentDisplacements;\nvec3 getTangentDisplacement(int vertexId) {\nreturn getVec3DisplacementFromTexture(cc_TangentDisplacements, vertexId);\n}\n#endif\nvoid applyMorph (inout StandardVertInput attr) {\nint vertexId = getVertexId();\n#if CC_MORPH_TARGET_HAS_POSITION\nattr.position.xyz = attr.position.xyz + getPositionDisplacement(vertexId);\n#endif\n#if CC_MORPH_TARGET_HAS_NORMAL\nattr.normal.xyz = attr.normal.xyz + getNormalDisplacement(vertexId);\n#endif\n#if CC_MORPH_TARGET_HAS_TANGENT\nattr.tangent.xyz = attr.tangent.xyz + getTangentDisplacement(vertexId);\n#endif\n}\nvoid applyMorph (inout vec4 position) {\n#if CC_MORPH_TARGET_HAS_POSITION\nposition.xyz = position.xyz + getPositionDisplacement(getVertexId());\n#endif\n}\n#endif\n#if CC_USE_SKINNING\nattribute vec4 a_joints;\nattribute vec4 a_weights;\n#if CC_USE_BAKED_ANIMATION\n#if USE_INSTANCING\nattribute highp vec4 a_jointAnimInfo;\n#endif\nuniform highp vec4 cc_jointTextureInfo;\nuniform highp vec4 cc_jointAnimInfo;\nuniform highp sampler2D cc_jointTexture;\n#else\nuniform highp vec4 cc_joints[90];\n#endif\n#if CC_USE_BAKED_ANIMATION\n#if CC_DEVICE_SUPPORT_FLOAT_TEXTURE\nmat4 getJointMatrix (float i) {\n#if USE_INSTANCING\nhighp float j = 3.0 * (a_jointAnimInfo.x * a_jointAnimInfo.y + i) + a_jointAnimInfo.z;\n#else\nhighp float j = 3.0 * (cc_jointAnimInfo.x * cc_jointTextureInfo.y + i) + cc_jointTextureInfo.z;\n#endif\nhighp float invSize = cc_jointTextureInfo.w;\nhighp float y = floor(j * invSize);\nhighp float x = floor(j - y * cc_jointTextureInfo.x);\ny = (y + 0.5) * invSize;\nvec4 v1 = texture2D(cc_jointTexture, vec2((x + 0.5) * invSize, y));\nvec4 v2 = texture2D(cc_jointTexture, vec2((x + 1.5) * invSize, y));\nvec4 v3 = texture2D(cc_jointTexture, vec2((x + 2.5) * invSize, y));\nreturn mat4(vec4(v1.xyz, 0.0), vec4(v2.xyz, 0.0), vec4(v3.xyz, 0.0), vec4(v1.w, v2.w, v3.w, 1.0));\n}\n#else\nmat4 getJointMatrix (float i) {\n#if USE_INSTANCING\nhighp float j = 12.0 * (a_jointAnimInfo.x * a_jointAnimInfo.y + i) + a_jointAnimInfo.z;\n#else\nhighp float j = 12.0 * (cc_jointAnimInfo.x * cc_jointTextureInfo.y + i) + cc_jointTextureInfo.z;\n#endif\nhighp float invSize = cc_jointTextureInfo.w;\nhighp float y = floor(j * invSize);\nhighp float x = floor(j - y * cc_jointTextureInfo.x);\ny = (y + 0.5) * invSize;\nvec4 v1 = vec4(\ndecode32(texture2D(cc_jointTexture, vec2((x + 0.5) * invSize, y))),\ndecode32(texture2D(cc_jointTexture, vec2((x + 1.5) * invSize, y))),\ndecode32(texture2D(cc_jointTexture, vec2((x + 2.5) * invSize, y))),\ndecode32(texture2D(cc_jointTexture, vec2((x + 3.5) * invSize, y)))\n);\nvec4 v2 = vec4(\ndecode32(texture2D(cc_jointTexture, vec2((x + 4.5) * invSize, y))),\ndecode32(texture2D(cc_jointTexture, vec2((x + 5.5) * invSize, y))),\ndecode32(texture2D(cc_jointTexture, vec2((x + 6.5) * invSize, y))),\ndecode32(texture2D(cc_jointTexture, vec2((x + 7.5) * invSize, y)))\n);\nvec4 v3 = vec4(\ndecode32(texture2D(cc_jointTexture, vec2((x + 8.5) * invSize, y))),\ndecode32(texture2D(cc_jointTexture, vec2((x + 9.5) * invSize, y))),\ndecode32(texture2D(cc_jointTexture, vec2((x + 10.5) * invSize, y))),\ndecode32(texture2D(cc_jointTexture, vec2((x + 11.5) * invSize, y)))\n);\nreturn mat4(vec4(v1.xyz, 0.0), vec4(v2.xyz, 0.0), vec4(v3.xyz, 0.0), vec4(v1.w, v2.w, v3.w, 1.0));\n}\n#endif\n#else\nmat4 getJointMatrix (float i) {\nint idx = int(i);\nvec4 v1 = cc_joints[idx * 3];\nvec4 v2 = cc_joints[idx * 3 + 1];\nvec4 v3 = cc_joints[idx * 3 + 2];\nreturn mat4(vec4(v1.xyz, 0.0), vec4(v2.xyz, 0.0), vec4(v3.xyz, 0.0), vec4(v1.w, v2.w, v3.w, 1.0));\n}\n#endif\nmat4 skinMatrix () {\nvec4 joints = vec4(a_joints);\nreturn getJointMatrix(joints.x) * a_weights.x\n+ getJointMatrix(joints.y) * a_weights.y\n+ getJointMatrix(joints.z) * a_weights.z\n+ getJointMatrix(joints.w) * a_weights.w;\n}\nvoid CCSkin (inout vec4 position) {\nmat4 m = skinMatrix();\nposition = m * position;\n}\nvoid CCSkin (inout StandardVertInput attr) {\nmat4 m = skinMatrix();\nattr.position = m * attr.position;\nattr.normal = (m * vec4(attr.normal, 0.0)).xyz;\nattr.tangent.xyz = (m * vec4(attr.tangent.xyz, 0.0)).xyz;\n}\n#endif\nuniform highp vec4 cc_cameraPos;\nvarying vec2 v_uv;\nvoid main () {\nStandardVertInput In;\nIn.position = vec4(a_position, 1.0);\nIn.normal = a_normal;\nIn.tangent = a_tangent;\n#if CC_USE_MORPH\napplyMorph(In);\n#endif\n#if CC_USE_SKINNING\nCCSkin(In);\n#endif\nIn.position.xy = cc_cameraPos.w == 0.0 ? vec2(In.position.xy.x, -In.position.xy.y) : In.position.xy;\ngl_Position = In.position;\ngl_Position.y = gl_Position.y;\nv_uv = a_texCoord;\n}", + "frag": "\nprecision highp float;\nvarying vec2 v_uv;\nuniform mediump vec4 texSize;\nuniform sampler2D bloomTexture;\nvec3 upsample4taps(vec2 uv, vec2 halfpixel) {\nvec3 sum = texture2D(bloomTexture, uv + vec2(-halfpixel.x, halfpixel.y)).xyz;\nsum += texture2D(bloomTexture, uv + vec2(halfpixel.x, halfpixel.y)).xyz;\nsum += texture2D(bloomTexture, uv + vec2(halfpixel.x, -halfpixel.y)).xyz;\nsum += texture2D(bloomTexture, uv + vec2(-halfpixel.x, -halfpixel.y)).xyz;\nreturn sum / 4.0;\n}\nvoid main() {\nvec3 result = upsample4taps(v_uv, 0.5 / texSize.xy).rgb;\ngl_FragColor = vec4(result, 1.0);\n}", + }, + { + "vert": "\nprecision highp float;\nhighp float decode32 (highp vec4 rgba) {\nrgba = rgba * 255.0;\nhighp float Sign = 1.0 - (step(128.0, (rgba[3]) + 0.5)) * 2.0;\nhighp float Exponent = 2.0 * (mod(float(int((rgba[3]) + 0.5)), 128.0)) + (step(128.0, (rgba[2]) + 0.5)) - 127.0;\nhighp float Mantissa = (mod(float(int((rgba[2]) + 0.5)), 128.0)) * 65536.0 + rgba[1] * 256.0 + rgba[0] + 8388608.0;\nreturn Sign * exp2(Exponent - 23.0) * Mantissa;\n}\nstruct StandardVertInput {\nhighp vec4 position;\nvec3 normal;\nvec4 tangent;\n};\nattribute vec3 a_position;\nattribute vec3 a_normal;\nattribute vec2 a_texCoord;\nattribute vec4 a_tangent;\n#if CC_USE_MORPH\nattribute float a_vertexId;\nint getVertexId() {\nreturn int(a_vertexId);\n}\nuniform vec4 cc_displacementWeights[15];\nuniform vec4 cc_displacementTextureInfo;\nvec2 getPixelLocation(vec2 textureResolution, int pixelIndex) {\nfloat pixelIndexF = float(pixelIndex);\nfloat x = mod(pixelIndexF, textureResolution.x);\nfloat y = floor(pixelIndexF / textureResolution.x);\nreturn vec2(x, y);\n}\nvec2 getPixelCoordFromLocation(vec2 location, vec2 textureResolution) {\nreturn (vec2(location.x, location.y) + .5) / textureResolution;\n}\n#if CC_DEVICE_SUPPORT_FLOAT_TEXTURE\nvec4 fetchVec3ArrayFromTexture(sampler2D tex, int elementIndex) {\nint pixelIndex = elementIndex;\nvec2 location = getPixelLocation(cc_displacementTextureInfo.xy, pixelIndex);\nvec2 uv = getPixelCoordFromLocation(location, cc_displacementTextureInfo.xy);\nreturn texture2D(tex, uv);\n}\n#else\nvec4 fetchVec3ArrayFromTexture(sampler2D tex, int elementIndex) {\nint pixelIndex = elementIndex * 4;\nvec2 location = getPixelLocation(cc_displacementTextureInfo.xy, pixelIndex);\nvec2 x = getPixelCoordFromLocation(location + vec2(0.0, 0.0), cc_displacementTextureInfo.xy);\nvec2 y = getPixelCoordFromLocation(location + vec2(1.0, 0.0), cc_displacementTextureInfo.xy);\nvec2 z = getPixelCoordFromLocation(location + vec2(2.0, 0.0), cc_displacementTextureInfo.xy);\nreturn vec4(\ndecode32(texture2D(tex, x)),\ndecode32(texture2D(tex, y)),\ndecode32(texture2D(tex, z)),\n1.0\n);\n}\n#endif\nfloat getDisplacementWeight(int index) {\nint quot = index / 4;\nint remainder = index - quot * 4;\nif (remainder == 0) {\nreturn cc_displacementWeights[quot].x;\n} else if (remainder == 1) {\nreturn cc_displacementWeights[quot].y;\n} else if (remainder == 2) {\nreturn cc_displacementWeights[quot].z;\n} else {\nreturn cc_displacementWeights[quot].w;\n}\n}\nvec3 getVec3DisplacementFromTexture(sampler2D tex, int vertexIndex) {\n#if CC_MORPH_PRECOMPUTED\nreturn fetchVec3ArrayFromTexture(tex, vertexIndex).rgb;\n#else\nvec3 result = vec3(0, 0, 0);\nint nVertices = int(cc_displacementTextureInfo.z);\nfor (int iTarget = 0; iTarget < CC_MORPH_TARGET_COUNT; ++iTarget) {\nresult += (fetchVec3ArrayFromTexture(tex, nVertices * iTarget + vertexIndex).rgb * getDisplacementWeight(iTarget));\n}\nreturn result;\n#endif\n}\n#if CC_MORPH_TARGET_HAS_POSITION\nuniform sampler2D cc_PositionDisplacements;\nvec3 getPositionDisplacement(int vertexId) {\nreturn getVec3DisplacementFromTexture(cc_PositionDisplacements, vertexId);\n}\n#endif\n#if CC_MORPH_TARGET_HAS_NORMAL\nuniform sampler2D cc_NormalDisplacements;\nvec3 getNormalDisplacement(int vertexId) {\nreturn getVec3DisplacementFromTexture(cc_NormalDisplacements, vertexId);\n}\n#endif\n#if CC_MORPH_TARGET_HAS_TANGENT\nuniform sampler2D cc_TangentDisplacements;\nvec3 getTangentDisplacement(int vertexId) {\nreturn getVec3DisplacementFromTexture(cc_TangentDisplacements, vertexId);\n}\n#endif\nvoid applyMorph (inout StandardVertInput attr) {\nint vertexId = getVertexId();\n#if CC_MORPH_TARGET_HAS_POSITION\nattr.position.xyz = attr.position.xyz + getPositionDisplacement(vertexId);\n#endif\n#if CC_MORPH_TARGET_HAS_NORMAL\nattr.normal.xyz = attr.normal.xyz + getNormalDisplacement(vertexId);\n#endif\n#if CC_MORPH_TARGET_HAS_TANGENT\nattr.tangent.xyz = attr.tangent.xyz + getTangentDisplacement(vertexId);\n#endif\n}\nvoid applyMorph (inout vec4 position) {\n#if CC_MORPH_TARGET_HAS_POSITION\nposition.xyz = position.xyz + getPositionDisplacement(getVertexId());\n#endif\n}\n#endif\n#if CC_USE_SKINNING\nattribute vec4 a_joints;\nattribute vec4 a_weights;\n#if CC_USE_BAKED_ANIMATION\n#if USE_INSTANCING\nattribute highp vec4 a_jointAnimInfo;\n#endif\nuniform highp vec4 cc_jointTextureInfo;\nuniform highp vec4 cc_jointAnimInfo;\nuniform highp sampler2D cc_jointTexture;\n#else\nuniform highp vec4 cc_joints[90];\n#endif\n#if CC_USE_BAKED_ANIMATION\n#if CC_DEVICE_SUPPORT_FLOAT_TEXTURE\nmat4 getJointMatrix (float i) {\n#if USE_INSTANCING\nhighp float j = 3.0 * (a_jointAnimInfo.x * a_jointAnimInfo.y + i) + a_jointAnimInfo.z;\n#else\nhighp float j = 3.0 * (cc_jointAnimInfo.x * cc_jointTextureInfo.y + i) + cc_jointTextureInfo.z;\n#endif\nhighp float invSize = cc_jointTextureInfo.w;\nhighp float y = floor(j * invSize);\nhighp float x = floor(j - y * cc_jointTextureInfo.x);\ny = (y + 0.5) * invSize;\nvec4 v1 = texture2D(cc_jointTexture, vec2((x + 0.5) * invSize, y));\nvec4 v2 = texture2D(cc_jointTexture, vec2((x + 1.5) * invSize, y));\nvec4 v3 = texture2D(cc_jointTexture, vec2((x + 2.5) * invSize, y));\nreturn mat4(vec4(v1.xyz, 0.0), vec4(v2.xyz, 0.0), vec4(v3.xyz, 0.0), vec4(v1.w, v2.w, v3.w, 1.0));\n}\n#else\nmat4 getJointMatrix (float i) {\n#if USE_INSTANCING\nhighp float j = 12.0 * (a_jointAnimInfo.x * a_jointAnimInfo.y + i) + a_jointAnimInfo.z;\n#else\nhighp float j = 12.0 * (cc_jointAnimInfo.x * cc_jointTextureInfo.y + i) + cc_jointTextureInfo.z;\n#endif\nhighp float invSize = cc_jointTextureInfo.w;\nhighp float y = floor(j * invSize);\nhighp float x = floor(j - y * cc_jointTextureInfo.x);\ny = (y + 0.5) * invSize;\nvec4 v1 = vec4(\ndecode32(texture2D(cc_jointTexture, vec2((x + 0.5) * invSize, y))),\ndecode32(texture2D(cc_jointTexture, vec2((x + 1.5) * invSize, y))),\ndecode32(texture2D(cc_jointTexture, vec2((x + 2.5) * invSize, y))),\ndecode32(texture2D(cc_jointTexture, vec2((x + 3.5) * invSize, y)))\n);\nvec4 v2 = vec4(\ndecode32(texture2D(cc_jointTexture, vec2((x + 4.5) * invSize, y))),\ndecode32(texture2D(cc_jointTexture, vec2((x + 5.5) * invSize, y))),\ndecode32(texture2D(cc_jointTexture, vec2((x + 6.5) * invSize, y))),\ndecode32(texture2D(cc_jointTexture, vec2((x + 7.5) * invSize, y)))\n);\nvec4 v3 = vec4(\ndecode32(texture2D(cc_jointTexture, vec2((x + 8.5) * invSize, y))),\ndecode32(texture2D(cc_jointTexture, vec2((x + 9.5) * invSize, y))),\ndecode32(texture2D(cc_jointTexture, vec2((x + 10.5) * invSize, y))),\ndecode32(texture2D(cc_jointTexture, vec2((x + 11.5) * invSize, y)))\n);\nreturn mat4(vec4(v1.xyz, 0.0), vec4(v2.xyz, 0.0), vec4(v3.xyz, 0.0), vec4(v1.w, v2.w, v3.w, 1.0));\n}\n#endif\n#else\nmat4 getJointMatrix (float i) {\nint idx = int(i);\nvec4 v1 = cc_joints[idx * 3];\nvec4 v2 = cc_joints[idx * 3 + 1];\nvec4 v3 = cc_joints[idx * 3 + 2];\nreturn mat4(vec4(v1.xyz, 0.0), vec4(v2.xyz, 0.0), vec4(v3.xyz, 0.0), vec4(v1.w, v2.w, v3.w, 1.0));\n}\n#endif\nmat4 skinMatrix () {\nvec4 joints = vec4(a_joints);\nreturn getJointMatrix(joints.x) * a_weights.x\n+ getJointMatrix(joints.y) * a_weights.y\n+ getJointMatrix(joints.z) * a_weights.z\n+ getJointMatrix(joints.w) * a_weights.w;\n}\nvoid CCSkin (inout vec4 position) {\nmat4 m = skinMatrix();\nposition = m * position;\n}\nvoid CCSkin (inout StandardVertInput attr) {\nmat4 m = skinMatrix();\nattr.position = m * attr.position;\nattr.normal = (m * vec4(attr.normal, 0.0)).xyz;\nattr.tangent.xyz = (m * vec4(attr.tangent.xyz, 0.0)).xyz;\n}\n#endif\nuniform highp vec4 cc_cameraPos;\nvarying vec2 v_uv;\nvoid main () {\nStandardVertInput In;\nIn.position = vec4(a_position, 1.0);\nIn.normal = a_normal;\nIn.tangent = a_tangent;\n#if CC_USE_MORPH\napplyMorph(In);\n#endif\n#if CC_USE_SKINNING\nCCSkin(In);\n#endif\nIn.position.xy = cc_cameraPos.w == 0.0 ? vec2(In.position.xy.x, -In.position.xy.y) : In.position.xy;\ngl_Position = In.position;\ngl_Position.y = gl_Position.y;\nv_uv = a_texCoord;\n}", + "frag": "\nprecision highp float;\nvarying vec2 v_uv;\nuniform mediump vec4 texSize;\nuniform sampler2D outputResultMap;\nuniform sampler2D bloomTexture;\nvoid main() {\nvec4 hdrColor = texture2D(outputResultMap, v_uv);\nvec3 bloomColor = texture2D(bloomTexture, v_uv).rgb;\nvec3 result = hdrColor.rgb + bloomColor * texSize.w * hdrColor.a;\ngl_FragColor = vec4(result, hdrColor.a);\n}", + } + ], + [ + { + "vert": "\nprecision highp float;\nstruct StandardVertInput {\nhighp vec4 position;\nvec3 normal;\nvec4 tangent;\n};\nattribute vec3 a_position;\nattribute vec3 a_normal;\nattribute vec2 a_texCoord;\nattribute vec4 a_tangent;\nuniform highp vec4 cc_cameraPos;\nvarying vec2 v_uv;\nvoid main () {\nvec4 position;\nposition = vec4(a_position, 1.0);\nposition.xy = cc_cameraPos.w == 0.0 ? vec2(position.xy.x, -position.xy.y) : position.xy;\ngl_Position = vec4(position.x, position.y, 1.0, 1.0);\nv_uv = a_texCoord;\n}", + "frag": "\n#ifdef GL_EXT_shader_framebuffer_fetch\n#extension GL_EXT_shader_framebuffer_fetch: enable\n#endif\n#ifdef GL_EXT_shader_texture_lod\n#extension GL_EXT_shader_texture_lod: enable\n#endif\nprecision highp float;\nuniform mediump vec4 cc_screenSize;\nuniform highp mat4 cc_matView;\nuniform highp vec4 cc_cameraPos;\nuniform mediump vec4 cc_mainLitDir;\nuniform mediump vec4 cc_mainLitColor;\nuniform mediump vec4 cc_ambientSky;\nuniform mediump vec4 cc_ambientGround;\nuniform mediump vec4 cc_fogColor;\nuniform mediump vec4 cc_fogBase;\nuniform mediump vec4 cc_fogAdd;\nuniform mediump vec4 cc_nearFar;\nvec3 SRGBToLinear (vec3 gamma) {\nreturn gamma * gamma;\n}\nuniform highp mat4 cc_matLightView;\nuniform highp mat4 cc_matLightViewProj;\nuniform highp vec4 cc_shadowInvProjDepthInfo;\nuniform highp vec4 cc_shadowProjDepthInfo;\nuniform highp vec4 cc_shadowProjInfo;\nuniform lowp vec4 cc_shadowNFLSInfo;\nuniform lowp vec4 cc_shadowWHPBInfo;\nuniform lowp vec4 cc_shadowLPNNInfo;\nfloat CCGetLinearDepthFromViewSpace(vec3 viewPos) {\nfloat dist = length(viewPos);\nreturn (dist - cc_shadowNFLSInfo.x) / (cc_shadowNFLSInfo.y - cc_shadowNFLSInfo.x);\n}\nfloat CCGetLinearDepth(vec3 worldPos) {\nvec4 viewStartPos = cc_matLightView * vec4(worldPos.xyz, 1.0);\nreturn CCGetLinearDepthFromViewSpace(viewStartPos.xyz);\n}\n#if CC_RECEIVE_SHADOW\nuniform highp sampler2D cc_shadowMap;\nuniform highp sampler2D cc_spotLightingMap;\nvec4 ApplyShadowDepthBias_FaceNormal(vec4 shadowPos, vec3 worldNormal)\n{\nvec4 newShadowPos = shadowPos;\nif(cc_shadowLPNNInfo.z > 0.0001)\n{\nvec4 viewNormal = cc_matLightView * vec4(worldNormal, 0.0);\nif(viewNormal.z < 0.1)\nnewShadowPos.xy += viewNormal.xy * cc_shadowProjInfo.xy * cc_shadowLPNNInfo.z * clamp(viewNormal.z, 0.001, 0.1);\n}\nreturn newShadowPos;\n}\nvec4 ApplyShadowDepthBias_Perspective(vec4 shadowPos, float viewspaceDepthBias)\n{\nvec3 viewSpacePos;\nviewSpacePos.xy = shadowPos.xy * cc_shadowProjInfo.zw;\nviewSpacePos.z = shadowPos.z * cc_shadowInvProjDepthInfo.x + shadowPos.w * cc_shadowInvProjDepthInfo.y;\nviewSpacePos.xyz += cc_shadowProjDepthInfo.z * normalize(viewSpacePos.xyz) * viewspaceDepthBias;\nvec4 clipSpacePos;\nclipSpacePos.xy = viewSpacePos.xy * cc_shadowProjInfo.xy;\nclipSpacePos.zw = viewSpacePos.z * cc_shadowProjDepthInfo.xz + vec2(cc_shadowProjDepthInfo.y, 0.0);\nif (cc_shadowNFLSInfo.z > 0.000001) {\nclipSpacePos.z = CCGetLinearDepthFromViewSpace(viewSpacePos.xyz);\nclipSpacePos.z = (clipSpacePos.z * 2.0 - 1.0) * clipSpacePos.w;\n}\nreturn clipSpacePos;\n}\nvec4 ApplyShadowDepthBias_Orthographic(vec4 shadowPos, float viewspaceDepthBias)\n{\nfloat coeffA = cc_shadowProjDepthInfo.x;\nfloat coeffB = cc_shadowProjDepthInfo.y;\nfloat viewSpacePos_z = (shadowPos.z - coeffB) / coeffA;\nviewSpacePos_z += viewspaceDepthBias;\nvec4 result = shadowPos;\nresult.z = viewSpacePos_z * coeffA + coeffB;\nreturn result;\n}\nfloat CCGetShadowFactorHard (vec4 shadowPos) {\nvec4 clipPosNew = ApplyShadowDepthBias_Orthographic(shadowPos, cc_shadowWHPBInfo.w);\nvec3 clipPos = clipPosNew.xyz / clipPosNew.w * 0.5 + 0.5;\nif (clipPos.x < 0.0 || clipPos.x > 1.0 ||\nclipPos.y < 0.0 || clipPos.y > 1.0 ||\nclipPos.z < 0.0 || clipPos.z > 1.0) { return 1.0; }\nclipPos.xy = cc_cameraPos.w == 1.0 ? vec2(clipPos.xy.x, 1.0 - clipPos.xy.y) : clipPos.xy;\nfloat shadow = 0.0;\nfloat closestDepth = 0.0;\nif (cc_shadowLPNNInfo.y > 0.000001) {\nclosestDepth = dot(texture2D(cc_shadowMap, clipPos.xy), vec4(1.0, 1.0 / 255.0, 1.0 / 65025.0, 1.0 / 16581375.0));\n} else {\nclosestDepth = texture2D(cc_shadowMap, clipPos.xy).x;\n}\nshadow = step(clipPos.z, closestDepth);\nreturn shadow;\n}\nfloat CCGetShadowFactorSoft (vec4 shadowPos) {\nvec4 clipPosNew = ApplyShadowDepthBias_Orthographic(shadowPos, cc_shadowWHPBInfo.w);\nvec3 clipPos = clipPosNew.xyz / clipPosNew.w * 0.5 + 0.5;\nif (clipPos.x < 0.0 || clipPos.x > 1.0 ||\nclipPos.y < 0.0 || clipPos.y > 1.0 ||\nclipPos.z < 0.0 || clipPos.z > 1.0) { return 1.0; }\nclipPos.xy = cc_cameraPos.w == 1.0 ? vec2(clipPos.xy.x, 1.0 - clipPos.xy.y) : clipPos.xy;\nfloat offsetDepth = clipPos.z;\nvec2 mapSize = cc_shadowWHPBInfo.xy;\nvec2 oneTap = 1.0 / mapSize;\nvec2 clipPos_offset = clipPos.xy + oneTap;\nfloat block0, block1, block2, block3;\nif (cc_shadowLPNNInfo.y > 0.000001) {\nblock0 = step(offsetDepth, dot(texture2D(cc_shadowMap, vec2(clipPos.x, clipPos.y)), vec4(1.0, 1.0 / 255.0, 1.0 / 65025.0, 1.0 / 16581375.0)));\nblock1 = step(offsetDepth, dot(texture2D(cc_shadowMap, vec2(clipPos_offset.x, clipPos.y)), vec4(1.0, 1.0 / 255.0, 1.0 / 65025.0, 1.0 / 16581375.0)));\nblock2 = step(offsetDepth, dot(texture2D(cc_shadowMap, vec2(clipPos.x, clipPos_offset.y)), vec4(1.0, 1.0 / 255.0, 1.0 / 65025.0, 1.0 / 16581375.0)));\nblock3 = step(offsetDepth, dot(texture2D(cc_shadowMap, vec2(clipPos_offset.x, clipPos_offset.y)), vec4(1.0, 1.0 / 255.0, 1.0 / 65025.0, 1.0 / 16581375.0)));\n} else {\nblock0 = step(offsetDepth, texture2D(cc_shadowMap, vec2(clipPos.x, clipPos.y)).x);\nblock1 = step(offsetDepth, texture2D(cc_shadowMap, vec2(clipPos_offset.x, clipPos.y)).x);\nblock2 = step(offsetDepth, texture2D(cc_shadowMap, vec2(clipPos.x, clipPos_offset.y)).x);\nblock3 = step(offsetDepth, texture2D(cc_shadowMap, vec2(clipPos_offset.x, clipPos_offset.y)).x);\n}\nfloat coefX = mod(clipPos.x, oneTap.x) * mapSize.x;\nfloat resultX = mix(block0, block1, coefX);\nfloat resultY = mix(block2, block3, coefX);\nfloat coefY = mod(clipPos.y, oneTap.y) * mapSize.y;\nreturn mix(resultX, resultY, coefY);\n}\nfloat CCGetShadowFactorSoft2X (vec4 shadowPos) {\nvec4 clipPosNew = ApplyShadowDepthBias_Orthographic(shadowPos, cc_shadowWHPBInfo.w);\nvec3 clipPos = clipPosNew.xyz / clipPosNew.w * 0.5 + 0.5;\nif (clipPos.x < 0.0 || clipPos.x > 1.0 ||\nclipPos.y < 0.0 || clipPos.y > 1.0 ||\nclipPos.z < 0.0 || clipPos.z > 1.0) { return 1.0; }\nclipPos.xy = cc_cameraPos.w == 1.0 ? vec2(clipPos.xy.x, 1.0 - clipPos.xy.y) : clipPos.xy;\nfloat offsetDepth = clipPos.z;\nvec2 mapSize = cc_shadowWHPBInfo.xy;\nvec2 oneTap = 1.0 / mapSize;\nfloat clipPos_offset_L = clipPos.x - oneTap.x;\nfloat clipPos_offset_R = clipPos.x + oneTap.x;\nfloat clipPos_offset_U = clipPos.y - oneTap.y;\nfloat clipPos_offset_D = clipPos.y + oneTap.y;\nfloat block0, block1, block2, block3, block4, block5, block6, block7, block8;\nif (cc_shadowLPNNInfo.y > 0.000001) {\nblock0 = step(offsetDepth, dot(texture2D(cc_shadowMap, vec2(clipPos_offset_L, clipPos_offset_U)), vec4(1.0, 1.0 / 255.0, 1.0 / 65025.0, 1.0 / 16581375.0)));\nblock1 = step(offsetDepth, dot(texture2D(cc_shadowMap, vec2(clipPos.x, clipPos_offset_U)), vec4(1.0, 1.0 / 255.0, 1.0 / 65025.0, 1.0 / 16581375.0)));\nblock2 = step(offsetDepth, dot(texture2D(cc_shadowMap, vec2(clipPos_offset_R, clipPos_offset_U)), vec4(1.0, 1.0 / 255.0, 1.0 / 65025.0, 1.0 / 16581375.0)));\nblock3 = step(offsetDepth, dot(texture2D(cc_shadowMap, vec2(clipPos_offset_L, clipPos.y)), vec4(1.0, 1.0 / 255.0, 1.0 / 65025.0, 1.0 / 16581375.0)));\nblock4 = step(offsetDepth, dot(texture2D(cc_shadowMap, vec2(clipPos.x, clipPos.y)), vec4(1.0, 1.0 / 255.0, 1.0 / 65025.0, 1.0 / 16581375.0)));\nblock5 = step(offsetDepth, dot(texture2D(cc_shadowMap, vec2(clipPos_offset_R, clipPos.y)), vec4(1.0, 1.0 / 255.0, 1.0 / 65025.0, 1.0 / 16581375.0)));\nblock6 = step(offsetDepth, dot(texture2D(cc_shadowMap, vec2(clipPos_offset_L, clipPos_offset_D)), vec4(1.0, 1.0 / 255.0, 1.0 / 65025.0, 1.0 / 16581375.0)));\nblock7 = step(offsetDepth, dot(texture2D(cc_shadowMap, vec2(clipPos.x, clipPos_offset_D)), vec4(1.0, 1.0 / 255.0, 1.0 / 65025.0, 1.0 / 16581375.0)));\nblock8 = step(offsetDepth, dot(texture2D(cc_shadowMap, vec2(clipPos_offset_R, clipPos_offset_D)), vec4(1.0, 1.0 / 255.0, 1.0 / 65025.0, 1.0 / 16581375.0)));\n} else {\nblock0 = step(offsetDepth, texture2D(cc_shadowMap, vec2(clipPos_offset_L, clipPos_offset_U)).x);\nblock1 = step(offsetDepth, texture2D(cc_shadowMap, vec2(clipPos.x, clipPos_offset_U)).x);\nblock2 = step(offsetDepth, texture2D(cc_shadowMap, vec2(clipPos_offset_R, clipPos_offset_U)).x);\nblock3 = step(offsetDepth, texture2D(cc_shadowMap, vec2(clipPos_offset_L, clipPos.y)).x);\nblock4 = step(offsetDepth, texture2D(cc_shadowMap, vec2(clipPos.x, clipPos.y)).x);\nblock5 = step(offsetDepth, texture2D(cc_shadowMap, vec2(clipPos_offset_R, clipPos.y)).x);\nblock6 = step(offsetDepth, texture2D(cc_shadowMap, vec2(clipPos_offset_L, clipPos_offset_D)).x);\nblock7 = step(offsetDepth, texture2D(cc_shadowMap, vec2(clipPos.x, clipPos_offset_D)).x);\nblock8 = step(offsetDepth, texture2D(cc_shadowMap, vec2(clipPos_offset_R, clipPos_offset_D)).x);\n}\nfloat coefX = mod(clipPos.x, oneTap.x) * mapSize.x;\nfloat coefY = mod(clipPos.y, oneTap.y) * mapSize.y;\nfloat shadow = 0.0;\nfloat resultX = mix(block0, block1, coefX);\nfloat resultY = mix(block3, block4, coefX);\nshadow += mix(resultX , resultY, coefY);\nresultX = mix(block1, block2, coefX);\nresultY = mix(block4, block5, coefX);\nshadow += mix(resultX , resultY, coefY);\nresultX = mix(block3, block4, coefX);\nresultY = mix(block6, block7, coefX);\nshadow += mix(resultX, resultY, coefY);\nresultX = mix(block4, block5, coefX);\nresultY = mix(block7, block8, coefX);\nshadow += mix(resultX, resultY, coefY);\nreturn shadow * 0.25;\n}\nfloat CCGetSpotLightShadowFactorHard (vec4 shadowPos, vec3 worldPos) {\nvec4 clipPosNew = ApplyShadowDepthBias_Perspective(shadowPos, cc_shadowWHPBInfo.w);\nvec3 clipPos = clipPosNew.xyz / clipPosNew.w * 0.5 + 0.5;\nif (clipPos.x < 0.0 || clipPos.x > 1.0 ||\nclipPos.y < 0.0 || clipPos.y > 1.0 ||\nclipPos.z < 0.0 || clipPos.z > 1.0) { return 1.0; }\nclipPos.xy = cc_cameraPos.w == 1.0 ? vec2(clipPos.xy.x, 1.0 - clipPos.xy.y) : clipPos.xy;\nfloat shadow = 0.0;\nfloat closestDepth = 0.0;\nfloat depth = clipPos.z;\nif (cc_shadowLPNNInfo.y > 0.000001) {\nclosestDepth = dot(texture2D(cc_spotLightingMap, clipPos.xy), vec4(1.0, 1.0 / 255.0, 1.0 / 65025.0, 1.0 / 16581375.0));\n} else {\nclosestDepth = texture2D(cc_spotLightingMap, clipPos.xy).x;\n}\nshadow = step(depth, closestDepth);\nreturn shadow;\n}\nfloat CCGetSpotLightShadowFactorSoft (vec4 shadowPos, vec3 worldPos) {\nvec4 clipPosNew = ApplyShadowDepthBias_Perspective(shadowPos, cc_shadowWHPBInfo.w);\nvec3 clipPos = clipPosNew.xyz / clipPosNew.w * 0.5 + 0.5;\nif (clipPos.x < 0.0 || clipPos.x > 1.0 ||\nclipPos.y < 0.0 || clipPos.y > 1.0 ||\nclipPos.z < 0.0 || clipPos.z > 1.0) { return 1.0; }\nclipPos.xy = cc_cameraPos.w == 1.0 ? vec2(clipPos.xy.x, 1.0 - clipPos.xy.y) : clipPos.xy;\nfloat depth = 0.0;\nif (cc_shadowNFLSInfo.z > 0.000001) {\ndepth = CCGetLinearDepth(worldPos);\n} else {\ndepth = clipPos.z;\n}\nfloat bias = cc_shadowWHPBInfo.w;\nvec2 oneTap = 1.0 / cc_shadowWHPBInfo.xy;\nvec2 clipPos_offset = clipPos.xy + oneTap;\nfloat block0, block1, block2, block3;\nif (cc_shadowLPNNInfo.y > 0.000001) {\nblock0 = step(depth, dot(texture2D(cc_spotLightingMap, vec2(clipPos.x, clipPos.y)), vec4(1.0, 1.0 / 255.0, 1.0 / 65025.0, 1.0 / 16581375.0)));\nblock1 = step(depth, dot(texture2D(cc_spotLightingMap, vec2(clipPos_offset.x, clipPos.y)), vec4(1.0, 1.0 / 255.0, 1.0 / 65025.0, 1.0 / 16581375.0)));\nblock2 = step(depth, dot(texture2D(cc_spotLightingMap, vec2(clipPos.x, clipPos_offset.y)), vec4(1.0, 1.0 / 255.0, 1.0 / 65025.0, 1.0 / 16581375.0)));\nblock3 = step(depth, dot(texture2D(cc_spotLightingMap, vec2(clipPos_offset.x, clipPos_offset.y)), vec4(1.0, 1.0 / 255.0, 1.0 / 65025.0, 1.0 / 16581375.0)));\n} else {\nblock0 = step(depth, texture2D(cc_spotLightingMap, vec2(clipPos.x, clipPos.y)).x);\nblock1 = step(depth, texture2D(cc_spotLightingMap, vec2(clipPos_offset.x, clipPos.y)).x);\nblock2 = step(depth, texture2D(cc_spotLightingMap, vec2(clipPos.x, clipPos_offset.y)).x);\nblock3 = step(depth, texture2D(cc_spotLightingMap, vec2(clipPos_offset.x, clipPos_offset.y)).x);\n}\nfloat coefX = mod(clipPos.x, oneTap.x) * cc_shadowWHPBInfo.x;\nfloat resultX = mix(block0, block1, coefX);\nfloat resultY = mix(block2, block3, coefX);\nfloat coefY = mod(clipPos.y, oneTap.y) * cc_shadowWHPBInfo.y;\nreturn mix(resultX, resultY, coefY);\n}\nfloat CCGetSpotLightShadowFactorSoft2X (vec4 shadowPos, vec3 worldPos) {\nvec4 clipPosNew = ApplyShadowDepthBias_Perspective(shadowPos, cc_shadowWHPBInfo.w);\nvec3 clipPos = clipPosNew.xyz / clipPosNew.w * 0.5 + 0.5;\nif (clipPos.x < 0.0 || clipPos.x > 1.0 ||\nclipPos.y < 0.0 || clipPos.y > 1.0 ||\nclipPos.z < 0.0 || clipPos.z > 1.0) { return 1.0; }\nclipPos.xy = cc_cameraPos.w == 1.0 ? vec2(clipPos.xy.x, 1.0 - clipPos.xy.y) : clipPos.xy;\nfloat depth = 0.0;\nif (cc_shadowNFLSInfo.z > 0.000001) {\ndepth = CCGetLinearDepth(worldPos);\n} else {\ndepth = clipPos.z;\n}\nfloat bias = cc_shadowWHPBInfo.w;\nvec2 mapSize = cc_shadowWHPBInfo.xy;\nvec2 oneTap = 1.0 / mapSize;\nfloat clipPos_offset_L = clipPos.x - oneTap.x;\nfloat clipPos_offset_R = clipPos.x + oneTap.x;\nfloat clipPos_offset_U = clipPos.y - oneTap.y;\nfloat clipPos_offset_D = clipPos.y + oneTap.y;\nfloat block0, block1, block2, block3, block4, block5, block6, block7, block8;\nif (cc_shadowLPNNInfo.y > 0.000001) {\nblock0 = step(depth, dot(texture2D(cc_spotLightingMap, vec2(clipPos_offset_L, clipPos_offset_U)), vec4(1.0, 1.0 / 255.0, 1.0 / 65025.0, 1.0 / 16581375.0)));\nblock1 = step(depth, dot(texture2D(cc_spotLightingMap, vec2(clipPos.x, clipPos_offset_U)), vec4(1.0, 1.0 / 255.0, 1.0 / 65025.0, 1.0 / 16581375.0)));\nblock2 = step(depth, dot(texture2D(cc_spotLightingMap, vec2(clipPos_offset_R, clipPos_offset_U)), vec4(1.0, 1.0 / 255.0, 1.0 / 65025.0, 1.0 / 16581375.0)));\nblock3 = step(depth, dot(texture2D(cc_spotLightingMap, vec2(clipPos_offset_L, clipPos.y)), vec4(1.0, 1.0 / 255.0, 1.0 / 65025.0, 1.0 / 16581375.0)));\nblock4 = step(depth, dot(texture2D(cc_spotLightingMap, vec2(clipPos.x, clipPos.y)), vec4(1.0, 1.0 / 255.0, 1.0 / 65025.0, 1.0 / 16581375.0)));\nblock5 = step(depth, dot(texture2D(cc_spotLightingMap, vec2(clipPos_offset_R, clipPos.y)), vec4(1.0, 1.0 / 255.0, 1.0 / 65025.0, 1.0 / 16581375.0)));\nblock6 = step(depth, dot(texture2D(cc_spotLightingMap, vec2(clipPos_offset_L, clipPos_offset_D)), vec4(1.0, 1.0 / 255.0, 1.0 / 65025.0, 1.0 / 16581375.0)));\nblock7 = step(depth, dot(texture2D(cc_spotLightingMap, vec2(clipPos.x, clipPos_offset_D)), vec4(1.0, 1.0 / 255.0, 1.0 / 65025.0, 1.0 / 16581375.0)));\nblock8 = step(depth, dot(texture2D(cc_spotLightingMap, vec2(clipPos_offset_R, clipPos_offset_D)), vec4(1.0, 1.0 / 255.0, 1.0 / 65025.0, 1.0 / 16581375.0)));\n} else {\nblock0 = step(depth, texture2D(cc_spotLightingMap, vec2(clipPos_offset_L, clipPos_offset_U)).x);\nblock1 = step(depth, texture2D(cc_spotLightingMap, vec2(clipPos.x, clipPos_offset_U)).x);\nblock2 = step(depth, texture2D(cc_spotLightingMap, vec2(clipPos_offset_R, clipPos_offset_U)).x);\nblock3 = step(depth, texture2D(cc_spotLightingMap, vec2(clipPos_offset_L, clipPos.y)).x);\nblock4 = step(depth, texture2D(cc_spotLightingMap, vec2(clipPos.x, clipPos.y)).x);\nblock5 = step(depth, texture2D(cc_spotLightingMap, vec2(clipPos_offset_R, clipPos.y)).x);\nblock6 = step(depth, texture2D(cc_spotLightingMap, vec2(clipPos_offset_L, clipPos_offset_D)).x);\nblock7 = step(depth, texture2D(cc_spotLightingMap, vec2(clipPos.x, clipPos_offset_D)).x);\nblock8 = step(depth, texture2D(cc_spotLightingMap, vec2(clipPos_offset_R, clipPos_offset_D)).x);\n}\nfloat coefX = mod(clipPos.x, oneTap.x) * mapSize.x;\nfloat coefY = mod(clipPos.y, oneTap.y) * mapSize.y;\nfloat shadow = 0.0;\nfloat resultX = mix(block0, block1, coefX);\nfloat resultY = mix(block3, block4, coefX);\nshadow += mix(resultX , resultY, coefY);\nresultX = mix(block1, block2, coefX);\nresultY = mix(block4, block5, coefX);\nshadow += mix(resultX , resultY, coefY);\nresultX = mix(block3, block4, coefX);\nresultY = mix(block6, block7, coefX);\nshadow += mix(resultX, resultY, coefY);\nresultX = mix(block4, block5, coefX);\nresultY = mix(block7, block8, coefX);\nshadow += mix(resultX, resultY, coefY);\nreturn shadow * 0.25;\n}\n#endif\n#if CC_USE_IBL\nuniform samplerCube cc_environment;\nvec4 fragTextureLod (sampler2D tex, vec2 coord, float lod) {\n#ifdef GL_EXT_shader_texture_lod\nreturn texture2DLodEXT(tex, coord, lod);\n#else\nreturn texture2D(tex, coord, lod);\n#endif\n}\nvec4 fragTextureLod (samplerCube tex, vec3 coord, float lod) {\n#ifdef GL_EXT_shader_texture_lod\nreturn textureCubeLodEXT(tex, coord, lod);\n#else\nreturn textureCube(tex, coord, lod);\n#endif\n}\nvec3 unpackRGBE (vec4 rgbe) {\nreturn rgbe.rgb * pow(1.1, rgbe.a * 255.0 - 128.0);\n}\n#if CC_USE_DIFFUSEMAP\nuniform samplerCube cc_diffuseMap;\n#endif\n#endif\nfloat GGXMobile (float roughness, float NoH, vec3 H, vec3 N) {\nvec3 NxH = cross(N, H);\nfloat OneMinusNoHSqr = dot(NxH, NxH);\nfloat a = roughness * roughness;\nfloat n = NoH * a;\nfloat p = a / (OneMinusNoHSqr + n * n);\nreturn p * p;\n}\nfloat CalcSpecular (float roughness, float NoH, vec3 H, vec3 N) {\nreturn (roughness * 0.25 + 0.25) * GGXMobile(roughness, NoH, H, N);\n}\nvec3 BRDFApprox (vec3 specular, float roughness, float NoV) {\nconst vec4 c0 = vec4(-1.0, -0.0275, -0.572, 0.022);\nconst vec4 c1 = vec4(1.0, 0.0425, 1.04, -0.04);\nvec4 r = roughness * c0 + c1;\nfloat a004 = min(r.x * r.x, exp2(-9.28 * NoV)) * r.x + r.y;\nvec2 AB = vec2(-1.04, 1.04) * a004 + r.zw;\nAB.y *= clamp(50.0 * specular.g, 0.0, 1.0);\nreturn specular * AB.x + AB.y;\n}\n#if USE_REFLECTION_DENOISE\nvec3 GetEnvReflectionWithMipFiltering(vec3 R, float roughness, float mipCount, float denoiseIntensity) {\n#if CC_USE_IBL\nfloat mip = roughness * mipCount;\nfloat delta = (dot(dFdx(R), dFdy(R))) * 1000.0;\nfloat mipBias = mix(0.0, 5.0, clamp(delta, 0.0, 1.0));\nvec4 biased = fragTextureLod(cc_environment, R, mip + mipBias);\nvec4 filtered = textureCube(cc_environment, R);\n#if CC_USE_IBL == 2\nbiased.rgb = unpackRGBE(biased);\nfiltered.rgb = unpackRGBE(filtered);\n#else\nbiased.rgb = SRGBToLinear(biased.rgb);\nfiltered.rgb = SRGBToLinear(filtered.rgb);\n#endif\nreturn mix(biased.rgb, filtered.rgb, denoiseIntensity);\n#else\nreturn vec3(0.0, 0.0, 0.0);\n#endif\n}\n#endif\nstruct StandardSurface {\nvec4 albedo;\nvec3 position;\nvec3 normal;\nvec3 emissive;\nvec3 lightmap;\nfloat lightmap_test;\nfloat roughness;\nfloat metallic;\nfloat occlusion;\n};\nvec4 CCStandardShadingBase (StandardSurface s, vec4 shadowPos) {\nvec3 diffuse = s.albedo.rgb * (1.0 - s.metallic);\nvec3 specular = mix(vec3(0.04), s.albedo.rgb, s.metallic);\nvec3 N = normalize(s.normal);\nvec3 V = normalize(cc_cameraPos.xyz - s.position);\nfloat NV = max(abs(dot(N, V)), 0.0);\nspecular = BRDFApprox(specular, s.roughness, NV);\nvec3 L = normalize(-cc_mainLitDir.xyz);\nvec3 H = normalize(L + V);\nfloat NH = max(dot(N, H), 0.0);\nfloat NL = max(dot(N, L), 0.0);\nvec3 finalColor = NL * cc_mainLitColor.rgb * cc_mainLitColor.w;\nvec3 diffuseContrib = diffuse;\n#if USE_LIGHTMAP && !USE_BATCHING && !CC_FORWARD_ADD\nif (s.lightmap_test > 0.0001) {\nfinalColor = s.lightmap.rgb;\n}\n#else\ndiffuseContrib /= 3.14159265359;\n#endif\nvec3 specularContrib = specular * CalcSpecular(s.roughness, NH, H, N);\nvec3 dirlightContrib = (diffuseContrib + specularContrib);\nfloat shadow = 1.0;\n#if CC_RECEIVE_SHADOW && CC_ENABLE_DIR_SHADOW\nif (NL > 0.0) {\n{\nvec4 pos = ApplyShadowDepthBias_FaceNormal(shadowPos, N);\nfloat pcf = cc_shadowWHPBInfo.z;\nif (pcf > 1.9) shadow = CCGetShadowFactorSoft2X(pos);\nelse if (pcf > 0.9) shadow = CCGetShadowFactorSoft(pos);\nelse shadow = CCGetShadowFactorHard(pos);\nshadow = mix(shadow, 1.0, cc_shadowNFLSInfo.w);\n}\n}\n#endif\ndirlightContrib *= shadow;\nfinalColor *= dirlightContrib;\nfloat fAmb = 0.5 - N.y * 0.5;\nvec3 ambDiff = mix(cc_ambientSky.rgb, cc_ambientGround.rgb, fAmb);\n#if CC_USE_IBL\n#if CC_USE_DIFFUSEMAP\nvec4 diffuseMap = textureCube(cc_diffuseMap, N);\n#if CC_USE_DIFFUSEMAP == 2\nambDiff = unpackRGBE(diffuseMap);\n#else\nambDiff = SRGBToLinear(diffuseMap.rgb);\n#endif\n#endif\nvec3 R = normalize(reflect(-V, N));\n#if USE_REFLECTION_DENOISE\nvec3 env = GetEnvReflectionWithMipFiltering(R, s.roughness, cc_ambientGround.w, 0.6);\n#else\nvec4 envmap = fragTextureLod(cc_environment, R, s.roughness * cc_ambientGround.w);\n#if CC_USE_IBL == 2\nvec3 env = unpackRGBE(envmap);\n#else\nvec3 env = SRGBToLinear(envmap.rgb);\n#endif\n#endif\nfinalColor += env * cc_ambientSky.w * specular * s.occlusion;\n#endif\nfinalColor += ambDiff.rgb * cc_ambientSky.w * diffuse * s.occlusion;\nfinalColor += s.emissive;\nreturn vec4(finalColor, s.albedo.a);\n}\n#if CC_PIPELINE_TYPE == 0\n# define LIGHTS_PER_PASS 1\n#else\n# define LIGHTS_PER_PASS 10\n#endif\n#if CC_ENABLE_CLUSTERED_LIGHT_CULLING == 0\nuniform highp vec4 cc_lightPos[LIGHTS_PER_PASS];\nuniform vec4 cc_lightColor[LIGHTS_PER_PASS];\nuniform vec4 cc_lightSizeRangeAngle[LIGHTS_PER_PASS];\nuniform vec4 cc_lightDir[LIGHTS_PER_PASS];\n#endif\nfloat SmoothDistAtt (float distSqr, float invSqrAttRadius) {\nfloat factor = distSqr * invSqrAttRadius;\nfloat smoothFactor = clamp(1.0 - factor * factor, 0.0, 1.0);\nreturn smoothFactor * smoothFactor;\n}\nfloat GetDistAtt (float distSqr, float invSqrAttRadius) {\nfloat attenuation = 1.0 / max(distSqr, 0.01*0.01);\nattenuation *= SmoothDistAtt(distSqr , invSqrAttRadius);\nreturn attenuation;\n}\nfloat GetAngleAtt (vec3 L, vec3 litDir, float litAngleScale, float litAngleOffset) {\nfloat cd = dot(litDir, L);\nfloat attenuation = clamp(cd * litAngleScale + litAngleOffset, 0.0, 1.0);\nreturn (attenuation * attenuation);\n}\n#if CC_ENABLE_CLUSTERED_LIGHT_CULLING == 0\nvec4 CCStandardShadingAdditive (StandardSurface s, vec4 shadowPos) {\nvec3 diffuse = s.albedo.rgb * (1.0 - s.metallic);\nvec3 specular = mix(vec3(0.04), s.albedo.rgb, s.metallic);\nvec3 diffuseContrib = diffuse / 3.14159265359;\nvec3 N = normalize(s.normal);\nvec3 V = normalize(cc_cameraPos.xyz - s.position);\nfloat NV = max(abs(dot(N, V)), 0.0);\nspecular = BRDFApprox(specular, s.roughness, NV);\nvec3 finalColor = vec3(0.0);\nint numLights = CC_PIPELINE_TYPE == 0 ? LIGHTS_PER_PASS : int(cc_lightDir[0].w);\nfor (int i = 0; i < LIGHTS_PER_PASS; i++) {\nif (i >= numLights) break;\nvec3 SLU = cc_lightPos[i].xyz - s.position;\nvec3 SL = normalize(SLU);\nvec3 SH = normalize(SL + V);\nfloat SNL = max(dot(N, SL), 0.0);\nfloat SNH = max(dot(N, SH), 0.0);\nfloat distSqr = dot(SLU, SLU);\nfloat litRadius = cc_lightSizeRangeAngle[i].x;\nfloat litRadiusSqr = litRadius * litRadius;\nfloat illum = 3.14159265359 * (litRadiusSqr / max(litRadiusSqr , distSqr));\nfloat attRadiusSqrInv = 1.0 / max(cc_lightSizeRangeAngle[i].y, 0.01);\nattRadiusSqrInv *= attRadiusSqrInv;\nfloat att = GetDistAtt(distSqr, attRadiusSqrInv);\nvec3 lspec = specular * CalcSpecular(s.roughness, SNH, SH, N);\nif (cc_lightPos[i].w > 0.0) {\nfloat cosInner = max(dot(-cc_lightDir[i].xyz, SL), 0.01);\nfloat cosOuter = cc_lightSizeRangeAngle[i].z;\nfloat litAngleScale = 1.0 / max(0.001, cosInner - cosOuter);\nfloat litAngleOffset = -cosOuter * litAngleScale;\natt *= GetAngleAtt(SL, -cc_lightDir[i].xyz, litAngleScale, litAngleOffset);\n}\nvec3 lightColor = cc_lightColor[i].rgb;\nfloat shadow = 1.0;\n#if CC_RECEIVE_SHADOW\nif (cc_lightPos[i].w > 0.0 && cc_lightSizeRangeAngle[i].w > 0.0) {\n{\nfloat pcf = cc_shadowWHPBInfo.z;\nif (pcf > 1.9) shadow = CCGetSpotLightShadowFactorSoft2X(shadowPos, s.position);\nelse if (pcf > 0.9) shadow = CCGetSpotLightShadowFactorSoft(shadowPos, s.position);\nelse shadow = CCGetSpotLightShadowFactorHard(shadowPos, s.position);\n}\n}\n#endif\nlightColor *= shadow;\nfinalColor += SNL * lightColor * cc_lightColor[i].w * illum * att * (diffuseContrib + lspec);\n}\nreturn vec4(finalColor, 0.0);\n}\n#endif\n#if CC_ENABLE_CLUSTERED_LIGHT_CULLING == 1\nreadonly buffer b_ccLightsBuffer { vec4 b_ccLights[]; };\nreadonly buffer b_clusterLightIndicesBuffer { uint b_clusterLightIndices[]; };\nreadonly buffer b_clusterLightGridBuffer { uvec4 b_clusterLightGrid[]; };\nstruct CCLight\n{\nvec4 cc_lightPos;\nvec4 cc_lightColor;\nvec4 cc_lightSizeRangeAngle;\nvec4 cc_lightDir;\n};\nstruct Cluster\n{\nvec3 minBounds;\nvec3 maxBounds;\n};\nstruct LightGrid\n{\nuint offset;\nuint ccLights;\n};\nCCLight getCCLight(uint i)\n{\nCCLight light;\nlight.cc_lightPos = b_ccLights[4u * i + 0u];\nlight.cc_lightColor = b_ccLights[4u * i + 1u];\nlight.cc_lightSizeRangeAngle = b_ccLights[4u * i + 2u];\nlight.cc_lightDir = b_ccLights[4u * i + 3u];\nreturn light;\n}\nLightGrid getLightGrid(uint cluster)\n{\nuvec4 gridvec = b_clusterLightGrid[cluster];\nLightGrid grid;\ngrid.offset = gridvec.x;\ngrid.ccLights = gridvec.y;\nreturn grid;\n}\nuint getGridLightIndex(uint start, uint offset)\n{\nreturn b_clusterLightIndices[start + offset];\n}\nuint getClusterZIndex(vec4 worldPos)\n{\nfloat scale = float(24) / log(cc_nearFar.y / cc_nearFar.x);\nfloat bias = -(float(24) * log(cc_nearFar.x) / log(cc_nearFar.y / cc_nearFar.x));\nfloat eyeDepth = -(cc_matView * worldPos).z;\nuint zIndex = uint(max(log(eyeDepth) * scale + bias, 0.0));\nreturn zIndex;\n}\nuint getClusterIndex(vec4 fragCoord, vec4 worldPos)\n{\nuint zIndex = getClusterZIndex(worldPos);\nfloat clusterSizeX = ceil(cc_screenSize.x / float(16));\nfloat clusterSizeY = ceil(cc_screenSize.y / float(8));\nuvec3 indices = uvec3(uvec2(fragCoord.xy / vec2(clusterSizeX, clusterSizeY)), zIndex);\nuint cluster = (16u * 8u) * indices.z + 16u * indices.y + indices.x;\nreturn cluster;\n}\nvec4 CCClusterShadingAdditive (StandardSurface s, vec4 shadowPos) {\nvec3 diffuse = s.albedo.rgb * (1.0 - s.metallic);\nvec3 specular = mix(vec3(0.04), s.albedo.rgb, s.metallic);\nvec3 diffuseContrib = diffuse / 3.14159265359;\nvec3 N = normalize(s.normal);\nvec3 V = normalize(cc_cameraPos.xyz - s.position);\nfloat NV = max(abs(dot(N, V)), 0.001);\nspecular = BRDFApprox(specular, s.roughness, NV);\nvec3 finalColor = vec3(0.0);\nuint cluster = getClusterIndex(gl_FragCoord, vec4(s.position, 1.0));\nLightGrid grid = getLightGrid(cluster);\nuint numLights = grid.ccLights;\nfor (uint i = 0u; i < 100u; i++) {\nif (i >= numLights) break;\nuint lightIndex = getGridLightIndex(grid.offset, i);\nCCLight light = getCCLight(lightIndex);\nvec3 SLU = light.cc_lightPos.xyz - s.position;\nvec3 SL = normalize(SLU);\nvec3 SH = normalize(SL + V);\nfloat SNL = max(dot(N, SL), 0.001);\nfloat SNH = max(dot(N, SH), 0.0);\nfloat distSqr = dot(SLU, SLU);\nfloat litRadius = light.cc_lightSizeRangeAngle.x;\nfloat litRadiusSqr = litRadius * litRadius;\nfloat illum = 3.14159265359 * (litRadiusSqr / max(litRadiusSqr , distSqr));\nfloat attRadiusSqrInv = 1.0 / max(light.cc_lightSizeRangeAngle.y, 0.01);\nattRadiusSqrInv *= attRadiusSqrInv;\nfloat att = GetDistAtt(distSqr, attRadiusSqrInv);\nvec3 lspec = specular * CalcSpecular(s.roughness, SNH, SH, N);\nif (light.cc_lightPos.w > 0.0) {\nfloat cosInner = max(dot(-light.cc_lightDir.xyz, SL), 0.01);\nfloat cosOuter = light.cc_lightSizeRangeAngle.z;\nfloat litAngleScale = 1.0 / max(0.001, cosInner - cosOuter);\nfloat litAngleOffset = -cosOuter * litAngleScale;\natt *= GetAngleAtt(SL, -light.cc_lightDir.xyz, litAngleScale, litAngleOffset);\n}\nvec3 lightColor = light.cc_lightColor.rgb;\nfloat shadow = 1.0;\n#if CC_RECEIVE_SHADOW\nif (light.cc_lightPos.w > 0.0) {\n{\nfloat pcf = cc_shadowWHPBInfo.z;\nif (pcf > 1.9) shadow = CCGetSpotLightShadowFactorSoft2X(shadowPos, s.position);\nelse if (pcf > 0.9) shadow = CCGetSpotLightShadowFactorSoft(shadowPos, s.position);\nelse shadow = CCGetSpotLightShadowFactorHard(shadowPos, s.position);\n}\n}\n#endif\nlightColor *= shadow;\nfinalColor += SNL * lightColor * light.cc_lightColor.w * illum * att * (diffuseContrib + lspec);\n}\nreturn vec4(finalColor, 0.0);\n}\n#endif\nvec3 ACESToneMap (vec3 color) {\ncolor = min(color, vec3(8.0));\nconst float A = 2.51;\nconst float B = 0.03;\nconst float C = 2.43;\nconst float D = 0.59;\nconst float E = 0.14;\nreturn (color * (A * color + B)) / (color * (C * color + D) + E);\n}\nvec4 CCFragOutput (vec4 color) {\n#if CC_USE_HDR\ncolor.rgb = ACESToneMap(color.rgb);\n#endif\ncolor.rgb = sqrt(color.rgb);\nreturn color;\n}\nfloat LinearFog(vec4 pos) {\nvec4 wPos = pos;\nfloat cam_dis = distance(cc_cameraPos, wPos);\nfloat fogStart = cc_fogBase.x;\nfloat fogEnd = cc_fogBase.y;\nreturn clamp((fogEnd - cam_dis) / (fogEnd - fogStart), 0., 1.);\n}\nfloat ExpFog(vec4 pos) {\nvec4 wPos = pos;\nfloat fogAtten = cc_fogAdd.z;\nfloat fogStart = cc_fogBase.x;\nfloat fogDensity = cc_fogBase.z;\nfloat cam_dis = max(distance(cc_cameraPos, wPos) - fogStart, 0.0) / fogAtten * 4.;\nfloat f = exp(-cam_dis * fogDensity);\nreturn f;\n}\nfloat ExpSquaredFog(vec4 pos) {\nvec4 wPos = pos;\nfloat fogAtten = cc_fogAdd.z;\nfloat fogStart = cc_fogBase.x;\nfloat fogDensity = cc_fogBase.z;\nfloat cam_dis = max(distance(cc_cameraPos, wPos) - fogStart, 0.0) / fogAtten * 4.;\nfloat f = exp(-cam_dis * cam_dis * fogDensity * fogDensity);\nreturn f;\n}\nfloat LayeredFog(vec4 pos) {\nvec4 wPos = pos;\nfloat fogAtten = cc_fogAdd.z;\nfloat _FogTop = cc_fogAdd.x;\nfloat _FogRange = cc_fogAdd.y;\nvec3 camWorldProj = cc_cameraPos.xyz;\ncamWorldProj.y = 0.;\nvec3 worldPosProj = wPos.xyz;\nworldPosProj.y = 0.;\nfloat fDeltaD = distance(worldPosProj, camWorldProj) / fogAtten * 2.0;\nfloat fDeltaY, fDensityIntegral;\nif (cc_cameraPos.y > _FogTop) {\nif (wPos.y < _FogTop) {\nfDeltaY = (_FogTop - wPos.y) / _FogRange * 2.0;\nfDensityIntegral = fDeltaY * fDeltaY * 0.5;\n} else {\nfDeltaY = 0.;\nfDensityIntegral = 0.;\n}\n} else {\nif (wPos.y < _FogTop) {\nfloat fDeltaA = (_FogTop - cc_cameraPos.y) / _FogRange * 2.;\nfloat fDeltaB = (_FogTop - wPos.y) / _FogRange * 2.;\nfDeltaY = abs(fDeltaA - fDeltaB);\nfDensityIntegral = abs((fDeltaA * fDeltaA * 0.5) - (fDeltaB * fDeltaB * 0.5));\n} else {\nfDeltaY = abs(_FogTop - cc_cameraPos.y) / _FogRange * 2.;\nfDensityIntegral = abs(fDeltaY * fDeltaY * 0.5);\n}\n}\nfloat fDensity;\nif (fDeltaY != 0.) {\nfDensity = (sqrt(1.0 + ((fDeltaD / fDeltaY) * (fDeltaD / fDeltaY)))) * fDensityIntegral;\n} else {\nfDensity = 0.;\n}\nfloat f = exp(-fDensity);\nreturn f;\n}\nvoid CC_TRANSFER_FOG_BASE(vec4 pos, out float factor)\n{\n#if CC_USE_FOG == 0\nfactor = LinearFog(pos);\n#elif CC_USE_FOG == 1\nfactor = ExpFog(pos);\n#elif CC_USE_FOG == 2\nfactor = ExpSquaredFog(pos);\n#elif CC_USE_FOG == 3\nfactor = LayeredFog(pos);\n#else\nfactor = 1.0;\n#endif\n}\nvoid CC_APPLY_FOG_BASE(inout vec4 color, float factor) {\ncolor = vec4(mix(cc_fogColor.rgb, color.rgb, factor), color.a);\n}\nvarying vec2 v_uv;\n#if CC_DEVICE_CAN_BENEFIT_FROM_INPUT_ATTACHMENT\n#else\nuniform sampler2D gbuffer_albedoMap;\nuniform sampler2D gbuffer_positionMap;\nuniform sampler2D gbuffer_normalMap;\nuniform sampler2D gbuffer_emissiveMap;\n#endif\n#if !CC_DEVICE_CAN_BENEFIT_FROM_INPUT_ATTACHMENT || __VERSION__ >= 450\n#endif\nvoid main () {\nStandardSurface s;\n#if CC_DEVICE_CAN_BENEFIT_FROM_INPUT_ATTACHMENT\nvec4 albedoMap = gl_LastFragData[0];\nvec4 positionMap = gl_LastFragData[1];\nvec4 normalMap = gl_LastFragData[2];\nvec4 emissiveMap = gl_LastFragData[3];\n#else\nvec4 albedoMap = texture2D(gbuffer_albedoMap,v_uv);\nvec4 positionMap = texture2D(gbuffer_positionMap,v_uv);\nvec4 normalMap = texture2D(gbuffer_normalMap,v_uv);\nvec4 emissiveMap = texture2D(gbuffer_emissiveMap,v_uv);\n#endif\ns.albedo = albedoMap;\ns.position = positionMap.xyz;\ns.roughness = positionMap.w;\ns.normal = normalMap.xyz;\ns.metallic = normalMap.w;\ns.emissive = emissiveMap.xyz;\ns.occlusion = emissiveMap.w;\nfloat fogFactor;\nCC_TRANSFER_FOG_BASE(vec4(s.position, 1), fogFactor);\nvec4 shadowPos;\nshadowPos = cc_matLightViewProj * vec4(s.position, 1);\nvec4 color = CCStandardShadingBase(s, shadowPos) +\n#if CC_ENABLE_CLUSTERED_LIGHT_CULLING == 1\nCCClusterShadingAdditive(s, shadowPos);\n#else\nCCStandardShadingAdditive(s, shadowPos);\n#endif\nCC_APPLY_FOG_BASE(color, fogFactor);\ncolor = CCFragOutput(color);\n#if CC_DEVICE_CAN_BENEFIT_FROM_INPUT_ATTACHMENT\ngl_FragData[3] = color;\n#else\ngl_FragColor = color;\n#endif\n}", + } + ], + [ + { + "vert": "\nprecision highp float;\nhighp float decode32 (highp vec4 rgba) {\nrgba = rgba * 255.0;\nhighp float Sign = 1.0 - (step(128.0, (rgba[3]) + 0.5)) * 2.0;\nhighp float Exponent = 2.0 * (mod(float(int((rgba[3]) + 0.5)), 128.0)) + (step(128.0, (rgba[2]) + 0.5)) - 127.0;\nhighp float Mantissa = (mod(float(int((rgba[2]) + 0.5)), 128.0)) * 65536.0 + rgba[1] * 256.0 + rgba[0] + 8388608.0;\nreturn Sign * exp2(Exponent - 23.0) * Mantissa;\n}\nstruct StandardVertInput {\nhighp vec4 position;\nvec3 normal;\nvec4 tangent;\n};\nattribute vec3 a_position;\nattribute vec3 a_normal;\nattribute vec2 a_texCoord;\nattribute vec4 a_tangent;\n#if CC_USE_MORPH\nattribute float a_vertexId;\nint getVertexId() {\nreturn int(a_vertexId);\n}\nuniform vec4 cc_displacementWeights[15];\nuniform vec4 cc_displacementTextureInfo;\nvec2 getPixelLocation(vec2 textureResolution, int pixelIndex) {\nfloat pixelIndexF = float(pixelIndex);\nfloat x = mod(pixelIndexF, textureResolution.x);\nfloat y = floor(pixelIndexF / textureResolution.x);\nreturn vec2(x, y);\n}\nvec2 getPixelCoordFromLocation(vec2 location, vec2 textureResolution) {\nreturn (vec2(location.x, location.y) + .5) / textureResolution;\n}\n#if CC_DEVICE_SUPPORT_FLOAT_TEXTURE\nvec4 fetchVec3ArrayFromTexture(sampler2D tex, int elementIndex) {\nint pixelIndex = elementIndex;\nvec2 location = getPixelLocation(cc_displacementTextureInfo.xy, pixelIndex);\nvec2 uv = getPixelCoordFromLocation(location, cc_displacementTextureInfo.xy);\nreturn texture2D(tex, uv);\n}\n#else\nvec4 fetchVec3ArrayFromTexture(sampler2D tex, int elementIndex) {\nint pixelIndex = elementIndex * 4;\nvec2 location = getPixelLocation(cc_displacementTextureInfo.xy, pixelIndex);\nvec2 x = getPixelCoordFromLocation(location + vec2(0.0, 0.0), cc_displacementTextureInfo.xy);\nvec2 y = getPixelCoordFromLocation(location + vec2(1.0, 0.0), cc_displacementTextureInfo.xy);\nvec2 z = getPixelCoordFromLocation(location + vec2(2.0, 0.0), cc_displacementTextureInfo.xy);\nreturn vec4(\ndecode32(texture2D(tex, x)),\ndecode32(texture2D(tex, y)),\ndecode32(texture2D(tex, z)),\n1.0\n);\n}\n#endif\nfloat getDisplacementWeight(int index) {\nint quot = index / 4;\nint remainder = index - quot * 4;\nif (remainder == 0) {\nreturn cc_displacementWeights[quot].x;\n} else if (remainder == 1) {\nreturn cc_displacementWeights[quot].y;\n} else if (remainder == 2) {\nreturn cc_displacementWeights[quot].z;\n} else {\nreturn cc_displacementWeights[quot].w;\n}\n}\nvec3 getVec3DisplacementFromTexture(sampler2D tex, int vertexIndex) {\n#if CC_MORPH_PRECOMPUTED\nreturn fetchVec3ArrayFromTexture(tex, vertexIndex).rgb;\n#else\nvec3 result = vec3(0, 0, 0);\nint nVertices = int(cc_displacementTextureInfo.z);\nfor (int iTarget = 0; iTarget < CC_MORPH_TARGET_COUNT; ++iTarget) {\nresult += (fetchVec3ArrayFromTexture(tex, nVertices * iTarget + vertexIndex).rgb * getDisplacementWeight(iTarget));\n}\nreturn result;\n#endif\n}\n#if CC_MORPH_TARGET_HAS_POSITION\nuniform sampler2D cc_PositionDisplacements;\nvec3 getPositionDisplacement(int vertexId) {\nreturn getVec3DisplacementFromTexture(cc_PositionDisplacements, vertexId);\n}\n#endif\n#if CC_MORPH_TARGET_HAS_NORMAL\nuniform sampler2D cc_NormalDisplacements;\nvec3 getNormalDisplacement(int vertexId) {\nreturn getVec3DisplacementFromTexture(cc_NormalDisplacements, vertexId);\n}\n#endif\n#if CC_MORPH_TARGET_HAS_TANGENT\nuniform sampler2D cc_TangentDisplacements;\nvec3 getTangentDisplacement(int vertexId) {\nreturn getVec3DisplacementFromTexture(cc_TangentDisplacements, vertexId);\n}\n#endif\nvoid applyMorph (inout StandardVertInput attr) {\nint vertexId = getVertexId();\n#if CC_MORPH_TARGET_HAS_POSITION\nattr.position.xyz = attr.position.xyz + getPositionDisplacement(vertexId);\n#endif\n#if CC_MORPH_TARGET_HAS_NORMAL\nattr.normal.xyz = attr.normal.xyz + getNormalDisplacement(vertexId);\n#endif\n#if CC_MORPH_TARGET_HAS_TANGENT\nattr.tangent.xyz = attr.tangent.xyz + getTangentDisplacement(vertexId);\n#endif\n}\nvoid applyMorph (inout vec4 position) {\n#if CC_MORPH_TARGET_HAS_POSITION\nposition.xyz = position.xyz + getPositionDisplacement(getVertexId());\n#endif\n}\n#endif\n#if CC_USE_SKINNING\nattribute vec4 a_joints;\nattribute vec4 a_weights;\n#if CC_USE_BAKED_ANIMATION\n#if USE_INSTANCING\nattribute highp vec4 a_jointAnimInfo;\n#endif\nuniform highp vec4 cc_jointTextureInfo;\nuniform highp vec4 cc_jointAnimInfo;\nuniform highp sampler2D cc_jointTexture;\n#else\nuniform highp vec4 cc_joints[90];\n#endif\n#if CC_USE_BAKED_ANIMATION\n#if CC_DEVICE_SUPPORT_FLOAT_TEXTURE\nmat4 getJointMatrix (float i) {\n#if USE_INSTANCING\nhighp float j = 3.0 * (a_jointAnimInfo.x * a_jointAnimInfo.y + i) + a_jointAnimInfo.z;\n#else\nhighp float j = 3.0 * (cc_jointAnimInfo.x * cc_jointTextureInfo.y + i) + cc_jointTextureInfo.z;\n#endif\nhighp float invSize = cc_jointTextureInfo.w;\nhighp float y = floor(j * invSize);\nhighp float x = floor(j - y * cc_jointTextureInfo.x);\ny = (y + 0.5) * invSize;\nvec4 v1 = texture2D(cc_jointTexture, vec2((x + 0.5) * invSize, y));\nvec4 v2 = texture2D(cc_jointTexture, vec2((x + 1.5) * invSize, y));\nvec4 v3 = texture2D(cc_jointTexture, vec2((x + 2.5) * invSize, y));\nreturn mat4(vec4(v1.xyz, 0.0), vec4(v2.xyz, 0.0), vec4(v3.xyz, 0.0), vec4(v1.w, v2.w, v3.w, 1.0));\n}\n#else\nmat4 getJointMatrix (float i) {\n#if USE_INSTANCING\nhighp float j = 12.0 * (a_jointAnimInfo.x * a_jointAnimInfo.y + i) + a_jointAnimInfo.z;\n#else\nhighp float j = 12.0 * (cc_jointAnimInfo.x * cc_jointTextureInfo.y + i) + cc_jointTextureInfo.z;\n#endif\nhighp float invSize = cc_jointTextureInfo.w;\nhighp float y = floor(j * invSize);\nhighp float x = floor(j - y * cc_jointTextureInfo.x);\ny = (y + 0.5) * invSize;\nvec4 v1 = vec4(\ndecode32(texture2D(cc_jointTexture, vec2((x + 0.5) * invSize, y))),\ndecode32(texture2D(cc_jointTexture, vec2((x + 1.5) * invSize, y))),\ndecode32(texture2D(cc_jointTexture, vec2((x + 2.5) * invSize, y))),\ndecode32(texture2D(cc_jointTexture, vec2((x + 3.5) * invSize, y)))\n);\nvec4 v2 = vec4(\ndecode32(texture2D(cc_jointTexture, vec2((x + 4.5) * invSize, y))),\ndecode32(texture2D(cc_jointTexture, vec2((x + 5.5) * invSize, y))),\ndecode32(texture2D(cc_jointTexture, vec2((x + 6.5) * invSize, y))),\ndecode32(texture2D(cc_jointTexture, vec2((x + 7.5) * invSize, y)))\n);\nvec4 v3 = vec4(\ndecode32(texture2D(cc_jointTexture, vec2((x + 8.5) * invSize, y))),\ndecode32(texture2D(cc_jointTexture, vec2((x + 9.5) * invSize, y))),\ndecode32(texture2D(cc_jointTexture, vec2((x + 10.5) * invSize, y))),\ndecode32(texture2D(cc_jointTexture, vec2((x + 11.5) * invSize, y)))\n);\nreturn mat4(vec4(v1.xyz, 0.0), vec4(v2.xyz, 0.0), vec4(v3.xyz, 0.0), vec4(v1.w, v2.w, v3.w, 1.0));\n}\n#endif\n#else\nmat4 getJointMatrix (float i) {\nint idx = int(i);\nvec4 v1 = cc_joints[idx * 3];\nvec4 v2 = cc_joints[idx * 3 + 1];\nvec4 v3 = cc_joints[idx * 3 + 2];\nreturn mat4(vec4(v1.xyz, 0.0), vec4(v2.xyz, 0.0), vec4(v3.xyz, 0.0), vec4(v1.w, v2.w, v3.w, 1.0));\n}\n#endif\nmat4 skinMatrix () {\nvec4 joints = vec4(a_joints);\nreturn getJointMatrix(joints.x) * a_weights.x\n+ getJointMatrix(joints.y) * a_weights.y\n+ getJointMatrix(joints.z) * a_weights.z\n+ getJointMatrix(joints.w) * a_weights.w;\n}\nvoid CCSkin (inout vec4 position) {\nmat4 m = skinMatrix();\nposition = m * position;\n}\nvoid CCSkin (inout StandardVertInput attr) {\nmat4 m = skinMatrix();\nattr.position = m * attr.position;\nattr.normal = (m * vec4(attr.normal, 0.0)).xyz;\nattr.tangent.xyz = (m * vec4(attr.tangent.xyz, 0.0)).xyz;\n}\n#endif\nuniform highp mat4 cc_matView;\nuniform highp mat4 cc_matProj;\n#if USE_INSTANCING\nattribute vec4 a_matWorld0;\nattribute vec4 a_matWorld1;\nattribute vec4 a_matWorld2;\n#if USE_LIGHTMAP\nattribute vec4 a_lightingMapUVParam;\n#endif\n#elif USE_BATCHING\nattribute float a_dyn_batch_id;\nuniform highp mat4 cc_matWorlds[10];\n#else\nuniform highp mat4 cc_matWorld;\n#endif\nuniform highp mat4 cc_matLightPlaneProj;\nvec4 vert () {\nvec4 position;\nposition = vec4(a_position, 1.0);\n#if CC_USE_MORPH\napplyMorph(position);\n#endif\n#if CC_USE_SKINNING\nCCSkin(position);\n#endif\nmat4 matWorld;\n#if USE_INSTANCING\nmatWorld = mat4(\nvec4(a_matWorld0.xyz, 0.0),\nvec4(a_matWorld1.xyz, 0.0),\nvec4(a_matWorld2.xyz, 0.0),\nvec4(a_matWorld0.w, a_matWorld1.w, a_matWorld2.w, 1.0)\n);\n#elif USE_BATCHING\nmatWorld = cc_matWorlds[int(a_dyn_batch_id)];\n#else\nmatWorld = cc_matWorld;\n#endif\nposition = cc_matProj * (cc_matView * cc_matLightPlaneProj * matWorld) * position;\nposition.z -= 0.0001;\nreturn position;\n}\nvoid main() { gl_Position = vert(); }", + "frag": "\nprecision mediump float;\nuniform lowp vec4 cc_shadowColor;\nvec4 CCFragOutput (vec4 color) {\nreturn color;\n}\nvec4 frag () {\nreturn CCFragOutput(cc_shadowColor);\n}\nvoid main() { gl_FragColor = frag(); }", + } + ], + [ + { + "vert": "\nprecision highp float;\nhighp float decode32 (highp vec4 rgba) {\nrgba = rgba * 255.0;\nhighp float Sign = 1.0 - (step(128.0, (rgba[3]) + 0.5)) * 2.0;\nhighp float Exponent = 2.0 * (mod(float(int((rgba[3]) + 0.5)), 128.0)) + (step(128.0, (rgba[2]) + 0.5)) - 127.0;\nhighp float Mantissa = (mod(float(int((rgba[2]) + 0.5)), 128.0)) * 65536.0 + rgba[1] * 256.0 + rgba[0] + 8388608.0;\nreturn Sign * exp2(Exponent - 23.0) * Mantissa;\n}\nstruct StandardVertInput {\nhighp vec4 position;\nvec3 normal;\nvec4 tangent;\n};\nattribute vec3 a_position;\nattribute vec3 a_normal;\nattribute vec2 a_texCoord;\nattribute vec4 a_tangent;\n#if CC_USE_MORPH\nattribute float a_vertexId;\nint getVertexId() {\nreturn int(a_vertexId);\n}\nuniform vec4 cc_displacementWeights[15];\nuniform vec4 cc_displacementTextureInfo;\nvec2 getPixelLocation(vec2 textureResolution, int pixelIndex) {\nfloat pixelIndexF = float(pixelIndex);\nfloat x = mod(pixelIndexF, textureResolution.x);\nfloat y = floor(pixelIndexF / textureResolution.x);\nreturn vec2(x, y);\n}\nvec2 getPixelCoordFromLocation(vec2 location, vec2 textureResolution) {\nreturn (vec2(location.x, location.y) + .5) / textureResolution;\n}\n#if CC_DEVICE_SUPPORT_FLOAT_TEXTURE\nvec4 fetchVec3ArrayFromTexture(sampler2D tex, int elementIndex) {\nint pixelIndex = elementIndex;\nvec2 location = getPixelLocation(cc_displacementTextureInfo.xy, pixelIndex);\nvec2 uv = getPixelCoordFromLocation(location, cc_displacementTextureInfo.xy);\nreturn texture2D(tex, uv);\n}\n#else\nvec4 fetchVec3ArrayFromTexture(sampler2D tex, int elementIndex) {\nint pixelIndex = elementIndex * 4;\nvec2 location = getPixelLocation(cc_displacementTextureInfo.xy, pixelIndex);\nvec2 x = getPixelCoordFromLocation(location + vec2(0.0, 0.0), cc_displacementTextureInfo.xy);\nvec2 y = getPixelCoordFromLocation(location + vec2(1.0, 0.0), cc_displacementTextureInfo.xy);\nvec2 z = getPixelCoordFromLocation(location + vec2(2.0, 0.0), cc_displacementTextureInfo.xy);\nreturn vec4(\ndecode32(texture2D(tex, x)),\ndecode32(texture2D(tex, y)),\ndecode32(texture2D(tex, z)),\n1.0\n);\n}\n#endif\nfloat getDisplacementWeight(int index) {\nint quot = index / 4;\nint remainder = index - quot * 4;\nif (remainder == 0) {\nreturn cc_displacementWeights[quot].x;\n} else if (remainder == 1) {\nreturn cc_displacementWeights[quot].y;\n} else if (remainder == 2) {\nreturn cc_displacementWeights[quot].z;\n} else {\nreturn cc_displacementWeights[quot].w;\n}\n}\nvec3 getVec3DisplacementFromTexture(sampler2D tex, int vertexIndex) {\n#if CC_MORPH_PRECOMPUTED\nreturn fetchVec3ArrayFromTexture(tex, vertexIndex).rgb;\n#else\nvec3 result = vec3(0, 0, 0);\nint nVertices = int(cc_displacementTextureInfo.z);\nfor (int iTarget = 0; iTarget < CC_MORPH_TARGET_COUNT; ++iTarget) {\nresult += (fetchVec3ArrayFromTexture(tex, nVertices * iTarget + vertexIndex).rgb * getDisplacementWeight(iTarget));\n}\nreturn result;\n#endif\n}\n#if CC_MORPH_TARGET_HAS_POSITION\nuniform sampler2D cc_PositionDisplacements;\nvec3 getPositionDisplacement(int vertexId) {\nreturn getVec3DisplacementFromTexture(cc_PositionDisplacements, vertexId);\n}\n#endif\n#if CC_MORPH_TARGET_HAS_NORMAL\nuniform sampler2D cc_NormalDisplacements;\nvec3 getNormalDisplacement(int vertexId) {\nreturn getVec3DisplacementFromTexture(cc_NormalDisplacements, vertexId);\n}\n#endif\n#if CC_MORPH_TARGET_HAS_TANGENT\nuniform sampler2D cc_TangentDisplacements;\nvec3 getTangentDisplacement(int vertexId) {\nreturn getVec3DisplacementFromTexture(cc_TangentDisplacements, vertexId);\n}\n#endif\nvoid applyMorph (inout StandardVertInput attr) {\nint vertexId = getVertexId();\n#if CC_MORPH_TARGET_HAS_POSITION\nattr.position.xyz = attr.position.xyz + getPositionDisplacement(vertexId);\n#endif\n#if CC_MORPH_TARGET_HAS_NORMAL\nattr.normal.xyz = attr.normal.xyz + getNormalDisplacement(vertexId);\n#endif\n#if CC_MORPH_TARGET_HAS_TANGENT\nattr.tangent.xyz = attr.tangent.xyz + getTangentDisplacement(vertexId);\n#endif\n}\nvoid applyMorph (inout vec4 position) {\n#if CC_MORPH_TARGET_HAS_POSITION\nposition.xyz = position.xyz + getPositionDisplacement(getVertexId());\n#endif\n}\n#endif\n#if CC_USE_SKINNING\nattribute vec4 a_joints;\nattribute vec4 a_weights;\n#if CC_USE_BAKED_ANIMATION\n#if USE_INSTANCING\nattribute highp vec4 a_jointAnimInfo;\n#endif\nuniform highp vec4 cc_jointTextureInfo;\nuniform highp vec4 cc_jointAnimInfo;\nuniform highp sampler2D cc_jointTexture;\n#else\nuniform highp vec4 cc_joints[90];\n#endif\n#if CC_USE_BAKED_ANIMATION\n#if CC_DEVICE_SUPPORT_FLOAT_TEXTURE\nmat4 getJointMatrix (float i) {\n#if USE_INSTANCING\nhighp float j = 3.0 * (a_jointAnimInfo.x * a_jointAnimInfo.y + i) + a_jointAnimInfo.z;\n#else\nhighp float j = 3.0 * (cc_jointAnimInfo.x * cc_jointTextureInfo.y + i) + cc_jointTextureInfo.z;\n#endif\nhighp float invSize = cc_jointTextureInfo.w;\nhighp float y = floor(j * invSize);\nhighp float x = floor(j - y * cc_jointTextureInfo.x);\ny = (y + 0.5) * invSize;\nvec4 v1 = texture2D(cc_jointTexture, vec2((x + 0.5) * invSize, y));\nvec4 v2 = texture2D(cc_jointTexture, vec2((x + 1.5) * invSize, y));\nvec4 v3 = texture2D(cc_jointTexture, vec2((x + 2.5) * invSize, y));\nreturn mat4(vec4(v1.xyz, 0.0), vec4(v2.xyz, 0.0), vec4(v3.xyz, 0.0), vec4(v1.w, v2.w, v3.w, 1.0));\n}\n#else\nmat4 getJointMatrix (float i) {\n#if USE_INSTANCING\nhighp float j = 12.0 * (a_jointAnimInfo.x * a_jointAnimInfo.y + i) + a_jointAnimInfo.z;\n#else\nhighp float j = 12.0 * (cc_jointAnimInfo.x * cc_jointTextureInfo.y + i) + cc_jointTextureInfo.z;\n#endif\nhighp float invSize = cc_jointTextureInfo.w;\nhighp float y = floor(j * invSize);\nhighp float x = floor(j - y * cc_jointTextureInfo.x);\ny = (y + 0.5) * invSize;\nvec4 v1 = vec4(\ndecode32(texture2D(cc_jointTexture, vec2((x + 0.5) * invSize, y))),\ndecode32(texture2D(cc_jointTexture, vec2((x + 1.5) * invSize, y))),\ndecode32(texture2D(cc_jointTexture, vec2((x + 2.5) * invSize, y))),\ndecode32(texture2D(cc_jointTexture, vec2((x + 3.5) * invSize, y)))\n);\nvec4 v2 = vec4(\ndecode32(texture2D(cc_jointTexture, vec2((x + 4.5) * invSize, y))),\ndecode32(texture2D(cc_jointTexture, vec2((x + 5.5) * invSize, y))),\ndecode32(texture2D(cc_jointTexture, vec2((x + 6.5) * invSize, y))),\ndecode32(texture2D(cc_jointTexture, vec2((x + 7.5) * invSize, y)))\n);\nvec4 v3 = vec4(\ndecode32(texture2D(cc_jointTexture, vec2((x + 8.5) * invSize, y))),\ndecode32(texture2D(cc_jointTexture, vec2((x + 9.5) * invSize, y))),\ndecode32(texture2D(cc_jointTexture, vec2((x + 10.5) * invSize, y))),\ndecode32(texture2D(cc_jointTexture, vec2((x + 11.5) * invSize, y)))\n);\nreturn mat4(vec4(v1.xyz, 0.0), vec4(v2.xyz, 0.0), vec4(v3.xyz, 0.0), vec4(v1.w, v2.w, v3.w, 1.0));\n}\n#endif\n#else\nmat4 getJointMatrix (float i) {\nint idx = int(i);\nvec4 v1 = cc_joints[idx * 3];\nvec4 v2 = cc_joints[idx * 3 + 1];\nvec4 v3 = cc_joints[idx * 3 + 2];\nreturn mat4(vec4(v1.xyz, 0.0), vec4(v2.xyz, 0.0), vec4(v3.xyz, 0.0), vec4(v1.w, v2.w, v3.w, 1.0));\n}\n#endif\nmat4 skinMatrix () {\nvec4 joints = vec4(a_joints);\nreturn getJointMatrix(joints.x) * a_weights.x\n+ getJointMatrix(joints.y) * a_weights.y\n+ getJointMatrix(joints.z) * a_weights.z\n+ getJointMatrix(joints.w) * a_weights.w;\n}\nvoid CCSkin (inout vec4 position) {\nmat4 m = skinMatrix();\nposition = m * position;\n}\nvoid CCSkin (inout StandardVertInput attr) {\nmat4 m = skinMatrix();\nattr.position = m * attr.position;\nattr.normal = (m * vec4(attr.normal, 0.0)).xyz;\nattr.tangent.xyz = (m * vec4(attr.tangent.xyz, 0.0)).xyz;\n}\n#endif\nuniform highp vec4 cc_cameraPos;\nvarying vec2 v_uv;\nvoid main () {\nStandardVertInput In;\nIn.position = vec4(a_position, 1.0);\nIn.normal = a_normal;\nIn.tangent = a_tangent;\n#if CC_USE_MORPH\napplyMorph(In);\n#endif\n#if CC_USE_SKINNING\nCCSkin(In);\n#endif\nIn.position.xy = cc_cameraPos.w == 0.0 ? vec2(In.position.xy.x, -In.position.xy.y) : In.position.xy;\ngl_Position = In.position;\ngl_Position.y = gl_Position.y;\nv_uv = a_texCoord;\n}", + "frag": "\nprecision highp float;\nuniform mediump vec4 cc_screenSize;\n#if ANTIALIAS_TYPE == 1\nvec4 fxaa(sampler2D tex, vec2 fragCoord, vec2 resolution,\nvec2 v_rgbNW, vec2 v_rgbNE,\nvec2 v_rgbSW, vec2 v_rgbSE,\nvec2 v_rgbM) {\nvec4 color;\nmediump vec2 inverseVP = vec2(1.0 / resolution.x, 1.0 / resolution.y);\nvec3 rgbNW = texture2D(tex, v_rgbNW).xyz;\nvec3 rgbNE = texture2D(tex, v_rgbNE).xyz;\nvec3 rgbSW = texture2D(tex, v_rgbSW).xyz;\nvec3 rgbSE = texture2D(tex, v_rgbSE).xyz;\nvec4 texColor = texture2D(tex, v_rgbM);\nvec3 rgbM = texColor.xyz;\nvec3 luma = vec3(0.299, 0.587, 0.114);\nfloat lumaNW = dot(rgbNW, luma);\nfloat lumaNE = dot(rgbNE, luma);\nfloat lumaSW = dot(rgbSW, luma);\nfloat lumaSE = dot(rgbSE, luma);\nfloat lumaM = dot(rgbM, luma);\nfloat lumaMin = min(lumaM, min(min(lumaNW, lumaNE), min(lumaSW, lumaSE)));\nfloat lumaMax = max(lumaM, max(max(lumaNW, lumaNE), max(lumaSW, lumaSE)));\nmediump vec2 dir;\ndir.x = -((lumaNW + lumaNE) - (lumaSW + lumaSE));\ndir.y = ((lumaNW + lumaSW) - (lumaNE + lumaSE));\nfloat dirReduce = max((lumaNW + lumaNE + lumaSW + lumaSE) *\n(0.25 * (1.0 / 8.0)), (1.0/ 128.0));\nfloat rcpDirMin = 1.0 / (min(abs(dir.x), abs(dir.y)) + dirReduce);\ndir = min(vec2(8.0, 8.0),\nmax(vec2(-8.0, -8.0),\ndir * rcpDirMin)) * inverseVP;\nvec3 rgbA = 0.5 * (\ntexture2D(tex, fragCoord * inverseVP + dir * (1.0 / 3.0 - 0.5)).xyz +\ntexture2D(tex, fragCoord * inverseVP + dir * (2.0 / 3.0 - 0.5)).xyz);\nvec3 rgbB = rgbA * 0.5 + 0.25 * (\ntexture2D(tex, fragCoord * inverseVP + dir * -0.5).xyz +\ntexture2D(tex, fragCoord * inverseVP + dir * 0.5).xyz);\nfloat lumaB = dot(rgbB, luma);\nif ((lumaB < lumaMin) || (lumaB > lumaMax))\ncolor = vec4(rgbA, texColor.a);\nelse\ncolor = vec4(rgbB, texColor.a);\nreturn color;\n}\n#endif\nvarying vec2 v_uv;\nuniform sampler2D outputResultMap;\nvoid texcoords(vec2 fragCoord, vec2 resolution,\nout vec2 v_rgbNW, out vec2 v_rgbNE,\nout vec2 v_rgbSW, out vec2 v_rgbSE,\nout vec2 v_rgbM) {\nvec2 inverseVP = 1.0 / resolution.xy;\nv_rgbNW = (fragCoord + vec2(-1.0, -1.0)) * inverseVP;\nv_rgbNE = (fragCoord + vec2(1.0, -1.0)) * inverseVP;\nv_rgbSW = (fragCoord + vec2(-1.0, 1.0)) * inverseVP;\nv_rgbSE = (fragCoord + vec2(1.0, 1.0)) * inverseVP;\nv_rgbM = vec2(fragCoord * inverseVP);\n}\nvoid main () {\nmediump vec2 v_rgbNW;\nmediump vec2 v_rgbNE;\nmediump vec2 v_rgbSW;\nmediump vec2 v_rgbSE;\nmediump vec2 v_rgbM;\n#if ANTIALIAS_TYPE == 1\nvec2 resolution = cc_screenSize.xy;\nvec2 fragCoord = v_uv * resolution;\ntexcoords(fragCoord, resolution, v_rgbNW, v_rgbNE, v_rgbSW, v_rgbSE, v_rgbM);\ngl_FragColor = fxaa(outputResultMap, fragCoord, resolution, v_rgbNW, v_rgbNE, v_rgbSW, v_rgbSE, v_rgbM);\n#else\ngl_FragColor = texture2D(outputResultMap, v_uv);\n#endif\n}", + } + ], + [ + { + "vert": "\nprecision highp float;\nuniform highp mat4 cc_matView;\nuniform highp mat4 cc_matProj;\nstruct StandardVertInput {\nhighp vec4 position;\nvec3 normal;\nvec4 tangent;\n};\nattribute vec3 a_position;\nattribute vec3 a_normal;\nattribute vec2 a_texCoord;\nattribute vec4 a_tangent;\nvarying mediump vec4 viewDir;\nvec4 vert () {\nviewDir = vec4(a_position, 1.0);\nmat4 matViewRotOnly = mat4(mat3(cc_matView));\nvec4 pos = matViewRotOnly * viewDir;\nif (cc_matProj[3].w > 0.0) {\nmat4 matProj = cc_matProj;\nvec2 scale = vec2(48.0, 24.0);\nmatProj[0].xy *= scale;\nmatProj[1].xy *= scale;\nmatProj[2].zw = vec2(-1.0);\nmatProj[3].zw = vec2(0.0);\npos = matProj * pos;\n} else {\npos = cc_matProj * pos;\n}\npos.z = 0.99999 * pos.w;\nreturn pos;\n}\nvoid main() { gl_Position = vert(); }", + "frag": "\nprecision mediump float;\nuniform mediump vec4 cc_ambientSky;\nuniform samplerCube cc_environment;\nvec3 unpackRGBE (vec4 rgbe) {\nreturn rgbe.rgb * pow(1.1, rgbe.a * 255.0 - 128.0);\n}\nvec3 SRGBToLinear (vec3 gamma) {\nreturn gamma * gamma;\n}\nvec3 ACESToneMap (vec3 color) {\ncolor = min(color, vec3(8.0));\nconst float A = 2.51;\nconst float B = 0.03;\nconst float C = 2.43;\nconst float D = 0.59;\nconst float E = 0.14;\nreturn (color * (A * color + B)) / (color * (C * color + D) + E);\n}\nvec4 CCFragOutput (vec4 color) {\n#if CC_USE_HDR\ncolor.rgb = ACESToneMap(color.rgb);\n#endif\ncolor.rgb = sqrt(color.rgb);\nreturn color;\n}\nvarying mediump vec4 viewDir;\nvec4 frag () {\n#if USE_RGBE_CUBEMAP\nvec3 c = unpackRGBE(textureCube(cc_environment, viewDir.xyz));\n#else\nvec3 c = SRGBToLinear(textureCube(cc_environment, viewDir.xyz).rgb);\n#endif\nreturn CCFragOutput(vec4(c * cc_ambientSky.w, 1.0));\n}\nvoid main() { gl_FragColor = frag(); }", + } + ], + [ + { + "vert": "\nprecision mediump float;\nuniform highp mat4 cc_matProj;\nattribute vec3 a_position;\nattribute vec4 a_color;\nvarying vec2 v_uv;\nuniform vec4 offset;\nuniform vec4 digits[20];\nfloat getComponent(vec4 v, float i) {\nif (i < 1.0) { return v.x; }\nelse if (i < 2.0) { return v.y; }\nelse if (i < 3.0) { return v.z; }\nelse { return v.w; }\n}\nvec4 vert () {\nmat2 proj = mat2(cc_matProj[0].xy, cc_matProj[1].xy);\nproj /= abs(proj[1].x + proj[1].y);\nvec2 position = proj * a_position.xy + offset.xy;\nv_uv = a_color.xy;\nif (a_color.z >= 0.0) {\nfloat n = getComponent(digits[int(a_color.z)], a_color.w);\nv_uv += vec2(offset.z * n, 0.0);\n}\nreturn vec4(position, 0.0, 1.0);\n}\nvoid main() { gl_Position = vert(); }", + "frag": "\nprecision mediump float;\nvec4 CCFragOutput (vec4 color) {\nreturn color;\n}\nvarying vec2 v_uv;\nuniform sampler2D mainTexture;\nvec4 frag () {\nreturn CCFragOutput(texture2D(mainTexture, v_uv));\n}\nvoid main() { gl_FragColor = frag(); }", + } + ], + [ + { + "vert": "\nprecision mediump float;\nattribute vec2 a_position;\nattribute vec2 a_texCoord;\nvarying vec2 v_uv;\nuniform vec4 u_buffer0;\nuniform vec4 u_buffer1;\nuniform mat4 u_projection;\nvec4 vert () {\nvec2 worldPos = a_position * u_buffer1.xy + u_buffer1.zw;\nvec2 clipSpace = worldPos / u_buffer0.xy * 2.0 - 1.0;\nvec4 screenPos = u_projection * vec4(clipSpace, 0.0, 1.0);\nv_uv = a_texCoord;\nreturn screenPos;\n}\nvoid main() { gl_Position = vert(); }", + "frag": "\nprecision mediump float;\nvarying vec2 v_uv;\nuniform float u_percent;\nuniform sampler2D mainTexture;\nvec4 frag () {\nvec4 color = texture2D(mainTexture, v_uv);\nfloat percent = clamp(u_percent, 0.0, 1.0);\ncolor.xyz *= percent;\nreturn color;\n}\nvoid main() { gl_FragColor = frag(); }", + } + ] +]; diff --git a/native/cocos/core/builtin/shader-sources/glsl3.cpp b/native/cocos/core/builtin/shader-sources/glsl3.cpp new file mode 100644 index 0000000000..c041b94a86 --- /dev/null +++ b/native/cocos/core/builtin/shader-sources/glsl3.cpp @@ -0,0 +1,134 @@ +/**************************************************************************** + 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. +****************************************************************************/ + +// clang-format off +#include "core/builtin/shader-sources/glsl3.h" + +namespace cc { + +ShaderSource builtinGLSL3{ +{{ + {"vert", GzipedString("H4sIAAAAAAAACoVXX2/bNhB/16fgUyHFjmMp2ZPRAl22FgFSLG26bO0QGLJMp9xk0RElW1Lg7767IylRtpwCgUPd/e7/kTx6m5wnQgmZsTVfinK9YatUxsXMS+NaloWvimV4NQ1YmYmVzNfsWmaqiLNCsRdvy5Mrto5F9lWkInua/7FaKQ6iRF/l8ZoDg8+3PL3l2X0Sp9zwlLPO5JJ/kUVcgA8zb3/a8PXHVC7iFOz+EE8/Nowxkk+SeSHWoM36b6kqyTmYFc0ALwNzW655r5m8hhjy2DG5jgtSAP8fBN/NTjFusu0g7y6X/55knBJChScFLbMnbONMyP87qU6mR1fikMmrjVRlPsDBct+K4jeRn+Rdy1QOcOP1QvCsuP+vPsn7mMsyWx6zV/LphFLg/BqrAT+B8X45oCrjcf4hHtC0xTzKvHi9IW5l4rSgU4a/ZJ4uZyfoN18tx1pL4auAPfMp3vz5cBfDXiG7xH4u44LnGeyHD7lcv6+EYj4wLlmF6zEt627Z4DJ48cDYJVuzt2j90tdYDdOImUc7mxV5nHCE/TN9hD82glX4CH+0ih7hz3Fk5okV87XMOzadBBC81qNAx3TyC7tg6jkvDGTEwskUTKHoZEeIiCCGVAHJJytg71xbjh4DdtYiao2YIp0QEXrpIhqNCMn7cx1HaBF7xlPFGTrt2wjf2QgD9uYN65Ep3KAfVDSZoi4MCoKhrExbW2HruRZ1Qh2Kqx85JWMo1LAtw7Qn1LjJGHXJuDgI1frVhfSziLo4utiGIjqqw1EtX3G/Po65K14XUXgQ0U9cj1qXDspy4PpRgwy5PpBXtzbDfraRdMHtjc8pz4BujJzZxYgZpWd2YSiNpTSWsrOUnd56qNBuPK08nNg9B9+BE1FrFehOGK3pjtxYctMj7yx5Z8l7L+dFmWfmLNgPnVC/lynPzREVZ08pD2wB0SmigFcXUEp7BNUtve7Rm5be9OgKFSmR+VV7iiVISqRySKo2qLpD1QbVkVRjUE2HagwKSW2AQMO1P3VTrDC9CSYzwYol+KnwUzVOxjsyoTqhFtVYlCFDmypHyKlH4lp0UajrVHE+lWkhNmlNVbli8VhfPIvgxT3Z26hi6poF2BvBekfritY1rdFwTL2ymNROnJbvytW0boyO81a3G7nlu3INrSuj47zVXTm5sNido7dysLXj50B2pFiyHEdN/sAT7NzPWGZfZHDXM2rfrUnUc9vCgjYW2d3qjUy2tpSTZ7K1xZwYdO2gaZMbREXoSku26MZB0wFgEDWhtZ2qRWMGzi2kciC14woo31JNBR0/lGKBFkhyhB7SGt0XjV7XKIOeE7Mvg0FYHNoktSiPMug/MfsyGIrFoW/WZmV69NJU4Sajcep+g5ODPj9g7BwzZ9hhzrTDunHHKRMtcHj7rPfs8fRkZiGrxU5DJAiOOHJ22/hW3xhMQB8d9oxPbhrZoG20jaSLALvJmS4jVsJkfkCEIVAPtNSUiVxvSrSQFzCrOx151SYkgp+80C8sG73JiPLGeuLc6oeHF+i32SURKLuoWZ9nl36nh1pJTaqxo5taSk3qMV45M60GXhF/g3QGI3CcwpvJ13q0NX0Jj61xfet2n/pidTR9e1VT2NcU9jWFPU3fX9UU9TVFfU0RaYLkTqoa2vXtQEf6veyNKQv0+41+v+ve2Hsi02WI56BO6GespkVAK3h1LWW+tDQ4jOem9CceGYtSQBdm9n2NTzWIb567b2Td9IpeXH5goWDfXlqdM2MW6kjxLumeJFBlateD1sJDtvUZcgO7F2b8mdfvUN90ZdeQAxOBrsh0gp00Pgpj0gSB7l//iFXp7hv339MHUdh3rw2k3B76jl5DoolsUt7fqLT3bArZUzq/MznDLNrkztj+f3tdp0QlEQAA")}, + {"frag", GzipedString("H4sIAAAAAAAACn2TTU/DMAyG7/0VPrYIoTHtVnGATpuQkJg0xBWZNNsCTVLlo2yg/XeclqBNNJyS5olfv3adrDWcCSu0Aslr4WULm0ajK7MGD9q73Lr6ejYpwCux0UZCVS0b/YoNfGU7sd21ANBxNgPGXpyQvMyiTDy1zHCu1uJzhCl0ouMDO/6TskLJDZ6klOh6AVqfBf8oU+BedaNsZfRbEqSCgmAyMMKz4Fgn6/2vtE22h2Ez0h++b7X1ZoRIFOpBuLkwSVbpRo9QlK+CK7d+PyTZ0miv6r94o7cJUSJ3aEd8EritR6QUR7PAEaUu9FEb1w9Ef1hVC4PbR+9a7yAf7gUXBc2D4c4bNXxTRCZUEJqCp58w7GcRxmmyKNuGm+kcQp+e+N71DU7MXkhdaWUdKmcpYa/ohIrdjSaxriEv4gVKCTcwvZrAxZCe1t+gsB+y5icOLslzUcaCTmvOSaEIxf1YbDSjZ0MP9gbIKJ389m4w2/vqtKj7AoOpM0ZhZDYvSjh+A59nWc79AwAA")} +}}, +{{ + {"vert", GzipedString("H4sIAAAAAAAACkWLMQ6DMBAE+3vFlraUJgrdKX/ID5BFHDiJ2NZxoYn4O3aCRLkzs1Q0DrJITphknApecw7GJAlrHG4IfcmLWPVMFXSVqsF5fP+zWtxb2rkzveDqmTTaR1MrmDZaszzxDpLaF+PcP474d1dznrHtFd2hYI4AAAA=")}, + {"frag", GzipedString("H4sIAAAAAAAAClWNwQrCMBBE7/mKOSYXqeAt9CT4G7KsabsQs2VNBZH+u4mevM3szL5xqyWWh2jBIvOyYspKNbpn4hMmoxk+4P2zihFd+ONhCNFZqpsVaHS7y/TSrfqsTLWzRgwB7fLtg/l6aaizZrWGVrnhTlI6+S9rb33Sh4j9A43v9mmZAAAA")} +}}, +{{ + {"vert", GzipedString("H4sIAAAAAAAACn1Ty07DMBC85yt8TBAHKnqLOEAQVaUiRSqUY7V13HTBj8hxAgX133HspqQi7inyzOzOeLOOKs0o1qgk2WG5q8iWKzBpxGGvGhPXpphMbxLSSNwqLUiWzbjaACc/kZcT0jI6JZSuDQqWRoIV2IjqhNZUMyaX+D3CSTDYMs8dLlhmIJiGgaUA4xrY7wrZZxoi5rId5XKt3oNEqKhrGCzsybPi/p7U5c9VHRwPBT4yH/ZVqbrRI4wAlAs0j6iDXKa4GmFBbJBJs/zYB7mZVo0s/tNbVQaaWuYB6pGclrgvRlpJBvoJRjq13RyVNpcXYqHoYAUHv+FNaV6kAXz+0jO9G7cng7J8hup1lYMG4XxRdopbAms7fzT2bfTY1GLUz8Am80jbI1biHo/VFFgbL/FIe0R8AdOGxInN747Wg9y5VvGf4TWZJGnkqfMNI1fDO9lT1e3VMYRVnwJ6T4d4c81Mo6XXH6JWYUG6XemSkJKv86O1C6NNnKTk8AvHbagyHgQAAA==")}, + {"frag", GzipedString("H4sIAAAAAAAAClVPy2rDMBC86yvmKJdEONCb8SmQ3wgb+SGB4jWS4hBK/r0ri7b0tvNaZtQaR+uT5wXOz27FFJhyp/yCbbSf2K6WA8ed2CVhBp/EsctTpBm6wVeFjP4vUe1Ewk1PP2Sna7T5lcLqinoyOCLdmbNLeVz1keiA1hxAt/STEcfJtBJlE+cbPnqwIUHl2v90Ko75ERdwp94q0IsfWQe2lMu2Hm0DYeooa68XKX6uPTf2A+7kl7Ljn1aay62bDu9vs5NL1ykBAAA=")} +}}, +{{ + {"vert", GzipedString("H4sIAAAAAAAACn2TT0+DQBDF73yKOUI1po29kR4sajXx0KSJHpsVlnZ0/5Bhoa2m392FBkrjbk/A/mbeezsZgoJ4iiVqBVvcbAvIhWYmDgQ76MqEpckm03EElcJck4QkWQj9yQT8BqdygJqnU0jTtUHJ40DyDCtZ9KdlSpyrFf44mGIGa35ixyuWCZOc2MBSMtMK2Oc78l3sA6+qdrIl6S8v8DU1gt7GDl40d/dM2/xLXXrHkzLhmA/fF7qsyEEkQ/WG5hHJyxIttIMy+YlcmdX3wcsWpCuV/ce53nhELZmz0pHTgofMIaU4o2fmUKqbOWoy1xfiQ5PI5k3Kfik6gV2PEnsVTrGXvzCRP+2NrSpbN1RN0T2wtZ06GvtHxEHbVXMyEEbWqv080+4NZq18eO68hcndOBpUjGZXzPuqm5n7CgOjy3WD0SAOcVORGhwcg1pjBs1CNPFhI9bLYWQyYRTD8Q9WgG4pAwQAAA==")}, + {"frag", GzipedString("H4sIAAAAAAAAClWNzQrDIBCE7z7FHBV6SKA36anQ1yjLxhRB3bDVQgl592puhTnNzzdm08DxHaUghyW2vGFNQtWbT+ArVqUXrMNuNNSmBcO18wXTqdl5c5hEX2nVJmGqA3TD5NCdswzm56NT7pJEO1XigkyxDOhf1mfjzTqP4wfn3nrmlgAAAA==")} +}}, +{{ + {"vert", GzipedString("H4sIAAAAAAAACtUb2W7bSPJdX8FBgICSJYWUnWu1nkXGcQYG7DhjO55jEQiMRHu4kUiZpCSSmfz71tEnScn2XoMFEpusrqquq6uruunOMg2nURYlsbMIZ9FqsXRu5kmQjzvrcHrg3K2CPExjGH6XJos3RZQ5LgzsOwU+9+mx1I8VPna/dhZBvu8snEMHH1zGZTTGGHdoEidPg2mIaH/3PsE/Zw+e/E/wj55Gn+CfIci4E904LtN873jDrvNV8MmAhzd87jxzsrs0Fyh7jj/0YCokHW4IY0QoAlQAyKVZYL4Bzzz61HV6CqNkDA/hhDFCKU2MijF8kn7AevgS45sTzrPQQaFdqeH3UsOu8/SpY4FJ3a6t1GjoIS9UCpQhq3hqLl9JzqSGqm162ZqTMdpU9ZUbPIuoMo2xp43xrKaqlEurdJ9GWg+tW5tGDT80fLlD/LKps3ae1sivaXSP6CMlUs0tNdEbAdImeotdTd+0y6k00cp9EzLPwxjgYpKefNhzBNOefBCQSkIqCdlIyIaXHjKUC4+Z+0O55uC9a2ikZgW4oYaaWoMrCa4s8EaCNxL8rZOG+SqNRS741pahjlfzMBUpKohv52FXOhCFIghI9QxcKVNQqeClBa8UvLLgGTLKotgtVBabImiaZAYoKwVWqbFKgaVBWSWwKo1VCSwEKQUBhs+uZ5o4Q/NO0ZhT9NgUXzN8zSrD4hpMWJpIYVUSS4AhTDODyPDH1JzRxEJeNedA5j/A9J9GBTrm4oq8Aur0HfLOUntmhK7myBwWyi8MpegclsorDKUIHVYSWhSCQw+YKWCpgKUGVgpYKWBZiqlMzLJSQI1ZVWJ6E7jh2TfW7JtSATXPTaWASC4shpZyO7CSBo5bor5V1e2j+HtA0EeRB8Cu73j9DgAHBGTsopDYJVpkUzASPZcEHBDQwC7LLiEthwBfDkv8gfw6XdNp7LHLmsty8TuzFtUdchIW7DvCQH1nw6qOTSejALaDUUnbuSi87dgWt7Y4tcWlLQ5tcWeLM1tc2eLIjUXIeUHHL2cAHbm81oeV7XbXdjsVDmBOV3hfv3MQyHdwoCtigUBgeNcOCQUWkSHfiZIDhEAVowwkSmVzgnCRYKDM0dU5ujmnoOlaWfhsNc+j5bwUURNQtBw4nyFajBJOpa+AVuFnWA178Lyh54KeS3pGoQJaap/RiiqhyXGTrqTnSvAYKN5mipPjJl1Fz4XgMVC8CyPpSdyNwbcwcEtDzmYaXCfRzEmTHDap63CK6+onzOduFCernJfTWhjqTi2rSGeUtciLJT2jTTj9rHVkRaWBzfmyEpQDkevWOldGlYHNebQQlAM1j4riCC0wkCiFgVIaogDzNfk0ojqDTBzhDANO61HJzyh+VPFziTQoOQ3aNKiExMM5ie3gjudB+WnQpkFVJB7KJucsRIzuCy+cxKfJNJhfLrFF4EJhmWQis3Gn4hhtjaP7GsNN9LCOws1PvDk32yTR9Egusu0hQhDEoJPLxpX8+jAFxFE9ZlwSU9B2VaABVGTufWJ3lZxhzyVEdb6y7guPS4h93Gg8MA/XsuxMNpiEsGmrfkcCCoGyp1A27SiVwYVRSlYZ5vfV/HW2dRpga4tYiJ87RCwFuC5ioeYfbZm/SVM22dZFLO4XsVT663S/7y68PpgC/o906sSBq4Q8zG0zeFe1HXnKTbTuj+FZdcjwLHpkxr7bQOxAir6DDH1XyXaZSnZP87zEjYjbZNEjg6wgt1rz8fqSSnsPCt9LyISqd+7RKzcsLAc3PywH971IDUilRBrJzoeVGJlIlUTyZAfIXD0DyWqilSG+14boPn3aGKi30kpl0bcp9IFh0IFB+gCL3GuCwjZbadAoV3o1mso2216b2cxeWwlv6r1LbVNV0wSPU3uXU4uH6FnatjHV9o0wb1F7h24jwxkN9z5Ytx2xqHXb4R4r9Lcpc1dZBlCtLXV5egnD/43OFCE2tyJVUFYjgMrxIeYKAgFTb/h8bBTpYSqrdHgSZTo8VXb1+j/uav9vetl5UEK15mb5zD+AbLmKo5skXThHSZzlQZxnzleZyqP4KppH8e3k/OYmC+Up6k0aLEIYCCfrcH4axpdQgIRiLDOe42QWXuC+D4UEzDveOvHRj/PkczCHeX+Pbn9fOg6XJtPpJI8WwE0e5UpoNk1DmDaqWsZimG4d8tiuKY9AhzQwpqRmERjA72soXcbbBk7idevYhzT5x9aBbUTIcCuhHLSIpZ5Tkv8DlktbzMOeqA+GBZRYq7RlBN19GuVvo3Tr2FEyT1pGg8XnKIzzyy/l1rEf02QVz5rDN8ntFqYw8kOQtcgJA29mLaziMEjfBS2csBL9kKT57oCgOlrFg+GGn5N0PhtvgZ9cyRE52xzeclgzZ8Hy4/WHANYKzYv9kSHYyFmtG0CgZ1tQmzVNFssV1sxpDm42eqwDVeKP4Eea8+KU9bw81eg8gS316Ghycfz+7fHF5Oz87bFzCFna+eOPFvB+p8+6rTnEO0/CeBbdbGHid8QsYRl2xMSQC5JplJfwzllSAigQFXQexrf57zasOIlnYSGnxB1gi+y8M6CI1PCgaWQhrA1B5WuGG4QBo1SIW4U3lEU0rKBfgDoG9wdzyBcu82H9ecftS3Pw1qlf+VDb4PTrTk6+zcm3OfkWp992chrZnEY2pxFxgugYFnhQctjSJLqW9fpkBfr5K/38jdu1J+F8i+OlmBcY5pao0zTJMldOPsDY6KsgQBifvWALK5l8XJL7NAr232bYwLZo2sLg5fTMUGLvWqq7SsieE3zOrAAhQaLb2ATi0dBACNUTIbndEKP/RigStY9nU45Xiy0a8mho4P9bPiYvaUh3t8P3/1N6Ng8AakLe7V6XekuUS9OA+A1I6wKVRvQN+yYkLFZQOG3P1pSOe4i4PmDHWiLKoydY0/MAgk0DMX5ZA5djmfWoKB7JpP/x2nE5N1KxRcFoZHzzXVVjfJAzcoI4AnLSdoTaAp8kdTUf0EXRYNSPO0RBhetO3BolHhQSYWljYTQ1Y+m7Q+ego2Sn+pcOZg2QsoWoV10hF57VKDS8JyTNjBn7lkI7StzLYLGch41CdzXJaOAkvkl2FQlX0fRLC/EGCwEodMcSgFXr23CeB8Qs4j7ICSYQAREWwxPgkOZc2+rRDGJ9glWBBqWieq6BRZWgAbMohbrjhtlx3ABxPLsMw1mrNw7RG0y/D6h5WByB42fjFti+CeRF2ZDFV64jvFUM6+TL0Spdh2+DPHBcNm86euvkKm6nyLwrrRhAPMAY+D10CYeHhUk/t45CWJieGxptHIZyGkxzlxApci3UwjjJigo3wIXcx5Nw/DXtqkPWh2vSd7A6E/cpf6Za2A2yThvUaMP63KMs819m4WqWXATxLFmI9FPo45cEr6XGHUwTi2Tm4vGgP4T8MsIjN3qWct6k4d11gP277w39Fy8OvJfP9w9e6bsr0VFLvJ7IOwl3+sAMfnaV2ms6NCxcD2eDaQa4nReU3J0enju89F763ouXr/wRgvBa7K94Ruj8zRmsnb84a6X+GnWl5XB+en4xOb+G9XB1cnaMi+Lj6fHk+P2bH06PO3K9a2dTlE8SyEK0uHFxeNt7CUSWeQLMF8HPFS+UCViOG1Ojvr44v3pzdXL+/hHyqMTwQJFkG96QSjFqE+zy5LfjRwhFCeyBAmGD3hCGGLQJ8u784ugxksDr9MGivEPkhizMgoUxIRmWAHX5ro9Pz49Orn59hIiymH2olNcCvyGoYmTKqoCt4l4d/3L18eJ48ub9yRlH3n3Siiw1gR15wfGyU9g3Es2QVuyNyGESyY1WCMXrPA2XIV4mirsCu2PEPCRWcQ4JghNGDsWAHJb9gDpf5IqT7ye5a1ZXXvKMMcJswRXxHafDJTcXe+JyhF5FpZiG+NXUkms+cTNi0UZrnWjp5BMoJFfj3PN2uc7oQMVxdXKFpB6toYJZ4PeDRgXBd7MtlYP+FkEVyjNBPp2D31yD4zOjRMANQSZS3odGDvKjvd6TZaPNU7cqBq6/DdcftleAh1wByhJ2VkgGutbAUs54K7uypG4nExUTqmTVSmRtXZDoswn54ZFhDvKPVI9OVjRSi9UJ3VeNG0qAl+pKFAqXe3MnXnYY6Y46a4wFYgdbWq3scFsya9/wWte4TlBiTdCZj2ek6f1H0/tqy76B6IPdjhaMWVSoqhRW0P7rV6PnaEmpNRYnLHlfSNBXjGj5mDUmNkrc+h/yobM4Psjo5Pf+TYOYUErHZKWaQ5SHvaM3AOUeE71umbYtZ6ePmKDNSQ9gZXBoc9M9HBp+ugEe2x018kf+C/KUaQD0ltChL0VR/rrR6Y6GrqBq/SIXluIiFp5pb9qv6KxPGVzS6nzuanjf6L/EnMZpEjTbGlWszUfs2uICaAlmOEuAKgpTj/rWcduQL4b4wESIsSW4rE1bxVeNqO7VLSWDGRr9mrSNqIMf4J+yNe7+Nf4W27ZgvJ+tX2PbiM/1rjziv3756sULTsmW/TBClb59LaOKUtyvG96lLGQB69JZ9N/sHcYKdFMeK9bt8kyFe52JEfHW0L1Bb2HLEsY8ZT2s+VGtC+NQq3YuWyszelZNwRn3O9jxP14eT34+vzh9O7n88ObouMMbqnFjglUV3lptu1kw9uoW/Wuqy9VsbAy0V8t+h/ZmszJQ+3Pb8dTOWwfgwp9jH9pTyLSy88DcINapQJU2beMYL/3aTFWtrAGqxtdaxMaV/MxZduFb83Qf151ySFuNpJHR5L1+S2LY0sRaW939gafu3+XnAuKTglDoz18h8e3eoflN2R1/eMbjl2gAezylCGObmV81MWpP8GxkWKVVW4p9iMrjGp+2nHo/n0YOTXfm0NHz0euRKmulxzAXan36hkwqB6YPcFH7utpvv4kcdUJ7JXiiYSFwYw38uZ63rkl3ninxKtGHQGqJEIjyFD/11JFg26HTjpJS3B5T3D2ChUHpP5yyEV7TXeH12vcOqGlqKoshJuTuSzFUcE2FjTGD1UjHO26ov1Od5jRJ4zA9l3c81De6so9Ux4zbtiKOANrKdRgazbOQwL6o5w9bzYlp3fR1x/L4m3nr65P7r+bNz0Nwe+roe9hOv/3znWG1dWTT6RsN7kZd08uthZYRaHgWtC4jGsZPgRrj5vdBvN4YRSL3BNeWpcgDzP3AKfDQ6X0i20Hzz3RcMr2oaix8RhR/GmKhGa7im1Y8+CaSnjwZUJcj/GcDa/7cCZOgxJXiKBIe5ptHEfyHzfsTs1yS3//Iiql+IUjf3I0fdKIn2hXMX++QXpByG8kMb5JGnxLFuWuc2OG9uWqFDaL65tR+WLi7GZbs2jbNB/Gz2bTtmfeyaeS0fGdO816+PqCm2DAFNcVKl74hkMppXLFbrlBY9Md8psVLxZ79zUekllOwNtdz0oftmnlXHsdxdK3ovFNeMbv23TIlxW1JoKC/r2l8EciXs01wtal/0U+fNCEiHno6t/PJB3G4BhKpE1G3O3a+/RN1jvlKxD0AAA==")}, + {"frag", GzipedString("H4sIAAAAAAAACn2TTU/DMAyG7/0VPrYIoTHtVnGATpuQkJg0xBWZNNsCTVLlo2yg/XeclqBNNJyS5olfv3adrDWcCSu0Aslr4WULm0ajK7MGD9q73Lr6ejYpwCux0UZCVS0b/YoNfGU7sd21ANBxNgPGXpyQvMyiTDy1zHCu1uJzhCl0ouMDO/6TskLJDZ6klOh6AVqfBf8oU+BedaNsZfRbEqSCgmAyMMKz4Fgn6/2vtE22h2Ez0h++b7X1ZoRIFOpBuLkwSVbpRo9QlK+CK7d+PyTZ0miv6r94o7cJUSJ3aEd8EritR6QUR7PAEaUu9FEb1w9Ef1hVC4PbR+9a7yAf7gUXBc2D4c4bNXxTRCZUEJqCp58w7GcRxmmyKNuGm+kcQp+e+N71DU7MXkhdaWUdKmcpYa/ohIrdjSaxriEv4gVKCTcwvZrAxZCe1t+gsB+y5icOLslzUcaCTmvOSaEIxf1YbDSjZ0MP9gbIKJ389m4w2/vqtKj7AoOpM0ZhZDYvSjh+A59nWc79AwAA")} +}}, +{{ + {"vert", GzipedString("H4sIAAAAAAAACn1UTW/iMBC951d4tRfSdhFQ9hT1QAOtkKiKoJRj5CYO9W5iR7YTCBX/fScOpmZJOCV+zzPzxvPhZIKEVFLOUEoimqcZihOOleckuOS56kgV9Yc9F+WMxlykyOdMKsyURF9OQcIhSjFlbzShbBO8xrEkYKrxWOCUAEGCgiQzwpYhTsiRk9Y/4xFZcIUVaPCcQ3tg/znhHziBuJ9085khhLR9GAaKpuDN6DeoDAWBsHTfwDEIV5CauxbShxwEtkKmWGkH8H2nZOu1EVNWNHJzwf+0Em1GlcNWQ0OeGZs8Q61/zmXr89SV+J8ku4zLXDQwVblnVI2paOV8nvAGFqcflDC1/Fu2cs+C5yy6pGO+aXEKzCOWDTqBGEUNrhjB4gk3eCqqd+RCXW+IGQ+tFrTKsOYiibwWfPpmGBMtgZOCmXnB2ep9jmFWdFwIiixhA5QXFyDY129BWXW8RziAYtF6fmpsCJgiO59zEdn3DNZvAge29THETxpD0sF4MVoH6+liEjwtRi8TrUhbF49YlCFUTtAQbhMW0bge60Lqdui4p8fSMChFD/q38y37DvXd4zaAXcFDqsrvSyfN3V25v0M9t1b1A2StlpNg/bqYjYPlfORPnNq59e7opgpYuT55PWcNcdKulx/AQtXLDCwsDd0d+oV63d8umFpoqcXfI5i2VQYWDHoFJ7BcOqHgUnZAQyUebO2RrPMxCqqTC7mZu7cPR3c3lhrvLEUz+SbLvADKkrXfAnOxnsE7um2A91vPc3TZtZfrDWDX/Szo4PSSgqhcsFrZwSk4jZBpCLRJgvmx9lWhTat46PAP26Yh0JAGAAA=")}, + {"frag", GzipedString("H4sIAAAAAAAACn1UTWvbQBC961cM9LIqJjiubyYHR45DIKXBCc3RTFYrextpV+yHGrfkv3d2ZRmHaCsQWs2bjzdvRspaI7i0UitoRCl900JVa3SLrMaD9o5ZV17Opzl4JSttGiiK21q/YA1/s73c7VsA6ASfA+dbJxuxyIY0g9VyI4R6lH9GMIVOdqLH3v9TssBGGDwr2aCLCej5U4rfixRwp7pR7MHoX0kgFRQSJgMH8EPw0CeP/B+0TcrDsR7RR7y12nozgjQo1b10K2mSWKFrPYJi8yKFco+vhyR2a7RX5We40rtEUkKu0Y7wJGBZjqRSAs0aRzJ1QUdtXFyIaCyKtcHdD+9a74D1foFFTvtghPNG9e8UkUkVEs3A0xD683wAv8iKUm1Xm+Xz9vluc7Ndb5bfb45e36C7RnPg1LyRnJyFKmWVDRtosWlrYWYrCNo+iTcXh5LY10C30Mo6VM4SycjCSTVMZGgMyxJYPjgQTbiC2cUUvvaU6XkKCue+KjtjMKE+83RnFTBUB1YLa5/2qNh5i5PYNZteTGc5XUSirx+okHUCl6c7D8IeBTnqfT4SRoHR5ahGrTl91fQ/uQLShCyn0fa6RAk6LcuoZej/A0ZhpAvLF/D+D87xXUScBAAA")} +}}, +{{ + {"vert", GzipedString("H4sIAAAAAAAACrUaa2/bRvK7fsUWAQJKlhSKdj8JDpA6bmHAjl3bSa89BAYt0w7vJFImKYnL1P+989inRCrpPQDHJmfnPbOzM8v0lkUyS8s0z8SX9OnLUjzO87ia9tbJ7Eg8r+IqKTJY/LnIF+/qtBQBLByKGp+H9CjtY4OP/a+9RVwdioU4FvgQMC6jMca0R0JEVcSzBNH+GX6GH3EAT5PP8ENP0Wf4cRSZ9tJHETDNWxGO++Kr4lMCj3D8o3gjyueiUigHYjIOQRSSjjeEERGKAtUACkgKyBux5OhzXwwMhmSMEOGEEaGWLkbDGBPSfsR2TDTGi0jmZSJQ6UBb+FZb2BevXwsPTOb2faOicYi80CgwhrwSGlkTozmTOqa22eVbTs5oM3ViwhB6RI3rjAPrjDdbpmq9rEnfssjaYW1rs2gnDjux3KO+3LXZBs9aNNmy6BuqR0alrbBsqb6TIG2qt/jVjU27nsYSa9yL0nmeZABXQgb64UAopgP9oCCNhjQastGQDW89ZKg3HjOfjPWeg/e+Y5GRCnDHDCPaghsNbjzwRoM3GvzSK5JqVWSqFry0VajT1TwpVImKs6d50tcBRKUIAlq9gVDqEiQNXHrwxsAbD14iozLNgtpUsRmCZnnpgEqpsKTFkgrLgspGYTUWq1FYCDIGAgyfg9B1cYnunaEzZxixGb6W+Fo2jsctmLAskcFqNJYCQ5qWDpETj5kr0cVCXlvBgcp/hOW/SGsMzPUtRQXMGQqKztJGJsJQc2aOaxMXhlJ2jqWJCkMpQ8eNhta14jAAZgYoDVBaYGOAjQFKqUS5mLIxQIvZNEq8C9yw9I0nfSMN0PLcNAaI5Mpj6KmgBztpJAKJ9jZNf4jqHwDBEFUeAbuhCIc9AI4IyNh1rbElemRTMxI9SwKOCOhgS9knpOUY4MuxxF/Ir9d3g8YRu9kKWaX+lt6mekZOyoNDoRw0FBs2deoGGRXwA4xG+sFF5f3AtoS1JagtIW0JaEs4W4LZEsqWQG48Qq4LNn+5AtjM5b0+bvywB37YqXEAdwYq+vadk0C/QwADlQsEAscHfkoYsMoM/U6UnCAEahhlpFEanxOkiwYDZYWhrjDMFSVN36vCF6t5lS7nUmVNTNlyJO4hW5wWzpSvmHbhPeyGA3je0HNNz5KeUamYtto9etEUNL3u0kl6bhSPkeHtlji97tI19FwrHiPDu3aKnsbdOHxrB1c6eu6WwXWePogir+CQ+pTMcF/9ivU8SLN8VfF2WitHPZttldqKslZ1UdIz+oTLz9pmViodbK6XjaIcqVq3trUybRxsrqO1ohwZOSaLU/TASKPUDop0VAHma4ppSn0GuThFCSMu66nkZ1Q/bfhZIg1qTos+DRqh8VAmsR09sxzUnxZ9GjRF46FuWmatcvRQReEsO89n8fxmiSMCNwrLvFSVjScV4Yw1ws41TpjoYZ0mm1/5cN4dk9TQo7nosYcIQRGHTm+bQPMbggjIo+2cCUhNRds3iQZQVbkPid1tfoEzl1JVfGXbFyG3EId40ITgHu5lOZjsMA1h1zbDngbUCuXAoGzaURqHC6NINhnkT4z8bbbbNMDWV7FWv/eoKBV4W8XayI865O/SyF222yrW31ZRGvttuT8MFuEQXAH/Ils6ceE2pwjz2AzRNWNHVfAQbedjeDYTMjyrGZmxnzeQO1Cin6FCPzd6XKaWPbQ8b/Ag4jFZzcigK+ht9ny2vqHWPoTG9wYqoZmdB/TKAwvrwcMP68FzL1IDktRIkZ582IjIRWo0UqgnQOYaOkjeEG0c8dY6ov/69c7C9ihtTFZzm0EfOQ4dOaTf4ZFvuqD23SYdGhPKcIum8d120OY2d9Y2yrt27zPbNdV1wd8ze19Q6++xU/q+cc2eOGneYvYe2yInGDvh/W7b9uSitW1PeLzU7zLmufEcYEZbmvLsFoZ/G6oU81hCvxCU1cPkCPbrKksf82IhTvKsrOKsKsVXXUzS7Dadp9nT3eXjY5noe7zHIl4ksJDcrZP5eZLdwBGYqLXSec7yh+QaTx44ykDutFPwyS/z/D6eg1y+NBR8OM5md1W6AG6L5CFdLZYGWs6KBMSmTctaBuLWCa/tE3kCNhSxI5LGFWAAfz/B4TntWjjL1q1rV0X+r86FLiJk2EmoFz1ibeeM9L/CA7vDPRyJ7cWkhkN+VbSsYLjP0+p9WnSuneTzvGU1XtynSVbd/Ft2rv1S5KvsYXf5MX/qYAorP8Vli56w8O6hhVWWxMXPcQsn7IWu8qLanxDUyZl8cMLwW17MH6Yd8LNbvaKlzeGtgj1zES8/frqKYa+QXOzQHcUisVrvAIGefUGN/ixfLFfYtRUVhNnp8o9MkxnBr6Lizak7Sj1X915BUT85ubs+/fD+9Pru4vL9qTiGOiH+/LMFfNgbsm1rTvHeqyR7SB87mEx6Skoik54SDLUgn6WVhHeuihpAiWig8yR7qr74sPose0hqLRKPnA7duf9CFanlRtfoVsw6ghqoEqdLB0YXSzhshmPdxsEO+gdQZxD+eA71ImA+bD/X/KF2Bxdv+8rXqg6n3/dymvicJj6nicfpj72cIp9T5HOKiBNkx7jGUf24ZUwJPO8NyQv0+3f6/QcPDK+SeUfgtZrXmOaeqrMiL8tACx9hbgxNEiCMp38cojSTj0sKn0XBCdBNGzjwXF84vMTATSWOrmd6YJQciPi+9BKEFEmfMheIlxMjpdRApWS3I6L/RyoS9QRvR0S4lVu0FNLSaPJfxZiiZCH9/QE//F/ZuTuCbin5vH9f2iNRb00HMtmBtG5Q7cSJ49+clMX7aBQ78C2lCwci3l7wcy1X7dEr7Cp5AcGugxhfboHlVFc9GuAiXfQ/fhIB10ZqtigZnYrvvptujK8SIhFnKZCTtRFaC3zyIrB8wBZDg1k/7REF3bnsxd2ixKsqIpQ+FmbTbi79cCyOekZ3uqyhq0EHZHyh+tdA6YW3BQYNv1SRZY7EoWcQtrhpxudTfAdeT7kBtbAqqU/Azoc22KQNGGngEQDVGd11MlpqQpxM9x+lRy3iDl0deB/sKGD5EnS+XJfUpYnA3NNgLnF1POa+XFVYz1jdT+ivQtZjfCfbZaZ35lti1g0F8R5zbP8B2Hy8Ob377fL6/P3dzdW7k9MeC3b6KVCPLqG6xRqJPpVesCKt5OvL23e3Z5cf7i4/AbPbs4tT5Pjx/PTu9MO7n85PzZXe7QIPJC/uvAsXq/nP8azKCx7z+DaECWBbvBWTkK5qwvGP6H2zMDqmFWhJHfoRMXgx13faeUw1pPsVqpd0Y2wpna/FI6Sj/ch/+V2qd6neG/Xe9HVl6tqXe9stYMFfQrc8840ewSHjujs2anSso+lDV4bS3GY5e6vlK22gubky9uE7UvptKdNevahAF1lSXOpTg0qRw21MX1IwDzr3TmcH7jf8fEXriqML26Hd1kN/Kt3btv1HvM2MyftZb7Fh+w0AfsVpX9i4UeUDghSN/rZaNlZUaCgldT2msNOtJ9BcmCtxdYcNMCCmZbyX2Fl3Lyt4+zGKRh4orrTE96j6ppUXmPuRqHGe/JDrwut+tQ7IGNU3ePiMqL6Uemi+8VwvmWSga645Nrhiq7sXPDU0rlbHkPAyl+gtT9IBsXXErNb0HwlUa+Kme+OHtjM3avpCuHOjxIf7LrjZTL2zQV+F6OPB/15B4zIywbNPPM3vrtQRBvTmYAz6U/HyFxxpSNigJgAA")}, + {"frag", GzipedString("H4sIAAAAAAAACn2TTU/DMAyG7/0VPrYIoTHtVnGATpuQkJg0xBWZNNsCTVLlo2yg/XeclqBNNJyS5olfv3adrDWcCSu0Aslr4WULm0ajK7MGD9q73Lr6ejYpwCux0UZCVS0b/YoNfGU7sd21ANBxNgPGXpyQvMyiTDy1zHCu1uJzhCl0ouMDO/6TskLJDZ6klOh6AVqfBf8oU+BedaNsZfRbEqSCgmAyMMKz4Fgn6/2vtE22h2Ez0h++b7X1ZoRIFOpBuLkwSVbpRo9QlK+CK7d+PyTZ0miv6r94o7cJUSJ3aEd8EritR6QUR7PAEaUu9FEb1w9Ef1hVC4PbR+9a7yAf7gUXBc2D4c4bNXxTRCZUEJqCp58w7GcRxmmyKNuGm+kcQp+e+N71DU7MXkhdaWUdKmcpYa/ohIrdjSaxriEv4gVKCTcwvZrAxZCe1t+gsB+y5icOLslzUcaCTmvOSaEIxf1YbDSjZ0MP9gbIKJ389m4w2/vqtKj7AoOpM0ZhZDYvSjh+A59nWc79AwAA")} +}}, +{{ + {"vert", GzipedString("H4sIAAAAAAAACn1Ty27bMBC86ysW6MUuekhc34QeUiUNAqiwUedxFDYk5WzDh0BRatLC/15KtBTFFXsSOLOcnVmuksoKRjUZDU+0f6qglAZdmkh8NY1b1I6fr8+W0GgqjVWQZdfSPKKEP0koB2gFWwNjhSMl0kQJTo2qRrRmVgi9o98znEZHrQjc4T8tM1TC4qSlQtcL+O89iV9pjLjR7Sy3teZnlIhd6gSjFwfy3eUhJ+v9b00dHQ9DOTMf8VKZurEzjELSOblLslEuM9LMsKgeSWi3e36NctfWNJr/S5dmHxH1zFesZ3x64oLPSGmB9hvOKLXdHI11/UJ8oBLudldFvsku8vh65IZNFnLyKA/GSp5G8JvbgRl6S39ypPffsbq736JFFVwIzalMSHeFnwEL/yjk/A+THrGVx5x4yYyxfMDWHmNhWN50QNrQYURW0LRnIeXtw6bINvnmx9XlqcDqnQJH+zxaCpiwDhZLn78/enPwpa9evDn9BOfL03GGwslA4GN3eRSf8sN2DyXet+emqY/ZevSY+zRXMP9WsRpbWeEaq4P0IWkNceiWuAsFe1lsjyn6XNYtlikc/gJe6WJXtwQAAA==")}, + {"frag", GzipedString("H4sIAAAAAAAACo1TTWvCQBC9768Y6GWjVlS8pTkEtfQgWGpKj2G72ZilazZsPrAU/3tnYxKjlSJ42Zk37728GUlmBJe51CkkcpdkECvNCpc8yBjet6vQX7+++GGw2gZEsW9dFjQvoul84kCZylibPZwR4dIPfPghNQUwlSUsSIzIE60ilxyRVKSRjEmlZdQbAypTqASfA9dKGwcZbqhjhdb9MYOnK3IHIplzZqJO4nhTpGfsH5W6f5dG67sKFWbXpBZ8bMLFZr15Wy17gIiZr27yVJ5BWU1c0uaYs32mhJktgfMwz4wsRCAORWmES2qS2LAdUGu8fmrwanI6HUHzc/46qKGFOCxsdDcnuubAs0ArSK8djKxVxGoM3+vo8DFov33MbNfsPrFPaQ/xCNMxXsugyQArQ1vBegfCqR7Acgwvmj0VfNkUVS6IvsuwBZ3Xc4r/vG+qEWMETqSg8UTbG1eas8L+JzxA71hp7pOHz7iE2ph7urA9k6ndyUUPx+yyqOPC8RfccVMbYQMAAA==")} +}}, +{{ + {"vert", GzipedString("H4sIAAAAAAAACqVXa0/rNhj+3l9hiS/JVrL0gjQt40ystEeVKHQtMKTpKHJTt3hL4+K46eWI/77Xdpw6bcKQ9gXwe/PzPu8lprHmJKIpZQl6pcvXNVrEDIugkQq+iQSarjkV5JlwQXa3WGD0vZGRqIvWLKUCnAJ9jFjMeNB4P/EbcLxckUQcPdtokym7GO/ZRjipmLe6vos2CV0wvkK93teYzXAM1hoOQvqCKBR0RYLGiszpZrUupGnECUmm9FChS7CgGdG6j67s4RXh2LpyhYUKAL+fKdkGdYphklXqxpz9Xauoc5IBax2NsuRs8owU/jFLa+mJcFzBD9lBGTe8QrPCNLmj4pbyWl1Pl/xUi1czChWf/rOv1X3lbJPMz9ULtqwJCprfcVqBExQ384pQCcF8gCsiZZJHxoVqCJpIeQfh8NjOWtYGGXR8jzE+VzI1FSCcYRG9hhSE0EraMgs3ma/P2koKRmxOCpuuEsk+fFgsUiJOFGPM8Sr1K6WtykkcJoLwBMf2RHImcDGRHSQ4TtLYlqS6CZRxGY2GbUDnBvp+o1zQOBb79X8M0tPwjkVqeA3fsTyHc8D5l9Prhbf952GvH45uXsLn/uSx/xI+3Q8HD5MRHHuPD5MpuoQwYX8wgGP4NO3f1ti56Cd0hX5AV98UIpXgM4kE448ycYnnjw3gdpQma2pe31yAxonYcKgy+hG1PR9iRJylqfPm7faHZvmQuWD05m3BKHPhokbG6BwA6loMkzWwIIt2tiWp7xoSZO4+uj4hgybCOXaTm2dSOLQ+4wDYWrZT+5NObdup80mnju3U/aRT95vpH74EF0WFty1kIIK/GHf40jXCGc4N296hkBWGMwyGtZNAYVpoyzOTkAfSQmseCiRQY6VTkwFS2SuOvnu3b6KW57tKb09L7txRCjMVEh/HkcidtzL/lu/5ubecqyKrbS7U85WLuyD0PbOFNJSuU9HQznFXwR0GexNZacueLSdcpOJ76kNt4nMI4YAKZql9dQUmTVmnS8SbQPmZCipziWZuYD7jf1LxOimWDl0g54Qqb4d+RcCCHIVz1TXCs/TcBeKXQ2uwbQXm0lrLHlTIOknHd0TilMBtZxHsbf5+xKoK8+UadTRItcnB+jS38vYGgxPU2iJf44Zcq8iqm6x2aSJVDY2i6CHA0T7iyNe/ucxs4zzFCt/WqW+BRDNnKTzd3CfCXbN0PGzVxitfeKSs/RFlujWt9DVDcDG6NKNiG+zdz5BcB6X1v6unXrQFaWf43JJJq9hGtokcFL/7s5z5ihKsDcfAfB4F/naDk1KXbA/bo60uhmnvj0m3p2mvd0FJeNiqL1lY7KWCzKBxAeROb0bju344mDyMwsljcZn9zoQv4hfVQb/p2dTF3dldBbV20S/mcXRBkjldwLXWEyf/n0GfYJkjR1bx/FMaNMofXKpoM4uMenYc2I1KdnzPyYzgHRGOhy/9u/Dmbvj1ftS/f2xoy+PjGthbywc0/JDfhaLG+dkNSh7yKW48LmRVzuKVLVT2+cNDifKnhHxLy7TRMg7H9vbnwnED9P4v4DOUEZ4NAAA=")}, + {"frag", GzipedString("H4sIAAAAAAAACqVWWW/bOBB+168YoEBBJYpWUtI2CzULpLHbLdCiRZy0u08GI9MOUV1L0a6dRf77zpCUdcTtw9YvMuf45uQMvVqJTDayKuFeru5rWOYV16nXaLXONMxqJbX4IpQW2wnXHP71NiI7g7pqpEal1B6zKq9U6j2O9N4qvipEqTvNBNYbI2fUrq5mvKhz8VXq+8u8vuczUXPFtViwxjBUMgG0HIBT9RHlmVyi4vx2Np1PP76ZTibTyfzyw+c/Lz0l9FqVJHvGUAsPghltVAzV6i6AERWODTCLwiiAKHzho5ifes9E3ogWbQxE7HIhl96jJ0vr12a+3kQpHU3yzPljtRCpkzgzlJl8EJ+Wy0boIf0zRlw00SFinNqciQ3PZ7nMxOL2C+ulwpYiggso5JaZuDEUP+jjBtBoUbMeJdzutjuKxfzxMaI9BNhfHfUh4icQ8VMI60rcdyUeudLiOK0Bq3MlHrkSH4rmAETUdyWBbwjD6jh8+A4nGA9+ffjNULY7S0FhJ3vnZJFzZGVbCTrHP9J1DfINhUwr3WFje7YDqGBvZZ73Cxa47iiwM6h49sSp7dE+Jgs7YAmM2PDHBSSYvb1Uo7nSKDXIWOqYipcrMWLuXGgLqZCD7p0M2A/fW2XUzUn5BK9oyVA8xKzSZ+tjXFF4Gp+fRr+fn7/E77n10Np7DZH10CIc26qZm3SShG2hjOOBtUK1acPtmJg4A9gKYRKB7t9B5A7Y8AKbmCfAfWaLT8AtdD/PsY2CSNhVOyINmgqePwfDeD1k7Ezs/ep1fjtqZKgd3dnY/sjG9hdstN1o6ETZVHJBA9YM4vdlvdasWh8czLKdqjRSb6Z/3dxeT9FX1o4xcvfUZSnEVrI+Rtgew7FGt+N4TKNO62W9j5kMMJeKZ9rwI/+XoeMB9HB8/j8Lw9gpwfs10K4yk1m70H6yvox0hUA/WX7drhkH5upQhRyOLkZjhhwbTsQH0/SuM6rU+noKs+t3b26qD7IUXAEzpBUvCk7ITticMUnmm+53HS0nt+vHDbMu5bJSBXSRZ9m8MTm5sSt0vzkNENZ7BYxMHmrJ1Bu2rvSfWuxeHqYs9t/RuBJjLwKgQu63/CGQvaNk8f1s/u768m/PcOgVgXL9BLI9AzH7QpRXtqh0JxBYWhQmcfKSHhyv4hcJfaNXSeL7I/3mH6UH4M4pV6H2yeXlfIcXm+VVxulFRjPBB7rqNrRsTpm9stJmKBRclpT4Ac/ewBXzU3j8D0vBljgUCgAA")} +}}, +{{ + {"vert", GzipedString("H4sIAAAAAAAACn1UUW+bMBB+51ectBeYOpR0eRrapoylUSTSoibt9oZcMKk3YyNjaNIq/322gRVWvBfQ3Xd3393HHU4pcEoqwhk8ksNjCTnlSAYORSdeS7eS2Xwx86BmJOeigDBcU/6AKLw4bThAg9MFpGkiSYEDp8AZqYvyr7dKBcZsR54nMIYkaXCLnf9DGaICCzSgLJA0BdT7nuCnwAZsWDOJxYL/sgK2JF3QmtiDo+R+ztT0H/PKKk+K6IQ++FjyqhYTSIEIi4j8ToQVCznlEygqHghmcvf7ZMXWgtcsewvn/GApqpBvqJroUwHLbKIUw0hcoYlKjdaRC2kW4h3J4W63SqKbcBnZ1yPi6WAhBx/lBxc0Cyz+zb5Hem6qLEnYYYvKu/sYCVS0XWCWkdw0s1tu42iVXN3ebJPbfY8Qpkt8BJSoz0WkOqWg810qn8THkHOR9b6F8qWtjGqcjnxkX0LdzALHIA0WElxPTWdMRQCfTY77ynYBc+9fsdrAwbjwXiePptHR8ebnKkqW0WZ9vV1d70d5eqf7NPXwj6dnhan/AxduZ3vBKENfwCsRrfCbeuMI04oaVoUMhZqQug0a3pL/BF9g7s/gq9HMVRH+8cJ4PmgB/ZMHn1olOyKjsqHq9BZY1oK1zZydhpMM9PFoueFAk7jT1ygupOsFcP4D+l2MJi8FAAA=")}, + {"frag", GzipedString("H4sIAAAAAAAACo1T34ucMBB+z18xcC/xukhW9noPdh+81WsLLZTTo+2TZDVqwDUSs0uPsv97J9H9cbYcBYlMZuabb76ZkF6LQg5SddDIuumhahU3ITmIYgWbTcp3fSu+S9NEbd/wVPRccyNKOjiHDmIw4tcCMDyA/cGD3+RGVpiYP6dJnnx9SOI4ifPoy7dPEdHC7HVnY1cUs9AQ1GVjoq/r7QJmt/DOAVPmswUw/87DMC8kN6IdxAltDmTdXSkrcnRMLA1XPc+SNCMtf1F7QwdTLlfMg30nK6V3cInI4yiLsAsnA3DbdNZoMTSqLUNyPKMflCyv0oDKsTEoVKv0SYdZdbyhzu9z+DAD96CUQ8F1edXAv4pcEXujivP/V41XvMMzXpb8yJ6fksltZ8tCcpLrMvyiyIdeSyOycQwXfSxmpXkN1NJ0poL1OPzlAqbP+7uigtv1W5s3L2mnziacz2n+8Sn6OU2v1vwFsCbzg2XwHm5B+RpXivn3y7vAmbUz2X0wmtuQ2JC189hzi6dFObc1/RzHSbGL8lQhjWktFS7LadtaVXBjXxhS8QBvJsWL/BEF2owwbtY7Ljur1ysfplkhqRfC8Q+yXQYJrwMAAA==")} +}}, +{{ + {"vert", GzipedString("H4sIAAAAAAAACuUbXXPiRvKdX6Gt1KWEjQkCe7MXkrtiAXu52EAB9uZqy6WSkbC1ERKRBAYn/u/XPR+aGWmE8W4uL3nxou6e/pqeme6e2coq9uZ+4keh8eDfP6yMRRA5absifRiuN49cr9U0TArdePNTI76/c6rG7xX81/iJfBpHRvPsrN5QR0/9+xAIrHrDODHMJPVWptV8V2/UDBMHfWrdVo1jo1E/q1aRQX54f7uKQi9MgQXggMJcRq5JcKYfpmaBSc0g7KsI0IhrSuJOgPT7vMArJ0z9JEGjtKKaOlFHxtuzs9ZbUPCYuOKTdUu8IUEat/DrXevdu7eNdygz9tJ1HFL3HBnedtU0M1tPjGYL+AKca9OuPFeSNF7PwaGpE7pO7N54cToIV+sUZkGamFWU+CnMZ7sCny0jjOKlE5CPUwNG3gN/YNau+KFBCBxbjBAwPoxCmgBJvW03imKXw04Rxvl94y+Mbte+nvbtq9Fk/AFpqDsdewN6etsBGZga9156wwAmiR/qBvSvIK2iuYGzi9YpTKFrnYIv1qG/AKVAzFUUrx5gKFFiPrddP1kFztxbgiofPfBEmnyyzm7bWoKZtwWB3iBcRMQNxDpQauxvveAymjvoCZNAU0o68ZIoWCO4hmoaK6QchK63Rf2plQJ2DnFDQ0aiazOyLSAxpiTyWlFMXQzYUW5RLA8xvisZw3yJypvbmrEjblQMJDN4HkdL1dKAfdUMveHSRJEBJh9QBzHZ7x0uDFgXOv1QExYkvf7NoNu3p9fj8Wgys88vR52ZPev/Mrue9OmULbx0/nADgdiJY2eH6rJZMxNnuQq8uNlDCbrp8LkBU//JA+cxRfDLJEMawk/w7QXnKIuiyFjJ0cY/OCM0U4J/J+BVyhGM84LE+wL1vYCEpTBAMQkskAlgQzhlIcu9DhSF6C0P+fp2J1tSZcy2EpdiiGSijmloNXA3hT9g+15JnPvuVdytV3J/ehX35uHcxWo6NSv8DDRZQNGI2cIZUILalaOeEAVmVljghK6/YOsdDOkVdjM8fCBWpAD5bR3hgeizaDylW2vsLR0ExRnqhFKSqIHFZ0oUP0HcilVdsovi6Nv6FtQ0MLyNAg/rUB67ch7NQ3k8ZTwOo39E9z7TY5AcO/OW7NwXFiY7i7jb2eZFTjd7POl3R1fj61m/xzUpX/SEo8ytDvlAW2wYLZi4ZB3ghOKXiQFKdxVUI8TT0p97CZnUdN/afsJjI4oNGi8zJwajYVSjnX38KEyYdSYX/ZndHV0PZ23j+JiR0Lkg6hxDAvSCVUK5o0zGccFWQJbENZNJ1gHzIxXe5sviWXU80/pDZ2qPR9PBbDAaVnhiIOYQfDRmOY0sNWlnsaBDm9Ksu1JMvhA6ZcJqhpLNMHvKrBmOJledS70tQ5KLlVhSRH65HRpBr7Ni1hle9IczvRkzmiyW2KHBfrkhOlF6SzaR7xrOahXsaFYJMiHp1OTYTprGfPvljOjJI9LZ9svBimzqPOGGcwZPryLsuDRGJRsOiyjCnGbzsjgJclwSRoeL4tNOOLOaQBYmg47LJrso7rlsdpQ6p7A569ye8/iBzlYmV9ZL9QdWPdOfB8PhYHghFUefI59EuIA80uNJKZfed37u9+zOcHDVIZoiCuGD4RTc2mUspfqOMe6E/pIWMUyZ0nJp+qsfhn54z9aHWi3CYiHs8mXRi9xQPs2stPyEesCMj6Z0yqYgC+dn4ouy9SKTTy3sD7RuicziFOk8/VI5AiaeYnj8BwVcOWnsbw3aETB8Hni52ZJ7CZ8h1lq0a5Gbtjrm8nnYDmLRxyIqj3jirilhnvc64a6ZWiFBh3zKvCaL8cMNq6V0Yx7V5omoVz9jSkCHVlWarURzAiP0mmJtgtzMHeu2CH6ssN9Yor4zcyxoIWua28JgkplzDs3DOFjlHFqHcWjqOLDjDGPMJFXGxsINidcnFNQsglpFkFV/hJ9N8reFfy1sS4m69E+IY6v5/wxkzv3vG8kldebrAltXc74usF/JQRPYr+TQ0nCoKCv09Z45/Wqtzr6aw9uv5vD9Xs+0vsgz775aq39+fdT9CYGri9zKX7en0tzioK2VFOPulpXvflVe8yJ1QQqau4i4L2DR8Ft5/nUUzdu/1gvE/gQyM257lbfmqWo8THlCLCZJdZpJ0bBdkgOF5cr1beW4hHCnEu5KCZ9UwqdSwkeVkPSPSAlCU8/S8oO4YAmGCjdgMchJsOkPjMU1i5ZreclZwl4pG5kMBdaWiz9ynQUUdC4EnM52FSe+rSvgcoMkpDLy+cUy5CKI7kANnrobWfKe+ks4CJee66+XIqVP5rHnhfSQzONCKDw2HsXtq1W6ztKLHUkk8SQwgH9vfC878QuIQbjR4sZx9LkUUTYIGZYO5EhlMLdzTvSH0rTUPXMn0PjH20IIkIIqj8G266UPhXdciutGQaTBOss7HyZ++uuuFHcRR+vQLaIX0X0JU8C8dxKNnoDouBpWoefE546G0wb9GMX0alNfQ7PqGZz+MYoDt9HWAC0dsCk4Xg4uPsyuOmOJKsDNAorSK2d1fTN2YmfZlg4INu59Z9b9wPTg96LuLrTvnHT+YPvuniDGq4zgPdJ5bhbKUgQRFZNPVoPXvXtLaMKtlE27BD6YtXMVt87q5xd7EVGYwAYCZwI7IVI/AB6jxSLxUnauOcGd50bKB4nyTuh212m0WDDU6i4mYhP27S39JIFdIfdJxgr9qO8vfRJH0b3Jt/LszIIgSmiDiBPDIsSOOwDhL2g/J4lJtjRrZEh2YQuBCxt5nNLDmcU33qBk6H7oqshddiDOA2e5Mk1GdMJF44WqAHIJePNYx+OYHMbZY4kDrcIFlqZemKkCyw3LpkOt6HkhHDI7leCp6LOlszX3+U0yiJ4nYGum2xEk8plMvArdrswTzvtIUkPkFAvFGdPf1k7suX8jn+i887KrLp2d92f5yQYus2ilILcycoIphILesWsAUJ5sN3ggUoLMNTTLkAnq6OhGnQ19JOAoYUMfsyEyIhvC7Oh5Qer05JUtU9cUfXKTQN4pyWz+W8MfxMWDMPXuY/J6ZmEoEwwK/Is7iNQGgH+k8B9lOGOJ6Rd35wm1aYd6CC9yRXKSsS/BWBxJv6Dukq5QhRDikiILBD8L+lJlJS90VJVV24uqqy58f5i9bUlz5y4xueQTzqaqtQZJM9ojQ/wi1eiJYXIljgzxizzz0voM2b3KUL1GJdNUpVfXmXfIUBpPnO4NThALFr7vmMlvcYovKPDtm8nj+zvOG8sbDbRKHrAVo1e2mkugMZHbfhb6vYUVOfZs0hlOz/sT+3x0AZnQtJ9tMjUDKx/GzZmnUVyt/C737GEEeapQoVgQKM7uFTl2aY6lkluCnJ2I5bRNhVY6MMqHtCRtxMaZ0UP6leEtXJ3KVfYbxqvT7V5POjPCtCK8sME90abj28olZc6RykZdyljrfeJ4WZB8tYWqSKnexk4eHDd6JEVI+cUModGllZeYJ44DJ/TkEihPIBdjOpw8NquAiEyomxDZ81bpA71v0lEdSEKxQfS4MnLY4fnltBz78cP4fTn2cjwclmNZZfScXQpO+t3+4KZvTz90eqOP++7OKAPIwPfesCWriDqSZuvKzRjGy01/Muv/YndHl6OJVNbMqV5Zv2PDIWw4Q7QAIfoNEpA/IGWgJoDWm9ynJQorelttY2klMcnel0qwO1+8OhWW4G3vtN8dDXv29Y3xxx+6ak1+xWoV/MCJjW+/Nd7INRsBwMScjyYfO5Oe3en1ZH0CNIutUMnPXWceXN+YfD97k6tHyTjIUGiaU6ymEHUs60svFzSET7ByKLenUmbZtYskVle56qRq6VShepLifTnxErYZaJOw2PEaQAwNQrmpxVqHHELbj4Qoa2uJx8oAZbFBwOWvk8WTAnMQFt43KPf5tEmnkNF+HCuNa4ZcJGs6DxxNEv/01Kwwk7I+hNRzzeOsPbjmHlwDG7UyG+Wzydu42DAX2lMFWR9A07qQDFE6D/TpttzNqN7u40t75hpWuUG5/gOPIXbsSVwhSKWgwcCUAmjFCwG+JQGM/sAnwaYkkbU5s9CS+ptVMbOzj6PpoNenVQd2nXp+7M1ThWu+cIEEUehUlVQ5gtIjSk3+XZMYViHJBvnGv40TzOd+UFIJza6ZbZZ6+yTr9C1cola2t6L74yhJZNW4gCr1N2fzKKYGtnS68Nj2AYRyh4fuLgoE9xE0Ztq5Gl9CyjIZXdmTGeek+PERSieLOIRcAyEJPsum/6+EfEHe/QM7ZspOBsLZUpS0vkpL6wA1LVVPSygqnUJ7DmV29BKt1UM4nxPSHFTK2bJlpKRS9DKi2NU86OjTnnKZRvdB9hoyk81EmqLjDV88MKv51fv8Px/vuOmTNAAA")}, + {"frag", GzipedString("H4sIAAAAAAAACu09a3PixrLf/SuUStUpYWNisL3ZHMc5hQE/qljbBd7N7j21RckgvDoREpGEASf+77d7nj3SCLM2m+y5d/3BoJnunp6enp7uac2wNU38YZAGceR8Cu4+TZ1xGHvZ0VboLeNZ5qbZqH6wV3FmUTCOk4nTap2F8a0XOn9scXDHufeHB85wOMiCiX+0NfFHwWwyVaXpMPH9qB88WOoiLwvufV73uKLJljfxE480OfEyRgA+3wX+/Kis4iK6t9ZdJ/F/SivKkJBgKaKsNJBlP4eM/+s4LRXP0Ast8vEX0zidJZaaiRdE3SBrB0lpXSsOY0utN7kN/Cjr/7YsrTtL4lk0KlaP47sSolBz4qUWPqGiObKQinwvOfUslO5RjnGSrVSIOEozL8pS0AiGlwVhEN1djcepD4isyAtv/VFsPDAhN6NRa5bF47Gomt4m117iTVLx7E+CNAWlzD0yXAbIGGNzxOkGrBvxnctJxWlFcgR9SJ1jLJLAoAODUYCF8B+4H/ou1YwqQ6lIaJBbP/OSDMC1eGsLUt2JRmYljGfiZ7MkcoahN5m6rgDalU1XnB8cXShbqFSdvVrVqdeg7UdBvrOYrtkrHN8s8yPFCox27WH9XrT9KA2ypQnwUJTZxFu4q+RGOoT92cO+Kt62nYOaahOIwbRydyXtbcJGRYlwbAij//vMS/zR/yOZ2KTztKi63tLflJwGQOUmnhqVC1rZ86I736heskm7j8z/GifhCO0xB1CiqS2W0AIFqKGg92oCdc6K41SgzhUKrVAooh9tP8y8Np3ZFLpq8JMbhEZtzyTzoYpfmIgvosy/S7zwaCsYO8YAAwO/SAGhgLF+zst/puWCJHDmSnHu8j4tkQ8tRclIrmVAlCS2ybe92iGMueOHqW80wkRSJIHFjxq+lFkihabJstn3IuumCE/W6+8R4dy7TV3Z8q4kU7H2BkEV7Lajv4FUcMq5koltR3/DuopVZkjuszpq56hkmJhNf9TSYahcnyTcdzhAQlmk3XHT35PMrdf2nB1HdraNistxKkDcUgp/vP2c9tJeyxa4TuTMz9huW+7jYARO4OCm17zsn3Z6g9Ors8FJs99RRqbqgJvgCGreMIuTytYfW99DNwHtbb+DGM4xtLrFa6FBvXZP2bL7vR8WwOsaXKyI5bANA5YsGOUo+4QbbTgVfOrr+jrOzu/9aBSMiUCa19fdD1oaQYRS4I4UumlVUyIwAKwYyCGMOwkWLnHqasndbZUj8q8CTZZ5TJdQpt+JbjRbrbe95g3rz1YQidbukeKAIyueCxwXmEX2SokX+yo6SBurrJKQRTiGvZfN21qnUjzaKlVEZfTRmdqrKAGqwSRkcAxscirtqKL1yNepfu/s5CbmSuy4rOjOm0w87IeYO+wZJiT7RMTS8Kr/yRvFcxVekaimCwXZdehFPg188gA0BLPVUVwV97A2IVrCyrY/zT5dROPYDrUmCK8N4/nUydVennb75bW/nl+flNd2ry8vy2tFPKRCAgiP/YwPC+P4NIknKIL+1AO3gI0Tj3BSveSh1wAKEfrRXfbJldXKBjIfj68NZm9qC+bRF8uXJdDa5ObZdAuTgXUTeWH+I/fdcsMKumXoPTpKXPcV70+Ig5BHZGVhYBr0Oq3OxbvOoH/ebF/9uiWVlY99CvFN6CeNtu7mG296tBJqGnPOIVBksKyDzek0XHL1Z/ydBF46OAXeLoGMF/IFRmgYTmwtJg6AywyDiaAnEgwkpVBwrXULulR7AP8NPPK9vbqigMLgRJ+QNAfiHj0jrzGB7s9QDkQpPyBaZ+eYNIAF28W5kysmzG6LkJK2xBjYq1dZezhwYshpy8Jclcj52k/SqT/ELaCCoMVaAu2lqCoKSYiLzyKmRawZ+oTdICNQ1tmHeQ7twcB6oEh5M1VbgGOkYecrYZcF9h5wOOzWjbUbMREHD2KGEER0sIpCEco8DIOpFgl94iLJC8muAjnMh3ke8yGPSMQCPUNNbbglAEuttjbDpaYFTgz0VwxOgJE17AmVVr4v6NrmSljkA/YSzRbTc1I7J2ptCneVWl8l2acYPN/pp2D4WXot4vvYH4+bTqmCqBiYAZ6UAy4lIBXLgMmAqvmuIIRrCW/b1NfBgzQeVqVL/HQWZqbJ42VM3DlK27J7O6JVtVJwnNwKxUV7ynyfcy8ZOTl5qoUKRweeL33U1qdHhQxIwQuozStyG4ETRQkr8mz2/kAL5jzSgh6xsJgpNq8FK4HWeM/5809HF/2CqgZFW7JoWYRaFqEeilAPHAqE4AghYpjgPCqcxTK/+zFnYQ2Q+ZeYpgqytmBLN6qDLoMI9J/kWSoUFxiL4tTuxTCMUz/NmMBljTHJ1XKyLExyA3MUZ27mL6A/vktX9yphpFLl6yEwzLn+wWkcHuqHV4d7DfJYf3X4ur7/I5QYQXiu4Scbxan3uKU6n2b+VAnwoWpIQHtAHHyFXvfjcfZNr78KvY5ZAkHqg2KHia0Bkc0UM1XU4CrZLpYCKI78G2/KI3aQp8ARlYLigLdDmkAHTaBKXm7DePgbaDD7rIvPhvjcX3ducSpSWUn/qivmmSlBPQWWlRfMO1A+3pUXMCMEt3GeGpsRkGRvIzztb1ROm2JN2c4VivXZSsUi0xXK8VzF0HTtA/zcwdV07YP0wgEyAnX0kt47DmZ74hFli1sL3ALYllZGu4bcmXqPWMHCzZsSRrNiwn6gsMrM5GHx6UOBm6XiZkm50flIJCxYqsr2OOkP+T2J/MrYeP9tbfy/vjZKB5JOhEGXLo/AodT3EvCeAb7zFPhbAr7U1Jcl4G0DfKcAvnqxFp8H4vNQfL4Snz+Kz9d/2aKuZJw3P4O3f/cSXzSJm+HpJUu80rEvw9oGVnoykpvxPg6+JpfxcKNjtxmeXn2R6dfeBGs/bnb6bYSn119k+r2Utc14syut6ct9W7tFfLlvu9KqbczFzVkmTdduYV4QO9itxHMthKZrn+kvnOWavH22Pnemarr2GffC2WYJTT4vMOEBxLrhQ/lu4wsDHOKSSVjRys4xjVYcS7hiaZp4fJKcpVHi/22iUUsfLI0SJ3Nlo+u1aemCpU3l0D6nTbJpyoKsxmE+QpSJ3KeSA5Y3PNaMG2li8lvY+JekCsSbEMXwciM5BDP3/5dmElY0bcsnjLid/pxcgm0+2JIK3+bDVzAfRlTp10uCS5TCOztqJIkmWmaQ1JZbGErrBs3cvj+zYifn705kjOzxQ36u/TWJjGcw88UTGS8T0JdJZGxETl84kTEqusmfoVSWYO8zCa6dyHg+o6sTGS/m90WJDIvJ+SpSGkW+npfcKFuqi1mOb4v1t8V65WL9LePyt2Vcnr+QffGMy0bW/Q1nXF4gri+dcdnISG444/I1+LaHGx27DWdcNjr9Nptx2cz022zGZaPT7wtlXJ7nda6dcXmxs1yScXkm2+tmXF4slZKMy6aCnLyVeJmFsGRcNqYW9ozLy9XCnnHZmFp8y7h8y7j8XRkXcSCVnIm9OOmqA3biaF1rduuze2qi+yCJo4kfyetXxol3d8MnQDceOa4+iwfTgus/sBAnI3kkJoxH5OxqplBdBi9AEUgdvilpgvEkG9l/WSP7ziyaesPfemcnHRGhJ3e3PqGBj3hcGiQ3jeewKoJmsjI8ecsWRjxb1HjNDj09UnG2L05P4fNN87pMqiD/8Sz12WlFORz8g/fm7Oz9m/g2CH3HFfMunt19ivxUnTO6jM+FGOTnpdhJgG+Lc4yxkjhN3cuqc65m71XkvwmiWQrI/d8TkU0B6CqiKCgPKlR70Ff1XQLgtR5AAqo8WYSRqIdHVnNN7Dh4FUaktXGK4iSbJ1447E/94SzEw86f11d5iJbyijrO9jEah2j/lBxdQpSRwz5rXTjptU+b02kSL8SJ61TwJFmw8PSOH7uPUnn2HH0e5kDtMg9qF0xs48dD9uXwxwY7Htdo4ME1glOXOAwFIA4ah8zBOuAEDiryMFZuUIZ4gcOwrsZsb++AmY3ITSBmh0HD5cNfTBvu7k+1xmsoQY4rvAZQk5rcSWiecB4ajO8D3joCMpoIiecpmycQOm9j5I6nRQ9xH2dbSal2x3jPnRCWtQAI2NgoEpFzBSdKr3Pa7bRuLq4uB+3O5dVFv8OH48zPOtF9zx+HuNsVR78G2ac3wfQ0CDM/gYWWj1GvdHAmwbQVz6JMPo/8KA5SH++t4LdQmFcCoPlTiDk5S1J64yjMcIK4OHVGp6OF2wO/Gb4s4QuTb31vjyyugH/CN3zQWDMhMR+ay5FRI7KTo417RD5eAmVaQtc0yFUUAbK8I5uR+GMmKUaB+ComKt5eYMiA33XBm2aG75jYSJeXo5EQtIsgskbdi2DQovcauLqmSNEApHX6GgiyQaspVR0KXC2OumRLYKMS8RGR/+g9E+JLmiWzYeb0My8aecmoP0vG3tCXe7bkKrJ9vK0kQG0Vj/yor3gw7h7bd0L0GCc6kyafB5mfKlUr2N2Jn3lhGAzVi9vDYThLWYuPYuBbLcUpLPswVfCGKcfNs883oYuv3u87YmVCh7fGeyfWQJdvraY1yYXcY1bTnKu4lOoBTAtKompBvQQcfSI6rfHvsvadUZu/6onxIkWu1q5LRMLbs/DmHLa6VZ13lYocXcKrNvmuNvZpja4T7yQnXYOT3SG9pE+cRubLkwHXhXn5TnN2LjgTXJ0rpkR916zvqnpGehxEXtgSl7wA7Hb+OkAxTPnS+ZExrq04ypIAZ5koOFLGuHtxdn4DPovzj38432HBSfOmdX5xecYKwEycXvV+bfbag2a7zTZX05qhtvreA7z+grKrAZFJ7oLiPMzx9MOxs1+rH9QPf2q8Otw//ElfMUPVTPeArC/UjXDNQdRrvZBDwpjRZNwcGzv5piqF4KnO7uyx3WaBsoLCzmXzpIuOYE/ecoECg2H7hd/W9oe8GmLKkjNP3VVBkj2XipvpcGxNEYg3a7Aakys/VTTfJedwxMVEbP9Go+49jUoRyyHxDS4BqYDQUvAHtvCRJJbKv8wr/IYroQT5gds+Vi/NEGXbPs6PsLpArDm5ZXHvIViOS3RmeLaLaYU3uW2DFgjGhvQqTXF5Uu4GTbHeAM3CMloSCbDh1n6/uTLrcj7CVhJ8fdaskpVX46tFTsMZ66mGNFdUOtV6hhlLuBvm7r5D3ipHT3pv4GYAgSd9uF7O3BZEPEcD+Ep1iAkQaE+Y8J52jAhxbhdz1Ev8H9IFImDeLuVFAhnS5WBWyRIlhcgdcSlTqGhz4lHj1xpZ361ExBBry58jJtfyHC2TSFrTvol2jA5cDUXWcU+HTM1Wp38TR0yXXRGPh+ZdZBiNkBu53Nfcw+XxD5+VeBtGo3ZYN0tP+AbVvlnaYrAHudI2n9Q/maUdVlo/0FctcabAj2myqypY752TCr9nSda1SF27Av86elOi1ToFnbuaZdOZfAHPuN5MKNJ5u7elrlpD267l5KpyrR0UlF3NR2HkBSXiJiq8iY3ckHU/UOvCc1dx7gQDpXB2f5TfrOC3K4W5m5X2nbdsWshNT9D3nDC4Mki764sc9Y68bA7l/LomL2aBYauhrohuQ6WPRXeq6E4W3aqiW14kpUP2tHSHtDPOyxpQhn2kT/UjgiDddSnId53eTef9oHXVveoJMBS5GAuyh8YuleuedNpXA8uODwiRzx1jr0egXV713jS7DE0zkuGVkBhw6qLbQBUWyXPGbeSvT3olLE1vExvCm85Ns9u9AKfm6u3Z+WWn3y/Bl458T1pYG7WrVqv7to/Lg52IMkk25M6bi34f/So7rrRZNtRm9/q8ObiBaWfcUZhC7OO4eFVgIRpS7+DceugHcuslYzurQihAbnxzy4BQEzGLNayHkLLSW6VFjBtwECQz0ldQulR1BPRbDDEkpC2CpnWUG+RF1ilWpKUHIgrwaMsMBY+tl27zu3QtY8BDBUFAlw9a583Ly07X+dlObl7B2/OGMEwFOX2WjWOSFA6hKUvTuFW5FcS3t7HDMmIB+KK90+QMWB4GHQtCD0Sokbz9rWhniA3g2waTCXUO1ewG54tDwoCL+FeE2oeMCdnElosU2B5g8YZzlKpxCZm0NrDWCcTlmojKJiEqwzTvNyPRvBKDNMpMEMZ2CbutHYrJne15K3Yv7qQiwuFmrOogCJsHUIA9P0a4WsKfl/L5jj8/yOdb/jyXz8UJWWIPGScFE0j4spnHHJeMiwKc5Glpr717wsaq7ktGqIlVDNTodFcQXPiYXaSOMy9cYqFkR5Q9YJlUFCiTX4U3alEhw0AY9p0QyptS2RNi8KuOQma9oe6UysNQEyCKri+uO92Ly87g5sN1h98Z/L0z8sHR9R1mUvqD605vcN3s9526cPTLAfZyeTQR8uNw3HR6nTa3UoPWW1CgS3FFcek1radxMgdLx2yMuqz1XlxHyswLOHn/zvHwUV4OKECYQXoKCNPB7NLpZnQX+k9BtwMbwUcdjzAXrz+J4+xTO0izZpbJLA5ebdr/XSVQgugenqC+542CGbkiVd2aKxBAd3KwavuFNXMq4fkOOt+VFES2xRdrNoJibxuPOh0FQeszu+Hhre8zT1g3+VImv8Wf4QNH9W38ByxRYFR4Kj+J4VQLjam+EHyDdzamjHm+bSmyZSHbqFSZ0oDDsZmZL+Q/tKG7NRyJLKGk0dVpQqPHfDQAfNtsAPx+k7ZtbFxDIJQyTa2uM8Psm+DN0SjAt6a/2o3wst1ZUKLcluh/1b65sQss5VHByCZzotmEmbuUbRlajLPzr4LR/SdMicylxmnvI9vIATPquEg1wLj/CD5+ziND4c6O/EWFwPnlWHNQcW4T3/tNMN3vvuX7qsruBh8LglOwhqwBVXa9f56rMZIB/fxuf7+bSwf08/mCfj5hIO0En5/QNFJ5W9EpJWE2SGdyxh/7VQDnJDX2tv4uYYMwnE2c3G49zgyDCLd/RlFVMl2hVkTVX7ANNW07y9nml80KU2rgY3RiFpGW+LZkztBW8whyCEPU73XzDH1MNPRFpkG8ek4VaK63/uXbW+lFFPkJGeVdqtlc6bRm1Mm5lvRqljHMcgk9kIEl1piKV1zyrBjZVZQreeQreRpwVzWes/NsJFD6ZBkCpaw61k7l1qDc6qP2GI2wzXRzgBLLJa2dmVkxKBg2lktyTpM2L0y9lJ8Sojkewz6vkZUpo7qa5hpEWOamjAjJzZBxsqdldo6ZydumI7pdHFHctObGhTkBaFIKyTk2Kyvk+ubCbvWefCPrM/3zOvHPD/bxFcggQu8BRHRQgQgRehWFS+d2Nh6D/t8OhkO+fJzwgj+4J6HL//3xyDF+6SxH9NBKFKIxmF6MwgVADn1Nf4YrnBXkqaZePdXUWRKMdDuyIzkA0Yp4JQIiT6yQmUwytWxxycowpBh1sCBDNsTZkNfDT4LoBDM4qTDTYMrks8ZRPAMWE1ssfkGOPcgRYhiiH86dn4mvLgMK8OJuWcn4OuKKXiNdxX0yPeAHM1RgfP9s9jEPLM2YDbxeBDcFVILXKOKB7EqA9xFYzBnRncctJSfsvnrgAhDDj2LgGnEHVfdsSbTohiiANghN+He0hf9r6jy5IIKeB6uQjJIqfQKTE3jkowYcIlWp9/6Cs5nyX0Ejo4wcCwL22cJQ8OgZA/9IWxDK9j+8AdZtdb5P2f9UrKXsyW0cYBIpjO9weRG/flhb8mP28nGhllRx/G/X1cjbeeTFOgQVRX/py+spdt2h+slKIKs4x5WJ9fCB9Qtzm+hJMwcNmpEUkJVURG3IJ7elOk7j2BZxEWlhYrbFX7ctSM9koSBtcpBSnhxk1TgX8NXpoR+E7J179bujtQX+SBUTZP1VxYb3wY63VHivEW3GLEnA1QOlw4KVGXsrUnUID6P+IN/v14xVjeYwZuI9rEhjw2vxTZP6K5yMr2cVtsnBGqvh7yrwclmChyLl9wX55UdGhqQjhfC+xbgbiHGZe73hKDc3+vnZchcOTs254mqm1eugpjHlZLSdliZaNEZjasO4igh5pkLkGY+R63vs25OBMUMMleHlbOSMMTHzVVg8j8y1UwhALLCaVMWIugvr618WeJP4aqOh96pV/euOvldy/l8QgBd1aa0YvOBOrRGGrxTV1xOJl3TtOcG4xbd9Tjy+coy+RdsbjbZtQ/ZFAm4RhYbxUCYHYDjVTzRydwrw3h/x9zLwdWXHxQEvOC5H7KUNN9Wv6q0Txeu3kZi47W6Si16RfoHKfMtQI5ckEmzYhV95lO++6XEU74prEbA29GtlHEPIEn9V1LXvjP/5p0hxtjoq0YmzCkRQ+TLiXy0WPGRQFMmGZWETRX3d3u4dWSDrNsi6DbJhg2zYIPdtkPufJWvNNHHMSbE6M0bdRbIWUhINDRuJHxc0PHPNogaUqfYqfW2UTPD/BbxdCZtXggAA")} +} +,{ + {"vert", GzipedString("H4sIAAAAAAAACuVZ3U/jSBJ/z1/R0uokZwKZ2IFZTt59yIQw5BaSiARmJYQsT9wBzzp2znY+b/nfr6o/7HbchjDs7cu9QFxV/avPru6ya4uYTv3Ej0Ly5D8+LcgsiNzUrikPxKPTyKNtixicuqLTExI/fnPr5D81/E9+ZY/kA7FOT5ut4uqx/xiCgNlskWNiJCldGKZ11mwdEQMX3bcf6qRBWs3Teh0B9pf3NosopGEKEMADCWMeeQbjGX6YGiWQI8Lg60jQqLMUdccg+vO+wms3TP0kQae0qiydqg/k0+lp+xMY2GChuDcfWDQUSusBfp21z84+tc5QZ0zTZRzy8HwgdLOwjMzXY2K1ARfo0hq79lxL0ng5hYCmbui5sXdH47QfLpYpZEFJzCJK/BTyadfgsU3CKJ67AXs4IbDyEfABzK75IWECrpOvyGlyGadYQEnpphtFsSdpJ0iTeD/5M9LtOrfjnnM9vBldogwPp+uswE666bOFKXmk6Z0gGKx+eBgwvrloHd0N3G20TCGFnnkCsViG/gyMAjXXUbx4gqXMiOnU8fxkEbhTOgdTvlKIRJrcm6cPtlZgQjegkPbDWcTCwLwDo0b+hgZX0dTFSBiMmnLRG5pEwRLJR2gmWaBkP/ToBu3nXua0C6gbXjKKnC3ENsDEmlLEj8pqmvmCLUeLYnUJ+VixRsQSjTc2R2TLwlhwkGXwIo7mRU8D8XRE9I4riWILDLmgCWqy31vcGLAvdPahJaJIznt3/W7PGd+ORsObiXNxNexMnEnv98ntTY+nbEbT6dMdFGInjt0tmiuyZiTufBHQ2DpHDbp0+NKBsb+jEDxhCD4ZbEkrjxM80+ACdXEWW6sEmvxDAqGbCv1jTq9zRHCOBgn9AfNpwMoyd6DgEnigCkBDOBElK6MOEqXqrS755marelIXYBsFpVwimaoGL60WdlP4A76/qEmib9+Ebr4RffcmdOtw9Hw3nRg1eQYaoqB4xWzgDKhgbatZO2SBmzVROKHnz8R+B0fOS90MDx+oFaVA/r2M8ED0RTWe8NYa07mLpDhjHXNJVjWw+QxF4leo23xXV3RRXP3Q3ICZBMublDDMQzG21RjWoRi7DOMw+TWG95kfg+zYmbbV4L6yMcVZJMMumhc73ZzRTa87vB7dTnrn0pLqTc8QVbQm3AfsvGG0IXHJMsCE4pOBBcq7CpoR4mnpT2nCkpq+tLd3eGxEMeH1MnFjcBpWtezs4ZfchUnn5ktv4nSHt4OJTRoNIcJzwcxpwAXoFa9y4z5kOholX4FZUddCJ9sHIo5cuS23xXMx8MLqy87YGQ3H/Ul/OKjJi0GeQ4jRSNxpVK2JndWCjm0oWfeUmnyldKqUHZHCbUb4U+XNYHhz3bnS+zJgd7EKT8rMH/dDo+htXkw6gy+9wUTvxoRfFiv80HB/3BGdKr0nq8j3iLtYBFt+qwSdcOnU3LHdNI1l+5VA/OTJr7P268WKME154YZzBk+vMq1RWaOKD4dVFAPnt3lVnUJpVJTR4apk2hmymAlUZSqpUZXssrrnquwU5pxSc9aFfS/iBwa7kFzVrmI8cOoZ/9YfDPqDL8pw9D3yWYXnlDU/ngrj0ufOb71zpzPoX3eYpchCen8whrB2BaQy3wngTujP+RAjjKkcl8Z/+GHoh49ifxSnRdgsDG5/LHoVDfXzm5UWLzcPwORqLldoCqpyeSa+qluvMrlv4/uB9gPTWU6RLtKvjSPg4gmWx79QwbWbxv6G8DcCxJeFt5ct9V3Cd6i1Nn9rsZe2Jt7l92lbqEUfh6h9xk6GpgJ8P+oMXZPaXIOOucuipqrxw5WYpXRr1sWXJ/m8+h2vBHxpvSizUWSOYYXeUpxNEM3YirctOZ4Y7FdmPt8ZexB8kDWMTWkxu5lLBOswBLMaoX0YgqVDEMcZ1pjBpoyViQ1JziecZJVJ7TLJbK7hp8X+tvGvia+l8rn0L6hj0/pfFrJE//+t5Io5822FrZs531bYb0TQFPYbEdoahFphh749Mifvtur03Qif3o3w84uRaf9QZM7ebdU/3191f0Hh6iq39vf1VH63OKi1smHc24jx3a+rez6/uqAEv7vkdV/iouMPav51EtbD3xsF5n8CNzPpe12+muemyTKVF+I8ScWgGZwN7ZIdKOKu3NzUGhWC26LgtlJwVxTcVQqui4Ls/REbQfjVs3L8YCGYg6N5GHAYlCL40h+A888sWtTqkbMCvjA2Ch0Fmq0Of+xzFkjwXOR0nu06Jt7WDXB7ixRmYWVhJirPL2JyAU++RnHgtWwN0dQRLTtDvOp/uZxcd0aKVICJgoHg2l3c3o3c2J3byuYU6z53Jt1LYYf8JuVtQ+ebm06fHN97YdjB18jBZ5SjXjZ0sHTAzpMmJvdmS84cL44vDK0Sxq6g9yf23rSj8/r51TkwChNIHuxHsTtTPwCM4WyW0FT0FDf4Rr2o8DAGk2kn9LrLNJrNBGvxLWZqE/FM536S+Cu698jW5vZVj3VPrhetdYG5Qk9HgRvSURx910SICdz5dP0ST10rY5gwnf1whcxzukif+LSqkzpQhHODaL0ge9zBxdW4mvv1cvS5mns1Ggyqud0oiGKefah2fOUx7nWHg3Pn9o78+adu26ifcs2saERbs8jKWa7s4qOZPcOp46yxJkdRwol8P62caeAvHA9jJI8n6GL8KCj3tT50pn6oti5xQEgKP2SYUNa88k/SQBVdiJGrv0HnL46Mflh6i1V4a8NbcUGMd12xCY+Iuh01PU6ysQ/jqVsTLmUdTzlZ93nmCzzrBV4Lj2MVpvBoycMar0W59dxA0XE0TVJxpNDj+Ad6tW/WH17C5TcjDdTeor1OJ1/LZnWm4MJBpJSN/LwPlcfFNLsejy6lYrGaec2IDQB8tQ1CrOECVaDs1pqtxYDMApJ5IJR0L98waDn3obkjH7PfawCEezIf87Irk+BmVwj8jIa7jDwG2VcItp/iFK4I5Pm/zUdHR98jAAA=")}, + {"frag", GzipedString("H4sIAAAAAAAACo1WWW/iMBB+51dYqlSFqmWBlu6uaFfiLJUojZoej5FJHPA2sSPHnCv++46dgwBJd/MA9nxzfJ6ZjFMJBXFoRDlDczqbh8jzOZbtio83fCGNSLqNm3oVLRj1uAhQj7NIYiYj9KeyJM4NktSnbPbseREBKy3C/pS4/GBjOdgnHeb2FpJ7XgKFU2FigYMo2ZOARhFdkqOtttWK7couNcXOZ5+Ecv7KXx66HWRo1shVompKTRCJ7pFaGo1a/RI1Wy31d9uqN/Wicdv60bj+Dusquoht25XYyBPYkQasq7HkKvED69pmu7pEdWX0LXapVRaCqYBAsTR1vQefT7EP9OJMI+0TOY4taQCnDohLF0GYSSNHEMIsui3AGJYqNRrblVer18MBETgXMsBSO4D/d0pW7TLgkS0LMVPw36VAmZFyWGqYggfG6Tkdzd/kUWl6VHecgmQd8mghCpAAUzamsk9FKdbjPi9AcTClhEnrc1OKPQi+YO4p7PFZiVNAujgq4AlAxy1wxQgWQ1zgaanyyIX8uiGsOXb5KmuIXB3GIJCmjxnJl+pYId80RVjeNquUjgn1VaB+bR+Zx4u1/lMlRn2+CtEROhmOrXL0Y2R2y9GxOZmUo0kFIbvxtIEXmsDBVUE046HggUqBBdOJGGB7jeKaRGokJROKRmq++ITN5NxI4WyCGBq/Oj1Nba3GjXEq35Roq0FUTDNmtuLCdxNq+piKiyWxkCAEhkdlhQGpB2BqVltvtjBBYQpm3P+Rjpx7ZawJnlEPzOyXQW/w+D6wrVGn//xRSZs1rn2Eg9AnotnfH/MJh+0vtUIeM4ebSeueEeZSr0KZOkQTLe0FjJr8rpFuIQ92ekYti3O4tB2fhnZyRyjab9bA7oy7g/6z/dQxMzZ7HvHFlw+/NzNHHft1YL2miA4Md84MGVk9pjAVdMdBMdIbtSDwXu3iHkmyhlIQI4t9iRLVt/fqVzxAYmSeanvA7o06k8lgjO4KL/Laqqo62sHC3SfZM07ep9oa/VJXpnoa6Pz89I0DjTtop5/6UTlQjE77epvzo7SS1tOtedrndr5bq7pd9z+6AXeHcTI2m+I4R58dRr4ttL88nzxYFDsZ0T534C6Hz697BIMaJNnUGUJDJDNnyamL1O2k+uMAiz9WZka1jXZ/AUPumEXMCQAA")} +}}, +{{ + {"vert", GzipedString("H4sIAAAAAAAACuVXS2/jNhC++1dwkYuUdVQ/0pO7BRzbyRpwEsN2EhSLhcHItKNWFrUS/Vzkv3eGEiVKptwU6K05JMrMN69v+BjWwoi5XuzxgKzZwtusQ7L0ORWdmk8PfCOsWCya1w2bbAJvyaM16fXufP5KffKz9uat3kJCyJa518R158Jbs05NuVHS2I0YC6be0aALqPC2LNG9nwnZo2sWUS3kmgrpAP4+e2zXqVIMg61RN474n5WKKiN0WGmolAVjVacr8x/zuJIel/oGftg+5PEmMmjW1AtGnuh7UaWux31u0NL1q8cCMf3rUKm7i/gmWJyql3xV4RQ0NzQ25AmK7sLgKmA0uqUGT1vkkUfi/IIYcVdbglobXnjkLzoV8uFMaVQ0H/4TXrC6p+HT85hGdC3jyi1ARp7Mkq8sCYdW2BBSfkOKMfmCIgWGFs8XHgrht6CByyy98XVpYis00DIVNBIAz9lz9pp6ECyKSmhXxMQmCojr03VoWSnoSoW2yS8kF6oIdp00nDppOhD7PXU/2IcfrArbJwQLslSgmc7x41X0WRB74lAEHE85W9O9dY43rSCsp4G1ZrldkmsniwnOYNdYV8r3pZaGnVG4LJAx/bGhEVv8jzgxsfPPVI3ogf1XPM3By4yHBeVeV05osGIFNewACNXG5OV2xuM2AWTUOPsDRNABDhLdcFLTnRTzODXdZSa6IjNJ6+gzX9C+vrN1dL2QT6kJLadRdPNHHT8kxcNAsFVE/U7NW5JCgyGB3xVBSDDqd4n8N12euoTMLEXnVVLTAfPIWVSJlCKDoXJxqX01nF+h54T5MSsEkZScukDxe46vTFZjoVtMuVj7aepFCm8+Vm9Hy5y+xpaKfKXc2MZqEJphL0n+BazglrNUEpck/0KdbeQM3f2rQs0ZVbRJnunvOTvSNFlPCvcJG5QuFnXuWPGPSFhNp0E+E1VsHxduYmODc4MUfpL4pdWrV60iJGuidPwszWfLlnsLuNLns0n3YXo7mMxvH+/mN93pIDtk6gSmAJJ6o67gkV37WbuAMsHsaTpAC/IFotYSLQTM7+5QXrsXzD+BN3N4eiNWY1sFrHZhVJu0tWzygzPDxyzXN3F3XrBg4S2BECzsU+qr2+s9Tboz6bSWs7DFM3Ge2GeWJiILB3WlYyP7kng9kK3liKloo9R2Hr/RBd/JEbdyaptKjGlsG+EcNvZpwPQBuwzQR32TTrfN5msZE6ZyVPZZKN6GwZKbUR+EJFqf70JS0j7cjqbV2pev45tq7Wj88FCtTedumE3TZT8Z9AbD58F8+rXbf3ypKZKTnGMYEH0Wtfq5A5hwO2dRIU+ITKbhrNVeQOTNSeewHjwBD8WOJgvAm7zBpKQFEsH2Pc4jmMELS6QNSyR3gCpt8Eel8oTl4fp8eJzcd0f33bEJLPDEDITR0auXuUoqKGFaZLPdnViitGGUNo3SllHaNmTkb7YGKSS23OCDqWKzzFIaYzVfPT2nb0T5n3y3lB4tcvvj249Y6VSWzzv5gOPsk5FJvYm+tb9/a3yHiyBvMM5hGfxwCm+W4AcNfjyFt0rwY1pDKAdG/MzmKXynNOCYSVTFhzXcPXK4hO7hpagtNOiclOT5HwGcEobFQBPPAA4IaJ0BHBHQPgPY5ct2NLz7OsNVC22HyRKMSq1C4WctfXBTRhzBH5ofDdbH/LTPksFBNuuz2kkyXbUTTJdCiXTbtPWynZY0qo0zg3xrJA8OjKa2m0I0MkTzFOFGPI6tzGs9S1EC81gJTinr2q62tfqzKydbK4WbAJg1Lq6VPx/nzMk19f439u8qWAcTAAA=")}, + {"frag", GzipedString("H4sIAAAAAAAACu09/W/iSLK/56/waqWTIYQFkszMHpc9ESAfEpNEkJndeacRcsBkfGts1jYh5Db/+6vqz7LdJiSQ2bn3RhpNoLuqurq6urqqq7vZmUXuyIu9MLC+eLdfZtbED52kueM7y3Ce2HEyrh/UStY88CZhNLXa7VM/vHF86z87HNyy7tzRgTUaDRNv6jZ3pu7Ym09nqjQeRa4bDLwHQ13gJN6dy+seVzTZdqZu5JAmp07CCMDfj567aBZVnAd3xrqrKPx3YUUREhIsRJSVKWTZzxHj/yqMC8UzcnyDfNz7WRjPI0PN1PGCnpd0vKiwrh36oaHWmd54bpAMfl8W1p1G4TwY56sn4W0BUag5dmIDn1DRGhtIBa4TnTgGSncoxzBKmEJA4b416J8eX4c9D1EsmxXdOtOpUwJ9iNxkHgX8u1XmfwGzWJMGX5xxuFCaRAawBwXJle8ELh3jLADVNlMdxVVDzNoExcDKjjtLvpwHk9AMtSYIr/XDxczK1F6c9AbFtb+eXR0X1/auLi6Ka8XQw7AwC4GWwE34sDCOT6JwiiIYzJyRy8eJD2aMI8Vxxl6cWEeW7wa3yRdbVjflONqsfi/fm+p9yfrJsvPlywJoVAIzm5yzRRj5Y8Ea6ybyMkicKIFC4DAzrKBbCGVLtOr98qFi1as1zfsT4iDkEZkx+KM3AbRhv9vunn/sDgdnrc7lrztSWfnYx8505rtRo6O7+d6ZNVdCzULOuRfcMljWwdZs5i+5+jP+jj0nHp4AbxdAxvFtBiQ0LIwrlhYTByjtCEkF0BMJBpJSKM0db2LndKn6YP1i1aq1Wq2uKKAwONEnJM2BKohfYuQ1JtD9B5QDUcoPiNbaPSINYEE5P3cyxYRZKPVBmKmWGAO1eoW1hwMnhpy2jMXFcr5yo3jmjnC1ywmaqym2F6OqKCQhLj6LmBaxZug37AYZgaLOPiwyaA8prAeKlDVT1Xtrl8AuVsIuc+w94HCYrRtrN2AiBgfAziKWUBNyQhHKPPK9mRYJ/cZFkhWSWQUymA+LLOZDFpGIBXqGmtqwCwCWWm1NhktNC5wYYITSnAAja9gTKq1sX4CCnSkpW41qDewlmi2m56R2QdQ6LdxVan0ZJV/C28iZffFGz9JrXjcK3cmkZRUqyH2TAh4XAy4lIBXLkMmAqvmeIIRrCW87ra/DB2k8jEoXufHcT9Imj5cxcWcolWX3dkWraqXgOJkViosW7HESRmdONLYy8lQLFY4OfL9wUVufHhUyIDkvoLooCR9LEEUJK/Js9v5EC3Dy16qH0CP4Xyg2rwUrgda4Zv35p6WLfkFVg6IdWbTMQy3zUA95qAcOBUKwhBDhW9N6VDhs1lNPG5g9OmKU/ymmqYKs3rOlG9VBly1L1t/Jd6lQXGBAGxhS2uiHsRsnTOCyJjXJ1XKyzE3yFOY4TOzEvYf+uDZd3SuEkVKFr4fAMOf6J6txeKi/vDmsNcjX+pvDd/X9t1BSwpXKcv3YzTf8ZKM49R53VOfjxJ0pAT5UUhLQHhAHX6HXg3CSfNfrb0Kvw8kkdpU+KHaY2BoQ2cwwKKcGV8kWaTCgMHCvnZl1JDRP4IhKQXHI2yFNoIMmUCUvN344+h00mP2ti78N8Xd/3bnFqUhlJf2rrJhnaQnqKbAsbTDvQPl4VzZgRghu6zw1tiMgyd5WeNrfqpy2xZqynSsU69lKxSLTFcrxUsXQdM0D/NLB1XTNg7ThAKUCdfSSfrMsaGcajilb3FrgFkBZWhntGnJn6jfE8u7trClhNEtp2E8UVpmZLCx++5TjZqm4WVJulmoNRMKCpYpsj5P+lN2TyK6Mjd++r43/19dG6UDSiTDs0eUROJT6XgDeT4HvPgX+gYAvNfVlAXgnBb6bA1+9WIu/B+Lvofj7Rvx9K/6++2qLupJx1vwMP/zVS3zeJG6Hp02WeKVjr8PaFlZ6MpLb8T4OviWX8XCrY7cdnt68yvTrbIO1t9udflvh6d2rTL9NWduON7vSmm7u25ot4ua+7UqrtjUXN2OZNF2zhdkgdjBbiZdaCE3XPNM3nOWavHm2vnSmarrmGbfhbDOEJs8LTHgAsW74ULzbuGGAQ1wyCSta2T2i0YplCFcMTROPT5IzNEr8v200auiDoVHiZK5sdL02DV0wtKkc2pe0STZNWZDVOMxGiDKR+1RygGZrnxc30sTk97Dxq6QKxEmIfHi5lRxCOvf/VTMJK5o25RPG3E4/J5dgmg+mpML3+fANzIcxVfr1kuASJXdmR40k0UTDDJLacgNDadygWZj3Z1bs5PzViYyxOX7IzrWvk8h4ATOvnsjYTECvk8jYipxeOZExzrvJz1AqQ7D3TIJrJzJezujqRMbG/G6UyDCYnG8ipZHn62XJjaKlOp/l+L5Yf1+sVy7W3zMuf1nG5eUL2atnXLay7m8547KBuF4747KVkdxyxuVb8G0Ptzp2W864bHX6bTfjsp3pt92My1an3ytlXF7mda6dcdnYWS7IuLyQ7XUzLhtLpSDjsq0gJ2slNrMQhozL1tTCnHHZXC3MGZetqcX3jMv3jMtflXH50Q3G3kTexvsw6A7Pj3vqgp24Wtee37jsSm5w50VhMHWDRFwLmUTO7TWfAL1wbNn6Lh5MC67/wEIYjeWVGD8ck7uriUK1GbwARSB1+aagCcaTbGR/s0b2rXkwc0a/90+PuyJCj25vXEIDv1bhP5DcLFzAqgiaycrw5i1bGPFuUeMdu/T0SMXZOT85gb/vW1dFUgX5T+axy24ryuHgf3hvTk9/ex/eeL5r2WLehfPbL4Ebq3tGF+GZEIP8eyF2EuDT/RnGWFEYx/ZFxTpTs/cycN97wTwG5MEfkcimAHQFURSUAxWqPeir+iwBAgAAElDlyCKMRB28spppYheAy1agtXGG4iSbJ44/Gszc0dzHy87P66u8REt5RR1n+xiNQ7R/So42IcrIYZ+1Lhz3Oyet2SwK78WN61jwJFkw8PSRZafCIE7ExWH0eZgDtcc8qD0wsY23h+zD4dsGux7XaODFNYJTlzgMBSAOGofMwTrgBA5K8jJWZlCgtV1AV2NWqx0wsxHYEcTsMGi4fLj3s4a993O18Q5KkOMSrwHUqCp3ElrHnIcG4/uAt46AjCZC4n3K1jGEzmWM3PG26CHu45SVlKq3jPfMDWFZC4CAjY0iETlXcKL0uye9bvv6/PJi2OleXJ4Punw4Tt2kG9z13YmPu11h8KuXfHnvzU48P3EjWGj5GPULB2fqzdrhPEjk97EbhF7sngeJG8RessSRy5g/hZiRsySlN478BCeIjVNnfDK+t/vgN8OHJXxg8q3XamRxBfxjvuGDxpoJifnQXI6MGpGdHG3cI3LHgJS2hHbaIFdQBMjyrmxG4k+YpBgF4qukUQE2LQPcWGvs8KaZ4TsiNtLm5WgkBO08iKxByhgMpGnRdw1sXZOnmAKkdSVlLMkGraZUsShwJT/qki2BjUrER0T+pxtQq2ScRPNRYg0SJxg70XgwjybOyJV7to5/445Dsdk6C6EV0FbxlV/1FV/cqRfH3p0rvvroMU51Jk1+HyZurFQtZ3enbuL4vjdSB7dHI38esxYfxcC324pTWPZhquAzFZadZZ9vQueP3u9bYmVCh7fKeyfWQJtvrcZVyYXcY1bTnKu4lOoBTAtKomJAvQAcfSM6rvLPsvZjqja1CYxb2MiLFLlauy4Qaerc285NzKYorH8fMbLlo0t41Sbf1sY+rtJ14qPkpJfiZC/1Hom4jcyXpxRcD+blR83ZmeBMcHWmmBL1vXR9T9Uz0hMvcHz2JAUuvj2euaAvn4hhypYumqlxbYdBEnk4y0RBUxnj3vnp2TX4LNbf/mb9gAXHrev22fnFKSsAM3Fy2f+11e8MW50O21yNqym11e8e4PMXlF0NiExyFxTnYYann46s/Wr9oH74c+PN4f7hz2oyptRM94CsL9SNsNODqNd6IYeIMaPJ2Bk2drNNlXLBEyYpzK9ZoKygsHvROu6hI9iXr1ygwGDYmIxQQMKAzFhy5qm3Kkiy50JxMxtNjCkCcbIGqzG58nNJ811wD8eeseQF27/RqLWnUSliMSSe4BKQCggtBf/CFj6SxFL5lwVzz5Qhzg5c+UgdmiHKVj7KjrAU16Q1vWFx7yFYjgt0Zni2i2mFM73pgBYIxkb01SBuu0aZx4LEegM0c8toQSTAhlv7/emVWZfzETaS4OuzZpWsvBpfLXIaLrWeasj0ikqnWj9lxiLuhtl7H5G3UvNJ7w3cDCDwpA/Xz5jbnIgXaADfqA4xAQLtKRPe044RIc7tYoZ6gf9DukAEzNulvEiglHQ5mFGyREkhckdcyhQq2oJ41PixStZ3IxExxNryZ4jJtTxDK00krmrfRDtGB7aGIuu4o0OmVrs7uA4Dpsu2iMcBmAdF3O5jNDLiFJhX8I57uDz+4bMSX8NoVA/r6dJjvkG1ny5tM9iDTGmHT+qf06VdVlo/0E8tcabAj2mxpypY763jEn9nSda1SV2nBP919aZEu30COnc5T2ZzeQBP9Zgo0lmnzwUgvFkiJ1uVa+2goPEfUZKCkQ+UiJeohCXjunYS3tpyCVFnCMQbRbNQ+YzgM4F1idmCH4MXOEp7UhVLvEgljGR4y15t4guLeOVM7zhCQTcYpyv1cQke0tgCaE82zSSsCmULzLtB2082Qbv3szV7hc+sJeDWK1Za4zEufOv2osMjgjTAQ15mzB9bITfSIe6tQV8Vb2XroKraBGIQjYPvKGiXCRt6pCcpYQz+mDsQzfw/kolJOk+Lqucs3W3JaQhUrsNZqvKeVvad4NZNVS/lYRtn+is7ChKF/86eWoEgAQwUAagumYUSqPIIiUBdKBRaoVBEPzq4edChM5tCV1L8ZAahoTcoOJlPFfzARIzx8m2Ekas4QaF7gYcnhIBQwFi/kOd/SLkgib61FOce79MS+dBSlIxkWsblXZAok0/MXVNpRt0IE0meBBY/avhCZokUWmmW033Ps54W4fF6/W0SzjFIlS3vSTIlY28QVMGWLf0JpIJTzpZMlC39CetKRpkhuWd11MxRwTAJz11Jh6FyfZJwP+AACWWRdsdmCyDuM+xasrMdVFyOg5trhlK+65bXXtpr2QLXiYz5mZhty13ojXFRv+63LgYn3T7Ev6cQEw+6yshUrHAuHY4JC3XwrS/iCwAGOpW1HV4LDeq1mwdE4E7mwOsaXKyIxbCNFCxZMIpR9gk32nAqePBuVT2Pc+WOmBRI6+qq90lLwwtQCtofqqQlQvxB5leKAEu+rSrCK/1RoMkyRyVXfhDdaLXbH/qta9afHS+Q764hxSFH1hsHWY5zzErnzUg831fpzZLGSqskZBBO7vAn0ZdU61SKzZ1CRVRGn+8gKwGqwSRkcAxMcirsqKL1iJImr7PeDdWexEt3kPgGLFDy53fNbKKMv+zpZ1713Lc+sJBMJtwh1so44nwhlobZ5TrMnqRjyoQW5F1VPgoIK3IVZSK0DypdLLpVRbey6EYV3fAi6fKSfCoVEHZLbwdDDXn2F+vk3rCU3MVl/32rh9sEedgEzTAmIPJVN54ipHggIA1rfrfI4mFhzVRYNxU2TIX7eV7UbmK2gg1uwfPEVzfRlRM501g6a3qDm+e89Ab4o0lDFi7qQep5WF05BlqeD5W1lbX1lbWNlbX7plo+IkXtqlpju6rW2K6qNbbrK1kwKxTPI1ht0fjk9v6l0em1PnX7A9wkFK4y2ZNSoq2gDpXoVuyBdePgbimx6Zg94f/EpoogzRYzCi3J68FB+jW1Umm8BsHbLUaE2biogiFbDVxH4DoHvs23tf+Kba0GbiBwgwPf5Bk7+FYYWw28j8D7HNhRub81h51n2VQmhy1R2nTmDaTSQPWi8noqqMAlM3qirtZBgbhbjEnlvwJ6LS18rdaegF5LEb8N3p6ALlTGtRRAb4IH0ynuAmhMkXQU+U2McWTC0jraQWh27oI88CxX7pK1y+uXmXq5fCuAzAvRQ5UP5b3Q7VEXQs4gvkUr50M62y7nIttXlMc0yKYwzWnhdLs67u/Q/XNxXjA7r9Ig6jNumOTnEgXeTUFLrSmEWBbPmW1QLYR4KJ4PX6fdQohFWr/TA0HDNp10Lx5EAiE/Fg2hAt2lsLrLxvqVw7cZxYL6lQP3ui0W1OcGLDcsMltUMJ6FGDqBw+e+4UzLS+Izts6KRGp6FfeVawjOPb52gMzJDD/A5WM0TSYFy48NHDEyD/ToDY+IKTei6Or8qts7v+gOrz9ddfnWyo/gj0/AzFmsd4PhFQTIV63BADSby7IYoJY5Ciuy9u3eh8F1t9/tcIEN2x96PRQSa67wl1ZOwmgBXjbrtvq9lTvxiyKsxxAr/yvDw2f5vr8AYTJ6CghPdLO9uVZw67tPQXc8E8FHnVJkkfJgGobJl44XJ60kkQcxcV958Ifa0PGCO/gG9X0HAjzyKydqc0EggKpnYNUJCtbMiYTnGSN+sEgQKYsPxgOFFLuc+qq39U7d5IXdcHBzfO4kaj1k9yp5soPhA0f1Mv4HLFHg8lFafhLDquQaU30h+Cne2Zgy5vnJI7Fh5LOzRuqws8fh2M8oZQsv2Q0D3a0RJuzwUJGk0dMnfVM95qMB4OV0A9ZuhrZpbOyUQChlejp6nRlmPsfWGo89vPj8zZ5lKzpgBUqUOdX0X3X0LXWQS8qjhPs8iRXMp8zcxezUj8E4W//MGd2/w5RIbGqcap/ZWQwwo5aNVD1c35rw5x9ZZCjc3ZWJJ8/65UhzULJuItf5Xf6EVu8DT8Apu+t9zglOwaZkDaiy64OzTE3qPN8ge2Bv0Muc6Btkj/wNsmf+pJ3g8xOaRiofVDXMOm42SGcyxh/7lQPnJDV2WX+WsJ7vz6dW5sAdzowUEW7/UkUVyXSJWhFVf87OxGjbWcw2/70YYUpT+GBOM0WkJX6yKGNoK1kEOYQ+6ve6RwUHeFZwIA4LitwnVaCFPr0nL2DF50HgRmSU96hmc6XTmlFXIgPMy3nCMIsl9EAGllhjKl7xO02KkT1FuZRFvpQP+uypxjN2no0ESp8sQ6CUFcvYqcwalFl91DGhlAeZdnOAEjsOuvbhyhWDgh5ssSQX9Nzlhqcnix/6oMc0U/Z5jYOVRVRX01yDCDt8WUSEHK8k42Q+WQnBzICdO6aQ+RHFOIcbF+YEoEnJna9ls7JEfoEpd+CsJi9VPdM/rxP//GAfbzF6AXoPIKKDkgUrxDgM/KV1M59MQP9vhqMRXz6OecF/uCehy//1uWmlfqgzQ/TQSNSfxzC9GIVzgBy5mv4cVzgjyFNNvXmqqdPIG+t2ZEcyAKIVcauh3WYV8jAymVqmuGRlGJKPOliQIRvibMhfeJt6wTEewoyFmQZTJr9rHMUzYDGx8auzTf5FjhDDEP2wbt1EfLQZkIf5eFnJ+GpyRa+SruImnx7wgzkqMF4hm3/OAkszZgKv58HTAirAa+TxQHYFwPsILOaM6M7jjpITdl994QIQw49i4BpxC1V3bEk06IYogDYITfivuYP/V9WTcIIIeh6sQjJKqvSpQE7gkY8acIhUpd6795zNmB8WI6OMHAsC5tnCUPD1GAb+mbYglO1/eAM8tSXz7cr+x2ItZd/sxgEeevHDW1xexG+1Vpf8pTz59V4tqeIFnz1bI5ezyPfrEFQU3aUrX5jcs0fqB3Zxz0hyjisT6+ED6xdA4jebOWjQjKSArMQiakM+uS3VcRrHNoiLSAvPVrf5jdmc9NIs5KRN3kKSj/+wapwLePt55Ho+uzavfiW5eo9neZgg629KJrxPZrylwnuHaHNmSTyuHigdFqzM2cVG1SF8T+oneUVfM1ZJNYcxE+9hSRobXotHlOpvcDK+m5fYJgdrrIo/jcjLZQm+ayQ/35MDsowMOVEshPc9xt1CjMvc6y1HuZnRz86WW394kp4rtmZa3ehMG1NORttpaaJFYzSmThlXESHPVYg85zFyvcY+PRkYM0RfGV7ORsYYEzNfgcWzmV47hQDEAqtJlVJRd259/WqBN4mvthp6r1rVv+3oeyXn/wUBeF6X1orBc+7UGmH4SlF9O5F4QddeEowbfNuXxOMrx+h7tL3VaNs0ZK8ScIso1A9HMjkAw6lOsnJ3CvB+E4fN8MaxZeOA5xyXJjuJZsf6tt06Ubw+1MnEbXaTbPSK9DnU9EVBjVyQSDBh5w7DynOwehzFdW8tAtaGvhnGMYQsMfdsm3fG//xTpDjbXZXoxFkFIii9jvhXiwVv++RFsmVZmERRX7e3taYBsm6CrJsgGybIhgly3wS5/yxZa6aJY06K1bMv1F0kayEl0dCw3CfKeOaaRQ0oTwRU6M1PMsH/Fw3dTSwFhwAA")} +} +,{ + {"vert", GzipedString("H4sIAAAAAAAACo2UTW/iMBCG7/kVPsKuhKDtLdrDNlVbpCyKxG57qKpomhhw1/FEjpMAq/73tROCXLBRTyTzvPPh8UuCUtKMVQwF2bD1piQrjqDCgMMOazWqVD67mY5JLdgKZUGi6IHjG3DyL+jlhDQ0uyFZlipW0DAoaM7qojxGq0xSKpZs72ACFGtozz4utIygoBKslgWoroD+fWK0DX1gLhonSyS+e4EvyRT0Jg7wU/JwzqybP8HKu54MuGM/dFtiVUsHKYCJmKk7Jr0sQo4OCsUbo0It/+687EFiLfJzvMK1p6gmt1A55tTgZ+4oJSjIe3BUasweUarLhogxsyxoXcMzSp6Hnvj890CGbly/KSbWv6D885SAhOJy3+UGcmxdjWNTKeEgqG2RU4FtVhezc48O6XpqXxl4R0u1mYsVulVflPSUY1uSE7q4j5d++vyY3PppnCwWfnpwjt4uEwZdE0i1u5nSXx47JvSmgQ+RKx1RdBshSn2t+lL6YJNmnJVpbo4aBl2jhkpFRmN9N91ray68+8cNT5Mt+WG74eX69WX6Sr5bc0y2lnx3Lp+dyHeWfH8uvzqR7y15q+WzyfQwvDmNjh5LfDIE+Wadxj65kfeJk722laSqlmII6VUHDbKcmM+B2QtZ8zQ5jKIzzb5G45B8/Acs38zMAQYAAA==")}, + {"frag", GzipedString("H4sIAAAAAAAACl1QPU/DMBDd/StutEsJScAFKeoArWBH7JHlpomFiS3jFlLU/86dnYGy2E/P9z7OzIdOm0/jRhhMP3jYW6diw46dvgOv9Pu283F4c68vT4/A0yPsiBLwk4dCF2ENBHlVlEuopaRrJcs6gWolH6rbe8QCFlnbsCzaB6UjRywycz37IC6m09cSShLdZMs0cggjBTbszMxIwzUcW22Nb2fjVAl9e+DUcJb8W4T/1RTfmHBBTNizLCRc0Skoy6rJHSK3TqtIX7UG7IVMqgtat8+YuHHWBWzgzA4+lBmpwMVb3rjnooHzL2R855t4AQAA")} +}}, +{{ + {"vert", GzipedString("H4sIAAAAAAAACuVabXPaSBL+zq/Q1tVVCYMJCDvrO+3eFcHY4dYGCmTvXqVclALCUVZIRBIg2PJ/v+550cygkY2T3H7ZLzbq7nn6ZVoz3TOqrGJv5id+FBqf/MdPK2MRRG5qV6QHY+7NornXtgyTUjfe7MyIHz+6VeOPCv43fiaPxolhnZ83muroif8YgkCr0TRODTNJvZXZsi4azbph4qAP7YeqUTOajfNqFQEOh/eyVRR6YQoQwAMJcxnNTcIz/TA1CyB1g8BXkaBRZ0nqTkH0x0OFt26Y+kmCTmlVWTpVJ8bb8/P2WzCwRkLxofVAoiFRmg/w66J9cfG2eYE6Yy9dxyENz4nhZSvLzH09Naw24AKdW2NXnipJGq9nENDUDeduPL/34rQfrtYpzII0Maso8VOYT7sCj20jjOKlG5CHMwNGPgI+gNkVPzSIgDsVIwSND6MUCyipl3WjKJ5z2hnSON7f/IXR7U7vJr3p7XA8eo8yNJzudAN2elmfDEyNRy+9ZwST5A8NA8ZXiFbR3cDdResUpnDeOoNYrEN/AUaBmtsoXn2CocSI2Ww695NV4M68JZjyqweRSJMPrfMHWyvgeBko9PrhIiJhIN6BUSM/84KbaOZiJExCTano2EuiYI3kOppprFCyH869DO2nXgraFeQNTRlJzmZiGTAxpyTxelFNQwzYUbQolocYb0rGsFii8WZWN3YkjIqDZAav4mipehqwp7qhd1yaKDLA5AMaoCb/vcMXA94LnX1oCUuSy959v9ubTu5Go+HYmV7dDDvO1On95tyNe3TKFl46+3QPidiJY3eH5rJZMxN3uQq82LpEDbrp8LkDE3/vQfCYIfhkkiFNESd49oIr1EVZZKwUaOPvHAjdlOhvBL1KEcE5L0i8rzDfC0haCgcUl8ADWQAWhDOWsjzqIFHI3vKUb2Q72ZMqA8sklGKK5KpqNLWauJrCH/D9WU0cffcq9NYr0fevQreORxdv05lZ4XugyRKKZkwGe0AJa1fO2iML3KywxAnn/oK97+DIZWE1w80HckVKkC/rCDdEn2XjGV1aY2/pIinOWadUkmQNvHymJPEz5K14q0tWURz90MjATAPT2yhgtI7F2JVjWMdi7HOM4+S3GN4nug2SbWfWloP7wovJ9iIedrZ4kd1tOhr3usPb0Z3Tu+SWlL/0BFFGa0A9YIsFow0Tl6wDnFB8MjFB6aqCZoS4W/ozLyGTmj73bu9x24hig+aL48bgNIxq2vnDT8IFpzO+7jnT7vBu4NhGrcZE6FwQc2pQAL3glTDuJNdRK/gKzJK8ZjrJe8DiSJXb/LV4UgPPrH7fmUxHw0nf6Q8HFV4YiDmEGI1YTSNrTew8F3RsU5r1uZSTL6ROmbK6oVQzzJ8ybwbD8W3nRu/LgNRiJZ4UmV/vh0bR67xwOoPr3sDRu+HQYrHEDw336x3RqdJ7son8ueGuVsGOVpWgE4pOTY3tpmnMl18ORHceUc7aLycrwjR4wQ37DO5eRVqtNEclH47LKAJOq3lZnUSplaTR8ar4tBNk1hPIymRSrWyyi+qeymZH6XMKi7Mu7AcRPzLYyuTKdqnxwK5n8kt/MOgPrqXm6HPkkwwXlC3dnpR26V3nl97ltDPo33aIpchCen8wgbB2GaTU3zHgTugvaRPDjCltlya/+2Hoh4/s/VC7RXhZCNxhW/QiGuqnlZUWT5gHYHw0lVMWBVk53xNf1K1XmXxo4/lA+4HoLE6RLtIvtSPg4hmmx39Qwa2bxn5m0BMBw+eJdzBb8lnCZ8i1Nj21OJi2Btbyh7Qd5KKPTdQhY89DUwJ+GHWCrplaoUHH3OdRk9X44Yb1UroxW/XwRPSrn7EkoEOrqkwmyZzCCL2l2Jsgmrljpy0CjzX2m5bo78wDCNrImmZWGEwqc45gHYfQKkdoH4dg6RDYdoY5ZpIuY9PCBYn3J5RkFUntIqnV2MJPi/xt498WHkuJvvQ75HHL+n8mMkf/62ZySZ/5usTW9ZyvS+xXImgS+5UIbQ1CRXlDXx+Zs2+26vybEd5+M8KPz0am/VWRufhmq/7x7Vn3HRJXl7mVP29NpbXFUUsracbnGWvf/ar8zovSBSVo7SLyvsBFxx/k+ddJWA9/bhSI/wlUZtz3Kj+ap6bxNOUFsZgkNWgmZcNySTYUVis3skqtRHCnCu5KBfeq4L5UcKsKkvMj0oLQ0rO0/SAhWIKjIgzYDHIRPPQHYHHNokUtbzlL4JW2kelQaLbc/JHrLJCgcyHodLarOPG2roE7GCQxlZFPL7Yh10H0EczgpbuRF++pv4SNcOnN/fVSlPTJLPa8kG6Sh7wQGo+NR3nP9Spdd+nFrqSSRBIA4P+97+U7foHRDzda3iiOPpcyygYhYOlAzlQGcz9nxH5oTUvDM3MDTXy8DFKANFSHHDx2vfGh8Y5Led0oiDRcd/nRh4mf/L4r5V3H0TqcF9mL6LEEFDjv3ERjJzA6cw1U6LnxlatB2mAco5hebep7aNY9Q9B/jeJg3rQ1xJaOaAnEm/71e+e2M5KkAlwsoCm9dVd39yM3dpe2tEGwce86Tvc9s4Pfi8534fSjm84+Tf35M0mMVxnBO5Tz5nkqSxlETEw+tJq87322hSZopTB2Cb3v2Acdt85r0XVTF298Ml3Ro8lXzHxrgLlK6DkMv+mEXMeDbSDCX1hlZmT/z9+AOhmS34tCfsB6Gad0D2RphBcVObsXzlXmLt93ZoG7XJkmEzrlqvHeUhC5Brzga+CuR/a8/JuEI73CPE5TL8xNgazG7uRYLy69ENbynSqwL8Zs6Wbmc3GTHKLLNvia23YC9XKuE28cs5V5yrFPJDPE1r1QgjH5snZjb/4XiokuOi+H6sbded8rTlNAcaKVwsxk5hh3aoW9Y6ftYDx5q3HfoQJ5aOhmLgs0MNDNBhu6JeQoYUO3+RCZkQ9hflx6Qepeym+2LF1X7DmYBPI5kAzz3zr+ICHuh6n3GJOPVBaGMsFgwL94gEgJDvwtpf8k0xkkVjk8nKfUpx3aIaLIDTnQjO0/gziRfkF7I91UCiUkJEUIJD8J+VJjpSh0VJNV34umqyF8d5y/tmS5+zExueZTDlPVeoOiueyJIX6Rpu/UMLkRJ4b4Rb6m0sYM4V7lqN6ikmmq0hviPDpkKM0nLvcDThBLFr7umMmXOMUPFfATM5Pn9xuOjV2Ehlol34kVs1f2mmugOXGw/Cz0awvrJabOuDOYXPXG06vhNRQck16+yNQNbDAYmjtLo7ha+UM+GocR5IuACuWCQrF3r8i2S0sZVbwlxNmOWC5rKbLShlE+pC1ZIxbOXB6qnJzfwrdTuTH+gWF1ut27ccchoBURhQ2uiVM63lbuAg8CqSzUpcDa6JPAy4qqBzYizH1v7PR+m3aHN8MxFodBtM3veWa0aEarBXnDydIFBwLxGwvWoFoguN6UlpUO+5gv4dtP6gdQzQ0Xi8RL5UqO6oSWVOrrRX8pdZ+sx+cUek6g+TBQ3OaZeQutu63JL9Rol6wRpm1xXrlqin7OJMVAemZWmJF5CyAddxzyWs/wrGd4TTwjkWGUR4ufoFTypFfaA8lipbqnn0fKHUP1wRYHUJoxpQmCeYGrYv5BJyxK8uyDb7CsKZT9loZ30rkd3UDGj4e307HDkZRFeQs7Ly6M/6aHdSiCH8/Rr3/JEyzb/2TJmbdJiqHKK8HSnRisJv7hi5qHQZy0iIVSdOnskoG13vDEx1V1RzTYE2PiG49B/pUHSXZY/6u28fQ/gm58fz8tAAA=")}, + {"frag", GzipedString("H4sIAAAAAAAACuVXS2/bRhC+61dskAupyqzkOEALNQVoSrYDKLEhKWlzItbUSmFLchVyJUsp/N87sw9yVyLTFOitPtj0PL/59jXT25YsSauUF+Rzuvm8JeuMUzHu7VnyioTRdLHkBXtHt8STkoRnvPTJXz35Qd6QPC08+T0gaOD9FAx9fwzqohIqFgnB7DJ4PXKl1yAdBsNXrjSStlcn0om0ff2zK51K6ehq3CuZ2JUFUUBIn3gh/FL//ECufZ/8aOkiSzfx4dcU8D6rghfz2+sln6UFo6WueEPznGLFOon8H0LIv9rxikTRTUk39zux3QnpeNVQ9TJdgz7+sJjGd5O5Yi4oN48A3yLYq+UA5yUrVunaMa2+lMKx0XikCHFk9Mh3wqvEanQ19MmuSNe8zCHzbcYfaQZA1AITouAlsUhzNu7lbJXu8m0trZKSsWKRfm3RFVSke6Z0z+PulBHNWUmtlDkVMgD8/Ziyp3GX4m2xb9U9lPyPTkWXEwbsdDRKx9nUmUj8D7zqpCehWQs/7LDl1a5s0eQ0LWapmKRlpy5SK3mqpfljygqx+PPYqbst+a5YnavXfNMRFDTXtGrBCYpw1RIKT8QNbYm0Rx55KeSGUAdTnZ8bvlEHASjBYyC/wbSCzbxFZpUxUB2vUhTCb0GLhHn2Agyki2+sAd5C0FKAeVNFcLDU02LlKo/NUclovvU8bXRhUsvroRaaDP4ALpcBGQXydtA3zmH7nVUhjUKwooYCpAZfv7+KCSuqVBxdg6/nnOX04H2LN6sgrGeItdbY+uQqqHNCMNi93oWJ3bdgNLfN2iFj8WVHS7b6H3HSxs4/UzWjR/Zf8RRDlCXfOsqDrZzTYsMc9VE/5wD+N15mK7z2lEFNTXA4QgbbIDjK51W7Pkkxr7TrU+1iK2oXXceEZYJO7JNtWw8cPCeLcBkM3TCfBvghKX5bCLYpaTbuwcPqLDAA+NUQhASj/knJf7HlOiQg8wydF6qmI+JoWDRATjKDownRt76gRYE1JyyrmJNEUnIeAsXPjX0nWIuF0IXs1n4O3aXw+vvqHVvI6WPlmcwXJozfWg2a1rZ90nwBK3jkPAOiT5ov1PmtnGG4f1VoO6KOZZJ3+nPDjnRV+8nYvcAF0pvF3DuebMJGwRC6RlPsBDeu8vGxvTyXwo/Kf7J77apNBrUnTq6fdfvdsufpChvL5Tx8v7iZzuOb+9v4OlxM60tmQKA9093ymiYC+tGe04+CB3kDWXtKCwmbt3srn92XLDszHzXm+kXstr10bK0Ho9vllYWmuThr+4o1+hGeTt0sN4SEDw+zTw0baYEsND35wGXEGmbQxsvTg2f1TthtD0jSfGo3I6NyLyGnL3QZYRR9mIdLWU8vLXS2PUaMlXON+QzxGVgzQLQGP6/VjGJWMv9bDLWQ49z3J/OLk91mcdzr3Ij1pY/N1NCvCawX0wqDa9DGU2ehdSy1BBLj7OEujJcwWBlvo1lOf19+mE9xTQDYJaTaQe9vppYKmsOMlZcTgv34kh2EbOR1jK5RB+dRWgjzmqOrbrkbTuWwEBaraCf4ei0bZQPp43QOqOLofnY/R1wZf9Kt9T7Wk53ZKihcw5BJvLp34LLbqTNyOSr237RlVa91a9razZ5+PZ1fD5s8oGhhhHTcxa3EJdgh0kdKKB49i9OBJB6CGjM94TrpbR3mx+xGdpbcWnK8wnnQCOLoLnz/fjqDN7WNlScfm5OElqvWvebx5s61R3wpr0fujCcwF3Ns2GBrNOcpidHDbAc8esgCLp+jw24Cvj1/TJ7/BrhOPOuPEQAA")} +}}, +{{ + {"vert", GzipedString("H4sIAAAAAAAACuVZbW/iRhD+zq9YqapkQsKBIbm09FRxhOToJYACSStFEfLBJvGdsaltiKHKf+/MvuA13k0gud6XfiHxzOwzr7s7YxdmIR27kRv45MG9f5iROy9w4kZBeSATOg4mtGYTi1MXdFwn4f0Xp0j+KeBf8oE9kj1iHx6WK9nVA/feB4FquUIOiBXFdGZV7eNyZZ9YuOimdlskJVIpHxaLCLC5vJ3MAp/6MUAADySsaTCxGM9y/djKgewTBl9Egkadrag7ANH3mwovHD92owid0qqydar2yNHhYe0IDCyxUNxUb1k0FErlFv47rh0fH1WOUWdI43no8/DsEZrMbGvt6wGxa4ALdGlNo/BUiOJwPoaAxo4/ccLJNQ3jjj+bx5AFJTGzIHJjyGejAI814gfh1PHYQ53AynvAB7BGwfUJE3BG6YqUJpdxig2UmCatIAgnklZHmsT7yb0jrdboatAeXfQu+59QhofTGS3ATpp02MKY3NP4WhAsVj88DBjfVLSI7nrOMpjHkMJJtQ6xmPvuHRgFai6CcPYAS5kR4/Fo4kYzzxnTKZjyJ4VIxNFN9fC2oRUY0gQU0o5/F7AwMO/AqL6bUO88GDsYCYtRYy56SaPAmyN5H80kM5Ts+BOaoP3cy5R2CnXDS0aRawixBJhYU4r4fl5NOV2w5GhBqC4h7wxrRCzReCvZJ0sWxoyDLIOnYTDNeuqJp32id1xJFFtgyQVlULP+f4kbA/aFzj60RBTJSfu602qPBlf9fu9yODo97zWHo2H7r+HVZZun7I7G44drKMRmGDpLNFdkzYqc6cyjoX2CGnTpcKUDA3dFIXjCEHyy2JJKGid4pt4p6uIstlYJNPlZAqGbCv1dSi9yRHCOehF9hfnUY2WZOpBxCTxQBeBAqIuSlVEHiVz1mku+nCxVT4oCLFFQ8iWyVlXipVXB0xR+wPdnNUn05U7o1R3RVzuh29ujp7upbhXkHWiJguIVk8AdYGAtzawVssDNgigcf+Leif0OjpzkTjO8fKBWlAL5ex7gheiKaqzzozWkUwdJ4Zp1wCVZ1cDmsxSJD1C36a42nKK4+racgJkEy5vkMKrbYizNGPa2GKs1xnbyjxjeJ34NsmtnXFOD+8LGFHeRDLs4vNjtNupftlu9i/7VsH0iLTFveoaoopWhH2ikB0YNEhfNPUwoPllYoPxUQTN8vC3dMY1YUuPn9vYKr40gJLxehk4ITsOqSmP98FvqwrB5edYejlq9q+6wQUolIcJzwcwpQQP0glepcXtrHaWcr8A01LXQyfaBiCNX3pDb4ikbeGH1p+Zg1O8NOsNOr1uQjUGaQ4hRX/Q0qtaosa4FHdtSsj5RavKF0jEp2yeZbkb4Y/Km27u8aJ7rfemyXszgSZ75ej80inbzYtjsnrW7Q70bQ94sGvzQcF/viE6V3pNF4E6IM5t5S95Vgk5oOjU9thPHoTx+JRC/edJ2tvFysSJMWTbccM/g7ZWnlYw1qviwXUUxcN7Nq+oUSslQRturkmlnyGImUJWppJIp2Xl1T6bsZOac3OGsC/tGxLcMdia5ql3ZeODUM/jc6XY73TNlOPoauKzCU8ojv54y49LH5uf2yajZ7Vw0maXIQnqnO4CwtgSkMt8J4KbvTvkQI4wxjkuDb67vu/692B/ZaRE2C4PbHIteREP9vLPS4qXmAZhczeUyh4KqXN6JL+rWq4xuavh+oHbLdOZTpIv0S+MIuFjH8vgDFVw4cegmhL8RIK4svI1sqe8SvkKt1fhbi420lbGX36QtoRZdHKI2GSsZGgP4ZtQZuia1qQYdc7WOmqrG9RdiltKtecy+PEnn1a/YEvClxaxMosgcwAq9pTibIJq1FG9bUjwx2C+q6XxnbUDwQdayktxi1plLBHs7hKoZobYdgq1DENcZ1pjFpoxFFQ8kOZ9wkp0n1fKkavkR/rXZbw1/q/haKp1Lv0MdV+3/spAl+v+3kg1z5m6FrZs5dyvsHRE0hb0jQk2DUMjs0N0jU3+zVYdvRjh6M8L7ZyNTe1Vkjt9s1S9vr7rvULi6yi38uDOV9xZbHa1sGJ8kYnx3i+qeT1sXlOC9S1r3OS46fqvmXydh3/7YKDD/I+jMpO9F+WqemybLVDbEaZKyQbM4G45LdqGIXrmcFEoGwWVWcGkUXGUFV0bBx6wge3/ERhDeehrHDxaCKTiahgGHQSmCL/0BOP3MokU1j5wG+MzYKHRkaA11+GOfs0CC5yKl82wXMfEN3QC3sUhhZlY+vTiGnHnBFzBDtu5k3bzH7hQuwimduPNp2tJH45BSn1+SmzwfBo8F5bznZpWWM6Who6hkkQQA+Hvt0vWNn2N0/IWW1w+Dr0aGaRECGhdKZmax9HPM7IfR1BieseNp4kMTKAE2UG1y8LXruQuDd2jktQIv0HCd6RcXEj/4tjTyzsJg7k/y7Lvg3gAKnI9OpLETGM2JBsqnTnjqaJAWGMcg5J82xSa1yWI0h7CyzYbe8bMpv9E6sFU6vrqXxIklKfzUY0Lr3ZR+IwWq2BaMbP4omr7JsDp+7rVK5jUCPxsyYoqFsOf46b+ukPIje6UPTfTv/JrMSuMHrIMNEpyfv5IsrVG499ZvM0GDws2wyuyTjvoMUYZYc//XH4qf/gVlI1UmXiAAAA==")}, + {"frag", GzipedString("H4sIAAAAAAAACn1TwW7bMAy9+yt4tIfAcNxuPQQrsKRYMKDDiqbbtVBlOtUmiYYseUmG/vsku07TTe7FgvnIx/coKmkMctEK0vAoto8N1JKYXSSS7cnZtLXV/LzIwGlRk1GwWq0lPTAJf5IhHaBDfg6c31uhcJEorIRTzTHacoOoN+IQwTSzosMBe3qj5YopNOykpWK2J/DnD4G/F1PAF91FsRtDPyeBqaJAOFk4gq+KR5+8139D7eR4OJOR+eCuodaZCKKY0NfCXgkzia1IUgRl6kGgtptf+0lsbcjp6n+4pu0EqUeWrI3o9MCnKkKlkZnPLMLUhTmSsf1C+OAZbG7Xyzu6FqEE0j60ZUqxzO+DQeuMHv7h3XD6ykToQFhCd++6yb1aSiL1ffnN87xSYXF3XMkxt2WqkWjKK/BMjbO32Dppv7LmyC6J+232r+gj+B4+MpDVho1D6x8WSKeEZprjYIUH7MRKRTbtY7NQf5YWeTkvP8ygyC/m78twFhdlmWXBZUeignDbaSB4ofMSvAdPh+k/amf9RLJ8tz8sElFD+qLmdMyDgiyDy3EY+SG0OJrxHYK7Uek8L4IgQNliLM2L7pU/f57Tk6e/fX/tH3wEAAA=")} +} +,{ + {"vert", GzipedString("H4sIAAAAAAAACuVZbW/iRhD+zq9YqapkQsKBIbm09FRxhOToJYACSStFEfLBJvGdsaltiKHKf+/MvuA13k0gud6XfiHxzOwzr7s7YxdmIR27kRv45MG9f5iROy9w4kZBeSATOg4mtGYTi1MXdFwn4f0Xp0j+KeBf8oE9kj1iHx6WK9nVA/feB4FquUIOiBXFdGZV7eNyZZ9YuOimdlskJVIpHxaLCLC5vJ3MAp/6MUAADySsaTCxGM9y/djKgewTBl9Egkadrag7ANH3mwovHD92owid0qqydar2yNHhYe0IDCyxUNxUb1k0FErlFv47rh0fH1WOUWdI43no8/DsEZrMbGvt6wGxa4ALdGlNo/BUiOJwPoaAxo4/ccLJNQ3jjj+bx5AFJTGzIHJjyGejAI814gfh1PHYQ53AynvAB7BGwfUJE3BG6YqUJpdxig2UmCatIAgnklZHmsT7yb0jrdboatAeXfQu+59QhofTGS3ATpp02MKY3NP4WhAsVj88DBjfVLSI7nrOMpjHkMJJtQ6xmPvuHRgFai6CcPYAS5kR4/Fo4kYzzxnTKZjyJ4VIxNFN9fC2oRUY0gQU0o5/F7AwMO/AqL6bUO88GDsYCYtRYy56SaPAmyN5H80kM5Ts+BOaoP3cy5R2CnXDS0aRawixBJhYU4r4fl5NOV2w5GhBqC4h7wxrRCzReCvZJ0sWxoyDLIOnYTDNeuqJp32id1xJFFtgyQVlULP+f4kbA/aFzj60RBTJSfu602qPBlf9fu9yODo97zWHo2H7r+HVZZun7I7G44drKMRmGDpLNFdkzYqc6cyjoX2CGnTpcKUDA3dFIXjCEHyy2JJKGid4pt4p6uIstlYJNPlZAqGbCv1dSi9yRHCOehF9hfnUY2WZOpBxCTxQBeBAqIuSlVEHiVz1mku+nCxVT4oCLFFQ8iWyVlXipVXB0xR+wPdnNUn05U7o1R3RVzuh29ujp7upbhXkHWiJguIVk8AdYGAtzawVssDNgigcf+Leif0OjpzkTjO8fKBWlAL5ex7gheiKaqzzozWkUwdJ4Zp1wCVZ1cDmsxSJD1C36a42nKK4+racgJkEy5vkMKrbYizNGPa2GKs1xnbyjxjeJ34NsmtnXFOD+8LGFHeRDLs4vNjtNupftlu9i/7VsH0iLTFveoaoopWhH2ikB0YNEhfNPUwoPllYoPxUQTN8vC3dMY1YUuPn9vYKr40gJLxehk4ITsOqSmP98FvqwrB5edYejlq9q+6wQUolIcJzwcwpQQP0glepcXtrHaWcr8A01LXQyfaBiCNX3pDb4ikbeGH1p+Zg1O8NOsNOr1uQjUGaQ4hRX/Q0qtaosa4FHdtSsj5RavKF0jEp2yeZbkb4Y/Km27u8aJ7rfemyXszgSZ75ej80inbzYtjsnrW7Q70bQ94sGvzQcF/viE6V3pNF4E6IM5t5S95Vgk5oOjU9thPHoTx+JRC/edJ2tvFysSJMWTbccM/g7ZWnlYw1qviwXUUxcN7Nq+oUSslQRturkmlnyGImUJWppJIp2Xl1T6bsZOac3OGsC/tGxLcMdia5ql3ZeODUM/jc6XY73TNlOPoauKzCU8ojv54y49LH5uf2yajZ7Vw0maXIQnqnO4CwtgSkMt8J4KbvTvkQI4wxjkuDb67vu/692B/ZaRE2C4PbHIteREP9vLPS4qXmAZhczeUyh4KqXN6JL+rWq4xuavh+oHbLdOZTpIv0S+MIuFjH8vgDFVw4cegmhL8RIK4svI1sqe8SvkKt1fhbi420lbGX36QtoRZdHKI2GSsZGgP4ZtQZuia1qQYdc7WOmqrG9RdiltKtecy+PEnn1a/YEvClxaxMosgcwAq9pTibIJq1FG9bUjwx2C+q6XxnbUDwQdayktxi1plLBHs7hKoZobYdgq1DENcZ1pjFpoxFFQ8kOZ9wkp0n1fKkavkR/rXZbw1/q/haKp1Lv0MdV+3/spAl+v+3kg1z5m6FrZs5dyvsHRE0hb0jQk2DUMjs0N0jU3+zVYdvRjh6M8L7ZyNTe1Vkjt9s1S9vr7rvULi6yi38uDOV9xZbHa1sGJ8kYnx3i+qeT1sXlOC9S1r3OS46fqvmXydh3/7YKDD/I+jMpO9F+WqemybLVDbEaZKyQbM4G45LdqGIXrmcFEoGwWVWcGkUXGUFV0bBx6wge3/ERhDeehrHDxaCKTiahgGHQSmCL/0BOP3MokU1j5wG+MzYKHRkaA11+GOfs0CC5yKl82wXMfEN3QC3sUhhZlY+vTiGnHnBFzBDtu5k3bzH7hQuwimduPNp2tJH45BSn1+SmzwfBo8F5bznZpWWM6Who6hkkQQA+Hvt0vWNn2N0/IWW1w+Dr0aGaRECGhdKZmax9HPM7IfR1BieseNp4kMTKAE2UG1y8LXruQuDd2jktQIv0HCd6RcXEj/4tjTyzsJg7k/y7Lvg3gAKnI9OpLETGM2JBsqnTnjqaJAWGMcg5J82xSa1yWI0h7CyzYbe8bMpv9E6sFU6vrqXxIklKfzUY0Lr3ZR+IwWq2BaMbP4omr7JsDp+7rVK5jUCPxsyYoqFsOf46b+ukPIje6UPTfTv/JrMSuMHrIMNEpyfv5IsrVG499ZvM0GDws2wyuyTjvoMUYZYc//XH4qf/gVlI1UmXiAAAA==")}, + {"frag", GzipedString("H4sIAAAAAAAACrWTT0/jMBDF7/kUPiaiDYXtLdrDtgi00kqLxMK1cpNJa7A9kf+ElBXfnYnTdkHEi4TEKYrfvN9MnidJY6AUVqBmW7HZNqyWyF2RSL5D71LrqrP5LGNeixqNYsvllcQ1l+xvMpQz1kI5Z2W5ckJBkSiohFfN8dSWBkDfiKcRTXMnWhi05/+0XHIFhr9qqbgLAHreCXgsYsJP3Y5q1wbvo0LM1AOjxoP4xnz4zjLMf402Gk/J5Ug+0DVovRlRFBf6l3AXwkS1JUocUblaC9Du5mEX1a4Mel29l2vcRKCkLLgdmZOEH9UISgM3l3yE1PY5onFhIYTuz89Zu/JtdD0WElHdLn7TeryBOeiOm3WotVw1Esz5BVv3rj/QuRDvHi2xpI2kP+E7owZ0MpBqww8fTu/fWIWPeiDNHW9sGmb07WQYdstl3YgOZEYThXrrFRHd0Cx93XlCNnYSfOn0aMy7yT9KvsuyvNs9FUmPOfmY8xWY6ec50w9BBsijQ0qnbJ7P6MaSFkXF+kVOs2SfogHrpaMg38W/6rM/y2dk3186gbPcbNZFcrw7MvaXmQ6YUJ9RpxduccIA/wQAAA==")} +} +,{ + {"vert", GzipedString("H4sIAAAAAAAACuVZbW/iRhD+zq9YqapkQsKBIbm09FRxhOToJYACSStFEfLBJvGdsaltiKHKf+/MvuA13k0gud6XfiHxzOwzr7s7YxdmIR27kRv45MG9f5iROy9w4kZBeSATOg4mtGYTi1MXdFwn4f0Xp0j+KeBf8oE9kj1iHx6WK9nVA/feB4FquUIOiBXFdGZV7eNyZZ9YuOimdlskJVIpHxaLCLC5vJ3MAp/6MUAADySsaTCxGM9y/djKgewTBl9Egkadrag7ANH3mwovHD92owid0qqydar2yNHhYe0IDCyxUNxUb1k0FErlFv47rh0fH1WOUWdI43no8/DsEZrMbGvt6wGxa4ALdGlNo/BUiOJwPoaAxo4/ccLJNQ3jjj+bx5AFJTGzIHJjyGejAI814gfh1PHYQ53AynvAB7BGwfUJE3BG6YqUJpdxig2UmCatIAgnklZHmsT7yb0jrdboatAeXfQu+59QhofTGS3ATpp02MKY3NP4WhAsVj88DBjfVLSI7nrOMpjHkMJJtQ6xmPvuHRgFai6CcPYAS5kR4/Fo4kYzzxnTKZjyJ4VIxNFN9fC2oRUY0gQU0o5/F7AwMO/AqL6bUO88GDsYCYtRYy56SaPAmyN5H80kM5Ts+BOaoP3cy5R2CnXDS0aRawixBJhYU4r4fl5NOV2w5GhBqC4h7wxrRCzReCvZJ0sWxoyDLIOnYTDNeuqJp32id1xJFFtgyQVlULP+f4kbA/aFzj60RBTJSfu602qPBlf9fu9yODo97zWHo2H7r+HVZZun7I7G44drKMRmGDpLNFdkzYqc6cyjoX2CGnTpcKUDA3dFIXjCEHyy2JJKGid4pt4p6uIstlYJNPlZAqGbCv1dSi9yRHCOehF9hfnUY2WZOpBxCTxQBeBAqIuSlVEHiVz1mku+nCxVT4oCLFFQ8iWyVlXipVXB0xR+wPdnNUn05U7o1R3RVzuh29ujp7upbhXkHWiJguIVk8AdYGAtzawVssDNgigcf+Leif0OjpzkTjO8fKBWlAL5ex7gheiKaqzzozWkUwdJ4Zp1wCVZ1cDmsxSJD1C36a42nKK4+racgJkEy5vkMKrbYizNGPa2GKs1xnbyjxjeJ34NsmtnXFOD+8LGFHeRDLs4vNjtNupftlu9i/7VsH0iLTFveoaoopWhH2ikB0YNEhfNPUwoPllYoPxUQTN8vC3dMY1YUuPn9vYKr40gJLxehk4ITsOqSmP98FvqwrB5edYejlq9q+6wQUolIcJzwcwpQQP0glepcXtrHaWcr8A01LXQyfaBiCNX3pDb4ikbeGH1p+Zg1O8NOsNOr1uQjUGaQ4hRX/Q0qtaosa4FHdtSsj5RavKF0jEp2yeZbkb4Y/Km27u8aJ7rfemyXszgSZ75ej80inbzYtjsnrW7Q70bQ94sGvzQcF/viE6V3pNF4E6IM5t5S95Vgk5oOjU9thPHoTx+JRC/edJ2tvFysSJMWTbccM/g7ZWnlYw1qviwXUUxcN7Nq+oUSslQRturkmlnyGImUJWppJIp2Xl1T6bsZOac3OGsC/tGxLcMdia5ql3ZeODUM/jc6XY73TNlOPoauKzCU8ojv54y49LH5uf2yajZ7Vw0maXIQnqnO4CwtgSkMt8J4KbvTvkQI4wxjkuDb67vu/692B/ZaRE2C4PbHIteREP9vLPS4qXmAZhczeUyh4KqXN6JL+rWq4xuavh+oHbLdOZTpIv0S+MIuFjH8vgDFVw4cegmhL8RIK4svI1sqe8SvkKt1fhbi420lbGX36QtoRZdHKI2GSsZGgP4ZtQZuia1qQYdc7WOmqrG9RdiltKtecy+PEnn1a/YEvClxaxMosgcwAq9pTibIJq1FG9bUjwx2C+q6XxnbUDwQdayktxi1plLBHs7hKoZobYdgq1DENcZ1pjFpoxFFQ8kOZ9wkp0n1fKkavkR/rXZbw1/q/haKp1Lv0MdV+3/spAl+v+3kg1z5m6FrZs5dyvsHRE0hb0jQk2DUMjs0N0jU3+zVYdvRjh6M8L7ZyNTe1Vkjt9s1S9vr7rvULi6yi38uDOV9xZbHa1sGJ8kYnx3i+qeT1sXlOC9S1r3OS46fqvmXydh3/7YKDD/I+jMpO9F+WqemybLVDbEaZKyQbM4G45LdqGIXrmcFEoGwWVWcGkUXGUFV0bBx6wge3/ERhDeehrHDxaCKTiahgGHQSmCL/0BOP3MokU1j5wG+MzYKHRkaA11+GOfs0CC5yKl82wXMfEN3QC3sUhhZlY+vTiGnHnBFzBDtu5k3bzH7hQuwimduPNp2tJH45BSn1+SmzwfBo8F5bznZpWWM6Who6hkkQQA+Hvt0vWNn2N0/IWW1w+Dr0aGaRECGhdKZmax9HPM7IfR1BieseNp4kMTKAE2UG1y8LXruQuDd2jktQIv0HCd6RcXEj/4tjTyzsJg7k/y7Lvg3gAKnI9OpLETGM2JBsqnTnjqaJAWGMcg5J82xSa1yWI0h7CyzYbe8bMpv9E6sFU6vrqXxIklKfzUY0Lr3ZR+IwWq2BaMbP4omr7JsDp+7rVK5jUCPxsyYoqFsOf46b+ukPIje6UPTfTv/JrMSuMHrIMNEpyfv5IsrVG499ZvM0GDws2wyuyTjvoMUYZYc//XH4qf/gVlI1UmXiAAAA==")}, + {"frag", GzipedString("H4sIAAAAAAAACrWTT2/TQBDF7/4Ue7TVxKQlnCwOJBUVEhKVClyjiT1OFnZ3rP1jnCK+O2O7MS14qYTEyfK+fb8ZvxknjcVSOklGHOXh2IhaEfgiUXCi4FPnq8v1KhPByJqsFtvtjaI9KPE9Ga8L0WK5FmW581JjkWisZNDNdOpKi2ju5P2MZsDLFkftx19KbkGjhUclNfgBwM/PEr8VMeGdaWe1W0tfokLM1AOjxrP4xHz+znLo/5ZcNJ4S1Ew+2DXkgp1RNEjzXvpraaPalhTNqKD3Eo2/+3qKajeWgqn+lGs6RKCsbMDN9MnCm2oGZRDsW5ghtX2OZP2wENL051ei3YU2uh4bRaQ/bT7wejyBeeymzTrfdaAbhfbqWux710fs/BDvA1pRyRvJf8JrwQX4ZCTVFs4fzu8vRWhGztpD49Khw9AuxlaPoOpGdqgy7me47YJmnh9LpY/rLtgmLgZfupyMebf4RclPWZZ3p/si6TEXz3P+B2b575zlsyCL7DFDSi/EOl/xvJKWZCX6NU6nFC26oDwH+Vv4uz75Vf6KzQ8DZ2yW28O+SKa5sa0fZDpCFuIyX2Vc5yegOjem+wQAAA==")} +} +,{ + {"vert", GzipedString("H4sIAAAAAAAACuVZbW/iRhD+zq9YqapkQsKBIbm09FRxhOToJYACSStFEfLBJvGdsaltiKHKf+/MvuA13k0gud6XfiHxzOwzr7s7YxdmIR27kRv45MG9f5iROy9w4kZBeSATOg4mtGYTi1MXdFwn4f0Xp0j+KeBf8oE9kj1iHx6WK9nVA/feB4FquUIOiBXFdGZV7eNyZZ9YuOimdlskJVIpHxaLCLC5vJ3MAp/6MUAADySsaTCxGM9y/djKgewTBl9Egkadrag7ANH3mwovHD92owid0qqydar2yNHhYe0IDCyxUNxUb1k0FErlFv47rh0fH1WOUWdI43no8/DsEZrMbGvt6wGxa4ALdGlNo/BUiOJwPoaAxo4/ccLJNQ3jjj+bx5AFJTGzIHJjyGejAI814gfh1PHYQ53AynvAB7BGwfUJE3BG6YqUJpdxig2UmCatIAgnklZHmsT7yb0jrdboatAeXfQu+59QhofTGS3ATpp02MKY3NP4WhAsVj88DBjfVLSI7nrOMpjHkMJJtQ6xmPvuHRgFai6CcPYAS5kR4/Fo4kYzzxnTKZjyJ4VIxNFN9fC2oRUY0gQU0o5/F7AwMO/AqL6bUO88GDsYCYtRYy56SaPAmyN5H80kM5Ts+BOaoP3cy5R2CnXDS0aRawixBJhYU4r4fl5NOV2w5GhBqC4h7wxrRCzReCvZJ0sWxoyDLIOnYTDNeuqJp32id1xJFFtgyQVlULP+f4kbA/aFzj60RBTJSfu602qPBlf9fu9yODo97zWHo2H7r+HVZZun7I7G44drKMRmGDpLNFdkzYqc6cyjoX2CGnTpcKUDA3dFIXjCEHyy2JJKGid4pt4p6uIstlYJNPlZAqGbCv1dSi9yRHCOehF9hfnUY2WZOpBxCTxQBeBAqIuSlVEHiVz1mku+nCxVT4oCLFFQ8iWyVlXipVXB0xR+wPdnNUn05U7o1R3RVzuh29ujp7upbhXkHWiJguIVk8AdYGAtzawVssDNgigcf+Leif0OjpzkTjO8fKBWlAL5ex7gheiKaqzzozWkUwdJ4Zp1wCVZ1cDmsxSJD1C36a42nKK4+racgJkEy5vkMKrbYizNGPa2GKs1xnbyjxjeJ34NsmtnXFOD+8LGFHeRDLs4vNjtNupftlu9i/7VsH0iLTFveoaoopWhH2ikB0YNEhfNPUwoPllYoPxUQTN8vC3dMY1YUuPn9vYKr40gJLxehk4ITsOqSmP98FvqwrB5edYejlq9q+6wQUolIcJzwcwpQQP0glepcXtrHaWcr8A01LXQyfaBiCNX3pDb4ikbeGH1p+Zg1O8NOsNOr1uQjUGaQ4hRX/Q0qtaosa4FHdtSsj5RavKF0jEp2yeZbkb4Y/Km27u8aJ7rfemyXszgSZ75ej80inbzYtjsnrW7Q70bQ94sGvzQcF/viE6V3pNF4E6IM5t5S95Vgk5oOjU9thPHoTx+JRC/edJ2tvFysSJMWTbccM/g7ZWnlYw1qviwXUUxcN7Nq+oUSslQRturkmlnyGImUJWppJIp2Xl1T6bsZOac3OGsC/tGxLcMdia5ql3ZeODUM/jc6XY73TNlOPoauKzCU8ojv54y49LH5uf2yajZ7Vw0maXIQnqnO4CwtgSkMt8J4KbvTvkQI4wxjkuDb67vu/692B/ZaRE2C4PbHIteREP9vLPS4qXmAZhczeUyh4KqXN6JL+rWq4xuavh+oHbLdOZTpIv0S+MIuFjH8vgDFVw4cegmhL8RIK4svI1sqe8SvkKt1fhbi420lbGX36QtoRZdHKI2GSsZGgP4ZtQZuia1qQYdc7WOmqrG9RdiltKtecy+PEnn1a/YEvClxaxMosgcwAq9pTibIJq1FG9bUjwx2C+q6XxnbUDwQdayktxi1plLBHs7hKoZobYdgq1DENcZ1pjFpoxFFQ8kOZ9wkp0n1fKkavkR/rXZbw1/q/haKp1Lv0MdV+3/spAl+v+3kg1z5m6FrZs5dyvsHRE0hb0jQk2DUMjs0N0jU3+zVYdvRjh6M8L7ZyNTe1Vkjt9s1S9vr7rvULi6yi38uDOV9xZbHa1sGJ8kYnx3i+qeT1sXlOC9S1r3OS46fqvmXydh3/7YKDD/I+jMpO9F+WqemybLVDbEaZKyQbM4G45LdqGIXrmcFEoGwWVWcGkUXGUFV0bBx6wge3/ERhDeehrHDxaCKTiahgGHQSmCL/0BOP3MokU1j5wG+MzYKHRkaA11+GOfs0CC5yKl82wXMfEN3QC3sUhhZlY+vTiGnHnBFzBDtu5k3bzH7hQuwimduPNp2tJH45BSn1+SmzwfBo8F5bznZpWWM6Who6hkkQQA+Hvt0vWNn2N0/IWW1w+Dr0aGaRECGhdKZmax9HPM7IfR1BieseNp4kMTKAE2UG1y8LXruQuDd2jktQIv0HCd6RcXEj/4tjTyzsJg7k/y7Lvg3gAKnI9OpLETGM2JBsqnTnjqaJAWGMcg5J82xSa1yWI0h7CyzYbe8bMpv9E6sFU6vrqXxIklKfzUY0Lr3ZR+IwWq2BaMbP4omr7JsDp+7rVK5jUCPxsyYoqFsOf46b+ukPIje6UPTfTv/JrMSuMHrIMNEpyfv5IsrVG499ZvM0GDws2wyuyTjvoMUYZYc//XH4qf/gVlI1UmXiAAAA==")}, + {"frag", GzipedString("H4sIAAAAAAAACn2TUU+DMBSF3/kVfdzULDr3RnxwLC4mGhenvi4XKFu17SWlZZtm/90Cg7DZ+gTpd+65p5dLkCuasIKhJBu23uQk4wg6DDjs0ehBodObyfWQGMkyVIJE0ZxjDJz8BI2ckJImE5IkK80EDQNBU2ZE3p0WiaJULtm3g0nQrKQNO/zTMgJBFfRaCtC1gX1+MLoNfeBRlk62UPjpBb6iytBb2MKT4vaeSZ1/gYV3PAlwx3zoLsfCKAcRwOQT0zOmvCxCjg4KImZU6uXX3svmCo1M/+IM1x5TS6ZQOHJacJ86rCQF9QAOp7KaIypdLwST1fmYlCtTetdjyhHF+/TFrseJmaa7brNabQEi51SNZ8Q65Ua/0sJw/Qy5SxJXxm90p+svcOzOMbFLa3+WO2Iz2JOmWaagnU2JLCXVNxgMbaSablJVQ1ukG7/BWf+r+o7DsNLfNp3PK/pxjvKRWsfHElU7WXnbq2Lksm910Y5ktLXvnQ7CoEtv66vAg8btqiey0Q6/DKE5rysEAAA=")} +}}, +{{ + {"vert", GzipedString("H4sIAAAAAAAACn1Ty26DMBC88xV7BClFpOVUFFUtVaNIPUSKlCvaGIe4xTYyhkCr/HsNiEBT6Ak8szP78NrKFCUsZ1LAiSWnDI6pRB1YuVYF0bDTKGJU8Z4qvRFZoeHb6uJKSnzIZM600QaWOT6AkIpj2h58MMqECmN1CSwmoA3AaFAMWC/rkHuDaFqFUqq4x/wG6/1SrGWh7VzHS99zoBDsaAwgDNepPGB6rRA6JSGRZpwGFqcxK3h2RXOiKBU79jXBCdSspB13+SdliJwqHKXkqFsD890zeg7miI0oJ7mtkh+zxJyoMZwV9uQvcd8naevfynx2PATTifnQylxkoSYYjky8M/3K1CwXylROsMgPzFzw7rOe5dZKFiL+Sx9lMmNqmBfMJ+o0xHM8YSUoqjeccCqbOUrVLbTZhm5Xy6gwYy0li6HpDmzHLMPN2+j/YNWa2cMrWMDS9Zwhwq1qEzS+F/cMqxV4rgdPbUJ7FOpWC7gbn2sHHmEEBFaSRtub7AO/GGLrtpK+nKYpEz5+h5cf6yGfICkEAAA=")}, + {"frag", GzipedString("H4sIAAAAAAAACu09aXPiSLLf/Ss0MREbAmMaMPQxXs8GBnxE0NgBbnf32+ggZBC2doTESMKAd/u/v8y6SyrhA9zT+56/GKkqMysrKyuPOuSdX73J2J1YJ91h58vlML51xm40nETO1L2eTyb47Caj251f3WXiBrEXBg+B/ma5gXPtu4ASjL3JzixyRx5BvPVubmfWxA+d5GDHd1bhPLHjZFytVwrWPPAmYTS1Wq0TP7x2fOvfOxTcsu7cUd0ajYaJN3UPdqbu2JtPZ6I0HkWuGwy8e0Nd4CTenUvrvq9psgVdiBylyamTEALwe+W5i4O8irPgzlh3EYX/yq3IQ0KCuYi8UkPm/RwR/i/COFc8I8c3yMddzsJ4Hhlqpo4XdL2k7UW5da3QDw21zvTac4Nk8Mcqt+4kCufBOFs9CW9yiELNkRMb+ISK5thAKnCd6NgxULpDOYZRQhQCCvetQf/k6DLseohi2aToxplOnQLoQ+Qm8yig71aR/gJmviYNYFKEC6FJygB2oSC58J3AVcc4DaBqm6lOxRVDTNoExcDKtjtLbs+CSWiGeiQIrfXDxcxK1faOu4P82s+nF0f5td2LXi+/lg09DAuxEGgJ3IQOC+H4OAqnKILBzBm5dJzoYMY4UhRn7MWJdWj5bnCT3Nq8+oCPo03q97K9KS8L1hvLzpavcqBRCcxsUs4WYeSPGWukm8jLIHGiBAqBw9Swgm4hlM3RysvVfcmqliuS9wfEoZBHZMIgmHZAG/Y7rc7ZVWc4OG22zz/vcGWlYx8705nvRrW27OZHZ3awFmoWUs694IbAkg42ZzN/RdWf8HfkOfHwGHjrARnHtwkQ07AwLllSTBSgsMMkFUBPOBhISqAc7HgTO6NL5Xvrd6tSrlQqVUEBhUGJPiBpClRC/AIhLzGB7t+hHIiq/IBord1DpQEsKGbnTqpYYRZKfRCm1hJhoFItkfZw4NiQqy1jcb6cL9wonrkj9HYZQVM1xfZiVBWBxMRFZxHRItKM+obdUEYgr7P3ixTavYZ1ryKlzVR5ae0qsIu1sKsMe/c4HGbrRtoNiIghALDTiAXUhIxQmDKPfG8mRaK+UZGkhWRWgRTm/SKNeZ9GVMQCPUNNrdk5ACuptibDJaYFTgwwQjonwMgj7IkqrXRfgIKdKilatXIF7CWaLaLnSu1CUWtduOvU+jxKbsObyJndeqMn6TWtG4XuZNK0chVkeaACHuUDrjigKpYhkYGq5nuMEPoS2raur8N7bjyMShe58dxPdJNHy4i4U5SKvHu7rFXhKShOykNR0YI9TsLo1InGVkqewlHh6MB7z0VtfXhUlAHJRAHlRYHFWIwoSliQJ7P3jVqAk79SbkCP4C9TbFoLVgKtccX6z38sWfQ7qhoU7fCiVRZqlYW6z0LdUygQgsWECG8H1neBQ2a9GmkDs4eHhPI/2DQVkOUlcd2oDrJsVbB+U965QlGBAW1gSGijH8ZunBCB8xptkgt3sspMcg1zHCZ2AnkbRPi26t1LCiOFEvWHwDDl+o1VazTky9tGpaa8Vt823lf330FJAT2V5fqxm234wUZx6n3fEZ2PE3cmBHhf0iQgIyAKvkavB+EkedXrn0Kvw8kkdoU+CHaI2GqQ2cwwKVcNrpAt0iBAYeBeOjPrkGkew2GVjOKQtqM0gQEaQ+W8XPvh6A/QYPJbZb819rv/2LlFqXBlVfpXWjPPdAnKKbAqbDDvQPloVzZghglu6zzVtiMgzt5WeNrfqpy2xZqwnWsU68lKRTLTNcrxXMWQdM0D/NzBlXTNg7ThAGmJOkZJXywL2pmGY5Utai1wCaDIrYwMDWkw9QWxvKWdNiWEZkGH/arCCjOThsW3rxluVoKblcrNSvhAJMxYKvH2KOmv6TWJtGesfXn1jf/XfSMPINWJMOyq7hE45PqeA97XwHcfAv+kgK8k9VUOeFsD382Ar3fW7LfOfhvs9y37fcd+3/8wpy5knDY/w09/tYvPmsTt8LSJixc69jKsbcHTKyO5neij/jOFjI2tjt12eHr7ItOvvQ3W3m13+m2Fp/cvMv02ZW070exaa7p5bGu2iJvHtmut2tZC3JRlknTNFmaD3MFsJZ5rISRd80zfcJZL8ubZ+tyZKumaZ9yGs82QmjwtMaEJxGPTh/zVxg0THCUk47Csld1DNVuxDOmKoWkl4uPkDI0q8d82GjX0wdCoEmSubfRxbRq6YGhTBLTPaVNZNCVJVq2RzhD5Ru5DmwPqbu3T8kZ1Y/I1bfwhWwXsJEQ2vdzKHoK+9/9DdxLWNG3aTxhTO/2UvQTTfDBtKrzOh59gPoxVpX/cJjhHyZzZESOpaKJhBnFtuYahNC7QLMzrM2tWcv7qjYyxOX9Iz7Ufs5HxDGZefCNjMwG9zEbGVuT0whsZ42yY/ASlMiR7TyT46I2M5zO6fiNjY3432sgwmJyfYksjy9fzNjfyXHV2l+PVWb8667XO+nXH5S/bcXm+I3vxHZet+P0t77hsIK6X3nHZykhuecflZ4htG1sduy3vuGx1+m13x2U702+7Oy5bnX4vtOPyvKjz0TsuGwfLOTsuz2T7sTsuG0slZ8dlW0lO2kpsZiEMOy5bUwvzjsvmamHecdmaWrzuuLzuuPxVOy7sHjS7jfdp0BmeHXXFBTt2ta41v3bJldzgzovCYOoGCbsWMomcm0s6Abrh2LLlXTyYFlT/gYUwGvMrMX44Vu6uJgLVJvAMFIHE5ZucJghPvJH9zRrZt+bBzBn90T856rAMPbq5dhUa+FqGPyC5WbgArwiaScrw5i1xjHi3qPaeXHr6roqzfXZ8DL8fmxd5UgX5T+axS24r8uGgP7Q3JydfPobXnu9aNpt34fzmNnBjcc+oF54yMfDfHltJgKflKeZYURjHdq9knYrZex64H71gHgPy4M+I7aYAdAlRBJQDFaI96Kt45gABAAAJqHJ4EWaiDl5ZTTWxC8BFK5DaOENxKosnjj8azNzR3MfLzk/rK79Eq/KKOk7WMWoNtH9CjrZClJDDPktdOOq3j5uzWRQu2Y3rmPHEWTDwdEV2p8IgTtjFYYx5SAC1RyKoPTCxtXcN8tB4VyPX42o1vLim4FQ5DkEBiHqtQQKsOiVQL/DLWKlBgdZ2AV2MWaVSJ2YjsCPI2WHQ0H24y1nN3vtQrr2HEuS4QGsANSrzlYTmEeWhRviu09YRkNBESLxP2TyC1LmImTveFm3gOk5RSKl8Q3hP3RDmtQAI2NgoEuFzBSdKv3Pc7bQuz857w3and3426NDhOHGTTnDXdyc+rnaFwWcvuf3ozY49P3EjcLR0jPq5gzP1Zq1wHiT8fewGoRe7ZwH5ZESywpFLmT+BmJIzJyUXjvwEJ4iNU2d8PF7afYib4WEFD0S+1UpFca6Af0QXfNBYEyGRGJrKkVBTZMdHG9eI3DEg6ZbQ1g1yCUWALO/yZjj+hEiKUFBiFR0VYHUZ4MJabYc2TQzfoWIjbVqORoLRzoLwGqSMyYBOS/2ugS1rshQ1QLWuIIylskArKZUsFbiUHXXOFsNGJaIjwv/IBoSXjJNoPkqsQeIEYycaD+bRxBm5fM3W8a/dccgWW2chtALayl7pVV/24k69OPbuXPbqY8Q4lTtp/H2YuLFQtYzdnbqJ4/veSBzcHo38eUxa/M4GvtUSnILbh6mCn6mw7DT7dBE6e/R+32KeCQPeMu0d84E2XVqNy5wLvsYspjlVcS7VOkwLlUTJgNoDHHkjOi7TZ157pdVqi8C4hI28cJEL39VDpKmztJ3rmExR8H9XmNnS0VV4lSbflsY+Lqt+4opz0tU42dO+R8JuI1P3pMF1YV5eSc5OGWeMq1PBFKvv6vVdUU9IT7zA8cknKdD5dunOhfrlEzZM6dLFgTaurTBIIg9nGSs4EMa4e3Zyegkxi/W3v1m/YMFR87J1etY7IQVgJo7P+5+b/faw2W6TxdW4rKmt/O4Bfv5CZVcCIpM0BMV5mOLpzaG1X67Wq40PtbeN/cYHMRk1NZM9UPyLGkbY+iBKX8/kEBFmJBk7xcZuuqlCJnnCTQrz1yxQVlDY6TWPuhgI9vlXLlBgMGxERiggZkBmZHPmoW9VKJs9PcHNbDQxbhGwkzVYjZsrHwqS75x7OPaMbF6Q9RuJWnkYVUXMh8QTXAxSAKGloC/E8SmbWGL/ZUHCM2GI0wNXPBSHZhRlKx6mR5iLa9KcXpO8twGWo4fBDN3tIlrhTK/boAWMsZH61SBqu0apjwUxfwM0M240JxMgwy3jft0zy3I6wkYS1D9LVhXPK/GFk5Nwmj+VkLpHVadaXzNjEQ3D7L0r5K1w8GD0BmEGEHgwhuunzG1GxAs0gG9Fh4gAgfaUCO/hwEghTu1iinpO/KN0QREwbVflhQNp0qVgRskqSgqZO+KqTKGiLZSIGh/Lin83EmFDLC1/ihj35SlaOpG4LGMTGRjVbQml+HFHTXUvzi463bNeZ3j59aKDwqvs/ApBFyC6FnEmg+FFpz+8aA4GVpUJLh+gklqXYCa01f00uOz0O23qn4atT90u+iTSXO5nr47DaAFWhyzMiY9f3bHPOxHrAMb0nykevvGPrTAQ0vmHgHB5re8EN24zuPHdh6AhXjCAfD/Qs//BNAyT27YXJ80k4VkxfioKMmqe0njBHbxBfR/CvLnyyakJsbnEwRMEGP0UrHBnpJljDk8zEhrlMSJF9mDM7lTsovYq03swAs/shpNA1D530HIom9xLW+ADR9Ui/gGWVGDwAJr8OIZVyjQm+qLga7yTMSXM0zCQrT74JPATK08ehSPftEsXnpPlXtmt0ZitunAaXbnsovWYjgaAF/UGIDzRaZvGxtYEolJW5+9jZpg5qWiOxx6eQvlpE4u8aBeUKBVi/lflIVpUzeUBlV6QWMF8SsxdTEIwg3G2/pExur/BlEhs1ThVvhHHCGbUspGqhyHTAfz8PY0Mhbu7OLoYMXrW74eSg4J1HbnOH/x7ht1PNE4Vdtf7lhGcgNVkDai864PTVI2WXA3S2dOgm0qvBun8a5BOwLidoPMTmkYqnwoyRWdmQ+lMyvhjvzLglKTELspnDuv5/nxqpbIfnBkaEWr/tKISZ7qgWhFRf0YCFGk789mmH+9iplTDB3OaKlJaomFeytCW0gh8CH3U78fmbQNM3AYsc2NHeVQFWshUiu+GxWdB4EbKKO+pmk2VTmpGVTknGJ/PE4KZL6F7ZWAVa6yKl300TzCyJygX0sjn/HT1nmg8ZefJSKD0FTcESlmyjJ1K+aCU9xHL3DKsUfpKwxygRHLzR2e6awYFk+B8SS7UJHjDVDb/1KWaM2v2+RFZbh7V9TQfQYRkwnlElFxXGSdzmgtx+4AsAqmQ2RHFJIAaFxIEoEnJLHaQWVlQPoeXif4rfIfrifF5VYnP6/u4pewFGD2AiOoFCzzEOAz8lUW/1WxdD0cj6j6OaMG/aSQhy//57cDSvpqcItowEoWsB6YXoXAGkCNX0p+jhzOCPNTU24eaOom8sWyHdyQFwFphS8ytFqngK0PK1DLlJWvTkGzWQZIM3hBlg39uc+oFR5gRx8xMgynj7xJH8AxYRGz0HMMBfeEjRDBYP6wbN2GPNgHy8EOIvJLwdUAVvax0FWSrDHh9jgqM+3nzb2lgbsZM4NUsuC6gHLxaFg9klwO8j8BszrDufN8RcsLuixcqADb8KAaqETdQdUdcokE3WAG0odCEPwc7+Lcs7ucwIhh5kArOqFIlT7RTAt/pqAGHSJXrvbukbMb42d6SpYwycswImGcLQcGjvAT8m9oCU7b/oQ2Qbovz0sL+x8yXkje7VscPVvrhDboX9uHs8opeW+KvS+FS2XHqPVsiF9PIy8cQFBTdlcuv++3ZI/G1cyArOEfPRHp4T/qFa0UYSZMADZrhFJCVmGVtyCe1pTJPo9gGcSnSwoWuFj2+kJGezkJG2srBdH4Sm1TjXMCjKCPX88kZJvHJ+vISpEIFWX1bMOF9NeOtBN57RJsTS+JR9UDpkGRlTnaZRYfwcP8bfl5KMlbSmsOcifawwI0NrcWV++pbnIzv5wWyyEEaK+N3amk5L8FD5vx5KWTPyIgzJ60WE95rjruFHJeE11vOclOjn54tN/7wWJ8rtmRabK/rxpSSkXaam2jWmJpTa8aVZchzkSLPaY5crZCnBxNjgugLw0vZSBljxcyXwHke6L6TCYA5WEmqoGXdGf/6wxJvJb/aauq9zqv/3Nn3Ws7/CxLwrC49KgfPhFOPSMPXiurnycRzuvacZNwQ2z4nH187Rq/Z9lazbdOQvUjCTbSl2eoMLsOAbB3b7PgrANMziFSH8PDfiFIgXvM99Xj0uCEdevz4fK3cqOqlR2RfvLKvl7YIbD1V2qZ76B/00g4prdblDsSIScluki/DEzFaRwX6b014XUupaxfgT6egxGPozWFGzub8exeix8q+7Wm7TwXADo8pcrJFudyMVUHjP6NEg+GRIfvHL2y60K3d4/DG5ic2xJVd9i9BZqFwJhA2DcEMs+03JxjpwVTJWqjx+CS8If8khU5H9k+FpBeDgk4w1itXSgCLO0Q2A9rjTRMJi0LeAjG2GAQVZMc6y9kje4X/1Qj3kAQrEBxLO/xwL9r0AJ4OcJ+VGd/gy5Ob0iE6SzDr4LwVrXpZtAnE3OXM3uO0iwobcqQnmjAGf86dyB3/P5KJSToPi6rrrNxtyWkIVC7DmVa5VCuJ49eqV/xuuzP9TBLcKPyXlbokDn4YDJQCUF4RC8VQeWLMUBcCRa0QKKwfbTyr21Zntgpd0vhJDUJNngemZL6W8IGIGI+n3kR4UJQtqMte4F1lJiCeTyz4dXulnJHEhJiLc4/2aYV8SClyRlIt48ILI1FUnsjpKHGrTzZCRJIlgcXfJXwus4oUmjrLet+zrOsiPHpcfw8UzjFP5S3vcTIFY28QVMAWLfkEUsEpZ3MmipZ8wrqCUWZI7kkdNXOUM0wsnBHSIahUnzjcLzhATFm43bGJA8SoedfinW2j4lIcXFQxlNJD7lntVXvNW6A6kTI/E7NtuQshHQenftlv9gbHnf7w+PxkeNQcdISRKVnhnAcc9FwKroEpsQBg0FML4gyM9N30/OGvrp8Br0pw5hHzYWsarOIw8lH2FW6k4RTwsSvraXDPD6BzgTQvLrpfpTS8AKUg46GSLhElHiRxJTvPyP+VITvNKB8ZGi+jB7y8gF7juhvO70S60e5cnbU6w1azNzzq9DrHZ5fD4/75x+FZ7+LT5bB5edlsnX7s9C75rokfjvhhFnBKCts37L9z0uUtcgcqi1I1ovAAPgepZkSiixc5KPtGFH4kjl3QwlFK3eSqtU39yAfSOM8HU3jNB0pxJ3blfnnCKOFXWIbDq05/gOc3h7hMVW9UzGMnxEOXbkl0zHMTVFI8cG7ZqHqZpdKna49yr4IekzWImVsELlEFSpMzgRMiVaAUMdNjpVKiCpRBCzLc8UO8GS5LOHkKRl7TOEqthqVynsYRdRqG3o80jlLLsfgtF7bWjH5GilkmzDSk40zSWEk9X6tXL7Ay4P/wUHDK0fhCtlZHcDiD6CokrxxPHGFNVS+UUJMfQMx1JPqaMNg9gcRlqPy3M/FoZf5vIwkdi4ZlZk6GW2HjjRwblyPk9sHuUzbV8zYqdJpcYXPP7mXBiSZkHQ73MoqcZN9kjk7hCk+f8AbtRHFzM0M8JLc7agV1k/8LgzSpeTB6AAA=")} +}}, +{{ + {"vert", GzipedString("H4sIAAAAAAAACuVa3U/jSBJ/z1/R0uokZwLZxAmznHzzEEKA7EKISGBOQijyxA141rGztgNOVvzvV9UfdjvuhjDs7cu+zIyrqn/10dVdVZ2pLWM69xM/Csmj//C4JPdB5KZOTfkgHp1HHu3YxOLUJzrvkvjhm1snf9bwb/KFfZJPxD44aLbKqyf+QwgC7WaL7BMrSenSatuHzdYesXDRbeeuThqk1Tyo1xFge/kgW0YhDVOAAB5IWIvIsxjP8sPUqoDsEQZfR4JGna2o2wfRX7YVXrhh6icJOqVVZetUfSKfDw46n8HABgvFbfuORUOhtO7gX4edw8PPrUPUGdN0FYc8PJ8IzZa2lfu6T+wO4AJdWuPUXmpJGq/mENDUDT039m5onA7D5SqFXVA2Zhklfgr76dTgs0PCKF64AfvoElj5APgA5tT8kDABd1asKGhyGafYQElp1o+i2JO0LtIk3k/+Pen3Z9eTwezi8mp8hjI8nO7sCeyk2ZAtTMkDTW8EwWL5w8OA8S1E6+hu4K6jVQpb6LW7EItV6N+DUaDmIoqXj7CUGTGfzzw/WQbunC7AlK8UIpEmt+2DO0crMKUZKKTD8D5iYWDegVFjP6PBeTR3MRIWo6Zc9IomUbBC8h6aSZYoOQw9mqH93MuCdgJ5w1NGkXOEWAZMzClFfK+qplksWHO0KFaXkJ8Na0Qs0Xgr2yNrFsaSg2wHT+JoUfY0EF97RO+4slFsgSUXNEFN/u81Hgw4Fzr70BKRJMeDm2F/MJtcj8eXV9PZyfllbzqbDv47vb4a8C27p+n88QYSsRfH7hrNFbtmJe5iGdDYPkYNuu3wpQMTf0MheMIQ/LLYklYRJ/imwQnq4iy2Vgk0+ZcEQjcV+s8Fvc4RwTkaJPQHzKcBS8vCgZJL4IEqABdCV6SsjDpIVLLXnPLNbK16UhdgmYJSTZFcVYOnVgtvU/gDfH9Vk0Rfvwu9/U70zbvQ7d3Ri9PUtWqyBloioXjGZFADDKy1mbVBFrhZE4kTev69OO/gyHHlNsPiA7miJMgfqwgLoi+yscuv1pguXCTFOWufS7KsgcNnKRJfIG+LU224RXH1XTMDMwmmN6lgtHfFWJsx7F0xNjnGbvLPGN4XXgZZ2Zl31OC+cTBFLZJhF5cXq26z8dWgf3kxvp4OjqUl5kPPEFW0JvQDTnFhdGDjklWAG4pfFiYov1XQjBCrpT+nCdvU9LWzvcGyEcWE58vUjcFpWNVy8o//FC5Me1eng+msf3k9mjqk0RAifC+YOQ1ogN7wqjDuU66jUfEVmIa8FjrZORBx5ModeSxeyoEXVp/1JrPx5WQ4HV6OarIxKPYQYjQWPY2qNXHyXNCxLWXXPSUn30gdk7I9UupmhD8mb0aXVxe9c70vI9aLGTypMn/cD42i93kx7Y1OB6Op3o0pbxYNfmi4P+6ITpXek6fI94i7XAZr3lWCTmg6NT22m6axvH4lEK88RTvrvJ2sCNOUDTfUGaxeVVrDmKOKD7tlFAPn3byqTqE0DGm0uyq57QxZzASqMpXUMG12Vd2LaXdKc07lctaFfSviOwa7tLmqXeV44NQz+W04Gg1Hp8pw9D3yWYYXlGdenkrj0lHvt8HxrDcaXvSYpchC+nA0gbD2BaQy3wngXugv+BAjjDGOS5Pf/TD0wwdxPsrTIhwWBrc9Fr2Jhvp5Z6XFK8wDMLmay5UuBVW5rIlv6tarTG47+D7QuWM6q1uki/Rb4wi42MX0+BUVXLhp7GeEvwgQXybe1m6pbwnfIdc6/NVia9ua2Mtv09aQiz4OUduMjQyNAXw76gxds7WFBh1zk0dNVeOHT2KW0q15Lj+eFPPqd2wJ+NJ6WSZTZPZhhd5SnE0QzVqL15YCTwz2T+1ivrO2IPgga1lZZTHrzCWCvRtC24zQ2Q3B1iGIcoY5ZrEp46mNF5KcTzjJrpI6VVK7+Qz/tNmfHfyzjc9SxVz6F+Rx2/5/JrJE/+dmsmHOfF9i62bO9yX2OxE0if1OhI4GoVY6oe+PTPfDVh18GOHzhxF+eTUynR+KzOGHrfr3x7PuL0hcXebW/r47lfcWO12tbBj3MjG++3X1zBetC0rw3qXI+woXHb9T918nYd/9vVFg/ifQmUnf6/Jpnpsm01Q2xMUmlYNmcTZcl6ygiF65mdUaBsF1WXBtFNyUBTdGweeyIHs/YiMIbz2N4wcLwQIcLcKAw6AUwUd/AC5+ZtGimkdOA3xpbBQ6SjRHHf7Yz1kgwfeioPPdruPGO7oBbmuRwiytfHlzDDkNom9ghmzdSd68p/4CCuGCev5qUbT0yTymNORFcpsXwuDxRDnvtVml7y5o7CoqWSQBAP6+8Wle8SuMYfik5Y3j6LuRYVqEgMaFkllaLP2cM/thNDWGZ+4GmvjQDFKADVTbHHx2Pfdh8I6NvH4URBquu/jmw8ZPfl8beadxtAq9Kvs+ejCAAufITTR2AqPnaaBC6sYnrgbpCeMYxfynTf0MLaZnCPrXKA68lqMhtnVEu0A8H56eTS96Y0UqwMsChtILd3l9M3Zjd+EoBUKsO+pN+2fCDvm7qLcOZ9/cdP44871Xkhh/ygiOUI56eSorGcRMTG7bLTn3vjpCMzQjjGOgD6fO1sSt8/plh7eIR9eLnnX6zxFwHLghVc/KtoB6anU8dW1+VJhOOGDIPKbL9JE/TOikdhTh3CB6XpIt7ujkfGLmfj0bH5m55+PRyMwVR+hF1n8oE0qtLe58pSKIuispvHZrfqwvXtisvKzpXlDyRy5euTTCvFTl2aQ5iJKJBQvbk5owMj+WSguyzWu/wrNf4bWwb1FhSp+27GpqzI/KkVUsLp04/l8W1FNcv3OKplCzJg+TskdF/RDjrygKfJisHAwgS7R6qafInzQ3ZP8LhqHVauedVqX1wLsek4c8BPmvFyxh4hRaC/LyP8hN1cEXJAAA")}, + {"frag", GzipedString("H4sIAAAAAAAACo2UwW7CMAyG732KHNvbJu1W7TCKYEgVq4S0HaeQpjRbEldpUsYm3n1JC6xAgnaqks+/7fi3GjWKEtYykEjQkhnRoIoD1mnE8Q6Mjltd3j/cJchIVoESKMtWNS5hi36imm3qBgmsHxAh7/ab2wtdcCxpoeAjDQS8Mrq9xcbajpKet33NhewcnNJG1wtZgT/qnyED5bBt0AVdzvJVmL49F5MwzYvlMkwz4KDSaH9junMOa8xP0/3LoJmgaXQ06ZSXKErlin17mMSadXRgt0pmWFCFRyVHrozNugLWDy8bO3gFQqJL673wTHx8J+n7L6ANjodg7pkP/WqgNcpDBGYyZ3rKVJAdrLykWKwZlXr1uQuyuQIjy2tcwSaQ1JIJbj19WvBUelJJitUMezJ1bo6gdL8Q/WWWzRTevBjdGI3iIc51kdh9UFQbJYezVQyCyoajeITHGeLzVU+c6rB3HIjdR/ufeUR2++zNqSknP7y8A1YiN2FX4IxZmascJyna/wKa+JBVtQQAAA==")} +}}, +{{ + {"vert", GzipedString("H4sIAAAAAAAACuVZbW/iRhD+zq9YqapkQsKBIbm09FRxhOToJYACSStFEfLBJvGdsaltiKHKf+/MvuA13k0gud6XfiHxzOwzr7s7YxdmIR27kRv45MG9f5iROy9w4kZBeSATOg4mtGYTi1MXdFwn4f0Xp0j+KeBf8oE9kj1iHx6WK9nVA/feB4FquUIOiBXFdGZV7eNyZZ9YuOimdlskJVIpHxaLCLC5vJ3MAp/6MUAADySsaTCxGM9y/djKgewTBl9Egkadrag7ANH3mwovHD92owid0qqydar2yNHhYe0IDCyxUNxUb1k0FErlFv47rh0fH1WOUWdI43no8/DsEZrMbGvt6wGxa4ALdGlNo/BUiOJwPoaAxo4/ccLJNQ3jjj+bx5AFJTGzIHJjyGejAI814gfh1PHYQ53AynvAB7BGwfUJE3BG6YqUJpdxig2UmCatIAgnklZHmsT7yb0jrdboatAeXfQu+59QhofTGS3ATpp02MKY3NP4WhAsVj88DBjfVLSI7nrOMpjHkMJJtQ6xmPvuHRgFai6CcPYAS5kR4/Fo4kYzzxnTKZjyJ4VIxNFN9fC2oRUY0gQU0o5/F7AwMO/AqL6bUO88GDsYCYtRYy56SaPAmyN5H80kM5Ts+BOaoP3cy5R2CnXDS0aRawixBJhYU4r4fl5NOV2w5GhBqC4h7wxrRCzReCvZJ0sWxoyDLIOnYTDNeuqJp32id1xJFFtgyQVlULP+f4kbA/aFzj60RBTJSfu602qPBlf9fu9yODo97zWHo2H7r+HVZZun7I7G44drKMRmGDpLNFdkzYqc6cyjoX2CGnTpcKUDA3dFIXjCEHyy2JJKGid4pt4p6uIstlYJNPlZAqGbCv1dSi9yRHCOehF9hfnUY2WZOpBxCTxQBeBAqIuSlVEHiVz1mku+nCxVT4oCLFFQ8iWyVlXipVXB0xR+wPdnNUn05U7o1R3RVzuh29ujp7upbhXkHWiJguIVk8AdYGAtzawVssDNgigcf+Leif0OjpzkTjO8fKBWlAL5ex7gheiKaqzzozWkUwdJ4Zp1wCVZ1cDmsxSJD1C36a42nKK4+racgJkEy5vkMKrbYizNGPa2GKs1xnbyjxjeJ34NsmtnXFOD+8LGFHeRDLs4vNjtNupftlu9i/7VsH0iLTFveoaoopWhH2ikB0YNEhfNPUwoPllYoPxUQTN8vC3dMY1YUuPn9vYKr40gJLxehk4ITsOqSmP98FvqwrB5edYejlq9q+6wQUolIcJzwcwpQQP0glepcXtrHaWcr8A01LXQyfaBiCNX3pDb4ikbeGH1p+Zg1O8NOsNOr1uQjUGaQ4hRX/Q0qtaosa4FHdtSsj5RavKF0jEp2yeZbkb4Y/Km27u8aJ7rfemyXszgSZ75ej80inbzYtjsnrW7Q70bQ94sGvzQcF/viE6V3pNF4E6IM5t5S95Vgk5oOjU9thPHoTx+JRC/edJ2tvFysSJMWTbccM/g7ZWnlYw1qviwXUUxcN7Nq+oUSslQRturkmlnyGImUJWppJIp2Xl1T6bsZOac3OGsC/tGxLcMdia5ql3ZeODUM/jc6XY73TNlOPoauKzCU8ojv54y49LH5uf2yajZ7Vw0maXIQnqnO4CwtgSkMt8J4KbvTvkQI4wxjkuDb67vu/692B/ZaRE2C4PbHIteREP9vLPS4qXmAZhczeUyh4KqXN6JL+rWq4xuavh+oHbLdOZTpIv0S+MIuFjH8vgDFVw4cegmhL8RIK4svI1sqe8SvkKt1fhbi420lbGX36QtoRZdHKI2GSsZGgP4ZtQZuia1qQYdc7WOmqrG9RdiltKtecy+PEnn1a/YEvClxaxMosgcwAq9pTibIJq1FG9bUjwx2C+q6XxnbUDwQdayktxi1plLBHs7hKoZobYdgq1DENcZ1pjFpoxFFQ8kOZ9wkp0n1fKkavkR/rXZbw1/q/haKp1Lv0MdV+3/spAl+v+3kg1z5m6FrZs5dyvsHRE0hb0jQk2DUMjs0N0jU3+zVYdvRjh6M8L7ZyNTe1Vkjt9s1S9vr7rvULi6yi38uDOV9xZbHa1sGJ8kYnx3i+qeT1sXlOC9S1r3OS46fqvmXydh3/7YKDD/I+jMpO9F+WqemybLVDbEaZKyQbM4G45LdqGIXrmcFEoGwWVWcGkUXGUFV0bBx6wge3/ERhDeehrHDxaCKTiahgGHQSmCL/0BOP3MokU1j5wG+MzYKHRkaA11+GOfs0CC5yKl82wXMfEN3QC3sUhhZlY+vTiGnHnBFzBDtu5k3bzH7hQuwimduPNp2tJH45BSn1+SmzwfBo8F5bznZpWWM6Who6hkkQQA+Hvt0vWNn2N0/IWW1w+Dr0aGaRECGhdKZmax9HPM7IfR1BieseNp4kMTKAE2UG1y8LXruQuDd2jktQIv0HCd6RcXEj/4tjTyzsJg7k/y7Lvg3gAKnI9OpLETGM2JBsqnTnjqaJAWGMcg5J82xSa1yWI0h7CyzYbe8bMpv9E6sFU6vrqXxIklKfzUY0Lr3ZR+IwWq2BaMbP4omr7JsDp+7rVK5jUCPxsyYoqFsOf46b+ukPIje6UPTfTv/JrMSuMHrIMNEpyfv5IsrVG499ZvM0GDws2wyuyTjvoMUYZYc//XH4qf/gVlI1UmXiAAAA==")}, + {"frag", GzipedString("H4sIAAAAAAAACq1WW2/bNhR+168gkBfJkV3bSdEWXgbYqVcEqIugLFrsKWAkOuUmiQYluXbX/Pcd3iRKpjwE2Istnst3LjwXBjtBE1YyXqDv7On7Dm0zTqpFkJEjr6uwrNLZ9TRCdcG2XOTo9vZDxh9Jhv4JtDhCe5pcoyR5qFhOF0FOU1bnu4ZaJoLSArOfHl5BKranmvd8xuQtyakgjsmcVAoA/r8y+mMxxLgr9l7eveB/DTKGlCTgoKJldpRtnIny/56Xg+lJSObJDz3seFkLDycnrPjIqvdMDPJuecY9XJI/MlpU+O/jIO+D4HWRnrK3/GkAFDgrUnr8BMYy9UAVlIg/iAdpL/PIRaUK4oJt0fLTl7vlx7slfvjy5/0a3dygWaCEtwdCwpLku4yK+XtU0UMsUeZoKwj4yUVqzoKWPKsrqPA4UIT9g3h6/PTNsPVp7fJwh4c7vE0Edai9PcnFHLFiT0VJv96jG0UIZ5MpeuW4MAEvT2jHaCEhr5DyC1QhmAruPdRBaXejyeH405Fb++XWPTnsx8N9POzHww7eteSrCvCKbpwoNkiLKGnHUFbnRKfmKpxO5u/exWg6ef32jfybza4BQY0fJacykfIqNLclaV2BtSOw9ghgBwH7ELCDgH0IKg4jsImRR4AVIJGzIlSnWH3ao/UaLiVuZKwjkNmoC0UOEoocGij4tMculCH2oDqVmMrRAD8TCToODQi6tChojAyGoUkQrXEEDdTTgHqxGpB2V0MHAHqfaVon1ITQt9fAtLpoFMgaeI1GyLTJ28k0gvDk6RWazdXRGhDJDqadTreWVmkmj2WoogQ9+32MIrDSeKSjMrekmhKAY2UsDqSvijZWxLGmSvlRaxLwRm1rt1W+BFAoXxlA0OmHZgS5etqnNtor+B1L/Ui1GLp8Ecbch+F04Ap8Uy6OlIuXyKb6JVbGEvnlzlmtTnmv2k5aNZ0GA16Xygr9ZvspQr9+IUP83XZGFAWJmTxyEkmUZdxOGIlFs5KeCK16QoJCEIWd3c/BBS1Stg2grMyIr2F/25dHu13gXbKrq8+0rLNqQ3bNWyXjCZEjXBZCJKX0ItPpUSb2nKXShURmqwz/c0MZDGdL9Sjrvgw+kcEnMnZrdTfU6XKCR4GxC+ywveVLvc3GM9UkM9mYvZZ4sDvpVOu8Ej5nalDpjKUhnY3dyd7ijWQ1qMuS7ycUyoR1BqrJy8JHXfuo2CuLvbKbs48dt0IgiM6rWt9Zp6pknFDHcoI1aougrUGn/JzKc55Fps6cx5CpqnbRNxUOxtRLrNchMfo/rFyonnZt2Sl0Yk5GrDRUPz//Cy5I6hzXDAAA")} +}}, +{{ + {"vert", GzipedString("H4sIAAAAAAAACn1UTYvbMBC9+1fM0V62xkl8aDFbaF26LBQaGthLCUFrK1m1smSksfNR9r93JMdxQu36EKN5M2/ejJ4T1IYXwgqt4FXsXmvYSs0wCyQ76gZDi+UsTSJolNhqU0GeP0r9wiT8Cbp0gJYXKRTFBkXFs6DipWiq+hK1heFcrcRpBFMMRcs77O0/LXNWccOuWlYMPQG9nwXfZ1PAk2pHsaXRvyaBqSJHOFnYgzfF/ZyF17/UdnI9BZMj++GHWtvGjCAVE+qbwC/CTGK5lnoEZdWL4ApXv4+T2KPRjSr/hbd6N0FKyGdmR3QS8KkcoVKcma9shKl1e9QGvSEsmqZAWCFTJTPlMzf4pOoGL07wVbQjgeTfLKDjAhR5hkl/SIEqdzSRZxMKfALbDBVDrC/rInOKID/kWpuyj6Uu1vORUeFGuxPur6M7kVQIIxJ6jsODTwuH5vcwi5OINuBMdHbQD43flTxSsouG9LMIB39F0ZmdKLqU65q7QYLYQjj4+ediHe/hIyTUjgT1/RxELNcfhB/cOi92cudh+j5O7mGe9ko9X7KOD9TvoUsd4rOJ+Hwdn/Y947vZDdfiGks8dJnOK7xz09L9AZeWk/wOHVRfEhwSnwhL4g/u6YCY/hwMx8aoPq3VogT3jbjrgZ3cLM8X4lUYDKMM3v4CJvE66xYFAAA=")}, + {"frag", GzipedString("H4sIAAAAAAAACo1UTY/aMBC98ytG2kvS0pTwIbVCe4DA0kq7Klp2e0XGGNbd2E4dh4+t+O8dOwSSNql6ceJ5njczzzNuJZpRnnIlQbA1z0QCm1gRM2zF5Kgy46VmHfY7PmSSb5QWEEWzWK1IDL9aL3z7kgDAjtE+ULo0XLBhq6AprCnVjMkFf6vBJDF8x3Ls9I+QERFMk1JIQYwjwO93zvbDJuCr3NVic61+NAJNTpaw0bEAK85FndTlP1dpozyUxDX6sEOi0kzXIIJwec/NhOtGLFKxqkGJWHEmzeL12IjNtMrk+m94o7YNpIiMSVqTJwKjdQ2VZETfkRqmndVRaeMaouiAlIgkZjrKVszJIndcKykw1WELHXvYKgmhr4+z8RQ8x6S3K+Zjw2hmMi3dNsAF3kGi9l4YhO3cRtDSHQyCDnyAsPsp6PgYOOdcIN2Tuuc2Vcfagy0RgpRo3R4Z3PfiOIqmiycl2QNJzn7Uqmb93A/cguDSc/9tW3jPs4ExMlUyNfkAwgiPdYNBWLWO0doJOr2qNXJn+39YJ+7s4HPVOnXWsD8sisgTwSq8ES755j2MfR8+lrCohE18XKaFUn0c0DtNtt8yk2TmrP+l4hu+QXz5vJguv0wecwHcTdyWdfIudmS9YXLNN5Wj6U9tKmfOudO8HU8tfn2/XHzbRm443G6D6YFXpGNzsa2yjJ7H04fRPL81imGubeQZdsAIzKu2W7sgDg7HN9/lGqfsSlDumf+iqJZ8rqqsp5PTo1b98uwG+zaEedOcinczVhTfU3zJ8YJ9QMtlqCzdeXJ3iq/BvhBWjgqGblYnzx/C6Tek/VSQFwYAAA==")} +}}, +{{ + {"vert", GzipedString("H4sIAAAAAAAACn1TTU/jMBC951fMMYGotKWHlUJXWroCIe2hEtJeqqpyEycMm9iR7aQfqP99x25dCiSc4sybeTN+8xzUiqeoUQqoeIZNVUNeSmaSoGQ72ZhQm2w0GUbQCMylqmA2eyzlmpXwFrxg8VIDQMvTCaTpymDFk8DT+KhOFefiGfcdmGAGW37EDt+0nLGKK3bRsmLGEdD3L/JN0gc8ibYTmyv52gv0FVnC3kIPfij290zd/HOpe+VJWdmhD9/WUjeqA6kYij9ofqPqxWaylB0oq9bIhXn+t+vFHpVsRPYVzmXRQ0rIPdMdcxLwK+ugEpypB9bB1FodpTLOEChs/BbYinRAQy71sQnF0uMsZBkbGUO7atp+E0mhDRNGk4tcvcxzzc13vptz9aBoc08il74qwwKNXvyAKxgN4QYmS8fg3gwUnESvailIw9Clt/HxOQFGxIA5hAh3MBpQlzdQ3DSKbjPYJnAIeKk5+Izxp4zdl4zbTxn7c8ZFcGODh+PkLVcGQjsGuXUMNXkVptbB4/Dd+ovhcrDdxRePYTGykSgJXMHNFNhah7UH4Br82ea4NfhVEburubpYH1FRyVF6OlMF7YwST8t0IXtD/7+Hn1MYuqueNLa0H3Q+bQTpeK6KlvGZchOdulxPnU3CU/c9DSZiR04rDLxmJFXop3Vo7NZlU1qJGdjHZVWEolzN329q1Q0jkvs/usn3vlEFAAA=")}, + {"frag", GzipedString("H4sIAAAAAAAACn2TMU/DMBCF9/wKj4nEAFW3iAFStUJColIRa+U6l9Zg+yLHDi2o/x3baVAqbKYo9/neO19eslYD4x1HRSTU3MqWNAKpKTNBT2hN3pn6bn5bEKt4g1qSqloJ3FFBvrMD3x9aQkgPbE4Y2xouocxGmbHaMQ2gNvwrwhQ1vIeBnf+xrKgETSeWkpog4J5vHD7LFHhSfZStNb4nQarJCyYbR3jVPN6ThfnX2CXXw6iI7AeOLXZWR4ikXD1zs+A6ySoUGKFU7jgos/k4JdlKo1X1X9zgPiHqyCPtInM68FBHpBRQvaQRpd7vEbUJgQjFqlpqun+xprWG5MM5P0Xh8qDBWK2Gd9eRceWFZqTfWvcZxgB1VLYC9GxB/Gpe4WjCToNU47RJPtGa2uVmOJtP+m6CeFF4u0tgBTIXZPcL3RMXW1f5vY2XuqysR14Hf292xVybnyIvSnL+ARBegAqQAwAA")} +}}, +{{ + {"vert", GzipedString("H4sIAAAAAAAAClVQy26DMBC8+yv2CGlKDMrNyik/EKkfgFyzVK7Aa/mVR5V/rwlNoMednZmdWWYdKu01GRix03G00A8kg2DaQELVgGwteR0yY40FvByJXCcYxTCDqY1JsEFeM1L40NV7XkI0uic3wpGMD9IE+GGZvIfYfsa+R8fF/7kWbJRhmq2jb1Tz3fsfK6ELUJSzSQNnckN3Ig+HVUrYLGbV5Qpvq/F2FrNSDdp+WKkwS18uuyXVJNxAU3F4h7p6hvTKIZr54Dpgpk774uW6BV7x7aQsszT/5ZFw+ZnDEJ1Z/HJDlkh3MEptpn7wNbSnZ6HDo3dRCrj/ArYF2iyvAQAA")}, + {"frag", GzipedString("H4sIAAAAAAAAClWQy47CIBiF9zzFWVLTNNW4I11pfILZN4TSCQmXhkKjY3x3/1I1zhI4l+/ApqiVmU3wcHow2U0YbZBJMOOxaHXA0udFMCtvISc+p2F/bCtkb8YQHS5SpRBxZ8WE3E86Ku3J/hDsLZqlm6yOhzOcNP5HX1OOWjBKP2KM8he8ooRyVMFSXIe0ifiXoS4klXhVvYpIqyzl8091jbZpa+yblrQlr7ne/rDr8GGLmgL9Vkak73E2KJnWn+hAE+kGG5PqL0R52tRLMEPZsUL/eyPbuoZXAo8n1qkbFlcBAAA=")} +}} +}; + +} // namespace cc diff --git a/native/cocos/core/builtin/shader-sources/glsl3.cpp.in b/native/cocos/core/builtin/shader-sources/glsl3.cpp.in new file mode 100644 index 0000000000..49b7829da6 --- /dev/null +++ b/native/cocos/core/builtin/shader-sources/glsl3.cpp.in @@ -0,0 +1,35 @@ +/**************************************************************************** + 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. +****************************************************************************/ + +// clang-format off +#include "core/builtin/shader-sources/glsl3.h" + +namespace cc { + +ShaderSource builtinGLSL3{ +${PLACE_HOLDER} +}; + +} diff --git a/native/cocos/core/builtin/shader-sources/glsl3.h b/native/cocos/core/builtin/shader-sources/glsl3.h new file mode 100644 index 0000000000..3cc6f0a4c1 --- /dev/null +++ b/native/cocos/core/builtin/shader-sources/glsl3.h @@ -0,0 +1,34 @@ +/**************************************************************************** + 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 "core/builtin/ShaderSourceAssembly.h" + +namespace cc { + +extern ShaderSource builtinGLSL3; + +} diff --git a/native/cocos/core/builtin/shader-sources/glsl3.ts b/native/cocos/core/builtin/shader-sources/glsl3.ts new file mode 100644 index 0000000000..3304e790b7 --- /dev/null +++ b/native/cocos/core/builtin/shader-sources/glsl3.ts @@ -0,0 +1,143 @@ +/* eslint-disable */ +export const glsl3 = [ + [ + { + "vert": "\nprecision mediump float;\nlayout(std140) uniform Constants {\nvec4 mainTiling_Offset;\nvec4 frameTile_velLenScale;\nvec4 scale;\nvec4 nodeRotation;\n};\nlayout(std140) uniform CCGlobal {\nhighp vec4 cc_time;\nmediump vec4 cc_screenSize;\nmediump vec4 cc_nativeSize;\n};\nlayout(std140) uniform CCCamera {\nhighp mat4 cc_matView;\nhighp mat4 cc_matViewInv;\nhighp mat4 cc_matProj;\nhighp mat4 cc_matProjInv;\nhighp mat4 cc_matViewProj;\nhighp mat4 cc_matViewProjInv;\nhighp vec4 cc_cameraPos;\nmediump vec4 cc_screenScale;\nmediump vec4 cc_exposure;\nmediump vec4 cc_mainLitDir;\nmediump vec4 cc_mainLitColor;\nmediump vec4 cc_ambientSky;\nmediump vec4 cc_ambientGround;\nmediump vec4 cc_fogColor;\nmediump vec4 cc_fogBase;\nmediump vec4 cc_fogAdd;\nmediump vec4 cc_nearFar;\nmediump vec4 cc_viewPort;\n};\nlayout(std140) uniform CCLocal {\nhighp mat4 cc_matWorld;\nhighp mat4 cc_matWorldIT;\nhighp vec4 cc_lightingMapUVParam;\n};\nvec4 quaternionFromAxis (vec3 xAxis,vec3 yAxis,vec3 zAxis){\nmat3 m = mat3(xAxis,yAxis,zAxis);\nfloat trace = m[0][0] + m[1][1] + m[2][2];\nvec4 quat;\nif (trace > 0.) {\nfloat s = 0.5 / sqrt(trace + 1.0);\nquat.w = 0.25 / s;\nquat.x = (m[2][1] - m[1][2]) * s;\nquat.y = (m[0][2] - m[2][0]) * s;\nquat.z = (m[1][0] - m[0][1]) * s;\n} else if ((m[0][0] > m[1][1]) && (m[0][0] > m[2][2])) {\nfloat s = 2.0 * sqrt(1.0 + m[0][0] - m[1][1] - m[2][2]);\nquat.w = (m[2][1] - m[1][2]) / s;\nquat.x = 0.25 * s;\nquat.y = (m[0][1] + m[1][0]) / s;\nquat.z = (m[0][2] + m[2][0]) / s;\n} else if (m[1][1] > m[2][2]) {\nfloat s = 2.0 * sqrt(1.0 + m[1][1] - m[0][0] - m[2][2]);\nquat.w = (m[0][2] - m[2][0]) / s;\nquat.x = (m[0][1] + m[1][0]) / s;\nquat.y = 0.25 * s;\nquat.z = (m[1][2] + m[2][1]) / s;\n} else {\nfloat s = 2.0 * sqrt(1.0 + m[2][2] - m[0][0] - m[1][1]);\nquat.w = (m[1][0] - m[0][1]) / s;\nquat.x = (m[0][2] + m[2][0]) / s;\nquat.y = (m[1][2] + m[2][1]) / s;\nquat.z = 0.25 * s;\n}\nfloat len = quat.x * quat.x + quat.y * quat.y + quat.z * quat.z + quat.w * quat.w;\nif (len > 0.) {\nlen = 1. / sqrt(len);\nquat.x = quat.x * len;\nquat.y = quat.y * len;\nquat.z = quat.z * len;\nquat.w = quat.w * len;\n}\nreturn quat;\n}\nvec4 quaternionFromEuler (vec3 angle){\nfloat x = angle.x / 2.;\nfloat y = angle.y / 2.;\nfloat z = angle.z / 2.;\nfloat sx = sin(x);\nfloat cx = cos(x);\nfloat sy = sin(y);\nfloat cy = cos(y);\nfloat sz = sin(z);\nfloat cz = cos(z);\nvec4 quat = vec4(0);\nquat.x = sx * cy * cz + cx * sy * sz;\nquat.y = cx * sy * cz + sx * cy * sz;\nquat.z = cx * cy * sz - sx * sy * cz;\nquat.w = cx * cy * cz - sx * sy * sz;\nreturn quat;\n}\nvec4 quatMultiply (vec4 a, vec4 b){\nvec4 quat;\nquat.x = a.x * b.w + a.w * b.x + a.y * b.z - a.z * b.y;\nquat.y = a.y * b.w + a.w * b.y + a.z * b.x - a.x * b.z;\nquat.z = a.z * b.w + a.w * b.z + a.x * b.y - a.y * b.x;\nquat.w = a.w * b.w - a.x * b.x - a.y * b.y - a.z * b.z;\nreturn quat;\n}\nvoid rotateVecFromQuat (inout vec3 v, vec4 q){\nfloat ix = q.w * v.x + q.y * v.z - q.z * v.y;\nfloat iy = q.w * v.y + q.z * v.x - q.x * v.z;\nfloat iz = q.w * v.z + q.x * v.y - q.y * v.x;\nfloat iw = -q.x * v.x - q.y * v.y - q.z * v.z;\nv.x = ix * q.w + iw * -q.x + iy * -q.z - iz * -q.y;\nv.y = iy * q.w + iw * -q.y + iz * -q.x - ix * -q.z;\nv.z = iz * q.w + iw * -q.z + ix * -q.y - iy * -q.x;\n}\nvec3 rotateInLocalSpace (vec3 pos, vec3 xAxis, vec3 yAxis, vec3 zAxis, vec4 q){\nvec4 viewQuat = quaternionFromAxis(xAxis, yAxis, zAxis);\nvec4 rotQuat = quatMultiply(viewQuat, q);\nrotateVecFromQuat(pos, rotQuat);\nreturn pos;\n}\nout mediump vec2 uv;\nout mediump vec4 color;\nvoid computeVertPos (inout vec4 pos, vec2 vertOffset, vec4 q, vec3 s\n, mat4 viewInv\n) {\nvec3 viewSpaceVert = vec3(vertOffset.x * s.x, vertOffset.y * s.y, 0.);\nvec3 camX = normalize(vec3(viewInv[0][0], viewInv[1][0], viewInv[2][0]));\nvec3 camY = normalize(vec3(viewInv[0][1], viewInv[1][1], viewInv[2][1]));\nvec3 camZ = normalize(vec3(viewInv[0][2], viewInv[1][2], viewInv[2][2]));\npos.xyz += rotateInLocalSpace(viewSpaceVert, camX, camY, camZ, q);\n}\nin vec3 a_position;\nin vec2 a_texCoord;\nin vec4 a_color;\nlayout(std140) uniform builtin {\nvec4 cc_size_rotation;\n};\nvec4 vs_main() {\nvec4 pos = vec4(a_position, 1);\npos = cc_matWorld * pos;\nvec2 vertOffset = a_texCoord.xy - 0.5;\ncomputeVertPos(pos, vertOffset, quaternionFromEuler(vec3(0., 0., cc_size_rotation.z)), vec3(cc_size_rotation.xy, 0.), cc_matViewInv);\npos = cc_matViewProj * pos;\nuv = a_texCoord.xy;\ncolor = a_color;\nreturn pos;\n}\nvoid main() { gl_Position = vs_main(); }", + "frag": "\nprecision mediump float;\nlayout(std140) uniform CCGlobal {\nhighp vec4 cc_time;\nmediump vec4 cc_screenSize;\nmediump vec4 cc_nativeSize;\n};\nlayout(std140) uniform CCCamera {\nhighp mat4 cc_matView;\nhighp mat4 cc_matViewInv;\nhighp mat4 cc_matProj;\nhighp mat4 cc_matProjInv;\nhighp mat4 cc_matViewProj;\nhighp mat4 cc_matViewProjInv;\nhighp vec4 cc_cameraPos;\nmediump vec4 cc_screenScale;\nmediump vec4 cc_exposure;\nmediump vec4 cc_mainLitDir;\nmediump vec4 cc_mainLitColor;\nmediump vec4 cc_ambientSky;\nmediump vec4 cc_ambientGround;\nmediump vec4 cc_fogColor;\nmediump vec4 cc_fogBase;\nmediump vec4 cc_fogAdd;\nmediump vec4 cc_nearFar;\nmediump vec4 cc_viewPort;\n};\nvec4 CCFragOutput (vec4 color) {\nreturn color;\n}\nin vec2 uv;\nin vec4 color;\nuniform sampler2D mainTexture;\nlayout(std140) uniform FragConstants {\nvec4 tintColor;\n};\nvec4 add () {\nvec4 col = 2.0 * color * tintColor * texture(mainTexture, uv);\nreturn CCFragOutput(col);\n}\nlayout(location = 0) out vec4 cc_FragColor;\nvoid main() { cc_FragColor = add(); }", + } + ], + [ + { + "vert": "\nprecision highp float;\nin vec3 a_position;\nvec4 vert () {\nvec4 pos = vec4(a_position, 1);\nreturn pos;\n}\nvoid main() { gl_Position = vert(); }", + "frag": "\nprecision highp float;\nvec4 frag () {\nvec4 o = vec4(1.0);\nreturn o;\n}\nlayout(location = 0) out vec4 cc_FragColor;\nvoid main() { cc_FragColor = frag(); }", + } + ], + [ + { + "vert": "\nprecision highp float;\nlayout(std140) uniform CCGlobal {\nhighp vec4 cc_time;\nmediump vec4 cc_screenSize;\nmediump vec4 cc_nativeSize;\n};\nlayout(std140) uniform CCCamera {\nhighp mat4 cc_matView;\nhighp mat4 cc_matViewInv;\nhighp mat4 cc_matProj;\nhighp mat4 cc_matProjInv;\nhighp mat4 cc_matViewProj;\nhighp mat4 cc_matViewProjInv;\nhighp vec4 cc_cameraPos;\nmediump vec4 cc_screenScale;\nmediump vec4 cc_exposure;\nmediump vec4 cc_mainLitDir;\nmediump vec4 cc_mainLitColor;\nmediump vec4 cc_ambientSky;\nmediump vec4 cc_ambientGround;\nmediump vec4 cc_fogColor;\nmediump vec4 cc_fogBase;\nmediump vec4 cc_fogAdd;\nmediump vec4 cc_nearFar;\nmediump vec4 cc_viewPort;\n};\nlayout(std140) uniform CCLocal {\nhighp mat4 cc_matWorld;\nhighp mat4 cc_matWorldIT;\nhighp vec4 cc_lightingMapUVParam;\n};\nin vec3 a_position;\nin vec4 a_color;\nout vec4 v_color;\nin float a_dist;\nout float v_dist;\nvec4 vert () {\nvec4 pos = vec4(a_position, 1);\npos = cc_matViewProj * cc_matWorld * pos;\nv_color = a_color;\nv_dist = a_dist;\nreturn pos;\n}\nvoid main() { gl_Position = vert(); }", + "frag": "\nprecision highp float;\nin vec4 v_color;\nin float v_dist;\nvec4 frag () {\nvec4 o = v_color;\nfloat aa = fwidth(v_dist);\nfloat alpha = 1. - smoothstep(-aa, 0., abs(v_dist) - 1.0);\no.rgb *= o.a;\no *= alpha;\nreturn o;\n}\nlayout(location = 0) out vec4 cc_FragColor;\nvoid main() { cc_FragColor = frag(); }", + } + ], + [ + { + "vert": "\nprecision highp float;\nlayout(std140) uniform CCGlobal {\nhighp vec4 cc_time;\nmediump vec4 cc_screenSize;\nmediump vec4 cc_nativeSize;\n};\nlayout(std140) uniform CCCamera {\nhighp mat4 cc_matView;\nhighp mat4 cc_matViewInv;\nhighp mat4 cc_matProj;\nhighp mat4 cc_matProjInv;\nhighp mat4 cc_matViewProj;\nhighp mat4 cc_matViewProjInv;\nhighp vec4 cc_cameraPos;\nmediump vec4 cc_screenScale;\nmediump vec4 cc_exposure;\nmediump vec4 cc_mainLitDir;\nmediump vec4 cc_mainLitColor;\nmediump vec4 cc_ambientSky;\nmediump vec4 cc_ambientGround;\nmediump vec4 cc_fogColor;\nmediump vec4 cc_fogBase;\nmediump vec4 cc_fogAdd;\nmediump vec4 cc_nearFar;\nmediump vec4 cc_viewPort;\n};\nlayout(std140) uniform CCWorldBound {\nhighp vec4 cc_worldBoundCenter;\nhighp vec4 cc_worldBoundHalfExtents;\n};\nin vec3 a_position;\nvec4 vert () {\nvec4 position;\nposition = vec4(a_position, 1.0);\nposition *= cc_worldBoundHalfExtents;\nposition += cc_worldBoundCenter;\nposition = cc_matViewProj * position;\nreturn position;\n}\nvoid main() { gl_Position = vert(); }", + "frag": "\nprecision mediump float;\nvec4 frag () {\nreturn vec4(1, 0, 0, 1);\n}\nlayout(location = 0) out vec4 cc_FragColor;\nvoid main() { cc_FragColor = frag(); }", + } + ], + [ + { + "vert": "\nprecision mediump float;\nvec4 quaternionFromAxis (vec3 xAxis,vec3 yAxis,vec3 zAxis){\nmat3 m = mat3(xAxis,yAxis,zAxis);\nfloat trace = m[0][0] + m[1][1] + m[2][2];\nvec4 quat;\nif (trace > 0.) {\nfloat s = 0.5 / sqrt(trace + 1.0);\nquat.w = 0.25 / s;\nquat.x = (m[2][1] - m[1][2]) * s;\nquat.y = (m[0][2] - m[2][0]) * s;\nquat.z = (m[1][0] - m[0][1]) * s;\n} else if ((m[0][0] > m[1][1]) && (m[0][0] > m[2][2])) {\nfloat s = 2.0 * sqrt(1.0 + m[0][0] - m[1][1] - m[2][2]);\nquat.w = (m[2][1] - m[1][2]) / s;\nquat.x = 0.25 * s;\nquat.y = (m[0][1] + m[1][0]) / s;\nquat.z = (m[0][2] + m[2][0]) / s;\n} else if (m[1][1] > m[2][2]) {\nfloat s = 2.0 * sqrt(1.0 + m[1][1] - m[0][0] - m[2][2]);\nquat.w = (m[0][2] - m[2][0]) / s;\nquat.x = (m[0][1] + m[1][0]) / s;\nquat.y = 0.25 * s;\nquat.z = (m[1][2] + m[2][1]) / s;\n} else {\nfloat s = 2.0 * sqrt(1.0 + m[2][2] - m[0][0] - m[1][1]);\nquat.w = (m[1][0] - m[0][1]) / s;\nquat.x = (m[0][2] + m[2][0]) / s;\nquat.y = (m[1][2] + m[2][1]) / s;\nquat.z = 0.25 * s;\n}\nfloat len = quat.x * quat.x + quat.y * quat.y + quat.z * quat.z + quat.w * quat.w;\nif (len > 0.) {\nlen = 1. / sqrt(len);\nquat.x = quat.x * len;\nquat.y = quat.y * len;\nquat.z = quat.z * len;\nquat.w = quat.w * len;\n}\nreturn quat;\n}\nvec4 quaternionFromEuler (vec3 angle){\nfloat x = angle.x / 2.;\nfloat y = angle.y / 2.;\nfloat z = angle.z / 2.;\nfloat sx = sin(x);\nfloat cx = cos(x);\nfloat sy = sin(y);\nfloat cy = cos(y);\nfloat sz = sin(z);\nfloat cz = cos(z);\nvec4 quat = vec4(0);\nquat.x = sx * cy * cz + cx * sy * sz;\nquat.y = cx * sy * cz + sx * cy * sz;\nquat.z = cx * cy * sz - sx * sy * cz;\nquat.w = cx * cy * cz - sx * sy * sz;\nreturn quat;\n}\nmat4 matrixFromRT (vec4 q, vec3 p){\nfloat x2 = q.x + q.x;\nfloat y2 = q.y + q.y;\nfloat z2 = q.z + q.z;\nfloat xx = q.x * x2;\nfloat xy = q.x * y2;\nfloat xz = q.x * z2;\nfloat yy = q.y * y2;\nfloat yz = q.y * z2;\nfloat zz = q.z * z2;\nfloat wx = q.w * x2;\nfloat wy = q.w * y2;\nfloat wz = q.w * z2;\nreturn mat4(\n1. - (yy + zz), xy + wz, xz - wy, 0,\nxy - wz, 1. - (xx + zz), yz + wx, 0,\nxz + wy, yz - wx, 1. - (xx + yy), 0,\np.x, p.y, p.z, 1\n);\n}\nmat4 matFromRTS (vec4 q, vec3 t, vec3 s){\nfloat x = q.x, y = q.y, z = q.z, w = q.w;\nfloat x2 = x + x;\nfloat y2 = y + y;\nfloat z2 = z + z;\nfloat xx = x * x2;\nfloat xy = x * y2;\nfloat xz = x * z2;\nfloat yy = y * y2;\nfloat yz = y * z2;\nfloat zz = z * z2;\nfloat wx = w * x2;\nfloat wy = w * y2;\nfloat wz = w * z2;\nfloat sx = s.x;\nfloat sy = s.y;\nfloat sz = s.z;\nreturn mat4((1. - (yy + zz)) * sx, (xy + wz) * sx, (xz - wy) * sx, 0,\n(xy - wz) * sy, (1. - (xx + zz)) * sy, (yz + wx) * sy, 0,\n(xz + wy) * sz, (yz - wx) * sz, (1. - (xx + yy)) * sz, 0,\nt.x, t.y, t.z, 1);\n}\nvec4 quatMultiply (vec4 a, vec4 b){\nvec4 quat;\nquat.x = a.x * b.w + a.w * b.x + a.y * b.z - a.z * b.y;\nquat.y = a.y * b.w + a.w * b.y + a.z * b.x - a.x * b.z;\nquat.z = a.z * b.w + a.w * b.z + a.x * b.y - a.y * b.x;\nquat.w = a.w * b.w - a.x * b.x - a.y * b.y - a.z * b.z;\nreturn quat;\n}\nvoid rotateVecFromQuat (inout vec3 v, vec4 q){\nfloat ix = q.w * v.x + q.y * v.z - q.z * v.y;\nfloat iy = q.w * v.y + q.z * v.x - q.x * v.z;\nfloat iz = q.w * v.z + q.x * v.y - q.y * v.x;\nfloat iw = -q.x * v.x - q.y * v.y - q.z * v.z;\nv.x = ix * q.w + iw * -q.x + iy * -q.z - iz * -q.y;\nv.y = iy * q.w + iw * -q.y + iz * -q.x - ix * -q.z;\nv.z = iz * q.w + iw * -q.z + ix * -q.y - iy * -q.x;\n}\nvec3 rotateInLocalSpace (vec3 pos, vec3 xAxis, vec3 yAxis, vec3 zAxis, vec4 q){\nvec4 viewQuat = quaternionFromAxis(xAxis, yAxis, zAxis);\nvec4 rotQuat = quatMultiply(viewQuat, q);\nrotateVecFromQuat(pos, rotQuat);\nreturn pos;\n}\nmat3 quatToMat3(vec4 q) {\nvec3 m0 = vec3(\n1.0 - 2.0 * q.y * q.y - 2.0 * q.z * q.z,\n2.0 * q.x * q.y + 2.0 * q.w * q.z,\n2.0 * q.x * q.z - 2.0 * q.w * q.y);\nvec3 m1 = vec3(\n2.0 * q.x * q.y - 2.0 * q.w * q.z,\n1.0 - 2.0 * q.x * q.x - 2.0 * q.z * q.z,\n2.0 * q.y * q.z + 2.0 * q.w * q.x);\nvec3 m2 = vec3(\n2.0 * q.x * q.z + 2.0 * q.w * q.y,\n2.0 * q.y * q.z - 2.0 * q.w * q.x,\n1.0 - 2.0 * q.x * q.x - 2.0 * q.y * q.y);\nreturn mat3(m0, m1, m2);\n}\nvec4 mat3ToQuat(mat3 mat) {\nfloat tr = mat[0][0] + mat[1][1] + mat[2][2];\nfloat qw, qx, qy, qz;\nif (tr > 0.0) {\nfloat S = sqrt(tr + 1.0) * 2.0;\nfloat invS = 1.0 / S;\nqw = 0.25 * S;\nqx = (mat[1][2] - mat[2][1]) * invS;\nqy = (mat[2][0] - mat[0][2]) * invS;\nqz = (mat[0][1] - mat[1][0]) * invS;\n} else if ((mat[0][0] > mat[1][1])&&(mat[0][0] > mat[2][2])) {\nfloat S = sqrt(1.0 + mat[0][0] - mat[1][1] - mat[2][2]) * 2.0;\nfloat invS = 1.0 / S;\nqw = (mat[1][2] - mat[2][1]) * invS;\nqx = 0.25 * S;\nqy = (mat[1][0] + mat[0][1]) * invS;\nqz = (mat[2][0] + mat[0][2]) * invS;\n} else if (mat[1][1] > mat[2][2]) {\nfloat S = sqrt(1.0 + mat[1][1] - mat[0][0] - mat[2][2]) * 2.0;\nfloat invS = 1.0 / S;\nqw = (mat[2][0] - mat[0][2]) * invS;\nqx = (mat[1][0] + mat[0][1]) * invS;\nqy = 0.25 * S;\nqz = (mat[2][1] + mat[1][2]) * invS;\n} else {\nfloat S = sqrt(1.0 + mat[2][2] - mat[0][0] - mat[1][1]) * 2.0;\nfloat invS = 1.0 / S;\nqw = (mat[0][1] - mat[1][0]) * invS;\nqx = (mat[2][0] + mat[0][2]) * invS;\nqy = (mat[2][1] + mat[1][2]) * invS;\nqz = 0.25 * S;\n}\nreturn vec4(qx, qy, qz, qw);\n}\nvec4 eulerToQuat(vec3 euler) {\nvec3 er = euler * 0.5;\nfloat x = er.x, y = er.y, z = er.z;\nfloat sx = sin(x);\nfloat cx = cos(x);\nfloat sy = sin(y);\nfloat cy = cos(y);\nfloat sz = sin(z);\nfloat cz = cos(z);\nvec4 quat;\nquat.x = sx * cy * cz + cx * sy * sz;\nquat.y = cx * sy * cz + sx * cy * sz;\nquat.z = cx * cy * sz - sx * sy * cz;\nquat.w = cx * cy * cz - sx * sy * sz;\nreturn quat;\n}\nlayout(std140) uniform Constants {\nvec4 mainTiling_Offset;\nvec4 frameTile_velLenScale;\nvec4 scale;\nvec4 nodeRotation;\n};\nlayout(std140) uniform CCGlobal {\nhighp vec4 cc_time;\nmediump vec4 cc_screenSize;\nmediump vec4 cc_nativeSize;\n};\nlayout(std140) uniform CCCamera {\nhighp mat4 cc_matView;\nhighp mat4 cc_matViewInv;\nhighp mat4 cc_matProj;\nhighp mat4 cc_matProjInv;\nhighp mat4 cc_matViewProj;\nhighp mat4 cc_matViewProjInv;\nhighp vec4 cc_cameraPos;\nmediump vec4 cc_screenScale;\nmediump vec4 cc_exposure;\nmediump vec4 cc_mainLitDir;\nmediump vec4 cc_mainLitColor;\nmediump vec4 cc_ambientSky;\nmediump vec4 cc_ambientGround;\nmediump vec4 cc_fogColor;\nmediump vec4 cc_fogBase;\nmediump vec4 cc_fogAdd;\nmediump vec4 cc_nearFar;\nmediump vec4 cc_viewPort;\n};\nlayout(std140) uniform CCLocal {\nhighp mat4 cc_matWorld;\nhighp mat4 cc_matWorldIT;\nhighp vec4 cc_lightingMapUVParam;\n};\nout mediump vec2 uv;\nout mediump vec4 color;\nvoid computeVertPos (inout vec4 pos, vec2 vertOffset, vec4 q, vec3 s\n#if CC_RENDER_MODE == 0 || CC_RENDER_MODE == 3\n, mat4 viewInv\n#endif\n#if CC_RENDER_MODE == 1\n, vec3 eye\n, vec4 velocity\n, float velocityScale\n, float lengthScale\n, float xIndex\n#endif\n) {\n#if CC_RENDER_MODE == 0\nvec3 viewSpaceVert = vec3(vertOffset.x * s.x, vertOffset.y * s.y, 0.);\nvec3 camX = normalize(vec3(viewInv[0][0], viewInv[1][0], viewInv[2][0]));\nvec3 camY = normalize(vec3(viewInv[0][1], viewInv[1][1], viewInv[2][1]));\nvec3 camZ = normalize(vec3(viewInv[0][2], viewInv[1][2], viewInv[2][2]));\npos.xyz += rotateInLocalSpace(viewSpaceVert, camX, camY, camZ, q);\n#elif CC_RENDER_MODE == 1\nvec3 camRight = normalize(cross(pos.xyz - eye, velocity.xyz)) * s.x;\nvec3 camUp = velocity.xyz * velocityScale + normalize(velocity.xyz) * lengthScale * s.y;\npos.xyz += (camRight * abs(vertOffset.x) * sign(vertOffset.y)) - camUp * xIndex;\n#elif CC_RENDER_MODE == 2\nvec3 viewSpaceVert = vec3(vertOffset.x * s.x, vertOffset.y * s.y, 0.);\nvec3 camX = vec3(1, 0, 0);\nvec3 camY = vec3(0, 0, -1);\npos.xyz += rotateInLocalSpace(viewSpaceVert, camX, camY, cross(camX, camY), q);\n#elif CC_RENDER_MODE == 3\nvec3 viewSpaceVert = vec3(vertOffset.x * s.x, vertOffset.y * s.y, 0.);\nrotateVecFromQuat(viewSpaceVert, q);\nvec3 camX = normalize(vec3(cc_matView[0][0], cc_matView[1][0], cc_matView[2][0]));\nvec3 camY = vec3(0, 1, 0);\nvec3 offset = camX * viewSpaceVert.x + camY * viewSpaceVert.y;\npos.xyz += offset;\n#else\npos.x += vertOffset.x;\npos.y += vertOffset.y;\n#endif\n}\nvec2 computeUV (float frameIndex, vec2 vertIndex, vec2 frameTile){\nvec2 aniUV = vec2(0, floor(frameIndex * frameTile.y));\naniUV.x = floor(frameIndex * frameTile.x * frameTile.y - aniUV.y * frameTile.x);\n#if CC_RENDER_MODE != 4\nvertIndex.y = 1. - vertIndex.y;\n#endif\nreturn (aniUV.xy + vertIndex) / vec2(frameTile.x, frameTile.y);\n}\nlayout(std140) uniform SampleConstants {\nvec4 u_sampleInfo;\n};\nlayout(std140) uniform TickConstants {\nvec4 u_worldRot;\nvec4 u_timeDelta;\n};\nin vec4 a_position_starttime;\nin vec4 a_size_uv;\nin vec4 a_rotation_uv;\nin vec4 a_color;\nin vec4 a_dir_life;\nin float a_rndSeed;\n#if CC_RENDER_MODE == 4\nin vec3 a_texCoord;\nin vec3 a_texCoord3;\nin vec3 a_normal;\nin vec4 a_color1;\n#endif\nvec3 unpackCurveData (sampler2D tex, vec2 coord) {\nvec4 a = texture(tex, coord);\nvec4 b = texture(tex, coord + u_sampleInfo.y);\nfloat c = fract(coord.x * u_sampleInfo.x);\nreturn mix(a.xyz, b.xyz, c);\n}\nvec3 unpackCurveData (sampler2D tex, vec2 coord, out float w) {\nvec4 a = texture(tex, coord);\nvec4 b = texture(tex, coord + u_sampleInfo.y);\nfloat c = fract(coord.x * u_sampleInfo.x);\nw = mix(a.w, b.w, c);\nreturn mix(a.xyz, b.xyz, c);\n}\nfloat pseudoRandom(float x) {\nfloat o = x;\nx = mod(x - 1.0, 2.0) - 1.0;\nfloat freqVar = 10.16640753482;\nfloat y = sin(freqVar * floor(o * 0.5 - 0.5));\nfloat v = max(0.0, 1.0-abs(x));\nv *= 0.7071067812;\nv = y < 0.0 ? -v : v;\nreturn v;\n}\n#if COLOR_OVER_TIME_MODULE_ENABLE\nuniform sampler2D color_over_time_tex0;\nlayout(std140) uniform ColorConstant {\nint u_color_mode;\n};\n#endif\n#if ROTATION_OVER_TIME_MODULE_ENABLE\nuniform sampler2D rotation_over_time_tex0;\nlayout(std140) uniform RotationConstant {\nint u_rotation_mode;\n};\n#endif\n#if SIZE_OVER_TIME_MODULE_ENABLE\nuniform sampler2D size_over_time_tex0;\nlayout(std140) uniform SizeConstant {\nint u_size_mode;\n};\n#endif\n#if FORCE_OVER_TIME_MODULE_ENABLE\nuniform sampler2D force_over_time_tex0;\nlayout(std140) uniform ForceConstant {\nint u_force_mode;\nint u_force_space;\n};\n#endif\n#if VELOCITY_OVER_TIME_MODULE_ENABLE\nuniform sampler2D velocity_over_time_tex0;\nlayout(std140) uniform VelocityConstant {\nint u_velocity_mode;\nint u_velocity_space;\n};\n#endif\n#if TEXTURE_ANIMATION_MODULE_ENABLE\nuniform sampler2D texture_animation_tex0;\nlayout(std140) uniform AnimationConstant {\nvec4 u_anim_info;\n};\n#endif\nfloat repeat (float t, float length) {\nreturn t - floor(t / length) * length;\n}\nvec4 rotateQuat (vec4 p, vec4 q) {\nvec3 iv = cross(q.xyz, p.xyz) + q.w * p.xyz;\nvec3 res = p.xyz + 2.0 * cross(q.xyz, iv);\nreturn vec4(res.xyz, p.w);\n}\nvec4 gpvs_main () {\nfloat activeTime = u_timeDelta.x - a_position_starttime.w;\nfloat normalizedTime = clamp(activeTime / a_dir_life.w, 0.0, 1.0);\nvec2 timeCoord0 = vec2(normalizedTime, 0.);\nvec2 timeCoord1 = vec2(normalizedTime, 1.);\n#if CC_RENDER_MODE == 4\nvec2 vertIdx = vec2(a_texCoord.x, a_texCoord.y);\n#else\nvec2 vertIdx = vec2(a_size_uv.w, a_rotation_uv.w);\n#endif\nvec4 velocity = vec4(a_dir_life.xyz, 0.);\nvec4 pos = vec4(a_position_starttime.xyz, 1.);\nvec3 size = a_size_uv.xyz;\n#if SIZE_OVER_TIME_MODULE_ENABLE\nif (u_size_mode == 1) {\nsize *= unpackCurveData(size_over_time_tex0, timeCoord0);\n} else {\nvec3 size_0 = unpackCurveData(size_over_time_tex0, timeCoord0);\nvec3 size_1 = unpackCurveData(size_over_time_tex0, timeCoord1);\nfloat factor_s = pseudoRandom(a_rndSeed + 39825.);\nsize *= mix(size_0, size_1, factor_s);\n}\n#endif\nvec3 compScale = scale.xyz * size;\n#if FORCE_OVER_TIME_MODULE_ENABLE\nvec3 forceAnim = vec3(0.);\nif (u_force_mode == 1) {\nforceAnim = unpackCurveData(force_over_time_tex0, timeCoord0);\n} else {\nvec3 force_0 = unpackCurveData(force_over_time_tex0, timeCoord0);\nvec3 force_1 = unpackCurveData(force_over_time_tex0, timeCoord1);\nfloat factor_f = pseudoRandom(a_rndSeed + 212165.);\nforceAnim = mix(force_0, force_1, factor_f);\n}\nvec4 forceTrack = vec4(forceAnim, 0.);\nif (u_force_space == 0) {\nforceTrack = rotateQuat(forceTrack, u_worldRot);\n}\nvelocity.xyz += forceTrack.xyz;\n#endif\n#if VELOCITY_OVER_TIME_MODULE_ENABLE\nfloat speedModifier0 = 1.;\nfloat speedModifier1 = 1.;\nvec3 velocityAnim = vec3(0.);\nif (u_velocity_mode == 1) {\nvelocityAnim = unpackCurveData(velocity_over_time_tex0, timeCoord0, speedModifier0);\n} else {\nvec3 vectory_0 = unpackCurveData(velocity_over_time_tex0, timeCoord0, speedModifier0);\nvec3 vectory_1 = unpackCurveData(velocity_over_time_tex0, timeCoord1, speedModifier1);\nfloat factor_v = pseudoRandom(a_rndSeed + 197866.);\nvelocityAnim = mix(vectory_0, vectory_1, factor_v);\nspeedModifier0 = mix(speedModifier0, speedModifier1, factor_v);\n}\nvec4 velocityTrack = vec4(velocityAnim, 0.);\nif (u_velocity_space == 0) {\nvelocityTrack = rotateQuat(velocityTrack, u_worldRot);\n}\nvelocity.xyz += velocityTrack.xyz;\nvelocity.xyz *= speedModifier0;\n#endif\npos.xyz += velocity.xyz * normalizedTime * a_dir_life.w;\n#if !CC_USE_WORLD_SPACE\npos = cc_matWorld * pos;\n#if CC_RENDER_MODE == 1\nvelocity = rotateQuat(velocity, u_worldRot);\n#endif\n#endif\nvec3 startRotation = a_rotation_uv.xyz;\n#if CC_RENDER_MODE != 4\n#if CC_RENDER_MODE == 0\nvec3 rotEuler = startRotation.xyz;\n#elif CC_RENDER_MODE == 1\nvec3 rotEuler = vec3(0.);\n#else\nvec3 rotEuler = vec3(0., 0., startRotation.z);\n#endif\nvec4 rot = quaternionFromEuler(rotEuler);\n#else\nvec4 rot = quaternionFromEuler(startRotation);\n#endif\n#if ROTATION_OVER_TIME_MODULE_ENABLE\nif (u_rotation_mode == 1) {\nvec3 euler = unpackCurveData(rotation_over_time_tex0, timeCoord0) * normalizedTime * a_dir_life.w;\nvec4 quat = eulerToQuat(euler);\nmat3 mLocal = quatToMat3(quat);\nmat3 mStart = quatToMat3(rot);\nrot = mat3ToQuat(mStart * mLocal);\n} else {\nvec3 rotation_0 = unpackCurveData(rotation_over_time_tex0, timeCoord0);\nvec3 rotation_1 = unpackCurveData(rotation_over_time_tex0, timeCoord1);\nfloat factor_r = pseudoRandom(a_rndSeed + 125292.);\nvec3 euler = mix(rotation_0, rotation_1, factor_r) * normalizedTime * a_dir_life.w;\n#if CC_RENDER_MODE == 3 || CC_RENDER_MODE == 2\neuler = vec3(0.0, 0.0, euler.z);\n#endif\nvec4 quat = eulerToQuat(euler);\nmat3 mLocal = quatToMat3(quat);\nmat3 mStart = quatToMat3(rot);\nrot = mat3ToQuat(mStart * mLocal);\n}\n#endif\n#if COLOR_OVER_TIME_MODULE_ENABLE\nif (u_color_mode == 1) {\ncolor = a_color * texture(color_over_time_tex0, timeCoord0);\n} else {\nvec4 color_0 = texture(color_over_time_tex0, timeCoord0);\nvec4 color_1 = texture(color_over_time_tex0, timeCoord1);\nfloat factor_c = pseudoRandom(a_rndSeed + 91041.);\ncolor = a_color * mix(color_0, color_1, factor_c);\n}\n#else\ncolor = a_color;\n#endif\n#if CC_RENDER_MODE != 4\nvec2 cornerOffset = vec2((vertIdx - 0.5));\n#if CC_RENDER_MODE == 1\nrot = vec4(0.0, 0.0, 0.0, 1.0);\n#endif\ncomputeVertPos(pos, cornerOffset, rot, compScale\n#if CC_RENDER_MODE == 0 || CC_RENDER_MODE == 3\n, cc_matViewInv\n#endif\n#if CC_RENDER_MODE == 1\n, cc_cameraPos.xyz\n, velocity\n, frameTile_velLenScale.z\n, frameTile_velLenScale.w\n, a_size_uv.w\n#endif\n);\n#else\nmat3 rotMat = quatToMat3(rot);\nmat3 nodeMat = quatToMat3(nodeRotation);\nrotMat = nodeMat * rotMat;\nrot = mat3ToQuat(rotMat);\nmat4 xformNoScale = matrixFromRT(rot, pos.xyz);\nmat4 xform = matFromRTS(rot, pos.xyz, compScale);\npos = xform * vec4(a_texCoord3, 1);\nvec4 normal = xformNoScale * vec4(a_normal, 0);\ncolor *= a_color1;\n#endif\npos = cc_matViewProj * pos;\nfloat frameIndex = 0.;\n#if TEXTURE_ANIMATION_MODULE_ENABLE\nfloat startFrame = 0.;\nvec3 frameInfo = vec3(0.);\nif (int(u_anim_info.x) == 1) {\nframeInfo = unpackCurveData(texture_animation_tex0, timeCoord0);\n} else {\nvec3 frameInfo0 = unpackCurveData(texture_animation_tex0, timeCoord0);\nvec3 frameInfo1 = unpackCurveData(texture_animation_tex0, timeCoord1);\nfloat factor_t = pseudoRandom(a_rndSeed + 90794.);\nframeInfo = mix(frameInfo0, frameInfo1, factor_t);\n}\nstartFrame = frameInfo.x / u_anim_info.y;\nframeIndex = repeat(u_anim_info.z * (frameInfo.y + startFrame), 1.);\n#endif\nuv = computeUV(frameIndex, vertIdx, frameTile_velLenScale.xy) * mainTiling_Offset.xy + mainTiling_Offset.zw;\nreturn pos;\n}\nvoid main() { gl_Position = gpvs_main(); }", + "frag": "\nprecision mediump float;\nlayout(std140) uniform CCGlobal {\nhighp vec4 cc_time;\nmediump vec4 cc_screenSize;\nmediump vec4 cc_nativeSize;\n};\nlayout(std140) uniform CCCamera {\nhighp mat4 cc_matView;\nhighp mat4 cc_matViewInv;\nhighp mat4 cc_matProj;\nhighp mat4 cc_matProjInv;\nhighp mat4 cc_matViewProj;\nhighp mat4 cc_matViewProjInv;\nhighp vec4 cc_cameraPos;\nmediump vec4 cc_screenScale;\nmediump vec4 cc_exposure;\nmediump vec4 cc_mainLitDir;\nmediump vec4 cc_mainLitColor;\nmediump vec4 cc_ambientSky;\nmediump vec4 cc_ambientGround;\nmediump vec4 cc_fogColor;\nmediump vec4 cc_fogBase;\nmediump vec4 cc_fogAdd;\nmediump vec4 cc_nearFar;\nmediump vec4 cc_viewPort;\n};\nvec4 CCFragOutput (vec4 color) {\nreturn color;\n}\nin vec2 uv;\nin vec4 color;\nuniform sampler2D mainTexture;\nlayout(std140) uniform FragConstants {\nvec4 tintColor;\n};\nvec4 add () {\nvec4 col = 2.0 * color * tintColor * texture(mainTexture, uv);\nreturn CCFragOutput(col);\n}\nlayout(location = 0) out vec4 cc_FragColor;\nvoid main() { cc_FragColor = add(); }", + } + ], + [ + { + "vert": "\nprecision mediump float;\nlayout(std140) uniform Constants {\nvec4 mainTiling_Offset;\nvec4 frameTile_velLenScale;\nvec4 scale;\nvec4 nodeRotation;\n};\nlayout(std140) uniform CCGlobal {\nhighp vec4 cc_time;\nmediump vec4 cc_screenSize;\nmediump vec4 cc_nativeSize;\n};\nlayout(std140) uniform CCCamera {\nhighp mat4 cc_matView;\nhighp mat4 cc_matViewInv;\nhighp mat4 cc_matProj;\nhighp mat4 cc_matProjInv;\nhighp mat4 cc_matViewProj;\nhighp mat4 cc_matViewProjInv;\nhighp vec4 cc_cameraPos;\nmediump vec4 cc_screenScale;\nmediump vec4 cc_exposure;\nmediump vec4 cc_mainLitDir;\nmediump vec4 cc_mainLitColor;\nmediump vec4 cc_ambientSky;\nmediump vec4 cc_ambientGround;\nmediump vec4 cc_fogColor;\nmediump vec4 cc_fogBase;\nmediump vec4 cc_fogAdd;\nmediump vec4 cc_nearFar;\nmediump vec4 cc_viewPort;\n};\nlayout(std140) uniform CCLocal {\nhighp mat4 cc_matWorld;\nhighp mat4 cc_matWorldIT;\nhighp vec4 cc_lightingMapUVParam;\n};\nout mediump vec2 uv;\nout mediump vec4 color;\nin vec3 a_position;\nin vec4 a_texCoord;\nin vec3 a_texCoord1;\nin vec3 a_texCoord2;\nin vec4 a_color;\n#if CC_DRAW_WIRE_FRAME\nout vec3 vBarycentric;\n#endif\nvec4 vs_main() {\nhighp vec4 pos = vec4(a_position, 1);\nvec4 velocity = vec4(a_texCoord1.xyz, 0);\n#if !CC_USE_WORLD_SPACE\npos = cc_matWorld * pos;\nvelocity = cc_matWorld * velocity;\n#endif\nfloat vertOffset = (a_texCoord.x - 0.5) * a_texCoord.y;\nvec3 camUp = normalize(cross(pos.xyz - cc_cameraPos.xyz, velocity.xyz));\npos.xyz += camUp * vertOffset;\npos = cc_matViewProj * pos;\nuv = a_texCoord.zw * mainTiling_Offset.xy + mainTiling_Offset.zw;;\ncolor = a_color;\n#if CC_DRAW_WIRE_FRAME\nvBarycentric = a_texCoord2;\n#endif\nreturn pos;\n}\nvoid main() { gl_Position = vs_main(); }", + "frag": "\nprecision mediump float;\nlayout(std140) uniform CCGlobal {\nhighp vec4 cc_time;\nmediump vec4 cc_screenSize;\nmediump vec4 cc_nativeSize;\n};\nlayout(std140) uniform CCCamera {\nhighp mat4 cc_matView;\nhighp mat4 cc_matViewInv;\nhighp mat4 cc_matProj;\nhighp mat4 cc_matProjInv;\nhighp mat4 cc_matViewProj;\nhighp mat4 cc_matViewProjInv;\nhighp vec4 cc_cameraPos;\nmediump vec4 cc_screenScale;\nmediump vec4 cc_exposure;\nmediump vec4 cc_mainLitDir;\nmediump vec4 cc_mainLitColor;\nmediump vec4 cc_ambientSky;\nmediump vec4 cc_ambientGround;\nmediump vec4 cc_fogColor;\nmediump vec4 cc_fogBase;\nmediump vec4 cc_fogAdd;\nmediump vec4 cc_nearFar;\nmediump vec4 cc_viewPort;\n};\nvec4 CCFragOutput (vec4 color) {\nreturn color;\n}\nin vec2 uv;\nin vec4 color;\n#if CC_DRAW_WIRE_FRAME\nin vec3 vBarycentric;\n#endif\nuniform sampler2D mainTexture;\nlayout(std140) uniform FragConstants {\nvec4 tintColor;\n};\nvec4 add () {\nvec4 col = 2.0 * color * tintColor * texture(mainTexture, uv);\n#if CC_DRAW_WIRE_FRAME\nif (any(lessThan(vBarycentric, vec3(0.02)))) {\ncol = vec4(0., 1., 1., 1.);\n}\n#endif\nreturn CCFragOutput(col);\n}\nlayout(location = 0) out vec4 cc_FragColor;\nvoid main() { cc_FragColor = add(); }", + } + ], + [ + { + "vert": "\nprecision highp float;\nvec4 quaternionFromAxis (vec3 xAxis,vec3 yAxis,vec3 zAxis){\nmat3 m = mat3(xAxis,yAxis,zAxis);\nfloat trace = m[0][0] + m[1][1] + m[2][2];\nvec4 quat;\nif (trace > 0.) {\nfloat s = 0.5 / sqrt(trace + 1.0);\nquat.w = 0.25 / s;\nquat.x = (m[2][1] - m[1][2]) * s;\nquat.y = (m[0][2] - m[2][0]) * s;\nquat.z = (m[1][0] - m[0][1]) * s;\n} else if ((m[0][0] > m[1][1]) && (m[0][0] > m[2][2])) {\nfloat s = 2.0 * sqrt(1.0 + m[0][0] - m[1][1] - m[2][2]);\nquat.w = (m[2][1] - m[1][2]) / s;\nquat.x = 0.25 * s;\nquat.y = (m[0][1] + m[1][0]) / s;\nquat.z = (m[0][2] + m[2][0]) / s;\n} else if (m[1][1] > m[2][2]) {\nfloat s = 2.0 * sqrt(1.0 + m[1][1] - m[0][0] - m[2][2]);\nquat.w = (m[0][2] - m[2][0]) / s;\nquat.x = (m[0][1] + m[1][0]) / s;\nquat.y = 0.25 * s;\nquat.z = (m[1][2] + m[2][1]) / s;\n} else {\nfloat s = 2.0 * sqrt(1.0 + m[2][2] - m[0][0] - m[1][1]);\nquat.w = (m[1][0] - m[0][1]) / s;\nquat.x = (m[0][2] + m[2][0]) / s;\nquat.y = (m[1][2] + m[2][1]) / s;\nquat.z = 0.25 * s;\n}\nfloat len = quat.x * quat.x + quat.y * quat.y + quat.z * quat.z + quat.w * quat.w;\nif (len > 0.) {\nlen = 1. / sqrt(len);\nquat.x = quat.x * len;\nquat.y = quat.y * len;\nquat.z = quat.z * len;\nquat.w = quat.w * len;\n}\nreturn quat;\n}\nvec4 quaternionFromEuler (vec3 angle){\nfloat x = angle.x / 2.;\nfloat y = angle.y / 2.;\nfloat z = angle.z / 2.;\nfloat sx = sin(x);\nfloat cx = cos(x);\nfloat sy = sin(y);\nfloat cy = cos(y);\nfloat sz = sin(z);\nfloat cz = cos(z);\nvec4 quat = vec4(0);\nquat.x = sx * cy * cz + cx * sy * sz;\nquat.y = cx * sy * cz + sx * cy * sz;\nquat.z = cx * cy * sz - sx * sy * cz;\nquat.w = cx * cy * cz - sx * sy * sz;\nreturn quat;\n}\nmat4 matrixFromRT (vec4 q, vec3 p){\nfloat x2 = q.x + q.x;\nfloat y2 = q.y + q.y;\nfloat z2 = q.z + q.z;\nfloat xx = q.x * x2;\nfloat xy = q.x * y2;\nfloat xz = q.x * z2;\nfloat yy = q.y * y2;\nfloat yz = q.y * z2;\nfloat zz = q.z * z2;\nfloat wx = q.w * x2;\nfloat wy = q.w * y2;\nfloat wz = q.w * z2;\nreturn mat4(\n1. - (yy + zz), xy + wz, xz - wy, 0,\nxy - wz, 1. - (xx + zz), yz + wx, 0,\nxz + wy, yz - wx, 1. - (xx + yy), 0,\np.x, p.y, p.z, 1\n);\n}\nmat4 matFromRTS (vec4 q, vec3 t, vec3 s){\nfloat x = q.x, y = q.y, z = q.z, w = q.w;\nfloat x2 = x + x;\nfloat y2 = y + y;\nfloat z2 = z + z;\nfloat xx = x * x2;\nfloat xy = x * y2;\nfloat xz = x * z2;\nfloat yy = y * y2;\nfloat yz = y * z2;\nfloat zz = z * z2;\nfloat wx = w * x2;\nfloat wy = w * y2;\nfloat wz = w * z2;\nfloat sx = s.x;\nfloat sy = s.y;\nfloat sz = s.z;\nreturn mat4((1. - (yy + zz)) * sx, (xy + wz) * sx, (xz - wy) * sx, 0,\n(xy - wz) * sy, (1. - (xx + zz)) * sy, (yz + wx) * sy, 0,\n(xz + wy) * sz, (yz - wx) * sz, (1. - (xx + yy)) * sz, 0,\nt.x, t.y, t.z, 1);\n}\nvec4 quatMultiply (vec4 a, vec4 b){\nvec4 quat;\nquat.x = a.x * b.w + a.w * b.x + a.y * b.z - a.z * b.y;\nquat.y = a.y * b.w + a.w * b.y + a.z * b.x - a.x * b.z;\nquat.z = a.z * b.w + a.w * b.z + a.x * b.y - a.y * b.x;\nquat.w = a.w * b.w - a.x * b.x - a.y * b.y - a.z * b.z;\nreturn quat;\n}\nvoid rotateVecFromQuat (inout vec3 v, vec4 q){\nfloat ix = q.w * v.x + q.y * v.z - q.z * v.y;\nfloat iy = q.w * v.y + q.z * v.x - q.x * v.z;\nfloat iz = q.w * v.z + q.x * v.y - q.y * v.x;\nfloat iw = -q.x * v.x - q.y * v.y - q.z * v.z;\nv.x = ix * q.w + iw * -q.x + iy * -q.z - iz * -q.y;\nv.y = iy * q.w + iw * -q.y + iz * -q.x - ix * -q.z;\nv.z = iz * q.w + iw * -q.z + ix * -q.y - iy * -q.x;\n}\nvec3 rotateInLocalSpace (vec3 pos, vec3 xAxis, vec3 yAxis, vec3 zAxis, vec4 q){\nvec4 viewQuat = quaternionFromAxis(xAxis, yAxis, zAxis);\nvec4 rotQuat = quatMultiply(viewQuat, q);\nrotateVecFromQuat(pos, rotQuat);\nreturn pos;\n}\nmat3 quatToMat3(vec4 q) {\nvec3 m0 = vec3(\n1.0 - 2.0 * q.y * q.y - 2.0 * q.z * q.z,\n2.0 * q.x * q.y + 2.0 * q.w * q.z,\n2.0 * q.x * q.z - 2.0 * q.w * q.y);\nvec3 m1 = vec3(\n2.0 * q.x * q.y - 2.0 * q.w * q.z,\n1.0 - 2.0 * q.x * q.x - 2.0 * q.z * q.z,\n2.0 * q.y * q.z + 2.0 * q.w * q.x);\nvec3 m2 = vec3(\n2.0 * q.x * q.z + 2.0 * q.w * q.y,\n2.0 * q.y * q.z - 2.0 * q.w * q.x,\n1.0 - 2.0 * q.x * q.x - 2.0 * q.y * q.y);\nreturn mat3(m0, m1, m2);\n}\nvec4 mat3ToQuat(mat3 mat) {\nfloat tr = mat[0][0] + mat[1][1] + mat[2][2];\nfloat qw, qx, qy, qz;\nif (tr > 0.0) {\nfloat S = sqrt(tr + 1.0) * 2.0;\nfloat invS = 1.0 / S;\nqw = 0.25 * S;\nqx = (mat[1][2] - mat[2][1]) * invS;\nqy = (mat[2][0] - mat[0][2]) * invS;\nqz = (mat[0][1] - mat[1][0]) * invS;\n} else if ((mat[0][0] > mat[1][1])&&(mat[0][0] > mat[2][2])) {\nfloat S = sqrt(1.0 + mat[0][0] - mat[1][1] - mat[2][2]) * 2.0;\nfloat invS = 1.0 / S;\nqw = (mat[1][2] - mat[2][1]) * invS;\nqx = 0.25 * S;\nqy = (mat[1][0] + mat[0][1]) * invS;\nqz = (mat[2][0] + mat[0][2]) * invS;\n} else if (mat[1][1] > mat[2][2]) {\nfloat S = sqrt(1.0 + mat[1][1] - mat[0][0] - mat[2][2]) * 2.0;\nfloat invS = 1.0 / S;\nqw = (mat[2][0] - mat[0][2]) * invS;\nqx = (mat[1][0] + mat[0][1]) * invS;\nqy = 0.25 * S;\nqz = (mat[2][1] + mat[1][2]) * invS;\n} else {\nfloat S = sqrt(1.0 + mat[2][2] - mat[0][0] - mat[1][1]) * 2.0;\nfloat invS = 1.0 / S;\nqw = (mat[0][1] - mat[1][0]) * invS;\nqx = (mat[2][0] + mat[0][2]) * invS;\nqy = (mat[2][1] + mat[1][2]) * invS;\nqz = 0.25 * S;\n}\nreturn vec4(qx, qy, qz, qw);\n}\nlayout(std140) uniform Constants {\nvec4 mainTiling_Offset;\nvec4 frameTile_velLenScale;\nvec4 scale;\nvec4 nodeRotation;\n};\nlayout(std140) uniform CCGlobal {\nhighp vec4 cc_time;\nmediump vec4 cc_screenSize;\nmediump vec4 cc_nativeSize;\n};\nlayout(std140) uniform CCCamera {\nhighp mat4 cc_matView;\nhighp mat4 cc_matViewInv;\nhighp mat4 cc_matProj;\nhighp mat4 cc_matProjInv;\nhighp mat4 cc_matViewProj;\nhighp mat4 cc_matViewProjInv;\nhighp vec4 cc_cameraPos;\nmediump vec4 cc_screenScale;\nmediump vec4 cc_exposure;\nmediump vec4 cc_mainLitDir;\nmediump vec4 cc_mainLitColor;\nmediump vec4 cc_ambientSky;\nmediump vec4 cc_ambientGround;\nmediump vec4 cc_fogColor;\nmediump vec4 cc_fogBase;\nmediump vec4 cc_fogAdd;\nmediump vec4 cc_nearFar;\nmediump vec4 cc_viewPort;\n};\nlayout(std140) uniform CCLocal {\nhighp mat4 cc_matWorld;\nhighp mat4 cc_matWorldIT;\nhighp vec4 cc_lightingMapUVParam;\n};\nout mediump vec2 uv;\nout mediump vec4 color;\nvoid computeVertPos (inout vec4 pos, vec2 vertOffset, vec4 q, vec3 s\n#if CC_RENDER_MODE == 0 || CC_RENDER_MODE == 3\n, mat4 viewInv\n#endif\n#if CC_RENDER_MODE == 1\n, vec3 eye\n, vec4 velocity\n, float velocityScale\n, float lengthScale\n, float xIndex\n#endif\n) {\n#if CC_RENDER_MODE == 0\nvec3 viewSpaceVert = vec3(vertOffset.x * s.x, vertOffset.y * s.y, 0.);\nvec3 camX = normalize(vec3(viewInv[0][0], viewInv[1][0], viewInv[2][0]));\nvec3 camY = normalize(vec3(viewInv[0][1], viewInv[1][1], viewInv[2][1]));\nvec3 camZ = normalize(vec3(viewInv[0][2], viewInv[1][2], viewInv[2][2]));\npos.xyz += rotateInLocalSpace(viewSpaceVert, camX, camY, camZ, q);\n#elif CC_RENDER_MODE == 1\nvec3 camRight = normalize(cross(pos.xyz - eye, velocity.xyz)) * s.x;\nvec3 camUp = velocity.xyz * velocityScale + normalize(velocity.xyz) * lengthScale * s.y;\npos.xyz += (camRight * abs(vertOffset.x) * sign(vertOffset.y)) - camUp * xIndex;\n#elif CC_RENDER_MODE == 2\nvec3 viewSpaceVert = vec3(vertOffset.x * s.x, vertOffset.y * s.y, 0.);\nvec3 camX = vec3(1, 0, 0);\nvec3 camY = vec3(0, 0, -1);\npos.xyz += rotateInLocalSpace(viewSpaceVert, camX, camY, cross(camX, camY), q);\n#elif CC_RENDER_MODE == 3\nvec3 viewSpaceVert = vec3(vertOffset.x * s.x, vertOffset.y * s.y, 0.);\nrotateVecFromQuat(viewSpaceVert, q);\nvec3 camX = normalize(vec3(cc_matView[0][0], cc_matView[1][0], cc_matView[2][0]));\nvec3 camY = vec3(0, 1, 0);\nvec3 offset = camX * viewSpaceVert.x + camY * viewSpaceVert.y;\npos.xyz += offset;\n#else\npos.x += vertOffset.x;\npos.y += vertOffset.y;\n#endif\n}\nvec2 computeUV (float frameIndex, vec2 vertIndex, vec2 frameTile){\nvec2 aniUV = vec2(0, floor(frameIndex * frameTile.y));\naniUV.x = floor(frameIndex * frameTile.x * frameTile.y - aniUV.y * frameTile.x);\n#if CC_RENDER_MODE != 4\nvertIndex.y = 1. - vertIndex.y;\n#endif\nreturn (aniUV.xy + vertIndex) / vec2(frameTile.x, frameTile.y);\n}\nin vec3 a_position;\nin vec3 a_texCoord;\nin vec3 a_texCoord1;\nin vec3 a_texCoord2;\nin vec4 a_color;\n#if CC_RENDER_MODE == 1\nin vec3 a_color1;\n#endif\n#if CC_RENDER_MODE == 4\nin vec3 a_texCoord3;\nin vec3 a_normal;\nin vec4 a_color1;\n#endif\nvec4 lpvs_main () {\nvec3 compScale = scale.xyz * a_texCoord1;\nvec4 pos = vec4(a_position, 1);\n#if CC_RENDER_MODE == 1\nvec4 velocity = vec4(a_color1.xyz, 0);\n#endif\n#if !CC_USE_WORLD_SPACE\npos = cc_matWorld * pos;\n#if CC_RENDER_MODE == 1\nvelocity = cc_matWorld * velocity;\n#endif\n#endif\n#if ROTATION_OVER_TIME_MODULE_ENABLE\nvec3 rotTmp = a_texCoord2;\nfloat mulFactor = 1.0;\nif (rotTmp.x > 10.0 * 0.5) {\nrotTmp.x -= 10.0;\nmulFactor = -1.0;\n}\nvec4 rot = vec4(rotTmp, 0.0);\nrot.w = mulFactor * sqrt(1.0 - rot.x * rot.x - rot.y * rot.y - rot.z * rot.z);\n#else\n#if CC_RENDER_MODE != 4\n#if CC_RENDER_MODE == 0\nvec3 rotEuler = a_texCoord2;\n#elif CC_RENDER_MODE == 1\nvec3 rotEuler = vec3(0.);\n#else\nvec3 rotEuler = vec3(0., 0., a_texCoord2.z);\n#endif\nvec4 rot = quaternionFromEuler(rotEuler);\n#else\nvec4 rot = quaternionFromEuler(a_texCoord2);\n#endif\n#endif\n#if CC_RENDER_MODE != 4\nvec2 cornerOffset = vec2((a_texCoord.xy - 0.5));\n#if CC_RENDER_MODE == 0 || CC_RENDER_MODE == 3\ncomputeVertPos(pos, cornerOffset, rot, compScale, cc_matViewInv);\n#elif CC_RENDER_MODE == 1\ncomputeVertPos(pos, cornerOffset, rot, compScale, cc_cameraPos.xyz, velocity, frameTile_velLenScale.z, frameTile_velLenScale.w, a_texCoord.x);\n#elif 2\ncomputeVertPos(pos, cornerOffset, rot, compScale);\n#endif\ncolor = a_color;\n#else\nmat3 rotMat = quatToMat3(rot);\nmat3 nodeMat = quatToMat3(nodeRotation);\nrotMat = nodeMat * rotMat;\nrot = mat3ToQuat(rotMat);\nmat4 xformNoScale = matrixFromRT(rot, pos.xyz);\nmat4 xform = matFromRTS(rot, pos.xyz, compScale);\npos = xform * vec4(a_texCoord3, 1);\nvec4 normal = xformNoScale * vec4(a_normal, 0);\ncolor = a_color * a_color1;\n#endif\nuv = computeUV(a_texCoord.z, a_texCoord.xy, frameTile_velLenScale.xy) * mainTiling_Offset.xy + mainTiling_Offset.zw;\npos = cc_matViewProj * pos;\nreturn pos;\n}\nvoid main() { gl_Position = lpvs_main(); }", + "frag": "\nprecision mediump float;\nlayout(std140) uniform CCGlobal {\nhighp vec4 cc_time;\nmediump vec4 cc_screenSize;\nmediump vec4 cc_nativeSize;\n};\nlayout(std140) uniform CCCamera {\nhighp mat4 cc_matView;\nhighp mat4 cc_matViewInv;\nhighp mat4 cc_matProj;\nhighp mat4 cc_matProjInv;\nhighp mat4 cc_matViewProj;\nhighp mat4 cc_matViewProjInv;\nhighp vec4 cc_cameraPos;\nmediump vec4 cc_screenScale;\nmediump vec4 cc_exposure;\nmediump vec4 cc_mainLitDir;\nmediump vec4 cc_mainLitColor;\nmediump vec4 cc_ambientSky;\nmediump vec4 cc_ambientGround;\nmediump vec4 cc_fogColor;\nmediump vec4 cc_fogBase;\nmediump vec4 cc_fogAdd;\nmediump vec4 cc_nearFar;\nmediump vec4 cc_viewPort;\n};\nvec4 CCFragOutput (vec4 color) {\nreturn color;\n}\nin vec2 uv;\nin vec4 color;\nuniform sampler2D mainTexture;\nlayout(std140) uniform FragConstants {\nvec4 tintColor;\n};\nvec4 add () {\nvec4 col = 2.0 * color * tintColor * texture(mainTexture, uv);\nreturn CCFragOutput(col);\n}\nlayout(location = 0) out vec4 cc_FragColor;\nvoid main() { cc_FragColor = add(); }", + } + ], + [ + { + "vert": "\nprecision highp float;\nlayout(std140) uniform CCGlobal {\nhighp vec4 cc_time;\nmediump vec4 cc_screenSize;\nmediump vec4 cc_nativeSize;\n};\nlayout(std140) uniform CCCamera {\nhighp mat4 cc_matView;\nhighp mat4 cc_matViewInv;\nhighp mat4 cc_matProj;\nhighp mat4 cc_matProjInv;\nhighp mat4 cc_matViewProj;\nhighp mat4 cc_matViewProjInv;\nhighp vec4 cc_cameraPos;\nmediump vec4 cc_screenScale;\nmediump vec4 cc_exposure;\nmediump vec4 cc_mainLitDir;\nmediump vec4 cc_mainLitColor;\nmediump vec4 cc_ambientSky;\nmediump vec4 cc_ambientGround;\nmediump vec4 cc_fogColor;\nmediump vec4 cc_fogBase;\nmediump vec4 cc_fogAdd;\nmediump vec4 cc_nearFar;\nmediump vec4 cc_viewPort;\n};\n#if USE_LOCAL\nlayout(std140) uniform CCLocal {\nhighp mat4 cc_matWorld;\nhighp mat4 cc_matWorldIT;\nhighp vec4 cc_lightingMapUVParam;\n};\n#endif\nin vec3 a_position;\nin vec2 a_texCoord;\nin vec4 a_color;\nout vec4 v_light;\nout vec2 uv0;\n#if TWO_COLORED\nin vec4 a_color2;\nout vec4 v_dark;\n#endif\nvec4 vert () {\nvec4 pos = vec4(a_position, 1);\n#if USE_LOCAL\npos = cc_matWorld * pos;\n#endif\npos = cc_matViewProj * pos;\nuv0 = a_texCoord;\nv_light = a_color;\n#if TWO_COLORED\nv_dark = a_color2;\n#endif\nreturn pos;\n}\nvoid main() { gl_Position = vert(); }", + "frag": "\nprecision highp float;\n#if USE_ALPHA_TEST\nlayout(std140) uniform ALPHA_TEST_DATA {\nfloat alphaThreshold;\n};\n#endif\nvoid ALPHA_TEST (in vec4 color) {\n#if USE_ALPHA_TEST\nif (color.a < alphaThreshold) discard;\n#endif\n}\nvoid ALPHA_TEST (in float alpha) {\n#if USE_ALPHA_TEST\nif (alpha < alphaThreshold) discard;\n#endif\n}\nin vec4 v_light;\n#if TWO_COLORED\nin vec4 v_dark;\n#endif\nin vec2 uv0;\nuniform sampler2D cc_spriteTexture;\nvec4 frag () {\nvec4 o = vec4(1, 1, 1, 1);\n#if TWO_COLORED\nvec4 texColor = vec4(1, 1, 1, 1);\ntexColor *= texture(cc_spriteTexture, uv0);\no.a = texColor.a * v_light.a;\no.rgb = ((texColor.a - 1.0) * v_dark.a + 1.0 - texColor.rgb) * v_dark.rgb + texColor.rgb * v_light.rgb;\n#else\no *= texture(cc_spriteTexture, uv0);\no *= v_light;\n#endif\nALPHA_TEST(o);\nreturn o;\n}\nlayout(location = 0) out vec4 cc_FragColor;\nvoid main() { cc_FragColor = frag(); }", + } + ], + [ + { + "vert": "\nprecision highp float;\nstruct SpriteVertexData {\nvec4 position;\nvec4 color;\n};\nstruct SpriteFragmentData {\nvec2 uv;\n};\nlayout(std140) uniform CCGlobal {\nhighp vec4 cc_time;\nmediump vec4 cc_screenSize;\nmediump vec4 cc_nativeSize;\n};\nlayout(std140) uniform CCCamera {\nhighp mat4 cc_matView;\nhighp mat4 cc_matViewInv;\nhighp mat4 cc_matProj;\nhighp mat4 cc_matProjInv;\nhighp mat4 cc_matViewProj;\nhighp mat4 cc_matViewProjInv;\nhighp vec4 cc_cameraPos;\nmediump vec4 cc_screenScale;\nmediump vec4 cc_exposure;\nmediump vec4 cc_mainLitDir;\nmediump vec4 cc_mainLitColor;\nmediump vec4 cc_ambientSky;\nmediump vec4 cc_ambientGround;\nmediump vec4 cc_fogColor;\nmediump vec4 cc_fogBase;\nmediump vec4 cc_fogAdd;\nmediump vec4 cc_nearFar;\nmediump vec4 cc_viewPort;\n};\nin vec3 a_position;\nin vec2 a_texCoord;\nin float a_batch_id;\nout vec2 v_uv0;\nout float v_uvMode;\nout vec4 v_uvSizeOffset;\nout vec4 v_uvParams0;\nout vec4 v_uvParams1;\nstruct SpriteVertexInternalData {\nvec4 rotation;\nvec3 translation;\nvec3 scale;\nvec4 uvSizeOffset;\nfloat uvMode;\nvec4 uvParams;\nfloat filltype;\n};\nlayout(std140) uniform CCUILocal {\nvec4 cc_local_data[(CC_DEVICE_MAX_VERTEX_UNIFORM_VECTORS - CC_EFFECT_USED_VERTEX_UNIFORM_VECTORS) / 5 * 5];\n};\nvec3 VectorTransformQuat (vec3 v, vec4 q) {\nreturn v + 2.0 * cross(q.xyz, cross(q.xyz, v) + q.w * v);\n}\nvoid CCSpriteInput(out SpriteVertexData i0) {\nvec4 data0 = cc_local_data[int(a_batch_id) * 5];\nvec4 data1 = cc_local_data[int(a_batch_id) * 5 + 1];\nvec4 data2 = cc_local_data[int(a_batch_id) * 5 + 2];\nvec4 data3 = cc_local_data[int(a_batch_id) * 5 + 3];\nvec4 data4 = cc_local_data[int(a_batch_id) * 5 + 4];\nfloat rg = data0.w;\nfloat r = floor(rg);\nfloat ba = data2.z;\nfloat b = floor(ba);\nSpriteVertexInternalData i1;\ni1.rotation = data1;\ni1.translation = data0.xyz;\ni1.scale = vec3(data2.xy, 1.0);\ni1.uvSizeOffset = data3;\ni1.filltype = fract(data2.w) * 10.0;\ni1.uvMode = data2.w;\ni1.uvParams = data4;\ni0.position = vec4(VectorTransformQuat(a_position * i1.scale, i1.rotation) + i1.translation, 1.0);\ni0.color = vec4(r * (1.0 / 255.0), rg - r, b * (1.0 / 255.0), ba - b);\nvec2 uvWithRotation;\nif (i1.uvSizeOffset.x < 0.0) {\ni1.uvSizeOffset.x = abs(i1.uvSizeOffset.x);\nuvWithRotation = vec2(1.0 - a_texCoord.y, a_texCoord.x);\n} else {\nuvWithRotation = a_texCoord;\n}\nif (i1.uvMode >= 3.0) {\nv_uv0 = uvWithRotation;\nv_uvSizeOffset = i1.uvSizeOffset;\nv_uvParams0 = vec4(i1.uvParams.xy, i1.filltype, 0);\nif (i1.filltype >= 2.0) {\nv_uvParams1 = i1.uvParams;\n} else if (i1.filltype >= 1.0) {\nv_uvParams0 = vec4(1.0 - v_uvParams0.y, 1.0 - v_uvParams0.x, v_uvParams0.zw);\n}\n} else if (i1.uvMode >= 2.0) {\nv_uv0 = uvWithRotation * i1.uvParams.xy;\nv_uv0.y -= fract(i1.uvParams.y);\nv_uvSizeOffset = i1.uvSizeOffset;\n} else if (i1.uvMode >= 1.0) {\nv_uv0 = uvWithRotation;\nv_uvSizeOffset = i1.uvSizeOffset;\nvec4 params0 = fract(i1.uvParams);\nvec4 params1 = floor(i1.uvParams) / 2048.0;\nv_uvParams0 = vec4(params0.xy, params1.xy);\nv_uvParams1 = vec4(params0.zw, params1.zw);\n} else {\nv_uv0 = uvWithRotation * i1.uvSizeOffset.xy + i1.uvSizeOffset.zw;\n}\nv_uvMode = i1.uvMode;\n#if SAMPLE_FROM_RT\nv_uv0 = cc_cameraPos.w > 1.0 ? vec2(v_uv0.x, 1.0 - v_uv0.y) : v_uv0;\n#endif\n}\nout vec4 v_color;\nvec4 vert () {\nSpriteVertexData i;\nCCSpriteInput(i);\nv_color = i.color;\nvec4 pos = i.position;\n#if USE_PIXEL_ALIGNMENT\npos = cc_matView * pos;\npos.xyz = floor(pos.xyz);\npos = cc_matProj * pos;\n#else\npos = cc_matViewProj * pos;\n#endif\nreturn pos;\n}\nvoid main() { gl_Position = vert(); }", + "frag": "\nprecision highp float;\nstruct SpriteVertexData {\nvec4 position;\nvec4 color;\n};\nstruct SpriteFragmentData {\nvec2 uv;\n};\nvec4 CCSampleWithAlphaSeparated(sampler2D tex, vec2 uv) {\n#if CC_USE_EMBEDDED_ALPHA\nreturn vec4(texture(tex, uv).rgb, texture(tex, uv + vec2(0.0, 0.5)).r);\n#else\nreturn texture(tex, uv);\n#endif\n}\nin vec2 v_uv0;\nin float v_uvMode;\nin vec4 v_uvSizeOffset;\nin vec4 v_uvParams0;\nin vec4 v_uvParams1;\nvec2 evalSlicedUV(vec2 uv) {\nvec4 p0 = mix(vec4(0.0), v_uvParams0, step(v_uvParams0.xyxy, uv.xyxy));\np0 = mix( p0, v_uvParams1, step(v_uvParams1.xyxy, uv.xyxy));\nvec4 p1 = mix(vec4(1.0), v_uvParams1, step(uv.xyxy, v_uvParams1.xyxy));\np1 = mix( p1, v_uvParams0, step(uv.xyxy, v_uvParams0.xyxy));\nvec2 k = (p1.zw - p0.zw) / (p1.xy - p0.xy);\nvec2 b = (p1.xy * p0.zw - p0.xy * p1.zw) / (p1.xy - p0.xy);\nreturn k * uv + b;\n}\nfloat evalFilledUV(vec2 uv, float mode) {\nfloat alpha = 1.0;\nif (mode >= 2.0) {\nfloat start = v_uvParams1.x;\nfloat range = v_uvParams1.y;\nvec2 dir = uv - v_uvParams1.zw;\nfloat angle = -atan(dir.y, dir.x) * 0.3183098861838;\nif (range < 0.0) {\nangle += mix(0.0, -2.0, step(start, angle));\nalpha = step(start + range, angle);\n} else {\nangle += mix(0.0, 2.0, step(angle, start));\nalpha = step(angle, start + range);\n}\n} else if (mode >= 1.0) {\nif (uv.y >= v_uvParams0.x && uv.y <= v_uvParams0.y) {\nalpha = 1.0;\n} else {\nalpha = 0.0;\n}\n} else {\nif (uv.x >= v_uvParams0.x && uv.x <= v_uvParams0.y) {\nalpha = 1.0;\n} else {\nalpha = 0.0;\n}\n}\nreturn alpha;\n}\nvoid CCSpriteInput(out SpriteFragmentData i) {\n#if USE_TEXTURE\nif(v_uvMode >= 3.0) {\ni.uv = v_uv0 * v_uvSizeOffset.xy + v_uvSizeOffset.zw;\n} else if (v_uvMode >= 2.0) {\ni.uv = fract(v_uv0) * v_uvSizeOffset.xy + v_uvSizeOffset.zw;\n} else if (v_uvMode >= 1.0) {\ni.uv = evalSlicedUV(v_uv0) * v_uvSizeOffset.xy + v_uvSizeOffset.zw;\n} else {\ni.uv = v_uv0;\n}\n#endif\n}\nvec4 CCSpriteSample(sampler2D tex, vec2 uv) {\nvec4 o = CCSampleWithAlphaSeparated(tex, uv);\nif (v_uvMode >= 3.0) {\no.a *= evalFilledUV(v_uv0, v_uvParams0.z);\n}\nreturn o;\n}\nvec3 SRGBToLinear (vec3 gamma) {\nreturn gamma * gamma;\n}\nin vec4 v_color;\n#if USE_TEXTURE\nuniform sampler2D cc_spriteTexture;\n#endif\nvec4 frag () {\nSpriteFragmentData i;\nCCSpriteInput(i);\n#if USE_TEXTURE\nvec4 color = v_color * CCSpriteSample(cc_spriteTexture, i.uv);\n#else\nvec4 color = v_color;\n#endif\n#if IS_GRAY\ncolor.rgb = SRGBToLinear(color.rgb);\ncolor.rgb = vec3(dot(color.rgb, vec3(0.2126, 0.7152, 0.0722)));\ncolor.rgb = sqrt(color.rgb);\n#endif\nreturn color;\n}\nlayout(location = 0) out vec4 cc_FragColor;\nvoid main() { cc_FragColor = frag(); }", + } + ], + [ + { + "vert": "\nprecision highp float;\nlayout(std140) uniform CCGlobal {\nhighp vec4 cc_time;\nmediump vec4 cc_screenSize;\nmediump vec4 cc_nativeSize;\n};\nlayout(std140) uniform CCCamera {\nhighp mat4 cc_matView;\nhighp mat4 cc_matViewInv;\nhighp mat4 cc_matProj;\nhighp mat4 cc_matProjInv;\nhighp mat4 cc_matViewProj;\nhighp mat4 cc_matViewProjInv;\nhighp vec4 cc_cameraPos;\nmediump vec4 cc_screenScale;\nmediump vec4 cc_exposure;\nmediump vec4 cc_mainLitDir;\nmediump vec4 cc_mainLitColor;\nmediump vec4 cc_ambientSky;\nmediump vec4 cc_ambientGround;\nmediump vec4 cc_fogColor;\nmediump vec4 cc_fogBase;\nmediump vec4 cc_fogAdd;\nmediump vec4 cc_nearFar;\nmediump vec4 cc_viewPort;\n};\n#if USE_LOCAL\nlayout(std140) uniform CCLocal {\nhighp mat4 cc_matWorld;\nhighp mat4 cc_matWorldIT;\nhighp vec4 cc_lightingMapUVParam;\n};\n#endif\n#if SAMPLE_FROM_RT\n#endif\nin vec3 a_position;\nin vec2 a_texCoord;\nin vec4 a_color;\nout vec4 color;\nout vec2 uv0;\nvec4 vert () {\nvec4 pos = vec4(a_position, 1);\n#if USE_LOCAL\npos = cc_matWorld * pos;\n#endif\n#if USE_PIXEL_ALIGNMENT\npos = cc_matView * pos;\npos.xyz = floor(pos.xyz);\npos = cc_matProj * pos;\n#else\npos = cc_matViewProj * pos;\n#endif\nuv0 = a_texCoord;\n#if SAMPLE_FROM_RT\nuv0 = cc_cameraPos.w > 1.0 ? vec2(uv0.x, 1.0 - uv0.y) : uv0;\n#endif\ncolor = a_color;\nreturn pos;\n}\nvoid main() { gl_Position = vert(); }", + "frag": "\nprecision highp float;\nvec4 CCSampleWithAlphaSeparated(sampler2D tex, vec2 uv) {\n#if CC_USE_EMBEDDED_ALPHA\nreturn vec4(texture(tex, uv).rgb, texture(tex, uv + vec2(0.0, 0.5)).r);\n#else\nreturn texture(tex, uv);\n#endif\n}\n#if USE_ALPHA_TEST\nlayout(std140) uniform ALPHA_TEST_DATA {\nfloat alphaThreshold;\n};\n#endif\nvoid ALPHA_TEST (in vec4 color) {\n#if USE_ALPHA_TEST\nif (color.a < alphaThreshold) discard;\n#endif\n}\nvoid ALPHA_TEST (in float alpha) {\n#if USE_ALPHA_TEST\nif (alpha < alphaThreshold) discard;\n#endif\n}\nin vec4 color;\n#if USE_TEXTURE\nin vec2 uv0;\nuniform sampler2D cc_spriteTexture;\n#endif\nvec4 frag () {\nvec4 o = vec4(1, 1, 1, 1);\n#if USE_TEXTURE\no *= CCSampleWithAlphaSeparated(cc_spriteTexture, uv0);\n#if IS_GRAY\nfloat gray = 0.2126 * o.r + 0.7152 * o.g + 0.0722 * o.b;\no.r = o.g = o.b = gray;\n#endif\n#endif\no *= color;\nALPHA_TEST(o);\nreturn o;\n}\nlayout(location = 0) out vec4 cc_FragColor;\nvoid main() { cc_FragColor = frag(); }", + } + ], + [ + { + "vert": "\nprecision highp float;\nhighp float decode32 (highp vec4 rgba) {\nrgba = rgba * 255.0;\nhighp float Sign = 1.0 - (step(128.0, (rgba[3]) + 0.5)) * 2.0;\nhighp float Exponent = 2.0 * (mod(float(int((rgba[3]) + 0.5)), 128.0)) + (step(128.0, (rgba[2]) + 0.5)) - 127.0;\nhighp float Mantissa = (mod(float(int((rgba[2]) + 0.5)), 128.0)) * 65536.0 + rgba[1] * 256.0 + rgba[0] + 8388608.0;\nreturn Sign * exp2(Exponent - 23.0) * Mantissa;\n}\nstruct StandardVertInput {\nhighp vec4 position;\nvec3 normal;\nvec4 tangent;\n};\nin vec3 a_position;\nin vec3 a_normal;\nin vec2 a_texCoord;\nin vec4 a_tangent;\n#if CC_USE_MORPH\nin float a_vertexId;\nint getVertexId() {\nreturn int(a_vertexId);\n}\nlayout(std140) uniform CCMorph {\nvec4 cc_displacementWeights[15];\nvec4 cc_displacementTextureInfo;\n};\nvec2 getPixelLocation(vec2 textureResolution, int pixelIndex) {\nfloat pixelIndexF = float(pixelIndex);\nfloat x = mod(pixelIndexF, textureResolution.x);\nfloat y = floor(pixelIndexF / textureResolution.x);\nreturn vec2(x, y);\n}\nvec2 getPixelCoordFromLocation(vec2 location, vec2 textureResolution) {\nreturn (vec2(location.x, location.y) + .5) / textureResolution;\n}\n#if CC_DEVICE_SUPPORT_FLOAT_TEXTURE\nvec4 fetchVec3ArrayFromTexture(sampler2D tex, int pixelIndex) {\nivec2 texSize = textureSize(tex, 0);\nreturn texelFetch(tex, ivec2(pixelIndex % texSize.x, pixelIndex / texSize.x), 0);\n}\n#else\nvec4 fetchVec3ArrayFromTexture(sampler2D tex, int elementIndex) {\nint pixelIndex = elementIndex * 4;\nvec2 location = getPixelLocation(cc_displacementTextureInfo.xy, pixelIndex);\nvec2 x = getPixelCoordFromLocation(location + vec2(0.0, 0.0), cc_displacementTextureInfo.xy);\nvec2 y = getPixelCoordFromLocation(location + vec2(1.0, 0.0), cc_displacementTextureInfo.xy);\nvec2 z = getPixelCoordFromLocation(location + vec2(2.0, 0.0), cc_displacementTextureInfo.xy);\nreturn vec4(\ndecode32(texture(tex, x)),\ndecode32(texture(tex, y)),\ndecode32(texture(tex, z)),\n1.0\n);\n}\n#endif\nfloat getDisplacementWeight(int index) {\nint quot = index / 4;\nint remainder = index - quot * 4;\nif (remainder == 0) {\nreturn cc_displacementWeights[quot].x;\n} else if (remainder == 1) {\nreturn cc_displacementWeights[quot].y;\n} else if (remainder == 2) {\nreturn cc_displacementWeights[quot].z;\n} else {\nreturn cc_displacementWeights[quot].w;\n}\n}\nvec3 getVec3DisplacementFromTexture(sampler2D tex, int vertexIndex) {\n#if CC_MORPH_PRECOMPUTED\nreturn fetchVec3ArrayFromTexture(tex, vertexIndex).rgb;\n#else\nvec3 result = vec3(0, 0, 0);\nint nVertices = int(cc_displacementTextureInfo.z);\nfor (int iTarget = 0; iTarget < CC_MORPH_TARGET_COUNT; ++iTarget) {\nresult += (fetchVec3ArrayFromTexture(tex, nVertices * iTarget + vertexIndex).rgb * getDisplacementWeight(iTarget));\n}\nreturn result;\n#endif\n}\n#if CC_MORPH_TARGET_HAS_POSITION\nuniform sampler2D cc_PositionDisplacements;\nvec3 getPositionDisplacement(int vertexId) {\nreturn getVec3DisplacementFromTexture(cc_PositionDisplacements, vertexId);\n}\n#endif\n#if CC_MORPH_TARGET_HAS_NORMAL\nuniform sampler2D cc_NormalDisplacements;\nvec3 getNormalDisplacement(int vertexId) {\nreturn getVec3DisplacementFromTexture(cc_NormalDisplacements, vertexId);\n}\n#endif\n#if CC_MORPH_TARGET_HAS_TANGENT\nuniform sampler2D cc_TangentDisplacements;\nvec3 getTangentDisplacement(int vertexId) {\nreturn getVec3DisplacementFromTexture(cc_TangentDisplacements, vertexId);\n}\n#endif\nvoid applyMorph (inout StandardVertInput attr) {\nint vertexId = getVertexId();\n#if CC_MORPH_TARGET_HAS_POSITION\nattr.position.xyz = attr.position.xyz + getPositionDisplacement(vertexId);\n#endif\n#if CC_MORPH_TARGET_HAS_NORMAL\nattr.normal.xyz = attr.normal.xyz + getNormalDisplacement(vertexId);\n#endif\n#if CC_MORPH_TARGET_HAS_TANGENT\nattr.tangent.xyz = attr.tangent.xyz + getTangentDisplacement(vertexId);\n#endif\n}\nvoid applyMorph (inout vec4 position) {\n#if CC_MORPH_TARGET_HAS_POSITION\nposition.xyz = position.xyz + getPositionDisplacement(getVertexId());\n#endif\n}\n#endif\n#if CC_USE_SKINNING\nin vec4 a_joints;\nin vec4 a_weights;\n#if CC_USE_BAKED_ANIMATION\n#if USE_INSTANCING\nin highp vec4 a_jointAnimInfo;\n#endif\nlayout(std140) uniform CCSkinningTexture {\nhighp vec4 cc_jointTextureInfo;\n};\nlayout(std140) uniform CCSkinningAnimation {\nhighp vec4 cc_jointAnimInfo;\n};\nuniform highp sampler2D cc_jointTexture;\n#else\nlayout(std140) uniform CCSkinning {\nhighp vec4 cc_joints[30 * 3];\n};\n#endif\n#if CC_USE_BAKED_ANIMATION\n#if CC_DEVICE_SUPPORT_FLOAT_TEXTURE\nmat4 getJointMatrix (float i) {\n#if USE_INSTANCING\nhighp float j = 3.0 * (a_jointAnimInfo.x * a_jointAnimInfo.y + i) + a_jointAnimInfo.z;\n#else\nhighp float j = 3.0 * (cc_jointAnimInfo.x * cc_jointTextureInfo.y + i) + cc_jointTextureInfo.z;\n#endif\nhighp float invSize = cc_jointTextureInfo.w;\nhighp float y = floor(j * invSize);\nhighp float x = floor(j - y * cc_jointTextureInfo.x);\ny = (y + 0.5) * invSize;\nvec4 v1 = texture(cc_jointTexture, vec2((x + 0.5) * invSize, y));\nvec4 v2 = texture(cc_jointTexture, vec2((x + 1.5) * invSize, y));\nvec4 v3 = texture(cc_jointTexture, vec2((x + 2.5) * invSize, y));\nreturn mat4(vec4(v1.xyz, 0.0), vec4(v2.xyz, 0.0), vec4(v3.xyz, 0.0), vec4(v1.w, v2.w, v3.w, 1.0));\n}\n#else\nmat4 getJointMatrix (float i) {\n#if USE_INSTANCING\nhighp float j = 12.0 * (a_jointAnimInfo.x * a_jointAnimInfo.y + i) + a_jointAnimInfo.z;\n#else\nhighp float j = 12.0 * (cc_jointAnimInfo.x * cc_jointTextureInfo.y + i) + cc_jointTextureInfo.z;\n#endif\nhighp float invSize = cc_jointTextureInfo.w;\nhighp float y = floor(j * invSize);\nhighp float x = floor(j - y * cc_jointTextureInfo.x);\ny = (y + 0.5) * invSize;\nvec4 v1 = vec4(\ndecode32(texture(cc_jointTexture, vec2((x + 0.5) * invSize, y))),\ndecode32(texture(cc_jointTexture, vec2((x + 1.5) * invSize, y))),\ndecode32(texture(cc_jointTexture, vec2((x + 2.5) * invSize, y))),\ndecode32(texture(cc_jointTexture, vec2((x + 3.5) * invSize, y)))\n);\nvec4 v2 = vec4(\ndecode32(texture(cc_jointTexture, vec2((x + 4.5) * invSize, y))),\ndecode32(texture(cc_jointTexture, vec2((x + 5.5) * invSize, y))),\ndecode32(texture(cc_jointTexture, vec2((x + 6.5) * invSize, y))),\ndecode32(texture(cc_jointTexture, vec2((x + 7.5) * invSize, y)))\n);\nvec4 v3 = vec4(\ndecode32(texture(cc_jointTexture, vec2((x + 8.5) * invSize, y))),\ndecode32(texture(cc_jointTexture, vec2((x + 9.5) * invSize, y))),\ndecode32(texture(cc_jointTexture, vec2((x + 10.5) * invSize, y))),\ndecode32(texture(cc_jointTexture, vec2((x + 11.5) * invSize, y)))\n);\nreturn mat4(vec4(v1.xyz, 0.0), vec4(v2.xyz, 0.0), vec4(v3.xyz, 0.0), vec4(v1.w, v2.w, v3.w, 1.0));\n}\n#endif\n#else\nmat4 getJointMatrix (float i) {\nint idx = int(i);\nvec4 v1 = cc_joints[idx * 3];\nvec4 v2 = cc_joints[idx * 3 + 1];\nvec4 v3 = cc_joints[idx * 3 + 2];\nreturn mat4(vec4(v1.xyz, 0.0), vec4(v2.xyz, 0.0), vec4(v3.xyz, 0.0), vec4(v1.w, v2.w, v3.w, 1.0));\n}\n#endif\nmat4 skinMatrix () {\nvec4 joints = vec4(a_joints);\nreturn getJointMatrix(joints.x) * a_weights.x\n+ getJointMatrix(joints.y) * a_weights.y\n+ getJointMatrix(joints.z) * a_weights.z\n+ getJointMatrix(joints.w) * a_weights.w;\n}\nvoid CCSkin (inout vec4 position) {\nmat4 m = skinMatrix();\nposition = m * position;\n}\nvoid CCSkin (inout StandardVertInput attr) {\nmat4 m = skinMatrix();\nattr.position = m * attr.position;\nattr.normal = (m * vec4(attr.normal, 0.0)).xyz;\nattr.tangent.xyz = (m * vec4(attr.tangent.xyz, 0.0)).xyz;\n}\n#endif\nlayout(std140) uniform CCGlobal {\nhighp vec4 cc_time;\nmediump vec4 cc_screenSize;\nmediump vec4 cc_nativeSize;\n};\nlayout(std140) uniform CCCamera {\nhighp mat4 cc_matView;\nhighp mat4 cc_matViewInv;\nhighp mat4 cc_matProj;\nhighp mat4 cc_matProjInv;\nhighp mat4 cc_matViewProj;\nhighp mat4 cc_matViewProjInv;\nhighp vec4 cc_cameraPos;\nmediump vec4 cc_screenScale;\nmediump vec4 cc_exposure;\nmediump vec4 cc_mainLitDir;\nmediump vec4 cc_mainLitColor;\nmediump vec4 cc_ambientSky;\nmediump vec4 cc_ambientGround;\nmediump vec4 cc_fogColor;\nmediump vec4 cc_fogBase;\nmediump vec4 cc_fogAdd;\nmediump vec4 cc_nearFar;\nmediump vec4 cc_viewPort;\n};\n#if USE_INSTANCING\nin vec4 a_matWorld0;\nin vec4 a_matWorld1;\nin vec4 a_matWorld2;\n#if USE_LIGHTMAP\nin vec4 a_lightingMapUVParam;\n#endif\n#elif USE_BATCHING\nin float a_dyn_batch_id;\nlayout(std140) uniform CCLocalBatched {\nhighp mat4 cc_matWorlds[10];\n};\n#else\nlayout(std140) uniform CCLocal {\nhighp mat4 cc_matWorld;\nhighp mat4 cc_matWorldIT;\nhighp vec4 cc_lightingMapUVParam;\n};\n#endif\nlayout(std140) uniform Constants {\nvec4 tilingOffset;\nvec4 albedo;\nvec4 albedoScaleAndCutoff;\nvec4 pbrParams;\nvec4 emissive;\nvec4 emissiveScaleParam;\n};\nfloat LinearFog(vec4 pos) {\nvec4 wPos = pos;\nfloat cam_dis = distance(cc_cameraPos, wPos);\nfloat fogStart = cc_fogBase.x;\nfloat fogEnd = cc_fogBase.y;\nreturn clamp((fogEnd - cam_dis) / (fogEnd - fogStart), 0., 1.);\n}\nfloat ExpFog(vec4 pos) {\nvec4 wPos = pos;\nfloat fogAtten = cc_fogAdd.z;\nfloat fogStart = cc_fogBase.x;\nfloat fogDensity = cc_fogBase.z;\nfloat cam_dis = max(distance(cc_cameraPos, wPos) - fogStart, 0.0) / fogAtten * 4.;\nfloat f = exp(-cam_dis * fogDensity);\nreturn f;\n}\nfloat ExpSquaredFog(vec4 pos) {\nvec4 wPos = pos;\nfloat fogAtten = cc_fogAdd.z;\nfloat fogStart = cc_fogBase.x;\nfloat fogDensity = cc_fogBase.z;\nfloat cam_dis = max(distance(cc_cameraPos, wPos) - fogStart, 0.0) / fogAtten * 4.;\nfloat f = exp(-cam_dis * cam_dis * fogDensity * fogDensity);\nreturn f;\n}\nfloat LayeredFog(vec4 pos) {\nvec4 wPos = pos;\nfloat fogAtten = cc_fogAdd.z;\nfloat _FogTop = cc_fogAdd.x;\nfloat _FogRange = cc_fogAdd.y;\nvec3 camWorldProj = cc_cameraPos.xyz;\ncamWorldProj.y = 0.;\nvec3 worldPosProj = wPos.xyz;\nworldPosProj.y = 0.;\nfloat fDeltaD = distance(worldPosProj, camWorldProj) / fogAtten * 2.0;\nfloat fDeltaY, fDensityIntegral;\nif (cc_cameraPos.y > _FogTop) {\nif (wPos.y < _FogTop) {\nfDeltaY = (_FogTop - wPos.y) / _FogRange * 2.0;\nfDensityIntegral = fDeltaY * fDeltaY * 0.5;\n} else {\nfDeltaY = 0.;\nfDensityIntegral = 0.;\n}\n} else {\nif (wPos.y < _FogTop) {\nfloat fDeltaA = (_FogTop - cc_cameraPos.y) / _FogRange * 2.;\nfloat fDeltaB = (_FogTop - wPos.y) / _FogRange * 2.;\nfDeltaY = abs(fDeltaA - fDeltaB);\nfDensityIntegral = abs((fDeltaA * fDeltaA * 0.5) - (fDeltaB * fDeltaB * 0.5));\n} else {\nfDeltaY = abs(_FogTop - cc_cameraPos.y) / _FogRange * 2.;\nfDensityIntegral = abs(fDeltaY * fDeltaY * 0.5);\n}\n}\nfloat fDensity;\nif (fDeltaY != 0.) {\nfDensity = (sqrt(1.0 + ((fDeltaD / fDeltaY) * (fDeltaD / fDeltaY)))) * fDensityIntegral;\n} else {\nfDensity = 0.;\n}\nfloat f = exp(-fDensity);\nreturn f;\n}\nvoid CC_TRANSFER_FOG_BASE(vec4 pos, out float factor)\n{\n#if CC_USE_FOG == 0\nfactor = LinearFog(pos);\n#elif CC_USE_FOG == 1\nfactor = ExpFog(pos);\n#elif CC_USE_FOG == 2\nfactor = ExpSquaredFog(pos);\n#elif CC_USE_FOG == 3\nfactor = LayeredFog(pos);\n#else\nfactor = 1.0;\n#endif\n}\n#if !CC_USE_ACCURATE_FOG\nout float v_fog_factor;\n#endif\nvoid CC_TRANSFER_FOG(vec4 pos) {\n#if !CC_USE_ACCURATE_FOG\nCC_TRANSFER_FOG_BASE(pos, v_fog_factor);\n#endif\n}\nout highp vec4 v_shadowPos;\nlayout(std140) uniform CCShadow {\nhighp mat4 cc_matLightPlaneProj;\nhighp mat4 cc_matLightView;\nhighp mat4 cc_matLightViewProj;\nhighp vec4 cc_shadowInvProjDepthInfo;\nhighp vec4 cc_shadowProjDepthInfo;\nhighp vec4 cc_shadowProjInfo;\nlowp vec4 cc_shadowNFLSInfo;\nlowp vec4 cc_shadowWHPBInfo;\nlowp vec4 cc_shadowLPNNInfo;\nlowp vec4 cc_shadowColor;\n};\n#if CC_RECEIVE_SHADOW\nuniform highp sampler2D cc_shadowMap;\nuniform highp sampler2D cc_spotLightingMap;\n#endif\n#if USE_VERTEX_COLOR\nin vec4 a_color;\nout vec4 v_color;\n#endif\nout vec3 v_position;\nout vec3 v_normal;\nout vec2 v_uv;\nout vec2 v_uv1;\n#if USE_NORMAL_MAP\nout vec3 v_tangent;\nout vec3 v_bitangent;\n#endif\n#if HAS_SECOND_UV || USE_LIGHTMAP\nin vec2 a_texCoord1;\n#endif\n#if USE_LIGHTMAP && !USE_BATCHING && !CC_FORWARD_ADD\nout vec3 v_luv;\nvoid CCLightingMapCaclUV()\n{\n#if !USE_INSTANCING\nv_luv.xy = cc_lightingMapUVParam.xy + a_texCoord1 * cc_lightingMapUVParam.zw;\nv_luv.z = cc_lightingMapUVParam.z;\n#else\nv_luv.xy = a_lightingMapUVParam.xy + a_texCoord1 * a_lightingMapUVParam.zw;\nv_luv.z = a_lightingMapUVParam.z;\n#endif\n}\n#endif\nvoid main () {\nStandardVertInput In;\nIn.position = vec4(a_position, 1.0);\nIn.normal = a_normal;\nIn.tangent = a_tangent;\n#if CC_USE_MORPH\napplyMorph(In);\n#endif\n#if CC_USE_SKINNING\nCCSkin(In);\n#endif\nmat4 matWorld, matWorldIT;\n#if USE_INSTANCING\nmatWorld = mat4(\nvec4(a_matWorld0.xyz, 0.0),\nvec4(a_matWorld1.xyz, 0.0),\nvec4(a_matWorld2.xyz, 0.0),\nvec4(a_matWorld0.w, a_matWorld1.w, a_matWorld2.w, 1.0)\n);\nmatWorldIT = matWorld;\n#elif USE_BATCHING\nmatWorld = cc_matWorlds[int(a_dyn_batch_id)];\nmatWorldIT = matWorld;\n#else\nmatWorld = cc_matWorld;\nmatWorldIT = cc_matWorldIT;\n#endif\nvec4 pos = matWorld * In.position;\nv_position = pos.xyz;\nv_normal = normalize((matWorldIT * vec4(In.normal, 0.0)).xyz);\n#if USE_TWOSIDE\nvec3 viewDirect = normalize(cc_cameraPos.xyz - v_position);\nv_normal *= dot(v_normal, viewDirect) < 0.0 ? -1.0 : 1.0;\n#endif\n#if USE_NORMAL_MAP\nv_tangent = normalize((matWorld * vec4(In.tangent.xyz, 0.0)).xyz);\nv_bitangent = cross(v_normal, v_tangent) * In.tangent.w;\n#endif\nv_uv = a_texCoord * tilingOffset.xy + tilingOffset.zw;\n#if SAMPLE_FROM_RT\nv_uv = cc_cameraPos.w > 1.0 ? vec2(v_uv.x, 1.0 - v_uv.y) : v_uv;\n#endif\n#if HAS_SECOND_UV\nv_uv1 = a_texCoord1 * tilingOffset.xy + tilingOffset.zw;\n#if SAMPLE_FROM_RT\nv_uv1 = cc_cameraPos.w > 1.0 ? vec2(v_uv1.x, 1.0 - v_uv1.y) : v_uv1;\n#endif\n#endif\n#if USE_VERTEX_COLOR\nv_color = a_color;\n#endif\nCC_TRANSFER_FOG(pos);\nv_shadowPos = cc_matLightViewProj * pos;\n#if USE_LIGHTMAP && !USE_BATCHING && !CC_FORWARD_ADD\nCCLightingMapCaclUV();\n#endif\ngl_Position = cc_matProj * (cc_matView * matWorld) * In.position;\n}", + "frag": "\nprecision highp float;\nlayout(std140) uniform CCGlobal {\nhighp vec4 cc_time;\nmediump vec4 cc_screenSize;\nmediump vec4 cc_nativeSize;\n};\nlayout(std140) uniform CCCamera {\nhighp mat4 cc_matView;\nhighp mat4 cc_matViewInv;\nhighp mat4 cc_matProj;\nhighp mat4 cc_matProjInv;\nhighp mat4 cc_matViewProj;\nhighp mat4 cc_matViewProjInv;\nhighp vec4 cc_cameraPos;\nmediump vec4 cc_screenScale;\nmediump vec4 cc_exposure;\nmediump vec4 cc_mainLitDir;\nmediump vec4 cc_mainLitColor;\nmediump vec4 cc_ambientSky;\nmediump vec4 cc_ambientGround;\nmediump vec4 cc_fogColor;\nmediump vec4 cc_fogBase;\nmediump vec4 cc_fogAdd;\nmediump vec4 cc_nearFar;\nmediump vec4 cc_viewPort;\n};\nlayout(std140) uniform Constants {\nvec4 tilingOffset;\nvec4 albedo;\nvec4 albedoScaleAndCutoff;\nvec4 pbrParams;\nvec4 emissive;\nvec4 emissiveScaleParam;\n};\nfloat LinearFog(vec4 pos) {\nvec4 wPos = pos;\nfloat cam_dis = distance(cc_cameraPos, wPos);\nfloat fogStart = cc_fogBase.x;\nfloat fogEnd = cc_fogBase.y;\nreturn clamp((fogEnd - cam_dis) / (fogEnd - fogStart), 0., 1.);\n}\nfloat ExpFog(vec4 pos) {\nvec4 wPos = pos;\nfloat fogAtten = cc_fogAdd.z;\nfloat fogStart = cc_fogBase.x;\nfloat fogDensity = cc_fogBase.z;\nfloat cam_dis = max(distance(cc_cameraPos, wPos) - fogStart, 0.0) / fogAtten * 4.;\nfloat f = exp(-cam_dis * fogDensity);\nreturn f;\n}\nfloat ExpSquaredFog(vec4 pos) {\nvec4 wPos = pos;\nfloat fogAtten = cc_fogAdd.z;\nfloat fogStart = cc_fogBase.x;\nfloat fogDensity = cc_fogBase.z;\nfloat cam_dis = max(distance(cc_cameraPos, wPos) - fogStart, 0.0) / fogAtten * 4.;\nfloat f = exp(-cam_dis * cam_dis * fogDensity * fogDensity);\nreturn f;\n}\nfloat LayeredFog(vec4 pos) {\nvec4 wPos = pos;\nfloat fogAtten = cc_fogAdd.z;\nfloat _FogTop = cc_fogAdd.x;\nfloat _FogRange = cc_fogAdd.y;\nvec3 camWorldProj = cc_cameraPos.xyz;\ncamWorldProj.y = 0.;\nvec3 worldPosProj = wPos.xyz;\nworldPosProj.y = 0.;\nfloat fDeltaD = distance(worldPosProj, camWorldProj) / fogAtten * 2.0;\nfloat fDeltaY, fDensityIntegral;\nif (cc_cameraPos.y > _FogTop) {\nif (wPos.y < _FogTop) {\nfDeltaY = (_FogTop - wPos.y) / _FogRange * 2.0;\nfDensityIntegral = fDeltaY * fDeltaY * 0.5;\n} else {\nfDeltaY = 0.;\nfDensityIntegral = 0.;\n}\n} else {\nif (wPos.y < _FogTop) {\nfloat fDeltaA = (_FogTop - cc_cameraPos.y) / _FogRange * 2.;\nfloat fDeltaB = (_FogTop - wPos.y) / _FogRange * 2.;\nfDeltaY = abs(fDeltaA - fDeltaB);\nfDensityIntegral = abs((fDeltaA * fDeltaA * 0.5) - (fDeltaB * fDeltaB * 0.5));\n} else {\nfDeltaY = abs(_FogTop - cc_cameraPos.y) / _FogRange * 2.;\nfDensityIntegral = abs(fDeltaY * fDeltaY * 0.5);\n}\n}\nfloat fDensity;\nif (fDeltaY != 0.) {\nfDensity = (sqrt(1.0 + ((fDeltaD / fDeltaY) * (fDeltaD / fDeltaY)))) * fDensityIntegral;\n} else {\nfDensity = 0.;\n}\nfloat f = exp(-fDensity);\nreturn f;\n}\nvoid CC_TRANSFER_FOG_BASE(vec4 pos, out float factor)\n{\n#if CC_USE_FOG == 0\nfactor = LinearFog(pos);\n#elif CC_USE_FOG == 1\nfactor = ExpFog(pos);\n#elif CC_USE_FOG == 2\nfactor = ExpSquaredFog(pos);\n#elif CC_USE_FOG == 3\nfactor = LayeredFog(pos);\n#else\nfactor = 1.0;\n#endif\n}\nvoid CC_APPLY_FOG_BASE(inout vec4 color, float factor) {\ncolor = vec4(mix(cc_fogColor.rgb, color.rgb, factor), color.a);\n}\n#if !CC_USE_ACCURATE_FOG\nin float v_fog_factor;\n#endif\nvoid CC_APPLY_FOG(inout vec4 color) {\n#if !CC_USE_ACCURATE_FOG\nCC_APPLY_FOG_BASE(color, v_fog_factor);\n#endif\n}\nvoid CC_APPLY_FOG(inout vec4 color, vec3 worldPos) {\n#if CC_USE_ACCURATE_FOG\nfloat factor;\nCC_TRANSFER_FOG_BASE(vec4(worldPos, 1.0), factor);\n#else\nfloat factor = v_fog_factor;\n#endif\nCC_APPLY_FOG_BASE(color, factor);\n}\nvec3 SRGBToLinear (vec3 gamma) {\nreturn gamma * gamma;\n}\nlayout(std140) uniform CCShadow {\nhighp mat4 cc_matLightPlaneProj;\nhighp mat4 cc_matLightView;\nhighp mat4 cc_matLightViewProj;\nhighp vec4 cc_shadowInvProjDepthInfo;\nhighp vec4 cc_shadowProjDepthInfo;\nhighp vec4 cc_shadowProjInfo;\nlowp vec4 cc_shadowNFLSInfo;\nlowp vec4 cc_shadowWHPBInfo;\nlowp vec4 cc_shadowLPNNInfo;\nlowp vec4 cc_shadowColor;\n};\nfloat CCGetLinearDepthFromViewSpace(vec3 viewPos) {\nfloat dist = length(viewPos);\nreturn (dist - cc_shadowNFLSInfo.x) / (cc_shadowNFLSInfo.y - cc_shadowNFLSInfo.x);\n}\nfloat CCGetLinearDepth(vec3 worldPos) {\nvec4 viewStartPos = cc_matLightView * vec4(worldPos.xyz, 1.0);\nreturn CCGetLinearDepthFromViewSpace(viewStartPos.xyz);\n}\n#if CC_RECEIVE_SHADOW\nuniform highp sampler2D cc_shadowMap;\nuniform highp sampler2D cc_spotLightingMap;\nvec4 ApplyShadowDepthBias_FaceNormal(vec4 shadowPos, vec3 worldNormal)\n{\nvec4 newShadowPos = shadowPos;\nif(cc_shadowLPNNInfo.z > 0.0001)\n{\nvec4 viewNormal = cc_matLightView * vec4(worldNormal, 0.0);\nif(viewNormal.z < 0.1)\nnewShadowPos.xy += viewNormal.xy * cc_shadowProjInfo.xy * cc_shadowLPNNInfo.z * clamp(viewNormal.z, 0.001, 0.1);\n}\nreturn newShadowPos;\n}\nvec4 ApplyShadowDepthBias_Perspective(vec4 shadowPos, float viewspaceDepthBias)\n{\nvec3 viewSpacePos;\nviewSpacePos.xy = shadowPos.xy * cc_shadowProjInfo.zw;\nviewSpacePos.z = shadowPos.z * cc_shadowInvProjDepthInfo.x + shadowPos.w * cc_shadowInvProjDepthInfo.y;\nviewSpacePos.xyz += cc_shadowProjDepthInfo.z * normalize(viewSpacePos.xyz) * viewspaceDepthBias;\nvec4 clipSpacePos;\nclipSpacePos.xy = viewSpacePos.xy * cc_shadowProjInfo.xy;\nclipSpacePos.zw = viewSpacePos.z * cc_shadowProjDepthInfo.xz + vec2(cc_shadowProjDepthInfo.y, 0.0);\nif (cc_shadowNFLSInfo.z > 0.000001) {\nclipSpacePos.z = CCGetLinearDepthFromViewSpace(viewSpacePos.xyz);\nclipSpacePos.z = (clipSpacePos.z * 2.0 - 1.0) * clipSpacePos.w;\n}\nreturn clipSpacePos;\n}\nvec4 ApplyShadowDepthBias_Orthographic(vec4 shadowPos, float viewspaceDepthBias)\n{\nfloat coeffA = cc_shadowProjDepthInfo.x;\nfloat coeffB = cc_shadowProjDepthInfo.y;\nfloat viewSpacePos_z = (shadowPos.z - coeffB) / coeffA;\nviewSpacePos_z += viewspaceDepthBias;\nvec4 result = shadowPos;\nresult.z = viewSpacePos_z * coeffA + coeffB;\nreturn result;\n}\nfloat CCGetShadowFactorHard (vec4 shadowPos) {\nvec4 clipPosNew = ApplyShadowDepthBias_Orthographic(shadowPos, cc_shadowWHPBInfo.w);\nvec3 clipPos = clipPosNew.xyz / clipPosNew.w * 0.5 + 0.5;\nif (clipPos.x < 0.0 || clipPos.x > 1.0 ||\nclipPos.y < 0.0 || clipPos.y > 1.0 ||\nclipPos.z < 0.0 || clipPos.z > 1.0) { return 1.0; }\nclipPos.xy = cc_cameraPos.w == 1.0 ? vec2(clipPos.xy.x, 1.0 - clipPos.xy.y) : clipPos.xy;\nfloat shadow = 0.0;\nfloat closestDepth = 0.0;\nif (cc_shadowLPNNInfo.y > 0.000001) {\nclosestDepth = dot(texture(cc_shadowMap, clipPos.xy), vec4(1.0, 1.0 / 255.0, 1.0 / 65025.0, 1.0 / 16581375.0));\n} else {\nclosestDepth = texture(cc_shadowMap, clipPos.xy).x;\n}\nshadow = step(clipPos.z, closestDepth);\nreturn shadow;\n}\nfloat CCGetShadowFactorSoft (vec4 shadowPos) {\nvec4 clipPosNew = ApplyShadowDepthBias_Orthographic(shadowPos, cc_shadowWHPBInfo.w);\nvec3 clipPos = clipPosNew.xyz / clipPosNew.w * 0.5 + 0.5;\nif (clipPos.x < 0.0 || clipPos.x > 1.0 ||\nclipPos.y < 0.0 || clipPos.y > 1.0 ||\nclipPos.z < 0.0 || clipPos.z > 1.0) { return 1.0; }\nclipPos.xy = cc_cameraPos.w == 1.0 ? vec2(clipPos.xy.x, 1.0 - clipPos.xy.y) : clipPos.xy;\nfloat offsetDepth = clipPos.z;\nvec2 mapSize = cc_shadowWHPBInfo.xy;\nvec2 oneTap = 1.0 / mapSize;\nvec2 clipPos_offset = clipPos.xy + oneTap;\nfloat block0, block1, block2, block3;\nif (cc_shadowLPNNInfo.y > 0.000001) {\nblock0 = step(offsetDepth, dot(texture(cc_shadowMap, vec2(clipPos.x, clipPos.y)), vec4(1.0, 1.0 / 255.0, 1.0 / 65025.0, 1.0 / 16581375.0)));\nblock1 = step(offsetDepth, dot(texture(cc_shadowMap, vec2(clipPos_offset.x, clipPos.y)), vec4(1.0, 1.0 / 255.0, 1.0 / 65025.0, 1.0 / 16581375.0)));\nblock2 = step(offsetDepth, dot(texture(cc_shadowMap, vec2(clipPos.x, clipPos_offset.y)), vec4(1.0, 1.0 / 255.0, 1.0 / 65025.0, 1.0 / 16581375.0)));\nblock3 = step(offsetDepth, dot(texture(cc_shadowMap, vec2(clipPos_offset.x, clipPos_offset.y)), vec4(1.0, 1.0 / 255.0, 1.0 / 65025.0, 1.0 / 16581375.0)));\n} else {\nblock0 = step(offsetDepth, texture(cc_shadowMap, vec2(clipPos.x, clipPos.y)).x);\nblock1 = step(offsetDepth, texture(cc_shadowMap, vec2(clipPos_offset.x, clipPos.y)).x);\nblock2 = step(offsetDepth, texture(cc_shadowMap, vec2(clipPos.x, clipPos_offset.y)).x);\nblock3 = step(offsetDepth, texture(cc_shadowMap, vec2(clipPos_offset.x, clipPos_offset.y)).x);\n}\nfloat coefX = mod(clipPos.x, oneTap.x) * mapSize.x;\nfloat resultX = mix(block0, block1, coefX);\nfloat resultY = mix(block2, block3, coefX);\nfloat coefY = mod(clipPos.y, oneTap.y) * mapSize.y;\nreturn mix(resultX, resultY, coefY);\n}\nfloat CCGetShadowFactorSoft2X (vec4 shadowPos) {\nvec4 clipPosNew = ApplyShadowDepthBias_Orthographic(shadowPos, cc_shadowWHPBInfo.w);\nvec3 clipPos = clipPosNew.xyz / clipPosNew.w * 0.5 + 0.5;\nif (clipPos.x < 0.0 || clipPos.x > 1.0 ||\nclipPos.y < 0.0 || clipPos.y > 1.0 ||\nclipPos.z < 0.0 || clipPos.z > 1.0) { return 1.0; }\nclipPos.xy = cc_cameraPos.w == 1.0 ? vec2(clipPos.xy.x, 1.0 - clipPos.xy.y) : clipPos.xy;\nfloat offsetDepth = clipPos.z;\nvec2 mapSize = cc_shadowWHPBInfo.xy;\nvec2 oneTap = 1.0 / mapSize;\nfloat clipPos_offset_L = clipPos.x - oneTap.x;\nfloat clipPos_offset_R = clipPos.x + oneTap.x;\nfloat clipPos_offset_U = clipPos.y - oneTap.y;\nfloat clipPos_offset_D = clipPos.y + oneTap.y;\nfloat block0, block1, block2, block3, block4, block5, block6, block7, block8;\nif (cc_shadowLPNNInfo.y > 0.000001) {\nblock0 = step(offsetDepth, dot(texture(cc_shadowMap, vec2(clipPos_offset_L, clipPos_offset_U)), vec4(1.0, 1.0 / 255.0, 1.0 / 65025.0, 1.0 / 16581375.0)));\nblock1 = step(offsetDepth, dot(texture(cc_shadowMap, vec2(clipPos.x, clipPos_offset_U)), vec4(1.0, 1.0 / 255.0, 1.0 / 65025.0, 1.0 / 16581375.0)));\nblock2 = step(offsetDepth, dot(texture(cc_shadowMap, vec2(clipPos_offset_R, clipPos_offset_U)), vec4(1.0, 1.0 / 255.0, 1.0 / 65025.0, 1.0 / 16581375.0)));\nblock3 = step(offsetDepth, dot(texture(cc_shadowMap, vec2(clipPos_offset_L, clipPos.y)), vec4(1.0, 1.0 / 255.0, 1.0 / 65025.0, 1.0 / 16581375.0)));\nblock4 = step(offsetDepth, dot(texture(cc_shadowMap, vec2(clipPos.x, clipPos.y)), vec4(1.0, 1.0 / 255.0, 1.0 / 65025.0, 1.0 / 16581375.0)));\nblock5 = step(offsetDepth, dot(texture(cc_shadowMap, vec2(clipPos_offset_R, clipPos.y)), vec4(1.0, 1.0 / 255.0, 1.0 / 65025.0, 1.0 / 16581375.0)));\nblock6 = step(offsetDepth, dot(texture(cc_shadowMap, vec2(clipPos_offset_L, clipPos_offset_D)), vec4(1.0, 1.0 / 255.0, 1.0 / 65025.0, 1.0 / 16581375.0)));\nblock7 = step(offsetDepth, dot(texture(cc_shadowMap, vec2(clipPos.x, clipPos_offset_D)), vec4(1.0, 1.0 / 255.0, 1.0 / 65025.0, 1.0 / 16581375.0)));\nblock8 = step(offsetDepth, dot(texture(cc_shadowMap, vec2(clipPos_offset_R, clipPos_offset_D)), vec4(1.0, 1.0 / 255.0, 1.0 / 65025.0, 1.0 / 16581375.0)));\n} else {\nblock0 = step(offsetDepth, texture(cc_shadowMap, vec2(clipPos_offset_L, clipPos_offset_U)).x);\nblock1 = step(offsetDepth, texture(cc_shadowMap, vec2(clipPos.x, clipPos_offset_U)).x);\nblock2 = step(offsetDepth, texture(cc_shadowMap, vec2(clipPos_offset_R, clipPos_offset_U)).x);\nblock3 = step(offsetDepth, texture(cc_shadowMap, vec2(clipPos_offset_L, clipPos.y)).x);\nblock4 = step(offsetDepth, texture(cc_shadowMap, vec2(clipPos.x, clipPos.y)).x);\nblock5 = step(offsetDepth, texture(cc_shadowMap, vec2(clipPos_offset_R, clipPos.y)).x);\nblock6 = step(offsetDepth, texture(cc_shadowMap, vec2(clipPos_offset_L, clipPos_offset_D)).x);\nblock7 = step(offsetDepth, texture(cc_shadowMap, vec2(clipPos.x, clipPos_offset_D)).x);\nblock8 = step(offsetDepth, texture(cc_shadowMap, vec2(clipPos_offset_R, clipPos_offset_D)).x);\n}\nfloat coefX = mod(clipPos.x, oneTap.x) * mapSize.x;\nfloat coefY = mod(clipPos.y, oneTap.y) * mapSize.y;\nfloat shadow = 0.0;\nfloat resultX = mix(block0, block1, coefX);\nfloat resultY = mix(block3, block4, coefX);\nshadow += mix(resultX , resultY, coefY);\nresultX = mix(block1, block2, coefX);\nresultY = mix(block4, block5, coefX);\nshadow += mix(resultX , resultY, coefY);\nresultX = mix(block3, block4, coefX);\nresultY = mix(block6, block7, coefX);\nshadow += mix(resultX, resultY, coefY);\nresultX = mix(block4, block5, coefX);\nresultY = mix(block7, block8, coefX);\nshadow += mix(resultX, resultY, coefY);\nreturn shadow * 0.25;\n}\nfloat CCGetSpotLightShadowFactorHard (vec4 shadowPos, vec3 worldPos) {\nvec4 clipPosNew = ApplyShadowDepthBias_Perspective(shadowPos, cc_shadowWHPBInfo.w);\nvec3 clipPos = clipPosNew.xyz / clipPosNew.w * 0.5 + 0.5;\nif (clipPos.x < 0.0 || clipPos.x > 1.0 ||\nclipPos.y < 0.0 || clipPos.y > 1.0 ||\nclipPos.z < 0.0 || clipPos.z > 1.0) { return 1.0; }\nclipPos.xy = cc_cameraPos.w == 1.0 ? vec2(clipPos.xy.x, 1.0 - clipPos.xy.y) : clipPos.xy;\nfloat shadow = 0.0;\nfloat closestDepth = 0.0;\nfloat depth = clipPos.z;\nif (cc_shadowLPNNInfo.y > 0.000001) {\nclosestDepth = dot(texture(cc_spotLightingMap, clipPos.xy), vec4(1.0, 1.0 / 255.0, 1.0 / 65025.0, 1.0 / 16581375.0));\n} else {\nclosestDepth = texture(cc_spotLightingMap, clipPos.xy).x;\n}\nshadow = step(depth, closestDepth);\nreturn shadow;\n}\nfloat CCGetSpotLightShadowFactorSoft (vec4 shadowPos, vec3 worldPos) {\nvec4 clipPosNew = ApplyShadowDepthBias_Perspective(shadowPos, cc_shadowWHPBInfo.w);\nvec3 clipPos = clipPosNew.xyz / clipPosNew.w * 0.5 + 0.5;\nif (clipPos.x < 0.0 || clipPos.x > 1.0 ||\nclipPos.y < 0.0 || clipPos.y > 1.0 ||\nclipPos.z < 0.0 || clipPos.z > 1.0) { return 1.0; }\nclipPos.xy = cc_cameraPos.w == 1.0 ? vec2(clipPos.xy.x, 1.0 - clipPos.xy.y) : clipPos.xy;\nfloat depth = 0.0;\nif (cc_shadowNFLSInfo.z > 0.000001) {\ndepth = CCGetLinearDepth(worldPos);\n} else {\ndepth = clipPos.z;\n}\nfloat bias = cc_shadowWHPBInfo.w;\nvec2 oneTap = 1.0 / cc_shadowWHPBInfo.xy;\nvec2 clipPos_offset = clipPos.xy + oneTap;\nfloat block0, block1, block2, block3;\nif (cc_shadowLPNNInfo.y > 0.000001) {\nblock0 = step(depth, dot(texture(cc_spotLightingMap, vec2(clipPos.x, clipPos.y)), vec4(1.0, 1.0 / 255.0, 1.0 / 65025.0, 1.0 / 16581375.0)));\nblock1 = step(depth, dot(texture(cc_spotLightingMap, vec2(clipPos_offset.x, clipPos.y)), vec4(1.0, 1.0 / 255.0, 1.0 / 65025.0, 1.0 / 16581375.0)));\nblock2 = step(depth, dot(texture(cc_spotLightingMap, vec2(clipPos.x, clipPos_offset.y)), vec4(1.0, 1.0 / 255.0, 1.0 / 65025.0, 1.0 / 16581375.0)));\nblock3 = step(depth, dot(texture(cc_spotLightingMap, vec2(clipPos_offset.x, clipPos_offset.y)), vec4(1.0, 1.0 / 255.0, 1.0 / 65025.0, 1.0 / 16581375.0)));\n} else {\nblock0 = step(depth, texture(cc_spotLightingMap, vec2(clipPos.x, clipPos.y)).x);\nblock1 = step(depth, texture(cc_spotLightingMap, vec2(clipPos_offset.x, clipPos.y)).x);\nblock2 = step(depth, texture(cc_spotLightingMap, vec2(clipPos.x, clipPos_offset.y)).x);\nblock3 = step(depth, texture(cc_spotLightingMap, vec2(clipPos_offset.x, clipPos_offset.y)).x);\n}\nfloat coefX = mod(clipPos.x, oneTap.x) * cc_shadowWHPBInfo.x;\nfloat resultX = mix(block0, block1, coefX);\nfloat resultY = mix(block2, block3, coefX);\nfloat coefY = mod(clipPos.y, oneTap.y) * cc_shadowWHPBInfo.y;\nreturn mix(resultX, resultY, coefY);\n}\nfloat CCGetSpotLightShadowFactorSoft2X (vec4 shadowPos, vec3 worldPos) {\nvec4 clipPosNew = ApplyShadowDepthBias_Perspective(shadowPos, cc_shadowWHPBInfo.w);\nvec3 clipPos = clipPosNew.xyz / clipPosNew.w * 0.5 + 0.5;\nif (clipPos.x < 0.0 || clipPos.x > 1.0 ||\nclipPos.y < 0.0 || clipPos.y > 1.0 ||\nclipPos.z < 0.0 || clipPos.z > 1.0) { return 1.0; }\nclipPos.xy = cc_cameraPos.w == 1.0 ? vec2(clipPos.xy.x, 1.0 - clipPos.xy.y) : clipPos.xy;\nfloat depth = 0.0;\nif (cc_shadowNFLSInfo.z > 0.000001) {\ndepth = CCGetLinearDepth(worldPos);\n} else {\ndepth = clipPos.z;\n}\nfloat bias = cc_shadowWHPBInfo.w;\nvec2 mapSize = cc_shadowWHPBInfo.xy;\nvec2 oneTap = 1.0 / mapSize;\nfloat clipPos_offset_L = clipPos.x - oneTap.x;\nfloat clipPos_offset_R = clipPos.x + oneTap.x;\nfloat clipPos_offset_U = clipPos.y - oneTap.y;\nfloat clipPos_offset_D = clipPos.y + oneTap.y;\nfloat block0, block1, block2, block3, block4, block5, block6, block7, block8;\nif (cc_shadowLPNNInfo.y > 0.000001) {\nblock0 = step(depth, dot(texture(cc_spotLightingMap, vec2(clipPos_offset_L, clipPos_offset_U)), vec4(1.0, 1.0 / 255.0, 1.0 / 65025.0, 1.0 / 16581375.0)));\nblock1 = step(depth, dot(texture(cc_spotLightingMap, vec2(clipPos.x, clipPos_offset_U)), vec4(1.0, 1.0 / 255.0, 1.0 / 65025.0, 1.0 / 16581375.0)));\nblock2 = step(depth, dot(texture(cc_spotLightingMap, vec2(clipPos_offset_R, clipPos_offset_U)), vec4(1.0, 1.0 / 255.0, 1.0 / 65025.0, 1.0 / 16581375.0)));\nblock3 = step(depth, dot(texture(cc_spotLightingMap, vec2(clipPos_offset_L, clipPos.y)), vec4(1.0, 1.0 / 255.0, 1.0 / 65025.0, 1.0 / 16581375.0)));\nblock4 = step(depth, dot(texture(cc_spotLightingMap, vec2(clipPos.x, clipPos.y)), vec4(1.0, 1.0 / 255.0, 1.0 / 65025.0, 1.0 / 16581375.0)));\nblock5 = step(depth, dot(texture(cc_spotLightingMap, vec2(clipPos_offset_R, clipPos.y)), vec4(1.0, 1.0 / 255.0, 1.0 / 65025.0, 1.0 / 16581375.0)));\nblock6 = step(depth, dot(texture(cc_spotLightingMap, vec2(clipPos_offset_L, clipPos_offset_D)), vec4(1.0, 1.0 / 255.0, 1.0 / 65025.0, 1.0 / 16581375.0)));\nblock7 = step(depth, dot(texture(cc_spotLightingMap, vec2(clipPos.x, clipPos_offset_D)), vec4(1.0, 1.0 / 255.0, 1.0 / 65025.0, 1.0 / 16581375.0)));\nblock8 = step(depth, dot(texture(cc_spotLightingMap, vec2(clipPos_offset_R, clipPos_offset_D)), vec4(1.0, 1.0 / 255.0, 1.0 / 65025.0, 1.0 / 16581375.0)));\n} else {\nblock0 = step(depth, texture(cc_spotLightingMap, vec2(clipPos_offset_L, clipPos_offset_U)).x);\nblock1 = step(depth, texture(cc_spotLightingMap, vec2(clipPos.x, clipPos_offset_U)).x);\nblock2 = step(depth, texture(cc_spotLightingMap, vec2(clipPos_offset_R, clipPos_offset_U)).x);\nblock3 = step(depth, texture(cc_spotLightingMap, vec2(clipPos_offset_L, clipPos.y)).x);\nblock4 = step(depth, texture(cc_spotLightingMap, vec2(clipPos.x, clipPos.y)).x);\nblock5 = step(depth, texture(cc_spotLightingMap, vec2(clipPos_offset_R, clipPos.y)).x);\nblock6 = step(depth, texture(cc_spotLightingMap, vec2(clipPos_offset_L, clipPos_offset_D)).x);\nblock7 = step(depth, texture(cc_spotLightingMap, vec2(clipPos.x, clipPos_offset_D)).x);\nblock8 = step(depth, texture(cc_spotLightingMap, vec2(clipPos_offset_R, clipPos_offset_D)).x);\n}\nfloat coefX = mod(clipPos.x, oneTap.x) * mapSize.x;\nfloat coefY = mod(clipPos.y, oneTap.y) * mapSize.y;\nfloat shadow = 0.0;\nfloat resultX = mix(block0, block1, coefX);\nfloat resultY = mix(block3, block4, coefX);\nshadow += mix(resultX , resultY, coefY);\nresultX = mix(block1, block2, coefX);\nresultY = mix(block4, block5, coefX);\nshadow += mix(resultX , resultY, coefY);\nresultX = mix(block3, block4, coefX);\nresultY = mix(block6, block7, coefX);\nshadow += mix(resultX, resultY, coefY);\nresultX = mix(block4, block5, coefX);\nresultY = mix(block7, block8, coefX);\nshadow += mix(resultX, resultY, coefY);\nreturn shadow * 0.25;\n}\n#endif\n#if CC_USE_IBL\nuniform samplerCube cc_environment;\nvec4 fragTextureLod (sampler2D tex, vec2 coord, float lod) {\nreturn textureLod(tex, coord, lod);\n}\nvec4 fragTextureLod (samplerCube tex, vec3 coord, float lod) {\nreturn textureLod(tex, coord, lod);\n}\nvec3 unpackRGBE (vec4 rgbe) {\nreturn rgbe.rgb * pow(1.1, rgbe.a * 255.0 - 128.0);\n}\n#if CC_USE_DIFFUSEMAP\nuniform samplerCube cc_diffuseMap;\n#endif\n#endif\nfloat GGXMobile (float roughness, float NoH, vec3 H, vec3 N) {\nvec3 NxH = cross(N, H);\nfloat OneMinusNoHSqr = dot(NxH, NxH);\nfloat a = roughness * roughness;\nfloat n = NoH * a;\nfloat p = a / (OneMinusNoHSqr + n * n);\nreturn p * p;\n}\nfloat CalcSpecular (float roughness, float NoH, vec3 H, vec3 N) {\nreturn (roughness * 0.25 + 0.25) * GGXMobile(roughness, NoH, H, N);\n}\nvec3 BRDFApprox (vec3 specular, float roughness, float NoV) {\nconst vec4 c0 = vec4(-1.0, -0.0275, -0.572, 0.022);\nconst vec4 c1 = vec4(1.0, 0.0425, 1.04, -0.04);\nvec4 r = roughness * c0 + c1;\nfloat a004 = min(r.x * r.x, exp2(-9.28 * NoV)) * r.x + r.y;\nvec2 AB = vec2(-1.04, 1.04) * a004 + r.zw;\nAB.y *= clamp(50.0 * specular.g, 0.0, 1.0);\nreturn specular * AB.x + AB.y;\n}\n#if USE_REFLECTION_DENOISE\nvec3 GetEnvReflectionWithMipFiltering(vec3 R, float roughness, float mipCount, float denoiseIntensity) {\n#if CC_USE_IBL\nfloat mip = roughness * mipCount;\nfloat delta = (dot(dFdx(R), dFdy(R))) * 1000.0;\nfloat mipBias = mix(0.0, 5.0, clamp(delta, 0.0, 1.0));\nvec4 biased = fragTextureLod(cc_environment, R, mip + mipBias);\nvec4 filtered = texture(cc_environment, R);\n#if CC_USE_IBL == 2\nbiased.rgb = unpackRGBE(biased);\nfiltered.rgb = unpackRGBE(filtered);\n#else\nbiased.rgb = SRGBToLinear(biased.rgb);\nfiltered.rgb = SRGBToLinear(filtered.rgb);\n#endif\nreturn mix(biased.rgb, filtered.rgb, denoiseIntensity);\n#else\nreturn vec3(0.0, 0.0, 0.0);\n#endif\n}\n#endif\nstruct StandardSurface {\nvec4 albedo;\nvec3 position;\nvec3 normal;\nvec3 emissive;\nvec3 lightmap;\nfloat lightmap_test;\nfloat roughness;\nfloat metallic;\nfloat occlusion;\n};\nvec4 CCStandardShadingBase (StandardSurface s, vec4 shadowPos) {\nvec3 diffuse = s.albedo.rgb * (1.0 - s.metallic);\nvec3 specular = mix(vec3(0.04), s.albedo.rgb, s.metallic);\nvec3 N = normalize(s.normal);\nvec3 V = normalize(cc_cameraPos.xyz - s.position);\nfloat NV = max(abs(dot(N, V)), 0.0);\nspecular = BRDFApprox(specular, s.roughness, NV);\nvec3 L = normalize(-cc_mainLitDir.xyz);\nvec3 H = normalize(L + V);\nfloat NH = max(dot(N, H), 0.0);\nfloat NL = max(dot(N, L), 0.0);\nvec3 finalColor = NL * cc_mainLitColor.rgb * cc_mainLitColor.w;\nvec3 diffuseContrib = diffuse;\n#if USE_LIGHTMAP && !USE_BATCHING && !CC_FORWARD_ADD\nif (s.lightmap_test > 0.0001) {\nfinalColor = s.lightmap.rgb;\n}\n#else\ndiffuseContrib /= 3.14159265359;\n#endif\nvec3 specularContrib = specular * CalcSpecular(s.roughness, NH, H, N);\nvec3 dirlightContrib = (diffuseContrib + specularContrib);\nfloat shadow = 1.0;\n#if CC_RECEIVE_SHADOW && CC_ENABLE_DIR_SHADOW\nif (NL > 0.0) {\n{\nvec4 pos = ApplyShadowDepthBias_FaceNormal(shadowPos, N);\nfloat pcf = cc_shadowWHPBInfo.z;\nif (pcf > 1.9) shadow = CCGetShadowFactorSoft2X(pos);\nelse if (pcf > 0.9) shadow = CCGetShadowFactorSoft(pos);\nelse shadow = CCGetShadowFactorHard(pos);\nshadow = mix(shadow, 1.0, cc_shadowNFLSInfo.w);\n}\n}\n#endif\ndirlightContrib *= shadow;\nfinalColor *= dirlightContrib;\nfloat fAmb = 0.5 - N.y * 0.5;\nvec3 ambDiff = mix(cc_ambientSky.rgb, cc_ambientGround.rgb, fAmb);\n#if CC_USE_IBL\n#if CC_USE_DIFFUSEMAP\nvec4 diffuseMap = texture(cc_diffuseMap, N);\n#if CC_USE_DIFFUSEMAP == 2\nambDiff = unpackRGBE(diffuseMap);\n#else\nambDiff = SRGBToLinear(diffuseMap.rgb);\n#endif\n#endif\nvec3 R = normalize(reflect(-V, N));\n#if USE_REFLECTION_DENOISE\nvec3 env = GetEnvReflectionWithMipFiltering(R, s.roughness, cc_ambientGround.w, 0.6);\n#else\nvec4 envmap = fragTextureLod(cc_environment, R, s.roughness * cc_ambientGround.w);\n#if CC_USE_IBL == 2\nvec3 env = unpackRGBE(envmap);\n#else\nvec3 env = SRGBToLinear(envmap.rgb);\n#endif\n#endif\nfinalColor += env * cc_ambientSky.w * specular * s.occlusion;\n#endif\nfinalColor += ambDiff.rgb * cc_ambientSky.w * diffuse * s.occlusion;\nfinalColor += s.emissive;\nreturn vec4(finalColor, s.albedo.a);\n}\nvec3 ACESToneMap (vec3 color) {\ncolor = min(color, vec3(8.0));\nconst float A = 2.51;\nconst float B = 0.03;\nconst float C = 2.43;\nconst float D = 0.59;\nconst float E = 0.14;\nreturn (color * (A * color + B)) / (color * (C * color + D) + E);\n}\nvec4 CCFragOutput (vec4 color) {\n#if CC_USE_HDR\ncolor.rgb = ACESToneMap(color.rgb);\n#endif\ncolor.rgb = sqrt(color.rgb);\nreturn color;\n}\nin highp vec4 v_shadowPos;\n#if USE_LIGHTMAP && !USE_BATCHING && !CC_FORWARD_ADD\nin vec3 v_luv;\nuniform sampler2D cc_lightingMap;\nvec3 UnpackLightingmap(vec4 color) {\nvec3 c;\nfloat e = 1.0 + color.a * (8.0 - 1.0);\nc.r = color.r * e;\nc.g = color.g * e;\nc.b = color.b * e;\nreturn c;\n}\n#endif\nin vec3 v_position;\nin vec2 v_uv;\nin vec2 v_uv1;\nin vec3 v_normal;\n#if USE_VERTEX_COLOR\nin vec4 v_color;\n#endif\n#if USE_ALBEDO_MAP\nuniform sampler2D albedoMap;\n#endif\n#if USE_NORMAL_MAP\nin vec3 v_tangent;\nin vec3 v_bitangent;\nuniform sampler2D normalMap;\n#endif\n#if USE_PBR_MAP\nuniform sampler2D pbrMap;\n#endif\n#if USE_METALLIC_ROUGHNESS_MAP\nuniform sampler2D metallicRoughnessMap;\n#endif\n#if USE_OCCLUSION_MAP\nuniform sampler2D occlusionMap;\n#endif\n#if USE_EMISSIVE_MAP\nuniform sampler2D emissiveMap;\n#endif\n#if USE_ALPHA_TEST\n#endif\nvoid surf (out StandardSurface s) {\nvec4 baseColor = albedo;\n#if USE_VERTEX_COLOR\nbaseColor.rgb *= SRGBToLinear(v_color.rgb);\nbaseColor.a *= v_color.a;\n#endif\n#if USE_ALBEDO_MAP\nvec4 texColor = texture(albedoMap, ALBEDO_UV);\ntexColor.rgb = SRGBToLinear(texColor.rgb);\nbaseColor *= texColor;\n#endif\ns.albedo = baseColor;\ns.albedo.rgb *= albedoScaleAndCutoff.xyz;\n#if USE_ALPHA_TEST\nif (s.albedo.ALPHA_TEST_CHANNEL < albedoScaleAndCutoff.w) discard;\n#endif\n#if USE_LIGHTMAP && !USE_BATCHING && !CC_FORWARD_ADD\nvec4 lightColor = texture(cc_lightingMap, v_luv.xy);\ns.lightmap = UnpackLightingmap(lightColor);\ns.lightmap_test = v_luv.z;\n#endif\ns.normal = v_normal;\n#if USE_NORMAL_MAP\nvec3 nmmp = texture(normalMap, NORMAL_UV).xyz - vec3(0.5);\ns.normal =\n(nmmp.x * emissiveScaleParam.w) * normalize(v_tangent) +\n(nmmp.y * emissiveScaleParam.w) * normalize(v_bitangent) +\nnmmp.z * normalize(s.normal);\n#endif\ns.position = v_position;\nvec4 pbr = pbrParams;\n#if USE_PBR_MAP\nvec4 res = texture(pbrMap, PBR_UV);\npbr.x *= res.r;\npbr.y *= res.g;\npbr.z *= res.b;\npbr.w *= res.a;\n#endif\n#if USE_METALLIC_ROUGHNESS_MAP\nvec4 metallicRoughness = texture(metallicRoughnessMap, PBR_UV);\npbr.z *= metallicRoughness.b;\npbr.y *= metallicRoughness.g;\n#endif\n#if USE_OCCLUSION_MAP\npbr.x *= texture(occlusionMap, PBR_UV).r;\n#endif\ns.occlusion = pbr.x;\ns.roughness = pbr.y;\ns.metallic = pbr.z;\ns.emissive = emissive.rgb * emissiveScaleParam.xyz;\n#if USE_EMISSIVE_MAP\ns.emissive *= SRGBToLinear(texture(emissiveMap, EMISSIVE_UV).rgb);\n#endif\n}\n#if CC_FORWARD_ADD\n#if CC_PIPELINE_TYPE == 0\n# define LIGHTS_PER_PASS 1\n#else\n# define LIGHTS_PER_PASS 10\n#endif\n#if CC_ENABLE_CLUSTERED_LIGHT_CULLING == 0\nlayout(std140) uniform CCForwardLight {\nhighp vec4 cc_lightPos[LIGHTS_PER_PASS];\nvec4 cc_lightColor[LIGHTS_PER_PASS];\nvec4 cc_lightSizeRangeAngle[LIGHTS_PER_PASS];\nvec4 cc_lightDir[LIGHTS_PER_PASS];\n};\n#endif\nfloat SmoothDistAtt (float distSqr, float invSqrAttRadius) {\nfloat factor = distSqr * invSqrAttRadius;\nfloat smoothFactor = clamp(1.0 - factor * factor, 0.0, 1.0);\nreturn smoothFactor * smoothFactor;\n}\nfloat GetDistAtt (float distSqr, float invSqrAttRadius) {\nfloat attenuation = 1.0 / max(distSqr, 0.01*0.01);\nattenuation *= SmoothDistAtt(distSqr , invSqrAttRadius);\nreturn attenuation;\n}\nfloat GetAngleAtt (vec3 L, vec3 litDir, float litAngleScale, float litAngleOffset) {\nfloat cd = dot(litDir, L);\nfloat attenuation = clamp(cd * litAngleScale + litAngleOffset, 0.0, 1.0);\nreturn (attenuation * attenuation);\n}\n#if CC_ENABLE_CLUSTERED_LIGHT_CULLING == 0\nvec4 CCStandardShadingAdditive (StandardSurface s, vec4 shadowPos) {\nvec3 diffuse = s.albedo.rgb * (1.0 - s.metallic);\nvec3 specular = mix(vec3(0.04), s.albedo.rgb, s.metallic);\nvec3 diffuseContrib = diffuse / 3.14159265359;\nvec3 N = normalize(s.normal);\nvec3 V = normalize(cc_cameraPos.xyz - s.position);\nfloat NV = max(abs(dot(N, V)), 0.0);\nspecular = BRDFApprox(specular, s.roughness, NV);\nvec3 finalColor = vec3(0.0);\nint numLights = CC_PIPELINE_TYPE == 0 ? LIGHTS_PER_PASS : int(cc_lightDir[0].w);\nfor (int i = 0; i < LIGHTS_PER_PASS; i++) {\nif (i >= numLights) break;\nvec3 SLU = cc_lightPos[i].xyz - s.position;\nvec3 SL = normalize(SLU);\nvec3 SH = normalize(SL + V);\nfloat SNL = max(dot(N, SL), 0.0);\nfloat SNH = max(dot(N, SH), 0.0);\nfloat distSqr = dot(SLU, SLU);\nfloat litRadius = cc_lightSizeRangeAngle[i].x;\nfloat litRadiusSqr = litRadius * litRadius;\nfloat illum = 3.14159265359 * (litRadiusSqr / max(litRadiusSqr , distSqr));\nfloat attRadiusSqrInv = 1.0 / max(cc_lightSizeRangeAngle[i].y, 0.01);\nattRadiusSqrInv *= attRadiusSqrInv;\nfloat att = GetDistAtt(distSqr, attRadiusSqrInv);\nvec3 lspec = specular * CalcSpecular(s.roughness, SNH, SH, N);\nif (cc_lightPos[i].w > 0.0) {\nfloat cosInner = max(dot(-cc_lightDir[i].xyz, SL), 0.01);\nfloat cosOuter = cc_lightSizeRangeAngle[i].z;\nfloat litAngleScale = 1.0 / max(0.001, cosInner - cosOuter);\nfloat litAngleOffset = -cosOuter * litAngleScale;\natt *= GetAngleAtt(SL, -cc_lightDir[i].xyz, litAngleScale, litAngleOffset);\n}\nvec3 lightColor = cc_lightColor[i].rgb;\nfloat shadow = 1.0;\n#if CC_RECEIVE_SHADOW\nif (cc_lightPos[i].w > 0.0 && cc_lightSizeRangeAngle[i].w > 0.0) {\n{\nfloat pcf = cc_shadowWHPBInfo.z;\nif (pcf > 1.9) shadow = CCGetSpotLightShadowFactorSoft2X(shadowPos, s.position);\nelse if (pcf > 0.9) shadow = CCGetSpotLightShadowFactorSoft(shadowPos, s.position);\nelse shadow = CCGetSpotLightShadowFactorHard(shadowPos, s.position);\n}\n}\n#endif\nlightColor *= shadow;\nfinalColor += SNL * lightColor * cc_lightColor[i].w * illum * att * (diffuseContrib + lspec);\n}\nreturn vec4(finalColor, 0.0);\n}\n#endif\n#if CC_ENABLE_CLUSTERED_LIGHT_CULLING == 1\nlayout(std430, binding = 4) readonly buffer b_ccLightsBuffer { vec4 b_ccLights[]; };\nlayout(std430, binding = 5) readonly buffer b_clusterLightIndicesBuffer { uint b_clusterLightIndices[]; };\nlayout(std430, binding = 6) readonly buffer b_clusterLightGridBuffer { uvec4 b_clusterLightGrid[]; };\nstruct CCLight\n{\nvec4 cc_lightPos;\nvec4 cc_lightColor;\nvec4 cc_lightSizeRangeAngle;\nvec4 cc_lightDir;\n};\nstruct Cluster\n{\nvec3 minBounds;\nvec3 maxBounds;\n};\nstruct LightGrid\n{\nuint offset;\nuint ccLights;\n};\nCCLight getCCLight(uint i)\n{\nCCLight light;\nlight.cc_lightPos = b_ccLights[4u * i + 0u];\nlight.cc_lightColor = b_ccLights[4u * i + 1u];\nlight.cc_lightSizeRangeAngle = b_ccLights[4u * i + 2u];\nlight.cc_lightDir = b_ccLights[4u * i + 3u];\nreturn light;\n}\nLightGrid getLightGrid(uint cluster)\n{\nuvec4 gridvec = b_clusterLightGrid[cluster];\nLightGrid grid;\ngrid.offset = gridvec.x;\ngrid.ccLights = gridvec.y;\nreturn grid;\n}\nuint getGridLightIndex(uint start, uint offset)\n{\nreturn b_clusterLightIndices[start + offset];\n}\nuint getClusterZIndex(vec4 worldPos)\n{\nfloat scale = float(24) / log(cc_nearFar.y / cc_nearFar.x);\nfloat bias = -(float(24) * log(cc_nearFar.x) / log(cc_nearFar.y / cc_nearFar.x));\nfloat eyeDepth = -(cc_matView * worldPos).z;\nuint zIndex = uint(max(log(eyeDepth) * scale + bias, 0.0));\nreturn zIndex;\n}\nuint getClusterIndex(vec4 fragCoord, vec4 worldPos)\n{\nuint zIndex = getClusterZIndex(worldPos);\nfloat clusterSizeX = ceil(cc_screenSize.x / float(16));\nfloat clusterSizeY = ceil(cc_screenSize.y / float(8));\nuvec3 indices = uvec3(uvec2(fragCoord.xy / vec2(clusterSizeX, clusterSizeY)), zIndex);\nuint cluster = (16u * 8u) * indices.z + 16u * indices.y + indices.x;\nreturn cluster;\n}\nvec4 CCClusterShadingAdditive (StandardSurface s, vec4 shadowPos) {\nvec3 diffuse = s.albedo.rgb * (1.0 - s.metallic);\nvec3 specular = mix(vec3(0.04), s.albedo.rgb, s.metallic);\nvec3 diffuseContrib = diffuse / 3.14159265359;\nvec3 N = normalize(s.normal);\nvec3 V = normalize(cc_cameraPos.xyz - s.position);\nfloat NV = max(abs(dot(N, V)), 0.001);\nspecular = BRDFApprox(specular, s.roughness, NV);\nvec3 finalColor = vec3(0.0);\nuint cluster = getClusterIndex(gl_FragCoord, vec4(s.position, 1.0));\nLightGrid grid = getLightGrid(cluster);\nuint numLights = grid.ccLights;\nfor (uint i = 0u; i < 100u; i++) {\nif (i >= numLights) break;\nuint lightIndex = getGridLightIndex(grid.offset, i);\nCCLight light = getCCLight(lightIndex);\nvec3 SLU = light.cc_lightPos.xyz - s.position;\nvec3 SL = normalize(SLU);\nvec3 SH = normalize(SL + V);\nfloat SNL = max(dot(N, SL), 0.001);\nfloat SNH = max(dot(N, SH), 0.0);\nfloat distSqr = dot(SLU, SLU);\nfloat litRadius = light.cc_lightSizeRangeAngle.x;\nfloat litRadiusSqr = litRadius * litRadius;\nfloat illum = 3.14159265359 * (litRadiusSqr / max(litRadiusSqr , distSqr));\nfloat attRadiusSqrInv = 1.0 / max(light.cc_lightSizeRangeAngle.y, 0.01);\nattRadiusSqrInv *= attRadiusSqrInv;\nfloat att = GetDistAtt(distSqr, attRadiusSqrInv);\nvec3 lspec = specular * CalcSpecular(s.roughness, SNH, SH, N);\nif (light.cc_lightPos.w > 0.0) {\nfloat cosInner = max(dot(-light.cc_lightDir.xyz, SL), 0.01);\nfloat cosOuter = light.cc_lightSizeRangeAngle.z;\nfloat litAngleScale = 1.0 / max(0.001, cosInner - cosOuter);\nfloat litAngleOffset = -cosOuter * litAngleScale;\natt *= GetAngleAtt(SL, -light.cc_lightDir.xyz, litAngleScale, litAngleOffset);\n}\nvec3 lightColor = light.cc_lightColor.rgb;\nfloat shadow = 1.0;\n#if CC_RECEIVE_SHADOW\nif (light.cc_lightPos.w > 0.0) {\n{\nfloat pcf = cc_shadowWHPBInfo.z;\nif (pcf > 1.9) shadow = CCGetSpotLightShadowFactorSoft2X(shadowPos, s.position);\nelse if (pcf > 0.9) shadow = CCGetSpotLightShadowFactorSoft(shadowPos, s.position);\nelse shadow = CCGetSpotLightShadowFactorHard(shadowPos, s.position);\n}\n}\n#endif\nlightColor *= shadow;\nfinalColor += SNL * lightColor * light.cc_lightColor.w * illum * att * (diffuseContrib + lspec);\n}\nreturn vec4(finalColor, 0.0);\n}\n#endif\nlayout(location = 0) out vec4 fragColorX;\nvoid main () {\nStandardSurface s; surf(s);\n#if CC_ENABLE_CLUSTERED_LIGHT_CULLING == 1\nvec4 color = CCClusterShadingAdditive(s, v_shadowPos);\n#else\nvec4 color = CCStandardShadingAdditive(s, v_shadowPos);\n#endif\nCC_APPLY_FOG(color, s.position.xyz);\nfragColorX = CCFragOutput(color);\n}\n#elif (CC_PIPELINE_TYPE == 0 || CC_FORCE_FORWARD_SHADING)\nlayout(location = 0) out vec4 fragColorX;\nvoid main () {\nStandardSurface s; surf(s);\nvec4 color = CCStandardShadingBase(s, v_shadowPos);\nCC_APPLY_FOG(color, s.position.xyz);\nfragColorX = CCFragOutput(color);\n}\n#elif CC_PIPELINE_TYPE == 1\nlayout(location = 0) out vec4 fragColor0;\nlayout(location = 1) out vec4 fragColor1;\nlayout(location = 2) out vec4 fragColor2;\nlayout(location = 3) out vec4 fragColor3;\nvoid main () {\nStandardSurface s; surf(s);\nfragColor0 = s.albedo;\nfragColor1 = vec4(s.position, s.roughness);\nfragColor2 = vec4(s.normal, s.metallic);\nfragColor3 = vec4(s.emissive, s.occlusion);\n}\n#endif", + }, + { + "vert": "\nprecision highp float;\nhighp float decode32 (highp vec4 rgba) {\nrgba = rgba * 255.0;\nhighp float Sign = 1.0 - (step(128.0, (rgba[3]) + 0.5)) * 2.0;\nhighp float Exponent = 2.0 * (mod(float(int((rgba[3]) + 0.5)), 128.0)) + (step(128.0, (rgba[2]) + 0.5)) - 127.0;\nhighp float Mantissa = (mod(float(int((rgba[2]) + 0.5)), 128.0)) * 65536.0 + rgba[1] * 256.0 + rgba[0] + 8388608.0;\nreturn Sign * exp2(Exponent - 23.0) * Mantissa;\n}\nstruct StandardVertInput {\nhighp vec4 position;\nvec3 normal;\nvec4 tangent;\n};\nin vec3 a_position;\nin vec3 a_normal;\nin vec2 a_texCoord;\nin vec4 a_tangent;\n#if CC_USE_MORPH\nin float a_vertexId;\nint getVertexId() {\nreturn int(a_vertexId);\n}\nlayout(std140) uniform CCMorph {\nvec4 cc_displacementWeights[15];\nvec4 cc_displacementTextureInfo;\n};\nvec2 getPixelLocation(vec2 textureResolution, int pixelIndex) {\nfloat pixelIndexF = float(pixelIndex);\nfloat x = mod(pixelIndexF, textureResolution.x);\nfloat y = floor(pixelIndexF / textureResolution.x);\nreturn vec2(x, y);\n}\nvec2 getPixelCoordFromLocation(vec2 location, vec2 textureResolution) {\nreturn (vec2(location.x, location.y) + .5) / textureResolution;\n}\n#if CC_DEVICE_SUPPORT_FLOAT_TEXTURE\nvec4 fetchVec3ArrayFromTexture(sampler2D tex, int pixelIndex) {\nivec2 texSize = textureSize(tex, 0);\nreturn texelFetch(tex, ivec2(pixelIndex % texSize.x, pixelIndex / texSize.x), 0);\n}\n#else\nvec4 fetchVec3ArrayFromTexture(sampler2D tex, int elementIndex) {\nint pixelIndex = elementIndex * 4;\nvec2 location = getPixelLocation(cc_displacementTextureInfo.xy, pixelIndex);\nvec2 x = getPixelCoordFromLocation(location + vec2(0.0, 0.0), cc_displacementTextureInfo.xy);\nvec2 y = getPixelCoordFromLocation(location + vec2(1.0, 0.0), cc_displacementTextureInfo.xy);\nvec2 z = getPixelCoordFromLocation(location + vec2(2.0, 0.0), cc_displacementTextureInfo.xy);\nreturn vec4(\ndecode32(texture(tex, x)),\ndecode32(texture(tex, y)),\ndecode32(texture(tex, z)),\n1.0\n);\n}\n#endif\nfloat getDisplacementWeight(int index) {\nint quot = index / 4;\nint remainder = index - quot * 4;\nif (remainder == 0) {\nreturn cc_displacementWeights[quot].x;\n} else if (remainder == 1) {\nreturn cc_displacementWeights[quot].y;\n} else if (remainder == 2) {\nreturn cc_displacementWeights[quot].z;\n} else {\nreturn cc_displacementWeights[quot].w;\n}\n}\nvec3 getVec3DisplacementFromTexture(sampler2D tex, int vertexIndex) {\n#if CC_MORPH_PRECOMPUTED\nreturn fetchVec3ArrayFromTexture(tex, vertexIndex).rgb;\n#else\nvec3 result = vec3(0, 0, 0);\nint nVertices = int(cc_displacementTextureInfo.z);\nfor (int iTarget = 0; iTarget < CC_MORPH_TARGET_COUNT; ++iTarget) {\nresult += (fetchVec3ArrayFromTexture(tex, nVertices * iTarget + vertexIndex).rgb * getDisplacementWeight(iTarget));\n}\nreturn result;\n#endif\n}\n#if CC_MORPH_TARGET_HAS_POSITION\nuniform sampler2D cc_PositionDisplacements;\nvec3 getPositionDisplacement(int vertexId) {\nreturn getVec3DisplacementFromTexture(cc_PositionDisplacements, vertexId);\n}\n#endif\n#if CC_MORPH_TARGET_HAS_NORMAL\nuniform sampler2D cc_NormalDisplacements;\nvec3 getNormalDisplacement(int vertexId) {\nreturn getVec3DisplacementFromTexture(cc_NormalDisplacements, vertexId);\n}\n#endif\n#if CC_MORPH_TARGET_HAS_TANGENT\nuniform sampler2D cc_TangentDisplacements;\nvec3 getTangentDisplacement(int vertexId) {\nreturn getVec3DisplacementFromTexture(cc_TangentDisplacements, vertexId);\n}\n#endif\nvoid applyMorph (inout StandardVertInput attr) {\nint vertexId = getVertexId();\n#if CC_MORPH_TARGET_HAS_POSITION\nattr.position.xyz = attr.position.xyz + getPositionDisplacement(vertexId);\n#endif\n#if CC_MORPH_TARGET_HAS_NORMAL\nattr.normal.xyz = attr.normal.xyz + getNormalDisplacement(vertexId);\n#endif\n#if CC_MORPH_TARGET_HAS_TANGENT\nattr.tangent.xyz = attr.tangent.xyz + getTangentDisplacement(vertexId);\n#endif\n}\nvoid applyMorph (inout vec4 position) {\n#if CC_MORPH_TARGET_HAS_POSITION\nposition.xyz = position.xyz + getPositionDisplacement(getVertexId());\n#endif\n}\n#endif\n#if CC_USE_SKINNING\nin vec4 a_joints;\nin vec4 a_weights;\n#if CC_USE_BAKED_ANIMATION\n#if USE_INSTANCING\nin highp vec4 a_jointAnimInfo;\n#endif\nlayout(std140) uniform CCSkinningTexture {\nhighp vec4 cc_jointTextureInfo;\n};\nlayout(std140) uniform CCSkinningAnimation {\nhighp vec4 cc_jointAnimInfo;\n};\nuniform highp sampler2D cc_jointTexture;\n#else\nlayout(std140) uniform CCSkinning {\nhighp vec4 cc_joints[30 * 3];\n};\n#endif\n#if CC_USE_BAKED_ANIMATION\n#if CC_DEVICE_SUPPORT_FLOAT_TEXTURE\nmat4 getJointMatrix (float i) {\n#if USE_INSTANCING\nhighp float j = 3.0 * (a_jointAnimInfo.x * a_jointAnimInfo.y + i) + a_jointAnimInfo.z;\n#else\nhighp float j = 3.0 * (cc_jointAnimInfo.x * cc_jointTextureInfo.y + i) + cc_jointTextureInfo.z;\n#endif\nhighp float invSize = cc_jointTextureInfo.w;\nhighp float y = floor(j * invSize);\nhighp float x = floor(j - y * cc_jointTextureInfo.x);\ny = (y + 0.5) * invSize;\nvec4 v1 = texture(cc_jointTexture, vec2((x + 0.5) * invSize, y));\nvec4 v2 = texture(cc_jointTexture, vec2((x + 1.5) * invSize, y));\nvec4 v3 = texture(cc_jointTexture, vec2((x + 2.5) * invSize, y));\nreturn mat4(vec4(v1.xyz, 0.0), vec4(v2.xyz, 0.0), vec4(v3.xyz, 0.0), vec4(v1.w, v2.w, v3.w, 1.0));\n}\n#else\nmat4 getJointMatrix (float i) {\n#if USE_INSTANCING\nhighp float j = 12.0 * (a_jointAnimInfo.x * a_jointAnimInfo.y + i) + a_jointAnimInfo.z;\n#else\nhighp float j = 12.0 * (cc_jointAnimInfo.x * cc_jointTextureInfo.y + i) + cc_jointTextureInfo.z;\n#endif\nhighp float invSize = cc_jointTextureInfo.w;\nhighp float y = floor(j * invSize);\nhighp float x = floor(j - y * cc_jointTextureInfo.x);\ny = (y + 0.5) * invSize;\nvec4 v1 = vec4(\ndecode32(texture(cc_jointTexture, vec2((x + 0.5) * invSize, y))),\ndecode32(texture(cc_jointTexture, vec2((x + 1.5) * invSize, y))),\ndecode32(texture(cc_jointTexture, vec2((x + 2.5) * invSize, y))),\ndecode32(texture(cc_jointTexture, vec2((x + 3.5) * invSize, y)))\n);\nvec4 v2 = vec4(\ndecode32(texture(cc_jointTexture, vec2((x + 4.5) * invSize, y))),\ndecode32(texture(cc_jointTexture, vec2((x + 5.5) * invSize, y))),\ndecode32(texture(cc_jointTexture, vec2((x + 6.5) * invSize, y))),\ndecode32(texture(cc_jointTexture, vec2((x + 7.5) * invSize, y)))\n);\nvec4 v3 = vec4(\ndecode32(texture(cc_jointTexture, vec2((x + 8.5) * invSize, y))),\ndecode32(texture(cc_jointTexture, vec2((x + 9.5) * invSize, y))),\ndecode32(texture(cc_jointTexture, vec2((x + 10.5) * invSize, y))),\ndecode32(texture(cc_jointTexture, vec2((x + 11.5) * invSize, y)))\n);\nreturn mat4(vec4(v1.xyz, 0.0), vec4(v2.xyz, 0.0), vec4(v3.xyz, 0.0), vec4(v1.w, v2.w, v3.w, 1.0));\n}\n#endif\n#else\nmat4 getJointMatrix (float i) {\nint idx = int(i);\nvec4 v1 = cc_joints[idx * 3];\nvec4 v2 = cc_joints[idx * 3 + 1];\nvec4 v3 = cc_joints[idx * 3 + 2];\nreturn mat4(vec4(v1.xyz, 0.0), vec4(v2.xyz, 0.0), vec4(v3.xyz, 0.0), vec4(v1.w, v2.w, v3.w, 1.0));\n}\n#endif\nmat4 skinMatrix () {\nvec4 joints = vec4(a_joints);\nreturn getJointMatrix(joints.x) * a_weights.x\n+ getJointMatrix(joints.y) * a_weights.y\n+ getJointMatrix(joints.z) * a_weights.z\n+ getJointMatrix(joints.w) * a_weights.w;\n}\nvoid CCSkin (inout vec4 position) {\nmat4 m = skinMatrix();\nposition = m * position;\n}\nvoid CCSkin (inout StandardVertInput attr) {\nmat4 m = skinMatrix();\nattr.position = m * attr.position;\nattr.normal = (m * vec4(attr.normal, 0.0)).xyz;\nattr.tangent.xyz = (m * vec4(attr.tangent.xyz, 0.0)).xyz;\n}\n#endif\n#if USE_INSTANCING\nin vec4 a_matWorld0;\nin vec4 a_matWorld1;\nin vec4 a_matWorld2;\n#if USE_LIGHTMAP\nin vec4 a_lightingMapUVParam;\n#endif\n#elif USE_BATCHING\nin float a_dyn_batch_id;\nlayout(std140) uniform CCLocalBatched {\nhighp mat4 cc_matWorlds[10];\n};\n#else\nlayout(std140) uniform CCLocal {\nhighp mat4 cc_matWorld;\nhighp mat4 cc_matWorldIT;\nhighp vec4 cc_lightingMapUVParam;\n};\n#endif\nlayout(std140) uniform Constants {\nvec4 tilingOffset;\nvec4 albedo;\nvec4 albedoScaleAndCutoff;\nvec4 pbrParams;\nvec4 emissive;\nvec4 emissiveScaleParam;\n};\nlayout(std140) uniform CCShadow {\nhighp mat4 cc_matLightPlaneProj;\nhighp mat4 cc_matLightView;\nhighp mat4 cc_matLightViewProj;\nhighp vec4 cc_shadowInvProjDepthInfo;\nhighp vec4 cc_shadowProjDepthInfo;\nhighp vec4 cc_shadowProjInfo;\nlowp vec4 cc_shadowNFLSInfo;\nlowp vec4 cc_shadowWHPBInfo;\nlowp vec4 cc_shadowLPNNInfo;\nlowp vec4 cc_shadowColor;\n};\n#if HAS_SECOND_UV || USE_LIGHTMAP\nin vec2 a_texCoord1;\n#endif\nout vec2 v_uv;\nout vec2 v_uv1;\nout vec4 v_worldPos;\nout float v_clip_depth;\nvec4 vert () {\nStandardVertInput In;\nIn.position = vec4(a_position, 1.0);\nIn.normal = a_normal;\nIn.tangent = a_tangent;\n#if CC_USE_MORPH\napplyMorph(In);\n#endif\n#if CC_USE_SKINNING\nCCSkin(In);\n#endif\nmat4 matWorld, matWorldIT;\n#if USE_INSTANCING\nmatWorld = mat4(\nvec4(a_matWorld0.xyz, 0.0),\nvec4(a_matWorld1.xyz, 0.0),\nvec4(a_matWorld2.xyz, 0.0),\nvec4(a_matWorld0.w, a_matWorld1.w, a_matWorld2.w, 1.0)\n);\nmatWorldIT = matWorld;\n#elif USE_BATCHING\nmatWorld = cc_matWorlds[int(a_dyn_batch_id)];\nmatWorldIT = matWorld;\n#else\nmatWorld = cc_matWorld;\nmatWorldIT = cc_matWorldIT;\n#endif\nv_worldPos = matWorld * In.position;\nvec4 clipPos = cc_matLightViewProj * v_worldPos;\nv_uv = a_texCoord * tilingOffset.xy + tilingOffset.zw;\n#if HAS_SECOND_UV\nv_uv1 = a_texCoord1 * tilingOffset.xy + tilingOffset.zw;\n#endif\nv_clip_depth = clipPos.z / clipPos.w * 0.5 + 0.5;\nreturn clipPos;\n}\nvoid main() { gl_Position = vert(); }", + "frag": "\nprecision highp float;\nlayout(std140) uniform Constants {\nvec4 tilingOffset;\nvec4 albedo;\nvec4 albedoScaleAndCutoff;\nvec4 pbrParams;\nvec4 emissive;\nvec4 emissiveScaleParam;\n};\nvec4 packDepthToRGBA (float depth) {\nvec4 ret = vec4(1.0, 255.0, 65025.0, 16581375.0) * depth;\nret = fract(ret);\nret -= vec4(ret.yzw, 0.0) / 255.0;\nreturn ret;\n}\nlayout(std140) uniform CCGlobal {\nhighp vec4 cc_time;\nmediump vec4 cc_screenSize;\nmediump vec4 cc_nativeSize;\n};\nlayout(std140) uniform CCCamera {\nhighp mat4 cc_matView;\nhighp mat4 cc_matViewInv;\nhighp mat4 cc_matProj;\nhighp mat4 cc_matProjInv;\nhighp mat4 cc_matViewProj;\nhighp mat4 cc_matViewProjInv;\nhighp vec4 cc_cameraPos;\nmediump vec4 cc_screenScale;\nmediump vec4 cc_exposure;\nmediump vec4 cc_mainLitDir;\nmediump vec4 cc_mainLitColor;\nmediump vec4 cc_ambientSky;\nmediump vec4 cc_ambientGround;\nmediump vec4 cc_fogColor;\nmediump vec4 cc_fogBase;\nmediump vec4 cc_fogAdd;\nmediump vec4 cc_nearFar;\nmediump vec4 cc_viewPort;\n};\nlayout(std140) uniform CCShadow {\nhighp mat4 cc_matLightPlaneProj;\nhighp mat4 cc_matLightView;\nhighp mat4 cc_matLightViewProj;\nhighp vec4 cc_shadowInvProjDepthInfo;\nhighp vec4 cc_shadowProjDepthInfo;\nhighp vec4 cc_shadowProjInfo;\nlowp vec4 cc_shadowNFLSInfo;\nlowp vec4 cc_shadowWHPBInfo;\nlowp vec4 cc_shadowLPNNInfo;\nlowp vec4 cc_shadowColor;\n};\nfloat CCGetLinearDepthFromViewSpace(vec3 viewPos) {\nfloat dist = length(viewPos);\nreturn (dist - cc_shadowNFLSInfo.x) / (cc_shadowNFLSInfo.y - cc_shadowNFLSInfo.x);\n}\nfloat CCGetLinearDepth(vec3 worldPos) {\nvec4 viewStartPos = cc_matLightView * vec4(worldPos.xyz, 1.0);\nreturn CCGetLinearDepthFromViewSpace(viewStartPos.xyz);\n}\n#if CC_RECEIVE_SHADOW\nuniform highp sampler2D cc_shadowMap;\nuniform highp sampler2D cc_spotLightingMap;\n#endif\nin vec2 v_uv;\nin vec2 v_uv1;\nin vec4 v_worldPos;\nin float v_clip_depth;\n#if USE_ALBEDO_MAP\nuniform sampler2D albedoMap;\n#endif\n#if USE_ALPHA_TEST\n#endif\nvec4 frag () {\nvec4 baseColor = albedo;\n#if USE_ALBEDO_MAP\nbaseColor *= texture(albedoMap, ALBEDO_UV);\n#endif\n#if USE_ALPHA_TEST\nif (baseColor.ALPHA_TEST_CHANNEL < albedoScaleAndCutoff.w) discard;\n#endif\nif(cc_shadowLPNNInfo.x > 0.000001 && cc_shadowLPNNInfo.x < 1.999999) {\nif (cc_shadowNFLSInfo.z > 0.000001) {\nreturn vec4(CCGetLinearDepth(v_worldPos.xyz), 1.0, 1.0, 1.0);\n}\n}\nif (cc_shadowLPNNInfo.y > 0.000001) {\nreturn packDepthToRGBA(v_clip_depth);\n}\nreturn vec4(v_clip_depth, 1.0, 1.0, 1.0);\n}\nlayout(location = 0) out vec4 cc_FragColor;\nvoid main() { cc_FragColor = frag(); }", + } + ], + [ + { + "vert": "\nprecision mediump float;\nlayout(std140) uniform CCGlobal {\nhighp vec4 cc_time;\nmediump vec4 cc_screenSize;\nmediump vec4 cc_nativeSize;\n};\nlayout(std140) uniform CCCamera {\nhighp mat4 cc_matView;\nhighp mat4 cc_matViewInv;\nhighp mat4 cc_matProj;\nhighp mat4 cc_matProjInv;\nhighp mat4 cc_matViewProj;\nhighp mat4 cc_matViewProjInv;\nhighp vec4 cc_cameraPos;\nmediump vec4 cc_screenScale;\nmediump vec4 cc_exposure;\nmediump vec4 cc_mainLitDir;\nmediump vec4 cc_mainLitColor;\nmediump vec4 cc_ambientSky;\nmediump vec4 cc_ambientGround;\nmediump vec4 cc_fogColor;\nmediump vec4 cc_fogBase;\nmediump vec4 cc_fogAdd;\nmediump vec4 cc_nearFar;\nmediump vec4 cc_viewPort;\n};\nlayout(std140) uniform CCLocal {\nhighp mat4 cc_matWorld;\nhighp mat4 cc_matWorldIT;\nhighp vec4 cc_lightingMapUVParam;\n};\nfloat LinearFog(vec4 pos) {\nvec4 wPos = pos;\nfloat cam_dis = distance(cc_cameraPos, wPos);\nfloat fogStart = cc_fogBase.x;\nfloat fogEnd = cc_fogBase.y;\nreturn clamp((fogEnd - cam_dis) / (fogEnd - fogStart), 0., 1.);\n}\nfloat ExpFog(vec4 pos) {\nvec4 wPos = pos;\nfloat fogAtten = cc_fogAdd.z;\nfloat fogStart = cc_fogBase.x;\nfloat fogDensity = cc_fogBase.z;\nfloat cam_dis = max(distance(cc_cameraPos, wPos) - fogStart, 0.0) / fogAtten * 4.;\nfloat f = exp(-cam_dis * fogDensity);\nreturn f;\n}\nfloat ExpSquaredFog(vec4 pos) {\nvec4 wPos = pos;\nfloat fogAtten = cc_fogAdd.z;\nfloat fogStart = cc_fogBase.x;\nfloat fogDensity = cc_fogBase.z;\nfloat cam_dis = max(distance(cc_cameraPos, wPos) - fogStart, 0.0) / fogAtten * 4.;\nfloat f = exp(-cam_dis * cam_dis * fogDensity * fogDensity);\nreturn f;\n}\nfloat LayeredFog(vec4 pos) {\nvec4 wPos = pos;\nfloat fogAtten = cc_fogAdd.z;\nfloat _FogTop = cc_fogAdd.x;\nfloat _FogRange = cc_fogAdd.y;\nvec3 camWorldProj = cc_cameraPos.xyz;\ncamWorldProj.y = 0.;\nvec3 worldPosProj = wPos.xyz;\nworldPosProj.y = 0.;\nfloat fDeltaD = distance(worldPosProj, camWorldProj) / fogAtten * 2.0;\nfloat fDeltaY, fDensityIntegral;\nif (cc_cameraPos.y > _FogTop) {\nif (wPos.y < _FogTop) {\nfDeltaY = (_FogTop - wPos.y) / _FogRange * 2.0;\nfDensityIntegral = fDeltaY * fDeltaY * 0.5;\n} else {\nfDeltaY = 0.;\nfDensityIntegral = 0.;\n}\n} else {\nif (wPos.y < _FogTop) {\nfloat fDeltaA = (_FogTop - cc_cameraPos.y) / _FogRange * 2.;\nfloat fDeltaB = (_FogTop - wPos.y) / _FogRange * 2.;\nfDeltaY = abs(fDeltaA - fDeltaB);\nfDensityIntegral = abs((fDeltaA * fDeltaA * 0.5) - (fDeltaB * fDeltaB * 0.5));\n} else {\nfDeltaY = abs(_FogTop - cc_cameraPos.y) / _FogRange * 2.;\nfDensityIntegral = abs(fDeltaY * fDeltaY * 0.5);\n}\n}\nfloat fDensity;\nif (fDeltaY != 0.) {\nfDensity = (sqrt(1.0 + ((fDeltaD / fDeltaY) * (fDeltaD / fDeltaY)))) * fDensityIntegral;\n} else {\nfDensity = 0.;\n}\nfloat f = exp(-fDensity);\nreturn f;\n}\nvoid CC_TRANSFER_FOG_BASE(vec4 pos, out float factor)\n{\n#if CC_USE_FOG == 0\nfactor = LinearFog(pos);\n#elif CC_USE_FOG == 1\nfactor = ExpFog(pos);\n#elif CC_USE_FOG == 2\nfactor = ExpSquaredFog(pos);\n#elif CC_USE_FOG == 3\nfactor = LayeredFog(pos);\n#else\nfactor = 1.0;\n#endif\n}\n#if !CC_USE_ACCURATE_FOG\nout float v_fog_factor;\n#endif\nvoid CC_TRANSFER_FOG(vec4 pos) {\n#if !CC_USE_ACCURATE_FOG\nCC_TRANSFER_FOG_BASE(pos, v_fog_factor);\n#endif\n}\nout highp vec4 v_shadowPos;\nlayout(std140) uniform CCShadow {\nhighp mat4 cc_matLightPlaneProj;\nhighp mat4 cc_matLightView;\nhighp mat4 cc_matLightViewProj;\nhighp vec4 cc_shadowInvProjDepthInfo;\nhighp vec4 cc_shadowProjDepthInfo;\nhighp vec4 cc_shadowProjInfo;\nlowp vec4 cc_shadowNFLSInfo;\nlowp vec4 cc_shadowWHPBInfo;\nlowp vec4 cc_shadowLPNNInfo;\nlowp vec4 cc_shadowColor;\n};\n#if CC_RECEIVE_SHADOW\nuniform highp sampler2D cc_shadowMap;\nuniform highp sampler2D cc_spotLightingMap;\n#endif\nin vec3 a_position;\nin vec3 a_normal;\nin vec2 a_texCoord;\nout highp vec3 v_position;\nout mediump vec3 v_normal;\n#if USE_NORMALMAP\nout mediump vec3 v_tangent;\nout mediump vec3 v_binormal;\n#endif\nout mediump vec2 uvw;\nout mediump vec2 uv0;\nout mediump vec2 uv1;\nout mediump vec2 uv2;\nout mediump vec2 uv3;\nout mediump vec3 luv;\nout mediump vec3 diffuse;\nlayout(std140) uniform TexCoords {\nvec4 UVScale;\nvec4 lightMapUVParam;\n};\nvoid main () {\nvec3 worldPos;\nworldPos.x = cc_matWorld[3][0] + a_position.x;\nworldPos.y = cc_matWorld[3][1] + a_position.y;\nworldPos.z = cc_matWorld[3][2] + a_position.z;\nvec4 pos = vec4(worldPos, 1.0);\npos = cc_matViewProj * pos;\nuvw = a_texCoord;\nuv0 = a_position.xz * UVScale.x;\nuv1 = a_position.xz * UVScale.y;\nuv2 = a_position.xz * UVScale.z;\nuv3 = a_position.xz * UVScale.w;\n#if USE_LIGHTMAP\nluv.xy = lightMapUVParam.xy + a_texCoord * lightMapUVParam.zw;\nluv.z = lightMapUVParam.z;\n#endif\nv_position = worldPos;\nv_normal = a_normal;\nCC_TRANSFER_FOG(vec4(worldPos, 1.0));\n#if USE_NORMALMAP\nv_tangent = vec3(1.0, 0.0, 0.0);\nv_binormal = vec3(0.0, 0.0, 1.0);\nv_binormal = cross(v_tangent, a_normal);\nv_tangent = cross(a_normal, v_binormal);\n#endif\nv_shadowPos = cc_matLightViewProj * vec4(worldPos, 1.0);\ngl_Position = pos;\n}", + "frag": "\nprecision highp float;\nlayout(std140) uniform CCGlobal {\nhighp vec4 cc_time;\nmediump vec4 cc_screenSize;\nmediump vec4 cc_nativeSize;\n};\nlayout(std140) uniform CCCamera {\nhighp mat4 cc_matView;\nhighp mat4 cc_matViewInv;\nhighp mat4 cc_matProj;\nhighp mat4 cc_matProjInv;\nhighp mat4 cc_matViewProj;\nhighp mat4 cc_matViewProjInv;\nhighp vec4 cc_cameraPos;\nmediump vec4 cc_screenScale;\nmediump vec4 cc_exposure;\nmediump vec4 cc_mainLitDir;\nmediump vec4 cc_mainLitColor;\nmediump vec4 cc_ambientSky;\nmediump vec4 cc_ambientGround;\nmediump vec4 cc_fogColor;\nmediump vec4 cc_fogBase;\nmediump vec4 cc_fogAdd;\nmediump vec4 cc_nearFar;\nmediump vec4 cc_viewPort;\n};\nvec3 SRGBToLinear (vec3 gamma) {\nreturn gamma * gamma;\n}\nlayout(std140) uniform CCShadow {\nhighp mat4 cc_matLightPlaneProj;\nhighp mat4 cc_matLightView;\nhighp mat4 cc_matLightViewProj;\nhighp vec4 cc_shadowInvProjDepthInfo;\nhighp vec4 cc_shadowProjDepthInfo;\nhighp vec4 cc_shadowProjInfo;\nlowp vec4 cc_shadowNFLSInfo;\nlowp vec4 cc_shadowWHPBInfo;\nlowp vec4 cc_shadowLPNNInfo;\nlowp vec4 cc_shadowColor;\n};\nfloat CCGetLinearDepthFromViewSpace(vec3 viewPos) {\nfloat dist = length(viewPos);\nreturn (dist - cc_shadowNFLSInfo.x) / (cc_shadowNFLSInfo.y - cc_shadowNFLSInfo.x);\n}\nfloat CCGetLinearDepth(vec3 worldPos) {\nvec4 viewStartPos = cc_matLightView * vec4(worldPos.xyz, 1.0);\nreturn CCGetLinearDepthFromViewSpace(viewStartPos.xyz);\n}\n#if CC_RECEIVE_SHADOW\nuniform highp sampler2D cc_shadowMap;\nuniform highp sampler2D cc_spotLightingMap;\nvec4 ApplyShadowDepthBias_FaceNormal(vec4 shadowPos, vec3 worldNormal)\n{\nvec4 newShadowPos = shadowPos;\nif(cc_shadowLPNNInfo.z > 0.0001)\n{\nvec4 viewNormal = cc_matLightView * vec4(worldNormal, 0.0);\nif(viewNormal.z < 0.1)\nnewShadowPos.xy += viewNormal.xy * cc_shadowProjInfo.xy * cc_shadowLPNNInfo.z * clamp(viewNormal.z, 0.001, 0.1);\n}\nreturn newShadowPos;\n}\nvec4 ApplyShadowDepthBias_Perspective(vec4 shadowPos, float viewspaceDepthBias)\n{\nvec3 viewSpacePos;\nviewSpacePos.xy = shadowPos.xy * cc_shadowProjInfo.zw;\nviewSpacePos.z = shadowPos.z * cc_shadowInvProjDepthInfo.x + shadowPos.w * cc_shadowInvProjDepthInfo.y;\nviewSpacePos.xyz += cc_shadowProjDepthInfo.z * normalize(viewSpacePos.xyz) * viewspaceDepthBias;\nvec4 clipSpacePos;\nclipSpacePos.xy = viewSpacePos.xy * cc_shadowProjInfo.xy;\nclipSpacePos.zw = viewSpacePos.z * cc_shadowProjDepthInfo.xz + vec2(cc_shadowProjDepthInfo.y, 0.0);\nif (cc_shadowNFLSInfo.z > 0.000001) {\nclipSpacePos.z = CCGetLinearDepthFromViewSpace(viewSpacePos.xyz);\nclipSpacePos.z = (clipSpacePos.z * 2.0 - 1.0) * clipSpacePos.w;\n}\nreturn clipSpacePos;\n}\nvec4 ApplyShadowDepthBias_Orthographic(vec4 shadowPos, float viewspaceDepthBias)\n{\nfloat coeffA = cc_shadowProjDepthInfo.x;\nfloat coeffB = cc_shadowProjDepthInfo.y;\nfloat viewSpacePos_z = (shadowPos.z - coeffB) / coeffA;\nviewSpacePos_z += viewspaceDepthBias;\nvec4 result = shadowPos;\nresult.z = viewSpacePos_z * coeffA + coeffB;\nreturn result;\n}\nfloat CCGetShadowFactorHard (vec4 shadowPos) {\nvec4 clipPosNew = ApplyShadowDepthBias_Orthographic(shadowPos, cc_shadowWHPBInfo.w);\nvec3 clipPos = clipPosNew.xyz / clipPosNew.w * 0.5 + 0.5;\nif (clipPos.x < 0.0 || clipPos.x > 1.0 ||\nclipPos.y < 0.0 || clipPos.y > 1.0 ||\nclipPos.z < 0.0 || clipPos.z > 1.0) { return 1.0; }\nclipPos.xy = cc_cameraPos.w == 1.0 ? vec2(clipPos.xy.x, 1.0 - clipPos.xy.y) : clipPos.xy;\nfloat shadow = 0.0;\nfloat closestDepth = 0.0;\nif (cc_shadowLPNNInfo.y > 0.000001) {\nclosestDepth = dot(texture(cc_shadowMap, clipPos.xy), vec4(1.0, 1.0 / 255.0, 1.0 / 65025.0, 1.0 / 16581375.0));\n} else {\nclosestDepth = texture(cc_shadowMap, clipPos.xy).x;\n}\nshadow = step(clipPos.z, closestDepth);\nreturn shadow;\n}\nfloat CCGetShadowFactorSoft (vec4 shadowPos) {\nvec4 clipPosNew = ApplyShadowDepthBias_Orthographic(shadowPos, cc_shadowWHPBInfo.w);\nvec3 clipPos = clipPosNew.xyz / clipPosNew.w * 0.5 + 0.5;\nif (clipPos.x < 0.0 || clipPos.x > 1.0 ||\nclipPos.y < 0.0 || clipPos.y > 1.0 ||\nclipPos.z < 0.0 || clipPos.z > 1.0) { return 1.0; }\nclipPos.xy = cc_cameraPos.w == 1.0 ? vec2(clipPos.xy.x, 1.0 - clipPos.xy.y) : clipPos.xy;\nfloat offsetDepth = clipPos.z;\nvec2 mapSize = cc_shadowWHPBInfo.xy;\nvec2 oneTap = 1.0 / mapSize;\nvec2 clipPos_offset = clipPos.xy + oneTap;\nfloat block0, block1, block2, block3;\nif (cc_shadowLPNNInfo.y > 0.000001) {\nblock0 = step(offsetDepth, dot(texture(cc_shadowMap, vec2(clipPos.x, clipPos.y)), vec4(1.0, 1.0 / 255.0, 1.0 / 65025.0, 1.0 / 16581375.0)));\nblock1 = step(offsetDepth, dot(texture(cc_shadowMap, vec2(clipPos_offset.x, clipPos.y)), vec4(1.0, 1.0 / 255.0, 1.0 / 65025.0, 1.0 / 16581375.0)));\nblock2 = step(offsetDepth, dot(texture(cc_shadowMap, vec2(clipPos.x, clipPos_offset.y)), vec4(1.0, 1.0 / 255.0, 1.0 / 65025.0, 1.0 / 16581375.0)));\nblock3 = step(offsetDepth, dot(texture(cc_shadowMap, vec2(clipPos_offset.x, clipPos_offset.y)), vec4(1.0, 1.0 / 255.0, 1.0 / 65025.0, 1.0 / 16581375.0)));\n} else {\nblock0 = step(offsetDepth, texture(cc_shadowMap, vec2(clipPos.x, clipPos.y)).x);\nblock1 = step(offsetDepth, texture(cc_shadowMap, vec2(clipPos_offset.x, clipPos.y)).x);\nblock2 = step(offsetDepth, texture(cc_shadowMap, vec2(clipPos.x, clipPos_offset.y)).x);\nblock3 = step(offsetDepth, texture(cc_shadowMap, vec2(clipPos_offset.x, clipPos_offset.y)).x);\n}\nfloat coefX = mod(clipPos.x, oneTap.x) * mapSize.x;\nfloat resultX = mix(block0, block1, coefX);\nfloat resultY = mix(block2, block3, coefX);\nfloat coefY = mod(clipPos.y, oneTap.y) * mapSize.y;\nreturn mix(resultX, resultY, coefY);\n}\nfloat CCGetShadowFactorSoft2X (vec4 shadowPos) {\nvec4 clipPosNew = ApplyShadowDepthBias_Orthographic(shadowPos, cc_shadowWHPBInfo.w);\nvec3 clipPos = clipPosNew.xyz / clipPosNew.w * 0.5 + 0.5;\nif (clipPos.x < 0.0 || clipPos.x > 1.0 ||\nclipPos.y < 0.0 || clipPos.y > 1.0 ||\nclipPos.z < 0.0 || clipPos.z > 1.0) { return 1.0; }\nclipPos.xy = cc_cameraPos.w == 1.0 ? vec2(clipPos.xy.x, 1.0 - clipPos.xy.y) : clipPos.xy;\nfloat offsetDepth = clipPos.z;\nvec2 mapSize = cc_shadowWHPBInfo.xy;\nvec2 oneTap = 1.0 / mapSize;\nfloat clipPos_offset_L = clipPos.x - oneTap.x;\nfloat clipPos_offset_R = clipPos.x + oneTap.x;\nfloat clipPos_offset_U = clipPos.y - oneTap.y;\nfloat clipPos_offset_D = clipPos.y + oneTap.y;\nfloat block0, block1, block2, block3, block4, block5, block6, block7, block8;\nif (cc_shadowLPNNInfo.y > 0.000001) {\nblock0 = step(offsetDepth, dot(texture(cc_shadowMap, vec2(clipPos_offset_L, clipPos_offset_U)), vec4(1.0, 1.0 / 255.0, 1.0 / 65025.0, 1.0 / 16581375.0)));\nblock1 = step(offsetDepth, dot(texture(cc_shadowMap, vec2(clipPos.x, clipPos_offset_U)), vec4(1.0, 1.0 / 255.0, 1.0 / 65025.0, 1.0 / 16581375.0)));\nblock2 = step(offsetDepth, dot(texture(cc_shadowMap, vec2(clipPos_offset_R, clipPos_offset_U)), vec4(1.0, 1.0 / 255.0, 1.0 / 65025.0, 1.0 / 16581375.0)));\nblock3 = step(offsetDepth, dot(texture(cc_shadowMap, vec2(clipPos_offset_L, clipPos.y)), vec4(1.0, 1.0 / 255.0, 1.0 / 65025.0, 1.0 / 16581375.0)));\nblock4 = step(offsetDepth, dot(texture(cc_shadowMap, vec2(clipPos.x, clipPos.y)), vec4(1.0, 1.0 / 255.0, 1.0 / 65025.0, 1.0 / 16581375.0)));\nblock5 = step(offsetDepth, dot(texture(cc_shadowMap, vec2(clipPos_offset_R, clipPos.y)), vec4(1.0, 1.0 / 255.0, 1.0 / 65025.0, 1.0 / 16581375.0)));\nblock6 = step(offsetDepth, dot(texture(cc_shadowMap, vec2(clipPos_offset_L, clipPos_offset_D)), vec4(1.0, 1.0 / 255.0, 1.0 / 65025.0, 1.0 / 16581375.0)));\nblock7 = step(offsetDepth, dot(texture(cc_shadowMap, vec2(clipPos.x, clipPos_offset_D)), vec4(1.0, 1.0 / 255.0, 1.0 / 65025.0, 1.0 / 16581375.0)));\nblock8 = step(offsetDepth, dot(texture(cc_shadowMap, vec2(clipPos_offset_R, clipPos_offset_D)), vec4(1.0, 1.0 / 255.0, 1.0 / 65025.0, 1.0 / 16581375.0)));\n} else {\nblock0 = step(offsetDepth, texture(cc_shadowMap, vec2(clipPos_offset_L, clipPos_offset_U)).x);\nblock1 = step(offsetDepth, texture(cc_shadowMap, vec2(clipPos.x, clipPos_offset_U)).x);\nblock2 = step(offsetDepth, texture(cc_shadowMap, vec2(clipPos_offset_R, clipPos_offset_U)).x);\nblock3 = step(offsetDepth, texture(cc_shadowMap, vec2(clipPos_offset_L, clipPos.y)).x);\nblock4 = step(offsetDepth, texture(cc_shadowMap, vec2(clipPos.x, clipPos.y)).x);\nblock5 = step(offsetDepth, texture(cc_shadowMap, vec2(clipPos_offset_R, clipPos.y)).x);\nblock6 = step(offsetDepth, texture(cc_shadowMap, vec2(clipPos_offset_L, clipPos_offset_D)).x);\nblock7 = step(offsetDepth, texture(cc_shadowMap, vec2(clipPos.x, clipPos_offset_D)).x);\nblock8 = step(offsetDepth, texture(cc_shadowMap, vec2(clipPos_offset_R, clipPos_offset_D)).x);\n}\nfloat coefX = mod(clipPos.x, oneTap.x) * mapSize.x;\nfloat coefY = mod(clipPos.y, oneTap.y) * mapSize.y;\nfloat shadow = 0.0;\nfloat resultX = mix(block0, block1, coefX);\nfloat resultY = mix(block3, block4, coefX);\nshadow += mix(resultX , resultY, coefY);\nresultX = mix(block1, block2, coefX);\nresultY = mix(block4, block5, coefX);\nshadow += mix(resultX , resultY, coefY);\nresultX = mix(block3, block4, coefX);\nresultY = mix(block6, block7, coefX);\nshadow += mix(resultX, resultY, coefY);\nresultX = mix(block4, block5, coefX);\nresultY = mix(block7, block8, coefX);\nshadow += mix(resultX, resultY, coefY);\nreturn shadow * 0.25;\n}\nfloat CCGetSpotLightShadowFactorHard (vec4 shadowPos, vec3 worldPos) {\nvec4 clipPosNew = ApplyShadowDepthBias_Perspective(shadowPos, cc_shadowWHPBInfo.w);\nvec3 clipPos = clipPosNew.xyz / clipPosNew.w * 0.5 + 0.5;\nif (clipPos.x < 0.0 || clipPos.x > 1.0 ||\nclipPos.y < 0.0 || clipPos.y > 1.0 ||\nclipPos.z < 0.0 || clipPos.z > 1.0) { return 1.0; }\nclipPos.xy = cc_cameraPos.w == 1.0 ? vec2(clipPos.xy.x, 1.0 - clipPos.xy.y) : clipPos.xy;\nfloat shadow = 0.0;\nfloat closestDepth = 0.0;\nfloat depth = clipPos.z;\nif (cc_shadowLPNNInfo.y > 0.000001) {\nclosestDepth = dot(texture(cc_spotLightingMap, clipPos.xy), vec4(1.0, 1.0 / 255.0, 1.0 / 65025.0, 1.0 / 16581375.0));\n} else {\nclosestDepth = texture(cc_spotLightingMap, clipPos.xy).x;\n}\nshadow = step(depth, closestDepth);\nreturn shadow;\n}\nfloat CCGetSpotLightShadowFactorSoft (vec4 shadowPos, vec3 worldPos) {\nvec4 clipPosNew = ApplyShadowDepthBias_Perspective(shadowPos, cc_shadowWHPBInfo.w);\nvec3 clipPos = clipPosNew.xyz / clipPosNew.w * 0.5 + 0.5;\nif (clipPos.x < 0.0 || clipPos.x > 1.0 ||\nclipPos.y < 0.0 || clipPos.y > 1.0 ||\nclipPos.z < 0.0 || clipPos.z > 1.0) { return 1.0; }\nclipPos.xy = cc_cameraPos.w == 1.0 ? vec2(clipPos.xy.x, 1.0 - clipPos.xy.y) : clipPos.xy;\nfloat depth = 0.0;\nif (cc_shadowNFLSInfo.z > 0.000001) {\ndepth = CCGetLinearDepth(worldPos);\n} else {\ndepth = clipPos.z;\n}\nfloat bias = cc_shadowWHPBInfo.w;\nvec2 oneTap = 1.0 / cc_shadowWHPBInfo.xy;\nvec2 clipPos_offset = clipPos.xy + oneTap;\nfloat block0, block1, block2, block3;\nif (cc_shadowLPNNInfo.y > 0.000001) {\nblock0 = step(depth, dot(texture(cc_spotLightingMap, vec2(clipPos.x, clipPos.y)), vec4(1.0, 1.0 / 255.0, 1.0 / 65025.0, 1.0 / 16581375.0)));\nblock1 = step(depth, dot(texture(cc_spotLightingMap, vec2(clipPos_offset.x, clipPos.y)), vec4(1.0, 1.0 / 255.0, 1.0 / 65025.0, 1.0 / 16581375.0)));\nblock2 = step(depth, dot(texture(cc_spotLightingMap, vec2(clipPos.x, clipPos_offset.y)), vec4(1.0, 1.0 / 255.0, 1.0 / 65025.0, 1.0 / 16581375.0)));\nblock3 = step(depth, dot(texture(cc_spotLightingMap, vec2(clipPos_offset.x, clipPos_offset.y)), vec4(1.0, 1.0 / 255.0, 1.0 / 65025.0, 1.0 / 16581375.0)));\n} else {\nblock0 = step(depth, texture(cc_spotLightingMap, vec2(clipPos.x, clipPos.y)).x);\nblock1 = step(depth, texture(cc_spotLightingMap, vec2(clipPos_offset.x, clipPos.y)).x);\nblock2 = step(depth, texture(cc_spotLightingMap, vec2(clipPos.x, clipPos_offset.y)).x);\nblock3 = step(depth, texture(cc_spotLightingMap, vec2(clipPos_offset.x, clipPos_offset.y)).x);\n}\nfloat coefX = mod(clipPos.x, oneTap.x) * cc_shadowWHPBInfo.x;\nfloat resultX = mix(block0, block1, coefX);\nfloat resultY = mix(block2, block3, coefX);\nfloat coefY = mod(clipPos.y, oneTap.y) * cc_shadowWHPBInfo.y;\nreturn mix(resultX, resultY, coefY);\n}\nfloat CCGetSpotLightShadowFactorSoft2X (vec4 shadowPos, vec3 worldPos) {\nvec4 clipPosNew = ApplyShadowDepthBias_Perspective(shadowPos, cc_shadowWHPBInfo.w);\nvec3 clipPos = clipPosNew.xyz / clipPosNew.w * 0.5 + 0.5;\nif (clipPos.x < 0.0 || clipPos.x > 1.0 ||\nclipPos.y < 0.0 || clipPos.y > 1.0 ||\nclipPos.z < 0.0 || clipPos.z > 1.0) { return 1.0; }\nclipPos.xy = cc_cameraPos.w == 1.0 ? vec2(clipPos.xy.x, 1.0 - clipPos.xy.y) : clipPos.xy;\nfloat depth = 0.0;\nif (cc_shadowNFLSInfo.z > 0.000001) {\ndepth = CCGetLinearDepth(worldPos);\n} else {\ndepth = clipPos.z;\n}\nfloat bias = cc_shadowWHPBInfo.w;\nvec2 mapSize = cc_shadowWHPBInfo.xy;\nvec2 oneTap = 1.0 / mapSize;\nfloat clipPos_offset_L = clipPos.x - oneTap.x;\nfloat clipPos_offset_R = clipPos.x + oneTap.x;\nfloat clipPos_offset_U = clipPos.y - oneTap.y;\nfloat clipPos_offset_D = clipPos.y + oneTap.y;\nfloat block0, block1, block2, block3, block4, block5, block6, block7, block8;\nif (cc_shadowLPNNInfo.y > 0.000001) {\nblock0 = step(depth, dot(texture(cc_spotLightingMap, vec2(clipPos_offset_L, clipPos_offset_U)), vec4(1.0, 1.0 / 255.0, 1.0 / 65025.0, 1.0 / 16581375.0)));\nblock1 = step(depth, dot(texture(cc_spotLightingMap, vec2(clipPos.x, clipPos_offset_U)), vec4(1.0, 1.0 / 255.0, 1.0 / 65025.0, 1.0 / 16581375.0)));\nblock2 = step(depth, dot(texture(cc_spotLightingMap, vec2(clipPos_offset_R, clipPos_offset_U)), vec4(1.0, 1.0 / 255.0, 1.0 / 65025.0, 1.0 / 16581375.0)));\nblock3 = step(depth, dot(texture(cc_spotLightingMap, vec2(clipPos_offset_L, clipPos.y)), vec4(1.0, 1.0 / 255.0, 1.0 / 65025.0, 1.0 / 16581375.0)));\nblock4 = step(depth, dot(texture(cc_spotLightingMap, vec2(clipPos.x, clipPos.y)), vec4(1.0, 1.0 / 255.0, 1.0 / 65025.0, 1.0 / 16581375.0)));\nblock5 = step(depth, dot(texture(cc_spotLightingMap, vec2(clipPos_offset_R, clipPos.y)), vec4(1.0, 1.0 / 255.0, 1.0 / 65025.0, 1.0 / 16581375.0)));\nblock6 = step(depth, dot(texture(cc_spotLightingMap, vec2(clipPos_offset_L, clipPos_offset_D)), vec4(1.0, 1.0 / 255.0, 1.0 / 65025.0, 1.0 / 16581375.0)));\nblock7 = step(depth, dot(texture(cc_spotLightingMap, vec2(clipPos.x, clipPos_offset_D)), vec4(1.0, 1.0 / 255.0, 1.0 / 65025.0, 1.0 / 16581375.0)));\nblock8 = step(depth, dot(texture(cc_spotLightingMap, vec2(clipPos_offset_R, clipPos_offset_D)), vec4(1.0, 1.0 / 255.0, 1.0 / 65025.0, 1.0 / 16581375.0)));\n} else {\nblock0 = step(depth, texture(cc_spotLightingMap, vec2(clipPos_offset_L, clipPos_offset_U)).x);\nblock1 = step(depth, texture(cc_spotLightingMap, vec2(clipPos.x, clipPos_offset_U)).x);\nblock2 = step(depth, texture(cc_spotLightingMap, vec2(clipPos_offset_R, clipPos_offset_U)).x);\nblock3 = step(depth, texture(cc_spotLightingMap, vec2(clipPos_offset_L, clipPos.y)).x);\nblock4 = step(depth, texture(cc_spotLightingMap, vec2(clipPos.x, clipPos.y)).x);\nblock5 = step(depth, texture(cc_spotLightingMap, vec2(clipPos_offset_R, clipPos.y)).x);\nblock6 = step(depth, texture(cc_spotLightingMap, vec2(clipPos_offset_L, clipPos_offset_D)).x);\nblock7 = step(depth, texture(cc_spotLightingMap, vec2(clipPos.x, clipPos_offset_D)).x);\nblock8 = step(depth, texture(cc_spotLightingMap, vec2(clipPos_offset_R, clipPos_offset_D)).x);\n}\nfloat coefX = mod(clipPos.x, oneTap.x) * mapSize.x;\nfloat coefY = mod(clipPos.y, oneTap.y) * mapSize.y;\nfloat shadow = 0.0;\nfloat resultX = mix(block0, block1, coefX);\nfloat resultY = mix(block3, block4, coefX);\nshadow += mix(resultX , resultY, coefY);\nresultX = mix(block1, block2, coefX);\nresultY = mix(block4, block5, coefX);\nshadow += mix(resultX , resultY, coefY);\nresultX = mix(block3, block4, coefX);\nresultY = mix(block6, block7, coefX);\nshadow += mix(resultX, resultY, coefY);\nresultX = mix(block4, block5, coefX);\nresultY = mix(block7, block8, coefX);\nshadow += mix(resultX, resultY, coefY);\nreturn shadow * 0.25;\n}\n#endif\n#if CC_USE_IBL\nuniform samplerCube cc_environment;\nvec4 fragTextureLod (sampler2D tex, vec2 coord, float lod) {\nreturn textureLod(tex, coord, lod);\n}\nvec4 fragTextureLod (samplerCube tex, vec3 coord, float lod) {\nreturn textureLod(tex, coord, lod);\n}\nvec3 unpackRGBE (vec4 rgbe) {\nreturn rgbe.rgb * pow(1.1, rgbe.a * 255.0 - 128.0);\n}\n#if CC_USE_DIFFUSEMAP\nuniform samplerCube cc_diffuseMap;\n#endif\n#endif\nfloat GGXMobile (float roughness, float NoH, vec3 H, vec3 N) {\nvec3 NxH = cross(N, H);\nfloat OneMinusNoHSqr = dot(NxH, NxH);\nfloat a = roughness * roughness;\nfloat n = NoH * a;\nfloat p = a / (OneMinusNoHSqr + n * n);\nreturn p * p;\n}\nfloat CalcSpecular (float roughness, float NoH, vec3 H, vec3 N) {\nreturn (roughness * 0.25 + 0.25) * GGXMobile(roughness, NoH, H, N);\n}\nvec3 BRDFApprox (vec3 specular, float roughness, float NoV) {\nconst vec4 c0 = vec4(-1.0, -0.0275, -0.572, 0.022);\nconst vec4 c1 = vec4(1.0, 0.0425, 1.04, -0.04);\nvec4 r = roughness * c0 + c1;\nfloat a004 = min(r.x * r.x, exp2(-9.28 * NoV)) * r.x + r.y;\nvec2 AB = vec2(-1.04, 1.04) * a004 + r.zw;\nAB.y *= clamp(50.0 * specular.g, 0.0, 1.0);\nreturn specular * AB.x + AB.y;\n}\n#if USE_REFLECTION_DENOISE\nvec3 GetEnvReflectionWithMipFiltering(vec3 R, float roughness, float mipCount, float denoiseIntensity) {\n#if CC_USE_IBL\nfloat mip = roughness * mipCount;\nfloat delta = (dot(dFdx(R), dFdy(R))) * 1000.0;\nfloat mipBias = mix(0.0, 5.0, clamp(delta, 0.0, 1.0));\nvec4 biased = fragTextureLod(cc_environment, R, mip + mipBias);\nvec4 filtered = texture(cc_environment, R);\n#if CC_USE_IBL == 2\nbiased.rgb = unpackRGBE(biased);\nfiltered.rgb = unpackRGBE(filtered);\n#else\nbiased.rgb = SRGBToLinear(biased.rgb);\nfiltered.rgb = SRGBToLinear(filtered.rgb);\n#endif\nreturn mix(biased.rgb, filtered.rgb, denoiseIntensity);\n#else\nreturn vec3(0.0, 0.0, 0.0);\n#endif\n}\n#endif\nstruct StandardSurface {\nvec4 albedo;\nvec3 position;\nvec3 normal;\nvec3 emissive;\nvec3 lightmap;\nfloat lightmap_test;\nfloat roughness;\nfloat metallic;\nfloat occlusion;\n};\nvec4 CCStandardShadingBase (StandardSurface s, vec4 shadowPos) {\nvec3 diffuse = s.albedo.rgb * (1.0 - s.metallic);\nvec3 specular = mix(vec3(0.04), s.albedo.rgb, s.metallic);\nvec3 N = normalize(s.normal);\nvec3 V = normalize(cc_cameraPos.xyz - s.position);\nfloat NV = max(abs(dot(N, V)), 0.0);\nspecular = BRDFApprox(specular, s.roughness, NV);\nvec3 L = normalize(-cc_mainLitDir.xyz);\nvec3 H = normalize(L + V);\nfloat NH = max(dot(N, H), 0.0);\nfloat NL = max(dot(N, L), 0.0);\nvec3 finalColor = NL * cc_mainLitColor.rgb * cc_mainLitColor.w;\nvec3 diffuseContrib = diffuse;\n#if USE_LIGHTMAP && !USE_BATCHING && !CC_FORWARD_ADD\nif (s.lightmap_test > 0.0001) {\nfinalColor = s.lightmap.rgb;\n}\n#else\ndiffuseContrib /= 3.14159265359;\n#endif\nvec3 specularContrib = specular * CalcSpecular(s.roughness, NH, H, N);\nvec3 dirlightContrib = (diffuseContrib + specularContrib);\nfloat shadow = 1.0;\n#if CC_RECEIVE_SHADOW && CC_ENABLE_DIR_SHADOW\nif (NL > 0.0) {\n{\nvec4 pos = ApplyShadowDepthBias_FaceNormal(shadowPos, N);\nfloat pcf = cc_shadowWHPBInfo.z;\nif (pcf > 1.9) shadow = CCGetShadowFactorSoft2X(pos);\nelse if (pcf > 0.9) shadow = CCGetShadowFactorSoft(pos);\nelse shadow = CCGetShadowFactorHard(pos);\nshadow = mix(shadow, 1.0, cc_shadowNFLSInfo.w);\n}\n}\n#endif\ndirlightContrib *= shadow;\nfinalColor *= dirlightContrib;\nfloat fAmb = 0.5 - N.y * 0.5;\nvec3 ambDiff = mix(cc_ambientSky.rgb, cc_ambientGround.rgb, fAmb);\n#if CC_USE_IBL\n#if CC_USE_DIFFUSEMAP\nvec4 diffuseMap = texture(cc_diffuseMap, N);\n#if CC_USE_DIFFUSEMAP == 2\nambDiff = unpackRGBE(diffuseMap);\n#else\nambDiff = SRGBToLinear(diffuseMap.rgb);\n#endif\n#endif\nvec3 R = normalize(reflect(-V, N));\n#if USE_REFLECTION_DENOISE\nvec3 env = GetEnvReflectionWithMipFiltering(R, s.roughness, cc_ambientGround.w, 0.6);\n#else\nvec4 envmap = fragTextureLod(cc_environment, R, s.roughness * cc_ambientGround.w);\n#if CC_USE_IBL == 2\nvec3 env = unpackRGBE(envmap);\n#else\nvec3 env = SRGBToLinear(envmap.rgb);\n#endif\n#endif\nfinalColor += env * cc_ambientSky.w * specular * s.occlusion;\n#endif\nfinalColor += ambDiff.rgb * cc_ambientSky.w * diffuse * s.occlusion;\nfinalColor += s.emissive;\nreturn vec4(finalColor, s.albedo.a);\n}\nvec3 ACESToneMap (vec3 color) {\ncolor = min(color, vec3(8.0));\nconst float A = 2.51;\nconst float B = 0.03;\nconst float C = 2.43;\nconst float D = 0.59;\nconst float E = 0.14;\nreturn (color * (A * color + B)) / (color * (C * color + D) + E);\n}\nvec4 CCFragOutput (vec4 color) {\n#if CC_USE_HDR\ncolor.rgb = ACESToneMap(color.rgb);\n#endif\ncolor.rgb = sqrt(color.rgb);\nreturn color;\n}\nfloat LinearFog(vec4 pos) {\nvec4 wPos = pos;\nfloat cam_dis = distance(cc_cameraPos, wPos);\nfloat fogStart = cc_fogBase.x;\nfloat fogEnd = cc_fogBase.y;\nreturn clamp((fogEnd - cam_dis) / (fogEnd - fogStart), 0., 1.);\n}\nfloat ExpFog(vec4 pos) {\nvec4 wPos = pos;\nfloat fogAtten = cc_fogAdd.z;\nfloat fogStart = cc_fogBase.x;\nfloat fogDensity = cc_fogBase.z;\nfloat cam_dis = max(distance(cc_cameraPos, wPos) - fogStart, 0.0) / fogAtten * 4.;\nfloat f = exp(-cam_dis * fogDensity);\nreturn f;\n}\nfloat ExpSquaredFog(vec4 pos) {\nvec4 wPos = pos;\nfloat fogAtten = cc_fogAdd.z;\nfloat fogStart = cc_fogBase.x;\nfloat fogDensity = cc_fogBase.z;\nfloat cam_dis = max(distance(cc_cameraPos, wPos) - fogStart, 0.0) / fogAtten * 4.;\nfloat f = exp(-cam_dis * cam_dis * fogDensity * fogDensity);\nreturn f;\n}\nfloat LayeredFog(vec4 pos) {\nvec4 wPos = pos;\nfloat fogAtten = cc_fogAdd.z;\nfloat _FogTop = cc_fogAdd.x;\nfloat _FogRange = cc_fogAdd.y;\nvec3 camWorldProj = cc_cameraPos.xyz;\ncamWorldProj.y = 0.;\nvec3 worldPosProj = wPos.xyz;\nworldPosProj.y = 0.;\nfloat fDeltaD = distance(worldPosProj, camWorldProj) / fogAtten * 2.0;\nfloat fDeltaY, fDensityIntegral;\nif (cc_cameraPos.y > _FogTop) {\nif (wPos.y < _FogTop) {\nfDeltaY = (_FogTop - wPos.y) / _FogRange * 2.0;\nfDensityIntegral = fDeltaY * fDeltaY * 0.5;\n} else {\nfDeltaY = 0.;\nfDensityIntegral = 0.;\n}\n} else {\nif (wPos.y < _FogTop) {\nfloat fDeltaA = (_FogTop - cc_cameraPos.y) / _FogRange * 2.;\nfloat fDeltaB = (_FogTop - wPos.y) / _FogRange * 2.;\nfDeltaY = abs(fDeltaA - fDeltaB);\nfDensityIntegral = abs((fDeltaA * fDeltaA * 0.5) - (fDeltaB * fDeltaB * 0.5));\n} else {\nfDeltaY = abs(_FogTop - cc_cameraPos.y) / _FogRange * 2.;\nfDensityIntegral = abs(fDeltaY * fDeltaY * 0.5);\n}\n}\nfloat fDensity;\nif (fDeltaY != 0.) {\nfDensity = (sqrt(1.0 + ((fDeltaD / fDeltaY) * (fDeltaD / fDeltaY)))) * fDensityIntegral;\n} else {\nfDensity = 0.;\n}\nfloat f = exp(-fDensity);\nreturn f;\n}\nvoid CC_TRANSFER_FOG_BASE(vec4 pos, out float factor)\n{\n#if CC_USE_FOG == 0\nfactor = LinearFog(pos);\n#elif CC_USE_FOG == 1\nfactor = ExpFog(pos);\n#elif CC_USE_FOG == 2\nfactor = ExpSquaredFog(pos);\n#elif CC_USE_FOG == 3\nfactor = LayeredFog(pos);\n#else\nfactor = 1.0;\n#endif\n}\nvoid CC_APPLY_FOG_BASE(inout vec4 color, float factor) {\ncolor = vec4(mix(cc_fogColor.rgb, color.rgb, factor), color.a);\n}\n#if !CC_USE_ACCURATE_FOG\nin float v_fog_factor;\n#endif\nvoid CC_APPLY_FOG(inout vec4 color) {\n#if !CC_USE_ACCURATE_FOG\nCC_APPLY_FOG_BASE(color, v_fog_factor);\n#endif\n}\nvoid CC_APPLY_FOG(inout vec4 color, vec3 worldPos) {\n#if CC_USE_ACCURATE_FOG\nfloat factor;\nCC_TRANSFER_FOG_BASE(vec4(worldPos, 1.0), factor);\n#else\nfloat factor = v_fog_factor;\n#endif\nCC_APPLY_FOG_BASE(color, factor);\n}\nin highp vec4 v_shadowPos;\n#if USE_LIGHTMAP && !USE_BATCHING && !CC_FORWARD_ADD\nin vec3 v_luv;\nuniform sampler2D cc_lightingMap;\nvec3 UnpackLightingmap(vec4 color) {\nvec3 c;\nfloat e = 1.0 + color.a * (8.0 - 1.0);\nc.r = color.r * e;\nc.g = color.g * e;\nc.b = color.b * e;\nreturn c;\n}\n#endif\nin highp vec3 v_position;\nin mediump vec3 v_normal;\n#if USE_NORMALMAP\nin mediump vec3 v_tangent;\nin mediump vec3 v_binormal;\n#endif\nin mediump vec2 uvw;\nin mediump vec2 uv0;\nin mediump vec2 uv1;\nin mediump vec2 uv2;\nin mediump vec2 uv3;\nin mediump vec3 diffuse;\nin mediump vec3 luv;\nlayout(std140) uniform PbrParams {\nvec4 metallic;\nvec4 roughness;\n};\nuniform sampler2D weightMap;\nuniform sampler2D detailMap0;\nuniform sampler2D detailMap1;\nuniform sampler2D detailMap2;\nuniform sampler2D detailMap3;\nuniform sampler2D normalMap0;\nuniform sampler2D normalMap1;\nuniform sampler2D normalMap2;\nuniform sampler2D normalMap3;\nuniform sampler2D lightMap;\nvoid surf (out StandardSurface s) {\n#if LAYERS > 1\nvec4 w = texture(weightMap, uvw);\n#endif\nvec4 baseColor = vec4(0, 0, 0, 0);\n#if LAYERS == 1\nbaseColor = texture(detailMap0, uv0);\n#elif LAYERS == 2\nbaseColor += texture(detailMap0, uv0) * w.r;\nbaseColor += texture(detailMap1, uv1) * w.g;\n#elif LAYERS == 3\nbaseColor += texture(detailMap0, uv0) * w.r;\nbaseColor += texture(detailMap1, uv1) * w.g;\nbaseColor += texture(detailMap2, uv2) * w.b;\n#elif LAYERS == 4\nbaseColor += texture(detailMap0, uv0) * w.r;\nbaseColor += texture(detailMap1, uv1) * w.g;\nbaseColor += texture(detailMap2, uv2) * w.b;\nbaseColor += texture(detailMap3, uv3) * w.a;\n#else\nbaseColor = texture(detailMap0, uv0);\n#endif\ns.position = v_position;\n#if USE_NORMALMAP\nvec4 baseNormal = vec4(0, 0, 0, 0);\n#if LAYERS == 1\nbaseNormal = texture(normalMap0, uv0);\n#elif LAYERS == 2\nbaseNormal += texture(normalMap0, uv0) * w.r;\nbaseNormal += texture(normalMap1, uv1) * w.g;\n#elif LAYERS == 3\nbaseNormal += texture(normalMap0, uv0) * w.r;\nbaseNormal += texture(normalMap1, uv1) * w.g;\nbaseNormal += texture(normalMap2, uv2) * w.b;\n#elif LAYERS == 4\nbaseNormal += texture(normalMap0, uv0) * w.r;\nbaseNormal += texture(normalMap1, uv1) * w.g;\nbaseNormal += texture(normalMap2, uv2) * w.b;\nbaseNormal += texture(normalMap3, uv3) * w.a;\n#else\nbaseNormal = texture(normalMap0, uv0);\n#endif\nvec3 nmmp = baseNormal.xyz - vec3(0.5);\ns.normal =\nnmmp.x * normalize(v_tangent) +\nnmmp.y * normalize(v_binormal) +\nnmmp.z * normalize(v_normal);\n#else\ns.normal = v_normal;\n#endif\ns.albedo = vec4(SRGBToLinear(baseColor.rgb), 1.0);\ns.occlusion = 1.0;\n#if USE_PBR\ns.roughness = 0.0;\n#if LAYERS == 1\ns.roughness = roughness.x;\n#elif LAYERS == 2\ns.roughness += roughness.x * w.r;\ns.roughness += roughness.y * w.g;\n#elif LAYERS == 3\ns.roughness += roughness.x * w.r;\ns.roughness += roughness.y * w.g;\ns.roughness += roughness.z * w.b;\n#elif LAYERS == 4\ns.roughness += roughness.x * w.r;\ns.roughness += roughness.y * w.g;\ns.roughness += roughness.z * w.b;\ns.roughness += roughness.w * w.a;\n#else\ns.roughness = 1.0;\n#endif\ns.metallic = 0.0;\n#if LAYERS == 1\ns.metallic = metallic.x;\n#elif LAYERS == 2\ns.metallic += metallic.x * w.r;\ns.metallic += metallic.y * w.g;\n#elif LAYERS == 3\ns.metallic += metallic.x * w.r;\ns.metallic += metallic.y * w.g;\ns.metallic += metallic.z * w.b;\n#elif LAYERS == 4\ns.metallic += metallic.x * w.r;\ns.metallic += metallic.y * w.g;\ns.metallic += metallic.z * w.b;\ns.metallic += metallic.w * w.a;\n#else\ns.metallic = 0.0;\n#endif\n#else\ns.roughness = 1.0;\ns.metallic = 0.0;\n#endif\ns.emissive = vec3(0.0, 0.0, 0.0);\n#if USE_LIGHTMAP && !USE_BATCHING && !CC_FORWARD_ADD\nvec4 lightColor = texture(lightMap, luv.xy);\ns.lightmap = UnpackLightingmap(lightColor);\ns.lightmap_test = luv.z;\n#endif\n}\n#if CC_FORWARD_ADD\n#if CC_PIPELINE_TYPE == 0\n# define LIGHTS_PER_PASS 1\n#else\n# define LIGHTS_PER_PASS 10\n#endif\n#if CC_ENABLE_CLUSTERED_LIGHT_CULLING == 0\nlayout(std140) uniform CCForwardLight {\nhighp vec4 cc_lightPos[LIGHTS_PER_PASS];\nvec4 cc_lightColor[LIGHTS_PER_PASS];\nvec4 cc_lightSizeRangeAngle[LIGHTS_PER_PASS];\nvec4 cc_lightDir[LIGHTS_PER_PASS];\n};\n#endif\nfloat SmoothDistAtt (float distSqr, float invSqrAttRadius) {\nfloat factor = distSqr * invSqrAttRadius;\nfloat smoothFactor = clamp(1.0 - factor * factor, 0.0, 1.0);\nreturn smoothFactor * smoothFactor;\n}\nfloat GetDistAtt (float distSqr, float invSqrAttRadius) {\nfloat attenuation = 1.0 / max(distSqr, 0.01*0.01);\nattenuation *= SmoothDistAtt(distSqr , invSqrAttRadius);\nreturn attenuation;\n}\nfloat GetAngleAtt (vec3 L, vec3 litDir, float litAngleScale, float litAngleOffset) {\nfloat cd = dot(litDir, L);\nfloat attenuation = clamp(cd * litAngleScale + litAngleOffset, 0.0, 1.0);\nreturn (attenuation * attenuation);\n}\n#if CC_ENABLE_CLUSTERED_LIGHT_CULLING == 0\nvec4 CCStandardShadingAdditive (StandardSurface s, vec4 shadowPos) {\nvec3 diffuse = s.albedo.rgb * (1.0 - s.metallic);\nvec3 specular = mix(vec3(0.04), s.albedo.rgb, s.metallic);\nvec3 diffuseContrib = diffuse / 3.14159265359;\nvec3 N = normalize(s.normal);\nvec3 V = normalize(cc_cameraPos.xyz - s.position);\nfloat NV = max(abs(dot(N, V)), 0.0);\nspecular = BRDFApprox(specular, s.roughness, NV);\nvec3 finalColor = vec3(0.0);\nint numLights = CC_PIPELINE_TYPE == 0 ? LIGHTS_PER_PASS : int(cc_lightDir[0].w);\nfor (int i = 0; i < LIGHTS_PER_PASS; i++) {\nif (i >= numLights) break;\nvec3 SLU = cc_lightPos[i].xyz - s.position;\nvec3 SL = normalize(SLU);\nvec3 SH = normalize(SL + V);\nfloat SNL = max(dot(N, SL), 0.0);\nfloat SNH = max(dot(N, SH), 0.0);\nfloat distSqr = dot(SLU, SLU);\nfloat litRadius = cc_lightSizeRangeAngle[i].x;\nfloat litRadiusSqr = litRadius * litRadius;\nfloat illum = 3.14159265359 * (litRadiusSqr / max(litRadiusSqr , distSqr));\nfloat attRadiusSqrInv = 1.0 / max(cc_lightSizeRangeAngle[i].y, 0.01);\nattRadiusSqrInv *= attRadiusSqrInv;\nfloat att = GetDistAtt(distSqr, attRadiusSqrInv);\nvec3 lspec = specular * CalcSpecular(s.roughness, SNH, SH, N);\nif (cc_lightPos[i].w > 0.0) {\nfloat cosInner = max(dot(-cc_lightDir[i].xyz, SL), 0.01);\nfloat cosOuter = cc_lightSizeRangeAngle[i].z;\nfloat litAngleScale = 1.0 / max(0.001, cosInner - cosOuter);\nfloat litAngleOffset = -cosOuter * litAngleScale;\natt *= GetAngleAtt(SL, -cc_lightDir[i].xyz, litAngleScale, litAngleOffset);\n}\nvec3 lightColor = cc_lightColor[i].rgb;\nfloat shadow = 1.0;\n#if CC_RECEIVE_SHADOW\nif (cc_lightPos[i].w > 0.0 && cc_lightSizeRangeAngle[i].w > 0.0) {\n{\nfloat pcf = cc_shadowWHPBInfo.z;\nif (pcf > 1.9) shadow = CCGetSpotLightShadowFactorSoft2X(shadowPos, s.position);\nelse if (pcf > 0.9) shadow = CCGetSpotLightShadowFactorSoft(shadowPos, s.position);\nelse shadow = CCGetSpotLightShadowFactorHard(shadowPos, s.position);\n}\n}\n#endif\nlightColor *= shadow;\nfinalColor += SNL * lightColor * cc_lightColor[i].w * illum * att * (diffuseContrib + lspec);\n}\nreturn vec4(finalColor, 0.0);\n}\n#endif\n#if CC_ENABLE_CLUSTERED_LIGHT_CULLING == 1\nlayout(std430, binding = 4) readonly buffer b_ccLightsBuffer { vec4 b_ccLights[]; };\nlayout(std430, binding = 5) readonly buffer b_clusterLightIndicesBuffer { uint b_clusterLightIndices[]; };\nlayout(std430, binding = 6) readonly buffer b_clusterLightGridBuffer { uvec4 b_clusterLightGrid[]; };\nstruct CCLight\n{\nvec4 cc_lightPos;\nvec4 cc_lightColor;\nvec4 cc_lightSizeRangeAngle;\nvec4 cc_lightDir;\n};\nstruct Cluster\n{\nvec3 minBounds;\nvec3 maxBounds;\n};\nstruct LightGrid\n{\nuint offset;\nuint ccLights;\n};\nCCLight getCCLight(uint i)\n{\nCCLight light;\nlight.cc_lightPos = b_ccLights[4u * i + 0u];\nlight.cc_lightColor = b_ccLights[4u * i + 1u];\nlight.cc_lightSizeRangeAngle = b_ccLights[4u * i + 2u];\nlight.cc_lightDir = b_ccLights[4u * i + 3u];\nreturn light;\n}\nLightGrid getLightGrid(uint cluster)\n{\nuvec4 gridvec = b_clusterLightGrid[cluster];\nLightGrid grid;\ngrid.offset = gridvec.x;\ngrid.ccLights = gridvec.y;\nreturn grid;\n}\nuint getGridLightIndex(uint start, uint offset)\n{\nreturn b_clusterLightIndices[start + offset];\n}\nuint getClusterZIndex(vec4 worldPos)\n{\nfloat scale = float(24) / log(cc_nearFar.y / cc_nearFar.x);\nfloat bias = -(float(24) * log(cc_nearFar.x) / log(cc_nearFar.y / cc_nearFar.x));\nfloat eyeDepth = -(cc_matView * worldPos).z;\nuint zIndex = uint(max(log(eyeDepth) * scale + bias, 0.0));\nreturn zIndex;\n}\nuint getClusterIndex(vec4 fragCoord, vec4 worldPos)\n{\nuint zIndex = getClusterZIndex(worldPos);\nfloat clusterSizeX = ceil(cc_screenSize.x / float(16));\nfloat clusterSizeY = ceil(cc_screenSize.y / float(8));\nuvec3 indices = uvec3(uvec2(fragCoord.xy / vec2(clusterSizeX, clusterSizeY)), zIndex);\nuint cluster = (16u * 8u) * indices.z + 16u * indices.y + indices.x;\nreturn cluster;\n}\nvec4 CCClusterShadingAdditive (StandardSurface s, vec4 shadowPos) {\nvec3 diffuse = s.albedo.rgb * (1.0 - s.metallic);\nvec3 specular = mix(vec3(0.04), s.albedo.rgb, s.metallic);\nvec3 diffuseContrib = diffuse / 3.14159265359;\nvec3 N = normalize(s.normal);\nvec3 V = normalize(cc_cameraPos.xyz - s.position);\nfloat NV = max(abs(dot(N, V)), 0.001);\nspecular = BRDFApprox(specular, s.roughness, NV);\nvec3 finalColor = vec3(0.0);\nuint cluster = getClusterIndex(gl_FragCoord, vec4(s.position, 1.0));\nLightGrid grid = getLightGrid(cluster);\nuint numLights = grid.ccLights;\nfor (uint i = 0u; i < 100u; i++) {\nif (i >= numLights) break;\nuint lightIndex = getGridLightIndex(grid.offset, i);\nCCLight light = getCCLight(lightIndex);\nvec3 SLU = light.cc_lightPos.xyz - s.position;\nvec3 SL = normalize(SLU);\nvec3 SH = normalize(SL + V);\nfloat SNL = max(dot(N, SL), 0.001);\nfloat SNH = max(dot(N, SH), 0.0);\nfloat distSqr = dot(SLU, SLU);\nfloat litRadius = light.cc_lightSizeRangeAngle.x;\nfloat litRadiusSqr = litRadius * litRadius;\nfloat illum = 3.14159265359 * (litRadiusSqr / max(litRadiusSqr , distSqr));\nfloat attRadiusSqrInv = 1.0 / max(light.cc_lightSizeRangeAngle.y, 0.01);\nattRadiusSqrInv *= attRadiusSqrInv;\nfloat att = GetDistAtt(distSqr, attRadiusSqrInv);\nvec3 lspec = specular * CalcSpecular(s.roughness, SNH, SH, N);\nif (light.cc_lightPos.w > 0.0) {\nfloat cosInner = max(dot(-light.cc_lightDir.xyz, SL), 0.01);\nfloat cosOuter = light.cc_lightSizeRangeAngle.z;\nfloat litAngleScale = 1.0 / max(0.001, cosInner - cosOuter);\nfloat litAngleOffset = -cosOuter * litAngleScale;\natt *= GetAngleAtt(SL, -light.cc_lightDir.xyz, litAngleScale, litAngleOffset);\n}\nvec3 lightColor = light.cc_lightColor.rgb;\nfloat shadow = 1.0;\n#if CC_RECEIVE_SHADOW\nif (light.cc_lightPos.w > 0.0) {\n{\nfloat pcf = cc_shadowWHPBInfo.z;\nif (pcf > 1.9) shadow = CCGetSpotLightShadowFactorSoft2X(shadowPos, s.position);\nelse if (pcf > 0.9) shadow = CCGetSpotLightShadowFactorSoft(shadowPos, s.position);\nelse shadow = CCGetSpotLightShadowFactorHard(shadowPos, s.position);\n}\n}\n#endif\nlightColor *= shadow;\nfinalColor += SNL * lightColor * light.cc_lightColor.w * illum * att * (diffuseContrib + lspec);\n}\nreturn vec4(finalColor, 0.0);\n}\n#endif\nlayout(location = 0) out vec4 fragColorX;\nvoid main () {\nStandardSurface s; surf(s);\n#if CC_ENABLE_CLUSTERED_LIGHT_CULLING == 1\nvec4 color = CCClusterShadingAdditive(s, v_shadowPos);\n#else\nvec4 color = CCStandardShadingAdditive(s, v_shadowPos);\n#endif\nCC_APPLY_FOG(color, s.position.xyz);\nfragColorX = CCFragOutput(color);\n}\n#elif (CC_PIPELINE_TYPE == 0 || CC_FORCE_FORWARD_SHADING)\nlayout(location = 0) out vec4 fragColorX;\nvoid main () {\nStandardSurface s; surf(s);\nvec4 color = CCStandardShadingBase(s, v_shadowPos);\nCC_APPLY_FOG(color, s.position.xyz);\nfragColorX = CCFragOutput(color);\n}\n#elif CC_PIPELINE_TYPE == 1\nlayout(location = 0) out vec4 fragColor0;\nlayout(location = 1) out vec4 fragColor1;\nlayout(location = 2) out vec4 fragColor2;\nlayout(location = 3) out vec4 fragColor3;\nvoid main () {\nStandardSurface s; surf(s);\nfragColor0 = s.albedo;\nfragColor1 = vec4(s.position, s.roughness);\nfragColor2 = vec4(s.normal, s.metallic);\nfragColor3 = vec4(s.emissive, s.occlusion);\n}\n#endif", + }, + { + "vert": "\nprecision highp float;\nlayout(std140) uniform CCGlobal {\nhighp vec4 cc_time;\nmediump vec4 cc_screenSize;\nmediump vec4 cc_nativeSize;\n};\nlayout(std140) uniform CCCamera {\nhighp mat4 cc_matView;\nhighp mat4 cc_matViewInv;\nhighp mat4 cc_matProj;\nhighp mat4 cc_matProjInv;\nhighp mat4 cc_matViewProj;\nhighp mat4 cc_matViewProjInv;\nhighp vec4 cc_cameraPos;\nmediump vec4 cc_screenScale;\nmediump vec4 cc_exposure;\nmediump vec4 cc_mainLitDir;\nmediump vec4 cc_mainLitColor;\nmediump vec4 cc_ambientSky;\nmediump vec4 cc_ambientGround;\nmediump vec4 cc_fogColor;\nmediump vec4 cc_fogBase;\nmediump vec4 cc_fogAdd;\nmediump vec4 cc_nearFar;\nmediump vec4 cc_viewPort;\n};\nlayout(std140) uniform CCLocal {\nhighp mat4 cc_matWorld;\nhighp mat4 cc_matWorldIT;\nhighp vec4 cc_lightingMapUVParam;\n};\nlayout(std140) uniform CCShadow {\nhighp mat4 cc_matLightPlaneProj;\nhighp mat4 cc_matLightView;\nhighp mat4 cc_matLightViewProj;\nhighp vec4 cc_shadowInvProjDepthInfo;\nhighp vec4 cc_shadowProjDepthInfo;\nhighp vec4 cc_shadowProjInfo;\nlowp vec4 cc_shadowNFLSInfo;\nlowp vec4 cc_shadowWHPBInfo;\nlowp vec4 cc_shadowLPNNInfo;\nlowp vec4 cc_shadowColor;\n};\nin vec3 a_position;\nin vec3 a_normal;\nin vec2 a_texCoord;\nout vec2 v_clip_depth;\nvec4 vert () {\nvec4 worldPos;\nworldPos.x = cc_matWorld[3][0] + a_position.x;\nworldPos.y = cc_matWorld[3][1] + a_position.y;\nworldPos.z = cc_matWorld[3][2] + a_position.z;\nworldPos.w = 1.0;\nvec4 clipPos = cc_matLightViewProj * worldPos;\nv_clip_depth = clipPos.zw;\nreturn clipPos;\n}\nvoid main() { gl_Position = vert(); }", + "frag": "\nprecision highp float;\nvec4 packDepthToRGBA (float depth) {\nvec4 ret = vec4(1.0, 255.0, 65025.0, 16581375.0) * depth;\nret = fract(ret);\nret -= vec4(ret.yzw, 0.0) / 255.0;\nreturn ret;\n}\nin vec2 v_clip_depth;\nvec4 frag () {\nreturn packDepthToRGBA(v_clip_depth.x / v_clip_depth.y * 0.5 + 0.5);\n}\nlayout(location = 0) out vec4 cc_FragColor;\nvoid main() { cc_FragColor = frag(); }", + } + ], + [ + { + "vert": "\nprecision highp float;\nhighp float decode32 (highp vec4 rgba) {\nrgba = rgba * 255.0;\nhighp float Sign = 1.0 - (step(128.0, (rgba[3]) + 0.5)) * 2.0;\nhighp float Exponent = 2.0 * (mod(float(int((rgba[3]) + 0.5)), 128.0)) + (step(128.0, (rgba[2]) + 0.5)) - 127.0;\nhighp float Mantissa = (mod(float(int((rgba[2]) + 0.5)), 128.0)) * 65536.0 + rgba[1] * 256.0 + rgba[0] + 8388608.0;\nreturn Sign * exp2(Exponent - 23.0) * Mantissa;\n}\nstruct StandardVertInput {\nhighp vec4 position;\nvec3 normal;\nvec4 tangent;\n};\nin vec3 a_position;\nin vec3 a_normal;\nin vec2 a_texCoord;\nin vec4 a_tangent;\n#if CC_USE_MORPH\nin float a_vertexId;\nint getVertexId() {\nreturn int(a_vertexId);\n}\nlayout(std140) uniform CCMorph {\nvec4 cc_displacementWeights[15];\nvec4 cc_displacementTextureInfo;\n};\nvec2 getPixelLocation(vec2 textureResolution, int pixelIndex) {\nfloat pixelIndexF = float(pixelIndex);\nfloat x = mod(pixelIndexF, textureResolution.x);\nfloat y = floor(pixelIndexF / textureResolution.x);\nreturn vec2(x, y);\n}\nvec2 getPixelCoordFromLocation(vec2 location, vec2 textureResolution) {\nreturn (vec2(location.x, location.y) + .5) / textureResolution;\n}\n#if CC_DEVICE_SUPPORT_FLOAT_TEXTURE\nvec4 fetchVec3ArrayFromTexture(sampler2D tex, int pixelIndex) {\nivec2 texSize = textureSize(tex, 0);\nreturn texelFetch(tex, ivec2(pixelIndex % texSize.x, pixelIndex / texSize.x), 0);\n}\n#else\nvec4 fetchVec3ArrayFromTexture(sampler2D tex, int elementIndex) {\nint pixelIndex = elementIndex * 4;\nvec2 location = getPixelLocation(cc_displacementTextureInfo.xy, pixelIndex);\nvec2 x = getPixelCoordFromLocation(location + vec2(0.0, 0.0), cc_displacementTextureInfo.xy);\nvec2 y = getPixelCoordFromLocation(location + vec2(1.0, 0.0), cc_displacementTextureInfo.xy);\nvec2 z = getPixelCoordFromLocation(location + vec2(2.0, 0.0), cc_displacementTextureInfo.xy);\nreturn vec4(\ndecode32(texture(tex, x)),\ndecode32(texture(tex, y)),\ndecode32(texture(tex, z)),\n1.0\n);\n}\n#endif\nfloat getDisplacementWeight(int index) {\nint quot = index / 4;\nint remainder = index - quot * 4;\nif (remainder == 0) {\nreturn cc_displacementWeights[quot].x;\n} else if (remainder == 1) {\nreturn cc_displacementWeights[quot].y;\n} else if (remainder == 2) {\nreturn cc_displacementWeights[quot].z;\n} else {\nreturn cc_displacementWeights[quot].w;\n}\n}\nvec3 getVec3DisplacementFromTexture(sampler2D tex, int vertexIndex) {\n#if CC_MORPH_PRECOMPUTED\nreturn fetchVec3ArrayFromTexture(tex, vertexIndex).rgb;\n#else\nvec3 result = vec3(0, 0, 0);\nint nVertices = int(cc_displacementTextureInfo.z);\nfor (int iTarget = 0; iTarget < CC_MORPH_TARGET_COUNT; ++iTarget) {\nresult += (fetchVec3ArrayFromTexture(tex, nVertices * iTarget + vertexIndex).rgb * getDisplacementWeight(iTarget));\n}\nreturn result;\n#endif\n}\n#if CC_MORPH_TARGET_HAS_POSITION\nuniform sampler2D cc_PositionDisplacements;\nvec3 getPositionDisplacement(int vertexId) {\nreturn getVec3DisplacementFromTexture(cc_PositionDisplacements, vertexId);\n}\n#endif\n#if CC_MORPH_TARGET_HAS_NORMAL\nuniform sampler2D cc_NormalDisplacements;\nvec3 getNormalDisplacement(int vertexId) {\nreturn getVec3DisplacementFromTexture(cc_NormalDisplacements, vertexId);\n}\n#endif\n#if CC_MORPH_TARGET_HAS_TANGENT\nuniform sampler2D cc_TangentDisplacements;\nvec3 getTangentDisplacement(int vertexId) {\nreturn getVec3DisplacementFromTexture(cc_TangentDisplacements, vertexId);\n}\n#endif\nvoid applyMorph (inout StandardVertInput attr) {\nint vertexId = getVertexId();\n#if CC_MORPH_TARGET_HAS_POSITION\nattr.position.xyz = attr.position.xyz + getPositionDisplacement(vertexId);\n#endif\n#if CC_MORPH_TARGET_HAS_NORMAL\nattr.normal.xyz = attr.normal.xyz + getNormalDisplacement(vertexId);\n#endif\n#if CC_MORPH_TARGET_HAS_TANGENT\nattr.tangent.xyz = attr.tangent.xyz + getTangentDisplacement(vertexId);\n#endif\n}\nvoid applyMorph (inout vec4 position) {\n#if CC_MORPH_TARGET_HAS_POSITION\nposition.xyz = position.xyz + getPositionDisplacement(getVertexId());\n#endif\n}\n#endif\n#if CC_USE_SKINNING\nin vec4 a_joints;\nin vec4 a_weights;\n#if CC_USE_BAKED_ANIMATION\n#if USE_INSTANCING\nin highp vec4 a_jointAnimInfo;\n#endif\nlayout(std140) uniform CCSkinningTexture {\nhighp vec4 cc_jointTextureInfo;\n};\nlayout(std140) uniform CCSkinningAnimation {\nhighp vec4 cc_jointAnimInfo;\n};\nuniform highp sampler2D cc_jointTexture;\n#else\nlayout(std140) uniform CCSkinning {\nhighp vec4 cc_joints[30 * 3];\n};\n#endif\n#if CC_USE_BAKED_ANIMATION\n#if CC_DEVICE_SUPPORT_FLOAT_TEXTURE\nmat4 getJointMatrix (float i) {\n#if USE_INSTANCING\nhighp float j = 3.0 * (a_jointAnimInfo.x * a_jointAnimInfo.y + i) + a_jointAnimInfo.z;\n#else\nhighp float j = 3.0 * (cc_jointAnimInfo.x * cc_jointTextureInfo.y + i) + cc_jointTextureInfo.z;\n#endif\nhighp float invSize = cc_jointTextureInfo.w;\nhighp float y = floor(j * invSize);\nhighp float x = floor(j - y * cc_jointTextureInfo.x);\ny = (y + 0.5) * invSize;\nvec4 v1 = texture(cc_jointTexture, vec2((x + 0.5) * invSize, y));\nvec4 v2 = texture(cc_jointTexture, vec2((x + 1.5) * invSize, y));\nvec4 v3 = texture(cc_jointTexture, vec2((x + 2.5) * invSize, y));\nreturn mat4(vec4(v1.xyz, 0.0), vec4(v2.xyz, 0.0), vec4(v3.xyz, 0.0), vec4(v1.w, v2.w, v3.w, 1.0));\n}\n#else\nmat4 getJointMatrix (float i) {\n#if USE_INSTANCING\nhighp float j = 12.0 * (a_jointAnimInfo.x * a_jointAnimInfo.y + i) + a_jointAnimInfo.z;\n#else\nhighp float j = 12.0 * (cc_jointAnimInfo.x * cc_jointTextureInfo.y + i) + cc_jointTextureInfo.z;\n#endif\nhighp float invSize = cc_jointTextureInfo.w;\nhighp float y = floor(j * invSize);\nhighp float x = floor(j - y * cc_jointTextureInfo.x);\ny = (y + 0.5) * invSize;\nvec4 v1 = vec4(\ndecode32(texture(cc_jointTexture, vec2((x + 0.5) * invSize, y))),\ndecode32(texture(cc_jointTexture, vec2((x + 1.5) * invSize, y))),\ndecode32(texture(cc_jointTexture, vec2((x + 2.5) * invSize, y))),\ndecode32(texture(cc_jointTexture, vec2((x + 3.5) * invSize, y)))\n);\nvec4 v2 = vec4(\ndecode32(texture(cc_jointTexture, vec2((x + 4.5) * invSize, y))),\ndecode32(texture(cc_jointTexture, vec2((x + 5.5) * invSize, y))),\ndecode32(texture(cc_jointTexture, vec2((x + 6.5) * invSize, y))),\ndecode32(texture(cc_jointTexture, vec2((x + 7.5) * invSize, y)))\n);\nvec4 v3 = vec4(\ndecode32(texture(cc_jointTexture, vec2((x + 8.5) * invSize, y))),\ndecode32(texture(cc_jointTexture, vec2((x + 9.5) * invSize, y))),\ndecode32(texture(cc_jointTexture, vec2((x + 10.5) * invSize, y))),\ndecode32(texture(cc_jointTexture, vec2((x + 11.5) * invSize, y)))\n);\nreturn mat4(vec4(v1.xyz, 0.0), vec4(v2.xyz, 0.0), vec4(v3.xyz, 0.0), vec4(v1.w, v2.w, v3.w, 1.0));\n}\n#endif\n#else\nmat4 getJointMatrix (float i) {\nint idx = int(i);\nvec4 v1 = cc_joints[idx * 3];\nvec4 v2 = cc_joints[idx * 3 + 1];\nvec4 v3 = cc_joints[idx * 3 + 2];\nreturn mat4(vec4(v1.xyz, 0.0), vec4(v2.xyz, 0.0), vec4(v3.xyz, 0.0), vec4(v1.w, v2.w, v3.w, 1.0));\n}\n#endif\nmat4 skinMatrix () {\nvec4 joints = vec4(a_joints);\nreturn getJointMatrix(joints.x) * a_weights.x\n+ getJointMatrix(joints.y) * a_weights.y\n+ getJointMatrix(joints.z) * a_weights.z\n+ getJointMatrix(joints.w) * a_weights.w;\n}\nvoid CCSkin (inout vec4 position) {\nmat4 m = skinMatrix();\nposition = m * position;\n}\nvoid CCSkin (inout StandardVertInput attr) {\nmat4 m = skinMatrix();\nattr.position = m * attr.position;\nattr.normal = (m * vec4(attr.normal, 0.0)).xyz;\nattr.tangent.xyz = (m * vec4(attr.tangent.xyz, 0.0)).xyz;\n}\n#endif\nlayout(std140) uniform CCGlobal {\nhighp vec4 cc_time;\nmediump vec4 cc_screenSize;\nmediump vec4 cc_nativeSize;\n};\nlayout(std140) uniform CCCamera {\nhighp mat4 cc_matView;\nhighp mat4 cc_matViewInv;\nhighp mat4 cc_matProj;\nhighp mat4 cc_matProjInv;\nhighp mat4 cc_matViewProj;\nhighp mat4 cc_matViewProjInv;\nhighp vec4 cc_cameraPos;\nmediump vec4 cc_screenScale;\nmediump vec4 cc_exposure;\nmediump vec4 cc_mainLitDir;\nmediump vec4 cc_mainLitColor;\nmediump vec4 cc_ambientSky;\nmediump vec4 cc_ambientGround;\nmediump vec4 cc_fogColor;\nmediump vec4 cc_fogBase;\nmediump vec4 cc_fogAdd;\nmediump vec4 cc_nearFar;\nmediump vec4 cc_viewPort;\n};\n#if USE_INSTANCING\nin vec4 a_matWorld0;\nin vec4 a_matWorld1;\nin vec4 a_matWorld2;\n#if USE_LIGHTMAP\nin vec4 a_lightingMapUVParam;\n#endif\n#elif USE_BATCHING\nin float a_dyn_batch_id;\nlayout(std140) uniform CCLocalBatched {\nhighp mat4 cc_matWorlds[10];\n};\n#else\nlayout(std140) uniform CCLocal {\nhighp mat4 cc_matWorld;\nhighp mat4 cc_matWorldIT;\nhighp vec4 cc_lightingMapUVParam;\n};\n#endif\nfloat LinearFog(vec4 pos) {\nvec4 wPos = pos;\nfloat cam_dis = distance(cc_cameraPos, wPos);\nfloat fogStart = cc_fogBase.x;\nfloat fogEnd = cc_fogBase.y;\nreturn clamp((fogEnd - cam_dis) / (fogEnd - fogStart), 0., 1.);\n}\nfloat ExpFog(vec4 pos) {\nvec4 wPos = pos;\nfloat fogAtten = cc_fogAdd.z;\nfloat fogStart = cc_fogBase.x;\nfloat fogDensity = cc_fogBase.z;\nfloat cam_dis = max(distance(cc_cameraPos, wPos) - fogStart, 0.0) / fogAtten * 4.;\nfloat f = exp(-cam_dis * fogDensity);\nreturn f;\n}\nfloat ExpSquaredFog(vec4 pos) {\nvec4 wPos = pos;\nfloat fogAtten = cc_fogAdd.z;\nfloat fogStart = cc_fogBase.x;\nfloat fogDensity = cc_fogBase.z;\nfloat cam_dis = max(distance(cc_cameraPos, wPos) - fogStart, 0.0) / fogAtten * 4.;\nfloat f = exp(-cam_dis * cam_dis * fogDensity * fogDensity);\nreturn f;\n}\nfloat LayeredFog(vec4 pos) {\nvec4 wPos = pos;\nfloat fogAtten = cc_fogAdd.z;\nfloat _FogTop = cc_fogAdd.x;\nfloat _FogRange = cc_fogAdd.y;\nvec3 camWorldProj = cc_cameraPos.xyz;\ncamWorldProj.y = 0.;\nvec3 worldPosProj = wPos.xyz;\nworldPosProj.y = 0.;\nfloat fDeltaD = distance(worldPosProj, camWorldProj) / fogAtten * 2.0;\nfloat fDeltaY, fDensityIntegral;\nif (cc_cameraPos.y > _FogTop) {\nif (wPos.y < _FogTop) {\nfDeltaY = (_FogTop - wPos.y) / _FogRange * 2.0;\nfDensityIntegral = fDeltaY * fDeltaY * 0.5;\n} else {\nfDeltaY = 0.;\nfDensityIntegral = 0.;\n}\n} else {\nif (wPos.y < _FogTop) {\nfloat fDeltaA = (_FogTop - cc_cameraPos.y) / _FogRange * 2.;\nfloat fDeltaB = (_FogTop - wPos.y) / _FogRange * 2.;\nfDeltaY = abs(fDeltaA - fDeltaB);\nfDensityIntegral = abs((fDeltaA * fDeltaA * 0.5) - (fDeltaB * fDeltaB * 0.5));\n} else {\nfDeltaY = abs(_FogTop - cc_cameraPos.y) / _FogRange * 2.;\nfDensityIntegral = abs(fDeltaY * fDeltaY * 0.5);\n}\n}\nfloat fDensity;\nif (fDeltaY != 0.) {\nfDensity = (sqrt(1.0 + ((fDeltaD / fDeltaY) * (fDeltaD / fDeltaY)))) * fDensityIntegral;\n} else {\nfDensity = 0.;\n}\nfloat f = exp(-fDensity);\nreturn f;\n}\nvoid CC_TRANSFER_FOG_BASE(vec4 pos, out float factor)\n{\n#if CC_USE_FOG == 0\nfactor = LinearFog(pos);\n#elif CC_USE_FOG == 1\nfactor = ExpFog(pos);\n#elif CC_USE_FOG == 2\nfactor = ExpSquaredFog(pos);\n#elif CC_USE_FOG == 3\nfactor = LayeredFog(pos);\n#else\nfactor = 1.0;\n#endif\n}\n#if !CC_USE_ACCURATE_FOG\nout float v_fog_factor;\n#endif\nvoid CC_TRANSFER_FOG(vec4 pos) {\n#if !CC_USE_ACCURATE_FOG\nCC_TRANSFER_FOG_BASE(pos, v_fog_factor);\n#endif\n}\n#if USE_VERTEX_COLOR\nin lowp vec4 a_color;\nout lowp vec4 v_color;\n#endif\n#if USE_TEXTURE\nout vec2 v_uv;\nlayout(std140) uniform TexCoords {\nvec4 tilingOffset;\n};\n#endif\nvec4 vert () {\nvec4 position;\nposition = vec4(a_position, 1.0);\n#if CC_USE_MORPH\napplyMorph(position);\n#endif\n#if CC_USE_SKINNING\nCCSkin(position);\n#endif\nmat4 matWorld;\n#if USE_INSTANCING\nmatWorld = mat4(\nvec4(a_matWorld0.xyz, 0.0),\nvec4(a_matWorld1.xyz, 0.0),\nvec4(a_matWorld2.xyz, 0.0),\nvec4(a_matWorld0.w, a_matWorld1.w, a_matWorld2.w, 1.0)\n);\n#elif USE_BATCHING\nmatWorld = cc_matWorlds[int(a_dyn_batch_id)];\n#else\nmatWorld = cc_matWorld;\n#endif\n#if USE_TEXTURE\nv_uv = a_texCoord * tilingOffset.xy + tilingOffset.zw;\n#if SAMPLE_FROM_RT\nv_uv = cc_cameraPos.w > 1.0 ? vec2(v_uv.x, 1.0 - v_uv.y) : v_uv;\n#endif\n#endif\n#if USE_VERTEX_COLOR\nv_color = a_color;\n#endif\nCC_TRANSFER_FOG(matWorld * position);\nreturn cc_matProj * (cc_matView * matWorld) * position;\n}\nvoid main() { gl_Position = vert(); }", + "frag": "\nprecision highp float;\nvec3 ACESToneMap (vec3 color) {\ncolor = min(color, vec3(8.0));\nconst float A = 2.51;\nconst float B = 0.03;\nconst float C = 2.43;\nconst float D = 0.59;\nconst float E = 0.14;\nreturn (color * (A * color + B)) / (color * (C * color + D) + E);\n}\nvec3 SRGBToLinear (vec3 gamma) {\nreturn gamma * gamma;\n}\nvec4 CCFragOutput (vec4 color) {\n#if CC_USE_HDR\ncolor.rgb = ACESToneMap(color.rgb);\n#endif\ncolor.rgb = sqrt(color.rgb);\nreturn color;\n}\nlayout(std140) uniform CCGlobal {\nhighp vec4 cc_time;\nmediump vec4 cc_screenSize;\nmediump vec4 cc_nativeSize;\n};\nlayout(std140) uniform CCCamera {\nhighp mat4 cc_matView;\nhighp mat4 cc_matViewInv;\nhighp mat4 cc_matProj;\nhighp mat4 cc_matProjInv;\nhighp mat4 cc_matViewProj;\nhighp mat4 cc_matViewProjInv;\nhighp vec4 cc_cameraPos;\nmediump vec4 cc_screenScale;\nmediump vec4 cc_exposure;\nmediump vec4 cc_mainLitDir;\nmediump vec4 cc_mainLitColor;\nmediump vec4 cc_ambientSky;\nmediump vec4 cc_ambientGround;\nmediump vec4 cc_fogColor;\nmediump vec4 cc_fogBase;\nmediump vec4 cc_fogAdd;\nmediump vec4 cc_nearFar;\nmediump vec4 cc_viewPort;\n};\nfloat LinearFog(vec4 pos) {\nvec4 wPos = pos;\nfloat cam_dis = distance(cc_cameraPos, wPos);\nfloat fogStart = cc_fogBase.x;\nfloat fogEnd = cc_fogBase.y;\nreturn clamp((fogEnd - cam_dis) / (fogEnd - fogStart), 0., 1.);\n}\nfloat ExpFog(vec4 pos) {\nvec4 wPos = pos;\nfloat fogAtten = cc_fogAdd.z;\nfloat fogStart = cc_fogBase.x;\nfloat fogDensity = cc_fogBase.z;\nfloat cam_dis = max(distance(cc_cameraPos, wPos) - fogStart, 0.0) / fogAtten * 4.;\nfloat f = exp(-cam_dis * fogDensity);\nreturn f;\n}\nfloat ExpSquaredFog(vec4 pos) {\nvec4 wPos = pos;\nfloat fogAtten = cc_fogAdd.z;\nfloat fogStart = cc_fogBase.x;\nfloat fogDensity = cc_fogBase.z;\nfloat cam_dis = max(distance(cc_cameraPos, wPos) - fogStart, 0.0) / fogAtten * 4.;\nfloat f = exp(-cam_dis * cam_dis * fogDensity * fogDensity);\nreturn f;\n}\nfloat LayeredFog(vec4 pos) {\nvec4 wPos = pos;\nfloat fogAtten = cc_fogAdd.z;\nfloat _FogTop = cc_fogAdd.x;\nfloat _FogRange = cc_fogAdd.y;\nvec3 camWorldProj = cc_cameraPos.xyz;\ncamWorldProj.y = 0.;\nvec3 worldPosProj = wPos.xyz;\nworldPosProj.y = 0.;\nfloat fDeltaD = distance(worldPosProj, camWorldProj) / fogAtten * 2.0;\nfloat fDeltaY, fDensityIntegral;\nif (cc_cameraPos.y > _FogTop) {\nif (wPos.y < _FogTop) {\nfDeltaY = (_FogTop - wPos.y) / _FogRange * 2.0;\nfDensityIntegral = fDeltaY * fDeltaY * 0.5;\n} else {\nfDeltaY = 0.;\nfDensityIntegral = 0.;\n}\n} else {\nif (wPos.y < _FogTop) {\nfloat fDeltaA = (_FogTop - cc_cameraPos.y) / _FogRange * 2.;\nfloat fDeltaB = (_FogTop - wPos.y) / _FogRange * 2.;\nfDeltaY = abs(fDeltaA - fDeltaB);\nfDensityIntegral = abs((fDeltaA * fDeltaA * 0.5) - (fDeltaB * fDeltaB * 0.5));\n} else {\nfDeltaY = abs(_FogTop - cc_cameraPos.y) / _FogRange * 2.;\nfDensityIntegral = abs(fDeltaY * fDeltaY * 0.5);\n}\n}\nfloat fDensity;\nif (fDeltaY != 0.) {\nfDensity = (sqrt(1.0 + ((fDeltaD / fDeltaY) * (fDeltaD / fDeltaY)))) * fDensityIntegral;\n} else {\nfDensity = 0.;\n}\nfloat f = exp(-fDensity);\nreturn f;\n}\nvoid CC_TRANSFER_FOG_BASE(vec4 pos, out float factor)\n{\n#if CC_USE_FOG == 0\nfactor = LinearFog(pos);\n#elif CC_USE_FOG == 1\nfactor = ExpFog(pos);\n#elif CC_USE_FOG == 2\nfactor = ExpSquaredFog(pos);\n#elif CC_USE_FOG == 3\nfactor = LayeredFog(pos);\n#else\nfactor = 1.0;\n#endif\n}\nvoid CC_APPLY_FOG_BASE(inout vec4 color, float factor) {\ncolor = vec4(mix(cc_fogColor.rgb, color.rgb, factor), color.a);\n}\n#if !CC_USE_ACCURATE_FOG\nin float v_fog_factor;\n#endif\nvoid CC_APPLY_FOG(inout vec4 color) {\n#if !CC_USE_ACCURATE_FOG\nCC_APPLY_FOG_BASE(color, v_fog_factor);\n#endif\n}\nvoid CC_APPLY_FOG(inout vec4 color, vec3 worldPos) {\n#if CC_USE_ACCURATE_FOG\nfloat factor;\nCC_TRANSFER_FOG_BASE(vec4(worldPos, 1.0), factor);\n#else\nfloat factor = v_fog_factor;\n#endif\nCC_APPLY_FOG_BASE(color, factor);\n}\n#if USE_ALPHA_TEST\n#endif\n#if USE_TEXTURE\nin vec2 v_uv;\nuniform sampler2D mainTexture;\n#endif\nlayout(std140) uniform Constant {\nvec4 mainColor;\nvec4 colorScaleAndCutoff;\n};\n#if USE_VERTEX_COLOR\nin lowp vec4 v_color;\n#endif\nvec4 frag () {\nvec4 o = mainColor;\no.rgb *= colorScaleAndCutoff.xyz;\n#if USE_VERTEX_COLOR\no.rgb *= SRGBToLinear(v_color.rgb);\no.a *= v_color.a;\n#endif\n#if USE_TEXTURE\nvec4 texColor = texture(mainTexture, v_uv);\ntexColor.rgb = SRGBToLinear(texColor.rgb);\no *= texColor;\n#endif\n#if USE_ALPHA_TEST\nif (o.ALPHA_TEST_CHANNEL < colorScaleAndCutoff.w) discard;\n#endif\nCC_APPLY_FOG(o);\nreturn CCFragOutput(o);\n}\nlayout(location = 0) out vec4 cc_FragColor;\nvoid main() { cc_FragColor = frag(); }", + } + ], + [ + { + "vert": "\nprecision highp float;\nhighp float decode32 (highp vec4 rgba) {\nrgba = rgba * 255.0;\nhighp float Sign = 1.0 - (step(128.0, (rgba[3]) + 0.5)) * 2.0;\nhighp float Exponent = 2.0 * (mod(float(int((rgba[3]) + 0.5)), 128.0)) + (step(128.0, (rgba[2]) + 0.5)) - 127.0;\nhighp float Mantissa = (mod(float(int((rgba[2]) + 0.5)), 128.0)) * 65536.0 + rgba[1] * 256.0 + rgba[0] + 8388608.0;\nreturn Sign * exp2(Exponent - 23.0) * Mantissa;\n}\nstruct StandardVertInput {\nhighp vec4 position;\nvec3 normal;\nvec4 tangent;\n};\nin vec3 a_position;\nin vec3 a_normal;\nin vec2 a_texCoord;\nin vec4 a_tangent;\n#if CC_USE_MORPH\nin float a_vertexId;\nint getVertexId() {\nreturn int(a_vertexId);\n}\nlayout(std140) uniform CCMorph {\nvec4 cc_displacementWeights[15];\nvec4 cc_displacementTextureInfo;\n};\nvec2 getPixelLocation(vec2 textureResolution, int pixelIndex) {\nfloat pixelIndexF = float(pixelIndex);\nfloat x = mod(pixelIndexF, textureResolution.x);\nfloat y = floor(pixelIndexF / textureResolution.x);\nreturn vec2(x, y);\n}\nvec2 getPixelCoordFromLocation(vec2 location, vec2 textureResolution) {\nreturn (vec2(location.x, location.y) + .5) / textureResolution;\n}\n#if CC_DEVICE_SUPPORT_FLOAT_TEXTURE\nvec4 fetchVec3ArrayFromTexture(sampler2D tex, int pixelIndex) {\nivec2 texSize = textureSize(tex, 0);\nreturn texelFetch(tex, ivec2(pixelIndex % texSize.x, pixelIndex / texSize.x), 0);\n}\n#else\nvec4 fetchVec3ArrayFromTexture(sampler2D tex, int elementIndex) {\nint pixelIndex = elementIndex * 4;\nvec2 location = getPixelLocation(cc_displacementTextureInfo.xy, pixelIndex);\nvec2 x = getPixelCoordFromLocation(location + vec2(0.0, 0.0), cc_displacementTextureInfo.xy);\nvec2 y = getPixelCoordFromLocation(location + vec2(1.0, 0.0), cc_displacementTextureInfo.xy);\nvec2 z = getPixelCoordFromLocation(location + vec2(2.0, 0.0), cc_displacementTextureInfo.xy);\nreturn vec4(\ndecode32(texture(tex, x)),\ndecode32(texture(tex, y)),\ndecode32(texture(tex, z)),\n1.0\n);\n}\n#endif\nfloat getDisplacementWeight(int index) {\nint quot = index / 4;\nint remainder = index - quot * 4;\nif (remainder == 0) {\nreturn cc_displacementWeights[quot].x;\n} else if (remainder == 1) {\nreturn cc_displacementWeights[quot].y;\n} else if (remainder == 2) {\nreturn cc_displacementWeights[quot].z;\n} else {\nreturn cc_displacementWeights[quot].w;\n}\n}\nvec3 getVec3DisplacementFromTexture(sampler2D tex, int vertexIndex) {\n#if CC_MORPH_PRECOMPUTED\nreturn fetchVec3ArrayFromTexture(tex, vertexIndex).rgb;\n#else\nvec3 result = vec3(0, 0, 0);\nint nVertices = int(cc_displacementTextureInfo.z);\nfor (int iTarget = 0; iTarget < CC_MORPH_TARGET_COUNT; ++iTarget) {\nresult += (fetchVec3ArrayFromTexture(tex, nVertices * iTarget + vertexIndex).rgb * getDisplacementWeight(iTarget));\n}\nreturn result;\n#endif\n}\n#if CC_MORPH_TARGET_HAS_POSITION\nuniform sampler2D cc_PositionDisplacements;\nvec3 getPositionDisplacement(int vertexId) {\nreturn getVec3DisplacementFromTexture(cc_PositionDisplacements, vertexId);\n}\n#endif\n#if CC_MORPH_TARGET_HAS_NORMAL\nuniform sampler2D cc_NormalDisplacements;\nvec3 getNormalDisplacement(int vertexId) {\nreturn getVec3DisplacementFromTexture(cc_NormalDisplacements, vertexId);\n}\n#endif\n#if CC_MORPH_TARGET_HAS_TANGENT\nuniform sampler2D cc_TangentDisplacements;\nvec3 getTangentDisplacement(int vertexId) {\nreturn getVec3DisplacementFromTexture(cc_TangentDisplacements, vertexId);\n}\n#endif\nvoid applyMorph (inout StandardVertInput attr) {\nint vertexId = getVertexId();\n#if CC_MORPH_TARGET_HAS_POSITION\nattr.position.xyz = attr.position.xyz + getPositionDisplacement(vertexId);\n#endif\n#if CC_MORPH_TARGET_HAS_NORMAL\nattr.normal.xyz = attr.normal.xyz + getNormalDisplacement(vertexId);\n#endif\n#if CC_MORPH_TARGET_HAS_TANGENT\nattr.tangent.xyz = attr.tangent.xyz + getTangentDisplacement(vertexId);\n#endif\n}\nvoid applyMorph (inout vec4 position) {\n#if CC_MORPH_TARGET_HAS_POSITION\nposition.xyz = position.xyz + getPositionDisplacement(getVertexId());\n#endif\n}\n#endif\n#if CC_USE_SKINNING\nin vec4 a_joints;\nin vec4 a_weights;\n#if CC_USE_BAKED_ANIMATION\n#if USE_INSTANCING\nin highp vec4 a_jointAnimInfo;\n#endif\nlayout(std140) uniform CCSkinningTexture {\nhighp vec4 cc_jointTextureInfo;\n};\nlayout(std140) uniform CCSkinningAnimation {\nhighp vec4 cc_jointAnimInfo;\n};\nuniform highp sampler2D cc_jointTexture;\n#else\nlayout(std140) uniform CCSkinning {\nhighp vec4 cc_joints[30 * 3];\n};\n#endif\n#if CC_USE_BAKED_ANIMATION\n#if CC_DEVICE_SUPPORT_FLOAT_TEXTURE\nmat4 getJointMatrix (float i) {\n#if USE_INSTANCING\nhighp float j = 3.0 * (a_jointAnimInfo.x * a_jointAnimInfo.y + i) + a_jointAnimInfo.z;\n#else\nhighp float j = 3.0 * (cc_jointAnimInfo.x * cc_jointTextureInfo.y + i) + cc_jointTextureInfo.z;\n#endif\nhighp float invSize = cc_jointTextureInfo.w;\nhighp float y = floor(j * invSize);\nhighp float x = floor(j - y * cc_jointTextureInfo.x);\ny = (y + 0.5) * invSize;\nvec4 v1 = texture(cc_jointTexture, vec2((x + 0.5) * invSize, y));\nvec4 v2 = texture(cc_jointTexture, vec2((x + 1.5) * invSize, y));\nvec4 v3 = texture(cc_jointTexture, vec2((x + 2.5) * invSize, y));\nreturn mat4(vec4(v1.xyz, 0.0), vec4(v2.xyz, 0.0), vec4(v3.xyz, 0.0), vec4(v1.w, v2.w, v3.w, 1.0));\n}\n#else\nmat4 getJointMatrix (float i) {\n#if USE_INSTANCING\nhighp float j = 12.0 * (a_jointAnimInfo.x * a_jointAnimInfo.y + i) + a_jointAnimInfo.z;\n#else\nhighp float j = 12.0 * (cc_jointAnimInfo.x * cc_jointTextureInfo.y + i) + cc_jointTextureInfo.z;\n#endif\nhighp float invSize = cc_jointTextureInfo.w;\nhighp float y = floor(j * invSize);\nhighp float x = floor(j - y * cc_jointTextureInfo.x);\ny = (y + 0.5) * invSize;\nvec4 v1 = vec4(\ndecode32(texture(cc_jointTexture, vec2((x + 0.5) * invSize, y))),\ndecode32(texture(cc_jointTexture, vec2((x + 1.5) * invSize, y))),\ndecode32(texture(cc_jointTexture, vec2((x + 2.5) * invSize, y))),\ndecode32(texture(cc_jointTexture, vec2((x + 3.5) * invSize, y)))\n);\nvec4 v2 = vec4(\ndecode32(texture(cc_jointTexture, vec2((x + 4.5) * invSize, y))),\ndecode32(texture(cc_jointTexture, vec2((x + 5.5) * invSize, y))),\ndecode32(texture(cc_jointTexture, vec2((x + 6.5) * invSize, y))),\ndecode32(texture(cc_jointTexture, vec2((x + 7.5) * invSize, y)))\n);\nvec4 v3 = vec4(\ndecode32(texture(cc_jointTexture, vec2((x + 8.5) * invSize, y))),\ndecode32(texture(cc_jointTexture, vec2((x + 9.5) * invSize, y))),\ndecode32(texture(cc_jointTexture, vec2((x + 10.5) * invSize, y))),\ndecode32(texture(cc_jointTexture, vec2((x + 11.5) * invSize, y)))\n);\nreturn mat4(vec4(v1.xyz, 0.0), vec4(v2.xyz, 0.0), vec4(v3.xyz, 0.0), vec4(v1.w, v2.w, v3.w, 1.0));\n}\n#endif\n#else\nmat4 getJointMatrix (float i) {\nint idx = int(i);\nvec4 v1 = cc_joints[idx * 3];\nvec4 v2 = cc_joints[idx * 3 + 1];\nvec4 v3 = cc_joints[idx * 3 + 2];\nreturn mat4(vec4(v1.xyz, 0.0), vec4(v2.xyz, 0.0), vec4(v3.xyz, 0.0), vec4(v1.w, v2.w, v3.w, 1.0));\n}\n#endif\nmat4 skinMatrix () {\nvec4 joints = vec4(a_joints);\nreturn getJointMatrix(joints.x) * a_weights.x\n+ getJointMatrix(joints.y) * a_weights.y\n+ getJointMatrix(joints.z) * a_weights.z\n+ getJointMatrix(joints.w) * a_weights.w;\n}\nvoid CCSkin (inout vec4 position) {\nmat4 m = skinMatrix();\nposition = m * position;\n}\nvoid CCSkin (inout StandardVertInput attr) {\nmat4 m = skinMatrix();\nattr.position = m * attr.position;\nattr.normal = (m * vec4(attr.normal, 0.0)).xyz;\nattr.tangent.xyz = (m * vec4(attr.tangent.xyz, 0.0)).xyz;\n}\n#endif\nlayout(std140) uniform CCGlobal {\nhighp vec4 cc_time;\nmediump vec4 cc_screenSize;\nmediump vec4 cc_nativeSize;\n};\nlayout(std140) uniform CCCamera {\nhighp mat4 cc_matView;\nhighp mat4 cc_matViewInv;\nhighp mat4 cc_matProj;\nhighp mat4 cc_matProjInv;\nhighp mat4 cc_matViewProj;\nhighp mat4 cc_matViewProjInv;\nhighp vec4 cc_cameraPos;\nmediump vec4 cc_screenScale;\nmediump vec4 cc_exposure;\nmediump vec4 cc_mainLitDir;\nmediump vec4 cc_mainLitColor;\nmediump vec4 cc_ambientSky;\nmediump vec4 cc_ambientGround;\nmediump vec4 cc_fogColor;\nmediump vec4 cc_fogBase;\nmediump vec4 cc_fogAdd;\nmediump vec4 cc_nearFar;\nmediump vec4 cc_viewPort;\n};\nout vec2 v_uv;\nvoid main () {\nStandardVertInput In;\nIn.position = vec4(a_position, 1.0);\nIn.normal = a_normal;\nIn.tangent = a_tangent;\n#if CC_USE_MORPH\napplyMorph(In);\n#endif\n#if CC_USE_SKINNING\nCCSkin(In);\n#endif\nIn.position.xy = cc_cameraPos.w == 0.0 ? vec2(In.position.xy.x, -In.position.xy.y) : In.position.xy;\ngl_Position = In.position;\ngl_Position.y = gl_Position.y;\nv_uv = a_texCoord;\n}", + "frag": "\nprecision highp float;\nlayout(std140) uniform CCGlobal {\nhighp vec4 cc_time;\nmediump vec4 cc_screenSize;\nmediump vec4 cc_nativeSize;\n};\nlayout(std140) uniform CCCamera {\nhighp mat4 cc_matView;\nhighp mat4 cc_matViewInv;\nhighp mat4 cc_matProj;\nhighp mat4 cc_matProjInv;\nhighp mat4 cc_matViewProj;\nhighp mat4 cc_matViewProjInv;\nhighp vec4 cc_cameraPos;\nmediump vec4 cc_screenScale;\nmediump vec4 cc_exposure;\nmediump vec4 cc_mainLitDir;\nmediump vec4 cc_mainLitColor;\nmediump vec4 cc_ambientSky;\nmediump vec4 cc_ambientGround;\nmediump vec4 cc_fogColor;\nmediump vec4 cc_fogBase;\nmediump vec4 cc_fogAdd;\nmediump vec4 cc_nearFar;\nmediump vec4 cc_viewPort;\n};\nvec3 SRGBToLinear (vec3 gamma) {\nreturn gamma * gamma;\n}\nin vec2 v_uv;\nlayout(std140) uniform BloomUBO {\nmediump vec4 texSize;\n};\nuniform sampler2D outputResultMap;\nlayout(location = 0) out vec4 fragColor;\nfloat luminance(vec3 color) {\nreturn dot(color, vec3(0.2126, 0.7152, 0.0722));\n}\nvoid main() {\nvec3 color = texture(outputResultMap, v_uv).xyz;\nif (luminance(SRGBToLinear(color)) > texSize.z) {\nfragColor = vec4(color, 1.0);\n} else {\nfragColor = vec4(0.0, 0.0, 0.0, 1.0);\n}\n}", + }, + { + "vert": "\nprecision highp float;\nhighp float decode32 (highp vec4 rgba) {\nrgba = rgba * 255.0;\nhighp float Sign = 1.0 - (step(128.0, (rgba[3]) + 0.5)) * 2.0;\nhighp float Exponent = 2.0 * (mod(float(int((rgba[3]) + 0.5)), 128.0)) + (step(128.0, (rgba[2]) + 0.5)) - 127.0;\nhighp float Mantissa = (mod(float(int((rgba[2]) + 0.5)), 128.0)) * 65536.0 + rgba[1] * 256.0 + rgba[0] + 8388608.0;\nreturn Sign * exp2(Exponent - 23.0) * Mantissa;\n}\nstruct StandardVertInput {\nhighp vec4 position;\nvec3 normal;\nvec4 tangent;\n};\nin vec3 a_position;\nin vec3 a_normal;\nin vec2 a_texCoord;\nin vec4 a_tangent;\n#if CC_USE_MORPH\nin float a_vertexId;\nint getVertexId() {\nreturn int(a_vertexId);\n}\nlayout(std140) uniform CCMorph {\nvec4 cc_displacementWeights[15];\nvec4 cc_displacementTextureInfo;\n};\nvec2 getPixelLocation(vec2 textureResolution, int pixelIndex) {\nfloat pixelIndexF = float(pixelIndex);\nfloat x = mod(pixelIndexF, textureResolution.x);\nfloat y = floor(pixelIndexF / textureResolution.x);\nreturn vec2(x, y);\n}\nvec2 getPixelCoordFromLocation(vec2 location, vec2 textureResolution) {\nreturn (vec2(location.x, location.y) + .5) / textureResolution;\n}\n#if CC_DEVICE_SUPPORT_FLOAT_TEXTURE\nvec4 fetchVec3ArrayFromTexture(sampler2D tex, int pixelIndex) {\nivec2 texSize = textureSize(tex, 0);\nreturn texelFetch(tex, ivec2(pixelIndex % texSize.x, pixelIndex / texSize.x), 0);\n}\n#else\nvec4 fetchVec3ArrayFromTexture(sampler2D tex, int elementIndex) {\nint pixelIndex = elementIndex * 4;\nvec2 location = getPixelLocation(cc_displacementTextureInfo.xy, pixelIndex);\nvec2 x = getPixelCoordFromLocation(location + vec2(0.0, 0.0), cc_displacementTextureInfo.xy);\nvec2 y = getPixelCoordFromLocation(location + vec2(1.0, 0.0), cc_displacementTextureInfo.xy);\nvec2 z = getPixelCoordFromLocation(location + vec2(2.0, 0.0), cc_displacementTextureInfo.xy);\nreturn vec4(\ndecode32(texture(tex, x)),\ndecode32(texture(tex, y)),\ndecode32(texture(tex, z)),\n1.0\n);\n}\n#endif\nfloat getDisplacementWeight(int index) {\nint quot = index / 4;\nint remainder = index - quot * 4;\nif (remainder == 0) {\nreturn cc_displacementWeights[quot].x;\n} else if (remainder == 1) {\nreturn cc_displacementWeights[quot].y;\n} else if (remainder == 2) {\nreturn cc_displacementWeights[quot].z;\n} else {\nreturn cc_displacementWeights[quot].w;\n}\n}\nvec3 getVec3DisplacementFromTexture(sampler2D tex, int vertexIndex) {\n#if CC_MORPH_PRECOMPUTED\nreturn fetchVec3ArrayFromTexture(tex, vertexIndex).rgb;\n#else\nvec3 result = vec3(0, 0, 0);\nint nVertices = int(cc_displacementTextureInfo.z);\nfor (int iTarget = 0; iTarget < CC_MORPH_TARGET_COUNT; ++iTarget) {\nresult += (fetchVec3ArrayFromTexture(tex, nVertices * iTarget + vertexIndex).rgb * getDisplacementWeight(iTarget));\n}\nreturn result;\n#endif\n}\n#if CC_MORPH_TARGET_HAS_POSITION\nuniform sampler2D cc_PositionDisplacements;\nvec3 getPositionDisplacement(int vertexId) {\nreturn getVec3DisplacementFromTexture(cc_PositionDisplacements, vertexId);\n}\n#endif\n#if CC_MORPH_TARGET_HAS_NORMAL\nuniform sampler2D cc_NormalDisplacements;\nvec3 getNormalDisplacement(int vertexId) {\nreturn getVec3DisplacementFromTexture(cc_NormalDisplacements, vertexId);\n}\n#endif\n#if CC_MORPH_TARGET_HAS_TANGENT\nuniform sampler2D cc_TangentDisplacements;\nvec3 getTangentDisplacement(int vertexId) {\nreturn getVec3DisplacementFromTexture(cc_TangentDisplacements, vertexId);\n}\n#endif\nvoid applyMorph (inout StandardVertInput attr) {\nint vertexId = getVertexId();\n#if CC_MORPH_TARGET_HAS_POSITION\nattr.position.xyz = attr.position.xyz + getPositionDisplacement(vertexId);\n#endif\n#if CC_MORPH_TARGET_HAS_NORMAL\nattr.normal.xyz = attr.normal.xyz + getNormalDisplacement(vertexId);\n#endif\n#if CC_MORPH_TARGET_HAS_TANGENT\nattr.tangent.xyz = attr.tangent.xyz + getTangentDisplacement(vertexId);\n#endif\n}\nvoid applyMorph (inout vec4 position) {\n#if CC_MORPH_TARGET_HAS_POSITION\nposition.xyz = position.xyz + getPositionDisplacement(getVertexId());\n#endif\n}\n#endif\n#if CC_USE_SKINNING\nin vec4 a_joints;\nin vec4 a_weights;\n#if CC_USE_BAKED_ANIMATION\n#if USE_INSTANCING\nin highp vec4 a_jointAnimInfo;\n#endif\nlayout(std140) uniform CCSkinningTexture {\nhighp vec4 cc_jointTextureInfo;\n};\nlayout(std140) uniform CCSkinningAnimation {\nhighp vec4 cc_jointAnimInfo;\n};\nuniform highp sampler2D cc_jointTexture;\n#else\nlayout(std140) uniform CCSkinning {\nhighp vec4 cc_joints[30 * 3];\n};\n#endif\n#if CC_USE_BAKED_ANIMATION\n#if CC_DEVICE_SUPPORT_FLOAT_TEXTURE\nmat4 getJointMatrix (float i) {\n#if USE_INSTANCING\nhighp float j = 3.0 * (a_jointAnimInfo.x * a_jointAnimInfo.y + i) + a_jointAnimInfo.z;\n#else\nhighp float j = 3.0 * (cc_jointAnimInfo.x * cc_jointTextureInfo.y + i) + cc_jointTextureInfo.z;\n#endif\nhighp float invSize = cc_jointTextureInfo.w;\nhighp float y = floor(j * invSize);\nhighp float x = floor(j - y * cc_jointTextureInfo.x);\ny = (y + 0.5) * invSize;\nvec4 v1 = texture(cc_jointTexture, vec2((x + 0.5) * invSize, y));\nvec4 v2 = texture(cc_jointTexture, vec2((x + 1.5) * invSize, y));\nvec4 v3 = texture(cc_jointTexture, vec2((x + 2.5) * invSize, y));\nreturn mat4(vec4(v1.xyz, 0.0), vec4(v2.xyz, 0.0), vec4(v3.xyz, 0.0), vec4(v1.w, v2.w, v3.w, 1.0));\n}\n#else\nmat4 getJointMatrix (float i) {\n#if USE_INSTANCING\nhighp float j = 12.0 * (a_jointAnimInfo.x * a_jointAnimInfo.y + i) + a_jointAnimInfo.z;\n#else\nhighp float j = 12.0 * (cc_jointAnimInfo.x * cc_jointTextureInfo.y + i) + cc_jointTextureInfo.z;\n#endif\nhighp float invSize = cc_jointTextureInfo.w;\nhighp float y = floor(j * invSize);\nhighp float x = floor(j - y * cc_jointTextureInfo.x);\ny = (y + 0.5) * invSize;\nvec4 v1 = vec4(\ndecode32(texture(cc_jointTexture, vec2((x + 0.5) * invSize, y))),\ndecode32(texture(cc_jointTexture, vec2((x + 1.5) * invSize, y))),\ndecode32(texture(cc_jointTexture, vec2((x + 2.5) * invSize, y))),\ndecode32(texture(cc_jointTexture, vec2((x + 3.5) * invSize, y)))\n);\nvec4 v2 = vec4(\ndecode32(texture(cc_jointTexture, vec2((x + 4.5) * invSize, y))),\ndecode32(texture(cc_jointTexture, vec2((x + 5.5) * invSize, y))),\ndecode32(texture(cc_jointTexture, vec2((x + 6.5) * invSize, y))),\ndecode32(texture(cc_jointTexture, vec2((x + 7.5) * invSize, y)))\n);\nvec4 v3 = vec4(\ndecode32(texture(cc_jointTexture, vec2((x + 8.5) * invSize, y))),\ndecode32(texture(cc_jointTexture, vec2((x + 9.5) * invSize, y))),\ndecode32(texture(cc_jointTexture, vec2((x + 10.5) * invSize, y))),\ndecode32(texture(cc_jointTexture, vec2((x + 11.5) * invSize, y)))\n);\nreturn mat4(vec4(v1.xyz, 0.0), vec4(v2.xyz, 0.0), vec4(v3.xyz, 0.0), vec4(v1.w, v2.w, v3.w, 1.0));\n}\n#endif\n#else\nmat4 getJointMatrix (float i) {\nint idx = int(i);\nvec4 v1 = cc_joints[idx * 3];\nvec4 v2 = cc_joints[idx * 3 + 1];\nvec4 v3 = cc_joints[idx * 3 + 2];\nreturn mat4(vec4(v1.xyz, 0.0), vec4(v2.xyz, 0.0), vec4(v3.xyz, 0.0), vec4(v1.w, v2.w, v3.w, 1.0));\n}\n#endif\nmat4 skinMatrix () {\nvec4 joints = vec4(a_joints);\nreturn getJointMatrix(joints.x) * a_weights.x\n+ getJointMatrix(joints.y) * a_weights.y\n+ getJointMatrix(joints.z) * a_weights.z\n+ getJointMatrix(joints.w) * a_weights.w;\n}\nvoid CCSkin (inout vec4 position) {\nmat4 m = skinMatrix();\nposition = m * position;\n}\nvoid CCSkin (inout StandardVertInput attr) {\nmat4 m = skinMatrix();\nattr.position = m * attr.position;\nattr.normal = (m * vec4(attr.normal, 0.0)).xyz;\nattr.tangent.xyz = (m * vec4(attr.tangent.xyz, 0.0)).xyz;\n}\n#endif\nlayout(std140) uniform CCGlobal {\nhighp vec4 cc_time;\nmediump vec4 cc_screenSize;\nmediump vec4 cc_nativeSize;\n};\nlayout(std140) uniform CCCamera {\nhighp mat4 cc_matView;\nhighp mat4 cc_matViewInv;\nhighp mat4 cc_matProj;\nhighp mat4 cc_matProjInv;\nhighp mat4 cc_matViewProj;\nhighp mat4 cc_matViewProjInv;\nhighp vec4 cc_cameraPos;\nmediump vec4 cc_screenScale;\nmediump vec4 cc_exposure;\nmediump vec4 cc_mainLitDir;\nmediump vec4 cc_mainLitColor;\nmediump vec4 cc_ambientSky;\nmediump vec4 cc_ambientGround;\nmediump vec4 cc_fogColor;\nmediump vec4 cc_fogBase;\nmediump vec4 cc_fogAdd;\nmediump vec4 cc_nearFar;\nmediump vec4 cc_viewPort;\n};\nout vec2 v_uv;\nvoid main () {\nStandardVertInput In;\nIn.position = vec4(a_position, 1.0);\nIn.normal = a_normal;\nIn.tangent = a_tangent;\n#if CC_USE_MORPH\napplyMorph(In);\n#endif\n#if CC_USE_SKINNING\nCCSkin(In);\n#endif\nIn.position.xy = cc_cameraPos.w == 0.0 ? vec2(In.position.xy.x, -In.position.xy.y) : In.position.xy;\ngl_Position = In.position;\ngl_Position.y = gl_Position.y;\nv_uv = a_texCoord;\n}", + "frag": "\nprecision highp float;\nlayout(std140) uniform CCGlobal {\nhighp vec4 cc_time;\nmediump vec4 cc_screenSize;\nmediump vec4 cc_nativeSize;\n};\nlayout(std140) uniform CCCamera {\nhighp mat4 cc_matView;\nhighp mat4 cc_matViewInv;\nhighp mat4 cc_matProj;\nhighp mat4 cc_matProjInv;\nhighp mat4 cc_matViewProj;\nhighp mat4 cc_matViewProjInv;\nhighp vec4 cc_cameraPos;\nmediump vec4 cc_screenScale;\nmediump vec4 cc_exposure;\nmediump vec4 cc_mainLitDir;\nmediump vec4 cc_mainLitColor;\nmediump vec4 cc_ambientSky;\nmediump vec4 cc_ambientGround;\nmediump vec4 cc_fogColor;\nmediump vec4 cc_fogBase;\nmediump vec4 cc_fogAdd;\nmediump vec4 cc_nearFar;\nmediump vec4 cc_viewPort;\n};\nin vec2 v_uv;\nlayout(std140) uniform BloomUBO {\nmediump vec4 texSize;\n};\nuniform sampler2D bloomTexture;\nlayout(location = 0) out vec4 fragColor;\nvec3 downsample4taps(vec2 uv, vec2 halfpixel) {\nvec3 sum = texture(bloomTexture, uv + vec2(-halfpixel.x, halfpixel.y)).xyz;\nsum += texture(bloomTexture, uv + vec2(halfpixel.x, halfpixel.y)).xyz;\nsum += texture(bloomTexture, uv + vec2(halfpixel.x, -halfpixel.y)).xyz;\nsum += texture(bloomTexture, uv + vec2(-halfpixel.x, -halfpixel.y)).xyz;\nreturn sum / 4.0;\n}\nvoid main()\n{\nvec3 result = downsample4taps(v_uv, 1.0 / texSize.xy).rgb;\nfragColor = vec4(result, 1.0);\n}", + }, + { + "vert": "\nprecision highp float;\nhighp float decode32 (highp vec4 rgba) {\nrgba = rgba * 255.0;\nhighp float Sign = 1.0 - (step(128.0, (rgba[3]) + 0.5)) * 2.0;\nhighp float Exponent = 2.0 * (mod(float(int((rgba[3]) + 0.5)), 128.0)) + (step(128.0, (rgba[2]) + 0.5)) - 127.0;\nhighp float Mantissa = (mod(float(int((rgba[2]) + 0.5)), 128.0)) * 65536.0 + rgba[1] * 256.0 + rgba[0] + 8388608.0;\nreturn Sign * exp2(Exponent - 23.0) * Mantissa;\n}\nstruct StandardVertInput {\nhighp vec4 position;\nvec3 normal;\nvec4 tangent;\n};\nin vec3 a_position;\nin vec3 a_normal;\nin vec2 a_texCoord;\nin vec4 a_tangent;\n#if CC_USE_MORPH\nin float a_vertexId;\nint getVertexId() {\nreturn int(a_vertexId);\n}\nlayout(std140) uniform CCMorph {\nvec4 cc_displacementWeights[15];\nvec4 cc_displacementTextureInfo;\n};\nvec2 getPixelLocation(vec2 textureResolution, int pixelIndex) {\nfloat pixelIndexF = float(pixelIndex);\nfloat x = mod(pixelIndexF, textureResolution.x);\nfloat y = floor(pixelIndexF / textureResolution.x);\nreturn vec2(x, y);\n}\nvec2 getPixelCoordFromLocation(vec2 location, vec2 textureResolution) {\nreturn (vec2(location.x, location.y) + .5) / textureResolution;\n}\n#if CC_DEVICE_SUPPORT_FLOAT_TEXTURE\nvec4 fetchVec3ArrayFromTexture(sampler2D tex, int pixelIndex) {\nivec2 texSize = textureSize(tex, 0);\nreturn texelFetch(tex, ivec2(pixelIndex % texSize.x, pixelIndex / texSize.x), 0);\n}\n#else\nvec4 fetchVec3ArrayFromTexture(sampler2D tex, int elementIndex) {\nint pixelIndex = elementIndex * 4;\nvec2 location = getPixelLocation(cc_displacementTextureInfo.xy, pixelIndex);\nvec2 x = getPixelCoordFromLocation(location + vec2(0.0, 0.0), cc_displacementTextureInfo.xy);\nvec2 y = getPixelCoordFromLocation(location + vec2(1.0, 0.0), cc_displacementTextureInfo.xy);\nvec2 z = getPixelCoordFromLocation(location + vec2(2.0, 0.0), cc_displacementTextureInfo.xy);\nreturn vec4(\ndecode32(texture(tex, x)),\ndecode32(texture(tex, y)),\ndecode32(texture(tex, z)),\n1.0\n);\n}\n#endif\nfloat getDisplacementWeight(int index) {\nint quot = index / 4;\nint remainder = index - quot * 4;\nif (remainder == 0) {\nreturn cc_displacementWeights[quot].x;\n} else if (remainder == 1) {\nreturn cc_displacementWeights[quot].y;\n} else if (remainder == 2) {\nreturn cc_displacementWeights[quot].z;\n} else {\nreturn cc_displacementWeights[quot].w;\n}\n}\nvec3 getVec3DisplacementFromTexture(sampler2D tex, int vertexIndex) {\n#if CC_MORPH_PRECOMPUTED\nreturn fetchVec3ArrayFromTexture(tex, vertexIndex).rgb;\n#else\nvec3 result = vec3(0, 0, 0);\nint nVertices = int(cc_displacementTextureInfo.z);\nfor (int iTarget = 0; iTarget < CC_MORPH_TARGET_COUNT; ++iTarget) {\nresult += (fetchVec3ArrayFromTexture(tex, nVertices * iTarget + vertexIndex).rgb * getDisplacementWeight(iTarget));\n}\nreturn result;\n#endif\n}\n#if CC_MORPH_TARGET_HAS_POSITION\nuniform sampler2D cc_PositionDisplacements;\nvec3 getPositionDisplacement(int vertexId) {\nreturn getVec3DisplacementFromTexture(cc_PositionDisplacements, vertexId);\n}\n#endif\n#if CC_MORPH_TARGET_HAS_NORMAL\nuniform sampler2D cc_NormalDisplacements;\nvec3 getNormalDisplacement(int vertexId) {\nreturn getVec3DisplacementFromTexture(cc_NormalDisplacements, vertexId);\n}\n#endif\n#if CC_MORPH_TARGET_HAS_TANGENT\nuniform sampler2D cc_TangentDisplacements;\nvec3 getTangentDisplacement(int vertexId) {\nreturn getVec3DisplacementFromTexture(cc_TangentDisplacements, vertexId);\n}\n#endif\nvoid applyMorph (inout StandardVertInput attr) {\nint vertexId = getVertexId();\n#if CC_MORPH_TARGET_HAS_POSITION\nattr.position.xyz = attr.position.xyz + getPositionDisplacement(vertexId);\n#endif\n#if CC_MORPH_TARGET_HAS_NORMAL\nattr.normal.xyz = attr.normal.xyz + getNormalDisplacement(vertexId);\n#endif\n#if CC_MORPH_TARGET_HAS_TANGENT\nattr.tangent.xyz = attr.tangent.xyz + getTangentDisplacement(vertexId);\n#endif\n}\nvoid applyMorph (inout vec4 position) {\n#if CC_MORPH_TARGET_HAS_POSITION\nposition.xyz = position.xyz + getPositionDisplacement(getVertexId());\n#endif\n}\n#endif\n#if CC_USE_SKINNING\nin vec4 a_joints;\nin vec4 a_weights;\n#if CC_USE_BAKED_ANIMATION\n#if USE_INSTANCING\nin highp vec4 a_jointAnimInfo;\n#endif\nlayout(std140) uniform CCSkinningTexture {\nhighp vec4 cc_jointTextureInfo;\n};\nlayout(std140) uniform CCSkinningAnimation {\nhighp vec4 cc_jointAnimInfo;\n};\nuniform highp sampler2D cc_jointTexture;\n#else\nlayout(std140) uniform CCSkinning {\nhighp vec4 cc_joints[30 * 3];\n};\n#endif\n#if CC_USE_BAKED_ANIMATION\n#if CC_DEVICE_SUPPORT_FLOAT_TEXTURE\nmat4 getJointMatrix (float i) {\n#if USE_INSTANCING\nhighp float j = 3.0 * (a_jointAnimInfo.x * a_jointAnimInfo.y + i) + a_jointAnimInfo.z;\n#else\nhighp float j = 3.0 * (cc_jointAnimInfo.x * cc_jointTextureInfo.y + i) + cc_jointTextureInfo.z;\n#endif\nhighp float invSize = cc_jointTextureInfo.w;\nhighp float y = floor(j * invSize);\nhighp float x = floor(j - y * cc_jointTextureInfo.x);\ny = (y + 0.5) * invSize;\nvec4 v1 = texture(cc_jointTexture, vec2((x + 0.5) * invSize, y));\nvec4 v2 = texture(cc_jointTexture, vec2((x + 1.5) * invSize, y));\nvec4 v3 = texture(cc_jointTexture, vec2((x + 2.5) * invSize, y));\nreturn mat4(vec4(v1.xyz, 0.0), vec4(v2.xyz, 0.0), vec4(v3.xyz, 0.0), vec4(v1.w, v2.w, v3.w, 1.0));\n}\n#else\nmat4 getJointMatrix (float i) {\n#if USE_INSTANCING\nhighp float j = 12.0 * (a_jointAnimInfo.x * a_jointAnimInfo.y + i) + a_jointAnimInfo.z;\n#else\nhighp float j = 12.0 * (cc_jointAnimInfo.x * cc_jointTextureInfo.y + i) + cc_jointTextureInfo.z;\n#endif\nhighp float invSize = cc_jointTextureInfo.w;\nhighp float y = floor(j * invSize);\nhighp float x = floor(j - y * cc_jointTextureInfo.x);\ny = (y + 0.5) * invSize;\nvec4 v1 = vec4(\ndecode32(texture(cc_jointTexture, vec2((x + 0.5) * invSize, y))),\ndecode32(texture(cc_jointTexture, vec2((x + 1.5) * invSize, y))),\ndecode32(texture(cc_jointTexture, vec2((x + 2.5) * invSize, y))),\ndecode32(texture(cc_jointTexture, vec2((x + 3.5) * invSize, y)))\n);\nvec4 v2 = vec4(\ndecode32(texture(cc_jointTexture, vec2((x + 4.5) * invSize, y))),\ndecode32(texture(cc_jointTexture, vec2((x + 5.5) * invSize, y))),\ndecode32(texture(cc_jointTexture, vec2((x + 6.5) * invSize, y))),\ndecode32(texture(cc_jointTexture, vec2((x + 7.5) * invSize, y)))\n);\nvec4 v3 = vec4(\ndecode32(texture(cc_jointTexture, vec2((x + 8.5) * invSize, y))),\ndecode32(texture(cc_jointTexture, vec2((x + 9.5) * invSize, y))),\ndecode32(texture(cc_jointTexture, vec2((x + 10.5) * invSize, y))),\ndecode32(texture(cc_jointTexture, vec2((x + 11.5) * invSize, y)))\n);\nreturn mat4(vec4(v1.xyz, 0.0), vec4(v2.xyz, 0.0), vec4(v3.xyz, 0.0), vec4(v1.w, v2.w, v3.w, 1.0));\n}\n#endif\n#else\nmat4 getJointMatrix (float i) {\nint idx = int(i);\nvec4 v1 = cc_joints[idx * 3];\nvec4 v2 = cc_joints[idx * 3 + 1];\nvec4 v3 = cc_joints[idx * 3 + 2];\nreturn mat4(vec4(v1.xyz, 0.0), vec4(v2.xyz, 0.0), vec4(v3.xyz, 0.0), vec4(v1.w, v2.w, v3.w, 1.0));\n}\n#endif\nmat4 skinMatrix () {\nvec4 joints = vec4(a_joints);\nreturn getJointMatrix(joints.x) * a_weights.x\n+ getJointMatrix(joints.y) * a_weights.y\n+ getJointMatrix(joints.z) * a_weights.z\n+ getJointMatrix(joints.w) * a_weights.w;\n}\nvoid CCSkin (inout vec4 position) {\nmat4 m = skinMatrix();\nposition = m * position;\n}\nvoid CCSkin (inout StandardVertInput attr) {\nmat4 m = skinMatrix();\nattr.position = m * attr.position;\nattr.normal = (m * vec4(attr.normal, 0.0)).xyz;\nattr.tangent.xyz = (m * vec4(attr.tangent.xyz, 0.0)).xyz;\n}\n#endif\nlayout(std140) uniform CCGlobal {\nhighp vec4 cc_time;\nmediump vec4 cc_screenSize;\nmediump vec4 cc_nativeSize;\n};\nlayout(std140) uniform CCCamera {\nhighp mat4 cc_matView;\nhighp mat4 cc_matViewInv;\nhighp mat4 cc_matProj;\nhighp mat4 cc_matProjInv;\nhighp mat4 cc_matViewProj;\nhighp mat4 cc_matViewProjInv;\nhighp vec4 cc_cameraPos;\nmediump vec4 cc_screenScale;\nmediump vec4 cc_exposure;\nmediump vec4 cc_mainLitDir;\nmediump vec4 cc_mainLitColor;\nmediump vec4 cc_ambientSky;\nmediump vec4 cc_ambientGround;\nmediump vec4 cc_fogColor;\nmediump vec4 cc_fogBase;\nmediump vec4 cc_fogAdd;\nmediump vec4 cc_nearFar;\nmediump vec4 cc_viewPort;\n};\nout vec2 v_uv;\nvoid main () {\nStandardVertInput In;\nIn.position = vec4(a_position, 1.0);\nIn.normal = a_normal;\nIn.tangent = a_tangent;\n#if CC_USE_MORPH\napplyMorph(In);\n#endif\n#if CC_USE_SKINNING\nCCSkin(In);\n#endif\nIn.position.xy = cc_cameraPos.w == 0.0 ? vec2(In.position.xy.x, -In.position.xy.y) : In.position.xy;\ngl_Position = In.position;\ngl_Position.y = gl_Position.y;\nv_uv = a_texCoord;\n}", + "frag": "\nprecision highp float;\nlayout(std140) uniform CCGlobal {\nhighp vec4 cc_time;\nmediump vec4 cc_screenSize;\nmediump vec4 cc_nativeSize;\n};\nlayout(std140) uniform CCCamera {\nhighp mat4 cc_matView;\nhighp mat4 cc_matViewInv;\nhighp mat4 cc_matProj;\nhighp mat4 cc_matProjInv;\nhighp mat4 cc_matViewProj;\nhighp mat4 cc_matViewProjInv;\nhighp vec4 cc_cameraPos;\nmediump vec4 cc_screenScale;\nmediump vec4 cc_exposure;\nmediump vec4 cc_mainLitDir;\nmediump vec4 cc_mainLitColor;\nmediump vec4 cc_ambientSky;\nmediump vec4 cc_ambientGround;\nmediump vec4 cc_fogColor;\nmediump vec4 cc_fogBase;\nmediump vec4 cc_fogAdd;\nmediump vec4 cc_nearFar;\nmediump vec4 cc_viewPort;\n};\nin vec2 v_uv;\nlayout(std140) uniform BloomUBO {\nmediump vec4 texSize;\n};\nuniform sampler2D bloomTexture;\nlayout(location = 0) out vec4 fragColor;\nvec3 upsample4taps(vec2 uv, vec2 halfpixel) {\nvec3 sum = texture(bloomTexture, uv + vec2(-halfpixel.x, halfpixel.y)).xyz;\nsum += texture(bloomTexture, uv + vec2(halfpixel.x, halfpixel.y)).xyz;\nsum += texture(bloomTexture, uv + vec2(halfpixel.x, -halfpixel.y)).xyz;\nsum += texture(bloomTexture, uv + vec2(-halfpixel.x, -halfpixel.y)).xyz;\nreturn sum / 4.0;\n}\nvoid main() {\nvec3 result = upsample4taps(v_uv, 0.5 / texSize.xy).rgb;\nfragColor = vec4(result, 1.0);\n}", + }, + { + "vert": "\nprecision highp float;\nhighp float decode32 (highp vec4 rgba) {\nrgba = rgba * 255.0;\nhighp float Sign = 1.0 - (step(128.0, (rgba[3]) + 0.5)) * 2.0;\nhighp float Exponent = 2.0 * (mod(float(int((rgba[3]) + 0.5)), 128.0)) + (step(128.0, (rgba[2]) + 0.5)) - 127.0;\nhighp float Mantissa = (mod(float(int((rgba[2]) + 0.5)), 128.0)) * 65536.0 + rgba[1] * 256.0 + rgba[0] + 8388608.0;\nreturn Sign * exp2(Exponent - 23.0) * Mantissa;\n}\nstruct StandardVertInput {\nhighp vec4 position;\nvec3 normal;\nvec4 tangent;\n};\nin vec3 a_position;\nin vec3 a_normal;\nin vec2 a_texCoord;\nin vec4 a_tangent;\n#if CC_USE_MORPH\nin float a_vertexId;\nint getVertexId() {\nreturn int(a_vertexId);\n}\nlayout(std140) uniform CCMorph {\nvec4 cc_displacementWeights[15];\nvec4 cc_displacementTextureInfo;\n};\nvec2 getPixelLocation(vec2 textureResolution, int pixelIndex) {\nfloat pixelIndexF = float(pixelIndex);\nfloat x = mod(pixelIndexF, textureResolution.x);\nfloat y = floor(pixelIndexF / textureResolution.x);\nreturn vec2(x, y);\n}\nvec2 getPixelCoordFromLocation(vec2 location, vec2 textureResolution) {\nreturn (vec2(location.x, location.y) + .5) / textureResolution;\n}\n#if CC_DEVICE_SUPPORT_FLOAT_TEXTURE\nvec4 fetchVec3ArrayFromTexture(sampler2D tex, int pixelIndex) {\nivec2 texSize = textureSize(tex, 0);\nreturn texelFetch(tex, ivec2(pixelIndex % texSize.x, pixelIndex / texSize.x), 0);\n}\n#else\nvec4 fetchVec3ArrayFromTexture(sampler2D tex, int elementIndex) {\nint pixelIndex = elementIndex * 4;\nvec2 location = getPixelLocation(cc_displacementTextureInfo.xy, pixelIndex);\nvec2 x = getPixelCoordFromLocation(location + vec2(0.0, 0.0), cc_displacementTextureInfo.xy);\nvec2 y = getPixelCoordFromLocation(location + vec2(1.0, 0.0), cc_displacementTextureInfo.xy);\nvec2 z = getPixelCoordFromLocation(location + vec2(2.0, 0.0), cc_displacementTextureInfo.xy);\nreturn vec4(\ndecode32(texture(tex, x)),\ndecode32(texture(tex, y)),\ndecode32(texture(tex, z)),\n1.0\n);\n}\n#endif\nfloat getDisplacementWeight(int index) {\nint quot = index / 4;\nint remainder = index - quot * 4;\nif (remainder == 0) {\nreturn cc_displacementWeights[quot].x;\n} else if (remainder == 1) {\nreturn cc_displacementWeights[quot].y;\n} else if (remainder == 2) {\nreturn cc_displacementWeights[quot].z;\n} else {\nreturn cc_displacementWeights[quot].w;\n}\n}\nvec3 getVec3DisplacementFromTexture(sampler2D tex, int vertexIndex) {\n#if CC_MORPH_PRECOMPUTED\nreturn fetchVec3ArrayFromTexture(tex, vertexIndex).rgb;\n#else\nvec3 result = vec3(0, 0, 0);\nint nVertices = int(cc_displacementTextureInfo.z);\nfor (int iTarget = 0; iTarget < CC_MORPH_TARGET_COUNT; ++iTarget) {\nresult += (fetchVec3ArrayFromTexture(tex, nVertices * iTarget + vertexIndex).rgb * getDisplacementWeight(iTarget));\n}\nreturn result;\n#endif\n}\n#if CC_MORPH_TARGET_HAS_POSITION\nuniform sampler2D cc_PositionDisplacements;\nvec3 getPositionDisplacement(int vertexId) {\nreturn getVec3DisplacementFromTexture(cc_PositionDisplacements, vertexId);\n}\n#endif\n#if CC_MORPH_TARGET_HAS_NORMAL\nuniform sampler2D cc_NormalDisplacements;\nvec3 getNormalDisplacement(int vertexId) {\nreturn getVec3DisplacementFromTexture(cc_NormalDisplacements, vertexId);\n}\n#endif\n#if CC_MORPH_TARGET_HAS_TANGENT\nuniform sampler2D cc_TangentDisplacements;\nvec3 getTangentDisplacement(int vertexId) {\nreturn getVec3DisplacementFromTexture(cc_TangentDisplacements, vertexId);\n}\n#endif\nvoid applyMorph (inout StandardVertInput attr) {\nint vertexId = getVertexId();\n#if CC_MORPH_TARGET_HAS_POSITION\nattr.position.xyz = attr.position.xyz + getPositionDisplacement(vertexId);\n#endif\n#if CC_MORPH_TARGET_HAS_NORMAL\nattr.normal.xyz = attr.normal.xyz + getNormalDisplacement(vertexId);\n#endif\n#if CC_MORPH_TARGET_HAS_TANGENT\nattr.tangent.xyz = attr.tangent.xyz + getTangentDisplacement(vertexId);\n#endif\n}\nvoid applyMorph (inout vec4 position) {\n#if CC_MORPH_TARGET_HAS_POSITION\nposition.xyz = position.xyz + getPositionDisplacement(getVertexId());\n#endif\n}\n#endif\n#if CC_USE_SKINNING\nin vec4 a_joints;\nin vec4 a_weights;\n#if CC_USE_BAKED_ANIMATION\n#if USE_INSTANCING\nin highp vec4 a_jointAnimInfo;\n#endif\nlayout(std140) uniform CCSkinningTexture {\nhighp vec4 cc_jointTextureInfo;\n};\nlayout(std140) uniform CCSkinningAnimation {\nhighp vec4 cc_jointAnimInfo;\n};\nuniform highp sampler2D cc_jointTexture;\n#else\nlayout(std140) uniform CCSkinning {\nhighp vec4 cc_joints[30 * 3];\n};\n#endif\n#if CC_USE_BAKED_ANIMATION\n#if CC_DEVICE_SUPPORT_FLOAT_TEXTURE\nmat4 getJointMatrix (float i) {\n#if USE_INSTANCING\nhighp float j = 3.0 * (a_jointAnimInfo.x * a_jointAnimInfo.y + i) + a_jointAnimInfo.z;\n#else\nhighp float j = 3.0 * (cc_jointAnimInfo.x * cc_jointTextureInfo.y + i) + cc_jointTextureInfo.z;\n#endif\nhighp float invSize = cc_jointTextureInfo.w;\nhighp float y = floor(j * invSize);\nhighp float x = floor(j - y * cc_jointTextureInfo.x);\ny = (y + 0.5) * invSize;\nvec4 v1 = texture(cc_jointTexture, vec2((x + 0.5) * invSize, y));\nvec4 v2 = texture(cc_jointTexture, vec2((x + 1.5) * invSize, y));\nvec4 v3 = texture(cc_jointTexture, vec2((x + 2.5) * invSize, y));\nreturn mat4(vec4(v1.xyz, 0.0), vec4(v2.xyz, 0.0), vec4(v3.xyz, 0.0), vec4(v1.w, v2.w, v3.w, 1.0));\n}\n#else\nmat4 getJointMatrix (float i) {\n#if USE_INSTANCING\nhighp float j = 12.0 * (a_jointAnimInfo.x * a_jointAnimInfo.y + i) + a_jointAnimInfo.z;\n#else\nhighp float j = 12.0 * (cc_jointAnimInfo.x * cc_jointTextureInfo.y + i) + cc_jointTextureInfo.z;\n#endif\nhighp float invSize = cc_jointTextureInfo.w;\nhighp float y = floor(j * invSize);\nhighp float x = floor(j - y * cc_jointTextureInfo.x);\ny = (y + 0.5) * invSize;\nvec4 v1 = vec4(\ndecode32(texture(cc_jointTexture, vec2((x + 0.5) * invSize, y))),\ndecode32(texture(cc_jointTexture, vec2((x + 1.5) * invSize, y))),\ndecode32(texture(cc_jointTexture, vec2((x + 2.5) * invSize, y))),\ndecode32(texture(cc_jointTexture, vec2((x + 3.5) * invSize, y)))\n);\nvec4 v2 = vec4(\ndecode32(texture(cc_jointTexture, vec2((x + 4.5) * invSize, y))),\ndecode32(texture(cc_jointTexture, vec2((x + 5.5) * invSize, y))),\ndecode32(texture(cc_jointTexture, vec2((x + 6.5) * invSize, y))),\ndecode32(texture(cc_jointTexture, vec2((x + 7.5) * invSize, y)))\n);\nvec4 v3 = vec4(\ndecode32(texture(cc_jointTexture, vec2((x + 8.5) * invSize, y))),\ndecode32(texture(cc_jointTexture, vec2((x + 9.5) * invSize, y))),\ndecode32(texture(cc_jointTexture, vec2((x + 10.5) * invSize, y))),\ndecode32(texture(cc_jointTexture, vec2((x + 11.5) * invSize, y)))\n);\nreturn mat4(vec4(v1.xyz, 0.0), vec4(v2.xyz, 0.0), vec4(v3.xyz, 0.0), vec4(v1.w, v2.w, v3.w, 1.0));\n}\n#endif\n#else\nmat4 getJointMatrix (float i) {\nint idx = int(i);\nvec4 v1 = cc_joints[idx * 3];\nvec4 v2 = cc_joints[idx * 3 + 1];\nvec4 v3 = cc_joints[idx * 3 + 2];\nreturn mat4(vec4(v1.xyz, 0.0), vec4(v2.xyz, 0.0), vec4(v3.xyz, 0.0), vec4(v1.w, v2.w, v3.w, 1.0));\n}\n#endif\nmat4 skinMatrix () {\nvec4 joints = vec4(a_joints);\nreturn getJointMatrix(joints.x) * a_weights.x\n+ getJointMatrix(joints.y) * a_weights.y\n+ getJointMatrix(joints.z) * a_weights.z\n+ getJointMatrix(joints.w) * a_weights.w;\n}\nvoid CCSkin (inout vec4 position) {\nmat4 m = skinMatrix();\nposition = m * position;\n}\nvoid CCSkin (inout StandardVertInput attr) {\nmat4 m = skinMatrix();\nattr.position = m * attr.position;\nattr.normal = (m * vec4(attr.normal, 0.0)).xyz;\nattr.tangent.xyz = (m * vec4(attr.tangent.xyz, 0.0)).xyz;\n}\n#endif\nlayout(std140) uniform CCGlobal {\nhighp vec4 cc_time;\nmediump vec4 cc_screenSize;\nmediump vec4 cc_nativeSize;\n};\nlayout(std140) uniform CCCamera {\nhighp mat4 cc_matView;\nhighp mat4 cc_matViewInv;\nhighp mat4 cc_matProj;\nhighp mat4 cc_matProjInv;\nhighp mat4 cc_matViewProj;\nhighp mat4 cc_matViewProjInv;\nhighp vec4 cc_cameraPos;\nmediump vec4 cc_screenScale;\nmediump vec4 cc_exposure;\nmediump vec4 cc_mainLitDir;\nmediump vec4 cc_mainLitColor;\nmediump vec4 cc_ambientSky;\nmediump vec4 cc_ambientGround;\nmediump vec4 cc_fogColor;\nmediump vec4 cc_fogBase;\nmediump vec4 cc_fogAdd;\nmediump vec4 cc_nearFar;\nmediump vec4 cc_viewPort;\n};\nout vec2 v_uv;\nvoid main () {\nStandardVertInput In;\nIn.position = vec4(a_position, 1.0);\nIn.normal = a_normal;\nIn.tangent = a_tangent;\n#if CC_USE_MORPH\napplyMorph(In);\n#endif\n#if CC_USE_SKINNING\nCCSkin(In);\n#endif\nIn.position.xy = cc_cameraPos.w == 0.0 ? vec2(In.position.xy.x, -In.position.xy.y) : In.position.xy;\ngl_Position = In.position;\ngl_Position.y = gl_Position.y;\nv_uv = a_texCoord;\n}", + "frag": "\nprecision highp float;\nlayout(std140) uniform CCGlobal {\nhighp vec4 cc_time;\nmediump vec4 cc_screenSize;\nmediump vec4 cc_nativeSize;\n};\nlayout(std140) uniform CCCamera {\nhighp mat4 cc_matView;\nhighp mat4 cc_matViewInv;\nhighp mat4 cc_matProj;\nhighp mat4 cc_matProjInv;\nhighp mat4 cc_matViewProj;\nhighp mat4 cc_matViewProjInv;\nhighp vec4 cc_cameraPos;\nmediump vec4 cc_screenScale;\nmediump vec4 cc_exposure;\nmediump vec4 cc_mainLitDir;\nmediump vec4 cc_mainLitColor;\nmediump vec4 cc_ambientSky;\nmediump vec4 cc_ambientGround;\nmediump vec4 cc_fogColor;\nmediump vec4 cc_fogBase;\nmediump vec4 cc_fogAdd;\nmediump vec4 cc_nearFar;\nmediump vec4 cc_viewPort;\n};\nin vec2 v_uv;\nlayout(std140) uniform BloomUBO {\nmediump vec4 texSize;\n};\nuniform sampler2D outputResultMap;\nuniform sampler2D bloomTexture;\nlayout(location = 0) out vec4 fragColor;\nvoid main() {\nvec4 hdrColor = texture(outputResultMap, v_uv);\nvec3 bloomColor = texture(bloomTexture, v_uv).rgb;\nvec3 result = hdrColor.rgb + bloomColor * texSize.w * hdrColor.a;\nfragColor = vec4(result, hdrColor.a);\n}", + } + ], + [ + { + "vert": "\nprecision highp float;\nstruct StandardVertInput {\nhighp vec4 position;\nvec3 normal;\nvec4 tangent;\n};\nin vec3 a_position;\nin vec3 a_normal;\nin vec2 a_texCoord;\nin vec4 a_tangent;\nlayout(std140) uniform CCGlobal {\nhighp vec4 cc_time;\nmediump vec4 cc_screenSize;\nmediump vec4 cc_nativeSize;\n};\nlayout(std140) uniform CCCamera {\nhighp mat4 cc_matView;\nhighp mat4 cc_matViewInv;\nhighp mat4 cc_matProj;\nhighp mat4 cc_matProjInv;\nhighp mat4 cc_matViewProj;\nhighp mat4 cc_matViewProjInv;\nhighp vec4 cc_cameraPos;\nmediump vec4 cc_screenScale;\nmediump vec4 cc_exposure;\nmediump vec4 cc_mainLitDir;\nmediump vec4 cc_mainLitColor;\nmediump vec4 cc_ambientSky;\nmediump vec4 cc_ambientGround;\nmediump vec4 cc_fogColor;\nmediump vec4 cc_fogBase;\nmediump vec4 cc_fogAdd;\nmediump vec4 cc_nearFar;\nmediump vec4 cc_viewPort;\n};\nout vec2 v_uv;\nvoid main () {\nvec4 position;\nposition = vec4(a_position, 1.0);\nposition.xy = cc_cameraPos.w == 0.0 ? vec2(position.xy.x, -position.xy.y) : position.xy;\ngl_Position = vec4(position.x, position.y, 1.0, 1.0);\nv_uv = a_texCoord;\n}", + "frag": "\n#ifdef GL_EXT_shader_framebuffer_fetch\n#extension GL_EXT_shader_framebuffer_fetch: enable\n#endif\nprecision highp float;\nlayout(std140) uniform CCGlobal {\nhighp vec4 cc_time;\nmediump vec4 cc_screenSize;\nmediump vec4 cc_nativeSize;\n};\nlayout(std140) uniform CCCamera {\nhighp mat4 cc_matView;\nhighp mat4 cc_matViewInv;\nhighp mat4 cc_matProj;\nhighp mat4 cc_matProjInv;\nhighp mat4 cc_matViewProj;\nhighp mat4 cc_matViewProjInv;\nhighp vec4 cc_cameraPos;\nmediump vec4 cc_screenScale;\nmediump vec4 cc_exposure;\nmediump vec4 cc_mainLitDir;\nmediump vec4 cc_mainLitColor;\nmediump vec4 cc_ambientSky;\nmediump vec4 cc_ambientGround;\nmediump vec4 cc_fogColor;\nmediump vec4 cc_fogBase;\nmediump vec4 cc_fogAdd;\nmediump vec4 cc_nearFar;\nmediump vec4 cc_viewPort;\n};\nvec3 SRGBToLinear (vec3 gamma) {\nreturn gamma * gamma;\n}\nlayout(std140) uniform CCShadow {\nhighp mat4 cc_matLightPlaneProj;\nhighp mat4 cc_matLightView;\nhighp mat4 cc_matLightViewProj;\nhighp vec4 cc_shadowInvProjDepthInfo;\nhighp vec4 cc_shadowProjDepthInfo;\nhighp vec4 cc_shadowProjInfo;\nlowp vec4 cc_shadowNFLSInfo;\nlowp vec4 cc_shadowWHPBInfo;\nlowp vec4 cc_shadowLPNNInfo;\nlowp vec4 cc_shadowColor;\n};\nfloat CCGetLinearDepthFromViewSpace(vec3 viewPos) {\nfloat dist = length(viewPos);\nreturn (dist - cc_shadowNFLSInfo.x) / (cc_shadowNFLSInfo.y - cc_shadowNFLSInfo.x);\n}\nfloat CCGetLinearDepth(vec3 worldPos) {\nvec4 viewStartPos = cc_matLightView * vec4(worldPos.xyz, 1.0);\nreturn CCGetLinearDepthFromViewSpace(viewStartPos.xyz);\n}\n#if CC_RECEIVE_SHADOW\nuniform highp sampler2D cc_shadowMap;\nuniform highp sampler2D cc_spotLightingMap;\nvec4 ApplyShadowDepthBias_FaceNormal(vec4 shadowPos, vec3 worldNormal)\n{\nvec4 newShadowPos = shadowPos;\nif(cc_shadowLPNNInfo.z > 0.0001)\n{\nvec4 viewNormal = cc_matLightView * vec4(worldNormal, 0.0);\nif(viewNormal.z < 0.1)\nnewShadowPos.xy += viewNormal.xy * cc_shadowProjInfo.xy * cc_shadowLPNNInfo.z * clamp(viewNormal.z, 0.001, 0.1);\n}\nreturn newShadowPos;\n}\nvec4 ApplyShadowDepthBias_Perspective(vec4 shadowPos, float viewspaceDepthBias)\n{\nvec3 viewSpacePos;\nviewSpacePos.xy = shadowPos.xy * cc_shadowProjInfo.zw;\nviewSpacePos.z = shadowPos.z * cc_shadowInvProjDepthInfo.x + shadowPos.w * cc_shadowInvProjDepthInfo.y;\nviewSpacePos.xyz += cc_shadowProjDepthInfo.z * normalize(viewSpacePos.xyz) * viewspaceDepthBias;\nvec4 clipSpacePos;\nclipSpacePos.xy = viewSpacePos.xy * cc_shadowProjInfo.xy;\nclipSpacePos.zw = viewSpacePos.z * cc_shadowProjDepthInfo.xz + vec2(cc_shadowProjDepthInfo.y, 0.0);\nif (cc_shadowNFLSInfo.z > 0.000001) {\nclipSpacePos.z = CCGetLinearDepthFromViewSpace(viewSpacePos.xyz);\nclipSpacePos.z = (clipSpacePos.z * 2.0 - 1.0) * clipSpacePos.w;\n}\nreturn clipSpacePos;\n}\nvec4 ApplyShadowDepthBias_Orthographic(vec4 shadowPos, float viewspaceDepthBias)\n{\nfloat coeffA = cc_shadowProjDepthInfo.x;\nfloat coeffB = cc_shadowProjDepthInfo.y;\nfloat viewSpacePos_z = (shadowPos.z - coeffB) / coeffA;\nviewSpacePos_z += viewspaceDepthBias;\nvec4 result = shadowPos;\nresult.z = viewSpacePos_z * coeffA + coeffB;\nreturn result;\n}\nfloat CCGetShadowFactorHard (vec4 shadowPos) {\nvec4 clipPosNew = ApplyShadowDepthBias_Orthographic(shadowPos, cc_shadowWHPBInfo.w);\nvec3 clipPos = clipPosNew.xyz / clipPosNew.w * 0.5 + 0.5;\nif (clipPos.x < 0.0 || clipPos.x > 1.0 ||\nclipPos.y < 0.0 || clipPos.y > 1.0 ||\nclipPos.z < 0.0 || clipPos.z > 1.0) { return 1.0; }\nclipPos.xy = cc_cameraPos.w == 1.0 ? vec2(clipPos.xy.x, 1.0 - clipPos.xy.y) : clipPos.xy;\nfloat shadow = 0.0;\nfloat closestDepth = 0.0;\nif (cc_shadowLPNNInfo.y > 0.000001) {\nclosestDepth = dot(texture(cc_shadowMap, clipPos.xy), vec4(1.0, 1.0 / 255.0, 1.0 / 65025.0, 1.0 / 16581375.0));\n} else {\nclosestDepth = texture(cc_shadowMap, clipPos.xy).x;\n}\nshadow = step(clipPos.z, closestDepth);\nreturn shadow;\n}\nfloat CCGetShadowFactorSoft (vec4 shadowPos) {\nvec4 clipPosNew = ApplyShadowDepthBias_Orthographic(shadowPos, cc_shadowWHPBInfo.w);\nvec3 clipPos = clipPosNew.xyz / clipPosNew.w * 0.5 + 0.5;\nif (clipPos.x < 0.0 || clipPos.x > 1.0 ||\nclipPos.y < 0.0 || clipPos.y > 1.0 ||\nclipPos.z < 0.0 || clipPos.z > 1.0) { return 1.0; }\nclipPos.xy = cc_cameraPos.w == 1.0 ? vec2(clipPos.xy.x, 1.0 - clipPos.xy.y) : clipPos.xy;\nfloat offsetDepth = clipPos.z;\nvec2 mapSize = cc_shadowWHPBInfo.xy;\nvec2 oneTap = 1.0 / mapSize;\nvec2 clipPos_offset = clipPos.xy + oneTap;\nfloat block0, block1, block2, block3;\nif (cc_shadowLPNNInfo.y > 0.000001) {\nblock0 = step(offsetDepth, dot(texture(cc_shadowMap, vec2(clipPos.x, clipPos.y)), vec4(1.0, 1.0 / 255.0, 1.0 / 65025.0, 1.0 / 16581375.0)));\nblock1 = step(offsetDepth, dot(texture(cc_shadowMap, vec2(clipPos_offset.x, clipPos.y)), vec4(1.0, 1.0 / 255.0, 1.0 / 65025.0, 1.0 / 16581375.0)));\nblock2 = step(offsetDepth, dot(texture(cc_shadowMap, vec2(clipPos.x, clipPos_offset.y)), vec4(1.0, 1.0 / 255.0, 1.0 / 65025.0, 1.0 / 16581375.0)));\nblock3 = step(offsetDepth, dot(texture(cc_shadowMap, vec2(clipPos_offset.x, clipPos_offset.y)), vec4(1.0, 1.0 / 255.0, 1.0 / 65025.0, 1.0 / 16581375.0)));\n} else {\nblock0 = step(offsetDepth, texture(cc_shadowMap, vec2(clipPos.x, clipPos.y)).x);\nblock1 = step(offsetDepth, texture(cc_shadowMap, vec2(clipPos_offset.x, clipPos.y)).x);\nblock2 = step(offsetDepth, texture(cc_shadowMap, vec2(clipPos.x, clipPos_offset.y)).x);\nblock3 = step(offsetDepth, texture(cc_shadowMap, vec2(clipPos_offset.x, clipPos_offset.y)).x);\n}\nfloat coefX = mod(clipPos.x, oneTap.x) * mapSize.x;\nfloat resultX = mix(block0, block1, coefX);\nfloat resultY = mix(block2, block3, coefX);\nfloat coefY = mod(clipPos.y, oneTap.y) * mapSize.y;\nreturn mix(resultX, resultY, coefY);\n}\nfloat CCGetShadowFactorSoft2X (vec4 shadowPos) {\nvec4 clipPosNew = ApplyShadowDepthBias_Orthographic(shadowPos, cc_shadowWHPBInfo.w);\nvec3 clipPos = clipPosNew.xyz / clipPosNew.w * 0.5 + 0.5;\nif (clipPos.x < 0.0 || clipPos.x > 1.0 ||\nclipPos.y < 0.0 || clipPos.y > 1.0 ||\nclipPos.z < 0.0 || clipPos.z > 1.0) { return 1.0; }\nclipPos.xy = cc_cameraPos.w == 1.0 ? vec2(clipPos.xy.x, 1.0 - clipPos.xy.y) : clipPos.xy;\nfloat offsetDepth = clipPos.z;\nvec2 mapSize = cc_shadowWHPBInfo.xy;\nvec2 oneTap = 1.0 / mapSize;\nfloat clipPos_offset_L = clipPos.x - oneTap.x;\nfloat clipPos_offset_R = clipPos.x + oneTap.x;\nfloat clipPos_offset_U = clipPos.y - oneTap.y;\nfloat clipPos_offset_D = clipPos.y + oneTap.y;\nfloat block0, block1, block2, block3, block4, block5, block6, block7, block8;\nif (cc_shadowLPNNInfo.y > 0.000001) {\nblock0 = step(offsetDepth, dot(texture(cc_shadowMap, vec2(clipPos_offset_L, clipPos_offset_U)), vec4(1.0, 1.0 / 255.0, 1.0 / 65025.0, 1.0 / 16581375.0)));\nblock1 = step(offsetDepth, dot(texture(cc_shadowMap, vec2(clipPos.x, clipPos_offset_U)), vec4(1.0, 1.0 / 255.0, 1.0 / 65025.0, 1.0 / 16581375.0)));\nblock2 = step(offsetDepth, dot(texture(cc_shadowMap, vec2(clipPos_offset_R, clipPos_offset_U)), vec4(1.0, 1.0 / 255.0, 1.0 / 65025.0, 1.0 / 16581375.0)));\nblock3 = step(offsetDepth, dot(texture(cc_shadowMap, vec2(clipPos_offset_L, clipPos.y)), vec4(1.0, 1.0 / 255.0, 1.0 / 65025.0, 1.0 / 16581375.0)));\nblock4 = step(offsetDepth, dot(texture(cc_shadowMap, vec2(clipPos.x, clipPos.y)), vec4(1.0, 1.0 / 255.0, 1.0 / 65025.0, 1.0 / 16581375.0)));\nblock5 = step(offsetDepth, dot(texture(cc_shadowMap, vec2(clipPos_offset_R, clipPos.y)), vec4(1.0, 1.0 / 255.0, 1.0 / 65025.0, 1.0 / 16581375.0)));\nblock6 = step(offsetDepth, dot(texture(cc_shadowMap, vec2(clipPos_offset_L, clipPos_offset_D)), vec4(1.0, 1.0 / 255.0, 1.0 / 65025.0, 1.0 / 16581375.0)));\nblock7 = step(offsetDepth, dot(texture(cc_shadowMap, vec2(clipPos.x, clipPos_offset_D)), vec4(1.0, 1.0 / 255.0, 1.0 / 65025.0, 1.0 / 16581375.0)));\nblock8 = step(offsetDepth, dot(texture(cc_shadowMap, vec2(clipPos_offset_R, clipPos_offset_D)), vec4(1.0, 1.0 / 255.0, 1.0 / 65025.0, 1.0 / 16581375.0)));\n} else {\nblock0 = step(offsetDepth, texture(cc_shadowMap, vec2(clipPos_offset_L, clipPos_offset_U)).x);\nblock1 = step(offsetDepth, texture(cc_shadowMap, vec2(clipPos.x, clipPos_offset_U)).x);\nblock2 = step(offsetDepth, texture(cc_shadowMap, vec2(clipPos_offset_R, clipPos_offset_U)).x);\nblock3 = step(offsetDepth, texture(cc_shadowMap, vec2(clipPos_offset_L, clipPos.y)).x);\nblock4 = step(offsetDepth, texture(cc_shadowMap, vec2(clipPos.x, clipPos.y)).x);\nblock5 = step(offsetDepth, texture(cc_shadowMap, vec2(clipPos_offset_R, clipPos.y)).x);\nblock6 = step(offsetDepth, texture(cc_shadowMap, vec2(clipPos_offset_L, clipPos_offset_D)).x);\nblock7 = step(offsetDepth, texture(cc_shadowMap, vec2(clipPos.x, clipPos_offset_D)).x);\nblock8 = step(offsetDepth, texture(cc_shadowMap, vec2(clipPos_offset_R, clipPos_offset_D)).x);\n}\nfloat coefX = mod(clipPos.x, oneTap.x) * mapSize.x;\nfloat coefY = mod(clipPos.y, oneTap.y) * mapSize.y;\nfloat shadow = 0.0;\nfloat resultX = mix(block0, block1, coefX);\nfloat resultY = mix(block3, block4, coefX);\nshadow += mix(resultX , resultY, coefY);\nresultX = mix(block1, block2, coefX);\nresultY = mix(block4, block5, coefX);\nshadow += mix(resultX , resultY, coefY);\nresultX = mix(block3, block4, coefX);\nresultY = mix(block6, block7, coefX);\nshadow += mix(resultX, resultY, coefY);\nresultX = mix(block4, block5, coefX);\nresultY = mix(block7, block8, coefX);\nshadow += mix(resultX, resultY, coefY);\nreturn shadow * 0.25;\n}\nfloat CCGetSpotLightShadowFactorHard (vec4 shadowPos, vec3 worldPos) {\nvec4 clipPosNew = ApplyShadowDepthBias_Perspective(shadowPos, cc_shadowWHPBInfo.w);\nvec3 clipPos = clipPosNew.xyz / clipPosNew.w * 0.5 + 0.5;\nif (clipPos.x < 0.0 || clipPos.x > 1.0 ||\nclipPos.y < 0.0 || clipPos.y > 1.0 ||\nclipPos.z < 0.0 || clipPos.z > 1.0) { return 1.0; }\nclipPos.xy = cc_cameraPos.w == 1.0 ? vec2(clipPos.xy.x, 1.0 - clipPos.xy.y) : clipPos.xy;\nfloat shadow = 0.0;\nfloat closestDepth = 0.0;\nfloat depth = clipPos.z;\nif (cc_shadowLPNNInfo.y > 0.000001) {\nclosestDepth = dot(texture(cc_spotLightingMap, clipPos.xy), vec4(1.0, 1.0 / 255.0, 1.0 / 65025.0, 1.0 / 16581375.0));\n} else {\nclosestDepth = texture(cc_spotLightingMap, clipPos.xy).x;\n}\nshadow = step(depth, closestDepth);\nreturn shadow;\n}\nfloat CCGetSpotLightShadowFactorSoft (vec4 shadowPos, vec3 worldPos) {\nvec4 clipPosNew = ApplyShadowDepthBias_Perspective(shadowPos, cc_shadowWHPBInfo.w);\nvec3 clipPos = clipPosNew.xyz / clipPosNew.w * 0.5 + 0.5;\nif (clipPos.x < 0.0 || clipPos.x > 1.0 ||\nclipPos.y < 0.0 || clipPos.y > 1.0 ||\nclipPos.z < 0.0 || clipPos.z > 1.0) { return 1.0; }\nclipPos.xy = cc_cameraPos.w == 1.0 ? vec2(clipPos.xy.x, 1.0 - clipPos.xy.y) : clipPos.xy;\nfloat depth = 0.0;\nif (cc_shadowNFLSInfo.z > 0.000001) {\ndepth = CCGetLinearDepth(worldPos);\n} else {\ndepth = clipPos.z;\n}\nfloat bias = cc_shadowWHPBInfo.w;\nvec2 oneTap = 1.0 / cc_shadowWHPBInfo.xy;\nvec2 clipPos_offset = clipPos.xy + oneTap;\nfloat block0, block1, block2, block3;\nif (cc_shadowLPNNInfo.y > 0.000001) {\nblock0 = step(depth, dot(texture(cc_spotLightingMap, vec2(clipPos.x, clipPos.y)), vec4(1.0, 1.0 / 255.0, 1.0 / 65025.0, 1.0 / 16581375.0)));\nblock1 = step(depth, dot(texture(cc_spotLightingMap, vec2(clipPos_offset.x, clipPos.y)), vec4(1.0, 1.0 / 255.0, 1.0 / 65025.0, 1.0 / 16581375.0)));\nblock2 = step(depth, dot(texture(cc_spotLightingMap, vec2(clipPos.x, clipPos_offset.y)), vec4(1.0, 1.0 / 255.0, 1.0 / 65025.0, 1.0 / 16581375.0)));\nblock3 = step(depth, dot(texture(cc_spotLightingMap, vec2(clipPos_offset.x, clipPos_offset.y)), vec4(1.0, 1.0 / 255.0, 1.0 / 65025.0, 1.0 / 16581375.0)));\n} else {\nblock0 = step(depth, texture(cc_spotLightingMap, vec2(clipPos.x, clipPos.y)).x);\nblock1 = step(depth, texture(cc_spotLightingMap, vec2(clipPos_offset.x, clipPos.y)).x);\nblock2 = step(depth, texture(cc_spotLightingMap, vec2(clipPos.x, clipPos_offset.y)).x);\nblock3 = step(depth, texture(cc_spotLightingMap, vec2(clipPos_offset.x, clipPos_offset.y)).x);\n}\nfloat coefX = mod(clipPos.x, oneTap.x) * cc_shadowWHPBInfo.x;\nfloat resultX = mix(block0, block1, coefX);\nfloat resultY = mix(block2, block3, coefX);\nfloat coefY = mod(clipPos.y, oneTap.y) * cc_shadowWHPBInfo.y;\nreturn mix(resultX, resultY, coefY);\n}\nfloat CCGetSpotLightShadowFactorSoft2X (vec4 shadowPos, vec3 worldPos) {\nvec4 clipPosNew = ApplyShadowDepthBias_Perspective(shadowPos, cc_shadowWHPBInfo.w);\nvec3 clipPos = clipPosNew.xyz / clipPosNew.w * 0.5 + 0.5;\nif (clipPos.x < 0.0 || clipPos.x > 1.0 ||\nclipPos.y < 0.0 || clipPos.y > 1.0 ||\nclipPos.z < 0.0 || clipPos.z > 1.0) { return 1.0; }\nclipPos.xy = cc_cameraPos.w == 1.0 ? vec2(clipPos.xy.x, 1.0 - clipPos.xy.y) : clipPos.xy;\nfloat depth = 0.0;\nif (cc_shadowNFLSInfo.z > 0.000001) {\ndepth = CCGetLinearDepth(worldPos);\n} else {\ndepth = clipPos.z;\n}\nfloat bias = cc_shadowWHPBInfo.w;\nvec2 mapSize = cc_shadowWHPBInfo.xy;\nvec2 oneTap = 1.0 / mapSize;\nfloat clipPos_offset_L = clipPos.x - oneTap.x;\nfloat clipPos_offset_R = clipPos.x + oneTap.x;\nfloat clipPos_offset_U = clipPos.y - oneTap.y;\nfloat clipPos_offset_D = clipPos.y + oneTap.y;\nfloat block0, block1, block2, block3, block4, block5, block6, block7, block8;\nif (cc_shadowLPNNInfo.y > 0.000001) {\nblock0 = step(depth, dot(texture(cc_spotLightingMap, vec2(clipPos_offset_L, clipPos_offset_U)), vec4(1.0, 1.0 / 255.0, 1.0 / 65025.0, 1.0 / 16581375.0)));\nblock1 = step(depth, dot(texture(cc_spotLightingMap, vec2(clipPos.x, clipPos_offset_U)), vec4(1.0, 1.0 / 255.0, 1.0 / 65025.0, 1.0 / 16581375.0)));\nblock2 = step(depth, dot(texture(cc_spotLightingMap, vec2(clipPos_offset_R, clipPos_offset_U)), vec4(1.0, 1.0 / 255.0, 1.0 / 65025.0, 1.0 / 16581375.0)));\nblock3 = step(depth, dot(texture(cc_spotLightingMap, vec2(clipPos_offset_L, clipPos.y)), vec4(1.0, 1.0 / 255.0, 1.0 / 65025.0, 1.0 / 16581375.0)));\nblock4 = step(depth, dot(texture(cc_spotLightingMap, vec2(clipPos.x, clipPos.y)), vec4(1.0, 1.0 / 255.0, 1.0 / 65025.0, 1.0 / 16581375.0)));\nblock5 = step(depth, dot(texture(cc_spotLightingMap, vec2(clipPos_offset_R, clipPos.y)), vec4(1.0, 1.0 / 255.0, 1.0 / 65025.0, 1.0 / 16581375.0)));\nblock6 = step(depth, dot(texture(cc_spotLightingMap, vec2(clipPos_offset_L, clipPos_offset_D)), vec4(1.0, 1.0 / 255.0, 1.0 / 65025.0, 1.0 / 16581375.0)));\nblock7 = step(depth, dot(texture(cc_spotLightingMap, vec2(clipPos.x, clipPos_offset_D)), vec4(1.0, 1.0 / 255.0, 1.0 / 65025.0, 1.0 / 16581375.0)));\nblock8 = step(depth, dot(texture(cc_spotLightingMap, vec2(clipPos_offset_R, clipPos_offset_D)), vec4(1.0, 1.0 / 255.0, 1.0 / 65025.0, 1.0 / 16581375.0)));\n} else {\nblock0 = step(depth, texture(cc_spotLightingMap, vec2(clipPos_offset_L, clipPos_offset_U)).x);\nblock1 = step(depth, texture(cc_spotLightingMap, vec2(clipPos.x, clipPos_offset_U)).x);\nblock2 = step(depth, texture(cc_spotLightingMap, vec2(clipPos_offset_R, clipPos_offset_U)).x);\nblock3 = step(depth, texture(cc_spotLightingMap, vec2(clipPos_offset_L, clipPos.y)).x);\nblock4 = step(depth, texture(cc_spotLightingMap, vec2(clipPos.x, clipPos.y)).x);\nblock5 = step(depth, texture(cc_spotLightingMap, vec2(clipPos_offset_R, clipPos.y)).x);\nblock6 = step(depth, texture(cc_spotLightingMap, vec2(clipPos_offset_L, clipPos_offset_D)).x);\nblock7 = step(depth, texture(cc_spotLightingMap, vec2(clipPos.x, clipPos_offset_D)).x);\nblock8 = step(depth, texture(cc_spotLightingMap, vec2(clipPos_offset_R, clipPos_offset_D)).x);\n}\nfloat coefX = mod(clipPos.x, oneTap.x) * mapSize.x;\nfloat coefY = mod(clipPos.y, oneTap.y) * mapSize.y;\nfloat shadow = 0.0;\nfloat resultX = mix(block0, block1, coefX);\nfloat resultY = mix(block3, block4, coefX);\nshadow += mix(resultX , resultY, coefY);\nresultX = mix(block1, block2, coefX);\nresultY = mix(block4, block5, coefX);\nshadow += mix(resultX , resultY, coefY);\nresultX = mix(block3, block4, coefX);\nresultY = mix(block6, block7, coefX);\nshadow += mix(resultX, resultY, coefY);\nresultX = mix(block4, block5, coefX);\nresultY = mix(block7, block8, coefX);\nshadow += mix(resultX, resultY, coefY);\nreturn shadow * 0.25;\n}\n#endif\n#if CC_USE_IBL\nuniform samplerCube cc_environment;\nvec4 fragTextureLod (sampler2D tex, vec2 coord, float lod) {\nreturn textureLod(tex, coord, lod);\n}\nvec4 fragTextureLod (samplerCube tex, vec3 coord, float lod) {\nreturn textureLod(tex, coord, lod);\n}\nvec3 unpackRGBE (vec4 rgbe) {\nreturn rgbe.rgb * pow(1.1, rgbe.a * 255.0 - 128.0);\n}\n#if CC_USE_DIFFUSEMAP\nuniform samplerCube cc_diffuseMap;\n#endif\n#endif\nfloat GGXMobile (float roughness, float NoH, vec3 H, vec3 N) {\nvec3 NxH = cross(N, H);\nfloat OneMinusNoHSqr = dot(NxH, NxH);\nfloat a = roughness * roughness;\nfloat n = NoH * a;\nfloat p = a / (OneMinusNoHSqr + n * n);\nreturn p * p;\n}\nfloat CalcSpecular (float roughness, float NoH, vec3 H, vec3 N) {\nreturn (roughness * 0.25 + 0.25) * GGXMobile(roughness, NoH, H, N);\n}\nvec3 BRDFApprox (vec3 specular, float roughness, float NoV) {\nconst vec4 c0 = vec4(-1.0, -0.0275, -0.572, 0.022);\nconst vec4 c1 = vec4(1.0, 0.0425, 1.04, -0.04);\nvec4 r = roughness * c0 + c1;\nfloat a004 = min(r.x * r.x, exp2(-9.28 * NoV)) * r.x + r.y;\nvec2 AB = vec2(-1.04, 1.04) * a004 + r.zw;\nAB.y *= clamp(50.0 * specular.g, 0.0, 1.0);\nreturn specular * AB.x + AB.y;\n}\n#if USE_REFLECTION_DENOISE\nvec3 GetEnvReflectionWithMipFiltering(vec3 R, float roughness, float mipCount, float denoiseIntensity) {\n#if CC_USE_IBL\nfloat mip = roughness * mipCount;\nfloat delta = (dot(dFdx(R), dFdy(R))) * 1000.0;\nfloat mipBias = mix(0.0, 5.0, clamp(delta, 0.0, 1.0));\nvec4 biased = fragTextureLod(cc_environment, R, mip + mipBias);\nvec4 filtered = texture(cc_environment, R);\n#if CC_USE_IBL == 2\nbiased.rgb = unpackRGBE(biased);\nfiltered.rgb = unpackRGBE(filtered);\n#else\nbiased.rgb = SRGBToLinear(biased.rgb);\nfiltered.rgb = SRGBToLinear(filtered.rgb);\n#endif\nreturn mix(biased.rgb, filtered.rgb, denoiseIntensity);\n#else\nreturn vec3(0.0, 0.0, 0.0);\n#endif\n}\n#endif\nstruct StandardSurface {\nvec4 albedo;\nvec3 position;\nvec3 normal;\nvec3 emissive;\nvec3 lightmap;\nfloat lightmap_test;\nfloat roughness;\nfloat metallic;\nfloat occlusion;\n};\nvec4 CCStandardShadingBase (StandardSurface s, vec4 shadowPos) {\nvec3 diffuse = s.albedo.rgb * (1.0 - s.metallic);\nvec3 specular = mix(vec3(0.04), s.albedo.rgb, s.metallic);\nvec3 N = normalize(s.normal);\nvec3 V = normalize(cc_cameraPos.xyz - s.position);\nfloat NV = max(abs(dot(N, V)), 0.0);\nspecular = BRDFApprox(specular, s.roughness, NV);\nvec3 L = normalize(-cc_mainLitDir.xyz);\nvec3 H = normalize(L + V);\nfloat NH = max(dot(N, H), 0.0);\nfloat NL = max(dot(N, L), 0.0);\nvec3 finalColor = NL * cc_mainLitColor.rgb * cc_mainLitColor.w;\nvec3 diffuseContrib = diffuse;\n#if USE_LIGHTMAP && !USE_BATCHING && !CC_FORWARD_ADD\nif (s.lightmap_test > 0.0001) {\nfinalColor = s.lightmap.rgb;\n}\n#else\ndiffuseContrib /= 3.14159265359;\n#endif\nvec3 specularContrib = specular * CalcSpecular(s.roughness, NH, H, N);\nvec3 dirlightContrib = (diffuseContrib + specularContrib);\nfloat shadow = 1.0;\n#if CC_RECEIVE_SHADOW && CC_ENABLE_DIR_SHADOW\nif (NL > 0.0) {\n{\nvec4 pos = ApplyShadowDepthBias_FaceNormal(shadowPos, N);\nfloat pcf = cc_shadowWHPBInfo.z;\nif (pcf > 1.9) shadow = CCGetShadowFactorSoft2X(pos);\nelse if (pcf > 0.9) shadow = CCGetShadowFactorSoft(pos);\nelse shadow = CCGetShadowFactorHard(pos);\nshadow = mix(shadow, 1.0, cc_shadowNFLSInfo.w);\n}\n}\n#endif\ndirlightContrib *= shadow;\nfinalColor *= dirlightContrib;\nfloat fAmb = 0.5 - N.y * 0.5;\nvec3 ambDiff = mix(cc_ambientSky.rgb, cc_ambientGround.rgb, fAmb);\n#if CC_USE_IBL\n#if CC_USE_DIFFUSEMAP\nvec4 diffuseMap = texture(cc_diffuseMap, N);\n#if CC_USE_DIFFUSEMAP == 2\nambDiff = unpackRGBE(diffuseMap);\n#else\nambDiff = SRGBToLinear(diffuseMap.rgb);\n#endif\n#endif\nvec3 R = normalize(reflect(-V, N));\n#if USE_REFLECTION_DENOISE\nvec3 env = GetEnvReflectionWithMipFiltering(R, s.roughness, cc_ambientGround.w, 0.6);\n#else\nvec4 envmap = fragTextureLod(cc_environment, R, s.roughness * cc_ambientGround.w);\n#if CC_USE_IBL == 2\nvec3 env = unpackRGBE(envmap);\n#else\nvec3 env = SRGBToLinear(envmap.rgb);\n#endif\n#endif\nfinalColor += env * cc_ambientSky.w * specular * s.occlusion;\n#endif\nfinalColor += ambDiff.rgb * cc_ambientSky.w * diffuse * s.occlusion;\nfinalColor += s.emissive;\nreturn vec4(finalColor, s.albedo.a);\n}\n#if CC_PIPELINE_TYPE == 0\n# define LIGHTS_PER_PASS 1\n#else\n# define LIGHTS_PER_PASS 10\n#endif\n#if CC_ENABLE_CLUSTERED_LIGHT_CULLING == 0\nlayout(std140) uniform CCForwardLight {\nhighp vec4 cc_lightPos[LIGHTS_PER_PASS];\nvec4 cc_lightColor[LIGHTS_PER_PASS];\nvec4 cc_lightSizeRangeAngle[LIGHTS_PER_PASS];\nvec4 cc_lightDir[LIGHTS_PER_PASS];\n};\n#endif\nfloat SmoothDistAtt (float distSqr, float invSqrAttRadius) {\nfloat factor = distSqr * invSqrAttRadius;\nfloat smoothFactor = clamp(1.0 - factor * factor, 0.0, 1.0);\nreturn smoothFactor * smoothFactor;\n}\nfloat GetDistAtt (float distSqr, float invSqrAttRadius) {\nfloat attenuation = 1.0 / max(distSqr, 0.01*0.01);\nattenuation *= SmoothDistAtt(distSqr , invSqrAttRadius);\nreturn attenuation;\n}\nfloat GetAngleAtt (vec3 L, vec3 litDir, float litAngleScale, float litAngleOffset) {\nfloat cd = dot(litDir, L);\nfloat attenuation = clamp(cd * litAngleScale + litAngleOffset, 0.0, 1.0);\nreturn (attenuation * attenuation);\n}\n#if CC_ENABLE_CLUSTERED_LIGHT_CULLING == 0\nvec4 CCStandardShadingAdditive (StandardSurface s, vec4 shadowPos) {\nvec3 diffuse = s.albedo.rgb * (1.0 - s.metallic);\nvec3 specular = mix(vec3(0.04), s.albedo.rgb, s.metallic);\nvec3 diffuseContrib = diffuse / 3.14159265359;\nvec3 N = normalize(s.normal);\nvec3 V = normalize(cc_cameraPos.xyz - s.position);\nfloat NV = max(abs(dot(N, V)), 0.0);\nspecular = BRDFApprox(specular, s.roughness, NV);\nvec3 finalColor = vec3(0.0);\nint numLights = CC_PIPELINE_TYPE == 0 ? LIGHTS_PER_PASS : int(cc_lightDir[0].w);\nfor (int i = 0; i < LIGHTS_PER_PASS; i++) {\nif (i >= numLights) break;\nvec3 SLU = cc_lightPos[i].xyz - s.position;\nvec3 SL = normalize(SLU);\nvec3 SH = normalize(SL + V);\nfloat SNL = max(dot(N, SL), 0.0);\nfloat SNH = max(dot(N, SH), 0.0);\nfloat distSqr = dot(SLU, SLU);\nfloat litRadius = cc_lightSizeRangeAngle[i].x;\nfloat litRadiusSqr = litRadius * litRadius;\nfloat illum = 3.14159265359 * (litRadiusSqr / max(litRadiusSqr , distSqr));\nfloat attRadiusSqrInv = 1.0 / max(cc_lightSizeRangeAngle[i].y, 0.01);\nattRadiusSqrInv *= attRadiusSqrInv;\nfloat att = GetDistAtt(distSqr, attRadiusSqrInv);\nvec3 lspec = specular * CalcSpecular(s.roughness, SNH, SH, N);\nif (cc_lightPos[i].w > 0.0) {\nfloat cosInner = max(dot(-cc_lightDir[i].xyz, SL), 0.01);\nfloat cosOuter = cc_lightSizeRangeAngle[i].z;\nfloat litAngleScale = 1.0 / max(0.001, cosInner - cosOuter);\nfloat litAngleOffset = -cosOuter * litAngleScale;\natt *= GetAngleAtt(SL, -cc_lightDir[i].xyz, litAngleScale, litAngleOffset);\n}\nvec3 lightColor = cc_lightColor[i].rgb;\nfloat shadow = 1.0;\n#if CC_RECEIVE_SHADOW\nif (cc_lightPos[i].w > 0.0 && cc_lightSizeRangeAngle[i].w > 0.0) {\n{\nfloat pcf = cc_shadowWHPBInfo.z;\nif (pcf > 1.9) shadow = CCGetSpotLightShadowFactorSoft2X(shadowPos, s.position);\nelse if (pcf > 0.9) shadow = CCGetSpotLightShadowFactorSoft(shadowPos, s.position);\nelse shadow = CCGetSpotLightShadowFactorHard(shadowPos, s.position);\n}\n}\n#endif\nlightColor *= shadow;\nfinalColor += SNL * lightColor * cc_lightColor[i].w * illum * att * (diffuseContrib + lspec);\n}\nreturn vec4(finalColor, 0.0);\n}\n#endif\n#if CC_ENABLE_CLUSTERED_LIGHT_CULLING == 1\nlayout(std430, binding = 4) readonly buffer b_ccLightsBuffer { vec4 b_ccLights[]; };\nlayout(std430, binding = 5) readonly buffer b_clusterLightIndicesBuffer { uint b_clusterLightIndices[]; };\nlayout(std430, binding = 6) readonly buffer b_clusterLightGridBuffer { uvec4 b_clusterLightGrid[]; };\nstruct CCLight\n{\nvec4 cc_lightPos;\nvec4 cc_lightColor;\nvec4 cc_lightSizeRangeAngle;\nvec4 cc_lightDir;\n};\nstruct Cluster\n{\nvec3 minBounds;\nvec3 maxBounds;\n};\nstruct LightGrid\n{\nuint offset;\nuint ccLights;\n};\nCCLight getCCLight(uint i)\n{\nCCLight light;\nlight.cc_lightPos = b_ccLights[4u * i + 0u];\nlight.cc_lightColor = b_ccLights[4u * i + 1u];\nlight.cc_lightSizeRangeAngle = b_ccLights[4u * i + 2u];\nlight.cc_lightDir = b_ccLights[4u * i + 3u];\nreturn light;\n}\nLightGrid getLightGrid(uint cluster)\n{\nuvec4 gridvec = b_clusterLightGrid[cluster];\nLightGrid grid;\ngrid.offset = gridvec.x;\ngrid.ccLights = gridvec.y;\nreturn grid;\n}\nuint getGridLightIndex(uint start, uint offset)\n{\nreturn b_clusterLightIndices[start + offset];\n}\nuint getClusterZIndex(vec4 worldPos)\n{\nfloat scale = float(24) / log(cc_nearFar.y / cc_nearFar.x);\nfloat bias = -(float(24) * log(cc_nearFar.x) / log(cc_nearFar.y / cc_nearFar.x));\nfloat eyeDepth = -(cc_matView * worldPos).z;\nuint zIndex = uint(max(log(eyeDepth) * scale + bias, 0.0));\nreturn zIndex;\n}\nuint getClusterIndex(vec4 fragCoord, vec4 worldPos)\n{\nuint zIndex = getClusterZIndex(worldPos);\nfloat clusterSizeX = ceil(cc_screenSize.x / float(16));\nfloat clusterSizeY = ceil(cc_screenSize.y / float(8));\nuvec3 indices = uvec3(uvec2(fragCoord.xy / vec2(clusterSizeX, clusterSizeY)), zIndex);\nuint cluster = (16u * 8u) * indices.z + 16u * indices.y + indices.x;\nreturn cluster;\n}\nvec4 CCClusterShadingAdditive (StandardSurface s, vec4 shadowPos) {\nvec3 diffuse = s.albedo.rgb * (1.0 - s.metallic);\nvec3 specular = mix(vec3(0.04), s.albedo.rgb, s.metallic);\nvec3 diffuseContrib = diffuse / 3.14159265359;\nvec3 N = normalize(s.normal);\nvec3 V = normalize(cc_cameraPos.xyz - s.position);\nfloat NV = max(abs(dot(N, V)), 0.001);\nspecular = BRDFApprox(specular, s.roughness, NV);\nvec3 finalColor = vec3(0.0);\nuint cluster = getClusterIndex(gl_FragCoord, vec4(s.position, 1.0));\nLightGrid grid = getLightGrid(cluster);\nuint numLights = grid.ccLights;\nfor (uint i = 0u; i < 100u; i++) {\nif (i >= numLights) break;\nuint lightIndex = getGridLightIndex(grid.offset, i);\nCCLight light = getCCLight(lightIndex);\nvec3 SLU = light.cc_lightPos.xyz - s.position;\nvec3 SL = normalize(SLU);\nvec3 SH = normalize(SL + V);\nfloat SNL = max(dot(N, SL), 0.001);\nfloat SNH = max(dot(N, SH), 0.0);\nfloat distSqr = dot(SLU, SLU);\nfloat litRadius = light.cc_lightSizeRangeAngle.x;\nfloat litRadiusSqr = litRadius * litRadius;\nfloat illum = 3.14159265359 * (litRadiusSqr / max(litRadiusSqr , distSqr));\nfloat attRadiusSqrInv = 1.0 / max(light.cc_lightSizeRangeAngle.y, 0.01);\nattRadiusSqrInv *= attRadiusSqrInv;\nfloat att = GetDistAtt(distSqr, attRadiusSqrInv);\nvec3 lspec = specular * CalcSpecular(s.roughness, SNH, SH, N);\nif (light.cc_lightPos.w > 0.0) {\nfloat cosInner = max(dot(-light.cc_lightDir.xyz, SL), 0.01);\nfloat cosOuter = light.cc_lightSizeRangeAngle.z;\nfloat litAngleScale = 1.0 / max(0.001, cosInner - cosOuter);\nfloat litAngleOffset = -cosOuter * litAngleScale;\natt *= GetAngleAtt(SL, -light.cc_lightDir.xyz, litAngleScale, litAngleOffset);\n}\nvec3 lightColor = light.cc_lightColor.rgb;\nfloat shadow = 1.0;\n#if CC_RECEIVE_SHADOW\nif (light.cc_lightPos.w > 0.0) {\n{\nfloat pcf = cc_shadowWHPBInfo.z;\nif (pcf > 1.9) shadow = CCGetSpotLightShadowFactorSoft2X(shadowPos, s.position);\nelse if (pcf > 0.9) shadow = CCGetSpotLightShadowFactorSoft(shadowPos, s.position);\nelse shadow = CCGetSpotLightShadowFactorHard(shadowPos, s.position);\n}\n}\n#endif\nlightColor *= shadow;\nfinalColor += SNL * lightColor * light.cc_lightColor.w * illum * att * (diffuseContrib + lspec);\n}\nreturn vec4(finalColor, 0.0);\n}\n#endif\nvec3 ACESToneMap (vec3 color) {\ncolor = min(color, vec3(8.0));\nconst float A = 2.51;\nconst float B = 0.03;\nconst float C = 2.43;\nconst float D = 0.59;\nconst float E = 0.14;\nreturn (color * (A * color + B)) / (color * (C * color + D) + E);\n}\nvec4 CCFragOutput (vec4 color) {\n#if CC_USE_HDR\ncolor.rgb = ACESToneMap(color.rgb);\n#endif\ncolor.rgb = sqrt(color.rgb);\nreturn color;\n}\nfloat LinearFog(vec4 pos) {\nvec4 wPos = pos;\nfloat cam_dis = distance(cc_cameraPos, wPos);\nfloat fogStart = cc_fogBase.x;\nfloat fogEnd = cc_fogBase.y;\nreturn clamp((fogEnd - cam_dis) / (fogEnd - fogStart), 0., 1.);\n}\nfloat ExpFog(vec4 pos) {\nvec4 wPos = pos;\nfloat fogAtten = cc_fogAdd.z;\nfloat fogStart = cc_fogBase.x;\nfloat fogDensity = cc_fogBase.z;\nfloat cam_dis = max(distance(cc_cameraPos, wPos) - fogStart, 0.0) / fogAtten * 4.;\nfloat f = exp(-cam_dis * fogDensity);\nreturn f;\n}\nfloat ExpSquaredFog(vec4 pos) {\nvec4 wPos = pos;\nfloat fogAtten = cc_fogAdd.z;\nfloat fogStart = cc_fogBase.x;\nfloat fogDensity = cc_fogBase.z;\nfloat cam_dis = max(distance(cc_cameraPos, wPos) - fogStart, 0.0) / fogAtten * 4.;\nfloat f = exp(-cam_dis * cam_dis * fogDensity * fogDensity);\nreturn f;\n}\nfloat LayeredFog(vec4 pos) {\nvec4 wPos = pos;\nfloat fogAtten = cc_fogAdd.z;\nfloat _FogTop = cc_fogAdd.x;\nfloat _FogRange = cc_fogAdd.y;\nvec3 camWorldProj = cc_cameraPos.xyz;\ncamWorldProj.y = 0.;\nvec3 worldPosProj = wPos.xyz;\nworldPosProj.y = 0.;\nfloat fDeltaD = distance(worldPosProj, camWorldProj) / fogAtten * 2.0;\nfloat fDeltaY, fDensityIntegral;\nif (cc_cameraPos.y > _FogTop) {\nif (wPos.y < _FogTop) {\nfDeltaY = (_FogTop - wPos.y) / _FogRange * 2.0;\nfDensityIntegral = fDeltaY * fDeltaY * 0.5;\n} else {\nfDeltaY = 0.;\nfDensityIntegral = 0.;\n}\n} else {\nif (wPos.y < _FogTop) {\nfloat fDeltaA = (_FogTop - cc_cameraPos.y) / _FogRange * 2.;\nfloat fDeltaB = (_FogTop - wPos.y) / _FogRange * 2.;\nfDeltaY = abs(fDeltaA - fDeltaB);\nfDensityIntegral = abs((fDeltaA * fDeltaA * 0.5) - (fDeltaB * fDeltaB * 0.5));\n} else {\nfDeltaY = abs(_FogTop - cc_cameraPos.y) / _FogRange * 2.;\nfDensityIntegral = abs(fDeltaY * fDeltaY * 0.5);\n}\n}\nfloat fDensity;\nif (fDeltaY != 0.) {\nfDensity = (sqrt(1.0 + ((fDeltaD / fDeltaY) * (fDeltaD / fDeltaY)))) * fDensityIntegral;\n} else {\nfDensity = 0.;\n}\nfloat f = exp(-fDensity);\nreturn f;\n}\nvoid CC_TRANSFER_FOG_BASE(vec4 pos, out float factor)\n{\n#if CC_USE_FOG == 0\nfactor = LinearFog(pos);\n#elif CC_USE_FOG == 1\nfactor = ExpFog(pos);\n#elif CC_USE_FOG == 2\nfactor = ExpSquaredFog(pos);\n#elif CC_USE_FOG == 3\nfactor = LayeredFog(pos);\n#else\nfactor = 1.0;\n#endif\n}\nvoid CC_APPLY_FOG_BASE(inout vec4 color, float factor) {\ncolor = vec4(mix(cc_fogColor.rgb, color.rgb, factor), color.a);\n}\nin vec2 v_uv;\n#if CC_DEVICE_CAN_BENEFIT_FROM_INPUT_ATTACHMENT\nlayout(location = 0) inout vec4 gbuffer_albedoMap;\nlayout(location = 1) inout vec4 gbuffer_positionMap;\nlayout(location = 2) inout vec4 gbuffer_normalMap;\nlayout(location = 3) inout vec4 gbuffer_emissiveMap;\n#else\nuniform sampler2D gbuffer_albedoMap;\nuniform sampler2D gbuffer_positionMap;\nuniform sampler2D gbuffer_normalMap;\nuniform sampler2D gbuffer_emissiveMap;\n#endif\n#if !CC_DEVICE_CAN_BENEFIT_FROM_INPUT_ATTACHMENT || __VERSION__ >= 450\nlayout(location = 0) out vec4 fragColor;\n#endif\nvoid main () {\nStandardSurface s;\n#if CC_DEVICE_CAN_BENEFIT_FROM_INPUT_ATTACHMENT\nvec4 albedoMap = gbuffer_albedoMap;\nvec4 positionMap = gbuffer_positionMap;\nvec4 normalMap = gbuffer_normalMap;\nvec4 emissiveMap = gbuffer_emissiveMap;\n#else\nvec4 albedoMap = texture(gbuffer_albedoMap,v_uv);\nvec4 positionMap = texture(gbuffer_positionMap,v_uv);\nvec4 normalMap = texture(gbuffer_normalMap,v_uv);\nvec4 emissiveMap = texture(gbuffer_emissiveMap,v_uv);\n#endif\ns.albedo = albedoMap;\ns.position = positionMap.xyz;\ns.roughness = positionMap.w;\ns.normal = normalMap.xyz;\ns.metallic = normalMap.w;\ns.emissive = emissiveMap.xyz;\ns.occlusion = emissiveMap.w;\nfloat fogFactor;\nCC_TRANSFER_FOG_BASE(vec4(s.position, 1), fogFactor);\nvec4 shadowPos;\nshadowPos = cc_matLightViewProj * vec4(s.position, 1);\nvec4 color = CCStandardShadingBase(s, shadowPos) +\n#if CC_ENABLE_CLUSTERED_LIGHT_CULLING == 1\nCCClusterShadingAdditive(s, shadowPos);\n#else\nCCStandardShadingAdditive(s, shadowPos);\n#endif\nCC_APPLY_FOG_BASE(color, fogFactor);\ncolor = CCFragOutput(color);\n#if CC_DEVICE_CAN_BENEFIT_FROM_INPUT_ATTACHMENT\ngbuffer_emissiveMap = color;\n#else\nfragColor = color;\n#endif\n}", + } + ], + [ + { + "vert": "\nprecision highp float;\nhighp float decode32 (highp vec4 rgba) {\nrgba = rgba * 255.0;\nhighp float Sign = 1.0 - (step(128.0, (rgba[3]) + 0.5)) * 2.0;\nhighp float Exponent = 2.0 * (mod(float(int((rgba[3]) + 0.5)), 128.0)) + (step(128.0, (rgba[2]) + 0.5)) - 127.0;\nhighp float Mantissa = (mod(float(int((rgba[2]) + 0.5)), 128.0)) * 65536.0 + rgba[1] * 256.0 + rgba[0] + 8388608.0;\nreturn Sign * exp2(Exponent - 23.0) * Mantissa;\n}\nstruct StandardVertInput {\nhighp vec4 position;\nvec3 normal;\nvec4 tangent;\n};\nin vec3 a_position;\nin vec3 a_normal;\nin vec2 a_texCoord;\nin vec4 a_tangent;\n#if CC_USE_MORPH\nin float a_vertexId;\nint getVertexId() {\nreturn int(a_vertexId);\n}\nlayout(std140) uniform CCMorph {\nvec4 cc_displacementWeights[15];\nvec4 cc_displacementTextureInfo;\n};\nvec2 getPixelLocation(vec2 textureResolution, int pixelIndex) {\nfloat pixelIndexF = float(pixelIndex);\nfloat x = mod(pixelIndexF, textureResolution.x);\nfloat y = floor(pixelIndexF / textureResolution.x);\nreturn vec2(x, y);\n}\nvec2 getPixelCoordFromLocation(vec2 location, vec2 textureResolution) {\nreturn (vec2(location.x, location.y) + .5) / textureResolution;\n}\n#if CC_DEVICE_SUPPORT_FLOAT_TEXTURE\nvec4 fetchVec3ArrayFromTexture(sampler2D tex, int pixelIndex) {\nivec2 texSize = textureSize(tex, 0);\nreturn texelFetch(tex, ivec2(pixelIndex % texSize.x, pixelIndex / texSize.x), 0);\n}\n#else\nvec4 fetchVec3ArrayFromTexture(sampler2D tex, int elementIndex) {\nint pixelIndex = elementIndex * 4;\nvec2 location = getPixelLocation(cc_displacementTextureInfo.xy, pixelIndex);\nvec2 x = getPixelCoordFromLocation(location + vec2(0.0, 0.0), cc_displacementTextureInfo.xy);\nvec2 y = getPixelCoordFromLocation(location + vec2(1.0, 0.0), cc_displacementTextureInfo.xy);\nvec2 z = getPixelCoordFromLocation(location + vec2(2.0, 0.0), cc_displacementTextureInfo.xy);\nreturn vec4(\ndecode32(texture(tex, x)),\ndecode32(texture(tex, y)),\ndecode32(texture(tex, z)),\n1.0\n);\n}\n#endif\nfloat getDisplacementWeight(int index) {\nint quot = index / 4;\nint remainder = index - quot * 4;\nif (remainder == 0) {\nreturn cc_displacementWeights[quot].x;\n} else if (remainder == 1) {\nreturn cc_displacementWeights[quot].y;\n} else if (remainder == 2) {\nreturn cc_displacementWeights[quot].z;\n} else {\nreturn cc_displacementWeights[quot].w;\n}\n}\nvec3 getVec3DisplacementFromTexture(sampler2D tex, int vertexIndex) {\n#if CC_MORPH_PRECOMPUTED\nreturn fetchVec3ArrayFromTexture(tex, vertexIndex).rgb;\n#else\nvec3 result = vec3(0, 0, 0);\nint nVertices = int(cc_displacementTextureInfo.z);\nfor (int iTarget = 0; iTarget < CC_MORPH_TARGET_COUNT; ++iTarget) {\nresult += (fetchVec3ArrayFromTexture(tex, nVertices * iTarget + vertexIndex).rgb * getDisplacementWeight(iTarget));\n}\nreturn result;\n#endif\n}\n#if CC_MORPH_TARGET_HAS_POSITION\nuniform sampler2D cc_PositionDisplacements;\nvec3 getPositionDisplacement(int vertexId) {\nreturn getVec3DisplacementFromTexture(cc_PositionDisplacements, vertexId);\n}\n#endif\n#if CC_MORPH_TARGET_HAS_NORMAL\nuniform sampler2D cc_NormalDisplacements;\nvec3 getNormalDisplacement(int vertexId) {\nreturn getVec3DisplacementFromTexture(cc_NormalDisplacements, vertexId);\n}\n#endif\n#if CC_MORPH_TARGET_HAS_TANGENT\nuniform sampler2D cc_TangentDisplacements;\nvec3 getTangentDisplacement(int vertexId) {\nreturn getVec3DisplacementFromTexture(cc_TangentDisplacements, vertexId);\n}\n#endif\nvoid applyMorph (inout StandardVertInput attr) {\nint vertexId = getVertexId();\n#if CC_MORPH_TARGET_HAS_POSITION\nattr.position.xyz = attr.position.xyz + getPositionDisplacement(vertexId);\n#endif\n#if CC_MORPH_TARGET_HAS_NORMAL\nattr.normal.xyz = attr.normal.xyz + getNormalDisplacement(vertexId);\n#endif\n#if CC_MORPH_TARGET_HAS_TANGENT\nattr.tangent.xyz = attr.tangent.xyz + getTangentDisplacement(vertexId);\n#endif\n}\nvoid applyMorph (inout vec4 position) {\n#if CC_MORPH_TARGET_HAS_POSITION\nposition.xyz = position.xyz + getPositionDisplacement(getVertexId());\n#endif\n}\n#endif\n#if CC_USE_SKINNING\nin vec4 a_joints;\nin vec4 a_weights;\n#if CC_USE_BAKED_ANIMATION\n#if USE_INSTANCING\nin highp vec4 a_jointAnimInfo;\n#endif\nlayout(std140) uniform CCSkinningTexture {\nhighp vec4 cc_jointTextureInfo;\n};\nlayout(std140) uniform CCSkinningAnimation {\nhighp vec4 cc_jointAnimInfo;\n};\nuniform highp sampler2D cc_jointTexture;\n#else\nlayout(std140) uniform CCSkinning {\nhighp vec4 cc_joints[30 * 3];\n};\n#endif\n#if CC_USE_BAKED_ANIMATION\n#if CC_DEVICE_SUPPORT_FLOAT_TEXTURE\nmat4 getJointMatrix (float i) {\n#if USE_INSTANCING\nhighp float j = 3.0 * (a_jointAnimInfo.x * a_jointAnimInfo.y + i) + a_jointAnimInfo.z;\n#else\nhighp float j = 3.0 * (cc_jointAnimInfo.x * cc_jointTextureInfo.y + i) + cc_jointTextureInfo.z;\n#endif\nhighp float invSize = cc_jointTextureInfo.w;\nhighp float y = floor(j * invSize);\nhighp float x = floor(j - y * cc_jointTextureInfo.x);\ny = (y + 0.5) * invSize;\nvec4 v1 = texture(cc_jointTexture, vec2((x + 0.5) * invSize, y));\nvec4 v2 = texture(cc_jointTexture, vec2((x + 1.5) * invSize, y));\nvec4 v3 = texture(cc_jointTexture, vec2((x + 2.5) * invSize, y));\nreturn mat4(vec4(v1.xyz, 0.0), vec4(v2.xyz, 0.0), vec4(v3.xyz, 0.0), vec4(v1.w, v2.w, v3.w, 1.0));\n}\n#else\nmat4 getJointMatrix (float i) {\n#if USE_INSTANCING\nhighp float j = 12.0 * (a_jointAnimInfo.x * a_jointAnimInfo.y + i) + a_jointAnimInfo.z;\n#else\nhighp float j = 12.0 * (cc_jointAnimInfo.x * cc_jointTextureInfo.y + i) + cc_jointTextureInfo.z;\n#endif\nhighp float invSize = cc_jointTextureInfo.w;\nhighp float y = floor(j * invSize);\nhighp float x = floor(j - y * cc_jointTextureInfo.x);\ny = (y + 0.5) * invSize;\nvec4 v1 = vec4(\ndecode32(texture(cc_jointTexture, vec2((x + 0.5) * invSize, y))),\ndecode32(texture(cc_jointTexture, vec2((x + 1.5) * invSize, y))),\ndecode32(texture(cc_jointTexture, vec2((x + 2.5) * invSize, y))),\ndecode32(texture(cc_jointTexture, vec2((x + 3.5) * invSize, y)))\n);\nvec4 v2 = vec4(\ndecode32(texture(cc_jointTexture, vec2((x + 4.5) * invSize, y))),\ndecode32(texture(cc_jointTexture, vec2((x + 5.5) * invSize, y))),\ndecode32(texture(cc_jointTexture, vec2((x + 6.5) * invSize, y))),\ndecode32(texture(cc_jointTexture, vec2((x + 7.5) * invSize, y)))\n);\nvec4 v3 = vec4(\ndecode32(texture(cc_jointTexture, vec2((x + 8.5) * invSize, y))),\ndecode32(texture(cc_jointTexture, vec2((x + 9.5) * invSize, y))),\ndecode32(texture(cc_jointTexture, vec2((x + 10.5) * invSize, y))),\ndecode32(texture(cc_jointTexture, vec2((x + 11.5) * invSize, y)))\n);\nreturn mat4(vec4(v1.xyz, 0.0), vec4(v2.xyz, 0.0), vec4(v3.xyz, 0.0), vec4(v1.w, v2.w, v3.w, 1.0));\n}\n#endif\n#else\nmat4 getJointMatrix (float i) {\nint idx = int(i);\nvec4 v1 = cc_joints[idx * 3];\nvec4 v2 = cc_joints[idx * 3 + 1];\nvec4 v3 = cc_joints[idx * 3 + 2];\nreturn mat4(vec4(v1.xyz, 0.0), vec4(v2.xyz, 0.0), vec4(v3.xyz, 0.0), vec4(v1.w, v2.w, v3.w, 1.0));\n}\n#endif\nmat4 skinMatrix () {\nvec4 joints = vec4(a_joints);\nreturn getJointMatrix(joints.x) * a_weights.x\n+ getJointMatrix(joints.y) * a_weights.y\n+ getJointMatrix(joints.z) * a_weights.z\n+ getJointMatrix(joints.w) * a_weights.w;\n}\nvoid CCSkin (inout vec4 position) {\nmat4 m = skinMatrix();\nposition = m * position;\n}\nvoid CCSkin (inout StandardVertInput attr) {\nmat4 m = skinMatrix();\nattr.position = m * attr.position;\nattr.normal = (m * vec4(attr.normal, 0.0)).xyz;\nattr.tangent.xyz = (m * vec4(attr.tangent.xyz, 0.0)).xyz;\n}\n#endif\nlayout(std140) uniform CCGlobal {\nhighp vec4 cc_time;\nmediump vec4 cc_screenSize;\nmediump vec4 cc_nativeSize;\n};\nlayout(std140) uniform CCCamera {\nhighp mat4 cc_matView;\nhighp mat4 cc_matViewInv;\nhighp mat4 cc_matProj;\nhighp mat4 cc_matProjInv;\nhighp mat4 cc_matViewProj;\nhighp mat4 cc_matViewProjInv;\nhighp vec4 cc_cameraPos;\nmediump vec4 cc_screenScale;\nmediump vec4 cc_exposure;\nmediump vec4 cc_mainLitDir;\nmediump vec4 cc_mainLitColor;\nmediump vec4 cc_ambientSky;\nmediump vec4 cc_ambientGround;\nmediump vec4 cc_fogColor;\nmediump vec4 cc_fogBase;\nmediump vec4 cc_fogAdd;\nmediump vec4 cc_nearFar;\nmediump vec4 cc_viewPort;\n};\n#if USE_INSTANCING\nin vec4 a_matWorld0;\nin vec4 a_matWorld1;\nin vec4 a_matWorld2;\n#if USE_LIGHTMAP\nin vec4 a_lightingMapUVParam;\n#endif\n#elif USE_BATCHING\nin float a_dyn_batch_id;\nlayout(std140) uniform CCLocalBatched {\nhighp mat4 cc_matWorlds[10];\n};\n#else\nlayout(std140) uniform CCLocal {\nhighp mat4 cc_matWorld;\nhighp mat4 cc_matWorldIT;\nhighp vec4 cc_lightingMapUVParam;\n};\n#endif\nlayout(std140) uniform CCShadow {\nhighp mat4 cc_matLightPlaneProj;\nhighp mat4 cc_matLightView;\nhighp mat4 cc_matLightViewProj;\nhighp vec4 cc_shadowInvProjDepthInfo;\nhighp vec4 cc_shadowProjDepthInfo;\nhighp vec4 cc_shadowProjInfo;\nlowp vec4 cc_shadowNFLSInfo;\nlowp vec4 cc_shadowWHPBInfo;\nlowp vec4 cc_shadowLPNNInfo;\nlowp vec4 cc_shadowColor;\n};\nvec4 vert () {\nvec4 position;\nposition = vec4(a_position, 1.0);\n#if CC_USE_MORPH\napplyMorph(position);\n#endif\n#if CC_USE_SKINNING\nCCSkin(position);\n#endif\nmat4 matWorld;\n#if USE_INSTANCING\nmatWorld = mat4(\nvec4(a_matWorld0.xyz, 0.0),\nvec4(a_matWorld1.xyz, 0.0),\nvec4(a_matWorld2.xyz, 0.0),\nvec4(a_matWorld0.w, a_matWorld1.w, a_matWorld2.w, 1.0)\n);\n#elif USE_BATCHING\nmatWorld = cc_matWorlds[int(a_dyn_batch_id)];\n#else\nmatWorld = cc_matWorld;\n#endif\nposition = cc_matProj * (cc_matView * cc_matLightPlaneProj * matWorld) * position;\nposition.z -= 0.0001;\nreturn position;\n}\nvoid main() { gl_Position = vert(); }", + "frag": "\nprecision mediump float;\nlayout(std140) uniform CCShadow {\nhighp mat4 cc_matLightPlaneProj;\nhighp mat4 cc_matLightView;\nhighp mat4 cc_matLightViewProj;\nhighp vec4 cc_shadowInvProjDepthInfo;\nhighp vec4 cc_shadowProjDepthInfo;\nhighp vec4 cc_shadowProjInfo;\nlowp vec4 cc_shadowNFLSInfo;\nlowp vec4 cc_shadowWHPBInfo;\nlowp vec4 cc_shadowLPNNInfo;\nlowp vec4 cc_shadowColor;\n};\nlayout(std140) uniform CCGlobal {\nhighp vec4 cc_time;\nmediump vec4 cc_screenSize;\nmediump vec4 cc_nativeSize;\n};\nlayout(std140) uniform CCCamera {\nhighp mat4 cc_matView;\nhighp mat4 cc_matViewInv;\nhighp mat4 cc_matProj;\nhighp mat4 cc_matProjInv;\nhighp mat4 cc_matViewProj;\nhighp mat4 cc_matViewProjInv;\nhighp vec4 cc_cameraPos;\nmediump vec4 cc_screenScale;\nmediump vec4 cc_exposure;\nmediump vec4 cc_mainLitDir;\nmediump vec4 cc_mainLitColor;\nmediump vec4 cc_ambientSky;\nmediump vec4 cc_ambientGround;\nmediump vec4 cc_fogColor;\nmediump vec4 cc_fogBase;\nmediump vec4 cc_fogAdd;\nmediump vec4 cc_nearFar;\nmediump vec4 cc_viewPort;\n};\nvec4 CCFragOutput (vec4 color) {\nreturn color;\n}\nvec4 frag () {\nreturn CCFragOutput(cc_shadowColor);\n}\nlayout(location = 0) out vec4 cc_FragColor;\nvoid main() { cc_FragColor = frag(); }", + } + ], + [ + { + "vert": "\nprecision highp float;\nhighp float decode32 (highp vec4 rgba) {\nrgba = rgba * 255.0;\nhighp float Sign = 1.0 - (step(128.0, (rgba[3]) + 0.5)) * 2.0;\nhighp float Exponent = 2.0 * (mod(float(int((rgba[3]) + 0.5)), 128.0)) + (step(128.0, (rgba[2]) + 0.5)) - 127.0;\nhighp float Mantissa = (mod(float(int((rgba[2]) + 0.5)), 128.0)) * 65536.0 + rgba[1] * 256.0 + rgba[0] + 8388608.0;\nreturn Sign * exp2(Exponent - 23.0) * Mantissa;\n}\nstruct StandardVertInput {\nhighp vec4 position;\nvec3 normal;\nvec4 tangent;\n};\nin vec3 a_position;\nin vec3 a_normal;\nin vec2 a_texCoord;\nin vec4 a_tangent;\n#if CC_USE_MORPH\nin float a_vertexId;\nint getVertexId() {\nreturn int(a_vertexId);\n}\nlayout(std140) uniform CCMorph {\nvec4 cc_displacementWeights[15];\nvec4 cc_displacementTextureInfo;\n};\nvec2 getPixelLocation(vec2 textureResolution, int pixelIndex) {\nfloat pixelIndexF = float(pixelIndex);\nfloat x = mod(pixelIndexF, textureResolution.x);\nfloat y = floor(pixelIndexF / textureResolution.x);\nreturn vec2(x, y);\n}\nvec2 getPixelCoordFromLocation(vec2 location, vec2 textureResolution) {\nreturn (vec2(location.x, location.y) + .5) / textureResolution;\n}\n#if CC_DEVICE_SUPPORT_FLOAT_TEXTURE\nvec4 fetchVec3ArrayFromTexture(sampler2D tex, int pixelIndex) {\nivec2 texSize = textureSize(tex, 0);\nreturn texelFetch(tex, ivec2(pixelIndex % texSize.x, pixelIndex / texSize.x), 0);\n}\n#else\nvec4 fetchVec3ArrayFromTexture(sampler2D tex, int elementIndex) {\nint pixelIndex = elementIndex * 4;\nvec2 location = getPixelLocation(cc_displacementTextureInfo.xy, pixelIndex);\nvec2 x = getPixelCoordFromLocation(location + vec2(0.0, 0.0), cc_displacementTextureInfo.xy);\nvec2 y = getPixelCoordFromLocation(location + vec2(1.0, 0.0), cc_displacementTextureInfo.xy);\nvec2 z = getPixelCoordFromLocation(location + vec2(2.0, 0.0), cc_displacementTextureInfo.xy);\nreturn vec4(\ndecode32(texture(tex, x)),\ndecode32(texture(tex, y)),\ndecode32(texture(tex, z)),\n1.0\n);\n}\n#endif\nfloat getDisplacementWeight(int index) {\nint quot = index / 4;\nint remainder = index - quot * 4;\nif (remainder == 0) {\nreturn cc_displacementWeights[quot].x;\n} else if (remainder == 1) {\nreturn cc_displacementWeights[quot].y;\n} else if (remainder == 2) {\nreturn cc_displacementWeights[quot].z;\n} else {\nreturn cc_displacementWeights[quot].w;\n}\n}\nvec3 getVec3DisplacementFromTexture(sampler2D tex, int vertexIndex) {\n#if CC_MORPH_PRECOMPUTED\nreturn fetchVec3ArrayFromTexture(tex, vertexIndex).rgb;\n#else\nvec3 result = vec3(0, 0, 0);\nint nVertices = int(cc_displacementTextureInfo.z);\nfor (int iTarget = 0; iTarget < CC_MORPH_TARGET_COUNT; ++iTarget) {\nresult += (fetchVec3ArrayFromTexture(tex, nVertices * iTarget + vertexIndex).rgb * getDisplacementWeight(iTarget));\n}\nreturn result;\n#endif\n}\n#if CC_MORPH_TARGET_HAS_POSITION\nuniform sampler2D cc_PositionDisplacements;\nvec3 getPositionDisplacement(int vertexId) {\nreturn getVec3DisplacementFromTexture(cc_PositionDisplacements, vertexId);\n}\n#endif\n#if CC_MORPH_TARGET_HAS_NORMAL\nuniform sampler2D cc_NormalDisplacements;\nvec3 getNormalDisplacement(int vertexId) {\nreturn getVec3DisplacementFromTexture(cc_NormalDisplacements, vertexId);\n}\n#endif\n#if CC_MORPH_TARGET_HAS_TANGENT\nuniform sampler2D cc_TangentDisplacements;\nvec3 getTangentDisplacement(int vertexId) {\nreturn getVec3DisplacementFromTexture(cc_TangentDisplacements, vertexId);\n}\n#endif\nvoid applyMorph (inout StandardVertInput attr) {\nint vertexId = getVertexId();\n#if CC_MORPH_TARGET_HAS_POSITION\nattr.position.xyz = attr.position.xyz + getPositionDisplacement(vertexId);\n#endif\n#if CC_MORPH_TARGET_HAS_NORMAL\nattr.normal.xyz = attr.normal.xyz + getNormalDisplacement(vertexId);\n#endif\n#if CC_MORPH_TARGET_HAS_TANGENT\nattr.tangent.xyz = attr.tangent.xyz + getTangentDisplacement(vertexId);\n#endif\n}\nvoid applyMorph (inout vec4 position) {\n#if CC_MORPH_TARGET_HAS_POSITION\nposition.xyz = position.xyz + getPositionDisplacement(getVertexId());\n#endif\n}\n#endif\n#if CC_USE_SKINNING\nin vec4 a_joints;\nin vec4 a_weights;\n#if CC_USE_BAKED_ANIMATION\n#if USE_INSTANCING\nin highp vec4 a_jointAnimInfo;\n#endif\nlayout(std140) uniform CCSkinningTexture {\nhighp vec4 cc_jointTextureInfo;\n};\nlayout(std140) uniform CCSkinningAnimation {\nhighp vec4 cc_jointAnimInfo;\n};\nuniform highp sampler2D cc_jointTexture;\n#else\nlayout(std140) uniform CCSkinning {\nhighp vec4 cc_joints[30 * 3];\n};\n#endif\n#if CC_USE_BAKED_ANIMATION\n#if CC_DEVICE_SUPPORT_FLOAT_TEXTURE\nmat4 getJointMatrix (float i) {\n#if USE_INSTANCING\nhighp float j = 3.0 * (a_jointAnimInfo.x * a_jointAnimInfo.y + i) + a_jointAnimInfo.z;\n#else\nhighp float j = 3.0 * (cc_jointAnimInfo.x * cc_jointTextureInfo.y + i) + cc_jointTextureInfo.z;\n#endif\nhighp float invSize = cc_jointTextureInfo.w;\nhighp float y = floor(j * invSize);\nhighp float x = floor(j - y * cc_jointTextureInfo.x);\ny = (y + 0.5) * invSize;\nvec4 v1 = texture(cc_jointTexture, vec2((x + 0.5) * invSize, y));\nvec4 v2 = texture(cc_jointTexture, vec2((x + 1.5) * invSize, y));\nvec4 v3 = texture(cc_jointTexture, vec2((x + 2.5) * invSize, y));\nreturn mat4(vec4(v1.xyz, 0.0), vec4(v2.xyz, 0.0), vec4(v3.xyz, 0.0), vec4(v1.w, v2.w, v3.w, 1.0));\n}\n#else\nmat4 getJointMatrix (float i) {\n#if USE_INSTANCING\nhighp float j = 12.0 * (a_jointAnimInfo.x * a_jointAnimInfo.y + i) + a_jointAnimInfo.z;\n#else\nhighp float j = 12.0 * (cc_jointAnimInfo.x * cc_jointTextureInfo.y + i) + cc_jointTextureInfo.z;\n#endif\nhighp float invSize = cc_jointTextureInfo.w;\nhighp float y = floor(j * invSize);\nhighp float x = floor(j - y * cc_jointTextureInfo.x);\ny = (y + 0.5) * invSize;\nvec4 v1 = vec4(\ndecode32(texture(cc_jointTexture, vec2((x + 0.5) * invSize, y))),\ndecode32(texture(cc_jointTexture, vec2((x + 1.5) * invSize, y))),\ndecode32(texture(cc_jointTexture, vec2((x + 2.5) * invSize, y))),\ndecode32(texture(cc_jointTexture, vec2((x + 3.5) * invSize, y)))\n);\nvec4 v2 = vec4(\ndecode32(texture(cc_jointTexture, vec2((x + 4.5) * invSize, y))),\ndecode32(texture(cc_jointTexture, vec2((x + 5.5) * invSize, y))),\ndecode32(texture(cc_jointTexture, vec2((x + 6.5) * invSize, y))),\ndecode32(texture(cc_jointTexture, vec2((x + 7.5) * invSize, y)))\n);\nvec4 v3 = vec4(\ndecode32(texture(cc_jointTexture, vec2((x + 8.5) * invSize, y))),\ndecode32(texture(cc_jointTexture, vec2((x + 9.5) * invSize, y))),\ndecode32(texture(cc_jointTexture, vec2((x + 10.5) * invSize, y))),\ndecode32(texture(cc_jointTexture, vec2((x + 11.5) * invSize, y)))\n);\nreturn mat4(vec4(v1.xyz, 0.0), vec4(v2.xyz, 0.0), vec4(v3.xyz, 0.0), vec4(v1.w, v2.w, v3.w, 1.0));\n}\n#endif\n#else\nmat4 getJointMatrix (float i) {\nint idx = int(i);\nvec4 v1 = cc_joints[idx * 3];\nvec4 v2 = cc_joints[idx * 3 + 1];\nvec4 v3 = cc_joints[idx * 3 + 2];\nreturn mat4(vec4(v1.xyz, 0.0), vec4(v2.xyz, 0.0), vec4(v3.xyz, 0.0), vec4(v1.w, v2.w, v3.w, 1.0));\n}\n#endif\nmat4 skinMatrix () {\nvec4 joints = vec4(a_joints);\nreturn getJointMatrix(joints.x) * a_weights.x\n+ getJointMatrix(joints.y) * a_weights.y\n+ getJointMatrix(joints.z) * a_weights.z\n+ getJointMatrix(joints.w) * a_weights.w;\n}\nvoid CCSkin (inout vec4 position) {\nmat4 m = skinMatrix();\nposition = m * position;\n}\nvoid CCSkin (inout StandardVertInput attr) {\nmat4 m = skinMatrix();\nattr.position = m * attr.position;\nattr.normal = (m * vec4(attr.normal, 0.0)).xyz;\nattr.tangent.xyz = (m * vec4(attr.tangent.xyz, 0.0)).xyz;\n}\n#endif\nlayout(std140) uniform CCGlobal {\nhighp vec4 cc_time;\nmediump vec4 cc_screenSize;\nmediump vec4 cc_nativeSize;\n};\nlayout(std140) uniform CCCamera {\nhighp mat4 cc_matView;\nhighp mat4 cc_matViewInv;\nhighp mat4 cc_matProj;\nhighp mat4 cc_matProjInv;\nhighp mat4 cc_matViewProj;\nhighp mat4 cc_matViewProjInv;\nhighp vec4 cc_cameraPos;\nmediump vec4 cc_screenScale;\nmediump vec4 cc_exposure;\nmediump vec4 cc_mainLitDir;\nmediump vec4 cc_mainLitColor;\nmediump vec4 cc_ambientSky;\nmediump vec4 cc_ambientGround;\nmediump vec4 cc_fogColor;\nmediump vec4 cc_fogBase;\nmediump vec4 cc_fogAdd;\nmediump vec4 cc_nearFar;\nmediump vec4 cc_viewPort;\n};\nout vec2 v_uv;\nvoid main () {\nStandardVertInput In;\nIn.position = vec4(a_position, 1.0);\nIn.normal = a_normal;\nIn.tangent = a_tangent;\n#if CC_USE_MORPH\napplyMorph(In);\n#endif\n#if CC_USE_SKINNING\nCCSkin(In);\n#endif\nIn.position.xy = cc_cameraPos.w == 0.0 ? vec2(In.position.xy.x, -In.position.xy.y) : In.position.xy;\ngl_Position = In.position;\ngl_Position.y = gl_Position.y;\nv_uv = a_texCoord;\n}", + "frag": "\nprecision highp float;\nlayout(std140) uniform CCGlobal {\nhighp vec4 cc_time;\nmediump vec4 cc_screenSize;\nmediump vec4 cc_nativeSize;\n};\nlayout(std140) uniform CCCamera {\nhighp mat4 cc_matView;\nhighp mat4 cc_matViewInv;\nhighp mat4 cc_matProj;\nhighp mat4 cc_matProjInv;\nhighp mat4 cc_matViewProj;\nhighp mat4 cc_matViewProjInv;\nhighp vec4 cc_cameraPos;\nmediump vec4 cc_screenScale;\nmediump vec4 cc_exposure;\nmediump vec4 cc_mainLitDir;\nmediump vec4 cc_mainLitColor;\nmediump vec4 cc_ambientSky;\nmediump vec4 cc_ambientGround;\nmediump vec4 cc_fogColor;\nmediump vec4 cc_fogBase;\nmediump vec4 cc_fogAdd;\nmediump vec4 cc_nearFar;\nmediump vec4 cc_viewPort;\n};\n#if ANTIALIAS_TYPE == 1\nvec4 fxaa(sampler2D tex, vec2 fragCoord, vec2 resolution,\nvec2 v_rgbNW, vec2 v_rgbNE,\nvec2 v_rgbSW, vec2 v_rgbSE,\nvec2 v_rgbM) {\nvec4 color;\nmediump vec2 inverseVP = vec2(1.0 / resolution.x, 1.0 / resolution.y);\nvec3 rgbNW = texture(tex, v_rgbNW).xyz;\nvec3 rgbNE = texture(tex, v_rgbNE).xyz;\nvec3 rgbSW = texture(tex, v_rgbSW).xyz;\nvec3 rgbSE = texture(tex, v_rgbSE).xyz;\nvec4 texColor = texture(tex, v_rgbM);\nvec3 rgbM = texColor.xyz;\nvec3 luma = vec3(0.299, 0.587, 0.114);\nfloat lumaNW = dot(rgbNW, luma);\nfloat lumaNE = dot(rgbNE, luma);\nfloat lumaSW = dot(rgbSW, luma);\nfloat lumaSE = dot(rgbSE, luma);\nfloat lumaM = dot(rgbM, luma);\nfloat lumaMin = min(lumaM, min(min(lumaNW, lumaNE), min(lumaSW, lumaSE)));\nfloat lumaMax = max(lumaM, max(max(lumaNW, lumaNE), max(lumaSW, lumaSE)));\nmediump vec2 dir;\ndir.x = -((lumaNW + lumaNE) - (lumaSW + lumaSE));\ndir.y = ((lumaNW + lumaSW) - (lumaNE + lumaSE));\nfloat dirReduce = max((lumaNW + lumaNE + lumaSW + lumaSE) *\n(0.25 * (1.0 / 8.0)), (1.0/ 128.0));\nfloat rcpDirMin = 1.0 / (min(abs(dir.x), abs(dir.y)) + dirReduce);\ndir = min(vec2(8.0, 8.0),\nmax(vec2(-8.0, -8.0),\ndir * rcpDirMin)) * inverseVP;\nvec3 rgbA = 0.5 * (\ntexture(tex, fragCoord * inverseVP + dir * (1.0 / 3.0 - 0.5)).xyz +\ntexture(tex, fragCoord * inverseVP + dir * (2.0 / 3.0 - 0.5)).xyz);\nvec3 rgbB = rgbA * 0.5 + 0.25 * (\ntexture(tex, fragCoord * inverseVP + dir * -0.5).xyz +\ntexture(tex, fragCoord * inverseVP + dir * 0.5).xyz);\nfloat lumaB = dot(rgbB, luma);\nif ((lumaB < lumaMin) || (lumaB > lumaMax))\ncolor = vec4(rgbA, texColor.a);\nelse\ncolor = vec4(rgbB, texColor.a);\nreturn color;\n}\n#endif\nin vec2 v_uv;\nuniform sampler2D outputResultMap;\nlayout(location = 0) out vec4 fragColor;\nvoid texcoords(vec2 fragCoord, vec2 resolution,\nout vec2 v_rgbNW, out vec2 v_rgbNE,\nout vec2 v_rgbSW, out vec2 v_rgbSE,\nout vec2 v_rgbM) {\nvec2 inverseVP = 1.0 / resolution.xy;\nv_rgbNW = (fragCoord + vec2(-1.0, -1.0)) * inverseVP;\nv_rgbNE = (fragCoord + vec2(1.0, -1.0)) * inverseVP;\nv_rgbSW = (fragCoord + vec2(-1.0, 1.0)) * inverseVP;\nv_rgbSE = (fragCoord + vec2(1.0, 1.0)) * inverseVP;\nv_rgbM = vec2(fragCoord * inverseVP);\n}\nvoid main () {\nmediump vec2 v_rgbNW;\nmediump vec2 v_rgbNE;\nmediump vec2 v_rgbSW;\nmediump vec2 v_rgbSE;\nmediump vec2 v_rgbM;\n#if ANTIALIAS_TYPE == 1\nvec2 resolution = cc_screenSize.xy;\nvec2 fragCoord = v_uv * resolution;\ntexcoords(fragCoord, resolution, v_rgbNW, v_rgbNE, v_rgbSW, v_rgbSE, v_rgbM);\nfragColor = fxaa(outputResultMap, fragCoord, resolution, v_rgbNW, v_rgbNE, v_rgbSW, v_rgbSE, v_rgbM);\n#else\nfragColor = texture(outputResultMap, v_uv);\n#endif\n}", + } + ], + [ + { + "vert": "\nprecision highp float;\nlayout(std140) uniform CCGlobal {\nhighp vec4 cc_time;\nmediump vec4 cc_screenSize;\nmediump vec4 cc_nativeSize;\n};\nlayout(std140) uniform CCCamera {\nhighp mat4 cc_matView;\nhighp mat4 cc_matViewInv;\nhighp mat4 cc_matProj;\nhighp mat4 cc_matProjInv;\nhighp mat4 cc_matViewProj;\nhighp mat4 cc_matViewProjInv;\nhighp vec4 cc_cameraPos;\nmediump vec4 cc_screenScale;\nmediump vec4 cc_exposure;\nmediump vec4 cc_mainLitDir;\nmediump vec4 cc_mainLitColor;\nmediump vec4 cc_ambientSky;\nmediump vec4 cc_ambientGround;\nmediump vec4 cc_fogColor;\nmediump vec4 cc_fogBase;\nmediump vec4 cc_fogAdd;\nmediump vec4 cc_nearFar;\nmediump vec4 cc_viewPort;\n};\nstruct StandardVertInput {\nhighp vec4 position;\nvec3 normal;\nvec4 tangent;\n};\nin vec3 a_position;\nin vec3 a_normal;\nin vec2 a_texCoord;\nin vec4 a_tangent;\nout mediump vec4 viewDir;\nvec4 vert () {\nviewDir = vec4(a_position, 1.0);\nmat4 matViewRotOnly = mat4(mat3(cc_matView));\nvec4 pos = matViewRotOnly * viewDir;\nif (cc_matProj[3].w > 0.0) {\nmat4 matProj = cc_matProj;\nvec2 scale = vec2(48.0, 24.0);\nmatProj[0].xy *= scale;\nmatProj[1].xy *= scale;\nmatProj[2].zw = vec2(-1.0);\nmatProj[3].zw = vec2(0.0);\npos = matProj * pos;\n} else {\npos = cc_matProj * pos;\n}\npos.z = 0.99999 * pos.w;\nreturn pos;\n}\nvoid main() { gl_Position = vert(); }", + "frag": "\nprecision mediump float;\nlayout(std140) uniform CCGlobal {\nhighp vec4 cc_time;\nmediump vec4 cc_screenSize;\nmediump vec4 cc_nativeSize;\n};\nlayout(std140) uniform CCCamera {\nhighp mat4 cc_matView;\nhighp mat4 cc_matViewInv;\nhighp mat4 cc_matProj;\nhighp mat4 cc_matProjInv;\nhighp mat4 cc_matViewProj;\nhighp mat4 cc_matViewProjInv;\nhighp vec4 cc_cameraPos;\nmediump vec4 cc_screenScale;\nmediump vec4 cc_exposure;\nmediump vec4 cc_mainLitDir;\nmediump vec4 cc_mainLitColor;\nmediump vec4 cc_ambientSky;\nmediump vec4 cc_ambientGround;\nmediump vec4 cc_fogColor;\nmediump vec4 cc_fogBase;\nmediump vec4 cc_fogAdd;\nmediump vec4 cc_nearFar;\nmediump vec4 cc_viewPort;\n};\nuniform samplerCube cc_environment;\nvec3 unpackRGBE (vec4 rgbe) {\nreturn rgbe.rgb * pow(1.1, rgbe.a * 255.0 - 128.0);\n}\nvec3 SRGBToLinear (vec3 gamma) {\nreturn gamma * gamma;\n}\nvec3 ACESToneMap (vec3 color) {\ncolor = min(color, vec3(8.0));\nconst float A = 2.51;\nconst float B = 0.03;\nconst float C = 2.43;\nconst float D = 0.59;\nconst float E = 0.14;\nreturn (color * (A * color + B)) / (color * (C * color + D) + E);\n}\nvec4 CCFragOutput (vec4 color) {\n#if CC_USE_HDR\ncolor.rgb = ACESToneMap(color.rgb);\n#endif\ncolor.rgb = sqrt(color.rgb);\nreturn color;\n}\nin mediump vec4 viewDir;\nvec4 frag () {\n#if USE_RGBE_CUBEMAP\nvec3 c = unpackRGBE(texture(cc_environment, viewDir.xyz));\n#else\nvec3 c = SRGBToLinear(texture(cc_environment, viewDir.xyz).rgb);\n#endif\nreturn CCFragOutput(vec4(c * cc_ambientSky.w, 1.0));\n}\nlayout(location = 0) out vec4 cc_FragColor;\nvoid main() { cc_FragColor = frag(); }", + } + ], + [ + { + "vert": "\nprecision mediump float;\nlayout(std140) uniform CCGlobal {\nhighp vec4 cc_time;\nmediump vec4 cc_screenSize;\nmediump vec4 cc_nativeSize;\n};\nlayout(std140) uniform CCCamera {\nhighp mat4 cc_matView;\nhighp mat4 cc_matViewInv;\nhighp mat4 cc_matProj;\nhighp mat4 cc_matProjInv;\nhighp mat4 cc_matViewProj;\nhighp mat4 cc_matViewProjInv;\nhighp vec4 cc_cameraPos;\nmediump vec4 cc_screenScale;\nmediump vec4 cc_exposure;\nmediump vec4 cc_mainLitDir;\nmediump vec4 cc_mainLitColor;\nmediump vec4 cc_ambientSky;\nmediump vec4 cc_ambientGround;\nmediump vec4 cc_fogColor;\nmediump vec4 cc_fogBase;\nmediump vec4 cc_fogAdd;\nmediump vec4 cc_nearFar;\nmediump vec4 cc_viewPort;\n};\nin vec3 a_position;\nin vec4 a_color;\nout vec2 v_uv;\nlayout(std140) uniform Constants {\nvec4 offset;\n};\nlayout(std140) uniform PerFrameInfo {\nvec4 digits[8 * 10 / 4];\n};\nfloat getComponent(vec4 v, float i) {\nif (i < 1.0) { return v.x; }\nelse if (i < 2.0) { return v.y; }\nelse if (i < 3.0) { return v.z; }\nelse { return v.w; }\n}\nvec4 vert () {\nmat2 proj = mat2(cc_matProj[0].xy, cc_matProj[1].xy);\nproj /= abs(proj[1].x + proj[1].y);\nvec2 position = proj * a_position.xy + offset.xy;\nv_uv = a_color.xy;\nif (a_color.z >= 0.0) {\nfloat n = getComponent(digits[int(a_color.z)], a_color.w);\nv_uv += vec2(offset.z * n, 0.0);\n}\nreturn vec4(position, 0.0, 1.0);\n}\nvoid main() { gl_Position = vert(); }", + "frag": "\nprecision mediump float;\nlayout(std140) uniform CCGlobal {\nhighp vec4 cc_time;\nmediump vec4 cc_screenSize;\nmediump vec4 cc_nativeSize;\n};\nlayout(std140) uniform CCCamera {\nhighp mat4 cc_matView;\nhighp mat4 cc_matViewInv;\nhighp mat4 cc_matProj;\nhighp mat4 cc_matProjInv;\nhighp mat4 cc_matViewProj;\nhighp mat4 cc_matViewProjInv;\nhighp vec4 cc_cameraPos;\nmediump vec4 cc_screenScale;\nmediump vec4 cc_exposure;\nmediump vec4 cc_mainLitDir;\nmediump vec4 cc_mainLitColor;\nmediump vec4 cc_ambientSky;\nmediump vec4 cc_ambientGround;\nmediump vec4 cc_fogColor;\nmediump vec4 cc_fogBase;\nmediump vec4 cc_fogAdd;\nmediump vec4 cc_nearFar;\nmediump vec4 cc_viewPort;\n};\nvec4 CCFragOutput (vec4 color) {\nreturn color;\n}\nin vec2 v_uv;\nuniform sampler2D mainTexture;\nvec4 frag () {\nreturn CCFragOutput(texture(mainTexture, v_uv));\n}\nlayout(location = 0) out vec4 cc_FragColor;\nvoid main() { cc_FragColor = frag(); }", + } + ], + [ + { + "vert": "\nprecision mediump float;\nin vec2 a_position;\nin vec2 a_texCoord;\nout vec2 v_uv;\nlayout(std140) uniform Constant {\nvec4 u_buffer0;\nvec4 u_buffer1;\nmat4 u_projection;\n};\nvec4 vert () {\nvec2 worldPos = a_position * u_buffer1.xy + u_buffer1.zw;\nvec2 clipSpace = worldPos / u_buffer0.xy * 2.0 - 1.0;\nvec4 screenPos = u_projection * vec4(clipSpace, 0.0, 1.0);\nv_uv = a_texCoord;\nreturn screenPos;\n}\nvoid main() { gl_Position = vert(); }", + "frag": "\nprecision mediump float;\nin vec2 v_uv;\nlayout(std140) uniform Factor {\nfloat u_percent;\n};\nuniform sampler2D mainTexture;\nvec4 frag () {\nvec4 color = texture(mainTexture, v_uv);\nfloat percent = clamp(u_percent, 0.0, 1.0);\ncolor.xyz *= percent;\nreturn color;\n}\nlayout(location = 0) out vec4 cc_FragColor;\nvoid main() { cc_FragColor = frag(); }", + } + ] +]; diff --git a/native/cocos/core/builtin/shader-sources/glsl4.cpp b/native/cocos/core/builtin/shader-sources/glsl4.cpp new file mode 100644 index 0000000000..964291a9bf --- /dev/null +++ b/native/cocos/core/builtin/shader-sources/glsl4.cpp @@ -0,0 +1,134 @@ +/**************************************************************************** + 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. +****************************************************************************/ + +// clang-format off +#include "core/builtin/shader-sources/glsl4.h" + +namespace cc { + +ShaderSource builtinGLSL4{ +{{ + {"vert", GzipedString("H4sIAAAAAAAACoVYX2/bNhB/96fgUyE1imsp2ZPRAl22FgFSLG26bu0QGLJMp9xk0RElWVKR7767IylRtpQChn26+93/I0V6ts95IpSQGdvxjSh3e7ZNZVwsZ2ncyLLwFC/YaxYGbC2yjcge4GHhszITW5nv2JXMVBFnhWI/ZhVPLtkuFtlnkQJw9cd2C8pLzd/m8Y6DgK8qnt7w7C6JU25kyqEzueGfZBEXENFy9nQUxmIqjKv3qVzHKUTxXTx83zPGyFqSrAqxA9s2N8tVSc4hCNGOyDJwXnEtezaA0A3gCvLLYyeAXVyQOfj9IvhhOSW4zqpR2W0u/50UTCmhwUlFKxwo26wTiv9Wqsli6S4dC3m9l6rMRyQ4Cjei+E3kk7IrmcoRabxbC54Vd/81k7L3uSyzzal4Kx8mjILk11iNxAmCt5sRUxmP83fxiKUK6yjz4nQ8osn5vJGJM55OU/6SebpZTvCvP1uJ9Z3CUwH2P8T7P7/cxrCqKAoSP5ZxwfMMVs67XO7e1kIxDwQXrEY6ILLpyRZJ/8cMnF2wHQSMhKexGqYRyxntCKzI44Qj7J/FPXzYGVDhPXyIiu7h4wSynIkt87TOG7aY+5C8tqOwNvNf2CumHvPCQM5YOF+AK1SdHwgREcSwamB55AX8nWvP0b3PXnaIRiMWyCdEhFG6iFYjQor+XOcRWsQT46niDIP2bIZvbIY+e/GCDdiUrj9MKpov0BYmBclQVRadr7CLXKs6qY7lNcycijGWati1YTFQat1inPXFeHWUqo2rT+lnGfV59LmNZXTSh5NePhN+c5pz37w+o/Aoo5+EHnUhHbXlKPSTARkLfaSubm/G4+wy6ZN7MjGnPAO+cfLSEmfMGH1pCcNpLae1nIPlHPTSQ4N24Wnj4dyuOXj2nYw6r8B30uhc9+zWstsB+2DZB8t+muW8KPPM7AVPYzvU72XKc7NFxdlDyn3bQAyKOBDVK2il3YKajt8M+G3Hbwd8hYaUyLy628USZCVSOSzVGFTToxqD6lmqNai2R7UGhawuQeAh7S3cEissb4LFTLBjCT4qfFStU/GeTaheqUO1FmXYMKbKUXL6kbgeXRTammrOhzItxD5tqCuXLA70i2ft/3B39i6rmKZmDf7OgD4QXRPdEI2OY5qV9bxx8rRyV68hujU2zjvbbuZW7uq1RNfGxnlnu3ZqYbEHx27tYBsnzpHqSLFhOR5K+Ree4OR+xDZ7IoM3P6PxrUyhHrsRFrSwyG+lFzL5qqgmj+SrwpoYdOOgaZEbRE3oWmt26NZB0wZgEA2htZ+6Q2MFzi2kdiCNEwoYr6ingrYfKrFAD6R5hhESjeGLVtMN6mDkJBzqYBIWhz7JLOqjDsZPwqEOpmJxGJv1WZsZvTBduM7oOHW3x5OD3j/gEBow57DDnNMO6487TpuIwKPcR71mT09P5ixkrdjTEClCII6eXTaetReAC5ij45nxKEyj63eDtpf0IjBHyRRyw+uPPkLiiDkH0IiV1XIEGZ4g4bioD8I0vonc7UuMJS/gjO/M7mVXugi+8kLf2mydTO3ULNBn00pfWGa+vu9dEIP6gJb1znfh9XZo6NS8DhzbNHxq3gT4clpqM3D7+Bu0MzgsxyncvDxtR3vTr+vAOtfv5/5Rv4IdS1+ftRQOLYVDS+HA0rdnLUVDS9HQUkSWoLjzuoHBfj0yu96gegFVgb6/0vc3PUUTgyEy3Zt4BT6Evi+PzoUGRgAseH0lZb4ZA0YWCLv+ykzO9F8AztV3XQoY/sz+AYD3RSjWKncv8XqtKbr2eb6FQtz2XdknEYBtKhu+wvqbEIwMrZKjOcW9vUsLCg2bBlwtlrPhuHtmxPvpHjmI6PYu5jiWwUka89b39WLwTkS1HuVgeKk/ysJevm0iZXUcO0YNZSe2acBwf6CFbEvIHtLVrakZVtEWd8me/gcwHeJg1BEAAA==")}, + {"frag", GzipedString("H4sIAAAAAAAACn1Sy07DMBC89yv2mKAK0dJbxAGCQEhIIIG4om3iloXYjvwIFNR/x3ZkSIXNyfHOzmR2PbNesYY0SQGctWR5D5tOoqlmHe6kNYVmBs7gZA5rEi2Jrb+UYAVtpOJQ19edXGMHX7MX2r70ADCwZgVN82yIs2oWRWNVN4ox8UCfCUygoYGN2P4/A4upgRo5UzgxwNEEOXc+EXuvcsCNGJLYvZKvWSBH8oJZYgQPyHHqJvi/lzq7rAa7xLbYRy+1VQmEI4lbMpekslgtO5lAka+JCfPwtsti10pa0f6FN3KbEXXIBeqETwectwkpwVBdYUJp8HuUyoR4hGJdXync3lnTWwPF2OddlC4PihmrxHh3jJinTjYuZy7vIcgkvPoS7FAlGhaxYRVlDkK5mIby9DeUGnnfMbW8BL/uR/Zhwjvluctfrp+nlkIbFEa7KcLPDYn4ZHFybFsoytjg3HmZ4xM4Gp2684fkv0cPxcTP3M1cVnFL00UWTqHMbsxVfh5kNBt8DZLaMK43dYA5mjNblBXsvwGo+0X1bgQAAA==")} +}}, +{{ + {"vert", GzipedString("H4sIAAAAAAAACkWLQQrCMBBF93OKv0zAhaK74B28QQkxtgMxE9JpoUjvbqKCu5n336NSY+CZJWPicSp4JPHqKPlNFjVJgtc+XnG04Iw1hjP8UGTmzh01cGm0KozF6/u2tQX9NH/1gJN1VKMuNXfD0U6r8B1Pz7m3GNNw+8mfvKqxDvsbCVKzp6MAAAA=")}, + {"frag", GzipedString("H4sIAAAAAAAAClWNwQrCMBBE7/mKOSYXqeAt9CT4G7KsabsQs2VNBZH+u4mevM3szL5xqyWWh2jBIvOyYspKNbpn4hMmoxk+4P2zihFd+ONhCNFZqpsVaHS7y/TSrfqsTLWzRgwB7fLtg/l6aaizZrWGVrnhTlI6+S9rb33Sh4j9A43v9mmZAAAA")} +}}, +{{ + {"vert", GzipedString("H4sIAAAAAAAACn1Ty07DMBC85yv2mCIOtHCLOEARFRJIkXgdq63jtgt+RI4TXuq/Y8dNCcLmlOzO7Ox4vc5qwxk1pBVsabOtYS002iIT+KFbmzfcwjmcHMOKVEVq44MJtIrW2kiYzxdCr1DAVxaKATrOzoCxpSXJi0zyilpZH7INM5yre/qMYAotdTxgu/8MTMcG5ii5wZEBibaXc98n4m9FCrhRXRQrjX5JAqkiL5gsHMBfxcOpWe+/1E1yWAxFZFr8vdZNayKIRFK3ZK/IJLG5FjqColwRV/b+9SOJLYxuVfUXXutNQtQhl9hEfDrgoopIKY7mGiNKnZ+jNvbvesyS+3mr2Wg9R5fyrI2oikT+5mFAht7CRdbp32H9+FSiQTl2IVwX659Q352ULzsFXLorIp+PEacD8cwRWZhdVM5lAq1L02a9WP90nVpFjU209GKB1u1pQZobC/nEDaoPnW9H97/5zyGOXX2RBej3YsPReHguqv067+069uF8oWefCc0Nt61Rgb/LOk0V+BX1TmAjluW+dW/G2HxSwO4btGSDxrEEAAA=")}, + {"frag", GzipedString("H4sIAAAAAAAACm2PzYrDMAyE73mKOTpLaxLYW+ip0NcoqvNjgxsF200pS9995ZgWCr1Jmm+GUbWEwbjoeIZ1k10weqbUVZ4efEvKs6GUxQOaGm7GOphfrGfDnsM3qt2oLUSw3kXJ2jxjoAmqxl9ZWdh3TMGJ5DbeXZ+sKtb6LfnFZrXV2CNemZONaVjUnmiHRu9Al/jyCNHqRqysw3TBzwGsSbY8bTldFYZ0CzO4q57fH5VL+dSY80mKH0vPlV2PK7k5//Gh5eYyq7rD8x9OwfMUUwEAAA==")} +}}, +{{ + {"vert", GzipedString("H4sIAAAAAAAACn2TwU+DMBTG7/wV7whzMZt6Izs41GniYckSPS5dKexpaUkpbNPsf7fFwFjW7gR9v37f+1oeQakYxQqlgC3m2xIyLomOA04OstZhxTTMYDKGDYoURW4XEdQCM6kKSJIFlxvC4Tf4FwM0jD4ApWuNBYuDgqVYF2VfrahiTKzwx8EE0diwf3a8FmA6DJCQgikyCFAQ3dqZ5weyXewDb6JxsqWSX17gE1lDr7CDZ+Lu1LTNv5SV97Io4Y7bYvtSVrVykIKgeEf9hMrLEsmlg5Jig0zo1ffByxZK1iK9xJnMPaaGzEnlyGnAY+qwEoyoF+Jwauw9SqUvx+POO5+fUvF0bjP3I9LZ7XqUmIMxFXv5K+HZ816bXdWwN5fUjKz5cdqeKKzyHsjafBi09ThorRqmNISR6d8uT7R7M3pLwpNyDNPbSTTYMZpdSdTvupm5zzVodD6RMBrEUUzXSgwKx6CRmIKdGRsfcr5eDiMrHUYxHP8AV450J0IEAAA=")}, + {"frag", GzipedString("H4sIAAAAAAAAClWNzQrDIBCE7z7FHBV6SKA36anQ1yjLxhRB3bDVQgl592puhTnNzzdm08DxHaUghyW2vGFNQtWbT+ArVqUXrMNuNNSmBcO18wXTqdl5c5hEX2nVJmGqA3TD5NCdswzm56NT7pJEO1XigkyxDOhf1mfjzTqP4wfn3nrmlgAAAA==")} +}}, +{{ + {"vert", GzipedString("H4sIAAAAAAAACtUba2/bRvK7fgWLAgVlSypJO6/TuYec4xQGkji1nfRxKARGolNeJFKmKIlkm/9+89gnuZLt3KM4IJGp2ZnZee3szC7VWxbJNF2leeYtklm6Xiy9m3kel+PeJpkee7fruEyKDIZfFvnieZWuPB8GjrwKnwf0WOvHBh/7v/cWcXnkLbwTDx98xmU0xhj3aBKvLOJpgmj/CH6Ff94hPIW/wj96in6Ff4Yg41564/lM850XjPre74LPCngEo0fet97qtigFyqEXjgKYCklHW8KICEWAKgD5NAvMN+SZo1/73oHCqBkjQDhhRCilidEwRkjSD1mPUGJ89pL5KvFQaF9q+J3UsO99841ngUndvq1UNAqQFyoFypBVAjVXqCRnUkNVl1625mQMl6qhckNgETWmMQ61Mb5tqSrl0irdpZHWQ+vm0qjjh44v94hfd3XWztMahS2N7hA9UiK13NISvRMgLtEddjV945ZTaaKV+yxknicZwMUkB/Lh0BNMD+SDgDQS0kjIVkK2vPSQoVx4zDwcyTUH3/uGRmpWgBtqqKk1uJHgxgJvJXgrwZ97RVKui0zkgs+uDHW2nieFSFFx9nGe9KUDUSiCgFTfgitlCqoVvLbgjYI3FnyFjFZp5lcqi00RNM1XBmhVC6xaY9UCS4NWjcBqNFYjsBCkFAQYPvuBaeIVmneKxpyix6b4dYVfV41hcQ0mLE2ksBqJJcAQpiuDyPDH1JzRxEJeLedA5j/G9F+kFTrm8pq8AuoMPPLOUnsmQldzZI4q5ReGUnSOauUVhlKEjhoJrSrB4QCYKWCtgLUGNgrYKGBdi6lMzLpRQI3ZNGJ6E7jl2bfW7NtaATXPbaOASC4shpbye7CShp5fo75N0x+g+IdAMECRh8Bu4AWDHgCHBGTsqpLYNVpkWzESPdcEHBLQwK7rPiEtRwBfjmr8QH69vuk09thVy2Wl+LuyFtUtchIWHHjCQANvy6qOTSejALaDUUnbuSi87ViHWx1OdbjU4VCHOx3OdLjS4citRch5QccvZwAdubzWR43tdt92OxUOYE5feF9/5yCQ38GBvogFAoHhfTskFFhEhvxOlBwgBGoYZShRGpsThIsEA2WJri7RzSUFTd/Kwq/X8zJdzmsRNTFFy7H3AaLFKOFU+oppFX6A1XAIz1t6rui5pmcUKqal9gGtqBKaHDfpanpuBI+h4m2mODlu0jX0XAkeQ8W7MpKexN0afCsDtzbk7KbBTZ7OvCIvYZN6n0xxXf2A+dxPs3xd8nLaCEPdqmWV6oyyEXmxpme0CaefjY6stDawOV82gnIoct1G58q0MbA5j1aCcqjmUVGcogWGEqUyUGpDFGC+IZ+mVGeQiVOcYchpPa35GcVPG36ukQYlp0GbBpWQeDgnsR3e8jwoPw3aNKiKxEPZ5JyViNEj4YXz7FU+jedXS2wRuFBY5iuR2bhT8Yy2xtN9jeEmetikyfYH3py7bZJoeiQX2fYQIQhi0Mll40t+A5gC4qgdMz6JKWj7KtAAKjL3EbG7zl9jzyVE9X5n3RcBlxBHuNEEYB6uZdmZbDAJYdM2g54EVALlUKFs3SiNwYVRalYZ5g/V/G22bRpga4tYic89ItYC3BaxUvNHO+bv0tRdtm0Rq7tFrJX+Ot0f+YtgAKaA/5FOnThwnZOHuW0G76q2oyy4idb9MTyrDhmeRY/M2LdbiB1I0beQoW8b2S5TyR5onle4EXGbLHpkkBXkVms+21xRaR9A4XsFmVD1zgf0lRsWloObH5aD+16kBqRaIkWy82ElIhOpkUiB7ACZa2AgWU20MsR32hD9b77pDLRbaaWy6NsU+tAw6NAgvYdF7jRBZZutNmiUK4MWTWOb7dBlNrPXVsKbeu9T21TVNMHD1N7n1Oo+eta2bUy1QyPMHWrv0S0ynNFx77112xOLWrc97rFCf5cyt41lANXaUpenlzD83+pMkWBzK1IFZTUCqByfYK4gEDANRo/GRpGeFLJKhydRpsNTY1ev/+Ou9v+ml53HNVRr/irBPRvS94c0m6XZR3Rh31tn6U1eLLzTPFuVcVauvN9lYk+z63QOiJOLmxsgFqrfFPEigYFksknmr5LsCsqRRIytjOcsnyWXWAVAWQFSjG0xgl1inH4/zz/Ec5Dit/Tjb0vP47JlOp2U6QJ4y2NeCV1NiwSESBvHWAaTbxIe2ytAaApwCvoVsSEAtZXADv6+hyJnvGvgPNs4x94W+T93DuwiQoY7CeWgRSy1npL8b7Gw2mEs9lJ7MKmgGFsXjhEMhVdp+SItdo6d5vPcMRovPqRJVl59qneOfV/k62zWHb7JP+5gCiN/j1cOOWHg+czBKkvi4mXs4IQ169u8KLvhEe2MT6q/VXQYTvkxL+az8Q74+bUckXPP4VsJ/F/Hy3fv38awqkwp5jALrhyeHZstQ/bIW29cmGEHE2ZiG1IjN80XyzVW5UUJ4WF0cceqiYjgoyh5wcuOQZ6b9L6GTfv0dHJ59ubF2eXk9cWLM+8E5PP++MMBPuoN2AobXhq9rxOw580OJmFPzJLUSU9MDPkln6ZlDd85D0sABbCCzpPsY/mbDavOs1lSySlxj9khO+89KCK1VGgaWWprQ1CBvMItyIBRssXNKBjJMh1W3k9AnUGgxHPIOj7zYf15Tx9Ic/DmrL/ysbnB6ee9nEKbU2hzCi1Ov+zlFNmcIptTRJwgOkYVHsWcONpQ37LegKxAnz/T5y/cEH6dzHc4Xop5iQvCEnVa5KuVLycfYmwMVBAgjE93sEmWTN4tyX0aBTt8M2xg4zVtYfDyDsxQYu9aqvtKyAMv/rCyAoQEST9mJhAPn4ZCqAMRkrsNEf03QpGoQzz98oJWbNFQQEPD8N/yMXlJQ/r7HX70n9Kze8TQEvJ2/7rUW6lcmgYk7ECcC1QaMTTsm5OwWKPhtAe2pnSgRMTtATvWclFyfY1dAw8g2DQQ49ctcD2WWY/K7kgm/XfvPZ9zIxVwFIxGxje/qwqPj4oiL85SICdtI9QW+OSFr/mALooGo37cIwoqjffitijxKJIIaxsLo6kbS1+deMc9JTtV2HT0a4CULURF7Au58DRIoeFNJGlmzDiwFNpfRBvF41W8WM6TTim9nqxo4Dy7ybulhsUs0syu0+knB6stlhNQWI8lAOviF8m8jHfXDym3Zl48gZBJET4BtkXJJbWzkNAkK1gxE3fBEZl4hSj2d+AembiiKuliHZtYs7SAMunGKeIjQuSIhrmz2VWSzJxxcoJx0mXwWM50BPRlUp1CnM5cMz1xIR65MJ+amJxtXGjPOpYIVaAS8TqDrPDpdF1skhdxGXs+h08RvfBKtUqnKEZfxkUMfGEMojzxCYeHRZB8cI7CIjAjc2S0xbhwi3ha+oRI69RCrYyTwbTyY0xbA7xZwD/Tvjq0vr8mAypdxf3Un6kWdtes0xY12rI+dyjL/JerZD3LL+Nsli9Esq30cVaO13zjHibFRT7z8bg1HEE2jfAIk56lnDdFcvs+xvOQMBiFjx8fB08eHR0/1XeB4oRC4h2ILJvzyQkwg8++UntDh7CVH+BsMM0Qi5eKtjLvAM9xngRPwuDxk6dhhCC8Zvwrnrl6f/OGG+8v3kapv0FdaYldvLq4nFy8hzV2ff76DBfau1dnk7M3z//+6mxfrjRaKR0KtAYmOWRkSma4yIJ9SfLIPLYAUpklwdQpfK55UU3Aytz4G53H5cX18+vzizdfInvokl1lvfuLf6z5yAOSjgaKrUuJq/Nfzr5EgcilAKX3+wv/yNjtgLIjOLFzCf3y4vL0i6Q+ckkNX6cPEfuxZvISSTtyM0MW3ISssEBr6/L+7NXF6fn1z1+izrFLHdmIPECjJ5rPe0HdUUqxNfVSQKdq12c/Xb+7PJs8f3P+mlfKvTV75NJM5OcJVF4Ljui7FHuq2TyXRIZmoupBfpNUFlRCAc53RbJM8JJa3EHZ5wSYj0U2KyFRcuIsoQSUw7ILVOfW3GfwvTeflairVHl2nWLW5D7olreFJbeUh+LSjb6K/qBI8G28JVf64sbNok03esOhE3WgkFyN8/SPy82Kjt88X28ysLmlG6hbF/heqlEb8p2/o/zT77io9mgmyKdz8KJvcPzWqMlwY5QbCu/HkYf8qDoKZLNg89QNqoEb7sINR+66/4Trftm4zCrJQFdnWMAb3+q+bKTcZKLCRZWsMpasrQszfSLliRfaDHOQf6R6dJ6mkRxWJ/RQtesoAeBrUShc7sz1eIlmpFw6T8FYIHawtbfKL9+R6weG1/rGNZUSa4LOfDgjTR8+mD5UpcsNRB/s5LRgzOJKVfywgo6ePY0eoSWl1likseQDIcFAMaLlY9ba2B7zgc8JX1+IQ6MV3RrcvXERE9oqMFmpIwGUh72jNxblHhO9bRnXxrbXR0zgctI9WBkcXG66g0PHTzfAY7ejojAKH5OnTAOgt4QOAymK8teNTnc0dA3V+ye5sBQXsfBMe9PeRie8yuCSVudzX8MHRmct5jTOEA9PjOnF2nxANSAuFpdghtc5UKVJEdBpxdg1FIohPiYTYuwILmuDV/HVImp7dUexYYbGoCVtJ+rgA/xTO+Puy/hbbF3BeDfbsMW2E5+bfXkkfPbk6ePHnJIt+2GEKn0HWkYVpbhfd7xLWcgCtqWz6D/bO4wV6KY8VqzbpZwK9zYTI+KtoTuD3sKWJYx5tn7S8qNaF8ZRZus0vlVmHFg1BWfcr2DHf3d1Nvnx4vLVi8nV2+enZz3eUI0bNayq8I5z132SsVc79G+pLlezsTHQXi37M9qbzcpA7c+uQ8m9d03AhV/zP7GnkGll7zWJQaxTgSptXOMYL4PWTE2rrAEqr/0WILHxJT9zln341jz9h3XeHNJW42tkNPm+iCMx7GjBra3u7sBT73V4J9arKonQn99u49vfE/NdxVt+oZHHr9AA9nhBEcY2M9+WY9QDwbOTYZVWrhR7H5XHLT6unHo3n04OLfbm0OhR9CxSZa30GOZCrc/AkEnlwOIeLnKvqyP3/XPUS+yVEIiGhcCdNfDnet66HN97tsarRB9wqSVCIMpT/HSgjkZdx2t7SkrxzgDF3QNYGJTh/Sk74TXdF17PwuCYmqaushhiQu6BFEMF11TYGDNYi3S8572Er1SnOc2LLCku5M0e9Y2+7CPVceuurYgjgLZyHYZG8ywksF/P4BemzYlp3Qx0x/Lw9zGsd5XufiHDfJkIt6eevn3vDdwvgo2anSPb3sBocLfq5Qy5tdAyAg1fx85lRMP4Ulln3HzTjNcbo0jkA8HVsRR5gLkfexUeOr3JZTto/vzLJ9OLqsbCZ0TxkyMLzXAV36/jBQCRHMiTAXWdxD9H2fCLc5gEJa4UR5HwMN83i+A/6d4jmeWSfFtMVkzta2C8IxyN73X6J9oVzF8vkV6QchvJDG/yTp+SZqVvnNjh2xKqFTaI2puT++hwfzMs2bk2zXvxs9m49sw72XRyWrk3pwVPnh1TU2yYgppipcvAEEjlNK7YLVcoLPqRqGnxWrFnf/MRqeUUrM31nPSDCc28L4/jOLrWdN4pXyzw7TcKKCnuSgIV/W6r824pX8l3wc22/UsRepENEfHQ0/s4n7wVh2sgkToR9ftj7/O/APKjUCAcQAAA")}, + {"frag", GzipedString("H4sIAAAAAAAACn1STUsDMRC991fMcVdE2iKCLB50RREEhYpXme6m7egmWfKxWsX/bpIltsXEUzbz5r19M3mTXrGGNEkBnLVkeQ+rTqKpJh1upTWFZgYuYHoMSxItibW/lGAFraTiUNe3nVxiB1+TDa03PQAMrDmFpnkxxFk1iaKxqhvFmFjQZwITaGhgI/b9n4HZvoEaOVO4Z4CjCXLufCb2XuWAOzEksUclX7NAjuQFs8QIHpDj1E3w/yh1dlkNdoltsY9eaqsSCEcS92SuSWWxWnYygSJfEhNm8bbNYrdKWtH+hVdynRF1yBXqhE8HXLYJKcFQ3WBCafB7lMqEeIRiXd8oXD9Y01sDxdjnXZQuD4oZq8R4d4yYp042Lmcu7yHIJLz6HOxQJRpmseE0yhyEcnYQyrNdKjXyvmNqfg1+30/sw4SHypPPd1w/UC2FNiiMdmOEvxsS8c3i6Ni2UJSxwdlzMvOTKRyNVt35S/Lfo4diz8+xG7qs4pr2N1k4hTK7Mlf5fZHRbPA1SGrDuN7UAeZozmxRVvD9AxS/z11vBAAA")} +}}, +{{ + {"vert", GzipedString("H4sIAAAAAAAACn1VS2/iMBC+51d4tRdoWcRrT1EPNNAKiaoISjlGJnGodx0bOU54rPjvO4kxNcXpiWS+mW++eWTwtpJENKOCo5TENE+3KGECK99j+CBy1ciIQg+o20JrymPKN/DSaaKc00TIFAWCZwpzlaF/XkGiAUox5W+UgWP4miQQ7Gt7InFKACBhQdiU8EWEGTljmfXMRUzmQmEFinzv9EVGp05G8MzEGjNQ8UE3H1uEUMUWRaGiKXCb2ow1iyQBEfTowDgkL4jGvhXQtQUEUJ/EloAUq4oOft8p2fl1wIQXTmwmxZ9aoC6oJKwNNOBVsKk6qvTPRFbbLD2lryDZb0WWSwdSrsKUqhGVtVggmHCgOF1TwtXi76EWe5Yi5/EtnIhNDSkgjzhz6ARgGDuoOMHyCTuYirKPQqrb9ejV7udURNZ6WkNZCcliv8Y+eTOIyc3gTQH/C94u32cYvipbBYMs5Zejs4MFWdp7KC9cnt0bT8ike+ikpbz06SMcwuSp/lCdrNpxAI6K7AMhZOxy7NmMxrHr8uy7PHsuz4Gd/FzLT5rAHMLRfLgKV5P5OHyaD1/GbkFlP6o8xSOWhwj2TdIIKAjMNtGHqsiqJW40L0OtzNASoCgfG5/9aUE3zvcNrp+IqDp8Ol1Kbu8PxxY0WEv9AVqXi3G4ep1PR+FiNgzGnia39gPdlQlL6gvrNWqAi/bquINZKn2eIcLS0N6jX6jT/t2EUMt6qMT3EdyI5RYiOOw0ZnAgG5EUWdYADaV4iLUPia7HKCjfmlCb8b1/ONPdWWr8qxLNvTJV5gVAlqzjDpCbPxxgR/cO83Hn+161CxXL91thz/0qae/SSUlULrlWdvIKQWNkFgJtWDg7z74ctFkVH53+A5WHV0pwBwAA")}, + {"frag", GzipedString("H4sIAAAAAAAACn1T0WrbMBR9z1cI9iKPUBKvb2YPqdOUwsZKWtbHcCPLiTZbMpLsNRv9913JVeowaQbj+B6d63PPPZl1mjNhhJKk5ZXo247UjQJbzBo4qd5Swy35TBZzsheyEvLgXjLSS1Er3ZKyvGvUHhryZ3YUh2NHCBk4uyaM7axoeTELTUPVMM25fBS/I5gEKwY+Yq//E7CcCiih5RomAlqwvh0+vwv+q0gB93KIYg9a/UgCKZJrmCQG8IIcpmZe/4MySbMYNBG3+EunTK8jSAtCfhF2LXQSK1WjIii0e8Glffx5SmJ3WvWy+heu1SHRFJEbMBGdCKyqSCvJQW8g0mlwPiptfTx8sSw3Gg7fetv1ltDxnFORYR40t72W4zsyQp4axTBnmHcfZCFd95z0QxE5sAwHrkObD6LGj+7W29Xz7vl+e7vbbFdfbyPUPFA/keEG9Imhd1ow7MAxxvVlupfTdOfv6TbQdg3X+Zq4vT3xF+sXnuZO/hnOmFJJY0Fag3b4KayQYffBQqgqQrNwAMd0Eq4W5OM4Mj7PJPd71EAneuZoXpZ0BqsU5Ik23JinI0g6dWPuDaKLq0We4YUixu87KVidk+X5ztwK37x72+x0+RSJWXLLWDmHaPTFWzAoUXln3fwXGNLQF5oV5PUvzYb6pyIFAAA=")} +}}, +{{ + {"vert", GzipedString("H4sIAAAAAAAACrUZa0/b2PJ7fsVZVaocSFLbsPeuFFGpS+kKCQoLtPtShUww1Pc6drCdxHaX/77zOM/ETrv3IfGw58x75syZOR4siniWlEmeic/J4+eFeEjzqJoOVvHsUDwtoyouMlh8V+TzN3VSCg8WDkSNzyN6bMxji4/DL4N5VB2IuTgS+OAxLqMxxnRAQkRVRLMY0f7wP8GP2Ien4BP80FP4CX4sRaaD5EF4TPNa+JOh+CL5lMDDn3wvXonyqagkyr4IJj6IQtLJmjBCQpGgGkAeSQF5Y5YcfhqKPY3RMIaPcMIIUUsbo2WMgLQfsx2BwngWcVrGApX2lIWvlYVD8fKlcMBk7tA1Kpz4yAuNAmPIK76WFWjNmdQytcsu13JyRpepgQ6D7xC1tjP2jTNebZiq9DImfc0iY4exrcuirThsxXKH+s22zSZ4xqJgw6KvqB5qlTbCsqH6VoJ0qd7hVzs23XpqS4xxz1LnNM4ALoXsqYd9IZnuqQcJaRWkVZC1gqx56yFDtfGYeTBRew7eh5ZFWirALTO0aANuFbh1wGsFXivw86CIq2WRyVrw3FWhTpZpXMgSFWWPaTxUAUSlCAJavYJQqhLUaHjjwFsNbx14iYzKJPNqXcVmCJrlpQUqG4nVGKxGYhlQ2Uqs1mC1EgtB2kCA4bPn2y4u0b0zdOYMIzbD1xJfy9byuAETliHSWK3CkmBI09IisuIxsyXaWMhrIzhQ+Q+x/BdJjYG5uqGogDkjQdFZmMiEGGrOzEmt48JQys5Jo6PCUMrQSaugdS057AEzDWw0sDHAVgNbDWwaKcrGbFoNNJhtK8XbwDVLXzvS140GGp7rVgORXHoMPeUNYCeNhdegvW07HKH6+0AwQpXHwG4k/NEAgGMCMnZdK+wGPbKuGYmeGwKOCWhhN82QkBYTgC8mDf5BfoOhHTSO2PVGyCr5v3Q21RNykh4cCemgkVizqVM7yKiAG2A00g0uKu8GtiOsHUHtCGlHQDvC2RHMjlB2BHLtEHJdMPnLFcBkLu/1SeuG3XPDTo0DuNOT0TfvnATqHQLoyVwgEDjec1NCg2VmqHei5AQhUMsoY4XSupwgXRQYKCsMdYVhrihphk4VPl+mVbJIG5k1EWXLobiDbLFaOF2+ItqFd7Ab9uF5Tc81PTf0jEpFtNXu0Iu6oKl1m66h51byGGvedolT6zZdS8+15DHWvGur6CnctcW3tnAbS8/tMrjKk3tR5BUcUh/jGe6rn7Gee0mWLyveTivpqCe9rRJTUVayLjb0jD7h8rMymZU0FjbXy1ZSjmWtW5lambQWNtfRWlKOtRydxQl6YKxQagulsVQB5iuKaUJ9Brk4QQljLutJw8+oftLyc4M0qDktujRohMJDmcR2/MRyUH9adGnQFIWHuimZtczRAxmF0+wsn0Xp9QJHBG4UFnkpKxtPKsIaa4SZa6ww0cMqidc/8+G8PSbJoUdxUWMPEYIiFp3aNp7iNwIRkEebOeORmpJ2qBMNoLJyHxC7m/wcZy6pqvjCts99biEO8KDxwT3cy3Iw2WEKwq5tRwMFqCXKvkZZd6O0FhdGadhkkB9o+ZtsN2mAratiLf/uULGR4E0Vay0/7JG/TdNss91Usf66io2235T7A2/uj8AV8Bua0okLNzlFmMdmiK4eO6qCh2gzH8OznpDhWc7IjP20htyBEv0EFfqpVeMytey+4XmNBxGPyXJGBl1Bb73ns9U1tfY+NL7XUAn17LxHrzywsB48/LAePPciNSA1CilUkw8bEdpIrULy1QTIXH0LyRmitSNeG0cMX77cWtgcpbXJcm7T6GPLoWOL9Bs88lUX1K7bGotGh9LfoGldt+13uc2etbXytt27zLZNtV3w98zeFdT6W+xsXN/YZgdWmneYvcO20ArGVni/2bYduWhs2xEeJ/X7jHlqHQfo0ZamPLOF4XdNlSKNGugXvDLGUwMKyF2S3SfZIzIZimWWPOTFXBznWVlFWVWKL6q0JNlNkgLi7cXDAxDLA+ihiOYxLMS3qzg9i7NrOBBjuVZaz1l+H1/hOQQHG2gxddXw+9Q4/inN76IUtOALRcEH52x2WyVz4D2P75PlfKGh5ayIQYmk7VjLQPgq5rWdCgS2AsdgXxFZCtBgA+zg/0c4Zqd9C6fZqnPtssj/1bvQR4QMewnVokOsrJ6R/pd4tPc4i6O0uRjX0A4si44VTIWzpHqbFL1rx3mad6xG87skzqrrfze9az8V+TK7315+yB97mMLKj1HZoScsvLnvYJXFUfEu6uCEXdNlXlTb6RH25id1gDo7rKD8khfp/bQHfnqjVpTsFN4q4H8eLT58vIxgV9lapCAFdw5Lx3bf0j0Uy1UXZrCFCZLYhzRKzPL5Yol9YVFBelhzxKFuY0P4U1S84VXPqib3wQs4No6Pb69O3r89ubo9v3h7Io5AP/Hnnx3gg8GIvbDirTF4EYM/H3qYBAMpJW7igRQM9SWfJVUD71x3FYASWEPTOHusPruw+jS7j2slEg+1Ht25w0MVqalH16hmzziCWrQS51cLRldXOM76E9Uows77FagzSJQoharjMR+2n0+VkXIHHw/mlS9uLU6/7eQUuJwCl1PgcPp9J6fQ5RS6nELiBNkxqfEy4KhjEPIc743IC/T3N/r7O48kL+K0J/BKzSvcEI6qsyIvS08JH2NujHQSIIzvF3BMU0w+LCh8BgVnTDtt4Ei1fWHxEnt2KnF0HdM9reSeiO5KJ0FIkeQxs4F4/TGWSu3JlOx3RPj/SEWiDvD+RfgbuUVLPi2Ng/8qxhQlAxnuDvjB/8rO7SF3Q8mn3fvSHKVqa1qQYAvSuUGVEwPLvzkpizfeKHbPtZSuNIh4c8HNtVy2XC+wb+UFBNsOYvxmA9xMVdWjETFURf/DR+FxbaQGjpLRqvj2u+7w+LIiFFGWADlZG6K1wCcvPMMHbNE0mPXTAVHQrc5O3A1KvAwjwsbFwmzazqXvjsThQOtO10F0+WiBtC9kh+xJvfA+QqPhtzCyzJI4cgyymmj3XE4yPrSiWwhFwp1u57FsEKu4PgaP3Hchhl2IQRfmQRdm2IV5qDAPAVM2A31H8Db1D7Ycog6muw/yww4u/+jS9qBL23/amLxfu9B+2DLKqEXQdLEqqTUVnr7Gwo3Apf2IBxV5PDiuVs2Q+mhmIstX1n2ucxoWQ8y6oSAuEJbrvgM2H65Pbn+5uDp7e3t9+eb4ZMCCrbYR1KM7un6xWqJLpRaMSCP56uLmzc3pxfvbi4/A7Ob0/AQ5fjg7uT15/+bHsxN943kzx9PUSTAuIfNl+i6aVXnBUzBfFjEB7OnXIvDpJsuffI/e1wvjI1qBPtyiHxODZ327qZzHVCO6fqJiTxfqhtL6mD5GOiom/J/fG/neyPdWvrdDVVb7isrOXhFY8IfiDc98pcGxyPjQmGg1etbR9JEtQ2puspy91fER21PcbBm78C0pw66U6S69dLoUWVxcqCOP6qjFbUIfmjAPevdO7/jgTit8g22Lo/vskdnWI3cU39lz/ke89WDN+1ltsVH3lQh+5OpeWNtR5dONFA3/tlomVlRoKCVVjaew06Uw0JzrLwbyih9gQEzLeFGztW7f3vD2YxSFvCe50hJfM6uLaF5g7oeixrH5fa4Kr/1R3yNjZNPj4DOi/JDsoLnGc71kkj1Vc/UBwxVbXkbhUaJwlTqahJe5RG94kg6IjSNmucJ6q/oqO91bN7S9uVHTB9StKzbuTLbB7XrqnA3q/kcdD+7nHJr1kQmefeIxvb2URxjQ64PRG07F81/Tu6A7vycAAA==")}, + {"frag", GzipedString("H4sIAAAAAAAACn2SzU7DMBCE732KPSYIobbiFnGAVCAkJJCKuKJt4rYLsR35JxQQ747tyJAKm5Njj3fy7XpmvWINaZICOGvJ8h62nURTzTp8l9YUmhm4gPkpbEi0JHZ+U4IVtJWKQ13fdHKDHXzO9rTb9wAwsOYcmubZEGfVLJrGU90oxsSaPhKaQEMDG7Wv/wAWU4AaOVM4AeBogp1bn4i9VTnhVgxJ7UHJl6yQK/KG2cIoHhXHrpvA/yB1dlgNdolpsUMvtVUJhSOJOzIrUlmtlp1MqMg3xIRZv75ntRslrWj/ylu5y5g65Qp1gtMJl23CSjBU15hwGvwcpTIhHuGwrq8V7u6t6a2BYrznKUqXB8WMVWLcu4qYp042Lmcu7yHIJLz7EuxQJS4s4oXzaHMUysU0lMvfUGrkfcfUcgV+3I/sYMI75Wsngfb91FJog8Jo10X4uSERnyx2jm0LRRkvODqPcDaHk5HUrT9F/ntkKCY8p67nsopTmg6ycA5ldmLu5OdBRtjANUhqQ7se6khzZQ62KCv4+gaiPIQfbgQAAA==")} +}}, +{{ + {"vert", GzipedString("H4sIAAAAAAAACn1TTU/jMBC951eMtJcWcYDALdoDhA8hBbXa8nGM3MQpA/6IHCcLrPrf147rEsDmlHjem5k3b+ykVbTCDqWAJ9w8tdAwSXSWMPImez3rqIbfcHQIaxQ1io09zKEX2EjFIc+vmVwTBv8Slwww0OoUqqrUyGmWcFpjz9t9tKsUpWKF7wFMEI0Dddj2JwHHUwE54VSRiQBO9FjOfB+Q/s1iwI0YgthSyecoEEuyBaOJHvyU7KeuRv1L2UXNqggLuEVfW9n1KoBwgqJAfYEqiuWSyQBK+Bqp0KuXtyh2rWQv6u9wIzeRogY5J11ApwHO6kApQYm6IoFKg/VRKj1ej1/YwP3qsiwW+Vnx+bKk0dtayGpyWScrepSK1VkkfnPnEa+EmZM29W9Je/+wJIpwp4maro0Xw0wzbd/VKAKFzT4BUpq9oY1nAeKxJ6aGqOlrLqWqQ8TUE08NsXLOB/uaiKMNTnWk646WQj8cOXPvHhdlvigWfy4vAikn3/qnEZkTATVRL3uXXIwqDbO5Wcl4NNaYJPs7+/Dp0Oj7um9HnOwIDmzyvvgU98/PU8yEBpvau7NmjO68/OqAE//BSPetFNW9Eq70Nhkk1mBfmR0KNqxc7qYY51J6Ns9g+x+QfZPBdAUAAA==")}, + {"frag", GzipedString("H4sIAAAAAAAACo1STW+CQBC98ysm6WVRa4T0Rj0QtenBxKbS9EhWWGDTlSXLR2wa/3tnEQGVNiYc2Jn35s2+t0amWMBzLlNIeJxkEAlJC8d44BF8bFe+u357dX1vtfUMQb9lWZCcFTAHawI7noY8jfEwM6FMeSTVHjq8v3Q9F36MeiBQkSXUSxTLEylCxziiBEN+ZFSShz0aEJ5CxYInCKSQysQJA7tghdT9KYXnq+EmhDwPqApbieOgSG+xf1Tq/l0ajT9CBrTQfta+nC9T+QLtbYz1Pjf+YrPevK+WAyy7zwqp+mo1brHWGWtDWc2cy4zsfkaW1YWU030mmLKXEAR+nileMI8dilIxx6h1I0VjINqV+iiRr38Ipt585u1NamjBDgudyyCjbY7mGqgFyfUGE30RxEpMdt6Ow8Po7OGU6q6Kd9gnpId4BGuKlo8a27Ay1hWstyBk9QB6xvii2VPBkzZe5MyQdy2sQV3Mp8S6x0QkYhRDRgrS+eu5YKV5/IH/giHUizmn57unPNWZXPSQpsMipgPHX4vyj0LMAwAA")} +}}, +{{ + {"vert", GzipedString("H4sIAAAAAAAACqVXbW/qNhT+zq+w1C/JRrMkgDQtu3fqKFwhlZZB21WariITDPUWEuqY16n/fcd2HBySVJX2pcXnPOf9xU5rw0hEM5om6JWuXjdoGaeYB62Ms23E0WzDKCfPhHFyuMUco39bOxJ10SbNKAehQB2jNE5Z0Hq/kBsyvFqThJ8lfbTdSVyMj+mWWxnh6Aty22hOkwVNVuJgo21Clylbo37/W5zOcQyyyjmElLko5HRNgtaaLOh2vSmoWcQISWb0VMNLMKc7ongfOuCZDvTxmjBsOLDGXKqD/8+U7IMmxijZ1fImLP27kdEkJBQ2CmpmSVhHHUn/J2nWmKwIxzXZIgco8ZbVcNaYJneU31LWyOurdrjk4vWcQjfM/jk28r6xdJssquxlumpQCpzfcVbjJzBuFjWqEoLZENdo2ok8poyb7RGnERZ9rvqSJgLcQTg8938V6GmgD0CYm36askUd0JdAOXCAnGMevYa0Fgm2gaJ07sLtzm2wK0BKn0CN0wVpsJtr60qcmImH5RJGoQ7duUBPMMPrrNaDbi3Uq90mo4QTluDY3Cos5bjYKh3EGU6y2KRkqlkluOy3ilrHnAOUfc1c0jjmx03N+Pvm+PfM8X8a3UF4sXYQukSEG4cL8Povq98PbwfPo/4gHN+8hM+D6ePgJXy6Hw0fpmM49h8fpjN0DWrCwXAIx/BpNrhtwNnoJ9RDP6Ded+mfDPeZRDxljyINwp8/thCFJTm7tsrymw2uMcK3DDoO/Yh8xwUdEUuzzHpzDsdTu3zY2QB6c/YA2tlgqLVL6QIcVJUZJRvIiShhZe9T19ZJELG7kKhyMmjCrXMT23kkhYD3GQHwzTOF/E8K+aZQ55NCHVOo+0mh7nfdTUz0ikyFsy9oQIJfKbPYytbEOc6BvnMqaAVwjgHYOBcUZod6jp6LXJEiGtNReAI1ljw5J0AVvWIp24djG3mOa0u+OTu5cEcy9IwI/xiOeC68F/F7ruPm0mLKiqj2OVFNW07uAtF19JpUrnStmoa2zssUbGjf28gIW/RsOeAiFNeRTw+tn4EKC1gwS36vB5C2qNM1YjDgVRZU5hrN7UA/TP6k/HVarCC6RNZFqpwD+hVBFsQoVFlfEJ5nVRHQX1atnPWlM9fGFeFAhYyTEHxHJM4IWKtoMG+W97OvsjBfYWkrJ+VdAejL2MpbHwAXXitEvul1co0iy24y2qWNZDWUF0UPgR/+2Y/8MtDG9G7OQ6yR9S5lC09U5gyGo5r7gnhol46nvdx4ZYPnlPkfpUy1phG+yhAYRtd6VEzA0f5Mkptc8f539eQbvUhaxT+7BPGKbWRCxKC43Z/FzNeUYKNzDJnPtcBvO7godQl72p+xqhi6vT9OujlNR7ULSsTTXt5kYbGXimQGrStI7uxmPLkbhMPpwzicPhbGzNcx3IhfZQf9pmZTFfdgdhXU2ka/6OfXFYH3whLMVl9BvdIrKP80UifY8MgSpa3er0GrfAtTmUu93ahj6oGFKWnnV6gIEx4X4WT0MrgLb+5G3+7Hg/vHlkKevxMgpRvxLQB/xGVRFD4/20FJQnxVaIkrUaqKvjJCpiR/jUhS/r4QnwUibLSKw4l5JTBu2QF6/w+H5mrjhQ4AAA==")}, + {"frag", GzipedString("H4sIAAAAAAAACqVW227bOBB911cQKFBIiaJKctJmobZAGrvdAi1axEkvTwYj0w5R3ZaiXTuL/PvODCnrErUPW7/ImjlzODwzHMqplEhlLcuC3cn1XcVWWcl14tRabVLN5pWSWnwRSovdlGvO/nW2Ij1lVVlLDUGJeU3LrFSJ8zCIe6v4OheFbiNjttkSjsIuL+c8rzLxVeq7i6y643NRccW1WLo1OVQ8ZbCyz2yoByxP5AoCFzfz2WL28c1sOp1NFxcfPv994SihN6pA7KkLUfAiXIqGwECtb302sLJjInbDIPRZGJx5APMS54nIatGwDYnQXSzlynlwMr4vN9rNypSjFuwVCz0mC5PsdrHZhskIJiIMyUygj+VSjOHihuuUYHN5Lz6tVrXQY+BJH/wZVMzr0eVPx5BRYoojtjybZzIVy5svbkdzU/MQwnO5c0lg0Mzzu4v5rNaicjuWYLff7VE0+uOBdAcKZn5V2KWIHlFEjylMKlE3lWiQSsNjo3quNpVokEo0tpsRirCbSsx+AI1bRcH9T3YC+4Gnx56RZbc3FgBb7K3FgufIYBsEvke/irWd+ANA1LO3cIIc00BYsLcyy7oF821z5dBYWDzzxvF8YfsF0BZwhFx0s9fQZ6DeAVVrrjSgeool1ql4sRYD595ubSkVeCC9k577/mcTDLEZBp/ALChcgAegKj52HuwrDCbR+ST86/z8OTzPTYZmvZcsNBkahmNTNTqyJ3HQFIoS980qWJtmu60ThCPCBgQiMjzoo8wtMfl8I8wj4q6z4Ufihrqrc2R2gSboqj2aek3Fnj5l5HjZd+xp793qtXlba0jW1m7X2P1qjd0frNF0I9nRsi3lEic5Tfz3RQXjBkbO2A0gm/GNs/t69u365moGubrNFMR0J1alAFrJ5BhCe/QHIJ6O46ENO62jepcz7nGuFE81+UPvj6mjHnV/fP6/Ffp7R4EP901zZ5Ky5ub8zT1J6BKIfnPLtpfacGO2DmXA2dGrwZjBxPoT8Z6a3nZGmZhcJ2x+9e7NdflBFoIr5pJpzfOcI7MF0zuIRM9k9FI9695Y9ktj2EU2CrTEm9NntxI0K9bYzXDfbgq5KlXOWrHSdFGTjNfmej/c6rQMtMiauZjlWBcnTr/bpfc4n/ariCpp/h0NizfMwmdY+8MXyBjJIVFc8f188e7q4rtDHvzCAVxXc/fgAM4uCEvhLkvdAnxjC4M4ip/jx9CL6CzGZ/gijj1vEF//o3SP3CZli9p8Do5/IeF0MFtLF6jspUHTHMm5LFD4ns8c2rXrJezhP525S7SwCgAA")} +}}, +{{ + {"vert", GzipedString("H4sIAAAAAAAACn1UUW/aMBB+z684aS9hYhGwPi3aJpZRhBTaqNBub5FJDPXm2MhxUujEf5/tJG2y2nsBfN93d5+/8+EdBc5ISTiDR3J4PMKeciRDj6Izr6RfYgmfYTKGHWE5YQd9GEHFyJ6LAqJoSfkOUfjjNckANc6uIMtSSQocegXOSVUcX6JlJjBmG/JswRiSpMYNdvmfgGlfQIQKLFBPQIGkKae+Hwh+Cl3AitVWLBH8lxNwJemCzsQOHCR3t86M/oSXTrMyRC1u4dORl5WwIAUiLCbyOxFOLOKUW1BU7AhmcvP77MSWglcsfwvv+cFRVCHfUGnRqYB5binFMBLXyFKp1j5yIc3zeEf2cL9ZpPFtNI+Hj2XmfK0xz3qPtTeiH1zQPHTEV9sO6ZRQdZKq/hod7x8SJFDRaMKq695I28zXSbxIr+9u1+ndtkNamVTJkHrjjDzCdN2PgFI1UaLjoYU47YgzRZT4FHEuchtx1hGvFDFrZmLtqyLthVyk6QtpBlU9CT1Dr7GQ4I+UjeaoRCuq/um/3mCscv+dUUPs+QrvdfLANs1OVj8XcTqPV8ub9eJmO8jTq9SlqY/gdH5WmPrL4sJvz6NwkKEX77URLfGbekOGkaIuqyh9ny0zbUj9FQ6e4AtMgwl8NZ75ihGcxibyQRsYnEfwqXGybWSsN63aIQgsK8EaMRev5iQHvbPabjjQNGn9NY4L6Y9CuPwFqnxoEMIFAAA=")}, + {"frag", GzipedString("H4sIAAAAAAAACo1STY+bMBC9+1eMtBezjRCg3e6BzYEG2q7UStXCqu0JOWDAEsHIOFFXVf57xw4JCfuhShHReOa9mXnzSK94IQYhO2hE3fRQtZLpkOx4cQOrVco2fct/Ct1Ebd+wlPdMMc1LOtiECmLQ/M8CsDyA7c6Bv+RKVAjMn9IkT75/SuI4ifPo24+vEVFcb1Vnam8oojDg1KIR6Kp6vYDZK3ywxNRzvQV47q2DZU5Irng78CPbnMiku1JUZG8nMWPY7nmWpBlp2bPcajpwDUvwF7AWWNvVGHgObDtRSbWBqT6PoyzCnawowIwEWaP40Mi2DMn+1GsnRXkGAyoOa0IhW6mOqsxmwRdq8y6D+xm5A6UYCqbKs3Vea3I22DtdbP6/eoz6tLJg2njC6nKxTHhqkiW/sqfH5BWMf8QYT3jhperBueq+P8k+Waoo8qFXQvPscNxJZzNGpVgN1KxrQ4k01lJ4zvHnvBxSwvXyPT/PWxoveSPPQ5p/eYx+jy6oFXsGI4wb+MFHuAbpKjSq5975t4ENaxt6d8EhXIfElCxtxnzX+DUsp7XGPzvjKPJ0QSpxjNHsMnzrRvgyHqnIP6NAqwON9cyGic7odZFDmBGSOiHs/wGIo6EnBQQAAA==")} +}}, +{{ + {"vert", GzipedString("H4sIAAAAAAAACuVbbXPaSBL+zq9Qauu2hI1ZBHbiLHt3RQA73GKgADt7lXKpZBhsZYVEJIHBu/7v1z0v0ow0IjjJ7Zf94qDpnqdfpmeme2byA9nGxI/cwDcu+3b3t6kdPThzEtpku/LcmRvbTujGD0sSuzM73q1IZLt+3Kj/bITk89oNSWkVkplLAR7c+4eVsfACJ26WpA9jTmbBnDTqhslaN2R2aoT3d07Z+KOE/xr/pJ/GkVE/O6vW1N4T994HBqtaM04MM4rJyrTq59VaxTCx08fGbdk4NmrVs3IZAbLdu9tV4BM/BgigAYe5DOYmpZlgipkDqRgUvowNGnF1SdwJsL7JCrxy/NiNIjRKK6quE3VkvD47a7wGBY+pKz5at9QbUkvtFn6dN87PX9fOUWZI4nXoM/ccGTBedTOx9cSoNwAX2oU2zdJzKYrD9QwcGjv+3AnnNySMe/5qHcMoSAOzCiI3hvFsluCzYfhBuHQ8+nFqQM97wAewZslzdsE6Nr1g5iA7mAsCXd+gvRw7hckzWjKjEJBnqwu2OrDFZNsOgnCuY2wIxlNkFDr+4C6Mdtu+nnTtq+F49L4EY2DckxjtJtve3KThx7x479m82Z+TLTqLS4kIjZyKcef6c9e/h4/TsrH23QWoDfBXQbh6ABwqfDaz52608pwZWYIKHwh4NY4+Wme3TS3DFGbfOiQ9fxFQl1JTQcORuyVen9tn0taYsY5JFHhrbK4YaM4KOanOaAwLwLTtArRl4SfxNTnbFogYnxJ7JS+mmnbYMbQglLsYPxX04Y5F5c1txdiV0amKgXQ4L8JgqVoqxrVi6A2XRo12SAKhCmKS3zucZDDHdPqhJjw4Ot2bXrtrT65Ho+F4al/0h62pPYV18HrcZUO2IPHs4QZCtRWGzg7V5aNmRs5y5ZGw3kEJuuFwhQET94mA87gi+GXSLrXUT/BNvAuUxUi0r+Ro4x8CCM2U2n9K28sMEYwjXkS+Qn3i0bBMDVBMAgtkBlhcTnnISlMxF73FIV/d7mRLyhxsK6HkQyQRdcxCq4YrM/wB2/dKEui7F6FbL0R/ehF6/XD0dDadmiWxn5o8oFjEbGE/KSDtiklPSAIzSzxwYJFb8PkOhnRyqxluZBArUoB8Xge4RLo8GiEmsDUkSwebwoR0wjhp1MDkMyUOunUks7pgFcXet1Vcmw0MbyOHYR2KsSvGqB+K8ZRgHMb/iO59Zlsq3YNmDdm5X5iYm3RvQgX54kV3NXs07raHV6PrabcjNCme9BRRRqtCbtFMF4wGDFy09nBA8cvEAGWrCqrh4x7pzkhEBzXeN7efcNsIQoPFy9QJ7+lGWmsmH7+kJkxb48vu1G4PrwfTpnF8zFnYWFB1jiGZ+oJVqXJHiYzjnK1ALIhrLpPOA+5HJrwppsWz6niu9fvWxB4NJ71pbzjYkzW8SbOGdIDBgSOeJ8kqRc0kUHRkUwqJuZzE7I+rImGVFEtaA4pMHQzHV63+HkPPCwwd0DyvwMw88euN1Ah6mYnT1uCyO5jusfFtgY1TlnsWGKmhfr2VOlF6MzeBOzec1crbsWQVZIJZmjLAieNQrOoCiG1oacrc/PIcQJiqSP9h+8JNMd92XBjdkg2HxSIFZ2WELE5qOS6IscNFiZigyLzEkIXJTcdFg50X91w0OkopllvzdW7PePxAZyuDK+ul+gOLqMmvvcGgN7jUFGCntABbN+q8BvsUuDTy85xncqn2yLZIpVR71/q127Fbg95Vi5qFJGzvDSYwBm29/DcUVSpiuQot312y6oqbUzylG3JVN/nd9X1o5/NNLZBh8lHwbPVWjF3XYaNuTH8teqr6XujXKTQDUdYjWU+xy7/QBXrtoo8NPEtp3FL18rGiG8UvlVvgjVOM0/+ggCsnDt2twU5PDFfMgEwkyOcun9ACdsKTGf0q1irZth1MCheLxCzhSTiqADw7QBRdExOpBB3xKfGaLMb1N7xW1PV5VA+a0nr8E6Y8rGtZ5dlKPCfQQ68p1l6IZu74yVSKxw8uNlZav5oZCFaom+Y215lWHgKhfhiCVYzQOAyhrkPg+yrGmEmrqI2FK6Oov1hTPd/UyDdZ1Uf4Wad/G/jXwiO8tO7+DnFs1f+fgSzQ/76RXFBHvyywdTX1ywL7hQiawH4hQkODUFJm6Ms9c/rNWp19M8Lrb0Z4s9czja/yzPk3a/X226PuOwSuLnJLf92aynKLg5ZWetgw3/LjCbcsz/k0dUEOlrukcZ+jouG38vjrOOq3f60XqP0RZGbC9rK4emCqiTAVGXg6SKrTTEaG5ZJuKDwPr25LxwWMO5VxV8j4pDI+FTI+qoz0fIzWQiz1LKyDqAuWYGjqBqxKBQteagBwevukRS2ufQvglfqVy1DamnIVSq/+gIONRdrORruMA9/UVZKZThJR6fmsrWZqcipfk1P5Sy+4A6VEIm8kqXzsLmFbXJK5u16mCX40Cwnx2ZaZpflQsWwIo2XrEkUBS1ag7SxJ6EgKUC8DHPx745IkG8gRev5GSxuFwadCQlEnBCzsKIhKZ2H1jOoP9XOhs2aOp/EW2UJ40NIrS8Ej574bd9ywkNYOvEBDdZZ3LgTF5PddIe0yDNb+PE9eBPcFoEB550QaPYHQmmugfOKEF44GaYN+DEJ2RXxQ7X4unwjASHwIQm9e050dvNVxWtoL5pqOtZ5q1O9dvp9etUa6vpbc18PlCUL6ylld34yc0Fk2pS2Jo71rTdvv9dZZ7BKb7VGOPd/59p0Tzx5sd76vrFfmL14gee+wF5knk0iKXWpc9NGqiWp8f5mfxy4EbRa096bNzKmAzk/P+mMXq0iZwI9gyYNdjO9psesB03CxgH58J3a8OzIPlA8691r+vL2Og8WCk1Z3IVUi4t9k6UYRrFyZT9o31ZaNUt+l0R3cm2LzSXZZCO2Ina0JZlga8A4EGuEvaD+jqVSyYFRol+QKHaYTbD1hzNIJPuvwTishd/25StwlW/jMc5Yr0+RMJ0I0XnGnjUIC3gVXMYGg6UPyFOZAq3DaxzHxE1VgEcBC71ArOvimKN6pDE95ny2drbnPb5JBbAcEWxPdjqD0SGTi5fR2ZZ4I7CNJjTQLWijOmHxeOyGZ/418ovPOl13Vd3bke/nJBpRpsFKIW5k4xqRHIe/4DQooTxcf3KYZQ+IalhfJDFV0dK3Kuz7S5iDiXR+TLjIh6cLt6BAvdjryzJa5K4o+mUGgr9BkmP9W8Ad1cc+PyX2IL57w9lmxYmf8SziIVjNAf2Ttv8jtHBITRuHOE2bTDvVIvSgUyUjGkxQOcST9gkpRutROhVCX5CGw+TnlL1RW8kJLVVm1Pa+66sJ3h9nblDR37iJTSD4RMGWtNcia8B4Z6S9aP58YplDiyEh/0Ud8Wp8h3IsM1WtUMExl9pgg8Q7tyuJJ8L3CAeLBItYdM/ocxvimBV82miK+fxLYWJBpWsv0eWI+emWrhQQWE5nlZ6FfW3hZZk/HrcHkoju2L4aXkElNuskiUzGwVuNoziwOwnLpD/mWAXrQxyMlRgWB6d69otsuy9FUditl5ztiMW9d4ZU2jOIuDUmbdOFM+CE1S+gWzk7lccErjtVqt6/HrSkF1b+0TF2zwYXSZqBN5dI3411l9S6Uph0SOhqyIPmqUPvAE/WTUsQNfVgcPNIiqrhsVG/KaA9dctrHbHPkOT6RC7osg1xa6mhy36SeozKhCkRih6ziB3YJp+M6kIVRveBxZWSog4v+pJj64f3oXTG1PxoMiqm8zntOrlbH3Xa3d9O1J+9bneGHPSPQ2HuhyNAhyd83iGf7IVYBGwJWLSi3hxiMN93xtPub3R72h2NdaCmPfWfMTu3b4eT4aCPY1GpEfUDMuRvAve/p8qnCWfx2+SzhqwPfeqPjeZ3hsdL6lL1ssPUV6htFh+S9s7a0lhjv3PRpdOpyfEMw6baHg459fWP8+ecXy+NT3atsKzeMAsL48UfjlVwk0waIyIvh+ENr3LFbnY6+1pdU99CBfEmTYqftzLzrG1PsCq8yZw20H+R5LFnMV6hIOpaNYJdKGsYnWEcY2lMhWHLdJonVnR/opGr5VKF6lvyDDeolPEJih8P5k84exHXPlw8z+ZGxaGHHzpQpOc5Mn+lDKw8j2lz82j5902L2/NwDG+VBCTucVdjYOSw/bqgY8sGD5lRJkGn5FJ+aJW5ScpwknbVnadYeWn0PrYYH9DKM8lkXx/d4UZJqzxTkZyuaAyTJEOVsB68z1NOj8u0+XHZXooHKdMqc6YgY4nmChApBKgUNBqYUQCtRTokVEdrYD3zqbkoS+fF2ElrSuXY5Hdnph+Gk1+my2g1PFDtuSGaxgpot/yDNTnUqS6ocQQEXxKb4rkiAZShVQL7xb+MEs+KflYRMsxQni63ePsk6/dE9VStZhtH9YRBFsmpCQJn5W8A8pkMD+wSbeHz5AEb5nIytLkoLriNozKR1NepDjjceXtnjqUBS/PgIBahFHUKv/5AF/7sB+79X9Auql5/5hla0iVBkS1HS+iYtrQPUtFQ9rVRRaWvak2jwHIFqrWYL2SSaZfJSPptMIyWxZJdQ+RPng/ZD7S6XaHTvJQ95E9lcpJneZsCXCMxydvY+/w8EdrMj+DcAAA==")}, + {"frag", GzipedString("H4sIAAAAAAAACu09a3PiyK7f8yu8tVWnTEJYIMk8TjZ7igB5VDFJCjKzM/fUFOWAyfissVnbhJDd+e9X6qfabhMmYXbn3Dv5EHC3pFar1Wqp5W62Zok/CtIgjpxPwe2nmTMJYy873Aq9ZTzP3NTPnCOnXnVugmgcRLf4UHHmUTCJk6nTbp+G8Y0XOn9scWTHufNH+85oNMyCqX+4NfXHwXw6U6XpKPH9aBA8WOoiLwvufF73eRUDDcpA25v6iUcYmHoZIwef7wJ/cVhWcR7dWeuukvg/pRVlSEiwFFFWGsiy1yPG/1Wclgpr5IUWafn3szidJ5aaqRdEvSDrBElpXTsOY0utN70J/Cgb/LYsrTtN4nk0LlZP4tsSolBz7KUWPqGiNbaQinwvOfEslO5QjnGSFdWjUaafcZRmXpSloB+MShaEAHQ5mQDeIS/ywht/HBsPTOStaNyeZ/FkIqpmN8mVl3jTVDz70yBNQWFzjwyXATI22WxyegHrVHzrclJxWpEcQY9SYHqGCsCBQSOG4wAL4T9wP/JdqidVhlKR0CDFQeYlKAUt7No9qe5GY7MSRjfxs3kSOaPQm85cVwDtyqYrzk+OLpQtVKpOvVZ1GjVo+7Mg372frdkrHO0s8yPFCox97WH9XnT8KA2ypQnwUJTZ1Lt3V8mNdAj7U8e+Kt62nf2aahOIwSRzdyXtbcJGRYlwYghj8PvcS/zx/yOZ2KTzuKh63tLflJyGQOU6nhmV97Sy70W3vlG9ZJN2D5n/NU7CMVpnDqBEU7tfQgsUoIaCrtcE6oIVx6lAXSgUWqFQRD86fph5HTqzKXTV4Cc3CM1a3STzoYpfmIjPo8y/TbzwcCuYOMYAAwO/SAGhgLF+wct/puWCJHDmSnHu8j4tkQ8tRclIrmVAlCS2ybd67QDG3PHD1DcaYSIpksDizxq+lFkihZbJstn3IuumCI/X6+8h4dy7SV3Z8q4kU7H2BkEV7Lajv4FUcMq5koltR3/DuopVZkjuizpq56hkmJhN/6ylw1C5Pkm4H3CAhLJIu+OmvyeZ26jVnR1HdraDistxKkDcUgp/vP2c9tJeyxa4TuTMz8RuW+7iYAwu4fC637oYnHT7w5PL0+Fxa9BVRqbqgNPgCGreKIuTytYfWz9CNwHt7aCLGM4RtLrFa6FBvXbP2LL7ox8WwBsaXKyI5bBNA5YsGOUoe4QbbTgVfOrr+gbOzh998IUmRCCtq6veBy2NIEIpcLcKnbaqKREYAFYM5BDGnQb3LnHxasntTZUj8q8CTZZ5TJdQpj+IbrTa7bf91jXrj3TcwngE/n4ccYctiAQLd9jMkFNUHSl0o9AD5Lm0xaIARK9pY5VVYrNIzFgEZPO21qloD7dKtVOtBOhh1StKqmqECRkcGJucSjuqaH3mi9egf3p8HXPNdlxWdOtNpx72Q0wo9gyzlH0iYnk81qTx2OCTN44XKh4jYVAPCrKr0It8GinlAWjMZqujuCpQYm1CeIWVHX+WfTqPJrEdak0QXhvGi5mTq7046Q3Ka389uzour+1dXVyU14oASkUNEF37GR8kxvFJEk9RBIOZB54DGzUeEqV6VUTHAoYk9KPb7JMrq5WZZG4gXz7M3tTumdNfLF+WQGurnGfTLUwN1k3khbmY3L3LDStomjEL0JfiM0Hx/og4CHlEVkYIJkW/2+6ev+sOB2etzuWvKzR5T2syV4wU4qPQT5odLYM33mzV5sTBahKzmPcZgBkhJprWbBYu+cRhPTsOvHR4Ar26ADJeyFcvoZtoILSAOQCuYQwmAhlIMOBFoeBC7ha0sPYAziG4+/V6Q1FAMXKij4wRB+LhAiOvMYHuz1AORCk/MCjOzhFpAAu2i7MuV0yY3RbxKm2JMVBvVFl7OORCWWjLwuyVyPnKT9KZP8K9p4KgxZoE7aWoZApJiIvPP6Z/rBn6hN0gI1DW2YdFDu3BwHqgSHkDV7sHr0vDLlbCLgvsPeBw2O0iazdiIg4exNwiiOi9FYUilHkUBjMtEvrERZIXkl0FcpgPizzmQx6RiAV6hpradEsAllptbSZPTQucGOgMGZwAI2tYIiqtfF/Qb86VsLAKLC0aPKbnpHZB1NoU7iq1vkyyTzG41bNPweiL9FpsHsT+ZNJyShVEBdgM8LgccCkBqViGTAZUzXcFIVyFeNumvg4fpPGwKl3ip/MwM00eL2PizlHalt3bEa2qNYbj5NY2LtoT5kOdecnYyclTLXE4OvB84aO2Pj4qZEAK/kNtUZF7FJwoSliRZ7P3J1qw4GEc9IjF3EyxeS1YCbTGdefPPx1d9AuqGhRtyaJlEWpZhHooQj1wKBCCI4SIMYjzWeHcL/NbKwsWMwGZf4lpqiBr92zRR3XQZRDe/pM8S4XiAmMhotoaGYVx6qcZE7isMSa5Wk6WhUluYI7jzM38e+iP79Klv0oYqVT5eggMc65/cpoHB/rhxUG9SR4bLw5eNfZeQokR4ecafrRRnHqft1Tn08yfKQE+VA0JaN+Jg6/Q60E8yb7r9Teh1zHLTkh9UOwwsTUhJpphiowaXCXb+6UAiiP/2pvx7QCQp8ARlYLikLdDmkAHTaBKXm4gTP8N/Vv8bIjPpvjcW3ducSpSWUn/qivmmSlBPQWWlWfMO1A+3pVnMCMEt3GempsRkGRvIzztbVROm2JN2c4VivXFSsVi2hXK8VTF0HTtA/zUwdV07YP0zAEyQnz0kt47DqaS4jFli1sL3DzYllZGu4bcmXqPWMG9mzcljGbFhP1AYZWZycPi04cCN0vFzZJyo5OdSFiwVJXtcdIf8rsZ+ZWx+f772vh/fW2UDiSdCMMeXR6BQ6nvJeB9A3znMfC3BHypqS9LwDsG+E4BfPViLT73xeeB+HwhPl+Kz1d/2aKuZJw3P8O3f/cSXzSJm+HpOUu80rGvw9oGVnoykpvxPva/JZfxYKNjtxmeXnyV6dfZBGsvNzv9NsLTq68y/Z7L2ma82ZXW9Pm+rd0iPt+3XWnVNubi5iyTpmu3MM+IHexW4qkWQtO1z/RnznJN3j5bnzpTNV37jHvmbLOEJl8WmPAAYt3woXy38ZkBDnHJJKxoZeeIRiuOJVyxNE08PknO0ijx/zbRqKUPlkaJk7my0fXatHTB0qZyaJ/SJtk0ZUFW8yAfIcpE7mPJAcubImvGjTQx+T1s/EtSBeIdimJ4uZEcgpn7/0szCSuatuUTxtxOf0kuwTYfbEmF7/PhG5gPY6r06yXBJUrhbR81kkQTLTNIassNDKV1g2Zh359ZsZPzdycyxvb4IT/X/ppExhOY+eqJjOcJ6OskMjYip6+cyBgX3eQvUCpLsPeFBNdOZDyd0dWJjGfz+6xEhsXkfBMpjSJfT0tulC3VxSzH98X6+2K9crH+nnH52zIuT1/IvnrGZSPr/oYzLs8Q19fOuGxkJDeccfkWfNuDjY7dhjMuG51+m824bGb6bTbjstHp95UyLk/zOtfOuDzbWS7JuDyR7XUzLs+WSknGZVNBTt5KPM9CWDIuG1MLe8bl+Wphz7hsTC2+Z1y+Z1z+royLONhKztaeH/dWnL7b16fvxLm79vzGZ/flRHdBEkdTP5IXv0wS7/aaz45ePHZcfVAP5gyfHMBfnIzleZkwHpMDsplCdRm8AEUgdTKnpAnGk2xk73mN7EGHZ97ot/7pcVeE78ntjU9o4CMe1AaxzuIFLJmgtqwMj/eyVRMPHjVfsRNRn6msO+cnJ/D5pnW1QuQvSkUOIzeZpz475ygHkn/wrp6evn8T3wSh77hixsbz20+Rn6oTShfxmZCR/LwQexDw7f4Mo7MkTlP3ouqcqXl/GflvgmieAvLg90TkYQC6iigKyoMK1R4IQn2XAHgyHUhAlSeLMIb18JhsrokdB2/oiLQez1DWZNvFC0eDmT+ah3jc+sv6Kg/uUl5xdrAdkOYBWk4lR5cQZeSwz1pRjvudk9ZslsT34sx3KniSLFh4esdvA4hSefodvSXmeu0y32sXjHPz5QH7cvCyyQ7WNZt45I3gNCQOQwGI/eYBc832OYH9ijzGlRuUEd4rMWqoMavX95nBidwEon0YNFx4/PtZ0919XWu+ghLkuMJrADWpyT2I1jHnocn43uetIyCjiZB4ErN1DEH3Nsb8eM70AHeAtpWUareM99ypZFkLgICNjSIROZFwFvW7J71u+/r88mLY6V5cng+6fDhO/awb3fX9SYj7ZHH0a5B9ehPMToIw8xOYW3yM+qWDMw1m7XgeZfJ57EdxkPp4nQa/HMO8lAANp0LMyVmS0ltOYYYTxMWpMz4Z37t98LjhyxK+MPk26nWyLAP+Md8qQjPPhMS8by5HRo3ITo427i75eDeVaSZd01pXUQTI8o5sRuJPmKQYBeLlmKh4f4IhA34FB2+aWcUjYkBdXo5GQtAugsgadTODQYverODqmiJFA5DW6YsoyNauplR1KHC1OOqSLYGNSsRHRP6jN12IL2mWzEeZM8i8aOwl48E8mXgjX+72khvS9vASlQC1VTzyQ8LiwbgSbc8J0dec6hycfB5mfqpUrWB3p37mhWEwUq98j0bhPGUtfhYD324rTsFhgKmCF185bp59vn1dfGl/zxErE7rKNd47sUC6fFM2rUku5O60muZcxaVU92FaUBJVC+oF4Oiz1GmNf5e174za/A1UjBcpcrV2XSASXuqFF/qw1a3qvKtU5OgSXrXJd7WxT2t0nXgnOekZnOyO6E2C4hwzX54MuB7My3easzPBmeDqTDEl6ntmfU/VM9KTIPLCtrh7BmC383cWimHKly4OjXFtx1GWBDjLRMGhMsa989Oza3BonH/8w/kBC45b1+2z84tTVgBm4uSy/2ur3xm2Oh22LZvWDLXVNybglRuUXQ2ITHLnFedhjqefjpy9WmO/cfC6+eJg7+C1vuSGqpnuAVlfqBvhmoOo13ohh4Qxo8m4OTZ28k1VCmFXg10lZLtBA2UFhd2L1nEPvcS+vFkDBQbD9gu/RO4PeanEjKV1HrvlgqSJLhQ3s9HEmlwQ7+RgNaZlXlc03yUneMR9SWznR6PWH0eliOWQ+O6XgFRAaCn4A1v4SPpLZW4WFX7xllCC/MBtH6nXbYiybR/lR1jda9aa3rCI+QAsxwU6MzxPxrTCm950QAsEYyN636e40yl3zadYb4BmYRktCRPYcGu/31yZdTkfYSsJvj5rVsnKq/HVIqfhjPVUQ5orKp1qfcOMJdwNc3ffIW+Vw0e9N3AzgMCjPlw/Z24LIl6gAXyhOsQECLSnTHiPO0aEOLeLOeol/g/pAhEwb5fyIoEM6XIwq2SJkkLMj7iUKVS0BfGo8WuNrO9WImKIteXPEZNreY6WSSStad9EO0b7roYi67inQ6ZWuzu4jiOmy64I1kPzijSMRsidYO4r7uHy+IfPSrxHo1k7aJilx3xra88sbTPY/Vxph0/q12Zpl5U29vX1Tpwp8GNa7JIL1nvnuMLvdpJ1bVLXqcC/rt6xaLdPQOcu59lsLl/dMy5YE4p01ulvqRvg0LZrObmqXGsHBWU3BlIYebWJuP3KckFcg10QR67quhuqxeKJS3uxkdesETbGd8Nwfpe75Klp3EBdL2x68PudwtzdTnvOWza95LYrzJucULlSSfvtiyz5jrxLD8frVU1eDQPDX0OdE+KDSh+LblXRrSy6UUU3vEhKmeyqFWWwR2WgPf0i4IEEbAIgkRUBeWGCNGww+7Q9GUrI8XzX7V933w/bl73LvgW3KXFRHYTykO1Cdg9f77jbuRwW9q+M66IbtqHklsDYuRI0Ly77b1o9SpPw9JL2J8PLOKPM1u9XFO4myENauGzauOQSs3F5ddx/pNt7NoKzm8RG7U33utXrnYMbePn29OyiOxg8Qry4DQvEZVzUlwuWranLdrv3doCr7eoWDmwtKPNvo9x9cz4YoA+7mnBxOxMIy8XDRrfVuzprDa/B/hnXVaYQhDou3hpZCEvVa1Q3HjrkfBmRQbZV+xUgXwVz67FQf2FONayHkLLSWzU7GDfgqUlmpNOmpkHVEdBvMdaTkLatDFpHuUFeZJ1iRS65QEQBHm6ZMfmR9VJ2fteyZQx4zCYI6PJh+6x1cdHtOT/byS0qeHXiCIapIKcvWleYJIVnbsrSXB2qfJHBF/CxwzJ0BPjigqHJGbA8Hj0ShB6IUCN5gV/RqBLzxfdvplPqpSuLAl4wh4QBFxsRYs/jgDEhm9hykQLbjC3egI9SNe6RkzYRnA6BuFwTURlJRGWY5hV1ZFtFiUEuYEwQxr4Vu80fismd/nnLeSeuFSPC4dax6iAImwdQgD0/Qrhawp+X8vmWPz/I5xv+vJDPxQlZYmYZJwXjSfiyGdYcl4yLApzkaWmvvX3EOqvuS0ao/VUM1Oh0VxBc+JggphEML1xioWRHlD1gmVQUKJNfRVhgUSHDQBjGnxDKm1LZE2Lwq45CZr2hfq3KllETIIquzq+6vfOL7vD6w1WX3yn9ozP2IeLwHWZSBsOrbn941RoMnIaIuMoB6rlUqNh7weG47va7HW6lhu23oEAX4grrFf4rvbH3JE4WYPeYxVH39t6Jm2mZsQE3+985jj7K2x4FCDNPjwFhfp9dUd6KbkP/MehOYCP4WYeJzGMeTOM4+9QJ0qyVZTK5hrfcDn5Xea0guoMnqO9742BObstV1ykLBNCkHKzaFWPNnEh4ntjgm8WCyLb4Yk0SUext41FnCU/97Ind8PA3AuYqWhJv2fLffGD4wFFjG/8BSxQY1Z/KT2I41UJjqi8E3+CdjSljnu8miyRmyPaPVXY74HBsnuYL+c+y6G6NxiJ5K2n0dPbW6DEfDQDfNhuAMMqkbRsb1xAIpUzT4evMN3tuojUeB/ga/DebnyjbNAclyu1U/1elM4zNeSkPqAyizInmU2buUraTazHVzr8KJvifMCUylxqn+ke2vwZm1HGRaoDbMYfw8XMeGQp3duTvbwTOL0eag4pzk/jeb4LpQe8t3+5Wdjf4WBCcgjVkDaiy64OzXI2RoxnkkzCDXi5LM8incQb5PI60E3x+QtNI5W1FZ/qE2SCdyRl/7FcBnJPU2Nv6u4QNwnA+dXJJFJwZBhFu/4yiqmS6Qq2Iqj9n+5zadpazzW8PFqbUwMdYxSwiLfHd4pyhreYR5BCGqN/rpn8GmP8ZiASQOEtAFWihMzLydbz0PIr8hIzyLtVsrnRaMxrkoFJ6Oc8YZrmEHsjAEmtMxStu7VaM7CrKlTzypTzeuasaz9l5NhIofbIMgVJWHWuncmtQbvVRW79GEGe6OUCJpfjWTpitGBQMIssluaC5tGdmxMqPfdHUm2Gf10iWlVFdTXMNIiyhVkaEpMzIONmzZTtHzORt0xHdLo4o5hK4cWFOAJqUQs6UzcoKuY+7kESoy7fovtBbb6zYknpZgYARuhWFS+dmPpnABLgZjkZ8/TjmBX9wV0KX//vjobPyZ/JeWalCdAYTjJE4B8iRrxuY4xpnBXm0rdePtXWaBGPdkOxKDkA0I15WgVAUK2SOmcwuW2iyMhIpBh4szpANcTbklf/TIDrG3FoqLDVYM/mscRTPgMXkFoufHGQPcowYhuiHc+tn4qvLgAK8jF1WMr4Oua7XSFdx40wP+f4cdRjfDJx/zANLS2YDbxTBTQGV4DWLeCC7EuA9BBbTRnTn85aSE3ZfPXABiOFHMXCNuIWqO7YqWnRDFEAbhCb8O9zC/zV1R4Aggs4Hq5CMkip9qpYT+MxHDThEqlLx/XvOZsp/No+MMnIsCNinC0PB44QM/CNtQSjb//AGWLfVmU21BKRiOWVPbnMf03thfIsrjPjxzNqSX50gH+/VqiqOdO66Gnk7j3y/DkFF0V/68sqRXXekfvEUyCrOcXFiPXxg/cKsMzrTzEeDZiQFZCUVgRvyyc2pDtU4tkVcRFqYMm/zt6QL0jNZKEibHI6Vp0FZNc4FfB1+5AchO0ehfsS2do+/asYE2XhRseF9sOMtFd4rRJszSxJw9UDpsHhlzt5XVR3CA8Y/yTMbmrGq0RyGTbyHFWlseC1QBR5xMr6aV9g+B2ushr+VwctlCR50ld/vyU+FMjIkUSyE9z3M3UCYyzzsDQe6udHPz5bbcHhizhVXM61e1DWNKSej7bQ00aIxGlYbxlUEyXMVJc95mNyos2+PxsYMMVSGl7ORM8bEzFdh8Tw0104hALHAalIVI/AurK9/WexNQqyNRt+rVvVvOwBfyfl/QQxe1KW1wvCCO7VGJL5SVN9OMF7StafE4xbf9ikh+cox+h5wbzTgtg3ZV4m5rT8wqn6+k7tTgPf+kL+ogS+SOy4OeMFxOWRvcbipfolynUBev9/FxG13k1z0ivRbbOb7nxq5JJdgwy78Aqh8K1GPo3iLX4uAtaFf+OMYQpb4M7SufXP8zz9FzrPdVZlPnFUggsrXEf9qseDxj6JINiwLmyga6/a2bnsLrGGDtL4n17RBNm2QezbIvS+StWaaOOakWJ3mo+4iWQspiaaGjcQPRhqeuWZRA8rce5W+0Esm+P8CLQ3CkrKEAAA=")} +} +,{ + {"vert", GzipedString("H4sIAAAAAAAACuVa3VPjOBJ/z1+hqq2rciaQiW1gmMvdQyYEyC4kKRKYq6Iol4kV8JxjZ23n85b//bol2ZZjOSTD3r7cCyB169cf6m6pZX6hq5j6kRv45OrG6vxrZEWvtkNDi65mnjt2Y8sO3fh1SmN3bMXrGY0s149N4+8kpL/P3ZBWZiEduwzg1X15nZGJF9hxsyINiEPHgUNNg2h8dkHHJyR8ebar5D8V/E3+yYbkEzFOT+uN/Oqh++IDg15vkGOiRTGdabpxXm8cEQ0XPZpPVVIjjfpptYoA28s7q1ngUz8GCKABhzYNHI3RNDBFK4AcEQZfxQmFOEMSdwysX7YF3tp+7EYRGqUUZahEfSJnp6fmGShYY6541J+YN6SZxhP8dW6en581zlFmSON56HP3fCKwX4aW2npMDBNwYT7Rpll5q0RxOB+DQ2Pbd+zQeaBh3PVn8xh2QdqYWRC5MexnswJDk/hBOLU9NjghsPIF8AGsWfHsdTCPNS8Y28gO5oJA1ydslW1lMEVGXWZMBBTZjITNALaYrtpBEDoqRjNhPEHGRMdf3Alpt637Yce67d8NriuwB+SFxmg3XXUdjYUf9+KLZ4lp36ErdJaQElEWOUfk2fUd13+BwUmVzH13AmoD/G0Qzl4Bhwkfjy3HjWaePaZTUOE7Ba/G0aN++tRUMowg++Yh7fqTgLmUmQoaDtwV9W6EfRqbjTnrHY0Cb47TRwTNmSEn0xmN4QGYzV2Ctjz8JL6mYFsBEeNTYj8qiqlnC9YcLQjlJeRzyRrhWFReWx2RdRWdmjOQbedlGEzzlib7ekTUhku7xhakgVAHMenfa0wyyDGVfqiJCI6LzkO33bGG94NB/25kXd70WyNrBHXw/q7Dt2xC4/HrA4RqKwztNaordk2L7OnMo6FxgRJU2+EmBgzdDQXnCUVwpLEljcxPMKbeJcriJLZWcjT5WwKEZkrzn7P5KkcE46gX0Z9Qn3osLDMDciaBBTIDFJcTEbJSKhaitzzk66u1bElVgK0klGKIpKJqPLQaWJnhB9i+U1KCvj4IXT8QfXMQurE/epZNJ1olOU81EVA8YlZwnpSQ1uWkDZLAzIoIHChyE5HvYMhFoZrhQQaxIgXI7/MAS6QrohFiAmdDOrVxKkxJx5yTRQ0knyZxsKMjzeqSKoqrn+pYmwmGNylg6PtirMsxjH0xNinGfvxLdO8bP1LZGTQ2Zee+k5iL7GxCBUXxYqeaNbjrtPu3g/tR5yLRpDzpGaKMVoe7RTMrGCZsXDT3cENxpGGA8qqCavh4RrpjGrFNjXfl9gaPjSAkPF5GdvjCDtJGMx38IzNh1Lq76oysdv++N2qSWk2w8L1g6tTgMvWOVZlyn1IZtYKtQCyJayGT5YHwIxfeTNLiLe94ofV1a2gN+sPuqNvv7bg1fMluDdkGgwMH4p4kqxQ100BRkTUpJBz5ErM7rsqEHWVYUg0oM7XXv7tt3eww9LzE0B6755WYWST+vJEKQYeZOGr1rjq90Q4bv5bYOOJ3zxIjFdSft1IlSm3mInAdYs9m3ppfVkEmmKVoA+w4DpOqngDxAy27MjffzwGEqSfXfzi+8FAsztVKo1uyYb9YZOC8jZDFSTO1khjbX1QSEwxZtBiyMHmqVrbZRXFvZbuTa8UKNV/l9i2P7+ns3ObKeuX9gU3U8Ldur9ftXSkasBPWgM1NQ/RgPwKXRX6R81Ru1Zb8iMy1at9av3UurFave9tiZiEJ57u9IexBWy3/C0OVmlihQst3p7y7EuaUp7Qpd3XDf7u+D/Mi3/INMiQfA9/u3sqxDRU26sb1V6Jnqu+EPsugOUiuHsl6Jqf8gS5Qaxc9mviWYj4x9YqxotrF99ot8MYJxumvKODWjkN3RfjrCXGTDNiKBPnd5QdawF94tna/jr3K9twaksLFJnGbsEkcVQK+vUEMXRETmQQVcZN6TRbj+gvRK6rWLPMPTVk//gOvPHxpNc+zkniOYYVaU+y9EE1bi5epDE88XCz0rH/VtiB4o65pq8Ji1nkkCMZ+CHo5grkfgqFCEOcqxpjGuqiFjpUx6b/4lFGcMotTen0Jfxrsp4k/dXzCy/ruPyGOdeN/GcgJ+v9vJJf00YcFtqqnPiywD0RQBPaBCKYCoZLL0MM9c/JhrU4/jHD2YYQvOz1j/pRnzj+s1dePR92fELiqyK38dTWV3y32Kq3sscFZiecJtyrnfHZ1QQ5+d8nivkBFw5/k/VdxGE9/rReY/RHczBLbq8mnB65aEqbJDTzbpLzTNE6GcskOFHEPr68qtRLGdZ5xXcq4yTNuShmXeUb2PsZ6IX71LO2DmAumYGjmBuxKExb8qAHA2dcnJWp571sCn+tfhYzcXFPuQtmnP+Dge5HN892u4sY3VZ3k1iKJmFuZa87e7Y3O5Y4LzPsehJ7TUPVmX1WcuvIDXkPFajRTjW66V9ej29ZAtVaX13q4/dBm3Nqz+4eBHdrTppTyAu1ba9S+Vlun84+EvAbYlrP2rWc7Hr9arrOrbWrIrQ4+0HvfcBV10naHBQLkfGJc9Kg3km5ndxtVxC4FbZbMd0fNra5L5ac3dVurlykT+BGEFFQJUTNi1wOm/mQC60Sls71n6gS5wRAMoC3fac/jYDIRpNlzyJSIxJhO3ShyF3RryNZm2ubUbJR3yK+2EyxVTrtBLww826eDMPih8B5jeHDpchdNXpv4N2Iyu/4CiRd0Fr/y5lvFtScLp3rBcka2qL3Lm2E59fv14Fs59WbQ65VT24EXhDwyIHfwfWjYafd7F9b9A/njj3dT01R9cde3wyz/yV9UaYMsrPmi5Gt/jkdZUYyUCY5ba4lJMAiUL0gm5+QZv7DGnjuzHNyN5LCGms4PxmKV70Kd7vpyIRfHZTLDj1zGlJby7F8UYFbUZDZd/p8G2Xue1vULj4u5xzR+MOXY+BkkSsERkYuCouInZDyV8A5SESalpV66Z2zT9B00YwetgZcTGSY3NJKrC14SM+25gqLuKYq7ZEiu7uJVLl/Zq0+7cPk9UQG1tWir3iav5WnwSbhwLEthk/wzB0QeZ1PUFzzIpTDGuOcxI5IK6HL5BV/DdTI3s1kqkpgB6TkkfU+oxLwsYVBzbkN9Qz6nfy8BELoG3vSmF0hBTS9U+NEUswz/dWYg51MYw4WJvP0Xo9XIG1omAAA=")}, + {"frag", GzipedString("H4sIAAAAAAAACo1WWW/iMBB+51dYqlSFqmWBLt1d0a7E2VaiFDU9HiOTOOBtYkeOubrqf9+xcxDAoZsHsP3NjD/PZVciQVwaU87QnM7mEfIDjmW7EuANX0grJhLdoMY5mlLmUTaDSb2KFoz6XISox1ksMZMx+ltZEvc7kjQAoUffB712soSDKfH4zsR2cUA6zOstJPf9FIqmYoIFDuN0TkIax3RJ9qZaVwu2K5+ZKnbf+ySS82f+dNvtIEufAXlqqZpRE/okamg1avVz1Gy11N9Vq97Ug8ZV62fj8geMq+gs0W1XEiVfYFdaMK4mKxepHRjXNh+rc1RXSt8Sk1pkIZjaECjuOrJe5sjebcCnOACySRSQ3gG5riNpCD4IiUcXYZSvxq4ghNn0w4AxLJWjNPbZPkKgUSTQwyERuEAgxFKbg/9XSlbtMuCeLY3YRPA/pUCZkjJYqpiBO8rZqV3Nf8LjUmepzDkEyTri8UIYkBBTNqKyT0Up1uMBN6A4nFLCpP2+KcVuBV8w7xD2+azEKCBdHBt4AtDxDKYYwWKIDZaWyo9cyC/So1lMD3uOPb7K06MQlREsyEmAGSkGbl+gmEImrKibx03vCdFWoC7we+Zzs9R/iiRowFcR2kPHw5Fdjr7dTbrl6GgyHpejaTzB10lfgmIncHAVHs14KHioXGBDHyMW6F6iJEKxal5pL6Oxik9A2EzOrQzOe42l8YvD09TWqjFZh+ubEmnVssw0E2YrLgIvpaaPqbjYEgsJi8BwL6zQSnWrzNRq680H9Frolzn3L9xRMK+UNcET6oOa8zToDe5fB4591+k/vh3J5MttJieJEeMwCoho9rc+eMDRsWJoHTcR8eTMIKwNnRBQ9DN7AXehJ8MVq5s+ZconTbR0Fsu2QaSxK9IwyTQzGQiAkznXJHipBZOILh03oJGT3m3KiS/2wOmMuoP+o/PQmRy59AtXxfbgyW1ePO/W5uSu4zwP7OcM0VThIp0hK0+dKbQzXRywQfZMMLDaip3dIEnWkDXEyvc+R6noy2v1GA9YsXJLtS3g9O464/FghK6Nr5PaqqqKz8XCy61T3zoo/doa/VbvAPU10OnpYXMAiWvI/F/6Uz5QjA5L8KNgR0mlVaKr6LAknWJhVXVlbX90rXzu7pOz2Zj32XtLWcWc0faKfIqgaW9j+sNK3iCHkBBpe1xy6iF1rar82MGSF9jMqrbR5z+uybZZrwoAAA==")} +}}, +{{ + {"vert", GzipedString("H4sIAAAAAAAACuVYW2/iOBR+51d41JekQ9kA7V7EzkoUaItEWwS0o9VohFwwNLshziTmOup/n3OcOHGIw3alfdt5mAk+37l959g+nkoQspkbudwnKzZ316uALDxORavi0T1fCytignwiTpW8uP7c9Zf4wyZr313wcEU6nVuPv1CPfK+8usvXgBCyYbNLMptNhbtirYoyqlajWciYP3YPBplPhbthseztVAB1PYAOXbGQagGsqJDm4N9nl21bZYK+vzHKhiH/q1RQpoQGSxWVMKessp7J+Ic8KiVrRj0DW2wX8GgdGiQr6voDV3TdsFTW4R43SOnqxWW+GP+9L5Xdhnztz4viBV+WGAXJNY0McYKgPTeY8hkNb6jB0gZ55KEotkejtD8HfKa1p1aUzzz05q2S9f5ESZRvD34JsH9Pg6fnIQ3pSkYhNwsZuDJmvrQkHApjg0v5DQFHEFOA9Y3BUPDp3MVF+FtQf8YsvQ2qUsVWaCBpLGiISWZc1naauOfP80IoXsjEOvTJzKOrwLIS0IVybZOfSLaoPNhV4tSqpF4D32+J+d4ueGdWWEwhmJ+GAqWtHd6fRZf5kSv2ecChyNmK7qxTvGkJYT4O5prGdk4ua6lPMAZ7yLpQts+1MOyUwkWOjPG3NQ3Z/H/EiYmdf6ZqQPfsv+JpClYmPMgJd7pwRP0ly4lhB4CrJgYvtzMevjEgpaa224MHHVBDop1aorqVyzxKVLepii5IVZI8uswTtKvvbB1dzcVzVIRGzcmb+bOKH5Livi/YMqReq+IuSK7AEMAfiiAkGOXbeP13fT0xCZFZis6LOKc9xpGxqAI58gyKysS59uXUrqDmhHkRyzmRlBRN4PJbhi8NVmOhnQ85n3sx9DyF1+/Lt6VFTl8iS3m+UGZsYzYITbHnJPsCVnDLWSqIc5J9ocw2cobm/lWi5ohKyiTP9LeMHaka95PCfcACJc2izh0r+hYKq15zyEeiku1i48Y6Nhg3rMKf2P9R9+pZKw9xTxwdPwvz2bLh7hyu9Olk1H4Y3/RG05vH2+l1e9xLD5kqgZmAJNboTPDQrnyvnEGaoPY07qEG+QReK7EUHGZ3dyCv3TPmFeD1DJ7ciOXYRg6rXRjlKk0tmuzgTPERy+R13J1nDEadBRCCiX1IbLU7nadReyKNquHIg+FH4Gwvh6KMmg0elNPYaGrOxG7u9C71ZiyJrIbuyNYCL8ZXj+PThq7NNHqlc76Vo3H5Y6ChT3tjqWEa9wY4vw096jN9TD8G6A8Gk0zXTad06RNmexR2WSBe+/6Cm1HvhMRSj28DciR9uBmMy6Wf74bX5dLB8OGhXJpM7zDTJttl1Ov0+s+96fiu3X38fKICzawCcUIRTJ0eCxvdzDqMzaeKeHXaRMDjEsTzd9pHxi53fSIvcDqFDnRxvWVutwzog188n4qwhoI1ACbYrsN5OC8B5tq3Ce17yn8zxmsvHNRQgWAFcJc9PI7u24P79tBg4dJoQeAN4QuTyyujAtRAOS0j9eeCYoOsN1uTj1+MUMcE/dUIrZugvxmhDWNdHSO2acTWDYx4640R2zBgga7FGl+2ucaul7xFJ0n7RGoQfnpOnvbyl3xgHr0u5ZGMT3ZiJeNzNphmk2htF8+26vH6pfn1i/MVbuxsC+DAnML3RXj9CL7X4IcivHEEPyQ5BHKyx8908MUHpQNHfyzK/38IDAnyFQDNhNOLtsGgZ+RKFv8BwAlhmAx0ygnAHgGNE4ADAponANtsEw76t3cTuQfXG3gCgNJRqXDxoxY+mDlGHHC3gPrBoH3IbuA0GHxxpHVW54IMV+1W00V9RLptOkjSIyIuVBOHO/kojF+G6E0dCQrhpIh6ETELeRRZqdVqGqIEZr5inBJWtZPH1vJPb/y0V3JXLzBrbK6lNx1mzMmeevsBS7ogSdoUAAA=")}, + {"frag", GzipedString("H4sIAAAAAAAACu09/W/bSK6/56/QYoGDnDhefyT9uFz24NjOB+CmgZ2223coDMWWU93KkleS4zi3/d8fOZ+UNFKcxOn23gtQNPYMyeFwOCRnODPemkfu2Iu9MLC+etdf59bUD53kYMt3VuEisWM3sQ6tetW68oKJF1zjl4q1CLxpGM2sTufED68c3/rPFke2rBt3vGeNx6PEm7kHWzN34i1mc1UajyPXDYbenaEucBLvxuV138oYaFAGOs7MjRzCwMxJGDn4+9FzlwdFFWfBjbHuIgr/XVhRhIQECxFlZQpZ9nrM+L8I40JhjR3fIC33dh7Gi8hQM3O8oO8lXS8qrOuEfmiodWZXnhskw99XhXUnUbgIJvnqaXhdQBRqjpzYwCdUtCcGUoHrRMeOgdINyjGMEqYeUNiyhoOTo8uw7yGKZbOia2c2cyqgD5GbLKKAf7e2+V/ALNGrJtWr4VdnEi6VXpHh7ENBcuE7gUtHPAtAdc9UR3HVgLM2QU2wsuvOk69nwTQ0Q60Jwmv9cDm3MrXnx/1hce2n04uj4tr+xfl5ca1QBBgkZkvQSrgJHyTG8XEUzlAEw7kzdvmo8aGNcdw4zsSLcXx8N7hOvtqy+kCOqs3qd/O9qd1WrF8sO1++KoBGlTCzyTlbhpE/EayxbiIvw8SJEigEDjPDCpqGULZEq92u7qpWo1bXvN8jDkIekRmDP3tTQBsNep3e2cfeaHja7r7/VKLJLa3JXDFiZzb33ajZ1TJ458zLjOx+OYl5yPsMwIwQE017PvdXfOKwnh15Tjw6hl6dAxnHtxmQ0M0wrlpawBygsiVkHIAMJBjwolAOtrypndPC2p31q1Wv1ev1hqKAYuRE7xkjDlRF/AojrzGB7j+gHIhSfmBQrJ1D0gAWbOdnXaaYMAulPggz1RJjoN6osvZwyIWy0JaxuFjOF24Uz90x+tCcoLmCY3sxKplCEuLi84/pH2uGfsNukBEo6uzdMoN2l8K6o0hZA1e7tXYI7LIUdpVj7w6Hw2wXWbsBEzGEFXYWsYKakBOKUOax7821SOg3LpKskMwqkMG8W2Yx77KIRCzQM9TUpl0AsNJqazJ5alrgxADzleYEGFnDElFpZfsCFOxMybbVrNXB0qLBY3pOapdErdPCLVPr91HyNbyOnPlXb/wgveZ149CdTttWoYLcHlDAo2LAlQSkYhkxGVA13xWE0AvxttP6OrqTxsOodJEbL/wkbfJ4GRN3htK27N6OaFX5GI6T8W1ctGCPkzA6daKJlZGncnE4OvD93EVtvX9UyIDk4ofasiJiNUEUJazIs9n7Cy3AyV+v7UOP4H+h2LwWrARa47r155+WLvoVVQ2KtmTRKg+1ykPd5aHuOBQIwRJChG8H1jeFw2Y9jdiB2cNDRvmfYpoqyNotc/qoDrpsVbH+Tr5LheICQ/8L7Ult9MPYjRMmcFmTmuTKnaxykzyFOQkTO3FvoT+uTV1/lTBSqXJ/CAxzrn+xmvv7+sur/XqTfG282n/TaL2Gkgp6Ksv1Yzff8L2N4tT7tqU6HyfuXAnwrpqSgI6dOHiJXg/DafKi1z+EXofTKcSVUh8UO0xsTVgTzXGpTw2uki3SYEBh4F46c+tQaJ7AEZWC4oi3Q5rAAE2gSl6u/HD8O8a3+Lch/jbF39a6c4tTkcpK+lctmWdpCeopsKo8Yd6B8vGuPIEZIbiN89TcjIAkexvhqbVROW2KNWU7SxTrwUrF1rQlyvFYxdB0zQP82MHVdM2D9MQBSi3xMUr6zbKgnVk4oWxxa4GbB9vSyujQkAdTvyGWd2tnTQmjWUnDfqawysxkYfHb5xw3K8XNinKzUj4QCQuWqrI9Tvpzdjcj6xmbv734xv/rvlEGkHQijPrUPQKHUt8LwAcp8J37wD8Q8JWmvioA76bAd3Lg5c5a/N0Tf/fF31fi72vx9813c+pKxlnzM/rwV7v4vEncDE9PcfFKx56HtQ14ejKSm4k+9n6kkHF/o2O3GZ5ePcv0626CtdebnX4b4enNs0y/p7K2mWi21Jo+PbY1W8Snx7alVm1jIW7GMmm6ZgvzhLWD2Uo81kJouuaZ/sRZrsmbZ+tjZ6qma55xT5xthqXJwxYmfAGx7vKheLfxiQscEpJJWNHKziFdrViG5YqhaRLxSXKGRkn8t4lGDX0wNEqCzNJG12vT0AVDmyqgfUybZNOULbKa+9kVokzk3pccoNnah60baWLyZdn4XVIF4gxFfnm5kRxCOvf/XTMJJU2b8gkTbqcfkkswzQdTUuFlPvwA82FClX69JLhEyZ32USNJNNEwg6S2XMFQGjdolub9mZKdnL86kTExrx+yc+37JDIewcyzJzKeJqDnSWRsRE7PnMiY5MPkByiVYbH3QIJrJzIez2h5IuPJ/D4pkWEwOT9ESiPP1+OSG0WuOp/leHHWL8661Fm/ZFz+sozL4x3Zs2dcNuL3N5xxeYK4njvjspGR3HDG5UeIbfc3OnYbzrhsdPptNuOymem32YzLRqffM2VcHhd1rp1xeXKwXJBxeSTb62ZcniyVgozLphY5WSvxNAthyLhsTC3MGZenq4U547IxtXjJuLxkXP6qjMvPbjDxpvIe34dhb3R21C+5fbenb9+Je3edxZXL7v0GN14UBjM3SMSdkWnkXF/y2dEPJ5atL+rBnOGTA/gLo4m8L+OHE3JBNlGoNoMXoAikbuYUNMF4ko20ntZICzo8d8a/D06OemL5Hl1fuYQGfq3BfyDWebgElwlqy8rwei/zmnjxqPmG3Yj6RmXdPTs+hr/v2hclIn9VKHIYuekidtk9RzmQ/A/v6snJb+/CK893LVvM2HBx/TVwY3VD6Tw8FTKSf8/FHgR8uj3F1VkUxrF9XrVO1bx/H7jvvGARA/Lwj0jkYQC6iigKyoEK1R4IQn2WAAEAAAmocmQRrmEdvCabaWIHgLetQOvxHGVNtl0cfzycu+OFj9etH9ZXeXGX8oqzg+2ANPfRcio52oQoI4d91opyNOget+fzKLwVd75jwZNkwcDTR5bXCoM4EZeVMVpiodcui712wTg3X++zD/uvm+xiXbOJV94ITkPiMBSA2Gvus9BsjxPYq8hrXJlBgdZ2AF2NWb2+xwxOYEew2odBQ8fj3s6b9u7bWvMNlCDHFV4DqFFN7kG0jzgPTcb3Hm8dARlNhMSbmO0jWHRv45of75nu4w7QtpJS7ZrxnrmVLGsBELCxUSQiJxLOokHvuN/rXJ69Px91e+fvz4Y9PhwnbtILbgbu1Md9sjD45CVf33nzY89P3AjmFh+jQeHgzLx5J1wEifw+cYPQi92zIHGD2EtWOHIZw6kQM3KWpPSWk5/gBLFx6kyOJ7f2ACJu+LCCD0y+jXqduGXAP+JbRWjmmZBY9M3lyKgR2cnRxt0ldwJIaTNpp611FUWALO/IZiT+lEmKUSBRThoVYNMywC255hZvmlnFQ2JAbV6ORkLQzoPIGqSMy4g0Lfqygq1r8hRTgLSuoowl2drVlKoWBa7mR12yJbBRifiIyP90A8q/xkm0GCfWMHGCiRNNhoto6oxdudvr+FfuJBTbtPMQWgFtFV/5JWHxxZ15cezduOKrj7HmTOfg5PdR4sZK1XJ2d+Ymju97Y3Xkezz2FzFr8ZsY+E5HcQoBA0wVfCjDsrPs8+3r/KH9liU8E4bKNd474SBtvikb1yQXcndaTXOu4lKqezAtKImqAfUccPRd6rjGP8vaj6na1PYxbn4jL1LkynedI9LMubWdq5hNUfB/H3FNzEeX8KpNvq2NfVyjfuKj5KSf4mQ39SKKuMfM3VMKrg/z8qPm7FRwJrg6VUyJ+n66vq/qGempFzg+ewYDnW+f5zzo2ytimLKly4PUuHbCIIk8nGWi4EAZ4/7ZyeklBDTW3/5m/YQFR+3LzunZ+QkrADNx/H7wqT3ojtrdLtuWjWsptdUvJuCTG5RdDYhM8uAV52GGp18OrVatsdfYf9t8td/af6smY0rNdA+If6FhhJ0eRO3rhRwixowmY2fY2Mk2VcktuzC9YX5BA2UFhb3z9lEfo8SBfFkDBQbDxmSEAhIGZM7SOve9ckHSROeKm/l4akwuiDM5WI1pmbcVzXfBDR57ztIebOdHo9bvR6WIxZB49ktAKiC0FPwLc3wk/aUyN0sWnilDnB247UN13IYo2/ZhdoSluKbt2RVbMe+D5TjHYIbnyZhWOLOrLmiBYGxM3y3itmucea5I+BugmXOjBcsENtw67k97Zl3OR9hIgvtnzSrxvBpfOTkNl/KnGjLtUelUG6TMWMTDMHv3I/JWObg3eoMwAwjcG8MNMuY2J+IlGsBXqkNMgEB7xoR3f2BEiHO7mKFeEP+QLhAB83YpLxIoJV0OZpQsUVJY8yMuZQoVbUkiavxYI/7dSEQMsbb8GWLSl2dopYnENR2b6MBoz9ZQxI87esnU7vSGl2HAdNkWi3UA5osibvdxNTLmFFhU8IZHuHz9w2clvqPRrO030qVHfGurlS7tMNi9TGmXT+q36dIeK23s6eedOFMQx7TZIxes99ZRhb/tJOs6pK5bgf96esei0zkGnXu/SOYLeXRP9Zgo0ml3wAUgolkiJ1uVa+2goPEfUZKCkU+biNevhCXjunYcXtvShajTB+J1o3moYkaImcC6xMzhxxAFjtORVNUSr2AJIxles5eiuGMR76zpvUoo6AWTdKU+aMGXNLYA2pVNMwmrQtkCi27Q9pPt097tfM1e4UNvCYT1ipX2ZIKOb91edPmKIA1wl5cZi8dK5EY6xKM16Kvibdvaq6k2gRisxiF2FLS3CRt6pKcpYQz/WDiwmvl/JBOTdO4XVd9ZuZuS0wioXIbzVOUtrRw4wbWbql7JYzrO7BM7RBKF/86ed4FFAhgoAlBbMQslUOXhE4G6VCi0QqGIfnRx86BLZzaFrqb4yQxCU29QcDKfq/iBiRjXy9cRrlzF2QvdCzx2IQSEAsb6pTw5RMoFSYytpTh3eZ9WyIeWomQk0zK6d0Fim3xi4ZpKUOpGmEjyJLD4m4YvZJZIoZ1mOd33POtpER6t198DwjkuUmXLu5JMxdgbBFWw25b+BFLBKWdLJrYt/QnrKkaZIbkHddTMUcEwichdSYehcn2ScD/hAAllkXbHZg4Q9xl2LNnZLioux8HNNUMp33XLay/ttWyB60TG/EzNtuUm9Cbo1C8H7fPhcW8A698TWBMPe8rIVK1wIQOOKVvq4CthJBYADAwq61u8FhrUvpsviCCczIE3NLjwiMWwzRQscRjFKC3CjTacCh6iW1XP17lyR0wKpH1x0f+speEFKAUdD1XTEiHxIIsrxQJLvu4qllf6o0CTZY7KvPwkutHudD4M2pesPzL54odjBxcZFntL2AvkM27YzIhT1LsJ2W7keiAjOmOLeQHIEJc0VikTm0FiubOkRIlSrVPRHmwVaqfyBHxbWUlVjTAhgwNjklNhRxWtbwbxN5j4yduxNyO1e/HIvSZDIy3WCpPazchf3GSeHW2m3nau59Jw/MVRP/PaaMv6wBZ88iAArOQyYT5389Lsu3yGsKfymKqifXpTk48Vgr+voXCFbkOli0XXquhaFl2poiteJANqkufNC6GZljRKQu9A58G5yMgDyIgg96jluJy/H7xr90lWkxDYMxFI0EcEianBfRM8DItssqhfr7J4TWtxszS18NoEWTdBvjFBNkyQb02QTRNko24CbRlBm3lZqP1XA3gjD55X8kbBA+YXV9GFEzmzWIbAOm3AM4k6rZB9Ez1FsmmaNksXJ0f+od8UZsuEOQEuPB8w62Wo+VMKFLVRhrpfitosQ80n6ilqqwz1tQmV6/h9fX1Tilra17elqKV9NZtDhVva2UbDhOsrlWCuLl5EEOehh8tlnaRn67c/9wZD3J4WizSyG6o0rIrTvkKTAHvWlYP79CSawLwd/ye28wRpFkZRaEleqyHSr6sYSeM1Cd5OMSJY6mUNvGU5cAOBGxz4Ot9W6xnbKgduInCTA1/lGdv7URgrB24hcIsDOyrrvOaw8/yuyiGyOEh70LxLVBqoXgFfTwUVuGRGm4dyHRSIO8WYVP4l0Gtp4XO1dg/0Wor4Y/B2D3ShMq6lADr9EsxmuP+kMUW6W2TWcXUtU+XW4RZCsxM/5FFyGZZVrB1ev8rUyzBMAWReNR+pTDzvhW6PBo1yBvHkgJwP6XMeci6yHW15QIikI2g2FafbxdFgi2ZuxBnX7LxKg6jPuFWXn0sUeCcFLbWmEGJVPGc2QbUQ4q54Pnyfdgshlmn9Tg8E3TDQxz2KB5FAyI9FQ6hAdyis7rKxvnT4nkaxoL504J63xYL63IDlhkXmKQvGsxBDpw753DecpnrMep/5WZHCT3txX4WGsBzCFzqQOXm2BODy63dNJgXLD6wcMjJ39NAX33ah3Iiii7OLXv/svDe6/HzR45t6P8MSYQpmzmK9G44ueoPRRXs4BM3msiwGqGeOb4vzIp3+h+Flb9DrcoGNOh/6fRQSa65kh4P+ytBxGC0h5mZCUL81dCN+TYf1/yKM/5Xh6Iv8hQoBwiR2HxDeSWB7xO3g2nfvg+56JoLfdGqb7akMZ2GYfO16cdJOEnkgGPMbwz/UxqIX3MA3qB84sEAmv/Cj9rMEAih+Blad5GHNHEt4nrnkB9wEkW3xwXiwlWJvp77q7eUTN3lkNxxM0izUZoC4GcyTbgwfOGps43/AEgXePkzLT2JY1Vxjqi8EP8U7G1PGPD8BJ/YofXbmTZ3I9zgc+0GxbOF7dkdGd2uMiWM83CZp9PWJ81SP+WgA+Ha6AWsnQ9s0NnZKIJQyPcK/znwzn6dsTyYeXt3/Yc9UFh30AyXKnK77rzqCmTpQKOUBlV6QWMFixswdeiyjqbb+mTPBf4cpkdjUONW/sDNBYEYtG6l66O0O4M8/sshQuLMjE6Ce9euh5qBiXUWu87v8Mbn+B54IVnbX+5ITnIJNyRpQZdeHp5ma1LnSYfbg6LCfOVk6zB49HWbPnko7wecnNI1UPqhqmHXcbJDOZIw/9isHzklq7G39WcJ6vr+YWZmDnzgzUkS4/UsVVSXTFWpFVP0ZO5ulbWcx2/wXj4QpTeGDOc0UkZasQ2LhtWnOIMgh9FG/rTWPrA7xzOpQHFoVOXiqQEt9ilReIYzPgsCNyCjvUs3mSqc1o6FEBpjvFwnDLJbQHRlYYo2peMUvjSlGdhXlShb5vXySalc1nrHzbCRQ+sQNgVJWLWOnMj4o433UcbVUPJkOc4ASO5a89iHfkkHBeLZYkkt6/veJp3iLn6qhx4VT9nmNA75FVMtprkGEHQIuIkKO+ZJxMp/whaXNkJ1/p5D5EcVVDzcuLAhAk5I7581mZYX8hlju4GNd3vx7YLTeKNtEb1Ys8BGTMPBX1tViOoUZcDUaj7kDOeIF/+GxhC7/15cDqzRdgzlRA1l/EcMUYzTOAHTs6hYW6OWMIPc3tndfYyeRN9Etyc5kAEQ74o5Np8Mq5NF4MsFMq5PSxUh+7cGWGrIhzob8pcKZFxzhkeBYGGswaPK7xlE8AxYTHL8CfsC/yFFiGKIf1rWbiI82A/LwdIisZHwdcHWvka7ixp8e9L0FqjFeaFx8yQJLY2YCb+TB0wIqwGvm8UB2BcAtBBYzR3Tn25aSE3ZffeECEMOPYuAacQ1VN8wxGnRDFEAbhCb8d7CF/9fU04aCCMYfrEIySqr0GVVO4BsfNeAQqUrNd285mzE/ukhGGTkWBMzzhaHgK0gM/AttQSjb//AGeLpLHvRQXiAWHpV9s5t7eATLD6/RyYjfLq6t+IuP8uutcqziJapdWyNvZ5Fv1yGoKLorV76UumuP1Q9O4z6S5Bz9E+vhHesXQOI3m4Vp0IykgKzEYu2GfHKLqldrHNsgLiItPOnf4Ze7c9JLs5CTNnnTSz5ixapxLuAt/rHr+ez5B/Ub4rVbPFnGBNl4VTHhfTbjrRTeG0RbMEvicfVA6bAly4Jds1UdwnfRfpFPTWjGqqnmcOXEe1iRxobXAlXgESfjm0WFbXWwxmr4E5+8XJbg+1zy8y05rs3IkPPtQngvK90NrHRZkL3htW5m9LOz5dofHafniq2ZVveL08aUk9F2Wppo0RhdWaeMq1gnL9RCecFXyo06+3Tv8pgh+srwcjYyxpiY+So4z4O07xQCEA5Wk6qk1t45//rdlt9klbXRBXiZV/+x1+ClnP8XLMPzurTWSjwXTq2xGC8V1Y+zHi/o2mOW5IbY9jGr8tIxellzb3TNbRqyZ1l2Gw95qyPUPJwCvN/EATS8/27ZOOC5wOWAnU6zY333c521vD4EzMRtDpNsjIr0Wef0tVWNXJBOMGHnTmHLA9h6HMXjA1oErA19T5FjCFliPto274//+adIe3Z6KvmJswpEUHke8ZeLBe+e5UWyYVmYRNFYt7fGY8YNE6TxmHHTBGk8ZtwyQbYeJGvNNAnMSbF6hIiGi8QXUhJNDctjokxkrlnUgPKUQJXeQyYT/H8BRVx11zGKAAA=")} +} +,{ + {"vert", GzipedString("H4sIAAAAAAAACo2UTY+bMBCG7/wKH5O2ihK2N9RDl9VuI9EIKe3uYbVCE3ASt8aDjCEf1f732hBSb2K3PSXM8854PPNCUEmas5qhIFu22VZkzRFUFHA4YKNGNVXkE5l+ICsmCiY25mFMGsHWKEsSxw8cV8DJr6BPJqSl+UeS55liJY2CkhasKatztM4lpWLJjg4mQLGW9uz1bw3M7AZiKKkEq4ESVFdO/z4yuot8YC5aJ0sl/vACX5Ip6E0c4Jvk4dZ513+KtXdYOXDHtOi+wrqRDlICEwlTd0x6WYwcHRTKFaNCLX8evOxBYiOKa7zGjaeoJrdQO/rU4HPhKCUoyHtwVGrNHFGqa3uEXn8mmFv2tJbyhJIXkSc+/zaQ4Wyun5Su/xWq748pSCj/YdLQ7mK5hQJ3rjYSUzflIKhtn0uBbWQXs3PP7unO1J4z8I5WajsXa3Sr/lPSU467ilzQxX2y9NOnL+mtnybpYuGnJ1f9mTXXG1Xmc9VtmgmjvyGQ6deBmbhLOLOFQu8EuEsWDrJQyxTdx4iy8BysI72yzXLOqqww44uCrvmWSkVGY73v7nFnLNW94cO/yV4Xsfz2fPPyPH0h761rTPaW/HAtn13ID5b8eC0PL+RHS74zE5pMT82b2+joucQbk5F31m3smxt5nzg5aqtKqhophpBeX9AiK4j5/Ji5kA3P0lMrOtPMazSOyOtvUmEU1o0GAAA=")}, + {"frag", GzipedString("H4sIAAAAAAAACnVQy07DMBC8+yv2aEMJScClUtQDD8EdcY8sN00s3NgybiGg/ju7dg60Ehd7NN55rJkPnTYfxo0wmH7wsLVOxYYdOn0LXun3p87H4c29vjzcA0+PsCFKwE8eCl2ENRDkVVEuoJaSrqUs6wSqpVxVN3eIBVxkbcOyaBuUjhyxyMzV7IO4mL4/F1CS6DpbppF9GCmwYUdm1eT2kVunVaT6a8BZM5JDDYdWW+PbOS31xLAeONWefc624381xRfGnhATli8LCZd0in8LIJN2AK3bZ0x8dNYFbODMBnbKjFTg5C1/Q89FA8df1Z02I40BAAA=")} +}}, +{{ + {"vert", GzipedString("H4sIAAAAAAAACuVabXPiOBL+zq/w1tZVmYSwYJKZzLJ3VwwhGW4ToIBk92oq5XJASTxrbMY2BLKV/37derEkW2bIzNx+2S8JVreeflFL6pb0I9mkJEz8KLQuLt3e71M3efTmJHbJZhn4Mz91vdhPHxck9Wduul2SxPXDtOX8bMXk88qPSWUZk5lPAR79h8eldR9EXtquKB/WnMyiOWk5ls1a12R2bMUPd17V+rOC/61/0k/rwHJOTuoNvffEfwiBoVlvWEeWnaRkaTed03qjZtnY6WPrtmodWo36SbWKAPnuvc0yCkmYAgTQgMNeRHOb0mwwxS6A1CwKX8UGgzhHEXcErG/zAq+8MPWTBI0yinJMog6sNycnrTeg4CF1xcfmLfWG0tK4hV+nrdPTN41TlBmTdBWHzD0HFoyXY2e2HllOC3ChXWjTrrxUkjRezcChqRfOvXh+Q+K0Hy5XKYyCMjDLKPFTGM92BT5bVhjFCy+gH8cW9HwAfABrVwJvG61SO4hmHrKDuSDQDy3ay3MlTJGxqTIKAUU2R7A5wJaSTTeK4rmJsSUYj5FR6Pijf291u+71pOdeDcejDxUYA+uBpGg32fTnNg0/5sWHwOXN4Zxs0FlcSkJo5NSsOz+c++EDfBxXrVXo34PaAH8VxctHwKHCZzN37ifLwJuRBajwGwGvpsnH5slt28gwhdm3ikk/vI+oS6mpoOHI35Dgkttn09aUsY5JEgUrbK5ZaM4SOanOaAwLQNl2Dtqy8FP42pxtA0SMT4W9VhRTlx22DC2K1S7WTyV9uGNReXtTs7ZVdKpmIB3O8zha6JaKca1ZZsOVUaMdskCog5js9xYnGcwxk36oCQ+Os95Nv9tzJ9ej0XA8dc8vh52pO4V18HrcY0N2T9LZ4w2EaieOvS2qy0fNTrzFMiCxc4YSTMPhCwMm/jMB53FF8MumXRrST/BNgnOUxUi0r+Jo6x8CCM1U2n+S7VWGCMaRICFfoT4JaFhKAzSTwAKVARaXYx6yylQsRG95yNc3W9WSKgfbKCjFEMlEHbLQauDKDH/A9p2SBPr2VejNV6I/vwrd2R9dzqZjuyL2U5sHFIuYDewnJaRtOekZSWBmhQcOLHL3fL6DIWeF1Qw3MogVJUA+ryJcIn0ejRAT2BqThYdNcUY6Ypw0amDy2QoH3TqyWV2yimLv2zquzRaGt1XAaO6LsS3HcPbFeM4w9uN/Qve+sC2V7kGzlurcL0zMtdybUEG+eNFdzR2Ne93h1eh62jsTmpRPeoqootUht2jLBaMFA5esAhxQ/LIxQNmqgmqEuEf6M5LQQU13ze1n3Dai2GLxMvXiB7qRNtrZxy/ShGlnfNGbut3h9WDatg4POQsbC6rOISRTX7BKKneQyTgs2ArEkrjmMuk84H5kwttiWrzojudaf+hM3NFw0p/2h4MdWcNbmTXIAQYHjniepKqUtLNAMZFtJSTmahKzO67KhNUklrIGlJk6GI6vOpc7DD0tMXRA87wSM4vErzfSIOh1Jk47g4veYLrDxnclNk5Z7llipIH69VaaRJnNXEf+3PKWy2DLklWQCWYZygAvTWOxqgsgtqHJlLn95TmAMHWR/sP2hZtise2wNLoVG/aLRQrOyghVnNJyWBJj+4sSMUGReYmhClObDssGuyjupWx0tFKssOab3J7z+J7O1gZX1Uv3BxZRk1/7g0F/cGEowI5pAbZqObwG+xT5NPKLnCdqqfbEtkitVHvf+bV35nYG/asONQtJ2N4fTGAMumb5bymqUsRyFTqhv2DVFTenfEq31Kpu8ocfhtDO55teIMPko+D56q0c2zFho25MfyO6VH0n9BsJzUC09UjVU+zyr3SBWbvkYwvPUlq3VL1irJhG8UvlFnjjGOP0Pyjgyktjf2Ox0xPLFzMgFwnqucsntICd8ORGv461Sr5tC5PCxyIxT3gWjioBzw8QRTfEhJRgIj5nXlPF+OGa14qmPk/6QZOsxz9hysO6VnWejcJzBD3MmmLthWj2lp9MSTx+cLFuyvrVzkGwQt22N4XOtPIQCM5+CM1yhNZ+CI4Jge+rGGM2raLWTVwZRf3FmpxiU6vY1Kw/wU+H/m3h3yYe4cm6+zvEcdP5fwayQP/7RnJJHf26wDbV1K8L7FciGAL7lQgtA0JFm6Gv98zxN2t18s0Ib74Z4e1Oz7S+yjOn36zVu2+Puu8QuKbIrfx1ayrLLfZaWulhw3zDjyf8qjrnZeqCHCx3kXFfoKLht+r4mzic27/WC9T+BDIzYXtVXD0w1USYigxcDpLuNJuRYbmkGwrPw+ubymEJ41Zn3JYyPuuMz6WMTzojPR+jtRBLPUvrIOqCBRgq3YBVqWDBSw0AlrdPRtTy2rcEXqtfuQytra1WofTqDzjYWMh2NtpVHPi2qZLMdVKIWs8XYzXTUFP5hprKXwTRHSglEnkrS+VTfwHb4oLM/dVCJvjJLCYkZFtmnhZCxbImjJavSzQFmqoCXW9BYk9RgHoZ4OD/jU+ybKBA6IdrI20UR59KCWWdELC0oyBqnYXVM6o/1M+lzpp5gcFbZAPhQUuvPAWPnC/99MyPS2ndKIgMVG9x50NQTP7YltIu4mgVzovk++ihBBQo773EoCcQOnMDVEi8+NwzIK3Rj1HMroj3qt1P1RMBGInfojiYN0xnB+9MnE3jBXPDxOpIjS77Fx+mV52RqW9T7Rvg8gQhfeUtr29GXuwt2sqWxNHed6bdD2brmuwSm+1Rnjvfhu6dl84eXX++q6zX5i9eIAXvsReZZ5NIiV1qXPKx2RDV+O4yv4hdCtouae9P27lTAZOf5MkAM//Sp2ETPdhiVc+2L4iZhB1aidtmmHN4uQCN8BdWwhnNUbKZWKNdsrtpiFNY0+OU7dM8nPGyKCP3wrlO3GZ74yzwFkvb5kxHQjTeHctGIQEvWeu4M9N9OXtjsqdVOJ/SlISZKjC7sILa14ozfKyTbnWG56LPFt7G3uU3xSC2tYCtmW4HkNNnMvHWd7O0jwT2gaKGTC/uNWdMPq+8mMz/Rj4xeefLrrr0tuR7+ckFlGm01IgblTjGbEIjb/nVBChPZzXuf4whcw1LOFSGOjq6Ueddn2hzlPCuT1kXlZB14XackSD1ztSZrXLXNH1yg0Cfd6kw/63hD+rifpiShxifEuG1rmbF1vqXcBAtE4D+xNp/Uds5JGZiwp1HzKYt6iG9KBTJScYjCg5xoPyCEky5LZZCqEuKENj8IvlLlVW80NFV1m0vqq678P1+9rYVzb27xBaSjwRM1WgNsma8B5b8RQvTI8sWShxY8hd9HWf0GcK9ylCzRiXDVGW39Jl3aFcWT4LvBxwgHixi3bGTz3GKj0XwyaAt4vsngY2VjqG1St/9FaNXtVpIYDGRW37uzWsLr3fc6bgzmJz3xu758AJSlEkvW2RqFhZBHM2bpVFcrfypHt9DD/oqo8KoIFDu3Uu67bLkR2dvSna+I5bzOhqvsmGUd2kp2siFM+OHnCejN3F2arf2P3CsTrd7Pe5MKaj5CaN0zRoXSpeBtrXb1Jx3tdW7VJpxSOhoqIKqOcUR5qY3nvZ+d7vDy+HYlGOy949B9JTdfs1Ynm98eokGSt614FUucVCmuJUxPsvklbkDvVfrXB7bLMk1p/wBZyJ2uNQPgGl4fw/91GSRqQWVuXK8IctspQjnRx2ihR2XGN59yttVOztJMF1aZRec7LDAwMxOB7Lk2FDfCCLNN9Jju8KVzAob5dQnT2vuoDk7aA08KlJhtE9HHCRVsnml1SyKxlo5gSdoesFSvW3LczhDn9IYwijBhTd7xAvrnjr6YBusnFrL8xNz76RzNbqE+TMeXrnjqUDS1v0n2Nxx7f03O7NEFnwjyR6M0y/YGX7moZrVbpqi2gTjM4IqrM+N/LTP3CAPnORaLA8k+F0LP2WAL9GvajqpwvIfAx/fJI/UYIctptq2Xv4H6DyxVrMvAAA=")}, + {"frag", GzipedString("H4sIAAAAAAAACuVYW4/aRhR+51dMlRebsi6QjdSKppLXsJtINLsCkjZP1qwZiFt7htgDC6n2v/ecudhjsNNU6lv3AYZz/c43tzPb2xUsSctUcPIp3X7akU0mqJz0Dix5ScJotlwJzn6lO+IpSSIyUfjkr54akNckT7mnxgOCBt6PwdD3J6DmpdSxSAhm4+DVqCm9AekwGL5sSiNle30mnSrbVz81pTMlHV1PegWT+4ITDYT0iRfCh/7xPbnxffKDo4sc3dSHjxngfdYFLxd3NysxTzmjhal4S/OcYsUmifoNIdS3cbwmUXRb0O39Xu72Ujle11S9SDegj98vZ/Gb6UIzFxTbR4DvEOxVcoDzgvF1ummYlp8L2bAxeJQIcWT0JPbSK5lEXgbkMYUYfIs/fLLn6UYUOeC4y8QjzQCWnm5CNNgklmnOJr2crdN9vqukZVIwxpfplxYdpzI9MK17nnwFwMgFENGcFdQBkFOpwsH3h5Q9TboUb/mhVfdQiD86FV1OGLDT0SobzrbqROF/EGUnWQnNWthix50o90WLJqcpn6dymhadukjP8rmW5o8p43L556lTd1eIPV9fqjdi2xEUNDe0bMEJinDdEgp3yy1tiXRAHkUh1fLQm1bvrVux1ZsEKMEtosZgWsJi2SGz2hiojtcpCuFTUp4wz52AgXLxrTXAW0pa4OqrqwiOjnrG103lqd5GGc13nmeMrmxqdXRUQpvBH8DBMyCjQJ0c5jQ67r6xKqRRSsYrKEBq8OXbq5gyXqby1DT4cslZTo/e13hzCsJ6hlhrha1ProMqJwSD1etd2dh9B0Z9Em0aZCw/72nB1v8jTtrY+Weq5vTE/iueYoiyEruG8ugqF5RvWUN9Mlc9gP9NFNkajz1tUFETHE+QwTUITurqNa5PSixK4/pUubiKysXUMWWZpFN3Z7vWgwaes0kYB8NmmI8DHCiK33LJtgXNJj24dBsTDAB+sQQhwah/0vKfXbkJCcg8S+eVrumEOGoWLZCzzOBoQ/SdEbQvMOeEZSVrJFGUXIZA8XNt3wnWYSFsQm7Wfgm9SeHNt9U7cZDTx9Kzma9sGL+1GjStbPukHgEruOU8C6JP6hHq/FbOMNy/KrQdUcc0qTP9uWZHuer1ZO2+wwkyi8WeO55q0EbBEDpKW+wUF6728bH1vJTCn85/tnrdqm0GvSbOjp9N+9lyEOkam87VIny3vJ0t4tv7u/gmXM6qQ2ZAoFkznfSGJhJ61V6jVwUP8hqy9rQWEtZ3905duy9YdmE+qs3NjdhtO27YOhdGt8tLB019cFb2Jav1I9ydppGuCQkfHuYfazZSjizU/fqgyYjz0EEbL0+PntM7YSc+IEk9NG5WRtVaQk6/M2WEUfR+Ea5UPbZhzkQCjbTgulNPuYFwwDSxjlgVclHGRQX2xdGa8ZIA+3Zzkvlfo62FscYlcPbgaWR3qZ30OldndRNghzX0K1arGXbC4MS08dRZaBVLz4vCOH94E8YreIlZb6tZzX5fvV/MWiZqrCYK0I4h//5w9vgZuY+fcf34KaHHzFgxnhJs61fsKNV7wGTtDuG+n/ABTLm0LQIGMn18PSfqBRLydbSXYrNR3bct6cNsAVXF0f38ftFS10jVlYkn08QfYvO+tOsPhRt46hKv6lKE6qsqGEI9WPuv26DovqAVS+XmvsE9k988eUVA0cIK6aRrwhQuyY6R2bxSU+05tA/UxEFQa2be2Y30rg7zY3Yru0jurCO8LERQC+LoTfju3WwOt3cbK08+tkEJLdatC9gT9enu/qNByZ/bj5F6kyYxetg1gvsZWcDpa+iwb4Gx50/I89+C3IenFRIAAA==")} +}}, +{{ + {"vert", GzipedString("H4sIAAAAAAAACuVZX2/ixhZ/51OMVFUyS0LBJtm03KsrSkhKmxAUyPZKq8jywoTM1tjUNsRQ5bv3nJkxHuMZFjZtX/pC4nPO/M7/mTn2NzRNaBCzMCDXN27v/2M3fvamNHJpuvDZhCWuF7HkeU4TNnGT9YLGLgsSx/6BRPT3JYtoZRHRCeMAz2z2vCBPfugl7YryQKZ0Ek6pYxNLUFd00iLR7JNXJX9U8C/5L38k74h9dlZvFFeP2CwAgWa9QU6JFSd0YTXti3rjhFi46KPzWCU10qifVasIsLu8ly7CgAYJQAAPJKx5OLU4zwJXrBLICeHwVSRo1NmKulMQfb+r8NYLEhbH6JRWla1T9Y6cn50552BgjYfiY/ORR0OhNB7hvwvn4uK8cYE6I5oso0CE5x2BfNnW1tdTYjuAC/TMmnbltRIn0XICAU28YOpF0w80SvrBYplAFpTELMKYJZDPdgUeHRKE0dzz+UOLwMoZ4ANYu+J763CZWH448VAc3AWFLCB8lefmMGXBpiqYKSiL2ZmYDWIJTbthGE11gk4m2ELBzMZv2BPpdt2HUc+9vbsf/lSBHJAZTdBvmvanFi8/EcWZ70pyMKUpBktqiSmvnBPyiQVTFszgoVUly4A9gdkAfxtGi2fA4conE3fK4oXvTegcTPiVQlST+GPz7LGtFRhD9y0j2g+eQh5S7ipYOGQp9W+kfxanJkL0nsahv0TyCUF3FijJbUZnRAHmtCuwVpSfIteWYikwsT4V8ZOymnq+YC3QwkhdQr4zrJGBReOt9ISsqxjUgoM8nVdROC96muX1hOgdV7LGF2wLoQ5qtv+vscmgx3T2oSWyOC57H/rdnjt6GA7v7sfu1c1dZ+yOYR98uO+JlD3RZPL8AUq1E0XeGs2VWbNib77waWRfogZdOljmwIhtKARPGoJPFl/SyOMEz9S/Ql2CxdcqgSbfZkDopkL/LqdXBSI4R/2YfoX51OdlmTtQcAk8UAVgc2nJklVasVS95pKvp2vVk6oESxWUcolsVdVEaTVwZ4Yf8H2vpgx9fRR680j0zVHo9uHoeTe1rEp2nlqyoETFpHCeGFhrM2uDLHCzIgsHNrkn2e/gyGVpN8ODDGpFKZDflyFukUxWI9QEUiM695AUbVmnQpJXDTSfpUjwo2Pb1YZdFFc/1nFvJljepITRPBRjbcawD8XYbDEOk3/B8L6KI5WfQRNHDe4XGnOVn01ooNy8+KnmDu973bvb4cO4d5lZYm56jqii1eFu0c43DAcSFy99TCg+WVigYldBMwI8I9mExjypyb7e3uCxEUZE1MvYi2b8IG20tw//yV0Yd+6ve2O3e/cwGLdJrSZFRC64OTW4TH3Bq9y4d1sdtZKvwDTUtdTJ+0DGUShvZ23xWgy8tPqnzsgd3o364/7dYM+t4X1+a8gTDAEcynuSalLc3haKjm0pJTFVLzH768qk7CTHUvYAk6uDu/vbzs0eRy8Mjg74Pc/gZpn59U5qFB3n4rgzuO4Nxnt8/N7g41jcPQ1Oarhf76VOld7NVcimxFss/LW4rIJOcEszBnhJEmW7egYkDrT8ytz+cg8gTD27/sPxhYdimVYzVrfiw2G1yMHFGKGqUyg1Q40driqrCY4sRwxVmUqqmZJdVvdqyk5hFCvt+bqw70T8wGAXkqvaVYwHDlGjX/qDQX9wrRnAWnwAWzq2nME+h4xXflnyTB3VXsQRWRjVfuz80rt0O4P+bYe7hSyk9wcjyEFXr/89R1WGWGlCJ2BzMV1Jd8wt7ahT3eg3FgRAl/1WHJCh+Tj47vRmxrZ12GibsF+Lnpu+F/o8hxYghf1ItTM75Y8Mgd66+KOD71KcR25euVZ0WfzSuAXRaGGd/owKbr0kYikRb08IyzpgpxLU9y6f0QPxhmcn+3WcVXZpa2gKhkPiLmOTBcoAvpsgjq6piVyDjrnZRk1Vw4KVnBV1a16KL5ryefwzXnnE0mpRJlVkTmGF3lKcvRDNWss3UzmefHGxaubzq7UDIQZ1y0pLi/nkkSHYhyE0zQjOYQi2DkGeq1hjFp+iVk3cGbP5S5DsMskpk5r1F/jX5r8O/jbxFV4+d/8Fddy0/85CztD/vZVsmKOPK2zdTH1cYR+JoCnsIxEcDUKl0KHHR6b1ZqvO3oxw/maE93sj43xVZC7ebNX3b6+6v6BwdZVb+ef2VHG3OGhr5S8bpql8PcGqas/nVxeUEHeXvO5LXHT8Uc2/TsJ+/GejwP2P4WaW+V7NPj0I07IyzW7geZKKQbMEG7ZLfqDIe3g9rdQMguui4NoouCkKboyCL0VB/n6Mz0Li6mmcg3gI5uBoHgacSjMR/KgBwPnXJy2qefY1wBfmV6mjQGurUyj/9AcSIhc5XWS7iolv6ybJnUUKs7DyVTvNNNSrfEO9yl/74ScwKrvIk+1VPmFzOBbndMqW8/yCH08iSgNxZO7yAphYVlTwdueSggFN1YCuN6eRpxjAowxw8PcDo9vbQInRD1Za3jAKPxsZpkUIaFyYMQuLM68n3H6Yn43Bmni+Jlo0hfLgo9cuB18537DkkkVGXjf0Qw3Xm39iUBSj39ZG3nUULoNpmf0UzgygwPnRizV2AqMz1UAF1IuuPA3SCuMYRns+EcuutsnKXUKseXeiy2IzK3dmH3qrH6jNJ7e4jCK2SS60bb/8szJQZR9xsvnrcP4OxuoHpRdChRcgYjMpiCkWQpOK42JbNvUX/o0Dbt3/E+dqURq/6J3ukGDD/YEUae3KzN++wQUNCrfAqvNvXOozRBliLfzffkZ//RMa222u/CEAAA==")}, + {"frag", GzipedString("H4sIAAAAAAAACn1TXW+cMBB851fsI1QnBKRtHlAj9S7qqVKqRrm0r5HPLBe3/kDGpndX5b/XhpBcUjsvWOx4Z2eHIek0UtYzJeGe7e47aLkipk44OShr0h4NfIJiAVsmGyZ3/iUDK1mrtIDVas3VlnD4m0zNAAPS90DpnWEC60Rgw6zonqo91Yhyw44BTBLDBpywh7cElKcCVkSgJicCBDEjnTt/MvxTx4Cvcghi11r9igKxJk8YbZzBF83z1nTUf636qFmU8IBbuO9Ub3UAEYTJK2YumY5iK8VVACViy1Caze9DFFtrZWXzP9yqXYTUIUvSB3Q64HMToJJI9BcSYBq8j0qbMR6ueAabm/XyVl0x3wLpWNoRIUjm8qDRWC2nd3g3na5zzhVX1OXNpX4MNJN+SgXDnR1eRa+MZH/JlRI/lt/dqBdCDe7DGS4jGe6J6Djq6hLc3c6aG+wtN99IV4e1uso0qdVkNn38aYFbwSSRFCcrqMdOrGiUScfawvefpUVeldXHBRT5efmh8mdxXlVZ5l0aFGvApyX1BM90ToJb0NFh+krtYjQvy/eHY52wFtJnNaefaVKQZXAxO5Uf/YinZdwEv92stMwLLwiQ9xi65kSPyh8fj9eTh39CN68C2AQAAA==")} +} +,{ + {"vert", GzipedString("H4sIAAAAAAAACuVZX2/ixhZ/51OMVFUyS0LBJtm03KsrSkhKmxAUyPZKq8jywoTM1tjUNsRQ5bv3nJkxHuMZFjZtX/pC4nPO/M7/mTn2NzRNaBCzMCDXN27v/2M3fvamNHJpuvDZhCWuF7HkeU4TNnGT9YLGLgsSx/6BRPT3JYtoZRHRCeMAz2z2vCBPfugl7YryQKZ0Ek6pYxNLUFd00iLR7JNXJX9U8C/5L38k74h9dlZvFFeP2CwAgWa9QU6JFSd0YTXti3rjhFi46KPzWCU10qifVasIsLu8ly7CgAYJQAAPJKx5OLU4zwJXrBLICeHwVSRo1NmKulMQfb+r8NYLEhbH6JRWla1T9Y6cn50552BgjYfiY/ORR0OhNB7hvwvn4uK8cYE6I5oso0CE5x2BfNnW1tdTYjuAC/TMmnbltRIn0XICAU28YOpF0w80SvrBYplAFpTELMKYJZDPdgUeHRKE0dzz+UOLwMoZ4ANYu+J763CZWH448VAc3AWFLCB8lefmMGXBpiqYKSiL2ZmYDWIJTbthGE11gk4m2ELBzMZv2BPpdt2HUc+9vbsf/lSBHJAZTdBvmvanFi8/EcWZ70pyMKUpBktqiSmvnBPyiQVTFszgoVUly4A9gdkAfxtGi2fA4conE3fK4oXvTegcTPiVQlST+GPz7LGtFRhD9y0j2g+eQh5S7ipYOGQp9W+kfxanJkL0nsahv0TyCUF3FijJbUZnRAHmtCuwVpSfIteWYikwsT4V8ZOymnq+YC3QwkhdQr4zrJGBReOt9ISsqxjUgoM8nVdROC96muX1hOgdV7LGF2wLoQ5qtv+vscmgx3T2oSWyOC57H/rdnjt6GA7v7sfu1c1dZ+yOYR98uO+JlD3RZPL8AUq1E0XeGs2VWbNib77waWRfogZdOljmwIhtKARPGoJPFl/SyOMEz9S/Ql2CxdcqgSbfZkDopkL/LqdXBSI4R/2YfoX51OdlmTtQcAk8UAVgc2nJklVasVS95pKvp2vVk6oESxWUcolsVdVEaTVwZ4Yf8H2vpgx9fRR680j0zVHo9uHoeTe1rEp2nlqyoETFpHCeGFhrM2uDLHCzIgsHNrkn2e/gyGVpN8ODDGpFKZDflyFukUxWI9QEUiM695AUbVmnQpJXDTSfpUjwo2Pb1YZdFFc/1nFvJljepITRPBRjbcawD8XYbDEOk3/B8L6KI5WfQRNHDe4XGnOVn01ooNy8+KnmDu973bvb4cO4d5lZYm56jqii1eFu0c43DAcSFy99TCg+WVigYldBMwI8I9mExjypyb7e3uCxEUZE1MvYi2b8IG20tw//yV0Yd+6ve2O3e/cwGLdJrSZFRC64OTW4TH3Bq9y4d1sdtZKvwDTUtdTJ+0DGUShvZ23xWgy8tPqnzsgd3o364/7dYM+t4X1+a8gTDAEcynuSalLc3haKjm0pJTFVLzH768qk7CTHUvYAk6uDu/vbzs0eRy8Mjg74Pc/gZpn59U5qFB3n4rgzuO4Nxnt8/N7g41jcPQ1Oarhf76VOld7NVcimxFss/LW4rIJOcEszBnhJEmW7egYkDrT8ytz+cg8gTD27/sPxhYdimVYzVrfiw2G1yMHFGKGqUyg1Q40driqrCY4sRwxVmUqqmZJdVvdqyk5hFCvt+bqw70T8wGAXkqvaVYwHDlGjX/qDQX9wrRnAWnwAWzq2nME+h4xXflnyTB3VXsQRWRjVfuz80rt0O4P+bYe7hSyk9wcjyEFXr/89R1WGWGlCJ2BzMV1Jd8wt7ahT3eg3FgRAl/1WHJCh+Tj47vRmxrZ12GibsF+Lnpu+F/o8hxYghf1ItTM75Y8Mgd66+KOD71KcR25euVZ0WfzSuAXRaGGd/owKbr0kYikRb08IyzpgpxLU9y6f0QPxhmcn+3WcVXZpa2gKhkPiLmOTBcoAvpsgjq6piVyDjrnZRk1Vw4KVnBV1a16KL5ryefwzXnnE0mpRJlVkTmGF3lKcvRDNWss3UzmefHGxaubzq7UDIQZ1y0pLi/nkkSHYhyE0zQjOYQi2DkGeq1hjFp+iVk3cGbP5S5DsMskpk5r1F/jX5r8O/jbxFV4+d/8Fddy0/85CztD/vZVsmKOPK2zdTH1cYR+JoCnsIxEcDUKl0KHHR6b1ZqvO3oxw/maE93sj43xVZC7ebNX3b6+6v6BwdZVb+ef2VHG3OGhr5S8bpql8PcGqas/nVxeUEHeXvO5LXHT8Uc2/TsJ+/GejwP2P4WaW+V7NPj0I07IyzW7geZKKQbMEG7ZLfqDIe3g9rdQMguui4NoouCkKboyCL0VB/n6Mz0Li6mmcg3gI5uBoHgacSjMR/KgBwPnXJy2qefY1wBfmV6mjQGurUyj/9AcSIhc5XWS7iolv6ybJnUUKs7DyVTvNNNSrfEO9yl/74ScwKrvIk+1VPmFzOBbndMqW8/yCH08iSgNxZO7yAphYVlTwdueSggFN1YCuN6eRpxjAowxw8PcDo9vbQInRD1Za3jAKPxsZpkUIaFyYMQuLM68n3H6Yn43Bmni+Jlo0hfLgo9cuB18537DkkkVGXjf0Qw3Xm39iUBSj39ZG3nUULoNpmf0UzgygwPnRizV2AqMz1UAF1IuuPA3SCuMYRns+EcuutsnKXUKseXeiy2IzK3dmH3qrH6jNJ7e4jCK2SS60bb/8szJQZR9xsvnrcP4OxuoHpRdChRcgYjMpiCkWQpOK42JbNvUX/o0Dbt3/E+dqURq/6J3ukGDD/YEUae3KzN++wQUNCrfAqvNvXOozRBliLfzffkZ//RMa222u/CEAAA==")}, + {"frag", GzipedString("H4sIAAAAAAAACrWTzW7bMBCE73oKHiXEVu3UN6GH2kGDAgUaIG2vBiWtbLYkV+CPIqfou5ekYsdpyAYIkJMgDefb5e4o6xU0TDOUZM92+550HKmpMk4PaE2uwZAPZDEjNZMtkzv/UhArWYdKkM3mmmNNOfmdTWZCBmhWpGm2hgmoMgEts6I/fdWNApC37D6iSWrYAJP2538NLM8b2FABip41IKgJOPf8weCuSgmf5RDVbhT+TAopkwcmjUfxifl46yb0f4M6OayG8si0YOxRWxVRBGXyCzNXTCW1DXKMqFTUDKS5/XVIatcKrWyfyx3uElCnrKmO9OmEj20EJYGqTzRCGvwcUZnzeHBsXGxceEMumfSHL8mwtcM/CVomIrzmiOL7+qtL0JN6BsZ4FJeJKGoqeg7q8orUHvkNRhPWE23UfZnKdIoeB+fe35MW7+REWhna6zxcxw6z6V57yruejcAL1244r61wRDMVy88rz5yNXARfPj8Zy3H2SCkPRVGOh/sq85iLlzlvgZm/njN/EaTAeWSY0juyKhdundmArCX+R8iL7GGKCrTlfrnPxr/1s1+WC2d/SIQDF6Xa1VV22p0z+mXmEyacL1ylv4niGtFbBQAA")} +} +,{ + {"vert", GzipedString("H4sIAAAAAAAACuVZX2/ixhZ/51OMVFUyS0LBJtm03KsrSkhKmxAUyPZKq8jywoTM1tjUNsRQ5bv3nJkxHuMZFjZtX/pC4nPO/M7/mTn2NzRNaBCzMCDXN27v/2M3fvamNHJpuvDZhCWuF7HkeU4TNnGT9YLGLgsSx/6BRPT3JYtoZRHRCeMAz2z2vCBPfugl7YryQKZ0Ek6pYxNLUFd00iLR7JNXJX9U8C/5L38k74h9dlZvFFeP2CwAgWa9QU6JFSd0YTXti3rjhFi46KPzWCU10qifVasIsLu8ly7CgAYJQAAPJKx5OLU4zwJXrBLICeHwVSRo1NmKulMQfb+r8NYLEhbH6JRWla1T9Y6cn50552BgjYfiY/ORR0OhNB7hvwvn4uK8cYE6I5oso0CE5x2BfNnW1tdTYjuAC/TMmnbltRIn0XICAU28YOpF0w80SvrBYplAFpTELMKYJZDPdgUeHRKE0dzz+UOLwMoZ4ANYu+J763CZWH448VAc3AWFLCB8lefmMGXBpiqYKSiL2ZmYDWIJTbthGE11gk4m2ELBzMZv2BPpdt2HUc+9vbsf/lSBHJAZTdBvmvanFi8/EcWZ70pyMKUpBktqiSmvnBPyiQVTFszgoVUly4A9gdkAfxtGi2fA4conE3fK4oXvTegcTPiVQlST+GPz7LGtFRhD9y0j2g+eQh5S7ipYOGQp9W+kfxanJkL0nsahv0TyCUF3FijJbUZnRAHmtCuwVpSfIteWYikwsT4V8ZOymnq+YC3QwkhdQr4zrJGBReOt9ISsqxjUgoM8nVdROC96muX1hOgdV7LGF2wLoQ5qtv+vscmgx3T2oSWyOC57H/rdnjt6GA7v7sfu1c1dZ+yOYR98uO+JlD3RZPL8AUq1E0XeGs2VWbNib77waWRfogZdOljmwIhtKARPGoJPFl/SyOMEz9S/Ql2CxdcqgSbfZkDopkL/LqdXBSI4R/2YfoX51OdlmTtQcAk8UAVgc2nJklVasVS95pKvp2vVk6oESxWUcolsVdVEaTVwZ4Yf8H2vpgx9fRR680j0zVHo9uHoeTe1rEp2nlqyoETFpHCeGFhrM2uDLHCzIgsHNrkn2e/gyGVpN8ODDGpFKZDflyFukUxWI9QEUiM695AUbVmnQpJXDTSfpUjwo2Pb1YZdFFc/1nFvJljepITRPBRjbcawD8XYbDEOk3/B8L6KI5WfQRNHDe4XGnOVn01ooNy8+KnmDu973bvb4cO4d5lZYm56jqii1eFu0c43DAcSFy99TCg+WVigYldBMwI8I9mExjypyb7e3uCxEUZE1MvYi2b8IG20tw//yV0Yd+6ve2O3e/cwGLdJrSZFRC64OTW4TH3Bq9y4d1sdtZKvwDTUtdTJ+0DGUShvZ23xWgy8tPqnzsgd3o364/7dYM+t4X1+a8gTDAEcynuSalLc3haKjm0pJTFVLzH768qk7CTHUvYAk6uDu/vbzs0eRy8Mjg74Pc/gZpn59U5qFB3n4rgzuO4Nxnt8/N7g41jcPQ1Oarhf76VOld7NVcimxFss/LW4rIJOcEszBnhJEmW7egYkDrT8ytz+cg8gTD27/sPxhYdimVYzVrfiw2G1yMHFGKGqUyg1Q40driqrCY4sRwxVmUqqmZJdVvdqyk5hFCvt+bqw70T8wGAXkqvaVYwHDlGjX/qDQX9wrRnAWnwAWzq2nME+h4xXflnyTB3VXsQRWRjVfuz80rt0O4P+bYe7hSyk9wcjyEFXr/89R1WGWGlCJ2BzMV1Jd8wt7ahT3eg3FgRAl/1WHJCh+Tj47vRmxrZ12GibsF+Lnpu+F/o8hxYghf1ItTM75Y8Mgd66+KOD71KcR25euVZ0WfzSuAXRaGGd/owKbr0kYikRb08IyzpgpxLU9y6f0QPxhmcn+3WcVXZpa2gKhkPiLmOTBcoAvpsgjq6piVyDjrnZRk1Vw4KVnBV1a16KL5ryefwzXnnE0mpRJlVkTmGF3lKcvRDNWss3UzmefHGxaubzq7UDIQZ1y0pLi/nkkSHYhyE0zQjOYQi2DkGeq1hjFp+iVk3cGbP5S5DsMskpk5r1F/jX5r8O/jbxFV4+d/8Fddy0/85CztD/vZVsmKOPK2zdTH1cYR+JoCnsIxEcDUKl0KHHR6b1ZqvO3oxw/maE93sj43xVZC7ebNX3b6+6v6BwdZVb+ef2VHG3OGhr5S8bpql8PcGqas/nVxeUEHeXvO5LXHT8Uc2/TsJ+/GejwP2P4WaW+V7NPj0I07IyzW7geZKKQbMEG7ZLfqDIe3g9rdQMguui4NoouCkKboyCL0VB/n6Mz0Li6mmcg3gI5uBoHgacSjMR/KgBwPnXJy2qefY1wBfmV6mjQGurUyj/9AcSIhc5XWS7iolv6ybJnUUKs7DyVTvNNNSrfEO9yl/74ScwKrvIk+1VPmFzOBbndMqW8/yCH08iSgNxZO7yAphYVlTwdueSggFN1YCuN6eRpxjAowxw8PcDo9vbQInRD1Za3jAKPxsZpkUIaFyYMQuLM68n3H6Yn43Bmni+Jlo0hfLgo9cuB18537DkkkVGXjf0Qw3Xm39iUBSj39ZG3nUULoNpmf0UzgygwPnRizV2AqMz1UAF1IuuPA3SCuMYRns+EcuutsnKXUKseXeiy2IzK3dmH3qrH6jNJ7e4jCK2SS60bb/8szJQZR9xsvnrcP4OxuoHpRdChRcgYjMpiCkWQpOK42JbNvUX/o0Dbt3/E+dqURq/6J3ukGDD/YEUae3KzN++wQUNCrfAqvNvXOozRBliLfzffkZ//RMa222u/CEAAA==")}, + {"frag", GzipedString("H4sIAAAAAAAACrWTTW+bQBCG7/yKOYKCqZ06J9RD7ahRpEiNlDZXa4HB3nY/0H5QnKr/vbsQO06620iRckLw7vvM7MxL0imsqaZSwI5udx20TBJTJozspTWpRgOfYJ5DRUVDxda/ZGAFbaXisF5fMVkRBr+TyQzQY72Eut4YyrFMODbU8u74VdcKUdzRh4AmiKE9Ttqf/zWwOG1gTTgqctIAJ2bEuec9xV9lTLgWfVC7VfJHVIiZPDBqPIjPzIdb12P/t1JHh1UTFpgWDp3UVgUUTqi4oeaSqqi2lkwGVMIrisLc/dxHtSslrWj+lVu5jUCdsiI60KcTPjcBlECivpAAqfdzlMqcxoPJ2sXGhXfMJRX+8Dn0G9u/SNAiEuEVk5J/X311CXpWz+AQjuIiEkVNeMdQnV9C5ZHfcDDjeoKNui9TmVaRw+Dc+0ew3cRZGtLpdLyM7fPpVjvC2o4OyDLX7HhaW+54ZiqVntbNnQ3ORl86OxqLIX+iFPssK4b9Q5l4zNnrnPfAzN7Omb0KUug8YpzSB1gWc7fMpJe0Af8bpMcpKtSW+dW+GP7GT35eXDjzYxocNivUtiqT496czS8ynSA5LIp55ur8BXceI2xXBQAA")} +} +,{ + {"vert", GzipedString("H4sIAAAAAAAACuVZX2/ixhZ/51OMVFUyS0LBJtm03KsrSkhKmxAUyPZKq8jywoTM1tjUNsRQ5bv3nJkxHuMZFjZtX/pC4nPO/M7/mTn2NzRNaBCzMCDXN27v/2M3fvamNHJpuvDZhCWuF7HkeU4TNnGT9YLGLgsSx/6BRPT3JYtoZRHRCeMAz2z2vCBPfugl7YryQKZ0Ek6pYxNLUFd00iLR7JNXJX9U8C/5L38k74h9dlZvFFeP2CwAgWa9QU6JFSd0YTXti3rjhFi46KPzWCU10qifVasIsLu8ly7CgAYJQAAPJKx5OLU4zwJXrBLICeHwVSRo1NmKulMQfb+r8NYLEhbH6JRWla1T9Y6cn50552BgjYfiY/ORR0OhNB7hvwvn4uK8cYE6I5oso0CE5x2BfNnW1tdTYjuAC/TMmnbltRIn0XICAU28YOpF0w80SvrBYplAFpTELMKYJZDPdgUeHRKE0dzz+UOLwMoZ4ANYu+J763CZWH448VAc3AWFLCB8lefmMGXBpiqYKSiL2ZmYDWIJTbthGE11gk4m2ELBzMZv2BPpdt2HUc+9vbsf/lSBHJAZTdBvmvanFi8/EcWZ70pyMKUpBktqiSmvnBPyiQVTFszgoVUly4A9gdkAfxtGi2fA4conE3fK4oXvTegcTPiVQlST+GPz7LGtFRhD9y0j2g+eQh5S7ipYOGQp9W+kfxanJkL0nsahv0TyCUF3FijJbUZnRAHmtCuwVpSfIteWYikwsT4V8ZOymnq+YC3QwkhdQr4zrJGBReOt9ISsqxjUgoM8nVdROC96muX1hOgdV7LGF2wLoQ5qtv+vscmgx3T2oSWyOC57H/rdnjt6GA7v7sfu1c1dZ+yOYR98uO+JlD3RZPL8AUq1E0XeGs2VWbNib77waWRfogZdOljmwIhtKARPGoJPFl/SyOMEz9S/Ql2CxdcqgSbfZkDopkL/LqdXBSI4R/2YfoX51OdlmTtQcAk8UAVgc2nJklVasVS95pKvp2vVk6oESxWUcolsVdVEaTVwZ4Yf8H2vpgx9fRR680j0zVHo9uHoeTe1rEp2nlqyoETFpHCeGFhrM2uDLHCzIgsHNrkn2e/gyGVpN8ODDGpFKZDflyFukUxWI9QEUiM695AUbVmnQpJXDTSfpUjwo2Pb1YZdFFc/1nFvJljepITRPBRjbcawD8XYbDEOk3/B8L6KI5WfQRNHDe4XGnOVn01ooNy8+KnmDu973bvb4cO4d5lZYm56jqii1eFu0c43DAcSFy99TCg+WVigYldBMwI8I9mExjypyb7e3uCxEUZE1MvYi2b8IG20tw//yV0Yd+6ve2O3e/cwGLdJrSZFRC64OTW4TH3Bq9y4d1sdtZKvwDTUtdTJ+0DGUShvZ23xWgy8tPqnzsgd3o364/7dYM+t4X1+a8gTDAEcynuSalLc3haKjm0pJTFVLzH768qk7CTHUvYAk6uDu/vbzs0eRy8Mjg74Pc/gZpn59U5qFB3n4rgzuO4Nxnt8/N7g41jcPQ1Oarhf76VOld7NVcimxFss/LW4rIJOcEszBnhJEmW7egYkDrT8ytz+cg8gTD27/sPxhYdimVYzVrfiw2G1yMHFGKGqUyg1Q40driqrCY4sRwxVmUqqmZJdVvdqyk5hFCvt+bqw70T8wGAXkqvaVYwHDlGjX/qDQX9wrRnAWnwAWzq2nME+h4xXflnyTB3VXsQRWRjVfuz80rt0O4P+bYe7hSyk9wcjyEFXr/89R1WGWGlCJ2BzMV1Jd8wt7ahT3eg3FgRAl/1WHJCh+Tj47vRmxrZ12GibsF+Lnpu+F/o8hxYghf1ItTM75Y8Mgd66+KOD71KcR25euVZ0WfzSuAXRaGGd/owKbr0kYikRb08IyzpgpxLU9y6f0QPxhmcn+3WcVXZpa2gKhkPiLmOTBcoAvpsgjq6piVyDjrnZRk1Vw4KVnBV1a16KL5ryefwzXnnE0mpRJlVkTmGF3lKcvRDNWss3UzmefHGxaubzq7UDIQZ1y0pLi/nkkSHYhyE0zQjOYQi2DkGeq1hjFp+iVk3cGbP5S5DsMskpk5r1F/jX5r8O/jbxFV4+d/8Fddy0/85CztD/vZVsmKOPK2zdTH1cYR+JoCnsIxEcDUKl0KHHR6b1ZqvO3oxw/maE93sj43xVZC7ebNX3b6+6v6BwdZVb+ef2VHG3OGhr5S8bpql8PcGqas/nVxeUEHeXvO5LXHT8Uc2/TsJ+/GejwP2P4WaW+V7NPj0I07IyzW7geZKKQbMEG7ZLfqDIe3g9rdQMguui4NoouCkKboyCL0VB/n6Mz0Li6mmcg3gI5uBoHgacSjMR/KgBwPnXJy2qefY1wBfmV6mjQGurUyj/9AcSIhc5XWS7iolv6ybJnUUKs7DyVTvNNNSrfEO9yl/74ScwKrvIk+1VPmFzOBbndMqW8/yCH08iSgNxZO7yAphYVlTwdueSggFN1YCuN6eRpxjAowxw8PcDo9vbQInRD1Za3jAKPxsZpkUIaFyYMQuLM68n3H6Yn43Bmni+Jlo0hfLgo9cuB18537DkkkVGXjf0Qw3Xm39iUBSj39ZG3nUULoNpmf0UzgygwPnRizV2AqMz1UAF1IuuPA3SCuMYRns+EcuutsnKXUKseXeiy2IzK3dmH3qrH6jNJ7e4jCK2SS60bb/8szJQZR9xsvnrcP4OxuoHpRdChRcgYjMpiCkWQpOK42JbNvUX/o0Dbt3/E+dqURq/6J3ukGDD/YEUae3KzN++wQUNCrfAqvNvXOozRBliLfzffkZ//RMa222u/CEAAA==")}, + {"frag", GzipedString("H4sIAAAAAAAACn2SzU7DMBCE73kKH1uoEC3cIg60CIQEAvF3RZtk2y7Y3shxQgHx7tgJqUKxOTXNtzMebyYpDeZUEWuxptW6FEvJYNNEwjvXdlShFSficCIy0gXplf8zFrWmJRslFosLyRlI8Zl0YiEazI9Fnj9bUpgmCguqVbl9W+UGUd/TR4BpsNRgx77+CzAdBliAQgODAApsa+d+nwjf0hi41E2Q3Rp+iYKYyBtGhT38Je5vnbf5b7mKLisHGdgWbkquahMgCkhfkT0jE2ULlhygoDJCbe9f36PswnCti794yauIqSNzqAI5HTgtAlYawZxDwKnxe2Rjh/WQnLvauPK2vSTth2eiea6bnQZNIxWeS2b1OL9xDfp1nsVNuIrTSBUrUKVEMzsTbras7R1WtbTXUP6nn4X0mY/0gBvbft7gRd2bLubSQL/4hqkQ/gOPxu4yLV0XpoVOZDu/0U64Sburcernj7qTdxXDOD/jB2aV/UhM6+TG+7M8E/tDq71+mQdv7nk7B2myTe/0PvCoc5sMhly0r28lJgL4pAQAAA==")} +}}, +{{ + {"vert", GzipedString("H4sIAAAAAAAACn2TwU7jMBCG73mKObZSiVroiQghCAIhcahUiWs1ddww4NiR44RmV333nSQbEqjDKbH/b2Z+jz1BbqWggoyGN0rfcjgogy4KCmdL4WDrUCdok1dp3bPOSwd/g46rpFhDbgpyHBsFvLwCbWyGql2sgSNTqTnVKQoU1qZ0M2UENjjcwHIOpKGNwt2Q5hxcjcG+wDl22WOXjDl5jI2xiQ+86sF1A/Ye/3OFdI23BexJJ6TTzmip6cCFIY6flNmj+uoBdHmE2DnKZBRkMqEyy792C2Gl1Fv649E0G6pkp51+M7AaG4gxkxZHBjJ0bTr+vpL8jKaEZ115tY0175PCVFCTcDKwF78F96cWrf+NKSabJVB5uiWP/EZK61EyJP1C7oHspBYbZTwqZnviy99+1JPakzWlTs7lg0knkrJyj4XHJwt3iSeVlmgf0ZOpavpo7C8DxDvdi692Jfe6MpRAc2SYzfmF/BjQ/o9DG2U2TN0CVuFyPhDhsWZofFnhJ9xwxXAJt23B2QgNjwu4GK/rOVzDaCMKUrXb/Kg+6IuBrVsnvZ3mUIyPp/n0DxNZfjmuBAAA")}, + {"frag", GzipedString("H4sIAAAAAAAACu09aXPiSLLf/Ss0MREbAmMGsOnpWa9nAwM+ImjsAHfP9G50EDIIt3aExEjCgHf7v29mnVk6wAc90/uevwCqyszKysrKow6xN4/csRd7YWB99u4+z62pHzrJ8Z7vrMNFYsduYp1YtYp16wUTL7jDh5K1CLxpGM2sdvvcD28d3/r3Hke2rHt3fGSNx6PEm7nHezN34i1mc1UajyPXDYbeQ05d4CTevcvrvmxioE4ZaDszN3IIAzMnYeTg+4PnLo+LKi6D+9y66yj8V2FFERISLESUlQay7PWY8X8dxoXCGjt+jrTc1TyMF1FOzczxgp6XdLyosK4d+mFOrTO79dwgGf62Lqw7j8JFMMlWT8O7AqJQc+rEOXxCRWuSQypwnejMyaF0j3IMo4SpBxQeWsPB+elN2PMQxbJZ0Z0zmzkl0IfITRZRwJ+tMv8GzA161aB6NfzsTMKl0isynD0oSK59J3DpiKcBqO7l1VFcNeCsTVATrOy48+TzZTAN86EeCcJr/XA5t1K1/bPesLj2l4vr0+La3nW/X1wrFAEGidkStBJuwgeJcXwWhTMUwXDujF0+anxoYxw3jjPxYhwf3w3uks+2rD6Wo2qz+oNsb6qrkvWDZWfL1wXQqBL5bHLOlmHkTwRrrJvIyzBxogQKgcPUsIKmIZQt0aqr9UPFqldrmvct4iDkEZkx+L03BbTRoNvuXn7ojoYXrc7VLxs0+VBrMleM2JnNfTdqdLQM3jnzTUa2uZnEPOR9BmBGiImmNZ/7az5xWM9OPScenUGv+kDG8W0GJHQzjCuWFjAHKO0JGQcgAwkGvCiU4z1vame0sPpg/WzVqrVara4ooBg50S1jxIEqiF9i5DUm0P0blANRyg8MirV/QhrAgnJ21qWKCbNQ6oMwjZYYA7V6hbWHQy6UhbaMxcVyvnajeO6O0YdmBM0VHNuLUckUkhAXn39M/1gz9Am7QUagqLMPyxTag4H1QJHSBq66svYJ7HIj7DrD3gMOR75dZO0GTMQQVthpxBJqQkYoQpnHvjfXIqFPXCRpIeWrQArzYZnGfEgjErFAz1BTG3YBwFqrbZ7JU9MCJwaYL5MTYOQRlohKK90XoGCnSspWo1oDS4sGj+k5qV0StTaFu0mtr6Lkc3gXOfPP3vhJes3rxqE7nbasQgVZHVPA02LAtQSkYhkxGVA1PxCE0Avxtk19HT1I45GrdJEbL/zENHm8jIk7Raksu7cvWlU+huOkfBsXLdjjJIwunGhipeSpXByODjz3XdTW7aNCBiQTP1SXJRGrCaIoYUWezd4faAFO/lq1CT2CT6HYvBasBFrjmvWf/1i66GdUNSjak0XrLNQ6C/WQhXrgUCAESwgRno6tLwqHzXoasQOzJyeM8t/FNFWQ1RVz+qgOumxdsv5KnqVCcYGh/4X2pDb6YezGCRO4rDEmuXIn68wkNzAnYWIn7gr649rU9VcII6UK94fAMOf6B6vRbOqHN81agzzW3zTf1g9/hJISeirL9WM32/DWRnHqfdlTnY8Td64E+FAxJKBjJw6+Qa+H4TR51etvQq/D6RTiSqkPih0mtgbkRHNM9anBVbJFGgwoDNwbZ26dCM0TOKJSUBzxdkgTGKAJVMnLrR+Of8P4Fr/r4rshvg8fO7c4FamspH+VDfPMlKCeAuvSC+YdKB/vyguYEYLbOU+N3QhIsrcTng53KqddsaZs5wbFerJSsZx2g3I8VzE03fwBfu7garr5g/TCATJSfIySfrUsaGcWTihb3Frg4kFZWhkdGvJg6lfE8lZ22pQwmiUT9iOFVWYmDYtPHzPcrBU3a8rNWvlAJCxYqsj2OOmP6dWMtGds/PrqG/+v+0YZQNKJMOpR9wgcSn0vAB8Y4PvbwN8T8LWmvi4A7xjg+xnwzc5afB+J76b4fiO+fxTfb/8wp65knDY/o/d/tovPmsTd8PQSF6907OuwtgNPT0ZyN9HH0bcUMjZ3Ona74enNV5l+nV2w9uNup99OeHr7VabfS1nbTTS70Zq+PLbNt4gvj203WrWdhbgpy6Tp5luYF+QO+VbiuRZC082f6S+c5Zp8/mx97kzVdPNn3AtnW05q8rTEhCcQj00filcbX5jgkJBMwopW9k9otmLlpCs5TZOIT5LLaZTEf7toNKcPOY2SIHNjo49rM6cLOW2qgPY5bZJFU5ZkNZrpDFFu5G7bHKC7tU/LG+nG5Gva+IdsFYgzFNn0cid7CObe/x+6k7Ch6bz9hAm300/ZS8ibD3mbCq/z4RuYDxOq9I/bBJcomdM+aiSJJubMIKkttzCUuQs0y/z1mQ0rOX/2RsYkP39Iz7U/ZiPjGcx89Y2Mlwno62xk7EROX3kjY5INk5+gVDnJ3hMJPnoj4/mMbt7IeDG/L9rIyDE538SWRpav521uFLnq7C7Hq7N+ddYbnfXrjsuftuPyfEf21XdcduL3d7zj8gJxfe0dl52M5I53XL6F2La507Hb8Y7LTqffbndcdjP9drvjstPp95V2XJ4XdT56x+XFwXLBjssz2X7sjsuLpVKw47KrJCdtJV5mIXJ2XHamFvk7Li9Xi/wdl52pxeuOy+uOy5+14/K9G0y8qbzH937YHV2e9jbcvjvSt+/Evbv24tZl936Dey8Kg5kbJOLOyDRy7m747OiFE8vWF/VgzvDJAfyF0UTel/HDCbkgmyhUm8ELUARSN3MKmmA8yUYOX9bIIXR47ox/G5yfdkX6Ht3duoQGPlbhA8Q6D5fgMkFtWRle72VeEy8eNd6yG1FfqKw7l2dn8P2udb1B5G8KRQ4jN13ELrvnKAeSf/Gunp//+i689XzXssWMDRd3nwM3VjeU+uGFkJH87os1CPi1usDsLArj2O5XrAs1768C950XLGJAHv4eiX0YgK4gioJyoEK1B4JQvyVAAABAAqocWYQ5rIPXZFNN7ANw2Qq0Hs9R1mTZxfHHw7k7Xvh43fppfZUXdymvODvYCkijiZZTydEmRBk57LNWlNNB56w1n0fhStz5jgVPkoUcnj6wfa0wiBNxWRmjJRZ6HbDY6wCMc+PHJvvR/LHBLtY1GnjljeDUJQ5DAYijRpOFZkecwFFJXuNKDQq0tg/oasxqtSNmcAI7gmwfBg0dj7uaN+yDn6qNt1CCHJd4DaBGVbkG0TrlPDQY30e8dQRkNBESb2K2TiHpLmPOj/dMm7gCVFZSqt4x3lO3kmUtAAI2NopE5ETCWTTonvW67ZvLq/6o0+1fXQ67fDjO3aQb3A/cqY/rZGHwi5d8fufNzzw/cSOYW3yMBoWDM/Pm7XARJPJ54gahF7uXQeIGsZesceRShlMhpuQsSeklJz/BCWLj1JmcTVb2ACJu+LGGH0y+9VqNuGXAP+VLRWjmmZBY9M3lyKgR2cnRxtUldwJIppm0TWtdQREgy/uyGYk/ZZJiFEiUY6ICrCkDXJJr7PGmmVU8IQbU5uVoJATtLIisQcqYRpi06JsVbF2TpWgA0rqSMpZkaVdTqlgUuJIddcmWwEYl4iMiP3QDyr/GSbQYJ9YwcYKJE02Gi2jqjF252uv4t+4kFMu08xBaAW0Vj/ySsHhwZ14ce/euePQx1pzpPTj5PErcWKlaxu7O3MTxfW+sjnyPx/4iZi1+EQPfbitOIWCAqYIvyrDsNPt8+Tp7aP/QEp4JQ+Uq751wkDZflI2rkgu5Oq2mOVdxKdUjmBaURCUHtQ84+i51XOW/Ze0Ho9ZYPsbFb+RFilz5rj4izZyV7dzGbIqC//uAOTEfXcKrNvm2NvZxlfqJD5KTnsHJgfFGFHGPmbsnA64H8/KD5uxCcCa4ulBMifqeWd9T9Yz01Ascn70GA51vj+950HeviGFKly6PjXFth0ESeTjLRMGxMsa9y/OLGwhorL/8xfoOC05bN+2Ly/45KwAzcXY1+KU16IxanQ5blo2rhtrqNybgKzcouxoQmeTBK87DFE8/nFiH1fpRvflT403zsPmTmoyGmukeEP9CwwjbHETt64UcIsaMJmOn2NhPN1XKpF24vZH/Bg2UFRR2+63THkaJA/lmDRQYDBuTEQpIGJA529bZ9pYLsk3UV9zMx9PczQVxJgercVvmp5Lmu+AGjz1n2x5s5Uej1rajUsRiSDz7JSAVEFoK/sAcH9n+Ujs3SxaeKUOcHrjyiTpuQ5StfJIeYSmuaWt2yzLmJliOPgYzfJ+MaYUzu+2AFgjGxvS9Rdx2jVOvKxL+Bmhm3GhBmsCGW8f9pmfW5XyEc0lw/6xZJZ5X4ysnp+EMf6ohTY9Kp9rAMGMRD8Psgw/IW+l4a/QGYQYQ2BrDDVLmNiPiJRrAN6pDTIBAe8aEtz0wIsS5XUxRL4h/SBeIgHm7lBcJZEiXg+VKligp5PyIS5lCRVuSiBp/Vol/zyUihlhb/hQx6ctTtEwicVXHJjowOrI1FPHjDs2Dry+vu73Lfnd08/G6i8Kr7X0PQRcguhZzJsPRdXcwum4Nh1ZdCK4YoJZa0RAmtN17P7zpDrod7p9G7fe9Hvok1pyRejcKX+h2FkZLsEFsgU+9futevGCK2Qowrf9McfRJvrRFgDBRbAPCZbqBE9y5reDOd7dBQ/SQA/Ll2FwLGM7CMPnc8eKklSQyR8aXVUF+LRMcL7iHJ6gfQNC3IC+9mjILzNw9QwBdSMEq58aaOZPwPD/hMZ8gUhY/cnM9il02HnWyDybhmd1wEojhFw7aEbJZvrIVPnBUL+MHsESBwR8Y8pMYViXTmOoLwTd4Z2PKmOdBoViL8FkYqBapPA7H3rGXLrxiy8a6W+OJWIORNHp6EcboMR8NAC+bDUCwYtLOGxvbEAilTGfzY+ZbforRmkw8PM3yzaYZRbEvKFEq4PyfykqMGFvKAyq9ILGCxYyZu5gFZDmm2vp7xgT/FaZEYlPjVPvE3CSYUctGqh4GUMfw9bc0MhTu7+PoYvzoWT+faA5K1m3kOr/J9yv23vOoVdld71NGcArWkDWgyq4PL1I1Rqo1TOdSw14q2Rqms7FhOh2TdoLPT2gaqbwv6YRdmA3SmZTxx35lwDlJjV3WvyWs5/uLmZXKhXBmGES4/TOKKpLpErUiqv6ShSvadhazzV8CJkypgQ/mNFVEWuJBX8rQVtIIcgh91O/HZnFDTOOGIo8TR4KoAi11YiV31eLLIHAjMsoHVLO50mnNqJPzhvHVImGYxRJ6IANLrDEVr3j5nmLkQFEupZGv5CntA9V4ys6zkUDpEzcESlmxcjuV8kEp76MWvXVYQ/rKwxygxDL1R+e9GwYFU+JiSS5pSvzCxLb49CbNoA37/Iict4jqZpqPIMLy4iIiJPMl45Sf9EIUP2RLQhQyO6KYEnDjwoIANCmZpQ82K0vktXqZXKAmN8OeGK3XzWi9ntqbBBcxCQN/bd0uplOYALej8Zj7j1Ne8G8eSujyf346ttIvdTaoNnOpQhYEE4yRuATIsasbWKCPywXZ2tabbW2dR95ENyS7kgIQzYg153abVcilIjK78lKTjZlINvFgeYZsiLMh39w584JTTJFjYanBmslnjaN4BiwmN34k4pg/yDFiGKIf1p2biJ82A/LwnYqykvF1zHW9SroKsiVDfrRAHcYNvsWnNLC0ZHng9Sy4KaACvEYWD2RXAHyIwGLaiO582VNywu6rBy4AMfwoBq4Rd1B1z7xijm6IAmiD0ISP4z38rKqrPoIIBh+sQjJKqvTheE7gCx814BCpSsV3V5zNGN8dXLHIKCPHgkD+dGEoeCqYgX+iLQhl+wdvgHVbHb1WLiAW7pQ92Y0jfPelH96hhxHv8q6u+Q0o+bhSXlWczD6wNXI5jbx6DEFF0V278ubggT1WL2AHsopzdE6shw+sX7h4hME0i9GgGUkBWYlF4oZ8cnOqUzWOnSMuIi1c+Wrzww4Z6ZksZKRNzrjLQ92sGucCnmoZu57PjkOpd+pXVyAVLsj6m1Ie3sd8vLXCe4toC2ZJPK4eKB2WryzYtrPqEN4T+EEevdKMVYzmMG3iPSxJY8NrcSm//gYn49tFia1zsMaq+MpbXi5L8Ly6/L1Sshdk1AmVdlsI7zXN3UGayyLsHSe6qdFPz5Y7f3RmzhVbM632201jysloOy1NtGiMptWGcRVJ8kJlyQueJtdr7NfW3Jgh+srwcjZSxpiY+Qo4z2PTdwoBCAerSZWMxDvjX/+w3JukWDvNvjd59W87Ad/I+f9ADp7VpUel4Zlw6hGZ+EZRfTvJeEHXnpOP58S2z0nJN47Ra8K904Q7b8i+Ss7NtKXV7g5vwoDtJdvisCwA80OJXIfwNOCYU2Be8y33ePz8IR96fI99o9qsm6WnbKO8dmiWthnsUaq0wzfVfzJLu6y0fqQ3IcZCSnaLvWSeidE6LfH/VpF1bVLXKcFHt0TiMfTmMCPnC/nqDNVjspF70RlwAYjTZEROtirXu7MUNP49SgwYGRmKf58R04Xv9Z6Fd7Y8wqFu/4p/F5mHyplA2DQCMyx24JxgbAZTFWtJ4/FpeMf+qYVPR/E/R9qLQUE3mJiVaxLA4iaRLYAOZNNMwqpQtsCMLQZBJd2x7mr+yF7hHy3hNpJiBYJjbYe396LDT+SZAA9Zmck9viK5kQ7xWYJZh+StbB1VVZtAzF3N7QNJu0zY0CM9NYQx/H3hRO7k/5FM8qSzXVQ9Z+3uSk4joHITzo3KFa1kjt+oXstr8s7sF5bgRuG/rNR9c/DDYKAIQHXNLJRAlYmxQF0qFFqhUEQ/Onh4t0NnNoWuGPykBqGhDwhzMh8r+IOJGM+r3kV4clSsqete4LVnISCZTyzlzX1SLkhiQizFecD7tEY+tBQlI6mWceFFkCiTX+y4lLogqBthIsmSwOIvGr6QWSKFlsmy2fcs66YITx/X32PCOeapsuUDSaaU2xsEVbBlS/8CqeCUsyUTZUv/wrpSrsyQ3JM6ms9RwTCJcEZJh6FyfZJw3+EACWWRdsdmDhCj5n1LdraDistxcFElp5Sfes9qL+21bIHrRMr8TPNty30I6Tg49ZtBqz886w5GZ1fno9PWsKuMTMUKFzLg4EdTcA2MxAKAwQ8uqGMw2nfzA4nfu34GvK7BhUcshm0YsMRhFKMcEm604VTwsavreXAvT6RLgbSur3sftTS8AKWg46GKKRESD7K4UhxwlP+uKI436p8CTZbxE19i48MPx/JECrgVL+A3we5Hi3uVg3S6Hy7b3VG71R+ddvvds8ub0dng6t3osn/9/mbUurlptS/edfs3G/ZSang2B4K8EQTMzvgzHugbeWJVhPxTaLy4nTsxJHQYD97xTZcRXyHL/hGd0UB9QwP1LQ3IjGFLE40NTTS2NMHXVrY0cLihgcMtDcgDf+L6GarchtHIXGJrdJ4o7k0UHivPTTQeJ7BNFFISUTub3z1Bo/GNOKPRh+5giCdiR7jOd9Ss5U8dNWP52jdLL2Ryh7Mcj/BbNs7dzFrz02cauanCDx4LpeiFzsTOjKS8QkQGpgCFQEgkNRIFKKpeIhDBF6AQCPMoMO2RPEqd6U0FjVN+l9I4pNbAon1K46g6A8PsVBqH1EoseddILPCjc9cTS69S8DhaMskDVHrK2axeYmUg/7BScSrR5O6BUcdwJIPonzWvEk8dJE5VL0l8Lw9+FnpvcyEenI1CkjIk/1anflqZ/91k8Xo5Z21fkpGuL/delI1rQHrPZv8phxmKdodMmlJhC89MZsGZJmS9vHTtRE66b3phhMOVnm4klCFCIUuDxIKRvAoekfwXugyqTel7AAA=")} +}}, +{{ + {"vert", GzipedString("H4sIAAAAAAAACuVa3VPqyBJ/56+Yqq2tCgdlSaIez+XuAyIqu4qUoOdWWVYqklHnbEjYJCiw5f9+u2fyMSEzHDju3Zf7ojLd8+uP6Z7uHvyJLhIaxCwMyPml0/vP2IlfXI9GDl3MfDZhieNGLHmZ0oRNnGQ5o7HDgsS2/kUi+uecRbQ2i+iEcYAX9vwyI09+6CbtmvSBeHQSetS2iCFWX+nkgETPj26d/FXD3+RX/pF8ItbhYbNV3j1izwEwmM0W2SdGnNCZYVrHzdYeMXDTvf1QJw3Sah7W6wiwvr23mIUBDRKAABpwGNPQMzjNAFOMCsge4fB1XFCIsyRx+8D6eV3glRskLI7RKKUoSyXqEzk6PLSPQMEGd8W9+cC9Ia20HuCvY/v4+Kh1jDIjmsyjQLjnE4Hzsozc1n1i2YAL65k27dp7LU6i+QQcmriB50beHY2SfjCbJ3AK0sHMwpglcJ7tGny0SRBGU9fnHw4I7HwGfABr13x3Gc4Tww8nLrKDuSCQBYTvcp0CpspoyoyZgCqblbFZwJbQRTcMI0/FaGeMB8iY6fgTeyLdrnM76jlX1zfDixqcAXmmCdpNF33P4OEnvPjsO+ly4NEFOiuVElMeOXvkkQUeC57hw0GdzAP2BGoD/FUYzV4AhwufTByPxTPfndApqPCVgleT+N48fGgrGcaQffOI9oOnkLuUmwoaDtmC+pepfQZfTQTrDY1Df47LewTNmSEn1xmNEQFYrJ2BtiL8JL52yrYAIsanxL5XFdMsNiwFWhjJW8gvmj2pY1F5Y7FHlnV0aslAfpxnUTgtW5qd6x5RGy6dGt+QB0ITxOR/LzHJIMdU+qEmaXCc9u763Z4zuh0Or2/GztnldWfsjOEevL3piSN7osnk5Q5CtRNF7hLVTU/NiN3pzKeRdYoSVMfBMgNGbEXBeaki+MngW1qFn+Az9c9QliDxvZKjyc8ZEJoprf9SrNcFIhhH/Zj+gPrU52FZGFAyCSyQGeByOUhDVkrFSvTqQ765WMqW1FOwhYRSDZFcVEOEVgtvZvgBtm+UlKEvd0I3d0Rf7YRubY9eZNOBUcvqqZEGlIiYBdQTDWmpJ62QBGbW0sCBS+4pzXcw5LRym2Ehg1iRAuTPeYhXJEujEWICVyM6dXEpykn7gpNHDSSfIXHw0pFnteYWxd0PTbybCYY3qWCY22Is9RjWthirHGM7/jd077soqbwGTWzZud9JzNeiNqGC6eXFq5ozvOl1r6+Gt+PeaaaJPuk5oozWhN6iXVwYNhxcPPfxQPGTgQEqbhVUI8AaySY05oeabMrtFZaNMCIiXsZu9MwLaaudf/h3YcK4c3PeGzvd69vBuE0ajZRFnAVXpwHN1HesKpT7lMtoVGwFoiauU5k8D1I/CuHtLC3ey45Ptb7ojJzh9ag/7l8PNnQNn4uuoThgcOAw7ZNkleJ2HigqsiGFhCc3MZvjSidsr8CS7gCdqYPrm6vO5QZDjzWGDnifpzGzSvxxIxWCdjNx3Bmc9wbjDTZ+0dg4Fr2nxkgF9cetVIlSm/kaMo+4s5m/FM0qyASzFGOAmyRRdqtnQKKgFS1z+/s5gDDNrP2H8oVFsbrW0Ea3ZMN2scjBxRghi5NWGpoY215UFhMcOR0xZGHyUkN32FVx77rTKY1ilTtf5fY1j2/p7NLhynqV/YFD1Oj3/mDQH5wrBrADPoDNbSudwb6FjEd+lfNQHtXeRIksjWonnd97p05n0L/qcLOQhOv9wQjOoKuW/5mjSkNsqkInYFMxXaXm6FPalqe60R8sCGA9zbfygAzJx8HXpzc9tqXCRt2E/kr0QvWN0EcFtAAp3UeynlmV39EFau3iexvfUuwHrl41VlSn+L1xC7xxgHH6Gwq4cpOILYh4PSEsy4C1SJDfXb6hBeKFZ+30mzirrK8tISkYDonrhFXmKA34+gFxdEVMFBJUxFXuNVkMC17TWVG156380FTM49+w5RFb62WehcSzDzvUmuLshWjGMn2ZKvDSh4tXs5hfjTUIMagbxqKymU8eGYK1HYKpR7C3Q7BUCGldxRgz+BT1auLNmM1fYsmqLtnVJbP5Bn9a/KeNP018wivm7r8hjk3rfxnIGfr/byRr5ujdAls1U+8W2DsiKAJ7RwRbgVArZejunjn4sFaHH0Y4+jDC542esX/IM8cf1urLx6PubwhcVeTW/rk7VfQWW12t/LHBW6TPE6wu53zRuiCH6F2KuK9Q0fAH+fxVHNbDP+sFbn8MnVlmez376kGoloVp1oEXh1R2miHIcF3ygpL24c1FraFhXJYZl1rGVZlxpWV8KzPy9zE+C4nWUzsHcRdMwdDCDTiVZiz4pQYAF98+KVH1s68GvjS/pjJKa215CuVf/QGHOItiXZx2HQ++rZok1zZJxNLOd+U005Jb+Zbcyp/74SMolTXyJG/lEzaFsjilHptPiwY/nkSUBqJkrtMCmFheqaCtzyUlBUxZga47pZErKcC9DHDw+47RvBuoEPrBq5I2jMJvWoJuEwJqN2bE0ubM6gnXH+ZnrbMmrq/wFl1AePDRa52CT86XLDllkZbWDf1QQXWnjwyCYvTHUks7j8J54FXJT+GzBhQoJ26s0BMIHU8BFVA3OnMVSK/oxzASXxFvNbsfyy8CcBJfw8j3Wqq3gy8qTlP5BXNLxWoVGl32zy/GV52haq8p7/XxeoKQvnJnt3dDN3KnbakkpWgnnXH3Qm2dKb7EFjXKdbxl4Dy6yeTFYd6msb6Uv/gFkn+Cu6iXJ5EUu9y4+N5sZdP45jG/iq0FbWvW++P22quAyk/v6meXlv5p5MX1wjeVNpcIP/TdgMoZvM4g3yUqmrw3T2AuE9Ieiad0lryIVxcV15YsguqHbzOyRh2cXY701K8XwxM99XI4GOipaWK/Zx0LFDapOyiqlFTD0k4hWxHdhuLfJorHSSMvxKo3n/x9UNRaBbMornlsKa6HjIglFhuqWqpkfi9ITdM6zdxAszbQWthpyTClj1bWh9W4HZWUlzQuZSM2oOV8rz+0izZWsSd3k3RGRVVLB/a0VInxt5IYsJyh1UtdUP4avCL7v6IbWi0z7w0rzRJWIAwe/LeYoRwwUQLNEHn/L0Xnp+Y2JgAA")}, + {"frag", GzipedString("H4sIAAAAAAAACo2UUU+DMBDH3/kUfYTEh2l8Iz44zOYSMklI9NF0UFi17ZFSmNPsu9vCNrutXXwi9Hf/u3/vDoJGkoK2FATipKQdb1DFAKs4YHgLnQpbotADmtygFRUlFbV+uYtQJ2gFkqMkyde4hA36Cda0XjeIY3WPiuJdP1N9oDKGBckkfMSegFdKNteYre1JMfB2qLkQvYFPpFHrhajAHfXPkJEy2DTojC5nae6nb8/Z1E/TbLn00wQYyDjYXev1xO71nMEKs2Ov//IpykkcHAZ4rFJIQkROvx1MYEV7MrKrBm5tAwnmRGLLgDUxe5AXQM/KyezpXgCf6HwtnPBEfLh1MfjPoPU2q8DM0S3y1UDbSQfhmIqUqicqvWw/5nOK+YoSofLPrZfNJXSivMQV1J6kmkxx6/CpwWPpSCUIljPsyNSbPoJUw3oMh0kyk7h+6VTTKRSOccZFpPdBEtVJMb5rxSiodDgKLWxnCE8/g8io9lvIoNDbqf9Iw/rrk6MpI9/fvAdaItNhU+CEaZmpHEYx2v0Cxvb5EN8EAAA=")} +}}, +{{ + {"vert", GzipedString("H4sIAAAAAAAACuVZX2/ixhZ/51OMVFUyS0LBJtm03KsrSkhKmxAUyPZKq8jywoTM1tjUNsRQ5bv3nJkxHuMZFjZtX/pC4nPO/M7/mTn2NzRNaBCzMCDXN27v/2M3fvamNHJpuvDZhCWuF7HkeU4TNnGT9YLGLgsSx/6BRPT3JYtoZRHRCeMAz2z2vCBPfugl7YryQKZ0Ek6pYxNLUFd00iLR7JNXJX9U8C/5L38k74h9dlZvFFeP2CwAgWa9QU6JFSd0YTXti3rjhFi46KPzWCU10qifVasIsLu8ly7CgAYJQAAPJKx5OLU4zwJXrBLICeHwVSRo1NmKulMQfb+r8NYLEhbH6JRWla1T9Y6cn50552BgjYfiY/ORR0OhNB7hvwvn4uK8cYE6I5oso0CE5x2BfNnW1tdTYjuAC/TMmnbltRIn0XICAU28YOpF0w80SvrBYplAFpTELMKYJZDPdgUeHRKE0dzz+UOLwMoZ4ANYu+J763CZWH448VAc3AWFLCB8lefmMGXBpiqYKSiL2ZmYDWIJTbthGE11gk4m2ELBzMZv2BPpdt2HUc+9vbsf/lSBHJAZTdBvmvanFi8/EcWZ70pyMKUpBktqiSmvnBPyiQVTFszgoVUly4A9gdkAfxtGi2fA4conE3fK4oXvTegcTPiVQlST+GPz7LGtFRhD9y0j2g+eQh5S7ipYOGQp9W+kfxanJkL0nsahv0TyCUF3FijJbUZnRAHmtCuwVpSfIteWYikwsT4V8ZOymnq+YC3QwkhdQr4zrJGBReOt9ISsqxjUgoM8nVdROC96muX1hOgdV7LGF2wLoQ5qtv+vscmgx3T2oSWyOC57H/rdnjt6GA7v7sfu1c1dZ+yOYR98uO+JlD3RZPL8AUq1E0XeGs2VWbNib77waWRfogZdOljmwIhtKARPGoJPFl/SyOMEz9S/Ql2CxdcqgSbfZkDopkL/LqdXBSI4R/2YfoX51OdlmTtQcAk8UAVgc2nJklVasVS95pKvp2vVk6oESxWUcolsVdVEaTVwZ4Yf8H2vpgx9fRR680j0zVHo9uHoeTe1rEp2nlqyoETFpHCeGFhrM2uDLHCzIgsHNrkn2e/gyGVpN8ODDGpFKZDflyFukUxWI9QEUiM695AUbVmnQpJXDTSfpUjwo2Pb1YZdFFc/1nFvJljepITRPBRjbcawD8XYbDEOk3/B8L6KI5WfQRNHDe4XGnOVn01ooNy8+KnmDu973bvb4cO4d5lZYm56jqii1eFu0c43DAcSFy99TCg+WVigYldBMwI8I9mExjypyb7e3uCxEUZE1MvYi2b8IG20tw//yV0Yd+6ve2O3e/cwGLdJrSZFRC64OTW4TH3Bq9y4d1sdtZKvwDTUtdTJ+0DGUShvZ23xWgy8tPqnzsgd3o364/7dYM+t4X1+a8gTDAEcynuSalLc3haKjm0pJTFVLzH768qk7CTHUvYAk6uDu/vbzs0eRy8Mjg74Pc/gZpn59U5qFB3n4rgzuO4Nxnt8/N7g41jcPQ1Oarhf76VOld7NVcimxFss/LW4rIJOcEszBnhJEmW7egYkDrT8ytz+cg8gTD27/sPxhYdimVYzVrfiw2G1yMHFGKGqUyg1Q40driqrCY4sRwxVmUqqmZJdVvdqyk5hFCvt+bqw70T8wGAXkqvaVYwHDlGjX/qDQX9wrRnAWnwAWzq2nME+h4xXflnyTB3VXsQRWRjVfuz80rt0O4P+bYe7hSyk9wcjyEFXr/89R1WGWGlCJ2BzMV1Jd8wt7ahT3eg3FgRAl/1WHJCh+Tj47vRmxrZ12GibsF+Lnpu+F/o8hxYghf1ItTM75Y8Mgd66+KOD71KcR25euVZ0WfzSuAXRaGGd/owKbr0kYikRb08IyzpgpxLU9y6f0QPxhmcn+3WcVXZpa2gKhkPiLmOTBcoAvpsgjq6piVyDjrnZRk1Vw4KVnBV1a16KL5ryefwzXnnE0mpRJlVkTmGF3lKcvRDNWss3UzmefHGxaubzq7UDIQZ1y0pLi/nkkSHYhyE0zQjOYQi2DkGeq1hjFp+iVk3cGbP5S5DsMskpk5r1F/jX5r8O/jbxFV4+d/8Fddy0/85CztD/vZVsmKOPK2zdTH1cYR+JoCnsIxEcDUKl0KHHR6b1ZqvO3oxw/maE93sj43xVZC7ebNX3b6+6v6BwdZVb+ef2VHG3OGhr5S8bpql8PcGqas/nVxeUEHeXvO5LXHT8Uc2/TsJ+/GejwP2P4WaW+V7NPj0I07IyzW7geZKKQbMEG7ZLfqDIe3g9rdQMguui4NoouCkKboyCL0VB/n6Mz0Li6mmcg3gI5uBoHgacSjMR/KgBwPnXJy2qefY1wBfmV6mjQGurUyj/9AcSIhc5XWS7iolv6ybJnUUKs7DyVTvNNNSrfEO9yl/74ScwKrvIk+1VPmFzOBbndMqW8/yCH08iSgNxZO7yAphYVlTwdueSggFN1YCuN6eRpxjAowxw8PcDo9vbQInRD1Za3jAKPxsZpkUIaFyYMQuLM68n3H6Yn43Bmni+Jlo0hfLgo9cuB18537DkkkVGXjf0Qw3Xm39iUBSj39ZG3nUULoNpmf0UzgygwPnRizV2AqMz1UAF1IuuPA3SCuMYRns+EcuutsnKXUKseXeiy2IzK3dmH3qrH6jNJ7e4jCK2SS60bb/8szJQZR9xsvnrcP4OxuoHpRdChRcgYjMpiCkWQpOK42JbNvUX/o0Dbt3/E+dqURq/6J3ukGDD/YEUae3KzN++wQUNCrfAqvNvXOozRBliLfzffkZ//RMa222u/CEAAA==")}, + {"frag", GzipedString("H4sIAAAAAAAACq1W3W/bNhB/119BIC+SI7u2k2ItvA6wU68IUBdBWXTYU0BLdMpNEg1Kcu2u+d93/JIomfIQYC+2eB+/++Dd8YK9oAkrGS/QN/b0bY92GSfVIsjIiddVWNIKvUPTGG1ZkbLiSR4iVBdsx0WO7u4+ZHxLMvRPoJUROtDkFiXJY8VyughymrI63zfUMhGUFpj98PAKUrED1bznSw7MXAfuSE4FcRzISaXg4P8ro98XQ4z74uDlPQj+1yBjSEkCDipaZkfZRp0o/x94OZishGSebNHjnpe18HBywoqPrHrPxCDvjmfcwyX5ltGiwn+fBnkfBK+L9Jy9408DoMBZkdLjJzCWqQeqoET8TjxIB5lHLipVHldsh5afvtwvP94v8eOXPx/W6B2URqCEd0dCwpLk+4yK+XtU0WMsUeZoJwj4yUVqzoKWPKsrqP44UITDo3jafvrDsPVp7fJwh4c7vE0Edai9PcvFHLHiQEVJvz5ACUtCOJtM0SvHhQl4eUY7RQsJeYOUX6AKwVRw76EOSrsbTY6nH47c2i+37slhPx7u42E/HnbwbiVfVYBXdONEsUFaREk7hrI6Jzo1N+F0Mn/7NkbTyes3v8i/2ewWENRoUnIqEymvQnNbktYVWDsCa48AdhCwDwE7CNiHoOIwApsYeQRYARI5K0J1itWnPVqv4VLiRsY6ApmNulDkKKHIsYGCT3vsQhliD6pTiakcDfAzkaDj0ICga4uCxshgGJoE0Ron0EA9DagXqwFpdzV0AKD3maZ1Qk0IfXsNTKuLRoGsgddohEybvJlMIwhPnl6h2VwdrQGR7GHa6XRraZVmsi1DFSXo2e9TFIGVxiMdlbkl1ZQAHCtjcSB9VbSxIo41VcqPWpOAN2pbu63ypXy1JiqAoNMPzQhy9bRPbbQ38DuW+pFqMXT9Ioy5D8PpwBX4plwcKRevkU31S6yMJfLLnbNanfJetZ20ajoNBrwulRX61fZThH7+RIb4m+2MKAoSM3nkJJIoy7idMBKLZiU9E1r1hASFIAo7u5+DKwobx84uIhlPiJzIegOCWjNzvz70dpXZwLLUvkcgu6+rz7Sss2pD9gu/CaDop08nVDl14CyVTicyv2X4n2+awXDetR5l3ZfBZzL4TMa+c9037fw5gzXC2AV22NbFtX7/xjPVVjPZyr0merSv2LnWZSV8ydSg0gVLQzob+4p7yz2S9aMuS25cKJQJ64xgk5eFj7r2UbFXFntlNxfXI7dCIIjOVq7vrFNVMk4ocjnzGrVF0NagU35O5TmLlKkzZ30yVdWuBk2FgzG1u/U6JEb/h5UrNQVcW3ZunZmTESsNNQGe/wWVLe8uJQ0AAA==")} +}}, +{{ + {"vert", GzipedString("H4sIAAAAAAAACn1UXWvbMBR9z6+4j3bpjL8eNkwHrcdKYbCwQF9KCIqtuNpkyciy8zH633clx7FD7OUhQfece3R0dZRFpWjGaiYFvLPivYIdl0QnC06OstFOTTU8gH8PWyZyJgqzcKERbCdVCWn6zOWWcPi76JoBWprFkGUbzUqaLEqas6asLtU6U5SKFTtNYIJo1tIO+/ifgWBsICUlVWRkoCTayuHvK6P7ZA54Ee0ktlTy9yww12QEZxt78Kq5P3Vm/S9lPTusjPCJadFDJetGTSAlYeIH09+YmsVSyeUESsoto0Kv/hxnsWclG5HfwjtZzIgi8kTqCZ8IPOYTUoIS9Z1MKLVmjlJpG49aqybTsNJE5ETlr1TpF1E1+pIE24UzYhqznSxwGYHAzBBuFzFgZ4EnGoeNy4wYepdyJsB2kc0gc0sMxsR+g1ta2NNCpGl6SKVU+RQx6omxIfYeJw1iBa6GZCZk771b4UzAcXEi5zp2GcAZDnQPgee7OGqT1nNUf0n9U/Ajkk3Vwa/IGYLsumd1lOgo4567wQLbgTM8nLdo7e3hK/i4HRrq9zMQqoxfnh1RbULf2Q2d+LOH7z+Me6dWz197B9zvoaMO9WCmHq69075X/BRcaUVjzLfQ5XTW4Z05LQYFKK8p2u/QwfWFYBDvZG7H+2I+HeDhv5CiulGip7WS5WAeo7keKPhmeb4Q60Jpx03g4x+VNAghmwUAAA==")}, + {"frag", GzipedString("H4sIAAAAAAAACo1U32/aMBB+5684qS/JxjLCD2kT6gMEyia1GirtXpExhnqN7cxxKLTif9/ZIZBsybYXJ77v7vPd5zu3Es0oT7mSINiaZyKBTayIGbZiclCZ8VJm4Bo6bVhxueZyazc+ZJJvlBYQRbNYrUgMb60nvn1KAGDHaB8oXRou2LBVkBbWlGrG5IK/1mCSGL5jOXb8WwJhOYGICKZJKQFBjKPD73fOXoZNwFe5q8XmWv1oBJqCLGFjYAFWgouqqct/rtJGsSiJa9Ri+0Slma5BBOHylpsJ141YpGJVgxKx4kyaxfOhEZtplcn1n/BGbRtIERmTtCZPBEbrGirJiL4hNUw7q6PS5h/t0b+0R0pEEjMdZSvmNJM7rpUUWMewhaw9dEwIfb6fjafguWP0dsV87CbNTKal2wa4wDtI1IsXBmE7txG0dAeDoAMfIOx+Cjo+ZpVzLpDuQd1yW4dj7cGWCEFKtG6PDO57DhxF08WDkuyOJKc4aiW1ce4HaxNceu6/bVXpefZgPJkqmZp8cmGEbt1gEFatY6tS0OlVrZHz7f9mnTjfweeqdeqsYX9YFJEnglV4I1zyzXsY+z58LGFRCZv4uEwLpfo4vTeabL9lJsnMSf9zxVd8g/jycTFdfpnc5wK4m7gu6+Sd7ch6xbAFNhXX9Kc2FZ9T7jTv1WPRRrGi+PrgK+ieN355DV1StvHcOLndBnMGr8jRJmj7Zxk9jqd3o3l+lRSJLr3lGbbHY5lX7cF2QRzsD6++KyBO2YWg3Ej/RVHV4VRqWWSnsUftlZSnPXhpQ5h3UoMiaDmPoaU7zfpO8TXYN8XKUcEwzOrk+UM4/gJS754xZQYAAA==")} +}}, +{{ + {"vert", GzipedString("H4sIAAAAAAAACn1TTW/bMAy9+1fwaLdGGqc5DPAyYMvQosAOAQrsEgSBYssuN1syZNn5KPLfRylR6ib2Tpb5Hp8o8tGrFE+wRimg5Ck2ZQVZIZmOvYLtZaP9mmuYwTiEDYoURW5+AmgEZlKVMJ8/F3LDCnj33jB/qwCg5ckUkmStseSx50RdtE4U5+IVDz2YYBpbfsKO/ysg6hYwZyVXrFNAybSVo+9v5Nt4CHgRbS+2UPLPIDCUZAQHEx34Kdm9OrH1L2Q92KyEFT3d4rtK1o3qQUqG4hfqn6gGsbksZA/Kyg1yoV//7gexZyUbkd7CmcwHRAn5weqeOgn4nvZICc7UE+tRak0fpdJdexQyIduQfa0vURjyI7A1NQdNvI8YOeKUiMmp6l45ihjaBNp10145MhpaCSlqzYSuyZL2CplllHFr6WjA0guunhSZ4kVk0mmkmKOul1/gDqIxPMB0ZfXsqkLOaZ5lJQWNx7f0NjxtMWBACpiBj/AVohGV+Q6K60bR80e7GI4eL2oOjjG5YuxvGI9XjMOF0QluTfB4qrzlSoNvyqBFmEBFa0DPNWf/Y6uW49Votw87e7aMTCSIPZvwMAO2qf3KAXAP7mw4dkRu4KRuc+46JiApSjkNgs6UQfMk4nn6NmRe6P4P8I1map967rGR/dTn80SQjpesYBVeJLfB+Zb7mbWQf779QIWJ0IrTCD3XM2qV76q1aGjHZSitxBTM3pouQl6sFx8vNd31A2r3PzPVmpXIBQAA")}, + {"frag", GzipedString("H4sIAAAAAAAACn2SzU7DMBCE73mKPSZSD7TiFnGAVK2QkKhUxLVyEydd8E/k2KEF9d2xHQIp2Jwi7+edHW8maRUtsUMpgNMKDW+hZpLoPGHkJI1OO6rhBq5msEdRoWjcIQMjsJaKQ1GsmdwTBh/JAZtDCwA9La+hLHcaOc2TUXSsdqWiVGzxPcAE0djTgZ3/MzCfGigIp4pMDHCivZz9PiN9y2PgXvRBtlHyJQpiTU4w2jjCi+bx1aX3v5FddFklYYFt0WMrO6MChBMUD6iXqKKskEwGKOF7pEJvX09RtlbSiOovrmUTEbXkjnQBnxbcVgEpQYlakYBS7/Yolfbx8MWiWCnSPBrdGg3pcM+5yGweFNVGieFsO8Y8MVnanNm8+yCjcOoL6Hem/xW5+TRyi5/IdYS3jKrFEtwyn+hR+7/gh9fWDaST6VODqR7uppO+mZ+cZVGDtvL9fif1teReYuXnu2EXzLY5F2mWw/kTfiJmP94DAAA=")} +}}, +{{ + {"vert", GzipedString("H4sIAAAAAAAACnVQy26DMBC88xV7hDShgHpDOeUHIvUDkGOWyJXxWn6QpFX+vXbcAJXa4+zOzM5spg1yYQUpGLEXftQwSGKuzSS7kXe5JM5cXO+hKkAomJA3wDpNVsT5X8R6TXR4PRCZ/h/HMEnMqfPTzLHoos8WTkL1Qp0T1ysxkBnhQMo6phx8ZUH6Br47+WFAU7W/cd1mI3MRa0MfyFPe+w9rQuMgL5JJAxcysj+SDaeWdrBZzMrrDV5W8PPSJiWXQr9rxjFIZ5fXJVUUbqApK9hBXT5DWm4QVTq4DhiocZ/PrluoymoblUWQhi89Ei5vNei8UYtfaJhNJHoYmVCxH5xld3wW2j9650UL92/FRr4p/AEAAA==")}, + {"frag", GzipedString("H4sIAAAAAAAACn2QTWuEMBCG7/6K92iKiCu9iaeW/QW9SxrHJZAPiYnstux/7xgX20LpcTLvPPNMijmQ0ov2DpZGneyMyXgZu8LIm0+xNF7JuLV7NALaYSXVYh3SekQWitw9VXjXbtTushUCyenJB4uzVNEHfBaZizTMFBQ53nD/j9B+ExZpZ0OhfYWV2r3RNaZAXcEiz5iCvKAUjM+l8oZ39Yh7qPwxUGVp0T08HhacVYb55eFVoambCqe64Wzm1dfbB556HOKBGOj2ZXzG31/FL9id1HBmy5c9vXo95js26V89HtuuKUWH+xf8YVsXlwEAAA==")} +}} +}; + +} diff --git a/native/cocos/core/builtin/shader-sources/glsl4.cpp.in b/native/cocos/core/builtin/shader-sources/glsl4.cpp.in new file mode 100644 index 0000000000..cbb5ee3d88 --- /dev/null +++ b/native/cocos/core/builtin/shader-sources/glsl4.cpp.in @@ -0,0 +1,35 @@ +/**************************************************************************** + 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. +****************************************************************************/ + +// clang-format off +#include "core/builtin/shader-sources/glsl4.h" + +namespace cc { + +ShaderSource builtinGLSL4{ +${PLACE_HOLDER} +}; + +} diff --git a/native/cocos/core/builtin/shader-sources/glsl4.h b/native/cocos/core/builtin/shader-sources/glsl4.h new file mode 100644 index 0000000000..67cff597bd --- /dev/null +++ b/native/cocos/core/builtin/shader-sources/glsl4.h @@ -0,0 +1,34 @@ +/**************************************************************************** + 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 "core/builtin/ShaderSourceAssembly.h" + +namespace cc { + +extern ShaderSource builtinGLSL4; + +} diff --git a/native/cocos/core/builtin/shader-sources/glsl4.ts b/native/cocos/core/builtin/shader-sources/glsl4.ts new file mode 100644 index 0000000000..0932b9ee81 --- /dev/null +++ b/native/cocos/core/builtin/shader-sources/glsl4.ts @@ -0,0 +1,143 @@ +/* eslint-disable */ +export const glsl4 = [ + [ + { + "vert": "\nprecision mediump float;\nlayout(set = 1, binding = 0) uniform Constants {\nvec4 mainTiling_Offset;\nvec4 frameTile_velLenScale;\nvec4 scale;\nvec4 nodeRotation;\n};\nlayout(set = 0, binding = 0) uniform CCGlobal {\nhighp vec4 cc_time;\nmediump vec4 cc_screenSize;\nmediump vec4 cc_nativeSize;\n};\nlayout(set = 0, binding = 1) uniform CCCamera {\nhighp mat4 cc_matView;\nhighp mat4 cc_matViewInv;\nhighp mat4 cc_matProj;\nhighp mat4 cc_matProjInv;\nhighp mat4 cc_matViewProj;\nhighp mat4 cc_matViewProjInv;\nhighp vec4 cc_cameraPos;\nmediump vec4 cc_screenScale;\nmediump vec4 cc_exposure;\nmediump vec4 cc_mainLitDir;\nmediump vec4 cc_mainLitColor;\nmediump vec4 cc_ambientSky;\nmediump vec4 cc_ambientGround;\nmediump vec4 cc_fogColor;\nmediump vec4 cc_fogBase;\nmediump vec4 cc_fogAdd;\nmediump vec4 cc_nearFar;\nmediump vec4 cc_viewPort;\n};\nlayout(set = 2, binding = 0) uniform CCLocal {\nhighp mat4 cc_matWorld;\nhighp mat4 cc_matWorldIT;\nhighp vec4 cc_lightingMapUVParam;\n};\nvec4 quaternionFromAxis (vec3 xAxis,vec3 yAxis,vec3 zAxis){\nmat3 m = mat3(xAxis,yAxis,zAxis);\nfloat trace = m[0][0] + m[1][1] + m[2][2];\nvec4 quat;\nif (trace > 0.) {\nfloat s = 0.5 / sqrt(trace + 1.0);\nquat.w = 0.25 / s;\nquat.x = (m[2][1] - m[1][2]) * s;\nquat.y = (m[0][2] - m[2][0]) * s;\nquat.z = (m[1][0] - m[0][1]) * s;\n} else if ((m[0][0] > m[1][1]) && (m[0][0] > m[2][2])) {\nfloat s = 2.0 * sqrt(1.0 + m[0][0] - m[1][1] - m[2][2]);\nquat.w = (m[2][1] - m[1][2]) / s;\nquat.x = 0.25 * s;\nquat.y = (m[0][1] + m[1][0]) / s;\nquat.z = (m[0][2] + m[2][0]) / s;\n} else if (m[1][1] > m[2][2]) {\nfloat s = 2.0 * sqrt(1.0 + m[1][1] - m[0][0] - m[2][2]);\nquat.w = (m[0][2] - m[2][0]) / s;\nquat.x = (m[0][1] + m[1][0]) / s;\nquat.y = 0.25 * s;\nquat.z = (m[1][2] + m[2][1]) / s;\n} else {\nfloat s = 2.0 * sqrt(1.0 + m[2][2] - m[0][0] - m[1][1]);\nquat.w = (m[1][0] - m[0][1]) / s;\nquat.x = (m[0][2] + m[2][0]) / s;\nquat.y = (m[1][2] + m[2][1]) / s;\nquat.z = 0.25 * s;\n}\nfloat len = quat.x * quat.x + quat.y * quat.y + quat.z * quat.z + quat.w * quat.w;\nif (len > 0.) {\nlen = 1. / sqrt(len);\nquat.x = quat.x * len;\nquat.y = quat.y * len;\nquat.z = quat.z * len;\nquat.w = quat.w * len;\n}\nreturn quat;\n}\nvec4 quaternionFromEuler (vec3 angle){\nfloat x = angle.x / 2.;\nfloat y = angle.y / 2.;\nfloat z = angle.z / 2.;\nfloat sx = sin(x);\nfloat cx = cos(x);\nfloat sy = sin(y);\nfloat cy = cos(y);\nfloat sz = sin(z);\nfloat cz = cos(z);\nvec4 quat = vec4(0);\nquat.x = sx * cy * cz + cx * sy * sz;\nquat.y = cx * sy * cz + sx * cy * sz;\nquat.z = cx * cy * sz - sx * sy * cz;\nquat.w = cx * cy * cz - sx * sy * sz;\nreturn quat;\n}\nvec4 quatMultiply (vec4 a, vec4 b){\nvec4 quat;\nquat.x = a.x * b.w + a.w * b.x + a.y * b.z - a.z * b.y;\nquat.y = a.y * b.w + a.w * b.y + a.z * b.x - a.x * b.z;\nquat.z = a.z * b.w + a.w * b.z + a.x * b.y - a.y * b.x;\nquat.w = a.w * b.w - a.x * b.x - a.y * b.y - a.z * b.z;\nreturn quat;\n}\nvoid rotateVecFromQuat (inout vec3 v, vec4 q){\nfloat ix = q.w * v.x + q.y * v.z - q.z * v.y;\nfloat iy = q.w * v.y + q.z * v.x - q.x * v.z;\nfloat iz = q.w * v.z + q.x * v.y - q.y * v.x;\nfloat iw = -q.x * v.x - q.y * v.y - q.z * v.z;\nv.x = ix * q.w + iw * -q.x + iy * -q.z - iz * -q.y;\nv.y = iy * q.w + iw * -q.y + iz * -q.x - ix * -q.z;\nv.z = iz * q.w + iw * -q.z + ix * -q.y - iy * -q.x;\n}\nvec3 rotateInLocalSpace (vec3 pos, vec3 xAxis, vec3 yAxis, vec3 zAxis, vec4 q){\nvec4 viewQuat = quaternionFromAxis(xAxis, yAxis, zAxis);\nvec4 rotQuat = quatMultiply(viewQuat, q);\nrotateVecFromQuat(pos, rotQuat);\nreturn pos;\n}\nlayout(location = 0) out mediump vec2 uv;\nlayout(location = 1) out mediump vec4 color;\nvoid computeVertPos (inout vec4 pos, vec2 vertOffset, vec4 q, vec3 s\n, mat4 viewInv\n) {\nvec3 viewSpaceVert = vec3(vertOffset.x * s.x, vertOffset.y * s.y, 0.);\nvec3 camX = normalize(vec3(viewInv[0][0], viewInv[1][0], viewInv[2][0]));\nvec3 camY = normalize(vec3(viewInv[0][1], viewInv[1][1], viewInv[2][1]));\nvec3 camZ = normalize(vec3(viewInv[0][2], viewInv[1][2], viewInv[2][2]));\npos.xyz += rotateInLocalSpace(viewSpaceVert, camX, camY, camZ, q);\n}\nlayout(location = 0) in vec3 a_position;\nlayout(location = 1) in vec2 a_texCoord;\nlayout(location = 2) in vec4 a_color;\nlayout(set = 1, binding = 1) uniform builtin {\nvec4 cc_size_rotation;\n};\nvec4 vs_main() {\nvec4 pos = vec4(a_position, 1);\npos = cc_matWorld * pos;\nvec2 vertOffset = a_texCoord.xy - 0.5;\ncomputeVertPos(pos, vertOffset, quaternionFromEuler(vec3(0., 0., cc_size_rotation.z)), vec3(cc_size_rotation.xy, 0.), cc_matViewInv);\npos = cc_matViewProj * pos;\nuv = a_texCoord.xy;\ncolor = a_color;\nreturn pos;\n}\nvoid main() { gl_Position = vs_main(); }", + "frag": "\nprecision mediump float;\nlayout(set = 0, binding = 0) uniform CCGlobal {\nhighp vec4 cc_time;\nmediump vec4 cc_screenSize;\nmediump vec4 cc_nativeSize;\n};\nlayout(set = 0, binding = 1) uniform CCCamera {\nhighp mat4 cc_matView;\nhighp mat4 cc_matViewInv;\nhighp mat4 cc_matProj;\nhighp mat4 cc_matProjInv;\nhighp mat4 cc_matViewProj;\nhighp mat4 cc_matViewProjInv;\nhighp vec4 cc_cameraPos;\nmediump vec4 cc_screenScale;\nmediump vec4 cc_exposure;\nmediump vec4 cc_mainLitDir;\nmediump vec4 cc_mainLitColor;\nmediump vec4 cc_ambientSky;\nmediump vec4 cc_ambientGround;\nmediump vec4 cc_fogColor;\nmediump vec4 cc_fogBase;\nmediump vec4 cc_fogAdd;\nmediump vec4 cc_nearFar;\nmediump vec4 cc_viewPort;\n};\nvec4 CCFragOutput (vec4 color) {\nreturn color;\n}\nlayout(location = 0) in vec2 uv;\nlayout(location = 1) in vec4 color;\nlayout(set = 1, binding = 3) uniform sampler2D mainTexture;\nlayout(set = 1, binding = 2) uniform FragConstants {\nvec4 tintColor;\n};\nvec4 add () {\nvec4 col = 2.0 * color * tintColor * texture(mainTexture, uv);\nreturn CCFragOutput(col);\n}\nlayout(location = 0) out vec4 cc_FragColor;\nvoid main() { cc_FragColor = add(); }", + } + ], + [ + { + "vert": "\nprecision highp float;\nlayout(location = 0) in vec3 a_position;\nvec4 vert () {\nvec4 pos = vec4(a_position, 1);\nreturn pos;\n}\nvoid main() { gl_Position = vert(); }", + "frag": "\nprecision highp float;\nvec4 frag () {\nvec4 o = vec4(1.0);\nreturn o;\n}\nlayout(location = 0) out vec4 cc_FragColor;\nvoid main() { cc_FragColor = frag(); }", + } + ], + [ + { + "vert": "\nprecision highp float;\nlayout(set = 0, binding = 0) uniform CCGlobal {\nhighp vec4 cc_time;\nmediump vec4 cc_screenSize;\nmediump vec4 cc_nativeSize;\n};\nlayout(set = 0, binding = 1) uniform CCCamera {\nhighp mat4 cc_matView;\nhighp mat4 cc_matViewInv;\nhighp mat4 cc_matProj;\nhighp mat4 cc_matProjInv;\nhighp mat4 cc_matViewProj;\nhighp mat4 cc_matViewProjInv;\nhighp vec4 cc_cameraPos;\nmediump vec4 cc_screenScale;\nmediump vec4 cc_exposure;\nmediump vec4 cc_mainLitDir;\nmediump vec4 cc_mainLitColor;\nmediump vec4 cc_ambientSky;\nmediump vec4 cc_ambientGround;\nmediump vec4 cc_fogColor;\nmediump vec4 cc_fogBase;\nmediump vec4 cc_fogAdd;\nmediump vec4 cc_nearFar;\nmediump vec4 cc_viewPort;\n};\nlayout(set = 2, binding = 0) uniform CCLocal {\nhighp mat4 cc_matWorld;\nhighp mat4 cc_matWorldIT;\nhighp vec4 cc_lightingMapUVParam;\n};\nlayout(location = 0) in vec3 a_position;\nlayout(location = 1) in vec4 a_color;\nlayout(location = 0) out vec4 v_color;\nlayout(location = 2) in float a_dist;\nlayout(location = 1) out float v_dist;\nvec4 vert () {\nvec4 pos = vec4(a_position, 1);\npos = cc_matViewProj * cc_matWorld * pos;\nv_color = a_color;\nv_dist = a_dist;\nreturn pos;\n}\nvoid main() { gl_Position = vert(); }", + "frag": "\nprecision highp float;\nlayout(location = 0) in vec4 v_color;\nlayout(location = 1) in float v_dist;\nvec4 frag () {\nvec4 o = v_color;\nfloat aa = fwidth(v_dist);\nfloat alpha = 1. - smoothstep(-aa, 0., abs(v_dist) - 1.0);\no.rgb *= o.a;\no *= alpha;\nreturn o;\n}\nlayout(location = 0) out vec4 cc_FragColor;\nvoid main() { cc_FragColor = frag(); }", + } + ], + [ + { + "vert": "\nprecision highp float;\nlayout(set = 0, binding = 0) uniform CCGlobal {\nhighp vec4 cc_time;\nmediump vec4 cc_screenSize;\nmediump vec4 cc_nativeSize;\n};\nlayout(set = 0, binding = 1) uniform CCCamera {\nhighp mat4 cc_matView;\nhighp mat4 cc_matViewInv;\nhighp mat4 cc_matProj;\nhighp mat4 cc_matProjInv;\nhighp mat4 cc_matViewProj;\nhighp mat4 cc_matViewProjInv;\nhighp vec4 cc_cameraPos;\nmediump vec4 cc_screenScale;\nmediump vec4 cc_exposure;\nmediump vec4 cc_mainLitDir;\nmediump vec4 cc_mainLitColor;\nmediump vec4 cc_ambientSky;\nmediump vec4 cc_ambientGround;\nmediump vec4 cc_fogColor;\nmediump vec4 cc_fogBase;\nmediump vec4 cc_fogAdd;\nmediump vec4 cc_nearFar;\nmediump vec4 cc_viewPort;\n};\nlayout(set = 2, binding = 0) uniform CCWorldBound {\nhighp vec4 cc_worldBoundCenter;\nhighp vec4 cc_worldBoundHalfExtents;\n};\nlayout(location = 0) in vec3 a_position;\nvec4 vert () {\nvec4 position;\nposition = vec4(a_position, 1.0);\nposition *= cc_worldBoundHalfExtents;\nposition += cc_worldBoundCenter;\nposition = cc_matViewProj * position;\nreturn position;\n}\nvoid main() { gl_Position = vert(); }", + "frag": "\nprecision mediump float;\nvec4 frag () {\nreturn vec4(1, 0, 0, 1);\n}\nlayout(location = 0) out vec4 cc_FragColor;\nvoid main() { cc_FragColor = frag(); }", + } + ], + [ + { + "vert": "\nprecision mediump float;\nvec4 quaternionFromAxis (vec3 xAxis,vec3 yAxis,vec3 zAxis){\nmat3 m = mat3(xAxis,yAxis,zAxis);\nfloat trace = m[0][0] + m[1][1] + m[2][2];\nvec4 quat;\nif (trace > 0.) {\nfloat s = 0.5 / sqrt(trace + 1.0);\nquat.w = 0.25 / s;\nquat.x = (m[2][1] - m[1][2]) * s;\nquat.y = (m[0][2] - m[2][0]) * s;\nquat.z = (m[1][0] - m[0][1]) * s;\n} else if ((m[0][0] > m[1][1]) && (m[0][0] > m[2][2])) {\nfloat s = 2.0 * sqrt(1.0 + m[0][0] - m[1][1] - m[2][2]);\nquat.w = (m[2][1] - m[1][2]) / s;\nquat.x = 0.25 * s;\nquat.y = (m[0][1] + m[1][0]) / s;\nquat.z = (m[0][2] + m[2][0]) / s;\n} else if (m[1][1] > m[2][2]) {\nfloat s = 2.0 * sqrt(1.0 + m[1][1] - m[0][0] - m[2][2]);\nquat.w = (m[0][2] - m[2][0]) / s;\nquat.x = (m[0][1] + m[1][0]) / s;\nquat.y = 0.25 * s;\nquat.z = (m[1][2] + m[2][1]) / s;\n} else {\nfloat s = 2.0 * sqrt(1.0 + m[2][2] - m[0][0] - m[1][1]);\nquat.w = (m[1][0] - m[0][1]) / s;\nquat.x = (m[0][2] + m[2][0]) / s;\nquat.y = (m[1][2] + m[2][1]) / s;\nquat.z = 0.25 * s;\n}\nfloat len = quat.x * quat.x + quat.y * quat.y + quat.z * quat.z + quat.w * quat.w;\nif (len > 0.) {\nlen = 1. / sqrt(len);\nquat.x = quat.x * len;\nquat.y = quat.y * len;\nquat.z = quat.z * len;\nquat.w = quat.w * len;\n}\nreturn quat;\n}\nvec4 quaternionFromEuler (vec3 angle){\nfloat x = angle.x / 2.;\nfloat y = angle.y / 2.;\nfloat z = angle.z / 2.;\nfloat sx = sin(x);\nfloat cx = cos(x);\nfloat sy = sin(y);\nfloat cy = cos(y);\nfloat sz = sin(z);\nfloat cz = cos(z);\nvec4 quat = vec4(0);\nquat.x = sx * cy * cz + cx * sy * sz;\nquat.y = cx * sy * cz + sx * cy * sz;\nquat.z = cx * cy * sz - sx * sy * cz;\nquat.w = cx * cy * cz - sx * sy * sz;\nreturn quat;\n}\nmat4 matrixFromRT (vec4 q, vec3 p){\nfloat x2 = q.x + q.x;\nfloat y2 = q.y + q.y;\nfloat z2 = q.z + q.z;\nfloat xx = q.x * x2;\nfloat xy = q.x * y2;\nfloat xz = q.x * z2;\nfloat yy = q.y * y2;\nfloat yz = q.y * z2;\nfloat zz = q.z * z2;\nfloat wx = q.w * x2;\nfloat wy = q.w * y2;\nfloat wz = q.w * z2;\nreturn mat4(\n1. - (yy + zz), xy + wz, xz - wy, 0,\nxy - wz, 1. - (xx + zz), yz + wx, 0,\nxz + wy, yz - wx, 1. - (xx + yy), 0,\np.x, p.y, p.z, 1\n);\n}\nmat4 matFromRTS (vec4 q, vec3 t, vec3 s){\nfloat x = q.x, y = q.y, z = q.z, w = q.w;\nfloat x2 = x + x;\nfloat y2 = y + y;\nfloat z2 = z + z;\nfloat xx = x * x2;\nfloat xy = x * y2;\nfloat xz = x * z2;\nfloat yy = y * y2;\nfloat yz = y * z2;\nfloat zz = z * z2;\nfloat wx = w * x2;\nfloat wy = w * y2;\nfloat wz = w * z2;\nfloat sx = s.x;\nfloat sy = s.y;\nfloat sz = s.z;\nreturn mat4((1. - (yy + zz)) * sx, (xy + wz) * sx, (xz - wy) * sx, 0,\n(xy - wz) * sy, (1. - (xx + zz)) * sy, (yz + wx) * sy, 0,\n(xz + wy) * sz, (yz - wx) * sz, (1. - (xx + yy)) * sz, 0,\nt.x, t.y, t.z, 1);\n}\nvec4 quatMultiply (vec4 a, vec4 b){\nvec4 quat;\nquat.x = a.x * b.w + a.w * b.x + a.y * b.z - a.z * b.y;\nquat.y = a.y * b.w + a.w * b.y + a.z * b.x - a.x * b.z;\nquat.z = a.z * b.w + a.w * b.z + a.x * b.y - a.y * b.x;\nquat.w = a.w * b.w - a.x * b.x - a.y * b.y - a.z * b.z;\nreturn quat;\n}\nvoid rotateVecFromQuat (inout vec3 v, vec4 q){\nfloat ix = q.w * v.x + q.y * v.z - q.z * v.y;\nfloat iy = q.w * v.y + q.z * v.x - q.x * v.z;\nfloat iz = q.w * v.z + q.x * v.y - q.y * v.x;\nfloat iw = -q.x * v.x - q.y * v.y - q.z * v.z;\nv.x = ix * q.w + iw * -q.x + iy * -q.z - iz * -q.y;\nv.y = iy * q.w + iw * -q.y + iz * -q.x - ix * -q.z;\nv.z = iz * q.w + iw * -q.z + ix * -q.y - iy * -q.x;\n}\nvec3 rotateInLocalSpace (vec3 pos, vec3 xAxis, vec3 yAxis, vec3 zAxis, vec4 q){\nvec4 viewQuat = quaternionFromAxis(xAxis, yAxis, zAxis);\nvec4 rotQuat = quatMultiply(viewQuat, q);\nrotateVecFromQuat(pos, rotQuat);\nreturn pos;\n}\nmat3 quatToMat3(vec4 q) {\nvec3 m0 = vec3(\n1.0 - 2.0 * q.y * q.y - 2.0 * q.z * q.z,\n2.0 * q.x * q.y + 2.0 * q.w * q.z,\n2.0 * q.x * q.z - 2.0 * q.w * q.y);\nvec3 m1 = vec3(\n2.0 * q.x * q.y - 2.0 * q.w * q.z,\n1.0 - 2.0 * q.x * q.x - 2.0 * q.z * q.z,\n2.0 * q.y * q.z + 2.0 * q.w * q.x);\nvec3 m2 = vec3(\n2.0 * q.x * q.z + 2.0 * q.w * q.y,\n2.0 * q.y * q.z - 2.0 * q.w * q.x,\n1.0 - 2.0 * q.x * q.x - 2.0 * q.y * q.y);\nreturn mat3(m0, m1, m2);\n}\nvec4 mat3ToQuat(mat3 mat) {\nfloat tr = mat[0][0] + mat[1][1] + mat[2][2];\nfloat qw, qx, qy, qz;\nif (tr > 0.0) {\nfloat S = sqrt(tr + 1.0) * 2.0;\nfloat invS = 1.0 / S;\nqw = 0.25 * S;\nqx = (mat[1][2] - mat[2][1]) * invS;\nqy = (mat[2][0] - mat[0][2]) * invS;\nqz = (mat[0][1] - mat[1][0]) * invS;\n} else if ((mat[0][0] > mat[1][1])&&(mat[0][0] > mat[2][2])) {\nfloat S = sqrt(1.0 + mat[0][0] - mat[1][1] - mat[2][2]) * 2.0;\nfloat invS = 1.0 / S;\nqw = (mat[1][2] - mat[2][1]) * invS;\nqx = 0.25 * S;\nqy = (mat[1][0] + mat[0][1]) * invS;\nqz = (mat[2][0] + mat[0][2]) * invS;\n} else if (mat[1][1] > mat[2][2]) {\nfloat S = sqrt(1.0 + mat[1][1] - mat[0][0] - mat[2][2]) * 2.0;\nfloat invS = 1.0 / S;\nqw = (mat[2][0] - mat[0][2]) * invS;\nqx = (mat[1][0] + mat[0][1]) * invS;\nqy = 0.25 * S;\nqz = (mat[2][1] + mat[1][2]) * invS;\n} else {\nfloat S = sqrt(1.0 + mat[2][2] - mat[0][0] - mat[1][1]) * 2.0;\nfloat invS = 1.0 / S;\nqw = (mat[0][1] - mat[1][0]) * invS;\nqx = (mat[2][0] + mat[0][2]) * invS;\nqy = (mat[2][1] + mat[1][2]) * invS;\nqz = 0.25 * S;\n}\nreturn vec4(qx, qy, qz, qw);\n}\nvec4 eulerToQuat(vec3 euler) {\nvec3 er = euler * 0.5;\nfloat x = er.x, y = er.y, z = er.z;\nfloat sx = sin(x);\nfloat cx = cos(x);\nfloat sy = sin(y);\nfloat cy = cos(y);\nfloat sz = sin(z);\nfloat cz = cos(z);\nvec4 quat;\nquat.x = sx * cy * cz + cx * sy * sz;\nquat.y = cx * sy * cz + sx * cy * sz;\nquat.z = cx * cy * sz - sx * sy * cz;\nquat.w = cx * cy * cz - sx * sy * sz;\nreturn quat;\n}\nlayout(set = 1, binding = 0) uniform Constants {\nvec4 mainTiling_Offset;\nvec4 frameTile_velLenScale;\nvec4 scale;\nvec4 nodeRotation;\n};\nlayout(set = 0, binding = 0) uniform CCGlobal {\nhighp vec4 cc_time;\nmediump vec4 cc_screenSize;\nmediump vec4 cc_nativeSize;\n};\nlayout(set = 0, binding = 1) uniform CCCamera {\nhighp mat4 cc_matView;\nhighp mat4 cc_matViewInv;\nhighp mat4 cc_matProj;\nhighp mat4 cc_matProjInv;\nhighp mat4 cc_matViewProj;\nhighp mat4 cc_matViewProjInv;\nhighp vec4 cc_cameraPos;\nmediump vec4 cc_screenScale;\nmediump vec4 cc_exposure;\nmediump vec4 cc_mainLitDir;\nmediump vec4 cc_mainLitColor;\nmediump vec4 cc_ambientSky;\nmediump vec4 cc_ambientGround;\nmediump vec4 cc_fogColor;\nmediump vec4 cc_fogBase;\nmediump vec4 cc_fogAdd;\nmediump vec4 cc_nearFar;\nmediump vec4 cc_viewPort;\n};\nlayout(set = 2, binding = 0) uniform CCLocal {\nhighp mat4 cc_matWorld;\nhighp mat4 cc_matWorldIT;\nhighp vec4 cc_lightingMapUVParam;\n};\nlayout(location = 0) out mediump vec2 uv;\nlayout(location = 1) out mediump vec4 color;\nvoid computeVertPos (inout vec4 pos, vec2 vertOffset, vec4 q, vec3 s\n#if CC_RENDER_MODE == 0 || CC_RENDER_MODE == 3\n, mat4 viewInv\n#endif\n#if CC_RENDER_MODE == 1\n, vec3 eye\n, vec4 velocity\n, float velocityScale\n, float lengthScale\n, float xIndex\n#endif\n) {\n#if CC_RENDER_MODE == 0\nvec3 viewSpaceVert = vec3(vertOffset.x * s.x, vertOffset.y * s.y, 0.);\nvec3 camX = normalize(vec3(viewInv[0][0], viewInv[1][0], viewInv[2][0]));\nvec3 camY = normalize(vec3(viewInv[0][1], viewInv[1][1], viewInv[2][1]));\nvec3 camZ = normalize(vec3(viewInv[0][2], viewInv[1][2], viewInv[2][2]));\npos.xyz += rotateInLocalSpace(viewSpaceVert, camX, camY, camZ, q);\n#elif CC_RENDER_MODE == 1\nvec3 camRight = normalize(cross(pos.xyz - eye, velocity.xyz)) * s.x;\nvec3 camUp = velocity.xyz * velocityScale + normalize(velocity.xyz) * lengthScale * s.y;\npos.xyz += (camRight * abs(vertOffset.x) * sign(vertOffset.y)) - camUp * xIndex;\n#elif CC_RENDER_MODE == 2\nvec3 viewSpaceVert = vec3(vertOffset.x * s.x, vertOffset.y * s.y, 0.);\nvec3 camX = vec3(1, 0, 0);\nvec3 camY = vec3(0, 0, -1);\npos.xyz += rotateInLocalSpace(viewSpaceVert, camX, camY, cross(camX, camY), q);\n#elif CC_RENDER_MODE == 3\nvec3 viewSpaceVert = vec3(vertOffset.x * s.x, vertOffset.y * s.y, 0.);\nrotateVecFromQuat(viewSpaceVert, q);\nvec3 camX = normalize(vec3(cc_matView[0][0], cc_matView[1][0], cc_matView[2][0]));\nvec3 camY = vec3(0, 1, 0);\nvec3 offset = camX * viewSpaceVert.x + camY * viewSpaceVert.y;\npos.xyz += offset;\n#else\npos.x += vertOffset.x;\npos.y += vertOffset.y;\n#endif\n}\nvec2 computeUV (float frameIndex, vec2 vertIndex, vec2 frameTile){\nvec2 aniUV = vec2(0, floor(frameIndex * frameTile.y));\naniUV.x = floor(frameIndex * frameTile.x * frameTile.y - aniUV.y * frameTile.x);\n#if CC_RENDER_MODE != 4\nvertIndex.y = 1. - vertIndex.y;\n#endif\nreturn (aniUV.xy + vertIndex) / vec2(frameTile.x, frameTile.y);\n}\nlayout(set = 1, binding = 1) uniform SampleConstants {\nvec4 u_sampleInfo;\n};\nlayout(set = 1, binding = 2) uniform TickConstants {\nvec4 u_worldRot;\nvec4 u_timeDelta;\n};\nlayout(location = 0) in vec4 a_position_starttime;\nlayout(location = 1) in vec4 a_size_uv;\nlayout(location = 2) in vec4 a_rotation_uv;\nlayout(location = 3) in vec4 a_color;\nlayout(location = 4) in vec4 a_dir_life;\nlayout(location = 5) in float a_rndSeed;\n#if CC_RENDER_MODE == 4\nlayout(location = 6) in vec3 a_texCoord;\nlayout(location = 7) in vec3 a_texCoord3;\nlayout(location = 8) in vec3 a_normal;\nlayout(location = 9) in vec4 a_color1;\n#endif\nvec3 unpackCurveData (sampler2D tex, vec2 coord) {\nvec4 a = texture(tex, coord);\nvec4 b = texture(tex, coord + u_sampleInfo.y);\nfloat c = fract(coord.x * u_sampleInfo.x);\nreturn mix(a.xyz, b.xyz, c);\n}\nvec3 unpackCurveData (sampler2D tex, vec2 coord, out float w) {\nvec4 a = texture(tex, coord);\nvec4 b = texture(tex, coord + u_sampleInfo.y);\nfloat c = fract(coord.x * u_sampleInfo.x);\nw = mix(a.w, b.w, c);\nreturn mix(a.xyz, b.xyz, c);\n}\nfloat pseudoRandom(float x) {\nfloat o = x;\nx = mod(x - 1.0, 2.0) - 1.0;\nfloat freqVar = 10.16640753482;\nfloat y = sin(freqVar * floor(o * 0.5 - 0.5));\nfloat v = max(0.0, 1.0-abs(x));\nv *= 0.7071067812;\nv = y < 0.0 ? -v : v;\nreturn v;\n}\n#if COLOR_OVER_TIME_MODULE_ENABLE\nlayout(set = 1, binding = 10) uniform sampler2D color_over_time_tex0;\nlayout(set = 1, binding = 3) uniform ColorConstant {\nint u_color_mode;\n};\n#endif\n#if ROTATION_OVER_TIME_MODULE_ENABLE\nlayout(set = 1, binding = 11) uniform sampler2D rotation_over_time_tex0;\nlayout(set = 1, binding = 4) uniform RotationConstant {\nint u_rotation_mode;\n};\n#endif\n#if SIZE_OVER_TIME_MODULE_ENABLE\nlayout(set = 1, binding = 12) uniform sampler2D size_over_time_tex0;\nlayout(set = 1, binding = 5) uniform SizeConstant {\nint u_size_mode;\n};\n#endif\n#if FORCE_OVER_TIME_MODULE_ENABLE\nlayout(set = 1, binding = 13) uniform sampler2D force_over_time_tex0;\nlayout(set = 1, binding = 6) uniform ForceConstant {\nint u_force_mode;\nint u_force_space;\n};\n#endif\n#if VELOCITY_OVER_TIME_MODULE_ENABLE\nlayout(set = 1, binding = 14) uniform sampler2D velocity_over_time_tex0;\nlayout(set = 1, binding = 7) uniform VelocityConstant {\nint u_velocity_mode;\nint u_velocity_space;\n};\n#endif\n#if TEXTURE_ANIMATION_MODULE_ENABLE\nlayout(set = 1, binding = 15) uniform sampler2D texture_animation_tex0;\nlayout(set = 1, binding = 8) uniform AnimationConstant {\nvec4 u_anim_info;\n};\n#endif\nfloat repeat (float t, float length) {\nreturn t - floor(t / length) * length;\n}\nvec4 rotateQuat (vec4 p, vec4 q) {\nvec3 iv = cross(q.xyz, p.xyz) + q.w * p.xyz;\nvec3 res = p.xyz + 2.0 * cross(q.xyz, iv);\nreturn vec4(res.xyz, p.w);\n}\nvec4 gpvs_main () {\nfloat activeTime = u_timeDelta.x - a_position_starttime.w;\nfloat normalizedTime = clamp(activeTime / a_dir_life.w, 0.0, 1.0);\nvec2 timeCoord0 = vec2(normalizedTime, 0.);\nvec2 timeCoord1 = vec2(normalizedTime, 1.);\n#if CC_RENDER_MODE == 4\nvec2 vertIdx = vec2(a_texCoord.x, a_texCoord.y);\n#else\nvec2 vertIdx = vec2(a_size_uv.w, a_rotation_uv.w);\n#endif\nvec4 velocity = vec4(a_dir_life.xyz, 0.);\nvec4 pos = vec4(a_position_starttime.xyz, 1.);\nvec3 size = a_size_uv.xyz;\n#if SIZE_OVER_TIME_MODULE_ENABLE\nif (u_size_mode == 1) {\nsize *= unpackCurveData(size_over_time_tex0, timeCoord0);\n} else {\nvec3 size_0 = unpackCurveData(size_over_time_tex0, timeCoord0);\nvec3 size_1 = unpackCurveData(size_over_time_tex0, timeCoord1);\nfloat factor_s = pseudoRandom(a_rndSeed + 39825.);\nsize *= mix(size_0, size_1, factor_s);\n}\n#endif\nvec3 compScale = scale.xyz * size;\n#if FORCE_OVER_TIME_MODULE_ENABLE\nvec3 forceAnim = vec3(0.);\nif (u_force_mode == 1) {\nforceAnim = unpackCurveData(force_over_time_tex0, timeCoord0);\n} else {\nvec3 force_0 = unpackCurveData(force_over_time_tex0, timeCoord0);\nvec3 force_1 = unpackCurveData(force_over_time_tex0, timeCoord1);\nfloat factor_f = pseudoRandom(a_rndSeed + 212165.);\nforceAnim = mix(force_0, force_1, factor_f);\n}\nvec4 forceTrack = vec4(forceAnim, 0.);\nif (u_force_space == 0) {\nforceTrack = rotateQuat(forceTrack, u_worldRot);\n}\nvelocity.xyz += forceTrack.xyz;\n#endif\n#if VELOCITY_OVER_TIME_MODULE_ENABLE\nfloat speedModifier0 = 1.;\nfloat speedModifier1 = 1.;\nvec3 velocityAnim = vec3(0.);\nif (u_velocity_mode == 1) {\nvelocityAnim = unpackCurveData(velocity_over_time_tex0, timeCoord0, speedModifier0);\n} else {\nvec3 vectory_0 = unpackCurveData(velocity_over_time_tex0, timeCoord0, speedModifier0);\nvec3 vectory_1 = unpackCurveData(velocity_over_time_tex0, timeCoord1, speedModifier1);\nfloat factor_v = pseudoRandom(a_rndSeed + 197866.);\nvelocityAnim = mix(vectory_0, vectory_1, factor_v);\nspeedModifier0 = mix(speedModifier0, speedModifier1, factor_v);\n}\nvec4 velocityTrack = vec4(velocityAnim, 0.);\nif (u_velocity_space == 0) {\nvelocityTrack = rotateQuat(velocityTrack, u_worldRot);\n}\nvelocity.xyz += velocityTrack.xyz;\nvelocity.xyz *= speedModifier0;\n#endif\npos.xyz += velocity.xyz * normalizedTime * a_dir_life.w;\n#if !CC_USE_WORLD_SPACE\npos = cc_matWorld * pos;\n#if CC_RENDER_MODE == 1\nvelocity = rotateQuat(velocity, u_worldRot);\n#endif\n#endif\nvec3 startRotation = a_rotation_uv.xyz;\n#if CC_RENDER_MODE != 4\n#if CC_RENDER_MODE == 0\nvec3 rotEuler = startRotation.xyz;\n#elif CC_RENDER_MODE == 1\nvec3 rotEuler = vec3(0.);\n#else\nvec3 rotEuler = vec3(0., 0., startRotation.z);\n#endif\nvec4 rot = quaternionFromEuler(rotEuler);\n#else\nvec4 rot = quaternionFromEuler(startRotation);\n#endif\n#if ROTATION_OVER_TIME_MODULE_ENABLE\nif (u_rotation_mode == 1) {\nvec3 euler = unpackCurveData(rotation_over_time_tex0, timeCoord0) * normalizedTime * a_dir_life.w;\nvec4 quat = eulerToQuat(euler);\nmat3 mLocal = quatToMat3(quat);\nmat3 mStart = quatToMat3(rot);\nrot = mat3ToQuat(mStart * mLocal);\n} else {\nvec3 rotation_0 = unpackCurveData(rotation_over_time_tex0, timeCoord0);\nvec3 rotation_1 = unpackCurveData(rotation_over_time_tex0, timeCoord1);\nfloat factor_r = pseudoRandom(a_rndSeed + 125292.);\nvec3 euler = mix(rotation_0, rotation_1, factor_r) * normalizedTime * a_dir_life.w;\n#if CC_RENDER_MODE == 3 || CC_RENDER_MODE == 2\neuler = vec3(0.0, 0.0, euler.z);\n#endif\nvec4 quat = eulerToQuat(euler);\nmat3 mLocal = quatToMat3(quat);\nmat3 mStart = quatToMat3(rot);\nrot = mat3ToQuat(mStart * mLocal);\n}\n#endif\n#if COLOR_OVER_TIME_MODULE_ENABLE\nif (u_color_mode == 1) {\ncolor = a_color * texture(color_over_time_tex0, timeCoord0);\n} else {\nvec4 color_0 = texture(color_over_time_tex0, timeCoord0);\nvec4 color_1 = texture(color_over_time_tex0, timeCoord1);\nfloat factor_c = pseudoRandom(a_rndSeed + 91041.);\ncolor = a_color * mix(color_0, color_1, factor_c);\n}\n#else\ncolor = a_color;\n#endif\n#if CC_RENDER_MODE != 4\nvec2 cornerOffset = vec2((vertIdx - 0.5));\n#if CC_RENDER_MODE == 1\nrot = vec4(0.0, 0.0, 0.0, 1.0);\n#endif\ncomputeVertPos(pos, cornerOffset, rot, compScale\n#if CC_RENDER_MODE == 0 || CC_RENDER_MODE == 3\n, cc_matViewInv\n#endif\n#if CC_RENDER_MODE == 1\n, cc_cameraPos.xyz\n, velocity\n, frameTile_velLenScale.z\n, frameTile_velLenScale.w\n, a_size_uv.w\n#endif\n);\n#else\nmat3 rotMat = quatToMat3(rot);\nmat3 nodeMat = quatToMat3(nodeRotation);\nrotMat = nodeMat * rotMat;\nrot = mat3ToQuat(rotMat);\nmat4 xformNoScale = matrixFromRT(rot, pos.xyz);\nmat4 xform = matFromRTS(rot, pos.xyz, compScale);\npos = xform * vec4(a_texCoord3, 1);\nvec4 normal = xformNoScale * vec4(a_normal, 0);\ncolor *= a_color1;\n#endif\npos = cc_matViewProj * pos;\nfloat frameIndex = 0.;\n#if TEXTURE_ANIMATION_MODULE_ENABLE\nfloat startFrame = 0.;\nvec3 frameInfo = vec3(0.);\nif (int(u_anim_info.x) == 1) {\nframeInfo = unpackCurveData(texture_animation_tex0, timeCoord0);\n} else {\nvec3 frameInfo0 = unpackCurveData(texture_animation_tex0, timeCoord0);\nvec3 frameInfo1 = unpackCurveData(texture_animation_tex0, timeCoord1);\nfloat factor_t = pseudoRandom(a_rndSeed + 90794.);\nframeInfo = mix(frameInfo0, frameInfo1, factor_t);\n}\nstartFrame = frameInfo.x / u_anim_info.y;\nframeIndex = repeat(u_anim_info.z * (frameInfo.y + startFrame), 1.);\n#endif\nuv = computeUV(frameIndex, vertIdx, frameTile_velLenScale.xy) * mainTiling_Offset.xy + mainTiling_Offset.zw;\nreturn pos;\n}\nvoid main() { gl_Position = gpvs_main(); }", + "frag": "\nprecision mediump float;\nlayout(set = 0, binding = 0) uniform CCGlobal {\nhighp vec4 cc_time;\nmediump vec4 cc_screenSize;\nmediump vec4 cc_nativeSize;\n};\nlayout(set = 0, binding = 1) uniform CCCamera {\nhighp mat4 cc_matView;\nhighp mat4 cc_matViewInv;\nhighp mat4 cc_matProj;\nhighp mat4 cc_matProjInv;\nhighp mat4 cc_matViewProj;\nhighp mat4 cc_matViewProjInv;\nhighp vec4 cc_cameraPos;\nmediump vec4 cc_screenScale;\nmediump vec4 cc_exposure;\nmediump vec4 cc_mainLitDir;\nmediump vec4 cc_mainLitColor;\nmediump vec4 cc_ambientSky;\nmediump vec4 cc_ambientGround;\nmediump vec4 cc_fogColor;\nmediump vec4 cc_fogBase;\nmediump vec4 cc_fogAdd;\nmediump vec4 cc_nearFar;\nmediump vec4 cc_viewPort;\n};\nvec4 CCFragOutput (vec4 color) {\nreturn color;\n}\nlayout(location = 0) in vec2 uv;\nlayout(location = 1) in vec4 color;\nlayout(set = 1, binding = 16) uniform sampler2D mainTexture;\nlayout(set = 1, binding = 9) uniform FragConstants {\nvec4 tintColor;\n};\nvec4 add () {\nvec4 col = 2.0 * color * tintColor * texture(mainTexture, uv);\nreturn CCFragOutput(col);\n}\nlayout(location = 0) out vec4 cc_FragColor;\nvoid main() { cc_FragColor = add(); }", + } + ], + [ + { + "vert": "\nprecision mediump float;\nlayout(set = 1, binding = 0) uniform Constants {\nvec4 mainTiling_Offset;\nvec4 frameTile_velLenScale;\nvec4 scale;\nvec4 nodeRotation;\n};\nlayout(set = 0, binding = 0) uniform CCGlobal {\nhighp vec4 cc_time;\nmediump vec4 cc_screenSize;\nmediump vec4 cc_nativeSize;\n};\nlayout(set = 0, binding = 1) uniform CCCamera {\nhighp mat4 cc_matView;\nhighp mat4 cc_matViewInv;\nhighp mat4 cc_matProj;\nhighp mat4 cc_matProjInv;\nhighp mat4 cc_matViewProj;\nhighp mat4 cc_matViewProjInv;\nhighp vec4 cc_cameraPos;\nmediump vec4 cc_screenScale;\nmediump vec4 cc_exposure;\nmediump vec4 cc_mainLitDir;\nmediump vec4 cc_mainLitColor;\nmediump vec4 cc_ambientSky;\nmediump vec4 cc_ambientGround;\nmediump vec4 cc_fogColor;\nmediump vec4 cc_fogBase;\nmediump vec4 cc_fogAdd;\nmediump vec4 cc_nearFar;\nmediump vec4 cc_viewPort;\n};\nlayout(set = 2, binding = 0) uniform CCLocal {\nhighp mat4 cc_matWorld;\nhighp mat4 cc_matWorldIT;\nhighp vec4 cc_lightingMapUVParam;\n};\nlayout(location = 0) out mediump vec2 uv;\nlayout(location = 1) out mediump vec4 color;\nlayout(location = 0) in vec3 a_position;\nlayout(location = 1) in vec4 a_texCoord;\nlayout(location = 2) in vec3 a_texCoord1;\nlayout(location = 3) in vec3 a_texCoord2;\nlayout(location = 4) in vec4 a_color;\n#if CC_DRAW_WIRE_FRAME\nlayout(location = 2) out vec3 vBarycentric;\n#endif\nvec4 vs_main() {\nhighp vec4 pos = vec4(a_position, 1);\nvec4 velocity = vec4(a_texCoord1.xyz, 0);\n#if !CC_USE_WORLD_SPACE\npos = cc_matWorld * pos;\nvelocity = cc_matWorld * velocity;\n#endif\nfloat vertOffset = (a_texCoord.x - 0.5) * a_texCoord.y;\nvec3 camUp = normalize(cross(pos.xyz - cc_cameraPos.xyz, velocity.xyz));\npos.xyz += camUp * vertOffset;\npos = cc_matViewProj * pos;\nuv = a_texCoord.zw * mainTiling_Offset.xy + mainTiling_Offset.zw;;\ncolor = a_color;\n#if CC_DRAW_WIRE_FRAME\nvBarycentric = a_texCoord2;\n#endif\nreturn pos;\n}\nvoid main() { gl_Position = vs_main(); }", + "frag": "\nprecision mediump float;\nlayout(set = 0, binding = 0) uniform CCGlobal {\nhighp vec4 cc_time;\nmediump vec4 cc_screenSize;\nmediump vec4 cc_nativeSize;\n};\nlayout(set = 0, binding = 1) uniform CCCamera {\nhighp mat4 cc_matView;\nhighp mat4 cc_matViewInv;\nhighp mat4 cc_matProj;\nhighp mat4 cc_matProjInv;\nhighp mat4 cc_matViewProj;\nhighp mat4 cc_matViewProjInv;\nhighp vec4 cc_cameraPos;\nmediump vec4 cc_screenScale;\nmediump vec4 cc_exposure;\nmediump vec4 cc_mainLitDir;\nmediump vec4 cc_mainLitColor;\nmediump vec4 cc_ambientSky;\nmediump vec4 cc_ambientGround;\nmediump vec4 cc_fogColor;\nmediump vec4 cc_fogBase;\nmediump vec4 cc_fogAdd;\nmediump vec4 cc_nearFar;\nmediump vec4 cc_viewPort;\n};\nvec4 CCFragOutput (vec4 color) {\nreturn color;\n}\nlayout(location = 0) in vec2 uv;\nlayout(location = 1) in vec4 color;\n#if CC_DRAW_WIRE_FRAME\nlayout(location = 2) in vec3 vBarycentric;\n#endif\nlayout(set = 1, binding = 2) uniform sampler2D mainTexture;\nlayout(set = 1, binding = 1) uniform FragConstants {\nvec4 tintColor;\n};\nvec4 add () {\nvec4 col = 2.0 * color * tintColor * texture(mainTexture, uv);\n#if CC_DRAW_WIRE_FRAME\nif (any(lessThan(vBarycentric, vec3(0.02)))) {\ncol = vec4(0., 1., 1., 1.);\n}\n#endif\nreturn CCFragOutput(col);\n}\nlayout(location = 0) out vec4 cc_FragColor;\nvoid main() { cc_FragColor = add(); }", + } + ], + [ + { + "vert": "\nprecision highp float;\nvec4 quaternionFromAxis (vec3 xAxis,vec3 yAxis,vec3 zAxis){\nmat3 m = mat3(xAxis,yAxis,zAxis);\nfloat trace = m[0][0] + m[1][1] + m[2][2];\nvec4 quat;\nif (trace > 0.) {\nfloat s = 0.5 / sqrt(trace + 1.0);\nquat.w = 0.25 / s;\nquat.x = (m[2][1] - m[1][2]) * s;\nquat.y = (m[0][2] - m[2][0]) * s;\nquat.z = (m[1][0] - m[0][1]) * s;\n} else if ((m[0][0] > m[1][1]) && (m[0][0] > m[2][2])) {\nfloat s = 2.0 * sqrt(1.0 + m[0][0] - m[1][1] - m[2][2]);\nquat.w = (m[2][1] - m[1][2]) / s;\nquat.x = 0.25 * s;\nquat.y = (m[0][1] + m[1][0]) / s;\nquat.z = (m[0][2] + m[2][0]) / s;\n} else if (m[1][1] > m[2][2]) {\nfloat s = 2.0 * sqrt(1.0 + m[1][1] - m[0][0] - m[2][2]);\nquat.w = (m[0][2] - m[2][0]) / s;\nquat.x = (m[0][1] + m[1][0]) / s;\nquat.y = 0.25 * s;\nquat.z = (m[1][2] + m[2][1]) / s;\n} else {\nfloat s = 2.0 * sqrt(1.0 + m[2][2] - m[0][0] - m[1][1]);\nquat.w = (m[1][0] - m[0][1]) / s;\nquat.x = (m[0][2] + m[2][0]) / s;\nquat.y = (m[1][2] + m[2][1]) / s;\nquat.z = 0.25 * s;\n}\nfloat len = quat.x * quat.x + quat.y * quat.y + quat.z * quat.z + quat.w * quat.w;\nif (len > 0.) {\nlen = 1. / sqrt(len);\nquat.x = quat.x * len;\nquat.y = quat.y * len;\nquat.z = quat.z * len;\nquat.w = quat.w * len;\n}\nreturn quat;\n}\nvec4 quaternionFromEuler (vec3 angle){\nfloat x = angle.x / 2.;\nfloat y = angle.y / 2.;\nfloat z = angle.z / 2.;\nfloat sx = sin(x);\nfloat cx = cos(x);\nfloat sy = sin(y);\nfloat cy = cos(y);\nfloat sz = sin(z);\nfloat cz = cos(z);\nvec4 quat = vec4(0);\nquat.x = sx * cy * cz + cx * sy * sz;\nquat.y = cx * sy * cz + sx * cy * sz;\nquat.z = cx * cy * sz - sx * sy * cz;\nquat.w = cx * cy * cz - sx * sy * sz;\nreturn quat;\n}\nmat4 matrixFromRT (vec4 q, vec3 p){\nfloat x2 = q.x + q.x;\nfloat y2 = q.y + q.y;\nfloat z2 = q.z + q.z;\nfloat xx = q.x * x2;\nfloat xy = q.x * y2;\nfloat xz = q.x * z2;\nfloat yy = q.y * y2;\nfloat yz = q.y * z2;\nfloat zz = q.z * z2;\nfloat wx = q.w * x2;\nfloat wy = q.w * y2;\nfloat wz = q.w * z2;\nreturn mat4(\n1. - (yy + zz), xy + wz, xz - wy, 0,\nxy - wz, 1. - (xx + zz), yz + wx, 0,\nxz + wy, yz - wx, 1. - (xx + yy), 0,\np.x, p.y, p.z, 1\n);\n}\nmat4 matFromRTS (vec4 q, vec3 t, vec3 s){\nfloat x = q.x, y = q.y, z = q.z, w = q.w;\nfloat x2 = x + x;\nfloat y2 = y + y;\nfloat z2 = z + z;\nfloat xx = x * x2;\nfloat xy = x * y2;\nfloat xz = x * z2;\nfloat yy = y * y2;\nfloat yz = y * z2;\nfloat zz = z * z2;\nfloat wx = w * x2;\nfloat wy = w * y2;\nfloat wz = w * z2;\nfloat sx = s.x;\nfloat sy = s.y;\nfloat sz = s.z;\nreturn mat4((1. - (yy + zz)) * sx, (xy + wz) * sx, (xz - wy) * sx, 0,\n(xy - wz) * sy, (1. - (xx + zz)) * sy, (yz + wx) * sy, 0,\n(xz + wy) * sz, (yz - wx) * sz, (1. - (xx + yy)) * sz, 0,\nt.x, t.y, t.z, 1);\n}\nvec4 quatMultiply (vec4 a, vec4 b){\nvec4 quat;\nquat.x = a.x * b.w + a.w * b.x + a.y * b.z - a.z * b.y;\nquat.y = a.y * b.w + a.w * b.y + a.z * b.x - a.x * b.z;\nquat.z = a.z * b.w + a.w * b.z + a.x * b.y - a.y * b.x;\nquat.w = a.w * b.w - a.x * b.x - a.y * b.y - a.z * b.z;\nreturn quat;\n}\nvoid rotateVecFromQuat (inout vec3 v, vec4 q){\nfloat ix = q.w * v.x + q.y * v.z - q.z * v.y;\nfloat iy = q.w * v.y + q.z * v.x - q.x * v.z;\nfloat iz = q.w * v.z + q.x * v.y - q.y * v.x;\nfloat iw = -q.x * v.x - q.y * v.y - q.z * v.z;\nv.x = ix * q.w + iw * -q.x + iy * -q.z - iz * -q.y;\nv.y = iy * q.w + iw * -q.y + iz * -q.x - ix * -q.z;\nv.z = iz * q.w + iw * -q.z + ix * -q.y - iy * -q.x;\n}\nvec3 rotateInLocalSpace (vec3 pos, vec3 xAxis, vec3 yAxis, vec3 zAxis, vec4 q){\nvec4 viewQuat = quaternionFromAxis(xAxis, yAxis, zAxis);\nvec4 rotQuat = quatMultiply(viewQuat, q);\nrotateVecFromQuat(pos, rotQuat);\nreturn pos;\n}\nmat3 quatToMat3(vec4 q) {\nvec3 m0 = vec3(\n1.0 - 2.0 * q.y * q.y - 2.0 * q.z * q.z,\n2.0 * q.x * q.y + 2.0 * q.w * q.z,\n2.0 * q.x * q.z - 2.0 * q.w * q.y);\nvec3 m1 = vec3(\n2.0 * q.x * q.y - 2.0 * q.w * q.z,\n1.0 - 2.0 * q.x * q.x - 2.0 * q.z * q.z,\n2.0 * q.y * q.z + 2.0 * q.w * q.x);\nvec3 m2 = vec3(\n2.0 * q.x * q.z + 2.0 * q.w * q.y,\n2.0 * q.y * q.z - 2.0 * q.w * q.x,\n1.0 - 2.0 * q.x * q.x - 2.0 * q.y * q.y);\nreturn mat3(m0, m1, m2);\n}\nvec4 mat3ToQuat(mat3 mat) {\nfloat tr = mat[0][0] + mat[1][1] + mat[2][2];\nfloat qw, qx, qy, qz;\nif (tr > 0.0) {\nfloat S = sqrt(tr + 1.0) * 2.0;\nfloat invS = 1.0 / S;\nqw = 0.25 * S;\nqx = (mat[1][2] - mat[2][1]) * invS;\nqy = (mat[2][0] - mat[0][2]) * invS;\nqz = (mat[0][1] - mat[1][0]) * invS;\n} else if ((mat[0][0] > mat[1][1])&&(mat[0][0] > mat[2][2])) {\nfloat S = sqrt(1.0 + mat[0][0] - mat[1][1] - mat[2][2]) * 2.0;\nfloat invS = 1.0 / S;\nqw = (mat[1][2] - mat[2][1]) * invS;\nqx = 0.25 * S;\nqy = (mat[1][0] + mat[0][1]) * invS;\nqz = (mat[2][0] + mat[0][2]) * invS;\n} else if (mat[1][1] > mat[2][2]) {\nfloat S = sqrt(1.0 + mat[1][1] - mat[0][0] - mat[2][2]) * 2.0;\nfloat invS = 1.0 / S;\nqw = (mat[2][0] - mat[0][2]) * invS;\nqx = (mat[1][0] + mat[0][1]) * invS;\nqy = 0.25 * S;\nqz = (mat[2][1] + mat[1][2]) * invS;\n} else {\nfloat S = sqrt(1.0 + mat[2][2] - mat[0][0] - mat[1][1]) * 2.0;\nfloat invS = 1.0 / S;\nqw = (mat[0][1] - mat[1][0]) * invS;\nqx = (mat[2][0] + mat[0][2]) * invS;\nqy = (mat[2][1] + mat[1][2]) * invS;\nqz = 0.25 * S;\n}\nreturn vec4(qx, qy, qz, qw);\n}\nlayout(set = 1, binding = 0) uniform Constants {\nvec4 mainTiling_Offset;\nvec4 frameTile_velLenScale;\nvec4 scale;\nvec4 nodeRotation;\n};\nlayout(set = 0, binding = 0) uniform CCGlobal {\nhighp vec4 cc_time;\nmediump vec4 cc_screenSize;\nmediump vec4 cc_nativeSize;\n};\nlayout(set = 0, binding = 1) uniform CCCamera {\nhighp mat4 cc_matView;\nhighp mat4 cc_matViewInv;\nhighp mat4 cc_matProj;\nhighp mat4 cc_matProjInv;\nhighp mat4 cc_matViewProj;\nhighp mat4 cc_matViewProjInv;\nhighp vec4 cc_cameraPos;\nmediump vec4 cc_screenScale;\nmediump vec4 cc_exposure;\nmediump vec4 cc_mainLitDir;\nmediump vec4 cc_mainLitColor;\nmediump vec4 cc_ambientSky;\nmediump vec4 cc_ambientGround;\nmediump vec4 cc_fogColor;\nmediump vec4 cc_fogBase;\nmediump vec4 cc_fogAdd;\nmediump vec4 cc_nearFar;\nmediump vec4 cc_viewPort;\n};\nlayout(set = 2, binding = 0) uniform CCLocal {\nhighp mat4 cc_matWorld;\nhighp mat4 cc_matWorldIT;\nhighp vec4 cc_lightingMapUVParam;\n};\nlayout(location = 0) out mediump vec2 uv;\nlayout(location = 1) out mediump vec4 color;\nvoid computeVertPos (inout vec4 pos, vec2 vertOffset, vec4 q, vec3 s\n#if CC_RENDER_MODE == 0 || CC_RENDER_MODE == 3\n, mat4 viewInv\n#endif\n#if CC_RENDER_MODE == 1\n, vec3 eye\n, vec4 velocity\n, float velocityScale\n, float lengthScale\n, float xIndex\n#endif\n) {\n#if CC_RENDER_MODE == 0\nvec3 viewSpaceVert = vec3(vertOffset.x * s.x, vertOffset.y * s.y, 0.);\nvec3 camX = normalize(vec3(viewInv[0][0], viewInv[1][0], viewInv[2][0]));\nvec3 camY = normalize(vec3(viewInv[0][1], viewInv[1][1], viewInv[2][1]));\nvec3 camZ = normalize(vec3(viewInv[0][2], viewInv[1][2], viewInv[2][2]));\npos.xyz += rotateInLocalSpace(viewSpaceVert, camX, camY, camZ, q);\n#elif CC_RENDER_MODE == 1\nvec3 camRight = normalize(cross(pos.xyz - eye, velocity.xyz)) * s.x;\nvec3 camUp = velocity.xyz * velocityScale + normalize(velocity.xyz) * lengthScale * s.y;\npos.xyz += (camRight * abs(vertOffset.x) * sign(vertOffset.y)) - camUp * xIndex;\n#elif CC_RENDER_MODE == 2\nvec3 viewSpaceVert = vec3(vertOffset.x * s.x, vertOffset.y * s.y, 0.);\nvec3 camX = vec3(1, 0, 0);\nvec3 camY = vec3(0, 0, -1);\npos.xyz += rotateInLocalSpace(viewSpaceVert, camX, camY, cross(camX, camY), q);\n#elif CC_RENDER_MODE == 3\nvec3 viewSpaceVert = vec3(vertOffset.x * s.x, vertOffset.y * s.y, 0.);\nrotateVecFromQuat(viewSpaceVert, q);\nvec3 camX = normalize(vec3(cc_matView[0][0], cc_matView[1][0], cc_matView[2][0]));\nvec3 camY = vec3(0, 1, 0);\nvec3 offset = camX * viewSpaceVert.x + camY * viewSpaceVert.y;\npos.xyz += offset;\n#else\npos.x += vertOffset.x;\npos.y += vertOffset.y;\n#endif\n}\nvec2 computeUV (float frameIndex, vec2 vertIndex, vec2 frameTile){\nvec2 aniUV = vec2(0, floor(frameIndex * frameTile.y));\naniUV.x = floor(frameIndex * frameTile.x * frameTile.y - aniUV.y * frameTile.x);\n#if CC_RENDER_MODE != 4\nvertIndex.y = 1. - vertIndex.y;\n#endif\nreturn (aniUV.xy + vertIndex) / vec2(frameTile.x, frameTile.y);\n}\nlayout(location = 0) in vec3 a_position;\nlayout(location = 1) in vec3 a_texCoord;\nlayout(location = 2) in vec3 a_texCoord1;\nlayout(location = 3) in vec3 a_texCoord2;\nlayout(location = 4) in vec4 a_color;\n#if CC_RENDER_MODE == 1\nlayout(location = 8) in vec3 a_color1;\n#endif\n#if CC_RENDER_MODE == 4\nlayout(location = 6) in vec3 a_texCoord3;\nlayout(location = 7) in vec3 a_normal;\nlayout(location = 8) in vec4 a_color1;\n#endif\nvec4 lpvs_main () {\nvec3 compScale = scale.xyz * a_texCoord1;\nvec4 pos = vec4(a_position, 1);\n#if CC_RENDER_MODE == 1\nvec4 velocity = vec4(a_color1.xyz, 0);\n#endif\n#if !CC_USE_WORLD_SPACE\npos = cc_matWorld * pos;\n#if CC_RENDER_MODE == 1\nvelocity = cc_matWorld * velocity;\n#endif\n#endif\n#if ROTATION_OVER_TIME_MODULE_ENABLE\nvec3 rotTmp = a_texCoord2;\nfloat mulFactor = 1.0;\nif (rotTmp.x > 10.0 * 0.5) {\nrotTmp.x -= 10.0;\nmulFactor = -1.0;\n}\nvec4 rot = vec4(rotTmp, 0.0);\nrot.w = mulFactor * sqrt(1.0 - rot.x * rot.x - rot.y * rot.y - rot.z * rot.z);\n#else\n#if CC_RENDER_MODE != 4\n#if CC_RENDER_MODE == 0\nvec3 rotEuler = a_texCoord2;\n#elif CC_RENDER_MODE == 1\nvec3 rotEuler = vec3(0.);\n#else\nvec3 rotEuler = vec3(0., 0., a_texCoord2.z);\n#endif\nvec4 rot = quaternionFromEuler(rotEuler);\n#else\nvec4 rot = quaternionFromEuler(a_texCoord2);\n#endif\n#endif\n#if CC_RENDER_MODE != 4\nvec2 cornerOffset = vec2((a_texCoord.xy - 0.5));\n#if CC_RENDER_MODE == 0 || CC_RENDER_MODE == 3\ncomputeVertPos(pos, cornerOffset, rot, compScale, cc_matViewInv);\n#elif CC_RENDER_MODE == 1\ncomputeVertPos(pos, cornerOffset, rot, compScale, cc_cameraPos.xyz, velocity, frameTile_velLenScale.z, frameTile_velLenScale.w, a_texCoord.x);\n#elif 2\ncomputeVertPos(pos, cornerOffset, rot, compScale);\n#endif\ncolor = a_color;\n#else\nmat3 rotMat = quatToMat3(rot);\nmat3 nodeMat = quatToMat3(nodeRotation);\nrotMat = nodeMat * rotMat;\nrot = mat3ToQuat(rotMat);\nmat4 xformNoScale = matrixFromRT(rot, pos.xyz);\nmat4 xform = matFromRTS(rot, pos.xyz, compScale);\npos = xform * vec4(a_texCoord3, 1);\nvec4 normal = xformNoScale * vec4(a_normal, 0);\ncolor = a_color * a_color1;\n#endif\nuv = computeUV(a_texCoord.z, a_texCoord.xy, frameTile_velLenScale.xy) * mainTiling_Offset.xy + mainTiling_Offset.zw;\npos = cc_matViewProj * pos;\nreturn pos;\n}\nvoid main() { gl_Position = lpvs_main(); }", + "frag": "\nprecision mediump float;\nlayout(set = 0, binding = 0) uniform CCGlobal {\nhighp vec4 cc_time;\nmediump vec4 cc_screenSize;\nmediump vec4 cc_nativeSize;\n};\nlayout(set = 0, binding = 1) uniform CCCamera {\nhighp mat4 cc_matView;\nhighp mat4 cc_matViewInv;\nhighp mat4 cc_matProj;\nhighp mat4 cc_matProjInv;\nhighp mat4 cc_matViewProj;\nhighp mat4 cc_matViewProjInv;\nhighp vec4 cc_cameraPos;\nmediump vec4 cc_screenScale;\nmediump vec4 cc_exposure;\nmediump vec4 cc_mainLitDir;\nmediump vec4 cc_mainLitColor;\nmediump vec4 cc_ambientSky;\nmediump vec4 cc_ambientGround;\nmediump vec4 cc_fogColor;\nmediump vec4 cc_fogBase;\nmediump vec4 cc_fogAdd;\nmediump vec4 cc_nearFar;\nmediump vec4 cc_viewPort;\n};\nvec4 CCFragOutput (vec4 color) {\nreturn color;\n}\nlayout(location = 0) in vec2 uv;\nlayout(location = 1) in vec4 color;\nlayout(set = 1, binding = 2) uniform sampler2D mainTexture;\nlayout(set = 1, binding = 1) uniform FragConstants {\nvec4 tintColor;\n};\nvec4 add () {\nvec4 col = 2.0 * color * tintColor * texture(mainTexture, uv);\nreturn CCFragOutput(col);\n}\nlayout(location = 0) out vec4 cc_FragColor;\nvoid main() { cc_FragColor = add(); }", + } + ], + [ + { + "vert": "\nprecision highp float;\nlayout(set = 0, binding = 0) uniform CCGlobal {\nhighp vec4 cc_time;\nmediump vec4 cc_screenSize;\nmediump vec4 cc_nativeSize;\n};\nlayout(set = 0, binding = 1) uniform CCCamera {\nhighp mat4 cc_matView;\nhighp mat4 cc_matViewInv;\nhighp mat4 cc_matProj;\nhighp mat4 cc_matProjInv;\nhighp mat4 cc_matViewProj;\nhighp mat4 cc_matViewProjInv;\nhighp vec4 cc_cameraPos;\nmediump vec4 cc_screenScale;\nmediump vec4 cc_exposure;\nmediump vec4 cc_mainLitDir;\nmediump vec4 cc_mainLitColor;\nmediump vec4 cc_ambientSky;\nmediump vec4 cc_ambientGround;\nmediump vec4 cc_fogColor;\nmediump vec4 cc_fogBase;\nmediump vec4 cc_fogAdd;\nmediump vec4 cc_nearFar;\nmediump vec4 cc_viewPort;\n};\n#if USE_LOCAL\nlayout(set = 2, binding = 0) uniform CCLocal {\nhighp mat4 cc_matWorld;\nhighp mat4 cc_matWorldIT;\nhighp vec4 cc_lightingMapUVParam;\n};\n#endif\nlayout(location = 0) in vec3 a_position;\nlayout(location = 1) in vec2 a_texCoord;\nlayout(location = 2) in vec4 a_color;\nlayout(location = 0) out vec4 v_light;\nlayout(location = 1) out vec2 uv0;\n#if TWO_COLORED\nlayout(location = 3) in vec4 a_color2;\nlayout(location = 2) out vec4 v_dark;\n#endif\nvec4 vert () {\nvec4 pos = vec4(a_position, 1);\n#if USE_LOCAL\npos = cc_matWorld * pos;\n#endif\npos = cc_matViewProj * pos;\nuv0 = a_texCoord;\nv_light = a_color;\n#if TWO_COLORED\nv_dark = a_color2;\n#endif\nreturn pos;\n}\nvoid main() { gl_Position = vert(); }", + "frag": "\nprecision highp float;\n#if USE_ALPHA_TEST\nlayout(set = 1, binding = 0) uniform ALPHA_TEST_DATA {\nfloat alphaThreshold;\n};\n#endif\nvoid ALPHA_TEST (in vec4 color) {\n#if USE_ALPHA_TEST\nif (color.a < alphaThreshold) discard;\n#endif\n}\nvoid ALPHA_TEST (in float alpha) {\n#if USE_ALPHA_TEST\nif (alpha < alphaThreshold) discard;\n#endif\n}\nlayout(location = 0) in vec4 v_light;\n#if TWO_COLORED\nlayout(location = 2) in vec4 v_dark;\n#endif\nlayout(location = 1) in vec2 uv0;\nlayout(set = 2, binding = 11) uniform sampler2D cc_spriteTexture;\nvec4 frag () {\nvec4 o = vec4(1, 1, 1, 1);\n#if TWO_COLORED\nvec4 texColor = vec4(1, 1, 1, 1);\ntexColor *= texture(cc_spriteTexture, uv0);\no.a = texColor.a * v_light.a;\no.rgb = ((texColor.a - 1.0) * v_dark.a + 1.0 - texColor.rgb) * v_dark.rgb + texColor.rgb * v_light.rgb;\n#else\no *= texture(cc_spriteTexture, uv0);\no *= v_light;\n#endif\nALPHA_TEST(o);\nreturn o;\n}\nlayout(location = 0) out vec4 cc_FragColor;\nvoid main() { cc_FragColor = frag(); }", + } + ], + [ + { + "vert": "\nprecision highp float;\nstruct SpriteVertexData {\nvec4 position;\nvec4 color;\n};\nstruct SpriteFragmentData {\nvec2 uv;\n};\nlayout(set = 0, binding = 0) uniform CCGlobal {\nhighp vec4 cc_time;\nmediump vec4 cc_screenSize;\nmediump vec4 cc_nativeSize;\n};\nlayout(set = 0, binding = 1) uniform CCCamera {\nhighp mat4 cc_matView;\nhighp mat4 cc_matViewInv;\nhighp mat4 cc_matProj;\nhighp mat4 cc_matProjInv;\nhighp mat4 cc_matViewProj;\nhighp mat4 cc_matViewProjInv;\nhighp vec4 cc_cameraPos;\nmediump vec4 cc_screenScale;\nmediump vec4 cc_exposure;\nmediump vec4 cc_mainLitDir;\nmediump vec4 cc_mainLitColor;\nmediump vec4 cc_ambientSky;\nmediump vec4 cc_ambientGround;\nmediump vec4 cc_fogColor;\nmediump vec4 cc_fogBase;\nmediump vec4 cc_fogAdd;\nmediump vec4 cc_nearFar;\nmediump vec4 cc_viewPort;\n};\nlayout(location = 0) in vec3 a_position;\nlayout(location = 1) in vec2 a_texCoord;\nlayout(location = 2) in float a_batch_id;\nlayout(location = 0) out vec2 v_uv0;\nlayout(location = 1) out float v_uvMode;\nlayout(location = 2) out vec4 v_uvSizeOffset;\nlayout(location = 3) out vec4 v_uvParams0;\nlayout(location = 4) out vec4 v_uvParams1;\nstruct SpriteVertexInternalData {\nvec4 rotation;\nvec3 translation;\nvec3 scale;\nvec4 uvSizeOffset;\nfloat uvMode;\nvec4 uvParams;\nfloat filltype;\n};\nlayout(set = 2, binding = 5) uniform CCUILocal {\nvec4 cc_local_data[(CC_DEVICE_MAX_VERTEX_UNIFORM_VECTORS - CC_EFFECT_USED_VERTEX_UNIFORM_VECTORS) / 5 * 5];\n};\nvec3 VectorTransformQuat (vec3 v, vec4 q) {\nreturn v + 2.0 * cross(q.xyz, cross(q.xyz, v) + q.w * v);\n}\nvoid CCSpriteInput(out SpriteVertexData i0) {\nvec4 data0 = cc_local_data[int(a_batch_id) * 5];\nvec4 data1 = cc_local_data[int(a_batch_id) * 5 + 1];\nvec4 data2 = cc_local_data[int(a_batch_id) * 5 + 2];\nvec4 data3 = cc_local_data[int(a_batch_id) * 5 + 3];\nvec4 data4 = cc_local_data[int(a_batch_id) * 5 + 4];\nfloat rg = data0.w;\nfloat r = floor(rg);\nfloat ba = data2.z;\nfloat b = floor(ba);\nSpriteVertexInternalData i1;\ni1.rotation = data1;\ni1.translation = data0.xyz;\ni1.scale = vec3(data2.xy, 1.0);\ni1.uvSizeOffset = data3;\ni1.filltype = fract(data2.w) * 10.0;\ni1.uvMode = data2.w;\ni1.uvParams = data4;\ni0.position = vec4(VectorTransformQuat(a_position * i1.scale, i1.rotation) + i1.translation, 1.0);\ni0.color = vec4(r * (1.0 / 255.0), rg - r, b * (1.0 / 255.0), ba - b);\nvec2 uvWithRotation;\nif (i1.uvSizeOffset.x < 0.0) {\ni1.uvSizeOffset.x = abs(i1.uvSizeOffset.x);\nuvWithRotation = vec2(1.0 - a_texCoord.y, a_texCoord.x);\n} else {\nuvWithRotation = a_texCoord;\n}\nif (i1.uvMode >= 3.0) {\nv_uv0 = uvWithRotation;\nv_uvSizeOffset = i1.uvSizeOffset;\nv_uvParams0 = vec4(i1.uvParams.xy, i1.filltype, 0);\nif (i1.filltype >= 2.0) {\nv_uvParams1 = i1.uvParams;\n} else if (i1.filltype >= 1.0) {\nv_uvParams0 = vec4(1.0 - v_uvParams0.y, 1.0 - v_uvParams0.x, v_uvParams0.zw);\n}\n} else if (i1.uvMode >= 2.0) {\nv_uv0 = uvWithRotation * i1.uvParams.xy;\nv_uv0.y -= fract(i1.uvParams.y);\nv_uvSizeOffset = i1.uvSizeOffset;\n} else if (i1.uvMode >= 1.0) {\nv_uv0 = uvWithRotation;\nv_uvSizeOffset = i1.uvSizeOffset;\nvec4 params0 = fract(i1.uvParams);\nvec4 params1 = floor(i1.uvParams) / 2048.0;\nv_uvParams0 = vec4(params0.xy, params1.xy);\nv_uvParams1 = vec4(params0.zw, params1.zw);\n} else {\nv_uv0 = uvWithRotation * i1.uvSizeOffset.xy + i1.uvSizeOffset.zw;\n}\nv_uvMode = i1.uvMode;\n#if SAMPLE_FROM_RT\nv_uv0 = cc_cameraPos.w > 1.0 ? vec2(v_uv0.x, 1.0 - v_uv0.y) : v_uv0;\n#endif\n}\nlayout(location = 5) out vec4 v_color;\nvec4 vert () {\nSpriteVertexData i;\nCCSpriteInput(i);\nv_color = i.color;\nvec4 pos = i.position;\n#if USE_PIXEL_ALIGNMENT\npos = cc_matView * pos;\npos.xyz = floor(pos.xyz);\npos = cc_matProj * pos;\n#else\npos = cc_matViewProj * pos;\n#endif\nreturn pos;\n}\nvoid main() { gl_Position = vert(); }", + "frag": "\nprecision highp float;\nstruct SpriteVertexData {\nvec4 position;\nvec4 color;\n};\nstruct SpriteFragmentData {\nvec2 uv;\n};\nvec4 CCSampleWithAlphaSeparated(sampler2D tex, vec2 uv) {\n#if CC_USE_EMBEDDED_ALPHA\nreturn vec4(texture(tex, uv).rgb, texture(tex, uv + vec2(0.0, 0.5)).r);\n#else\nreturn texture(tex, uv);\n#endif\n}\nlayout(location = 0) in vec2 v_uv0;\nlayout(location = 1) in float v_uvMode;\nlayout(location = 2) in vec4 v_uvSizeOffset;\nlayout(location = 3) in vec4 v_uvParams0;\nlayout(location = 4) in vec4 v_uvParams1;\nvec2 evalSlicedUV(vec2 uv) {\nvec4 p0 = mix(vec4(0.0), v_uvParams0, step(v_uvParams0.xyxy, uv.xyxy));\np0 = mix( p0, v_uvParams1, step(v_uvParams1.xyxy, uv.xyxy));\nvec4 p1 = mix(vec4(1.0), v_uvParams1, step(uv.xyxy, v_uvParams1.xyxy));\np1 = mix( p1, v_uvParams0, step(uv.xyxy, v_uvParams0.xyxy));\nvec2 k = (p1.zw - p0.zw) / (p1.xy - p0.xy);\nvec2 b = (p1.xy * p0.zw - p0.xy * p1.zw) / (p1.xy - p0.xy);\nreturn k * uv + b;\n}\nfloat evalFilledUV(vec2 uv, float mode) {\nfloat alpha = 1.0;\nif (mode >= 2.0) {\nfloat start = v_uvParams1.x;\nfloat range = v_uvParams1.y;\nvec2 dir = uv - v_uvParams1.zw;\nfloat angle = -atan(dir.y, dir.x) * 0.3183098861838;\nif (range < 0.0) {\nangle += mix(0.0, -2.0, step(start, angle));\nalpha = step(start + range, angle);\n} else {\nangle += mix(0.0, 2.0, step(angle, start));\nalpha = step(angle, start + range);\n}\n} else if (mode >= 1.0) {\nif (uv.y >= v_uvParams0.x && uv.y <= v_uvParams0.y) {\nalpha = 1.0;\n} else {\nalpha = 0.0;\n}\n} else {\nif (uv.x >= v_uvParams0.x && uv.x <= v_uvParams0.y) {\nalpha = 1.0;\n} else {\nalpha = 0.0;\n}\n}\nreturn alpha;\n}\nvoid CCSpriteInput(out SpriteFragmentData i) {\n#if USE_TEXTURE\nif(v_uvMode >= 3.0) {\ni.uv = v_uv0 * v_uvSizeOffset.xy + v_uvSizeOffset.zw;\n} else if (v_uvMode >= 2.0) {\ni.uv = fract(v_uv0) * v_uvSizeOffset.xy + v_uvSizeOffset.zw;\n} else if (v_uvMode >= 1.0) {\ni.uv = evalSlicedUV(v_uv0) * v_uvSizeOffset.xy + v_uvSizeOffset.zw;\n} else {\ni.uv = v_uv0;\n}\n#endif\n}\nvec4 CCSpriteSample(sampler2D tex, vec2 uv) {\nvec4 o = CCSampleWithAlphaSeparated(tex, uv);\nif (v_uvMode >= 3.0) {\no.a *= evalFilledUV(v_uv0, v_uvParams0.z);\n}\nreturn o;\n}\nvec3 SRGBToLinear (vec3 gamma) {\nreturn gamma * gamma;\n}\nlayout(location = 5) in vec4 v_color;\n#if USE_TEXTURE\nlayout(set = 2, binding = 11) uniform sampler2D cc_spriteTexture;\n#endif\nvec4 frag () {\nSpriteFragmentData i;\nCCSpriteInput(i);\n#if USE_TEXTURE\nvec4 color = v_color * CCSpriteSample(cc_spriteTexture, i.uv);\n#else\nvec4 color = v_color;\n#endif\n#if IS_GRAY\ncolor.rgb = SRGBToLinear(color.rgb);\ncolor.rgb = vec3(dot(color.rgb, vec3(0.2126, 0.7152, 0.0722)));\ncolor.rgb = sqrt(color.rgb);\n#endif\nreturn color;\n}\nlayout(location = 0) out vec4 cc_FragColor;\nvoid main() { cc_FragColor = frag(); }", + } + ], + [ + { + "vert": "\nprecision highp float;\nlayout(set = 0, binding = 0) uniform CCGlobal {\nhighp vec4 cc_time;\nmediump vec4 cc_screenSize;\nmediump vec4 cc_nativeSize;\n};\nlayout(set = 0, binding = 1) uniform CCCamera {\nhighp mat4 cc_matView;\nhighp mat4 cc_matViewInv;\nhighp mat4 cc_matProj;\nhighp mat4 cc_matProjInv;\nhighp mat4 cc_matViewProj;\nhighp mat4 cc_matViewProjInv;\nhighp vec4 cc_cameraPos;\nmediump vec4 cc_screenScale;\nmediump vec4 cc_exposure;\nmediump vec4 cc_mainLitDir;\nmediump vec4 cc_mainLitColor;\nmediump vec4 cc_ambientSky;\nmediump vec4 cc_ambientGround;\nmediump vec4 cc_fogColor;\nmediump vec4 cc_fogBase;\nmediump vec4 cc_fogAdd;\nmediump vec4 cc_nearFar;\nmediump vec4 cc_viewPort;\n};\n#if USE_LOCAL\nlayout(set = 2, binding = 0) uniform CCLocal {\nhighp mat4 cc_matWorld;\nhighp mat4 cc_matWorldIT;\nhighp vec4 cc_lightingMapUVParam;\n};\n#endif\n#if SAMPLE_FROM_RT\n#endif\nlayout(location = 0) in vec3 a_position;\nlayout(location = 1) in vec2 a_texCoord;\nlayout(location = 2) in vec4 a_color;\nlayout(location = 0) out vec4 color;\nlayout(location = 1) out vec2 uv0;\nvec4 vert () {\nvec4 pos = vec4(a_position, 1);\n#if USE_LOCAL\npos = cc_matWorld * pos;\n#endif\n#if USE_PIXEL_ALIGNMENT\npos = cc_matView * pos;\npos.xyz = floor(pos.xyz);\npos = cc_matProj * pos;\n#else\npos = cc_matViewProj * pos;\n#endif\nuv0 = a_texCoord;\n#if SAMPLE_FROM_RT\nuv0 = cc_cameraPos.w > 1.0 ? vec2(uv0.x, 1.0 - uv0.y) : uv0;\n#endif\ncolor = a_color;\nreturn pos;\n}\nvoid main() { gl_Position = vert(); }", + "frag": "\nprecision highp float;\nvec4 CCSampleWithAlphaSeparated(sampler2D tex, vec2 uv) {\n#if CC_USE_EMBEDDED_ALPHA\nreturn vec4(texture(tex, uv).rgb, texture(tex, uv + vec2(0.0, 0.5)).r);\n#else\nreturn texture(tex, uv);\n#endif\n}\n#if USE_ALPHA_TEST\nlayout(set = 1, binding = 0) uniform ALPHA_TEST_DATA {\nfloat alphaThreshold;\n};\n#endif\nvoid ALPHA_TEST (in vec4 color) {\n#if USE_ALPHA_TEST\nif (color.a < alphaThreshold) discard;\n#endif\n}\nvoid ALPHA_TEST (in float alpha) {\n#if USE_ALPHA_TEST\nif (alpha < alphaThreshold) discard;\n#endif\n}\nlayout(location = 0) in vec4 color;\n#if USE_TEXTURE\nlayout(location = 1) in vec2 uv0;\nlayout(set = 2, binding = 11) uniform sampler2D cc_spriteTexture;\n#endif\nvec4 frag () {\nvec4 o = vec4(1, 1, 1, 1);\n#if USE_TEXTURE\no *= CCSampleWithAlphaSeparated(cc_spriteTexture, uv0);\n#if IS_GRAY\nfloat gray = 0.2126 * o.r + 0.7152 * o.g + 0.0722 * o.b;\no.r = o.g = o.b = gray;\n#endif\n#endif\no *= color;\nALPHA_TEST(o);\nreturn o;\n}\nlayout(location = 0) out vec4 cc_FragColor;\nvoid main() { cc_FragColor = frag(); }", + } + ], + [ + { + "vert": "#extension GL_EXT_shader_explicit_arithmetic_types_int32: require\nprecision highp float;\nhighp float decode32 (highp vec4 rgba) {\nrgba = rgba * 255.0;\nhighp float Sign = 1.0 - (step(128.0, (rgba[3]) + 0.5)) * 2.0;\nhighp float Exponent = 2.0 * (mod(float(int((rgba[3]) + 0.5)), 128.0)) + (step(128.0, (rgba[2]) + 0.5)) - 127.0;\nhighp float Mantissa = (mod(float(int((rgba[2]) + 0.5)), 128.0)) * 65536.0 + rgba[1] * 256.0 + rgba[0] + 8388608.0;\nreturn Sign * exp2(Exponent - 23.0) * Mantissa;\n}\nstruct StandardVertInput {\nhighp vec4 position;\nvec3 normal;\nvec4 tangent;\n};\nlayout(location = 0) in vec3 a_position;\nlayout(location = 1) in vec3 a_normal;\nlayout(location = 2) in vec2 a_texCoord;\nlayout(location = 3) in vec4 a_tangent;\n#if CC_USE_MORPH\nint getVertexId() {\nreturn gl_VertexIndex;\n}\nlayout(set = 2, binding = 4) uniform CCMorph {\nvec4 cc_displacementWeights[15];\nvec4 cc_displacementTextureInfo;\n};\nvec2 getPixelLocation(vec2 textureResolution, int pixelIndex) {\nfloat pixelIndexF = float(pixelIndex);\nfloat x = mod(pixelIndexF, textureResolution.x);\nfloat y = floor(pixelIndexF / textureResolution.x);\nreturn vec2(x, y);\n}\nvec2 getPixelCoordFromLocation(vec2 location, vec2 textureResolution) {\nreturn (vec2(location.x, location.y) + .5) / textureResolution;\n}\n#if CC_DEVICE_SUPPORT_FLOAT_TEXTURE\nvec4 fetchVec3ArrayFromTexture(sampler2D tex, int pixelIndex) {\nivec2 texSize = textureSize(tex, 0);\nreturn texelFetch(tex, ivec2(pixelIndex % texSize.x, pixelIndex / texSize.x), 0);\n}\n#else\nvec4 fetchVec3ArrayFromTexture(sampler2D tex, int elementIndex) {\nint pixelIndex = elementIndex * 4;\nvec2 location = getPixelLocation(cc_displacementTextureInfo.xy, pixelIndex);\nvec2 x = getPixelCoordFromLocation(location + vec2(0.0, 0.0), cc_displacementTextureInfo.xy);\nvec2 y = getPixelCoordFromLocation(location + vec2(1.0, 0.0), cc_displacementTextureInfo.xy);\nvec2 z = getPixelCoordFromLocation(location + vec2(2.0, 0.0), cc_displacementTextureInfo.xy);\nreturn vec4(\ndecode32(texture(tex, x)),\ndecode32(texture(tex, y)),\ndecode32(texture(tex, z)),\n1.0\n);\n}\n#endif\nfloat getDisplacementWeight(int index) {\nint quot = index / 4;\nint remainder = index - quot * 4;\nif (remainder == 0) {\nreturn cc_displacementWeights[quot].x;\n} else if (remainder == 1) {\nreturn cc_displacementWeights[quot].y;\n} else if (remainder == 2) {\nreturn cc_displacementWeights[quot].z;\n} else {\nreturn cc_displacementWeights[quot].w;\n}\n}\nvec3 getVec3DisplacementFromTexture(sampler2D tex, int vertexIndex) {\n#if CC_MORPH_PRECOMPUTED\nreturn fetchVec3ArrayFromTexture(tex, vertexIndex).rgb;\n#else\nvec3 result = vec3(0, 0, 0);\nint nVertices = int(cc_displacementTextureInfo.z);\nfor (int iTarget = 0; iTarget < CC_MORPH_TARGET_COUNT; ++iTarget) {\nresult += (fetchVec3ArrayFromTexture(tex, nVertices * iTarget + vertexIndex).rgb * getDisplacementWeight(iTarget));\n}\nreturn result;\n#endif\n}\n#if CC_MORPH_TARGET_HAS_POSITION\nlayout(set = 2, binding = 7) uniform sampler2D cc_PositionDisplacements;\nvec3 getPositionDisplacement(int vertexId) {\nreturn getVec3DisplacementFromTexture(cc_PositionDisplacements, vertexId);\n}\n#endif\n#if CC_MORPH_TARGET_HAS_NORMAL\nlayout(set = 2, binding = 8) uniform sampler2D cc_NormalDisplacements;\nvec3 getNormalDisplacement(int vertexId) {\nreturn getVec3DisplacementFromTexture(cc_NormalDisplacements, vertexId);\n}\n#endif\n#if CC_MORPH_TARGET_HAS_TANGENT\nlayout(set = 2, binding = 9) uniform sampler2D cc_TangentDisplacements;\nvec3 getTangentDisplacement(int vertexId) {\nreturn getVec3DisplacementFromTexture(cc_TangentDisplacements, vertexId);\n}\n#endif\nvoid applyMorph (inout StandardVertInput attr) {\nint vertexId = getVertexId();\n#if CC_MORPH_TARGET_HAS_POSITION\nattr.position.xyz = attr.position.xyz + getPositionDisplacement(vertexId);\n#endif\n#if CC_MORPH_TARGET_HAS_NORMAL\nattr.normal.xyz = attr.normal.xyz + getNormalDisplacement(vertexId);\n#endif\n#if CC_MORPH_TARGET_HAS_TANGENT\nattr.tangent.xyz = attr.tangent.xyz + getTangentDisplacement(vertexId);\n#endif\n}\nvoid applyMorph (inout vec4 position) {\n#if CC_MORPH_TARGET_HAS_POSITION\nposition.xyz = position.xyz + getPositionDisplacement(getVertexId());\n#endif\n}\n#endif\n#if CC_USE_SKINNING\nlayout(location = 4) in u32vec4 a_joints;\nlayout(location = 5) in vec4 a_weights;\n#if CC_USE_BAKED_ANIMATION\n#if USE_INSTANCING\nlayout(location = 7) in highp vec4 a_jointAnimInfo;\n#endif\nlayout(set = 2, binding = 3) uniform CCSkinningTexture {\nhighp vec4 cc_jointTextureInfo;\n};\nlayout(set = 2, binding = 2) uniform CCSkinningAnimation {\nhighp vec4 cc_jointAnimInfo;\n};\nlayout(set = 2, binding = 6) uniform highp sampler2D cc_jointTexture;\n#else\nlayout(set = 2, binding = 3) uniform CCSkinning {\nhighp vec4 cc_joints[30 * 3];\n};\n#endif\n#if CC_USE_BAKED_ANIMATION\n#if CC_DEVICE_SUPPORT_FLOAT_TEXTURE\nmat4 getJointMatrix (float i) {\n#if USE_INSTANCING\nhighp float j = 3.0 * (a_jointAnimInfo.x * a_jointAnimInfo.y + i) + a_jointAnimInfo.z;\n#else\nhighp float j = 3.0 * (cc_jointAnimInfo.x * cc_jointTextureInfo.y + i) + cc_jointTextureInfo.z;\n#endif\nhighp float invSize = cc_jointTextureInfo.w;\nhighp float y = floor(j * invSize);\nhighp float x = floor(j - y * cc_jointTextureInfo.x);\ny = (y + 0.5) * invSize;\nvec4 v1 = texture(cc_jointTexture, vec2((x + 0.5) * invSize, y));\nvec4 v2 = texture(cc_jointTexture, vec2((x + 1.5) * invSize, y));\nvec4 v3 = texture(cc_jointTexture, vec2((x + 2.5) * invSize, y));\nreturn mat4(vec4(v1.xyz, 0.0), vec4(v2.xyz, 0.0), vec4(v3.xyz, 0.0), vec4(v1.w, v2.w, v3.w, 1.0));\n}\n#else\nmat4 getJointMatrix (float i) {\n#if USE_INSTANCING\nhighp float j = 12.0 * (a_jointAnimInfo.x * a_jointAnimInfo.y + i) + a_jointAnimInfo.z;\n#else\nhighp float j = 12.0 * (cc_jointAnimInfo.x * cc_jointTextureInfo.y + i) + cc_jointTextureInfo.z;\n#endif\nhighp float invSize = cc_jointTextureInfo.w;\nhighp float y = floor(j * invSize);\nhighp float x = floor(j - y * cc_jointTextureInfo.x);\ny = (y + 0.5) * invSize;\nvec4 v1 = vec4(\ndecode32(texture(cc_jointTexture, vec2((x + 0.5) * invSize, y))),\ndecode32(texture(cc_jointTexture, vec2((x + 1.5) * invSize, y))),\ndecode32(texture(cc_jointTexture, vec2((x + 2.5) * invSize, y))),\ndecode32(texture(cc_jointTexture, vec2((x + 3.5) * invSize, y)))\n);\nvec4 v2 = vec4(\ndecode32(texture(cc_jointTexture, vec2((x + 4.5) * invSize, y))),\ndecode32(texture(cc_jointTexture, vec2((x + 5.5) * invSize, y))),\ndecode32(texture(cc_jointTexture, vec2((x + 6.5) * invSize, y))),\ndecode32(texture(cc_jointTexture, vec2((x + 7.5) * invSize, y)))\n);\nvec4 v3 = vec4(\ndecode32(texture(cc_jointTexture, vec2((x + 8.5) * invSize, y))),\ndecode32(texture(cc_jointTexture, vec2((x + 9.5) * invSize, y))),\ndecode32(texture(cc_jointTexture, vec2((x + 10.5) * invSize, y))),\ndecode32(texture(cc_jointTexture, vec2((x + 11.5) * invSize, y)))\n);\nreturn mat4(vec4(v1.xyz, 0.0), vec4(v2.xyz, 0.0), vec4(v3.xyz, 0.0), vec4(v1.w, v2.w, v3.w, 1.0));\n}\n#endif\n#else\nmat4 getJointMatrix (float i) {\nint idx = int(i);\nvec4 v1 = cc_joints[idx * 3];\nvec4 v2 = cc_joints[idx * 3 + 1];\nvec4 v3 = cc_joints[idx * 3 + 2];\nreturn mat4(vec4(v1.xyz, 0.0), vec4(v2.xyz, 0.0), vec4(v3.xyz, 0.0), vec4(v1.w, v2.w, v3.w, 1.0));\n}\n#endif\nmat4 skinMatrix () {\nvec4 joints = vec4(a_joints);\nreturn getJointMatrix(joints.x) * a_weights.x\n+ getJointMatrix(joints.y) * a_weights.y\n+ getJointMatrix(joints.z) * a_weights.z\n+ getJointMatrix(joints.w) * a_weights.w;\n}\nvoid CCSkin (inout vec4 position) {\nmat4 m = skinMatrix();\nposition = m * position;\n}\nvoid CCSkin (inout StandardVertInput attr) {\nmat4 m = skinMatrix();\nattr.position = m * attr.position;\nattr.normal = (m * vec4(attr.normal, 0.0)).xyz;\nattr.tangent.xyz = (m * vec4(attr.tangent.xyz, 0.0)).xyz;\n}\n#endif\nlayout(set = 0, binding = 0) uniform CCGlobal {\nhighp vec4 cc_time;\nmediump vec4 cc_screenSize;\nmediump vec4 cc_nativeSize;\n};\nlayout(set = 0, binding = 1) uniform CCCamera {\nhighp mat4 cc_matView;\nhighp mat4 cc_matViewInv;\nhighp mat4 cc_matProj;\nhighp mat4 cc_matProjInv;\nhighp mat4 cc_matViewProj;\nhighp mat4 cc_matViewProjInv;\nhighp vec4 cc_cameraPos;\nmediump vec4 cc_screenScale;\nmediump vec4 cc_exposure;\nmediump vec4 cc_mainLitDir;\nmediump vec4 cc_mainLitColor;\nmediump vec4 cc_ambientSky;\nmediump vec4 cc_ambientGround;\nmediump vec4 cc_fogColor;\nmediump vec4 cc_fogBase;\nmediump vec4 cc_fogAdd;\nmediump vec4 cc_nearFar;\nmediump vec4 cc_viewPort;\n};\n#if USE_INSTANCING\nlayout(location = 8) in vec4 a_matWorld0;\nlayout(location = 9) in vec4 a_matWorld1;\nlayout(location = 10) in vec4 a_matWorld2;\n#if USE_LIGHTMAP\nlayout(location = 11) in vec4 a_lightingMapUVParam;\n#endif\n#elif USE_BATCHING\nlayout(location = 12) in float a_dyn_batch_id;\nlayout(set = 2, binding = 0) uniform CCLocalBatched {\nhighp mat4 cc_matWorlds[10];\n};\n#else\nlayout(set = 2, binding = 0) uniform CCLocal {\nhighp mat4 cc_matWorld;\nhighp mat4 cc_matWorldIT;\nhighp vec4 cc_lightingMapUVParam;\n};\n#endif\nlayout(set = 1, binding = 0) uniform Constants {\nvec4 tilingOffset;\nvec4 albedo;\nvec4 albedoScaleAndCutoff;\nvec4 pbrParams;\nvec4 emissive;\nvec4 emissiveScaleParam;\n};\nfloat LinearFog(vec4 pos) {\nvec4 wPos = pos;\nfloat cam_dis = distance(cc_cameraPos, wPos);\nfloat fogStart = cc_fogBase.x;\nfloat fogEnd = cc_fogBase.y;\nreturn clamp((fogEnd - cam_dis) / (fogEnd - fogStart), 0., 1.);\n}\nfloat ExpFog(vec4 pos) {\nvec4 wPos = pos;\nfloat fogAtten = cc_fogAdd.z;\nfloat fogStart = cc_fogBase.x;\nfloat fogDensity = cc_fogBase.z;\nfloat cam_dis = max(distance(cc_cameraPos, wPos) - fogStart, 0.0) / fogAtten * 4.;\nfloat f = exp(-cam_dis * fogDensity);\nreturn f;\n}\nfloat ExpSquaredFog(vec4 pos) {\nvec4 wPos = pos;\nfloat fogAtten = cc_fogAdd.z;\nfloat fogStart = cc_fogBase.x;\nfloat fogDensity = cc_fogBase.z;\nfloat cam_dis = max(distance(cc_cameraPos, wPos) - fogStart, 0.0) / fogAtten * 4.;\nfloat f = exp(-cam_dis * cam_dis * fogDensity * fogDensity);\nreturn f;\n}\nfloat LayeredFog(vec4 pos) {\nvec4 wPos = pos;\nfloat fogAtten = cc_fogAdd.z;\nfloat _FogTop = cc_fogAdd.x;\nfloat _FogRange = cc_fogAdd.y;\nvec3 camWorldProj = cc_cameraPos.xyz;\ncamWorldProj.y = 0.;\nvec3 worldPosProj = wPos.xyz;\nworldPosProj.y = 0.;\nfloat fDeltaD = distance(worldPosProj, camWorldProj) / fogAtten * 2.0;\nfloat fDeltaY, fDensityIntegral;\nif (cc_cameraPos.y > _FogTop) {\nif (wPos.y < _FogTop) {\nfDeltaY = (_FogTop - wPos.y) / _FogRange * 2.0;\nfDensityIntegral = fDeltaY * fDeltaY * 0.5;\n} else {\nfDeltaY = 0.;\nfDensityIntegral = 0.;\n}\n} else {\nif (wPos.y < _FogTop) {\nfloat fDeltaA = (_FogTop - cc_cameraPos.y) / _FogRange * 2.;\nfloat fDeltaB = (_FogTop - wPos.y) / _FogRange * 2.;\nfDeltaY = abs(fDeltaA - fDeltaB);\nfDensityIntegral = abs((fDeltaA * fDeltaA * 0.5) - (fDeltaB * fDeltaB * 0.5));\n} else {\nfDeltaY = abs(_FogTop - cc_cameraPos.y) / _FogRange * 2.;\nfDensityIntegral = abs(fDeltaY * fDeltaY * 0.5);\n}\n}\nfloat fDensity;\nif (fDeltaY != 0.) {\nfDensity = (sqrt(1.0 + ((fDeltaD / fDeltaY) * (fDeltaD / fDeltaY)))) * fDensityIntegral;\n} else {\nfDensity = 0.;\n}\nfloat f = exp(-fDensity);\nreturn f;\n}\nvoid CC_TRANSFER_FOG_BASE(vec4 pos, out float factor)\n{\n#if CC_USE_FOG == 0\nfactor = LinearFog(pos);\n#elif CC_USE_FOG == 1\nfactor = ExpFog(pos);\n#elif CC_USE_FOG == 2\nfactor = ExpSquaredFog(pos);\n#elif CC_USE_FOG == 3\nfactor = LayeredFog(pos);\n#else\nfactor = 1.0;\n#endif\n}\n#if !CC_USE_ACCURATE_FOG\nlayout(location = 0) out float v_fog_factor;\n#endif\nvoid CC_TRANSFER_FOG(vec4 pos) {\n#if !CC_USE_ACCURATE_FOG\nCC_TRANSFER_FOG_BASE(pos, v_fog_factor);\n#endif\n}\nlayout(location = 1) out highp vec4 v_shadowPos;\nlayout(set = 0, binding = 2) uniform CCShadow {\nhighp mat4 cc_matLightPlaneProj;\nhighp mat4 cc_matLightView;\nhighp mat4 cc_matLightViewProj;\nhighp vec4 cc_shadowInvProjDepthInfo;\nhighp vec4 cc_shadowProjDepthInfo;\nhighp vec4 cc_shadowProjInfo;\nlowp vec4 cc_shadowNFLSInfo;\nlowp vec4 cc_shadowWHPBInfo;\nlowp vec4 cc_shadowLPNNInfo;\nlowp vec4 cc_shadowColor;\n};\n#if CC_RECEIVE_SHADOW\nlayout(set = 0, binding = 3) uniform highp sampler2D cc_shadowMap;\nlayout(set = 0, binding = 5) uniform highp sampler2D cc_spotLightingMap;\n#endif\n#if USE_VERTEX_COLOR\nlayout(location = 13) in vec4 a_color;\nlayout(location = 2) out vec4 v_color;\n#endif\nlayout(location = 3) out vec3 v_position;\nlayout(location = 4) out vec3 v_normal;\nlayout(location = 5) out vec2 v_uv;\nlayout(location = 6) out vec2 v_uv1;\n#if USE_NORMAL_MAP\nlayout(location = 7) out vec3 v_tangent;\nlayout(location = 8) out vec3 v_bitangent;\n#endif\n#if HAS_SECOND_UV || USE_LIGHTMAP\nlayout(location = 14) in vec2 a_texCoord1;\n#endif\n#if USE_LIGHTMAP && !USE_BATCHING && !CC_FORWARD_ADD\nlayout(location = 9) out vec3 v_luv;\nvoid CCLightingMapCaclUV()\n{\n#if !USE_INSTANCING\nv_luv.xy = cc_lightingMapUVParam.xy + a_texCoord1 * cc_lightingMapUVParam.zw;\nv_luv.z = cc_lightingMapUVParam.z;\n#else\nv_luv.xy = a_lightingMapUVParam.xy + a_texCoord1 * a_lightingMapUVParam.zw;\nv_luv.z = a_lightingMapUVParam.z;\n#endif\n}\n#endif\nvoid main () {\nStandardVertInput In;\nIn.position = vec4(a_position, 1.0);\nIn.normal = a_normal;\nIn.tangent = a_tangent;\n#if CC_USE_MORPH\napplyMorph(In);\n#endif\n#if CC_USE_SKINNING\nCCSkin(In);\n#endif\nmat4 matWorld, matWorldIT;\n#if USE_INSTANCING\nmatWorld = mat4(\nvec4(a_matWorld0.xyz, 0.0),\nvec4(a_matWorld1.xyz, 0.0),\nvec4(a_matWorld2.xyz, 0.0),\nvec4(a_matWorld0.w, a_matWorld1.w, a_matWorld2.w, 1.0)\n);\nmatWorldIT = matWorld;\n#elif USE_BATCHING\nmatWorld = cc_matWorlds[int(a_dyn_batch_id)];\nmatWorldIT = matWorld;\n#else\nmatWorld = cc_matWorld;\nmatWorldIT = cc_matWorldIT;\n#endif\nvec4 pos = matWorld * In.position;\nv_position = pos.xyz;\nv_normal = normalize((matWorldIT * vec4(In.normal, 0.0)).xyz);\n#if USE_TWOSIDE\nvec3 viewDirect = normalize(cc_cameraPos.xyz - v_position);\nv_normal *= dot(v_normal, viewDirect) < 0.0 ? -1.0 : 1.0;\n#endif\n#if USE_NORMAL_MAP\nv_tangent = normalize((matWorld * vec4(In.tangent.xyz, 0.0)).xyz);\nv_bitangent = cross(v_normal, v_tangent) * In.tangent.w;\n#endif\nv_uv = a_texCoord * tilingOffset.xy + tilingOffset.zw;\n#if SAMPLE_FROM_RT\nv_uv = cc_cameraPos.w > 1.0 ? vec2(v_uv.x, 1.0 - v_uv.y) : v_uv;\n#endif\n#if HAS_SECOND_UV\nv_uv1 = a_texCoord1 * tilingOffset.xy + tilingOffset.zw;\n#if SAMPLE_FROM_RT\nv_uv1 = cc_cameraPos.w > 1.0 ? vec2(v_uv1.x, 1.0 - v_uv1.y) : v_uv1;\n#endif\n#endif\n#if USE_VERTEX_COLOR\nv_color = a_color;\n#endif\nCC_TRANSFER_FOG(pos);\nv_shadowPos = cc_matLightViewProj * pos;\n#if USE_LIGHTMAP && !USE_BATCHING && !CC_FORWARD_ADD\nCCLightingMapCaclUV();\n#endif\ngl_Position = cc_matProj * (cc_matView * matWorld) * In.position;\n}", + "frag": "\nprecision highp float;\nlayout(set = 0, binding = 0) uniform CCGlobal {\nhighp vec4 cc_time;\nmediump vec4 cc_screenSize;\nmediump vec4 cc_nativeSize;\n};\nlayout(set = 0, binding = 1) uniform CCCamera {\nhighp mat4 cc_matView;\nhighp mat4 cc_matViewInv;\nhighp mat4 cc_matProj;\nhighp mat4 cc_matProjInv;\nhighp mat4 cc_matViewProj;\nhighp mat4 cc_matViewProjInv;\nhighp vec4 cc_cameraPos;\nmediump vec4 cc_screenScale;\nmediump vec4 cc_exposure;\nmediump vec4 cc_mainLitDir;\nmediump vec4 cc_mainLitColor;\nmediump vec4 cc_ambientSky;\nmediump vec4 cc_ambientGround;\nmediump vec4 cc_fogColor;\nmediump vec4 cc_fogBase;\nmediump vec4 cc_fogAdd;\nmediump vec4 cc_nearFar;\nmediump vec4 cc_viewPort;\n};\nlayout(set = 1, binding = 0) uniform Constants {\nvec4 tilingOffset;\nvec4 albedo;\nvec4 albedoScaleAndCutoff;\nvec4 pbrParams;\nvec4 emissive;\nvec4 emissiveScaleParam;\n};\nfloat LinearFog(vec4 pos) {\nvec4 wPos = pos;\nfloat cam_dis = distance(cc_cameraPos, wPos);\nfloat fogStart = cc_fogBase.x;\nfloat fogEnd = cc_fogBase.y;\nreturn clamp((fogEnd - cam_dis) / (fogEnd - fogStart), 0., 1.);\n}\nfloat ExpFog(vec4 pos) {\nvec4 wPos = pos;\nfloat fogAtten = cc_fogAdd.z;\nfloat fogStart = cc_fogBase.x;\nfloat fogDensity = cc_fogBase.z;\nfloat cam_dis = max(distance(cc_cameraPos, wPos) - fogStart, 0.0) / fogAtten * 4.;\nfloat f = exp(-cam_dis * fogDensity);\nreturn f;\n}\nfloat ExpSquaredFog(vec4 pos) {\nvec4 wPos = pos;\nfloat fogAtten = cc_fogAdd.z;\nfloat fogStart = cc_fogBase.x;\nfloat fogDensity = cc_fogBase.z;\nfloat cam_dis = max(distance(cc_cameraPos, wPos) - fogStart, 0.0) / fogAtten * 4.;\nfloat f = exp(-cam_dis * cam_dis * fogDensity * fogDensity);\nreturn f;\n}\nfloat LayeredFog(vec4 pos) {\nvec4 wPos = pos;\nfloat fogAtten = cc_fogAdd.z;\nfloat _FogTop = cc_fogAdd.x;\nfloat _FogRange = cc_fogAdd.y;\nvec3 camWorldProj = cc_cameraPos.xyz;\ncamWorldProj.y = 0.;\nvec3 worldPosProj = wPos.xyz;\nworldPosProj.y = 0.;\nfloat fDeltaD = distance(worldPosProj, camWorldProj) / fogAtten * 2.0;\nfloat fDeltaY, fDensityIntegral;\nif (cc_cameraPos.y > _FogTop) {\nif (wPos.y < _FogTop) {\nfDeltaY = (_FogTop - wPos.y) / _FogRange * 2.0;\nfDensityIntegral = fDeltaY * fDeltaY * 0.5;\n} else {\nfDeltaY = 0.;\nfDensityIntegral = 0.;\n}\n} else {\nif (wPos.y < _FogTop) {\nfloat fDeltaA = (_FogTop - cc_cameraPos.y) / _FogRange * 2.;\nfloat fDeltaB = (_FogTop - wPos.y) / _FogRange * 2.;\nfDeltaY = abs(fDeltaA - fDeltaB);\nfDensityIntegral = abs((fDeltaA * fDeltaA * 0.5) - (fDeltaB * fDeltaB * 0.5));\n} else {\nfDeltaY = abs(_FogTop - cc_cameraPos.y) / _FogRange * 2.;\nfDensityIntegral = abs(fDeltaY * fDeltaY * 0.5);\n}\n}\nfloat fDensity;\nif (fDeltaY != 0.) {\nfDensity = (sqrt(1.0 + ((fDeltaD / fDeltaY) * (fDeltaD / fDeltaY)))) * fDensityIntegral;\n} else {\nfDensity = 0.;\n}\nfloat f = exp(-fDensity);\nreturn f;\n}\nvoid CC_TRANSFER_FOG_BASE(vec4 pos, out float factor)\n{\n#if CC_USE_FOG == 0\nfactor = LinearFog(pos);\n#elif CC_USE_FOG == 1\nfactor = ExpFog(pos);\n#elif CC_USE_FOG == 2\nfactor = ExpSquaredFog(pos);\n#elif CC_USE_FOG == 3\nfactor = LayeredFog(pos);\n#else\nfactor = 1.0;\n#endif\n}\nvoid CC_APPLY_FOG_BASE(inout vec4 color, float factor) {\ncolor = vec4(mix(cc_fogColor.rgb, color.rgb, factor), color.a);\n}\n#if !CC_USE_ACCURATE_FOG\nlayout(location = 0) in float v_fog_factor;\n#endif\nvoid CC_APPLY_FOG(inout vec4 color) {\n#if !CC_USE_ACCURATE_FOG\nCC_APPLY_FOG_BASE(color, v_fog_factor);\n#endif\n}\nvoid CC_APPLY_FOG(inout vec4 color, vec3 worldPos) {\n#if CC_USE_ACCURATE_FOG\nfloat factor;\nCC_TRANSFER_FOG_BASE(vec4(worldPos, 1.0), factor);\n#else\nfloat factor = v_fog_factor;\n#endif\nCC_APPLY_FOG_BASE(color, factor);\n}\nvec3 SRGBToLinear (vec3 gamma) {\nreturn gamma * gamma;\n}\nlayout(set = 0, binding = 2) uniform CCShadow {\nhighp mat4 cc_matLightPlaneProj;\nhighp mat4 cc_matLightView;\nhighp mat4 cc_matLightViewProj;\nhighp vec4 cc_shadowInvProjDepthInfo;\nhighp vec4 cc_shadowProjDepthInfo;\nhighp vec4 cc_shadowProjInfo;\nlowp vec4 cc_shadowNFLSInfo;\nlowp vec4 cc_shadowWHPBInfo;\nlowp vec4 cc_shadowLPNNInfo;\nlowp vec4 cc_shadowColor;\n};\nfloat CCGetLinearDepthFromViewSpace(vec3 viewPos) {\nfloat dist = length(viewPos);\nreturn (dist - cc_shadowNFLSInfo.x) / (cc_shadowNFLSInfo.y - cc_shadowNFLSInfo.x);\n}\nfloat CCGetLinearDepth(vec3 worldPos) {\nvec4 viewStartPos = cc_matLightView * vec4(worldPos.xyz, 1.0);\nreturn CCGetLinearDepthFromViewSpace(viewStartPos.xyz);\n}\n#if CC_RECEIVE_SHADOW\nlayout(set = 0, binding = 3) uniform highp sampler2D cc_shadowMap;\nlayout(set = 0, binding = 5) uniform highp sampler2D cc_spotLightingMap;\nvec4 ApplyShadowDepthBias_FaceNormal(vec4 shadowPos, vec3 worldNormal)\n{\nvec4 newShadowPos = shadowPos;\nif(cc_shadowLPNNInfo.z > 0.0001)\n{\nvec4 viewNormal = cc_matLightView * vec4(worldNormal, 0.0);\nif(viewNormal.z < 0.1)\nnewShadowPos.xy += viewNormal.xy * cc_shadowProjInfo.xy * cc_shadowLPNNInfo.z * clamp(viewNormal.z, 0.001, 0.1);\n}\nreturn newShadowPos;\n}\nvec4 ApplyShadowDepthBias_Perspective(vec4 shadowPos, float viewspaceDepthBias)\n{\nvec3 viewSpacePos;\nviewSpacePos.xy = shadowPos.xy * cc_shadowProjInfo.zw;\nviewSpacePos.z = shadowPos.z * cc_shadowInvProjDepthInfo.x + shadowPos.w * cc_shadowInvProjDepthInfo.y;\nviewSpacePos.xyz += cc_shadowProjDepthInfo.z * normalize(viewSpacePos.xyz) * viewspaceDepthBias;\nvec4 clipSpacePos;\nclipSpacePos.xy = viewSpacePos.xy * cc_shadowProjInfo.xy;\nclipSpacePos.zw = viewSpacePos.z * cc_shadowProjDepthInfo.xz + vec2(cc_shadowProjDepthInfo.y, 0.0);\nif (cc_shadowNFLSInfo.z > 0.000001) {\nclipSpacePos.z = CCGetLinearDepthFromViewSpace(viewSpacePos.xyz);\nclipSpacePos.z = (clipSpacePos.z * 2.0 - 1.0) * clipSpacePos.w;\n}\nreturn clipSpacePos;\n}\nvec4 ApplyShadowDepthBias_Orthographic(vec4 shadowPos, float viewspaceDepthBias)\n{\nfloat coeffA = cc_shadowProjDepthInfo.x;\nfloat coeffB = cc_shadowProjDepthInfo.y;\nfloat viewSpacePos_z = (shadowPos.z - coeffB) / coeffA;\nviewSpacePos_z += viewspaceDepthBias;\nvec4 result = shadowPos;\nresult.z = viewSpacePos_z * coeffA + coeffB;\nreturn result;\n}\nfloat CCGetShadowFactorHard (vec4 shadowPos) {\nvec4 clipPosNew = ApplyShadowDepthBias_Orthographic(shadowPos, cc_shadowWHPBInfo.w);\nvec3 clipPos = clipPosNew.xyz / clipPosNew.w * 0.5 + 0.5;\nif (clipPos.x < 0.0 || clipPos.x > 1.0 ||\nclipPos.y < 0.0 || clipPos.y > 1.0 ||\nclipPos.z < 0.0 || clipPos.z > 1.0) { return 1.0; }\nclipPos.xy = cc_cameraPos.w == 1.0 ? vec2(clipPos.xy.x, 1.0 - clipPos.xy.y) : clipPos.xy;\nfloat shadow = 0.0;\nfloat closestDepth = 0.0;\nif (cc_shadowLPNNInfo.y > 0.000001) {\nclosestDepth = dot(texture(cc_shadowMap, clipPos.xy), vec4(1.0, 1.0 / 255.0, 1.0 / 65025.0, 1.0 / 16581375.0));\n} else {\nclosestDepth = texture(cc_shadowMap, clipPos.xy).x;\n}\nshadow = step(clipPos.z, closestDepth);\nreturn shadow;\n}\nfloat CCGetShadowFactorSoft (vec4 shadowPos) {\nvec4 clipPosNew = ApplyShadowDepthBias_Orthographic(shadowPos, cc_shadowWHPBInfo.w);\nvec3 clipPos = clipPosNew.xyz / clipPosNew.w * 0.5 + 0.5;\nif (clipPos.x < 0.0 || clipPos.x > 1.0 ||\nclipPos.y < 0.0 || clipPos.y > 1.0 ||\nclipPos.z < 0.0 || clipPos.z > 1.0) { return 1.0; }\nclipPos.xy = cc_cameraPos.w == 1.0 ? vec2(clipPos.xy.x, 1.0 - clipPos.xy.y) : clipPos.xy;\nfloat offsetDepth = clipPos.z;\nvec2 mapSize = cc_shadowWHPBInfo.xy;\nvec2 oneTap = 1.0 / mapSize;\nvec2 clipPos_offset = clipPos.xy + oneTap;\nfloat block0, block1, block2, block3;\nif (cc_shadowLPNNInfo.y > 0.000001) {\nblock0 = step(offsetDepth, dot(texture(cc_shadowMap, vec2(clipPos.x, clipPos.y)), vec4(1.0, 1.0 / 255.0, 1.0 / 65025.0, 1.0 / 16581375.0)));\nblock1 = step(offsetDepth, dot(texture(cc_shadowMap, vec2(clipPos_offset.x, clipPos.y)), vec4(1.0, 1.0 / 255.0, 1.0 / 65025.0, 1.0 / 16581375.0)));\nblock2 = step(offsetDepth, dot(texture(cc_shadowMap, vec2(clipPos.x, clipPos_offset.y)), vec4(1.0, 1.0 / 255.0, 1.0 / 65025.0, 1.0 / 16581375.0)));\nblock3 = step(offsetDepth, dot(texture(cc_shadowMap, vec2(clipPos_offset.x, clipPos_offset.y)), vec4(1.0, 1.0 / 255.0, 1.0 / 65025.0, 1.0 / 16581375.0)));\n} else {\nblock0 = step(offsetDepth, texture(cc_shadowMap, vec2(clipPos.x, clipPos.y)).x);\nblock1 = step(offsetDepth, texture(cc_shadowMap, vec2(clipPos_offset.x, clipPos.y)).x);\nblock2 = step(offsetDepth, texture(cc_shadowMap, vec2(clipPos.x, clipPos_offset.y)).x);\nblock3 = step(offsetDepth, texture(cc_shadowMap, vec2(clipPos_offset.x, clipPos_offset.y)).x);\n}\nfloat coefX = mod(clipPos.x, oneTap.x) * mapSize.x;\nfloat resultX = mix(block0, block1, coefX);\nfloat resultY = mix(block2, block3, coefX);\nfloat coefY = mod(clipPos.y, oneTap.y) * mapSize.y;\nreturn mix(resultX, resultY, coefY);\n}\nfloat CCGetShadowFactorSoft2X (vec4 shadowPos) {\nvec4 clipPosNew = ApplyShadowDepthBias_Orthographic(shadowPos, cc_shadowWHPBInfo.w);\nvec3 clipPos = clipPosNew.xyz / clipPosNew.w * 0.5 + 0.5;\nif (clipPos.x < 0.0 || clipPos.x > 1.0 ||\nclipPos.y < 0.0 || clipPos.y > 1.0 ||\nclipPos.z < 0.0 || clipPos.z > 1.0) { return 1.0; }\nclipPos.xy = cc_cameraPos.w == 1.0 ? vec2(clipPos.xy.x, 1.0 - clipPos.xy.y) : clipPos.xy;\nfloat offsetDepth = clipPos.z;\nvec2 mapSize = cc_shadowWHPBInfo.xy;\nvec2 oneTap = 1.0 / mapSize;\nfloat clipPos_offset_L = clipPos.x - oneTap.x;\nfloat clipPos_offset_R = clipPos.x + oneTap.x;\nfloat clipPos_offset_U = clipPos.y - oneTap.y;\nfloat clipPos_offset_D = clipPos.y + oneTap.y;\nfloat block0, block1, block2, block3, block4, block5, block6, block7, block8;\nif (cc_shadowLPNNInfo.y > 0.000001) {\nblock0 = step(offsetDepth, dot(texture(cc_shadowMap, vec2(clipPos_offset_L, clipPos_offset_U)), vec4(1.0, 1.0 / 255.0, 1.0 / 65025.0, 1.0 / 16581375.0)));\nblock1 = step(offsetDepth, dot(texture(cc_shadowMap, vec2(clipPos.x, clipPos_offset_U)), vec4(1.0, 1.0 / 255.0, 1.0 / 65025.0, 1.0 / 16581375.0)));\nblock2 = step(offsetDepth, dot(texture(cc_shadowMap, vec2(clipPos_offset_R, clipPos_offset_U)), vec4(1.0, 1.0 / 255.0, 1.0 / 65025.0, 1.0 / 16581375.0)));\nblock3 = step(offsetDepth, dot(texture(cc_shadowMap, vec2(clipPos_offset_L, clipPos.y)), vec4(1.0, 1.0 / 255.0, 1.0 / 65025.0, 1.0 / 16581375.0)));\nblock4 = step(offsetDepth, dot(texture(cc_shadowMap, vec2(clipPos.x, clipPos.y)), vec4(1.0, 1.0 / 255.0, 1.0 / 65025.0, 1.0 / 16581375.0)));\nblock5 = step(offsetDepth, dot(texture(cc_shadowMap, vec2(clipPos_offset_R, clipPos.y)), vec4(1.0, 1.0 / 255.0, 1.0 / 65025.0, 1.0 / 16581375.0)));\nblock6 = step(offsetDepth, dot(texture(cc_shadowMap, vec2(clipPos_offset_L, clipPos_offset_D)), vec4(1.0, 1.0 / 255.0, 1.0 / 65025.0, 1.0 / 16581375.0)));\nblock7 = step(offsetDepth, dot(texture(cc_shadowMap, vec2(clipPos.x, clipPos_offset_D)), vec4(1.0, 1.0 / 255.0, 1.0 / 65025.0, 1.0 / 16581375.0)));\nblock8 = step(offsetDepth, dot(texture(cc_shadowMap, vec2(clipPos_offset_R, clipPos_offset_D)), vec4(1.0, 1.0 / 255.0, 1.0 / 65025.0, 1.0 / 16581375.0)));\n} else {\nblock0 = step(offsetDepth, texture(cc_shadowMap, vec2(clipPos_offset_L, clipPos_offset_U)).x);\nblock1 = step(offsetDepth, texture(cc_shadowMap, vec2(clipPos.x, clipPos_offset_U)).x);\nblock2 = step(offsetDepth, texture(cc_shadowMap, vec2(clipPos_offset_R, clipPos_offset_U)).x);\nblock3 = step(offsetDepth, texture(cc_shadowMap, vec2(clipPos_offset_L, clipPos.y)).x);\nblock4 = step(offsetDepth, texture(cc_shadowMap, vec2(clipPos.x, clipPos.y)).x);\nblock5 = step(offsetDepth, texture(cc_shadowMap, vec2(clipPos_offset_R, clipPos.y)).x);\nblock6 = step(offsetDepth, texture(cc_shadowMap, vec2(clipPos_offset_L, clipPos_offset_D)).x);\nblock7 = step(offsetDepth, texture(cc_shadowMap, vec2(clipPos.x, clipPos_offset_D)).x);\nblock8 = step(offsetDepth, texture(cc_shadowMap, vec2(clipPos_offset_R, clipPos_offset_D)).x);\n}\nfloat coefX = mod(clipPos.x, oneTap.x) * mapSize.x;\nfloat coefY = mod(clipPos.y, oneTap.y) * mapSize.y;\nfloat shadow = 0.0;\nfloat resultX = mix(block0, block1, coefX);\nfloat resultY = mix(block3, block4, coefX);\nshadow += mix(resultX , resultY, coefY);\nresultX = mix(block1, block2, coefX);\nresultY = mix(block4, block5, coefX);\nshadow += mix(resultX , resultY, coefY);\nresultX = mix(block3, block4, coefX);\nresultY = mix(block6, block7, coefX);\nshadow += mix(resultX, resultY, coefY);\nresultX = mix(block4, block5, coefX);\nresultY = mix(block7, block8, coefX);\nshadow += mix(resultX, resultY, coefY);\nreturn shadow * 0.25;\n}\nfloat CCGetSpotLightShadowFactorHard (vec4 shadowPos, vec3 worldPos) {\nvec4 clipPosNew = ApplyShadowDepthBias_Perspective(shadowPos, cc_shadowWHPBInfo.w);\nvec3 clipPos = clipPosNew.xyz / clipPosNew.w * 0.5 + 0.5;\nif (clipPos.x < 0.0 || clipPos.x > 1.0 ||\nclipPos.y < 0.0 || clipPos.y > 1.0 ||\nclipPos.z < 0.0 || clipPos.z > 1.0) { return 1.0; }\nclipPos.xy = cc_cameraPos.w == 1.0 ? vec2(clipPos.xy.x, 1.0 - clipPos.xy.y) : clipPos.xy;\nfloat shadow = 0.0;\nfloat closestDepth = 0.0;\nfloat depth = clipPos.z;\nif (cc_shadowLPNNInfo.y > 0.000001) {\nclosestDepth = dot(texture(cc_spotLightingMap, clipPos.xy), vec4(1.0, 1.0 / 255.0, 1.0 / 65025.0, 1.0 / 16581375.0));\n} else {\nclosestDepth = texture(cc_spotLightingMap, clipPos.xy).x;\n}\nshadow = step(depth, closestDepth);\nreturn shadow;\n}\nfloat CCGetSpotLightShadowFactorSoft (vec4 shadowPos, vec3 worldPos) {\nvec4 clipPosNew = ApplyShadowDepthBias_Perspective(shadowPos, cc_shadowWHPBInfo.w);\nvec3 clipPos = clipPosNew.xyz / clipPosNew.w * 0.5 + 0.5;\nif (clipPos.x < 0.0 || clipPos.x > 1.0 ||\nclipPos.y < 0.0 || clipPos.y > 1.0 ||\nclipPos.z < 0.0 || clipPos.z > 1.0) { return 1.0; }\nclipPos.xy = cc_cameraPos.w == 1.0 ? vec2(clipPos.xy.x, 1.0 - clipPos.xy.y) : clipPos.xy;\nfloat depth = 0.0;\nif (cc_shadowNFLSInfo.z > 0.000001) {\ndepth = CCGetLinearDepth(worldPos);\n} else {\ndepth = clipPos.z;\n}\nfloat bias = cc_shadowWHPBInfo.w;\nvec2 oneTap = 1.0 / cc_shadowWHPBInfo.xy;\nvec2 clipPos_offset = clipPos.xy + oneTap;\nfloat block0, block1, block2, block3;\nif (cc_shadowLPNNInfo.y > 0.000001) {\nblock0 = step(depth, dot(texture(cc_spotLightingMap, vec2(clipPos.x, clipPos.y)), vec4(1.0, 1.0 / 255.0, 1.0 / 65025.0, 1.0 / 16581375.0)));\nblock1 = step(depth, dot(texture(cc_spotLightingMap, vec2(clipPos_offset.x, clipPos.y)), vec4(1.0, 1.0 / 255.0, 1.0 / 65025.0, 1.0 / 16581375.0)));\nblock2 = step(depth, dot(texture(cc_spotLightingMap, vec2(clipPos.x, clipPos_offset.y)), vec4(1.0, 1.0 / 255.0, 1.0 / 65025.0, 1.0 / 16581375.0)));\nblock3 = step(depth, dot(texture(cc_spotLightingMap, vec2(clipPos_offset.x, clipPos_offset.y)), vec4(1.0, 1.0 / 255.0, 1.0 / 65025.0, 1.0 / 16581375.0)));\n} else {\nblock0 = step(depth, texture(cc_spotLightingMap, vec2(clipPos.x, clipPos.y)).x);\nblock1 = step(depth, texture(cc_spotLightingMap, vec2(clipPos_offset.x, clipPos.y)).x);\nblock2 = step(depth, texture(cc_spotLightingMap, vec2(clipPos.x, clipPos_offset.y)).x);\nblock3 = step(depth, texture(cc_spotLightingMap, vec2(clipPos_offset.x, clipPos_offset.y)).x);\n}\nfloat coefX = mod(clipPos.x, oneTap.x) * cc_shadowWHPBInfo.x;\nfloat resultX = mix(block0, block1, coefX);\nfloat resultY = mix(block2, block3, coefX);\nfloat coefY = mod(clipPos.y, oneTap.y) * cc_shadowWHPBInfo.y;\nreturn mix(resultX, resultY, coefY);\n}\nfloat CCGetSpotLightShadowFactorSoft2X (vec4 shadowPos, vec3 worldPos) {\nvec4 clipPosNew = ApplyShadowDepthBias_Perspective(shadowPos, cc_shadowWHPBInfo.w);\nvec3 clipPos = clipPosNew.xyz / clipPosNew.w * 0.5 + 0.5;\nif (clipPos.x < 0.0 || clipPos.x > 1.0 ||\nclipPos.y < 0.0 || clipPos.y > 1.0 ||\nclipPos.z < 0.0 || clipPos.z > 1.0) { return 1.0; }\nclipPos.xy = cc_cameraPos.w == 1.0 ? vec2(clipPos.xy.x, 1.0 - clipPos.xy.y) : clipPos.xy;\nfloat depth = 0.0;\nif (cc_shadowNFLSInfo.z > 0.000001) {\ndepth = CCGetLinearDepth(worldPos);\n} else {\ndepth = clipPos.z;\n}\nfloat bias = cc_shadowWHPBInfo.w;\nvec2 mapSize = cc_shadowWHPBInfo.xy;\nvec2 oneTap = 1.0 / mapSize;\nfloat clipPos_offset_L = clipPos.x - oneTap.x;\nfloat clipPos_offset_R = clipPos.x + oneTap.x;\nfloat clipPos_offset_U = clipPos.y - oneTap.y;\nfloat clipPos_offset_D = clipPos.y + oneTap.y;\nfloat block0, block1, block2, block3, block4, block5, block6, block7, block8;\nif (cc_shadowLPNNInfo.y > 0.000001) {\nblock0 = step(depth, dot(texture(cc_spotLightingMap, vec2(clipPos_offset_L, clipPos_offset_U)), vec4(1.0, 1.0 / 255.0, 1.0 / 65025.0, 1.0 / 16581375.0)));\nblock1 = step(depth, dot(texture(cc_spotLightingMap, vec2(clipPos.x, clipPos_offset_U)), vec4(1.0, 1.0 / 255.0, 1.0 / 65025.0, 1.0 / 16581375.0)));\nblock2 = step(depth, dot(texture(cc_spotLightingMap, vec2(clipPos_offset_R, clipPos_offset_U)), vec4(1.0, 1.0 / 255.0, 1.0 / 65025.0, 1.0 / 16581375.0)));\nblock3 = step(depth, dot(texture(cc_spotLightingMap, vec2(clipPos_offset_L, clipPos.y)), vec4(1.0, 1.0 / 255.0, 1.0 / 65025.0, 1.0 / 16581375.0)));\nblock4 = step(depth, dot(texture(cc_spotLightingMap, vec2(clipPos.x, clipPos.y)), vec4(1.0, 1.0 / 255.0, 1.0 / 65025.0, 1.0 / 16581375.0)));\nblock5 = step(depth, dot(texture(cc_spotLightingMap, vec2(clipPos_offset_R, clipPos.y)), vec4(1.0, 1.0 / 255.0, 1.0 / 65025.0, 1.0 / 16581375.0)));\nblock6 = step(depth, dot(texture(cc_spotLightingMap, vec2(clipPos_offset_L, clipPos_offset_D)), vec4(1.0, 1.0 / 255.0, 1.0 / 65025.0, 1.0 / 16581375.0)));\nblock7 = step(depth, dot(texture(cc_spotLightingMap, vec2(clipPos.x, clipPos_offset_D)), vec4(1.0, 1.0 / 255.0, 1.0 / 65025.0, 1.0 / 16581375.0)));\nblock8 = step(depth, dot(texture(cc_spotLightingMap, vec2(clipPos_offset_R, clipPos_offset_D)), vec4(1.0, 1.0 / 255.0, 1.0 / 65025.0, 1.0 / 16581375.0)));\n} else {\nblock0 = step(depth, texture(cc_spotLightingMap, vec2(clipPos_offset_L, clipPos_offset_U)).x);\nblock1 = step(depth, texture(cc_spotLightingMap, vec2(clipPos.x, clipPos_offset_U)).x);\nblock2 = step(depth, texture(cc_spotLightingMap, vec2(clipPos_offset_R, clipPos_offset_U)).x);\nblock3 = step(depth, texture(cc_spotLightingMap, vec2(clipPos_offset_L, clipPos.y)).x);\nblock4 = step(depth, texture(cc_spotLightingMap, vec2(clipPos.x, clipPos.y)).x);\nblock5 = step(depth, texture(cc_spotLightingMap, vec2(clipPos_offset_R, clipPos.y)).x);\nblock6 = step(depth, texture(cc_spotLightingMap, vec2(clipPos_offset_L, clipPos_offset_D)).x);\nblock7 = step(depth, texture(cc_spotLightingMap, vec2(clipPos.x, clipPos_offset_D)).x);\nblock8 = step(depth, texture(cc_spotLightingMap, vec2(clipPos_offset_R, clipPos_offset_D)).x);\n}\nfloat coefX = mod(clipPos.x, oneTap.x) * mapSize.x;\nfloat coefY = mod(clipPos.y, oneTap.y) * mapSize.y;\nfloat shadow = 0.0;\nfloat resultX = mix(block0, block1, coefX);\nfloat resultY = mix(block3, block4, coefX);\nshadow += mix(resultX , resultY, coefY);\nresultX = mix(block1, block2, coefX);\nresultY = mix(block4, block5, coefX);\nshadow += mix(resultX , resultY, coefY);\nresultX = mix(block3, block4, coefX);\nresultY = mix(block6, block7, coefX);\nshadow += mix(resultX, resultY, coefY);\nresultX = mix(block4, block5, coefX);\nresultY = mix(block7, block8, coefX);\nshadow += mix(resultX, resultY, coefY);\nreturn shadow * 0.25;\n}\n#endif\n#if CC_USE_IBL\nlayout(set = 0, binding = 4) uniform samplerCube cc_environment;\nvec4 fragTextureLod (sampler2D tex, vec2 coord, float lod) {\nreturn textureLod(tex, coord, lod);\n}\nvec4 fragTextureLod (samplerCube tex, vec3 coord, float lod) {\nreturn textureLod(tex, coord, lod);\n}\nvec3 unpackRGBE (vec4 rgbe) {\nreturn rgbe.rgb * pow(1.1, rgbe.a * 255.0 - 128.0);\n}\n#if CC_USE_DIFFUSEMAP\nlayout(set = 0, binding = 6) uniform samplerCube cc_diffuseMap;\n#endif\n#endif\nfloat GGXMobile (float roughness, float NoH, vec3 H, vec3 N) {\nvec3 NxH = cross(N, H);\nfloat OneMinusNoHSqr = dot(NxH, NxH);\nfloat a = roughness * roughness;\nfloat n = NoH * a;\nfloat p = a / (OneMinusNoHSqr + n * n);\nreturn p * p;\n}\nfloat CalcSpecular (float roughness, float NoH, vec3 H, vec3 N) {\nreturn (roughness * 0.25 + 0.25) * GGXMobile(roughness, NoH, H, N);\n}\nvec3 BRDFApprox (vec3 specular, float roughness, float NoV) {\nconst vec4 c0 = vec4(-1.0, -0.0275, -0.572, 0.022);\nconst vec4 c1 = vec4(1.0, 0.0425, 1.04, -0.04);\nvec4 r = roughness * c0 + c1;\nfloat a004 = min(r.x * r.x, exp2(-9.28 * NoV)) * r.x + r.y;\nvec2 AB = vec2(-1.04, 1.04) * a004 + r.zw;\nAB.y *= clamp(50.0 * specular.g, 0.0, 1.0);\nreturn specular * AB.x + AB.y;\n}\n#if USE_REFLECTION_DENOISE\nvec3 GetEnvReflectionWithMipFiltering(vec3 R, float roughness, float mipCount, float denoiseIntensity) {\n#if CC_USE_IBL\nfloat mip = roughness * mipCount;\nfloat delta = (dot(dFdx(R), dFdy(R))) * 1000.0;\nfloat mipBias = mix(0.0, 5.0, clamp(delta, 0.0, 1.0));\nvec4 biased = fragTextureLod(cc_environment, R, mip + mipBias);\nvec4 filtered = texture(cc_environment, R);\n#if CC_USE_IBL == 2\nbiased.rgb = unpackRGBE(biased);\nfiltered.rgb = unpackRGBE(filtered);\n#else\nbiased.rgb = SRGBToLinear(biased.rgb);\nfiltered.rgb = SRGBToLinear(filtered.rgb);\n#endif\nreturn mix(biased.rgb, filtered.rgb, denoiseIntensity);\n#else\nreturn vec3(0.0, 0.0, 0.0);\n#endif\n}\n#endif\nstruct StandardSurface {\nvec4 albedo;\nvec3 position;\nvec3 normal;\nvec3 emissive;\nvec3 lightmap;\nfloat lightmap_test;\nfloat roughness;\nfloat metallic;\nfloat occlusion;\n};\nvec4 CCStandardShadingBase (StandardSurface s, vec4 shadowPos) {\nvec3 diffuse = s.albedo.rgb * (1.0 - s.metallic);\nvec3 specular = mix(vec3(0.04), s.albedo.rgb, s.metallic);\nvec3 N = normalize(s.normal);\nvec3 V = normalize(cc_cameraPos.xyz - s.position);\nfloat NV = max(abs(dot(N, V)), 0.0);\nspecular = BRDFApprox(specular, s.roughness, NV);\nvec3 L = normalize(-cc_mainLitDir.xyz);\nvec3 H = normalize(L + V);\nfloat NH = max(dot(N, H), 0.0);\nfloat NL = max(dot(N, L), 0.0);\nvec3 finalColor = NL * cc_mainLitColor.rgb * cc_mainLitColor.w;\nvec3 diffuseContrib = diffuse;\n#if USE_LIGHTMAP && !USE_BATCHING && !CC_FORWARD_ADD\nif (s.lightmap_test > 0.0001) {\nfinalColor = s.lightmap.rgb;\n}\n#else\ndiffuseContrib /= 3.14159265359;\n#endif\nvec3 specularContrib = specular * CalcSpecular(s.roughness, NH, H, N);\nvec3 dirlightContrib = (diffuseContrib + specularContrib);\nfloat shadow = 1.0;\n#if CC_RECEIVE_SHADOW && CC_ENABLE_DIR_SHADOW\nif (NL > 0.0) {\n{\nvec4 pos = ApplyShadowDepthBias_FaceNormal(shadowPos, N);\nfloat pcf = cc_shadowWHPBInfo.z;\nif (pcf > 1.9) shadow = CCGetShadowFactorSoft2X(pos);\nelse if (pcf > 0.9) shadow = CCGetShadowFactorSoft(pos);\nelse shadow = CCGetShadowFactorHard(pos);\nshadow = mix(shadow, 1.0, cc_shadowNFLSInfo.w);\n}\n}\n#endif\ndirlightContrib *= shadow;\nfinalColor *= dirlightContrib;\nfloat fAmb = 0.5 - N.y * 0.5;\nvec3 ambDiff = mix(cc_ambientSky.rgb, cc_ambientGround.rgb, fAmb);\n#if CC_USE_IBL\n#if CC_USE_DIFFUSEMAP\nvec4 diffuseMap = texture(cc_diffuseMap, N);\n#if CC_USE_DIFFUSEMAP == 2\nambDiff = unpackRGBE(diffuseMap);\n#else\nambDiff = SRGBToLinear(diffuseMap.rgb);\n#endif\n#endif\nvec3 R = normalize(reflect(-V, N));\n#if USE_REFLECTION_DENOISE\nvec3 env = GetEnvReflectionWithMipFiltering(R, s.roughness, cc_ambientGround.w, 0.6);\n#else\nvec4 envmap = fragTextureLod(cc_environment, R, s.roughness * cc_ambientGround.w);\n#if CC_USE_IBL == 2\nvec3 env = unpackRGBE(envmap);\n#else\nvec3 env = SRGBToLinear(envmap.rgb);\n#endif\n#endif\nfinalColor += env * cc_ambientSky.w * specular * s.occlusion;\n#endif\nfinalColor += ambDiff.rgb * cc_ambientSky.w * diffuse * s.occlusion;\nfinalColor += s.emissive;\nreturn vec4(finalColor, s.albedo.a);\n}\nvec3 ACESToneMap (vec3 color) {\ncolor = min(color, vec3(8.0));\nconst float A = 2.51;\nconst float B = 0.03;\nconst float C = 2.43;\nconst float D = 0.59;\nconst float E = 0.14;\nreturn (color * (A * color + B)) / (color * (C * color + D) + E);\n}\nvec4 CCFragOutput (vec4 color) {\n#if CC_USE_HDR\ncolor.rgb = ACESToneMap(color.rgb);\n#endif\ncolor.rgb = sqrt(color.rgb);\nreturn color;\n}\nlayout(location = 1) in highp vec4 v_shadowPos;\n#if USE_LIGHTMAP && !USE_BATCHING && !CC_FORWARD_ADD\nlayout(location = 9) in vec3 v_luv;\nlayout(set = 2, binding = 10) uniform sampler2D cc_lightingMap;\nvec3 UnpackLightingmap(vec4 color) {\nvec3 c;\nfloat e = 1.0 + color.a * (8.0 - 1.0);\nc.r = color.r * e;\nc.g = color.g * e;\nc.b = color.b * e;\nreturn c;\n}\n#endif\nlayout(location = 3) in vec3 v_position;\nlayout(location = 5) in vec2 v_uv;\nlayout(location = 6) in vec2 v_uv1;\nlayout(location = 4) in vec3 v_normal;\n#if USE_VERTEX_COLOR\nlayout(location = 2) in vec4 v_color;\n#endif\n#if USE_ALBEDO_MAP\nlayout(set = 1, binding = 1) uniform sampler2D albedoMap;\n#endif\n#if USE_NORMAL_MAP\nlayout(location = 7) in vec3 v_tangent;\nlayout(location = 8) in vec3 v_bitangent;\nlayout(set = 1, binding = 2) uniform sampler2D normalMap;\n#endif\n#if USE_PBR_MAP\nlayout(set = 1, binding = 3) uniform sampler2D pbrMap;\n#endif\n#if USE_METALLIC_ROUGHNESS_MAP\nlayout(set = 1, binding = 4) uniform sampler2D metallicRoughnessMap;\n#endif\n#if USE_OCCLUSION_MAP\nlayout(set = 1, binding = 5) uniform sampler2D occlusionMap;\n#endif\n#if USE_EMISSIVE_MAP\nlayout(set = 1, binding = 6) uniform sampler2D emissiveMap;\n#endif\n#if USE_ALPHA_TEST\n#endif\nvoid surf (out StandardSurface s) {\nvec4 baseColor = albedo;\n#if USE_VERTEX_COLOR\nbaseColor.rgb *= SRGBToLinear(v_color.rgb);\nbaseColor.a *= v_color.a;\n#endif\n#if USE_ALBEDO_MAP\nvec4 texColor = texture(albedoMap, ALBEDO_UV);\ntexColor.rgb = SRGBToLinear(texColor.rgb);\nbaseColor *= texColor;\n#endif\ns.albedo = baseColor;\ns.albedo.rgb *= albedoScaleAndCutoff.xyz;\n#if USE_ALPHA_TEST\nif (s.albedo.ALPHA_TEST_CHANNEL < albedoScaleAndCutoff.w) discard;\n#endif\n#if USE_LIGHTMAP && !USE_BATCHING && !CC_FORWARD_ADD\nvec4 lightColor = texture(cc_lightingMap, v_luv.xy);\ns.lightmap = UnpackLightingmap(lightColor);\ns.lightmap_test = v_luv.z;\n#endif\ns.normal = v_normal;\n#if USE_NORMAL_MAP\nvec3 nmmp = texture(normalMap, NORMAL_UV).xyz - vec3(0.5);\ns.normal =\n(nmmp.x * emissiveScaleParam.w) * normalize(v_tangent) +\n(nmmp.y * emissiveScaleParam.w) * normalize(v_bitangent) +\nnmmp.z * normalize(s.normal);\n#endif\ns.position = v_position;\nvec4 pbr = pbrParams;\n#if USE_PBR_MAP\nvec4 res = texture(pbrMap, PBR_UV);\npbr.x *= res.r;\npbr.y *= res.g;\npbr.z *= res.b;\npbr.w *= res.a;\n#endif\n#if USE_METALLIC_ROUGHNESS_MAP\nvec4 metallicRoughness = texture(metallicRoughnessMap, PBR_UV);\npbr.z *= metallicRoughness.b;\npbr.y *= metallicRoughness.g;\n#endif\n#if USE_OCCLUSION_MAP\npbr.x *= texture(occlusionMap, PBR_UV).r;\n#endif\ns.occlusion = pbr.x;\ns.roughness = pbr.y;\ns.metallic = pbr.z;\ns.emissive = emissive.rgb * emissiveScaleParam.xyz;\n#if USE_EMISSIVE_MAP\ns.emissive *= SRGBToLinear(texture(emissiveMap, EMISSIVE_UV).rgb);\n#endif\n}\n#if CC_FORWARD_ADD\n#if CC_PIPELINE_TYPE == 0\n# define LIGHTS_PER_PASS 1\n#else\n# define LIGHTS_PER_PASS 10\n#endif\n#if CC_ENABLE_CLUSTERED_LIGHT_CULLING == 0\nlayout(set = 2, binding = 1) uniform CCForwardLight {\nhighp vec4 cc_lightPos[LIGHTS_PER_PASS];\nvec4 cc_lightColor[LIGHTS_PER_PASS];\nvec4 cc_lightSizeRangeAngle[LIGHTS_PER_PASS];\nvec4 cc_lightDir[LIGHTS_PER_PASS];\n};\n#endif\nfloat SmoothDistAtt (float distSqr, float invSqrAttRadius) {\nfloat factor = distSqr * invSqrAttRadius;\nfloat smoothFactor = clamp(1.0 - factor * factor, 0.0, 1.0);\nreturn smoothFactor * smoothFactor;\n}\nfloat GetDistAtt (float distSqr, float invSqrAttRadius) {\nfloat attenuation = 1.0 / max(distSqr, 0.01*0.01);\nattenuation *= SmoothDistAtt(distSqr , invSqrAttRadius);\nreturn attenuation;\n}\nfloat GetAngleAtt (vec3 L, vec3 litDir, float litAngleScale, float litAngleOffset) {\nfloat cd = dot(litDir, L);\nfloat attenuation = clamp(cd * litAngleScale + litAngleOffset, 0.0, 1.0);\nreturn (attenuation * attenuation);\n}\n#if CC_ENABLE_CLUSTERED_LIGHT_CULLING == 0\nvec4 CCStandardShadingAdditive (StandardSurface s, vec4 shadowPos) {\nvec3 diffuse = s.albedo.rgb * (1.0 - s.metallic);\nvec3 specular = mix(vec3(0.04), s.albedo.rgb, s.metallic);\nvec3 diffuseContrib = diffuse / 3.14159265359;\nvec3 N = normalize(s.normal);\nvec3 V = normalize(cc_cameraPos.xyz - s.position);\nfloat NV = max(abs(dot(N, V)), 0.0);\nspecular = BRDFApprox(specular, s.roughness, NV);\nvec3 finalColor = vec3(0.0);\nint numLights = CC_PIPELINE_TYPE == 0 ? LIGHTS_PER_PASS : int(cc_lightDir[0].w);\nfor (int i = 0; i < LIGHTS_PER_PASS; i++) {\nif (i >= numLights) break;\nvec3 SLU = cc_lightPos[i].xyz - s.position;\nvec3 SL = normalize(SLU);\nvec3 SH = normalize(SL + V);\nfloat SNL = max(dot(N, SL), 0.0);\nfloat SNH = max(dot(N, SH), 0.0);\nfloat distSqr = dot(SLU, SLU);\nfloat litRadius = cc_lightSizeRangeAngle[i].x;\nfloat litRadiusSqr = litRadius * litRadius;\nfloat illum = 3.14159265359 * (litRadiusSqr / max(litRadiusSqr , distSqr));\nfloat attRadiusSqrInv = 1.0 / max(cc_lightSizeRangeAngle[i].y, 0.01);\nattRadiusSqrInv *= attRadiusSqrInv;\nfloat att = GetDistAtt(distSqr, attRadiusSqrInv);\nvec3 lspec = specular * CalcSpecular(s.roughness, SNH, SH, N);\nif (cc_lightPos[i].w > 0.0) {\nfloat cosInner = max(dot(-cc_lightDir[i].xyz, SL), 0.01);\nfloat cosOuter = cc_lightSizeRangeAngle[i].z;\nfloat litAngleScale = 1.0 / max(0.001, cosInner - cosOuter);\nfloat litAngleOffset = -cosOuter * litAngleScale;\natt *= GetAngleAtt(SL, -cc_lightDir[i].xyz, litAngleScale, litAngleOffset);\n}\nvec3 lightColor = cc_lightColor[i].rgb;\nfloat shadow = 1.0;\n#if CC_RECEIVE_SHADOW\nif (cc_lightPos[i].w > 0.0 && cc_lightSizeRangeAngle[i].w > 0.0) {\n{\nfloat pcf = cc_shadowWHPBInfo.z;\nif (pcf > 1.9) shadow = CCGetSpotLightShadowFactorSoft2X(shadowPos, s.position);\nelse if (pcf > 0.9) shadow = CCGetSpotLightShadowFactorSoft(shadowPos, s.position);\nelse shadow = CCGetSpotLightShadowFactorHard(shadowPos, s.position);\n}\n}\n#endif\nlightColor *= shadow;\nfinalColor += SNL * lightColor * cc_lightColor[i].w * illum * att * (diffuseContrib + lspec);\n}\nreturn vec4(finalColor, 0.0);\n}\n#endif\n#if CC_ENABLE_CLUSTERED_LIGHT_CULLING == 1\nlayout(set = 1, binding = 7) readonly buffer b_ccLightsBuffer { vec4 b_ccLights[]; };\nlayout(set = 1, binding = 8) readonly buffer b_clusterLightIndicesBuffer { uint b_clusterLightIndices[]; };\nlayout(set = 1, binding = 9) readonly buffer b_clusterLightGridBuffer { uvec4 b_clusterLightGrid[]; };\nstruct CCLight\n{\nvec4 cc_lightPos;\nvec4 cc_lightColor;\nvec4 cc_lightSizeRangeAngle;\nvec4 cc_lightDir;\n};\nstruct Cluster\n{\nvec3 minBounds;\nvec3 maxBounds;\n};\nstruct LightGrid\n{\nuint offset;\nuint ccLights;\n};\nCCLight getCCLight(uint i)\n{\nCCLight light;\nlight.cc_lightPos = b_ccLights[4u * i + 0u];\nlight.cc_lightColor = b_ccLights[4u * i + 1u];\nlight.cc_lightSizeRangeAngle = b_ccLights[4u * i + 2u];\nlight.cc_lightDir = b_ccLights[4u * i + 3u];\nreturn light;\n}\nLightGrid getLightGrid(uint cluster)\n{\nuvec4 gridvec = b_clusterLightGrid[cluster];\nLightGrid grid;\ngrid.offset = gridvec.x;\ngrid.ccLights = gridvec.y;\nreturn grid;\n}\nuint getGridLightIndex(uint start, uint offset)\n{\nreturn b_clusterLightIndices[start + offset];\n}\nuint getClusterZIndex(vec4 worldPos)\n{\nfloat scale = float(24) / log(cc_nearFar.y / cc_nearFar.x);\nfloat bias = -(float(24) * log(cc_nearFar.x) / log(cc_nearFar.y / cc_nearFar.x));\nfloat eyeDepth = -(cc_matView * worldPos).z;\nuint zIndex = uint(max(log(eyeDepth) * scale + bias, 0.0));\nreturn zIndex;\n}\nuint getClusterIndex(vec4 fragCoord, vec4 worldPos)\n{\nuint zIndex = getClusterZIndex(worldPos);\nfloat clusterSizeX = ceil(cc_screenSize.x / float(16));\nfloat clusterSizeY = ceil(cc_screenSize.y / float(8));\nuvec3 indices = uvec3(uvec2(fragCoord.xy / vec2(clusterSizeX, clusterSizeY)), zIndex);\nuint cluster = (16u * 8u) * indices.z + 16u * indices.y + indices.x;\nreturn cluster;\n}\nvec4 CCClusterShadingAdditive (StandardSurface s, vec4 shadowPos) {\nvec3 diffuse = s.albedo.rgb * (1.0 - s.metallic);\nvec3 specular = mix(vec3(0.04), s.albedo.rgb, s.metallic);\nvec3 diffuseContrib = diffuse / 3.14159265359;\nvec3 N = normalize(s.normal);\nvec3 V = normalize(cc_cameraPos.xyz - s.position);\nfloat NV = max(abs(dot(N, V)), 0.001);\nspecular = BRDFApprox(specular, s.roughness, NV);\nvec3 finalColor = vec3(0.0);\nuint cluster = getClusterIndex(gl_FragCoord, vec4(s.position, 1.0));\nLightGrid grid = getLightGrid(cluster);\nuint numLights = grid.ccLights;\nfor (uint i = 0u; i < 100u; i++) {\nif (i >= numLights) break;\nuint lightIndex = getGridLightIndex(grid.offset, i);\nCCLight light = getCCLight(lightIndex);\nvec3 SLU = light.cc_lightPos.xyz - s.position;\nvec3 SL = normalize(SLU);\nvec3 SH = normalize(SL + V);\nfloat SNL = max(dot(N, SL), 0.001);\nfloat SNH = max(dot(N, SH), 0.0);\nfloat distSqr = dot(SLU, SLU);\nfloat litRadius = light.cc_lightSizeRangeAngle.x;\nfloat litRadiusSqr = litRadius * litRadius;\nfloat illum = 3.14159265359 * (litRadiusSqr / max(litRadiusSqr , distSqr));\nfloat attRadiusSqrInv = 1.0 / max(light.cc_lightSizeRangeAngle.y, 0.01);\nattRadiusSqrInv *= attRadiusSqrInv;\nfloat att = GetDistAtt(distSqr, attRadiusSqrInv);\nvec3 lspec = specular * CalcSpecular(s.roughness, SNH, SH, N);\nif (light.cc_lightPos.w > 0.0) {\nfloat cosInner = max(dot(-light.cc_lightDir.xyz, SL), 0.01);\nfloat cosOuter = light.cc_lightSizeRangeAngle.z;\nfloat litAngleScale = 1.0 / max(0.001, cosInner - cosOuter);\nfloat litAngleOffset = -cosOuter * litAngleScale;\natt *= GetAngleAtt(SL, -light.cc_lightDir.xyz, litAngleScale, litAngleOffset);\n}\nvec3 lightColor = light.cc_lightColor.rgb;\nfloat shadow = 1.0;\n#if CC_RECEIVE_SHADOW\nif (light.cc_lightPos.w > 0.0) {\n{\nfloat pcf = cc_shadowWHPBInfo.z;\nif (pcf > 1.9) shadow = CCGetSpotLightShadowFactorSoft2X(shadowPos, s.position);\nelse if (pcf > 0.9) shadow = CCGetSpotLightShadowFactorSoft(shadowPos, s.position);\nelse shadow = CCGetSpotLightShadowFactorHard(shadowPos, s.position);\n}\n}\n#endif\nlightColor *= shadow;\nfinalColor += SNL * lightColor * light.cc_lightColor.w * illum * att * (diffuseContrib + lspec);\n}\nreturn vec4(finalColor, 0.0);\n}\n#endif\nlayout(location = 0) out vec4 fragColorX;\nvoid main () {\nStandardSurface s; surf(s);\n#if CC_ENABLE_CLUSTERED_LIGHT_CULLING == 1\nvec4 color = CCClusterShadingAdditive(s, v_shadowPos);\n#else\nvec4 color = CCStandardShadingAdditive(s, v_shadowPos);\n#endif\nCC_APPLY_FOG(color, s.position.xyz);\nfragColorX = CCFragOutput(color);\n}\n#elif (CC_PIPELINE_TYPE == 0 || CC_FORCE_FORWARD_SHADING)\nlayout(location = 0) out vec4 fragColorX;\nvoid main () {\nStandardSurface s; surf(s);\nvec4 color = CCStandardShadingBase(s, v_shadowPos);\nCC_APPLY_FOG(color, s.position.xyz);\nfragColorX = CCFragOutput(color);\n}\n#elif CC_PIPELINE_TYPE == 1\nlayout(location = 0) out vec4 fragColor0;\nlayout(location = 1) out vec4 fragColor1;\nlayout(location = 2) out vec4 fragColor2;\nlayout(location = 3) out vec4 fragColor3;\nvoid main () {\nStandardSurface s; surf(s);\nfragColor0 = s.albedo;\nfragColor1 = vec4(s.position, s.roughness);\nfragColor2 = vec4(s.normal, s.metallic);\nfragColor3 = vec4(s.emissive, s.occlusion);\n}\n#endif", + }, + { + "vert": "#extension GL_EXT_shader_explicit_arithmetic_types_int32: require\nprecision highp float;\nhighp float decode32 (highp vec4 rgba) {\nrgba = rgba * 255.0;\nhighp float Sign = 1.0 - (step(128.0, (rgba[3]) + 0.5)) * 2.0;\nhighp float Exponent = 2.0 * (mod(float(int((rgba[3]) + 0.5)), 128.0)) + (step(128.0, (rgba[2]) + 0.5)) - 127.0;\nhighp float Mantissa = (mod(float(int((rgba[2]) + 0.5)), 128.0)) * 65536.0 + rgba[1] * 256.0 + rgba[0] + 8388608.0;\nreturn Sign * exp2(Exponent - 23.0) * Mantissa;\n}\nstruct StandardVertInput {\nhighp vec4 position;\nvec3 normal;\nvec4 tangent;\n};\nlayout(location = 0) in vec3 a_position;\nlayout(location = 1) in vec3 a_normal;\nlayout(location = 2) in vec2 a_texCoord;\nlayout(location = 3) in vec4 a_tangent;\n#if CC_USE_MORPH\nint getVertexId() {\nreturn gl_VertexIndex;\n}\nlayout(set = 2, binding = 4) uniform CCMorph {\nvec4 cc_displacementWeights[15];\nvec4 cc_displacementTextureInfo;\n};\nvec2 getPixelLocation(vec2 textureResolution, int pixelIndex) {\nfloat pixelIndexF = float(pixelIndex);\nfloat x = mod(pixelIndexF, textureResolution.x);\nfloat y = floor(pixelIndexF / textureResolution.x);\nreturn vec2(x, y);\n}\nvec2 getPixelCoordFromLocation(vec2 location, vec2 textureResolution) {\nreturn (vec2(location.x, location.y) + .5) / textureResolution;\n}\n#if CC_DEVICE_SUPPORT_FLOAT_TEXTURE\nvec4 fetchVec3ArrayFromTexture(sampler2D tex, int pixelIndex) {\nivec2 texSize = textureSize(tex, 0);\nreturn texelFetch(tex, ivec2(pixelIndex % texSize.x, pixelIndex / texSize.x), 0);\n}\n#else\nvec4 fetchVec3ArrayFromTexture(sampler2D tex, int elementIndex) {\nint pixelIndex = elementIndex * 4;\nvec2 location = getPixelLocation(cc_displacementTextureInfo.xy, pixelIndex);\nvec2 x = getPixelCoordFromLocation(location + vec2(0.0, 0.0), cc_displacementTextureInfo.xy);\nvec2 y = getPixelCoordFromLocation(location + vec2(1.0, 0.0), cc_displacementTextureInfo.xy);\nvec2 z = getPixelCoordFromLocation(location + vec2(2.0, 0.0), cc_displacementTextureInfo.xy);\nreturn vec4(\ndecode32(texture(tex, x)),\ndecode32(texture(tex, y)),\ndecode32(texture(tex, z)),\n1.0\n);\n}\n#endif\nfloat getDisplacementWeight(int index) {\nint quot = index / 4;\nint remainder = index - quot * 4;\nif (remainder == 0) {\nreturn cc_displacementWeights[quot].x;\n} else if (remainder == 1) {\nreturn cc_displacementWeights[quot].y;\n} else if (remainder == 2) {\nreturn cc_displacementWeights[quot].z;\n} else {\nreturn cc_displacementWeights[quot].w;\n}\n}\nvec3 getVec3DisplacementFromTexture(sampler2D tex, int vertexIndex) {\n#if CC_MORPH_PRECOMPUTED\nreturn fetchVec3ArrayFromTexture(tex, vertexIndex).rgb;\n#else\nvec3 result = vec3(0, 0, 0);\nint nVertices = int(cc_displacementTextureInfo.z);\nfor (int iTarget = 0; iTarget < CC_MORPH_TARGET_COUNT; ++iTarget) {\nresult += (fetchVec3ArrayFromTexture(tex, nVertices * iTarget + vertexIndex).rgb * getDisplacementWeight(iTarget));\n}\nreturn result;\n#endif\n}\n#if CC_MORPH_TARGET_HAS_POSITION\nlayout(set = 2, binding = 7) uniform sampler2D cc_PositionDisplacements;\nvec3 getPositionDisplacement(int vertexId) {\nreturn getVec3DisplacementFromTexture(cc_PositionDisplacements, vertexId);\n}\n#endif\n#if CC_MORPH_TARGET_HAS_NORMAL\nlayout(set = 2, binding = 8) uniform sampler2D cc_NormalDisplacements;\nvec3 getNormalDisplacement(int vertexId) {\nreturn getVec3DisplacementFromTexture(cc_NormalDisplacements, vertexId);\n}\n#endif\n#if CC_MORPH_TARGET_HAS_TANGENT\nlayout(set = 2, binding = 9) uniform sampler2D cc_TangentDisplacements;\nvec3 getTangentDisplacement(int vertexId) {\nreturn getVec3DisplacementFromTexture(cc_TangentDisplacements, vertexId);\n}\n#endif\nvoid applyMorph (inout StandardVertInput attr) {\nint vertexId = getVertexId();\n#if CC_MORPH_TARGET_HAS_POSITION\nattr.position.xyz = attr.position.xyz + getPositionDisplacement(vertexId);\n#endif\n#if CC_MORPH_TARGET_HAS_NORMAL\nattr.normal.xyz = attr.normal.xyz + getNormalDisplacement(vertexId);\n#endif\n#if CC_MORPH_TARGET_HAS_TANGENT\nattr.tangent.xyz = attr.tangent.xyz + getTangentDisplacement(vertexId);\n#endif\n}\nvoid applyMorph (inout vec4 position) {\n#if CC_MORPH_TARGET_HAS_POSITION\nposition.xyz = position.xyz + getPositionDisplacement(getVertexId());\n#endif\n}\n#endif\n#if CC_USE_SKINNING\nlayout(location = 4) in u32vec4 a_joints;\nlayout(location = 5) in vec4 a_weights;\n#if CC_USE_BAKED_ANIMATION\n#if USE_INSTANCING\nlayout(location = 7) in highp vec4 a_jointAnimInfo;\n#endif\nlayout(set = 2, binding = 3) uniform CCSkinningTexture {\nhighp vec4 cc_jointTextureInfo;\n};\nlayout(set = 2, binding = 2) uniform CCSkinningAnimation {\nhighp vec4 cc_jointAnimInfo;\n};\nlayout(set = 2, binding = 6) uniform highp sampler2D cc_jointTexture;\n#else\nlayout(set = 2, binding = 3) uniform CCSkinning {\nhighp vec4 cc_joints[30 * 3];\n};\n#endif\n#if CC_USE_BAKED_ANIMATION\n#if CC_DEVICE_SUPPORT_FLOAT_TEXTURE\nmat4 getJointMatrix (float i) {\n#if USE_INSTANCING\nhighp float j = 3.0 * (a_jointAnimInfo.x * a_jointAnimInfo.y + i) + a_jointAnimInfo.z;\n#else\nhighp float j = 3.0 * (cc_jointAnimInfo.x * cc_jointTextureInfo.y + i) + cc_jointTextureInfo.z;\n#endif\nhighp float invSize = cc_jointTextureInfo.w;\nhighp float y = floor(j * invSize);\nhighp float x = floor(j - y * cc_jointTextureInfo.x);\ny = (y + 0.5) * invSize;\nvec4 v1 = texture(cc_jointTexture, vec2((x + 0.5) * invSize, y));\nvec4 v2 = texture(cc_jointTexture, vec2((x + 1.5) * invSize, y));\nvec4 v3 = texture(cc_jointTexture, vec2((x + 2.5) * invSize, y));\nreturn mat4(vec4(v1.xyz, 0.0), vec4(v2.xyz, 0.0), vec4(v3.xyz, 0.0), vec4(v1.w, v2.w, v3.w, 1.0));\n}\n#else\nmat4 getJointMatrix (float i) {\n#if USE_INSTANCING\nhighp float j = 12.0 * (a_jointAnimInfo.x * a_jointAnimInfo.y + i) + a_jointAnimInfo.z;\n#else\nhighp float j = 12.0 * (cc_jointAnimInfo.x * cc_jointTextureInfo.y + i) + cc_jointTextureInfo.z;\n#endif\nhighp float invSize = cc_jointTextureInfo.w;\nhighp float y = floor(j * invSize);\nhighp float x = floor(j - y * cc_jointTextureInfo.x);\ny = (y + 0.5) * invSize;\nvec4 v1 = vec4(\ndecode32(texture(cc_jointTexture, vec2((x + 0.5) * invSize, y))),\ndecode32(texture(cc_jointTexture, vec2((x + 1.5) * invSize, y))),\ndecode32(texture(cc_jointTexture, vec2((x + 2.5) * invSize, y))),\ndecode32(texture(cc_jointTexture, vec2((x + 3.5) * invSize, y)))\n);\nvec4 v2 = vec4(\ndecode32(texture(cc_jointTexture, vec2((x + 4.5) * invSize, y))),\ndecode32(texture(cc_jointTexture, vec2((x + 5.5) * invSize, y))),\ndecode32(texture(cc_jointTexture, vec2((x + 6.5) * invSize, y))),\ndecode32(texture(cc_jointTexture, vec2((x + 7.5) * invSize, y)))\n);\nvec4 v3 = vec4(\ndecode32(texture(cc_jointTexture, vec2((x + 8.5) * invSize, y))),\ndecode32(texture(cc_jointTexture, vec2((x + 9.5) * invSize, y))),\ndecode32(texture(cc_jointTexture, vec2((x + 10.5) * invSize, y))),\ndecode32(texture(cc_jointTexture, vec2((x + 11.5) * invSize, y)))\n);\nreturn mat4(vec4(v1.xyz, 0.0), vec4(v2.xyz, 0.0), vec4(v3.xyz, 0.0), vec4(v1.w, v2.w, v3.w, 1.0));\n}\n#endif\n#else\nmat4 getJointMatrix (float i) {\nint idx = int(i);\nvec4 v1 = cc_joints[idx * 3];\nvec4 v2 = cc_joints[idx * 3 + 1];\nvec4 v3 = cc_joints[idx * 3 + 2];\nreturn mat4(vec4(v1.xyz, 0.0), vec4(v2.xyz, 0.0), vec4(v3.xyz, 0.0), vec4(v1.w, v2.w, v3.w, 1.0));\n}\n#endif\nmat4 skinMatrix () {\nvec4 joints = vec4(a_joints);\nreturn getJointMatrix(joints.x) * a_weights.x\n+ getJointMatrix(joints.y) * a_weights.y\n+ getJointMatrix(joints.z) * a_weights.z\n+ getJointMatrix(joints.w) * a_weights.w;\n}\nvoid CCSkin (inout vec4 position) {\nmat4 m = skinMatrix();\nposition = m * position;\n}\nvoid CCSkin (inout StandardVertInput attr) {\nmat4 m = skinMatrix();\nattr.position = m * attr.position;\nattr.normal = (m * vec4(attr.normal, 0.0)).xyz;\nattr.tangent.xyz = (m * vec4(attr.tangent.xyz, 0.0)).xyz;\n}\n#endif\n#if USE_INSTANCING\nlayout(location = 8) in vec4 a_matWorld0;\nlayout(location = 9) in vec4 a_matWorld1;\nlayout(location = 10) in vec4 a_matWorld2;\n#if USE_LIGHTMAP\nlayout(location = 11) in vec4 a_lightingMapUVParam;\n#endif\n#elif USE_BATCHING\nlayout(location = 12) in float a_dyn_batch_id;\nlayout(set = 2, binding = 0) uniform CCLocalBatched {\nhighp mat4 cc_matWorlds[10];\n};\n#else\nlayout(set = 2, binding = 0) uniform CCLocal {\nhighp mat4 cc_matWorld;\nhighp mat4 cc_matWorldIT;\nhighp vec4 cc_lightingMapUVParam;\n};\n#endif\nlayout(set = 1, binding = 0) uniform Constants {\nvec4 tilingOffset;\nvec4 albedo;\nvec4 albedoScaleAndCutoff;\nvec4 pbrParams;\nvec4 emissive;\nvec4 emissiveScaleParam;\n};\nlayout(set = 0, binding = 2) uniform CCShadow {\nhighp mat4 cc_matLightPlaneProj;\nhighp mat4 cc_matLightView;\nhighp mat4 cc_matLightViewProj;\nhighp vec4 cc_shadowInvProjDepthInfo;\nhighp vec4 cc_shadowProjDepthInfo;\nhighp vec4 cc_shadowProjInfo;\nlowp vec4 cc_shadowNFLSInfo;\nlowp vec4 cc_shadowWHPBInfo;\nlowp vec4 cc_shadowLPNNInfo;\nlowp vec4 cc_shadowColor;\n};\n#if HAS_SECOND_UV || USE_LIGHTMAP\nlayout(location = 13) in vec2 a_texCoord1;\n#endif\nlayout(location = 0) out vec2 v_uv;\nlayout(location = 1) out vec2 v_uv1;\nlayout(location = 2) out vec4 v_worldPos;\nlayout(location = 3) out float v_clip_depth;\nvec4 vert () {\nStandardVertInput In;\nIn.position = vec4(a_position, 1.0);\nIn.normal = a_normal;\nIn.tangent = a_tangent;\n#if CC_USE_MORPH\napplyMorph(In);\n#endif\n#if CC_USE_SKINNING\nCCSkin(In);\n#endif\nmat4 matWorld, matWorldIT;\n#if USE_INSTANCING\nmatWorld = mat4(\nvec4(a_matWorld0.xyz, 0.0),\nvec4(a_matWorld1.xyz, 0.0),\nvec4(a_matWorld2.xyz, 0.0),\nvec4(a_matWorld0.w, a_matWorld1.w, a_matWorld2.w, 1.0)\n);\nmatWorldIT = matWorld;\n#elif USE_BATCHING\nmatWorld = cc_matWorlds[int(a_dyn_batch_id)];\nmatWorldIT = matWorld;\n#else\nmatWorld = cc_matWorld;\nmatWorldIT = cc_matWorldIT;\n#endif\nv_worldPos = matWorld * In.position;\nvec4 clipPos = cc_matLightViewProj * v_worldPos;\nv_uv = a_texCoord * tilingOffset.xy + tilingOffset.zw;\n#if HAS_SECOND_UV\nv_uv1 = a_texCoord1 * tilingOffset.xy + tilingOffset.zw;\n#endif\nv_clip_depth = clipPos.z / clipPos.w * 0.5 + 0.5;\nreturn clipPos;\n}\nvoid main() { gl_Position = vert(); }", + "frag": "\nprecision highp float;\nlayout(set = 1, binding = 0) uniform Constants {\nvec4 tilingOffset;\nvec4 albedo;\nvec4 albedoScaleAndCutoff;\nvec4 pbrParams;\nvec4 emissive;\nvec4 emissiveScaleParam;\n};\nvec4 packDepthToRGBA (float depth) {\nvec4 ret = vec4(1.0, 255.0, 65025.0, 16581375.0) * depth;\nret = fract(ret);\nret -= vec4(ret.yzw, 0.0) / 255.0;\nreturn ret;\n}\nlayout(set = 0, binding = 0) uniform CCGlobal {\nhighp vec4 cc_time;\nmediump vec4 cc_screenSize;\nmediump vec4 cc_nativeSize;\n};\nlayout(set = 0, binding = 1) uniform CCCamera {\nhighp mat4 cc_matView;\nhighp mat4 cc_matViewInv;\nhighp mat4 cc_matProj;\nhighp mat4 cc_matProjInv;\nhighp mat4 cc_matViewProj;\nhighp mat4 cc_matViewProjInv;\nhighp vec4 cc_cameraPos;\nmediump vec4 cc_screenScale;\nmediump vec4 cc_exposure;\nmediump vec4 cc_mainLitDir;\nmediump vec4 cc_mainLitColor;\nmediump vec4 cc_ambientSky;\nmediump vec4 cc_ambientGround;\nmediump vec4 cc_fogColor;\nmediump vec4 cc_fogBase;\nmediump vec4 cc_fogAdd;\nmediump vec4 cc_nearFar;\nmediump vec4 cc_viewPort;\n};\nlayout(set = 0, binding = 2) uniform CCShadow {\nhighp mat4 cc_matLightPlaneProj;\nhighp mat4 cc_matLightView;\nhighp mat4 cc_matLightViewProj;\nhighp vec4 cc_shadowInvProjDepthInfo;\nhighp vec4 cc_shadowProjDepthInfo;\nhighp vec4 cc_shadowProjInfo;\nlowp vec4 cc_shadowNFLSInfo;\nlowp vec4 cc_shadowWHPBInfo;\nlowp vec4 cc_shadowLPNNInfo;\nlowp vec4 cc_shadowColor;\n};\nfloat CCGetLinearDepthFromViewSpace(vec3 viewPos) {\nfloat dist = length(viewPos);\nreturn (dist - cc_shadowNFLSInfo.x) / (cc_shadowNFLSInfo.y - cc_shadowNFLSInfo.x);\n}\nfloat CCGetLinearDepth(vec3 worldPos) {\nvec4 viewStartPos = cc_matLightView * vec4(worldPos.xyz, 1.0);\nreturn CCGetLinearDepthFromViewSpace(viewStartPos.xyz);\n}\n#if CC_RECEIVE_SHADOW\nlayout(set = 0, binding = 3) uniform highp sampler2D cc_shadowMap;\nlayout(set = 0, binding = 5) uniform highp sampler2D cc_spotLightingMap;\n#endif\nlayout(location = 0) in vec2 v_uv;\nlayout(location = 1) in vec2 v_uv1;\nlayout(location = 2) in vec4 v_worldPos;\nlayout(location = 3) in float v_clip_depth;\n#if USE_ALBEDO_MAP\nlayout(set = 1, binding = 1) uniform sampler2D albedoMap;\n#endif\n#if USE_ALPHA_TEST\n#endif\nvec4 frag () {\nvec4 baseColor = albedo;\n#if USE_ALBEDO_MAP\nbaseColor *= texture(albedoMap, ALBEDO_UV);\n#endif\n#if USE_ALPHA_TEST\nif (baseColor.ALPHA_TEST_CHANNEL < albedoScaleAndCutoff.w) discard;\n#endif\nif(cc_shadowLPNNInfo.x > 0.000001 && cc_shadowLPNNInfo.x < 1.999999) {\nif (cc_shadowNFLSInfo.z > 0.000001) {\nreturn vec4(CCGetLinearDepth(v_worldPos.xyz), 1.0, 1.0, 1.0);\n}\n}\nif (cc_shadowLPNNInfo.y > 0.000001) {\nreturn packDepthToRGBA(v_clip_depth);\n}\nreturn vec4(v_clip_depth, 1.0, 1.0, 1.0);\n}\nlayout(location = 0) out vec4 cc_FragColor;\nvoid main() { cc_FragColor = frag(); }", + } + ], + [ + { + "vert": "\nprecision mediump float;\nlayout(set = 0, binding = 0) uniform CCGlobal {\nhighp vec4 cc_time;\nmediump vec4 cc_screenSize;\nmediump vec4 cc_nativeSize;\n};\nlayout(set = 0, binding = 1) uniform CCCamera {\nhighp mat4 cc_matView;\nhighp mat4 cc_matViewInv;\nhighp mat4 cc_matProj;\nhighp mat4 cc_matProjInv;\nhighp mat4 cc_matViewProj;\nhighp mat4 cc_matViewProjInv;\nhighp vec4 cc_cameraPos;\nmediump vec4 cc_screenScale;\nmediump vec4 cc_exposure;\nmediump vec4 cc_mainLitDir;\nmediump vec4 cc_mainLitColor;\nmediump vec4 cc_ambientSky;\nmediump vec4 cc_ambientGround;\nmediump vec4 cc_fogColor;\nmediump vec4 cc_fogBase;\nmediump vec4 cc_fogAdd;\nmediump vec4 cc_nearFar;\nmediump vec4 cc_viewPort;\n};\nlayout(set = 2, binding = 0) uniform CCLocal {\nhighp mat4 cc_matWorld;\nhighp mat4 cc_matWorldIT;\nhighp vec4 cc_lightingMapUVParam;\n};\nfloat LinearFog(vec4 pos) {\nvec4 wPos = pos;\nfloat cam_dis = distance(cc_cameraPos, wPos);\nfloat fogStart = cc_fogBase.x;\nfloat fogEnd = cc_fogBase.y;\nreturn clamp((fogEnd - cam_dis) / (fogEnd - fogStart), 0., 1.);\n}\nfloat ExpFog(vec4 pos) {\nvec4 wPos = pos;\nfloat fogAtten = cc_fogAdd.z;\nfloat fogStart = cc_fogBase.x;\nfloat fogDensity = cc_fogBase.z;\nfloat cam_dis = max(distance(cc_cameraPos, wPos) - fogStart, 0.0) / fogAtten * 4.;\nfloat f = exp(-cam_dis * fogDensity);\nreturn f;\n}\nfloat ExpSquaredFog(vec4 pos) {\nvec4 wPos = pos;\nfloat fogAtten = cc_fogAdd.z;\nfloat fogStart = cc_fogBase.x;\nfloat fogDensity = cc_fogBase.z;\nfloat cam_dis = max(distance(cc_cameraPos, wPos) - fogStart, 0.0) / fogAtten * 4.;\nfloat f = exp(-cam_dis * cam_dis * fogDensity * fogDensity);\nreturn f;\n}\nfloat LayeredFog(vec4 pos) {\nvec4 wPos = pos;\nfloat fogAtten = cc_fogAdd.z;\nfloat _FogTop = cc_fogAdd.x;\nfloat _FogRange = cc_fogAdd.y;\nvec3 camWorldProj = cc_cameraPos.xyz;\ncamWorldProj.y = 0.;\nvec3 worldPosProj = wPos.xyz;\nworldPosProj.y = 0.;\nfloat fDeltaD = distance(worldPosProj, camWorldProj) / fogAtten * 2.0;\nfloat fDeltaY, fDensityIntegral;\nif (cc_cameraPos.y > _FogTop) {\nif (wPos.y < _FogTop) {\nfDeltaY = (_FogTop - wPos.y) / _FogRange * 2.0;\nfDensityIntegral = fDeltaY * fDeltaY * 0.5;\n} else {\nfDeltaY = 0.;\nfDensityIntegral = 0.;\n}\n} else {\nif (wPos.y < _FogTop) {\nfloat fDeltaA = (_FogTop - cc_cameraPos.y) / _FogRange * 2.;\nfloat fDeltaB = (_FogTop - wPos.y) / _FogRange * 2.;\nfDeltaY = abs(fDeltaA - fDeltaB);\nfDensityIntegral = abs((fDeltaA * fDeltaA * 0.5) - (fDeltaB * fDeltaB * 0.5));\n} else {\nfDeltaY = abs(_FogTop - cc_cameraPos.y) / _FogRange * 2.;\nfDensityIntegral = abs(fDeltaY * fDeltaY * 0.5);\n}\n}\nfloat fDensity;\nif (fDeltaY != 0.) {\nfDensity = (sqrt(1.0 + ((fDeltaD / fDeltaY) * (fDeltaD / fDeltaY)))) * fDensityIntegral;\n} else {\nfDensity = 0.;\n}\nfloat f = exp(-fDensity);\nreturn f;\n}\nvoid CC_TRANSFER_FOG_BASE(vec4 pos, out float factor)\n{\n#if CC_USE_FOG == 0\nfactor = LinearFog(pos);\n#elif CC_USE_FOG == 1\nfactor = ExpFog(pos);\n#elif CC_USE_FOG == 2\nfactor = ExpSquaredFog(pos);\n#elif CC_USE_FOG == 3\nfactor = LayeredFog(pos);\n#else\nfactor = 1.0;\n#endif\n}\n#if !CC_USE_ACCURATE_FOG\nlayout(location = 0) out float v_fog_factor;\n#endif\nvoid CC_TRANSFER_FOG(vec4 pos) {\n#if !CC_USE_ACCURATE_FOG\nCC_TRANSFER_FOG_BASE(pos, v_fog_factor);\n#endif\n}\nlayout(location = 1) out highp vec4 v_shadowPos;\nlayout(set = 0, binding = 2) uniform CCShadow {\nhighp mat4 cc_matLightPlaneProj;\nhighp mat4 cc_matLightView;\nhighp mat4 cc_matLightViewProj;\nhighp vec4 cc_shadowInvProjDepthInfo;\nhighp vec4 cc_shadowProjDepthInfo;\nhighp vec4 cc_shadowProjInfo;\nlowp vec4 cc_shadowNFLSInfo;\nlowp vec4 cc_shadowWHPBInfo;\nlowp vec4 cc_shadowLPNNInfo;\nlowp vec4 cc_shadowColor;\n};\n#if CC_RECEIVE_SHADOW\nlayout(set = 0, binding = 3) uniform highp sampler2D cc_shadowMap;\nlayout(set = 0, binding = 5) uniform highp sampler2D cc_spotLightingMap;\n#endif\nlayout(location = 0) in vec3 a_position;\nlayout(location = 1) in vec3 a_normal;\nlayout(location = 2) in vec2 a_texCoord;\nlayout(location = 2) out highp vec3 v_position;\nlayout(location = 3) out mediump vec3 v_normal;\n#if USE_NORMALMAP\nlayout(location = 4) out mediump vec3 v_tangent;\nlayout(location = 5) out mediump vec3 v_binormal;\n#endif\nlayout(location = 6) out mediump vec2 uvw;\nlayout(location = 7) out mediump vec2 uv0;\nlayout(location = 8) out mediump vec2 uv1;\nlayout(location = 9) out mediump vec2 uv2;\nlayout(location = 10) out mediump vec2 uv3;\nlayout(location = 11) out mediump vec3 luv;\nlayout(location = 12) out mediump vec3 diffuse;\nlayout(set = 1, binding = 0) uniform TexCoords {\nvec4 UVScale;\nvec4 lightMapUVParam;\n};\nvoid main () {\nvec3 worldPos;\nworldPos.x = cc_matWorld[3][0] + a_position.x;\nworldPos.y = cc_matWorld[3][1] + a_position.y;\nworldPos.z = cc_matWorld[3][2] + a_position.z;\nvec4 pos = vec4(worldPos, 1.0);\npos = cc_matViewProj * pos;\nuvw = a_texCoord;\nuv0 = a_position.xz * UVScale.x;\nuv1 = a_position.xz * UVScale.y;\nuv2 = a_position.xz * UVScale.z;\nuv3 = a_position.xz * UVScale.w;\n#if USE_LIGHTMAP\nluv.xy = lightMapUVParam.xy + a_texCoord * lightMapUVParam.zw;\nluv.z = lightMapUVParam.z;\n#endif\nv_position = worldPos;\nv_normal = a_normal;\nCC_TRANSFER_FOG(vec4(worldPos, 1.0));\n#if USE_NORMALMAP\nv_tangent = vec3(1.0, 0.0, 0.0);\nv_binormal = vec3(0.0, 0.0, 1.0);\nv_binormal = cross(v_tangent, a_normal);\nv_tangent = cross(a_normal, v_binormal);\n#endif\nv_shadowPos = cc_matLightViewProj * vec4(worldPos, 1.0);\ngl_Position = pos;\n}", + "frag": "\nprecision highp float;\nlayout(set = 0, binding = 0) uniform CCGlobal {\nhighp vec4 cc_time;\nmediump vec4 cc_screenSize;\nmediump vec4 cc_nativeSize;\n};\nlayout(set = 0, binding = 1) uniform CCCamera {\nhighp mat4 cc_matView;\nhighp mat4 cc_matViewInv;\nhighp mat4 cc_matProj;\nhighp mat4 cc_matProjInv;\nhighp mat4 cc_matViewProj;\nhighp mat4 cc_matViewProjInv;\nhighp vec4 cc_cameraPos;\nmediump vec4 cc_screenScale;\nmediump vec4 cc_exposure;\nmediump vec4 cc_mainLitDir;\nmediump vec4 cc_mainLitColor;\nmediump vec4 cc_ambientSky;\nmediump vec4 cc_ambientGround;\nmediump vec4 cc_fogColor;\nmediump vec4 cc_fogBase;\nmediump vec4 cc_fogAdd;\nmediump vec4 cc_nearFar;\nmediump vec4 cc_viewPort;\n};\nvec3 SRGBToLinear (vec3 gamma) {\nreturn gamma * gamma;\n}\nlayout(set = 0, binding = 2) uniform CCShadow {\nhighp mat4 cc_matLightPlaneProj;\nhighp mat4 cc_matLightView;\nhighp mat4 cc_matLightViewProj;\nhighp vec4 cc_shadowInvProjDepthInfo;\nhighp vec4 cc_shadowProjDepthInfo;\nhighp vec4 cc_shadowProjInfo;\nlowp vec4 cc_shadowNFLSInfo;\nlowp vec4 cc_shadowWHPBInfo;\nlowp vec4 cc_shadowLPNNInfo;\nlowp vec4 cc_shadowColor;\n};\nfloat CCGetLinearDepthFromViewSpace(vec3 viewPos) {\nfloat dist = length(viewPos);\nreturn (dist - cc_shadowNFLSInfo.x) / (cc_shadowNFLSInfo.y - cc_shadowNFLSInfo.x);\n}\nfloat CCGetLinearDepth(vec3 worldPos) {\nvec4 viewStartPos = cc_matLightView * vec4(worldPos.xyz, 1.0);\nreturn CCGetLinearDepthFromViewSpace(viewStartPos.xyz);\n}\n#if CC_RECEIVE_SHADOW\nlayout(set = 0, binding = 3) uniform highp sampler2D cc_shadowMap;\nlayout(set = 0, binding = 5) uniform highp sampler2D cc_spotLightingMap;\nvec4 ApplyShadowDepthBias_FaceNormal(vec4 shadowPos, vec3 worldNormal)\n{\nvec4 newShadowPos = shadowPos;\nif(cc_shadowLPNNInfo.z > 0.0001)\n{\nvec4 viewNormal = cc_matLightView * vec4(worldNormal, 0.0);\nif(viewNormal.z < 0.1)\nnewShadowPos.xy += viewNormal.xy * cc_shadowProjInfo.xy * cc_shadowLPNNInfo.z * clamp(viewNormal.z, 0.001, 0.1);\n}\nreturn newShadowPos;\n}\nvec4 ApplyShadowDepthBias_Perspective(vec4 shadowPos, float viewspaceDepthBias)\n{\nvec3 viewSpacePos;\nviewSpacePos.xy = shadowPos.xy * cc_shadowProjInfo.zw;\nviewSpacePos.z = shadowPos.z * cc_shadowInvProjDepthInfo.x + shadowPos.w * cc_shadowInvProjDepthInfo.y;\nviewSpacePos.xyz += cc_shadowProjDepthInfo.z * normalize(viewSpacePos.xyz) * viewspaceDepthBias;\nvec4 clipSpacePos;\nclipSpacePos.xy = viewSpacePos.xy * cc_shadowProjInfo.xy;\nclipSpacePos.zw = viewSpacePos.z * cc_shadowProjDepthInfo.xz + vec2(cc_shadowProjDepthInfo.y, 0.0);\nif (cc_shadowNFLSInfo.z > 0.000001) {\nclipSpacePos.z = CCGetLinearDepthFromViewSpace(viewSpacePos.xyz);\nclipSpacePos.z = (clipSpacePos.z * 2.0 - 1.0) * clipSpacePos.w;\n}\nreturn clipSpacePos;\n}\nvec4 ApplyShadowDepthBias_Orthographic(vec4 shadowPos, float viewspaceDepthBias)\n{\nfloat coeffA = cc_shadowProjDepthInfo.x;\nfloat coeffB = cc_shadowProjDepthInfo.y;\nfloat viewSpacePos_z = (shadowPos.z - coeffB) / coeffA;\nviewSpacePos_z += viewspaceDepthBias;\nvec4 result = shadowPos;\nresult.z = viewSpacePos_z * coeffA + coeffB;\nreturn result;\n}\nfloat CCGetShadowFactorHard (vec4 shadowPos) {\nvec4 clipPosNew = ApplyShadowDepthBias_Orthographic(shadowPos, cc_shadowWHPBInfo.w);\nvec3 clipPos = clipPosNew.xyz / clipPosNew.w * 0.5 + 0.5;\nif (clipPos.x < 0.0 || clipPos.x > 1.0 ||\nclipPos.y < 0.0 || clipPos.y > 1.0 ||\nclipPos.z < 0.0 || clipPos.z > 1.0) { return 1.0; }\nclipPos.xy = cc_cameraPos.w == 1.0 ? vec2(clipPos.xy.x, 1.0 - clipPos.xy.y) : clipPos.xy;\nfloat shadow = 0.0;\nfloat closestDepth = 0.0;\nif (cc_shadowLPNNInfo.y > 0.000001) {\nclosestDepth = dot(texture(cc_shadowMap, clipPos.xy), vec4(1.0, 1.0 / 255.0, 1.0 / 65025.0, 1.0 / 16581375.0));\n} else {\nclosestDepth = texture(cc_shadowMap, clipPos.xy).x;\n}\nshadow = step(clipPos.z, closestDepth);\nreturn shadow;\n}\nfloat CCGetShadowFactorSoft (vec4 shadowPos) {\nvec4 clipPosNew = ApplyShadowDepthBias_Orthographic(shadowPos, cc_shadowWHPBInfo.w);\nvec3 clipPos = clipPosNew.xyz / clipPosNew.w * 0.5 + 0.5;\nif (clipPos.x < 0.0 || clipPos.x > 1.0 ||\nclipPos.y < 0.0 || clipPos.y > 1.0 ||\nclipPos.z < 0.0 || clipPos.z > 1.0) { return 1.0; }\nclipPos.xy = cc_cameraPos.w == 1.0 ? vec2(clipPos.xy.x, 1.0 - clipPos.xy.y) : clipPos.xy;\nfloat offsetDepth = clipPos.z;\nvec2 mapSize = cc_shadowWHPBInfo.xy;\nvec2 oneTap = 1.0 / mapSize;\nvec2 clipPos_offset = clipPos.xy + oneTap;\nfloat block0, block1, block2, block3;\nif (cc_shadowLPNNInfo.y > 0.000001) {\nblock0 = step(offsetDepth, dot(texture(cc_shadowMap, vec2(clipPos.x, clipPos.y)), vec4(1.0, 1.0 / 255.0, 1.0 / 65025.0, 1.0 / 16581375.0)));\nblock1 = step(offsetDepth, dot(texture(cc_shadowMap, vec2(clipPos_offset.x, clipPos.y)), vec4(1.0, 1.0 / 255.0, 1.0 / 65025.0, 1.0 / 16581375.0)));\nblock2 = step(offsetDepth, dot(texture(cc_shadowMap, vec2(clipPos.x, clipPos_offset.y)), vec4(1.0, 1.0 / 255.0, 1.0 / 65025.0, 1.0 / 16581375.0)));\nblock3 = step(offsetDepth, dot(texture(cc_shadowMap, vec2(clipPos_offset.x, clipPos_offset.y)), vec4(1.0, 1.0 / 255.0, 1.0 / 65025.0, 1.0 / 16581375.0)));\n} else {\nblock0 = step(offsetDepth, texture(cc_shadowMap, vec2(clipPos.x, clipPos.y)).x);\nblock1 = step(offsetDepth, texture(cc_shadowMap, vec2(clipPos_offset.x, clipPos.y)).x);\nblock2 = step(offsetDepth, texture(cc_shadowMap, vec2(clipPos.x, clipPos_offset.y)).x);\nblock3 = step(offsetDepth, texture(cc_shadowMap, vec2(clipPos_offset.x, clipPos_offset.y)).x);\n}\nfloat coefX = mod(clipPos.x, oneTap.x) * mapSize.x;\nfloat resultX = mix(block0, block1, coefX);\nfloat resultY = mix(block2, block3, coefX);\nfloat coefY = mod(clipPos.y, oneTap.y) * mapSize.y;\nreturn mix(resultX, resultY, coefY);\n}\nfloat CCGetShadowFactorSoft2X (vec4 shadowPos) {\nvec4 clipPosNew = ApplyShadowDepthBias_Orthographic(shadowPos, cc_shadowWHPBInfo.w);\nvec3 clipPos = clipPosNew.xyz / clipPosNew.w * 0.5 + 0.5;\nif (clipPos.x < 0.0 || clipPos.x > 1.0 ||\nclipPos.y < 0.0 || clipPos.y > 1.0 ||\nclipPos.z < 0.0 || clipPos.z > 1.0) { return 1.0; }\nclipPos.xy = cc_cameraPos.w == 1.0 ? vec2(clipPos.xy.x, 1.0 - clipPos.xy.y) : clipPos.xy;\nfloat offsetDepth = clipPos.z;\nvec2 mapSize = cc_shadowWHPBInfo.xy;\nvec2 oneTap = 1.0 / mapSize;\nfloat clipPos_offset_L = clipPos.x - oneTap.x;\nfloat clipPos_offset_R = clipPos.x + oneTap.x;\nfloat clipPos_offset_U = clipPos.y - oneTap.y;\nfloat clipPos_offset_D = clipPos.y + oneTap.y;\nfloat block0, block1, block2, block3, block4, block5, block6, block7, block8;\nif (cc_shadowLPNNInfo.y > 0.000001) {\nblock0 = step(offsetDepth, dot(texture(cc_shadowMap, vec2(clipPos_offset_L, clipPos_offset_U)), vec4(1.0, 1.0 / 255.0, 1.0 / 65025.0, 1.0 / 16581375.0)));\nblock1 = step(offsetDepth, dot(texture(cc_shadowMap, vec2(clipPos.x, clipPos_offset_U)), vec4(1.0, 1.0 / 255.0, 1.0 / 65025.0, 1.0 / 16581375.0)));\nblock2 = step(offsetDepth, dot(texture(cc_shadowMap, vec2(clipPos_offset_R, clipPos_offset_U)), vec4(1.0, 1.0 / 255.0, 1.0 / 65025.0, 1.0 / 16581375.0)));\nblock3 = step(offsetDepth, dot(texture(cc_shadowMap, vec2(clipPos_offset_L, clipPos.y)), vec4(1.0, 1.0 / 255.0, 1.0 / 65025.0, 1.0 / 16581375.0)));\nblock4 = step(offsetDepth, dot(texture(cc_shadowMap, vec2(clipPos.x, clipPos.y)), vec4(1.0, 1.0 / 255.0, 1.0 / 65025.0, 1.0 / 16581375.0)));\nblock5 = step(offsetDepth, dot(texture(cc_shadowMap, vec2(clipPos_offset_R, clipPos.y)), vec4(1.0, 1.0 / 255.0, 1.0 / 65025.0, 1.0 / 16581375.0)));\nblock6 = step(offsetDepth, dot(texture(cc_shadowMap, vec2(clipPos_offset_L, clipPos_offset_D)), vec4(1.0, 1.0 / 255.0, 1.0 / 65025.0, 1.0 / 16581375.0)));\nblock7 = step(offsetDepth, dot(texture(cc_shadowMap, vec2(clipPos.x, clipPos_offset_D)), vec4(1.0, 1.0 / 255.0, 1.0 / 65025.0, 1.0 / 16581375.0)));\nblock8 = step(offsetDepth, dot(texture(cc_shadowMap, vec2(clipPos_offset_R, clipPos_offset_D)), vec4(1.0, 1.0 / 255.0, 1.0 / 65025.0, 1.0 / 16581375.0)));\n} else {\nblock0 = step(offsetDepth, texture(cc_shadowMap, vec2(clipPos_offset_L, clipPos_offset_U)).x);\nblock1 = step(offsetDepth, texture(cc_shadowMap, vec2(clipPos.x, clipPos_offset_U)).x);\nblock2 = step(offsetDepth, texture(cc_shadowMap, vec2(clipPos_offset_R, clipPos_offset_U)).x);\nblock3 = step(offsetDepth, texture(cc_shadowMap, vec2(clipPos_offset_L, clipPos.y)).x);\nblock4 = step(offsetDepth, texture(cc_shadowMap, vec2(clipPos.x, clipPos.y)).x);\nblock5 = step(offsetDepth, texture(cc_shadowMap, vec2(clipPos_offset_R, clipPos.y)).x);\nblock6 = step(offsetDepth, texture(cc_shadowMap, vec2(clipPos_offset_L, clipPos_offset_D)).x);\nblock7 = step(offsetDepth, texture(cc_shadowMap, vec2(clipPos.x, clipPos_offset_D)).x);\nblock8 = step(offsetDepth, texture(cc_shadowMap, vec2(clipPos_offset_R, clipPos_offset_D)).x);\n}\nfloat coefX = mod(clipPos.x, oneTap.x) * mapSize.x;\nfloat coefY = mod(clipPos.y, oneTap.y) * mapSize.y;\nfloat shadow = 0.0;\nfloat resultX = mix(block0, block1, coefX);\nfloat resultY = mix(block3, block4, coefX);\nshadow += mix(resultX , resultY, coefY);\nresultX = mix(block1, block2, coefX);\nresultY = mix(block4, block5, coefX);\nshadow += mix(resultX , resultY, coefY);\nresultX = mix(block3, block4, coefX);\nresultY = mix(block6, block7, coefX);\nshadow += mix(resultX, resultY, coefY);\nresultX = mix(block4, block5, coefX);\nresultY = mix(block7, block8, coefX);\nshadow += mix(resultX, resultY, coefY);\nreturn shadow * 0.25;\n}\nfloat CCGetSpotLightShadowFactorHard (vec4 shadowPos, vec3 worldPos) {\nvec4 clipPosNew = ApplyShadowDepthBias_Perspective(shadowPos, cc_shadowWHPBInfo.w);\nvec3 clipPos = clipPosNew.xyz / clipPosNew.w * 0.5 + 0.5;\nif (clipPos.x < 0.0 || clipPos.x > 1.0 ||\nclipPos.y < 0.0 || clipPos.y > 1.0 ||\nclipPos.z < 0.0 || clipPos.z > 1.0) { return 1.0; }\nclipPos.xy = cc_cameraPos.w == 1.0 ? vec2(clipPos.xy.x, 1.0 - clipPos.xy.y) : clipPos.xy;\nfloat shadow = 0.0;\nfloat closestDepth = 0.0;\nfloat depth = clipPos.z;\nif (cc_shadowLPNNInfo.y > 0.000001) {\nclosestDepth = dot(texture(cc_spotLightingMap, clipPos.xy), vec4(1.0, 1.0 / 255.0, 1.0 / 65025.0, 1.0 / 16581375.0));\n} else {\nclosestDepth = texture(cc_spotLightingMap, clipPos.xy).x;\n}\nshadow = step(depth, closestDepth);\nreturn shadow;\n}\nfloat CCGetSpotLightShadowFactorSoft (vec4 shadowPos, vec3 worldPos) {\nvec4 clipPosNew = ApplyShadowDepthBias_Perspective(shadowPos, cc_shadowWHPBInfo.w);\nvec3 clipPos = clipPosNew.xyz / clipPosNew.w * 0.5 + 0.5;\nif (clipPos.x < 0.0 || clipPos.x > 1.0 ||\nclipPos.y < 0.0 || clipPos.y > 1.0 ||\nclipPos.z < 0.0 || clipPos.z > 1.0) { return 1.0; }\nclipPos.xy = cc_cameraPos.w == 1.0 ? vec2(clipPos.xy.x, 1.0 - clipPos.xy.y) : clipPos.xy;\nfloat depth = 0.0;\nif (cc_shadowNFLSInfo.z > 0.000001) {\ndepth = CCGetLinearDepth(worldPos);\n} else {\ndepth = clipPos.z;\n}\nfloat bias = cc_shadowWHPBInfo.w;\nvec2 oneTap = 1.0 / cc_shadowWHPBInfo.xy;\nvec2 clipPos_offset = clipPos.xy + oneTap;\nfloat block0, block1, block2, block3;\nif (cc_shadowLPNNInfo.y > 0.000001) {\nblock0 = step(depth, dot(texture(cc_spotLightingMap, vec2(clipPos.x, clipPos.y)), vec4(1.0, 1.0 / 255.0, 1.0 / 65025.0, 1.0 / 16581375.0)));\nblock1 = step(depth, dot(texture(cc_spotLightingMap, vec2(clipPos_offset.x, clipPos.y)), vec4(1.0, 1.0 / 255.0, 1.0 / 65025.0, 1.0 / 16581375.0)));\nblock2 = step(depth, dot(texture(cc_spotLightingMap, vec2(clipPos.x, clipPos_offset.y)), vec4(1.0, 1.0 / 255.0, 1.0 / 65025.0, 1.0 / 16581375.0)));\nblock3 = step(depth, dot(texture(cc_spotLightingMap, vec2(clipPos_offset.x, clipPos_offset.y)), vec4(1.0, 1.0 / 255.0, 1.0 / 65025.0, 1.0 / 16581375.0)));\n} else {\nblock0 = step(depth, texture(cc_spotLightingMap, vec2(clipPos.x, clipPos.y)).x);\nblock1 = step(depth, texture(cc_spotLightingMap, vec2(clipPos_offset.x, clipPos.y)).x);\nblock2 = step(depth, texture(cc_spotLightingMap, vec2(clipPos.x, clipPos_offset.y)).x);\nblock3 = step(depth, texture(cc_spotLightingMap, vec2(clipPos_offset.x, clipPos_offset.y)).x);\n}\nfloat coefX = mod(clipPos.x, oneTap.x) * cc_shadowWHPBInfo.x;\nfloat resultX = mix(block0, block1, coefX);\nfloat resultY = mix(block2, block3, coefX);\nfloat coefY = mod(clipPos.y, oneTap.y) * cc_shadowWHPBInfo.y;\nreturn mix(resultX, resultY, coefY);\n}\nfloat CCGetSpotLightShadowFactorSoft2X (vec4 shadowPos, vec3 worldPos) {\nvec4 clipPosNew = ApplyShadowDepthBias_Perspective(shadowPos, cc_shadowWHPBInfo.w);\nvec3 clipPos = clipPosNew.xyz / clipPosNew.w * 0.5 + 0.5;\nif (clipPos.x < 0.0 || clipPos.x > 1.0 ||\nclipPos.y < 0.0 || clipPos.y > 1.0 ||\nclipPos.z < 0.0 || clipPos.z > 1.0) { return 1.0; }\nclipPos.xy = cc_cameraPos.w == 1.0 ? vec2(clipPos.xy.x, 1.0 - clipPos.xy.y) : clipPos.xy;\nfloat depth = 0.0;\nif (cc_shadowNFLSInfo.z > 0.000001) {\ndepth = CCGetLinearDepth(worldPos);\n} else {\ndepth = clipPos.z;\n}\nfloat bias = cc_shadowWHPBInfo.w;\nvec2 mapSize = cc_shadowWHPBInfo.xy;\nvec2 oneTap = 1.0 / mapSize;\nfloat clipPos_offset_L = clipPos.x - oneTap.x;\nfloat clipPos_offset_R = clipPos.x + oneTap.x;\nfloat clipPos_offset_U = clipPos.y - oneTap.y;\nfloat clipPos_offset_D = clipPos.y + oneTap.y;\nfloat block0, block1, block2, block3, block4, block5, block6, block7, block8;\nif (cc_shadowLPNNInfo.y > 0.000001) {\nblock0 = step(depth, dot(texture(cc_spotLightingMap, vec2(clipPos_offset_L, clipPos_offset_U)), vec4(1.0, 1.0 / 255.0, 1.0 / 65025.0, 1.0 / 16581375.0)));\nblock1 = step(depth, dot(texture(cc_spotLightingMap, vec2(clipPos.x, clipPos_offset_U)), vec4(1.0, 1.0 / 255.0, 1.0 / 65025.0, 1.0 / 16581375.0)));\nblock2 = step(depth, dot(texture(cc_spotLightingMap, vec2(clipPos_offset_R, clipPos_offset_U)), vec4(1.0, 1.0 / 255.0, 1.0 / 65025.0, 1.0 / 16581375.0)));\nblock3 = step(depth, dot(texture(cc_spotLightingMap, vec2(clipPos_offset_L, clipPos.y)), vec4(1.0, 1.0 / 255.0, 1.0 / 65025.0, 1.0 / 16581375.0)));\nblock4 = step(depth, dot(texture(cc_spotLightingMap, vec2(clipPos.x, clipPos.y)), vec4(1.0, 1.0 / 255.0, 1.0 / 65025.0, 1.0 / 16581375.0)));\nblock5 = step(depth, dot(texture(cc_spotLightingMap, vec2(clipPos_offset_R, clipPos.y)), vec4(1.0, 1.0 / 255.0, 1.0 / 65025.0, 1.0 / 16581375.0)));\nblock6 = step(depth, dot(texture(cc_spotLightingMap, vec2(clipPos_offset_L, clipPos_offset_D)), vec4(1.0, 1.0 / 255.0, 1.0 / 65025.0, 1.0 / 16581375.0)));\nblock7 = step(depth, dot(texture(cc_spotLightingMap, vec2(clipPos.x, clipPos_offset_D)), vec4(1.0, 1.0 / 255.0, 1.0 / 65025.0, 1.0 / 16581375.0)));\nblock8 = step(depth, dot(texture(cc_spotLightingMap, vec2(clipPos_offset_R, clipPos_offset_D)), vec4(1.0, 1.0 / 255.0, 1.0 / 65025.0, 1.0 / 16581375.0)));\n} else {\nblock0 = step(depth, texture(cc_spotLightingMap, vec2(clipPos_offset_L, clipPos_offset_U)).x);\nblock1 = step(depth, texture(cc_spotLightingMap, vec2(clipPos.x, clipPos_offset_U)).x);\nblock2 = step(depth, texture(cc_spotLightingMap, vec2(clipPos_offset_R, clipPos_offset_U)).x);\nblock3 = step(depth, texture(cc_spotLightingMap, vec2(clipPos_offset_L, clipPos.y)).x);\nblock4 = step(depth, texture(cc_spotLightingMap, vec2(clipPos.x, clipPos.y)).x);\nblock5 = step(depth, texture(cc_spotLightingMap, vec2(clipPos_offset_R, clipPos.y)).x);\nblock6 = step(depth, texture(cc_spotLightingMap, vec2(clipPos_offset_L, clipPos_offset_D)).x);\nblock7 = step(depth, texture(cc_spotLightingMap, vec2(clipPos.x, clipPos_offset_D)).x);\nblock8 = step(depth, texture(cc_spotLightingMap, vec2(clipPos_offset_R, clipPos_offset_D)).x);\n}\nfloat coefX = mod(clipPos.x, oneTap.x) * mapSize.x;\nfloat coefY = mod(clipPos.y, oneTap.y) * mapSize.y;\nfloat shadow = 0.0;\nfloat resultX = mix(block0, block1, coefX);\nfloat resultY = mix(block3, block4, coefX);\nshadow += mix(resultX , resultY, coefY);\nresultX = mix(block1, block2, coefX);\nresultY = mix(block4, block5, coefX);\nshadow += mix(resultX , resultY, coefY);\nresultX = mix(block3, block4, coefX);\nresultY = mix(block6, block7, coefX);\nshadow += mix(resultX, resultY, coefY);\nresultX = mix(block4, block5, coefX);\nresultY = mix(block7, block8, coefX);\nshadow += mix(resultX, resultY, coefY);\nreturn shadow * 0.25;\n}\n#endif\n#if CC_USE_IBL\nlayout(set = 0, binding = 4) uniform samplerCube cc_environment;\nvec4 fragTextureLod (sampler2D tex, vec2 coord, float lod) {\nreturn textureLod(tex, coord, lod);\n}\nvec4 fragTextureLod (samplerCube tex, vec3 coord, float lod) {\nreturn textureLod(tex, coord, lod);\n}\nvec3 unpackRGBE (vec4 rgbe) {\nreturn rgbe.rgb * pow(1.1, rgbe.a * 255.0 - 128.0);\n}\n#if CC_USE_DIFFUSEMAP\nlayout(set = 0, binding = 6) uniform samplerCube cc_diffuseMap;\n#endif\n#endif\nfloat GGXMobile (float roughness, float NoH, vec3 H, vec3 N) {\nvec3 NxH = cross(N, H);\nfloat OneMinusNoHSqr = dot(NxH, NxH);\nfloat a = roughness * roughness;\nfloat n = NoH * a;\nfloat p = a / (OneMinusNoHSqr + n * n);\nreturn p * p;\n}\nfloat CalcSpecular (float roughness, float NoH, vec3 H, vec3 N) {\nreturn (roughness * 0.25 + 0.25) * GGXMobile(roughness, NoH, H, N);\n}\nvec3 BRDFApprox (vec3 specular, float roughness, float NoV) {\nconst vec4 c0 = vec4(-1.0, -0.0275, -0.572, 0.022);\nconst vec4 c1 = vec4(1.0, 0.0425, 1.04, -0.04);\nvec4 r = roughness * c0 + c1;\nfloat a004 = min(r.x * r.x, exp2(-9.28 * NoV)) * r.x + r.y;\nvec2 AB = vec2(-1.04, 1.04) * a004 + r.zw;\nAB.y *= clamp(50.0 * specular.g, 0.0, 1.0);\nreturn specular * AB.x + AB.y;\n}\n#if USE_REFLECTION_DENOISE\nvec3 GetEnvReflectionWithMipFiltering(vec3 R, float roughness, float mipCount, float denoiseIntensity) {\n#if CC_USE_IBL\nfloat mip = roughness * mipCount;\nfloat delta = (dot(dFdx(R), dFdy(R))) * 1000.0;\nfloat mipBias = mix(0.0, 5.0, clamp(delta, 0.0, 1.0));\nvec4 biased = fragTextureLod(cc_environment, R, mip + mipBias);\nvec4 filtered = texture(cc_environment, R);\n#if CC_USE_IBL == 2\nbiased.rgb = unpackRGBE(biased);\nfiltered.rgb = unpackRGBE(filtered);\n#else\nbiased.rgb = SRGBToLinear(biased.rgb);\nfiltered.rgb = SRGBToLinear(filtered.rgb);\n#endif\nreturn mix(biased.rgb, filtered.rgb, denoiseIntensity);\n#else\nreturn vec3(0.0, 0.0, 0.0);\n#endif\n}\n#endif\nstruct StandardSurface {\nvec4 albedo;\nvec3 position;\nvec3 normal;\nvec3 emissive;\nvec3 lightmap;\nfloat lightmap_test;\nfloat roughness;\nfloat metallic;\nfloat occlusion;\n};\nvec4 CCStandardShadingBase (StandardSurface s, vec4 shadowPos) {\nvec3 diffuse = s.albedo.rgb * (1.0 - s.metallic);\nvec3 specular = mix(vec3(0.04), s.albedo.rgb, s.metallic);\nvec3 N = normalize(s.normal);\nvec3 V = normalize(cc_cameraPos.xyz - s.position);\nfloat NV = max(abs(dot(N, V)), 0.0);\nspecular = BRDFApprox(specular, s.roughness, NV);\nvec3 L = normalize(-cc_mainLitDir.xyz);\nvec3 H = normalize(L + V);\nfloat NH = max(dot(N, H), 0.0);\nfloat NL = max(dot(N, L), 0.0);\nvec3 finalColor = NL * cc_mainLitColor.rgb * cc_mainLitColor.w;\nvec3 diffuseContrib = diffuse;\n#if USE_LIGHTMAP && !USE_BATCHING && !CC_FORWARD_ADD\nif (s.lightmap_test > 0.0001) {\nfinalColor = s.lightmap.rgb;\n}\n#else\ndiffuseContrib /= 3.14159265359;\n#endif\nvec3 specularContrib = specular * CalcSpecular(s.roughness, NH, H, N);\nvec3 dirlightContrib = (diffuseContrib + specularContrib);\nfloat shadow = 1.0;\n#if CC_RECEIVE_SHADOW && CC_ENABLE_DIR_SHADOW\nif (NL > 0.0) {\n{\nvec4 pos = ApplyShadowDepthBias_FaceNormal(shadowPos, N);\nfloat pcf = cc_shadowWHPBInfo.z;\nif (pcf > 1.9) shadow = CCGetShadowFactorSoft2X(pos);\nelse if (pcf > 0.9) shadow = CCGetShadowFactorSoft(pos);\nelse shadow = CCGetShadowFactorHard(pos);\nshadow = mix(shadow, 1.0, cc_shadowNFLSInfo.w);\n}\n}\n#endif\ndirlightContrib *= shadow;\nfinalColor *= dirlightContrib;\nfloat fAmb = 0.5 - N.y * 0.5;\nvec3 ambDiff = mix(cc_ambientSky.rgb, cc_ambientGround.rgb, fAmb);\n#if CC_USE_IBL\n#if CC_USE_DIFFUSEMAP\nvec4 diffuseMap = texture(cc_diffuseMap, N);\n#if CC_USE_DIFFUSEMAP == 2\nambDiff = unpackRGBE(diffuseMap);\n#else\nambDiff = SRGBToLinear(diffuseMap.rgb);\n#endif\n#endif\nvec3 R = normalize(reflect(-V, N));\n#if USE_REFLECTION_DENOISE\nvec3 env = GetEnvReflectionWithMipFiltering(R, s.roughness, cc_ambientGround.w, 0.6);\n#else\nvec4 envmap = fragTextureLod(cc_environment, R, s.roughness * cc_ambientGround.w);\n#if CC_USE_IBL == 2\nvec3 env = unpackRGBE(envmap);\n#else\nvec3 env = SRGBToLinear(envmap.rgb);\n#endif\n#endif\nfinalColor += env * cc_ambientSky.w * specular * s.occlusion;\n#endif\nfinalColor += ambDiff.rgb * cc_ambientSky.w * diffuse * s.occlusion;\nfinalColor += s.emissive;\nreturn vec4(finalColor, s.albedo.a);\n}\nvec3 ACESToneMap (vec3 color) {\ncolor = min(color, vec3(8.0));\nconst float A = 2.51;\nconst float B = 0.03;\nconst float C = 2.43;\nconst float D = 0.59;\nconst float E = 0.14;\nreturn (color * (A * color + B)) / (color * (C * color + D) + E);\n}\nvec4 CCFragOutput (vec4 color) {\n#if CC_USE_HDR\ncolor.rgb = ACESToneMap(color.rgb);\n#endif\ncolor.rgb = sqrt(color.rgb);\nreturn color;\n}\nfloat LinearFog(vec4 pos) {\nvec4 wPos = pos;\nfloat cam_dis = distance(cc_cameraPos, wPos);\nfloat fogStart = cc_fogBase.x;\nfloat fogEnd = cc_fogBase.y;\nreturn clamp((fogEnd - cam_dis) / (fogEnd - fogStart), 0., 1.);\n}\nfloat ExpFog(vec4 pos) {\nvec4 wPos = pos;\nfloat fogAtten = cc_fogAdd.z;\nfloat fogStart = cc_fogBase.x;\nfloat fogDensity = cc_fogBase.z;\nfloat cam_dis = max(distance(cc_cameraPos, wPos) - fogStart, 0.0) / fogAtten * 4.;\nfloat f = exp(-cam_dis * fogDensity);\nreturn f;\n}\nfloat ExpSquaredFog(vec4 pos) {\nvec4 wPos = pos;\nfloat fogAtten = cc_fogAdd.z;\nfloat fogStart = cc_fogBase.x;\nfloat fogDensity = cc_fogBase.z;\nfloat cam_dis = max(distance(cc_cameraPos, wPos) - fogStart, 0.0) / fogAtten * 4.;\nfloat f = exp(-cam_dis * cam_dis * fogDensity * fogDensity);\nreturn f;\n}\nfloat LayeredFog(vec4 pos) {\nvec4 wPos = pos;\nfloat fogAtten = cc_fogAdd.z;\nfloat _FogTop = cc_fogAdd.x;\nfloat _FogRange = cc_fogAdd.y;\nvec3 camWorldProj = cc_cameraPos.xyz;\ncamWorldProj.y = 0.;\nvec3 worldPosProj = wPos.xyz;\nworldPosProj.y = 0.;\nfloat fDeltaD = distance(worldPosProj, camWorldProj) / fogAtten * 2.0;\nfloat fDeltaY, fDensityIntegral;\nif (cc_cameraPos.y > _FogTop) {\nif (wPos.y < _FogTop) {\nfDeltaY = (_FogTop - wPos.y) / _FogRange * 2.0;\nfDensityIntegral = fDeltaY * fDeltaY * 0.5;\n} else {\nfDeltaY = 0.;\nfDensityIntegral = 0.;\n}\n} else {\nif (wPos.y < _FogTop) {\nfloat fDeltaA = (_FogTop - cc_cameraPos.y) / _FogRange * 2.;\nfloat fDeltaB = (_FogTop - wPos.y) / _FogRange * 2.;\nfDeltaY = abs(fDeltaA - fDeltaB);\nfDensityIntegral = abs((fDeltaA * fDeltaA * 0.5) - (fDeltaB * fDeltaB * 0.5));\n} else {\nfDeltaY = abs(_FogTop - cc_cameraPos.y) / _FogRange * 2.;\nfDensityIntegral = abs(fDeltaY * fDeltaY * 0.5);\n}\n}\nfloat fDensity;\nif (fDeltaY != 0.) {\nfDensity = (sqrt(1.0 + ((fDeltaD / fDeltaY) * (fDeltaD / fDeltaY)))) * fDensityIntegral;\n} else {\nfDensity = 0.;\n}\nfloat f = exp(-fDensity);\nreturn f;\n}\nvoid CC_TRANSFER_FOG_BASE(vec4 pos, out float factor)\n{\n#if CC_USE_FOG == 0\nfactor = LinearFog(pos);\n#elif CC_USE_FOG == 1\nfactor = ExpFog(pos);\n#elif CC_USE_FOG == 2\nfactor = ExpSquaredFog(pos);\n#elif CC_USE_FOG == 3\nfactor = LayeredFog(pos);\n#else\nfactor = 1.0;\n#endif\n}\nvoid CC_APPLY_FOG_BASE(inout vec4 color, float factor) {\ncolor = vec4(mix(cc_fogColor.rgb, color.rgb, factor), color.a);\n}\n#if !CC_USE_ACCURATE_FOG\nlayout(location = 0) in float v_fog_factor;\n#endif\nvoid CC_APPLY_FOG(inout vec4 color) {\n#if !CC_USE_ACCURATE_FOG\nCC_APPLY_FOG_BASE(color, v_fog_factor);\n#endif\n}\nvoid CC_APPLY_FOG(inout vec4 color, vec3 worldPos) {\n#if CC_USE_ACCURATE_FOG\nfloat factor;\nCC_TRANSFER_FOG_BASE(vec4(worldPos, 1.0), factor);\n#else\nfloat factor = v_fog_factor;\n#endif\nCC_APPLY_FOG_BASE(color, factor);\n}\nlayout(location = 1) in highp vec4 v_shadowPos;\n#if USE_LIGHTMAP && !USE_BATCHING && !CC_FORWARD_ADD\nlayout(location = 13) in vec3 v_luv;\nlayout(set = 2, binding = 10) uniform sampler2D cc_lightingMap;\nvec3 UnpackLightingmap(vec4 color) {\nvec3 c;\nfloat e = 1.0 + color.a * (8.0 - 1.0);\nc.r = color.r * e;\nc.g = color.g * e;\nc.b = color.b * e;\nreturn c;\n}\n#endif\nlayout(location = 2) in highp vec3 v_position;\nlayout(location = 3) in mediump vec3 v_normal;\n#if USE_NORMALMAP\nlayout(location = 4) in mediump vec3 v_tangent;\nlayout(location = 5) in mediump vec3 v_binormal;\n#endif\nlayout(location = 6) in mediump vec2 uvw;\nlayout(location = 7) in mediump vec2 uv0;\nlayout(location = 8) in mediump vec2 uv1;\nlayout(location = 9) in mediump vec2 uv2;\nlayout(location = 10) in mediump vec2 uv3;\nlayout(location = 12) in mediump vec3 diffuse;\nlayout(location = 11) in mediump vec3 luv;\nlayout(set = 1, binding = 1) uniform PbrParams {\nvec4 metallic;\nvec4 roughness;\n};\nlayout(set = 1, binding = 2) uniform sampler2D weightMap;\nlayout(set = 1, binding = 3) uniform sampler2D detailMap0;\nlayout(set = 1, binding = 4) uniform sampler2D detailMap1;\nlayout(set = 1, binding = 5) uniform sampler2D detailMap2;\nlayout(set = 1, binding = 6) uniform sampler2D detailMap3;\nlayout(set = 1, binding = 7) uniform sampler2D normalMap0;\nlayout(set = 1, binding = 8) uniform sampler2D normalMap1;\nlayout(set = 1, binding = 9) uniform sampler2D normalMap2;\nlayout(set = 1, binding = 10) uniform sampler2D normalMap3;\nlayout(set = 1, binding = 11) uniform sampler2D lightMap;\nvoid surf (out StandardSurface s) {\n#if LAYERS > 1\nvec4 w = texture(weightMap, uvw);\n#endif\nvec4 baseColor = vec4(0, 0, 0, 0);\n#if LAYERS == 1\nbaseColor = texture(detailMap0, uv0);\n#elif LAYERS == 2\nbaseColor += texture(detailMap0, uv0) * w.r;\nbaseColor += texture(detailMap1, uv1) * w.g;\n#elif LAYERS == 3\nbaseColor += texture(detailMap0, uv0) * w.r;\nbaseColor += texture(detailMap1, uv1) * w.g;\nbaseColor += texture(detailMap2, uv2) * w.b;\n#elif LAYERS == 4\nbaseColor += texture(detailMap0, uv0) * w.r;\nbaseColor += texture(detailMap1, uv1) * w.g;\nbaseColor += texture(detailMap2, uv2) * w.b;\nbaseColor += texture(detailMap3, uv3) * w.a;\n#else\nbaseColor = texture(detailMap0, uv0);\n#endif\ns.position = v_position;\n#if USE_NORMALMAP\nvec4 baseNormal = vec4(0, 0, 0, 0);\n#if LAYERS == 1\nbaseNormal = texture(normalMap0, uv0);\n#elif LAYERS == 2\nbaseNormal += texture(normalMap0, uv0) * w.r;\nbaseNormal += texture(normalMap1, uv1) * w.g;\n#elif LAYERS == 3\nbaseNormal += texture(normalMap0, uv0) * w.r;\nbaseNormal += texture(normalMap1, uv1) * w.g;\nbaseNormal += texture(normalMap2, uv2) * w.b;\n#elif LAYERS == 4\nbaseNormal += texture(normalMap0, uv0) * w.r;\nbaseNormal += texture(normalMap1, uv1) * w.g;\nbaseNormal += texture(normalMap2, uv2) * w.b;\nbaseNormal += texture(normalMap3, uv3) * w.a;\n#else\nbaseNormal = texture(normalMap0, uv0);\n#endif\nvec3 nmmp = baseNormal.xyz - vec3(0.5);\ns.normal =\nnmmp.x * normalize(v_tangent) +\nnmmp.y * normalize(v_binormal) +\nnmmp.z * normalize(v_normal);\n#else\ns.normal = v_normal;\n#endif\ns.albedo = vec4(SRGBToLinear(baseColor.rgb), 1.0);\ns.occlusion = 1.0;\n#if USE_PBR\ns.roughness = 0.0;\n#if LAYERS == 1\ns.roughness = roughness.x;\n#elif LAYERS == 2\ns.roughness += roughness.x * w.r;\ns.roughness += roughness.y * w.g;\n#elif LAYERS == 3\ns.roughness += roughness.x * w.r;\ns.roughness += roughness.y * w.g;\ns.roughness += roughness.z * w.b;\n#elif LAYERS == 4\ns.roughness += roughness.x * w.r;\ns.roughness += roughness.y * w.g;\ns.roughness += roughness.z * w.b;\ns.roughness += roughness.w * w.a;\n#else\ns.roughness = 1.0;\n#endif\ns.metallic = 0.0;\n#if LAYERS == 1\ns.metallic = metallic.x;\n#elif LAYERS == 2\ns.metallic += metallic.x * w.r;\ns.metallic += metallic.y * w.g;\n#elif LAYERS == 3\ns.metallic += metallic.x * w.r;\ns.metallic += metallic.y * w.g;\ns.metallic += metallic.z * w.b;\n#elif LAYERS == 4\ns.metallic += metallic.x * w.r;\ns.metallic += metallic.y * w.g;\ns.metallic += metallic.z * w.b;\ns.metallic += metallic.w * w.a;\n#else\ns.metallic = 0.0;\n#endif\n#else\ns.roughness = 1.0;\ns.metallic = 0.0;\n#endif\ns.emissive = vec3(0.0, 0.0, 0.0);\n#if USE_LIGHTMAP && !USE_BATCHING && !CC_FORWARD_ADD\nvec4 lightColor = texture(lightMap, luv.xy);\ns.lightmap = UnpackLightingmap(lightColor);\ns.lightmap_test = luv.z;\n#endif\n}\n#if CC_FORWARD_ADD\n#if CC_PIPELINE_TYPE == 0\n# define LIGHTS_PER_PASS 1\n#else\n# define LIGHTS_PER_PASS 10\n#endif\n#if CC_ENABLE_CLUSTERED_LIGHT_CULLING == 0\nlayout(set = 2, binding = 1) uniform CCForwardLight {\nhighp vec4 cc_lightPos[LIGHTS_PER_PASS];\nvec4 cc_lightColor[LIGHTS_PER_PASS];\nvec4 cc_lightSizeRangeAngle[LIGHTS_PER_PASS];\nvec4 cc_lightDir[LIGHTS_PER_PASS];\n};\n#endif\nfloat SmoothDistAtt (float distSqr, float invSqrAttRadius) {\nfloat factor = distSqr * invSqrAttRadius;\nfloat smoothFactor = clamp(1.0 - factor * factor, 0.0, 1.0);\nreturn smoothFactor * smoothFactor;\n}\nfloat GetDistAtt (float distSqr, float invSqrAttRadius) {\nfloat attenuation = 1.0 / max(distSqr, 0.01*0.01);\nattenuation *= SmoothDistAtt(distSqr , invSqrAttRadius);\nreturn attenuation;\n}\nfloat GetAngleAtt (vec3 L, vec3 litDir, float litAngleScale, float litAngleOffset) {\nfloat cd = dot(litDir, L);\nfloat attenuation = clamp(cd * litAngleScale + litAngleOffset, 0.0, 1.0);\nreturn (attenuation * attenuation);\n}\n#if CC_ENABLE_CLUSTERED_LIGHT_CULLING == 0\nvec4 CCStandardShadingAdditive (StandardSurface s, vec4 shadowPos) {\nvec3 diffuse = s.albedo.rgb * (1.0 - s.metallic);\nvec3 specular = mix(vec3(0.04), s.albedo.rgb, s.metallic);\nvec3 diffuseContrib = diffuse / 3.14159265359;\nvec3 N = normalize(s.normal);\nvec3 V = normalize(cc_cameraPos.xyz - s.position);\nfloat NV = max(abs(dot(N, V)), 0.0);\nspecular = BRDFApprox(specular, s.roughness, NV);\nvec3 finalColor = vec3(0.0);\nint numLights = CC_PIPELINE_TYPE == 0 ? LIGHTS_PER_PASS : int(cc_lightDir[0].w);\nfor (int i = 0; i < LIGHTS_PER_PASS; i++) {\nif (i >= numLights) break;\nvec3 SLU = cc_lightPos[i].xyz - s.position;\nvec3 SL = normalize(SLU);\nvec3 SH = normalize(SL + V);\nfloat SNL = max(dot(N, SL), 0.0);\nfloat SNH = max(dot(N, SH), 0.0);\nfloat distSqr = dot(SLU, SLU);\nfloat litRadius = cc_lightSizeRangeAngle[i].x;\nfloat litRadiusSqr = litRadius * litRadius;\nfloat illum = 3.14159265359 * (litRadiusSqr / max(litRadiusSqr , distSqr));\nfloat attRadiusSqrInv = 1.0 / max(cc_lightSizeRangeAngle[i].y, 0.01);\nattRadiusSqrInv *= attRadiusSqrInv;\nfloat att = GetDistAtt(distSqr, attRadiusSqrInv);\nvec3 lspec = specular * CalcSpecular(s.roughness, SNH, SH, N);\nif (cc_lightPos[i].w > 0.0) {\nfloat cosInner = max(dot(-cc_lightDir[i].xyz, SL), 0.01);\nfloat cosOuter = cc_lightSizeRangeAngle[i].z;\nfloat litAngleScale = 1.0 / max(0.001, cosInner - cosOuter);\nfloat litAngleOffset = -cosOuter * litAngleScale;\natt *= GetAngleAtt(SL, -cc_lightDir[i].xyz, litAngleScale, litAngleOffset);\n}\nvec3 lightColor = cc_lightColor[i].rgb;\nfloat shadow = 1.0;\n#if CC_RECEIVE_SHADOW\nif (cc_lightPos[i].w > 0.0 && cc_lightSizeRangeAngle[i].w > 0.0) {\n{\nfloat pcf = cc_shadowWHPBInfo.z;\nif (pcf > 1.9) shadow = CCGetSpotLightShadowFactorSoft2X(shadowPos, s.position);\nelse if (pcf > 0.9) shadow = CCGetSpotLightShadowFactorSoft(shadowPos, s.position);\nelse shadow = CCGetSpotLightShadowFactorHard(shadowPos, s.position);\n}\n}\n#endif\nlightColor *= shadow;\nfinalColor += SNL * lightColor * cc_lightColor[i].w * illum * att * (diffuseContrib + lspec);\n}\nreturn vec4(finalColor, 0.0);\n}\n#endif\n#if CC_ENABLE_CLUSTERED_LIGHT_CULLING == 1\nlayout(set = 1, binding = 12) readonly buffer b_ccLightsBuffer { vec4 b_ccLights[]; };\nlayout(set = 1, binding = 13) readonly buffer b_clusterLightIndicesBuffer { uint b_clusterLightIndices[]; };\nlayout(set = 1, binding = 14) readonly buffer b_clusterLightGridBuffer { uvec4 b_clusterLightGrid[]; };\nstruct CCLight\n{\nvec4 cc_lightPos;\nvec4 cc_lightColor;\nvec4 cc_lightSizeRangeAngle;\nvec4 cc_lightDir;\n};\nstruct Cluster\n{\nvec3 minBounds;\nvec3 maxBounds;\n};\nstruct LightGrid\n{\nuint offset;\nuint ccLights;\n};\nCCLight getCCLight(uint i)\n{\nCCLight light;\nlight.cc_lightPos = b_ccLights[4u * i + 0u];\nlight.cc_lightColor = b_ccLights[4u * i + 1u];\nlight.cc_lightSizeRangeAngle = b_ccLights[4u * i + 2u];\nlight.cc_lightDir = b_ccLights[4u * i + 3u];\nreturn light;\n}\nLightGrid getLightGrid(uint cluster)\n{\nuvec4 gridvec = b_clusterLightGrid[cluster];\nLightGrid grid;\ngrid.offset = gridvec.x;\ngrid.ccLights = gridvec.y;\nreturn grid;\n}\nuint getGridLightIndex(uint start, uint offset)\n{\nreturn b_clusterLightIndices[start + offset];\n}\nuint getClusterZIndex(vec4 worldPos)\n{\nfloat scale = float(24) / log(cc_nearFar.y / cc_nearFar.x);\nfloat bias = -(float(24) * log(cc_nearFar.x) / log(cc_nearFar.y / cc_nearFar.x));\nfloat eyeDepth = -(cc_matView * worldPos).z;\nuint zIndex = uint(max(log(eyeDepth) * scale + bias, 0.0));\nreturn zIndex;\n}\nuint getClusterIndex(vec4 fragCoord, vec4 worldPos)\n{\nuint zIndex = getClusterZIndex(worldPos);\nfloat clusterSizeX = ceil(cc_screenSize.x / float(16));\nfloat clusterSizeY = ceil(cc_screenSize.y / float(8));\nuvec3 indices = uvec3(uvec2(fragCoord.xy / vec2(clusterSizeX, clusterSizeY)), zIndex);\nuint cluster = (16u * 8u) * indices.z + 16u * indices.y + indices.x;\nreturn cluster;\n}\nvec4 CCClusterShadingAdditive (StandardSurface s, vec4 shadowPos) {\nvec3 diffuse = s.albedo.rgb * (1.0 - s.metallic);\nvec3 specular = mix(vec3(0.04), s.albedo.rgb, s.metallic);\nvec3 diffuseContrib = diffuse / 3.14159265359;\nvec3 N = normalize(s.normal);\nvec3 V = normalize(cc_cameraPos.xyz - s.position);\nfloat NV = max(abs(dot(N, V)), 0.001);\nspecular = BRDFApprox(specular, s.roughness, NV);\nvec3 finalColor = vec3(0.0);\nuint cluster = getClusterIndex(gl_FragCoord, vec4(s.position, 1.0));\nLightGrid grid = getLightGrid(cluster);\nuint numLights = grid.ccLights;\nfor (uint i = 0u; i < 100u; i++) {\nif (i >= numLights) break;\nuint lightIndex = getGridLightIndex(grid.offset, i);\nCCLight light = getCCLight(lightIndex);\nvec3 SLU = light.cc_lightPos.xyz - s.position;\nvec3 SL = normalize(SLU);\nvec3 SH = normalize(SL + V);\nfloat SNL = max(dot(N, SL), 0.001);\nfloat SNH = max(dot(N, SH), 0.0);\nfloat distSqr = dot(SLU, SLU);\nfloat litRadius = light.cc_lightSizeRangeAngle.x;\nfloat litRadiusSqr = litRadius * litRadius;\nfloat illum = 3.14159265359 * (litRadiusSqr / max(litRadiusSqr , distSqr));\nfloat attRadiusSqrInv = 1.0 / max(light.cc_lightSizeRangeAngle.y, 0.01);\nattRadiusSqrInv *= attRadiusSqrInv;\nfloat att = GetDistAtt(distSqr, attRadiusSqrInv);\nvec3 lspec = specular * CalcSpecular(s.roughness, SNH, SH, N);\nif (light.cc_lightPos.w > 0.0) {\nfloat cosInner = max(dot(-light.cc_lightDir.xyz, SL), 0.01);\nfloat cosOuter = light.cc_lightSizeRangeAngle.z;\nfloat litAngleScale = 1.0 / max(0.001, cosInner - cosOuter);\nfloat litAngleOffset = -cosOuter * litAngleScale;\natt *= GetAngleAtt(SL, -light.cc_lightDir.xyz, litAngleScale, litAngleOffset);\n}\nvec3 lightColor = light.cc_lightColor.rgb;\nfloat shadow = 1.0;\n#if CC_RECEIVE_SHADOW\nif (light.cc_lightPos.w > 0.0) {\n{\nfloat pcf = cc_shadowWHPBInfo.z;\nif (pcf > 1.9) shadow = CCGetSpotLightShadowFactorSoft2X(shadowPos, s.position);\nelse if (pcf > 0.9) shadow = CCGetSpotLightShadowFactorSoft(shadowPos, s.position);\nelse shadow = CCGetSpotLightShadowFactorHard(shadowPos, s.position);\n}\n}\n#endif\nlightColor *= shadow;\nfinalColor += SNL * lightColor * light.cc_lightColor.w * illum * att * (diffuseContrib + lspec);\n}\nreturn vec4(finalColor, 0.0);\n}\n#endif\nlayout(location = 0) out vec4 fragColorX;\nvoid main () {\nStandardSurface s; surf(s);\n#if CC_ENABLE_CLUSTERED_LIGHT_CULLING == 1\nvec4 color = CCClusterShadingAdditive(s, v_shadowPos);\n#else\nvec4 color = CCStandardShadingAdditive(s, v_shadowPos);\n#endif\nCC_APPLY_FOG(color, s.position.xyz);\nfragColorX = CCFragOutput(color);\n}\n#elif (CC_PIPELINE_TYPE == 0 || CC_FORCE_FORWARD_SHADING)\nlayout(location = 0) out vec4 fragColorX;\nvoid main () {\nStandardSurface s; surf(s);\nvec4 color = CCStandardShadingBase(s, v_shadowPos);\nCC_APPLY_FOG(color, s.position.xyz);\nfragColorX = CCFragOutput(color);\n}\n#elif CC_PIPELINE_TYPE == 1\nlayout(location = 0) out vec4 fragColor0;\nlayout(location = 1) out vec4 fragColor1;\nlayout(location = 2) out vec4 fragColor2;\nlayout(location = 3) out vec4 fragColor3;\nvoid main () {\nStandardSurface s; surf(s);\nfragColor0 = s.albedo;\nfragColor1 = vec4(s.position, s.roughness);\nfragColor2 = vec4(s.normal, s.metallic);\nfragColor3 = vec4(s.emissive, s.occlusion);\n}\n#endif", + }, + { + "vert": "\nprecision highp float;\nlayout(set = 0, binding = 0) uniform CCGlobal {\nhighp vec4 cc_time;\nmediump vec4 cc_screenSize;\nmediump vec4 cc_nativeSize;\n};\nlayout(set = 0, binding = 1) uniform CCCamera {\nhighp mat4 cc_matView;\nhighp mat4 cc_matViewInv;\nhighp mat4 cc_matProj;\nhighp mat4 cc_matProjInv;\nhighp mat4 cc_matViewProj;\nhighp mat4 cc_matViewProjInv;\nhighp vec4 cc_cameraPos;\nmediump vec4 cc_screenScale;\nmediump vec4 cc_exposure;\nmediump vec4 cc_mainLitDir;\nmediump vec4 cc_mainLitColor;\nmediump vec4 cc_ambientSky;\nmediump vec4 cc_ambientGround;\nmediump vec4 cc_fogColor;\nmediump vec4 cc_fogBase;\nmediump vec4 cc_fogAdd;\nmediump vec4 cc_nearFar;\nmediump vec4 cc_viewPort;\n};\nlayout(set = 2, binding = 0) uniform CCLocal {\nhighp mat4 cc_matWorld;\nhighp mat4 cc_matWorldIT;\nhighp vec4 cc_lightingMapUVParam;\n};\nlayout(set = 0, binding = 2) uniform CCShadow {\nhighp mat4 cc_matLightPlaneProj;\nhighp mat4 cc_matLightView;\nhighp mat4 cc_matLightViewProj;\nhighp vec4 cc_shadowInvProjDepthInfo;\nhighp vec4 cc_shadowProjDepthInfo;\nhighp vec4 cc_shadowProjInfo;\nlowp vec4 cc_shadowNFLSInfo;\nlowp vec4 cc_shadowWHPBInfo;\nlowp vec4 cc_shadowLPNNInfo;\nlowp vec4 cc_shadowColor;\n};\nlayout(location = 0) in vec3 a_position;\nlayout(location = 1) in vec3 a_normal;\nlayout(location = 2) in vec2 a_texCoord;\nlayout(location = 0) out vec2 v_clip_depth;\nvec4 vert () {\nvec4 worldPos;\nworldPos.x = cc_matWorld[3][0] + a_position.x;\nworldPos.y = cc_matWorld[3][1] + a_position.y;\nworldPos.z = cc_matWorld[3][2] + a_position.z;\nworldPos.w = 1.0;\nvec4 clipPos = cc_matLightViewProj * worldPos;\nv_clip_depth = clipPos.zw;\nreturn clipPos;\n}\nvoid main() { gl_Position = vert(); }", + "frag": "\nprecision highp float;\nvec4 packDepthToRGBA (float depth) {\nvec4 ret = vec4(1.0, 255.0, 65025.0, 16581375.0) * depth;\nret = fract(ret);\nret -= vec4(ret.yzw, 0.0) / 255.0;\nreturn ret;\n}\nlayout(location = 0) in vec2 v_clip_depth;\nvec4 frag () {\nreturn packDepthToRGBA(v_clip_depth.x / v_clip_depth.y * 0.5 + 0.5);\n}\nlayout(location = 0) out vec4 cc_FragColor;\nvoid main() { cc_FragColor = frag(); }", + } + ], + [ + { + "vert": "#extension GL_EXT_shader_explicit_arithmetic_types_int32: require\nprecision highp float;\nhighp float decode32 (highp vec4 rgba) {\nrgba = rgba * 255.0;\nhighp float Sign = 1.0 - (step(128.0, (rgba[3]) + 0.5)) * 2.0;\nhighp float Exponent = 2.0 * (mod(float(int((rgba[3]) + 0.5)), 128.0)) + (step(128.0, (rgba[2]) + 0.5)) - 127.0;\nhighp float Mantissa = (mod(float(int((rgba[2]) + 0.5)), 128.0)) * 65536.0 + rgba[1] * 256.0 + rgba[0] + 8388608.0;\nreturn Sign * exp2(Exponent - 23.0) * Mantissa;\n}\nstruct StandardVertInput {\nhighp vec4 position;\nvec3 normal;\nvec4 tangent;\n};\nlayout(location = 0) in vec3 a_position;\nlayout(location = 1) in vec3 a_normal;\nlayout(location = 2) in vec2 a_texCoord;\nlayout(location = 3) in vec4 a_tangent;\n#if CC_USE_MORPH\nint getVertexId() {\nreturn gl_VertexIndex;\n}\nlayout(set = 2, binding = 4) uniform CCMorph {\nvec4 cc_displacementWeights[15];\nvec4 cc_displacementTextureInfo;\n};\nvec2 getPixelLocation(vec2 textureResolution, int pixelIndex) {\nfloat pixelIndexF = float(pixelIndex);\nfloat x = mod(pixelIndexF, textureResolution.x);\nfloat y = floor(pixelIndexF / textureResolution.x);\nreturn vec2(x, y);\n}\nvec2 getPixelCoordFromLocation(vec2 location, vec2 textureResolution) {\nreturn (vec2(location.x, location.y) + .5) / textureResolution;\n}\n#if CC_DEVICE_SUPPORT_FLOAT_TEXTURE\nvec4 fetchVec3ArrayFromTexture(sampler2D tex, int pixelIndex) {\nivec2 texSize = textureSize(tex, 0);\nreturn texelFetch(tex, ivec2(pixelIndex % texSize.x, pixelIndex / texSize.x), 0);\n}\n#else\nvec4 fetchVec3ArrayFromTexture(sampler2D tex, int elementIndex) {\nint pixelIndex = elementIndex * 4;\nvec2 location = getPixelLocation(cc_displacementTextureInfo.xy, pixelIndex);\nvec2 x = getPixelCoordFromLocation(location + vec2(0.0, 0.0), cc_displacementTextureInfo.xy);\nvec2 y = getPixelCoordFromLocation(location + vec2(1.0, 0.0), cc_displacementTextureInfo.xy);\nvec2 z = getPixelCoordFromLocation(location + vec2(2.0, 0.0), cc_displacementTextureInfo.xy);\nreturn vec4(\ndecode32(texture(tex, x)),\ndecode32(texture(tex, y)),\ndecode32(texture(tex, z)),\n1.0\n);\n}\n#endif\nfloat getDisplacementWeight(int index) {\nint quot = index / 4;\nint remainder = index - quot * 4;\nif (remainder == 0) {\nreturn cc_displacementWeights[quot].x;\n} else if (remainder == 1) {\nreturn cc_displacementWeights[quot].y;\n} else if (remainder == 2) {\nreturn cc_displacementWeights[quot].z;\n} else {\nreturn cc_displacementWeights[quot].w;\n}\n}\nvec3 getVec3DisplacementFromTexture(sampler2D tex, int vertexIndex) {\n#if CC_MORPH_PRECOMPUTED\nreturn fetchVec3ArrayFromTexture(tex, vertexIndex).rgb;\n#else\nvec3 result = vec3(0, 0, 0);\nint nVertices = int(cc_displacementTextureInfo.z);\nfor (int iTarget = 0; iTarget < CC_MORPH_TARGET_COUNT; ++iTarget) {\nresult += (fetchVec3ArrayFromTexture(tex, nVertices * iTarget + vertexIndex).rgb * getDisplacementWeight(iTarget));\n}\nreturn result;\n#endif\n}\n#if CC_MORPH_TARGET_HAS_POSITION\nlayout(set = 2, binding = 7) uniform sampler2D cc_PositionDisplacements;\nvec3 getPositionDisplacement(int vertexId) {\nreturn getVec3DisplacementFromTexture(cc_PositionDisplacements, vertexId);\n}\n#endif\n#if CC_MORPH_TARGET_HAS_NORMAL\nlayout(set = 2, binding = 8) uniform sampler2D cc_NormalDisplacements;\nvec3 getNormalDisplacement(int vertexId) {\nreturn getVec3DisplacementFromTexture(cc_NormalDisplacements, vertexId);\n}\n#endif\n#if CC_MORPH_TARGET_HAS_TANGENT\nlayout(set = 2, binding = 9) uniform sampler2D cc_TangentDisplacements;\nvec3 getTangentDisplacement(int vertexId) {\nreturn getVec3DisplacementFromTexture(cc_TangentDisplacements, vertexId);\n}\n#endif\nvoid applyMorph (inout StandardVertInput attr) {\nint vertexId = getVertexId();\n#if CC_MORPH_TARGET_HAS_POSITION\nattr.position.xyz = attr.position.xyz + getPositionDisplacement(vertexId);\n#endif\n#if CC_MORPH_TARGET_HAS_NORMAL\nattr.normal.xyz = attr.normal.xyz + getNormalDisplacement(vertexId);\n#endif\n#if CC_MORPH_TARGET_HAS_TANGENT\nattr.tangent.xyz = attr.tangent.xyz + getTangentDisplacement(vertexId);\n#endif\n}\nvoid applyMorph (inout vec4 position) {\n#if CC_MORPH_TARGET_HAS_POSITION\nposition.xyz = position.xyz + getPositionDisplacement(getVertexId());\n#endif\n}\n#endif\n#if CC_USE_SKINNING\nlayout(location = 4) in u32vec4 a_joints;\nlayout(location = 5) in vec4 a_weights;\n#if CC_USE_BAKED_ANIMATION\n#if USE_INSTANCING\nlayout(location = 7) in highp vec4 a_jointAnimInfo;\n#endif\nlayout(set = 2, binding = 3) uniform CCSkinningTexture {\nhighp vec4 cc_jointTextureInfo;\n};\nlayout(set = 2, binding = 2) uniform CCSkinningAnimation {\nhighp vec4 cc_jointAnimInfo;\n};\nlayout(set = 2, binding = 6) uniform highp sampler2D cc_jointTexture;\n#else\nlayout(set = 2, binding = 3) uniform CCSkinning {\nhighp vec4 cc_joints[30 * 3];\n};\n#endif\n#if CC_USE_BAKED_ANIMATION\n#if CC_DEVICE_SUPPORT_FLOAT_TEXTURE\nmat4 getJointMatrix (float i) {\n#if USE_INSTANCING\nhighp float j = 3.0 * (a_jointAnimInfo.x * a_jointAnimInfo.y + i) + a_jointAnimInfo.z;\n#else\nhighp float j = 3.0 * (cc_jointAnimInfo.x * cc_jointTextureInfo.y + i) + cc_jointTextureInfo.z;\n#endif\nhighp float invSize = cc_jointTextureInfo.w;\nhighp float y = floor(j * invSize);\nhighp float x = floor(j - y * cc_jointTextureInfo.x);\ny = (y + 0.5) * invSize;\nvec4 v1 = texture(cc_jointTexture, vec2((x + 0.5) * invSize, y));\nvec4 v2 = texture(cc_jointTexture, vec2((x + 1.5) * invSize, y));\nvec4 v3 = texture(cc_jointTexture, vec2((x + 2.5) * invSize, y));\nreturn mat4(vec4(v1.xyz, 0.0), vec4(v2.xyz, 0.0), vec4(v3.xyz, 0.0), vec4(v1.w, v2.w, v3.w, 1.0));\n}\n#else\nmat4 getJointMatrix (float i) {\n#if USE_INSTANCING\nhighp float j = 12.0 * (a_jointAnimInfo.x * a_jointAnimInfo.y + i) + a_jointAnimInfo.z;\n#else\nhighp float j = 12.0 * (cc_jointAnimInfo.x * cc_jointTextureInfo.y + i) + cc_jointTextureInfo.z;\n#endif\nhighp float invSize = cc_jointTextureInfo.w;\nhighp float y = floor(j * invSize);\nhighp float x = floor(j - y * cc_jointTextureInfo.x);\ny = (y + 0.5) * invSize;\nvec4 v1 = vec4(\ndecode32(texture(cc_jointTexture, vec2((x + 0.5) * invSize, y))),\ndecode32(texture(cc_jointTexture, vec2((x + 1.5) * invSize, y))),\ndecode32(texture(cc_jointTexture, vec2((x + 2.5) * invSize, y))),\ndecode32(texture(cc_jointTexture, vec2((x + 3.5) * invSize, y)))\n);\nvec4 v2 = vec4(\ndecode32(texture(cc_jointTexture, vec2((x + 4.5) * invSize, y))),\ndecode32(texture(cc_jointTexture, vec2((x + 5.5) * invSize, y))),\ndecode32(texture(cc_jointTexture, vec2((x + 6.5) * invSize, y))),\ndecode32(texture(cc_jointTexture, vec2((x + 7.5) * invSize, y)))\n);\nvec4 v3 = vec4(\ndecode32(texture(cc_jointTexture, vec2((x + 8.5) * invSize, y))),\ndecode32(texture(cc_jointTexture, vec2((x + 9.5) * invSize, y))),\ndecode32(texture(cc_jointTexture, vec2((x + 10.5) * invSize, y))),\ndecode32(texture(cc_jointTexture, vec2((x + 11.5) * invSize, y)))\n);\nreturn mat4(vec4(v1.xyz, 0.0), vec4(v2.xyz, 0.0), vec4(v3.xyz, 0.0), vec4(v1.w, v2.w, v3.w, 1.0));\n}\n#endif\n#else\nmat4 getJointMatrix (float i) {\nint idx = int(i);\nvec4 v1 = cc_joints[idx * 3];\nvec4 v2 = cc_joints[idx * 3 + 1];\nvec4 v3 = cc_joints[idx * 3 + 2];\nreturn mat4(vec4(v1.xyz, 0.0), vec4(v2.xyz, 0.0), vec4(v3.xyz, 0.0), vec4(v1.w, v2.w, v3.w, 1.0));\n}\n#endif\nmat4 skinMatrix () {\nvec4 joints = vec4(a_joints);\nreturn getJointMatrix(joints.x) * a_weights.x\n+ getJointMatrix(joints.y) * a_weights.y\n+ getJointMatrix(joints.z) * a_weights.z\n+ getJointMatrix(joints.w) * a_weights.w;\n}\nvoid CCSkin (inout vec4 position) {\nmat4 m = skinMatrix();\nposition = m * position;\n}\nvoid CCSkin (inout StandardVertInput attr) {\nmat4 m = skinMatrix();\nattr.position = m * attr.position;\nattr.normal = (m * vec4(attr.normal, 0.0)).xyz;\nattr.tangent.xyz = (m * vec4(attr.tangent.xyz, 0.0)).xyz;\n}\n#endif\nlayout(set = 0, binding = 0) uniform CCGlobal {\nhighp vec4 cc_time;\nmediump vec4 cc_screenSize;\nmediump vec4 cc_nativeSize;\n};\nlayout(set = 0, binding = 1) uniform CCCamera {\nhighp mat4 cc_matView;\nhighp mat4 cc_matViewInv;\nhighp mat4 cc_matProj;\nhighp mat4 cc_matProjInv;\nhighp mat4 cc_matViewProj;\nhighp mat4 cc_matViewProjInv;\nhighp vec4 cc_cameraPos;\nmediump vec4 cc_screenScale;\nmediump vec4 cc_exposure;\nmediump vec4 cc_mainLitDir;\nmediump vec4 cc_mainLitColor;\nmediump vec4 cc_ambientSky;\nmediump vec4 cc_ambientGround;\nmediump vec4 cc_fogColor;\nmediump vec4 cc_fogBase;\nmediump vec4 cc_fogAdd;\nmediump vec4 cc_nearFar;\nmediump vec4 cc_viewPort;\n};\n#if USE_INSTANCING\nlayout(location = 8) in vec4 a_matWorld0;\nlayout(location = 9) in vec4 a_matWorld1;\nlayout(location = 10) in vec4 a_matWorld2;\n#if USE_LIGHTMAP\nlayout(location = 11) in vec4 a_lightingMapUVParam;\n#endif\n#elif USE_BATCHING\nlayout(location = 12) in float a_dyn_batch_id;\nlayout(set = 2, binding = 0) uniform CCLocalBatched {\nhighp mat4 cc_matWorlds[10];\n};\n#else\nlayout(set = 2, binding = 0) uniform CCLocal {\nhighp mat4 cc_matWorld;\nhighp mat4 cc_matWorldIT;\nhighp vec4 cc_lightingMapUVParam;\n};\n#endif\nfloat LinearFog(vec4 pos) {\nvec4 wPos = pos;\nfloat cam_dis = distance(cc_cameraPos, wPos);\nfloat fogStart = cc_fogBase.x;\nfloat fogEnd = cc_fogBase.y;\nreturn clamp((fogEnd - cam_dis) / (fogEnd - fogStart), 0., 1.);\n}\nfloat ExpFog(vec4 pos) {\nvec4 wPos = pos;\nfloat fogAtten = cc_fogAdd.z;\nfloat fogStart = cc_fogBase.x;\nfloat fogDensity = cc_fogBase.z;\nfloat cam_dis = max(distance(cc_cameraPos, wPos) - fogStart, 0.0) / fogAtten * 4.;\nfloat f = exp(-cam_dis * fogDensity);\nreturn f;\n}\nfloat ExpSquaredFog(vec4 pos) {\nvec4 wPos = pos;\nfloat fogAtten = cc_fogAdd.z;\nfloat fogStart = cc_fogBase.x;\nfloat fogDensity = cc_fogBase.z;\nfloat cam_dis = max(distance(cc_cameraPos, wPos) - fogStart, 0.0) / fogAtten * 4.;\nfloat f = exp(-cam_dis * cam_dis * fogDensity * fogDensity);\nreturn f;\n}\nfloat LayeredFog(vec4 pos) {\nvec4 wPos = pos;\nfloat fogAtten = cc_fogAdd.z;\nfloat _FogTop = cc_fogAdd.x;\nfloat _FogRange = cc_fogAdd.y;\nvec3 camWorldProj = cc_cameraPos.xyz;\ncamWorldProj.y = 0.;\nvec3 worldPosProj = wPos.xyz;\nworldPosProj.y = 0.;\nfloat fDeltaD = distance(worldPosProj, camWorldProj) / fogAtten * 2.0;\nfloat fDeltaY, fDensityIntegral;\nif (cc_cameraPos.y > _FogTop) {\nif (wPos.y < _FogTop) {\nfDeltaY = (_FogTop - wPos.y) / _FogRange * 2.0;\nfDensityIntegral = fDeltaY * fDeltaY * 0.5;\n} else {\nfDeltaY = 0.;\nfDensityIntegral = 0.;\n}\n} else {\nif (wPos.y < _FogTop) {\nfloat fDeltaA = (_FogTop - cc_cameraPos.y) / _FogRange * 2.;\nfloat fDeltaB = (_FogTop - wPos.y) / _FogRange * 2.;\nfDeltaY = abs(fDeltaA - fDeltaB);\nfDensityIntegral = abs((fDeltaA * fDeltaA * 0.5) - (fDeltaB * fDeltaB * 0.5));\n} else {\nfDeltaY = abs(_FogTop - cc_cameraPos.y) / _FogRange * 2.;\nfDensityIntegral = abs(fDeltaY * fDeltaY * 0.5);\n}\n}\nfloat fDensity;\nif (fDeltaY != 0.) {\nfDensity = (sqrt(1.0 + ((fDeltaD / fDeltaY) * (fDeltaD / fDeltaY)))) * fDensityIntegral;\n} else {\nfDensity = 0.;\n}\nfloat f = exp(-fDensity);\nreturn f;\n}\nvoid CC_TRANSFER_FOG_BASE(vec4 pos, out float factor)\n{\n#if CC_USE_FOG == 0\nfactor = LinearFog(pos);\n#elif CC_USE_FOG == 1\nfactor = ExpFog(pos);\n#elif CC_USE_FOG == 2\nfactor = ExpSquaredFog(pos);\n#elif CC_USE_FOG == 3\nfactor = LayeredFog(pos);\n#else\nfactor = 1.0;\n#endif\n}\n#if !CC_USE_ACCURATE_FOG\nlayout(location = 0) out float v_fog_factor;\n#endif\nvoid CC_TRANSFER_FOG(vec4 pos) {\n#if !CC_USE_ACCURATE_FOG\nCC_TRANSFER_FOG_BASE(pos, v_fog_factor);\n#endif\n}\n#if USE_VERTEX_COLOR\nlayout(location = 13) in lowp vec4 a_color;\nlayout(location = 1) out lowp vec4 v_color;\n#endif\n#if USE_TEXTURE\nlayout(location = 2) out vec2 v_uv;\nlayout(set = 1, binding = 0) uniform TexCoords {\nvec4 tilingOffset;\n};\n#endif\nvec4 vert () {\nvec4 position;\nposition = vec4(a_position, 1.0);\n#if CC_USE_MORPH\napplyMorph(position);\n#endif\n#if CC_USE_SKINNING\nCCSkin(position);\n#endif\nmat4 matWorld;\n#if USE_INSTANCING\nmatWorld = mat4(\nvec4(a_matWorld0.xyz, 0.0),\nvec4(a_matWorld1.xyz, 0.0),\nvec4(a_matWorld2.xyz, 0.0),\nvec4(a_matWorld0.w, a_matWorld1.w, a_matWorld2.w, 1.0)\n);\n#elif USE_BATCHING\nmatWorld = cc_matWorlds[int(a_dyn_batch_id)];\n#else\nmatWorld = cc_matWorld;\n#endif\n#if USE_TEXTURE\nv_uv = a_texCoord * tilingOffset.xy + tilingOffset.zw;\n#if SAMPLE_FROM_RT\nv_uv = cc_cameraPos.w > 1.0 ? vec2(v_uv.x, 1.0 - v_uv.y) : v_uv;\n#endif\n#endif\n#if USE_VERTEX_COLOR\nv_color = a_color;\n#endif\nCC_TRANSFER_FOG(matWorld * position);\nreturn cc_matProj * (cc_matView * matWorld) * position;\n}\nvoid main() { gl_Position = vert(); }", + "frag": "\nprecision highp float;\nvec3 ACESToneMap (vec3 color) {\ncolor = min(color, vec3(8.0));\nconst float A = 2.51;\nconst float B = 0.03;\nconst float C = 2.43;\nconst float D = 0.59;\nconst float E = 0.14;\nreturn (color * (A * color + B)) / (color * (C * color + D) + E);\n}\nvec3 SRGBToLinear (vec3 gamma) {\nreturn gamma * gamma;\n}\nvec4 CCFragOutput (vec4 color) {\n#if CC_USE_HDR\ncolor.rgb = ACESToneMap(color.rgb);\n#endif\ncolor.rgb = sqrt(color.rgb);\nreturn color;\n}\nlayout(set = 0, binding = 0) uniform CCGlobal {\nhighp vec4 cc_time;\nmediump vec4 cc_screenSize;\nmediump vec4 cc_nativeSize;\n};\nlayout(set = 0, binding = 1) uniform CCCamera {\nhighp mat4 cc_matView;\nhighp mat4 cc_matViewInv;\nhighp mat4 cc_matProj;\nhighp mat4 cc_matProjInv;\nhighp mat4 cc_matViewProj;\nhighp mat4 cc_matViewProjInv;\nhighp vec4 cc_cameraPos;\nmediump vec4 cc_screenScale;\nmediump vec4 cc_exposure;\nmediump vec4 cc_mainLitDir;\nmediump vec4 cc_mainLitColor;\nmediump vec4 cc_ambientSky;\nmediump vec4 cc_ambientGround;\nmediump vec4 cc_fogColor;\nmediump vec4 cc_fogBase;\nmediump vec4 cc_fogAdd;\nmediump vec4 cc_nearFar;\nmediump vec4 cc_viewPort;\n};\nfloat LinearFog(vec4 pos) {\nvec4 wPos = pos;\nfloat cam_dis = distance(cc_cameraPos, wPos);\nfloat fogStart = cc_fogBase.x;\nfloat fogEnd = cc_fogBase.y;\nreturn clamp((fogEnd - cam_dis) / (fogEnd - fogStart), 0., 1.);\n}\nfloat ExpFog(vec4 pos) {\nvec4 wPos = pos;\nfloat fogAtten = cc_fogAdd.z;\nfloat fogStart = cc_fogBase.x;\nfloat fogDensity = cc_fogBase.z;\nfloat cam_dis = max(distance(cc_cameraPos, wPos) - fogStart, 0.0) / fogAtten * 4.;\nfloat f = exp(-cam_dis * fogDensity);\nreturn f;\n}\nfloat ExpSquaredFog(vec4 pos) {\nvec4 wPos = pos;\nfloat fogAtten = cc_fogAdd.z;\nfloat fogStart = cc_fogBase.x;\nfloat fogDensity = cc_fogBase.z;\nfloat cam_dis = max(distance(cc_cameraPos, wPos) - fogStart, 0.0) / fogAtten * 4.;\nfloat f = exp(-cam_dis * cam_dis * fogDensity * fogDensity);\nreturn f;\n}\nfloat LayeredFog(vec4 pos) {\nvec4 wPos = pos;\nfloat fogAtten = cc_fogAdd.z;\nfloat _FogTop = cc_fogAdd.x;\nfloat _FogRange = cc_fogAdd.y;\nvec3 camWorldProj = cc_cameraPos.xyz;\ncamWorldProj.y = 0.;\nvec3 worldPosProj = wPos.xyz;\nworldPosProj.y = 0.;\nfloat fDeltaD = distance(worldPosProj, camWorldProj) / fogAtten * 2.0;\nfloat fDeltaY, fDensityIntegral;\nif (cc_cameraPos.y > _FogTop) {\nif (wPos.y < _FogTop) {\nfDeltaY = (_FogTop - wPos.y) / _FogRange * 2.0;\nfDensityIntegral = fDeltaY * fDeltaY * 0.5;\n} else {\nfDeltaY = 0.;\nfDensityIntegral = 0.;\n}\n} else {\nif (wPos.y < _FogTop) {\nfloat fDeltaA = (_FogTop - cc_cameraPos.y) / _FogRange * 2.;\nfloat fDeltaB = (_FogTop - wPos.y) / _FogRange * 2.;\nfDeltaY = abs(fDeltaA - fDeltaB);\nfDensityIntegral = abs((fDeltaA * fDeltaA * 0.5) - (fDeltaB * fDeltaB * 0.5));\n} else {\nfDeltaY = abs(_FogTop - cc_cameraPos.y) / _FogRange * 2.;\nfDensityIntegral = abs(fDeltaY * fDeltaY * 0.5);\n}\n}\nfloat fDensity;\nif (fDeltaY != 0.) {\nfDensity = (sqrt(1.0 + ((fDeltaD / fDeltaY) * (fDeltaD / fDeltaY)))) * fDensityIntegral;\n} else {\nfDensity = 0.;\n}\nfloat f = exp(-fDensity);\nreturn f;\n}\nvoid CC_TRANSFER_FOG_BASE(vec4 pos, out float factor)\n{\n#if CC_USE_FOG == 0\nfactor = LinearFog(pos);\n#elif CC_USE_FOG == 1\nfactor = ExpFog(pos);\n#elif CC_USE_FOG == 2\nfactor = ExpSquaredFog(pos);\n#elif CC_USE_FOG == 3\nfactor = LayeredFog(pos);\n#else\nfactor = 1.0;\n#endif\n}\nvoid CC_APPLY_FOG_BASE(inout vec4 color, float factor) {\ncolor = vec4(mix(cc_fogColor.rgb, color.rgb, factor), color.a);\n}\n#if !CC_USE_ACCURATE_FOG\nlayout(location = 0) in float v_fog_factor;\n#endif\nvoid CC_APPLY_FOG(inout vec4 color) {\n#if !CC_USE_ACCURATE_FOG\nCC_APPLY_FOG_BASE(color, v_fog_factor);\n#endif\n}\nvoid CC_APPLY_FOG(inout vec4 color, vec3 worldPos) {\n#if CC_USE_ACCURATE_FOG\nfloat factor;\nCC_TRANSFER_FOG_BASE(vec4(worldPos, 1.0), factor);\n#else\nfloat factor = v_fog_factor;\n#endif\nCC_APPLY_FOG_BASE(color, factor);\n}\n#if USE_ALPHA_TEST\n#endif\n#if USE_TEXTURE\nlayout(location = 2) in vec2 v_uv;\nlayout(set = 1, binding = 2) uniform sampler2D mainTexture;\n#endif\nlayout(set = 1, binding = 1) uniform Constant {\nvec4 mainColor;\nvec4 colorScaleAndCutoff;\n};\n#if USE_VERTEX_COLOR\nlayout(location = 1) in lowp vec4 v_color;\n#endif\nvec4 frag () {\nvec4 o = mainColor;\no.rgb *= colorScaleAndCutoff.xyz;\n#if USE_VERTEX_COLOR\no.rgb *= SRGBToLinear(v_color.rgb);\no.a *= v_color.a;\n#endif\n#if USE_TEXTURE\nvec4 texColor = texture(mainTexture, v_uv);\ntexColor.rgb = SRGBToLinear(texColor.rgb);\no *= texColor;\n#endif\n#if USE_ALPHA_TEST\nif (o.ALPHA_TEST_CHANNEL < colorScaleAndCutoff.w) discard;\n#endif\nCC_APPLY_FOG(o);\nreturn CCFragOutput(o);\n}\nlayout(location = 0) out vec4 cc_FragColor;\nvoid main() { cc_FragColor = frag(); }", + } + ], + [ + { + "vert": "#extension GL_EXT_shader_explicit_arithmetic_types_int32: require\nprecision highp float;\nhighp float decode32 (highp vec4 rgba) {\nrgba = rgba * 255.0;\nhighp float Sign = 1.0 - (step(128.0, (rgba[3]) + 0.5)) * 2.0;\nhighp float Exponent = 2.0 * (mod(float(int((rgba[3]) + 0.5)), 128.0)) + (step(128.0, (rgba[2]) + 0.5)) - 127.0;\nhighp float Mantissa = (mod(float(int((rgba[2]) + 0.5)), 128.0)) * 65536.0 + rgba[1] * 256.0 + rgba[0] + 8388608.0;\nreturn Sign * exp2(Exponent - 23.0) * Mantissa;\n}\nstruct StandardVertInput {\nhighp vec4 position;\nvec3 normal;\nvec4 tangent;\n};\nlayout(location = 0) in vec3 a_position;\nlayout(location = 1) in vec3 a_normal;\nlayout(location = 2) in vec2 a_texCoord;\nlayout(location = 3) in vec4 a_tangent;\n#if CC_USE_MORPH\nint getVertexId() {\nreturn gl_VertexIndex;\n}\nlayout(set = 2, binding = 4) uniform CCMorph {\nvec4 cc_displacementWeights[15];\nvec4 cc_displacementTextureInfo;\n};\nvec2 getPixelLocation(vec2 textureResolution, int pixelIndex) {\nfloat pixelIndexF = float(pixelIndex);\nfloat x = mod(pixelIndexF, textureResolution.x);\nfloat y = floor(pixelIndexF / textureResolution.x);\nreturn vec2(x, y);\n}\nvec2 getPixelCoordFromLocation(vec2 location, vec2 textureResolution) {\nreturn (vec2(location.x, location.y) + .5) / textureResolution;\n}\n#if CC_DEVICE_SUPPORT_FLOAT_TEXTURE\nvec4 fetchVec3ArrayFromTexture(sampler2D tex, int pixelIndex) {\nivec2 texSize = textureSize(tex, 0);\nreturn texelFetch(tex, ivec2(pixelIndex % texSize.x, pixelIndex / texSize.x), 0);\n}\n#else\nvec4 fetchVec3ArrayFromTexture(sampler2D tex, int elementIndex) {\nint pixelIndex = elementIndex * 4;\nvec2 location = getPixelLocation(cc_displacementTextureInfo.xy, pixelIndex);\nvec2 x = getPixelCoordFromLocation(location + vec2(0.0, 0.0), cc_displacementTextureInfo.xy);\nvec2 y = getPixelCoordFromLocation(location + vec2(1.0, 0.0), cc_displacementTextureInfo.xy);\nvec2 z = getPixelCoordFromLocation(location + vec2(2.0, 0.0), cc_displacementTextureInfo.xy);\nreturn vec4(\ndecode32(texture(tex, x)),\ndecode32(texture(tex, y)),\ndecode32(texture(tex, z)),\n1.0\n);\n}\n#endif\nfloat getDisplacementWeight(int index) {\nint quot = index / 4;\nint remainder = index - quot * 4;\nif (remainder == 0) {\nreturn cc_displacementWeights[quot].x;\n} else if (remainder == 1) {\nreturn cc_displacementWeights[quot].y;\n} else if (remainder == 2) {\nreturn cc_displacementWeights[quot].z;\n} else {\nreturn cc_displacementWeights[quot].w;\n}\n}\nvec3 getVec3DisplacementFromTexture(sampler2D tex, int vertexIndex) {\n#if CC_MORPH_PRECOMPUTED\nreturn fetchVec3ArrayFromTexture(tex, vertexIndex).rgb;\n#else\nvec3 result = vec3(0, 0, 0);\nint nVertices = int(cc_displacementTextureInfo.z);\nfor (int iTarget = 0; iTarget < CC_MORPH_TARGET_COUNT; ++iTarget) {\nresult += (fetchVec3ArrayFromTexture(tex, nVertices * iTarget + vertexIndex).rgb * getDisplacementWeight(iTarget));\n}\nreturn result;\n#endif\n}\n#if CC_MORPH_TARGET_HAS_POSITION\nlayout(set = 2, binding = 7) uniform sampler2D cc_PositionDisplacements;\nvec3 getPositionDisplacement(int vertexId) {\nreturn getVec3DisplacementFromTexture(cc_PositionDisplacements, vertexId);\n}\n#endif\n#if CC_MORPH_TARGET_HAS_NORMAL\nlayout(set = 2, binding = 8) uniform sampler2D cc_NormalDisplacements;\nvec3 getNormalDisplacement(int vertexId) {\nreturn getVec3DisplacementFromTexture(cc_NormalDisplacements, vertexId);\n}\n#endif\n#if CC_MORPH_TARGET_HAS_TANGENT\nlayout(set = 2, binding = 9) uniform sampler2D cc_TangentDisplacements;\nvec3 getTangentDisplacement(int vertexId) {\nreturn getVec3DisplacementFromTexture(cc_TangentDisplacements, vertexId);\n}\n#endif\nvoid applyMorph (inout StandardVertInput attr) {\nint vertexId = getVertexId();\n#if CC_MORPH_TARGET_HAS_POSITION\nattr.position.xyz = attr.position.xyz + getPositionDisplacement(vertexId);\n#endif\n#if CC_MORPH_TARGET_HAS_NORMAL\nattr.normal.xyz = attr.normal.xyz + getNormalDisplacement(vertexId);\n#endif\n#if CC_MORPH_TARGET_HAS_TANGENT\nattr.tangent.xyz = attr.tangent.xyz + getTangentDisplacement(vertexId);\n#endif\n}\nvoid applyMorph (inout vec4 position) {\n#if CC_MORPH_TARGET_HAS_POSITION\nposition.xyz = position.xyz + getPositionDisplacement(getVertexId());\n#endif\n}\n#endif\n#if CC_USE_SKINNING\nlayout(location = 4) in u32vec4 a_joints;\nlayout(location = 5) in vec4 a_weights;\n#if CC_USE_BAKED_ANIMATION\n#if USE_INSTANCING\nlayout(location = 7) in highp vec4 a_jointAnimInfo;\n#endif\nlayout(set = 2, binding = 3) uniform CCSkinningTexture {\nhighp vec4 cc_jointTextureInfo;\n};\nlayout(set = 2, binding = 2) uniform CCSkinningAnimation {\nhighp vec4 cc_jointAnimInfo;\n};\nlayout(set = 2, binding = 6) uniform highp sampler2D cc_jointTexture;\n#else\nlayout(set = 2, binding = 3) uniform CCSkinning {\nhighp vec4 cc_joints[30 * 3];\n};\n#endif\n#if CC_USE_BAKED_ANIMATION\n#if CC_DEVICE_SUPPORT_FLOAT_TEXTURE\nmat4 getJointMatrix (float i) {\n#if USE_INSTANCING\nhighp float j = 3.0 * (a_jointAnimInfo.x * a_jointAnimInfo.y + i) + a_jointAnimInfo.z;\n#else\nhighp float j = 3.0 * (cc_jointAnimInfo.x * cc_jointTextureInfo.y + i) + cc_jointTextureInfo.z;\n#endif\nhighp float invSize = cc_jointTextureInfo.w;\nhighp float y = floor(j * invSize);\nhighp float x = floor(j - y * cc_jointTextureInfo.x);\ny = (y + 0.5) * invSize;\nvec4 v1 = texture(cc_jointTexture, vec2((x + 0.5) * invSize, y));\nvec4 v2 = texture(cc_jointTexture, vec2((x + 1.5) * invSize, y));\nvec4 v3 = texture(cc_jointTexture, vec2((x + 2.5) * invSize, y));\nreturn mat4(vec4(v1.xyz, 0.0), vec4(v2.xyz, 0.0), vec4(v3.xyz, 0.0), vec4(v1.w, v2.w, v3.w, 1.0));\n}\n#else\nmat4 getJointMatrix (float i) {\n#if USE_INSTANCING\nhighp float j = 12.0 * (a_jointAnimInfo.x * a_jointAnimInfo.y + i) + a_jointAnimInfo.z;\n#else\nhighp float j = 12.0 * (cc_jointAnimInfo.x * cc_jointTextureInfo.y + i) + cc_jointTextureInfo.z;\n#endif\nhighp float invSize = cc_jointTextureInfo.w;\nhighp float y = floor(j * invSize);\nhighp float x = floor(j - y * cc_jointTextureInfo.x);\ny = (y + 0.5) * invSize;\nvec4 v1 = vec4(\ndecode32(texture(cc_jointTexture, vec2((x + 0.5) * invSize, y))),\ndecode32(texture(cc_jointTexture, vec2((x + 1.5) * invSize, y))),\ndecode32(texture(cc_jointTexture, vec2((x + 2.5) * invSize, y))),\ndecode32(texture(cc_jointTexture, vec2((x + 3.5) * invSize, y)))\n);\nvec4 v2 = vec4(\ndecode32(texture(cc_jointTexture, vec2((x + 4.5) * invSize, y))),\ndecode32(texture(cc_jointTexture, vec2((x + 5.5) * invSize, y))),\ndecode32(texture(cc_jointTexture, vec2((x + 6.5) * invSize, y))),\ndecode32(texture(cc_jointTexture, vec2((x + 7.5) * invSize, y)))\n);\nvec4 v3 = vec4(\ndecode32(texture(cc_jointTexture, vec2((x + 8.5) * invSize, y))),\ndecode32(texture(cc_jointTexture, vec2((x + 9.5) * invSize, y))),\ndecode32(texture(cc_jointTexture, vec2((x + 10.5) * invSize, y))),\ndecode32(texture(cc_jointTexture, vec2((x + 11.5) * invSize, y)))\n);\nreturn mat4(vec4(v1.xyz, 0.0), vec4(v2.xyz, 0.0), vec4(v3.xyz, 0.0), vec4(v1.w, v2.w, v3.w, 1.0));\n}\n#endif\n#else\nmat4 getJointMatrix (float i) {\nint idx = int(i);\nvec4 v1 = cc_joints[idx * 3];\nvec4 v2 = cc_joints[idx * 3 + 1];\nvec4 v3 = cc_joints[idx * 3 + 2];\nreturn mat4(vec4(v1.xyz, 0.0), vec4(v2.xyz, 0.0), vec4(v3.xyz, 0.0), vec4(v1.w, v2.w, v3.w, 1.0));\n}\n#endif\nmat4 skinMatrix () {\nvec4 joints = vec4(a_joints);\nreturn getJointMatrix(joints.x) * a_weights.x\n+ getJointMatrix(joints.y) * a_weights.y\n+ getJointMatrix(joints.z) * a_weights.z\n+ getJointMatrix(joints.w) * a_weights.w;\n}\nvoid CCSkin (inout vec4 position) {\nmat4 m = skinMatrix();\nposition = m * position;\n}\nvoid CCSkin (inout StandardVertInput attr) {\nmat4 m = skinMatrix();\nattr.position = m * attr.position;\nattr.normal = (m * vec4(attr.normal, 0.0)).xyz;\nattr.tangent.xyz = (m * vec4(attr.tangent.xyz, 0.0)).xyz;\n}\n#endif\nlayout(set = 0, binding = 0) uniform CCGlobal {\nhighp vec4 cc_time;\nmediump vec4 cc_screenSize;\nmediump vec4 cc_nativeSize;\n};\nlayout(set = 0, binding = 1) uniform CCCamera {\nhighp mat4 cc_matView;\nhighp mat4 cc_matViewInv;\nhighp mat4 cc_matProj;\nhighp mat4 cc_matProjInv;\nhighp mat4 cc_matViewProj;\nhighp mat4 cc_matViewProjInv;\nhighp vec4 cc_cameraPos;\nmediump vec4 cc_screenScale;\nmediump vec4 cc_exposure;\nmediump vec4 cc_mainLitDir;\nmediump vec4 cc_mainLitColor;\nmediump vec4 cc_ambientSky;\nmediump vec4 cc_ambientGround;\nmediump vec4 cc_fogColor;\nmediump vec4 cc_fogBase;\nmediump vec4 cc_fogAdd;\nmediump vec4 cc_nearFar;\nmediump vec4 cc_viewPort;\n};\nlayout(location = 0) out vec2 v_uv;\nvoid main () {\nStandardVertInput In;\nIn.position = vec4(a_position, 1.0);\nIn.normal = a_normal;\nIn.tangent = a_tangent;\n#if CC_USE_MORPH\napplyMorph(In);\n#endif\n#if CC_USE_SKINNING\nCCSkin(In);\n#endif\nIn.position.xy = cc_cameraPos.w == 0.0 ? vec2(In.position.xy.x, -In.position.xy.y) : In.position.xy;\ngl_Position = In.position;\ngl_Position.y = gl_Position.y;\nv_uv = a_texCoord;\n}", + "frag": "\nprecision highp float;\nlayout(set = 0, binding = 0) uniform CCGlobal {\nhighp vec4 cc_time;\nmediump vec4 cc_screenSize;\nmediump vec4 cc_nativeSize;\n};\nlayout(set = 0, binding = 1) uniform CCCamera {\nhighp mat4 cc_matView;\nhighp mat4 cc_matViewInv;\nhighp mat4 cc_matProj;\nhighp mat4 cc_matProjInv;\nhighp mat4 cc_matViewProj;\nhighp mat4 cc_matViewProjInv;\nhighp vec4 cc_cameraPos;\nmediump vec4 cc_screenScale;\nmediump vec4 cc_exposure;\nmediump vec4 cc_mainLitDir;\nmediump vec4 cc_mainLitColor;\nmediump vec4 cc_ambientSky;\nmediump vec4 cc_ambientGround;\nmediump vec4 cc_fogColor;\nmediump vec4 cc_fogBase;\nmediump vec4 cc_fogAdd;\nmediump vec4 cc_nearFar;\nmediump vec4 cc_viewPort;\n};\nvec3 SRGBToLinear (vec3 gamma) {\nreturn gamma * gamma;\n}\nlayout(location = 0) in vec2 v_uv;\nlayout(set = 1, binding = 0) uniform BloomUBO {\nmediump vec4 texSize;\n};\nlayout(set = 1, binding = 1) uniform sampler2D outputResultMap;\nlayout(location = 0) out vec4 fragColor;\nfloat luminance(vec3 color) {\nreturn dot(color, vec3(0.2126, 0.7152, 0.0722));\n}\nvoid main() {\nvec3 color = texture(outputResultMap, v_uv).xyz;\nif (luminance(SRGBToLinear(color)) > texSize.z) {\nfragColor = vec4(color, 1.0);\n} else {\nfragColor = vec4(0.0, 0.0, 0.0, 1.0);\n}\n}", + }, + { + "vert": "#extension GL_EXT_shader_explicit_arithmetic_types_int32: require\nprecision highp float;\nhighp float decode32 (highp vec4 rgba) {\nrgba = rgba * 255.0;\nhighp float Sign = 1.0 - (step(128.0, (rgba[3]) + 0.5)) * 2.0;\nhighp float Exponent = 2.0 * (mod(float(int((rgba[3]) + 0.5)), 128.0)) + (step(128.0, (rgba[2]) + 0.5)) - 127.0;\nhighp float Mantissa = (mod(float(int((rgba[2]) + 0.5)), 128.0)) * 65536.0 + rgba[1] * 256.0 + rgba[0] + 8388608.0;\nreturn Sign * exp2(Exponent - 23.0) * Mantissa;\n}\nstruct StandardVertInput {\nhighp vec4 position;\nvec3 normal;\nvec4 tangent;\n};\nlayout(location = 0) in vec3 a_position;\nlayout(location = 1) in vec3 a_normal;\nlayout(location = 2) in vec2 a_texCoord;\nlayout(location = 3) in vec4 a_tangent;\n#if CC_USE_MORPH\nint getVertexId() {\nreturn gl_VertexIndex;\n}\nlayout(set = 2, binding = 4) uniform CCMorph {\nvec4 cc_displacementWeights[15];\nvec4 cc_displacementTextureInfo;\n};\nvec2 getPixelLocation(vec2 textureResolution, int pixelIndex) {\nfloat pixelIndexF = float(pixelIndex);\nfloat x = mod(pixelIndexF, textureResolution.x);\nfloat y = floor(pixelIndexF / textureResolution.x);\nreturn vec2(x, y);\n}\nvec2 getPixelCoordFromLocation(vec2 location, vec2 textureResolution) {\nreturn (vec2(location.x, location.y) + .5) / textureResolution;\n}\n#if CC_DEVICE_SUPPORT_FLOAT_TEXTURE\nvec4 fetchVec3ArrayFromTexture(sampler2D tex, int pixelIndex) {\nivec2 texSize = textureSize(tex, 0);\nreturn texelFetch(tex, ivec2(pixelIndex % texSize.x, pixelIndex / texSize.x), 0);\n}\n#else\nvec4 fetchVec3ArrayFromTexture(sampler2D tex, int elementIndex) {\nint pixelIndex = elementIndex * 4;\nvec2 location = getPixelLocation(cc_displacementTextureInfo.xy, pixelIndex);\nvec2 x = getPixelCoordFromLocation(location + vec2(0.0, 0.0), cc_displacementTextureInfo.xy);\nvec2 y = getPixelCoordFromLocation(location + vec2(1.0, 0.0), cc_displacementTextureInfo.xy);\nvec2 z = getPixelCoordFromLocation(location + vec2(2.0, 0.0), cc_displacementTextureInfo.xy);\nreturn vec4(\ndecode32(texture(tex, x)),\ndecode32(texture(tex, y)),\ndecode32(texture(tex, z)),\n1.0\n);\n}\n#endif\nfloat getDisplacementWeight(int index) {\nint quot = index / 4;\nint remainder = index - quot * 4;\nif (remainder == 0) {\nreturn cc_displacementWeights[quot].x;\n} else if (remainder == 1) {\nreturn cc_displacementWeights[quot].y;\n} else if (remainder == 2) {\nreturn cc_displacementWeights[quot].z;\n} else {\nreturn cc_displacementWeights[quot].w;\n}\n}\nvec3 getVec3DisplacementFromTexture(sampler2D tex, int vertexIndex) {\n#if CC_MORPH_PRECOMPUTED\nreturn fetchVec3ArrayFromTexture(tex, vertexIndex).rgb;\n#else\nvec3 result = vec3(0, 0, 0);\nint nVertices = int(cc_displacementTextureInfo.z);\nfor (int iTarget = 0; iTarget < CC_MORPH_TARGET_COUNT; ++iTarget) {\nresult += (fetchVec3ArrayFromTexture(tex, nVertices * iTarget + vertexIndex).rgb * getDisplacementWeight(iTarget));\n}\nreturn result;\n#endif\n}\n#if CC_MORPH_TARGET_HAS_POSITION\nlayout(set = 2, binding = 7) uniform sampler2D cc_PositionDisplacements;\nvec3 getPositionDisplacement(int vertexId) {\nreturn getVec3DisplacementFromTexture(cc_PositionDisplacements, vertexId);\n}\n#endif\n#if CC_MORPH_TARGET_HAS_NORMAL\nlayout(set = 2, binding = 8) uniform sampler2D cc_NormalDisplacements;\nvec3 getNormalDisplacement(int vertexId) {\nreturn getVec3DisplacementFromTexture(cc_NormalDisplacements, vertexId);\n}\n#endif\n#if CC_MORPH_TARGET_HAS_TANGENT\nlayout(set = 2, binding = 9) uniform sampler2D cc_TangentDisplacements;\nvec3 getTangentDisplacement(int vertexId) {\nreturn getVec3DisplacementFromTexture(cc_TangentDisplacements, vertexId);\n}\n#endif\nvoid applyMorph (inout StandardVertInput attr) {\nint vertexId = getVertexId();\n#if CC_MORPH_TARGET_HAS_POSITION\nattr.position.xyz = attr.position.xyz + getPositionDisplacement(vertexId);\n#endif\n#if CC_MORPH_TARGET_HAS_NORMAL\nattr.normal.xyz = attr.normal.xyz + getNormalDisplacement(vertexId);\n#endif\n#if CC_MORPH_TARGET_HAS_TANGENT\nattr.tangent.xyz = attr.tangent.xyz + getTangentDisplacement(vertexId);\n#endif\n}\nvoid applyMorph (inout vec4 position) {\n#if CC_MORPH_TARGET_HAS_POSITION\nposition.xyz = position.xyz + getPositionDisplacement(getVertexId());\n#endif\n}\n#endif\n#if CC_USE_SKINNING\nlayout(location = 4) in u32vec4 a_joints;\nlayout(location = 5) in vec4 a_weights;\n#if CC_USE_BAKED_ANIMATION\n#if USE_INSTANCING\nlayout(location = 7) in highp vec4 a_jointAnimInfo;\n#endif\nlayout(set = 2, binding = 3) uniform CCSkinningTexture {\nhighp vec4 cc_jointTextureInfo;\n};\nlayout(set = 2, binding = 2) uniform CCSkinningAnimation {\nhighp vec4 cc_jointAnimInfo;\n};\nlayout(set = 2, binding = 6) uniform highp sampler2D cc_jointTexture;\n#else\nlayout(set = 2, binding = 3) uniform CCSkinning {\nhighp vec4 cc_joints[30 * 3];\n};\n#endif\n#if CC_USE_BAKED_ANIMATION\n#if CC_DEVICE_SUPPORT_FLOAT_TEXTURE\nmat4 getJointMatrix (float i) {\n#if USE_INSTANCING\nhighp float j = 3.0 * (a_jointAnimInfo.x * a_jointAnimInfo.y + i) + a_jointAnimInfo.z;\n#else\nhighp float j = 3.0 * (cc_jointAnimInfo.x * cc_jointTextureInfo.y + i) + cc_jointTextureInfo.z;\n#endif\nhighp float invSize = cc_jointTextureInfo.w;\nhighp float y = floor(j * invSize);\nhighp float x = floor(j - y * cc_jointTextureInfo.x);\ny = (y + 0.5) * invSize;\nvec4 v1 = texture(cc_jointTexture, vec2((x + 0.5) * invSize, y));\nvec4 v2 = texture(cc_jointTexture, vec2((x + 1.5) * invSize, y));\nvec4 v3 = texture(cc_jointTexture, vec2((x + 2.5) * invSize, y));\nreturn mat4(vec4(v1.xyz, 0.0), vec4(v2.xyz, 0.0), vec4(v3.xyz, 0.0), vec4(v1.w, v2.w, v3.w, 1.0));\n}\n#else\nmat4 getJointMatrix (float i) {\n#if USE_INSTANCING\nhighp float j = 12.0 * (a_jointAnimInfo.x * a_jointAnimInfo.y + i) + a_jointAnimInfo.z;\n#else\nhighp float j = 12.0 * (cc_jointAnimInfo.x * cc_jointTextureInfo.y + i) + cc_jointTextureInfo.z;\n#endif\nhighp float invSize = cc_jointTextureInfo.w;\nhighp float y = floor(j * invSize);\nhighp float x = floor(j - y * cc_jointTextureInfo.x);\ny = (y + 0.5) * invSize;\nvec4 v1 = vec4(\ndecode32(texture(cc_jointTexture, vec2((x + 0.5) * invSize, y))),\ndecode32(texture(cc_jointTexture, vec2((x + 1.5) * invSize, y))),\ndecode32(texture(cc_jointTexture, vec2((x + 2.5) * invSize, y))),\ndecode32(texture(cc_jointTexture, vec2((x + 3.5) * invSize, y)))\n);\nvec4 v2 = vec4(\ndecode32(texture(cc_jointTexture, vec2((x + 4.5) * invSize, y))),\ndecode32(texture(cc_jointTexture, vec2((x + 5.5) * invSize, y))),\ndecode32(texture(cc_jointTexture, vec2((x + 6.5) * invSize, y))),\ndecode32(texture(cc_jointTexture, vec2((x + 7.5) * invSize, y)))\n);\nvec4 v3 = vec4(\ndecode32(texture(cc_jointTexture, vec2((x + 8.5) * invSize, y))),\ndecode32(texture(cc_jointTexture, vec2((x + 9.5) * invSize, y))),\ndecode32(texture(cc_jointTexture, vec2((x + 10.5) * invSize, y))),\ndecode32(texture(cc_jointTexture, vec2((x + 11.5) * invSize, y)))\n);\nreturn mat4(vec4(v1.xyz, 0.0), vec4(v2.xyz, 0.0), vec4(v3.xyz, 0.0), vec4(v1.w, v2.w, v3.w, 1.0));\n}\n#endif\n#else\nmat4 getJointMatrix (float i) {\nint idx = int(i);\nvec4 v1 = cc_joints[idx * 3];\nvec4 v2 = cc_joints[idx * 3 + 1];\nvec4 v3 = cc_joints[idx * 3 + 2];\nreturn mat4(vec4(v1.xyz, 0.0), vec4(v2.xyz, 0.0), vec4(v3.xyz, 0.0), vec4(v1.w, v2.w, v3.w, 1.0));\n}\n#endif\nmat4 skinMatrix () {\nvec4 joints = vec4(a_joints);\nreturn getJointMatrix(joints.x) * a_weights.x\n+ getJointMatrix(joints.y) * a_weights.y\n+ getJointMatrix(joints.z) * a_weights.z\n+ getJointMatrix(joints.w) * a_weights.w;\n}\nvoid CCSkin (inout vec4 position) {\nmat4 m = skinMatrix();\nposition = m * position;\n}\nvoid CCSkin (inout StandardVertInput attr) {\nmat4 m = skinMatrix();\nattr.position = m * attr.position;\nattr.normal = (m * vec4(attr.normal, 0.0)).xyz;\nattr.tangent.xyz = (m * vec4(attr.tangent.xyz, 0.0)).xyz;\n}\n#endif\nlayout(set = 0, binding = 0) uniform CCGlobal {\nhighp vec4 cc_time;\nmediump vec4 cc_screenSize;\nmediump vec4 cc_nativeSize;\n};\nlayout(set = 0, binding = 1) uniform CCCamera {\nhighp mat4 cc_matView;\nhighp mat4 cc_matViewInv;\nhighp mat4 cc_matProj;\nhighp mat4 cc_matProjInv;\nhighp mat4 cc_matViewProj;\nhighp mat4 cc_matViewProjInv;\nhighp vec4 cc_cameraPos;\nmediump vec4 cc_screenScale;\nmediump vec4 cc_exposure;\nmediump vec4 cc_mainLitDir;\nmediump vec4 cc_mainLitColor;\nmediump vec4 cc_ambientSky;\nmediump vec4 cc_ambientGround;\nmediump vec4 cc_fogColor;\nmediump vec4 cc_fogBase;\nmediump vec4 cc_fogAdd;\nmediump vec4 cc_nearFar;\nmediump vec4 cc_viewPort;\n};\nlayout(location = 0) out vec2 v_uv;\nvoid main () {\nStandardVertInput In;\nIn.position = vec4(a_position, 1.0);\nIn.normal = a_normal;\nIn.tangent = a_tangent;\n#if CC_USE_MORPH\napplyMorph(In);\n#endif\n#if CC_USE_SKINNING\nCCSkin(In);\n#endif\nIn.position.xy = cc_cameraPos.w == 0.0 ? vec2(In.position.xy.x, -In.position.xy.y) : In.position.xy;\ngl_Position = In.position;\ngl_Position.y = gl_Position.y;\nv_uv = a_texCoord;\n}", + "frag": "\nprecision highp float;\nlayout(set = 0, binding = 0) uniform CCGlobal {\nhighp vec4 cc_time;\nmediump vec4 cc_screenSize;\nmediump vec4 cc_nativeSize;\n};\nlayout(set = 0, binding = 1) uniform CCCamera {\nhighp mat4 cc_matView;\nhighp mat4 cc_matViewInv;\nhighp mat4 cc_matProj;\nhighp mat4 cc_matProjInv;\nhighp mat4 cc_matViewProj;\nhighp mat4 cc_matViewProjInv;\nhighp vec4 cc_cameraPos;\nmediump vec4 cc_screenScale;\nmediump vec4 cc_exposure;\nmediump vec4 cc_mainLitDir;\nmediump vec4 cc_mainLitColor;\nmediump vec4 cc_ambientSky;\nmediump vec4 cc_ambientGround;\nmediump vec4 cc_fogColor;\nmediump vec4 cc_fogBase;\nmediump vec4 cc_fogAdd;\nmediump vec4 cc_nearFar;\nmediump vec4 cc_viewPort;\n};\nlayout(location = 0) in vec2 v_uv;\nlayout(set = 1, binding = 0) uniform BloomUBO {\nmediump vec4 texSize;\n};\nlayout(set = 1, binding = 1) uniform sampler2D bloomTexture;\nlayout(location = 0) out vec4 fragColor;\nvec3 downsample4taps(vec2 uv, vec2 halfpixel) {\nvec3 sum = texture(bloomTexture, uv + vec2(-halfpixel.x, halfpixel.y)).xyz;\nsum += texture(bloomTexture, uv + vec2(halfpixel.x, halfpixel.y)).xyz;\nsum += texture(bloomTexture, uv + vec2(halfpixel.x, -halfpixel.y)).xyz;\nsum += texture(bloomTexture, uv + vec2(-halfpixel.x, -halfpixel.y)).xyz;\nreturn sum / 4.0;\n}\nvoid main()\n{\nvec3 result = downsample4taps(v_uv, 1.0 / texSize.xy).rgb;\nfragColor = vec4(result, 1.0);\n}", + }, + { + "vert": "#extension GL_EXT_shader_explicit_arithmetic_types_int32: require\nprecision highp float;\nhighp float decode32 (highp vec4 rgba) {\nrgba = rgba * 255.0;\nhighp float Sign = 1.0 - (step(128.0, (rgba[3]) + 0.5)) * 2.0;\nhighp float Exponent = 2.0 * (mod(float(int((rgba[3]) + 0.5)), 128.0)) + (step(128.0, (rgba[2]) + 0.5)) - 127.0;\nhighp float Mantissa = (mod(float(int((rgba[2]) + 0.5)), 128.0)) * 65536.0 + rgba[1] * 256.0 + rgba[0] + 8388608.0;\nreturn Sign * exp2(Exponent - 23.0) * Mantissa;\n}\nstruct StandardVertInput {\nhighp vec4 position;\nvec3 normal;\nvec4 tangent;\n};\nlayout(location = 0) in vec3 a_position;\nlayout(location = 1) in vec3 a_normal;\nlayout(location = 2) in vec2 a_texCoord;\nlayout(location = 3) in vec4 a_tangent;\n#if CC_USE_MORPH\nint getVertexId() {\nreturn gl_VertexIndex;\n}\nlayout(set = 2, binding = 4) uniform CCMorph {\nvec4 cc_displacementWeights[15];\nvec4 cc_displacementTextureInfo;\n};\nvec2 getPixelLocation(vec2 textureResolution, int pixelIndex) {\nfloat pixelIndexF = float(pixelIndex);\nfloat x = mod(pixelIndexF, textureResolution.x);\nfloat y = floor(pixelIndexF / textureResolution.x);\nreturn vec2(x, y);\n}\nvec2 getPixelCoordFromLocation(vec2 location, vec2 textureResolution) {\nreturn (vec2(location.x, location.y) + .5) / textureResolution;\n}\n#if CC_DEVICE_SUPPORT_FLOAT_TEXTURE\nvec4 fetchVec3ArrayFromTexture(sampler2D tex, int pixelIndex) {\nivec2 texSize = textureSize(tex, 0);\nreturn texelFetch(tex, ivec2(pixelIndex % texSize.x, pixelIndex / texSize.x), 0);\n}\n#else\nvec4 fetchVec3ArrayFromTexture(sampler2D tex, int elementIndex) {\nint pixelIndex = elementIndex * 4;\nvec2 location = getPixelLocation(cc_displacementTextureInfo.xy, pixelIndex);\nvec2 x = getPixelCoordFromLocation(location + vec2(0.0, 0.0), cc_displacementTextureInfo.xy);\nvec2 y = getPixelCoordFromLocation(location + vec2(1.0, 0.0), cc_displacementTextureInfo.xy);\nvec2 z = getPixelCoordFromLocation(location + vec2(2.0, 0.0), cc_displacementTextureInfo.xy);\nreturn vec4(\ndecode32(texture(tex, x)),\ndecode32(texture(tex, y)),\ndecode32(texture(tex, z)),\n1.0\n);\n}\n#endif\nfloat getDisplacementWeight(int index) {\nint quot = index / 4;\nint remainder = index - quot * 4;\nif (remainder == 0) {\nreturn cc_displacementWeights[quot].x;\n} else if (remainder == 1) {\nreturn cc_displacementWeights[quot].y;\n} else if (remainder == 2) {\nreturn cc_displacementWeights[quot].z;\n} else {\nreturn cc_displacementWeights[quot].w;\n}\n}\nvec3 getVec3DisplacementFromTexture(sampler2D tex, int vertexIndex) {\n#if CC_MORPH_PRECOMPUTED\nreturn fetchVec3ArrayFromTexture(tex, vertexIndex).rgb;\n#else\nvec3 result = vec3(0, 0, 0);\nint nVertices = int(cc_displacementTextureInfo.z);\nfor (int iTarget = 0; iTarget < CC_MORPH_TARGET_COUNT; ++iTarget) {\nresult += (fetchVec3ArrayFromTexture(tex, nVertices * iTarget + vertexIndex).rgb * getDisplacementWeight(iTarget));\n}\nreturn result;\n#endif\n}\n#if CC_MORPH_TARGET_HAS_POSITION\nlayout(set = 2, binding = 7) uniform sampler2D cc_PositionDisplacements;\nvec3 getPositionDisplacement(int vertexId) {\nreturn getVec3DisplacementFromTexture(cc_PositionDisplacements, vertexId);\n}\n#endif\n#if CC_MORPH_TARGET_HAS_NORMAL\nlayout(set = 2, binding = 8) uniform sampler2D cc_NormalDisplacements;\nvec3 getNormalDisplacement(int vertexId) {\nreturn getVec3DisplacementFromTexture(cc_NormalDisplacements, vertexId);\n}\n#endif\n#if CC_MORPH_TARGET_HAS_TANGENT\nlayout(set = 2, binding = 9) uniform sampler2D cc_TangentDisplacements;\nvec3 getTangentDisplacement(int vertexId) {\nreturn getVec3DisplacementFromTexture(cc_TangentDisplacements, vertexId);\n}\n#endif\nvoid applyMorph (inout StandardVertInput attr) {\nint vertexId = getVertexId();\n#if CC_MORPH_TARGET_HAS_POSITION\nattr.position.xyz = attr.position.xyz + getPositionDisplacement(vertexId);\n#endif\n#if CC_MORPH_TARGET_HAS_NORMAL\nattr.normal.xyz = attr.normal.xyz + getNormalDisplacement(vertexId);\n#endif\n#if CC_MORPH_TARGET_HAS_TANGENT\nattr.tangent.xyz = attr.tangent.xyz + getTangentDisplacement(vertexId);\n#endif\n}\nvoid applyMorph (inout vec4 position) {\n#if CC_MORPH_TARGET_HAS_POSITION\nposition.xyz = position.xyz + getPositionDisplacement(getVertexId());\n#endif\n}\n#endif\n#if CC_USE_SKINNING\nlayout(location = 4) in u32vec4 a_joints;\nlayout(location = 5) in vec4 a_weights;\n#if CC_USE_BAKED_ANIMATION\n#if USE_INSTANCING\nlayout(location = 7) in highp vec4 a_jointAnimInfo;\n#endif\nlayout(set = 2, binding = 3) uniform CCSkinningTexture {\nhighp vec4 cc_jointTextureInfo;\n};\nlayout(set = 2, binding = 2) uniform CCSkinningAnimation {\nhighp vec4 cc_jointAnimInfo;\n};\nlayout(set = 2, binding = 6) uniform highp sampler2D cc_jointTexture;\n#else\nlayout(set = 2, binding = 3) uniform CCSkinning {\nhighp vec4 cc_joints[30 * 3];\n};\n#endif\n#if CC_USE_BAKED_ANIMATION\n#if CC_DEVICE_SUPPORT_FLOAT_TEXTURE\nmat4 getJointMatrix (float i) {\n#if USE_INSTANCING\nhighp float j = 3.0 * (a_jointAnimInfo.x * a_jointAnimInfo.y + i) + a_jointAnimInfo.z;\n#else\nhighp float j = 3.0 * (cc_jointAnimInfo.x * cc_jointTextureInfo.y + i) + cc_jointTextureInfo.z;\n#endif\nhighp float invSize = cc_jointTextureInfo.w;\nhighp float y = floor(j * invSize);\nhighp float x = floor(j - y * cc_jointTextureInfo.x);\ny = (y + 0.5) * invSize;\nvec4 v1 = texture(cc_jointTexture, vec2((x + 0.5) * invSize, y));\nvec4 v2 = texture(cc_jointTexture, vec2((x + 1.5) * invSize, y));\nvec4 v3 = texture(cc_jointTexture, vec2((x + 2.5) * invSize, y));\nreturn mat4(vec4(v1.xyz, 0.0), vec4(v2.xyz, 0.0), vec4(v3.xyz, 0.0), vec4(v1.w, v2.w, v3.w, 1.0));\n}\n#else\nmat4 getJointMatrix (float i) {\n#if USE_INSTANCING\nhighp float j = 12.0 * (a_jointAnimInfo.x * a_jointAnimInfo.y + i) + a_jointAnimInfo.z;\n#else\nhighp float j = 12.0 * (cc_jointAnimInfo.x * cc_jointTextureInfo.y + i) + cc_jointTextureInfo.z;\n#endif\nhighp float invSize = cc_jointTextureInfo.w;\nhighp float y = floor(j * invSize);\nhighp float x = floor(j - y * cc_jointTextureInfo.x);\ny = (y + 0.5) * invSize;\nvec4 v1 = vec4(\ndecode32(texture(cc_jointTexture, vec2((x + 0.5) * invSize, y))),\ndecode32(texture(cc_jointTexture, vec2((x + 1.5) * invSize, y))),\ndecode32(texture(cc_jointTexture, vec2((x + 2.5) * invSize, y))),\ndecode32(texture(cc_jointTexture, vec2((x + 3.5) * invSize, y)))\n);\nvec4 v2 = vec4(\ndecode32(texture(cc_jointTexture, vec2((x + 4.5) * invSize, y))),\ndecode32(texture(cc_jointTexture, vec2((x + 5.5) * invSize, y))),\ndecode32(texture(cc_jointTexture, vec2((x + 6.5) * invSize, y))),\ndecode32(texture(cc_jointTexture, vec2((x + 7.5) * invSize, y)))\n);\nvec4 v3 = vec4(\ndecode32(texture(cc_jointTexture, vec2((x + 8.5) * invSize, y))),\ndecode32(texture(cc_jointTexture, vec2((x + 9.5) * invSize, y))),\ndecode32(texture(cc_jointTexture, vec2((x + 10.5) * invSize, y))),\ndecode32(texture(cc_jointTexture, vec2((x + 11.5) * invSize, y)))\n);\nreturn mat4(vec4(v1.xyz, 0.0), vec4(v2.xyz, 0.0), vec4(v3.xyz, 0.0), vec4(v1.w, v2.w, v3.w, 1.0));\n}\n#endif\n#else\nmat4 getJointMatrix (float i) {\nint idx = int(i);\nvec4 v1 = cc_joints[idx * 3];\nvec4 v2 = cc_joints[idx * 3 + 1];\nvec4 v3 = cc_joints[idx * 3 + 2];\nreturn mat4(vec4(v1.xyz, 0.0), vec4(v2.xyz, 0.0), vec4(v3.xyz, 0.0), vec4(v1.w, v2.w, v3.w, 1.0));\n}\n#endif\nmat4 skinMatrix () {\nvec4 joints = vec4(a_joints);\nreturn getJointMatrix(joints.x) * a_weights.x\n+ getJointMatrix(joints.y) * a_weights.y\n+ getJointMatrix(joints.z) * a_weights.z\n+ getJointMatrix(joints.w) * a_weights.w;\n}\nvoid CCSkin (inout vec4 position) {\nmat4 m = skinMatrix();\nposition = m * position;\n}\nvoid CCSkin (inout StandardVertInput attr) {\nmat4 m = skinMatrix();\nattr.position = m * attr.position;\nattr.normal = (m * vec4(attr.normal, 0.0)).xyz;\nattr.tangent.xyz = (m * vec4(attr.tangent.xyz, 0.0)).xyz;\n}\n#endif\nlayout(set = 0, binding = 0) uniform CCGlobal {\nhighp vec4 cc_time;\nmediump vec4 cc_screenSize;\nmediump vec4 cc_nativeSize;\n};\nlayout(set = 0, binding = 1) uniform CCCamera {\nhighp mat4 cc_matView;\nhighp mat4 cc_matViewInv;\nhighp mat4 cc_matProj;\nhighp mat4 cc_matProjInv;\nhighp mat4 cc_matViewProj;\nhighp mat4 cc_matViewProjInv;\nhighp vec4 cc_cameraPos;\nmediump vec4 cc_screenScale;\nmediump vec4 cc_exposure;\nmediump vec4 cc_mainLitDir;\nmediump vec4 cc_mainLitColor;\nmediump vec4 cc_ambientSky;\nmediump vec4 cc_ambientGround;\nmediump vec4 cc_fogColor;\nmediump vec4 cc_fogBase;\nmediump vec4 cc_fogAdd;\nmediump vec4 cc_nearFar;\nmediump vec4 cc_viewPort;\n};\nlayout(location = 0) out vec2 v_uv;\nvoid main () {\nStandardVertInput In;\nIn.position = vec4(a_position, 1.0);\nIn.normal = a_normal;\nIn.tangent = a_tangent;\n#if CC_USE_MORPH\napplyMorph(In);\n#endif\n#if CC_USE_SKINNING\nCCSkin(In);\n#endif\nIn.position.xy = cc_cameraPos.w == 0.0 ? vec2(In.position.xy.x, -In.position.xy.y) : In.position.xy;\ngl_Position = In.position;\ngl_Position.y = gl_Position.y;\nv_uv = a_texCoord;\n}", + "frag": "\nprecision highp float;\nlayout(set = 0, binding = 0) uniform CCGlobal {\nhighp vec4 cc_time;\nmediump vec4 cc_screenSize;\nmediump vec4 cc_nativeSize;\n};\nlayout(set = 0, binding = 1) uniform CCCamera {\nhighp mat4 cc_matView;\nhighp mat4 cc_matViewInv;\nhighp mat4 cc_matProj;\nhighp mat4 cc_matProjInv;\nhighp mat4 cc_matViewProj;\nhighp mat4 cc_matViewProjInv;\nhighp vec4 cc_cameraPos;\nmediump vec4 cc_screenScale;\nmediump vec4 cc_exposure;\nmediump vec4 cc_mainLitDir;\nmediump vec4 cc_mainLitColor;\nmediump vec4 cc_ambientSky;\nmediump vec4 cc_ambientGround;\nmediump vec4 cc_fogColor;\nmediump vec4 cc_fogBase;\nmediump vec4 cc_fogAdd;\nmediump vec4 cc_nearFar;\nmediump vec4 cc_viewPort;\n};\nlayout(location = 0) in vec2 v_uv;\nlayout(set = 1, binding = 0) uniform BloomUBO {\nmediump vec4 texSize;\n};\nlayout(set = 1, binding = 1) uniform sampler2D bloomTexture;\nlayout(location = 0) out vec4 fragColor;\nvec3 upsample4taps(vec2 uv, vec2 halfpixel) {\nvec3 sum = texture(bloomTexture, uv + vec2(-halfpixel.x, halfpixel.y)).xyz;\nsum += texture(bloomTexture, uv + vec2(halfpixel.x, halfpixel.y)).xyz;\nsum += texture(bloomTexture, uv + vec2(halfpixel.x, -halfpixel.y)).xyz;\nsum += texture(bloomTexture, uv + vec2(-halfpixel.x, -halfpixel.y)).xyz;\nreturn sum / 4.0;\n}\nvoid main() {\nvec3 result = upsample4taps(v_uv, 0.5 / texSize.xy).rgb;\nfragColor = vec4(result, 1.0);\n}", + }, + { + "vert": "#extension GL_EXT_shader_explicit_arithmetic_types_int32: require\nprecision highp float;\nhighp float decode32 (highp vec4 rgba) {\nrgba = rgba * 255.0;\nhighp float Sign = 1.0 - (step(128.0, (rgba[3]) + 0.5)) * 2.0;\nhighp float Exponent = 2.0 * (mod(float(int((rgba[3]) + 0.5)), 128.0)) + (step(128.0, (rgba[2]) + 0.5)) - 127.0;\nhighp float Mantissa = (mod(float(int((rgba[2]) + 0.5)), 128.0)) * 65536.0 + rgba[1] * 256.0 + rgba[0] + 8388608.0;\nreturn Sign * exp2(Exponent - 23.0) * Mantissa;\n}\nstruct StandardVertInput {\nhighp vec4 position;\nvec3 normal;\nvec4 tangent;\n};\nlayout(location = 0) in vec3 a_position;\nlayout(location = 1) in vec3 a_normal;\nlayout(location = 2) in vec2 a_texCoord;\nlayout(location = 3) in vec4 a_tangent;\n#if CC_USE_MORPH\nint getVertexId() {\nreturn gl_VertexIndex;\n}\nlayout(set = 2, binding = 4) uniform CCMorph {\nvec4 cc_displacementWeights[15];\nvec4 cc_displacementTextureInfo;\n};\nvec2 getPixelLocation(vec2 textureResolution, int pixelIndex) {\nfloat pixelIndexF = float(pixelIndex);\nfloat x = mod(pixelIndexF, textureResolution.x);\nfloat y = floor(pixelIndexF / textureResolution.x);\nreturn vec2(x, y);\n}\nvec2 getPixelCoordFromLocation(vec2 location, vec2 textureResolution) {\nreturn (vec2(location.x, location.y) + .5) / textureResolution;\n}\n#if CC_DEVICE_SUPPORT_FLOAT_TEXTURE\nvec4 fetchVec3ArrayFromTexture(sampler2D tex, int pixelIndex) {\nivec2 texSize = textureSize(tex, 0);\nreturn texelFetch(tex, ivec2(pixelIndex % texSize.x, pixelIndex / texSize.x), 0);\n}\n#else\nvec4 fetchVec3ArrayFromTexture(sampler2D tex, int elementIndex) {\nint pixelIndex = elementIndex * 4;\nvec2 location = getPixelLocation(cc_displacementTextureInfo.xy, pixelIndex);\nvec2 x = getPixelCoordFromLocation(location + vec2(0.0, 0.0), cc_displacementTextureInfo.xy);\nvec2 y = getPixelCoordFromLocation(location + vec2(1.0, 0.0), cc_displacementTextureInfo.xy);\nvec2 z = getPixelCoordFromLocation(location + vec2(2.0, 0.0), cc_displacementTextureInfo.xy);\nreturn vec4(\ndecode32(texture(tex, x)),\ndecode32(texture(tex, y)),\ndecode32(texture(tex, z)),\n1.0\n);\n}\n#endif\nfloat getDisplacementWeight(int index) {\nint quot = index / 4;\nint remainder = index - quot * 4;\nif (remainder == 0) {\nreturn cc_displacementWeights[quot].x;\n} else if (remainder == 1) {\nreturn cc_displacementWeights[quot].y;\n} else if (remainder == 2) {\nreturn cc_displacementWeights[quot].z;\n} else {\nreturn cc_displacementWeights[quot].w;\n}\n}\nvec3 getVec3DisplacementFromTexture(sampler2D tex, int vertexIndex) {\n#if CC_MORPH_PRECOMPUTED\nreturn fetchVec3ArrayFromTexture(tex, vertexIndex).rgb;\n#else\nvec3 result = vec3(0, 0, 0);\nint nVertices = int(cc_displacementTextureInfo.z);\nfor (int iTarget = 0; iTarget < CC_MORPH_TARGET_COUNT; ++iTarget) {\nresult += (fetchVec3ArrayFromTexture(tex, nVertices * iTarget + vertexIndex).rgb * getDisplacementWeight(iTarget));\n}\nreturn result;\n#endif\n}\n#if CC_MORPH_TARGET_HAS_POSITION\nlayout(set = 2, binding = 7) uniform sampler2D cc_PositionDisplacements;\nvec3 getPositionDisplacement(int vertexId) {\nreturn getVec3DisplacementFromTexture(cc_PositionDisplacements, vertexId);\n}\n#endif\n#if CC_MORPH_TARGET_HAS_NORMAL\nlayout(set = 2, binding = 8) uniform sampler2D cc_NormalDisplacements;\nvec3 getNormalDisplacement(int vertexId) {\nreturn getVec3DisplacementFromTexture(cc_NormalDisplacements, vertexId);\n}\n#endif\n#if CC_MORPH_TARGET_HAS_TANGENT\nlayout(set = 2, binding = 9) uniform sampler2D cc_TangentDisplacements;\nvec3 getTangentDisplacement(int vertexId) {\nreturn getVec3DisplacementFromTexture(cc_TangentDisplacements, vertexId);\n}\n#endif\nvoid applyMorph (inout StandardVertInput attr) {\nint vertexId = getVertexId();\n#if CC_MORPH_TARGET_HAS_POSITION\nattr.position.xyz = attr.position.xyz + getPositionDisplacement(vertexId);\n#endif\n#if CC_MORPH_TARGET_HAS_NORMAL\nattr.normal.xyz = attr.normal.xyz + getNormalDisplacement(vertexId);\n#endif\n#if CC_MORPH_TARGET_HAS_TANGENT\nattr.tangent.xyz = attr.tangent.xyz + getTangentDisplacement(vertexId);\n#endif\n}\nvoid applyMorph (inout vec4 position) {\n#if CC_MORPH_TARGET_HAS_POSITION\nposition.xyz = position.xyz + getPositionDisplacement(getVertexId());\n#endif\n}\n#endif\n#if CC_USE_SKINNING\nlayout(location = 4) in u32vec4 a_joints;\nlayout(location = 5) in vec4 a_weights;\n#if CC_USE_BAKED_ANIMATION\n#if USE_INSTANCING\nlayout(location = 7) in highp vec4 a_jointAnimInfo;\n#endif\nlayout(set = 2, binding = 3) uniform CCSkinningTexture {\nhighp vec4 cc_jointTextureInfo;\n};\nlayout(set = 2, binding = 2) uniform CCSkinningAnimation {\nhighp vec4 cc_jointAnimInfo;\n};\nlayout(set = 2, binding = 6) uniform highp sampler2D cc_jointTexture;\n#else\nlayout(set = 2, binding = 3) uniform CCSkinning {\nhighp vec4 cc_joints[30 * 3];\n};\n#endif\n#if CC_USE_BAKED_ANIMATION\n#if CC_DEVICE_SUPPORT_FLOAT_TEXTURE\nmat4 getJointMatrix (float i) {\n#if USE_INSTANCING\nhighp float j = 3.0 * (a_jointAnimInfo.x * a_jointAnimInfo.y + i) + a_jointAnimInfo.z;\n#else\nhighp float j = 3.0 * (cc_jointAnimInfo.x * cc_jointTextureInfo.y + i) + cc_jointTextureInfo.z;\n#endif\nhighp float invSize = cc_jointTextureInfo.w;\nhighp float y = floor(j * invSize);\nhighp float x = floor(j - y * cc_jointTextureInfo.x);\ny = (y + 0.5) * invSize;\nvec4 v1 = texture(cc_jointTexture, vec2((x + 0.5) * invSize, y));\nvec4 v2 = texture(cc_jointTexture, vec2((x + 1.5) * invSize, y));\nvec4 v3 = texture(cc_jointTexture, vec2((x + 2.5) * invSize, y));\nreturn mat4(vec4(v1.xyz, 0.0), vec4(v2.xyz, 0.0), vec4(v3.xyz, 0.0), vec4(v1.w, v2.w, v3.w, 1.0));\n}\n#else\nmat4 getJointMatrix (float i) {\n#if USE_INSTANCING\nhighp float j = 12.0 * (a_jointAnimInfo.x * a_jointAnimInfo.y + i) + a_jointAnimInfo.z;\n#else\nhighp float j = 12.0 * (cc_jointAnimInfo.x * cc_jointTextureInfo.y + i) + cc_jointTextureInfo.z;\n#endif\nhighp float invSize = cc_jointTextureInfo.w;\nhighp float y = floor(j * invSize);\nhighp float x = floor(j - y * cc_jointTextureInfo.x);\ny = (y + 0.5) * invSize;\nvec4 v1 = vec4(\ndecode32(texture(cc_jointTexture, vec2((x + 0.5) * invSize, y))),\ndecode32(texture(cc_jointTexture, vec2((x + 1.5) * invSize, y))),\ndecode32(texture(cc_jointTexture, vec2((x + 2.5) * invSize, y))),\ndecode32(texture(cc_jointTexture, vec2((x + 3.5) * invSize, y)))\n);\nvec4 v2 = vec4(\ndecode32(texture(cc_jointTexture, vec2((x + 4.5) * invSize, y))),\ndecode32(texture(cc_jointTexture, vec2((x + 5.5) * invSize, y))),\ndecode32(texture(cc_jointTexture, vec2((x + 6.5) * invSize, y))),\ndecode32(texture(cc_jointTexture, vec2((x + 7.5) * invSize, y)))\n);\nvec4 v3 = vec4(\ndecode32(texture(cc_jointTexture, vec2((x + 8.5) * invSize, y))),\ndecode32(texture(cc_jointTexture, vec2((x + 9.5) * invSize, y))),\ndecode32(texture(cc_jointTexture, vec2((x + 10.5) * invSize, y))),\ndecode32(texture(cc_jointTexture, vec2((x + 11.5) * invSize, y)))\n);\nreturn mat4(vec4(v1.xyz, 0.0), vec4(v2.xyz, 0.0), vec4(v3.xyz, 0.0), vec4(v1.w, v2.w, v3.w, 1.0));\n}\n#endif\n#else\nmat4 getJointMatrix (float i) {\nint idx = int(i);\nvec4 v1 = cc_joints[idx * 3];\nvec4 v2 = cc_joints[idx * 3 + 1];\nvec4 v3 = cc_joints[idx * 3 + 2];\nreturn mat4(vec4(v1.xyz, 0.0), vec4(v2.xyz, 0.0), vec4(v3.xyz, 0.0), vec4(v1.w, v2.w, v3.w, 1.0));\n}\n#endif\nmat4 skinMatrix () {\nvec4 joints = vec4(a_joints);\nreturn getJointMatrix(joints.x) * a_weights.x\n+ getJointMatrix(joints.y) * a_weights.y\n+ getJointMatrix(joints.z) * a_weights.z\n+ getJointMatrix(joints.w) * a_weights.w;\n}\nvoid CCSkin (inout vec4 position) {\nmat4 m = skinMatrix();\nposition = m * position;\n}\nvoid CCSkin (inout StandardVertInput attr) {\nmat4 m = skinMatrix();\nattr.position = m * attr.position;\nattr.normal = (m * vec4(attr.normal, 0.0)).xyz;\nattr.tangent.xyz = (m * vec4(attr.tangent.xyz, 0.0)).xyz;\n}\n#endif\nlayout(set = 0, binding = 0) uniform CCGlobal {\nhighp vec4 cc_time;\nmediump vec4 cc_screenSize;\nmediump vec4 cc_nativeSize;\n};\nlayout(set = 0, binding = 1) uniform CCCamera {\nhighp mat4 cc_matView;\nhighp mat4 cc_matViewInv;\nhighp mat4 cc_matProj;\nhighp mat4 cc_matProjInv;\nhighp mat4 cc_matViewProj;\nhighp mat4 cc_matViewProjInv;\nhighp vec4 cc_cameraPos;\nmediump vec4 cc_screenScale;\nmediump vec4 cc_exposure;\nmediump vec4 cc_mainLitDir;\nmediump vec4 cc_mainLitColor;\nmediump vec4 cc_ambientSky;\nmediump vec4 cc_ambientGround;\nmediump vec4 cc_fogColor;\nmediump vec4 cc_fogBase;\nmediump vec4 cc_fogAdd;\nmediump vec4 cc_nearFar;\nmediump vec4 cc_viewPort;\n};\nlayout(location = 0) out vec2 v_uv;\nvoid main () {\nStandardVertInput In;\nIn.position = vec4(a_position, 1.0);\nIn.normal = a_normal;\nIn.tangent = a_tangent;\n#if CC_USE_MORPH\napplyMorph(In);\n#endif\n#if CC_USE_SKINNING\nCCSkin(In);\n#endif\nIn.position.xy = cc_cameraPos.w == 0.0 ? vec2(In.position.xy.x, -In.position.xy.y) : In.position.xy;\ngl_Position = In.position;\ngl_Position.y = gl_Position.y;\nv_uv = a_texCoord;\n}", + "frag": "\nprecision highp float;\nlayout(set = 0, binding = 0) uniform CCGlobal {\nhighp vec4 cc_time;\nmediump vec4 cc_screenSize;\nmediump vec4 cc_nativeSize;\n};\nlayout(set = 0, binding = 1) uniform CCCamera {\nhighp mat4 cc_matView;\nhighp mat4 cc_matViewInv;\nhighp mat4 cc_matProj;\nhighp mat4 cc_matProjInv;\nhighp mat4 cc_matViewProj;\nhighp mat4 cc_matViewProjInv;\nhighp vec4 cc_cameraPos;\nmediump vec4 cc_screenScale;\nmediump vec4 cc_exposure;\nmediump vec4 cc_mainLitDir;\nmediump vec4 cc_mainLitColor;\nmediump vec4 cc_ambientSky;\nmediump vec4 cc_ambientGround;\nmediump vec4 cc_fogColor;\nmediump vec4 cc_fogBase;\nmediump vec4 cc_fogAdd;\nmediump vec4 cc_nearFar;\nmediump vec4 cc_viewPort;\n};\nlayout(location = 0) in vec2 v_uv;\nlayout(set = 1, binding = 0) uniform BloomUBO {\nmediump vec4 texSize;\n};\nlayout(set = 1, binding = 1) uniform sampler2D outputResultMap;\nlayout(set = 1, binding = 2) uniform sampler2D bloomTexture;\nlayout(location = 0) out vec4 fragColor;\nvoid main() {\nvec4 hdrColor = texture(outputResultMap, v_uv);\nvec3 bloomColor = texture(bloomTexture, v_uv).rgb;\nvec3 result = hdrColor.rgb + bloomColor * texSize.w * hdrColor.a;\nfragColor = vec4(result, hdrColor.a);\n}", + } + ], + [ + { + "vert": "\nprecision highp float;\nstruct StandardVertInput {\nhighp vec4 position;\nvec3 normal;\nvec4 tangent;\n};\nlayout(location = 0) in vec3 a_position;\nlayout(location = 1) in vec3 a_normal;\nlayout(location = 2) in vec2 a_texCoord;\nlayout(location = 3) in vec4 a_tangent;\nlayout(set = 0, binding = 0) uniform CCGlobal {\nhighp vec4 cc_time;\nmediump vec4 cc_screenSize;\nmediump vec4 cc_nativeSize;\n};\nlayout(set = 0, binding = 1) uniform CCCamera {\nhighp mat4 cc_matView;\nhighp mat4 cc_matViewInv;\nhighp mat4 cc_matProj;\nhighp mat4 cc_matProjInv;\nhighp mat4 cc_matViewProj;\nhighp mat4 cc_matViewProjInv;\nhighp vec4 cc_cameraPos;\nmediump vec4 cc_screenScale;\nmediump vec4 cc_exposure;\nmediump vec4 cc_mainLitDir;\nmediump vec4 cc_mainLitColor;\nmediump vec4 cc_ambientSky;\nmediump vec4 cc_ambientGround;\nmediump vec4 cc_fogColor;\nmediump vec4 cc_fogBase;\nmediump vec4 cc_fogAdd;\nmediump vec4 cc_nearFar;\nmediump vec4 cc_viewPort;\n};\nlayout(location = 0) out vec2 v_uv;\nvoid main () {\nvec4 position;\nposition = vec4(a_position, 1.0);\nposition.xy = cc_cameraPos.w == 0.0 ? vec2(position.xy.x, -position.xy.y) : position.xy;\ngl_Position = vec4(position.x, position.y, 1.0, 1.0);\nv_uv = a_texCoord;\n}", + "frag": "\nprecision highp float;\nlayout(set = 0, binding = 0) uniform CCGlobal {\nhighp vec4 cc_time;\nmediump vec4 cc_screenSize;\nmediump vec4 cc_nativeSize;\n};\nlayout(set = 0, binding = 1) uniform CCCamera {\nhighp mat4 cc_matView;\nhighp mat4 cc_matViewInv;\nhighp mat4 cc_matProj;\nhighp mat4 cc_matProjInv;\nhighp mat4 cc_matViewProj;\nhighp mat4 cc_matViewProjInv;\nhighp vec4 cc_cameraPos;\nmediump vec4 cc_screenScale;\nmediump vec4 cc_exposure;\nmediump vec4 cc_mainLitDir;\nmediump vec4 cc_mainLitColor;\nmediump vec4 cc_ambientSky;\nmediump vec4 cc_ambientGround;\nmediump vec4 cc_fogColor;\nmediump vec4 cc_fogBase;\nmediump vec4 cc_fogAdd;\nmediump vec4 cc_nearFar;\nmediump vec4 cc_viewPort;\n};\nvec3 SRGBToLinear (vec3 gamma) {\nreturn gamma * gamma;\n}\nlayout(set = 0, binding = 2) uniform CCShadow {\nhighp mat4 cc_matLightPlaneProj;\nhighp mat4 cc_matLightView;\nhighp mat4 cc_matLightViewProj;\nhighp vec4 cc_shadowInvProjDepthInfo;\nhighp vec4 cc_shadowProjDepthInfo;\nhighp vec4 cc_shadowProjInfo;\nlowp vec4 cc_shadowNFLSInfo;\nlowp vec4 cc_shadowWHPBInfo;\nlowp vec4 cc_shadowLPNNInfo;\nlowp vec4 cc_shadowColor;\n};\nfloat CCGetLinearDepthFromViewSpace(vec3 viewPos) {\nfloat dist = length(viewPos);\nreturn (dist - cc_shadowNFLSInfo.x) / (cc_shadowNFLSInfo.y - cc_shadowNFLSInfo.x);\n}\nfloat CCGetLinearDepth(vec3 worldPos) {\nvec4 viewStartPos = cc_matLightView * vec4(worldPos.xyz, 1.0);\nreturn CCGetLinearDepthFromViewSpace(viewStartPos.xyz);\n}\n#if CC_RECEIVE_SHADOW\nlayout(set = 0, binding = 3) uniform highp sampler2D cc_shadowMap;\nlayout(set = 0, binding = 5) uniform highp sampler2D cc_spotLightingMap;\nvec4 ApplyShadowDepthBias_FaceNormal(vec4 shadowPos, vec3 worldNormal)\n{\nvec4 newShadowPos = shadowPos;\nif(cc_shadowLPNNInfo.z > 0.0001)\n{\nvec4 viewNormal = cc_matLightView * vec4(worldNormal, 0.0);\nif(viewNormal.z < 0.1)\nnewShadowPos.xy += viewNormal.xy * cc_shadowProjInfo.xy * cc_shadowLPNNInfo.z * clamp(viewNormal.z, 0.001, 0.1);\n}\nreturn newShadowPos;\n}\nvec4 ApplyShadowDepthBias_Perspective(vec4 shadowPos, float viewspaceDepthBias)\n{\nvec3 viewSpacePos;\nviewSpacePos.xy = shadowPos.xy * cc_shadowProjInfo.zw;\nviewSpacePos.z = shadowPos.z * cc_shadowInvProjDepthInfo.x + shadowPos.w * cc_shadowInvProjDepthInfo.y;\nviewSpacePos.xyz += cc_shadowProjDepthInfo.z * normalize(viewSpacePos.xyz) * viewspaceDepthBias;\nvec4 clipSpacePos;\nclipSpacePos.xy = viewSpacePos.xy * cc_shadowProjInfo.xy;\nclipSpacePos.zw = viewSpacePos.z * cc_shadowProjDepthInfo.xz + vec2(cc_shadowProjDepthInfo.y, 0.0);\nif (cc_shadowNFLSInfo.z > 0.000001) {\nclipSpacePos.z = CCGetLinearDepthFromViewSpace(viewSpacePos.xyz);\nclipSpacePos.z = (clipSpacePos.z * 2.0 - 1.0) * clipSpacePos.w;\n}\nreturn clipSpacePos;\n}\nvec4 ApplyShadowDepthBias_Orthographic(vec4 shadowPos, float viewspaceDepthBias)\n{\nfloat coeffA = cc_shadowProjDepthInfo.x;\nfloat coeffB = cc_shadowProjDepthInfo.y;\nfloat viewSpacePos_z = (shadowPos.z - coeffB) / coeffA;\nviewSpacePos_z += viewspaceDepthBias;\nvec4 result = shadowPos;\nresult.z = viewSpacePos_z * coeffA + coeffB;\nreturn result;\n}\nfloat CCGetShadowFactorHard (vec4 shadowPos) {\nvec4 clipPosNew = ApplyShadowDepthBias_Orthographic(shadowPos, cc_shadowWHPBInfo.w);\nvec3 clipPos = clipPosNew.xyz / clipPosNew.w * 0.5 + 0.5;\nif (clipPos.x < 0.0 || clipPos.x > 1.0 ||\nclipPos.y < 0.0 || clipPos.y > 1.0 ||\nclipPos.z < 0.0 || clipPos.z > 1.0) { return 1.0; }\nclipPos.xy = cc_cameraPos.w == 1.0 ? vec2(clipPos.xy.x, 1.0 - clipPos.xy.y) : clipPos.xy;\nfloat shadow = 0.0;\nfloat closestDepth = 0.0;\nif (cc_shadowLPNNInfo.y > 0.000001) {\nclosestDepth = dot(texture(cc_shadowMap, clipPos.xy), vec4(1.0, 1.0 / 255.0, 1.0 / 65025.0, 1.0 / 16581375.0));\n} else {\nclosestDepth = texture(cc_shadowMap, clipPos.xy).x;\n}\nshadow = step(clipPos.z, closestDepth);\nreturn shadow;\n}\nfloat CCGetShadowFactorSoft (vec4 shadowPos) {\nvec4 clipPosNew = ApplyShadowDepthBias_Orthographic(shadowPos, cc_shadowWHPBInfo.w);\nvec3 clipPos = clipPosNew.xyz / clipPosNew.w * 0.5 + 0.5;\nif (clipPos.x < 0.0 || clipPos.x > 1.0 ||\nclipPos.y < 0.0 || clipPos.y > 1.0 ||\nclipPos.z < 0.0 || clipPos.z > 1.0) { return 1.0; }\nclipPos.xy = cc_cameraPos.w == 1.0 ? vec2(clipPos.xy.x, 1.0 - clipPos.xy.y) : clipPos.xy;\nfloat offsetDepth = clipPos.z;\nvec2 mapSize = cc_shadowWHPBInfo.xy;\nvec2 oneTap = 1.0 / mapSize;\nvec2 clipPos_offset = clipPos.xy + oneTap;\nfloat block0, block1, block2, block3;\nif (cc_shadowLPNNInfo.y > 0.000001) {\nblock0 = step(offsetDepth, dot(texture(cc_shadowMap, vec2(clipPos.x, clipPos.y)), vec4(1.0, 1.0 / 255.0, 1.0 / 65025.0, 1.0 / 16581375.0)));\nblock1 = step(offsetDepth, dot(texture(cc_shadowMap, vec2(clipPos_offset.x, clipPos.y)), vec4(1.0, 1.0 / 255.0, 1.0 / 65025.0, 1.0 / 16581375.0)));\nblock2 = step(offsetDepth, dot(texture(cc_shadowMap, vec2(clipPos.x, clipPos_offset.y)), vec4(1.0, 1.0 / 255.0, 1.0 / 65025.0, 1.0 / 16581375.0)));\nblock3 = step(offsetDepth, dot(texture(cc_shadowMap, vec2(clipPos_offset.x, clipPos_offset.y)), vec4(1.0, 1.0 / 255.0, 1.0 / 65025.0, 1.0 / 16581375.0)));\n} else {\nblock0 = step(offsetDepth, texture(cc_shadowMap, vec2(clipPos.x, clipPos.y)).x);\nblock1 = step(offsetDepth, texture(cc_shadowMap, vec2(clipPos_offset.x, clipPos.y)).x);\nblock2 = step(offsetDepth, texture(cc_shadowMap, vec2(clipPos.x, clipPos_offset.y)).x);\nblock3 = step(offsetDepth, texture(cc_shadowMap, vec2(clipPos_offset.x, clipPos_offset.y)).x);\n}\nfloat coefX = mod(clipPos.x, oneTap.x) * mapSize.x;\nfloat resultX = mix(block0, block1, coefX);\nfloat resultY = mix(block2, block3, coefX);\nfloat coefY = mod(clipPos.y, oneTap.y) * mapSize.y;\nreturn mix(resultX, resultY, coefY);\n}\nfloat CCGetShadowFactorSoft2X (vec4 shadowPos) {\nvec4 clipPosNew = ApplyShadowDepthBias_Orthographic(shadowPos, cc_shadowWHPBInfo.w);\nvec3 clipPos = clipPosNew.xyz / clipPosNew.w * 0.5 + 0.5;\nif (clipPos.x < 0.0 || clipPos.x > 1.0 ||\nclipPos.y < 0.0 || clipPos.y > 1.0 ||\nclipPos.z < 0.0 || clipPos.z > 1.0) { return 1.0; }\nclipPos.xy = cc_cameraPos.w == 1.0 ? vec2(clipPos.xy.x, 1.0 - clipPos.xy.y) : clipPos.xy;\nfloat offsetDepth = clipPos.z;\nvec2 mapSize = cc_shadowWHPBInfo.xy;\nvec2 oneTap = 1.0 / mapSize;\nfloat clipPos_offset_L = clipPos.x - oneTap.x;\nfloat clipPos_offset_R = clipPos.x + oneTap.x;\nfloat clipPos_offset_U = clipPos.y - oneTap.y;\nfloat clipPos_offset_D = clipPos.y + oneTap.y;\nfloat block0, block1, block2, block3, block4, block5, block6, block7, block8;\nif (cc_shadowLPNNInfo.y > 0.000001) {\nblock0 = step(offsetDepth, dot(texture(cc_shadowMap, vec2(clipPos_offset_L, clipPos_offset_U)), vec4(1.0, 1.0 / 255.0, 1.0 / 65025.0, 1.0 / 16581375.0)));\nblock1 = step(offsetDepth, dot(texture(cc_shadowMap, vec2(clipPos.x, clipPos_offset_U)), vec4(1.0, 1.0 / 255.0, 1.0 / 65025.0, 1.0 / 16581375.0)));\nblock2 = step(offsetDepth, dot(texture(cc_shadowMap, vec2(clipPos_offset_R, clipPos_offset_U)), vec4(1.0, 1.0 / 255.0, 1.0 / 65025.0, 1.0 / 16581375.0)));\nblock3 = step(offsetDepth, dot(texture(cc_shadowMap, vec2(clipPos_offset_L, clipPos.y)), vec4(1.0, 1.0 / 255.0, 1.0 / 65025.0, 1.0 / 16581375.0)));\nblock4 = step(offsetDepth, dot(texture(cc_shadowMap, vec2(clipPos.x, clipPos.y)), vec4(1.0, 1.0 / 255.0, 1.0 / 65025.0, 1.0 / 16581375.0)));\nblock5 = step(offsetDepth, dot(texture(cc_shadowMap, vec2(clipPos_offset_R, clipPos.y)), vec4(1.0, 1.0 / 255.0, 1.0 / 65025.0, 1.0 / 16581375.0)));\nblock6 = step(offsetDepth, dot(texture(cc_shadowMap, vec2(clipPos_offset_L, clipPos_offset_D)), vec4(1.0, 1.0 / 255.0, 1.0 / 65025.0, 1.0 / 16581375.0)));\nblock7 = step(offsetDepth, dot(texture(cc_shadowMap, vec2(clipPos.x, clipPos_offset_D)), vec4(1.0, 1.0 / 255.0, 1.0 / 65025.0, 1.0 / 16581375.0)));\nblock8 = step(offsetDepth, dot(texture(cc_shadowMap, vec2(clipPos_offset_R, clipPos_offset_D)), vec4(1.0, 1.0 / 255.0, 1.0 / 65025.0, 1.0 / 16581375.0)));\n} else {\nblock0 = step(offsetDepth, texture(cc_shadowMap, vec2(clipPos_offset_L, clipPos_offset_U)).x);\nblock1 = step(offsetDepth, texture(cc_shadowMap, vec2(clipPos.x, clipPos_offset_U)).x);\nblock2 = step(offsetDepth, texture(cc_shadowMap, vec2(clipPos_offset_R, clipPos_offset_U)).x);\nblock3 = step(offsetDepth, texture(cc_shadowMap, vec2(clipPos_offset_L, clipPos.y)).x);\nblock4 = step(offsetDepth, texture(cc_shadowMap, vec2(clipPos.x, clipPos.y)).x);\nblock5 = step(offsetDepth, texture(cc_shadowMap, vec2(clipPos_offset_R, clipPos.y)).x);\nblock6 = step(offsetDepth, texture(cc_shadowMap, vec2(clipPos_offset_L, clipPos_offset_D)).x);\nblock7 = step(offsetDepth, texture(cc_shadowMap, vec2(clipPos.x, clipPos_offset_D)).x);\nblock8 = step(offsetDepth, texture(cc_shadowMap, vec2(clipPos_offset_R, clipPos_offset_D)).x);\n}\nfloat coefX = mod(clipPos.x, oneTap.x) * mapSize.x;\nfloat coefY = mod(clipPos.y, oneTap.y) * mapSize.y;\nfloat shadow = 0.0;\nfloat resultX = mix(block0, block1, coefX);\nfloat resultY = mix(block3, block4, coefX);\nshadow += mix(resultX , resultY, coefY);\nresultX = mix(block1, block2, coefX);\nresultY = mix(block4, block5, coefX);\nshadow += mix(resultX , resultY, coefY);\nresultX = mix(block3, block4, coefX);\nresultY = mix(block6, block7, coefX);\nshadow += mix(resultX, resultY, coefY);\nresultX = mix(block4, block5, coefX);\nresultY = mix(block7, block8, coefX);\nshadow += mix(resultX, resultY, coefY);\nreturn shadow * 0.25;\n}\nfloat CCGetSpotLightShadowFactorHard (vec4 shadowPos, vec3 worldPos) {\nvec4 clipPosNew = ApplyShadowDepthBias_Perspective(shadowPos, cc_shadowWHPBInfo.w);\nvec3 clipPos = clipPosNew.xyz / clipPosNew.w * 0.5 + 0.5;\nif (clipPos.x < 0.0 || clipPos.x > 1.0 ||\nclipPos.y < 0.0 || clipPos.y > 1.0 ||\nclipPos.z < 0.0 || clipPos.z > 1.0) { return 1.0; }\nclipPos.xy = cc_cameraPos.w == 1.0 ? vec2(clipPos.xy.x, 1.0 - clipPos.xy.y) : clipPos.xy;\nfloat shadow = 0.0;\nfloat closestDepth = 0.0;\nfloat depth = clipPos.z;\nif (cc_shadowLPNNInfo.y > 0.000001) {\nclosestDepth = dot(texture(cc_spotLightingMap, clipPos.xy), vec4(1.0, 1.0 / 255.0, 1.0 / 65025.0, 1.0 / 16581375.0));\n} else {\nclosestDepth = texture(cc_spotLightingMap, clipPos.xy).x;\n}\nshadow = step(depth, closestDepth);\nreturn shadow;\n}\nfloat CCGetSpotLightShadowFactorSoft (vec4 shadowPos, vec3 worldPos) {\nvec4 clipPosNew = ApplyShadowDepthBias_Perspective(shadowPos, cc_shadowWHPBInfo.w);\nvec3 clipPos = clipPosNew.xyz / clipPosNew.w * 0.5 + 0.5;\nif (clipPos.x < 0.0 || clipPos.x > 1.0 ||\nclipPos.y < 0.0 || clipPos.y > 1.0 ||\nclipPos.z < 0.0 || clipPos.z > 1.0) { return 1.0; }\nclipPos.xy = cc_cameraPos.w == 1.0 ? vec2(clipPos.xy.x, 1.0 - clipPos.xy.y) : clipPos.xy;\nfloat depth = 0.0;\nif (cc_shadowNFLSInfo.z > 0.000001) {\ndepth = CCGetLinearDepth(worldPos);\n} else {\ndepth = clipPos.z;\n}\nfloat bias = cc_shadowWHPBInfo.w;\nvec2 oneTap = 1.0 / cc_shadowWHPBInfo.xy;\nvec2 clipPos_offset = clipPos.xy + oneTap;\nfloat block0, block1, block2, block3;\nif (cc_shadowLPNNInfo.y > 0.000001) {\nblock0 = step(depth, dot(texture(cc_spotLightingMap, vec2(clipPos.x, clipPos.y)), vec4(1.0, 1.0 / 255.0, 1.0 / 65025.0, 1.0 / 16581375.0)));\nblock1 = step(depth, dot(texture(cc_spotLightingMap, vec2(clipPos_offset.x, clipPos.y)), vec4(1.0, 1.0 / 255.0, 1.0 / 65025.0, 1.0 / 16581375.0)));\nblock2 = step(depth, dot(texture(cc_spotLightingMap, vec2(clipPos.x, clipPos_offset.y)), vec4(1.0, 1.0 / 255.0, 1.0 / 65025.0, 1.0 / 16581375.0)));\nblock3 = step(depth, dot(texture(cc_spotLightingMap, vec2(clipPos_offset.x, clipPos_offset.y)), vec4(1.0, 1.0 / 255.0, 1.0 / 65025.0, 1.0 / 16581375.0)));\n} else {\nblock0 = step(depth, texture(cc_spotLightingMap, vec2(clipPos.x, clipPos.y)).x);\nblock1 = step(depth, texture(cc_spotLightingMap, vec2(clipPos_offset.x, clipPos.y)).x);\nblock2 = step(depth, texture(cc_spotLightingMap, vec2(clipPos.x, clipPos_offset.y)).x);\nblock3 = step(depth, texture(cc_spotLightingMap, vec2(clipPos_offset.x, clipPos_offset.y)).x);\n}\nfloat coefX = mod(clipPos.x, oneTap.x) * cc_shadowWHPBInfo.x;\nfloat resultX = mix(block0, block1, coefX);\nfloat resultY = mix(block2, block3, coefX);\nfloat coefY = mod(clipPos.y, oneTap.y) * cc_shadowWHPBInfo.y;\nreturn mix(resultX, resultY, coefY);\n}\nfloat CCGetSpotLightShadowFactorSoft2X (vec4 shadowPos, vec3 worldPos) {\nvec4 clipPosNew = ApplyShadowDepthBias_Perspective(shadowPos, cc_shadowWHPBInfo.w);\nvec3 clipPos = clipPosNew.xyz / clipPosNew.w * 0.5 + 0.5;\nif (clipPos.x < 0.0 || clipPos.x > 1.0 ||\nclipPos.y < 0.0 || clipPos.y > 1.0 ||\nclipPos.z < 0.0 || clipPos.z > 1.0) { return 1.0; }\nclipPos.xy = cc_cameraPos.w == 1.0 ? vec2(clipPos.xy.x, 1.0 - clipPos.xy.y) : clipPos.xy;\nfloat depth = 0.0;\nif (cc_shadowNFLSInfo.z > 0.000001) {\ndepth = CCGetLinearDepth(worldPos);\n} else {\ndepth = clipPos.z;\n}\nfloat bias = cc_shadowWHPBInfo.w;\nvec2 mapSize = cc_shadowWHPBInfo.xy;\nvec2 oneTap = 1.0 / mapSize;\nfloat clipPos_offset_L = clipPos.x - oneTap.x;\nfloat clipPos_offset_R = clipPos.x + oneTap.x;\nfloat clipPos_offset_U = clipPos.y - oneTap.y;\nfloat clipPos_offset_D = clipPos.y + oneTap.y;\nfloat block0, block1, block2, block3, block4, block5, block6, block7, block8;\nif (cc_shadowLPNNInfo.y > 0.000001) {\nblock0 = step(depth, dot(texture(cc_spotLightingMap, vec2(clipPos_offset_L, clipPos_offset_U)), vec4(1.0, 1.0 / 255.0, 1.0 / 65025.0, 1.0 / 16581375.0)));\nblock1 = step(depth, dot(texture(cc_spotLightingMap, vec2(clipPos.x, clipPos_offset_U)), vec4(1.0, 1.0 / 255.0, 1.0 / 65025.0, 1.0 / 16581375.0)));\nblock2 = step(depth, dot(texture(cc_spotLightingMap, vec2(clipPos_offset_R, clipPos_offset_U)), vec4(1.0, 1.0 / 255.0, 1.0 / 65025.0, 1.0 / 16581375.0)));\nblock3 = step(depth, dot(texture(cc_spotLightingMap, vec2(clipPos_offset_L, clipPos.y)), vec4(1.0, 1.0 / 255.0, 1.0 / 65025.0, 1.0 / 16581375.0)));\nblock4 = step(depth, dot(texture(cc_spotLightingMap, vec2(clipPos.x, clipPos.y)), vec4(1.0, 1.0 / 255.0, 1.0 / 65025.0, 1.0 / 16581375.0)));\nblock5 = step(depth, dot(texture(cc_spotLightingMap, vec2(clipPos_offset_R, clipPos.y)), vec4(1.0, 1.0 / 255.0, 1.0 / 65025.0, 1.0 / 16581375.0)));\nblock6 = step(depth, dot(texture(cc_spotLightingMap, vec2(clipPos_offset_L, clipPos_offset_D)), vec4(1.0, 1.0 / 255.0, 1.0 / 65025.0, 1.0 / 16581375.0)));\nblock7 = step(depth, dot(texture(cc_spotLightingMap, vec2(clipPos.x, clipPos_offset_D)), vec4(1.0, 1.0 / 255.0, 1.0 / 65025.0, 1.0 / 16581375.0)));\nblock8 = step(depth, dot(texture(cc_spotLightingMap, vec2(clipPos_offset_R, clipPos_offset_D)), vec4(1.0, 1.0 / 255.0, 1.0 / 65025.0, 1.0 / 16581375.0)));\n} else {\nblock0 = step(depth, texture(cc_spotLightingMap, vec2(clipPos_offset_L, clipPos_offset_U)).x);\nblock1 = step(depth, texture(cc_spotLightingMap, vec2(clipPos.x, clipPos_offset_U)).x);\nblock2 = step(depth, texture(cc_spotLightingMap, vec2(clipPos_offset_R, clipPos_offset_U)).x);\nblock3 = step(depth, texture(cc_spotLightingMap, vec2(clipPos_offset_L, clipPos.y)).x);\nblock4 = step(depth, texture(cc_spotLightingMap, vec2(clipPos.x, clipPos.y)).x);\nblock5 = step(depth, texture(cc_spotLightingMap, vec2(clipPos_offset_R, clipPos.y)).x);\nblock6 = step(depth, texture(cc_spotLightingMap, vec2(clipPos_offset_L, clipPos_offset_D)).x);\nblock7 = step(depth, texture(cc_spotLightingMap, vec2(clipPos.x, clipPos_offset_D)).x);\nblock8 = step(depth, texture(cc_spotLightingMap, vec2(clipPos_offset_R, clipPos_offset_D)).x);\n}\nfloat coefX = mod(clipPos.x, oneTap.x) * mapSize.x;\nfloat coefY = mod(clipPos.y, oneTap.y) * mapSize.y;\nfloat shadow = 0.0;\nfloat resultX = mix(block0, block1, coefX);\nfloat resultY = mix(block3, block4, coefX);\nshadow += mix(resultX , resultY, coefY);\nresultX = mix(block1, block2, coefX);\nresultY = mix(block4, block5, coefX);\nshadow += mix(resultX , resultY, coefY);\nresultX = mix(block3, block4, coefX);\nresultY = mix(block6, block7, coefX);\nshadow += mix(resultX, resultY, coefY);\nresultX = mix(block4, block5, coefX);\nresultY = mix(block7, block8, coefX);\nshadow += mix(resultX, resultY, coefY);\nreturn shadow * 0.25;\n}\n#endif\n#if CC_USE_IBL\nlayout(set = 0, binding = 4) uniform samplerCube cc_environment;\nvec4 fragTextureLod (sampler2D tex, vec2 coord, float lod) {\nreturn textureLod(tex, coord, lod);\n}\nvec4 fragTextureLod (samplerCube tex, vec3 coord, float lod) {\nreturn textureLod(tex, coord, lod);\n}\nvec3 unpackRGBE (vec4 rgbe) {\nreturn rgbe.rgb * pow(1.1, rgbe.a * 255.0 - 128.0);\n}\n#if CC_USE_DIFFUSEMAP\nlayout(set = 0, binding = 6) uniform samplerCube cc_diffuseMap;\n#endif\n#endif\nfloat GGXMobile (float roughness, float NoH, vec3 H, vec3 N) {\nvec3 NxH = cross(N, H);\nfloat OneMinusNoHSqr = dot(NxH, NxH);\nfloat a = roughness * roughness;\nfloat n = NoH * a;\nfloat p = a / (OneMinusNoHSqr + n * n);\nreturn p * p;\n}\nfloat CalcSpecular (float roughness, float NoH, vec3 H, vec3 N) {\nreturn (roughness * 0.25 + 0.25) * GGXMobile(roughness, NoH, H, N);\n}\nvec3 BRDFApprox (vec3 specular, float roughness, float NoV) {\nconst vec4 c0 = vec4(-1.0, -0.0275, -0.572, 0.022);\nconst vec4 c1 = vec4(1.0, 0.0425, 1.04, -0.04);\nvec4 r = roughness * c0 + c1;\nfloat a004 = min(r.x * r.x, exp2(-9.28 * NoV)) * r.x + r.y;\nvec2 AB = vec2(-1.04, 1.04) * a004 + r.zw;\nAB.y *= clamp(50.0 * specular.g, 0.0, 1.0);\nreturn specular * AB.x + AB.y;\n}\n#if USE_REFLECTION_DENOISE\nvec3 GetEnvReflectionWithMipFiltering(vec3 R, float roughness, float mipCount, float denoiseIntensity) {\n#if CC_USE_IBL\nfloat mip = roughness * mipCount;\nfloat delta = (dot(dFdx(R), dFdy(R))) * 1000.0;\nfloat mipBias = mix(0.0, 5.0, clamp(delta, 0.0, 1.0));\nvec4 biased = fragTextureLod(cc_environment, R, mip + mipBias);\nvec4 filtered = texture(cc_environment, R);\n#if CC_USE_IBL == 2\nbiased.rgb = unpackRGBE(biased);\nfiltered.rgb = unpackRGBE(filtered);\n#else\nbiased.rgb = SRGBToLinear(biased.rgb);\nfiltered.rgb = SRGBToLinear(filtered.rgb);\n#endif\nreturn mix(biased.rgb, filtered.rgb, denoiseIntensity);\n#else\nreturn vec3(0.0, 0.0, 0.0);\n#endif\n}\n#endif\nstruct StandardSurface {\nvec4 albedo;\nvec3 position;\nvec3 normal;\nvec3 emissive;\nvec3 lightmap;\nfloat lightmap_test;\nfloat roughness;\nfloat metallic;\nfloat occlusion;\n};\nvec4 CCStandardShadingBase (StandardSurface s, vec4 shadowPos) {\nvec3 diffuse = s.albedo.rgb * (1.0 - s.metallic);\nvec3 specular = mix(vec3(0.04), s.albedo.rgb, s.metallic);\nvec3 N = normalize(s.normal);\nvec3 V = normalize(cc_cameraPos.xyz - s.position);\nfloat NV = max(abs(dot(N, V)), 0.0);\nspecular = BRDFApprox(specular, s.roughness, NV);\nvec3 L = normalize(-cc_mainLitDir.xyz);\nvec3 H = normalize(L + V);\nfloat NH = max(dot(N, H), 0.0);\nfloat NL = max(dot(N, L), 0.0);\nvec3 finalColor = NL * cc_mainLitColor.rgb * cc_mainLitColor.w;\nvec3 diffuseContrib = diffuse;\n#if USE_LIGHTMAP && !USE_BATCHING && !CC_FORWARD_ADD\nif (s.lightmap_test > 0.0001) {\nfinalColor = s.lightmap.rgb;\n}\n#else\ndiffuseContrib /= 3.14159265359;\n#endif\nvec3 specularContrib = specular * CalcSpecular(s.roughness, NH, H, N);\nvec3 dirlightContrib = (diffuseContrib + specularContrib);\nfloat shadow = 1.0;\n#if CC_RECEIVE_SHADOW && CC_ENABLE_DIR_SHADOW\nif (NL > 0.0) {\n{\nvec4 pos = ApplyShadowDepthBias_FaceNormal(shadowPos, N);\nfloat pcf = cc_shadowWHPBInfo.z;\nif (pcf > 1.9) shadow = CCGetShadowFactorSoft2X(pos);\nelse if (pcf > 0.9) shadow = CCGetShadowFactorSoft(pos);\nelse shadow = CCGetShadowFactorHard(pos);\nshadow = mix(shadow, 1.0, cc_shadowNFLSInfo.w);\n}\n}\n#endif\ndirlightContrib *= shadow;\nfinalColor *= dirlightContrib;\nfloat fAmb = 0.5 - N.y * 0.5;\nvec3 ambDiff = mix(cc_ambientSky.rgb, cc_ambientGround.rgb, fAmb);\n#if CC_USE_IBL\n#if CC_USE_DIFFUSEMAP\nvec4 diffuseMap = texture(cc_diffuseMap, N);\n#if CC_USE_DIFFUSEMAP == 2\nambDiff = unpackRGBE(diffuseMap);\n#else\nambDiff = SRGBToLinear(diffuseMap.rgb);\n#endif\n#endif\nvec3 R = normalize(reflect(-V, N));\n#if USE_REFLECTION_DENOISE\nvec3 env = GetEnvReflectionWithMipFiltering(R, s.roughness, cc_ambientGround.w, 0.6);\n#else\nvec4 envmap = fragTextureLod(cc_environment, R, s.roughness * cc_ambientGround.w);\n#if CC_USE_IBL == 2\nvec3 env = unpackRGBE(envmap);\n#else\nvec3 env = SRGBToLinear(envmap.rgb);\n#endif\n#endif\nfinalColor += env * cc_ambientSky.w * specular * s.occlusion;\n#endif\nfinalColor += ambDiff.rgb * cc_ambientSky.w * diffuse * s.occlusion;\nfinalColor += s.emissive;\nreturn vec4(finalColor, s.albedo.a);\n}\n#if CC_PIPELINE_TYPE == 0\n# define LIGHTS_PER_PASS 1\n#else\n# define LIGHTS_PER_PASS 10\n#endif\n#if CC_ENABLE_CLUSTERED_LIGHT_CULLING == 0\nlayout(set = 2, binding = 1) uniform CCForwardLight {\nhighp vec4 cc_lightPos[LIGHTS_PER_PASS];\nvec4 cc_lightColor[LIGHTS_PER_PASS];\nvec4 cc_lightSizeRangeAngle[LIGHTS_PER_PASS];\nvec4 cc_lightDir[LIGHTS_PER_PASS];\n};\n#endif\nfloat SmoothDistAtt (float distSqr, float invSqrAttRadius) {\nfloat factor = distSqr * invSqrAttRadius;\nfloat smoothFactor = clamp(1.0 - factor * factor, 0.0, 1.0);\nreturn smoothFactor * smoothFactor;\n}\nfloat GetDistAtt (float distSqr, float invSqrAttRadius) {\nfloat attenuation = 1.0 / max(distSqr, 0.01*0.01);\nattenuation *= SmoothDistAtt(distSqr , invSqrAttRadius);\nreturn attenuation;\n}\nfloat GetAngleAtt (vec3 L, vec3 litDir, float litAngleScale, float litAngleOffset) {\nfloat cd = dot(litDir, L);\nfloat attenuation = clamp(cd * litAngleScale + litAngleOffset, 0.0, 1.0);\nreturn (attenuation * attenuation);\n}\n#if CC_ENABLE_CLUSTERED_LIGHT_CULLING == 0\nvec4 CCStandardShadingAdditive (StandardSurface s, vec4 shadowPos) {\nvec3 diffuse = s.albedo.rgb * (1.0 - s.metallic);\nvec3 specular = mix(vec3(0.04), s.albedo.rgb, s.metallic);\nvec3 diffuseContrib = diffuse / 3.14159265359;\nvec3 N = normalize(s.normal);\nvec3 V = normalize(cc_cameraPos.xyz - s.position);\nfloat NV = max(abs(dot(N, V)), 0.0);\nspecular = BRDFApprox(specular, s.roughness, NV);\nvec3 finalColor = vec3(0.0);\nint numLights = CC_PIPELINE_TYPE == 0 ? LIGHTS_PER_PASS : int(cc_lightDir[0].w);\nfor (int i = 0; i < LIGHTS_PER_PASS; i++) {\nif (i >= numLights) break;\nvec3 SLU = cc_lightPos[i].xyz - s.position;\nvec3 SL = normalize(SLU);\nvec3 SH = normalize(SL + V);\nfloat SNL = max(dot(N, SL), 0.0);\nfloat SNH = max(dot(N, SH), 0.0);\nfloat distSqr = dot(SLU, SLU);\nfloat litRadius = cc_lightSizeRangeAngle[i].x;\nfloat litRadiusSqr = litRadius * litRadius;\nfloat illum = 3.14159265359 * (litRadiusSqr / max(litRadiusSqr , distSqr));\nfloat attRadiusSqrInv = 1.0 / max(cc_lightSizeRangeAngle[i].y, 0.01);\nattRadiusSqrInv *= attRadiusSqrInv;\nfloat att = GetDistAtt(distSqr, attRadiusSqrInv);\nvec3 lspec = specular * CalcSpecular(s.roughness, SNH, SH, N);\nif (cc_lightPos[i].w > 0.0) {\nfloat cosInner = max(dot(-cc_lightDir[i].xyz, SL), 0.01);\nfloat cosOuter = cc_lightSizeRangeAngle[i].z;\nfloat litAngleScale = 1.0 / max(0.001, cosInner - cosOuter);\nfloat litAngleOffset = -cosOuter * litAngleScale;\natt *= GetAngleAtt(SL, -cc_lightDir[i].xyz, litAngleScale, litAngleOffset);\n}\nvec3 lightColor = cc_lightColor[i].rgb;\nfloat shadow = 1.0;\n#if CC_RECEIVE_SHADOW\nif (cc_lightPos[i].w > 0.0 && cc_lightSizeRangeAngle[i].w > 0.0) {\n{\nfloat pcf = cc_shadowWHPBInfo.z;\nif (pcf > 1.9) shadow = CCGetSpotLightShadowFactorSoft2X(shadowPos, s.position);\nelse if (pcf > 0.9) shadow = CCGetSpotLightShadowFactorSoft(shadowPos, s.position);\nelse shadow = CCGetSpotLightShadowFactorHard(shadowPos, s.position);\n}\n}\n#endif\nlightColor *= shadow;\nfinalColor += SNL * lightColor * cc_lightColor[i].w * illum * att * (diffuseContrib + lspec);\n}\nreturn vec4(finalColor, 0.0);\n}\n#endif\n#if CC_ENABLE_CLUSTERED_LIGHT_CULLING == 1\nlayout(set = 1, binding = 4) readonly buffer b_ccLightsBuffer { vec4 b_ccLights[]; };\nlayout(set = 1, binding = 5) readonly buffer b_clusterLightIndicesBuffer { uint b_clusterLightIndices[]; };\nlayout(set = 1, binding = 6) readonly buffer b_clusterLightGridBuffer { uvec4 b_clusterLightGrid[]; };\nstruct CCLight\n{\nvec4 cc_lightPos;\nvec4 cc_lightColor;\nvec4 cc_lightSizeRangeAngle;\nvec4 cc_lightDir;\n};\nstruct Cluster\n{\nvec3 minBounds;\nvec3 maxBounds;\n};\nstruct LightGrid\n{\nuint offset;\nuint ccLights;\n};\nCCLight getCCLight(uint i)\n{\nCCLight light;\nlight.cc_lightPos = b_ccLights[4u * i + 0u];\nlight.cc_lightColor = b_ccLights[4u * i + 1u];\nlight.cc_lightSizeRangeAngle = b_ccLights[4u * i + 2u];\nlight.cc_lightDir = b_ccLights[4u * i + 3u];\nreturn light;\n}\nLightGrid getLightGrid(uint cluster)\n{\nuvec4 gridvec = b_clusterLightGrid[cluster];\nLightGrid grid;\ngrid.offset = gridvec.x;\ngrid.ccLights = gridvec.y;\nreturn grid;\n}\nuint getGridLightIndex(uint start, uint offset)\n{\nreturn b_clusterLightIndices[start + offset];\n}\nuint getClusterZIndex(vec4 worldPos)\n{\nfloat scale = float(24) / log(cc_nearFar.y / cc_nearFar.x);\nfloat bias = -(float(24) * log(cc_nearFar.x) / log(cc_nearFar.y / cc_nearFar.x));\nfloat eyeDepth = -(cc_matView * worldPos).z;\nuint zIndex = uint(max(log(eyeDepth) * scale + bias, 0.0));\nreturn zIndex;\n}\nuint getClusterIndex(vec4 fragCoord, vec4 worldPos)\n{\nuint zIndex = getClusterZIndex(worldPos);\nfloat clusterSizeX = ceil(cc_screenSize.x / float(16));\nfloat clusterSizeY = ceil(cc_screenSize.y / float(8));\nuvec3 indices = uvec3(uvec2(fragCoord.xy / vec2(clusterSizeX, clusterSizeY)), zIndex);\nuint cluster = (16u * 8u) * indices.z + 16u * indices.y + indices.x;\nreturn cluster;\n}\nvec4 CCClusterShadingAdditive (StandardSurface s, vec4 shadowPos) {\nvec3 diffuse = s.albedo.rgb * (1.0 - s.metallic);\nvec3 specular = mix(vec3(0.04), s.albedo.rgb, s.metallic);\nvec3 diffuseContrib = diffuse / 3.14159265359;\nvec3 N = normalize(s.normal);\nvec3 V = normalize(cc_cameraPos.xyz - s.position);\nfloat NV = max(abs(dot(N, V)), 0.001);\nspecular = BRDFApprox(specular, s.roughness, NV);\nvec3 finalColor = vec3(0.0);\nuint cluster = getClusterIndex(gl_FragCoord, vec4(s.position, 1.0));\nLightGrid grid = getLightGrid(cluster);\nuint numLights = grid.ccLights;\nfor (uint i = 0u; i < 100u; i++) {\nif (i >= numLights) break;\nuint lightIndex = getGridLightIndex(grid.offset, i);\nCCLight light = getCCLight(lightIndex);\nvec3 SLU = light.cc_lightPos.xyz - s.position;\nvec3 SL = normalize(SLU);\nvec3 SH = normalize(SL + V);\nfloat SNL = max(dot(N, SL), 0.001);\nfloat SNH = max(dot(N, SH), 0.0);\nfloat distSqr = dot(SLU, SLU);\nfloat litRadius = light.cc_lightSizeRangeAngle.x;\nfloat litRadiusSqr = litRadius * litRadius;\nfloat illum = 3.14159265359 * (litRadiusSqr / max(litRadiusSqr , distSqr));\nfloat attRadiusSqrInv = 1.0 / max(light.cc_lightSizeRangeAngle.y, 0.01);\nattRadiusSqrInv *= attRadiusSqrInv;\nfloat att = GetDistAtt(distSqr, attRadiusSqrInv);\nvec3 lspec = specular * CalcSpecular(s.roughness, SNH, SH, N);\nif (light.cc_lightPos.w > 0.0) {\nfloat cosInner = max(dot(-light.cc_lightDir.xyz, SL), 0.01);\nfloat cosOuter = light.cc_lightSizeRangeAngle.z;\nfloat litAngleScale = 1.0 / max(0.001, cosInner - cosOuter);\nfloat litAngleOffset = -cosOuter * litAngleScale;\natt *= GetAngleAtt(SL, -light.cc_lightDir.xyz, litAngleScale, litAngleOffset);\n}\nvec3 lightColor = light.cc_lightColor.rgb;\nfloat shadow = 1.0;\n#if CC_RECEIVE_SHADOW\nif (light.cc_lightPos.w > 0.0) {\n{\nfloat pcf = cc_shadowWHPBInfo.z;\nif (pcf > 1.9) shadow = CCGetSpotLightShadowFactorSoft2X(shadowPos, s.position);\nelse if (pcf > 0.9) shadow = CCGetSpotLightShadowFactorSoft(shadowPos, s.position);\nelse shadow = CCGetSpotLightShadowFactorHard(shadowPos, s.position);\n}\n}\n#endif\nlightColor *= shadow;\nfinalColor += SNL * lightColor * light.cc_lightColor.w * illum * att * (diffuseContrib + lspec);\n}\nreturn vec4(finalColor, 0.0);\n}\n#endif\nvec3 ACESToneMap (vec3 color) {\ncolor = min(color, vec3(8.0));\nconst float A = 2.51;\nconst float B = 0.03;\nconst float C = 2.43;\nconst float D = 0.59;\nconst float E = 0.14;\nreturn (color * (A * color + B)) / (color * (C * color + D) + E);\n}\nvec4 CCFragOutput (vec4 color) {\n#if CC_USE_HDR\ncolor.rgb = ACESToneMap(color.rgb);\n#endif\ncolor.rgb = sqrt(color.rgb);\nreturn color;\n}\nfloat LinearFog(vec4 pos) {\nvec4 wPos = pos;\nfloat cam_dis = distance(cc_cameraPos, wPos);\nfloat fogStart = cc_fogBase.x;\nfloat fogEnd = cc_fogBase.y;\nreturn clamp((fogEnd - cam_dis) / (fogEnd - fogStart), 0., 1.);\n}\nfloat ExpFog(vec4 pos) {\nvec4 wPos = pos;\nfloat fogAtten = cc_fogAdd.z;\nfloat fogStart = cc_fogBase.x;\nfloat fogDensity = cc_fogBase.z;\nfloat cam_dis = max(distance(cc_cameraPos, wPos) - fogStart, 0.0) / fogAtten * 4.;\nfloat f = exp(-cam_dis * fogDensity);\nreturn f;\n}\nfloat ExpSquaredFog(vec4 pos) {\nvec4 wPos = pos;\nfloat fogAtten = cc_fogAdd.z;\nfloat fogStart = cc_fogBase.x;\nfloat fogDensity = cc_fogBase.z;\nfloat cam_dis = max(distance(cc_cameraPos, wPos) - fogStart, 0.0) / fogAtten * 4.;\nfloat f = exp(-cam_dis * cam_dis * fogDensity * fogDensity);\nreturn f;\n}\nfloat LayeredFog(vec4 pos) {\nvec4 wPos = pos;\nfloat fogAtten = cc_fogAdd.z;\nfloat _FogTop = cc_fogAdd.x;\nfloat _FogRange = cc_fogAdd.y;\nvec3 camWorldProj = cc_cameraPos.xyz;\ncamWorldProj.y = 0.;\nvec3 worldPosProj = wPos.xyz;\nworldPosProj.y = 0.;\nfloat fDeltaD = distance(worldPosProj, camWorldProj) / fogAtten * 2.0;\nfloat fDeltaY, fDensityIntegral;\nif (cc_cameraPos.y > _FogTop) {\nif (wPos.y < _FogTop) {\nfDeltaY = (_FogTop - wPos.y) / _FogRange * 2.0;\nfDensityIntegral = fDeltaY * fDeltaY * 0.5;\n} else {\nfDeltaY = 0.;\nfDensityIntegral = 0.;\n}\n} else {\nif (wPos.y < _FogTop) {\nfloat fDeltaA = (_FogTop - cc_cameraPos.y) / _FogRange * 2.;\nfloat fDeltaB = (_FogTop - wPos.y) / _FogRange * 2.;\nfDeltaY = abs(fDeltaA - fDeltaB);\nfDensityIntegral = abs((fDeltaA * fDeltaA * 0.5) - (fDeltaB * fDeltaB * 0.5));\n} else {\nfDeltaY = abs(_FogTop - cc_cameraPos.y) / _FogRange * 2.;\nfDensityIntegral = abs(fDeltaY * fDeltaY * 0.5);\n}\n}\nfloat fDensity;\nif (fDeltaY != 0.) {\nfDensity = (sqrt(1.0 + ((fDeltaD / fDeltaY) * (fDeltaD / fDeltaY)))) * fDensityIntegral;\n} else {\nfDensity = 0.;\n}\nfloat f = exp(-fDensity);\nreturn f;\n}\nvoid CC_TRANSFER_FOG_BASE(vec4 pos, out float factor)\n{\n#if CC_USE_FOG == 0\nfactor = LinearFog(pos);\n#elif CC_USE_FOG == 1\nfactor = ExpFog(pos);\n#elif CC_USE_FOG == 2\nfactor = ExpSquaredFog(pos);\n#elif CC_USE_FOG == 3\nfactor = LayeredFog(pos);\n#else\nfactor = 1.0;\n#endif\n}\nvoid CC_APPLY_FOG_BASE(inout vec4 color, float factor) {\ncolor = vec4(mix(cc_fogColor.rgb, color.rgb, factor), color.a);\n}\nlayout(location = 0) in vec2 v_uv;\n#if CC_DEVICE_CAN_BENEFIT_FROM_INPUT_ATTACHMENT\nlayout(set = 1, binding = 0, input_attachment_index = 0) uniform subpassInput gbuffer_albedoMap;\nlayout(set = 1, binding = 1, input_attachment_index = 1) uniform subpassInput gbuffer_positionMap;\nlayout(set = 1, binding = 2, input_attachment_index = 2) uniform subpassInput gbuffer_normalMap;\nlayout(set = 1, binding = 3, input_attachment_index = 3) uniform subpassInput gbuffer_emissiveMap;\n#else\nlayout(set = 1, binding = 0) uniform sampler2D gbuffer_albedoMap;\nlayout(set = 1, binding = 1) uniform sampler2D gbuffer_positionMap;\nlayout(set = 1, binding = 2) uniform sampler2D gbuffer_normalMap;\nlayout(set = 1, binding = 3) uniform sampler2D gbuffer_emissiveMap;\n#endif\n#if !CC_DEVICE_CAN_BENEFIT_FROM_INPUT_ATTACHMENT || __VERSION__ >= 450\nlayout(location = 0) out vec4 fragColor;\n#endif\nvoid main () {\nStandardSurface s;\n#if CC_DEVICE_CAN_BENEFIT_FROM_INPUT_ATTACHMENT\nvec4 albedoMap = subpassLoad(gbuffer_albedoMap);\nvec4 positionMap = subpassLoad(gbuffer_positionMap);\nvec4 normalMap = subpassLoad(gbuffer_normalMap);\nvec4 emissiveMap = subpassLoad(gbuffer_emissiveMap);\n#else\nvec4 albedoMap = texture(gbuffer_albedoMap,v_uv);\nvec4 positionMap = texture(gbuffer_positionMap,v_uv);\nvec4 normalMap = texture(gbuffer_normalMap,v_uv);\nvec4 emissiveMap = texture(gbuffer_emissiveMap,v_uv);\n#endif\ns.albedo = albedoMap;\ns.position = positionMap.xyz;\ns.roughness = positionMap.w;\ns.normal = normalMap.xyz;\ns.metallic = normalMap.w;\ns.emissive = emissiveMap.xyz;\ns.occlusion = emissiveMap.w;\nfloat fogFactor;\nCC_TRANSFER_FOG_BASE(vec4(s.position, 1), fogFactor);\nvec4 shadowPos;\nshadowPos = cc_matLightViewProj * vec4(s.position, 1);\nvec4 color = CCStandardShadingBase(s, shadowPos) +\n#if CC_ENABLE_CLUSTERED_LIGHT_CULLING == 1\nCCClusterShadingAdditive(s, shadowPos);\n#else\nCCStandardShadingAdditive(s, shadowPos);\n#endif\nCC_APPLY_FOG_BASE(color, fogFactor);\ncolor = CCFragOutput(color);\n#if CC_DEVICE_CAN_BENEFIT_FROM_INPUT_ATTACHMENT\nfragColor = color;\n#else\nfragColor = color;\n#endif\n}", + } + ], + [ + { + "vert": "#extension GL_EXT_shader_explicit_arithmetic_types_int32: require\nprecision highp float;\nhighp float decode32 (highp vec4 rgba) {\nrgba = rgba * 255.0;\nhighp float Sign = 1.0 - (step(128.0, (rgba[3]) + 0.5)) * 2.0;\nhighp float Exponent = 2.0 * (mod(float(int((rgba[3]) + 0.5)), 128.0)) + (step(128.0, (rgba[2]) + 0.5)) - 127.0;\nhighp float Mantissa = (mod(float(int((rgba[2]) + 0.5)), 128.0)) * 65536.0 + rgba[1] * 256.0 + rgba[0] + 8388608.0;\nreturn Sign * exp2(Exponent - 23.0) * Mantissa;\n}\nstruct StandardVertInput {\nhighp vec4 position;\nvec3 normal;\nvec4 tangent;\n};\nlayout(location = 0) in vec3 a_position;\nlayout(location = 1) in vec3 a_normal;\nlayout(location = 2) in vec2 a_texCoord;\nlayout(location = 3) in vec4 a_tangent;\n#if CC_USE_MORPH\nint getVertexId() {\nreturn gl_VertexIndex;\n}\nlayout(set = 2, binding = 4) uniform CCMorph {\nvec4 cc_displacementWeights[15];\nvec4 cc_displacementTextureInfo;\n};\nvec2 getPixelLocation(vec2 textureResolution, int pixelIndex) {\nfloat pixelIndexF = float(pixelIndex);\nfloat x = mod(pixelIndexF, textureResolution.x);\nfloat y = floor(pixelIndexF / textureResolution.x);\nreturn vec2(x, y);\n}\nvec2 getPixelCoordFromLocation(vec2 location, vec2 textureResolution) {\nreturn (vec2(location.x, location.y) + .5) / textureResolution;\n}\n#if CC_DEVICE_SUPPORT_FLOAT_TEXTURE\nvec4 fetchVec3ArrayFromTexture(sampler2D tex, int pixelIndex) {\nivec2 texSize = textureSize(tex, 0);\nreturn texelFetch(tex, ivec2(pixelIndex % texSize.x, pixelIndex / texSize.x), 0);\n}\n#else\nvec4 fetchVec3ArrayFromTexture(sampler2D tex, int elementIndex) {\nint pixelIndex = elementIndex * 4;\nvec2 location = getPixelLocation(cc_displacementTextureInfo.xy, pixelIndex);\nvec2 x = getPixelCoordFromLocation(location + vec2(0.0, 0.0), cc_displacementTextureInfo.xy);\nvec2 y = getPixelCoordFromLocation(location + vec2(1.0, 0.0), cc_displacementTextureInfo.xy);\nvec2 z = getPixelCoordFromLocation(location + vec2(2.0, 0.0), cc_displacementTextureInfo.xy);\nreturn vec4(\ndecode32(texture(tex, x)),\ndecode32(texture(tex, y)),\ndecode32(texture(tex, z)),\n1.0\n);\n}\n#endif\nfloat getDisplacementWeight(int index) {\nint quot = index / 4;\nint remainder = index - quot * 4;\nif (remainder == 0) {\nreturn cc_displacementWeights[quot].x;\n} else if (remainder == 1) {\nreturn cc_displacementWeights[quot].y;\n} else if (remainder == 2) {\nreturn cc_displacementWeights[quot].z;\n} else {\nreturn cc_displacementWeights[quot].w;\n}\n}\nvec3 getVec3DisplacementFromTexture(sampler2D tex, int vertexIndex) {\n#if CC_MORPH_PRECOMPUTED\nreturn fetchVec3ArrayFromTexture(tex, vertexIndex).rgb;\n#else\nvec3 result = vec3(0, 0, 0);\nint nVertices = int(cc_displacementTextureInfo.z);\nfor (int iTarget = 0; iTarget < CC_MORPH_TARGET_COUNT; ++iTarget) {\nresult += (fetchVec3ArrayFromTexture(tex, nVertices * iTarget + vertexIndex).rgb * getDisplacementWeight(iTarget));\n}\nreturn result;\n#endif\n}\n#if CC_MORPH_TARGET_HAS_POSITION\nlayout(set = 2, binding = 7) uniform sampler2D cc_PositionDisplacements;\nvec3 getPositionDisplacement(int vertexId) {\nreturn getVec3DisplacementFromTexture(cc_PositionDisplacements, vertexId);\n}\n#endif\n#if CC_MORPH_TARGET_HAS_NORMAL\nlayout(set = 2, binding = 8) uniform sampler2D cc_NormalDisplacements;\nvec3 getNormalDisplacement(int vertexId) {\nreturn getVec3DisplacementFromTexture(cc_NormalDisplacements, vertexId);\n}\n#endif\n#if CC_MORPH_TARGET_HAS_TANGENT\nlayout(set = 2, binding = 9) uniform sampler2D cc_TangentDisplacements;\nvec3 getTangentDisplacement(int vertexId) {\nreturn getVec3DisplacementFromTexture(cc_TangentDisplacements, vertexId);\n}\n#endif\nvoid applyMorph (inout StandardVertInput attr) {\nint vertexId = getVertexId();\n#if CC_MORPH_TARGET_HAS_POSITION\nattr.position.xyz = attr.position.xyz + getPositionDisplacement(vertexId);\n#endif\n#if CC_MORPH_TARGET_HAS_NORMAL\nattr.normal.xyz = attr.normal.xyz + getNormalDisplacement(vertexId);\n#endif\n#if CC_MORPH_TARGET_HAS_TANGENT\nattr.tangent.xyz = attr.tangent.xyz + getTangentDisplacement(vertexId);\n#endif\n}\nvoid applyMorph (inout vec4 position) {\n#if CC_MORPH_TARGET_HAS_POSITION\nposition.xyz = position.xyz + getPositionDisplacement(getVertexId());\n#endif\n}\n#endif\n#if CC_USE_SKINNING\nlayout(location = 4) in u32vec4 a_joints;\nlayout(location = 5) in vec4 a_weights;\n#if CC_USE_BAKED_ANIMATION\n#if USE_INSTANCING\nlayout(location = 7) in highp vec4 a_jointAnimInfo;\n#endif\nlayout(set = 2, binding = 3) uniform CCSkinningTexture {\nhighp vec4 cc_jointTextureInfo;\n};\nlayout(set = 2, binding = 2) uniform CCSkinningAnimation {\nhighp vec4 cc_jointAnimInfo;\n};\nlayout(set = 2, binding = 6) uniform highp sampler2D cc_jointTexture;\n#else\nlayout(set = 2, binding = 3) uniform CCSkinning {\nhighp vec4 cc_joints[30 * 3];\n};\n#endif\n#if CC_USE_BAKED_ANIMATION\n#if CC_DEVICE_SUPPORT_FLOAT_TEXTURE\nmat4 getJointMatrix (float i) {\n#if USE_INSTANCING\nhighp float j = 3.0 * (a_jointAnimInfo.x * a_jointAnimInfo.y + i) + a_jointAnimInfo.z;\n#else\nhighp float j = 3.0 * (cc_jointAnimInfo.x * cc_jointTextureInfo.y + i) + cc_jointTextureInfo.z;\n#endif\nhighp float invSize = cc_jointTextureInfo.w;\nhighp float y = floor(j * invSize);\nhighp float x = floor(j - y * cc_jointTextureInfo.x);\ny = (y + 0.5) * invSize;\nvec4 v1 = texture(cc_jointTexture, vec2((x + 0.5) * invSize, y));\nvec4 v2 = texture(cc_jointTexture, vec2((x + 1.5) * invSize, y));\nvec4 v3 = texture(cc_jointTexture, vec2((x + 2.5) * invSize, y));\nreturn mat4(vec4(v1.xyz, 0.0), vec4(v2.xyz, 0.0), vec4(v3.xyz, 0.0), vec4(v1.w, v2.w, v3.w, 1.0));\n}\n#else\nmat4 getJointMatrix (float i) {\n#if USE_INSTANCING\nhighp float j = 12.0 * (a_jointAnimInfo.x * a_jointAnimInfo.y + i) + a_jointAnimInfo.z;\n#else\nhighp float j = 12.0 * (cc_jointAnimInfo.x * cc_jointTextureInfo.y + i) + cc_jointTextureInfo.z;\n#endif\nhighp float invSize = cc_jointTextureInfo.w;\nhighp float y = floor(j * invSize);\nhighp float x = floor(j - y * cc_jointTextureInfo.x);\ny = (y + 0.5) * invSize;\nvec4 v1 = vec4(\ndecode32(texture(cc_jointTexture, vec2((x + 0.5) * invSize, y))),\ndecode32(texture(cc_jointTexture, vec2((x + 1.5) * invSize, y))),\ndecode32(texture(cc_jointTexture, vec2((x + 2.5) * invSize, y))),\ndecode32(texture(cc_jointTexture, vec2((x + 3.5) * invSize, y)))\n);\nvec4 v2 = vec4(\ndecode32(texture(cc_jointTexture, vec2((x + 4.5) * invSize, y))),\ndecode32(texture(cc_jointTexture, vec2((x + 5.5) * invSize, y))),\ndecode32(texture(cc_jointTexture, vec2((x + 6.5) * invSize, y))),\ndecode32(texture(cc_jointTexture, vec2((x + 7.5) * invSize, y)))\n);\nvec4 v3 = vec4(\ndecode32(texture(cc_jointTexture, vec2((x + 8.5) * invSize, y))),\ndecode32(texture(cc_jointTexture, vec2((x + 9.5) * invSize, y))),\ndecode32(texture(cc_jointTexture, vec2((x + 10.5) * invSize, y))),\ndecode32(texture(cc_jointTexture, vec2((x + 11.5) * invSize, y)))\n);\nreturn mat4(vec4(v1.xyz, 0.0), vec4(v2.xyz, 0.0), vec4(v3.xyz, 0.0), vec4(v1.w, v2.w, v3.w, 1.0));\n}\n#endif\n#else\nmat4 getJointMatrix (float i) {\nint idx = int(i);\nvec4 v1 = cc_joints[idx * 3];\nvec4 v2 = cc_joints[idx * 3 + 1];\nvec4 v3 = cc_joints[idx * 3 + 2];\nreturn mat4(vec4(v1.xyz, 0.0), vec4(v2.xyz, 0.0), vec4(v3.xyz, 0.0), vec4(v1.w, v2.w, v3.w, 1.0));\n}\n#endif\nmat4 skinMatrix () {\nvec4 joints = vec4(a_joints);\nreturn getJointMatrix(joints.x) * a_weights.x\n+ getJointMatrix(joints.y) * a_weights.y\n+ getJointMatrix(joints.z) * a_weights.z\n+ getJointMatrix(joints.w) * a_weights.w;\n}\nvoid CCSkin (inout vec4 position) {\nmat4 m = skinMatrix();\nposition = m * position;\n}\nvoid CCSkin (inout StandardVertInput attr) {\nmat4 m = skinMatrix();\nattr.position = m * attr.position;\nattr.normal = (m * vec4(attr.normal, 0.0)).xyz;\nattr.tangent.xyz = (m * vec4(attr.tangent.xyz, 0.0)).xyz;\n}\n#endif\nlayout(set = 0, binding = 0) uniform CCGlobal {\nhighp vec4 cc_time;\nmediump vec4 cc_screenSize;\nmediump vec4 cc_nativeSize;\n};\nlayout(set = 0, binding = 1) uniform CCCamera {\nhighp mat4 cc_matView;\nhighp mat4 cc_matViewInv;\nhighp mat4 cc_matProj;\nhighp mat4 cc_matProjInv;\nhighp mat4 cc_matViewProj;\nhighp mat4 cc_matViewProjInv;\nhighp vec4 cc_cameraPos;\nmediump vec4 cc_screenScale;\nmediump vec4 cc_exposure;\nmediump vec4 cc_mainLitDir;\nmediump vec4 cc_mainLitColor;\nmediump vec4 cc_ambientSky;\nmediump vec4 cc_ambientGround;\nmediump vec4 cc_fogColor;\nmediump vec4 cc_fogBase;\nmediump vec4 cc_fogAdd;\nmediump vec4 cc_nearFar;\nmediump vec4 cc_viewPort;\n};\n#if USE_INSTANCING\nlayout(location = 8) in vec4 a_matWorld0;\nlayout(location = 9) in vec4 a_matWorld1;\nlayout(location = 10) in vec4 a_matWorld2;\n#if USE_LIGHTMAP\nlayout(location = 11) in vec4 a_lightingMapUVParam;\n#endif\n#elif USE_BATCHING\nlayout(location = 12) in float a_dyn_batch_id;\nlayout(set = 2, binding = 0) uniform CCLocalBatched {\nhighp mat4 cc_matWorlds[10];\n};\n#else\nlayout(set = 2, binding = 0) uniform CCLocal {\nhighp mat4 cc_matWorld;\nhighp mat4 cc_matWorldIT;\nhighp vec4 cc_lightingMapUVParam;\n};\n#endif\nlayout(set = 0, binding = 2) uniform CCShadow {\nhighp mat4 cc_matLightPlaneProj;\nhighp mat4 cc_matLightView;\nhighp mat4 cc_matLightViewProj;\nhighp vec4 cc_shadowInvProjDepthInfo;\nhighp vec4 cc_shadowProjDepthInfo;\nhighp vec4 cc_shadowProjInfo;\nlowp vec4 cc_shadowNFLSInfo;\nlowp vec4 cc_shadowWHPBInfo;\nlowp vec4 cc_shadowLPNNInfo;\nlowp vec4 cc_shadowColor;\n};\nvec4 vert () {\nvec4 position;\nposition = vec4(a_position, 1.0);\n#if CC_USE_MORPH\napplyMorph(position);\n#endif\n#if CC_USE_SKINNING\nCCSkin(position);\n#endif\nmat4 matWorld;\n#if USE_INSTANCING\nmatWorld = mat4(\nvec4(a_matWorld0.xyz, 0.0),\nvec4(a_matWorld1.xyz, 0.0),\nvec4(a_matWorld2.xyz, 0.0),\nvec4(a_matWorld0.w, a_matWorld1.w, a_matWorld2.w, 1.0)\n);\n#elif USE_BATCHING\nmatWorld = cc_matWorlds[int(a_dyn_batch_id)];\n#else\nmatWorld = cc_matWorld;\n#endif\nposition = cc_matProj * (cc_matView * cc_matLightPlaneProj * matWorld) * position;\nposition.z -= 0.0001;\nreturn position;\n}\nvoid main() { gl_Position = vert(); }", + "frag": "\nprecision mediump float;\nlayout(set = 0, binding = 2) uniform CCShadow {\nhighp mat4 cc_matLightPlaneProj;\nhighp mat4 cc_matLightView;\nhighp mat4 cc_matLightViewProj;\nhighp vec4 cc_shadowInvProjDepthInfo;\nhighp vec4 cc_shadowProjDepthInfo;\nhighp vec4 cc_shadowProjInfo;\nlowp vec4 cc_shadowNFLSInfo;\nlowp vec4 cc_shadowWHPBInfo;\nlowp vec4 cc_shadowLPNNInfo;\nlowp vec4 cc_shadowColor;\n};\nlayout(set = 0, binding = 0) uniform CCGlobal {\nhighp vec4 cc_time;\nmediump vec4 cc_screenSize;\nmediump vec4 cc_nativeSize;\n};\nlayout(set = 0, binding = 1) uniform CCCamera {\nhighp mat4 cc_matView;\nhighp mat4 cc_matViewInv;\nhighp mat4 cc_matProj;\nhighp mat4 cc_matProjInv;\nhighp mat4 cc_matViewProj;\nhighp mat4 cc_matViewProjInv;\nhighp vec4 cc_cameraPos;\nmediump vec4 cc_screenScale;\nmediump vec4 cc_exposure;\nmediump vec4 cc_mainLitDir;\nmediump vec4 cc_mainLitColor;\nmediump vec4 cc_ambientSky;\nmediump vec4 cc_ambientGround;\nmediump vec4 cc_fogColor;\nmediump vec4 cc_fogBase;\nmediump vec4 cc_fogAdd;\nmediump vec4 cc_nearFar;\nmediump vec4 cc_viewPort;\n};\nvec4 CCFragOutput (vec4 color) {\nreturn color;\n}\nvec4 frag () {\nreturn CCFragOutput(cc_shadowColor);\n}\nlayout(location = 0) out vec4 cc_FragColor;\nvoid main() { cc_FragColor = frag(); }", + } + ], + [ + { + "vert": "#extension GL_EXT_shader_explicit_arithmetic_types_int32: require\nprecision highp float;\nhighp float decode32 (highp vec4 rgba) {\nrgba = rgba * 255.0;\nhighp float Sign = 1.0 - (step(128.0, (rgba[3]) + 0.5)) * 2.0;\nhighp float Exponent = 2.0 * (mod(float(int((rgba[3]) + 0.5)), 128.0)) + (step(128.0, (rgba[2]) + 0.5)) - 127.0;\nhighp float Mantissa = (mod(float(int((rgba[2]) + 0.5)), 128.0)) * 65536.0 + rgba[1] * 256.0 + rgba[0] + 8388608.0;\nreturn Sign * exp2(Exponent - 23.0) * Mantissa;\n}\nstruct StandardVertInput {\nhighp vec4 position;\nvec3 normal;\nvec4 tangent;\n};\nlayout(location = 0) in vec3 a_position;\nlayout(location = 1) in vec3 a_normal;\nlayout(location = 2) in vec2 a_texCoord;\nlayout(location = 3) in vec4 a_tangent;\n#if CC_USE_MORPH\nint getVertexId() {\nreturn gl_VertexIndex;\n}\nlayout(set = 2, binding = 4) uniform CCMorph {\nvec4 cc_displacementWeights[15];\nvec4 cc_displacementTextureInfo;\n};\nvec2 getPixelLocation(vec2 textureResolution, int pixelIndex) {\nfloat pixelIndexF = float(pixelIndex);\nfloat x = mod(pixelIndexF, textureResolution.x);\nfloat y = floor(pixelIndexF / textureResolution.x);\nreturn vec2(x, y);\n}\nvec2 getPixelCoordFromLocation(vec2 location, vec2 textureResolution) {\nreturn (vec2(location.x, location.y) + .5) / textureResolution;\n}\n#if CC_DEVICE_SUPPORT_FLOAT_TEXTURE\nvec4 fetchVec3ArrayFromTexture(sampler2D tex, int pixelIndex) {\nivec2 texSize = textureSize(tex, 0);\nreturn texelFetch(tex, ivec2(pixelIndex % texSize.x, pixelIndex / texSize.x), 0);\n}\n#else\nvec4 fetchVec3ArrayFromTexture(sampler2D tex, int elementIndex) {\nint pixelIndex = elementIndex * 4;\nvec2 location = getPixelLocation(cc_displacementTextureInfo.xy, pixelIndex);\nvec2 x = getPixelCoordFromLocation(location + vec2(0.0, 0.0), cc_displacementTextureInfo.xy);\nvec2 y = getPixelCoordFromLocation(location + vec2(1.0, 0.0), cc_displacementTextureInfo.xy);\nvec2 z = getPixelCoordFromLocation(location + vec2(2.0, 0.0), cc_displacementTextureInfo.xy);\nreturn vec4(\ndecode32(texture(tex, x)),\ndecode32(texture(tex, y)),\ndecode32(texture(tex, z)),\n1.0\n);\n}\n#endif\nfloat getDisplacementWeight(int index) {\nint quot = index / 4;\nint remainder = index - quot * 4;\nif (remainder == 0) {\nreturn cc_displacementWeights[quot].x;\n} else if (remainder == 1) {\nreturn cc_displacementWeights[quot].y;\n} else if (remainder == 2) {\nreturn cc_displacementWeights[quot].z;\n} else {\nreturn cc_displacementWeights[quot].w;\n}\n}\nvec3 getVec3DisplacementFromTexture(sampler2D tex, int vertexIndex) {\n#if CC_MORPH_PRECOMPUTED\nreturn fetchVec3ArrayFromTexture(tex, vertexIndex).rgb;\n#else\nvec3 result = vec3(0, 0, 0);\nint nVertices = int(cc_displacementTextureInfo.z);\nfor (int iTarget = 0; iTarget < CC_MORPH_TARGET_COUNT; ++iTarget) {\nresult += (fetchVec3ArrayFromTexture(tex, nVertices * iTarget + vertexIndex).rgb * getDisplacementWeight(iTarget));\n}\nreturn result;\n#endif\n}\n#if CC_MORPH_TARGET_HAS_POSITION\nlayout(set = 2, binding = 7) uniform sampler2D cc_PositionDisplacements;\nvec3 getPositionDisplacement(int vertexId) {\nreturn getVec3DisplacementFromTexture(cc_PositionDisplacements, vertexId);\n}\n#endif\n#if CC_MORPH_TARGET_HAS_NORMAL\nlayout(set = 2, binding = 8) uniform sampler2D cc_NormalDisplacements;\nvec3 getNormalDisplacement(int vertexId) {\nreturn getVec3DisplacementFromTexture(cc_NormalDisplacements, vertexId);\n}\n#endif\n#if CC_MORPH_TARGET_HAS_TANGENT\nlayout(set = 2, binding = 9) uniform sampler2D cc_TangentDisplacements;\nvec3 getTangentDisplacement(int vertexId) {\nreturn getVec3DisplacementFromTexture(cc_TangentDisplacements, vertexId);\n}\n#endif\nvoid applyMorph (inout StandardVertInput attr) {\nint vertexId = getVertexId();\n#if CC_MORPH_TARGET_HAS_POSITION\nattr.position.xyz = attr.position.xyz + getPositionDisplacement(vertexId);\n#endif\n#if CC_MORPH_TARGET_HAS_NORMAL\nattr.normal.xyz = attr.normal.xyz + getNormalDisplacement(vertexId);\n#endif\n#if CC_MORPH_TARGET_HAS_TANGENT\nattr.tangent.xyz = attr.tangent.xyz + getTangentDisplacement(vertexId);\n#endif\n}\nvoid applyMorph (inout vec4 position) {\n#if CC_MORPH_TARGET_HAS_POSITION\nposition.xyz = position.xyz + getPositionDisplacement(getVertexId());\n#endif\n}\n#endif\n#if CC_USE_SKINNING\nlayout(location = 4) in u32vec4 a_joints;\nlayout(location = 5) in vec4 a_weights;\n#if CC_USE_BAKED_ANIMATION\n#if USE_INSTANCING\nlayout(location = 7) in highp vec4 a_jointAnimInfo;\n#endif\nlayout(set = 2, binding = 3) uniform CCSkinningTexture {\nhighp vec4 cc_jointTextureInfo;\n};\nlayout(set = 2, binding = 2) uniform CCSkinningAnimation {\nhighp vec4 cc_jointAnimInfo;\n};\nlayout(set = 2, binding = 6) uniform highp sampler2D cc_jointTexture;\n#else\nlayout(set = 2, binding = 3) uniform CCSkinning {\nhighp vec4 cc_joints[30 * 3];\n};\n#endif\n#if CC_USE_BAKED_ANIMATION\n#if CC_DEVICE_SUPPORT_FLOAT_TEXTURE\nmat4 getJointMatrix (float i) {\n#if USE_INSTANCING\nhighp float j = 3.0 * (a_jointAnimInfo.x * a_jointAnimInfo.y + i) + a_jointAnimInfo.z;\n#else\nhighp float j = 3.0 * (cc_jointAnimInfo.x * cc_jointTextureInfo.y + i) + cc_jointTextureInfo.z;\n#endif\nhighp float invSize = cc_jointTextureInfo.w;\nhighp float y = floor(j * invSize);\nhighp float x = floor(j - y * cc_jointTextureInfo.x);\ny = (y + 0.5) * invSize;\nvec4 v1 = texture(cc_jointTexture, vec2((x + 0.5) * invSize, y));\nvec4 v2 = texture(cc_jointTexture, vec2((x + 1.5) * invSize, y));\nvec4 v3 = texture(cc_jointTexture, vec2((x + 2.5) * invSize, y));\nreturn mat4(vec4(v1.xyz, 0.0), vec4(v2.xyz, 0.0), vec4(v3.xyz, 0.0), vec4(v1.w, v2.w, v3.w, 1.0));\n}\n#else\nmat4 getJointMatrix (float i) {\n#if USE_INSTANCING\nhighp float j = 12.0 * (a_jointAnimInfo.x * a_jointAnimInfo.y + i) + a_jointAnimInfo.z;\n#else\nhighp float j = 12.0 * (cc_jointAnimInfo.x * cc_jointTextureInfo.y + i) + cc_jointTextureInfo.z;\n#endif\nhighp float invSize = cc_jointTextureInfo.w;\nhighp float y = floor(j * invSize);\nhighp float x = floor(j - y * cc_jointTextureInfo.x);\ny = (y + 0.5) * invSize;\nvec4 v1 = vec4(\ndecode32(texture(cc_jointTexture, vec2((x + 0.5) * invSize, y))),\ndecode32(texture(cc_jointTexture, vec2((x + 1.5) * invSize, y))),\ndecode32(texture(cc_jointTexture, vec2((x + 2.5) * invSize, y))),\ndecode32(texture(cc_jointTexture, vec2((x + 3.5) * invSize, y)))\n);\nvec4 v2 = vec4(\ndecode32(texture(cc_jointTexture, vec2((x + 4.5) * invSize, y))),\ndecode32(texture(cc_jointTexture, vec2((x + 5.5) * invSize, y))),\ndecode32(texture(cc_jointTexture, vec2((x + 6.5) * invSize, y))),\ndecode32(texture(cc_jointTexture, vec2((x + 7.5) * invSize, y)))\n);\nvec4 v3 = vec4(\ndecode32(texture(cc_jointTexture, vec2((x + 8.5) * invSize, y))),\ndecode32(texture(cc_jointTexture, vec2((x + 9.5) * invSize, y))),\ndecode32(texture(cc_jointTexture, vec2((x + 10.5) * invSize, y))),\ndecode32(texture(cc_jointTexture, vec2((x + 11.5) * invSize, y)))\n);\nreturn mat4(vec4(v1.xyz, 0.0), vec4(v2.xyz, 0.0), vec4(v3.xyz, 0.0), vec4(v1.w, v2.w, v3.w, 1.0));\n}\n#endif\n#else\nmat4 getJointMatrix (float i) {\nint idx = int(i);\nvec4 v1 = cc_joints[idx * 3];\nvec4 v2 = cc_joints[idx * 3 + 1];\nvec4 v3 = cc_joints[idx * 3 + 2];\nreturn mat4(vec4(v1.xyz, 0.0), vec4(v2.xyz, 0.0), vec4(v3.xyz, 0.0), vec4(v1.w, v2.w, v3.w, 1.0));\n}\n#endif\nmat4 skinMatrix () {\nvec4 joints = vec4(a_joints);\nreturn getJointMatrix(joints.x) * a_weights.x\n+ getJointMatrix(joints.y) * a_weights.y\n+ getJointMatrix(joints.z) * a_weights.z\n+ getJointMatrix(joints.w) * a_weights.w;\n}\nvoid CCSkin (inout vec4 position) {\nmat4 m = skinMatrix();\nposition = m * position;\n}\nvoid CCSkin (inout StandardVertInput attr) {\nmat4 m = skinMatrix();\nattr.position = m * attr.position;\nattr.normal = (m * vec4(attr.normal, 0.0)).xyz;\nattr.tangent.xyz = (m * vec4(attr.tangent.xyz, 0.0)).xyz;\n}\n#endif\nlayout(set = 0, binding = 0) uniform CCGlobal {\nhighp vec4 cc_time;\nmediump vec4 cc_screenSize;\nmediump vec4 cc_nativeSize;\n};\nlayout(set = 0, binding = 1) uniform CCCamera {\nhighp mat4 cc_matView;\nhighp mat4 cc_matViewInv;\nhighp mat4 cc_matProj;\nhighp mat4 cc_matProjInv;\nhighp mat4 cc_matViewProj;\nhighp mat4 cc_matViewProjInv;\nhighp vec4 cc_cameraPos;\nmediump vec4 cc_screenScale;\nmediump vec4 cc_exposure;\nmediump vec4 cc_mainLitDir;\nmediump vec4 cc_mainLitColor;\nmediump vec4 cc_ambientSky;\nmediump vec4 cc_ambientGround;\nmediump vec4 cc_fogColor;\nmediump vec4 cc_fogBase;\nmediump vec4 cc_fogAdd;\nmediump vec4 cc_nearFar;\nmediump vec4 cc_viewPort;\n};\nlayout(location = 0) out vec2 v_uv;\nvoid main () {\nStandardVertInput In;\nIn.position = vec4(a_position, 1.0);\nIn.normal = a_normal;\nIn.tangent = a_tangent;\n#if CC_USE_MORPH\napplyMorph(In);\n#endif\n#if CC_USE_SKINNING\nCCSkin(In);\n#endif\nIn.position.xy = cc_cameraPos.w == 0.0 ? vec2(In.position.xy.x, -In.position.xy.y) : In.position.xy;\ngl_Position = In.position;\ngl_Position.y = gl_Position.y;\nv_uv = a_texCoord;\n}", + "frag": "\nprecision highp float;\nlayout(set = 0, binding = 0) uniform CCGlobal {\nhighp vec4 cc_time;\nmediump vec4 cc_screenSize;\nmediump vec4 cc_nativeSize;\n};\nlayout(set = 0, binding = 1) uniform CCCamera {\nhighp mat4 cc_matView;\nhighp mat4 cc_matViewInv;\nhighp mat4 cc_matProj;\nhighp mat4 cc_matProjInv;\nhighp mat4 cc_matViewProj;\nhighp mat4 cc_matViewProjInv;\nhighp vec4 cc_cameraPos;\nmediump vec4 cc_screenScale;\nmediump vec4 cc_exposure;\nmediump vec4 cc_mainLitDir;\nmediump vec4 cc_mainLitColor;\nmediump vec4 cc_ambientSky;\nmediump vec4 cc_ambientGround;\nmediump vec4 cc_fogColor;\nmediump vec4 cc_fogBase;\nmediump vec4 cc_fogAdd;\nmediump vec4 cc_nearFar;\nmediump vec4 cc_viewPort;\n};\n#if ANTIALIAS_TYPE == 1\nvec4 fxaa(sampler2D tex, vec2 fragCoord, vec2 resolution,\nvec2 v_rgbNW, vec2 v_rgbNE,\nvec2 v_rgbSW, vec2 v_rgbSE,\nvec2 v_rgbM) {\nvec4 color;\nmediump vec2 inverseVP = vec2(1.0 / resolution.x, 1.0 / resolution.y);\nvec3 rgbNW = texture(tex, v_rgbNW).xyz;\nvec3 rgbNE = texture(tex, v_rgbNE).xyz;\nvec3 rgbSW = texture(tex, v_rgbSW).xyz;\nvec3 rgbSE = texture(tex, v_rgbSE).xyz;\nvec4 texColor = texture(tex, v_rgbM);\nvec3 rgbM = texColor.xyz;\nvec3 luma = vec3(0.299, 0.587, 0.114);\nfloat lumaNW = dot(rgbNW, luma);\nfloat lumaNE = dot(rgbNE, luma);\nfloat lumaSW = dot(rgbSW, luma);\nfloat lumaSE = dot(rgbSE, luma);\nfloat lumaM = dot(rgbM, luma);\nfloat lumaMin = min(lumaM, min(min(lumaNW, lumaNE), min(lumaSW, lumaSE)));\nfloat lumaMax = max(lumaM, max(max(lumaNW, lumaNE), max(lumaSW, lumaSE)));\nmediump vec2 dir;\ndir.x = -((lumaNW + lumaNE) - (lumaSW + lumaSE));\ndir.y = ((lumaNW + lumaSW) - (lumaNE + lumaSE));\nfloat dirReduce = max((lumaNW + lumaNE + lumaSW + lumaSE) *\n(0.25 * (1.0 / 8.0)), (1.0/ 128.0));\nfloat rcpDirMin = 1.0 / (min(abs(dir.x), abs(dir.y)) + dirReduce);\ndir = min(vec2(8.0, 8.0),\nmax(vec2(-8.0, -8.0),\ndir * rcpDirMin)) * inverseVP;\nvec3 rgbA = 0.5 * (\ntexture(tex, fragCoord * inverseVP + dir * (1.0 / 3.0 - 0.5)).xyz +\ntexture(tex, fragCoord * inverseVP + dir * (2.0 / 3.0 - 0.5)).xyz);\nvec3 rgbB = rgbA * 0.5 + 0.25 * (\ntexture(tex, fragCoord * inverseVP + dir * -0.5).xyz +\ntexture(tex, fragCoord * inverseVP + dir * 0.5).xyz);\nfloat lumaB = dot(rgbB, luma);\nif ((lumaB < lumaMin) || (lumaB > lumaMax))\ncolor = vec4(rgbA, texColor.a);\nelse\ncolor = vec4(rgbB, texColor.a);\nreturn color;\n}\n#endif\nlayout(location = 0) in vec2 v_uv;\nlayout(set = 1, binding = 0) uniform sampler2D outputResultMap;\nlayout(location = 0) out vec4 fragColor;\nvoid texcoords(vec2 fragCoord, vec2 resolution,\nout vec2 v_rgbNW, out vec2 v_rgbNE,\nout vec2 v_rgbSW, out vec2 v_rgbSE,\nout vec2 v_rgbM) {\nvec2 inverseVP = 1.0 / resolution.xy;\nv_rgbNW = (fragCoord + vec2(-1.0, -1.0)) * inverseVP;\nv_rgbNE = (fragCoord + vec2(1.0, -1.0)) * inverseVP;\nv_rgbSW = (fragCoord + vec2(-1.0, 1.0)) * inverseVP;\nv_rgbSE = (fragCoord + vec2(1.0, 1.0)) * inverseVP;\nv_rgbM = vec2(fragCoord * inverseVP);\n}\nvoid main () {\nmediump vec2 v_rgbNW;\nmediump vec2 v_rgbNE;\nmediump vec2 v_rgbSW;\nmediump vec2 v_rgbSE;\nmediump vec2 v_rgbM;\n#if ANTIALIAS_TYPE == 1\nvec2 resolution = cc_screenSize.xy;\nvec2 fragCoord = v_uv * resolution;\ntexcoords(fragCoord, resolution, v_rgbNW, v_rgbNE, v_rgbSW, v_rgbSE, v_rgbM);\nfragColor = fxaa(outputResultMap, fragCoord, resolution, v_rgbNW, v_rgbNE, v_rgbSW, v_rgbSE, v_rgbM);\n#else\nfragColor = texture(outputResultMap, v_uv);\n#endif\n}", + } + ], + [ + { + "vert": "\nprecision highp float;\nlayout(set = 0, binding = 0) uniform CCGlobal {\nhighp vec4 cc_time;\nmediump vec4 cc_screenSize;\nmediump vec4 cc_nativeSize;\n};\nlayout(set = 0, binding = 1) uniform CCCamera {\nhighp mat4 cc_matView;\nhighp mat4 cc_matViewInv;\nhighp mat4 cc_matProj;\nhighp mat4 cc_matProjInv;\nhighp mat4 cc_matViewProj;\nhighp mat4 cc_matViewProjInv;\nhighp vec4 cc_cameraPos;\nmediump vec4 cc_screenScale;\nmediump vec4 cc_exposure;\nmediump vec4 cc_mainLitDir;\nmediump vec4 cc_mainLitColor;\nmediump vec4 cc_ambientSky;\nmediump vec4 cc_ambientGround;\nmediump vec4 cc_fogColor;\nmediump vec4 cc_fogBase;\nmediump vec4 cc_fogAdd;\nmediump vec4 cc_nearFar;\nmediump vec4 cc_viewPort;\n};\nstruct StandardVertInput {\nhighp vec4 position;\nvec3 normal;\nvec4 tangent;\n};\nlayout(location = 0) in vec3 a_position;\nlayout(location = 1) in vec3 a_normal;\nlayout(location = 2) in vec2 a_texCoord;\nlayout(location = 3) in vec4 a_tangent;\nlayout(location = 0) out mediump vec4 viewDir;\nvec4 vert () {\nviewDir = vec4(a_position, 1.0);\nmat4 matViewRotOnly = mat4(mat3(cc_matView));\nvec4 pos = matViewRotOnly * viewDir;\nif (cc_matProj[3].w > 0.0) {\nmat4 matProj = cc_matProj;\nvec2 scale = vec2(48.0, 24.0);\nmatProj[0].xy *= scale;\nmatProj[1].xy *= scale;\nmatProj[2].zw = vec2(-1.0);\nmatProj[3].zw = vec2(0.0);\npos = matProj * pos;\n} else {\npos = cc_matProj * pos;\n}\npos.z = 0.99999 * pos.w;\nreturn pos;\n}\nvoid main() { gl_Position = vert(); }", + "frag": "\nprecision mediump float;\nlayout(set = 0, binding = 0) uniform CCGlobal {\nhighp vec4 cc_time;\nmediump vec4 cc_screenSize;\nmediump vec4 cc_nativeSize;\n};\nlayout(set = 0, binding = 1) uniform CCCamera {\nhighp mat4 cc_matView;\nhighp mat4 cc_matViewInv;\nhighp mat4 cc_matProj;\nhighp mat4 cc_matProjInv;\nhighp mat4 cc_matViewProj;\nhighp mat4 cc_matViewProjInv;\nhighp vec4 cc_cameraPos;\nmediump vec4 cc_screenScale;\nmediump vec4 cc_exposure;\nmediump vec4 cc_mainLitDir;\nmediump vec4 cc_mainLitColor;\nmediump vec4 cc_ambientSky;\nmediump vec4 cc_ambientGround;\nmediump vec4 cc_fogColor;\nmediump vec4 cc_fogBase;\nmediump vec4 cc_fogAdd;\nmediump vec4 cc_nearFar;\nmediump vec4 cc_viewPort;\n};\nlayout(set = 0, binding = 4) uniform samplerCube cc_environment;\nvec3 unpackRGBE (vec4 rgbe) {\nreturn rgbe.rgb * pow(1.1, rgbe.a * 255.0 - 128.0);\n}\nvec3 SRGBToLinear (vec3 gamma) {\nreturn gamma * gamma;\n}\nvec3 ACESToneMap (vec3 color) {\ncolor = min(color, vec3(8.0));\nconst float A = 2.51;\nconst float B = 0.03;\nconst float C = 2.43;\nconst float D = 0.59;\nconst float E = 0.14;\nreturn (color * (A * color + B)) / (color * (C * color + D) + E);\n}\nvec4 CCFragOutput (vec4 color) {\n#if CC_USE_HDR\ncolor.rgb = ACESToneMap(color.rgb);\n#endif\ncolor.rgb = sqrt(color.rgb);\nreturn color;\n}\nlayout(location = 0) in mediump vec4 viewDir;\nvec4 frag () {\n#if USE_RGBE_CUBEMAP\nvec3 c = unpackRGBE(texture(cc_environment, viewDir.xyz));\n#else\nvec3 c = SRGBToLinear(texture(cc_environment, viewDir.xyz).rgb);\n#endif\nreturn CCFragOutput(vec4(c * cc_ambientSky.w, 1.0));\n}\nlayout(location = 0) out vec4 cc_FragColor;\nvoid main() { cc_FragColor = frag(); }", + } + ], + [ + { + "vert": "\nprecision mediump float;\nlayout(set = 0, binding = 0) uniform CCGlobal {\nhighp vec4 cc_time;\nmediump vec4 cc_screenSize;\nmediump vec4 cc_nativeSize;\n};\nlayout(set = 0, binding = 1) uniform CCCamera {\nhighp mat4 cc_matView;\nhighp mat4 cc_matViewInv;\nhighp mat4 cc_matProj;\nhighp mat4 cc_matProjInv;\nhighp mat4 cc_matViewProj;\nhighp mat4 cc_matViewProjInv;\nhighp vec4 cc_cameraPos;\nmediump vec4 cc_screenScale;\nmediump vec4 cc_exposure;\nmediump vec4 cc_mainLitDir;\nmediump vec4 cc_mainLitColor;\nmediump vec4 cc_ambientSky;\nmediump vec4 cc_ambientGround;\nmediump vec4 cc_fogColor;\nmediump vec4 cc_fogBase;\nmediump vec4 cc_fogAdd;\nmediump vec4 cc_nearFar;\nmediump vec4 cc_viewPort;\n};\nlayout(location = 0) in vec3 a_position;\nlayout(location = 1) in vec4 a_color;\nlayout(location = 0) out vec2 v_uv;\nlayout(set = 1, binding = 0) uniform Constants {\nvec4 offset;\n};\nlayout(set = 1, binding = 1) uniform PerFrameInfo {\nvec4 digits[8 * 10 / 4];\n};\nfloat getComponent(vec4 v, float i) {\nif (i < 1.0) { return v.x; }\nelse if (i < 2.0) { return v.y; }\nelse if (i < 3.0) { return v.z; }\nelse { return v.w; }\n}\nvec4 vert () {\nmat2 proj = mat2(cc_matProj[0].xy, cc_matProj[1].xy);\nproj /= abs(proj[1].x + proj[1].y);\nvec2 position = proj * a_position.xy + offset.xy;\nv_uv = a_color.xy;\nif (a_color.z >= 0.0) {\nfloat n = getComponent(digits[int(a_color.z)], a_color.w);\nv_uv += vec2(offset.z * n, 0.0);\n}\nreturn vec4(position, 0.0, 1.0);\n}\nvoid main() { gl_Position = vert(); }", + "frag": "\nprecision mediump float;\nlayout(set = 0, binding = 0) uniform CCGlobal {\nhighp vec4 cc_time;\nmediump vec4 cc_screenSize;\nmediump vec4 cc_nativeSize;\n};\nlayout(set = 0, binding = 1) uniform CCCamera {\nhighp mat4 cc_matView;\nhighp mat4 cc_matViewInv;\nhighp mat4 cc_matProj;\nhighp mat4 cc_matProjInv;\nhighp mat4 cc_matViewProj;\nhighp mat4 cc_matViewProjInv;\nhighp vec4 cc_cameraPos;\nmediump vec4 cc_screenScale;\nmediump vec4 cc_exposure;\nmediump vec4 cc_mainLitDir;\nmediump vec4 cc_mainLitColor;\nmediump vec4 cc_ambientSky;\nmediump vec4 cc_ambientGround;\nmediump vec4 cc_fogColor;\nmediump vec4 cc_fogBase;\nmediump vec4 cc_fogAdd;\nmediump vec4 cc_nearFar;\nmediump vec4 cc_viewPort;\n};\nvec4 CCFragOutput (vec4 color) {\nreturn color;\n}\nlayout(location = 0) in vec2 v_uv;\nlayout(set = 1, binding = 2) uniform sampler2D mainTexture;\nvec4 frag () {\nreturn CCFragOutput(texture(mainTexture, v_uv));\n}\nlayout(location = 0) out vec4 cc_FragColor;\nvoid main() { cc_FragColor = frag(); }", + } + ], + [ + { + "vert": "\nprecision mediump float;\nlayout(location = 0) in vec2 a_position;\nlayout(location = 1) in vec2 a_texCoord;\nlayout(location = 0) out vec2 v_uv;\nlayout(set = 1, binding = 0) uniform Constant {\nvec4 u_buffer0;\nvec4 u_buffer1;\nmat4 u_projection;\n};\nvec4 vert () {\nvec2 worldPos = a_position * u_buffer1.xy + u_buffer1.zw;\nvec2 clipSpace = worldPos / u_buffer0.xy * 2.0 - 1.0;\nvec4 screenPos = u_projection * vec4(clipSpace, 0.0, 1.0);\nv_uv = a_texCoord;\nreturn screenPos;\n}\nvoid main() { gl_Position = vert(); }", + "frag": "\nprecision mediump float;\nlayout(location = 0) in vec2 v_uv;\nlayout(set = 1, binding = 1) uniform Factor {\nfloat u_percent;\n};\nlayout(set = 1, binding = 2) uniform sampler2D mainTexture;\nvec4 frag () {\nvec4 color = texture(mainTexture, v_uv);\nfloat percent = clamp(u_percent, 0.0, 1.0);\ncolor.xyz *= percent;\nreturn color;\n}\nlayout(location = 0) out vec4 cc_FragColor;\nvoid main() { cc_FragColor = frag(); }", + } + ] +]; diff --git a/native/cocos/core/data/Object.cpp b/native/cocos/core/data/Object.cpp new file mode 100644 index 0000000000..ce5414e4c5 --- /dev/null +++ b/native/cocos/core/data/Object.cpp @@ -0,0 +1,118 @@ +/**************************************************************************** + 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/data/Object.h" + +#include + +namespace cc { + +namespace { +std::vector objectsToDestroy; +} + +/* static */ +void CCObject::deferredDestroy() { + if (objectsToDestroy.empty()) return; + auto deleteCount = static_cast(objectsToDestroy.size()); + for (size_t i = 0; i < deleteCount; ++i) { + CCObject *obj = objectsToDestroy[i]; + if (!(obj->_objFlags & Flags::DESTROYED)) { + obj->destroyImmediate(); + obj->release(); + } + } + // if we called b.destory() in a.onDestroy(), objectsToDestroy will be resized, + // but we only destroy the objects which called destory in this frame. + if (deleteCount == objectsToDestroy.size()) { + objectsToDestroy.clear(); + } else { + objectsToDestroy.erase(objectsToDestroy.begin(), objectsToDestroy.begin() + deleteCount); + } + + //cjh TODO: if (EDITOR) { + // deferredDestroyTimer = null; + // } +} + +CCObject::CCObject(std::string name /* = ""*/) +: _name(std::move(name)) { +} + +bool CCObject::destroy() { + if (static_cast(_objFlags & Flags::DESTROYED)) { + //cjh TODO: warnID(5000); + return false; + } + if (static_cast(_objFlags & Flags::TO_DESTROY)) { + return false; + } + _objFlags |= Flags::TO_DESTROY; + addRef(); + objectsToDestroy.emplace_back(this); + + //cjh TODO: if (EDITOR && deferredDestroyTimer === null && legacyCC.engine && !legacyCC.engine._isUpdating) { + // // auto destroy immediate in edit mode + // // @ts-expect-error no function + // deferredDestroyTimer = setImmediate(CCObject._deferredDestroy); + // } + return true; +} + +void CCObject::destruct() { + //cjh TODO: it seems that this function doesn't need to be implemented in c++ + // const ctor: any = this.constructor; + // let destruct = ctor.__destruct__; + // if (!destruct) { + // destruct = compileDestruct(this, ctor); + // js.value(ctor, '__destruct__', destruct, true); + // } + // destruct(this); +} + +void CCObject::destroyImmediate() { + if (static_cast(_objFlags & Flags::DESTROYED)) { + //cjh TODO: errorID(5000); + return; + } + + onPreDestroy(); + + //cjh TODO: if (!EDITOR || legacyCC.GAME_VIEW) { + destruct(); + // } + + _objFlags |= Flags::DESTROYED; +} + +bool isObjectValid(CCObject *value, bool strictMode /* = false*/) { + if (value == nullptr) { + return false; + } + + return !(value->_objFlags & (strictMode ? (CCObject::Flags::DESTROYED | CCObject::Flags::TO_DESTROY) : CCObject::Flags::DESTROYED)); +} + +} // namespace cc diff --git a/native/cocos/core/data/Object.h b/native/cocos/core/data/Object.h new file mode 100644 index 0000000000..dca4b68cce --- /dev/null +++ b/native/cocos/core/data/Object.h @@ -0,0 +1,292 @@ +/**************************************************************************** + 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 + +#include "base/Macros.h" +#include "base/RefCounted.h" +#include "base/TypeDef.h" + +namespace cc { + +/** + * @en + * The base class of most of all the objects in Cocos Creator. + * @zh + * 大部分对象的基类。 + * @private + */ +class CCObject : public RefCounted /*cjh implements EditorExtendableObject*/ { +public: + // definitions for CCObject.Flags + enum class Flags : FlagBits { + ZERO = 0, + DESTROYED = 1 << 0, + REAL_DESTROYED = 1 << 1, + TO_DESTROY = 1 << 2, + /** + * @en The object will not be saved. + * @zh 该对象将不会被保存。 + */ + DONT_SAVE = 1 << 3, + /** + * @en The object will not be saved when building a player. + * @zh 构建项目时,该对象将不会被保存。 + */ + EDITOR_ONLY = 1 << 4, + DIRTY = 1 << 5, + /** + * @en Dont destroy automatically when loading a new scene. + * @zh 加载一个新场景时,不自动删除该对象。 + * @private + */ + DONT_DESTROY = 1 << 6, + DESTROYING = 1 << 7, + /** + * @en The node is deactivating. + * @zh 节点正在反激活的过程中。 + * @private + */ + DEACTIVATING = 1 << 8, + /** + * @en The lock node, when the node is locked, cannot be clicked in the scene. + * @zh 锁定节点,锁定后场景内不能点击。 + * @private + */ + LOCKED_IN_EDITOR = 1 << 9, + /** + * @en Hide the object in editor. + * @zh 在编辑器中隐藏该对象。 + */ + HIDE_IN_HIERARCHY = 1 << 10, + + IS_ON_ENABLE_CALLED = 1 << 11, + IS_EDITOR_ON_ENABLE_CALLED = 1 << 12, + IS_PRELOAD_STARTED = 1 << 13, + IS_ON_LOAD_CALLED = 1 << 14, + IS_ON_LOAD_STARTED = 1 << 15, + IS_START_CALLED = 1 << 16, + + IS_ROTATION_LOCKED = 1 << 17, + IS_SCALE_LOCKED = 1 << 18, + IS_ANCHOR_LOCKED = 1 << 19, + IS_SIZE_LOCKED = 1 << 20, + IS_POSITION_LOCKED = 1 << 21, + + // Distributed + IS_REPLICATED = 1 << 22, + IS_CLIENT_LOAD = 1 << 23, + + // var Hide = HideInGame | HideInEditor; + // should not clone or serialize these flags + PERSISTENT_MASK = ~(TO_DESTROY | DIRTY | DESTROYING | DONT_DESTROY | DEACTIVATING | IS_PRELOAD_STARTED | IS_ON_LOAD_STARTED | IS_ON_LOAD_CALLED | IS_START_CALLED | IS_ON_ENABLE_CALLED | IS_EDITOR_ON_ENABLE_CALLED | IS_ROTATION_LOCKED | IS_SCALE_LOCKED | IS_ANCHOR_LOCKED | IS_SIZE_LOCKED | IS_POSITION_LOCKED + /* RegisteredInEditor */), + + // all the hideFlags + /** + * @en The object will not be saved and hide the object in editor,and lock node, when the node is locked, + * cannot be clicked in the scene,and The object will not be saved when building a player. + * @zh 该对象将不会被保存,构建项目时,该对象将不会被保存, 锁定节点,锁定后场景内不能点击, 在编辑器中隐藏该对象。 + */ + ALL_HIDE_MASKS = DONT_SAVE | EDITOR_ONLY | LOCKED_IN_EDITOR | HIDE_IN_HIERARCHY, + }; + + static void deferredDestroy(); + + //cjh public declare [editorExtrasTag]: unknown; + + Flags _objFlags{Flags::ZERO}; + std::string _name; + +protected: + explicit CCObject(std::string name = ""); + ~CCObject() override = default; + +public: + // MEMBER + + /** + * @en The name of the object. + * @zh 该对象的名称。 + * @default "" + * @example + * ``` + * obj.name = "New Obj"; + * ``` + */ + inline const std::string &getName() const { return _name; } + inline void setName(const std::string &value) { _name = value; } + + /** + * @en After inheriting CCObject objects, control whether you need to hide, lock, serialize, and other functions. + * @zh 在继承 CCObject 对象后,控制是否需要隐藏,锁定,序列化等功能。 + */ + inline void setHideFlags(Flags hideFlags); + inline Flags getHideFlags() const; + + inline void setReplicated(bool value); + inline bool isReplicated() const; + + /** + * @en + * Indicates whether the object is not yet destroyed. (It will not be available after being destroyed)
+ * When an object's `destroy` is called, it is actually destroyed after the end of this frame. + * So `isValid` will return false from the next frame, while `isValid` in the current frame will still be true. + * If you want to determine whether the current frame has called `destroy`, use `isValid(obj, true)`, + * but this is often caused by a particular logical requirements, which is not normally required. + * + * @zh + * 表示该对象是否可用(被 destroy 后将不可用)。
+ * 当一个对象的 `destroy` 调用以后,会在这一帧结束后才真正销毁。
+ * 因此从下一帧开始 `isValid` 就会返回 false,而当前帧内 `isValid` 仍然会是 true。
+ * 如果希望判断当前帧是否调用过 `destroy`,请使用 `isValid(obj, true)`,不过这往往是特殊的业务需求引起的,通常情况下不需要这样。 + * @default true + * @readOnly + * @example + * ```ts + * import { Node, log } from 'cc'; + * const node = new Node(); + * log(node.isValid); // true + * node.destroy(); + * log(node.isValid); // true, still valid in this frame + * // after a frame... + * log(node.isValid); // false, destroyed in the end of last frame + * ``` + */ + inline bool isValid() const; + + /** + * @en + * Destroy this Object, and release all its own references to other objects.
+ * Actual object destruction will delayed until before rendering. + * From the next frame, this object is not usable any more. + * You can use `isValid(obj)` to check whether the object is destroyed before accessing it. + * @zh + * 销毁该对象,并释放所有它对其它对象的引用。
+ * 实际销毁操作会延迟到当前帧渲染前执行。从下一帧开始,该对象将不再可用。 + * 您可以在访问对象之前使用 `isValid(obj)` 来检查对象是否已被销毁。 + * @return whether it is the first time the destroy being called + * @example + * ``` + * obj.destroy(); + * ``` + */ + virtual bool destroy(); + + /** + * Clear all references in the instance. + * + * NOTE: this method will not clear the getter or setter functions which defined in the instance of CCObject. + * You can override the _destruct method if you need, for example: + * _destruct: function () { + * for (var key in this) { + * if (hasOwnProperty(key)) { + * switch (typeof this[key]) { + * case 'string': + * this[key] = ''; + * break; + * case 'object': + * case 'function': + * this[key] = null; + * break; + * } + * } + * } + * + */ + void destruct(); + + void destroyImmediate(); + + virtual std::string toString() const { return ""; }; + +protected: + virtual bool onPreDestroy() { + // FIXME: need reture value + return true; + } +}; + +CC_ENUM_BITWISE_OPERATORS(CCObject::Flags); + +inline bool CCObject::isValid() const { + return !(_objFlags & Flags::DESTROYED); +} + +inline void CCObject::setHideFlags(Flags hideFlags) { + Flags flags = hideFlags & Flags::ALL_HIDE_MASKS; + _objFlags = (_objFlags & ~Flags::ALL_HIDE_MASKS) | flags; +} + +inline CCObject::Flags CCObject::getHideFlags() const { + return _objFlags & Flags::ALL_HIDE_MASKS; +} + +inline void CCObject::setReplicated(bool value) { + if (value) { + _objFlags |= Flags::IS_REPLICATED; + } else { + _objFlags &= ~Flags::IS_REPLICATED; + } +} + +inline bool CCObject::isReplicated() const { + return !!(_objFlags & Flags::IS_REPLICATED); +} + +/* + * @en + * Checks whether the object is non-nil and not yet destroyed.
+ * When an object's `destroy` is called, it is actually destroyed after the end of this frame. + * So `isValid` will return false from the next frame, while `isValid` in the current frame will still be true. + * If you want to determine whether the current frame has called `destroy`, use `isValid(obj, true)`, + * but this is often caused by a particular logical requirements, which is not normally required. + * + * @zh + * 检查该对象是否不为 null 并且尚未销毁。
+ * 当一个对象的 `destroy` 调用以后,会在这一帧结束后才真正销毁。
+ * 因此从下一帧开始 `isValid` 就会返回 false,而当前帧内 `isValid` 仍然会是 true。
+ * 如果希望判断当前帧是否调用过 `destroy`,请使用 `isValid(obj, true)`,不过这往往是特殊的业务需求引起的,通常情况下不需要这样。 + * + * @method isValid + * @param value + * @param [strictMode=false] - If true, Object called destroy() in this frame will also treated as invalid. + * @return whether is valid + * @example + * ``` + * import { Node, log } from 'cc'; + * var node = new Node(); + * log(isValid(node)); // true + * node.destroy(); + * log(isValid(node)); // true, still valid in this frame + * // after a frame... + * log(isValid(node)); // false, destroyed in the end of last frame + * ``` + */ +bool isObjectValid(CCObject *value, bool strictMode = false); + +} // namespace cc diff --git a/native/cocos/core/data/deserializer/AssetDeserializerFactory.cpp b/native/cocos/core/data/deserializer/AssetDeserializerFactory.cpp new file mode 100644 index 0000000000..5eecdee0ca --- /dev/null +++ b/native/cocos/core/data/deserializer/AssetDeserializerFactory.cpp @@ -0,0 +1,65 @@ +/**************************************************************************** + 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/data/deserializer/AssetDeserializerFactory.h" +#include "core/data/deserializer/EffectAssetDeserializer.h" +//#include "core/data/deserializer/MaterialDeserializer.h" +//#include "core/data/deserializer/MeshDeserializer.h" +//#include "core/data/deserializer/TerrainAssetDeserializer.h" +//#include "core/data/deserializer/Texture2DDeserializer.h" +//#include "core/data/deserializer/TextureBaseDeserializer.h" + +namespace cc { + +/*static*/ +std::shared_ptr AssetDeserializerFactory::createAssetDeserializer(DeserializeAssetType type) { + std::shared_ptr deserializer; + switch (type) { + case DeserializeAssetType::EFFECT: + deserializer = std::make_shared(); + break; + // case DeserializeAssetType::MESH: + // deserializer = std::make_shared(); + // break; + // case DeserializeAssetType::MATERIAL: + // deserializer = std::make_shared(); + // break; + // case DeserializeAssetType::TEXTUREBASE: + // deserializer = std::make_shared(); + // break; + // case DeserializeAssetType::TEXTURE2D: + // deserializer = std::make_shared(); + // break; + // case DeserializeAssetType::TERRAIN: + // deserializer = std::make_shared(); + // break; + default: + break; + } + + return deserializer; +} + +} // namespace cc diff --git a/native/cocos/core/data/deserializer/AssetDeserializerFactory.h b/native/cocos/core/data/deserializer/AssetDeserializerFactory.h new file mode 100644 index 0000000000..1f33d62659 --- /dev/null +++ b/native/cocos/core/data/deserializer/AssetDeserializerFactory.h @@ -0,0 +1,48 @@ +/**************************************************************************** + 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 + +#include "core/data/deserializer/IAssetDeserializer.h" + +namespace cc { + +enum class DeserializeAssetType { + EFFECT, + MATERIAL, + MESH, + TEXTUREBASE, + TEXTURE2D, + TERRAIN, +}; + +class AssetDeserializerFactory final { +public: + static std::shared_ptr createAssetDeserializer(DeserializeAssetType type); +}; + +} // namespace cc diff --git a/native/cocos/core/data/deserializer/EffectAssetDeserializer.cpp b/native/cocos/core/data/deserializer/EffectAssetDeserializer.cpp new file mode 100644 index 0000000000..7982d25f0f --- /dev/null +++ b/native/cocos/core/data/deserializer/EffectAssetDeserializer.cpp @@ -0,0 +1,867 @@ +/**************************************************************************** + 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/data/deserializer/EffectAssetDeserializer.h" +#include "base/Log.h" +#include "core/assets/EffectAsset.h" + +namespace cc { + +template +using DeserializeArrayElementCallback = std::function; + +template +static void deserializeArray(const rapidjson::Value &valArray, std::vector &cValArray, const DeserializeArrayElementCallback &deserializeArrayElement) { + CC_ASSERT(valArray.IsArray()); + index_t i = 0; + cValArray.resize(valArray.Size()); + for (const auto &val : valArray.GetArray()) { + deserializeArrayElement(val, cValArray[i]); + ++i; + } +} + +static void deserializeArray(const rapidjson::Value &valArray, std::vector &cValArray) { + deserializeArray(valArray, cValArray, [](const rapidjson::Value &val, std::string &cVal) { + cVal = val.GetString(); + }); +} + +static void deserializeArray(const rapidjson::Value &valArray, std::vector &cValArray) { + CC_ASSERT(valArray.IsArray()); + index_t i = 0; + cValArray.resize(valArray.Size()); + // note: candidate function not viable: no known conversion from 'std::__1::vector::reference' (aka '__bit_reference>') to 'bool &' for 2nd argument + + for (const auto &val : valArray.GetArray()) { + cValArray[i] = val.GetBool(); + ++i; + } +} + +template ::value && !std::is_same::value, T>> +static void deserializeArray(const rapidjson::Value &valArray, std::vector &cValArray) { + DeserializeArrayElementCallback cb{[](const rapidjson::Value &val, T &cVal) { + cVal = val.Get(); + }}; + deserializeArray(valArray, cValArray, cb); +} + +static MacroRecord jsonToMacroRecord(const rapidjson::Value &embeddedMacrosVal) { + MacroRecord cEmbeddedMacros; + for (const auto ¯o : embeddedMacrosVal.GetObject()) { + const auto *name = macro.name.GetString(); + const auto &value = macro.value; + + // using MacroValue = cc::variant; + // MacroValue only support one of int32_t, float, bool, std::string + if (value.IsInt()) { + cEmbeddedMacros.emplace(name, value.GetInt()); + // CC_LOG_DEBUG(">> embeddedMacros[%s]=%d", name, value.GetInt()); + } else if (value.IsInt64()) { + cEmbeddedMacros.emplace(name, static_cast(value.GetInt64())); //cjh TODO: need int64? + // CC_LOG_DEBUG(">> embeddedMacros[%s]=%ld", name, value.GetInt64()); + } else if (value.IsFloat()) { + cEmbeddedMacros.emplace(name, value.GetFloat()); + // CC_LOG_DEBUG(">> embeddedMacros[%s]=%f", name, value.GetFloat()); + } else if (value.IsDouble()) { + cEmbeddedMacros.emplace(name, static_cast(value.GetDouble())); //cjh TODO: need double? + // CC_LOG_DEBUG(">> embeddedMacros[%s]=%lf", name, value.GetDouble()); + } else if (value.IsBool()) { + cEmbeddedMacros.emplace(name, value.GetBool()); + // CC_LOG_DEBUG(">> embeddedMacros[%s]=%d", name, static_cast(value.GetBool())); + } else if (value.IsString()) { + cEmbeddedMacros.emplace(name, value.GetString()); + // CC_LOG_DEBUG(">> embeddedMacros[%s]=%s", name, value.GetString()); + } else { + CC_LOG_WARNING("Unknown macro value type: %s", name); + } + } + + return cEmbeddedMacros; +} + +static IPropertyHandleInfo jsonToPropertyHandleInfo(const rapidjson::Value &handleInfoVal) { + if (handleInfoVal.IsArray()) { + // using IPropertyHandleInfo = std::tuple; + std::string t0; + uint32_t t1 = 0; + gfx::Type t2 = gfx::Type::UNKNOWN; + int32_t i = 0; + + for (const auto &e : handleInfoVal.GetArray()) { + switch (i) { + case 0: + t0 = e.GetString(); + break; + case 1: + t1 = e.GetUint(); + break; + case 2: + t2 = static_cast(e.GetUint()); + break; + default: + break; + } + + ++i; + } + + return IPropertyHandleInfo{t0, t1, t2}; + } + + return {}; +} + +static IPropertyInfo jsonToPropertyInfo(const rapidjson::Value &propertyInfoVal) { + IPropertyInfo ret; + + ret.type = propertyInfoVal["type"].GetInt(); + + if (propertyInfoVal.HasMember("value")) { + const auto &val = propertyInfoVal["value"]; + if (val.IsArray()) { + std::vector arr; + arr.reserve(val.GetArray().Size()); + for (const auto &e : val.GetArray()) { + if (e.IsNumber()) { + arr.emplace_back(e.GetFloat()); + } + } + ret.value = std::move(arr); + } else if (val.IsString()) { + ret.value = val.GetString(); + } else { + CC_ASSERT(false); + } + } + + if (propertyInfoVal.HasMember("handleInfo")) { + ret.handleInfo = jsonToPropertyHandleInfo(propertyInfoVal["handleInfo"]); + // using IPropertyHandleInfo = std::tuple; + // CC_LOG_DEBUG("handleInfo: %s, %u, %u", std::get<0>(ret.handleInfo.value()).c_str(), std::get<1>(ret.handleInfo.value()), static_cast(std::get<2>(ret.handleInfo.value()))); + } + + if (propertyInfoVal.HasMember("samplerHash")) { + ret.samplerHash = propertyInfoVal.GetUint64(); + // CC_LOG_DEBUG("samplerHash: %lu", ret.samplerHash.value()); + } + + return ret; +} + +static PassPropertyInfoMap jsonToPassPropertyInfoMap(const rapidjson::Value &propertyInfoMapVal) { + PassPropertyInfoMap propertyInfoMap; + + for (const auto &propertyVal : propertyInfoMapVal.GetObject()) { + const auto *name = propertyVal.name.GetString(); + const auto &value = propertyVal.value; + propertyInfoMap.emplace(name, jsonToPropertyInfo(value)); + } + + return propertyInfoMap; +} + +static RasterizerStateInfo jsonToRasterizerState(const rapidjson::Value &rasterizerStateVal) { + RasterizerStateInfo rasterizerState; + + CC_ASSERT(rasterizerStateVal.IsObject()); + + if (rasterizerStateVal.HasMember("cullMode")) { + rasterizerState.cullMode = static_cast(rasterizerStateVal["cullMode"].GetInt()); + // CC_LOG_DEBUG("cullMode: %d", static_cast(rasterizerState->cullMode)); + } + + if (rasterizerStateVal.HasMember("isDiscard")) { + rasterizerState.isDiscard = rasterizerStateVal["isDiscard"].GetUint(); + } + + if (rasterizerStateVal.HasMember("polygonMode")) { + rasterizerState.polygonMode = static_cast(rasterizerStateVal["polygonMode"].GetInt()); + } + + if (rasterizerStateVal.HasMember("shadeModel")) { + rasterizerState.shadeModel = static_cast(rasterizerStateVal["shadeModel"].GetInt()); + } + + if (rasterizerStateVal.HasMember("isFrontFaceCCW")) { + rasterizerState.isFrontFaceCCW = rasterizerStateVal["isFrontFaceCCW"].GetUint(); + } + + if (rasterizerStateVal.HasMember("depthBiasEnabled")) { + rasterizerState.depthBiasEnabled = rasterizerStateVal["depthBiasEnabled"].GetUint(); + } + + if (rasterizerStateVal.HasMember("depthBias")) { + rasterizerState.depthBias = rasterizerStateVal["depthBias"].GetFloat(); + } + + if (rasterizerStateVal.HasMember("depthBiasClamp")) { + rasterizerState.depthBiasClamp = rasterizerStateVal["depthBiasClamp"].GetFloat(); + } + + if (rasterizerStateVal.HasMember("depthBiasSlop")) { + rasterizerState.depthBiasSlop = rasterizerStateVal["depthBiasSlop"].GetFloat(); + } + + if (rasterizerStateVal.HasMember("isDepthClip")) { + rasterizerState.isDepthClip = rasterizerStateVal["isDepthClip"].GetUint(); + } + + if (rasterizerStateVal.HasMember("isMultisample")) { + rasterizerState.isMultisample = rasterizerStateVal["isMultisample"].GetUint(); + } + + if (rasterizerStateVal.HasMember("lineWidth")) { + rasterizerState.lineWidth = rasterizerStateVal["lineWidth"].GetFloat(); + } + + return rasterizerState; +} + +static DepthStencilStateInfo jsonToDepthStencilState(const rapidjson::Value &val) { + DepthStencilStateInfo dss; + + CC_ASSERT(val.IsObject()); + + if (val.HasMember("depthTest")) { + dss.depthTest = val["depthTest"].GetBool() ? 1 : 0; + } + + if (val.HasMember("depthWrite")) { + dss.depthWrite = val["depthWrite"].GetBool() ? 1 : 0; + } + + if (val.HasMember("depthFunc")) { + dss.depthFunc = static_cast(val["depthFunc"].GetInt()); + } + + if (val.HasMember("stencilTestFront")) { + dss.stencilTestFront = val["stencilTestFront"].GetBool() ? 1 : 0; + } + + if (val.HasMember("stencilFuncFront")) { + dss.stencilFuncFront = static_cast(val["stencilFuncFront"].GetInt()); + } + + if (val.HasMember("stencilReadMaskFront")) { + dss.stencilReadMaskFront = val["stencilReadMaskFront"].GetUint(); + } + + if (val.HasMember("stencilWriteMaskFront")) { + dss.stencilWriteMaskFront = val["stencilWriteMaskFront"].GetUint(); + } + + if (val.HasMember("stencilFailOpFront")) { + dss.stencilFailOpFront = static_cast(val["stencilFailOpFront"].GetUint()); + } + + if (val.HasMember("stencilZFailOpFront")) { + dss.stencilZFailOpFront = static_cast(val["stencilZFailOpFront"].GetUint()); + } + + if (val.HasMember("stencilPassOpFront")) { + dss.stencilPassOpFront = static_cast(val["stencilPassOpFront"].GetUint()); + } + + if (val.HasMember("stencilRefFront")) { + dss.stencilRefFront = val["stencilRefFront"].GetUint(); + } + + if (val.HasMember("stencilTestBack")) { + dss.stencilTestBack = val["stencilTestBack"].GetBool() ? 1 : 0; + } + + if (val.HasMember("stencilFuncBack")) { + dss.stencilFuncBack = static_cast(val["stencilFuncBack"].GetInt()); + } + + if (val.HasMember("stencilReadMaskBack")) { + dss.stencilReadMaskBack = val["stencilReadMaskBack"].GetUint(); + } + + if (val.HasMember("stencilWriteMaskBack")) { + dss.stencilWriteMaskBack = val["stencilWriteMaskBack"].GetUint(); + } + + if (val.HasMember("stencilFailOpBack")) { + dss.stencilFailOpBack = static_cast(val["stencilFailOpBack"].GetInt()); + } + + if (val.HasMember("stencilZFailOpBack")) { + dss.stencilZFailOpBack = static_cast(val["stencilZFailOpBack"].GetInt()); + } + + if (val.HasMember("stencilPassOpBack")) { + dss.stencilPassOpBack = static_cast(val["stencilPassOpBack"].GetInt()); + } + + if (val.HasMember("stencilRefBack")) { + dss.stencilWriteMaskBack = val["stencilRefBack"].GetUint(); + } + + return dss; +} + +static void jsonToBlendTarget(const rapidjson::Value &val, BlendTargetInfo *outBlendTarget) { + if (outBlendTarget == nullptr) { + return; + } + + CC_ASSERT(val.IsObject()); + + if (val.HasMember("blend")) { + outBlendTarget->blend = val["blend"].GetBool() ? 1 : 0; + } + + if (val.HasMember("blendSrc")) { + outBlendTarget->blendSrc = static_cast(val["blendSrc"].GetInt()); + } + + if (val.HasMember("blendDst")) { + outBlendTarget->blendDst = static_cast(val["blendDst"].GetInt()); + } + + if (val.HasMember("blendEq")) { + outBlendTarget->blendEq = static_cast(val["blendEq"].GetInt()); + } + + if (val.HasMember("blendSrcAlpha")) { + outBlendTarget->blendSrcAlpha = static_cast(val["blendSrcAlpha"].GetInt()); + } + + if (val.HasMember("blendDstAlpha")) { + outBlendTarget->blendDstAlpha = static_cast(val["blendDstAlpha"].GetInt()); + } + + if (val.HasMember("blendAlphaEq")) { + outBlendTarget->blendAlphaEq = static_cast(val["blendAlphaEq"].GetInt()); + } + + if (val.HasMember("blendColorMask")) { + outBlendTarget->blendColorMask = static_cast(val["blendColorMask"].GetInt()); + } +} + +static void deserializeGfxColor(const rapidjson::Value &color, cc::optional &gfxColor) { + if (gfxColor.has_value()) { + if (color.HasMember("x")) { + gfxColor->x = color["x"].GetFloat(); + } + + if (color.HasMember("y")) { + gfxColor->y = color["y"].GetFloat(); + } + + if (color.HasMember("z")) { + gfxColor->z = color["z"].GetFloat(); + } + + if (color.HasMember("w")) { + gfxColor->w = color["w"].GetFloat(); + } + } +} + +static BlendStateInfo jsonToBlendState(const rapidjson::Value &val) { + CC_ASSERT(val.IsObject()); + + BlendStateInfo bs; + + if (val.HasMember("isA2C")) { + bs.isA2C = val["isA2C"].GetBool() ? 1 : 0; + } + + if (val.HasMember("isIndepend")) { + bs.isIndepend = val["isIndepend"].GetBool() ? 1 : 0; + } + + if (val.HasMember("blendColor")) { + deserializeGfxColor(val["blendColor"], bs.blendColor); + } + + if (val.HasMember("targets")) { + if (val["targets"].IsArray()) { + const auto & targetsVal = val["targets"].GetArray(); + BlendTargetInfoList targets; + targets.resize(targetsVal.Size()); + int32_t i = 0; + for (const auto &targetVal : targetsVal) { + jsonToBlendTarget(targetVal, &targets[i]); + ++i; + } + + bs.targets = targets; + } + } + + return bs; +} + +static void deserializePass(const rapidjson::Value &passVal, IPassInfoFull &cPass) { + // Filling IPassInfo is enough, the properties in IPassInfoFull will be assigned in Material::createPasses + CC_ASSERT(passVal.IsObject()); + + // IPassInfo + cPass.program = passVal["program"].GetString(); + // CC_LOG_DEBUG("program: %s", cPass.program.c_str()); + if (passVal.HasMember("embeddedMacros")) { + cPass.embeddedMacros = jsonToMacroRecord(passVal["embeddedMacros"]); + } + + if (passVal.HasMember("propertyIndex")) { + cPass.propertyIndex = passVal["propertyIndex"].GetInt(); + // CC_LOG_DEBUG("propertyIndex: %d", cPass.propertyIndex); + } + + if (passVal.HasMember("switch")) { + cPass.switch_ = passVal["switch"].GetString(); + // CC_LOG_DEBUG("switch: %s", cPass.switch_.value().c_str()); + } + + if (passVal.HasMember("properties")) { + cPass.properties = jsonToPassPropertyInfoMap(passVal["properties"]); + } + + // IPassStates + if (passVal.HasMember("priority")) { + cPass.priority = passVal["priority"].GetInt(); + // CC_LOG_DEBUG("priority: %d", cPass.priority.value()); + } + + if (passVal.HasMember("primitive")) { + cPass.primitive = static_cast(passVal["primitive"].GetInt()); + } + + if (passVal.HasMember("stage")) { + cPass.stage = static_cast(passVal["stage"].GetInt()); + } + + if (passVal.HasMember("rasterizerState")) { + cPass.rasterizerState = jsonToRasterizerState(passVal["rasterizerState"]); + } + + if (passVal.HasMember("depthStencilState")) { + cPass.depthStencilState = jsonToDepthStencilState(passVal["depthStencilState"]); + } + + if (passVal.HasMember("blendState")) { + cPass.blendState = jsonToBlendState(passVal["blendState"]); + } + + if (passVal.HasMember("dynamicStates")) { + cPass.dynamicStates = static_cast(passVal["dynamicStates"].GetInt()); + } + + if (passVal.HasMember("phase")) { + cPass.phase = passVal["phase"].GetString(); + // CC_LOG_DEBUG("phase: %s", cPass.phase.value().c_str()); + } +} + +static void deserializeTechnique(const rapidjson::Value &technique, ITechniqueInfo &cTechnique) { + if (technique.IsObject()) { + if (technique.HasMember("name")) { + cTechnique.name = technique["name"].GetString(); + // CC_LOG_DEBUG("tech name: %s", _techniques[techIndex].name.value().c_str()); + } + + if (technique.HasMember("passes")) { + const auto &passesVal = technique["passes"]; + deserializeArray(passesVal, cTechnique.passes, deserializePass); + } + } +} + +static void deserializeShaderBuiltin(const rapidjson::Value &builtinVal, IBuiltin &cBuiltin) { + CC_ASSERT(builtinVal.IsObject()); + + if (builtinVal.HasMember("name")) { + cBuiltin.name = builtinVal["name"].GetString(); + } + + if (builtinVal.HasMember("defines")) { + deserializeArray(builtinVal["defines"], cBuiltin.defines); + } +} + +static void deserializeShaderBuiltinInfo(const rapidjson::Value &builtinInfoVal, IBuiltinInfo &cBuiltinInfo) { + CC_ASSERT(builtinInfoVal.IsObject()); + + if (builtinInfoVal.HasMember("blocks")) { + deserializeArray(builtinInfoVal["blocks"], cBuiltinInfo.blocks, deserializeShaderBuiltin); + } + + if (builtinInfoVal.HasMember("samplerTextures")) { + deserializeArray(builtinInfoVal["samplerTextures"], cBuiltinInfo.samplerTextures, deserializeShaderBuiltin); + } +} + +static void deserializeShaderBuiltinsStatistics(const rapidjson::Value &statisticsVal, BuiltinsStatisticsType &cStatistics) { + CC_ASSERT(statisticsVal.IsObject()); + + for (const auto &e : statisticsVal.GetObject()) { + cStatistics[e.name.GetString()] = e.value.GetInt(); + } +} + +static void deserializeShaderBuiltins(const rapidjson::Value &builtinsVal, IBuiltins &cBuiltins) { + CC_ASSERT(builtinsVal.IsObject()); + + if (builtinsVal.HasMember("globals")) { + deserializeShaderBuiltinInfo(builtinsVal["globals"], cBuiltins.globals); + } + + if (builtinsVal.HasMember("locals")) { + deserializeShaderBuiltinInfo(builtinsVal["locals"], cBuiltins.locals); + } + + if (builtinsVal.HasMember("statistics")) { + deserializeShaderBuiltinsStatistics(builtinsVal["statistics"], cBuiltins.statistics); + } +} +// + +static void deserializeShaderDefine(const rapidjson::Value &defineVal, IDefineInfo &cDefine) { + CC_ASSERT(defineVal.IsObject()); + + if (defineVal.HasMember("name")) { + cDefine.name = defineVal["name"].GetString(); + } + + if (defineVal.HasMember("type")) { + cDefine.type = defineVal["type"].GetString(); + } + + if (defineVal.HasMember("range")) { + auto & cRange = cDefine.range; + const auto &rangeVal = defineVal["range"]; + + cRange = std::vector{}; + deserializeArray(rangeVal, cRange.value()); + } + + if (defineVal.HasMember("options")) { + auto & cOptions = cDefine.options; + const auto &optionsVal = defineVal["options"]; + + cOptions = std::vector{}; + deserializeArray(optionsVal, cOptions.value()); + } + + if (defineVal.HasMember("default")) { + cDefine.defaultVal = defineVal["default"].GetString(); + } +} + +// + +static void deserializeMember(const rapidjson::Value &memberVal, gfx::Uniform &cMember) { + CC_ASSERT(memberVal.IsObject()); + + if (memberVal.HasMember("name")) { + cMember.name = memberVal["name"].GetString(); + } + + if (memberVal.HasMember("type")) { + cMember.type = static_cast(memberVal["type"].GetInt()); + } + + if (memberVal.HasMember("count")) { + cMember.count = memberVal["count"].GetUint(); + } +} + +static void deserializeShaderBlock(const rapidjson::Value &blockVal, IBlockInfo &cBlock) { + CC_ASSERT(blockVal.IsObject()); + + if (blockVal.HasMember("binding")) { + cBlock.binding = blockVal["binding"].GetInt(); + } + + if (blockVal.HasMember("name")) { + cBlock.name = blockVal["name"].GetString(); + } + + if (blockVal.HasMember("members")) { + deserializeArray(blockVal["members"], cBlock.members, deserializeMember); + } + + if (blockVal.HasMember("stageFlags")) { + cBlock.stageFlags = static_cast(blockVal["stageFlags"].GetInt()); + } +} + +static void deserializeShaderSamplerTexture(const rapidjson::Value &samplerTextureVal, ISamplerTextureInfo &cSamplerTexture) { + CC_ASSERT(samplerTextureVal.IsObject()); + + if (samplerTextureVal.HasMember("binding")) { + cSamplerTexture.binding = samplerTextureVal["binding"].GetInt(); + } + + if (samplerTextureVal.HasMember("name")) { + cSamplerTexture.name = samplerTextureVal["name"].GetString(); + } + + if (samplerTextureVal.HasMember("type")) { + cSamplerTexture.type = static_cast(samplerTextureVal["type"].GetInt()); + } + + if (samplerTextureVal.HasMember("count")) { + cSamplerTexture.count = samplerTextureVal["count"].GetUint(); + } + + if (samplerTextureVal.HasMember("stageFlags")) { + cSamplerTexture.stageFlags = static_cast(samplerTextureVal["stageFlags"].GetInt()); + } +} + +static void deserializeShaderSampler(const rapidjson::Value &samplerVal, ISamplerInfo &cSampler) { + CC_ASSERT(samplerVal.IsObject()); + + if (samplerVal.HasMember("set")) { + cSampler.set = samplerVal["set"].GetUint(); + } + + if (samplerVal.HasMember("binding")) { + cSampler.binding = samplerVal["binding"].GetInt(); + } + + if (samplerVal.HasMember("name")) { + cSampler.name = samplerVal["name"].GetString(); + } + + if (samplerVal.HasMember("count")) { + cSampler.count = samplerVal["count"].GetUint(); + } + + if (samplerVal.HasMember("stageFlags")) { + cSampler.stageFlags = static_cast(samplerVal["stageFlags"].GetInt()); + } +} + +static void deserializeShaderTexture(const rapidjson::Value &textureVal, ITextureInfo &cTexture) { + CC_ASSERT(textureVal.IsObject()); + + if (textureVal.HasMember("set")) { + cTexture.set = textureVal["set"].GetUint(); + } + + if (textureVal.HasMember("binding")) { + cTexture.binding = textureVal["binding"].GetInt(); + } + + if (textureVal.HasMember("name")) { + cTexture.name = textureVal["name"].GetString(); + } + + if (textureVal.HasMember("type")) { + cTexture.type = static_cast(textureVal["type"].GetInt()); + } + + if (textureVal.HasMember("count")) { + cTexture.count = textureVal["count"].GetUint(); + } + + if (textureVal.HasMember("stageFlags")) { + cTexture.stageFlags = static_cast(textureVal["stageFlags"].GetInt()); + } +} + +static void deserializeShaderBuffer(const rapidjson::Value &bufferVal, IBufferInfo &cBuffer) { + CC_ASSERT(bufferVal.IsObject()); + + if (bufferVal.HasMember("binding")) { + cBuffer.binding = bufferVal["binding"].GetInt(); + } + + if (bufferVal.HasMember("name")) { + cBuffer.name = bufferVal["name"].GetString(); + } + + if (bufferVal.HasMember("memoryAccess")) { + cBuffer.memoryAccess = static_cast(bufferVal["memoryAccess"].GetInt()); + } + + if (bufferVal.HasMember("stageFlags")) { + cBuffer.stageFlags = static_cast(bufferVal["stageFlags"].GetInt()); + } +} + +static void deserializeShaderImage(const rapidjson::Value &imageVal, IImageInfo &cImage) { + CC_ASSERT(imageVal.IsObject()); + + if (imageVal.HasMember("binding")) { + cImage.binding = imageVal["binding"].GetInt(); + } + + if (imageVal.HasMember("name")) { + cImage.name = imageVal["name"].GetString(); + } + + if (imageVal.HasMember("type")) { + cImage.type = static_cast(imageVal["type"].GetInt()); + } + + if (imageVal.HasMember("count")) { + cImage.count = imageVal["count"].GetUint(); + } + + if (imageVal.HasMember("memoryAccess")) { + cImage.memoryAccess = static_cast(imageVal["memoryAccess"].GetInt()); + } + + if (imageVal.HasMember("stageFlags")) { + cImage.stageFlags = static_cast(imageVal["stageFlags"].GetInt()); + } +} + +static void deserializeShaderInputAttachment(const rapidjson::Value &inputAttachmentVal, IInputAttachmentInfo &cInputAttachment) { + CC_ASSERT(inputAttachmentVal.IsObject()); + + if (inputAttachmentVal.HasMember("set")) { + cInputAttachment.set = inputAttachmentVal["set"].GetUint(); + } + + if (inputAttachmentVal.HasMember("binding")) { + cInputAttachment.binding = inputAttachmentVal["binding"].GetInt(); + } + + if (inputAttachmentVal.HasMember("name")) { + cInputAttachment.name = inputAttachmentVal["name"].GetString(); + } + + if (inputAttachmentVal.HasMember("count")) { + cInputAttachment.count = inputAttachmentVal["count"].GetUint(); + } + + if (inputAttachmentVal.HasMember("stageFlags")) { + cInputAttachment.stageFlags = static_cast(inputAttachmentVal["stageFlags"].GetInt()); + } +} + +static void deserializeShaderAttribute(const rapidjson::Value &gfxAttributeVal, IAttributeInfo &cAttribute) { + CC_ASSERT(gfxAttributeVal.IsObject()); + + if (gfxAttributeVal.HasMember("name")) { + cAttribute.name = gfxAttributeVal["name"].GetString(); + } + + if (gfxAttributeVal.HasMember("format")) { + cAttribute.format = static_cast(gfxAttributeVal["format"].GetInt()); + } + + if (gfxAttributeVal.HasMember("isNormalized")) { + cAttribute.isNormalized = gfxAttributeVal["isNormalized"].GetBool(); + } + + if (gfxAttributeVal.HasMember("stream")) { + cAttribute.stream = gfxAttributeVal["stream"].GetUint(); + } + + if (gfxAttributeVal.HasMember("isInstanced")) { + cAttribute.isNormalized = gfxAttributeVal["isInstanced"].GetBool(); + } + + if (gfxAttributeVal.HasMember("location")) { + cAttribute.location = gfxAttributeVal["location"].GetUint(); + } +} + +static void deserializeShaderAttributeInfo(const rapidjson::Value &attributeVal, IAttributeInfo &cAttributeInfo) { + CC_ASSERT(attributeVal.IsObject()); + + deserializeShaderAttribute(attributeVal, cAttributeInfo); + if (attributeVal.HasMember("defines")) { + deserializeArray(attributeVal["defines"], cAttributeInfo.defines); + } +} + +static void deserializeShader(const rapidjson::Value &shaderVal, IShaderInfo &cShader) { + CC_ASSERT(shaderVal.IsObject()); + + cShader.name = shaderVal["name"].GetString(); + cShader.hash = shaderVal["hash"].GetUint64(); + //NOTE: glsl1, glsl3, glsl4 are not initialized here + + deserializeShaderBuiltins(shaderVal["builtins"], cShader.builtins); + deserializeArray(shaderVal["defines"], cShader.defines, deserializeShaderDefine); + deserializeArray(shaderVal["attributes"], cShader.attributes, deserializeShaderAttributeInfo); + deserializeArray(shaderVal["blocks"], cShader.blocks, deserializeShaderBlock); + deserializeArray(shaderVal["samplerTextures"], cShader.samplerTextures, deserializeShaderSamplerTexture); + deserializeArray(shaderVal["samplers"], cShader.samplers, deserializeShaderSampler); + deserializeArray(shaderVal["textures"], cShader.textures, deserializeShaderTexture); + deserializeArray(shaderVal["buffers"], cShader.buffers, deserializeShaderBuffer); + deserializeArray(shaderVal["images"], cShader.images, deserializeShaderImage); + deserializeArray(shaderVal["subpassInputs"], cShader.subpassInputs, deserializeShaderInputAttachment); +} + +static void deserializePreCompileInfoValue(const rapidjson::Value &infoVal, IPreCompileInfoValueType &cInfo) { + if (infoVal.IsBool()) { + std::vector boolInfo; + deserializeArray(infoVal, boolInfo); + cInfo = std::move(boolInfo); + } else if (infoVal.IsFloat()) { + std::vector floatInfo; + deserializeArray(infoVal, floatInfo); + cInfo = std::move(floatInfo); + } else if (infoVal.IsString()) { + std::vector strInfo; + deserializeArray(infoVal, strInfo); + cInfo = std::move(strInfo); + } else { + CC_ASSERT(false); + } +} + +static void deserializeCombination(const rapidjson::Value &combinationVal, IPreCompileInfo &cCombination) { + CC_ASSERT(combinationVal.IsObject()); + for (const auto &e : combinationVal.GetObject()) { + IPreCompileInfoValueType info; + deserializePreCompileInfoValue(e.value, info); + cCombination.emplace(e.name.GetString(), info); + } +} + +void EffectAssetDeserializer::deserialize(const rapidjson::Value &serializedData, Asset *asset) { + CC_ASSERT(serializedData.IsObject()); + auto *effectAsset = dynamic_cast(asset); + CC_ASSERT(effectAsset != nullptr); + + effectAsset->_name = serializedData["name"].GetString(); //cjh TODO: name needs to be deserialize in CCObject class. + // CC_LOG_DEBUG("EffectAsset::deserialize: %s", _name.c_str()); + if (serializedData.HasMember("techniques")) { + deserializeArray(serializedData["techniques"], effectAsset->_techniques, deserializeTechnique); + } + + if (serializedData.HasMember("shaders")) { + deserializeArray(serializedData["shaders"], effectAsset->_shaders, deserializeShader); + } + + if (serializedData.HasMember("combinations")) { + deserializeArray(serializedData["combinations"], effectAsset->_combinations, deserializeCombination); + } +} + +} // namespace cc diff --git a/native/cocos/core/data/deserializer/EffectAssetDeserializer.h b/native/cocos/core/data/deserializer/EffectAssetDeserializer.h new file mode 100644 index 0000000000..f53545f81d --- /dev/null +++ b/native/cocos/core/data/deserializer/EffectAssetDeserializer.h @@ -0,0 +1,42 @@ +/**************************************************************************** + 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 "core/data/deserializer/IAssetDeserializer.h" + +namespace cc { + +class Asset; + +class EffectAssetDeserializer final : public IAssetDeserializer { +public: + EffectAssetDeserializer() = default; + ~EffectAssetDeserializer() override = default; + + void deserialize(const rapidjson::Value &serializedData, Asset *effectAsset) override; +}; + +} // namespace cc diff --git a/native/cocos/core/data/deserializer/IAssetDeserializer.h b/native/cocos/core/data/deserializer/IAssetDeserializer.h new file mode 100644 index 0000000000..ab9c229ab6 --- /dev/null +++ b/native/cocos/core/data/deserializer/IAssetDeserializer.h @@ -0,0 +1,40 @@ +/**************************************************************************** + 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 "rapidjson/document.h" + +namespace cc { + +class Asset; + +class IAssetDeserializer { +public: + virtual ~IAssetDeserializer() = default; + virtual void deserialize(const rapidjson::Value &serializedData, Asset *asset) = 0; +}; + +} // namespace cc diff --git a/native/cocos/core/event/CallbacksInvoker.cpp b/native/cocos/core/event/CallbacksInvoker.cpp new file mode 100644 index 0000000000..66a71f2421 --- /dev/null +++ b/native/cocos/core/event/CallbacksInvoker.cpp @@ -0,0 +1,265 @@ +/**************************************************************************** + 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/event/CallbacksInvoker.h" +#include "base/Log.h" + +namespace cc { + +CallbackInfoBase::ID CallbacksInvoker::cbIDCounter{0}; + +void CallbackList::removeByCallbackID(CallbackInfoBase::ID cbID) { + for (int32_t i = 0; i < _callbackInfos.size(); ++i) { + auto &info = _callbackInfos[i]; + if (info->_id == cbID) { + utils::array::fastRemoveAt(_callbackInfos, i); + --i; + } + } +} + +void CallbackList::removeByTarget(void *target) { + for (int32_t i = 0; i < _callbackInfos.size(); ++i) { + auto &info = _callbackInfos[i]; + if (info->_target == target) { + utils::array::fastRemoveAt(_callbackInfos, i); + --i; + } + } +} + +void CallbackList::cancel(index_t index) { + std::shared_ptr *info = nullptr; + if (index >= 0 && index < _callbackInfos.size()) { + info = &_callbackInfos[index]; + } + + if (info) { + if (_isInvoking) { + _callbackInfos[index] = nullptr; + } else { + utils::array::fastRemoveAt(_callbackInfos, index); + } + } + _containCanceled = true; +} + +void CallbackList::cancelAll() { + for (auto &callbackInfo : _callbackInfos) { + callbackInfo = nullptr; + } + _containCanceled = true; +} + +void CallbackList::purgeCanceled() { + for (index_t i = static_cast(_callbackInfos.size()) - 1; i >= 0; --i) { + const auto &info = _callbackInfos[i]; + if (!info) { + utils::array::fastRemoveAt(_callbackInfos, i); + } + } + _containCanceled = false; +} + +void CallbackList::clear() { + cancelAll(); + _callbackInfos.clear(); + _isInvoking = false; + _containCanceled = false; +} + +bool CallbacksInvoker::hasEventListener(const KeyType &key) const { + auto iter = _callbackTable.find(key); + if (iter == _callbackTable.end()) { + return false; + } + + const auto &list = iter->second; + // check any valid callback + const auto &infos = list._callbackInfos; + // Make sure no cancelled callbacks + if (list._isInvoking) { + for (const auto &info : infos) { // NOLINT(readability-use-anyofallof) + if (info != nullptr) { + return true; + } + } + return false; + } + + return !infos.empty(); +} + +bool CallbacksInvoker::hasEventListener(const KeyType &key, CallbackInfoBase::ID cbID) const { + auto iter = _callbackTable.find(key); + if (iter == _callbackTable.end()) { + return false; + } + + const auto &list = iter->second; + // check any valid callback + const auto &infos = list._callbackInfos; + + for (const auto &info : infos) { // NOLINT(readability-use-anyofallof) + if (info != nullptr && info->check() && info->_id == cbID) { + return true; + } + } + + return false; +} + +bool CallbacksInvoker::hasEventListener(const KeyType &key, void *target) { + auto iter = _callbackTable.find(key); + if (iter == _callbackTable.end()) { + return false; + } + + const auto &list = iter->second; + // check any valid callback + const auto &infos = list._callbackInfos; + + for (const auto &info : infos) { // NOLINT(readability-use-anyofallof) + if (info != nullptr && info->check() && info->_target == target) { + return true; + } + } + + return false; +} + +bool CallbacksInvoker::hasEventListener(const KeyType &key, void *target, CallbackInfoBase::ID cbID) const { + auto iter = _callbackTable.find(key); + if (iter == _callbackTable.end()) { + return false; + } + + const auto &list = iter->second; + // check any valid callback + const auto &infos = list._callbackInfos; + + for (const auto &info : infos) { // NOLINT(readability-use-anyofallof) + if (info != nullptr && info->check() && info->_target == target && info->_id == cbID) { + return true; + } + } + + return false; +} + +void CallbacksInvoker::offAll(const KeyType &key) { + auto iter = _callbackTable.find(key); + if (iter != _callbackTable.end()) { + auto &list = iter->second; + if (list._isInvoking) { + list.cancelAll(); + } else { + list.clear(); + _callbackTable.erase(iter); + } + } +} + +void CallbacksInvoker::offAll(void *target) { + for (auto &e : _callbackTable) { + auto & list = e.second; + const auto &infos = list._callbackInfos; + if (list._isInvoking) { + index_t i = 0; + for (const auto &info : infos) { + if (info != nullptr && info->_target == target) { + list.cancel(i); + } + ++i; + } + } else { + list.removeByTarget(target); + } + } +} + +void CallbacksInvoker::offAll() { + for (auto iter = _callbackTable.begin(); iter != _callbackTable.end();) { + auto &list = iter->second; + if (list._isInvoking) { + list.cancelAll(); + ++iter; + } else { + list.clear(); + iter = _callbackTable.erase(iter); + } + } +} + +void CallbacksInvoker::off(const KeyType &key, CallbackInfoBase::ID cbID) { + auto iter = _callbackTable.find(key); + if (iter != _callbackTable.end()) { + auto & list = iter->second; + const auto &infos = list._callbackInfos; + index_t i = 0; + for (const auto &info : infos) { + if (info != nullptr && info->_id == cbID) { + list.cancel(i); + break; + } + ++i; + } + } +} + +void CallbacksInvoker::offAll(const KeyType &key, void *target) { + auto iter = _callbackTable.find(key); + if (iter != _callbackTable.end()) { + auto & list = iter->second; + const auto &infos = list._callbackInfos; + index_t i = 0; + if (list._isInvoking) { + for (const auto &info : infos) { + if (info != nullptr && info->_target == target) { + list.cancel(i); + } + ++i; + } + } else { + list.removeByTarget(target); + } + } +} + +void CallbacksInvoker::off(CallbackInfoBase::ID cbID) { + for (auto &cbInfo : _callbackTable) { + auto & list = cbInfo.second; + const auto &infos = list._callbackInfos; + index_t i = 0; + for (const auto &info : infos) { + if (info != nullptr && info->_id == cbID) { + list.cancel(i); + break; + } + ++i; + } + } +} + +} // namespace cc diff --git a/native/cocos/core/event/CallbacksInvoker.h b/native/cocos/core/event/CallbacksInvoker.h new file mode 100644 index 0000000000..651c2ad267 --- /dev/null +++ b/native/cocos/core/event/CallbacksInvoker.h @@ -0,0 +1,475 @@ +/**************************************************************************** + 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 +#include +#include +#include +#include +#include + +#include "base/Log.h" +#include "base/Macros.h" +#include "base/Utils.h" +#include "core/data/Object.h" +#include "core/memop/Pool.h" + +namespace cc { + +#define CC_CALLBACK_INVOKE_0(__selector__, __target__, ...) std::function(std::bind(&__selector__, __target__, ##__VA_ARGS__)), __target__ +#define CC_CALLBACK_INVOKE_1(__selector__, __target__, Arg0, ...) std::function(std::bind(&__selector__, __target__, std::placeholders::_1, ##__VA_ARGS__)), __target__ +#define CC_CALLBACK_INVOKE_2(__selector__, __target__, Arg0, Arg1, ...) std::function(std::bind(&__selector__, __target__, std::placeholders::_1, std::placeholders::_2, ##__VA_ARGS__)), __target__ +#define CC_CALLBACK_INVOKE_3(__selector__, __target__, Arg0, Arg1, Arg2, ...) std::function(std::bind(&__selector__, __target__, std::placeholders::_1, std::placeholders::_2, std::placeholders::_3, ##__VA_ARGS__)), __target__ + +struct CallbackInfoBase { + using ID = uint32_t; + using FakeCallbackMemberFn = void (CCObject::*)(); + + CallbackInfoBase() = default; + virtual ~CallbackInfoBase() = default; + + virtual bool check() const = 0; + virtual void reset() = 0; + virtual FakeCallbackMemberFn getMemberFn() const = 0; + + void *_target{nullptr}; + ID _id{0}; + bool _once{false}; + bool _isCCObject{false}; +#if CC_DEBUG + std::vector _argTypes; +#endif +}; + +template +struct CallbackInfo final : public CallbackInfoBase { + using CallbackFn = std::function; + using CallbackMemberFn = void (CCObject::*)(Args...); + + CallbackFn _callback{nullptr}; + CallbackMemberFn _memberFn{nullptr}; + + template + void set(CallbackFn &&callback, Target *target, bool once) { + _callback = std::forward(callback); + _target = target; + _once = once; + _isCCObject = std::is_base_of::value; +#if CC_DEBUG + _argTypes = {(typeid(Args).name())...}; +#endif + } + + template ::value>> + void set(CallbackMemberFn memberFn, Target *target, bool once) { + _memberFn = memberFn; + _target = target; + _once = once; + _isCCObject = true; +#if CC_DEBUG + _argTypes = {(typeid(Args).name())...}; +#endif + } + + void reset() override { + _callback = nullptr; + _memberFn = nullptr; + _target = nullptr; + _once = false; + _isCCObject = false; +#if CC_DEBUG + _argTypes.clear(); +#endif + } + + bool check() const override { + // Validation + if (_isCCObject) { + if (!isObjectValid(reinterpret_cast(_target), true)) { + return false; + } + } + return true; + } + + FakeCallbackMemberFn getMemberFn() const override { + return reinterpret_cast(_memberFn); + } +}; + +/** + * @zh 事件监听器列表的简单封装。 + * @en A simple list of event callbacks + */ +class CallbackList final { +public: + std::vector> _callbackInfos; + bool _isInvoking{false}; + bool _containCanceled{false}; + + /** + * @zh 从列表中移除与指定目标相同回调函数的事件。 + * @en Remove the event listeners with the given callback from the list + * + * @param cbID - The callback id to be removed + */ + void removeByCallbackID(CallbackInfoBase::ID cbID); + + /** + * @zh 从列表中移除与指定目标相同调用者的事件。 + * @en Remove the event listeners with the given target from the list + * @param target + */ + void removeByTarget(void *target); + + /** + * @zh 移除指定编号事件。 + * @en Remove the event listener at the given index + * @param index + */ + void cancel(index_t index); + + /** + * @zh 注销所有事件。 + * @en Cancel all event listeners + */ + void cancelAll(); + + /** + * @zh 立即删除所有取消的回调。(在移除过程中会更加紧凑的排列数组) + * @en Delete all canceled callbacks and compact array + */ + void purgeCanceled(); + + /** + * @zh 清除并重置所有数据。 + * @en Clear all data + */ + void clear(); +}; + +/** + * @zh CallbacksInvoker 用来根据事件名(Key)管理事件监听器列表并调用回调方法。 + * @en CallbacksInvoker is used to manager and invoke event listeners with different event keys, + * each key is mapped to a CallbackList. + */ +class CallbacksInvoker { +public: + using KeyType = uint32_t; + CallbacksInvoker() = default; + virtual ~CallbacksInvoker() = default; + /** + * @zh 向一个事件名注册一个新的事件监听器,包含回调函数和调用者 + * @en Register an event listener to a given event key with callback and target. + * + * @param key - Event type + * @param callback - Callback function when event triggered + * @param target - Callback callee + * @param once - Whether invoke the callback only once (and remove it) + */ + template + void on(const KeyType &key, void (Target::*memberFn)(Args...), Target *target, bool once = false); + + template + void on(const KeyType &key, std::function &&callback, Target *target, bool once = false); + + template + void on(const KeyType &key, std::function &&callback, bool once = false); + + template + std::enable_if_t::value, void> + on(const KeyType &key, LambdaType &&callback, Target *target, bool once = false); + + template + std::enable_if_t::value, void> + on(const KeyType &key, LambdaType &&callback, bool once = false); + + // + template + void on(const KeyType &key, std::function &&callback, Target *target, CallbackInfoBase::ID &outCallbackID, bool once = false); + + template + void on(const KeyType &key, std::function &&callback, CallbackInfoBase::ID &outCallbackID, bool once = false); + + template + std::enable_if_t::value, void> + on(const KeyType &key, LambdaType &&callback, Target *target, CallbackInfoBase::ID &outCallbackID, bool once = false); + + template + std::enable_if_t::value, void> + on(const KeyType &key, LambdaType &&callback, CallbackInfoBase::ID &outCallbackID, bool once = false); + + /** + * @zh 检查指定事件是否已注册回调。 + * @en Checks whether there is correspond event listener registered on the given event + * @param key - Event type + * @param cbID - Callback ID + */ + bool hasEventListener(const KeyType &key) const; + bool hasEventListener(const KeyType &key, CallbackInfoBase::ID cbID) const; + bool hasEventListener(const KeyType &key, void *target); + bool hasEventListener(const KeyType &key, void *target, CallbackInfoBase::ID cbID) const; + template + bool hasEventListener(const KeyType &key, void (Target::*memberFn)(Args...), Target *target) const; + /** + * @zh 移除在特定事件类型中注册的所有回调或在某个目标中注册的所有回调。 + * @en Removes all callbacks registered in a certain event type or all callbacks registered with a certain target + * @param key - The event type or target with which the listeners will be removed + */ + void offAll(const KeyType &key, void *target); + void offAll(const KeyType &key); + void offAll(void *target); + void offAll(); + + /** + * @zh 删除以指定事件,回调函数,目标注册的回调。 + * @en Remove event listeners registered with the given event key, callback and target + * @param key - Event type + * @param target callback Target + * @param cbID - The callback ID of the event listener, if absent all event listeners for the given type will be removed + */ + void off(const KeyType &key, CallbackInfoBase::ID cbID); + void off(CallbackInfoBase::ID cbID); + template + void off(const KeyType &key, void (Target::*memberFn)(Args...), Target *target); + + /** + * @zh 派发一个指定事件,并传递需要的参数 + * @en Trigger an event directly with the event name and necessary arguments. + * @param key - event type + * @param args - The arguments to be passed to the callback + */ + template + void emit(const KeyType &key, Args &&...args); + + template + struct FunctionTraits + : public FunctionTraits { + }; + + template + struct FunctionTraits { + using type = std::function; + }; + + template + struct FunctionTraits { + using type = std::function; + }; + + template + static typename FunctionTraits>::type toFunction(T &&l) { + return typename FunctionTraits>::type{std::forward(l)}; + } + +private: + std::unordered_map _callbackTable; + static CallbackInfoBase::ID cbIDCounter; +}; + +template +void CallbacksInvoker::on(const KeyType &key, void (Target::*memberFn)(Args...), Target *target, bool once) { + static_assert(std::is_base_of::value, "Target must be the subclass of CCObject"); + using CallbackInfoType = CallbackInfo; + auto &list = _callbackTable[key]; + auto info = std::make_shared(); + info->_id = ++cbIDCounter; + CallbackInfoBase::ID cbID = info->_id; + info->set(static_cast(memberFn), target, once); + list._callbackInfos.emplace_back(std::move(info)); +} + +template +void CallbacksInvoker::on(const KeyType &key, std::function &&callback, Target *target, CallbackInfoBase::ID &outCallbackID, bool once) { + auto &list = _callbackTable[key]; + auto info = std::make_shared>(); + info->_id = ++cbIDCounter; + CallbackInfoBase::ID cbID = info->_id; + info->set(std::forward>(callback), target, once); + list._callbackInfos.emplace_back(std::move(info)); + outCallbackID = cbID; +} + +template +void CallbacksInvoker::on(const KeyType &key, std::function &&callback, CallbackInfoBase::ID &outCallbackID, bool once) { + on(key, std::forward>(callback), nullptr, outCallbackID, once); +} + +template +std::enable_if_t::value, void> +CallbacksInvoker::on(const KeyType &key, LambdaType &&callback, Target *target, CallbackInfoBase::ID &outCallbackID, bool once) { + on(key, toFunction(std::forward(callback)), target, outCallbackID, once); +} + +template +std::enable_if_t::value, void> +CallbacksInvoker::on(const KeyType &key, LambdaType &&callback, CallbackInfoBase::ID &outCallbackID, bool once) { + on(key, toFunction(std::forward(callback)), outCallbackID, once); +} + +template +void CallbacksInvoker::on(const KeyType &key, std::function &&callback, Target *target, bool once) { + CallbackInfoBase::ID unusedID{0}; + on(key, callback, target, unusedID, once); +} + +template +void CallbacksInvoker::on(const KeyType &key, std::function &&callback, bool once) { + CallbackInfoBase::ID unusedID{0}; + on(key, std::forward>(callback), nullptr, unusedID, once); +} + +template +std::enable_if_t::value, void> +CallbacksInvoker::on(const KeyType &key, LambdaType &&callback, Target *target, bool once) { + CallbackInfoBase::ID unusedID{0}; + on(key, toFunction(std::forward(callback)), target, unusedID, once); +} + +template +std::enable_if_t::value, void> +CallbacksInvoker::on(const KeyType &key, LambdaType &&callback, bool once) { + CallbackInfoBase::ID unusedID{0}; + on(key, toFunction(std::forward(callback)), unusedID, once); +} + +template +void CallbacksInvoker::off(const KeyType &key, void (Target::*memberFn)(Args...), Target *target) { + static_assert(std::is_base_of::value, "Target must be the subclass of CCObject"); + using CallbackFn = void (CCObject::*)(Args...); + auto iter = _callbackTable.find(key); + if (iter != _callbackTable.end()) { + auto & list = iter->second; + const auto &infos = list._callbackInfos; + size_t i = 0; + for (const auto &info : infos) { + if (info != nullptr && reinterpret_cast(info->getMemberFn()) == memberFn && info->_target == target) { + list.cancel(static_cast(i)); + break; + } + ++i; + } + } +} + +template +void CallbacksInvoker::emit(const KeyType &key, Args &&...args) { +#if CC_DEBUG + std::vector argTypes{(typeid(Args).name())...}; +#endif + auto iter = _callbackTable.find(key); + if (iter != _callbackTable.end()) { + auto &list = iter->second; + bool rootInvoker = !list._isInvoking; + list._isInvoking = true; + + auto &infos = list._callbackInfos; + for (auto &i : infos) { + auto &baseInfo = i; + if (baseInfo == nullptr) { + continue; + } + +#if CC_DEBUG + CC_ASSERT(baseInfo->_argTypes.size() == argTypes.size()); + for (size_t i = 0, len = argTypes.size(); i < len; ++i) { + if (baseInfo->_argTypes[i] != argTypes[i]) { + CC_LOG_ERROR("Wrong argument type! baseInfo->_argTypes[%d]=%s, argTypes[%d]=%s", i, baseInfo->_argTypes[i].c_str(), i, argTypes[i].c_str()); + CC_ASSERT(false); + } + } +#endif + using CallbackInfoType = CallbackInfo; + auto info = std::static_pointer_cast(i); + if (info != nullptr) { + if (info->_memberFn != nullptr && info->_target != nullptr) { + auto memberFn = info->_memberFn; + auto *target = reinterpret_cast(info->_target); + + // Pre off once callbacks to avoid influence on logic in callback + if (info->_once) { + off(key, memberFn, target); + } + // Lazy check validity of callback target, + // if target is CCObject and is no longer valid, then remove the callback info directly + if (!info->check()) { + off(key, memberFn, target); + } else { + (target->*memberFn)(std::forward(args)...); + } + } else { + const auto & callback = info->_callback; + CallbackInfoBase::ID cbID = info->_id; + // Pre off once callbacks to avoid influence on logic in callback + if (info->_once) { + off(key, cbID); + } + // Lazy check validity of callback target, + // if target is CCObject and is no longer valid, then remove the callback info directly + if (!info->check()) { + off(key, cbID); + } else { + callback(std::forward(args)...); + } + } + } else { + CC_ASSERT(false); + } + } + + if (rootInvoker) { + list._isInvoking = false; + if (list._containCanceled) { + list.purgeCanceled(); + } + } + } +} + +template +bool CallbacksInvoker::hasEventListener(const KeyType &key, void (Target::*memberFn)(Args...), Target *target) const { + using CallbackFn = void (CCObject::*)(Args...); + auto iter = _callbackTable.find(key); + if (iter == _callbackTable.end()) { + return false; + } + + const auto &list = iter->second; + // check any valid callback + const auto &infos = list._callbackInfos; + + for (const auto &info : infos) { + if (info != nullptr && info->check() && reinterpret_cast(info->getMemberFn()) == memberFn && info->_target == target) { + return true; + } + } + + return false; +} + +using EventTarget = CallbacksInvoker; + +} // namespace cc diff --git a/native/cocos/core/event/EventModuleHeader.h b/native/cocos/core/event/EventModuleHeader.h new file mode 100644 index 0000000000..e69de29bb2 diff --git a/native/cocos/core/event/EventTarget.cpp b/native/cocos/core/event/EventTarget.cpp new file mode 100644 index 0000000000..e69de29bb2 diff --git a/native/cocos/core/event/EventTarget.h b/native/cocos/core/event/EventTarget.h new file mode 100644 index 0000000000..e69de29bb2 diff --git a/native/cocos/core/event/EventTargetFactory.cpp b/native/cocos/core/event/EventTargetFactory.cpp new file mode 100644 index 0000000000..e69de29bb2 diff --git a/native/cocos/core/event/EventTargetFactory.h b/native/cocos/core/event/EventTargetFactory.h new file mode 100644 index 0000000000..e69de29bb2 diff --git a/native/cocos/core/event/EventTypesToJS.cpp b/native/cocos/core/event/EventTypesToJS.cpp new file mode 100644 index 0000000000..cb517b6be7 --- /dev/null +++ b/native/cocos/core/event/EventTypesToJS.cpp @@ -0,0 +1,66 @@ +/**************************************************************************** + 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/event/EventTypesToJS.h" + +namespace cc { + +// Internal NodeEventType : 0~99 +// Internal EventTypesToJS : 100~199 +// Internal Game event : 200~299 +// Internal Director Event Type: 300~399 +const CallbacksInvoker::KeyType EventTypesToJS::ROOT_BATCH2D_INIT{100}; //{"ROOT_BATCH2D_INIT"}; +const CallbacksInvoker::KeyType EventTypesToJS::ROOT_BATCH2D_UPDATE{101}; //{"ROOT_BATCH2D_UPDATE"}; +const CallbacksInvoker::KeyType EventTypesToJS::ROOT_BATCH2D_UPLOAD_BUFFERS{102}; //{"ROOT_BATCH2D_UPLOAD_BUFFERS"}; +const CallbacksInvoker::KeyType EventTypesToJS::ROOT_BATCH2D_RESET{103}; //{"ROOT_BATCH2D_RESET"}; + +const CallbacksInvoker::KeyType EventTypesToJS::NODE_REATTACH{104}; //{"NODE_REATTACH"}; +const CallbacksInvoker::KeyType EventTypesToJS::NODE_REMOVE_PERSIST_ROOT_NODE{105}; //{"NODE_REMOVE_PERSIST_ROOT_NODE"}; +const CallbacksInvoker::KeyType EventTypesToJS::NODE_DESTROY_COMPONENTS{106}; //{"NODE_DESTROY_COMPONENTS"}; +const CallbacksInvoker::KeyType EventTypesToJS::NODE_UI_TRANSFORM_DIRTY{107}; //{"NODE_UI_TRANSFORM_DIRTY"}; +const CallbacksInvoker::KeyType EventTypesToJS::NODE_ACTIVE_NODE{108}; //{"NODE_ACTIVE_NODE"}; +const CallbacksInvoker::KeyType EventTypesToJS::NODE_ON_BATCH_CREATED{109}; //{"NODE_ON_BATCH_CREATED"}; + +const CallbacksInvoker::KeyType EventTypesToJS::MODEL_UPDATE_TRANSFORM{110}; //{"MODEL_UPDATE_TRANSFORM"}; +const CallbacksInvoker::KeyType EventTypesToJS::MODEL_UPDATE_UBO{111}; //{"MODEL_UPDATE_UBO"}; +const CallbacksInvoker::KeyType EventTypesToJS::MODEL_UPDATE_LOCAL_DESCRIPTORS{112}; //{"MODEL_UPDATE_LOCAL_DESCRIPTORS"}; +const CallbacksInvoker::KeyType EventTypesToJS::MODEL_UPDATE_INSTANCED_ATTRIBUTES{113}; //{"MODEL_UPDATE_INSTANCED_ATTRIBUTES"}; +const CallbacksInvoker::KeyType EventTypesToJS::MODEL_GET_MACRO_PATCHES{114}; //{"MODEL_GET_MACRO_PATCHES"}; + +const CallbacksInvoker::KeyType EventTypesToJS::DIRECTOR_BEFORE_COMMIT{115}; //{"MODEL_GET_MACRO_PATCHES"}; + +const CallbacksInvoker::KeyType EventTypesToJS::SIMPLE_TEXTURE_GFX_TEXTURE_UPDATED{116}; +const CallbacksInvoker::KeyType EventTypesToJS::TEXTURE_BASE_GFX_SAMPLER_UPDATED{117}; + +const CallbacksInvoker::KeyType EventTypesToJS::NODE_SCENE_UPDATED{118}; + +const CallbacksInvoker::KeyType EventTypesToJS::MATERIAL_PASSES_UPDATED{119}; + +const CallbacksInvoker::KeyType EventTypesToJS::NODE_LOCAL_POSITION_UPDATED{120}; +const CallbacksInvoker::KeyType EventTypesToJS::NODE_LOCAL_ROTATION_UPDATED{121}; +const CallbacksInvoker::KeyType EventTypesToJS::NODE_LOCAL_SCALE_UPDATED{122}; +const CallbacksInvoker::KeyType EventTypesToJS::NODE_LOCAL_POSITION_ROTATION_SCALE_UPDATED{123}; + +} // namespace cc diff --git a/native/cocos/core/event/EventTypesToJS.h b/native/cocos/core/event/EventTypesToJS.h new file mode 100644 index 0000000000..5e47ef0fab --- /dev/null +++ b/native/cocos/core/event/EventTypesToJS.h @@ -0,0 +1,66 @@ +/**************************************************************************** + 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 +#include "core/event/CallbacksInvoker.h" + +namespace cc { + +class EventTypesToJS final { +public: + static const CallbacksInvoker::KeyType ROOT_BATCH2D_INIT; + static const CallbacksInvoker::KeyType ROOT_BATCH2D_UPDATE; + static const CallbacksInvoker::KeyType ROOT_BATCH2D_UPLOAD_BUFFERS; + static const CallbacksInvoker::KeyType ROOT_BATCH2D_RESET; + + static const CallbacksInvoker::KeyType NODE_REATTACH; + static const CallbacksInvoker::KeyType NODE_REMOVE_PERSIST_ROOT_NODE; + static const CallbacksInvoker::KeyType NODE_DESTROY_COMPONENTS; + static const CallbacksInvoker::KeyType NODE_UI_TRANSFORM_DIRTY; + static const CallbacksInvoker::KeyType NODE_ACTIVE_NODE; + static const CallbacksInvoker::KeyType NODE_ON_BATCH_CREATED; + static const CallbacksInvoker::KeyType NODE_SCENE_UPDATED; + static const CallbacksInvoker::KeyType NODE_LOCAL_POSITION_UPDATED; + static const CallbacksInvoker::KeyType NODE_LOCAL_ROTATION_UPDATED; + static const CallbacksInvoker::KeyType NODE_LOCAL_SCALE_UPDATED; + static const CallbacksInvoker::KeyType NODE_LOCAL_POSITION_ROTATION_SCALE_UPDATED; + + static const CallbacksInvoker::KeyType MODEL_UPDATE_TRANSFORM; + static const CallbacksInvoker::KeyType MODEL_UPDATE_UBO; + static const CallbacksInvoker::KeyType MODEL_UPDATE_LOCAL_DESCRIPTORS; + static const CallbacksInvoker::KeyType MODEL_UPDATE_INSTANCED_ATTRIBUTES; + static const CallbacksInvoker::KeyType MODEL_GET_MACRO_PATCHES; + + static const CallbacksInvoker::KeyType DIRECTOR_BEFORE_COMMIT; + + static const CallbacksInvoker::KeyType SIMPLE_TEXTURE_GFX_TEXTURE_UPDATED; + static const CallbacksInvoker::KeyType TEXTURE_BASE_GFX_SAMPLER_UPDATED; + + static const CallbacksInvoker::KeyType MATERIAL_PASSES_UPDATED; +}; + +} // namespace cc diff --git a/native/cocos/scene/AABB.cpp b/native/cocos/core/geometry/AABB.cpp similarity index 64% rename from native/cocos/scene/AABB.cpp rename to native/cocos/core/geometry/AABB.cpp index cbdbe7af66..4592bdbd76 100644 --- a/native/cocos/scene/AABB.cpp +++ b/native/cocos/core/geometry/AABB.cpp @@ -25,70 +25,33 @@ #include "AABB.h" -#include "base/TypeDef.h" +#include +#include "cocos/core/geometry/Enums.h" +#include "cocos/core/geometry/Sphere.h" namespace cc { -namespace scene { -bool AABB::aabbAabb(AABB *aabb) const { - Vec3 aMin; - Vec3 aMax; - Vec3 bMin; - Vec3 bMax; - Vec3::subtract(getCenter(), getHalfExtents(), &aMin); - Vec3::add(getCenter(), getHalfExtents(), &aMax); - Vec3::subtract(aabb->getCenter(), aabb->getHalfExtents(), &bMin); - Vec3::add(aabb->getCenter(), aabb->getHalfExtents(), &bMax); - return (aMin.x <= bMax.x && aMax.x >= bMin.x) && - (aMin.y <= bMax.y && aMax.y >= bMin.y) && - (aMin.z <= bMax.z && aMax.z >= bMin.z); +namespace geometry { + +Sphere *AABB::toBoundingSphere(Sphere *out, const AABB &a) { + out->setCenter(a.getCenter()); + out->setRadius(a.getHalfExtents().length()); + return out; } -int AABB::aabbPlane(const Plane &plane) const { - auto r = getHalfExtents().x * std::abs(plane.n.x) + - getHalfExtents().y * std::abs(plane.n.y) + - getHalfExtents().z * std::abs(plane.n.z); - auto dot = Vec3::dot(plane.n, getCenter()); - if (dot + r < plane.d) { - return -1; - } - if (dot - r > plane.d) { - return 0; - } - return 1; +AABB *AABB::fromPoints(const Vec3 &minPos, const Vec3 &maxPos, AABB *dst) { + Vec3 center{(minPos + maxPos) * 0.5F}; + Vec3 halfExtents{(maxPos - minPos) * 0.5F}; + dst->setCenter(center); + dst->setHalfExtents(halfExtents); + return dst; } -void AABB::initWithData(uint8_t *data) { - _aabbLayout = reinterpret_cast(data); -} - -bool AABB::aabbFrustum(const Frustum &frustum) const { - const auto &planes = frustum.planes; - const auto *self = this; - return std::all_of(planes.begin(), - planes.end(), - // frustum plane normal points to the inside - [self](const Plane &plane) { return self->aabbPlane(plane) != -1; }); -} - -void AABB::getBoundary(cc::Vec3 *minPos, cc::Vec3 *maxPos) const { - Vec3::subtract(getCenter(), getHalfExtents(), minPos); - Vec3::add(getCenter(), getHalfExtents(), maxPos); -} - -void AABB::merge(const AABB &aabb) { - const cc::Vec3 minA = getCenter() - getHalfExtents(); - const cc::Vec3 minB = aabb.getCenter() - aabb.getHalfExtents(); - const cc::Vec3 maxA = getCenter() + getHalfExtents(); - const cc::Vec3 maxB = aabb.getCenter() + aabb.getHalfExtents(); - cc::Vec3 maxP; - cc::Vec3 minP; - cc::Vec3::max(maxA, maxB, &maxP); - cc::Vec3::min(minA, minB, &minP); - - const cc::Vec3 addP = maxP + minP; - const cc::Vec3 subP = maxP - minP; - setCenter(addP * 0.5F); - setHalfExtents(subP * 0.5F); +AABB *AABB::merge(AABB *out, const AABB &a, const AABB &b) { + Vec3 minCornor; + Vec3 maxCorner; + Vec3::max(a.getCenter() + a.getHalfExtents(), b.getCenter() + b.getHalfExtents(), &maxCorner); + Vec3::min(a.getCenter() - a.getHalfExtents(), b.getCenter() - b.getHalfExtents(), &minCornor); + return AABB::fromPoints(minCornor, maxCorner, out); } void AABB::merge(const cc::Vec3 &point) { @@ -118,22 +81,73 @@ void AABB::merge(const cc::Vec3 &point) { setHalfExtents(maxPos.x - center.x, maxPos.y - center.y, maxPos.z - center.z); } +void AABB::merge(const std::vector &points) { + for (const auto &p : points) { + merge(p); + } +} + void AABB::merge(const Frustum &frustum) { const std::array &vertices = frustum.vertices; - for (uint i = 0; i < vertices.max_size(); ++i) { + for (size_t i = 0; i < vertices.max_size(); ++i) { merge(vertices[i]); } } +bool AABB::aabbAabb(const AABB &aabb) const { + Vec3 aMin; + Vec3 aMax; + Vec3 bMin; + Vec3 bMax; + Vec3::subtract(getCenter(), getHalfExtents(), &aMin); + Vec3::add(getCenter(), getHalfExtents(), &aMax); + Vec3::subtract(aabb.getCenter(), aabb.getHalfExtents(), &bMin); + Vec3::add(aabb.getCenter(), aabb.getHalfExtents(), &bMax); + return (aMin.x <= bMax.x && aMax.x >= bMin.x) && + (aMin.y <= bMax.y && aMax.y >= bMin.y) && + (aMin.z <= bMax.z && aMax.z >= bMin.z); +} + +int AABB::aabbPlane(const Plane &plane) const { + auto r = getHalfExtents().x * std::abs(plane.n.x) + + getHalfExtents().y * std::abs(plane.n.y) + + getHalfExtents().z * std::abs(plane.n.z); + auto dot = Vec3::dot(plane.n, getCenter()); + if (dot + r < plane.d) { + return -1; + } + if (dot - r > plane.d) { + return 0; + } + return 1; +} + +bool AABB::aabbFrustum(const Frustum &frustum) const { + const auto &planes = frustum.planes; + const auto *self = this; + return std::all_of(planes.begin(), + planes.end(), + // frustum plane normal points to the inside + [self](const Plane *plane) { return self->aabbPlane(*plane) != -1; }); +} + +void AABB::getBoundary(cc::Vec3 *minPos, cc::Vec3 *maxPos) const { + *maxPos = getCenter() + getHalfExtents(); + *minPos = getCenter() - getHalfExtents(); +} + +void AABB::merge(const AABB &aabb) { + AABB::merge(this, aabb, *this); +} + void AABB::set(const cc::Vec3 ¢erVal, const cc::Vec3 &halfExtentVal) { setCenter(centerVal); setHalfExtents(halfExtentVal); } void AABB::transform(const Mat4 &m, AABB *out) const { - AABBLayout *layout = out->_aabbLayout; - layout->center.transformMat4(getCenter(), m); - transformExtentM4(&layout->halfExtents, getHalfExtents(), m); + Vec3::transformMat4(center, m, &out->center); + transformExtentM4(&out->halfExtents, getHalfExtents(), m); } bool AABB::contain(const cc::Vec3 &point) const { @@ -145,31 +159,30 @@ bool AABB::contain(const cc::Vec3 &point) const { point.z > maxPos.z || point.z < minPos.z); } +// https://zeuxcg.org/2010/10/17/aabb-from-obb-with-component-wise-abs/ void AABB::transformExtentM4(Vec3 *out, const Vec3 &extent, const Mat4 &m4) { Mat3 m3Tmp; - m3Tmp.m[0] = abs(m4.m[0]); - m3Tmp.m[1] = abs(m4.m[1]); - m3Tmp.m[2] = abs(m4.m[2]); - m3Tmp.m[3] = abs(m4.m[4]); - m3Tmp.m[4] = abs(m4.m[5]); - m3Tmp.m[5] = abs(m4.m[6]); - m3Tmp.m[6] = abs(m4.m[8]); - m3Tmp.m[7] = abs(m4.m[9]); - m3Tmp.m[8] = abs(m4.m[10]); + m3Tmp.m[0] = std::abs(m4.m[0]); + m3Tmp.m[1] = std::abs(m4.m[1]); + m3Tmp.m[2] = std::abs(m4.m[2]); + m3Tmp.m[3] = std::abs(m4.m[4]); + m3Tmp.m[4] = std::abs(m4.m[5]); + m3Tmp.m[5] = std::abs(m4.m[6]); + m3Tmp.m[6] = std::abs(m4.m[8]); + m3Tmp.m[7] = std::abs(m4.m[9]); + m3Tmp.m[8] = std::abs(m4.m[10]); out->transformMat3(extent, m3Tmp); } AABB::AABB() { - _aabbLayout = &_embedLayout; + setType(ShapeEnum::SHAPE_AABB); } -void AABB::fromPoints(const Vec3 &minPos, const Vec3 &maxPos, AABB *dst) { - Vec3 v3Tmp; - Vec3::add(maxPos, minPos, &v3Tmp); - dst->setCenter(v3Tmp * 0.5); - Vec3::subtract(maxPos, minPos, &v3Tmp); - dst->setHalfExtents(v3Tmp * 0.5); +AABB::AABB(float px, float py, float pz, float hw, float hh, float hl) { + setType(ShapeEnum::SHAPE_AABB); + setCenter(px, py, pz); + setHalfExtents(hw, hh, hl); } -} // namespace scene +} // namespace geometry } // namespace cc diff --git a/native/cocos/core/geometry/AABB.h b/native/cocos/core/geometry/AABB.h new file mode 100644 index 0000000000..7123ef813d --- /dev/null +++ b/native/cocos/core/geometry/AABB.h @@ -0,0 +1,164 @@ +/**************************************************************************** + 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 +#include +#include "core/geometry/Enums.h" +#include "math/Mat3.h" +#include "math/Quaternion.h" +#include "math/Vec3.h" + +namespace cc { +namespace geometry { + +class Sphere; +class Frustum; +class Plane; + +class AABB final : public ShapeBase { +public: + /** + * @en + * create a new AABB + * @zh + * 创建一个新的 AABB 实例。 + * @param px - AABB 的原点的 X 坐标。 + * @param py - AABB 的原点的 Y 坐标。 + * @param pz - AABB 的原点的 Z 坐标。 + * @param hw - AABB 宽度的一半。 + * @param hh - AABB 高度的一半。 + * @param hl - AABB 长度的一半。 + * @returns 返回新创建的 AABB 实例。 + */ + static AABB *create(float px, float py, float pz, float hw, float hh, float hl) { + return new AABB(px, py, pz, hw, hh, hl); + } + + /** + * @en + * Set the components of a AABB to the given values + * @zh + * 将 AABB 的属性设置为给定的值。 + * @param {AABB} out 接受操作的 AABB。 + * @param px - AABB 的原点的 X 坐标。 + * @param py - AABB 的原点的 Y 坐标。 + * @param pz - AABB 的原点的 Z 坐标。 + * @param hw - AABB 宽度的一半。 + * @param hh - AABB 高度的一半。 + * @param hl - AABB 长度度的一半。 + * @return {AABB} out 接受操作的 AABB。 + */ + + static AABB *set(AABB *out, float px, float py, + float pz, + float hw, + float hh, + float hl) { + out->setCenter(px, py, pz); + out->setHalfExtents(hw, hh, hl); + return out; + } + + /** + * @en + * Merge tow AABB. + * @zh + * 合并两个 AABB 到 out。 + * @param out 接受操作的 AABB。 + * @param a 输入的 AABB。 + * @param b 输入的 AABB。 + * @returns {AABB} out 接受操作的 AABB。 + */ + static AABB *merge(AABB *out, const AABB &a, const AABB &b); + + /** + * @en + * AABB to sphere + * @zh + * 包围盒转包围球 + * @param out 接受操作的 sphere。 + * @param a 输入的 AABB。 + */ + + static Sphere *toBoundingSphere(Sphere *out, const AABB &a); + + static AABB *fromPoints(const Vec3 &minPos, const Vec3 &maxPos, AABB *dst); + static void transformExtentM4(Vec3 *out, const Vec3 &extent, const Mat4 &m4); + + AABB(float px, float py, float pz, float hw, float hh, float hl); + AABB(); + ~AABB() override = default; + + /** + * @en + * aabb-plane intersect detect. + * @zh + * 轴对齐包围盒和平面的相交性检测。 + * @param {AABB} aabb 轴对齐包围盒 + * @param {Plane} plane 平面 + * @return {number} inside(back) = -1, outside(front) = 0, intersect = 1 + */ + bool aabbAabb(const AABB &aabb) const; + + /** + * @en + * aabb-frustum intersect detect, faster but has false positive corner cases. + * @zh + * 轴对齐包围盒和锥台相交性检测,速度快,但有错误情况。 + * @param {AABB} aabb 轴对齐包围盒 + * @param {Frustum} frustum 锥台 + * @return {number} 0 或 非0 + */ + bool aabbFrustum(const Frustum &) const; + + int aabbPlane(const Plane &) const; + void getBoundary(cc::Vec3 *minPos, cc::Vec3 *maxPos) const; + void merge(const AABB &aabb); + void merge(const cc::Vec3 &point); + void merge(const std::vector &points); + void merge(const Frustum &frustum); + void set(const cc::Vec3 ¢erVal, const cc::Vec3 &halfExtentVal); + void transform(const Mat4 &m, AABB *out) const; + bool contain(const cc::Vec3 &point) const; + inline void setCenter(float x, float y, float z) { center.set(x, y, z); } + inline void setCenter(const Vec3 ¢er) { this->center.set(center); } + inline void setValid(bool isValid) { _isValid = isValid; } + inline const Vec3 &getCenter() const { return center; } + inline bool isValid() const { return _isValid; } + inline void setHalfExtents(float x, float y, float z) { halfExtents.set(x, y, z); } + inline void setHalfExtents(const Vec3 &halfExtents) { this->halfExtents.set(halfExtents); } + inline const Vec3 &getHalfExtents() const { return halfExtents; } + + cc::Vec3 center; + cc::Vec3 halfExtents{1, 1, 1}; + +private: + bool _isValid{true}; +}; + +} // namespace geometry +} // namespace cc diff --git a/native/cocos/core/geometry/Capsule.cpp b/native/cocos/core/geometry/Capsule.cpp new file mode 100644 index 0000000000..de447b2266 --- /dev/null +++ b/native/cocos/core/geometry/Capsule.cpp @@ -0,0 +1,47 @@ +#include "cocos/core/geometry/Capsule.h" +#include "cocos/math/Vec3.h" +namespace cc { +namespace geometry { + +void Capsule::transform(const Mat4 &m, const Vec3 & /*pos*/, const Quaternion &rot, const Vec3 &scale, Capsule *out) const { + const auto maxComponent = mathutils::absMaxComponent(scale); + out->radius = this->radius * abs(maxComponent); + + const auto halfTotalWorldHeight = (this->halfHeight + this->radius) * std::abs(scale.y); + auto halfWorldHeight = halfTotalWorldHeight - out->radius; + if (halfWorldHeight < 0) halfWorldHeight = 0; + out->halfHeight = halfWorldHeight; + + out->center.transformMat4(this->center, m); + Quaternion::multiply(this->rotation, rot, &out->rotation); + out->updateCache(); +} + +void Capsule::updateCache() { + updateLocalCenter(); + ellipseCenter0.transformQuat(rotation); + ellipseCenter1.transformQuat(rotation); + ellipseCenter0 += center; + ellipseCenter1 += center; +} + +void Capsule::updateLocalCenter() { + switch (axis) { + case CenterEnum::X: + ellipseCenter0 = {halfHeight, 0, 0}; + ellipseCenter1 = {-halfHeight, 0, 0}; + break; + case CenterEnum::Y: + ellipseCenter0 = {0, halfHeight, 0}; + ellipseCenter1 = {0, -halfHeight, 0}; + break; + case CenterEnum::Z: + ellipseCenter0 = {0, 0, halfHeight}; + ellipseCenter1 = {0, 0, -halfHeight}; + break; + default: + assert(false); + } +} +} // namespace geometry +} // namespace cc \ No newline at end of file diff --git a/native/cocos/core/geometry/Capsule.h b/native/cocos/core/geometry/Capsule.h new file mode 100644 index 0000000000..cb94c42679 --- /dev/null +++ b/native/cocos/core/geometry/Capsule.h @@ -0,0 +1,107 @@ +#pragma once + +#include "core/geometry/Enums.h" +#include "math/Mat4.h" +#include "math/Quaternion.h" +#include "math/Utils.h" +#include "math/Vec3.h" + +namespace cc { +namespace geometry { + +/** + * @en + * Basic Geometry: capsule. + * @zh + * 基础几何,胶囊体。 + */ +class Capsule final : public ShapeBase { + /** + * @en + * Gets the type of the shape. + * @zh + * 获取形状的类型。 + */ +public: + enum class CenterEnum { + X = 0, + Y = 1, + Z = 2 + }; + + /** + * @en + * Capsule sphere radius. + * @zh + * 胶囊体球部半径。 + */ + float radius{0.0F}; + + /** + * @en + * The distance between the center point of the capsule and the center of the sphere. + * @zh + * 胶囊体中心点和球部圆心的距离。 + */ + float halfHeight{0.0F}; + + /** + * @en + * Local orientation of capsule [0,1,2] => [x,y,z]. + * @zh + * 胶囊体的本地朝向,映射关系 [0,1,2] => [x,y,z]。 + */ + CenterEnum axis; + + /** + * @en + * The origin of the capsule. + * @zh + * 胶囊体的原点。 + */ + Vec3 center; + + /** + * @en + * The rotation of the capsule. + * @zh + * 胶囊体的旋转。 + */ + Quaternion rotation; + + /** cache, local center of ellipse */ + Vec3 ellipseCenter0; + Vec3 ellipseCenter1; + + explicit Capsule(float radius = 0.5, float halfHeight = 0.5, CenterEnum axis = CenterEnum::Y) { + this->setType(ShapeEnum::SHAPE_CAPSULE); + this->radius = radius; + this->halfHeight = halfHeight; + this->axis = axis; + this->center = {}; + this->rotation = {}; + ellipseCenter0 = {0, halfHeight, 0}; + ellipseCenter1 = {0, -halfHeight, 0}; + updateCache(); + } + + Capsule(const Capsule &other) = default; + Capsule(Capsule &&other) = default; + Capsule &operator=(const Capsule &other) = default; + Capsule &operator=(Capsule &&other) = default; + ~Capsule() override = default; + + /** + * @en + * Transform this capsule. + * @zh + * 变换此胶囊体。 + */ + void transform(const Mat4 &m, const Vec3 &pos, const Quaternion &rot, const Vec3 &scale, Capsule *out) const; + +private: + void updateCache(); + void updateLocalCenter(); +}; +} // namespace geometry +} // namespace cc \ No newline at end of file diff --git a/native/cocos/core/geometry/Curve.cpp b/native/cocos/core/geometry/Curve.cpp new file mode 100644 index 0000000000..ee803c7427 --- /dev/null +++ b/native/cocos/core/geometry/Curve.cpp @@ -0,0 +1,15 @@ +#include "cocos/core/geometry/Curve.h" +#include +namespace cc { +namespace geometry { + +float OptimizedKey::evaluate(float tt) { + const t = tt - time; + return evalOptCurve(t, coefficient); +} + +float evalOptCurve(float t, const std::vector &coefs) { + return (t * (t * (t * coefs[0] + coefs[1]) + coefs[2])) + coefs[3]; +} +} // namespace geometry +} // namespace cc \ No newline at end of file diff --git a/native/cocos/core/geometry/Curve.h b/native/cocos/core/geometry/Curve.h new file mode 100644 index 0000000000..e5f8ddae9a --- /dev/null +++ b/native/cocos/core/geometry/Curve.h @@ -0,0 +1,363 @@ +#pragma once + +#include +namespace cc { +namespace geometry { + +constexpr auto LOOK_FORWARD = 3; + +/** + * @en + * A key frame in the curve. + * @zh + * 曲线中的一个关键帧。 + */ +struct Keyframe { + /** + * @en Current frame time. + * @zh 当前帧时间。 + */ + float time = 0; + + /** + * @en Current frame value. + * @zh 当前帧的值。 + */ + float value = 0; + + /** + * @en In tangent value. + * @zh 左切线。 + */ + float inTangent = 0; + + /** + * @en Out tangent value. + * @zh 右切线。 + */ + float outTangent = 0; +}; + +float evalOptCurve(float t, const std::vector &coefs); + +struct OptimizedKey { + float index; + float time; + float endTime; + std::vector coefficient; + OptimizedKey() { + index = -1; + time = 0; + endTime = 0; + coefficient.resize(4); + } + static float evaluate(float t); +}; + +/** + * @en + * Describe a curve in which three times Hermite interpolation is used for each adjacent key frame. + * @zh + * 描述一条曲线,其中每个相邻关键帧采用三次hermite插值计算。 + */ +class AnimationCurve { + // @serializable +private: + // _curve ! : RealCurve; + +public: + static std::vector defaultKF = [ { + time : 0, + value : 1, + inTangent : 0, + outTangent : 0, + }, + { + time : 1, + value : 1, + inTangent : 0, + outTangent : 0, + } ]; + + /** + * For internal usage only. + * @internal + */ + get _internalCurve() { + return this._curve; + } + + /** + * @en + * The key frame of the curve. + * @zh + * 曲线的关键帧。 + */ + auto getKeyFrames() { + return Array.from(this._curve.keyframes()).map(([ time, value ]) = > { + const legacyKeyframe = new Keyframe(); + legacyKeyframe.time = time; + legacyKeyframe.value = value.value; + legacyKeyframe.inTangent = value.leftTangent; + legacyKeyframe.outTangent = value.rightTangent; + return legacyKeyframe; + }); + } + + void setKeyFrames(value) { + this._curve.assignSorted(value.map((legacyCurve) = > [ + legacyCurve.time, + { + interpolationMode : RealInterpolationMode.CUBIC, + value : legacyCurve.value, + leftTangent : legacyCurve.inTangent, + rightTangent : legacyCurve.outTangent, + }, + ])); + } + + /** + * @en + * Loop mode [[WrapMode]] when the sampling time exceeds the left end. + * @zh + * 当采样时间超出左端时采用的循环模式[[WrapMode]]。 + */ + auto getPreWrapMode() { + return toLegacyWrapMode(this._curve.preExtrapolation); + } + + void sPreWrapMode(value) { + this._curve.preExtrapolation = fromLegacyWrapMode(value); + } + + /** + * @en + * Cycle mode [[WrapMode]] when the sampling time exceeds the right end. + * @zh + * 当采样时间超出右端时采用的循环模式[[WrapMode]]。 + */ + get postWrapMode() { + return toLegacyWrapMode(this._curve.postExtrapolation); + } + + set postWrapMode(value) { + this._curve.postExtrapolation = fromLegacyWrapMode(value); + } + +private + cachedKey : OptimizedKey; + + /** + * 构造函数。 + * @param keyFrames 关键帧。 + */ + constructor(keyFrames + : Keyframe[] | null | RealCurve = null) { + if (keyFrames instanceof RealCurve) { + this._curve = keyFrames; + } else { + const curve = new RealCurve(); + this._curve = curve; + curve.preExtrapolation = ExtrapolationMode.LOOP; + curve.postExtrapolation = ExtrapolationMode.CLAMP; + if (!keyFrames) { + curve.assignSorted([ + [ 0.0, {interpolationMode : RealInterpolationMode.CUBIC, value : 1.0} ], + [ 1.0, {interpolationMode : RealInterpolationMode.CUBIC, value : 1.0} ], + ]); + } else { + curve.assignSorted(keyFrames.map((legacyKeyframe) = > [ legacyKeyframe.time, { + interpolationMode : RealInterpolationMode.CUBIC, + value : legacyKeyframe.value, + leftTangent : legacyKeyframe.inTangent, + rightTangent : legacyKeyframe.outTangent, + } ])); + } + } + this.cachedKey = new OptimizedKey(); + } + + /** + * @en + * Add a keyframe. + * @zh + * 添加一个关键帧。 + * @param keyFrame 关键帧。 + */ +public + addKey(keyFrame + : Keyframe | null) { + if (!keyFrame) { + this._curve.clear(); + } else { + this._curve.addKeyFrame(keyFrame.time, { + interpolationMode : RealInterpolationMode.CUBIC, + value : keyFrame.value, + leftTangent : keyFrame.inTangent, + rightTangent : keyFrame.outTangent, + }); + } + } + + /** + * @ignore + * @param time + */ +public + evaluate_slow(time + : number) { + return this._curve.evaluate(time); + } + + /** + * @en + * Calculate the curve interpolation at a given point in time. + * @zh + * 计算给定时间点的曲线插值。 + * @param time 时间。 + */ +public + evaluate(time + : number) { + const {cachedKey, _curve : curve} = this; + const nKeyframes = curve.keyFramesCount; + const lastKeyframeIndex = nKeyframes - 1; + let wrappedTime = time; + const extrapolationMode = time < 0 ? curve.preExtrapolation : curve.postExtrapolation; + const startTime = curve.getKeyframeTime(0); + const endTime = curve.getKeyframeTime(lastKeyframeIndex); + switch (extrapolationMode) { + case ExtrapolationMode.LOOP: + wrappedTime = repeat(time - startTime, endTime - startTime) + startTime; + break; + case ExtrapolationMode.PING_PONG: + wrappedTime = pingPong(time - startTime, endTime - startTime) + startTime; + break; + case ExtrapolationMode.CLAMP: + default: + wrappedTime = clamp(time, startTime, endTime); + break; + } + if (wrappedTime >= cachedKey.time && wrappedTime < cachedKey.endTime) { + return cachedKey.evaluate(wrappedTime); + } + const leftIndex = this.findIndex(cachedKey, wrappedTime); + const rightIndex = Math.min(leftIndex + 1, lastKeyframeIndex); + this.calcOptimizedKey(cachedKey, leftIndex, rightIndex); + return cachedKey.evaluate(wrappedTime); + } + + /** + * @ignore + * @param optKey + * @param leftIndex + * @param rightIndex + */ +public + calcOptimizedKey(optKey + : OptimizedKey, leftIndex + : number, rightIndex + : number) { + const lhsTime = this._curve.getKeyframeTime(leftIndex); + const rhsTime = this._curve.getKeyframeTime(rightIndex); + const {value : lhsValue, leftTangent : lhsOutTangent} = this._curve.getKeyframeValue(leftIndex); + const {value : rhsValue, rightTangent : rhsInTangent} = this._curve.getKeyframeValue(rightIndex); + optKey.index = leftIndex; + optKey.time = lhsTime; + optKey.endTime = rhsTime; + + const dx = rhsTime - lhsTime; + const dy = rhsValue - lhsValue; + const length = 1 / (dx * dx); + const d1 = lhsOutTangent * dx; + const d2 = rhsInTangent * dx; + + optKey.coefficient[0] = (d1 + d2 - dy - dy) * length / dx; + optKey.coefficient[1] = (dy + dy + dy - d1 - d1 - d2) * length; + optKey.coefficient[2] = lhsOutTangent; + optKey.coefficient[3] = lhsValue; + } + + /** + * @ignore + * @param optKey + * @param t + */ +private + findIndex(optKey + : OptimizedKey, t + : number) { + const {_curve : curve} = this; + const nKeyframes = curve.keyFramesCount; + const cachedIndex = optKey.index; + if (cachedIndex != = -1) { + const cachedTime = curve.getKeyframeTime(cachedIndex); + if (t > cachedTime) { + for (let i = 0; i < LOOK_FORWARD; i++) { + const currIndex = cachedIndex + i; + if (currIndex + 1 < nKeyframes && curve.getKeyframeTime(currIndex + 1) > t) { + return currIndex; + } + } + } else { + for (let i = 0; i < LOOK_FORWARD; i++) { + const currIndex = cachedIndex - i; + if (currIndex >= 0 && curve.getKeyframeTime(currIndex - 1) <= t) { + return currIndex - 1; + } + } + } + } + let left = 0; + let right = nKeyframes; + let mid; + while (right - left > 1) { + mid = Math.floor((left + right) / 2); + if (curve.getKeyframeTime(mid) >= t) { + right = mid; + } else { + left = mid; + } + } + return left; + } +} + +function +fromLegacyWrapMode(legacyWrapMode + : WrapModeMask) : ExtrapolationMode { + switch (legacyWrapMode) { + default: + case WrapModeMask.Default: + case WrapModeMask.Normal: + case WrapModeMask.Clamp: return ExtrapolationMode.CLAMP; + case WrapModeMask.PingPong: return ExtrapolationMode.PING_PONG; + case WrapModeMask.Loop: return ExtrapolationMode.LOOP; + } +} + +function toLegacyWrapMode(extrapolationMode + : ExtrapolationMode) : WrapModeMask { + switch (extrapolationMode) { + default: + case ExtrapolationMode.LINEAR: + case ExtrapolationMode.CLAMP: return WrapModeMask.Clamp; + case ExtrapolationMode.PING_PONG: return WrapModeMask.PingPong; + case ExtrapolationMode.LOOP: return WrapModeMask.Loop; + } +} + +/** + * Same as but more effective than `new LegacyCurve()._internalCurve`. + */ +export function constructLegacyCurveAndConvert() { + const curve = new RealCurve(); + curve.assignSorted([ + [ 0.0, {interpolationMode : RealInterpolationMode.CUBIC, value : 1.0} ], + [ 1.0, {interpolationMode : RealInterpolationMode.CUBIC, value : 1.0} ], + ]); + return curve; +} + +} +} // namespace cc \ No newline at end of file diff --git a/native/cocos/core/geometry/Distance.cpp b/native/cocos/core/geometry/Distance.cpp new file mode 100644 index 0000000000..eb1ae5397d --- /dev/null +++ b/native/cocos/core/geometry/Distance.cpp @@ -0,0 +1,80 @@ +#include "cocos/core/geometry/Distance.h" + +#include "cocos/core/geometry/AABB.h" +#include "cocos/core/geometry/Obb.h" +#include "cocos/core/geometry/Plane.h" +#include "cocos/math/Mat4.h" + +#include +#include +#include "cocos/math/Utils.h" +#include "cocos/math/Vec3.h" + +namespace cc { +namespace geometry { + +float pointPlane(const Vec3 &point, const Plane &plane) { + return Vec3::dot(plane.n, point) - plane.d; +} + +Vec3 *ptPointPlane(Vec3 *out, const Vec3 &point, const Plane &plane) { + auto t = pointPlane(point, plane); + *out = point - t * plane.n; + return out; +} + +Vec3 *ptPointAabb(Vec3 *out, const Vec3 &point, const AABB &aabb) { + auto min = aabb.getCenter() - aabb.getHalfExtents(); + auto max = aabb.getCenter() + aabb.getHalfExtents(); + *out = {cc::mathutils::clamp(point.x, min.x, max.x), + cc::mathutils::clamp(point.y, min.y, max.y), + cc::mathutils::clamp(point.z, min.z, max.z)}; + return out; +} + +Vec3 *ptPointObb(Vec3 *out, const Vec3 &point, const OBB &obb) { + std::array u = { + Vec3{obb.orientation.m[0], obb.orientation.m[1], obb.orientation.m[2]}, + Vec3{obb.orientation.m[3], obb.orientation.m[4], obb.orientation.m[5]}, + Vec3{obb.orientation.m[6], obb.orientation.m[7], obb.orientation.m[8]}, + }; + std::array e = {obb.halfExtents.x, obb.halfExtents.y, obb.halfExtents.z}; + + auto d = point - obb.center; + float dist = 0.0F; + + // Start result at center of obb; make steps from there + *out = obb.center; + + // For each OBB axis... + for (int i = 0; i < 3; i++) { + // ...project d onto that axis to get the distance + // along the axis of d from the obb center + dist = Vec3::dot(d, u[i]); + // if distance farther than the obb extents, clamp to the obb + dist = cc::mathutils::clamp(dist, -e[i], e[i]); + + // Step that distance along the axis to get world coordinate + *out += (dist * u[i]); + } + return out; +} + +Vec3 *ptPointLine(Vec3 *out, const Vec3 &point, const Vec3 &linePointA, const Vec3 &linePointB) { + auto dir = linePointA - linePointB; + auto dirSquared = dir.lengthSquared(); + + if (dirSquared == 0.0F) { + // The point is at the segment start. + *out = linePointA; + } else { + // Calculate the projection of the point onto the line extending through the segment. + auto ap = point - linePointA; + auto t = Vec3::dot(ap, dir) / dirSquared; + *out = linePointA + cc::mathutils::clamp(t, 0.0F, 1.0F) * dir; + } + return out; +} + +} // namespace geometry +} // namespace cc \ No newline at end of file diff --git a/native/cocos/core/geometry/Distance.h b/native/cocos/core/geometry/Distance.h new file mode 100644 index 0000000000..13a43887a9 --- /dev/null +++ b/native/cocos/core/geometry/Distance.h @@ -0,0 +1,72 @@ +#pragma once + +namespace cc { + +class Mat4; +class Vec3; +namespace geometry { + +class Plane; +class OBB; +class AABB; +/** + * @en + * the distance between a point and a plane + * @zh + * 计算点和平面之间的距离。 + * @param {Vec3} point 点。 + * @param {Plane} plane 平面。 + * @return 距离。 + */ +float pointPlane(const Vec3 &point, const Plane &plane); + +/** + * @en + * the closest point on plane to a given point + * @zh + * 计算平面上最接近给定点的点。 + * @param out 最近点。 + * @param point 给定点。 + * @param plane 平面。 + * @return 最近点。 + */ +Vec3 *ptPointPlane(Vec3 *out, const Vec3 &point, const Plane &plane); + +/** + * @en + * the closest point on aabb to a given point + * @zh + * 计算 aabb 上最接近给定点的点。 + * @param {Vec3} out 最近点。 + * @param {Vec3} point 给定点。 + * @param {AABB} aabb 轴对齐包围盒。 + * @return {Vec3} 最近点。 + */ +Vec3 *ptPointAabb(Vec3 *out, const Vec3 &point, const AABB &aabb); + +/** + * @en + * the closest point on obb to a given point + * @zh + * 计算 obb 上最接近给定点的点。 + * @param {Vec3} out 最近点。 + * @param {Vec3} point 给定点。 + * @param {OBB} obb 方向包围盒。 + * @return {Vec3} 最近点。 + */ +Vec3 *ptPointObb(Vec3 *out, const Vec3 &point, const OBB &obb); + +/** + * @en + * Calculate the nearest point on the line to the given point. + * @zh + * 计算给定点距离直线上最近的一点。 + * @param out 最近点 + * @param point 给定点 + * @param linePointA 线上的某点 A + * @param linePointB 线上的某点 B + */ +Vec3 *ptPointLine(Vec3 *out, const Vec3 &point, const Vec3 &linePointA, const Vec3 &linePointB); + +} // namespace geometry +} // namespace cc \ No newline at end of file diff --git a/native/cocos/core/geometry/Enums.h b/native/cocos/core/geometry/Enums.h new file mode 100644 index 0000000000..251c1739e7 --- /dev/null +++ b/native/cocos/core/geometry/Enums.h @@ -0,0 +1,42 @@ +#pragma once + +#include +#include "base/RefCounted.h" + +namespace cc { +namespace geometry { + +enum class ShapeEnum { + SHAPE_RAY = (1 << 0), + SHAPE_LINE = (1 << 1), + SHAPE_SPHERE = (1 << 2), + SHAPE_AABB = (1 << 3), + SHAPE_OBB = (1 << 4), + SHAPE_PLANE = (1 << 5), + SHAPE_TRIANGLE = (1 << 6), + SHAPE_FRUSTUM = (1 << 7), + SHAPE_FRUSTUM_ACCURATE = (1 << 8), + SHAPE_CAPSULE = (1 << 9), + SHAPE_BAD = (1 << 10), +}; + +class ShapeBase : public RefCounted { +public: + /** + * @en + * Gets the type of the shape. + * @zh + * 获取形状的类型。 + */ + inline ShapeEnum getType() const { + assert(_type != ShapeEnum::SHAPE_BAD); // shape is not initialized + return _type; + } + inline void setType(ShapeEnum type) { _type = type; } + +private: + ShapeEnum _type = ShapeEnum::SHAPE_BAD; +}; + +} // namespace geometry +} // namespace cc diff --git a/native/cocos/core/geometry/Frustum.cpp b/native/cocos/core/geometry/Frustum.cpp new file mode 100644 index 0000000000..b4d9fd7d75 --- /dev/null +++ b/native/cocos/core/geometry/Frustum.cpp @@ -0,0 +1,215 @@ +/**************************************************************************** + 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/geometry/Frustum.h" +#include +#include "core/geometry/Enums.h" +#include "scene/Camera.h" +#include "scene/Define.h" + +namespace cc { +namespace geometry { +namespace { +const std::vector VEC_VALS{ + {1, 1, 1}, + {-1, 1, 1}, + {-1, -1, 1}, + {1, -1, 1}, + {1, 1, -1}, + {-1, 1, -1}, + {-1, -1, -1}, + {1, -1, -1}}; +} // namespace + +void Frustum::createOrtho(Frustum *out, float width, + float height, + float near, + float far, + const Mat4 &transform) { + auto halfWidth = width / 2.0F; + auto halfHeight = height / 2.0F; + Vec3::transformMat4({halfWidth, halfHeight, -near}, transform, &out->vertices[0]); + Vec3::transformMat4({-halfWidth, halfHeight, -near}, transform, &out->vertices[1]); + Vec3::transformMat4({-halfWidth, -halfHeight, -near}, transform, &out->vertices[2]); + Vec3::transformMat4({halfWidth, -halfHeight, -near}, transform, &out->vertices[3]); + Vec3::transformMat4({halfWidth, halfHeight, -far}, transform, &out->vertices[4]); + Vec3::transformMat4({-halfWidth, halfHeight, -far}, transform, &out->vertices[5]); + Vec3::transformMat4({-halfWidth, -halfHeight, -far}, transform, &out->vertices[6]); + Vec3::transformMat4({halfWidth, -halfHeight, -far}, transform, &out->vertices[7]); + + Plane::fromPoints(out->planes[0], out->vertices[1], out->vertices[6], out->vertices[5]); + Plane::fromPoints(out->planes[1], out->vertices[3], out->vertices[4], out->vertices[7]); + Plane::fromPoints(out->planes[2], out->vertices[6], out->vertices[3], out->vertices[7]); + Plane::fromPoints(out->planes[3], out->vertices[0], out->vertices[5], out->vertices[4]); + Plane::fromPoints(out->planes[4], out->vertices[2], out->vertices[0], out->vertices[3]); + Plane::fromPoints(out->planes[5], out->vertices[7], out->vertices[5], out->vertices[6]); +} + +Frustum *Frustum::createFromAABB(Frustum *out, const AABB &aabb) { + Vec3 minPos; + Vec3 maxPos; + aabb.getBoundary(&minPos, &maxPos); + + out->vertices[0].set(minPos.x, maxPos.y, minPos.z); + out->vertices[1].set(maxPos.x, maxPos.y, minPos.z); + out->vertices[2].set(maxPos.x, minPos.y, minPos.z); + out->vertices[3].set(minPos.x, minPos.y, minPos.z); + out->vertices[4].set(minPos.x, maxPos.y, maxPos.z); + out->vertices[5].set(maxPos.x, maxPos.y, maxPos.z); + out->vertices[6].set(maxPos.x, minPos.y, maxPos.z); + out->vertices[7].set(minPos.x, minPos.y, maxPos.z); + + if (out->getType() != ShapeEnum::SHAPE_FRUSTUM_ACCURATE) { + return out; + } + + out->updatePlanes(); + + return out; +} + +Frustum *Frustum::split(Frustum *out, const scene::Camera &camera, const Mat4 &m, float start, float end) { + // 0: cameraNear 1:cameraFar + auto h = static_cast(::tan(camera.getFov() * 0.5)); + float w = h * camera.getAspect(); + Vec3 nearTemp{start * w, start * h, start}; + Vec3 farTemp{end * w, end * h, end}; + Vec3 v3Tmp; + + auto &vertexes = out->vertices; + // startHalfWidth startHalfHeight + v3Tmp.set(nearTemp.x, nearTemp.y, nearTemp.z); + vertexes[0].transformMat4(v3Tmp, m); + v3Tmp.set(-nearTemp.x, nearTemp.y, nearTemp.z); + vertexes[1].transformMat4(v3Tmp, m); + v3Tmp.set(-nearTemp.x, -nearTemp.y, nearTemp.z); + vertexes[2].transformMat4(v3Tmp, m); + v3Tmp.set(nearTemp.x, -nearTemp.y, nearTemp.z); + vertexes[3].transformMat4(v3Tmp, m); + + // endHalfWidth, endHalfHeight + v3Tmp.set(farTemp.x, farTemp.y, farTemp.z); + vertexes[4].transformMat4(v3Tmp, m); + v3Tmp.set(-farTemp.x, farTemp.y, farTemp.z); + vertexes[5].transformMat4(v3Tmp, m); + v3Tmp.set(-farTemp.x, -farTemp.y, farTemp.z); + vertexes[6].transformMat4(v3Tmp, m); + v3Tmp.set(farTemp.x, -farTemp.y, farTemp.z); + vertexes[7].transformMat4(v3Tmp, m); + + out->updatePlanes(); + return out; +} + +void Frustum::update(const Mat4 &m, const Mat4 &inv) { + // left plane + planes[0]->n.set(m.m[3] + m.m[0], m.m[7] + m.m[4], m.m[11] + m.m[8]); + planes[0]->d = -(m.m[15] + m.m[12]); + // right plane + planes[1]->n.set(m.m[3] - m.m[0], m.m[7] - m.m[4], m.m[11] - m.m[8]); + planes[1]->d = -(m.m[15] - m.m[12]); + // bottom plane + planes[2]->n.set(m.m[3] + m.m[1], m.m[7] + m.m[5], m.m[11] + m.m[9]); + planes[2]->d = -(m.m[15] + m.m[13]); + // top plane + planes[3]->n.set(m.m[3] - m.m[1], m.m[7] - m.m[5], m.m[11] - m.m[9]); + planes[3]->d = -(m.m[15] - m.m[13]); + // near plane + planes[4]->n.set(m.m[3] + m.m[2], m.m[7] + m.m[6], m.m[11] + m.m[10]); + planes[4]->d = -(m.m[15] + m.m[14]); + // far plane + planes[5]->n.set(m.m[3] - m.m[2], m.m[7] - m.m[6], m.m[11] - m.m[10]); + planes[5]->d = -(m.m[15] - m.m[14]); + + if (getType() != ShapeEnum::SHAPE_FRUSTUM_ACCURATE) { + return; + } + + for (Plane *plane : planes) { + float invDist = 1 / plane->n.length(); + plane->n *= invDist; + plane->d *= invDist; + } + uint32_t i = 0; + for (const Vec3 &vec : VEC_VALS) { + vertices[i].transformMat4(vec, inv); + i++; + } +} + +void Frustum::transform(const Mat4 &mat) { + if (getType() != ShapeEnum::SHAPE_FRUSTUM_ACCURATE) { + return; + } + for (auto i = 0; i < 8; i++) { + vertices[i].transformMat4(vertices[i], mat); + } + Plane::fromPoints(planes[0], vertices[1], vertices[6], vertices[5]); + Plane::fromPoints(planes[1], vertices[3], vertices[4], vertices[7]); + Plane::fromPoints(planes[2], vertices[6], vertices[3], vertices[7]); + Plane::fromPoints(planes[3], vertices[0], vertices[5], vertices[4]); + Plane::fromPoints(planes[4], vertices[2], vertices[0], vertices[3]); + Plane::fromPoints(planes[5], vertices[7], vertices[5], vertices[6]); +} + +void Frustum::createOrtho(const float width, const float height, const float near, const float far, const Mat4 &transform) { + createOrtho(this, width, height, near, far, transform); +} + +void Frustum::split(float start, float end, float aspect, float fov, const Mat4 &transform) { + const float h = tanf(fov * 0.5F); + const float w = h * aspect; + const Vec3 nearTemp(start * w, start * h, start); + const Vec3 farTemp(end * w, end * h, end); + + vertices[0].transformMat4(Vec3(nearTemp.x, nearTemp.y, nearTemp.z), transform); + vertices[1].transformMat4(Vec3(-nearTemp.x, nearTemp.y, nearTemp.z), transform); + vertices[2].transformMat4(Vec3(-nearTemp.x, -nearTemp.y, nearTemp.z), transform); + vertices[3].transformMat4(Vec3(nearTemp.x, -nearTemp.y, nearTemp.z), transform); + vertices[4].transformMat4(Vec3(farTemp.x, farTemp.y, farTemp.z), transform); + vertices[5].transformMat4(Vec3(-farTemp.x, farTemp.y, farTemp.z), transform); + vertices[6].transformMat4(Vec3(-farTemp.x, -farTemp.y, farTemp.z), transform); + vertices[7].transformMat4(Vec3(farTemp.x, -farTemp.y, farTemp.z), transform); + + updatePlanes(); +} + +void Frustum::updatePlanes() { + // left plane + planes[0]->define(vertices[1], vertices[6], vertices[5]); + // right plane + planes[1]->define(vertices[3], vertices[4], vertices[7]); + // bottom plane + planes[2]->define(vertices[6], vertices[3], vertices[7]); + // top plane + planes[3]->define(vertices[0], vertices[5], vertices[4]); + // near plane + planes[4]->define(vertices[2], vertices[0], vertices[3]); + // far plane + planes[5]->define(vertices[7], vertices[5], vertices[6]); +} + +} // namespace geometry +} // namespace cc diff --git a/native/cocos/core/geometry/Frustum.h b/native/cocos/core/geometry/Frustum.h new file mode 100644 index 0000000000..497e77a3b2 --- /dev/null +++ b/native/cocos/core/geometry/Frustum.h @@ -0,0 +1,165 @@ +/**************************************************************************** + 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 +#include "core/geometry/AABB.h" +#include "core/geometry/Enums.h" +#include "core/geometry/Plane.h" +#include "math/Mat4.h" +#include "math/Vec3.h" + +namespace cc { +namespace scene { +class Camera; +} +namespace geometry { + +class Frustum final : public ShapeBase { +public: + /** + * @en + * Create a ortho frustum. + * @zh + * 创建一个正交视锥体。 + * @param out 正交视锥体。 + * @param width 正交视锥体的宽度。 + * @param height 正交视锥体的高度。 + * @param near 正交视锥体的近平面值。 + * @param far 正交视锥体的远平面值。 + * @param transform 正交视锥体的变换矩阵。 + * @return {Frustum} frustum. + */ + static void createOrtho(Frustum *out, float width, + float height, + float near, + float far, + const Mat4 &transform); + /** + * @en Create a frustum from an AABB box. + * @zh 从 AABB 包围盒中创建一个视锥体。 + * @param out 视锥体。 + * @param aabb AABB 包围盒。 + * @return {Frustum} frustum. + */ + static Frustum *createFromAABB(Frustum *out, const AABB &aabb); + + /** + * @en create a new frustum. + * @zh 创建一个新的截锥体。 + * @param out 返回新截锥体 + * @param camera 相机参数 + * @param m 变换矩阵 + * @param start 分割开始位置 + * @param end 分割末尾位置 + * @return {Frustum} 返回新截锥体. + */ + static Frustum *split(Frustum *out, const scene::Camera &camera, const Mat4 &m, float start, float end); + + /** + * @en + * create a new frustum. + * @zh + * 创建一个新的截锥体。 + * @return {Frustum} frustum. + */ + static Frustum *create() { + return new Frustum(); + } + + /** + * @en + * Clone a frustum. + * @zh + * 克隆一个截锥体。 + */ + static Frustum *clone(const Frustum &f) { + return Frustum::copy(new Frustum(), f); + } + + /** + * @en + * Copy the values from one frustum to another. + * @zh + * 从一个截锥体拷贝到另一个截锥体。 + */ + static Frustum *copy(Frustum *out, const Frustum &f) { + out->setType(f.getType()); + for (size_t i = 0; i < 6; ++i) { + Plane::copy(out->planes[i], *(f.planes[i])); + } + out->vertices = f.vertices; + return out; + } + + /** + * @en + * Set whether to use accurate intersection testing function on this frustum. + * @zh + * 设置是否在此截锥体上使用精确的相交测试函数。 + */ + void setAccurate(bool accurate) { + setType(accurate ? ShapeEnum::SHAPE_FRUSTUM_ACCURATE : ShapeEnum::SHAPE_FRUSTUM); + } + + Frustum() { + setType(ShapeEnum::SHAPE_FRUSTUM); + for (size_t i = 0; i < planes.size(); ++i) { + planes[i] = new Plane(); + planes[i]->addRef(); + } + } + + ~Frustum() override { + for (auto* plane : planes) { + plane->release(); + } + } + + /** + * @en + * Transform this frustum. + * @zh + * 变换此截锥体。 + * @param mat 变换矩阵。 + */ + void transform(const Mat4 &); + + std::array vertices; + std::array planes; + void createOrtho(float width, float height, float near, float far, const Mat4 &transform); + void split(float start, float end, float aspect, float fov, const Mat4 &transform); + void updatePlanes(); + void update(const Mat4 &m, const Mat4 &inv); + Frustum clone() const { + Frustum tmp; + copy(&tmp, *this); + return tmp; + } +}; + +} // namespace geometry +} // namespace cc diff --git a/native/cocos/core/geometry/Geometry.h b/native/cocos/core/geometry/Geometry.h new file mode 100644 index 0000000000..c75641fdf6 --- /dev/null +++ b/native/cocos/core/geometry/Geometry.h @@ -0,0 +1,16 @@ +#pragma once + +#include "AABB.h" +#include "Capsule.h" +// #include "Curve.h" +#include "Distance.h" +#include "Enums.h" +#include "Frustum.h" +#include "Intersect.h" +#include "Line.h" +#include "Obb.h" +#include "Plane.h" +#include "Ray.h" +#include "Spec.h" +#include "Sphere.h" +#include "Triangle.h" diff --git a/native/cocos/core/geometry/Intersect.cpp b/native/cocos/core/geometry/Intersect.cpp new file mode 100644 index 0000000000..77f1ef353b --- /dev/null +++ b/native/cocos/core/geometry/Intersect.cpp @@ -0,0 +1,1062 @@ +#include "core/geometry/Intersect.h" + +#include +#include +#include +#include +#include "3d/assets/Mesh.h" +#include "base/Macros.h" +#include "core/TypedArray.h" +#include "core/assets/RenderingSubMesh.h" +#include "core/geometry/AABB.h" +#include "core/geometry/Capsule.h" +#include "core/geometry/Distance.h" +#include "core/geometry/Enums.h" +#include "core/geometry/Frustum.h" +#include "core/geometry/Line.h" +#include "core/geometry/Obb.h" +#include "core/geometry/Plane.h" +#include "core/geometry/Ray.h" +#include "core/geometry/Spec.h" +#include "core/geometry/Sphere.h" +#include "core/geometry/Triangle.h" +#include "math/Mat3.h" +#include "math/Math.h" +#include "math/Vec3.h" +#include "renderer/gfx-base/GFXDef.h" +#include "scene/Model.h" + +namespace cc { +namespace geometry { + +float rayPlane(const Ray &ray, const Plane &plane) { + auto denom = Vec3::dot(ray.d, plane.n); + if (abs(denom) < math::EPSILON) { + return 0; + } + auto t = (plane.n * plane.d - ray.o).dot(plane.n) / denom; + return t < 0 ? 0 : t; +} + +// based on http://fileadmin.cs.lth.se/cs/Personal/Tomas_Akenine-Moller/raytri/ +float rayTriangle(const Ray &ray, const Triangle &triangle, bool doubleSided) { + Vec3 pvec{}; + Vec3 qvec{}; + auto ab = triangle.b - triangle.a; + auto ac = triangle.c - triangle.a; + Vec3::cross(ray.d, ac, &pvec); + float det = Vec3::dot(ab, pvec); + if (det < math::EPSILON && (!doubleSided || det > -math::EPSILON)) { + return 0; + } + float invDet = 1.0F / det; + auto ao = ray.o - triangle.a; + auto u = Vec3::dot(ao, pvec) * invDet; + if (u < 0 || u > 1) { + return 0; + } + Vec3::cross(ao, ab, &qvec); + auto v = Vec3::dot(ray.d, qvec) * invDet; + if (v < 0 || u + v > 1) { + return 0; + } + + auto t = Vec3::dot(ac, qvec) * invDet; + return t < 0 ? 0 : t; +} + +float raySphere(const Ray &ray, const Sphere &sphere) { + auto rSq = sphere.getRadius() * sphere.getRadius(); + auto e = sphere.getCenter() - ray.o; + auto eSq = e.lengthSquared(); + + auto aLength = Vec3::dot(e, ray.d); // assume ray direction already normalized + auto fSq = rSq - (eSq - aLength * aLength); + if (fSq < 0) { + return 0; + } + + auto f = sqrt(fSq); + auto t = eSq < rSq ? aLength + f : aLength - f; + return t < 0 ? 0 : t; +} + +float rayAABB2(const Ray &ray, const Vec3 &min, const Vec3 &max) { + const auto &o = ray.o; + auto d = ray.d; + auto ix = 1.0F / d.x; + auto iy = 1.0F / d.y; + auto iz = 1.0F / d.z; + auto tx1 = (min.x - o.x) * ix; + auto tx2 = (max.x - o.x) * ix; + auto ty1 = (min.y - o.y) * iy; + auto ty2 = (max.y - o.y) * iy; + auto tz1 = (min.z - o.z) * iz; + auto tz2 = (max.z - o.z) * iz; + auto tmin = std::max(std::max(std::min(tx1, tx2), std::min(ty1, ty2)), std::min(tz1, tz2)); + auto tmax = std::min(std::min(std::max(tx1, tx2), std::max(ty1, ty2)), std::max(tz1, tz2)); + if (tmax < 0 || tmin > tmax) { + return 0; + } + return tmin > 0 ? tmin : tmax; // ray origin inside aabb +} + +float rayAABB(const Ray &ray, const AABB &aabb) { + auto minV = aabb.getCenter() - aabb.getHalfExtents(); + auto maxV = aabb.getCenter() + aabb.getHalfExtents(); + return rayAABB2(ray, minV, maxV); +} + +float rayOBB(const Ray &ray, const OBB &obb) { + std::array t; + std::array size = {obb.halfExtents.x, obb.halfExtents.y, obb.halfExtents.z}; + const auto & center = obb.center; + auto const & d = ray.d; + + Vec3 x = {obb.orientation.m[0], obb.orientation.m[1], obb.orientation.m[2]}; + Vec3 y = {obb.orientation.m[3], obb.orientation.m[4], obb.orientation.m[5]}; + Vec3 z = {obb.orientation.m[6], obb.orientation.m[7], obb.orientation.m[8]}; + Vec3 p = center - ray.o; + + // The cos values of the ray on the X, Y, Z + std::array f = {Vec3::dot(x, d), Vec3::dot(y, d), Vec3::dot(z, d)}; + + // The projection length of P on X, Y, Z + std::array e{Vec3::dot(x, p), Vec3::dot(y, p), Vec3::dot(z, p)}; + + for (auto i = 0; i < 3; ++i) { + if (f[i] == 0) { + if (-e[i] - size[i] > 0 || -e[i] + size[i] < 0) { + return 0; + } + // Avoid div by 0! + f[i] = 0.000001F; + } + // min + t[i * 2 + 0] = (e[i] + size[i]) / f[i]; + // max + t[i * 2 + 1] = (e[i] - size[i]) / f[i]; + } + auto tmin = std::max(std::max(std::min(t[0], t[1]), std::min(t[2], t[3])), std::min(t[4], t[5])); + auto tmax = std::min(std::min(std::max(t[0], t[1]), std::max(t[2], t[3])), std::max(t[4], t[5])); + if (tmax < 0 || tmin > tmax) { + return 0; + } + return tmin > 0 ? tmin : tmax; // ray origin inside aabb +} + +float rayCapsule(const Ray &ray, const Capsule &capsule) { + Sphere sphere; + auto radiusSqr = capsule.radius * capsule.radius; + auto vRayNorm = ray.d.getNormalized(); + auto aa = capsule.ellipseCenter0; + auto bb = capsule.ellipseCenter1; + auto ba = bb - aa; + if (ba == Vec3::ZERO) { + sphere.setRadius(capsule.radius); + sphere.setCenter(capsule.ellipseCenter0); + return raySphere(ray, sphere); + } + + auto oa = ray.o - aa; + Vec3 VxBA; //NOLINT(readability-identifier-naming) + Vec3::cross(vRayNorm, ba, &VxBA); + auto a = VxBA.lengthSquared(); + if (a == 0.0F) { + sphere.setRadius(capsule.radius); + auto bo = bb - ray.o; + if (oa.lengthSquared() < bo.lengthSquared()) { + sphere.setCenter(capsule.ellipseCenter0); + } else { + sphere.setCenter(capsule.ellipseCenter1); + } + return raySphere(ray, sphere); + } + + Vec3 OAxBA; //NOLINT(readability-identifier-naming) + Vec3::cross(oa, ba, &OAxBA); + auto ab2 = ba.lengthSquared(); + auto b = 2.0F * Vec3::dot(VxBA, OAxBA); + auto c = OAxBA.lengthSquared() - (radiusSqr * ab2); + auto d = b * b - 4 * a * c; + + if (d < 0) { + return 0; + } + + auto t = (-b - std::sqrt(d)) / (2.0F * a); + if (t < 0.0F) { + sphere.setRadius(capsule.radius); + auto bo = bb - ray.o; + if (oa.lengthSquared() < bo.lengthSquared()) { + sphere.setCenter(capsule.ellipseCenter0); + } else { + sphere.setCenter(capsule.ellipseCenter1); + } + return raySphere(ray, sphere); + } + // Limit intersection between the bounds of the cylinder's end caps. + auto iPos = ray.o + vRayNorm * t; + auto iPosLen = iPos - aa; + auto tLimit = Vec3::dot(iPosLen, ba) / ab2; + + if (tLimit >= 0 && tLimit <= 1) { + return t; + } + if (tLimit < 0) { + sphere.setRadius(capsule.radius); + sphere.setCenter(capsule.ellipseCenter0); + return raySphere(ray, sphere); + } + if (tLimit > 1) { + sphere.setRadius(capsule.radius); + sphere.setCenter(capsule.ellipseCenter1); + return raySphere(ray, sphere); + } + return 0; +} + +namespace { +void fillResult(float *minDis, ERaycastMode m, float d, float i0, float i1, float i2, cc::optional> &r) { + if (m == ERaycastMode::CLOSEST) { + if (*minDis > d || *minDis == 0.0F) { + *minDis = d; + if (r) { + if (r->empty()) { + r->emplace_back(IRaySubMeshResult{d, static_cast(i0 / 3), static_cast(i1 / 3), static_cast(i2 / 3)}); + } else { + (*r)[0].distance = d; + (*r)[0].vertexIndex0 = static_cast(i0 / 3); + (*r)[0].vertexIndex1 = static_cast(i1 / 3); + (*r)[0].vertexIndex2 = static_cast(i2 / 3); + } + } + } + } else { + *minDis = d; + if (r) r->emplace_back(IRaySubMeshResult{d, static_cast(i0 / 3), static_cast(i1 / 3), static_cast(i2 / 3)}); + } +} + +float narrowphase(float *minDis, const Float32Array &vb, const IBArray &ib, gfx::PrimitiveMode pm, const Ray &ray, IRaySubMeshOptions *opt) { + Triangle tri; + auto ibSize = cc::visit([](auto &arr) { return arr.length(); }, ib); + return cc::visit([&](auto &ib) { + if (pm == gfx::PrimitiveMode::TRIANGLE_LIST) { + auto cnt = ibSize; + for (auto j = 0; j < cnt; j += 3) { + auto i0 = ib[j] * 3; + auto i1 = ib[j + 1] * 3; + auto i2 = ib[j + 2] * 3; + tri.a = {vb[i0], vb[i0 + 1], vb[i0 + 2]}; + tri.b = {vb[i1], vb[i1 + 1], vb[i1 + 2]}; + tri.c = {vb[i2], vb[i2 + 1], vb[i2 + 2]}; + auto dist = rayTriangle(ray, tri, opt->doubleSided); + if (dist == 0.0F || dist > opt->distance) continue; + fillResult(minDis, opt->mode, dist, static_cast(i0), static_cast(i1), static_cast(i2), opt->result); + if (opt->mode == ERaycastMode::ANY) return dist; + } + } else if (pm == gfx::PrimitiveMode::TRIANGLE_STRIP) { + auto cnt = ibSize - 2; + int32_t rev = 0; + for (auto j = 0; j < cnt; j += 1) { + auto i0 = ib[j - rev] * 3; + auto i1 = ib[j + rev + 1] * 3; + auto i2 = ib[j + 2] * 3; + tri.a = {vb[i0], vb[i0 + 1], vb[i0 + 2]}; + tri.b = {vb[i1], vb[i1 + 1], vb[i1 + 2]}; + tri.c = {vb[i2], vb[i2 + 1], vb[i2 + 2]}; + rev = ~rev; + auto dist = rayTriangle(ray, tri, opt->doubleSided); + if (dist == 0.0F || dist > opt->distance) continue; + fillResult(minDis, opt->mode, dist, static_cast(i0), static_cast(i1), static_cast(i2), opt->result); + if (opt->mode == ERaycastMode::ANY) return dist; + } + } else if (pm == gfx::PrimitiveMode::TRIANGLE_FAN) { + auto cnt = ibSize - 1; + auto i0 = ib[0] * 3; + tri.a = {vb[i0], vb[i0 + 1], vb[i0 + 2]}; + for (auto j = 1; j < cnt; j += 1) { + auto i1 = ib[j] * 3; + auto i2 = ib[j + 1] * 3; + tri.b = {vb[i1], vb[i1 + 1], vb[i1 + 2]}; + tri.c = {vb[i2], vb[i2 + 1], vb[i2 + 2]}; + auto dist = rayTriangle(ray, tri, opt->doubleSided); + if (dist == 0.0 || dist > opt->distance) continue; + fillResult(minDis, opt->mode, dist, static_cast(i0), static_cast(i1), static_cast(i2), opt->result); + if (opt->mode == ERaycastMode::ANY) return dist; + } + } + return *minDis; + }, + ib); +} +} // namespace + +float raySubMesh(const Ray &ray, const RenderingSubMesh &submesh, IRaySubMeshOptions *options) { + Triangle tri; + IRaySubMeshOptions deOpt; + deOpt.mode = ERaycastMode::ANY; + deOpt.distance = FLT_MAX; + deOpt.doubleSided = false; + float minDis = 0.0F; + auto &mesh = const_cast(submesh); + if (mesh.getGeometricInfo().positions.empty()) return minDis; + IRaySubMeshOptions *opt = options ? options : &deOpt; + auto min = mesh.getGeometricInfo().boundingBox.min; + auto max = mesh.getGeometricInfo().boundingBox.max; + if (rayAABB2(ray, min, max) != 0.0F) { + const auto &pm = mesh.getPrimitiveMode(); + const auto &info = mesh.getGeometricInfo(); + narrowphase(&minDis, info.positions, info.indices.value(), pm, ray, opt); + } + return minDis; +} + +float rayMesh(const Ray &ray, const Mesh &mesh, IRayMeshOptions *option) { + float minDis = 0.0F; + IRayMeshOptions deOpt; + deOpt.distance = std::numeric_limits::max(); + deOpt.doubleSided = false; + deOpt.mode = ERaycastMode::ANY; + IRayMeshOptions *opt = option ? option : &deOpt; + auto length = mesh.getSubMeshCount(); + auto min = mesh.getStruct().minPosition; + auto max = mesh.getStruct().maxPosition; + if (min.has_value() && max.has_value() && rayAABB2(ray, min.value(), max.value()) == 0.0F) return minDis; + for (uint32_t i = 0; i < length; i++) { + const auto &sm = const_cast(mesh).getRenderingSubMeshes()[i]; + float dis = raySubMesh(ray, *sm, opt); + if (dis != 0.0F) { + if (opt->mode == ERaycastMode::CLOSEST) { + if (minDis == 0.0F || minDis > dis) { + minDis = dis; + if (opt->subIndices.has_value()) { + if (opt->subIndices->empty()) { + opt->subIndices->resize(1); + } + opt->subIndices.value()[0] = i; + } + } + } else { + minDis = dis; + if (opt->subIndices.has_value()) opt->subIndices->emplace_back(i); + if (opt->mode == ERaycastMode::ANY) { + return dis; + } + } + } + } + if (minDis != 0.0F && opt->mode == ERaycastMode::CLOSEST) { + if (opt->result.has_value()) { + opt->result.value()[0].distance = minDis; + opt->result.value().resize(1); + } + if (opt->subIndices.has_value()) opt->subIndices.value().resize(1); + } + return minDis; +} + +float rayModel(const Ray &ray, const scene::Model &model, IRayModelOptions *option) { + float minDis = 0.0F; + IRayModelOptions deOpt; + deOpt.distance = std::numeric_limits::max(); + deOpt.doubleSided = false; + deOpt.mode = ERaycastMode::ANY; + + IRayModelOptions *opt = option ? option : &deOpt; + const auto * wb = model.getWorldBounds(); + if (wb && rayAABB(ray, *wb) == 0.0F) { + return minDis; + } + Ray modelRay{ray}; + if (model.getNode()) { + Mat4 m4 = model.getNode()->getWorldMatrix().getInversed(); + Vec3::transformMat4(ray.o, m4, &modelRay.o); + Vec3::transformMat4Normal(ray.d, m4, &modelRay.d); + } + const auto &subModels = model.getSubModels(); + for (auto i = 0; i < subModels.size(); i++) { + const auto &subMesh = subModels[i]->getSubMesh(); + float dis = raySubMesh(modelRay, *subMesh, opt); + if (dis != 0.0F) { + if (opt->mode == ERaycastMode::CLOSEST) { + if (minDis == 0.0F || minDis > dis) { + minDis = dis; + if (opt->subIndices.has_value()) { + if (opt->subIndices->empty()) { + opt->subIndices->resize(1); + } + opt->subIndices.value()[0] = i; + } + } + } else { + minDis = dis; + if (opt->subIndices.has_value()) opt->subIndices->emplace_back(i); + if (opt->mode == ERaycastMode::ANY) { + return dis; + } + } + } + } + if (minDis != 0.0F && opt->mode == ERaycastMode::CLOSEST) { + if (opt->result.has_value()) { + opt->result.value()[0].distance = minDis; + opt->result.value().resize(1); + } + if (opt->subIndices.has_value()) opt->subIndices->resize(1); + } + return minDis; +} + +float linePlane(const Line &line, const Plane &plane) { + auto ab = line.e - line.s; + auto t = (plane.d - Vec3::dot(line.s, plane.n)) / Vec3::dot(ab, plane.n); + return (t < 0 || t > 1) ? 0 : t; +} + +int lineTriangle(const Line &line, const Triangle &triangle, Vec3 *outPt) { + Vec3 n; + Vec3 e; + auto ab = triangle.b - triangle.a; + auto ac = triangle.c - triangle.a; + auto qp = line.s - line.e; + Vec3::cross(ab, ac, &n); + + auto det = Vec3::dot(qp, n); + + if (det <= 0.0F) { + return 0; + } + + auto ap = line.s - triangle.a; + auto t = Vec3::dot(ap, n); + if (t < 0 || t > det) { + return 0; + } + + Vec3::cross(qp, ap, &e); + auto v = Vec3::dot(ac, e); + if (v < 0.0F || v > det) { + return 0; + } + + auto w = -Vec3::dot(ab, e); + if (w < 0.0F || v + w > det) { + return 0; + } + + if (outPt) { + auto invDet = 1.0F / det; + v *= invDet; + w *= invDet; + auto u = 1.0F - v - w; + + // outPt = u*a + v*d + w*c; + *outPt = {triangle.a.x * u + triangle.b.x * v + triangle.c.x * w, + triangle.a.y * u + triangle.b.y * v + triangle.c.y * w, + triangle.a.z * u + triangle.b.z * v + triangle.c.z * w}; + } + + return 1; +} + +float lineAABB(const Line &line, const AABB &aabb) { + Ray ray; + ray.o.set(line.s); + ray.d = line.e - line.s; + ray.d.normalize(); + auto min = rayAABB(ray, aabb); + return min < line.length() ? min : 0.0F; +} + +float lineOBB(const Line &line, const OBB &obb) { + Ray ray; + ray.o.set(line.s); + ray.d = line.e - line.s; + ray.d.normalize(); + auto min = rayOBB(ray, obb); + return min < line.length() ? min : 0.0F; +} + +float lineSphere(const Line &line, const Sphere &sphere) { + Ray ray; + ray.o.set(line.s); + ray.d = line.e - line.s; + ray.d.normalize(); + auto min = raySphere(ray, sphere); + return min < line.length() ? min : 0.0F; +} + +bool aabbWithAABB(const AABB &aabb1, const AABB &aabb2) { + auto aMin = aabb1.getCenter() - aabb1.getHalfExtents(); + auto aMax = aabb1.getCenter() + aabb1.getHalfExtents(); + auto bMin = aabb2.getCenter() - aabb2.getHalfExtents(); + auto bMax = aabb2.getCenter() + aabb2.getHalfExtents(); + return (aMin.x <= bMax.x && aMax.x >= bMin.x) && (aMin.y <= bMax.y && aMax.y >= bMin.y) && (aMin.z <= bMax.z && aMax.z >= bMin.z); +} + +static void getAABBVertices(const Vec3 &min, const Vec3 &max, std::array *out) { + *out = { + Vec3{min.x, max.y, max.z}, + Vec3{min.x, max.y, min.z}, + Vec3{min.x, min.y, max.z}, + Vec3{min.x, min.y, min.z}, + Vec3{max.x, max.y, max.z}, + Vec3{max.x, max.y, min.z}, + Vec3{max.x, min.y, max.z}, + Vec3{max.x, min.y, min.z}, + }; +} + +static void getOBBVertices(const Vec3 &c, const Vec3 &e, + const Vec3 &a1, const Vec3 &a2, const Vec3 &a3, + std::array *out) { + *out = {Vec3{ + c.x + a1.x * e.x + a2.x * e.y + a3.x * e.z, + c.y + a1.y * e.x + a2.y * e.y + a3.y * e.z, + c.z + a1.z * e.x + a2.z * e.y + a3.z * e.z}, + Vec3{ + c.x - a1.x * e.x + a2.x * e.y + a3.x * e.z, + c.y - a1.y * e.x + a2.y * e.y + a3.y * e.z, + c.z - a1.z * e.x + a2.z * e.y + a3.z * e.z}, + Vec3{ + c.x + a1.x * e.x - a2.x * e.y + a3.x * e.z, + c.y + a1.y * e.x - a2.y * e.y + a3.y * e.z, + c.z + a1.z * e.x - a2.z * e.y + a3.z * e.z}, + Vec3{ + c.x + a1.x * e.x + a2.x * e.y - a3.x * e.z, + c.y + a1.y * e.x + a2.y * e.y - a3.y * e.z, + c.z + a1.z * e.x + a2.z * e.y - a3.z * e.z}, + Vec3{ + c.x - a1.x * e.x - a2.x * e.y - a3.x * e.z, + c.y - a1.y * e.x - a2.y * e.y - a3.y * e.z, + c.z - a1.z * e.x - a2.z * e.y - a3.z * e.z}, + Vec3{ + c.x + a1.x * e.x - a2.x * e.y - a3.x * e.z, + c.y + a1.y * e.x - a2.y * e.y - a3.y * e.z, + c.z + a1.z * e.x - a2.z * e.y - a3.z * e.z}, + Vec3{ + c.x - a1.x * e.x + a2.x * e.y - a3.x * e.z, + c.y - a1.y * e.x + a2.y * e.y - a3.y * e.z, + c.z - a1.z * e.x + a2.z * e.y - a3.z * e.z}, + Vec3{ + c.x - a1.x * e.x - a2.x * e.y + a3.x * e.z, + c.y - a1.y * e.x - a2.y * e.y + a3.y * e.z, + c.z - a1.z * e.x - a2.z * e.y + a3.z * e.z}}; +} + +struct Interval { + float min; + float max; +}; + +static Interval getInterval(const std::array &vertices, const Vec3 &axis) { + auto min = std::numeric_limits::max(); + auto max = std::numeric_limits::min(); + for (auto i = 0; i < 8; ++i) { + auto projection = Vec3::dot(axis, vertices[i]); + min = std::min(projection, min); + max = std::max(projection, max); + } + return Interval{min, max}; +} + +int aabbWithOBB(const AABB &aabb, const OBB &obb) { + std::array test; + std::array vertices; + std::array vertices2; + test[0] = {1, 0, 0}; + test[1] = {0, 1, 0}; + test[2] = {0, 0, 1}; + test[3] = {obb.orientation.m[0], obb.orientation.m[1], obb.orientation.m[2]}; + test[4] = {obb.orientation.m[3], obb.orientation.m[4], obb.orientation.m[5]}; + test[5] = {obb.orientation.m[6], obb.orientation.m[7], obb.orientation.m[8]}; + + for (auto i = 0; i < 3; ++i) { // Fill out rest of axis + Vec3::cross(test[i], test[3], &test[6 + i * 3 + 0]); + Vec3::cross(test[i], test[4], &test[6 + i * 3 + 1]); + Vec3::cross(test[i], test[5], &test[6 + i * 3 + 2]); + } + + auto min = aabb.getCenter() - aabb.getHalfExtents(); + auto max = aabb.getCenter() + aabb.getHalfExtents(); + getAABBVertices(min, max, &vertices); + getOBBVertices(obb.center, obb.halfExtents, test[3], test[4], test[5], &vertices2); + + for (auto j = 0; j < 15; ++j) { + auto a = getInterval(vertices, test[j]); + auto b = getInterval(vertices2, test[j]); + if (b.min > a.max || a.min > b.max) { + return 0; // Seperating axis found + } + } + + return 1; +} + +int aabbPlane(const AABB &aabb, const Plane &plane) { + auto r = aabb.getHalfExtents().x * std::abs(plane.n.x) + aabb.getHalfExtents().y * std::abs(plane.n.y) + aabb.getHalfExtents().z * std::abs(plane.n.z); + auto dot = Vec3::dot(plane.n, aabb.getCenter()); + if (dot + r < plane.d) { + return -1; + } + if (dot - r > plane.d) { + return 0; + } + return 1; +} + +int aabbFrustum(const AABB &aabb, const Frustum &frustum) { + for (const auto &plane : frustum.planes) { + // frustum plane normal points to the inside + if (aabbPlane(aabb, *plane) == -1) { + return 0; + } + } // completely outside + return 1; +} + +// https://cesium.com/blog/2017/02/02/tighter-frustum-culling-and-why-you-may-want-to-disregard-it/ +int aabbFrustumAccurate(const AABB &aabb, const Frustum &frustum) { + std::array tmp; + int out1 = 0; + int out2 = 0; + int result = 0; + bool intersects = false; + // 1. aabb inside/outside frustum test + for (const auto &plane : frustum.planes) { + result = aabbPlane(aabb, *plane); + // frustum plane normal points to the inside + if (result == -1) { + return 0; // completely outside + } + if (result == 1) { + intersects = true; + } + } + if (!intersects) { + return 1; + } // completely inside + // in case of false positives + // 2. frustum inside/outside aabb test + for (auto i = 0; i < frustum.vertices.size(); i++) { + tmp[i] = frustum.vertices[i] - aabb.getCenter(); + } + out1 = 0; + out2 = 0; + for (auto i = 0; i < frustum.vertices.size(); i++) { + if (tmp[i].x > aabb.getHalfExtents().x) { + out1++; + } else if (tmp[i].x < -aabb.getHalfExtents().x) { + out2++; + } + } + if (out1 == frustum.vertices.size() || out2 == frustum.vertices.size()) { + return 0; + } + out1 = 0; + out2 = 0; + for (auto i = 0; i < frustum.vertices.size(); i++) { + if (tmp[i].y > aabb.getHalfExtents().y) { + out1++; + } else if (tmp[i].y < -aabb.getHalfExtents().y) { + out2++; + } + } + if (out1 == frustum.vertices.size() || out2 == frustum.vertices.size()) { + return 0; + } + out1 = 0; + out2 = 0; + for (auto i = 0; i < frustum.vertices.size(); i++) { + if (tmp[i].z > aabb.getHalfExtents().z) { + out1++; + } else if (tmp[i].z < -aabb.getHalfExtents().z) { + out2++; + } + } + if (out1 == frustum.vertices.size() || out2 == frustum.vertices.size()) { + return 0; + } + return 1; +} + +bool obbPoint(const OBB &obb, const Vec3 &point) { + Mat3 m3; + auto lessThan = [](const Vec3 &a, const Vec3 &b) -> bool { + return std::abs(a.x) < b.x && std::abs(a.y) < b.y && std::abs(a.z) < b.z; + }; + auto tmp = point - obb.center; + Mat3::transpose(obb.orientation, &m3); + tmp.transformMat3(tmp, m3); + return lessThan(tmp, obb.halfExtents); +}; + +int obbPlane(const OBB &obb, const Plane &plane) { + auto absDot = [](const Vec3 &n, float x, float y, float z) -> float { + return std::abs(n.x * x + n.y * y + n.z * z); + }; + + // Real-Time Collision Detection, Christer Ericson, p. 163. + auto r = obb.halfExtents.x * absDot(plane.n, obb.orientation.m[0], obb.orientation.m[1], obb.orientation.m[2]) + + obb.halfExtents.y * absDot(plane.n, obb.orientation.m[3], obb.orientation.m[4], obb.orientation.m[5]) + + obb.halfExtents.z * absDot(plane.n, obb.orientation.m[6], obb.orientation.m[7], obb.orientation.m[8]); + + auto dot = Vec3::dot(plane.n, obb.center); + if (dot + r < plane.d) { + return -1; + } + if (dot - r > plane.d) { + return 0; + } + return 1; +} + +int obbFrustum(const OBB &obb, const Frustum &frustum) { + for (const auto &plane : frustum.planes) { + // frustum plane normal points to the inside + if (obbPlane(obb, *plane) == -1) { + return 0; + } + } // completely outside + return 1; +}; + +// https://cesium.com/blog/2017/02/02/tighter-frustum-culling-and-why-you-may-want-to-disregard-it/ +int obbFrustumAccurate(const OBB &obb, const Frustum &frustum) { + std::array tmp = {}; + float dist = 0.0F; + size_t out1 = 0; + size_t out2 = 0; + auto dot = [](const Vec3 &n, float x, float y, float z) -> float { + return n.x * x + n.y * y + n.z * z; + }; + int result = 0; + auto intersects = false; + // 1. obb inside/outside frustum test + for (const auto &plane : frustum.planes) { + result = obbPlane(obb, *plane); + // frustum plane normal points to the inside + if (result == -1) { + return 0; // completely outside + } + if (result == 1) { + intersects = true; + } + } + if (!intersects) { + return 1; + } // completely inside + // in case of false positives + // 2. frustum inside/outside obb test + for (auto i = 0; i < frustum.vertices.size(); i++) { + tmp[i] = frustum.vertices[i] - obb.center; + } + out1 = 0; + out2 = 0; + for (auto i = 0; i < frustum.vertices.size(); i++) { + dist = dot(tmp[i], obb.orientation.m[0], obb.orientation.m[1], obb.orientation.m[2]); + if (dist > obb.halfExtents.x) { + out1++; + } else if (dist < -obb.halfExtents.x) { + out2++; + } + } + if (out1 == frustum.vertices.size() || out2 == frustum.vertices.size()) { + return 0.0F; + } + out1 = 0; + out2 = 0; + for (auto i = 0; i < frustum.vertices.size(); i++) { + dist = dot(tmp[i], obb.orientation.m[3], obb.orientation.m[4], obb.orientation.m[5]); + if (dist > obb.halfExtents.y) { + out1++; + } else if (dist < -obb.halfExtents.y) { + out2++; + } + } + if (out1 == frustum.vertices.size() || out2 == frustum.vertices.size()) { + return 0; + } + out1 = 0; + out2 = 0; + for (auto i = 0; i < frustum.vertices.size(); i++) { + dist = dot(tmp[i], obb.orientation.m[6], obb.orientation.m[7], obb.orientation.m[8]); + if (dist > obb.halfExtents.z) { + out1++; + } else if (dist < -obb.halfExtents.z) { + out2++; + } + } + if (out1 == frustum.vertices.size() || out2 == frustum.vertices.size()) { + return 0; + } + return 1; +} + +int obbWithOBB(const OBB &obb1, const OBB &obb2) { + std::array vertices; + std::array vertices2; + std::array test; + + test[0] = {obb1.orientation.m[0], obb1.orientation.m[1], obb1.orientation.m[2]}; + test[1] = {obb1.orientation.m[3], obb1.orientation.m[4], obb1.orientation.m[5]}; + test[2] = {obb1.orientation.m[6], obb1.orientation.m[7], obb1.orientation.m[8]}; + test[3] = {obb2.orientation.m[0], obb2.orientation.m[1], obb2.orientation.m[2]}; + test[4] = {obb2.orientation.m[3], obb2.orientation.m[4], obb2.orientation.m[5]}; + test[5] = {obb2.orientation.m[6], obb2.orientation.m[7], obb2.orientation.m[8]}; + + for (auto i = 0; i < 3; ++i) { // Fill out rest of axis + Vec3::cross(test[i], test[3], &test[6 + i * 3 + 0]); + Vec3::cross(test[i], test[4], &test[6 + i * 3 + 1]); + Vec3::cross(test[i], test[5], &test[6 + i * 3 + 2]); + } + + getOBBVertices(obb1.center, obb1.halfExtents, test[0], test[1], test[2], &vertices); + getOBBVertices(obb2.center, obb2.halfExtents, test[3], test[4], test[5], &vertices2); + + for (auto i = 0; i < 15; ++i) { + auto a = getInterval(vertices, test[i]); + auto b = getInterval(vertices2, test[i]); + if (b.min > a.max || a.min > b.max) { + return 0; // Seperating axis found + } + } + return 1; +} + +// https://github.com/diku-dk/bvh-tvcg18/blob/1fd3348c17bc8cf3da0b4ae60fdb8f2aa90a6ff0/FOUNDATION/GEOMETRY/GEOMETRY/include/overlap/geometry_overlap_obb_capsule.h +int obbCapsule(const OBB &obb, const Capsule &capsule) { + Sphere sphere{}; + std::array v3Verts8{}; + std::array v3Axis8{}; + auto h = capsule.ellipseCenter0.distanceSquared(capsule.ellipseCenter1); + if (h == 0.0F) { + sphere.setRadius(capsule.radius); + sphere.setCenter(capsule.ellipseCenter0); + return sphereOBB(sphere, obb); + } + Vec3 v3Tmp0 = { + obb.orientation.m[0], + obb.orientation.m[1], + obb.orientation.m[2]}; + Vec3 v3Tmp1 = { + obb.orientation.m[3], + obb.orientation.m[4], + obb.orientation.m[5]}; + Vec3 v3Tmp2 = { + obb.orientation.m[6], + obb.orientation.m[7], + obb.orientation.m[8]}; + getOBBVertices(obb.center, obb.halfExtents, v3Tmp0, v3Tmp1, v3Tmp2, &v3Verts8); + + auto axes = v3Axis8; + auto a0 = axes[0] = v3Tmp0; + auto a1 = axes[1] = v3Tmp1; + auto a2 = axes[2] = v3Tmp2; + auto cc = axes[3] = capsule.center - obb.center; + auto bb = axes[4] = capsule.ellipseCenter0 - capsule.ellipseCenter1; + cc.normalize(); + bb.normalize(); + Vec3::cross(a0, bb, &axes[5]); + Vec3::cross(a1, bb, &axes[6]); + Vec3::cross(a2, bb, &axes[7]); + + for (auto i = 0; i < 8; ++i) { + auto a = getInterval(v3Verts8, axes[i]); + auto d0 = Vec3::dot(axes[i], capsule.ellipseCenter0); + auto d1 = Vec3::dot(axes[i], capsule.ellipseCenter1); + auto dMin = std::min(d0, d1) - capsule.radius; + auto dMax = std::max(d0, d1) + capsule.radius; + if (dMin > a.max || a.min > dMax) { + return 0; // Seperating axis found + } + } + return 1; +} + +int spherePlane(const Sphere &sphere, const Plane &plane) { + auto dot = Vec3::dot(plane.n, sphere.getCenter()); + auto r = sphere.getRadius() * plane.n.length(); + if (dot + r < plane.d) { + return -1; + } + if (dot - r > plane.d) { + return 0; + } + return 1; +} + +int sphereFrustum(const Sphere &sphere, const Frustum &frustum) { + for (const auto &plane : frustum.planes) { + // frustum plane normal points to the inside + if (spherePlane(sphere, *plane) == -1) { + return 0; + } + } // completely outside + return 1; +} + +int sphereFrustumAccurate(const Sphere &sphere, const Frustum &frustum) { + const static std::array MAP = {1, -1, 1, -1, 1, -1}; + for (auto i = 0; i < 6; i++) { + const auto &plane = frustum.planes[i]; + const auto &n = plane->n; + const auto &d = plane->d; + auto r = sphere.getRadius(); + const auto &c = sphere.getCenter(); + auto dot = Vec3::dot(n, c); + // frustum plane normal points to the inside + if (dot + r < d) { + return 0; // completely outside + } + if (dot - r > d) { + continue; + } + // in case of false positives + // has false negatives, still working on it + auto pt = c + n * r; + for (auto j = 0; j < 6; j++) { + if (j == i || j == i + MAP[i]) { + continue; + } + const auto &test = frustum.planes[j]; + if (Vec3::dot(test->n, pt) < test->d) { + return 0; + } + } + } + return 1; +} + +bool sphereWithSphere(const Sphere &sphere0, const Sphere &sphere1) { + auto r = sphere0.getRadius() + sphere1.getRadius(); + return sphere0.getCenter().distanceSquared(sphere1.getCenter()) < r * r; +} + +bool sphereAABB(const Sphere &sphere, const AABB &aabb) { + Vec3 pt; + ptPointAabb(&pt, sphere.getCenter(), aabb); + return sphere.getCenter().distanceSquared(pt) < sphere.getRadius() * sphere.getRadius(); +} + +bool sphereOBB(const Sphere &sphere, const OBB &obb) { + Vec3 pt; + ptPointObb(&pt, sphere.getCenter(), obb); + return sphere.getCenter().distanceSquared(pt) < sphere.getRadius() * sphere.getRadius(); +} + +bool sphereCapsule(const Sphere &sphere, const Capsule &capsule) { + auto r = sphere.getRadius() + capsule.radius; + auto squaredR = r * r; + auto h = capsule.ellipseCenter0.distanceSquared(capsule.ellipseCenter1); + if (h == 0.0F) { + return sphere.getCenter().distanceSquared(capsule.center) < squaredR; + } + auto v3Tmp0 = sphere.getCenter() - capsule.ellipseCenter0; + auto v3Tmp1 = capsule.ellipseCenter1 - capsule.ellipseCenter0; + auto t = Vec3::dot(v3Tmp0, v3Tmp1) / h; + if (t < 0) { + return sphere.getCenter().distanceSquared(capsule.ellipseCenter0) < squaredR; + } + if (t > 1) { + return sphere.getCenter().distanceSquared(capsule.ellipseCenter1) < squaredR; + } + v3Tmp0 = capsule.ellipseCenter0 + t * v3Tmp1; + return sphere.getCenter().distanceSquared(v3Tmp0) < squaredR; +} + +bool capsuleWithCapsule(const Capsule &capsuleA, const Capsule &capsuleB) { + auto u = capsuleA.ellipseCenter1 - capsuleA.ellipseCenter0; + auto v = capsuleB.ellipseCenter1 - capsuleB.ellipseCenter0; + auto w = capsuleA.ellipseCenter0 - capsuleB.ellipseCenter0; + auto a = Vec3::dot(u, u); // always >= 0 + auto b = Vec3::dot(u, v); + auto c = Vec3::dot(v, v); // always >= 0 + auto d = Vec3::dot(u, w); + auto e = Vec3::dot(v, w); + auto dd = a * c - b * b; // always >= 0 + float sN; + float sD = dd; // sc = sN / sD, default sD = dd >= 0 + float tN; + float tD = dd; // tc = tN / tD, default tD = dd >= 0 + + // compute the line parameters of the two closest points + if (dd < math::EPSILON) { // the lines are almost parallel + sN = 0.0F; // force using point P0 on segment S1 + sD = 1.0F; // to prevent possible division by 0.0 later + tN = e; + tD = c; + } else { // get the closest points on the infinite lines + sN = (b * e - c * d); + tN = (a * e - b * d); + if (sN < 0.0F) { // sc < 0 => the s=0 edge is visible + sN = 0.0F; + tN = e; + tD = c; + } else if (sN > sD) { // sc > 1 => the s=1 edge is visible + sN = sD; + tN = e + b; + tD = c; + } + } + + if (tN < 0.0F) { // tc < 0 => the t=0 edge is visible + tN = 0.0F; + // recompute sc for this edge + if (-d < 0.0F) { + sN = 0.0F; + } else if (-d > a) { + sN = sD; + } else { + sN = -d; + sD = a; + } + } else if (tN > tD) { // tc > 1 => the t=1 edge is visible + tN = tD; + // recompute sc for this edge + if ((-d + b) < 0.0F) { + sN = 0.0F; + } else if ((-d + b) > a) { + sN = sD; + } else { + sN = (-d + b); + sD = a; + } + } + // finally do the division to get sc and tc + auto sc = (std::abs(sN) < math::EPSILON ? 0.0F : sN / sD); + auto tc = (std::abs(tN) < math::EPSILON ? 0.0F : tN / tD); + + // get the difference of the two closest points + auto dP = w; + dP = dP + u * sc; + dP = dP - v * tc; + auto radius = capsuleA.radius + capsuleB.radius; + return dP.lengthSquared() < radius * radius; +} + +int dynObbFrustum(const OBB &obb, const Frustum &frustum) { + if (frustum.getType() == ShapeEnum::SHAPE_FRUSTUM_ACCURATE) { + return obbFrustumAccurate(obb, frustum); + } + return obbFrustum(obb, frustum); +} + +int dynSphereFrustum(const Sphere &sphere, const Frustum &frustum) { + if (frustum.getType() == ShapeEnum::SHAPE_FRUSTUM_ACCURATE) { + return sphereFrustumAccurate(sphere, frustum); + } + return sphereFrustum(sphere, frustum); +} + +int dynAabbFrustum(const AABB &aabb, const Frustum &frustum) { + if (frustum.getType() == ShapeEnum::SHAPE_FRUSTUM_ACCURATE) { + return aabbFrustumAccurate(aabb, frustum); + } + return aabbFrustum(aabb, frustum); +} + +} // namespace geometry +} // namespace cc diff --git a/native/cocos/core/geometry/Intersect.h b/native/cocos/core/geometry/Intersect.h new file mode 100644 index 0000000000..161539cf44 --- /dev/null +++ b/native/cocos/core/geometry/Intersect.h @@ -0,0 +1,465 @@ +#pragma once + +#include "base/Macros.h" + +#include +#include "core/assets/RenderingSubMesh.h" +#include "core/geometry/Distance.h" +#include "core/geometry/Enums.h" +#include "core/geometry/Frustum.h" +#include "core/geometry/Spec.h" + +#include "renderer/gfx-base/GFXDef.h" + +#include + +namespace cc { + +class Vec3; +class Mat3; + +namespace scene { +class Model; +} + +namespace geometry { + +class Ray; +class Plane; +class OBB; +class AABB; +class Line; +class Frustum; +class Sphere; +class Triangle; +class Capsule; + +/** + * @en + * ray-plane intersect detect. + * @zh + * 射线与平面的相交性检测。 + * @param {Ray} ray 射线 + * @param {Plane} plane 平面 + * @return {number} 0 或 非0 + */ +float rayPlane(const Ray &ray, const Plane &plane); + +// based on http://fileadmin.cs.lth.se/cs/Personal/Tomas_Akenine-Moller/raytri/ +/** + * @en + * ray-triangle intersect detect. + * @zh + * 射线与三角形的相交性检测。 + * @param {Ray} ray 射线 + * @param {Triangle} triangle 三角形 + * @param {boolean} doubleSided 三角形是否为双面 + * @return {number} 0 或 非0 + */ +float rayTriangle(const Ray &ray, const Triangle &triangle, bool doubleSided = false); +/** + * @en + * ray-sphere intersect detect. + * @zh + * 射线和球的相交性检测。 + * @param {Ray} ray 射线 + * @param {Sphere} sphere 球 + * @return {number} 0 或 非0 + */ +float raySphere(const Ray &ray, const Sphere &sphere); + +float rayAABB2(const Ray &ray, const Vec3 &min, const Vec3 &max); + +/** + * @en + * ray-aabb intersect detect. + * @zh + * 射线和轴对齐包围盒的相交性检测。 + * @param {Ray} ray 射线 + * @param {AABB} aabb 轴对齐包围盒 + * @return {number} 0 或 非0 + */ +float rayAABB(const Ray &ray, const AABB &aabb); + +/** + * @en + * ray-obb intersect detect. + * @zh + * 射线和方向包围盒的相交性检测。 + * @param {Ray} ray 射线 + * @param {OBB} obb 方向包围盒 + * @return {number} 0 或 非0 + */ +float rayOBB(const Ray &ray, const OBB &obb); + +/** + * @en + * ray-capsule intersect detect. + * @zh + * 射线和胶囊体的相交性检测。 + * @param {Ray} ray 射线 + * @param {Capsule} capsule 胶囊体 + * @return {number} 0 或 非0 + */ +float rayCapsule(const Ray &ray, const Capsule &capsule); + +/** + * @en + * ray-subMesh intersect detect, in model space. + * @zh + * 在模型空间中,射线和子三角网格的相交性检测。 + * @param {Ray} ray + * @param {RenderingSubMesh} subMesh + * @param {IRaySubMeshOptions} options + * @return {number} 0 or !0 + */ +float raySubMesh(const Ray &ray, const RenderingSubMesh &submesh, IRaySubMeshOptions *options = nullptr); + +/** + * @en + * ray-mesh intersect detect, in model space. + * @zh + * 在模型空间中,射线和三角网格资源的相交性检测。 + * @param {Ray} ray + * @param {Mesh} mesh + * @param {IRayMeshOptions} options + * @return {number} 0 or !0 + */ +float rayMesh(const Ray &ray, const Mesh &mesh, IRayMeshOptions *option); + +/** + * @en + * ray-model intersect detect, in world space. + * @zh + * 在世界空间中,射线和渲染模型的相交性检测。 + * @param ray + * @param model + * @param options + * @return 0 or !0 + */ +float rayModel(const Ray &ray, const scene::Model &model, IRayModelOptions *option); + +/** + * @en + * line-plane intersect detect. + * @zh + * 线段与平面的相交性检测。 + * @param {line} line 线段 + * @param {Plane} plane 平面 + * @return {number} 0 或 非0 + */ +float linePlane(const Line &line, const Plane &plane); +/** + * @en + * line-triangle intersect detect. + * @zh + * 线段与三角形的相交性检测。 + * @param {line} line 线段 + * @param {Triangle} triangle 三角形 + * @param {Vec3} outPt 可选,相交点 + * @return {number} 0 或 非0 + */ +int lineTriangle(const Line &line, const Triangle &triangle, Vec3 *outPt = nullptr); + +/** + * @en + * line-aabb intersect detect. + * @zh + * 线段与轴对齐包围盒的相交性检测 + * @param line 线段 + * @param aabb 轴对齐包围盒 + * @return {number} 0 或 非0 + */ +float lineAABB(const Line &line, const AABB &aabb); + +/** + * @en + * line-obb intersect detect. + * @zh + * 线段与方向包围盒的相交性检测 + * @param line 线段 + * @param obb 方向包围盒 + * @return {number} 0 或 非0 + */ +float lineOBB(const Line &line, const OBB &obb); + +/** + * @en + * line-sphere intersect detect. + * @zh + * 线段与球的相交性检测 + * @param line 线段 + * @param sphere 球 + * @return {number} 0 或 非0 + */ +float lineSphere(const Line &line, const Sphere &sphere); + +/** + * @en + * aabb-aabb intersect detect. + * @zh + * 轴对齐包围盒和轴对齐包围盒的相交性检测。 + * @param {AABB} aabb1 轴对齐包围盒1 + * @param {AABB} aabb2 轴对齐包围盒2 + * @return {number} 0 或 非0 + */ +bool aabbWithAABB(const AABB &aabb1, const AABB &aabb2); + +/** + * @en + * aabb-obb intersect detect. + * @zh + * 轴对齐包围盒和方向包围盒的相交性检测。 + * @param {AABB} aabb 轴对齐包围盒 + * @param {OBB} obb 方向包围盒 + * @return {number} 0 或 非0 + */ +int aabbWithOBB(const AABB &aabb, const OBB &obb); + +/** + * @en + * aabb-plane intersect detect. + * @zh + * 轴对齐包围盒和平面的相交性检测。 + * @param {AABB} aabb 轴对齐包围盒 + * @param {Plane} plane 平面 + * @return {number} inside(back) = -1, outside(front) = 0, intersect = 1 + */ +int aabbPlane(const AABB &aabb, const Plane &plane); +/** + * @en + * aabb-frustum intersect detect, faster but has false positive corner cases. + * @zh + * 轴对齐包围盒和锥台相交性检测,速度快,但有错误情况。 + * @param {AABB} aabb 轴对齐包围盒 + * @param {Frustum} frustum 锥台 + * @return {number} 0 或 非0 + */ +int aabbFrustum(const AABB &aabb, const Frustum &frustum); + +// https://cesium.com/blog/2017/02/02/tighter-frustum-culling-and-why-you-may-want-to-disregard-it/ +/** + * @en + * aabb-frustum intersect, handles most of the false positives correctly. + * @zh + * 轴对齐包围盒和锥台相交性检测,正确处理大多数错误情况。 + * @param {AABB} aabb 轴对齐包围盒 + * @param {Frustum} frustum 锥台 + * @return {number} + */ +int aabbFrustumAccurate(const AABB &aabb, const Frustum &frustum); + +/** + * @en + * obb contains the point. + * @zh + * 方向包围盒和点的相交性检测。 + * @param {OBB} obb 方向包围盒 + * @param {Vec3} point 点 + * @return {boolean} true or false + */ +bool obbPoint(const OBB &obb, const Vec3 &point); + +/** + * @en + * obb-plane intersect detect. + * @zh + * 方向包围盒和平面的相交性检测。 + * @param {OBB} obb 方向包围盒 + * @param {Plane} plane 平面 + * @return {number} inside(back) = -1, outside(front) = 0, intersect = 1 + */ +int obbPlane(const OBB &obb, const Plane &plane); + +/** + * @en + * obb-frustum intersect, faster but has false positive corner cases. + * @zh + * 方向包围盒和锥台相交性检测,速度快,但有错误情况。 + * @param {OBB} obb 方向包围盒 + * @param {Frustum} frustum 锥台 + * @return {number} 0 或 非0 + */ +int obbFrustum(const OBB &obb, const Frustum &frustum); + +// https://cesium.com/blog/2017/02/02/tighter-frustum-culling-and-why-you-may-want-to-disregard-it/ +/** + * @en + * obb-frustum intersect, handles most of the false positives correctly. + * @zh + * 方向包围盒和锥台相交性检测,正确处理大多数错误情况。 + * @param {OBB} obb 方向包围盒 + * @param {Frustum} frustum 锥台 + * @return {number} 0 或 非0 + */ +int obbFrustumAccurate(const OBB &obb, const Frustum &frustum); + +/** + * @en + * obb-obb intersect detect. + * @zh + * 方向包围盒和方向包围盒的相交性检测。 + * @param {OBB} obb1 方向包围盒1 + * @param {OBB} obb2 方向包围盒2 + * @return {number} 0 或 非0 + */ +int obbWithOBB(const OBB &obb1, const OBB &obb2); + +// https://github.com/diku-dk/bvh-tvcg18/blob/1fd3348c17bc8cf3da0b4ae60fdb8f2aa90a6ff0/FOUNDATION/GEOMETRY/GEOMETRY/include/overlap/geometry_overlap_obb_capsule.h +/** + * @en + * obb-capsule intersect detect. + * @zh + * 方向包围盒和胶囊体的相交性检测。 + * @param obb 方向包围盒 + * @param capsule 胶囊体 + */ +int obbCapsule(const OBB &obb, const Capsule &capsule); + +/** + * @en + * sphere-plane intersect, not necessarily faster than obb-plane,due to the length calculation of the + * plane normal to factor out the unnomalized plane distance. + * @zh + * 球与平面的相交性检测。 + * @param {Sphere} sphere 球 + * @param {Plane} plane 平面 + * @return {number} inside(back) = -1, outside(front) = 0, intersect = 1 + */ +int spherePlane(const Sphere &sphere, const Plane &plane); +/** + * @en + * sphere-frustum intersect, faster but has false positive corner cases. + * @zh + * 球和锥台的相交性检测,速度快,但有错误情况。 + * @param {Sphere} sphere 球 + * @param {Frustum} frustum 锥台 + * @return {number} 0 或 非0 + */ +int sphereFrustum(const Sphere &sphere, const Frustum &frustum); + +// https://stackoverflow.com/questions/20912692/view-frustum-culling-corner-cases +/** + * @en + * sphere-frustum intersect, handles the false positives correctly. + * @zh + * 球和锥台的相交性检测,正确处理大多数错误情况。 + * @param {Sphere} sphere 球 + * @param {Frustum} frustum 锥台 + * @return {number} 0 或 非0 + */ +int sphereFrustumAccurate(const Sphere &sphere, const Frustum &frustum); + +/** + * @en + * sphere-sphere intersect detect. + * @zh + * 球和球的相交性检测。 + * @param {Sphere} sphere0 球0 + * @param {Sphere} sphere1 球1 + * @return {boolean} true or false + */ +bool sphereWithSphere(const Sphere &sphere0, const Sphere &sphere1); +/** + * @en + * sphere-aabb intersect detect. + * @zh + * 球和轴对齐包围盒的相交性检测。 + * @param {Sphere} sphere 球 + * @param {AABB} aabb 轴对齐包围盒 + * @return {boolean} true or false + */ +bool sphereAABB(const Sphere &sphere, const AABB &aabb); + +/** + * @en + * sphere-obb intersect detect. + * @zh + * 球和方向包围盒的相交性检测。 + * @param {Sphere} sphere 球 + * @param {OBB} obb 方向包围盒 + * @return {boolean} true or false + */ +bool sphereOBB(const Sphere &sphere, const OBB &obb); + +/** + * @en + * sphere-capsule intersect detect. + * @zh + * 球和胶囊体的相交性检测。 + */ +bool sphereCapsule(const Sphere &sphere, const Capsule &capsule); + +// http://www.geomalgorithms.com/a07-_distance.html +/** + * @en + * capsule-capsule intersect detect. + * @zh + * 胶囊体和胶囊体的相交性检测。 + */ +bool capsuleWithCapsule(const Capsule &capsuleA, const Capsule &capsuleB); + +template +auto intersects(const T1 & /*a*/, const T2 & /*b*/) { + static_assert(std::is_base_of::value, "type is not base of ShapeBase"); + static_assert(std::is_base_of::value, "type is not base of ShapeBase"); + assert(false); // mismatch +} + +#define DECLARE_EXCHANGABLE_INTERSECT(TYPE1, TYPE2, FN) \ + template <> \ + inline auto intersects(const TYPE1 &arg1, const TYPE2 &arg2) { \ + return FN(arg1, arg2); \ + } \ + template <> \ + inline auto intersects(const TYPE2 &arg2, const TYPE1 &arg1) { \ + return FN(arg1, arg2); \ + } + +#define DECLARE_SELF_INTERSECT(TYPE, FN) \ + template <> \ + inline auto intersects(const TYPE &arg1, const TYPE &arg2) { \ + return FN(arg1, arg2); \ + } + +int dynObbFrustum(const OBB &obb, const Frustum &frustum); +int dynSphereFrustum(const Sphere &sphere, const Frustum &frustum); +int dynAabbFrustum(const AABB &aabb, const Frustum &frustum); + +DECLARE_EXCHANGABLE_INTERSECT(Ray, Sphere, raySphere) +DECLARE_EXCHANGABLE_INTERSECT(Ray, AABB, rayAABB) +DECLARE_EXCHANGABLE_INTERSECT(Ray, OBB, rayOBB) +DECLARE_EXCHANGABLE_INTERSECT(Ray, Plane, rayPlane) +DECLARE_EXCHANGABLE_INTERSECT(Ray, Triangle, rayTriangle) +DECLARE_EXCHANGABLE_INTERSECT(Ray, Capsule, rayCapsule) + +DECLARE_EXCHANGABLE_INTERSECT(Line, Sphere, lineSphere) +DECLARE_EXCHANGABLE_INTERSECT(Line, AABB, lineAABB) +DECLARE_EXCHANGABLE_INTERSECT(Line, OBB, lineOBB) +DECLARE_EXCHANGABLE_INTERSECT(Line, Plane, linePlane) +DECLARE_EXCHANGABLE_INTERSECT(Line, Triangle, lineTriangle) + +DECLARE_SELF_INTERSECT(Sphere, sphereWithSphere) +DECLARE_EXCHANGABLE_INTERSECT(Sphere, AABB, sphereAABB) +DECLARE_EXCHANGABLE_INTERSECT(Sphere, OBB, sphereOBB) +DECLARE_EXCHANGABLE_INTERSECT(Sphere, Plane, spherePlane) +DECLARE_EXCHANGABLE_INTERSECT(Sphere, Frustum, dynSphereFrustum) +DECLARE_EXCHANGABLE_INTERSECT(Sphere, Capsule, sphereCapsule) + +DECLARE_SELF_INTERSECT(AABB, aabbWithAABB) +DECLARE_EXCHANGABLE_INTERSECT(AABB, OBB, aabbWithOBB) +DECLARE_EXCHANGABLE_INTERSECT(AABB, Plane, aabbPlane) +DECLARE_EXCHANGABLE_INTERSECT(AABB, Frustum, dynAabbFrustum) + +DECLARE_SELF_INTERSECT(OBB, obbWithOBB) +DECLARE_EXCHANGABLE_INTERSECT(OBB, Plane, obbPlane) +DECLARE_EXCHANGABLE_INTERSECT(OBB, Frustum, dynObbFrustum) +DECLARE_EXCHANGABLE_INTERSECT(OBB, Capsule, obbCapsule) + +DECLARE_SELF_INTERSECT(Capsule, capsuleWithCapsule) + +#undef DECLARE_SELF_INTERSECT +#undef DECLARE_EXCHANGABLE_INTERSECT + +} // namespace geometry +} // namespace cc \ No newline at end of file diff --git a/native/cocos/core/geometry/Line.cpp b/native/cocos/core/geometry/Line.cpp new file mode 100644 index 0000000000..ed5dad90ba --- /dev/null +++ b/native/cocos/core/geometry/Line.cpp @@ -0,0 +1,57 @@ +#include "core/geometry/Line.h" + +namespace cc { +namespace geometry { + +Line *Line::create(float sx, + float sy, + float sz, + float ex, + float ey, + float ez) { + return new Line(sx, sy, sz, ex, ey, ez); +} + +Line *Line::clone(const Line &a) { + return new Line( + a.s.x, a.s.y, a.s.z, + a.e.x, a.e.y, a.e.z); +} + +Line *Line::copy(Line *out, const Line &a) { + out->s = a.s; + out->e = a.e; + return out; +} + +Line *Line::fromPoints(Line *out, const Vec3 &start, const Vec3 &end) { + out->s = start; + out->e = end; + return out; +} + +Line *Line::set(Line *out, + float sx, + float sy, + float sz, + float ex, + float ey, + float ez) { + out->s.x = sx; + out->s.y = sy; + out->s.z = sz; + out->e.x = ex; + out->e.y = ey; + out->e.z = ez; + + return out; +} + +Line::Line(float sx, float sy, float sz, float ex, float ey, float ez) { + setType(ShapeEnum::SHAPE_LINE); + s = {sx, sy, sz}; + e = {ex, ey, ez}; +} + +} // namespace geometry +} // namespace cc \ No newline at end of file diff --git a/native/cocos/core/geometry/Line.h b/native/cocos/core/geometry/Line.h new file mode 100644 index 0000000000..f4c5317e8e --- /dev/null +++ b/native/cocos/core/geometry/Line.h @@ -0,0 +1,147 @@ +#pragma once + +#include "core/geometry/Enums.h" +#include "math/Vec3.h" +namespace cc { +namespace geometry { + +/** + * @en + * Basic Geometry: Line. + * @zh + * 基础几何 line。 + */ + +class Line final : public ShapeBase { +public: + /** + * @en + * create a new line + * @zh + * 创建一个新的 line。 + * @param sx 起点的 x 部分。 + * @param sy 起点的 y 部分。 + * @param sz 起点的 z 部分。 + * @param ex 终点的 x 部分。 + * @param ey 终点的 y 部分。 + * @param ez 终点的 z 部分。 + * @return + */ + + static Line *create(float sx, + float sy, + float sz, + float ex, + float ey, + float ez); + + /** + * @en + * Creates a new Line initialized with values from an existing Line + * @zh + * 克隆一个新的 line。 + * @param a 克隆的来源。 + * @return 克隆出的对象。 + */ + + static Line *clone(const Line &a); + + /** + * @en + * Copy the values from one Line to another + * @zh + * 复制一个线的值到另一个。 + * @param out 接受操作的对象。 + * @param a 复制的来源。 + * @return 接受操作的对象。 + */ + static Line *copy(Line *out, const Line &a); + + /** + * @en + * create a line from two points + * @zh + * 用两个点创建一个线。 + * @param out 接受操作的对象。 + * @param start 起点。 + * @param end 终点。 + * @return out 接受操作的对象。 + */ + + static Line *fromPoints(Line *out, const Vec3 &start, const Vec3 &end); + + /** + * @en + * Set the components of a Vec3 to the given values + * @zh + * 将给定线的属性设置为给定值。 + * @param out 接受操作的对象。 + * @param sx 起点的 x 部分。 + * @param sy 起点的 y 部分。 + * @param sz 起点的 z 部分。 + * @param ex 终点的 x 部分。 + * @param ey 终点的 y 部分。 + * @param ez 终点的 z 部分。 + * @return out 接受操作的对象。 + */ + static Line *set(Line *out, + float sx, + float sy, + float sz, + float ex, + float ey, + float ez); + + /** + * @zh + * 计算线的长度。 + * @param a 要计算的线。 + * @return 长度。 + */ + static inline float len(const Line &a) { + return a.s.distance(a.e); + } + + /** + * @zh + * 起点。 + */ + Vec3 s; + + /** + * @zh + * 终点。 + */ + Vec3 e; + + /** + * 构造一条线。 + * @param sx 起点的 x 部分。 + * @param sy 起点的 y 部分。 + * @param sz 起点的 z 部分。 + * @param ex 终点的 x 部分。 + * @param ey 终点的 y 部分。 + * @param ez 终点的 z 部分。 + */ + explicit Line(float sx = 0, float sy = 0, float sz = 0, float ex = 0, float ey = 0, float ez = -1); + + Line(const Line &) = default; + Line &operator=(const Line &) = default; + Line &operator=(Line &&) = default; + Line(Line &&) = default; + ~Line() override = default; + + /** + * @zh + * 计算线的长度。 + * @param a 要计算的线。 + * @return 长度。 + */ + + inline float length() const { + return s.distance(e); + } +}; + +} // namespace geometry +} // namespace cc \ No newline at end of file diff --git a/native/cocos/core/geometry/Obb.cpp b/native/cocos/core/geometry/Obb.cpp new file mode 100644 index 0000000000..ca5c275287 --- /dev/null +++ b/native/cocos/core/geometry/Obb.cpp @@ -0,0 +1,104 @@ +#include "cocos/core/geometry/Obb.h" + +namespace { +void transformExtentM3(cc::Vec3 *out, const cc::Vec3 &extent, const cc::Mat3 &m3) { + cc::Mat3 m3Tmp; + m3Tmp.m[0] = abs(m3.m[0]); + m3Tmp.m[1] = abs(m3.m[1]); + m3Tmp.m[2] = abs(m3.m[2]); + m3Tmp.m[3] = abs(m3.m[3]); + m3Tmp.m[4] = abs(m3.m[4]); + m3Tmp.m[5] = abs(m3.m[5]); + m3Tmp.m[6] = abs(m3.m[6]); + m3Tmp.m[7] = abs(m3.m[7]); + m3Tmp.m[8] = abs(m3.m[8]); + out->transformMat3(extent, m3Tmp); +}; +} // namespace + +namespace cc { +namespace geometry { + +OBB *OBB::create( + float cx, float cy, float cz, + float hw, float hh, float hl, + float ox1, float ox2, float ox3, + float oy1, float oy2, float oy3, + float oz1, float oz2, float oz3) { + return new OBB(cx, cy, cz, hw, hh, hl, + ox1, ox2, ox3, + oy1, oy2, oy3, + oz1, oz2, oz3); +} + +OBB *OBB::clone(const OBB &a) { + return new OBB(a.center.x, a.center.y, a.center.z, + a.halfExtents.x, a.halfExtents.y, a.halfExtents.z, + a.orientation.m[0], a.orientation.m[1], a.orientation.m[2], + a.orientation.m[3], a.orientation.m[4], a.orientation.m[5], + a.orientation.m[6], a.orientation.m[7], a.orientation.m[8]); +} + +OBB *OBB::copy(OBB *out, const OBB &a) { + out->center = a.center; + out->halfExtents = a.halfExtents; + out->orientation = a.orientation; + return out; +} + +OBB *OBB::fromPoints(OBB *out, const Vec3 &minPos, const Vec3 &maxPos) { + out->center = 0.5F * (minPos + maxPos); + out->halfExtents = 0.5F * (maxPos - minPos); + Mat3::identity(out->orientation); + return out; +} + +OBB *OBB::set(OBB * out, + float cx, float cy, float cz, + float hw, float hh, float hl, + float ox1, float ox2, float ox3, + float oy1, float oy2, float oy3, + float oz1, float oz2, float oz3) { + out->center = {cx, cy, cz}; + out->halfExtents = {hw, hh, hl}; + out->orientation = {ox1, ox2, ox3, oy1, oy2, oy3, oz1, oz2, oz3}; + return out; +} + +OBB::OBB(float cx, float cy, float cz, + float hw, float hh, float hl, + float ox1, float ox2, float ox3, + float oy1, float oy2, float oy3, + float oz1, float oz2, float oz3) { + setType(ShapeEnum::SHAPE_OBB); + center = {cx, cy, cz}; + halfExtents = {hw, hh, hl}; + orientation = {ox1, ox2, ox3, oy1, oy2, oy3, oz1, oz2, oz3}; +} + +void OBB::getBoundary(Vec3 *minPos, Vec3 *maxPos) const { + Vec3 v3Tmp; + transformExtentM3(&v3Tmp, halfExtents, orientation); + *minPos = center - v3Tmp; + *maxPos = center + v3Tmp; +} + +void OBB::transform(const Mat4 &m, const Vec3 & /*pos*/, const Quaternion &rot, const Vec3 &scale, OBB *out) const { + Vec3::transformMat4(center, m, &out->center); + // parent shape doesn't contain rotations for now + Mat3::fromQuat(rot, &out->orientation); + Vec3::multiply(halfExtents, scale, &out->halfExtents); +} + +void OBB::translateAndRotate(const Mat4 &m, const Quaternion &rot, OBB *out) const { + Vec3::transformMat4(center, m, &out->center); + // parent shape doesn't contain rotations for now + Mat3::fromQuat(rot, &out->orientation); +} + +void OBB::setScale(const Vec3 &scale, OBB *out) const { + Vec3::multiply(halfExtents, scale, &out->halfExtents); +} + +} // namespace geometry +} // namespace cc \ No newline at end of file diff --git a/native/cocos/core/geometry/Obb.h b/native/cocos/core/geometry/Obb.h new file mode 100644 index 0000000000..84002a5093 --- /dev/null +++ b/native/cocos/core/geometry/Obb.h @@ -0,0 +1,168 @@ +#pragma once + +#include "cocos/core/geometry/Enums.h" +#include "cocos/math/Mat3.h" +#include "cocos/math/Quaternion.h" +#include "cocos/math/Vec3.h" + +namespace cc { +namespace geometry { +class OBB final : public ShapeBase { +public: + /** + * @en + * create a new obb + * @zh + * 创建一个新的 obb 实例。 + * @param cx 形状的相对于原点的 X 坐标。 + * @param cy 形状的相对于原点的 Y 坐标。 + * @param cz 形状的相对于原点的 Z 坐标。 + * @param hw - obb 宽度的一半。 + * @param hh - obb 高度的一半。 + * @param hl - obb 长度的一半。 + * @param ox1 方向矩阵参数。 + * @param ox2 方向矩阵参数。 + * @param ox3 方向矩阵参数。 + * @param oy1 方向矩阵参数。 + * @param oy2 方向矩阵参数。 + * @param oy3 方向矩阵参数。 + * @param oz1 方向矩阵参数。 + * @param oz2 方向矩阵参数。 + * @param oz3 方向矩阵参数。 + * @return 返回一个 obb。 + */ + static OBB *create( + float cx, float cy, float cz, + float hw, float hh, float hl, + float ox1, float ox2, float ox3, + float oy1, float oy2, float oy3, + float oz1, float oz2, float oz3); + + /** + * @en + * clone a new obb + * @zh + * 克隆一个 obb。 + * @param a 克隆的目标。 + * @returns 克隆出的新对象。 + */ + static OBB *clone(const OBB &a); + /** + * @en + * copy the values from one obb to another + * @zh + * 将从一个 obb 的值复制到另一个 obb。 + * @param {OBB} out 接受操作的 obb。 + * @param {OBB} a 被复制的 obb。 + * @return {OBB} out 接受操作的 obb。 + */ + static OBB *copy(OBB *out, const OBB &a); + + /** + * @en + * create a new obb from two corner points + * @zh + * 用两个点创建一个新的 obb。 + * @param out - 接受操作的 obb。 + * @param minPos - obb 的最小点。 + * @param maxPos - obb 的最大点。 + * @returns {OBB} out 接受操作的 obb。 + */ + static OBB *fromPoints(OBB *out, const Vec3 &minPos, const Vec3 &maxPos); + + /** + * @en + * Set the components of a obb to the given values + * @zh + * 将给定 obb 的属性设置为给定的值。 + * @param cx - obb 的原点的 X 坐标。 + * @param cy - obb 的原点的 Y 坐标。 + * @param cz - obb 的原点的 Z 坐标。 + * @param hw - obb 宽度的一半。 + * @param hh - obb 高度的一半。 + * @param hl - obb 长度的一半。 + * @param ox1 方向矩阵参数。 + * @param ox2 方向矩阵参数。 + * @param ox3 方向矩阵参数。 + * @param oy1 方向矩阵参数。 + * @param oy2 方向矩阵参数。 + * @param oy3 方向矩阵参数。 + * @param oz1 方向矩阵参数。 + * @param oz2 方向矩阵参数。 + * @param oz3 方向矩阵参数。 + * @return {OBB} out + */ + + static OBB *set(OBB * out, + float cx, float cy, float cz, + float hw, float hh, float hl, + float ox1, float ox2, float ox3, + float oy1, float oy2, float oy3, + float oz1, float oz2, float oz3); + + /** + * @zh + * 本地坐标的中心点。 + */ + Vec3 center; + + /** + * @zh + * 长宽高的一半。 + */ + Vec3 halfExtents; + + /** + * @zh + * 方向矩阵。 + */ + + Mat3 orientation; + + explicit OBB(float cx = 0, float cy = 0, float cz = 0, + float hw = 1, float hh = 1, float hl = 1, + float ox1 = 1, float ox2 = 0, float ox3 = 0, + float oy1 = 0, float oy2 = 1, float oy3 = 0, + float oz1 = 0, float oz2 = 0, float oz3 = 1); + + /** + * @en + * Get the bounding points of this shape + * @zh + * 获取 obb 的最小点和最大点。 + * @param {Vec3} minPos 最小点。 + * @param {Vec3} maxPos 最大点。 + */ + void getBoundary(Vec3 *minPos, Vec3 *maxPos) const; + /** + * Transform this shape + * @zh + * 将 out 根据这个 obb 的数据进行变换。 + * @param m 变换的矩阵。 + * @param pos 变换的位置部分。 + * @param rot 变换的旋转部分。 + * @param scale 变换的缩放部分。 + * @param out 变换的目标。 + */ + void transform(const Mat4 &m, const Vec3 &pos, const Quaternion &rot, const Vec3 &scale, OBB *out) const; + + /** + * @zh + * 将 out 根据这个 obb 的数据进行变换。 + * @param m 变换的矩阵。 + * @param rot 变换的旋转部分。 + * @param out 变换的目标。 + */ + void translateAndRotate(const Mat4 &m, const Quaternion &rot, OBB *out) const; + + /** + * @zh + * 将 out 根据这个 obb 的数据进行缩放。 + * @param scale 缩放值。 + * @param out 缩放的目标。 + */ + void setScale(const Vec3 &scale, OBB *out) const; +}; + +} // namespace geometry +} // namespace cc \ No newline at end of file diff --git a/native/cocos/core/geometry/Plane.cpp b/native/cocos/core/geometry/Plane.cpp new file mode 100644 index 0000000000..5d1c242ca0 --- /dev/null +++ b/native/cocos/core/geometry/Plane.cpp @@ -0,0 +1,94 @@ +#include "cocos/core/geometry/Plane.h" + +namespace cc { +namespace geometry { +Plane *Plane::create(float nx, float ny, float nz, float d) { + return new Plane{nx, ny, nz, d}; +} + +Plane *Plane::clone(const Plane &p) { + return new Plane{p.n.x, p.n.y, p.n.z, p.d}; +} + +Plane *Plane::copy(Plane *out, const Plane &p) { + out->n = p.n; + out->d = p.d; + return out; +} + +Plane *Plane::fromPoints(Plane * out, + const Vec3 &a, + const Vec3 &b, + const Vec3 &c) { + Vec3::cross(b - a, c - a, &out->n); + out->n.normalize(); + out->d = Vec3::dot(out->n, a); + return out; +} + +Plane *Plane::fromNormalAndPoint(Plane *out, const Vec3 &normal, const Vec3 &point) { + out->n = normal; + out->d = Vec3::dot(normal, point); + return out; +} + +Plane *Plane::normalize(Plane *out, const Plane &a) { + const auto len = a.n.length(); + out->n = a.n.getNormalized(); + if (len > 0) { + out->d = a.d / len; + } + return out; +} + +Plane *Plane::set(Plane *out, float nx, float ny, float nz, float d) { + out->n = {nx, ny, nz}; + out->d = d; + return out; +} + +Plane::Plane(float nx, float ny, float nz, float d) { + setType(ShapeEnum::SHAPE_PLANE); + n = {nx, ny, nz}; + this->d = d; +} + +void Plane::transform(const Mat4 &mat) { + Mat4 tempMat = mat.getInversed(); + tempMat.transpose(); + Vec4 tempVec4 = {n.x, n.y, n.z, d}; + tempMat.transformVector(&tempVec4); + n.set(tempVec4.x, tempVec4.y, tempVec4.z); + d = tempVec4.w; +} + +// Define from 3 vertices. +void Plane::define(const Vec3 &v0, const Vec3 &v1, const Vec3 &v2) { + const Vec3 dist1 = v1 - v0; + const Vec3 dist2 = v2 - v0; + + Vec3 dist; + Vec3::crossProduct(dist1, dist2, &dist); + define(dist, v0); +} +// Define from a normal vector and a point on the plane. +void Plane::define(const Vec3 &normal, const Vec3 &point) { + n = normal.getNormalized(); + d = n.dot(point); +} + +// Return signed distance to a point. +float Plane::distance(const Vec3 &point) const { + return n.dot(point) - d; +} + +Plane Plane::clone() const { + Plane plane; + plane.n.set(n); + plane.d = d; + + return plane; +} + +} // namespace geometry +} // namespace cc \ No newline at end of file diff --git a/native/cocos/core/geometry/Plane.h b/native/cocos/core/geometry/Plane.h new file mode 100644 index 0000000000..465b584d55 --- /dev/null +++ b/native/cocos/core/geometry/Plane.h @@ -0,0 +1,167 @@ +#pragma once + +#include "cocos/core/geometry/Enums.h" +#include "cocos/math/Mat4.h" +#include "cocos/math/Vec3.h" +#include "cocos/math/Vec4.h" + +namespace cc { +namespace geometry { +/** + * @en + * Basic Geometry: Plane. + * @zh + * 基础几何 Plane。 + */ +class Plane final : public ShapeBase { + /** + * @en + * create a new plane + * @zh + * 创建一个新的 plane。 + * @param nx 法向分量的 x 部分。 + * @param ny 法向分量的 y 部分。 + * @param nz 法向分量的 z 部分。 + * @param d 与原点的距离。 + * @return + */ +public: + static Plane *create(float nx, float ny, float nz, float d); + + /** + * @en + * clone a new plane + * @zh + * 克隆一个新的 plane。 + * @param p 克隆的来源。 + * @return 克隆出的对象。 + */ + static Plane *clone(const Plane &p); + + /** + * @en + * copy the values from one plane to another + * @zh + * 复制一个平面的值到另一个。 + * @param out 接受操作的对象。 + * @param p 复制的来源。 + * @return 接受操作的对象。 + */ + + static Plane *copy(Plane *out, const Plane &p); + + /** + * @en + * create a plane from three points + * @zh + * 用三个点创建一个平面。 + * @param out 接受操作的对象。 + * @param a 点 a。 + * @param b 点 b。 + * @param c 点 c。 + * @return out 接受操作的对象。 + */ + static Plane *fromPoints(Plane * out, + const Vec3 &a, + const Vec3 &b, + const Vec3 &c); + + /** + * @en + * Set the components of a plane to the given values + * @zh + * 将给定平面的属性设置为给定值。 + * @param out 接受操作的对象。 + * @param nx 法向分量的 x 部分。 + * @param ny 法向分量的 y 部分。 + * @param nz 法向分量的 z 部分。 + * @param d 与原点的距离。 + * @return out 接受操作的对象。 + */ + static Plane *set(Plane *out, float nx, float ny, float nz, float d); + + /** + * @en + * create plane from normal and point + * @zh + * 用一条法线和一个点创建平面。 + * @param out 接受操作的对象。 + * @param normal 平面的法线。 + * @param point 平面上的一点。 + * @return out 接受操作的对象。 + */ + static Plane *fromNormalAndPoint(Plane *out, const Vec3 &normal, const Vec3 &point); + + /** + * @en + * normalize a plane + * @zh + * 归一化一个平面。 + * @param out 接受操作的对象。 + * @param a 操作的源数据。 + * @return out 接受操作的对象。 + */ + static Plane *normalize(Plane *out, const Plane &a); + + // compatibility with vector interfaces + inline void setX(float val) { n.x = val; } + inline float getX() const { return n.x; } + inline void setY(float val) { n.y = val; } + inline float getY() const { return n.y; } + inline void setZ(float val) { n.z = val; } + inline float getZ() const { return n.z; } + inline void setW(float val) { d = val; } + inline float getW() const { return d; } + + /** + * @en + * Construct a plane. + * @zh + * 构造一个平面。 + * @param nx 法向分量的 x 部分。 + * @param ny 法向分量的 y 部分。 + * @param nz 法向分量的 z 部分。 + * @param d 与原点的距离。 + */ + explicit Plane(float nx, float ny, float nz, float d); + + Plane() = default; + // Plane(const Plane& other) = default; + // Plane(Plane&& other) = default; + // Plane& operator=(const Plane& other) = default; + // Plane& operator=(Plane&& other) = default; + // ~Plane() = default; + + /** + * @en + * transform this plane. + * @zh + * 变换一个平面。 + * @param mat + */ + void transform(const Mat4 &mat); + + /** + * @en + * The normal of the plane. + * @zh + * 法线向量。 + */ + Vec3 n{0.0F, 1.0F, 0.0F}; + + /** + * @en + * The distance from the origin to the plane. + * @zh + * 原点到平面的距离。 + */ + float d{0.0F}; + + void define(const Vec3 &v0, const Vec3 &v1, const Vec3 &v2); + void define(const Vec3 &normal, const Vec3 &point); + float distance(const Vec3 &point) const; + Plane clone() const; +}; + +} // namespace geometry +} // namespace cc diff --git a/native/cocos/core/geometry/Ray.cpp b/native/cocos/core/geometry/Ray.cpp new file mode 100644 index 0000000000..ab361b7556 --- /dev/null +++ b/native/cocos/core/geometry/Ray.cpp @@ -0,0 +1,52 @@ +#include "core/geometry/Ray.h" + +namespace cc { +namespace geometry { +Ray *Ray::create(float ox, float oy, float oz, float dx, float dy, float dz) { + return new Ray{ox, oy, oz, dx, dy, dz}; +} + +Ray *Ray::clone(const Ray &a) { + return new Ray{ + a.o.x, a.o.y, a.o.z, + a.d.x, a.d.y, a.d.z}; +} + +Ray *Ray::copy(Ray *out, const Ray &a) { + out->o = a.o; + out->d = a.d; + return out; +} + +Ray *Ray::fromPoints(Ray *out, const Vec3 &origin, const Vec3 &target) { + out->o = origin; + out->d = (target - origin).getNormalized(); + return out; +} + +Ray *Ray::set(Ray *out, float ox, float oy, + float oz, + float dx, + float dy, + float dz) { + out->o.x = ox; + out->o.y = oy; + out->o.z = oz; + out->d.x = dx; + out->d.y = dy; + out->d.z = dz; + return out; +} + +Ray::Ray(float ox, float oy, float oz, + float dx, float dy, float dz) { + setType(ShapeEnum::SHAPE_RAY); + o = {ox, oy, oz}; + d = {dx, dy, dz}; +} + +void Ray::computeHit(Vec3 *out, float distance) const { + *out = o + d.getNormalized() * distance; +} +} // namespace geometry +} // namespace cc \ No newline at end of file diff --git a/native/cocos/core/geometry/Ray.h b/native/cocos/core/geometry/Ray.h new file mode 100644 index 0000000000..372be21a31 --- /dev/null +++ b/native/cocos/core/geometry/Ray.h @@ -0,0 +1,136 @@ +#pragma once + +#include "core/geometry/Enums.h" +#include "math/Vec3.h" + +namespace cc { +namespace geometry { + +/** + * @en + * Basic Geometry: ray. + * @zh + * 基础几何 射线。 + */ + +class Ray final : public ShapeBase { +public: + /** + * @en + * create a new ray + * @zh + * 创建一条射线。 + * @param {number} ox 起点的 x 部分。 + * @param {number} oy 起点的 y 部分。 + * @param {number} oz 起点的 z 部分。 + * @param {number} dx 方向的 x 部分。 + * @param {number} dy 方向的 y 部分。 + * @param {number} dz 方向的 z 部分。 + * @return {Ray} 射线。 + */ + static Ray *create(float ox = 0, float oy = 0, float oz = 0, float dx = 0, float dy = 0, float dz = 1); + + /** + * @en + * Creates a new ray initialized with values from an existing ray + * @zh + * 从一条射线克隆出一条新的射线。 + * @param {Ray} a 克隆的目标。 + * @return {Ray} 克隆出的新对象。 + */ + static Ray *clone(const Ray &a); + /** + * @en + * Copy the values from one ray to another + * @zh + * 将从一个 ray 的值复制到另一个 ray。 + * @param {Ray} out 接受操作的 ray。 + * @param {Ray} a 被复制的 ray。 + * @return {Ray} out 接受操作的 ray。 + */ + static Ray *copy(Ray *out, const Ray &a); + + /** + * @en + * create a ray from two points + * @zh + * 用两个点创建一条射线。 + * @param {Ray} out 接受操作的射线。 + * @param {Vec3} origin 射线的起点。 + * @param {Vec3} target 射线上的一点。 + * @return {Ray} out 接受操作的射线。 + */ + static Ray *fromPoints(Ray *out, const Vec3 &origin, const Vec3 &target); + + /** + * @en + * Set the components of a ray to the given values + * @zh + * 将给定射线的属性设置为给定的值。 + * @param {Ray} out 接受操作的射线。 + * @param {number} ox 起点的 x 部分。 + * @param {number} oy 起点的 y 部分。 + * @param {number} oz 起点的 z 部分。 + * @param {number} dx 方向的 x 部分。 + * @param {number} dy 方向的 y 部分。 + * @param {number} dz 方向的 z 部分。 + * @return {Ray} out 接受操作的射线。 + */ + + static Ray *set(Ray *out, float ox, float oy, + float oz, + float dx, + float dy, + float dz); + + /** + * @en + * The origin of the ray. + * @zh + * 起点。 + */ + Vec3 o; + + /** + * @en + * The direction of the ray. + * @zh + * 方向。 + */ + Vec3 d; + + /** + * @en + * Construct a ray; + * @zh + * 构造一条射线。 + * @param {number} ox 起点的 x 部分。 + * @param {number} oy 起点的 y 部分。 + * @param {number} oz 起点的 z 部分。 + * @param {number} dx 方向的 x 部分。 + * @param {number} dy 方向的 y 部分。 + * @param {number} dz 方向的 z 部分。 + */ + explicit Ray(float ox = 0, float oy = 0, float oz = 0, + float dx = 0, float dy = 0, float dz = -1); + + Ray(const Ray &) = default; + Ray &operator=(const Ray &) = default; + Ray &operator=(Ray &&) = default; + Ray(Ray &&) = default; + ~Ray() override = default; + + /** + * @en + * Compute a point with the distance between the origin. + * @zh + * 根据给定距离计算出射线上的一点。 + * @param out 射线上的另一点。 + * @param distance 给定距离。 + */ + + void computeHit(Vec3 *out, float distance) const; +}; + +} // namespace geometry +} // namespace cc \ No newline at end of file diff --git a/native/cocos/core/geometry/Spec.cpp b/native/cocos/core/geometry/Spec.cpp new file mode 100644 index 0000000000..e69de29bb2 diff --git a/native/cocos/core/geometry/Spec.h b/native/cocos/core/geometry/Spec.h new file mode 100644 index 0000000000..b8c81980f7 --- /dev/null +++ b/native/cocos/core/geometry/Spec.h @@ -0,0 +1,149 @@ +#pragma once + +#include +#include +#include +#include "base/Optional.h" + +namespace cc { +namespace geometry { + +/** + * @en + * The raycast mode. + * @zh + * 射线检测模式。 + */ +enum class ERaycastMode { + + /** + * @en + * Detect and record all data. + * @zh + * 检测并记录所有的数据。 + */ + ALL, + + /** + * @en + * Detect all, but record only the most recent data. + * @zh + * 检测所有,但只记录最近的数据。 + */ + CLOSEST, + + /** + * @en + * Once the test is successful, the test is stopped and the data is recorded only once. + * @zh + * 一旦检测成功就停止检测,只会记录一次数据。 + */ + ANY, +}; + +/** + * @en + * The storage structure of the raycast results. + * @zh + * 射线检测结果的存储结构。 + */ +struct IRaySubMeshResult { + /** + * @en + * The distance between the hit point and the ray. + * @zh + * 击中点和射线的距离。 + */ + float distance{0.0F}; + + /** + * @en + * The index of the triangle vertex 0。 + * @zh + * 三角形顶点0的索引。 + */ + uint32_t vertexIndex0{0}; + + /** + * @en + * The index of the triangle vertex 1。 + * @zh + * 三角形顶点1的索引 + */ + uint32_t vertexIndex1{0}; + + /** + * @en + * The index of the triangle vertex 2。 + * @zh + * 三角形顶点2的索引 + */ + uint32_t vertexIndex2{0}; +}; + +/** + * @en + * The optional param structure of the `raySubMesh`. + * @zh + * `raySubMesh`的可选参数结构。 + */ +struct IRaySubMeshOptions { + /** + * @en + * The raycast mode,`ANY` by default. + * @zh + * 射线检测模式:[0, 1, 2]=>[`ALL`, `CLOSEST`, `ANY`] + */ + ERaycastMode mode; + + /** + * @en + * The maximum distance of the raycast, `Infinity` by default. + * @zh + * 射线检测的最大距离,默认为`Infinity`。 + */ + float distance = FLT_MAX; + + /** + * @en + * An array used to store the results of a ray detection. + * @zh + * 用于存储射线检测结果的数组。 + */ + cc::optional> result{}; + + /** + * @en + * Whether to detect the double-sided or not,`false` by default. + * @zh + * 是否检测双面,默认为`false`。 + */ + bool doubleSided{false}; +}; + +/** + * @en + * The optional param structure of the `rayMesh`. + * @zh + * `rayMesh`的可选参数结构。 + */ +struct IRayMeshOptions : public IRaySubMeshOptions { + /** + * @en + * The index of the sub mesh. + * @zh + * 子网格的索引。 + */ + cc::optional> subIndices{}; +}; + +/** + * @en + * The optional param structure of the `rayModel`. + * @zh + * `rayModel`的可选参数结构。 + */ +using IRayModelOptions = IRayMeshOptions; + +} // namespace geometry +} // namespace cc \ No newline at end of file diff --git a/native/cocos/scene/Sphere.cpp b/native/cocos/core/geometry/Sphere.cpp similarity index 52% rename from native/cocos/scene/Sphere.cpp rename to native/cocos/core/geometry/Sphere.cpp index fd70a75f73..8c3d970316 100644 --- a/native/cocos/scene/Sphere.cpp +++ b/native/cocos/core/geometry/Sphere.cpp @@ -23,12 +23,100 @@ THE SOFTWARE. ****************************************************************************/ -#include "scene/Sphere.h" +#include "core/geometry/Sphere.h" #include -#include "base/TypeDef.h" +#include "core/geometry/AABB.h" +#include "math/Vec3.h" namespace cc { -namespace scene { +namespace geometry { + +Sphere *Sphere::create(float cx, float cy, float cz, float radius) { + return new Sphere(cx, cy, cz, radius); +} + +Sphere *Sphere::clone(const Sphere &p) { + return new Sphere(p._center.x, p._center.y, p._center.z, p._radius); +} + +Sphere *Sphere::copy(Sphere *out, const Sphere &p) { + out->_center = p._center; + out->_radius = p._radius; + return out; +} + +Sphere *Sphere::fromPoints(Sphere *out, const Vec3 &minPos, const Vec3 &maxPos) { + out->_center = 0.5F * (minPos + maxPos); + out->_radius = 0.5F * (maxPos - minPos).length(); + return out; +} + +Sphere *Sphere::set(Sphere *out, float cx, float cy, float cz, float r) { + out->_center = {cx, cy, cz}; + out->_radius = r; + return out; +} + +Sphere *Sphere::mergePoint(Sphere *out, const Sphere &s, const Vec3 &point) { + // if sphere.radius Less than 0, + // Set this point as anchor, + // And set radius to 0. + if (s._radius < 0.0) { + out->_center = point; + out->_radius = 0.0F; + return out; + } + + auto offset = point - s._center; + auto dist = offset.length(); + + if (dist > s._radius) { + auto half = (dist - s._radius) * 0.5F; + out->_radius += half; + offset.scale(half / dist); + out->_center = out->_center + offset; + } + + return out; +} + +void Sphere::merge(const std::vector &points) { + if (points.empty()) return; + _radius = -1.0F; + for (const auto &p : points) { + merge(p); + } +} + +Sphere *Sphere::mergeAABB(Sphere *out, const Sphere &s, const AABB &a) { + Vec3 aabbMin; + Vec3 aabbMax; + a.getBoundary(&aabbMin, &aabbMax); + Sphere::mergePoint(out, s, aabbMin); + Sphere::mergePoint(out, s, aabbMax); + return out; +} + +Sphere::Sphere(float cx, float cy, float cz, float radius) { + setType(ShapeEnum::SHAPE_SPHERE); + _center = {cx, cy, cz}; + _radius = radius; +} + +void Sphere::getBoundary(Vec3 *minPos, Vec3 *maxPos) const { + Vec3 half = {_radius, _radius, _radius}; + *minPos = _center - half; + *maxPos = _center + half; +} + +void Sphere::transform(const Mat4 &m, + const Vec3 & /*pos*/, + const Quaternion & /*rot*/, + const Vec3 &scale, + Sphere * out) const { + Vec3::transformMat4(_center, m, &out->_center); + out->_radius = _radius * mathutils::maxComponent(scale); +} int Sphere::interset(const Plane &plane) const { const float dot = plane.n.dot(_center); @@ -50,20 +138,21 @@ bool Sphere::interset(const Frustum &frustum) const { return std::all_of(planes.begin(), planes.end(), // frustum plane normal points to the inside - [self](const Plane &plane) { return self->interset(plane) != -1; }); + [self](const Plane *plane) { return self->interset(*plane) != -1; }); } -void Sphere::merge(const Vec3 &point) { +void Sphere::mergePoint(const Vec3 &point) { if (_radius < 0.0F) { _center = point; _radius = 0.0F; return; } - Vec3 offset = point - _center; - const float distance = offset.length(); + auto offset = point - _center; + auto distance = offset.length(); + if (distance > _radius) { - const float half = (distance - _radius) * 0.5F; + auto half = (distance - _radius) * 0.5F; _radius += half; offset.scale(half / distance); _center += offset; @@ -88,12 +177,12 @@ void Sphere::define(const AABB &aabb) { _center += (half / dist) * offset; } -void Sphere::merge(const AABB *aabb) { +void Sphere::mergeAABB(const AABB *aabb) { cc::Vec3 minPos; cc::Vec3 maxPos; aabb->getBoundary(&minPos, &maxPos); - merge(minPos); - merge(maxPos); + mergePoint(minPos); + mergePoint(maxPos); } int Sphere::spherePlane(const Plane &plane) { @@ -114,15 +203,15 @@ bool Sphere::sphereFrustum(const Frustum &frustum) const { return std::all_of(planes.begin(), planes.end(), // frustum plane normal points to the inside - [self](const Plane &plane) { return self->interset(plane) != -1; }); + [self](const Plane *plane) { return self->interset(*plane) != -1; }); } -void Sphere::merge(const Frustum &frustum) { +void Sphere::mergeFrustum(const Frustum &frustum) { const std::array &vertices = frustum.vertices; - for (uint i = 0; i < vertices.max_size(); ++i) { + for (size_t i = 0; i < vertices.max_size(); ++i) { merge(vertices[i]); } } -} // namespace scene +} // namespace geometry } // namespace cc diff --git a/native/cocos/core/geometry/Sphere.h b/native/cocos/core/geometry/Sphere.h new file mode 100644 index 0000000000..a38ee17b05 --- /dev/null +++ b/native/cocos/core/geometry/Sphere.h @@ -0,0 +1,202 @@ +/**************************************************************************** + 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 "core/geometry/Enums.h" +#include "core/geometry/Frustum.h" +#include "math/Utils.h" +#include "math/Vec3.h" + +namespace cc { +namespace geometry { + +class AABB; + +class Sphere final : public ShapeBase { +public: + /** + * @en + * create a new sphere + * @zh + * 创建一个新的 sphere 实例。 + * @param cx 形状的相对于原点的 X 坐标。 + * @param cy 形状的相对于原点的 Y 坐标。 + * @param cz 形状的相对于原点的 Z 坐标。 + * @param r 球体的半径 + * @return {Sphere} 返回一个 sphere。 + */ + static Sphere *create(float cx, float cy, float cz, float radius); + + /** + * @en + * clone a new sphere + * @zh + * 克隆一个新的 sphere 实例。 + * @param {Sphere} p 克隆的目标。 + * @return {Sphere} 克隆出的示例。 + */ + static Sphere *clone(const Sphere &p); + /** + * @en + * copy the values from one sphere to another + * @zh + * 将从一个 sphere 的值复制到另一个 sphere。 + * @param {Sphere} out 接受操作的 sphere。 + * @param {Sphere} a 被复制的 sphere。 + * @return {Sphere} out 接受操作的 sphere。 + */ + static Sphere *copy(Sphere *out, const Sphere &p); + + /** + * @en + * create a new bounding sphere from two corner points + * @zh + * 从两个点创建一个新的 sphere。 + * @param out - 接受操作的 sphere。 + * @param minPos - sphere 的最小点。 + * @param maxPos - sphere 的最大点。 + * @returns {Sphere} out 接受操作的 sphere。 + */ + static Sphere *fromPoints(Sphere *out, const Vec3 &minPos, const Vec3 &maxPos); + + /** + * @en + * Set the components of a sphere to the given values + * @zh + * 将球体的属性设置为给定的值。 + * @param {Sphere} out 接受操作的 sphere。 + * @param cx 形状的相对于原点的 X 坐标。 + * @param cy 形状的相对于原点的 Y 坐标。 + * @param cz 形状的相对于原点的 Z 坐标。 + * @param {number} r 半径。 + * @return {Sphere} out 接受操作的 sphere。 + * @function + */ + static Sphere *set(Sphere *out, float cx, float cy, float cz, float r); + /** + * @zh + * 球跟点合并 + */ + static Sphere *mergePoint(Sphere *out, const Sphere &s, const Vec3 &point); + + /** + * @zh + * 球跟立方体合并 + */ + static Sphere *mergeAABB(Sphere *out, const Sphere &s, const AABB &a); + explicit Sphere(float cx = 0, float cy = 0, float cz = 0, float radius = 1.0F); + + Sphere(const Sphere &) = delete; + Sphere(Sphere &&) = delete; + ~Sphere() override = default; + Sphere &operator=(const Sphere &) = delete; + Sphere &operator=(Sphere &&) = delete; + + inline float getRadius() const { return _radius; } + inline const Vec3 &getCenter() const { return _center; } + inline void setCenter(const Vec3 &val) { _center = val; } + inline void setRadius(float val) { _radius = val; } + + inline Sphere *clone() const { + return Sphere::clone(*this); + } + + inline Sphere *copy(Sphere *out) const { + return Sphere::copy(out, *this); + } + + void define(const AABB &aabb); + void mergeAABB(const AABB *aabb); + void mergePoint(const Vec3 &point); + void mergeFrustum(const Frustum &frustum); + inline void merge(const AABB *aabb) { mergeAABB(aabb); } + inline void merge(const Vec3 &point) { mergePoint(point); } + void merge(const std::vector &points); + inline void merge(const Frustum &frustum) { mergeFrustum(frustum); } + bool interset(const Frustum &frustum) const; + int interset(const Plane &plane) const; + int spherePlane(const Plane &plane); + bool sphereFrustum(const Frustum &frustum) const; + + /** + * @en + * Get the bounding points of this shape + * @zh + * 获取此形状的边界点。 + * @param {Vec3} minPos 最小点。 + * @param {Vec3} maxPos 最大点。 + */ + void getBoundary(Vec3 *minPos, Vec3 *maxPos) const; + + /** + * @en + * Transform this shape + * @zh + * 将 out 根据这个 sphere 的数据进行变换。 + * @param m 变换的矩阵。 + * @param pos 变换的位置部分。 + * @param rot 变换的旋转部分。 + * @param scale 变换的缩放部分。 + * @param out 变换的目标。 + */ + void transform(const Mat4 &m, + const Vec3 & /*pos*/, + const Quaternion & /*rot*/, + const Vec3 &scale, + Sphere * out) const; + + /** + * @en + * Translate and rotate this sphere. + * @zh + * 将 out 根据这个 sphere 的数据进行变换。 + * @param m 变换的矩阵。 + * @param rot 变换的旋转部分。 + * @param out 变换的目标。 + */ + inline void translateAndRotate(const Mat4 &m, const Quaternion & /*rot*/, Sphere *out) const { + Vec3::transformMat4(_center, m, &out->_center); + } + + /** + * @en + * Scaling this sphere. + * @zh + * 将 out 根据这个 sphere 的数据进行缩放。 + * @param scale 缩放值。 + * @param out 缩放的目标。 + */ + inline void setScale(const Vec3 &scale, Sphere *out) const { + out->_radius = _radius * mathutils::maxComponent(scale); + } + +private: + float _radius{-1.0}; + Vec3 _center; +}; + +} // namespace geometry +} // namespace cc diff --git a/native/cocos/core/geometry/Triangle.cpp b/native/cocos/core/geometry/Triangle.cpp new file mode 100644 index 0000000000..40a3012073 --- /dev/null +++ b/native/cocos/core/geometry/Triangle.cpp @@ -0,0 +1,63 @@ +#include "core/geometry/Triangle.h" + +namespace cc { +namespace geometry { + +Triangle *Triangle::create(float ax, float ay, float az, + float bx, float by, float bz, + float cx, float cy, float cz) { + return new Triangle(ax, ay, az, bx, by, bz, cx, cy, cz); +} + +auto Triangle::clone(const Triangle &t) -> Triangle * { + return new Triangle( + t.a.x, t.a.y, t.a.z, + t.b.x, t.b.y, t.b.z, + t.c.x, t.c.y, t.c.z); +} + +auto Triangle::copy(Triangle *out, const Triangle &t) -> Triangle * { + out->a = t.a; + out->b = t.b; + out->c = t.c; + return out; +} + +auto Triangle::fromPoints(Triangle *out, const Vec3 &a, + const Vec3 &b, + const Vec3 &c) -> Triangle * { + out->a = a; + out->b = b; + out->c = c; + return out; +} + +auto Triangle::set(Triangle *out, + float ax, float ay, float az, + float bx, float by, float bz, + float cx, float cy, float cz) -> Triangle * { + out->a.x = ax; + out->a.y = ay; + out->a.z = az; + + out->b.x = bx; + out->b.y = by; + out->b.z = bz; + + out->c.x = cx; + out->c.y = cy; + out->c.z = cz; + + return out; +} + +Triangle::Triangle(float ax, float ay, float az, + float bx, float by, float bz, + float cx, float cy, float cz) { + setType(ShapeEnum::SHAPE_TRIANGLE); + a = {ax, ay, az}; + b = {bx, by, bz}; + c = {cx, cy, cz}; +} +} // namespace geometry +} // namespace cc \ No newline at end of file diff --git a/native/cocos/core/geometry/Triangle.h b/native/cocos/core/geometry/Triangle.h new file mode 100644 index 0000000000..20180d52ad --- /dev/null +++ b/native/cocos/core/geometry/Triangle.h @@ -0,0 +1,151 @@ +#pragma once +#include "core/geometry/Enums.h" + +#include "math/Vec3.h" + +namespace cc { +namespace geometry { + +/** + * @en + * Basic Geometry: Triangle. + * @zh + * 基础几何 三角形。 + */ + +class Triangle final : public ShapeBase { +public: + /** + * @en + * create a new triangle + * @zh + * 创建一个新的 triangle。 + * @param {number} ax a 点的 x 部分。 + * @param {number} ay a 点的 y 部分。 + * @param {number} az a 点的 z 部分。 + * @param {number} bx b 点的 x 部分。 + * @param {number} by b 点的 y 部分。 + * @param {number} bz b 点的 z 部分。 + * @param {number} cx c 点的 x 部分。 + * @param {number} cy c 点的 y 部分。 + * @param {number} cz c 点的 z 部分。 + * @return {Triangle} 一个新的 triangle。 + */ + static Triangle *create(float ax = 1, float ay = 0, float az = 0, + float bx = 0, float by = 0, float bz = 0, + float cx = 0, float cy = 0, float cz = 1); + + /** + * @en + * clone a new triangle + * @zh + * 克隆一个新的 triangle。 + * @param {Triangle} t 克隆的目标。 + * @return {Triangle} 克隆出的新对象。 + */ + + static auto clone(const Triangle &t) -> Triangle *; + + /** + * @en + * copy the values from one triangle to another + * @zh + * 将一个 triangle 的值复制到另一个 triangle。 + * @param {Triangle} out 接受操作的 triangle。 + * @param {Triangle} t 被复制的 triangle。 + * @return {Triangle} out 接受操作的 triangle。 + */ + + static auto copy(Triangle *out, const Triangle &t) -> Triangle *; + + /** + * @en + * Create a triangle from three points + * @zh + * 用三个点创建一个 triangle。 + * @param {Triangle} out 接受操作的 triangle。 + * @param {Vec3} a a 点。 + * @param {Vec3} b b 点。 + * @param {Vec3} c c 点。 + * @return {Triangle} out 接受操作的 triangle。 + */ + static auto fromPoints(Triangle *out, const Vec3 &a, + const Vec3 &b, + const Vec3 &c) -> Triangle *; + + /** + * @en + * Set the components of a triangle to the given values + * @zh + * 将给定三角形的属性设置为给定值。 + * @param {Triangle} out 给定的三角形。 + * @param {number} ax a 点的 x 部分。 + * @param {number} ay a 点的 y 部分。 + * @param {number} az a 点的 z 部分。 + * @param {number} bx b 点的 x 部分。 + * @param {number} by b 点的 y 部分。 + * @param {number} bz b 点的 z 部分。 + * @param {number} cx c 点的 x 部分。 + * @param {number} cy c 点的 y 部分。 + * @param {number} cz c 点的 z 部分。 + * @return {Triangle} + * @function + */ + static auto set(Triangle *out, + float ax, float ay, float az, + float bx, float by, float bz, + float cx, float cy, float cz) -> Triangle *; + + /** + * @en + * Point a. + * @zh + * 点 a。 + */ + + Vec3 a; + + /** + * @en + * Point b. + * @zh + * 点 b。 + */ + Vec3 b; + + /** + * @en + * Point c. + * @zh + * 点 c。 + */ + Vec3 c; + /** + * @en + * Construct a triangle. + * @zh + * 构造一个三角形。 + * @param {number} ax a 点的 x 部分。 + * @param {number} ay a 点的 y 部分。 + * @param {number} az a 点的 z 部分。 + * @param {number} bx b 点的 x 部分。 + * @param {number} by b 点的 y 部分。 + * @param {number} bz b 点的 z 部分。 + * @param {number} cx c 点的 x 部分。 + * @param {number} cy c 点的 y 部分。 + * @param {number} cz c 点的 z 部分。 + */ + explicit Triangle(float ax = 0, float ay = 0, float az = 0, + float bx = 1, float by = 0, float bz = 0, + float cx = 0, float cy = 1, float cz = 0); + + Triangle(const Triangle &) = default; + Triangle(Triangle &&) = default; + ~Triangle() override = default; + Triangle &operator=(const Triangle &) = default; + Triangle &operator=(Triangle &&) = default; + +}; // namespace geometry + +} // namespace geometry +} // namespace cc \ No newline at end of file diff --git a/native/cocos/scene/BaseNode.cpp b/native/cocos/core/memop/CachedArray.cpp similarity index 80% rename from native/cocos/scene/BaseNode.cpp rename to native/cocos/core/memop/CachedArray.cpp index bead4ea801..ba8b7abd2d 100644 --- a/native/cocos/scene/BaseNode.cpp +++ b/native/cocos/core/memop/CachedArray.cpp @@ -23,21 +23,8 @@ THE SOFTWARE. ****************************************************************************/ -#include "scene/BaseNode.h" +#include "core/memop/CachedArray.h" namespace cc { -namespace scene { -void BaseNode::setParent(BaseNode *parent) { - if (_parent == parent) { - return; - } - if (_parent != nullptr) { - _parent->removeChild(this); - } - _parent = parent; - if (_parent) { - _parent->addChild(this); - } + } -} // namespace scene -} // namespace cc diff --git a/native/cocos/core/memop/CachedArray.h b/native/cocos/core/memop/CachedArray.h new file mode 100644 index 0000000000..8689f99dfd --- /dev/null +++ b/native/cocos/core/memop/CachedArray.h @@ -0,0 +1,192 @@ +/**************************************************************************** + 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 +#include +#include +#include + +namespace cc { + +/** + * @en + * Cached array is a data structure for objects cache, it's designed for persistent data. + * Its content array length will keep grow. + * @zh + * 适用于对象缓存的数组类型封装,一般用于不易被移除的常驻数据。 + * 它的内部数组长度会持续增长,不会减少。 + */ +template +class CachedArray final { +public: + using CompareFn = std::function; + + explicit CachedArray(uint32_t length) { + _array.reverse(length); + } + + /** + * @param length Initial length + * @param compareFn Comparison function for sorting + */ + CachedArray(uint32_t length, const CompareFn &compareFn) { + _array.reverse(length); + _compareFn = compareFn; + } + + CachedArray(const CachedArray &) = delete; + CachedArray(CachedArray &&) = delete; + CachedArray &operator=(const CachedArray &) = delete; + CachedArray &operator=(CachedArray &&) = delete; + + /** + * @en + * Push an element to the end of the array + * @zh + * 向数组末尾添加一个元素 + * @param item The item to be added + */ + void push(T *item) { + if (_length < _array.capacity()) { + _array[_length++] = item; + } + } + + /** + * @en + * Pop the last element in the array. The [[length]] will reduce, but the internal array will keep its size. + * @zh + * 弹出数组最后一个元素,CachedArray 的 [[length]] 会减少,但是内部数组的实际长度不变 + * @return The last element. + */ + T *pop() { + if (_length == 0) { + return nullptr; + } + return _array[_length--]; + } + + /** + * @en + * Get the element at the specified index of the array + * @zh + * 得到数组中指定位置的元素 + * @param idx The index of the requested element + * @return The element at given index + */ + T *get(uint32_t idx) const { + if (idx < _length) { + return _array[idx]; + } + return nullptr; + } + + /** + * @en + * Clear the cache. The [[length]] will be set to 0, but the internal array will keep its size. + * @zh + * 清空数组所有元素。[[length]] 会被设为 0,但内部数组的实际长度不变 + */ + void clear() { + _length = 0; + } + + /** + * @en + * Clear the cache. The [[length]] will be set to 0, and clear the internal array. + * @zh + * 清空数组所有元素。[[length]] 会被设为 0,并且清空内部数组 + */ + void destroy() { + _length = 0; + _array.clear(); + } + + /** + * @en + * Sort the existing elements in cache + * @zh + * 排序所有现有元素 + */ + void sort() { + if (_compareFn) { + std::sort(_array.begin(), _array.begin() + _length, _compareFn); + } else { + std::sort(_array.begin(), _array.begin() + _length); + } + } + + /** + * @en + * Add all elements of a given array to the end of the current array + * @zh + * 添加一个指定数组中的所有元素到当前数组末尾 + * @param array The given array to be appended + */ + void concat(const std::vector &array) { + size_t freeSize = _array.capacity() - _length; + size_t elementsToConcat = std::min(freeSize, array.size()); + _array.insert(_array.begin() + _length, array.begin(), array.begin() + elementsToConcat); + _length += elementsToConcat; + } + + /** + * @en Delete the element at the specified location and move the last element to that location. + * @zh 删除指定位置的元素并将最后一个元素移动至该位置。 + * @param idx The index of the element to be deleted + */ + void fastRemove(uint32_t idx) { + if (idx >= _length) { + return; + } + + const uint32_t last = --_length; + _array[idx] = _array[last]; + } + + /** + * @en Returns the first index at which a given element can be found in the array. + * @zh 返回在数组中可以找到一个给定元素的第一个索引。 + * @param val The element + */ + int32_t indexOf(T *val) { + auto it = std::find(_array.begin(), _array.begin() + _length, val); + if (it != _array.end()) { + return it - _array.begin(); + } + + return -1; + } + + std::vector _array; + uint32_t _length{0}; + +private: + CompareFn _compareFn{nullptr}; +}; + +} // namespace cc diff --git a/native/cocos/scene/Scene.cpp b/native/cocos/core/memop/Pool.cpp similarity index 97% rename from native/cocos/scene/Scene.cpp rename to native/cocos/core/memop/Pool.cpp index d2eae55041..4d1ac959c2 100644 --- a/native/cocos/scene/Scene.cpp +++ b/native/cocos/core/memop/Pool.cpp @@ -23,8 +23,8 @@ THE SOFTWARE. ****************************************************************************/ +#include "core/memop/Pool.h" + namespace cc { -namespace scene { } -} // namespace cc diff --git a/native/cocos/core/memop/Pool.h b/native/cocos/core/memop/Pool.h new file mode 100644 index 0000000000..0f5ef55454 --- /dev/null +++ b/native/cocos/core/memop/Pool.h @@ -0,0 +1,127 @@ +/**************************************************************************** + 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 +#include +#include +#include +#include "base/TypeDef.h" + +namespace cc { + +namespace memop { + +template +class Pool final { +public: + /** + * @en Constructor with the allocator of elements and initial pool size + * @zh 使用元素的构造器和初始大小的构造函数 + * @param ctor The allocator of elements in pool, it's invoked directly without `new` + * @param elementsPerBatch Initial pool size, this size will also be the incremental size when the pool is overloaded + */ + Pool(const std::function &ctor, uint32_t elementsPerBatch) + : _ctor(ctor), + _elementsPerBatch(std::max(elementsPerBatch, static_cast(1))) { + _nextAvail = static_cast(_elementsPerBatch - 1); + + for (uint32_t i = 0; i < _elementsPerBatch; ++i) { + _freepool.push_back(ctor()); + } + } + + Pool(const Pool &) = delete; + Pool(Pool &&) = delete; + ~Pool() = default; + Pool &operator=(const Pool &) = delete; + Pool &operator=(Pool &&) = delete; + + /** + * @en Take an object out of the object pool. + * @zh 从对象池中取出一个对象。 + * @return An object ready for use. This function always return an object. + */ + T *alloc() { + if (_nextAvail < 0) { + _freepool.resize(_elementsPerBatch); + for (uint32_t i = 0; i < _elementsPerBatch; ++i) { + _freepool[i] = _ctor(); + } + _nextAvail = static_cast(_elementsPerBatch - 1); + } + + return _freepool[_nextAvail--]; + } + + /** + * @en Put an object back into the object pool. + * @zh 将一个对象放回对象池中。 + * @param obj The object to be put back into the pool + */ + void free(T *obj) { + _freepool[++_nextAvail] = obj; + } + + /** + * @en Put multiple objects back into the object pool. + * @zh 将一组对象放回对象池中。 + * @param objs An array of objects to be put back into the pool + */ + void freeArray(const std::vector &objs) { + _freepool.reserve(_nextAvail + 1 + objs.size()); + _freepool.insert(_freepool.begin() + _nextAvail + 1, + objs.begin(), objs.end()); + _nextAvail += static_cast(objs.size()); + } + + /** + * @en Destroy all elements and clear the pool. + * @zh 释放对象池中所有资源并清空缓存池。 + * @param dtor The destructor function, it will be invoked for all elements in the pool + */ + void destroy(const std::function &dtor) { + for (int i = 0; i < _nextAvail; ++i) { + dtor(_freepool[i]); + } + destroy(); + } + + void destroy() { + _nextAvail = -1; + _freepool.clear(); + } + +private: + std::function _ctor{nullptr}; + uint32_t _elementsPerBatch{0}; + index_t _nextAvail{-1}; + std::vector _freepool; +}; + +} // namespace memop + +} // namespace cc diff --git a/native/cocos/core/memop/RecyclePool.cpp b/native/cocos/core/memop/RecyclePool.cpp new file mode 100644 index 0000000000..ad811bcd6a --- /dev/null +++ b/native/cocos/core/memop/RecyclePool.cpp @@ -0,0 +1,30 @@ +/**************************************************************************** + 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/memop/RecyclePool.h" + +namespace cc { + +} diff --git a/native/cocos/core/memop/RecyclePool.h b/native/cocos/core/memop/RecyclePool.h new file mode 100644 index 0000000000..0f5476c4e2 --- /dev/null +++ b/native/cocos/core/memop/RecyclePool.h @@ -0,0 +1,106 @@ +/**************************************************************************** + 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 +#include +#include + +namespace cc { + +/** + * @en Recyclable object pool. It's designed to be entirely reused each time. + * There is no put and get method, each time you get the [[data]], you can use all elements as new. + * You shouldn't simultaneously use the same RecyclePool in more than two overlapped logic. + * Its size can be automatically incremented or manually resized. + * @zh 循环对象池。这种池子被设计为每次使用都完整复用。 + * 它没有回收和提取的函数,通过获取 [[data]] 可以获取池子中所有元素,全部都应该被当做新对象来使用。 + * 开发者不应该在相互交叉的不同逻辑中同时使用同一个循环对象池。 + * 池子尺寸可以在池子满时自动扩充,也可以手动调整。 + * @see [[Pool]] + */ +template +class RecyclePool final { +public: + /** + * @en Constructor with the allocator of elements and initial pool size, all elements will be pre-allocated. + * @zh 使用元素的构造器和初始大小的构造函数,所有元素都会被预创建。 + * @param fn The allocator of elements in pool, it's invoked directly without `new` + * @param size Initial pool size + */ + RecyclePool(const std::function &fn, uint32_t size); + + RecyclePool(const RecyclePool &) = delete; + RecyclePool(RecyclePool &&) = delete; + ~RecyclePool() = default; + RecyclePool &operator=(const RecyclePool &) = delete; + RecyclePool &operator=(RecyclePool &&) = delete; + + /** + * @en The length of the object pool. + * @zh 对象池大小。 + */ + inline uint32_t getLength() const { return _count; } + + /** + * @en The underlying array of all pool elements. + * @zh 实际对象池数组。 + */ + inline const std::vector &getData() const { return _data; } + + /** + * @en Resets the object pool. Only changes the length to 0 + * @zh 清空对象池。目前仅仅会设置尺寸为 0 + */ + inline void reset() { _count = 0; } + + /** + * @en Resize the object poo, and fills with new created elements. + * @zh 设置对象池大小,并填充新的元素。 + * @param size The new size of the pool + */ + void resize(uint32_t size); + + /** + * @en Expand the object pool, the size will be increment to current size times two, and fills with new created elements. + * @zh 扩充对象池容量,会自动扩充尺寸到两倍,并填充新的元素。 + * @param idx + */ + void add(); + + /** + * @en Remove an element of the object pool. This will also decrease size of the pool + * @zh 移除对象池中的一个元素,同时会减小池子尺寸。 + * @param idx The index of the element to be removed + */ + void removeAt(uint32_t idx); + +private: + uint32_t _count{0}; + std::vector _data; +}; + +} // namespace cc diff --git a/native/cocos/core/platform/Debug.cpp b/native/cocos/core/platform/Debug.cpp new file mode 100644 index 0000000000..0037f604b9 --- /dev/null +++ b/native/cocos/core/platform/Debug.cpp @@ -0,0 +1,28 @@ +/**************************************************************************** + 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. +****************************************************************************/ + +namespace cc { + +} //namespace cc \ No newline at end of file diff --git a/native/cocos/core/platform/Debug.h b/native/cocos/core/platform/Debug.h new file mode 100644 index 0000000000..bff3fdebf6 --- /dev/null +++ b/native/cocos/core/platform/Debug.h @@ -0,0 +1,188 @@ +/**************************************************************************** + 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 +#include "cocos/base/Any.h" + +namespace cc { +namespace debug { + +const std::string ERROR_MAP_URL{"https://github.com/cocos-creator/engine/blob/3d/EngineErrorMap.md"}; + +enum class DebugMode { + + /** + * @en The debug mode none. + * @zh 禁止模式,禁止显示任何日志消息。 + */ + NONE = 0, + + /** + * @en The debug mode none. + * @zh 调试模式,显示所有日志消息。 + */ + VERBOSE = 1, + + /** + * @en Information mode, which display messages with level higher than "information" level. + * @zh 信息模式,显示“信息”级别以上的日志消息。 + */ + INFO = 2, + + /** + * @en Information mode, which display messages with level higher than "warning" level. + * @zh 警告模式,显示“警告”级别以上的日志消息。 + */ + WARN = 3, + + /** + * @en Information mode, which display only messages with "error" level. + * @zh 错误模式,仅显示“错误”级别的日志消息。 + */ + ERROR = 4, + + /** + * @en The debug mode info for web page. + * @zh 信息模式(仅 WEB 端有效),在画面上输出所有信息。 + */ + INFO_FOR_WEB_PAGE = 5, + + /** + * @en The debug mode warn for web page. + * @zh 警告模式(仅 WEB 端有效),在画面上输出 warn 级别以上的(包含 error)信息。 + */ + WARN_FOR_WEB_PAGE = 6, + + /** + * @en The debug mode error for web page. + * @zh 错误模式(仅 WEB 端有效),在画面上输出 error 信息。 + */ + ERROR_FOR_WEB_PAGE = 7, +}; + +/** + * @en Outputs a message to the Cocos Creator Console (editor) or Web Console (runtime). + * @zh 输出一条消息到 Cocos Creator 编辑器的 Console 或运行时 Web 端的 Console 中。 + * @param message - A JavaScript string containing zero or more substitution strings. + * @param optionalParams - JavaScript objects with which to replace substitution strings within msg. + * This gives you additional control over the format of the output. + */ + +template +void log(cc::any message, Args... optionalParams); + +/** + * @en + * Outputs a warning message to the Cocos Creator Console (editor) or Web Console (runtime). + * - In Cocos Creator, warning is yellow. + * - In Chrome, warning have a yellow warning icon with the message text. + * @zh + * 输出警告消息到 Cocos Creator 编辑器的 Console 或运行时 Web 端的 Console 中。
+ * - 在 Cocos Creator 中,警告信息显示是黄色的。
+ * - 在 Chrome 中,警告信息有着黄色的图标以及黄色的消息文本。
+ * @param message - A JavaScript string containing zero or more substitution strings. + * @param optionalParams - JavaScript objects with which to replace substitution strings within msg. + * This gives you additional control over the format of the output. + */ +template +void warn(cc::any message, Args... optionalParams); + +/** + * @en + * Outputs an error message to the Cocos Creator Console (editor) or Web Console (runtime).
+ * - In Cocos Creator, error is red.
+ * - In Chrome, error have a red icon along with red message text.
+ * @zh + * 输出错误消息到 Cocos Creator 编辑器的 Console 或运行时页面端的 Console 中。
+ * - 在 Cocos Creator 中,错误信息显示是红色的。
+ * - 在 Chrome 中,错误信息有红色的图标以及红色的消息文本。
+ * @param message - A JavaScript string containing zero or more substitution strings. + * @param optionalParams - JavaScript objects with which to replace substitution strings within msg. + * This gives you additional control over the format of the output. + */ +template +void error(cc::any message, Args... optionalParams); + +/** + * @en + * Assert the condition and output error messages if the condition is not true. + * @zh + * 对检查测试条件进行检查,如果条件不为 true 则输出错误消息 + * @param value - The condition to check on + * @param message - A JavaScript string containing zero or more substitution strings. + * @param optionalParams - JavaScript objects with which to replace substitution strings within msg. + * This gives you additional control over the format of the output. + */ + +template +void _assert(cc::any value, std::string message, Args... optionalParams); // NOLINT //assert is a reserved word + +/** + * @en Outputs a message at the "debug" log level. + * @zh 输出一条“调试”日志等级的消息。 + */ +template +void debug(Args... data); + +void resetDebugSetting(DebugMode mode); + +/** + * @en Gets error message with the error id and possible parameters. + * @zh 通过 error id 和必要的参数来获取错误信息。 + */ +template +std::string getError(uint32_t errorId, Args... param); + +/** + * @en Returns whether or not to display the FPS and debug information. + * @zh 是否显示 FPS 信息和部分调试信息。 + */ +bool isDisplayStats(); + +/** + * @en Sets whether display the FPS and debug informations on the bottom-left corner. + * @zh 设置是否在左下角显示 FPS 和部分调试。 + */ + +void setDisplayStats(bool displayStats); + +template +void logID(uint32_t id, Args... optionalParams); + +template +void warnID(uint32_t id, Args... optionalParams); + +template +void errorID(uint32_t id, Args... optionalParams); + +template +void assertID(uint32_t id, Args... optionalParams); + +void _throw(); // NOLINT // throw is a reserved word +} // namespace debug + +} // namespace cc \ No newline at end of file diff --git a/native/cocos/core/platform/Macro.cpp b/native/cocos/core/platform/Macro.cpp new file mode 100644 index 0000000000..ba3aabaf7a --- /dev/null +++ b/native/cocos/core/platform/Macro.cpp @@ -0,0 +1,35 @@ +/**************************************************************************** + 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/platform/Macro.h" + +namespace cc { + +namespace macro { +const std::vector SUPPORT_TEXTURE_FORMATS = { + ".astc", ".pkm", ".pvr", ".webp", ".jpg", ".jpeg", ".bmp", ".png"}; + +} +} // namespace cc \ No newline at end of file diff --git a/native/cocos/core/platform/Macro.h b/native/cocos/core/platform/Macro.h new file mode 100644 index 0000000000..8fb127d16b --- /dev/null +++ b/native/cocos/core/platform/Macro.h @@ -0,0 +1,868 @@ +/**************************************************************************** + 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 +#include + +#include "math/Math.h" + +namespace cc { +namespace macro { +/** + * @en + * The image format supported by the engine defaults, and the supported formats may differ in different build platforms and device types. + * Currently all platform and device support ['.webp', '.jpg', '.jpeg', '.bmp', '.png'], ios mobile platform + * @zh + * 引擎默认支持的图片格式,支持的格式可能在不同的构建平台和设备类型上有所差别。 + * 目前所有平台和设备支持的格式有 ['.webp', '.jpg', '.jpeg', '.bmp', '.png']. The iOS mobile platform also supports the PVR format。 + */ +extern const std::vector SUPPORT_TEXTURE_FORMATS; +/** + * @en Key map for keyboard event + * @zh 键盘事件的按键值。 + * @example {@link cocos/core/platform/CCCommon/KEY.js} + * @deprecated since v3.3 please use KeyCode instead + */ +enum class KEY { + /** + * @en None + * @zh 没有分配 + * @readonly + */ + NONE = 0, + + // android + /** + * @en The back key on mobile phone + * @zh 移动端返回键 + * @readonly + * @deprecated since v3.3 + */ + BACK = 6, + /** + * @en The menu key on mobile phone + * @zh 移动端菜单键 + * @readonly + * @deprecated since v3.3 + */ + MENU = 18, + + /** + * @en The backspace key + * @zh 退格键 + * @readonly + */ + BACKSPACE = 8, + + /** + * @en The tab key + * @zh Tab 键 + * @readonly + */ + TAB = 9, + + /** + * @en The enter key + * @zh 回车键 + * @readonly + */ + ENTER = 13, + + /** + * @en The shift key + * @zh Shift 键 + * @readonly + * @deprecated since v3.3, please use KeyCode.SHIFT_LEFT instead. + */ + SHIFT = 16, // should use shiftkey instead + + /** + * @en The ctrl key + * @zh Ctrl 键 + * @readonly + * @deprecated since v3.3, please use KeyCode.CTRL_LEFT instead. + */ + CTRL = 17, // should use ctrlkey + + /** + * @en The alt key + * @zh Alt 键 + * @readonly + * @deprecated since v3.3, please use KeyCode.ALT_LEFT instead. + */ + ALT = 18, // should use altkey + + /** + * @en The pause key + * @zh 暂停键 + * @readonly + */ + PAUSE = 19, + + /** + * @en The caps lock key + * @zh 大写锁定键 + * @readonly + */ + CAPSLOCK = 20, + + /** + * @en The esc key + * @zh ESC 键 + * @readonly + */ + ESCAPE = 27, + + /** + * @en The space key + * @zh 空格键 + * @readonly + */ + SPACE = 32, + + /** + * @en The page up key + * @zh 向上翻页键 + * @readonly + */ + PAGEUP = 33, + + /** + * @en The page down key + * @zh 向下翻页键 + * @readonly + */ + PAGEDOWN = 34, + + /** + * @en The end key + * @zh 结束键 + * @readonly + */ + END = 35, + + /** + * @en The home key + * @zh 主菜单键 + * @readonly + */ + HOME = 36, + + /** + * @en The left key + * @zh 向左箭头键 + * @readonly + */ + LEFT = 37, + + /** + * @en The up key + * @zh 向上箭头键 + * @readonly + */ + UP = 38, + + /** + * @en The right key + * @zh 向右箭头键 + * @readonly + */ + RIGHT = 39, + + /** + * @en The down key + * @zh 向下箭头键 + * @readonly + */ + DOWN = 40, + + /** + * @en The select key + * @zh Select 键 + * @readonly + * @deprecated since v3.3 + */ + SELECT = 41, + + /** + * @en The insert key + * @zh 插入键 + * @readonly + */ + INSERT = 45, + + /** + * @en The Delete key + * @zh 删除键 + * @readonly + */ + DELETE = 46, + + /** + * @en The a key + * @zh A 键 + * @readonly + */ + A = 65, + + /** + * @en The b key + * @zh B 键 + * @readonly + */ + B = 66, + + /** + * @en The c key + * @zh C 键 + * @readonly + */ + C = 67, + + /** + * @en The d key + * @zh D 键 + * @readonly + */ + D = 68, + + /** + * @en The e key + * @zh E 键 + * @readonly + */ + E = 69, + + /** + * @en The f key + * @zh F 键 + * @readonly + */ + F = 70, + + /** + * @en The g key + * @zh G 键 + * @readonly + */ + G = 71, + + /** + * @en The h key + * @zh H 键 + * @readonly + */ + H = 72, + + /** + * @en The i key + * @zh I 键 + * @readonly + */ + I = 73, + + /** + * @en The j key + * @zh J 键 + * @readonly + */ + J = 74, + + /** + * @en The k key + * @zh K 键 + * @readonly + */ + K = 75, + + /** + * @en The l key + * @zh L 键 + * @readonly + */ + L = 76, + + /** + * @en The m key + * @zh M 键 + * @readonly + */ + M = 77, + + /** + * @en The n key + * @zh N 键 + * @readonly + */ + N = 78, + + /** + * @en The o key + * @zh O 键 + * @readonly + */ + O = 79, + + /** + * @en The p key + * @zh P 键 + * @readonly + */ + P = 80, + + /** + * @en The q key + * @zh Q 键 + * @readonly + */ + Q = 81, + + /** + * @en The r key + * @zh R 键 + * @readonly + */ + R = 82, + + /** + * @en The s key + * @zh S 键 + * @readonly + */ + S = 83, + + /** + * @en The t key + * @zh T 键 + * @readonly + */ + T = 84, + + /** + * @en The u key + * @zh U 键 + * @readonly + */ + U = 85, + + /** + * @en The v key + * @zh V 键 + * @readonly + */ + V = 86, + + /** + * @en The w key + * @zh W 键 + * @readonly + */ + W = 87, + + /** + * @en The x key + * @zh X 键 + * @readonly + */ + X = 88, + + /** + * @en The y key + * @zh Y 键 + * @readonly + */ + Y = 89, + + /** + * @en The z key + * @zh Z 键 + * @readonly + */ + Z = 90, + + /** + * @en The numeric keypad 0 + * @zh 数字键盘 0 + * @readonly + */ + NUM0 = 96, + + /** + * @en The numeric keypad 1 + * @zh 数字键盘 1 + * @readonly + */ + NUM1 = 97, + + /** + * @en The numeric keypad 2 + * @zh 数字键盘 2 + * @readonly + */ + NUM2 = 98, + + /** + * @en The numeric keypad 3 + * @zh 数字键盘 3 + * @readonly + */ + NUM3 = 99, + + /** + * @en The numeric keypad 4 + * @zh 数字键盘 4 + * @readonly + */ + NUM4 = 100, + + /** + * @en The numeric keypad 5 + * @zh 数字键盘 5 + * @readonly + */ + NUM5 = 101, + + /** + * @en The numeric keypad 6 + * @zh 数字键盘 6 + * @readonly + */ + NUM6 = 102, + + /** + * @en The numeric keypad 7 + * @zh 数字键盘 7 + * @readonly + */ + NUM7 = 103, + + /** + * @en The numeric keypad 8 + * @zh 数字键盘 8 + * @readonly + */ + NUM8 = 104, + + /** + * @en The numeric keypad 9 + * @zh 数字键盘 9 + * @readonly + */ + NUM9 = 105, + + /** + * @en The numeric keypad 'delete' + * @zh 数字键盘删除键 + * @readonly + */ + NUMDEL = 110, + + /** + * @en The F1 function key + * @zh F1 功能键 + * @readonly + */ + F1 = 112, // f1-f12 dont work on ie + + /** + * @en The F2 function key + * @zh F2 功能键 + * @readonly + */ + F2 = 113, + + /** + * @en The F3 function key + * @zh F3 功能键 + * @readonly + */ + F3 = 114, + + /** + * @en The F4 function key + * @zh F4 功能键 + * @readonly + */ + F4 = 115, + + /** + * @en The F5 function key + * @zh F5 功能键 + * @readonly + */ + F5 = 116, + + /** + * @en The F6 function key + * @zh F6 功能键 + * @readonly + */ + F6 = 117, + + /** + * @en The F7 function key + * @zh F7 功能键 + * @readonly + */ + F7 = 118, + + /** + * @en The F8 function key + * @zh F8 功能键 + * @readonly + */ + F8 = 119, + + /** + * @en The F9 function key + * @zh F9 功能键 + * @readonly + */ + F9 = 120, + + /** + * @en The F10 function key + * @zh F10 功能键 + * @readonly + */ + F10 = 121, + + /** + * @en The F11 function key + * @zh F11 功能键 + * @readonly + */ + F11 = 122, + + /** + * @en The F12 function key + * @zh F12 功能键 + * @readonly + */ + F12 = 123, + + /** + * @en The numlock key + * @zh 数字锁定键 + * @readonly + */ + NUMLOCK = 144, + + /** + * @en The scroll lock key + * @zh 滚动锁定键 + * @readonly + */ + SCROLLLOCK = 145, + + /** + * @en The ';' key. + * @zh 分号键 + * @readonly + */ + SEMICOLON = 186, + + /** + * @en The '=' key. + * @zh 等于号键 + * @readonly + */ + EQUAL = 187, + + /** + * @en The ',' key. + * @zh 逗号键 + * @readonly + */ + COMMA = 188, + + /** + * @en The dash '-' key. + * @zh 中划线键 + * @readonly + */ + DASH = 189, + + /** + * @en The '.' key + * @zh 句号键 + * @readonly + */ + PERIOD = 190, + + /** + * @en The forward slash key + * @zh 正斜杠键 + * @readonly + */ + FORWARDSLASH = 191, + + /** + * @en The grave key + * @zh 按键 ` + * @readonly + */ + GRAVE = 192, + + /** + * @en The '[' key + * @zh 按键 [ + * @readonly + */ + OPENBRACKET = 219, + + /** + * @en The '\' key + * @zh 反斜杠键 + * @readonly + */ + BACKSLASH = 220, + + /** + * @en The ']' key + * @zh 按键 ] + * @readonly + */ + CLOSEBRACKET = 221, + + /** + * @en The quote key + * @zh 单引号键 + * @readonly + */ + QUOTE = 222, + + /** + * @en The dpad left key + * @zh 导航键 向左 + * @readonly + * @deprecated since v3.3 + */ + DPAD_LEFT = 1000, + + /** + * @en The dpad right key + * @zh 导航键 向右 + * @readonly + * @deprecated since v3.3 + */ + DPAD_RIGHT = 1001, + + /** + * @en The dpad up key + * @zh 导航键 向上 + * @readonly + * @deprecated since v3.3 + */ + DPAD_UP = 1003, + + /** + * @en The dpad down key + * @zh 导航键 向下 + * @readonly + * @deprecated since v3.3 + */ + DPAD_DOWN = 1004, + + /** + * @en The dpad center key + * @zh 导航键 确定键 + * @readonly + * @deprecated since v3.3 + */ + DPAD_CENTER = 1005, +}; + +/** + * PI / 180 + */ +static const float RAD{math::PI / 180}; + +/** + * One degree + */ +// static const float DEG; +static const float DEG{math::PI / 180}; + +/** + * A maximum value of number + */ +static const uint32_t REPEAT_FOREVER{UINT32_MAX}; + +/** + * A minimal float value + */ +// FLT_EPSILON: 0.0000001192092896, + +// static const float FLTEPSILON {0.0000001192092896}; //FLT_EPSILON is keyword in cpp +// Possible device orientations +/** + * @en Oriented vertically + * @zh 竖屏朝向 + */ +static const int32_t ORIENTATION_PORTRAIT{1}; + +/** + * @en Oriented horizontally + * @zh 横屏朝向 + */ +static const int32_t ORIENTATION_LANDSCAPE{2}; + +/** + * @en Oriented automatically + * @zh 自动适配朝向 + */ +static const int32_t ORIENTATION_AUTO{3}; + +/** + *

+ * If enabled, the texture coordinates will be calculated by using this formula:
+ * - texCoord.left = (rect.x*2+1) / (texture.wide*2);
+ * - texCoord.right = texCoord.left + (rect.width*2-2)/(texture.wide*2);
+ *
+ * The same for bottom and top.
+ *
+ * This formula prevents artifacts by using 99% of the texture.
+ * The "correct" way to prevent artifacts is by expand the texture's border with the same color by 1 pixel
+ *
+ * Affected component:
+ * - TMXLayer
+ *
+ * Enabled by default. To disabled set it to 0.
+ * To modify it, in Web engine please refer to CCMacro.js, in JSB please refer to CCConfig.h + *

+ * Currently not useful in 3D engine + */ +// FIX_ARTIFACTS_BY_STRECHING_TEXEL_TMX: true, + +/** + * @en + * Whether or not enabled tiled map auto culling. If you set the TiledMap skew or rotation, + * then need to manually disable this, otherwise, the rendering will be wrong. + * Currently not useful in 3D engine + * @zh + * 是否开启瓦片地图的自动裁减功能。瓦片地图如果设置了 skew, rotation 的话,需要手动关闭,否则渲染会出错。 + * 在 3D 引擎中暂时无效。 + * @default true + */ +static const bool ENABLE_TILEDMAP_CULLING{true}; + +/** + * @en + * The timeout to determine whether a touch is no longer active and should be removed. + * The reason to add this timeout is due to an issue in X5 browser core, + * when X5 is presented in wechat on Android, if a touch is glissed from the bottom up, and leave the page area, + * no touch cancel event is triggered, and the touch will be considered active forever. + * After multiple times of this action, our maximum touches number will be reached and all new touches will be ignored. + * So this new mechanism can remove the touch that should be inactive if it's not updated during the last 5000 milliseconds. + * Though it might remove a real touch if it's just not moving for the last 5 seconds which is not easy with the sensibility of mobile touch screen. + * You can modify this value to have a better behavior if you find it's not enough. + * @zh + * 用于甄别一个触点对象是否已经失效并且可以被移除的延时时长 + * 添加这个时长的原因是 X5 内核在微信浏览器中出现的一个 bug。 + * 在这个环境下,如果用户将一个触点从底向上移出页面区域,将不会触发任何 touch cancel 或 touch end 事件,而这个触点会被永远当作停留在页面上的有效触点。 + * 重复这样操作几次之后,屏幕上的触点数量将达到我们的事件系统所支持的最高触点数量,之后所有的触摸事件都将被忽略。 + * 所以这个新的机制可以在触点在一定时间内没有任何更新的情况下视为失效触点并从事件系统中移除。 + * 当然,这也可能移除一个真实的触点,如果用户的触点真的在一定时间段内完全没有移动(这在当前手机屏幕的灵敏度下会很难)。 + * 你可以修改这个值来获得你需要的效果,默认值是 5000 毫秒。 + * @default 5000 + */ +static const uint32_t TOUCH_TIMEOUT{5000}; +/** + * @en + * Boolean that indicates if the canvas contains an alpha channel, default sets to false for better performance. + * Though if you want to make your canvas background transparent and show other dom elements at the background, + * you can set it to true before {{game.init}}. + * Web only. + * @zh + * 用于设置 Canvas 背景是否支持 alpha 通道,默认为 false,这样可以有更高的性能表现。 + * 如果你希望 Canvas 背景是透明的,并显示背后的其他 DOM 元素,你可以在 {{game.init}} 之前将这个值设为 true。 + * 仅支持 Web + * @default false + */ +static const bool ENABLE_TRANSPARENT_CANVAS{false}; + +/** + * @en + * Boolean that indicates if the WebGL context is created with `antialias` option turned on, default value is false. + * Set it to true could make your game graphics slightly smoother, like texture hard edges when rotated. + * Whether to use this really depend on your game design and targeted platform, + * device with retina display usually have good detail on graphics with or without this option, + * you probably don't want antialias if your game style is pixel art based. + * Also, it could have great performance impact with some browser / device using software MSAA. + * You can set it to true before {{game.init}}. + * Web only. + * @zh + * 用于设置在创建 WebGL Context 时是否开启抗锯齿选项,默认值是 false。 + * 将这个选项设置为 true 会让你的游戏画面稍稍平滑一些,比如旋转硬边贴图时的锯齿。是否开启这个选项很大程度上取决于你的游戏和面向的平台。 + * 在大多数拥有 retina 级别屏幕的设备上用户往往无法区分这个选项带来的变化;如果你的游戏选择像素艺术风格,你也多半不会想开启这个选项。 + * 同时,在少部分使用软件级别抗锯齿算法的设备或浏览器上,这个选项会对性能产生比较大的影响。 + * 你可以在 {{game.init}} 之前设置这个值,否则它不会生效。 + * 仅支持 Web + * @default true + */ +static const bool ENABLE_WEBGL_ANTIALIAS{true}; + +/** + * @en + * Whether to clear the original image cache after uploaded a texture to GPU. + * If cleared, [Dynamic Atlas](https://docs.cocos.com/creator/manual/en/advanced-topics/dynamic-atlas.html) will not be supported. + * Normally you don't need to enable this option on the web platform, because Image object doesn't consume too much memory. + * But on Wechat Game platform, the current version cache decoded data in Image object, which has high memory usage. + * So we enabled this option by default on Wechat, so that we can release Image cache immediately after uploaded to GPU. + * Currently not useful in 3D engine + * @zh + * 是否在将贴图上传至 GPU 之后删除原始图片缓存,删除之后图片将无法进行 [动态合图](https://docs.cocos.com/creator/manual/zh/advanced-topics/dynamic-atlas.html)。 + * 在 Web 平台,你通常不需要开启这个选项,因为在 Web 平台 Image 对象所占用的内存很小。 + * 但是在微信小游戏平台的当前版本,Image 对象会缓存解码后的图片数据,它所占用的内存空间很大。 + * 所以我们在微信平台默认开启了这个选项,这样我们就可以在上传 GL 贴图之后立即释放 Image 对象的内存,避免过高的内存占用。 + * 在 3D 引擎中暂时无效。 + * @default false + */ +static const bool CLEANUP_IMAGE_CACHE{false}; + +/** + * @en + * Whether to enable multi-touch. + * @zh + * 是否开启多点触摸 + * @default true + */ +static const bool ENABLE_MULTI_TOUCH{true}; + +/** + * @en + * The maximum size of the canvas pool used by Label, please adjust according to the number of label component in the same scene of the project + * @zh + * Label 使用的 canvas pool 的最大大小,请根据项目同场景的 label 数量进行调整 + * @default 20 + */ +static const uint32_t MAX_LABEL_CANVAS_POOL_SIZE{20}; + +} // namespace macro + +} // namespace cc diff --git a/native/cocos/scene/Scene.h b/native/cocos/core/scene-graph/BaseNode.h similarity index 79% rename from native/cocos/scene/Scene.h rename to native/cocos/core/scene-graph/BaseNode.h index 418d481cea..bddfcb8eea 100644 --- a/native/cocos/scene/Scene.h +++ b/native/cocos/core/scene-graph/BaseNode.h @@ -24,18 +24,12 @@ ****************************************************************************/ #pragma once -#include "scene/BaseNode.h" + +#include "core/data/Object.h" namespace cc { -namespace scene { -class Scene final : public BaseNode { -public: - Scene() = default; - Scene(const Scene &) = delete; - Scene(Scene &&) = delete; - ~Scene() override = default; - Scene &operator=(const Scene &) = delete; - Scene &operator=(Scene &&) = delete; + +class BaseNode : public CCObject { }; -} // namespace scene + } // namespace cc \ No newline at end of file diff --git a/native/cocos/core/scene-graph/Layers.cpp b/native/cocos/core/scene-graph/Layers.cpp new file mode 100644 index 0000000000..e69de29bb2 diff --git a/native/cocos/core/scene-graph/Layers.h b/native/cocos/core/scene-graph/Layers.h new file mode 100644 index 0000000000..99e1a58466 --- /dev/null +++ b/native/cocos/core/scene-graph/Layers.h @@ -0,0 +1,123 @@ +/* + 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 + +#include "base/Macros.h" +#include "base/TypeDef.h" + +namespace cc { + +/** + * @zh 节点层管理器,层数据是以掩码数据方式存储在 [[Node.layer]] 中,用于射线检测、物理碰撞和用户自定义脚本逻辑。 + * 每个节点可属于一个或多个层,可通过 “包含式” 或 “排除式” 两种检测器进行层检测。 + * @en Node's layer manager, it's stored as bit mask data in [[Node.layer]]. + * Layer information is widely used in raycast, physics and user logic. + * Every node can be assigned to multiple layers with different bit masks, you can setup layer with inclusive or exclusive operation. + */ +class Layers final { +public: + Layers() = delete; + ~Layers() = delete; + + // built-in layers, users can use 0~19 bits, 20~31 are system preserve bits. + enum class LayerList : uint32_t { + NONE = 0, + IGNORE_RAYCAST = (1 << 20), + GIZMOS = (1 << 21), + EDITOR = (1 << 22), + UI_3D = (1 << 23), + SCENE_GIZMO = (1 << 24), + UI_2D = (1 << 25), + + PROFILER = (1 << 28), + DEFAULT = (1 << 30), + ALL = 0xffffffff, + }; + + using Enum = LayerList; + + /** + * @en + * Make a layer mask accepting nothing but the listed layers + * @zh + * 创建一个包含式层检测器,只接受列表中的层 + * @param includes All accepted layers + * @return A filter which can detect all accepted layers + */ + static uint32_t makeMaskInclude(const std::vector &includes) { + uint32_t mask = 0; + for (uint32_t inc : includes) { + mask |= inc; + } + return mask; + } + + /** + * @en + * Make a layer mask accepting everything but the listed layers + * @zh + * 创建一个排除式层检测器,只拒绝列表中的层 + * @param excludes All excluded layers + * @return A filter which can detect for excluded layers + */ + static uint32_t makeMaskExclude(const std::vector &excludes) { + return ~makeMaskInclude(excludes); + } + + /** + * @zh 添加一个新层,用户可编辑 0 - 19 位为用户自定义层 + * @en Add a new layer, user can use layers from bit position 0 to 19, other bits are reserved. + * @param name Layer's name + * @param bitNum Layer's bit position + */ + static void addLayer(const std::string &name, uint32_t bitNum); + + /** + * @en Remove a layer, user can remove layers from bit position 0 to 19, other bits are reserved. + * @zh 移除一个层,用户可编辑 0 - 19 位为用户自定义层 + * @param bitNum Layer's bit position + */ + static void deleteLayer(uint32_t bitNum); + + /** + * @en Given a layer name, returns the layer index as defined by either a Builtin or a User Layer in the Tags and Layers manager. + * @zh 给定层名称,返回由标记和层管理器中的内置层或用户层定义的层索引。 + * @param name layer's name + */ + static uint32_t nameToLayer(const std::string &name); + + /** + * @en Given a layer number, returns the name of the layer as defined in either a Builtin or a User Layer in the Tags and Layers manager. + * @zh 给定层数,返回在标记和层管理器中的内置层或用户层中定义的层名称。 + * @param bitNum layer's value + */ + static std::string layerToName(uint32_t bitNum); +}; + +CC_ENUM_BITWISE_OPERATORS(Layers::LayerList); + +} // namespace cc diff --git a/native/cocos/core/scene-graph/Node.cpp b/native/cocos/core/scene-graph/Node.cpp new file mode 100644 index 0000000000..809d5cfdd2 --- /dev/null +++ b/native/cocos/core/scene-graph/Node.cpp @@ -0,0 +1,1029 @@ +/**************************************************************************** + 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/CachedArray.h" +#include "base/StringUtil.h" +// #include "core/Director.h" +// #include "core/Game.h" +#include "core/data/Object.h" +//#include "core/scene-graph/Find.h" +//#include "core/scene-graph/NodeActivator.h" +#include "core/scene-graph/NodeEnum.h" +//#include "core/scene-graph/NodeUIProperties.h" +#include "core/scene-graph/Scene.h" +#include "core/utils/IDGenerator.h" + +namespace cc { + +// static variables + +uint32_t Node::clearFrame{0}; +uint32_t Node::clearRound{1000}; +bool Node::isStatic{false}; +const uint32_t Node::TRANSFORM_ON{1 << 0}; +const uint32_t Node::DESTROYING{static_cast(CCObject::Flags::DESTROYING)}; +const uint32_t Node::DEACTIVATING{static_cast(CCObject::Flags::DEACTIVATING)}; +const uint32_t Node::DONT_DESTROY{static_cast(CCObject::Flags::DONT_DESTROY)}; +index_t Node::stackId{0}; +std::vector> Node::stacks; +// + +namespace { +CachedArray allNodes{128}; //cjh how to clear ? +const std::string EMPTY_NODE_NAME; +IDGenerator idGenerator("Node"); + +std::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) { + return dirtyNodes[idx]; +} + +} // namespace + +Node::Node() : Node(EMPTY_NODE_NAME) { +} + +Node::Node(const std::string &name) { + _id = idGenerator.getNewId(); + if (name.empty()) { + _name.append("New Node"); + } else { + _name = name; + } + allNodes.push(this); + _eventProcessor = new NodeEventProcessor(this); +} + +Node::~Node() { + uint32_t index = allNodes.indexOf(this); + allNodes.fastRemove(index); + CC_SAFE_DELETE(_eventProcessor); +} + +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*/) { + Node *newParent = _parent; + auto *scene = dynamic_cast(newParent); + if (isPersistNode() && scene == nullptr) { + emit(EventTypesToJS::NODE_REMOVE_PERSIST_ROOT_NODE); + + // if (EDITOR) { + // warnID(1623); + // } + } + // TODO() + // if (EDITOR) { + // const scene = legacyCC.director.getScene() as this | null; + // const inCurrentSceneBefore = oldParent && oldParent.isChildOf(scene); + // const inCurrentSceneNow = newParent && newParent.isChildOf(scene); + // if (!inCurrentSceneBefore && inCurrentSceneNow) { + // // attached + // this._registerIfAttached !(true); + // } else if (inCurrentSceneBefore && !inCurrentSceneNow) { + // // detached + // this._registerIfAttached !(false); + // } + + // // conflict detection + // // _Scene.DetectConflict.afterAddChild(this); + //} + bool shouldActiveNow = _active && !!(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->off(type, useCapture); + bool hasListeners = _eventProcessor->hasEventListener(type); + if (!hasListeners) { + if (type == NodeEventType::TRANSFORM_CHANGED) { + _eventMask &= ~TRANSFORM_ON; + } + } +} + +void Node::off(const CallbacksInvoker::KeyType &type, CallbackInfoBase::ID 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, CallbackInfoBase::ID 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, CallbackInfoBase::ID 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) { + if (_active != isActive) { + _active = isActive; + 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 && oldParent && !!(oldParent->_objFlags & Flags::DEACTIVATING)) { + // // TODO: errorID not implemented + // } + _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 && !!(newParent->_objFlags & Flags::DEACTIVATING)) { + // // TODO:errorID(3821); + // } + newParent->_children.emplace_back(this); + _siblingIndex = static_cast(newParent->_children.size() - 1); + newParent->emit(NodeEventType::CHILD_ADDED, this); + } + onHierarchyChanged(oldParent); +} + +Scene *Node::getScene() const { + return _scene; +} + +void Node::walk(const std::function &preFunc) { + walk(preFunc, nullptr); +} + +void Node::walk(const std::function &preFunc, const std::function &postFunc) { + index_t index{1}; + index_t i{0}; + const std::vector> *children = nullptr; + Node * curr{nullptr}; + auto stacksCount = static_cast(Node::stacks.size()); + if (stackId >= stacksCount) { + stacks.resize(stackId + 1); + } + auto stack = stacks[stackId]; + stackId++; + + stack.clear(); + stack.resize(1); + stack[0] = this; + Node *parent{nullptr}; + bool afterChildren{false}; + while (index) { + index--; + auto stackCount = static_cast(stack.size()); + if (index >= stackCount) { + continue; + } + curr = stack[index]; + if (curr == nullptr) { + continue; + } + if (!afterChildren && preFunc != nullptr) { + // pre call + preFunc(curr); + } else if (afterChildren && postFunc != nullptr) { + // post call + postFunc(curr); + } + stack[index] = nullptr; + if (afterChildren) { + if (parent == _parent) { + break; + } + afterChildren = false; + } else { + if (static_cast(curr->_children.size()) > 0) { + parent = curr; + children = &curr->_children; + i = 0; + stack[index] = (*children)[i]; + stack.resize(++index); + } else { + stack[index] = curr; + stack.resize(++index); + afterChildren = true; + } + continue; + } + + if (children != nullptr && !children->empty()) { + i++; + if (i < children->size() && children->at(i) != nullptr) { + stack[index] = children->at(i); + stack.resize(++index); + } else if (parent) { + stack[index] = parent; + stack.resize(++index); + afterChildren = true; + if (parent->_parent != nullptr) { + children = &parent->_parent->_children; + index_t idx = getIdxOfChild(*children, parent); + if (idx != CC_INVALID_INDEX) { + i = idx; + } + parent = parent->_parent; + } else { + // At root + parent = nullptr; + children = nullptr; + } + if (i < 0) { + break; + } + } + } + } + stack.clear(); + stackId--; +} + +//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)); + // TODO() + /*if (!destroyByParent && EDITOR) { + this._registerIfAttached !(false); + }*/ + 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); + } + } + 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 std::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); +} + +index_t Node::getIdxOfChild(const std::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 std::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) { + 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)) { + // TODO(): errorID(3821); + return; + } + std::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 std::string &path) const { + size_t end = 0; + std::vector segments = StringUtil::split(path, "/"); + auto * lastNode = const_cast(this); + for (const std::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() { + 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->getWorldMatrix()); + 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->getWorldMatrix(), currChild->_worldMatrix, &currChild->_worldMatrix); + if (dirtyBits & static_cast(TransformBit::ROTATION)) { + Quaternion::multiply(curr->getWorldRotation(), 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 { + 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->_uiTransformDirty[0] = 1; // UIOnly TRS dirty + 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->getWorldMatrix()}; + 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->getWorldRotation().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 { + 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->getWorldRotation().getConjugated(), &mat3); + Mat3 b; + Mat3::fromMat4(_parent->getWorldMatrix(), &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::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) { + Node *parent = _parent; + if (parent) { + parent->updateWorldTransform(); + Mat4 mTemp{Mat4::IDENTITY}; // cjh FIXME: the logic is different from ts version. + Mat4::inverseTranspose(parent->getWorldMatrix(), &mTemp); + mTemp *= _worldMatrix; + + } 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 * _worldRotation; + 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); +} + +void Node::inverseTransformPoint(Vec3 &out, const Vec3 &p) { + 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 = dirtyNodes[i]; + } +} + +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->getWorldRotation().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() { + for (uint32_t i = 0, len = allNodes.size(); i < len; ++i) { + allNodes[i]->setChangedFlags(0); + } +} + +void Node::clearNodeArray() { + if (clearFrame < clearRound) { + clearFrame++; + } else { + clearFrame = 0; + dirtyNodes.clear(); + } +} + +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 std::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(std::vector> &&children) { + _children = std::move(children); +} + +// + +} // namespace cc diff --git a/native/cocos/core/scene-graph/Node.h b/native/cocos/core/scene-graph/Node.h new file mode 100644 index 0000000000..23a0aca382 --- /dev/null +++ b/native/cocos/core/scene-graph/Node.h @@ -0,0 +1,853 @@ +/**************************************************************************** + 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 +#include "base/Ptr.h" +#include "base/TypeDef.h" +#include "cocos/base/Any.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; +//class NodeUiProperties; + +/** + * 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 const uint32_t DESTROYING; + static const uint32_t DEACTIVATING; + static const uint32_t DONT_DESTROY; + + static Node *instantiate(Node *cloned, bool isSyncedNode); + // for walk + static std::vector> stacks; + static index_t stackId; + + static void setScene(Node *); + static index_t getIdxOfChild(const std::vector> &, Node *); + + static bool isStatic; // cjh TODO: add getter / setter + + /** + * @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 std::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 std::string &name); + ~Node() override; + + void setParent(Node *parent, bool isKeepWorld = false); + + Scene *getScene() const; + + void walk(const std::function &preFunc); + void walk(const std::function &preFunc, const std::function &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, CallbackInfoBase::ID &cbID, bool useCapture = false); + + template + void on(const CallbacksInvoker::KeyType &type, std::function &&callback, Target *target, CallbackInfoBase::ID &cbID, bool useCapture = false); + + template + std::enable_if_t::value, void> + on(const CallbacksInvoker::KeyType &type, LambdaType &&callback, Target *target, CallbackInfoBase::ID &cbID, bool useCapture = false); + + template + std::enable_if_t::value, void> + on(const CallbacksInvoker::KeyType &type, LambdaType &&callback, CallbackInfoBase::ID &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, CallbackInfoBase::ID &cbID, bool useCapture = false); + + template + void once(const CallbacksInvoker::KeyType &type, std::function &&callback, Target *target, CallbackInfoBase::ID &cbID, bool useCapture = false); + + template + std::enable_if_t::value, void> + once(const CallbacksInvoker::KeyType &type, LambdaType &&callback, CallbackInfoBase::ID &cbID, bool useCapture = false); + + template + std::enable_if_t::value, void> + once(const CallbacksInvoker::KeyType &type, LambdaType &&callback, Target *target, CallbackInfoBase::ID &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, CallbackInfoBase::ID 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, CallbackInfoBase::ID cbID) const; + bool hasEventListener(const CallbacksInvoker::KeyType &type, void *target) const; + bool hasEventListener(const CallbacksInvoker::KeyType &type, void *target, CallbackInfoBase::ID 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); + + 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 std::string &getUuid() const { + return _id; + } + + inline bool isActive() const { return _active; } + + inline bool isActiveInHierarchy() const { return _activeInHierarchyArr[0] != 0; } + inline void setActiveInHierarchy(bool v) { _activeInHierarchyArr[0] = (v ? 1 : 0); } + inline void setActiveInHierarchyPtr(uint8_t *ptr) { _activeInHierarchyArr = ptr; } + + virtual void onPostActivated(bool active) {} + inline const std::vector> &getChildren() const { return _children; } + inline Node * getParent() const { return _parent; } + inline NodeEventProcessor * getEventProcessor() const { return _eventProcessor; } + + Node * getChildByUuid(const std::string &) const; + Node * getChildByName(const std::string &) const; + Node * getChildByPath(const std::string &) 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: + + // =============================== + // 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); + 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 + */ + 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 + */ + 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 + */ + const Vec3 &getScale() const { return _localScale; } + + /** + * @en Inversely transform a point from world coordinate system to local coordinate system. + * @zh 逆向变换一个空间点,一般用于将世界坐标转换到本地坐标系中。 + * @param out The result point in local coordinate system will be stored in this vector + * @param p A position in world coordinate system + */ + void inverseTransformPoint(Vec3 &out, 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); } + + inline void 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 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() { + Vec3 forward{0, 0, -1}; + forward.transformQuat(_worldRotation); + return forward; + } + + inline Vec3 getUp() { + Vec3 up{0, 1, 0}; + up.transformQuat(_worldRotation); + return up; + } + + inline Vec3 getRight() { + Vec3 right{1, 0, 0}; + right.transformQuat(_worldRotation); + return right; + } + + /** + * @en Whether the node's transformation have changed during the current frame. + * @zh 这个节点的空间变换信息在当前帧内是否有变过? + */ + inline uint32_t getChangedFlags() const { return _flagChange; } + inline void setChangedFlags(uint32_t value) { _flagChange = value; } + + inline void setDirtyFlag(uint32_t value) { _dirtyFlag = value; } + inline uint32_t getDirtyFlag() const { return _dirtyFlag; } + inline void setLayer(uint32_t layer) { + _layerArr[0] = layer; + emit(NodeEventType::LAYER_CHANGED, layer); + } + inline uint32_t getLayer() const { return _layerArr[0]; } + inline void setLayerPtr(uint32_t *ptr) { _layerArr = ptr; } + + // inline NodeUiProperties *getUIProps() const { return _uiProps.get(); } + + inline void setUIPropsTransformDirtyPtr(uint32_t *pDirty) { _uiTransformDirty = pDirty; } + + // // ------------------ 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 std::vector & /*components*/) { + // // cjh TODO: + // CC_ASSERT(false); + // return nullptr; + // } + // + // template ::value>> + // static Component *findChildComponent(const std::vector & /*children*/) { + // // cjh TODO: + // CC_ASSERT(false); + // return nullptr; + // } + // + // template ::value>> + // static void findChildComponents(const std::vector & /*children*/, std::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>> + // std::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>> + // std::vector getComponentsInChildren() const { + // // cjh TODO: + // CC_ASSERT(false); + // return {}; + // } + // + // inline std::vector getComponents() const { return _components; } + // + // void checkMultipleComp(Component *comp) {} + // std::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(std::vector> &&children); // NOLINT + // For JS wrapper. + inline uint32_t getEventMask() const { return _eventMask; } + inline void setEventMask(uint32_t mask) { _eventMask = mask; } + +protected: + bool onPreDestroy() override; + + void onSetParent(Node *oldParent, bool keepWorldTransform); + + virtual void updateScene(); + + void onHierarchyChanged(Node *); + void onHierarchyChangedBase(Node *oldParent); + + virtual void onBatchCreated(bool dontChildPrefab); + + bool onPreDestroyBase(); + + static uint32_t clearFrame; + static uint32_t clearRound; + +private: + 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); + } + +protected: + Scene * _scene{nullptr}; + NodeEventProcessor *_eventProcessor{nullptr}; + + uint32_t _eventMask{0}; + + Mat4 _rtMat{Mat4::IDENTITY}; + cc::Mat4 _worldMatrix{Mat4::IDENTITY}; + + uint32_t _flagChange{0}; + uint32_t _dirtyFlag{0}; + + bool _eulerDirty{false}; + // IntrusivePtr _uiProps; + // bool _activeInHierarchy{false}; + // Shared memory with JS. + uint8_t * _activeInHierarchyArr{nullptr}; + uint32_t *_layerArr{nullptr}; + +public: + std::function onSiblingIndexChanged{nullptr}; + index_t _siblingIndex{0}; + // For deserialization + std::string _id; + std::vector> _children; + Node * _parent{nullptr}; + bool _active{true}; + +private: + // local transform + cc::Vec3 _localPosition{Vec3::ZERO}; + cc::Quaternion _localRotation{Quaternion::identity()}; + cc::Vec3 _localScale{Vec3::ONE}; + // world transform + cc::Vec3 _worldPosition{Vec3::ZERO}; + cc::Quaternion _worldRotation{Quaternion::identity()}; + cc::Vec3 _worldScale{Vec3::ONE}; + // + Vec3 _euler{0, 0, 0}; + + // + + IntrusivePtr _userData; + friend class NodeActivator; + friend class Scene; + + // Used to shared memory of Node._uiProps._uiTransformDirty. + uint32_t *_uiTransformDirty{nullptr}; + + 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, CallbackInfoBase::ID &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, CallbackInfoBase::ID &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, CallbackInfoBase::ID &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, CallbackInfoBase::ID &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) { + CallbackInfoBase::ID unusedID{0}; + on(type, callback, unusedID, useCapture); +} + +template +void Node::on(const CallbacksInvoker::KeyType &type, std::function &&callback, Target *target, bool useCapture) { + CallbackInfoBase::ID 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) { + CallbackInfoBase::ID 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) { + CallbackInfoBase::ID 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, CallbackInfoBase::ID &cbID, bool useCapture) { + _eventProcessor->once(type, callback, cbID, useCapture); +} + +template +void Node::once(const CallbacksInvoker::KeyType &type, std::function &&callback, Target *target, CallbackInfoBase::ID &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, CallbackInfoBase::ID &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, CallbackInfoBase::ID &cbID, bool useCapture) { + _eventProcessor->once(type, callback, target, cbID, useCapture); +} + +template +void Node::once(const CallbacksInvoker::KeyType &type, std::function &&callback, bool useCapture) { + CallbackInfoBase::ID unusedID{0}; + once(type, callback, unusedID, useCapture); +} + +template +void Node::once(const CallbacksInvoker::KeyType &type, std::function &&callback, Target *target, bool useCapture) { + CallbackInfoBase::ID 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) { + CallbackInfoBase::ID 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) { + CallbackInfoBase::ID 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/native/cocos/core/scene-graph/NodeEnum.cpp b/native/cocos/core/scene-graph/NodeEnum.cpp new file mode 100644 index 0000000000..a22483538b --- /dev/null +++ b/native/cocos/core/scene-graph/NodeEnum.cpp @@ -0,0 +1,24 @@ +/**************************************************************************** + 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. + ****************************************************************************/ diff --git a/native/cocos/scene/MorphModel.h b/native/cocos/core/scene-graph/NodeEnum.h similarity index 77% rename from native/cocos/scene/MorphModel.h rename to native/cocos/core/scene-graph/NodeEnum.h index 78482e4bb1..9ec32ffede 100644 --- a/native/cocos/scene/MorphModel.h +++ b/native/cocos/core/scene-graph/NodeEnum.h @@ -24,18 +24,24 @@ ****************************************************************************/ #pragma once +#include "base/TypeDef.h" -#include "scene/Model.h" namespace cc { -namespace scene { -class MorphModel : public Model { -public: - MorphModel() = default; - MorphModel(const MorphModel &) = delete; - MorphModel(MorphModel &&) = delete; - ~MorphModel() override = default; - MorphModel &operator=(const MorphModel &) = delete; - MorphModel &operator=(MorphModel &&) = delete; + +enum class NodeSpace { + LOCAL, + WORLD }; -} // namespace scene -} // namespace cc \ No newline at end of file + +enum class TransformBit : uint32_t { + NONE = 0, + POSITION = (1 << 0), + ROTATION = (1 << 1), + SCALE = (1 << 2), + RS = ROTATION | SCALE, + TRS = POSITION | ROTATION | SCALE, + TRS_MASK = ~TRS, +}; +CC_ENUM_BITWISE_OPERATORS(TransformBit); + +} // namespace cc diff --git a/native/cocos/core/scene-graph/NodeEvent.cpp b/native/cocos/core/scene-graph/NodeEvent.cpp new file mode 100644 index 0000000000..345333253f --- /dev/null +++ b/native/cocos/core/scene-graph/NodeEvent.cpp @@ -0,0 +1,60 @@ +/**************************************************************************** + 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/NodeEvent.h" + +namespace cc { + +// Internal NodeEventType : 0~99 +// Internal EventTypesToJS : 100~199 +// Internal Game event : 200~299 +// Internal Director Event Type: 300~399 +const CallbacksInvoker::KeyType NodeEventType::TOUCH_START{0}; //{"touch-start"}; +const CallbacksInvoker::KeyType NodeEventType::TOUCH_MOVE{1}; //{"touch-move"}; +const CallbacksInvoker::KeyType NodeEventType::TOUCH_END{2}; //{"touch-end"}; +const CallbacksInvoker::KeyType NodeEventType::TOUCH_CANCEL{3}; //{"touch-cancel"}; +const CallbacksInvoker::KeyType NodeEventType::MOUSE_DOWN{4}; //{"mouse-down"}; +const CallbacksInvoker::KeyType NodeEventType::MOUSE_MOVE{5}; //{"mouse-move"}; +const CallbacksInvoker::KeyType NodeEventType::MOUSE_UP{6}; //{"mouse-up"}; +const CallbacksInvoker::KeyType NodeEventType::MOUSE_WHEEL{7}; //{"mouse-wheel"}; +const CallbacksInvoker::KeyType NodeEventType::MOUSE_ENTER{8}; //{"mouse-enter"}; +const CallbacksInvoker::KeyType NodeEventType::MOUSE_LEAVE{9}; //{"mouse-leave"}; +const CallbacksInvoker::KeyType NodeEventType::KEY_DOWN{10}; //{"keydown"}; +const CallbacksInvoker::KeyType NodeEventType::KEY_UP{11}; //{"keyup"}; +const CallbacksInvoker::KeyType NodeEventType::DEVICEMOTION{12}; //{"devicemotion"}; +const CallbacksInvoker::KeyType NodeEventType::TRANSFORM_CHANGED{13}; //{"transform-changed"}; +const CallbacksInvoker::KeyType NodeEventType::SCENE_CHANGED_FOR_PERSISTS{14}; //{"scene-changed-for-persists"}; +const CallbacksInvoker::KeyType NodeEventType::SIZE_CHANGED{15}; //{"size-changed"}; +const CallbacksInvoker::KeyType NodeEventType::ANCHOR_CHANGED{16}; //{"anchor-changed"}; +const CallbacksInvoker::KeyType NodeEventType::COLOR_CHANGED{17}; //{"color-changed"}; +const CallbacksInvoker::KeyType NodeEventType::CHILD_ADDED{18}; //{"child-added"}; +const CallbacksInvoker::KeyType NodeEventType::CHILD_REMOVED{19}; //{"child-removed"}; +const CallbacksInvoker::KeyType NodeEventType::PARENT_CHANGED{20}; //{"parent-changed"}; +const CallbacksInvoker::KeyType NodeEventType::NODE_DESTROYED{21}; //{"node-destroyed"}; +const CallbacksInvoker::KeyType NodeEventType::LAYER_CHANGED{22}; //{"layer-changed"}; +const CallbacksInvoker::KeyType NodeEventType::SIBLING_ORDER_CHANGED{23}; //{"sibling-order-changed"}; +const CallbacksInvoker::KeyType NodeEventType::ACTIVE_IN_HIERARCHY_CHANGED{24}; //{"active-in-hierarchy-changed"}; + +} // namespace cc diff --git a/native/cocos/core/scene-graph/NodeEvent.h b/native/cocos/core/scene-graph/NodeEvent.h new file mode 100644 index 0000000000..b5a97321f0 --- /dev/null +++ b/native/cocos/core/scene-graph/NodeEvent.h @@ -0,0 +1,61 @@ +/**************************************************************************** + 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 +#include "core/event/CallbacksInvoker.h" + +namespace cc { + +class NodeEventType { +public: + static const CallbacksInvoker::KeyType TOUCH_START; + static const CallbacksInvoker::KeyType TOUCH_MOVE; + static const CallbacksInvoker::KeyType TOUCH_END; + static const CallbacksInvoker::KeyType TOUCH_CANCEL; + static const CallbacksInvoker::KeyType MOUSE_DOWN; + static const CallbacksInvoker::KeyType MOUSE_MOVE; + static const CallbacksInvoker::KeyType MOUSE_UP; + static const CallbacksInvoker::KeyType MOUSE_WHEEL; + static const CallbacksInvoker::KeyType MOUSE_ENTER; + static const CallbacksInvoker::KeyType MOUSE_LEAVE; + static const CallbacksInvoker::KeyType KEY_DOWN; + static const CallbacksInvoker::KeyType KEY_UP; + static const CallbacksInvoker::KeyType DEVICEMOTION; + static const CallbacksInvoker::KeyType TRANSFORM_CHANGED; + static const CallbacksInvoker::KeyType SCENE_CHANGED_FOR_PERSISTS; + static const CallbacksInvoker::KeyType SIZE_CHANGED; + static const CallbacksInvoker::KeyType ANCHOR_CHANGED; + static const CallbacksInvoker::KeyType COLOR_CHANGED; + static const CallbacksInvoker::KeyType CHILD_ADDED; + static const CallbacksInvoker::KeyType CHILD_REMOVED; + static const CallbacksInvoker::KeyType PARENT_CHANGED; + static const CallbacksInvoker::KeyType NODE_DESTROYED; + static const CallbacksInvoker::KeyType LAYER_CHANGED; + static const CallbacksInvoker::KeyType SIBLING_ORDER_CHANGED; + static const CallbacksInvoker::KeyType ACTIVE_IN_HIERARCHY_CHANGED; +}; + +} // namespace cc diff --git a/native/cocos/core/scene-graph/NodeEventProcessor.cpp b/native/cocos/core/scene-graph/NodeEventProcessor.cpp new file mode 100644 index 0000000000..b7e9e2f82a --- /dev/null +++ b/native/cocos/core/scene-graph/NodeEventProcessor.cpp @@ -0,0 +1,561 @@ +/**************************************************************************** + 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/NodeEventProcessor.h" +// #include "2d/framework/UITransform.h" +// #include "core/Director.h" +//#include "core/components/Component.h" +#include "core/scene-graph/Node.h" +//#include "core/scene-graph/NodeUIProperties.h" +#include "math/Vec2.h" + +namespace { +std::vector cachedArray(16); +cc::Node * currentHovered = nullptr; +cc::Vec2 pos; + +//bool touchStartHandler(cc::event::EventListener *listener, cc::event::Touch *touch, cc::event::Event *event) { +// auto *touchEvent = static_cast(event); +// auto *node = dynamic_cast(listener->owner); +// if (node == nullptr || !node->getUIProps()->getUITransformComp()) { +// return false; +// } +// +// pos = touch->getUILocation(); +// +// if (node->getUIProps()->getUITransformComp()->isHit(pos)) { +// touchEvent->setEventName(cc::NodeEventType::TOUCH_START); +// touchEvent->setTouch(touch); +// touchEvent->setUseBubbles(true); +// node->dispatchEvent(touchEvent); +// return true; +// } +// +// return false; +//} +// +//void touchMoveHandler(cc::event::EventListener *listener, cc::event::Touch *touch, cc::event::Event *event) { +// auto *touchEvent = static_cast(event); +// auto *node = dynamic_cast(listener->owner); +// if (node == nullptr || !node->getUIProps()->getUITransformComp()) { +// return; +// } +// +// touchEvent->setEventName(cc::NodeEventType::TOUCH_MOVE); +// touchEvent->setTouch(touch); +// touchEvent->setUseBubbles(true); +// node->dispatchEvent(touchEvent); +//} +// +//void touchEndHandler(cc::event::EventListener *listener, cc::event::Touch *touch, cc::event::Event *event) { +// auto *touchEvent = static_cast(event); +// auto *node = dynamic_cast(listener->owner); +// if (node == nullptr || !node->getUIProps()->getUITransformComp()) { +// return; +// } +// +// pos = touch->getUILocation(); +// +// if (node->getUIProps()->getUITransformComp()->isHit(pos)) { +// event->setEventName(cc::NodeEventType::TOUCH_END); +// } else { +// event->setEventName(cc::NodeEventType::TOUCH_CANCEL); +// } +// +// touchEvent->setTouch(touch); +// touchEvent->setUseBubbles(true); +// node->dispatchEvent(touchEvent); +//} +// +//void touchCancelHandler(cc::event::EventListener *listener, cc::event::Touch *touch, cc::event::Event *event) { +// auto *touchEvent = static_cast(event); +// auto *node = dynamic_cast(listener->owner); +// if (node == nullptr || !node->getUIProps()->getUITransformComp()) { +// return; +// } +// +// touchEvent->setEventName(cc::NodeEventType::TOUCH_CANCEL); +// touchEvent->setTouch(touch); +// touchEvent->setUseBubbles(true); +// node->dispatchEvent(event); +//} +// +//void mouseDownHandler(cc::event::EventListener *listener, cc::event::EventMouse *mouseEvent) { +// auto *node = dynamic_cast(listener->owner); +// if (node == nullptr || !node->getUIProps()->getUITransformComp()) { +// return; +// } +// +// pos = mouseEvent->getUILocation(); +// +// if (node->getUIProps()->getUITransformComp()->isHit(pos)) { +// mouseEvent->setEventName(cc::NodeEventType::MOUSE_DOWN); +// mouseEvent->setUseBubbles(true); +// node->dispatchEvent(mouseEvent); +// } +//} +// +//void mouseMoveHandler(cc::event::EventListener *listener, cc::event::EventMouse *mouseEvent) { +// auto *node = dynamic_cast(listener->owner); +// if (node == nullptr || !node->getUIProps()->getUITransformComp()) { +// return; +// } +// +// pos = mouseEvent->getUILocation(); +// +// if (node->getUIProps()->getUITransformComp()->isHit(pos)) { +// if (!listener->_previousIn) { +// // Fix issue when hover node switched, previous hovered node won't get MOUSE_LEAVE notification +// if (currentHovered && currentHovered->getEventProcessor()->getMouseListener()) { +// mouseEvent->setEventName(cc::NodeEventType::MOUSE_LEAVE); +// currentHovered->dispatchEvent(mouseEvent); +// if (currentHovered->getEventProcessor()->getMouseListener()) { +// currentHovered->getEventProcessor()->getMouseListener()->_previousIn = false; +// } +// } +// currentHovered = node; +// mouseEvent->setEventName(cc::NodeEventType::MOUSE_ENTER); +// node->dispatchEvent(mouseEvent); +// listener->_previousIn = true; +// } +// mouseEvent->setEventName(cc::NodeEventType::MOUSE_MOVE); +// mouseEvent->setUseBubbles(true); +// node->dispatchEvent(mouseEvent); +// } else if (listener->_previousIn) { +// mouseEvent->setEventName(cc::NodeEventType::MOUSE_LEAVE); +// node->dispatchEvent(mouseEvent); +// listener->_previousIn = false; +// currentHovered = nullptr; +// } else { +// // continue dispatching +// return; +// } +// +// // Event processed, cleanup +// mouseEvent->setPropagationStopped(true); +//} +//void mouseUpHandler(cc::event::EventListener *listener, cc::event::EventMouse *mouseEvent) { +// auto *node = dynamic_cast(listener->owner); +// if (node == nullptr || !node->getUIProps()->getUITransformComp()) { +// return; +// } +// +// pos = mouseEvent->getUILocation(); +// +// if (node->getUIProps()->getUITransformComp()->isHit(pos)) { +// mouseEvent->setEventName(cc::NodeEventType::MOUSE_UP); +// mouseEvent->setUseBubbles(true); +// node->dispatchEvent(mouseEvent); +// mouseEvent->setPropagationStopped(true); +// } +//} +// +//void mouseWheelHandler(cc::event::EventListener *listener, cc::event::EventMouse *mouseEvent) { +// auto *node = dynamic_cast(listener->owner); +// if (node == nullptr || !node->getUIProps()->getUITransformComp()) { +// return; +// } +// +// pos = mouseEvent->getUILocation(); +// +// if (node->getUIProps()->getUITransformComp()->isHit(pos)) { +// mouseEvent->setEventName(cc::NodeEventType::MOUSE_WHEEL); +// mouseEvent->setUseBubbles(true); +// node->dispatchEvent(mouseEvent); +// mouseEvent->setPropagationStopped(true); +// } +//} +// +//void doDispatchEvent(cc::Node *owner, cc::event::Event *event) { +// cc::Node *target = nullptr; +// event->setTarget(owner); +// +// // Event.CAPTURING_PHASE +// cachedArray.clear(); +// owner->getEventProcessor()->getCapturingTargets(event->getEventName(), cachedArray); +// // capturing +// event->setEventPhase(cc::event::Event::Phase::CAPTURING); +// for (auto i = static_cast(cachedArray.size() - 1); i >= 0; --i) { +// target = cachedArray[i]; +// if (target->getEventProcessor()->getCapturingTargets()) { +// event->setCurrentTarget(target); +// // fire event +// target->getEventProcessor()->getCapturingTargets()->emit(event->getEventName(), event, cachedArray); +// // check if propagation stopped +// if (event->isPropagationStopped()) { +// cachedArray.clear(); +// return; +// } +// } +// } +// cachedArray.clear(); +// +// // Event.AT_TARGET +// // checks if destroyed in capturing callbacks +// event->setEventPhase(cc::event::Event::Phase::AT_TARGET); +// event->setCurrentTarget(owner); +// if (owner->getEventProcessor()->getCapturingTargets()) { +// owner->getEventProcessor()->getCapturingTargets()->emit(event->getEventName(), event); +// } +// if (!event->isPropagationImmediateStopped() && owner->getEventProcessor()->getBubblingTargets()) { +// owner->getEventProcessor()->getBubblingTargets()->emit(event->getEventName(), event); +// } +// +// if (!event->isPropagationStopped() && event->isUseBubbles()) { +// // Event.BUBBLING_PHASE +// owner->getEventProcessor()->getBubblingTargets(event->getEventName(), cachedArray); +// // propagate +// event->setEventPhase(cc::event::Event::Phase::BUBBLING); +// for (uint32_t i = 0; i < cachedArray.size(); ++i) { +// target = cachedArray[i]; +// if (target->getEventProcessor()->getBubblingTargets()) { +// event->setCurrentTarget(target); +// // fire event +// target->getEventProcessor()->getBubblingTargets()->emit(event->getEventName(), event); +// // check if propagation stopped +// if (event->isPropagationStopped()) { +// cachedArray.clear(); +// return; +// } +// } +// } +// } +// cachedArray.clear(); +//} +// +//template ::value, T>> +//std::vector searchComponentsInParent(cc::Node *node) { +// index_t index = 0; +// std::vector list; +// +// for (cc::Node *curr = node; curr != nullptr && cc::Node::isNode(curr); curr = curr->getParent(), ++index) { +// auto *comp = curr->getComponent(); +// if (comp != nullptr) { +// list.emplace_back(); +// auto &info = list.back(); +// info.index = index; +// info.comp = comp; +// } +// } +// return list.empty() ? std::vector() : list; +//} + +} // namespace +namespace cc { +NodeEventProcessor::NodeEventProcessor(Node *node) : _node(node) {} + +NodeEventProcessor::~NodeEventProcessor() { + delete _bubblingTargets; + delete _capturingTargets; + // delete _touchListener; + // delete _mouseListener; +} + +bool NodeEventProcessor::checkListeners(cc::Node *node, const std::vector &events) { + if (!node->isPersistNode()) { + if (node->getEventProcessor()->_bubblingTargets) { + for (const auto &event : events) { + if (node->getEventProcessor()->_bubblingTargets->hasEventListener(event)) { + return true; + } + } + } + if (node->getEventProcessor()->_bubblingTargets) { + for (const auto &event : events) { + if (node->getEventProcessor()->_bubblingTargets->hasEventListener(event)) { + return true; + } + } + } + return false; + } + return true; +} + +void NodeEventProcessor::reattach() { + // std::vector currMask; + // _node->walk( + // [&](Node *node) { + // if (currMask.empty()) { + // currMask = searchComponentsInParent(node); + // } + // if (node->getEventProcessor()->_touchListener != nullptr) { + // node->getEventProcessor()->_touchListener->mask = currMask; + // } + // if (node->getEventProcessor()->_mouseListener != nullptr) { + // node->getEventProcessor()->_mouseListener->mask = currMask; + // } + // }); +} + +void NodeEventProcessor::destroy() { + if (currentHovered == _node) { + currentHovered = nullptr; + } + + // Remove all event listeners if necessary + // if (_touchListener || _mouseListener) { + // event::EventManager::getInstance()->removeEventListenersForTarget(_node); + // if (_touchListener) { + // _touchListener->owner = nullptr; + // _touchListener->mask.clear(); + // _touchListener = nullptr; + // } + // if (_mouseListener) { + // _mouseListener->owner = nullptr; + // _mouseListener->mask.clear(); + // _mouseListener = nullptr; + // } + // } + + if (_capturingTargets) _capturingTargets->offAll(); + if (_bubblingTargets) _bubblingTargets->offAll(); +} + +void NodeEventProcessor::off(const CallbacksInvoker::KeyType &type, void *target, bool /*useCapture*/ /* = false*/) { + // bool touchEventExist = std::find(TOUCH_EVENTS.begin(), TOUCH_EVENTS.end(), type) != TOUCH_EVENTS.end(); + // bool mouseEventExist = std::find(MOUSE_EVENTS.begin(), MOUSE_EVENTS.end(), type) != MOUSE_EVENTS.end(); + // if (touchEventExist || mouseEventExist) { + // offDispatch(type, target, useCapture); + // + // if (touchEventExist) { + // if (_touchListener && !checkListeners(_node, TOUCH_EVENTS)) { + // event::EventManager::getInstance()->removeEventListener(_touchListener); + // _touchListener = nullptr; + // } + // } else if (mouseEventExist) { + // if (_mouseListener && !checkListeners(_node, MOUSE_EVENTS)) { + // event::EventManager::getInstance()->removeEventListener(_mouseListener); + // _mouseListener = nullptr; + // } + // } + // } else + if (_bubblingTargets != nullptr) { + _bubblingTargets->offAll(type, target); + } +} + +void NodeEventProcessor::off(const CallbacksInvoker::KeyType &type, CallbackInfoBase::ID cbID, bool /*useCapture*/) { + // bool touchEventExist = std::find(TOUCH_EVENTS.begin(), TOUCH_EVENTS.end(), type) != TOUCH_EVENTS.end(); + // bool mouseEventExist = std::find(MOUSE_EVENTS.begin(), MOUSE_EVENTS.end(), type) != MOUSE_EVENTS.end(); + // if (touchEventExist || mouseEventExist) { + // offDispatch(type, cbID, useCapture); + // + // if (touchEventExist) { + // if (_touchListener && !checkListeners(_node, TOUCH_EVENTS)) { + // event::EventManager::getInstance()->removeEventListener(_touchListener); + // _touchListener = nullptr; + // } + // } else if (mouseEventExist) { + // if (_mouseListener && !checkListeners(_node, MOUSE_EVENTS)) { + // event::EventManager::getInstance()->removeEventListener(_mouseListener); + // _mouseListener = nullptr; + // } + // } + // } else + if (_bubblingTargets != nullptr) { + _bubblingTargets->off(type, cbID); + } +} + +//void NodeEventProcessor::dispatchEvent(event::Event *event) { +// doDispatchEvent(_node, event); +// cachedArray.clear(); +//} + +bool NodeEventProcessor::hasEventListener(const CallbacksInvoker::KeyType &type) const { + bool has = false; + if (_bubblingTargets) { + has = _bubblingTargets->hasEventListener(type); + } + if (!has && _capturingTargets) { + has = _capturingTargets->hasEventListener(type); + } + return has; +} + +bool NodeEventProcessor::hasEventListener(const CallbacksInvoker::KeyType &type, CallbackInfoBase::ID cbID) const { + bool has = false; + if (_bubblingTargets) { + has = _bubblingTargets->hasEventListener(type, cbID); + } + if (!has && _capturingTargets) { + has = _capturingTargets->hasEventListener(type, cbID); + } + return has; +} + +bool NodeEventProcessor::hasEventListener(const CallbacksInvoker::KeyType &type, void *target) const { + bool has = false; + if (_bubblingTargets) { + has = _bubblingTargets->hasEventListener(type, target); + } + if (!has && _capturingTargets) { + has = _capturingTargets->hasEventListener(type, target); + } + return has; +} +bool NodeEventProcessor::hasEventListener(const CallbacksInvoker::KeyType &type, void *target, CallbackInfoBase::ID cbID) const { + bool has = false; + if (_bubblingTargets) { + has = _bubblingTargets->hasEventListener(type, target, cbID); + } + if (!has && _capturingTargets) { + has = _capturingTargets->hasEventListener(type, target, cbID); + } + return has; +} + +void NodeEventProcessor::targetOff(const CallbacksInvoker::KeyType &target) { + if (_capturingTargets) { + _capturingTargets->offAll(target); + } + if (_bubblingTargets) { + _bubblingTargets->offAll(target); + } + + // if (_touchListener && !checkListeners(_node, TOUCH_EVENTS)) { + // event::EventManager::getInstance()->removeEventListener(_touchListener); + // _touchListener = nullptr; + // } + // if (_mouseListener && !checkListeners(_node, MOUSE_EVENTS)) { + // event::EventManager::getInstance()->removeEventListener(_mouseListener); + // _mouseListener = nullptr; + // } +} + +void NodeEventProcessor::getCapturingTargets(const CallbacksInvoker::KeyType &type, std::vector &targets) const { + auto *parent = _node->getParent(); + while (parent != nullptr) { + if (parent->getEventProcessor()->_capturingTargets != nullptr && parent->getEventProcessor()->_capturingTargets->hasEventListener(type)) { + targets.emplace_back(parent); + } + parent = parent->getParent(); + } +} + +void NodeEventProcessor::getBubblingTargets(const CallbacksInvoker::KeyType &type, std::vector &targets) const { + auto *parent = _node->getParent(); + while (parent != nullptr) { + if (parent->getEventProcessor()->_bubblingTargets != nullptr && parent->getEventProcessor()->_bubblingTargets->hasEventListener(type)) { + targets.emplace_back(parent); + } + parent = parent->getParent(); + } +} + +//bool NodeEventProcessor::checknSetupSysEvent(const CallbacksInvoker::KeyType &type) { +// bool newAdded = false; +// bool forDispatch = false; +// // just for ui +// +// auto *eventManager = event::EventManager::getInstance(); +// if (std::find(TOUCH_EVENTS.begin(), TOUCH_EVENTS.end(), type) != TOUCH_EVENTS.end()) { +// if (_touchListener != nullptr) { +// _touchListener = event::EventListenerTouchOneByOne::create(); +// _touchListener->setSwallowTouches(true); +// _touchListener->owner = _node; +// //cjh TODO: _touchListener->mask = searchComponentsInParent(_node, NodeEventProcessor._comp), +// event::EventListener *listener = _touchListener; +// _touchListener->onTouchBegan = [=](event::Touch *touch, event::Event *event) -> bool { +// return touchStartHandler(listener, touch, event); +// }; +// _touchListener->onTouchMoved = [=](event::Touch *touch, event::Event *event) { +// touchMoveHandler(listener, touch, event); +// }; +// _touchListener->onTouchEnded = [=](event::Touch *touch, event::Event *event) { +// touchEndHandler(listener, touch, event); +// }; +// _touchListener->onTouchCancelled = [=](event::Touch *touch, event::Event *event) { +// touchCancelHandler(listener, touch, event); +// }; +// eventManager->addEventListenerWithSceneGraphPriority(_touchListener, _node); +// newAdded = true; +// } +// forDispatch = true; +// } else if (std::find(MOUSE_EVENTS.begin(), MOUSE_EVENTS.end(), type) != MOUSE_EVENTS.end()) { +// if (_mouseListener != nullptr) { +// _mouseListener = event::EventListenerMouse::create(); +// _mouseListener->_previousIn = false; +// _mouseListener->owner = _node; +// //cjh _mouseListener->mask = searchComponentsInParent(_node, NodeEventProcessor._comp), +// +// event::EventListener *listener = _mouseListener; +// _mouseListener->onMouseDown = [=](event::EventMouse *event) { +// mouseDownHandler(listener, event); +// }; +// +// _mouseListener->onMouseMove = [=](event::EventMouse *event) { +// mouseMoveHandler(listener, event); +// }; +// +// _mouseListener->onMouseUp = [=](event::EventMouse *event) { +// mouseUpHandler(listener, event); +// }; +// +// _mouseListener->onMouseScroll = [=](event::EventMouse *event) { +// mouseWheelHandler(listener, event); +// }; +// +// eventManager->addEventListenerWithSceneGraphPriority(_mouseListener, _node); +// newAdded = true; +// } +// forDispatch = true; +// } +// // TODO(xwx): not sure use scheduler +// // if (newAdded && !_node->isActiveInHierarchy()) { +// // Director::getInstance()->getScheduler()->schedule([](){ +// // if (!_node->isActiveInHierarchy()) { +// // eventManager.pauseTarget(_node); +// // } +// // }, _node, 0, 0, 0, false); +// // } +// return forDispatch; +//} + +void NodeEventProcessor::offDispatch(const CallbacksInvoker::KeyType &type, CallbackInfoBase::ID cbID, bool useCapture) { + if (cbID == 0) { + if (_capturingTargets != nullptr) { + _capturingTargets->offAll(type); + } + if (_bubblingTargets != nullptr) { + _bubblingTargets->offAll(type); + } + } else { + CallbacksInvoker *listeners = useCapture ? _capturingTargets : _bubblingTargets; + if (listeners != nullptr) { + listeners->off(type, cbID); + } + } +} + +void NodeEventProcessor::offDispatch(const CallbacksInvoker::KeyType &type, void *target, bool useCapture) { + CallbacksInvoker *listeners = useCapture ? _capturingTargets : _bubblingTargets; + if (listeners != nullptr) { + listeners->offAll(type, target); + } +} + +} // namespace cc diff --git a/native/cocos/core/scene-graph/NodeEventProcessor.h b/native/cocos/core/scene-graph/NodeEventProcessor.h new file mode 100644 index 0000000000..abf9fb2f0b --- /dev/null +++ b/native/cocos/core/scene-graph/NodeEventProcessor.h @@ -0,0 +1,436 @@ +/**************************************************************************** + 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 +#include +#include "cocos/base/Any.h" +#include "core/event/CallbacksInvoker.h" +//#include "core/event/Event.h" +#include "core/scene-graph/NodeEvent.h" + +namespace cc { +const std::vector TOUCH_EVENTS{ + cc::NodeEventType::TOUCH_START, + cc::NodeEventType::TOUCH_MOVE, + cc::NodeEventType::TOUCH_END, + cc::NodeEventType::TOUCH_CANCEL}; + +const std::vector MOUSE_EVENTS{ + cc::NodeEventType::MOUSE_DOWN, + cc::NodeEventType::MOUSE_ENTER, + cc::NodeEventType::MOUSE_MOVE, + cc::NodeEventType::MOUSE_LEAVE, + cc::NodeEventType::MOUSE_UP, + cc::NodeEventType::MOUSE_WHEEL}; + +class Node; + +class NodeEventProcessor final { +public: + NodeEventProcessor() = default; + explicit NodeEventProcessor(Node *node); + ~NodeEventProcessor(); + + inline Node *getNode() { return _node; } + void reattach(); + void destroy(); + + /** + * @zh + * 分发事件到事件流中。 + * + * @param event - 分派到事件流中的事件对象。 + */ + // void dispatchEvent(event::Event *event); + + bool hasEventListener(const CallbacksInvoker::KeyType &type) const; + + bool hasEventListener(const CallbacksInvoker::KeyType &type, CallbackInfoBase::ID cbID) const; + + bool hasEventListener(const CallbacksInvoker::KeyType &type, void *target) const; + + bool hasEventListener(const CallbacksInvoker::KeyType &type, void *target, CallbackInfoBase::ID cbID) const; + + template + bool hasEventListener(const CallbacksInvoker::KeyType &type, void (Target::*memberFn)(Args...), Target *target) const; + + static bool checkListeners(Node *node, const std::vector &events); + + template + void on(const CallbacksInvoker::KeyType &type, std::function &&callback, CallbackInfoBase::ID &cbID, bool useCapture = false); + + 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, Target *target, CallbackInfoBase::ID &cbID, bool useCapture = false); + + template + std::enable_if_t::value, void> + on(const CallbacksInvoker::KeyType &type, LambdaType &&callback, Target *target, CallbackInfoBase::ID &cbID, bool useCapture = false); + + template + std::enable_if_t::value, void> + on(const CallbacksInvoker::KeyType &type, LambdaType &&callback, CallbackInfoBase::ID &cbID, 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, CallbackInfoBase::ID &cbID, bool useCapture = false); + + template + void once(const CallbacksInvoker::KeyType &type, std::function &&callback, Target *target, CallbackInfoBase::ID &cbID, bool useCapture = false); + + template + std::enable_if_t::value, void> + once(const CallbacksInvoker::KeyType &type, LambdaType &&callback, Target *target, CallbackInfoBase::ID &cbID, bool useCapture = false); + + template + std::enable_if_t::value, void> + once(const CallbacksInvoker::KeyType &type, LambdaType &&callback, CallbackInfoBase::ID &cbID, bool useCapture = false); + + void off(const CallbacksInvoker::KeyType &type, CallbackInfoBase::ID 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); + + /** + * @zh + * 通过事件名发送自定义事件 + * + * @param type - event type + * @param args - The arguments to be passed to the callback + */ + template + void emit(const CallbacksInvoker::KeyType &type, Args &&...args); + + void targetOff(const CallbacksInvoker::KeyType &target); + + void getCapturingTargets(const CallbacksInvoker::KeyType &type, std::vector &targets) const; + void getBubblingTargets(const CallbacksInvoker::KeyType &type, std::vector &targets) const; + + inline CallbacksInvoker *getBubblingTargets() const { return _bubblingTargets; } + inline CallbacksInvoker *getCapturingTargets() const { return _capturingTargets; } + // inline event::EventListener *getTouchListener() const { return _touchListener; } + // inline event::EventListener *getMouseListener() const { return _mouseListener; } + +private: + /** + * @zh + * 节点冒泡事件监听器 + */ + CallbacksInvoker *_bubblingTargets{nullptr}; + + /** + * @zh + * 节点捕获事件监听器 + */ + CallbacksInvoker *_capturingTargets{nullptr}; + + // /** + // * @zh + // * 触摸监听器 + // */ + // event::EventListenerTouchOneByOne *_touchListener{nullptr}; + // + // /** + // * @zh + // * 鼠标监听器 + // */ + // event::EventListenerMouse *_mouseListener{nullptr}; + + Node *_node{nullptr}; + + // bool checknSetupSysEvent(const CallbacksInvoker::KeyType &type); + + template + void onDispatch(const CallbacksInvoker::KeyType &type, std::function &&callback, CallbackInfoBase::ID &cbID, bool useCapture = false); + + template + void onDispatch(const CallbacksInvoker::KeyType &type, void (Target::*memberFn)(Args...), Target *target, bool useCapture = false); + + template + void onDispatch(const CallbacksInvoker::KeyType &type, std::function &&callback, Target *target, CallbackInfoBase::ID &cbID, bool useCapture = false); + + void offDispatch(const CallbacksInvoker::KeyType &type, CallbackInfoBase::ID cbID, bool useCapture = false); + void offDispatch(const CallbacksInvoker::KeyType &type, void *target, bool useCapture = false); + + template + void offDispatch(const CallbacksInvoker::KeyType &type, void (Target::*memberFn)(Args...), Target *target, bool useCapture = false); + + CC_DISALLOW_COPY_MOVE_ASSIGN(NodeEventProcessor); +}; + +template +void NodeEventProcessor::emit(const CallbacksInvoker::KeyType &type, Args &&...args) { + if (_bubblingTargets != nullptr) { + _bubblingTargets->emit(type, std::forward(args)...); + } +} +template +void NodeEventProcessor::onDispatch(const CallbacksInvoker::KeyType &type, std::function &&callback, CallbackInfoBase::ID &cbID, bool useCapture) { + CallbacksInvoker *listeners = nullptr; + if (useCapture) { + if (_capturingTargets == nullptr) { + _capturingTargets = new CallbacksInvoker(); + } + listeners = _capturingTargets; + } else { + if (_bubblingTargets == nullptr) { + _bubblingTargets = new CallbacksInvoker(); + } + listeners = _bubblingTargets; + } + if (!listeners->hasEventListener(type)) { + listeners->on(type, std::forward>(callback), cbID); + } +} + +template +void NodeEventProcessor::onDispatch(const CallbacksInvoker::KeyType &type, std::function &&callback, Target *target, CallbackInfoBase::ID &cbID, bool useCapture) { + CallbacksInvoker *listeners = nullptr; + if (useCapture) { + if (_capturingTargets == nullptr) { + _capturingTargets = new CallbacksInvoker(); + } + listeners = _capturingTargets; + } else { + if (_bubblingTargets == nullptr) { + _bubblingTargets = new CallbacksInvoker(); + } + listeners = _bubblingTargets; + } + if (!listeners->hasEventListener(type)) { + listeners->on(type, std::forward>(callback), target, cbID); + } +} + +template +void NodeEventProcessor::onDispatch(const CallbacksInvoker::KeyType &type, void (Target::*memberFn)(Args...), Target *target, bool useCapture) { + CallbacksInvoker *listeners = nullptr; + if (useCapture) { + if (_capturingTargets == nullptr) { + _capturingTargets = new CallbacksInvoker(); + } + listeners = _capturingTargets; + } else { + if (_bubblingTargets == nullptr) { + _bubblingTargets = new CallbacksInvoker(); + } + listeners = _bubblingTargets; + } + if (!listeners->hasEventListener(type)) { + listeners->on(type, memberFn, target); + } +} + +template +void NodeEventProcessor::on(const CallbacksInvoker::KeyType &type, std::function &&callback, CallbackInfoBase::ID &cbID, bool /*useCapture*/) { + // bool forDispatch = checknSetupSysEvent(type); + // if (forDispatch) { + // onDispatch(type, std::forward>(callback), cbID, useCapture); + // } else + { + if (_bubblingTargets == nullptr) { + _bubblingTargets = new CallbacksInvoker(); + } + _bubblingTargets->on(type, std::forward>(callback), cbID); + } +} + +template +void NodeEventProcessor::on(const CallbacksInvoker::KeyType &type, std::function &&callback, Target * /*target*/, CallbackInfoBase::ID &cbID, bool /*useCapture*/) { + // bool forDispatch = checknSetupSysEvent(type); + // if (forDispatch) { + // onDispatch(type, std::forward>(callback), target, cbID, useCapture); + // } else + { + if (_bubblingTargets == nullptr) { + _bubblingTargets = new CallbacksInvoker(); + } + _bubblingTargets->on(type, std::forward>(callback), cbID); + } +} + +template +std::enable_if_t::value, void> +NodeEventProcessor::on(const CallbacksInvoker::KeyType &type, LambdaType &&callback, Target *target, CallbackInfoBase::ID &cbID, bool /*useCapture*/) { + // bool forDispatch = checknSetupSysEvent(type); + // if (forDispatch) { + // onDispatch(type, CallbacksInvoker::toFunction(std::forward(callback)), target, cbID, useCapture); + // } else + { + if (_bubblingTargets == nullptr) { + _bubblingTargets = new CallbacksInvoker(); + } + _bubblingTargets->on(type, callback, target, cbID); + } +} + +template +std::enable_if_t::value, void> +NodeEventProcessor::on(const CallbacksInvoker::KeyType &type, LambdaType &&callback, CallbackInfoBase::ID &cbID, bool /*useCapture*/) { + // bool forDispatch = checknSetupSysEvent(type); + // if (forDispatch) { + // onDispatch(type, CallbacksInvoker::toFunction(std::forward(callback)), cbID, useCapture); + // } else + { + if (_bubblingTargets == nullptr) { + _bubblingTargets = new CallbacksInvoker(); + } + _bubblingTargets->on(type, callback, cbID); + } +} + +template +void NodeEventProcessor::on(const CallbacksInvoker::KeyType &type, void (Target::*memberFn)(Args...), Target *target, bool /*useCapture*/) { + using CallbackInfoType = CallbackInfo; + // bool forDispatch = checknSetupSysEvent(type); + // if (forDispatch) { + // onDispatch(type, memberFn, target, useCapture); + // } else + { + if (_bubblingTargets == nullptr) { + _bubblingTargets = new CallbacksInvoker(); + } + _bubblingTargets->on(type, memberFn, target); + } +} + +template +void NodeEventProcessor::once(const CallbacksInvoker::KeyType &type, std::function &&callback, CallbackInfoBase::ID &cbID, bool useCapture /* = false*/) { + once(type, std::forward(callback), nullptr, cbID, useCapture); +} + +template +void NodeEventProcessor::once(const CallbacksInvoker::KeyType &type, void (Target::*memberFn)(Args...), Target *target, bool useCapture) { + CallbacksInvoker *listeners = nullptr; + if (useCapture) { + if (_capturingTargets == nullptr) { + _capturingTargets = new CallbacksInvoker(); + } + listeners = _capturingTargets; + } else { + if (_bubblingTargets == nullptr) { + _bubblingTargets = new CallbacksInvoker(); + } + listeners = _bubblingTargets; + } + + listeners->on(type, memberFn, target, true); + listeners->on( + type, [=](Args... /*unused*/) { off(type, memberFn, target); }, true); +} + +template +void NodeEventProcessor::once(const CallbacksInvoker::KeyType &type, std::function &&callback, Target *target, CallbackInfoBase::ID &cbID, bool useCapture) { + CallbacksInvoker *listeners = nullptr; + if (useCapture) { + if (_capturingTargets == nullptr) { + _capturingTargets = new CallbacksInvoker(); + } + listeners = _capturingTargets; + } else { + if (_bubblingTargets == nullptr) { + _bubblingTargets = new CallbacksInvoker(); + } + listeners = _bubblingTargets; + } + listeners->on(type, std::forward>(callback), target, cbID, true); + CallbackInfoBase::ID cacheID = cbID; + listeners->on( + type, [=](Args... /*unused*/) { off(type, cacheID); }, target, true); +} + +template +std::enable_if_t::value, void> +NodeEventProcessor::once(const CallbacksInvoker::KeyType &type, LambdaType &&callback, Target *target, CallbackInfoBase::ID &cbID, bool useCapture) { + once(type, CallbacksInvoker::toFunction(callback), target, cbID, useCapture); +} + +template +std::enable_if_t::value, void> +NodeEventProcessor::once(const CallbacksInvoker::KeyType &type, LambdaType &&callback, CallbackInfoBase::ID &cbID, bool useCapture) { + once(type, std::forward(callback), nullptr, cbID, useCapture); +} + +template +void NodeEventProcessor::off(const CallbacksInvoker::KeyType &type, void (Target::*memberFn)(Args...), Target *target, bool /*useCapture*/) { + // bool touchEventExist = std::find(TOUCH_EVENTS.begin(), TOUCH_EVENTS.end(), type) != TOUCH_EVENTS.end(); + // bool mouseEventExist = std::find(MOUSE_EVENTS.begin(), MOUSE_EVENTS.end(), type) != MOUSE_EVENTS.end(); + // if (touchEventExist || mouseEventExist) { + // offDispatch(type, memberFn, target, useCapture); + // + // if (touchEventExist) { + // if (_touchListener && !checkListeners(_node, TOUCH_EVENTS)) { + // event::EventManager::getInstance()->removeEventListener(_touchListener); + // _touchListener = nullptr; + // } + // } else if (mouseEventExist) { + // if (_mouseListener && !checkListeners(_node, MOUSE_EVENTS)) { + // event::EventManager::getInstance()->removeEventListener(_mouseListener); + // _mouseListener = nullptr; + // } + // } + // } else + if (_bubblingTargets != nullptr) { + _bubblingTargets->off(type, memberFn, target); + } +} + +template +void NodeEventProcessor::offDispatch(const CallbacksInvoker::KeyType &type, void (Target::*memberFn)(Args...), Target *target, bool useCapture) { + if (memberFn == nullptr) { + if (_capturingTargets != nullptr) { + _capturingTargets->offAll(type, target); + } + if (_bubblingTargets != nullptr) { + _bubblingTargets->offAll(type, target); + } + } else { + CallbacksInvoker *listeners = useCapture ? _capturingTargets : _bubblingTargets; + if (listeners != nullptr) { + listeners->off(type, memberFn, target); + } + } +} + +template +bool NodeEventProcessor::hasEventListener(const CallbacksInvoker::KeyType &type, void (Target::*memberFn)(Args...), Target *target) const { + bool has = false; + if (_bubblingTargets) { + has = _bubblingTargets->hasEventListener(type, memberFn, target); + } + if (!has && _capturingTargets) { + has = _capturingTargets->hasEventListener(type, memberFn, target); + } + return has; +} +} // namespace cc diff --git a/native/cocos/core/scene-graph/Scene.cpp b/native/cocos/core/scene-graph/Scene.cpp new file mode 100644 index 0000000000..1d9abc0c0c --- /dev/null +++ b/native/cocos/core/scene-graph/Scene.cpp @@ -0,0 +1,110 @@ +/**************************************************************************** + 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/Scene.h" +// #include "core/Director.h" +#include "core/Root.h" +//#include "core/scene-graph/NodeActivator.h" + +namespace cc { + +Scene::Scene(const std::string &name) +: Node(name) { + // _activeInHierarchy is initalized to 'false', so doesn't need to set it to false again + // _activeInHierarchy = false; + _renderScene = Root::getInstance()->createScene({}); + // _globals = new SceneGlobals(); +} + +Scene::Scene() : Scene("") {} + +Scene::~Scene() = default; + +void Scene::load() { + if (!_inited) { + //cjh if (TEST) { + // assert(!_activeInHierarchy, 'Should deactivate ActionManager by default'); + // } + // expandNestedPrefabInstanceNode(this); // TODO(xwx): expandNestedPrefabInstanceNode not implement yet + // applyTargetOverrides(this); // TODO(xwx): applyTargetOverrides not implement yet + //cjh _onBatchCreated is implemented in TS now, so comment the following line + // onBatchCreated(false); //cjh EDITOR && _prefabSyncedInLiveReload); + _inited = true; + } + _scene = this; + // static method can't use this as parameter type + walk(Node::setScene); +} + +void Scene::activate(bool active /* = true */) { + //cjh if (EDITOR) { + // // register all nodes to editor + // _registerIfAttached!(active); + // } + // Director::getInstance()->getNodeActivator()->activateNode(this, active); + // The test environment does not currently support the renderer + // if (!TEST) { + _globals->activate(); + if (_renderScene) { + _renderScene->activate(); + } + // } +} + +void Scene::onBatchCreated(bool dontSyncChildPrefab) { + // Moved from Node::onBatchCreated, Node::onBatchCreated only emits event to JS now. + if (_parent) { + index_t idx = getIdxOfChild(_parent->_children, this); + if (idx != CC_INVALID_INDEX) { + _siblingIndex = idx; + } + } + // + + auto len = static_cast(_children.size()); + for (int32_t i = 0; i < len; ++i) { + _children[i]->setSiblingIndex(i); + _children[i]->onBatchCreated(dontSyncChildPrefab); + } +} + +bool Scene::destroy() { + bool success = Super::destroy(); + if (success) { + for (auto &child : _children) { + child->setActive(false); + } + } + + if (_renderScene != nullptr) { + Root::getInstance()->destroyScene(_renderScene); + } + + _active = false; + setActiveInHierarchy(false); + return success; +} + +} // namespace cc diff --git a/native/cocos/core/scene-graph/Scene.h b/native/cocos/core/scene-graph/Scene.h new file mode 100644 index 0000000000..ad43a2bf30 --- /dev/null +++ b/native/cocos/core/scene-graph/Scene.h @@ -0,0 +1,79 @@ +/**************************************************************************** + 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 "core/scene-graph/Node.h" +#include "core/scene-graph/SceneGlobals.h" + +namespace cc { + +namespace scene { +class RenderScene; +} + +class Scene final : public Node { +public: + using Super = Node; + explicit Scene(const std::string &name); + Scene(); + ~Scene() override; + + inline scene::RenderScene *getRenderScene() const { return _renderScene; } + inline SceneGlobals * getSceneGlobals() const { return _globals.get(); } + inline void setSceneGlobals(SceneGlobals *globals) { _globals = globals; } + inline bool isAutoReleaseAssets() const { return _autoReleaseAssets; } + inline void setAutoReleaseAssets(bool val) { _autoReleaseAssets = val; } + + void load(); + void activate(bool active = true); + + void onBatchCreated(bool dontSyncChildPrefab) override; + bool destroy() override; + +protected: + void updateScene() override { _scene = this; } + + scene::RenderScene *_renderScene{nullptr}; + /** + * @en Per-scene level rendering info + * @zh 场景级别的渲染信息 + */ + // @serializable + IntrusivePtr _globals; + bool _inited{false}; + + /** + * @en Indicates whether all (directly or indirectly) static referenced assets of this scene are releasable by default after scene unloading. + * @zh 指示该场景中直接或间接静态引用到的所有资源是否默认在场景切换后自动释放。 + */ + // @serializable + // @editable + bool _autoReleaseAssets{false}; + + CC_DISALLOW_COPY_MOVE_ASSIGN(Scene); +}; + +} // namespace cc diff --git a/native/cocos/scene/Sphere.h b/native/cocos/core/scene-graph/SceneGlobals.cpp similarity index 57% rename from native/cocos/scene/Sphere.h rename to native/cocos/core/scene-graph/SceneGlobals.cpp index 5b45e6c501..603797ce87 100644 --- a/native/cocos/scene/Sphere.h +++ b/native/cocos/core/scene-graph/SceneGlobals.cpp @@ -1,8 +1,8 @@ /**************************************************************************** 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 @@ -10,10 +10,10 @@ 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 @@ -23,42 +23,45 @@ THE SOFTWARE. ****************************************************************************/ -#pragma once - -#include "math/Vec3.h" -#include "scene/AABB.h" -#include "scene/Frustum.h" +#include "core/scene-graph/SceneGlobals.h" +#include "core/Root.h" +#include "scene/Ambient.h" +#include "scene/Fog.h" +#include "scene/Octree.h" +#include "scene/Shadow.h" +#include "scene/Skybox.h" namespace cc { -namespace scene { -class Sphere { -public: - Sphere() = default; - Sphere(const Sphere &) = delete; - Sphere(Sphere &&) = delete; - ~Sphere() = default; - Sphere &operator=(const Sphere &) = delete; - Sphere &operator=(Sphere &&) = delete; +SceneGlobals::SceneGlobals() { + _ambientInfo = new scene::AmbientInfo(); + _shadowInfo = new scene::ShadowsInfo(); + _skyboxInfo = new scene::SkyboxInfo(); + _fogInfo = new scene::FogInfo(); + _octreeInfo = new scene::OctreeInfo(); +} - inline float getRadius() const { return _radius; } - inline const Vec3 &getCenter() const { return _center; } - inline void setCenter(const Vec3 &val) { _center = val; } - inline void setRadius(float val) { _radius = val; } +void SceneGlobals::activate() { + auto *sceneData = Root::getInstance()->getPipeline()->getPipelineSceneData(); + if (_ambientInfo != nullptr) { + _ambientInfo->activate(sceneData->getAmbient()); + } - void define(const AABB &aabb); - void merge(const AABB *aabb); - void merge(const Vec3 &point); - bool interset(const Frustum &frustum) const; - int interset(const Plane &plane) const; - int spherePlane(const Plane &plane); - bool sphereFrustum(const Frustum &frustum) const; - void merge(const Frustum &frustum); + if (_skyboxInfo != nullptr) { + _skyboxInfo->activate(sceneData->getSkybox()); + } -private: - float _radius{-1.0F}; - Vec3 _center; -}; + if (_shadowInfo != nullptr) { + _shadowInfo->activate(sceneData->getShadows()); + } + + if (_fogInfo != nullptr) { + _fogInfo->activate(sceneData->getFog()); + } + + if (_octreeInfo != nullptr) { + _octreeInfo->activate(sceneData->getOctree()); + } +} -} // namespace scene } // namespace cc diff --git a/native/cocos/scene/Frustum.h b/native/cocos/core/scene-graph/SceneGlobals.h similarity index 52% rename from native/cocos/scene/Frustum.h rename to native/cocos/core/scene-graph/SceneGlobals.h index 7c99541a7c..b2c1e3ac2f 100644 --- a/native/cocos/scene/Frustum.h +++ b/native/cocos/core/scene-graph/SceneGlobals.h @@ -1,8 +1,8 @@ /**************************************************************************** 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 @@ -10,10 +10,10 @@ 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 @@ -25,46 +25,44 @@ #pragma once -#include -#include "math/Vec3.h" +#include "base/Ptr.h" +#include "base/RefCounted.h" namespace cc { + namespace scene { -enum class ShapeEnums { - SHAPE_RAY = (1 << 0), - SHAPE_LINE = (1 << 1), - SHAPE_SPHERE = (1 << 2), - SHAPE_AABB = (1 << 3), - SHAPE_OBB = (1 << 4), - SHAPE_PLANE = (1 << 5), - SHAPE_TRIANGLE = (1 << 6), - SHAPE_FRUSTUM = (1 << 7), - SHAPE_FRUSTUM_ACCURATE = (1 << 8), - SHAPE_CAPSULE = (1 << 9), -}; - -struct Plane final { - float d{0.F}; - Vec3 n; - - void define(const Vec3 &v0, const Vec3 &v1, const Vec3 &v2); - void define(const Vec3 &normal, const Vec3 &point); - float distance(const Vec3 &point) const; - Plane clone() const; -}; - -struct Frustum final { - std::array vertices; - std::array planes; - - void createOrtho(float width, float height, float near, float far, const Mat4 &transform); - void split(float start, float end, float aspect, float fov, const Mat4 &transform); - void updatePlanes(); - void update(const Mat4 &m, const Mat4 &inv); - Frustum clone(); - void transform(const Mat4 &transform); - ShapeEnums type{ShapeEnums::SHAPE_FRUSTUM}; -}; - +class AmbientInfo; +class ShadowsInfo; +class SkyboxInfo; +class FogInfo; +class OctreeInfo; } // namespace scene + +class SceneGlobals : public RefCounted { +public: + SceneGlobals(); + ~SceneGlobals() override = default; + + void activate(); + + inline scene::AmbientInfo *getAmbientInfo() const { return _ambientInfo.get(); } + inline scene::ShadowsInfo *getShadowsInfo() const { return _shadowInfo.get(); } + inline scene::SkyboxInfo * getSkyboxInfo() const { return _skyboxInfo.get(); } + inline scene::FogInfo * getFogInfo() const { return _fogInfo.get(); } + inline scene::OctreeInfo * getOctreeInfo() const { return _octreeInfo.get(); } + + inline void setAmbientInfo(scene::AmbientInfo *info) { _ambientInfo = info; } + inline void setShadowsInfo(scene::ShadowsInfo *info) { _shadowInfo = info; } + inline void setSkyboxInfo(scene::SkyboxInfo *info) { _skyboxInfo = info; } + inline void setFogInfo(scene::FogInfo *info) { _fogInfo = info; } + inline void setOctreeInfo(scene::OctreeInfo *info) { _octreeInfo = info; } + +private: + IntrusivePtr _ambientInfo; + IntrusivePtr _shadowInfo; + IntrusivePtr _skyboxInfo; + IntrusivePtr _fogInfo; + IntrusivePtr _octreeInfo; +}; + } // namespace cc diff --git a/native/cocos/core/scene-graph/SceneGraphModuleHeader.h b/native/cocos/core/scene-graph/SceneGraphModuleHeader.h new file mode 100644 index 0000000000..1fb9af1d00 --- /dev/null +++ b/native/cocos/core/scene-graph/SceneGraphModuleHeader.h @@ -0,0 +1,36 @@ +/**************************************************************************** + 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/ComponentScheduler.h" +//#include "core/scene-graph/Find.h" +#include "core/scene-graph/Layers.h" +#include "core/scene-graph/Node.h" +//#include "core/scene-graph/NodeActivator.h" +#include "core/scene-graph/NodeEnum.h" +#include "core/scene-graph/NodeEvent.h" +#include "core/scene-graph/NodeEventProcessor.h" +//#include "core/scene-graph/NodeUIProperties.h" +#include "core/scene-graph/Scene.h" +#include "core/scene-graph/SceneGlobals.h" diff --git a/native/cocos/core/utils/IDGenerator.cpp b/native/cocos/core/utils/IDGenerator.cpp new file mode 100644 index 0000000000..f46dc62c0b --- /dev/null +++ b/native/cocos/core/utils/IDGenerator.cpp @@ -0,0 +1,21 @@ +#include "core/utils/IDGenerator.h" +#include "base/Random.h" + +namespace cc { + +IDGenerator globalIdGenerator("global"); + +IDGenerator::IDGenerator(const std::string &category) { + // Tnit with a random id to emphasize that the returns id should not be stored in persistence data. + _id = static_cast(RandomHelper::randomInt(0, 998)); + _prefix = (category + nonUuidMark); +} + +std::string IDGenerator::getNewId() { + //cjh TODO: if (EDITOR && (this.prefix === 'Node.' || this.prefix === 'Comp.')) { + // return EditorExtends.UuidUtils.uuid(); + // } + return _prefix + std::to_string(++_id); +} + +} // namespace cc diff --git a/native/cocos/renderer/pipeline/helper/DefineMap.h b/native/cocos/core/utils/IDGenerator.h similarity index 65% rename from native/cocos/renderer/pipeline/helper/DefineMap.h rename to native/cocos/core/utils/IDGenerator.h index 20ac0f9874..12370e64ce 100644 --- a/native/cocos/renderer/pipeline/helper/DefineMap.h +++ b/native/cocos/core/utils/IDGenerator.h @@ -1,5 +1,5 @@ /**************************************************************************** - Copyright (c) 2020-2021 Xiamen Yaji Software Co., Ltd. + Copyright (c) 2021 Xiamen Yaji Software Co., Ltd. http://www.cocos.com @@ -25,31 +25,36 @@ #pragma once -#include "base/CoreStd.h" -#include "base/Macros.h" -#include "cocos/bindings/jswrapper/Object.h" +#include "base/Random.h" + +#include namespace cc { -namespace pipeline { -class CC_DLL DefineMap final : public Object { +static const char *nonUuidMark = "."; + +/** + * ID generator for runtime. + */ +class IDGenerator { public: - DefineMap(); - ~DefineMap() override; + /** + * @param [category] You can specify a unique category to avoid id collision with other instance of IdGenerator. + */ + explicit IDGenerator(const std::string &category); - inline se::Object *getObject() const { return _jsbMacros; } - inline void getValue(const String &name, se::Value *value) const { _jsbMacros->getProperty(name.c_str(), value); } - - template - ENABLE_IF_T3_RET(float, bool, String) - setValue(const String &name, const T &value) { - se::Value v(value); - _jsbMacros->setProperty(name.c_str(), v); - } + std::string getNewId(); private: - se::Object *_jsbMacros = nullptr; + uint32_t _id{0}; + + std::string _prefix; }; -} // namespace pipeline +/* +* The global id generator might have a conflict problem once every 365 days, +* if the game runs at 60 FPS and each frame 4760273 counts of new id are requested. +*/ +extern IDGenerator globalIdGenerator; + } // namespace cc diff --git a/native/cocos/core/utils/ImageUtils.cpp b/native/cocos/core/utils/ImageUtils.cpp new file mode 100644 index 0000000000..fe1c16f332 --- /dev/null +++ b/native/cocos/core/utils/ImageUtils.cpp @@ -0,0 +1,94 @@ +/**************************************************************************** + 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/utils/ImageUtils.h" +#include "base/Log.h" +#include "renderer/gfx-base/GFXDef-common.h" +namespace { +uint8_t *convertRGB2RGBA(uint32_t length, uint8_t *src) { + auto *dst = reinterpret_cast(malloc(length)); + for (uint32_t i = 0; i < length; i += 4) { + dst[i] = *src++; + dst[i + 1] = *src++; + dst[i + 2] = *src++; + dst[i + 3] = 255; + } + return dst; +} + +uint8_t *convertIA2RGBA(uint32_t length, uint8_t *src) { + auto *dst = reinterpret_cast(malloc(length)); + for (uint32_t i = 0; i < length; i += 4) { + dst[i] = *src; + dst[i + 1] = *src; + dst[i + 2] = *src++; + dst[i + 3] = *src++; + } + return dst; +} + +uint8_t *convertI2RGBA(uint32_t length, uint8_t *src) { + auto *dst = reinterpret_cast(malloc(length)); + for (uint32_t i = 0; i < length; i += 4) { + dst[i] = *src; + dst[i + 1] = *src; + dst[i + 2] = *src++; + dst[i + 3] = 255; + } + return dst; +} +} // namespace + +namespace cc { +void ImageUtils::convert2RGBA(Image *image) { + if (!image->_isCompressed && image->_renderFormat != gfx::Format::RGBA8) { + image->_dataLen = image->_width * image->_height * 4; + uint8_t *dst = nullptr; + uint32_t length = static_cast(image->_dataLen); + uint8_t *src = image->_data; + switch (image->_renderFormat) { + case gfx::Format::A8: + case gfx::Format::LA8: + dst = convertIA2RGBA(length, src); + break; + case gfx::Format::L8: + case gfx::Format::R8: + case gfx::Format::R8I: + dst = convertI2RGBA(length, src); + break; + case gfx::Format::RGB8: + dst = convertRGB2RGBA(length, src); + break; + default: + CC_LOG_INFO("cannot convert to RGBA: unknown image format"); + break; + } + if (dst != image->_data) free(image->_data); + image->_data = dst; + image->_renderFormat = gfx::Format::RGBA8; + } +} + +} // namespace cc \ No newline at end of file diff --git a/native/cocos/core/utils/ImageUtils.h b/native/cocos/core/utils/ImageUtils.h new file mode 100644 index 0000000000..0e35c09cb5 --- /dev/null +++ b/native/cocos/core/utils/ImageUtils.h @@ -0,0 +1,36 @@ +/**************************************************************************** + 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 "cocos/platform/Image.h" + +namespace cc { +class ImageUtils { +public: + static void convert2RGBA(Image *image); +}; + +} // namespace cc \ No newline at end of file diff --git a/native/cocos/core/utils/MutableForwardIterator.cpp b/native/cocos/core/utils/MutableForwardIterator.cpp new file mode 100644 index 0000000000..2d1692d8c8 --- /dev/null +++ b/native/cocos/core/utils/MutableForwardIterator.cpp @@ -0,0 +1,29 @@ +#include "core/utils/MutableForwardIterator.h" + +namespace cc { + +} + +#if UNIT_TEST + +void MutableForwardIteratorTest() { + using namespace cc; + + std::vector myarr{1, 2, 3, 43, 4, 5}; + MutableForwardIterator iter{myarr}; + + iter.fastRemoveAt(2); + iter.fastRemove(43); + iter.push(123); + iter.push(100); + iter.fastRemove(123); + + for (iter.i = 0; iter.i < static_cast(myarr.size()); ++iter.i) { + auto &&item = myarr[iter.i]; + printf("item[%d]=%d\n", iter.i, item); + } + + int a = 0; +} + +#endif diff --git a/native/cocos/core/utils/MutableForwardIterator.h b/native/cocos/core/utils/MutableForwardIterator.h new file mode 100644 index 0000000000..00cd8621b0 --- /dev/null +++ b/native/cocos/core/utils/MutableForwardIterator.h @@ -0,0 +1,115 @@ +/**************************************************************************** + 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 // for std::find +#include + +namespace cc { + +/** + * @example + * ``` + * import { js } from 'cc'; + * var array = [0, 1, 2, 3, 4]; + * var iterator = new js.array.MutableForwardIterator(array); + * for (iterator.i = 0; iterator.i < array.length; ++iterator.i) { + * var item = array[iterator.i]; + * ... + * } + * ``` + */ +template +class MutableForwardIterator { +public: + explicit MutableForwardIterator(std::vector &array) + : array(array) {} + + int32_t getLength() const { + return static_cast(array.size()); + } + + void setLength(int32_t value) { + if (value < 0) { + return; + } + + array.resize(value); + if (this->i >= value) { + this->i = value - 1; + } + } + + void remove(T value) { + auto iter = std::find(array.cbegin(), array.cend(), value); + if (iter != array.cend()) { + removeAt(iter - array.cbegin()); + } + } + + void removeAt(int32_t ii) { + if (ii >= 0 && ii < static_cast(array.size())) { + array.erase(array.begin() + ii); + + if (ii <= this->i) { + --this->i; + } + } + } + + void fastRemove(T value) { + auto iter = std::find(array.cbegin(), array.cend(), value); + if (iter != array.cend()) { + fastRemoveAt(iter - array.cbegin()); + } + } + + void fastRemoveAt(int32_t ii) { + if (ii >= 0 && ii < static_cast(array.size())) { + array[ii] = array[array.size() - 1]; + array.resize(array.size() - 1); + + if (ii <= this->i) { + --this->i; + } + } + } + + void push(T &&item) { + array.emplace_back(std::forward(item)); + } + + int32_t i = 0; + std::vector &array; +}; + +} // namespace cc + +//#define UNIT_TEST 1 + +#if UNIT_TEST +void MutableForwardIteratorTest(); +#endif diff --git a/native/cocos/core/utils/Path.cpp b/native/cocos/core/utils/Path.cpp new file mode 100644 index 0000000000..0df774797d --- /dev/null +++ b/native/cocos/core/utils/Path.cpp @@ -0,0 +1,216 @@ +/**************************************************************************** + 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/utils/Path.h" +#include "base/StringUtil.h" + +namespace cc { + +namespace { +const std::string EMPTY_STRING; + +std::string &removeLastSlash(std::string &path) { + if (!path.empty()) { + if (path[path.length() - 1] == '/' || path[path.length() - 1] == '\\') { + path = path.substr(0, path.length() - 1); + } else if (path.length() > 1 && path[path.length() - 1] == '\\' && path[path.length() - 2] == '\\') { + path = path.substr(0, path.length() - 2); + } + } + return path; +} + +} // namespace + +std::string join(const std::vector &segments) { + std::string result; + + for (const auto &segment : segments) { + if (!result.empty()) { + result += "/"; + } + result += segment; + removeLastSlash(result); + } + + return result; +} + +std::string extname(const std::string &path) { + if (path.empty()) { + return EMPTY_STRING; + } + + std::string newPath = path; + size_t index = path.find_first_of('?'); + if (index != std::string::npos && index > 0) { + newPath = newPath.substr(0, index); + } + + index = newPath.find_last_of('.'); + if (index == std::string::npos) { + return EMPTY_STRING; + } + + return newPath.substr(index); +} + +std::string mainFileName(const std::string &fileName) { + if (!fileName.empty()) { + size_t idx = fileName.find_last_of('.'); + if (idx != std::string::npos) { + return fileName.substr(0, idx); + } + } + + return fileName; +} + +std::string basename(const std::string &path, const std::string &extName /* = ""*/) { + std::string newPath = path; + size_t index = path.find_first_of('?'); + if (index != std::string::npos && index > 0) { + newPath = newPath.substr(0, index); + } + + removeLastSlash(newPath); + + index = newPath.find_last_of("/\\"); + if (index == std::string::npos) { + return newPath; + } + + std::string baseName = newPath.substr(index + 1); + + if (!extName.empty() && extName.length() < newPath.length()) { + std::string extInPath = newPath.substr(newPath.length() - extName.length()); + std::string expectedExtName = extName; + if (StringUtil::tolower(extInPath) == StringUtil::tolower(expectedExtName)) { + baseName = baseName.substr(0, baseName.length() - extName.length()); + } + } + + return baseName; +} + +std::string dirname(const std::string &path) { + size_t index = path.find_last_of("/\\"); + if (index == std::string::npos) { + return ""; + } + + std::string dir = path.substr(0, index); + removeLastSlash(dir); + return dir; +} + +std::string changeExtname(const std::string &path, const std::string &extName /* = ""*/) { + size_t index = path.find_first_of('?'); + std::string newPath = path; + std::string tempStr; + if (index != std::string::npos && index > 0) { + tempStr = path.substr(index); + newPath = path.substr(0, index); + } + + index = newPath.find_last_of('.'); + if (index == std::string::npos) { + return newPath + extName + tempStr; + } + + return newPath.substr(0, index) + extName + tempStr; +} + +std::string changeBasename(const std::string &path, const std::string &baseName, bool isSameExt /* = false*/) { + if (baseName.find_last_of('.') == 0) { + return changeExtname(path, baseName); + } + + size_t index = path.find_last_of('?'); + std::string tempStr; + std::string newPath = path; + const std::string ext = isSameExt ? extname(path) : ""; + if (index != std::string::npos && index > 0) { + tempStr = path.substr(index); + newPath = path.substr(0, index); + } + + index = newPath.find_last_of("/\\"); + if (index == std::string::npos) { + index = 0; + } else if (index > 0) { + ++index; + } + + return newPath.substr(0, index) + baseName + ext + tempStr; +} + +std::string normalize(const std::string &url) { + std::string oldUrl = url; + std::string newUrl = url; + + // remove all ../ + do { + oldUrl = newUrl; + size_t index = newUrl.find("../"); + if (index == std::string::npos) { + index = newUrl.find("..\\"); + } + size_t previousSlashIndex = std::string::npos; + size_t previousTwiceSlashIndex = std::string::npos; + if (index != std::string::npos && index > 0) { + previousSlashIndex = newUrl.find_last_of("/\\", index - 1); + if (previousSlashIndex != std::string::npos) { + previousTwiceSlashIndex = newUrl.find_last_of("/\\", previousSlashIndex - 1); + } + } + + if (previousTwiceSlashIndex == std::string::npos) { + if (previousSlashIndex != std::string::npos) { + newUrl = newUrl.substr(index + strlen("../")); + } + } else if (previousSlashIndex != std::string::npos) { + newUrl = newUrl.substr(0, previousTwiceSlashIndex) + '/' + newUrl.substr(index + strlen("../")); + } + } while (oldUrl.length() != newUrl.length()); + + return newUrl; +} + +std::string stripSep(const std::string &path) { + std::string result = path; + removeLastSlash(result); + return result; +} + +char getSeperator() { +#if (CC_PLATFORM == CC_PLATFORM_WINDOWS) + return '\\'; +#else + return '/'; +#endif +} + +} // namespace cc diff --git a/native/cocos/core/utils/Path.h b/native/cocos/core/utils/Path.h new file mode 100644 index 0000000000..8853eef1d4 --- /dev/null +++ b/native/cocos/core/utils/Path.h @@ -0,0 +1,88 @@ +/**************************************************************************** + 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 +#include + +namespace cc { + +/** + * @en Join strings to be a path. + * @zh 拼接字符串为路径。 + * @example {@link cocos/core/utils/CCPath/join.js} + */ +std::string join(const std::vector &segments); + +/** + * @en Get the ext name of a path including '.', like '.png'. + * @zh 返回 Path 的扩展名,包括 '.',例如 '.png'。 + * @example {@link cocos/core/utils/CCPath/extname.js} + */ +std::string extname(const std::string &path); + +/** + * @en Get the main name of a file name. + * @zh 获取文件名的主名称。 + * @deprecated + */ +std::string mainFileName(const std::string &fileName); + +/** + * @en Get the file name of a file path. + * @zh 获取文件路径的文件名。 + * @example {@link cocos/core/utils/CCPath/basename.js} + */ +std::string basename(const std::string &path, const std::string &extName = ""); + +/** + * @en Get dirname of a file path. + * @zh 获取文件路径的目录名。 + * @example {@link cocos/core/utils/CCPath/dirname.js} + */ +std::string dirname(const std::string &path); + +/** + * @en Change extname of a file path. + * @zh 更改文件路径的扩展名。 + * @example {@link cocos/core/utils/CCPath/changeExtname.js} + */ +std::string changeExtname(const std::string &path, const std::string &extName = ""); + +/** + * @en Change file name of a file path. + * @zh 更改文件路径的文件名。 + * @example {@link cocos/core/utils/CCPath/changeBasename.js} + */ +std::string changeBasename(const std::string &path, const std::string &baseName, bool isSameExt = false); + +std::string normalize(const std::string &url); + +std::string stripSep(const std::string &path); + +char getSeperator(); + +} // namespace cc diff --git a/native/cocos/core/utils/Pool.h b/native/cocos/core/utils/Pool.h new file mode 100644 index 0000000000..671231a881 --- /dev/null +++ b/native/cocos/core/utils/Pool.h @@ -0,0 +1,190 @@ +/**************************************************************************** + 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 + +/** + * @packageDocumentation + * @module core + */ + +/** + * @en + * A fixed-length object pool designed for general type.
+ * The implementation of this object pool is very simple, + * it can helps you to improve your game performance for objects which need frequent release and recreate operations
+ * @zh + * 长度固定的对象缓存池,可以用来缓存各种对象类型。
+ * 这个对象池的实现非常精简,它可以帮助您提高游戏性能,适用于优化对象的反复创建和销毁。 + * @class js.Pool + * @example + * ``` + * + * Example 1: + * + * function Details () { + * uuidList = []; + * }; + * Details.prototype.reset = function () { + * uuidList.length = 0; + * }; + * Details.pool = new js.Pool(function (obj) { + * obj.reset(); + * }, 5); + * Details.pool.get = function () { + * return _get() || new Details(); + * }; + * + * var detail = Details.pool.get(); + * ... + * Details.pool.put(detail); + * + * Example 2: + * + * function Details (buffer) { + * uuidList = buffer; + * }; + * ... + * Details.pool.get = function (buffer) { + * var cached = _get(); + * if (cached) { + * cached.uuidList = buffer; + * return cached; + * } + * else { + * return new Details(buffer); + * } + * }; + * + * var detail = Details.pool.get( [] ); + * ... + * ``` + */ + +#include +#include + +#include "base/Macros.h" + +template +class Pool { +public: + using CleanUpFunction = std::function; + + /** + * @en + * Get and initialize an object from pool. This method defaults to null and requires the user to implement it. + * @zh + * 获取并初始化对象池中的对象。这个方法默认为空,需要用户自己实现。 + * @param args - parameters to used to initialize the object + */ + std::function get{}; + + /** + * 使用构造函数来创建一个指定对象类型的对象池,您可以传递一个回调函数,用于处理对象回收时的清理逻辑。 + * @method constructor + * @param {Function} [cleanupFunc] - the callback method used to process the cleanup logic when the object is recycled. + * @param {Object} cleanupFunc.obj + * @param {Number} size - initializes the length of the array + */ + Pool(const CleanUpFunction &cleanup, int32_t size) { + _count = 0; + _pool.resize(size); + _cleanup = cleanup; + } + + /** + * 使用构造函数来创建一个指定对象类型的对象池,您可以传递一个回调函数,用于处理对象回收时的清理逻辑。 + * @method constructor + * @param {Function} [cleanupFunc] - the callback method used to process the cleanup logic when the object is recycled. + * @param {Object} cleanupFunc.obj + * @param {Number} size - initializes the length of the array + */ + explicit Pool(int32_t size) + : Pool{nullptr, size} {} + + ~Pool() = default; + + /** + * @en + * Get an object from pool, if no available object in the pool, null will be returned. + * @zh + * 获取对象池中的对象,如果对象池没有可用对象,则返回空。 + */ + T _get() { //NOLINT(readability-identifier-naming) + if (_count > 0) { + --_count; + T cache = _pool[_count]; + _pool[_count] = nullptr; + return cache; + } + return nullptr; + } + + /** + * @en Put an object into the pool. + * @zh 向对象池返还一个不再需要的对象。 + */ + void put(T &obj) { + if (_count < static_cast(_pool.size())) { + if (_cleanup != nullptr && !_cleanup(obj)) { + return; + } + _pool[_count] = obj; + ++_count; + } + } + + /** + * @en Resize the pool. + * @zh 设置对象池容量。 + */ + void resize(int32_t length) { + if (length >= 0) { + _pool.resize(length); + if (_count > length) { + _count = length; + } + } + } + + int32_t getCount() const { return _count; } + +private: + std::vector _pool; + CleanUpFunction _cleanup{nullptr}; + + /** + * @en + * The current number of available objects, the default is 0, it will gradually increase with the recycle of the object, + * the maximum will not exceed the size specified when the constructor is called. + * @zh + * 当前可用对象数量,一开始默认是 0,随着对象的回收会逐渐增大,最大不会超过调用构造函数时指定的 size。 + * @default 0 + */ + int32_t _count{0}; + + CC_DISALLOW_COPY_MOVE_ASSIGN(Pool); +}; diff --git a/native/cocos/editor-support/IOBuffer.cpp b/native/cocos/editor-support/IOBuffer.cpp index f3d9c0fedb..a2bc13b310 100644 --- a/native/cocos/editor-support/IOBuffer.cpp +++ b/native/cocos/editor-support/IOBuffer.cpp @@ -29,7 +29,7 @@ MIDDLEWARE_BEGIN void IOBuffer::resize(std::size_t newLen, bool needCopy) { if (_bufferSize < newLen) { - uint8_t *newBuffer = new uint8_t[newLen]; + auto *newBuffer = new uint8_t[newLen]; if (needCopy) { memcpy(newBuffer, _buffer, _bufferSize); } diff --git a/native/cocos/editor-support/IOBuffer.h b/native/cocos/editor-support/IOBuffer.h index 1fc392840a..e534061618 100644 --- a/native/cocos/editor-support/IOBuffer.h +++ b/native/cocos/editor-support/IOBuffer.h @@ -24,14 +24,15 @@ ****************************************************************************/ #pragma once -#include "MiddlewareMacro.h" -#include "base/Macros.h" +#include #include #include +#include #include -#include #include -#include +#include +#include "MiddlewareMacro.h" +#include "base/Macros.h" MIDDLEWARE_BEGIN /** @@ -41,12 +42,12 @@ MIDDLEWARE_BEGIN */ class IOBuffer { public: - IOBuffer(std::size_t defaultSize) { + explicit IOBuffer(std::size_t defaultSize) { _bufferSize = defaultSize; - _buffer = new uint8_t[_bufferSize]; + _buffer = new uint8_t[_bufferSize]; } - IOBuffer() {} + IOBuffer() = default; virtual ~IOBuffer() { if (_buffer) { @@ -60,8 +61,8 @@ public: _outRange = true; return; } - uint32_t *buffer = (uint32_t *)(_buffer + pos); - *buffer = val; + auto *buffer = reinterpret_cast(_buffer + pos); + *buffer = val; } inline void writeFloat32(std::size_t pos, float val) { @@ -69,8 +70,8 @@ public: _outRange = true; return; } - float *buffer = (float *)(_buffer + pos); - *buffer = val; + auto *buffer = reinterpret_cast(_buffer + pos); + *buffer = val; } inline void writeBytes(const char *bytes, std::size_t bytesLen) { @@ -87,8 +88,8 @@ public: _outRange = true; return; } - uint32_t *buffer = (uint32_t *)(_buffer + _curPos); - *buffer = val; + auto *buffer = reinterpret_cast(_buffer + _curPos); + *buffer = val; _curPos += sizeof(val); } @@ -97,8 +98,8 @@ public: _outRange = true; return; } - float *buffer = (float *)(_buffer + _curPos); - *buffer = val; + auto *buffer = reinterpret_cast(_buffer + _curPos); + *buffer = val; _curPos += sizeof(val); } @@ -107,37 +108,37 @@ public: _outRange = true; return; } - uint16_t *buffer = (uint16_t *)(_buffer + _curPos); - *buffer = val; + auto *buffer = reinterpret_cast(_buffer + _curPos); + *buffer = val; _curPos += sizeof(val); } inline uint32_t readUint32() { - uint32_t *buffer = (uint32_t *)(_buffer + _readPos); + auto *buffer = reinterpret_cast(_buffer + _readPos); _readPos += sizeof(uint32_t); return *buffer; } inline uint16_t readUint16() { - uint16_t *buffer = (uint16_t *)(_buffer + _readPos); + auto *buffer = reinterpret_cast(_buffer + _readPos); _readPos += sizeof(uint16_t); return *buffer; } inline float readFloat32() { - float *buffer = (float *)(_buffer + _readPos); + auto *buffer = reinterpret_cast(_buffer + _readPos); _readPos += sizeof(float); return *buffer; } inline char readUint8() { - char *buffer = (char *)(_buffer + _readPos); + char *buffer = reinterpret_cast(_buffer + _readPos); _readPos += sizeof(char); return *buffer; } inline void reset() { - _curPos = 0; + _curPos = 0; _readPos = 0; } @@ -173,13 +174,13 @@ public: return _bufferSize; } - inline bool isOutRange() { + inline bool isOutRange() const { return _outRange; } inline int checkSpace(std::size_t needSize, bool needCopy = false) { auto needLen = _curPos + needSize; - auto isFull = 0; + auto isFull = 0; if (_maxSize > 0 && needLen > _maxSize) { isFull = 1; if (_fullCallback) { @@ -189,7 +190,7 @@ public: } if (_bufferSize < needLen) { - std::size_t fitSize = (std::size_t)ceil(needLen / float(MIN_TYPE_ARRAY_SIZE)) * MIN_TYPE_ARRAY_SIZE; + std::size_t fitSize = static_cast(ceil(static_cast(needLen) / float(MIN_TYPE_ARRAY_SIZE))) * MIN_TYPE_ARRAY_SIZE; resize(fitSize, needCopy); if (_resizeCallback) { _resizeCallback(); @@ -203,14 +204,14 @@ public: _maxSize = maxSize; } - typedef std::function fullCallback; + using fullCallback = std::function; void setFullCallback(fullCallback callback) { - _fullCallback = callback; + _fullCallback = std::move(callback); } - typedef std::function resizeCallback; + using resizeCallback = std::function; void setResizeCallback(resizeCallback callback) { - _resizeCallback = callback; + _resizeCallback = std::move(callback); } /** @@ -218,16 +219,16 @@ public: * @param[in] newLen New size you want to adjustment. * @param[in] needCopy If true,will copy old data to new buffer,default false. */ - virtual void resize(std::size_t newLen, bool needCopy = false); + virtual void resize(std::size_t newLen, bool needCopy); protected: - uint8_t *_buffer = nullptr; - std::size_t _bufferSize = 0; - std::size_t _curPos = 0; - std::size_t _readPos = 0; - bool _outRange = false; - std::size_t _maxSize = 0; - fullCallback _fullCallback = nullptr; + uint8_t * _buffer = nullptr; + std::size_t _bufferSize = 0; + std::size_t _curPos = 0; + std::size_t _readPos = 0; + bool _outRange = false; + std::size_t _maxSize = 0; + fullCallback _fullCallback = nullptr; resizeCallback _resizeCallback = nullptr; }; diff --git a/native/cocos/editor-support/IOTypedArray.cpp b/native/cocos/editor-support/IOTypedArray.cpp index 68ddfcb841..d188f37acb 100644 --- a/native/cocos/editor-support/IOTypedArray.cpp +++ b/native/cocos/editor-support/IOTypedArray.cpp @@ -73,7 +73,7 @@ void IOTypedArray::resize(std::size_t newLen, bool needCopy) { uint8_t *newBuffer = nullptr; se::AutoHandleScope hs; - newTypeBuffer->getTypedArrayData(&newBuffer, (size_t *)&newLen); + newTypeBuffer->getTypedArrayData(&newBuffer, static_cast(&newLen)); if (needCopy) { memcpy(newBuffer, _buffer, _bufferSize); diff --git a/native/cocos/editor-support/IOTypedArray.h b/native/cocos/editor-support/IOTypedArray.h index d5a65af44b..c4eebfbbd4 100644 --- a/native/cocos/editor-support/IOTypedArray.h +++ b/native/cocos/editor-support/IOTypedArray.h @@ -43,13 +43,13 @@ public: * @param[in] usePool If true,will get TypeArray from pool,or create TypeArray,default false. */ IOTypedArray(se::Object::TypedArrayType arrayType, std::size_t defaultSize, bool usePool = false); - virtual ~IOTypedArray(); + ~IOTypedArray() override; inline se::Object *getTypeArray() const { return _typeArray; } - virtual void resize(std::size_t newLen, bool needCopy = false) override; + void resize(std::size_t newLen, bool needCopy) override; private: se::Object::TypedArrayType _arrayType = se::Object::TypedArrayType::NONE; diff --git a/native/cocos/editor-support/MiddlewareManager.cpp b/native/cocos/editor-support/MiddlewareManager.cpp index 6bdb396b9a..82a2ec525d 100644 --- a/native/cocos/editor-support/MiddlewareManager.cpp +++ b/native/cocos/editor-support/MiddlewareManager.cpp @@ -29,7 +29,7 @@ MIDDLEWARE_BEGIN -MiddlewareManager *MiddlewareManager::_instance = nullptr; +MiddlewareManager *MiddlewareManager::instance = nullptr; MiddlewareManager::MiddlewareManager() : _renderInfo(se::Object::TypedArrayType::UINT32), _attachInfo(se::Object::TypedArrayType::FLOAT32) { @@ -37,10 +37,10 @@ MiddlewareManager::MiddlewareManager() : _renderInfo(se::Object::TypedArrayType: MiddlewareManager::~MiddlewareManager() { for (auto it : _mbMap) { - auto buffer = it.second; - if (buffer) { + auto *buffer = it.second; + delete buffer; - } + } _mbMap.clear(); } @@ -54,9 +54,8 @@ MeshBuffer *MiddlewareManager::getMeshBuffer(int format) { return mb; } -void MiddlewareManager::_clearRemoveList() { - for (std::size_t i = 0; i < _removeList.size(); i++) { - auto editor = _removeList[i]; +void MiddlewareManager::clearRemoveList() { + for (auto *editor : _removeList) { auto it = std::find(_updateList.begin(), _updateList.end(), editor); if (it != _updateList.end()) { _updateList.erase(it); @@ -70,23 +69,22 @@ void MiddlewareManager::update(float dt) { isUpdating = true; _renderInfo.reset(); - auto renderBuffer = _renderInfo.getBuffer(); + auto *renderBuffer = _renderInfo.getBuffer(); if (renderBuffer) { renderBuffer->writeUint32(0); } _attachInfo.reset(); - auto attachBuffer = _attachInfo.getBuffer(); + auto *attachBuffer = _attachInfo.getBuffer(); if (attachBuffer) { attachBuffer->writeUint32(0); } auto isOrderDirty = false; uint32_t maxRenderOrder = 0; - for (std::size_t i = 0, n = _updateList.size(); i < n; i++) { - auto editor = _updateList[i]; + for (auto *editor : _updateList) { uint32_t renderOrder = maxRenderOrder; - if (_removeList.size() > 0) { + if (!_removeList.empty()) { auto removeIt = std::find(_removeList.begin(), _removeList.end(), editor); if (removeIt == _removeList.end()) { editor->update(dt); @@ -106,7 +104,7 @@ void MiddlewareManager::update(float dt) { isUpdating = false; - _clearRemoveList(); + clearRemoveList(); if (isOrderDirty) { std::sort(_updateList.begin(), _updateList.end(), [](IMiddleware *it1, IMiddleware *it2) { @@ -117,7 +115,7 @@ void MiddlewareManager::update(float dt) { void MiddlewareManager::render(float dt) { for (auto it : _mbMap) { - auto buffer = it.second; + auto *buffer = it.second; if (buffer) { buffer->reset(); } @@ -125,9 +123,8 @@ void MiddlewareManager::render(float dt) { isRendering = true; - for (std::size_t i = 0, n = _updateList.size(); i < n; i++) { - auto editor = _updateList[i]; - if (_removeList.size() > 0) { + for (auto *editor : _updateList) { + if (!_removeList.empty()) { auto removeIt = std::find(_removeList.begin(), _removeList.end(), editor); if (removeIt == _removeList.end()) { editor->render(dt); @@ -140,14 +137,14 @@ void MiddlewareManager::render(float dt) { isRendering = false; for (auto it : _mbMap) { - auto buffer = it.second; + auto *buffer = it.second; if (buffer) { buffer->uploadIB(); buffer->uploadVB(); } } - _clearRemoveList(); + clearRemoveList(); } void MiddlewareManager::addTimer(IMiddleware *editor) { diff --git a/native/cocos/editor-support/MiddlewareManager.h b/native/cocos/editor-support/MiddlewareManager.h index 7f3f4ae84b..2ae13ee33a 100644 --- a/native/cocos/editor-support/MiddlewareManager.h +++ b/native/cocos/editor-support/MiddlewareManager.h @@ -25,12 +25,12 @@ #pragma once +#include +#include #include "MeshBuffer.h" #include "MiddlewareMacro.h" #include "SharedBufferManager.h" -#include "base/Ref.h" -#include -#include +#include "base/RefCounted.h" MIDDLEWARE_BEGIN @@ -39,8 +39,8 @@ MIDDLEWARE_BEGIN */ class IMiddleware { public: - IMiddleware() {} - virtual ~IMiddleware() {} + IMiddleware() = default; + virtual ~IMiddleware() = default; virtual void update(float dt) = 0; virtual void render(float dt) = 0; virtual uint32_t getRenderOrder() const = 0; @@ -53,17 +53,17 @@ public: class MiddlewareManager { public: static MiddlewareManager *getInstance() { - if (_instance == nullptr) { - _instance = new MiddlewareManager; + if (instance == nullptr) { + instance = new MiddlewareManager; } - return _instance; + return instance; } static void destroyInstance() { - if (_instance) { - delete _instance; - _instance = nullptr; + if (instance) { + delete instance; + instance = nullptr; } } @@ -100,9 +100,9 @@ public: se_object_ptr getVBTypedArray(int format, int bufferPos); se_object_ptr getIBTypedArray(int format, int bufferPos); - std::size_t getBufferCount(int format); - std::size_t getVBTypedArrayLength(int format, std::size_t bufferPos); - std::size_t getIBTypedArrayLength(int format, std::size_t bufferPos); + std::size_t getBufferCount(int format); + std::size_t getVBTypedArrayLength(int format, std::size_t bufferPos); + std::size_t getIBTypedArrayLength(int format, std::size_t bufferPos); SharedBufferManager *getRenderInfoMgr(); SharedBufferManager *getAttachInfoMgr(); @@ -112,12 +112,11 @@ public: // If manager is traversing _updateMap, will set the flag untill traverse is finished. bool isRendering = false; - bool isUpdating = false; + bool isUpdating = false; private: - void _clearRemoveList(); + void clearRemoveList(); -private: std::vector _updateList; std::vector _removeList; std::map _mbMap; @@ -125,6 +124,6 @@ private: SharedBufferManager _renderInfo; SharedBufferManager _attachInfo; - static MiddlewareManager *_instance; + static MiddlewareManager *instance; }; MIDDLEWARE_END diff --git a/native/cocos/editor-support/SharedBufferManager.cpp b/native/cocos/editor-support/SharedBufferManager.cpp index d757983c12..16a13ccb51 100644 --- a/native/cocos/editor-support/SharedBufferManager.cpp +++ b/native/cocos/editor-support/SharedBufferManager.cpp @@ -41,7 +41,7 @@ void SharedBufferManager::afterCleanupHandle() { delete _buffer; _buffer = nullptr; } - se::ScriptEngine::getInstance()->addAfterInitHook(std::bind(&SharedBufferManager::init, this)); + se::ScriptEngine::getInstance()->addAfterInitHook([this] { init(); }); } void SharedBufferManager::init() { @@ -53,7 +53,7 @@ void SharedBufferManager::init() { } }); } - se::ScriptEngine::getInstance()->addAfterCleanupHook(std::bind(&SharedBufferManager::afterCleanupHandle, this)); + se::ScriptEngine::getInstance()->addAfterCleanupHook([this] { afterCleanupHandle(); }); } MIDDLEWARE_END diff --git a/native/cocos/editor-support/SharedBufferManager.h b/native/cocos/editor-support/SharedBufferManager.h index b272fdb3fc..ceae574406 100644 --- a/native/cocos/editor-support/SharedBufferManager.h +++ b/native/cocos/editor-support/SharedBufferManager.h @@ -25,14 +25,15 @@ #pragma once -#include "IOTypedArray.h" #include +#include +#include "IOTypedArray.h" MIDDLEWARE_BEGIN class SharedBufferManager { public: - SharedBufferManager(se::Object::TypedArrayType arrayType); + explicit SharedBufferManager(se::Object::TypedArrayType arrayType); virtual ~SharedBufferManager(); void reset() { @@ -43,9 +44,9 @@ public: return _buffer; } - typedef std::function resizeCallback; + using resizeCallback = std::function; void setResizeCallback(resizeCallback callback) { - _resizeCallback = callback; + _resizeCallback = std::move(callback); } se_object_ptr getSharedBuffer() const { @@ -56,10 +57,9 @@ private: void init(); void afterCleanupHandle(); -private: se::Object::TypedArrayType _arrayType; - IOTypedArray *_buffer = nullptr; - resizeCallback _resizeCallback = nullptr; + IOTypedArray * _buffer = nullptr; + resizeCallback _resizeCallback = nullptr; }; MIDDLEWARE_END diff --git a/native/cocos/editor-support/TypedArrayPool.cpp b/native/cocos/editor-support/TypedArrayPool.cpp index 5191182f62..581c37e987 100644 --- a/native/cocos/editor-support/TypedArrayPool.cpp +++ b/native/cocos/editor-support/TypedArrayPool.cpp @@ -24,22 +24,22 @@ ****************************************************************************/ #include "TypedArrayPool.h" +#include +#include #include "MiddlewareMacro.h" #include "base/Log.h" #include "base/Macros.h" -#include -#include #define POOL_DEBUG 0 #if POOL_DEBUG > 0 -#define PoolLog(...) \ - do { \ - fprintf(stdout, __VA_ARGS__); \ - fflush(stdout); \ - } while (false) + #define PoolLog(...) \ + do { \ + fprintf(stdout, __VA_ARGS__); \ + fflush(stdout); \ + } while (false) #else -#define POOL_LOG(...) + #define POOL_LOG(...) #endif MIDDLEWARE_BEGIN @@ -71,14 +71,14 @@ void TypedArrayPool::clearPool() { POOL_LOG("*****clearPool TypeArray pool begin"); //map - for (auto & it : _pool) { + for (auto &it : _pool) { //map fitMap &mapPool = *(it.second); - for (auto & itMapPool : mapPool) { + for (auto &itMapPool : mapPool) { //vector objPool &itFitPool = *(itMapPool.second); POOL_LOG("clear arrayType:%d,fitSize:%lu,objSize:%lu\n", it->first, itMapPool->first, itFitPool.size()); - for (auto & itFit : itFitPool) { + for (auto &itFit : itFitPool) { itFit->unroot(); itFit->decRef(); } @@ -93,10 +93,10 @@ void TypedArrayPool::clearPool() { void TypedArrayPool::dump() { //map - for (auto & it : _pool) { + for (auto &it : _pool) { //map fitMap &mapPool = *(it.second); - for (auto & itMapPool : mapPool) { + for (auto &itMapPool : mapPool) { //vector CC_UNUSED objPool &itFitPool = *(itMapPool.second); POOL_LOG("arrayType:%d,fitSize:%lu,objSize:%lu\n", it->first, itMapPool->first, itFitPool.size()); @@ -105,7 +105,7 @@ void TypedArrayPool::dump() { } se::Object *TypedArrayPool::pop(arrayType type, std::size_t size) { - auto fitSize = static_cast(std::ceil(size / float(MIN_TYPE_ARRAY_SIZE)) * MIN_TYPE_ARRAY_SIZE); + auto fitSize = static_cast(std::ceil(static_cast(size) / float(MIN_TYPE_ARRAY_SIZE)) * MIN_TYPE_ARRAY_SIZE); objPool *objPoolPtr = getObjPool(type, fitSize); if (!objPoolPtr->empty()) { @@ -117,25 +117,25 @@ se::Object *TypedArrayPool::pop(arrayType type, std::size_t size) { POOL_LOG("TypedArrayPool:pop result:empty,type:%d,fitSize:%lu,objSize:%lu\n", (int)type, fitSize, objPoolPtr->size()); se::AutoHandleScope hs; - auto *typeArray = se::Object::createTypedArray(type, nullptr, fitSize); + auto * typeArray = se::Object::createTypedArray(type, nullptr, fitSize); typeArray->root(); return typeArray; } TypedArrayPool::objPool *TypedArrayPool::getObjPool(arrayType type, std::size_t fitSize) { - auto it = _pool.find(type); + auto it = _pool.find(type); fitMap *fitMapPtr = nullptr; if (it == _pool.end()) { - fitMapPtr = new fitMap(); + fitMapPtr = new fitMap(); _pool[type] = fitMapPtr; } else { fitMapPtr = it->second; } - auto itPool = fitMapPtr->find(fitSize); + auto itPool = fitMapPtr->find(fitSize); objPool *objPoolPtr = nullptr; if (itPool == fitMapPtr->end()) { - objPoolPtr = new objPool(); + objPoolPtr = new objPool(); (*fitMapPtr)[fitSize] = objPoolPtr; } else { objPoolPtr = itPool->second; @@ -157,7 +157,7 @@ void TypedArrayPool::push(arrayType type, std::size_t arrayCapacity, se::Object } objPool *objPoolPtr = getObjPool(type, arrayCapacity); - auto it = std::find(objPoolPtr->begin(), objPoolPtr->end(), object); + auto it = std::find(objPoolPtr->begin(), objPoolPtr->end(), object); if (it != objPoolPtr->end()) { POOL_LOG("TypedArrayPool:push result:repeat\n"); return; diff --git a/native/cocos/editor-support/dragonbones-creator-support/ArmatureCache.cpp b/native/cocos/editor-support/dragonbones-creator-support/ArmatureCache.cpp index 992ed4192a..8504af0063 100644 --- a/native/cocos/editor-support/dragonbones-creator-support/ArmatureCache.cpp +++ b/native/cocos/editor-support/dragonbones-creator-support/ArmatureCache.cpp @@ -25,24 +25,23 @@ #include "CCFactory.h" #include "base/TypeDef.h" -USING_NS_MW; +USING_NS_MW; // NOLINT(google-build-using-namespace) -using namespace cc; +using namespace cc; // NOLINT(google-build-using-namespace) DRAGONBONES_NAMESPACE_BEGIN -float ArmatureCache::FrameTime = 1.0f / 60.0f; -float ArmatureCache::MaxCacheTime = 120.0f; +float ArmatureCache::FrameTime = 1.0F / 60.0F; +float ArmatureCache::MaxCacheTime = 120.0F; -ArmatureCache::SegmentData::SegmentData() { -} +ArmatureCache::SegmentData::SegmentData() = default; ArmatureCache::SegmentData::~SegmentData() { CC_SAFE_RELEASE_NULL(_texture); } void ArmatureCache::SegmentData::setTexture(cc::middleware::Texture2D *value) { - CC_SAFE_RETAIN(value); + CC_SAFE_ADD_REF(value); CC_SAFE_RELEASE(_texture); _texture = value; } @@ -51,22 +50,21 @@ cc::middleware::Texture2D *ArmatureCache::SegmentData::getTexture() const { return _texture; } -ArmatureCache::FrameData::FrameData() { -} +ArmatureCache::FrameData::FrameData() = default; ArmatureCache::FrameData::~FrameData() { - for (std::size_t i = 0, c = _bones.size(); i < c; i++) { - delete _bones[i]; + for (auto &bone : _bones) { + delete bone; } _bones.clear(); - for (std::size_t i = 0, c = _colors.size(); i < c; i++) { - delete _colors[i]; + for (auto &color : _colors) { + delete color; } _colors.clear(); - for (std::size_t i = 0, c = _segments.size(); i < c; i++) { - delete _segments[i]; + for (auto &segment : _segments) { + delete segment; } _segments.clear(); } @@ -74,7 +72,7 @@ ArmatureCache::FrameData::~FrameData() { ArmatureCache::BoneData *ArmatureCache::FrameData::buildBoneData(std::size_t index) { if (index > _bones.size()) return nullptr; if (index == _bones.size()) { - BoneData *boneData = new BoneData; + auto *boneData = new BoneData; _bones.push_back(boneData); } return _bones[index]; @@ -87,7 +85,7 @@ std::size_t ArmatureCache::FrameData::getBoneCount() const { ArmatureCache::ColorData *ArmatureCache::FrameData::buildColorData(std::size_t index) { if (index > _colors.size()) return nullptr; if (index == _colors.size()) { - ColorData *colorData = new ColorData; + auto *colorData = new ColorData; _colors.push_back(colorData); } return _colors[index]; @@ -100,7 +98,7 @@ std::size_t ArmatureCache::FrameData::getColorCount() const { ArmatureCache::SegmentData *ArmatureCache::FrameData::buildSegmentData(std::size_t index) { if (index > _segments.size()) return nullptr; if (index == _segments.size()) { - SegmentData *segmentData = new SegmentData; + auto *segmentData = new SegmentData; _segments.push_back(segmentData); } return _segments[index]; @@ -110,20 +108,19 @@ std::size_t ArmatureCache::FrameData::getSegmentCount() const { return _segments.size(); } -ArmatureCache::AnimationData::AnimationData() { -} +ArmatureCache::AnimationData::AnimationData() = default; ArmatureCache::AnimationData::~AnimationData() { reset(); } void ArmatureCache::AnimationData::reset() { - for (std::size_t i = 0, c = _frames.size(); i < c; i++) { - delete _frames[i]; + for (auto &frame : _frames) { + delete frame; } _frames.clear(); _isComplete = false; - _totalTime = 0.0f; + _totalTime = 0.0F; } bool ArmatureCache::AnimationData::needUpdate(int toFrameIdx) const { @@ -135,7 +132,7 @@ ArmatureCache::FrameData *ArmatureCache::AnimationData::buildFrameData(std::size return nullptr; } if (frameIdx == _frames.size()) { - auto frameData = new FrameData(); + auto *frameData = new FrameData(); _frames.push_back(frameData); } return _frames[frameIdx]; @@ -155,7 +152,7 @@ std::size_t ArmatureCache::AnimationData::getFrameCount() const { ArmatureCache::ArmatureCache(const std::string &armatureName, const std::string &armatureKey, const std::string &atlasUUID) { _armatureDisplay = dragonBones::CCFactory::getFactory()->buildArmatureDisplay(armatureName, armatureKey, "", atlasUUID); if (_armatureDisplay) { - _armatureDisplay->retain(); + _armatureDisplay->addRef(); } } @@ -165,8 +162,8 @@ ArmatureCache::~ArmatureCache() { _armatureDisplay = nullptr; } - for (auto it = _animationCaches.begin(); it != _animationCaches.end(); it++) { - delete it->second; + for (auto &animationCache : _animationCaches) { + delete animationCache.second; } _animationCaches.clear(); } @@ -175,15 +172,15 @@ ArmatureCache::AnimationData *ArmatureCache::buildAnimationData(const std::strin if (!_armatureDisplay) return nullptr; AnimationData *aniData = nullptr; - auto it = _animationCaches.find(animationName); + auto it = _animationCaches.find(animationName); if (it == _animationCaches.end()) { - auto armature = _armatureDisplay->getArmature(); - auto animation = armature->getAnimation(); - auto hasAni = animation->hasAnimation(animationName); + auto *armature = _armatureDisplay->getArmature(); + auto *animation = armature->getAnimation(); + auto hasAni = animation->hasAnimation(animationName); if (!hasAni) return nullptr; - aniData = new AnimationData(); - aniData->_animationName = animationName; + aniData = new AnimationData(); + aniData->_animationName = animationName; _animationCaches[animationName] = aniData; } else { aniData = it->second; @@ -195,9 +192,8 @@ ArmatureCache::AnimationData *ArmatureCache::getAnimationData(const std::string auto it = _animationCaches.find(animationName); if (it == _animationCaches.end()) { return nullptr; - } else { - return it->second; } + return it->second; } void ArmatureCache::updateToFrame(const std::string &animationName, int toFrameIdx /*= -1*/) { @@ -216,8 +212,8 @@ void ArmatureCache::updateToFrame(const std::string &animationName, int toFrameI _curAnimationName = animationName; } - auto armature = _armatureDisplay->getArmature(); - auto animation = armature->getAnimation(); + auto *armature = _armatureDisplay->getArmature(); + auto *animation = armature->getAnimation(); // init animation if (animationData->getFrameCount() == 0) { @@ -236,32 +232,32 @@ void ArmatureCache::updateToFrame(const std::string &animationName, int toFrameI void ArmatureCache::renderAnimationFrame(AnimationData *animationData) { std::size_t frameIndex = animationData->getFrameCount(); - _frameData = animationData->buildFrameData(frameIndex); + _frameData = animationData->buildFrameData(frameIndex); - _preColor = Color4F(-1.0f, -1.0f, -1.0f, -1.0f); - _color = Color4F(1.0f, 1.0f, 1.0f, 1.0f); + _preColor = Color4F(-1.0F, -1.0F, -1.0F, -1.0F); + _color = Color4F(1.0F, 1.0F, 1.0F, 1.0F); - _preBlendMode = -1; + _preBlendMode = -1; _preTextureIndex = -1; _curTextureIndex = -1; _preISegWritePos = -1; - _curISegLen = 0; - _curVSegLen = 0; - _materialLen = 0; + _curISegLen = 0; + _curVSegLen = 0; + _materialLen = 0; - auto armature = _armatureDisplay->getArmature(); + auto *armature = _armatureDisplay->getArmature(); traverseArmature(armature); if (_preISegWritePos != -1) { - SegmentData *preSegmentData = _frameData->buildSegmentData(_materialLen - 1); - preSegmentData->indexCount = _curISegLen; + SegmentData *preSegmentData = _frameData->buildSegmentData(_materialLen - 1); + preSegmentData->indexCount = _curISegLen; preSegmentData->vertexFloatCount = _curVSegLen; } auto colorCount = _frameData->getColorCount(); if (colorCount > 0) { - ColorData *preColorData = _frameData->buildColorData(colorCount - 1); - preColorData->vertexFloatOffset = (int)_frameData->vb.getCurPos() / sizeof(float); + ColorData *preColorData = _frameData->buildColorData(colorCount - 1); + preColorData->vertexFloatOffset = static_cast(_frameData->vb.getCurPos()) / sizeof(float); } _frameData = nullptr; @@ -271,31 +267,31 @@ void ArmatureCache::traverseArmature(Armature *armature, float parentOpacity /*= middleware::IOBuffer &vb = _frameData->vb; middleware::IOBuffer &ib = _frameData->ib; - auto &bones = armature->getBones(); - Bone *bone = nullptr; - auto &slots = armature->getSlots(); - CCSlot *slot = nullptr; + const auto &bones = armature->getBones(); + Bone * bone = nullptr; + const auto &slots = armature->getSlots(); + CCSlot * slot = nullptr; // range [0.0, 1.0] - Color4F preColor(-1.0f, -1.0f, -1.0f, -1.0f); - Color4F color; + Color4F preColor(-1.0F, -1.0F, -1.0F, -1.0F); + Color4F color; middleware::Texture2D *texture = nullptr; auto flush = [&]() { // fill pre segment count field if (_preISegWritePos != -1) { - SegmentData *preSegmentData = _frameData->buildSegmentData(_materialLen - 1); - preSegmentData->indexCount = _curISegLen; + SegmentData *preSegmentData = _frameData->buildSegmentData(_materialLen - 1); + preSegmentData->indexCount = _curISegLen; preSegmentData->vertexFloatCount = _curVSegLen; } SegmentData *segmentData = _frameData->buildSegmentData(_materialLen); segmentData->setTexture(texture); - segmentData->blendMode = (int)(slot->_blendMode); + segmentData->blendMode = static_cast(slot->_blendMode); // save new segment count pos field - _preISegWritePos = (int)ib.getCurPos() / sizeof(unsigned short); + _preISegWritePos = static_cast(ib.getCurPos() / sizeof(uint16_t)); // reset pre blend mode to current - _preBlendMode = (int)slot->_blendMode; + _preBlendMode = static_cast(slot->_blendMode); // reset pre texture index to current _preTextureIndex = _curTextureIndex; // reset index segmentation count @@ -306,23 +302,25 @@ void ArmatureCache::traverseArmature(Armature *armature, float parentOpacity /*= _materialLen++; }; - for (std::size_t i = 0, len = bones.size(); i < len; i++) { - bone = bones[i]; - auto boneCount = _frameData->getBoneCount(); - BoneData *boneData = _frameData->buildBoneData(boneCount); - auto &boneOriginMat = bone->globalTransformMatrix; - auto &matm = boneData->globalTransformMatrix.m; - matm[0] = boneOriginMat.a; - matm[1] = boneOriginMat.b; - matm[4] = -boneOriginMat.c; - matm[5] = -boneOriginMat.d; - matm[12] = boneOriginMat.tx; - matm[13] = boneOriginMat.ty; + for (auto *i : bones) { + bone = i; + auto boneCount = _frameData->getBoneCount(); + BoneData *boneData = _frameData->buildBoneData(boneCount); + auto & boneOriginMat = bone->globalTransformMatrix; + auto & matm = boneData->globalTransformMatrix.m; + matm[0] = boneOriginMat.a; + matm[1] = boneOriginMat.b; + matm[4] = -boneOriginMat.c; + matm[5] = -boneOriginMat.d; + matm[12] = boneOriginMat.tx; + matm[13] = boneOriginMat.ty; } - for (std::size_t i = 0, len = slots.size(); i < len; i++) { - slot = (CCSlot *)slots[i]; - + for (auto *i : slots) { + slot = dynamic_cast(i); // TODO(zhakasi): refine the logic + if (slot == nullptr) { + return; + } if (!slot->getVisible()) { continue; } @@ -333,7 +331,7 @@ void ArmatureCache::traverseArmature(Armature *armature, float parentOpacity /*= // If slots has child armature,will traverse child first. Armature *childArmature = slot->getChildArmature(); if (childArmature != nullptr) { - traverseArmature(childArmature, parentOpacity * slot->color.a / 255.0f); + traverseArmature(childArmature, parentOpacity * static_cast(slot->color.a) / 255.0F); continue; } @@ -345,36 +343,36 @@ void ArmatureCache::traverseArmature(Armature *armature, float parentOpacity /*= vb.checkSpace(vbSize, true); // If texture or blendMode change,will change material. - if (_preTextureIndex != _curTextureIndex || _preBlendMode != (int)slot->_blendMode) { + if (_preTextureIndex != _curTextureIndex || _preBlendMode != static_cast(slot->_blendMode)) { flush(); } // Calculation vertex color. - color.a = slot->color.a * parentOpacity / 255.0f; - color.r = slot->color.r / 255.0f; - color.g = slot->color.g / 255.0f; - color.b = slot->color.b / 255.0f; + color.a = static_cast(slot->color.a) * parentOpacity / 255.0F; + color.r = static_cast(slot->color.r) / 255.0F; + color.g = static_cast(slot->color.g) / 255.0F; + color.b = static_cast(slot->color.b) / 255.0F; if (preColor != color) { - preColor = color; + preColor = color; auto colorCount = _frameData->getColorCount(); if (colorCount > 0) { - ColorData *preColorData = _frameData->buildColorData(colorCount - 1); + ColorData *preColorData = _frameData->buildColorData(colorCount - 1); preColorData->vertexFloatOffset = vb.getCurPos() / sizeof(float); } ColorData *colorData = _frameData->buildColorData(colorCount); - colorData->color = color; + colorData->color = color; } // Transform component matrix to global matrix - middleware::Triangles &triangles = slot->triangles; + middleware::Triangles & triangles = slot->triangles; middleware::V2F_T2F_C4F *worldTriangles = slot->worldVerts; for (int v = 0, w = 0, vn = triangles.vertCount; v < vn; ++v, w += 2) { - middleware::V2F_T2F_C4F *vertex = triangles.verts + v; + middleware::V2F_T2F_C4F *vertex = triangles.verts + v; middleware::V2F_T2F_C4F *worldVertex = worldTriangles + v; - worldVertex->vertex.x = vertex->vertex.x * worldMatrix->m[0] + vertex->vertex.y * worldMatrix->m[4] + worldMatrix->m[12]; - worldVertex->vertex.y = vertex->vertex.x * worldMatrix->m[1] + vertex->vertex.y * worldMatrix->m[5] + worldMatrix->m[13]; + worldVertex->vertex.x = vertex->vertex.x * worldMatrix->m[0] + vertex->vertex.y * worldMatrix->m[4] + worldMatrix->m[12]; + worldVertex->vertex.y = vertex->vertex.x * worldMatrix->m[1] + vertex->vertex.y * worldMatrix->m[5] + worldMatrix->m[13]; worldVertex->color.r = color.r; worldVertex->color.g = color.g; @@ -382,9 +380,9 @@ void ArmatureCache::traverseArmature(Armature *armature, float parentOpacity /*= worldVertex->color.a = color.a; } - vb.writeBytes((char *)worldTriangles, vbSize); + vb.writeBytes(reinterpret_cast(worldTriangles), vbSize); - auto ibSize = triangles.indexCount * sizeof(unsigned short); + auto ibSize = triangles.indexCount * sizeof(uint16_t); ib.checkSpace(ibSize, true); auto vertexOffset = _curVSegLen / VF_XYZUVC; @@ -393,20 +391,20 @@ void ArmatureCache::traverseArmature(Armature *armature, float parentOpacity /*= } _curISegLen += triangles.indexCount; - _curVSegLen += vbSize / sizeof(float); + _curVSegLen += static_cast(vbSize / sizeof(float)); } // End slot traverse } void ArmatureCache::resetAllAnimationData() { - for (auto it = _animationCaches.begin(); it != _animationCaches.end(); it++) { - it->second->reset(); + for (auto &animationCache : _animationCaches) { + animationCache.second->reset(); } } void ArmatureCache::resetAnimationData(const std::string &animationName) { - for (auto it = _animationCaches.begin(); it != _animationCaches.end(); it++) { - if (it->second->_animationName == animationName) { - it->second->reset(); + for (auto &animationCache : _animationCaches) { + if (animationCache.second->_animationName == animationName) { + animationCache.second->reset(); break; } } diff --git a/native/cocos/editor-support/dragonbones-creator-support/ArmatureCache.h b/native/cocos/editor-support/dragonbones-creator-support/ArmatureCache.h index d619f9bb50..58bfe7b7f3 100644 --- a/native/cocos/editor-support/dragonbones-creator-support/ArmatureCache.h +++ b/native/cocos/editor-support/dragonbones-creator-support/ArmatureCache.h @@ -25,11 +25,11 @@ #include "CCArmatureDisplay.h" #include "IOBuffer.h" -#include "base/Ref.h" +#include "base/RefCounted.h" DRAGONBONES_NAMESPACE_BEGIN -class ArmatureCache : public cc::Ref { +class ArmatureCache : public cc::RefCounted { public: struct SegmentData { friend class ArmatureCache; @@ -37,12 +37,12 @@ public: SegmentData(); ~SegmentData(); - void setTexture(cc::middleware::Texture2D *value); + void setTexture(cc::middleware::Texture2D *value); cc::middleware::Texture2D *getTexture() const; public: - int blendMode = 0; - std::size_t indexCount = 0; + int blendMode = 0; + std::size_t indexCount = 0; std::size_t vertexFloatCount = 0; private: @@ -55,7 +55,7 @@ public: struct ColorData { cc::middleware::Color4F color; - std::size_t vertexFloatOffset = 0; + std::size_t vertexFloatOffset = 0; }; struct FrameData { @@ -87,8 +87,8 @@ public: // if bone data is empty, it will build new one. BoneData *buildBoneData(std::size_t index); - std::vector _bones; - std::vector _colors; + std::vector _bones; + std::vector _colors; std::vector _segments; public: @@ -103,7 +103,7 @@ public: ~AnimationData(); void reset(); - FrameData *getFrameData(std::size_t frameIdx) const; + FrameData * getFrameData(std::size_t frameIdx) const; std::size_t getFrameCount() const; bool isComplete() const { return _isComplete; } @@ -112,21 +112,20 @@ public: private: // if frame is empty, it will build new one. FrameData *buildFrameData(std::size_t frameIdx); - - private: - std::string _animationName = ""; + + std::string _animationName; bool _isComplete = false; - float _totalTime = 0.0f; + float _totalTime = 0.0F; std::vector _frames; }; ArmatureCache(const std::string &armatureName, const std::string &armatureKey, const std::string &atlasUUID); - virtual ~ArmatureCache(); + ~ArmatureCache() override; void updateToFrame(const std::string &animationName, int toFrameIdx = -1); // if animation data is empty, it will build new one. - AnimationData *buildAnimationData(const std::string &animationName); - AnimationData *getAnimationData(const std::string &animationName); + AnimationData * buildAnimationData(const std::string &animationName); + AnimationData * getAnimationData(const std::string &animationName); CCArmatureDisplay *getArmatureDisplay(); void resetAllAnimationData(); @@ -134,16 +133,16 @@ public: private: void renderAnimationFrame(AnimationData *animationData); - void traverseArmature(Armature *armature, float parentOpacity = 1.0f); + void traverseArmature(Armature *armature, float parentOpacity = 1.0F); public: - static float FrameTime; - static float MaxCacheTime; + static float FrameTime; // NOLINT + static float MaxCacheTime; // NOLINT private: FrameData *_frameData = nullptr; - cc::middleware::Color4F _preColor = cc::middleware::Color4F(-1.0f, -1.0f, -1.0f, -1.0f); - cc::middleware::Color4F _color = cc::middleware::Color4F(1.0f, 1.0f, 1.0f, 1.0f); + cc::middleware::Color4F _preColor = cc::middleware::Color4F(-1.0F, -1.0F, -1.0F, -1.0F); + cc::middleware::Color4F _color = cc::middleware::Color4F(1.0F, 1.0F, 1.0F, 1.0F); CCArmatureDisplay *_armatureDisplay = nullptr; int _preBlendMode = -1; int _preTextureIndex = -1; @@ -152,7 +151,7 @@ private: int _curISegLen = 0; int _curVSegLen = 0; int _materialLen = 0; - std::string _curAnimationName = ""; + std::string _curAnimationName; std::map _animationCaches; }; diff --git a/native/cocos/editor-support/dragonbones-creator-support/ArmatureCacheMgr.cpp b/native/cocos/editor-support/dragonbones-creator-support/ArmatureCacheMgr.cpp index 76cb7abaad..7b4937480d 100644 --- a/native/cocos/editor-support/dragonbones-creator-support/ArmatureCacheMgr.cpp +++ b/native/cocos/editor-support/dragonbones-creator-support/ArmatureCacheMgr.cpp @@ -22,23 +22,25 @@ */ #include "ArmatureCacheMgr.h" +#include "base/DeferredReleasePool.h" DRAGONBONES_NAMESPACE_BEGIN ArmatureCacheMgr *ArmatureCacheMgr::_instance = nullptr; -ArmatureCache *ArmatureCacheMgr::buildArmatureCache(const std::string &armatureName, const std::string &armatureKey, const std::string &atlasUUID) { +ArmatureCache * ArmatureCacheMgr::buildArmatureCache(const std::string &armatureName, const std::string &armatureKey, const std::string &atlasUUID) { ArmatureCache *animation = _caches.at(armatureKey); if (!animation) { animation = new ArmatureCache(armatureName, armatureKey, atlasUUID); + animation->addRef(); _caches.insert(armatureKey, animation); - animation->autorelease(); + cc::DeferredReleasePool::add(animation); } return animation; } -void ArmatureCacheMgr::removeArmatureCache(const std::string &uuid) { +void ArmatureCacheMgr::removeArmatureCache(const std::string &armatureKey) { for (auto it = _caches.begin(); it != _caches.end();) { - auto found = it->first.find(uuid); + auto found = it->first.find(armatureKey); if (found != std::string::npos) { it = _caches.erase(it); } else { diff --git a/native/cocos/editor-support/dragonbones-creator-support/CCArmatureCacheDisplay.cpp b/native/cocos/editor-support/dragonbones-creator-support/CCArmatureCacheDisplay.cpp index e4cb7969bd..4297f26e48 100644 --- a/native/cocos/editor-support/dragonbones-creator-support/CCArmatureCacheDisplay.cpp +++ b/native/cocos/editor-support/dragonbones-creator-support/CCArmatureCacheDisplay.cpp @@ -28,31 +28,29 @@ #include "SharedBufferManager.h" #include "base/TypeDef.h" #include "base/memory/Memory.h" -#include "math/Math.h" #include "gfx-base/GFXDef.h" +#include "math/Math.h" -using namespace cc; -using namespace cc::gfx; +using namespace cc; // NOLINT(google-build-using-namespace) +using namespace cc::gfx; // NOLINT(google-build-using-namespace) -static const std::string techStage = "opaque"; -static const std::string textureKey = "texture"; -static const std::string startEvent = "start"; -static const std::string loopCompleteEvent = "loopComplete"; -static const std::string completeEvent = "complete"; +static const std::string TECH_STAGE = "opaque"; +static const std::string TEXTURE_KEY = "texture"; +static const std::string START_EVENT = "start"; +static const std::string LOOP_COMPLETE_EVENT = "loopComplete"; +static const std::string COMPLETE_EVENT = "complete"; DRAGONBONES_NAMESPACE_BEGIN -USING_NS_MW; +USING_NS_MW; // NOLINT(google-build-using-namespace) CCArmatureCacheDisplay::CCArmatureCacheDisplay(const std::string &armatureName, const std::string &armatureKey, const std::string &atlasUUID, bool isShare) { _eventObject = BaseObject::borrowObject(); if (isShare) { _armatureCache = ArmatureCacheMgr::getInstance()->buildArmatureCache(armatureName, armatureKey, atlasUUID); - _armatureCache->retain(); + _armatureCache->addRef(); } else { _armatureCache = new ArmatureCache(armatureName, armatureKey, atlasUUID); - _armatureCache->retain(); - _armatureCache->autorelease(); } // store global TypedArray begin and end offset @@ -63,7 +61,7 @@ CCArmatureCacheDisplay::CCArmatureCacheDisplay(const std::string &armatureName, // set render order to 0 _paramsBuffer->writeFloat32(0); // set world transform to identity - _paramsBuffer->writeBytes((const char *)&cc::Mat4::IDENTITY, sizeof(float) * 16); + _paramsBuffer->writeBytes(reinterpret_cast(&cc::Mat4::IDENTITY), sizeof(float) * 16); beginSchedule(); } @@ -83,7 +81,6 @@ CCArmatureCacheDisplay::~CCArmatureCacheDisplay() { } void CCArmatureCacheDisplay::dispose() { - if (_armatureCache) { _armatureCache->release(); _armatureCache = nullptr; @@ -109,7 +106,7 @@ void CCArmatureCacheDisplay::update(float dt) { if (_accTime <= 0.00001 && _playCount == 0) { _eventObject->type = EventObject::START; - dispatchDBEvent(startEvent, _eventObject); + dispatchDBEvent(START_EVENT, _eventObject); } _accTime += dt; @@ -118,54 +115,53 @@ void CCArmatureCacheDisplay::update(float dt) { _armatureCache->updateToFrame(_animationName, frameIdx); } - int finalFrameIndex = (int)_animationData->getFrameCount() - 1; + int finalFrameIndex = static_cast(_animationData->getFrameCount()) - 1; if (_animationData->isComplete() && frameIdx >= finalFrameIndex) { _playCount++; - _accTime = 0.0f; + _accTime = 0.0F; if (_playTimes > 0 && _playCount >= _playTimes) { - frameIdx = finalFrameIndex; - _playCount = 0; + frameIdx = finalFrameIndex; + _playCount = 0; _isAniComplete = true; } else { frameIdx = 0; } _eventObject->type = EventObject::COMPLETE; - dispatchDBEvent(completeEvent, _eventObject); + dispatchDBEvent(COMPLETE_EVENT, _eventObject); _eventObject->type = EventObject::LOOP_COMPLETE; - dispatchDBEvent(loopCompleteEvent, _eventObject); + dispatchDBEvent(LOOP_COMPLETE_EVENT, _eventObject); } _curFrameIndex = frameIdx; } -void CCArmatureCacheDisplay::render(float dt) { - +void CCArmatureCacheDisplay::render(float /*dt*/) { if (!_animationData) return; ArmatureCache::FrameData *frameData = _animationData->getFrameData(_curFrameIndex); if (!frameData) return; - auto mgr = MiddlewareManager::getInstance(); + auto *mgr = MiddlewareManager::getInstance(); if (!mgr->isRendering) return; - auto &segments = frameData->getSegments(); - auto &colors = frameData->getColors(); + const auto &segments = frameData->getSegments(); + const auto &colors = frameData->getColors(); _sharedBufferOffset->reset(); _sharedBufferOffset->clear(); - auto renderMgr = mgr->getRenderInfoMgr(); - auto renderInfo = renderMgr->getBuffer(); + auto *renderMgr = mgr->getRenderInfoMgr(); + auto *renderInfo = renderMgr->getBuffer(); if (!renderInfo) return; - auto attachMgr = mgr->getAttachInfoMgr(); - auto attachInfo = attachMgr->getBuffer(); + auto *attachMgr = mgr->getAttachInfoMgr(); + auto *attachInfo = attachMgr->getBuffer(); if (!attachInfo) return; // store render info offset - _sharedBufferOffset->writeUint32((uint32_t)renderInfo->getCurPos() / sizeof(uint32_t)); + _sharedBufferOffset->writeUint32(static_cast(renderInfo->getCurPos()) / sizeof(uint32_t)); // store attach info offset - _sharedBufferOffset->writeUint32((uint32_t)attachInfo->getCurPos() / sizeof(uint32_t)); + _sharedBufferOffset->writeUint32(static_cast(attachInfo->getCurPos()) / sizeof(uint32_t)); // check enough space renderInfo->checkSpace(sizeof(uint32_t) * 2, true); @@ -175,54 +171,57 @@ void CCArmatureCacheDisplay::render(float dt) { // matieral len renderInfo->writeUint32(segments.size()); - if (segments.size() == 0 || colors.size() == 0) return; + if (segments.empty() || colors.empty()) return; - middleware::MeshBuffer *mb = mgr->getMeshBuffer(VF_XYZUVC); - middleware::IOBuffer &vb = mb->getVB(); - middleware::IOBuffer &ib = mb->getIB(); - const auto &srcVB = frameData->vb; - const auto &srcIB = frameData->ib; + middleware::MeshBuffer *mb = mgr->getMeshBuffer(VF_XYZUVC); + middleware::IOBuffer & vb = mb->getVB(); + middleware::IOBuffer & ib = mb->getIB(); + const auto & srcVB = frameData->vb; + const auto & srcIB = frameData->ib; - auto paramsBuffer = _paramsBuffer->getBuffer(); - const cc::Mat4 &nodeWorldMat = *(cc::Mat4 *)¶msBuffer[4]; + auto * paramsBuffer = _paramsBuffer->getBuffer(); + const cc::Mat4 &nodeWorldMat = *reinterpret_cast(¶msBuffer[4]); - int colorOffset = 0; - ArmatureCache::ColorData *nowColor = colors[colorOffset++]; - auto maxVFOffset = nowColor->vertexFloatOffset; + int colorOffset = 0; + ArmatureCache::ColorData *nowColor = colors[colorOffset++]; + auto maxVFOffset = nowColor->vertexFloatOffset; Color4F color; - float tempR = 0.0f, tempG = 0.0f, tempB = 0.0f, tempA = 0.0f; - float multiplier = 1.0f; - std::size_t srcVertexBytesOffset = 0; - std::size_t srcIndexBytesOffset = 0; - std::size_t vertexBytes = 0; - std::size_t indexBytes = 0; - int curTextureIndex = 0; - BlendMode blendMode = BlendMode::Normal; - std::size_t dstVertexOffset = 0; - std::size_t dstIndexOffset = 0; - float *dstVertexBuffer = nullptr; - unsigned int *dstColorBuffer = nullptr; - unsigned short *dstIndexBuffer = nullptr; - bool needColor = false; - int curBlendSrc = -1; - int curBlendDst = -1; + float tempR = 0.0F; + float tempG = 0.0F; + float tempB = 0.0F; + float tempA = 0.0F; + float multiplier = 1.0F; + std::size_t srcVertexBytesOffset = 0; + std::size_t srcIndexBytesOffset = 0; + std::size_t vertexBytes = 0; + std::size_t indexBytes = 0; + int curTextureIndex = 0; + BlendMode blendMode = BlendMode::Normal; + std::size_t dstVertexOffset = 0; + std::size_t dstIndexOffset = 0; + float * dstVertexBuffer = nullptr; + unsigned int *dstColorBuffer = nullptr; + uint16_t * dstIndexBuffer = nullptr; + bool needColor = false; + int curBlendSrc = -1; + int curBlendDst = -1; - if (abs(_nodeColor.r - 1.0f) > 0.0001f || - abs(_nodeColor.g - 1.0f) > 0.0001f || - abs(_nodeColor.b - 1.0f) > 0.0001f || - abs(_nodeColor.a - 1.0f) > 0.0001f || + if (abs(_nodeColor.r - 1.0F) > 0.0001F || + abs(_nodeColor.g - 1.0F) > 0.0001F || + abs(_nodeColor.b - 1.0F) > 0.0001F || + abs(_nodeColor.a - 1.0F) > 0.0001F || _premultipliedAlpha) { needColor = true; } auto handleColor = [&](ArmatureCache::ColorData *colorData) { - tempA = colorData->color.a * _nodeColor.a; + tempA = colorData->color.a * _nodeColor.a; multiplier = _premultipliedAlpha ? tempA / 255.0f : 1.0f; - tempR = _nodeColor.r * multiplier; - tempG = _nodeColor.g * multiplier; - tempB = _nodeColor.b * multiplier; + tempR = _nodeColor.r * multiplier; + tempG = _nodeColor.g * multiplier; + tempB = _nodeColor.b * multiplier; color.a = tempA; color.r = colorData->color.r * tempR; @@ -232,8 +231,7 @@ void CCArmatureCacheDisplay::render(float dt) { handleColor(nowColor); - for (std::size_t segIndex = 0, segLen = segments.size(); segIndex < segLen; segIndex++) { - auto segment = segments[segIndex]; + for (auto *segment : segments) { vertexBytes = segment->vertexFloatCount * sizeof(float); // check enough space @@ -243,23 +241,23 @@ void CCArmatureCacheDisplay::render(float dt) { curTextureIndex = segment->getTexture()->getRealTextureIndex(); renderInfo->writeUint32(curTextureIndex); - blendMode = (BlendMode)segment->blendMode; + blendMode = static_cast(segment->blendMode); switch (blendMode) { case BlendMode::Add: - curBlendSrc = (int)(_premultipliedAlpha ? BlendFactor::ONE : BlendFactor::SRC_ALPHA); - curBlendDst = (int)BlendFactor::ONE; + curBlendSrc = static_cast(_premultipliedAlpha ? BlendFactor::ONE : BlendFactor::SRC_ALPHA); + curBlendDst = static_cast(BlendFactor::ONE); break; case BlendMode::Multiply: - curBlendSrc = (int)BlendFactor::DST_COLOR; - curBlendDst = (int)BlendFactor::ONE_MINUS_SRC_ALPHA; + curBlendSrc = static_cast(BlendFactor::DST_COLOR); + curBlendDst = static_cast(BlendFactor::ONE_MINUS_SRC_ALPHA); break; case BlendMode::Screen: - curBlendSrc = (int)BlendFactor::ONE; - curBlendDst = (int)BlendFactor::ONE_MINUS_SRC_COLOR; + curBlendSrc = static_cast(BlendFactor::ONE); + curBlendDst = static_cast(BlendFactor::ONE_MINUS_SRC_COLOR); break; default: - curBlendSrc = (int)(_premultipliedAlpha ? BlendFactor::ONE : BlendFactor::SRC_ALPHA); - curBlendDst = (int)BlendFactor::ONE_MINUS_SRC_ALPHA; + curBlendSrc = static_cast(_premultipliedAlpha ? BlendFactor::ONE : BlendFactor::SRC_ALPHA); + curBlendDst = static_cast(BlendFactor::ONE_MINUS_SRC_ALPHA); break; } // fill new blend src and dst @@ -269,16 +267,16 @@ void CCArmatureCacheDisplay::render(float dt) { // fill vertex buffer vb.checkSpace(vertexBytes, true); dstVertexOffset = vb.getCurPos() / sizeof(V2F_T2F_C4F); - dstVertexBuffer = (float *)vb.getCurBuffer(); - dstColorBuffer = (unsigned int *)vb.getCurBuffer(); - vb.writeBytes((char *)srcVB.getBuffer() + srcVertexBytesOffset, vertexBytes); + dstVertexBuffer = reinterpret_cast(vb.getCurBuffer()); + dstColorBuffer = reinterpret_cast(vb.getCurBuffer()); + vb.writeBytes(reinterpret_cast(srcVB.getBuffer()) + srcVertexBytesOffset, vertexBytes); // batch handle if (_batch) { cc::Vec3 *point = nullptr; for (auto posIndex = 0; posIndex < segment->vertexFloatCount; posIndex += VF_XYZUVC) { - point = (cc::Vec3 *)(dstVertexBuffer + posIndex); + point = reinterpret_cast(dstVertexBuffer + posIndex); // force z value to zero point->z = 0; point->transformMat4(*point, nodeWorldMat); @@ -302,11 +300,11 @@ void CCArmatureCacheDisplay::render(float dt) { srcVertexBytesOffset += vertexBytes; // fill index buffer - indexBytes = segment->indexCount * sizeof(unsigned short); + indexBytes = segment->indexCount * sizeof(uint16_t); ib.checkSpace(indexBytes, true); - dstIndexOffset = (int)ib.getCurPos() / sizeof(unsigned short); - dstIndexBuffer = (unsigned short *)ib.getCurBuffer(); - ib.writeBytes((char *)srcIB.getBuffer() + srcIndexBytesOffset, indexBytes); + dstIndexOffset = static_cast(ib.getCurPos()) / sizeof(uint16_t); + dstIndexBuffer = reinterpret_cast(ib.getCurBuffer()); + ib.writeBytes(reinterpret_cast(srcIB.getBuffer()) + srcIndexBytesOffset, indexBytes); for (auto indexPos = 0; indexPos < segment->indexCount; indexPos++) { dstIndexBuffer[indexPos] += dstVertexOffset; } @@ -323,13 +321,13 @@ void CCArmatureCacheDisplay::render(float dt) { } if (_useAttach) { - auto &bonesData = frameData->getBones(); - auto boneCount = frameData->getBoneCount(); + const auto &bonesData = frameData->getBones(); + auto boneCount = frameData->getBoneCount(); - for (int i = 0, n = boneCount; i < n; i++) { - auto bone = bonesData[i]; + for (int i = 0; i < boneCount; i++) { + auto *bone = bonesData[i]; attachInfo->checkSpace(sizeof(cc::Mat4), true); - attachInfo->writeBytes((const char *)&bone->globalTransformMatrix, sizeof(cc::Mat4)); + attachInfo->writeBytes(reinterpret_cast(&bone->globalTransformMatrix), sizeof(cc::Mat4)); } } } @@ -355,22 +353,22 @@ void CCArmatureCacheDisplay::onDisable() { } Armature *CCArmatureCacheDisplay::getArmature() const { - auto armatureDisplay = _armatureCache->getArmatureDisplay(); + auto *armatureDisplay = _armatureCache->getArmatureDisplay(); return armatureDisplay->getArmature(); } Animation *CCArmatureCacheDisplay::getAnimation() const { - auto armature = getArmature(); + auto *armature = getArmature(); return armature->getAnimation(); } void CCArmatureCacheDisplay::playAnimation(const std::string &name, int playTimes) { - _playTimes = playTimes; + _playTimes = playTimes; _animationName = name; _animationData = _armatureCache->buildAnimationData(_animationName); _isAniComplete = false; - _accTime = 0.0f; - _playCount = 0; + _accTime = 0.0F; + _playCount = 0; _curFrameIndex = 0; } @@ -405,10 +403,10 @@ void CCArmatureCacheDisplay::updateAllAnimationCache() { } void CCArmatureCacheDisplay::setColor(float r, float g, float b, float a) { - _nodeColor.r = r / 255.0f; - _nodeColor.g = g / 255.0f; - _nodeColor.b = b / 255.0f; - _nodeColor.a = a / 255.0f; + _nodeColor.r = r / 255.0F; + _nodeColor.g = g / 255.0F; + _nodeColor.b = b / 255.0F; + _nodeColor.a = a / 255.0F; } void CCArmatureCacheDisplay::setAttachEnabled(bool enabled) { @@ -431,8 +429,8 @@ se_object_ptr CCArmatureCacheDisplay::getParamsBuffer() const { uint32_t CCArmatureCacheDisplay::getRenderOrder() const { if (_paramsBuffer) { - auto buffer = _paramsBuffer->getBuffer(); - return (uint32_t)buffer[0]; + auto *buffer = _paramsBuffer->getBuffer(); + return static_cast(buffer[0]); } return 0; } diff --git a/native/cocos/editor-support/dragonbones-creator-support/CCArmatureCacheDisplay.h b/native/cocos/editor-support/dragonbones-creator-support/CCArmatureCacheDisplay.h index 9bc57ea4d5..8451c4f080 100644 --- a/native/cocos/editor-support/dragonbones-creator-support/CCArmatureCacheDisplay.h +++ b/native/cocos/editor-support/dragonbones-creator-support/CCArmatureCacheDisplay.h @@ -23,22 +23,24 @@ #pragma once +#include + #include "ArmatureCache.h" #include "CCArmatureDisplay.h" -#include "base/Ref.h" +#include "base/RefCounted.h" #include "dragonbones/DragonBonesHeaders.h" DRAGONBONES_NAMESPACE_BEGIN -class CCArmatureCacheDisplay : public cc::middleware::IMiddleware, public cc::Ref { +class CCArmatureCacheDisplay : public cc::RefCounted, public cc::middleware::IMiddleware { public: CCArmatureCacheDisplay(const std::string &armatureName, const std::string &armatureKey, const std::string &atlasUUID, bool isShare); - virtual ~CCArmatureCacheDisplay(); + ~CCArmatureCacheDisplay() override; void dispose(); - virtual void update(float dt) override; - virtual void render(float dt) override; - virtual uint32_t getRenderOrder() const override; + void update(float dt) override; + void render(float dt) override; + uint32_t getRenderOrder() const override; void setTimeScale(float scale) { _timeScale = scale; @@ -53,7 +55,7 @@ public: void onEnable(); void onDisable(); - Armature *getArmature() const; + Armature * getArmature() const; Animation *getAnimation() const; void setColor(float r, float g, float b, float a); @@ -67,9 +69,9 @@ public: _premultipliedAlpha = value; } - typedef std::function dbEventCallback; - void setDBEventCallback(dbEventCallback callback) { - _dbEventCallback = callback; + using dbEventCallback = std::function; + void setDBEventCallback(dbEventCallback callback) { + _dbEventCallback = std::move(callback); } void addDBEventListener(const std::string &type); void removeDBEventListener(const std::string &type); @@ -91,26 +93,26 @@ public: se_object_ptr getParamsBuffer() const; private: - float _timeScale = 1; - int _curFrameIndex = -1; - float _accTime = 0.0f; - int _playCount = 0; - int _playTimes = 0; - bool _isAniComplete = true; - std::string _animationName = ""; + float _timeScale = 1; + int _curFrameIndex = -1; + float _accTime = 0.0F; + int _playCount = 0; + int _playTimes = 0; + bool _isAniComplete = true; + std::string _animationName; - Armature *_armature = nullptr; + Armature * _armature = nullptr; ArmatureCache::AnimationData *_animationData = nullptr; - std::map _listenerIDMap; + std::map _listenerIDMap; - bool _useAttach = false; - bool _batch = true; + bool _useAttach = false; + bool _batch = true; cc::middleware::Color4F _nodeColor = cc::middleware::Color4F::WHITE; - bool _premultipliedAlpha = false; - dbEventCallback _dbEventCallback = nullptr; - ArmatureCache *_armatureCache = nullptr; - EventObject *_eventObject; + bool _premultipliedAlpha = false; + dbEventCallback _dbEventCallback = nullptr; + ArmatureCache * _armatureCache = nullptr; + EventObject * _eventObject; cc::middleware::IOTypedArray *_sharedBufferOffset = nullptr; // Js fill this buffer to send parameter to cpp, avoid to call jsb function. diff --git a/native/cocos/editor-support/dragonbones-creator-support/CCArmatureDisplay.cpp b/native/cocos/editor-support/dragonbones-creator-support/CCArmatureDisplay.cpp index 174c3bd35a..21719288ea 100644 --- a/native/cocos/editor-support/dragonbones-creator-support/CCArmatureDisplay.cpp +++ b/native/cocos/editor-support/dragonbones-creator-support/CCArmatureDisplay.cpp @@ -24,30 +24,26 @@ #include "dragonbones-creator-support/CCArmatureDisplay.h" #include "MiddlewareMacro.h" #include "SharedBufferManager.h" +#include "base/DeferredReleasePool.h" #include "base/TypeDef.h" #include "base/memory/Memory.h" #include "dragonbones-creator-support/CCSlot.h" +#include "gfx-base/GFXDef.h" #include "math/Math.h" #include "math/Vec3.h" -#include "gfx-base/GFXDef.h" -USING_NS_MW; -using namespace cc; -using namespace cc::gfx; +USING_NS_MW; // NOLINT(google-build-using-namespace) +using namespace cc; // NOLINT(google-build-using-namespace) -static const std::string techStage = "opaque"; -static const std::string textureKey = "texture"; +static const std::string TECH_STAGE = "opaque"; +static const std::string TEXTURE_KEY = "texture"; +namespace cc { +} DRAGONBONES_NAMESPACE_BEGIN CCArmatureDisplay *CCArmatureDisplay::create() { - CCArmatureDisplay *displayContainer = new (std::nothrow) CCArmatureDisplay(); - if (displayContainer) { - displayContainer->autorelease(); - } else { - CC_SAFE_DELETE(displayContainer); - } - return displayContainer; + return new (std::nothrow) CCArmatureDisplay(); } CCArmatureDisplay::CCArmatureDisplay() { @@ -58,11 +54,11 @@ CCArmatureDisplay::CCArmatureDisplay() { // set render order to 0 _paramsBuffer->writeFloat32(0); // set world transform to identity - _paramsBuffer->writeBytes((const char *)&cc::Mat4::IDENTITY, sizeof(float) * 16); + _paramsBuffer->writeBytes(reinterpret_cast(&cc::Mat4::IDENTITY), sizeof(float) * 16); } CCArmatureDisplay::~CCArmatureDisplay() { - dispose(); + dispose(true); if (_debugBuffer) { delete _debugBuffer; @@ -80,7 +76,7 @@ CCArmatureDisplay::~CCArmatureDisplay() { } } -void CCArmatureDisplay::dispose(bool disposeProxy) { +void CCArmatureDisplay::dispose(bool /*disposeProxy*/) { if (_armature != nullptr) { _armature->dispose(); _armature = nullptr; @@ -102,24 +98,25 @@ void CCArmatureDisplay::dbRender() { _sharedBufferOffset->reset(); _sharedBufferOffset->clear(); - if (this->_armature->getParent()) + if (this->_armature->getParent()) { return; + } - auto mgr = MiddlewareManager::getInstance(); + auto *mgr = MiddlewareManager::getInstance(); if (!mgr->isRendering) return; - auto renderMgr = mgr->getRenderInfoMgr(); - auto renderInfo = renderMgr->getBuffer(); + auto *renderMgr = mgr->getRenderInfoMgr(); + auto *renderInfo = renderMgr->getBuffer(); if (!renderInfo) return; - auto attachMgr = mgr->getAttachInfoMgr(); - auto attachInfo = attachMgr->getBuffer(); + auto *attachMgr = mgr->getAttachInfoMgr(); + auto *attachInfo = attachMgr->getBuffer(); if (!attachInfo) return; // store render info offset - _sharedBufferOffset->writeUint32((uint32_t)renderInfo->getCurPos() / sizeof(uint32_t)); + _sharedBufferOffset->writeUint32(static_cast(renderInfo->getCurPos()) / sizeof(uint32_t)); // store attach info offset - _sharedBufferOffset->writeUint32((uint32_t)attachInfo->getCurPos() / sizeof(uint32_t)); + _sharedBufferOffset->writeUint32(static_cast(attachInfo->getCurPos()) / sizeof(uint32_t)); // check enough space renderInfo->checkSpace(sizeof(uint32_t) * 2, true); @@ -131,20 +128,20 @@ void CCArmatureDisplay::dbRender() { renderInfo->writeUint32(0); // render not ready - auto paramsBuffer = _paramsBuffer->getBuffer(); - float renderOrder = *(float *)paramsBuffer; + auto *paramsBuffer = _paramsBuffer->getBuffer(); + float renderOrder = *reinterpret_cast(paramsBuffer); if (renderOrder < 0) { return; } - _preBlendMode = -1; + _preBlendMode = -1; _preTextureIndex = -1; _curTextureIndex = -1; _preISegWritePos = -1; - _curISegLen = 0; + _curISegLen = 0; _debugSlotsLen = 0; - _materialLen = 0; + _materialLen = 0; // Traverse all aramture to fill vertex and index buffer. traverseArmature(_armature); @@ -155,7 +152,7 @@ void CCArmatureDisplay::dbRender() { } if (_useAttach || _debugDraw) { - auto &bones = _armature->getBones(); + const auto &bones = _armature->getBones(); std::size_t count = bones.size(); cc::Mat4 boneMat = cc::Mat4::IDENTITY; @@ -166,29 +163,29 @@ void CCArmatureDisplay::dbRender() { _debugBuffer = new IOTypedArray(se::Object::TypedArrayType::FLOAT32, MAX_DEBUG_BUFFER_SIZE); } _debugBuffer->reset(); - _debugBuffer->writeFloat32(count * 4); + _debugBuffer->writeFloat32(static_cast(count) * 4); } for (int i = 0; i < count; i++) { - Bone *bone = (Bone *)bones[i]; + Bone *bone = static_cast(bones[i]); float boneLen = 5; if (bone->_boneData->length > boneLen) { boneLen = bone->_boneData->length; } - boneMat.m[0] = bone->globalTransformMatrix.a; - boneMat.m[1] = bone->globalTransformMatrix.b; - boneMat.m[4] = -bone->globalTransformMatrix.c; - boneMat.m[5] = -bone->globalTransformMatrix.d; + boneMat.m[0] = bone->globalTransformMatrix.a; + boneMat.m[1] = bone->globalTransformMatrix.b; + boneMat.m[4] = -bone->globalTransformMatrix.c; + boneMat.m[5] = -bone->globalTransformMatrix.d; boneMat.m[12] = bone->globalTransformMatrix.tx; boneMat.m[13] = bone->globalTransformMatrix.ty; attachInfo->checkSpace(sizeof(boneMat), true); - attachInfo->writeBytes((const char *)&boneMat, sizeof(boneMat)); + attachInfo->writeBytes(reinterpret_cast(&boneMat), sizeof(boneMat)); if (_debugDraw) { - float bx = bone->globalTransformMatrix.tx; - float by = bone->globalTransformMatrix.ty; + float bx = bone->globalTransformMatrix.tx; + float by = bone->globalTransformMatrix.ty; float endx = bx + bone->globalTransformMatrix.a * boneLen; float endy = by + bone->globalTransformMatrix.b * boneLen; _debugBuffer->writeFloat32(bx); @@ -206,17 +203,18 @@ void CCArmatureDisplay::dbRender() { } } -cc::Vec2 CCArmatureDisplay::convertToRootSpace(float x, float y) const { - CCSlot *slot = (CCSlot *)_armature->getParent(); +const cc::Vec2 &CCArmatureDisplay::convertToRootSpace(float x, float y) const { + auto *slot = reinterpret_cast(_armature->getParent()); if (!slot) { - return cc::Vec2(x, y); + _tmpVec2.set(x, y); + return _tmpVec2; } - cc::Vec2 newPos; + slot->updateWorldMatrix(); cc::Mat4 &worldMatrix = slot->worldMatrix; - newPos.x = x * worldMatrix.m[0] + y * worldMatrix.m[4] + worldMatrix.m[12]; - newPos.y = x * worldMatrix.m[1] + y * worldMatrix.m[5] + worldMatrix.m[13]; - return newPos; + _tmpVec2.x = x * worldMatrix.m[0] + y * worldMatrix.m[4] + worldMatrix.m[12]; + _tmpVec2.y = x * worldMatrix.m[1] + y * worldMatrix.m[5] + worldMatrix.m[13]; + return _tmpVec2; } CCArmatureDisplay *CCArmatureDisplay::getRootDisplay() { @@ -227,40 +225,43 @@ CCArmatureDisplay *CCArmatureDisplay::getRootDisplay() { Slot *parentSlot = slot->_armature->getParent(); while (parentSlot) { - slot = parentSlot; + slot = parentSlot; parentSlot = parentSlot->_armature->getParent(); } - return (CCArmatureDisplay *)slot->_armature->getDisplay(); + return static_cast(slot->_armature->getDisplay()); } void CCArmatureDisplay::traverseArmature(Armature *armature, float parentOpacity) { static cc::Mat4 matrixTemp; - auto paramsBuffer = _paramsBuffer->getBuffer(); + auto *paramsBuffer = _paramsBuffer->getBuffer(); // data store in buffer which 0 to 3 is render order, left data is node world matrix - const cc::Mat4 &nodeWorldMat = *(cc::Mat4 *)¶msBuffer[4]; + const cc::Mat4 &nodeWorldMat = *reinterpret_cast(¶msBuffer[4]); - auto &slots = armature->getSlots(); - auto mgr = MiddlewareManager::getInstance(); + const auto &slots = armature->getSlots(); + auto * mgr = MiddlewareManager::getInstance(); middleware::MeshBuffer *mb = mgr->getMeshBuffer(VF_XYZUVC); - IOBuffer &vb = mb->getVB(); - IOBuffer &ib = mb->getIB(); + IOBuffer & vb = mb->getVB(); + IOBuffer & ib = mb->getIB(); float realOpacity = _nodeColor.a; - auto renderMgr = mgr->getRenderInfoMgr(); - auto renderInfo = renderMgr->getBuffer(); + auto *renderMgr = mgr->getRenderInfoMgr(); + auto *renderInfo = renderMgr->getBuffer(); if (!renderInfo) return; - auto attachMgr = mgr->getAttachInfoMgr(); - auto attachInfo = attachMgr->getBuffer(); + auto *attachMgr = mgr->getAttachInfoMgr(); + auto *attachInfo = attachMgr->getBuffer(); if (!attachInfo) return; // range [0.0, 255.0] - float r, g, b, a; - CCSlot *slot = nullptr; + float r; + float g; + float b; + float a; + CCSlot * slot = nullptr; middleware::Texture2D *texture = nullptr; - int isFull = 0; + int isFull = 0; auto flush = [&]() { // fill pre segment count field @@ -272,20 +273,20 @@ void CCArmatureDisplay::traverseArmature(Armature *armature, float parentOpacity // prepare to fill new segment field switch (slot->_blendMode) { case BlendMode::Add: - _curBlendSrc = (int)(_premultipliedAlpha ? BlendFactor::ONE : BlendFactor::SRC_ALPHA); - _curBlendDst = (int)BlendFactor::ONE; + _curBlendSrc = static_cast(_premultipliedAlpha ? gfx::BlendFactor::ONE : gfx::BlendFactor::SRC_ALPHA); + _curBlendDst = static_cast(gfx::BlendFactor::ONE); break; case BlendMode::Multiply: - _curBlendSrc = (int)BlendFactor::DST_COLOR; - _curBlendDst = (int)BlendFactor::ONE_MINUS_SRC_ALPHA; + _curBlendSrc = static_cast(gfx::BlendFactor::DST_COLOR); + _curBlendDst = static_cast(gfx::BlendFactor::ONE_MINUS_SRC_ALPHA); break; case BlendMode::Screen: - _curBlendSrc = (int)BlendFactor::ONE; - _curBlendDst = (int)BlendFactor::ONE_MINUS_SRC_COLOR; + _curBlendSrc = static_cast(gfx::BlendFactor::ONE); + _curBlendDst = static_cast(gfx::BlendFactor::ONE_MINUS_SRC_COLOR); break; default: - _curBlendSrc = (int)(_premultipliedAlpha ? BlendFactor::ONE : BlendFactor::SRC_ALPHA); - _curBlendDst = (int)BlendFactor::ONE_MINUS_SRC_ALPHA; + _curBlendSrc = static_cast(_premultipliedAlpha ? gfx::BlendFactor::ONE : gfx::BlendFactor::SRC_ALPHA); + _curBlendDst = static_cast(gfx::BlendFactor::ONE_MINUS_SRC_ALPHA); break; } @@ -302,16 +303,16 @@ void CCArmatureDisplay::traverseArmature(Armature *armature, float parentOpacity renderInfo->writeUint32(bufferIndex); // fill new index offset - renderInfo->writeUint32((uint32_t)ib.getCurPos() / sizeof(unsigned short)); + renderInfo->writeUint32(static_cast(ib.getCurPos()) / sizeof(uint16_t)); // save new segment indices count pos field - _preISegWritePos = (int)renderInfo->getCurPos(); + _preISegWritePos = static_cast(renderInfo->getCurPos()); // reserve indice segamentation count renderInfo->writeUint32(0); // reset pre blend mode to current - _preBlendMode = (int)slot->_blendMode; + _preBlendMode = static_cast(slot->_blendMode); // reset pre texture index to current _preTextureIndex = _curTextureIndex; @@ -321,9 +322,12 @@ void CCArmatureDisplay::traverseArmature(Armature *armature, float parentOpacity _materialLen++; }; - for (std::size_t i = 0, len = slots.size(); i < len; i++) { + for (auto *i : slots) { isFull = 0; - slot = (CCSlot *)slots[i]; + slot = dynamic_cast(i); //TODO(zhakasi): refine the logic + if (slot == nullptr) { + return; + } if (!slot->getVisible()) { continue; } @@ -333,31 +337,31 @@ void CCArmatureDisplay::traverseArmature(Armature *armature, float parentOpacity // If slots has child armature,will traverse child first. Armature *childArmature = slot->getChildArmature(); if (childArmature != nullptr) { - traverseArmature(childArmature, parentOpacity * slot->color.a / 255.0f); + traverseArmature(childArmature, parentOpacity * static_cast(slot->color.a) / 255.0F); continue; } texture = slot->getTexture(); if (!texture) continue; _curTextureIndex = texture->getRealTextureIndex(); - auto vbSize = slot->triangles.vertCount * sizeof(middleware::V2F_T2F_C4F); + auto vbSize = slot->triangles.vertCount * sizeof(middleware::V2F_T2F_C4F); isFull |= vb.checkSpace(vbSize, true); // If texture or blendMode change,will change material. - if (_preTextureIndex != _curTextureIndex || _preBlendMode != (int)slot->_blendMode || isFull) { + if (_preTextureIndex != _curTextureIndex || _preBlendMode != static_cast(slot->_blendMode) || isFull) { flush(); } // Calculation vertex color. - a = realOpacity * slot->color.a * parentOpacity / 255.0f; - float multiplier = _premultipliedAlpha ? a / 255.0f : 1.0f / 255.0f; - r = _nodeColor.r * slot->color.r * multiplier; - g = _nodeColor.g * slot->color.g * multiplier; - b = _nodeColor.b * slot->color.b * multiplier; + a = realOpacity * static_cast(slot->color.a) * parentOpacity / 255.0F; + float multiplier = _premultipliedAlpha ? a / 255.0F : 1.0F / 255.0F; + r = _nodeColor.r * static_cast(slot->color.r) * multiplier; + g = _nodeColor.g * static_cast(slot->color.g) * multiplier; + b = _nodeColor.b * static_cast(slot->color.b) * multiplier; // Transform component matrix to global matrix - middleware::Triangles &triangles = slot->triangles; - cc::Mat4 *worldMatrix = &slot->worldMatrix; + middleware::Triangles &triangles = slot->triangles; + cc::Mat4 * worldMatrix = &slot->worldMatrix; if (_batch) { cc::Mat4::multiply(nodeWorldMat, *worldMatrix, &matrixTemp); worldMatrix = &matrixTemp; @@ -366,10 +370,10 @@ void CCArmatureDisplay::traverseArmature(Armature *armature, float parentOpacity middleware::V2F_T2F_C4F *worldTriangles = slot->worldVerts; for (int v = 0, w = 0, vn = triangles.vertCount; v < vn; ++v, w += 2) { - middleware::V2F_T2F_C4F *vertex = triangles.verts + v; + middleware::V2F_T2F_C4F *vertex = triangles.verts + v; middleware::V2F_T2F_C4F *worldVertex = worldTriangles + v; - vertex->vertex.z = 0;//reset for z value + vertex->vertex.z = 0; //reset for z value worldVertex->vertex.transformMat4(vertex->vertex, *worldMatrix); worldVertex->color.r = r; @@ -380,9 +384,9 @@ void CCArmatureDisplay::traverseArmature(Armature *armature, float parentOpacity // Fill MiddlewareManager vertex buffer auto vertexOffset = vb.getCurPos() / sizeof(middleware::V2F_T2F_C4F); - vb.writeBytes((char *)worldTriangles, vbSize); + vb.writeBytes(reinterpret_cast(worldTriangles), vbSize); - auto ibSize = triangles.indexCount * sizeof(unsigned short); + auto ibSize = triangles.indexCount * sizeof(uint16_t); ib.checkSpace(ibSize, true); // If vertex buffer current offset is zero,fill it directly or recalculate vertex offset. if (vertexOffset > 0) { @@ -390,7 +394,7 @@ void CCArmatureDisplay::traverseArmature(Armature *armature, float parentOpacity ib.writeUint16(triangles.indices[ii] + vertexOffset); } } else { - ib.writeBytes((char *)triangles.indices, ibSize); + ib.writeBytes(reinterpret_cast(triangles.indices), ibSize); } // Record this turn index segmentation count,it will store in material buffer in the end. @@ -403,7 +407,7 @@ bool CCArmatureDisplay::hasDBEventListener(const std::string &type) const { return it != _listenerIDMap.end(); } -void CCArmatureDisplay::addDBEventListener(const std::string &type, const std::function &callback) { +void CCArmatureDisplay::addDBEventListener(const std::string &type, const std::function & /*listener*/) { _listenerIDMap[type] = true; } @@ -418,7 +422,7 @@ void CCArmatureDisplay::dispatchDBEvent(const std::string &type, EventObject *va } } -void CCArmatureDisplay::removeDBEventListener(const std::string &type, const std::function &callback) { +void CCArmatureDisplay::removeDBEventListener(const std::string &type, const std::function & /*listener*/) { auto it = _listenerIDMap.find(type); if (it != _listenerIDMap.end()) { _listenerIDMap.erase(it); @@ -433,10 +437,10 @@ se_object_ptr CCArmatureDisplay::getDebugData() const { } void CCArmatureDisplay::setColor(float r, float g, float b, float a) { - _nodeColor.r = r / 255.0f; - _nodeColor.g = g / 255.0f; - _nodeColor.b = b / 255.0f; - _nodeColor.a = a / 255.0f; + _nodeColor.r = r / 255.0F; + _nodeColor.g = g / 255.0F; + _nodeColor.b = b / 255.0F; + _nodeColor.a = a / 255.0F; } se_object_ptr CCArmatureDisplay::getSharedBufferOffset() const { @@ -455,8 +459,8 @@ se_object_ptr CCArmatureDisplay::getParamsBuffer() const { uint32_t CCArmatureDisplay::getRenderOrder() const { if (_paramsBuffer) { - auto buffer = _paramsBuffer->getBuffer(); - return (uint32_t)buffer[0]; + auto *buffer = _paramsBuffer->getBuffer(); + return static_cast(buffer[0]); } return 0; } diff --git a/native/cocos/editor-support/dragonbones-creator-support/CCArmatureDisplay.h b/native/cocos/editor-support/dragonbones-creator-support/CCArmatureDisplay.h index 0e4ec08012..343c5e2074 100644 --- a/native/cocos/editor-support/dragonbones-creator-support/CCArmatureDisplay.h +++ b/native/cocos/editor-support/dragonbones-creator-support/CCArmatureDisplay.h @@ -24,16 +24,17 @@ #ifndef DRAGONBONES_CC_ARMATURE_DISPLAY_CONTAINER_H #define DRAGONBONES_CC_ARMATURE_DISPLAY_CONTAINER_H +#include +#include +#include #include "IOTypedArray.h" #include "MiddlewareManager.h" #include "base/Map.h" -#include "base/Ref.h" +#include "base/RefCounted.h" #include "bindings/event/EventDispatcher.h" #include "dragonbones-creator-support/CCSlot.h" #include "dragonbones/DragonBonesHeaders.h" #include "middleware-adapter.h" -#include -#include DRAGONBONES_NAMESPACE_BEGIN @@ -42,7 +43,7 @@ DRAGONBONES_NAMESPACE_BEGIN * It will not save vertices and indices.Only CCSlot will save these info. * And CCArmatureDisplay will traverse all tree node and calculate render data. */ -class CCArmatureDisplay : public cc::Ref, public virtual IArmatureProxy { +class CCArmatureDisplay : public cc::RefCounted, public virtual IArmatureProxy { DRAGONBONES_DISALLOW_COPY_AND_ASSIGN(CCArmatureDisplay) public: @@ -52,72 +53,72 @@ public: static CCArmatureDisplay *create(); private: - void traverseArmature(Armature *armature, float parentOpacity = 1.0f); + void traverseArmature(Armature *armature, float parentOpacity = 1.0F); protected: - bool _debugDraw = false; - Armature *_armature = nullptr; + bool _debugDraw = false; + Armature *_armature = nullptr; public: CCArmatureDisplay(); - virtual ~CCArmatureDisplay(); + ~CCArmatureDisplay() override; /** * @inheritDoc */ - virtual void dbInit(Armature *armature) override; + void dbInit(Armature *armature) override; /** * @inheritDoc */ - virtual void dbClear() override; + void dbClear() override; /** * @inheritDoc */ - virtual void dbUpdate() override; + void dbUpdate() override; /** * @inheritDoc */ - virtual void dbRender() override; + void dbRender() override; /** * @inheritDoc */ - virtual void dispose(bool disposeProxy = true) override; + void dispose(bool disposeProxy) override; /** * @inheritDoc */ - virtual bool hasDBEventListener(const std::string &type) const override; + bool hasDBEventListener(const std::string &type) const override; /** * @inheritDoc */ - virtual void dispatchDBEvent(const std::string &type, EventObject *value) override; + void dispatchDBEvent(const std::string &type, EventObject *value) override; /** * @inheritDoc */ - virtual void addDBEventListener(const std::string &type, const std::function &listener) override; + void addDBEventListener(const std::string &type, const std::function &listener) override; /** * @inheritDoc */ - virtual void removeDBEventListener(const std::string &type, const std::function &listener) override; + void removeDBEventListener(const std::string &type, const std::function &listener) override; /** * @inheritDoc */ - virtual uint32_t getRenderOrder() const override; + uint32_t getRenderOrder() const override; - typedef std::function dbEventCallback; + using dbEventCallback = std::function; void setDBEventCallback(dbEventCallback callback) { - _dbEventCallback = callback; + _dbEventCallback = std::move(callback); } /** * @inheritDoc */ - inline virtual Armature *getArmature() const override { + inline Armature *getArmature() const override { return _armature; } /** * @inheritDoc */ - inline virtual Animation *getAnimation() const override { + inline Animation *getAnimation() const override { return _armature->getAnimation(); } @@ -161,7 +162,7 @@ public: * @param[in] pos Component position * @return Global position */ - cc::Vec2 convertToRootSpace(float x, float y) const; + const cc::Vec2 &convertToRootSpace(float x, float y) const; /** * @return root display,if this diplay is root,then return itself. @@ -170,26 +171,31 @@ public: private: std::map _listenerIDMap; - int _preBlendMode = -1; - int _preTextureIndex = -1; - int _curTextureIndex = -1; - int _curBlendSrc = -1; - int _curBlendDst = -1; + int _preBlendMode = -1; + int _preTextureIndex = -1; + int _curTextureIndex = -1; + int _curBlendSrc = -1; + int _curBlendDst = -1; int _preISegWritePos = -1; - int _curISegLen = 0; + int _curISegLen = 0; int _debugSlotsLen = 0; - int _materialLen = 0; + int _materialLen = 0; - bool _batch = true; - bool _useAttach = false; + bool _batch = true; + bool _useAttach = false; bool _premultipliedAlpha = false; - cc::middleware::Color4F _nodeColor = cc::middleware::Color4F::WHITE; - dbEventCallback _dbEventCallback = nullptr; + + // NOTE: We bind Vec2 to make JS deserialization works, we need to return const reference in convertToRootSpace method, + // because returning Vec2 JSB object on stack to JS will let JS get mess data. + mutable cc::Vec2 _tmpVec2; + // + cc::middleware::Color4F _nodeColor = cc::middleware::Color4F::WHITE; + dbEventCallback _dbEventCallback = nullptr; cc::middleware::IOTypedArray *_sharedBufferOffset = nullptr; - cc::middleware::IOTypedArray *_debugBuffer = nullptr; + cc::middleware::IOTypedArray *_debugBuffer = nullptr; // Js fill this buffer to send parameter to cpp, avoid to call jsb function. cc::middleware::IOTypedArray *_paramsBuffer = nullptr; }; diff --git a/native/cocos/editor-support/dragonbones-creator-support/CCFactory.cpp b/native/cocos/editor-support/dragonbones-creator-support/CCFactory.cpp index d59501d58a..8a21ee769c 100644 --- a/native/cocos/editor-support/dragonbones-creator-support/CCFactory.cpp +++ b/native/cocos/editor-support/dragonbones-creator-support/CCFactory.cpp @@ -32,13 +32,13 @@ using namespace cc; DRAGONBONES_NAMESPACE_BEGIN DragonBones *CCFactory::_dragonBonesInstance = nullptr; -CCFactory *CCFactory::_factory = nullptr; +CCFactory * CCFactory::_factory = nullptr; TextureAtlasData *CCFactory::_buildTextureAtlasData(TextureAtlasData *textureAtlasData, void *textureAtlas) const { if (textureAtlasData != nullptr) { const auto pos = _prevPath.find_last_of("/"); if (pos != std::string::npos) { - const auto basePath = _prevPath.substr(0, pos + 1); + const auto basePath = _prevPath.substr(0, pos + 1); textureAtlasData->imagePath = basePath + textureAtlasData->imagePath; } @@ -53,11 +53,11 @@ TextureAtlasData *CCFactory::_buildTextureAtlasData(TextureAtlasData *textureAtl } Armature *CCFactory::_buildArmature(const BuildArmaturePackage &dataPackage) const { - const auto armature = BaseObject::borrowObject(); + const auto armature = BaseObject::borrowObject(); const auto armatureDisplay = CCArmatureDisplay::create(); // will release when armature destructor - armatureDisplay->retain(); + armatureDisplay->addRef(); armature->init( dataPackage.armature, @@ -146,7 +146,7 @@ void CCFactory::removeDragonBonesDataByUUID(const std::string &uuid, bool dispos } TextureAtlasData *CCFactory::loadTextureAtlasData(const std::string &filePath, const std::string &name, float scale) { - _prevPath = cc::FileUtils::getInstance()->fullPathForFilename(filePath); + _prevPath = cc::FileUtils::getInstance()->fullPathForFilename(filePath); const auto data = cc::FileUtils::getInstance()->getStringFromFile(_prevPath); if (data.empty()) { return nullptr; diff --git a/native/cocos/editor-support/dragonbones-creator-support/CCFactory.h b/native/cocos/editor-support/dragonbones-creator-support/CCFactory.h index 5fcf64caeb..c9f7a644a0 100644 --- a/native/cocos/editor-support/dragonbones-creator-support/CCFactory.h +++ b/native/cocos/editor-support/dragonbones-creator-support/CCFactory.h @@ -47,7 +47,7 @@ class CCFactory : public BaseFactory, public cc::middleware::IMiddleware { private: static DragonBones *_dragonBonesInstance; - static CCFactory *_factory; + static CCFactory * _factory; public: static bool isInit() { @@ -94,7 +94,7 @@ public: CCFactory() : _prevPath() { if (_dragonBonesInstance == nullptr) { const auto eventManager = CCArmatureDisplay::create(); - eventManager->retain(); + eventManager->addRef(); _dragonBonesInstance = new DragonBones(eventManager); @@ -130,8 +130,8 @@ public: protected: virtual TextureAtlasData *_buildTextureAtlasData(TextureAtlasData *textureAtlasData, void *textureAtlas) const override; - virtual Armature *_buildArmature(const BuildArmaturePackage &dataPackage) const override; - virtual Slot *_buildSlot(const BuildArmaturePackage &dataPackage, const SlotData *slotData, Armature *armature) const override; + virtual Armature * _buildArmature(const BuildArmaturePackage &dataPackage) const override; + virtual Slot * _buildSlot(const BuildArmaturePackage &dataPackage, const SlotData *slotData, Armature *armature) const override; public: virtual DragonBonesData *loadDragonBonesData(const std::string &filePath, const std::string &name = "", float scale = 1.0f); @@ -245,7 +245,7 @@ public: void removeDragonBonesDataByUUID(const std::string &uuid, bool disposeData = true); CCTextureAtlasData *getTextureAtlasDataByIndex(const std::string &name, int textureIndex) const; - DragonBonesData *parseDragonBonesDataByPath(const std::string &filePath, const std::string &name = "", float scale = 1.0f); + DragonBonesData * parseDragonBonesDataByPath(const std::string &filePath, const std::string &name = "", float scale = 1.0f); }; DRAGONBONES_NAMESPACE_END diff --git a/native/cocos/editor-support/dragonbones-creator-support/CCTextureAtlasData.cpp b/native/cocos/editor-support/dragonbones-creator-support/CCTextureAtlasData.cpp index 0f715db03d..56cb279d72 100644 --- a/native/cocos/editor-support/dragonbones-creator-support/CCTextureAtlasData.cpp +++ b/native/cocos/editor-support/dragonbones-creator-support/CCTextureAtlasData.cpp @@ -48,7 +48,7 @@ void CCTextureAtlasData::setRenderTexture(middleware::Texture2D *value) { _renderTexture = value; if (_renderTexture != nullptr) { - _renderTexture->retain(); + _renderTexture->addRef(); for (const auto &pair : textures) { const auto textureData = static_cast(pair.second); @@ -61,7 +61,7 @@ void CCTextureAtlasData::setRenderTexture(middleware::Texture2D *value) { cc::Vec2 offset(0.0f, 0.0f); cc::Size originSize(rect.size.width, rect.size.height); textureData->spriteFrame = middleware::SpriteFrame::createWithTexture(_renderTexture, rect, textureData->rotated, offset, originSize); // TODO multiply textureAtlas - textureData->spriteFrame->retain(); + textureData->spriteFrame->addRef(); } } } else { diff --git a/native/cocos/editor-support/middleware-adapter.cpp b/native/cocos/editor-support/middleware-adapter.cpp index 2cc426f9ed..d8b74329b6 100644 --- a/native/cocos/editor-support/middleware-adapter.cpp +++ b/native/cocos/editor-support/middleware-adapter.cpp @@ -24,36 +24,31 @@ ****************************************************************************/ #include "middleware-adapter.h" +#include "base/DeferredReleasePool.h" #include "base/Macros.h" MIDDLEWARE_BEGIN -const Color4F Color4F::WHITE(1.0f, 1.0f, 1.0f, 1.0f); +const Color4F Color4F::WHITE(1.0F, 1.0F, 1.0F, 1.0F); const Color4B Color4B::WHITE(255, 255, 255, 255); -Color4F::Color4F(float _r, float _g, float _b, float _a) -: r(_r), g(_g), b(_b), a(_a) {} -Color4F::Color4F() {} +Color4F::Color4F(float r, float g, float b, float a) +: r(r), g(g), b(b), a(a) {} +Color4F::Color4F() = default; -Color4F& Color4F::operator=(const Color4B &right) { - r = right.r / 255.0f; - g = right.g / 255.0f; - b = right.b / 255.0f; - a = right.a / 255.0f; +Color4F &Color4F::operator=(const Color4B &right) { + r = static_cast(right.r) / 255.0F; + g = static_cast(right.g) / 255.0F; + b = static_cast(right.b) / 255.0F; + a = static_cast(right.a) / 255.0F; return *this; } -Color4B::Color4B() {} -Color4B::Color4B(uint32_t _r, uint32_t _g, uint32_t _b, uint32_t _a) -: r(_r), g(_g), b(_b), a(_a) {} +Color4B::Color4B() = default; +Color4B::Color4B(uint32_t r, uint32_t g, uint32_t b, uint32_t a) +: r(r), g(g), b(b), a(a) {} -Color4B& Color4B::operator=(const Color4B &right) { - r = right.r; - g = right.g; - b = right.b; - a = right.a; - return *this; -} +Color4B &Color4B::operator=(const Color4B &right) = default; bool Color4B::operator==(const Color4B &right) const { return (r == right.r && g == right.g && b == right.b && a == right.a); @@ -71,8 +66,7 @@ bool Color4F::operator!=(const Color4F &right) const { return (r != right.r || g != right.g || b != right.b || a != right.a); } -Texture2D::Texture2D() { -} +Texture2D::Texture2D() = default; Texture2D::~Texture2D() { _texParamCallback = nullptr; @@ -113,17 +107,15 @@ void Texture2D::setTexParameters(const TexParams &texParams) { } SpriteFrame *SpriteFrame::createWithTexture(Texture2D *texture, const cc::Rect &rect) { - SpriteFrame *spriteFrame = new (std::nothrow) SpriteFrame(); + auto *spriteFrame = new (std::nothrow) SpriteFrame(); spriteFrame->initWithTexture(texture, rect); - spriteFrame->autorelease(); return spriteFrame; } SpriteFrame *SpriteFrame::createWithTexture(Texture2D *texture, const cc::Rect &rect, bool rotated, const cc::Vec2 &offset, const cc::Size &originalSize) { - SpriteFrame *spriteFrame = new (std::nothrow) SpriteFrame(); + auto *spriteFrame = new (std::nothrow) SpriteFrame(); spriteFrame->initWithTexture(texture, rect, rotated, offset, originalSize); - spriteFrame->autorelease(); return spriteFrame; } @@ -136,20 +128,19 @@ bool SpriteFrame::initWithTexture(Texture2D *texture, const cc::Rect &rect, bool _texture = texture; if (texture) { - texture->retain(); + texture->addRef(); } - _rectInPixels = rect; - _offsetInPixels = offset; + _rectInPixels = rect; + _offsetInPixels = offset; _originalSizeInPixels = originalSize; - _rotated = rotated; - _anchorPoint = cc::Vec2(NAN, NAN); + _rotated = rotated; + _anchorPoint = cc::Vec2(NAN, NAN); return true; } -SpriteFrame::SpriteFrame() { -} +SpriteFrame::SpriteFrame() = default; SpriteFrame::~SpriteFrame() { CC_SAFE_RELEASE(_texture); @@ -158,7 +149,7 @@ SpriteFrame::~SpriteFrame() { void SpriteFrame::setTexture(Texture2D *texture) { if (_texture != texture) { CC_SAFE_RELEASE(_texture); - CC_SAFE_RETAIN(texture); + CC_SAFE_ADD_REF(texture); _texture = texture; } } diff --git a/native/cocos/editor-support/middleware-adapter.h b/native/cocos/editor-support/middleware-adapter.h index 5dff899a4e..03cbdd1777 100644 --- a/native/cocos/editor-support/middleware-adapter.h +++ b/native/cocos/editor-support/middleware-adapter.h @@ -25,20 +25,20 @@ #pragma once +#include #include "MiddlewareMacro.h" -#include "base/Ref.h" +#include "base/RefCounted.h" #include "math/Geometry.h" #include "math/Vec3.h" -#include MIDDLEWARE_BEGIN struct Color4B { - Color4B(uint32_t _r, uint32_t _g, uint32_t _b, uint32_t _a); + Color4B(uint32_t r, uint32_t g, uint32_t b, uint32_t a); Color4B(); - bool operator==(const Color4B &right) const; - bool operator!=(const Color4B &right) const; - Color4B& operator=(const Color4B &right); + bool operator==(const Color4B &right) const; + bool operator!=(const Color4B &right) const; + Color4B &operator=(const Color4B &right); uint32_t r = 0; uint32_t g = 0; @@ -49,16 +49,16 @@ struct Color4B { }; struct Color4F { - Color4F(float _r, float _g, float _b, float _a); + Color4F(float r, float g, float b, float a); Color4F(); bool operator==(const Color4F &right) const; bool operator!=(const Color4F &right) const; Color4F& operator=(const Color4B &right); - float r = 0.0f; - float g = 0.0f; - float b = 0.0f; - float a = 0.0f; + float r = 0.0F; + float g = 0.0F; + float b = 0.0F; + float a = 0.0F; static const Color4F WHITE; }; @@ -74,7 +74,7 @@ struct Tex2F { /** * Vertex Format with x y z u v color. */ -struct V2F_T2F_C4F { +struct V2F_T2F_C4F { //NOLINT // vertices (3F) cc::Vec3 vertex; @@ -88,7 +88,7 @@ struct V2F_T2F_C4F { /** * Vertex Format with x y u v color1 color2. */ -struct V2F_T2F_C4F_C4F { +struct V2F_T2F_C4F_C4F { // NOLINT // vertices (3F) cc::Vec3 vertex; @@ -106,7 +106,7 @@ struct Triangles { /**Vertex data pointer.*/ V2F_T2F_C4F *verts = nullptr; /**Index data pointer.*/ - unsigned short *indices = nullptr; + unsigned short *indices = nullptr; // NOLINT /**The number of vertices.*/ int vertCount = 0; /**The number of indices.*/ @@ -117,7 +117,7 @@ struct TwoColorTriangles { /**Vertex data pointer.*/ V2F_T2F_C4F_C4F *verts = nullptr; /**Index data pointer.*/ - unsigned short *indices = nullptr; + unsigned short *indices = nullptr; //NOLINT /**The number of vertices.*/ int vertCount = 0; /**The number of indices.*/ @@ -127,24 +127,24 @@ struct TwoColorTriangles { /////////////////////////////////////////////////////////////////////// // adapt to editor texture,this is a texture delegate,not real texture /////////////////////////////////////////////////////////////////////// -class Texture2D : public cc::Ref { +class Texture2D : public cc::RefCounted { public: Texture2D(); - virtual ~Texture2D(); + ~Texture2D() override; /** Extension to set the Min / Mag filter */ - typedef struct _TexParams { + using TexParams = struct _TexParams { // NOLINT uint32_t minFilter; uint32_t magFilter; uint32_t wrapS; uint32_t wrapT; - } TexParams; + }; /** * set texture param callback */ - typedef std::function texParamCallback; + using texParamCallback = std::function; /** Sets the min filter, mag filter, wrap s and wrap t texture parameters. If the texture size is NPOT (non power of 2), then in can only use GL_CLAMP_TO_EDGE in GL_TEXTURE_WRAP_{S,T}. @@ -197,13 +197,13 @@ private: /////////////////////////////////////////////////////////////////////// // adapt to editor sprite frame /////////////////////////////////////////////////////////////////////// -class SpriteFrame : public cc::Ref { +class SpriteFrame : public cc::RefCounted { public: static SpriteFrame *createWithTexture(Texture2D *pobTexture, const cc::Rect &rect); static SpriteFrame *createWithTexture(Texture2D *pobTexture, const cc::Rect &rect, bool rotated, const cc::Vec2 &offset, const cc::Size &originalSize); SpriteFrame(); - virtual ~SpriteFrame(); + ~SpriteFrame() override; /** Initializes a SpriteFrame with a texture, rect in points. It is assumed that the frame was not trimmed. @@ -227,11 +227,11 @@ public: void setTexture(Texture2D *pobTexture); protected: - cc::Vec2 _anchorPoint; - cc::Rect _rectInPixels; - bool _rotated = false; - cc::Vec2 _offsetInPixels; - cc::Size _originalSizeInPixels; + cc::Vec2 _anchorPoint; + cc::Rect _rectInPixels; + bool _rotated = false; + cc::Vec2 _offsetInPixels; + cc::Size _originalSizeInPixels; Texture2D *_texture = nullptr; }; MIDDLEWARE_END diff --git a/native/cocos/editor-support/spine-creator-support/AttachmentVertices.cpp b/native/cocos/editor-support/spine-creator-support/AttachmentVertices.cpp index 2f1d664ba8..1f8b42232b 100644 --- a/native/cocos/editor-support/spine-creator-support/AttachmentVertices.cpp +++ b/native/cocos/editor-support/spine-creator-support/AttachmentVertices.cpp @@ -29,18 +29,18 @@ #include "spine-creator-support/AttachmentVertices.h" -using namespace cc; +using namespace cc; // NOLINT(google-build-using-namespace) namespace spine { -AttachmentVertices::AttachmentVertices(middleware::Texture2D *texture, int verticesCount, unsigned short *triangles, int trianglesCount) { +AttachmentVertices::AttachmentVertices(middleware::Texture2D *texture, int verticesCount, uint16_t *triangles, int trianglesCount) { _texture = texture; - if (_texture) _texture->retain(); + if (_texture) _texture->addRef(); - _triangles = new middleware::Triangles(); - _triangles->verts = new middleware::V2F_T2F_C4F[verticesCount]; - _triangles->vertCount = verticesCount; - _triangles->indices = triangles; + _triangles = new middleware::Triangles(); + _triangles->verts = new middleware::V2F_T2F_C4F[verticesCount]; + _triangles->vertCount = verticesCount; + _triangles->indices = triangles; _triangles->indexCount = trianglesCount; } diff --git a/native/cocos/editor-support/spine-creator-support/AttachmentVertices.h b/native/cocos/editor-support/spine-creator-support/AttachmentVertices.h index 6dc6579e9d..7839607e11 100644 --- a/native/cocos/editor-support/spine-creator-support/AttachmentVertices.h +++ b/native/cocos/editor-support/spine-creator-support/AttachmentVertices.h @@ -38,7 +38,7 @@ namespace spine { */ class AttachmentVertices { public: - AttachmentVertices(cc::middleware::Texture2D *texture, int verticesCount, unsigned short *triangles, int trianglesCount); + AttachmentVertices(cc::middleware::Texture2D *texture, int verticesCount, uint16_t *triangles, int trianglesCount); virtual ~AttachmentVertices(); cc::middleware::Texture2D *_texture = nullptr; diff --git a/native/cocos/editor-support/spine-creator-support/SkeletonAnimation.cpp b/native/cocos/editor-support/spine-creator-support/SkeletonAnimation.cpp index d2f7eb30b0..46b983578b 100644 --- a/native/cocos/editor-support/spine-creator-support/SkeletonAnimation.cpp +++ b/native/cocos/editor-support/spine-creator-support/SkeletonAnimation.cpp @@ -29,6 +29,7 @@ #include "spine-creator-support/SkeletonAnimation.h" #include +#include "base/DeferredReleasePool.h" #include "base/Log.h" #include "spine-creator-support/spine-cocos2dx.h" #include "spine/Extension.h" @@ -73,28 +74,24 @@ void SkeletonAnimation::setGlobalTimeScale(float timeScale) { SkeletonAnimation *SkeletonAnimation::create() { auto *skeleton = new SkeletonAnimation(); - skeleton->autorelease(); return skeleton; } SkeletonAnimation *SkeletonAnimation::createWithData(SkeletonData *skeletonData, bool ownsSkeletonData) { auto *node = new SkeletonAnimation(); node->initWithData(skeletonData, ownsSkeletonData); - node->autorelease(); return node; } SkeletonAnimation *SkeletonAnimation::createWithJsonFile(const std::string &skeletonJsonFile, const std::string &atlasFile, float scale) { auto *node = new SkeletonAnimation(); node->initWithJsonFile(skeletonJsonFile, atlasFile, scale); - node->autorelease(); return node; } SkeletonAnimation *SkeletonAnimation::createWithBinaryFile(const std::string &skeletonBinaryFile, const std::string &atlasFile, float scale) { auto *node = new SkeletonAnimation(); node->initWithBinaryFile(skeletonBinaryFile, atlasFile, scale); - node->autorelease(); return node; } diff --git a/native/cocos/editor-support/spine-creator-support/SkeletonCache.cpp b/native/cocos/editor-support/spine-creator-support/SkeletonCache.cpp index fe1cd1ccac..502d5d813b 100644 --- a/native/cocos/editor-support/spine-creator-support/SkeletonCache.cpp +++ b/native/cocos/editor-support/spine-creator-support/SkeletonCache.cpp @@ -30,23 +30,22 @@ #include "SkeletonCache.h" #include "spine-creator-support/AttachmentVertices.h" -USING_NS_MW; -using namespace cc; +USING_NS_MW; // NOLINT(google-build-using-namespace) +using namespace cc; // NOLINT(google-build-using-namespace) namespace spine { -float SkeletonCache::FrameTime = 1.0f / 60.0f; -float SkeletonCache::MaxCacheTime = 120.0f; +float SkeletonCache::FrameTime = 1.0F / 60.0F; +float SkeletonCache::MaxCacheTime = 120.0F; -SkeletonCache::SegmentData::SegmentData() { -} +SkeletonCache::SegmentData::SegmentData() = default; SkeletonCache::SegmentData::~SegmentData() { CC_SAFE_RELEASE_NULL(_texture); } void SkeletonCache::SegmentData::setTexture(cc::middleware::Texture2D *value) { - CC_SAFE_RETAIN(value); + CC_SAFE_ADD_REF(value); CC_SAFE_RELEASE(_texture); _texture = value; } @@ -55,22 +54,21 @@ cc::middleware::Texture2D *SkeletonCache::SegmentData::getTexture() const { return _texture; } -SkeletonCache::FrameData::FrameData() { -} +SkeletonCache::FrameData::FrameData() = default; SkeletonCache::FrameData::~FrameData() { - for (std::size_t i = 0, c = _bones.size(); i < c; i++) { - delete _bones[i]; + for (auto &bone : _bones) { + delete bone; } _bones.clear(); - for (std::size_t i = 0, c = _colors.size(); i < c; i++) { - delete _colors[i]; + for (auto &color : _colors) { + delete color; } _colors.clear(); - for (std::size_t i = 0, c = _segments.size(); i < c; i++) { - delete _segments[i]; + for (auto &segment : _segments) { + delete segment; } _segments.clear(); } @@ -78,7 +76,7 @@ SkeletonCache::FrameData::~FrameData() { SkeletonCache::BoneData *SkeletonCache::FrameData::buildBoneData(std::size_t index) { if (index > _bones.size()) return nullptr; if (index == _bones.size()) { - BoneData *boneData = new BoneData; + auto *boneData = new BoneData; _bones.push_back(boneData); } return _bones[index]; @@ -91,7 +89,7 @@ std::size_t SkeletonCache::FrameData::getBoneCount() const { SkeletonCache::ColorData *SkeletonCache::FrameData::buildColorData(std::size_t index) { if (index > _colors.size()) return nullptr; if (index == _colors.size()) { - ColorData *colorData = new ColorData; + auto *colorData = new ColorData; _colors.push_back(colorData); } return _colors[index]; @@ -104,7 +102,7 @@ std::size_t SkeletonCache::FrameData::getColorCount() const { SkeletonCache::SegmentData *SkeletonCache::FrameData::buildSegmentData(std::size_t index) { if (index > _segments.size()) return nullptr; if (index == _segments.size()) { - SegmentData *segmentData = new SegmentData; + auto *segmentData = new SegmentData; _segments.push_back(segmentData); } return _segments[index]; @@ -114,20 +112,19 @@ std::size_t SkeletonCache::FrameData::getSegmentCount() const { return _segments.size(); } -SkeletonCache::AnimationData::AnimationData() { -} +SkeletonCache::AnimationData::AnimationData() = default; SkeletonCache::AnimationData::~AnimationData() { reset(); } void SkeletonCache::AnimationData::reset() { - for (std::size_t i = 0, c = _frames.size(); i < c; i++) { - delete _frames[i]; + for (auto &frame : _frames) { + delete frame; } _frames.clear(); _isComplete = false; - _totalTime = 0.0f; + _totalTime = 0.0F; } bool SkeletonCache::AnimationData::needUpdate(int toFrameIdx) const { @@ -139,7 +136,7 @@ SkeletonCache::FrameData *SkeletonCache::AnimationData::buildFrameData(std::size return nullptr; } if (frameIdx == _frames.size()) { - auto frameData = new FrameData(); + auto *frameData = new FrameData(); _frames.push_back(frameData); } return _frames[frameIdx]; @@ -156,25 +153,24 @@ std::size_t SkeletonCache::AnimationData::getFrameCount() const { return _frames.size(); } -SkeletonCache::SkeletonCache() { -} +SkeletonCache::SkeletonCache() = default; SkeletonCache::~SkeletonCache() { - for (auto it = _animationCaches.begin(); it != _animationCaches.end(); it++) { - delete it->second; + for (auto &animationCache : _animationCaches) { + delete animationCache.second; } _animationCaches.clear(); } SkeletonCache::AnimationData *SkeletonCache::buildAnimationData(const std::string &animationName) { AnimationData *aniData = nullptr; - auto it = _animationCaches.find(animationName); + auto it = _animationCaches.find(animationName); if (it == _animationCaches.end()) { - auto animation = findAnimation(animationName); + auto *animation = findAnimation(animationName); if (animation == nullptr) return nullptr; - aniData = new AnimationData(); - aniData->_animationName = animationName; + aniData = new AnimationData(); + aniData->_animationName = animationName; _animationCaches[animationName] = aniData; } else { aniData = it->second; @@ -186,9 +182,8 @@ SkeletonCache::AnimationData *SkeletonCache::getAnimationData(const std::string auto it = _animationCaches.find(animationName); if (it == _animationCaches.end()) { return nullptr; - } else { - return it->second; } + return it->second; } void SkeletonCache::update(float deltaTime) { @@ -229,7 +224,7 @@ void SkeletonCache::updateToFrame(const std::string &animationName, int toFrameI void SkeletonCache::renderAnimationFrame(AnimationData *animationData) { std::size_t frameIndex = animationData->getFrameCount(); - FrameData *frameData = animationData->buildFrameData(frameIndex); + FrameData * frameData = animationData->buildFrameData(frameIndex); if (!_skeleton) return; @@ -238,42 +233,42 @@ void SkeletonCache::renderAnimationFrame(AnimationData *animationData) { return; } - Color4F preColor(-1.0f, -1.0f, -1.0f, -1.0f); - Color4F preDarkColor(-1.0f, -1.0f, -1.0f, -1.0f); + Color4F preColor(-1.0F, -1.0F, -1.0F, -1.0F); + Color4F preDarkColor(-1.0F, -1.0F, -1.0F, -1.0F); // range [0.0, 1.0] Color4F color; Color4F darkColor; - AttachmentVertices *attachmentVertices = nullptr; - middleware::IOBuffer &vb = frameData->vb; - middleware::IOBuffer &ib = frameData->ib; + AttachmentVertices * attachmentVertices = nullptr; + middleware::IOBuffer &vb = frameData->vb; + middleware::IOBuffer &ib = frameData->ib; // vertex size int bytes with two color int vbs2 = sizeof(V2F_T2F_C4F_C4F); - // verex size in floats with two color - int vs2 = vbs2 / sizeof(float); + // vertex size in floats with two color + int vs2 = static_cast(vbs2 / sizeof(float)); int vbSize = 0; int ibSize = 0; - int preBlendMode = -1; + int preBlendMode = -1; int preTextureIndex = -1; int curTextureIndex = -1; int preISegWritePos = -1; - int curISegLen = 0; - int curVSegLen = 0; + int curISegLen = 0; + int curVSegLen = 0; - int materialLen = 0; - Slot *slot = nullptr; + int materialLen = 0; + Slot *slot = nullptr; middleware::Texture2D *texture = nullptr; auto flush = [&]() { // fill pre segment count field if (preISegWritePos != -1) { - SegmentData *preSegmentData = frameData->buildSegmentData(materialLen - 1); - preSegmentData->indexCount = curISegLen; + SegmentData *preSegmentData = frameData->buildSegmentData(materialLen - 1); + preSegmentData->indexCount = curISegLen; preSegmentData->vertexFloatCount = curVSegLen; } @@ -282,9 +277,9 @@ void SkeletonCache::renderAnimationFrame(AnimationData *animationData) { segmentData->blendMode = slot->getData().getBlendMode(); // save new segment count pos field - preISegWritePos = (int)ib.getCurPos() / sizeof(unsigned short); + preISegWritePos = static_cast(ib.getCurPos() / sizeof(uint16_t)); // reset pre blend mode to current - preBlendMode = (int)slot->getData().getBlendMode(); + preBlendMode = static_cast(slot->getData().getBlendMode()); // reset pre texture index to current preTextureIndex = curTextureIndex; // reset index segmentation count @@ -297,16 +292,16 @@ void SkeletonCache::renderAnimationFrame(AnimationData *animationData) { auto &bones = _skeleton->getBones(); for (std::size_t i = 0, n = bones.size(); i < n; i++) { - auto &bone = bones[i]; - auto boneCount = frameData->getBoneCount(); - BoneData *boneData = frameData->buildBoneData(boneCount); - auto &matm = boneData->globalTransformMatrix.m; - matm[0] = bone->getA(); - matm[1] = bone->getC(); - matm[4] = bone->getB(); - matm[5] = bone->getD(); - matm[12] = bone->getWorldX(); - matm[13] = bone->getWorldY(); + auto & bone = bones[i]; + auto boneCount = frameData->getBoneCount(); + BoneData *boneData = frameData->buildBoneData(boneCount); + auto & matm = boneData->globalTransformMatrix.m; + matm[0] = bone->getA(); + matm[1] = bone->getC(); + matm[4] = bone->getB(); + matm[5] = bone->getD(); + matm[12] = bone->getWorldX(); + matm[13] = bone->getWorldY(); } auto &drawOrder = _skeleton->getDrawOrder(); @@ -327,8 +322,8 @@ void SkeletonCache::renderAnimationFrame(AnimationData *animationData) { TwoColorTriangles trianglesTwoColor; if (slot->getAttachment()->getRTTI().isExactly(RegionAttachment::rtti)) { - RegionAttachment *attachment = (RegionAttachment *)slot->getAttachment(); - attachmentVertices = (AttachmentVertices *)attachment->getRendererObject(); + auto *attachment = dynamic_cast(slot->getAttachment()); + attachmentVertices = static_cast(attachment->getRendererObject()); // Early exit if attachment is invisible if (attachment->getColor().a == 0) { @@ -337,18 +332,18 @@ void SkeletonCache::renderAnimationFrame(AnimationData *animationData) { } trianglesTwoColor.vertCount = attachmentVertices->_triangles->vertCount; - vbSize = trianglesTwoColor.vertCount * sizeof(V2F_T2F_C4F_C4F); + vbSize = static_cast(trianglesTwoColor.vertCount * sizeof(V2F_T2F_C4F_C4F)); vb.checkSpace(vbSize, true); - trianglesTwoColor.verts = (V2F_T2F_C4F_C4F *)vb.getCurBuffer(); + trianglesTwoColor.verts = reinterpret_cast(vb.getCurBuffer()); for (int ii = 0; ii < trianglesTwoColor.vertCount; ii++) { trianglesTwoColor.verts[ii].texCoord = attachmentVertices->_triangles->verts[ii].texCoord; } - attachment->computeWorldVertices(slot->getBone(), (float *)trianglesTwoColor.verts, 0, vs2); + attachment->computeWorldVertices(slot->getBone(), reinterpret_cast(trianglesTwoColor.verts), 0, vs2); trianglesTwoColor.indexCount = attachmentVertices->_triangles->indexCount; - ibSize = trianglesTwoColor.indexCount * sizeof(unsigned short); + ibSize = static_cast(trianglesTwoColor.indexCount * sizeof(uint16_t)); ib.checkSpace(ibSize, true); - trianglesTwoColor.indices = (unsigned short *)ib.getCurBuffer(); + trianglesTwoColor.indices = reinterpret_cast(ib.getCurBuffer()); memcpy(trianglesTwoColor.indices, attachmentVertices->_triangles->indices, ibSize); color.r = attachment->getColor().r; @@ -357,8 +352,8 @@ void SkeletonCache::renderAnimationFrame(AnimationData *animationData) { color.a = attachment->getColor().a; } else if (slot->getAttachment()->getRTTI().isExactly(MeshAttachment::rtti)) { - MeshAttachment *attachment = (MeshAttachment *)slot->getAttachment(); - attachmentVertices = (AttachmentVertices *)attachment->getRendererObject(); + auto *attachment = dynamic_cast(slot->getAttachment()); + attachmentVertices = static_cast(attachment->getRendererObject()); // Early exit if attachment is invisible if (attachment->getColor().a == 0) { @@ -367,18 +362,18 @@ void SkeletonCache::renderAnimationFrame(AnimationData *animationData) { } trianglesTwoColor.vertCount = attachmentVertices->_triangles->vertCount; - vbSize = trianglesTwoColor.vertCount * sizeof(V2F_T2F_C4F_C4F); + vbSize = static_cast(trianglesTwoColor.vertCount * sizeof(V2F_T2F_C4F_C4F)); vb.checkSpace(vbSize, true); - trianglesTwoColor.verts = (V2F_T2F_C4F_C4F *)vb.getCurBuffer(); + trianglesTwoColor.verts = reinterpret_cast(vb.getCurBuffer()); for (int ii = 0; ii < trianglesTwoColor.vertCount; ii++) { trianglesTwoColor.verts[ii].texCoord = attachmentVertices->_triangles->verts[ii].texCoord; } - attachment->computeWorldVertices(*slot, 0, attachment->getWorldVerticesLength(), (float *)trianglesTwoColor.verts, 0, vs2); + attachment->computeWorldVertices(*slot, 0, attachment->getWorldVerticesLength(), reinterpret_cast(trianglesTwoColor.verts), 0, vs2); trianglesTwoColor.indexCount = attachmentVertices->_triangles->indexCount; - ibSize = trianglesTwoColor.indexCount * sizeof(unsigned short); + ibSize = static_cast(trianglesTwoColor.indexCount * sizeof(uint16_t)); ib.checkSpace(ibSize, true); - trianglesTwoColor.indices = (unsigned short *)ib.getCurBuffer(); + trianglesTwoColor.indices = reinterpret_cast(ib.getCurBuffer()); memcpy(trianglesTwoColor.indices, attachmentVertices->_triangles->indices, ibSize); color.r = attachment->getColor().r; @@ -387,7 +382,7 @@ void SkeletonCache::renderAnimationFrame(AnimationData *animationData) { color.a = attachment->getColor().a; } else if (slot->getAttachment()->getRTTI().isExactly(ClippingAttachment::rtti)) { - ClippingAttachment *clip = (ClippingAttachment *)slot->getAttachment(); + auto *clip = dynamic_cast(slot->getAttachment()); _clipper->clipStart(*slot, clip); continue; } else { @@ -402,9 +397,9 @@ void SkeletonCache::renderAnimationFrame(AnimationData *animationData) { continue; } - float red = _skeleton->getColor().r * color.r * 255; + float red = _skeleton->getColor().r * color.r * 255; float green = _skeleton->getColor().g * color.g * 255; - float blue = _skeleton->getColor().b * color.b * 255; + float blue = _skeleton->getColor().b * color.b * 255; color.r = red * slot->getColor().r; color.g = green * slot->getColor().g; @@ -422,71 +417,71 @@ void SkeletonCache::renderAnimationFrame(AnimationData *animationData) { darkColor.a = 0; if (preColor != color || preDarkColor != darkColor) { - preColor = color; - preDarkColor = darkColor; + preColor = color; + preDarkColor = darkColor; auto colorCount = frameData->getColorCount(); if (colorCount > 0) { - ColorData *preColorData = frameData->buildColorData(colorCount - 1); - preColorData->vertexFloatOffset = (int)vb.getCurPos() / sizeof(float); + ColorData *preColorData = frameData->buildColorData(colorCount - 1); + preColorData->vertexFloatOffset = static_cast(vb.getCurPos() / sizeof(float)); } - ColorData *colorData = frameData->buildColorData(colorCount); + ColorData *colorData = frameData->buildColorData(colorCount); colorData->finalColor = color; - colorData->darkColor = darkColor; + colorData->darkColor = darkColor; } // Two color tint logic if (_clipper->isClipping()) { - _clipper->clipTriangles((float *)&trianglesTwoColor.verts[0].vertex, trianglesTwoColor.indices, trianglesTwoColor.indexCount, (float *)&trianglesTwoColor.verts[0].texCoord, vs2); + _clipper->clipTriangles(reinterpret_cast(&trianglesTwoColor.verts[0].vertex), trianglesTwoColor.indices, trianglesTwoColor.indexCount, reinterpret_cast(&trianglesTwoColor.verts[0].texCoord), vs2); if (_clipper->getClippedTriangles().size() == 0) { _clipper->clipEnd(*slot); continue; } - trianglesTwoColor.vertCount = (int)_clipper->getClippedVertices().size() >> 1; - vbSize = trianglesTwoColor.vertCount * sizeof(V2F_T2F_C4F_C4F); + trianglesTwoColor.vertCount = static_cast(_clipper->getClippedVertices().size()) >> 1; + vbSize = static_cast(trianglesTwoColor.vertCount * sizeof(V2F_T2F_C4F_C4F)); vb.checkSpace(vbSize, true); - trianglesTwoColor.verts = (V2F_T2F_C4F_C4F *)vb.getCurBuffer(); + trianglesTwoColor.verts = reinterpret_cast(vb.getCurBuffer()); - trianglesTwoColor.indexCount = (int)_clipper->getClippedTriangles().size(); - ibSize = trianglesTwoColor.indexCount * sizeof(unsigned short); + trianglesTwoColor.indexCount = static_cast(_clipper->getClippedTriangles().size()); + ibSize = static_cast(trianglesTwoColor.indexCount * sizeof(uint16_t)); ib.checkSpace(ibSize, true); - trianglesTwoColor.indices = (unsigned short *)ib.getCurBuffer(); - memcpy(trianglesTwoColor.indices, _clipper->getClippedTriangles().buffer(), sizeof(unsigned short) * _clipper->getClippedTriangles().size()); + trianglesTwoColor.indices = reinterpret_cast(ib.getCurBuffer()); + memcpy(trianglesTwoColor.indices, _clipper->getClippedTriangles().buffer(), sizeof(uint16_t) * _clipper->getClippedTriangles().size()); float *verts = _clipper->getClippedVertices().buffer(); - float *uvs = _clipper->getClippedUVs().buffer(); + float *uvs = _clipper->getClippedUVs().buffer(); for (int v = 0, vn = trianglesTwoColor.vertCount, vv = 0; v < vn; ++v, vv += 2) { V2F_T2F_C4F_C4F *vertex = trianglesTwoColor.verts + v; - vertex->vertex.x = verts[vv]; - vertex->vertex.y = verts[vv + 1]; - vertex->texCoord.u = uvs[vv]; - vertex->texCoord.v = uvs[vv + 1]; - vertex->color.r = color.r / 255.0f; - vertex->color.g = color.g / 255.0f; - vertex->color.b = color.b / 255.0f; - vertex->color.a = color.a / 255.0f; - vertex->color2.r = darkColor.r / 255.0f; - vertex->color2.g = darkColor.g / 255.0f; - vertex->color2.b = darkColor.b / 255.0f; - vertex->color2.a = darkColor.a / 255.0f; + vertex->vertex.x = verts[vv]; + vertex->vertex.y = verts[vv + 1]; + vertex->texCoord.u = uvs[vv]; + vertex->texCoord.v = uvs[vv + 1]; + vertex->color.r = color.r / 255.0F; + vertex->color.g = color.g / 255.0F; + vertex->color.b = color.b / 255.0F; + vertex->color.a = color.a / 255.0F; + vertex->color2.r = darkColor.r / 255.0F; + vertex->color2.g = darkColor.g / 255.0F; + vertex->color2.b = darkColor.b / 255.0F; + vertex->color2.a = darkColor.a / 255.0F; } } else { for (int v = 0, vn = trianglesTwoColor.vertCount; v < vn; ++v) { V2F_T2F_C4F_C4F *vertex = trianglesTwoColor.verts + v; - vertex->color.r = color.r / 255.0f; - vertex->color.g = color.g / 255.0f; - vertex->color.b = color.b / 255.0f; - vertex->color.a = color.a / 255.0f; - vertex->color2.r = darkColor.r / 255.0f; - vertex->color2.g = darkColor.g / 255.0f; - vertex->color2.b = darkColor.b / 255.0f; - vertex->color2.a = darkColor.a / 255.0f; + vertex->color.r = color.r / 255.0F; + vertex->color.g = color.g / 255.0F; + vertex->color.b = color.b / 255.0F; + vertex->color.a = color.a / 255.0F; + vertex->color2.r = darkColor.r / 255.0F; + vertex->color2.g = darkColor.g / 255.0F; + vertex->color2.b = darkColor.b / 255.0F; + vertex->color2.a = darkColor.a / 255.0F; } } - texture = attachmentVertices->_texture; + texture = attachmentVertices->_texture; curTextureIndex = attachmentVertices->_texture->getRealTextureIndex(); // If texture or blendMode change,will change material. if (preTextureIndex != curTextureIndex || preBlendMode != slot->getData().getBlendMode()) { @@ -497,8 +492,8 @@ void SkeletonCache::renderAnimationFrame(AnimationData *animationData) { auto vertexOffset = curVSegLen / vs2; if (vertexOffset > 0) { - unsigned short *ibBuffer = (unsigned short *)ib.getCurBuffer(); - for (int ii = 0, nn = ibSize / sizeof(unsigned short); ii < nn; ii++) { + auto *ibBuffer = reinterpret_cast(ib.getCurBuffer()); + for (uint32_t ii = 0, nn = ibSize / sizeof(uint16_t); ii < nn; ii++) { ibBuffer[ii] += vertexOffset; } } @@ -506,8 +501,8 @@ void SkeletonCache::renderAnimationFrame(AnimationData *animationData) { ib.move(ibSize); // Record this turn index segmentation count,it will store in material buffer in the end. - curISegLen += ibSize / sizeof(unsigned short); - curVSegLen += vbSize / sizeof(float); + curISegLen += static_cast(ibSize / sizeof(uint16_t)); + curVSegLen += static_cast(vbSize / sizeof(float)); } _clipper->clipEnd(*slot); @@ -516,15 +511,15 @@ void SkeletonCache::renderAnimationFrame(AnimationData *animationData) { _clipper->clipEnd(); if (preISegWritePos != -1) { - SegmentData *preSegmentData = frameData->buildSegmentData(materialLen - 1); - preSegmentData->indexCount = curISegLen; + SegmentData *preSegmentData = frameData->buildSegmentData(materialLen - 1); + preSegmentData->indexCount = curISegLen; preSegmentData->vertexFloatCount = curVSegLen; } auto colorCount = frameData->getColorCount(); if (colorCount > 0) { - ColorData *preColorData = frameData->buildColorData(colorCount - 1); - preColorData->vertexFloatOffset = (int)vb.getCurPos() / sizeof(float); + ColorData *preColorData = frameData->buildColorData(colorCount - 1); + preColorData->vertexFloatOffset = static_cast(vb.getCurPos() / sizeof(float)); } } @@ -543,15 +538,15 @@ void SkeletonCache::onAnimationStateEvent(TrackEntry *entry, EventType type, Eve } void SkeletonCache::resetAllAnimationData() { - for (auto it = _animationCaches.begin(); it != _animationCaches.end(); it++) { - it->second->reset(); + for (auto &animationCache : _animationCaches) { + animationCache.second->reset(); } } void SkeletonCache::resetAnimationData(const std::string &animationName) { - for (auto it = _animationCaches.begin(); it != _animationCaches.end(); it++) { - if (it->second->_animationName == animationName) { - it->second->reset(); + for (auto &animationCache : _animationCaches) { + if (animationCache.second->_animationName == animationName) { + animationCache.second->reset(); break; } } diff --git a/native/cocos/editor-support/spine-creator-support/SkeletonCacheAnimation.cpp b/native/cocos/editor-support/spine-creator-support/SkeletonCacheAnimation.cpp index 109c9bb42c..78660be0ef 100644 --- a/native/cocos/editor-support/spine-creator-support/SkeletonCacheAnimation.cpp +++ b/native/cocos/editor-support/spine-creator-support/SkeletonCacheAnimation.cpp @@ -33,27 +33,25 @@ #include "SkeletonCacheMgr.h" #include "base/TypeDef.h" #include "base/memory/Memory.h" -#include "math/Math.h" #include "gfx-base/GFXDef.h" +#include "math/Math.h" -USING_NS_MW; +USING_NS_MW; // NOLINT(google-build-using-namespace) -using namespace cc; -using namespace cc::gfx; -static const std::string techStage = "opaque"; -static const std::string textureKey = "texture"; +using namespace cc; // NOLINT(google-build-using-namespace) +using namespace cc::gfx; // NOLINT(google-build-using-namespace) +static const std::string TECH_STAGE = "opaque"; +static const std::string TEXTURE_KEY = "texture"; namespace spine { SkeletonCacheAnimation::SkeletonCacheAnimation(const std::string &uuid, bool isShare) { if (isShare) { _skeletonCache = SkeletonCacheMgr::getInstance()->buildSkeletonCache(uuid); - _skeletonCache->retain(); + _skeletonCache->addRef(); } else { _skeletonCache = new SkeletonCache(); _skeletonCache->initWithUUID(uuid); - _skeletonCache->retain(); - _skeletonCache->autorelease(); } // store global TypedArray begin and end offset @@ -64,13 +62,12 @@ SkeletonCacheAnimation::SkeletonCacheAnimation(const std::string &uuid, bool isS // set render order to 0 _paramsBuffer->writeFloat32(0); // set world transform to identity - _paramsBuffer->writeBytes((const char *)&cc::Mat4::IDENTITY, sizeof(float) * 16); + _paramsBuffer->writeBytes(reinterpret_cast(&cc::Mat4::IDENTITY), sizeof(float) * 16); beginSchedule(); } SkeletonCacheAnimation::~SkeletonCacheAnimation() { - if (_sharedBufferOffset) { delete _sharedBufferOffset; _sharedBufferOffset = nullptr; @@ -86,7 +83,7 @@ SkeletonCacheAnimation::~SkeletonCacheAnimation() { _skeletonCache = nullptr; } while (!_animationQueue.empty()) { - auto ani = _animationQueue.front(); + auto *ani = _animationQueue.front(); _animationQueue.pop(); delete ani; } @@ -116,7 +113,7 @@ void SkeletonCacheAnimation::update(float dt) { _accTime += dt; if (_accTime > _headAnimation->delay) { std::string name = _headAnimation->animationName; - bool loop = _headAnimation->loop; + bool loop = _headAnimation->loop; delete _headAnimation; _headAnimation = nullptr; setAnimation(name, loop); @@ -138,13 +135,13 @@ void SkeletonCacheAnimation::update(float dt) { _skeletonCache->updateToFrame(_animationName, frameIdx); } - int finalFrameIndex = (int)_animationData->getFrameCount() - 1; + int finalFrameIndex = static_cast(_animationData->getFrameCount()) - 1; if (_animationData->isComplete() && frameIdx >= finalFrameIndex) { _playCount++; - _accTime = 0.0f; + _accTime = 0.0F; if (_playTimes > 0 && _playCount >= _playTimes) { - frameIdx = finalFrameIndex; - _playCount = 0; + frameIdx = finalFrameIndex; + _playCount = 0; _isAniComplete = true; } else { frameIdx = 0; @@ -159,105 +156,108 @@ void SkeletonCacheAnimation::update(float dt) { _curFrameIndex = frameIdx; } -void SkeletonCacheAnimation::render(float dt) { +void SkeletonCacheAnimation::render(float /*dt*/) { if (!_animationData) return; SkeletonCache::FrameData *frameData = _animationData->getFrameData(_curFrameIndex); if (!frameData) return; - auto &segments = frameData->getSegments(); - auto &colors = frameData->getColors(); - if (segments.size() == 0 || colors.size() == 0) return; + const auto &segments = frameData->getSegments(); + const auto &colors = frameData->getColors(); + if (segments.empty() || colors.empty()) return; - auto mgr = MiddlewareManager::getInstance(); + auto *mgr = MiddlewareManager::getInstance(); if (!mgr->isRendering) return; _sharedBufferOffset->reset(); _sharedBufferOffset->clear(); - auto renderMgr = mgr->getRenderInfoMgr(); - auto renderInfo = renderMgr->getBuffer(); + auto *renderMgr = mgr->getRenderInfoMgr(); + auto *renderInfo = renderMgr->getBuffer(); if (!renderInfo) return; - auto attachMgr = mgr->getAttachInfoMgr(); - auto attachInfo = attachMgr->getBuffer(); + auto *attachMgr = mgr->getAttachInfoMgr(); + auto *attachInfo = attachMgr->getBuffer(); if (!attachInfo) return; // store render info offset - _sharedBufferOffset->writeUint32((uint32_t)renderInfo->getCurPos() / sizeof(uint32_t)); + _sharedBufferOffset->writeUint32(static_cast(renderInfo->getCurPos()) / sizeof(uint32_t)); // store attach info offset - _sharedBufferOffset->writeUint32((uint32_t)attachInfo->getCurPos() / sizeof(uint32_t)); + _sharedBufferOffset->writeUint32(static_cast(attachInfo->getCurPos()) / sizeof(uint32_t)); // check enough space renderInfo->checkSpace(sizeof(uint32_t) * 2, true); // write border renderInfo->writeUint32(0xffffffff); - // matieral len + // material len renderInfo->writeUint32(segments.size()); - auto vertexFormat = _useTint ? VF_XYZUVCC : VF_XYZUVC; - middleware::MeshBuffer *mb = mgr->getMeshBuffer(vertexFormat); - middleware::IOBuffer &vb = mb->getVB(); - middleware::IOBuffer &ib = mb->getIB(); - const auto &srcVB = frameData->vb; - const auto &srcIB = frameData->ib; + auto vertexFormat = _useTint ? VF_XYZUVCC : VF_XYZUVC; + middleware::MeshBuffer *mb = mgr->getMeshBuffer(vertexFormat); + middleware::IOBuffer & vb = mb->getVB(); + middleware::IOBuffer & ib = mb->getIB(); + const auto & srcVB = frameData->vb; + const auto & srcIB = frameData->ib; // vertex size int bytes with one color int vbs1 = sizeof(V2F_T2F_C4F); // vertex size in floats with one color - int vs1 = vbs1 / sizeof(float); + int vs1 = static_cast(vbs1 / sizeof(float)); // vertex size int bytes with two color int vbs2 = sizeof(V2F_T2F_C4F_C4F); // vertex size in floats with two color - int vs2 = vbs2 / sizeof(float); + int vs2 = static_cast(vbs2 / sizeof(float)); - int vs = _useTint ? vs2 : vs1; + int vs = _useTint ? vs2 : vs1; int vbs = _useTint ? vbs2 : vbs1; - auto paramsBuffer = _paramsBuffer->getBuffer(); - const cc::Mat4 &nodeWorldMat = *(cc::Mat4 *)¶msBuffer[4]; + auto * paramsBuffer = _paramsBuffer->getBuffer(); + const cc::Mat4 &nodeWorldMat = *reinterpret_cast(¶msBuffer[4]); - int colorOffset = 0; - SkeletonCache::ColorData *nowColor = colors[colorOffset++]; - auto maxVFOffset = nowColor->vertexFloatOffset; + int colorOffset = 0; + SkeletonCache::ColorData *nowColor = colors[colorOffset++]; + auto maxVFOffset = nowColor->vertexFloatOffset; - Color4F finalColor; - Color4F darkColor; - float tempR = 0.0f, tempG = 0.0f, tempB = 0.0f, tempA = 0.0f; - float multiplier = 1.0f; - int srcVertexBytesOffset = 0; - int srcVertexBytes = 0; - int vertexBytes = 0; - int vertexFloats = 0; - int tintBytes = 0; - int srcIndexBytesOffset = 0; - int indexBytes = 0; - int curTextureIndex = 0; - double effectHash = 0; - int blendMode = 0; - int dstVertexOffset = 0; - int dstIndexOffset = 0; - float *dstVertexBuffer = nullptr; - unsigned int *dstColorBuffer = nullptr; - unsigned short *dstIndexBuffer = nullptr; - bool needColor = false; - int curBlendSrc = -1; - int curBlendDst = -1; + Color4F finalColor; + Color4F darkColor; + float tempR = 0.0F; + float tempG = 0.0F; + float tempB = 0.0F; + float tempA = 0.0F; + float multiplier = 1.0F; + int srcVertexBytesOffset = 0; + int srcVertexBytes = 0; + int vertexBytes = 0; + int vertexFloats = 0; + int tintBytes = 0; + int srcIndexBytesOffset = 0; + int indexBytes = 0; + int curTextureIndex = 0; + double effectHash = 0; + int blendMode = 0; + int dstVertexOffset = 0; + int dstIndexOffset = 0; + float * dstVertexBuffer = nullptr; + unsigned int *dstColorBuffer = nullptr; + uint16_t * dstIndexBuffer = nullptr; + bool needColor = false; + int curBlendSrc = -1; + int curBlendDst = -1; - if (abs(_nodeColor.r - 1.0f) > 0.0001f || - abs(_nodeColor.g - 1.0f) > 0.0001f || - abs(_nodeColor.b - 1.0f) > 0.0001f || - abs(_nodeColor.a - 1.0f) > 0.0001f || + if (abs(_nodeColor.r - 1.0F) > 0.0001F || + abs(_nodeColor.g - 1.0F) > 0.0001F || + abs(_nodeColor.b - 1.0F) > 0.0001F || + abs(_nodeColor.a - 1.0F) > 0.0001F || _premultipliedAlpha) { needColor = true; } auto handleColor = [&](SkeletonCache::ColorData *colorData) { - tempA = colorData->finalColor.a * _nodeColor.a; + tempA = colorData->finalColor.a * _nodeColor.a; multiplier = _premultipliedAlpha ? tempA / 255 : 1; - tempR = _nodeColor.r * multiplier; - tempG = _nodeColor.g * multiplier; - tempB = _nodeColor.b * multiplier; + tempR = _nodeColor.r * multiplier; + tempG = _nodeColor.g * multiplier; + tempB = _nodeColor.b * multiplier; finalColor.a = tempA / 255.0f; finalColor.r = (colorData->finalColor.r * tempR) / 255.0f; @@ -272,15 +272,14 @@ void SkeletonCacheAnimation::render(float dt) { handleColor(nowColor); - for (std::size_t segIndex = 0, segLen = segments.size(); segIndex < segLen; segIndex++) { - auto segment = segments[segIndex]; - srcVertexBytes = segment->vertexFloatCount * sizeof(float); + for (auto *segment : segments) { + srcVertexBytes = static_cast(segment->vertexFloatCount * sizeof(float)); if (!_useTint) { - tintBytes = segment->vertexFloatCount / vs2 * sizeof(float); - vertexBytes = srcVertexBytes - tintBytes; - vertexFloats = vertexBytes / sizeof(float); + tintBytes = static_cast(segment->vertexFloatCount / vs2 * sizeof(float)); + vertexBytes = srcVertexBytes - tintBytes; + vertexFloats = static_cast(vertexBytes / sizeof(float)); } else { - vertexBytes = srcVertexBytes; + vertexBytes = srcVertexBytes; vertexFloats = segment->vertexFloatCount; } @@ -294,20 +293,20 @@ void SkeletonCacheAnimation::render(float dt) { blendMode = segment->blendMode; switch (blendMode) { case BlendMode_Additive: - curBlendSrc = (int)(_premultipliedAlpha ? BlendFactor::ONE : BlendFactor::SRC_ALPHA); - curBlendDst = (int)BlendFactor::ONE; + curBlendSrc = static_cast(_premultipliedAlpha ? BlendFactor::ONE : BlendFactor::SRC_ALPHA); + curBlendDst = static_cast(BlendFactor::ONE); break; case BlendMode_Multiply: - curBlendSrc = (int)BlendFactor::DST_COLOR; - curBlendDst = (int)BlendFactor::ONE_MINUS_SRC_ALPHA; + curBlendSrc = static_cast(BlendFactor::DST_COLOR); + curBlendDst = static_cast(BlendFactor::ONE_MINUS_SRC_ALPHA); break; case BlendMode_Screen: - curBlendSrc = (int)BlendFactor::ONE; - curBlendDst = (int)BlendFactor::ONE_MINUS_SRC_COLOR; + curBlendSrc = static_cast(BlendFactor::ONE); + curBlendDst = static_cast(BlendFactor::ONE_MINUS_SRC_COLOR); break; default: - curBlendSrc = (int)(_premultipliedAlpha ? BlendFactor::ONE : BlendFactor::SRC_ALPHA); - curBlendDst = (int)BlendFactor::ONE_MINUS_SRC_ALPHA; + curBlendSrc = static_cast(_premultipliedAlpha ? BlendFactor::ONE : BlendFactor::SRC_ALPHA); + curBlendDst = static_cast(BlendFactor::ONE_MINUS_SRC_ALPHA); } // fill new blend src and dst renderInfo->writeUint32(curBlendSrc); @@ -315,23 +314,23 @@ void SkeletonCacheAnimation::render(float dt) { // fill vertex buffer vb.checkSpace(vertexBytes, true); - dstVertexOffset = (int)vb.getCurPos() / vbs; - dstVertexBuffer = (float *)vb.getCurBuffer(); - dstColorBuffer = (unsigned int *)vb.getCurBuffer(); + dstVertexOffset = static_cast(vb.getCurPos()) / vbs; + dstVertexBuffer = reinterpret_cast(vb.getCurBuffer()); + dstColorBuffer = reinterpret_cast(vb.getCurBuffer()); if (!_useTint) { - char *srcBuffer = (char *)srcVB.getBuffer() + srcVertexBytesOffset; + char *srcBuffer = reinterpret_cast(srcVB.getBuffer()) + srcVertexBytesOffset; for (std::size_t srcBufferIdx = 0; srcBufferIdx < srcVertexBytes; srcBufferIdx += vbs2) { vb.writeBytes(srcBuffer + srcBufferIdx, vbs); } } else { - vb.writeBytes((char *)srcVB.getBuffer() + srcVertexBytesOffset, vertexBytes); + vb.writeBytes(reinterpret_cast(srcVB.getBuffer()) + srcVertexBytesOffset, vertexBytes); } // batch handle if (_batch) { cc::Vec3 *point = nullptr; for (auto posIndex = 0; posIndex < vertexFloats; posIndex += vs) { - point = (cc::Vec3 *)(dstVertexBuffer + posIndex); + point = reinterpret_cast(dstVertexBuffer + posIndex); // force z value to zero point->z = 0; point->transformMat4(*point, nodeWorldMat); @@ -340,7 +339,7 @@ void SkeletonCacheAnimation::render(float dt) { // handle vertex color if (needColor) { - int srcVertexFloatOffset = srcVertexBytesOffset / sizeof(float); + int srcVertexFloatOffset = static_cast(srcVertexBytesOffset / sizeof(float)); if (_useTint) { for (auto colorIndex = 0; colorIndex < vertexFloats; colorIndex += vs, srcVertexFloatOffset += vs2) { if (srcVertexFloatOffset >= maxVFOffset) { @@ -367,11 +366,11 @@ void SkeletonCacheAnimation::render(float dt) { srcVertexBytesOffset += srcVertexBytes; // fill index buffer - indexBytes = segment->indexCount * sizeof(unsigned short); + indexBytes = static_cast(segment->indexCount * sizeof(uint16_t)); ib.checkSpace(indexBytes, true); - dstIndexOffset = (int)ib.getCurPos() / sizeof(unsigned short); - dstIndexBuffer = (unsigned short *)ib.getCurBuffer(); - ib.writeBytes((char *)srcIB.getBuffer() + srcIndexBytesOffset, indexBytes); + dstIndexOffset = static_cast(ib.getCurPos() / sizeof(uint16_t)); + dstIndexBuffer = reinterpret_cast(ib.getCurBuffer()); + ib.writeBytes(reinterpret_cast(srcIB.getBuffer()) + srcIndexBytesOffset, indexBytes); for (auto indexPos = 0; indexPos < segment->indexCount; indexPos++) { dstIndexBuffer[indexPos] += dstVertexOffset; } @@ -388,13 +387,13 @@ void SkeletonCacheAnimation::render(float dt) { } if (_useAttach) { - auto &bonesData = frameData->getBones(); - auto boneCount = frameData->getBoneCount(); + const auto &bonesData = frameData->getBones(); + auto boneCount = frameData->getBoneCount(); - for (int i = 0, n = boneCount; i < n; i++) { - auto bone = bonesData[i]; + for (std::size_t i = 0, n = boneCount; i < n; i++) { + auto *bone = bonesData[i]; attachInfo->checkSpace(sizeof(cc::Mat4), true); - attachInfo->writeBytes((const char *)&bone->globalTransformMatrix, sizeof(cc::Mat4)); + attachInfo->writeBytes(reinterpret_cast(&bone->globalTransformMatrix), sizeof(cc::Mat4)); } } } @@ -450,10 +449,10 @@ bool SkeletonCacheAnimation::setAttachment(const std::string &slotName, const ch } void SkeletonCacheAnimation::setColor(float r, float g, float b, float a) { - _nodeColor.r = r / 255.0f; - _nodeColor.g = g / 255.0f; - _nodeColor.b = b / 255.0f; - _nodeColor.a = a / 255.0f; + _nodeColor.r = r / 255.0F; + _nodeColor.g = g / 255.0F; + _nodeColor.b = b / 255.0F; + _nodeColor.a = a / 255.0F; } void SkeletonCacheAnimation::setBatchEnabled(bool enabled) { @@ -500,20 +499,20 @@ void SkeletonCacheAnimation::setAttachEnabled(bool enabled) { } void SkeletonCacheAnimation::setAnimation(const std::string &name, bool loop) { - _playTimes = loop ? 0 : 1; + _playTimes = loop ? 0 : 1; _animationName = name; _animationData = _skeletonCache->buildAnimationData(_animationName); _isAniComplete = false; - _accTime = 0.0f; - _playCount = 0; + _accTime = 0.0F; + _playCount = 0; _curFrameIndex = 0; } void SkeletonCacheAnimation::addAnimation(const std::string &name, bool loop, float delay) { - auto aniInfo = new AniQueueData(); + auto *aniInfo = new AniQueueData(); aniInfo->animationName = name; - aniInfo->loop = loop; - aniInfo->delay = delay; + aniInfo->loop = loop; + aniInfo->delay = delay; _animationQueue.push(aniInfo); } @@ -557,8 +556,8 @@ se_object_ptr SkeletonCacheAnimation::getParamsBuffer() const { uint32_t SkeletonCacheAnimation::getRenderOrder() const { if (_paramsBuffer) { - auto buffer = _paramsBuffer->getBuffer(); - return (uint32_t)buffer[0]; + auto *buffer = _paramsBuffer->getBuffer(); + return static_cast(buffer[0]); } return 0; } diff --git a/native/cocos/editor-support/spine-creator-support/SkeletonCacheAnimation.h b/native/cocos/editor-support/spine-creator-support/SkeletonCacheAnimation.h index 8890ad2151..73dc686a4f 100644 --- a/native/cocos/editor-support/spine-creator-support/SkeletonCacheAnimation.h +++ b/native/cocos/editor-support/spine-creator-support/SkeletonCacheAnimation.h @@ -28,27 +28,27 @@ *****************************************************************************/ #pragma once +#include #include "MiddlewareManager.h" #include "SkeletonCache.h" -#include "base/Ref.h" +#include "base/RefCounted.h" #include "middleware-adapter.h" #include "spine/spine.h" -#include namespace spine { -class SkeletonCacheAnimation : public cc::middleware::IMiddleware, public cc::Ref { +class SkeletonCacheAnimation : public cc::RefCounted, public cc::middleware::IMiddleware { public: SkeletonCacheAnimation(const std::string &uuid, bool isShare); - virtual ~SkeletonCacheAnimation(); + ~SkeletonCacheAnimation() override; - virtual void update(float dt) override; - virtual void render(float dt) override; - virtual uint32_t getRenderOrder() const override; + void update(float dt) override; + void render(float dt) override; + uint32_t getRenderOrder() const override; Skeleton *getSkeleton() const; - void setTimeScale(float scale); + void setTimeScale(float scale); float getTimeScale() const; void paused(bool value); @@ -60,11 +60,11 @@ public: void setSkin(const char *skinName); Attachment *getAttachment(const std::string &slotName, const std::string &attachmentName) const; - bool setAttachment(const std::string &slotName, const std::string &attachmentName); - bool setAttachment(const std::string &slotName, const char *attachmentName); - void setColor(float r, float g, float b, float a); - void setBatchEnabled(bool enabled); - void setAttachEnabled(bool enabled); + bool setAttachment(const std::string &slotName, const std::string &attachmentName); + bool setAttachment(const std::string &slotName, const char *attachmentName); + void setColor(float r, float g, float b, float a); + void setBatchEnabled(bool enabled); + void setAttachEnabled(bool enabled); void setOpacityModifyRGB(bool value); bool isOpacityModifyRGB() const; @@ -75,11 +75,11 @@ public: void onDisable(); void setUseTint(bool enabled); - void setAnimation(const std::string &name, bool loop); - void addAnimation(const std::string &name, bool loop, float delay = 0); + void setAnimation(const std::string &name, bool loop); + void addAnimation(const std::string &name, bool loop, float delay = 0); Animation *findAnimation(const std::string &name) const; - typedef std::function CacheFrameEvent; + using CacheFrameEvent = std::function; void setStartListener(const CacheFrameEvent &listener); void setEndListener(const CacheFrameEvent &listener); void setCompleteListener(const CacheFrameEvent &listener); @@ -102,35 +102,35 @@ public: se_object_ptr getParamsBuffer() const; private: - float _timeScale = 1; - bool _paused = false; - bool _useAttach = false; - bool _batch = true; - cc::middleware::Color4F _nodeColor = cc::middleware::Color4F::WHITE; - bool _premultipliedAlpha = false; + float _timeScale = 1; + bool _paused = false; + bool _useAttach = false; + bool _batch = true; + cc::middleware::Color4F _nodeColor = cc::middleware::Color4F::WHITE; + bool _premultipliedAlpha = false; - CacheFrameEvent _startListener = nullptr; - CacheFrameEvent _endListener = nullptr; + CacheFrameEvent _startListener = nullptr; + CacheFrameEvent _endListener = nullptr; CacheFrameEvent _completeListener = nullptr; - SkeletonCache *_skeletonCache = nullptr; + SkeletonCache * _skeletonCache = nullptr; SkeletonCache::AnimationData *_animationData = nullptr; - int _curFrameIndex = -1; + int _curFrameIndex = -1; - float _accTime = 0.0f; - int _playCount = 0; - int _playTimes = 0; - bool _isAniComplete = true; - std::string _animationName = ""; - bool _useTint = true; + float _accTime = 0.0F; + int _playCount = 0; + int _playTimes = 0; + bool _isAniComplete = true; + std::string _animationName; + bool _useTint = true; struct AniQueueData { - std::string animationName = ""; - bool loop = false; - float delay = 0.0f; + std::string animationName; + bool loop = false; + float delay = 0.0F; }; std::queue _animationQueue; - AniQueueData *_headAnimation = nullptr; + AniQueueData * _headAnimation = nullptr; cc::middleware::IOTypedArray *_sharedBufferOffset = nullptr; // Js fill this buffer to send parameter to cpp, avoid to call jsb function. diff --git a/native/cocos/editor-support/spine-creator-support/SkeletonCacheMgr.cpp b/native/cocos/editor-support/spine-creator-support/SkeletonCacheMgr.cpp index 971212e738..674a83dd00 100644 --- a/native/cocos/editor-support/spine-creator-support/SkeletonCacheMgr.cpp +++ b/native/cocos/editor-support/spine-creator-support/SkeletonCacheMgr.cpp @@ -28,16 +28,18 @@ *****************************************************************************/ #include "SkeletonCacheMgr.h" +#include "base/DeferredReleasePool.h" namespace spine { -SkeletonCacheMgr *SkeletonCacheMgr::_instance = nullptr; -SkeletonCache *SkeletonCacheMgr::buildSkeletonCache(const std::string &uuid) { +SkeletonCacheMgr *SkeletonCacheMgr::instance = nullptr; +SkeletonCache * SkeletonCacheMgr::buildSkeletonCache(const std::string &uuid) { SkeletonCache *animation = _caches.at(uuid); if (!animation) { animation = new SkeletonCache(); + animation->addRef(); animation->initWithUUID(uuid); _caches.insert(uuid, animation); - animation->autorelease(); + cc::DeferredReleasePool::add(animation); } return animation; } diff --git a/native/cocos/editor-support/spine-creator-support/SkeletonCacheMgr.h b/native/cocos/editor-support/spine-creator-support/SkeletonCacheMgr.h index d2931cc63f..d37c565f9b 100644 --- a/native/cocos/editor-support/spine-creator-support/SkeletonCacheMgr.h +++ b/native/cocos/editor-support/spine-creator-support/SkeletonCacheMgr.h @@ -36,16 +36,16 @@ namespace spine { class SkeletonCacheMgr { public: static SkeletonCacheMgr *getInstance() { - if (_instance == nullptr) { - _instance = new SkeletonCacheMgr(); + if (instance == nullptr) { + instance = new SkeletonCacheMgr(); } - return _instance; + return instance; } static void destroyInstance() { - if (_instance) { - delete _instance; - _instance = nullptr; + if (instance) { + delete instance; + instance = nullptr; } } @@ -53,7 +53,7 @@ public: SkeletonCache *buildSkeletonCache(const std::string &uuid); private: - static SkeletonCacheMgr *_instance; + static SkeletonCacheMgr *instance; cc::Map _caches; }; diff --git a/native/cocos/editor-support/spine-creator-support/SkeletonDataMgr.h b/native/cocos/editor-support/spine-creator-support/SkeletonDataMgr.h index 2355adb18a..b5572d170e 100644 --- a/native/cocos/editor-support/spine-creator-support/SkeletonDataMgr.h +++ b/native/cocos/editor-support/spine-creator-support/SkeletonDataMgr.h @@ -29,13 +29,13 @@ #pragma once -#include "base/Ref.h" -#include "spine/SkeletonData.h" -#include "spine/spine.h" #include #include #include #include +#include "base/RefCounted.h" +#include "spine/SkeletonData.h" +#include "spine/spine.h" namespace spine { @@ -78,8 +78,8 @@ public: } private: - static SkeletonDataMgr* instance; - destroyCallback _destroyCallback = nullptr; + static SkeletonDataMgr * instance; + destroyCallback _destroyCallback = nullptr; std::map _dataMap; }; diff --git a/native/cocos/editor-support/spine-creator-support/SkeletonRenderer.cpp b/native/cocos/editor-support/spine-creator-support/SkeletonRenderer.cpp index 62409b76df..5c35653dd8 100644 --- a/native/cocos/editor-support/spine-creator-support/SkeletonRenderer.cpp +++ b/native/cocos/editor-support/spine-creator-support/SkeletonRenderer.cpp @@ -28,21 +28,22 @@ *****************************************************************************/ #include "spine-creator-support/SkeletonRenderer.h" +#include #include "MiddlewareMacro.h" #include "SharedBufferManager.h" #include "SkeletonDataMgr.h" +#include "base/DeferredReleasePool.h" #include "base/TypeDef.h" #include "base/memory/Memory.h" +#include "gfx-base/GFXDef.h" #include "math/Math.h" #include "math/Vec3.h" -#include "gfx-base/GFXDef.h" #include "spine-creator-support/AttachmentVertices.h" #include "spine-creator-support/spine-cocos2dx.h" -#include -USING_NS_MW; // NOLINT(google-build-using-namespace) -using namespace spine; // NOLINT(google-build-using-namespace) -using namespace cc; // NOLINT(google-build-using-namespace) +USING_NS_MW; // NOLINT(google-build-using-namespace) +using namespace spine; // NOLINT(google-build-using-namespace) +using namespace cc; // NOLINT(google-build-using-namespace) using namespace cc::gfx; // NOLINT(google-build-using-namespace) using std::max; @@ -60,27 +61,19 @@ enum DebugType { BONES }; SkeletonRenderer *SkeletonRenderer::create() { - auto *skeleton = new SkeletonRenderer(); - skeleton->autorelease(); - return skeleton; + return new SkeletonRenderer(); } SkeletonRenderer *SkeletonRenderer::createWithSkeleton(Skeleton *skeleton, bool ownsSkeleton, bool ownsSkeletonData) { - auto *node = new SkeletonRenderer(skeleton, ownsSkeleton, ownsSkeletonData); - node->autorelease(); - return node; + return new SkeletonRenderer(skeleton, ownsSkeleton, ownsSkeletonData); } SkeletonRenderer *SkeletonRenderer::createWithData(SkeletonData *skeletonData, bool ownsSkeletonData) { - auto *node = new SkeletonRenderer(skeletonData, ownsSkeletonData); - node->autorelease(); - return node; + return new SkeletonRenderer(skeletonData, ownsSkeletonData); } SkeletonRenderer *SkeletonRenderer::createWithFile(const std::string &skeletonDataFile, const std::string &atlasFile, float scale) { - auto *node = new SkeletonRenderer(skeletonDataFile, atlasFile, scale); - node->autorelease(); - return node; + return new SkeletonRenderer(skeletonDataFile, atlasFile, scale); } void SkeletonRenderer::initialize() { @@ -829,7 +822,7 @@ void SkeletonRenderer::render(float /*deltaTime*/) { uint8_t * vbBuffer = vb.getCurBuffer(); cc::Vec3 *point = nullptr; for (unsigned int ii = 0, nn = vbSize; ii < nn; ii += vbs) { - point = reinterpret_cast(vbBuffer + ii); + point = reinterpret_cast(vbBuffer + ii); point->z = 0; //reset for z value point->transformMat4(*point, nodeWorldMat); } @@ -1032,7 +1025,7 @@ void SkeletonRenderer::setVertexEffectDelegate(VertexEffectDelegate *effectDeleg } CC_SAFE_RELEASE(_effectDelegate); _effectDelegate = effectDelegate; - CC_SAFE_RETAIN(_effectDelegate); + CC_SAFE_ADD_REF(_effectDelegate); } void SkeletonRenderer::setSlotsRange(int startSlotIndex, int endSlotIndex) { @@ -1116,4 +1109,3 @@ uint32_t SkeletonRenderer::getRenderOrder() const { } return 0; } - diff --git a/native/cocos/editor-support/spine-creator-support/SkeletonRenderer.h b/native/cocos/editor-support/spine-creator-support/SkeletonRenderer.h index d5574b81b2..d402676d8f 100644 --- a/native/cocos/editor-support/spine-creator-support/SkeletonRenderer.h +++ b/native/cocos/editor-support/spine-creator-support/SkeletonRenderer.h @@ -29,16 +29,16 @@ #pragma once +#include #include "IOTypedArray.h" #include "MiddlewareManager.h" #include "Object.h" #include "base/Macros.h" #include "base/Map.h" -#include "base/Ref.h" +#include "base/RefCounted.h" #include "middleware-adapter.h" #include "spine-creator-support/VertexEffectDelegate.h" #include "spine/spine.h" -#include namespace spine { @@ -46,21 +46,21 @@ class AttachmentVertices; /** Draws a skeleton. */ -class SkeletonRenderer : public cc::middleware::IMiddleware, public cc::Ref { +class SkeletonRenderer : public cc::RefCounted, public cc::middleware::IMiddleware { public: static SkeletonRenderer *create(); static SkeletonRenderer *createWithSkeleton(Skeleton *skeleton, bool ownsSkeleton = false, bool ownsSkeletonData = false); static SkeletonRenderer *createWithData(SkeletonData *skeletonData, bool ownsSkeletonData = false); static SkeletonRenderer *createWithFile(const std::string &skeletonDataFile, const std::string &atlasFile, float scale = 1); - void update(float deltaTime) override {} - void render(float deltaTime) override; + void update(float deltaTime) override {} + void render(float deltaTime) override; virtual cc::Rect getBoundingBox() const; - uint32_t getRenderOrder() const override; + uint32_t getRenderOrder() const override; Skeleton *getSkeleton() const; - void setTimeScale(float scale); + void setTimeScale(float scale); float getTimeScale() const; void updateWorldTransform(); @@ -126,8 +126,8 @@ public: virtual void beginSchedule(); virtual void stopSchedule(); - void onEnable(); - void onDisable(); + void onEnable(); + void onDisable(); SkeletonRenderer(); explicit SkeletonRenderer(Skeleton *skeleton, bool ownsSkeleton = false, bool ownsSkeletonData = false, bool ownsAtlas = false); @@ -149,32 +149,32 @@ public: protected: void setSkeletonData(SkeletonData *skeletonData, bool ownsSkeletonData); - bool _ownsSkeletonData = false; - bool _ownsSkeleton = false; - bool _ownsAtlas = false; - Atlas *_atlas = nullptr; - AttachmentLoader *_attachmentLoader = nullptr; - Skeleton *_skeleton = nullptr; - VertexEffectDelegate *_effectDelegate = nullptr; - float _timeScale = 1; - bool _paused = false; + bool _ownsSkeletonData = false; + bool _ownsSkeleton = false; + bool _ownsAtlas = false; + Atlas * _atlas = nullptr; + AttachmentLoader * _attachmentLoader = nullptr; + Skeleton * _skeleton = nullptr; + VertexEffectDelegate *_effectDelegate = nullptr; + float _timeScale = 1; + bool _paused = false; - bool _batch = true; - bool _useAttach = false; - bool _debugMesh = false; - bool _debugSlots = false; - bool _debugBones = false; - cc::middleware::Color4F _nodeColor = cc::middleware::Color4F::WHITE; - bool _premultipliedAlpha = false; - SkeletonClipping *_clipper = nullptr; - bool _useTint = false; - std::string _uuid; + bool _batch = true; + bool _useAttach = false; + bool _debugMesh = false; + bool _debugSlots = false; + bool _debugBones = false; + cc::middleware::Color4F _nodeColor = cc::middleware::Color4F::WHITE; + bool _premultipliedAlpha = false; + SkeletonClipping * _clipper = nullptr; + bool _useTint = false; + std::string _uuid; int _startSlotIndex = -1; - int _endSlotIndex = -1; + int _endSlotIndex = -1; cc::middleware::IOTypedArray *_sharedBufferOffset = nullptr; - cc::middleware::IOTypedArray *_debugBuffer = nullptr; + cc::middleware::IOTypedArray *_debugBuffer = nullptr; // Js fill this buffer to send parameter to cpp, avoid to call jsb function. cc::middleware::IOTypedArray *_paramsBuffer = nullptr; }; diff --git a/native/cocos/editor-support/spine-creator-support/VertexEffectDelegate.h b/native/cocos/editor-support/spine-creator-support/VertexEffectDelegate.h index d2b0badc05..0c489fa760 100644 --- a/native/cocos/editor-support/spine-creator-support/VertexEffectDelegate.h +++ b/native/cocos/editor-support/spine-creator-support/VertexEffectDelegate.h @@ -29,31 +29,31 @@ #pragma once -#include "base/Ref.h" -#include "spine/spine.h" #include +#include "base/RefCounted.h" +#include "spine/spine.h" namespace spine { -class VertexEffectDelegate : public cc::Ref { +class VertexEffectDelegate : public cc::RefCounted { public: VertexEffectDelegate(); - ~VertexEffectDelegate(); + ~VertexEffectDelegate() override; JitterVertexEffect *initJitter(float jitterX, float jitterY); - SwirlVertexEffect *initSwirlWithPow(float radius, int power); - SwirlVertexEffect *initSwirlWithPowOut(float radius, int power); - VertexEffect *getVertexEffect() { + SwirlVertexEffect * initSwirlWithPow(float radius, int power); + SwirlVertexEffect * initSwirlWithPowOut(float radius, int power); + VertexEffect * getVertexEffect() { return _vertexEffect; } JitterVertexEffect *getJitterVertexEffect(); - SwirlVertexEffect *getSwirlVertexEffect(); - const std::string &getEffectType() const { + SwirlVertexEffect * getSwirlVertexEffect(); + const std::string & getEffectType() const { return _effectType; } void clear(); private: - VertexEffect *_vertexEffect = nullptr; + VertexEffect * _vertexEffect = nullptr; Interpolation *_interpolation = nullptr; - std::string _effectType = "none"; + std::string _effectType = "none"; }; } // namespace spine diff --git a/native/cocos/editor-support/spine-creator-support/spine-cocos2dx.cpp b/native/cocos/editor-support/spine-creator-support/spine-cocos2dx.cpp index 3f72a7e0b7..ab555d7d74 100644 --- a/native/cocos/editor-support/spine-creator-support/spine-cocos2dx.cpp +++ b/native/cocos/editor-support/spine-creator-support/spine-cocos2dx.cpp @@ -34,31 +34,31 @@ #include "spine-creator-support/AttachmentVertices.h" namespace spine { -static CustomTextureLoader _customTextureLoader = nullptr; -void spAtlasPage_setCustomTextureLoader(CustomTextureLoader texLoader) { - _customTextureLoader = texLoader; +static CustomTextureLoader customTextureLoader = nullptr; +void spAtlasPage_setCustomTextureLoader(CustomTextureLoader texLoader) { + customTextureLoader = texLoader; } -static SpineObjectDisposeCallback _spineObjectDisposeCallback = 0; -void setSpineObjectDisposeCallback(SpineObjectDisposeCallback callback) { - _spineObjectDisposeCallback = callback; +static SpineObjectDisposeCallback spineObjectDisposeCallback = nullptr; +void setSpineObjectDisposeCallback(SpineObjectDisposeCallback callback) { + spineObjectDisposeCallback = callback; } } // namespace spine -USING_NS_MW; -using namespace cc; -using namespace spine; +USING_NS_MW; // NOLINT(google-build-using-namespace) +using namespace cc; // NOLINT(google-build-using-namespace) +using namespace spine; // NOLINT(google-build-using-namespace) static void deleteAttachmentVertices(void *vertices) { - delete (AttachmentVertices *)vertices; + delete static_cast(vertices); } -static unsigned short quadTriangles[6] = {0, 1, 2, 2, 3, 0}; +static uint16_t quadTriangles[6] = {0, 1, 2, 2, 3, 0}; static void setAttachmentVertices(RegionAttachment *attachment) { - AtlasRegion *region = (AtlasRegion *)attachment->getRendererObject(); - AttachmentVertices *attachmentVertices = new AttachmentVertices((Texture2D *)region->page->getRendererObject(), 4, quadTriangles, 6); - V2F_T2F_C4F *vertices = attachmentVertices->_triangles->verts; + auto * region = static_cast(attachment->getRendererObject()); + auto * attachmentVertices = new AttachmentVertices(static_cast(region->page->getRendererObject()), 4, quadTriangles, 6); + V2F_T2F_C4F *vertices = attachmentVertices->_triangles->verts; for (int i = 0, ii = 0; i < 4; ++i, ii += 2) { vertices[i].texCoord.u = attachment->getUVs()[ii]; vertices[i].texCoord.v = attachment->getUVs()[ii + 1]; @@ -67,10 +67,10 @@ static void setAttachmentVertices(RegionAttachment *attachment) { } static void setAttachmentVertices(MeshAttachment *attachment) { - AtlasRegion *region = (AtlasRegion *)attachment->getRendererObject(); - AttachmentVertices *attachmentVertices = new AttachmentVertices((Texture2D *)region->page->getRendererObject(), - attachment->getWorldVerticesLength() >> 1, attachment->getTriangles().buffer(), attachment->getTriangles().size()); - V2F_T2F_C4F *vertices = attachmentVertices->_triangles->verts; + auto * region = static_cast(attachment->getRendererObject()); + auto * attachmentVertices = new AttachmentVertices(static_cast(region->page->getRendererObject()), + static_cast(attachment->getWorldVerticesLength() >> 1), attachment->getTriangles().buffer(), static_cast(attachment->getTriangles().size())); + V2F_T2F_C4F *vertices = attachmentVertices->_triangles->verts; for (size_t i = 0, ii = 0, nn = attachment->getWorldVerticesLength(); ii < nn; ++i, ii += 2) { vertices[i].texCoord.u = attachment->getUVs()[ii]; vertices[i].texCoord.v = attachment->getUVs()[ii + 1]; @@ -81,64 +81,64 @@ static void setAttachmentVertices(MeshAttachment *attachment) { Cocos2dAtlasAttachmentLoader::Cocos2dAtlasAttachmentLoader(Atlas *atlas) : AtlasAttachmentLoader(atlas) { } -Cocos2dAtlasAttachmentLoader::~Cocos2dAtlasAttachmentLoader() {} +Cocos2dAtlasAttachmentLoader::~Cocos2dAtlasAttachmentLoader() = default; void Cocos2dAtlasAttachmentLoader::configureAttachment(Attachment *attachment) { if (attachment->getRTTI().isExactly(RegionAttachment::rtti)) { - setAttachmentVertices((RegionAttachment *)attachment); + setAttachmentVertices(dynamic_cast(attachment)); } else if (attachment->getRTTI().isExactly(MeshAttachment::rtti)) { - setAttachmentVertices((MeshAttachment *)attachment); + setAttachmentVertices(dynamic_cast(attachment)); } } -uint32_t wrap(TextureWrap _wrap) { - return (uint32_t)_wrap; +uint32_t wrap(TextureWrap wrap) { + return static_cast(wrap); } -uint32_t filter(TextureFilter _filter) { - return (uint32_t)_filter; +uint32_t filter(TextureFilter filter) { + return static_cast(filter); } -Cocos2dTextureLoader::Cocos2dTextureLoader() : TextureLoader() {} -Cocos2dTextureLoader::~Cocos2dTextureLoader() {} +Cocos2dTextureLoader::Cocos2dTextureLoader() = default; +Cocos2dTextureLoader::~Cocos2dTextureLoader() = default; void Cocos2dTextureLoader::load(AtlasPage &page, const spine::String &path) { Texture2D *texture = nullptr; - if (spine::_customTextureLoader) { - texture = spine::_customTextureLoader(path.buffer()); + if (spine::customTextureLoader) { + texture = spine::customTextureLoader(path.buffer()); } CCASSERT(texture != nullptr, "Invalid image"); if (texture) { - texture->retain(); + texture->addRef(); Texture2D::TexParams textureParams = {filter(page.minFilter), filter(page.magFilter), wrap(page.uWrap), wrap(page.vWrap)}; texture->setTexParameters(textureParams); page.setRendererObject(texture); - page.width = texture->getPixelsWide(); + page.width = texture->getPixelsWide(); page.height = texture->getPixelsHigh(); } } void Cocos2dTextureLoader::unload(void *texture) { if (texture) { - ((Texture2D *)texture)->release(); + (static_cast(texture))->release(); } } -Cocos2dExtension::Cocos2dExtension() : DefaultSpineExtension() {} +Cocos2dExtension::Cocos2dExtension() = default; -Cocos2dExtension::~Cocos2dExtension() {} +Cocos2dExtension::~Cocos2dExtension() = default; char *Cocos2dExtension::_readFile(const spine::String &path, int *length) { - *length = 0; + *length = 0; Data data = FileUtils::getInstance()->getDataFromFile(FileUtils::getInstance()->fullPathForFilename(path.buffer())); - if (data.isNull()) return 0; + if (data.isNull()) return nullptr; - char *ret = (char *)malloc(sizeof(unsigned char) * data.getSize()); - memcpy(ret, (char *)data.getBytes(), data.getSize()); - *length = (int)data.getSize(); + char *ret = static_cast(malloc(sizeof(unsigned char) * data.getSize())); + memcpy(ret, reinterpret_cast(data.getBytes()), data.getSize()); + *length = static_cast(data.getSize()); return ret; } @@ -147,6 +147,6 @@ SpineExtension *spine::getDefaultExtension() { } void Cocos2dExtension::_free(void *mem, const char *file, int line) { - _spineObjectDisposeCallback(mem); + spineObjectDisposeCallback(mem); DefaultSpineExtension::_free(mem, file, line); } diff --git a/native/cocos/engine/Engine.cpp b/native/cocos/engine/Engine.cpp index f905f7bd2e..42f11210f6 100644 --- a/native/cocos/engine/Engine.cpp +++ b/native/cocos/engine/Engine.cpp @@ -25,10 +25,10 @@ #include "engine/Engine.h" #include -#include "base/AutoreleasePool.h" #include "base/Macros.h" +#include "base/DeferredReleasePool.h" #include "platform/BasePlatform.h" - +#include "platform/FileUtils.h" #include "cocos/bindings/jswrapper/SeApi.h" #include "cocos/renderer/GFXDeviceManager.h" #include "pipeline/RenderPipeline.h" @@ -144,7 +144,7 @@ void Engine::close() { // NOLINT auto* scriptEngine = se::ScriptEngine::getInstance(); - cc::PoolManager::getInstance()->getCurrentPool()->clear(); + cc::DeferredReleasePool::clear(); #if USE_AUDIO cc::AudioEngine::stopAll(); #endif @@ -218,10 +218,7 @@ void Engine::tick() { _scheduler->update(dt); cc::EventDispatcher::dispatchTickEvent(dt); - LegacyAutoreleasePool* currentPool = PoolManager::getInstance()->getCurrentPool(); - if (currentPool) { - currentPool->clear(); - } + cc::DeferredReleasePool::clear(); now = std::chrono::steady_clock::now(); dtNS = dtNS * 0.1 + 0.9 * static_cast(std::chrono::duration_cast(now - prevTime).count()); @@ -235,7 +232,7 @@ int32_t Engine::restartVM() { auto* scriptEngine = se::ScriptEngine::getInstance(); - cc::PoolManager::getInstance()->getCurrentPool()->clear(); + cc::DeferredReleasePool::clear(); #if USE_AUDIO cc::AudioEngine::stopAll(); #endif diff --git a/native/cocos/math/Color.cpp b/native/cocos/math/Color.cpp new file mode 100644 index 0000000000..5cc6466990 --- /dev/null +++ b/native/cocos/math/Color.cpp @@ -0,0 +1,100 @@ +/**************************************************************************** +Copyright (c) 2010-2012 cocos2d-x.org +Copyright (c) 2013-2016 Chukong Technologies Inc. +Copyright (c) 2017-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 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. +****************************************************************************/ + +#include "Color.h" + +namespace cc { + +Color::Color() +: r(0), + g(0), + b(0), + a(0) { +} + +Color::Color(uint8_t r, uint8_t g, uint8_t b, uint8_t a) +: r(r), + g(g), + b(b), + a(a) { +} + +Color::Color(const uint8_t *src) { + set(src); +} + +Color::Color(uint32_t val) { + set(val); +} + +Color::Color(const Color &p1, const Color &p2) { + set(p1, p2); +} + +Color::Color(const Color ©) { + set(copy); +} + +void Color::set(uint8_t r, uint8_t g, uint8_t b, uint8_t a) { + this->r = r; + this->g = g; + this->b = b; + this->a = a; +} + +void Color::set(const uint8_t *array) { + r = array[0]; + g = array[1]; + b = array[2]; + a = array[3]; +} + +void Color::set(uint32_t val) { + r = val & 0x000000FF; + g = (val & 0x0000FF00) >> 8; + b = (val & 0x00FF0000) >> 16; + a = (val & 0xFF000000) >> 24; +} + +void Color::set(const Color &c) { + this->r = c.r; + this->g = c.g; + this->b = c.b; + this->a = c.a; +} + +void Color::set(const Color &p1, const Color &p2) { + r = p2.r - p1.r; + g = p2.g - p1.g; + b = p2.b - p1.b; + a = p2.a - p1.a; +} + +Vec4 Color::toVec4() const { + return {static_cast(r) / 255.F, static_cast(g) / 255.F, static_cast(b) / 255.F, static_cast(a) / 255.F}; +} + +} // namespace cc diff --git a/native/cocos/math/Color.h b/native/cocos/math/Color.h new file mode 100644 index 0000000000..f09863154d --- /dev/null +++ b/native/cocos/math/Color.h @@ -0,0 +1,118 @@ +/**************************************************************************** +Copyright (c) 2010-2012 cocos2d-x.org +Copyright (c) 2013-2016 Chukong Technologies Inc. +Copyright (c) 2017-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 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. +****************************************************************************/ + +#pragma once + +#include + +#include "math/Vec4.h" + +namespace cc { + +class Color { +public: + uint8_t r; + uint8_t g; + uint8_t b; + uint8_t a; + /** + * Constructs a new color initialized to all zeros. + */ + Color(); + + /** + * Constructs a new color initialized to the specified values. + * + * @param xx The x coordinate. + * @param yy The y coordinate. + * @param zz The z coordinate. + * @param ww The w coordinate. + */ + explicit Color(uint8_t r, uint8_t g, uint8_t b, uint8_t a); + + /** + * Constructs a new color from the values in the specified array. + * + * @param array An array containing the elements of the color in the order r, g, b, a. + */ + explicit Color(const uint8_t *src); + + explicit Color(uint32_t val); + + /** + * Constructs a color that describes the direction between the specified points. + * + * @param p1 The first point. + * @param p2 The second point. + */ + Color(const Color &p1, const Color &p2); + + /** + * Constructor. + * + * Creates a new color that is a copy of the specified color. + * + * @param copy The color to copy. + */ + Color(const Color ©); + /** + * Sets the elements of this color to the specified values. + * + * @param xx The new x coordinate. + * @param yy The new y coordinate. + * @param zz The new z coordinate. + * @param ww The new w coordinate. + */ + void set(uint8_t r, uint8_t g, uint8_t b, uint8_t a); + + /** + * Sets the elements of this color from the values in the specified array. + * + * @param array An array containing the elements of the color in the order r, g, b, a. + */ + void set(const uint8_t *array); + + void set(uint32_t val); + + /** + * Sets the elements of this color to those in the specified color. + * + * @param v The color to copy. + */ + void set(const Color &c); + + /** + * Sets this color to the directional color between the specified points. + * + * @param p1 The first point. + * @param p2 The second point. + */ + void set(const Color &p1, const Color &p2); + + Vec4 toVec4() const; +}; + +} // namespace cc diff --git a/native/cocos/math/Mat3.cpp b/native/cocos/math/Mat3.cpp index a45174594f..55d5c853b0 100644 --- a/native/cocos/math/Mat3.cpp +++ b/native/cocos/math/Mat3.cpp @@ -1,7 +1,7 @@ /**************************************************************************** - Copyright (c) 2018 Xiamen Yaji Software Co., Ltd. + Copyright (c) 2018-2021 Xiamen Yaji Software Co., Ltd. - http://www.cocos2d-x.org + http://www.cocos.com Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal @@ -25,9 +25,10 @@ #include "math/Mat3.h" #include -#include "math/Quaternion.h" -#include "math/MathUtil.h" #include "base/Macros.h" +#include "math/Math.h" +#include "math/MathUtil.h" +#include "math/Quaternion.h" NS_CC_MATH_BEGIN @@ -48,9 +49,6 @@ Mat3::Mat3(const Mat3 ©) { memcpy(m, copy.m, MATRIX3_SIZE); } -Mat3::~Mat3() { -} - void Mat3::set(float m11, float m12, float m13, float m21, float m22, float m23, float m31, float m32, float m33) { m[0] = m11; m[1] = m21; @@ -84,32 +82,66 @@ void Mat3::identity(Mat3 &mat) { mat.m[8] = 1; } -void Mat3::transpose() { - float a01 = m[1], a02 = m[2], a12 = m[5]; - m[1] = m[3]; - m[2] = m[6]; - m[3] = a01; - m[5] = m[7]; - m[6] = a02; - m[7] = a12; +void Mat3::fromViewUp(const Vec3 &view, Mat3 *out) { + GP_ASSERT(out); + fromViewUp(view, Vec3(0, 1, 0), out); +} +void Mat3::fromViewUp(const Vec3 &view, const Vec3 &up, Mat3 *out) { + GP_ASSERT(out); + if (view.lengthSquared() < math::EPSILON * math::EPSILON) { + Mat3::identity(*out); + return; + } + Vec3 vTempA{Vec3::ZERO}; + Vec3 vTempB{Vec3::ZERO}; + + Vec3::cross(up, view, &vTempA); + vTempA.normalize(); + if (vTempA.lengthSquared() < math::EPSILON * math::EPSILON) { + Mat3::identity(*out); + return; + } + Vec3::cross(view, vTempA, &vTempB); + out->set(vTempA.x, vTempA.y, vTempA.z, + vTempB.x, vTempB.y, vTempB.z, + view.x, view.y, view.z); } -void Mat3::transpose(Mat3 &out, const Mat3 &mat) { - out.m[0] = mat.m[0]; - out.m[1] = mat.m[3]; - out.m[2] = mat.m[6]; - out.m[3] = mat.m[1]; - out.m[4] = mat.m[4]; - out.m[5] = mat.m[7]; - out.m[6] = mat.m[2]; - out.m[7] = mat.m[5]; - out.m[8] = mat.m[8]; +void Mat3::transpose() { + float a01 = m[1]; + float a02 = m[2]; + float a12 = m[5]; + m[1] = m[3]; + m[2] = m[6]; + m[3] = a01; + m[5] = m[7]; + m[6] = a02; + m[7] = a12; +} + +void Mat3::transpose(const Mat3 &mat, Mat3 *out) { + GP_ASSERT(out); + out->m[0] = mat.m[0]; + out->m[1] = mat.m[3]; + out->m[2] = mat.m[6]; + out->m[3] = mat.m[1]; + out->m[4] = mat.m[4]; + out->m[5] = mat.m[7]; + out->m[6] = mat.m[2]; + out->m[7] = mat.m[5]; + out->m[8] = mat.m[8]; } void Mat3::inverse() { - float a00 = m[0], a01 = m[1], a02 = m[2]; - float a10 = m[3], a11 = m[4], a12 = m[5]; - float a20 = m[6], a21 = m[7], a22 = m[8]; + float a00 = m[0]; + float a01 = m[1]; + float a02 = m[2]; + float a10 = m[3]; + float a11 = m[4]; + float a12 = m[5]; + float a20 = m[6]; + float a21 = m[7]; + float a22 = m[8]; float b01 = a22 * a11 - a12 * a21; float b11 = -a22 * a10 + a12 * a20; @@ -118,7 +150,7 @@ void Mat3::inverse() { // Calculate the determinant float det = a00 * b01 + a01 * b11 + a02 * b21; - det = 1.0f / det; + det = 1.0F / det; m[0] = b01 * det; m[1] = (-a22 * a01 + a02 * a21) * det; m[2] = (a12 * a01 - a02 * a11) * det; @@ -130,161 +162,206 @@ void Mat3::inverse() { m[8] = (a11 * a00 - a01 * a10) * det; } -void Mat3::adjoint(Mat3 &out, const Mat3 &mat) { - float a00 = mat.m[0], a01 = mat.m[1], a02 = mat.m[2]; - float a10 = mat.m[3], a11 = mat.m[4], a12 = mat.m[5]; - float a20 = mat.m[6], a21 = mat.m[7], a22 = mat.m[8]; +void Mat3::adjoint(const Mat3 &mat, Mat3 *out) { + GP_ASSERT(out); + float a00 = mat.m[0]; + float a01 = mat.m[1]; + float a02 = mat.m[2]; + float a10 = mat.m[3]; + float a11 = mat.m[4]; + float a12 = mat.m[5]; + float a20 = mat.m[6]; + float a21 = mat.m[7]; + float a22 = mat.m[8]; - out.m[0] = (a11 * a22 - a12 * a21); - out.m[1] = (a02 * a21 - a01 * a22); - out.m[2] = (a01 * a12 - a02 * a11); - out.m[3] = (a12 * a20 - a10 * a22); - out.m[4] = (a00 * a22 - a02 * a20); - out.m[5] = (a02 * a10 - a00 * a12); - out.m[6] = (a10 * a21 - a11 * a20); - out.m[7] = (a01 * a20 - a00 * a21); - out.m[8] = (a00 * a11 - a01 * a10); + out->m[0] = (a11 * a22 - a12 * a21); + out->m[1] = (a02 * a21 - a01 * a22); + out->m[2] = (a01 * a12 - a02 * a11); + out->m[3] = (a12 * a20 - a10 * a22); + out->m[4] = (a00 * a22 - a02 * a20); + out->m[5] = (a02 * a10 - a00 * a12); + out->m[6] = (a10 * a21 - a11 * a20); + out->m[7] = (a01 * a20 - a00 * a21); + out->m[8] = (a00 * a11 - a01 * a10); } float Mat3::determinant() { return m[0] * (m[8] * m[4] - m[5] * m[7]) + m[1] * (-m[8] * m[3] + m[5] * m[6]) + m[2] * (m[7] * m[3] - m[4] * m[6]); } -void Mat3::multiply(Mat3 &out, const Mat3 &a, const Mat3 &b) { - float a00 = a.m[0], a01 = a.m[1], a02 = a.m[2]; - float a10 = a.m[3], a11 = a.m[4], a12 = a.m[5]; - float a20 = a.m[6], a21 = a.m[7], a22 = a.m[8]; +void Mat3::multiply(const Mat3 &a, const Mat3 &b, Mat3 *out) { + GP_ASSERT(out); + float a00 = a.m[0]; + float a01 = a.m[1]; + float a02 = a.m[2]; + float a10 = a.m[3]; + float a11 = a.m[4]; + float a12 = a.m[5]; + float a20 = a.m[6]; + float a21 = a.m[7]; + float a22 = a.m[8]; - float b00 = b.m[0], b01 = b.m[1], b02 = b.m[2]; - float b10 = b.m[3], b11 = b.m[4], b12 = b.m[5]; - float b20 = b.m[6], b21 = b.m[7], b22 = b.m[8]; + float b00 = b.m[0]; + float b01 = b.m[1]; + float b02 = b.m[2]; + float b10 = b.m[3]; + float b11 = b.m[4]; + float b12 = b.m[5]; + float b20 = b.m[6]; + float b21 = b.m[7]; + float b22 = b.m[8]; - out.m[0] = b00 * a00 + b01 * a10 + b02 * a20; - out.m[1] = b00 * a01 + b01 * a11 + b02 * a21; - out.m[2] = b00 * a02 + b01 * a12 + b02 * a22; + out->m[0] = b00 * a00 + b01 * a10 + b02 * a20; + out->m[1] = b00 * a01 + b01 * a11 + b02 * a21; + out->m[2] = b00 * a02 + b01 * a12 + b02 * a22; - out.m[3] = b10 * a00 + b11 * a10 + b12 * a20; - out.m[4] = b10 * a01 + b11 * a11 + b12 * a21; - out.m[5] = b10 * a02 + b11 * a12 + b12 * a22; + out->m[3] = b10 * a00 + b11 * a10 + b12 * a20; + out->m[4] = b10 * a01 + b11 * a11 + b12 * a21; + out->m[5] = b10 * a02 + b11 * a12 + b12 * a22; - out.m[6] = b20 * a00 + b21 * a10 + b22 * a20; - out.m[7] = b20 * a01 + b21 * a11 + b22 * a21; - out.m[8] = b20 * a02 + b21 * a12 + b22 * a22; + out->m[6] = b20 * a00 + b21 * a10 + b22 * a20; + out->m[7] = b20 * a01 + b21 * a11 + b22 * a21; + out->m[8] = b20 * a02 + b21 * a12 + b22 * a22; } -void Mat3::translate(Mat3 &out, const Mat3 &mat, const Vec2 &vec) { - float a00 = mat.m[0], a01 = mat.m[1], a02 = mat.m[2]; - float a10 = mat.m[3], a11 = mat.m[4], a12 = mat.m[5]; - float a20 = mat.m[6], a21 = mat.m[7], a22 = mat.m[8]; - float x = vec.x, y = vec.y; +void Mat3::translate(const Mat3 &mat, const Vec2 &vec, Mat3 *out) { + GP_ASSERT(out); + float a00 = mat.m[0]; + float a01 = mat.m[1]; + float a02 = mat.m[2]; + float a10 = mat.m[3]; + float a11 = mat.m[4]; + float a12 = mat.m[5]; + float a20 = mat.m[6]; + float a21 = mat.m[7]; + float a22 = mat.m[8]; + float x = vec.x; + float y = vec.y; - out.m[0] = a00; - out.m[1] = a01; - out.m[2] = a02; + out->m[0] = a00; + out->m[1] = a01; + out->m[2] = a02; - out.m[3] = a10; - out.m[4] = a11; - out.m[5] = a12; + out->m[3] = a10; + out->m[4] = a11; + out->m[5] = a12; - out.m[6] = x * a00 + y * a10 + a20; - out.m[7] = x * a01 + y * a11 + a21; - out.m[8] = x * a02 + y * a12 + a22; + out->m[6] = x * a00 + y * a10 + a20; + out->m[7] = x * a01 + y * a11 + a21; + out->m[8] = x * a02 + y * a12 + a22; } -void Mat3::rotate(Mat3 &out, const Mat3 &mat, float rad) { - float a00 = mat.m[0], a01 = mat.m[1], a02 = mat.m[2]; - float a10 = mat.m[3], a11 = mat.m[4], a12 = mat.m[5]; - float a20 = mat.m[6], a21 = mat.m[7], a22 = mat.m[8]; +void Mat3::rotate(const Mat3 &mat, float rad, Mat3 *out) { + GP_ASSERT(out); + float a00 = mat.m[0]; + float a01 = mat.m[1]; + float a02 = mat.m[2]; + float a10 = mat.m[3]; + float a11 = mat.m[4]; + float a12 = mat.m[5]; + float a20 = mat.m[6]; + float a21 = mat.m[7]; + float a22 = mat.m[8]; float s = sin(rad); float c = cos(rad); - out.m[0] = c * a00 + s * a10; - out.m[1] = c * a01 + s * a11; - out.m[2] = c * a02 + s * a12; + out->m[0] = c * a00 + s * a10; + out->m[1] = c * a01 + s * a11; + out->m[2] = c * a02 + s * a12; - out.m[3] = c * a10 - s * a00; - out.m[4] = c * a11 - s * a01; - out.m[5] = c * a12 - s * a02; + out->m[3] = c * a10 - s * a00; + out->m[4] = c * a11 - s * a01; + out->m[5] = c * a12 - s * a02; - out.m[6] = a20; - out.m[7] = a21; - out.m[8] = a22; + out->m[6] = a20; + out->m[7] = a21; + out->m[8] = a22; } -void Mat3::scale(Mat3 &out, const Mat3 &mat, const Vec2 &vec) { - float x = vec.x, y = vec.y; +void Mat3::scale(const Mat3 &mat, const Vec2 &vec, Mat3 *out) { + GP_ASSERT(out); + float x = vec.x; + float y = vec.y; - out.m[0] = x * mat.m[0]; - out.m[1] = x * mat.m[1]; - out.m[2] = x * mat.m[2]; + out->m[0] = x * mat.m[0]; + out->m[1] = x * mat.m[1]; + out->m[2] = x * mat.m[2]; - out.m[3] = y * mat.m[3]; - out.m[4] = y * mat.m[4]; - out.m[5] = y * mat.m[5]; + out->m[3] = y * mat.m[3]; + out->m[4] = y * mat.m[4]; + out->m[5] = y * mat.m[5]; - out.m[6] = mat.m[6]; - out.m[7] = mat.m[7]; - out.m[8] = mat.m[8]; + out->m[6] = mat.m[6]; + out->m[7] = mat.m[7]; + out->m[8] = mat.m[8]; } -void Mat3::fromMat4(Mat3 &out, const Mat4 &mat) { - out.m[0] = mat.m[0]; - out.m[1] = mat.m[1]; - out.m[2] = mat.m[2]; - out.m[3] = mat.m[4]; - out.m[4] = mat.m[5]; - out.m[5] = mat.m[6]; - out.m[6] = mat.m[8]; - out.m[7] = mat.m[9]; - out.m[8] = mat.m[10]; +void Mat3::fromMat4(const Mat4 &mat, Mat3 *out) { + GP_ASSERT(out); + out->m[0] = mat.m[0]; + out->m[1] = mat.m[1]; + out->m[2] = mat.m[2]; + out->m[3] = mat.m[4]; + out->m[4] = mat.m[5]; + out->m[5] = mat.m[6]; + out->m[6] = mat.m[8]; + out->m[7] = mat.m[9]; + out->m[8] = mat.m[10]; } -void Mat3::fromTranslation(Mat3 &out, const Vec2 &vec) { - out.m[0] = 1; - out.m[1] = 0; - out.m[2] = 0; - out.m[3] = 0; - out.m[4] = 1; - out.m[5] = 0; - out.m[6] = vec.x; - out.m[7] = vec.y; - out.m[8] = 1; +void Mat3::fromTranslation(const Vec2 &vec, Mat3 *out) { + GP_ASSERT(out); + out->m[0] = 1; + out->m[1] = 0; + out->m[2] = 0; + out->m[3] = 0; + out->m[4] = 1; + out->m[5] = 0; + out->m[6] = vec.x; + out->m[7] = vec.y; + out->m[8] = 1; } -void Mat3::fromRotation(Mat3 &out, float rad) { +void Mat3::fromRotation(float rad, Mat3 *out) { + GP_ASSERT(out); float s = sin(rad); float c = cos(rad); - out.m[0] = c; - out.m[1] = s; - out.m[2] = 0; + out->m[0] = c; + out->m[1] = s; + out->m[2] = 0; - out.m[3] = -s; - out.m[4] = c; - out.m[5] = 0; + out->m[3] = -s; + out->m[4] = c; + out->m[5] = 0; - out.m[6] = 0; - out.m[7] = 0; - out.m[8] = 1; + out->m[6] = 0; + out->m[7] = 0; + out->m[8] = 1; } -void Mat3::fromScaling(Mat3 &out, const Vec2 &vec) { - out.m[0] = vec.x; - out.m[1] = 0; - out.m[2] = 0; +void Mat3::fromScaling(const Vec2 &vec, Mat3 *out) { + GP_ASSERT(out); + out->m[0] = vec.x; + out->m[1] = 0; + out->m[2] = 0; - out.m[3] = 0; - out.m[4] = vec.y; - out.m[5] = 0; + out->m[3] = 0; + out->m[4] = vec.y; + out->m[5] = 0; - out.m[6] = 0; - out.m[7] = 0; - out.m[8] = 1; + out->m[6] = 0; + out->m[7] = 0; + out->m[8] = 1; } -void Mat3::fromQuat(Mat3 &out, const Quaternion &quat) { - float x = quat.x, y = quat.y, z = quat.z, w = quat.w; +void Mat3::fromQuat(const Quaternion &quat, Mat3 *out) { + GP_ASSERT(out); + float x = quat.x; + float y = quat.y; + float z = quat.z; + float w = quat.w; float x2 = x + x; float y2 = y + y; float z2 = z + z; @@ -299,47 +376,49 @@ void Mat3::fromQuat(Mat3 &out, const Quaternion &quat) { float wy = w * y2; float wz = w * z2; - out.m[0] = 1 - yy - zz; - out.m[3] = yx - wz; - out.m[6] = zx + wy; + out->m[0] = 1 - yy - zz; + out->m[3] = yx - wz; + out->m[6] = zx + wy; - out.m[1] = yx + wz; - out.m[4] = 1 - xx - zz; - out.m[7] = zy - wx; + out->m[1] = yx + wz; + out->m[4] = 1 - xx - zz; + out->m[7] = zy - wx; - out.m[2] = zx - wy; - out.m[5] = zy + wx; - out.m[8] = 1 - xx - yy; + out->m[2] = zx - wy; + out->m[5] = zy + wx; + out->m[8] = 1 - xx - yy; } -void Mat3::add(Mat3 &out, const Mat3 &a, const Mat3 &b) { - out.m[0] = a.m[0] + b.m[0]; - out.m[1] = a.m[1] + b.m[1]; - out.m[2] = a.m[2] + b.m[2]; - out.m[3] = a.m[3] + b.m[3]; - out.m[4] = a.m[4] + b.m[4]; - out.m[5] = a.m[5] + b.m[5]; - out.m[6] = a.m[6] + b.m[6]; - out.m[7] = a.m[7] + b.m[7]; - out.m[8] = a.m[8] + b.m[8]; +void Mat3::add(const Mat3 &a, const Mat3 &b, Mat3 *out) { + GP_ASSERT(out); + out->m[0] = a.m[0] + b.m[0]; + out->m[1] = a.m[1] + b.m[1]; + out->m[2] = a.m[2] + b.m[2]; + out->m[3] = a.m[3] + b.m[3]; + out->m[4] = a.m[4] + b.m[4]; + out->m[5] = a.m[5] + b.m[5]; + out->m[6] = a.m[6] + b.m[6]; + out->m[7] = a.m[7] + b.m[7]; + out->m[8] = a.m[8] + b.m[8]; } -void Mat3::subtract(Mat3 &out, const Mat3 &a, const Mat3 &b) { - out.m[0] = a.m[0] - b.m[0]; - out.m[1] = a.m[1] - b.m[1]; - out.m[2] = a.m[2] - b.m[2]; - out.m[3] = a.m[3] - b.m[3]; - out.m[4] = a.m[4] - b.m[4]; - out.m[5] = a.m[5] - b.m[5]; - out.m[6] = a.m[6] - b.m[6]; - out.m[7] = a.m[7] - b.m[7]; - out.m[8] = a.m[8] - b.m[8]; +void Mat3::subtract(const Mat3 &a, const Mat3 &b, Mat3 *out) { + GP_ASSERT(out); + out->m[0] = a.m[0] - b.m[0]; + out->m[1] = a.m[1] - b.m[1]; + out->m[2] = a.m[2] - b.m[2]; + out->m[3] = a.m[3] - b.m[3]; + out->m[4] = a.m[4] - b.m[4]; + out->m[5] = a.m[5] - b.m[5]; + out->m[6] = a.m[6] - b.m[6]; + out->m[7] = a.m[7] - b.m[7]; + out->m[8] = a.m[8] - b.m[8]; } const Mat3 Mat3::IDENTITY = Mat3( - 1.0f, 0.0f, 0.0f, - 0.0f, 1.0f, 0.0f, - 0.0f, 0.0f, 1.0f); + 1.F, 0.F, 0.F, + 0.F, 1.F, 0.F, + 0.F, 0.F, 1.F); const Mat3 Mat3::ZERO = Mat3( 0, 0, 0, diff --git a/native/cocos/math/Mat3.h b/native/cocos/math/Mat3.h index 859896ead4..7cd900ceec 100644 --- a/native/cocos/math/Mat3.h +++ b/native/cocos/math/Mat3.h @@ -1,7 +1,7 @@ /**************************************************************************** - Copyright (c) 2018 Xiamen Yaji Software Co., Ltd. + Copyright (c) 2018-2021 Xiamen Yaji Software Co., Ltd. - http://www.cocos2d-x.org + http://www.cocos.com Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal @@ -29,10 +29,10 @@ #include "base/Macros.h" +#include "math/Mat4.h" #include "math/Vec2.h" #include "math/Vec3.h" #include "math/Vec4.h" -#include "math/Mat4.h" /** * @addtogroup base @@ -84,7 +84,7 @@ public: * * @param mat An array containing 16 elements in column-major order. */ - Mat3(const float *mat); + explicit Mat3(const float *mat); /** * Constructs a new matrix by copying the values from the specified matrix. @@ -96,7 +96,7 @@ public: /** * Destructor. */ - ~Mat3(); + ~Mat3() = default; /** * Sets the values of this matrix. @@ -141,7 +141,7 @@ public: /** * Transposes a matrix. */ - static void transpose(Mat3 &out, const Mat3 &mat); + static void transpose(const Mat3 &mat, Mat3 *out); /** * Inverts a matrix. @@ -151,7 +151,7 @@ public: /** * Calculates the adjugate of a matrix. */ - static void adjoint(Mat3 &out, const Mat3 &mat); + static void adjoint(const Mat3 &mat, Mat3 *out); /** * Calculates the determinant of a matrix. @@ -161,58 +161,64 @@ public: /** * Multiply two matrices explicitly. */ - static void multiply(Mat3 &out, const Mat3 &a, const Mat3 &b); + static void multiply(const Mat3 &a, const Mat3 &b, Mat3 *out); /** * Multiply a matrix with a translation matrix given by a translation offset. */ - static void translate(Mat3 &out, const Mat3 &mat, const Vec2 &vec); + static void translate(const Mat3 &mat, const Vec2 &vec, Mat3 *out); /** * Rotates a matrix by the given angle. */ - static void rotate(Mat3 &out, const Mat3 &mat, float rad); + static void rotate(const Mat3 &mat, float rad, Mat3 *out); /** * Multiply a matrix with a scale matrix given by a scale vector. */ - static void scale(Mat3 &out, const Mat3 &mat, const Vec2 &vec); + static void scale(const Mat3 &mat, const Vec2 &vec, Mat3 *out); /** * Copies the upper-left 3x3 values of a 4x4 matrix into a 3x3 matrix. */ - static void fromMat4(Mat3 &out, const Mat4 &mat); + static void fromMat4(const Mat4 &mat, Mat3 *out); /** * Creates a matrix from a translation offset. */ - static void fromTranslation(Mat3 &out, const Vec2 &vec); + static void fromTranslation(const Vec2 &vec, Mat3 *out); /** * Creates a matrix from a given angle. */ - static void fromRotation(Mat3 &out, float rad); + static void fromRotation(float rad, Mat3 *out); /** * Creates a matrix from a scale vector. */ - static void fromScaling(Mat3 &out, const Vec2 &vec); + static void fromScaling(const Vec2 &vec, Mat3 *out); + + /** + * Sets a third order matrix with view direction and up direction. Then save the results to out matrix + */ + static void fromViewUp(const Vec3 &view, Mat3 *out); + static void fromViewUp(const Vec3 &view, const Vec3 &up, Mat3 *out); /** * Calculates a 3x3 matrix from the given quaternion. */ - static void fromQuat(Mat3 &out, const Quaternion &quat); + static void fromQuat(const Quaternion &quat, Mat3 *out); /** * Adds two matrices. */ - static void add(Mat3 &out, const Mat3 &a, const Mat3 &b); + static void add(const Mat3 &a, const Mat3 &b, Mat3 *out); /** * Subtracts matrix b from matrix a. */ - static void subtract(Mat3 &out, const Mat3 &a, const Mat3 &b); + static void subtract(const Mat3 &a, const Mat3 &b, Mat3 *out); /** equals to a matrix full of zeros */ static const Mat3 ZERO; diff --git a/native/cocos/math/Mat4.cpp b/native/cocos/math/Mat4.cpp index d11bed70fb..3a6eae5cfe 100644 --- a/native/cocos/math/Mat4.cpp +++ b/native/cocos/math/Mat4.cpp @@ -1,7 +1,7 @@ /** Copyright 2013 BlackBerry Inc. Copyright (c) 2013-2016 Chukong Technologies Inc. - Copyright (c) 2017-2018 Xiamen Yaji Software Co., Ltd. + Copyright (c) 2017-2021 Xiamen Yaji Software Co., Ltd. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -22,6 +22,7 @@ #include "math/Mat4.h" +#include #include #include "base/Log.h" #include "math/MathUtil.h" @@ -29,6 +30,17 @@ NS_CC_MATH_BEGIN +namespace { + +const std::array, 4> PRE_TRANSFORMS = {{ + {{1, 0, 0, 1}}, // SurfaceTransform.IDENTITY + {{0, 1, -1, 0}}, // SurfaceTransform.ROTATE_90 + {{-1, 0, 0, -1}}, // SurfaceTransform.ROTATE_180 + {{0, -1, 1, 0}} // SurfaceTransform.ROTATE_270 +}}; + +} + Mat4::Mat4() { // As JS defautl mat4 is zero, so change it to zero. *this = IDENTITY; @@ -95,22 +107,19 @@ void Mat4::createLookAt(float eyePositionX, float eyePositionY, float eyePositio dst->m[15] = 1.0F; } -void Mat4::createPerspective(float fieldOfView, float aspectRatio, - float zNearPlane, float zFarPlane, Mat4 *dst) { +void Mat4::createPerspective(float fieldOfView, float aspectRatio, float zNearPlane, float zFarPlane, + bool isFieldOfViewY, float minClipZ, float projectionSignY, int orientation, Mat4 *dst) { GP_ASSERT(dst); GP_ASSERT(zFarPlane != zNearPlane); - GP_ASSERT(fieldOfView != 0.0F); - - const float minClipZ = -1.0F; - const float projectionSignY = 1.0F; + GP_ASSERT(fieldOfView != 0.0f); const float f = 1.0F / tanf(fieldOfView / 2.0F); const float nf = 1.0F / (zNearPlane - zFarPlane); - const float x = f / aspectRatio; - const float y = f * projectionSignY; + const float x = isFieldOfViewY ? f / aspectRatio : f; + const float y = (isFieldOfViewY ? f : f * aspectRatio) * projectionSignY; - float const preTransform[] = {1.0, 0.0F, 0.0F, 1.0F}; + const std::array &preTransform = PRE_TRANSFORMS[orientation]; dst->m[0] = x * preTransform[0]; dst->m[1] = x * preTransform[1]; @@ -136,23 +145,41 @@ void Mat4::createOrthographic(float left, float right, float bottom, float top, void Mat4::createOrthographicOffCenter(float left, float right, float bottom, float top, float zNearPlane, float zFarPlane, Mat4 *dst) { - createOrthographicOffCenter(left, right, bottom, top, zNearPlane, zFarPlane, -1.0F, 1.0F, dst); + createOrthographicOffCenter(left, right, bottom, top, zNearPlane, zFarPlane, -1.0F, 1.0F, 0, dst); } -void Mat4::createOrthographicOffCenter(float left, float right, float bottom, float top, float zNearPlane, float zFarPlane, float minClipZ, float projectionSignY, Mat4 *dst) { +void Mat4::createOrthographicOffCenter(float left, float right, float bottom, float top, float zNearPlane, float zFarPlane, float minClipZ, float projectionSignY, int orientation, Mat4 *dst) { GP_ASSERT(dst); GP_ASSERT(right != left); GP_ASSERT(top != bottom); GP_ASSERT(zFarPlane != zNearPlane); - memset(dst->m, 0, MATRIX_SIZE); - dst->m[0] = 2.0F / (right - left); - dst->m[5] = 2.0F / (top - bottom) * projectionSignY; - dst->m[10] = (1.0F - minClipZ) / (zNearPlane - zFarPlane); - dst->m[12] = (left + right) / (left - right); - dst->m[13] = (top + bottom) / (bottom - top); - dst->m[14] = (zNearPlane - minClipZ * zFarPlane) / (zNearPlane - zFarPlane); - dst->m[15] = 1.0F; + const std::array &preTransform = PRE_TRANSFORMS[orientation]; + const float lr = 1.F / (left - right); + const float bt = 1.F / (bottom - top) * projectionSignY; + const float nf = 1.F / (zNearPlane - zFarPlane); + + const float x = -2 * lr; + const float y = -2 * bt; + const float dx = (left + right) * lr; + const float dy = (top + bottom) * bt; + + dst->m[0] = x * preTransform[0]; + dst->m[1] = x * preTransform[1]; + dst->m[2] = 0; + dst->m[3] = 0; + dst->m[4] = y * preTransform[2]; + dst->m[5] = y * preTransform[3]; + dst->m[6] = 0; + dst->m[7] = 0; + dst->m[8] = 0; + dst->m[9] = 0; + dst->m[10] = nf * (1 - minClipZ); + dst->m[11] = 0; + dst->m[12] = dx * preTransform[0] + dy * preTransform[2]; + dst->m[13] = dx * preTransform[1] + dy * preTransform[3]; + dst->m[14] = (zNearPlane - minClipZ * zFarPlane) * nf; + dst->m[15] = 1.F; } void Mat4::createBillboard(const Vec3 &objectPosition, const Vec3 &cameraPosition, @@ -455,7 +482,7 @@ void Mat4::fromRT(const Quaternion &rotation, const Vec3 &translation, Mat4 *dst dst->m[15] = 1; } -void Mat4::fromRTS(const Quaternion& rotation, const Vec3& translation, const Vec3& scale, Mat4* dst) { +void Mat4::fromRTS(const Quaternion &rotation, const Vec3 &translation, const Vec3 &scale, Mat4 *dst) { const float x = rotation.x; const float y = rotation.y; const float z = rotation.z; @@ -477,16 +504,16 @@ void Mat4::fromRTS(const Quaternion& rotation, const Vec3& translation, const Ve const float sy = scale.y; const float sz = scale.z; - dst->m[0] = (1 - (yy + zz)) * sx; - dst->m[1] = (xy + wz) * sx; - dst->m[2] = (xz - wy) * sx; - dst->m[3] = 0; - dst->m[4] = (xy - wz) * sy; - dst->m[5] = (1 - (xx + zz)) * sy; - dst->m[6] = (yz + wx) * sy; - dst->m[7] = 0; - dst->m[8] = (xz + wy) * sz; - dst->m[9] = (yz - wx) * sz; + dst->m[0] = (1 - (yy + zz)) * sx; + dst->m[1] = (xy + wz) * sx; + dst->m[2] = (xz - wy) * sx; + dst->m[3] = 0; + dst->m[4] = (xy - wz) * sy; + dst->m[5] = (1 - (xx + zz)) * sy; + dst->m[6] = (yz + wx) * sy; + dst->m[7] = 0; + dst->m[8] = (xz + wy) * sz; + dst->m[9] = (yz - wx) * sz; dst->m[10] = (1 - (xx + yy)) * sz; dst->m[11] = 0; dst->m[12] = translation.x; @@ -495,6 +522,13 @@ void Mat4::fromRTS(const Quaternion& rotation, const Vec3& translation, const Ve dst->m[15] = 1; } +void Mat4::toRTS(Quaternion &rotation, Vec3 &translation, Vec3 &scale, Mat4 *dst) { + if (dst == nullptr) { + return; + } + dst->decompose(&scale, &rotation, &translation); +} + bool Mat4::decompose(Vec3 *scale, Quaternion *rotation, Vec3 *translation) const { if (translation) { // Extract the translation. @@ -614,11 +648,23 @@ float Mat4::determinant() const { return (a0 * b5 - a1 * b4 + a2 * b3 + a3 * b2 - a4 * b1 + a5 * b0); } -void Mat4::inverseTranspose(const Mat4& mat, Mat4 *dst) { - float a00 = mat.m[0]; float a01 = mat.m[1]; float a02 = mat.m[2]; float a03 = mat.m[3]; - float a10 = mat.m[4]; float a11 = mat.m[5]; float a12 = mat.m[6]; float a13 = mat.m[7]; - float a20 = mat.m[8]; float a21 = mat.m[9]; float a22 = mat.m[10]; float a23 = mat.m[11]; - float a30 = mat.m[12]; float a31 = mat.m[13]; float a32 = mat.m[14]; float a33 = mat.m[15]; +void Mat4::inverseTranspose(const Mat4 &mat, Mat4 *dst) { + float a00 = mat.m[0]; + float a01 = mat.m[1]; + float a02 = mat.m[2]; + float a03 = mat.m[3]; + float a10 = mat.m[4]; + float a11 = mat.m[5]; + float a12 = mat.m[6]; + float a13 = mat.m[7]; + float a20 = mat.m[8]; + float a21 = mat.m[9]; + float a22 = mat.m[10]; + float a23 = mat.m[11]; + float a30 = mat.m[12]; + float a31 = mat.m[13]; + float a32 = mat.m[14]; + float a33 = mat.m[15]; float b00 = a00 * a11 - a01 * a10; float b01 = a00 * a12 - a02 * a10; @@ -651,8 +697,8 @@ void Mat4::inverseTranspose(const Mat4& mat, Mat4 *dst) { dst->m[6] = (a01 * b08 - a00 * b10 - a03 * b06) * det; dst->m[7] = 0; - dst->m[8] = (a31 * b05 - a32 * b04 + a33 * b03) * det; - dst->m[9] = (a32 * b02 - a30 * b05 - a33 * b01) * det; + dst->m[8] = (a31 * b05 - a32 * b04 + a33 * b03) * det; + dst->m[9] = (a32 * b02 - a30 * b05 - a33 * b01) * det; dst->m[10] = (a30 * b04 - a31 * b02 + a33 * b00) * det; dst->m[11] = 0; diff --git a/native/cocos/math/Mat4.h b/native/cocos/math/Mat4.h index e9a2147691..455fe9d7b0 100644 --- a/native/cocos/math/Mat4.h +++ b/native/cocos/math/Mat4.h @@ -201,7 +201,13 @@ public: * @param zFarPlane The distance to the far view plane. * @param dst A matrix to store the result in. */ - static void createPerspective(float fieldOfView, float aspectRatio, float zNearPlane, float zFarPlane, Mat4 *dst); + static void createPerspective(float fieldOfView, float aspectRatio, float zNearPlane, float zFarPlane, Mat4 *dst = nullptr) { + Mat4::createPerspective(fieldOfView, aspectRatio, zNearPlane, zFarPlane, true, -1.0F, 1.0F, 0, dst); + } + + static void createPerspective(float fieldOfView, float aspectRatio, float zNearPlane, float zFarPlane, + bool isFieldOfViewY = false, float minClipZ = -1, float projectionSignY = 1, + int orientation = 0, Mat4 *dst = nullptr); /** * Creates an orthographic projection matrix. @@ -245,7 +251,8 @@ public: static void createOrthographicOffCenter(float left, float right, float bottom, float top, float zNearPlane, float zFarPlane, Mat4 *dst); static void createOrthographicOffCenter(float left, float right, float bottom, float top, - float zNearPlane, float zFarPlane, float minClipZ, float projectionSignY, Mat4 *dst); + float zNearPlane, float zFarPlane, float minClipZ, + float projectionSignY, int orientation, Mat4 *dst); /** * Creates a spherical billboard that rotates around a specified object position. @@ -407,6 +414,11 @@ public: */ static void fromRTS(const Quaternion &rotation, const Vec3 &translation, const Vec3 &scale, Mat4 *dst); + /** + * Decomposes the scale, rotation and translation components of this matrix. + */ + static void toRTS(Quaternion &rotation, Vec3 &translation, Vec3 &scale, Mat4 *dst); + /** * Decomposes the scale, rotation and translation components of this matrix. * @@ -897,7 +909,7 @@ public: /** * Calculates the inverse transpose of a matrix and save the results to out matrix */ - static void inverseTranspose(const Mat4& mat, Mat4 *dst); + static void inverseTranspose(const Mat4 &mat, Mat4 *dst); /** * Calculates the sum of this matrix with the given matrix. * diff --git a/native/cocos/math/MathBase.h b/native/cocos/math/MathBase.h index 073aa022d2..fb6c1faeb4 100644 --- a/native/cocos/math/MathBase.h +++ b/native/cocos/math/MathBase.h @@ -1,5 +1,5 @@ /**************************************************************************** - Copyright (c) 2017-2018 Xiamen Yaji Software Co., Ltd. + Copyright (c) 2017-2021 Xiamen Yaji Software Co., Ltd. http://www.cocos.com @@ -27,7 +27,7 @@ #define __CCMATHBASE_H__ #include -#include +#include #include "base/Macros.h" /** * @addtogroup base @@ -72,11 +72,11 @@ NS_CC_MATH_BEGIN template ::value>> -struct Hasher final { size_t operator()(const T& info) const; }; +struct Hasher final { size_t operator()(const T &info) const; }; // make this boost::hash compatible template ::value>> -size_t hash_value(const T& info) { return Hasher()(info); } // NOLINT(readability-identifier-naming) +size_t hash_value(const T &info) { return Hasher()(info); } // NOLINT(readability-identifier-naming) NS_CC_MATH_END diff --git a/native/cocos/math/Quaternion.cpp b/native/cocos/math/Quaternion.cpp index 01ec462a6d..1efaac1a58 100644 --- a/native/cocos/math/Quaternion.cpp +++ b/native/cocos/math/Quaternion.cpp @@ -1,7 +1,7 @@ /** Copyright 2013 BlackBerry Inc. Copyright (c) 2013-2016 Chukong Technologies Inc. - Copyright (c) 2017-2018 Xiamen Yaji Software Co., Ltd. + Copyright (c) 2017-2021 Xiamen Yaji Software Co., Ltd. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -24,17 +24,13 @@ #include #include "base/Macros.h" +#include "math/Mat3.h" +#include "math/Math.h" +#include "math/Utils.h" NS_CC_MATH_BEGIN -const Quaternion Quaternion::ZERO(0.0f, 0.0f, 0.0f, 0.0f); - -Quaternion::Quaternion() -: x(0.0f), - y(0.0f), - z(0.0f), - w(1.0f) { -} +const Quaternion Quaternion::ZERO(0.F, 0.F, 0.F, 0.F); Quaternion::Quaternion(float xx, float yy, float zz, float ww) : x(xx), @@ -55,29 +51,22 @@ Quaternion::Quaternion(const Vec3 &axis, float angle) { set(axis, angle); } -Quaternion::Quaternion(const Quaternion ©) { - set(copy); -} - -Quaternion::~Quaternion() { -} - const Quaternion &Quaternion::identity() { - static Quaternion value(0.0f, 0.0f, 0.0f, 1.0f); + static Quaternion value(0.F, 0.F, 0.F, 1.F); return value; } const Quaternion &Quaternion::zero() { - static Quaternion value(0.0f, 0.0f, 0.0f, 0.0f); + static Quaternion value(0.F, 0.F, 0.F, 0.F); return value; } bool Quaternion::isIdentity() const { - return x == 0.0f && y == 0.0f && z == 0.0f && w == 1.0f; + return x == 0.F && y == 0.F && z == 0.F && w == 1.F; } bool Quaternion::isZero() const { - return x == 0.0f && y == 0.0f && z == 0.0f && w == 0.0f; + return x == 0.F && y == 0.F && z == 0.F && w == 0.F; } void Quaternion::createFromRotationMatrix(const Mat4 &m, Quaternion *dst) { @@ -87,7 +76,7 @@ void Quaternion::createFromRotationMatrix(const Mat4 &m, Quaternion *dst) { void Quaternion::createFromAxisAngle(const Vec3 &axis, float angle, Quaternion *dst) { GP_ASSERT(dst); - float halfAngle = angle * 0.5f; + float halfAngle = angle * 0.5F; float sinHalfAngle = sinf(halfAngle); Vec3 normal(axis); @@ -98,6 +87,15 @@ void Quaternion::createFromAxisAngle(const Vec3 &axis, float angle, Quaternion * dst->w = cosf(halfAngle); } +void Quaternion::createFromAngleZ(float z, Quaternion *dst) { + GP_ASSERT(dst); + + z *= mathutils::HALF_TO_RAD; + dst->x = dst->y = 0.F; + dst->z = sinf(z); + dst->w = cosf(z); +} + void Quaternion::conjugate() { x = -x; y = -y; @@ -113,7 +111,7 @@ Quaternion Quaternion::getConjugated() const { bool Quaternion::inverse() { float n = x * x + y * y + z * z + w * w; - if (n == 1.0f) { + if (n == 1.F) { x = -x; y = -y; z = -z; @@ -123,10 +121,11 @@ bool Quaternion::inverse() { } // Too close to zero. - if (n < 0.000001f) + if (n < 0.000001F) { return false; + } - n = 1.0f / n; + n = 1.F / n; x = -x * n; y = -y * n; z = -z * n; @@ -163,15 +162,17 @@ void Quaternion::normalize() { float n = x * x + y * y + z * z + w * w; // Already normalized. - if (n == 1.0f) + if (n == 1.F) { return; + } n = std::sqrt(n); // Too close to zero. - if (n < 0.000001f) + if (n < 0.000001F) { return; + } - n = 1.0f / n; + n = 1.F / n; x *= n; y *= n; z *= n; @@ -191,9 +192,8 @@ void Quaternion::set(float xx, float yy, float zz, float ww) { this->w = ww; } -void Quaternion::set(float *array) { +void Quaternion::set(const float *array) { GP_ASSERT(array); - x = array[0]; y = array[1]; z = array[2]; @@ -216,10 +216,10 @@ void Quaternion::set(const Quaternion &q) { } void Quaternion::setIdentity() { - x = 0.0f; - y = 0.0f; - z = 0.0f; - w = 1.0f; + x = 0.F; + y = 0.F; + z = 0.F; + w = 1.F; } float Quaternion::toAxisAngle(Vec3 *axis) const { @@ -232,22 +232,23 @@ float Quaternion::toAxisAngle(Vec3 *axis) const { axis->z = q.z; axis->normalize(); - return (2.0f * std::acos(q.w)); + return (2.F * std::acos(q.w)); } void Quaternion::lerp(const Quaternion &q1, const Quaternion &q2, float t, Quaternion *dst) { GP_ASSERT(dst); - GP_ASSERT(!(t < 0.0f || t > 1.0f)); + GP_ASSERT(!(t < 0.F || t > 1.F)); - if (t == 0.0f) { + if (t == 0.F) { memcpy(dst, &q1, sizeof(float) * 4); return; - } else if (t == 1.0f) { + } + if (t == 1.F) { memcpy(dst, &q2, sizeof(float) * 4); return; } - float t1 = 1.0f - t; + float t1 = 1.F - t; dst->x = t1 * q1.x + t * q2.x; dst->y = t1 * q1.y + t * q2.y; @@ -261,14 +262,124 @@ void Quaternion::slerp(const Quaternion &q1, const Quaternion &q2, float t, Quat } void Quaternion::squad(const Quaternion &q1, const Quaternion &q2, const Quaternion &s1, const Quaternion &s2, float t, Quaternion *dst) { - GP_ASSERT(!(t < 0.0f || t > 1.0f)); + GP_ASSERT(!(t < 0.F || t > 1.F)); - Quaternion dstQ(0.0f, 0.0f, 0.0f, 1.0f); - Quaternion dstS(0.0f, 0.0f, 0.0f, 1.0f); + Quaternion dstQ(0.F, 0.F, 0.F, 1.F); + Quaternion dstS(0.F, 0.F, 0.F, 1.F); slerpForSquad(q1, q2, t, &dstQ); slerpForSquad(s1, s2, t, &dstS); - slerpForSquad(dstQ, dstS, 2.0f * t * (1.0f - t), dst); + slerpForSquad(dstQ, dstS, 2.F * t * (1.F - t), dst); +} + +void Quaternion::fromViewUp(const Vec3 &view, Quaternion *out) { + GP_ASSERT(out); + fromViewUp(view, Vec3(0, 1, 0), out); +} +void Quaternion::fromViewUp(const Vec3 &view, const Vec3 &up, Quaternion *out) { + GP_ASSERT(out); + Mat3 mTemp{Mat3::IDENTITY}; + Mat3::fromViewUp(view, up, &mTemp); + Quaternion::fromMat3(mTemp, out); + out->normalize(); +} + +void Quaternion::fromEuler(float x, float y, float z, Quaternion *dst) { + GP_ASSERT(dst); + float halfToRad = 0.5F * cc::math::PI / 180.F; + x *= halfToRad; + y *= halfToRad; + z *= halfToRad; + float sx = std::sin(x); + float cx = std::cos(x); + float sy = std::sin(y); + float cy = std::cos(y); + float sz = std::sin(z); + float cz = std::cos(z); + + dst->x = sx * cy * cz + cx * sy * sz; + dst->y = cx * sy * cz + sx * cy * sz; + dst->z = cx * cy * sz - sx * sy * cz; + dst->w = cx * cy * cz - sx * sy * sz; +} + +void Quaternion::toEuler(const Quaternion &q, bool outerZ, Vec3 *out) { + GP_ASSERT(out); + float x{q.x}; + float y{q.y}; + float z{q.z}; + float w{q.w}; + float bank{0}; + float heading{0}; + float attitude{0}; + float test = x * y + z * w; + float r2d = 180.F / math::PI; + if (test > 0.499999) { + bank = 0; + heading = -2 * atan2(x, w) * r2d; + attitude = 90; + } else if (test < -0.499999) { + bank = 0; + heading = -2 * atan2(x, w) * r2d; + attitude = -90; + } else { + float sqx = x * x; + float sqy = y * y; + float sqz = z * z; + bank = atan2(2 * x * w - 2 * y * z, 1 - 2 * sqx - 2 * sqz) * r2d; + heading = atan2(2 * y * w - 2 * x * z, 1 - 2 * sqy - 2 * sqz) * r2d; + attitude = asin(2 * test) * r2d; + if (outerZ) { + bank = static_cast(-180.F * math::Sgn(bank + 1e-6) + bank); + heading = static_cast(-180.F * math::Sgn(heading + 1e-6) + heading); + attitude = static_cast(180.F * math::Sgn(attitude + 1e-6) - attitude); + } + } + out->x = bank; + out->y = heading; + out->z = attitude; +} + +void Quaternion::fromMat3(const Mat3 &m, Quaternion *out) { + GP_ASSERT(out); + float m00 = m.m[0]; + float m03 = m.m[1]; + float m06 = m.m[2]; + float m01 = m.m[3]; + float m04 = m.m[4]; + float m07 = m.m[5]; + float m02 = m.m[6]; + float m05 = m.m[7]; + float m08 = m.m[8]; + float trace = m00 + m04 + m08; + if (trace > 0) { + const float s = 0.5F / std::sqrtf(trace + 1.F); + out->w = 0.25F / s; + out->x = (m05 - m07) * s; + out->y = (m06 - m02) * s; + out->z = (m01 - m03) * s; + } else if ((m00 > m04) && (m00 > m08)) { + const float s = 2.F * std::sqrtf(1.F + m04 - m00 - m08); + + out->w = (m05 - m07) / s; + out->x = 0.25F * s; + out->y = (m03 + m01) / s; + out->z = (m06 + m02) / s; + } else if (m04 > m08) { + const float s = 2.F * std::sqrtf(1.F + m04 - m00 - m08); + + out->w = (m06 - m02) / s; + out->x = (m03 + m01) / s; + out->y = 0.25F * s; + out->z = (m07 + m05) / s; + } else { + const float s = 2.F * std::sqrtf(1.F + m08 - m00 - m04); + + out->w = (m01 - m03) / s; + out->x = (m06 + m02) / s; + out->y = (m07 + m05) / s; + out->z = 0.25F * s; + } } void Quaternion::slerp(float q1x, float q1y, float q1z, float q1w, float q2x, float q2y, float q2z, float q2w, float t, float *dstx, float *dsty, float *dstz, float *dstw) { @@ -277,15 +388,17 @@ void Quaternion::slerp(float q1x, float q1y, float q1z, float q1w, float q2x, fl // and no sqrt. Not only does this code tolerate small constraint // errors in the input quaternions, it actually corrects for them. GP_ASSERT(dstx && dsty && dstz && dstw); - GP_ASSERT(!(t < 0.0f || t > 1.0f)); + GP_ASSERT(!(t < 0.F || t > 1.F)); - if (t == 0.0f) { + if (t == 0.F) { *dstx = q1x; *dsty = q1y; *dstz = q1z; *dstw = q1w; return; - } else if (t == 1.0f) { + } + + if (t == 1.F) { *dstx = q2x; *dsty = q2y; *dstz = q2z; @@ -301,44 +414,56 @@ void Quaternion::slerp(float q1x, float q1y, float q1z, float q1w, float q2x, fl return; } - float halfY, alpha, beta; - float u, f1, f2a, f2b; - float ratio1, ratio2; - float halfSecHalfTheta, versHalfTheta; - float sqNotU, sqU; + float halfY; + float alpha; + float beta; + + float u; + float f1; + float f2a; + float f2b; + + float ratio1; + float ratio2; + + float halfSecHalfTheta; + float versHalfTheta; + + float sqNotU; + float sqU; float cosTheta = q1w * q2w + q1x * q2x + q1y * q2y + q1z * q2z; // As usual in all slerp implementations, we fold theta. - alpha = cosTheta >= 0 ? 1.0f : -1.0f; - halfY = 1.0f + alpha * cosTheta; + alpha = cosTheta >= 0 ? 1.F : -1.F; + halfY = 1.F + alpha * cosTheta; // Here we bisect the interval, so we need to fold t as well. - f2b = t - 0.5f; - u = f2b >= 0 ? f2b : -f2b; + f2b = t - 0.5F; + u = f2b >= 0 ? f2b : -f2b; f2a = u - f2b; f2b += u; u += u; - f1 = 1.0f - u; + f1 = 1.F - u; // One iteration of Newton to get 1-cos(theta / 2) to good accuracy. - halfSecHalfTheta = 1.09f - (0.476537f - 0.0903321f * halfY) * halfY; - halfSecHalfTheta *= 1.5f - halfY * halfSecHalfTheta * halfSecHalfTheta; - versHalfTheta = 1.0f - halfY * halfSecHalfTheta; + halfSecHalfTheta = 1.09F - (0.476537F - 0.0903321F * halfY) * halfY; + halfSecHalfTheta *= 1.5F - halfY * halfSecHalfTheta * halfSecHalfTheta; + versHalfTheta = 1.F - halfY * halfSecHalfTheta; // Evaluate series expansions of the coefficients. sqNotU = f1 * f1; - ratio2 = 0.0000440917108f * versHalfTheta; - ratio1 = -0.00158730159f + (sqNotU - 16.0f) * ratio2; - ratio1 = 0.0333333333f + ratio1 * (sqNotU - 9.0f) * versHalfTheta; - ratio1 = -0.333333333f + ratio1 * (sqNotU - 4.0f) * versHalfTheta; - ratio1 = 1.0f + ratio1 * (sqNotU - 1.0f) * versHalfTheta; + ratio2 = 0.0000440917108F * versHalfTheta; + ratio1 = -0.00158730159F + (sqNotU - 16.F) * ratio2; + ratio1 = 0.0333333333F + ratio1 * (sqNotU - 9.F) * versHalfTheta; + ratio1 = -0.333333333F + ratio1 * (sqNotU - 4.F) * versHalfTheta; + ratio1 = 1.F + ratio1 * (sqNotU - 1.F) * versHalfTheta; - sqU = u * u; - ratio2 = -0.00158730159f + (sqU - 16.0f) * ratio2; - ratio2 = 0.0333333333f + ratio2 * (sqU - 9.0f) * versHalfTheta; - ratio2 = -0.333333333f + ratio2 * (sqU - 4.0f) * versHalfTheta; - ratio2 = 1.0f + ratio2 * (sqU - 1.0f) * versHalfTheta; + sqU = u * u; + ratio2 = -0.00158730159F + (sqU - 16.F) * ratio2; + ratio2 = 0.0333333333F + ratio2 * (sqU - 9.F) * versHalfTheta; + ratio2 = -0.333333333F + ratio2 * (sqU - 4.F) * versHalfTheta; + ratio2 = 1.F + ratio2 * (sqU - 1.F) * versHalfTheta; // Perform the bisection and resolve the folding done earlier. f1 *= ratio1 * halfSecHalfTheta; @@ -358,7 +483,7 @@ void Quaternion::slerp(float q1x, float q1y, float q1z, float q1w, float q2x, fl // can see, it comes at the cost of 9 additional multiplication // operations. If this error-correcting feature is not required, // the following code may be removed. - f1 = 1.5f - 0.5f * (w * w + x * x + y * y + z * z); + f1 = 1.5F - 0.5F * (w * w + x * x + y * y + z * z); *dstw = w * f1; *dstx = x * f1; *dsty = y * f1; @@ -374,7 +499,7 @@ void Quaternion::slerpForSquad(const Quaternion &q1, const Quaternion &q2, float // This is a straight-forward implementation of the formula of slerp. It does not do any sign switching. float c = q1.x * q2.x + q1.y * q2.y + q1.z * q2.z + q1.w * q2.w; - if (std::abs(c) >= 1.0f) { + if (std::abs(c) >= 1.F) { dst->x = q1.x; dst->y = q1.y; dst->z = q1.z; @@ -383,8 +508,8 @@ void Quaternion::slerpForSquad(const Quaternion &q1, const Quaternion &q2, float } float omega = std::acos(c); - float s = std::sqrt(1.0f - c * c); - if (std::abs(s) <= 0.00001f) { + float s = std::sqrt(1.F - c * c); + if (std::abs(s) <= 0.00001F) { dst->x = q1.x; dst->y = q1.y; dst->z = q1.z; @@ -394,10 +519,10 @@ void Quaternion::slerpForSquad(const Quaternion &q1, const Quaternion &q2, float float r1 = std::sin((1 - t) * omega) / s; float r2 = std::sin(t * omega) / s; - dst->x = (q1.x * r1 + q2.x * r2); - dst->y = (q1.y * r1 + q2.y * r2); - dst->z = (q1.z * r1 + q2.z * r2); - dst->w = (q1.w * r1 + q2.w * r2); + dst->x = (q1.x * r1 + q2.x * r2); + dst->y = (q1.y * r1 + q2.y * r2); + dst->z = (q1.z * r1 + q2.z * r2); + dst->w = (q1.w * r1 + q2.w * r2); } NS_CC_MATH_END diff --git a/native/cocos/math/Quaternion.h b/native/cocos/math/Quaternion.h index 0e5db25c8e..651501fb78 100644 --- a/native/cocos/math/Quaternion.h +++ b/native/cocos/math/Quaternion.h @@ -1,7 +1,7 @@ /** Copyright 2013 BlackBerry Inc. Copyright (c) 2014-2016 Chukong Technologies Inc. - Copyright (c) 2017-2018 Xiamen Yaji Software Co., Ltd. + Copyright (c) 2017-2021 Xiamen Yaji Software Co., Ltd. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -23,8 +23,8 @@ #ifndef QUATERNION_H_ #define QUATERNION_H_ -#include "math/Vec3.h" #include "math/Mat4.h" +#include "math/Vec3.h" //#include "Plane.h" /** @@ -35,7 +35,7 @@ NS_CC_MATH_BEGIN class Mat4; - +class Mat3; /** * Defines a 4-element quaternion that represents the orientation of an object in space. * @@ -72,27 +72,27 @@ public: /** * The x-value of the quaternion's vector component. */ - float x; + float x{0.0F}; /** * The y-value of the quaternion's vector component. */ - float y; + float y{0.0F}; /** * The z-value of the quaternion's vector component. */ - float z; + float z{0.0F}; /** * The scalar component of the quaternion. */ - float w; + float w{1.0F}; /** * Constructs a quaternion initialized to (0, 0, 0, 1). */ - Quaternion(); + Quaternion() = default; /** - * Constructs a quaternion initialized to (0, 0, 0, 1). + * Constructs a quaternion. * * @param xx The x component of the quaternion. * @param yy The y component of the quaternion. @@ -106,14 +106,14 @@ public: * * @param array The values for the new quaternion. */ - Quaternion(float *array); + explicit Quaternion(float *array); /** * Constructs a quaternion equal to the rotational part of the specified matrix. * * @param m The matrix. */ - Quaternion(const Mat4 &m); + explicit Quaternion(const Mat4 &m); /** * Constructs a quaternion equal to the rotation from the specified axis and angle. @@ -123,18 +123,6 @@ public: */ Quaternion(const Vec3 &axis, float angle); - /** - * Constructs a new quaternion that is a copy of the specified one. - * - * @param copy The quaternion to copy. - */ - Quaternion(const Quaternion ©); - - /** - * Destructor. - */ - ~Quaternion(); - /** * Returns the identity quaternion. * @@ -163,6 +151,16 @@ public: */ bool isZero() const; + /** + * Calculates the quaternion with Euler angles, the rotation order is YZX + */ + static void fromEuler(float x, float y, float z, Quaternion *dst); + + /** + * Converts the quaternion to angles, result angle x, y in the range of [-180, 180], z in the range of [-90, 90] interval, the rotation order is YZX + */ + static void toEuler(const Quaternion &q, bool outerZ, Vec3 *out); + /** * Creates a quaternion equal to the rotational part of the specified matrix * and stores the result in dst. @@ -182,6 +180,15 @@ public: */ static void createFromAxisAngle(const Vec3 &axis, float angle, Quaternion *dst); + /** + * @en Calculates the quaternion with given 2D angle (0, 0, z). + * @zh 根据 2D 角度(0, 0, z)计算四元数 + * + * @param out Output quaternion + * @param z Angle to rotate around Z axis in degrees. + */ + static void createFromAngleZ(float z, Quaternion *dst); + /** * Sets this quaternion to the conjugate of itself. */ @@ -263,7 +270,7 @@ public: * * @param array An array containing the elements of the quaternion in the order x, y, z, w. */ - void set(float *array); + void set(const float *array); /** * Sets the quaternion equal to the rotational part of the specified matrix. @@ -299,7 +306,7 @@ public: * * @return The angle (in radians). */ - float toAxisAngle(Vec3 *e) const; + float toAxisAngle(Vec3 *axis) const; /** * Interpolates between two quaternions using linear interpolation. @@ -314,6 +321,17 @@ public: */ static void lerp(const Quaternion &q1, const Quaternion &q2, float t, Quaternion *dst); + /** + * Calculates the quaternion with the three-dimensional transform matrix, considering no scale included in the matrix + */ + static void fromMat3(const Mat3 &m, Quaternion *out); + + /** + * Calculates the quaternion with the up direction and the direction of the viewport + */ + static void fromViewUp(const Vec3 &view, Quaternion *out); + static void fromViewUp(const Vec3 &view, const Vec3 &up, Quaternion *out); + /** * Interpolates between two quaternions using spherical linear interpolation. * diff --git a/native/cocos/math/Utils.cpp b/native/cocos/math/Utils.cpp new file mode 100644 index 0000000000..a49a50a657 --- /dev/null +++ b/native/cocos/math/Utils.cpp @@ -0,0 +1,31 @@ +#include "cocos/math/Utils.h" + +#include +#include +#include +#include "math/Math.h" + +namespace { +std::random_device rd; +std::uniform_real_distribution uniformReal{0.0F, 1.0F}; +} // namespace + +namespace cc { + +namespace mathutils { + +float random() { + return uniformReal(rd); +} + +Vec3ElementType absMaxComponent(const Vec3 &v) { + return absMax(absMax(v.x, v.y), v.z); +} + +Vec3ElementType maxComponent(const Vec3 &v) { + return std::max(std::max(v.x, v.y), v.z); +} + +} // namespace mathutils + +} // namespace cc \ No newline at end of file diff --git a/native/cocos/math/Utils.h b/native/cocos/math/Utils.h new file mode 100644 index 0000000000..08dc6296bb --- /dev/null +++ b/native/cocos/math/Utils.h @@ -0,0 +1,259 @@ +#pragma once + +#include +#include +#include "cocos/math/Vec3.h" + +namespace cc { + +namespace mathutils { + +constexpr auto EPSILON = 0.000001; +constexpr auto D2R = M_PI / 180.0; +constexpr auto R2D = 180.0 / M_PI; +constexpr auto HALF_TO_RAD = 0.5 * D2R; +/** + * @en Tests whether or not the arguments have approximately the same value, within an absolute
+ * or relative tolerance of glMatrix.EPSILON (an absolute tolerance is used for values less
+ * than or equal to 1.0, and a relative tolerance is used for larger values) + * @zh 在glMatrix的绝对或相对容差范围内,测试参数是否具有近似相同的值。
+ * EPSILON(小于等于1.0的值采用绝对公差,大于1.0的值采用相对公差) + * @param a The first number to test. + * @param b The second number to test. + * @return True if the numbers are approximately equal, false otherwise. + */ +template +bool equals(F a, F b) { + static_assert(std::is_floating_point::value, "number expected"); + return std::abs(a - b) <= EPSILON * std::max(1.0, std::abs(a), std::abs(b)); +} + +/** + * @en Tests whether or not the arguments have approximately the same value by given maxDiff
+ * @zh 通过给定的最大差异,测试参数是否具有近似相同的值。 + * @param a The first number to test. + * @param b The second number to test. + * @param maxDiff Maximum difference. + * @return True if the numbers are approximately equal, false otherwise. + */ +template +bool approx(F a, F b, F maxDiff) { + static_assert(std::is_floating_point::value, "number expected"); + maxDiff = maxDiff || EPSILON; + return std::abs(a - b) <= maxDiff; +} + +/** + * @en Clamps a value between a minimum float and maximum float value.
+ * @zh 返回最小浮点数和最大浮点数之间的一个数值。可以使用 clamp 函数将不断变化的数值限制在范围内。 + * @param val + * @param min + * @param max + */ +template +typename std::enable_if::value, F>::type +clamp(F val, F min, F max) { + if (min > max) { + const auto temp = min; + min = max; + max = temp; + } + + return val < min ? min : val > max ? max + : val; +} + +/** + * @en Clamps a value between 0 and 1.
+ * @zh 将值限制在0和1之间。 + * @param val + */ +template +auto clamp01(F val) { + static_assert(std::is_floating_point::value, "number expected"); + return val < 0 ? 0 : val > 1 ? 1 + : val; +} + +/** + * @param from + * @param to + * @param ratio - The interpolation coefficient. + */ +template +auto lerp(F from, F to, F ratio) { + static_assert(std::is_floating_point::value, "number expected"); + return from + (to - from) * ratio; +} + +/** + * @en Convert Degree To Radian
+ * @zh 把角度换算成弧度。 + * @param {Number} a Angle in Degrees + */ +template +auto toRadian(F a) { + static_assert(std::is_floating_point::value, "number expected"); + return a * D2R; +} + +/** + * @en Convert Radian To Degree
+ * @zh 把弧度换算成角度。 + * @param {Number} a Angle in Radian + */ +template +auto toDegree(F a) { + return a * R2D; +} + +/** + * @method random + */ +float random(); + +/** + * @en Returns a floating-point random number between min (inclusive) and max (exclusive).
+ * @zh 返回最小(包含)和最大(不包含)之间的浮点随机数。 + * @method randomRange + * @param min + * @param max + * @return The random number. + */ +template +auto randomRange(T min, T max) { + return random() * (max - min) + min; +} + +/** + * @en Returns a random integer between min (inclusive) and max (exclusive).
+ * @zh 返回最小(包含)和最大(不包含)之间的随机整数。 + * @param min + * @param max + * @return The random integer. + */ +template +auto randomRangeInt(T min, T max) { + static_assert(std::is_arithmetic::value, "number expected"); + return floor(randomRange(min, max)); +} + +/** + * Linear congruential generator using Hull-Dobell Theorem. + * + * @param seed The random seed. + * @return The pseudo random. + */ +template +auto pseudoRandom(In seed) { + static_assert(std::is_arithmetic::value, "number expected"); + seed = (seed * 9301 + 49297) % 233280; + return seed / 233280.0; +} + +/** + * Returns a floating-point pseudo-random number between min (inclusive) and max (exclusive). + * + * @param seed + * @param min + * @param max + * @return The random number. + */ +template +auto pseudoRandomRange(In seed, In min, In max) { + static_assert(std::is_arithmetic::value, "number expected"); + return pseudoRandom(seed) * (max - min) + min; +} + +/** + * @en Returns a pseudo-random integer between min (inclusive) and max (exclusive).
+ * @zh 返回最小(包含)和最大(不包含)之间的浮点伪随机数。 + * @param seed + * @param min + * @param max + * @return The random integer. + */ +template +auto pseudoRandomRangeInt(In seed, In min, In max) { + return floor(pseudoRandomRange(seed, min, max)); +} + +/** + * Returns the next power of two for the value.
+ * + * @param val + * @return The the next power of two. + */ +template +auto nextPow2(T val) { + --val; + val = (val >> 1) | val; + val = (val >> 2) | val; + val = (val >> 4) | val; + val = (val >> 8) | val; + val = (val >> 16) | val; + ++val; + return val; +} + +/** + * @en Returns float remainder for t / length.
+ * @zh 返回t / length的浮点余数。 + * @param t Time start at 0. + * @param length Time of one cycle. + * @return The Time wrapped in the first cycle. + */ +template +auto repeat(T t, T length) { + return t - floor(t / length) * length; +} + +/** + * Returns time wrapped in ping-pong mode. + * + * @param t Time start at 0. + * @param length Time of one cycle. + * @return The time wrapped in the first cycle. + */ +template +auto pingPong(T t, T length) { + t = repeat(t, length * 2); + t = length - abs(t - length); + return t; +} + +/** + * @en Returns ratio of a value within a given range.
+ * @zh 返回给定范围内的值的比率。 + * @param from Start value. + * @param to End value. + * @param value Given value. + * @return The ratio between [from, to]. + */ +template +auto inverseLerp(T from, T to, T value) { + return (value - from) / (to - from); +} + +using Vec3ElementType = decltype(static_cast(nullptr)->x); +/** + * @zh 对所有分量的绝对值进行比较大小,返回绝对值最大的分量。 + * @param v 类 Vec3 结构 + * @returns 绝对值最大的分量 + */ +Vec3ElementType absMaxComponent(const Vec3 &v); + +Vec3ElementType maxComponent(const Vec3 &v); + +/** + * @zh 对 a b 的绝对值进行比较大小,返回绝对值最大的值。 + * @param a number + * @param b number + */ +template +auto absMax(F a, F b) { + return abs(a) > abs(b) ? a : b; +} + +} // namespace mathutils +} // namespace cc diff --git a/native/cocos/math/Vec3.cpp b/native/cocos/math/Vec3.cpp index cf7cb76dc6..ab01364488 100644 --- a/native/cocos/math/Vec3.cpp +++ b/native/cocos/math/Vec3.cpp @@ -1,7 +1,7 @@ /** Copyright 2013 BlackBerry Inc. Copyright (c) 2013-2016 Chukong Technologies Inc. - Copyright (c) 2017-2018 Xiamen Yaji Software Co., Ltd. + Copyright (c) 2017-2021 Xiamen Yaji Software Co., Ltd. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -21,9 +21,10 @@ */ #include "math/Vec3.h" -#include "math/Mat3.h" -#include "math/MathUtil.h" #include "base/Macros.h" +#include "math/Mat3.h" +#include "math/Math.h" +#include "math/MathUtil.h" #include "math/Quaternion.h" NS_CC_MATH_BEGIN @@ -48,9 +49,9 @@ Vec3::Vec3(const Vec3 ©) { Vec3 Vec3::fromColor(unsigned int color) { float components[3]; - int componentIndex = 0; + int componentIndex = 0; for (int i = 2; i >= 0; --i) { - const unsigned int component = (color >> i * 8) & 0x0000ff; + auto component = (color >> i * 8) & 0x0000ff; components[componentIndex++] = static_cast(component) / 255.0F; } @@ -59,6 +60,21 @@ Vec3 Vec3::fromColor(unsigned int color) { return value; } +void Vec3::transformInverseRTS(const Vec3 &v, const Quaternion &r, const Vec3 &t, const Vec3 &s, Vec3 *out) { + GP_ASSERT(out); + const float x = v.x - t.x; + const float y = v.y - t.y; + const float z = v.z - t.z; + + const float ix = r.w * x - r.y * z + r.z * y; + const float iy = r.w * y - r.z * x + r.x * z; + const float iz = r.w * z - r.x * y + r.y * x; + const float iw = r.x * x + r.y * y + r.z * z; + out->x = (ix * r.w + iw * r.x + iy * r.z - iz * r.y) / s.x; + out->y = (iy * r.w + iw * r.y + iz * r.x - ix * r.z) / s.y; + out->z = (iz * r.w + iw * r.z + ix * r.y - iy * r.x) / s.z; +} + float Vec3::angle(const Vec3 &v1, const Vec3 &v2) { const float dx = v1.y * v2.z - v1.z * v2.y; const float dy = v1.z * v2.x - v1.x * v2.z; @@ -81,18 +97,18 @@ void Vec3::clamp(const Vec3 &min, const Vec3 &max) { // Clamp the x value. if (x < min.x) { x = min.x; - } + } if (x > max.x) { x = max.x; } - + // Clamp the y value. if (y < min.y) { y = min.y; - } + } if (y > max.y) { y = max.y; - } + } // Clamp the z value. if (z < min.z) { @@ -100,7 +116,7 @@ void Vec3::clamp(const Vec3 &min, const Vec3 &max) { } if (z > max.z) { z = max.z; - } + } } void Vec3::clamp(const Vec3 &v, const Vec3 &min, const Vec3 &max, Vec3 *dst) { @@ -129,7 +145,7 @@ void Vec3::clamp(const Vec3 &v, const Vec3 &min, const Vec3 &max, Vec3 *dst) { dst->z = v.z; if (dst->z < min.z) { dst->z = min.z; - } + } if (dst->z > max.z) { dst->z = max.z; } @@ -171,21 +187,33 @@ void Vec3::transformMat3(const Vec3 &v, const Mat3 &m) { const float ix = v.x; const float iy = v.y; const float iz = v.z; - x = ix * m.m[0] + iy * m.m[3] + iz * m.m[6]; - y = ix * m.m[1] + iy * m.m[4] + iz * m.m[7]; - z = ix * m.m[2] + iy * m.m[5] + iz * m.m[8]; + x = ix * m.m[0] + iy * m.m[3] + iz * m.m[6]; + y = ix * m.m[1] + iy * m.m[4] + iz * m.m[7]; + z = ix * m.m[2] + iy * m.m[5] + iz * m.m[8]; } void Vec3::transformMat4(const Vec3 &v, const Mat4 &m) { - const float ix = v.x; - const float iy = v.y; - const float iz = v.z; - float rhw = m.m[3] * ix + m.m[7] * iy + m.m[11] * iz + m.m[15]; - rhw = static_cast(rhw) ? 1.0F / rhw : 1.0F; + alignas(16) float tmp[4] = {v.x, v.y, v.z, 1.0F}; + MathUtil::transformVec4(m.m, tmp, tmp); + float rhw = math::IsNotEqualF(tmp[3], 0.0F) ? 1 / tmp[3] : 1; + x = tmp[0] * rhw; + y = tmp[1] * rhw; + z = tmp[2] * rhw; +} - x = (m.m[0] * ix + m.m[4] * iy + m.m[8] * iz + m.m[12]) * rhw; - y = (m.m[1] * ix + m.m[5] * iy + m.m[9] * iz + m.m[13]) * rhw; - z = (m.m[2] * ix + m.m[6] * iy + m.m[10] * iz + m.m[14]) * rhw; +void Vec3::transformMat4(const Vec3 &v, const Mat4 &m, Vec3 *dst) { + dst->transformMat4(v, m); +} + +void Vec3::transformMat4Normal(const Vec3 &v, const Mat4 &m, Vec3 *dst) { + float x = v.x; + float y = v.y; + float z = v.z; + float rhw = m.m[3] * x + m.m[7] * y + m.m[11] * z; + rhw = rhw != 0.0F ? abs(1.0F / rhw) : 1.0F; + dst->x = (m.m[0] * x + m.m[4] * y + m.m[8] * z) * rhw; + dst->y = (m.m[1] * x + m.m[5] * y + m.m[9] * z) * rhw; + dst->z = (m.m[2] * x + m.m[6] * y + m.m[10] * z) * rhw; } void Vec3::transformQuat(const Quaternion &q) { @@ -241,7 +269,7 @@ void Vec3::normalize() { // Too close to zero. if (n < MATH_TOLERANCE) { return; - } + } n = 1.0F / n; x *= n; @@ -264,7 +292,6 @@ void Vec3::subtract(const Vec3 &v1, const Vec3 &v2, Vec3 *dst) { } void Vec3::max(const Vec3 &v1, const Vec3 &v2, Vec3 *dst) { - GP_ASSERT(dst); dst->x = std::fmaxf(v1.x, v2.x); @@ -273,7 +300,6 @@ void Vec3::max(const Vec3 &v1, const Vec3 &v2, Vec3 *dst) { } void Vec3::min(const Vec3 &v1, const Vec3 &v2, Vec3 *dst) { - GP_ASSERT(dst); dst->x = std::fminf(v1.x, v2.x); diff --git a/native/cocos/math/Vec3.h b/native/cocos/math/Vec3.h index 907a8628ca..246280776b 100644 --- a/native/cocos/math/Vec3.h +++ b/native/cocos/math/Vec3.h @@ -1,7 +1,7 @@ /** Copyright 2013 BlackBerry Inc. Copyright (c) 2014-2016 Chukong Technologies Inc. - Copyright (c) 2017-2018 Xiamen Yaji Software Co., Ltd. + Copyright (c) 2017-2021 Xiamen Yaji Software Co., Ltd. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -23,6 +23,7 @@ #ifndef MATH_VEC3_H #define MATH_VEC3_H +#include #include "math/MathBase.h" /** @@ -137,6 +138,11 @@ public: */ static float angle(const Vec3 &v1, const Vec3 &v2); + /** + * Transforms the current vector with given scale, rotation and translation in reverse order + */ + static void transformInverseRTS(const Vec3 &v, const Quaternion &r, const Vec3 &t, const Vec3 &s, Vec3 *out); + /** * Adds the elements of the specified vector to this one. * @@ -237,6 +243,21 @@ public: */ void transformMat4(const Vec3 &v, const Mat4 &m); + /** + * Transforms vector v by the specified Mat4 and stores the result in dst vector. + * @zh 向量与四维矩阵乘法,默认向量第四位为 1。 + * @param v The Vec3 to transform. + * @param m The matrix. + * @param dst The destination vector + */ + static void transformMat4(const Vec3 &v, const Mat4 &m, Vec3 *dst); + + /** + * @en Vector and fourth order matrix multiplication, will complete the vector with a fourth element as one + * @zh 向量与四维矩阵乘法,默认向量第四位为 0。 + */ + static void transformMat4Normal(const Vec3 &v, const Mat4 &m, Vec3 *dst); + /** * Transforms this vector by the specified quaternion and stores the result in this vector. * @@ -533,11 +554,11 @@ public: * @return bool */ inline bool operator<(const Vec3 &rhs) const { - bool temp = false; - if (x < rhs.x && y < rhs.y && z < rhs.z) { - temp = true; - } - return temp; + return x < rhs.x && y < rhs.y && z < rhs.z; + } + + inline bool operator<=(const Vec3 &rhs) const { + return x <= rhs.x && y <= rhs.y && z <= rhs.z; } /** @@ -548,11 +569,11 @@ public: * @return bool */ inline bool operator>(const Vec3 &rhs) const { - bool temp = false; - if (x > rhs.x && y > rhs.y && z > rhs.z) { - temp = true; - } - return temp; + return x > rhs.x && y > rhs.y && z > rhs.z; + } + + inline bool operator>=(const Vec3 &rhs) const { + return x >= rhs.x && y >= rhs.y && z >= rhs.z; } /** diff --git a/native/cocos/math/Vec4.cpp b/native/cocos/math/Vec4.cpp index 5827aa3cbe..e68fc199b2 100644 --- a/native/cocos/math/Vec4.cpp +++ b/native/cocos/math/Vec4.cpp @@ -1,7 +1,7 @@ /** Copyright 2013 BlackBerry Inc. Copyright (c) 2013-2016 Chukong Technologies Inc. - Copyright (c) 2017-2018 Xiamen Yaji Software Co., Ltd. + Copyright (c) 2017-2021 Xiamen Yaji Software Co., Ltd. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -107,34 +107,34 @@ void Vec4::clamp(const Vec4 &min, const Vec4 &max) { // Clamp the x value. if (x < min.x) { x = min.x; -} + } if (x > max.x) { x = max.x; -} + } // Clamp the y value. if (y < min.y) { y = min.y; -} + } if (y > max.y) { y = max.y; -} + } // Clamp the z value. if (z < min.z) { z = min.z; -} + } if (z > max.z) { z = max.z; -} + } // Clamp the z value. if (w < min.w) { w = min.w; -} + } if (w > max.w) { w = max.w; -} + } } void Vec4::clamp(const Vec4 &v, const Vec4 &min, const Vec4 &max, Vec4 *dst) { @@ -145,37 +145,37 @@ void Vec4::clamp(const Vec4 &v, const Vec4 &min, const Vec4 &max, Vec4 *dst) { dst->x = v.x; if (dst->x < min.x) { dst->x = min.x; -} + } if (dst->x > max.x) { dst->x = max.x; -} + } // Clamp the y value. dst->y = v.y; if (dst->y < min.y) { dst->y = min.y; -} + } if (dst->y > max.y) { dst->y = max.y; -} + } // Clamp the z value. dst->z = v.z; if (dst->z < min.z) { dst->z = min.z; -} + } if (dst->z > max.z) { dst->z = max.z; -} + } // Clamp the w value. dst->w = v.w; if (dst->w < min.w) { dst->w = min.w; -} + } if (dst->w > max.w) { dst->w = max.w; -} + } } float Vec4::distance(const Vec4 &v) const { @@ -224,13 +224,13 @@ void Vec4::normalize() { // Already normalized. if (n == 1.0F) { return; -} + } n = std::sqrt(n); // Too close to zero. if (n < MATH_TOLERANCE) { return; -} + } n = 1.0F / n; x *= n; @@ -298,6 +298,14 @@ void Vec4::subtract(const Vec4 &v1, const Vec4 &v2, Vec4 *dst) { dst->w = v1.w - v2.w; } +void Vec4::lerp(const Vec4 &a, const Vec4 &b, float t, Vec4 *dst) { + GP_ASSERT(dst); + dst->x = a.x + t * (b.x - a.x); + dst->y = a.y + t * (b.y - a.y); + dst->z = a.z + t * (b.z - a.z); + dst->w = a.w + t * (b.w - a.w); +} + const Vec4 Vec4::ZERO = Vec4(0.0F, 0.0F, 0.0F, 0.0F); const Vec4 Vec4::ONE = Vec4(1.0F, 1.0F, 1.0F, 1.0F); const Vec4 Vec4::UNIT_X = Vec4(1.0F, 0.0F, 0.0F, 0.0F); diff --git a/native/cocos/math/Vec4.h b/native/cocos/math/Vec4.h index 613bc1abb5..b134f9a74f 100644 --- a/native/cocos/math/Vec4.h +++ b/native/cocos/math/Vec4.h @@ -1,7 +1,7 @@ /** Copyright 2013 BlackBerry Inc. Copyright (c) 2014-2016 Chukong Technologies Inc. - Copyright (c) 2017-2018 Xiamen Yaji Software Co., Ltd. + Copyright (c) 2017-2021 Xiamen Yaji Software Co., Ltd. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -331,6 +331,12 @@ public: */ static void subtract(const Vec4 &v1, const Vec4 &v2, Vec4 *dst); + /** + * @en Calculates the linear interpolation between two vectors with a given ratio + * @zh 逐元素向量线性插值: A + t * (B - A) + */ + static void lerp(const Vec4 &a, const Vec4 &b, float t, Vec4 *dst); + /** * Calculates the sum of this vector with the given vector. * diff --git a/native/cocos/math/Vertex.cpp b/native/cocos/math/Vertex.cpp index 60d7b1b0f8..20d77dc646 100644 --- a/native/cocos/math/Vertex.cpp +++ b/native/cocos/math/Vertex.cpp @@ -2,9 +2,9 @@ Copyright (c) 2010-2012 cocos2d-x.org Copyright (c) 2011 ForzeField Studios S.L Copyright (c) 2013-2016 Chukong Technologies Inc. - Copyright (c) 2017-2018 Xiamen Yaji Software Co., Ltd. + Copyright (c) 2017-2021 Xiamen Yaji Software Co., Ltd. - http://www.cocos2d-x.org + http://www.cocos.com Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal @@ -26,29 +26,31 @@ ****************************************************************************/ #include "math/Vertex.h" +#include #include "base/Macros.h" namespace cc { -void ccVertexLineToPolygon(Vec2 *points, float stroke, Vec2 *vertices, unsigned int offset, unsigned int nuPoints) { +void ccVertexLineToPolygon(const std::vector &points, float stroke, unsigned int offset, unsigned int nuPoints, std::vector *vertices) { + GP_ASSERT(vertices); nuPoints += offset; if (nuPoints <= 1) return; - stroke *= 0.5f; + stroke *= 0.5F; unsigned int idx; unsigned int nuPointsMinus = nuPoints - 1; for (unsigned int i = offset; i < nuPoints; i++) { - idx = i * 2; + idx = i * 2; Vec2 p1 = points[i]; Vec2 perpVector; - if (i == 0) + if (i == 0) { perpVector = (p1 - points[i + 1]).getNormalized().getPerp(); - else if (i == nuPointsMinus) + } else if (i == nuPointsMinus) { perpVector = (points[i - 1] - p1).getNormalized().getPerp(); - else { + } else { Vec2 p2 = points[i + 1]; Vec2 p0 = points[i - 1]; @@ -58,79 +60,89 @@ void ccVertexLineToPolygon(Vec2 *points, float stroke, Vec2 *vertices, unsigned // Calculate angle between vectors float angle = acosf(p2p1.dot(p0p1)); - if (angle < CC_DEGREES_TO_RADIANS(70)) + if (angle < CC_DEGREES_TO_RADIANS(70)) { perpVector = p2p1.getMidpoint(p0p1).getNormalized().getPerp(); - else if (angle < CC_DEGREES_TO_RADIANS(170)) + } else if (angle < CC_DEGREES_TO_RADIANS(170)) { perpVector = p2p1.getMidpoint(p0p1).getNormalized(); - else + } else { perpVector = (p2 - p0).getNormalized().getPerp(); + } } perpVector = perpVector * stroke; - vertices[idx].set(p1.x + perpVector.x, p1.y + perpVector.y); - vertices[idx + 1].set(p1.x - perpVector.x, p1.y - perpVector.y); + (*vertices)[idx].set(p1.x + perpVector.x, p1.y + perpVector.y); + (*vertices)[idx + 1].set(p1.x - perpVector.x, p1.y - perpVector.y); } // Validate vertexes offset = (offset == 0) ? 0 : offset - 1; for (unsigned int i = offset; i < nuPointsMinus; i++) { - idx = i * 2; + idx = i * 2; const unsigned int idx1 = idx + 2; - Vec2 p1 = vertices[idx]; - Vec2 p2 = vertices[idx + 1]; - Vec2 p3 = vertices[idx1]; - Vec2 p4 = vertices[idx1 + 1]; + Vec2 p1 = (*vertices)[idx]; + Vec2 p2 = (*vertices)[idx + 1]; + Vec2 p3 = (*vertices)[idx1]; + Vec2 p4 = (*vertices)[idx1 + 1]; float s; //BOOL fixVertex = !ccpLineIntersect(Vec2(p1.x, p1.y), Vec2(p4.x, p4.y), Vec2(p2.x, p2.y), Vec2(p3.x, p3.y), &s, &t); bool fixVertex = !ccVertexLineIntersect(p1.x, p1.y, p4.x, p4.y, p2.x, p2.y, p3.x, p3.y, &s); - if (!fixVertex) - if (s < 0.0f || s > 1.0f) + if (!fixVertex) { + if (s < 0.F || s > 1.F) { fixVertex = true; + } + } if (fixVertex) { - vertices[idx1] = p4; - vertices[idx1 + 1] = p3; + (*vertices)[idx1] = p4; + (*vertices)[idx1 + 1] = p3; } } } -bool ccVertexLineIntersect(float Ax, float Ay, - float Bx, float By, - float Cx, float Cy, - float Dx, float Dy, float *T) { - float distAB, theCos, theSin, newX; +bool ccVertexLineIntersect(float ax, float ay, + float bx, float by, + float cx, float cy, + float dx, float dy, float *t) { + float distAB; + float theCos; + float theSin; + float newX; // FAIL: Line undefined - if ((Ax == Bx && Ay == By) || (Cx == Dx && Cy == Dy)) return false; + if ((ax == bx && ay == by) || (cx == dx && cy == dy)) { + return false; + } // Translate system to make A the origin - Bx -= Ax; - By -= Ay; - Cx -= Ax; - Cy -= Ay; - Dx -= Ax; - Dy -= Ay; + bx -= ax; + by -= ay; + cx -= ax; + cy -= ay; + dx -= ax; + dy -= ay; // Length of segment AB - distAB = sqrtf(Bx * Bx + By * By); + distAB = sqrtf(bx * bx + by * by); // Rotate the system so that point B is on the positive X axis. - theCos = Bx / distAB; - theSin = By / distAB; - newX = Cx * theCos + Cy * theSin; - Cy = Cy * theCos - Cx * theSin; - Cx = newX; - newX = Dx * theCos + Dy * theSin; - Dy = Dy * theCos - Dx * theSin; - Dx = newX; + theCos = bx / distAB; + theSin = by / distAB; + newX = cx * theCos + cy * theSin; + cy = cy * theCos - cx * theSin; + cx = newX; + newX = dx * theCos + dy * theSin; + dy = dy * theCos - dx * theSin; + dx = newX; // FAIL: Lines are parallel. - if (Cy == Dy) return false; + if (cy == dy) { + return false; + } // Discover the relative position of the intersection in the line AB - *T = (Dx + (Cx - Dx) * Dy / (Dy - Cy)) / distAB; + *t = (dx + (cx - dx) * dy / (dy - cy)) / distAB; // Success. return true; diff --git a/native/cocos/math/Vertex.h b/native/cocos/math/Vertex.h index 043dd23ecd..09f448ee80 100644 --- a/native/cocos/math/Vertex.h +++ b/native/cocos/math/Vertex.h @@ -2,9 +2,9 @@ Copyright (c) 2010-2012 cocos2d-x.org Copyright (c) 2011 ForzeField Studios S.L Copyright (c) 2013-2016 Chukong Technologies Inc. - Copyright (c) 2017-2018 Xiamen Yaji Software Co., Ltd. + Copyright (c) 2017-2021 Xiamen Yaji Software Co., Ltd. - http://www.cocos2d-x.org + http://www.cocos.com Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal @@ -27,6 +27,7 @@ #ifndef __CCVERTEX_H__ #define __CCVERTEX_H__ +#include #include "base/Macros.h" #include "math/Vec2.h" @@ -40,13 +41,13 @@ namespace cc { /** @file CCVertex.h */ /** converts a line to a polygon */ -void CC_DLL ccVertexLineToPolygon(Vec2 *points, float stroke, Vec2 *vertices, unsigned int offset, unsigned int nuPoints); +void CC_DLL ccVertexLineToPolygon(const std::vector &points, float stroke, unsigned int offset, unsigned int nuPoints, std::vector *vertices); /** returns whether or not the line intersects */ -bool CC_DLL ccVertexLineIntersect(float Ax, float Ay, - float Bx, float By, - float Cx, float Cy, - float Dx, float Dy, float *T); +bool CC_DLL ccVertexLineIntersect(float ax, float ay, + float bx, float by, + float cx, float cy, + float dx, float dy, float *t); } // namespace cc diff --git a/native/cocos/network/HttpClient-apple.mm b/native/cocos/network/HttpClient-apple.mm index 2e70b9abb1..50478cbf68 100644 --- a/native/cocos/network/HttpClient-apple.mm +++ b/native/cocos/network/HttpClient-apple.mm @@ -69,6 +69,7 @@ void HttpClient::networkThread() { // Create a HttpResponse object, the default setting is http access failed HttpResponse *response = new (std::nothrow) HttpResponse(request); + response->addRef(); processResponse(response, _responseMessage); @@ -334,9 +335,10 @@ HttpClient::HttpClient() _timeoutForConnect(30), _timeoutForRead(60), _threadCount(0), - _cookie(nullptr), - _requestSentinel(new HttpRequest()) { + _cookie(nullptr) { CC_LOG_DEBUG("In the constructor of HttpClient!"); + _requestSentinel = new HttpRequest(); + _requestSentinel->addRef(); memset(_responseMessage, 0, sizeof(char) * RESPONSE_BUFFER_SIZE); _scheduler = CC_CURRENT_ENGINE()->getScheduler(); increaseThreadCount(); @@ -374,7 +376,7 @@ void HttpClient::send(HttpRequest *request) { return; } - request->retain(); + request->addRef(); _requestQueueMutex.lock(); _requestQueue.pushBack(request); @@ -389,9 +391,10 @@ void HttpClient::sendImmediate(HttpRequest *request) { return; } - request->retain(); + request->addRef(); // Create a HttpResponse object, the default setting is http access failed HttpResponse *response = new (std::nothrow) HttpResponse(request); + response->addRef(); // NOTE: RefCounted object's reference count is changed to 0 now. so needs to addRef after new. auto t = std::thread(&HttpClient::networkThreadAlone, this, request, response); t.detach(); diff --git a/native/cocos/network/HttpClient-java.cpp b/native/cocos/network/HttpClient-java.cpp index 10de1d4567..1db37feebc 100644 --- a/native/cocos/network/HttpClient-java.cpp +++ b/native/cocos/network/HttpClient-java.cpp @@ -545,8 +545,8 @@ private: return nullptr; } std::string strValue = cc::StringUtils::getStringUTFCharsJNI(env, jstr); - size_t size = strValue.size() + 1; - char* retVal = static_cast(malloc(size)); + size_t size = strValue.size() + 1; + char * retVal = static_cast(malloc(size)); if (retVal == nullptr) { return nullptr; } @@ -634,7 +634,7 @@ void HttpClient::processResponse(HttpResponse *response, char *responseMessage) if (0 != suc) { response->setSucceed(false); response->setErrorBuffer("connect failed"); - response->setResponseCode(responseCode); + response->setResponseCode(static_cast(responseCode)); return; } @@ -684,7 +684,7 @@ void HttpClient::processResponse(HttpResponse *response, char *responseMessage) urlConnection.disconnect(); // write data to HttpResponse - response->setResponseCode(responseCode); + response->setResponseCode(static_cast(responseCode)); if (responseCode == -1) { response->setSucceed(false); @@ -721,6 +721,7 @@ void HttpClient::networkThread() { // Create a HttpResponse object, the default setting is http access failed auto *response = new (std::nothrow) HttpResponse(request); + response->addRef(); // NOTE: RefCounted object's reference count is changed to 0 now. so needs to addRef after new. processResponse(response, _responseMessage); // add response packet into queue @@ -863,7 +864,7 @@ void HttpClient::send(HttpRequest *request) { return; } - request->retain(); + request->addRef(); _requestQueueMutex.lock(); _requestQueue.pushBack(request); @@ -878,10 +879,10 @@ void HttpClient::sendImmediate(HttpRequest *request) { return; } - request->retain(); + request->addRef(); // Create a HttpResponse object, the default setting is http access failed auto *response = new (std::nothrow) HttpResponse(request); - + response->addRef(); // NOTE: RefCounted object's reference count is changed to 0 now. so needs to addRef after new. auto t = std::thread(&HttpClient::networkThreadAlone, this, request, response); t.detach(); } diff --git a/native/cocos/network/HttpClient.cpp b/native/cocos/network/HttpClient.cpp index 3c958ec2f9..6832b91937 100644 --- a/native/cocos/network/HttpClient.cpp +++ b/native/cocos/network/HttpClient.cpp @@ -27,13 +27,13 @@ ****************************************************************************/ #include "network/HttpClient.h" -#include -#include #include -#include "platform/FileUtils.h" +#include +#include #include "application/ApplicationManager.h" -#include "platform/StdC.h" #include "base/Log.h" +#include "platform/FileUtils.h" +#include "platform/StdC.h" namespace cc { @@ -50,7 +50,7 @@ typedef size_t (*write_callback)(void *ptr, size_t size, size_t nmemb, void *str // Callback function used by libcurl for collect response data static size_t writeData(void *ptr, size_t size, size_t nmemb, void *stream) { std::vector *recvBuffer = (std::vector *)stream; - size_t sizes = size * nmemb; + size_t sizes = size * nmemb; // add data to the end of recvBuffer // write data maybe called more than once in a single request @@ -62,7 +62,7 @@ static size_t writeData(void *ptr, size_t size, size_t nmemb, void *stream) { // Callback function used by libcurl for collect header data static size_t writeHeaderData(void *ptr, size_t size, size_t nmemb, void *stream) { std::vector *recvBuffer = (std::vector *)stream; - size_t sizes = size * nmemb; + size_t sizes = size * nmemb; // add data to the end of recvBuffer // write data maybe called more than once in a single request @@ -102,6 +102,7 @@ void HttpClient::networkThread() { // Create a HttpResponse object, the default setting is http access failed HttpResponse *response = new (std::nothrow) HttpResponse(request); + response->addRef(); // NOTE: RefCounted object's reference count is changed to 0 now. so needs to addRef after new. processResponse(response, _responseMessage); @@ -271,35 +272,35 @@ public: //Process Get Request static int processGetTask(HttpClient *client, HttpRequest *request, write_callback callback, void *stream, long *responseCode, write_callback headerCallback, void *headerStream, char *errorBuffer) { CURLRaii curl; - bool ok = curl.init(client, request, callback, stream, headerCallback, headerStream, errorBuffer) && curl.setOption(CURLOPT_FOLLOWLOCATION, true) && curl.perform(responseCode); + bool ok = curl.init(client, request, callback, stream, headerCallback, headerStream, errorBuffer) && curl.setOption(CURLOPT_FOLLOWLOCATION, true) && curl.perform(responseCode); return ok ? 0 : 1; } //Process POST Request static int processPostTask(HttpClient *client, HttpRequest *request, write_callback callback, void *stream, long *responseCode, write_callback headerCallback, void *headerStream, char *errorBuffer) { CURLRaii curl; - bool ok = curl.init(client, request, callback, stream, headerCallback, headerStream, errorBuffer) && curl.setOption(CURLOPT_POST, 1) && curl.setOption(CURLOPT_POSTFIELDS, request->getRequestData()) && curl.setOption(CURLOPT_POSTFIELDSIZE, request->getRequestDataSize()) && curl.perform(responseCode); + bool ok = curl.init(client, request, callback, stream, headerCallback, headerStream, errorBuffer) && curl.setOption(CURLOPT_POST, 1) && curl.setOption(CURLOPT_POSTFIELDS, request->getRequestData()) && curl.setOption(CURLOPT_POSTFIELDSIZE, request->getRequestDataSize()) && curl.perform(responseCode); return ok ? 0 : 1; } //Process PUT Request static int processPutTask(HttpClient *client, HttpRequest *request, write_callback callback, void *stream, long *responseCode, write_callback headerCallback, void *headerStream, char *errorBuffer) { CURLRaii curl; - bool ok = curl.init(client, request, callback, stream, headerCallback, headerStream, errorBuffer) && curl.setOption(CURLOPT_CUSTOMREQUEST, "PUT") && curl.setOption(CURLOPT_POSTFIELDS, request->getRequestData()) && curl.setOption(CURLOPT_POSTFIELDSIZE, request->getRequestDataSize()) && curl.perform(responseCode); + bool ok = curl.init(client, request, callback, stream, headerCallback, headerStream, errorBuffer) && curl.setOption(CURLOPT_CUSTOMREQUEST, "PUT") && curl.setOption(CURLOPT_POSTFIELDS, request->getRequestData()) && curl.setOption(CURLOPT_POSTFIELDSIZE, request->getRequestDataSize()) && curl.perform(responseCode); return ok ? 0 : 1; } //Process HEAD Request static int processHeadTask(HttpClient *client, HttpRequest *request, write_callback callback, void *stream, long *responseCode, write_callback headerCallback, void *headerStream, char *errorBuffer) { CURLRaii curl; - bool ok = curl.init(client, request, callback, stream, headerCallback, headerStream, errorBuffer) && curl.setOption(CURLOPT_NOBODY, "HEAD") && curl.setOption(CURLOPT_POSTFIELDS, request->getRequestData()) && curl.setOption(CURLOPT_POSTFIELDSIZE, request->getRequestDataSize()) && curl.perform(responseCode); + bool ok = curl.init(client, request, callback, stream, headerCallback, headerStream, errorBuffer) && curl.setOption(CURLOPT_NOBODY, "HEAD") && curl.setOption(CURLOPT_POSTFIELDS, request->getRequestData()) && curl.setOption(CURLOPT_POSTFIELDSIZE, request->getRequestDataSize()) && curl.perform(responseCode); return ok ? 0 : 1; } //Process DELETE Request static int processDeleteTask(HttpClient *client, HttpRequest *request, write_callback callback, void *stream, long *responseCode, write_callback headerCallback, void *headerStream, char *errorBuffer) { CURLRaii curl; - bool ok = curl.init(client, request, callback, stream, headerCallback, headerStream, errorBuffer) && curl.setOption(CURLOPT_CUSTOMREQUEST, "DELETE") && curl.setOption(CURLOPT_FOLLOWLOCATION, true) && curl.perform(responseCode); + bool ok = curl.init(client, request, callback, stream, headerCallback, headerStream, errorBuffer) && curl.setOption(CURLOPT_CUSTOMREQUEST, "DELETE") && curl.setOption(CURLOPT_FOLLOWLOCATION, true) && curl.perform(responseCode); return ok ? 0 : 1; } @@ -319,7 +320,7 @@ void HttpClient::destroyInstance() { } CC_LOG_DEBUG("HttpClient::destroyInstance begin"); - auto thiz = _httpClient; + auto thiz = _httpClient; _httpClient = nullptr; if (auto sche = thiz->_scheduler.lock()) { @@ -395,7 +396,7 @@ void HttpClient::send(HttpRequest *request) { return; } - request->retain(); + request->addRef(); _requestQueueMutex.lock(); _requestQueue.pushBack(request); @@ -410,9 +411,10 @@ void HttpClient::sendImmediate(HttpRequest *request) { return; } - request->retain(); + request->addRef(); // Create a HttpResponse object, the default setting is http access failed HttpResponse *response = new (std::nothrow) HttpResponse(request); + response->addRef(); // NOTE: RefCounted object's reference count is changed to 0 now. so needs to addRef after new. auto t = std::thread(&HttpClient::networkThreadAlone, this, request, response); t.detach(); @@ -432,7 +434,7 @@ void HttpClient::dispatchResponseCallbacks() { _responseQueueMutex.unlock(); if (response) { - HttpRequest *request = response->getHttpRequest(); + HttpRequest * request = response->getHttpRequest(); const ccHttpRequestCallback &callback = request->getResponseCallback(); if (callback != nullptr) { @@ -447,9 +449,9 @@ void HttpClient::dispatchResponseCallbacks() { // Process Response void HttpClient::processResponse(HttpResponse *response, char *responseMessage) { - auto request = response->getHttpRequest(); + auto request = response->getHttpRequest(); long responseCode = -1; - int retValue = 0; + int retValue = 0; // Process the request -> get response packet switch (request->getRequestType()) { diff --git a/native/cocos/network/HttpRequest.h b/native/cocos/network/HttpRequest.h index ae28776fb2..2d28927648 100644 --- a/native/cocos/network/HttpRequest.h +++ b/native/cocos/network/HttpRequest.h @@ -28,12 +28,12 @@ #ifndef __HTTP_REQUEST_H__ #define __HTTP_REQUEST_H__ -#include "base/Ref.h" #include "base/Macros.h" +#include "base/RefCounted.h" +#include #include #include -#include /** * @addtogroup network @@ -47,7 +47,7 @@ namespace network { class HttpClient; class HttpResponse; -typedef std::function ccHttpRequestCallback; +using ccHttpRequestCallback = std::function; /** * Defines the object which users must packed for HttpClient::send(HttpRequest*) method. @@ -63,7 +63,7 @@ typedef std::function ccHttpRequestCallback; #endif #endif -class CC_DLL HttpRequest : public Ref { +class CC_DLL HttpRequest : public RefCounted { public: /** * The HttpRequest type enum used in the HttpRequest::setRequestType. @@ -85,15 +85,10 @@ public: Please refer to HttpRequestTest.cpp to find its usage. */ HttpRequest() - : _requestType(Type::UNKNOWN), - _callback(nullptr), - _userData(nullptr), - _timeoutInSeconds(10.0f) { - } + : _callback(nullptr) {} /** Destructor. */ - virtual ~HttpRequest() { - } + ~HttpRequest() override = default; /** * Override autorelease method to avoid developers to call it. @@ -101,8 +96,9 @@ public: * * @return Ref* always return nullptr. */ - Ref *autorelease() { - CCASSERT(false, "HttpResponse is used between network thread and ui thread \ + RefCounted *autorelease() { // NOLINT(readability-convert-member-functions-to-static) + CCASSERT(false, + "HttpResponse is used between network thread and ui thread \ therefore, autorelease is forbidden here"); return nullptr; } @@ -162,8 +158,9 @@ public: * @return char* the request data pointer. */ inline char *getRequestData() { - if (!_requestData.empty()) + if (!_requestData.empty()) { return _requestData.data(); + } return nullptr; } @@ -174,7 +171,7 @@ public: * @return ssize_t the size of request data */ inline ssize_t getRequestDataSize() const { - return _requestData.size(); + return static_cast(_requestData.size()); } /** @@ -265,14 +262,14 @@ public: protected: // properties - Type _requestType; /// kHttpRequestGet, kHttpRequestPost or other enums - std::string _url; /// target url that this request is sent to - std::vector _requestData; /// used for POST - std::string _tag; /// user defined tag, to identify different requests in response callback - ccHttpRequestCallback _callback; /// C++11 style callbacks - void *_userData; /// You can add your customed data here - std::vector _headers; /// custom http headers - float _timeoutInSeconds; + Type _requestType{Type::UNKNOWN}; /// kHttpRequestGet, kHttpRequestPost or other enums + std::string _url; /// target url that this request is sent to + std::vector _requestData; /// used for POST + std::string _tag; /// user defined tag, to identify different requests in response callback + ccHttpRequestCallback _callback; /// C++11 style callbacks + void * _userData{nullptr}; /// You can add your customed data here + std::vector _headers; /// custom http headers + float _timeoutInSeconds{10.F}; }; } // namespace network diff --git a/native/cocos/network/HttpResponse.h b/native/cocos/network/HttpResponse.h index fd85586626..d54b680ca6 100644 --- a/native/cocos/network/HttpResponse.h +++ b/native/cocos/network/HttpResponse.h @@ -45,7 +45,7 @@ namespace network { * @since v2.0.2. * @lua NA */ -class CC_DLL HttpResponse : public cc::Ref { +class CC_DLL HttpResponse : public cc::RefCounted { public: /** * Constructor, it's used by HttpClient internal, users don't need to create HttpResponse manually. @@ -56,7 +56,7 @@ public: _succeed(false), _responseDataString("") { if (_pHttpRequest) { - _pHttpRequest->retain(); + _pHttpRequest->addRef(); } } @@ -75,8 +75,9 @@ public: * If this method is called , it would trigger CCASSERT. * @return cc::Ref* always return nullptr. */ - cc::Ref *autorelease() { - CCASSERT(false, "HttpResponse is used between network thread and ui thread \ + cc::RefCounted *autorelease() { + CCASSERT(false, + "HttpResponse is used between network thread and ui thread \ therefore, autorelease is forbidden here"); return nullptr; } @@ -204,13 +205,13 @@ protected: bool initWithRequest(HttpRequest *request); // properties - HttpRequest *_pHttpRequest; /// the corresponding HttpRequest pointer who leads to this response - bool _succeed; /// to indicate if the http request is successful simply - std::vector _responseData; /// the returned raw data. You can also dump it as a string - std::vector _responseHeader; /// the returned raw header data. You can also dump it as a string - long _responseCode; /// the status code returned from libcurl, e.g. 200, 404 - std::string _errorBuffer; /// if _responseCode != 200, please read _errorBuffer to find the reason - std::string _responseDataString; // the returned raw data. You can also dump it as a string + HttpRequest * _pHttpRequest; /// the corresponding HttpRequest pointer who leads to this response + bool _succeed; /// to indicate if the http request is successful simply + std::vector _responseData; /// the returned raw data. You can also dump it as a string + std::vector _responseHeader; /// the returned raw header data. You can also dump it as a string + long _responseCode; /// the status code returned from libcurl, e.g. 200, 404 + std::string _errorBuffer; /// if _responseCode != 200, please read _errorBuffer to find the reason + std::string _responseDataString; // the returned raw data. You can also dump it as a string }; } // namespace network diff --git a/native/cocos/network/SocketIO.cpp b/native/cocos/network/SocketIO.cpp index 3192aac380..d42a087d29 100644 --- a/native/cocos/network/SocketIO.cpp +++ b/native/cocos/network/SocketIO.cpp @@ -30,12 +30,12 @@ #include #include #include +#include "application/ApplicationManager.h" #include "base/Log.h" #include "base/UTF8.h" #include "network/HttpClient.h" #include "network/Uri.h" #include "network/WebSocket.h" -#include "application/ApplicationManager.h" #include "json/document-wrapper.h" #include "json/rapidjson.h" @@ -296,7 +296,7 @@ SocketIOPacket *SocketIOPacket::createPacketWithTypeIndex(int type, SocketIOPack * @brief The implementation of the socket.io connection * Clients/endpoints may share the same impl to accomplish multiplexing on the same websocket */ -class SIOClientImpl : public cc::Ref, +class SIOClientImpl : public cc::RefCounted, public WebSocket::Delegate { private: int _heartbeat, _timeout; @@ -392,8 +392,8 @@ void SIOClientImpl::handshakeResponse(HttpClient * /*sender*/, HttpResponse *res CC_LOG_INFO("%s completed", response->getHttpRequest()->getTag()); } - int32_t statusCode = response->getResponseCode(); - char statusString[64] = {}; + int32_t statusCode = static_cast(response->getResponseCode()); + char statusString[64] = {}; sprintf(statusString, "HTTP Status Code: %d, tag = %s", statusCode, response->getHttpRequest()->getTag()); CC_LOG_INFO("response code: %ld", statusCode); @@ -654,7 +654,7 @@ void SIOClientImpl::onOpen(WebSocket * /*ws*/) { _ws->send(s); } - CC_CURRENT_ENGINE()->getScheduler()->schedule([this](auto &&pH1) { this->heartbeat(std::forward(pH1)); }, this, (static_cast(_heartbeat) * .9F), false, "heartbeat"); + CC_CURRENT_ENGINE()->getScheduler()->schedule([this](auto &&pH1) { this->heartbeat(std::forward(pH1)); }, this, (static_cast(_heartbeat) * .9F), false, "heartbeat"); for (auto &client : _clients) { client.second->onOpen(); @@ -746,7 +746,7 @@ void SIOClientImpl::onMessage(WebSocket * /*ws*/, const WebSocket::Data &data) { pos2 = sData.find(','); if (pos2 > pos) { eventname = sData.substr(pos + 2, pos2 - (pos + 3)); - sData = sData.substr(pos2 + 9, sData.size() - (pos2 + 11)); + sData = sData.substr(pos2 + 9, sData.size() - (pos2 + 11)); } c->fireEvent(eventname, sData); diff --git a/native/cocos/network/SocketIO.h b/native/cocos/network/SocketIO.h index 4ba4a727da..413c42f90f 100644 --- a/native/cocos/network/SocketIO.h +++ b/native/cocos/network/SocketIO.h @@ -167,7 +167,7 @@ using EventRegistry = std::unordered_map; * @lua NA */ class CC_DLL SIOClient -: public cc::Ref { +: public cc::RefCounted { private: friend class SocketIO; // Only SocketIO class could contruct a SIOClient instance. diff --git a/native/cocos/network/WebSocket-apple.mm b/native/cocos/network/WebSocket-apple.mm index 8770bc932e..c53c264c1a 100644 --- a/native/cocos/network/WebSocket-apple.mm +++ b/native/cocos/network/WebSocket-apple.mm @@ -78,7 +78,7 @@ static std::vector *__websocketInstances = nullptr; - (void)close { _isDestroyed = true; - _ccws->retain(); + _ccws->addRef(); _delegate->onClose(_ccws); [_ws close]; _ccws->release(); diff --git a/native/cocos/network/WebSocket-libwebsockets.cpp b/native/cocos/network/WebSocket-libwebsockets.cpp index 36247bb2f0..e44f708fd1 100644 --- a/native/cocos/network/WebSocket-libwebsockets.cpp +++ b/native/cocos/network/WebSocket-libwebsockets.cpp @@ -53,10 +53,10 @@ #include #include #include +#include "application/ApplicationManager.h" #include "base/Scheduler.h" #include "network/Uri.h" #include "network/WebSocket.h" -#include "application/ApplicationManager.h" #include "platform/FileUtils.h" #include "platform/StdC.h" @@ -148,7 +148,7 @@ static void wsLog(const char *format, ...) { #define QUOTEME(x) DO_QUOTEME(x) // Since CC_LOG_DEBUG isn't thread safe, we uses LOGD for multi-thread logging. -#ifdef ANDROID +#if CC_PLATFORM == CC_PLATFORM_ANDROID #if CC_DEBUG > 0 #define LOGD(...) __android_log_print(ANDROID_LOG_DEBUG, LOG_TAG, __VA_ARGS__) #else @@ -436,15 +436,6 @@ bool WsThreadHelper::createWebSocketThread() { void WsThreadHelper::quitWebSocketThread() { _needQuit = true; -#if WS_ENABLE_LIBUV - // stop libuv loop - if (wsContext && wsPolling) { - auto *loop = lws_uv_getloop(wsContext, 0); - if (loop) { - uv_stop(loop); - } - } -#endif } void WsThreadHelper::onSubThreadLoop() { diff --git a/native/cocos/network/WebSocket.h b/native/cocos/network/WebSocket.h index 7dbcf3ed4f..1f41f71612 100644 --- a/native/cocos/network/WebSocket.h +++ b/native/cocos/network/WebSocket.h @@ -28,12 +28,12 @@ #pragma once #include "base/Macros.h" -#include "base/Ref.h" +#include "base/RefCounted.h" #include "platform/StdC.h" +#include #include #include -#include #ifndef OBJC_CLASS #ifdef __OBJC__ #define OBJC_CLASS(name) @class name @@ -57,7 +57,7 @@ namespace network { * WebSocket is wrapper of the libwebsockets-protocol, let the develop could call the websocket easily. * Please note that all public methods of WebSocket have to be invoked on Cocos Thread. */ -class CC_DLL WebSocket : public Ref { +class CC_DLL WebSocket : public RefCounted { public: /** * Close all connections and wait for all websocket threads to exit @@ -87,10 +87,10 @@ public: */ struct Data { Data() = default; - char *bytes{nullptr}; + char * bytes{nullptr}; ssize_t len{0}, issued{0}; - bool isBinary{false}; - void *ext{nullptr}; + bool isBinary{false}; + void * ext{nullptr}; ssize_t getRemain() const { return std::max(static_cast(0), len - issued); } }; @@ -166,10 +166,10 @@ public: * @return true: Success, false: Failure. * @lua NA */ - bool init(const Delegate &delegate, - const std::string &url, - const std::vector *protocols = nullptr, - const std::string &caFilePath = ""); + bool init(const Delegate & delegate, + const std::string & url, + const std::vector *protocols = nullptr, + const std::string & caFilePath = ""); /** * @brief Sends string data to websocket server. diff --git a/native/cocos/physics/physx/PhysXRigidBody.cpp b/native/cocos/physics/physx/PhysXRigidBody.cpp index dcb728e40a..6882a5da8d 100644 --- a/native/cocos/physics/physx/PhysXRigidBody.cpp +++ b/native/cocos/physics/physx/PhysXRigidBody.cpp @@ -40,7 +40,7 @@ namespace physics { PhysXRigidBody::PhysXRigidBody() : _mEnabled(false), _mGroup(1) {} -void PhysXRigidBody::initialize(scene::Node *node, ERigidBodyType t, uint32_t g) { +void PhysXRigidBody::initialize(Node *node, ERigidBodyType t, uint32_t g) { _mGroup = g; PhysXWorld &ins = PhysXWorld::getInstance(); _mSharedBody = ins.getSharedBody(node, this); diff --git a/native/cocos/physics/physx/PhysXRigidBody.h b/native/cocos/physics/physx/PhysXRigidBody.h index fca5837884..9886e3e095 100644 --- a/native/cocos/physics/physx/PhysXRigidBody.h +++ b/native/cocos/physics/physx/PhysXRigidBody.h @@ -41,8 +41,8 @@ public: inline const PhysXSharedBody &getSharedBody() const { return *_mSharedBody; } inline PhysXSharedBody & getSharedBody() { return *_mSharedBody; } inline uintptr_t getImpl() override { return reinterpret_cast(this); } - inline uintptr_t getNodeHandle() override { return reinterpret_cast(this->_mSharedBody->getNode());} - void initialize(scene::Node *node, ERigidBodyType t, uint32_t g) override; + inline uintptr_t getNodeHandle() override { return reinterpret_cast(this->_mSharedBody->getNode()); } + void initialize(Node *node, ERigidBodyType t, uint32_t g) override; void onEnable() override; void onDisable() override; void onDestroy() override; diff --git a/native/cocos/physics/physx/PhysXSharedBody.cpp b/native/cocos/physics/physx/PhysXSharedBody.cpp index 2b636cb908..11be59d6c7 100644 --- a/native/cocos/physics/physx/PhysXSharedBody.cpp +++ b/native/cocos/physics/physx/PhysXSharedBody.cpp @@ -45,11 +45,11 @@ using physx::PxVec3; namespace cc { namespace physics { -std::map PhysXSharedBody::sharedBodesMap = std::map(); +std::map PhysXSharedBody::sharedBodesMap = std::map(); static int idCounter = 0; PhysXSharedBody::PhysXSharedBody( - scene::Node * node, + Node * node, PhysXWorld *const world, PhysXRigidBody *const body) : _mID(idCounter++), _mRef(0), @@ -65,16 +65,16 @@ PhysXSharedBody::PhysXSharedBody( _mNode = node; }; -PhysXSharedBody *PhysXSharedBody::getSharedBody(const scene::Node *node, PhysXWorld *const world, PhysXRigidBody *const body) { - auto iter = sharedBodesMap.find(const_cast(node)); +PhysXSharedBody *PhysXSharedBody::getSharedBody(const Node *node, PhysXWorld *const world, PhysXRigidBody *const body) { + auto iter = sharedBodesMap.find(const_cast(node)); PhysXSharedBody *newSB; if (iter != sharedBodesMap.end()) { newSB = iter->second; } else { - newSB = new PhysXSharedBody(const_cast(node), world, body); + newSB = new PhysXSharedBody(const_cast(node), world, body); newSB->_mFilterData.word0 = 1; newSB->_mFilterData.word1 = world->getMaskByIndex(0); - sharedBodesMap.insert(std::pair(const_cast(node), newSB)); + sharedBodesMap.insert(std::pair(const_cast(node), newSB)); } if (body != nullptr) { auto g = body->getInitialGroup(); @@ -105,7 +105,7 @@ void PhysXSharedBody::setType(ERigidBodyType v) { } else { _mImpl.ptr = reinterpret_cast(_mDynamicActor); _mImpl.rigidDynamic->setRigidBodyFlag(physx::PxRigidBodyFlag::eKINEMATIC, _mType == ERigidBodyType::KINEMATIC); - } + } } void PhysXSharedBody::reference(bool v) { @@ -221,15 +221,15 @@ void PhysXSharedBody::syncScale() { } void PhysXSharedBody::syncSceneToPhysics() { - uint32_t hasChangedFlags = getNode()->getFlagsChanged(); - if (hasChangedFlags) { - if (hasChangedFlags & static_cast(TransformBit::SCALE)) syncScale(); + uint32_t getChangedFlags = getNode()->getChangedFlags(); + if (getChangedFlags) { + if (getChangedFlags & static_cast(TransformBit::SCALE)) syncScale(); auto wp = getImpl().rigidActor->getGlobalPose(); - if (hasChangedFlags & static_cast(TransformBit::POSITION)) { + if (getChangedFlags & static_cast(TransformBit::POSITION)) { getNode()->updateWorldTransform(); pxSetVec3Ext(wp.p, getNode()->getWorldPosition()); } - if (hasChangedFlags & static_cast(TransformBit::ROTATION)) { + if (getChangedFlags & static_cast(TransformBit::ROTATION)) { getNode()->updateWorldTransform(); pxSetQuatExt(wp.q, getNode()->getWorldRotation()); } @@ -243,7 +243,7 @@ void PhysXSharedBody::syncSceneToPhysics() { } void PhysXSharedBody::syncSceneWithCheck() { - if (getNode()->getFlagsChanged() & static_cast(TransformBit::SCALE)) syncScale(); + if (getNode()->getChangedFlags() & static_cast(TransformBit::SCALE)) syncScale(); auto wp = getImpl().rigidActor->getGlobalPose(); bool needUpdate = false; getNode()->updateWorldTransform(); @@ -267,7 +267,7 @@ void PhysXSharedBody::syncPhysicsToScene() { const PxTransform &wp = getImpl().rigidActor->getGlobalPose(); getNode()->setWorldPosition(wp.p.x, wp.p.y, wp.p.z); getNode()->setWorldRotation(wp.q.x, wp.q.y, wp.q.z, wp.q.w); - getNode()->setFlagsChanged(getNode()->getFlagsChanged() | static_cast(TransformBit::POSITION) | static_cast(TransformBit::ROTATION)); + getNode()->setChangedFlags(getNode()->getChangedFlags() | static_cast(TransformBit::POSITION) | static_cast(TransformBit::ROTATION)); } void PhysXSharedBody::addShape(const PhysXShape &shape) { diff --git a/native/cocos/physics/physx/PhysXSharedBody.h b/native/cocos/physics/physx/PhysXSharedBody.h index e14ebc3e66..bf1f59f709 100644 --- a/native/cocos/physics/physx/PhysXSharedBody.h +++ b/native/cocos/physics/physx/PhysXSharedBody.h @@ -28,22 +28,12 @@ #include #include #include "base/Macros.h" +#include "core/scene-graph/Node.h" #include "physics/physx/PhysXInc.h" #include "physics/spec/IBody.h" -#include "scene/Node.h" namespace cc { -enum class TransformBit { - NONE = 0, - POSITION = (1 << 0), - ROTATION = (1 << 1), - SCALE = (1 << 2), - RS = TransformBit::ROTATION | TransformBit::SCALE, - TRS = TransformBit::POSITION | TransformBit::ROTATION | TransformBit::SCALE, - TRS_MASK = ~TransformBit::TRS, -}; - namespace physics { class PhysXWorld; @@ -53,19 +43,19 @@ class PhysXRigidBody; class PhysXSharedBody final { public: - static PhysXSharedBody *getSharedBody(const scene::Node *node, PhysXWorld *world, PhysXRigidBody *body); + static PhysXSharedBody *getSharedBody(const Node *node, PhysXWorld *world, PhysXRigidBody *body); PhysXSharedBody() = delete; PhysXSharedBody(const PhysXSharedBody &other) = delete; PhysXSharedBody(PhysXSharedBody &&other) = delete; - void reference(bool v); - void enabled(bool v); - inline bool isInWorld() { return _mIndex >= 0; } - inline bool isStatic() { return static_cast(_mType) & static_cast(ERigidBodyType::STATIC); } - inline bool isKinematic() { return static_cast(_mType) & static_cast(ERigidBodyType::KINEMATIC); } - inline bool isStaticOrKinematic() { return static_cast(_mType) & static_cast(ERigidBodyType::STATIC) || static_cast(_mType) & static_cast(ERigidBodyType::KINEMATIC); } - inline bool isDynamic() { return !isStaticOrKinematic(); } - inline scene::Node *getNode() const { return _mNode; } - inline PhysXWorld & getWorld() const { return *_mWrappedWorld; } + void reference(bool v); + void enabled(bool v); + inline bool isInWorld() { return _mIndex >= 0; } + inline bool isStatic() { return static_cast(_mType) & static_cast(ERigidBodyType::STATIC); } + inline bool isKinematic() { return static_cast(_mType) & static_cast(ERigidBodyType::KINEMATIC); } + inline bool isStaticOrKinematic() { return static_cast(_mType) & static_cast(ERigidBodyType::STATIC) || static_cast(_mType) & static_cast(ERigidBodyType::KINEMATIC); } + inline bool isDynamic() { return !isStaticOrKinematic(); } + inline Node * getNode() const { return _mNode; } + inline PhysXWorld &getWorld() const { return *_mWrappedWorld; } union UActor { uintptr_t ptr; physx::PxRigidActor * rigidActor; @@ -93,24 +83,24 @@ public: inline uint32_t getMask() const { return _mFilterData.word1; } private: - static std::map sharedBodesMap; - const uint32_t _mID; - uint8_t _mRef; - bool _mIsStatic; - ERigidBodyType _mType; - float _mMass; - int _mIndex; - physx::PxFilterData _mFilterData; - scene::Node * _mNode; - UActor _mImpl; - physx::PxRigidStatic * _mStaticActor; - physx::PxRigidDynamic * _mDynamicActor; - PhysXWorld * _mWrappedWorld; - PhysXRigidBody * _mWrappedBody; - std::vector _mWrappedShapes; - std::vector _mWrappedJoints0; - std::vector _mWrappedJoints1; - PhysXSharedBody(scene::Node *node, PhysXWorld *world, PhysXRigidBody *body); + static std::map sharedBodesMap; + const uint32_t _mID; + uint8_t _mRef; + bool _mIsStatic; + ERigidBodyType _mType; + float _mMass; + int _mIndex; + physx::PxFilterData _mFilterData; + Node * _mNode; + UActor _mImpl; + physx::PxRigidStatic * _mStaticActor; + physx::PxRigidDynamic * _mDynamicActor; + PhysXWorld * _mWrappedWorld; + PhysXRigidBody * _mWrappedBody; + std::vector _mWrappedShapes; + std::vector _mWrappedJoints0; + std::vector _mWrappedJoints1; + PhysXSharedBody(Node *node, PhysXWorld *world, PhysXRigidBody *body); ~PhysXSharedBody(); void initActor(); void switchActor(bool isStaticBefore); diff --git a/native/cocos/physics/physx/PhysXWorld.h b/native/cocos/physics/physx/PhysXWorld.h index 988726d57b..4e51213ce4 100644 --- a/native/cocos/physics/physx/PhysXWorld.h +++ b/native/cocos/physics/physx/PhysXWorld.h @@ -27,13 +27,13 @@ #include #include "base/Macros.h" +#include "core/scene-graph/Node.h" #include "physics/physx/PhysXEventManager.h" #include "physics/physx/PhysXFilterShader.h" #include "physics/physx/PhysXInc.h" #include "physics/physx/PhysXRigidBody.h" #include "physics/physx/PhysXSharedBody.h" #include "physics/spec/IWorld.h" -#include "scene/Node.h" namespace cc { namespace physics { @@ -46,20 +46,20 @@ public: static physx::PxPhysics & getPhysics(); PhysXWorld(); ~PhysXWorld() override; - void step(float fixedTimeStep) override; - void setGravity(float x, float y, float z) override; - void setAllowSleep(bool v) override; - void emitEvents() override; - void setCollisionMatrix(uint32_t index, uint32_t mask) override; - bool raycast(RaycastOptions &opt) override; - bool raycastClosest(RaycastOptions &opt) override; - std::vector &raycastResult() override; - RaycastResult & raycastClosestResult() override; - uintptr_t createConvex(ConvexDesc &desc) override; - uintptr_t createTrimesh(TrimeshDesc &desc) override; - uintptr_t createHeightField(HeightFieldDesc &desc) override; - uintptr_t createMaterial(uint16_t id, float f, float df, float r, - uint8_t m0, uint8_t m1) override; + void step(float fixedTimeStep) override; + void setGravity(float x, float y, float z) override; + void setAllowSleep(bool v) override; + void emitEvents() override; + void setCollisionMatrix(uint32_t index, uint32_t mask) override; + bool raycast(RaycastOptions &opt) override; + bool raycastClosest(RaycastOptions &opt) override; + std::vector & raycastResult() override; + RaycastResult & raycastClosestResult() override; + uintptr_t createConvex(ConvexDesc &desc) override; + uintptr_t createTrimesh(TrimeshDesc &desc) override; + uintptr_t createHeightField(HeightFieldDesc &desc) override; + uintptr_t createMaterial(uint16_t id, float f, float df, float r, + uint8_t m0, uint8_t m1) override; inline std::vector> &getTriggerEventPairs() override { return _mEventMgr->getTriggerPairs(); } @@ -71,16 +71,16 @@ public: void destroy() override; inline PhysXSharedBody *getSharedBody( - const scene::Node * node, + const Node * node, PhysXRigidBody *const body = nullptr) { return PhysXSharedBody::getSharedBody(node, this, body); } inline physx::PxScene &getScene() const { return *_mScene; } - uint32_t getMaskByIndex(uint32_t i); - void syncPhysicsToScene(); - void addActor(const PhysXSharedBody &sb); - void removeActor(const PhysXSharedBody &sb); + uint32_t getMaskByIndex(uint32_t i); + void syncPhysicsToScene(); + void addActor(const PhysXSharedBody &sb); + void removeActor(const PhysXSharedBody &sb); private: static PhysXWorld * instance; diff --git a/native/cocos/physics/physx/joints/PhysXJoint.cpp b/native/cocos/physics/physx/joints/PhysXJoint.cpp index 4459232290..abd98ec38e 100644 --- a/native/cocos/physics/physx/joints/PhysXJoint.cpp +++ b/native/cocos/physics/physx/joints/PhysXJoint.cpp @@ -31,10 +31,10 @@ namespace cc { namespace physics { -physx::PxRigidActor* PhysXJoint::tempRigidActor = nullptr; +physx::PxRigidActor *PhysXJoint::tempRigidActor = nullptr; -void PhysXJoint::initialize(scene::Node* node) { - auto& ins = PhysXWorld::getInstance(); +void PhysXJoint::initialize(Node *node) { + auto &ins = PhysXWorld::getInstance(); _mSharedBody = ins.getSharedBody(node); _mSharedBody->reference(true); onComponentSet(); @@ -62,8 +62,8 @@ void PhysXJoint::onDestroy() { void PhysXJoint::setConnectedBody(uintptr_t v) { if (v) { - auto& ins = PhysXWorld::getInstance(); - _mConnectedBody = ins.getSharedBody(reinterpret_cast(v)); + auto &ins = PhysXWorld::getInstance(); + _mConnectedBody = ins.getSharedBody(reinterpret_cast(v)); } else { _mConnectedBody = nullptr; } @@ -79,7 +79,7 @@ void PhysXJoint::setEnableCollision(const bool v) { } } -physx::PxRigidActor& PhysXJoint::getTempRigidActor() { +physx::PxRigidActor &PhysXJoint::getTempRigidActor() { if (!PhysXJoint::tempRigidActor) { PhysXJoint::tempRigidActor = PxGetPhysics().createRigidDynamic(physx::PxTransform{physx::PxIdentity}); } diff --git a/native/cocos/physics/physx/joints/PhysXJoint.h b/native/cocos/physics/physx/joints/PhysXJoint.h index 59e4e280e9..3cd36556fb 100644 --- a/native/cocos/physics/physx/joints/PhysXJoint.h +++ b/native/cocos/physics/physx/joints/PhysXJoint.h @@ -26,9 +26,9 @@ #pragma once #include "base/Macros.h" +#include "core/scene-graph/Node.h" #include "physics/physx/PhysXInc.h" #include "physics/spec/IJoint.h" -#include "scene/Node.h" namespace cc { namespace physics { @@ -40,17 +40,17 @@ class PhysXJoint : virtual public IBaseJoint { public: ~PhysXJoint() override = default; - inline uintptr_t getImpl() override { return reinterpret_cast(this); } - void initialize(scene::Node *node) override; - void onEnable() override; - void onDisable() override; - void onDestroy() override; - void setConnectedBody(uintptr_t v) override; - void setEnableCollision(bool v) override; - virtual void updateScale0() = 0; - virtual void updateScale1() = 0; + inline uintptr_t getImpl() override { return reinterpret_cast(this); } + void initialize(Node *node) override; + void onEnable() override; + void onDisable() override; + void onDestroy() override; + void setConnectedBody(uintptr_t v) override; + void setEnableCollision(bool v) override; + virtual void updateScale0() = 0; + virtual void updateScale1() = 0; static physx::PxRigidActor &getTempRigidActor(); - static void releaseTempRigidActor(); + static void releaseTempRigidActor(); protected: physx::PxJoint * _mJoint{nullptr}; @@ -60,7 +60,7 @@ protected: virtual void onComponentSet() = 0; private: - static physx::PxRigidActor* tempRigidActor; + static physx::PxRigidActor *tempRigidActor; }; } // namespace physics diff --git a/native/cocos/physics/physx/shapes/PhysXShape.cpp b/native/cocos/physics/physx/shapes/PhysXShape.cpp index 773ffe5d40..bf351d8bff 100644 --- a/native/cocos/physics/physx/shapes/PhysXShape.cpp +++ b/native/cocos/physics/physx/shapes/PhysXShape.cpp @@ -32,7 +32,7 @@ namespace cc { namespace physics { -void PhysXShape::initialize(scene::Node *node) { +void PhysXShape::initialize(Node *node) { PhysXWorld &ins = PhysXWorld::getInstance(); _mSharedBody = ins.getSharedBody(node); getSharedBody().reference(true); @@ -102,18 +102,18 @@ void PhysXShape::setMask(uint32_t m) { void PhysXShape::updateEventListener(EShapeFilterFlag flag) { } -scene::AABB &PhysXShape::getAABB() { - static scene::AABB aabb; +geometry::AABB &PhysXShape::getAABB() { + static geometry::AABB aabb; if (_mShape) { auto bounds = physx::PxShapeExt::getWorldBounds(getShape(), *getSharedBody().getImpl().rigidActor); - pxSetVec3Ext(aabb.getLayout()->center, (bounds.maximum + bounds.minimum) / 2); - pxSetVec3Ext(aabb.getLayout()->halfExtents, (bounds.maximum - bounds.minimum) / 2); + pxSetVec3Ext(aabb.center, (bounds.maximum + bounds.minimum) / 2); + pxSetVec3Ext(aabb.halfExtents, (bounds.maximum - bounds.minimum) / 2); } return aabb; } -scene::Sphere &PhysXShape::getBoundingSphere() { - static scene::Sphere sphere; +geometry::Sphere &PhysXShape::getBoundingSphere() { + static geometry::Sphere sphere; if (_mShape) sphere.define(getAABB()); return sphere; } diff --git a/native/cocos/physics/physx/shapes/PhysXShape.h b/native/cocos/physics/physx/shapes/PhysXShape.h index 0797dc8a79..564bd56dcd 100644 --- a/native/cocos/physics/physx/shapes/PhysXShape.h +++ b/native/cocos/physics/physx/shapes/PhysXShape.h @@ -26,9 +26,9 @@ #pragma once #include "base/Macros.h" +#include "core/scene-graph/Node.h" #include "physics/physx/PhysXInc.h" #include "physics/spec/IShape.h" -#include "scene/Node.h" namespace cc { namespace physics { @@ -48,7 +48,7 @@ class PhysXShape : virtual public IBaseShape { public: ~PhysXShape() override = default; inline uintptr_t getImpl() override { return reinterpret_cast(this); } - void initialize(scene::Node *node) override; + void initialize(Node *node) override; void onEnable() override; void onDisable() override; void onDestroy() override; @@ -56,8 +56,8 @@ public: uint8_t m0, uint8_t m1) override; void setAsTrigger(bool v) override; void setCenter(float x, float y, float z) override; - scene::AABB & getAABB() override; - scene::Sphere & getBoundingSphere() override; + geometry::AABB & getAABB() override; + geometry::Sphere & getBoundingSphere() override; void updateEventListener(EShapeFilterFlag flag) override; uint32_t getGroup() override; void setGroup(uint32_t g) override; diff --git a/native/cocos/physics/sdk/Joint.cpp b/native/cocos/physics/sdk/Joint.cpp index 7cbf2b23fa..5419632c14 100644 --- a/native/cocos/physics/sdk/Joint.cpp +++ b/native/cocos/physics/sdk/Joint.cpp @@ -40,7 +40,7 @@ return _impl->getImpl(); \ } \ \ - void CLASS::initialize(scene::Node* node) { \ + void CLASS::initialize(Node *node) { \ _impl->initialize(node); \ } \ \ diff --git a/native/cocos/physics/sdk/Joint.h b/native/cocos/physics/sdk/Joint.h index 9b143a9776..4bd7743d6f 100644 --- a/native/cocos/physics/sdk/Joint.h +++ b/native/cocos/physics/sdk/Joint.h @@ -28,23 +28,23 @@ #include #include #include "base/Macros.h" +#include "core/scene-graph/Node.h" #include "physics/spec/IJoint.h" -#include "scene/Node.h" -#define CC_PHYSICS_JOINT_CLASS(CLASS) \ - class CC_DLL CLASS final : virtual public I##CLASS { \ - protected: \ - std::unique_ptr _impl; \ - \ - public: \ - CLASS(); \ - ~CLASS() override; \ - uintptr_t getImpl() override; \ - void initialize(scene::Node* node) override; \ - void onEnable() override; \ - void onDisable() override; \ - void onDestroy() override; \ - void setEnableCollision(bool v) override; \ +#define CC_PHYSICS_JOINT_CLASS(CLASS) \ + class CC_DLL CLASS final : virtual public I##CLASS { \ + protected: \ + std::unique_ptr _impl; \ + \ + public: \ + CLASS(); \ + ~CLASS() override; \ + uintptr_t getImpl() override; \ + void initialize(Node *node) override; \ + void onEnable() override; \ + void onDisable() override; \ + void onDestroy() override; \ + void setEnableCollision(bool v) override; \ void setConnectedBody(uintptr_t v) override; namespace cc { diff --git a/native/cocos/physics/sdk/RigidBody.cpp b/native/cocos/physics/sdk/RigidBody.cpp index 7d1a25046f..f83a7d957b 100644 --- a/native/cocos/physics/sdk/RigidBody.cpp +++ b/native/cocos/physics/sdk/RigidBody.cpp @@ -38,7 +38,7 @@ RigidBody::~RigidBody() { _impl.reset(nullptr); } -void RigidBody::initialize(scene::Node *node, const ERigidBodyType t, const uint32_t g) { +void RigidBody::initialize(Node *node, const ERigidBodyType t, const uint32_t g) { _impl->initialize(node, t, g); } diff --git a/native/cocos/physics/sdk/RigidBody.h b/native/cocos/physics/sdk/RigidBody.h index 216c63286b..cc24928a4b 100644 --- a/native/cocos/physics/sdk/RigidBody.h +++ b/native/cocos/physics/sdk/RigidBody.h @@ -37,7 +37,7 @@ public: ~RigidBody() override; inline uintptr_t getImpl() override { return _impl->getImpl(); }; inline uintptr_t getNodeHandle() override { return _impl->getNodeHandle(); }; - void initialize(scene::Node* node, ERigidBodyType t, uint32_t g) override; + void initialize(Node *node, ERigidBodyType t, uint32_t g) override; void onEnable() override; void onDisable() override; void onDestroy() override; diff --git a/native/cocos/physics/sdk/Shape.cpp b/native/cocos/physics/sdk/Shape.cpp index 6b1f153be6..f88bd9b20b 100644 --- a/native/cocos/physics/sdk/Shape.cpp +++ b/native/cocos/physics/sdk/Shape.cpp @@ -40,7 +40,7 @@ return _impl->getImpl(); \ } \ \ - void CLASS::initialize(scene::Node* node) { \ + void CLASS::initialize(Node *node) { \ _impl->initialize(node); \ } \ \ @@ -89,11 +89,11 @@ _impl->updateEventListener(v); \ } \ \ - scene::AABB& CLASS::getAABB() { \ + geometry::AABB &CLASS::getAABB() { \ return _impl->getAABB(); \ } \ \ - scene::Sphere& CLASS::getBoundingSphere() { \ + geometry::Sphere &CLASS::getBoundingSphere() { \ return _impl->getBoundingSphere(); \ } diff --git a/native/cocos/physics/sdk/Shape.h b/native/cocos/physics/sdk/Shape.h index a9309f737b..fea8e2b7f6 100644 --- a/native/cocos/physics/sdk/Shape.h +++ b/native/cocos/physics/sdk/Shape.h @@ -28,45 +28,45 @@ #include #include #include "base/Macros.h" +#include "core/geometry/AABB.h" +#include "core/geometry/Sphere.h" #include "physics/spec/IShape.h" -#include "scene/AABB.h" -#include "scene/Sphere.h" -#define CC_PHYSICS_SHAPE_CLASS(CLASS) \ - class CC_DLL CLASS final : public I##CLASS { \ - protected: \ - std::unique_ptr _impl; \ - \ - public: \ - CLASS(); \ - ~CLASS() override; \ - uintptr_t getImpl() override; \ - void initialize(scene::Node* node) override; \ - void onEnable() override; \ - void onDisable() override; \ - void onDestroy() override; \ - void setMaterial(uint16_t ID, float f, float df, float r, \ - uint8_t m0, uint8_t m1) override; \ - void setAsTrigger(bool v) override; \ - void setCenter(float x, float y, float z) override; \ - void updateEventListener(EShapeFilterFlag v) override; \ - scene::AABB& getAABB() override; \ - scene::Sphere& getBoundingSphere() override; \ - uint32_t getGroup() override; \ - void setGroup(uint32_t g) override; \ - uint32_t getMask() override; \ - void setMask(uint32_t m) override; +#define CC_PHYSICS_SHAPE_CLASS(CLASS) \ + class CC_DLL CLASS final : public I##CLASS { \ + protected: \ + std::unique_ptr _impl; \ + \ + public: \ + CLASS(); \ + ~CLASS() override; \ + uintptr_t getImpl() override; \ + void initialize(Node *node) override; \ + void onEnable() override; \ + void onDisable() override; \ + void onDestroy() override; \ + void setMaterial(uint16_t ID, float f, float df, float r, \ + uint8_t m0, uint8_t m1) override; \ + void setAsTrigger(bool v) override; \ + void setCenter(float x, float y, float z) override; \ + void updateEventListener(EShapeFilterFlag v) override; \ + geometry::AABB & getAABB() override; \ + geometry::Sphere &getBoundingSphere() override; \ + uint32_t getGroup() override; \ + void setGroup(uint32_t g) override; \ + uint32_t getMask() override; \ + void setMask(uint32_t m) override; namespace cc { namespace physics { CC_PHYSICS_SHAPE_CLASS(SphereShape) void setRadius(float v) override; -}; +}; // namespace physics CC_PHYSICS_SHAPE_CLASS(BoxShape) void setSize(float x, float y, float z) override; -}; +}; // namespace cc CC_PHYSICS_SHAPE_CLASS(CapsuleShape) void setRadius(float v) override; diff --git a/native/cocos/physics/spec/IBody.h b/native/cocos/physics/spec/IBody.h index 7b1027a087..1392cbbfee 100644 --- a/native/cocos/physics/spec/IBody.h +++ b/native/cocos/physics/spec/IBody.h @@ -25,9 +25,9 @@ #pragma once +#include "core/scene-graph/Node.h" #include "math/Vec3.h" #include "physics/spec/ILifecycle.h" -#include "scene/Node.h" namespace cc { namespace physics { @@ -41,9 +41,9 @@ enum class ERigidBodyType : uint8_t { class IRigidBody : public ILifecycle { public: ~IRigidBody() override = default; - virtual uintptr_t getImpl() = 0; + virtual uintptr_t getImpl() = 0; virtual uintptr_t getNodeHandle() = 0; - virtual void initialize(scene::Node *node, ERigidBodyType t, uint32_t g) = 0; + virtual void initialize(Node *node, ERigidBodyType t, uint32_t g) = 0; virtual bool isAwake() = 0; virtual bool isSleepy() = 0; virtual bool isSleeping() = 0; @@ -51,7 +51,7 @@ public: virtual void setMass(float v) = 0; virtual void setLinearDamping(float v) = 0; virtual void setAngularDamping(float v) = 0; - virtual void useGravity(bool v) = 0; + virtual void useGravity(bool v) = 0; virtual void useCCD(bool v) = 0; virtual void setLinearFactor(float x, float y, float z) = 0; virtual void setAngularFactor(float x, float y, float z) = 0; diff --git a/native/cocos/physics/spec/IJoint.h b/native/cocos/physics/spec/IJoint.h index 05e6ba388d..19e3e02566 100644 --- a/native/cocos/physics/spec/IJoint.h +++ b/native/cocos/physics/spec/IJoint.h @@ -26,8 +26,8 @@ #pragma once #include +#include "core/scene-graph/Node.h" #include "physics/spec/ILifecycle.h" -#include "scene/Node.h" namespace cc { namespace physics { @@ -35,7 +35,7 @@ namespace physics { class IBaseJoint : virtual public ILifecycle { public: ~IBaseJoint() override = default; - virtual void initialize(scene::Node* node) = 0; + virtual void initialize(Node *node) = 0; virtual uintptr_t getImpl() = 0; virtual void setEnableCollision(bool v) = 0; virtual void setConnectedBody(uintptr_t v) = 0; diff --git a/native/cocos/physics/spec/IShape.h b/native/cocos/physics/spec/IShape.h index 48463752a1..17851bd2c8 100644 --- a/native/cocos/physics/spec/IShape.h +++ b/native/cocos/physics/spec/IShape.h @@ -26,11 +26,10 @@ #pragma once #include -#include "bindings/manual/jsb_conversions.h" +#include "core/geometry/AABB.h" +#include "core/geometry/Sphere.h" +#include "core/scene-graph/Node.h" #include "physics/spec/ILifecycle.h" -#include "scene/AABB.h" -#include "scene/Node.h" -#include "scene/Sphere.h" namespace cc { namespace physics { @@ -53,19 +52,19 @@ class IBaseShape : virtual public ILifecycle { public: ~IBaseShape() override = default; ; - virtual void initialize(scene::Node *node) = 0; - virtual uintptr_t getImpl() = 0; - virtual void setMaterial(uint16_t id, float f, float df, float r, - uint8_t m0, uint8_t m1) = 0; - virtual void setAsTrigger(bool v) = 0; - virtual void setCenter(float x, float y, float z) = 0; - virtual scene::AABB & getAABB() = 0; - virtual scene::Sphere &getBoundingSphere() = 0; - virtual void updateEventListener(EShapeFilterFlag flag) = 0; - virtual uint32_t getGroup() = 0; - virtual void setGroup(uint32_t g) = 0; - virtual uint32_t getMask() = 0; - virtual void setMask(uint32_t m) = 0; + virtual void initialize(Node *node) = 0; + virtual uintptr_t getImpl() = 0; + virtual void setMaterial(uint16_t id, float f, float df, float r, + uint8_t m0, uint8_t m1) = 0; + virtual void setAsTrigger(bool v) = 0; + virtual void setCenter(float x, float y, float z) = 0; + virtual geometry::AABB & getAABB() = 0; + virtual geometry::Sphere &getBoundingSphere() = 0; + virtual void updateEventListener(EShapeFilterFlag flag) = 0; + virtual uint32_t getGroup() = 0; + virtual void setGroup(uint32_t g) = 0; + virtual uint32_t getMask() = 0; + virtual void setMask(uint32_t m) = 0; }; class ISphereShape : virtual public IBaseShape { @@ -130,23 +129,3 @@ public: } // namespace physics } // namespace cc - -template <> -inline bool nativevalue_to_se(const cc::scene::AABB &from, se::Value &to, se::Object *ctx) { - se::HandleObject obj(se::Object::createPlainObject()); - se::Value tmp; - if (nativevalue_to_se(from.getCenter(), tmp, ctx)) obj->setProperty("center", tmp); - if (nativevalue_to_se(from.getHalfExtents(), tmp, ctx)) obj->setProperty("halfExtents", tmp); - to.setObject(obj); - return true; -} - -template <> -inline bool nativevalue_to_se(const cc::scene::Sphere &from, se::Value &to, se::Object *ctx) { - se::HandleObject obj(se::Object::createPlainObject()); - se::Value tmp(from.getRadius()); - obj->setProperty("radius", tmp); - if (nativevalue_to_se(from.getCenter(), tmp, ctx)) obj->setProperty("center", tmp); - to.setObject(obj); - return true; -} diff --git a/native/cocos/physics/spec/IWorld.h b/native/cocos/physics/spec/IWorld.h index eb587024ae..51a39ce302 100644 --- a/native/cocos/physics/spec/IWorld.h +++ b/native/cocos/physics/spec/IWorld.h @@ -29,7 +29,7 @@ #include #include #include "base/TypeDef.h" -#include "bindings/manual/jsb_conversions.h" +#include "math/Vec3.h" namespace cc { namespace physics { @@ -91,18 +91,18 @@ struct HeightFieldDesc { }; struct RaycastOptions { - cc::Vec3 origin; + Vec3 origin; float distance; - cc::Vec3 unitDir; + Vec3 unitDir; uint32_t mask; bool queryTrigger; }; struct RaycastResult { uintptr_t shape{0}; - cc::Vec3 hitPoint; + Vec3 hitPoint; float distance; - cc::Vec3 hitNormal; + Vec3 hitNormal; RaycastResult() = default; }; @@ -133,210 +133,3 @@ public: } // namespace physics } // namespace cc - -template <> -inline bool nativevalue_to_se(const std::vector> &from, se::Value &to, se::Object * /*ctx*/) { - se::HandleObject array(se::Object::createArrayObject(from.size() * cc::physics::TriggerEventPair::COUNT)); - for (size_t i = 0; i < from.size(); i++) { - auto t = i * cc::physics::TriggerEventPair::COUNT; - array->setArrayElement(static_cast(t + 0), se::Value(static_cast(from[i]->shapeA))); - array->setArrayElement(static_cast(t + 1), se::Value(static_cast(from[i]->shapeB))); - array->setArrayElement(static_cast(t + 2), se::Value(static_cast(from[i]->state))); - } - to.setObject(array); - return true; -} - -template <> -inline bool nativevalue_to_se(const std::vector &from, se::Value &to, se::Object * /*ctx*/) { - const auto contactCount = from.size(); - se::HandleObject array(se::Object::createArrayObject(contactCount)); - for (size_t i = 0; i < contactCount; i++) { - auto t = i * cc::physics::ContactPoint::COUNT; - uint32_t j = 0; - array->setArrayElement(static_cast(t + j++), se::Value(from[i].position.x)); - array->setArrayElement(static_cast(t + j++), se::Value(from[i].position.y)); - array->setArrayElement(static_cast(t + j++), se::Value(from[i].position.z)); - array->setArrayElement(static_cast(t + j++), se::Value(from[i].normal.x)); - array->setArrayElement(static_cast(t + j++), se::Value(from[i].normal.y)); - array->setArrayElement(static_cast(t + j++), se::Value(from[i].normal.z)); - array->setArrayElement(static_cast(t + j++), se::Value(from[i].impulse.x)); - array->setArrayElement(static_cast(t + j++), se::Value(from[i].impulse.y)); - array->setArrayElement(static_cast(t + j++), se::Value(from[i].impulse.z)); - array->setArrayElement(static_cast(t + j++), se::Value(from[i].separation)); - array->setArrayElement(static_cast(t + j++), se::Value(from[i].internalFaceIndex0)); - array->setArrayElement(static_cast(t + j++), se::Value(from[i].internalFaceIndex1)); - } - to.setObject(array); - return true; -} - -template <> -inline bool nativevalue_to_se(const std::vector> &from, se::Value &to, se::Object *ctx) { - se::HandleObject array(se::Object::createArrayObject(from.size() * cc::physics::ContactEventPair::COUNT)); - for (size_t i = 0; i < from.size(); i++) { - auto t = i * cc::physics::ContactEventPair::COUNT; - array->setArrayElement(static_cast(t + 0), se::Value(static_cast(from[i]->shapeA))); - array->setArrayElement(static_cast(t + 1), se::Value(static_cast(from[i]->shapeB))); - array->setArrayElement(static_cast(t + 2), se::Value(static_cast(from[i]->state))); - array->setArrayElement(static_cast(t + 3), [&]() -> se::Value { - auto obj = se::Value(); - nativevalue_to_se(from[i]->contacts, obj, ctx); - return obj; - }()); - } - to.setObject(array); - return true; -} - -template <> -inline bool nativevalue_to_se(const cc::physics::RaycastResult &from, se::Value &to, se::Object *ctx) { - se::HandleObject obj(se::Object::createPlainObject()); - obj->setProperty("shape", se::Value(static_cast(from.shape))); - obj->setProperty("distance", se::Value(from.distance)); - se::Value tmp; - if (nativevalue_to_se(from.hitPoint, tmp, ctx)) obj->setProperty("hitPoint", tmp); - if (nativevalue_to_se(from.hitNormal, tmp, ctx)) obj->setProperty("hitNormal", tmp); - to.setObject(obj); - return true; -} - -template <> -inline bool sevalue_to_native(const se::Value &from, cc::physics::ConvexDesc *to, se::Object *ctx) { - assert(from.isObject()); - se::Object *json = from.toObject(); - auto * data = static_cast(json->getPrivateData()); - if (data) { - *to = *data; - return true; - } - - se::Value field; - bool ok = true; - - json->getProperty("positionLength", &field); - if (!field.isNullOrUndefined()) ok &= sevalue_to_native(field, &to->positionLength, ctx); - - CC_UNUSED size_t dataLength = 0; - json->getProperty("positions", &field); - if (!field.isNullOrUndefined()) { - se::Object *obj = field.toObject(); - if (obj->isArrayBuffer()) { - ok &= obj->getArrayBufferData(reinterpret_cast(&to->positions), &dataLength); - SE_PRECONDITION2(ok, false, "getArrayBufferData failed!"); - } else if (obj->isTypedArray()) { - ok &= obj->getTypedArrayData(reinterpret_cast(&to->positions), &dataLength); - SE_PRECONDITION2(ok, false, "getTypedArrayData failed!"); - } else { - ok &= false; - } - } - return ok; -} - -template <> -inline bool sevalue_to_native(const se::Value &from, cc::physics::TrimeshDesc *to, se::Object *ctx) { - if (!sevalue_to_native(from, reinterpret_cast(to), ctx)) { - return false; - } - - assert(from.isObject()); - se::Object *json = from.toObject(); - auto * data = static_cast(json->getPrivateData()); - if (data) { - *to = *data; - return true; - } - se::Value field; - bool ok = true; - - json->getProperty("triangleLength", &field); - if (!field.isNullOrUndefined()) ok &= sevalue_to_native(field, &(to->triangleLength), ctx); - - json->getProperty("isU16", &field); - if (!field.isNullOrUndefined()) ok &= sevalue_to_native(field, &(to->isU16), ctx); - - CC_UNUSED size_t dataLength = 0; - json->getProperty("triangles", &field); - if (!field.isNullOrUndefined()) { - se::Object *obj = field.toObject(); - if (obj->isArrayBuffer()) { - ok &= obj->getArrayBufferData(reinterpret_cast(&to->triangles), &dataLength); - SE_PRECONDITION2(ok, false, "getArrayBufferData failed!"); - } else if (obj->isTypedArray()) { - ok &= obj->getTypedArrayData(reinterpret_cast(&to->triangles), &dataLength); - SE_PRECONDITION2(ok, false, "getTypedArrayData failed!"); - } else { - ok &= false; - } - } - - return ok; -} - -template <> -inline bool sevalue_to_native(const se::Value &from, cc::physics::HeightFieldDesc *to, se::Object *ctx) { - assert(from.isObject()); - se::Object *json = from.toObject(); - auto * data = static_cast(json->getPrivateData()); - if (data) { - *to = *data; - return true; - } - - se::Value field; - bool ok = true; - - json->getProperty("rows", &field); - if (!field.isNullOrUndefined()) ok &= sevalue_to_native(field, &to->rows, ctx); - - json->getProperty("columns", &field); - if (!field.isNullOrUndefined()) ok &= sevalue_to_native(field, &to->columns, ctx); - - CC_UNUSED size_t dataLength = 0; - json->getProperty("samples", &field); - if (!field.isNullOrUndefined()) { - se::Object *obj = field.toObject(); - if (obj->isArrayBuffer()) { - ok &= obj->getArrayBufferData(reinterpret_cast(&to->samples), &dataLength); - SE_PRECONDITION2(ok, false, "getArrayBufferData failed!"); - } else if (obj->isTypedArray()) { - ok &= obj->getTypedArrayData(reinterpret_cast(&to->samples), &dataLength); - SE_PRECONDITION2(ok, false, "getTypedArrayData failed!"); - } else { - ok &= false; - } - } - return ok; -} - -template <> -inline bool sevalue_to_native(const se::Value &from, cc::physics::RaycastOptions *to, se::Object *ctx) { - assert(from.isObject()); - se::Object *json = from.toObject(); - auto * data = static_cast(json->getPrivateData()); - if (data) { - *to = *data; - return true; - } - - se::Value field; - bool ok = true; - - json->getProperty("origin", &field); - if (!field.isNullOrUndefined()) ok &= sevalue_to_native(field, &to->origin, ctx); - - json->getProperty("unitDir", &field); - if (!field.isNullOrUndefined()) ok &= sevalue_to_native(field, &to->unitDir, ctx); - - json->getProperty("mask", &field); - if (!field.isNullOrUndefined()) ok &= sevalue_to_native(field, &to->mask, ctx); - - json->getProperty("distance", &field); - if (!field.isNullOrUndefined()) ok &= sevalue_to_native(field, &to->distance, ctx); - - json->getProperty("queryTrigger", &field); - if (!field.isNullOrUndefined()) ok &= sevalue_to_native(field, &to->queryTrigger, ctx); - - return ok; -} diff --git a/native/cocos/platform/Application.cpp b/native/cocos/platform/Application.cpp deleted file mode 100644 index 76b29d8ac4..0000000000 --- a/native/cocos/platform/Application.cpp +++ /dev/null @@ -1,132 +0,0 @@ -/**************************************************************************** - Copyright (c) 2020-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 "cocos/platform/Application.h" -#include "cocos/bindings/jswrapper/SeApi.h" -#include "pipeline/RenderPipeline.h" -#include "cocos/renderer/GFXDeviceManager.h" - -#if USE_AUDIO - #include "cocos/audio/include/AudioEngine.h" -#endif - -#if USE_SOCKET - #include "cocos/network/WebSocket.h" -#endif - -#include "cocos/network/HttpClient.h" - -namespace cc { -void Application::restartVM() { - cc::EventDispatcher::dispatchRestartVM(); - - pipeline::RenderPipeline::getInstance()->destroy(); - - auto *scriptEngine = se::ScriptEngine::getInstance(); - - cc::PoolManager::getInstance()->getCurrentPool()->clear(); -#if USE_AUDIO - cc::AudioEngine::stopAll(); -#endif -#if USE_SOCKET - cc::network::WebSocket::closeAllConnections(); -#endif - cc::network::HttpClient::destroyInstance(); - - scheduler->removeAllFunctionsToBePerformedInCocosThread(); - scheduler->unscheduleAll(); - - scriptEngine->cleanup(); - cc::gfx::DeviceManager::destroy(); - cc::EventDispatcher::destroy(); - cc::EventDispatcher::init(); - init(); -} - -void Application::close() { // NOLINT - if (cc::EventDispatcher::initialized()) { - cc::EventDispatcher::dispatchCloseEvent(); - } - - auto *scriptEngine = se::ScriptEngine::getInstance(); - - cc::PoolManager::getInstance()->getCurrentPool()->clear(); -#if USE_AUDIO - cc::AudioEngine::stopAll(); -#endif -#if USE_SOCKET - cc::network::WebSocket::closeAllConnections(); -#endif - cc::network::HttpClient::destroyInstance(); - - scheduler->removeAllFunctionsToBePerformedInCocosThread(); - scheduler->unscheduleAll(); - - scriptEngine->cleanup(); - cc::EventDispatcher::destroy(); - - // exit - - exit(0); -} - -void Application::tick() { - if (_needRestart) { - restartVM(); - _needRestart = false; - } - - static std::chrono::steady_clock::time_point prevTime; - static std::chrono::steady_clock::time_point now; - static float dt = 0.F; - static double dtNS = NANOSECONDS_60FPS; - - ++_totalFrames; - - // iOS/macOS use its own fps limitation algorithm. -#if (CC_PLATFORM == CC_PLATFORM_ANDROID || CC_PLATFORM == CC_PLATFORM_WINDOWS || CC_PLATFORM == CC_PLATFORM_OHOS) - if (dtNS < static_cast(_prefererredNanosecondsPerFrame)) { - std::this_thread::sleep_for( - std::chrono::nanoseconds(_prefererredNanosecondsPerFrame - static_cast(dtNS))); - dtNS = static_cast(_prefererredNanosecondsPerFrame); - } -#endif - - prevTime = std::chrono::steady_clock::now(); - - scheduler->update(dt); - cc::EventDispatcher::dispatchTickEvent(dt); - - LegacyAutoreleasePool *currentPool = PoolManager::getInstance()->getCurrentPool(); - if (currentPool) { - currentPool->clear(); - } - - now = std::chrono::steady_clock::now(); - dtNS = dtNS * 0.1 + 0.9 * static_cast(std::chrono::duration_cast(now - prevTime).count()); - dt = static_cast(dtNS) / NANOSECONDS_PER_SECOND; -} - -} // namespace cc diff --git a/native/cocos/platform/FileUtils.cpp b/native/cocos/platform/FileUtils.cpp index 88ce89cfe8..f79eacff0e 100644 --- a/native/cocos/platform/FileUtils.cpp +++ b/native/cocos/platform/FileUtils.cpp @@ -572,7 +572,7 @@ FileUtils::Status FileUtils::getContents(const std::string &filename, ResizableB fclose(fp); return Status::READ_FAILED; } - size_t size = statBuf.st_size; + auto size = static_cast(statBuf.st_size); buffer->resize(size); size_t readsize = fread(buffer->buffer(), 1, size, fp); diff --git a/native/cocos/platform/Image.h b/native/cocos/platform/Image.h index 5a43da5f24..54b6c09cc8 100644 --- a/native/cocos/platform/Image.h +++ b/native/cocos/platform/Image.h @@ -29,14 +29,15 @@ #include #include -#include "base/Ref.h" +#include "base/RefCounted.h" #include "gfx-base/GFXDef.h" namespace cc { -class Image : public Ref { +class Image : public RefCounted { public: Image(); + ~Image() override; /** Supported formats for Image */ enum class Format { @@ -66,7 +67,7 @@ public: // @warning kFmtRawData only support RGBA8888 bool initWithRawData(const unsigned char *data, ssize_t dataLen, int width, int height, int bitsPerComponent, bool preMulti = false); - // data will be free ouside. + // data will be free outside. inline void takeData(unsigned char **outData) { *outData = _data; _data = nullptr; @@ -103,8 +104,6 @@ protected: std::string _filePath; bool _isCompressed = false; - ~Image() override; - static Format detectFormat(const unsigned char *data, ssize_t dataLen); static bool isPng(const unsigned char *data, ssize_t dataLen); static bool isJpg(const unsigned char *data, ssize_t dataLen); @@ -115,6 +114,8 @@ protected: static bool isASTC(const unsigned char *data, ssize_t detaLen); static gfx::Format getASTCFormat(const unsigned char *pHeader); + + friend class ImageUtils; }; } //namespace cc diff --git a/native/cocos/platform/apple/Reachability.cpp b/native/cocos/platform/apple/Reachability.cpp index 5d4c1fa519..3aa70c5b0f 100644 --- a/native/cocos/platform/apple/Reachability.cpp +++ b/native/cocos/platform/apple/Reachability.cpp @@ -24,13 +24,14 @@ ****************************************************************************/ #include "Reachability.h" +#include "base/DeferredReleasePool.h" #include "base/Macros.h" #include -#include #include #include #include +#include #include namespace { @@ -105,12 +106,13 @@ cc::Reachability::NetworkStatus getNetworkStatusForFlags(SCNetworkReachabilityFl namespace cc { Reachability *Reachability::createWithHostName(const std::string &hostName) { - Reachability *returnValue = nullptr; + Reachability * returnValue = nullptr; SCNetworkReachabilityRef reachability = SCNetworkReachabilityCreateWithName(nullptr, hostName.c_str()); if (reachability != nullptr) { returnValue = new (std::nothrow) Reachability(); + returnValue->addRef(); if (returnValue != nullptr) { - returnValue->autorelease(); + cc::DeferredReleasePool::add(returnValue); returnValue->_reachabilityRef = reachability; } else { CFRelease(reachability); @@ -126,8 +128,9 @@ Reachability *Reachability::createWithAddress(const struct sockaddr *hostAddress if (reachability != nullptr) { returnValue = new (std::nothrow) Reachability(); + returnValue->addRef(); if (returnValue != nullptr) { - returnValue->autorelease(); + cc::DeferredReleasePool::add(returnValue); returnValue->_reachabilityRef = reachability; } else { CFRelease(reachability); @@ -139,7 +142,7 @@ Reachability *Reachability::createWithAddress(const struct sockaddr *hostAddress Reachability *Reachability::createForInternetConnection() { struct sockaddr_in zeroAddress; bzero(&zeroAddress, sizeof(zeroAddress)); - zeroAddress.sin_len = sizeof(zeroAddress); + zeroAddress.sin_len = sizeof(zeroAddress); zeroAddress.sin_family = AF_INET; return createWithAddress((const struct sockaddr *)&zeroAddress); @@ -172,8 +175,8 @@ bool Reachability::startNotifier(const ReachabilityCallback &cb, void *userData) _callback = cb; _userData = userData; - bool returnValue = false; - SCNetworkReachabilityContext context = {0, this, nullptr, nullptr, nullptr}; + bool returnValue = false; + SCNetworkReachabilityContext context = {0, this, nullptr, nullptr, nullptr}; if (SCNetworkReachabilitySetCallback(_reachabilityRef, onReachabilityCallback, &context)) { if (SCNetworkReachabilityScheduleWithRunLoop(_reachabilityRef, CFRunLoopGetCurrent(), kCFRunLoopDefaultMode)) { @@ -203,7 +206,7 @@ bool Reachability::isConnectionRequired() const { Reachability::NetworkStatus Reachability::getCurrentReachabilityStatus() const { CCASSERT(_reachabilityRef != nullptr, "currentNetworkStatus called with nullptr SCNetworkReachabilityRef"); - NetworkStatus returnValue = NetworkStatus::NOT_REACHABLE; + NetworkStatus returnValue = NetworkStatus::NOT_REACHABLE; SCNetworkReachabilityFlags flags; if (SCNetworkReachabilityGetFlags(_reachabilityRef, &flags)) { diff --git a/native/cocos/platform/apple/Reachability.h b/native/cocos/platform/apple/Reachability.h index 03ed06fb71..0c28be9f4c 100644 --- a/native/cocos/platform/apple/Reachability.h +++ b/native/cocos/platform/apple/Reachability.h @@ -25,17 +25,17 @@ #pragma once -#include "base/Ref.h" +#include "base/RefCounted.h" -#include -#include #include +#include +#include struct sockaddr; namespace cc { -class Reachability final : public Ref { +class Reachability final : public RefCounted { public: enum class NetworkStatus : uint8_t { NOT_REACHABLE, @@ -79,8 +79,8 @@ private: static void onReachabilityCallback(SCNetworkReachabilityRef target, SCNetworkReachabilityFlags flags, void *info); - ReachabilityCallback _callback; - void *_userData; + ReachabilityCallback _callback; + void * _userData; SCNetworkReachabilityRef _reachabilityRef; }; diff --git a/native/cocos/platform/interfaces/modules/Device.cpp b/native/cocos/platform/interfaces/modules/Device.cpp index 81091d0b50..2a68fedcbc 100644 --- a/native/cocos/platform/interfaces/modules/Device.cpp +++ b/native/cocos/platform/interfaces/modules/Device.cpp @@ -93,4 +93,4 @@ Vec4 Device::getSafeAreaEdge() { return CC_GET_PLATFORM_INTERFACE(IScreen)->getSafeAreaEdge(); } -} // namespace cc \ No newline at end of file +} // namespace cc diff --git a/native/cocos/platform/interfaces/modules/Device.h b/native/cocos/platform/interfaces/modules/Device.h index 239f7900c6..199a978b7a 100644 --- a/native/cocos/platform/interfaces/modules/Device.h +++ b/native/cocos/platform/interfaces/modules/Device.h @@ -50,27 +50,8 @@ struct FontDefinition; */ class CC_DLL Device { public: - // https://developer.mozilla.org/en-US/docs/Web/API/Window/orientation - enum class Orientation { - PORTRAIT = 0, - LANDSCAPE_LEFT = -90, - PORTRAIT_UPSIDE_DOWN = 180, - LANDSCAPE_RIGHT = 90 - }; - - struct MotionValue { - float accelerationX = 0.0F; - float accelerationY = 0.0F; - float accelerationZ = 0.0F; - - float accelerationIncludingGravityX = 0.0F; - float accelerationIncludingGravityY = 0.0F; - float accelerationIncludingGravityZ = 0.0F; - - float rotationRateAlpha = 0.0F; - float rotationRateBeta = 0.0F; - float rotationRateGamma = 0.0F; - }; + using Orientation = IScreen::Orientation; + using MotionValue = IAccelerometer::MotionValue; /** * Gets the DPI of device diff --git a/native/cocos/platform/ios/modules/Network.mm b/native/cocos/platform/ios/modules/Network.mm index 2c3433bf05..1d3d5c4c54 100644 --- a/native/cocos/platform/ios/modules/Network.mm +++ b/native/cocos/platform/ios/modules/Network.mm @@ -33,7 +33,7 @@ INetwork::NetworkType Network::getNetworkType() const { static Reachability *__reachability = nullptr; if (__reachability == nullptr) { __reachability = Reachability::createForInternetConnection(); - __reachability->retain(); + __reachability->addRef(); } NetworkType ret = NetworkType::NONE; diff --git a/native/cocos/platform/ios/modules/SystemWindow.mm b/native/cocos/platform/ios/modules/SystemWindow.mm index 444b599060..6b557d63b9 100644 --- a/native/cocos/platform/ios/modules/SystemWindow.mm +++ b/native/cocos/platform/ios/modules/SystemWindow.mm @@ -39,6 +39,7 @@ bool SystemWindow::createWindow(const char* title, int h, int flags) { _width = w; _height = h; + return true; } void SystemWindow::setCursorEnabled(bool value) { diff --git a/native/cocos/platform/java/jni/JniImp.cpp b/native/cocos/platform/java/jni/JniImp.cpp index 3faba86c50..0ccde9d583 100644 --- a/native/cocos/platform/java/jni/JniImp.cpp +++ b/native/cocos/platform/java/jni/JniImp.cpp @@ -25,6 +25,12 @@ #include "JniImp.h" +#if CC_PLATFORM == CC_PLATFORM_ANDROID + #include +#else + #include +#endif + #include #include "JniHelper.h" diff --git a/native/cocos/platform/mac/modules/Network.mm b/native/cocos/platform/mac/modules/Network.mm index dccb1fd46e..76a5ceec7e 100644 --- a/native/cocos/platform/mac/modules/Network.mm +++ b/native/cocos/platform/mac/modules/Network.mm @@ -35,7 +35,7 @@ INetwork::NetworkType Network::getNetworkType() const { static Reachability *__reachability = nullptr; if (__reachability == nullptr) { __reachability = Reachability::createForInternetConnection(); - __reachability->retain(); + __reachability->addRef(); } NetworkType ret = NetworkType::NONE; diff --git a/native/cocos/platform/mac/modules/SystemWindow.mm b/native/cocos/platform/mac/modules/SystemWindow.mm index f9012398f8..433f07d524 100644 --- a/native/cocos/platform/mac/modules/SystemWindow.mm +++ b/native/cocos/platform/mac/modules/SystemWindow.mm @@ -49,6 +49,8 @@ bool SystemWindow::createWindow(const char *title, AppDelegate *delegate = [[NSApplication sharedApplication] delegate]; NSString * aString = [NSString stringWithUTF8String:title]; [delegate createWindow:aString xPos:x yPos:y width:w height:h]; + + return true; } void SystemWindow::setCursorEnabled(bool value) { diff --git a/native/cocos/platform/win32/FileUtils-win32.cpp b/native/cocos/platform/win32/FileUtils-win32.cpp index eb8f8e599f..a1b6a6b818 100644 --- a/native/cocos/platform/win32/FileUtils-win32.cpp +++ b/native/cocos/platform/win32/FileUtils-win32.cpp @@ -28,12 +28,12 @@ #if CC_PLATFORM == CC_PLATFORM_WINDOWS #include "platform/win32/FileUtils-win32.h" - #include "platform/win32/Utils-win32.h" - #include "base/Log.h" #include #include #include #include + #include "base/Log.h" + #include "platform/win32/Utils-win32.h" using namespace std; @@ -48,7 +48,7 @@ static std::string s_resourcePath = ""; // D:\aaa\bbb\ccc\ddd\abc.txt --> D:/aaa/bbb/ccc/ddd/abc.txt static inline std::string convertPathFormatToUnixStyle(const std::string &path) { std::string ret = path; - int len = ret.length(); + int len = ret.length(); for (int i = 0; i < len; ++i) { if (ret[i] == '\\') { ret[i] = '/'; @@ -67,7 +67,7 @@ static void _checkPath() { WCHAR *pUtf16DirEnd = wcsrchr(pUtf16ExePath, L'\\'); char utf8ExeDir[CC_MAX_PATH] = {0}; - int nNum = WideCharToMultiByte(CP_UTF8, 0, pUtf16ExePath, pUtf16DirEnd - pUtf16ExePath + 1, utf8ExeDir, sizeof(utf8ExeDir), nullptr, nullptr); + int nNum = WideCharToMultiByte(CP_UTF8, 0, pUtf16ExePath, pUtf16DirEnd - pUtf16ExePath + 1, utf8ExeDir, sizeof(utf8ExeDir), nullptr, nullptr); s_resourcePath = convertPathFormatToUnixStyle(utf8ExeDir); } @@ -114,7 +114,7 @@ long FileUtilsWin32::getFileSize(const std::string &filepath) { } LARGE_INTEGER size; size.HighPart = fad.nFileSizeHigh; - size.LowPart = fad.nFileSizeLow; + size.LowPart = fad.nFileSizeLow; return (long)size.QuadPart; } @@ -153,7 +153,7 @@ FileUtils::Status FileUtilsWin32::getContents(const std::string &filename, Resiz return FileUtils::Status::OPEN_FAILED; DWORD hi; - auto size = ::GetFileSize(fileHandle, &hi); + auto size = ::GetFileSize(fileHandle, &hi); if (hi > 0) { ::CloseHandle(fileHandle); return FileUtils::Status::TOO_LARGE; @@ -165,8 +165,8 @@ FileUtils::Status FileUtilsWin32::getContents(const std::string &filename, Resiz } buffer->resize(size); - DWORD sizeRead = 0; - BOOL successed = ::ReadFile(fileHandle, buffer->buffer(), size, &sizeRead, nullptr); + DWORD sizeRead = 0; + BOOL successed = ::ReadFile(fileHandle, buffer->buffer(), size, &sizeRead, nullptr); ::CloseHandle(fileHandle); if (!successed) { @@ -178,7 +178,7 @@ FileUtils::Status FileUtilsWin32::getContents(const std::string &filename, Resiz } std::string FileUtilsWin32::getPathForFilename(const std::string &filename, const std::string &searchPath) const { - std::string unixFileName = convertPathFormatToUnixStyle(filename); + std::string unixFileName = convertPathFormatToUnixStyle(filename); std::string unixSearchPath = convertPathFormatToUnixStyle(searchPath); return FileUtils::getPathForFilename(unixFileName, unixSearchPath); @@ -186,7 +186,7 @@ std::string FileUtilsWin32::getPathForFilename(const std::string &filename, cons std::string FileUtilsWin32::getFullPathForDirectoryAndFilename(const std::string &strDirectory, const std::string &strFilename) const { std::string unixDirectory = convertPathFormatToUnixStyle(strDirectory); - std::string unixFilename = convertPathFormatToUnixStyle(strFilename); + std::string unixFilename = convertPathFormatToUnixStyle(strFilename); return FileUtils::getFullPathForDirectoryAndFilename(unixDirectory, unixFilename); } @@ -203,7 +203,7 @@ string FileUtilsWin32::getWritablePath() const { // Debug app uses executable directory; Non-debug app uses local app data directory //#ifndef _DEBUG // Get filename of executable only, e.g. MyGame.exe - WCHAR *base_name = wcsrchr(full_path, '\\'); + WCHAR * base_name = wcsrchr(full_path, '\\'); wstring retPath; if (base_name) { WCHAR app_data_path[CC_MAX_PATH + 1]; @@ -265,7 +265,7 @@ bool FileUtilsWin32::renameFile(const std::string &path, const std::string &oldn std::string oldPath = path + oldname; std::string newPath = path + name; - std::regex pat("\\/"); + std::regex pat("\\/"); std::string _old = std::regex_replace(oldPath, pat, "\\"); std::string _new = std::regex_replace(newPath, pat, "\\"); @@ -281,9 +281,9 @@ bool FileUtilsWin32::createDirectory(const std::string &dirPath) { std::wstring path = StringUtf8ToWideChar(dirPath); // Split the path - size_t start = 0; - size_t found = path.find_first_of(L"/\\", start); - std::wstring subpath; + size_t start = 0; + size_t found = path.find_first_of(L"/\\", start); + std::wstring subpath; std::vector dirs; if (found != std::wstring::npos) { @@ -321,7 +321,7 @@ bool FileUtilsWin32::createDirectory(const std::string &dirPath) { } bool FileUtilsWin32::removeFile(const std::string &filepath) { - std::regex pat("\\/"); + std::regex pat("\\/"); std::string win32path = std::regex_replace(filepath, pat, "\\"); if (DeleteFile(StringUtf8ToWideChar(win32path).c_str())) { @@ -333,11 +333,11 @@ bool FileUtilsWin32::removeFile(const std::string &filepath) { } bool FileUtilsWin32::removeDirectory(const std::string &dirPath) { - std::wstring wpath = StringUtf8ToWideChar(dirPath); - std::wstring files = wpath + L"*.*"; + std::wstring wpath = StringUtf8ToWideChar(dirPath); + std::wstring files = wpath + L"*.*"; WIN32_FIND_DATA wfd; - HANDLE search = FindFirstFileEx(files.c_str(), FindExInfoStandard, &wfd, FindExSearchNameMatch, NULL, 0); - bool ret = true; + HANDLE search = FindFirstFileEx(files.c_str(), FindExInfoStandard, &wfd, FindExSearchNameMatch, NULL, 0); + bool ret = true; if (search != INVALID_HANDLE_VALUE) { BOOL find = true; while (find) { diff --git a/native/cocos/platform/win32/FileUtils-win32.h b/native/cocos/platform/win32/FileUtils-win32.h index dd7c25225b..48c646133b 100644 --- a/native/cocos/platform/win32/FileUtils-win32.h +++ b/native/cocos/platform/win32/FileUtils-win32.h @@ -53,7 +53,7 @@ public: virtual std::string getWritablePath() const override; virtual bool isAbsolutePath(const std::string &strPath) const override; virtual std::string getSuitableFOpen(const std::string &filenameUtf8) const override; - virtual long getFileSize(const std::string &filepath); + virtual long getFileSize(const std::string &filepath); protected: virtual bool isFileExistInternal(const std::string &strFilePath) const override; diff --git a/native/cocos/platform/win32/modules/CanvasRenderingContext2DDelegate.cpp b/native/cocos/platform/win32/modules/CanvasRenderingContext2DDelegate.cpp index 494eebaaee..0c0d06a8d9 100644 --- a/native/cocos/platform/win32/modules/CanvasRenderingContext2DDelegate.cpp +++ b/native/cocos/platform/win32/modules/CanvasRenderingContext2DDelegate.cpp @@ -437,7 +437,7 @@ void CanvasRenderingContext2DDelegate::fillTextureData() { // Because text is drawn in white color, and background color is black, // so the red value is equal to alpha value. And we should keep this value // as it includes anti-atlas information. - uint8_t alpha = GetRValue(clr) ? 255 : 0; + uint8_t alpha = GetRValue(clr); if (alpha > 0) { val = (alpha << 24) | textColor; } diff --git a/native/cocos/platform/win32/modules/System.cpp b/native/cocos/platform/win32/modules/System.cpp index a769f6c77e..89dbd84b81 100644 --- a/native/cocos/platform/win32/modules/System.cpp +++ b/native/cocos/platform/win32/modules/System.cpp @@ -111,7 +111,7 @@ std::string System::getCurrentLanguageCode() const { const LCID locale_id = MAKELCID(lid, SORT_DEFAULT); int length = GetLocaleInfoA(locale_id, LOCALE_SISO639LANGNAME, nullptr, 0); - char* tempCode = new char[length]; + char *tempCode = new char[length]; GetLocaleInfoA(locale_id, LOCALE_SISO639LANGNAME, tempCode, length); std::string code = tempCode; delete tempCode; @@ -143,10 +143,10 @@ std::string System::getSystemVersion() const { //return buff; } -bool System::openURL(const std::string& url) { - WCHAR* temp = new WCHAR[url.size() + 1]; +bool System::openURL(const std::string &url) { + WCHAR *temp = new WCHAR[url.size() + 1]; MultiByteToWideChar(CP_UTF8, 0, url.c_str(), url.size() + 1, temp, url.size() + 1); - HINSTANCE r = ShellExecuteW(NULL, L"open", temp, NULL, NULL, SW_SHOWNORMAL); + HINSTANCE r = ShellExecuteW(NULL, L"open", temp, NULL, NULL, SW_SHOWNORMAL); delete[] temp; return (size_t)r > 32; } diff --git a/native/cocos/primitive/Box.cpp b/native/cocos/primitive/Box.cpp new file mode 100644 index 0000000000..bff1f3a910 --- /dev/null +++ b/native/cocos/primitive/Box.cpp @@ -0,0 +1,148 @@ +/**************************************************************************** + 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 "primitive/Box.h" +#include "cocos/base/Optional.h" + +namespace cc { +namespace { +const std::vector> FACE_AXES{ + {2, 3, 1}, // FRONT + {4, 5, 7}, // BACK + {7, 6, 2}, // TOP + {1, 0, 4}, // BOTTOM + {1, 4, 2}, // RIGHT + {5, 0, 6} // LEFT +}; + +const std::vector> FACE_NORMALS{ + {0, 0, 1}, // FRONT + {0, 0, -1}, // BACK + {0, 1, 0}, // TOP + {0, -1, 0}, // BOTTOM + {1, 0, 0}, // RIGHT + {-1, 0, 0} // LEFT +}; + +const std::vector> FACE_TANGENTS{ + {-1, 0, 0, 1}, // FRONT + {-1, 0, 0, 1}, // BACK + {-1, 0, 0, 1}, // TOP + {-1, 0, 0, 1}, // BOTTOM + {0, 0, -1, 1}, // RIGHT + {0, 0, 1, 1} // LEFT +}; +} // namespace + +IGeometry box(const cc::optional &options) { + const uint32_t ws = options->widthSegments.has_value() ? options->widthSegments.value() : 1; + const uint32_t hs = options->heightSegments.has_value() ? options->heightSegments.value() : 1; + const uint32_t ls = options->lengthSegments.has_value() ? options->lengthSegments.value() : 1; + + const float hw = options->width.has_value() ? options->width.value() / 2 : 1.0F / 2; + const float hh = options->height.has_value() ? options->height.value() / 2 : 1.0F / 2; + const float hl = options->length.has_value() ? options->length.value() / 2 : 1.0F / 2; + + std::vector corners{Vec3{-hw, -hh, hl}, Vec3{hw, -hh, hl}, Vec3{hw, hh, hl}, Vec3{-hw, hh, hl}, Vec3{hw, -hh, -hl}, Vec3{-hw, -hh, -hl}, Vec3{-hw, hh, -hl}, Vec3{hw, hh, -hl}}; + + std::vector positions; + std::vector normals; + std::vector uvs; + std::vector tangents; + std::vector indices; + const Vec3 minPos(-hw, -hh, -hl); + const Vec3 maxPos(hw, hh, hl); + float boundingRadius{sqrt(hw * hw + hh * hh + hl * hl)}; + + auto buildPlane = [&](uint32_t side, uint32_t uSegments, uint32_t vSegments) { + float u = 0; + float v = 0; + const auto offset = static_cast(positions.size() / 3); + const vector faceAxe = FACE_AXES[side]; + const vector faceNormal = FACE_NORMALS[side]; + const vector faceTangent = FACE_TANGENTS[side]; + + for (index_t iy = 0; iy <= vSegments; ++iy) { + for (index_t ix = 0; ix <= uSegments; ++ix) { + u = static_cast(ix) / static_cast(uSegments); + v = static_cast(iy) / static_cast(vSegments); + Vec3 temp1 = corners[faceAxe[0]].lerp(corners[faceAxe[1]], u); + Vec3 temp2 = corners[faceAxe[0]].lerp(corners[faceAxe[2]], v); + temp2.subtract(corners[faceAxe[0]]); + temp1.add(temp2); + positions.emplace_back(temp1.x); + positions.emplace_back(temp1.y); + positions.emplace_back(temp1.z); + + normals.emplace_back(faceNormal[0]); + normals.emplace_back(faceNormal[1]); + normals.emplace_back(faceNormal[2]); + + uvs.emplace_back(u); + uvs.emplace_back(v); + tangents.emplace_back(faceTangent[0]); + tangents.emplace_back(faceTangent[1]); + tangents.emplace_back(faceTangent[2]); + tangents.emplace_back(faceTangent[3]); + + if ((ix < uSegments) && (iy < vSegments)) { + auto uSeg1 = uSegments + 1; + const auto a = ix + iy * uSeg1; + const auto b = ix + (iy + 1) * uSeg1; + const auto c = (ix + 1) + (iy + 1) * uSeg1; + const auto d = (ix + 1) + iy * uSeg1; + + indices.emplace_back(offset + a); + indices.emplace_back(offset + d); + indices.emplace_back(offset + b); + + indices.emplace_back(offset + b); + indices.emplace_back(offset + d); + indices.emplace_back(offset + c); + } + } + } + }; + + buildPlane(0, ws, hs); // FRONT + buildPlane(4, ls, hs); // RIGHT + buildPlane(1, ws, hs); // BACK + buildPlane(5, ls, hs); // LEFT + buildPlane(3, ws, ls); // BOTTOM + buildPlane(2, ws, ls); // TOP + + IGeometry info; + info.positions = positions; + info.normals = normals; + info.uvs = uvs; + info.tangents = tangents; + info.boundingRadius = boundingRadius; + info.minPos = minPos; + info.maxPos = maxPos; + info.indices = indices; + return info; +} + +} // namespace cc \ No newline at end of file diff --git a/native/cocos/primitive/Box.h b/native/cocos/primitive/Box.h new file mode 100644 index 0000000000..057d930d9c --- /dev/null +++ b/native/cocos/primitive/Box.h @@ -0,0 +1,96 @@ +/**************************************************************************** + 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 "primitive/PrimitiveDefine.h" + +namespace cc { + +/** + * @en + * The definition of the parameter for building a box. + * @zh + * 立方体参数选项。 + */ +struct IBoxOptions : public IGeometryOptions { + /** + * @en + * Box extent on X-axis. + * @zh + * 立方体宽度。 + */ + cc::optional width; + + /** + * @en + * Box extent on Y-axis. + * @zh + * 立方体高度。 + */ + cc::optional height; + + /** + * @en + * Box extent on Z-axis. + * @zh + * 立方体长度。 + */ + cc::optional length; + + /** + * @en + * Segment count on X-axis. + * @zh + * 宽度线段数。 + */ + cc::optional widthSegments; + + /** + * @en + * Segment count on Y-axis. + * @zh + * 高度线段数。 + */ + cc::optional heightSegments; + + /** + * @en + * Segment count on Z-axis. + * @zh + * 长度线段数。 + */ + cc::optional lengthSegments; +}; + +/** + * @en + * This function generates a box with specified extents and centered at origin, + * but may be repositioned through the `center` option. + * @zh + * 生成一个立方体,其大小是定义的范围且中心在原点。 + * @param options 参数选项。 + */ +IGeometry box(const cc::optional &options = cc::nullopt); +} // namespace cc diff --git a/native/cocos/primitive/Capsule.cpp b/native/cocos/primitive/Capsule.cpp new file mode 100644 index 0000000000..ddd3f358a0 --- /dev/null +++ b/native/cocos/primitive/Capsule.cpp @@ -0,0 +1,239 @@ +/**************************************************************************** + 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 "primitive/Capsule.h" + +namespace cc { + +IGeometry capsule(float radiusTop, float radiusBottom, float height, const cc::optional &opts) { + const float torsoHeight = height - radiusTop - radiusBottom; + const uint32_t sides = opts.has_value() ? opts->sides : 32; + const uint32_t heightSegments = opts.has_value() ? opts->heightSegments : 32; + const float bottomProp = radiusBottom / height; + const float torProp = torsoHeight / height; + const float topProp = radiusTop / height; + const uint32_t bottomSegments = floor(static_cast(heightSegments) * bottomProp); + const uint32_t topSegments = floor(static_cast(heightSegments) * topProp); + const uint32_t torSegments = floor(static_cast(heightSegments) * torProp); + const float topOffset = torsoHeight + radiusBottom - height / 2; + const float torOffset = radiusBottom - height / 2; + const float bottomOffset = radiusBottom - height / 2; + + const float arc = opts.has_value() ? opts->arc : math::PI_2; + + // calculate vertex count + std::vector positions; + std::vector normals; + std::vector uvs; + std::vector indices; + const float maxRadius = std::max(radiusTop, radiusBottom); + const Vec3 minPos(-maxRadius, -height / 2, -maxRadius); + const Vec3 maxPos(maxRadius, height / 2, maxRadius); + const float boundingRadius = height / 2; + + uint32_t index = 0; + std::vector> indexArray; + + // ======================= + // internal functions + // ======================= + auto generateTorso = [&]() { + // this will be used to calculate the normal + float slope = (radiusTop - radiusBottom) / torsoHeight; + + // generate positions, normals and uvs + for (uint32_t y = 0; y <= torSegments; y++) { + std::vector indexRow; + const float lat = static_cast(y) / static_cast(torSegments); + const float radius = lat * (radiusTop - radiusBottom) + radiusBottom; + + for (uint32_t x = 0; x <= sides; ++x) { + const float u = static_cast(x) / static_cast(sides); + const float v = lat * torProp + bottomProp; + const float theta = u * arc - (arc / 4); + + const float sinTheta = sin(theta); + const float cosTheta = cos(theta); + + // vertex + positions.emplace_back(radius * sinTheta); + positions.emplace_back(lat * torsoHeight + torOffset); + positions.emplace_back(radius * cosTheta); + + // normal + Vec3 temp1(sinTheta, -slope, cosTheta); + temp1.normalize(); + + normals.emplace_back(temp1.x); + normals.emplace_back(temp1.y); + normals.emplace_back(temp1.z); + + // uv + uvs.emplace_back(u); + uvs.emplace_back(v); + // save index of vertex in respective row + indexRow.emplace_back(index); + + // increase index + ++index; + } + + // now save positions of the row in our index array + indexArray.emplace_back(indexRow); + } + + // generate indices + for (uint32_t y = 0; y < torSegments; ++y) { + for (uint32_t x = 0; x < sides; ++x) { + // we use the index array to access the correct indices + const uint32_t i1 = indexArray[y][x]; + const uint32_t i2 = indexArray[y + 1][x]; + const uint32_t i3 = indexArray[y + 1][x + 1]; + const uint32_t i4 = indexArray[y][x + 1]; + + // face one + indices.emplace_back(i1); + indices.emplace_back(i4); + indices.emplace_back(i2); + + // face two + indices.emplace_back(i4); + indices.emplace_back(i3); + indices.emplace_back(i2); + } + } + }; + + auto generateBottom = [&]() { + for (uint32_t lat = 0; lat <= bottomSegments; ++lat) { + float theta = static_cast(lat) * math::PI / static_cast(bottomSegments) / 2; + float sinTheta = sin(theta); + float cosTheta = -cos(theta); + + for (uint32_t lon = 0; lon <= sides; ++lon) { + const float phi = static_cast(lon) * math::PI_2 / static_cast(sides) - math::PI / 2; + const float sinPhi = sin(phi); + const float cosPhi = cos(phi); + + const float x = sinPhi * sinTheta; + const float y = cosTheta; + const float z = cosPhi * sinTheta; + const float u = static_cast(lon) / static_cast(sides); + const float v = static_cast(lat) / static_cast(heightSegments); + + positions.emplace_back(x * radiusBottom); + positions.emplace_back(y * radiusBottom + bottomOffset); + positions.emplace_back(z * radiusBottom); + + normals.emplace_back(x); + normals.emplace_back(y); + normals.emplace_back(z); + uvs.emplace_back(u); + uvs.emplace_back(v); + + if ((lat < bottomSegments) && (lon < sides)) { + const uint32_t seg1 = sides + 1; + const uint32_t a = seg1 * lat + lon; + const uint32_t b = seg1 * (lat + 1) + lon; + const uint32_t c = seg1 * (lat + 1) + lon + 1; + const uint32_t d = seg1 * lat + lon + 1; + + indices.emplace_back(a); + indices.emplace_back(d); + indices.emplace_back(b); + + indices.emplace_back(d); + indices.emplace_back(c); + indices.emplace_back(b); + } + + ++index; + } + } + }; + + auto generateTop = [&]() { + for (uint32_t lat = 0; lat <= topSegments; ++lat) { + const float theta = static_cast(lat) * math::PI / static_cast(topSegments) / 2 + math::PI / 2; + const float sinTheta = sin(theta); + const float cosTheta = -cos(theta); + + for (uint32_t lon = 0; lon <= sides; ++lon) { + const float phi = static_cast(lon) * 2 * math::PI / static_cast(sides) - math::PI / 2; + const float sinPhi = sin(phi); + const float cosPhi = cos(phi); + const float x = sinPhi * sinTheta; + const float y = cosTheta; + const float z = cosPhi * sinTheta; + const float u = static_cast(lon) / static_cast(sides); + const float v = static_cast(lat) / static_cast(heightSegments) + (1 - topProp); + + positions.emplace_back(x * radiusTop); + positions.emplace_back(y * radiusTop + topOffset); + positions.emplace_back(z * radiusTop); + + normals.emplace_back(x); + normals.emplace_back(y); + normals.emplace_back(z); + uvs.emplace_back(u); + uvs.emplace_back(v); + + if ((lat < topSegments) && (lon < sides)) { + const uint32_t seg1 = sides + 1; + const uint32_t a = seg1 * lat + lon + indexArray[torSegments][sides] + 1; + const uint32_t b = seg1 * (lat + 1) + lon + indexArray[torSegments][sides] + 1; + const uint32_t c = seg1 * (lat + 1) + lon + 1 + indexArray[torSegments][sides] + 1; + const uint32_t d = seg1 * lat + lon + 1 + indexArray[torSegments][sides] + 1; + + indices.emplace_back(a); + indices.emplace_back(d); + indices.emplace_back(b); + + indices.emplace_back(d); + indices.emplace_back(c); + indices.emplace_back(b); + } + } + } + }; + + generateBottom(); + + generateTorso(); + + generateTop(); + + IGeometry info; + info.positions = positions; + info.normals = normals; + info.uvs = uvs; + info.boundingRadius = boundingRadius; + info.minPos = minPos; + info.maxPos = maxPos; + info.indices = indices; + return info; +} + +} // namespace cc \ No newline at end of file diff --git a/native/cocos/primitive/Capsule.h b/native/cocos/primitive/Capsule.h new file mode 100644 index 0000000000..6c6af2f458 --- /dev/null +++ b/native/cocos/primitive/Capsule.h @@ -0,0 +1,54 @@ +/**************************************************************************** + 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 "primitive/PrimitiveDefine.h" +namespace cc { +/** + * @en + * The definition of the parameter for building a capsule. + * @zh + * 胶囊体参数选项。 + */ +struct ICapsuleOptions { + uint32_t sides{32}; + uint32_t heightSegments{32}; + bool capped{true}; + float arc{math::PI_2}; +}; + +/** + * Generate a capsule with radiusTop radiusBottom 0.5, height 2, centered at origin, + * but may be repositioned through the `center` option. + * @zh + * 生成一个胶囊体。 + * @param radiusTop 顶部半径。 + * @param radiusBottom 底部半径。 + * @param opts 胶囊体参数选项。 + */ +IGeometry capsule(float radiusTop = 0.5, float radiusBottom = 0.5, float height = 2, const cc::optional &opts = cc::nullopt); + +} // namespace cc diff --git a/native/cocos/primitive/Circle.cpp b/native/cocos/primitive/Circle.cpp new file mode 100644 index 0000000000..ecc5481858 --- /dev/null +++ b/native/cocos/primitive/Circle.cpp @@ -0,0 +1,65 @@ +/**************************************************************************** + 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 "primitive/Circle.h" +#include "gfx-base/GFXDef-common.h" + +namespace cc { +IGeometry circle(cc::optional &options) { + if (!options.has_value()) options = ICircleOptions(); + const uint32_t segments = options->segments; + std::vector positions(3 * (segments + 1)); + positions[0] = 0; + positions[1] = 0; + positions[2] = 0; + std::vector indices(1 + segments * 2); + indices[0] = 0; + const float step = math::PI * 2 / static_cast(segments); + for (uint32_t iSegment = 0; iSegment < segments; ++iSegment) { + const float angle = step * static_cast(iSegment); + const float x = cos(angle); + const float y = sin(angle); + const uint32_t p = (iSegment + 1) * 3; + positions[p + 0] = x; + positions[p + 1] = y; + positions[p + 2] = 0; + const uint32_t i = iSegment * 2; + indices[1 + (i)] = iSegment + 1; + indices[1 + (i + 1)] = iSegment + 2; + } + if (segments > 0) { + indices[indices.size() - 1] = 1; + } + + IGeometry info; + info.positions = positions; + info.boundingRadius = 1; + info.minPos = Vec3(1, 1, 0); + info.maxPos = Vec3(-1, -1, 0); + info.indices = indices; + info.primitiveMode = gfx::PrimitiveMode::TRIANGLE_FAN; + return info; +} +} // namespace cc \ No newline at end of file diff --git a/native/cocos/primitive/Circle.h b/native/cocos/primitive/Circle.h new file mode 100644 index 0000000000..9b77f78806 --- /dev/null +++ b/native/cocos/primitive/Circle.h @@ -0,0 +1,52 @@ +/**************************************************************************** + 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 "primitive/PrimitiveDefine.h" + +namespace cc { +/** + * @en + * The definition of the parameter for building a circle. + * @zh + * 圆形参数选项。 + */ +struct ICircleOptions : public IGeometryOptions { + // The segments. Default to 64. + uint32_t segments{64}; +}; + +/** + * @en + * Generate a circle with radius 1, centered at origin, + * but may be repositioned through the `center` option. + * @zh + * 生成一个圆,其半径是单位1,中心点在原点。 + * @param options 参数选项。 + */ +IGeometry circle(cc::optional &options); + +} // namespace cc diff --git a/native/cocos/primitive/Cone.cpp b/native/cocos/primitive/Cone.cpp new file mode 100644 index 0000000000..45eeba124f --- /dev/null +++ b/native/cocos/primitive/Cone.cpp @@ -0,0 +1,34 @@ +/**************************************************************************** + 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 "primitive/Cone.h" + +namespace cc { + +IGeometry cone(float radius, float height, const cc::optional &opts) { + return cylinder(0, radius, height, opts); +} + +} // namespace cc diff --git a/native/cocos/primitive/Cone.h b/native/cocos/primitive/Cone.h new file mode 100644 index 0000000000..48a2a15908 --- /dev/null +++ b/native/cocos/primitive/Cone.h @@ -0,0 +1,42 @@ +/**************************************************************************** + 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 "primitive/Cylinder.h" +#include "primitive/PrimitiveDefine.h" + +namespace cc { + +/** + * @en + * The definition of the parameter for building a cylinder. + * @zh + * 圆锥参数选项。 + */ +using IConeOptions = ICylinderOptions; + +IGeometry cone(float radius = 0.5F, float height = 1.0F, const cc::optional &opts = cc::nullopt); + +} // namespace cc diff --git a/native/cocos/primitive/Cylinder.cpp b/native/cocos/primitive/Cylinder.cpp new file mode 100644 index 0000000000..7712fa0c0e --- /dev/null +++ b/native/cocos/primitive/Cylinder.cpp @@ -0,0 +1,266 @@ +/**************************************************************************** + 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 "primitive/Cylinder.h" + +namespace cc { + +float sign(float v) { + return (v < 0 ? -1.0F : (v > 0 ? 1.0F : 0.0F)); +} + +IGeometry cylinder(float radiusTop, float radiusBottom, float height, const cc::optional &opts) { + const float halfHeight = height * 0.5F; + const uint32_t radialSegments = opts.has_value() ? opts->radialSegments : 32; + const uint32_t heightSegments = opts.has_value() ? opts->heightSegments : 1; + const bool capped = opts.has_value() ? opts->capped : true; + const float arc = opts.has_value() ? opts->arc : math::PI_2; + + uint32_t cntCap = 0; + if (capped) { + if (radiusTop > 0) { + ++cntCap; + } + + if (radiusBottom > 0) { + ++cntCap; + } + } + + // calculate vertex count + uint32_t vertCount = (radialSegments + 1) * (heightSegments + 1); + if (capped) { + vertCount += ((radialSegments + 1) * cntCap) + (radialSegments * cntCap); + } + + // calculate index count + uint32_t indexCount = radialSegments * heightSegments * 2 * 3; + if (capped) { + indexCount += radialSegments * cntCap * 3; + } + + std::vector indices(indexCount); + std::vector positions(vertCount * 3); + std::vector normals(vertCount * 3); + std::vector uvs(vertCount * 2); + const float maxRadius = std::max(radiusTop, radiusBottom); + const Vec3 minPos(-maxRadius, -halfHeight, -maxRadius); + const Vec3 maxPos(maxRadius, halfHeight, maxRadius); + const float boundingRadius = sqrt(maxRadius * maxRadius + halfHeight * halfHeight); + + uint32_t index = 0; + uint32_t indexOffset = 0; + + // ======================= + // internal functions + // ======================= + auto generateTorso = [&]() { + std::vector> indexArray; + + // this will be used to calculate the normal + const float r = radiusTop - radiusBottom; + + const float slope = r * r / height * sign(r); + // generate positions, normals and uvs + for (uint32_t y = 0; y <= heightSegments; y++) { + std::vector indexRow; + const float v = static_cast(y) / static_cast(heightSegments); + + // calculate the radius of the current row + const float radius = v * r + radiusBottom; + + for (uint32_t x = 0; x <= radialSegments; ++x) { + const float u = static_cast(x) / static_cast(radialSegments); + const float theta = u * arc; + + const float sinTheta = sin(theta); + const float cosTheta = cos(theta); + + // vertex + positions[3 * index] = radius * sinTheta; + positions[3 * index + 1] = v * height - halfHeight; + positions[3 * index + 2] = radius * cosTheta; + + // normal + Vec3 temp1(sinTheta, -slope, cosTheta); + temp1.normalize(); + + normals[3 * index] = temp1.x; + normals[3 * index + 1] = temp1.y; + normals[3 * index + 2] = temp1.z; + + // uv + uvs[2 * index] = fmod((1 - u) * 2.0F, 1.0F); + uvs[2 * index + 1] = v; + + // save index of vertex in respective row + indexRow.emplace_back(index); + + // increase index + ++index; + } + + // now save positions of the row in our index array + indexArray.emplace_back(indexRow); + } + + // generate indices + for (uint32_t y = 0; y < heightSegments; ++y) { + for (uint32_t x = 0; x < radialSegments; ++x) { + // we use the index array to access the correct indices + const uint32_t i1 = indexArray[y][x]; + const uint32_t i2 = indexArray[y + 1][x]; + const uint32_t i3 = indexArray[y + 1][x + 1]; + const uint32_t i4 = indexArray[y][x + 1]; + + // face one + indices[indexOffset] = i1; + ++indexOffset; + indices[indexOffset] = i4; + ++indexOffset; + indices[indexOffset] = i2; + ++indexOffset; + + // face two + indices[indexOffset] = i4; + ++indexOffset; + indices[indexOffset] = i3; + ++indexOffset; + indices[indexOffset] = i2; + ++indexOffset; + } + } + }; + + auto generateCap = [&](bool top) { + const float radius = top ? radiusTop : radiusBottom; + const float sign = top ? 1 : -1; + + // save the index of the first center vertex + const uint32_t centerIndexStart = index; + + // first we generate the center vertex data of the cap. + // because the geometry needs one set of uvs per face, + // we must generate a center vertex per face/segment + + for (uint32_t x = 1; x <= radialSegments; ++x) { + // vertex + positions[3 * index] = 0; + positions[3 * index + 1] = halfHeight * sign; + positions[3 * index + 2] = 0; + + // // normal + normals[3 * index] = 0; + normals[3 * index + 1] = sign; + normals[3 * index + 2] = 0; + + // uv + uvs[2 * index] = 0.5; + uvs[2 * index + 1] = 0.5; + + // increase index + ++index; + } + + // save the index of the last center vertex + const uint32_t centerIndexEnd = index; + + // now we generate the surrounding positions, normals and uvs + + for (uint32_t x = 0; x <= radialSegments; ++x) { + const float u = static_cast(x) / static_cast(radialSegments); + const float theta = u * arc; + + const float cosTheta = cos(theta); + const float sinTheta = sin(theta); + + // vertex + positions[3 * index] = radius * sinTheta; + positions[3 * index + 1] = halfHeight * sign; + positions[3 * index + 2] = radius * cosTheta; + + // normal + normals[3 * index] = 0; + normals[3 * index + 1] = sign; + normals[3 * index + 2] = 0; + + // uv + uvs[2 * index] = 0.5F - (sinTheta * 0.5F * sign); + uvs[2 * index + 1] = 0.5F + (cosTheta * 0.5F); + + // increase index + ++index; + } + + // generate indices + + for (uint32_t x = 0; x < radialSegments; ++x) { + const uint32_t c = centerIndexStart + x; + const uint32_t i = centerIndexEnd + x; + + if (top) { + // face top + indices[indexOffset] = i + 1; + ++indexOffset; + indices[indexOffset] = c; + ++indexOffset; + indices[indexOffset] = i; + ++indexOffset; + } else { + // face bottom + indices[indexOffset] = c; + ++indexOffset; + indices[indexOffset] = i + 1; + ++indexOffset; + indices[indexOffset] = i; + ++indexOffset; + } + } + }; + + generateTorso(); + + if (capped) { + if (radiusBottom > 0) { + generateCap(false); + } + + if (radiusTop > 0) { + generateCap(true); + } + } + + IGeometry info; + info.positions = positions; + info.normals = normals; + info.uvs = uvs; + info.boundingRadius = boundingRadius; + info.minPos = minPos; + info.maxPos = maxPos; + info.indices = indices; + return info; +} + +} // namespace cc \ No newline at end of file diff --git a/native/cocos/primitive/Cylinder.h b/native/cocos/primitive/Cylinder.h new file mode 100644 index 0000000000..73448a5727 --- /dev/null +++ b/native/cocos/primitive/Cylinder.h @@ -0,0 +1,56 @@ +/**************************************************************************** + 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 +#include "3d/assets/Mesh.h" +#include "primitive/PrimitiveDefine.h" + +namespace cc { + +/** + * @zh + * 球参数选项。 + */ +struct ICylinderOptions : public IGeometryOptions { + uint32_t radialSegments{32}; + uint32_t heightSegments{1}; + bool capped{true}; + float arc{math::PI_2}; +}; + +/** + * @en + * Generate a sphere with radius 0.5. + * @zh + * 生成一个球。 + * @param radius 球半径。 + * @param options 参数选项。 + */ + +IGeometry cylinder(float radiusTop = 0.5, float radiusBottom = 0.5, float height = 2, const cc::optional &opts = cc::nullopt); + +} // namespace cc diff --git a/native/cocos/primitive/Plane.cpp b/native/cocos/primitive/Plane.cpp new file mode 100644 index 0000000000..09e6dae929 --- /dev/null +++ b/native/cocos/primitive/Plane.cpp @@ -0,0 +1,111 @@ + +/**************************************************************************** + 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 "primitive/Plane.h" +namespace cc { + +IGeometry plane(cc::optional options) { + if (!options.has_value()) { + options = IPlaneOptions(); + } + const float width = options->width; + const float length = options->length; + const uint32_t uSegments = options->widthSegments; + const uint32_t vSegments = options->lengthSegments; + + const float hw = width * 0.5F; + const float hl = length * 0.5F; + + std::vector positions; + std::vector uvs; + std::vector indices; + const Vec3 minPos(-hw, 0, -hl); + const Vec3 maxPos(hw, 0, hl); + const float boundingRadius = sqrt(width * width + length * length); + + Vec3 c00(-hw, 0, hl); + Vec3 c10(hw, 0, hl); + Vec3 c01(-hw, 0, -hl); + + for (uint32_t y = 0; y <= vSegments; ++y) { + for (uint32_t x = 0; x <= uSegments; ++x) { + const float u = static_cast(x) / static_cast(uSegments); + const float v = static_cast(y) / static_cast(vSegments); + + Vec3 temp1 = c00.lerp(c10, u); + Vec3 temp2 = c00.lerp(c01, v); + temp2.subtract(c00); + temp1.add(temp2); + + positions.emplace_back(temp1.x); + positions.emplace_back(temp1.y); + positions.emplace_back(temp1.z); + if (options->includeUV) { + uvs.emplace_back(u); + uvs.emplace_back(v); + } + + if ((x < uSegments) && (y < vSegments)) { + const uint32_t uSeg1 = uSegments + 1; + const uint32_t a = x + y * uSeg1; + const uint32_t b = x + (y + 1) * uSeg1; + const uint32_t c = (x + 1) + (y + 1) * uSeg1; + const uint32_t d = (x + 1) + y * uSeg1; + + indices.emplace_back(a); + indices.emplace_back(d); + indices.emplace_back(b); + indices.emplace_back(d); + indices.emplace_back(c); + indices.emplace_back(b); + } + } + } + + IGeometry result; + result.positions = positions; + result.boundingRadius = boundingRadius; + result.minPos = minPos; + result.maxPos = maxPos; + result.indices = indices; + + if (options->includeNormal) { + const uint32_t nVertex = (vSegments + 1) * (uSegments + 1); + std::vector normals(3 * nVertex); + for (uint32_t i = 0; i < nVertex; ++i) { + normals[i * 3 + 0] = 0; + normals[i * 3 + 1] = 1; + normals[i * 3 + 2] = 0; + } + result.normals = normals; + } + if (options->includeUV) { + result.uvs = uvs; + } + return result; +} + +} // namespace cc diff --git a/native/cocos/primitive/Plane.h b/native/cocos/primitive/Plane.h new file mode 100644 index 0000000000..cdce6e1113 --- /dev/null +++ b/native/cocos/primitive/Plane.h @@ -0,0 +1,69 @@ +/**************************************************************************** + 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 "primitive/PrimitiveDefine.h" + +namespace cc { +/** + * @en + * The definition of the parameter for building a plane. + * @zh + * 平面参数选项。 + */ +struct IPlaneOptions : public IGeometryOptions { + /** + * Plane extent on X-axis. Default to 10. + */ + float width{10}; + + /** + * Plane extent on Z-axis. Default to 10. + */ + float length{10}; + + /** + * Segment count on X-axis. Default to 10. + */ + uint32_t widthSegments{10}; + + /** + * Segment count on Z-axis. Default to 10. + */ + uint32_t lengthSegments{10}; +}; + +/** + * @en + * This function generates a plane on XOZ plane with positive Y direction. + * @zh + * 生成一个平面,其位于XOZ平面,方向为Y轴正方向。 + * @param options 平面参数选项。 + */ + +IGeometry plane(cc::optional options = cc::nullopt); + +} // namespace cc diff --git a/native/cocos/primitive/Primitive.cpp b/native/cocos/primitive/Primitive.cpp new file mode 100644 index 0000000000..ef6aa8fdcb --- /dev/null +++ b/native/cocos/primitive/Primitive.cpp @@ -0,0 +1,78 @@ +/**************************************************************************** + 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 "primitive/Primitive.h" +#include "3d/misc/CreateMesh.h" + +namespace cc { + +Primitive::Primitive(PrimitiveType type) +: Mesh(), type(type) { +} + +void Primitive::onLoaded() { + reset(createMeshInfo(createGeometry(type))); +} + +IGeometry createGeometry(PrimitiveType type, const cc::optional &options) { + switch (type) { + case PrimitiveType::BOX: { + return options.has_value() ? box(cc::get(options.value())) : box(); + break; + } + case PrimitiveType::SPHERE: { + return sphere(); //TODO(xwx): now for test, need to add options usage + break; + } + case PrimitiveType::CYLINDER: { + return cylinder(); //TODO(xwx): now for test, need to add options usage + break; + } + case PrimitiveType::CONE: { + return cone(); //TODO(xwx): now for test, need to add options usage + break; + } + case PrimitiveType::CAPSULE: { + return capsule(); //TODO(xwx): now for test, need to add options usage + break; + } + case PrimitiveType::TORUS: { + return torus(); //TODO(xwx): now for test, need to add options usage + break; + } + case PrimitiveType::PLANE: { + return options.has_value() ? quad(cc::get(options.value())) : plane(); + break; + } + case PrimitiveType::QUAD: { + return options.has_value() ? quad(cc::get(options.value())) : quad(); + break; + } + default: + break; + } + return box(); +} + +} // namespace cc diff --git a/native/cocos/primitive/Primitive.h b/native/cocos/primitive/Primitive.h new file mode 100644 index 0000000000..2497a25b21 --- /dev/null +++ b/native/cocos/primitive/Primitive.h @@ -0,0 +1,99 @@ +/**************************************************************************** + 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 "cocos/base/Optional.h" + +#include "3d/assets/Mesh.h" +#include "cocos/base/Variant.h" +#include "primitive/Box.h" +#include "primitive/Capsule.h" +#include "primitive/Circle.h" +#include "primitive/Cone.h" +#include "primitive/Cylinder.h" +#include "primitive/Plane.h" +#include "primitive/Quad.h" +#include "primitive/Sphere.h" +#include "primitive/Torus.h" + +#include "primitive/PrimitiveDefine.h" +namespace cc { + +using PrimitiveOptions = cc::variant; +enum class PrimitiveType { + BOX = 0, + SPHERE = 1, + CYLINDER = 2, + CONE = 3, + CAPSULE = 4, + TORUS = 5, + PLANE = 6, + QUAD = 7, +}; + +/** + * @en + * Basic primitive mesh, this can be generate some primitive mesh at runtime. + * @zh + * 基础图形网格,可以在运行时构建一些基础的网格。 + */ +class Primitive : public Mesh { +public: + /** + * @en + * The type of the primitive mesh, set it before you call onLoaded. + * @zh + * 此基础图形网格的类型,请在 onLoaded 调用之前设置。 + */ + // @type(PrimitiveType) + PrimitiveType type{PrimitiveType::BOX}; + + /** + * @en + * The option for build the primitive mesh, set it before you call onLoaded. + * @zh + * 创建此基础图形网格的可选参数,请在 onLoaded 调用之前设置。 + */ + // @serializable + // @editable + Record info; //cjh float? + + explicit Primitive(PrimitiveType type = PrimitiveType::BOX); + ~Primitive() override = default; + /** + * @en + * Construct the primitive mesh with `type` and `info`. + * @zh + * 根据`type`和`info`构建相应的网格。 + */ + void onLoaded() override; + +private: + CC_DISALLOW_COPY_MOVE_ASSIGN(Primitive); +}; + +IGeometry createGeometry(PrimitiveType type, const cc::optional &options = cc::nullopt); + +} // namespace cc diff --git a/native/cocos/primitive/PrimitiveDefine.h b/native/cocos/primitive/PrimitiveDefine.h new file mode 100644 index 0000000000..1bf9749206 --- /dev/null +++ b/native/cocos/primitive/PrimitiveDefine.h @@ -0,0 +1,172 @@ +/**************************************************************************** + 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 +#include "cocos/base/Optional.h" + +#include "renderer/gfx-base/GFXDef.h" + +#include "math/Vec3.h" +#include "math/Vec4.h" + +namespace cc { + +/** + * @en + * The definition of the parameter for building a primitive geometry. + * @zh + * 几何体参数选项。 + */ +struct IGeometryOptions { + /** + * @en + * Whether to include normal. Default to true. + * @zh + * 是否包含法线。默认为true。 + */ + bool includeNormal{true}; + + /** + * @en + * Whether to include uv. Default to true. + * @zh + * 是否包含UV。默认为true。 + */ + bool includeUV{true}; +}; + +/** + * @en + * The definition of the geometry, this struct can build a mesh. + * @zh + * 几何体信息。 + */ +struct IGeometry { + /** + * @en + * Vertex positions. + * @zh + * 顶点位置。 + */ + std::vector positions; + + /** + * @en + * Vertex normals. + * @zh + * 顶点法线。 + */ + cc::optional> normals; + + /** + * @en + * Texture coordinates. + * @zh + * 纹理坐标。 + */ + cc::optional> uvs; + + /** + * @en + * Vertex Tangents. + * @zh + * 顶点切线。 + */ + cc::optional> tangents; + + /** + * @en + * Vertex colors. + * @zh + * 顶点颜色。 + */ + cc::optional> colors; + + /** + * @en + * specify vertex attributes, use (positions|normals|uvs|colors) as keys + * @zh + * 顶点属性。 + */ + cc::optional attributes; + + struct CustomAttribute { + gfx::Attribute attr; + std::vector values; + }; + + cc::optional> customAttributes; + + /** + * @en + * Bounding sphere radius. + * @zh + * 包围球半径。 + */ + cc::optional boundingRadius; + + /** + * @en + * Min position. + * @zh + * 最小位置。 + */ + cc::optional minPos; + + /** + * @en + * Max position. + * @zh + * 最大位置。 + */ + cc::optional maxPos; + + /** + * @en + * Geometry indices, if one needs indexed-draw. + * @zh + * 几何索引,当使用索引绘制时。 + */ + cc::optional> indices; //cjh uint16_t ? + + /** + * @en + * Topology of the geometry vertices. Default is TRIANGLE_LIST. + * @zh + * 几何顶点的拓扑图元。默认值是TRIANGLE_LIST。 + */ + cc::optional primitiveMode; + + /** + * @en + * whether rays casting from the back face of this geometry could collide with it + * @zh + * 是否是双面,用于判断来自于几何体背面的射线检测。 + */ + cc::optional doubleSided; +}; + +} // namespace cc diff --git a/native/cocos/primitive/PrimitiveUtils.cpp b/native/cocos/primitive/PrimitiveUtils.cpp new file mode 100644 index 0000000000..e69de29bb2 diff --git a/native/cocos/primitive/PrimitiveUtils.h b/native/cocos/primitive/PrimitiveUtils.h new file mode 100644 index 0000000000..1449737744 --- /dev/null +++ b/native/cocos/primitive/PrimitiveUtils.h @@ -0,0 +1,30 @@ +/**************************************************************************** + 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 + +namespace cc { + +} diff --git a/native/cocos/primitive/Quad.cpp b/native/cocos/primitive/Quad.cpp new file mode 100644 index 0000000000..867bd31850 --- /dev/null +++ b/native/cocos/primitive/Quad.cpp @@ -0,0 +1,55 @@ +/**************************************************************************** + 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 "primitive/Quad.h" +namespace cc { +IGeometry quad(cc::optional options) { + if (!options.has_value()) { + options = IGeometryOptions(); + } + IGeometry result; + result.positions = std::vector{-0.5, -0.5, 0, -0.5, 0.5, 0, 0.5, 0.5, 0, 0.5, -0.5, 0}; + result.boundingRadius = sqrt(0.5 * 0.5 + 0.5 * 0.5); + result.minPos = Vec3(-0.5, -0.5, 0); + result.maxPos = Vec3(0.5, 0.5, 0); + result.indices = std::vector{0, 3, 1, 3, 2, 1}; + if (options->includeNormal) { + result.normals = std::vector{ + 0, 0, 1, + 0, 0, 1, + 0, 0, 1, + 0, 0, 1}; + } + if (options->includeUV) { + result.uvs = std::vector{ + 0, 0, + 0, 1, + 1, 1, + 1, 0}; + } + return result; +} + +} // namespace cc diff --git a/native/cocos/primitive/Quad.h b/native/cocos/primitive/Quad.h new file mode 100644 index 0000000000..304efc8bf2 --- /dev/null +++ b/native/cocos/primitive/Quad.h @@ -0,0 +1,39 @@ +/**************************************************************************** + 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 "primitive/PrimitiveDefine.h" +namespace cc { +/** + * @en + * Generate a quad with width and height both to 1, centered at origin. + * @zh + * 生成一个四边形,宽高都为1,中心在原点。 + * @param options 参数选项。 + */ + +IGeometry quad(cc::optional options = cc::nullopt); +} // namespace cc diff --git a/native/cocos/primitive/Sphere.cpp b/native/cocos/primitive/Sphere.cpp new file mode 100644 index 0000000000..b847419747 --- /dev/null +++ b/native/cocos/primitive/Sphere.cpp @@ -0,0 +1,99 @@ +/**************************************************************************** + 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 "primitive/Sphere.h" + +namespace cc { +IGeometry sphere(float radius, const cc::optional &opts) { + const uint32_t segments = opts.has_value() ? opts->segments : 32; + + // lat === latitude + // lon === longitude + + std::vector positions; + std::vector normals; + std::vector uvs; + std::vector indices; + const Vec3 minPos(-radius, -radius, -radius); + const Vec3 maxPos(radius, radius, radius); + const float boundingRadius = radius; + + for (uint32_t lat = 0; lat <= segments; lat++) { + const float theta = static_cast(lat) * math::PI / static_cast(segments); + const float sinTheta = sin(theta); + const float cosTheta = -cos(theta); + + for (uint32_t lon = 0; lon <= segments; ++lon) { + const float phi = static_cast(lon) * 2.F * math::PI / static_cast(segments) - math::PI / 2.F; + const float sinPhi = sin(phi); + const float cosPhi = cos(phi); + + const float x = sinPhi * sinTheta; + const float y = cosTheta; + const float z = cosPhi * sinTheta; + const float u = static_cast(lon) / static_cast(segments); + const float v = static_cast(lat) / static_cast(segments); + + positions.emplace_back(x * radius); + positions.emplace_back(y * radius); + positions.emplace_back(z * radius); + + normals.emplace_back(x); + normals.emplace_back(y); + normals.emplace_back(z); + + uvs.emplace_back(u); + uvs.emplace_back(v); + + if ((lat < segments) && (lon < segments)) { + const uint32_t seg1 = segments + 1; + const uint32_t a = seg1 * lat + lon; + const uint32_t b = seg1 * (lat + 1) + lon; + const uint32_t c = seg1 * (lat + 1) + lon + 1; + const uint32_t d = seg1 * lat + lon + 1; + + indices.emplace_back(a); + indices.emplace_back(d); + indices.emplace_back(b); + + indices.emplace_back(d); + indices.emplace_back(c); + indices.emplace_back(b); + } + } + } + + IGeometry info; + info.positions = positions; + info.normals = normals; + info.uvs = uvs; + info.boundingRadius = boundingRadius; + info.minPos = minPos; + info.maxPos = maxPos; + info.indices = indices; + return info; +} + +} // namespace cc diff --git a/native/cocos/primitive/Sphere.h b/native/cocos/primitive/Sphere.h new file mode 100644 index 0000000000..680f4b1ff4 --- /dev/null +++ b/native/cocos/primitive/Sphere.h @@ -0,0 +1,53 @@ +/**************************************************************************** + 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 +#include "3d/assets/Mesh.h" +#include "primitive/PrimitiveDefine.h" + +namespace cc { + +/** + * @zh + * 球参数选项。 + */ +struct ISphereOptions : public IGeometryOptions { + uint32_t segments{0}; +}; + +/** + * @en + * Generate a shpere with radius 0.5. + * @zh + * 生成一个球。 + * @param radius 球半径。 + * @param options 参数选项。 + */ + +IGeometry sphere(float radius = 0.5, const cc::optional &opts = cc::nullopt); + +} // namespace cc diff --git a/native/cocos/primitive/Torus.cpp b/native/cocos/primitive/Torus.cpp new file mode 100644 index 0000000000..16e02d4219 --- /dev/null +++ b/native/cocos/primitive/Torus.cpp @@ -0,0 +1,99 @@ +/**************************************************************************** + 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 "primitive/Torus.h" + +namespace cc { +IGeometry torus(float radius, float tube, const cc::optional &opts) { + const uint32_t radialSegments = opts.has_value() ? opts->radialSegments : 32; + const uint32_t tubularSegments = opts.has_value() ? opts->tubularSegments : 32; + const float arc = opts.has_value() ? opts->arc : math::PI_2; + + std::vector positions; + std::vector normals; + std::vector uvs; + std::vector indices; + const Vec3 minPos(-radius - tube, -tube, -radius - tube); + const Vec3 maxPos(radius + tube, tube, radius + tube); + const float boundingRadius = radius + tube; + + for (uint32_t j = 0; j <= radialSegments; j++) { + for (uint32_t i = 0; i <= tubularSegments; i++) { + const float u = static_cast(i) / static_cast(tubularSegments); + const float v = static_cast(j) / static_cast(radialSegments); + + const float u1 = u * arc; + const float v1 = v * math::PI_2; + + // vertex + const float x = (radius + tube * cos(v1)) * sin(u1); + const float y = tube * sin(v1); + const float z = (radius + tube * cos(v1)) * cos(u1); + + // this vector is used to calculate the normal + const float nx = sin(u1) * cos(v1); + const float ny = sin(v1); + const float nz = cos(u1) * cos(v1); + + positions.emplace_back(x); + positions.emplace_back(y); + positions.emplace_back(z); + normals.emplace_back(nx); + normals.emplace_back(ny); + normals.emplace_back(nz); + + uvs.emplace_back(u); + uvs.emplace_back(v); + + if ((i < tubularSegments) && (j < radialSegments)) { + const uint32_t seg1 = tubularSegments + 1; + const uint32_t a = seg1 * j + i; + const uint32_t b = seg1 * (j + 1) + i; + const uint32_t c = seg1 * (j + 1) + i + 1; + const uint32_t d = seg1 * j + i + 1; + + indices.emplace_back(a); + indices.emplace_back(d); + indices.emplace_back(b); + + indices.emplace_back(d); + indices.emplace_back(c); + indices.emplace_back(b); + } + } + } + + IGeometry info; + info.positions = positions; + info.normals = normals; + info.uvs = uvs; + info.boundingRadius = boundingRadius; + info.minPos = minPos; + info.maxPos = maxPos; + info.indices = indices; + return info; +} + +} // namespace cc diff --git a/native/cocos/primitive/Torus.h b/native/cocos/primitive/Torus.h new file mode 100644 index 0000000000..b210bd9958 --- /dev/null +++ b/native/cocos/primitive/Torus.h @@ -0,0 +1,51 @@ +/**************************************************************************** + 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 "primitive/PrimitiveDefine.h" +namespace cc { +/** + * @zh + * 环面参数选项。 + */ +struct ITorusOptions { + uint32_t radialSegments{32}; + uint32_t tubularSegments{32}; + float arc{math::PI_2}; +}; + +/** + * @en + * Generate a torus with raidus 0.4, tube 0.1 and centered at origin. + * @zh + * 生成一个环面。 + * @param radius 环面半径。 + * @param tube 管形大小。 + * @param opts 参数选项。 + */ +IGeometry torus(float radius = 0.4, float tube = 0.1, const cc::optional &opts = cc::nullopt); + +} // namespace cc diff --git a/native/cocos/primitive/Transform.cpp b/native/cocos/primitive/Transform.cpp new file mode 100644 index 0000000000..fd909c9da9 --- /dev/null +++ b/native/cocos/primitive/Transform.cpp @@ -0,0 +1,128 @@ +/**************************************************************************** + 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 "primitive/Transform.h" + +namespace cc { +IGeometry translate(IGeometry &geometry, const cc::optional &offset) { + const float x = offset.has_value() ? offset->x : 0; + const float y = offset.has_value() ? offset->y : 0; + const float z = offset.has_value() ? offset->z : 0; + + const uint32_t nVertex = floor(geometry.positions.size() / 3); + + for (uint32_t iVertex = 0; iVertex < nVertex; ++iVertex) { + const uint32_t iX = iVertex * 3; + const uint32_t iY = iVertex * 3 + 1; + const uint32_t iZ = iVertex * 3 + 2; + geometry.positions[iX] += x; + geometry.positions[iY] += y; + geometry.positions[iZ] += z; + } + + if (geometry.minPos.has_value()) { + geometry.minPos->x += x; + geometry.minPos->y += y; + geometry.minPos->z += z; + } + + if (geometry.maxPos.has_value()) { + geometry.maxPos->x += x; + geometry.maxPos->y += y; + geometry.maxPos->z += z; + } + + return geometry; +} + +IGeometry scale(IGeometry &geometry, const cc::optional &value) { + const float x = value.has_value() ? value->x : 0; + const float y = value.has_value() ? value->y : 0; + const float z = value.has_value() ? value->z : 0; + + const uint32_t nVertex = floor(geometry.positions.size() / 3); + + for (uint32_t iVertex = 0; iVertex < nVertex; ++iVertex) { + const uint32_t iX = iVertex * 3; + const uint32_t iY = iVertex * 3 + 1; + const uint32_t iZ = iVertex * 3 + 2; + geometry.positions[iX] += x; + geometry.positions[iY] += y; + geometry.positions[iZ] += z; + } + + if (geometry.minPos.has_value()) { + geometry.minPos->x += x; + geometry.minPos->y += y; + geometry.minPos->z += z; + } + + if (geometry.maxPos.has_value()) { + geometry.maxPos->x += x; + geometry.maxPos->y += y; + geometry.maxPos->z += z; + } + geometry.boundingRadius = std::max(std::max(x, y), z); + + return geometry; +} + +IGeometry wireframed(IGeometry &geometry) { + const auto indices = geometry.indices; + if (!indices.has_value()) { + return geometry; + } + + // We only support triangles' wireframe. + if (geometry.primitiveMode.has_value() && geometry.primitiveMode.value() != gfx::PrimitiveMode::TRIANGLE_LIST) { + return geometry; + } + + // const offsets = [ [ 0, 1 ], [ 1, 2 ], [ 2, 0 ] ]; + std::vector> offsets{{0, 1}, {1, 2}, {2, 0}}; + std::vector lines; + std::unordered_map lineIDs; + for (uint32_t i = 0; i < indices->size(); i += 3) { + for (uint32_t k = 0; k < 3; ++k) { + const uint32_t i1 = (*indices)[i + offsets[k][0]]; + const uint32_t i2 = (*indices)[i + offsets[k][1]]; + + // check if we already have the line in our lines + const uint32_t id = (i1 > i2) ? ((i2 << 16) | i1) : ((i1 << 16) | i2); + if (lineIDs.find(id) == lineIDs.end()) { + lineIDs[id] = 0; + lines.emplace_back(i1); + lines.emplace_back(i2); + } + } + } + + geometry.indices = lines; + geometry.primitiveMode = gfx::PrimitiveMode::LINE_LIST; + + return geometry; +} + +} // namespace cc diff --git a/native/cocos/primitive/Transform.h b/native/cocos/primitive/Transform.h new file mode 100644 index 0000000000..9cfedc2639 --- /dev/null +++ b/native/cocos/primitive/Transform.h @@ -0,0 +1,61 @@ +/**************************************************************************** + 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 "primitive/PrimitiveDefine.h" + +namespace cc { + +/** + * @en + * Translate the geometry. + * @zh + * 平移几何体。 + * @param geometry 几何体信息。 + * @param offset 偏移量。 + */ +IGeometry translate(IGeometry &geometry, const cc::optional &offset); + +/** + * @en + * Scale the geometry. + * @zh + * 缩放几何体。 + * @param geometry 几何体信息。 + * @param value 缩放量。 + */ +IGeometry scale(IGeometry &geometry, const cc::optional &value); + +/** + * @en + * Converts geometry to wireframe mode. Only geometry with triangle topology is supported. + * @zh + * 将几何体转换为线框模式,仅支持三角形拓扑的几何体。 + * @param geometry 几何体信息。 + */ +IGeometry wireframed(IGeometry &geometry); + +} // namespace cc diff --git a/native/cocos/renderer/GFXDeviceManager.h b/native/cocos/renderer/GFXDeviceManager.h index 0b224189f0..923f826946 100644 --- a/native/cocos/renderer/GFXDeviceManager.h +++ b/native/cocos/renderer/GFXDeviceManager.h @@ -99,7 +99,7 @@ public: } static void destroy() { - CC_SAFE_DESTROY(Device::instance); + CC_SAFE_DESTROY_AND_DELETE(Device::instance); } static void addSurfaceEventListener() { diff --git a/native/cocos/renderer/core/MaterialInstance.cpp b/native/cocos/renderer/core/MaterialInstance.cpp new file mode 100644 index 0000000000..d9fa71ed59 --- /dev/null +++ b/native/cocos/renderer/core/MaterialInstance.cpp @@ -0,0 +1,92 @@ +#include "renderer/core/MaterialInstance.h" +//#include "core/components/RenderableComponent.h" +#include "renderer/core/PassInstance.h" + +namespace cc { + +MaterialInstance::MaterialInstance(const IMaterialInstanceInfo &info) { + _parent = info.parent; + // _owner = info.owner; + _subModelIdx = info.subModelIdx; + copy(_parent); +} + +void MaterialInstance::recompileShaders(const MacroRecord &overrides, index_t passIdx /* = CC_INVALID_INDEX */) { + auto &passes = *_passes; + if (passes.empty() || _effectAsset == nullptr) { + return; + } + + if (passIdx == CC_INVALID_INDEX) { + for (const auto &pass : passes) { + pass->tryCompile(overrides); + } + } else { + if (passIdx < passes.size()) { + auto *pass = passes[passIdx].get(); + pass->tryCompile(overrides); + } + } +} + +void MaterialInstance::overridePipelineStates(const PassOverrides &overrides, index_t passIdx /* = CC_INVALID_INDEX */) { + auto &passes = *_passes; + if (passes.empty() || _effectAsset == nullptr) { + return; + } + + std::vector &passInfos = _effectAsset->_techniques[getTechniqueIndex()].passes; + if (passIdx == CC_INVALID_INDEX) { + for (size_t i = 0, len = passes.size(); i < len; i++) { + auto *pass = passes[i].get(); + if (i >= _states.size()) { + _states.resize(i + 1); + } + auto &state = _states[i]; + state.overrides(IPassInfoFull(overrides)); + pass->overridePipelineStates(passInfos[pass->getPassIndex()], state); + } + } else { + if (passIdx >= _states.size()) { + _states.resize(passIdx + 1); + } + auto &state = _states[passIdx]; + state.overrides(IPassInfoFull(overrides)); + passes[passIdx]->overridePipelineStates(passInfos[passIdx], state); + } +} + +bool MaterialInstance::destroy() { + doDestroy(); + return true; +} + +std::vector> MaterialInstance::createPasses() { + std::vector> passes; + auto & parentPasses = _parent->getPasses(); + + passes.reserve(parentPasses->size()); + for (auto &parentPass : *parentPasses) { + passes.emplace_back(new PassInstance(parentPass, this)); + } + return passes; +} + +void MaterialInstance::onPassStateChange(bool dontNotify) { + _hash = Material::getHashForMaterial(this); + if (!dontNotify) { + if (_rebuildPSOCallback != nullptr) { + _rebuildPSOCallback(_subModelIdx, this); + } + + // if (_owner != nullptr) { + // _owner->onRebuildPSO(_subModelIdx, this); + // } + } +} + +void MaterialInstance::setRebuildPSOCallback(const RebuildPSOCallback &cb) { + _rebuildPSOCallback = cb; +} + +} // namespace cc diff --git a/native/cocos/renderer/core/MaterialInstance.h b/native/cocos/renderer/core/MaterialInstance.h new file mode 100644 index 0000000000..3ad03c7482 --- /dev/null +++ b/native/cocos/renderer/core/MaterialInstance.h @@ -0,0 +1,91 @@ +/**************************************************************************** + 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/TypeDef.h" +#include "cocos/base/Optional.h" + +#include "core/assets/Material.h" + +namespace cc { + +struct IMaterialInstanceInfo { + Material *parent{nullptr}; + // RenderableComponent *owner{nullptr}; + index_t subModelIdx{0}; +}; + +class PassInstance; + +/** + * @zh + * 材质实例,当有材质修改需求时,根据材质资源创建的,可任意定制的实例。 + */ +class MaterialInstance final : public Material { +public: + using Super = Material; + + explicit MaterialInstance(const IMaterialInstanceInfo &info); + + Material *getParent() const override { + return _parent.get(); + } + + // RenderableComponent *getOwner() const override { + // return _owner; + // } + + void recompileShaders(const MacroRecord &overrides) override { + MaterialInstance::recompileShaders(overrides, CC_INVALID_INDEX); + } + void recompileShaders(const MacroRecord &overrides, index_t passIdx) override; + + void overridePipelineStates(const PassOverrides &overrides) override { + MaterialInstance::overridePipelineStates(overrides, CC_INVALID_INDEX); + } + void overridePipelineStates(const PassOverrides &overrides, index_t passIdx) override; + + bool destroy() override; + + void onPassStateChange(bool dontNotify); + + // For JS + using RebuildPSOCallback = std::function; + void setRebuildPSOCallback(const RebuildPSOCallback &cb); + // + +protected: + std::vector> createPasses() override; + +private: + IntrusivePtr _parent; + // RenderableComponent *_owner{nullptr}; + index_t _subModelIdx{0}; + + RebuildPSOCallback _rebuildPSOCallback{nullptr}; +}; + +} // namespace cc diff --git a/native/cocos/renderer/core/PassInstance.cpp b/native/cocos/renderer/core/PassInstance.cpp new file mode 100644 index 0000000000..5ebbb7893e --- /dev/null +++ b/native/cocos/renderer/core/PassInstance.cpp @@ -0,0 +1,96 @@ +/**************************************************************************** + 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 "renderer/core/PassInstance.h" +#include +#include "renderer/core/ProgramLib.h" + +namespace cc { + +PassInstance::PassInstance(scene::Pass *parent, MaterialInstance *owner) : Super(parent->getRoot()), _parent(parent), _owner(owner) { + doInit(_parent->getPassInfoFull()); + for (const auto &b : _shaderInfo->blocks) { + scene::IBlockRef & block = _blocks[b.binding]; + const scene::IBlockRef &parentBlock = _parent->getBlocks()[b.binding]; + assert(block.count == parentBlock.count); + memcpy(block.data, parentBlock.data, parentBlock.count * 4); + } + + _rootBufferDirty = true; + gfx::DescriptorSet *parentDescriptorSet = _parent->getDescriptorSet(); + for (const auto &samplerTexture : _shaderInfo->samplerTextures) { + for (uint32_t i = 0; i < samplerTexture.count; ++i) { + auto *sampler = parentDescriptorSet->getSampler(samplerTexture.binding, i); + auto *texture = parentDescriptorSet->getTexture(samplerTexture.binding, i); + _descriptorSet->bindSampler(samplerTexture.binding, sampler, i); + _descriptorSet->bindTexture(samplerTexture.binding, texture, i); + } + } + Super::tryCompile(); +} + +scene::Pass *PassInstance::getParent() const { + return _parent.get(); +} + +void PassInstance::overridePipelineStates(const IPassInfo &original, const PassOverrides &override) { + _blendState.reset(); + _rs.reset(); + _depthStencilState.reset(); + + Pass::fillPipelineInfo(this, original); + Pass::fillPipelineInfo(this, IPassInfoFull(override)); + onStateChange(); +} + +bool PassInstance::tryCompile(const cc::optional &defineOverrides) { + if (defineOverrides.has_value()) { + if (!overrideMacros(_defines, defineOverrides.value())) return false; + } + bool ret = Super::tryCompile(); + onStateChange(); + return ret; +} + +void PassInstance::beginChangeStatesSilently() { + _dontNotify = true; +} + +void PassInstance::endChangeStatesSilently() { + _dontNotify = false; +} + +void PassInstance::syncBatchingScheme() { + _defines["USE_INSTANCING"] = false; + _defines["USE_BATCHING"] = false; + _batchingScheme = scene::BatchingSchemes::NONE; +} + +void PassInstance::onStateChange() { + _hash = Pass::getPassHash(this); + _owner->onPassStateChange(_dontNotify); +} + +} // namespace cc diff --git a/native/cocos/renderer/core/PassInstance.h b/native/cocos/renderer/core/PassInstance.h new file mode 100644 index 0000000000..65b54233cd --- /dev/null +++ b/native/cocos/renderer/core/PassInstance.h @@ -0,0 +1,84 @@ +/**************************************************************************** + 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 "MaterialInstance.h" +#include "cocos/base/Optional.h" +#include "scene/Pass.h" + +namespace cc { +/** + * @en A pass instance defines an variant version of the [[Pass]] + * @zh 表示 [[Pass]] 的一种特殊实例 + */ +class PassInstance final : public scene::Pass { +public: + using Super = scene::Pass; + + PassInstance(Pass *parent, MaterialInstance *owner); + ~PassInstance() override = default; + /** + * @en The parent pass + * @zh 相关联的原始 Pass + */ + scene::Pass *getParent() const; + + /** + * @en Override pipeline states with the given pass override info. + * This won't affect the original pass + * @zh 重载当前 Pass 的管线状态。这不会影响原始 Pass + * @param original The original pass info + * @param value The override pipeline state info + */ + void overridePipelineStates(const IPassInfo &original, const PassOverrides &override) override; + + bool tryCompile(const cc::optional &defineOverrides) override; + + /** + * @en Prepare to change states of the pass and do not notify the material to rebuild the pipeline state object + * @zh 开始静默修改 Pass 相关状态,不会通知材质去重新构建管线状态对象。 + */ + void beginChangeStatesSilently() override; + + /** + * @en End the silent states changing process, all state changes will be notified. + * @zh 结束静默状态修改,所有修改将会开始通知材质。 + */ + void endChangeStatesSilently() override; + +protected: + void syncBatchingScheme() override; + + void onStateChange(); + +private: + IntrusivePtr _parent; + // Weak reference. + MaterialInstance *_owner{nullptr}; + bool _dontNotify{false}; +}; + +} // namespace cc diff --git a/native/cocos/renderer/core/PassUtils.cpp b/native/cocos/renderer/core/PassUtils.cpp new file mode 100644 index 0000000000..84e0e68aae --- /dev/null +++ b/native/cocos/renderer/core/PassUtils.cpp @@ -0,0 +1,272 @@ +/**************************************************************************** + 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 "renderer/core/PassUtils.h" +#include +#include "base/Log.h" +#include "core/Types.h" +#include "gfx-base/GFXDef-common.h" +#include "math/Color.h" +#include "math/Mat3.h" +#include "math/Mat4.h" +#include "math/Vec2.h" +#include "math/Vec3.h" +#include "math/Vec4.h" +#include "renderer/gfx-base/GFXDef.h" + +namespace cc { + +const std::unordered_map type2reader = { + {gfx::Type::UNKNOWN, [](const float * /*a*/, MaterialProperty & /*v*/, index_t /*idx*/) { + CC_LOG_ERROR("type2reader unknown type"); + }}, + {gfx::Type::INT, [](const float *a, MaterialProperty &v, index_t idx) { + auto *p = cc::get_if(&v); + CC_ASSERT(p != nullptr); + p[0] = static_cast(a[idx]); + }}, + {gfx::Type::INT2, [](const float *a, MaterialProperty &v, index_t idx) { + auto *p = cc::get_if(&v); + CC_ASSERT(p != nullptr); + p->x = a[idx]; + p->y = a[idx + 1]; + }}, + {gfx::Type::INT3, [](const float *a, MaterialProperty &v, index_t idx) { + auto *p = cc::get_if(&v); + CC_ASSERT(p != nullptr); + p->x = a[idx]; + p->y = a[idx + 1]; + p->z = a[idx + 2]; + }}, + {gfx::Type::INT4, [](const float *a, MaterialProperty &v, index_t idx) { + auto *p = cc::get_if(&v); + CC_ASSERT(p != nullptr); + p->x = a[idx]; + p->y = a[idx + 1]; + p->z = a[idx + 2]; + p->w = a[idx + 3]; + }}, + {gfx::Type::FLOAT, [](const float *a, MaterialProperty &v, index_t idx) { + auto *p = cc::get_if(&v); + CC_ASSERT(p != nullptr); + p[0] = a[idx]; + }}, + {gfx::Type::FLOAT2, [](const float *a, MaterialProperty &v, index_t idx) { + auto *p = cc::get_if(&v); + CC_ASSERT(p != nullptr); + p->x = a[idx]; + p->y = a[idx + 1]; + }}, + {gfx::Type::FLOAT3, [](const float *a, MaterialProperty &v, index_t idx) { + auto *p = cc::get_if(&v); + CC_ASSERT(p != nullptr); + p->x = a[idx]; + p->y = a[idx + 1]; + p->z = a[idx + 2]; + }}, + {gfx::Type::FLOAT4, [](const float *a, MaterialProperty &v, index_t idx) { + auto *p = cc::get_if(&v); + CC_ASSERT(p != nullptr); + p->x = a[idx]; + p->y = a[idx + 1]; + p->z = a[idx + 2]; + p->w = a[idx + 3]; + }}, + {gfx::Type::MAT3, [](const float *a, MaterialProperty &v, index_t idx) { + auto *p = cc::get_if(&v); + CC_ASSERT(p != nullptr); + memcpy(&p->m[0], &a[idx], sizeof(Mat3)); + }}, + {gfx::Type::MAT4, [](const float *a, MaterialProperty &v, index_t idx) { + auto *p = cc::get_if(&v); + CC_ASSERT(p != nullptr); + memcpy(&p->m[0], &a[idx], sizeof(Mat4)); + }}, +}; + +const std::unordered_map type2writer = { + {gfx::Type::UNKNOWN, [](float * /*a*/, const MaterialProperty & /*v*/, index_t /*idx*/) { + CC_LOG_ERROR("type2writer unknown type"); + }}, + {gfx::Type::INT, [](float *a, const MaterialProperty &v, index_t idx) { + const int32_t *p = cc::get_if(&v); + const float * pFloat = nullptr; + if (p != nullptr) { + a[idx] = static_cast(*p); + } else { + pFloat = cc::get_if(&v); + if (pFloat != nullptr) { + a[idx] = static_cast(*p); + } + } + CC_ASSERT(p != nullptr || pFloat != nullptr); + }}, + {gfx::Type::INT2, [](float *a, const MaterialProperty &v, index_t idx) { + const auto *p = cc::get_if(&v); + CC_ASSERT(p != nullptr); + a[idx] = p->x; + a[idx + 1] = p->y; + }}, + {gfx::Type::INT3, [](float *a, const MaterialProperty &v, index_t idx) { + const auto *p = cc::get_if(&v); + CC_ASSERT(p != nullptr); + a[idx] = p->x; + a[idx + 1] = p->y; + a[idx + 2] = p->z; + }}, + {gfx::Type::INT4, [](float *a, const MaterialProperty &v, index_t idx) { + const auto *p = cc::get_if(&v); + CC_ASSERT(p != nullptr); + a[idx] = p->x; + a[idx + 1] = p->y; + a[idx + 2] = p->z; + a[idx + 3] = p->w; + }}, + {gfx::Type::FLOAT, [](float *a, const MaterialProperty &v, index_t idx) { + const float * p = cc::get_if(&v); + const int32_t *pInt = nullptr; + if (p != nullptr) { + a[idx] = *p; + } else { + pInt = cc::get_if(&v); + if (pInt != nullptr) { + a[idx] = static_cast(*pInt); + } + } + CC_ASSERT(p != nullptr || pInt != nullptr); + }}, + {gfx::Type::FLOAT2, [](float *a, const MaterialProperty &v, index_t idx) { + const auto *p = cc::get_if(&v); + CC_ASSERT(p != nullptr); + a[idx] = p->x; + a[idx + 1] = p->y; + }}, + {gfx::Type::FLOAT3, [](float *a, const MaterialProperty &v, index_t idx) { + if (cc::holds_alternative(v)) { + const auto &vec3 = cc::get(v); + a[idx] = vec3.x; + a[idx + 1] = vec3.y; + a[idx + 2] = vec3.z; + } else if (cc::holds_alternative(v)) { + const auto &vec4 = cc::get(v); + a[idx] = vec4.x; + a[idx + 1] = vec4.y; + a[idx + 2] = vec4.z; + } else { + assert(false); + } + }}, + {gfx::Type::FLOAT4, [](float *a, const MaterialProperty &v, index_t idx) { + if (cc::holds_alternative(v)) { + const auto &vec4 = cc::get(v); + a[idx] = vec4.x; + a[idx + 1] = vec4.y; + a[idx + 2] = vec4.z; + a[idx + 3] = vec4.w; + } else if (cc::holds_alternative(v)) { + const auto &color = cc::get(v); + Vec4 colorFloat{color.toVec4()}; + a[idx] = colorFloat.x; + a[idx + 1] = colorFloat.y; + a[idx + 2] = colorFloat.z; + a[idx + 3] = colorFloat.w; + } else if (cc::holds_alternative(v)) { + const auto &quat = cc::get(v); + a[idx] = quat.x; + a[idx + 1] = quat.y; + a[idx + 2] = quat.z; + a[idx + 3] = quat.w; + } else { + assert(false); + } + }}, + {gfx::Type::MAT3, [](float *a, const MaterialProperty &v, index_t idx) { + const auto *p = cc::get_if(&v); + CC_ASSERT(p != nullptr); + memcpy(&a[idx], &p->m[0], sizeof(Mat3)); + }}, + {gfx::Type::MAT4, [](float *a, const MaterialProperty &v, index_t idx) { + const auto *p = cc::get_if(&v); + CC_ASSERT(p != nullptr); + memcpy(&a[idx], &p->m[0], sizeof(Mat4)); + }}, +}; + +const std::vector &getDefaultFloatArrayFromType(gfx::Type type) { + static const std::vector DEFAULT_FLOAT_VALUES[] = { + {0}, + {0, 0}, + {0, 0, 0, 0}, + {1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1}}; + + switch (type) { + case gfx::Type::BOOL: + case gfx::Type::INT: + case gfx::Type::UINT: + case gfx::Type::FLOAT: + return DEFAULT_FLOAT_VALUES[0]; + case gfx::Type::BOOL2: + case gfx::Type::INT2: + case gfx::Type::UINT2: + case gfx::Type::FLOAT2: + return DEFAULT_FLOAT_VALUES[1]; + case gfx::Type::BOOL4: + case gfx::Type::INT4: + case gfx::Type::UINT4: + case gfx::Type::FLOAT4: + return DEFAULT_FLOAT_VALUES[2]; + case gfx::Type::MAT4: + return DEFAULT_FLOAT_VALUES[3]; + default: + return DEFAULT_FLOAT_VALUES[0]; + } +} + +const std::string &getDefaultStringFromType(gfx::Type type) { + static const std::string DEFAULT_TEXTURE_STR{"default-texture"}; + static const std::string DEFAULT_CUBE_TEXTURE_STR{"default-cube-texture"}; + + switch (type) { + case gfx::Type::SAMPLER2D: + return DEFAULT_TEXTURE_STR; + case gfx::Type::SAMPLER_CUBE: + return DEFAULT_CUBE_TEXTURE_STR; + default: + return DEFAULT_TEXTURE_STR; + } +} + +bool overrideMacros(MacroRecord &target, const MacroRecord &source) { + bool isDifferent = false; + for (const auto &p : source) { + if (target[p.first] != p.second) { + target[p.first] = p.second; + isDifferent = true; + } + } + return isDifferent; +} + +}; // namespace cc diff --git a/native/cocos/renderer/core/PassUtils.h b/native/cocos/renderer/core/PassUtils.h new file mode 100644 index 0000000000..dcb09c5a2f --- /dev/null +++ b/native/cocos/renderer/core/PassUtils.h @@ -0,0 +1,110 @@ +/**************************************************************************** + 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 +#include "base/TypeDef.h" +#include "cocos/base/Variant.h" +#include "core/Types.h" +#include "core/assets/TextureBase.h" + +#include "math/Color.h" +#include "math/Mat3.h" +#include "math/Mat4.h" +#include "math/Quaternion.h" +#include "math/Vec2.h" +#include "math/Vec3.h" +#include "math/Vec4.h" + +#include "renderer/gfx-base/GFXDef-common.h" +#include "renderer/gfx-base/GFXDef.h" + +namespace cc { + +constexpr uint32_t TYPE_MASK = 0xfc000000; // 6 bits => 64 types +constexpr uint32_t BINDING_MASK = 0x03f00000; // 6 bits => 64 bindings +constexpr uint32_t COUNT_MASK = 0x000ff000; // 8 bits => 256 vectors +constexpr uint32_t OFFSET_MASK = 0x00000fff; // 12 bits => 1024 vectors + +constexpr uint32_t genHandle(uint32_t binding, gfx::Type type, uint32_t count, uint32_t offset = 0) { + return ((static_cast(type) << 26) & TYPE_MASK) | + ((binding << 20) & BINDING_MASK) | + ((count << 12) & COUNT_MASK) | + (offset & OFFSET_MASK); +} + +constexpr gfx::Type getTypeFromHandle(uint32_t handle) { return static_cast((handle & TYPE_MASK) >> 26); } +constexpr uint32_t getBindingFromHandle(uint32_t handle) { return (handle & BINDING_MASK) >> 20; } +constexpr uint32_t getCountFromHandle(uint32_t handle) { return (handle & COUNT_MASK) >> 12; } +constexpr uint32_t getOffsetFromHandle(uint32_t handle) { return (handle & OFFSET_MASK); } +constexpr uint32_t customizeType(uint32_t handle, gfx::Type type) { + return (handle & ~TYPE_MASK) | ((static_cast(type) << 26) & TYPE_MASK); +} + +using MacroValue = cc::variant; + +/** + * @en Combination of preprocess macros + * @zh 预处理宏组合 + */ +using MacroRecord = Record; + +using MaterialProperty = cc::variant; + +using MaterialPropertyList = std::vector; + +using MaterialPropertyVariant = cc::variant; + +#define MATERIAL_PROPERTY_INDEX_SINGLE 1 +#define MATERIAL_PROPERTY_INDEX_LIST 2 + +using GFXTypeReaderCallback = void (*)(const float *, MaterialProperty &, index_t); +using GFXTypeWriterCallback = void (*)(float *, const MaterialProperty &, index_t); + +extern const std::unordered_map type2reader; //NOLINT(readability-identifier-naming) +extern const std::unordered_map type2writer; //NOLINT(readability-identifier-naming) + +/** + * @en Gets the default values for the given type of uniform + * @zh 根据指定的 Uniform 类型来获取默认值 + * @param type The type of the uniform + */ +const std::vector &getDefaultFloatArrayFromType(gfx::Type type); +const std::string & getDefaultStringFromType(gfx::Type type); + +/** + * @en Combination of preprocess macros + * @zh 预处理宏组合 + */ +/** + * @en Override the preprocess macros + * @zh 覆写预处理宏 + * @param target Target preprocess macros to be overridden + * @param source Preprocess macros used for override + */ +bool overrideMacros(MacroRecord &target, const MacroRecord &source); + +} // namespace cc diff --git a/native/cocos/renderer/core/ProgramLib.cpp b/native/cocos/renderer/core/ProgramLib.cpp new file mode 100644 index 0000000000..7bd0256960 --- /dev/null +++ b/native/cocos/renderer/core/ProgramLib.cpp @@ -0,0 +1,719 @@ +/**************************************************************************** + 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 "renderer/core/ProgramLib.h" +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include "base/Log.h" +#include "cocos/base/Optional.h" +#include "core/Types.h" +#include "core/assets/EffectAsset.h" +#include "renderer/core/PassUtils.h" +#include "renderer/gfx-base/GFXDef-common.h" +#include "renderer/gfx-base/GFXPipelineLayout.h" +#include "renderer/pipeline/Define.h" + +namespace cc { + +namespace { + +int32_t getBitCount(int32_t cnt) { + return std::ceil(std::log2(std::max(cnt, 2))); // std::max checks number types +} + +bool recordAsBool(const MacroRecord::mapped_type &v) { + if (cc::holds_alternative(v)) { + return cc::get(v); + } + if (cc::holds_alternative(v)) { + return cc::get(v) == "true"; + } + if (cc::holds_alternative(v)) { + return cc::get(v); + } + if (cc::holds_alternative(v)) { + return std::abs(cc::get(v)) > FLT_EPSILON; + } + return false; +} + +std::string recordAsString(const MacroRecord::mapped_type &v) { + if (cc::holds_alternative(v)) { + return cc::get(v) ? "1" : "0"; + } + if (cc::holds_alternative(v)) { + return cc::get(v); + } + if (cc::holds_alternative(v)) { + return std::to_string(cc::get(v)); + } + if (cc::holds_alternative(v)) { + return std::to_string(cc::get(v)); + } + return ""; +} + +std::string mapDefine(const IDefineInfo &info, const cc::optional &def) { + if (info.type == "boolean") { + return def.has_value() ? (recordAsBool(def.value()) ? "1" : "0") : "0"; + } + if (info.type == "string") { + return def.has_value() ? recordAsString(def.value()) : info.options.value()[0]; + } + if (info.type == "number") { + return def.has_value() ? recordAsString(def.value()) : std::to_string(info.range.value()[0]); + } + CC_LOG_WARNING("unknown define type '%s', name: %s", info.type.c_str(), info.name.c_str()); + return "-1"; // should neven happen +} + +std::vector prepareDefines(const MacroRecord &records, const std::vector &defList) { + std::vector macros{}; + for (const auto &tmp : defList) { + const auto &name = tmp.name; + auto it = records.find(name); + auto value = mapDefine(tmp, it == records.end() ? cc::nullopt : cc::optional(it->second)); + bool isDefault = it == records.end() || (cc::holds_alternative(it->second) && cc::get(it->second) == "0"); + macros.emplace_back(); + auto &info = macros.back(); + info.name = name; + info.value = value; + info.isDefault = isDefault; + } + return macros; +} + +std::string getShaderInstanceName(const std::string &name, const std::vector ¯os) { + std::stringstream ret; + ret << name; + for (const auto &cur : macros) { + if (!cur.isDefault) { + ret << "|" << cur.name << cur.value; + } + } + return ret.str(); +} + +void insertBuiltinBindings(const IProgramInfo &tmpl, ITemplateInfo &tmplInfo, const pipeline::DescriptorSetLayoutInfos &source, + const std::string &type, std::vector *outBindings) { + CC_ASSERT(type == "locals" || type == "globals"); + const auto &target = type == "globals" ? tmpl.builtins.globals : tmpl.builtins.locals; + + // Blocks + std::vector tempBlocks{}; + for (const auto &b : target.blocks) { + auto infoIt = source.blocks.find(b.name); + if (infoIt == source.blocks.end()) { + CC_LOG_WARNING("builtin UBO '%s' not available !", b.name.c_str()); + continue; + } + const auto &info = infoIt->second; + const auto bindingsIter = std::find_if(source.bindings.begin(), source.bindings.end(), [&info](const auto &bd) -> bool { return bd.binding == info.binding; }); + if (bindingsIter == source.bindings.end()) { + CC_LOG_WARNING("builtin UBO '%s' not available !", b.name.c_str()); + continue; + } + + tempBlocks.emplace_back(info); + + if (outBindings != nullptr && std::count_if(outBindings->begin(), outBindings->end(), [&bindingsIter](const auto &b) { return b.binding == bindingsIter->binding; }) == 0) { + outBindings->emplace_back(*bindingsIter); + } + } + tmplInfo.shaderInfo.blocks.insert(tmplInfo.shaderInfo.blocks.begin(), tempBlocks.begin(), tempBlocks.end()); + + // SamplerTextures + std::vector tempSamplerTextures; + for (const auto &s : target.samplerTextures) { + auto infoIt = source.samplers.find(s.name); + if (infoIt == source.samplers.end()) { + CC_LOG_WARNING("builtin samplerTexture '%s' not available !", s.name.c_str()); + continue; + } + const auto &info = infoIt->second; + const auto binding = std::find_if(source.bindings.begin(), source.bindings.end(), [&info](const auto &bd) { + return bd.binding == info.binding; + }); + if (binding == source.bindings.end() || !(binding->descriptorType & gfx::DESCRIPTOR_SAMPLER_TYPE)) { + CC_LOG_WARNING("builtin samplerTexture '%s' not available !", s.name.c_str()); + continue; + } + tempSamplerTextures.emplace_back(info); + if (outBindings != nullptr && std::count_if(outBindings->begin(), outBindings->end(), [&binding](const auto &b) { return b.binding == binding->binding; }) == 0) { + outBindings->emplace_back(*binding); + } + } + + tmplInfo.shaderInfo.samplerTextures.insert(tmplInfo.shaderInfo.samplerTextures.begin(), tempSamplerTextures.begin(), tempSamplerTextures.end()); + if (outBindings != nullptr) { + std::stable_sort(outBindings->begin(), outBindings->end(), [](const auto &a, const auto &b) { + return a.binding < b.binding; + }); + } +} + +int32_t getSize(const IBlockInfo &block) { + auto s = 0; + for (const auto &m : block.members) { + s += static_cast(getTypeSize(m.type) * m.count); + } + return s; +} + +auto genHandles(const IProgramInfo &tmpl) { + Record handleMap{}; + // block member handles + for (const auto &block : tmpl.blocks) { + const auto members = block.members; + uint32_t offset = 0; + for (const auto &uniform : members) { + handleMap[uniform.name] = genHandle(block.binding, + uniform.type, + uniform.count, + offset); + offset += (getTypeSize(uniform.type) >> 2) * uniform.count; // assumes no implicit padding, which is guaranteed by effect compiler + } + } + // samplerTexture handles + for (const auto &samplerTexture : tmpl.samplerTextures) { + handleMap[samplerTexture.name] = genHandle(samplerTexture.binding, + samplerTexture.type, + samplerTexture.count); + } + return handleMap; +} + +bool dependencyCheck(const std::vector &dependencies, const MacroRecord &defines) { + for (const auto &d : dependencies) { // NOLINT(readability-use-anyofallof) + if (d[0] == '!') { // negative dependency + if (defines.find(d.substr(1)) != defines.end()) { + return false; + } + } else if (defines.count(d) == 0 ? true : !recordAsBool(defines.at(d))) { + return false; + } + } + return true; +} + +std::vector getActiveAttributes(const IProgramInfo &tmpl, const ITemplateInfo &tmplInfo, const MacroRecord &defines) { + std::vector out{}; + const auto & attributes = tmpl.attributes; + const auto & gfxAttributes = tmplInfo.gfxAttributes; + for (auto i = 0; i < attributes.size(); i++) { + if (!dependencyCheck(attributes[i].defines, defines)) { + continue; + } + out.emplace_back(gfxAttributes[i]); + } + return out; +} + +} // namespace + +const char *getDeviceShaderVersion(const gfx::Device *device) { + switch (device->getGfxAPI()) { + case gfx::API::GLES2: + case gfx::API::WEBGL: + return "glsl1"; + case gfx::API::GLES3: + case gfx::API::WEBGL2: + return "glsl3"; + default: + return "glsl4"; + } +} + +// +static void copyDefines(const std::vector &from, std::vector &to) { + to.resize(from.size()); + for (size_t i = 0, len = from.size(); i < len; ++i) { + to[i].name = from[i].name; + to[i].type = from[i].type; + to[i].range = from[i].range; + to[i].options = from[i].options; + to[i].defaultVal = from[i].defaultVal; + } +} + +// IProgramInfo +void IProgramInfo::copyFrom(const IShaderInfo &o) { + name = o.name; + hash = o.hash; + glsl4 = o.glsl4; + glsl3 = o.glsl3; + glsl1 = o.glsl1; + builtins = o.builtins; + copyDefines(o.defines, defines); + blocks = o.blocks; + samplerTextures = o.samplerTextures; + attributes = o.attributes; + samplers = o.samplers; + textures = o.textures; + buffers = o.buffers; + images = o.images; + subpassInputs = o.subpassInputs; +} + +// +/*static*/ +ProgramLib *ProgramLib::getInstance() { + static ProgramLib instance; + return &instance; // cjh TODO: how to release it ? +} + +void ProgramLib::registerEffect(EffectAsset *effect) { + for (auto &shader : effect->_shaders) { + auto *tmpl = define(shader); + tmpl->effectName = effect->getName(); + } + + for (auto &tech : effect->_techniques) { + for (auto &pass : tech.passes) { + // grab default property declaration if there is none + if (pass.propertyIndex != CC_INVALID_INDEX && !pass.properties.has_value()) { + pass.properties = tech.passes[pass.propertyIndex].properties; + } + } + } +} + +IProgramInfo *ProgramLib::define(IShaderInfo &shader) { + auto itCurrTmpl = _templates.find(shader.name); + if (itCurrTmpl != _templates.end() && itCurrTmpl->second.hash == shader.hash) { + return &itCurrTmpl->second; + } + + IProgramInfo &tmpl = _templates[shader.name]; + tmpl.copyFrom(shader); + + // calculate option mask offset + int32_t offset = 0; + for (auto &def : tmpl.defines) { + int32_t cnt = 1; + if (def.type == "number") { + auto &range = def.range.value(); + cnt = getBitCount(range[1] - range[0] + 1); // inclusive on both ends + def.map = [=](const MacroValue &value) -> int32_t { + if (cc::holds_alternative(value)) { + return cc::get(value) - range[0]; + } + if (cc::holds_alternative(value)) { + return static_cast(cc::get(value)) - range[0]; + } + if (cc::holds_alternative(value)) { + return (cc::get(value) ? 1 : 0) - range[0]; + } + CC_ASSERT(false); // We only support macro with int32_t type now. + return 0; + }; + } else if (def.type == "string") { + cnt = getBitCount(static_cast(def.options.value().size())); + def.map = [=](const MacroValue &value) -> int32_t { + const auto *pValue = cc::get_if(&value); + if (pValue != nullptr) { + auto idx = static_cast(std::find(def.options.value().begin(), def.options.value().end(), *pValue) - def.options.value().begin()); + return std::max(0, idx); + } + return 0; + }; + } else if (def.type == "boolean") { + def.map = [](const MacroValue &value) -> int32_t { + const auto *pBool = cc::get_if(&value); + if (pBool != nullptr) { + return *pBool ? 1 : 0; + } + const auto *pFloat = cc::get_if(&value); + if (pFloat != nullptr) { + return *pFloat != 0.F ? 1 : 0; + } + const auto *pInt = cc::get_if(&value); + if (pInt != nullptr) { + return *pInt ? 1 : 0; + } + const auto *pString = cc::get_if(&value); + if (pString != nullptr) { + return *pString != "0" || !(*pString).empty() ? 1 : 0; + } + return 0; + }; + } + def.offset = offset; + offset += cnt; + } + if (offset > 31) { + tmpl.uber = true; + } + // generate constant macros + { + tmpl.constantMacros.clear(); + std::stringstream ss; + for (auto &key : tmpl.builtins.statistics) { + ss << "#define " << key.first << " " << key.second << std::endl; + } + tmpl.constantMacros = ss.str(); + } + + if (_templateInfos.count(tmpl.hash) == 0) { + ITemplateInfo tmplInfo{}; + // cache material-specific descriptor set layout + tmplInfo.samplerStartBinding = static_cast(tmpl.blocks.size()); + tmplInfo.bindings = {}; + tmplInfo.blockSizes = {}; + for (const auto &block : tmpl.blocks) { + tmplInfo.blockSizes.emplace_back(getSize(block)); + tmplInfo.bindings.emplace_back(); + auto &bindingsInfo = tmplInfo.bindings.back(); + bindingsInfo.binding = static_cast(block.binding); + bindingsInfo.descriptorType = gfx::DescriptorType::UNIFORM_BUFFER; + bindingsInfo.count = 1; + bindingsInfo.stageFlags = block.stageFlags; + std::vector uniforms; + { + // construct uniforms + uniforms.reserve(block.members.size()); + for (const auto &member : block.members) { + uniforms.emplace_back(); + auto &info = uniforms.back(); + info.name = member.name; + info.type = member.type; + info.count = member.count; + } + } + tmplInfo.shaderInfo.blocks.emplace_back(); + auto &blocksInfo = tmplInfo.shaderInfo.blocks.back(); + blocksInfo.set = static_cast(pipeline::SetIndex::MATERIAL); + blocksInfo.binding = static_cast(block.binding); + blocksInfo.name = block.name; + blocksInfo.members = uniforms; + blocksInfo.count = 1; // effect compiler guarantees block count = 1 + } + for (const auto &samplerTexture : tmpl.samplerTextures) { + tmplInfo.bindings.emplace_back(); + auto &descriptorLayoutBindingInfo = tmplInfo.bindings.back(); + descriptorLayoutBindingInfo.binding = static_cast(samplerTexture.binding); + descriptorLayoutBindingInfo.descriptorType = gfx::DescriptorType::SAMPLER_TEXTURE; + descriptorLayoutBindingInfo.count = samplerTexture.count; + descriptorLayoutBindingInfo.stageFlags = samplerTexture.stageFlags; + + tmplInfo.shaderInfo.samplerTextures.emplace_back(); + auto &samplerTextureInfo = tmplInfo.shaderInfo.samplerTextures.back(); + samplerTextureInfo.set = static_cast(pipeline::SetIndex::MATERIAL); + samplerTextureInfo.binding = static_cast(samplerTexture.binding); + samplerTextureInfo.name = samplerTexture.name; + samplerTextureInfo.type = samplerTexture.type; + samplerTextureInfo.count = samplerTexture.count; + } + + for (const auto &sampler : tmpl.samplers) { + tmplInfo.bindings.emplace_back(gfx::DescriptorSetLayoutBinding{ + static_cast(sampler.binding), + gfx::DescriptorType::SAMPLER, + sampler.count, + sampler.stageFlags}); + + tmplInfo.shaderInfo.samplers.emplace_back(gfx::UniformSampler{ + static_cast(pipeline::SetIndex::MATERIAL), + static_cast(sampler.binding), + sampler.name, + sampler.count, + }); + } + + for (const auto &texture : tmpl.textures) { + tmplInfo.bindings.emplace_back(gfx::DescriptorSetLayoutBinding{ + static_cast(texture.binding), + gfx::DescriptorType::TEXTURE, + texture.count, + texture.stageFlags}); + + tmplInfo.shaderInfo.textures.emplace_back(gfx::UniformTexture{ + static_cast(pipeline::SetIndex::MATERIAL), + static_cast(texture.binding), + texture.name, + texture.type, + texture.count, + }); + } + + for (const auto &buffer : tmpl.buffers) { + tmplInfo.bindings.emplace_back(gfx::DescriptorSetLayoutBinding{ + static_cast(buffer.binding), + gfx::DescriptorType::STORAGE_BUFFER, + 1, + buffer.stageFlags}); + + tmplInfo.shaderInfo.buffers.emplace_back(gfx::UniformStorageBuffer{ + static_cast(pipeline::SetIndex::MATERIAL), + static_cast(buffer.binding), + buffer.name, + 1, + buffer.memoryAccess}); // effect compiler guarantees buffer count = 1 + } + + for (const auto &image : tmpl.images) { + tmplInfo.bindings.emplace_back(gfx::DescriptorSetLayoutBinding{ + static_cast(image.binding), + gfx::DescriptorType::STORAGE_IMAGE, + image.count, + image.stageFlags}); + + tmplInfo.shaderInfo.images.emplace_back(gfx::UniformStorageImage{ + static_cast(pipeline::SetIndex::MATERIAL), + static_cast(image.binding), + image.name, + image.type, + image.count, + image.memoryAccess}); + } + + for (const auto &subpassInput : tmpl.subpassInputs) { + tmplInfo.bindings.emplace_back(gfx::DescriptorSetLayoutBinding{ + static_cast(subpassInput.binding), + gfx::DescriptorType::INPUT_ATTACHMENT, + subpassInput.count, + subpassInput.stageFlags}); + + tmplInfo.shaderInfo.subpassInputs.emplace_back(gfx::UniformInputAttachment{ + static_cast(pipeline::SetIndex::MATERIAL), + static_cast(subpassInput.binding), + subpassInput.name, + subpassInput.count}); + } + + tmplInfo.gfxAttributes = {}; + for (auto &attr : tmpl.attributes) { + tmplInfo.gfxAttributes.emplace_back(); + auto &info = tmplInfo.gfxAttributes.back(); + info.name = attr.name; + info.format = attr.format; + info.isNormalized = attr.isNormalized; + info.stream = 0; + info.isInstanced = attr.isInstanced; + info.location = attr.location; + } + insertBuiltinBindings(tmpl, tmplInfo, pipeline::localDescriptorSetLayout, "locals", nullptr); + + tmplInfo.shaderInfo.stages.emplace_back(); + auto &vertexShaderInfo = tmplInfo.shaderInfo.stages.back(); + vertexShaderInfo.stage = gfx::ShaderStageFlagBit::VERTEX; + vertexShaderInfo.source = ""; + tmplInfo.shaderInfo.stages.emplace_back(); + auto &fragmentShaderInfo = tmplInfo.shaderInfo.stages.back(); + fragmentShaderInfo.stage = gfx::ShaderStageFlagBit::FRAGMENT; + fragmentShaderInfo.source = ""; + tmplInfo.handleMap = genHandles(tmpl); + tmplInfo.setLayouts = {}; + + _templateInfos[tmpl.hash] = tmplInfo; + } + return &tmpl; +} + +/** + * @en Gets the shader template with its name + * @zh 通过名字获取 Shader 模板 + * @param name Target shader name + */ + +IProgramInfo *ProgramLib::getTemplate(const std::string &name) { + auto it = _templates.find(name); + return it != _templates.end() ? &it->second : nullptr; +} + +/** + * @en Gets the shader template info with its name + * @zh 通过名字获取 Shader 模版信息 + * @param name Target shader name + */ + +ITemplateInfo *ProgramLib::getTemplateInfo(const std::string &name) { + auto it = _templates.find(name); + assert(it != _templates.end()); + auto hash = it->second.hash; + auto itInfo = _templateInfos.find(hash); + return itInfo != _templateInfos.end() ? &itInfo->second : nullptr; +} + +/** + * @en Gets the pipeline layout of the shader template given its name + * @zh 通过名字获取 Shader 模板相关联的管线布局 + * @param name Target shader name + */ +gfx::DescriptorSetLayout *ProgramLib::getDescriptorSetLayout(gfx::Device *device, const std::string &name, bool isLocal) { + auto itTmpl = _templates.find(name); + assert(itTmpl != _templates.end()); + const auto &tmpl = itTmpl->second; + auto itTplInfo = _templateInfos.find(tmpl.hash); + if (itTplInfo == _templateInfos.end()) { + return nullptr; + } + + auto &tmplInfo = itTplInfo->second; + if (tmplInfo.setLayouts.empty()) { + gfx::DescriptorSetLayoutInfo info; + tmplInfo.setLayouts.resize(static_cast(pipeline::SetIndex::COUNT)); + info.bindings = tmplInfo.bindings; + tmplInfo.setLayouts.replace(static_cast(pipeline::SetIndex::MATERIAL), device->createDescriptorSetLayout(info)); + info.bindings = pipeline::localDescriptorSetLayout.bindings; + tmplInfo.setLayouts.replace(static_cast(pipeline::SetIndex::LOCAL), device->createDescriptorSetLayout(info)); + } + return tmplInfo.setLayouts.at(isLocal ? static_cast(pipeline::SetIndex::LOCAL) : static_cast(pipeline::SetIndex::MATERIAL)); +} + +std::string ProgramLib::getKey(const std::string &name, const MacroRecord &defines) { + auto itTpl = _templates.find(name); + assert(itTpl != _templates.end()); + auto &tmpl = itTpl->second; + auto &tmplDefs = tmpl.defines; + if (tmpl.uber) { + std::stringstream key; + for (auto &tmplDef : tmplDefs) { + auto itDef = defines.find(tmplDef.name); + if (itDef == defines.end() || !tmplDef.map) { + continue; + } + const auto &value = itDef->second; + auto mapped = tmplDef.map(value); + auto offset = tmplDef.offset; + key << offset << mapped << "|"; + } + std::string ret{key.str() + std::to_string(tmpl.hash)}; + return ret; + } + uint32_t key = 0; + std::stringstream ss; + for (auto &tmplDef : tmplDefs) { + auto itDef = defines.find(tmplDef.name); + if (itDef == defines.end() || !tmplDef.map) { + continue; + } + const auto &value = itDef->second; + auto mapped = tmplDef.map(value); + auto offset = tmplDef.offset; + key |= (mapped << offset); + } + ss << std::hex << key << "|" << std::to_string(tmpl.hash); + std::string ret{ss.str()}; + return ret; +} + +void ProgramLib::destroyShaderByDefines(const MacroRecord &defines) { + if (defines.empty()) return; + std::vector defineValues; + for (const auto &i : defines) { + defineValues.emplace_back(i.first + recordAsString(i.second)); + } + std::vector matchedKeys; + for (const auto &i : _cache) { + bool matched = true; + for (const auto &v : defineValues) { + if (i.first.find(v) == std::string::npos) { + matched = false; + break; + } + } + if (matched) { + matchedKeys.emplace_back(i.first); + } + } + for (const auto &key : matchedKeys) { + CC_LOG_DEBUG("destroyed shader %s", key.c_str()); + _cache[key]->destroy(); + _cache.erase(key); + } +} + +gfx::Shader *ProgramLib::getGFXShader(gfx::Device *device, const std::string &name, MacroRecord &defines, + pipeline::RenderPipeline *pipeline, std::string *keyOut) { + for (const auto &it : pipeline->getMacros()) { + defines[it.first] = it.second; + } + + std::string key; + if (!keyOut) { + key = getKey(name, defines); + } else { + key = *keyOut; + } + auto itRes = _cache.find(key); + if (itRes != _cache.end()) { + // CC_LOG_DEBUG("Found ProgramLib::_cache[%s]=%p, defines: %d", key.c_str(), itRes->second, defines.size()); + return itRes->second; + } + + auto itTpl = _templates.find(name); + assert(itTpl != _templates.end()); + + const auto &tmpl = itTpl->second; + const auto itTplInfo = _templateInfos.find(tmpl.hash); + assert(itTplInfo != _templateInfos.end()); + auto &tmplInfo = itTplInfo->second; + + if (!tmplInfo.pipelineLayout) { + getDescriptorSetLayout(device, name); // ensure set layouts have been created + insertBuiltinBindings(tmpl, tmplInfo, pipeline::globalDescriptorSetLayout, "globals", nullptr); + tmplInfo.setLayouts.replace(static_cast(pipeline::SetIndex::GLOBAL), pipeline->getDescriptorSetLayout()); + tmplInfo.pipelineLayout = device->createPipelineLayout(gfx::PipelineLayoutInfo{tmplInfo.setLayouts.get()}); + } + + std::vector macroArray = prepareDefines(defines, tmpl.defines); + std::stringstream ss; + ss << std::endl; + for (const auto &m : macroArray) { + ss << "#define " << m.name << " " << m.value << std::endl; + } + auto prefix = pipeline->getConstantMacros() + tmpl.constantMacros + ss.str(); + + const IShaderSource *src = &tmpl.glsl3; + const auto * deviceShaderVersion = getDeviceShaderVersion(device); + if (deviceShaderVersion) { + src = tmpl.getSource(deviceShaderVersion); + } else { + CC_LOG_ERROR("Invalid GFX API!"); + } + tmplInfo.shaderInfo.stages[0].source = prefix + src->vert; + tmplInfo.shaderInfo.stages[1].source = prefix + src->frag; + + // strip out the active attributes only, instancing depend on this + tmplInfo.shaderInfo.attributes = getActiveAttributes(tmpl, tmplInfo, defines); + + tmplInfo.shaderInfo.name = getShaderInstanceName(name, macroArray); + + auto *shader = device->createShader(tmplInfo.shaderInfo); + _cache[key] = shader; + CC_LOG_DEBUG("ProgramLib::_cache[%s]=%p, defines: %d", key.c_str(), shader, defines.size()); + return shader; +} + +} // namespace cc diff --git a/native/cocos/renderer/core/ProgramLib.h b/native/cocos/renderer/core/ProgramLib.h new file mode 100644 index 0000000000..95d6dbf5ef --- /dev/null +++ b/native/cocos/renderer/core/ProgramLib.h @@ -0,0 +1,167 @@ +/**************************************************************************** + 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 +#include +#include +#include +#include +#include +#include +#include "cocos/base/Optional.h" +#include "core/Types.h" +#include "core/assets/EffectAsset.h" +#include "renderer/core/PassUtils.h" +#include "renderer/gfx-base/GFXDef-common.h" +#include "renderer/gfx-base/GFXDevice.h" +#include "renderer/gfx-base/GFXPipelineLayout.h" +#include "renderer/pipeline/Define.h" +#include "renderer/pipeline/RenderPipeline.h" + +namespace cc { + +struct IDefineRecord : public IDefineInfo { + std::function map{nullptr}; + int32_t offset{0}; +}; +struct IMacroInfo { + std::string name; + std::string value; + bool isDefault{false}; +}; + +struct ITemplateInfo { + std::vector gfxAttributes; + gfx::ShaderInfo shaderInfo; + std::vector blockSizes; + Vector setLayouts; + IntrusivePtr pipelineLayout{nullptr}; + Record handleMap; + std::vector bindings; + int32_t samplerStartBinding{-1}; +}; + +struct IProgramInfo : public IShaderInfo { + std::string effectName; + std::vector defines; + std::string constantMacros; + bool uber{false}; // macro number exceeds default limits, will fallback to string hash + + void copyFrom(const IShaderInfo &o); +}; + +const char *getDeviceShaderVersion(const gfx::Device *device); + +/** + * @en The global maintainer of all shader resources. + * @zh 维护 shader 资源实例的全局管理器。 + */ +class ProgramLib final { +public: + static ProgramLib *getInstance(); + + ProgramLib() = default; + ~ProgramLib() = default; + + void registerEffect(EffectAsset *effect); + + /** + * @en Register the shader template with the given info + * @zh 注册 shader 模板。 + */ + IProgramInfo *define(IShaderInfo &shader); + + /** + * @en Gets the shader template with its name + * @zh 通过名字获取 Shader 模板 + * @param name Target shader name + */ + + IProgramInfo *getTemplate(const std::string &name); + + /** + * @en Gets the shader template info with its name + * @zh 通过名字获取 Shader 模版信息 + * @param name Target shader name + */ + + ITemplateInfo *getTemplateInfo(const std::string &name); + + /** + * @en Gets the pipeline layout of the shader template given its name + * @zh 通过名字获取 Shader 模板相关联的管线布局 + * @param name Target shader name + */ + gfx::DescriptorSetLayout *getDescriptorSetLayout(gfx::Device *device, const std::string &name, bool isLocal = false); + + /** + * @en + * Does this library has the specified program + * @zh + * 当前是否有已注册的指定名字的 shader + * @param name Target shader name + */ + inline bool hasProgram(const std::string &name) const { + return _templates.count(name) > 0; + } + + /** + * @en Gets the shader key with the name and a macro combination + * @zh 根据 shader 名和预处理宏列表获取 shader key。 + * @param name Target shader name + * @param defines The combination of preprocess macros + */ + std::string getKey(const std::string &name, const MacroRecord &defines); + + /** + * @en Destroy all shader instance match the preprocess macros + * @zh 销毁所有完全满足指定预处理宏特征的 shader 实例。 + * @param defines The preprocess macros as filter + */ + + void destroyShaderByDefines(const MacroRecord &defines); + + /** + * @en Gets the shader resource instance with given information + * @zh 获取指定 shader 的渲染资源实例 + * @param name Shader name + * @param defines Preprocess macros + * @param pipeline The [[RenderPipeline]] which owns the render command + * @param key The shader cache key, if already known + */ + gfx::Shader *getGFXShader(gfx::Device *device, const std::string &name, MacroRecord &defines, + pipeline::RenderPipeline *pipeline, std::string *key = nullptr); + +protected: + Record _templates; // per shader + Record> _cache; + Record _templateInfos; + +private: + CC_DISALLOW_COPY_MOVE_ASSIGN(ProgramLib); +}; + +} // namespace cc diff --git a/native/cocos/renderer/core/TextureBufferPool.cpp b/native/cocos/renderer/core/TextureBufferPool.cpp new file mode 100644 index 0000000000..ee664fab22 --- /dev/null +++ b/native/cocos/renderer/core/TextureBufferPool.cpp @@ -0,0 +1,312 @@ +/**************************************************************************** + 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 "renderer/core/TextureBufferPool.h" +#include +#include "core/ArrayBuffer.h" +#include "core/TypedArray.h" + +namespace { + +uint32_t roundUp(uint32_t n, uint32_t alignment) { + return static_cast(std::ceil(n / alignment)) * alignment; +} +} // namespace + +namespace cc { + +TextureBufferPool::TextureBufferPool(gfx::Device *device) { + _device = device; +} + +void TextureBufferPool::initialize(const ITextureBufferPoolInfo &info) { + const auto &formatInfo = gfx::GFX_FORMAT_INFOS[static_cast(info.format)]; + _format = info.format; + _formatSize = formatInfo.size; + _channels = formatInfo.count; + _roundUpFn = info.roundUpFn.has_value() ? info.roundUpFn.value() : nullptr; + _alignment = info.alignment.has_value() ? info.alignment.value() : 1; + _useMcDonaldAlloc = info.alignment.has_value() && info.alignment.value(); +} + +void TextureBufferPool::destroy() { + for (auto &chunk : _chunks) { + CC_SAFE_DESTROY_AND_DELETE(chunk.texture); + } + _chunks.clear(); + _handles.clear(); +} + +ITextureBufferHandle TextureBufferPool::alloc(uint32_t size) { + if (_useMcDonaldAlloc) { + return mcDonaldAlloc(size); + } + + size = roundUp(size, _alignment); + index_t index = CC_INVALID_INDEX; + index_t start = CC_INVALID_INDEX; + if (start < 0) { + for (index_t i = 0; i < _chunkCount; ++i) { + index = i; + start = findAvailableSpace(size, index); + if (start >= 0) break; + } + } + + if (start >= 0) { + auto chunk = _chunks[index]; + chunk.start += static_cast(size); + ITextureBufferHandle handle; + handle.chunkIdx = index; + handle.start = start; + handle.end = static_cast(start + size); + handle.texture = chunk.texture; + + _handles.emplace_back(handle); + return handle; + } + // create a new one + auto targetSize = static_cast(std::sqrt(size / _formatSize)); + uint32_t texLength = _roundUpFn ? _roundUpFn(targetSize, _formatSize) : std::max(1024, static_cast(utils::nextPOT(targetSize))); + auto newChunk = _chunks[createChunk(texLength)]; + + newChunk.start += static_cast(size); + ITextureBufferHandle texHandle; + texHandle.chunkIdx = static_cast(_chunkCount - 1); + texHandle.start = 0; + texHandle.end = static_cast(size); + texHandle.texture = newChunk.texture; + _handles.emplace_back(texHandle); + return texHandle; +} + +ITextureBufferHandle TextureBufferPool::alloc(uint32_t size, index_t chunkIdx) { + size = roundUp(size, _alignment); + index_t index = chunkIdx; + index_t start = findAvailableSpace(size, index); + + if (start < 0) { + for (index_t i = 0; i < _chunkCount; ++i) { + index = i; + start = findAvailableSpace(size, index); + if (start >= 0) break; + } + } + + if (start >= 0) { + auto chunk = _chunks[index]; + chunk.start += static_cast(size); + ITextureBufferHandle handle; + handle.chunkIdx = index; + handle.start = start; + handle.end = static_cast(start + size); + handle.texture = chunk.texture; + + _handles.emplace_back(handle); + return handle; + } + // create a new one + auto targetSize = static_cast(std::sqrt(size / _formatSize)); + uint32_t texLength = _roundUpFn ? _roundUpFn(targetSize, _formatSize) : std::max(1024, static_cast(utils::nextPOT(targetSize))); + auto newChunk = _chunks[createChunk(texLength)]; + + newChunk.start += static_cast(size); + ITextureBufferHandle texHandle; + texHandle.chunkIdx = static_cast(_chunkCount - 1); + texHandle.start = 0; + texHandle.end = static_cast(size); + texHandle.texture = newChunk.texture; + _handles.emplace_back(texHandle); + return texHandle; +} + +void TextureBufferPool::free(const ITextureBufferHandle &handle) { + auto iter = std::find(_handles.begin(), _handles.end(), handle); + if (iter != _handles.end()) { + _chunks[handle.chunkIdx].end = handle.end; + _handles.erase(iter); + } +} + +uint32_t TextureBufferPool::createChunk(uint32_t length) { + uint32_t texSize = length * length * _formatSize; + // debug(`TextureBufferPool: Allocate chunk $device->createTexture({gfx::TextureType::TEX2D, + auto *texture = _device->createTexture({gfx::TextureType::TEX2D, + gfx::TextureUsageBit::SAMPLED | gfx::TextureUsageBit::TRANSFER_DST, + _format, + length, + length}); + + ITextureBuffer chunk; + chunk.texture = texture; + chunk.size = texSize; + chunk.start = 0; + chunk.end = static_cast(texSize); + _chunks[_chunkCount] = chunk; + return _chunkCount++; +} + +void TextureBufferPool::update(const ITextureBufferHandle &handle, ArrayBuffer *buffer) { + gfx::BufferDataList buffers; + uint8_t * bufferData = buffer->getData(); + gfx::BufferTextureCopyList regions; + auto start = static_cast(handle.start / _formatSize); + + uint32_t remainSize = buffer->byteLength() / _formatSize; + int32_t offsetX = start % static_cast(handle.texture->getWidth()); + int32_t offsetY = std::floor(start / handle.texture->getWidth()); + uint32_t copySize = std::min(handle.texture->getWidth() - offsetX, remainSize); + uint32_t begin = 0; + + if (offsetX > 0) { + _region0.texOffset.x = offsetX; + _region0.texOffset.y = offsetY; + _region0.texExtent.width = copySize; + _region0.texExtent.height = 1; + buffers.emplace_back(bufferData + begin * _formatSize); + regions.emplace_back(_region0); + offsetX = 0; + offsetY += 1; + remainSize -= copySize; + begin += copySize; + } + + if (remainSize > 0) { + _region1.texOffset.x = offsetX; + _region1.texOffset.y = offsetY; + + if (remainSize > handle.texture->getWidth()) { + _region1.texExtent.width = handle.texture->getWidth(); + _region1.texExtent.height = std::floor(remainSize / handle.texture->getWidth()); + copySize = _region1.texExtent.width * _region1.texExtent.height; + } else { + copySize = remainSize; + _region1.texExtent.width = copySize; + _region1.texExtent.height = 1; + } + + buffers.emplace_back(bufferData + begin * _formatSize); + regions.emplace_back(_region1); + + offsetX = 0; + offsetY += static_cast(_region1.texExtent.height); + remainSize -= copySize; + begin += copySize; + } + + if (remainSize > 0) { + _region2.texOffset.x = offsetX; + _region2.texOffset.y = offsetY; + _region2.texExtent.width = remainSize; + _region2.texExtent.height = 1; + + buffers.emplace_back(bufferData + begin * _formatSize); + regions.emplace_back(_region2); + } + _device->copyBuffersToTexture(buffers, handle.texture, regions); +} + +index_t TextureBufferPool::findAvailableSpace(uint32_t size, index_t chunkIdx) const { + auto chunk = _chunks[chunkIdx]; + bool isFound = false; + index_t start = chunk.start; + if ((start + size) <= chunk.size) { + isFound = true; + } else { + start = 0; // try to find from head again + std::vector handles; + for (auto h : _handles) { + if (h.chunkIdx == chunkIdx) { + handles.emplace_back(h); + } + } + std::sort(handles.begin(), handles.end(), [](const ITextureBufferHandle &a, const ITextureBufferHandle &b) { return a.start - b.start; }); + for (auto handle : handles) { + if ((start + size) <= handle.start) { + isFound = true; + break; + } + start = handle.end; + } + if (!isFound && (start + size) <= chunk.size) { + isFound = true; + } + } + return isFound ? start : CC_INVALID_INDEX; +} + +ITextureBufferHandle TextureBufferPool::mcDonaldAlloc(uint32_t size) { + size = roundUp(size, _alignment); + for (index_t i = 0; i < _chunkCount; ++i) { + auto chunk = _chunks[i]; + bool isFound = false; + index_t start = chunk.start; + if ((start + size) <= chunk.end) { + isFound = true; + } else if (start > chunk.end) { + if ((start + size) <= chunk.size) { + isFound = true; + } else if (size <= chunk.end) { + // Try to find from head again. + start = 0; + chunk.start = 0; + isFound = true; + } + } else if (start == chunk.end) { + start = 0; + chunk.start = 0; + chunk.end = static_cast(chunk.size); + if (size <= chunk.end) { + isFound = true; + } + } + if (isFound) { + chunk.start += static_cast(size); + + ITextureBufferHandle handle; + handle.chunkIdx = i; + handle.start = start; + handle.end = static_cast(size); + handle.texture = chunk.texture; + _handles.emplace_back(handle); + return handle; + } + } + // create a new one + auto targetSize = static_cast(std::sqrt(size / _formatSize)); + uint32_t texLength = _roundUpFn ? _roundUpFn(targetSize, _formatSize) : std::max(1024, static_cast(utils::nextPOT(targetSize))); + auto newChunk = _chunks[createChunk(texLength)]; + + newChunk.start += static_cast(size); + ITextureBufferHandle texHandle; + texHandle.chunkIdx = static_cast(_chunkCount); + texHandle.start = 0; + texHandle.end = static_cast(size), + texHandle.texture = newChunk.texture; + _handles.emplace_back(texHandle); + return texHandle; +} + +} // namespace cc diff --git a/native/cocos/renderer/core/TextureBufferPool.h b/native/cocos/renderer/core/TextureBufferPool.h new file mode 100644 index 0000000000..891a5075a5 --- /dev/null +++ b/native/cocos/renderer/core/TextureBufferPool.h @@ -0,0 +1,100 @@ +/**************************************************************************** + 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 +#include "audio/android/PcmBufferProvider.h" +#include "cocos/base/Optional.h" +#include "core/ArrayBuffer.h" +#include "gfx-base/GFXTexture.h" +#include "renderer/gfx-base/GFXDef.h" +#include "renderer/gfx-base/GFXDevice.h" + +namespace cc { +using roundUpType = std::function; + +struct ITextureBuffer { + gfx::Texture *texture{nullptr}; + uint32_t size{0}; + index_t start{0}; + index_t end{0}; +}; + +struct ITextureBufferHandle { + index_t chunkIdx{0}; + index_t start{0}; + index_t end{0}; + gfx::Texture *texture{nullptr}; + + bool operator==(const ITextureBufferHandle &handle) const { + return chunkIdx == handle.chunkIdx && start == handle.start && end == handle.end && texture == handle.texture; + } +}; + +struct ITextureBufferPoolInfo { + gfx::Format format{gfx::Format::UNKNOWN}; // target texture format + cc::optional inOrderFree; // will the handles be freed exactly in the order of their allocation? + cc::optional alignment; // the data alignment for each handle allocated, in bytes + cc::optional roundUpFn; // given a target size, how will the actual texture size round up? +}; + +class TextureBufferPool : public RefCounted { +public: + TextureBufferPool() = default; + explicit TextureBufferPool(gfx::Device *device); + ~TextureBufferPool() override = default; + + void initialize(const ITextureBufferPoolInfo &info); + void destroy(); + ITextureBufferHandle alloc(uint32_t size); + ITextureBufferHandle alloc(uint32_t size, index_t chunkIdx); + + void free(const ITextureBufferHandle &handle); + uint32_t createChunk(uint32_t length); + void update(const ITextureBufferHandle &handle, ArrayBuffer *buffer); + +private: + index_t findAvailableSpace(uint32_t size, index_t chunkIdx) const; + + // [McDonald 12] Efficient Buffer Management + ITextureBufferHandle mcDonaldAlloc(uint32_t size); + + gfx::Device * _device{nullptr}; + gfx::Format _format{gfx::Format::UNKNOWN}; + uint32_t _formatSize{0}; + std::vector _chunks; + uint32_t _chunkCount{0}; + std::vector _handles; + gfx::BufferTextureCopy _region0; + gfx::BufferTextureCopy _region1; + gfx::BufferTextureCopy _region2; + roundUpType _roundUpFn{nullptr}; + bool _useMcDonaldAlloc{false}; + uint32_t _channels{4}; + uint32_t _alignment{1}; + CC_DISALLOW_COPY_MOVE_ASSIGN(TextureBufferPool); +}; + +} // namespace cc diff --git a/native/cocos/renderer/gfx-agent/SwapchainAgent.cpp b/native/cocos/renderer/gfx-agent/SwapchainAgent.cpp index b19f9b2131..73c59a0cfd 100644 --- a/native/cocos/renderer/gfx-agent/SwapchainAgent.cpp +++ b/native/cocos/renderer/gfx-agent/SwapchainAgent.cpp @@ -40,9 +40,6 @@ SwapchainAgent::SwapchainAgent(Swapchain *actor) } SwapchainAgent::~SwapchainAgent() { - CC_SAFE_DELETE(_depthStencilTexture); - CC_SAFE_DELETE(_colorTexture); - ENQUEUE_MESSAGE_1( DeviceAgent::getInstance()->getMessageQueue(), SwapchainDestruct, actor, _actor, @@ -84,8 +81,8 @@ void SwapchainAgent::doInit(const SwapchainInfo &info) { } void SwapchainAgent::doDestroy() { - CC_SAFE_DELETE(_depthStencilTexture); - CC_SAFE_DELETE(_colorTexture); + _depthStencilTexture = nullptr; + _colorTexture = nullptr; ENQUEUE_MESSAGE_1( DeviceAgent::getInstance()->getMessageQueue(), SwapchainDestroy, @@ -110,8 +107,8 @@ void SwapchainAgent::doResize(uint32_t width, uint32_t height, SurfaceTransform mq->kickAndWait(); - auto *colorTexture = static_cast(_colorTexture); - auto *depthStencilTexture = static_cast(_depthStencilTexture); + auto *colorTexture = static_cast(_colorTexture.get()); + auto *depthStencilTexture = static_cast(_depthStencilTexture.get()); colorTexture->_info.width = depthStencilTexture->_info.width = _actor->getWidth(); colorTexture->_info.height = depthStencilTexture->_info.height = _actor->getHeight(); diff --git a/native/cocos/renderer/gfx-base/GFXDef-common.h b/native/cocos/renderer/gfx-base/GFXDef-common.h index e7899ce942..1a12b84fda 100644 --- a/native/cocos/renderer/gfx-base/GFXDef-common.h +++ b/native/cocos/renderer/gfx-base/GFXDef-common.h @@ -1082,6 +1082,27 @@ struct Attribute { using AttributeList = vector; +constexpr const char *ATTR_NAME_POSITION = "a_position"; +constexpr const char *ATTR_NAME_NORMAL = "a_normal"; +constexpr const char *ATTR_NAME_TANGENT = "a_tangent"; +constexpr const char *ATTR_NAME_BITANGENT = "a_bitangent"; +constexpr const char *ATTR_NAME_WEIGHTS = "a_weights"; +constexpr const char *ATTR_NAME_JOINTS = "a_joints"; +constexpr const char *ATTR_NAME_COLOR = "a_color"; +constexpr const char *ATTR_NAME_COLOR1 = "a_color1"; +constexpr const char *ATTR_NAME_COLOR2 = "a_color2"; +constexpr const char *ATTR_NAME_TEX_COORD = "a_texCoord"; +constexpr const char *ATTR_NAME_TEX_COORD1 = "a_texCoord1"; +constexpr const char *ATTR_NAME_TEX_COORD2 = "a_texCoord2"; +constexpr const char *ATTR_NAME_TEX_COORD3 = "a_texCoord3"; +constexpr const char *ATTR_NAME_TEX_COORD4 = "a_texCoord4"; +constexpr const char *ATTR_NAME_TEX_COORD5 = "a_texCoord5"; +constexpr const char *ATTR_NAME_TEX_COORD6 = "a_texCoord6"; +constexpr const char *ATTR_NAME_TEX_COORD7 = "a_texCoord7"; +constexpr const char *ATTR_NAME_TEX_COORD8 = "a_texCoord8"; +constexpr const char *ATTR_NAME_BATCH_ID = "a_batch_id"; +constexpr const char *ATTR_NAME_BATCH_UV = "a_batch_uv"; + struct ShaderInfo { String name; ShaderStageList stages; @@ -1175,7 +1196,7 @@ using TextureBarrierInfoList = vector; struct FramebufferInfo { RenderPass *renderPass{nullptr}; - TextureList colorTextures; + TextureList colorTextures; // @ts-overrides { type: '(Texture | null)[]' } Texture * depthStencilTexture{nullptr}; // @ts-nullable }; @@ -1218,6 +1239,21 @@ struct RasterizerState { uint32_t isDepthClip{1U}; uint32_t isMultisample{0U}; float lineWidth{1.F}; + + void reset() { + isDiscard = 0; + polygonMode = PolygonMode::FILL; + shadeModel = ShadeModel::GOURAND; + cullMode = CullMode::BACK; + isFrontFaceCCW = 1; + depthBiasEnabled = 0; + depthBias = 0.0F; + depthBiasClamp = 0.0F; + depthBiasSlop = 0.0F; + isDepthClip = 1; + isMultisample = 0; + lineWidth = 1.0F; + } }; // Use uint32_t for all boolean values to convert memory to DepthStencilState* in shared memory. @@ -1241,6 +1277,28 @@ struct DepthStencilState { StencilOp stencilZFailOpBack{StencilOp::KEEP}; StencilOp stencilPassOpBack{StencilOp::KEEP}; uint32_t stencilRefBack{1U}; + + void reset() { + depthTest = 1; + depthWrite = 1; + depthFunc = ComparisonFunc::LESS; + stencilTestFront = 0; + stencilFuncFront = ComparisonFunc::ALWAYS; + stencilReadMaskFront = 0xffffffff; + stencilWriteMaskFront = 0xffffffff; + stencilFailOpFront = StencilOp::KEEP; + stencilZFailOpFront = StencilOp::KEEP; + stencilPassOpFront = StencilOp::KEEP; + stencilRefFront = 1; + stencilTestBack = 0; + stencilFuncBack = ComparisonFunc::ALWAYS; + stencilReadMaskBack = 0xffffffff; + stencilWriteMaskBack = 0xffffffff; + stencilFailOpBack = StencilOp::KEEP; + stencilZFailOpBack = StencilOp::KEEP; + stencilPassOpBack = StencilOp::KEEP; + stencilRefBack = 1; + } }; // Use uint32_t for all boolean values to do convert memory to BlendTarget* in shared memory. @@ -1263,6 +1321,26 @@ struct BlendState { uint32_t isIndepend{0U}; Color blendColor; BlendTargetList targets{1U}; + + void setTarget(index_t index, const BlendTarget &target) { + if (index >= targets.size()) { + targets.resize(index + 1); + } + targets[index] = target; + } + + void reset() { + isA2C = 0; + isIndepend = 0; + blendColor.x = 0; + blendColor.y = 0; + blendColor.z = 0; + blendColor.w = 0; + targets.clear(); + targets.resize(1); + } + + void destroy() {} }; struct PipelineStateInfo { diff --git a/native/cocos/renderer/gfx-base/GFXDef.cpp b/native/cocos/renderer/gfx-base/GFXDef.cpp index 0d8a06772d..f4419b236c 100644 --- a/native/cocos/renderer/gfx-base/GFXDef.cpp +++ b/native/cocos/renderer/gfx-base/GFXDef.cpp @@ -23,8 +23,8 @@ THE SOFTWARE. ****************************************************************************/ +#include #include - #include "base/CoreStd.h" #include "base/Utils.h" @@ -36,13 +36,13 @@ namespace gfx { // T must have no implicit padding template -size_t quickHashTrivialStruct(const T* info, size_t count = 1) { +size_t quickHashTrivialStruct(const T *info, size_t count = 1) { static_assert(std::is_trivially_copyable::value && sizeof(T) % 8 == 0, "T must be 8 bytes aligned and trivially copyable"); - return boost::hash_range(reinterpret_cast(info), reinterpret_cast(info + count)); + return boost::hash_range(reinterpret_cast(info), reinterpret_cast(info + count)); } template <> -size_t Hasher::operator()(const ColorAttachment& info) const { +size_t Hasher::operator()(const ColorAttachment &info) const { size_t seed = 6; boost::hash_combine(seed, info.format); boost::hash_combine(seed, info.sampleCount); @@ -54,7 +54,7 @@ size_t Hasher::operator()(const ColorAttachment& info) const { } template <> -size_t Hasher::operator()(const DepthStencilAttachment& info) const { +size_t Hasher::operator()(const DepthStencilAttachment &info) const { size_t seed = 8; boost::hash_combine(seed, info.format); boost::hash_combine(seed, info.sampleCount); @@ -68,7 +68,7 @@ size_t Hasher::operator()(const DepthStencilAttachment& } template <> -size_t Hasher::operator()(const SubpassInfo& info) const { +size_t Hasher::operator()(const SubpassInfo &info) const { size_t seed = 8; boost::hash_combine(seed, info.inputs); boost::hash_combine(seed, info.colors); @@ -82,7 +82,7 @@ size_t Hasher::operator()(const SubpassInfo& info) const { } template <> -size_t Hasher::operator()(const SubpassDependency& info) const { +size_t Hasher::operator()(const SubpassDependency &info) const { size_t seed = 4; boost::hash_combine(seed, info.srcSubpass); boost::hash_combine(seed, info.dstSubpass); @@ -92,7 +92,7 @@ size_t Hasher::operator()(const SubpassDependency& info) cons } template <> -size_t Hasher::operator()(const RenderPassInfo& info) const { +size_t Hasher::operator()(const RenderPassInfo &info) const { size_t seed = 4; boost::hash_combine(seed, info.colorAttachments); boost::hash_combine(seed, info.depthStencilAttachment); @@ -102,7 +102,7 @@ size_t Hasher::operator()(const RenderPassInfo& info) const { } template <> -size_t Hasher::operator()(const FramebufferInfo& info) const { +size_t Hasher::operator()(const FramebufferInfo &info) const { size_t seed = 3; boost::hash_combine(seed, info.renderPass); boost::hash_combine(seed, info.colorTextures); @@ -111,22 +111,22 @@ size_t Hasher::operator()(const FramebufferInfo& info) const { } template <> -size_t Hasher::operator()(const TextureInfo& info) const { +size_t Hasher::operator()(const TextureInfo &info) const { return quickHashTrivialStruct(&info); } template <> -size_t Hasher::operator()(const TextureViewInfo& info) const { +size_t Hasher::operator()(const TextureViewInfo &info) const { return quickHashTrivialStruct(&info); } template <> -size_t Hasher::operator()(const BufferInfo& info) const { +size_t Hasher::operator()(const BufferInfo &info) const { return quickHashTrivialStruct(&info); } template <> -size_t Hasher::operator()(const SamplerInfo& info) const { +size_t Hasher::operator()(const SamplerInfo &info) const { // return quickHashTrivialStruct(&info); // the hash may be used to reconstruct the original struct @@ -142,7 +142,7 @@ size_t Hasher::operator()(const SamplerInfo& info) const { } template <> -size_t Hasher::operator()(const GlobalBarrierInfo& info) const { +size_t Hasher::operator()(const GlobalBarrierInfo &info) const { size_t seed = 2; boost::hash_combine(seed, info.prevAccesses); boost::hash_combine(seed, info.nextAccesses); @@ -150,7 +150,7 @@ size_t Hasher::operator()(const GlobalBarrierInfo& info) cons } template <> -size_t Hasher::operator()(const TextureBarrierInfo& info) const { +size_t Hasher::operator()(const TextureBarrierInfo &info) const { size_t seed = 5; boost::hash_combine(seed, info.prevAccesses); boost::hash_combine(seed, info.nextAccesses); @@ -160,7 +160,7 @@ size_t Hasher::operator()(const TextureBarrierInfo& info) co return seed; } -bool operator==(const ColorAttachment& lhs, const ColorAttachment& rhs) { +bool operator==(const ColorAttachment &lhs, const ColorAttachment &rhs) { return lhs.format == rhs.format && lhs.sampleCount == rhs.sampleCount && lhs.loadOp == rhs.loadOp && @@ -170,7 +170,7 @@ bool operator==(const ColorAttachment& lhs, const ColorAttachment& rhs) { lhs.endAccesses == rhs.endAccesses; } -bool operator==(const DepthStencilAttachment& lhs, const DepthStencilAttachment& rhs) { +bool operator==(const DepthStencilAttachment &lhs, const DepthStencilAttachment &rhs) { return lhs.format == rhs.format && lhs.sampleCount == rhs.sampleCount && lhs.depthLoadOp == rhs.depthLoadOp && @@ -182,7 +182,7 @@ bool operator==(const DepthStencilAttachment& lhs, const DepthStencilAttachment& lhs.endAccesses == rhs.endAccesses; } -bool operator==(const SubpassInfo& lhs, const SubpassInfo& rhs) { +bool operator==(const SubpassInfo &lhs, const SubpassInfo &rhs) { return lhs.colors == rhs.colors && lhs.resolves == rhs.resolves && lhs.inputs == rhs.inputs && @@ -193,27 +193,27 @@ bool operator==(const SubpassInfo& lhs, const SubpassInfo& rhs) { lhs.stencilResolveMode == rhs.stencilResolveMode; } -bool operator==(const SubpassDependency& lhs, const SubpassDependency& rhs) { +bool operator==(const SubpassDependency &lhs, const SubpassDependency &rhs) { return lhs.srcAccesses == rhs.srcAccesses && lhs.dstAccesses == rhs.dstAccesses && lhs.srcSubpass == rhs.srcSubpass && lhs.dstSubpass == rhs.dstSubpass; } -bool operator==(const RenderPassInfo& lhs, const RenderPassInfo& rhs) { +bool operator==(const RenderPassInfo &lhs, const RenderPassInfo &rhs) { return lhs.colorAttachments == rhs.colorAttachments && lhs.depthStencilAttachment == rhs.depthStencilAttachment && lhs.subpasses == rhs.subpasses && lhs.dependencies == rhs.dependencies; } -bool operator==(const FramebufferInfo& lhs, const FramebufferInfo& rhs) { +bool operator==(const FramebufferInfo &lhs, const FramebufferInfo &rhs) { return lhs.renderPass == rhs.renderPass && lhs.colorTextures == rhs.colorTextures && lhs.depthStencilTexture == rhs.depthStencilTexture; } -bool operator==(const Viewport& lhs, const Viewport& rhs) { +bool operator==(const Viewport &lhs, const Viewport &rhs) { return lhs.left == rhs.left && lhs.top == rhs.top && lhs.width == rhs.width && @@ -222,60 +222,60 @@ bool operator==(const Viewport& lhs, const Viewport& rhs) { lhs.maxDepth == rhs.maxDepth; } -bool operator==(const Rect& lhs, const Rect& rhs) { +bool operator==(const Rect &lhs, const Rect &rhs) { return lhs.x == rhs.x && lhs.y == rhs.y && lhs.width == rhs.width && lhs.height == rhs.height; } -bool operator==(const Color& lhs, const Color& rhs) { +bool operator==(const Color &lhs, const Color &rhs) { return lhs.x == rhs.x && lhs.y == rhs.y && lhs.z == rhs.z && lhs.w == rhs.w; } -bool operator==(const Offset& lhs, const Offset& rhs) { +bool operator==(const Offset &lhs, const Offset &rhs) { return lhs.x == rhs.x && lhs.y == rhs.y && lhs.z == rhs.z; } -bool operator==(const Extent& lhs, const Extent& rhs) { +bool operator==(const Extent &lhs, const Extent &rhs) { return lhs.width == rhs.width && lhs.height == rhs.height && lhs.depth == rhs.depth; } -bool operator==(const Size& lhs, const Size& rhs) { +bool operator==(const Size &lhs, const Size &rhs) { return lhs.x == rhs.x && lhs.y == rhs.y && lhs.z == rhs.z; } -bool operator==(const TextureInfo& lhs, const TextureInfo& rhs) { +bool operator==(const TextureInfo &lhs, const TextureInfo &rhs) { return !memcmp(&lhs, &rhs, sizeof(TextureInfo)); } -bool operator==(const TextureViewInfo& lhs, const TextureViewInfo& rhs) { +bool operator==(const TextureViewInfo &lhs, const TextureViewInfo &rhs) { return !memcmp(&lhs, &rhs, sizeof(TextureViewInfo)); } -bool operator==(const BufferInfo& lhs, const BufferInfo& rhs) { +bool operator==(const BufferInfo &lhs, const BufferInfo &rhs) { return !memcmp(&lhs, &rhs, sizeof(BufferInfo)); } -bool operator==(const SamplerInfo& lhs, const SamplerInfo& rhs) { +bool operator==(const SamplerInfo &lhs, const SamplerInfo &rhs) { return !memcmp(&lhs, &rhs, sizeof(SamplerInfo)); } -bool operator==(const GlobalBarrierInfo& lhs, const GlobalBarrierInfo& rhs) { +bool operator==(const GlobalBarrierInfo &lhs, const GlobalBarrierInfo &rhs) { return lhs.prevAccesses == rhs.prevAccesses && lhs.nextAccesses == rhs.nextAccesses; } -bool operator==(const TextureBarrierInfo& lhs, const TextureBarrierInfo& rhs) { +bool operator==(const TextureBarrierInfo &lhs, const TextureBarrierInfo &rhs) { return lhs.prevAccesses == rhs.prevAccesses && lhs.nextAccesses == rhs.nextAccesses && lhs.discardContents == rhs.discardContents && @@ -511,7 +511,6 @@ uint32_t formatSize(Format format, uint32_t width, uint32_t height, uint32_t dep return 0; } } - std::pair formatAlignment(Format format) { switch (format) { case Format::BC1: @@ -597,7 +596,7 @@ std::pair formatAlignment(Format format) { } } -const uint32_t GFX_TYPE_SIZES[] = { +std::array GFX_TYPE_SIZES = { 0, // UNKNOWN 4, // BOOL 8, // BOOL2 @@ -632,6 +631,20 @@ const uint32_t GFX_TYPE_SIZES[] = { 4, // SAMPLER_CUBE }; +/** + * @en Get the memory size of the specified type. + * @zh 得到 GFX 数据类型的大小。 + * @param type The target type. + */ +uint32_t getTypeSize(gfx::Type type) { + if (static_cast(type) < GFX_TYPE_SIZES.size()) { + return GFX_TYPE_SIZES[static_cast(type)]; + } + + CC_LOG_WARNING("getTypeSize: wrong type: %d", static_cast(type)); + return 0; +} + uint32_t formatSurfaceSize(Format format, uint32_t width, uint32_t height, uint32_t depth, uint32_t mips) { uint32_t size = 0; diff --git a/native/cocos/renderer/gfx-base/GFXDef.h b/native/cocos/renderer/gfx-base/GFXDef.h index cb11b8e603..5ec67e1a20 100644 --- a/native/cocos/renderer/gfx-base/GFXDef.h +++ b/native/cocos/renderer/gfx-base/GFXDef.h @@ -32,15 +32,15 @@ namespace cc { namespace gfx { template ::value>> -struct Hasher final { size_t operator()(const T& info) const; }; +struct Hasher final { size_t operator()(const T &info) const; }; // make this boost::hash compatible template ::value>> -size_t hash_value(const T& info) { return Hasher()(info); } // NOLINT(readability-identifier-naming) +size_t hash_value(const T &info) { return Hasher()(info); } // NOLINT(readability-identifier-naming) -#define DEFINE_CMP_OP(type) \ - bool operator==(const type& lhs, const type& rhs); \ - inline bool operator!=(const type& lhs, const type& rhs) { return !(lhs == rhs); } +#define DEFINE_CMP_OP(type) \ + bool operator==(const type &lhs, const type &rhs); \ + inline bool operator!=(const type &lhs, const type &rhs) { return !(lhs == rhs); } DEFINE_CMP_OP(DepthStencilAttachment) DEFINE_CMP_OP(SubpassInfo) @@ -73,8 +73,8 @@ class CallbackExecutable final : public Executable { public: using ExecuteMethod = std::remove_reference_t; - explicit CallbackExecutable(ExecuteMethod& execute) : Executable(), _execute(execute) {} - explicit CallbackExecutable(ExecuteMethod&& execute) : Executable(), _execute(execute) {} + explicit CallbackExecutable(ExecuteMethod &execute) : Executable(), _execute(execute) {} + explicit CallbackExecutable(ExecuteMethod &&execute) : Executable(), _execute(execute) {} void execute() override { _execute(); } @@ -83,7 +83,7 @@ private: }; struct SwapchainTextureInfo final { - Swapchain* swapchain{nullptr}; + Swapchain *swapchain{nullptr}; Format format{Format::UNKNOWN}; uint32_t width{0}; uint32_t height{0}; @@ -107,17 +107,33 @@ constexpr DescriptorType DESCRIPTOR_TEXTURE_TYPE = static_cast( static_cast(DescriptorType::STORAGE_IMAGE) | static_cast(DescriptorType::INPUT_ATTACHMENT)); +constexpr DescriptorType DESCRIPTOR_SAMPLER_TYPE = static_cast( + static_cast(DescriptorType::SAMPLER_TEXTURE) | + static_cast(DescriptorType::SAMPLER) | + static_cast(DescriptorType::TEXTURE) | + static_cast(DescriptorType::STORAGE_IMAGE) | + static_cast(DescriptorType::INPUT_ATTACHMENT)); + constexpr DescriptorType DESCRIPTOR_DYNAMIC_TYPE = static_cast( static_cast(DescriptorType::DYNAMIC_STORAGE_BUFFER) | static_cast(DescriptorType::DYNAMIC_UNIFORM_BUFFER)); extern const FormatInfo GFX_FORMAT_INFOS[]; -extern const uint32_t GFX_TYPE_SIZES[]; std::pair formatAlignment(Format format); uint32_t formatSize(Format format, uint32_t width, uint32_t height, uint32_t depth); uint32_t formatSurfaceSize(Format format, uint32_t width, uint32_t height, uint32_t depth, uint32_t mips); + +extern std::array GFX_TYPE_SIZES; + +/** + * @en Get the memory size of the specified type. + * @zh 得到 GFX 数据类型的大小。 + * @param type The target type. + */ +extern uint32_t getTypeSize(gfx::Type type); + } // namespace gfx } // namespace cc diff --git a/native/cocos/renderer/gfx-base/GFXDevice.cpp b/native/cocos/renderer/gfx-base/GFXDevice.cpp index 5d16229c8c..23711489e6 100644 --- a/native/cocos/renderer/gfx-base/GFXDevice.cpp +++ b/native/cocos/renderer/gfx-base/GFXDevice.cpp @@ -45,6 +45,8 @@ Device::Device() { Device::~Device() { Device::instance = nullptr; + CC_SAFE_RELEASE(_cmdBuff); + CC_SAFE_RELEASE(_queue); } bool Device::initialize(const DeviceInfo &info) { @@ -57,27 +59,22 @@ bool Device::initialize(const DeviceInfo &info) { } #if CC_CPU_ARCH == CC_CPU_ARCH_32 - static_assert(sizeof(void*) == 4, "pointer size assumption broken"); + static_assert(sizeof(void *) == 4, "pointer size assumption broken"); #else - static_assert(sizeof(void*) == 8, "pointer size assumption broken"); + static_assert(sizeof(void *) == 8, "pointer size assumption broken"); #endif - return doInit(info); + bool result = doInit(info); + _cmdBuff->addRef(); + _queue->addRef(); + + return result; } void Device::destroy() { - for (auto pair : _samplers) { - CC_SAFE_DELETE(pair.second); - } - - for (auto pair : _globalBarriers) { - CC_SAFE_DELETE(pair.second); - } - - for (auto pair : _textureBarriers) { - CC_SAFE_DELETE(pair.second); - } - + _samplers.clear(); + _globalBarriers.clear(); + _textureBarriers.clear(); _bindingMappingInfo.bufferOffsets.clear(); _bindingMappingInfo.samplerOffsets.clear(); @@ -87,7 +84,7 @@ void Device::destroy() { } void Device::destroySurface(void *windowHandle) { - for (auto *swapchain :_swapchains) { + for (const auto &swapchain : _swapchains) { if (swapchain->getWindowHandle() == windowHandle) { swapchain->destroySurface(); break; @@ -96,7 +93,7 @@ void Device::destroySurface(void *windowHandle) { } void Device::createSurface(void *windowHandle) { - for (auto *swapchain :_swapchains) { + for (const auto &swapchain : _swapchains) { if (!swapchain->getWindowHandle()) { swapchain->createSurface(windowHandle); break; diff --git a/native/cocos/renderer/gfx-base/GFXDevice.h b/native/cocos/renderer/gfx-base/GFXDevice.h index 06bff789c8..840ff9be9d 100644 --- a/native/cocos/renderer/gfx-base/GFXDevice.h +++ b/native/cocos/renderer/gfx-base/GFXDevice.h @@ -171,12 +171,12 @@ protected: uint32_t _numTriangles{0U}; MemoryStatus _memoryStatus; - unordered_map> _samplers; - unordered_map> _globalBarriers; - unordered_map> _textureBarriers; + unordered_map, Hasher> _samplers; + unordered_map, Hasher> _globalBarriers; + unordered_map, Hasher> _textureBarriers; private: - vector _swapchains; + vector> _swapchains; }; ////////////////////////////////////////////////////////////////////////// diff --git a/native/cocos/renderer/gfx-base/GFXObject.h b/native/cocos/renderer/gfx-base/GFXObject.h index 95561e7f3d..4cef1344bc 100644 --- a/native/cocos/renderer/gfx-base/GFXObject.h +++ b/native/cocos/renderer/gfx-base/GFXObject.h @@ -27,6 +27,7 @@ #include "GFXDef.h" #include "base/Object.h" +#include "base/RefCounted.h" namespace cc { namespace gfx { diff --git a/native/cocos/renderer/gfx-base/GFXSwapchain.h b/native/cocos/renderer/gfx-base/GFXSwapchain.h index 724dbcf566..7ef95e5323 100644 --- a/native/cocos/renderer/gfx-base/GFXSwapchain.h +++ b/native/cocos/renderer/gfx-base/GFXSwapchain.h @@ -26,6 +26,7 @@ #pragma once #include "GFXTexture.h" +#include "base/Ptr.h" #include "gfx-base/GFXDef-common.h" namespace cc { @@ -65,11 +66,11 @@ public: inline uint32_t getHeight() const { return _colorTexture->getHeight(); } protected: - virtual void doInit(const SwapchainInfo &info) = 0; - virtual void doDestroy() = 0; + virtual void doInit(const SwapchainInfo &info) = 0; + virtual void doDestroy() = 0; virtual void doResize(uint32_t width, uint32_t height, SurfaceTransform transform) = 0; - virtual void doDestroySurface() = 0; - virtual void doCreateSurface(void *windowHandle) = 0; + virtual void doDestroySurface() = 0; + virtual void doCreateSurface(void *windowHandle) = 0; static inline void initTexture(const SwapchainTextureInfo &info, Texture *texture); @@ -78,8 +79,8 @@ protected: SurfaceTransform _transform{SurfaceTransform::IDENTITY}; bool _preRotationEnabled{false}; - Texture *_colorTexture{nullptr}; - Texture *_depthStencilTexture{nullptr}; + IntrusivePtr _colorTexture; + IntrusivePtr _depthStencilTexture; }; /////////////////////////////////////////////////////////// diff --git a/native/cocos/renderer/gfx-base/states/GFXSampler.cpp b/native/cocos/renderer/gfx-base/states/GFXSampler.cpp index 4679f49c9c..c503b84661 100644 --- a/native/cocos/renderer/gfx-base/states/GFXSampler.cpp +++ b/native/cocos/renderer/gfx-base/states/GFXSampler.cpp @@ -40,5 +40,18 @@ size_t Sampler::computeHash(const SamplerInfo &info) { return Hasher()(info); } +SamplerInfo Sampler::unpackFromHash(size_t hash) { + SamplerInfo info; + info.minFilter = static_cast((hash & ((1 << 2) - 1)) >> 0); + info.magFilter = static_cast((hash & ((1 << 2) - 1)) >> 2); + info.mipFilter = static_cast((hash & ((1 << 2) - 1)) >> 4); + info.addressU = static_cast
((hash & ((1 << 2) - 1)) >> 6); + info.addressV = static_cast
((hash & ((1 << 2) - 1)) >> 8); + info.addressW = static_cast
((hash & ((1 << 2) - 1)) >> 10); + info.maxAnisotropy = (hash & ((1 << 4) - 1)) >> 12; + info.cmpFunc = static_cast((hash & ((1 << 3) - 1)) >> 16); + return info; +} + } // namespace gfx } // namespace cc diff --git a/native/cocos/renderer/gfx-base/states/GFXSampler.h b/native/cocos/renderer/gfx-base/states/GFXSampler.h index 678be3e034..884bbef859 100644 --- a/native/cocos/renderer/gfx-base/states/GFXSampler.h +++ b/native/cocos/renderer/gfx-base/states/GFXSampler.h @@ -35,7 +35,8 @@ class CC_DLL Sampler : public GFXObject { public: explicit Sampler(const SamplerInfo &info); - static size_t computeHash(const SamplerInfo &info); + static size_t computeHash(const SamplerInfo &info); + static SamplerInfo unpackFromHash(size_t hash); inline const SamplerInfo &getInfo() const { return _info; } inline const size_t & getHash() const { return _hash; } diff --git a/native/cocos/renderer/gfx-empty/EmptyDevice.cpp b/native/cocos/renderer/gfx-empty/EmptyDevice.cpp index b799f50431..cec17a5a97 100644 --- a/native/cocos/renderer/gfx-empty/EmptyDevice.cpp +++ b/native/cocos/renderer/gfx-empty/EmptyDevice.cpp @@ -77,9 +77,9 @@ bool EmptyDevice::doInit(const DeviceInfo & /*info*/) { } void EmptyDevice::doDestroy() { - CC_SAFE_DESTROY(_cmdBuff); - CC_SAFE_DESTROY(_queryPool); - CC_SAFE_DESTROY(_queue); + CC_SAFE_DESTROY_AND_DELETE(_cmdBuff); + CC_SAFE_DESTROY_AND_DELETE(_queryPool); + CC_SAFE_DESTROY_AND_DELETE(_queue); } void EmptyDevice::acquire(Swapchain *const * /*swapchains*/, uint32_t /*count*/) { diff --git a/native/cocos/renderer/gfx-empty/EmptySwapchain.cpp b/native/cocos/renderer/gfx-empty/EmptySwapchain.cpp index fe469b92cb..ad6b089902 100644 --- a/native/cocos/renderer/gfx-empty/EmptySwapchain.cpp +++ b/native/cocos/renderer/gfx-empty/EmptySwapchain.cpp @@ -46,8 +46,8 @@ void EmptySwapchain::doInit(const SwapchainInfo &info) { } void EmptySwapchain::doDestroy() { - CC_SAFE_DESTROY(_depthStencilTexture); - CC_SAFE_DESTROY(_colorTexture); + CC_SAFE_DESTROY_NULL(_depthStencilTexture); + CC_SAFE_DESTROY_NULL(_colorTexture); } void EmptySwapchain::doResize(uint32_t width, uint32_t height, SurfaceTransform /*transform*/) { diff --git a/native/cocos/renderer/gfx-gles2/GLES2Commands.cpp b/native/cocos/renderer/gfx-gles2/GLES2Commands.cpp index 380e31ba12..5f3e4f8053 100644 --- a/native/cocos/renderer/gfx-gles2/GLES2Commands.cpp +++ b/native/cocos/renderer/gfx-gles2/GLES2Commands.cpp @@ -27,6 +27,7 @@ #include "GLES2Commands.h" #include "GLES2Device.h" +#include "cocos/renderer/gfx-base/GFXDef.h" #define BUFFER_OFFSET(idx) (static_cast(0) + (idx)) @@ -1004,7 +1005,7 @@ void cmdFuncGLES2CreateShader(GLES2Device *device, GLES2GPUShader *gpuShader) { gpuUniform.binding = INVALID_BINDING; gpuUniform.name = uniform.name; gpuUniform.type = uniform.type; - gpuUniform.stride = GFX_TYPE_SIZES[static_cast(uniform.type)]; + gpuUniform.stride = cc::gfx::GFX_TYPE_SIZES[static_cast(uniform.type)]; gpuUniform.count = uniform.count; gpuUniform.size = gpuUniform.stride * gpuUniform.count; gpuUniform.glType = mapGLType(gpuUniform.type); diff --git a/native/cocos/renderer/gfx-gles2/GLES2Device.cpp b/native/cocos/renderer/gfx-gles2/GLES2Device.cpp index 481d72bbd5..7f8dcaef48 100644 --- a/native/cocos/renderer/gfx-gles2/GLES2Device.cpp +++ b/native/cocos/renderer/gfx-gles2/GLES2Device.cpp @@ -249,10 +249,10 @@ void GLES2Device::doDestroy() { CCASSERT(!_memoryStatus.bufferSize, "Buffer memory leaked"); CCASSERT(!_memoryStatus.textureSize, "Texture memory leaked"); - CC_SAFE_DESTROY(_cmdBuff) - CC_SAFE_DESTROY(_queryPool) - CC_SAFE_DESTROY(_queue) - CC_SAFE_DESTROY(_gpuContext) + CC_SAFE_DESTROY_AND_DELETE(_cmdBuff) + CC_SAFE_DESTROY_AND_DELETE(_queryPool) + CC_SAFE_DESTROY_AND_DELETE(_queue) + CC_SAFE_DESTROY_AND_DELETE(_gpuContext) } void GLES2Device::acquire(Swapchain *const *swapchains, uint32_t count) { diff --git a/native/cocos/renderer/gfx-gles2/GLES2Swapchain.cpp b/native/cocos/renderer/gfx-gles2/GLES2Swapchain.cpp index 4d0370ce8d..8d0a85b25a 100644 --- a/native/cocos/renderer/gfx-gles2/GLES2Swapchain.cpp +++ b/native/cocos/renderer/gfx-gles2/GLES2Swapchain.cpp @@ -46,10 +46,10 @@ GLES2Swapchain::~GLES2Swapchain() { destroy(); } -void GLES2Swapchain::doInit(const SwapchainInfo& info) { - const auto* context = GLES2Device::getInstance()->context(); +void GLES2Swapchain::doInit(const SwapchainInfo &info) { + const auto *context = GLES2Device::getInstance()->context(); _gpuSwapchain = CC_NEW(GLES2GPUSwapchain); - auto window = reinterpret_cast(info.windowHandle); //NOLINT[readability-qualified-auto] + auto window = reinterpret_cast(info.windowHandle); //NOLINT[readability-qualified-auto] #if CC_PLATFORM == CC_PLATFORM_ANDROID || CC_PLATFORM == CC_PLATFORM_OHOS EGLint nFmt; @@ -99,7 +99,7 @@ void GLES2Swapchain::doInit(const SwapchainInfo& info) { textureInfo.format = Format::DEPTH_STENCIL; initTexture(textureInfo, _depthStencilTexture); - _gpuSwapchain->gpuColorTexture = static_cast(_colorTexture)->gpuTexture(); + _gpuSwapchain->gpuColorTexture = static_cast(_colorTexture.get())->gpuTexture(); } void GLES2Swapchain::doDestroy() { @@ -121,16 +121,16 @@ void GLES2Swapchain::doResize(uint32_t width, uint32_t height, SurfaceTransform void GLES2Swapchain::doDestroySurface() { if (_gpuSwapchain->eglSurface != EGL_NO_SURFACE) { - auto* context = GLES2Device::getInstance()->context(); + auto *context = GLES2Device::getInstance()->context(); eglDestroySurface(context->eglDisplay, _gpuSwapchain->eglSurface); _gpuSwapchain->eglSurface = EGL_NO_SURFACE; context->bindContext(false); } } -void GLES2Swapchain::doCreateSurface(void* windowHandle) { - auto* context = GLES2Device::getInstance()->context(); - auto window = reinterpret_cast(windowHandle); //NOLINT [readability-qualified-auto] +void GLES2Swapchain::doCreateSurface(void *windowHandle) { + auto *context = GLES2Device::getInstance()->context(); + auto window = reinterpret_cast(windowHandle); //NOLINT [readability-qualified-auto] EGLint nFmt = 0; if (eglGetConfigAttrib(context->eglDisplay, context->eglConfig, EGL_NATIVE_VISUAL_ID, &nFmt) == EGL_FALSE) { diff --git a/native/cocos/renderer/gfx-gles3/GLES3Commands.cpp b/native/cocos/renderer/gfx-gles3/GLES3Commands.cpp index 33856964fc..b431aa3d93 100644 --- a/native/cocos/renderer/gfx-gles3/GLES3Commands.cpp +++ b/native/cocos/renderer/gfx-gles3/GLES3Commands.cpp @@ -1469,12 +1469,14 @@ static GLES3GPUFramebuffer::GLFramebufferInfo doCreateFramebuffer(GLES3Device * } *resolveMask |= GL_COLOR_BUFFER_BIT; // fallback to blit-based manual resolve } - if (gpuColorTexture->glTexture) { - GL_CHECK(glFramebufferTexture2D(GL_DRAW_FRAMEBUFFER, static_cast(GL_COLOR_ATTACHMENT0 + j), - gpuColorTexture->glTarget, gpuColorTexture->glTexture, 0)); - } else { - GL_CHECK(glFramebufferRenderbuffer(GL_DRAW_FRAMEBUFFER, static_cast(GL_COLOR_ATTACHMENT0 + j), - gpuColorTexture->glTarget, gpuColorTexture->glRenderbuffer)); + if (gpuColorTexture) { + if (gpuColorTexture->glTexture) { + GL_CHECK(glFramebufferTexture2D(GL_DRAW_FRAMEBUFFER, static_cast(GL_COLOR_ATTACHMENT0 + j), + gpuColorTexture->glTarget, gpuColorTexture->glTexture, 0)); + } else { + GL_CHECK(glFramebufferRenderbuffer(GL_DRAW_FRAMEBUFFER, static_cast(GL_COLOR_ATTACHMENT0 + j), + gpuColorTexture->glTarget, gpuColorTexture->glRenderbuffer)); + } } res.width = std::min(res.width, gpuColorTexture->width); res.height = std::min(res.height, gpuColorTexture->height); diff --git a/native/cocos/renderer/gfx-gles3/GLES3Device.cpp b/native/cocos/renderer/gfx-gles3/GLES3Device.cpp index 263324ea2a..d96d66cf32 100644 --- a/native/cocos/renderer/gfx-gles3/GLES3Device.cpp +++ b/native/cocos/renderer/gfx-gles3/GLES3Device.cpp @@ -247,10 +247,10 @@ void GLES3Device::doDestroy() { CCASSERT(!_memoryStatus.bufferSize, "Buffer memory leaked"); CCASSERT(!_memoryStatus.textureSize, "Texture memory leaked"); - CC_SAFE_DESTROY(_cmdBuff) - CC_SAFE_DESTROY(_queryPool) - CC_SAFE_DESTROY(_queue) - CC_SAFE_DESTROY(_gpuContext) + CC_SAFE_DESTROY_AND_DELETE(_cmdBuff) + CC_SAFE_DESTROY_AND_DELETE(_queryPool) + CC_SAFE_DESTROY_AND_DELETE(_queue) + CC_SAFE_DESTROY_AND_DELETE(_gpuContext) } void GLES3Device::acquire(Swapchain *const *swapchains, uint32_t count) { diff --git a/native/cocos/renderer/gfx-gles3/GLES3Device.h b/native/cocos/renderer/gfx-gles3/GLES3Device.h index 2aaec972dc..e66106eb77 100644 --- a/native/cocos/renderer/gfx-gles3/GLES3Device.h +++ b/native/cocos/renderer/gfx-gles3/GLES3Device.h @@ -26,6 +26,7 @@ #pragma once #include "GLES3Std.h" +#include "base/Any.h" #include "gfx-base/GFXDevice.h" namespace cc { diff --git a/native/cocos/renderer/gfx-gles3/GLES3Swapchain.cpp b/native/cocos/renderer/gfx-gles3/GLES3Swapchain.cpp index 27a36cb6c8..2d9c36020c 100644 --- a/native/cocos/renderer/gfx-gles3/GLES3Swapchain.cpp +++ b/native/cocos/renderer/gfx-gles3/GLES3Swapchain.cpp @@ -46,10 +46,10 @@ GLES3Swapchain::~GLES3Swapchain() { destroy(); } -void GLES3Swapchain::doInit(const SwapchainInfo& info) { - const auto* context = GLES3Device::getInstance()->context(); +void GLES3Swapchain::doInit(const SwapchainInfo &info) { + const auto *context = GLES3Device::getInstance()->context(); _gpuSwapchain = CC_NEW(GLES3GPUSwapchain); - auto window = reinterpret_cast(info.windowHandle); //NOLINT [readability-qualified-auto] + auto *window = reinterpret_cast(info.windowHandle); #if CC_PLATFORM == CC_PLATFORM_ANDROID || CC_PLATFORM == CC_PLATFORM_OHOS EGLint nFmt; @@ -99,7 +99,7 @@ void GLES3Swapchain::doInit(const SwapchainInfo& info) { textureInfo.format = Format::DEPTH_STENCIL; initTexture(textureInfo, _depthStencilTexture); - _gpuSwapchain->gpuColorTexture = static_cast(_colorTexture)->gpuTexture(); + _gpuSwapchain->gpuColorTexture = static_cast(_colorTexture.get())->gpuTexture(); } void GLES3Swapchain::doDestroy() { @@ -121,16 +121,16 @@ void GLES3Swapchain::doResize(uint32_t width, uint32_t height, SurfaceTransform void GLES3Swapchain::doDestroySurface() { if (_gpuSwapchain->eglSurface != EGL_NO_SURFACE) { - auto* context = GLES3Device::getInstance()->context(); + auto *context = GLES3Device::getInstance()->context(); eglDestroySurface(context->eglDisplay, _gpuSwapchain->eglSurface); _gpuSwapchain->eglSurface = EGL_NO_SURFACE; context->bindContext(false); } } -void GLES3Swapchain::doCreateSurface(void* windowHandle) { - auto* context = GLES3Device::getInstance()->context(); - auto window = reinterpret_cast(windowHandle); //NOLINT [readability-qualified-auto] +void GLES3Swapchain::doCreateSurface(void *windowHandle) { + auto *context = GLES3Device::getInstance()->context(); + auto *window = reinterpret_cast(windowHandle); EGLint nFmt = 0; if (eglGetConfigAttrib(context->eglDisplay, context->eglConfig, EGL_NATIVE_VISUAL_ID, &nFmt) == EGL_FALSE) { diff --git a/native/cocos/renderer/gfx-metal/MTLBuffer.mm b/native/cocos/renderer/gfx-metal/MTLBuffer.mm index f9b374df3f..29a318ae54 100644 --- a/native/cocos/renderer/gfx-metal/MTLBuffer.mm +++ b/native/cocos/renderer/gfx-metal/MTLBuffer.mm @@ -97,7 +97,7 @@ void CCMTLBuffer::doInit(const BufferViewInfo &info) { bool CCMTLBuffer::createMTLBuffer(uint size, MemoryUsage usage) { if(!size) { - return; + return false; } _mtlResourceOptions = mu::toMTLResourceOption(usage); @@ -190,17 +190,18 @@ void CCMTLBuffer::update(const void *buffer, uint size) { return; } - uint drawInfoCount = size / _stride; - const auto *drawInfo = static_cast(buffer); - if (drawInfoCount > 0) { - if (drawInfo->indexCount) { - _isDrawIndirectByIndex = true; - } else { - _isDrawIndirectByIndex = false; - } - } + _isDrawIndirectByIndex = false; if (hasFlag(_usage, BufferUsageBit::INDIRECT)) { + + uint drawInfoCount = size / _stride; + const auto *drawInfo = static_cast(buffer); + if (drawInfoCount > 0) { + if (drawInfo->indexCount) { + _isDrawIndirectByIndex = true; + } + } + if (_isIndirectDrawSupported) { if (drawInfoCount > 0) { if (_isDrawIndirectByIndex) { @@ -217,7 +218,7 @@ void CCMTLBuffer::update(const void *buffer, uint size) { } updateMTLBuffer(_indexedPrimitivesIndirectArguments.data(), 0, drawInfoCount * stride); } else { - uint stride = sizeof(MTLDrawIndexedPrimitivesIndirectArguments); + uint stride = sizeof(MTLDrawPrimitivesIndirectArguments); for (uint i = 0; i < drawInfoCount; ++i) { auto &arguments = _primitiveIndirectArguments[i]; diff --git a/native/cocos/renderer/gfx-metal/MTLDevice.mm b/native/cocos/renderer/gfx-metal/MTLDevice.mm index 34d5772392..ed5868e5ec 100644 --- a/native/cocos/renderer/gfx-metal/MTLDevice.mm +++ b/native/cocos/renderer/gfx-metal/MTLDevice.mm @@ -170,9 +170,9 @@ void CCMTLDevice::doDestroy() { _autoreleasePool = nullptr; } - CC_SAFE_DESTROY(_queryPool) - CC_SAFE_DESTROY(_queue); - CC_SAFE_DESTROY(_cmdBuff); + CC_SAFE_DESTROY_AND_DELETE(_queryPool) + CC_SAFE_DESTROY_AND_DELETE(_queue); + CC_SAFE_DESTROY_AND_DELETE(_cmdBuff); CCMTLGPUGarbageCollectionPool::getInstance()->flush(); diff --git a/native/cocos/renderer/gfx-metal/MTLSwapchain.mm b/native/cocos/renderer/gfx-metal/MTLSwapchain.mm index 6cea11e57c..0f16a9d754 100644 --- a/native/cocos/renderer/gfx-metal/MTLSwapchain.mm +++ b/native/cocos/renderer/gfx-metal/MTLSwapchain.mm @@ -122,13 +122,8 @@ void CCMTLSwapchain::doDestroy(){ CC_SAFE_DELETE(_gpuSwapchainObj); } - if(_colorTexture) { - CC_SAFE_DESTROY(_colorTexture); - } - - if(_depthStencilTexture) { - CC_SAFE_DESTROY(_depthStencilTexture); - } + CC_SAFE_DESTROY_AND_DELETE(_colorTexture); + CC_SAFE_DESTROY_AND_DELETE(_depthStencilTexture); } void CCMTLSwapchain::doDestroySurface() { @@ -144,11 +139,11 @@ void CCMTLSwapchain::doResize(uint32_t width, uint32_t height, SurfaceTransform } CCMTLTexture* CCMTLSwapchain::colorTexture() { - return static_cast(_colorTexture); + return static_cast(_colorTexture.get()); } CCMTLTexture* CCMTLSwapchain::depthStencilTexture() { - return static_cast(_depthStencilTexture); + return static_cast(_depthStencilTexture.get()); } id CCMTLSwapchain::currentDrawable() { @@ -157,14 +152,14 @@ id CCMTLSwapchain::currentDrawable() { void CCMTLSwapchain::release() { _gpuSwapchainObj->currentDrawable = nil; - static_cast(_colorTexture)->update(); + static_cast(_colorTexture.get())->update(); } void CCMTLSwapchain::acquire() { // hang on here if next drawable not available while(!_gpuSwapchainObj->currentDrawable) { _gpuSwapchainObj->currentDrawable = [_gpuSwapchainObj->mtlLayer nextDrawable] ; - static_cast(_colorTexture)->update(); + static_cast(_colorTexture.get())->update(); } } diff --git a/native/cocos/renderer/gfx-metal/MTLUtils.mm b/native/cocos/renderer/gfx-metal/MTLUtils.mm index 1b32ae9d66..36b39c81c1 100644 --- a/native/cocos/renderer/gfx-metal/MTLUtils.mm +++ b/native/cocos/renderer/gfx-metal/MTLUtils.mm @@ -838,6 +838,8 @@ MTLSamplerAddressMode mu::toMTLSamplerAddressMode(Address mode) { #endif } } + + return MTLSamplerAddressModeClampToEdge; } int mu::toMTLSamplerBorderColor(const Color &color) { @@ -850,6 +852,8 @@ int mu::toMTLSamplerBorderColor(const Color &color) { else return MTLSamplerBorderColorOpaqueWhite; #endif + + return 0; } MTLSamplerMinMagFilter mu::toMTLSamplerMinMagFilter(Filter filter) { diff --git a/native/cocos/renderer/gfx-validator/SwapchainValidator.cpp b/native/cocos/renderer/gfx-validator/SwapchainValidator.cpp index 3341b22a13..cbf8f384f3 100644 --- a/native/cocos/renderer/gfx-validator/SwapchainValidator.cpp +++ b/native/cocos/renderer/gfx-validator/SwapchainValidator.cpp @@ -41,9 +41,6 @@ SwapchainValidator::SwapchainValidator(Swapchain *actor) } SwapchainValidator::~SwapchainValidator() { - CC_SAFE_DELETE(_depthStencilTexture); - CC_SAFE_DELETE(_colorTexture); - DeviceResourceTracker::erase(this); CC_SAFE_DELETE(_actor); } @@ -59,12 +56,12 @@ void SwapchainValidator::doInit(const SwapchainInfo &info) { auto *colorTexture = CC_NEW(TextureValidator(_actor->getColorTexture())); colorTexture->renounceOwnership(); _colorTexture = colorTexture; - DeviceResourceTracker::push(_colorTexture); + DeviceResourceTracker::push(_colorTexture.get()); auto *depthStencilTexture = CC_NEW(TextureValidator(_actor->getDepthStencilTexture())); depthStencilTexture->renounceOwnership(); _depthStencilTexture = depthStencilTexture; - DeviceResourceTracker::push(_depthStencilTexture); + DeviceResourceTracker::push(_depthStencilTexture.get()); SwapchainTextureInfo textureInfo; textureInfo.swapchain = this; @@ -84,9 +81,8 @@ void SwapchainValidator::doDestroy() { _inited = false; /////////// execute /////////// - - CC_SAFE_DELETE(_depthStencilTexture); - CC_SAFE_DELETE(_colorTexture); + _depthStencilTexture = nullptr; + _colorTexture = nullptr; _actor->destroy(); } @@ -96,11 +92,11 @@ void SwapchainValidator::doResize(uint32_t width, uint32_t height, SurfaceTransf _actor->resize(width, height, transform); - auto *colorTexture = static_cast(_colorTexture); - auto *depthStencilTexture = static_cast(_depthStencilTexture); + auto *colorTexture = static_cast(_colorTexture.get()); + auto *depthStencilTexture = static_cast(_depthStencilTexture.get()); colorTexture->_info.width = depthStencilTexture->_info.width = _actor->getWidth(); colorTexture->_info.height = depthStencilTexture->_info.height = _actor->getHeight(); - _transform = _actor->getSurfaceTransform(); + _transform = _actor->getSurfaceTransform(); } void SwapchainValidator::doDestroySurface() { diff --git a/native/cocos/renderer/gfx-vulkan/VKDevice.cpp b/native/cocos/renderer/gfx-vulkan/VKDevice.cpp index d7c0e1b3ae..6ba5ee6f16 100644 --- a/native/cocos/renderer/gfx-vulkan/VKDevice.cpp +++ b/native/cocos/renderer/gfx-vulkan/VKDevice.cpp @@ -89,7 +89,7 @@ CCVKDevice::~CCVKDevice() { bool CCVKDevice::doInit(const DeviceInfo & /*info*/) { _gpuContext = CC_NEW(CCVKGPUContext); if (!_gpuContext->initialize()) { - CC_SAFE_DESTROY(_gpuContext) + CC_SAFE_DESTROY_AND_DELETE(_gpuContext) return false; } @@ -459,13 +459,13 @@ void CCVKDevice::doDestroy() { SPIRVUtils::getInstance()->destroy(); for (CCVKTexture *texture : _depthStencilTextures) { - CC_SAFE_DESTROY(texture) + CC_SAFE_DESTROY_AND_DELETE(texture) } _depthStencilTextures.clear(); - CC_SAFE_DESTROY(_queryPool) - CC_SAFE_DESTROY(_queue) - CC_SAFE_DESTROY(_cmdBuff) + CC_SAFE_DESTROY_AND_DELETE(_queryPool) + CC_SAFE_DESTROY_AND_DELETE(_queue) + CC_SAFE_DESTROY_AND_DELETE(_cmdBuff) CC_SAFE_DELETE(_gpuBufferHub) CC_SAFE_DELETE(_gpuTransportHub) @@ -535,7 +535,7 @@ void CCVKDevice::doDestroy() { _gpuDevice = nullptr; } - CC_SAFE_DESTROY(_gpuContext) + CC_SAFE_DESTROY_AND_DELETE(_gpuContext) } namespace { diff --git a/native/cocos/renderer/gfx-vulkan/VKSwapchain.cpp b/native/cocos/renderer/gfx-vulkan/VKSwapchain.cpp index 83f7a03b3f..009d602f9f 100644 --- a/native/cocos/renderer/gfx-vulkan/VKSwapchain.cpp +++ b/native/cocos/renderer/gfx-vulkan/VKSwapchain.cpp @@ -306,8 +306,8 @@ bool CCVKSwapchain::checkSwapchainStatus(uint32_t width, uint32_t height) { CCASSERT(imageCount == _gpuSwapchain->createInfo.minImageCount, "swapchain image count assumption is broken"); // should skip size check, since the old swapchain has already been destroyed - static_cast(_colorTexture)->_info.width = 1; - static_cast(_depthStencilTexture)->_info.width = 1; + static_cast(_colorTexture.get())->_info.width = 1; + static_cast(_depthStencilTexture.get())->_info.width = 1; _colorTexture->resize(newWidth, newHeight); _depthStencilTexture->resize(newWidth, newHeight); @@ -322,8 +322,8 @@ bool CCVKSwapchain::checkSwapchainStatus(uint32_t width, uint32_t height) { tempBarrier.subresourceRange.layerCount = VK_REMAINING_ARRAY_LAYERS; VkPipelineStageFlags tempSrcStageMask = 0; VkPipelineStageFlags tempDstStageMask = 0; - auto * colorGPUTexture = static_cast(_colorTexture)->gpuTexture(); - auto * depthStencilGPUTexture = static_cast(_depthStencilTexture)->gpuTexture(); + auto * colorGPUTexture = static_cast(_colorTexture.get())->gpuTexture(); + auto * depthStencilGPUTexture = static_cast(_depthStencilTexture.get())->gpuTexture(); for (uint32_t i = 0U; i < imageCount; i++) { tempBarrier.nextAccessCount = 1; tempBarrier.pNextAccesses = &THSVS_ACCESS_TYPES[toNumber(AccessType::PRESENT)]; diff --git a/native/cocos/renderer/pipeline/BatchedBuffer.cpp b/native/cocos/renderer/pipeline/BatchedBuffer.cpp index 7e644b3ad7..19c0b60344 100644 --- a/native/cocos/renderer/pipeline/BatchedBuffer.cpp +++ b/native/cocos/renderer/pipeline/BatchedBuffer.cpp @@ -65,16 +65,16 @@ BatchedBuffer::~BatchedBuffer() = default; void BatchedBuffer::destroy() { for (auto &batch : _batches) { for (auto *vb : batch.vbs) { - CC_SAFE_DESTROY(vb); + CC_SAFE_DESTROY_AND_DELETE(vb); } for (auto *data : batch.vbDatas) { CC_FREE(data); } - CC_SAFE_DESTROY(batch.indexBuffer); - CC_SAFE_DESTROY(batch.ia); - CC_SAFE_DESTROY(batch.ubo); + CC_SAFE_DESTROY_AND_DELETE(batch.indexBuffer); + CC_SAFE_DESTROY_AND_DELETE(batch.ia); + CC_SAFE_DESTROY_AND_DELETE(batch.ubo); CC_FREE(batch.indexData); } @@ -83,7 +83,7 @@ void BatchedBuffer::destroy() { void BatchedBuffer::merge(const scene::SubModel *subModel, uint passIdx, const scene::Model *model) { const auto *subMesh = subModel->getSubMesh(); - const auto &flatBuffers = subMesh->flatBuffers; + const auto &flatBuffers = subMesh->getFlatBuffers(); auto flatBuffersCount = static_cast(flatBuffers.size()); if (0 == flatBuffersCount) { return; @@ -126,7 +126,7 @@ void BatchedBuffer::merge(const scene::SubModel *subModel, uint passIdx, const s } auto offset = batch.vbCount * flatBuffer.stride; - memcpy(vbData + offset, flatBuffer.data, flatBuffer.size); + memcpy(vbData + offset, flatBuffer.buffer.buffer()->getData(), flatBuffer.buffer.buffer()->byteLength()); } auto *indexData = batch.indexData; @@ -143,9 +143,9 @@ void BatchedBuffer::merge(const scene::SubModel *subModel, uint passIdx, const s const auto start = batch.vbCount; const auto end = start + vbCount; const auto mergeCount = batch.mergeCount; - if (indexData[start] != mergeCount || indexData[end - 1] != mergeCount) { + if (indexData[start] != static_cast(mergeCount) || indexData[end - 1] != static_cast(mergeCount)) { for (auto j = start; j < end; j++) { - indexData[j] = mergeCount + 0.1F; // guard against underflow + indexData[j] = static_cast(mergeCount) + 0.1F; // guard against underflow } } @@ -185,7 +185,7 @@ void BatchedBuffer::merge(const scene::SubModel *subModel, uint passIdx, const s flatBuffer.stride, }); auto size = 0U; - newVB->update(flatBuffer.data, flatBuffer.size); + newVB->update(flatBuffer.buffer.buffer()->getData(), flatBuffer.buffer.buffer()->byteLength()); vbs[i] = newVB; vbDatas[i] = static_cast(CC_MALLOC(newVB->getSize())); diff --git a/native/cocos/renderer/pipeline/ClusterLightCulling.cpp b/native/cocos/renderer/pipeline/ClusterLightCulling.cpp index a32bd80d17..dc06e41433 100644 --- a/native/cocos/renderer/pipeline/ClusterLightCulling.cpp +++ b/native/cocos/renderer/pipeline/ClusterLightCulling.cpp @@ -27,6 +27,8 @@ #include "Define.h" #include "deferred/DeferredPipeline.h" #include "frame-graph/FrameGraph.h" +#include "scene/SphereLight.h" +#include "scene/SpotLight.h" namespace cc { namespace pipeline { @@ -41,28 +43,28 @@ framegraph::StringHandle fgStrHandleClusterBuildPass = framegraph::FrameGraph: framegraph::StringHandle fgStrHandleClusterCullingPass = framegraph::FrameGraph::stringToHandle("clusterCullingPass"); ClusterLightCulling::~ClusterLightCulling() { - CC_SAFE_DESTROY(_buildingShader); - CC_SAFE_DESTROY(_buildingDescriptorSetLayout); - CC_SAFE_DESTROY(_buildingPipelineLayout); - CC_SAFE_DESTROY(_buildingPipelineState); - CC_SAFE_DESTROY(_buildingDescriptorSet); + CC_SAFE_DESTROY_AND_DELETE(_buildingShader); + CC_SAFE_DESTROY_AND_DELETE(_buildingDescriptorSetLayout); + CC_SAFE_DESTROY_AND_DELETE(_buildingPipelineLayout); + CC_SAFE_DESTROY_AND_DELETE(_buildingPipelineState); + CC_SAFE_DESTROY_AND_DELETE(_buildingDescriptorSet); - CC_SAFE_DESTROY(_resetCounterShader); - CC_SAFE_DESTROY(_resetCounterDescriptorSetLayout); - CC_SAFE_DESTROY(_resetCounterPipelineLayout); - CC_SAFE_DESTROY(_resetCounterPipelineState); - CC_SAFE_DESTROY(_resetCounterDescriptorSet); + CC_SAFE_DESTROY_AND_DELETE(_resetCounterShader); + CC_SAFE_DESTROY_AND_DELETE(_resetCounterDescriptorSetLayout); + CC_SAFE_DESTROY_AND_DELETE(_resetCounterPipelineLayout); + CC_SAFE_DESTROY_AND_DELETE(_resetCounterPipelineState); + CC_SAFE_DESTROY_AND_DELETE(_resetCounterDescriptorSet); - CC_SAFE_DESTROY(_cullingShader); - CC_SAFE_DESTROY(_cullingDescriptorSetLayout); - CC_SAFE_DESTROY(_cullingPipelineLayout); - CC_SAFE_DESTROY(_cullingPipelineState); - CC_SAFE_DESTROY(_cullingDescriptorSet); + CC_SAFE_DESTROY_AND_DELETE(_cullingShader); + CC_SAFE_DESTROY_AND_DELETE(_cullingDescriptorSetLayout); + CC_SAFE_DESTROY_AND_DELETE(_cullingPipelineLayout); + CC_SAFE_DESTROY_AND_DELETE(_cullingPipelineState); + CC_SAFE_DESTROY_AND_DELETE(_cullingDescriptorSet); - CC_SAFE_DESTROY(_constantsBuffer); + CC_SAFE_DESTROY_AND_DELETE(_constantsBuffer); } -void ClusterLightCulling::initialize(gfx::Device* dev) { +void ClusterLightCulling::initialize(gfx::Device *dev) { _device = dev; if (!_device->hasFeature(gfx::Feature::COMPUTE_SHADER)) return; @@ -109,18 +111,18 @@ void ClusterLightCulling::initialize(gfx::Device* dev) { void ClusterLightCulling::update() { if (!_initialized) return; - auto* const sceneData = _pipeline->getPipelineSceneData(); - auto* const sharedData = sceneData->getSharedData(); + auto *const sceneData = _pipeline->getPipelineSceneData(); - _constants[NEAR_FAR_OFFSET + 0] = static_cast(_camera->nearClip); - _constants[NEAR_FAR_OFFSET + 1] = static_cast(_camera->farClip); - _constants[VIEW_PORT_OFFSET + 0] = _camera->viewPort.x * static_cast(_camera->width) * sharedData->shadingScale; - _constants[VIEW_PORT_OFFSET + 1] = _camera->viewPort.y * static_cast(_camera->height) * sharedData->shadingScale; - _constants[VIEW_PORT_OFFSET + 2] = _camera->viewPort.z * static_cast(_camera->width) * sharedData->shadingScale; - _constants[VIEW_PORT_OFFSET + 3] = _camera->viewPort.w * static_cast(_camera->height) * sharedData->shadingScale; + _constants[NEAR_FAR_OFFSET + 0] = static_cast(_camera->getNearClip()); + _constants[NEAR_FAR_OFFSET + 1] = static_cast(_camera->getFarClip()); + const auto &viewport = _camera->getViewport(); + _constants[VIEW_PORT_OFFSET + 0] = viewport.x * static_cast(_camera->getWidth()) * sceneData->getShadingScale(); + _constants[VIEW_PORT_OFFSET + 1] = viewport.y * static_cast(_camera->getHeight()) * sceneData->getShadingScale(); + _constants[VIEW_PORT_OFFSET + 2] = viewport.z * static_cast(_camera->getWidth()) * sceneData->getShadingScale(); + _constants[VIEW_PORT_OFFSET + 3] = viewport.w * static_cast(_camera->getHeight()) * sceneData->getShadingScale(); - memcpy(_constants.data() + MAT_VIEW_OFFSET, _camera->matView.m, sizeof(cc::Mat4)); - memcpy(_constants.data() + MAT_PROJ_INV_OFFSET, _camera->matProjInv.m, sizeof(cc::Mat4)); + memcpy(_constants.data() + MAT_VIEW_OFFSET, _camera->getMatView().m, sizeof(cc::Mat4)); + memcpy(_constants.data() + MAT_PROJ_INV_OFFSET, _camera->getMatProjInv().m, sizeof(cc::Mat4)); _constantsBuffer->update(_constants.data(), 2 * sizeof(Vec4) + 2 * sizeof(Mat4)); updateLights(); @@ -130,10 +132,10 @@ void ClusterLightCulling::update() { _rebuildClusters = true; uint nextLength = std::max(nextPow2(static_cast(cameraIndex)), uint(1)); _oldCamProjMats.resize(nextLength, Mat4::ZERO); - _oldCamProjMats[cameraIndex] = _camera->matProj; + _oldCamProjMats[cameraIndex] = _camera->getMatProj(); } else { - _rebuildClusters = ClusterLightCulling::isProjMatChange(_camera->matProj, _oldCamProjMats[cameraIndex]); - _oldCamProjMats[cameraIndex] = _camera->matProj; + _rebuildClusters = ClusterLightCulling::isProjMatChange(_camera->getMatProj(), _oldCamProjMats[cameraIndex]); + _oldCamProjMats[cameraIndex] = _camera->getMatProj(); } } @@ -144,28 +146,27 @@ void ClusterLightCulling::updateLights() { _validLights.clear(); - scene::Sphere sphere; - const auto* const scene = _camera->scene; - for (auto* light : scene->getSphereLights()) { + geometry::Sphere sphere; + const auto *const scene = _camera->getScene(); + for (const auto &light : scene->getSphereLights()) { sphere.setCenter(light->getPosition()); sphere.setRadius(light->getRange()); - if (sphere.sphereFrustum(_camera->frustum)) { - _validLights.emplace_back(static_cast(light)); + if (sphere.sphereFrustum(_camera->getFrustum())) { + _validLights.emplace_back(static_cast(light)); } } - for (auto* light : scene->getSpotLights()) { + for (const auto &light : scene->getSpotLights()) { sphere.setCenter(light->getPosition()); sphere.setRadius(light->getRange()); - if (sphere.sphereFrustum(_camera->frustum)) { - _validLights.emplace_back(static_cast(light)); + if (sphere.sphereFrustum(_camera->getFrustum())) { + _validLights.emplace_back(static_cast(light)); } } - const auto exposure = _camera->exposure; + const auto exposure = _camera->getExposure(); const auto validLightCount = _validLights.size(); - auto* const sceneData = _pipeline->getPipelineSceneData(); - auto* const sharedData = sceneData->getSharedData(); + auto *const sceneData = _pipeline->getPipelineSceneData(); if (validLightCount > _lightBufferCount) { _lightBufferResized = true; @@ -174,13 +175,13 @@ void ClusterLightCulling::updateLights() { } for (unsigned l = 0, offset = 0; l < validLightCount; l++, offset += 16) { - auto* light = _validLights[l]; + auto * light = _validLights[l]; const bool isSpotLight = scene::LightType::SPOT == light->getType(); - const auto* spotLight = isSpotLight ? static_cast(light) : nullptr; - const auto* sphereLight = isSpotLight ? nullptr : static_cast(light); + const auto *spotLight = isSpotLight ? static_cast(light) : nullptr; + const auto *sphereLight = isSpotLight ? nullptr : static_cast(light); auto index = offset + UBOForwardLight::LIGHT_POS_OFFSET; - const auto& position = isSpotLight ? spotLight->getPosition() : sphereLight->getPosition(); + const auto &position = isSpotLight ? spotLight->getPosition() : sphereLight->getPosition(); _lightBufferData[index++] = position.x; _lightBufferData[index++] = position.y; _lightBufferData[index] = position.z; @@ -190,9 +191,9 @@ void ClusterLightCulling::updateLights() { _lightBufferData[index] = isSpotLight ? spotLight->getRange() : sphereLight->getRange(); index = offset + UBOForwardLight::LIGHT_COLOR_OFFSET; - const auto& color = light->getColor(); - if (light->getUseColorTemperature()) { - const auto& tempRGB = light->getColorTemperatureRGB(); + const auto &color = light->getColor(); + if (light->isUseColorTemperature()) { + const auto &tempRGB = light->getColorTemperatureRGB(); _lightBufferData[index++] = color.x * tempRGB.x; _lightBufferData[index++] = color.y * tempRGB.y; _lightBufferData[index++] = color.z * tempRGB.z; @@ -204,7 +205,7 @@ void ClusterLightCulling::updateLights() { float luminanceHDR = isSpotLight ? spotLight->getLuminanceHDR() : sphereLight->getLuminanceHDR(); float luminanceLDR = isSpotLight ? spotLight->getLuminanceLDR() : sphereLight->getLuminanceLDR(); - if (sharedData->isHDR) { + if (sceneData->isHDR()) { _lightBufferData[index] = luminanceHDR * exposure * _lightMeterScale; } else { _lightBufferData[index] = luminanceLDR; @@ -220,7 +221,7 @@ void ClusterLightCulling::updateLights() { _lightBufferData[offset + UBOForwardLight::LIGHT_SIZE_RANGE_ANGLE_OFFSET + 2] = spotLight->getSpotAngle(); index = offset + UBOForwardLight::LIGHT_DIR_OFFSET; - const auto& direction = spotLight->getDirection(); + const auto &direction = spotLight->getDirection(); _lightBufferData[index++] = direction.x; _lightBufferData[index++] = direction.y; _lightBufferData[index] = direction.z; @@ -657,7 +658,7 @@ void ClusterLightCulling::initCullingStage() { _cullingPipelineState = _device->createPipelineState(pipelineInfo); } -void ClusterLightCulling::clusterLightCulling(scene::Camera* camera) { +void ClusterLightCulling::clusterLightCulling(scene::Camera *camera) { if (!_initialized || _pipeline->getPipelineUBO()->getCurrentCameraUBOOffset() != 0) return; _camera = camera; update(); // update ubo and light data @@ -667,7 +668,7 @@ void ClusterLightCulling::clusterLightCulling(scene::Camera* camera) { framegraph::BufferHandle globalIndexBuffer; // global light index storage buffer }; - auto clusterBuildSetup = [&](framegraph::PassNodeBuilder& builder, DataClusterBuild& data) { + auto clusterBuildSetup = [&](framegraph::PassNodeBuilder &builder, DataClusterBuild &data) { data.clusterBuffer = framegraph::BufferHandle(builder.readFromBlackboard(fgStrHandleClusterBuffer)); if (!data.clusterBuffer.isValid()) { // each cluster has 2 vec4, min + max position for AABB @@ -707,22 +708,22 @@ void ClusterLightCulling::clusterLightCulling(scene::Camera* camera) { builder.writeToBlackboard(fgStrHandleClusterGlobalIndexBuffer, data.globalIndexBuffer); }; - auto clusterBuildExec = [&](DataClusterBuild const& data, const framegraph::DevicePassResourceTable& table) { - auto* cmdBuff = _pipeline->getCommandBuffers()[0]; + auto clusterBuildExec = [&](DataClusterBuild const &data, const framegraph::DevicePassResourceTable &table) { + auto *cmdBuff = _pipeline->getCommandBuffers()[0]; if (_rebuildClusters) { // building cluster _buildingDescriptorSet->bindBuffer(0, _constantsBuffer); _buildingDescriptorSet->bindBuffer(1, table.getWrite(data.clusterBuffer)); _buildingDescriptorSet->update(); - cmdBuff->bindPipelineState(const_cast(_buildingPipelineState)); - cmdBuff->bindDescriptorSet(0, const_cast(_buildingDescriptorSet)); + cmdBuff->bindPipelineState(const_cast(_buildingPipelineState)); + cmdBuff->bindDescriptorSet(0, const_cast(_buildingDescriptorSet)); cmdBuff->dispatch(_buildingDispatchInfo); } // reset global index _resetCounterDescriptorSet->bindBuffer(0, table.getWrite(data.globalIndexBuffer)); _resetCounterDescriptorSet->update(); - cmdBuff->bindPipelineState(const_cast(_resetCounterPipelineState)); - cmdBuff->bindDescriptorSet(0, const_cast(_resetCounterDescriptorSet)); + cmdBuff->bindPipelineState(const_cast(_resetCounterPipelineState)); + cmdBuff->bindDescriptorSet(0, const_cast(_resetCounterDescriptorSet)); cmdBuff->dispatch(_resetDispatchInfo); cmdBuff->pipelineBarrier(_resetBarrier); }; @@ -735,7 +736,7 @@ void ClusterLightCulling::clusterLightCulling(scene::Camera* camera) { framegraph::BufferHandle globalIndexBuffer; // global light index storage buffer }; - auto lightCullingSetup = [&](framegraph::PassNodeBuilder& builder, DataLightCulling& data) { + auto lightCullingSetup = [&](framegraph::PassNodeBuilder &builder, DataLightCulling &data) { data.lightBuffer = framegraph::BufferHandle(builder.readFromBlackboard(fgStrHandleClusterLightBuffer)); if (!data.lightBuffer.isValid() || _lightBufferResized) { framegraph::Buffer::Descriptor bufferInfo; @@ -795,8 +796,8 @@ void ClusterLightCulling::clusterLightCulling(scene::Camera* camera) { builder.writeToBlackboard(fgStrHandleClusterGlobalIndexBuffer, data.globalIndexBuffer); }; - auto lightCullingExec = [&](DataLightCulling const& data, const framegraph::DevicePassResourceTable& table) { - auto* cmdBuff = _pipeline->getCommandBuffers()[0]; + auto lightCullingExec = [&](DataLightCulling const &data, const framegraph::DevicePassResourceTable &table) { + auto *cmdBuff = _pipeline->getCommandBuffers()[0]; cmdBuff->updateBuffer(table.getRead(data.lightBuffer), _lightBufferData.data(), static_cast(_lightBufferData.size() * sizeof(float))); @@ -808,18 +809,18 @@ void ClusterLightCulling::clusterLightCulling(scene::Camera* camera) { _cullingDescriptorSet->bindBuffer(5, table.getRead(data.globalIndexBuffer)); _cullingDescriptorSet->update(); // light culling - cmdBuff->bindPipelineState(const_cast(_cullingPipelineState)); - cmdBuff->bindDescriptorSet(0, const_cast(_cullingDescriptorSet)); + cmdBuff->bindPipelineState(const_cast(_cullingPipelineState)); + cmdBuff->bindDescriptorSet(0, const_cast(_cullingDescriptorSet)); cmdBuff->dispatch(_cullingDispatchInfo); }; - auto* pipeline = static_cast(_pipeline); + auto *pipeline = static_cast(_pipeline); uint insertPoint = static_cast(DeferredInsertPoint::DIP_CLUSTER); pipeline->getFrameGraph().addPass(insertPoint++, fgStrHandleClusterBuildPass, clusterBuildSetup, clusterBuildExec); pipeline->getFrameGraph().addPass(insertPoint++, fgStrHandleClusterCullingPass, lightCullingSetup, lightCullingExec); } -String& ClusterLightCulling::getShaderSource(ShaderStrings& sources) { +String &ClusterLightCulling::getShaderSource(ShaderStrings &sources) { switch (_device->getGfxAPI()) { case gfx::API::GLES2: return sources.glsl1; diff --git a/native/cocos/renderer/pipeline/Define.cpp b/native/cocos/renderer/pipeline/Define.cpp index a97ab92476..8d1f22789b 100644 --- a/native/cocos/renderer/pipeline/Define.cpp +++ b/native/cocos/renderer/pipeline/Define.cpp @@ -278,12 +278,12 @@ const gfx::UniformBlock UBOMorph::LAYOUT = { UBOMorph::NAME, { {"cc_displacementWeights", gfx::Type::FLOAT4, static_cast(UBOMorph::MAX_MORPH_TARGET_COUNT / 4)}, - {"cc_displacementWeights", gfx::Type::FLOAT4, 1}, + {"cc_displacementTextureInfo", gfx::Type::FLOAT4, 1}, }, 1, }; -const String UBOUILocal::NAME = "CCMorph"; +const String UBOUILocal::NAME = "CCUILocal"; const gfx::DescriptorSetLayoutBinding UBOUILocal::DESCRIPTOR = { UBOUILocal::BINDING, gfx::DescriptorType::DYNAMIC_UNIFORM_BUFFER, @@ -517,25 +517,17 @@ bool supportsFloatTexture(gfx::Device *device) { device->getGfxAPI() != gfx::API::GLES2; } -uint getPhaseID(const String &phase) { - se::Object *globalObj = se::ScriptEngine::getInstance()->getGlobalObject(); +static std::unordered_map phases; //cjh how to clear this global variable when exiting game? +static uint32_t phaseNum = 0; - se::Value nrValue; - if (!globalObj->getProperty("nr", &nrValue)) { - CC_LOG_ERROR("getPhaseID: failed to get nr property."); - return 0; +uint getPhaseID(const String &phaseName) { + auto iter = phases.find(phaseName); + if (iter == phases.end()) { + phases.emplace(phaseName, 1 << phaseNum); + ++phaseNum; } - se::Object *nrObjct = nrValue.toObject(); - se::Value nrPhase; - if (!nrObjct->getProperty("getPhaseID", &nrPhase)) { - CC_LOG_ERROR("getPhaseID: failed to get getPhaseID property."); - return 0; - } - se::ValueArray args; - args.push_back(se::Value(phase)); - se::Value nrResult; - nrPhase.toObject()->call(args, nullptr, &nrResult); - return nrResult.toUint32(); + return phases.at(phaseName); } + } // namespace pipeline } // namespace cc diff --git a/native/cocos/renderer/pipeline/Define.h b/native/cocos/renderer/pipeline/Define.h index cdadf213db..ba9fb1f1aa 100644 --- a/native/cocos/renderer/pipeline/Define.h +++ b/native/cocos/renderer/pipeline/Define.h @@ -25,16 +25,22 @@ #pragma once -#include #include +#include #include "base/Object.h" #include "base/TypeDef.h" #include "base/Value.h" +#include "gfx-base/GFXDef-common.h" #include "renderer/gfx-base/GFXDef.h" #include "scene/Light.h" -#include "scene/Model.h" namespace cc { + +namespace scene { +class Model; +class SubModel; +} // namespace scene + namespace pipeline { class RenderStage; @@ -132,8 +138,8 @@ struct CC_DLL InternalBindingInst : public InternalBindingDesc { }; struct CC_DLL RenderQueueCreateInfo { - bool isTransparent = false; - uint phases = 0; + bool isTransparent = false; + uint phases = 0; std::function sortFunc; }; @@ -151,8 +157,8 @@ enum class CC_DLL RenderQueueSortMode { CC_ENUM_CONVERSION_OPERATOR(RenderQueueSortMode) struct CC_DLL RenderQueueDesc { - bool isTransparent = false; - RenderQueueSortMode sortMode = RenderQueueSortMode::FRONT_TO_BACK; + bool isTransparent = false; + RenderQueueSortMode sortMode = RenderQueueSortMode::FRONT_TO_BACK; StringArray stages; }; using RenderQueueDescList = std::vector; @@ -253,6 +259,7 @@ enum class CC_DLL SetIndex { GLOBAL, MATERIAL, LOCAL, + COUNT, }; CC_ENUM_CONVERSION_OPERATOR(SetIndex) diff --git a/native/cocos/renderer/pipeline/GeometryRenderer.cpp b/native/cocos/renderer/pipeline/GeometryRenderer.cpp index 5b697b1905..0b79ed0ab7 100644 --- a/native/cocos/renderer/pipeline/GeometryRenderer.cpp +++ b/native/cocos/renderer/pipeline/GeometryRenderer.cpp @@ -32,8 +32,8 @@ #include "base/Log.h" #include "math/Mat4.h" #include "math/Math.h" -#include "scene/AABB.h" -#include "scene/Frustum.h" +#include "core/geometry/AABB.h" +#include "core/geometry/Frustum.h" namespace cc { namespace pipeline { @@ -199,9 +199,8 @@ void GeometryRenderer::render(gfx::RenderPass* renderPass, gfx::CommandBuffer* c update(); const auto* sceneData = _pipeline->getPipelineSceneData(); - const auto* sharedData = sceneData->getSharedData(); - const auto& passes = sharedData->geometryRendererPasses; - const auto& shaders = sharedData->geometryRendererShaders; + const auto& passes = sceneData->getGeometryRendererPasses(); + const auto& shaders = sceneData->getGeometryRendererShaders(); uint32_t offset = 0U; const uint32_t passCount[GEOMETRY_DEPTH_TYPE_COUNT] = {GEOMETRY_NO_DEPTH_TEST_PASS_NUM, GEOMETRY_DEPTH_TEST_PASS_NUM}; @@ -372,7 +371,7 @@ void GeometryRenderer::addQuad(const Vec3& v0, const Vec3& v1, const Vec3& v2, c } } -void GeometryRenderer::addBoundingBox(const scene::AABB* aabb, gfx::Color color, bool wireframe, bool depthTest, bool unlit, bool useTransform, const Mat4& transform) { +void GeometryRenderer::addBoundingBox(const geometry::AABB* aabb, gfx::Color color, bool wireframe, bool depthTest, bool unlit, bool useTransform, const Mat4& transform) { /** * 2---3 * / / @@ -438,7 +437,7 @@ void GeometryRenderer::addCross(const Vec3& center, float size, gfx::Color color addLine(Vec3(center.x, center.y, center.z - halfSize), Vec3(center.x, center.y, center.z + halfSize), color, depthTest); } -void GeometryRenderer::addFrustum(const scene::Frustum* frustum, gfx::Color color, bool depthTest) { +void GeometryRenderer::addFrustum(const geometry::Frustum* frustum, gfx::Color color, bool depthTest) { const auto& vertices = frustum->vertices; addLine(vertices[0], vertices[1], color, depthTest); diff --git a/native/cocos/renderer/pipeline/GeometryRenderer.h b/native/cocos/renderer/pipeline/GeometryRenderer.h index 7bc029f0c3..a081a044ce 100644 --- a/native/cocos/renderer/pipeline/GeometryRenderer.h +++ b/native/cocos/renderer/pipeline/GeometryRenderer.h @@ -27,6 +27,7 @@ #include #include "base/Macros.h" +#include "base/RefCounted.h" #include "gfx-base/GFXDef-common.h" #include "gfx-base/GFXDevice.h" #include "math/Vec2.h" @@ -42,9 +43,12 @@ class RenderPass; class CommandBuffer; } // namespace gfx -namespace scene { +namespace geometry { class AABB; -struct Frustum; +class Frustum; +} // namespace geometry + +namespace scene { class Pass; } // namespace scene @@ -61,10 +65,10 @@ struct GeometryConfig { uint32_t maxTriangles{0U}; }; -class GeometryRenderer { +class GeometryRenderer : public RefCounted { public: GeometryRenderer(); - ~GeometryRenderer(); + ~GeometryRenderer() override; GeometryRenderer(const GeometryRenderer &) = delete; GeometryRenderer(GeometryRenderer &&) = delete; GeometryRenderer &operator=(const GeometryRenderer &) = delete; @@ -79,9 +83,9 @@ public: void addLine(const Vec3 &v0, const Vec3 &v1, gfx::Color color, bool depthTest = true); void addTriangle(const Vec3 &v0, const Vec3 &v1, const Vec3 &v2, gfx::Color color, bool wireframe = true, bool depthTest = true, bool unlit = false); // counterclockwise void addQuad(const Vec3 &v0, const Vec3 &v1, const Vec3 &v2, const Vec3 &v3, gfx::Color color, bool wireframe = true, bool depthTest = true, bool unlit = false); // counterclockwise - void addBoundingBox(const scene::AABB *aabb, gfx::Color color, bool wireframe = true, bool depthTest = true, bool unlit = false, bool useTransform = false, const Mat4 &transform = Mat4()); + void addBoundingBox(const geometry::AABB *aabb, gfx::Color color, bool wireframe = true, bool depthTest = true, bool unlit = false, bool useTransform = false, const Mat4 &transform = Mat4()); void addCross(const Vec3 ¢er, float size, gfx::Color color, bool depthTest = true); - void addFrustum(const scene::Frustum *frustum, gfx::Color color, bool depthTest = true); + void addFrustum(const geometry::Frustum *frustum, gfx::Color color, bool depthTest = true); void addCapsule(const Vec3 ¢er, float radius, float height, gfx::Color color, uint32_t segmentsU = 32U, uint32_t hemiSegmentsV = 8U, bool wireframe = true, bool depthTest = true, bool unlit = false, bool useTransform = false, const Mat4 &transform = Mat4()); void addCylinder(const Vec3 ¢er, float radius, float height, gfx::Color color, uint32_t segments = 32U, bool wireframe = true, bool depthTest = true, bool unlit = false, bool useTransform = false, const Mat4 &transform = Mat4()); void addCone(const Vec3 ¢er, float radius, float height, gfx::Color color, uint32_t segments = 32U, bool wireframe = true, bool depthTest = true, bool unlit = false, bool useTransform = false, const Mat4 &transform = Mat4()); diff --git a/native/cocos/renderer/pipeline/GlobalDescriptorSetManager.h b/native/cocos/renderer/pipeline/GlobalDescriptorSetManager.h index 506f33596e..bad881c6d3 100644 --- a/native/cocos/renderer/pipeline/GlobalDescriptorSetManager.h +++ b/native/cocos/renderer/pipeline/GlobalDescriptorSetManager.h @@ -58,7 +58,6 @@ public: gfx::DescriptorSet *getOrCreateDescriptorSet(uint idx); void destroy(); -protected: static void setDescriptorSetLayout(); private: diff --git a/native/cocos/renderer/pipeline/InstancedBuffer.cpp b/native/cocos/renderer/pipeline/InstancedBuffer.cpp index c8e048d959..6f7105d86a 100644 --- a/native/cocos/renderer/pipeline/InstancedBuffer.cpp +++ b/native/cocos/renderer/pipeline/InstancedBuffer.cpp @@ -67,8 +67,8 @@ InstancedBuffer::~InstancedBuffer() = default; void InstancedBuffer::destroy() { for (auto &instance : _instances) { - CC_SAFE_DESTROY(instance.vb); - CC_SAFE_DESTROY(instance.ia); + CC_SAFE_DESTROY_AND_DELETE(instance.vb); + CC_SAFE_DESTROY_AND_DELETE(instance.ia); CC_FREE(instance.data); } _instances.clear(); @@ -141,8 +141,7 @@ void InstancedBuffer::merge(const scene::Model *model, const scene::SubModel *su attribute.isNormalized, static_cast(vertexBuffers.size()), // stream true, - attribute.location - }); + attribute.location}); } auto *data = static_cast(CC_MALLOC(newSize)); diff --git a/native/cocos/renderer/pipeline/PipelineSceneData.cpp b/native/cocos/renderer/pipeline/PipelineSceneData.cpp index d386f2c466..dda451139d 100644 --- a/native/cocos/renderer/pipeline/PipelineSceneData.cpp +++ b/native/cocos/renderer/pipeline/PipelineSceneData.cpp @@ -24,31 +24,133 @@ ****************************************************************************/ #include "PipelineSceneData.h" +#include "core/ArrayBuffer.h" +#include "gfx-base/GFXDef-common.h" #include "gfx-base/GFXDevice.h" #include "gfx-base/GFXFramebuffer.h" +#include "scene/Ambient.h" +#include "scene/Fog.h" +#include "scene/Octree.h" +#include "scene/Shadow.h" +#include "scene/Skybox.h" + +#include namespace cc { namespace pipeline { -void PipelineSceneData::activate(gfx::Device *device, RenderPipeline *pipeline) -{ - _device = device; +PipelineSceneData::PipelineSceneData() { + _fog = new scene::Fog(); // cjh how to delete? + _ambient = new scene::Ambient(); + _skybox = new scene::Skybox(); + _shadow = new scene::Shadows(); + _octree = new scene::Octree(); +} + +PipelineSceneData::~PipelineSceneData() { + CC_SAFE_DELETE(_fog); // cjh correct ? + CC_SAFE_DELETE(_ambient); + CC_SAFE_DELETE(_skybox); + CC_SAFE_DELETE(_shadow); + CC_SAFE_DELETE(_octree); +} + +void PipelineSceneData::activate(gfx::Device *device, RenderPipeline *pipeline) { + _device = device; _pipeline = pipeline; + initGeometryRendererMaterials(); + initOcclusionQuery(); } -void PipelineSceneData::setPipelineSharedSceneData(scene::PipelineSharedSceneData *data) -{ - _sharedSceneData = data; -} - -void PipelineSceneData::destroy() -{ +void PipelineSceneData::destroy() { for (auto &pair : _shadowFrameBufferMap) { pair.second->destroy(); delete pair.second; } _shadowFrameBufferMap.clear(); + _validPunctualLights.clear(); + + CC_SAFE_DESTROY_NULL(_occlusionQueryInputAssembler); + CC_SAFE_DESTROY_NULL(_occlusionQueryVertexBuffer); + CC_SAFE_DESTROY_NULL(_occlusionQueryIndicesBuffer); +} + +void PipelineSceneData::initOcclusionQuery() { + if (!_occlusionQueryInputAssembler) { + _occlusionQueryInputAssembler = createOcclusionQueryIA(); + } + + if (!_occlusionQueryMaterial) { + _occlusionQueryMaterial = new Material(); + _occlusionQueryMaterial->initDefault(std::string{"default-occlusion-query-material"}); + IMaterialInfo info; + info.effectName = "occlusion-query"; + _occlusionQueryMaterial->initialize(info); + _occlusionQueryPass = (*_occlusionQueryMaterial->getPasses())[0]; + _occlusionQueryShader = _occlusionQueryPass->getShaderVariant(); + } +} + +void PipelineSceneData::initGeometryRendererMaterials() { + _geometryRendererMaterials.resize(GEOMETRY_RENDERER_TECHNIQUE_COUNT); + _geometryRendererPasses.reserve(GEOMETRY_RENDERER_TECHNIQUE_COUNT); + _geometryRendererShaders.reserve(GEOMETRY_RENDERER_TECHNIQUE_COUNT); + + for (uint32_t tech = 0; tech < GEOMETRY_RENDERER_TECHNIQUE_COUNT; tech++) { + _geometryRendererMaterials[tech] = new Material(); + + std::stringstream ss; + ss << "geometry-renderer-material-" << tech; + _geometryRendererMaterials[tech]->setUuid(ss.str()); + + IMaterialInfo materialInfo; + materialInfo.effectName = "geometry-renderer"; + materialInfo.technique = tech; + _geometryRendererMaterials[tech]->initialize(materialInfo); + + const auto &passes = _geometryRendererMaterials[tech]->getPasses().get(); + for (const auto &pass : *passes) { + _geometryRendererPasses.emplace_back(pass); + _geometryRendererShaders.emplace_back(pass->getShaderVariant()); + } + } +} + +scene::Pass *PipelineSceneData::getOcclusionQueryPass() { + if (_occlusionQueryMaterial) { + const auto &passes = *_occlusionQueryMaterial->getPasses(); + return passes[0].get(); + } + + return nullptr; +} + +gfx::InputAssembler *PipelineSceneData::createOcclusionQueryIA() { + // create vertex buffer + const float vertices[] = {-1, -1, -1, 1, -1, -1, -1, 1, -1, 1, 1, -1, -1, -1, 1, 1, -1, 1, -1, 1, 1, 1, 1, 1}; + uint32_t vbStride = sizeof(float) * 3; + uint32_t vbSize = vbStride * 8; + + _occlusionQueryVertexBuffer = _device->createBuffer(gfx::BufferInfo{ + gfx::BufferUsageBit::VERTEX | gfx::BufferUsageBit::TRANSFER_DST, + gfx::MemoryUsageBit::DEVICE, vbSize, vbStride}); + _occlusionQueryVertexBuffer->update(vertices); + + // create index buffer + const uint16_t indices[] = {0, 2, 1, 1, 2, 3, 4, 5, 6, 5, 7, 6, 1, 3, 7, 1, 7, 5, 0, 4, 6, 0, 6, 2, 0, 1, 5, 0, 5, 4, 2, 6, 7, 2, 7, 3}; + uint32_t ibStride = sizeof(uint16_t); + uint32_t ibSize = ibStride * 36; + _occlusionQueryIndicesBuffer = _device->createBuffer(gfx::BufferInfo{ + gfx::BufferUsageBit::INDEX | gfx::BufferUsageBit::TRANSFER_DST, + gfx::MemoryUsageBit::DEVICE, ibSize, ibStride}); + _occlusionQueryIndicesBuffer->update(indices); + + gfx::AttributeList attributes{gfx::Attribute{gfx::ATTR_NAME_POSITION, gfx::Format::RGB32F}}; + + // create cube input assembler + gfx::InputAssemblerInfo info{attributes, {_occlusionQueryVertexBuffer}, _occlusionQueryIndicesBuffer}; + return _device->createInputAssembler(info); } } // namespace pipeline diff --git a/native/cocos/renderer/pipeline/PipelineSceneData.h b/native/cocos/renderer/pipeline/PipelineSceneData.h index d8c6f2a8cb..a27739832d 100644 --- a/native/cocos/renderer/pipeline/PipelineSceneData.h +++ b/native/cocos/renderer/pipeline/PipelineSceneData.h @@ -26,39 +26,47 @@ #pragma once #include "Define.h" -#include "scene/Define.h" +#include "core/assets/Material.h" +#include "core/geometry/Sphere.h" +#include "gfx-base/GFXBuffer.h" #include "scene/Light.h" -#include "scene/Sphere.h" +#include "scene/Pass.h" namespace cc { namespace gfx { class Framebuffer; } - +namespace scene { +class Ambient; +class Shadows; +class Skybox; +class Fog; +class Octree; +} // namespace scene namespace pipeline { class RenderPipeline; class CC_DLL PipelineSceneData : public Object { public: - PipelineSceneData() = default; - ~PipelineSceneData() override = default; - void activate(gfx::Device *device, RenderPipeline *pipeline); - void setPipelineSharedSceneData(scene::PipelineSharedSceneData *data); - void destroy(); + PipelineSceneData(); + ~PipelineSceneData() override; + virtual void activate(gfx::Device *device, RenderPipeline *pipeline); + void destroy(); + + virtual void onGlobalPipelineStateChanged() {} inline void setShadowFramebuffer(const scene::Light *light, gfx::Framebuffer *framebuffer) { _shadowFrameBufferMap.emplace(light, framebuffer); } inline const std::unordered_map &getShadowFramebufferMap() const { return _shadowFrameBufferMap; } - inline scene::PipelineSharedSceneData * getSharedData() const { return _sharedSceneData; } inline const RenderObjectList & getRenderObjects() const { return _renderObjects; } inline const RenderObjectList & getDirShadowObjects() const { return _dirShadowObjects; } inline void setRenderObjects(RenderObjectList &&ro) { _renderObjects = std::forward(ro); } inline void setDirShadowObjects(RenderObjectList &&ro) { _dirShadowObjects = std::forward(ro); } - inline const RenderObjectList & getCastShadowObjects() const { return _castShadowObjects; } + inline const RenderObjectList & isCastShadowObjects() const { return _castShadowObjects; } inline void setCastShadowObjects(RenderObjectList &&ro) { _castShadowObjects = std::forward(ro); } - inline const vector & getValidPunctualLights() const { return _validPunctualLights; } - inline void setValidPunctualLights(vector &&validPunctualLights) { _validPunctualLights = std::forward>(validPunctualLights); } + inline const vector & getValidPunctualLights() const { return _validPunctualLights; } + inline void setValidPunctualLights(vector &&validPunctualLights) { _validPunctualLights = std::forward>(validPunctualLights); } inline float getShadowCameraFar() const { return _shadowCameraFar; } inline void setShadowCameraFar(float shadowDistance) { _shadowCameraFar = shadowDistance; } inline Mat4 getMatShadowView() const { return _matShadowView; } @@ -67,20 +75,62 @@ public: inline void setMatShadowProj(const Mat4 &matShadowProj) { _matShadowProj = matShadowProj; } inline Mat4 getMatShadowViewProj() const { return _matShadowViewProj; } inline void setMatShadowViewProj(const Mat4 &matShadowViewProj) { _matShadowViewProj = matShadowViewProj; } + inline bool isHDR() const { return _isHDR; } + inline void setHDR(bool val) { _isHDR = val; } + inline scene::Shadows * getShadows() const { return _shadow; } + inline scene::Ambient * getAmbient() const { return _ambient; } + inline scene::Skybox * getSkybox() const { return _skybox; } + inline scene::Fog * getFog() const { return _fog; } + inline scene::Octree * getOctree() const { return _octree; } + inline gfx::InputAssembler * getOcclusionQueryInputAssembler() const { return _occlusionQueryInputAssembler; } + inline scene::Pass * getOcclusionQueryPass() const { return _occlusionQueryPass; } + inline gfx::Shader * getOcclusionQueryShader() const { return _occlusionQueryShader; } + inline const std::vector> & getGeometryRendererMaterials() const { return _geometryRendererMaterials; } + inline const std::vector & getGeometryRendererPasses() const { return _geometryRendererPasses; } + inline const std::vector & getGeometryRendererShaders() const { return _geometryRendererShaders; } -private: - RenderObjectList _renderObjects; - RenderObjectList _dirShadowObjects; - RenderObjectList _castShadowObjects; - vector _validPunctualLights; + inline float getShadingScale() const { return _shadingScale; } + inline void setShadingScale(float val) { _shadingScale = val; } - scene::PipelineSharedSceneData *_sharedSceneData = nullptr; - RenderPipeline * _pipeline = nullptr; - gfx::Device * _device = nullptr; - float _shadowCameraFar = 0.0F; - Mat4 _matShadowView; - Mat4 _matShadowProj; - Mat4 _matShadowViewProj; + scene::Pass *getOcclusionQueryPass(); + +protected: + void initOcclusionQuery(); + void initGeometryRendererMaterials(); + gfx::InputAssembler *createOcclusionQueryIA(); + + static constexpr uint32_t GEOMETRY_RENDERER_TECHNIQUE_COUNT{6}; + + RenderObjectList _renderObjects; + RenderObjectList _dirShadowObjects; + RenderObjectList _castShadowObjects; + vector _validPunctualLights; + gfx::Buffer * _occlusionQueryVertexBuffer{nullptr}; + gfx::Buffer * _occlusionQueryIndicesBuffer{nullptr}; + gfx::InputAssembler * _occlusionQueryInputAssembler{nullptr}; + + IntrusivePtr _occlusionQueryMaterial{nullptr}; + gfx::Shader * _occlusionQueryShader{nullptr}; + scene::Pass * _occlusionQueryPass{nullptr}; + + std::vector> _geometryRendererMaterials; + std::vector _geometryRendererPasses; // weak reference + std::vector _geometryRendererShaders; // weak reference + + RenderPipeline *_pipeline{nullptr}; + gfx::Device * _device{nullptr}; + float _shadowCameraFar{0.0F}; + Mat4 _matShadowView; + Mat4 _matShadowProj; + Mat4 _matShadowViewProj; + + scene::Fog * _fog{nullptr}; + scene::Ambient *_ambient{nullptr}; + scene::Skybox * _skybox{nullptr}; + scene::Shadows *_shadow{nullptr}; + scene::Octree * _octree{nullptr}; + bool _isHDR{true}; + float _shadingScale{1.0F}; std::unordered_map _shadowFrameBufferMap; }; diff --git a/native/cocos/renderer/pipeline/PipelineStateManager.cpp b/native/cocos/renderer/pipeline/PipelineStateManager.cpp index ab23e17100..ead5c3f5b0 100644 --- a/native/cocos/renderer/pipeline/PipelineStateManager.cpp +++ b/native/cocos/renderer/pipeline/PipelineStateManager.cpp @@ -30,7 +30,7 @@ namespace cc { namespace pipeline { -unordered_map PipelineStateManager::psoHashMap; +unordered_map> PipelineStateManager::psoHashMap; gfx::PipelineState *PipelineStateManager::getOrCreatePipelineState(const scene::Pass * pass, gfx::Shader * shader, @@ -46,7 +46,7 @@ gfx::PipelineState *PipelineStateManager::getOrCreatePipelineState(const scene:: hash = hash << subpass; } - auto *pso = psoHashMap[hash]; + auto *pso = psoHashMap[static_cast(hash)].get(); if (!pso) { auto *pipelineLayout = pass->getPipelineLayout(); @@ -58,11 +58,11 @@ gfx::PipelineState *PipelineStateManager::getOrCreatePipelineState(const scene:: *(pass->getDepthStencilState()), *(pass->getBlendState()), pass->getPrimitive(), - pass->getDynamicState(), + pass->getDynamicStates(), gfx::PipelineBindPoint::GRAPHICS, subpass}); - psoHashMap[hash] = pso; + psoHashMap[static_cast(hash)] = pso; } return pso; @@ -70,7 +70,7 @@ gfx::PipelineState *PipelineStateManager::getOrCreatePipelineState(const scene:: void PipelineStateManager::destroyAll() { for (auto &pair : psoHashMap) { - CC_SAFE_DESTROY(pair.second); + CC_SAFE_DESTROY_NULL(pair.second); } psoHashMap.clear(); } diff --git a/native/cocos/renderer/pipeline/PipelineStateManager.h b/native/cocos/renderer/pipeline/PipelineStateManager.h index 26339d417d..581c398dde 100644 --- a/native/cocos/renderer/pipeline/PipelineStateManager.h +++ b/native/cocos/renderer/pipeline/PipelineStateManager.h @@ -41,7 +41,7 @@ public: static void destroyAll(); private: - static unordered_map psoHashMap; + static unordered_map> psoHashMap; }; } // namespace pipeline diff --git a/native/cocos/renderer/pipeline/PipelineUBO.cpp b/native/cocos/renderer/pipeline/PipelineUBO.cpp index c0d7d38d2d..d9ebe25dc9 100644 --- a/native/cocos/renderer/pipeline/PipelineUBO.cpp +++ b/native/cocos/renderer/pipeline/PipelineUBO.cpp @@ -26,10 +26,14 @@ #include "PipelineUBO.h" #include "RenderPipeline.h" #include "SceneCulling.h" -#include "gfx-base/GFXDevice.h" -#include "scene/RenderScene.h" -#include "forward/ForwardPipeline.h" #include "application/ApplicationManager.h" +#include "core/Root.h" +#include "forward/ForwardPipeline.h" +#include "gfx-base/GFXDevice.h" +#include "scene/DirectionalLight.h" +#include "scene/Fog.h" +#include "scene/RenderScene.h" +#include "scene/SpotLight.h" namespace cc { @@ -48,16 +52,16 @@ namespace pipeline { Mat4 matShadowViewProj; void PipelineUBO::updateGlobalUBOView(const scene::Camera *camera, std::array *bufferView) { - const scene::Root * root = scene::Root::instance; + auto *const root = Root::getInstance(); const gfx::Device * device = gfx::Device::getInstance(); std::array &uboGlobalView = *bufferView; - const auto shadingWidth = std::floor(camera->window->getWidth()); - const auto shadingHeight = std::floor(camera->window->getHeight()); + const auto shadingWidth = std::floor(camera->getWindow()->getWidth()); + const auto shadingHeight = std::floor(camera->getWindow()->getHeight()); // update UBOGlobal - uboGlobalView[UBOGlobal::TIME_OFFSET + 0] = root->cumulativeTime; - uboGlobalView[UBOGlobal::TIME_OFFSET + 1] = root->frameTime; + uboGlobalView[UBOGlobal::TIME_OFFSET + 0] = root->getCumulativeTime(); + uboGlobalView[UBOGlobal::TIME_OFFSET + 1] = root->getFrameTime(); uboGlobalView[UBOGlobal::TIME_OFFSET + 2] = static_cast(CC_CURRENT_ENGINE()->getTotalFrames()); uboGlobalView[UBOGlobal::SCREEN_SIZE_OFFSET + 0] = static_cast(shadingWidth); @@ -72,35 +76,34 @@ void PipelineUBO::updateGlobalUBOView(const scene::Camera *camera, std::arrayscene; - const scene::DirectionalLight *mainLight = scene->getMainLight(); - auto * sceneData = pipeline->getPipelineSceneData(); - auto *const sharedData = sceneData->getSharedData(); - auto *const descriptorSet = pipeline->getDescriptorSet(); - auto * ambient = sharedData->ambient; - auto * fog = sharedData->fog; - const auto isHDR = sharedData->isHDR; + const auto *const scene = camera->getScene(); + const scene::DirectionalLight *mainLight = scene->getMainLight(); + const auto * sceneData = pipeline->getPipelineSceneData(); + auto *const descriptorSet = pipeline->getDescriptorSet(); + const auto * ambient = sceneData->getAmbient(); + auto * fog = sceneData->getFog(); + const auto isHDR = sceneData->isHDR(); auto *device = gfx::Device::getInstance(); - const auto shadingWidth = static_cast(std::floor(camera->window->getWidth())); - const auto shadingHeight = static_cast(std::floor(camera->window->getHeight())); + const auto shadingWidth = static_cast(std::floor(camera->getWindow()->getWidth())); + const auto shadingHeight = static_cast(std::floor(camera->getWindow()->getHeight())); - output[UBOCamera::SCREEN_SCALE_OFFSET + 0] = sharedData->shadingScale; - output[UBOCamera::SCREEN_SCALE_OFFSET + 1] = sharedData->shadingScale; + output[UBOCamera::SCREEN_SCALE_OFFSET + 0] = sceneData->getShadingScale(); + output[UBOCamera::SCREEN_SCALE_OFFSET + 1] = sceneData->getShadingScale(); output[UBOCamera::SCREEN_SCALE_OFFSET + 2] = 1.0F / output[UBOCamera::SCREEN_SCALE_OFFSET]; output[UBOCamera::SCREEN_SCALE_OFFSET + 3] = 1.0F / output[UBOCamera::SCREEN_SCALE_OFFSET + 1]; - const auto exposure = camera->exposure; + const auto exposure = camera->getExposure(); output[UBOCamera::EXPOSURE_OFFSET + 0] = exposure; output[UBOCamera::EXPOSURE_OFFSET + 1] = 1.0F / exposure; output[UBOCamera::EXPOSURE_OFFSET + 2] = isHDR ? 1.0F : 0.0F; output[UBOCamera::EXPOSURE_OFFSET + 3] = 0.0F; - if (mainLight) { + if (mainLight != nullptr) { TO_VEC3(output, mainLight->getDirection(), UBOCamera::MAIN_LIT_DIR_OFFSET) TO_VEC3(output, mainLight->getColor(), UBOCamera::MAIN_LIT_COLOR_OFFSET) - if (mainLight->getUseColorTemperature()) { + if (mainLight->isUseColorTemperature()) { const auto &colorTempRGB = mainLight->getColorTemperatureRGB(); output[UBOCamera::MAIN_LIT_COLOR_OFFSET + 0] *= colorTempRGB.x; output[UBOCamera::MAIN_LIT_COLOR_OFFSET + 1] *= colorTempRGB.y; @@ -109,8 +112,7 @@ void PipelineUBO::updateCameraUBOView(const RenderPipeline *pipeline, float *out if (isHDR) { output[UBOCamera::MAIN_LIT_COLOR_OFFSET + 3] = mainLight->getIlluminanceHDR() * exposure; - } - else { + } else { output[UBOCamera::MAIN_LIT_COLOR_OFFSET + 3] = mainLight->getIlluminanceLDR(); } } else { @@ -118,71 +120,85 @@ void PipelineUBO::updateCameraUBOView(const RenderPipeline *pipeline, float *out TO_VEC4(output, Vec4::ZERO, UBOCamera::MAIN_LIT_COLOR_OFFSET); } - Vec4 skyColor = ambient->skyColor; - if (isHDR) { - skyColor.w = ambient->skyIllum * exposure; - } - else { - skyColor.w = ambient->skyIllum; - } - TO_VEC4(output, skyColor, UBOCamera::AMBIENT_SKY_OFFSET) + if (ambient != nullptr) { + auto &skyColor = const_cast(ambient)->getSkyColor(); + if (isHDR) { + skyColor.w = ambient->getSkyIllum() * exposure; + } else { + skyColor.w = ambient->getSkyIllum(); + } - output[UBOCamera::AMBIENT_GROUND_OFFSET + 0] = ambient->groundAlbedo.x; - output[UBOCamera::AMBIENT_GROUND_OFFSET + 1] = ambient->groundAlbedo.y; - output[UBOCamera::AMBIENT_GROUND_OFFSET + 2] = ambient->groundAlbedo.z; - auto *const envmap = descriptorSet->getTexture(static_cast(PipelineGlobalBindings::SAMPLER_ENVIRONMENT)); - if (envmap) { - output[UBOCamera::AMBIENT_GROUND_OFFSET + 3] = static_cast(envmap->getViewInfo().levelCount); + output[UBOCamera::AMBIENT_SKY_OFFSET + 0] = skyColor.x; + output[UBOCamera::AMBIENT_SKY_OFFSET + 1] = skyColor.y; + output[UBOCamera::AMBIENT_SKY_OFFSET + 2] = skyColor.z; + output[UBOCamera::AMBIENT_SKY_OFFSET + 3] = skyColor.w; + + auto &groundAlbedo = const_cast(ambient)->getGroundAlbedo(); + output[UBOCamera::AMBIENT_GROUND_OFFSET + 0] = groundAlbedo.x; + output[UBOCamera::AMBIENT_GROUND_OFFSET + 1] = groundAlbedo.y; + output[UBOCamera::AMBIENT_GROUND_OFFSET + 2] = groundAlbedo.z; + output[UBOCamera::AMBIENT_GROUND_OFFSET + 3] = groundAlbedo.w; + // } - memcpy(output + UBOCamera::MAT_VIEW_OFFSET, camera->matView.m, sizeof(cc::Mat4)); - memcpy(output + UBOCamera::MAT_VIEW_INV_OFFSET, camera->node->getWorldMatrix().m, sizeof(cc::Mat4)); - TO_VEC3(output, camera->position, UBOCamera::CAMERA_POS_OFFSET) + // cjh TS doesn't have this logic ? auto *const envmap = descriptorSet->getTexture(static_cast(PipelineGlobalBindings::SAMPLER_ENVIRONMENT)); + // if (envmap != nullptr) { + // output[UBOCamera::AMBIENT_GROUND_OFFSET + 3] = static_cast(envmap->getLevelCount()); + // } - memcpy(output + UBOCamera::MAT_PROJ_OFFSET, camera->matProj.m, sizeof(cc::Mat4)); - memcpy(output + UBOCamera::MAT_PROJ_INV_OFFSET, camera->matProjInv.m, sizeof(cc::Mat4)); - memcpy(output + UBOCamera::MAT_VIEW_PROJ_OFFSET, camera->matViewProj.m, sizeof(cc::Mat4)); - memcpy(output + UBOCamera::MAT_VIEW_PROJ_INV_OFFSET, camera->matViewProjInv.m, sizeof(cc::Mat4)); + memcpy(output + UBOCamera::MAT_VIEW_OFFSET, camera->getMatView().m, sizeof(cc::Mat4)); + memcpy(output + UBOCamera::MAT_VIEW_INV_OFFSET, camera->getNode()->getWorldMatrix().m, sizeof(cc::Mat4)); + TO_VEC3(output, camera->getPosition(), UBOCamera::CAMERA_POS_OFFSET); + + memcpy(output + UBOCamera::MAT_PROJ_OFFSET, camera->getMatProj().m, sizeof(cc::Mat4)); + memcpy(output + UBOCamera::MAT_PROJ_INV_OFFSET, camera->getMatProjInv().m, sizeof(cc::Mat4)); + memcpy(output + UBOCamera::MAT_VIEW_PROJ_OFFSET, camera->getMatViewProj().m, sizeof(cc::Mat4)); + memcpy(output + UBOCamera::MAT_VIEW_PROJ_INV_OFFSET, camera->getMatViewProjInv().m, sizeof(cc::Mat4)); output[UBOCamera::CAMERA_POS_OFFSET + 3] = getCombineSignY(); - if (fog->enabled) { - TO_VEC4(output, fog->color, UBOCamera::GLOBAL_FOG_COLOR_OFFSET) + if (fog != nullptr) { + const auto &colorTempRGB = fog->getColorArray(); + output[UBOCamera::GLOBAL_FOG_COLOR_OFFSET] = colorTempRGB.x; + output[UBOCamera::GLOBAL_FOG_COLOR_OFFSET + 1] = colorTempRGB.y; + output[UBOCamera::GLOBAL_FOG_COLOR_OFFSET + 2] = colorTempRGB.z; + output[UBOCamera::GLOBAL_FOG_COLOR_OFFSET + 3] = colorTempRGB.z; - output[UBOCamera::GLOBAL_FOG_BASE_OFFSET + 0] = fog->start; - output[UBOCamera::GLOBAL_FOG_BASE_OFFSET + 1] = fog->end; - output[UBOCamera::GLOBAL_FOG_BASE_OFFSET + 2] = fog->density; + output[UBOCamera::GLOBAL_FOG_BASE_OFFSET + 0] = fog->getFogStart(); + output[UBOCamera::GLOBAL_FOG_BASE_OFFSET + 1] = fog->getFogEnd(); + output[UBOCamera::GLOBAL_FOG_BASE_OFFSET + 2] = fog->getFogDensity(); - output[UBOCamera::GLOBAL_FOG_ADD_OFFSET + 0] = fog->top; - output[UBOCamera::GLOBAL_FOG_ADD_OFFSET + 1] = fog->range; - output[UBOCamera::GLOBAL_FOG_ADD_OFFSET + 2] = fog->atten; + output[UBOCamera::GLOBAL_FOG_ADD_OFFSET + 0] = fog->getFogTop(); + output[UBOCamera::GLOBAL_FOG_ADD_OFFSET + 1] = fog->getFogRange(); + output[UBOCamera::GLOBAL_FOG_ADD_OFFSET + 2] = fog->getFogAtten(); } - output[UBOCamera::GLOBAL_NEAR_FAR_OFFSET + 0] = static_cast(camera->nearClip); - output[UBOCamera::GLOBAL_NEAR_FAR_OFFSET + 1] = static_cast(camera->farClip); + output[UBOCamera::GLOBAL_NEAR_FAR_OFFSET + 0] = static_cast(camera->getNearClip()); + output[UBOCamera::GLOBAL_NEAR_FAR_OFFSET + 1] = static_cast(camera->getFarClip()); - output[UBOCamera::GLOBAL_VIEW_PORT_OFFSET + 0] = camera->viewPort.x; - output[UBOCamera::GLOBAL_VIEW_PORT_OFFSET + 1] = camera->viewPort.y; - output[UBOCamera::GLOBAL_VIEW_PORT_OFFSET + 2] = camera->viewPort.z; - output[UBOCamera::GLOBAL_VIEW_PORT_OFFSET + 3] = camera->viewPort.w; + const auto &vp = camera->getViewport(); + output[UBOCamera::GLOBAL_VIEW_PORT_OFFSET + 0] = vp.x; + output[UBOCamera::GLOBAL_VIEW_PORT_OFFSET + 1] = vp.y; + output[UBOCamera::GLOBAL_VIEW_PORT_OFFSET + 2] = vp.z; + output[UBOCamera::GLOBAL_VIEW_PORT_OFFSET + 3] = vp.w; } void PipelineUBO::updateShadowUBOView(const RenderPipeline *pipeline, std::array *bufferView, const scene::Camera *camera) { - const scene::RenderScene *const scene = camera->scene; - const scene::DirectionalLight * mainLight = scene->getMainLight(); - gfx::Device * device = gfx::Device::getInstance(); - const PipelineSceneData * sceneData = pipeline->getPipelineSceneData(); - scene::Shadow *const shadowInfo = sceneData->getSharedData()->shadow; - std::array &shadowUBO = *bufferView; - const bool hFTexture = supportsFloatTexture(device); + const auto *const scene = camera->getScene(); + const scene::DirectionalLight * mainLight = scene->getMainLight(); + gfx::Device * device = gfx::Device::getInstance(); + const PipelineSceneData * sceneData = pipeline->getPipelineSceneData(); + auto * shadows = sceneData->getShadows(); + std::array &shadowUBO = *bufferView; + const bool hFTexture = supportsFloatTexture(device); - if (shadowInfo->enabled) { - if (mainLight && shadowInfo->shadowType == scene::ShadowType::SHADOWMAP) { + if (shadows->isEnabled()) { + if (mainLight && shadows->getType() == scene::ShadowType::SHADOW_MAP) { float nearClamp; float farClamp; - Mat4 matShadowView; - Mat4 matShadowProj; - Mat4 matShadowViewProj; - if (!shadowInfo->fixedArea) { - nearClamp = shadowInfo->nearValue; + Mat4 matShadowView; + Mat4 matShadowProj; + Mat4 matShadowViewProj; + if (!shadows->isFixedArea()) { + nearClamp = shadows->getNear(); farClamp = sceneData->getShadowCameraFar(); matShadowView = sceneData->getMatShadowView(); matShadowProj = sceneData->getMatShadowProj(); @@ -190,14 +206,14 @@ void PipelineUBO::updateShadowUBOView(const RenderPipeline *pipeline, std::array } else { const auto *node = mainLight->getNode(); matShadowView = node->getWorldMatrix().getInversed(); - const float x = shadowInfo->orthoSize; - const float y = shadowInfo->orthoSize; - nearClamp = shadowInfo->nearValue; - farClamp = shadowInfo->farValue; + const float x = shadows->getOrthoSize(); + const float y = shadows->getOrthoSize(); + nearClamp = shadows->getNear(); + farClamp = shadows->getFar(); const float projectionSinY = device->getCapabilities().clipSpaceSignY; const float clipSpaceMinZ = device->getCapabilities().clipSpaceMinZ; Mat4::createOrthographicOffCenter(-x, x, -y, y, -nearClamp, - farClamp, clipSpaceMinZ, projectionSinY, &matShadowProj); + farClamp, clipSpaceMinZ, projectionSinY, 0, &matShadowProj); matShadowViewProj = matShadowProj * matShadowView; } @@ -212,33 +228,33 @@ void PipelineUBO::updateShadowUBOView(const RenderPipeline *pipeline, std::array memcpy(shadowUBO.data() + UBOShadow::MAT_LIGHT_VIEW_PROJ_OFFSET, matShadowViewProj.m, sizeof(matShadowViewProj)); const float linear = 0.0F; - const float shadowNFLSInfos[4] = {nearClamp, farClamp, linear, 1.0F - shadowInfo->saturation}; + float shadowNFLSInfos[4] = {shadows->getNear(), farClamp, linear, 1.0F - shadows->getSaturation()}; memcpy(shadowUBO.data() + UBOShadow::SHADOW_NEAR_FAR_LINEAR_SATURATION_INFO_OFFSET, &shadowNFLSInfos, sizeof(shadowNFLSInfos)); - const float shadowWHPBInfos[4] = {shadowInfo->size.x, shadowInfo->size.y, static_cast(shadowInfo->pcfType), shadowInfo->bias}; + const auto &shadowSize = shadows->getSize(); + float shadowWHPBInfos[4] = {shadowSize.x, shadowSize.y, static_cast(shadows->getPcf()), shadows->getBias()}; memcpy(shadowUBO.data() + UBOShadow::SHADOW_WIDTH_HEIGHT_PCF_BIAS_INFO_OFFSET, &shadowWHPBInfos, sizeof(shadowWHPBInfos)); const float packing = hFTexture ? 0.0F : 1.0F; - const float shadowLPNNInfos[4] = {0.0F, packing, shadowInfo->normalBias, 0.0F}; + const float shadowLPNNInfos[4] = {0.0F, packing, shadows->getNormalBias(), 0.0F}; memcpy(shadowUBO.data() + UBOShadow::SHADOW_LIGHT_PACKING_NBIAS_NULL_INFO_OFFSET, &shadowLPNNInfos, sizeof(shadowLPNNInfos)); - } else if (mainLight && shadowInfo->shadowType == scene::ShadowType::PLANAR) { - updateDirLight(shadowInfo, mainLight, &shadowUBO); + } else if (mainLight && shadows->getType() == scene::ShadowType::PLANAR) { + updateDirLight(const_cast(shadows), mainLight, &shadowUBO); } - const float color[4] = {shadowInfo->color.x, shadowInfo->color.y, shadowInfo->color.z, shadowInfo->color.w}; - memcpy(shadowUBO.data() + UBOShadow::SHADOW_COLOR_OFFSET, &color, sizeof(float) * 4); + memcpy(shadowUBO.data() + UBOShadow::SHADOW_COLOR_OFFSET, shadows->getShadowColor4f().data(), sizeof(float) * 4); } } void PipelineUBO::updateShadowUBOLightView(const RenderPipeline *pipeline, std::array *bufferView, - const scene::Light *light) { - const auto *sceneData = pipeline->getPipelineSceneData(); - const auto *shadowInfo = sceneData->getSharedData()->shadow; - auto * device = gfx::Device::getInstance(); - auto & shadowUBO = *bufferView; - const bool hFTexture = supportsFloatTexture(device); - const float linear = 0.0F; - const float packing = hFTexture ? 0.0F : 1.0F; + const scene::Light *light) { + const auto *sceneData = pipeline->getPipelineSceneData(); + const auto *shadows = sceneData->getShadows(); + auto * device = gfx::Device::getInstance(); + auto & shadowUBO = *bufferView; + const bool hFTexture = supportsFloatTexture(device); + const float linear = 0.0F; + const float packing = hFTexture ? 0.0F : 1.0F; switch (light->getType()) { case scene::LightType::DIRECTIONAL: { float nearClamp; @@ -246,7 +262,7 @@ void PipelineUBO::updateShadowUBOLightView(const RenderPipeline *pipeline, std:: Mat4 matShadowView; Mat4 matShadowProj; Mat4 matShadowViewProj; - if (!shadowInfo->fixedArea) { + if (!shadows->isFixedArea()) { nearClamp = 0.1F; farClamp = sceneData->getShadowCameraFar(); matShadowView = sceneData->getMatShadowView(); @@ -255,14 +271,14 @@ void PipelineUBO::updateShadowUBOLightView(const RenderPipeline *pipeline, std:: } else { auto *const node = light->getNode(); matShadowView = node->getWorldMatrix().getInversed(); - const float x = shadowInfo->orthoSize; - const float y = shadowInfo->orthoSize; - nearClamp = shadowInfo->nearValue; - farClamp = shadowInfo->farValue; + const float x = shadows->getOrthoSize(); + const float y = shadows->getOrthoSize(); + nearClamp = shadows->getNear(); + farClamp = shadows->getFar(); const float projectionSinY = device->getCapabilities().clipSpaceSignY; const float clipSpaceMinZ = device->getCapabilities().clipSpaceMinZ; Mat4::createOrthographicOffCenter(-x, x, -y, y, -nearClamp, - farClamp, clipSpaceMinZ, projectionSinY, &matShadowProj); + farClamp, clipSpaceMinZ, projectionSinY, 0, &matShadowProj); matShadowViewProj = matShadowProj * matShadowView; } @@ -276,10 +292,10 @@ void PipelineUBO::updateShadowUBOLightView(const RenderPipeline *pipeline, std:: memcpy(shadowUBO.data() + UBOShadow::MAT_LIGHT_VIEW_PROJ_OFFSET, matShadowViewProj.m, sizeof(matShadowViewProj)); - float shadowNFLSInfos[4] = {nearClamp, farClamp, linear, 1.0F - shadowInfo->saturation}; + float shadowNFLSInfos[4] = {shadows->getNear(), farClamp, linear, 1.0F - shadows->getSaturation()}; memcpy(shadowUBO.data() + UBOShadow::SHADOW_NEAR_FAR_LINEAR_SATURATION_INFO_OFFSET, &shadowNFLSInfos, sizeof(shadowNFLSInfos)); - float shadowLPNNInfos[4] = {0.0F, packing, shadowInfo->normalBias, 0.0F}; + float shadowLPNNInfos[4] = {0.0F, packing, shadows->getNormalBias(), 0.0F}; memcpy(shadowUBO.data() + UBOShadow::SHADOW_LIGHT_PACKING_NBIAS_NULL_INFO_OFFSET, &shadowLPNNInfos, sizeof(shadowLPNNInfos)); } break; case scene::LightType::SPOT: { @@ -293,10 +309,10 @@ void PipelineUBO::updateShadowUBOLightView(const RenderPipeline *pipeline, std:: matShadowViewProj.multiply(matShadowView); memcpy(shadowUBO.data() + UBOShadow::MAT_LIGHT_VIEW_PROJ_OFFSET, matShadowViewProj.m, sizeof(matShadowViewProj)); - const float shadowNFLSInfos[4] = {0.01F, spotLight->getRange(), linear, 1.0F - shadowInfo->saturation}; + const float shadowNFLSInfos[4] = {0.01F, spotLight->getRange(), linear, 1.0F - shadows->getSaturation()}; memcpy(shadowUBO.data() + UBOShadow::SHADOW_NEAR_FAR_LINEAR_SATURATION_INFO_OFFSET, &shadowNFLSInfos, sizeof(shadowNFLSInfos)); - const float shadowLPNNInfos[4] = {1.0F, packing, shadowInfo->normalBias, 0.0F}; + const float shadowLPNNInfos[4] = {1.0F, packing, shadows->getNormalBias(), 0.0F}; memcpy(shadowUBO.data() + UBOShadow::SHADOW_LIGHT_PACKING_NBIAS_NULL_INFO_OFFSET, &shadowLPNNInfos, sizeof(shadowLPNNInfos)); } break; case scene::LightType::SPHERE: break; @@ -305,11 +321,11 @@ void PipelineUBO::updateShadowUBOLightView(const RenderPipeline *pipeline, std:: break; } - const float shadowWHPBInfos[4] = {shadowInfo->size.x, shadowInfo->size.y, static_cast(shadowInfo->pcfType), shadowInfo->bias}; + const auto &shadowSize = shadows->getSize(); + const float shadowWHPBInfos[4] = {shadowSize.x, shadowSize.y, static_cast(shadows->getPcf()), shadows->getBias()}; memcpy(shadowUBO.data() + UBOShadow::SHADOW_WIDTH_HEIGHT_PCF_BIAS_INFO_OFFSET, &shadowWHPBInfos, sizeof(shadowWHPBInfos)); - const float color[4] = {shadowInfo->color.x, shadowInfo->color.y, shadowInfo->color.z, shadowInfo->color.w}; - memcpy(shadowUBO.data() + UBOShadow::SHADOW_COLOR_OFFSET, &color, sizeof(color)); + memcpy(shadowUBO.data() + UBOShadow::SHADOW_COLOR_OFFSET, shadows->getShadowColor4f().data(), sizeof(float) * 4); } static uint8_t combineSignY = 0; @@ -371,7 +387,7 @@ void PipelineUBO::activate(gfx::Device *device, RenderPipeline *pipeline) { void PipelineUBO::destroy() { for (auto &ubo : _ubos) { - CC_SAFE_DESTROY(ubo) + CC_SAFE_DESTROY_AND_DELETE(ubo) } _ubos.clear(); } @@ -388,14 +404,14 @@ void PipelineUBO::updateGlobalUBO(const scene::Camera *camera) { } void PipelineUBO::updateCameraUBO(const scene::Camera *camera) { - auto *const cmdBuffer = _pipeline->getCommandBuffers()[0]; + auto *const cmdBuffer = _pipeline->getCommandBuffers()[0]; PipelineUBO::updateCameraUBOView(_pipeline, _cameraUBOs.data(), camera); cmdBuffer->updateBuffer(_cameraBuffer, _cameraUBOs.data()); } void PipelineUBO::updateMultiCameraUBO(const vector &cameras) { const auto cameraCount = cameras.size(); - const auto totalUboSize = static_cast(_alignedCameraUBOSize * cameraCount); + const auto totalUboSize = static_cast(_alignedCameraUBOSize * cameraCount); if (_cameraBuffer->getSize() < totalUboSize) { _cameraBuffer->resize(totalUboSize); @@ -413,16 +429,18 @@ void PipelineUBO::updateMultiCameraUBO(const vector &cameras) { } void PipelineUBO::updateShadowUBO(const scene::Camera *camera) { - auto *const ds = _pipeline->getDescriptorSet(); - auto *const cmdBuffer = _pipeline->getCommandBuffers()[0]; - const auto * sceneData = _pipeline->getPipelineSceneData(); - const auto * shadowInfo = sceneData->getSharedData()->shadow; - const auto *const scene = camera->scene; - if (!shadowInfo->enabled) return; + auto *const ds = _pipeline->getDescriptorSet(); + auto *const cmdBuffer = _pipeline->getCommandBuffers()[0]; + const auto * sceneData = _pipeline->getPipelineSceneData(); + const auto * shadows = sceneData->getShadows(); + const auto *const scene = camera->getScene(); + if (shadows == nullptr || !shadows->isEnabled()) { + return; + } const auto & shadowFrameBufferMap = sceneData->getShadowFramebufferMap(); const scene::DirectionalLight *mainLight = scene->getMainLight(); - if (mainLight && shadowInfo->shadowType == scene::ShadowType::SHADOWMAP) { + if (mainLight && shadows->getType() == scene::ShadowType::SHADOW_MAP) { if (shadowFrameBufferMap.count(mainLight) > 0) { auto *texture = shadowFrameBufferMap.at(mainLight)->getColorTextures()[0]; if (texture) { diff --git a/native/cocos/renderer/pipeline/PlanarShadowQueue.cpp b/native/cocos/renderer/pipeline/PlanarShadowQueue.cpp index 838d3b851c..e08e324e09 100644 --- a/native/cocos/renderer/pipeline/PlanarShadowQueue.cpp +++ b/native/cocos/renderer/pipeline/PlanarShadowQueue.cpp @@ -31,12 +31,13 @@ #include "PlanarShadowQueue.h" #include "RenderInstancedQueue.h" #include "RenderPipeline.h" +#include "core/geometry/AABB.h" #include "gfx-base/GFXCommandBuffer.h" #include "gfx-base/GFXDevice.h" #include "gfx-base/GFXShader.h" #include "scene/Model.h" #include "scene/RenderScene.h" -#include "scene/AABB.h" +#include "scene/Shadow.h" namespace cc { namespace pipeline { @@ -49,44 +50,43 @@ PlanarShadowQueue::PlanarShadowQueue(RenderPipeline *pipeline) void PlanarShadowQueue::gatherShadowPasses(scene::Camera *camera, gfx::CommandBuffer *cmdBuffer) { clear(); - const PipelineSceneData * sceneData = _pipeline->getPipelineSceneData(); - const scene::PipelineSharedSceneData *sharedData = sceneData->getSharedData(); - const scene::Shadow * shadowInfo = sharedData->shadow; - if (!shadowInfo->enabled || shadowInfo->shadowType != scene::ShadowType::PLANAR) { + const PipelineSceneData *sceneData = _pipeline->getPipelineSceneData(); + const scene::Shadows * shadows = sceneData->getShadows(); + if (shadows == nullptr || !shadows->isEnabled() || shadows->getType() != scene::ShadowType::PLANAR) { return; } - const auto *scene = camera->scene; - const bool shadowVisible = camera->visibility & static_cast(LayerList::DEFAULT); - + const auto *scene = camera->getScene(); + const bool shadowVisible = camera->getVisibility() & static_cast(LayerList::DEFAULT); if (!scene->getMainLight() || !shadowVisible) { return; } const auto &models = scene->getModels(); - for (const auto *model : models) { - if (!model->getEnabled() || !model->getCastShadow() || !model->getNode()) { + for (const auto &model : models) { + if (!model->isEnabled() || !model->isCastShadow() || !model->getNode()) { continue; } - if (model->getWorldBounds() && model->getCastShadow()) { + if (model->getWorldBounds() && model->isCastShadow()) { _castModels.emplace_back(model); } } - auto *instancedBuffer = InstancedBuffer::get(shadowInfo->instancePass); + auto & passes = *shadows->getInstancingMaterial()->getPasses(); + InstancedBuffer *instancedBuffer = passes[0]->getInstancedBuffer(); - scene::AABB ab; + geometry::AABB ab; for (const auto *model : _castModels) { // frustum culling - model->getWorldBounds()->transform(shadowInfo->matLight, &ab); - if (!ab.aabbFrustum(camera->frustum)) { + model->getWorldBounds()->transform(shadows->getMatLight(), &ab); + if (!ab.aabbFrustum(camera->getFrustum())) { continue; } if (!model->getInstanceAttributes().empty()) { int i = 0; - for (const auto *subModel : model->getSubModels()) { + for (const auto &subModel : model->getSubModels()) { instancedBuffer->merge(model, subModel, i, subModel->getPlanarInstanceShader()); _instancedQueue->add(instancedBuffer); ++i; @@ -106,10 +106,9 @@ void PlanarShadowQueue::clear() { } void PlanarShadowQueue::recordCommandBuffer(gfx::Device *device, gfx::RenderPass *renderPass, gfx::CommandBuffer *cmdBuffer) { - const PipelineSceneData * sceneData = _pipeline->getPipelineSceneData(); - const scene::PipelineSharedSceneData *sharedData = sceneData->getSharedData(); - const scene::Shadow * shadowInfo = sharedData->shadow; - if (!shadowInfo->enabled || shadowInfo->shadowType != scene::ShadowType::PLANAR) { + const PipelineSceneData *sceneData = _pipeline->getPipelineSceneData(); + const auto * shadows = sceneData->getShadows(); + if (shadows == nullptr || !shadows->isEnabled() || shadows->getType() != scene::ShadowType::PLANAR) { return; } @@ -119,11 +118,11 @@ void PlanarShadowQueue::recordCommandBuffer(gfx::Device *device, gfx::RenderPass return; } - const auto *pass = shadowInfo->planarPass; + const scene::Pass *pass = (*shadows->getMaterial()->getPasses())[0]; cmdBuffer->bindDescriptorSet(materialSet, pass->getDescriptorSet()); for (const auto *model : _pendingModels) { - for (const auto *subModel : model->getSubModels()) { + for (const auto &subModel : model->getSubModels()) { auto *const shader = subModel->getPlanarShader(); auto *const ia = subModel->getInputAssembler(); auto *const pso = PipelineStateManager::getOrCreatePipelineState(pass, shader, ia, renderPass); diff --git a/native/cocos/renderer/pipeline/RenderAdditiveLightQueue.cpp b/native/cocos/renderer/pipeline/RenderAdditiveLightQueue.cpp index 281319a671..8fb26b0d41 100644 --- a/native/cocos/renderer/pipeline/RenderAdditiveLightQueue.cpp +++ b/native/cocos/renderer/pipeline/RenderAdditiveLightQueue.cpp @@ -36,8 +36,10 @@ #include "RenderInstancedQueue.h" #include "SceneCulling.h" #include "base/Utils.h" +#include "core/geometry/Sphere.h" #include "forward/ForwardPipeline.h" #include "gfx-base/GFXDevice.h" +#include "scene/DirectionalLight.h" #include "scene/RenderScene.h" namespace cc { @@ -66,14 +68,14 @@ RenderAdditiveLightQueue::RenderAdditiveLightQueue(RenderPipeline *pipeline) : _ RenderAdditiveLightQueue ::~RenderAdditiveLightQueue() { CC_SAFE_DELETE(_instancedQueue); CC_SAFE_DELETE(_batchedQueue); - CC_SAFE_DESTROY(_firstLightBufferView); - CC_SAFE_DESTROY(_lightBuffer); + CC_SAFE_DESTROY_AND_DELETE(_firstLightBufferView); + CC_SAFE_DESTROY_AND_DELETE(_lightBuffer); } void RenderAdditiveLightQueue::recordCommandBuffer(gfx::Device *device, scene::Camera *camera, gfx::RenderPass *renderPass, gfx::CommandBuffer *cmdBuffer) { _instancedQueue->recordCommandBuffer(device, renderPass, cmdBuffer); _batchedQueue->recordCommandBuffer(device, renderPass, cmdBuffer); - const bool enableOcclusionQuery = _pipeline->getOcclusionQueryEnabled(); + const bool enableOcclusionQuery = _pipeline->isOcclusionQueryEnabled(); const auto offset = _pipeline->getPipelineUBO()->getCurrentCameraUBOOffset(); for (const auto &lightPass : _lightPasses) { @@ -127,7 +129,7 @@ void RenderAdditiveLightQueue::gatherLightPasses(const scene::Camera *camera, gf if (_lightIndices.empty()) continue; int i = 0; - for (const auto *subModel : model->getSubModels()) { + for (const auto &subModel : model->getSubModels()) { const auto lightPassIdx = lightPassIndices[i]; if (lightPassIdx == UINT_MAX) continue; const auto *pass = subModel->getPass(lightPassIdx); @@ -135,7 +137,7 @@ void RenderAdditiveLightQueue::gatherLightPasses(const scene::Camera *camera, gf if (isTransparent) { continue; } - auto * descriptorSet = subModel->getDescriptorSet(); + auto *descriptorSet = subModel->getDescriptorSet(); descriptorSet->bindBuffer(UBOForwardLight::BINDING, _firstLightBufferView); descriptorSet->update(); @@ -201,13 +203,12 @@ void RenderAdditiveLightQueue::addRenderQueue(const scene::Pass *pass, const sce } void RenderAdditiveLightQueue::updateUBOs(const scene::Camera *camera, gfx::CommandBuffer *cmdBuffer) { - const auto exposure = camera->exposure; + const auto exposure = camera->getExposure(); const auto validLightCount = _validPunctualLights.size(); const auto *sceneData = _pipeline->getPipelineSceneData(); - const auto *sharedData = sceneData->getSharedData(); - const auto *shadowInfo = sharedData->shadow; - size_t offset = 0; + const auto *shadows = sceneData->getShadows(); + size_t offset = 0; if (validLightCount > _lightBufferCount) { _firstLightBufferView->destroy(); @@ -235,7 +236,7 @@ void RenderAdditiveLightQueue::updateUBOs(const scene::Camera *camera, gfx::Comm index = offset + UBOForwardLight::LIGHT_COLOR_OFFSET; const auto &color = light->getColor(); - if (light->getUseColorTemperature()) { + if (light->isUseColorTemperature()) { const auto &tempRGB = light->getColorTemperatureRGB(); _lightBufferData[index++] = color.x * tempRGB.x; _lightBufferData[index++] = color.y * tempRGB.y; @@ -248,7 +249,7 @@ void RenderAdditiveLightQueue::updateUBOs(const scene::Camera *camera, gfx::Comm const float luminanceHDR = isSpotLight ? spotLight->getLuminanceHDR() : sphereLight->getLuminanceHDR(); const float luminanceLDR = isSpotLight ? spotLight->getLuminanceLDR() : sphereLight->getLuminanceLDR(); - if (sharedData->isHDR) { + if (sceneData->isHDR()) { _lightBufferData[index] = luminanceHDR * exposure * _lightMeterScale; } else { _lightBufferData[index] = luminanceLDR; @@ -258,12 +259,12 @@ void RenderAdditiveLightQueue::updateUBOs(const scene::Camera *camera, gfx::Comm case scene::LightType::SPHERE: _lightBufferData[offset + UBOForwardLight::LIGHT_POS_OFFSET + 3] = 0; _lightBufferData[offset + UBOForwardLight::LIGHT_SIZE_RANGE_ANGLE_OFFSET + 2] = 0; - _lightBufferData[offset + UBOForwardLight::LIGHT_SIZE_RANGE_ANGLE_OFFSET + 3] = (shadowInfo->enabled && shadowInfo->shadowType == scene::ShadowType::SHADOWMAP) ? 1.0F : 0.0F; + _lightBufferData[offset + UBOForwardLight::LIGHT_SIZE_RANGE_ANGLE_OFFSET + 3] = (shadows->isEnabled() && shadows->getType() == scene::ShadowType::SHADOW_MAP) ? 1.0F : 0.0F; break; case scene::LightType::SPOT: { _lightBufferData[offset + UBOForwardLight::LIGHT_POS_OFFSET + 3] = 1.0F; _lightBufferData[offset + UBOForwardLight::LIGHT_SIZE_RANGE_ANGLE_OFFSET + 2] = spotLight->getSpotAngle(); - _lightBufferData[offset + UBOForwardLight::LIGHT_SIZE_RANGE_ANGLE_OFFSET + 3] = (shadowInfo->enabled && shadowInfo->shadowType == scene::ShadowType::SHADOWMAP) ? 1.0F : 0.0F; + _lightBufferData[offset + UBOForwardLight::LIGHT_SIZE_RANGE_ANGLE_OFFSET + 3] = (shadows->isEnabled() && shadows->getType() == scene::ShadowType::SHADOW_MAP) ? 1.0F : 0.0F; index = offset + UBOForwardLight::LIGHT_DIR_OFFSET; const auto &direction = spotLight->getDirection(); @@ -280,14 +281,14 @@ void RenderAdditiveLightQueue::updateUBOs(const scene::Camera *camera, gfx::Comm } void RenderAdditiveLightQueue::updateLightDescriptorSet(const scene::Camera *camera, gfx::CommandBuffer *cmdBuffer) { - const auto * sceneData = _pipeline->getPipelineSceneData(); - auto * shadowInfo = sceneData->getSharedData()->shadow; - const auto *const scene = camera->scene; - auto * device = gfx::Device::getInstance(); - const bool hFTexture = supportsFloatTexture(device); - const float linear = 0.0F; - const float packing = hFTexture ? 0.0F : 1.0F; - const scene::Light *mainLight = scene->getMainLight(); + const auto * sceneData = _pipeline->getPipelineSceneData(); + auto * shadows = sceneData->getShadows(); + const auto *const scene = camera->getScene(); + auto * device = gfx::Device::getInstance(); + const bool hFTexture = supportsFloatTexture(device); + const float linear = 0.0F; + const float packing = hFTexture ? 0.0F : 1.0F; + const scene::Light *mainLight = scene->getMainLight(); for (uint i = 0; i < _validPunctualLights.size(); ++i) { const auto *light = _validPunctualLights[i]; @@ -302,21 +303,22 @@ void RenderAdditiveLightQueue::updateLightDescriptorSet(const scene::Camera *cam case scene::LightType::SPHERE: { // update planar PROJ if (mainLight) { - updateDirLight(shadowInfo, mainLight, &_shadowUBO); + updateDirLight(const_cast(shadows), mainLight, &_shadowUBO); } // Reserve sphere light shadow interface - float shadowWHPBInfos[4] = {shadowInfo->size.x, shadowInfo->size.y, static_cast(shadowInfo->pcfType), shadowInfo->bias}; + const auto &shadowSize = shadows->getSize(); + float shadowWHPBInfos[4] = {shadowSize.x, shadowSize.y, static_cast(shadows->getPcf()), shadows->getBias()}; memcpy(_shadowUBO.data() + UBOShadow::SHADOW_WIDTH_HEIGHT_PCF_BIAS_INFO_OFFSET, &shadowWHPBInfos, sizeof(float) * 4); - float shadowLPNNInfos[4] = {2.0F, packing, shadowInfo->normalBias, 0.0F}; + float shadowLPNNInfos[4] = {2.0F, packing, shadows->getNormalBias(), 0.0F}; memcpy(_shadowUBO.data() + UBOShadow::SHADOW_LIGHT_PACKING_NBIAS_NULL_INFO_OFFSET, &shadowLPNNInfos, sizeof(float) * 4); } break; case scene::LightType::SPOT: { const auto *spotLight = static_cast(light); // update planar PROJ if (mainLight) { - updateDirLight(shadowInfo, mainLight, &_shadowUBO); + updateDirLight(shadows, mainLight, &_shadowUBO); } const auto &matShadowCamera = light->getNode()->getWorldMatrix(); @@ -334,13 +336,14 @@ void RenderAdditiveLightQueue::updateLightDescriptorSet(const scene::Camera *cam memcpy(_shadowUBO.data() + UBOShadow::MAT_LIGHT_VIEW_PROJ_OFFSET, matShadowViewProj.m, sizeof(matShadowViewProj)); // shadow info - float shadowNFLSInfos[4] = {0.1F, spotLight->getRange(), linear, 1.0F - shadowInfo->saturation}; + float shadowNFLSInfos[4] = {0.1F, spotLight->getRange(), linear, 1.0F - shadows->getSaturation()}; memcpy(_shadowUBO.data() + UBOShadow::SHADOW_NEAR_FAR_LINEAR_SATURATION_INFO_OFFSET, &shadowNFLSInfos, sizeof(shadowNFLSInfos)); - float shadowWHPBInfos[4] = {shadowInfo->size.x, shadowInfo->size.y, static_cast(shadowInfo->pcfType), shadowInfo->bias}; + const auto &shadowSize = shadows->getSize(); + float shadowWHPBInfos[4] = {shadowSize.x, shadowSize.y, static_cast(shadows->getPcf()), shadows->getBias()}; memcpy(_shadowUBO.data() + UBOShadow::SHADOW_WIDTH_HEIGHT_PCF_BIAS_INFO_OFFSET, &shadowWHPBInfos, sizeof(shadowWHPBInfos)); - float shadowLPNNInfos[4] = {1.0F, packing, shadowInfo->normalBias, 0.0F}; + float shadowLPNNInfos[4] = {1.0F, packing, shadows->getNormalBias(), 0.0F}; memcpy(_shadowUBO.data() + UBOShadow::SHADOW_LIGHT_PACKING_NBIAS_NULL_INFO_OFFSET, &shadowLPNNInfos, sizeof(float) * 4); float shadowInvProjDepthInfos[4] = {matShadowInvProj.m[10], matShadowInvProj.m[14], matShadowInvProj.m[11], matShadowInvProj.m[15]}; @@ -365,8 +368,7 @@ void RenderAdditiveLightQueue::updateLightDescriptorSet(const scene::Camera *cam break; } - float color[4] = {shadowInfo->color.x, shadowInfo->color.y, shadowInfo->color.z, shadowInfo->color.w}; - memcpy(_shadowUBO.data() + UBOShadow::SHADOW_COLOR_OFFSET, &color, sizeof(float) * 4); + memcpy(_shadowUBO.data() + UBOShadow::SHADOW_COLOR_OFFSET, shadows->getShadowColor4f().data(), sizeof(float) * 4); descriptorSet->update(); @@ -378,9 +380,9 @@ bool RenderAdditiveLightQueue::getLightPassIndex(const scene::Model *model, vect lightPassIndices->clear(); bool hasValidLightPass = false; - for (const auto *subModel : model->getSubModels()) { + for (const auto &subModel : model->getSubModels()) { int lightPassIndex = 0; - for (const auto *pass : subModel->getPasses()) { + for (const auto &pass : subModel->getPasses()) { if (pass->getPhase() == _phaseID) { hasValidLightPass = true; break; diff --git a/native/cocos/renderer/pipeline/RenderAdditiveLightQueue.h b/native/cocos/renderer/pipeline/RenderAdditiveLightQueue.h index 283bf90e1e..aa89e8e5b5 100644 --- a/native/cocos/renderer/pipeline/RenderAdditiveLightQueue.h +++ b/native/cocos/renderer/pipeline/RenderAdditiveLightQueue.h @@ -35,22 +35,21 @@ namespace cc { namespace scene { -struct Camera; +class Camera; } namespace pipeline { struct RenderObject; class RenderPipeline; -class DefineMap; class RenderInstancedQueue; class RenderBatchedQueue; class ForwardPipeline; struct AdditiveLightPass { - const scene::SubModel * subModel = nullptr; - const scene::Pass * pass = nullptr; - gfx::Shader * shader = nullptr; - vector dynamicOffsets; - vector lights; + const scene::SubModel *subModel = nullptr; + const scene::Pass * pass = nullptr; + gfx::Shader * shader = nullptr; + vector dynamicOffsets; + vector lights; }; class RenderAdditiveLightQueue : public Object { @@ -65,12 +64,12 @@ private: static bool cullSphereLight(const scene::SphereLight *light, const scene::Model *model); static bool cullSpotLight(const scene::SpotLight *light, const scene::Model *model); - void clear(); - void addRenderQueue(const scene::Pass *pass, const scene::SubModel *subModel, const scene::Model *model, uint lightPassIdx); - void updateUBOs(const scene::Camera *camera, gfx::CommandBuffer *cmdBuffer); - void updateLightDescriptorSet(const scene::Camera *camera, gfx::CommandBuffer *cmdBuffer); - bool getLightPassIndex(const scene::Model *model, vector *lightPassIndices) const; - void lightCulling(const scene::Model *model); + void clear(); + void addRenderQueue(const scene::Pass *pass, const scene::SubModel *subModel, const scene::Model *model, uint lightPassIdx); + void updateUBOs(const scene::Camera *camera, gfx::CommandBuffer *cmdBuffer); + void updateLightDescriptorSet(const scene::Camera *camera, gfx::CommandBuffer *cmdBuffer); + bool getLightPassIndex(const scene::Model *model, vector *lightPassIndices) const; + void lightCulling(const scene::Model *model); RenderPipeline * _pipeline = nullptr; vector> _sortedSubModelsArray; @@ -85,7 +84,7 @@ private: gfx::Buffer * _lightBuffer = nullptr; gfx::Buffer * _firstLightBufferView = nullptr; - std::array _shadowUBO{}; + std::array _shadowUBO{}; uint _lightBufferStride = 0; uint _lightBufferElementCount = 0; diff --git a/native/cocos/renderer/pipeline/RenderPipeline.cpp b/native/cocos/renderer/pipeline/RenderPipeline.cpp index d20ee3dc2d..f36450c55f 100644 --- a/native/cocos/renderer/pipeline/RenderPipeline.cpp +++ b/native/cocos/renderer/pipeline/RenderPipeline.cpp @@ -38,6 +38,7 @@ #include "gfx-base/GFXDevice.h" #include "gfx-base/GFXTexture.h" #include "helper/Utils.h" +#include "scene/Skybox.h" namespace cc { namespace pipeline { @@ -57,9 +58,8 @@ RenderPipeline::RenderPipeline() : _device(gfx::Device::getInstance()) { RenderPipeline::instance = this; - _globalDSManager = new GlobalDSManager(); - _pipelineUBO = new PipelineUBO(); - _pipelineSceneData = new PipelineSceneData(); + _globalDSManager = new GlobalDSManager(); + _pipelineUBO = new PipelineUBO(); } RenderPipeline::~RenderPipeline() { @@ -73,7 +73,7 @@ bool RenderPipeline::initialize(const RenderPipelineInfo &info) { } bool RenderPipeline::isEnvmapEnabled() const { - return _pipelineSceneData->getSharedData()->skybox->useIBL; + return _pipelineSceneData->getSkybox()->isUseIBL(); } bool RenderPipeline::activate(gfx::Swapchain * /*swapchain*/) { @@ -81,6 +81,8 @@ bool RenderPipeline::activate(gfx::Swapchain * /*swapchain*/) { _descriptorSet = _globalDSManager->getGlobalDescriptorSet(); _pipelineUBO->activate(_device, this); _pipelineSceneData->activate(_device, this); + + CC_ASSERT(_geometryRenderer != nullptr); _geometryRenderer->activate(_device, this); // generate macros here rather than construct func because _clusterEnabled @@ -106,30 +108,30 @@ void RenderPipeline::render(const vector &cameras) { } void RenderPipeline::destroyQuadInputAssembler() { - CC_SAFE_DESTROY(_quadIB); + CC_SAFE_DESTROY_AND_DELETE(_quadIB); for (auto *node : _quadVB) { - CC_SAFE_DESTROY(node); + CC_SAFE_DESTROY_AND_DELETE(node); } for (auto node : _quadIA) { - CC_SAFE_DESTROY(node.second); + CC_SAFE_DESTROY_AND_DELETE(node.second); } _quadVB.clear(); _quadIA.clear(); } -void RenderPipeline::destroy() { +bool RenderPipeline::destroy() { for (auto *flow : _flows) { flow->destroy(); } _flows.clear(); _descriptorSet = nullptr; - CC_SAFE_DESTROY(_globalDSManager); - CC_SAFE_DESTROY(_pipelineUBO); - CC_SAFE_DESTROY(_pipelineSceneData); - _geometryRenderer->destroy(); + CC_SAFE_DESTROY_AND_DELETE(_globalDSManager); + CC_SAFE_DESTROY_AND_DELETE(_pipelineUBO); + CC_SAFE_DESTROY_NULL(_pipelineSceneData); + CC_SAFE_DESTROY_AND_DELETE(_geometryRenderer); for (auto *const queryPool : _queryPools) { queryPool->destroy(); @@ -145,22 +147,23 @@ void RenderPipeline::destroy() { BatchedBuffer::destroyBatchedBuffer(); InstancedBuffer::destroyInstancedBuffer(); framegraph::FrameGraph::gc(0); + + return Super::destroy(); } gfx::Color RenderPipeline::getClearcolor(scene::Camera *camera) const { - auto *const sceneData = getPipelineSceneData(); - auto *const sharedData = sceneData->getSharedData(); - gfx::Color clearColor{0.0, 0.0, 0.0, 1.0F}; - if (camera->clearFlag & static_cast(gfx::ClearFlagBit::COLOR)) { - clearColor = camera->clearColor; + auto *const sceneData = getPipelineSceneData(); + gfx::Color clearColor{0.0F, 0.0F, 0.0F, 1.0F}; + if (static_cast(camera->getClearFlag()) & static_cast(gfx::ClearFlagBit::COLOR)) { + clearColor = camera->getClearColor(); } - clearColor.w = 0; + clearColor.w = 0.F; return clearColor; } void RenderPipeline::updateQuadVertexData(const Vec4 &viewport, gfx::Buffer *buffer) { - float vbData[16] = {0}; + float vbData[16] = {0.F}; genQuadVertexData(viewport, vbData); buffer->update(vbData, sizeof(vbData)); } @@ -213,40 +216,41 @@ bool RenderPipeline::createQuadInputAssembler(gfx::Buffer *quadIB, gfx::Buffer * void RenderPipeline::ensureEnoughSize(const vector &cameras) { for (auto *camera : cameras) { - _width = std::max(camera->window->getWidth(), _width); - _height = std::max(camera->window->getHeight(), _height); + _width = std::max(camera->getWindow()->getWidth(), _width); + _height = std::max(camera->getWindow()->getHeight(), _height); } } gfx::Viewport RenderPipeline::getViewport(scene::Camera *camera) { - auto scale{_pipelineSceneData->getSharedData()->shadingScale}; + auto scale{_pipelineSceneData->getShadingScale()}; const gfx::Rect &rect = getRenderArea(camera); return { - static_cast(rect.x * scale), - static_cast(rect.y * scale), - static_cast(rect.width * scale), - static_cast(rect.height * scale)}; + static_cast(static_cast(rect.x) * scale), + static_cast(static_cast(rect.y) * scale), + static_cast(static_cast(rect.width) * scale), + static_cast(static_cast(rect.height) * scale)}; } gfx::Rect RenderPipeline::getScissor(scene::Camera *camera) { - auto scale{_pipelineSceneData->getSharedData()->shadingScale}; + auto scale{_pipelineSceneData->getShadingScale()}; const gfx::Rect &rect = getRenderArea(camera); return { - static_cast(rect.x * scale), - static_cast(rect.y * scale), - static_cast(rect.width * scale), - static_cast(rect.height * scale)}; + static_cast(static_cast(rect.x) * scale), + static_cast(static_cast(rect.y) * scale), + static_cast(static_cast(rect.width) * scale), + static_cast(static_cast(rect.height) * scale)}; } gfx::Rect RenderPipeline::getRenderArea(scene::Camera *camera) { - float w{static_cast(camera->window->getWidth())}; - float h{static_cast(camera->window->getHeight())}; + float w{static_cast(camera->getWindow()->getWidth())}; + float h{static_cast(camera->getWindow()->getHeight())}; + const auto &vp = camera->getViewport(); return { - static_cast(camera->viewPort.x * w), - static_cast(camera->viewPort.y * h), - static_cast(camera->viewPort.z * w), - static_cast(camera->viewPort.w * h), + static_cast(vp.x * w), + static_cast(vp.y * h), + static_cast(vp.z * w), + static_cast(vp.w * h), }; } @@ -259,28 +263,24 @@ void RenderPipeline::genQuadVertexData(const Vec4 &viewport, float *vbData) { std::swap(minY, maxY); } int n = 0; - vbData[n++] = -1.0; - vbData[n++] = -1.0; + vbData[n++] = -1.0F; + vbData[n++] = -1.0F; vbData[n++] = minX; // uv vbData[n++] = maxY; - vbData[n++] = 1.0; - vbData[n++] = -1.0; + vbData[n++] = 1.0F; + vbData[n++] = -1.0F; vbData[n++] = maxX; vbData[n++] = maxY; - vbData[n++] = -1.0; - vbData[n++] = 1.0; + vbData[n++] = -1.0F; + vbData[n++] = 1.0F; vbData[n++] = minX; vbData[n++] = minY; - vbData[n++] = 1.0; - vbData[n++] = 1.0; + vbData[n++] = 1.0F; + vbData[n++] = 1.0F; vbData[n++] = maxX; vbData[n++] = minY; } -void RenderPipeline::setPipelineSharedSceneData(scene::PipelineSharedSceneData *data) { - _pipelineSceneData->setPipelineSharedSceneData(data); -} - void RenderPipeline::generateConstantMacros() { _constantMacros = StringUtil::format( R"( @@ -317,7 +317,7 @@ bool RenderPipeline::isOccluded(const scene::Camera *camera, const scene::SubMod } // assume visible if camera is inside of worldBound. - if (worldBound->contain(camera->position)) { + if (worldBound->contain(camera->getPosition())) { return false; } diff --git a/native/cocos/renderer/pipeline/RenderPipeline.h b/native/cocos/renderer/pipeline/RenderPipeline.h index 52194df440..f46af2a5be 100644 --- a/native/cocos/renderer/pipeline/RenderPipeline.h +++ b/native/cocos/renderer/pipeline/RenderPipeline.h @@ -25,15 +25,17 @@ #pragma once +#include #include #include "Define.h" #include "GlobalDescriptorSetManager.h" #include "PipelineSceneData.h" #include "PipelineUBO.h" #include "base/CoreStd.h" +#include "core/assets/Asset.h" #include "frame-graph/FrameGraph.h" #include "frame-graph/Handle.h" -#include "helper/DefineMap.h" +#include "renderer/core/PassUtils.h" #include "scene/Camera.h" #include "scene/Model.h" @@ -47,7 +49,7 @@ namespace scene { class SubModel; } // namespace scene namespace pipeline { -class DefineMap; + class GlobalDSManager; class RenderStage; class GeometryRenderer; @@ -57,8 +59,9 @@ struct CC_DLL RenderPipelineInfo { RenderFlowList flows; }; -class CC_DLL RenderPipeline : public Object { +class CC_DLL RenderPipeline : public Asset { public: + using Super = Asset; static RenderPipeline * getInstance(); static framegraph::StringHandle fgStrHandleOutDepthTexture; static framegraph::StringHandle fgStrHandleOutColorTexture; @@ -70,17 +73,18 @@ public: ~RenderPipeline() override; virtual bool activate(gfx::Swapchain *swapchain); - virtual void destroy(); + bool destroy() override; virtual bool initialize(const RenderPipelineInfo &info); virtual void render(const vector &cameras); - void setPipelineSharedSceneData(scene::PipelineSharedSceneData *data); - inline const RenderFlowList & getFlows() const { return _flows; } inline uint getTag() const { return _tag; } inline const map &getGlobalBindings() const { return _globalBindings; } - inline const DefineMap & getMacros() const { return _macros; } - inline void setValue(const String &name, bool value) { _macros.setValue(name, value); } + inline const MacroRecord & getMacros() const { return _macros; } + inline void setValue(const String &name, int32_t value) { _macros[name] = value; } + inline void setValue(const String &name, bool value) { _macros[name] = value; } + inline void setValue(const String &name, const std::string &value) { _macros[name] = value; } + inline void setValue(const String &name, float value) { _macros[name] = value; } inline GlobalDSManager * getGlobalDSManager() const { return _globalDSManager; } inline gfx::DescriptorSet * getDescriptorSet() const { return _descriptorSet; } inline gfx::DescriptorSetLayout * getDescriptorSetLayout() const { return _globalDSManager->getDescriptorSetLayout(); } @@ -92,7 +96,7 @@ public: inline gfx::Device * getDevice() const { return _device; } RenderStage * getRenderstageByName(const String &name) const; bool isOccluded(const scene::Camera *camera, const scene::SubModel *subModel); - bool getOcclusionQueryEnabled() const { return _occlusionQueryEnabled && _device->getCapabilities().supportQuery; } + bool isOcclusionQueryEnabled() const { return _occlusionQueryEnabled && _device->getCapabilities().supportQuery; } void setOcclusionQueryEnabled(bool enable) { _occlusionQueryEnabled = enable; } bool isEnvmapEnabled() const; @@ -114,10 +118,10 @@ public: inline GeometryRenderer *getGeometryRenderer() const { return _geometryRenderer; } inline void setGeometryRenderer(GeometryRenderer *geometryRenderer) { _geometryRenderer = geometryRenderer; } - inline bool getClusterEnabled() const { return _clusterEnabled; } + inline bool isClusterEnabled() const { return _clusterEnabled; } inline void setClusterEnabled(bool enable) { _clusterEnabled = enable; } - inline bool getBloomEnabled() const { return _bloomEnabled; } + inline bool isBloomEnabled() const { return _bloomEnabled; } inline void setBloomEnabled(bool enable) { _bloomEnabled = enable; } protected: @@ -132,18 +136,17 @@ protected: gfx::QueryPoolList _queryPools; RenderFlowList _flows; map _globalBindings; - DefineMap _macros; + MacroRecord _macros; uint _tag = 0; String _constantMacros; - gfx::Device * _device{nullptr}; - GlobalDSManager * _globalDSManager{nullptr}; - gfx::DescriptorSet *_descriptorSet{nullptr}; - PipelineUBO * _pipelineUBO{nullptr}; - scene::Model * _profiler{nullptr}; - PipelineSceneData * _pipelineSceneData{nullptr}; - GeometryRenderer * _geometryRenderer{nullptr}; - + gfx::Device * _device{nullptr}; + GlobalDSManager * _globalDSManager{nullptr}; + gfx::DescriptorSet * _descriptorSet{nullptr}; + PipelineUBO * _pipelineUBO{nullptr}; + scene::Model * _profiler{nullptr}; + IntrusivePtr _pipelineSceneData; + IntrusivePtr _geometryRenderer; // has not initBuiltinRes, // create temporary default Texture to binding sampler2d uint _width{0}; diff --git a/native/cocos/renderer/pipeline/RenderQueue.cpp b/native/cocos/renderer/pipeline/RenderQueue.cpp index be0e47f976..653fe00a9a 100644 --- a/native/cocos/renderer/pipeline/RenderQueue.cpp +++ b/native/cocos/renderer/pipeline/RenderQueue.cpp @@ -31,6 +31,7 @@ #include "gfx-base/GFXCommandBuffer.h" #include "gfx-base/GFXDevice.h" #include "gfx-base/GFXShader.h" +#include "scene/Model.h" #include "scene/SubModel.h" namespace cc { @@ -45,7 +46,7 @@ void RenderQueue::clear() { } bool RenderQueue::insertRenderPass(const RenderObject &renderObj, uint subModelIdx, uint passIdx) { - const auto *const subModel = renderObj.model->getSubModels()[subModelIdx]; + const auto * subModel = renderObj.model->getSubModels()[subModelIdx].get(); const auto *const pass = subModel->getPass(passIdx); const bool isTransparent = pass->getBlendState()->targets[0].blend; @@ -75,10 +76,9 @@ void RenderQueue::sort() { } void RenderQueue::recordCommandBuffer(gfx::Device * /*device*/, scene::Camera *camera, gfx::RenderPass *renderPass, gfx::CommandBuffer *cmdBuff, uint32_t subpassIndex) { - PipelineSceneData *const sceneData = _pipeline->getPipelineSceneData(); - const scene::PipelineSharedSceneData *sharedData = sceneData->getSharedData(); - bool enableOcclusionQuery = _pipeline->getOcclusionQueryEnabled() && _useOcclusionQuery; - auto * queryPool = _pipeline->getQueryPools()[0]; + PipelineSceneData *const sceneData = _pipeline->getPipelineSceneData(); + bool enableOcclusionQuery = _pipeline->isOcclusionQueryEnabled() && _useOcclusionQuery; + auto * queryPool = _pipeline->getQueryPools()[0]; for (auto &i : _queue) { const auto *subModel = i.subModel; if (enableOcclusionQuery) { @@ -86,10 +86,10 @@ void RenderQueue::recordCommandBuffer(gfx::Device * /*device*/, scene::Camera *c } if (enableOcclusionQuery && _pipeline->isOccluded(camera, subModel)) { - auto * inputAssembler = sharedData->occlusionQueryInputAssembler; - const auto *pass = sharedData->occlusionQueryPass; - auto * shader = sharedData->occlusionQueryShader; - auto * pso = PipelineStateManager::getOrCreatePipelineState(pass, shader, inputAssembler, renderPass, subpassIndex); + gfx::InputAssembler *inputAssembler = sceneData->getOcclusionQueryInputAssembler(); + const scene::Pass * pass = sceneData->getOcclusionQueryPass(); + gfx::Shader * shader = sceneData->getOcclusionQueryShader(); + auto * pso = PipelineStateManager::getOrCreatePipelineState(pass, shader, inputAssembler, renderPass, subpassIndex); cmdBuff->bindPipelineState(pso); cmdBuff->bindDescriptorSet(materialSet, pass->getDescriptorSet()); diff --git a/native/cocos/renderer/pipeline/RenderQueue.h b/native/cocos/renderer/pipeline/RenderQueue.h index 676ba7548a..cc236d1613 100644 --- a/native/cocos/renderer/pipeline/RenderQueue.h +++ b/native/cocos/renderer/pipeline/RenderQueue.h @@ -29,7 +29,7 @@ namespace cc { namespace scene { -struct Camera; +class Camera; } namespace pipeline { diff --git a/native/cocos/renderer/pipeline/RenderStage.cpp b/native/cocos/renderer/pipeline/RenderStage.cpp index c2cba49538..052145eea7 100644 --- a/native/cocos/renderer/pipeline/RenderStage.cpp +++ b/native/cocos/renderer/pipeline/RenderStage.cpp @@ -33,8 +33,7 @@ RenderStage::RenderStage() } -RenderStage::~RenderStage() { -} +RenderStage::~RenderStage() = default; bool RenderStage::initialize(const RenderStageInfo &info) { _name = info.name; @@ -50,7 +49,7 @@ void RenderStage::activate(RenderPipeline *pipeline, RenderFlow *flow) { } void RenderStage::destroy() { - for (auto renderQueue : _renderQueues) { + for (auto *renderQueue : _renderQueues) { CC_SAFE_DELETE(renderQueue); } _renderQueues.clear(); diff --git a/native/cocos/renderer/pipeline/SceneCulling.cpp b/native/cocos/renderer/pipeline/SceneCulling.cpp index 62c7e279c4..f0e6dacbd7 100644 --- a/native/cocos/renderer/pipeline/SceneCulling.cpp +++ b/native/cocos/renderer/pipeline/SceneCulling.cpp @@ -29,14 +29,17 @@ #include "Define.h" #include "RenderPipeline.h" #include "SceneCulling.h" +#include "core/geometry/AABB.h" +#include "core/geometry/Frustum.h" +#include "core/geometry/Sphere.h" +#include "core/scene-graph/Node.h" #include "gfx-base/GFXDevice.h" #include "math/Quaternion.h" -#include "scene/AABB.h" -#include "scene/Frustum.h" +#include "scene/DirectionalLight.h" #include "scene/Light.h" #include "scene/Octree.h" #include "scene/RenderScene.h" -#include "scene/Sphere.h" +#include "scene/Skybox.h" #include "scene/SpotLight.h" namespace cc { @@ -45,16 +48,16 @@ namespace pipeline { RenderObject genRenderObject(const scene::Model *model, const scene::Camera *camera) { float depth = 0; if (model->getNode()) { - const auto *node = model->getTransform(); - cc::Vec3 position; - cc::Vec3::subtract(node->getWorldPosition(), camera->position, &position); - depth = position.dot(camera->forward); + auto * node = model->getTransform(); + cc::Vec3 position; + cc::Vec3::subtract(node->getWorldPosition(), camera->getPosition(), &position); + depth = position.dot(camera->getForward()); } return {depth, model}; } -void getShadowWorldMatrix(const scene::Sphere *sphere, const cc::Quaternion &rotation, const cc::Vec3 &dir, cc::Mat4 *shadowWorldMat, cc::Vec3 *out) { +void getShadowWorldMatrix(const geometry::Sphere *sphere, const cc::Quaternion &rotation, const cc::Vec3 &dir, cc::Mat4 *shadowWorldMat, cc::Vec3 *out) { Vec3 translation(dir); translation.negate(); const auto distance = sphere->getRadius() * COEFFICIENT_OF_EXPANSION; @@ -65,16 +68,16 @@ void getShadowWorldMatrix(const scene::Sphere *sphere, const cc::Quaternion &rot Mat4::fromRT(rotation, translation, shadowWorldMat); } -void updateSphereLight(scene::Shadow *shadows, const scene::Light *light, std::array *shadowUBO) { +void updateSphereLight(scene::Shadows *shadows, const scene::Light *light, std::array *shadowUBO) { const auto *node = light->getNode(); - if (!node->getFlagsChanged() && !shadows->dirty) { + if (!node->getChangedFlags() && !shadows->isShadowMapDirty()) { return; } - shadows->dirty = false; + shadows->setShadowMapDirty(false); const auto &position = node->getWorldPosition(); - const auto &normal = shadows->normal; - const auto distance = shadows->distance + 0.001F; // avoid z-fighting + const auto &normal = shadows->getNormal(); + const auto distance = shadows->getDistance() + 0.001F; // avoid z-fighting const auto ndL = normal.dot(position); const auto lx = position.x; const auto ly = position.y; @@ -82,7 +85,7 @@ void updateSphereLight(scene::Shadow *shadows, const scene::Light *light, std::a const auto nx = normal.x; const auto ny = normal.y; const auto nz = normal.z; - auto & matLight = shadows->matLight; + auto & matLight = shadows->getMatLight(); matLight.m[0] = ndL - distance - lx * nx; matLight.m[1] = -ly * nx; matLight.m[2] = -lz * nx; @@ -103,14 +106,14 @@ void updateSphereLight(scene::Shadow *shadows, const scene::Light *light, std::a memcpy(shadowUBO->data() + UBOShadow::MAT_LIGHT_PLANE_PROJ_OFFSET, matLight.m, sizeof(matLight)); } -void updateDirLight(scene::Shadow *shadows, const scene::Light *light, std::array *shadowUBO) { +void updateDirLight(scene::Shadows *shadows, const scene::Light *light, std::array *shadowUBO) { const auto * node = light->getNode(); const auto & rotation = node->getWorldRotation(); const Quaternion qt(rotation.x, rotation.y, rotation.z, rotation.w); Vec3 forward(0, 0, -1.0F); forward.transformQuat(qt); - const auto &normal = shadows->normal; - const auto distance = shadows->distance + 0.001F; // avoid z-fighting + const auto &normal = shadows->getNormal(); + const auto distance = shadows->getDistance() + 0.001F; // avoid z-fighting const auto ndL = normal.dot(forward); const auto scale = 1.0F / ndL; const auto lx = forward.x * scale; @@ -119,56 +122,56 @@ void updateDirLight(scene::Shadow *shadows, const scene::Light *light, std::arra const auto nx = normal.x; const auto ny = normal.y; const auto nz = normal.z; - auto & matLight = shadows->matLight; - matLight.m[0] = 1 - nx * lx; - matLight.m[1] = -nx * ly; - matLight.m[2] = -nx * lz; - matLight.m[3] = 0; - matLight.m[4] = -ny * lx; - matLight.m[5] = 1 - ny * ly; - matLight.m[6] = -ny * lz; - matLight.m[7] = 0; - matLight.m[8] = -nz * lx; - matLight.m[9] = -nz * ly; - matLight.m[10] = 1 - nz * lz; - matLight.m[11] = 0; - matLight.m[12] = lx * distance; - matLight.m[13] = ly * distance; - matLight.m[14] = lz * distance; - matLight.m[15] = 1; + // TODO(): how to avoid create Mat4 every time? + auto &matLight = shadows->getMatLight(); + matLight.m[0] = 1 - nx * lx; + matLight.m[1] = -nx * ly; + matLight.m[2] = -nx * lz; + matLight.m[3] = 0; + matLight.m[4] = -ny * lx; + matLight.m[5] = 1 - ny * ly; + matLight.m[6] = -ny * lz; + matLight.m[7] = 0; + matLight.m[8] = -nz * lx; + matLight.m[9] = -nz * ly; + matLight.m[10] = 1 - nz * lz; + matLight.m[11] = 0; + matLight.m[12] = lx * distance; + matLight.m[13] = ly * distance; + matLight.m[14] = lz * distance; + matLight.m[15] = 1; memcpy(shadowUBO->data() + UBOShadow::MAT_LIGHT_PLANE_PROJ_OFFSET, matLight.m, sizeof(matLight)); - const float color[4] = {shadows->color.x, shadows->color.y, shadows->color.z, shadows->color.w}; - memcpy(shadowUBO->data() + UBOShadow::SHADOW_COLOR_OFFSET, &color, sizeof(color)); + memcpy(shadowUBO->data() + UBOShadow::SHADOW_COLOR_OFFSET, shadows->getShadowColor4f().data(), sizeof(float) * 4); } void validPunctualLightsCulling(RenderPipeline *pipeline, scene::Camera *camera) { - const auto *const scene = camera->scene; + const auto *const scene = camera->getScene(); PipelineSceneData * sceneData = pipeline->getPipelineSceneData(); vector validPunctualLights = sceneData->getValidPunctualLights(); validPunctualLights.clear(); - scene::Sphere sphere; - for (auto *light : scene->getSpotLights()) { - if (light->getBaked()) { + geometry::Sphere sphere; + for (const auto &light : scene->getSpotLights()) { + if (light->isBaked()) { continue; } sphere.setCenter(light->getPosition()); sphere.setRadius(light->getRange()); - if (sphere.sphereFrustum(camera->frustum)) { + if (sphere.sphereFrustum(camera->getFrustum())) { validPunctualLights.emplace_back(static_cast(light)); } } - for (auto *light : scene->getSphereLights()) { - if (light->getBaked()) { + for (const auto &light : scene->getSphereLights()) { + if (light->isBaked()) { continue; } sphere.setCenter(light->getPosition()); sphere.setRadius(light->getRange()); - if (sphere.sphereFrustum(camera->frustum)) { + if (sphere.sphereFrustum(camera->getFrustum())) { validPunctualLights.emplace_back(static_cast(light)); } } @@ -178,13 +181,13 @@ void validPunctualLightsCulling(RenderPipeline *pipeline, scene::Camera *camera) Mat4 getCameraWorldMatrix(const scene::Camera *camera) { Mat4 out; - if (!camera || !camera->node) { + if (!camera || !camera->getNode()) { return out; } - const scene::Node *cameraNode = camera->node; - const Vec3 & position = cameraNode->getWorldPosition(); - const Quaternion & rotation = cameraNode->getWorldRotation(); + const Node * cameraNode = camera->getNode(); + const Vec3 & position = cameraNode->getWorldPosition(); + const Quaternion &rotation = cameraNode->getWorldRotation(); Mat4::fromRT(rotation, position, &out); out.m[8] *= -1.0F; @@ -194,7 +197,7 @@ Mat4 getCameraWorldMatrix(const scene::Camera *camera) { return out; } -void updateDirFrustum(const scene::Sphere *cameraBoundingSphere, const Quaternion &rotation, float range, scene::Frustum *dirLightFrustum) { +void updateDirFrustum(const geometry::Sphere *cameraBoundingSphere, const Quaternion &rotation, float range, geometry::Frustum *dirLightFrustum) { const float radius = cameraBoundingSphere->getRadius(); const Vec3 &position = cameraBoundingSphere->getCenter(); Mat4 matWorldTrans; @@ -206,24 +209,23 @@ void updateDirFrustum(const scene::Sphere *cameraBoundingSphere, const Quaternio dirLightFrustum->createOrtho(radius, radius, -range, radius, matWorldTrans); } -void quantizeDirLightShadowCamera(RenderPipeline *pipeline, const scene::Camera *camera, scene::Frustum *out) { - const gfx::Device * device = gfx::Device::getInstance(); - PipelineSceneData *const sceneData = pipeline->getPipelineSceneData(); - const scene::PipelineSharedSceneData *sharedData = sceneData->getSharedData(); - const scene::Shadow * shadowInfo = sharedData->shadow; - const scene::RenderScene *const scene = camera->scene; - const scene::DirectionalLight * mainLight = scene->getMainLight(); - const float invisibleOcclusionRange = shadowInfo->invisibleOcclusionRange; - const float shadowMapWidth = shadowInfo->size.x; - const auto * node = mainLight->getNode(); - const Quaternion & rotation = node->getWorldRotation(); +void quantizeDirLightShadowCamera(RenderPipeline *pipeline, const scene::Camera *camera, geometry::Frustum *out) { + const gfx::Device * device = gfx::Device::getInstance(); + PipelineSceneData *const sceneData = pipeline->getPipelineSceneData(); + const scene::Shadows * shadows = sceneData->getShadows(); + const scene::RenderScene *const scene = camera->getScene(); + const scene::DirectionalLight * mainLight = scene->getMainLight(); + const float invisibleOcclusionRange = shadows->getInvisibleOcclusionRange(); + const float shadowMapWidth = shadows->getSize().x; + const auto * node = mainLight->getNode(); + const Quaternion & rotation = node->getWorldRotation(); // Raw data. - const Mat4 matWorldTrans = getCameraWorldMatrix(camera); - scene::Frustum validFrustum; - validFrustum.type = scene::ShapeEnums::SHAPE_FRUSTUM_ACCURATE; - validFrustum.split(0.1F, shadowInfo->shadowDistance, camera->aspect, camera->fov, matWorldTrans); - scene::Frustum lightViewFrustum = validFrustum.clone(); + const Mat4 matWorldTrans = getCameraWorldMatrix(camera); + geometry::Frustum validFrustum; + validFrustum.setType(geometry::ShapeEnum::SHAPE_FRUSTUM_ACCURATE); + validFrustum.split(0.1F, shadows->getShadowDistance(), camera->getAspect(), camera->getFov(), matWorldTrans); + geometry::Frustum lightViewFrustum = validFrustum.clone(); // view matrix with range back. Mat4 matShadowTrans; @@ -234,8 +236,8 @@ void quantizeDirLightShadowCamera(RenderPipeline *pipeline, const scene::Camera const Mat4 shadowViewArbitraryPos = matShadowView.clone(); lightViewFrustum.transform(matShadowView); // bounding box in light space. - scene::AABB castLightViewBounds; - scene::AABB::fromPoints(Vec3(10000000.0F, 10000000.0F, 10000000.0F), Vec3(-10000000.0F, -10000000.0F, -10000000.0F), &castLightViewBounds); + geometry::AABB castLightViewBounds; + geometry::AABB::fromPoints(Vec3(10000000.0F, 10000000.0F, 10000000.0F), Vec3(-10000000.0F, -10000000.0F, -10000000.0F), &castLightViewBounds); castLightViewBounds.merge(lightViewFrustum); const float r = castLightViewBounds.getHalfExtents().z * 2.0F; @@ -251,7 +253,7 @@ void quantizeDirLightShadowCamera(RenderPipeline *pipeline, const scene::Camera // min value may lead to some shadow leaks. const float orthoSizeMin = validFrustum.vertices[0].distance(validFrustum.vertices[6]); // max value is accurate but poor usage for shadowMap - scene::Sphere cameraBoundingSphere; + geometry::Sphere cameraBoundingSphere; cameraBoundingSphere.setCenter(Vec3(0.0F, 0.0F, 0.0F)); cameraBoundingSphere.setRadius(-1.0F); cameraBoundingSphere.merge(validFrustum); @@ -266,7 +268,7 @@ void quantizeDirLightShadowCamera(RenderPipeline *pipeline, const scene::Camera const float projectionSinY = device->getCapabilities().clipSpaceSignY; const float clipSpaceMinZ = device->getCapabilities().clipSpaceMinZ; Mat4::createOrthographicOffCenter(-halfOrthoSize, halfOrthoSize, -halfOrthoSize, halfOrthoSize, 0.1F, sceneData->getShadowCameraFar(), - clipSpaceMinZ, projectionSinY, &matShadowProj); + clipSpaceMinZ, projectionSinY, 0, &matShadowProj); if (shadowMapWidth > 0.0F) { const Mat4 matShadowViewProjArbitraryPos = matShadowProj * shadowViewArbitraryPos; @@ -298,17 +300,16 @@ void quantizeDirLightShadowCamera(RenderPipeline *pipeline, const scene::Camera sceneData->setMatShadowViewProj(matShadowViewProj); } void sceneCulling(RenderPipeline *pipeline, scene::Camera *camera) { - PipelineSceneData *const sceneData = pipeline->getPipelineSceneData(); - const scene::PipelineSharedSceneData *sharedData = sceneData->getSharedData(); - const scene::Shadow * shadowInfo = sharedData->shadow; - const scene::Skybox * skyBox = sharedData->skybox; - const scene::RenderScene *const scene = camera->scene; - const scene::DirectionalLight * mainLight = scene->getMainLight(); - scene::Frustum dirLightFrustum; + PipelineSceneData *const sceneData = pipeline->getPipelineSceneData(); + const scene::Shadows * shadows = sceneData->getShadows(); + const scene::Skybox * skyBox = sceneData->getSkybox(); + const scene::RenderScene *const scene = camera->getScene(); + const scene::DirectionalLight * mainLight = scene->getMainLight(); + geometry::Frustum dirLightFrustum; RenderObjectList dirShadowObjects; bool isShadowMap = false; - if (shadowInfo->enabled && shadowInfo->shadowType == scene::ShadowType::SHADOWMAP) { + if (shadows != nullptr && shadows->isEnabled() && shadows->getType() == scene::ShadowType::SHADOW_MAP) { isShadowMap = true; // update dirLightFrustum @@ -325,26 +326,26 @@ void sceneCulling(RenderPipeline *pipeline, scene::Camera *camera) { RenderObjectList renderObjects; RenderObjectList castShadowObject; - if (skyBox->enabled && skyBox->model && (camera->clearFlag & skyboxFlag)) { - renderObjects.emplace_back(genRenderObject(skyBox->model, camera)); + if (skyBox != nullptr && skyBox->isEnabled() && skyBox->getModel() && (static_cast(camera->getClearFlag()) & skyboxFlag)) { + renderObjects.emplace_back(genRenderObject(skyBox->getModel(), camera)); } const scene::Octree *octree = scene->getOctree(); - if (octree) { - for (const auto *model : scene->getModels()) { + if (octree && octree->isEnabled()) { + for (const auto &model : scene->getModels()) { // filter model by view visibility - if (model->getEnabled()) { - if (model->getCastShadow()) { + if (model->isEnabled()) { + if (model->isCastShadow()) { castShadowObject.emplace_back(genRenderObject(model, camera)); } - const auto visibility = camera->visibility; + const auto visibility = camera->getVisibility(); const auto *const node = model->getNode(); if ((model->getNode() && ((visibility & node->getLayer()) == node->getLayer())) || - (visibility & model->getVisFlags())) { + (visibility & static_cast(model->getVisFlags()))) { const auto *modelWorldBounds = model->getWorldBounds(); - if (!modelWorldBounds && skyBox->model != model) { + if (!modelWorldBounds && skyBox->getModel() != model) { renderObjects.emplace_back(genRenderObject(model, camera)); } } @@ -354,8 +355,8 @@ void sceneCulling(RenderPipeline *pipeline, scene::Camera *camera) { if (isShadowMap) { std::vector casters; casters.reserve(scene->getModels().size() / 4); - if (shadowInfo->fixedArea) { - octree->queryVisibility(camera, camera->frustum, true, casters); + if (shadows->isFixedArea()) { + octree->queryVisibility(camera, camera->getFrustum(), true, casters); } else { octree->queryVisibility(camera, dirLightFrustum, true, casters); } @@ -366,25 +367,25 @@ void sceneCulling(RenderPipeline *pipeline, scene::Camera *camera) { std::vector models; models.reserve(scene->getModels().size() / 4); - octree->queryVisibility(camera, camera->frustum, false, models); + octree->queryVisibility(camera, camera->getFrustum(), false, models); for (const auto *model : models) { renderObjects.emplace_back(genRenderObject(model, camera)); } } else { - scene::AABB ab; - for (const auto *model : scene->getModels()) { + geometry::AABB ab; + for (const auto &model : scene->getModels()) { // filter model by view visibility - if (model->getEnabled()) { - const auto visibility = camera->visibility; + if (model->isEnabled()) { + const auto visibility = camera->getVisibility(); const auto *const node = model->getNode(); // cast shadow render Object - if (model->getCastShadow()) { + if (model->isCastShadow()) { castShadowObject.emplace_back(genRenderObject(model, camera)); } if ((model->getNode() && ((visibility & node->getLayer()) == node->getLayer())) || - (visibility & model->getVisFlags())) { + (visibility & static_cast(model->getVisFlags()))) { const auto *modelWorldBounds = model->getWorldBounds(); if (!modelWorldBounds) { renderObjects.emplace_back(genRenderObject(model, camera)); @@ -392,10 +393,10 @@ void sceneCulling(RenderPipeline *pipeline, scene::Camera *camera) { } // dir shadow render Object - if (isShadowMap && model->getCastShadow()) { - if (shadowInfo->fixedArea) { - model->getWorldBounds()->transform(shadowInfo->matLight, &ab); - if (ab.aabbFrustum(camera->frustum)) { + if (isShadowMap && model->isCastShadow()) { + if (shadows->isFixedArea()) { + model->getWorldBounds()->transform(shadows->getMatLight(), &ab); + if (ab.aabbFrustum(camera->getFrustum())) { dirShadowObjects.emplace_back(genRenderObject(model, camera)); } } else { @@ -406,7 +407,7 @@ void sceneCulling(RenderPipeline *pipeline, scene::Camera *camera) { } // frustum culling - if (modelWorldBounds->aabbFrustum(camera->frustum)) { + if (modelWorldBounds->aabbFrustum(camera->getFrustum())) { renderObjects.emplace_back(genRenderObject(model, camera)); } } diff --git a/native/cocos/renderer/pipeline/SceneCulling.h b/native/cocos/renderer/pipeline/SceneCulling.h index 6292c9c3ee..814023ee87 100644 --- a/native/cocos/renderer/pipeline/SceneCulling.h +++ b/native/cocos/renderer/pipeline/SceneCulling.h @@ -24,12 +24,14 @@ ****************************************************************************/ #pragma once + +#include "core/geometry/Frustum.h" +#include "core/geometry/Sphere.h" #include "pipeline/Define.h" #include "scene/Camera.h" #include "scene/Define.h" #include "scene/Light.h" -#include "scene/Sphere.h" -#include "scene/Frustum.h" +#include "scene/Shadow.h" namespace cc { class Mat4; @@ -41,13 +43,13 @@ struct RenderObject; class RenderPipeline; RenderObject genRenderObject(const scene::Model *, const scene::Camera *); -void quantizeDirLightShadowCamera(RenderPipeline *pipeline, const scene::Camera *camera, scene::Frustum *out); +void quantizeDirLightShadowCamera(RenderPipeline *pipeline, const scene::Camera *camera, geometry::Frustum *out); void validPunctualLightsCulling(RenderPipeline *pipeline, scene::Camera *camera); void sceneCulling(RenderPipeline *, scene::Camera *); -void updateSphereLight(scene::Shadow *shadows, const scene::Light *light, std::array *); -void updateDirLight(scene::Shadow *shadows, const scene::Light *light, std::array *); -void getShadowWorldMatrix(const scene::Sphere *sphere, const cc::Quaternion &rotation, const cc::Vec3 &dir, cc::Mat4 *shadowWorldMat, cc::Vec3 *out); +void updateSphereLight(scene::Shadows *shadows, const scene::Light *light, std::array *); +void updateDirLight(scene::Shadows *shadows, const scene::Light *light, std::array *); +void getShadowWorldMatrix(const geometry::Sphere *sphere, const cc::Quaternion &rotation, const cc::Vec3 &dir, cc::Mat4 *shadowWorldMat, cc::Vec3 *out); Mat4 getCameraWorldMatrix(const scene::Camera *camera); -void updateDirFrustum(const scene::Sphere *cameraBoundingSphere, const Quaternion &rotation, float range, scene::Frustum *dirLightFrustum); +void updateDirFrustum(const geometry::Sphere *cameraBoundingSphere, const Quaternion &rotation, float range, geometry::Frustum *dirLightFrustum); } // namespace pipeline } // namespace cc diff --git a/native/cocos/renderer/pipeline/ShadowMapBatchedQueue.cpp b/native/cocos/renderer/pipeline/ShadowMapBatchedQueue.cpp index 5b8e31dff9..3747e93df8 100644 --- a/native/cocos/renderer/pipeline/ShadowMapBatchedQueue.cpp +++ b/native/cocos/renderer/pipeline/ShadowMapBatchedQueue.cpp @@ -36,6 +36,7 @@ #include "gfx-base/GFXCommandBuffer.h" #include "gfx-base/GFXDescriptorSet.h" #include "gfx-base/GFXDevice.h" +#include "scene/Shadow.h" #include "scene/SpotLight.h" namespace cc { @@ -52,10 +53,10 @@ void ShadowMapBatchedQueue::gatherLightPasses(const scene::Camera *camera, const clear(); const PipelineSceneData *sceneData = _pipeline->getPipelineSceneData(); - const scene::Shadow * shadowInfo = sceneData->getSharedData()->shadow; + const scene::Shadows * shadows = sceneData->getShadows(); const RenderObjectList & dirShadowObjects = sceneData->getDirShadowObjects(); - const RenderObjectList & castShadowObjects = sceneData->getCastShadowObjects(); - if (light && shadowInfo->enabled && shadowInfo->shadowType == scene::ShadowType::SHADOWMAP) { + const RenderObjectList & castShadowObjects = sceneData->isCastShadowObjects(); + if (light && shadows->isEnabled() && shadows->getType() == scene::ShadowType::SHADOW_MAP) { switch (light->getType()) { case scene::LightType::DIRECTIONAL: { for (const auto ro : dirShadowObjects) { @@ -69,17 +70,17 @@ void ShadowMapBatchedQueue::gatherLightPasses(const scene::Camera *camera, const const Mat4 matShadowView = light->getNode()->getWorldMatrix().getInversed(); Mat4 matShadowProj; Mat4::createPerspective(spotLight->getSpotAngle(), spotLight->getAspect(), 0.001F, spotLight->getRange(), &matShadowProj); - const Mat4 matShadowViewProj = matShadowProj * matShadowView; - scene::AABB ab; + const Mat4 matShadowViewProj = matShadowProj * matShadowView; + geometry::AABB ab; for (const auto ro : castShadowObjects) { const auto *model = ro.model; - if (!model->getEnabled() || !model->getCastShadow() || !model->getNode()) { + if (!model->isEnabled() || !model->isCastShadow() || !model->getNode()) { continue; } if (model->getWorldBounds()) { model->getWorldBounds()->transform(matShadowViewProj, &ab); - if (ab.aabbFrustum(camera->frustum)) { + if (ab.aabbFrustum(camera->getFrustum())) { add(model, cmdBuffer); } } @@ -113,7 +114,7 @@ void ShadowMapBatchedQueue::add(const scene::Model *model, gfx::CommandBuffer *c return; } - for (auto *subModel : model->getSubModels()) { + for (const auto &subModel : model->getSubModels()) { const auto *pass = subModel->getPass(shadowPassIdx); const auto batchingScheme = pass->getBatchingScheme(); @@ -164,9 +165,9 @@ void ShadowMapBatchedQueue::destroy() { } int ShadowMapBatchedQueue::getShadowPassIndex(const scene::Model *model) const { - for (const scene::SubModel *subModel : model->getSubModels()) { + for (const auto &subModel : model->getSubModels()) { int i = 0; - for (const scene::Pass *pass : subModel->getPasses()) { + for (const auto &pass : subModel->getPasses()) { if (pass->getPhase() == _phaseID) { return i; } diff --git a/native/cocos/renderer/pipeline/UIPhase.cpp b/native/cocos/renderer/pipeline/UIPhase.cpp index e87b91a184..55bbbd953a 100644 --- a/native/cocos/renderer/pipeline/UIPhase.cpp +++ b/native/cocos/renderer/pipeline/UIPhase.cpp @@ -26,6 +26,7 @@ #include "UIPhase.h" #include "gfx-base/GFXCommandBuffer.h" #include "pipeline/PipelineStateManager.h" +#include "scene/DrawBatch2D.h" #include "scene/RenderScene.h" #include "scene/SubModel.h" @@ -40,10 +41,10 @@ void UIPhase::activate(RenderPipeline *pipeline) { void UIPhase::render(scene::Camera *camera, gfx::RenderPass *renderPass) { auto *cmdBuff = _pipeline->getCommandBuffers()[0]; - const auto &batches = camera->scene->getDrawBatch2Ds(); + const auto &batches = camera->getScene()->getDrawBatch2Ds(); // Notice: The batches[0] is batchCount for (auto *batch : batches) { - if (!(camera->visibility & batch->visFlags)) continue; + if (!(camera->getVisibility() & batch->visFlags)) continue; for (size_t i = 0; i < batch->shaders.size(); ++i) { const auto *pass = batch->passes[i]; if (pass->getPhase() != _phaseID) continue; diff --git a/native/cocos/renderer/pipeline/deferred/BloomStage.cpp b/native/cocos/renderer/pipeline/deferred/BloomStage.cpp index 8a51357b1c..334190ecb8 100644 --- a/native/cocos/renderer/pipeline/deferred/BloomStage.cpp +++ b/native/cocos/renderer/pipeline/deferred/BloomStage.cpp @@ -28,7 +28,6 @@ #include "../PipelineStateManager.h" #include "../RenderPipeline.h" #include "../RenderQueue.h" -#include "pipeline/UIPhase.h" #include "frame-graph/DevicePass.h" #include "frame-graph/PassNodeBuilder.h" #include "frame-graph/Resource.h" @@ -39,8 +38,10 @@ #include "gfx-base/GFXFramebuffer.h" #include "gfx-base/states/GFXSampler.h" #include "pipeline/Define.h" -#include "scene/SubModel.h" +#include "pipeline/UIPhase.h" +#include "renderer/pipeline/deferred/DeferredPipelineSceneData.h" #include "scene/RenderScene.h" +#include "scene/SubModel.h" namespace cc { namespace pipeline { @@ -113,7 +114,7 @@ void BloomStage::destroy() { void BloomStage::render(scene::Camera *camera) { auto *pipeline = _pipeline; CC_ASSERT(pipeline != nullptr); - if (!pipeline->getBloomEnabled() || pipeline->getPipelineSceneData()->getRenderObjects().empty()) return; + if (!pipeline->isBloomEnabled() || pipeline->getPipelineSceneData()->getRenderObjects().empty()) return; if (_prefilterUBO == nullptr) { _prefilterUBO = _device->createBuffer({gfx::BufferUsage::UNIFORM, gfx::MemoryUsage::DEVICE | gfx::MemoryUsage::HOST, UBOBloom::SIZE}); @@ -134,12 +135,12 @@ void BloomStage::render(scene::Camera *camera) { _sampler = pipeline->getDevice()->getSampler(info); } - if (hasFlag(static_cast(camera->clearFlag), gfx::ClearFlagBit::COLOR)) { - _clearColors[0].x = camera->clearColor.x; - _clearColors[0].y = camera->clearColor.y; - _clearColors[0].z = camera->clearColor.z; + if (hasFlag(static_cast(camera->getClearFlag()), gfx::ClearFlagBit::COLOR)) { + _clearColors[0].x = camera->getClearColor().x; + _clearColors[0].y = camera->getClearColor().y; + _clearColors[0].z = camera->getClearColor().z; } - _clearColors[0].w = camera->clearColor.w; + _clearColors[0].w = camera->getClearColor().w; framegraph::RenderTargetAttachment::Descriptor colorAttachmentInfo; colorAttachmentInfo.usage = framegraph::RenderTargetAttachment::Usage::COLOR; @@ -164,11 +165,11 @@ void BloomStage::render(scene::Camera *camera) { float intensity = stage->getIntensity(); float threshold = stage->getThreshold(); - _renderArea = RenderPipeline::getRenderArea(camera); + _renderArea = RenderPipeline::getRenderArea(camera); _inputAssembler = pipeline->getIAByRenderArea(_renderArea); _renderArea.width >>= 1; _renderArea.height >>= 1; - float shadingScale{_pipeline->getPipelineSceneData()->getSharedData()->shadingScale}; + float shadingScale{_pipeline->getPipelineSceneData()->getShadingScale()}; auto prefilterSetup = [&](framegraph::PassNodeBuilder &builder, PrefilterRenderData &data) { data.sampler = _sampler; // read lightingout as input @@ -178,8 +179,8 @@ void BloomStage::render(scene::Camera *camera) { framegraph::Texture::Descriptor colorTexInfo; colorTexInfo.format = gfx::Format::RGBA16F; colorTexInfo.usage = gfx::TextureUsageBit::COLOR_ATTACHMENT | gfx::TextureUsageBit::SAMPLED; - colorTexInfo.width = static_cast(pipeline->getWidth() * shadingScale); - colorTexInfo.height = static_cast(pipeline->getHeight() * shadingScale); + colorTexInfo.width = static_cast(static_cast(pipeline->getWidth()) * shadingScale); + colorTexInfo.height = static_cast(static_cast(pipeline->getHeight()) * shadingScale); data.inputTexHandle = builder.create( RenderPipeline::fgStrHandleOutColorTexture, colorTexInfo); @@ -194,8 +195,8 @@ void BloomStage::render(scene::Camera *camera) { framegraph::Texture::Descriptor colorTexInfo; colorTexInfo.format = gfx::Format::RGBA16F; colorTexInfo.usage = gfx::TextureUsageBit::COLOR_ATTACHMENT | gfx::TextureUsageBit::SAMPLED; - colorTexInfo.width = static_cast(_renderArea.width * shadingScale); - colorTexInfo.height = static_cast(_renderArea.height * shadingScale); + colorTexInfo.width = static_cast(static_cast(_renderArea.width) * shadingScale); + colorTexInfo.height = static_cast(static_cast(_renderArea.height) * shadingScale); data.outputTexHandle = builder.create(prefilterTexHandle, colorTexInfo); } @@ -215,10 +216,10 @@ void BloomStage::render(scene::Camera *camera) { const std::array globalOffsets = {_pipeline->getPipelineUBO()->getCurrentCameraUBOOffset()}; cmdBf->bindDescriptorSet(globalSet, pipeline->getDescriptorSet(), utils::toUint(globalOffsets.size()), globalOffsets.data()); - auto *const sharedData = pipeline->getPipelineSceneData()->getSharedData(); - scene::Pass * pass = sharedData->bloomPrefilterPass; - gfx::Shader * shader = sharedData->bloomPrefilterPassShader; - gfx::PipelineState * pso = PipelineStateManager::getOrCreatePipelineState( + auto * sceneData = static_cast(pipeline->getPipelineSceneData()); + scene::Pass * pass = sceneData->getBloomPrefilterPass(); + gfx::Shader * shader = sceneData->getBloomPrefilterPassShader(); + gfx::PipelineState *pso = PipelineStateManager::getOrCreatePipelineState( pass, shader, _inputAssembler, renderPass); CC_ASSERT(pso != nullptr); @@ -271,8 +272,8 @@ void BloomStage::render(scene::Camera *camera) { framegraph::Texture::Descriptor colorTexInfo; colorTexInfo.format = gfx::Format::RGBA16F; colorTexInfo.usage = gfx::TextureUsageBit::COLOR_ATTACHMENT | gfx::TextureUsageBit::SAMPLED; - colorTexInfo.width = static_cast(_renderArea.width * shadingScale); - colorTexInfo.height = static_cast(_renderArea.height * shadingScale); + colorTexInfo.width = static_cast(static_cast(_renderArea.width) * shadingScale); + colorTexInfo.height = static_cast(static_cast(_renderArea.height) * shadingScale); data.outputTexHandle = builder.create(downsampleTexHandles[data.index], colorTexInfo); } @@ -280,9 +281,9 @@ void BloomStage::render(scene::Camera *camera) { builder.writeToBlackboard(downsampleTexHandles[data.index], data.outputTexHandle); // Update cc_textureSize - data.bloomUBO = stage->getDownsampelUBO()[data.index]; - data.textureSize[0] = static_cast(static_cast(_renderArea.width * shadingScale) << 1); - data.textureSize[1] = static_cast(static_cast(_renderArea.height * shadingScale) << 1); + data.bloomUBO = stage->getDownsampleUBO()[data.index]; + data.textureSize[0] = static_cast(static_cast(static_cast(_renderArea.width) * shadingScale) << 1); + data.textureSize[1] = static_cast(static_cast(static_cast(_renderArea.height) * shadingScale) << 1); }; auto downsampleExec = [this, camera](ScalingSampleRenderData const &data, const framegraph::DevicePassResourceTable &table) { @@ -293,10 +294,10 @@ void BloomStage::render(scene::Camera *camera) { const std::array globalOffsets = {_pipeline->getPipelineUBO()->getCurrentCameraUBOOffset()}; cmdBf->bindDescriptorSet(globalSet, pipeline->getDescriptorSet(), utils::toUint(globalOffsets.size()), globalOffsets.data()); - auto *const sharedData = pipeline->getPipelineSceneData()->getSharedData(); - scene::Pass * pass = sharedData->bloomDownsamplePass[data.index]; - gfx::Shader * shader = sharedData->bloomDownsamplePassShader; - gfx::PipelineState * pso = PipelineStateManager::getOrCreatePipelineState( + auto *const sceneData = static_cast(pipeline->getPipelineSceneData()); + scene::Pass * pass = sceneData->getBloomDownSamplePasses()[data.index]; + gfx::Shader * shader = sceneData->getBloomDownSamplePassShader(); + gfx::PipelineState *pso = PipelineStateManager::getOrCreatePipelineState( pass, shader, _inputAssembler, renderPass); CC_ASSERT(pso != nullptr); @@ -342,8 +343,8 @@ void BloomStage::render(scene::Camera *camera) { framegraph::Texture::Descriptor colorTexInfo; colorTexInfo.format = gfx::Format::RGBA16F; colorTexInfo.usage = gfx::TextureUsageBit::COLOR_ATTACHMENT | gfx::TextureUsageBit::SAMPLED; - colorTexInfo.width = static_cast(_renderArea.width * shadingScale); - colorTexInfo.height = static_cast(_renderArea.height * shadingScale); + colorTexInfo.width = static_cast(static_cast(_renderArea.width) * shadingScale); + colorTexInfo.height = static_cast(static_cast(_renderArea.height) * shadingScale); data.outputTexHandle = builder.create( upsampleTexHandles[data.index], colorTexInfo); @@ -353,8 +354,8 @@ void BloomStage::render(scene::Camera *camera) { // Update cc_textureSize data.bloomUBO = stage->getUpsampleUBO()[data.index]; - data.textureSize[0] = static_cast(static_cast(_renderArea.width * shadingScale) >> 1); - data.textureSize[1] = static_cast(static_cast(_renderArea.height * shadingScale) >> 1); + data.textureSize[0] = static_cast(static_cast(static_cast(_renderArea.width) * shadingScale) >> 1); + data.textureSize[1] = static_cast(static_cast(static_cast(_renderArea.height) * shadingScale) >> 1); }; auto upsampleExec = [this, camera](ScalingSampleRenderData const &data, const framegraph::DevicePassResourceTable &table) { @@ -365,10 +366,10 @@ void BloomStage::render(scene::Camera *camera) { const std::array globalOffsets = {_pipeline->getPipelineUBO()->getCurrentCameraUBOOffset()}; cmdBf->bindDescriptorSet(globalSet, pipeline->getDescriptorSet(), utils::toUint(globalOffsets.size()), globalOffsets.data()); - auto *const sharedData = pipeline->getPipelineSceneData()->getSharedData(); - scene::Pass * pass = sharedData->bloomUpsamplePass[data.index]; - gfx::Shader * shader = sharedData->bloomUpsamplePassShader; - gfx::PipelineState * pso = PipelineStateManager::getOrCreatePipelineState( + auto *const sceneData = static_cast(pipeline->getPipelineSceneData()); + scene::Pass * pass = sceneData->getBloomUpSamplePasses()[data.index]; + gfx::Shader * shader = sceneData->getBloomUpSamplePassShader(); + gfx::PipelineState *pso = PipelineStateManager::getOrCreatePipelineState( pass, shader, _inputAssembler, renderPass); CC_ASSERT(pso != nullptr); @@ -420,8 +421,8 @@ void BloomStage::render(scene::Camera *camera) { framegraph::Texture::Descriptor colorTexInfo; colorTexInfo.format = gfx::Format::RGBA16F; colorTexInfo.usage = gfx::TextureUsageBit::COLOR_ATTACHMENT | gfx::TextureUsageBit::SAMPLED; - colorTexInfo.width = static_cast(_renderArea.width * shadingScale); - colorTexInfo.height = static_cast(_renderArea.height * shadingScale); + colorTexInfo.width = static_cast(static_cast(_renderArea.width) * shadingScale); + colorTexInfo.height = static_cast(static_cast(_renderArea.height) * shadingScale); data.bloomOutTexHandle = builder.create( RenderPipeline::fgStrHandleBloomOutTexture, colorTexInfo); @@ -442,10 +443,10 @@ void BloomStage::render(scene::Camera *camera) { const std::array globalOffsets = {_pipeline->getPipelineUBO()->getCurrentCameraUBOOffset()}; cmdBf->bindDescriptorSet(globalSet, pipeline->getDescriptorSet(), utils::toUint(globalOffsets.size()), globalOffsets.data()); - auto *const sharedData = pipeline->getPipelineSceneData()->getSharedData(); - scene::Pass * pass = sharedData->bloomCombinePass; - gfx::Shader * shader = sharedData->bloomCombinePassShader; - gfx::PipelineState * pso = PipelineStateManager::getOrCreatePipelineState( + auto *const sceneData = static_cast(pipeline->getPipelineSceneData()); + scene::Pass * pass = sceneData->getBloomCombinePass(); + gfx::Shader * shader = sceneData->getBloomCombinePassShader(); + gfx::PipelineState *pso = PipelineStateManager::getOrCreatePipelineState( pass, shader, _inputAssembler, renderPass); CC_ASSERT(pso != nullptr); diff --git a/native/cocos/renderer/pipeline/deferred/BloomStage.h b/native/cocos/renderer/pipeline/deferred/BloomStage.h index c2461d2468..75140bb5f1 100644 --- a/native/cocos/renderer/pipeline/deferred/BloomStage.h +++ b/native/cocos/renderer/pipeline/deferred/BloomStage.h @@ -52,7 +52,7 @@ public: void render(scene::Camera *camera) override; gfx::Buffer * getPrefilterUBO() { return _prefilterUBO; } - auto & getDownsampelUBO() { return _downsampleUBO; } + auto & getDownsampleUBO() { return _downsampleUBO; } auto & getUpsampleUBO() { return _upsampleUBO; } gfx::Buffer * getCombineUBO() { return _combineUBO; } gfx::Sampler *getSampler() const { return _sampler; } diff --git a/native/cocos/renderer/pipeline/deferred/DeferredPipeline.cpp b/native/cocos/renderer/pipeline/deferred/DeferredPipeline.cpp index 13391526af..5689d0e355 100644 --- a/native/cocos/renderer/pipeline/deferred/DeferredPipeline.cpp +++ b/native/cocos/renderer/pipeline/deferred/DeferredPipeline.cpp @@ -25,7 +25,9 @@ #include "DeferredPipeline.h" #include "../SceneCulling.h" +#include "../helper/Utils.h" #include "../shadow/ShadowFlow.h" +#include "DeferredPipelineSceneData.h" #include "MainFlow.h" #include "gfx-base/GFXBuffer.h" #include "gfx-base/GFXCommandBuffer.h" @@ -34,10 +36,11 @@ #include "gfx-base/GFXDevice.h" #include "gfx-base/GFXSwapchain.h" #include "gfx-base/states/GFXTextureBarrier.h" -#include "../helper/Utils.h" +#include "scene/RenderWindow.h" namespace cc { namespace pipeline { + #define TO_VEC3(dst, src, offset) \ dst[offset] = (src).x; \ (dst)[(offset) + 1] = (src).y; \ @@ -48,6 +51,10 @@ namespace pipeline { (dst)[(offset) + 2] = (src).z; \ (dst)[(offset) + 3] = (src).w; +DeferredPipeline::DeferredPipeline() { + _pipelineSceneData = new DeferredPipelineSceneData(); +} + framegraph::StringHandle DeferredPipeline::fgStrHandleGbufferTexture[GBUFFER_COUNT] = { framegraph::FrameGraph::stringToHandle("gbufferAlbedoTexture"), framegraph::FrameGraph::stringToHandle("gbufferPositionTexture"), @@ -75,7 +82,7 @@ bool DeferredPipeline::initialize(const RenderPipelineInfo &info) { } bool DeferredPipeline::activate(gfx::Swapchain *swapchain) { - _macros.setValue("CC_PIPELINE_TYPE", static_cast(1.0)); + _macros["CC_PIPELINE_TYPE"] = 1; if (!RenderPipeline::activate(swapchain)) { CC_LOG_ERROR("RenderPipeline active failed."); @@ -92,7 +99,7 @@ bool DeferredPipeline::activate(gfx::Swapchain *swapchain) { void DeferredPipeline::render(const vector &cameras) { auto *device = gfx::Device::getInstance(); - bool enableOcclusionQuery = getOcclusionQueryEnabled(); + bool enableOcclusionQuery = isOcclusionQueryEnabled(); if (enableOcclusionQuery) { device->getQueryPoolResults(_queryPools[0]); } @@ -139,7 +146,6 @@ void DeferredPipeline::render(const vector &cameras) { bool DeferredPipeline::activeRenderer(gfx::Swapchain *swapchain) { _commandBuffers.push_back(_device->getCommandBuffer()); _queryPools.push_back(_device->getQueryPool()); - auto *const sharedData = _pipelineSceneData->getSharedData(); gfx::Sampler *const sampler = getGlobalDSManager()->getPointSampler(); @@ -149,8 +155,8 @@ bool DeferredPipeline::activeRenderer(gfx::Swapchain *swapchain) { _descriptorSet->update(); // update global defines when all states initialized. - _macros.setValue("CC_USE_HDR", static_cast(sharedData->isHDR)); - _macros.setValue("CC_SUPPORT_FLOAT_TEXTURE", _device->hasFeature(gfx::Feature::TEXTURE_FLOAT)); + _macros["CC_USE_HDR"] = static_cast(_pipelineSceneData->isHDR()); + _macros["CC_SUPPORT_FLOAT_TEXTURE"] = _device->hasFeature(gfx::Feature::TEXTURE_FLOAT); // step 2 create index buffer uint ibStride = 4; @@ -179,7 +185,7 @@ bool DeferredPipeline::activeRenderer(gfx::Swapchain *swapchain) { return true; } -void DeferredPipeline::destroy() { +bool DeferredPipeline::destroy() { destroyQuadInputAssembler(); for (auto &it : _renderPasses) { @@ -192,7 +198,7 @@ void DeferredPipeline::destroy() { CC_SAFE_DELETE(_clusterComp); - RenderPipeline::destroy(); + return RenderPipeline::destroy(); } } // namespace pipeline diff --git a/native/cocos/renderer/pipeline/deferred/DeferredPipeline.h b/native/cocos/renderer/pipeline/deferred/DeferredPipeline.h index d3170936f0..30e4d0ee9c 100644 --- a/native/cocos/renderer/pipeline/deferred/DeferredPipeline.h +++ b/native/cocos/renderer/pipeline/deferred/DeferredPipeline.h @@ -31,8 +31,8 @@ #include "gfx-base/GFXBuffer.h" #include "gfx-base/GFXInputAssembler.h" #include "pipeline/ClusterLightCulling.h" -#include "pipeline/RenderPipeline.h" #include "pipeline/Enum.h" +#include "pipeline/RenderPipeline.h" #include "scene/RenderWindow.h" namespace cc { @@ -43,11 +43,11 @@ struct UBOShadow; class CC_DLL DeferredPipeline : public RenderPipeline { public: - DeferredPipeline() = default; + DeferredPipeline(); ~DeferredPipeline() override = default; bool initialize(const RenderPipelineInfo &info) override; - void destroy() override; + bool destroy() override; bool activate(gfx::Swapchain *swapchain) override; void render(const vector &cameras) override; diff --git a/native/cocos/renderer/pipeline/deferred/DeferredPipelineSceneData.cpp b/native/cocos/renderer/pipeline/deferred/DeferredPipelineSceneData.cpp new file mode 100644 index 0000000000..bb5c5ef8e3 --- /dev/null +++ b/native/cocos/renderer/pipeline/deferred/DeferredPipelineSceneData.cpp @@ -0,0 +1,150 @@ +#include "renderer/pipeline/deferred/DeferredPipelineSceneData.h" +#include "renderer/pipeline/RenderPipeline.h" +#include "renderer/pipeline/deferred/BloomStage.h" +#include "scene/Shadow.h" + +namespace cc { +namespace pipeline { + +void DeferredPipelineSceneData::activate(gfx::Device *device, RenderPipeline *pipeline) { + PipelineSceneData::activate(device, pipeline); + initPipelinePassInfo(); +} + +void DeferredPipelineSceneData::onGlobalPipelineStateChanged() { + updatePipelinePassInfo(); +} + +void DeferredPipelineSceneData::initPipelinePassInfo() { + // builtin deferred material + _lightingMaterial = new Material(); + _lightingMaterial->setUuid("builtin-deferred-material"); + IMaterialInfo materialInfo; + materialInfo.effectName = "deferred-lighting"; + _lightingMaterial->initialize(materialInfo); + for (const auto &pass : *_lightingMaterial->getPasses()) { + pass->tryCompile(); + } + + _bloomMaterial = new Material(); + _bloomMaterial->setUuid("builtin-bloom-material"); + materialInfo.effectName = "bloom"; + _bloomMaterial->initialize(materialInfo); + for (const auto &pass : *_bloomMaterial->getPasses()) { + pass->tryCompile(); + } + + _postProcessMaterial = new Material(); + _postProcessMaterial->setUuid("builtin-post-process-material"); + //TODO(minggo): + // if (macro.ENABLE_ANTIALIAS_FXAA) { + // _antiAliasing = AntiAliasing::FXAA; + // } + materialInfo.effectName = "post-process"; + MacroRecord record{{"ANTIALIAS_TYPE", static_cast(_antiAliasing)}}; + materialInfo.defines = record; + _postProcessMaterial->initialize(materialInfo); + for (const auto &pass : *_postProcessMaterial->getPasses()) { + pass->tryCompile(); + } + + updatePipelinePassInfo(); +} + +void DeferredPipelineSceneData::setAntiAliasing(AntiAliasing value) { + _antiAliasing = value; + if (_postProcessMaterial) { + auto &defines = (*_postProcessMaterial->getPasses())[0]->getDefines(); + defines.emplace("ANTIALIAS_TYPE", static_cast(value)); + auto * renderMat = new Material(); + IMaterialInfo materialInfo; + materialInfo.effectAsset = _postProcessMaterial->getEffectAsset(); + materialInfo.defines = defines; + renderMat->initialize(materialInfo); + for (const auto &pass : *renderMat->getPasses()) { + pass->tryCompile(); + } + _postProcessMaterial = renderMat; + } +} + +void DeferredPipelineSceneData::updateBloomPass() { + if (!_bloomMaterial) { + return; + } + + auto &bloomPasses = *_bloomMaterial->getPasses(); + _bloomPrefilterPass = bloomPasses[BLOOM_PREFILTERPASS_INDEX]; + _bloomPrefilterPass->beginChangeStatesSilently(); + _bloomPrefilterPass->tryCompile(); + _bloomPrefilterPass->endChangeStatesSilently(); + _bloomPrefilterPassShader = _bloomPrefilterPass->getShaderVariant(); + + for (uint32_t i = 0; i < MAX_BLOOM_FILTER_PASS_NUM; ++i) { + scene::Pass *downsamplePass = bloomPasses[BLOOM_DOWNSAMPLEPASS_INDEX + i]; + downsamplePass->beginChangeStatesSilently(); + downsamplePass->tryCompile(); + downsamplePass->endChangeStatesSilently(); + + scene::Pass *upsamplePass = bloomPasses[BLOOM_UPSAMPLEPASS_INDEX + i]; + upsamplePass->beginChangeStatesSilently(); + upsamplePass->tryCompile(); + upsamplePass->endChangeStatesSilently(); + + _bloomUpSamplePasses.emplace_back(upsamplePass); + _bloomDownSamplePasses.emplace_back(downsamplePass); + } + + _bloomCombinePass = bloomPasses[BLOOM_COMBINEPASS_INDEX]; + _bloomCombinePass->beginChangeStatesSilently(); + _bloomCombinePass->tryCompile(); + _bloomCombinePass->endChangeStatesSilently(); + _bloomCombinePassShader = _bloomCombinePass->getShaderVariant(); + + _bloomUpSamplePassShader = bloomPasses[BLOOM_UPSAMPLEPASS_INDEX]->getShaderVariant(); + _bloomDownSamplePassShader = bloomPasses[BLOOM_DOWNSAMPLEPASS_INDEX]->getShaderVariant(); +} + +void DeferredPipelineSceneData::updatePostProcessPass() { + if (!_postProcessMaterial) { + return; + } + + _postPass = (*_postProcessMaterial->getPasses())[0]; + _postPass->beginChangeStatesSilently(); + _postPass->tryCompile(); + _postPass->endChangeStatesSilently(); + + _postPassShader = _postPass->getShaderVariant(); +} + +void DeferredPipelineSceneData::updatePipelinePassInfo() { + updateBloomPass(); + updatePostProcessPass(); + updateDeferredPassInfo(); +} + +void DeferredPipelineSceneData::updateDeferredPassInfo() { + updateDeferredLightPass(); +} + +void DeferredPipelineSceneData::updateDeferredLightPass() { + if (!_lightingMaterial) { + return; + } + + // It's temporary solution for main light shadowmap + if (_shadow->isEnabled()) { + _pipeline->setValue("CC_RECEIVE_SHADOW", 1); + } + + _lightPass = (*_lightingMaterial->getPasses())[0]; + _lightPass->beginChangeStatesSilently(); + _lightPass->tryCompile(); + _lightPass->endChangeStatesSilently(); + + _lightPassShader = _lightPass->getShaderVariant(); +} + +} // namespace pipeline +} // namespace cc diff --git a/native/cocos/renderer/pipeline/deferred/DeferredPipelineSceneData.h b/native/cocos/renderer/pipeline/deferred/DeferredPipelineSceneData.h new file mode 100644 index 0000000000..4066f55fbe --- /dev/null +++ b/native/cocos/renderer/pipeline/deferred/DeferredPipelineSceneData.h @@ -0,0 +1,98 @@ +#pragma once + +#include "base/Ptr.h" +#include "core/assets/Material.h" +#include "renderer/gfx-base/GFXShader.h" +#include "renderer/pipeline/PipelineSceneData.h" +#include "scene/Pass.h" + +#define BLOOM_PREFILTERPASS_INDEX 0 +#define BLOOM_DOWNSAMPLEPASS_INDEX 1 +#define BLOOM_UPSAMPLEPASS_INDEX (BLOOM_DOWNSAMPLEPASS_INDEX + 1) +#define BLOOM_COMBINEPASS_INDEX (BLOOM_UPSAMPLEPASS_INDEX + 1) + +namespace cc { +namespace pipeline { + +enum class AntiAliasing { + NONE, + FXAA +}; + +class DeferredPipelineSceneData : public PipelineSceneData { +public: + DeferredPipelineSceneData() = default; + ~DeferredPipelineSceneData() override = default; + + void activate(gfx::Device *device, RenderPipeline *pipeline) override; + void onGlobalPipelineStateChanged() override; + + void initPipelinePassInfo(); + + void setAntiAliasing(AntiAliasing value); + inline AntiAliasing getAntiAliasing() const { return _antiAliasing; } + + inline Material *getBloomMaterial() const { return _bloomMaterial; } + inline void setBloomMaterial(Material *mat) { + if (mat == _bloomMaterial.get()) { + return; + } + _bloomMaterial = mat; + updatePipelinePassInfo(); + } + + inline Material *getPostProcessMaterial() const { return _postProcessMaterial; } + inline void setPostProcessMaterial(Material *mat) { + if (mat == _postProcessMaterial.get()) { + return; + } + _postProcessMaterial = mat; + updatePipelinePassInfo(); + } + + inline void setLightingMaterial(Material *mat) { _lightingMaterial = mat; } + inline Material * getLightingMaterial() const { return _lightingMaterial; } + inline gfx::Shader * getLightPassShader() const { return _lightPassShader; } + inline scene::Pass * getLightPass() const { return _lightPass; } + inline gfx::Shader * getBloomPrefilterPassShader() const { return _bloomPrefilterPassShader; } + inline scene::Pass * getBloomPrefilterPass() const { return _bloomPrefilterPass; } + inline const std::vector &getBloomUpSamplePasses() const { return _bloomUpSamplePasses; } + inline gfx::Shader * getBloomUpSamplePassShader() const { return _bloomUpSamplePassShader; } + inline const std::vector &getBloomDownSamplePasses() const { return _bloomDownSamplePasses; } + inline gfx::Shader * getBloomDownSamplePassShader() const { return _bloomDownSamplePassShader; } + inline scene::Pass * getBloomCombinePass() const { return _bloomCombinePass; } + inline gfx::Shader * getBloomCombinePassShader() const { return _bloomCombinePassShader; } + + inline gfx::Shader *getPostPassShader() const { return _postPassShader; } + inline scene::Pass *getPostPass() const { return _postPass; } + +private: + void updateBloomPass(); + void updatePostProcessPass(); + void updatePipelinePassInfo(); + void updateDeferredPassInfo(); + void updateDeferredLightPass(); + + IntrusivePtr _postProcessMaterial; + gfx::Shader * _postPassShader{nullptr}; // weak reference + scene::Pass * _postPass{nullptr}; // weak reference + + IntrusivePtr _lightingMaterial; + gfx::Shader * _lightPassShader{nullptr}; // weak reference + scene::Pass * _lightPass{nullptr}; // weak reference + + IntrusivePtr _bloomMaterial; + scene::Pass * _bloomPrefilterPass{nullptr}; // weak reference + gfx::Shader * _bloomPrefilterPassShader{nullptr}; // weak reference + scene::Pass * _bloomCombinePass{nullptr}; // weak reference + gfx::Shader * _bloomCombinePassShader{nullptr}; // weak reference + std::vector _bloomUpSamplePasses; // weak reference + gfx::Shader * _bloomUpSamplePassShader{nullptr}; // weak reference + std::vector _bloomDownSamplePasses; // weak reference + gfx::Shader * _bloomDownSamplePassShader{nullptr}; // weak reference + + AntiAliasing _antiAliasing{AntiAliasing::NONE}; +}; + +} // namespace pipeline +} // namespace cc diff --git a/native/cocos/renderer/pipeline/deferred/GbufferStage.cpp b/native/cocos/renderer/pipeline/deferred/GbufferStage.cpp index b9f0812a6e..03cf265343 100644 --- a/native/cocos/renderer/pipeline/deferred/GbufferStage.cpp +++ b/native/cocos/renderer/pipeline/deferred/GbufferStage.cpp @@ -79,7 +79,7 @@ void GbufferStage::activate(RenderPipeline *pipeline, RenderFlow *flow) { void GbufferStage::destroy() { CC_SAFE_DELETE(_batchedQueue); CC_SAFE_DELETE(_instancedQueue); - CC_SAFE_DESTROY(_planarShadowQueue); + CC_SAFE_DESTROY_AND_DELETE(_planarShadowQueue); RenderStage::destroy(); } @@ -146,8 +146,8 @@ void GbufferStage::render(scene::Camera *camera) { framegraph::TextureHandle depth; }; - auto *pipeline = static_cast(_pipeline); - float shadingScale{_pipeline->getPipelineSceneData()->getSharedData()->shadingScale}; + auto *pipeline = static_cast(_pipeline); + float shadingScale{_pipeline->getPipelineSceneData()->getShadingScale()}; _renderArea = RenderPipeline::getRenderArea(camera); auto gbufferSetup = [&](framegraph::PassNodeBuilder &builder, RenderData &data) { @@ -158,15 +158,15 @@ void GbufferStage::render(scene::Camera *camera) { gfx::TextureType::TEX2D, gfx::TextureUsageBit::COLOR_ATTACHMENT | gfx::TextureUsageBit::INPUT_ATTACHMENT, gfx::Format::RGBA8, - static_cast(pipeline->getWidth() * shadingScale), - static_cast(pipeline->getHeight() * shadingScale), + static_cast(static_cast(pipeline->getWidth()) * shadingScale), + static_cast(static_cast(pipeline->getHeight()) * shadingScale), }; gfx::TextureInfo gbufferInfoFloat = { gfx::TextureType::TEX2D, gfx::TextureUsageBit::COLOR_ATTACHMENT | gfx::TextureUsageBit::INPUT_ATTACHMENT, gfx::Format::RGBA16F, - static_cast(pipeline->getWidth() * shadingScale), - static_cast(pipeline->getHeight() * shadingScale), + static_cast(static_cast(pipeline->getWidth()) * shadingScale), + static_cast(static_cast(pipeline->getHeight()) * shadingScale), }; for (int i = 0; i < DeferredPipeline::GBUFFER_COUNT - 1; ++i) { if (i != 0) { // positions & normals need more precision @@ -202,16 +202,16 @@ void GbufferStage::render(scene::Camera *camera) { gfx::TextureType::TEX2D, gfx::TextureUsageBit::DEPTH_STENCIL_ATTACHMENT | gfx::TextureUsageBit::SAMPLED, gfx::Format::DEPTH_STENCIL, - static_cast(pipeline->getWidth() * shadingScale), - static_cast(pipeline->getHeight() * shadingScale), + static_cast(static_cast(pipeline->getWidth()) * shadingScale), + static_cast(static_cast(pipeline->getHeight()) * shadingScale), }; data.depth = builder.create(DeferredPipeline::fgStrHandleOutDepthTexture, depthTexInfo); framegraph::RenderTargetAttachment::Descriptor depthInfo; depthInfo.usage = framegraph::RenderTargetAttachment::Usage::DEPTH_STENCIL; depthInfo.loadOp = gfx::LoadOp::CLEAR; - depthInfo.clearDepth = camera->clearDepth; - depthInfo.clearStencil = camera->clearStencil; + depthInfo.clearDepth = camera->getClearDepth(); + depthInfo.clearStencil = camera->getClearStencil(); depthInfo.endAccesses = {gfx::AccessType::DEPTH_STENCIL_ATTACHMENT_WRITE}; data.depth = builder.write(data.depth, depthInfo); builder.writeToBlackboard(DeferredPipeline::fgStrHandleOutDepthTexture, data.depth); diff --git a/native/cocos/renderer/pipeline/deferred/GbufferStage.h b/native/cocos/renderer/pipeline/deferred/GbufferStage.h index 834946e8f3..3d28b333d0 100644 --- a/native/cocos/renderer/pipeline/deferred/GbufferStage.h +++ b/native/cocos/renderer/pipeline/deferred/GbufferStage.h @@ -30,7 +30,7 @@ namespace cc { namespace scene { -struct Camera; +class Camera; } namespace pipeline { @@ -63,7 +63,7 @@ private: PlanarShadowQueue * _planarShadowQueue = nullptr; RenderBatchedQueue * _batchedQueue = nullptr; RenderInstancedQueue * _instancedQueue = nullptr; - uint _phaseID = 0; + uint _phaseID = 0; }; } // namespace pipeline diff --git a/native/cocos/renderer/pipeline/deferred/LightingStage.cpp b/native/cocos/renderer/pipeline/deferred/LightingStage.cpp index 7f0ba2a345..7d29e85461 100644 --- a/native/cocos/renderer/pipeline/deferred/LightingStage.cpp +++ b/native/cocos/renderer/pipeline/deferred/LightingStage.cpp @@ -34,6 +34,7 @@ #include "../RenderInstancedQueue.h" #include "../RenderQueue.h" #include "DeferredPipeline.h" +#include "DeferredPipelineSceneData.h" #include "base/Utils.h" #include "frame-graph/Blackboard.h" #include "frame-graph/Handle.h" @@ -44,8 +45,8 @@ #include "gfx-base/GFXQueue.h" #include "pipeline/Define.h" #include "scene/RenderScene.h" -#include "scene/Sphere.h" #include "scene/SphereLight.h" +#include "scene/SpotLight.h" namespace cc { namespace pipeline { @@ -96,8 +97,8 @@ const RenderStageInfo &LightingStage::getInitializeInfo() { return LightingStage LightingStage::LightingStage() = default; LightingStage::~LightingStage() { - CC_SAFE_DESTROY(_deferredLitsBufs); - CC_SAFE_DESTROY(_deferredLitsBufView); + CC_SAFE_DESTROY_AND_DELETE(_deferredLitsBufs); + CC_SAFE_DESTROY_AND_DELETE(_deferredLitsBufView); } bool LightingStage::initialize(const RenderStageInfo &info) { @@ -111,22 +112,21 @@ bool LightingStage::initialize(const RenderStageInfo &info) { } void LightingStage::gatherLights(scene::Camera *camera) { - auto * pipeline = static_cast(_pipeline); - auto *const sceneData = _pipeline->getPipelineSceneData(); - auto *const sharedData = sceneData->getSharedData(); + auto * pipeline = static_cast(_pipeline); + auto *const sceneData = _pipeline->getPipelineSceneData(); gfx::CommandBuffer *cmdBuf = pipeline->getCommandBuffers()[0]; - const auto * scene = camera->scene; + const auto * scene = camera->getScene(); - scene::Sphere sphere; - auto exposure = camera->exposure; - uint idx = 0; - int elementLen = sizeof(cc::Vec4) / sizeof(float); - uint fieldLen = elementLen * _maxDeferredLights; - uint offset = 0; - cc::Vec4 tmpArray; + geometry::Sphere sphere; + auto exposure = camera->getExposure(); + uint idx = 0; + int elementLen = sizeof(cc::Vec4) / sizeof(float); + uint fieldLen = elementLen * _maxDeferredLights; + uint offset = 0; + cc::Vec4 tmpArray; - for (auto *light : scene->getSphereLights()) { + for (const auto &light : scene->getSphereLights()) { if (idx >= _maxDeferredLights) { break; } @@ -134,7 +134,7 @@ void LightingStage::gatherLights(scene::Camera *camera) { const auto &position = light->getPosition(); sphere.setCenter(position); sphere.setRadius(light->getRange()); - if (!sphere.sphereFrustum(camera->frustum)) { + if (!sphere.sphereFrustum(camera->getFrustum())) { continue; } // position @@ -148,14 +148,14 @@ void LightingStage::gatherLights(scene::Camera *camera) { const auto &color = light->getColor(); offset = idx * elementLen + fieldLen; tmpArray.set(color.x, color.y, color.z, 0); - if (light->getUseColorTemperature()) { + if (light->isUseColorTemperature()) { const auto &colorTemperatureRGB = light->getColorTemperatureRGB(); tmpArray.x *= colorTemperatureRGB.x; tmpArray.y *= colorTemperatureRGB.y; tmpArray.z *= colorTemperatureRGB.z; } - if (sharedData->isHDR) { + if (sceneData->isHDR()) { tmpArray.w = light->getLuminanceHDR() * exposure * _lightMeterScale; } else { tmpArray.w = light->getLuminanceLDR(); @@ -175,7 +175,7 @@ void LightingStage::gatherLights(scene::Camera *camera) { ++idx; } - for (auto *light : scene->getSpotLights()) { + for (const auto &light : scene->getSpotLights()) { if (idx >= _maxDeferredLights) { break; } @@ -183,7 +183,7 @@ void LightingStage::gatherLights(scene::Camera *camera) { const auto &position = light->getPosition(); sphere.setCenter(position); sphere.setRadius(light->getRange()); - if (!sphere.sphereFrustum(camera->frustum)) { + if (!sphere.sphereFrustum(camera->getFrustum())) { continue; } // position @@ -197,14 +197,14 @@ void LightingStage::gatherLights(scene::Camera *camera) { offset = idx * elementLen + fieldLen; const auto &color = light->getColor(); tmpArray.set(color.x, color.y, color.z, 0); - if (light->getUseColorTemperature()) { + if (light->isUseColorTemperature()) { const auto &colorTemperatureRGB = light->getColorTemperatureRGB(); tmpArray.x *= colorTemperatureRGB.x; tmpArray.y *= colorTemperatureRGB.y; tmpArray.z *= colorTemperatureRGB.z; } - if (sharedData->isHDR) { + if (sceneData->isHDR()) { tmpArray.w = light->getLuminanceHDR() * exposure * _lightMeterScale; } else { tmpArray.w = light->getLuminanceLDR(); @@ -276,7 +276,7 @@ void LightingStage::activate(RenderPipeline *pipeline, RenderFlow *flow) { } // not use cluster shading, go normal deferred render path - if (!pipeline->getClusterEnabled()) { + if (!pipeline->isClusterEnabled()) { // create descriptor set/layout gfx::DescriptorSetLayoutInfo layoutInfo = {localDescriptorSetLayout.bindings}; _descLayout = device->createDescriptorSetLayout(layoutInfo); @@ -301,9 +301,9 @@ void LightingStage::activate(RenderPipeline *pipeline, RenderFlow *flow) { } void LightingStage::destroy() { - CC_SAFE_DESTROY(_descriptorSet); - CC_SAFE_DESTROY(_descLayout); - CC_SAFE_DESTROY(_planarShadowQueue); + CC_SAFE_DESTROY_AND_DELETE(_descriptorSet); + CC_SAFE_DESTROY_AND_DELETE(_descLayout); + CC_SAFE_DESTROY_AND_DELETE(_planarShadowQueue); CC_SAFE_DELETE(_reflectionRenderQueue); RenderStage::destroy(); @@ -313,7 +313,7 @@ void LightingStage::destroy() { void LightingStage::fgLightingPass(scene::Camera *camera) { // lights info and ubo are updated in ClusterLightCulling::update() // if using cluster lighting. - if (!_pipeline->getClusterEnabled()) { + if (!_pipeline->isClusterEnabled()) { // lighting info, ubo gatherLights(camera); _descriptorSet->update(); @@ -330,7 +330,7 @@ void LightingStage::fgLightingPass(scene::Camera *camera) { auto * pipeline = static_cast(_pipeline); gfx::Color clearColor = pipeline->getClearcolor(camera); - float shadingScale{_pipeline->getPipelineSceneData()->getSharedData()->shadingScale}; + float shadingScale{_pipeline->getPipelineSceneData()->getShadingScale()}; _renderArea = RenderPipeline::getRenderArea(camera); _inputAssembler = pipeline->getIAByRenderArea(_renderArea); _planarShadowQueue->gatherShadowPasses(camera, pipeline->getCommandBuffers()[0]); @@ -354,7 +354,7 @@ void LightingStage::fgLightingPass(scene::Camera *camera) { data.depth = builder.write(data.depth, depthAttachmentInfo); builder.writeToBlackboard(RenderPipeline::fgStrHandleOutDepthTexture, data.depth); - if (_pipeline->getClusterEnabled()) { + if (_pipeline->isClusterEnabled()) { // read cluster and light info data.lightBuffer = framegraph::BufferHandle(builder.readFromBlackboard(fgStrHandleClusterLightBuffer)); builder.read(data.lightBuffer); @@ -368,8 +368,8 @@ void LightingStage::fgLightingPass(scene::Camera *camera) { framegraph::Texture::Descriptor colorTexInfo; colorTexInfo.format = gfx::Format::RGBA16F; colorTexInfo.usage = gfx::TextureUsageBit::COLOR_ATTACHMENT | gfx::TextureUsageBit::SAMPLED; - colorTexInfo.width = static_cast(pipeline->getWidth() * shadingScale); - colorTexInfo.height = static_cast(pipeline->getHeight() * shadingScale); + colorTexInfo.width = static_cast(static_cast(pipeline->getWidth()) * shadingScale); + colorTexInfo.height = static_cast(static_cast(pipeline->getHeight()) * shadingScale); data.outputTex = builder.create(RenderPipeline::fgStrHandleOutColorTexture, colorTexInfo); framegraph::RenderTargetAttachment::Descriptor colorAttachmentInfo; @@ -386,12 +386,12 @@ void LightingStage::fgLightingPass(scene::Camera *camera) { auto lightingExec = [this, camera](RenderData const &data, const framegraph::DevicePassResourceTable &table) { auto * pipeline = static_cast(_pipeline); - auto *const sceneData = pipeline->getPipelineSceneData(); + auto *const sceneData = static_cast(pipeline->getPipelineSceneData()); auto *cmdBuff = pipeline->getCommandBuffers()[0]; // no need to bind localSet in cluster - if (!_pipeline->getClusterEnabled()) { + if (!_pipeline->isClusterEnabled()) { vector dynamicOffsets = {0}; cmdBuff->bindDescriptorSet(localSet, _descriptorSet, dynamicOffsets); } @@ -399,8 +399,8 @@ void LightingStage::fgLightingPass(scene::Camera *camera) { const std::array globalOffsets = {_pipeline->getPipelineUBO()->getCurrentCameraUBOOffset()}; cmdBuff->bindDescriptorSet(globalSet, pipeline->getDescriptorSet(), utils::toUint(globalOffsets.size()), globalOffsets.data()); // get PSO and draw quad - scene::Pass * pass = sceneData->getSharedData()->deferredLightPass; - gfx::Shader * shader = sceneData->getSharedData()->deferredLightPassShader; + scene::Pass * pass = sceneData->getLightPass(); + gfx::Shader * shader = sceneData->getLightPassShader(); gfx::PipelineState *pso = PipelineStateManager::getOrCreatePipelineState(pass, shader, _inputAssembler, table.getRenderPass(), table.getSubpassIndex()); for (uint i = 0; i < DeferredPipeline::GBUFFER_COUNT; ++i) { @@ -408,7 +408,7 @@ void LightingStage::fgLightingPass(scene::Camera *camera) { pass->getDescriptorSet()->bindSampler(i, _defaultSampler); } - if (_pipeline->getClusterEnabled()) { + if (_pipeline->isClusterEnabled()) { // cluster buffer bind pass->getDescriptorSet()->bindBuffer(CLUSTER_LIGHT_BINDING, table.getRead(data.lightBuffer)); pass->getDescriptorSet()->bindBuffer(CLUSTER_LIGHT_INDEX_BINDING, table.getRead(data.lightIndexBuffer)); @@ -436,7 +436,7 @@ void LightingStage::fgTransparent(scene::Camera *camera) { auto * pipeline = static_cast(_pipeline); gfx::Color clearColor = pipeline->getClearcolor(camera); - float shadingScale{_pipeline->getPipelineSceneData()->getSharedData()->shadingScale}; + float shadingScale{_pipeline->getPipelineSceneData()->getShadingScale()}; auto transparentSetup = [&](framegraph::PassNodeBuilder &builder, RenderData &data) { // write to lighting output framegraph::RenderTargetAttachment::Descriptor colorAttachmentInfo; @@ -451,8 +451,8 @@ void LightingStage::fgTransparent(scene::Camera *camera) { framegraph::Texture::Descriptor colorTexInfo; colorTexInfo.format = gfx::Format::RGBA16F; colorTexInfo.usage = gfx::TextureUsageBit::COLOR_ATTACHMENT | gfx::TextureUsageBit::SAMPLED; - colorTexInfo.width = static_cast(pipeline->getWidth() * shadingScale); - colorTexInfo.height = static_cast(pipeline->getHeight() * shadingScale); + colorTexInfo.width = static_cast(static_cast(pipeline->getWidth()) * shadingScale); + colorTexInfo.height = static_cast(static_cast(pipeline->getHeight()) * shadingScale); colorAttachmentInfo.loadOp = gfx::LoadOp::CLEAR; colorAttachmentInfo.clearColor = clearColor; @@ -475,8 +475,8 @@ void LightingStage::fgTransparent(scene::Camera *camera) { gfx::TextureType::TEX2D, gfx::TextureUsageBit::DEPTH_STENCIL_ATTACHMENT, gfx::Format::DEPTH_STENCIL, - static_cast(pipeline->getWidth() * shadingScale), - static_cast(pipeline->getHeight() * shadingScale), + static_cast(static_cast(pipeline->getWidth()) * shadingScale), + static_cast(static_cast(pipeline->getHeight()) * shadingScale), }; data.depth = builder.create(DeferredPipeline::fgStrHandleOutDepthTexture, depthTexInfo); depthAttachmentInfo.loadOp = gfx::LoadOp::CLEAR; @@ -528,9 +528,9 @@ void LightingStage::putTransparentObj2Queue() { for (auto ro : renderObjects) { m = 0; const auto *const model = ro.model; - for (auto *subModel : model->getSubModels()) { + for (const auto &subModel : model->getSubModels()) { p = 0; - for (auto *pass : subModel->getPasses()) { + for (const auto &pass : subModel->getPasses()) { // TODO(xwx): need to fallback unlit and gizmo material. if (pass->getPhase() != _phaseID) continue; for (k = 0; k < _renderQueues.size(); k++) { @@ -558,7 +558,7 @@ void LightingStage::fgSsprPass(scene::Camera *camera) { auto *pipeline = static_cast(_pipeline); _denoiseIndex = 0; - _matViewProj = camera->matViewProj; + _matViewProj = camera->getMatViewProj(); _reflectionElems.clear(); // step 1 prepare clear model's reflection texture pass. should switch to image clear command after available @@ -649,8 +649,8 @@ void LightingStage::fgSsprPass(scene::Camera *camera) { gfx::Viewport vp = pipeline->getViewport(camera); Vec4 value = Vec4(static_cast(vp.left), static_cast(vp.top), static_cast(vp.width), static_cast(vp.height)); - _reflectionComp->applyTexSize(_ssprTexWidth, _ssprTexHeight, camera->matView, camera->matViewProj, - camera->matViewProjInv, camera->matProjInv, value); + _reflectionComp->applyTexSize(_ssprTexWidth, _ssprTexHeight, camera->getMatView(), camera->getMatViewProj(), + camera->getMatViewProjInv(), camera->getMatProjInv(), value); auto *texReflection = static_cast(table.getWrite(data.reflection)); auto *texLightingOut = static_cast(table.getRead(data.lightingOut)); @@ -748,7 +748,7 @@ void LightingStage::fgSsprPass(scene::Camera *camera) { cmdBuff->bindPipelineState(const_cast(_reflectionComp->getDenoisePipelineState(useEnvmap))); cmdBuff->bindDescriptorSet(globalSet, const_cast(_reflectionComp->getDenoiseDescriptorSet())); cmdBuff->bindDescriptorSet(materialSet, elem.set); - cmdBuff->dispatch(_reflectionComp->getDenioseDispatchInfo()); + cmdBuff->dispatch(_reflectionComp->getDenoiseDispatchInfo()); // pipeline barrier // dispatch -> fragment @@ -830,7 +830,7 @@ void LightingStage::fgSsprPass(scene::Camera *camera) { const auto &passes = subModel->getPasses(); auto passCount = passes.size(); for (p = 0; p < passCount; ++p) { - auto *pass = passes[p]; + const auto &pass = passes[p]; if (pass->getPhase() == _reflectionPhaseID) { RenderElem elem = {ro, subModel->getDescriptorSet(), m, p}; _reflectionElems.push_back(elem); diff --git a/native/cocos/renderer/pipeline/deferred/PostProcessStage.cpp b/native/cocos/renderer/pipeline/deferred/PostProcessStage.cpp index ad09bc27e6..a3e4dcab7b 100644 --- a/native/cocos/renderer/pipeline/deferred/PostProcessStage.cpp +++ b/native/cocos/renderer/pipeline/deferred/PostProcessStage.cpp @@ -24,11 +24,7 @@ THE SOFTWARE. ****************************************************************************/ -#include "PostProcessStage.h" -#include "../PipelineStateManager.h" -#include "../RenderPipeline.h" -#include "../RenderQueue.h" -#include "pipeline/UIPhase.h" +#include "renderer/pipeline/deferred/PostProcessStage.h" #include "frame-graph/DevicePass.h" #include "frame-graph/PassNodeBuilder.h" #include "frame-graph/Resource.h" @@ -37,6 +33,12 @@ #include "gfx-base/GFXFramebuffer.h" #include "pipeline/Define.h" #include "pipeline/helper/Utils.h" +#include "renderer/pipeline/PipelineStateManager.h" +#include "renderer/pipeline/RenderPipeline.h" +#include "renderer/pipeline/RenderQueue.h" +#include "renderer/pipeline/UIPhase.h" +#include "renderer/pipeline/deferred/DeferredPipelineSceneData.h" +#include "scene/RenderWindow.h" #include "scene/SubModel.h" namespace cc { @@ -103,18 +105,18 @@ void PostProcessStage::render(scene::Camera *camera) { framegraph::TextureHandle depth; }; - if (hasFlag(static_cast(camera->clearFlag), gfx::ClearFlagBit::COLOR)) { - _clearColors[0].x = camera->clearColor.x; - _clearColors[0].y = camera->clearColor.y; - _clearColors[0].z = camera->clearColor.z; + if (hasFlag(static_cast(camera->getClearFlag()), gfx::ClearFlagBit::COLOR)) { + _clearColors[0].x = camera->getClearColor().x; + _clearColors[0].y = camera->getClearColor().y; + _clearColors[0].z = camera->getClearColor().z; } - _clearColors[0].w = camera->clearColor.w; + _clearColors[0].w = camera->getClearColor().w; _renderArea = RenderPipeline::getRenderArea(camera); _inputAssembler = _pipeline->getIAByRenderArea(_renderArea); - auto *pipeline = _pipeline; - float shadingScale{_pipeline->getPipelineSceneData()->getSharedData()->shadingScale}; + auto *pipeline = _pipeline; + float shadingScale{_pipeline->getPipelineSceneData()->getShadingScale()}; auto postSetup = [&](framegraph::PassNodeBuilder &builder, RenderData &data) { - if (pipeline->getBloomEnabled()) { + if (pipeline->isBloomEnabled()) { data.outColorTex = framegraph::TextureHandle(builder.readFromBlackboard(RenderPipeline::fgStrHandleBloomOutTexture)); } else { data.outColorTex = framegraph::TextureHandle(builder.readFromBlackboard(RenderPipeline::fgStrHandleOutColorTexture)); @@ -124,8 +126,8 @@ void PostProcessStage::render(scene::Camera *camera) { framegraph::Texture::Descriptor colorTexInfo; colorTexInfo.format = gfx::Format::RGBA16F; colorTexInfo.usage = gfx::TextureUsageBit::COLOR_ATTACHMENT | gfx::TextureUsageBit::SAMPLED; - colorTexInfo.width = static_cast(pipeline->getWidth() * shadingScale); - colorTexInfo.height = static_cast(pipeline->getHeight() * shadingScale); + colorTexInfo.width = static_cast(static_cast(pipeline->getWidth()) * shadingScale); + colorTexInfo.height = static_cast(static_cast(pipeline->getHeight()) * shadingScale); data.outColorTex = builder.create(RenderPipeline::fgStrHandleOutColorTexture, colorTexInfo); } @@ -138,7 +140,7 @@ void PostProcessStage::render(scene::Camera *camera) { colorAttachmentInfo.clearColor = _clearColors[0]; colorAttachmentInfo.loadOp = gfx::LoadOp::CLEAR; - auto clearFlags = static_cast(camera->clearFlag); + auto clearFlags = static_cast(camera->getClearFlag()); if (!hasFlag(clearFlags, gfx::ClearFlagBit::COLOR)) { if (hasFlag(clearFlags, static_cast(skyboxFlag))) { colorAttachmentInfo.loadOp = gfx::LoadOp::DISCARD; @@ -147,7 +149,7 @@ void PostProcessStage::render(scene::Camera *camera) { } } - gfx::AccessType accessType{camera->window->swapchain ? gfx::AccessType::COLOR_ATTACHMENT_WRITE : gfx::AccessType::FRAGMENT_SHADER_READ_TEXTURE}; + gfx::AccessType accessType{camera->getWindow()->getSwapchain() ? gfx::AccessType::COLOR_ATTACHMENT_WRITE : gfx::AccessType::FRAGMENT_SHADER_READ_TEXTURE}; colorAttachmentInfo.beginAccesses.push_back(accessType); colorAttachmentInfo.endAccesses.push_back(accessType); @@ -155,8 +157,8 @@ void PostProcessStage::render(scene::Camera *camera) { gfx::TextureType::TEX2D, gfx::TextureUsageBit::COLOR_ATTACHMENT, gfx::Format::RGBA8, - static_cast(camera->window->getWidth() * shadingScale), - static_cast(camera->window->getHeight() * shadingScale), + static_cast(static_cast(camera->getWindow()->getWidth()) * shadingScale), + static_cast(static_cast(camera->getWindow()->getHeight()) * shadingScale), }; if (shadingScale != 1.F) { textureInfo.usage |= gfx::TextureUsageBit::TRANSFER_SRC; @@ -178,8 +180,8 @@ void PostProcessStage::render(scene::Camera *camera) { gfx::TextureType::TEX2D, gfx::TextureUsageBit::DEPTH_STENCIL_ATTACHMENT, gfx::Format::DEPTH_STENCIL, - static_cast(pipeline->getWidth() * shadingScale), - static_cast(pipeline->getHeight() * shadingScale), + static_cast(static_cast(pipeline->getWidth()) * shadingScale), + static_cast(static_cast(pipeline->getHeight()) * shadingScale), }; data.depth = builder.create(RenderPipeline::fgStrHandleOutDepthTexture, depthTexInfo); } @@ -199,10 +201,10 @@ void PostProcessStage::render(scene::Camera *camera) { if (!pipeline->getPipelineSceneData()->getRenderObjects().empty()) { // post process - auto *const sceneData = pipeline->getPipelineSceneData(); - scene::Pass *pv = sceneData->getSharedData()->pipelinePostPass; - gfx::Shader *sd = sceneData->getSharedData()->pipelinePostPassShader; - float shadingScale{sceneData->getSharedData()->shadingScale}; + auto *const sceneData = static_cast(pipeline->getPipelineSceneData()); + scene::Pass *pv = sceneData->getPostPass(); + gfx::Shader *sd = sceneData->getPostPassShader(); + float shadingScale{sceneData->getShadingScale()}; // get pso and draw quad gfx::PipelineState * pso = PipelineStateManager::getOrCreatePipelineState(pv, sd, _inputAssembler, renderPass); pipeline::GlobalDSManager *globalDS = pipeline->getGlobalDSManager(); @@ -224,7 +226,7 @@ void PostProcessStage::render(scene::Camera *camera) { // add pass pipeline->getFrameGraph().addPass(static_cast(CommonInsertPoint::DIP_POSTPROCESS), RenderPipeline::fgStrHandlePostprocessPass, postSetup, postExec); - pipeline->getFrameGraph().presentFromBlackboard(fgStrHandlePostProcessOutTexture, camera->window->frameBuffer->getColorTextures()[0], shadingScale == 1.F); + pipeline->getFrameGraph().presentFromBlackboard(fgStrHandlePostProcessOutTexture, camera->getWindow()->getFramebuffer()->getColorTextures()[0], shadingScale == 1.F); } } // namespace pipeline diff --git a/native/cocos/renderer/pipeline/deferred/ReflectionComp.cpp b/native/cocos/renderer/pipeline/deferred/ReflectionComp.cpp index 5435b3dfa2..4870a7a7c8 100644 --- a/native/cocos/renderer/pipeline/deferred/ReflectionComp.cpp +++ b/native/cocos/renderer/pipeline/deferred/ReflectionComp.cpp @@ -4,26 +4,25 @@ namespace cc { ReflectionComp::~ReflectionComp() { + CC_SAFE_DESTROY_AND_DELETE(_compShader[0]); + CC_SAFE_DESTROY_AND_DELETE(_compShader[1]); + CC_SAFE_DESTROY_AND_DELETE(_compDescriptorSetLayout); + CC_SAFE_DESTROY_AND_DELETE(_compPipelineLayout); + CC_SAFE_DESTROY_AND_DELETE(_compPipelineState[0]); + CC_SAFE_DESTROY_AND_DELETE(_compPipelineState[1]); + CC_SAFE_DESTROY_AND_DELETE(_compDescriptorSet); - CC_SAFE_DESTROY(_compShader[0]); - CC_SAFE_DESTROY(_compShader[1]); - CC_SAFE_DESTROY(_compDescriptorSetLayout); - CC_SAFE_DESTROY(_compPipelineLayout); - CC_SAFE_DESTROY(_compPipelineState[0]); - CC_SAFE_DESTROY(_compPipelineState[1]); - CC_SAFE_DESTROY(_compDescriptorSet); + CC_SAFE_DESTROY_AND_DELETE(_compDenoiseShader[0]); + CC_SAFE_DESTROY_AND_DELETE(_compDenoiseShader[1]); + CC_SAFE_DESTROY_AND_DELETE(_compDenoiseDescriptorSetLayout); + CC_SAFE_DESTROY_AND_DELETE(_compDenoisePipelineLayout); + CC_SAFE_DESTROY_AND_DELETE(_compDenoisePipelineState[0]); + CC_SAFE_DESTROY_AND_DELETE(_compDenoisePipelineState[1]); + CC_SAFE_DESTROY_AND_DELETE(_compDenoiseDescriptorSet); - CC_SAFE_DESTROY(_compDenoiseShader[0]); - CC_SAFE_DESTROY(_compDenoiseShader[1]); - CC_SAFE_DESTROY(_compDenoiseDescriptorSetLayout); - CC_SAFE_DESTROY(_compDenoisePipelineLayout); - CC_SAFE_DESTROY(_compDenoisePipelineState[0]); - CC_SAFE_DESTROY(_compDenoisePipelineState[1]); - CC_SAFE_DESTROY(_compDenoiseDescriptorSet); + CC_SAFE_DESTROY_AND_DELETE(_localDescriptorSetLayout); - CC_SAFE_DESTROY(_localDescriptorSetLayout); - - CC_SAFE_DESTROY(_compConstantsBuffer); + CC_SAFE_DESTROY_AND_DELETE(_compConstantsBuffer); } namespace { @@ -32,15 +31,15 @@ struct ConstantBuffer { Mat4 matProjInv; Mat4 matViewProj; Mat4 matViewProjInv; - Vec4 viewPort; // viewport of lighting pass - Vec2 texSize; // texture size of reflect texture + Vec4 viewPort; // viewport of lighting pass + Vec2 texSize; // texture size of reflect texture }; } // namespace void ReflectionComp::applyTexSize(uint width, uint height, const Mat4 &matView, - const Mat4& matViewProj, const Mat4& matViewProjInv, - const Mat4& matProjInv, const Vec4 &viewPort) { + const Mat4 &matViewProj, const Mat4 &matViewProjInv, + const Mat4 &matProjInv, const Vec4 &viewPort) { uint globalWidth = width; uint globalHeight = height; uint groupWidth = this->getGroupSizeX(); @@ -50,13 +49,13 @@ void ReflectionComp::applyTexSize(uint width, uint height, const Mat4 &matView, _denoiseDispatchInfo = {((globalWidth - 1) / 2) / groupWidth + 1, ((globalHeight - 1) / 2) / groupHeight + 1, 1}; ConstantBuffer constants; - constants.matView = matView; - constants.matProjInv = matProjInv; - constants.matViewProj = matViewProj; - constants.matViewProjInv = matViewProjInv; - constants.viewPort = viewPort; - constants.texSize = {float(width), float(height)}; - constants.viewPort = viewPort; + constants.matView = matView; + constants.matProjInv = matProjInv; + constants.matViewProj = matViewProj; + constants.matViewProjInv = matViewProjInv; + constants.viewPort = viewPort; + constants.texSize = {float(width), float(height)}; + constants.viewPort = viewPort; if (_compConstantsBuffer) { _compConstantsBuffer->update(&constants, sizeof(constants)); @@ -66,9 +65,9 @@ void ReflectionComp::applyTexSize(uint width, uint height, const Mat4 &matView, void ReflectionComp::init(gfx::Device *dev, uint groupSizeX, uint groupSizeY) { if (!dev->hasFeature(gfx::Feature::COMPUTE_SHADER)) return; - _device = dev; - _groupSizeX = groupSizeX; - _groupSizeY = groupSizeY; + _device = dev; + _groupSizeX = groupSizeX; + _groupSizeY = groupSizeY; gfx::SamplerInfo samplerInfo; samplerInfo.minFilter = gfx::Filter::POINT; @@ -119,7 +118,6 @@ void ReflectionComp::init(gfx::Device *dev, uint groupSizeX, uint groupSizeY) { _barrierBeforeDenoise.push_back(_device->getTextureBarrier(infoBeforeDenoise2)); _barrierAfterDenoise.push_back(_device->getTextureBarrier(infoAfterDenoise)); - _compConstantsBuffer = _device->createBuffer({gfx::BufferUsage::UNIFORM, gfx::MemoryUsage::DEVICE | gfx::MemoryUsage::HOST, (sizeof(Mat4) * 4 + sizeof(Vec2) + sizeof(Vec4) + 15) / 16 * 16}); @@ -277,13 +275,14 @@ void ReflectionComp::initReflectionRes() { shaderInfo.stages = {{gfx::ShaderStageFlagBit::COMPUTE, getAppropriateShaderSource(sources)}}; shaderInfo.blocks = { {0, 0, "Constants", { - {"matView", gfx::Type::MAT4, 1}, - {"matProjInv", gfx::Type::MAT4, 1}, - {"matViewProj", gfx::Type::MAT4, 1}, - {"matViewProjInv", gfx::Type::MAT4, 1}, - {"viewPort", gfx::Type::FLOAT4, 1}, - {"texSize", gfx::Type::FLOAT2, 1}, - }, 1}, + {"matView", gfx::Type::MAT4, 1}, + {"matProjInv", gfx::Type::MAT4, 1}, + {"matViewProj", gfx::Type::MAT4, 1}, + {"matViewProjInv", gfx::Type::MAT4, 1}, + {"viewPort", gfx::Type::FLOAT4, 1}, + {"texSize", gfx::Type::FLOAT2, 1}, + }, + 1}, {0, 4, "CCLocal", {{"cc_matWorld", gfx::Type::MAT4, 1}, {"cc_matWorldIT", gfx::Type::MAT4, 1}, {"cc_lightingMapUVParam", gfx::Type::FLOAT4, 1}}, 1}}; shaderInfo.samplerTextures = { {0, 1, "lightingTex", gfx::Type::SAMPLER2D, 1}, @@ -296,7 +295,7 @@ void ReflectionComp::initReflectionRes() { gfx::DescriptorSetLayoutInfo dslInfo; dslInfo.bindings.push_back({0, gfx::DescriptorType::UNIFORM_BUFFER, 1, gfx::ShaderStageFlagBit::COMPUTE}); dslInfo.bindings.push_back({1, gfx::DescriptorType::SAMPLER_TEXTURE, 1, gfx::ShaderStageFlagBit::COMPUTE}); - dslInfo.bindings.push_back({2, gfx::DescriptorType::SAMPLER_TEXTURE, 1, gfx::ShaderStageFlagBit::COMPUTE }); + dslInfo.bindings.push_back({2, gfx::DescriptorType::SAMPLER_TEXTURE, 1, gfx::ShaderStageFlagBit::COMPUTE}); dslInfo.bindings.push_back({3, gfx::DescriptorType::STORAGE_IMAGE, 1, gfx::ShaderStageFlagBit::COMPUTE}); dslInfo.bindings.push_back({4, gfx::DescriptorType::UNIFORM_BUFFER, 1, gfx::ShaderStageFlagBit::COMPUTE}); @@ -511,8 +510,8 @@ void ReflectionComp::initDenoiseRes() { getDenoiseShader(sources, i); gfx::ShaderInfo shaderInfo; - shaderInfo.name = "Compute "; - shaderInfo.stages = {{gfx::ShaderStageFlagBit::COMPUTE, getAppropriateShaderSource(sources)}}; + shaderInfo.name = "Compute "; + shaderInfo.stages = {{gfx::ShaderStageFlagBit::COMPUTE, getAppropriateShaderSource(sources)}}; if (i == 0) { shaderInfo.blocks = {}; @@ -521,14 +520,15 @@ void ReflectionComp::initDenoiseRes() { } else { shaderInfo.blocks = { {0, 0, "Constants", { - {"matView", gfx::Type::MAT4, 1}, - {"matProjInv", gfx::Type::MAT4, 1}, - {"matViewProj", gfx::Type::MAT4, 1}, - {"matViewProjInv", gfx::Type::MAT4, 1}, - {"viewPort", gfx::Type::FLOAT4, 1}, - {"texSize", gfx::Type::FLOAT2, 1}, - }, 1}, - }; + {"matView", gfx::Type::MAT4, 1}, + {"matProjInv", gfx::Type::MAT4, 1}, + {"matViewProj", gfx::Type::MAT4, 1}, + {"matViewProjInv", gfx::Type::MAT4, 1}, + {"viewPort", gfx::Type::FLOAT4, 1}, + {"texSize", gfx::Type::FLOAT2, 1}, + }, + 1}, + }; shaderInfo.samplerTextures = { {0, 0, "reflectionTex", gfx::Type::SAMPLER2D, 1}, {0, 1, "envMap", gfx::Type::SAMPLER_CUBE, 1}, @@ -549,7 +549,7 @@ void ReflectionComp::initDenoiseRes() { dslInfo.bindings.push_back({4, gfx::DescriptorType::UNIFORM_BUFFER, 1, gfx::ShaderStageFlagBit::COMPUTE}); _compDenoiseDescriptorSetLayout = _device->createDescriptorSetLayout(dslInfo); _compDenoisePipelineLayout = _device->createPipelineLayout({{_compDenoiseDescriptorSetLayout, _localDescriptorSetLayout}}); - _compDenoiseDescriptorSet = _device->createDescriptorSet({_compDenoiseDescriptorSetLayout}); + _compDenoiseDescriptorSet = _device->createDescriptorSet({_compDenoiseDescriptorSetLayout}); for (int i = 0; i < 2; ++i) { gfx::PipelineStateInfo pipelineInfo; diff --git a/native/cocos/renderer/pipeline/deferred/ReflectionComp.h b/native/cocos/renderer/pipeline/deferred/ReflectionComp.h index 6808f21fad..b1bb411d84 100644 --- a/native/cocos/renderer/pipeline/deferred/ReflectionComp.h +++ b/native/cocos/renderer/pipeline/deferred/ReflectionComp.h @@ -42,9 +42,9 @@ public: inline const gfx::TextureBarrierList& getBarrierBeforeDenoise() { return _barrierBeforeDenoise; } inline const gfx::TextureBarrierList& getBarrierAfterDenoise() { return _barrierAfterDenoise; } inline const gfx::DispatchInfo& getDispatchInfo() { return _dispatchInfo; } - inline const gfx::DispatchInfo& getDenioseDispatchInfo() { return _denoiseDispatchInfo; } - inline int getGroupSizeX() const { return _groupSizeX; } - inline int getGroupSizeY() const { return _groupSizeY; } + inline const gfx::DispatchInfo& getDenoiseDispatchInfo() { return _denoiseDispatchInfo; } + inline uint getGroupSizeX() const { return _groupSizeX; } + inline uint getGroupSizeY() const { return _groupSizeY; } inline gfx::Buffer* getConstantsBuffer() { return _compConstantsBuffer; } inline gfx::Sampler* getSampler() { return _sampler; } diff --git a/native/cocos/renderer/pipeline/forward/ForwardPipeline.cpp b/native/cocos/renderer/pipeline/forward/ForwardPipeline.cpp index bb982170c8..95f5e96666 100644 --- a/native/cocos/renderer/pipeline/forward/ForwardPipeline.cpp +++ b/native/cocos/renderer/pipeline/forward/ForwardPipeline.cpp @@ -25,11 +25,11 @@ #include "ForwardPipeline.h" #include "../SceneCulling.h" +#include "../helper/Utils.h" #include "../shadow/ShadowFlow.h" #include "ForwardFlow.h" #include "gfx-base/GFXDevice.h" #include "scene/RenderScene.h" -#include "../helper/Utils.h" namespace cc { namespace pipeline { @@ -45,6 +45,10 @@ namespace { (dst)[(offset) + 3] = (src).w; } // namespace +ForwardPipeline::ForwardPipeline() { + _pipelineSceneData = new PipelineSceneData(); +} + framegraph::StringHandle ForwardPipeline::fgStrHandleForwardColorTexture = framegraph::FrameGraph::stringToHandle("forwardColorTexture"); framegraph::StringHandle ForwardPipeline::fgStrHandleForwardDepthTexture = framegraph::FrameGraph::stringToHandle("forwardDepthTexture"); framegraph::StringHandle ForwardPipeline::fgStrHandleForwardPass = framegraph::FrameGraph::stringToHandle("forwardPass"); @@ -66,7 +70,7 @@ bool ForwardPipeline::initialize(const RenderPipelineInfo &info) { } bool ForwardPipeline::activate(gfx::Swapchain *swapchain) { - _macros.setValue("CC_PIPELINE_TYPE", 0.F); + _macros["CC_PIPELINE_TYPE"] = 0; if (!RenderPipeline::activate(swapchain)) { CC_LOG_ERROR("RenderPipeline active failed."); @@ -83,7 +87,7 @@ bool ForwardPipeline::activate(gfx::Swapchain *swapchain) { void ForwardPipeline::render(const vector &cameras) { auto * device = gfx::Device::getInstance(); - const bool enableOcclusionQuery = getOcclusionQueryEnabled(); + const bool enableOcclusionQuery = isOcclusionQueryEnabled(); if (enableOcclusionQuery) { device->getQueryPoolResults(_queryPools[0]); } @@ -125,7 +129,6 @@ void ForwardPipeline::render(const vector &cameras) { bool ForwardPipeline::activeRenderer(gfx::Swapchain *swapchain) { _commandBuffers.push_back(_device->getCommandBuffer()); _queryPools.push_back(_device->getQueryPool()); - const auto *sharedData = _pipelineSceneData->getSharedData(); gfx::Sampler *const sampler = getGlobalDSManager()->getPointSampler(); @@ -135,8 +138,8 @@ bool ForwardPipeline::activeRenderer(gfx::Swapchain *swapchain) { _descriptorSet->update(); // update global defines when all states initialized. - _macros.setValue("CC_USE_HDR", static_cast(sharedData->isHDR)); - _macros.setValue("CC_SUPPORT_FLOAT_TEXTURE", _device->hasFeature(gfx::Feature::TEXTURE_FLOAT)); + _macros["CC_USE_HDR"] = static_cast(_pipelineSceneData->isHDR()); + _macros["CC_SUPPORT_FLOAT_TEXTURE"] = _device->hasFeature(gfx::Feature::TEXTURE_FLOAT); // step 2 create index buffer uint ibStride = 4; @@ -158,17 +161,17 @@ bool ForwardPipeline::activeRenderer(gfx::Swapchain *swapchain) { return true; } -void ForwardPipeline::destroy() { +bool ForwardPipeline::destroy() { destroyQuadInputAssembler(); for (auto &it : _renderPasses) { - CC_SAFE_DESTROY(it.second); + CC_SAFE_DESTROY_AND_DELETE(it.second); } _renderPasses.clear(); _queryPools.clear(); _commandBuffers.clear(); - RenderPipeline::destroy(); + return RenderPipeline::destroy(); } } // namespace pipeline diff --git a/native/cocos/renderer/pipeline/forward/ForwardPipeline.h b/native/cocos/renderer/pipeline/forward/ForwardPipeline.h index 45e6ca217f..7abdbad228 100644 --- a/native/cocos/renderer/pipeline/forward/ForwardPipeline.h +++ b/native/cocos/renderer/pipeline/forward/ForwardPipeline.h @@ -40,11 +40,11 @@ struct UBOShadow; class CC_DLL ForwardPipeline : public RenderPipeline { public: - ForwardPipeline() = default; + ForwardPipeline(); ~ForwardPipeline() override = default; bool initialize(const RenderPipelineInfo &info) override; - void destroy() override; + bool destroy() override; bool activate(gfx::Swapchain *swapchain) override; void render(const vector &cameras) override; @@ -63,11 +63,11 @@ private: bool activeRenderer(gfx::Swapchain *swapchain); void updateUBO(scene::Camera *); - gfx::Buffer * _lightsUBO = nullptr; - LightList _validLights; - gfx::BufferList _lightBuffers; - UintList _lightIndexOffsets; - UintList _lightIndices; + gfx::Buffer * _lightsUBO = nullptr; + LightList _validLights; + gfx::BufferList _lightBuffers; + UintList _lightIndexOffsets; + UintList _lightIndices; }; } // namespace pipeline diff --git a/native/cocos/renderer/pipeline/forward/ForwardStage.cpp b/native/cocos/renderer/pipeline/forward/ForwardStage.cpp index 4354da14b2..b985c01f1c 100644 --- a/native/cocos/renderer/pipeline/forward/ForwardStage.cpp +++ b/native/cocos/renderer/pipeline/forward/ForwardStage.cpp @@ -37,6 +37,7 @@ #include "gfx-base/GFXCommandBuffer.h" #include "gfx-base/GFXFramebuffer.h" #include "pipeline/UIPhase.h" +#include "scene/RenderWindow.h" namespace cc { namespace pipeline { @@ -99,7 +100,7 @@ void ForwardStage::dispenseRenderObject2Queues() { queue->clear(); } - for (auto ro : renderObjects) { + for (const auto &ro : renderObjects) { const auto *const model = ro.model; const auto & subModels = model->getSubModels(); const auto subModelCount = subModels.size(); @@ -137,11 +138,10 @@ void ForwardStage::render(scene::Camera *camera) { framegraph::TextureHandle outputTex; framegraph::TextureHandle depth; }; - auto * pipeline = static_cast(_pipeline); - auto *const sceneData = _pipeline->getPipelineSceneData(); - auto *const sharedData = sceneData->getSharedData(); + auto * pipeline = static_cast(_pipeline); + auto *const sceneData = _pipeline->getPipelineSceneData(); - float shadingScale{_pipeline->getPipelineSceneData()->getSharedData()->shadingScale}; + float shadingScale{sceneData->getShadingScale()}; _renderArea = RenderPipeline::getRenderArea(camera); // Command 'updateBuffer' must be recorded outside render passes, cannot put them in execute lambda dispenseRenderObject2Queues(); @@ -153,18 +153,18 @@ void ForwardStage::render(scene::Camera *camera) { _additiveLightQueue->gatherLightPasses(camera, cmdBuff); _planarShadowQueue->gatherShadowPasses(camera, cmdBuff); auto forwardSetup = [&](framegraph::PassNodeBuilder &builder, RenderData &data) { - if (hasFlag(static_cast(camera->clearFlag), gfx::ClearFlagBit::COLOR)) { - _clearColors[0].x = camera->clearColor.x; - _clearColors[0].y = camera->clearColor.y; - _clearColors[0].z = camera->clearColor.z; + if (hasFlag(static_cast(camera->getClearFlag()), gfx::ClearFlagBit::COLOR)) { + _clearColors[0].x = camera->getClearColor().x; + _clearColors[0].y = camera->getClearColor().y; + _clearColors[0].z = camera->getClearColor().z; } - _clearColors[0].w = camera->clearColor.w; + _clearColors[0].w = camera->getClearColor().w; // color framegraph::Texture::Descriptor colorTexInfo; - colorTexInfo.format = sharedData->isHDR ? gfx::Format::RGBA16F : gfx::Format::RGBA8; + colorTexInfo.format = sceneData->isHDR() ? gfx::Format::RGBA16F : gfx::Format::RGBA8; colorTexInfo.usage = gfx::TextureUsageBit::COLOR_ATTACHMENT; - colorTexInfo.width = static_cast(pipeline->getWidth() * shadingScale); - colorTexInfo.height = static_cast(pipeline->getHeight() * shadingScale); + colorTexInfo.width = static_cast(static_cast(pipeline->getWidth()) * shadingScale); + colorTexInfo.height = static_cast(static_cast(pipeline->getHeight()) * shadingScale); if (shadingScale != 1.F) { colorTexInfo.usage |= gfx::TextureUsageBit::TRANSFER_SRC; } @@ -173,8 +173,8 @@ void ForwardStage::render(scene::Camera *camera) { colorAttachmentInfo.usage = framegraph::RenderTargetAttachment::Usage::COLOR; colorAttachmentInfo.clearColor = _clearColors[0]; colorAttachmentInfo.loadOp = gfx::LoadOp::CLEAR; - auto clearFlags = static_cast(camera->clearFlag); - bool isSwapchain = !!camera->window->swapchain; + auto clearFlags = static_cast(camera->getClearFlag()); + bool isSwapchain = !!camera->getWindow()->getSwapchain(); if (isSwapchain && !hasFlag(clearFlags, gfx::ClearFlagBit::COLOR)) { if (hasFlag(clearFlags, static_cast(skyboxFlag))) { colorAttachmentInfo.loadOp = gfx::LoadOp::DISCARD; @@ -191,19 +191,18 @@ void ForwardStage::render(scene::Camera *camera) { gfx::TextureType::TEX2D, gfx::TextureUsageBit::DEPTH_STENCIL_ATTACHMENT, gfx::Format::DEPTH_STENCIL, - static_cast(pipeline->getWidth() * shadingScale), - static_cast(pipeline->getHeight() * shadingScale), + static_cast(static_cast(pipeline->getWidth()) * shadingScale), + static_cast(static_cast(pipeline->getHeight()) * shadingScale), }; framegraph::RenderTargetAttachment::Descriptor depthAttachmentInfo; - depthAttachmentInfo.usage = framegraph::RenderTargetAttachment::Usage::DEPTH_STENCIL; - depthAttachmentInfo.loadOp = gfx::LoadOp::CLEAR; - depthAttachmentInfo.clearDepth = camera->clearDepth; - depthAttachmentInfo.clearStencil = camera->clearStencil; - depthAttachmentInfo.beginAccesses = {gfx::AccessType::DEPTH_STENCIL_ATTACHMENT_WRITE}; - depthAttachmentInfo.endAccesses = {gfx::AccessType::DEPTH_STENCIL_ATTACHMENT_WRITE}; - if (isSwapchain && static_cast(clearFlags & gfx::ClearFlagBit::DEPTH_STENCIL) != gfx::ClearFlagBit::DEPTH_STENCIL - && (!hasFlag(clearFlags, gfx::ClearFlagBit::DEPTH) || !hasFlag(clearFlags, gfx::ClearFlagBit::STENCIL))) { + depthAttachmentInfo.usage = framegraph::RenderTargetAttachment::Usage::DEPTH_STENCIL; + depthAttachmentInfo.loadOp = gfx::LoadOp::CLEAR; + depthAttachmentInfo.clearDepth = camera->getClearDepth(); + depthAttachmentInfo.clearStencil = camera->getClearStencil(); + depthAttachmentInfo.beginAccesses = {gfx::AccessType::DEPTH_STENCIL_ATTACHMENT_WRITE}; + depthAttachmentInfo.endAccesses = {gfx::AccessType::DEPTH_STENCIL_ATTACHMENT_WRITE}; + if (isSwapchain && static_cast(clearFlags & gfx::ClearFlagBit::DEPTH_STENCIL) != gfx::ClearFlagBit::DEPTH_STENCIL && (!hasFlag(clearFlags, gfx::ClearFlagBit::DEPTH) || !hasFlag(clearFlags, gfx::ClearFlagBit::STENCIL))) { depthAttachmentInfo.loadOp = gfx::LoadOp::LOAD; } data.depth = builder.create(RenderPipeline::fgStrHandleOutDepthTexture, depthTexInfo); @@ -235,7 +234,7 @@ void ForwardStage::render(scene::Camera *camera) { // add pass pipeline->getFrameGraph().addPass(static_cast(ForwardInsertPoint::IP_FORWARD), ForwardPipeline::fgStrHandleForwardPass, forwardSetup, forwardExec); - pipeline->getFrameGraph().presentFromBlackboard(RenderPipeline::fgStrHandleOutColorTexture, camera->window->frameBuffer->getColorTextures()[0], true); + pipeline->getFrameGraph().presentFromBlackboard(RenderPipeline::fgStrHandleOutColorTexture, camera->getWindow()->getFramebuffer()->getColorTextures()[0], true); } } // namespace pipeline diff --git a/native/cocos/renderer/pipeline/helper/Utils.cpp b/native/cocos/renderer/pipeline/helper/Utils.cpp new file mode 100644 index 0000000000..50c871145c --- /dev/null +++ b/native/cocos/renderer/pipeline/helper/Utils.cpp @@ -0,0 +1,74 @@ +/**************************************************************************** + Copyright (c) 2020-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 "renderer/pipeline/helper/Utils.h" +#include "renderer/pipeline/PipelineStateManager.h" + +#include "gfx-base/GFXSwapchain.h" +#include "pipeline/Define.h" +#include "scene/Camera.h" +#include "scene/Model.h" +#include "scene/RenderWindow.h" +#include "scene/SubModel.h" + +namespace cc { +namespace pipeline { + +const scene::Camera *profilerCamera{nullptr}; + +void decideProfilerCamera(const vector &cameras) { + for (int i = static_cast(cameras.size() - 1); i >= 0; --i) { + if (cameras[i]->getWindow()->getSwapchain()) { + profilerCamera = cameras[i]; + return; + } + } + profilerCamera = nullptr; +} + +void renderProfiler(gfx::RenderPass *renderPass, gfx::CommandBuffer *cmdBuff, scene::Model *profiler, const scene::Camera *camera) { + if (profiler && profiler->isEnabled() && camera == profilerCamera) { + const auto &submodel = profiler->getSubModels()[0]; + auto * pass = submodel->getPass(0); + auto * ia = submodel->getInputAssembler(); + auto * pso = PipelineStateManager::getOrCreatePipelineState(pass, submodel->getShader(0), ia, renderPass); + + gfx::Viewport profilerViewport; + gfx::Rect profilerScissor; + profilerViewport.width = profilerScissor.width = camera->getWindow()->getWidth(); + profilerViewport.height = profilerScissor.height = camera->getWindow()->getHeight(); + cmdBuff->setViewport(profilerViewport); + cmdBuff->setScissor(profilerScissor); + + cmdBuff->bindPipelineState(pso); + cmdBuff->bindDescriptorSet(materialSet, pass->getDescriptorSet()); + cmdBuff->bindDescriptorSet(localSet, submodel->getDescriptorSet()); + cmdBuff->bindInputAssembler(ia); + cmdBuff->draw(ia); + } +} + +} // namespace pipeline +} // namespace cc diff --git a/native/cocos/renderer/pipeline/helper/Utils.h b/native/cocos/renderer/pipeline/helper/Utils.h index 1e821c1705..e5c14114a0 100644 --- a/native/cocos/renderer/pipeline/helper/Utils.h +++ b/native/cocos/renderer/pipeline/helper/Utils.h @@ -25,25 +25,41 @@ #pragma once -#include "../PipelineStateManager.h" -#include "gfx-base/GFXCommandBuffer.h" -#include "gfx-base/GFXDef-common.h" #include "gfx-base/GFXDef.h" -#include "gfx-base/GFXSwapchain.h" -#include "pipeline/Define.h" -#include "scene/Model.h" -#include "scene/SubModel.h" -#include "scene/Camera.h" +#include "math/Vec4.h" namespace cc { + +namespace scene { +class Camera; +class Model; +} // namespace scene + +namespace gfx { +class CommandBuffer; +class RenderPass; +} // namespace gfx + namespace pipeline { +inline void srgbToLinear(cc::Vec4 *out, const cc::Vec4 &gamma) { + out->x = gamma.x * gamma.x; + out->y = gamma.y * gamma.y; + out->z = gamma.z * gamma.z; +} + inline void srgbToLinear(gfx::Color *out, const gfx::Color &gamma) { out->x = gamma.x * gamma.x; out->y = gamma.y * gamma.y; out->z = gamma.z * gamma.z; } +inline void linearToSrgb(cc::Vec4 *out, const cc::Vec4 &linear) { + out->x = std::sqrt(linear.x); + out->y = std::sqrt(linear.y); + out->z = std::sqrt(linear.z); +} + inline void linearToSrgb(gfx::Color *out, const gfx::Color &linear) { out->x = std::sqrt(linear.x); out->y = std::sqrt(linear.y); @@ -52,37 +68,8 @@ inline void linearToSrgb(gfx::Color *out, const gfx::Color &linear) { extern const scene::Camera *profilerCamera; -inline void decideProfilerCamera(const vector &cameras) { - for (int i = static_cast(cameras.size() - 1); i >= 0; --i) { - if (cameras[i]->window->swapchain) { - profilerCamera = cameras[i]; - return; - } - } - profilerCamera = nullptr; -} - -inline void renderProfiler(gfx::RenderPass *renderPass, gfx::CommandBuffer *cmdBuff, scene::Model *profiler, const scene::Camera *camera) { - if (profiler && profiler->getEnabled() && camera == profilerCamera) { - auto *submodel = profiler->getSubModels()[0]; - auto *pass = submodel->getPass(0); - auto *ia = submodel->getInputAssembler(); - auto *pso = PipelineStateManager::getOrCreatePipelineState(pass, submodel->getShader(0), ia, renderPass); - - gfx::Viewport profilerViewport; - gfx::Rect profilerScissor; - profilerViewport.width = profilerScissor.width = camera->window->getWidth(); - profilerViewport.height = profilerScissor.height = camera->window->getHeight(); - cmdBuff->setViewport(profilerViewport); - cmdBuff->setScissor(profilerScissor); - - cmdBuff->bindPipelineState(pso); - cmdBuff->bindDescriptorSet(materialSet, pass->getDescriptorSet()); - cmdBuff->bindDescriptorSet(localSet, submodel->getDescriptorSet()); - cmdBuff->bindInputAssembler(ia); - cmdBuff->draw(ia); - } -} +void decideProfilerCamera(const vector &cameras); +void renderProfiler(gfx::RenderPass *renderPass, gfx::CommandBuffer *cmdBuff, scene::Model *profiler, const scene::Camera *camera); } // namespace pipeline } // namespace cc diff --git a/native/cocos/renderer/pipeline/shadow/ShadowFlow.cpp b/native/cocos/renderer/pipeline/shadow/ShadowFlow.cpp index f792175915..13fab257cf 100644 --- a/native/cocos/renderer/pipeline/shadow/ShadowFlow.cpp +++ b/native/cocos/renderer/pipeline/shadow/ShadowFlow.cpp @@ -33,6 +33,7 @@ #include "gfx-base/GFXFramebuffer.h" #include "gfx-base/GFXRenderPass.h" #include "gfx-base/GFXTexture.h" +#include "scene/DirectionalLight.h" #include "scene/RenderScene.h" namespace cc { @@ -65,9 +66,11 @@ void ShadowFlow::activate(RenderPipeline *pipeline) { } void ShadowFlow::render(scene::Camera *camera) { - const auto *sceneData = _pipeline->getPipelineSceneData(); - auto * shadowInfo = sceneData->getSharedData()->shadow; - if (!shadowInfo->enabled || shadowInfo->shadowType != scene::ShadowType::SHADOWMAP) return; + const auto *sceneData = _pipeline->getPipelineSceneData(); + auto * shadows = sceneData->getShadows(); + if (shadows == nullptr || !shadows->isEnabled() || shadows->getType() != scene::ShadowType::SHADOW_MAP) { + return; + } lightCollecting(); @@ -76,12 +79,12 @@ void ShadowFlow::render(scene::Camera *camera) { return; } - if (shadowInfo->shadowMapDirty) { - resizeShadowMap(&shadowInfo); + if (shadows->isShadowMapDirty()) { + resizeShadowMap(); } const auto & shadowFramebufferMap = sceneData->getShadowFramebufferMap(); - const scene::DirectionalLight *mainLight = camera->scene->getMainLight(); + const scene::DirectionalLight *mainLight = camera->getScene()->getMainLight(); if (mainLight) { gfx::DescriptorSet *globalDS = _pipeline->getDescriptorSet(); if (!shadowFramebufferMap.count(mainLight)) { @@ -97,8 +100,8 @@ void ShadowFlow::render(scene::Camera *camera) { } for (uint l = 0; l < _validLights.size(); ++l) { - const scene::Light *light = _validLights[l]; - gfx::DescriptorSet *globalDS = _pipeline->getGlobalDSManager()->getOrCreateDescriptorSet(l); + const scene::Light *light = _validLights[l]; + gfx::DescriptorSet *globalDS = _pipeline->getGlobalDSManager()->getOrCreateDescriptorSet(l); if (!shadowFramebufferMap.count(light)) { initShadowFrameBuffer(_pipeline, light); @@ -117,7 +120,7 @@ void ShadowFlow::render(scene::Camera *camera) { void ShadowFlow::lightCollecting() { _validLights.clear(); - const vector validPunctualLights = _pipeline->getPipelineSceneData()->getValidPunctualLights(); + const vector validPunctualLights = _pipeline->getPipelineSceneData()->getValidPunctualLights(); for (const scene::Light *light : validPunctualLights) { if (light->getType() == scene::LightType::SPOT) { _validLights.emplace_back(light); @@ -128,7 +131,7 @@ void ShadowFlow::lightCollecting() { void ShadowFlow::clearShadowMap(scene::Camera *camera) { const auto * sceneData = _pipeline->getPipelineSceneData(); const auto & shadowFramebufferMap = sceneData->getShadowFramebufferMap(); - const scene::DirectionalLight *mainLight = camera->scene->getMainLight(); + const scene::DirectionalLight *mainLight = camera->getScene()->getMainLight(); if (mainLight) { gfx::DescriptorSet *globalDS = _pipeline->getDescriptorSet(); @@ -145,8 +148,8 @@ void ShadowFlow::clearShadowMap(scene::Camera *camera) { } for (uint l = 0; l < _validLights.size(); ++l) { - const scene::Light *light = _validLights[l]; - gfx::DescriptorSet *globalDS = _pipeline->getGlobalDSManager()->getOrCreateDescriptorSet(l); + const scene::Light *light = _validLights[l]; + gfx::DescriptorSet *globalDS = _pipeline->getGlobalDSManager()->getOrCreateDescriptorSet(l); if (!shadowFramebufferMap.count(light)) { continue; @@ -161,12 +164,13 @@ void ShadowFlow::clearShadowMap(scene::Camera *camera) { } } -void ShadowFlow::resizeShadowMap(scene::Shadow **shadowInfo) { - const auto *sceneData = _pipeline->getPipelineSceneData(); - auto * device = gfx::Device::getInstance(); - const auto width = static_cast((*shadowInfo)->size.x); - const auto height = static_cast((*shadowInfo)->size.y); - const auto format = supportsFloatTexture(device) ? gfx::Format::R32F : gfx::Format::RGBA8; +void ShadowFlow::resizeShadowMap() { + auto * sceneData = _pipeline->getPipelineSceneData(); + auto * shadows = sceneData->getShadows(); + auto * device = gfx::Device::getInstance(); + const auto width = static_cast(shadows->getSize().x); + const auto height = static_cast(shadows->getSize().y); + const auto format = supportsFloatTexture(device) ? gfx::Format::R32F : gfx::Format::RGBA8; for (const auto &pair : sceneData->getShadowFramebufferMap()) { gfx::Framebuffer *framebuffer = pair.second; @@ -210,14 +214,14 @@ void ShadowFlow::resizeShadowMap(scene::Shadow **shadowInfo) { }); } - (*shadowInfo)->shadowMapDirty = false; + shadows->setShadowMapDirty(false); } void ShadowFlow::initShadowFrameBuffer(RenderPipeline *pipeline, const scene::Light *light) { auto * device = gfx::Device::getInstance(); const auto *sceneData = _pipeline->getPipelineSceneData(); - const auto *shadowInfo = sceneData->getSharedData()->shadow; - const auto shadowMapSize = shadowInfo->size; + const auto *shadows = sceneData->getShadows(); + const auto shadowMapSize = shadows->getSize(); const auto width = static_cast(shadowMapSize.x); const auto height = static_cast(shadowMapSize.y); const auto format = supportsFloatTexture(device) ? gfx::Format::R32F : gfx::Format::RGBA8; @@ -247,7 +251,7 @@ void ShadowFlow::initShadowFrameBuffer(RenderPipeline *pipeline, const scene::Li rpInfo.depthStencilAttachment = depthStencilAttachment; size_t rpHash = cc::gfx::RenderPass::computeHash(rpInfo); - auto iter = renderPassHashMap.find(rpHash); + auto iter = renderPassHashMap.find(rpHash); if (iter != renderPassHashMap.end()) { _renderPass = iter->second; } else { @@ -293,7 +297,7 @@ void ShadowFlow::destroy() { renderPassHashMap.clear(); for (auto *texture : _usedTextures) { - CC_SAFE_DESTROY(texture); + CC_SAFE_DESTROY_AND_DELETE(texture); } _usedTextures.clear(); diff --git a/native/cocos/renderer/pipeline/shadow/ShadowFlow.h b/native/cocos/renderer/pipeline/shadow/ShadowFlow.h index b9b2e61c99..901a8c1ba5 100644 --- a/native/cocos/renderer/pipeline/shadow/ShadowFlow.h +++ b/native/cocos/renderer/pipeline/shadow/ShadowFlow.h @@ -53,7 +53,7 @@ private: void clearShadowMap(scene::Camera *camera); - void resizeShadowMap(scene::Shadow **shadowInfo); + void resizeShadowMap(); void initShadowFrameBuffer(RenderPipeline *pipeline, const scene::Light *light); diff --git a/native/cocos/renderer/pipeline/shadow/ShadowStage.cpp b/native/cocos/renderer/pipeline/shadow/ShadowStage.cpp index a37d791b12..e1c27b4e9d 100644 --- a/native/cocos/renderer/pipeline/shadow/ShadowStage.cpp +++ b/native/cocos/renderer/pipeline/shadow/ShadowStage.cpp @@ -30,6 +30,7 @@ #include "gfx-base/GFXCommandBuffer.h" #include "gfx-base/GFXFramebuffer.h" #include "math/Vec2.h" +#include "scene/Shadow.h" namespace cc { namespace pipeline { @@ -56,9 +57,8 @@ void ShadowStage::activate(RenderPipeline *pipeline, RenderFlow *flow) { } void ShadowStage::render(scene::Camera *camera) { - const auto *sceneData = _pipeline->getPipelineSceneData(); - const auto *sharedData = sceneData->getSharedData(); - const auto *shadowInfo = sceneData->getSharedData()->shadow; + const auto *sceneData = _pipeline->getPipelineSceneData(); + const auto *shadows = sceneData->getShadows(); if (!_light || !_framebuffer) { return; @@ -68,18 +68,18 @@ void ShadowStage::render(scene::Camera *camera) { _pipeline->getPipelineUBO()->updateShadowUBOLight(_globalDS, _light); _additiveShadowQueue->gatherLightPasses(camera, _light, cmdBuffer); - const auto shadowMapSize = shadowInfo->size; - const auto &viewport = camera->viewPort; + const auto &shadowMapSize = shadows->getSize(); + const auto &viewport = camera->getViewport(); _renderArea.x = static_cast(viewport.x * shadowMapSize.x); _renderArea.y = static_cast(viewport.y * shadowMapSize.y); - _renderArea.width = static_cast(viewport.z * shadowMapSize.x * sharedData->shadingScale); - _renderArea.height = static_cast(viewport.w * shadowMapSize.y * sharedData->shadingScale); + _renderArea.width = static_cast(viewport.z * shadowMapSize.x * sceneData->getShadingScale()); + _renderArea.height = static_cast(viewport.w * shadowMapSize.y * sceneData->getShadingScale()); _clearColors[0] = {1.0F, 1.0F, 1.0F, 1.0F}; auto *renderPass = _framebuffer->getRenderPass(); cmdBuffer->beginRenderPass(renderPass, _framebuffer, _renderArea, - _clearColors, camera->clearDepth, camera->clearStencil); + _clearColors, camera->getClearDepth(), camera->getClearStencil()); const std::array globalOffsets = {_pipeline->getPipelineUBO()->getCurrentCameraUBOOffset()}; cmdBuffer->bindDescriptorSet(globalSet, _globalDS, utils::toUint(globalOffsets.size()), globalOffsets.data()); @@ -93,7 +93,7 @@ void ShadowStage::destroy() { _globalDS = nullptr; _light = nullptr; - CC_SAFE_DESTROY(_additiveShadowQueue); + CC_SAFE_DESTROY_AND_DELETE(_additiveShadowQueue); RenderStage::destroy(); } @@ -109,7 +109,7 @@ void ShadowStage::clearFramebuffer(scene::Camera *camera) { auto *renderPass = _framebuffer->getRenderPass(); cmdBuffer->beginRenderPass(renderPass, _framebuffer, _renderArea, - _clearColors, camera->clearDepth, camera->clearStencil); + _clearColors, camera->getClearDepth(), camera->getClearStencil()); cmdBuffer->endRenderPass(); } diff --git a/native/cocos/scene/AABB.h b/native/cocos/scene/AABB.h deleted file mode 100644 index 8f2be0b001..0000000000 --- a/native/cocos/scene/AABB.h +++ /dev/null @@ -1,86 +0,0 @@ -/**************************************************************************** - 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 -#include "math/Mat3.h" -#include "math/Quaternion.h" -#include "math/Vec3.h" -#include "scene/Frustum.h" - -namespace cc { -namespace scene { - -struct AABBLayout { - cc::Vec3 center; - cc::Vec3 halfExtents{1, 1, 1}; -}; -class AABB final { -public: - static void fromPoints(const Vec3 &minPos, const Vec3 &maxPos, AABB *dst); - static void transformExtentM4(Vec3 *out, const Vec3 &extent, const Mat4 &m4); - AABB(); - AABB(const AABB &) = delete; - AABB(AABB &&) = delete; - ~AABB() = default; - AABB &operator=(const AABB &) = delete; - AABB &operator=(AABB &&) = delete; - - void initWithData(uint8_t *data); - bool aabbAabb(AABB *aabb) const; - /** - * @return true if (partially) inside, false if outside. - */ - bool aabbFrustum(const Frustum &) const; - /** - * @return -1 if outside, 0 if inside, 1 if intersects. - */ - int aabbPlane(const Plane &) const; - void getBoundary(cc::Vec3 *minPos, cc::Vec3 *maxPos) const; - void merge(const AABB &aabb); - void merge(const cc::Vec3 &point); - void merge(const Frustum &frustum); - void set(const cc::Vec3 ¢erVal, const cc::Vec3 &halfExtentVal); - void transform(const Mat4 &m, AABB *out) const; - bool contain(const cc::Vec3 &point) const; - inline void setCenter(float x, float y, float z) { _aabbLayout->center.set(x, y, z); } - inline void setCenter(const Vec3 ¢er) { _aabbLayout->center.set(center); } - inline void setValid(bool isValid) { _isValid = isValid; } - inline const Vec3 &getCenter() const { return _aabbLayout->center; } - inline bool getValid() const { return _isValid; } - inline void setHalfExtents(float x, float y, float z) { _aabbLayout->halfExtents.set(x, y, z); } - inline void setHalfExtents(const Vec3 &halfExtents) { _aabbLayout->halfExtents.set(halfExtents); } - inline const Vec3 &getHalfExtents() const { return _aabbLayout->halfExtents; } - inline AABBLayout *getLayout() { return _aabbLayout; } - -private: - AABBLayout _embedLayout; - AABBLayout *_aabbLayout{nullptr}; - bool _isValid{true}; -}; - -} // namespace scene -} // namespace cc diff --git a/native/cocos/scene/Ambient.cpp b/native/cocos/scene/Ambient.cpp new file mode 100644 index 0000000000..d814ae1f0a --- /dev/null +++ b/native/cocos/scene/Ambient.cpp @@ -0,0 +1,210 @@ +/**************************************************************************** + 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 "scene/Ambient.h" +#include "core/Root.h" + +namespace { +cc::Color col; + +// Normalize HDR color +void normalizeHDRColor(cc::Vec4 &color) { + const float intensity = 1.F / std::max(std::max(std::max(color.x, color.y), color.z), 0.0001F); + if (intensity < 1.F) { + color.x *= intensity; + color.y *= intensity; + color.z *= intensity; + } +} + +} // namespace +namespace cc { +namespace scene { + +void AmbientInfo::setSkyLightingColor(const Color &val) { + Vec4 v4(static_cast(val.r) / 255.F, static_cast(val.g) / 255.F, static_cast(val.b) / 255.F, static_cast(val.a) / 255.F); + const bool isHDR = Root::getInstance()->getPipeline()->getPipelineSceneData()->isHDR(); + if (isHDR) { + _skyColorHDR.set(v4); + } else { + _skyColorLDR.set(v4); + } + if (_resource != nullptr) { + _resource->setSkyColor(v4); + } +} + +const Color &AmbientInfo::getSkyLightingColor() const { + const bool isHDR = Root::getInstance()->getPipeline()->getPipelineSceneData()->isHDR(); + Vec4 v4(isHDR ? _skyColorHDR : _skyColorLDR); + normalizeHDRColor(v4); + col.set(static_cast(v4.x) * 255, static_cast(v4.y) * 255, static_cast(v4.z) * 255, 255); + return col; +} + +void AmbientInfo::setSkyColor(const Vec4 &val) { + const bool isHDR = Root::getInstance()->getPipeline()->getPipelineSceneData()->isHDR(); + if (isHDR) { + _skyColorHDR.set(val); + } else { + _skyColorLDR.set(val); + } + if (_resource != nullptr) { + _resource->setSkyColor(val); + } +} + +void AmbientInfo::setSkyIllum(float val) { + const bool isHDR = Root::getInstance()->getPipeline()->getPipelineSceneData()->isHDR(); + if (isHDR) { + _skyIllumHDR = val; + + } else { + _skyIllumLDR = val; + } + + if (_resource != nullptr) { + _resource->setSkyIllum(val); + } +} + +void AmbientInfo::setGroundLightingColor(const Color &val) { + Vec4 v4(static_cast(val.r) / 255.F, static_cast(val.g) / 255.F, static_cast(val.b) / 255.F, static_cast(val.a) / 255.F); + const bool isHDR = Root::getInstance()->getPipeline()->getPipelineSceneData()->isHDR(); + if (isHDR) { + _groundAlbedoHDR.set(v4); + } else { + _groundAlbedoHDR.set(v4); + } + + if (_resource != nullptr) { + _resource->setGroundAlbedo(v4); + } +} + +const Color &AmbientInfo::getGroundLightingColor() const { + const bool isHDR = Root::getInstance()->getPipeline()->getPipelineSceneData()->isHDR(); + Vec4 v4(isHDR ? _groundAlbedoHDR : _groundAlbedoLDR); + normalizeHDRColor(v4); + col.set(static_cast(v4.x) * 255, static_cast(v4.y) * 255, static_cast(v4.z) * 255, 255); + return col; +} + +void AmbientInfo::setGroundAlbedo(const Vec4 &val) { + const bool isHDR = Root::getInstance()->getPipeline()->getPipelineSceneData()->isHDR(); + if (isHDR) { + _groundAlbedoHDR.set(val); + } else { + _groundAlbedoLDR.set(val); + } + + if (_resource != nullptr) { + _resource->setGroundAlbedo(val); + } +} + +void AmbientInfo::activate(Ambient *resource) { + _resource = resource; + _resource->initialize(this); +} + +// +void Ambient::initialize(AmbientInfo *info) { + // setSkyColor(info->getSkyColor()); + // setGroundAlbedo(info->getGroundAlbedo()); + // _skyIllum = info->getSkyIllum(); + + // Init HDR/LDR from serialized data on load + _skyColorHDR = info->getSkyColorHDR(); + _groundAlbedoHDR.x = info->getGroundAlbedoHDR().x; + _groundAlbedoHDR.y = info->getGroundAlbedoHDR().y; + _groundAlbedoHDR.z = info->getGroundAlbedoHDR().z; + _skyIllumHDR = info->getSkyIllumHDR(); + _skyColorLDR = info->getSkyColorLDR(); + _groundAlbedoLDR.x = info->getGroundAlbedoLDR().x; + _groundAlbedoLDR.y = info->getGroundAlbedoLDR().y; + _groundAlbedoLDR.z = info->getGroundAlbedoLDR().z; + _skyIllumLDR = info->getSkyIllumLDR(); +} + +Vec4 &Ambient::getSkyColor() { + const bool isHDR = Root::getInstance()->getPipeline()->getPipelineSceneData()->isHDR(); + return isHDR ? _skyColorHDR : _skyColorLDR; +} + +void Ambient::setSkyColor(const Vec4 &color) { + const bool isHDR = Root::getInstance()->getPipeline()->getPipelineSceneData()->isHDR(); + if (isHDR) { + _skyColorHDR.x = color.x; + _skyColorHDR.y = color.y; + _skyColorHDR.z = color.z; + } else { + _skyColorLDR.x = color.x; + _skyColorLDR.y = color.y; + _skyColorLDR.z = color.z; + } +} + +/** + * @en Sky illuminance + * @zh 天空亮度 + */ +float Ambient::getSkyIllum() const { + const bool isHDR = Root::getInstance()->getPipeline()->getPipelineSceneData()->isHDR(); + return isHDR ? _skyIllumHDR : _skyIllumLDR; +} +void Ambient::setSkyIllum(float illum) { + const bool isHDR = Root::getInstance()->getPipeline()->getPipelineSceneData()->isHDR(); + if (isHDR) { + _skyIllumHDR = illum; + } else { + _skyIllumLDR = illum; + } +} + +/** + * @en Ground color + * @zh 地面颜色 + */ +Vec4 &Ambient::getGroundAlbedo() { //TODO(xwx): temporary remove const. need jk20012001 refactor in v3.5 + const bool isHDR = Root::getInstance()->getPipeline()->getPipelineSceneData()->isHDR(); + return isHDR ? _groundAlbedoHDR : _groundAlbedoLDR; +} + +void Ambient::setGroundAlbedo(const Vec4 &color) { + const bool isHDR = Root::getInstance()->getPipeline()->getPipelineSceneData()->isHDR(); + if (isHDR) { + _groundAlbedoHDR.x = color.x; + _groundAlbedoHDR.y = color.y; + _groundAlbedoHDR.z = color.z; + } else { + _groundAlbedoLDR.x = color.x; + _groundAlbedoLDR.y = color.y; + _groundAlbedoLDR.z = color.z; + } +} + +} // namespace scene +} // namespace cc diff --git a/native/cocos/scene/Ambient.h b/native/cocos/scene/Ambient.h new file mode 100644 index 0000000000..4b42597814 --- /dev/null +++ b/native/cocos/scene/Ambient.h @@ -0,0 +1,193 @@ +/**************************************************************************** + 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 +#include "base/Macros.h" +#include "base/RefCounted.h" +#include "core/Root.h" +#include "math/Color.h" + +namespace cc { +namespace scene { + +class AmbientInfo; + +class Ambient final { +public: + friend class Skybox; + + static constexpr float SUN_ILLUM{65000.0F}; + static constexpr float SKY_ILLUM{20000.0F}; + + Ambient(/* args */) = default; + ~Ambient() = default; + + void initialize(AmbientInfo *info); + + /** + * @en Enable ambient + * @zh 是否开启环境光 + */ + inline void setEnabled(bool val) { _enabled = val; } + inline bool isEnabled() const { return _enabled; } + + /** + * @en Sky color + * @zh 天空颜色 + */ + + Vec4 &getSkyColor(); + void setSkyColor(const Vec4 &color); + + /** + * @en Sky illuminance + * @zh 天空亮度 + */ + float getSkyIllum() const; + void setSkyIllum(float illum); + + /** + * @en Ground color + * @zh 地面颜色 + */ + Vec4 &getGroundAlbedo(); + void setGroundAlbedo(const Vec4 &color); + +protected: + Vec4 _groundAlbedoHDR{0.2F, 0.2F, 0.2F, 1.F}; + Vec4 _skyColorHDR{0.2F, 0.5F, 0.8F, 1.F}; + float _skyIllumHDR{0.F}; + + Vec4 _groundAlbedoLDR{0.2F, 0.2F, 0.2F, 1.F}; + Vec4 _skyColorLDR{0.2F, 0.5F, 0.8F, 1.F}; + float _skyIllumLDR{0.F}; + + bool _enabled{false}; + + CC_DISALLOW_COPY_MOVE_ASSIGN(Ambient); +}; + +/** + * @en Environment lighting information in the Scene + * @zh 场景的环境光照相关信息 + */ +// @ccclass('cc.AmbientInfo') +// @help('i18n:cc.Ambient') +class AmbientInfo : public RefCounted { +public: + AmbientInfo(/* args */) = default; + ~AmbientInfo() override = default; + + inline const Vec4 &getSkyColorHDR() const { return _skyColorHDR; }; + inline const Vec4 &getSkyColorLDR() const { return _skyColorLDR; }; + + inline const Vec4 &getGroundAlbedoHDR() const { return _groundAlbedoHDR; }; + inline const Vec4 &getGroundAlbedoLDR() const { return _groundAlbedoLDR; }; + + inline const float &getSkyIllumHDR() const { return _skyIllumHDR; }; + inline const float &getSkyIllumLDR() const { return _skyIllumLDR; }; + + /** + * @en Sky lighting color configurable in editor with color picker + * @zh 编辑器中可配置的天空光照颜色(通过颜色拾取器) + */ + // @visible(() => { + // const scene = legacyCC.director.getScene(); + // const skybox = scene.globals.skybox; + // if (skybox.useIBL && skybox.applyDiffuseMap) { + // return false; + // } else { + // return true; + // } + // }) + // @editable + // @tooltip('i18n:ambient.skyLightingColor') + void setSkyLightingColor(const Color &val); + const Color &getSkyLightingColor() const; + + void setSkyColor(const Vec4 &val); + + /** + * @en Sky illuminance + * @zh 天空亮度 + */ + // @editable + // @type(CCFloat) + // @tooltip('i18n:ambient.skyIllum') + void setSkyIllum(float val); + inline float getSkyIllum() const { + const bool isHDR = Root::getInstance()->getPipeline()->getPipelineSceneData()->isHDR(); + return isHDR ? _skyIllumHDR : _skyIllumLDR; + } + + /** + * @en Ground lighting color configurable in editor with color picker + * @zh 编辑器中可配置的地面光照颜色(通过颜色拾取器) + */ + // @visible(() => { + // const scene = legacyCC.director.getScene(); + // const skybox = scene.globals.skybox; + // if (skybox.useIBL && skybox.applyDiffuseMap) { + // return false; + // } else { + // return true; + // } + // }) + // @editable + // @tooltip('i18n:ambient.groundLightingColor') + void setGroundLightingColor(const Color &val); + const Color &getGroundLightingColor() const; + + void setGroundAlbedo(const Vec4 &val); + + void activate(Ambient *resource); + + //cjh JSB need to bind the property, so need to make it public + //private: + // @serializable + // @formerlySerializedAs('_skyColor')); + Vec4 _skyColorHDR{0.2F, 0.5F, 0.8F, 1.F}; + // @serializable + // @formerlySerializedAs('_skyIllum') + float _skyIllumHDR{Ambient::SKY_ILLUM}; + // @serializable + // @formerlySerializedAs('_groundAlbedo') + Vec4 _groundAlbedoHDR{0.2F, 0.2F, 0.2F, 1.F}; + + // @serializable + Vec4 _skyColorLDR{0.2F, 0.5F, 0.8F, 1.F}; + + // @serializable + float _skyIllumLDR{Ambient::SKY_ILLUM}; + // @serializable + Vec4 _groundAlbedoLDR{0.2F, 0.2F, 0.2F, 1.F}; + + Ambient *_resource{nullptr}; +}; + +} // namespace scene +} // namespace cc diff --git a/native/cocos/scene/BakedSkinningModel.cpp b/native/cocos/scene/BakedSkinningModel.cpp deleted file mode 100644 index 638b29260f..0000000000 --- a/native/cocos/scene/BakedSkinningModel.cpp +++ /dev/null @@ -1,62 +0,0 @@ -/**************************************************************************** - 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 "scene/BakedSkinningModel.h" -#include "scene/RenderScene.h" - -namespace cc { -namespace scene { -void BakedSkinningModel::updateTransform(uint32_t stamp) { - Model::updateTransform(stamp); - if (!_isUploadAnim) { - return; - } - BakedAnimInfo& animInfo = _jointMedium.animInfo; - AABB* skelBound = !_jointMedium.boundsInfo.empty() ? _jointMedium.boundsInfo[*animInfo.data] : nullptr; - if (_worldBounds && skelBound) { - Node* node = getTransform(); - skelBound->transform(node->getWorldMatrix(), _worldBounds); - } - - // Fix me: update twice - if (_scene) { - _scene->updateOctree(this); - } -} - -void BakedSkinningModel::updateUBOs(uint32_t stamp) { - Model::updateUBOs(stamp); - BakedAnimInfo& info = _jointMedium.animInfo; - int idx = _instAnimInfoIdx; - if (idx >= 0) { - std::vector& views = getInstancedAttributeBlock()->views; - *reinterpret_cast(views[0]) = *reinterpret_cast(info.data); - } else if (info.getDirty()) { - info.buffer->update(info.data, info.buffer->getSize()); - *info.dirty = 0; - } -} - -} // namespace scene -} // namespace cc diff --git a/native/cocos/scene/BakedSkinningModel.h b/native/cocos/scene/BakedSkinningModel.h deleted file mode 100644 index 0849ee586b..0000000000 --- a/native/cocos/scene/BakedSkinningModel.h +++ /dev/null @@ -1,84 +0,0 @@ -/**************************************************************************** - 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 - -#include "scene/Model.h" - -namespace cc { -namespace scene { -struct BakedAnimInfo { - gfx::Buffer *buffer{nullptr}; - uint8_t * data{nullptr}; - uint8_t * dirty{nullptr}; - inline bool getDirty() const { - return static_cast(*reinterpret_cast(dirty)); - } -}; -struct BakedJointInfo { - std::vector boundsInfo; - uint8_t * jointTextureInfo{nullptr}; - BakedAnimInfo animInfo; - gfx::Buffer * buffer{nullptr}; -}; -class BakedSkinningModel : public Model { -public: - BakedSkinningModel() = default; - BakedSkinningModel(const BakedSkinningModel &) = delete; - BakedSkinningModel(BakedSkinningModel &&) = delete; - ~BakedSkinningModel() override = default; - BakedSkinningModel &operator=(const BakedSkinningModel &) = delete; - BakedSkinningModel &operator=(BakedSkinningModel &&) = delete; - - void updateTransform(uint32_t stamp) override; - void updateUBOs(uint32_t stamp) override; - inline void updateModelBounds(AABB *modelBounds) { - if (modelBounds == nullptr) { - _modelBounds.setValid(false); - return; - } - _modelBounds.setValid(true); - _modelBounds.set(modelBounds->getCenter(), modelBounds->getHalfExtents()); - } - - inline void setJointMedium(bool isUploadAnim, BakedJointInfo &&jointMedium) { - _isUploadAnim = isUploadAnim; - _jointMedium = std::move(jointMedium); - } - inline void setAnimInfoIdx(int32_t idx) { - _instAnimInfoIdx = idx; - } - -private: - ModelType _type{ModelType::BAKED_SKINNING}; - BakedJointInfo _jointMedium; - bool _isUploadAnim{false}; - int32_t _instAnimInfoIdx{-1}; -}; - -} // namespace scene -} // namespace cc diff --git a/native/cocos/scene/BaseNode.h b/native/cocos/scene/BaseNode.h deleted file mode 100644 index 12151006df..0000000000 --- a/native/cocos/scene/BaseNode.h +++ /dev/null @@ -1,103 +0,0 @@ -/**************************************************************************** - 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 -#include "math/Mat3.h" -#include "math/Mat4.h" -#include "math/Quaternion.h" -#include "math/Vec3.h" -#include "math/Vec4.h" - -namespace cc { -namespace scene { -class BaseNode { -public: - BaseNode() = default; - BaseNode(const BaseNode &) = delete; - BaseNode(BaseNode &&) = delete; - virtual ~BaseNode() = default; - BaseNode &operator=(const BaseNode &) = delete; - BaseNode &operator=(const BaseNode &&) = delete; - - virtual inline void updateWorldTransform(){} - virtual inline void updateWorldRTMatrix(){} - - virtual inline void setWorldPosition(float x, float y, float z){} - virtual inline void setWorldRotation(float x, float y, float z, float w){} - void setParent(BaseNode *parent); - - inline void addChild(BaseNode *node) { _children.emplace_back(node); } - inline void removeChild(BaseNode *node) { - auto iter = std::find(_children.begin(), _children.end(), node); - if (iter != _children.end()) { - _children.erase(iter); - } - } - - virtual inline void setFlagsChanged(uint32_t value){} - virtual inline void setDirtyFlag(uint32_t value){} - virtual inline void setLayer(uint32_t layer){} - virtual inline void setWorldMatrix(const Mat4 &matrix){} - virtual inline void setWorldPosition(const Vec3 &pos){} - virtual inline void setWorldRotation(const Quaternion &rotation){} - virtual inline void setWorldScale(const Vec3 &scale){} - virtual inline void setLocalPosition(const Vec3 &pos){} - virtual inline void setLocalPosition(float x, float y, float z){} - virtual inline void setLocalRotation(const Quaternion &rotation){} - virtual inline void setLocalRotation(float x, float y, float z, float w){} - virtual inline void setLocalScale(const Vec3 &scale){} - - inline const std::vector &getChilds() { return _children; } - inline BaseNode * getParent() const { return _parent; } - virtual inline uint32_t getFlagsChanged() const { return _flagChange; } - virtual inline uint32_t getLayer() const { return _layer; } - virtual inline uint32_t getDirtyFlag() const { return _dirtyFlag; } - virtual inline const Vec3 & getPosition() const { return _localPosition; } - virtual inline const Vec3 & getScale() const { return _localScale; } - virtual inline const Quaternion & getRotation() const { return _localRotation; } - virtual inline const Mat4 & getWorldMatrix() const { return _worldMatrix; } - virtual inline const Vec3 & getWorldPosition() const { return _worldPosition; } - virtual inline const Quaternion & getWorldRotation() const { return _worldRotation; } - virtual inline const Vec3 & getWorldScale() const { return _worldScale; } - virtual inline const Mat4 & getWorldRTMatrix() const { return _rtMat; } - -protected: - std::vector _children; - BaseNode * _parent{nullptr}; - uint32_t _flagChange{0}; - uint32_t _dirtyFlag{0}; - uint32_t _layer{0}; - cc::Vec3 _worldScale{Vec3::ONE}; - cc::Vec3 _worldPosition{Vec3::ZERO}; - cc::Quaternion _worldRotation{Quaternion::identity()}; - Mat4 _rtMat{Mat4::IDENTITY}; - cc::Mat4 _worldMatrix{Mat4::IDENTITY}; - cc::Vec3 _localScale{Vec3::ONE}; - cc::Vec3 _localPosition{Vec3::ZERO}; - cc::Quaternion _localRotation{Quaternion::identity()}; -}; -} // namespace scene -} // namespace cc \ No newline at end of file diff --git a/native/cocos/scene/Camera.cpp b/native/cocos/scene/Camera.cpp new file mode 100644 index 0000000000..e1ca10cbdf --- /dev/null +++ b/native/cocos/scene/Camera.cpp @@ -0,0 +1,407 @@ +/**************************************************************************** + 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 "scene/Camera.h" +#include +#include "core/Root.h" +#include "math/MathUtil.h" +#include "renderer/gfx-base/GFXDevice.h" +#include "renderer/pipeline/Define.h" + +namespace cc { +namespace scene { + +namespace { +std::array correctionMatrices; + +void assignMat4(Mat4 &mat4, float m0, float m1, float m2, float m3, float m4, float m5) { + mat4.m[0] = m0; + mat4.m[1] = m1; + mat4.m[2] = m2; + mat4.m[3] = m3; + mat4.m[4] = m4; + mat4.m[5] = m5; +} + +constexpr std::array, 4> PRE_TRANSFORMS = {{ + {{1, 0, 0, 1}}, // SurfaceTransform.IDENTITY + {{0, 1, -1, 0}}, // SurfaceTransform.ROTATE_90 + {{-1, 0, 0, -1}}, // SurfaceTransform.ROTATE_180 + {{0, -1, 1, 0}} // SurfaceTransform.ROTATE_270 +}}; + +} // namespace + +const std::vector Camera::FSTOPS{1.8F, 2.0F, 2.2F, 2.5F, 2.8F, 3.2F, 3.5F, 4.0F, 4.5F, 5.0F, 5.6F, 6.3F, 7.1F, 8.0F, 9.0F, 10.0F, 11.0F, 13.0F, 14.0F, 16.0F, 18.0F, 20.0F, 22.0F}; +const std::vector Camera::SHUTTERS{1.0F, 1.0F / 2.0F, 1.0F / 4.0F, 1.0F / 8.0F, 1.0F / 15.0F, 1.0F / 30.0F, 1.0F / 60.0F, 1.0F / 125.0F, + 1.0F / 250.0F, 1.0F / 500.0F, 1.0F / 1000.0F, 1.0F / 2000.0F, 1.0F / 4000.0F}; +const std::vector Camera::ISOS{100.0F, 200.0F, 400.0F, 800.0F}; + +Camera::Camera(gfx::Device *device) +: _device(device) { + _apertureValue = Camera::FSTOPS.at(static_cast(_aperture)); + _shutterValue = Camera::SHUTTERS.at(static_cast(_shutter)); + _isoValue = Camera::ISOS[static_cast(_iso)]; + + _aspect = _screenScale = 1.F; + _frustum = new geometry::Frustum(); + _frustum->addRef(); + _frustum->setAccurate(true); + + if (correctionMatrices.empty()) { + float ySign = _device->getCapabilities().clipSpaceSignY; + assignMat4(correctionMatrices[static_cast(gfx::SurfaceTransform::IDENTITY)], 1.F, 0, 0, 0, 0, ySign); + assignMat4(correctionMatrices[static_cast(gfx::SurfaceTransform::ROTATE_90)], 0, 1.F, 0, 0, -ySign, 0); + assignMat4(correctionMatrices[static_cast(gfx::SurfaceTransform::ROTATE_180)], -1, 0, 0, 0, 0, -ySign); + assignMat4(correctionMatrices[static_cast(gfx::SurfaceTransform::ROTATE_270)], 0, -1, 0, 0, ySign, 0); + } +} + +Camera::~Camera() { + _frustum->release(); +} + +bool Camera::initialize(const ICameraInfo &info) { + _node = info.node; + _width = 1.F; + _height = 1.F; + _clearFlag = gfx::ClearFlagBit::NONE; + _clearDepth = 1.0F; + _visibility = pipeline::CAMERA_DEFAULT_MASK; + _name = info.name; + _proj = info.projection; + _priority = info.priority; + _aspect = _screenScale = 1.F; + updateExposure(); + changeTargetWindow(info.window); + return true; +} + +void Camera::destroy() { + if (_window) { + _window->detachCamera(this); + _window = nullptr; + } + _name.clear(); +} + +void Camera::attachToScene(RenderScene *scene) { + _enabled = true; + _scene = scene; +} + +void Camera::detachFromScene() { + _enabled = false; + _scene = nullptr; +} + +void Camera::resize(uint32_t width, uint32_t height) { + if (!_window) { + return; + } + + _width = width; + _height = height; + updateAspect(); +} + +void Camera::setFixedSize(uint32_t width, uint32_t height) { + _width = width; + _height = height; + updateAspect(false); + _isWindowSize = false; +} + +// Editor specific gizmo camera logic +void Camera::syncCameraEditor(const Camera &camera) { + // TODO(xwx): EDITOR not implemented + // if (EDITOR) { + // this.position = camera.position; + // this.forward = camera.forward; + // this._matView = camera.matView; + // this._matProj = camera.matProj; + // this._matProjInv = camera.matProjInv; + // this._matViewProj = camera.matViewProj; + // } +} + +void Camera::update(bool forceUpdate /*false*/) { + if (!_node) { + return; + } + + bool viewProjDirty = false; + // view matrix + if (_node->getChangedFlags() || forceUpdate) { + _matView = _node->getWorldMatrix().getInversed(); + _forward.set(-_matView.m[2], -_matView.m[6], -_matView.m[10]); + + _position.set(_node->getWorldPosition()); + viewProjDirty = true; + } + + // projection matrix + auto * swapchain = _window->getSwapchain(); + const auto &orientation = swapchain ? swapchain->getSurfaceTransform() : gfx::SurfaceTransform::IDENTITY; + + if (_isProjDirty || _curTransform != orientation) { + _curTransform = orientation; + const float projectionSignY = _device->getCapabilities().clipSpaceSignY; + // Only for rendertexture processing + if (_proj == CameraProjection::PERSPECTIVE) { + Mat4::createPerspective(_fov, _aspect, _nearClip, _farClip, + _fovAxis == CameraFOVAxis::VERTICAL, _device->getCapabilities().clipSpaceMinZ, projectionSignY, static_cast(orientation), &_matProj); + } else { + const float x = _orthoHeight * _aspect; + const float y = _orthoHeight; + Mat4::createOrthographicOffCenter(-x, x, -y, y, _nearClip, _farClip, + _device->getCapabilities().clipSpaceMinZ, projectionSignY, + static_cast(orientation), &_matProj); + } + _matProjInv = _matProj.getInversed(); + viewProjDirty = true; + _isProjDirty = false; + } + + // view-projection + if (viewProjDirty) { + Mat4::multiply(_matProj, _matView, &_matViewProj); + _matViewProjInv = _matViewProj.getInversed(); + _frustum->update(_matViewProj, _matViewProjInv); + } +} +void Camera::changeTargetWindow(RenderWindow *window) { + if (_window) { + _window->detachCamera(this); + } + RenderWindow *win = window ? window : Root::getInstance()->getMainWindow(); + if (win) { + win->attachCamera(this); + _window = win; + + // window size is pre-rotated + auto * swapchain = win->getSwapchain(); + const auto orientation = swapchain ? swapchain->getSurfaceTransform() : gfx::SurfaceTransform::IDENTITY; + if (static_cast(orientation) % 2) { + resize(win->getHeight(), win->getWidth()); + } else { + resize(win->getWidth(), win->getHeight()); + } + } +} + +void Camera::detachCamera() { + if (_window) { + _window->detachCamera(this); + } +} + +geometry::Ray Camera::screenPointToRay(float x, float y) { + CC_ASSERT(_node != nullptr); + const float cx = _orientedViewport.x * static_cast(_width); + const float cy = _orientedViewport.y * static_cast(_height); + const float cw = _orientedViewport.z * static_cast(_width); + const float ch = _orientedViewport.w * static_cast(_height); + const bool isProj = _proj == CameraProjection::PERSPECTIVE; + const float ySign = _device->getCapabilities().clipSpaceSignY; + const std::array &preTransform = PRE_TRANSFORMS[static_cast(_curTransform)]; + + Vec3 tmpVec3{ + (x - cx) / cw * 2 - 1.F, + (y - cy) / ch * 2 - 1.F, + isProj ? 1.F : -1.F}; + tmpVec3.x = tmpVec3.x * preTransform[0] + tmpVec3.y * preTransform[2] * ySign; + tmpVec3.y = tmpVec3.x * preTransform[1] + tmpVec3.y * preTransform[3] * ySign; + + geometry::Ray out; + if (isProj) { + tmpVec3.transformMat4(tmpVec3, _matViewProjInv); + } else { + out.o.transformMat4(tmpVec3, _matViewProjInv); + } + + if (isProj) { + // camera origin + geometry::Ray::fromPoints(&out, _node->getWorldPosition(), tmpVec3); + } else { + out.d.set(0, 0, -1.F); + out.d.transformQuat(_node->getRotation()); + } + + return out; +} + +Vec3 Camera::screenToWorld(const Vec3 &screenPos) { + const float cx = _orientedViewport.x * static_cast(_width); + const float cy = _orientedViewport.y * static_cast(_height); + const float cw = _orientedViewport.z * static_cast(_width); + const float ch = _orientedViewport.w * static_cast(_height); + const float ySign = _device->getCapabilities().clipSpaceSignY; + const std::array &preTransform = PRE_TRANSFORMS[static_cast(_curTransform)]; + Vec3 out; + + if (_proj == CameraProjection::PERSPECTIVE) { + // calculate screen pos in far clip plane + out.set( + (screenPos.x - cx) / cw * 2 - 1, + (screenPos.y - cy) / ch * 2 - 1, + 1.0F); + + // transform to world + out.x = out.x * preTransform[0] + out.y * preTransform[2] * ySign; + out.y = out.x * preTransform[1] + out.y * preTransform[3] * ySign; + _matViewProjInv.transformPoint(&out); + + // lerp to depth z + Vec3 tmpVec3; + if (_node) { + tmpVec3.set(_node->getWorldPosition()); + } + + out = out.lerp(tmpVec3, MathUtil::lerp(_nearClip / _farClip, 1, screenPos.z)); + } else { + out.set( + (screenPos.x - cx) / cw * 2 - 1, + (screenPos.y - cy) / ch * 2 - 1, + screenPos.z * 2 - 1); + + // transform to world + out.x = out.x * preTransform[0] + out.y * preTransform[2] * ySign; + out.y = out.x * preTransform[1] + out.y * preTransform[3] * ySign; + _matViewProjInv.transformPoint(&out); + } + + return out; +} + +Vec3 Camera::worldToScreen(const Vec3 &worldPos) { + const float ySign = _device->getCapabilities().clipSpaceSignY; + const std::array &preTransform = PRE_TRANSFORMS[static_cast(_curTransform)]; + Vec3 out; + Vec3::transformMat4(worldPos, _matViewProj, &out); + + out.x = out.x * preTransform[0] + out.y * preTransform[2] * ySign; + out.y = out.x * preTransform[1] + out.y * preTransform[3] * ySign; + + const float cx = _orientedViewport.x * static_cast(_width); + const float cy = _orientedViewport.y * static_cast(_height); + const float cw = _orientedViewport.z * static_cast(_width); + const float ch = _orientedViewport.w * static_cast(_height); + + out.x = cx + (out.x + 1) * 0.5F * cw; + out.y = cy + (out.y + 1) * 0.5F * ch; + out.z = out.z * 0.5F + 0.5F; + + return out; +} + +Mat4 Camera::worldMatrixToScreen(const Mat4 &worldMatrix, uint32_t width, uint32_t height) { + Mat4 out; + Mat4::multiply(_matViewProj, worldMatrix, &out); + Mat4::multiply(correctionMatrices[static_cast(_curTransform)], out, &out); + + const float halfWidth = static_cast(width) / 2; + const float halfHeight = static_cast(height) / 2; + Mat4 tmpMat4(Mat4::IDENTITY); + tmpMat4.translate(halfWidth, halfHeight, 0); + tmpMat4.scale(halfWidth, halfHeight, 1); + + out.multiply(tmpMat4); + + return out; +} + +void Camera::setExposure(float ev100) { + _exposure = 0.833333F / std::pow(2.0F, ev100); +} + +void Camera::updateExposure() { + const float ev100 = std::log2((_apertureValue * _apertureValue) / _shutterValue * 100.F / _isoValue); + setExposure(ev100); +} + +void Camera::updateAspect(bool oriented) { + _aspect = (static_cast(getWindow()->getWidth()) * _viewport.z) / (static_cast(getWindow()->getHeight()) * _viewport.w); + // window size/viewport is pre-rotated, but aspect should be oriented to acquire the correct projection + if (oriented) { + auto * swapchain = getWindow()->getSwapchain(); + const auto orientation = swapchain ? swapchain->getSurfaceTransform() : gfx::SurfaceTransform::IDENTITY; + if (static_cast(orientation) % 2) _aspect = 1 / _aspect; + } + _isProjDirty = true; +} + +void Camera::setViewport(const Vec4 &val) { + // warnID(8302); // TODO(xwx): not implemented yet + setViewportInOrientedSpace(val); +} + +void Camera::setViewportInOrientedSpace(const Vec4 &val) { + const float x = val.x; + const float width = val.z; + const float height = val.w; + + const float y = _device->getCapabilities().screenSpaceSignY < 0 ? 1 - val.y - height : val.y; + + auto * swapchain = getWindow()->getSwapchain(); + const auto orientation = swapchain ? swapchain->getSurfaceTransform() : gfx::SurfaceTransform::IDENTITY; + switch (orientation) { + case gfx::SurfaceTransform::ROTATE_90: + _viewport.x = 1 - y - height; + _viewport.y = x; + _viewport.z = height; + _viewport.w = width; + break; + case gfx::SurfaceTransform::ROTATE_180: + _viewport.x = 1 - x - width; + _viewport.y = 1 - y - height; + _viewport.z = width; + _viewport.w = height; + break; + case gfx::SurfaceTransform::ROTATE_270: + _viewport.x = y; + _viewport.y = 1 - x - width; + _viewport.z = height; + _viewport.w = width; + break; + case gfx::SurfaceTransform::IDENTITY: + _viewport.x = x; + _viewport.y = y; + _viewport.z = width; + _viewport.w = height; + break; + default: + break; + } + _orientedViewport.x = x; + _orientedViewport.y = y; + _orientedViewport.z = width; + _orientedViewport.w = height; + + resize(_width, _height); +} + +} // namespace scene +} // namespace cc diff --git a/native/cocos/scene/Camera.h b/native/cocos/scene/Camera.h index 8ea61afd92..65bdbe84dc 100644 --- a/native/cocos/scene/Camera.h +++ b/native/cocos/scene/Camera.h @@ -26,49 +26,345 @@ #pragma once #include +#include +#include "base/Macros.h" +#include "base/Ptr.h" +#include "base/RefCounted.h" +#include "cocos/base/Optional.h" +#include "cocos/math/Utils.h" +#include "core/geometry/Frustum.h" +#include "core/geometry/Ray.h" +#include "core/scene-graph/Node.h" #include "math/Mat4.h" #include "math/Vec3.h" #include "math/Vec4.h" #include "renderer/gfx-base/GFXDef-common.h" -#include "scene/Frustum.h" -#include "scene/Node.h" -#include "scene/RenderWindow.h" +#include "renderer/pipeline/Define.h" namespace cc { + namespace scene { // As RenderScene includes Camera.h, so use forward declaration here. class RenderScene; +// As RenderWindow includes Camera.h, so use forward declaration here. +class RenderWindow; -struct Camera final { - uint32_t width{0}; - uint32_t height{0}; - uint32_t nearClip{0}; - uint32_t farClip{0}; - uint32_t clearFlag{0}; - float exposure{0.0F}; - float clearDepth{0.0F}; - float fov{0.0F}; - float aspect{0.0F}; - Vec4 viewPort; - uint32_t clearStencil{0}; - uint32_t visibility{0}; - Node * node{nullptr}; - RenderScene * scene{nullptr}; - RenderWindow *window{nullptr}; - Frustum frustum; - Vec3 forward; - Vec3 position; - gfx::Color clearColor; - Mat4 matView; - Mat4 matViewProj; - Mat4 matViewProjInv; - Mat4 matProj; - Mat4 matProjInv; - Mat4 matViewProjOffscreen; - Mat4 matViewProjInvOffscreen; - Mat4 matProjOffscreen; - Mat4 matProjInvOffscreen; +enum class CameraProjection { + ORTHO, + PERSPECTIVE, + UNKNOWN +}; + +enum class CameraFOVAxis { + VERTICAL, + HORIZONTAL, +}; + +enum class CameraAperture { + F1_8, + F2_0, + F2_2, + F2_5, + F2_8, + F3_2, + F3_5, + F4_0, + F4_5, + F5_0, + F5_6, + F6_3, + F7_1, + F8_0, + F9_0, + F10_0, + F11_0, + F13_0, + F14_0, + F16_0, + F18_0, + F20_0, + F22_0, +}; + +enum class CameraISO { + ISO100, + ISO200, + ISO400, + ISO800, +}; + +enum class CameraShutter { + D1, + D2, + D4, + D8, + D15, + D30, + D60, + D125, + D250, + D500, + D1000, + D2000, + D4000, +}; + +struct ICameraInfo { + std::string name; + Node * node{nullptr}; + CameraProjection projection; + cc::optional targetDisplay; + RenderWindow * window{nullptr}; + uint32_t priority{0}; + cc::optional pipeline; +}; + +class Camera : public RefCounted { +public: + static constexpr int32_t SKYBOX_FLAG{static_cast(gfx::ClearFlagBit::STENCIL) << 1}; + + explicit Camera(gfx::Device *device); + ~Camera() override; + + /** + * this exposure value corresponding to default standard camera exposure parameters + */ + static constexpr float getStandardExposureValue() { + return 1.F / 38400.F; + } + + /** + * luminance unit scale used by area lights + */ + static constexpr float getStandardLightMeterScale() { + return 10000.F; + } + + bool initialize(const ICameraInfo &info); + void destroy(); + void attachToScene(RenderScene *scene); + void detachFromScene(); + void resize(uint32_t width, uint32_t height); + void setFixedSize(uint32_t width, uint32_t height); + void syncCameraEditor(const Camera &camera); + void update(bool forceUpdate = false); // for lazy eval situations like the in-editor preview + void changeTargetWindow(RenderWindow *window); + + /** + * transform a screen position (in oriented space) to a world space ray + */ + geometry::Ray screenPointToRay(float x, float y); + + /** + * transform a screen position (in oriented space) to world space + */ + Vec3 screenToWorld(const Vec3 &screenPos); + + /** + * transform a world space position to screen space + */ + Vec3 worldToScreen(const Vec3 &worldPos); + + /** + * transform a world space matrix to screen space + * @param {Mat4} out the resulting vector + * @param {Mat4} worldMatrix the world space matrix to be transformed + * @param {number} width framebuffer width + * @param {number} height framebuffer height + * @returns {Mat4} the resulting vector + */ + Mat4 worldMatrixToScreen(const Mat4 &worldMatrix, uint32_t width, uint32_t height); + + inline void setNode(Node *val) { _node = val; } + inline Node *getNode() const { return _node.get(); } + + inline void setEnabled(bool val) { _enabled = val; } + inline bool isEnabled() const { return _enabled; } + + inline void setOrthoHeight(float val) { + _orthoHeight = val; + _isProjDirty = true; + } + inline float getOrthoHeight() const { return _orthoHeight; } + + inline void setProjectionType(CameraProjection val) { + _proj = val; + _isProjDirty = true; + } + inline CameraProjection getProjectionType() const { return _proj; } + + inline void setFovAxis(CameraFOVAxis axis) { + _fovAxis = axis; + _isProjDirty = true; + } + inline CameraFOVAxis getFovAxis() const { return _fovAxis; } + + inline void setFov(float fov) { + _fov = fov; + _isProjDirty = true; + } + inline float getFov() const { return _fov; } + + inline void setNearClip(float nearClip) { + _nearClip = nearClip; + _isProjDirty = true; + } + inline float getNearClip() const { return _nearClip; } + + inline void setFarClip(float farClip) { + _farClip = farClip; + _isProjDirty = true; + } + inline float getFarClip() const { return _farClip; } + + inline void setClearColor(const gfx::Color &val) { _clearColor = val; } + inline const gfx::Color &getClearColor() const { return _clearColor; } + + /** + * Pre-rotated (i.e. always in identity/portrait mode) if possible. + */ + inline const Vec4 &getViewport() const { return _viewport; } + void setViewport(const Vec4 &val); + void setViewportInOrientedSpace(const Vec4 &val); + + inline RenderScene * getScene() const { return _scene; } + inline const std::string &getName() const { return _name; } + inline uint32_t getWidth() const { return _width; } + inline uint32_t getHeight() const { return _height; } + inline float getAspect() const { return _aspect; } + inline const Mat4 & getMatView() const { return _matView; } + inline const Mat4 & getMatProj() const { return _matProj; } + inline const Mat4 & getMatProjInv() const { return _matProjInv; } + inline const Mat4 & getMatViewProj() const { return _matViewProj; } + inline const Mat4 & getMatViewProjInv() const { return _matViewProjInv; } + + inline void setFrustum(const geometry::Frustum &val) { + *_frustum = val; + } + inline const geometry::Frustum &getFrustum() const { return *_frustum; } + + inline void setWindow(RenderWindow *val) { _window = val; } + inline RenderWindow *getWindow() const { return _window; } + + inline void setForward(const Vec3 &val) { _forward = val; } + inline const Vec3 &getForward() const { return _forward; } + + inline void setPosition(const Vec3 &val) { _position = val; } + inline const Vec3 &getPosition() const { return _position; } + + inline void setVisibility(uint32_t vis) { _visibility = vis; } + inline uint32_t getVisibility() const { return _visibility; } + + inline uint32_t getPriority() const { return _priority; } + inline void setPriority(uint32_t val) { _priority = val; } + + inline void setAperture(CameraAperture val) { + _aperture = val; + _apertureValue = Camera::FSTOPS[static_cast(_aperture)]; + updateExposure(); + } + inline CameraAperture getAperture() const { return _aperture; } + + inline float getApertureValue() const { return _apertureValue; } + + inline void setShutter(CameraShutter val) { + _shutter = val; + _shutterValue = Camera::SHUTTERS[static_cast(_shutter)]; + updateExposure(); + } + inline CameraShutter getShutter() const { return _shutter; } + + inline float getShutterValue() const { return _shutterValue; } + + inline void setIso(CameraISO val) { + _iso = val; + _isoValue = Camera::ISOS[static_cast(_iso)]; + updateExposure(); + } + inline CameraISO getIso() const { return _iso; } + + inline float getIsoValue() const { return _isoValue; } + + inline void setEc(float val) { _ec = val; } + inline float getEc() const { return _ec; } + + inline float getExposure() const { return _exposure; } + + inline gfx::ClearFlagBit getClearFlag() const { return _clearFlag; } + inline void setClearFlag(gfx::ClearFlagBit flag) { _clearFlag = flag; } + + inline float getClearDepth() const { return _clearDepth; } + inline void setClearDepth(float depth) { _clearDepth = depth; } + + inline uint32_t getClearStencil() const { return _clearStencil; } + inline void setClearStencil(uint32_t stencil) { _clearStencil = stencil; } + + inline bool isWindowSize() const { return _isWindowSize; } + inline void setWindowSize(bool val) { _isWindowSize = val; } + + inline float getScreenScale() const { return _screenScale; } + inline void setScreenScale(float val) { _screenScale = val; } + + void detachCamera(); + +protected: + void setExposure(float ev100); + +private: + void updateExposure(); + void updateAspect(bool oriented = true); + + bool _isWindowSize{true}; + float _screenScale{0.F}; + gfx::Device * _device{nullptr}; + RenderScene * _scene{nullptr}; + IntrusivePtr _node; + std::string _name; + bool _enabled{false}; + CameraProjection _proj{CameraProjection::UNKNOWN}; + float _aspect{0.F}; + float _orthoHeight{10.0F}; + CameraFOVAxis _fovAxis{CameraFOVAxis::VERTICAL}; + float _fov{static_cast(mathutils::toRadian(45.F))}; + float _nearClip{1.0F}; + float _farClip{1000.0F}; + gfx::Color _clearColor{0.2, 0.2, 0.2, 1}; + Vec4 _viewport{0, 0, 1, 1}; + Vec4 _orientedViewport{0, 0, 1, 1}; + gfx::SurfaceTransform _curTransform{gfx::SurfaceTransform::IDENTITY}; + bool _isProjDirty{true}; + Mat4 _matView; + Mat4 _matProj; + Mat4 _matProjInv; + Mat4 _matViewProj; + Mat4 _matViewProjInv; + geometry::Frustum * _frustum{nullptr}; + Vec3 _forward; + Vec3 _position; + uint32_t _priority{0}; + CameraAperture _aperture{CameraAperture::F16_0}; + float _apertureValue{0.F}; + CameraShutter _shutter{CameraShutter::D125}; + float _shutterValue{0.F}; + CameraISO _iso{CameraISO::ISO100}; + float _isoValue{0.F}; + float _ec = {0.F}; + RenderWindow * _window{nullptr}; + uint32_t _width{0}; + uint32_t _height{0}; + gfx::ClearFlagBit _clearFlag{gfx::ClearFlagBit::NONE}; + float _clearDepth{1.0F}; + + static const std::vector FSTOPS; + static const std::vector SHUTTERS; + static const std::vector ISOS; + + uint32_t _visibility = pipeline::CAMERA_DEFAULT_MASK; + float _exposure{0.F}; + uint32_t _clearStencil{0}; + + CC_DISALLOW_COPY_MOVE_ASSIGN(Camera); }; } // namespace scene diff --git a/native/cocos/scene/Define.cpp b/native/cocos/scene/Define.cpp index 16b183278d..8ae05dc4b2 100644 --- a/native/cocos/scene/Define.cpp +++ b/native/cocos/scene/Define.cpp @@ -28,7 +28,5 @@ namespace cc { namespace scene { -Root* Root::instance = nullptr; - } // namespace scene } // namespace cc diff --git a/native/cocos/scene/Define.h b/native/cocos/scene/Define.h index b4d5d93615..3916bf1fb2 100644 --- a/native/cocos/scene/Define.h +++ b/native/cocos/scene/Define.h @@ -25,166 +25,16 @@ #pragma once +#include #include -#include "math/Mat4.h" -#include "math/Vec2.h" -#include "math/Vec3.h" -#include "math/Vec4.h" -#include "renderer/gfx-base/GFXInputAssembler.h" -#include "renderer/gfx-base/GFXShader.h" -#include "scene/Model.h" +#include "renderer/core/PassUtils.h" namespace cc { namespace scene { -// As Pass.h will include Define.h, so use forward declaration. -class Pass; - -struct Fog { - bool enabled{false}; - bool accurate{false}; - uint32_t type{0}; - float density{0.0F}; - float start{0.0F}; - float end{0.0F}; - float atten{0.0F}; - float top{0.0F}; - float range{0.0F}; - Vec4 color; -}; - -enum class ShadowType { - PLANAR = 0, - SHADOWMAP = 1 -}; - -enum class TransformBit { - NONE = 0, - POSITION = (1 << 0), - ROTATION = (1 << 1), - SCALE = (1 << 2), - RS = ROTATION | SCALE, - TRS = POSITION | ROTATION | SCALE, - TRS_MASK = ~TRS, -}; - -struct Shadow { - bool enabled{false}; - bool dirty{false}; - bool shadowMapDirty{false}; - bool fixedArea{false}; - ShadowType shadowType{ShadowType::PLANAR}; - float invisibleOcclusionRange{0.0F}; - float shadowDistance{0.0F}; - float distance{0.0F}; - Pass * instancePass{nullptr}; - Pass * planarPass{nullptr}; - float nearValue{0.0F}; - float farValue{0.0F}; - uint32_t pcfType{0}; - float bias{0.0F}; - float normalBias{0.0F}; - float saturation{0.0F}; - float orthoSize{0.0F}; - - Vec4 color; - Vec2 size; - Vec3 normal; - Mat4 matLight; -}; - -struct Skybox { - bool enabled{false}; - bool isRGBE{false}; - bool useIBL{false}; - bool useHDR{true}; - bool useDiffuseMap{false}; - Model *model{nullptr}; -}; - -struct Ambient { - bool enabled{false}; - float skyIllum{0.0F}; - Vec4 skyColor; - Vec4 groundAlbedo; -}; - -struct OctreeInfo { - bool enabled{false}; - Vec3 minPos; - Vec3 maxPos; - uint32_t depth{0}; -}; - -struct PipelineSharedSceneData { - bool isHDR{true}; - float shadingScale{1.0F}; - Ambient * ambient{nullptr}; - Shadow * shadow{nullptr}; - Skybox * skybox{nullptr}; - Fog * fog{nullptr}; - OctreeInfo * octree{nullptr}; - std::vector geometryRendererPasses; - std::vector geometryRendererShaders; - gfx::InputAssembler * occlusionQueryInputAssembler{nullptr}; - Pass * occlusionQueryPass{nullptr}; - gfx::Shader * occlusionQueryShader{nullptr}; - Pass * deferredLightPass{nullptr}; - gfx::Shader * deferredLightPassShader{nullptr}; - Pass * bloomPrefilterPass{nullptr}; - gfx::Shader * bloomPrefilterPassShader{nullptr}; - std::vector bloomDownsamplePass; - gfx::Shader * bloomDownsamplePassShader{nullptr}; - std::vector bloomUpsamplePass; - gfx::Shader * bloomUpsamplePassShader{nullptr}; - Pass * bloomCombinePass{nullptr}; - gfx::Shader * bloomCombinePassShader{nullptr}; - Pass * pipelinePostPass{nullptr}; - gfx::Shader * pipelinePostPassShader{nullptr}; -}; - -struct FlatBuffer { - uint32_t stride{0}; - uint32_t count{0}; - uint32_t size{0}; - uint8_t *data{nullptr}; -}; - -struct RenderingSubMesh { - RenderingSubMesh() = default; - std::vector flatBuffers; -}; - -struct Root { - Root() { - Root::instance = this; - } - - ~Root() { - Root::instance = nullptr; - } - - float cumulativeTime{0}; - float frameTime{0}; - - static Root *instance; -}; - -enum class RenderPriority { - MIN = 0, - MAX = 0xff, - DEFAULT = 0x80, -}; - -enum class RenderPassStage { - DEFAULT = 100, - UI = 200, -}; - -enum class BatchingSchemes { - NONE = 0, - INSTANCING = 1, - VB_MERGING = 2, +struct IMacroPatch { + std::string name; + MacroValue value; }; } // namespace scene diff --git a/native/cocos/scene/DirectionalLight.cpp b/native/cocos/scene/DirectionalLight.cpp index 14953eb18b..284380ad2c 100644 --- a/native/cocos/scene/DirectionalLight.cpp +++ b/native/cocos/scene/DirectionalLight.cpp @@ -24,12 +24,20 @@ ****************************************************************************/ #include "scene/DirectionalLight.h" +#include "core/scene-graph/Node.h" namespace cc { namespace scene { +void DirectionalLight::initialize() { + Light::initialize(); + + setIlluminance(Ambient::SUN_ILLUM); + _dir.set(1.0F, -1.0F, -1.0F); +} + void DirectionalLight::update() { - if (_node && _node->getFlagsChanged()) { + if (_node && _node->getChangedFlags()) { _dir = _forward; _node->updateWorldTransform(); _dir.transformQuat(_node->getWorldRotation()); diff --git a/native/cocos/scene/DirectionalLight.h b/native/cocos/scene/DirectionalLight.h index 53ddc5b27d..6f5488cfd8 100644 --- a/native/cocos/scene/DirectionalLight.h +++ b/native/cocos/scene/DirectionalLight.h @@ -25,35 +25,50 @@ #pragma once +#include "core/Root.h" #include "math/Vec3.h" +#include "scene/Ambient.h" #include "scene/Light.h" namespace cc { namespace scene { -class DirectionalLight : public Light { +class DirectionalLight final : public Light { public: - DirectionalLight() = default; - DirectionalLight(const DirectionalLight &) = delete; - DirectionalLight(DirectionalLight &&) = delete; - ~DirectionalLight() override = default; - DirectionalLight &operator=(const DirectionalLight &) = delete; - DirectionalLight &operator=(DirectionalLight &&) = delete; + DirectionalLight() { _type = LightType::DIRECTIONAL; } + ~DirectionalLight() override = default; + void initialize() override; void update() override; - inline void setDirection(const Vec3 &dir) { _dir = dir; } - inline void setIlluminanceHDR(float illum) { _illuminanceHDR = illum; } - inline void setIlluminanceLDR(float illum) { _illuminanceLDR = illum; } - inline const Vec3 &getDirection() const { return _dir; } + inline void setDirection(const Vec3 &dir) { _dir = dir; } + inline void setIlluminanceHDR(float value) { _illuminanceHDR = value; } + inline void setIlluminanceLDR(float value) { _illuminanceLDR = value; } inline float getIlluminanceHDR() const { return _illuminanceHDR; } inline float getIlluminanceLDR() const { return _illuminanceLDR; } + inline float getIlluminance() const { + const bool isHDR = Root::getInstance()->getPipeline()->getPipelineSceneData()->isHDR(); + if (isHDR) { + return _illuminanceHDR; + } + return _illuminanceLDR; + } + inline void setIlluminance(float value) { + const bool isHDR = Root::getInstance()->getPipeline()->getPipelineSceneData()->isHDR(); + if (isHDR) { + _illuminanceHDR = value; + } else { + _illuminanceLDR = value; + } + } private: - float _illuminanceHDR{0.F}; - float _illuminanceLDR{0.F}; - Vec3 _dir; + float _illuminanceHDR{Ambient::SUN_ILLUM}; + float _illuminanceLDR{1.F}; + Vec3 _dir{1.0F, -1.0F, -1.0F}; + + CC_DISALLOW_COPY_MOVE_ASSIGN(DirectionalLight); }; } // namespace scene diff --git a/native/cocos/scene/Fog.cpp b/native/cocos/scene/Fog.cpp new file mode 100644 index 0000000000..64500cc27e --- /dev/null +++ b/native/cocos/scene/Fog.cpp @@ -0,0 +1,149 @@ +/**************************************************************************** + 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 "scene/Fog.h" +#include "core/Root.h" +#include "renderer/pipeline/helper/Utils.h" + +namespace cc { +namespace scene { + +void FogInfo::setEnabled(bool val) const { + if (_isEnabled == val) { + return; + } + + if (_resource != nullptr) { + _resource->setEnabled(val); + if (val) { + _resource->setType(_type); + } + } +} + +void FogInfo::setFogColor(const Color &val) { + _fogColor.set(val); + if (_resource != nullptr) { + _resource->setFogColor(_fogColor); + } +} + +void FogInfo::setType(FogType val) { + _type = val; + if (_resource != nullptr) { + _resource->setType(_type); + } +} + +void FogInfo::setFogDensity(float val) { + _fogDensity = val; + if (_resource) { + _resource->setFogDensity(_fogDensity); + } +} + +void FogInfo::setFogStart(float val) { + _fogStart = val; + if (_resource != nullptr) { + _resource->setFogStart(_fogStart); + } +} + +void FogInfo::setFogEnd(float val) { + _fogEnd = val; + if (_resource != nullptr) { + _resource->setFogEnd(_fogEnd); + } +} + +void FogInfo::setFogAtten(float val) { + _fogAtten = val; + if (_resource != nullptr) { + _resource->setFogAtten(_fogAtten); + } +} + +void FogInfo::setFogTop(float val) { + _fogTop = val; + if (_resource != nullptr) { + _resource->setFogTop(_fogTop); + } +} + +void FogInfo::setFogRange(float val) { + _fogRange = val; + if (_resource != nullptr) { + _resource->setfogRange(_fogRange); + } +} + +void FogInfo::activate(Fog *resource) { + _resource = resource; + _resource->initialize(*this); + _resource->activate(); +} + +// +void Fog::initialize(const FogInfo &fogInfo) { + setFogColor(fogInfo.getFogColor()); + _enabled = fogInfo.isEnabled(); + _accurate = fogInfo.isAccurate(); + _type = _enabled ? fogInfo.getType() : FogType::NONE; + _fogDensity = fogInfo.getFogDensity(); + _fogStart = fogInfo.getFogStart(); + _fogEnd = fogInfo.getFogEnd(); + _fogAtten = fogInfo.getFogAtten(); + _fogTop = fogInfo.getFogTop(); + _fogRange = fogInfo.getFogRange(); +} + +void Fog::updatePipeline() { + auto * root = Root::getInstance(); + const FogType value = _enabled ? _type : FogType::NONE; + const int32_t accurateValue = isAccurate() ? 1 : 0; + auto * pipeline = root->getPipeline(); + auto iterMacroFog = pipeline->getMacros().find("CC_USE_FOG"); + auto iterMacroAccurateFog = pipeline->getMacros().find("CC_USE_ACCURATE_FOG"); + if (iterMacroFog != pipeline->getMacros().end() && iterMacroAccurateFog != pipeline->getMacros().end()) { + const MacroValue ¯oFog = iterMacroFog->second; + const MacroValue ¯oAccurateFog = iterMacroAccurateFog->second; + const int32_t * macroFogPtr = cc::get_if(¯oFog); + const int32_t * macroAccurateFogPtr = cc::get_if(¯oAccurateFog); + if (macroFogPtr != nullptr && *macroFogPtr == static_cast(value) && macroAccurateFogPtr != nullptr && *macroAccurateFogPtr == accurateValue) return; + } + + pipeline->setValue("CC_USE_FOG", static_cast(value)); + pipeline->setValue("CC_USE_ACCURATE_FOG", accurateValue); + root->onGlobalPipelineStateChanged(); +} + +void Fog::setFogColor(const Color &val) { + _fogColor.set(val); + Vec4 v4(static_cast(val.r) / 255.F, static_cast(val.g) / 255.F, static_cast(val.b) / 255.F, static_cast(val.a) / 255.F); + pipeline::srgbToLinear(&_colorArray, v4); +} + +} // namespace scene +} // namespace cc diff --git a/native/cocos/scene/Fog.h b/native/cocos/scene/Fog.h new file mode 100644 index 0000000000..71e5f9ce0f --- /dev/null +++ b/native/cocos/scene/Fog.h @@ -0,0 +1,350 @@ +/**************************************************************************** + 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 +#include "base/Macros.h" +#include "base/RefCounted.h" +#include "math/Color.h" + +namespace cc { +namespace scene { + +enum class FogType { + /** + * @zh + * 线性雾。 + * @en + * Linear fog + * @readonly + */ + LINEAR = 0, + /** + * @zh + * 指数雾。 + * @en + * Exponential fog + * @readonly + */ + EXP = 1, + /** + * @zh + * 指数平方雾。 + * @en + * Exponential square fog + * @readonly + */ + EXP_SQUARED = 2, + /** + * @zh + * 层叠雾。 + * @en + * Layered fog + * @readonly + */ + LAYERED = 3, + NONE = 4 +}; + +class FogInfo; + +class Fog final { +public: + Fog() = default; + ~Fog() = default; + + void initialize(const FogInfo &fogInfo); + + inline void activate() { updatePipeline(); } + + /** + * @zh 是否启用全局雾效 + * @en Enable global fog + */ + inline void setEnabled(bool val) { + _enabled = val; + if (!val) { + _type = FogType::NONE; + updatePipeline(); + } else { + activate(); + } + } + inline bool isEnabled() const { return _enabled; } + + /** + * @zh 是否启用精确雾效(像素雾)计算 + * @en Enable accurate fog (pixel fog) + */ + inline void setAccurate(bool val) { + _accurate = val; + updatePipeline(); + } + inline bool isAccurate() const { return _accurate; } + + /** + * @zh 全局雾颜色 + * @en Global fog color + */ + void setFogColor(const Color &val); + inline const Color &getFogColor() const { return _fogColor; } + + /** + * @zh 当前雾化类型。 + * @en The current global fog type. + * @returns {FogType} + * Returns the current global fog type + * - -1:Disable global Fog + * - 0:Linear fog + * - 1:Exponential fog + * - 2:Exponential square fog + * - 3:Layered fog + */ + inline FogType getType() const { return _type; } + inline void setType(FogType val) { + _type = _enabled ? val : FogType::NONE; + if (_enabled) { + updatePipeline(); + } + } + + /** + * @zh 全局雾浓度 + * @en Global fog density + */ + inline float getFogDensity() const { return _fogDensity; } + inline void setFogDensity(float val) { _fogDensity = val; } + + /** + * @zh 雾效起始位置,只适用于线性雾 + * @en Global fog start position, only for linear fog + */ + inline float getFogStart() const { return _fogStart; } + inline void setFogStart(float val) { _fogStart = val; } + + /** + * @zh 雾效结束位置,只适用于线性雾 + * @en Global fog end position, only for linear fog + */ + float getFogEnd() const { return _fogEnd; } + void setFogEnd(float val) { _fogEnd = val; } + + /** + * @zh 雾效衰减 + * @en Global fog attenuation + */ + inline float getFogAtten() const { return _fogAtten; } + inline void setFogAtten(float val) { _fogAtten = val; } + + /** + * @zh 雾效顶部范围,只适用于层级雾 + * @en Global fog top range, only for layered fog + */ + inline float getFogTop() const { return _fogTop; } + + inline void setFogTop(float val) { _fogTop = val; } + + /** + * @zh 雾效范围,只适用于层级雾 + * @en Global fog range, only for layered fog + */ + inline float getFogRange() const { return _fogRange; } + inline void setfogRange(float val) { _fogRange = val; } + + const Vec4 &getColorArray() const { return _colorArray; } + +private: + void updatePipeline(); + + Color _fogColor{200, 200, 200, 255}; + Vec4 _colorArray{0.2F, 0.2F, 0.2F, 1.0F}; + bool _enabled{false}; + bool _accurate{false}; + FogType _type{FogType::LINEAR}; + float _fogDensity{0.3F}; + float _fogStart{0.5F}; + float _fogEnd{300.F}; + float _fogAtten{5.F}; + float _fogTop{1.5F}; + float _fogRange{1.2F}; + + CC_DISALLOW_COPY_MOVE_ASSIGN(Fog); +}; + +class FogInfo : public RefCounted { +public: + FogInfo() = default; + ~FogInfo() override = default; + /** + * @zh 是否启用全局雾效 + * @en Enable global fog + */ + void setEnabled(bool val) const; + inline bool isEnabled() const { return _isEnabled; } + + /** + * @zh 是否启用精确雾效(像素雾)计算 + * @en Enable accurate fog (pixel fog) + */ + // @editable + // @tooltip('i18n:fog.accurate') + inline void setAccurate(bool val) { + if (_accurate == val) return; + _accurate = val; + if (_resource != nullptr) { + _resource->setAccurate(val); + if (val) { + _resource->setType(_type); + } + } + } + inline bool isAccurate() const { return _accurate; } + + /** + * @zh 全局雾颜色 + * @en Global fog color + */ + // @editable + // @tooltip('i18n:fog.fogColor') + void setFogColor(const Color &val); + inline const Color &getFogColor() const { return _fogColor; } + + /** + * @zh 全局雾类型 + * @en Global fog type + */ + // @editable + // @type(FogType) + // @tooltip('i18n:fog.type') + void setType(FogType val); + inline FogType getType() const { return _type; } + + /** + * @zh 全局雾浓度 + * @en Global fog density + */ + // @visible(function (this: FogInfo) { + // return this._type !== FogType.LAYERED && this._type !== FogType.LINEAR; + // }) + // @type(CCFloat) + // @range([0, 1]) + // @rangeStep(0.01) + // @slide + // @displayOrder(3) + // @tooltip('i18n:fog.fogDensity') + void setFogDensity(float val); + inline float getFogDensity() const { return _fogDensity; } + + // /** + // * @zh 雾效起始位置 + // * @en Global fog start position + // */ + // @visible(function (this: FogInfo) { return this._type !== FogType.LAYERED; }) + // @type(CCFloat) + // @rangeStep(0.01) + // @displayOrder(4) + // @tooltip('i18n:fog.fogStart') + void setFogStart(float val); + inline float getFogStart() const { return _fogStart; } + + // /** + // * @zh 雾效结束位置,只适用于线性雾 + // * @en Global fog end position, only for linear fog + // */ + // @visible(function (this: FogInfo) { return this._type === FogType.LINEAR; }) + // @type(CCFloat) + // @rangeStep(0.01) + // @displayOrder(5) + // @tooltip('i18n:fog.fogEnd') + void setFogEnd(float val); + inline float getFogEnd() const { return _fogEnd; } + + /** + * @zh 雾效衰减 + * @en Global fog attenuation + */ + // @visible(function (this: FogInfo) { return this._type !== FogType.LINEAR; }) + // @type(CCFloat) + // @rangeMin(0.01) + // @rangeStep(0.01) + // @displayOrder(6) + // @tooltip('i18n:fog.fogAtten') + void setFogAtten(float val); + inline float getFogAtten() const { return _fogAtten; } + + /** + * @zh 雾效顶部范围,只适用于层级雾 + * @en Global fog top range, only for layered fog + */ + // @visible(function (this: FogInfo) { return this._type === FogType.LAYERED; }) + // @type(CCFloat) + // @rangeStep(0.01) + // @displayOrder(7) + // @tooltip('i18n:fog.fogTop') + void setFogTop(float val); + inline float getFogTop() const { return _fogTop; } + + /** + * @zh 雾效范围,只适用于层级雾 + * @en Global fog range, only for layered fog + */ + // @visible(function (this: FogInfo) { return this._type === FogType.LAYERED; }) + // @type(CCFloat) + // @rangeStep(0.01) + // @displayOrder(8) + // @tooltip('i18n:fog.fogRange') + void setFogRange(float val); + inline float getFogRange() const { return _fogRange; } + + void activate(Fog *resource); + + //cjh JSB need to bind the property, so need to make it public + //private: + // @serializable + FogType _type{FogType::LINEAR}; + // @serializable + Color _fogColor{200, 200, 200, 255}; + // @serializable + bool _isEnabled{false}; + // @serializable + float _fogDensity{0.3F}; + // @serializable + float _fogStart{0.5F}; + // @serializable + float _fogEnd{0.5F}; + // @serializable + float _fogAtten{5.F}; + // @serializable + float _fogTop{1.5F}; + // @serializable + float _fogRange{1.2F}; + // @serializable + bool _accurate{false}; + Fog *_resource{nullptr}; +}; + +} // namespace scene +} // namespace cc diff --git a/native/cocos/scene/Frustum.cpp b/native/cocos/scene/Frustum.cpp deleted file mode 100644 index 939a4e617a..0000000000 --- a/native/cocos/scene/Frustum.cpp +++ /dev/null @@ -1,184 +0,0 @@ -/**************************************************************************** - 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 "scene/Frustum.h" -#include "scene/Define.h" - -namespace cc { -namespace scene { -namespace { -const std::vector VEC_VALS{ - {1, 1, 1}, - {-1, 1, 1}, - {-1, -1, 1}, - {1, -1, 1}, - {1, 1, -1}, - {-1, 1, -1}, - {-1, -1, -1}, - {1, -1, -1}}; -} // namespace - -// Define from 3 vertices. -void Plane::define(const Vec3 &v0, const Vec3 &v1, const Vec3 &v2) { - const Vec3 dist1 = v1 - v0; - const Vec3 dist2 = v2 - v0; - - Vec3 dist; - Vec3::crossProduct(dist1, dist2, &dist); - define(dist, v0); -} - -// Define from a normal vector and a point on the plane. -void Plane::define(const Vec3 &normal, const Vec3 &point) { - n = normal.getNormalized(); - d = n.dot(point); -} - -// Return signed distance to a point. -float Plane::distance(const Vec3 &point) const { - return n.dot(point) - d; -} - -Plane Plane::clone() const { - Plane plane; - plane.n.set(n); - plane.d = d; - - return plane; -} - -void Frustum::createOrtho(const float width, const float height, const float near, const float far, const Mat4 &transform) { - const float halfWidth = width * 0.5F; - const float halfHeight = height * 0.5F; - - vertices[0].transformMat4(Vec3(halfWidth, halfHeight, -near), transform); - vertices[1].transformMat4(Vec3(-halfWidth, halfHeight, -near), transform); - vertices[2].transformMat4(Vec3(-halfWidth, -halfHeight, -near), transform); - vertices[3].transformMat4(Vec3(halfWidth, -halfHeight, -near), transform); - vertices[4].transformMat4(Vec3(halfWidth, halfHeight, -far), transform); - vertices[5].transformMat4(Vec3(-halfWidth, halfHeight, -far), transform); - vertices[6].transformMat4(Vec3(-halfWidth, -halfHeight, -far), transform); - vertices[7].transformMat4(Vec3(halfWidth, -halfHeight, -far), transform); - - updatePlanes(); -} - -void Frustum::split(float start, float end, float aspect, float fov, const Mat4 &transform) { - const float h = tanf(fov * 0.5F); - const float w = h * aspect; - const Vec3 nearTemp(start * w, start * h, start); - const Vec3 farTemp(end * w, end * h, end); - - vertices[0].transformMat4(Vec3(nearTemp.x, nearTemp.y, nearTemp.z), transform); - vertices[1].transformMat4(Vec3(-nearTemp.x, nearTemp.y, nearTemp.z), transform); - vertices[2].transformMat4(Vec3(-nearTemp.x, -nearTemp.y, nearTemp.z), transform); - vertices[3].transformMat4(Vec3(nearTemp.x, -nearTemp.y, nearTemp.z), transform); - vertices[4].transformMat4(Vec3(farTemp.x, farTemp.y, farTemp.z), transform); - vertices[5].transformMat4(Vec3(-farTemp.x, farTemp.y, farTemp.z), transform); - vertices[6].transformMat4(Vec3(-farTemp.x, -farTemp.y, farTemp.z), transform); - vertices[7].transformMat4(Vec3(farTemp.x, -farTemp.y, farTemp.z), transform); - - updatePlanes(); -} - -void Frustum::updatePlanes() { - // left plane - planes[0].define(vertices[1], vertices[6], vertices[5]); - // right plane - planes[1].define(vertices[3], vertices[4], vertices[7]); - // bottom plane - planes[2].define(vertices[6], vertices[3], vertices[7]); - // top plane - planes[3].define(vertices[0], vertices[5], vertices[4]); - // near plane - planes[4].define(vertices[2], vertices[0], vertices[3]); - // far plane - planes[5].define(vertices[7], vertices[5], vertices[6]); -} - -void Frustum::update(const Mat4 &m, const Mat4 &inv) { - // left plane - planes[0].n.set(m.m[3] + m.m[0], m.m[7] + m.m[4], m.m[11] + m.m[8]); - planes[0].d = -(m.m[15] + m.m[12]); - // right plane - planes[1].n.set(m.m[3] - m.m[0], m.m[7] - m.m[4], m.m[11] - m.m[8]); - planes[1].d = -(m.m[15] - m.m[12]); - // bottom plane - planes[2].n.set(m.m[3] + m.m[1], m.m[7] + m.m[5], m.m[11] + m.m[9]); - planes[2].d = -(m.m[15] + m.m[13]); - // top plane - planes[3].n.set(m.m[3] - m.m[1], m.m[7] - m.m[5], m.m[11] - m.m[9]); - planes[3].d = -(m.m[15] - m.m[13]); - // near plane - planes[4].n.set(m.m[3] + m.m[2], m.m[7] + m.m[6], m.m[11] + m.m[10]); - planes[4].d = -(m.m[15] + m.m[14]); - // far plane - planes[5].n.set(m.m[3] - m.m[2], m.m[7] - m.m[6], m.m[11] - m.m[10]); - planes[5].d = -(m.m[15] - m.m[14]); - - if (type != ShapeEnums::SHAPE_FRUSTUM_ACCURATE) { - return; - } - - for (Plane &plane : planes) { - float invDist = 1 / plane.n.length(); - plane.n *= invDist; - plane.d *= invDist; - } - uint32_t i = 0; - for (const Vec3 &vec : VEC_VALS) { - vertices[i].transformMat4(vec, inv); - i++; - } -} - -Frustum Frustum::clone() { - Frustum frustum; - for (uint i = 0; i < planes.size(); ++i) { - frustum.planes[i] = planes[i].clone(); - } - - frustum.type = type; - - for (uint i = 0; i < vertices.size(); ++i) { - frustum.vertices[i].set(vertices[i]); - } - - return frustum; -} - -void Frustum::transform(const Mat4 &transform) { - vertices[0].transformMat4(vertices[0], transform); - vertices[1].transformMat4(vertices[1], transform); - vertices[2].transformMat4(vertices[2], transform); - vertices[3].transformMat4(vertices[3], transform); - vertices[4].transformMat4(vertices[4], transform); - vertices[5].transformMat4(vertices[5], transform); - vertices[6].transformMat4(vertices[6], transform); - vertices[7].transformMat4(vertices[7], transform); -} - -} // namespace scene -} // namespace cc \ No newline at end of file diff --git a/native/cocos/scene/Light.cpp b/native/cocos/scene/Light.cpp index 864a623c2c..734b8cd767 100644 --- a/native/cocos/scene/Light.cpp +++ b/native/cocos/scene/Light.cpp @@ -24,9 +24,14 @@ ****************************************************************************/ #include "scene/Light.h" +#include "math/Math.h" namespace cc { namespace scene { +float Light::nt2lm(float size) { + return 4 * math::PI * math::PI * size * size; +} + } // namespace scene } // namespace cc diff --git a/native/cocos/scene/Light.h b/native/cocos/scene/Light.h index c7c319b3d7..7c34f94e14 100644 --- a/native/cocos/scene/Light.h +++ b/native/cocos/scene/Light.h @@ -25,12 +25,17 @@ #pragma once +#include +#include "base/Ptr.h" +#include "base/RefCounted.h" +#include "core/scene-graph/Node.h" #include "math/Vec3.h" -#include "scene/Node.h" namespace cc { namespace scene { +class RenderScene; + enum class LightType { DIRECTIONAL, SPHERE, @@ -38,41 +43,68 @@ enum class LightType { UNKNOWN, }; -class Light { +class Light : public RefCounted { public: - Light() = default; - Light(const Light &) = delete; - Light(Light &&) = delete; - virtual ~Light() = default; - Light &operator=(const Light &) = delete; - Light &operator=(const Light &&) = delete; + Light() = default; + ~Light() override = default; - virtual void update() = 0; + inline void attachToScene(RenderScene *scene) { _scene = scene; } + inline void detachFromScene() { _scene = nullptr; } - inline void setColor(const Vec3 &color) { _color = color; } - inline void setColorTemperatureRGB(const Vec3 &value) { _colorTemperatureRGB = value; } - inline void setNode(Node *node) { - _node = node; + inline void destroy() { + _name.clear(); + _node = nullptr; } - inline void setUseColorTemperature(bool value) { _useColorTemperature = value; } - inline void setBaked(bool value) { _baked = value; } - inline void setType(LightType type) { _type = type; } + + virtual void initialize() { + _color = Vec3(1, 1, 1); + _colorTemp = 6550.F; + } + + virtual void update(){}; + + inline bool isBaked() const { return _baked; } + inline void setBaked(bool val) { _baked = val; } inline const Vec3 &getColor() const { return _color; } + inline void setColor(const Vec3 &color) { _color = color; } + + inline bool isUseColorTemperature() const { return _useColorTemperature; } + inline void setUseColorTemperature(bool value) { _useColorTemperature = value; } + + inline float getColorTemperature() const { return _colorTemp; } + inline void setColorTemperature(float val) { _colorTemp = val; } + + inline Node *getNode() const { return _node.get(); } + inline void setNode(Node *node) { _node = node; } + + inline LightType getType() const { return _type; } + inline void setType(LightType type) { _type = type; } + + inline const std::string &getName() const { return _name; } + inline void setName(const std::string &name) { _name = name; } + + inline RenderScene *getScene() const { return _scene; } + inline const Vec3 &getColorTemperatureRGB() const { return _colorTemperatureRGB; } - inline Node * getNode() const { return _node; } - inline LightType getType() const { return _type; } - inline bool getUseColorTemperature() const { return _useColorTemperature; } - inline bool getBaked() const { return _baked; } + inline void setColorTemperatureRGB(const Vec3 &value) { _colorTemperatureRGB = value; } + + static float nt2lm(float size); protected: - bool _useColorTemperature{false}; - bool _baked{false}; - Node * _node{nullptr}; - LightType _type{LightType::UNKNOWN}; - Vec3 _color; - Vec3 _colorTemperatureRGB; - Vec3 _forward{0, 0, -1}; + bool _useColorTemperature{false}; + bool _baked{false}; + IntrusivePtr _node; + float _colorTemp{6550.F}; + LightType _type{LightType::UNKNOWN}; + std::string _name; + RenderScene * _scene{nullptr}; + Vec3 _color{1, 1, 1}; + Vec3 _colorTemperatureRGB; + Vec3 _forward{0, 0, -1}; + +private: + CC_DISALLOW_COPY_MOVE_ASSIGN(Light); }; } // namespace scene diff --git a/native/cocos/scene/Model.cpp b/native/cocos/scene/Model.cpp index 4413510783..4a690a852c 100644 --- a/native/cocos/scene/Model.cpp +++ b/native/cocos/scene/Model.cpp @@ -22,66 +22,222 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ****************************************************************************/ -#include "scene/Model.h" +#include + +// #include "core/Director.h" +#include "core/Root.h" +#include "core/TypedArray.h" +#include "core/assets/Material.h" +#include "core/event/EventTypesToJS.h" +#include "gfx-base/GFXTexture.h" #include "renderer/pipeline/Define.h" -#include "renderer/pipeline/RenderPipeline.h" +#include "renderer/pipeline/InstancedBuffer.h" +#include "scene/Model.h" +#include "scene/Pass.h" #include "scene/RenderScene.h" #include "scene/SubModel.h" +namespace { +cc::TypedArray getTypedArrayConstructor(const cc::gfx::FormatInfo &info, cc::ArrayBuffer *buffer, uint32_t byteOffset, uint32_t length) { + const uint32_t stride = info.size / info.count; + switch (info.type) { + case cc::gfx::FormatType::UNORM: + case cc::gfx::FormatType::UINT: { + switch (stride) { + case 1: return cc::Uint8Array(buffer, byteOffset, length); + case 2: return cc::Uint16Array(buffer, byteOffset, length); + case 4: return cc::Uint32Array(buffer, byteOffset, length); + default: + break; + } + break; + } + case cc::gfx::FormatType::SNORM: + case cc::gfx::FormatType::INT: { + switch (stride) { + case 1: return cc::Int8Array(buffer, byteOffset, length); + case 2: return cc::Int16Array(buffer, byteOffset, length); + case 4: return cc::Int32Array(buffer, byteOffset, length); + default: + break; + } + break; + } + case cc::gfx::FormatType::FLOAT: { + return cc::Float32Array(buffer, byteOffset, length); + } + default: + break; + } + return cc::Float32Array(buffer, byteOffset, length); +} + +cc::Float32Array &vec4ToFloat32Array(const cc::Vec4 &v, cc::Float32Array &out, index_t ofs = 0) { + out[ofs + 0] = v.x; + out[ofs + 1] = v.y; + out[ofs + 2] = v.z; + out[ofs + 3] = v.w; + return out; +} + +cc::Float32Array &mat4ToFloat32Array(const cc::Mat4 &mat, cc::Float32Array &out, index_t ofs = 0) { + memcpy(reinterpret_cast(const_cast(out.buffer()->getData())) + ofs, mat.m, 16 * sizeof(float)); + return out; +} + +const cc::gfx::SamplerInfo LIGHTMAP_SAMPLER_HASH{ + cc::gfx::Filter::LINEAR, + cc::gfx::Filter::LINEAR, + cc::gfx::Filter::NONE, + cc::gfx::Address::CLAMP, + cc::gfx::Address::CLAMP, + cc::gfx::Address::CLAMP, +}; + +const cc::gfx::SamplerInfo LIGHTMAP_SAMPLER_WITH_MIP_HASH{ + cc::gfx::Filter::LINEAR, + cc::gfx::Filter::LINEAR, + cc::gfx::Filter::LINEAR, + cc::gfx::Address::CLAMP, + cc::gfx::Address::CLAMP, + cc::gfx::Address::CLAMP, +}; + +const std::vector SHADOW_MAP_PATCHES{{"CC_ENABLE_DIR_SHADOW", true}, {"CC_RECEIVE_SHADOW", true}}; +const std::string INST_MAT_WORLD = "a_matWorld0"; +} // namespace + namespace cc { namespace scene { -void Model::uploadMat4AsVec4x3(const Mat4 &mat, float *v1, float *v2, float *v3) { - uint size = sizeof(float) * 4; - memcpy(v1, mat.m, size); - memcpy(v2, mat.m + 4, size); - memcpy(v3, mat.m + 8, size); + +Model::Model() { + _device = Root::getInstance()->getDevice(); +} + +void Model::initialize() { + if (_inited) return; + _receiveShadow = true; + _castShadow = false; + _enabled = true; + _visFlags = Layers::Enum::NONE; + _inited = true; + _localData.reset(pipeline::UBOLocal::COUNT); +} + +void Model::destroy() { + for (SubModel *subModel : _subModels) { + CC_SAFE_DESTROY(subModel); + } + _subModels.clear(); + + CC_SAFE_DESTROY_NULL(_localBuffer); + CC_SAFE_DESTROY_NULL(_worldBoundBuffer); + + _worldBounds = nullptr; + _modelBounds = nullptr; + _inited = false; + _localDataUpdated = true; + _transform = nullptr; + _node = nullptr; + _isDynamicBatching = false; +} + +void Model::uploadMat4AsVec4x3(const Mat4 &mat, Float32Array &v1, Float32Array &v2, Float32Array &v3) { + uint32_t copyBytes = sizeof(float) * 3; + auto * buffer = const_cast(v1.buffer()->getData()); + + uint8_t *dst = buffer + v1.byteOffset(); + memcpy(dst, mat.m, copyBytes); v1[3] = mat.m[12]; + + dst = buffer + v2.byteOffset(); + memcpy(dst, mat.m + 4, copyBytes); v2[3] = mat.m[13]; + + dst = buffer + v3.byteOffset(); + memcpy(dst, mat.m + 8, copyBytes); v3[3] = mat.m[14]; } -void Model::updateTransform(uint32_t /*stamp*/) { - Node *node = _transform; - if (node->getFlagsChanged() || node->getDirtyFlag()) { - node->updateWorldTransform(); - _transformUpdated = true; - if (_modelBounds.getValid() && _worldBounds) { - _modelBounds.transform(node->getWorldMatrix(), _worldBounds); +void Model::updateTransform(uint32_t stamp) { + if (isModelImplementedInJS()) { + if (!_isCalledFromJS) { + _eventProcessor.emit(EventTypesToJS::MODEL_UPDATE_TRANSFORM, stamp); + _isCalledFromJS = false; + return; } + } + Node *node = _transform; + if (node->getChangedFlags() || node->getDirtyFlag()) { + node->updateWorldTransform(); + _localDataUpdated = true; + if (_modelBounds != nullptr && _modelBounds->isValid() && _worldBounds != nullptr) { + _modelBounds->transform(node->getWorldMatrix(), _worldBounds); + } if (_scene) { _scene->updateOctree(this); } } } +void Model::updateWorldBound() { + Node *node = _transform; + if (node) { + node->updateWorldTransform(); + _localDataUpdated = true; + if (_modelBounds != nullptr && _modelBounds->isValid() && _worldBounds != nullptr) { + _modelBounds->transform(node->getWorldMatrix(), _worldBounds); + } + } +} + +void Model::updateWorldBoundsForJSSkinningModel(const Vec3 &min, const Vec3 &max) { + Node *node = _transform; + if (node) { + if (_modelBounds != nullptr && _modelBounds->isValid() && _worldBounds != nullptr) { + geometry::AABB::fromPoints(min, max, _modelBounds); + _modelBounds->transform(node->getWorldMatrix(), _worldBounds); + } + } +} + +void Model::updateWorldBoundsForJSBakedSkinningModel(geometry::AABB *aabb) { + _worldBounds->center = aabb->center; + _worldBounds->halfExtents = aabb->halfExtents; +} + void Model::updateUBOs(uint32_t stamp) { + if (isModelImplementedInJS()) { + if (!_isCalledFromJS) { + _eventProcessor.emit(EventTypesToJS::MODEL_UPDATE_UBO, stamp); + _isCalledFromJS = false; + return; + } + } + for (SubModel *subModel : _subModels) { subModel->update(); } _updateStamp = stamp; - if (!_transformUpdated) { + if (!_localDataUpdated) { return; } - _transformUpdated = false; + _localDataUpdated = false; getTransform()->updateWorldTransform(); - const auto & worldMatrix = getTransform()->getWorldMatrix(); - int idx = _instMatWorldIdx; - Mat4 mat4; - std::array bufferView; + const auto &worldMatrix = getTransform()->getWorldMatrix(); + Mat4 mat4; + int idx = _instMatWorldIdx; if (idx >= 0) { - const std::vector &attrs = getInstancedAttributeBlock()->views; - uploadMat4AsVec4x3(worldMatrix, - reinterpret_cast(attrs[idx]), - reinterpret_cast(attrs[idx + 1]), - reinterpret_cast(attrs[idx + 2])); + std::vector &attrs = getInstancedAttributeBlock()->views; + uploadMat4AsVec4x3(worldMatrix, cc::get(attrs[idx]), cc::get(attrs[idx + 1]), cc::get(attrs[idx + 2])); } else if (_localBuffer) { - memcpy(bufferView.data() + pipeline::UBOLocal::MAT_WORLD_OFFSET, worldMatrix.m, sizeof(Mat4)); + mat4ToFloat32Array(worldMatrix, _localData, pipeline::UBOLocal::MAT_WORLD_OFFSET); Mat4::inverseTranspose(worldMatrix, &mat4); - memcpy(bufferView.data() + pipeline::UBOLocal::MAT_WORLD_IT_OFFSET, mat4.m, sizeof(Mat4)); - _localBuffer->update(bufferView.data(), pipeline::UBOLocal::SIZE); - const bool enableOcclusionQuery = pipeline::RenderPipeline::getInstance()->getOcclusionQueryEnabled(); + mat4ToFloat32Array(mat4, _localData, pipeline::UBOLocal::MAT_WORLD_IT_OFFSET); + _localBuffer->update(_localData.buffer()->getData()); + const bool enableOcclusionQuery = pipeline::RenderPipeline::getInstance()->isOcclusionQueryEnabled(); if (enableOcclusionQuery) { updateWorldBoundUBOs(); } @@ -101,13 +257,224 @@ void Model::updateWorldBoundUBOs() { } } -void Model::setSubModel(uint32_t idx, SubModel *subModel) { - subModel->setOwner(this); - if (idx >= static_cast(_subModels.size())) { - _subModels.emplace_back(subModel); +void Model::createBoundingShape(const cc::optional &minPos, const cc::optional &maxPos) { + if (!minPos.has_value() || !maxPos.has_value()) { return; } - _subModels[idx] = subModel; + + _modelBounds = geometry::AABB::fromPoints(minPos.value(), maxPos.value(), new geometry::AABB()); + _worldBounds = geometry::AABB::fromPoints(minPos.value(), maxPos.value(), new geometry::AABB()); +} + +SubModel *Model::createSubModel() { + return new SubModel(); +} + +void Model::initSubModel(index_t idx, cc::RenderingSubMesh *subMeshData, Material *mat) { + initialize(); + bool isNewSubModel = false; + if (idx >= _subModels.size()) { + _subModels.resize(idx + 1, nullptr); + } + + if (_subModels[idx] == nullptr) { + _subModels[idx] = createSubModel(); + isNewSubModel = true; + } else { + CC_SAFE_DESTROY(_subModels[idx]); + } + _subModels[idx]->initialize(subMeshData, mat->getPasses(), getMacroPatches(idx)); + _subModels[idx]->initPlanarShadowShader(); + _subModels[idx]->initPlanarShadowInstanceShader(); + updateAttributesAndBinding(idx); +} + +void Model::setSubModelMesh(index_t idx, cc::RenderingSubMesh *subMesh) const { + if (idx < _subModels.size()) { + _subModels[idx]->setSubMesh(subMesh); + } +} + +void Model::setSubModelMaterial(index_t idx, Material *mat) { + if (idx < _subModels.size()) { + _subModels[idx]->setPasses(mat->getPasses()); + updateAttributesAndBinding(idx); + } +} + +void Model::onGlobalPipelineStateChanged() const { + for (SubModel *subModel : _subModels) { + subModel->onPipelineStateChanged(); + } +} + +void Model::onMacroPatchesStateChanged() { + for (index_t i = 0; i < _subModels.size(); ++i) { + _subModels[i]->onMacroPatchesStateChanged(getMacroPatches(i)); + } +} + +void Model::updateLightingmap(Texture2D *texture, const Vec4 &uvParam) { + vec4ToFloat32Array(uvParam, _localData, pipeline::UBOLocal::LIGHTINGMAP_UVPARAM); //TODO(xwx): toArray not implemented in Math + _localDataUpdated = true; + _lightmap = texture; + _lightmapUVParam = uvParam; + + if (texture == nullptr) { + texture = BuiltinResMgr::getInstance()->get(std::string("empty-texture")); + } + gfx::Texture *gfxTexture = texture->getGFXTexture(); + if (gfxTexture) { + auto *sampler = _device->getSampler(texture->getMipmaps().size() > 1 ? LIGHTMAP_SAMPLER_WITH_MIP_HASH : LIGHTMAP_SAMPLER_HASH); + for (SubModel *subModel : _subModels) { + gfx::DescriptorSet *descriptorSet = subModel->getDescriptorSet(); + // // TODO(Yun Hsiao Wu): should manage lightmap macro switches automatically + // // USE_LIGHTMAP -> CC_USE_LIGHTMAP + descriptorSet->bindTexture(pipeline::LIGHTMAPTEXTURE::BINDING, gfxTexture); + descriptorSet->bindSampler(pipeline::LIGHTMAPTEXTURE::BINDING, sampler); + descriptorSet->update(); + } + } +} + +std::vector &Model::getMacroPatches(index_t subModelIndex) { + if (isModelImplementedInJS()) { + if (!_isCalledFromJS) { + _eventProcessor.emit(EventTypesToJS::MODEL_GET_MACRO_PATCHES, subModelIndex, &_macroPatches); + _isCalledFromJS = false; + return _macroPatches; + } + } + + if (_receiveShadow) { + for (const auto &patch : SHADOW_MAP_PATCHES) { + _macroPatches.emplace_back(patch); + } + } else { + _macroPatches.clear(); + } + + return _macroPatches; +} + +void Model::updateAttributesAndBinding(index_t subModelIndex) { + if (subModelIndex >= _subModels.size()) return; + SubModel *subModel = _subModels[subModelIndex]; + initLocalDescriptors(subModelIndex); + updateLocalDescriptors(subModelIndex, subModel->getDescriptorSet()); + + initWorldBoundDescriptors(subModelIndex); + updateWorldBoundDescriptors(subModelIndex, subModel->getWorldBoundDescriptorSet()); + + gfx::Shader *shader = subModel->getPasses()[0]->getShaderVariant(subModel->getPatches()); + updateInstancedAttributes(shader->getAttributes(), subModel->getPasses()[0]); +} + +index_t Model::getInstancedAttributeIndex(const std::string &name) const { + const auto &attributes = _instanceAttributeBlock.attributes; + for (index_t i = 0; i < attributes.size(); ++i) { + if (attributes[i].name == name) { + return i; + } + } + return CC_INVALID_INDEX; +} + +void Model::updateInstancedAttributes(const std::vector &attributes, Pass *pass) { + if (isModelImplementedInJS()) { + if (!_isCalledFromJS) { + _eventProcessor.emit(EventTypesToJS::MODEL_UPDATE_INSTANCED_ATTRIBUTES, attributes, pass); + _isCalledFromJS = false; + return; + } + } + + if (!pass->getDevice()->hasFeature(gfx::Feature::INSTANCED_ARRAYS)) return; + // free old data + + uint32_t size = 0; + for (const gfx::Attribute &attribute : attributes) { + if (!attribute.isInstanced) continue; + size += gfx::GFX_FORMAT_INFOS[static_cast(attribute.format)].size; + } + auto &attrs = _instanceAttributeBlock; + attrs.buffer = Uint8Array(size); + attrs.views.clear(); + attrs.attributes.clear(); + uint32_t offset = 0; + + for (const gfx::Attribute &attribute : attributes) { + if (!attribute.isInstanced) continue; + gfx::Attribute attr; + attr.format = attribute.format; + attr.name = attribute.name; + attr.isNormalized = attribute.isNormalized; + attr.location = attribute.location; + attrs.attributes.emplace_back(attr); + const auto &info = gfx::GFX_FORMAT_INFOS[static_cast(attribute.format)]; + auto * buffer = attrs.buffer.buffer(); + auto typeViewArray = getTypedArrayConstructor(info, buffer, offset, info.count); + attrs.views.emplace_back(typeViewArray); + offset += info.size; + } + if (pass->getBatchingScheme() == BatchingSchemes::INSTANCING) { + pass->getInstancedBuffer()->destroy(); + } + setInstMatWorldIdx(getInstancedAttributeIndex(INST_MAT_WORLD)); + _localDataUpdated = true; +} + +void Model::initLocalDescriptors(index_t /*subModelIndex*/) { + if (!_localBuffer) { + _localBuffer = _device->createBuffer({ + gfx::BufferUsageBit::UNIFORM | gfx::BufferUsageBit::TRANSFER_DST, + gfx::MemoryUsageBit::DEVICE, + pipeline::UBOLocal::SIZE, + pipeline::UBOLocal::SIZE, + }); + } +} + +void Model::initWorldBoundDescriptors(index_t /*subModelIndex*/) { + if (!_worldBoundBuffer) { + _worldBoundBuffer = _device->createBuffer({ + gfx::BufferUsageBit::UNIFORM | gfx::BufferUsageBit::TRANSFER_DST, + gfx::MemoryUsageBit::DEVICE, + pipeline::UBOLocal::SIZE, + pipeline::UBOLocal::SIZE, + }); + } +} + +void Model::updateLocalDescriptors(index_t subModelIndex, gfx::DescriptorSet *descriptorSet) { + if (isModelImplementedInJS()) { + if (!_isCalledFromJS) { + _eventProcessor.emit(EventTypesToJS::MODEL_UPDATE_LOCAL_DESCRIPTORS, subModelIndex, descriptorSet); + _isCalledFromJS = false; + return; + } + } + + if (_localBuffer) { + descriptorSet->bindBuffer(pipeline::UBOLocal::BINDING, _localBuffer); + } +} + +void Model::updateWorldBoundDescriptors(index_t subModelIndex, gfx::DescriptorSet *descriptorSet) { + if (isModelImplementedInJS()) { + if (!_isCalledFromJS) { + _eventProcessor.emit(EventTypesToJS::MODEL_UPDATE_LOCAL_DESCRIPTORS, subModelIndex, descriptorSet); + _isCalledFromJS = false; + return; + } + } + + if (_worldBoundBuffer) { + descriptorSet->bindBuffer(pipeline::UBOLocal::BINDING, _worldBoundBuffer); + } +} +void Model::setInstancedAttributesViewData(index_t viewIdx, index_t arrIdx, float value) { + cc::get(_instanceAttributeBlock.views[viewIdx])[arrIdx] = value; } } // namespace scene diff --git a/native/cocos/scene/Model.h b/native/cocos/scene/Model.h index e3fab19237..35394a4a20 100644 --- a/native/cocos/scene/Model.h +++ b/native/cocos/scene/Model.h @@ -1,8 +1,8 @@ /**************************************************************************** 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 @@ -10,10 +10,10 @@ 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 @@ -27,119 +27,200 @@ #include #include +#include "base/Ptr.h" +#include "base/RefCounted.h" +#include "core/TypedArray.h" +#include "core/assets/RenderingSubMesh.h" +#include "core/assets/Texture2D.h" +#include "core/builtin/BuiltinResMgr.h" +#include "core/event/CallbacksInvoker.h" +#include "core/geometry/AABB.h" +#include "core/scene-graph/Layers.h" +#include "core/scene-graph/Node.h" #include "renderer/gfx-base/GFXBuffer.h" #include "renderer/gfx-base/GFXDef-common.h" -#include "scene/AABB.h" -#include "scene/Node.h" +#include "renderer/gfx-base/GFXTexture.h" +#include "scene/SubModel.h" namespace cc { -namespace scene { -enum class ModelType { - DEFAULT, - SKINNING, - BAKED_SKINNING, - BATCH_2D, - PARTICLE_BATCH, - LINE, -}; +class Material; + +namespace scene { // SubModel.h -> Define.h -> Model.h, so do not include SubModel.h here. class SubModel; +// RenderScene.h <-> Model.h, so do not include RenderScene.h here. class RenderScene; class OctreeNode; class Octree; - +class Pass; +struct IMacroPatch; struct InstancedAttributeBlock { - std::vector views{}; + Uint8Array buffer; + std::vector views; + std::vector attributes; }; -class Model { +class Model : public RefCounted { public: - Model() = default; - Model(const Model &) = delete; - Model(Model &&) = delete; - virtual ~Model() = default; - Model &operator=(const Model &) = delete; - Model &operator=(Model &&) = delete; + friend class Skybox; + + enum class Type { + DEFAULT, + SKINNING, + BAKED_SKINNING, + BATCH_2D, + PARTICLE_BATCH, + LINE, + }; + + Model(); + ~Model() override = default; + + void initialize(); + virtual void destroy(); + void updateWorldBound(); + void updateWorldBoundsForJSSkinningModel(const Vec3 &min, const Vec3 &max); + void updateWorldBoundsForJSBakedSkinningModel(geometry::AABB *aabb); + void createBoundingShape(const cc::optional &minPos, const cc::optional &maxPos); + virtual void initSubModel(index_t idx, RenderingSubMesh *subMeshData, Material *mat); + void setSubModelMesh(index_t idx, RenderingSubMesh *subMesh) const; + virtual void setSubModelMaterial(index_t idx, Material *mat); + void onGlobalPipelineStateChanged() const; + void onMacroPatchesStateChanged(); + void updateLightingmap(Texture2D *texture, const Vec4 &uvParam); + virtual std::vector &getMacroPatches(index_t subModelIndex); + virtual void updateInstancedAttributes(const std::vector &attributes, Pass *pass); virtual void updateTransform(uint32_t stamp); virtual void updateUBOs(uint32_t stamp); void updateWorldBoundUBOs(); - void setSubModel(uint32_t idx, SubModel *subModel); - + inline void attachToScene(RenderScene *scene) { + _scene = scene; + _localDataUpdated = true; + }; + inline void detachFromScene() { _scene = nullptr; }; inline void setCastShadow(bool value) { _castShadow = value; } inline void setEnabled(bool value) { _enabled = value; } inline void setInstMatWorldIdx(int32_t idx) { _instMatWorldIdx = idx; } inline void setLocalBuffer(gfx::Buffer *buffer) { _localBuffer = buffer; } inline void setWorldBoundBuffer(gfx::Buffer *buffer) { _worldBoundBuffer = buffer; } + inline void setNode(Node *node) { _node = node; } - inline void setReceiveShadow(bool value) { _receiveShadow = value; } - inline void setTransform(Node *node) { _transform = node; } - inline void seVisFlag(uint32_t flags) { _visFlags = flags; } - inline void setBounds(AABB *world) { - _worldBounds = world; - _modelBounds.set(_worldBounds->getCenter(), _worldBounds->getHalfExtents()); + inline void setReceiveShadow(bool value) { + _receiveShadow = value; + onMacroPatchesStateChanged(); } - inline void setInstancedAttrBlock(uint8_t *buffer, uint32_t size, InstancedAttributeBlock &&block, const std::vector &attributes) { - _instancedBuffer = std::make_tuple(buffer, size); - _instanceAttributeBlock = std::move(block); - _instanceAttributes = attributes; - _transformUpdated = true; + inline void setTransform(Node *node) { _transform = node; } + inline void setVisFlags(Layers::Enum flags) { _visFlags = flags; } + inline void setBounds(geometry::AABB *world) { + _worldBounds = world; + _modelBounds->set(_worldBounds->getCenter(), _worldBounds->getHalfExtents()); + } + inline void setInstancedAttributeBlock(const InstancedAttributeBlock &val) { + _instanceAttributeBlock = val; + _localDataUpdated = true; } inline void setOctreeNode(OctreeNode *node) { _octreeNode = node; } - inline void setScene(RenderScene *scene) { _scene = scene; if (scene) _transformUpdated = true; } + inline void setScene(RenderScene *scene) { + _scene = scene; + if (scene) _localDataUpdated = true; + } - inline bool getCastShadow() const { return _castShadow; } - inline bool getEnabled() const { return _enabled; } - inline int32_t getInstMatWorldIdx() const { return _instMatWorldIdx; } - inline const std::vector &getInstanceAttributes() const { return _instanceAttributes; } - inline InstancedAttributeBlock * getInstancedAttributeBlock() { return &_instanceAttributeBlock; } - inline uint8_t * getInstancedBuffer() const { return std::get<0>(_instancedBuffer); } - inline uint32_t getInstancedBufferSize() const { return std::get<1>(_instancedBuffer); } - inline gfx::Buffer * getLocalBuffer() const { return _localBuffer; } - inline gfx::Buffer * getWorldBoundBuffer() const { return _worldBoundBuffer; } - inline float * getLocalData() const { return _localData; } - inline const AABB & getModelBounds() const { return _modelBounds; } - inline Node * getNode() const { return _node; } - inline bool getReceiveShadow() const { return _receiveShadow; } - inline const std::vector & getSubModels() const { return _subModels; } - inline Node * getTransform() const { return _transform; } - inline bool getTransformUpdated() const { return _transformUpdated; } - inline int32_t getUpdatStamp() const { return _updateStamp; } - inline uint32_t getVisFlags() const { return _visFlags; } - inline AABB * getWorldBounds() const { return _worldBounds; } - inline ModelType getType() const { return _type; }; - inline OctreeNode * getOctreeNode() const { return _octreeNode; } - inline RenderScene * getScene() const { return _scene; } + inline bool isInited() const { return _inited; }; + inline bool isCastShadow() const { return _castShadow; } + inline bool isEnabled() const { return _enabled; } + inline bool isInstancingEnabled() const { return _instMatWorldIdx >= 0; }; + inline int32_t getInstMatWorldIdx() const { return _instMatWorldIdx; } + inline const std::vector & getInstanceAttributes() const { return _instanceAttributeBlock.attributes; } + inline InstancedAttributeBlock * getInstancedAttributeBlock() { return &_instanceAttributeBlock; } + inline const uint8_t * getInstancedBuffer() const { return _instanceAttributeBlock.buffer.buffer()->getData(); } + inline uint32_t getInstancedBufferSize() const { return _instanceAttributeBlock.buffer.length(); } + inline gfx::Buffer * getLocalBuffer() const { return _localBuffer.get(); } + inline gfx::Buffer * getWorldBoundBuffer() const { return _worldBoundBuffer.get(); } + inline Float32Array getLocalData() const { return _localData; } + inline geometry::AABB * getModelBounds() const { return _modelBounds; } + inline Node * getNode() const { return _node.get(); } + inline bool isReceiveShadow() const { return _receiveShadow; } + inline const std::vector> &getSubModels() const { return _subModels; } + inline Node * getTransform() const { return _transform.get(); } + inline bool isLocalDataUpdated() const { return _localDataUpdated; } + inline uint32_t getUpdateStamp() const { return _updateStamp; } + inline Layers::Enum getVisFlags() const { return _visFlags; } + inline geometry::AABB * getWorldBounds() const { return _worldBounds; } + inline Type getType() const { return _type; }; + inline void setType(Type type) { _type = type; } + inline OctreeNode * getOctreeNode() const { return _octreeNode; } + inline RenderScene * getScene() const { return _scene; } + inline void setDynamicBatching(bool val) { _isDynamicBatching = val; } + inline bool isDynamicBatching() const { return _isDynamicBatching; } + + void initLocalDescriptors(index_t subModelIndex); + void initWorldBoundDescriptors(index_t subModelIndex); + + virtual void updateLocalDescriptors(index_t subModelIndex, gfx::DescriptorSet *descriptorSet); + virtual void updateWorldBoundDescriptors(index_t subModelIndex, gfx::DescriptorSet *descriptorSet); + + int32_t getInstancedAttributeIndex(const std::string &name) const; + + // For JS + inline void setCalledFromJS(bool v) { _isCalledFromJS = v; } + inline CallbacksInvoker &getEventProcessor() { return _eventProcessor; } + void setInstancedAttributesViewData(index_t viewIdx, index_t arrIdx, float value); + inline void setLocalDataUpdated(bool v) { _localDataUpdated = v; } + inline void setWorldBounds(geometry::AABB *bounds) { _worldBounds = bounds; } + inline void setModelBounds(geometry::AABB *bounds) { _modelBounds = bounds; } + inline bool isModelImplementedInJS() const { return (_type != Type::DEFAULT && _type != Type::SKINNING && _type != Type::BAKED_SKINNING); }; + // protected: - ModelType _type{ModelType::DEFAULT}; - bool _transformUpdated{false}; - AABB * _worldBounds{nullptr}; - AABB _modelBounds; - OctreeNode * _octreeNode{nullptr}; - RenderScene *_scene{nullptr}; + static void uploadMat4AsVec4x3(const Mat4 &mat, Float32Array &v1, Float32Array &v2, Float32Array &v3); + + void updateAttributesAndBinding(index_t subModelIndex); + + static SubModel *createSubModel(); + + Type _type{Type::DEFAULT}; + bool _localDataUpdated{false}; + IntrusivePtr _worldBounds; + IntrusivePtr _modelBounds; + OctreeNode * _octreeNode{nullptr}; + RenderScene * _scene{nullptr}; + gfx::Device * _device{nullptr}; + bool _inited{false}; + uint32_t _descriptorSetCount{1}; -private: bool _enabled{false}; bool _castShadow{false}; bool _receiveShadow{false}; + bool _isDynamicBatching{false}; - int32_t _instMatWorldIdx{-1}; - uint32_t _visFlags; - int32_t _updateStamp{-1}; - Node * _transform{nullptr}; - Node * _node{nullptr}; - float * _localData{nullptr}; - std::tuple _instancedBuffer{nullptr, 0}; - gfx::Buffer * _localBuffer{nullptr}; - gfx::Buffer * _worldBoundBuffer{nullptr}; - InstancedAttributeBlock _instanceAttributeBlock{}; - std::vector _subModels; - std::vector _instanceAttributes; - static void uploadMat4AsVec4x3(const Mat4 &mat, float *v1, float *v2, float *v3); + int32_t _instMatWorldIdx{-1}; + Layers::Enum _visFlags{Layers::Enum::NONE}; + uint32_t _updateStamp{0}; + IntrusivePtr _transform; + IntrusivePtr _node; + Float32Array _localData; + std::tuple _instancedBuffer{nullptr, 0}; + IntrusivePtr _localBuffer; + IntrusivePtr _worldBoundBuffer; + InstancedAttributeBlock _instanceAttributeBlock{}; + std::vector> _subModels; + + IntrusivePtr _lightmap; + Vec4 _lightmapUVParam; + + std::vector _macroPatches; + + // For JS + CallbacksInvoker _eventProcessor; + bool _isCalledFromJS{false}; + // + +private: + CC_DISALLOW_COPY_MOVE_ASSIGN(Model); }; } // namespace scene diff --git a/native/cocos/scene/Node.cpp b/native/cocos/scene/Node.cpp deleted file mode 100644 index 8e9ba4be0d..0000000000 --- a/native/cocos/scene/Node.cpp +++ /dev/null @@ -1,182 +0,0 @@ -/**************************************************************************** - 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 "scene/Node.h" -#include "scene/Define.h" - -namespace cc { -namespace scene { -se::Object *Node::dirtyNodes{nullptr}; -void Node::updateWorldTransform() { - if (!getDirtyFlag()) { - return; - } - int i = 0; - BaseNode * curr = this; - Mat3 mat3; - Mat3 m43; - Quaternion quat; - while (curr && curr->getDirtyFlag()) { - setDirtyNode(i++, reinterpret_cast(curr)); - curr = curr->getParent(); - } - Node * child{nullptr}; - uint32_t dirtyBits = 0; - while (i) { - child = getDirtyNode(--i); - if (!child) { - continue; - } - dirtyBits |= child->getDirtyFlag(); - auto *childLayout = child->_nodeLayout; - if (curr) { - if (dirtyBits & static_cast(TransformBit::POSITION)) { - childLayout->worldPosition.transformMat4(childLayout->localPosition, curr->getWorldMatrix()); - childLayout->worldMatrix.m[12] = childLayout->worldPosition.x; - childLayout->worldMatrix.m[13] = childLayout->worldPosition.y; - childLayout->worldMatrix.m[14] = childLayout->worldPosition.z; - } - if (dirtyBits & static_cast(TransformBit::RS)) { - Mat4::fromRTS(childLayout->localRotation, childLayout->localPosition, childLayout->localScale, &childLayout->worldMatrix); - Mat4::multiply(curr->getWorldMatrix(), childLayout->worldMatrix, &childLayout->worldMatrix); - if (dirtyBits & static_cast(TransformBit::ROTATION)) { - Quaternion::multiply(curr->getWorldRotation(), childLayout->localRotation, &childLayout->worldRotation); - } - quat = childLayout->worldRotation; - quat.conjugate(); - Mat3::fromQuat(mat3, quat); - Mat3::fromMat4(m43, childLayout->worldMatrix); - Mat3::multiply(mat3, mat3, m43); - childLayout->worldScale.set(mat3.m[0], mat3.m[4], mat3.m[8]); - } - } else if (child) { - if (dirtyBits & static_cast(TransformBit::POSITION)) { - childLayout->worldPosition.set(childLayout->localPosition); - childLayout->worldMatrix.m[12] = childLayout->worldPosition.x; - childLayout->worldMatrix.m[13] = childLayout->worldPosition.y; - childLayout->worldMatrix.m[14] = childLayout->worldPosition.z; - } - if (dirtyBits & static_cast(TransformBit::RS)) { - if (dirtyBits & static_cast(TransformBit::ROTATION)) { - childLayout->worldRotation.set(childLayout->localRotation); - } - if (dirtyBits & static_cast(TransformBit::SCALE)) { - childLayout->worldScale.set(childLayout->localScale); - Mat4::fromRTS(childLayout->worldRotation, childLayout->worldPosition, childLayout->worldScale, &childLayout->worldMatrix); - } - } - } - child->setDirtyFlag(static_cast(TransformBit::NONE)); - curr = child; - } -} - -void Node::updateWorldRTMatrix() { - updateWorldTransform(); - Mat4::fromRT(_nodeLayout->worldRotation, _nodeLayout->worldPosition, &_rtMat); -} - -void Node::invalidateChildren(TransformBit dirtyBit) { - uint32_t curDirtyBit{static_cast(dirtyBit)}; - const uint32_t childDirtyBit{curDirtyBit | static_cast(TransformBit::POSITION)}; - setDirtyNode(0, this); - int i{0}; - while (i >= 0) { - BaseNode * cur = getDirtyNode(i--); - const uint32_t &hasChangedFlags = cur->getFlagsChanged(); - if ((cur->getDirtyFlag() & hasChangedFlags & curDirtyBit) != curDirtyBit) { - cur->setDirtyFlag(cur->getDirtyFlag() | curDirtyBit); - cur->setFlagsChanged(hasChangedFlags | curDirtyBit); - int childCount{static_cast(cur->getChilds().size())}; - for (BaseNode *curChild : cur->getChilds()) { - setDirtyNode(++i, reinterpret_cast(curChild)); - } - } - curDirtyBit = childDirtyBit; - } -} - -void Node::setWorldPosition(float x, float y, float z) { - _nodeLayout->worldPosition.set(x, y, z); - if (_parent) { - _parent->updateWorldTransform(); - Mat4 invertWMat{_parent->getWorldMatrix()}; - invertWMat.inverse(); - _nodeLayout->localPosition.transformMat4(_nodeLayout->worldPosition, invertWMat); - } else { - _nodeLayout->localPosition.set(_nodeLayout->worldPosition); - } - invalidateChildren(TransformBit::POSITION); -} - -void Node::setWorldRotation(float x, float y, float z, float w) { - _nodeLayout->worldRotation.set(x, y, z, w); - if (_parent) { - _parent->updateWorldTransform(); - _nodeLayout->localRotation.set(_parent->getWorldRotation().getConjugated()); - _nodeLayout->localRotation.multiply(_nodeLayout->worldRotation); - } else { - _nodeLayout->localRotation.set(_nodeLayout->worldRotation); - } - invalidateChildren(TransformBit::ROTATION); -} - -void Node::setDirtyNode(int idx, Node *node) { - se::AutoHandleScope autoHandle; - if (dirtyNodes) { - se::Value value; - nativevalue_to_se(node, value, nullptr); - dirtyNodes->setArrayElement(static_cast(idx), value); - } -} - -Node *Node::getDirtyNode(const int idx) { - se::AutoHandleScope autoHandle; - if (dirtyNodes) { - se::Value value; - if (dirtyNodes->getArrayElement(static_cast(idx), &value)) { - if (value.isObject()) { - return reinterpret_cast(value.toObject()->getPrivateData()); - } - } - } - return nullptr; -} - -void Node::initWithData(uint8_t *data, uint8_t *flagChunk, const se::Value &dirtys) { - _nodeLayout = reinterpret_cast(data); - _flagChunk = reinterpret_cast(flagChunk); - if (dirtyNodes == nullptr) { - dirtyNodes = dirtys.toObject(); - dirtyNodes->incRef(); - se::ScriptEngine::getInstance()->addBeforeCleanupHook([]() { - dirtyNodes->decRef(); - dirtyNodes = nullptr; - }); - } -} - -} // namespace scene -} // namespace cc diff --git a/native/cocos/scene/Node.h b/native/cocos/scene/Node.h deleted file mode 100644 index 5c44472750..0000000000 --- a/native/cocos/scene/Node.h +++ /dev/null @@ -1,107 +0,0 @@ -/**************************************************************************** - 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 -#include "cocos/bindings/manual/jsb_conversions.h" -#include "math/Mat3.h" -#include "math/Mat4.h" -#include "math/Quaternion.h" -#include "math/Vec3.h" -#include "math/Vec4.h" -#include "scene/BaseNode.h" -#include "scene/Scene.h" - -namespace cc { -namespace scene { -enum class TransformBit; -// This struct defines the memory layout shared between JS and C++. -struct NodeLayout { - uint32_t dirtyFlag{0}; - uint32_t layer{0}; - cc::Vec3 worldScale; - cc::Vec3 worldPosition; - cc::Quaternion worldRotation; - cc::Mat4 worldMatrix; - cc::Vec3 localScale; - cc::Vec3 localPosition; - cc::Quaternion localRotation; -}; - -class Node final : public BaseNode { -public: - Node() = default; - Node(const Node &) = delete; - Node(Node &&) = delete; - ~Node() override = default; - Node &operator=(const Node &) = delete; - Node &operator=(Node &&) = delete; - - void initWithData(uint8_t *, uint8_t *, const se::Value &); - void invalidateChildren(TransformBit dirtyBit); - - void updateWorldTransform() override; - void updateWorldRTMatrix() override; - - void setWorldPosition(float x, float y, float z) override; - void setWorldRotation(float x, float y, float z, float w) override; - static void setDirtyNode(int idx, Node *node); - - inline void setFlagsChanged(uint32_t value) override { *_flagChunk = value; } - inline void setDirtyFlag(uint32_t value) override { _nodeLayout->dirtyFlag = value; } - inline void setLayer(uint32_t layer) override { _nodeLayout->layer = layer; } - inline void setWorldMatrix(const Mat4 &matrix) override { _nodeLayout->worldMatrix.set(matrix); } - inline void setWorldPosition(const Vec3 &pos) override { setWorldPosition(pos.x, pos.y, pos.z); } - inline void setWorldRotation(const Quaternion &rotation) override { setWorldRotation(rotation.x, rotation.y, rotation.z, rotation.w); } - inline void setWorldScale(const Vec3 &scale) override { _nodeLayout->worldScale.set(scale); } - inline void setLocalPosition(const Vec3 &pos) override { _nodeLayout->localPosition.set(pos); } - inline void setLocalPosition(float x, float y, float z) override { _nodeLayout->localPosition.set(x, y, z); } - inline void setLocalRotation(const Quaternion &rotation) override { _nodeLayout->localRotation.set(rotation); } - inline void setLocalRotation(float x, float y, float z, float w) override { _nodeLayout->localRotation.set(x, y, z, w); } - inline void setLocalScale(const Vec3 &scale) override { _nodeLayout->localScale.set(scale); } - - inline uint32_t getFlagsChanged() const override { return *_flagChunk; } - inline uint32_t getLayer() const override { return _nodeLayout->layer; } - inline uint32_t getDirtyFlag() const override { return _nodeLayout->dirtyFlag; } - inline const Vec3 & getPosition() const override { return _nodeLayout->localPosition; } - inline const Vec3 & getScale() const override { return _nodeLayout->localScale; } - inline const Quaternion &getRotation() const override { return _nodeLayout->localRotation; } - inline const NodeLayout *getNodeLayout() const { return _nodeLayout; }; - inline const Mat4 & getWorldMatrix() const override { return _nodeLayout->worldMatrix; } - inline const Vec3 & getWorldPosition() const override { return _nodeLayout->worldPosition; } - inline const Quaternion &getWorldRotation() const override { return _nodeLayout->worldRotation; } - inline const Vec3 & getWorldScale() const override { return _nodeLayout->worldScale; } - inline const Mat4 & getWorldRTMatrix() const override { return _rtMat; }; - static Node * getDirtyNode(int idx); - -private: - NodeLayout * _nodeLayout{nullptr}; - uint32_t * _flagChunk{nullptr}; - static se::Object *dirtyNodes; -}; - -} // namespace scene -} // namespace cc diff --git a/native/cocos/scene/Octree.cpp b/native/cocos/scene/Octree.cpp index fad5b39cf2..cb7b9677d2 100644 --- a/native/cocos/scene/Octree.cpp +++ b/native/cocos/scene/Octree.cpp @@ -1,8 +1,8 @@ /**************************************************************************** Copyright (c) 2020-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 @@ -10,10 +10,10 @@ 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 @@ -32,6 +32,42 @@ namespace cc { namespace scene { +void OctreeInfo::setEnabled(bool val) { + if (_enabled == val) { + return; + } + _enabled = val; + if (_resource) { + _resource->setEnabled(val); + } +} + +void OctreeInfo::setMinPos(const Vec3 &val) { + _minPos = val; + if (_resource) { + _resource->setMinPos(val); + } +} + +void OctreeInfo::setMaxPos(const Vec3 &val) { + _maxPos = val; + if (_resource) { + _resource->setMaxPos(val); + } +} + +void OctreeInfo::setDepth(uint32_t val) { + _depth = val; + if (_resource) { + _resource->setMaxDepth(val); + } +} + +void OctreeInfo::activate(Octree *resource) { + _resource = resource; + _resource->initialize(*this); +} + /* children layout y | @@ -51,8 +87,8 @@ namespace scene { /** * OctreeNode class */ -OctreeNode::OctreeNode(Octree* owner, OctreeNode* parent, BBox aabb, uint32_t depth, uint32_t index) -: _owner(owner), _parent(parent), _aabb(std::move(aabb)), _depth(depth), _index(index) { +OctreeNode::OctreeNode(Octree *owner, OctreeNode *parent) +: _owner(owner), _parent(parent) { } OctreeNode::~OctreeNode() { @@ -87,10 +123,13 @@ BBox OctreeNode::getChildBox(uint32_t index) const { return {min, max}; } -OctreeNode* OctreeNode::getOrCreateChild(uint32_t index) { +OctreeNode *OctreeNode::getOrCreateChild(uint32_t index) { if (!_children[index]) { - BBox childBox = getChildBox(index); - _children[index] = new OctreeNode(_owner, this, childBox, _depth + 1, index); + BBox childBox = getChildBox(index); + auto *child = _children[index] = new OctreeNode(_owner, this); + child->setBox(childBox); + child->setDepth(_depth + 1); + child->setIndex(index); } return _children[index]; @@ -103,12 +142,12 @@ void OctreeNode::deleteChild(uint32_t index) { } } -void OctreeNode::insert(Model* model) { // NOLINT(misc-no-recursion) +void OctreeNode::insert(Model *model) { // NOLINT(misc-no-recursion) bool split = false; if (_depth < _owner->getMaxDepth() - 1) { BBox modelBox(*model->getWorldBounds()); - const cc::Vec3& modelCenter = modelBox.getCenter(); - const cc::Vec3& nodeCenter = _aabb.getCenter(); + const cc::Vec3 &modelCenter = modelBox.getCenter(); + const cc::Vec3 &nodeCenter = _aabb.getCenter(); uint32_t index = modelCenter.x < nodeCenter.x ? 0 : 1; index += modelCenter.y < nodeCenter.y ? 0 : 2; @@ -119,14 +158,14 @@ void OctreeNode::insert(Model* model) { // NOLINT(misc-no-recursion) split = true; // insert to child node recursively - OctreeNode* child = getOrCreateChild(index); + OctreeNode *child = getOrCreateChild(index); child->insert(model); } } if (!split) { // insert to this node - OctreeNode* lastNode = model->getOctreeNode(); + OctreeNode *lastNode = model->getOctreeNode(); if (lastNode != this) { add(model); @@ -137,12 +176,12 @@ void OctreeNode::insert(Model* model) { // NOLINT(misc-no-recursion) } } -void OctreeNode::add(Model* model) { +void OctreeNode::add(Model *model) { _models.push_back(model); model->setOctreeNode(this); } -void OctreeNode::remove(Model* model) { +void OctreeNode::remove(Model *model) { auto iter = std::find(_models.begin(), _models.end(), model); if (iter != _models.end()) { _models.erase(iter); @@ -157,49 +196,49 @@ void OctreeNode::onRemoved() { // NOLINT(misc-no-recursion) return; } - for (auto* child : _children) { + for (auto *child : _children) { if (child) { return; } } // delete recursively - OctreeNode* parent = _parent; + OctreeNode *parent = _parent; if (parent) { parent->deleteChild(_index); parent->onRemoved(); } } -void OctreeNode::gatherModels(std::vector& results) const { // NOLINT(misc-no-recursion) - for (auto* model : _models) { +void OctreeNode::gatherModels(std::vector &results) const { // NOLINT(misc-no-recursion) + for (auto *model : _models) { results.push_back(model); } - for (auto* child : _children) { + for (auto *child : _children) { if (child) { child->gatherModels(results); } } } -void OctreeNode::doQueryVisibility(const Camera* camera, const Frustum& frustum, bool isShadow, std::vector& results) const { - const auto visibility = camera->visibility; - for (auto* model : _models) { - if (!model->getEnabled()) { +void OctreeNode::doQueryVisibility(const Camera *camera, const geometry::Frustum &frustum, bool isShadow, std::vector &results) const { + const auto visibility = camera->getVisibility(); + for (auto *model : _models) { + if (!model->isEnabled()) { continue; } - const Node* node = model->getNode(); + const Node *node = model->getNode(); if ((node && ((visibility & node->getLayer()) == node->getLayer())) || - (visibility & model->getVisFlags())) { - const AABB* modelWorldBounds = model->getWorldBounds(); + (visibility & static_cast(model->getVisFlags()))) { + const geometry::AABB *modelWorldBounds = model->getWorldBounds(); if (!modelWorldBounds) { continue; } if (isShadow) { - if (model->getCastShadow() && modelWorldBounds->aabbFrustum(frustum)) { + if (model->isCastShadow() && modelWorldBounds->aabbFrustum(frustum)) { results.push_back(model); } } else { @@ -211,18 +250,18 @@ void OctreeNode::doQueryVisibility(const Camera* camera, const Frustum& frustum, } } -void OctreeNode::queryVisibilityParallelly(const Camera* camera, const Frustum& frustum, bool isShadow, std::vector& results) const { - AABB box; - AABB::fromPoints(_aabb.min, _aabb.max, &box); +void OctreeNode::queryVisibilityParallelly(const Camera *camera, const geometry::Frustum &frustum, bool isShadow, std::vector &results) const { + geometry::AABB box; + geometry::AABB::fromPoints(_aabb.min, _aabb.max, &box); if (!box.aabbFrustum(frustum)) { return; } - std::array>, OCTREE_CHILDREN_NUM> futures{}; + std::array>, OCTREE_CHILDREN_NUM> futures{}; for (auto i = 0; i < OCTREE_CHILDREN_NUM; i++) { if (_children[i]) { futures[i] = std::async(std::launch::async, [=, &frustum] { - std::vector models; + std::vector models; _children[i]->queryVisibilitySequentially(camera, frustum, isShadow, models); return models; }); @@ -239,9 +278,9 @@ void OctreeNode::queryVisibilityParallelly(const Camera* camera, const Frustum& } } -void OctreeNode::queryVisibilitySequentially(const Camera* camera, const Frustum& frustum, bool isShadow, std::vector& results) const { // NOLINT(misc-no-recursion) - AABB box; - AABB::fromPoints(_aabb.min, _aabb.max, &box); +void OctreeNode::queryVisibilitySequentially(const Camera *camera, const geometry::Frustum &frustum, bool isShadow, std::vector &results) const { // NOLINT(misc-no-recursion) + geometry::AABB box; + geometry::AABB::fromPoints(_aabb.min, _aabb.max, &box); if (!box.aabbFrustum(frustum)) { return; } @@ -249,7 +288,7 @@ void OctreeNode::queryVisibilitySequentially(const Camera* camera, const Frustum doQueryVisibility(camera, frustum, isShadow, results); // query recursively. - for (auto* child : _children) { + for (auto *child : _children) { if (child) { child->queryVisibilitySequentially(camera, frustum, isShadow, results); } @@ -259,37 +298,69 @@ void OctreeNode::queryVisibilitySequentially(const Camera* camera, const Frustum /** * Octree class */ -Octree::Octree(const Vec3& minPos, const Vec3& maxPos, uint32_t maxDepth) { - const Vec3 expand{OCTREE_BOX_EXPAND_SIZE, OCTREE_BOX_EXPAND_SIZE, OCTREE_BOX_EXPAND_SIZE}; - _root = new OctreeNode(this, nullptr, BBox(minPos - expand, maxPos), 0, 0); - _maxDepth = std::max(maxDepth, 1U); +Octree::Octree() { + _root = new OctreeNode(this, nullptr); } Octree::~Octree() { delete _root; } -void Octree::resize(const Vec3& minPos, const Vec3& maxPos, uint32_t maxDepth) { +void Octree::initialize(const OctreeInfo &info) { + const Vec3 expand{OCTREE_BOX_EXPAND_SIZE, OCTREE_BOX_EXPAND_SIZE, OCTREE_BOX_EXPAND_SIZE}; + _minPos = info.getMinPos(); + _maxPos = info.getMaxPos(); + _maxDepth = std::max(info.getDepth(), 1U); + setEnabled(info.isEnabled()); + _root->setBox(BBox{_minPos - expand, _maxPos}); + _root->setDepth(0); + _root->setIndex(0); +} + +void Octree::setEnabled(bool val) { + if (_enabled == val) { + return; + } + _enabled = val; +} + +void Octree::setMinPos(const Vec3 &val) { + _minPos = val; +} + +void Octree::setMaxPos(const Vec3 &val) { + _maxPos = val; +} + +void Octree::setMaxDepth(uint32_t val) { + _maxDepth = val; +} + +void Octree::resize(const Vec3 &minPos, const Vec3 &maxPos, uint32_t maxDepth) { const Vec3 expand{OCTREE_BOX_EXPAND_SIZE, OCTREE_BOX_EXPAND_SIZE, OCTREE_BOX_EXPAND_SIZE}; BBox rootBox = _root->getBox(); if ((minPos - expand) == rootBox.min && maxPos == rootBox.max && maxDepth == _maxDepth) { return; } - std::vector models; + std::vector models; _root->gatherModels(models); delete _root; - _root = new OctreeNode(this, nullptr, BBox(minPos - expand, maxPos), 0, 0); + _root = new OctreeNode(this, nullptr); + _root->setBox(BBox{minPos - expand, maxPos}); + _root->setDepth(0); + _root->setIndex(0); + _maxDepth = std::max(maxDepth, 1U); - for (auto* model : models) { + for (auto *model : models) { model->setOctreeNode(nullptr); insert(model); } } -void Octree::insert(Model* model) { +void Octree::insert(Model *model) { CCASSERT(model, "Octree insert: model is nullptr."); if (!model->getWorldBounds()) { @@ -309,10 +380,10 @@ void Octree::insert(Model* model) { _root->insert(model); } -void Octree::remove(Model* model) { +void Octree::remove(Model *model) { CCASSERT(model, "Octree remove: model is nullptr."); - OctreeNode* node = model->getOctreeNode(); + OctreeNode *node = model->getOctreeNode(); if (node) { node->remove(model); model->setOctreeNode(nullptr); @@ -320,11 +391,11 @@ void Octree::remove(Model* model) { } } -void Octree::update(Model* model) { +void Octree::update(Model *model) { insert(model); } -void Octree::queryVisibility(const Camera* camera, const Frustum& frustum, bool isShadow, std::vector& results) const { +void Octree::queryVisibility(Camera *camera, const geometry::Frustum &frustum, bool isShadow, std::vector &results) const { if (_totalCount > USE_MULTI_THRESHOLD) { _root->queryVisibilityParallelly(camera, frustum, isShadow, results); } else { @@ -332,8 +403,8 @@ void Octree::queryVisibility(const Camera* camera, const Frustum& frustum, bool } } -bool Octree::isInside(Model* model) const { - const BBox& rootBox = _root->getBox(); +bool Octree::isInside(Model *model) const { + const BBox &rootBox = _root->getBox(); BBox modelBox = BBox(*model->getWorldBounds()); return rootBox.contain(modelBox); diff --git a/native/cocos/scene/Octree.h b/native/cocos/scene/Octree.h index 4b1d5bb525..9f8813e2ae 100644 --- a/native/cocos/scene/Octree.h +++ b/native/cocos/scene/Octree.h @@ -1,8 +1,8 @@ /**************************************************************************** Copyright (c) 2020-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 @@ -10,10 +10,10 @@ 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 @@ -28,13 +28,14 @@ #include #include #include "base/Macros.h" +#include "base/RefCounted.h" +#include "core/geometry/AABB.h" #include "math/Vec3.h" -#include "scene/AABB.h" namespace cc { namespace scene { -struct Camera; +class Camera; class Model; class Octree; @@ -45,16 +46,62 @@ const Vec3 DEFAULT_WORLD_MAX_POS = {1024.0F, 1024.0F, 1024.0F}; const float OCTREE_BOX_EXPAND_SIZE = 10.0F; constexpr int USE_MULTI_THRESHOLD = 1024; // use parallel culling if greater than this value +class CC_DLL OctreeInfo final : public RefCounted { +public: + OctreeInfo() = default; + ~OctreeInfo() override = default; + /** + * @en Whether activate octree + * @zh 是否启用八叉树加速剔除? + */ + void setEnabled(bool val); + inline bool isEnabled() const { return _enabled; } + + /** + * @en min pos of scene bounding box + * @zh 场景包围盒最小值 + */ + void setMinPos(const Vec3 &val); + inline const Vec3 &getMinPos() const { return _minPos; } + + /** + * @en max pos of scene bounding box + * @zh 场景包围盒最大值 + */ + void setMaxPos(const Vec3 &val); + inline const Vec3 &getMaxPos() const { return _maxPos; } + + /** + * @en depth of octree + * @zh 八叉树深度 + */ + void setDepth(uint32_t val); + inline uint32_t getDepth() const { return _depth; } + + void activate(Octree *resource); + + // JS deserialization require the properties to be public + // private: + bool _enabled{false}; + Vec3 _minPos{DEFAULT_WORLD_MIN_POS}; + Vec3 _maxPos{DEFAULT_WORLD_MAX_POS}; + uint32_t _depth{DEFAULT_OCTREE_DEPTH}; + + Octree *_resource{nullptr}; +}; + // Axis aligned bounding box -struct CC_DLL BBox { +struct CC_DLL BBox final { cc::Vec3 min; cc::Vec3 max; - explicit BBox(const AABB& aabb) + BBox() = default; + + explicit BBox(const geometry::AABB &aabb) : min(aabb.getCenter() - aabb.getHalfExtents()), max(aabb.getCenter() + aabb.getHalfExtents()) { } - BBox(const cc::Vec3& minPos, const cc::Vec3& maxPos) + BBox(const cc::Vec3 &minPos, const cc::Vec3 &maxPos) : min(minPos), max(maxPos) { } @@ -62,17 +109,17 @@ struct CC_DLL BBox { return (min + max) * 0.5F; } - inline bool operator==(const BBox& box) const { + inline bool operator==(const BBox &box) const { return min == box.min && max == box.max; } - inline bool contain(const cc::Vec3& point) const { + inline bool contain(const cc::Vec3 &point) const { return !(point.x > max.x || point.x < min.x || point.y > max.y || point.y < min.y || point.z > max.z || point.z < min.z); } - inline bool contain(const BBox& box) const { + inline bool contain(const BBox &box) const { return contain(box.min) && contain(box.max); } }; @@ -80,32 +127,36 @@ struct CC_DLL BBox { /** * OctreeNode class */ -class CC_DLL OctreeNode { +class CC_DLL OctreeNode final { private: - OctreeNode(Octree* owner, OctreeNode* parent, BBox aabb, uint32_t depth, uint32_t index); + OctreeNode(Octree *owner, OctreeNode *parent); ~OctreeNode(); - inline Octree* getOwner() const { return _owner; } - inline const BBox& getBox() const { return _aabb; } - BBox getChildBox(uint32_t index) const; - OctreeNode* getOrCreateChild(uint32_t index); - void deleteChild(uint32_t index); - void insert(Model* model); - void add(Model* model); - void remove(Model* model); - void onRemoved(); - void gatherModels(std::vector& results) const; - void doQueryVisibility(const Camera* camera, const Frustum& frustum, bool isShadow, std::vector& results) const; - void queryVisibilityParallelly(const Camera* camera, const Frustum& frustum, bool isShadow, std::vector& results) const; - void queryVisibilitySequentially(const Camera* camera, const Frustum& frustum, bool isShadow, std::vector& results) const; + inline void setBox(const BBox &aabb) { _aabb = aabb; } + inline void setDepth(uint32_t depth) { _depth = depth; } + inline void setIndex(uint32_t index) { _index = index; } - Octree* _owner{nullptr}; - OctreeNode* _parent{nullptr}; - std::array _children{}; - std::vector _models; - BBox _aabb; - uint32_t _depth{0}; - uint32_t _index{0}; + inline Octree * getOwner() const { return _owner; } + inline const BBox &getBox() const { return _aabb; } + BBox getChildBox(uint32_t index) const; + OctreeNode * getOrCreateChild(uint32_t index); + void deleteChild(uint32_t index); + void insert(Model *model); + void add(Model *model); + void remove(Model *model); + void onRemoved(); + void gatherModels(std::vector &results) const; + void doQueryVisibility(const Camera *camera, const geometry::Frustum &frustum, bool isShadow, std::vector &results) const; + void queryVisibilityParallelly(const Camera *camera, const geometry::Frustum &frustum, bool isShadow, std::vector &results) const; + void queryVisibilitySequentially(const Camera *camera, const geometry::Frustum &frustum, bool isShadow, std::vector &results) const; + + Octree * _owner{nullptr}; + OctreeNode * _parent{nullptr}; + std::array _children{}; + std::vector _models; + BBox _aabb{}; + uint32_t _depth{0}; + uint32_t _index{0}; friend class Octree; }; @@ -113,35 +164,67 @@ private: /** * Octree class */ -class CC_DLL Octree { +class CC_DLL Octree final { public: - explicit Octree(const Vec3& minPos = DEFAULT_WORLD_MIN_POS, const Vec3& maxPos = DEFAULT_WORLD_MAX_POS, uint32_t maxDepth = DEFAULT_OCTREE_DEPTH); + Octree(); ~Octree(); + void initialize(const OctreeInfo &info); + + /** + * @en Whether activate octree + * @zh 是否启用八叉树加速剔除? + */ + void setEnabled(bool val); + inline bool isEnabled() const { return _enabled; } + + /** + * @en min pos of scene bounding box + * @zh 场景包围盒最小值 + */ + void setMinPos(const Vec3 &val); + inline const Vec3 &getMinPos() const { return _minPos; } + + /** + * @en max pos of scene bounding box + * @zh 场景包围盒最大值 + */ + void setMaxPos(const Vec3 &val); + inline const Vec3 &getMaxPos() const { return _maxPos; } + // reinsert all models in the tree when you change the aabb or max depth in editor - void resize(const Vec3& minPos, const Vec3& maxPos, uint32_t maxDepth); + void resize(const Vec3 &minPos, const Vec3 &maxPos, uint32_t maxDepth); // insert a model to tree. - void insert(Model* model); + void insert(Model *model); // remove a model from tree. - void remove(Model* model); + void remove(Model *model); // update model's location in the tree. - void update(Model* model); + void update(Model *model); + /** + * @en depth of octree + * @zh 八叉树深度 + */ + void setMaxDepth(uint32_t val); // return octree depth inline uint32_t getMaxDepth() const { return _maxDepth; } // view frustum culling - void queryVisibility(const Camera* camera, const Frustum& frustum, bool isShadow, std::vector& results) const; + void queryVisibility(Camera *camera, const geometry::Frustum &frustum, bool isShadow, std::vector &results) const; private: - bool isInside(Model* model) const; + bool isInside(Model *model) const; - OctreeNode* _root{nullptr}; + OctreeNode *_root{nullptr}; uint32_t _maxDepth{DEFAULT_OCTREE_DEPTH}; uint32_t _totalCount{0}; + + bool _enabled{false}; + Vec3 _minPos; + Vec3 _maxPos; }; } // namespace scene diff --git a/native/cocos/scene/Pass.cpp b/native/cocos/scene/Pass.cpp index 793d7076b3..32dbbccc2c 100644 --- a/native/cocos/scene/Pass.cpp +++ b/native/cocos/scene/Pass.cpp @@ -1,8 +1,8 @@ /**************************************************************************** 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 @@ -10,10 +10,10 @@ 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 @@ -25,22 +25,602 @@ #include "scene/Pass.h" -extern void jsbFlushFastMQ(); +#include + +#include "MurmurHash2/MurmurHash2.h" +#include "core/Root.h" +#include "core/assets/TextureBase.h" +#include "core/builtin/BuiltinResMgr.h" +#include "renderer/core/PassUtils.h" +#include "renderer/core/ProgramLib.h" +#include "renderer/gfx-base/GFXDef.h" +#include "renderer/gfx-base/states/GFXSampler.h" +#include "renderer/pipeline/BatchedBuffer.h" +#include "renderer/pipeline/Define.h" +#include "renderer/pipeline/InstancedBuffer.h" +#include "scene/Define.h" namespace cc { namespace scene { +namespace { + +std::string serializeBlendState(const gfx::BlendState &bs) { + std::stringstream res; + res << ",bs," << bs.isA2C; + for (const auto &t : bs.targets) { + res << ",bt," << t.blend << "," << static_cast(t.blendEq) << "," << static_cast(t.blendAlphaEq) << "," << static_cast(t.blendColorMask); + res << "," << static_cast(t.blendSrc) << "," << static_cast(t.blendDst) << "," << static_cast(t.blendSrcAlpha) << "," << static_cast(t.blendDstAlpha); + } + return res.str(); +} + +std::string serializeRasterizerState(const gfx::RasterizerState &rs) { + std::stringstream res; + res << ",rs," << static_cast(rs.cullMode) << "," << static_cast(rs.depthBias) << "," << static_cast(rs.isFrontFaceCCW); + return res.str(); +} + +std::string serializeDepthStencilState(const gfx::DepthStencilState &dss) { + std::stringstream res; + res << ",dss," << static_cast(dss.depthTest) << "," << static_cast(dss.depthWrite) << "," << static_cast(dss.depthFunc); + res << "," << static_cast(dss.stencilTestFront) << "," << static_cast(dss.stencilFuncFront) << "," << static_cast(dss.stencilRefFront) << "," << static_cast(dss.stencilReadMaskFront); + res << "," << static_cast(dss.stencilFailOpFront) << "," << static_cast(dss.stencilZFailOpFront) << "," << static_cast(dss.stencilPassOpFront) << "," << static_cast(dss.stencilWriteMaskFront); + res << "," << static_cast(dss.stencilTestBack) << "," << static_cast(dss.stencilFuncBack) << "," << static_cast(dss.stencilRefBack) << "," << static_cast(dss.stencilReadMaskBack); + res << "," << static_cast(dss.stencilFailOpBack) << "," << static_cast(dss.stencilZFailOpBack) << "," << static_cast(dss.stencilPassOpBack) << "," << dss.stencilWriteMaskBack; + return res.str(); +} + +} // namespace + +/*static*/ +void Pass::fillPipelineInfo(Pass *pass, const IPassInfoFull &info) { + if (info.priority.has_value()) { + pass->_priority = static_cast(info.priority.value()); + } + if (info.primitive.has_value()) { + pass->_primitive = info.primitive.value(); + } + if (info.stage.has_value()) { + pass->_stage = info.stage.value(); + } + if (info.dynamicStates.has_value()) { + pass->_dynamicStates = info.dynamicStates.value(); + } + if (info.phase.has_value()) { + pass->_phaseString = info.phase.value(); + pass->_phase = pipeline::getPhaseID(pass->_phaseString); + } + + if (info.blendState.has_value()) { + info.blendState.value().assignToGFXBlendState(pass->_blendState); + } + + if (info.rasterizerState.has_value()) { + info.rasterizerState.value().assignToGFXRasterizerState(pass->_rs); + } + + if (info.depthStencilState.has_value()) { + info.depthStencilState.value().assignToGFXDepthStencilState(pass->_depthStencilState); + } +} + +/* static */ +uint64_t Pass::getPassHash(Pass *pass) { + const std::string &shaderKey = ProgramLib::getInstance()->getKey(pass->getProgram(), pass->getDefines()); + std::stringstream res; + res << shaderKey << "," << static_cast(pass->_primitive) << "," << static_cast(pass->_dynamicStates); + res << serializeBlendState(pass->_blendState); + res << serializeDepthStencilState(pass->_depthStencilState); + res << serializeRasterizerState(pass->_rs); + + std::string str{res.str()}; + return murmurhash2::MurmurHash2(str.data(), static_cast(str.size()), 666); +} + +Pass::Pass() : Pass(Root::getInstance()) {} + +Pass::Pass(Root *root) { + _device = root->getDevice(); + _root = root; + _phaseString = "default"; + _phase = pipeline::getPhaseID(_phaseString); +} + +void Pass::initialize(const IPassInfoFull &info) { + doInit(info); + resetUBOs(); + resetTextures(); + tryCompile(); +} + +uint32_t Pass::getHandle(const std::string &name, uint32_t offset /* = 0 */, gfx::Type targetType /* = gfx::Type::UNKNOWN */) const { + uint32_t handle = 0; + auto iter = _propertyHandleMap.find(name); // handle = _propertyHandleMap[name]; + if (iter == _propertyHandleMap.end()) { + return 0; + } + + handle = iter->second; + + if (targetType != gfx::Type::UNKNOWN) { + handle = customizeType(handle, targetType); + } else if (offset) { + handle = customizeType(handle, static_cast(static_cast(getTypeFromHandle(handle)) - offset)); + } + return handle + offset; +} + +uint32_t Pass::getBinding(const std::string &name) const { + uint32_t handle = getHandle(name); + if (0 == handle) { + return -1; + } + return Pass::getBindingFromHandle(handle); +} + +void Pass::setUniform(uint32_t handle, const MaterialProperty &value) { + const uint32_t binding = Pass::getBindingFromHandle(handle); + const gfx::Type type = Pass::getTypeFromHandle(handle); + const uint32_t ofs = Pass::getOffsetFromHandle(handle); + auto & block = _blocks[binding]; + auto iter = type2writer.find(type); + if (iter != type2writer.end()) { + iter->second(block.data, value, static_cast(ofs)); + } + + _rootBufferDirty = true; +} + +MaterialProperty &Pass::getUniform(uint32_t handle, MaterialProperty &out) const { + const uint32_t binding = Pass::getBindingFromHandle(handle); + const gfx::Type type = Pass::getTypeFromHandle(handle); + const uint32_t ofs = Pass::getOffsetFromHandle(handle); + const auto & block = _blocks[binding]; + auto iter = type2reader.find(type); + if (iter != type2reader.end()) { + iter->second(block.data, out, static_cast(ofs)); + } + return out; +} + +void Pass::setUniformArray(uint32_t handle, const MaterialPropertyList &value) { + const uint32_t binding = Pass::getBindingFromHandle(handle); + const gfx::Type type = Pass::getTypeFromHandle(handle); + const uint32_t stride = gfx::getTypeSize(type) >> 2; + auto & block = _blocks[binding]; + uint32_t ofs = Pass::getOffsetFromHandle(handle); + for (size_t i = 0; i < value.size(); i++, ofs += stride) { + if (value[i].index() == 0) { + continue; + } + auto iter = type2writer.find(type); + if (iter != type2writer.end()) { + iter->second(block.data, value[i], static_cast(ofs)); + } + } + _rootBufferDirty = true; +} + +void Pass::bindTexture(uint32_t binding, gfx::Texture *value, index_t index /* = CC_INVALID_INDEX */) { + _descriptorSet->bindTexture(binding, value, index != CC_INVALID_INDEX ? index : 0); +} + +void Pass::bindSampler(uint32_t binding, gfx::Sampler *value, index_t index /* = CC_INVALID_INDEX */) { + _descriptorSet->bindSampler(binding, value, index != CC_INVALID_INDEX ? index : 0); +} + +void Pass::setDynamicState(gfx::DynamicStateFlagBit state, float value) { + auto &ds = _dynamics[static_cast(state)]; + if (ds.value == value) { + return; + } + + ds.value = value; + ds.dirty = true; +} + +void Pass::overridePipelineStates(const IPassInfo & /*original*/, const PassOverrides & /*overrides*/) { + CC_LOG_WARNING("base pass cannot override states, please use pass instance instead."); +} + void Pass::update() { - jsbFlushFastMQ(); + if (_descriptorSet == nullptr) { + // cjh errorID(12006); + return; + } + if (_rootBufferDirty && _rootBuffer) { - _rootBuffer->update(_rootBlock, _rootBuffer->getSize()); + _rootBuffer->update(_rootBlock->getData(), _rootBlock->byteLength()); _rootBufferDirty = false; } _descriptorSet->update(); } -void Pass::initWithData(uint8_t *data) { - _passLayout = reinterpret_cast(data); +pipeline::InstancedBuffer *Pass::getInstancedBuffer(int32_t extraKey) { + auto iter = _instancedBuffers.find(extraKey); + if (iter != _instancedBuffers.end()) { + return iter->second.get(); + } + auto *instancedBuffer = new pipeline::InstancedBuffer(this); + _instancedBuffers[extraKey] = instancedBuffer; + return instancedBuffer; +} + +pipeline::BatchedBuffer *Pass::getBatchedBuffer(int32_t extraKey) { + auto iter = _batchedBuffers.find(extraKey); + if (iter != _batchedBuffers.end()) { + return iter->second.get(); + } + auto *batchedBuffers = new pipeline::BatchedBuffer(this); + _batchedBuffers[extraKey] = batchedBuffers; + return batchedBuffers; +} + +void Pass::destroy() { + for (const auto &u : _shaderInfo->blocks) { + _buffers[u.binding]->destroy(); + } + + _buffers.clear(); + + if (_rootBuffer) { + _rootBuffer->destroy(); + _rootBuffer = nullptr; + } + + for (auto &ib : _instancedBuffers) { + ib.second->destroy(); + } + _instancedBuffers.clear(); + + for (auto &bb : _batchedBuffers) { + bb.second->destroy(); + } + _batchedBuffers.clear(); + + _descriptorSet->destroy(); +} + +void Pass::resetUniform(const std::string &name) { + const uint32_t handle = getHandle(name); + if (0 == handle) { + return; + } + const gfx::Type type = Pass::getTypeFromHandle(handle); + const uint32_t binding = Pass::getBindingFromHandle(handle); + const uint32_t ofs = Pass::getOffsetFromHandle(handle); + const uint32_t count = Pass::getCountFromHandle(handle); + auto & block = _blocks[binding]; + IPropertyValue givenDefaultOpt; + auto iter = _properties.find(name); + if (iter != _properties.end()) { + givenDefaultOpt = iter->second.value; + } + + if (givenDefaultOpt.has_value()) { + const auto &value = givenDefaultOpt.value(); + if (cc::holds_alternative>(value)) { + const auto &floatArr = cc::get>(value); + auto iter = type2writer.find(type); + if (iter != type2writer.end()) { + iter->second(block.data, floatArr.data(), static_cast(ofs)); + } + } + } + + _rootBufferDirty = true; +} + +void Pass::resetTexture(const std::string &name, index_t index /* = CC_INVALID_INDEX */) { + const uint32_t handle = getHandle(name); + if (0 == handle) { + return; + } + const gfx::Type type = Pass::getTypeFromHandle(handle); + const uint32_t binding = Pass::getBindingFromHandle(handle); + std::string texName; + IPropertyInfo * info = nullptr; + auto iter = _properties.find(name); + if (iter != _properties.end()) { + if (iter->second.value.has_value()) { + info = &iter->second; + std::string *pStrVal = cc::get_if(&iter->second.value.value()); + if (pStrVal != nullptr) { + texName = (*pStrVal) + "-texture"; + } + } + } + + if (texName.empty()) { + texName = getDefaultStringFromType(type); + } + + auto * textureBase = BuiltinResMgr::getInstance()->get(texName); + gfx::Texture * texture = textureBase != nullptr ? textureBase->getGFXTexture() : nullptr; + cc::optional samplerInfo; + if (info != nullptr && info->samplerHash.has_value()) { + samplerInfo = gfx::Sampler::unpackFromHash(static_cast(info->samplerHash.value())); + } else if (textureBase != nullptr) { + samplerInfo = textureBase->getSamplerInfo(); + } + + if (samplerInfo.has_value()) { + auto *sampler = _device->getSampler(samplerInfo.value()); + _descriptorSet->bindSampler(binding, sampler, index); + _descriptorSet->bindTexture(binding, texture, index); + } else { + CC_LOG_WARNING("sampler hash could not be found!"); + } +} + +void Pass::resetUBOs() { + for (auto &u : _shaderInfo->blocks) { + uint32_t ofs = 0; + for (auto &cur : u.members) { + const auto & block = _blocks[u.binding]; + const auto & info = _properties[cur.name]; + const auto & givenDefault = info.value; + const auto & value = (givenDefault.has_value() ? cc::get>(givenDefault.value()) : getDefaultFloatArrayFromType(cur.type)); + const uint32_t size = (gfx::getTypeSize(cur.type) >> 2) * cur.count; + for (size_t k = 0; (k + value.size()) <= size; k += value.size()) { + std::copy(value.begin(), value.end(), block.data + ofs + k); + } + ofs += size; + } + } + _rootBufferDirty = true; +} + +void Pass::resetTextures() { + for (auto &u : _shaderInfo->samplerTextures) { + for (int32_t j = 0; j < u.count; j++) { + resetTexture(u.name, j); + } + } +} + +bool Pass::tryCompile() { + if (_root->getPipeline() == nullptr) { + return false; + } + + syncBatchingScheme(); + auto *shader = ProgramLib::getInstance()->getGFXShader(_device, _programName, _defines, _root->getPipeline()); + if (!shader) { + CC_LOG_WARNING("create shader %s failed", _programName.c_str()); + return false; + } + _shader = shader; + _pipelineLayout = ProgramLib::getInstance()->getTemplateInfo(_programName)->pipelineLayout; + _hash = Pass::getPassHash(this); + return true; +} + +gfx::Shader *Pass::getShaderVariant() { + return getShaderVariant({}); +} + +gfx::Shader *Pass::getShaderVariant(const std::vector &patches) { + if (!_shader && !tryCompile()) { + CC_LOG_WARNING("pass resources incomplete"); + return nullptr; + } + + if (patches.empty()) { + return _shader; + } + + // cjh if (EDITOR) { + // for (let i = 0; i < patches.length; i++) { + // if (!patches[i].name.startsWith('CC_')) { + // console.warn('cannot patch non-builtin macros'); + // return null; + // } + // } + // } + + auto *pipeline = _root->getPipeline(); + for (const auto &patch : patches) { + _defines[patch.name] = patch.value; + } + + auto *shader = ProgramLib::getInstance()->getGFXShader(_device, _programName, _defines, pipeline); + + for (const auto &patch : patches) { + auto iter = _defines.find(patch.name); + if (iter != _defines.end()) { + _defines.erase(iter); + } + } + return shader; +} + +IPassInfoFull Pass::getPassInfoFull() const { + IPassInfoFull ret; + ret.passIndex = _passIndex; + ret.defines = _defines; + + ret.program = _programName; + ret.propertyIndex = _propertyIndex; + ret.properties = _properties; + ret.priority = static_cast(_priority); + + ret.primitive = _primitive; + ret.stage = _stage; + + RasterizerStateInfo rsInfo; + rsInfo.fromGFXRasterizerState(_rs); + ret.rasterizerState = rsInfo; + + DepthStencilStateInfo dsInfo; + dsInfo.fromGFXDepthStencilState(_depthStencilState); + ret.depthStencilState = dsInfo; + + BlendStateInfo bsInfo; + bsInfo.fromGFXBlendState(_blendState); + ret.blendState = bsInfo; + + ret.dynamicStates = _dynamicStates; + ret.phase = _phaseString; + + return ret; +} + +void Pass::setState(const gfx::BlendState &bs, const gfx::DepthStencilState &dss, const gfx::RasterizerState &rs, gfx::DescriptorSet *ds) { + // cjh how to control lifecycle? + _blendState = bs; + _depthStencilState = dss; + _rs = rs; + _descriptorSet = ds; +} + +void Pass::doInit(const IPassInfoFull &info, bool /*copyDefines*/ /* = false */) { + auto *programLib = ProgramLib::getInstance(); + _priority = pipeline::RenderPriority::DEFAULT; + _stage = pipeline::RenderPassStage::DEFAULT; + _phaseString = "default"; + _phase = pipeline::getPhaseID(_phaseString); + _primitive = gfx::PrimitiveMode::TRIANGLE_LIST; + + _passIndex = info.passIndex; + _propertyIndex = info.propertyIndex != CC_INVALID_INDEX ? info.propertyIndex : info.passIndex; + _programName = info.program; + _defines = info.defines; // cjh c++ always does copy by assignment. copyDefines ? ({ ...info.defines }) : info.defines; + _shaderInfo = programLib->getTemplate(info.program); + if (info.properties.has_value()) { + _properties = info.properties.value(); + } + // + gfx::Device *device = _device; + Pass::fillPipelineInfo(this, info); + if (info.stateOverrides.has_value()) { + Pass::fillPipelineInfo(this, IPassInfoFull(info.stateOverrides.value())); + } + + // init descriptor set + gfx::DescriptorSetInfo dsInfo; + dsInfo.layout = programLib->getDescriptorSetLayout(_device, info.program); + _descriptorSet = _device->createDescriptorSet(dsInfo); + + // calculate total size required + const auto & blocks = _shaderInfo->blocks; + const auto * tmplInfo = programLib->getTemplateInfo(info.program); + const std::vector &blockSizes = tmplInfo->blockSizes; + const auto & handleMap = tmplInfo->handleMap; + + const auto alignment = device->getCapabilities().uboOffsetAlignment; + std::vector startOffsets; + startOffsets.reserve(blocks.size()); + uint32_t lastSize = 0; + uint32_t lastOffset = 0; + for (size_t i = 0; i < blocks.size(); i++) { + const auto &size = blockSizes[i]; + startOffsets.emplace_back(lastOffset); + lastOffset += static_cast(std::ceil(static_cast(size) / static_cast(alignment))) * alignment; + lastSize = size; + } + + // create gfx buffer resource + uint32_t totalSize = !startOffsets.empty() ? (startOffsets[startOffsets.size() - 1] + lastSize) : 0; + if (totalSize > 0) { + gfx::BufferInfo bufferInfo; + bufferInfo.usage = gfx::BufferUsageBit::UNIFORM | gfx::BufferUsageBit::TRANSFER_DST; + bufferInfo.memUsage = gfx::MemoryUsageBit::DEVICE; + // https://bugs.chromium.org/p/chromium/issues/detail?id=988988 + bufferInfo.size = static_cast(std::ceil(static_cast(totalSize) / 16.F)) * 16; + _rootBuffer = device->createBuffer(bufferInfo); + _rootBlock = new ArrayBuffer(totalSize); + } + + gfx::BufferViewInfo bufferViewInfo; + + // create buffer views + for (size_t i = 0, count = 0; i < blocks.size(); i++) { + int32_t binding = blocks[i].binding; + int32_t size = blockSizes[i]; + bufferViewInfo.buffer = _rootBuffer; + bufferViewInfo.offset = startOffsets[count++]; + bufferViewInfo.range = static_cast(std::ceil(static_cast(size) / 16.F)) * 16; + if (binding >= _buffers.size()) { + _buffers.resize(binding + 1); + } + auto *bufferView = device->createBuffer(bufferViewInfo); + _buffers[binding] = bufferView; + // non-builtin UBO data pools, note that the effect compiler + // guarantees these bindings to be consecutive, starting from 0 and non-array-typed + if (binding >= _blocks.size()) { + _blocks.resize(binding + 1); + } + _blocks[binding].data = reinterpret_cast(const_cast(_rootBlock->getData()) + bufferViewInfo.offset); + _blocks[binding].count = size / 4; + _blocks[binding].offset = bufferViewInfo.offset / 4; + _descriptorSet->bindBuffer(binding, bufferView); + } + // store handles + _propertyHandleMap = handleMap; + auto & directHandleMap = _propertyHandleMap; + Record indirectHandleMap; + for (const auto &properties : _properties) { + if (!properties.second.handleInfo.has_value()) { + continue; + } + + const auto &propVal = properties.second.handleInfo.value(); + indirectHandleMap[properties.first] = getHandle(std::get<0>(propVal), std::get<1>(propVal), std::get<2>(propVal)); + } + + utils::mergeToMap(directHandleMap, indirectHandleMap); +} + +void Pass::syncBatchingScheme() { + auto iter = _defines.find("USE_INSTANCING"); + if (iter != _defines.end()) { + if (_device->hasFeature(gfx::Feature::INSTANCED_ARRAYS)) { + _batchingScheme = BatchingSchemes::INSTANCING; + } else { + iter->second = false; + _batchingScheme = BatchingSchemes::NONE; + } + } else { + auto iter = _defines.find("USE_BATCHING"); + if (iter != _defines.end()) { + _batchingScheme = BatchingSchemes::VB_MERGING; + } else { + _batchingScheme = BatchingSchemes::NONE; + } + } +} + +void Pass::initPassFromTarget(Pass *target, const gfx::DepthStencilState &dss, const gfx::BlendState &bs, uint64_t hashFactor) { + _priority = target->_priority; + _stage = target->_stage; + _phase = target->_phase; + _batchingScheme = target->_batchingScheme; + _primitive = target->_primitive; + _dynamicStates = target->_dynamicStates; + _blendState = bs; // cjh lifecycle? + _depthStencilState = dss; + _descriptorSet = target->_descriptorSet; + _rs = *target->getRasterizerState(); + _passIndex = target->_passIndex; + _propertyIndex = target->_propertyIndex; + _programName = target->getProgram(); + _defines = target->_defines; + _shaderInfo = target->_shaderInfo; // cjh how to release? + _properties = target->_properties; + + _blocks = target->_blocks; + _dynamics = target->_dynamics; + + _shader = target->_shader; + + _pipelineLayout = ProgramLib::getInstance()->getTemplateInfo(_programName)->pipelineLayout; + _hash = target->_hash ^ hashFactor; +} + +gfx::DescriptorSetLayout *Pass::getLocalSetLayout() const { + return ProgramLib::getInstance()->getDescriptorSetLayout(_device, _programName, true); } } // namespace scene diff --git a/native/cocos/scene/Pass.h b/native/cocos/scene/Pass.h index 8ec8037465..6d0af5845d 100644 --- a/native/cocos/scene/Pass.h +++ b/native/cocos/scene/Pass.h @@ -26,79 +26,331 @@ #pragma once #include +#include +#include +#include "base/Ptr.h" +#include "base/RefCounted.h" +#include "base/TypeDef.h" +#include "core/ArrayBuffer.h" +#include "core/TypedArray.h" +#include "core/assets/EffectAsset.h" +#include "renderer/core/PassUtils.h" #include "renderer/gfx-base/GFXBuffer.h" #include "renderer/gfx-base/GFXDef-common.h" #include "renderer/gfx-base/GFXDescriptorSet.h" -#include "scene/Define.h" +#include "renderer/gfx-base/GFXDevice.h" +#include "renderer/pipeline/Define.h" namespace cc { -namespace scene { -// This struct defines the memory layout shared between JS and C++. -struct PassLayout { - RenderPriority priority{RenderPriority::DEFAULT}; - RenderPassStage stage{RenderPassStage::DEFAULT}; - uint32_t phase{0}; - gfx::PrimitiveMode primitive{gfx::PrimitiveMode::TRIANGLE_LIST}; - BatchingSchemes batchingScheme{BatchingSchemes::VB_MERGING}; - gfx::DynamicStateFlagBit dynamicState{gfx::DynamicStateFlagBit::NONE}; - // FIXME: is uint32_t enough? - uint32_t hash{0}; +class Root; +struct IProgramInfo; +namespace pipeline { +class InstancedBuffer; +class BatchedBuffer; +} // namespace pipeline +namespace scene { +struct IMacroPatch; + +struct PassDynamicsValue { + bool dirty{false}; + float value{0.F}; +}; +using IPassDynamics = std::unordered_map; + +enum class BatchingSchemes { + NONE = 0, + INSTANCING = 1, + VB_MERGING = 2, }; -class Pass final { -public: - Pass() = default; - Pass(const Pass &) = delete; - Pass(Pass &&) = delete; - ~Pass() = default; - Pass &operator=(const Pass &) = delete; - Pass &operator=(Pass &&) = delete; +struct IBlockRef { + float *data{nullptr}; + size_t count{0}; + size_t offset{0}; +}; + +class Pass : public RefCounted { +public: + /** + * @en Get the type of member in uniform buffer object with the handle + * @zh 根据 handle 获取 uniform 的具体类型。 + */ + static gfx::Type getTypeFromHandle(uint32_t handle) { + return cc::getTypeFromHandle(handle); + } + + /** + * @en Get the binding with handle + * @zh 根据 handle 获取 binding。 + */ + static uint32_t getBindingFromHandle(uint32_t handle) { + return cc::getBindingFromHandle(handle); + } + + /** + * @en Get the array length with handle + * @zh 根据 handle 获取数组长度。 + */ + static uint32_t getCountFromHandle(uint32_t handle) { + return cc::getCountFromHandle(handle); + } + + static uint32_t getOffsetFromHandle(uint32_t handle) { + return cc::getOffsetFromHandle(handle); + } + + /** + * @en Fill a pass represented by the given pass handle with the given override info + * @param pass The pass handle point to the pass + * @param info The pass override info + */ + static void fillPipelineInfo(Pass *pass, const IPassInfoFull &info); + + /** + * @en Get pass hash value by [[Pass]] hash information. + * @zh 根据 [[Pass]] 的哈希信息获取哈希值。 + * + * @param pass Handle of the pass info used to compute hash value. + */ + static uint64_t getPassHash(Pass *pass); + + Pass(); + explicit Pass(Root *root); + ~Pass() override = default; + + /** + * @en Initialize the pass with given pass info, shader will be compiled in the init process + * @zh 根据指定参数初始化当前 pass,shader 会在这一阶段就尝试编译。 + */ + void initialize(const IPassInfoFull &info); + + /** + * @en Get the handle of a UBO member, or specific channels of it. + * @zh 获取指定 UBO 成员,或其更具体分量的读写句柄。默认以成员自身的类型为目标读写类型(即读写时必须传入与成员类型相同的变量)。 + * @param name Name of the target UBO member. + * @param offset Channel offset into the member. + * @param targetType Target type of the handle, i.e. the type of data when read/write to it. + * @example + * ``` + * import { Vec3, gfx } from 'cc'; + * // say 'pbrParams' is a uniform vec4 + * const hParams = pass.getHandle('pbrParams'); // get the default handle + * pass.setUniform(hAlbedo, new Vec3(1, 0, 0)); // wrong! pbrParams.w is NaN now + * + * // say 'albedoScale' is a uniform vec4, and we only want to modify the w component in the form of a single float + * const hThreshold = pass.getHandle('albedoScale', 3, gfx.Type.FLOAT); + * pass.setUniform(hThreshold, 0.5); // now, albedoScale.w = 0.5 + * ``` + */ + uint32_t getHandle(const std::string &name, uint32_t offset = 0, gfx::Type targetType = gfx::Type::UNKNOWN) const; + + /** + * @en Gets the uniform binding with its name + * @zh 获取指定 uniform 的 binding。 + * @param name The name of target uniform + */ + uint32_t getBinding(const std::string &name) const; + + /** + * @en Sets a vector type uniform value, if a uniform requires frequent update, please use this method. + * @zh 设置指定普通向量类 uniform 的值,如果需要频繁更新请尽量使用此接口。 + * @param handle The handle for the target uniform + * @param value New value + */ + void setUniform(uint32_t handle, const MaterialProperty &value); + + /** + * @en Gets a uniform's value. + * @zh 获取指定普通向量类 uniform 的值。 + * @param handle The handle for the target uniform + * @param out The output property to store the result + */ + MaterialProperty &getUniform(uint32_t handle, MaterialProperty &out) const; + + /** + * @en Sets an array type uniform value, if a uniform requires frequent update, please use this method. + * @zh 设置指定数组类 uniform 的值,如果需要频繁更新请尽量使用此接口。 + * @param handle The handle for the target uniform + * @param value New value + */ + void setUniformArray(uint32_t handle, const MaterialPropertyList &value); + + /** + * @en Bind a GFX [[Texture]] the the given uniform binding + * @zh 绑定实际 GFX [[Texture]] 到指定 binding。 + * @param binding The binding for target uniform of texture type + * @param value Target texture + */ + void bindTexture(uint32_t binding, gfx::Texture *value, index_t index = CC_INVALID_INDEX); + + /** + * @en Bind a GFX [[Sampler]] the the given uniform binding + * @zh 绑定实际 GFX [[Sampler]] 到指定 binding。 + * @param binding The binding for target uniform of sampler type + * @param value Target sampler + */ + void bindSampler(uint32_t binding, gfx::Sampler *value, index_t index = CC_INVALID_INDEX); + + /** + * @en Sets the dynamic pipeline state property at runtime + * @zh 设置运行时 pass 内可动态更新的管线状态属性。 + * @param state Target dynamic state + * @param value Target value + */ + void setDynamicState(gfx::DynamicStateFlagBit state, float value); + + /** + * @en Override all pipeline states with the given pass override info. + * @zh 重载当前所有管线状态。 + * @param original The original pass info + * @param value The override pipeline state info + */ + virtual void overridePipelineStates(const IPassInfo &original, const PassOverrides &overrides); - void initWithData(uint8_t *data); void update(); - inline void setBatchingScheme(BatchingSchemes value) { _passLayout->batchingScheme = value; } - inline void setBlendState(gfx::BlendState *blendState) { _blendState = blendState; } - inline void setDepthStencilState(gfx::DepthStencilState *state) { _depthStencilState = state; } - inline void setDescriptorSet(gfx::DescriptorSet *descriptorSet) { _descriptorSet = descriptorSet; } - inline void setDynamicState(gfx::DynamicStateFlagBit value) { _passLayout->dynamicState = value; } - inline void setHash(uint32_t hash) { _passLayout->hash = hash; } - inline void setPhase(uint32_t phase) { _passLayout->phase = phase; } - inline void setPipelineLayout(gfx::PipelineLayout *layout) { _pipelineLayout = layout; } - inline void setPrimitive(gfx::PrimitiveMode mode) { _passLayout->primitive = mode; } - inline void setPriority(RenderPriority priority) { _passLayout->priority = priority; } - inline void setRasterizerState(gfx::RasterizerState *state) { _rasterizerState = state; } - inline void setStage(RenderPassStage stage) { _passLayout->stage = stage; } - inline void setRootBufferAndBlock(gfx::Buffer *buffer, uint8_t *block) { - _rootBuffer = buffer; - _rootBlock = block; - } - inline void setRootBufferDirty(bool val) { _rootBufferDirty = val; } + pipeline::InstancedBuffer *getInstancedBuffer(int32_t extraKey = 0); + pipeline::BatchedBuffer * getBatchedBuffer(int32_t extraKey = 0); - inline BatchingSchemes getBatchingScheme() const { return _passLayout->batchingScheme; } - inline gfx::BlendState * getBlendState() const { return _blendState; } - inline gfx::DepthStencilState * getDepthStencilState() const { return _depthStencilState; } - inline gfx::DescriptorSet * getDescriptorSet() const { return _descriptorSet; } - inline gfx::DynamicStateFlagBit getDynamicState() const { return _passLayout->dynamicState; } - inline uint32_t getHash() const { return _passLayout->hash; } - inline uint32_t getPhase() const { return _passLayout->phase; } - inline gfx::PipelineLayout * getPipelineLayout() const { return _pipelineLayout; } - inline gfx::PrimitiveMode getPrimitive() const { return _passLayout->primitive; } - inline RenderPriority getPriority() const { return _passLayout->priority; } - inline gfx::RasterizerState * getRasterizerState() const { return _rasterizerState; } - inline RenderPassStage getStage() const { return _passLayout->stage; } + /** + * @en Destroy the current pass. + * @zh 销毁当前 pass。 + */ + void destroy(); -private: - bool _rootBufferDirty{false}; - PassLayout * _passLayout{nullptr}; - gfx::RasterizerState * _rasterizerState{nullptr}; - gfx::DepthStencilState *_depthStencilState{nullptr}; - gfx::BlendState * _blendState{nullptr}; - gfx::DescriptorSet * _descriptorSet{nullptr}; - gfx::PipelineLayout * _pipelineLayout{nullptr}; - gfx::Buffer * _rootBuffer{nullptr}; - uint8_t * _rootBlock{nullptr}; + /** + * @en Resets the value of the given uniform by name to the default value in [[EffectAsset]]. + * This method does not support array type uniform. + * @zh 重置指定(非数组) Uniform 为 [[EffectAsset]] 默认值。 + */ + void resetUniform(const std::string &name); + + /** + * @en Resets the value of the given texture by name to the default value in [[EffectAsset]]. + * @zh 重置指定贴图为 [[EffectAsset]] 默认值。 + */ + void resetTexture(const std::string &name, index_t index = CC_INVALID_INDEX); + + /** + * @en Resets all uniform buffer objects to the default values in [[EffectAsset]] + * @zh 重置所有 UBO 为默认值。 + */ + void resetUBOs(); + + /** + * @en Resets all textures and samplers to the default values in [[EffectAsset]] + * @zh 重置所有 texture 和 sampler 为初始默认值。 + */ + void resetTextures(); + + /** + * @en Try to compile the shader and retrieve related resources references. + * @zh 尝试编译 shader 并获取相关资源引用。 + */ + virtual bool tryCompile(); + virtual bool tryCompile(const cc::optional & /*defineOverrides*/) { return Pass::tryCompile(); } + + /** + * @en Gets the shader variant of the current pass and given macro patches + * @zh 结合指定的编译宏组合获取当前 Pass 的 Shader Variant + * @param patches The macro patches + */ + gfx::Shader *getShaderVariant(); + gfx::Shader *getShaderVariant(const std::vector &patches); + + IPassInfoFull getPassInfoFull() const; + + // infos + inline Root * getRoot() const { return _root; } + inline gfx::Device * getDevice() const { return _device; } + inline IProgramInfo * getShaderInfo() const { return _shaderInfo; } + gfx::DescriptorSetLayout * getLocalSetLayout() const; + inline const std::string & getProgram() const { return _programName; } + inline const Record &getProperties() const { return _properties; } + inline const MacroRecord & getDefines() const { return _defines; } + inline MacroRecord & getDefines() { return _defines; } + inline index_t getPassIndex() const { return _passIndex; } + inline index_t getPropertyIndex() const { return _propertyIndex; } + // data + inline const IPassDynamics & getDynamics() const { return _dynamics; } + inline const std::vector &getBlocks() const { return _blocks; } + inline ArrayBuffer * getRootBlock() { return _rootBlock; } + inline bool isRootBufferDirty() const { return _rootBufferDirty; } + //NOTE: _setRootBufferDirty must contain a _ prefix to make bindings-generator work correctly. + // In ts engine, Pass has rootBufferDirty getter and without setter, but it contains a protected function named _setRootBufferDirty. + // If we remove _ prefix in C++, bindings-generator doesn't support to bind rootBufferDirty property as getter and ignore to bind setRootBufferDirty as setter at the same time. + // So let's keep the _ prefix temporarily. + inline void _setRootBufferDirty(bool val) { _rootBufferDirty = val; } // NOLINT(readability-identifier-naming) + // states + inline pipeline::RenderPriority getPriority() const { return _priority; } + inline gfx::PrimitiveMode getPrimitive() const { return _primitive; } + inline pipeline::RenderPassStage getStage() const { return _stage; } + inline uint32_t getPhase() const { return _phase; } + inline const gfx::RasterizerState * getRasterizerState() const { return &_rs; } + inline const gfx::DepthStencilState *getDepthStencilState() const { return &_depthStencilState; } + inline const gfx::BlendState * getBlendState() const { return &_blendState; } + inline gfx::DynamicStateFlagBit getDynamicStates() const { return _dynamicStates; } + inline BatchingSchemes getBatchingScheme() const { return _batchingScheme; } + inline gfx::DescriptorSet * getDescriptorSet() const { return _descriptorSet; } + inline uint64_t getHash() const { return _hash; } + inline double getHashForJS() const { return static_cast(getHash()); } + inline gfx::PipelineLayout * getPipelineLayout() const { return _pipelineLayout; } + + // Only for UI + void initPassFromTarget(Pass *target, const gfx::DepthStencilState &dss, const gfx::BlendState &bs, uint64_t hashFactor); + + // internal use + /** + * @private + */ + virtual void beginChangeStatesSilently() {} + virtual void endChangeStatesSilently() {} + +protected: + void setState(const gfx::BlendState &bs, const gfx::DepthStencilState &dss, const gfx::RasterizerState &rs, gfx::DescriptorSet *ds); + void doInit(const IPassInfoFull &info, bool copyDefines = false); + virtual void syncBatchingScheme(); + + // internal resources + IntrusivePtr _rootBuffer; + std::vector> _buffers; + IntrusivePtr _descriptorSet; + IntrusivePtr _pipelineLayout; + // internal data + index_t _passIndex{0}; + index_t _propertyIndex{0}; + std::string _programName; + IPassDynamics _dynamics; + Record _propertyHandleMap; + IntrusivePtr _rootBlock; + std::vector _blocks; // Point to position in _rootBlock + + IProgramInfo * _shaderInfo; // weakref to template of ProgramLib + MacroRecord _defines; + Record _properties; + IntrusivePtr _shader; + gfx::BlendState _blendState{}; + gfx::DepthStencilState _depthStencilState{}; + gfx::RasterizerState _rs{}; + pipeline::RenderPriority _priority{pipeline::RenderPriority::DEFAULT}; + pipeline::RenderPassStage _stage{pipeline::RenderPassStage::DEFAULT}; + uint32_t _phase{0}; + std::string _phaseString; + gfx::PrimitiveMode _primitive{gfx::PrimitiveMode::TRIANGLE_LIST}; + BatchingSchemes _batchingScheme{BatchingSchemes::NONE}; + gfx::DynamicStateFlagBit _dynamicStates{gfx::DynamicStateFlagBit::NONE}; + Record> _instancedBuffers; + Record> _batchedBuffers; + + uint64_t _hash{0}; + // external references + Root * _root{nullptr}; + gfx::Device *_device{nullptr}; + + bool _rootBufferDirty{false}; + + CC_DISALLOW_COPY_MOVE_ASSIGN(Pass); }; } // namespace scene diff --git a/native/cocos/scene/RenderScene.cpp b/native/cocos/scene/RenderScene.cpp index 6221c6a074..43a6a16131 100644 --- a/native/cocos/scene/RenderScene.cpp +++ b/native/cocos/scene/RenderScene.cpp @@ -1,8 +1,8 @@ /**************************************************************************** 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 @@ -10,10 +10,10 @@ 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 @@ -24,52 +24,115 @@ ****************************************************************************/ #include "scene/RenderScene.h" -#include -#include "base/Log.h" -#include "renderer/pipeline/RenderPipeline.h" -#include "scene/Octree.h" -extern void jsbFlushFastMQ(); +#include +#include "3d/models/BakedSkinningModel.h" +#include "3d/models/SkinningModel.h" +#include "base/Log.h" +#include "core/scene-graph/Node.h" +#include "renderer/pipeline/RenderPipeline.h" +#include "scene/Camera.h" +#include "scene/DirectionalLight.h" +#include "scene/DrawBatch2D.h" +#include "scene/Model.h" +#include "scene/Octree.h" +#include "scene/SphereLight.h" +#include "scene/SpotLight.h" namespace cc { namespace scene { -RenderScene::~RenderScene() { - CC_SAFE_DELETE(_octree); -} +RenderScene::~RenderScene() = default; void RenderScene::activate() { - const auto *sceneData = pipeline::RenderPipeline::getInstance()->getPipelineSceneData(); - const auto *sharedData = sceneData->getSharedData(); - const auto *info = sharedData->octree; + const auto *sceneData = pipeline::RenderPipeline::getInstance()->getPipelineSceneData(); + _octree = sceneData->getOctree(); +} - if (info->enabled) { - _octree = new Octree(info->minPos, info->maxPos, info->depth); - } +bool RenderScene::initialize(const IRenderSceneInfo &info) { + _name = info.name; + return true; +} + +void RenderScene::setMainLight(DirectionalLight *dl) { + _mainLight = dl; } void RenderScene::update(uint32_t stamp) { - jsbFlushFastMQ(); - - if (_directionalLight) { - _directionalLight->update(); + if (_mainLight) { + _mainLight->update(); } - for (SphereLight *light : _sphereLights) { + for (const auto &light : _sphereLights) { light->update(); } - for (SpotLight *spotLight : _spotLights) { + for (const auto &spotLight : _spotLights) { spotLight->update(); } - for (auto *model : _models) { - if (model->getEnabled()) { + for (const auto &model : _models) { + if (model->isEnabled()) { model->updateTransform(stamp); model->updateUBOs(stamp); } } } +void RenderScene::destroy() { + removeCameras(); + removeSphereLights(); + removeSpotLights(); + removeModels(); +} + +void RenderScene::addCamera(Camera *camera) { + camera->attachToScene(this); + _cameras.emplace_back(camera); +} + +void RenderScene::removeCamera(Camera *camera) { + auto iter = std::find(_cameras.begin(), _cameras.end(), camera); + if (iter != _cameras.end()) { + _cameras.erase(iter); + } +} + +void RenderScene::removeCameras() { + for (const auto &camera : _cameras) { + camera->detachFromScene(); + } + _cameras.clear(); +} + +void RenderScene::unsetMainLight(DirectionalLight *dl) { + if (_mainLight == dl) { + const auto &dlList = _directionalLights; + if (!dlList.empty()) { + setMainLight(dlList[dlList.size() - 1]); + if (_mainLight->getNode() != nullptr) { + uint32_t flag = _mainLight->getNode()->getChangedFlags(); + _mainLight->getNode()->setChangedFlags(flag | static_cast(TransformBit::ROTATION)); + } + return; + } + setMainLight(nullptr); + } +} + +void RenderScene::addDirectionalLight(DirectionalLight *dl) { + dl->attachToScene(this); + _directionalLights.emplace_back(dl); +} + +void RenderScene::removeDirectionalLight(DirectionalLight *dl) { + auto iter = std::find(_directionalLights.begin(), _directionalLights.end(), dl); + if (iter != _directionalLights.end()) { + (*iter)->detachFromScene(); + _directionalLights.erase(iter); + return; + } +} + void RenderScene::addSphereLight(SphereLight *light) { - _sphereLights.push_back(light); + _sphereLights.emplace_back(light); } void RenderScene::removeSphereLight(SphereLight *sphereLight) { @@ -81,12 +144,8 @@ void RenderScene::removeSphereLight(SphereLight *sphereLight) { } } -void RenderScene::removeSphereLights() { - _sphereLights.clear(); -} - void RenderScene::addSpotLight(SpotLight *spotLight) { - _spotLights.push_back(spotLight); + _spotLights.emplace_back(spotLight); } void RenderScene::removeSpotLight(SpotLight *spotLight) { @@ -98,93 +157,87 @@ void RenderScene::removeSpotLight(SpotLight *spotLight) { } } -void RenderScene::removeSpotLights() { +void RenderScene::removeSphereLights() { + for (const auto &sphereLight : _sphereLights) { + sphereLight->detachFromScene(); + } _sphereLights.clear(); } +void RenderScene::removeSpotLights() { + for (const auto &spotLight : _spotLights) { + spotLight->detachFromScene(); + } + _spotLights.clear(); +} + void RenderScene::addModel(Model *model) { - _models.push_back(model); - model->setScene(this); - if (_octree) { + model->attachToScene(this); + _models.emplace_back(model); + if (_octree && _octree->isEnabled()) { _octree->insert(model); } } -void RenderScene::addBakedSkinningModel(BakedSkinningModel *bakedSkinModel) { - _models.push_back(bakedSkinModel); - bakedSkinModel->setScene(this); - if (_octree) { - _octree->insert(bakedSkinModel); - } -} - -void RenderScene::addSkinningModel(SkinningModel *skinModel) { - _models.push_back(skinModel); - skinModel->setScene(this); - if (_octree) { - _octree->insert(skinModel); - } -} - -void RenderScene::removeModel(uint32_t idx) { - if (idx >= static_cast(_models.size())) { +void RenderScene::removeModel(index_t idx) { + if (idx >= static_cast(_models.size())) { CC_LOG_WARNING("Try to remove invalid model."); return; } - auto iter = _models.begin() + idx; - if (_octree) { - _octree->remove(*iter); - } - (*iter)->setScene(nullptr); + _models.erase(_models.begin() + idx); +} - _models.erase(iter); +void RenderScene::removeModel(Model *model) { + auto iter = std::find(_models.begin(), _models.end(), model); + if (iter != _models.end()) { + if (_octree && _octree->isEnabled()) { + _octree->remove(*iter); + } + model->detachFromScene(); + _models.erase(iter); + } else { + CC_LOG_WARNING("Try to remove invalid model."); + } } void RenderScene::removeModels() { - for (auto *model : _models) { - if (_octree) { + for (const auto &model : _models) { + if (_octree && _octree->isEnabled()) { _octree->remove(model); } - model->setScene(nullptr); + model->detachFromScene(); + CC_SAFE_DESTROY(model); } - _models.clear(); } - -void RenderScene::updateBatches(std::vector &&batches) { - _drawBatch2Ds = batches; -} - void RenderScene::addBatch(DrawBatch2D *drawBatch2D) { - _drawBatch2Ds.push_back(drawBatch2D); + _batches.emplace_back(drawBatch2D); } void RenderScene::removeBatch(DrawBatch2D *drawBatch2D) { - auto iter = std::find(_drawBatch2Ds.begin(), _drawBatch2Ds.end(), drawBatch2D); - if (iter != _drawBatch2Ds.end()) { - _drawBatch2Ds.erase(iter); + auto iter = std::find(_batches.begin(), _batches.end(), drawBatch2D); + if (iter != _batches.end()) { + _batches.erase(iter); } else { CC_LOG_WARNING("Try to remove invalid DrawBatch2D."); } } -void RenderScene::removeBatch(uint32_t index) { - if (index >= static_cast(_drawBatch2Ds.size())) { - return; - } - - removeBatch(_drawBatch2Ds[index]); -} - void RenderScene::removeBatches() { - _drawBatch2Ds.clear(); + _batches.clear(); } void RenderScene::updateOctree(Model *model) { - if (_octree) { + if (_octree && _octree->isEnabled()) { _octree->update(model); } } +void RenderScene::onGlobalPipelineStateChanged() { + for (const auto &model : _models) { + model->onGlobalPipelineStateChanged(); + } +} + } // namespace scene } // namespace cc diff --git a/native/cocos/scene/RenderScene.h b/native/cocos/scene/RenderScene.h index 77224d8023..c0854b1165 100644 --- a/native/cocos/scene/RenderScene.h +++ b/native/cocos/scene/RenderScene.h @@ -1,8 +1,8 @@ /**************************************************************************** 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 @@ -10,10 +10,10 @@ 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 @@ -25,31 +25,54 @@ #pragma once +#include #include -#include "scene/BakedSkinningModel.h" -#include "scene/DirectionalLight.h" -#include "scene/DrawBatch2D.h" -#include "scene/Model.h" -#include "scene/SkinningModel.h" -#include "scene/SphereLight.h" -#include "scene/SpotLight.h" +#include "base/Macros.h" +#include "base/Ptr.h" +#include "base/TypeDef.h" +#include "scene/Camera.h" namespace cc { + +class Node; +class SkinningModel; +class BakedSkinningModel; + namespace scene { class Octree; +struct DrawBatch2D; +class DirectionalLight; +class SphereLight; +class SpotLight; -class RenderScene final { +struct IRaycastResult { + Node *node{nullptr}; + float distance{0.F}; +}; + +struct IRenderSceneInfo { + std::string name; +}; + +class RenderScene : public RefCounted { public: - RenderScene() = default; - RenderScene(const RenderScene &) = delete; - RenderScene(RenderScene &&) = delete; - ~RenderScene(); - RenderScene &operator=(const RenderScene &) = delete; - RenderScene &operator=(RenderScene &&) = delete; + RenderScene() = default; + ~RenderScene() override; + + bool initialize(const IRenderSceneInfo &info); + void update(uint32_t stamp); + void destroy(); void activate(); - void update(uint32_t stamp); + + void addCamera(Camera *camera); + void removeCamera(Camera *camera); + void removeCameras(); + + void unsetMainLight(DirectionalLight *dl); + void addDirectionalLight(DirectionalLight *dl); + void removeDirectionalLight(DirectionalLight *dl); void addSphereLight(SphereLight *); void removeSphereLight(SphereLight *); @@ -60,34 +83,44 @@ public: void removeSpotLights(); void addModel(Model *); - void addSkinningModel(SkinningModel *); - void addBakedSkinningModel(BakedSkinningModel *); - void removeModel(uint32_t); + void removeModel(index_t idx); + void removeModel(Model *model); void removeModels(); - void updateBatches(std::vector &&); void addBatch(DrawBatch2D *); void removeBatch(DrawBatch2D *); - void removeBatch(uint32_t index); void removeBatches(); - inline void setMainLight(DirectionalLight *light) { _directionalLight = light; } + void onGlobalPipelineStateChanged(); - inline const std::vector &getDrawBatch2Ds() const { return _drawBatch2Ds; } - inline DirectionalLight * getMainLight() const { return _directionalLight; } - inline const std::vector & getModels() const { return _models; } - inline const std::vector &getSphereLights() const { return _sphereLights; } - inline const std::vector & getSpotLights() const { return _spotLights; } - inline Octree * getOctree() const { return _octree; } - void updateOctree(Model *model); + inline DirectionalLight *getMainLight() const { return _mainLight.get(); } + void setMainLight(DirectionalLight *dl); + + inline uint64_t generateModelId() { return _modelId++; } + inline const std::string & getName() const { return _name; } + inline const std::vector> & getCameras() const { return _cameras; } + inline const std::vector> &getSphereLights() const { return _sphereLights; } + inline const std::vector> & getSpotLights() const { return _spotLights; } + inline const std::vector> & getModels() const { return _models; } + inline Octree * getOctree() const { return _octree; } + void updateOctree(Model *model); + // FIXME: remove getDrawBatch2Ds + inline const std::vector &getBatches() const { return _batches; } + inline const std::vector &getDrawBatch2Ds() const { return _batches; } private: - DirectionalLight * _directionalLight{nullptr}; - std::vector _models; - std::vector _sphereLights; - std::vector _spotLights; - std::vector _drawBatch2Ds; - Octree * _octree{nullptr}; + std::string _name; + uint64_t _modelId{0}; + IntrusivePtr _mainLight; + std::vector> _models; + std::vector> _cameras; + std::vector> _directionalLights; + std::vector> _sphereLights; + std::vector> _spotLights; + std::vector _batches; + Octree * _octree{nullptr}; + + CC_DISALLOW_COPY_MOVE_ASSIGN(RenderScene); }; } // namespace scene diff --git a/native/cocos/scene/RenderWindow.cpp b/native/cocos/scene/RenderWindow.cpp new file mode 100644 index 0000000000..66cafff8d5 --- /dev/null +++ b/native/cocos/scene/RenderWindow.cpp @@ -0,0 +1,171 @@ +/**************************************************************************** + 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 "scene/RenderWindow.h" +#include "scene/Camera.h" +#include "platform/interfaces/modules/Device.h" + +namespace cc { +namespace scene { + +namespace { + +const std::unordered_map orientationMap { + { IScreen::Orientation::PORTRAIT, gfx::SurfaceTransform::IDENTITY }, + { IScreen::Orientation::LANDSCAPE_RIGHT, gfx::SurfaceTransform::ROTATE_90 }, + { IScreen::Orientation::PORTRAIT_UPSIDE_DOWN, gfx::SurfaceTransform::ROTATE_180 }, + { IScreen::Orientation::LANDSCAPE_LEFT, gfx::SurfaceTransform::ROTATE_270 }, +}; + +} + +bool RenderWindow::initialize(gfx::Device *device, IRenderWindowInfo &info) { + if (info.title.has_value() && !info.title.value().empty()) { + _title = info.title.value(); + } + + if (info.swapchain != nullptr) { + _swapchain = info.swapchain; + } + + _width = info.width; + _height = info.height; + + _renderPass = device->createRenderPass(info.renderPassInfo); + + if (info.swapchain != nullptr) { + _swapchain = info.swapchain; + _colorTextures.pushBack(info.swapchain->getColorTexture()); + _depthStencilTexture = info.swapchain->getDepthStencilTexture(); + } else { + for (auto &colorAttachment : info.renderPassInfo.colorAttachments) { + _colorTextures.pushBack( + device->createTexture({gfx::TextureType::TEX2D, + gfx::TextureUsageBit::COLOR_ATTACHMENT | gfx::TextureUsageBit::SAMPLED | gfx::TextureUsageBit::TRANSFER_SRC, + colorAttachment.format, + _width, + _height})); + } + } + + // Use the sign bit to indicate depth attachment + if (info.renderPassInfo.depthStencilAttachment.format != gfx::Format::UNKNOWN) { + _depthStencilTexture = device->createTexture({gfx::TextureType::TEX2D, + gfx::TextureUsageBit::DEPTH_STENCIL_ATTACHMENT | gfx::TextureUsageBit::SAMPLED, + info.renderPassInfo.depthStencilAttachment.format, + _width, + _height}); + } + + _frameBuffer = device->createFramebuffer(gfx::FramebufferInfo{ + _renderPass, + _colorTextures.get(), + _depthStencilTexture}); + return true; +} + +void RenderWindow::destroy() { + clearCameras(); + + CC_SAFE_DESTROY_NULL(_frameBuffer); + + CC_SAFE_DESTROY_NULL(_depthStencilTexture); + + for (auto *colorTexture : _colorTextures) { + CC_SAFE_DESTROY(colorTexture); + } + _colorTextures.clear(); +} + +void RenderWindow::resize(uint32_t width, uint32_t height) { + if (_swapchain != nullptr) { + _swapchain->resize(width, height, orientationMap.at(Device::getDeviceOrientation())); + _width = _swapchain->getWidth(); + _height = _swapchain->getHeight(); + } else { + for (auto *colorTexture : _colorTextures) { + colorTexture->resize(width, height); + } + if (_depthStencilTexture != nullptr) { + _depthStencilTexture->resize(width, height); + } + _width = width; + _height = height; + } + + if (_frameBuffer != nullptr) { + _frameBuffer->destroy(); + _frameBuffer->initialize({ + _renderPass, + _colorTextures.get(), + _depthStencilTexture, + }); + } + + for (Camera *camera : _cameras) { + camera->resize(width, height); + } +} + +void RenderWindow::extractRenderCameras(std::vector &cameras) { + for (Camera *camera : _cameras) { + if (camera->isEnabled()) { + camera->update(); + cameras.emplace_back(camera); + } + } +} + +void RenderWindow::attachCamera(Camera *camera) { + for (Camera *cam : _cameras) { + if (cam == camera) return; + } + _cameras.emplace_back(camera); + sortCameras(); +} + +void RenderWindow::detachCamera(Camera *camera) { + for (auto it = _cameras.begin(); it != _cameras.end(); ++it) { + if (*it == camera) { + _cameras.erase(it); + return; + } + } +} + +void RenderWindow::clearCameras() { + for (Camera *camera : _cameras) { + CC_SAFE_DESTROY(camera); + } + _cameras.clear(); +} + +void RenderWindow::sortCameras() { + std::sort(_cameras.begin(), _cameras.end(), [](Camera *a, Camera *b) { return a->getPriority() < b->getPriority(); }); +} + +} // namespace scene + +} // namespace cc diff --git a/native/cocos/scene/RenderWindow.h b/native/cocos/scene/RenderWindow.h index 1616dbbde1..30ac9534ef 100644 --- a/native/cocos/scene/RenderWindow.h +++ b/native/cocos/scene/RenderWindow.h @@ -1,8 +1,8 @@ /**************************************************************************** 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 @@ -10,10 +10,10 @@ 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 @@ -25,18 +25,113 @@ #pragma once +#include "base/Macros.h" +#include "base/Vector.h" +#include "cocos/base/Optional.h" +#include "renderer/gfx-base/GFXDef-common.h" +#include "renderer/gfx-base/GFXDevice.h" #include "renderer/gfx-base/GFXFramebuffer.h" +#include "renderer/gfx-base/GFXSwapchain.h" #include "renderer/gfx-base/GFXTexture.h" +#include "scene/Camera.h" namespace cc { namespace scene { -struct RenderWindow final { - gfx::Swapchain * swapchain{nullptr}; - gfx::Framebuffer *frameBuffer{nullptr}; +struct IRenderWindowInfo { + cc::optional title; + uint32_t width{0}; + uint32_t height{0}; + gfx::RenderPassInfo renderPassInfo; + gfx::Swapchain * swapchain{nullptr}; +}; - inline uint getWidth() const { return frameBuffer->getColorTextures()[0]->getWidth(); } - inline uint getHeight() const { return frameBuffer->getColorTextures()[0]->getHeight(); } +/** + * @en The render window represents the render target, it could be an off screen frame buffer or the on screen buffer. + * @zh 渲染窗口代表了一个渲染目标,可以是离屏的帧缓冲,也可以是屏幕缓冲 + */ +class RenderWindow : public RefCounted { +public: + RenderWindow() = default; + ~RenderWindow() override = default; + + bool initialize(gfx::Device *device, IRenderWindowInfo &info); + void destroy(); + + /** + * @en Resize window. + * @zh 重置窗口大小。 + * @param width The new width. + * @param height The new height. + */ + void resize(uint32_t width, uint32_t height); + + void extractRenderCameras(std::vector &cameras); + + /** + * @zh + * 添加渲染相机 + * @param camera 渲染相机 + */ + void attachCamera(Camera *camera); + + /** + * @zh + * 移除渲染相机 + * @param camera 相机 + */ + void detachCamera(Camera *camera); + + /** + * @zh + * 销毁全部渲染相机 + */ + void clearCameras(); + + void sortCameras(); + + /** + * @en Get window width. Pre-rotated (i.e. rotationally invariant, always in identity/portrait mode) if possible. + * If you want to get oriented size instead, you should use [[Camera.width]] which corresponds to the current screen rotation. + * @zh 获取窗口宽度。如果支持交换链预变换,返回值将始终处于单位旋转(竖屏)坐标系下。如果需要获取旋转后的尺寸,请使用 [[Camera.width]]。 + */ + inline uint32_t getWidth() const { return _width; } + + /** + * @en Get window height. Pre-rotated (i.e. rotationally invariant, always in identity/portrait mode) if possible. + * If you want to get oriented size instead, you should use [[Camera.width]] which corresponds to the current screen rotation. + * @zh 获取窗口高度。如果支持交换链预变换,返回值将始终处于单位旋转(竖屏)坐标系下。如果需要获取旋转后的尺寸,请使用 [[Camera.height]]。 + */ + inline uint32_t getHeight() const { return _height; } + + /** + * @en Get the swapchain for this window, if there is one + * @zh 如果存在的话,获取此窗口的交换链 + */ + inline gfx::Swapchain *getSwapchain() { + return _swapchain; + } + + /** + * @en Get window frame buffer. + * @zh 帧缓冲对象。 + */ + inline gfx::Framebuffer *getFramebuffer() const { return _frameBuffer; } + + inline const std::vector> &getCameras() const { return _cameras; } + +private: + uint32_t _width{1}; + uint32_t _height{1}; + gfx::Swapchain * _swapchain{nullptr}; + std::string _title; + IntrusivePtr _renderPass; + IntrusivePtr _depthStencilTexture; + IntrusivePtr _frameBuffer; + std::vector> _cameras; + Vector _colorTextures; + + CC_DISALLOW_COPY_MOVE_ASSIGN(RenderWindow); }; } // namespace scene diff --git a/native/cocos/scene/Shadow.cpp b/native/cocos/scene/Shadow.cpp new file mode 100644 index 0000000000..544566f472 --- /dev/null +++ b/native/cocos/scene/Shadow.cpp @@ -0,0 +1,292 @@ +/**************************************************************************** + 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 "scene/Shadow.h" +#include +#include "core/Root.h" +#include "core/scene-graph/Node.h" +#include "scene/Pass.h" + +namespace cc { +namespace scene { + +// ShadowInfo + +void ShadowsInfo::setEnabled(bool val) { + if (_enabled == val) { + return; + } + + _enabled = val; + if (_resource != nullptr) { + _resource->setEnabled(val); + if (val) { + _resource->setType(_type); + } + } +} + +void ShadowsInfo::setType(ShadowType val) { + _type = val; + if (_resource != nullptr) { + _resource->setType(val); + } +} + +void ShadowsInfo::setShadowColor(const Color &val) { + _shadowColor.set(val); + if (_resource != nullptr) { + _resource->setShadowColor(val); + } +} + +void ShadowsInfo::setNormal(const Vec3 &val) { + _normal = val; + if (_resource != nullptr) { + _resource->setNormal(val); + } +} + +void ShadowsInfo::setDistance(float val) { + _distance = val; + if (_resource != nullptr) { + _resource->setDistance(val); + } +} + +void ShadowsInfo::setSaturation(float val) { + if (val > 1.0) { + _saturation = val / val; + if (_resource != nullptr) { + _resource->setSaturation(val / val); + } + } else { + _saturation = val; + if (_resource != nullptr) { + _resource->setSaturation(val); + } + } +} + +void ShadowsInfo::setPcf(PCFType val) { + _pcf = val; + if (_resource != nullptr) { + _resource->setPcf(val); + } +} + +void ShadowsInfo::setMaxReceived(uint32_t val) { + _maxReceived = val; + if (_resource != nullptr) { + _resource->setMaxReceived(val); + } +} + +void ShadowsInfo::setBias(float val) { + _bias = val; + if (_resource != nullptr) { + _resource->setBias(val); + } +} + +void ShadowsInfo::setNormalBias(float val) { + _normalBias = val; + if (_resource != nullptr) { + _resource->setNormalBias(val); + } +} + +void ShadowsInfo::setShadowMapSize(float value) { + _size.set(value, value); + if (_resource != nullptr) { + _resource->setShadowMapSize(value); + _resource->setShadowMapDirty(true); + } +} + +void ShadowsInfo::setFixedArea(bool val) { + _fixedArea = val; + if (_resource != nullptr) { + _resource->setFixedArea(val); + } +} + +void ShadowsInfo::setNear(float val) { + _near = val; + if (_resource != nullptr) { + _resource->setNear(val); + } +} + +void ShadowsInfo::setFar(float val) { + _far = CC_MIN(val, Shadows::MAX_FAR); + if (_resource != nullptr) { + _resource->setFar(val); + } +} + +void ShadowsInfo::setInvisibleOcclusionRange(float val) { + _invisibleOcclusionRange = CC_MIN(val, Shadows::MAX_FAR); + if (_resource) { + _resource->setInvisibleOcclusionRange(_invisibleOcclusionRange); + } +} + +void ShadowsInfo::setShadowDistance(float val) { + _shadowDistance = CC_MIN(val, Shadows::MAX_FAR); + if (_resource) { + _resource->setShadowDistance(_shadowDistance); + } +} + +void ShadowsInfo::setOrthoSize(float val) { + _orthoSize = val; + if (_resource != nullptr) { + _resource->setOrthoSize(val); + } +} + +void ShadowsInfo::setPlaneFromNode(Node *node) { + const auto &qt = node->getWorldRotation(); + _normal = Vec3::UNIT_Y; + _normal.transformQuat(qt); + _distance = _normal.dot(node->getWorldPosition()); +} + +void ShadowsInfo::activate(Shadows *resource) { + _resource = resource; + _resource->initialize(*this); + _resource->activate(); +} + +// +const float Shadows::COEFFICIENT_OF_EXPANSION{2.0F * std::sqrt(3.0F)}; + +void Shadows::initialize(const ShadowsInfo &shadowsInfo) { + _near = shadowsInfo.getNear(); + _far = shadowsInfo.getFar(); + setInvisibleOcclusionRange(shadowsInfo.getInvisibleOcclusionRange()); + setShadowDistance(shadowsInfo.getShadowDistance()); + _orthoSize = shadowsInfo.getOrthoSize(); + _size = shadowsInfo.getSize(); + _pcf = shadowsInfo.getPcf(); + _normal = shadowsInfo.getNormal(); + _distance = shadowsInfo.getDistance(); + setShadowColor(shadowsInfo.getShadowColor()); + _bias = shadowsInfo.getBias(); + _normalBias = shadowsInfo.getNormalBias(); + _maxReceived = shadowsInfo.getMaxReceived(); + _fixedArea = shadowsInfo.isFixedArea(); + setEnabled(shadowsInfo.isEnabled()); + _type = shadowsInfo.getType(); + _saturation = shadowsInfo.getSaturation(); +} + +void Shadows::destroy() { + if (_material) { + _material->destroy(); + _material = nullptr; + } + + if (_instancingMaterial) { + _instancingMaterial->destroy(); + _instancingMaterial = nullptr; + } +} + +gfx::Shader *Shadows::getPlanarShader(const std::vector &patches) { + if (!_material) { + createMaterial(); + } + + const auto &passes = *_material->getPasses(); + return passes[0]->getShaderVariant(patches); +} + +gfx::Shader *Shadows::getPlanarInstanceShader(const std::vector &patches) { + if (!_instancingMaterial) { + createInstanceMaterial(); + } + + const auto &passes = *_instancingMaterial->getPasses(); + return passes[0]->getShaderVariant(patches); +} + +void Shadows::activate() { + if (_enabled) { + if (_type == ShadowType::SHADOW_MAP) { + updatePipeline(); + } else { + updatePlanarInfo(); + } + } else { + auto *root = Root::getInstance(); + auto *pipeline = root->getPipeline(); + pipeline->setValue("CC_ENABLE_DIR_SHADOW", 0); + root->onGlobalPipelineStateChanged(); + } +} + +void Shadows::updatePlanarInfo() { + if (!_material) { + createMaterial(); + } + if (!_instancingMaterial) { + createInstanceMaterial(); + } + + auto *root = Root::getInstance(); + auto *pipeline = root->getPipeline(); + pipeline->setValue("CC_ENABLE_DIR_SHADOW", 0); + root->onGlobalPipelineStateChanged(); +} + +void Shadows::updatePipeline() { + auto *root = Root::getInstance(); + auto *pipeline = root->getPipeline(); + pipeline->setValue("CC_ENABLE_DIR_SHADOW", 1); + root->onGlobalPipelineStateChanged(); +} + +void Shadows::createInstanceMaterial() { + _instancingMaterial = new Material(); + + IMaterialInfo materialInfo; + materialInfo.effectName = "planar-shadow"; + MacroRecord microRecord{{"USE_INSTANCING", true}}; + materialInfo.defines = microRecord; + _instancingMaterial->initialize(materialInfo); +} + +void Shadows::createMaterial() { + _material = new Material(); + + IMaterialInfo materialInfo; + materialInfo.effectName = "planar-shadow"; + _material->initialize(materialInfo); +} + +} // namespace scene +} // namespace cc diff --git a/native/cocos/scene/Shadow.h b/native/cocos/scene/Shadow.h new file mode 100644 index 0000000000..bec94997f0 --- /dev/null +++ b/native/cocos/scene/Shadow.h @@ -0,0 +1,562 @@ +/**************************************************************************** + 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 +#include +#include "core/assets/Material.h" +#include "core/geometry/Sphere.h" +#include "math/Color.h" +#include "math/Mat4.h" +#include "math/Vec2.h" +#include "math/Vec3.h" +#include "renderer/gfx-base/GFXShader.h" +#include "scene/Define.h" + +namespace cc { + +class Node; + +namespace scene { + +/** + * @zh 阴影贴图分辨率。 + * @en The shadow map size. + * @static + * @enum Shadows.ShadowSize + */ +enum class ShadowSize { + /** + * @zh 分辨率 256 * 256。 + * @en shadow resolution 256 * 256. + * @readonly + */ + LOW_256X256 = 256, + + /** + * @zh 分辨率 512 * 512。 + * @en shadow resolution 512 * 512. + * @readonly + */ + MEDIUM_512X512 = 512, + + /** + * @zh 分辨率 1024 * 1024。 + * @en shadow resolution 1024 * 1024. + * @readonly + */ + HIGH_1024X1024 = 1024, + + /** + * @zh 分辨率 2048 * 2048。 + * @en shadow resolution 2048 * 2048. + * @readonly + */ + ULTRA_2048X2048 = 2048 +}; + +/** + * @zh 阴影类型。 + * @en The shadow type + * @enum Shadows.ShadowType + */ +enum class ShadowType { + /** + * @zh 平面阴影。 + * @en Planar shadow + * @property Planar + * @readonly + */ + PLANAR = 0, + + /** + * @zh 阴影贴图。 + * @en Shadow type + * @property ShadowMap + * @readonly + */ + SHADOW_MAP = 1, + NONE +}; + +/** + * @zh pcf阴影等级。 + * @en The pcf type + * @static + * @enum Shadows.PCFType + */ +enum class PCFType { + /** + * @zh x1 次采样 + * @en x1 times + * @readonly + */ + HARD = 0, + + /** + * @zh 软阴影 + * @en soft shadow + * @readonly + */ + SOFT = 1, + + /** + * @zh 软阴影 + * @en soft shadow + * @readonly + */ + SOFT_2X = 2 +}; + +class Shadows; + +class ShadowsInfo : public RefCounted { +public: + ShadowsInfo() = default; + ~ShadowsInfo() override = default; + /** + * @en Whether activate planar shadow + * @zh 是否启用平面阴影? + */ + void setEnabled(bool val); + inline bool isEnabled() const { + return _enabled; + } + + void setType(ShadowType val); + inline ShadowType getType() const { + return _type; + } + + /** + * @en Shadow color + * @zh 阴影颜色 + */ + void setShadowColor(const Color &val); + inline const Color &getShadowColor() const { + return _shadowColor; + } + + /** + * @en The normal of the plane which receives shadow + * @zh 阴影接收平面的法线 + */ + void setNormal(const Vec3 &val); + inline const Vec3 &getNormal() const { + return _normal; + } + + /** + * @en The distance from coordinate origin to the receiving plane. + * @zh 阴影接收平面与原点的距离 + */ + void setDistance(float val); + inline float getDistance() const { + return _distance; + } + + /** + * @en Shadow color saturation + * @zh 阴影颜色饱和度 + */ + void setSaturation(float val); + inline float getSaturation() const { + return _saturation; + } + + /** + * @en The normal of the plane which receives shadow + * @zh 阴影接收平面的法线 + */ + void setPcf(PCFType val); + inline PCFType getPcf() const { + return _pcf; + } + + /** + * @en get or set shadow max received + * @zh 获取或者设置阴影接收的最大光源数量 + */ + void setMaxReceived(uint32_t val); + inline uint32_t getMaxReceived() const { + return _maxReceived; + } + + /** + * @en get or set shadow map sampler offset + * @zh 获取或者设置阴影纹理偏移值 + */ + void setBias(float val); + inline float getBias() const { + return _bias; + } + + /** + * @en on or off Self-shadowing. + * @zh 打开或者关闭自阴影。 + */ + void setNormalBias(float val); + inline float getNormalBias() const { + return _normalBias; + } + + /** + * @en get or set shadow map size + * @zh 获取或者设置阴影纹理大小 + */ + void setShadowMapSize(float value); + inline float getShadowMapSize() const { + return _size.x; + } + + inline const Vec2 &getSize() const { + return _size; + } + + /** + * @en get or set fixed area shadow + * @zh 是否是固定区域阴影 + */ + void setFixedArea(bool val); + inline bool isFixedArea() const { + return _fixedArea; + } + + /** + * @en get or set shadow camera near + * @zh 获取或者设置阴影相机近裁剪面 + */ + void setNear(float val); + inline float getNear() const { + return _near; + } + + /** + * @en get or set shadow camera far + * @zh 获取或者设置阴影相机远裁剪面 + */ + void setFar(float val); + inline float getFar() const { + return _far; + } + + /** + * @en get or set shadow camera far + * @zh 获取或者设置潜在阴影产生的范围 + */ + void setInvisibleOcclusionRange(float val); + inline float getInvisibleOcclusionRange() const { + return _invisibleOcclusionRange; + } + + /** + * @en get or set shadow camera far + * @zh 获取或者设置潜在阴影产生的范围 + */ + void setShadowDistance(float val); + + inline float getShadowDistance() const { + return _shadowDistance; + } + + /** + * @en get or set shadow camera orthoSize + * @zh 获取或者设置阴影相机正交大小 + */ + void setOrthoSize(float val); + inline float getOrthoSize() const { + return _orthoSize; + } + + /** + * @en Set plane which receives shadow with the given node's world transformation + * @zh 根据指定节点的世界变换设置阴影接收平面的信息 + * @param node The node for setting up the plane + */ + void setPlaneFromNode(Node *node); + + void activate(Shadows *resource); + + float _distance{0.F}; + float _bias{0.00001F}; + float _normalBias{0.F}; + float _near{0.1F}; + float _far{10.F}; + float _shadowDistance{100.F}; + float _invisibleOcclusionRange{200.F}; + float _orthoSize{5.F}; + float _saturation{0.75}; + uint32_t _maxReceived{4}; + PCFType _pcf{PCFType::HARD}; + ShadowType _type{ShadowType::PLANAR}; + Shadows * _resource{nullptr}; + Color _shadowColor{0, 0, 0, 76}; + Vec3 _normal{0.F, 1.F, 0.F}; + Vec2 _size{512.F, 512.F}; + bool _firstSetCSM{false}; + bool _fixedArea{false}; + bool _enabled{false}; +}; + +class Shadows final { +public: + /** + * @en MAX_FAR. This is shadow camera max far. + * @zh 阴影相机的最远视距。 + */ + static constexpr float MAX_FAR{2000.F}; + + /** + * @en EXPANSION_RATIO. This is shadow boundingBox Coefficient of expansion. + * @zh 阴影包围盒扩大系数。 + */ + static const float COEFFICIENT_OF_EXPANSION; + + Shadows() = default; + ~Shadows() = default; + + void initialize(const ShadowsInfo &shadowsInfo); + void destroy(); + gfx::Shader *getPlanarShader(const std::vector &patches); + gfx::Shader *getPlanarInstanceShader(const std::vector &patches); + void activate(); + + /** + * @en Whether activate planar shadow. + * @zh 是否启用平面阴影? + */ + inline bool isEnabled() const { return _enabled; } + inline void setEnabled(bool val) { + _enabled = val; + activate(); + } + + /** + * @en The normal of the plane which receives shadow. + * @zh 阴影接收平面的法线。 + */ + inline const Vec3 &getNormal() const { return _normal; } + inline void setNormal(const Vec3 &val) { _normal.set(val); } + + /** + * @en The distance from coordinate origin to the receiving plane. + * @zh 阴影接收平面与原点的距离。 + */ + inline float getDistance() const { return _distance; } + inline void setDistance(float val) { _distance = val; } + + /** + * @en Shadow color. + * @zh 阴影颜色。 + */ + inline const Color &getShadowColor() const { return _shadowColor; } + inline void setShadowColor(const Color &color) { + _shadowColor.set(color); + _shadowColor4f[0] = static_cast(color.r) / 255.F; + _shadowColor4f[1] = static_cast(color.g) / 255.F; + _shadowColor4f[2] = static_cast(color.b) / 255.F; + _shadowColor4f[3] = static_cast(color.a) / 255.F; + } + inline const std::array &getShadowColor4f() const { return _shadowColor4f; } + + /** + * @en get or set shadow invisible Occlusion Range. + * @zh 控制潜在遮挡体产生的范围。 + */ + inline float getInvisibleOcclusionRange() const { + return _invisibleOcclusionRange; + } + + inline void setInvisibleOcclusionRange(float val) { + _invisibleOcclusionRange = val; + } + + /** + * @en get or set shadow distance. + * @zh 控制阴影的可视范围。 + */ + inline float getShadowDistance() const { + return _shadowDistance; + } + + inline void setShadowDistance(float val) { + _shadowDistance = val; + } + + /** + * @en Shadow type. + * @zh 阴影类型。 + */ + inline ShadowType getType() const { return _type; } + inline void setType(ShadowType val) { + _type = _enabled ? val : ShadowType::NONE; + activate(); + } + + /** + * @en get or set shadow camera near. + * @zh 获取或者设置阴影相机近裁剪面。 + */ + inline float getNear() const { return _near; } + inline void setNear(float val) { _near = val; } + + /** + * @en get or set shadow camera far. + * @zh 获取或者设置阴影相机远裁剪面。 + */ + inline float getFar() const { return _far; } + inline void setFar(float val) { _far = val; } + + /** + * @en get or set shadow camera orthoSize. + * @zh 获取或者设置阴影相机正交大小。 + */ + inline float getOrthoSize() const { return _orthoSize; } + inline void setOrthoSize(float val) { _orthoSize = val; } + + /** + * @en get or set shadow camera orthoSize. + * @zh 获取或者设置阴影纹理大小。 + */ + inline const Vec2 &getSize() const { return _size; } + inline void setSize(const Vec2 &val) { _size.set(val); } + inline void setShadowMapSize(float value) { + _size.set(value, value); + } + inline float getShadowMapSize() const { + return _size.x; + } + + /** + * @en get or set shadow pcf. + * @zh 获取或者设置阴影pcf等级。 + */ + inline PCFType getPcf() const { return _pcf; } + inline void setPcf(PCFType val) { _pcf = val; } + + /** + * @en shadow Map size has been modified. + * @zh 阴影贴图大小是否被修改。 + */ + inline bool isShadowMapDirty() const { return _shadowMapDirty; } + inline void setShadowMapDirty(bool val) { _shadowMapDirty = val; } + + /** + * @en get or set shadow bias. + * @zh 获取或者设置阴影偏移量。 + */ + inline float getBias() const { return _bias; } + inline void setBias(float val) { _bias = val; } + + /** + * @en get or set normal bias. + * @zh 设置或者获取法线偏移。 + */ + inline float getNormalBias() const { return _normalBias; } + inline void setNormalBias(float val) { _normalBias = val; } + + /** + * @en get or set shadow saturation. + * @zh 设置或者获取阴影饱和度。 + */ + inline float getSaturation() const { return _saturation; } + inline void setSaturation(float val) { _saturation = val; } + + /** + * @en get or set fixed area shadow + * @zh 是否是固定区域阴影 + */ + inline bool isFixedArea() const { return _fixedArea; } + inline void setFixedArea(bool val) { _fixedArea = val; } + + inline const Mat4 &getMatLight() const { return _matLight; } + inline Mat4 & getMatLight() { return _matLight; } + + inline Material *getMaterial() const { return _material.get(); } + inline Material *getInstancingMaterial() const { return _instancingMaterial.get(); } + + /** + * @en get or set shadow max received + * @zh 获取或者设置阴影接收的最大光源数量 + */ + inline void setMaxReceived(uint32_t val) { + _maxReceived = val; + } + + inline uint32_t getMaxReceived() const { + return _maxReceived; + } + +private: + void updatePlanarInfo(); + void updatePipeline(); + void createInstanceMaterial(); + void createMaterial(); + + /** + * @en The bounding sphere of the shadow map. + * @zh 用于计算固定区域阴影 Shadow map 的场景包围球. + */ + geometry::Sphere _fixedSphere{0.0F, 0.0F, 0.0F, 0.01F}; + + /** + * @en get or set shadow max received. + * @zh 阴影接收的最大灯光数量。 + */ + uint32_t _maxReceived{4}; + + // local set + bool _firstSetCSM{false}; + float _shadowCameraFar{0.F}; + Mat4 _matShadowView; + Mat4 _matShadowProj; + Mat4 _matShadowViewProj; + + Vec3 _normal{0.F, 1.F, 0.F}; + Color _shadowColor{0, 0, 0, 76}; + std::array _shadowColor4f{0.F, 0.F, 0.F, 76.F / 255.F}; + Mat4 _matLight; + IntrusivePtr _material; + IntrusivePtr _instancingMaterial; + Vec2 _size{512.F, 512.F}; + bool _enabled{false}; + float _distance{0.F}; + ShadowType _type{ShadowType::NONE}; + float _near{0.1F}; + float _far{10.F}; + float _invisibleOcclusionRange{200.F}; + float _shadowDistance{100.F}; + float _orthoSize{1.F}; + PCFType _pcf{PCFType::HARD}; + bool _shadowMapDirty{false}; + float _bias{0.F}; + float _normalBias{0.F}; + bool _fixedArea{false}; + float _saturation{0.75F}; +}; + +} // namespace scene +} // namespace cc diff --git a/native/cocos/scene/SkinningModel.cpp b/native/cocos/scene/SkinningModel.cpp deleted file mode 100644 index 3dfeb8bb4b..0000000000 --- a/native/cocos/scene/SkinningModel.cpp +++ /dev/null @@ -1,130 +0,0 @@ -/**************************************************************************** - 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 "scene/SkinningModel.h" -#include -#include "scene/RenderScene.h" - - -namespace cc { -namespace scene { -void SkinningModel::updateWorldMatrix(JointInfo* info, uint32_t stamp) { - int i = -1; - _worldMatrix.setIdentity(); - auto* currTransform = &info->transform; - auto parentSize = static_cast(info->parents.size()); - std::vector transStacks; - while (currTransform->node) { - if ((currTransform->stamp == stamp || currTransform->stamp + 1 == stamp) && !currTransform->node->getFlagsChanged()) { - _worldMatrix.set(currTransform->world); - currTransform->stamp = stamp; - break; - } - currTransform->stamp = stamp; - transStacks.push_back(currTransform); - i++; - if (i >= parentSize) { - break; - } - currTransform = &info->parents[i]; - } - while (i > -1) { - currTransform = transStacks[i--]; - auto* node = currTransform->node; - Mat4::fromRTS(node->getRotation(), node->getPosition(), node->getScale(), &currTransform->local); - Mat4::multiply(_worldMatrix, currTransform->local, &currTransform->world); - _worldMatrix.set(currTransform->world); - } -} - -void SkinningModel::updateUBOs(uint32_t stamp) { - Model::updateUBOs(stamp); - uint32_t bIdx = 0; - Mat4 mat4; - for (const JointInfo& jointInfo : _joints) { - Mat4::multiply(jointInfo.transform.world, jointInfo.bindpose, &mat4); - for (uint32_t buffer : jointInfo.buffers) { - uploadJointData(jointInfo.indices[bIdx] * 12, mat4, _dataArray[buffer]->data()); - bIdx++; - } - bIdx = 0; - } - bIdx = 0; - for (gfx::Buffer* buffer : _buffers) { - buffer->update(_dataArray[bIdx]->data(), buffer->getSize()); - bIdx++; - } -} - -void SkinningModel::uploadJointData(uint32_t base, const Mat4& mat, float* dst) { - memcpy(reinterpret_cast(dst + base), mat.m, sizeof(float) * 12); - dst[base + 3] = mat.m[12]; - dst[base + 7] = mat.m[13]; - dst[base + 11] = mat.m[14]; -} - -SkinningModel::~SkinningModel() { - for (auto* curr : _dataArray) { - delete curr; - } -} - -void SkinningModel::setBuffers(std::vector buffers) { - _buffers = std::move(buffers); - for (auto* buffer : _buffers) { - auto* data = new std::array(); - _dataArray.push_back(data); - } -} - -void SkinningModel::updateTransform(uint32_t stamp) { - auto* root = getTransform(); - if (root->getFlagsChanged() || root->getDirtyFlag()) { - root->updateWorldTransform(); - _transformUpdated = true; - } - Vec3 v3Min{INFINITY, INFINITY, INFINITY}; - Vec3 v3Max{-INFINITY, -INFINITY, -INFINITY}; - AABB ab1; - Vec3 v31; - Vec3 v32; - for (JointInfo& jointInfo : _joints) { - updateWorldMatrix(&jointInfo, stamp); - jointInfo.bound->transform(_worldMatrix, &ab1); - ab1.getBoundary(&v31, &v32); - Vec3::min(v3Min, v31, &v3Min); - Vec3::max(v3Max, v32, &v3Max); - } - if (_modelBounds.getValid() && _worldBounds) { - AABB::fromPoints(v3Min, v3Max, &_modelBounds); - _modelBounds.transform(root->getNodeLayout()->worldMatrix, _worldBounds); - } - - if (_scene) { - _scene->updateOctree(this); - } -} -} // namespace scene -} // namespace cc diff --git a/native/cocos/scene/Skybox.cpp b/native/cocos/scene/Skybox.cpp new file mode 100644 index 0000000000..a75732efd6 --- /dev/null +++ b/native/cocos/scene/Skybox.cpp @@ -0,0 +1,295 @@ +/**************************************************************************** + 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 "scene/Skybox.h" +#include "3d/assets/Mesh.h" +#include "3d/misc/CreateMesh.h" +#include "core/builtin/BuiltinResMgr.h" +#include "core/scene-graph/SceneGlobals.h" +#include "primitive/Primitive.h" +#include "renderer/core/MaterialInstance.h" +#include "renderer/core/PassUtils.h" +#include "renderer/gfx-base/GFXDevice.h" +#include "scene/Ambient.h" +#include "scene/Model.h" + +namespace { +cc::Mesh * skyboxMesh{nullptr}; // TODO(cjh): How to release ? +cc::Material *skyboxMaterial{nullptr}; +} // namespace +namespace cc { +namespace scene { + +void SkyboxInfo::setEnabled(bool val) { + _enabled = val; + if (_resource != nullptr) { + _resource->setEnabled(_enabled); + } +} + +void SkyboxInfo::setUseIBL(bool val) { + _useIBL = val; + if (_resource != nullptr) { + _resource->setUseIBL(_useIBL); + } +} + +void SkyboxInfo::setApplyDiffuseMap(bool val) { + _applyDiffuseMap = val; + if (_resource != nullptr) { + _resource->setUseDiffuseMap(val); + } +} + +void SkyboxInfo::setUseHDR(bool val) { + Root::getInstance()->getPipeline()->getPipelineSceneData()->setHDR(val); + _useHDR = val; + + // Switch UI to and from LDR/HDR textures depends on HDR state + if (_resource) { + setEnvmap(_resource->getEnvmap()); + setDiffuseMap(_resource->getDiffuseMap()); + + if (getDiffuseMap() == nullptr) { + setApplyDiffuseMap(false); + } + } + + if (_resource) { + _resource->setUseHDR(_useHDR); + } +} + +void SkyboxInfo::setEnvmap(TextureCube *val) { + const bool isHDR = Root::getInstance()->getPipeline()->getPipelineSceneData()->isHDR(); + if (isHDR) { + _envmapHDR = val; + } else { + _envmapLDR = val; + } + + if (!_envmapHDR) { + _diffuseMapHDR = nullptr; + _applyDiffuseMap = false; + setUseIBL(false); + } + + if (_resource) { + _resource->setEnvMaps(_envmapHDR, _envmapLDR); + _resource->setDiffuseMaps(_diffuseMapHDR, _diffuseMapLDR); + _resource->setUseDiffuseMap(_applyDiffuseMap); + _resource->setEnvmap(val); + } +} + +void SkyboxInfo::setDiffuseMap(TextureCube *val) { + const bool isHDR = Root::getInstance()->getPipeline()->getPipelineSceneData()->isHDR(); + if (isHDR) { + _diffuseMapHDR = val; + } else { + _diffuseMapHDR = val; + } + + if (_resource) { + _resource->setDiffuseMaps(_diffuseMapHDR, _diffuseMapLDR); + } +} + +void SkyboxInfo::activate(Skybox *resource) { + _resource = resource; // weak reference + if (_resource != nullptr) { + _resource->initialize(*this); + _resource->setEnvMaps(_envmapHDR, _envmapLDR); + _resource->setDiffuseMaps(_diffuseMapHDR, _diffuseMapLDR); + _resource->activate(); // update global DS first + } +} + +void Skybox::setEnvmap(TextureCube *val) { + const bool isHDR = Root::getInstance()->getPipeline()->getPipelineSceneData()->isHDR(); + if (isHDR) { + setEnvMaps(val, _envmapLDR); + } else { + setEnvMaps(_envmapHDR, val); + } +} + +void Skybox::initialize(const SkyboxInfo &skyboxInfo) { + _enabled = skyboxInfo.isEnabled(); + _useIBL = skyboxInfo.isUseIBL(); + _useDiffuseMap = skyboxInfo.isApplyDiffuseMap(); + _useHDR = skyboxInfo.isUseHDR(); +} + +void Skybox::setEnvMaps(TextureCube *envmapHDR, TextureCube *envmapLDR) { + _envmapHDR = envmapHDR; + _envmapLDR = envmapLDR; + const bool isHDR = Root::getInstance()->getPipeline()->getPipelineSceneData()->isHDR(); + if (isHDR) { + if (envmapHDR) { + Root::getInstance()->getPipeline()->getPipelineSceneData()->getAmbient()->getGroundAlbedo().w = static_cast(envmapHDR->mipmapLevel()); + } + } else if (envmapLDR) { + Root::getInstance()->getPipeline()->getPipelineSceneData()->getAmbient()->getGroundAlbedo().w = static_cast(envmapLDR->mipmapLevel()); + } + + updateGlobalBinding(); + updatePipeline(); +} + +void Skybox::setDiffuseMaps(TextureCube *diffuseMapHDR, TextureCube *diffuseMapLDR) { + _diffuseMapHDR = diffuseMapHDR; + _diffuseMapLDR = diffuseMapLDR; + updateGlobalBinding(); + updatePipeline(); +} + +void Skybox::activate() { + auto *pipeline = Root::getInstance()->getPipeline(); + _globalDSManager = pipeline->getGlobalDSManager(); + _default = BuiltinResMgr::getInstance()->get("default-cube-texture"); + + if (!_model) { + _model = Root::getInstance()->createModel(); + _model->initLocalDescriptors(CC_INVALID_INDEX); + _model->initWorldBoundDescriptors(CC_INVALID_INDEX); + } + auto *envmap = getEnvmap(); + bool isRGBE = envmap != nullptr ? envmap->isRGBE : _default->isRGBE; + + if (!skyboxMaterial) { + auto * mat = new Material(); + MacroRecord defines{{"USE_RGBE_CUBEMAP", isRGBE}}; + IMaterialInfo matInfo; + matInfo.effectName = std::string{"skybox"}; + matInfo.defines = IMaterialInfo::DefinesType{defines}; + mat->initialize({matInfo}); + IMaterialInstanceInfo matInstInfo; + matInstInfo.parent = mat; + skyboxMaterial = new MaterialInstance(matInstInfo); + } + + if (_enabled) { + if (!skyboxMesh) { + IBoxOptions options; + options.width = 2; + options.height = 2; + options.length = 2; + skyboxMesh = createMesh( + createGeometry( + PrimitiveType::BOX, + PrimitiveOptions{options})); + } + _model->initSubModel(0, skyboxMesh->getRenderingSubMeshes()[0], skyboxMaterial); + } + + if (!getEnvmap()) { + setEnvmap(_default.get()); + } + + if (!getDiffuseMap()) { + setDiffuseMap(_default.get()); + } + + updateGlobalBinding(); + updatePipeline(); +} + +void Skybox::updatePipeline() const { + if (isEnabled() && skyboxMaterial != nullptr) { + skyboxMaterial->recompileShaders({{"USE_RGBE_CUBEMAP", isRGBE()}}); + } + + if (_model != nullptr && skyboxMaterial != nullptr) { + _model->setSubModelMaterial(0, skyboxMaterial); + } + + Root * root = Root::getInstance(); + pipeline::RenderPipeline *pipeline = root->getPipeline(); + + const bool useRGBE = isRGBE(); + const int32_t useIBLValue = isUseIBL() ? (useRGBE ? 2 : 1) : 0; + const int32_t useDiffuseMapValue = (isUseIBL() && isUseDiffuseMap() && getDiffuseMap() != nullptr) ? (useRGBE ? 2 : 1) : 0; + const bool useHDRValue = isUseHDR(); + + auto iter = pipeline->getMacros().find("CC_USE_IBL"); + if (iter != pipeline->getMacros().end()) { + const MacroValue ¯oIBL = iter->second; + const int32_t * macroIBLPtr = cc::get_if(¯oIBL); + if (macroIBLPtr != nullptr && (*macroIBLPtr == useIBLValue)) { + auto iter = pipeline->getMacros().find("CC_USE_DIFFUSEMAP"); + if (iter != pipeline->getMacros().end()) { + const MacroValue ¯oDIFFUSEMAP = iter->second; + const int32_t * macroDIFFUSEMAPPtr = cc::get_if(¯oDIFFUSEMAP); + if (macroDIFFUSEMAPPtr != nullptr && ((*macroDIFFUSEMAPPtr != 0) == useDiffuseMapValue)) { + auto iter = pipeline->getMacros().find("CC_USE_HDR"); + if (iter != pipeline->getMacros().end()) { + const MacroValue ¯oHDR = iter->second; + const int32_t * macroHDRPtr = cc::get_if(¯oHDR); + if (macroHDRPtr != nullptr && ((*macroHDRPtr != 0) == useHDRValue)) { + return; + } + } + } + } + } + } + pipeline->setValue("CC_USE_IBL", useIBLValue); + pipeline->setValue("CC_USE_DIFFUSEMAP", useDiffuseMapValue); + pipeline->setValue("CC_USE_HDR", useHDRValue); + + root->onGlobalPipelineStateChanged(); +} + +void Skybox::updateGlobalBinding() { + if (_globalDSManager != nullptr) { + auto *device = Root::getInstance()->getDevice(); + auto *envmap = getEnvmap(); + if (!envmap) { + envmap = _default.get(); + } + if (envmap != nullptr) { + auto *texture = envmap->getGFXTexture(); + auto *sampler = device->getSampler(envmap->getSamplerInfo()); + _globalDSManager->bindSampler(pipeline::ENVIRONMENT::BINDING, sampler); + _globalDSManager->bindTexture(pipeline::ENVIRONMENT::BINDING, texture); + } + + auto *diffuseMap = getDiffuseMap(); + if (!diffuseMap) { + diffuseMap = _default.get(); + } + if (diffuseMap != nullptr) { + auto *texture = diffuseMap->getGFXTexture(); + auto *sampler = device->getSampler(envmap->getSamplerInfo()); + _globalDSManager->bindSampler(pipeline::DIFFUSEMAP::BINDING, sampler); + _globalDSManager->bindTexture(pipeline::DIFFUSEMAP::BINDING, texture); + } + _globalDSManager->update(); + } +} + +} // namespace scene +} // namespace cc diff --git a/native/cocos/scene/Skybox.h b/native/cocos/scene/Skybox.h new file mode 100644 index 0000000000..5196087ba8 --- /dev/null +++ b/native/cocos/scene/Skybox.h @@ -0,0 +1,275 @@ +/**************************************************************************** + 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/Macros.h" +#include "base/RefCounted.h" +#include "core/Root.h" +#include "core/assets/TextureCube.h" +#include "pipeline/GlobalDescriptorSetManager.h" +#include "renderer/gfx-base/GFXTexture.h" +#include "scene/Model.h" + +namespace cc { +namespace scene { + +class Skybox; + +/** + * @en Skybox related information + * @zh 天空盒相关信息 + */ +// @ccclass('cc.SkyboxInfo') +// @help('i18n:cc.Skybox') +class SkyboxInfo : public RefCounted { +public: + SkyboxInfo(/* args */) = default; + ~SkyboxInfo() override = default; + + /** + * @en Whether to use diffuse convolution map. Enabled -> Will use map specified. Disabled -> Will revert to hemispheric lighting + * @zh 是否为IBL启用漫反射卷积图?不启用的话将使用默认的半球光照 + */ + // @visible(function (this : SkyboxInfo) { + // if (useIBL) { + // return true; + // } + // return false; + // }) + // @editable + // @tooltip('i18n:skybox.applyDiffuseMap') + void setApplyDiffuseMap(bool val); + + bool isApplyDiffuseMap() const { return _applyDiffuseMap; } + + /** + * @en Whether activate skybox in the scene + * @zh 是否启用天空盒? + */ + // @editable + // @tooltip('i18n:skybox.enabled') + void setEnabled(bool val); + inline bool isEnabled() const { return _enabled; } + + /** + * @en Whether use environment lighting + * @zh 是否启用环境光照? + */ + // @editable + // @tooltip('i18n:skybox.useIBL') + void setUseIBL(bool val); + inline bool isUseIBL() const { return _useIBL; } + + /** + * @en Toggle HDR (TODO: This SHOULD be moved into it's own subgroup away from skybox) + * @zh 是否启用HDR? + */ + // @editable + // @tooltip('i18n:skybox.useHDR') + void setUseHDR(bool val); + inline bool isUseHDR() const { + const bool isHDR = Root::getInstance()->getPipeline()->getPipelineSceneData()->isHDR(); + return _useHDR; + } + + /** + * @en The texture cube used for the skybox + * @zh 使用的立方体贴图 + */ + // @editable + // @type(TextureCube) + // @tooltip('i18n:skybox.envmap') + void setEnvmap(TextureCube *val); + inline TextureCube *getEnvamp() const { + const bool isHDR = Root::getInstance()->getPipeline()->getPipelineSceneData()->isHDR(); + return isHDR ? _envmapHDR : _envmapLDR; + } + + /** + * @en The optional diffusion convolution map used in tandem with IBL + * @zh 使用的漫反射卷积图 + */ + // @visible(function (this : SkyboxInfo) { + // if (this.useIBL) { + // return true; + // } + // return false; + // }) + // @editable + // @readOnly + // @type(TextureCube) + void setDiffuseMap(TextureCube *val); + inline TextureCube *getDiffuseMap() const { + const bool isHDR = Root::getInstance()->getPipeline()->getPipelineSceneData()->isHDR(); + return isHDR ? _diffuseMapHDR : _diffuseMapLDR; + } + + void activate(Skybox *resource); + + // cjh JSB need to bind the property, so need to make it public + // private: + // @serializable + bool _applyDiffuseMap{false}; + // @serializable + // @type(TextureCube) + // @formerlySerializedAs('_envmap') + TextureCube *_envmapHDR{nullptr}; + // @serializable + // @type(TextureCube) + TextureCube *_envmapLDR{nullptr}; + // @serializable + // @type(TextureCube) + TextureCube *_diffuseMapHDR{nullptr}; + // @serializable + // @type(TextureCube) + TextureCube *_diffuseMapLDR{nullptr}; + // @serializable + bool _enabled{false}; + // @serializable + bool _useIBL{false}; + // @serializable + bool _useHDR{true}; + + Skybox *_resource{nullptr}; +}; + +class Skybox final { +public: + Skybox() = default; + ~Skybox() = default; + + void initialize(const SkyboxInfo &skyboxInfo); + + void setEnvMaps(TextureCube *envmapHDR, TextureCube *envmapLDR); + + void setDiffuseMaps(TextureCube *diffuseMapHDR, TextureCube *diffuseMapLDR); + + void activate(); + + inline Model *getModel() const { return _model.get(); } + + /** + * @en Whether activate skybox in the scene + * @zh 是否启用天空盒? + */ + inline bool isEnabled() const { return _enabled; } + inline void setEnabled(bool val) { + _enabled = val; + if (val) { + activate(); + } else { + updatePipeline(); + } + } + + /** + * @en HDR + * @zh 是否启用HDR? + */ + inline bool isUseHDR() const { return _useHDR; } + inline void setUseHDR(bool val) { + _useHDR = val; + setEnvMaps(_envmapHDR, _envmapLDR); + } + + /** + * @en Whether use environment lighting + * @zh 是否启用环境光照? + */ + inline bool isUseIBL() const { return _useIBL; } + inline void setUseIBL(bool val) { + _useIBL = val; + updatePipeline(); + } + + /** + * @en Whether use diffuse convolution map lighting + * @zh 是否为IBL启用漫反射卷积图? + */ + inline bool isUseDiffuseMap() const { return _useDiffuseMap; } + inline void setUseDiffuseMap(bool val) { + _useDiffuseMap = val; + updateGlobalBinding(); + updatePipeline(); + } + + /** + * @en The texture cube used for the skybox + * @zh 使用的立方体贴图 + */ + inline TextureCube *getEnvmap() const { + const bool isHDR = Root::getInstance()->getPipeline()->getPipelineSceneData()->isHDR(); + return isHDR ? _envmapHDR : _envmapLDR; + } + void setEnvmap(TextureCube *val); + + /** + * @en Whether enable RGBE data support in skybox shader + * @zh 是否需要开启 shader 内的 RGBE 数据支持? + */ + inline bool isRGBE() const { + auto *envmap = getEnvmap(); + return envmap != nullptr ? envmap->isRGBE : false; + } + + /** + * @en The texture cube used diffuse convolution map + * @zh 使用的漫反射卷积图 + */ + inline TextureCube *getDiffuseMap() const { + const bool isHDR = Root::getInstance()->getPipeline()->getPipelineSceneData()->isHDR(); + return isHDR ? _diffuseMapHDR.get() : _diffuseMapLDR.get(); + } + inline void setDiffuseMap(TextureCube *val) { + const bool isHDR = Root::getInstance()->getPipeline()->getPipelineSceneData()->isHDR(); + if (isHDR) { + setDiffuseMaps(val, _envmapLDR); + } else { + setDiffuseMaps(_envmapHDR, val); + } + } + +private: + void updatePipeline() const; + void updateGlobalBinding(); + + IntrusivePtr _envmapLDR; + IntrusivePtr _envmapHDR; + IntrusivePtr _diffuseMapLDR; + IntrusivePtr _diffuseMapHDR; + pipeline::GlobalDSManager *_globalDSManager{nullptr}; + IntrusivePtr _model; + IntrusivePtr _default; + bool _enabled{false}; + bool _useIBL{false}; + bool _useHDR{true}; + bool _useDiffuseMap{false}; + + CC_DISALLOW_COPY_MOVE_ASSIGN(Skybox); +}; + +} // namespace scene +} // namespace cc diff --git a/native/cocos/scene/SphereLight.cpp b/native/cocos/scene/SphereLight.cpp index 44ac9d1bf8..43fea1c1af 100644 --- a/native/cocos/scene/SphereLight.cpp +++ b/native/cocos/scene/SphereLight.cpp @@ -24,18 +24,48 @@ ****************************************************************************/ #include "scene/SphereLight.h" +#include "core/Root.h" +#include "core/scene-graph/Node.h" namespace cc { namespace scene { +SphereLight::SphereLight() { + _type = LightType::SPHERE; +} + +void SphereLight::initialize() { + Light::initialize(); + + _size = 0.15F; + _range = 1.0F; + setLuminance(1700 / Light::nt2lm(_size)); + _luminanceLDR = 1.0; +} void SphereLight::update() { - if (_node && (_node->getFlagsChanged() || _needUpdate)) { + if (_node && (_node->getChangedFlags() || _needUpdate)) { _node->updateWorldTransform(); _pos = _node->getWorldPosition(); - _aabb->set(_pos, {_range, _range, _range}); + _aabb.set(_pos, {_range, _range, _range}); _needUpdate = false; } } +float SphereLight::getLuminance() const { + auto *sceneData = Root::getInstance()->getPipeline()->getPipelineSceneData(); + auto isHDR = sceneData->isHDR(); + return isHDR ? _luminanceHDR : _luminanceLDR; +} + +void SphereLight::setLuminance(float value) { + auto *sceneData = Root::getInstance()->getPipeline()->getPipelineSceneData(); + auto isHDR = sceneData->isHDR(); + if (isHDR) { + _luminanceHDR = value; + } else { + _luminanceLDR = value; + } +} + } // namespace scene } // namespace cc diff --git a/native/cocos/scene/SphereLight.h b/native/cocos/scene/SphereLight.h index b0f805a2cd..efd9b68094 100644 --- a/native/cocos/scene/SphereLight.h +++ b/native/cocos/scene/SphereLight.h @@ -25,49 +25,54 @@ #pragma once +#include "core/geometry/AABB.h" #include "math/Vec3.h" -#include "scene/AABB.h" #include "scene/Light.h" namespace cc { namespace scene { -class SphereLight : public Light { +class SphereLight final : public Light { public: - SphereLight() = default; - SphereLight(const SphereLight &) = delete; - SphereLight(SphereLight &&) = delete; - ~SphereLight() override = default; - SphereLight &operator=(const SphereLight &) = delete; - SphereLight &operator=(SphereLight &&) = delete; + SphereLight(); + ~SphereLight() override = default; + void initialize() override; void update() override; - inline void setAABB(AABB *aabb) { _aabb = aabb; } - inline void setLuminanceHDR(float illum) { _luminanceHDR = illum; } - inline void setLuminanceLDR(float illum) { _luminanceLDR = illum; } - inline void setPosition(const Vec3 &pos) { _pos = pos; } - inline void setRange(float range) { + inline const Vec3 &getPosition() const { return _pos; } + inline void setPosition(const Vec3 &pos) { _pos = pos; } + + inline float getSize() const { return _size; } + inline void setSize(float size) { _size = size; } + + inline float getRange() const { return _range; } + inline void setRange(float range) { _range = range; _needUpdate = true; } - inline void setSize(float size) { _size = size; } - inline AABB * getAABB() const { return _aabb; } - inline float getLuminanceHDR() const { return _luminanceHDR; } - inline float getLuminanceLDR() const { return _luminanceLDR; } - inline const Vec3 &getPosition() const { return _pos; } - inline float getRange() const { return _range; } - inline float getSize() const { return _size; } + float getLuminance() const; + void setLuminance(float); + + inline void setLuminanceHDR(float illum) { _luminanceHDR = illum; } + inline float getLuminanceHDR() const { return _luminanceHDR; } + + inline void setLuminanceLDR(float illum) { _luminanceLDR = illum; } + inline float getLuminanceLDR() const { return _luminanceLDR; } + + inline const geometry::AABB &getAABB() const { return _aabb; } private: - bool _needUpdate{false}; - float _luminanceHDR{0.F}; - float _luminanceLDR{0.F}; - float _range{0.F}; - float _size{0.F}; - Vec3 _pos; - AABB *_aabb{nullptr}; + bool _needUpdate{false}; + float _luminanceHDR{0.F}; + float _luminanceLDR{0.F}; + float _range{0.F}; + float _size{0.F}; + Vec3 _pos; + geometry::AABB _aabb; + + CC_DISALLOW_COPY_MOVE_ASSIGN(SphereLight); }; } // namespace scene diff --git a/native/cocos/scene/SpotLight.cpp b/native/cocos/scene/SpotLight.cpp index 59bfcdfffa..c99248c1fa 100644 --- a/native/cocos/scene/SpotLight.cpp +++ b/native/cocos/scene/SpotLight.cpp @@ -1,8 +1,8 @@ /**************************************************************************** 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 @@ -10,10 +10,10 @@ 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 @@ -24,32 +24,79 @@ ****************************************************************************/ #include "scene/SpotLight.h" +#include +#include "core/Root.h" +#include "core/scene-graph/Node.h" +#include "math/Math.h" namespace cc { namespace scene { + +SpotLight::SpotLight() { + _type = LightType::SPOT; + _aabb = new geometry::AABB(); + _aabb->addRef(); + _frustum = new geometry::Frustum(); + _frustum->addRef(); +} + +SpotLight::~SpotLight() { + _aabb->release(); + _frustum->release(); +} + +void SpotLight::initialize() { + Light::initialize(); + + _size = 0.15F; + _aspect = 1.0F; + setLuminance(1700 / Light::nt2lm(_size)); + setLuminanceLDR(1.F); + _range = cos(math::PI / 6); + _dir.set(1.0, -1.0, -1.0); +} + +float SpotLight::getLuminance() const { + const bool isHDR = Root::getInstance()->getPipeline()->getPipelineSceneData()->isHDR(); + return isHDR ? _luminanceHDR : _luminanceLDR; +} + +void SpotLight::setLuminance(float value) { + const bool isHDR = Root::getInstance()->getPipeline()->getPipelineSceneData()->isHDR(); + if (isHDR) { + setLuminanceHDR(value); + } else { + setLuminanceLDR(value); + } +} + void SpotLight::update() { - if (_node && (_node->getFlagsChanged() || _needUpdate)) { + if (_node && (_node->getChangedFlags() || _needUpdate)) { + _pos = _node->getWorldPosition(); + Mat4 matView; Mat4 matProj; Mat4 matViewProj; Mat4 matViewProjInv; - _node->updateWorldRTMatrix(); - _pos = _node->getWorldPosition(); + _dir = _forward; _dir.transformQuat(_node->getWorldRotation()); _dir.normalize(); _aabb->set(_pos, {_range, _range, _range}); - matView = _node->getWorldRTMatrix(); + + // view matrix + matView = _node->getWorldRT(); matView.inverse(); Mat4::createPerspective(_angle, 1.0F, 0.001F, _range, &matProj); Mat4::multiply(matProj, matView, &matViewProj); - _frustum.update(matViewProj, matViewProjInv); + _frustum->update(matViewProj, matViewProjInv); _needUpdate = false; } } + } // namespace scene } // namespace cc diff --git a/native/cocos/scene/SpotLight.h b/native/cocos/scene/SpotLight.h index f7303426d5..7ff233fcec 100644 --- a/native/cocos/scene/SpotLight.h +++ b/native/cocos/scene/SpotLight.h @@ -1,8 +1,8 @@ /**************************************************************************** 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 @@ -10,10 +10,10 @@ 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 @@ -25,72 +25,79 @@ #pragma once -#include "scene/AABB.h" -#include "scene/Frustum.h" +#include "core/geometry/AABB.h" +#include "core/geometry/Frustum.h" +#include "renderer/pipeline/RenderPipeline.h" #include "scene/Light.h" namespace cc { namespace scene { -class SpotLight : public Light { +class SpotLight final : public Light { public: - SpotLight() = default; - SpotLight(const SpotLight &) = delete; - SpotLight(SpotLight &&) = delete; - ~SpotLight() override = default; - SpotLight &operator=(const SpotLight &) = delete; - SpotLight &operator=(SpotLight &&) = delete; + SpotLight(); + ~SpotLight() override; + void initialize() override; void update() override; - inline void setAABB(AABB *aabb) { _aabb = aabb; } - inline void setAngle(float angle) { - _spotAngle = angle; - _angle = acos(_spotAngle) * 2; - _needUpdate = true; - } - inline void setAspect(float aspect) { - _aspect = aspect; - _needUpdate = true; - } - inline void setDirection(const Vec3 &dir) { _dir = dir; } - inline void setFrustum(Frustum frustum) { _frustum = std::move(frustum); } - inline void setLuminanceHDR(float illu) { _luminanceHDR = illu; } - inline void setLuminanceLDR(float illu) { _luminanceLDR = illu; } - inline void setNeedUpdate(bool value) { _needUpdate = value; } - inline void setRange(float range) { + inline const Vec3 &getPosition() const { return _pos; } + + inline float getSize() const { return _size; } + inline void setSize(float size) { _size = size; } + + inline float getRange() const { return _range; } + inline void setRange(float range) { _range = range; _needUpdate = true; } - inline void setPosition(const Vec3 &pos) { _pos = pos; } - inline void setSize(float size) { _size = size; } - inline AABB * getAABB() const { return _aabb; } - inline float getAngle() const { return _angle; } - inline float getSpotAngle() const { return _spotAngle; } - inline float getAspect() const { return _aspect; } - inline const Vec3 & getDirection() const { return _dir; } - inline const Frustum &getFrustum() const { return _frustum; } - inline float getLuminanceHDR() const { return _luminanceHDR; } - inline float getLuminanceLDR() const { return _luminanceLDR; } - inline bool getNeedUpdate() const { return _needUpdate; } - inline float getRange() const { return _range; } - inline const Vec3 & getPosition() const { return _pos; } - inline float getSize() const { return _size; } + inline void setLuminanceHDR(float value) { _luminanceHDR = value; } + inline void setLuminanceLDR(float value) { _luminanceLDR = value; } + + float getLuminance() const; + void setLuminance(float value); + + inline const Vec3 &getDirection() const { return _dir; } + + inline float getSpotAngle() const { return _spotAngle; } + inline void setSpotAngle(float val) { + _angle = val; + _spotAngle = cos(val * 0.5F); + _needUpdate = true; + } + + inline float getAngle() const { return _angle; } + + inline float getAspect() const { return _aspect; } + inline void setAspect(float aspect) { + _aspect = aspect; + _needUpdate = true; + } + + inline const geometry::AABB &getAABB() const { return *_aabb; } + + inline const geometry::Frustum &getFrustum() const { return *_frustum; } + inline float getLuminanceHDR() const { return _luminanceHDR; } + inline float getLuminanceLDR() const { return _luminanceLDR; } + + inline void setFrustum(const geometry::Frustum &frustum) { *_frustum = frustum; } private: - bool _needUpdate{false}; - float _luminanceHDR{0.F}; - float _luminanceLDR{0.F}; - float _range{0.F}; - float _size{0.F}; - float _angle{0.F}; - float _spotAngle{0.F}; - float _aspect{0.F}; - Vec3 _dir; - Vec3 _pos; - AABB * _aabb{nullptr}; - Frustum _frustum; + bool _needUpdate{false}; + float _luminanceHDR{0.F}; + float _luminanceLDR{0.F}; + float _range{0.F}; + float _size{0.F}; + float _angle{0.F}; + float _spotAngle{0.F}; + float _aspect{0.F}; + Vec3 _dir; + Vec3 _pos; + geometry::AABB* _aabb{nullptr}; + geometry::Frustum* _frustum{nullptr}; + + CC_DISALLOW_COPY_MOVE_ASSIGN(SpotLight); }; } // namespace scene diff --git a/native/cocos/scene/SubModel.cpp b/native/cocos/scene/SubModel.cpp index d7838d1c83..bfd177433e 100644 --- a/native/cocos/scene/SubModel.cpp +++ b/native/cocos/scene/SubModel.cpp @@ -23,7 +23,12 @@ THE SOFTWARE. ****************************************************************************/ #include "scene/SubModel.h" +#include "core/Root.h" +#include "pipeline/Define.h" +#include "renderer/pipeline/forward/ForwardPipeline.h" +#include "scene/Model.h" #include "scene/Pass.h" +#include "scene/Shadow.h" namespace cc { namespace scene { @@ -32,16 +37,37 @@ SubModel::SubModel() { _id = generateId(); } +const static uint32_t MAX_PASS_COUNT = 8; +gfx::DescriptorSetInfo dsInfo = gfx::DescriptorSetInfo(); + void SubModel::update() { - for (Pass *pass : _passes) { + auto &passes = *_passes; + for (Pass *pass : passes) { pass->update(); } - _descriptSet->update(); + _descriptorSet->update(); _worldBoundDescriptorSet->update(); } -SubModel::~SubModel() { - delete _subMesh; +void SubModel::setPasses(const std::shared_ptr>> &pPasses) { + if (!pPasses || pPasses->size() > MAX_PASS_COUNT) { + // errorID(12004, MAX_PASS_COUNT); //errorID not implemented + return; + } + + _passes = pPasses; + flushPassInfo(); + + const auto &passes = *_passes; + if (passes[0].get()->getBatchingScheme() == BatchingSchemes::VB_MERGING) { + _subMesh->genFlatBuffers(); + } + // DS layout might change too + if (_descriptorSet) { + _descriptorSet->destroy(); + dsInfo.layout = passes[0]->getLocalSetLayout(); + _descriptorSet = _device->createDescriptorSet(dsInfo); + } } gfx::Shader *SubModel::getShader(uint index) const { @@ -53,11 +79,160 @@ gfx::Shader *SubModel::getShader(uint index) const { } Pass *SubModel::getPass(uint index) const { - if (index >= _passes.size()) { + auto &passes = *_passes; + if (index >= passes.size()) { return nullptr; } - return _passes[index]; + return passes[index]; +} + +void SubModel::initialize(RenderingSubMesh *subMesh, const std::shared_ptr>> &pPasses, const std::vector &patches) { + _device = Root::getInstance()->getDevice(); + if (!pPasses->empty()) { + dsInfo.layout = (*pPasses)[0]->getLocalSetLayout(); + } + _inputAssembler = _device->createInputAssembler(subMesh->getIaInfo()); + _descriptorSet = _device->createDescriptorSet(dsInfo); + auto * pipeline = Root::getInstance()->getPipeline(); + auto * occlusionPass = pipeline->getPipelineSceneData()->getOcclusionQueryPass(); + cc::gfx::DescriptorSetInfo occlusionDSInfo; + occlusionDSInfo.layout = occlusionPass->getLocalSetLayout(); + _worldBoundDescriptorSet = _device->createDescriptorSet(occlusionDSInfo); + _subMesh = subMesh; + _patches = patches; + _passes = pPasses; + + flushPassInfo(); + + const auto &passes = *_passes; + if (passes[0]->getBatchingScheme() == BatchingSchemes::VB_MERGING) { + subMesh->genFlatBuffers(); + } + _priority = pipeline::RenderPriority::DEFAULT; + + // initialize resources for reflection material + if (passes[0]->getPhase() == pipeline::getPhaseID("reflection")) { + auto * mainWindow = Root::getInstance()->getMainWindow(); + uint32_t texWidth = mainWindow->getWidth(); + uint32_t texHeight = mainWindow->getHeight(); + const uint32_t minSize = 512; + if (texHeight < texWidth) { + texWidth = minSize * texWidth / texHeight; + texHeight = minSize; + } else { + texWidth = minSize; + texHeight = minSize * texHeight / texWidth; + } + _reflectionTex = _device->createTexture(gfx::TextureInfo{ + gfx::TextureType::TEX2D, + gfx::TextureUsageBit::STORAGE | gfx::TextureUsageBit::TRANSFER_SRC | gfx::TextureUsageBit::SAMPLED, + gfx::Format::RGBA8, + texWidth, + texHeight, + }); + _descriptorSet->bindTexture(pipeline::REFLECTIONTEXTURE::BINDING, _reflectionTex); + + const gfx::SamplerInfo samplerInfo{ + gfx::Filter::LINEAR, + gfx::Filter::LINEAR, + gfx::Filter::NONE, + gfx::Address::CLAMP, + gfx::Address::CLAMP, + gfx::Address::CLAMP, + }; + _reflectionSampler = _device->getSampler(samplerInfo); + _descriptorSet->bindSampler(pipeline::REFLECTIONTEXTURE::BINDING, _reflectionSampler); + _descriptorSet->bindTexture(pipeline::REFLECTIONTEXTURE::BINDING, _reflectionTex); + } +} + +// TODO(): +// This is a temporary solution +// It should not be written in a fixed way, or modified by the user +void SubModel::initPlanarShadowShader() { + auto * pipeline = static_cast(Root::getInstance()->getPipeline()); + Shadows *shadows = pipeline->getPipelineSceneData()->getShadows(); + if (shadows != nullptr) { + _planarShader = shadows->getPlanarShader(_patches); + } else { + _planarShader = nullptr; + } +} + +// TODO(): +// This is a temporary solution +// It should not be written in a fixed way, or modified by the user +void SubModel::initPlanarShadowInstanceShader() { + auto * pipeline = static_cast(Root::getInstance()->getPipeline()); + Shadows *shadows = pipeline->getPipelineSceneData()->getShadows(); + if (shadows != nullptr) { + _planarInstanceShader = shadows->getPlanarInstanceShader(_patches); + } else { + _planarInstanceShader = nullptr; + } +} + +void SubModel::destroy() { + CC_SAFE_DESTROY_NULL(_descriptorSet); + CC_SAFE_DESTROY_NULL(_inputAssembler); + CC_SAFE_DESTROY_NULL(_worldBoundDescriptorSet); + + _priority = pipeline::RenderPriority::DEFAULT; + + _patches.clear(); + _subMesh = nullptr; + _passes.reset(); + _shaders.clear(); + + CC_SAFE_DESTROY_NULL(_reflectionTex); + _reflectionSampler = nullptr; +} + +void SubModel::onPipelineStateChanged() { + auto &passes = *_passes; + if (passes.empty()) return; + + for (Pass *pass : passes) { + pass->beginChangeStatesSilently(); + pass->tryCompile(); // force update shaders + pass->endChangeStatesSilently(); + } + flushPassInfo(); +} + +void SubModel::onMacroPatchesStateChanged(const std::vector &patches) { + _patches = patches; + auto &passes = *_passes; + if (passes.empty()) return; + for (Pass *pass : passes) { + pass->beginChangeStatesSilently(); + pass->tryCompile(); // force update shaders + pass->endChangeStatesSilently(); + } + flushPassInfo(); +} + +void SubModel::flushPassInfo() { + auto &passes = *_passes; + if (passes.empty()) return; + if (!_shaders.empty()) { + _shaders.clear(); + } + _shaders.resize(passes.size()); + for (uint i = 0; i < passes.size(); ++i) { + _shaders[i] = passes[i]->getShaderVariant(_patches); + } +} + +void SubModel::setSubMesh(RenderingSubMesh *subMesh) { + auto &passes = *_passes; + _inputAssembler->destroy(); + _inputAssembler->initialize(subMesh->getIaInfo()); + if (passes[0]->getBatchingScheme() == BatchingSchemes::VB_MERGING) { + subMesh->genFlatBuffers(); + } + _subMesh = subMesh; } } // namespace scene diff --git a/native/cocos/scene/SubModel.h b/native/cocos/scene/SubModel.h index 788133263f..520b9b6341 100644 --- a/native/cocos/scene/SubModel.h +++ b/native/cocos/scene/SubModel.h @@ -27,77 +27,85 @@ #include #include +#include "base/RefCounted.h" +#include "core/assets/RenderingSubMesh.h" #include "renderer/gfx-base/GFXDescriptorSet.h" #include "renderer/gfx-base/GFXInputAssembler.h" #include "renderer/gfx-base/GFXShader.h" +#include "renderer/pipeline/Define.h" #include "scene/Define.h" - namespace cc { namespace scene { - class Pass; -class Model; - -class SubModel final { +class SubModel : public RefCounted { public: SubModel(); - SubModel(const SubModel &) = delete; - SubModel(SubModel &&) = delete; - ~SubModel(); - SubModel &operator=(const SubModel &) = delete; - SubModel &operator=(SubModel &&) = delete; + ~SubModel() override = default; void update(); gfx::Shader *getShader(uint) const; Pass * getPass(uint) const; - inline void setShaders(const std::vector &shaders) { _shaders = shaders; } - inline void setPasses(const std::vector &passes) { _passes = passes; } - inline void setDescriptorSet(gfx::DescriptorSet *descriptorSet) { _descriptSet = descriptorSet; } inline void setWorldBoundDescriptorSet(gfx::DescriptorSet *descriptorSet) { _worldBoundDescriptorSet = descriptorSet; } - inline void setInputAssembler(gfx::InputAssembler *ia) { _ia = ia; } + inline void setDescriptorSet(gfx::DescriptorSet *descriptorSet) { _descriptorSet = descriptorSet; } + inline void setInputAssembler(gfx::InputAssembler *ia) { _inputAssembler = ia; } + inline void setShaders(const std::vector> &shaders) { _shaders = shaders; } + void setPasses(const std::shared_ptr>> &passes); inline void setPlanarInstanceShader(gfx::Shader *shader) { _planarInstanceShader = shader; } inline void setPlanarShader(gfx::Shader *shader) { _planarShader = shader; } - inline void setPriority(RenderPriority priority) { _priority = priority; } + inline void setPriority(pipeline::RenderPriority priority) { _priority = priority; } inline void setOwner(Model *model) { _owner = model; } - inline void setSubMeshBuffers(const std::vector &flatBuffers) { - if (!_subMesh) { - _subMesh = new RenderingSubMesh(); - } - _subMesh->flatBuffers = flatBuffers; - } + void setSubMesh(RenderingSubMesh *subMesh); - inline gfx::DescriptorSet * getDescriptorSet() const { return _descriptSet; } - inline gfx::DescriptorSet * getWorldBoundDescriptorSet() const { return _worldBoundDescriptorSet; } - inline gfx::InputAssembler * getInputAssembler() const { return _ia; } - inline std::vector &getShaders() { return _shaders; } - inline const std::vector & getPasses() const { return _passes; } - inline gfx::Shader * getPlanarInstanceShader() const { return _planarInstanceShader; } - inline gfx::Shader * getPlanarShader() const { return _planarShader; } - inline RenderPriority getPriority() const { return _priority; } - inline RenderingSubMesh * getSubMesh() const { return _subMesh; } - inline Model * getOwner() const { return _owner; } - inline uint32_t getId() const { return _id; } + inline gfx::DescriptorSet * getDescriptorSet() const { return _descriptorSet; } + inline gfx::DescriptorSet * getWorldBoundDescriptorSet() const { return _worldBoundDescriptorSet; } + inline gfx::InputAssembler * getInputAssembler() const { return _inputAssembler; } + inline const std::vector> &getShaders() const { return _shaders; } + inline const std::vector> & getPasses() const { return *_passes; } + inline const std::vector & getPatches() const { return _patches; } + inline gfx::Shader * getPlanarInstanceShader() const { return _planarInstanceShader; } + inline gfx::Shader * getPlanarShader() const { return _planarShader; } + inline pipeline::RenderPriority getPriority() const { return _priority; } + inline RenderingSubMesh * getSubMesh() const { return _subMesh; } + inline Model * getOwner() const { return _owner; } + inline uint32_t getId() const { return _id; } + + void initialize(RenderingSubMesh *subMesh, const std::shared_ptr>> &passes, const std::vector &patches); + void initPlanarShadowShader(); + void initPlanarShadowInstanceShader(); + void destroy(); + void onPipelineStateChanged(); + void onMacroPatchesStateChanged(const std::vector &patches); + +protected: + void flushPassInfo(); + + gfx::Device * _device{nullptr}; + std::vector _patches; + IntrusivePtr _inputAssembler; + IntrusivePtr _descriptorSet; + IntrusivePtr _worldBoundDescriptorSet; + + IntrusivePtr _reflectionTex; + IntrusivePtr _reflectionSampler; + pipeline::RenderPriority _priority{pipeline::RenderPriority::DEFAULT}; + IntrusivePtr _planarShader; + IntrusivePtr _planarInstanceShader; + IntrusivePtr _subMesh; + std::shared_ptr>> _passes; + std::vector> _shaders; + Model * _owner{nullptr}; + int32_t _id{-1}; private: - static inline uint32_t generateId() { - static uint32_t generator = 0; + static inline int32_t generateId() { + static int32_t generator = 0; return generator++; } - RenderPriority _priority{RenderPriority::DEFAULT}; - gfx::Shader * _planarShader{nullptr}; - gfx::Shader * _planarInstanceShader{nullptr}; - gfx::DescriptorSet * _descriptSet{nullptr}; - gfx::DescriptorSet * _worldBoundDescriptorSet{nullptr}; - gfx::InputAssembler * _ia{nullptr}; - RenderingSubMesh * _subMesh{nullptr}; - std::vector _passes; - std::vector _shaders; - Model * _owner{nullptr}; - uint32_t _id = -1; + CC_DISALLOW_COPY_MOVE_ASSIGN(SubModel); }; } // namespace scene diff --git a/native/cocos/ui/videoplayer/VideoPlayer.h b/native/cocos/ui/videoplayer/VideoPlayer.h index 0cf1d0e43d..2294dbab46 100644 --- a/native/cocos/ui/videoplayer/VideoPlayer.h +++ b/native/cocos/ui/videoplayer/VideoPlayer.h @@ -30,7 +30,7 @@ #include #include #include "base/Macros.h" -#include "base/Ref.h" +#include "base/RefCounted.h" #ifndef OBJC_CLASS #ifdef __OBJC__ @@ -50,7 +50,7 @@ namespace cc { * It's mean VideoPlayer displays a video file above all graphical elements of cocos2d-x. * @js NA */ -class VideoPlayer : public Ref { +class VideoPlayer : public RefCounted { public: /** * Videoplayer play event type. @@ -153,7 +153,6 @@ public: protected: ~VideoPlayer() override; -protected: enum class Source { FILENAME = 0, URL diff --git a/native/cocos/ui/webview/WebView-inl.h b/native/cocos/ui/webview/WebView-inl.h index 85fa5e57dc..87312ffa59 100644 --- a/native/cocos/ui/webview/WebView-inl.h +++ b/native/cocos/ui/webview/WebView-inl.h @@ -52,7 +52,6 @@ WebView::~WebView() { WebView *WebView::create() { auto webView = new (std::nothrow) WebView(); if (webView) { - webView->autorelease(); return webView; } CC_SAFE_DELETE(webView); diff --git a/native/cocos/ui/webview/WebView.h b/native/cocos/ui/webview/WebView.h index 434fd74915..1026f5c6e1 100644 --- a/native/cocos/ui/webview/WebView.h +++ b/native/cocos/ui/webview/WebView.h @@ -31,7 +31,7 @@ #include "base/Config.h" #include "base/Data.h" #include "base/Macros.h" -#include "base/Ref.h" +#include "base/RefCounted.h" /** * @addtogroup ui @@ -49,7 +49,7 @@ class WebViewImpl; * It's mean WebView displays web pages above all graphical elements of cocos2d-x. * @js NA */ -class WebView : public Ref { +class WebView : public RefCounted { public: /** * Allocates and initializes a WebView. diff --git a/native/extensions/assets-manager/AssetsManagerEx.cpp b/native/extensions/assets-manager/AssetsManagerEx.cpp index 99a0a5874e..c291dfb088 100644 --- a/native/extensions/assets-manager/AssetsManagerEx.cpp +++ b/native/extensions/assets-manager/AssetsManagerEx.cpp @@ -25,12 +25,13 @@ ****************************************************************************/ #include "AssetsManagerEx.h" -#include -#include +#include +#include -#include "base/UTF8.h" #include "AsyncTaskPool.h" +#include "base/DeferredReleasePool.h" #include "base/Log.h" +#include "base/UTF8.h" #ifdef MINIZIP_FROM_SYSTEM #include @@ -52,7 +53,7 @@ NS_CC_EXT_BEGIN #define SAVE_POINT_INTERVAL 0.1 -const std::string AssetsManagerEx::VERSION_ID = "@version"; +const std::string AssetsManagerEx::VERSION_ID = "@version"; const std::string AssetsManagerEx::MANIFEST_ID = "@manifest"; // Implementation of AssetsManagerEx @@ -61,58 +62,59 @@ AssetsManagerEx::AssetsManagerEx(const std::string &manifestUrl, const std::stri init(manifestUrl, storagePath); } -AssetsManagerEx::AssetsManagerEx(const std::string &manifestUrl, const std::string &storagePath, const VersionCompareHandle &handle) -: _versionCompareHandle(handle) { +AssetsManagerEx::AssetsManagerEx(const std::string &manifestUrl, const std::string &storagePath, VersionCompareHandle handle) +: _versionCompareHandle(std::move(handle)) { init(manifestUrl, storagePath); } void AssetsManagerEx::init(const std::string &manifestUrl, const std::string &storagePath) { // Init variables std::string pointer = StringUtils::format("%p", this); - _eventName = "__cc_assets_manager_" + pointer; - _fileUtils = FileUtils::getInstance(); + _eventName = "__cc_assets_manager_" + pointer; + _fileUtils = FileUtils::getInstance(); network::DownloaderHints hints = { static_cast(_maxConcurrentTask), DEFAULT_CONNECTION_TIMEOUT, ".tmp"}; - _downloader = std::shared_ptr(new network::Downloader(hints)); - _downloader->onTaskError = std::bind(&AssetsManagerEx::onError, this, std::placeholders::_1, std::placeholders::_2, std::placeholders::_3, std::placeholders::_4); + _downloader = std::shared_ptr(new network::Downloader(hints)); + _downloader->onTaskError = [this](auto &&pH1, auto &&pH2, auto &&pH3, auto &&pH4) { onError(std::forward(pH1), std::forward(pH2), std::forward(pH3), std::forward(pH4)); }; _downloader->onTaskProgress = [this](const network::DownloadTask &task, int64_t /*bytesReceived*/, int64_t totalBytesReceived, int64_t totalBytesExpected) { - this->onProgress(totalBytesExpected, totalBytesReceived, task.requestURL, task.identifier); + this->onProgress(static_cast(totalBytesExpected), static_cast(totalBytesReceived), task.requestURL, task.identifier); }; _downloader->onFileTaskSuccess = [this](const network::DownloadTask &task) { this->onSuccess(task.requestURL, task.storagePath, task.identifier); }; setStoragePath(storagePath); - _tempVersionPath = _tempStoragePath + VERSION_FILENAME; + _tempVersionPath = _tempStoragePath + VERSION_FILENAME; _cacheManifestPath = _storagePath + MANIFEST_FILENAME; - _tempManifestPath = _tempStoragePath + TEMP_MANIFEST_FILENAME; + _tempManifestPath = _tempStoragePath + TEMP_MANIFEST_FILENAME; - if (manifestUrl.size() > 0) { + if (!manifestUrl.empty()) { loadLocalManifest(manifestUrl); } } AssetsManagerEx::~AssetsManagerEx() { - _downloader->onTaskError = (nullptr); + _downloader->onTaskError = (nullptr); _downloader->onFileTaskSuccess = (nullptr); - _downloader->onTaskProgress = (nullptr); + _downloader->onTaskProgress = (nullptr); CC_SAFE_RELEASE(_localManifest); // _tempManifest could share a ptr with _remoteManifest or _localManifest - if (_tempManifest != _localManifest && _tempManifest != _remoteManifest) + if (_tempManifest != _localManifest && _tempManifest != _remoteManifest) { CC_SAFE_RELEASE(_tempManifest); + } CC_SAFE_RELEASE(_remoteManifest); } AssetsManagerEx *AssetsManagerEx::create(const std::string &manifestUrl, const std::string &storagePath) { - AssetsManagerEx *ret = new (std::nothrow) AssetsManagerEx(manifestUrl, storagePath); + auto *ret = new (std::nothrow) AssetsManagerEx(manifestUrl, storagePath); if (ret) { - ret->autorelease(); + cc::DeferredReleasePool::add(ret); } else { CC_SAFE_DELETE(ret); } @@ -148,8 +150,8 @@ void AssetsManagerEx::initManifests() { CC_SAFE_RELEASE(_localManifest); CC_SAFE_RELEASE(_tempManifest); CC_SAFE_RELEASE(_remoteManifest); - _localManifest = nullptr; - _tempManifest = nullptr; + _localManifest = nullptr; + _tempManifest = nullptr; _remoteManifest = nullptr; } } @@ -171,18 +173,18 @@ bool AssetsManagerEx::loadLocalManifest(Manifest *localManifest, const std::stri } _inited = true; // Reset storage path - if (storagePath.size() > 0) { + if (!storagePath.empty()) { setStoragePath(storagePath); - _tempVersionPath = _tempStoragePath + VERSION_FILENAME; + _tempVersionPath = _tempStoragePath + VERSION_FILENAME; _cacheManifestPath = _storagePath + MANIFEST_FILENAME; - _tempManifestPath = _tempStoragePath + TEMP_MANIFEST_FILENAME; + _tempManifestPath = _tempStoragePath + TEMP_MANIFEST_FILENAME; } // Release existing local manifest if (_localManifest) { CC_SAFE_RELEASE(_localManifest); } _localManifest = localManifest; - _localManifest->retain(); + _localManifest->addRef(); // Find the cached manifest file Manifest *cachedManifest = nullptr; if (_fileUtils->isFileExist(_cacheManifestPath)) { @@ -216,14 +218,13 @@ bool AssetsManagerEx::loadLocalManifest(Manifest *localManifest, const std::stri if (!_inited) { return false; - } else { - _updateState = State::UNCHECKED; - return true; } + _updateState = State::UNCHECKED; + return true; } bool AssetsManagerEx::loadLocalManifest(const std::string &manifestUrl) { - if (manifestUrl.size() == 0) { + if (manifestUrl.empty()) { return false; } if (_updateState > State::UNINITED) { @@ -253,8 +254,8 @@ bool AssetsManagerEx::loadLocalManifest(const std::string &manifestUrl) { std::vector searchPaths = _fileUtils->getSearchPaths(); if (cachedManifest) { std::vector cacheSearchPaths = cachedManifest->getSearchPaths(); - std::vector trimmedPaths = searchPaths; - for (auto path : cacheSearchPaths) { + std::vector trimmedPaths = searchPaths; + for (const auto &path : cacheSearchPaths) { const auto pos = std::find(trimmedPaths.begin(), trimmedPaths.end(), path); if (pos != trimmedPaths.end()) { trimmedPaths.erase(pos); @@ -308,7 +309,7 @@ bool AssetsManagerEx::loadRemoteManifest(Manifest *remoteManifest) { CC_SAFE_RELEASE(_remoteManifest); } _remoteManifest = remoteManifest; - _remoteManifest->retain(); + _remoteManifest->addRef(); // Compare manifest version and set state if (_localManifest->versionGreaterOrEquals(_remoteManifest, _versionCompareHandle)) { _updateState = State::UP_TO_DATE; @@ -321,22 +322,21 @@ bool AssetsManagerEx::loadRemoteManifest(Manifest *remoteManifest) { return true; } -std::string AssetsManagerEx::basename(const std::string &path) const { +std::string AssetsManagerEx::basename(const std::string &path) { size_t found = path.find_last_of("/\\"); if (std::string::npos != found) { return path.substr(0, found); - } else { - return path; } + return path; } std::string AssetsManagerEx::get(const std::string &key) const { auto it = _assets->find(key); if (it != _assets->cend()) { return _storagePath + it->second.path; - } else - return ""; + } + return ""; } const Manifest *AssetsManagerEx::getLocalManifest() const { @@ -362,31 +362,31 @@ void AssetsManagerEx::setStoragePath(const std::string &storagePath) { } void AssetsManagerEx::adjustPath(std::string &path) { - if (path.size() > 0 && path[path.size() - 1] != '/') { + if (!path.empty() && path[path.size() - 1] != '/') { path.append("/"); } } -bool AssetsManagerEx::decompress(const std::string &zip) { +bool AssetsManagerEx::decompress(const std::string &filename) { // Find root path for zip file - size_t pos = zip.find_last_of("/\\"); + size_t pos = filename.find_last_of("/\\"); if (pos == std::string::npos) { - CC_LOG_DEBUG("AssetsManagerEx : no root path specified for zip file %s\n", zip.c_str()); + CC_LOG_DEBUG("AssetsManagerEx : no root path specified for zip file %s\n", filename.c_str()); return false; } - const std::string rootPath = zip.substr(0, pos + 1); + const std::string rootPath = filename.substr(0, pos + 1); // Open the zip file - unzFile zipfile = unzOpen(FileUtils::getInstance()->getSuitableFOpen(zip).c_str()); + unzFile zipfile = unzOpen(FileUtils::getInstance()->getSuitableFOpen(filename).c_str()); if (!zipfile) { - CC_LOG_DEBUG("AssetsManagerEx : can not open downloaded zip file %s\n", zip.c_str()); + CC_LOG_DEBUG("AssetsManagerEx : can not open downloaded zip file %s\n", filename.c_str()); return false; } // Get info about the zip file - unz_global_info global_info; - if (unzGetGlobalInfo(zipfile, &global_info) != UNZ_OK) { - CC_LOG_DEBUG("AssetsManagerEx : can not read file global info of %s\n", zip.c_str()); + unz_global_info globalInfo; + if (unzGetGlobalInfo(zipfile, &globalInfo) != UNZ_OK) { + CC_LOG_DEBUG("AssetsManagerEx : can not read file global info of %s\n", filename.c_str()); unzClose(zipfile); return false; } @@ -395,17 +395,17 @@ bool AssetsManagerEx::decompress(const std::string &zip) { char readBuffer[BUFFER_SIZE]; // Loop to extract all files. uLong i; - for (i = 0; i < global_info.number_entry; ++i) { + for (i = 0; i < globalInfo.number_entry; ++i) { // Get info about current file. unz_file_info fileInfo; - char fileName[MAX_FILENAME]; + char fileName[MAX_FILENAME]; if (unzGetCurrentFileInfo(zipfile, &fileInfo, fileName, MAX_FILENAME, - NULL, + nullptr, 0, - NULL, + nullptr, 0) != UNZ_OK) { CC_LOG_DEBUG("AssetsManagerEx : can not read compressed file info\n"); unzClose(zipfile); @@ -475,7 +475,7 @@ bool AssetsManagerEx::decompress(const std::string &zip) { unzCloseCurrentFile(zipfile); // Goto next entry listed in the zip file. - if ((i + 1) < global_info.number_entry) { + if ((i + 1) < globalInfo.number_entry) { if (unzGoToNextFile(zipfile) != UNZ_OK) { CC_LOG_DEBUG("AssetsManagerEx : can not read next file for decompressing\n"); unzClose(zipfile); @@ -492,28 +492,28 @@ void AssetsManagerEx::decompressDownloadedZip(const std::string &customId, const struct AsyncData { std::string customId; std::string zipFile; - bool succeed; + bool succeed; }; - AsyncData *asyncData = new AsyncData; + auto *asyncData = new AsyncData; asyncData->customId = customId; - asyncData->zipFile = storagePath; - asyncData->succeed = false; + asyncData->zipFile = storagePath; + asyncData->succeed = false; std::function decompressFinished = [this](void *param) { - auto dataInner = reinterpret_cast(param); + auto *dataInner = reinterpret_cast(param); if (dataInner->succeed) { fileSuccess(dataInner->customId, dataInner->zipFile); } else { std::string errorMsg = "Unable to decompress file " + dataInner->zipFile; - // Ensure zip file deletion (if decompress failure cause task thread exit anormally) + // Ensure zip file deletion (if decompress failure cause task thread exit abnormally) _fileUtils->removeFile(dataInner->zipFile); dispatchUpdateEvent(EventAssetsManagerEx::EventCode::ERROR_DECOMPRESS, "", errorMsg); fileError(dataInner->customId, errorMsg); } delete dataInner; }; - AsyncTaskPool::getInstance()->enqueue(AsyncTaskPool::TaskType::TASK_OTHER, decompressFinished, (void *)asyncData, [this, asyncData]() { + AsyncTaskPool::getInstance()->enqueue(AsyncTaskPool::TaskType::TASK_OTHER, decompressFinished, static_cast(asyncData), [this, asyncData]() { // Decompress all compressed files if (decompress(asyncData->zipFile)) { asyncData->succeed = true; @@ -522,7 +522,7 @@ void AssetsManagerEx::decompressDownloadedZip(const std::string &customId, const }); } -void AssetsManagerEx::dispatchUpdateEvent(EventAssetsManagerEx::EventCode code, const std::string &assetId /* = ""*/, const std::string &message /* = ""*/, int curle_code /* = CURLE_OK*/, int curlm_code /* = CURLM_OK*/) { +void AssetsManagerEx::dispatchUpdateEvent(EventAssetsManagerEx::EventCode code, const std::string &assetId /* = ""*/, const std::string &message /* = ""*/, int curleCode /* = CURLE_OK*/, int curlmCode /* = CURLM_OK*/) { switch (code) { case EventAssetsManagerEx::EventCode::ERROR_UPDATING: case EventAssetsManagerEx::EventCode::ERROR_PARSE_MANIFEST: @@ -548,7 +548,7 @@ void AssetsManagerEx::dispatchUpdateEvent(EventAssetsManagerEx::EventCode code, } if (_eventCallback != nullptr) { - EventAssetsManagerEx *event = new (std::nothrow) EventAssetsManagerEx(_eventName, this, code, assetId, message, curle_code, curlm_code); + auto *event = new (std::nothrow) EventAssetsManagerEx(_eventName, this, code, assetId, message, curleCode, curlmCode); _eventCallback(event); event->release(); } @@ -559,12 +559,13 @@ AssetsManagerEx::State AssetsManagerEx::getState() const { } void AssetsManagerEx::downloadVersion() { - if (_updateState > State::PREDOWNLOAD_VERSION) + if (_updateState > State::PREDOWNLOAD_VERSION) { return; + } std::string versionUrl = _localManifest->getVersionFileUrl(); - if (versionUrl.size() > 0) { + if (!versionUrl.empty()) { _updateState = State::DOWNLOADING_VERSION; // Download version file asynchronously _downloader->createDownloadFileTask(versionUrl, _tempVersionPath, VERSION_ID); @@ -578,8 +579,9 @@ void AssetsManagerEx::downloadVersion() { } void AssetsManagerEx::parseVersion() { - if (_updateState != State::VERSION_LOADED) + if (_updateState != State::VERSION_LOADED) { return; + } _remoteManifest->parseVersion(_tempVersionPath); @@ -600,12 +602,13 @@ void AssetsManagerEx::parseVersion() { } void AssetsManagerEx::downloadManifest() { - if (_updateState != State::PREDOWNLOAD_MANIFEST) + if (_updateState != State::PREDOWNLOAD_MANIFEST) { return; + } std::string manifestUrl = _localManifest->getManifestFileUrl(); - if (manifestUrl.size() > 0) { + if (!manifestUrl.empty()) { _updateState = State::DOWNLOADING_MANIFEST; // Download version file asynchronously _downloader->createDownloadFileTask(manifestUrl, _tempManifestPath, MANIFEST_ID); @@ -619,8 +622,9 @@ void AssetsManagerEx::downloadManifest() { } void AssetsManagerEx::parseManifest() { - if (_updateState != State::MANIFEST_LOADED) + if (_updateState != State::MANIFEST_LOADED) { return; + } _remoteManifest->parseFile(_tempManifestPath); @@ -648,16 +652,19 @@ void AssetsManagerEx::parseManifest() { } void AssetsManagerEx::prepareUpdate() { - if (_updateState != State::NEED_UPDATE) + if (_updateState != State::NEED_UPDATE) { return; + } // Clean up before update _failedUnits.clear(); _downloadUnits.clear(); _totalWaitToDownload = _totalToDownload = 0; - _nextSavePoint = 0; - _percent = _percentByFile = _sizeCollected = _totalDownloaded = _totalSize = 0; - _downloadResumed = false; + _nextSavePoint = 0; + _percent = _percentByFile = 0.F; + _sizeCollected = 0; + _totalDownloaded = _totalSize = 0.0; + _downloadResumed = false; _downloadedSize.clear(); _totalEnabled = false; @@ -665,11 +672,11 @@ void AssetsManagerEx::prepareUpdate() { if (_tempManifest && _tempManifest->isLoaded() && _tempManifest->isUpdating() && _tempManifest->versionEquals(_remoteManifest)) { _tempManifest->saveToFile(_tempManifestPath); _tempManifest->genResumeAssetsList(&_downloadUnits); - _totalWaitToDownload = _totalToDownload = (int)_downloadUnits.size(); - _downloadResumed = true; + _totalWaitToDownload = _totalToDownload = static_cast(_downloadUnits.size()); + _downloadResumed = true; // Collect total size - for (auto iter : _downloadUnits) { + for (const auto &iter : _downloadUnits) { const DownloadUnit &unit = iter.second; if (unit.size > 0) { _totalSize += unit.size; @@ -691,35 +698,33 @@ void AssetsManagerEx::prepareUpdate() { _tempManifest = _remoteManifest; // Check difference between local manifest and remote manifest - std::unordered_map diff_map = _localManifest->genDiff(_remoteManifest); - if (diff_map.size() == 0) { + std::unordered_map diffMap = _localManifest->genDiff(_remoteManifest); + if (diffMap.empty()) { updateSucceed(); return; - } else { - // Generate download units for all assets that need to be updated or added - std::string packageUrl = _remoteManifest->getPackageUrl(); - // Preprocessing local files in previous version and creating download folders - for (auto it = diff_map.begin(); it != diff_map.end(); ++it) { - Manifest::AssetDiff diff = it->second; - if (diff.type != Manifest::DiffType::DELETED) { - std::string path = diff.asset.path; - DownloadUnit unit; - unit.customId = it->first; - unit.srcUrl = packageUrl + path + "?md5=" + diff.asset.md5; - unit.storagePath = _tempStoragePath + path; - unit.size = diff.asset.size; - _downloadUnits.emplace(unit.customId, unit); - _tempManifest->setAssetDownloadState(it->first, Manifest::DownloadState::UNSTARTED); - _totalSize += unit.size; - } + } // Generate download units for all assets that need to be updated or added + std::string packageUrl = _remoteManifest->getPackageUrl(); + // Preprocessing local files in previous version and creating download folders + for (auto &it : diffMap) { + Manifest::AssetDiff diff = it.second; + if (diff.type != Manifest::DiffType::DELETED) { + std::string path = diff.asset.path; + DownloadUnit unit; + unit.customId = it.first; + unit.srcUrl = packageUrl + path + "?md5=" + diff.asset.md5; + unit.storagePath = _tempStoragePath + path; + unit.size = diff.asset.size; + _downloadUnits.emplace(unit.customId, unit); + _tempManifest->setAssetDownloadState(it.first, Manifest::DownloadState::UNSTARTED); + _totalSize += unit.size; } - // Start updating the temp manifest - _tempManifest->setUpdating(true); - // Save current download manifest information for resuming - _tempManifest->saveToFile(_tempManifestPath); - - _totalWaitToDownload = _totalToDownload = (int)_downloadUnits.size(); } + // Start updating the temp manifest + _tempManifest->setUpdating(true); + // Save current download manifest information for resuming + _tempManifest->saveToFile(_tempManifestPath); + + _totalWaitToDownload = _totalToDownload = static_cast(_downloadUnits.size()); } _updateState = State::READY_TO_UPDATE; } @@ -729,7 +734,7 @@ void AssetsManagerEx::startUpdate() { prepareUpdate(); } if (_updateState == State::READY_TO_UPDATE) { - _totalSize = 0; + _totalSize = 0; _updateState = State::UPDATING; std::string msg; if (_downloadResumed) { @@ -755,17 +760,18 @@ void AssetsManagerEx::updateSucceed() { } // 2. Get the delete files - std::unordered_map diff_map = _localManifest->genDiff(_remoteManifest); + std::unordered_map diffMap = _localManifest->genDiff(_remoteManifest); // 3. merge temporary storage path to storage path so that temporary version turns to cached version if (_fileUtils->isDirectoryExist(_tempStoragePath)) { // Merging all files in temp storage path to storage path std::vector files; _fileUtils->listFilesRecursively(_tempStoragePath, &files); - int baseOffset = (int)_tempStoragePath.length(); - std::string relativePath, dstPath; - for (std::vector::iterator it = files.begin(); it != files.end(); ++it) { - relativePath.assign((*it).substr(baseOffset)); + int baseOffset = static_cast(_tempStoragePath.length()); + std::string relativePath; + std::string dstPath; + for (auto &file : files) { + relativePath.assign(file.substr(baseOffset)); dstPath.assign(_storagePath + relativePath); // Create directory if (relativePath.back() == '/') { @@ -776,21 +782,21 @@ void AssetsManagerEx::updateSucceed() { if (_fileUtils->isFileExist(dstPath)) { _fileUtils->removeFile(dstPath); } - _fileUtils->renameFile(*it, dstPath); + _fileUtils->renameFile(file, dstPath); } // Remove from delete list for safe, although this is not the case in general. - auto diff_itr = diff_map.find(relativePath); - if (diff_itr != diff_map.end()) { - diff_map.erase(diff_itr); + auto diffIter = diffMap.find(relativePath); + if (diffIter != diffMap.end()) { + diffMap.erase(diffIter); } } // Preprocessing local files in previous version and creating download folders - for (auto it = diff_map.begin(); it != diff_map.end(); ++it) { - Manifest::AssetDiff diff = it->second; + for (auto &it : diffMap) { + Manifest::AssetDiff diff = it.second; if (diff.type == Manifest::DiffType::DELETED) { - // TODO: Do this when download finish, it don’t matter delete or not. + // TODO(kenshin): Do this when download finish, it don’t matter delete or not. std::string exsitedPath = _storagePath + diff.asset.path; _fileUtils->removeFile(exsitedPath); } @@ -919,10 +925,12 @@ void AssetsManagerEx::updateAssets(const DownloadUnits &assets) { _updateState = State::UPDATING; _downloadUnits.clear(); _downloadedSize.clear(); - _percent = _percentByFile = _sizeCollected = _totalDownloaded = _totalSize = 0; - _totalWaitToDownload = _totalToDownload = (int)assets.size(); - _nextSavePoint = 0; - _totalEnabled = false; + _percent = _percentByFile = 0.F; + _sizeCollected = 0; + _totalDownloaded = _totalSize = 0.0; + _totalWaitToDownload = _totalToDownload = static_cast(assets.size()); + _nextSavePoint = 0; + _totalEnabled = false; if (_totalToDownload > 0) { _downloadUnits = assets; this->batchDownload(); @@ -957,7 +965,7 @@ void AssetsManagerEx::fileError(const std::string &identifier, const std::string queueDowload(); } -void AssetsManagerEx::fileSuccess(const std::string &customId, const std::string &storagePath) { +void AssetsManagerEx::fileSuccess(const std::string &customId, const std::string & /*storagePath*/) { // Set download state to SUCCESSED _tempManifest->setAssetDownloadState(customId, Manifest::DownloadState::SUCCESSED); @@ -973,7 +981,7 @@ void AssetsManagerEx::fileSuccess(const std::string &customId, const std::string // Reduce count only when unit found in _downloadUnits _totalWaitToDownload--; - _percentByFile = 100 * (float)(_totalToDownload - _totalWaitToDownload) / _totalToDownload; + _percentByFile = 100 * static_cast(_totalToDownload - _totalWaitToDownload) / static_cast(_totalToDownload); // Notify progression event dispatchUpdateEvent(EventAssetsManagerEx::EventCode::UPDATE_PROGRESSION, ""); } @@ -985,9 +993,9 @@ void AssetsManagerEx::fileSuccess(const std::string &customId, const std::string } void AssetsManagerEx::onError(const network::DownloadTask &task, - int errorCode, - int errorCodeInternal, - const std::string &errorStr) { + int errorCode, + int errorCodeInternal, + const std::string & errorStr) { // Skip version error occurred if (task.identifier == VERSION_ID) { CC_LOG_DEBUG("AssetsManagerEx : Fail to download version file, step skipped\n"); @@ -1003,46 +1011,44 @@ void AssetsManagerEx::onError(const network::DownloadTask &task, void AssetsManagerEx::onProgress(double total, double downloaded, const std::string & /*url*/, const std::string &customId) { if (customId == VERSION_ID || customId == MANIFEST_ID) { - _percent = 100 * downloaded / total; + _percent = static_cast(100 * downloaded / total); // Notify progression event dispatchUpdateEvent(EventAssetsManagerEx::EventCode::UPDATE_PROGRESSION, customId); return; - } else { - // Calcul total downloaded - bool found = false; - _totalDownloaded = 0; - for (auto it = _downloadedSize.begin(); it != _downloadedSize.end(); ++it) { - if (it->first == customId) { - it->second = downloaded; - found = true; - } - _totalDownloaded += it->second; + } // Calculate total downloaded + bool found = false; + _totalDownloaded = 0; + for (auto &it : _downloadedSize) { + if (it.first == customId) { + it.second = downloaded; + found = true; } - // Collect information if not registed - if (!found) { - // Set download state to DOWNLOADING, this will run only once in the download process - _tempManifest->setAssetDownloadState(customId, Manifest::DownloadState::DOWNLOADING); - // Register the download size information - _downloadedSize.emplace(customId, downloaded); - // Check download unit size existance, if not exist collect size in total size - if (_downloadUnits[customId].size == 0) { - _totalSize += total; - _sizeCollected++; - // All collected, enable total size - if (_sizeCollected == _totalToDownload) { - _totalEnabled = true; - } + _totalDownloaded += it.second; + } + // Collect information if not registed + if (!found) { + // Set download state to DOWNLOADING, this will run only once in the download process + _tempManifest->setAssetDownloadState(customId, Manifest::DownloadState::DOWNLOADING); + // Register the download size information + _downloadedSize.emplace(customId, downloaded); + // Check download unit size existance, if not exist collect size in total size + if (_downloadUnits[customId].size == 0) { + _totalSize += total; + _sizeCollected++; + // All collected, enable total size + if (_sizeCollected == _totalToDownload) { + _totalEnabled = true; } } + } - if (_totalEnabled && _updateState == State::UPDATING) { - float currentPercent = 100 * _totalDownloaded / _totalSize; - // Notify at integer level change - if ((int)currentPercent != (int)_percent) { - _percent = currentPercent; - // Notify progression event - dispatchUpdateEvent(EventAssetsManagerEx::EventCode::UPDATE_PROGRESSION, customId); - } + if (_totalEnabled && _updateState == State::UPDATING) { + auto currentPercent = static_cast(100 * _totalDownloaded / _totalSize); + // Notify at integer level change + if (static_cast(currentPercent) != static_cast(_percent)) { + _percent = currentPercent; + // Notify progression event + dispatchUpdateEvent(EventAssetsManagerEx::EventCode::UPDATE_PROGRESSION, customId); } } } @@ -1055,9 +1061,9 @@ void AssetsManagerEx::onSuccess(const std::string & /*srcUrl*/, const std::strin _updateState = State::MANIFEST_LOADED; parseManifest(); } else { - bool ok = true; - auto &assets = _remoteManifest->getAssets(); - auto assetIt = assets.find(customId); + bool ok = true; + const auto &assets = _remoteManifest->getAssets(); + auto assetIt = assets.find(customId); if (assetIt != assets.end()) { Manifest::Asset asset = assetIt->second; if (_verifyCallback != nullptr) { @@ -1085,7 +1091,7 @@ void AssetsManagerEx::destroyDownloadedVersion() { void AssetsManagerEx::batchDownload() { _queue.clear(); - for (auto iter : _downloadUnits) { + for (const auto &iter : _downloadUnits) { const DownloadUnit &unit = iter.second; if (unit.size > 0) { _totalSize += unit.size; @@ -1108,7 +1114,7 @@ void AssetsManagerEx::queueDowload() { return; } - while (_currConcurrentTask < _maxConcurrentTask && _queue.size() > 0) { + while (_currConcurrentTask < _maxConcurrentTask && !_queue.empty()) { std::string key = _queue.back(); _queue.pop_back(); @@ -1131,7 +1137,7 @@ void AssetsManagerEx::onDownloadUnitsFinished() { _tempManifest->saveToFile(_tempManifestPath); // Finished with error check - if (_failedUnits.size() > 0) { + if (!_failedUnits.empty()) { _updateState = State::FAIL_TO_UPDATE; dispatchUpdateEvent(EventAssetsManagerEx::EventCode::UPDATE_FAILED); } else if (_updateState == State::UPDATING) { diff --git a/native/extensions/assets-manager/AssetsManagerEx.h b/native/extensions/assets-manager/AssetsManagerEx.h index 3069ff2010..d75a18a7f8 100644 --- a/native/extensions/assets-manager/AssetsManagerEx.h +++ b/native/extensions/assets-manager/AssetsManagerEx.h @@ -1,9 +1,9 @@ /**************************************************************************** Copyright (c) 2013 cocos2d-x.org Copyright (c) 2014-2016 Chukong Technologies Inc. - Copyright (c) 2017-2018 Xiamen Yaji Software Co., Ltd. + Copyright (c) 2017-2021 Xiamen Yaji Software Co., Ltd. - http://www.cocos2d-x.org + http://www.cocos.com Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal @@ -31,14 +31,14 @@ #include #include -#include "platform/FileUtils.h" #include "network/Downloader.h" +#include "platform/FileUtils.h" #include "EventAssetsManagerEx.h" #include "Manifest.h" -#include "extensions/ExtensionMacros.h" #include "extensions/ExtensionExport.h" +#include "extensions/ExtensionMacros.h" #include "json/document-wrapper.h" NS_CC_EXT_BEGIN @@ -46,7 +46,7 @@ NS_CC_EXT_BEGIN /** * @brief This class is used to auto update resources, such as pictures or scripts. */ -class CC_EX_DLL AssetsManagerEx : public Ref { +class CC_EX_DLL AssetsManagerEx : public RefCounted { public: //! Update states enum class State { @@ -69,9 +69,9 @@ public: const static std::string VERSION_ID; const static std::string MANIFEST_ID; - typedef std::function VersionCompareHandle; - typedef std::function VerifyCallback; - typedef std::function EventCallback; + using VersionCompareHandle = std::function; + using VerifyCallback = std::function; + using EventCallback = std::function; /** @brief Create function for creating a new AssetsManagerEx @param manifestUrl The url for the local manifest file @@ -82,8 +82,8 @@ public: static AssetsManagerEx *create(const std::string &manifestUrl, const std::string &storagePath); AssetsManagerEx(const std::string &manifestUrl, const std::string &storagePath); - AssetsManagerEx(const std::string &manifestUrl, const std::string &storagePath, const VersionCompareHandle &handle); - virtual ~AssetsManagerEx(); + AssetsManagerEx(const std::string &manifestUrl, const std::string &storagePath, VersionCompareHandle handle); + ~AssetsManagerEx() override; /** @brief Check out if there is a new version of manifest. * You may use this method before updating, then let user determine whether @@ -182,7 +182,7 @@ public: /** @brief Function for retrieving the max concurrent task count */ - const int getMaxConcurrentTask() const { + int getMaxConcurrentTask() const { return _maxConcurrentTask; }; @@ -216,7 +216,7 @@ public: protected: void init(const std::string &manifestUrl, const std::string &storagePath); - std::string basename(const std::string &path) const; + static std::string basename(const std::string &path); std::string get(const std::string &key) const; @@ -226,9 +226,9 @@ protected: void setStoragePath(const std::string &storagePath); - void adjustPath(std::string &path); + static void adjustPath(std::string &path); - void dispatchUpdateEvent(EventAssetsManagerEx::EventCode code, const std::string &message = "", const std::string &assetId = "", int curle_code = 0, int curlm_code = 0); + void dispatchUpdateEvent(EventAssetsManagerEx::EventCode code, const std::string &assetId = "", const std::string &message = "", int curleCode = 0, int curlmCode = 0); void downloadVersion(); void parseVersion(); @@ -267,9 +267,9 @@ protected: * @lua NA */ virtual void onError(const network::DownloadTask &task, - int errorCode, - int errorCodeInternal, - const std::string &errorStr); + int errorCode, + int errorCodeInternal, + const std::string & errorStr); /** @brief Call back function for recording downloading percent of the current asset, the progression will then be reported to user's listener registed in addUpdateProgressEventListener @@ -370,10 +370,10 @@ private: int _currConcurrentTask = 0; //! Download percent - float _percent = 0.f; + float _percent = 0.F; //! Download percent by file - float _percentByFile = 0.f; + float _percentByFile = 0.F; //! Indicate whether the total size should be enabled bool _totalEnabled = false; @@ -382,10 +382,10 @@ private: int _sizeCollected = 0; //! Total file size need to be downloaded (sum of all files) - double _totalSize = 0.f; + double _totalSize = 0.F; //! Total downloaded file size (sum of all downloaded files) - double _totalDownloaded = 0.f; + double _totalDownloaded = 0.F; //! Downloaded size for each file std::unordered_map _downloadedSize; @@ -395,7 +395,7 @@ private: //! Total number of assets still waiting to be downloaded int _totalWaitToDownload = 0; //! Next target percent for saving the manifest file - float _nextSavePoint = 0.f; + float _nextSavePoint = 0.F; //! Handle function to compare versions between different manifests VersionCompareHandle _versionCompareHandle = nullptr; diff --git a/native/extensions/assets-manager/EventAssetsManagerEx.cpp b/native/extensions/assets-manager/EventAssetsManagerEx.cpp index 11e84b3027..cc89c047d0 100644 --- a/native/extensions/assets-manager/EventAssetsManagerEx.cpp +++ b/native/extensions/assets-manager/EventAssetsManagerEx.cpp @@ -24,19 +24,20 @@ ****************************************************************************/ #include "EventAssetsManagerEx.h" -#include "base/Macros.h" #include +#include #include "AssetsManagerEx.h" +#include "base/Macros.h" NS_CC_EXT_BEGIN -EventAssetsManagerEx::EventAssetsManagerEx(const std::string &eventName, cc::extension::AssetsManagerEx *manager, const EventCode &code, const std::string &assetId /* = "" */, const std::string &message /* = "" */, int curle_code /* = CURLE_OK*/, int curlm_code /* = CURLM_OK*/) +EventAssetsManagerEx::EventAssetsManagerEx(const std::string & /*eventName*/, cc::extension::AssetsManagerEx *manager, const EventCode &code, std::string assetId /* = "" */, std::string message /* = "" */, int curleCode /* = CURLE_OK*/, int curlmCode /* = CURLM_OK*/) : _code(code), _manager(manager), - _message(message), - _assetId(assetId), - _curle_code(curle_code), - _curlm_code(curlm_code) { + _message(std::move(message)), + _assetId(std::move(assetId)), + _curle_code(curleCode), + _curlm_code(curlmCode) { } bool EventAssetsManagerEx::isResuming() const { @@ -44,11 +45,11 @@ bool EventAssetsManagerEx::isResuming() const { } float EventAssetsManagerEx::getPercent() const { - return _manager->getDownloadedBytes() / _manager->getTotalBytes(); + return static_cast(_manager->getDownloadedBytes() / _manager->getTotalBytes()); } float EventAssetsManagerEx::getPercentByFile() const { - return (float)(_manager->getDownloadedFiles()) / _manager->getTotalFiles(); + return static_cast(_manager->getDownloadedFiles()) / static_cast(_manager->getTotalFiles()); } double EventAssetsManagerEx::getDownloadedBytes() const { diff --git a/native/extensions/assets-manager/EventAssetsManagerEx.h b/native/extensions/assets-manager/EventAssetsManagerEx.h index 88332d7d30..29903742e5 100644 --- a/native/extensions/assets-manager/EventAssetsManagerEx.h +++ b/native/extensions/assets-manager/EventAssetsManagerEx.h @@ -27,15 +27,15 @@ #define __cocos2d_libs__CCEventAssetsManagerEx__ #include -#include "base/Ref.h" -#include "extensions/ExtensionMacros.h" +#include "base/RefCounted.h" #include "extensions/ExtensionExport.h" +#include "extensions/ExtensionMacros.h" NS_CC_EXT_BEGIN class AssetsManagerEx; -class CC_EX_DLL EventAssetsManagerEx : public cc::Ref { +class CC_EX_DLL EventAssetsManagerEx : public cc::RefCounted { public: //! Update events code enum class EventCode { @@ -90,13 +90,11 @@ public: int getTotalFiles() const; -public: /** Constructor */ - EventAssetsManagerEx(const std::string &eventName, cc::extension::AssetsManagerEx *manager, const EventCode &code, const std::string &assetId = "", const std::string &message = "", int curle_code = 0, int curlm_code = 0); + EventAssetsManagerEx(const std::string &eventName, cc::extension::AssetsManagerEx *manager, const EventCode &code, std::string assetId = "", std::string message = "", int curleCode = 0, int curlmCode = 0); private: - virtual ~EventAssetsManagerEx() { - } + ~EventAssetsManagerEx() override = default; EventCode _code; diff --git a/native/extensions/assets-manager/Manifest.h b/native/extensions/assets-manager/Manifest.h index 6b2851f672..ac231cfc62 100644 --- a/native/extensions/assets-manager/Manifest.h +++ b/native/extensions/assets-manager/Manifest.h @@ -30,9 +30,9 @@ #include #include -#include "base/Ref.h" -#include "extensions/ExtensionMacros.h" +#include "base/RefCounted.h" #include "extensions/ExtensionExport.h" +#include "extensions/ExtensionMacros.h" #include "network/Downloader.h" #include "platform/FileUtils.h" @@ -44,20 +44,20 @@ struct DownloadUnit { std::string srcUrl; std::string storagePath; std::string customId; - float size; + float size; }; struct ManifestAsset { std::string md5; std::string path; - bool compressed; - float size; - int downloadState; + bool compressed; + float size; + int downloadState; }; -using DownloadUnits = std::unordered_map; +using DownloadUnits = std::unordered_map; -class CC_EX_DLL Manifest : public Ref { +class CC_EX_DLL Manifest : public RefCounted { public: friend class AssetsManagerEx; @@ -80,7 +80,7 @@ public: //! Object indicate the difference between two Assets struct AssetDiff { - Asset asset; + Asset asset; DiffType type; }; diff --git a/native/external/config.json b/native/external/config.json index b8d268b825..14bc2b06fa 100644 --- a/native/external/config.json +++ b/native/external/config.json @@ -1,9 +1,9 @@ { - "version": "v3d-gfx-85", + "version": "v3d-gfx-86", "from": { "type": "github", "owner": "cocos-creator", "name": "engine-native-external", - "checkout": "v3d-gfx-85" + "checkout": "v3d-gfx-86" } } diff --git a/native/templates/common/Classes/Game.cpp b/native/templates/common/Classes/Game.cpp index d46722b7b9..3613991c01 100644 --- a/native/templates/common/Classes/Game.cpp +++ b/native/templates/common/Classes/Game.cpp @@ -30,6 +30,7 @@ #include "cocos/bindings/manual/jsb_classtype.h" #include "cocos/bindings/manual/jsb_global.h" #include "cocos/bindings/manual/jsb_module_register.h" +#include "cocos/renderer/pipeline/GlobalDescriptorSetManager.h" Game::Game() : cc::CocosApplication() {} @@ -46,6 +47,11 @@ int Game::init() { } setXXTeaKey(""); + //TODO: Is here the correct place to invoke setDescriptorSetLayout? + cc::pipeline::GlobalDSManager::setDescriptorSetLayout(); + // + + se::ScriptEngine *se = se::ScriptEngine::getInstance(); runJsScript("jsb-adapter/jsb-builtin.js"); runJsScript("main.js"); diff --git a/native/tests/unit-test/src/ core_scenegraph_nodeeventprocessor.cpp b/native/tests/unit-test/src/ core_scenegraph_nodeeventprocessor.cpp new file mode 100644 index 0000000000..bee5e1e976 --- /dev/null +++ b/native/tests/unit-test/src/ core_scenegraph_nodeeventprocessor.cpp @@ -0,0 +1,363 @@ +/**************************************************************************** +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 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. +****************************************************************************/ +/* +#include "core/Director.h" +#include "core/Root.h" +#include "core/platform/event-manager/Events.h" +#include "core/scene-graph/SceneGraphModuleHeader.h" +#include "gtest/gtest.h" +#include "renderer/GFXDeviceManager.h" +#include "renderer/gfx-base/GFXDef.h" +#include "utils.h" + +using namespace cc; +using namespace cc::event; +using namespace cc::gfx; + +namespace { + +template +struct FunctionTraits +: public FunctionTraits {}; + +template +struct FunctionTraits { + typedef std::function type; +}; + +template +struct FunctionTraits { + typedef std::function type; +}; + +template +typename FunctionTraits::type toFunction(T l) { + return static_cast::type>(l); +} + +} // namespace + +template +class TestFunctor final { +public: + using Fn = std::function; + + TestFunctor(Fn &&cb) + : _cb(std::forward(cb)) { + } + + template + TestFunctor(const Lambda &cb) { + _cb = toFunction(cb); + } + + void operator()(Args &&...args) { + _cb(std::forward(args)...); + *_calledCount = *_calledCount + 1; + } + + uint32_t getCalledCount() const { + return *_calledCount; + } + + void clear() { + *_calledCount = 0; + } + +private: + Fn _cb; + std::shared_ptr _calledCount{std::make_shared(0)}; +}; + +TEST(CoreNodeEventProcessor, remove_and_add_again_during_invoking) { + auto * node = new Node(); + static bool callbackInvoked = false; + callbackInvoked = false; + class MyTarget : public CCObject { + public: + MyTarget(Node *node) : _node{node} {} + void onEvent(cc::event::Event *event) { + _node->off("eve", &MyTarget::onEvent, this); + EXPECT_FALSE(_node->hasEventListener("eve", &MyTarget::onEvent, this)); + _node->on("eve", &MyTarget::onEvent, this); + callbackInvoked = true; + } + + private: + Node *_node; + }; + + MyTarget target{node}; + + node->on("eve", &MyTarget::onEvent, &target); + EXPECT_TRUE(node->hasEventListener("eve", &MyTarget::onEvent, &target)); + + EventCustom event{"eve"}; + node->dispatchEvent(&event); + + EXPECT_TRUE(callbackInvoked); + EXPECT_TRUE(node->hasEventListener("eve", &MyTarget::onEvent, &target)); + + delete node; +} + +TEST(CoreNodeEventProcessor, remove_twice_and_add_again_during_invoking) { + auto * node = new Node(); + static bool callbackInvoked = false; + callbackInvoked = false; + class MyTarget : public CCObject { + public: + MyTarget(Node *node) : _node{node} {} + void onEvent(cc::event::Event *event) { + _node->off("eve", &MyTarget::onEvent, this); + EXPECT_FALSE(_node->hasEventListener("eve", &MyTarget::onEvent, this)); + _node->off("eve", &MyTarget::onEvent, this); + EXPECT_FALSE(_node->hasEventListener("eve", &MyTarget::onEvent, this)); + _node->on("eve", &MyTarget::onEvent, this); + EXPECT_TRUE(_node->hasEventListener("eve", &MyTarget::onEvent, this)); + callbackInvoked = true; + } + + private: + Node *_node; + }; + + MyTarget target{node}; + + node->on("eve", &MyTarget::onEvent, &target); + EXPECT_TRUE(node->hasEventListener("eve", &MyTarget::onEvent, &target)); + + EventCustom event{"eve"}; + node->dispatchEvent(&event); + + EXPECT_TRUE(callbackInvoked); + EXPECT_TRUE(node->hasEventListener("eve", &MyTarget::onEvent, &target)); + + delete node; +} + +TEST(CoreNodeEventProcessor, remove_and_check_has_during_invoking) { + auto *node = new Node(); + class MyTarget : public CCObject { + public: + MyTarget(Node *node) : _node{node} {} + void onEvent(cc::event::Event *event) { + _node->off("eve", &MyTarget::onEvent, this); + EXPECT_FALSE(_node->hasEventListener("eve", &MyTarget::onEvent, this)); + } + + private: + Node *_node; + }; + + MyTarget target{node}; + + node->on("eve", &MyTarget::onEvent, &target); + EXPECT_TRUE(node->hasEventListener("eve", &MyTarget::onEvent, &target)); + EventCustom event{"eve"}; + node->dispatchEvent(&event); + EXPECT_FALSE(node->hasEventListener("eve", &MyTarget::onEvent, &target)); + + delete node; +} + +TEST(CoreNodeEventProcessor, remove_self_during_invoking_node) { + static CallbackInfoBase::ID id1{0}; + static CallbackInfoBase::ID id2{0}; + + auto * node = new Node(); + TestFunctor<> cb1{[&node]() { + node->off("LambdaType", id1); + CC_LOG_DEBUG("Test remove_self_during_invoking_node"); + }}; + TestFunctor<> cb2{[]() {}}; + node->on("LambdaType", cb1, id1); + node->on("LambdaType", cb2, id2); + node->emit("LambdaType"); + EXPECT_EQ(cb2.getCalledCount(), 1); + EXPECT_EQ(cb1.getCalledCount(), 1); + node->emit("LambdaType"); + EXPECT_EQ(cb1.getCalledCount(), 1); + EXPECT_EQ(cb2.getCalledCount(), 2); + + delete node; +} + +//////// test LambdaType +TEST(CoreNodeEventProcessor, test_lambda) { + static CallbackInfoBase::ID id1{0}; + static CallbackInfoBase::ID id2{0}; + + auto *node = new Node(); + // test on + node->on( + "hello", [](int a) { + CC_LOG_DEBUG("hello callback, a: %d", a); + }, + id1); + EXPECT_TRUE(node->hasEventListener("hello", id1)); + + // test emit + node->emit("hello", 1); + node->emit("hello", 2); + // test off + node->off("hello", id1); + EXPECT_FALSE(node->hasEventListener("hello", id1)); + + // test once + node->once( + "helloOnce", [](int b) { + CC_LOG_DEBUG("hello callback only once, b: %d", b); + }, + id2); + + EXPECT_TRUE(node->hasEventListener("helloOnce", id2)); + node->emit("helloOnce", 1); + EXPECT_FALSE(node->hasEventListener("helloOnce", id2)); + + delete node; +} + +//////// test memberFunction +TEST(CoreNodeEventProcessor, test_memberFunction) { + auto *node = new Node(); + + static int ccc; + class MyTarget : public CCObject { + public: + MyTarget(Node *node) : _node{node} {} + + void foo(int a, float b, int *c) { + EXPECT_EQ(a, 1); + EXPECT_TRUE(IsEqualF(b, 2.3F)); + EXPECT_EQ(c, &ccc); + EXPECT_EQ(magic, 1234); + CC_LOG_DEBUG("test memberFunction MyTarget::foo"); + } + + private: + Node *_node; + int magic = 1234; + }; + // test on + MyTarget target{node}; + node->on("hello", &MyTarget::foo, &target); + EXPECT_TRUE(node->hasEventListener("hello", &MyTarget::foo, &target)); + + node->emit("hello", 1, 2.3F, &ccc); + + //off + node->off("hello", &MyTarget::foo, &target); + EXPECT_FALSE(node->hasEventListener("hello", &MyTarget::foo, &target)); + + //once + node->once("helloOnce", &MyTarget::foo, &target); + EXPECT_TRUE(node->hasEventListener("helloOnce", &MyTarget::foo, &target)); + node->emit("helloOnce", 1, 2.3F, &ccc); + EXPECT_FALSE(node->hasEventListener("helloOnce", &MyTarget::foo, &target)); + + delete node; +} + +//////// test std::function +TEST(CoreNodeEventProcessor, test_function_args) { + // CallbacksInvoker ci; + auto * node = new Node(); + CallbackInfoBase::ID id1_not_target1{0}, id1_not_target2{0}, id1_target11{0}, id1_target22{0}, id1_b1{0}, id2{0}, id21{0}, id22{0}, id3{0}, id31{0}, id32{0}; + + static uint32_t myTargetFooCalledCount = 0; + myTargetFooCalledCount = 0; + + class MyTarget { + public: + MyTarget(const std::string &name_ = "") + : name(name_) {} + void foo() { + if (!name.empty()) { + ++count; + } + + ++myTargetFooCalledCount; + } + + void operator()() { + foo(); + } + + std::string name; + uint32_t count{0}; + }; + + MyTarget target11{"CallbackTarget1"}; + MyTarget target1; + MyTarget target22{"CallbackTarget2"}; + + std::function cb1 = target1; + std::function cb1_target11 = std::bind(&MyTarget::foo, &target11); + std::function cb1_target22 = std::bind(&MyTarget::foo, &target22); + + // test on + node->on("a", cb1, id1_not_target1); + node->on("a", cb1, id1_not_target2); + EXPECT_TRUE(node->hasEventListener("a", id1_not_target1)); + EXPECT_TRUE(node->hasEventListener("a", id1_not_target2)); + + node->on("a", cb1_target11, &target11, id1_target11); + node->on("a", cb1_target22, &target22, id1_target22); + EXPECT_TRUE(node->hasEventListener("a", &target11, id1_target11)); + EXPECT_TRUE(node->hasEventListener("a", &target22, id1_target22)); + + // test emit + node->emit("a"); + EXPECT_EQ(myTargetFooCalledCount, 4); + + // test off + node->off("a", id1_not_target1); + node->off("a", id1_not_target2); + EXPECT_FALSE(node->hasEventListener("a", id1_not_target1)); + EXPECT_FALSE(node->hasEventListener("a", id1_not_target2)); + + node->off("a", id1_target11); + node->off("a", id1_target22); + EXPECT_FALSE(node->hasEventListener("a", &target11, id1_target11)); + EXPECT_FALSE(node->hasEventListener("a", &target22, id1_target22)); + + //once + node->once("b", cb1, id1_not_target1); + node->once("b", cb1, id1_not_target2); + node->once("b", cb1_target11, &target11, id1_target11); + node->once("b", cb1_target22, &target22, id1_target22); + EXPECT_TRUE(node->hasEventListener("b", id1_not_target1)); + EXPECT_TRUE(node->hasEventListener("b", id1_not_target2)); + EXPECT_TRUE(node->hasEventListener("b", &target11, id1_target11)); + EXPECT_TRUE(node->hasEventListener("b", &target22, id1_target22)); + node->emit("b"); + EXPECT_FALSE(node->hasEventListener("b", id1_not_target1)); + EXPECT_FALSE(node->hasEventListener("b", id1_not_target2)); + EXPECT_FALSE(node->hasEventListener("b", id1_not_target1)); + EXPECT_FALSE(node->hasEventListener("b", id1_not_target2)); + + delete node; +} +*/ diff --git a/native/tests/unit-test/src/component_test.cpp b/native/tests/unit-test/src/component_test.cpp new file mode 100644 index 0000000000..98281b6f78 --- /dev/null +++ b/native/tests/unit-test/src/component_test.cpp @@ -0,0 +1,60 @@ +/**************************************************************************** + 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 "base/Log.h" +#include "core/Director.h" +#include "core/Root.h" +#include "core/scene-graph/SceneGraphModuleHeader.h" +#include "gtest/gtest.h" +#include "renderer/GFXDeviceManager.h" +#include "renderer/gfx-base/GFXDef.h" +#include "utils.h" + +using namespace cc; +using namespace cc::gfx; + +class MyComponent : public Component { +public: + void onLoad() override { + CC_LOG_INFO("MyComponent.onLoad"); + } +}; + +TEST(ComponentTest, isOnLoadCalled) { + initCocos(100, 100); + + auto *director = Director::getInstance(); + auto *scene = director->getScene(); + + auto *node = new Node(); + auto *comp = node->addComponent(); + director->getScene()->addChild(node); + EXPECT_TRUE(comp->isEnabledInHierarchy()); + EXPECT_TRUE(comp->isOnLoadCalled()); + + //xwx FIXME: gfx-validator Assert + destroyCocos(); +} +*/ diff --git a/native/tests/unit-test/src/core_event_callbacksinvoker.cpp b/native/tests/unit-test/src/core_event_callbacksinvoker.cpp new file mode 100644 index 0000000000..963011ad6e --- /dev/null +++ b/native/tests/unit-test/src/core_event_callbacksinvoker.cpp @@ -0,0 +1,870 @@ +/**************************************************************************** +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 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. +****************************************************************************/ +/* +#include "core/Director.h" +#include "core/Root.h" +#include "core/event/CallbacksInvoker.h" +#include "core/scene-graph/SceneGraphModuleHeader.h" +#include "gtest/gtest.h" +#include "renderer/GFXDeviceManager.h" +#include "renderer/gfx-base/GFXDef.h" +#include "utils.h" + +using namespace cc; +using namespace cc::gfx; + +namespace { + +template +struct FunctionTraits +: public FunctionTraits {}; + +template +struct FunctionTraits { + typedef std::function type; +}; + +template +struct FunctionTraits { + typedef std::function type; +}; + +template +typename FunctionTraits::type toFunction(T l) { + return static_cast::type>(l); +} + +} // namespace + +template +class TestFunctor final { +public: + using Fn = std::function; + + TestFunctor(Fn &&cb) + : _cb(std::forward(cb)) { + } + + template + TestFunctor(const Lambda &cb) { + _cb = toFunction(cb); + } + + void operator()(Args &&...args) { + _cb(std::forward(args)...); + *_calledCount = *_calledCount + 1; + } + + uint32_t getCalledCount() const { + return *_calledCount; + } + + void clear() { + *_calledCount = 0; + } + + // TestFunctor(const TestFunctor&) { + // CC_LOG_DEBUG("copy consturctor"); + // } + // + // TestFunctor& operator=(const TestFunctor&) { + // CC_LOG_DEBUG("copy operator"); + // } + // + // TestFunctor(TestFunctor&&) { + // CC_LOG_DEBUG("move consturctor"); + // } + // + // TestFunctor& operator=(TestFunctor&&) { + // CC_LOG_DEBUG("move operator"); + // } + +private: + Fn _cb; + std::shared_ptr _calledCount{std::make_shared(0)}; +}; + +class MyCallbackTarget { +public: +}; + +TEST(CoreEventCallbacksInvoker, output_log) { + static CallbackInfoBase::ID id1{0}; + static CallbackInfoBase::ID id2{0}; + static CallbackInfoBase::ID id3{0}; + static CallbackInfoBase::ID id4{0}; + static CallbackInfoBase::ID id5{0}; + static CallbackInfoBase::ID id6{0}; + + CallbacksInvoker ci; + + class MyTarget { + public: + MyTarget(CallbacksInvoker &ci) + : _ci(ci) {} + void foo() { + CC_LOG_DEBUG("magic: %d, foo", magic); + } + + void haha1(int a) { + CC_LOG_DEBUG("magic: %d, haha1", magic); + _ci.off("memberfunction0", id5); + } + + void haha2(int a) { + CC_LOG_DEBUG("magic: %d, haha2", magic); + } + + void haha3(int a) { + CC_LOG_DEBUG("magic: %d, haha3", magic); + } + + void haha4(int a) { + CC_LOG_DEBUG("magic: %d, haha4", magic); + } + + void haha5(int a) { + CC_LOG_DEBUG("magic: %d, haha5", magic); + } + + void foo1(int a) { + CC_LOG_DEBUG("magic: %d, foo1, a: %d", magic, a); + } + + void foo2(int a, float b) { + CC_LOG_DEBUG("magic: %d, foo2, a: %d, b: %f", magic, a, b); + } + void foo3(int a, float b, bool c) { + CC_LOG_DEBUG("magic: %d, foo3, a: %d, b: %f, c: %d", magic, a, b, c); + } + + void xxx() { + CC_LOG_DEBUG("magic: %d, xxx", magic); + } + + void xxx1(int a) { + CC_LOG_DEBUG("magic: %d, xxx1, a: %d", magic, a); + } + + void xxx2(int a, float b) { + CC_LOG_DEBUG("magic: %d, xxx2, a: %d, b: %f", magic, a, b); + } + void xxx3(int a, float b, bool c) { + CC_LOG_DEBUG("magic: %d, xxx3, a: %d, b: %f, c: %d", magic, a, b, c); + } + + int magic = 12334; + CallbacksInvoker &_ci; + }; + MyTarget target{ci}; + + ci.on("hello", [](int a) { + CC_LOG_DEBUG("hello callback, a: %d", a); + }); + + ci.emit("hello", 100); + + auto ret = ci.hasEventListener("xxx"); + ret = ci.hasEventListener("hello"); + + ci.on("memberfunction0", CC_CALLBACK_INVOKE_1(MyTarget::haha1, &target, int), id3); + ci.on("memberfunction0", CC_CALLBACK_INVOKE_1(MyTarget::haha2, &target, int), id4); + ci.on("memberfunction0", CC_CALLBACK_INVOKE_1(MyTarget::haha3, &target, int), id5); + ci.on("memberfunction0", CC_CALLBACK_INVOKE_1(MyTarget::haha4, &target, int), id6); + ci.on("memberfunction0", CC_CALLBACK_INVOKE_1(MyTarget::foo1, &target, int), id1); + ci.on("memberfunction0", CC_CALLBACK_INVOKE_1(MyTarget::xxx1, &target, int), id2); + + ci.emit("memberfunction0", 100); + CC_LOG_DEBUG("--------------------------"); + ci.emit("memberfunction0", 100); + CC_LOG_DEBUG("--------------------------"); + ci.off("memberfunction0", id1); + ci.emit("memberfunction0", 100); + CC_LOG_DEBUG("--------------------------"); + ci.on("memberfunction1", CC_CALLBACK_INVOKE_1(MyTarget::foo1, &target, int)); + ci.emit("memberfunction1", 123); + CC_LOG_DEBUG("--------------------------"); + ci.on("memberfunction2", CC_CALLBACK_INVOKE_2(MyTarget::foo2, &target, int, float)); + ci.emit("memberfunction2", 234, 345.3F); + CC_LOG_DEBUG("--------------------------"); + ci.on("memberfunction3", CC_CALLBACK_INVOKE_3(MyTarget::foo3, &target, int, float, bool)); + ci.emit("memberfunction3", 323, 34.3F, true); + CC_LOG_DEBUG("--------------------------"); +} + +TEST(CoreEventCallbacksInvoker, member_function_target) { + CallbacksInvoker ci; + + static int ccc = 123344; + class MyFoo : public CCObject { + public: + void foo(int a, float b, int *c) { + EXPECT_EQ(a, 1); + EXPECT_TRUE(IsEqualF(b, 2.3F)); + EXPECT_EQ(c, &ccc); + EXPECT_EQ(magic, 1234); + } + + private: + int magic = 1234; + }; + + MyFoo foo; + ci.on("hello", &MyFoo::foo, &foo); + ci.emit("hello", 1, 2.3F, &ccc); +} + +TEST(CoreEventCallbacksInvoker, member_function_target_remove) { + static CallbacksInvoker ci; + + static int fooCount = 0, fooCountA = 0, fooCountB = 0, fooCountC = 0; + fooCount = fooCountA = fooCountB = fooCountC = 0; + + static int ccc = 0; + class MyFoo : public CCObject { + public: + void foo(int a, float b, int *c) { + EXPECT_EQ(a, 1); + EXPECT_TRUE(IsEqualF(b, 2.3F)); + EXPECT_EQ(c, &ccc); + EXPECT_EQ(magic, 1234); + ++fooCount; + } + + void fooA() { + ++fooCountA; + } + + void fooB(bool cancelSelf) { + ++fooCountB; + if (cancelSelf) { + ci.off("hello3", &MyFoo::fooB, this); + } + } + void fooC() { + ++fooCountC; + } + + private: + int magic = 1234; + }; + + MyFoo foo; + ci.on("hello", &MyFoo::foo, &foo); + ci.on("hello2", &MyFoo::fooA, &foo); + ci.on("hello3", &MyFoo::fooB, &foo); + ci.on("hello4", &MyFoo::fooC, &foo); + ci.emit("hello", 1, 2.3F, &ccc); + ci.emit("hello2"); + ci.emit("hello3", false); + ci.emit("hello4"); + + EXPECT_EQ(fooCount, 1); + EXPECT_EQ(fooCountA, 1); + EXPECT_EQ(fooCountB, 1); + EXPECT_EQ(fooCountC, 1); + + ci.off("hello", &MyFoo::foo, &foo); + ci.emit("hello", 1, 2.3F, &ccc); + ci.emit("hello2"); + ci.emit("hello3", false); + ci.emit("hello4"); + + EXPECT_EQ(fooCount, 1); + EXPECT_EQ(fooCountA, 2); + EXPECT_EQ(fooCountB, 2); + EXPECT_EQ(fooCountC, 2); + + ci.emit("hello3", true); + EXPECT_EQ(fooCountB, 3); + ci.emit("hello3", false); + EXPECT_EQ(fooCountB, 3); + + ci.offAll(); +} + +TEST(CoreEventCallbacksInvoker, test) { + CallbacksInvoker ci; + CallbackInfoBase::ID id1{0}, id2{0}, id3{0}; + + TestFunctor<> cb1{[]() {}}; + TestFunctor<> cb2{[]() {}}; + TestFunctor<> cb3{[]() {}}; + + ci.on("a", cb1, id1); + EXPECT_FALSE(ci.hasEventListener("a", 12334)); + EXPECT_TRUE(ci.hasEventListener("a", id1)); + ci.on("a", cb2, id2); + ci.on("b", cb3, id3); + + ci.emit("a"); + EXPECT_EQ(cb1.getCalledCount(), 1); + EXPECT_EQ(cb2.getCalledCount(), 1); + + ci.emit("b"); + EXPECT_EQ(cb3.getCalledCount(), 1); + + ci.off("a", id2); + ci.emit("a"); + EXPECT_EQ(cb1.getCalledCount(), 2); + EXPECT_EQ(cb2.getCalledCount(), 1); + + ci.on("a", cb2); + EXPECT_TRUE(ci.hasEventListener("a")); + ci.offAll("a"); + EXPECT_FALSE(ci.hasEventListener("a")); + + ci.emit("a"); + EXPECT_EQ(cb1.getCalledCount(), 2); + EXPECT_EQ(cb2.getCalledCount(), 1); +} + +TEST(CoreEventCallbacksInvoker, remove_self_during_invoking) { + CallbacksInvoker ci; + + CallbackInfoBase::ID id1{0}; + TestFunctor<> cb1{[&ci, &id1]() { + ci.off("eve", id1); + }}; + TestFunctor<> cb2{[]() {}}; + + ci.on("eve", cb1, id1); + ci.on("eve", cb2); + ci.emit("eve"); + EXPECT_EQ(cb2.getCalledCount(), 1); + ci.emit("eve"); + EXPECT_EQ(cb1.getCalledCount(), 1); + EXPECT_EQ(cb2.getCalledCount(), 2); +} + +TEST(CoreEventCallbacksInvoker, remove_self_with_target_during_invoking) { + CallbacksInvoker ci; + MyCallbackTarget target; + CallbackInfoBase::ID id1{0}; + + TestFunctor<> cb1{[&]() { + ci.off("eve", id1); + }}; + + TestFunctor<> cb2{[]() {}}; + + ci.on("eve", cb1, id1, &target); + ci.on("eve", cb2, &target); + ci.emit("eve"); + EXPECT_EQ(cb1.getCalledCount(), 1); + EXPECT_EQ(cb2.getCalledCount(), 1); + + ci.emit("eve"); + EXPECT_EQ(cb1.getCalledCount(), 1); + EXPECT_EQ(cb2.getCalledCount(), 2); +} + +TEST(CoreEventCallbacksInvoker, remove_previous_during_invoking) { + CallbacksInvoker ci; + CallbackInfoBase::ID id1{0}, id2{0}; + + TestFunctor<> cb1{[]() {}}; + TestFunctor<> cb2{[&]() { + ci.off("eve", id1); + }}; + + ci.on("eve", cb1, id1); + ci.on("eve", cb2, id2); + ci.emit("eve"); + + EXPECT_FALSE(ci.hasEventListener("eve", id1)); + EXPECT_TRUE(ci.hasEventListener("eve", id2)); +} + +TEST(CoreEventCallbacksInvoker, remove_previous_with_target_during_invoking) { + CallbacksInvoker ci; + MyCallbackTarget target; + CallbackInfoBase::ID id1{0}, id2{0}; + + TestFunctor<> cb1{[]() {}}; + TestFunctor<> cb2{[&]() { + ci.off("eve", id1); + }}; + + ci.on("eve", cb1, &target, id1); + ci.on("eve", cb2, &target, id2); + ci.emit("eve"); + + EXPECT_FALSE(ci.hasEventListener("eve", &target, id1)); + EXPECT_TRUE(ci.hasEventListener("eve", &target, id2)); +} + +TEST(CoreEventCallbacksInvoker, remove_last_during_invoking) { + CallbacksInvoker ci; + CallbackInfoBase::ID id1{0}, id2{0}; + + TestFunctor<> cb1{[]() {}}; + TestFunctor<> cb2{[&]() { + ci.off("eve", id2); + }}; + + ci.on("eve", cb1, id1); + ci.on("eve", cb2, id2); + ci.emit("eve"); + + EXPECT_TRUE(ci.hasEventListener("eve", id1)); + EXPECT_FALSE(ci.hasEventListener("eve", id2)); +} + +TEST(CoreEventCallbacksInvoker, remove_last_with_target_during_invoking) { + CallbacksInvoker ci; + MyCallbackTarget target; + CallbackInfoBase::ID id1{0}, id2{0}; + + TestFunctor<> cb1{[]() {}}; + TestFunctor<> cb2{[&]() { + ci.off("eve", id2); + }}; + + ci.on("eve", cb1, &target, id1); + ci.on("eve", cb2, &target, id2); + ci.emit("eve"); + + EXPECT_TRUE(ci.hasEventListener("eve", &target, id1)); + EXPECT_FALSE(ci.hasEventListener("eve", &target, id2)); +} + +TEST(CoreEventCallbacksInvoker, remove_multiple_callbacks_during_invoking) { + CallbacksInvoker ci; + MyCallbackTarget target; + CallbackInfoBase::ID id1{0}, id11{0}, id2{0}, id3{0}, id31{0}; + + TestFunctor<> cb1{[]() {}}; + TestFunctor<> cb2{[&]() { + ci.off("eve", id1); + ci.off("eve", id31); + }}; + TestFunctor<> cb3{[&]() { + ci.off("eve", id2); + }}; + + ci.on("eve", cb1, id1); + ci.on("eve", cb1, &target, id11); + ci.on("eve", cb2, &target, id2); + ci.on("eve", cb3, id3); + ci.on("eve", cb3, &target, id31); + ci.emit("eve"); + + EXPECT_EQ(cb1.getCalledCount(), 2); + EXPECT_EQ(cb2.getCalledCount(), 1); + EXPECT_EQ(cb3.getCalledCount(), 1); + + EXPECT_TRUE(ci.hasEventListener("eve", &target, id11)); + EXPECT_FALSE(ci.hasEventListener("eve", id1)); + + EXPECT_FALSE(ci.hasEventListener("eve", &target, id2)); + EXPECT_FALSE(ci.hasEventListener("eve", &target, id31)); +} + +TEST(CoreEventCallbacksInvoker, remove_all_callbacks_during_invoking) { + CallbacksInvoker ci; + MyCallbackTarget target; + CallbackInfoBase::ID id1{0}, id11{0}, id2{0}, id3{0}, id31{0}; + + TestFunctor<> cb1{[]() {}}; + TestFunctor<> cb2{[&]() { + ci.offAll("eve"); + }}; + TestFunctor<> cb3{[&]() { + ci.off("eve", id2); + }}; + + ci.on("eve", cb1, id1); + ci.on("eve", cb1, &target, id11); + ci.on("eve", cb2, &target, id2); + ci.on("eve", cb3, id3); + ci.on("eve", cb3, &target, id31); + ci.emit("eve"); + + EXPECT_EQ(cb1.getCalledCount(), 2); + EXPECT_EQ(cb2.getCalledCount(), 1); + EXPECT_EQ(cb3.getCalledCount(), 0); + + EXPECT_FALSE(ci.hasEventListener("eve")); +} + +TEST(CoreEventCallbacksInvoker, CallbacksInvoker_support_target) { + CallbacksInvoker ci; + CallbackInfoBase::ID id1_not_target1{0}, id1_not_target2{0}, id1_target11{0}, id1_target22{0}, id1_b1{0}, id2{0}, id21{0}, id22{0}, id3{0}, id31{0}, id32{0}; + + static uint32_t myTargetFooCalledCount = 0; + myTargetFooCalledCount = 0; + + class MyTarget { + public: + MyTarget(const std::string &name_ = "") + : name(name_) {} + void foo() { + if (!name.empty()) { + ++count; + } + + ++myTargetFooCalledCount; + } + + void operator()() { + foo(); + } + + std::string name; + uint32_t count{0}; + }; + + MyTarget target11{"CallbackTarget1"}; + MyTarget target1; + MyTarget target22{"CallbackTarget2"}; + + std::function cb1 = target1; + std::function cb1_target11 = std::bind(&MyTarget::foo, &target11); + std::function cb1_target22 = std::bind(&MyTarget::foo, &target22); + + TestFunctor<> cb2{[]() {}}; + TestFunctor<> cb3{[]() {}}; + + ci.on("a", cb1, id1_not_target1); + ci.on("a", cb1_target11, &target11, id1_target11); + ci.on("a", cb1, id1_not_target2); + ci.on("a", cb1_target22, &target22, id1_target22); + ci.on("a", cb2, &target22, id21); + ci.on("a", cb2, &target11, id22); + ci.on("a", cb3, id3); + ci.on("a", cb3, &target11, id31); + ci.on("b", cb1_target11, &target11, id1_b1); + + EXPECT_FALSE(ci.hasEventListener("a", nullptr, id21)); + EXPECT_FALSE(ci.hasEventListener("a", nullptr, id22)); + + EXPECT_TRUE(ci.hasEventListener("a", &target11, id22)); + EXPECT_TRUE(ci.hasEventListener("a", nullptr, id3)); + + ci.emit("a"); + EXPECT_EQ(myTargetFooCalledCount, 4); //cjh TODO: ts is 3 + EXPECT_EQ(target11.count, 1); + EXPECT_EQ(target22.count, 1); + + EXPECT_EQ(cb2.getCalledCount(), 2); + EXPECT_EQ(cb3.getCalledCount(), 2); + + ci.off("b", id1_not_target1); + ci.off("b", id1_target22); + EXPECT_TRUE(ci.hasEventListener("b", &target11, id1_b1)); + ci.off("b", id1_b1); + EXPECT_FALSE(ci.hasEventListener("b", &target11, id1_b1)); + + target11.count = 0; + target22.count = 0; + myTargetFooCalledCount = 0; + cb2.clear(); + cb3.clear(); + + ci.off("a", id1_target22); + ci.off("a", id1_target11); + ci.off("a", id21); + ci.emit("a"); + + EXPECT_EQ(myTargetFooCalledCount, 2); + EXPECT_EQ(target11.count, 0); + EXPECT_EQ(target22.count, 0); + + EXPECT_EQ(cb2.getCalledCount(), 1); + EXPECT_EQ(cb3.getCalledCount(), 2); +} + +TEST(CoreEventCallbacksInvoker, pointer_args) { + CallbacksInvoker ci; + class Sender {}; + static Sender sender; + + ci.on("hello", [&](Sender *s) { + EXPECT_EQ(s, &sender); + }); + + ci.emit("hello", &sender); + + // + class Foo { + public: + void foo(Sender *s, int arg1) { + EXPECT_EQ(s, &sender); + EXPECT_EQ(_magic, 1234); + EXPECT_EQ(arg1, 222333); + } + + private: + int _magic{1234}; + }; + Foo myFoo; + ci.on("world", CC_CALLBACK_INVOKE_2(Foo::foo, &myFoo, Sender *, int)); + ci.emit("world", &sender, 222333); +} + +TEST(CoreEventCallbacksInvoker, reference_args) { + CallbacksInvoker ci; + class Sender {}; + static Sender sender; + + ci.on("hello", [&](Sender &s) { + EXPECT_EQ(&s, &sender); + }); + + ci.emit("hello", sender); + // + class Foo { + public: + void foo(Sender &s) { + EXPECT_EQ(&s, &sender); + EXPECT_EQ(_magic, 1234); + } + + private: + int _magic{1234}; + }; + Foo myFoo; + ci.on("world", CC_CALLBACK_INVOKE_1(Foo::foo, &myFoo, Sender &)); + ci.emit("world", sender); +} + +TEST(CoreEventCallbacksInvoker, const_pointer_args) { + CallbacksInvoker ci; + class Sender {}; + static const Sender sender; + + ci.on("hello", [&](const Sender *s) { + EXPECT_EQ(s, &sender); + }); + + ci.emit("hello", &sender); + + // + class Foo { + public: + void foo(const Sender *s, int arg1) { + EXPECT_EQ(s, &sender); + EXPECT_EQ(_magic, 1234); + EXPECT_EQ(arg1, 222333); + } + + private: + int _magic{1234}; + }; + Foo myFoo; + ci.on("world", CC_CALLBACK_INVOKE_2(Foo::foo, &myFoo, const Sender *, int)); + ci.emit("world", &sender, 222333); +} + +TEST(CoreEventCallbacksInvoker, const_reference_args) { + CallbacksInvoker ci; + class Sender {}; + static const Sender sender; + + ci.on("hello", [&](const Sender &s) { + EXPECT_EQ(&s, &sender); + }); + + ci.emit("hello", sender); + // + class Foo { + public: + void foo(const Sender &s) { + EXPECT_EQ(&s, &sender); + EXPECT_EQ(_magic, 1234); + } + + private: + int _magic{1234}; + }; + Foo myFoo; + ci.on("world", CC_CALLBACK_INVOKE_1(Foo::foo, &myFoo, const Sender &)); + ci.emit("world", sender); +} + +TEST(CoreEventCallbacksInvoker, remove_target) { + CallbacksInvoker ci; + CallbackInfoBase::ID id1_not_target1{0}, id1_not_target2{0}, id1_target11{0}, id1_target22{0}, id1_b1{0}, id2{0}, id21{0}, id22{0}, id3{0}, id31{0}, id32{0}; + static uint32_t myTargetFooCalledCount = 0; + myTargetFooCalledCount = 0; + + class MyTarget { + public: + MyTarget(const std::string &name_ = "") + : name(name_) {} + void foo() { + if (!name.empty()) { + ++count; + } + ++myTargetFooCalledCount; + } + + void operator()() { + foo(); + } + + std::string name; + uint32_t count{0}; + }; + + MyTarget target1; + MyTarget target11{"CallbackTarget1"}; + MyTarget target22{"CallbackTarget2"}; + + std::function cb1 = target1; + std::function cb1_target11 = std::bind(&MyTarget::foo, &target11); + std::function cb1_target22 = std::bind(&MyTarget::foo, &target22); + + TestFunctor<> cb2{[]() {}}; + TestFunctor<> cb3{[]() {}}; + + ci.on("a", cb1, id1_not_target1); + ci.on("a", cb1_target11, &target11, id1_target11); + ci.on("a", cb1, id1_not_target2); + ci.on("a", cb1_target22, &target22, id1_target22); + ci.on("a", cb2, &target22, id21); + ci.on("a", cb2, &target11, id22); + ci.on("a", cb3, id3); + ci.on("a", cb3, &target11, id31); + + ci.emit("a"); + EXPECT_EQ(myTargetFooCalledCount, 4); + EXPECT_EQ(cb2.getCalledCount(), 2); + EXPECT_EQ(cb3.getCalledCount(), 2); + + ci.offAll(&target11); + myTargetFooCalledCount = 0; + target1.count = 0; + cb2.clear(); + cb3.clear(); + + ci.emit("a"); + EXPECT_EQ(myTargetFooCalledCount, 3); + EXPECT_EQ(cb2.getCalledCount(), 1); + EXPECT_EQ(cb3.getCalledCount(), 1); + + ci.offAll(&target22); + myTargetFooCalledCount = 0; + target1.count = 0; + cb2.clear(); + cb3.clear(); + + ci.emit("a"); + EXPECT_EQ(myTargetFooCalledCount, 2); + EXPECT_EQ(cb2.getCalledCount(), 0); + EXPECT_EQ(cb3.getCalledCount(), 1); +} + +TEST(CoreEventCallbacksInvoker, nest_invoke) { + CallbacksInvoker ci; + + std::vector actualSequence; + bool isParentLoop{true}; + + auto cb1 = [&]() { + actualSequence.emplace_back(1); + if (isParentLoop) { + isParentLoop = false; + ci.emit("visit"); + } + }; + auto cb2 = [&]() { + actualSequence.emplace_back(2); + }; + + ci.on("visit", cb1); + ci.on("visit", cb2); + ci.emit("visit"); + EXPECT_EQ(actualSequence.size(), 4); + EXPECT_EQ(actualSequence[0], 1); + EXPECT_EQ(actualSequence[1], 1); + EXPECT_EQ(actualSequence[2], 2); + EXPECT_EQ(actualSequence[3], 2); +} + +TEST(CoreEventCallbacksInvoker, remove_during_nest_invoke) { + CallbacksInvoker ci; + + std::vector actualSequence; + bool isParentLoop{true}; + CallbackInfoBase::ID id1{0}; + + auto cb1 = [&]() { + actualSequence.emplace_back(1); + if (isParentLoop) { + isParentLoop = false; + ci.emit("visit"); + } else { + ci.off("visit", id1); + EXPECT_FALSE(ci.hasEventListener("visit")); + } + }; + + ci.on("visit", cb1, id1); + ci.emit("visit"); + + EXPECT_EQ(actualSequence.size(), 2); + EXPECT_EQ(actualSequence[0], 1); + EXPECT_EQ(actualSequence[1], 1); +} + +TEST(CoreEventCallbacksInvoker, remove_many_during_nest_invoke) { + CallbacksInvoker ci; + + std::vector actualSequence; + bool isParentLoop{true}; + CallbackInfoBase::ID id1{0}, id2{0}; + + auto cb1 = [&]() { + actualSequence.emplace_back(1); + }; + auto cb2 = [&]() { + actualSequence.emplace_back(2); + if (isParentLoop) { + isParentLoop = false; + ci.emit("visit"); + } else { + ci.off("visit", id1); + ci.off("visit", id2); + } + }; + auto cb3 = [&]() { + actualSequence.emplace_back(3); + }; + + ci.on("visit", cb1, id1); + ci.on("visit", cb2, id2); + ci.on("visit", cb3); + ci.emit("visit"); + EXPECT_EQ(actualSequence.size(), 6); + EXPECT_EQ(actualSequence[0], 1); + EXPECT_EQ(actualSequence[1], 2); + EXPECT_EQ(actualSequence[2], 1); + EXPECT_EQ(actualSequence[3], 2); + EXPECT_EQ(actualSequence[4], 3); + EXPECT_EQ(actualSequence[5], 3); +} + +*/ diff --git a/native/tests/unit-test/src/core_find_test.cpp b/native/tests/unit-test/src/core_find_test.cpp new file mode 100644 index 0000000000..49e8eb6f77 --- /dev/null +++ b/native/tests/unit-test/src/core_find_test.cpp @@ -0,0 +1,75 @@ +/**************************************************************************** +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 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. +****************************************************************************/ +/* +#include "core/Director.h" +#include "core/Root.h" +#include "core/scene-graph/SceneGraphModuleHeader.h" +#include "gtest/gtest.h" +#include "renderer/GFXDeviceManager.h" +#include "renderer/gfx-base/GFXDef.h" +#include "utils.h" + +using namespace cc; +using namespace cc::gfx; + +TEST(CoreFindTest, test0) { + initCocos(100, 100); + + auto *director = Director::getInstance(); + auto *scene = director->getScene(); + + auto *node = new Node("test"); + scene->addChild(node); + + EXPECT_EQ(find("/test"), node); + EXPECT_EQ(find("test"), node); + + auto *node2 = new Node(".赞"); + scene->addChild(node2); + + EXPECT_EQ(find("/.赞"), node2); + EXPECT_EQ(find(".赞"), node2); + + auto *nodenode = new Node(""); + scene->addChild(nodenode); + + //cjh TODO: Creator 2.x return node or nullptr but 3.x return scene, which one is correct? + EXPECT_EQ(find("/"), scene); + EXPECT_EQ(find(""), scene); + + auto *node2node2 = new Node("Jare Guo"); + node2->addChild(node2node2); + + EXPECT_EQ(find("/.赞/Jare Guo"), node2node2); + EXPECT_EQ(find(".赞/Jare Guo"), node2node2); + EXPECT_EQ(find("Jare Guo", node2), node2node2); + + auto *ent2ent2ent2 = new Node("FOO"); + node2node2->addChild(ent2ent2ent2); + EXPECT_EQ(find("Jare Guo/FOO", node2), ent2ent2ent2); + + //cjh FIXME: crash if invoke + destroyCocos(); +} +*/ diff --git a/native/tests/unit-test/src/core_utils_path_test.cpp b/native/tests/unit-test/src/core_utils_path_test.cpp new file mode 100644 index 0000000000..5768cd999f --- /dev/null +++ b/native/tests/unit-test/src/core_utils_path_test.cpp @@ -0,0 +1,148 @@ +/**************************************************************************** +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 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. +****************************************************************************/ +#include "utils.h" + +#include "base/StringUtil.h" +#include "core/utils/Path.h" + +using namespace cc; + +TEST(CoreUtilsPathTest, join) { + EXPECT_EQ(join({"a", "b", "c", "d"}), "a/b/c/d"); + EXPECT_EQ(join({"a/", "b/", "c", "d"}), "a/b/c/d"); + EXPECT_EQ(join({"a//", "b/", "c", "d"}), "a//b/c/d"); + EXPECT_EQ(join({"a\\", "b\\", "c\\", "d"}), "a/b/c/d"); +} + +TEST(CoreUtilsPathTest, extname) { + EXPECT_EQ(extname("?"), ""); + EXPECT_EQ(extname("."), "."); + EXPECT_EQ(extname("a/b/c/d.png"), ".png"); + EXPECT_EQ(extname("a/b/c/d.png?hello=1&world=22"), ".png"); + EXPECT_EQ(extname(""), ""); + EXPECT_EQ(extname("a"), ""); + EXPECT_EQ(extname("a.png"), ".png"); + EXPECT_EQ(extname("/a.png"), ".png"); + EXPECT_EQ(extname("\\a.png"), ".png"); +} + +TEST(CoreUtilsPathTest, mainFileName) { + EXPECT_EQ(mainFileName("a/b/c/d.png"), "a/b/c/d"); + EXPECT_EQ(mainFileName(""), ""); + EXPECT_EQ(mainFileName("a"), "a"); + EXPECT_EQ(mainFileName("a.png"), "a"); + EXPECT_EQ(mainFileName("/a.png"), "/a"); + EXPECT_EQ(mainFileName("\\a.png"), "\\a"); +} + +TEST(CoreUtilsPathTest, basename) { + EXPECT_EQ(basename("?"), "?"); + EXPECT_EQ(basename("aa/bb/cc.js/ee.js", "xxxyyyyyyyyyyyyyyyzzzzzzzzzzjhhhhhhhhhh.js"), "ee.js"); + EXPECT_EQ(basename("aa/bb/cc.js?hello=1&world=200", ".js"), "cc"); + EXPECT_EQ(basename("aa/bb/cc.js?hello=1&world=200", ".wrongext"), "cc.js"); + + EXPECT_EQ(basename("aa/bb/cc.js", ".js"), "cc"); + EXPECT_EQ(basename("aa/bb/cc_cc.js", ".js"), "cc_cc"); + EXPECT_EQ(basename("aa/bb/cc/"), "cc"); + EXPECT_EQ(basename("D:\\aa\\bb\\cc"), "cc"); + EXPECT_EQ(basename("aa/bb/cc(cc).js", ".js"), "cc(cc)"); + EXPECT_EQ(basename("aa/bb/cc[cc].js", ".js"), "cc[cc]"); + EXPECT_EQ(basename("aa/bb/cc.js/ee.js", ".js"), "ee"); + EXPECT_EQ(basename("aa/bb/.github"), ".github"); + EXPECT_EQ(basename("aa"), "aa"); + // ios only, and linux not suggest + EXPECT_EQ(basename("aa/bb/cc|cc.js", ".js"), "cc|cc"); +} + +TEST(CoreUtilsPathTest, dirname) { + EXPECT_EQ(dirname("aa/bb/cc"), "aa/bb"); + EXPECT_EQ(dirname("aa/bb/cc.png"), "aa/bb"); + EXPECT_EQ(dirname("aa/bb/cc/"), "aa/bb/cc"); + EXPECT_EQ(dirname("aa/bb/cc.png/ee.png"), "aa/bb/cc.png"); + EXPECT_EQ(dirname("D:\\aa\\bb"), "D:\\aa"); + EXPECT_EQ(dirname("aa/bb/.github/.gitignore"), "aa/bb/.github"); +} + +TEST(CoreUtilsPathTest, changeExtname) { + EXPECT_EQ(changeExtname(""), ""); + EXPECT_EQ(changeExtname("?"), "?"); + EXPECT_EQ(changeExtname("a"), "a"); + EXPECT_EQ(changeExtname("aa/bb/cc"), "aa/bb/cc"); + EXPECT_EQ(changeExtname("aa/bb/cc.png"), "aa/bb/cc"); + EXPECT_EQ(changeExtname("aa/bb/cc", ".png"), "aa/bb/cc.png"); + EXPECT_EQ(changeExtname("aa/bb/cc.jpg", ".png"), "aa/bb/cc.png"); + EXPECT_EQ(changeExtname("aa/bb/cc.jpg?a=1&b=2", ".png"), "aa/bb/cc.png?a=1&b=2"); + EXPECT_EQ(changeExtname("aa/bb/cc.png/ee.png", ".gif"), "aa/bb/cc.png/ee.gif"); + EXPECT_EQ(changeExtname("D:\\aa\\bb\\cc.png\\ee.png", ".gif"), "D:\\aa\\bb\\cc.png\\ee.gif"); + EXPECT_EQ(changeExtname("aa/bb/.github/.gitignore"), "aa/bb/.github/"); + EXPECT_EQ(changeExtname("aa/bb/.github/.gitignore", ".png"), "aa/bb/.github/.png"); +} + +TEST(CoreUtilsPathTest, changeBasename) { + EXPECT_EQ(changeBasename(".", "hello"), "hello"); + EXPECT_EQ(changeBasename(".", "hello", true), "hello."); + EXPECT_EQ(changeBasename("", "abc"), "abc"); + EXPECT_EQ(changeBasename("", "abc", true), "abc"); + EXPECT_EQ(changeBasename("abc", "eee"), "eee"); + EXPECT_EQ(changeBasename("abc", "eee", true), "eee"); + EXPECT_EQ(changeBasename("abc", ".eee"), "abc.eee"); + + EXPECT_EQ(changeBasename("?", ".eee"), "?.eee"); + EXPECT_EQ(changeBasename("?", ".eee", true), "?.eee"); + EXPECT_EQ(changeBasename("aa/bb/cc", "hello"), "aa/bb/hello"); + EXPECT_EQ(changeBasename("aa/bb/cc", "hello", true), "aa/bb/hello"); + EXPECT_EQ(changeBasename("aa/bb/cc.png", "hello"), "aa/bb/hello"); + EXPECT_EQ(changeBasename("aa/bb/cc.png", "hello", true), "aa/bb/hello.png"); + + EXPECT_EQ(changeBasename("aa/bb/cc.jpg?a=1&b=2", "hello"), "aa/bb/hello?a=1&b=2"); + EXPECT_EQ(changeBasename("aa/bb/cc.jpg?a=1&b=2", "hello", true), "aa/bb/hello.jpg?a=1&b=2"); + EXPECT_EQ(changeBasename("aa/bb/cc.png/ee.png", "hello"), "aa/bb/cc.png/hello"); + EXPECT_EQ(changeBasename("aa/bb/cc.png/ee.png", "hello", true), "aa/bb/cc.png/hello.png"); + EXPECT_EQ(changeBasename("D:\\aa\\bb\\cc.png\\ee.png", "hello"), "D:\\aa\\bb\\cc.png\\hello"); + EXPECT_EQ(changeBasename("aa/bb/.github/.gitignore", "hello"), "aa/bb/.github/hello"); + EXPECT_EQ(changeBasename("aa/bb/.github/.gitignore", "hello", true), "aa/bb/.github/hello.gitignore"); +} + +TEST(CoreUtilsPathTest, normalize) { + EXPECT_EQ(normalize("../aa.png"), "../aa.png"); + EXPECT_EQ(normalize("aa/../../aa.png"), "../aa.png"); + EXPECT_EQ(normalize("aa/../aa.png"), "aa.png"); + EXPECT_EQ(normalize("aa/bb/cc/../aa.png"), "aa/bb/aa.png"); + EXPECT_EQ(normalize("aa/bb/cc/../../aa.png"), "aa/aa.png"); + std::string normalizedStr = normalize("D:\\aa\\bb\\cc\\..\\ee.png"); + StringUtil::replaceAll(normalizedStr, "/", "\\"); + EXPECT_EQ(normalizedStr, "D:\\aa\\bb\\ee.png"); +} + +TEST(CoreUtilsPathTest, stripSep) { + EXPECT_EQ(stripSep(""), ""); + EXPECT_EQ(stripSep("/"), ""); + EXPECT_EQ(stripSep("\\"), ""); + EXPECT_EQ(stripSep("a"), "a"); + EXPECT_EQ(stripSep("a/"), "a"); + EXPECT_EQ(stripSep("a\\"), "a"); + EXPECT_EQ(stripSep("a/b/c/"), "a/b/c"); + EXPECT_EQ(stripSep("a/b/c//"), "a/b/c/"); + EXPECT_EQ(stripSep("a\\b\\c\\"), "a\\b\\c"); +} diff --git a/native/tests/unit-test/src/geometry_capsule_test.cpp b/native/tests/unit-test/src/geometry_capsule_test.cpp new file mode 100644 index 0000000000..41db2a285c --- /dev/null +++ b/native/tests/unit-test/src/geometry_capsule_test.cpp @@ -0,0 +1,53 @@ +/**************************************************************************** +Copyright (c) 2021 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. +****************************************************************************/ +#include +#include "cocos/core/geometry/Capsule.h" +#include "cocos/math/Mat3.h" +#include "cocos/math/Mat4.h" +#include "cocos/math/Math.h" +#include "cocos/math/Quaternion.h" +#include "cocos/math/Vec3.h" +#include "cocos/math/Vec4.h" +#include "gtest/gtest.h" +#include "utils.h" + +TEST(geometryCapsuleTest, testTransform) { + cc::geometry::Capsule capsule{1.0, 2.0}; + cc::geometry::Capsule capsuleNew{}; + cc::Mat4 trans; + cc::Quaternion quat{}; + cc::Vec3 scale{1.0F, 2.0F, 3.0F}; + { + cc::Vec3 axis = {1.0, 0.0, 0.0}; + float angle = M_PI; + cc::Quaternion::createFromAxisAngle(axis, angle, &quat); + trans.translate(0, 1, 0); + } + capsule.transform(trans, {}, quat, scale, &capsuleNew); + EXPECT_TRUE(capsuleNew.center == cc::Vec3(0.0F, 1.0F, 0.0F)); + EXPECT_FLOAT_EQ(capsule.ellipseCenter0.y, 2.0F); + EXPECT_FLOAT_EQ(capsule.ellipseCenter1.y, -2.0F); + EXPECT_FLOAT_EQ(capsuleNew.ellipseCenter0.y, -2.0F); + EXPECT_FLOAT_EQ(capsuleNew.ellipseCenter1.y, 4.0F); +} diff --git a/native/tests/unit-test/src/math_mat3_test.cpp b/native/tests/unit-test/src/math_mat3_test.cpp index 7c34393cea..e8c05392f5 100644 --- a/native/tests/unit-test/src/math_mat3_test.cpp +++ b/native/tests/unit-test/src/math_mat3_test.cpp @@ -21,28 +21,28 @@ 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 "gtest/gtest.h" -#include "cocos/math/Vec2.h" +#include #include "cocos/math/Mat3.h" #include "cocos/math/Mat4.h" #include "cocos/math/Math.h" #include "cocos/math/Quaternion.h" +#include "cocos/math/Vec2.h" +#include "gtest/gtest.h" #include "utils.h" -#include TEST(mathMat3Test, test4) { - cc::Mat3 mat3(0,2,3, 4,5,6, 7,8,9); + cc::Mat3 mat3(0, 2, 3, 4, 5, 6, 7, 8, 9); // identity logLabel = "test the mat3 identity function"; cc::Mat3::identity(mat3); ExpectEq(mat3.m[0] == 1 && mat3.m[4] == 1 && mat3.m[8] == 1, true); // transpose logLabel = "test the mat3 transpose function"; - mat3.set(11,21,31, 12,22,32, 13,23,33); + mat3.set(11, 21, 31, 12, 22, 32, 13, 23, 33); mat3.transpose(); ExpectEq(mat3.m[1] == 21 && mat3.m[4] == 22 && mat3.m[7] == 23, true); - cc::Mat3 matTemp(11,21,31, 12,22,32, 13,23,33); - cc::Mat3::transpose(mat3, matTemp); + cc::Mat3 matTemp(11, 21, 31, 12, 22, 32, 13, 23, 33); + cc::Mat3::transpose(matTemp, &mat3); ExpectEq(mat3.m[1] == 21 && mat3.m[4] == 22 && mat3.m[7] == 23, true); // inverse logLabel = "test the mat3 inverse function"; @@ -52,7 +52,7 @@ TEST(mathMat3Test, test4) { // adjoint logLabel = "test the mat3 adjoint function"; cc::Mat3 matAdj(0, 2, 0, 3, 0, 0, 2, 0, 1); - cc::Mat3::adjoint(mat3, matAdj); + cc::Mat3::adjoint(matAdj, &mat3); ExpectEq(mat3.m[1] == -3 && mat3.m[3] == -2 && mat3.m[8] == -6, true); // determinant logLabel = "test the mat3 determinant function"; @@ -63,7 +63,7 @@ TEST(mathMat3Test, test4) { logLabel = "test the mat3 multiply function"; cc::Mat3 lm(2, 3, 1, 4, 7, 3, 8, 2, 0); cc::Mat3 rm(5, 2, 6, 8, 1, 0, 6, 5, 4); - cc::Mat3::multiply(mat3, lm, rm); + cc::Mat3::multiply(lm, rm, &mat3); ExpectEq(mat3.m[0] == 40 && mat3.m[4] == 30 && mat3.m[8] == 48, true); // translate logLabel = "test the mat3 translate function"; @@ -72,26 +72,26 @@ TEST(mathMat3Test, test4) { translate.m[7] = 2; cc::Vec2 pos(1, 2); cc::Mat3 transOut; - cc::Mat3::translate(transOut, translate, pos); + cc::Mat3::translate(translate, pos, &transOut); ExpectEq(transOut.m[6] == 4 && transOut.m[7] == 4, true); - cc::Mat3::fromTranslation(transOut, pos); + cc::Mat3::fromTranslation(pos, &transOut); ExpectEq(transOut.m[7] == 2, true); // rotate logLabel = "test the mat3 rotate function"; cc::Mat3 rotate; cc::Mat3 rotateOut; - cc::Mat3::rotate(rotateOut, rotate, cc::math::PI_DIV2); + cc::Mat3::rotate(rotate, cc::math::PI_DIV2, &rotateOut); ExpectEq(rotateOut.m[1] == 1 && rotateOut.m[3] == -1, true); - cc::Mat3::fromRotation(rotateOut, cc::math::PI_DIV2); + cc::Mat3::fromRotation(cc::math::PI_DIV2, &rotateOut); ExpectEq(rotateOut.m[1] == 1 && rotateOut.m[3] == -1, true); // scale logLabel = "test the mat3 scale function"; cc::Mat3 scale; cc::Mat3 scaleOut; cc::Vec2 scaleVec(2, 1); - cc::Mat3::scale(scaleOut, scale, scaleVec); + cc::Mat3::scale(scale, scaleVec, &scaleOut); ExpectEq(scaleOut.m[0] == 2, true); - cc::Mat3::fromScaling(scaleOut, scaleVec); + cc::Mat3::fromScaling(scaleVec, &scaleOut); ExpectEq(scaleOut.m[0] == 2, true); // fromMat4 logLabel = "test the mat3 fromMat4 function"; @@ -100,25 +100,24 @@ TEST(mathMat3Test, test4) { fromMat4.m[4] = 6; fromMat4.m[5] = 7; cc::Mat3 copyMat; - cc::Mat3::fromMat4(copyMat, fromMat4); + cc::Mat3::fromMat4(fromMat4, ©Mat); ExpectEq(copyMat.m[0] == 3 && copyMat.m[3] == 6 && copyMat.m[4] == 7, true); // fromQuat logLabel = "test the mat3 fromQuat function"; - cc::Mat3 fromQuat; + cc::Mat3 fromQuat; cc::Quaternion quat(0, 0, 3, 1); - cc::Mat3::fromQuat(fromQuat, quat); + cc::Mat3::fromQuat(quat, &fromQuat); ExpectEq(copyMat.m[0] == 3 && copyMat.m[3] == 6 && copyMat.m[4] == 7, true); // add logLabel = "test the mat3 add function"; - cc::Mat3 lAdd(9,0,0, 3,8,0, 9,0,0); - cc::Mat3 rAdd(1,0,0, 5,2,0, 1,0,0); + cc::Mat3 lAdd(9, 0, 0, 3, 8, 0, 9, 0, 0); + cc::Mat3 rAdd(1, 0, 0, 5, 2, 0, 1, 0, 0); cc::Mat3 addOut; - cc::Mat3::add(addOut, lAdd, rAdd); + cc::Mat3::add(lAdd, rAdd, &addOut); ExpectEq(addOut.m[0] == 10 && addOut.m[2] == 10 && addOut.m[4] == 10, true); // subtract logLabel = "test the mat3 subtract function"; cc::Mat3 subOut; - cc::Mat3::subtract(subOut, lAdd, rAdd); + cc::Mat3::subtract(lAdd, rAdd, &subOut); ExpectEq(subOut.m[0] == 8 && subOut.m[2] == 8 && subOut.m[4] == 6, true); } - diff --git a/native/tests/unit-test/src/math_mat4_test.cpp b/native/tests/unit-test/src/math_mat4_test.cpp index 450ad625a7..2baef8054c 100644 --- a/native/tests/unit-test/src/math_mat4_test.cpp +++ b/native/tests/unit-test/src/math_mat4_test.cpp @@ -21,15 +21,15 @@ 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 "gtest/gtest.h" -#include "cocos/math/Vec3.h" -#include "cocos/math/Vec4.h" +#include #include "cocos/math/Mat3.h" #include "cocos/math/Mat4.h" #include "cocos/math/Math.h" #include "cocos/math/Quaternion.h" +#include "cocos/math/Vec3.h" +#include "cocos/math/Vec4.h" +#include "gtest/gtest.h" #include "utils.h" -#include TEST(mathMat4Test, test5) { cc::Mat4 mat4; @@ -55,7 +55,7 @@ TEST(mathMat4Test, test5) { logLabel = "test the mat4 createOrthographicOffCenter function"; cc::Mat4::createOrthographicOffCenter(20, 40, 100, 200, 10, 100, &outMat); ExpectEq(outMat.m[12] == -3 && outMat.m[13] == -3, true); - cc::Mat4::createOrthographicOffCenter(20, 40, 100, 200, 10, 100, 0, 1, &outMat); + cc::Mat4::createOrthographicOffCenter(20, 40, 100, 200, 10, 100, 0, 1, 0, &outMat); ExpectEq(outMat.m[12] == -3 && outMat.m[13] == -3, true); // createBillboard logLabel = "test the mat4 createBillboard function"; diff --git a/native/tests/unit-test/src/math_vertex_test.cpp b/native/tests/unit-test/src/math_vertex_test.cpp index 8d5e800b58..fb221bf456 100644 --- a/native/tests/unit-test/src/math_vertex_test.cpp +++ b/native/tests/unit-test/src/math_vertex_test.cpp @@ -21,34 +21,28 @@ 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 "gtest/gtest.h" -#include "cocos/math/Vec2.h" -#include "cocos/math/Math.h" -#include "cocos/math/Vertex.h" -#include "utils.h" #include #include +#include "cocos/math/Math.h" +#include "cocos/math/Vec2.h" +#include "cocos/math/Vertex.h" +#include "gtest/gtest.h" +#include "utils.h" TEST(mathVertexTest, test8) { // ccVertexLineToPolygon logLabel = "test the vertex ccVertexLineToPolygon function"; - cc::Vec2 points[4]; - cc::Vec2 p1(1, 1); - points[0] = p1; - cc::Vec2 p2(10, 10); - points[1] = p2; - cc::Vec2 p3(0, -10); - points[2] = p3; - cc::Vec2 p4(20, 70); - points[3] = p4; - cc::Vec2 outP[6]; - cc::ccVertexLineToPolygon(points, 1, outP, 0, 5); + std::vector points{4}; + points[0] = {1, 1}; + points[1] = {10, 10}; + points[2] = {0, -10}; + points[3] = {20, 70}; + std::vector outP{8}; + cc::ccVertexLineToPolygon(points, 1, 0, 4, &outP); ExpectEq(IsEqualF(outP[5].x, -0.468942523) && IsEqualF(outP[5].y, -9.82652664), true); // ccVertexLineIntersect logLabel = "test the vertex ccVertexLineIntersect function"; float res; - bool isFind = cc::ccVertexLineIntersect(5, 5, 1, 10, 12, 20, 12, 40, &res); + bool isFind = cc::ccVertexLineIntersect(5, 5, 1, 10, 12, 20, 12, 40, &res); ExpectEq(isFind, true); - } - diff --git a/native/tests/unit-test/src/node_test.cpp b/native/tests/unit-test/src/node_test.cpp new file mode 100644 index 0000000000..8ccd675524 --- /dev/null +++ b/native/tests/unit-test/src/node_test.cpp @@ -0,0 +1,101 @@ +/**************************************************************************** + 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/Director.h" +#include "core/Root.h" +#include "core/platform/event-manager/Events.h" +#include "core/scene-graph/SceneGraphModuleHeader.h" +#include "gtest/gtest.h" +#include "renderer/GFXDeviceManager.h" +#include "renderer/gfx-base/GFXDef.h" +#include "utils.h" + +using namespace cc; +using namespace cc::event; +using namespace cc::gfx; + +namespace { + +class MyCallbackTarget { +public: +}; + +TEST(NodeTest, inverseTransformPoint) { + initCocos(100, 100); + + auto *director = Director::getInstance(); + auto *scene = director->getScene(); + + auto *parentNode = new Node(""); + auto *subNode = new Node(""); + parentNode->setPosition(20.F, -30.F, 100.F); + subNode->setPosition(55, 35, 22); + parentNode->setParent(scene); + subNode->setParent(parentNode); + auto p = Vec3(100.F, 200.F, 0.F); + subNode->inverseTransformPoint(p, p); + + EXPECT_EQ(p, Vec3(25.F, 195.F, -122.F)); + + //xwx FIXME: gfx-validator Assert + destroyCocos(); +} + +TEST(NodeTest, activeInHierarchyChanged) { + // TODO(xwx): need fix Director usage in setActive() + initCocos(100, 100); + static CallbackInfoBase::ID id{0}; + static CallbackInfoBase::ID id1{0}; + static CallbackInfoBase::ID id2{0}; + auto * director = Director::getInstance(); + auto * scene = director->getScene(); + auto * node = new Node(); + auto cb = [](Node *node) { + EXPECT_TRUE(node->isActiveInHierarchy()); + }; + + node->once(NodeEventType::ACTIVE_IN_HIERARCHY_CHANGED, cb, id); + scene->addChild(node); + auto cb1 = [](Node *node) { + EXPECT_FALSE(node->isActiveInHierarchy()); + }; + node->once(NodeEventType::ACTIVE_IN_HIERARCHY_CHANGED, cb1, id1); + node->setActive(false); + node->once(NodeEventType::ACTIVE_IN_HIERARCHY_CHANGED, cb, id); + node->setActive(true); + + auto *node2 = new Node(); + scene->addChild(node2); + node2->setActive(false); + node->once(NodeEventType::ACTIVE_IN_HIERARCHY_CHANGED, cb1, id1); + node2->addChild(node); + + node->once(NodeEventType::ACTIVE_IN_HIERARCHY_CHANGED, cb, id); + node->setParent(scene); + // xwx FIXME: gfx-validator Assert + destroyCocos(); +} +} // namespace +*/ diff --git a/native/tests/unit-test/src/pool_test.cpp b/native/tests/unit-test/src/pool_test.cpp new file mode 100644 index 0000000000..fcc8c57598 --- /dev/null +++ b/native/tests/unit-test/src/pool_test.cpp @@ -0,0 +1,75 @@ +/**************************************************************************** + 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/memop/Pool.h" +#include "gtest/gtest.h" + +#include "utils.h" + +using namespace cc; +using namespace memop; + +namespace { +class PoolTest { +public: + int32_t tag{0}; + explicit PoolTest(int32_t num) : tag(num) {} +}; +int32_t tagValue = 0; + +PoolTest *createTest() { + return new PoolTest(tagValue++); +} + +const int32_t ARRAY_SIZE = 10; +auto * pool = new memop::Pool(createTest, ARRAY_SIZE); + +} // namespace + +TEST(PoolTest, alloc) { + for (int32_t i = 0; i < ARRAY_SIZE + 2; ++i) { + auto *obj = pool->alloc(); + EXPECT_NE(obj, nullptr); + } +} + +TEST(PoolTest, free) { + auto *tmp = createTest(); + pool->free(tmp); + auto *newElement = pool->alloc(); + EXPECT_EQ(newElement, tmp); +} + +TEST(PoolTest, freeArray) { + const int32_t TEST_SIZE = 5; + std::vector tmpArr(TEST_SIZE); + for (int32_t i = 0; i < TEST_SIZE; ++i) { + PoolTest *a = createTest(); + } + pool->freeArray(tmpArr); + for (int32_t i = 0; i < TEST_SIZE; ++i) { + auto *tmpObj = pool->alloc(); + EXPECT_EQ(tmpArr[TEST_SIZE - i - 1], tmpObj); + } +} diff --git a/native/tests/unit-test/src/utils.cpp b/native/tests/unit-test/src/utils.cpp new file mode 100644 index 0000000000..7c41c04db3 --- /dev/null +++ b/native/tests/unit-test/src/utils.cpp @@ -0,0 +1,68 @@ +#include "utils.h" + +#ifdef CC_USE_VULKAN + #undef CC_USE_VULKAN +#endif + +#ifdef CC_USE_METAL + #undef CC_USE_METAL +#endif + +#ifdef CC_USE_GLES3 + #undef CC_USE_GLES3 +#endif + +#ifdef CC_USE_GLES2 + #undef CC_USE_GLES2 +#endif + +/* +#include "core/Director.h" +#include "core/Root.h" +#include "core/scene-graph/SceneGraphModuleHeader.h" +#include "renderer/GFXDeviceManager.h" +#include "renderer/gfx-base/GFXDef.h" + +using namespace cc; +using namespace cc::gfx; + +void initCocos(int width, int height) { + // Initialize Device + BindingMappingInfo bindingMappingInfo; + bindingMappingInfo.bufferOffsets = std::vector{0, pipeline::globalUBOCount + pipeline::localUBOCount, pipeline::globalUBOCount}; + bindingMappingInfo.samplerOffsets = std::vector{-pipeline::globalUBOCount, pipeline::globalSamplerCount + pipeline::localSamplerCount, pipeline::globalSamplerCount - pipeline::localUBOCount}; + bindingMappingInfo.flexibleSet = 1; + + int pixelWidth = width * 2; + int pixelHeight = height * 2; + + DeviceInfo info; + info.windowHandle = 0; + info.width = pixelWidth; + info.height = pixelHeight; + info.pixelRatio = 2; + info.bindingMappingInfo = bindingMappingInfo; + auto *_device = DeviceManager::create(info); + + // Initialize director + auto *_director = new Director(); + _director->init(); + _director->getRoot()->resize(pixelWidth, pixelHeight); + _director->getRoot()->setRenderPipeline(nullptr); + + BuiltinResMgr::getInstance()->initBuiltinRes(_device); + + BuiltinResMgr::getInstance()->tryCompileAllPasses(); + + auto *scene = new Scene("myScene"); + Director::getInstance()->runSceneImmediate(scene, nullptr, nullptr); +} + +void destroyCocos() { + auto *director = Director::getInstance(); + auto *scene = director->getScene(); + CC_SAFE_DELETE(scene); + CC_SAFE_DELETE(director); + DeviceManager::destroy(); +} +*/ diff --git a/native/tests/unit-test/src/utils.h b/native/tests/unit-test/src/utils.h index de56c7fe26..d8e27ae259 100644 --- a/native/tests/unit-test/src/utils.h +++ b/native/tests/unit-test/src/utils.h @@ -22,11 +22,19 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ****************************************************************************/ #pragma once + +#include + #include "cocos/math/Math.h" +#include "gtest/gtest.h" + static std::string logLabel; -static bool IsEqualF(float l, float r) { +static bool IsEqualF(float l, float r) { return cc::math::IsEqualF(l, r); }; static void ExpectEq(bool lf, bool rt) { - EXPECT_EQ(lf, rt) << "ERROR in: " <' + suffix + normalized_name = container_name + '<' + \ + ', '.join( + sections[1:1+stl_type_map[name_for_search]]) + '>' + suffix else: normalized_name = container_name + '<' + ', '.join(sections[1:]) + '>' @@ -185,7 +196,8 @@ def normalize_std_function_by_sections(sections): if sections[0] == 'std_function_args': normalized_name = '(' + ', '.join(sections[1:]) + ')' elif sections[0] == 'std::function' or sections[0] == 'function': - normalized_name = 'std::function<' + sections[1] + ' ' + sections[2] + '>' + normalized_name = 'std::function<' + \ + sections[1] + ' ' + sections[2] + '>' else: assert(False) return normalized_name @@ -195,10 +207,10 @@ def normalize_type_str(s, depth=1): if s.find('std::function') == 0 or s.find('function') == 0: start = s.find('<') assert(start > 0) - sections = [s[:start]] # std::function + sections = [s[:start]] # std::function start += 1 ret_pos = s.find('(', start) - sections.append(s[start:ret_pos].strip()) # return type + sections.append(s[start:ret_pos].strip()) # return type end = s.find(')', ret_pos + 1) sections.append('std_function_args<' + s[ret_pos+1:end].strip() + '>') else: @@ -233,8 +245,9 @@ def normalize_type_str(s, depth=1): normalized_name = normalize_type_name_by_sections(sections) return normalized_name + def capitalize(name): - if len(name) == 0 : + if len(name) == 0: return name return name[0].upper() + name[1:] @@ -253,7 +266,8 @@ class BaseEnumeration(object): def __init__(self, value): if value >= len(self.__class__._kinds): - self.__class__._kinds += [None] * (value - len(self.__class__._kinds) + 1) + self.__class__._kinds += [None] * \ + (value - len(self.__class__._kinds) + 1) if self.__class__._kinds[value] is not None: raise ValueError('{0} value {1} already loaded'.format( str(self.__class__), value)) @@ -261,7 +275,6 @@ class BaseEnumeration(object): self.__class__._kinds[value] = self self.__class__._name_map = None - def from_param(self): return self.value @@ -286,6 +299,7 @@ class BaseEnumeration(object): ### Availability Kinds ### + class AvailabilityKind(BaseEnumeration): """ Describes the availability of an entity. @@ -298,24 +312,27 @@ class AvailabilityKind(BaseEnumeration): def __repr__(self): return 'AvailabilityKind.%s' % (self.name,) + AvailabilityKind.AVAILABLE = AvailabilityKind(0) AvailabilityKind.DEPRECATED = AvailabilityKind(1) AvailabilityKind.NOT_AVAILABLE = AvailabilityKind(2) AvailabilityKind.NOT_ACCESSIBLE = AvailabilityKind(3) + def get_availability(cursor): """ Retrieves the availability of the entity pointed at by the cursor. """ if not hasattr(cursor, '_availability'): - cursor._availability = cindex.conf.lib.clang_getCursorAvailability(cursor) + cursor._availability = cindex.conf.lib.clang_getCursorAvailability( + cursor) return AvailabilityKind.from_id(cursor._availability) def native_name_from_type(ntype, underlying=False): - kind = ntype.kind #get_canonical().kind - const = "" #"const " if ntype.is_const_qualified() else "" + kind = ntype.kind # get_canonical().kind + const = "" # "const " if ntype.is_const_qualified() else "" if not underlying and kind == cindex.TypeKind.ENUM: decl = ntype.get_declaration() return get_namespaced_class_name(decl) @@ -338,13 +355,14 @@ def native_name_from_type(ntype, underlying=False): decl = ntype.get_declaration() etype = ntype.element_type esize = ntype.element_count - logger.info("probably a function const array: " + str(etype.spelling) + "[" + str(esize) + "]") - #return "decltype(" + str(etype.spelling) + " _[" + str(esize) + "])" + logger.info("probably a function const array: " + + str(etype.spelling) + "[" + str(esize) + "]") + # return "decltype(" + str(etype.spelling) + " _[" + str(esize) + "])" return "std::array<%s, %s>" % (etype.spelling, esize) else: name = ntype.get_declaration().spelling #print >> sys.stderr, "Unknown type: " + str(kind) + " " + str(name) - return INVALID_NATIVE_TYPE + " - " + str(kind) + " ? " +str(name) + return INVALID_NATIVE_TYPE + " - " + str(kind) + " ? " + str(name) # pdb.set_trace() @@ -372,6 +390,7 @@ def get_namespaced_class_name(declaration_cursor): return ns + "::" + display_name return display_name + def generate_namespace_list(cursor, namespaces=[]): ''' build the full namespace for a specific cursor @@ -385,6 +404,7 @@ def generate_namespace_list(cursor, namespaces=[]): generate_namespace_list(parent, namespaces) return namespaces + def get_namespace_name(declaration_cursor): ns_list = generate_namespace_list(declaration_cursor, []) ns_list.reverse() @@ -410,8 +430,8 @@ class NativeType(object): self.not_supported = False self.param_types = [] self.ret_type = None - self.namespaced_class_name = "" # with namespace and class name - self.namespace_name = "" # only contains namespace + self.namespaced_class_name = "" # with namespace and class name + self.namespace_name = "" # only contains namespace self.name = "" self.whole_name = None self.is_const = False @@ -421,6 +441,27 @@ class NativeType(object): self.canonical_type = None self.kind = None + def toJSON(self): + return { + "name": self.name, + "script_ns": self.generator.scriptname_from_native(self.namespaced_class_name, self.namespace_name), + "whole_name": self.whole_name, + "namespace_name": self.namespace_name, + "namespaced_class_name": self.namespaced_class_name, + "is_const": self.is_const, + "is_pointer": self.is_pointer, + "is_reference": self.is_reference, + "is_rreference": self.is_rreference, + "is_object": self.is_object, + "is_struct": self.is_struct, + "is_function": self.is_function, + "is_enum": self.is_enum, + "is_numeric": self.is_numeric, + "enum_declare_type": self.enum_declare_type, + "param_types": list(map(lambda x: x.toJSON(), self.param_types)), + "ret_type" : self.ret_type.name if self.ret_type is not None else None + } + @property def is_const_array(self): return self.kind == cindex.TypeKind.CONSTANTARRAY @@ -470,16 +511,18 @@ class NativeType(object): nt = NativeType(generator) decl = ntype.get_declaration() - nt.namespaced_class_name = get_namespaced_class_name(decl).replace('::__ndk1', '') + nt.namespaced_class_name = get_namespaced_class_name( + decl).replace('::__ndk1', '') nt.is_struct = decl.kind == cindex.CursorKind.STRUCT_DECL if decl.kind == cindex.CursorKind.CLASS_DECL \ - and not nt.namespaced_class_name.startswith('std::function') \ - and not nt.namespaced_class_name.startswith('std::string') \ - and not nt.namespaced_class_name.startswith('std::basic_string'): + and not nt.namespaced_class_name.startswith('std::function') \ + and not nt.namespaced_class_name.startswith('std::string') \ + and not nt.namespaced_class_name.startswith('std::basic_string'): nt.is_object = True displayname = decl.displayname.replace('::__ndk1', '') nt.name = normalize_type_str(displayname) - nt.namespaced_class_name = normalize_type_str(nt.namespaced_class_name) + nt.namespaced_class_name = normalize_type_str( + nt.namespaced_class_name) nt.namespace_name = get_namespace_name(decl) nt.whole_name = nt.namespaced_class_name else: @@ -490,7 +533,8 @@ class NativeType(object): nt.namespace_name = get_namespace_name(decl) if len(nt.namespaced_class_name) > 0: - nt.namespaced_class_name = normalize_type_str(nt.namespaced_class_name) + nt.namespaced_class_name = normalize_type_str( + nt.namespaced_class_name) if nt.namespaced_class_name.startswith("std::function"): nt.name = "std::function" @@ -510,7 +554,8 @@ class NativeType(object): if nt.name != INVALID_NATIVE_TYPE and nt.name != "std::string" and nt.name != "std::function": if ntype.kind == cindex.TypeKind.UNEXPOSED or ntype.kind == cindex.TypeKind.TYPEDEF or ntype.kind == cindex.TypeKind.ELABORATED: - ret = NativeType.from_type(ntype.get_canonical(), generator) + ret = NativeType.from_type( + ntype.get_canonical(), generator) if ret.name != "": if decl.kind == cindex.CursorKind.TYPEDEF_DECL: ret.canonical_type = nt @@ -524,23 +569,27 @@ class NativeType(object): if nt.enum_kind in type_map: nt.enum_declare_type = type_map[nt.enum_kind] else: - nt.enum_declare_type = 'int' # FIXME: cjh + nt.enum_declare_type = 'int' # FIXME: cjh # raise TypeError("Can't find (" + str(nt.enum_kind) + ") in type_map") # logger.info("==> enum kind: " + nt.namespaced_class_name + ": " + str(cdecl.enum_type.kind)) if nt.name == "std::function": nt.is_object = False lambda_display_name = get_namespaced_class_name(cdecl) - lambda_display_name = lambda_display_name.replace("::__ndk1", "") - lambda_display_name = normalize_type_str(lambda_display_name) + lambda_display_name = lambda_display_name.replace( + "::__ndk1", "") + lambda_display_name = normalize_type_str( + lambda_display_name) nt.namespaced_class_name = lambda_display_name - r = re.compile('function<([^\s]+).*\((.*)\)>').search(nt.namespaced_class_name) + r = re.compile( + 'function<([^\s]+).*\((.*)\)>').search(nt.namespaced_class_name) (ret_type, params) = r.groups() params = filter(None, params.split(", ")) nt.is_function = True nt.ret_type = NativeType.from_string(ret_type, generator) - nt.param_types = [NativeType.from_string(string, generator) for string in params] + nt.param_types = [NativeType.from_string( + string, generator) for string in params] # mark argument as not supported if nt.name == INVALID_NATIVE_TYPE: @@ -565,7 +614,8 @@ class NativeType(object): @property def lambda_parameters(self): - params = ["%s larg%d" % (str(nt.to_string(self.generator)), i) for i, nt in enumerate(self.param_types)] + params = ["%s larg%d" % (str(nt.to_string(self.generator)), i) + for i, nt in enumerate(self.param_types)] return ", ".join(params) @staticmethod @@ -626,7 +676,7 @@ class NativeType(object): keys = [] if self.is_function: tpl = Template(file=os.path.join(generator.target, "templates", "lambda.c"), - searchList=[convert_opts, self]) + searchList=[convert_opts, self]) indent = convert_opts['level'] * four_space return str(tpl).replace("\n", "\n" + indent) @@ -645,7 +695,7 @@ class NativeType(object): native_types_dict = conversions['native_types'] if NativeType.dict_has_key_re(native_types_dict, [self.namespaced_class_name]): # print "type ---> " + self.namespaced_class_name - return NativeType.dict_get_value_re(native_types_dict, [self.namespaced_class_name]) + return NativeType.dict_get_value_re(native_types_dict, [self.namespaced_class_name]) name = self.namespaced_class_name @@ -681,7 +731,8 @@ class NativeType(object): to_replace = None if 'native_types' in conversions: native_types_dict = conversions['native_types'] - to_replace = NativeType.dict_replace_value_re(native_types_dict, [name]) + to_replace = NativeType.dict_replace_value_re( + native_types_dict, [name]) if to_replace: # print("get_whole_name: " + name + " --> " + to_replace) @@ -690,19 +741,20 @@ class NativeType(object): return name def get_class_name(self, generator): - original_name = self.to_string(generator); + original_name = self.to_string(generator) if original_name.find('>') != -1: return original_name - cls_name = original_name.replace('*', '').replace('const ', '').replace('&', '') + cls_name = original_name.replace( + '*', '').replace('const ', '').replace('&', '') cls_name = cls_name.split("::")[-1] # print("get_class_name: " + original_name + " -> " + cls_name) return cls_name - def object_can_convert(self, generator, is_to_native = True): + def object_can_convert(self, generator, is_to_native=True): if self.is_object: keys = [] - if self.canonical_type != None: + if self.canonical_type != None: keys.append(self.canonical_type.name) keys.append(self.name) if is_to_native: @@ -717,46 +769,64 @@ class NativeType(object): return False def __str__(self): - return self.canonical_type.whole_name if None != self.canonical_type else self.whole_name + return self.canonical_type.whole_name if None != self.canonical_type else self.whole_name + class NativeField(object): - def __init__(self, cursor, generator): + def __init__(self, cursor, native_class, generator): cursor = cursor.canonical self.cursor = cursor self.name = cursor.displayname + new_name = generator.should_rename_function(native_class.class_name, self.name) + self.export_name = new_name if new_name is not None else self.name self.kind = cursor.type.kind + self.is_static = cursor.storage_class.value == 3 and cursor.kind == cindex.CursorKind.VAR_DECL self.location = cursor.location self.is_const_array = self.kind == cindex.TypeKind.CONSTANTARRAY + self.is_static_const = cursor.type.spelling.startswith("const ") and self.is_static member_field_re = re.compile('m_(\w+)') match = member_field_re.match(self.name) self.signature_name = self.name - self.ntype = NativeType.from_type(cursor.type, generator) + self.ntype = NativeType.from_type(cursor.type, generator) if match: self.pretty_name = match.group(1) else: self.pretty_name = self.name + def toJSON(self): + return { + "name": self.export_name, + "pretty_name": self.pretty_name, + "signature_name" : self.signature_name, + "type": self.ntype.toJSON(), + "is_static": self.is_static, + "is_static_const": self.is_static_const, + } + @staticmethod def can_parse(ntype, generator, cursor): native_type = NativeType.from_type(ntype, generator) - if ntype.kind == cindex.TypeKind.UNEXPOSED and native_type.name != "std::string": - logger.error(' %s is ntype.kind %s' % (native_type.name, ntype.kind)) + if ntype.kind == cindex.TypeKind.UNEXPOSED and ntype.get_declaration().type.kind == cindex.TypeKind.UNEXPOSED and native_type.name != "std::string": + logger.error(' %s is ntype.kind %s or %s' % + (native_type.name, ntype.kind, ntype.get_declaration().type.kind)) return False return True - def generate_code(self, current_class = None, generator = None): + def generate_code(self, current_class=None, generator=None): gen = current_class.generator if current_class else generator config = gen.config if 'public_field' in config['definitions']: tpl = Template(config['definitions']['public_field'], - searchList=[current_class, self]) + searchList=[current_class, self]) self.signature_name = str(tpl) - tpl = Template(file=os.path.join(gen.target, "templates", "public_field.c"), + tpl = Template(file=os.path.join(gen.target, "templates", "public_field.c" if not self.is_static else "public_static_field.c"), searchList=[current_class, self]) gen.impl_file.write(unicode(tpl)) # return True if found default argument. + + def iterate_param_node(param_node, depth=1): for node in param_node.get_children(): # logger.info(">"*depth+" "+str(node.kind)) @@ -768,8 +838,9 @@ def iterate_param_node(param_node, depth=1): return False + class NativeFunction(object): - def __init__(self, cursor, generator): + def __init__(self, cursor, current_class, generator): self.cursor = cursor self.func_name = cursor.spelling self.signature_name = self.func_name @@ -784,6 +855,9 @@ class NativeFunction(object): self.ret_type = NativeType.from_type(cursor.result_type, generator) self.comment = self.get_comment(cursor.raw_comment) self.current_class = None + self.should_skip_function = current_class.skip_bind_function({"name":self.func_name}) + self.name = self.func_name + self.export_name = generator.should_rename_function(current_class.class_name, self.name) or self.name # parse the arguments # if self.func_name == "spriteWithFile": @@ -812,6 +886,23 @@ class NativeFunction(object): self.min_args = index if found_default_arg else len(self.arguments) + def toJSON(self): + return { + "name": self.func_name, + "signature_name": self.signature_name, + "arguments": list(map(lambda x : x.toJSON(), self.arguments)), + "argumentTips": self.argumtntTips, + "static": self.static, + "min_args": self.min_args, + # "implementations": self.implementations, + "is_overloaded": self.is_overloaded, + "is_constructor": self.is_constructor, + "not_supported": self.not_supported, + "ret_type": self.ret_type.toJSON(), + "comment": self.comment, + "current_class_name": self.current_class.class_name if self.current_class is not None else None + } + def get_comment(self, comment): replaceStr = comment @@ -819,26 +910,25 @@ class NativeFunction(object): return "" regular_replace_list = [ - ("(\s)*//!",""), - ("(\s)*//",""), - ("(\s)*/\*\*",""), - ("(\s)*/\*",""), - ("\*/",""), + ("(\s)*//!", ""), + ("(\s)*//", ""), + ("(\s)*/\*\*", ""), + ("(\s)*/\*", ""), + ("\*/", ""), ("\r\n", "\n"), ("\n(\s)*\*", "\n"), - ("\n(\s)*@","\n"), - ("\n(\s)*","\n"), + ("\n(\s)*@", "\n"), + ("\n(\s)*", "\n"), ("\n(\s)*\n", "\n"), - ("^(\s)*\n",""), + ("^(\s)*\n", ""), ("\n(\s)*$", ""), - ("\n","
\n"), + ("\n", "
\n"), ("\n", "\n-- ") ] for item in regular_replace_list: replaceStr = re.sub(item[0], item[1], replaceStr) - return replaceStr def generate_code(self, current_class=None, generator=None, is_override=False, is_ctor=False): @@ -849,41 +939,41 @@ class NativeFunction(object): # logger.info("NativeFunction: " + current_class.namespaced_class_name + ':' + self.func_name + ", is_constructor:" + str(self.is_constructor) + ", is_ctor:" + str(self.is_ctor)) if not is_ctor: tpl = Template(file=os.path.join(gen.target, "templates", "function.h"), - searchList=[current_class, self]) + searchList=[current_class, self]) if not is_override: gen.head_file.write(unicode(tpl)) if self.static: if 'sfunction' in config['definitions']: tpl = Template(config['definitions']['sfunction'], - searchList=[current_class, self]) + searchList=[current_class, self]) self.signature_name = str(tpl) tpl = Template(file=os.path.join(gen.target, "templates", "sfunction.c"), - searchList=[current_class, self]) + searchList=[current_class, self]) else: if not self.is_constructor: if 'ifunction' in config['definitions']: tpl = Template(config['definitions']['ifunction'], - searchList=[current_class, self]) + searchList=[current_class, self]) self.signature_name = str(tpl) else: if 'constructor' in config['definitions']: if not is_ctor: tpl = Template(config['definitions']['constructor'], - searchList=[current_class, self]) + searchList=[current_class, self]) else: tpl = Template(config['definitions']['ctor'], - searchList=[current_class, self]) + searchList=[current_class, self]) self.signature_name = str(tpl) - if self.is_constructor and gen.script_type == "spidermonkey" : + if self.is_constructor and gen.script_type == "spidermonkey": if not is_ctor: tpl = Template(file=os.path.join(gen.target, "templates", "constructor.c"), - searchList=[current_class, self]) + searchList=[current_class, self]) else: tpl = Template(file=os.path.join(gen.target, "templates", "ctor.c"), - searchList=[current_class, self]) - else : + searchList=[current_class, self]) + else: tpl = Template(file=os.path.join(gen.target, "templates", "ifunction.c"), - searchList=[current_class, self]) + searchList=[current_class, self]) if not is_override: gen.impl_file.write(unicode(tpl)) @@ -892,7 +982,11 @@ class NativeOverloadedFunction(object): def __init__(self, func_array): self.implementations = func_array self.func_name = func_array[0].func_name - self.signature_name = self.func_name + self.signature_name = func_array[0].signature_name + self.name = func_array[0].name + self.export_name = func_array[0].export_name + self.ret_type = func_array[0].ret_type + self.should_skip_function = func_array[0].should_skip_function self.min_args = 100 self.is_constructor = False self.is_overloaded = True @@ -903,6 +997,18 @@ class NativeOverloadedFunction(object): self.comment = self.get_comment(func_array[0].cursor.raw_comment) + def toJSON(self): + return { + "name": self.func_name, + "signature_name": self.signature_name, + "min_args": self.min_args, + "comment": self.comment, + "is_ctor": self.is_ctor, + "ret_type": self.ret_type.toJSON(), + "current_class_name": self.current_class.class_name if self.current_class is not None else None, + "implementations": list(map(lambda x: x.toJSON(), self.implementations)), + } + def get_comment(self, comment): replaceStr = comment @@ -910,19 +1016,19 @@ class NativeOverloadedFunction(object): return "" regular_replace_list = [ - ("(\s)*//!",""), - ("(\s)*//",""), - ("(\s)*/\*\*",""), - ("(\s)*/\*",""), - ("\*/",""), + ("(\s)*//!", ""), + ("(\s)*//", ""), + ("(\s)*/\*\*", ""), + ("(\s)*/\*", ""), + ("\*/", ""), ("\r\n", "\n"), ("\n(\s)*\*", "\n"), - ("\n(\s)*@","\n"), - ("\n(\s)*","\n"), + ("\n(\s)*@", "\n"), + ("\n(\s)*", "\n"), ("\n(\s)*\n", "\n"), - ("^(\s)*\n",""), + ("^(\s)*\n", ""), ("\n(\s)*$", ""), - ("\n","
\n"), + ("\n", "
\n"), ("\n", "\n-- ") ] @@ -945,58 +1051,59 @@ class NativeOverloadedFunction(object): if not is_ctor: tpl = Template(file=os.path.join(gen.target, "templates", "function.h"), - searchList=[current_class, self]) + searchList=[current_class, self]) if not is_override: gen.head_file.write(unicode(tpl)) if static: if 'sfunction' in config['definitions']: tpl = Template(config['definitions']['sfunction'], - searchList=[current_class, self]) + searchList=[current_class, self]) self.signature_name = str(tpl) tpl = Template(file=os.path.join(gen.target, "templates", "sfunction_overloaded.c"), - searchList=[current_class, self]) + searchList=[current_class, self]) else: if not self.is_constructor: if 'ifunction' in config['definitions']: tpl = Template(config['definitions']['ifunction'], - searchList=[current_class, self]) + searchList=[current_class, self]) self.signature_name = str(tpl) else: if 'constructor' in config['definitions']: if not is_ctor: tpl = Template(config['definitions']['constructor'], - searchList=[current_class, self]) + searchList=[current_class, self]) else: tpl = Template(config['definitions']['ctor'], - searchList=[current_class, self]) + searchList=[current_class, self]) self.signature_name = str(tpl) - if self.is_constructor and gen.script_type == "spidermonkey" : + if self.is_constructor and gen.script_type == "spidermonkey": if not is_ctor: tpl = Template(file=os.path.join(gen.target, "templates", "constructor_overloaded.c"), - searchList=[current_class, self]) + searchList=[current_class, self]) else: tpl = Template(file=os.path.join(gen.target, "templates", "ctor_overloaded.c"), - searchList=[current_class, self]) - else : + searchList=[current_class, self]) + else: tpl = Template(file=os.path.join(gen.target, "templates", "ifunction_overloaded.c"), - searchList=[current_class, self]) + searchList=[current_class, self]) if not is_override: gen.impl_file.write(unicode(tpl)) class NativeClass(object): - def __init__(self, cursor, generator, is_struct = False): + def __init__(self, cursor, generator, is_struct=False): # the cursor to the implementation self.cursor = cursor self.class_name = cursor.displayname - self.is_ref_class = self.class_name == "Ref" + self.is_ref_class = self.class_name == "RefCount" self.rename_destructor = generator.rename_destructor(self.class_name) self.parents = [] self.fields = [] self.public_fields = [] self.methods = {} self.static_methods = {} - self.dict_of_override_method_should_be_bound = {} # Key: function name, Value: list of NativeFunction + # Key: function name, Value: list of NativeFunction + self.dict_of_override_method_should_be_bound = {} self.generator = generator self.is_const_array = cursor.kind == cindex.TypeKind.CONSTANTARRAY self.is_abstract = self.class_name in generator.abstract_classes @@ -1006,41 +1113,78 @@ class NativeClass(object): self._current_visibility = cindex.AccessSpecifier.PRIVATE if is_struct: self._current_visibility = cindex.AccessSpecifier.PUBLIC - #for generate lua api doc + # for generate lua api doc self.override_methods = {} - self.has_constructor = False - self.namespace_name = "" + self.has_constructor = False + self.namespace_name = "" self.is_struct = is_struct self.getter_setter = [] self.getter_list = [] self.setter_list = [] + self.nested_classes = [] - registration_name = generator.get_class_or_rename_class(self.class_name) + registration_name = generator.get_class_or_rename_class( + self.class_name) if generator.remove_prefix: - self.target_class_name = re.sub('^' + generator.remove_prefix, '', registration_name) + self.target_class_name = re.sub( + '^' + generator.remove_prefix, '', registration_name) else: self.target_class_name = registration_name self.namespaced_class_name = get_namespaced_class_name(cursor) - self.namespace_name = get_namespace_name(cursor) + self.namespace_name = get_namespace_name(cursor) self.parse() + # signature_name # post parse - if self.class_name in generator.getter_setter : + + def get_func_name(func): + if isinstance(func, NativeOverloadedFunction): + return func.implementations[0].func_name + else: + return func.func_name + + if self.class_name in generator.getter_setter: for field_name in iter(generator.getter_setter[self.class_name].keys()): field = generator.getter_setter[self.class_name][field_name] + name_array ='{' +", ".join(list(map(lambda x: "\"%s\"" % x, field["names"]))) +'}' + setter = self.find_method(field["setter"]) + getter = self.find_method(field["getter"]) item = { - "name" : field_name, - "getter" : self.find_method(field["getter"]), - "setter" : self.find_method(field["setter"]), + "name": '"'+field_name+'"' if len(field["names"]) == 1 else name_array, + "field_name": field_name, + "names": field["names"], + "getter": getter, + "setter": setter, } - if item["getter"] is None and item["setter"] is None: - #logger.info("gettter %s, setter %s" % (field["getter"], field["setter"])) - raise Exception("getter_setter for %s.%s both None" %(self.class_name, field_name)) - if item["getter"] is not None: - self.getter_list.append(item["getter"].func_name) - if item["setter"] is not None: - self.setter_list.append(item["setter"].func_name) + if getter is None and setter is None: + logger.info("gettter %s, setter %s" % (field["getter"], field["setter"])) + raise Exception("getter_setter for %s.%s both None" % ( + self.class_name, field_name)) + if getter is not None: + self.getter_list.append(get_func_name(getter)) + if isinstance(getter, NativeOverloadedFunction): + old = getter + # logger.error(" old getter %s" % old.__dict__) + # logger.error(" getter_list %s\n setter_list: %s", self.getter_list, self.setter_list) + item["getter"] = getter.implementations[0] + item["getter"].signature_name = "js_%s_%s_%s" % (self.generator.prefix, self.class_name, old.func_name) + if setter is not None: + self.setter_list.append(get_func_name(setter)) self.getter_setter.append(item) + @property + def nested_class_name(self): + classes = list(self.nested_classes) + classes.append(self.class_name) + return "_".join(classes) + + @property + def nested_class_array(self): + classes = list(self.nested_classes) + classes.append(self.target_class_name) + if len(classes) == 1: + return "\"%s\""%(self.target_class_name) + return "{" + ",".join(list(map(lambda x: "\"%s\"" % x, classes))) + "}" + @property def is_skip_constructor(self): @@ -1050,29 +1194,30 @@ class NativeClass(object): def underlined_class_name(self): return self.namespaced_class_name.replace("::", "_") - - def skip_bind_function(self, method_name): - if self.generator.is_reserved_function(self.class_name, method_name["name"]): + def skip_bind_function(self, method): + if self.class_name in self.generator.shadowed_methods_by_getter_setter: + ret = method["name"] in self.generator.shadowed_methods_by_getter_setter[self.class_name] + # logger.info("??? skip %s contains %s , %s" %(self.generator.shadowed_methods_by_getter_setter[self.class_name], method, ret)) + return ret + if self.generator.is_reserved_function(self.class_name, method["name"]): + # logger.info("??? %s is reserved for getter/setter " % (method_name)) return False - if self.class_name in self.generator.shadowed_methods_by_getter_setter : - #logger.info("??? skip %s contains %s" %(self.generator.shadowed_methods_by_getter_setter[self.class_name], method_name)) - return method_name["name"] in self.generator.shadowed_methods_by_getter_setter[self.class_name] return False def find_method(self, method_name): - for m in self.methods : - if self.methods[m].signature_name == method_name : + for m in self.methods: + if self.methods[m].signature_name == method_name: return self.methods[m] return None - def is_getter_method(self, method_name): + def is_getter_attribute(self, method_name): return method_name in self.getter_list - def is_setter_method(self, method_name): + def is_setter_attribute(self, method_name): return method_name in self.setter_list def is_getter_or_setter(self, method_name): - return self.is_getter_method(method_name) or self.is_setter_method(method_name) + return self.is_getter_attribute(method_name) or self.is_setter_attribute(method_name) def parse(self): ''' @@ -1093,7 +1238,7 @@ class NativeClass(object): if self.generator.should_skip(self.class_name, name): should_skip = True if not should_skip: - ret.append({"name": self.generator.should_rename_function(self.class_name, name) or name, "impl": impl}) + ret.append({"name": impl.name, "impl": impl, "export_name": impl.export_name}) return sorted(ret, key=lambda fn: fn["name"]) def static_methods_clean(self): @@ -1102,10 +1247,10 @@ class NativeClass(object): ''' ret = [] for name, impl in iter(self.static_methods.items()): - should_skip = self.generator.should_skip(self.class_name, name) + should_skip = self.generator.should_skip(self.class_name, impl.name) if not should_skip: - ret.append({"name": name, "impl": impl}) - return ret + ret.append({"name": impl.export_name, "impl": impl}) + return sorted(ret, key=lambda fn: fn["name"]) def override_methods_clean(self): ''' @@ -1116,26 +1261,57 @@ class NativeClass(object): should_skip = self.generator.should_skip(self.class_name, name) if not should_skip: ret.append({"name": name, "impl": impl}) - return ret + return sorted(ret, key=lambda fn: fn["name"]) + + def toJSON(self): + return { + "namespace_name" : self.namespace_name, + "script_ns": self.generator.scriptname_from_native(self.namespaced_class_name, self.namespace_name), + "parents": list(map(lambda x: x.namespaced_class_name, self.parents)), + "nested_classes": self.nested_classes, + "class_name" : self.class_name, + "is_ref_class" : self.is_ref_class, + "namespaced_class_name": self.namespaced_class_name, + "underlined_class_name": self.underlined_class_name, + "is_struct": self.is_struct, + "is_abstract": self.is_abstract, + "is_persistent" : self.is_persistent, + "is_class_owned_by_cpp": self.is_class_owned_by_cpp, + "has_constructor": self.has_constructor, + "public_fields": list(map(lambda x: x.toJSON(), filter(lambda x: self.should_export_field(x.name), self.public_fields))), + # "fields" : list(map(lambda x: x.toJSON(), self.fields)), + "override_methods": dict(map(lambda kv: (kv[0], kv[1].toJSON()), self.override_methods.items())), + "getter_setter": list(map(lambda x: { + "name": x["field_name"], + "names": x["names"], + "type": x["getter"].ret_type.toJSON() if x["getter"] is not None else (x["setter"].arguments[0].toJSON() if x["setter"] is not None else None) + }, self.getter_setter)), + "methods": dict(map(lambda kv: (kv[0], kv[1].toJSON()), filter(lambda f: not f[1].should_skip_function, self.methods.items()))), + "static_methods": dict(map(lambda kv: (kv[0], kv[1].toJSON()), filter(lambda x: not self.generator.should_skip(self.class_name, x[0]), self.static_methods.items()))), + "dict_of_override_method_should_be_bound": dict(map(lambda kv: (kv[0], list(map(lambda x: x.toJSON(), kv[1]))), self.dict_of_override_method_should_be_bound.items())), + } def generate_code(self): ''' actually generate the code. it uses the current target templates/rules in order to generate the right code ''' - + if not self.is_ref_class: self.is_ref_class = self._is_ref_class() config = self.generator.config prelude_h = Template(file=os.path.join(self.generator.target, "templates", "prelude.h"), - searchList=[{"current_class": self}]) + searchList=[{"current_class": self}]) prelude_c = Template(file=os.path.join(self.generator.target, "templates", "prelude.c"), - searchList=[{"current_class": self}]) - + searchList=[{"current_class": self}]) + regtype_h = Template(file=os.path.join(self.generator.target, "templates", "reg_types.h"), + searchList=[{"current_class": self}]) self.generator.head_file.write(unicode(prelude_h)) self.generator.impl_file.write(unicode(prelude_c)) + self.generator.regi_file_lines.append(unicode(regtype_h)) + for m in self.methods_clean(): m['impl'].generate_code(self) for m in self.static_methods_clean(): @@ -1147,25 +1323,28 @@ class NativeClass(object): register = Template(file=os.path.join(self.generator.target, "templates", "register.c"), searchList=[{"current_class": self}]) self.generator.impl_file.write(unicode(register)) + self.generator.class_json_list.append(self.toJSON()) def should_export_field(self, field_name): return (self.is_struct and not self.generator.should_skip_field(self.class_name, field_name)) or self.generator.should_bind_field(self.class_name, field_name) def generate_struct_constructor(self): - stream = open(os.path.join(self.generator.target, "conversions.yaml"), "r") + stream = open(os.path.join( + self.generator.target, "conversions.yaml"), "r") config = yaml.load(stream) tpl = Template(config['definitions']['constructor'], - searchList=[self]) + searchList=[self]) self.struct_constructor_name = str(tpl) tpl = Template(file=os.path.join(self.generator.target, "templates", "struct_constructor.c"), - searchList=[self]) + searchList=[self]) self.generator.impl_file.write(unicode(tpl)) - def _deep_iterate(self, cursor=None, depth=0): + def _deep_iterate(self, cursor=None, depth=0, nested_classes = []): + # self.nested_classes = list(nested_classes) for node in cursor.get_children(): - # logger.info("%s%s - %s" % ("> " * depth, node.displayname, node.kind)) - if self._process_node(node): - self._deep_iterate(node, depth + 1) + # logger.info("_deep_iterate %s%s - %s" % ("> " * depth, node.displayname, node.kind)) + if self._process_node(node, depth, nested_classes): + self._deep_iterate(node, depth + 1, nested_classes) @staticmethod def _is_method_in_parents(current_class, method_name): @@ -1192,13 +1371,14 @@ class NativeClass(object): for om in self.dict_of_override_method_should_be_bound[om_name]: previous_m.append(om) else: - self.methods[om_name] = NativeOverloadedFunction([previous_m]) + self.methods[om_name] = NativeOverloadedFunction([ + previous_m]) for om in self.dict_of_override_method_should_be_bound[om_name]: self.methods[om_name].append(om) del self.dict_of_override_method_should_be_bound[om_name] return - def _is_ref_class(self, depth = 0): + def _is_ref_class(self, depth=0): """ Mark the class as 'cc::Ref' or its subclass. """ @@ -1212,21 +1392,44 @@ class NativeClass(object): return True return False + + def _contains_same_method(self, methods, curr): + for method in methods: + if len(curr.arguments) == len(method.arguments): + if len(curr.arguments) == 0: + return True + sameArguments = True + for i in range(len(curr.arguments)): + if curr.arguments[i].name != method.arguments[i].name: + sameArguments = False + if sameArguments: + return True + return False - def _process_node(self, cursor): + def _previous_method_already_contains(self, previous_m, curr): + if isinstance(previous_m, NativeOverloadedFunction): + return self._contains_same_method(previous_m.implementations, curr) + else: + return self._contains_same_method([previous_m], curr) + + def _process_node(self, cursor, depth= 0, nested_classes = []): ''' process the node, depending on the type. If returns true, then it will perform a deep iteration on its children. Otherwise it will continue with its siblings (if any) @param: cursor the cursor to analyze ''' + + # if nested_classes is None: + # logger.error("process class %s found %s nested classes" % (cursor.displayname, len(nested_classes))) + if cursor.kind == cindex.CursorKind.CXX_BASE_SPECIFIER: parent = cursor.get_definition() parent_name = parent.displayname if not self.class_name in self.generator.classes_have_no_parents: if parent_name and parent_name not in self.generator.base_classes_to_skip: - #if parent and self.generator.in_listed_classes(parent.displayname): + # if parent and self.generator.in_listed_classes(parent.displayname): if parent.displayname not in self.generator.generated_classes: parent = NativeClass(parent, self.generator) self.generator.generated_classes[parent.class_name] = parent @@ -1235,19 +1438,18 @@ class NativeClass(object): self.parents.append(parent) - if parent_name == "Ref": + if parent_name == "RefCount": self.is_ref_class = True - - elif cursor.kind == cindex.CursorKind.FIELD_DECL: - self.fields.append(NativeField(cursor, self.generator)) + elif cursor.kind == cindex.CursorKind.FIELD_DECL or cursor.kind == cindex.CursorKind.VAR_DECL: + self.fields.append(NativeField(cursor, self, self.generator)) if (self.is_struct or self._current_visibility == cindex.AccessSpecifier.PUBLIC) and NativeField.can_parse(cursor.type, self.generator, cursor) and not self.generator.should_skip_public_field(self.class_name, cursor.displayname): - self.public_fields.append(NativeField(cursor, self.generator)) + self.public_fields.append(NativeField(cursor, self, self.generator)) elif cursor.kind == cindex.CursorKind.CXX_ACCESS_SPEC_DECL: self._current_visibility = cursor.access_specifier elif cursor.kind == cindex.CursorKind.CXX_METHOD and get_availability(cursor) != AvailabilityKind.DEPRECATED: # skip if variadic if self._current_visibility == cindex.AccessSpecifier.PUBLIC and not cursor.type.is_function_variadic(): - m = NativeFunction(cursor, self.generator) + m = NativeFunction(cursor, self, self.generator) registration_name = m.func_name # bail if the function is not supported (at least one arg not supported) if m.not_supported: @@ -1266,16 +1468,20 @@ class NativeClass(object): if isinstance(previous_m, NativeOverloadedFunction): previous_m.append(m) else: - self.static_methods[registration_name] = NativeOverloadedFunction([m, previous_m]) + self.static_methods[registration_name] = NativeOverloadedFunction([ + m, previous_m]) else: if registration_name not in self.methods: self.methods[registration_name] = m else: previous_m = self.methods[registration_name] - if isinstance(previous_m, NativeOverloadedFunction): - previous_m.append(m) - else: - self.methods[registration_name] = NativeOverloadedFunction([m, previous_m]) + + if not self._previous_method_already_contains(previous_m, m): + if isinstance(previous_m, NativeOverloadedFunction): + previous_m.append(m) + else: + self.methods[registration_name] = NativeOverloadedFunction([ + m, previous_m]) self._handle_override_method_with_same_name_as_instance_method() @@ -1287,7 +1493,7 @@ class NativeClass(object): # logger.debug("Skip copy constructor: " + cursor.displayname) return True - m = NativeFunction(cursor, self.generator) + m = NativeFunction(cursor, self, self.generator) m.is_constructor = True self.has_constructor = True if 'constructor' not in self.methods: @@ -1301,8 +1507,13 @@ class NativeClass(object): m.is_constructor = True self.methods['constructor'] = m return True - # else: - # logger.error("unknown cursor: %s - %s" % (cursor.kind, cursor.displayname)) + elif cursor.kind == cindex.CursorKind.CLASS_DECL or cursor.kind == cindex.CursorKind.STRUCT_DECL: + # logging.error("find class %s in %s , nested_classes %s" % (cursor.displayname, self.class_name, nested_classes)) + nn = list(nested_classes) + nn.append(self.class_name) + self.generator._deep_iterate(cursor, depth + 1, nn) + # else: + # logger.error("unknown cursor: %s - %s" % (cursor.kind, cursor.displayname)) return False @@ -1319,34 +1530,35 @@ class NativeEnum(object): self.static_methods = {} self.generator = generator self._current_visibility = cindex.AccessSpecifier.PRIVATE - #for generate lua api doc + # for generate lua api doc - registration_name = generator.get_class_or_rename_class(self.class_name) + registration_name = generator.get_class_or_rename_class( + self.class_name) if generator.remove_prefix: - self.target_class_name = re.sub('^' + generator.remove_prefix, '', registration_name) + self.target_class_name = re.sub( + '^' + generator.remove_prefix, '', registration_name) else: self.target_class_name = registration_name self.namespaced_class_name = get_namespaced_class_name(cursor) - self.namespace_name = get_namespace_name(cursor) + self.namespace_name = get_namespace_name(cursor) self.parse() def parse(self): self._deep_iterate(self.cursor, 0) - def _deep_iterate(self, cursor=None, depth=0): + def _deep_iterate(self, cursor=None, depth=0, nested_classes = []): for node in cursor.get_children(): #logger.info("%s%s - %s" % ("> " * depth, node.displayname, node.kind)) - if self._process_node(node): - self._deep_iterate(node, depth + 1) + if self._process_node(node, nested_classes): + self._deep_iterate(node, depth + 1, list(nested_classes)) - def _process_node(self, node): + def _process_node(self, node, nested_classes = []): if node.kind == cindex.CursorKind.ENUM_CONSTANT_DECL: field = {} field["name"] = node.displayname field["value"] = node.enum_value self.fields.append(field) - def generate_code(self): ''' actually generate the code. it uses the current target templates/rules in order to @@ -1357,20 +1569,24 @@ class NativeEnum(object): searchList=[{"current_class": self, "generator": self.generator}]) self.generator.impl_file.write(unicode(register)) + class Generator(object): def __init__(self, opts): self.index = cindex.Index.create() self.outdir = opts['outdir'] self.search_path = opts['search_path'] self.prefix = opts['prefix'] - self.headers = opts['headers'].split(' ') + self.headers = opts['headers'] self.classes = opts['classes'] self.classes_need_extend = opts['classes_need_extend'] - self.classes_have_no_parents = opts['classes_have_no_parents'].split(' ') + self.classes_have_no_parents = opts['classes_have_no_parents'].split( + ' ') self.base_classes_to_skip = opts['base_classes_to_skip'].split(' ') self.abstract_classes = opts['abstract_classes'].split(' ') - self.persistent_classes = opts['persistent_classes'].split(' ') if opts['persistent_classes'] != None else [] - self.classes_owned_by_cpp = opts['classes_owned_by_cpp'].split(' ') if opts['classes_owned_by_cpp'] != None else [] + self.persistent_classes = opts['persistent_classes'].split( + ' ') if opts['persistent_classes'] != None else [] + self.classes_owned_by_cpp = opts['classes_owned_by_cpp'].split( + ' ') if opts['classes_owned_by_cpp'] != None else [] self.clang_args = opts['clang_args'] self.target = opts['target'] self.remove_prefix = opts['remove_prefix'] @@ -1378,6 +1594,7 @@ class Generator(object): self.cpp_ns = opts['cpp_ns'] self.impl_file = None self.head_file = None + self.json_file = None self.skip_classes = {} self.skip_public_fields_classes = {} self.bind_fields = {} @@ -1389,8 +1606,8 @@ class Generator(object): self.out_file = opts['out_file'] self.script_type = opts['script_type'] self.macro_judgement = opts['macro_judgement'] - self._hpp_headers = opts['hpp_headers'] - self.cpp_headers = opts['cpp_headers'] + self._hpp_headers = filter(lambda x: len(x) > 0, opts['hpp_headers']) if opts['hpp_headers'] is not None else None + self.cpp_headers = filter(lambda x: len(x) > 0, opts['cpp_headers']) if opts['cpp_headers'] is not None else None self.win32_clang_flags = opts['win32_clang_flags'] self.getter_setter = {} self.shadowed_methods_by_getter_setter = {} @@ -1401,20 +1618,24 @@ class Generator(object): self.hpp_headers = [] if self._hpp_headers is not None: self.hpp_headers += self._hpp_headers - cocos_root = os.path.normpath(os.path.join(os.path.dirname(__file__),"../..")) + cocos_root = os.path.normpath( + os.path.join(os.path.dirname(__file__), "../..")) for header in self.headers: reldir = os.path.relpath(header, cocos_root) self.hpp_headers.append(reldir.replace(os.sep, '/')) for clang_arg in self.clang_args: - if not os.path.exists(clang_arg.replace("-I","")): - find_ret = re.search(r"lib(\d+)?/clang/\d+(\.\d+)*/include", clang_arg) + if not os.path.exists(clang_arg.replace("-I", "")): + find_ret = re.search( + r"lib(\d+)?/clang/\d+(\.\d+)*/include", clang_arg) if None != find_ret: - clang_versions = os.path.abspath(os.path.join(clang_arg,"../..")) + clang_versions = os.path.abspath( + os.path.join(clang_arg, "../..")) clang_folders = os.listdir(clang_versions) if 0 != len(clang_folders): - #simply pickup first installed clang version - clang_arg = os.path.join(clang_versions, clang_folders[0], "include") + # simply pickup first installed clang version + clang_arg = os.path.join( + clang_versions, clang_folders[0], "include") extend_clang_args.append("-I"+clang_arg) #logger.info(" => append %s"%clang_arg) @@ -1461,11 +1682,13 @@ class Generator(object): self.obtain_return_value[class_name] = [] match = re.match("\[([^]]+)\]", fields) if match: - self.obtain_return_value[class_name] = match.group(1).split(" ") + self.obtain_return_value[class_name] = match.group( + 1).split(" ") else: raise Exception("invalid list of bind obtain_return_value") if opts['rename_functions']: - list_of_function_renames = re.split(",\n?", opts['rename_functions']) + list_of_function_renames = re.split( + ",\n?", opts['rename_functions']) for rename in list_of_function_renames: class_name, methods = rename.split("::") self.rename_functions[class_name] = {} @@ -1482,7 +1705,8 @@ class Generator(object): list_of_class_renames = re.split(",\n?", opts['rename_classes']) for rename in list_of_class_renames: class_name, renamed_class_name = rename.split("::") - self.rename_classes[class_name.strip()] = renamed_class_name.strip() + self.rename_classes[class_name.strip( + )] = renamed_class_name.strip() if opts['replace_headers']: list_of_replace_headers = re.split(",\n?", opts['replace_headers']) @@ -1490,40 +1714,48 @@ class Generator(object): header, replaced_header = replace.split("::") self.replace_headers[header] = replaced_header - if "getter_setter" in opts : + if "getter_setter" in opts: #logger.info(" getter_setter : %s" % opts["getter_setter"]) list_of_getter_setter = re.split(",\n?", opts['getter_setter']) + + def list_get_or(arr, idx, defaultValue): + if idx >= len(arr) or arr[idx] is None or len(arr[idx]) == 0: + return defaultValue + return arr[idx] + for line in list_of_getter_setter: #logger.info(" line %s" % line) if len(line) == 0: continue - gs_kls, gs_fields_txt = line.split("::") - gs_obj = self.getter_setter[gs_kls] = {} - gs_sd = self.shadowed_methods_by_getter_setter[gs_kls] = [] - match = re.match("\[([^]]+)\]",gs_fields_txt) + getter_setter_class_name, getter_setter_fields_raw = line.split("::") + getter_setter_map = self.getter_setter[getter_setter_class_name] = {} + shadow_methods = self.shadowed_methods_by_getter_setter[getter_setter_class_name] = [] + match = re.match("\[([^]]+)\]", getter_setter_fields_raw) if match: - list_of_fields = match.group(1).split(" ") - for field in list_of_fields: - field_component = field.split("/") - cap = capitalize(field) - default_getter = "get" + cap - default_setter = "set" + cap - if len(field_component) == 1: - #getter = field - gs_obj[field] = {"getter": default_getter , "setter": default_setter} - gs_sd.extend([field, default_getter, default_setter]) - elif len(field_component) == 2: - field = field_component[0] - gs_obj[field] = {"getter": field_component[1], "setter": default_setter} - gs_sd.extend([field, field_component[1], default_setter]) - elif len(field_component) == 3: - field = field_component[0] - getter = field_component[1] if len(field_component[1]) > 0 else default_getter - setter = field_component[2] if len(field_component[2]) > 0 else default_setter - gs_obj[field] = {"getter": getter, "setter": setter} - gs_sd.extend([field, getter, setter]) - else: - raise Exception("getter_setter parse %s:%s failed" %(gs_kls, field)) + list_of_fields = list(filter(lambda x: len(x.strip()) > 0, match.group(1).split(" "))) + for segment in list_of_fields: + field_components = segment.split("/") + name_variants = field_components[0].split(":") + shadow_getter_setter = len(name_variants[0].split("?")) == 1 + field_name = name_variants[0].split("?")[0] + cap_field_name = capitalize(field_name) + + if len(field_components) > 3: + raise Exception("getter_setter parse %s:%s failed" % (getter_setter_class_name, field_name)) + + getter_raw = list_get_or(field_components, 1, "get" + cap_field_name).split("?") + setter_raw = list_get_or(field_components, 2, "set" + cap_field_name).split("?") + getter_setter_map[field_name] = { + "getter": getter_raw[0], + "setter": setter_raw[0], + "names": name_variants, + } + shadow_methods.append(field_name) + shadow_methods.extend(name_variants) + if len(getter_raw) == 1 and shadow_getter_setter: + shadow_methods.append(getter_raw[0]) + if len(setter_raw) == 1 and shadow_getter_setter: + shadow_methods.append(setter_raw[0]) def is_reserved_function(self, class_name, method_name): if class_name in self.rename_functions: @@ -1559,6 +1791,13 @@ class Generator(object): return False def should_skip(self, class_name, method_name, verbose=False): + result = self.should_skip_impl(class_name, method_name, verbose) + if verbose: + logger.info(" should_skip %s in %s ->\t %s" % + (method_name, class_name, result)) + return result + + def should_skip_impl(self, class_name, method_name, verbose=False): if method_name is not None and (method_name.startswith("operator") or method_name.find("=") != -1): return True if class_name == "*" and "*" in self.skip_classes: @@ -1572,13 +1811,15 @@ class Generator(object): logger.info("%s in skip_classes" % (class_name)) if len(self.skip_classes[key]) == 1 and self.skip_classes[key][0] == "*": if verbose: - logger.info("%s will be skipped completely" % (class_name)) + logger.info( + "%s will be skipped completely" % (class_name)) return True if method_name != None: for func in self.skip_classes[key]: if re.match(func, method_name): if verbose: - logger.info("%s will skip method %s" % (class_name, method_name)) + logger.info("%s will skip method %s" % + (class_name, method_name)) return True if verbose: logger.info("(%s:%s) will be accepted" % (class_name, method_name)) @@ -1621,16 +1862,18 @@ class Generator(object): for key in iter(self.bind_fields.keys()): if key == "*" or re.match("^" + key + "$", class_name): if verbose: - logger.info( "%s in bind_fields" % (class_name)) + logger.info("%s in bind_fields" % (class_name)) if len(self.bind_fields[key]) == 1 and self.bind_fields[key][0] == "*": if verbose: - logger.info( "All public fields of %s will be bound" % (class_name)) + logger.info( + "All public fields of %s will be bound" % (class_name)) return True if field_name != None: for field in self.bind_fields[key]: if re.match(field, field_name): if verbose: - logger.info( "Field %s of %s will be bound" % (field_name, class_name)) + logger.info("Field %s of %s will be bound" % ( + field_name, class_name)) return True return False @@ -1674,7 +1917,7 @@ class Generator(object): sorted classes in order of inheritance ''' sorted_list = [] - for class_name in iter(self.generated_classes.keys()): + for class_name in iter(sorted(self.generated_classes.keys())): nclass = self.generated_classes[class_name] sorted_list += self._sorted_parents(nclass) # remove dupes from the list @@ -1687,11 +1930,14 @@ class Generator(object): returns the sorted list of parents for a native class ''' sorted_parents = [] + for scope_name in nclass.nested_classes: + if scope_name in self.generated_classes.keys(): + sorted_parents.append(self.generated_classes[scope_name]) for p in nclass.parents: if p.class_name in self.generated_classes.keys(): sorted_parents += self._sorted_parents(p) if nclass.class_name in self.generated_classes.keys(): - sorted_parents.append(nclass.class_name) + sorted_parents.append(nclass) return sorted_parents def generate_code(self): @@ -1701,6 +1947,8 @@ class Generator(object): self.config = data implfilepath = os.path.join(self.outdir, self.out_file + ".cpp") headfilepath = os.path.join(self.outdir, self.out_file + ".h") + jsonfilepath = os.path.join(self.outdir, self.out_file + ".json") + reg_typepath = os.path.join(self.outdir, self.out_file + ".inl") headLicense = '' implLicense = '' @@ -1708,38 +1956,66 @@ class Generator(object): licensePattern = re.compile('\/\*{5,}.*?\*{5,}\/\s*', re.S) with open(headfilepath, 'a+') as headReader: headMatch = licensePattern.search(headReader.read()) - if headMatch: headLicense = headMatch.group() + if headMatch: + headLicense = headMatch.group() with open(implfilepath, 'a+') as implReader: implMatch = licensePattern.search(implReader.read()) - if implMatch: implLicense = implMatch.group() + if implMatch: + implLicense = implMatch.group() self.head_file = io.open(headfilepath, "w+", newline="\n") self.impl_file = io.open(implfilepath, "w+", newline="\n") + self.json_file = io.open(jsonfilepath, "w+", newline="\n") + self.regi_file_lines = [] - layout_h = Template(file=os.path.join(self.target, "templates", "layout_head.h"), searchList=[self]) - layout_c = Template(file=os.path.join(self.target, "templates", "layout_head.c"), searchList=[self]) + self.class_json_list = [] + + layout_h = Template(file=os.path.join( + self.target, "templates", "layout_head.h"), searchList=[self]) + layout_c = Template(file=os.path.join( + self.target, "templates", "layout_head.c"), searchList=[self]) self.head_file.write(headLicense + unicode(layout_h)) self.impl_file.write(implLicense + unicode(layout_c)) self._parse_headers() - layout_h = Template(file=os.path.join(self.target, "templates", "layout_foot.h"), searchList=[self]) - layout_c = Template(file=os.path.join(self.target, "templates", "layout_foot.c"), searchList=[self]) + layout_h = Template(file=os.path.join( + self.target, "templates", "layout_foot.h"), searchList=[self]) + layout_c = Template(file=os.path.join( + self.target, "templates", "layout_foot.c"), searchList=[self]) self.head_file.write(unicode(layout_h)) self.impl_file.write(unicode(layout_c)) - + + try: + self.json_file.write(unicode(json.dumps(self.class_json_list, sort_keys=False, indent=4))) + except Exception as err: + logger.error("json.dumps error %s" % (err)) self.impl_file.close() self.head_file.close() + self.json_file.close() + # post parse actions + self.inplace_change(headfilepath, "// placeholder for jsb_register_types", "".join(self.regi_file_lines)) + + def inplace_change(self, filename, old_string, new_string): + logger.info("replace file %s" % filename) + with open(filename) as f: + s = f.read() + if old_string not in s: + print('"{old_string}" not found in {filename}.'.format(**locals())) + return + with open(filename, 'w') as f: + s = s.replace(old_string, new_string) + f.write(s) def _pretty_print(self, diagnostics): - errors=[] + errors = [] for idx, d in enumerate(diagnostics): if d.severity > 2: errors.append(d) if len(errors) == 0: return logger.error("=== Errors in parsing headers:") - severities=['Ignored', 'Note', 'Warning', 'Error', 'Fatal'] + severities = ['Ignored', 'Note', 'Warning', 'Error', 'Fatal'] for idx, d in enumerate(errors): logger.info("%s. " % ( idx+1, severities[d.severity], d.location, d.spelling)) @@ -1748,6 +2024,9 @@ class Generator(object): def _parse_headers(self): for header in self.headers: logger.info(">>> parse_header: " + header) + if not os.path.exists(header): + logger.error("[error] header %s not found" % header) + # logger.info(">>> arguments %s" % self.clang_args) tu = self.index.parse(header, self.clang_args) if len(tu.diagnostics) > 0: self._pretty_print(tu.diagnostics) @@ -1758,9 +2037,12 @@ class Generator(object): if is_fatal: logger.error("*** Found errors - can not continue") raise Exception("Fatal error in parsing headers") - self._deep_iterate(tu.cursor) + self._deep_iterate(tu.cursor, 0, []) - def _deep_iterate(self, cursor, depth=0): + def _deep_iterate(self, cursor, depth=0, nested_classes = []): + + if nested_classes is None: + logger.error(" ? depth %s, nested_classes %s" %(depth, nested_classes)) def get_children_array_from_iter(iter): children = [] @@ -1772,9 +2054,10 @@ class Generator(object): if cursor.kind == cindex.CursorKind.CLASS_DECL or cursor.kind == cindex.CursorKind.STRUCT_DECL: is_struct = cursor.kind == cindex.CursorKind.STRUCT_DECL namespaced_class_name = get_namespaced_class_name(cursor) + # logger.error("process class %s" % (namespaced_class_name) ) if len(namespaced_class_name) == 0 or cursor.displayname.startswith("__"): return - if cursor == cursor.type.get_declaration() and len(get_children_array_from_iter(cursor.get_children())) > 0: + if cursor == cursor.type.get_declaration() and len(get_children_array_from_iter(cursor.get_children())) > 0: is_targeted_class = True if self.cpp_ns: is_targeted_class = False @@ -1782,14 +2065,15 @@ class Generator(object): if namespaced_class_name.startswith(ns): is_targeted_class = True break - if is_targeted_class and self.in_listed_classes(cursor.displayname): if cursor.displayname not in self.generated_classes: nclass = NativeClass(cursor, self, is_struct) + # logger.error(" - depth %s, nested_classes %s" %(depth, nested_classes)) + nclass.nested_classes = list(nested_classes) nclass.generate_code() self.generated_classes[cursor.displayname] = nclass return - elif cursor.kind == cindex.CursorKind.ENUM_DECL : + elif cursor.kind == cindex.CursorKind.ENUM_DECL: if cursor == cursor.type.get_declaration() and len(get_children_array_from_iter(cursor.get_children())) > 0: namespaced_class_name = get_namespaced_class_name(cursor) if len(namespaced_class_name) == 0 or cursor.displayname.startswith("__"): @@ -1803,7 +2087,7 @@ class Generator(object): is_targeted_class = True break - if is_targeted_class and len(cursor.displayname) > 0 and self.in_listed_classes_exactly(cursor.displayname): + if is_targeted_class and len(cursor.displayname) > 0 and self.in_listed_classes_exactly(cursor.displayname): if cursor.displayname not in self.generated_classes: nclass = NativeEnum(cursor, self) nclass.generate_code() @@ -1812,19 +2096,38 @@ class Generator(object): for node in cursor.get_children(): # print("%s %s - %s" % (">" * depth, node.displayname, node.kind)) - self._deep_iterate(node, depth + 1) + self._deep_iterate(node, depth + 1, list(nested_classes) if nested_classes is not None else []) + def scriptname_from_native(self, namespace_class_name, namespace_name): script_ns_dict = self.config['conversions']['ns_map'] + if namespace_name.startswith("const "): + namespace_name = namespace_name.replace("const ","") + if namespace_class_name.startswith("const "): + namespace_class_name = namespace_class_name.replace("const ","") + if len(namespace_name) == 0 and namespace_class_name.find("::") >=0 and namespace_class_name.find("std:: ") < 0: + parts = namespace_class_name.split("::") + if len(parts) > 1: + parts.pop() + namespace_name = "".join(list(map(lambda x: x+"::", parts))) + for (k, v) in script_ns_dict.items(): if k == namespace_name: - return namespace_class_name.replace("*","").replace("const ", "").replace(k, v) + return namespace_class_name.replace("*", "").replace("const ", "").replace(k, v) if namespace_class_name.find("::") >= 0: if namespace_class_name.find("std::") == 0: return namespace_class_name else: - raise Exception("The namespace (%s) conversion wasn't set in 'ns_map' section of the conversions.yaml" % namespace_class_name) + #raise Exception( + # "The namespace (%s) conversion wasn't set in 'ns_map' section of the conversions.yaml" % namespace_class_name) + if len(namespace_name) == 0: + parts = namespace_class_name.split("::") + if len(parts) > 1: + nn = parts.pop() + return self.scriptname_from_native("::".join(parts)+"::", nn) + logger.error("The namespace (%s), '%s' conversion wasn't set in 'ns_map' section of the conversions.yaml" % (namespace_class_name, namespace_name)) + return "nowhere" else: - return namespace_class_name.replace("*","").replace("const ", "") + return namespace_class_name.replace("*", "").replace("const ", "") def is_cocos_class(self, namespace_class_name): script_ns_dict = self.config['conversions']['ns_map'] @@ -1840,8 +2143,9 @@ class Generator(object): script_ns_dict = self.config['conversions']['ns_map'] for (k, v) in script_ns_dict.items(): if namespace_class_name.find(k) >= 0: - return namespace_class_name.replace("*","").replace("const ", "").replace(k,v) - raise Exception("The namespace (%s) conversion wasn't set in 'ns_map' section of the conversions.yaml" % namespace_class_name) + return namespace_class_name.replace("*", "").replace("const ", "").replace(k, v) + raise Exception( + "The namespace (%s) conversion wasn't set in 'ns_map' section of the conversions.yaml" % namespace_class_name) def js_typename_from_natve(self, namespace_class_name): script_ns_dict = self.config['conversions']['ns_map'] @@ -1869,11 +2173,11 @@ class Generator(object): return "Array" if namespace_class_name.find("cc::Map") == 0: return "map_object" - if namespace_class_name.find("cc::Point") == 0: + if namespace_class_name.find("cc::Point") == 0: return "point_object" - if namespace_class_name.find("cc::Size") == 0: + if namespace_class_name.find("cc::Size") == 0: return "size_object" - if namespace_class_name.find("cc::Rect") == 0: + if namespace_class_name.find("cc::Rect") == 0: return "rect_object" if namespace_class_name.find("cc::Color3B") == 0: return "color3b_object" @@ -1882,14 +2186,14 @@ class Generator(object): if namespace_class_name.find("cc::Color4F") == 0: return "color4f_object" else: - return namespace_class_name.replace("*","").replace("const ", "").replace(k,v) - return namespace_class_name.replace("*","").replace("const ", "") + return namespace_class_name.replace("*", "").replace("const ", "").replace(k, v) + return namespace_class_name.replace("*", "").replace("const ", "") - def js_ret_name_from_native(self, namespace_class_name, is_enum) : + def js_ret_name_from_native(self, namespace_class_name, is_enum): if self.is_cocos_class(namespace_class_name): - if namespace_class_name.find("cc::Vector") >=0: + if namespace_class_name.find("cc::Vector") >= 0: return "new Array()" - if namespace_class_name.find("cc::Map") >=0: + if namespace_class_name.find("cc::Map") >= 0: return "map_object" if is_enum: return 0 @@ -1899,7 +2203,7 @@ class Generator(object): lower_name = namespace_class_name.lower() if lower_name.find("unsigned ") >= 0: - lower_name = lower_name.replace("unsigned ","") + lower_name = lower_name.replace("unsigned ", "") if lower_name == "std::string": return "" @@ -1921,19 +2225,20 @@ class Generator(object): else: return namespace_class_name + def main(): from optparse import OptionParser parser = OptionParser("usage: %prog [options] {configfile}") parser.add_option("-s", action="store", type="string", dest="section", - help="sets a specific section to be converted") + help="sets a specific section to be converted") parser.add_option("-t", action="store", type="string", dest="target", - help="specifies the target vm. Will search for TARGET.yaml") + help="specifies the target vm. Will search for TARGET.yaml") parser.add_option("-o", action="store", type="string", dest="outdir", - help="specifies the output directory for generated C++ code") + help="specifies the output directory for generated C++ code") parser.add_option("-n", action="store", type="string", dest="out_file", - help="specifcies the name of the output file, defaults to the prefix in the .ini file") + help="specifcies the name of the output file, defaults to the prefix in the .ini file") (opts, args) = parser.parse_args() @@ -1944,12 +2249,14 @@ def main(): parser.error('invalid number of arguments') userconfig = configparser.ConfigParser() - userconfig_path = os.path.join(os.path.abspath(os.path.dirname(__file__)), "../tojs", 'userconf.ini') + userconfig_path = os.path.join(os.path.abspath( + os.path.dirname(__file__)), "../tojs", 'userconf.ini') userconfig.read(userconfig_path) userconfig.set('DEFAULT', 'configdir', os.path.dirname(args[0])) # logger.info('Using userconfig \n %s' % (userconfig.items('DEFAULT'))) - clang_lib_path = os.path.join(userconfig.get('DEFAULT', 'cxxgeneratordir'), 'libclang') + clang_lib_path = os.path.join(userconfig.get( + 'DEFAULT', 'cxxgeneratordir'), 'libclang') cindex.Config.set_library_path(clang_lib_path) config = configparser.ConfigParser() @@ -1964,7 +2271,8 @@ def main(): sections = [] sections.append(opts.section) else: - raise Exception("Section %s not found in config file" % opts.section) + raise Exception( + "Section %s not found in config file" % opts.section) else: logger.info("processing all sections") sections = config.sections() @@ -1974,7 +2282,7 @@ def main(): targets = [] if (os.path.isdir(targetdir)): targets = [entry for entry in os.listdir(targetdir) - if (os.path.isdir(os.path.join(targetdir, entry)))] + if (os.path.isdir(os.path.join(targetdir, entry)))] if 0 == len(targets): raise Exception("No targets defined") @@ -1990,7 +2298,6 @@ def main(): if not os.path.exists(outdir): os.makedirs(outdir) - for t in targets: # Fix for hidden '.svn', '.cvs' and '.git' etc. folders - these must be ignored or otherwise they will be interpreted as a target. if t == ".svn" or t == ".cvs" or t == ".git" or t == ".gitignore": @@ -2001,7 +2308,7 @@ def main(): logger.info(".... .... Processing section " + s) gen_opts = { 'prefix': config.get(s, 'prefix'), - 'headers': (config.get(s, 'headers', raw=False, vars=dict(userconfig.items('DEFAULT')))), + 'headers': re.split('[\s,]+', re.sub('[#;].*', '', (config.get(s, 'headers', raw=False, vars=dict(userconfig.items('DEFAULT')))))), 'replace_headers': config.get(s, 'replace_headers') if config.has_option(s, 'replace_headers') else None, 'classes': re.split('[\s,]+', re.sub('[#;].*', '', config.get(s, 'classes'))), 'classes_need_extend': config.get(s, 'classes_need_extend').split(' ') if config.has_option(s, 'classes_need_extend') else [], @@ -2014,7 +2321,7 @@ def main(): 'cpp_ns': config.get(s, 'cpp_namespace').split(' ') if config.has_option(s, 'cpp_namespace') else None, 'classes_have_no_parents': config.get(s, 'classes_have_no_parents'), 'base_classes_to_skip': config.get(s, 'base_classes_to_skip'), - 'getter_setter': config.get(s, 'getter_setter') if config.has_option(s, 'getter_setter') else "", + 'getter_setter': config.get(s, 'getter_setter') if config.has_option(s, 'getter_setter') else "", 'abstract_classes': config.get(s, 'abstract_classes'), 'persistent_classes': config.get(s, 'persistent_classes') if config.has_option(s, 'persistent_classes') else None, 'classes_owned_by_cpp': config.get(s, 'classes_owned_by_cpp') if config.has_option(s, 'classes_owned_by_cpp') else None, @@ -2030,17 +2337,19 @@ def main(): 'hpp_headers': config.get(s, 'hpp_headers', raw=False, vars=dict(userconfig.items('DEFAULT'))).split(' ') if config.has_option(s, 'hpp_headers') else None, 'cpp_headers': config.get(s, 'cpp_headers', raw=False, vars=dict(userconfig.items('DEFAULT'))).split(' ') if config.has_option(s, 'cpp_headers') else None, 'win32_clang_flags': (config.get(s, 'win32_clang_flags', raw=False, vars=dict(userconfig.items('DEFAULT'))) or "").split(" ") if config.has_option(s, 'win32_clang_flags') else None - } + } generator = Generator(gen_opts) generator.generate_code() + if __name__ == '__main__': try: logger = logging.getLogger(os.path.basename(sys.argv[1])) logger.setLevel(logging.INFO) ch = logging.StreamHandler() ch.setLevel(logging.INFO) - formatter = logging.Formatter('[%(name)s] - %(levelname)s: %(message)s') + formatter = logging.Formatter( + '[%(name)s] - %(levelname)s: %(message)s') ch.setFormatter(formatter) logger.addHandler(ch) main() diff --git a/native/tools/bindings-generator/targets/spidermonkey/conversions.yaml b/native/tools/bindings-generator/targets/spidermonkey/conversions.yaml index c73c7036b6..baad311f0a 100644 --- a/native/tools/bindings-generator/targets/spidermonkey/conversions.yaml +++ b/native/tools/bindings-generator/targets/spidermonkey/conversions.yaml @@ -2,7 +2,7 @@ definitions: # the names of the functions - we use this to generate the code and to register the functions in # the javascript class ifunction: "js_${generator.prefix}_${class_name}_${func_name}" - sfunction: "js_${generator.prefix}_${class_name}_${func_name}" + sfunction: "js_${generator.prefix}_${class_name}_${func_name}_static" constructor: "js_${generator.prefix}_${class_name}_constructor" ctor: "js_${generator.prefix}_${class_name}_ctor" public_field: "js_${generator.prefix}_${class_name}" @@ -18,12 +18,21 @@ conversions: "long long": "int64_t" ns_map: "cc::extension::": "cc." + "cc::network::": "cc." + "cc::middleware::": "cc." "cc::ui::": "ccui." - "cc::": "cc." + "cc::": "jsb." "spine::": "sp." + "dragonBones::": "dragonbones." "cc::gfx::": "gfx." "cc::pipeline::": "nr." - "cc::scene::": "ns." + "cc::scene::": "jsb." + "cc::geometry::": "jsb." + "cc::event::": "jsb." + "cc::physics::": "jsb." + "boost::variant2::": "boost." + "boost::": "boost." + "se::": "jsb." to_native: # jsval to int int32_t: "ok &= seval_to_int32(${in_value}, (int32_t*)&${out_value})" @@ -152,6 +161,6 @@ conversions: "@shared_ptr<.*DownloadTask.*": "ok &= DownloadTask_to_seval(*${in_value}, &${out_value})" "Data": "ok &= Data_to_seval(${in_value}, &${out_value})" "se_object_ptr": "${out_value}.setObject(${in_value})" - "String": "${out_value}.setString(${in_value})" + "String": "${out_value}.setString(${in_value})" object: "ok &= native_ptr_to_seval(${in_value}, &${out_value})" rooted_object: "ok &= native_ptr_to_rooted_seval<${ntype.replace('*', '').replace('const ', '')}>((${ntype.replace('const ', '')})${in_value}, &${out_value})" diff --git a/native/tools/bindings-generator/targets/spidermonkey/templates/constructor.c b/native/tools/bindings-generator/targets/spidermonkey/templates/constructor.c index de032a319d..8a404bcc90 100644 --- a/native/tools/bindings-generator/targets/spidermonkey/templates/constructor.c +++ b/native/tools/bindings-generator/targets/spidermonkey/templates/constructor.c @@ -6,7 +6,7 @@ SE_DECLARE_FINALIZE_FUNC(js_${underlined_class_name}_finalize) static bool ${signature_name}(se::State& /*s*/) // NOLINT(readability-identifier-naming) constructor.c { //#3 ${namespaced_class_name}: is_skip_construtor ${is_skip_constructor} - se::ScriptEngine::getInstance()->evalString("throw new Error(\"${namespaced_class_name} constructor is skipped\")"); + se::ScriptEngine::getInstance()->throwException("${namespaced_class_name} constructor is skipped"); return false; #else static bool ${signature_name}(se::State& s) // NOLINT(readability-identifier-naming) constructor.c @@ -58,11 +58,8 @@ static bool ${signature_name}(se::State& s) // NOLINT(readability-identifier-nam #else #set $arg_list = ", " + ", ".join($arg_array) #end if - ${namespaced_class_name}* cobj = JSB_ALLOC(${namespaced_class_name}$arg_list); - s.thisObject()->setPrivateData(cobj); - #if not $is_ref_class - se::NonRefNativePtrCreatedByCtorMap::emplace(cobj); - #end if + auto *ptr = JSB_MAKE_PRIVATE_OBJECT(${namespaced_class_name}$arg_list); + s.thisObject()->setPrivateObject(ptr); #end if return true; #end if diff --git a/native/tools/bindings-generator/targets/spidermonkey/templates/constructor_overloaded.c b/native/tools/bindings-generator/targets/spidermonkey/templates/constructor_overloaded.c index d833dbcbf5..f01819ca44 100644 --- a/native/tools/bindings-generator/targets/spidermonkey/templates/constructor_overloaded.c +++ b/native/tools/bindings-generator/targets/spidermonkey/templates/constructor_overloaded.c @@ -57,11 +57,8 @@ static bool ${signature_name}(se::State& s) // NOLINT(readability-identifier-nam #else #set $arg_list = ", " + ", ".join($arg_array) #end if - ${namespaced_class_name}* cobj = JSB_ALLOC(${namespaced_class_name}$arg_list); - s.thisObject()->setPrivateData(cobj); - #if not $is_ref_class - se::NonRefNativePtrCreatedByCtorMap::emplace(cobj); - #end if + auto *ptr = JSB_MAKE_PRIVATE_OBJECT(${namespaced_class_name}$arg_list); + s.thisObject()->setPrivateObject(ptr); return true; } } while(false); diff --git a/native/tools/bindings-generator/targets/spidermonkey/templates/ctor.c b/native/tools/bindings-generator/targets/spidermonkey/templates/ctor.c index 40f44a2f97..7d2b347f43 100644 --- a/native/tools/bindings-generator/targets/spidermonkey/templates/ctor.c +++ b/native/tools/bindings-generator/targets/spidermonkey/templates/ctor.c @@ -55,11 +55,8 @@ static bool ${signature_name}(se::State& s) // NOLINT(readability-identifier-nam #else #set $arg_list = "," + ", ".join($arg_array) #end if - ${namespaced_class_name}* cobj = JSB_ALLOC(${namespaced_class_name}$arg_list); - s.thisObject()->setPrivateData(cobj); - #if not $is_ref_class - se::NonRefNativePtrCreatedByCtorMap::emplace(cobj); - #end if + auto *ptr = JSB_MAKE_PRIVATE_OBJECT(${namespaced_class_name}$arg_list); + s.thisObject()->setPrivateObject(ptr); #end if return true; #end if diff --git a/native/tools/bindings-generator/targets/spidermonkey/templates/ctor_overloaded.c b/native/tools/bindings-generator/targets/spidermonkey/templates/ctor_overloaded.c index 379b499448..ece371165a 100644 --- a/native/tools/bindings-generator/targets/spidermonkey/templates/ctor_overloaded.c +++ b/native/tools/bindings-generator/targets/spidermonkey/templates/ctor_overloaded.c @@ -48,11 +48,8 @@ static bool ${signature_name}(se::State& s) // NOLINT(readability-identifier-nam #end while #end if #set $arg_list = ", ".join($arg_array) - ${namespaced_class_name}* cobj = new (std::nothrow) ${namespaced_class_name}($arg_list); - s.thisObject()->setPrivateData(cobj); - #if not $is_ref_class - se::NonRefNativePtrCreatedByCtorMap::emplace(cobj); - #end if + auto *ptr = JSB_MAKE_PRIVATE_OBJECT(${namespaced_class_name},$arg_list); + s.thisObject()->setPrivateObject(ptr); return true; } } while(false); diff --git a/native/tools/bindings-generator/targets/spidermonkey/templates/enum.c b/native/tools/bindings-generator/targets/spidermonkey/templates/enum.c index 18f9224238..33acdb9947 100644 --- a/native/tools/bindings-generator/targets/spidermonkey/templates/enum.c +++ b/native/tools/bindings-generator/targets/spidermonkey/templates/enum.c @@ -10,7 +10,7 @@ bool sevalue_to_native(const se::Value &from, ${current_class.namespaced_class_n return false; } -int js_register_${generator.prefix}_${current_class.class_name}(se::Object* obj) // NOLINT(readability-identifier-naming) +int js_register_${generator.prefix}_${current_class.nested_class_name}(se::Object* obj) // NOLINT(readability-identifier-naming) { auto enum_kls = se::Object::createPlainObject(); #for m in fields diff --git a/native/tools/bindings-generator/targets/spidermonkey/templates/ifunction.c b/native/tools/bindings-generator/targets/spidermonkey/templates/ifunction.c index b4b2aea307..f012de816b 100644 --- a/native/tools/bindings-generator/targets/spidermonkey/templates/ifunction.c +++ b/native/tools/bindings-generator/targets/spidermonkey/templates/ifunction.c @@ -73,7 +73,7 @@ static bool ${signature_name}(se::State& s) // NOLINT(readability-identifier-nam "level": 2})}; SE_PRECONDITION2(ok, false, "${signature_name} : Error processing arguments"); #if $generator.should_obtain_return_value($class_name, $func_name) - se::NonRefNativePtrCreatedByCtorMap::emplace(result); + s.rval().toObject()->getPrivateObject()->tryAllowDestroyInGC(); #end if SE_HOLD_RETURN_VALUE(result, s.thisObject(), s.rval()); #else @@ -87,10 +87,14 @@ static bool ${signature_name}(se::State& s) // NOLINT(readability-identifier-nam #end if return false; } -#if $current_class is not None and $current_class.is_getter_method($func_name) -SE_BIND_PROP_GET(${signature_name}) -#elif $current_class is not None and $current_class.is_setter_method($func_name) -SE_BIND_PROP_SET(${signature_name}) -#else +#if $current_class is not None +#if $current_class.is_getter_attribute($func_name) +SE_BIND_FUNC_AS_PROP_GET(${signature_name}) +#end if +#if $current_class.is_setter_attribute($func_name) +SE_BIND_FUNC_AS_PROP_SET(${signature_name}) +#end if +#if not $current_class.skip_bind_function({"name":$func_name}) SE_BIND_FUNC(${signature_name}) #end if +#end if diff --git a/native/tools/bindings-generator/targets/spidermonkey/templates/ifunction_overloaded.c b/native/tools/bindings-generator/targets/spidermonkey/templates/ifunction_overloaded.c index cb3d1dd354..44c3353b71 100644 --- a/native/tools/bindings-generator/targets/spidermonkey/templates/ifunction_overloaded.c +++ b/native/tools/bindings-generator/targets/spidermonkey/templates/ifunction_overloaded.c @@ -21,7 +21,7 @@ static bool ${signature_name}(se::State& s) // NOLINT(readability-identifier-nam #set $count = 0 #while $count < $arg_idx #set $arg = $func.arguments[$count] - #set $arg_type = $arg.to_string($generator, omit_const=True) + #set $arg_type = $arg.to_string($generator, omit_const = True) #if $arg.is_reference #set $holder_prefix="HolderType<"+$arg_type+", true>" #else @@ -83,4 +83,14 @@ static bool ${signature_name}(se::State& s) // NOLINT(readability-identifier-nam SE_REPORT_ERROR("wrong number of arguments: %d", (int)argc); return false; } +#if $current_class is not None +#if $current_class.is_getter_attribute($func_name) +SE_BIND_FUNC_AS_PROP_GET(${signature_name}) +#end if +#if $current_class.is_setter_attribute($func_name) +SE_BIND_FUNC_AS_PROP_SET(${signature_name}) +#end if +#if not $current_class.skip_bind_function({"name":$func_name}) SE_BIND_FUNC(${signature_name}) +#end if +#end if \ No newline at end of file diff --git a/native/tools/bindings-generator/targets/spidermonkey/templates/lambda.c b/native/tools/bindings-generator/targets/spidermonkey/templates/lambda.c index 2c378c2dd9..28d2cc393f 100644 --- a/native/tools/bindings-generator/targets/spidermonkey/templates/lambda.c +++ b/native/tools/bindings-generator/targets/spidermonkey/templates/lambda.c @@ -8,6 +8,7 @@ do { #else jsThis.toObject()->attachObject(jsFunc.toObject()); #end if + auto * thisObj = s.thisObject(); auto lambda = [=](${lambda_parameters}) -> ${ret_type.name} { se::ScriptEngine::getInstance()->clearException(); se::AutoHandleScope hs; @@ -34,7 +35,6 @@ do { #set $count = $count + 1 #end while se::Value rval; - se::Object* thisObj = jsThis.isObject() ? jsThis.toObject() : nullptr; se::Object* funcObj = jsFunc.toObject(); #if $arg_count > 0 bool succeed = funcObj->call(args, thisObj, &rval); diff --git a/native/tools/bindings-generator/targets/spidermonkey/templates/layout_foot.c b/native/tools/bindings-generator/targets/spidermonkey/templates/layout_foot.c index 359ec5631a..f4c295d3a4 100644 --- a/native/tools/bindings-generator/targets/spidermonkey/templates/layout_foot.c +++ b/native/tools/bindings-generator/targets/spidermonkey/templates/layout_foot.c @@ -1,9 +1,9 @@ -bool register_all_${prefix}(se::Object* obj) +bool register_all_${prefix}(se::Object* obj) // NOLINT { #if $target_ns // Get the ns se::Value nsVal; - if (!obj->getProperty("${target_ns}", &nsVal)) + if (!obj->getProperty("${target_ns}", &nsVal, true)) { se::HandleObject jsobj(se::Object::createPlainObject()); nsVal.setObject(jsobj); @@ -16,8 +16,8 @@ bool register_all_${prefix}(se::Object* obj) #end if #for jsclass in $sorted_classes - #if $in_listed_classes(jsclass) - js_register_${prefix}_${jsclass}(ns); + #if $in_listed_classes(jsclass.class_name) + js_register_${prefix}_${jsclass.nested_class_name}(ns); #end if #end for return true; @@ -25,4 +25,5 @@ bool register_all_${prefix}(se::Object* obj) #if $macro_judgement \#endif //$macro_judgement -#end if \ No newline at end of file +#end if +// clang-format on \ No newline at end of file diff --git a/native/tools/bindings-generator/targets/spidermonkey/templates/layout_foot.h b/native/tools/bindings-generator/targets/spidermonkey/templates/layout_foot.h index 6107578595..0171bb42d5 100644 --- a/native/tools/bindings-generator/targets/spidermonkey/templates/layout_foot.h +++ b/native/tools/bindings-generator/targets/spidermonkey/templates/layout_foot.h @@ -1,4 +1,4 @@ - #if $macro_judgement \#endif //$macro_judgement -#end if \ No newline at end of file + #end if + // clang-format on \ No newline at end of file diff --git a/native/tools/bindings-generator/targets/spidermonkey/templates/layout_head.c b/native/tools/bindings-generator/targets/spidermonkey/templates/layout_head.c index 3ce09646ba..8efca730cf 100644 --- a/native/tools/bindings-generator/targets/spidermonkey/templates/layout_head.c +++ b/native/tools/bindings-generator/targets/spidermonkey/templates/layout_head.c @@ -1,3 +1,5 @@ + +// clang-format off \#include "${os.path.relpath(os.path.join($outdir, $out_file + '.h'), $search_path+'/..').replace(os.path.sep, '/')}" #if $macro_judgement $macro_judgement diff --git a/native/tools/bindings-generator/targets/spidermonkey/templates/layout_head.h b/native/tools/bindings-generator/targets/spidermonkey/templates/layout_head.h index 01ac190506..d73fb5210d 100644 --- a/native/tools/bindings-generator/targets/spidermonkey/templates/layout_head.h +++ b/native/tools/bindings-generator/targets/spidermonkey/templates/layout_head.h @@ -1,3 +1,4 @@ +// clang-format off #pragma once \#include "base/Config.h" #if $macro_judgement @@ -11,3 +12,7 @@ $macro_judgement \#include "${header}" #end for #end if + +bool register_all_${prefix}(se::Object *obj); // NOLINT + +// placeholder for jsb_register_types diff --git a/native/tools/bindings-generator/targets/spidermonkey/templates/prelude.c b/native/tools/bindings-generator/targets/spidermonkey/templates/prelude.c index 00b44fcbfa..0bf1fde052 100644 --- a/native/tools/bindings-generator/targets/spidermonkey/templates/prelude.c +++ b/native/tools/bindings-generator/targets/spidermonkey/templates/prelude.c @@ -1,3 +1,3 @@ #set generator = $current_class.generator -se::Object* __jsb_${current_class.underlined_class_name}_proto = nullptr; -se::Class* __jsb_${current_class.underlined_class_name}_class = nullptr; +se::Object* __jsb_${current_class.underlined_class_name}_proto = nullptr; // NOLINT +se::Class* __jsb_${current_class.underlined_class_name}_class = nullptr; // NOLINT diff --git a/native/tools/bindings-generator/targets/spidermonkey/templates/prelude.h b/native/tools/bindings-generator/targets/spidermonkey/templates/prelude.h index dceb0ccbd3..423a3ad6d2 100644 --- a/native/tools/bindings-generator/targets/spidermonkey/templates/prelude.h +++ b/native/tools/bindings-generator/targets/spidermonkey/templates/prelude.h @@ -1,13 +1,11 @@ #set generator = $current_class.generator -extern se::Object* __jsb_${current_class.underlined_class_name}_proto; -extern se::Class* __jsb_${current_class.underlined_class_name}_class; +extern se::Object *__jsb_${current_class.underlined_class_name}_proto; // NOLINT +extern se::Class * __jsb_${current_class.underlined_class_name}_class; // NOLINT -bool js_register_${current_class.underlined_class_name}(se::Object* obj); -bool register_all_${generator.prefix}(se::Object* obj); +bool js_register_${current_class.underlined_class_name}(se::Object *obj); // NOLINT #if $current_class.is_struct -template<> -bool sevalue_to_native(const se::Value &, ${current_class.namespaced_class_name} *, se::Object *ctx); -#end if -JSB_REGISTER_OBJECT_TYPE(${current_class.namespaced_class_name}); +template <> +bool sevalue_to_native(const se::Value &, ${current_class.namespaced_class_name} *, se::Object *ctx); //NOLINT + #end if \ No newline at end of file diff --git a/native/tools/bindings-generator/targets/spidermonkey/templates/public_static_field.c b/native/tools/bindings-generator/targets/spidermonkey/templates/public_static_field.c new file mode 100644 index 0000000000..808425ce6d --- /dev/null +++ b/native/tools/bindings-generator/targets/spidermonkey/templates/public_static_field.c @@ -0,0 +1,71 @@ +## ===== member implementation template + +static bool ${signature_name}_get_${name}(se::State& s) // NOLINT(readability-identifier-naming) +{ + CC_UNUSED bool ok = true; + se::Value jsret; + #if $ntype.is_object and not $ntype.object_can_convert($generator, False) + ${ntype.from_native({"generator": $generator, + "type_name": $ntype.namespaced_class_name.replace("*", ""), + "ntype": $ntype.get_whole_name($generator), + "level": 2, + "in_value": $namespaced_class_name + "::" + $pretty_name, + "out_value": "jsret", + "context" : "s.thisObject()" + })}; + #else + ${ntype.from_native({"generator": $generator, + "type_name": $ntype.namespaced_class_name.replace("*", ""), + "ntype": $ntype.get_whole_name($generator), + "level": 2, + "scriptname": $generator.scriptname_from_native($ntype.namespaced_class_name, $ntype.namespace_name), + "in_value": $namespaced_class_name + "::" + $pretty_name, + "out_value": "jsret", + "context" : "s.thisObject()" + })}; + #end if + s.rval() = jsret; + // SE_HOLD_RETURN_VALUE(cobj->${pretty_name}, s.thisObject(), s.rval()); + return true; +} +SE_BIND_PROP_GET(${signature_name}_get_${name}) + +#if not $is_static_const +static bool ${signature_name}_set_${name}(se::State& s) // NOLINT(readability-identifier-naming) +{ + const auto& args = s.args(); + SE_PRECONDITION2(args.size() == 1, false, "${signature_name}_set_${name} : arguments count incorrect"); + + CC_UNUSED bool ok = true; + #set $arg_type = $ntype.to_string($generator) +#if $ntype.is_object and not $ntype.object_can_convert($generator) + #set conv_text = $ntype.to_native({"generator": $generator, \ + "arg_idx": 2, \ + "arg_type": $arg_type, \ + "ntype": $ntype.get_whole_name($generator), \ + "in_value": "args[0]", \ + "out_value": $namespaced_class_name + "::" + $pretty_name, \ + "func_name": $name, \ + "level": 2, \ + "arg":$ntype, \ + "context" : "s.thisObject()" \ + }) +#else + #set conv_text = $ntype.to_native({"generator": $generator, \ + "arg_idx": 2, \ + "arg_type": $arg_type, \ + "in_value": "args[0]", \ + "out_value": $namespaced_class_name + "::" + $pretty_name, \ + "func_name": $name, \ + "scriptname": $generator.scriptname_from_native($ntype.namespaced_class_name, $ntype.namespace_name), \ + "level": 2, \ + "arg":$ntype, \ + "context" : "s.thisObject()" \ + }) +#end if + $conv_text; + SE_PRECONDITION2(ok, false, "${signature_name}_set_${name} : Error processing new value"); + return true; +} +SE_BIND_PROP_SET(${signature_name}_set_${name}) +#end if diff --git a/native/tools/bindings-generator/targets/spidermonkey/templates/reg_types.h b/native/tools/bindings-generator/targets/spidermonkey/templates/reg_types.h new file mode 100644 index 0000000000..78b4396ecc --- /dev/null +++ b/native/tools/bindings-generator/targets/spidermonkey/templates/reg_types.h @@ -0,0 +1 @@ +JSB_REGISTER_OBJECT_TYPE(${current_class.namespaced_class_name}); diff --git a/native/tools/bindings-generator/targets/spidermonkey/templates/register.c b/native/tools/bindings-generator/targets/spidermonkey/templates/register.c index 860e6a4a61..e07e068078 100644 --- a/native/tools/bindings-generator/targets/spidermonkey/templates/register.c +++ b/native/tools/bindings-generator/targets/spidermonkey/templates/register.c @@ -11,7 +11,6 @@ ${current_class.generate_struct_constructor()} #set constructor = $current_class.methods.constructor ${current_class.methods.constructor.generate_code($current_class)} #end if - #if $generator.in_listed_extend_classed($current_class.class_name) and $has_constructor #if not $constructor.is_overloaded ${constructor.generate_code($current_class, None, False, True)} @@ -19,90 +18,57 @@ ${current_class.methods.constructor.generate_code($current_class)} ${constructor.generate_code($current_class, False, True)} #end if #end if - #if not $current_class.is_abstract static bool js_${current_class.underlined_class_name}_finalize(se::State& s) // NOLINT(readability-identifier-naming) { - #if $current_class.rename_destructor is None - #if $current_class.is_ref_class - auto* cobj =SE_THIS_OBJECT<${current_class.namespaced_class_name}>(s); - cobj->release(); - #else - #if not $current_class.is_class_owned_by_cpp - auto iter = se::NonRefNativePtrCreatedByCtorMap::find(SE_THIS_OBJECT<${current_class.namespaced_class_name}>(s)); - if (iter != se::NonRefNativePtrCreatedByCtorMap::end()) - { - se::NonRefNativePtrCreatedByCtorMap::erase(iter); - auto* cobj = SE_THIS_OBJECT<${current_class.namespaced_class_name}>(s); - JSB_FREE(cobj); - } - #end if - #end if - #else - // destructor is skipped - #end if return true; } SE_BIND_FINALIZE_FUNC(js_${current_class.underlined_class_name}_finalize) #end if #if $current_class.rename_destructor is not None - static bool js_${current_class.underlined_class_name}_${current_class.rename_destructor}(se::State& s) // NOLINT(readability-identifier-naming) { - #if $current_class.is_ref_class - auto* cobj = SE_THIS_OBJECT<${current_class.namespaced_class_name}>(s); - cobj->release(); - #else - #if not $current_class.is_class_owned_by_cpp - auto iter = se::NonRefNativePtrCreatedByCtorMap::find(SE_THIS_OBJECT<${current_class.namespaced_class_name}>(s)); - if (iter != se::NonRefNativePtrCreatedByCtorMap::end()) - { - se::NonRefNativePtrCreatedByCtorMap::erase(iter); - auto* cobj = SE_THIS_OBJECT<${current_class.namespaced_class_name}>(s); - JSB_FREE(cobj); - } - #end if - #end if auto objIter = se::NativePtrToObjectMap::find(SE_THIS_OBJECT<${current_class.namespaced_class_name}>(s)); if(objIter != se::NativePtrToObjectMap::end()) { objIter->second->clearPrivateData(true); + objIter->second->decRef(); } return true; } SE_BIND_FUNC(js_${current_class.underlined_class_name}_${current_class.rename_destructor}) #end if -bool js_register_${generator.prefix}_${current_class.class_name}(se::Object* obj) // NOLINT(readability-identifier-naming) +bool js_register_${generator.prefix}_${current_class.nested_class_name}(se::Object* obj) // NOLINT(readability-identifier-naming) { #if has_constructor #if len($current_class.parents) > 0 - auto* cls = se::Class::create("${current_class.target_class_name}", obj, __jsb_${current_class.parents[0].underlined_class_name}_proto, _SE(js_${generator.prefix}_${current_class.class_name}_constructor)); + auto* cls = se::Class::create(${current_class.nested_class_array}, obj, __jsb_${current_class.parents[0].underlined_class_name}_proto, _SE(js_${generator.prefix}_${current_class.class_name}_constructor)); #else - auto* cls = se::Class::create("${current_class.target_class_name}", obj, nullptr, _SE(js_${generator.prefix}_${current_class.class_name}_constructor)); + auto* cls = se::Class::create(${current_class.nested_class_array}, obj, nullptr, _SE(js_${generator.prefix}_${current_class.class_name}_constructor)); #end if #else #if len($current_class.parents) > 0 - auto* cls = se::Class::create("${current_class.target_class_name}", obj, __jsb_${current_class.parents[0].underlined_class_name}_proto, nullptr); + auto* cls = se::Class::create(${current_class.nested_class_array}, obj, __jsb_${current_class.parents[0].underlined_class_name}_proto, nullptr); #else - auto* cls = se::Class::create("${current_class.target_class_name}", obj, nullptr, nullptr); + auto* cls = se::Class::create(${current_class.nested_class_array}, obj, nullptr, nullptr); #end if #end if #for m in public_fields - #if $current_class.should_export_field(m.name) - cls->defineProperty("${m.name}", _SE(${m.signature_name}_get_${m.name}), _SE(${m.signature_name}_set_${m.name})); + #if $current_class.should_export_field(m.name) and not m.is_static + cls->defineProperty("${m.export_name}", _SE(${m.signature_name}_get_${m.name}), _SE(${m.signature_name}_set_${m.name})); #end if #end for #for m in $current_class.getter_setter - #set tmp_getter = "nullptr" if m["getter"] is None else "_SE(" + m["getter"].signature_name + ")" - #set tmp_setter = "nullptr" if m["setter"] is None else "_SE(" + m["setter"].signature_name + ")" - cls->defineProperty("${m.name}", ${tmp_getter}, ${tmp_setter}); + #set tmp_getter = "nullptr" if m["getter"] is None else "_SE(" + m["getter"].signature_name + "_asGetter)" + #set tmp_setter = "nullptr" if m["setter"] is None else "_SE(" + m["setter"].signature_name + "_asSetter)" + cls->defineProperty(${m.name}, ${tmp_getter}, ${tmp_setter}); #end for #for m in methods #if not $current_class.skip_bind_function(m) #set fn = m['impl'] - cls->defineFunction("${m['name']}", _SE(${fn.signature_name})); + cls->defineFunction("${m['export_name']}", _SE(${fn.signature_name})); #end if #end for #if $generator.in_listed_extend_classed($current_class.class_name) and $has_constructor @@ -117,6 +83,14 @@ bool js_register_${generator.prefix}_${current_class.class_name}(se::Object* obj cls->defineStaticFunction("${m['name']}", _SE(${fn.signature_name})); #end for #end if +#set static_fields = list(filter(lambda m: $current_class.should_export_field(m.name) and m.is_static, public_fields)) +#if len(static_fields) > 0 + // static fields +#for m in static_fields + #set static_setter = "_SE("+m.signature_name+"_set_"+m.name+")" if not m.is_static_const else "nullptr" + cls->defineStaticProperty("${m.export_name}", _SE(${m.signature_name}_get_${m.name}), ${static_setter}); +#end for +#end if #if not $current_class.is_abstract cls->defineFinalizeFunction(_SE(js_${current_class.underlined_class_name}_finalize)); #end if @@ -129,6 +103,7 @@ bool js_register_${generator.prefix}_${current_class.class_name}(se::Object* obj #if $generator.in_listed_extend_classed($current_class.class_name) and not $current_class.is_abstract jsb_set_extend_property("${generator.target_ns}", "${current_class.target_class_name}"); #end if + se::ScriptEngine::getInstance()->clearException(); return true; } diff --git a/native/tools/bindings-generator/targets/spidermonkey/templates/sfunction.c b/native/tools/bindings-generator/targets/spidermonkey/templates/sfunction.c index e4e2d59d79..1e2d62d69f 100644 --- a/native/tools/bindings-generator/targets/spidermonkey/templates/sfunction.c +++ b/native/tools/bindings-generator/targets/spidermonkey/templates/sfunction.c @@ -51,9 +51,9 @@ static bool ${signature_name}(se::State& s) // NOLINT(readability-identifier-nam #if str($ret_type) != "void" #if $func_name.startswith("create") and $is_ref_class auto result = ${namespaced_class_name}::${func_name}($arg_list); - result->retain(); + result->addRef(); auto obj = se::Object::createObjectWithClass(__jsb_${underlined_class_name}_class); - obj->setPrivateData(result); + obj->setPrivateObject(se::make_shared_private_object(result)); s.rval().setObject(obj); #elif $func_name.startswith("getInstance") and $is_ref_class auto result = ${namespaced_class_name}::${func_name}($arg_list); diff --git a/native/tools/bindings-generator/targets/spidermonkey/templates/struct_constructor.c b/native/tools/bindings-generator/targets/spidermonkey/templates/struct_constructor.c index fabbc6ca55..35432e6d80 100644 --- a/native/tools/bindings-generator/targets/spidermonkey/templates/struct_constructor.c +++ b/native/tools/bindings-generator/targets/spidermonkey/templates/struct_constructor.c @@ -13,10 +13,13 @@ bool sevalue_to_native(const se::Value &from, ${namespaced_class_name} * to, se: } se::Value field; bool ok = true; +#for p in $parents + ok &= sevalue_to_native<${p.namespaced_class_name}>(from, to, ctx); +#end for #set arg_idx = 0 #for field in $public_fields #set field_type = field.ntype.to_string($generator) - json->getProperty("${field.name}", &field); + json->getProperty("${field.export_name}", &field, true); if(!field.isNullOrUndefined()) { ok &= sevalue_to_native(field, &(to->${field.name}), ctx); } @@ -35,33 +38,33 @@ static bool ${struct_constructor_name}(se::State& s) // NOLINT(readability-ident if(argc == 0) { - ${namespaced_class_name}* cobj = JSB_ALLOC(${namespaced_class_name}); - s.thisObject()->setPrivateData(cobj); - se::NonRefNativePtrCreatedByCtorMap::emplace(cobj); + auto *ptr = JSB_MAKE_PRIVATE_OBJECT(${namespaced_class_name}); + s.thisObject()->setPrivateObject(ptr); return true; } - #if len($public_fields) > 1 + #if len($public_fields) > 1 or len($parents) > 0 if(argc == 1 && args[0].isObject()) { se::Object *json = args[0].toObject(); se::Value field; - - ${namespaced_class_name}* cobj = JSB_ALLOC(${namespaced_class_name}); + auto *ptr = JSB_MAKE_PRIVATE_OBJECT(${namespaced_class_name}); + auto cobj = ptr->get<${namespaced_class_name}>(); ok &= sevalue_to_native(args[0], cobj, s.thisObject()); if(!ok) { - JSB_FREE(cobj); + delete ptr; SE_REPORT_ERROR("argument convertion error"); return false; } - - s.thisObject()->setPrivateData(cobj); - se::NonRefNativePtrCreatedByCtorMap::emplace(cobj); +#for p in $parents + sevalue_to_native<${p.namespaced_class_name}>(args[0], cobj, s.thisObject()); // skip ok +#end for + s.thisObject()->setPrivateObject(ptr); return true; } #end if - - ${namespaced_class_name}* cobj = JSB_ALLOC(${namespaced_class_name}); + auto *ptr = JSB_MAKE_PRIVATE_OBJECT(${namespaced_class_name}); + auto cobj = ptr->get<${namespaced_class_name}>(); #set arg_idx = 0 #for field in $public_fields #set field_type = field.ntype.to_string($generator) @@ -91,13 +94,11 @@ static bool ${struct_constructor_name}(se::State& s) // NOLINT(readability-ident #end for if(!ok) { - JSB_FREE(cobj); + delete ptr; SE_REPORT_ERROR("Argument convertion error"); return false; } - - s.thisObject()->setPrivateData(cobj); - se::NonRefNativePtrCreatedByCtorMap::emplace(cobj); + s.thisObject()->setPrivateObject(ptr); return true; } SE_BIND_CTOR(${struct_constructor_name}, __jsb_${underlined_class_name}_class, js_${underlined_class_name}_finalize) diff --git a/native/tools/simulator/frameworks/runtime-src/Classes/ide-support/RuntimeJsImpl.cpp b/native/tools/simulator/frameworks/runtime-src/Classes/ide-support/RuntimeJsImpl.cpp index 96d9b33531..3ddeb89105 100755 --- a/native/tools/simulator/frameworks/runtime-src/Classes/ide-support/RuntimeJsImpl.cpp +++ b/native/tools/simulator/frameworks/runtime-src/Classes/ide-support/RuntimeJsImpl.cpp @@ -39,20 +39,20 @@ #if (CC_CODE_IDE_DEBUG_SUPPORT > 0) - #include "runtime/ConfigParser.h" // config - #include "runtime/Runtime.h" - #include "runtime/FileServer.h" + #include "runtime/ConfigParser.h" // config #include "runtime/ConfigParser.h" + #include "runtime/FileServer.h" + #include "runtime/Runtime.h" // js - #include "cocos/bindings/jswrapper/SeApi.h" #include "cocos/bindings/auto/jsb_cocos_auto.h" + #include "cocos/bindings/jswrapper/SeApi.h" #include "cocos/bindings/manual/jsb_classtype.h" #include "cocos/bindings/manual/jsb_conversions.h" - #include "cocos/bindings/manual/jsb_module_register.h" #include "cocos/bindings/manual/jsb_global.h" + #include "cocos/bindings/manual/jsb_module_register.h" -static bool reloadScript(const string& file) { +static bool reloadScript(const string &file) { CC_LOG_DEBUG("------------------------------------------------"); CC_LOG_DEBUG("RELOAD Js FILE: %s", file.c_str()); CC_LOG_DEBUG("------------------------------------------------"); @@ -66,16 +66,16 @@ static bool reloadScript(const string& file) { return jsb_run_script(modulefile.c_str()); } -static bool runtime_FileUtils_addSearchPath(se::State& s) { - const auto& args = s.args(); +static bool runtime_FileUtils_addSearchPath(se::State &s) { + const auto & args = s.args(); int argc = (int)args.size(); bool ok = true; - cc::FileUtils* cobj = (cc::FileUtils*)s.nativeThisObject(); + cc::FileUtils *cobj = (cc::FileUtils *)s.nativeThisObject(); if (argc == 1 || argc == 2) { std::string arg0; bool arg1 = false; - ok &= seval_to_std_string(args[0], &arg0); + ok &= sevalue_to_native(args[0], &arg0); SE_PRECONDITION2(ok, false, "Error processing arguments"); if (argc == 2) { @@ -103,14 +103,14 @@ static bool runtime_FileUtils_addSearchPath(se::State& s) { } SE_BIND_FUNC(runtime_FileUtils_addSearchPath) -static bool runtime_FileUtils_setSearchPaths(se::State& s) { - const auto& args = s.args(); +static bool runtime_FileUtils_setSearchPaths(se::State &s) { + const auto & args = s.args(); int argc = (int)args.size(); bool ok = true; - cc::FileUtils* cobj = (cc::FileUtils*)s.nativeThisObject(); + cc::FileUtils *cobj = (cc::FileUtils *)s.nativeThisObject(); if (argc == 1) { std::vector vecPaths, writePaths; - ok &= seval_to_std_vector_string(args[0], &vecPaths); + ok &= sevalue_to_native(args[0], &vecPaths); SE_PRECONDITION2(ok, false, "Error processing arguments"); std::vector originPath; // for IOS platform. @@ -141,14 +141,14 @@ static bool runtime_FileUtils_setSearchPaths(se::State& s) { } SE_BIND_FUNC(runtime_FileUtils_setSearchPaths) -static bool register_FileUtils(se::Object* obj) { +static bool register_FileUtils(se::Object *obj) { __jsb_cc_FileUtils_proto->defineFunction("addSearchPath", _SE(runtime_FileUtils_addSearchPath)); __jsb_cc_FileUtils_proto->defineFunction("setSearchPaths", _SE(runtime_FileUtils_setSearchPaths)); return true; } -RuntimeJsImpl* RuntimeJsImpl::create() { - RuntimeJsImpl* instance = new RuntimeJsImpl(); +RuntimeJsImpl *RuntimeJsImpl::create() { + RuntimeJsImpl *instance = new RuntimeJsImpl(); return instance; } @@ -167,7 +167,7 @@ bool RuntimeJsImpl::initJsEnv() { jsb_enable_debugger("0.0.0.0", parser->getDebugPort(), parser->isWaitForConnect()); #endif - se->setExceptionCallback([](const char* location, const char* message, const char* stack) { + se->setExceptionCallback([](const char *location, const char *message, const char *stack) { // Send exception information to server like Tencent Bugly. }); @@ -184,11 +184,11 @@ bool RuntimeJsImpl::startWithDebugger() { return true; } -void RuntimeJsImpl::startScript(const std::string& path) { +void RuntimeJsImpl::startScript(const std::string &path) { loadScriptFile(path); } -void RuntimeJsImpl::onStartDebuger(const rapidjson::Document& dArgParse, rapidjson::Document& dReplyParse) { +void RuntimeJsImpl::onStartDebuger(const rapidjson::Document &dArgParse, rapidjson::Document &dReplyParse) { if (loadScriptFile(ConfigParser::getInstance()->getEntryFile())) { dReplyParse.AddMember("code", 0, dReplyParse.GetAllocator()); } else { @@ -196,17 +196,17 @@ void RuntimeJsImpl::onStartDebuger(const rapidjson::Document& dArgParse, rapidjs } } -void RuntimeJsImpl::onClearCompile(const rapidjson::Document& dArgParse, rapidjson::Document& dReplyParse) { +void RuntimeJsImpl::onClearCompile(const rapidjson::Document &dArgParse, rapidjson::Document &dReplyParse) { } -void RuntimeJsImpl::onPrecompile(const rapidjson::Document& dArgParse, rapidjson::Document& dReplyParse) { +void RuntimeJsImpl::onPrecompile(const rapidjson::Document &dArgParse, rapidjson::Document &dReplyParse) { } -void RuntimeJsImpl::onReload(const rapidjson::Document& dArgParse, rapidjson::Document& dReplyParse) { +void RuntimeJsImpl::onReload(const rapidjson::Document &dArgParse, rapidjson::Document &dReplyParse) { if (dArgParse.HasMember("modulefiles")) { - auto& allocator = dReplyParse.GetAllocator(); + auto & allocator = dReplyParse.GetAllocator(); rapidjson::Value bodyvalue(rapidjson::kObjectType); - const rapidjson::Value& objectfiles = dArgParse["modulefiles"]; + const rapidjson::Value &objectfiles = dArgParse["modulefiles"]; for (rapidjson::SizeType i = 0; i < objectfiles.Size(); i++) { if (!reloadScript(objectfiles[i].GetString())) { bodyvalue.AddMember(rapidjson::Value(objectfiles[i].GetString(), allocator), rapidjson::Value(1), allocator); @@ -223,7 +223,7 @@ void RuntimeJsImpl::onReload(const rapidjson::Document& dArgParse, rapidjson::Do dReplyParse.AddMember("code", 0, dReplyParse.GetAllocator()); } -void RuntimeJsImpl::onRemove(const std::string& filename) { +void RuntimeJsImpl::onRemove(const std::string &filename) { } void RuntimeJsImpl::end() { @@ -235,7 +235,7 @@ void RuntimeJsImpl::end() { RuntimeJsImpl::RuntimeJsImpl() { } -bool RuntimeJsImpl::loadScriptFile(const std::string& path) { +bool RuntimeJsImpl::loadScriptFile(const std::string &path) { std::string filepath = path; if (filepath.empty()) { filepath = ConfigParser::getInstance()->getEntryFile(); diff --git a/native/tools/simulator/libsimulator/CMakeLists.txt b/native/tools/simulator/libsimulator/CMakeLists.txt index fa24289d05..70c300bf6b 100644 --- a/native/tools/simulator/libsimulator/CMakeLists.txt +++ b/native/tools/simulator/libsimulator/CMakeLists.txt @@ -182,6 +182,7 @@ if(WINDOWS) ${CMAKE_CURRENT_LIST_DIR}/proj.win32 ${CMAKE_CURRENT_LIST_DIR}/../simulator/frameworks/runtime-src/proj.win32 PRIVATE ${CMAKE_CURRENT_LIST_DIR}/../../../external/win32/include + PRIVATE ${CMAKE_CURRENT_LIST_DIR}/../../../external/win32/include/v8 PRIVATE ${CMAKE_CURRENT_LIST_DIR}/../../../external/win32/include/zlib ) if(COMMAND target_precompile_headers) @@ -190,6 +191,10 @@ if(WINDOWS) ) endif() target_compile_options(cocos2d PUBLIC /MP) +elseif(APPLE) + target_include_directories(${libsimulator_name} PRIVATE + PRIVATE ${CMAKE_CURRENT_LIST_DIR}/../../../external/mac/include/v8 + ) endif() target_include_directories(${libsimulator_name} diff --git a/native/tools/simulator/libsimulator/lib/PlayerMenuServiceProtocol.h b/native/tools/simulator/libsimulator/lib/PlayerMenuServiceProtocol.h index da0104bee5..a1e46fc5d2 100644 --- a/native/tools/simulator/libsimulator/lib/PlayerMenuServiceProtocol.h +++ b/native/tools/simulator/libsimulator/lib/PlayerMenuServiceProtocol.h @@ -31,7 +31,7 @@ #include "PlayerMacros.h" #include "PlayerServiceProtocol.h" #include "SimulatorExport.h" -#include "cocos/base/Ref.h" +#include "cocos/base/RefCounted.h" PLAYER_NS_BEGIN @@ -40,21 +40,21 @@ PLAYER_NS_BEGIN #define kPlayerCtrlModifyKey "ctrl" #define kPlayerAltModifyKey "alt" -class CC_LIBSIM_DLL PlayerMenuItem : public cc::Ref { +class CC_LIBSIM_DLL PlayerMenuItem : public cc::RefCounted { public: virtual ~PlayerMenuItem(); std::string getMenuId() const; std::string getTitle() const; - int getOrder() const; - bool isGroup() const; - bool isEnabled() const; - bool isChecked() const; + int getOrder() const; + bool isGroup() const; + bool isEnabled() const; + bool isChecked() const; std::string getShortcut() const; - virtual void setTitle(const std::string &title) = 0; - virtual void setEnabled(bool enabled) = 0; - virtual void setChecked(bool checked) = 0; + virtual void setTitle(const std::string &title) = 0; + virtual void setEnabled(bool enabled) = 0; + virtual void setChecked(bool checked) = 0; virtual void setShortcut(const std::string &shortcut) = 0; protected: @@ -62,11 +62,11 @@ protected: std::string _menuId; std::string _title; - int _order; - bool _isGroup; - bool _isEnabled; - bool _isChecked; // ignored when isGroup = true - std::string _shortcut; // ignored when isGroup = true + int _order; + bool _isGroup; + bool _isEnabled; + bool _isChecked; // ignored when isGroup = true + std::string _shortcut; // ignored when isGroup = true }; class PlayerMenuServiceProtocol : public PlayerServiceProtocol { @@ -76,12 +76,12 @@ public: virtual PlayerMenuItem *addItem(const std::string &menuId, const std::string &title, const std::string &parentId, - int order = MAX_ORDER) = 0; + int order = MAX_ORDER) = 0; virtual PlayerMenuItem *addItem(const std::string &menuId, - const std::string &title) = 0; - virtual PlayerMenuItem *getItem(const std::string &menuId) = 0; - virtual bool removeItem(const std::string &menuId) = 0; - virtual void setMenuBarEnabled(bool enabled) = 0; + const std::string &title) = 0; + virtual PlayerMenuItem *getItem(const std::string &menuId) = 0; + virtual bool removeItem(const std::string &menuId) = 0; + virtual void setMenuBarEnabled(bool enabled) = 0; }; PLAYER_NS_END diff --git a/native/tools/simulator/libsimulator/lib/PlayerTaskServiceProtocol.h b/native/tools/simulator/libsimulator/lib/PlayerTaskServiceProtocol.h index cc0b5a44a4..597579c579 100644 --- a/native/tools/simulator/libsimulator/lib/PlayerTaskServiceProtocol.h +++ b/native/tools/simulator/libsimulator/lib/PlayerTaskServiceProtocol.h @@ -30,14 +30,14 @@ #include "PlayerMacros.h" #include "PlayerServiceProtocol.h" -#include "cocos/base/Ref.h" +#include "cocos/base/RefCounted.h" PLAYER_NS_BEGIN -class PlayerTask : public cc::Ref { +class PlayerTask : public cc::RefCounted { public: - static const int STATE_IDLE = 0; - static const int STATE_RUNNING = 1; + static const int STATE_IDLE = 0; + static const int STATE_RUNNING = 1; static const int STATE_COMPLETED = 2; virtual ~PlayerTask(){}; @@ -46,15 +46,15 @@ public: std::string getExecutePath() const; std::string getCommandLineArguments() const; std::string getOutput() const; - int getState() const; - bool isIdle() const; - bool isRunning() const; - bool isCompleted() const; - float getLifetime() const; - int getResultCode() const; + int getState() const; + bool isIdle() const; + bool isRunning() const; + bool isCompleted() const; + float getLifetime() const; + int getResultCode() const; - virtual bool run() = 0; - virtual void stop() = 0; + virtual bool run() = 0; + virtual void stop() = 0; virtual void runInTerminal() = 0; protected: @@ -66,9 +66,9 @@ protected: std::string _executePath; std::string _commandLineArguments; std::string _output; - float _lifetime; - int _state; - int _resultCode; + float _lifetime; + int _state; + int _resultCode; }; class PlayerTaskServiceProtocol : public PlayerServiceProtocol { @@ -76,8 +76,8 @@ public: virtual PlayerTask *createTask(const std::string &name, const std::string &executePath, const std::string &commandLineArguments) = 0; - virtual PlayerTask *getTask(const std::string &name) = 0; - virtual void removeTask(const std::string &name) = 0; + virtual PlayerTask *getTask(const std::string &name) = 0; + virtual void removeTask(const std::string &name) = 0; }; PLAYER_NS_END diff --git a/native/tools/simulator/libsimulator/lib/network/CCHTTPRequest.cpp b/native/tools/simulator/libsimulator/lib/network/CCHTTPRequest.cpp index 17daa601c3..27e899b1fd 100755 --- a/native/tools/simulator/libsimulator/lib/network/CCHTTPRequest.cpp +++ b/native/tools/simulator/libsimulator/lib/network/CCHTTPRequest.cpp @@ -30,32 +30,31 @@ #if CC_LUA_ENGINE_ENABLED > 0 extern "C" { -#include "lua.h" + #include "lua.h" } -#include "CCLuaEngine.h" + #include "CCLuaEngine.h" #endif #include - +#include "cocos/base/DeferredReleasePool.h" NS_CC_EXTRA_BEGIN unsigned int HTTPRequest::s_id = 0; HTTPRequest *HTTPRequest::createWithUrl(HTTPRequestDelegate *delegate, - const char *url, - int method) -{ + const char * url, + int method) { HTTPRequest *request = new HTTPRequest(); request->initWithDelegate(delegate, url, method); - request->autorelease(); + request->addRef(); + cc::DeferredReleasePool::add(request); return request; } #if CC_LUA_ENGINE_ENABLED > 0 HTTPRequest *HTTPRequest::createWithUrlLua(LUA_FUNCTION listener, - const char *url, - int method) -{ + const char * url, + int method) { HTTPRequest *request = new HTTPRequest(); request->initWithListener(listener, url, method); request->autorelease(); @@ -63,22 +62,19 @@ HTTPRequest *HTTPRequest::createWithUrlLua(LUA_FUNCTION listener, } #endif -bool HTTPRequest::initWithDelegate(HTTPRequestDelegate *delegate, const char *url, int method) -{ +bool HTTPRequest::initWithDelegate(HTTPRequestDelegate *delegate, const char *url, int method) { _delegate = delegate; return initWithUrl(url, method); } #if CC_LUA_ENGINE_ENABLED > 0 -bool HTTPRequest::initWithListener(LUA_FUNCTION listener, const char *url, int method) -{ +bool HTTPRequest::initWithListener(LUA_FUNCTION listener, const char *url, int method) { _listener = listener; return initWithUrl(url, method); } #endif -bool HTTPRequest::initWithUrl(const char *url, int method) -{ +bool HTTPRequest::initWithUrl(const char *url, int method) { CCASSERT(url, "HTTPRequest::initWithUrl() - invalid url"); _curl = curl_easy_init(); curl_easy_setopt(_curl, CURLOPT_URL, url); @@ -87,22 +83,19 @@ bool HTTPRequest::initWithUrl(const char *url, int method) curl_easy_setopt(_curl, CURLOPT_TIMEOUT, DEFAULT_TIMEOUT); curl_easy_setopt(_curl, CURLOPT_NOSIGNAL, 1L); - if (method == kCCHTTPRequestMethodPOST) - { + if (method == kCCHTTPRequestMethodPOST) { curl_easy_setopt(_curl, CURLOPT_POST, 1L); curl_easy_setopt(_curl, CURLOPT_COPYPOSTFIELDS, ""); } - + ++s_id; // CCLOG("HTTPRequest[0x%04x] - create request with url: %s", s_id, url); return true; } -HTTPRequest::~HTTPRequest(void) -{ +HTTPRequest::~HTTPRequest(void) { cleanup(); - if (_listener) - { + if (_listener) { #if (CC_LUA_ENGINE_ENABLED > 0) LuaEngine::getInstance()->removeScriptHandler(_listener); #endif @@ -110,34 +103,29 @@ HTTPRequest::~HTTPRequest(void) // CCLOG("HTTPRequest[0x%04x] - request removed", s_id); } -void HTTPRequest::setRequestUrl(const char *url) -{ +void HTTPRequest::setRequestUrl(const char *url) { CCASSERT(url, "HTTPRequest::setRequestUrl() - invalid url"); _url = url; curl_easy_setopt(_curl, CURLOPT_URL, _url.c_str()); } -const string HTTPRequest::getRequestUrl(void) -{ +const string HTTPRequest::getRequestUrl(void) { return _url; } -void HTTPRequest::addRequestHeader(const char *header) -{ +void HTTPRequest::addRequestHeader(const char *header) { CCASSERT(_state == kCCHTTPRequestStateIdle, "HTTPRequest::addRequestHeader() - request not idle"); CCASSERT(header, "HTTPRequest::addRequestHeader() - invalid header"); _headers.push_back(string(header)); } -void HTTPRequest::addPOSTValue(const char *key, const char *value) -{ +void HTTPRequest::addPOSTValue(const char *key, const char *value) { CCASSERT(_state == kCCHTTPRequestStateIdle, "HTTPRequest::addPOSTValue() - request not idle"); CCASSERT(key, "HTTPRequest::addPOSTValue() - invalid key"); _postFields[string(key)] = string(value ? value : ""); } -void HTTPRequest::setPOSTData(const char *data) -{ +void HTTPRequest::setPOSTData(const char *data) { CCASSERT(_state == kCCHTTPRequestStateIdle, "HTTPRequest::setPOSTData() - request not idle"); CCASSERT(data, "HTTPRequest::setPOSTData() - invalid post data"); _postFields.clear(); @@ -145,69 +133,61 @@ void HTTPRequest::setPOSTData(const char *data) curl_easy_setopt(_curl, CURLOPT_COPYPOSTFIELDS, data); } -void HTTPRequest::addFormFile(const char *name, const char *filePath, const char *contentType) -{ - curl_formadd(&_formPost, &_lastPost, - CURLFORM_COPYNAME, name, - CURLFORM_FILE, filePath, - CURLFORM_CONTENTTYPE, contentType, - CURLFORM_END); - //CCLOG("addFormFile %s %s %s", name, filePath, contentType); +void HTTPRequest::addFormFile(const char *name, const char *filePath, const char *contentType) { + curl_formadd(&_formPost, &_lastPost, + CURLFORM_COPYNAME, name, + CURLFORM_FILE, filePath, + CURLFORM_CONTENTTYPE, contentType, + CURLFORM_END); + //CCLOG("addFormFile %s %s %s", name, filePath, contentType); } -void HTTPRequest::addFormContents(const char *name, const char *value) -{ - curl_formadd(&_formPost, &_lastPost, - CURLFORM_COPYNAME, name, - CURLFORM_COPYCONTENTS, value, - CURLFORM_END); - //CCLOG("addFormContents %s %s", name, value); +void HTTPRequest::addFormContents(const char *name, const char *value) { + curl_formadd(&_formPost, &_lastPost, + CURLFORM_COPYNAME, name, + CURLFORM_COPYCONTENTS, value, + CURLFORM_END); + //CCLOG("addFormContents %s %s", name, value); } -void HTTPRequest::setCookieString(const char *cookie) -{ +void HTTPRequest::setCookieString(const char *cookie) { CCASSERT(_state == kCCHTTPRequestStateIdle, "HTTPRequest::setAcceptEncoding() - request not idle"); curl_easy_setopt(_curl, CURLOPT_COOKIE, cookie ? cookie : ""); } -const string HTTPRequest::getCookieString(void) -{ +const string HTTPRequest::getCookieString(void) { CCASSERT(_state == kCCHTTPRequestStateCompleted, "HTTPRequest::getResponseData() - request not completed"); return _responseCookies; } -void HTTPRequest::setAcceptEncoding(int acceptEncoding) -{ +void HTTPRequest::setAcceptEncoding(int acceptEncoding) { CCASSERT(_state == kCCHTTPRequestStateIdle, "HTTPRequest::setAcceptEncoding() - request not idle"); - switch (acceptEncoding) - { + switch (acceptEncoding) { case kCCHTTPRequestAcceptEncodingGzip: curl_easy_setopt(_curl, CURLOPT_ACCEPT_ENCODING, "gzip"); break; - + case kCCHTTPRequestAcceptEncodingDeflate: curl_easy_setopt(_curl, CURLOPT_ACCEPT_ENCODING, "deflate"); break; - + default: curl_easy_setopt(_curl, CURLOPT_ACCEPT_ENCODING, "identity"); } } -void HTTPRequest::setTimeout(int timeout) -{ +void HTTPRequest::setTimeout(int timeout) { CCASSERT(_state == kCCHTTPRequestStateIdle, "HTTPRequest::setTimeout() - request not idle"); curl_easy_setopt(_curl, CURLOPT_CONNECTTIMEOUT, timeout); curl_easy_setopt(_curl, CURLOPT_TIMEOUT, timeout); } -bool HTTPRequest::start(void) -{ +bool HTTPRequest::start(void) { CCASSERT(_state == kCCHTTPRequestStateIdle, "HTTPRequest::start() - request not idle"); - _state = kCCHTTPRequestStateInProgress; + _state = kCCHTTPRequestStateInProgress; _curlState = kCCHTTPRequestCURLStateBusy; - retain(); + addRef(); curl_easy_setopt(_curl, CURLOPT_HTTP_CONTENT_DECODING, 1); curl_easy_setopt(_curl, CURLOPT_WRITEFUNCTION, writeDataCURL); @@ -221,73 +201,64 @@ bool HTTPRequest::start(void) #ifdef _WINDOWS_ -#if (CC_PLATFORM == CC_PLATFORM_WP8) || (CC_PLATFORM == CC_PLATFORM_WINRT) - std::thread worker(requestCURL, this); - worker.detach(); + #if (CC_PLATFORM == CC_PLATFORM_WP8) || (CC_PLATFORM == CC_PLATFORM_WINRT) + std::thread worker(requestCURL, this); + worker.detach(); -#else - CreateThread(NULL, // default security attributes - 0, // use default stack size - requestCURL, // thread function name - this, // argument to thread function - 0, // use default creation flags + #else + CreateThread(NULL, // default security attributes + 0, // use default stack size + requestCURL, // thread function name + this, // argument to thread function + 0, // use default creation flags NULL); -#endif // CC_PLATFORM == CC_PLATFORM_WP8 + #endif // CC_PLATFORM == CC_PLATFORM_WP8 #else pthread_create(&_thread, NULL, requestCURL, this); pthread_detach(_thread); #endif -// Director::getInstance()->getScheduler()->scheduleUpdate(this, 0, false); + // Director::getInstance()->getScheduler()->scheduleUpdate(this, 0, false); // CCLOG("HTTPRequest[0x%04x] - request start", s_id); return true; } -void HTTPRequest::cancel(void) -{ +void HTTPRequest::cancel(void) { _delegate = NULL; - if (_state == kCCHTTPRequestStateIdle || _state == kCCHTTPRequestStateInProgress) - { + if (_state == kCCHTTPRequestStateIdle || _state == kCCHTTPRequestStateInProgress) { _state = kCCHTTPRequestStateCancelled; } } -int HTTPRequest::getState(void) -{ +int HTTPRequest::getState(void) { return _state; } -int HTTPRequest::getResponseStatusCode(void) -{ +int HTTPRequest::getResponseStatusCode(void) { CCASSERT(_state == kCCHTTPRequestStateCompleted, "Request not completed"); return _responseCode; } -const HTTPRequestHeaders &HTTPRequest::getResponseHeaders(void) -{ +const HTTPRequestHeaders &HTTPRequest::getResponseHeaders(void) { CCASSERT(_state == kCCHTTPRequestStateCompleted, "HTTPRequest::getResponseHeaders() - request not completed"); return _responseHeaders; } -const string HTTPRequest::getResponseHeadersString() -{ +const string HTTPRequest::getResponseHeadersString() { string buf; - for (HTTPRequestHeadersIterator it = _responseHeaders.begin(); it != _responseHeaders.end(); ++it) - { + for (HTTPRequestHeadersIterator it = _responseHeaders.begin(); it != _responseHeaders.end(); ++it) { buf.append(*it); } return buf; } -const string HTTPRequest::getResponseString(void) -{ +const string HTTPRequest::getResponseString(void) { CCASSERT(_state == kCCHTTPRequestStateCompleted, "HTTPRequest::getResponseString() - request not completed"); - return string(_responseBuffer ? static_cast(_responseBuffer) : ""); + return string(_responseBuffer ? static_cast(_responseBuffer) : ""); } -void *HTTPRequest::getResponseData(void) -{ +void *HTTPRequest::getResponseData(void) { CCASSERT(_state == kCCHTTPRequestStateCompleted, "HTTPRequest::getResponseData() - request not completed"); void *buff = malloc(_responseDataLength); memcpy(buff, _responseBuffer, _responseDataLength); @@ -295,77 +266,65 @@ void *HTTPRequest::getResponseData(void) } #if CC_LUA_ENGINE_ENABLED > 0 -LUA_STRING HTTPRequest::getResponseDataLua(void) -{ +LUA_STRING HTTPRequest::getResponseDataLua(void) { CCASSERT(_state == kCCHTTPRequestStateCompleted, "HTTPRequest::getResponseDataLua() - request not completed"); LuaStack *stack = LuaEngine::getInstance()->getLuaStack(); stack->clean(); - stack->pushString(static_cast(_responseBuffer), (int)_responseDataLength); + stack->pushString(static_cast(_responseBuffer), (int)_responseDataLength); return 1; } #endif -int HTTPRequest::getResponseDataLength(void) -{ +int HTTPRequest::getResponseDataLength(void) { CCASSERT(_state == kCCHTTPRequestStateCompleted, "Request not completed"); return (int)_responseDataLength; } -size_t HTTPRequest::saveResponseData(const char *filename) -{ +size_t HTTPRequest::saveResponseData(const char *filename) { CCASSERT(_state == kCCHTTPRequestStateCompleted, "HTTPRequest::saveResponseData() - request not completed"); - + FILE *fp = fopen(filename, "wb"); CCASSERT(fp, "HTTPRequest::saveResponseData() - open file failure"); - + size_t writedBytes = _responseDataLength; - if (writedBytes > 0) - { + if (writedBytes > 0) { fwrite(_responseBuffer, _responseDataLength, 1, fp); } fclose(fp); return writedBytes; } -int HTTPRequest::getErrorCode(void) -{ +int HTTPRequest::getErrorCode(void) { return _errorCode; } -const string HTTPRequest::getErrorMessage(void) -{ +const string HTTPRequest::getErrorMessage(void) { return _errorMessage; } -HTTPRequestDelegate* HTTPRequest::getDelegate(void) -{ +HTTPRequestDelegate *HTTPRequest::getDelegate(void) { return _delegate; } -void HTTPRequest::checkCURLState(float dt) -{ +void HTTPRequest::checkCURLState(float dt) { CC_UNUSED_PARAM(dt); - if (_curlState != kCCHTTPRequestCURLStateBusy) - { -// Director::getInstance()->getScheduler()->unscheduleAllForTarget(this); + if (_curlState != kCCHTTPRequestCURLStateBusy) { + // Director::getInstance()->getScheduler()->unscheduleAllForTarget(this); release(); } } -void HTTPRequest::update(float dt) -{ - if (_state == kCCHTTPRequestStateInProgress) - { +void HTTPRequest::update(float dt) { + if (_state == kCCHTTPRequestStateInProgress) { #if CC_LUA_ENGINE_ENABLED > 0 - if (_listener) - { + if (_listener) { LuaValueDict dict; - - dict["name"] = LuaValue::stringValue("progress"); - dict["total"] = LuaValue::intValue((int)_dltotal); + + dict["name"] = LuaValue::stringValue("progress"); + dict["total"] = LuaValue::intValue((int)_dltotal); dict["dltotal"] = LuaValue::intValue((int)_dlnow); dict["request"] = LuaValue::ccobjectValue(this, "HTTPRequest"); - + LuaStack *stack = LuaEngine::getInstance()->getLuaStack(); stack->clean(); stack->pushLuaValueDict(dict); @@ -374,43 +333,37 @@ void HTTPRequest::update(float dt) #endif return; } - -// Director::getInstance()->getScheduler()->unscheduleAllForTarget(this); - if (_curlState != kCCHTTPRequestCURLStateIdle) - { -// Director::getInstance()->getScheduler()->schedule(schedule_selector(HTTPRequest::checkCURLState), this, 0, false); + + // Director::getInstance()->getScheduler()->unscheduleAllForTarget(this); + if (_curlState != kCCHTTPRequestCURLStateIdle) { + // Director::getInstance()->getScheduler()->schedule(schedule_selector(HTTPRequest::checkCURLState), this, 0, false); } - if (_state == kCCHTTPRequestStateCompleted) - { + if (_state == kCCHTTPRequestStateCompleted) { // CCLOG("HTTPRequest[0x%04x] - request completed", s_id); if (_delegate) _delegate->requestFinished(this); - } - else - { + } else { // CCLOG("HTTPRequest[0x%04x] - request failed", s_id); if (_delegate) _delegate->requestFailed(this); } #if CC_LUA_ENGINE_ENABLED > 0 - if (_listener) - { + if (_listener) { LuaValueDict dict; - switch (_state) - { + switch (_state) { case kCCHTTPRequestStateCompleted: dict["name"] = LuaValue::stringValue("completed"); break; - + case kCCHTTPRequestStateCancelled: dict["name"] = LuaValue::stringValue("cancelled"); break; - + case kCCHTTPRequestStateFailed: dict["name"] = LuaValue::stringValue("failed"); break; - + default: dict["name"] = LuaValue::stringValue("unknown"); } @@ -425,38 +378,33 @@ void HTTPRequest::update(float dt) // instance callback -void HTTPRequest::onRequest(void) -{ - if (_postFields.size() > 0) - { +void HTTPRequest::onRequest(void) { + if (_postFields.size() > 0) { curl_easy_setopt(_curl, CURLOPT_POST, 1L); stringbuf buf; - for (Fields::iterator it = _postFields.begin(); it != _postFields.end(); ++it) - { + for (Fields::iterator it = _postFields.begin(); it != _postFields.end(); ++it) { char *part = curl_easy_escape(_curl, it->first.c_str(), 0); buf.sputn(part, strlen(part)); buf.sputc('='); curl_free(part); - + part = curl_easy_escape(_curl, it->second.c_str(), 0); buf.sputn(part, strlen(part)); curl_free(part); - + buf.sputc('&'); } curl_easy_setopt(_curl, CURLOPT_COPYPOSTFIELDS, buf.str().c_str()); } struct curl_slist *chunk = NULL; - for (HTTPRequestHeadersIterator it = _headers.begin(); it != _headers.end(); ++it) - { + for (HTTPRequestHeadersIterator it = _headers.begin(); it != _headers.end(); ++it) { chunk = curl_slist_append(chunk, (*it).c_str()); } - if (_formPost) - { - curl_easy_setopt(_curl, CURLOPT_HTTPPOST, _formPost); - } + if (_formPost) { + curl_easy_setopt(_curl, CURLOPT_HTTPPOST, _formPost); + } curl_slist *cookies = NULL; curl_easy_setopt(_curl, CURLOPT_HTTPHEADER, chunk); @@ -464,12 +412,10 @@ void HTTPRequest::onRequest(void) curl_easy_getinfo(_curl, CURLINFO_RESPONSE_CODE, &_responseCode); curl_easy_getinfo(_curl, CURLINFO_COOKIELIST, &cookies); - if (cookies) - { + if (cookies) { struct curl_slist *nc = cookies; - stringbuf buf; - while (nc) - { + stringbuf buf; + while (nc) { buf.sputn(nc->data, strlen(nc->data)); buf.sputc('\n'); nc = nc->next; @@ -481,65 +427,57 @@ void HTTPRequest::onRequest(void) curl_easy_cleanup(_curl); _curl = NULL; - if (_formPost) - { - curl_formfree(_formPost); - _formPost = NULL; - } + if (_formPost) { + curl_formfree(_formPost); + _formPost = NULL; + } curl_slist_free_all(chunk); - - _errorCode = code; + + _errorCode = code; _errorMessage = (code == CURLE_OK) ? "" : curl_easy_strerror(code); - _state = (code == CURLE_OK) ? kCCHTTPRequestStateCompleted : kCCHTTPRequestStateFailed; - _curlState = kCCHTTPRequestCURLStateClosed; + _state = (code == CURLE_OK) ? kCCHTTPRequestStateCompleted : kCCHTTPRequestStateFailed; + _curlState = kCCHTTPRequestCURLStateClosed; } -size_t HTTPRequest::onWriteData(void *buffer, size_t bytes) -{ - if (_responseDataLength + bytes + 1 > _responseBufferLength) - { +size_t HTTPRequest::onWriteData(void *buffer, size_t bytes) { + if (_responseDataLength + bytes + 1 > _responseBufferLength) { _responseBufferLength += BUFFER_CHUNK_SIZE; _responseBuffer = realloc(_responseBuffer, _responseBufferLength); } - memcpy(static_cast(_responseBuffer) + _responseDataLength, buffer, bytes); + memcpy(static_cast(_responseBuffer) + _responseDataLength, buffer, bytes); _responseDataLength += bytes; - static_cast(_responseBuffer)[_responseDataLength] = 0; + static_cast(_responseBuffer)[_responseDataLength] = 0; return bytes; } -size_t HTTPRequest::onWriteHeader(void *buffer, size_t bytes) -{ - char *headerBuffer = new char[bytes + 1]; +size_t HTTPRequest::onWriteHeader(void *buffer, size_t bytes) { + char *headerBuffer = new char[bytes + 1]; headerBuffer[bytes] = 0; - memcpy(headerBuffer, buffer, bytes); + memcpy(headerBuffer, buffer, bytes); _responseHeaders.push_back(string(headerBuffer)); - delete []headerBuffer; + delete[] headerBuffer; return bytes; } -int HTTPRequest::onProgress(double dltotal, double dlnow, double ultotal, double ulnow) -{ +int HTTPRequest::onProgress(double dltotal, double dlnow, double ultotal, double ulnow) { _dltotal = dltotal; - _dlnow = dlnow; + _dlnow = dlnow; _ultotal = ultotal; - _ulnow = ulnow; - - return _state == kCCHTTPRequestStateCancelled ? 1: 0; + _ulnow = ulnow; + + return _state == kCCHTTPRequestStateCancelled ? 1 : 0; } -void HTTPRequest::cleanup(void) -{ - _state = kCCHTTPRequestStateCleared; +void HTTPRequest::cleanup(void) { + _state = kCCHTTPRequestStateCleared; _responseBufferLength = 0; - _responseDataLength = 0; - if (_responseBuffer) - { + _responseDataLength = 0; + if (_responseBuffer) { free(_responseBuffer); _responseBuffer = NULL; } - if (_curl) - { + if (_curl) { curl_easy_cleanup(_curl); _curl = NULL; } @@ -548,32 +486,27 @@ void HTTPRequest::cleanup(void) // curl callback #ifdef _WINDOWS_ -DWORD WINAPI HTTPRequest::requestCURL(LPVOID userdata) -{ - static_cast(userdata)->onRequest(); +DWORD WINAPI HTTPRequest::requestCURL(LPVOID userdata) { + static_cast(userdata)->onRequest(); return 0; } -#else // _WINDOWS_ -void *HTTPRequest::requestCURL(void *userdata) -{ - static_cast(userdata)->onRequest(); +#else // _WINDOWS_ +void *HTTPRequest::requestCURL(void *userdata) { + static_cast(userdata)->onRequest(); return NULL; } #endif // _WINDOWS_ -size_t HTTPRequest::writeDataCURL(void *buffer, size_t size, size_t nmemb, void *userdata) -{ - return static_cast(userdata)->onWriteData(buffer, size *nmemb); +size_t HTTPRequest::writeDataCURL(void *buffer, size_t size, size_t nmemb, void *userdata) { + return static_cast(userdata)->onWriteData(buffer, size * nmemb); } -size_t HTTPRequest::writeHeaderCURL(void *buffer, size_t size, size_t nmemb, void *userdata) -{ - return static_cast(userdata)->onWriteHeader(buffer, size *nmemb); +size_t HTTPRequest::writeHeaderCURL(void *buffer, size_t size, size_t nmemb, void *userdata) { + return static_cast(userdata)->onWriteHeader(buffer, size * nmemb); } -int HTTPRequest::progressCURL(void *userdata, double dltotal, double dlnow, double ultotal, double ulnow) -{ - return static_cast(userdata)->onProgress(dltotal, dlnow, ultotal, ulnow); +int HTTPRequest::progressCURL(void *userdata, double dltotal, double dlnow, double ultotal, double ulnow) { + return static_cast(userdata)->onProgress(dltotal, dlnow, ultotal, ulnow); } NS_CC_EXTRA_END diff --git a/native/tools/simulator/libsimulator/lib/network/CCHTTPRequest.h b/native/tools/simulator/libsimulator/lib/network/CCHTTPRequest.h index bed850b9d2..5a646cd004 100644 --- a/native/tools/simulator/libsimulator/lib/network/CCHTTPRequest.h +++ b/native/tools/simulator/libsimulator/lib/network/CCHTTPRequest.h @@ -26,7 +26,7 @@ #ifndef __CC_HTTP_REQUEST_H_ #define __CC_HTTP_REQUEST_H_ -#include "cocos/base/Ref.h" +#include "cocos/base/RefCounted.h" #include "cocos2dx_extra.h" #include "network/CCHTTPRequestDelegate.h" @@ -40,11 +40,11 @@ #include #endif -#include "curl/curl.h" -#include #include +#include #include #include +#include "curl/curl.h" using namespace std; @@ -68,19 +68,19 @@ NS_CC_EXTRA_BEGIN #define kCCHTTPRequestCURLStateBusy 1 #define kCCHTTPRequestCURLStateClosed 2 -typedef vector HTTPRequestHeaders; +typedef vector HTTPRequestHeaders; typedef HTTPRequestHeaders::iterator HTTPRequestHeadersIterator; -class HTTPRequest : public cc::Ref { +class HTTPRequest : public cc::RefCounted { public: static HTTPRequest *createWithUrl(HTTPRequestDelegate *delegate, - const char *url, - int method = kCCHTTPRequestMethodGET); + const char * url, + int method = kCCHTTPRequestMethodGET); #if CC_LUA_ENGINE_ENABLED > 0 static HTTPRequest *createWithUrlLua(LUA_FUNCTION listener, - const char *url, - int method = kCCHTTPRequestMethodGET); + const char * url, + int method = kCCHTTPRequestMethodGET); #endif ~HTTPRequest(void); @@ -104,7 +104,7 @@ public: void addFormContents(const char *name, const char *value); /** @brief Set/Get cookie string. */ - void setCookieString(const char *cookie); + void setCookieString(const char *cookie); const string getCookieString(void); /** @brief Set accept encoding. */ @@ -127,7 +127,7 @@ public: /** @brief Return HTTP response headers. */ const HTTPRequestHeaders &getResponseHeaders(void); - const string getResponseHeadersString(void); + const string getResponseHeadersString(void); /** @brief Returns the contents of the result. */ const string getResponseString(void); @@ -155,7 +155,7 @@ public: HTTPRequestDelegate *getDelegate(void); /** @brief timer function. */ - void checkCURLState(float dt); + void checkCURLState(float dt); virtual void update(float dt); private: @@ -183,36 +183,36 @@ private: bool initWithUrl(const char *url, int method); enum { - DEFAULT_TIMEOUT = 10, // 10 seconds + DEFAULT_TIMEOUT = 10, // 10 seconds BUFFER_CHUNK_SIZE = 32768, // 32 KB }; - static unsigned int s_id; - string _url; + static unsigned int s_id; + string _url; HTTPRequestDelegate *_delegate; - int _listener; - int _curlState; + int _listener; + int _curlState; - CURL *_curl; + CURL * _curl; curl_httppost *_formPost; curl_httppost *_lastPost; - int _state; - int _errorCode; + int _state; + int _errorCode; string _errorMessage; // request typedef map Fields; - Fields _postFields; - HTTPRequestHeaders _headers; + Fields _postFields; + HTTPRequestHeaders _headers; // response - int _responseCode; + int _responseCode; HTTPRequestHeaders _responseHeaders; - void *_responseBuffer; - size_t _responseBufferLength; - size_t _responseDataLength; - string _responseCookies; + void * _responseBuffer; + size_t _responseBufferLength; + size_t _responseDataLength; + string _responseCookies; double _dltotal; double _dlnow; @@ -224,21 +224,21 @@ private: void cleanupRawResponseBuff(void); // instance callback - void onRequest(void); + void onRequest(void); size_t onWriteData(void *buffer, size_t bytes); size_t onWriteHeader(void *buffer, size_t bytes); - int onProgress(double dltotal, double dlnow, double ultotal, double ulnow); + int onProgress(double dltotal, double dlnow, double ultotal, double ulnow); // curl callback #ifdef _WINDOWS_ static DWORD WINAPI requestCURL(LPVOID userdata); #else - pthread_t _thread; + pthread_t _thread; static void *requestCURL(void *userdata); #endif static size_t writeDataCURL(void *buffer, size_t size, size_t nmemb, void *userdata); static size_t writeHeaderCURL(void *buffer, size_t size, size_t nmemb, void *userdata); - static int progressCURL(void *userdata, double dltotal, double dlnow, double ultotal, double ulnow); + static int progressCURL(void *userdata, double dltotal, double dlnow, double ultotal, double ulnow); }; NS_CC_EXTRA_END diff --git a/native/tools/simulator/libsimulator/lib/platform/mac/PlayerMenuServiceMac.mm b/native/tools/simulator/libsimulator/lib/platform/mac/PlayerMenuServiceMac.mm index 3a1dc4b5c1..94985d0028 100755 --- a/native/tools/simulator/libsimulator/lib/platform/mac/PlayerMenuServiceMac.mm +++ b/native/tools/simulator/libsimulator/lib/platform/mac/PlayerMenuServiceMac.mm @@ -29,6 +29,7 @@ #include "cocos/bindings/event/EventDispatcher.h" #include "CustomAppEvent.h" #include +#include "cocos/base/DeferredReleasePool.h" /////////////////////////////////////// menu helper ////////////////////////////////////////////// static bool __G_IS_MENUBAR_ENABLED__ = true; // WTF @@ -137,7 +138,8 @@ PlayerMenuItemMac *PlayerMenuItemMac::create(const std::string &menuId, const st PlayerMenuItemMac *item = new PlayerMenuItemMac(); item->_menuId = menuId; item->_title = title; - item->autorelease(); + item->addRef(); + cc::DeferredReleasePool::add(item); return item; } @@ -260,7 +262,7 @@ PlayerMenuItem* PlayerMenuServiceMac::addItem(const std::string &menuId, const s // create new menu item PlayerMenuItemMac *item = PlayerMenuItemMac::create(menuId, title); item->_parent = parent; - item->_parent->retain(); + item->_parent->addRef(); // check new menu item position int childSize = (int) [parent->_menu itemArray].count; diff --git a/native/tools/simulator/libsimulator/lib/platform/mac/PlayerTaskServiceMac.mm b/native/tools/simulator/libsimulator/lib/platform/mac/PlayerTaskServiceMac.mm index 2589ea745e..716d897b78 100755 --- a/native/tools/simulator/libsimulator/lib/platform/mac/PlayerTaskServiceMac.mm +++ b/native/tools/simulator/libsimulator/lib/platform/mac/PlayerTaskServiceMac.mm @@ -27,6 +27,7 @@ #include "PlayerTaskServiceMac.h" #include "cocos/base/Log.h" #include "cocos/base/UTF8.h" +#include "cocos/base/DeferredReleasePool.h" @implementation PlayerTaskPrivate @synthesize buildTask = _buildTask; @@ -130,7 +131,8 @@ PLAYER_NS_BEGIN PlayerTaskMac *PlayerTaskMac::create(const std::string &name, const std::string &executePath, const std::string &commandLineArguments) { PlayerTaskMac *task = new PlayerTaskMac(name, executePath, commandLineArguments); - task->autorelease(); + task->addRef(); + cc::DeferredReleasePool::add(task); return task; } diff --git a/native/tools/simulator/libsimulator/lib/platform/win32/PlayerFileDialogServiceWin.h b/native/tools/simulator/libsimulator/lib/platform/win32/PlayerFileDialogServiceWin.h index bfbee2ca8f..fcd3ea3109 100755 --- a/native/tools/simulator/libsimulator/lib/platform/win32/PlayerFileDialogServiceWin.h +++ b/native/tools/simulator/libsimulator/lib/platform/win32/PlayerFileDialogServiceWin.h @@ -23,39 +23,38 @@ THE SOFTWARE. ****************************************************************************/ - #ifndef __PLAYER_FILE_DIALOG_SERVICE_WIN_H_ #define __PLAYER_FILE_DIALOG_SERVICE_WIN_H_ -#include "stdafx.h" +#include #include "PlayerFileDialogServiceProtocol.h" +#include "stdafx.h" PLAYER_NS_BEGIN -class PlayerFileDialogServiceWin : public PlayerFileDialogServiceProtocol -{ +class PlayerFileDialogServiceWin : public PlayerFileDialogServiceProtocol { public: PlayerFileDialogServiceWin(HWND hwnd); - virtual std::string openFile(const std::string &title, - const std::string &directory, - const std::string &extensions) const; + virtual std::string openFile(const std::string &title, + const std::string &directory, + const std::string &extensions) const; virtual std::vector openMultiple(const std::string &title, const std::string &directory, const std::string &extensions) const; - virtual std::string saveFile(const std::string &title, - const std::string &path) const; - virtual std::string openDirectory(const std::string &title, - const std::string &directory) const; + virtual std::string saveFile(const std::string &title, + const std::string &path) const; + virtual std::string openDirectory(const std::string &title, + const std::string &directory) const; protected: HWND _hwnd; - LPTSTR parseExtensions(const std::string &extensions) const; - vector openMultipleInternal(const std::string &title, - const std::string &directory, - const std::string &extensions, - bool isMulti) const; + LPTSTR parseExtensions(const std::string &extensions) const; + std::vector openMultipleInternal(const std::string &title, + const std::string &directory, + const std::string &extensions, + bool isMulti) const; }; PLAYER_NS_END diff --git a/native/tools/simulator/libsimulator/lib/platform/win32/PlayerMenuServiceWin.cpp b/native/tools/simulator/libsimulator/lib/platform/win32/PlayerMenuServiceWin.cpp index b79a68c664..807bf2baea 100755 --- a/native/tools/simulator/libsimulator/lib/platform/win32/PlayerMenuServiceWin.cpp +++ b/native/tools/simulator/libsimulator/lib/platform/win32/PlayerMenuServiceWin.cpp @@ -23,180 +23,143 @@ THE SOFTWARE. ****************************************************************************/ - -#include "cocos/base/UTF8.h" -#include "cocos/base/Log.h" #include "PlayerMenuServiceWin.h" +#include "cocos/base/DeferredReleasePool.h" +#include "cocos/base/Log.h" +#include "cocos/base/UTF8.h" PLAYER_NS_BEGIN -PlayerMenuItemWin *PlayerMenuItemWin::create(const std::string &menuId, const std::string &title) -{ +PlayerMenuItemWin *PlayerMenuItemWin::create(const std::string &menuId, const std::string &title) { PlayerMenuItemWin *item = new PlayerMenuItemWin(); - item->_menuId = menuId; - item->_title = title; - item->autorelease(); + item->_menuId = menuId; + item->_title = title; + item->addRef(); + cc::DeferredReleasePool::add(item); return item; } PlayerMenuItemWin::PlayerMenuItemWin() - : _parent(nullptr) - , _commandId(0) - , _hmenu(NULL) - , _menubarEnabled(true) -{ +: _parent(nullptr), _commandId(0), _hmenu(NULL), _menubarEnabled(true) { } -PlayerMenuItemWin::~PlayerMenuItemWin() -{ +PlayerMenuItemWin::~PlayerMenuItemWin() { CC_SAFE_RELEASE(_parent); - if (_hmenu) - { + if (_hmenu) { CC_LOG_DEBUG("PlayerMenuItemWin::~PlayerMenuItemWin() - %s (HMENU)", _menuId.c_str()); DestroyMenu(_hmenu); - } - else - { + } else { CC_LOG_DEBUG("PlayerMenuItemWin::~PlayerMenuItemWin() - %s", _menuId.c_str()); } } -void PlayerMenuItemWin::setTitle(const std::string &title) -{ - if (title.length() == 0) - { +void PlayerMenuItemWin::setTitle(const std::string &title) { + if (title.length() == 0) { CC_LOG_DEBUG("MenuServiceWin::setTitle() - can not set menu title to empty, menu id (%s)", _menuId.c_str()); return; } MENUITEMINFO menuitem; menuitem.cbSize = sizeof(menuitem); - menuitem.fMask = MIIM_FTYPE | MIIM_STRING; - menuitem.fType = (title.compare("-") == 0) ? MFT_SEPARATOR : MFT_STRING; + menuitem.fMask = MIIM_FTYPE | MIIM_STRING; + menuitem.fType = (title.compare("-") == 0) ? MFT_SEPARATOR : MFT_STRING; std::u16string u16title; cc::StringUtils::UTF8ToUTF16(title, u16title); menuitem.dwTypeData = (LPTSTR)u16title.c_str(); - if (SetMenuItemInfo(_parent->_hmenu, _commandId, MF_BYCOMMAND, &menuitem)) - { + if (SetMenuItemInfo(_parent->_hmenu, _commandId, MF_BYCOMMAND, &menuitem)) { _title = title; - } - else - { + } else { DWORD err = GetLastError(); CC_LOG_DEBUG("MenuServiceWin::setTitle() - set menu title failed, menu id (%s). error code = %u", _menuId.c_str(), err); } } -void PlayerMenuItemWin::setEnabled(bool enabled) -{ +void PlayerMenuItemWin::setEnabled(bool enabled) { MENUITEMINFO menuitem = {0}; - menuitem.cbSize = sizeof(menuitem); - menuitem.fMask = MIIM_STATE; - menuitem.fState = (enabled && _menubarEnabled) ? MFS_ENABLED : MFS_DISABLED; - if (SetMenuItemInfo(_parent->_hmenu, _commandId, MF_BYCOMMAND, &menuitem)) - { + menuitem.cbSize = sizeof(menuitem); + menuitem.fMask = MIIM_STATE; + menuitem.fState = (enabled && _menubarEnabled) ? MFS_ENABLED : MFS_DISABLED; + if (SetMenuItemInfo(_parent->_hmenu, _commandId, MF_BYCOMMAND, &menuitem)) { _isEnabled = enabled; - } - else - { + } else { DWORD err = GetLastError(); CC_LOG_DEBUG("MenuServiceWin::setEnabled() - set menu enabled failed, menu id (%s). error code = %u", _menuId.c_str(), err); } } -void PlayerMenuItemWin::setChecked(bool checked) -{ +void PlayerMenuItemWin::setChecked(bool checked) { MENUITEMINFO menuitem; menuitem.cbSize = sizeof(menuitem); - menuitem.fMask = MIIM_STATE; + menuitem.fMask = MIIM_STATE; menuitem.fState = (checked) ? MFS_CHECKED : MFS_UNCHECKED; - if (SetMenuItemInfo(_parent->_hmenu, _commandId, MF_BYCOMMAND, &menuitem)) - { + if (SetMenuItemInfo(_parent->_hmenu, _commandId, MF_BYCOMMAND, &menuitem)) { _isChecked = checked; - } - else - { + } else { DWORD err = GetLastError(); CC_LOG_DEBUG("MenuServiceWin::setChecked() - set menu checked failed, menu id (%s). error code = %u", _menuId.c_str(), err); } } -void PlayerMenuItemWin::setShortcut(const std::string &shortcut) -{ - +void PlayerMenuItemWin::setShortcut(const std::string &shortcut) { } - // MenuServiceWin WORD PlayerMenuServiceWin::_newCommandId = 0x1000; PlayerMenuServiceWin::PlayerMenuServiceWin(HWND hwnd) - : _hwnd(hwnd) - , _menubarEnabled(true) -{ +: _hwnd(hwnd), _menubarEnabled(true) { // create menu - _root._menuId = "__ROOT__"; + _root._menuId = "__ROOT__"; _root._commandId = 0; - // hwnd has menu - HMENU menu = GetSystemMenu(hwnd, FALSE);// GetMenu(hwnd); - if (menu) - { + // hwnd has menu + HMENU menu = GetSystemMenu(hwnd, FALSE); // GetMenu(hwnd); + if (menu) { _root._hmenu = menu; - } - else - { + } else { _root._hmenu = CreateMenu(); SetMenu(hwnd, _root._hmenu); } } -PlayerMenuServiceWin::~PlayerMenuServiceWin() -{ +PlayerMenuServiceWin::~PlayerMenuServiceWin() { } PlayerMenuItem *PlayerMenuServiceWin::addItem(const std::string &menuId, const std::string &title, const std::string &parentId, - int order /* = MAX_ORDER */) -{ - if (menuId.length() == 0 || title.length() == 0) - { + int order /* = MAX_ORDER */) { + if (menuId.length() == 0 || title.length() == 0) { CC_LOG_DEBUG("MenuServiceWin::addItem() - menuId and title must is non-empty"); return nullptr; } // check menu id is exists - if (_items.find(menuId) != _items.end()) - { + if (_items.find(menuId) != _items.end()) { CC_LOG_DEBUG("MenuServiceWin::addItem() - menu id (%s) is exists", menuId.c_str()); return false; } // set parent PlayerMenuItemWin *parent = &_root; - if (parentId.length()) - { + if (parentId.length()) { // query parent menu auto it = _items.find(parentId); - if (it != _items.end()) - { + if (it != _items.end()) { parent = it->second; } } - if (!parent->_hmenu) - { + if (!parent->_hmenu) { // create menu handle for parent (convert parent to submenu) - parent->_hmenu = CreateMenu(); + parent->_hmenu = CreateMenu(); parent->_isGroup = true; MENUITEMINFO menuitem; - menuitem.cbSize = sizeof(menuitem); - menuitem.fMask = MIIM_SUBMENU; + menuitem.cbSize = sizeof(menuitem); + menuitem.fMask = MIIM_SUBMENU; menuitem.hSubMenu = parent->_hmenu; - if (!SetMenuItemInfo(parent->_parent->_hmenu, parent->_commandId, MF_BYCOMMAND, &menuitem)) - { + if (!SetMenuItemInfo(parent->_parent->_hmenu, parent->_commandId, MF_BYCOMMAND, &menuitem)) { DWORD err = GetLastError(); CC_LOG_DEBUG("MenuServiceWin::addItem() - set menu handle failed, menu id (%s). error code = %u", parent->_menuId.c_str(), err); return nullptr; @@ -206,35 +169,31 @@ PlayerMenuItem *PlayerMenuServiceWin::addItem(const std::string &menuId, // create new menu item _newCommandId++; PlayerMenuItemWin *item = PlayerMenuItemWin::create(menuId, title); - item->_commandId = _newCommandId; - item->_parent = parent; - item->_parent->retain(); + item->_commandId = _newCommandId; + item->_parent = parent; + item->_parent->addRef(); // add menu item to menu bar MENUITEMINFO menuitem; menuitem.cbSize = sizeof(menuitem); - menuitem.fMask = MIIM_FTYPE | MIIM_ID | MIIM_STATE | MIIM_STRING; - menuitem.fType = (item->_title.compare("-") == 0) ? MFT_SEPARATOR : MFT_STRING; + menuitem.fMask = MIIM_FTYPE | MIIM_ID | MIIM_STATE | MIIM_STRING; + menuitem.fType = (item->_title.compare("-") == 0) ? MFT_SEPARATOR : MFT_STRING; menuitem.fState = (item->_isEnabled) ? MFS_ENABLED : MFS_DISABLED; menuitem.fState |= (item->_isChecked) ? MFS_CHECKED : MFS_UNCHECKED; std::u16string u16title; cc::StringUtils::UTF8ToUTF16(item->_title, u16title); menuitem.dwTypeData = (LPTSTR)u16title.c_str(); - menuitem.wID = _newCommandId; + menuitem.wID = _newCommandId; // check new menu item position - if (order > parent->_children.size()) - { + if (order > parent->_children.size()) { order = parent->_children.size(); - } - else if (order < 0) - { + } else if (order < 0) { order = 0; } // create new menu item - if (!InsertMenuItem(parent->_hmenu, order, TRUE, &menuitem)) - { + if (!InsertMenuItem(parent->_hmenu, order, TRUE, &menuitem)) { DWORD err = GetLastError(); CC_LOG_DEBUG("MenuServiceWin::addItem() - insert new menu item failed, menu id (%s). error code = %u", item->_menuId.c_str(), err); item->release(); @@ -243,7 +202,7 @@ PlayerMenuItem *PlayerMenuServiceWin::addItem(const std::string &menuId, // update menu state parent->_children.insert(order, item); - _items[item->_menuId] = item; + _items[item->_menuId] = item; _commandId2menuId[item->_commandId] = item->_menuId; updateChildrenOrder(parent); @@ -251,16 +210,13 @@ PlayerMenuItem *PlayerMenuServiceWin::addItem(const std::string &menuId, } PlayerMenuItem *PlayerMenuServiceWin::addItem(const std::string &menuId, - const std::string &title) -{ + const std::string &title) { return addItem(menuId, title, ""); } -PlayerMenuItem *PlayerMenuServiceWin::getItem(const std::string &menuId) -{ +PlayerMenuItem *PlayerMenuServiceWin::getItem(const std::string &menuId) { auto it = _items.find(menuId); - if (it == _items.end()) - { + if (it == _items.end()) { CC_LOG_DEBUG("MenuServiceWin::getItem() - Invalid menu id (%s)", menuId.c_str()); return nullptr; } @@ -268,61 +224,51 @@ PlayerMenuItem *PlayerMenuServiceWin::getItem(const std::string &menuId) return it->second; } -bool PlayerMenuServiceWin::removeItem(const std::string &menuId) -{ +bool PlayerMenuServiceWin::removeItem(const std::string &menuId) { return removeItemInternal(menuId, true); } -void PlayerMenuServiceWin::setMenuBarEnabled(bool enabled) -{ +void PlayerMenuServiceWin::setMenuBarEnabled(bool enabled) { _menubarEnabled = enabled; UINT state = enabled ? MFS_ENABLED : MFS_DISABLED; - for (auto it = _root._children.begin(); it != _root._children.end(); ++it) - { - PlayerMenuItemWin *item = *it; - MENUITEMINFO menuitem = {0}; - menuitem.cbSize = sizeof(menuitem); - menuitem.fMask = MIIM_STATE; - menuitem.fState = state; + for (auto it = _root._children.begin(); it != _root._children.end(); ++it) { + PlayerMenuItemWin *item = *it; + MENUITEMINFO menuitem = {0}; + menuitem.cbSize = sizeof(menuitem); + menuitem.fMask = MIIM_STATE; + menuitem.fState = state; SetMenuItemInfo(item->_parent->_hmenu, item->_commandId, MF_BYCOMMAND, &menuitem); item->_menubarEnabled = enabled; } } -PlayerMenuItemWin *PlayerMenuServiceWin::getItemByCommandId(WORD commandId) -{ +PlayerMenuItemWin *PlayerMenuServiceWin::getItemByCommandId(WORD commandId) { auto it = _commandId2menuId.find(commandId); if (it == _commandId2menuId.end()) return nullptr; return _items[it->second]; } -bool PlayerMenuServiceWin::removeItemInternal(const std::string &menuId, bool isUpdateChildrenOrder) -{ +bool PlayerMenuServiceWin::removeItemInternal(const std::string &menuId, bool isUpdateChildrenOrder) { auto it = _items.find(menuId); - if (it == _items.end()) - { + if (it == _items.end()) { CC_LOG_DEBUG("MenuServiceWin::removeItem() - Invalid menu id (%s)", menuId.c_str()); return false; } PlayerMenuItemWin *item = it->second; - if (item->_children.size() == 0) - { - if (!DeleteMenu(item->_parent->_hmenu, item->_commandId, MF_BYCOMMAND)) - { + if (item->_children.size() == 0) { + if (!DeleteMenu(item->_parent->_hmenu, item->_commandId, MF_BYCOMMAND)) { DWORD err = GetLastError(); CC_LOG_DEBUG("MenuServiceWin::removeItem() - remove menu item failed, menu id (%s). error code = %u", item->_menuId.c_str(), err); return false; } // remove item from parent - bool removed = false; + bool removed = false; auto *children = &item->_parent->_children; - for (auto it = children->begin(); it != children->end(); ++it) - { - if ((*it)->_commandId == item->_commandId) - { + for (auto it = children->begin(); it != children->end(); ++it) { + if ((*it)->_commandId == item->_commandId) { CC_LOG_DEBUG("MenuServiceWin::removeItem() - remove menu item (%s)", item->_menuId.c_str()); children->erase(it); removed = true; @@ -330,29 +276,23 @@ bool PlayerMenuServiceWin::removeItemInternal(const std::string &menuId, bool is } } - if (!removed) - { + if (!removed) { CC_LOG_DEBUG("MenuServiceWin::removeItem() - remove menu item (%s) failed, not found command id from parent->children", item->_menuId.c_str()); } // remove menu id mapping _items.erase(menuId); _commandId2menuId.erase(item->_commandId); - if (isUpdateChildrenOrder) - { + if (isUpdateChildrenOrder) { updateChildrenOrder(item->_parent); } DrawMenuBar(_hwnd); return true; - } - else - { + } else { // remove all children - while (item->_children.size() != 0) - { + while (item->_children.size() != 0) { PlayerMenuItemWin *child = *item->_children.begin(); - if (!removeItemInternal(child->_menuId.c_str(), false)) - { + if (!removeItemInternal(child->_menuId.c_str(), false)) { break; return false; } @@ -363,13 +303,10 @@ bool PlayerMenuServiceWin::removeItemInternal(const std::string &menuId, bool is return false; } - -void PlayerMenuServiceWin::updateChildrenOrder(PlayerMenuItemWin *parent) -{ +void PlayerMenuServiceWin::updateChildrenOrder(PlayerMenuItemWin *parent) { auto *children = &parent->_children; - int order = 0; - for (auto it = children->begin(); it != children->end(); ++it) - { + int order = 0; + for (auto it = children->begin(); it != children->end(); ++it) { (*it)->_order = order; order++; } diff --git a/native/tools/simulator/libsimulator/lib/platform/win32/PlayerTaskServiceWin.cpp b/native/tools/simulator/libsimulator/lib/platform/win32/PlayerTaskServiceWin.cpp index b534257b9d..444f0b56eb 100755 --- a/native/tools/simulator/libsimulator/lib/platform/win32/PlayerTaskServiceWin.cpp +++ b/native/tools/simulator/libsimulator/lib/platform/win32/PlayerTaskServiceWin.cpp @@ -23,49 +23,39 @@ THE SOFTWARE. ****************************************************************************/ - #include -#include "cocos/base/UTF8.h" -#include "cocos/base/Log.h" -#include "stdafx.h" -#include "shellapi.h" #include "PlayerTaskServiceWin.h" +#include "cocos/base/DeferredReleasePool.h" +#include "cocos/base/Log.h" +#include "cocos/base/UTF8.h" +#include "shellapi.h" +#include "stdafx.h" -static const int MAX_LOG_LENGTH = 16 * 1024;// from 2dx +static const int MAX_LOG_LENGTH = 16 * 1024; // from 2dx PLAYER_NS_BEGIN -PlayerTaskWin *PlayerTaskWin::create(const std::string &name, const std::string &executePath, const std::string &commandLineArguments) -{ +PlayerTaskWin *PlayerTaskWin::create(const std::string &name, const std::string &executePath, const std::string &commandLineArguments) { PlayerTaskWin *task = new PlayerTaskWin(name, executePath, commandLineArguments); - task->autorelease(); + task->addRef(); + cc::DeferredReleasePool::add(task); return task; } PlayerTaskWin::PlayerTaskWin(const std::string &name, const std::string &executePath, const std::string &commandLineArguments) - : PlayerTask(name, executePath, commandLineArguments) - , _childStdInRead(NULL) - , _childStdInWrite(NULL) - , _childStdOutRead(NULL) - , _childStdOutWrite(NULL) - , _outputBuff(NULL) - , _outputBuffWide(NULL) -{ +: PlayerTask(name, executePath, commandLineArguments), _childStdInRead(NULL), _childStdInWrite(NULL), _childStdOutRead(NULL), _childStdOutWrite(NULL), _outputBuff(NULL), _outputBuffWide(NULL) { ZeroMemory(&_pi, sizeof(_pi)); } -PlayerTaskWin::~PlayerTaskWin() -{ +PlayerTaskWin::~PlayerTaskWin() { cleanup(); } -bool PlayerTaskWin::run() -{ - if (!isIdle()) - { +bool PlayerTaskWin::run() { + if (!isIdle()) { CC_LOG_DEBUG("PlayerTaskWin::run() - task is not idle"); return false; } @@ -85,20 +75,18 @@ bool PlayerTaskWin::run() // http://msdn.microsoft.com/en-us/library/windows/desktop/ms682499(v=vs.85).aspx SECURITY_ATTRIBUTES sa = {0}; - sa.nLength = sizeof(sa); - sa.bInheritHandle = TRUE; + sa.nLength = sizeof(sa); + sa.bInheritHandle = TRUE; - // Create a pipe for the child process's STDOUT. - if (!CreatePipe(&_childStdOutRead, &_childStdOutWrite, &sa, 0) || !SetHandleInformation(_childStdOutRead, HANDLE_FLAG_INHERIT, 0)) - { + // Create a pipe for the child process's STDOUT. + if (!CreatePipe(&_childStdOutRead, &_childStdOutWrite, &sa, 0) || !SetHandleInformation(_childStdOutRead, HANDLE_FLAG_INHERIT, 0)) { CC_LOG_DEBUG("PlayerTaskWin::run() - create stdout handle failed, for execute %s", _executePath.c_str()); cleanup(); return false; } - // Create a pipe for the child process's STDIN. - if (!CreatePipe(&_childStdInRead, &_childStdInWrite, &sa, 0) || !SetHandleInformation(_childStdInWrite, HANDLE_FLAG_INHERIT, 0)) - { + // Create a pipe for the child process's STDIN. + if (!CreatePipe(&_childStdInRead, &_childStdInWrite, &sa, 0) || !SetHandleInformation(_childStdInWrite, HANDLE_FLAG_INHERIT, 0)) { CC_LOG_DEBUG("PlayerTaskWin::run() - create stdout handle failed, for execute %s", _executePath.c_str()); cleanup(); return false; @@ -107,75 +95,69 @@ bool PlayerTaskWin::run() ZeroMemory(&_pi, sizeof(_pi)); STARTUPINFO si = {0}; - si.cb = sizeof(STARTUPINFO); - si.hStdError = _childStdOutWrite; - si.hStdOutput = _childStdOutWrite; - si.hStdInput = _childStdInRead; - si.dwFlags = STARTF_USESHOWWINDOW | STARTF_USESTDHANDLES; + si.cb = sizeof(STARTUPINFO); + si.hStdError = _childStdOutWrite; + si.hStdOutput = _childStdOutWrite; + si.hStdInput = _childStdInRead; + si.dwFlags = STARTF_USESHOWWINDOW | STARTF_USESTDHANDLES; si.wShowWindow = SW_HIDE; #define MAX_COMMAND 4096 //MAX_PATH const std::u16string u16command = makeCommandLine(); - WCHAR command[MAX_COMMAND]; - wcscpy_s(command, MAX_COMMAND, (WCHAR*)u16command.c_str()); + WCHAR command[MAX_COMMAND]; + wcscpy_s(command, MAX_COMMAND, (WCHAR *)u16command.c_str()); BOOL success = CreateProcess(NULL, - (LPSTR)command, // command line - NULL, // process security attributes - NULL, // primary thread security attributes - TRUE, // handles are inherited - 0, // creation flags - NULL, // use parent's environment - NULL, // use parent's current directory - &si, // STARTUPINFO pointer - &_pi); // receives PROCESS_INFORMATION + (LPSTR)command, // command line + NULL, // process security attributes + NULL, // primary thread security attributes + TRUE, // handles are inherited + 0, // creation flags + NULL, // use parent's environment + NULL, // use parent's current directory + &si, // STARTUPINFO pointer + &_pi); // receives PROCESS_INFORMATION - if (!success) - { + if (!success) { CC_LOG_DEBUG("PlayerTaskWin::run() - create process failed, for execute %s", _executePath.c_str()); cleanup(); return false; } - _outputBuff = new CHAR[BUFF_SIZE + 1]; + _outputBuff = new CHAR[BUFF_SIZE + 1]; _outputBuffWide = new WCHAR[BUFF_SIZE]; - _state = STATE_RUNNING; + _state = STATE_RUNNING; // cc::Director::getInstance()->getScheduler()->scheduleUpdate(this, 0, false); return true; } -void PlayerTaskWin::runInTerminal() -{ - std::stringstream buf; - buf << "/K "; - buf << _executePath; - buf << " "; - buf << _commandLineArguments; +void PlayerTaskWin::runInTerminal() { + std::stringstream buf; + buf << "/K "; + buf << _executePath; + buf << " "; + buf << _commandLineArguments; - std::u16string u16command; - cc::StringUtils::UTF8ToUTF16(buf.str(), u16command); + std::u16string u16command; + cc::StringUtils::UTF8ToUTF16(buf.str(), u16command); - ShellExecute(NULL, NULL, (LPCSTR)L"CMD.EXE", (LPCSTR)u16command.c_str(), NULL, SW_SHOWNORMAL); + ShellExecute(NULL, NULL, (LPCSTR)L"CMD.EXE", (LPCSTR)u16command.c_str(), NULL, SW_SHOWNORMAL); } -void PlayerTaskWin::stop() -{ - if (_pi.hProcess) - { +void PlayerTaskWin::stop() { + if (_pi.hProcess) { TerminateProcess(_pi.hProcess, 0); _resultCode = -1; } cleanup(); } -void PlayerTaskWin::update(float dt) -{ +void PlayerTaskWin::update(float dt) { _lifetime += dt; // read output - for (;;) - { + for (;;) { DWORD readCount = 0; PeekNamedPipe(_childStdOutRead, NULL, NULL, NULL, &readCount, NULL); if (readCount == 0) break; @@ -187,8 +169,7 @@ void PlayerTaskWin::update(float dt) if (!success || readCount == 0) break; int chars = MultiByteToWideChar(CP_OEMCP, 0, _outputBuff, readCount, _outputBuffWide, BUFF_SIZE); - if (chars) - { + if (chars) { ZeroMemory(_outputBuff, BUFF_SIZE + 1); WideCharToMultiByte(CP_UTF8, 0, _outputBuffWide, chars, _outputBuff, BUFF_SIZE + 1, 0, NULL); _output.append(_outputBuff); @@ -198,13 +179,10 @@ void PlayerTaskWin::update(float dt) // get child process exit code DWORD resultCode = 0; - if (GetExitCodeProcess(_pi.hProcess, &resultCode)) - { + if (GetExitCodeProcess(_pi.hProcess, &resultCode)) { if (resultCode == STILL_ACTIVE) return; _resultCode = (int)resultCode; - } - else - { + } else { // unexpected error _resultCode = (int)GetLastError(); } @@ -213,8 +191,7 @@ void PlayerTaskWin::update(float dt) cleanup(); } -void PlayerTaskWin::cleanup() -{ +void PlayerTaskWin::cleanup() { if (_pi.hProcess) CloseHandle(_pi.hProcess); if (_pi.hThread) CloseHandle(_pi.hThread); ZeroMemory(&_pi, sizeof(_pi)); @@ -229,10 +206,10 @@ void PlayerTaskWin::cleanup() if (_childStdInRead) CloseHandle(_childStdInRead); if (_childStdInWrite) CloseHandle(_childStdInWrite); - _childStdOutRead = NULL; + _childStdOutRead = NULL; _childStdOutWrite = NULL; - _childStdInRead = NULL; - _childStdInWrite = NULL; + _childStdInRead = NULL; + _childStdInWrite = NULL; _state = STATE_COMPLETED; @@ -241,8 +218,7 @@ void PlayerTaskWin::cleanup() // cc::Director::getInstance()->getEventDispatcher()->dispatchCustomEvent(_name); } -std::u16string PlayerTaskWin::makeCommandLine() const -{ +std::u16string PlayerTaskWin::makeCommandLine() const { std::stringstream buf; buf << "\""; buf << _executePath; @@ -255,41 +231,33 @@ std::u16string PlayerTaskWin::makeCommandLine() const } PlayerTaskServiceWin::PlayerTaskServiceWin(HWND hwnd) - : _hwnd(hwnd) -{ +: _hwnd(hwnd) { } -PlayerTaskServiceWin::~PlayerTaskServiceWin() -{ - for (auto it = _tasks.begin(); it != _tasks.end(); ++it) - { +PlayerTaskServiceWin::~PlayerTaskServiceWin() { + for (auto it = _tasks.begin(); it != _tasks.end(); ++it) { it->second->stop(); } } PlayerTask *PlayerTaskServiceWin::createTask(const std::string &name, const std::string &executePath, - const std::string &commandLineArguments) -{ + const std::string &commandLineArguments) { CCASSERT(_tasks.find(name) == _tasks.end(), "Task already exists."); PlayerTaskWin *task = PlayerTaskWin::create(name, executePath, commandLineArguments); _tasks.insert(name, task); return task; } -PlayerTask *PlayerTaskServiceWin::getTask(const std::string &name) -{ +PlayerTask *PlayerTaskServiceWin::getTask(const std::string &name) { auto it = _tasks.find(name); return it != _tasks.end() ? it->second : nullptr; } -void PlayerTaskServiceWin::removeTask(const std::string &name) -{ +void PlayerTaskServiceWin::removeTask(const std::string &name) { auto it = _tasks.find(name); - if (it != _tasks.end()) - { - if (!it->second->isCompleted()) - { + if (it != _tasks.end()) { + if (!it->second->isCompleted()) { it->second->stop(); } _tasks.erase(it); diff --git a/native/tools/simulator/libsimulator/lib/platform/win32/PlayerWin.h b/native/tools/simulator/libsimulator/lib/platform/win32/PlayerWin.h index 62438f459e..9c98e9c2a1 100755 --- a/native/tools/simulator/libsimulator/lib/platform/win32/PlayerWin.h +++ b/native/tools/simulator/libsimulator/lib/platform/win32/PlayerWin.h @@ -25,44 +25,41 @@ #pragma once - +#include "PlayerEditBoxServiceWin.h" +#include "PlayerFileDialogServiceWin.h" #include "PlayerMacros.h" -#include "PlayerProtocol.h" #include "PlayerMenuServiceWin.h" #include "PlayerMessageBoxServiceWin.h" -#include "PlayerFileDialogServiceWin.h" -#include "PlayerEditBoxServiceWin.h" +#include "PlayerProtocol.h" #include "PlayerTaskServiceWin.h" #include "SimulatorExport.h" PLAYER_NS_BEGIN -class CC_LIBSIM_DLL PlayerWin : public PlayerProtocol, public cc::Ref -{ +class CC_LIBSIM_DLL PlayerWin : public PlayerProtocol, public cc::RefCounted { public: static PlayerWin *createWithHwnd(HWND hWnd); virtual ~PlayerWin(); virtual PlayerFileDialogServiceProtocol *getFileDialogService(); virtual PlayerMessageBoxServiceProtocol *getMessageBoxService(); - virtual PlayerMenuServiceProtocol *getMenuService(); - virtual PlayerEditBoxServiceProtocol *getEditBoxService(); - virtual PlayerTaskServiceProtocol *getTaskService(); + virtual PlayerMenuServiceProtocol * getMenuService(); + virtual PlayerEditBoxServiceProtocol * getEditBoxService(); + virtual PlayerTaskServiceProtocol * getTaskService(); protected: PlayerWin(); - + // services void initServices(); - PlayerMenuServiceWin *_menuService; + PlayerMenuServiceWin * _menuService; PlayerMessageBoxServiceWin *_messageBoxService; PlayerFileDialogServiceWin *_fileDialogService; - PlayerEditBoxServiceWin *_editboxService; - PlayerTaskServiceWin *_taskService; + PlayerEditBoxServiceWin * _editboxService; + PlayerTaskServiceWin * _taskService; HWND _hwnd; }; - PLAYER_NS_END diff --git a/native/tools/simulator/libsimulator/lib/runtime/Runtime.cpp b/native/tools/simulator/libsimulator/lib/runtime/Runtime.cpp index 2504c663e7..b83ad8e156 100644 --- a/native/tools/simulator/libsimulator/lib/runtime/Runtime.cpp +++ b/native/tools/simulator/libsimulator/lib/runtime/Runtime.cpp @@ -123,7 +123,7 @@ void RuntimeEngine::setupRuntime() { entryFile = ConfigParser::getInstance()->getEntryFile(); #endif _launchEvent = "js"; - _runtime = _runtimes[kRuntimeEngineJs]; + _runtime = _runtimes[kRuntimeEngineJs]; } void RuntimeEngine::setProjectConfig(const ProjectConfig &config) { @@ -150,12 +150,12 @@ void RuntimeEngine::setProjectPath(const std::string &workPath) { nEnd = i; } szAppDir[nEnd] = 0; - int iLen = 2 * wcslen((wchar_t *)szAppDir); - char *chRtn = new char[iLen + 1]; + int iLen = 2 * wcslen((wchar_t *)szAppDir); + char *chRtn = new char[iLen + 1]; wcstombs(chRtn, (wchar_t *)szAppDir, iLen + 1); std::string strPath = chRtn; delete[] chRtn; - chRtn = NULL; + chRtn = NULL; char fuldir[MAX_PATH] = {0}; _fullpath(fuldir, strPath.c_str(), MAX_PATH); appPath = fuldir; @@ -163,7 +163,7 @@ void RuntimeEngine::setProjectPath(const std::string &workPath) { #elif (CC_PLATFORM == CC_PLATFORM_MAC_OSX) appPath.append("/../../../"); #endif - appPath = replaceAll(appPath, "\\", "/"); + appPath = replaceAll(appPath, "\\", "/"); g_projectPath = appPath; } else { g_projectPath = workPath; @@ -189,7 +189,6 @@ void RuntimeEngine::startScript(const std::string &args) { } void RuntimeEngine::start() { - #if (CC_PLATFORM != CC_PLATFORM_WINDOWS) && (CC_PLATFORM != CC_PLATFORM_MAC_OSX) _project.setDebuggerType(kCCRuntimeDebuggerCodeIDE); #endif @@ -250,7 +249,7 @@ RuntimeProtocol *RuntimeEngine::getRuntime() { void RuntimeEngine::updateConfigParser() { // set entry file - auto parser = ConfigParser::getInstance(); + auto parser = ConfigParser::getInstance(); string entryFile(_project.getScriptFileRealPath()); if (entryFile.find(_project.getProjectDir()) != string::npos) { entryFile.erase(0, _project.getProjectDir().length()); @@ -282,7 +281,7 @@ void RuntimeEngine::trackEvent(const std::string &eventName) { char cidBuf[64] = {0}; auto guid = player::DeviceEx::getInstance()->getUserGUID(); snprintf(cidBuf, sizeof(cidBuf), "%x", XXH32(guid.c_str(), (int)guid.length(), 0)); - auto request = cc::extra::HTTPRequest::createWithUrl(NULL, + IntrusivePtr request = cc::extra::HTTPRequest::createWithUrl(NULL, "http://www.google-analytics.com/collect", kCCHTTPRequestMethodPOST); request->addPOSTValue("v", "1"); diff --git a/native/tools/tojs/assets.ini b/native/tools/tojs/assets.ini new file mode 100644 index 0000000000..fbacc6ebfe --- /dev/null +++ b/native/tools/tojs/assets.ini @@ -0,0 +1,127 @@ +[assets] +# the prefix to be added to the generated functions. You might or might not use this in your own +# templates +prefix = assets + +# create a target namespace (in javascript, this would create some code like the equiv. to `ns = ns || {}`) +# all classes will be embedded in that namespace +target_namespace = jsb + +android_headers = + +android_flags = -target armv7-none-linux-androideabi -D_LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS -DANDROID -D__ANDROID_API__=14 -gcc-toolchain %(gcc_toolchain_dir)s --sysroot=%(androidndkdir)s/platforms/android-14/arch-arm -idirafter %(androidndkdir)s/sources/android/support/include -idirafter %(androidndkdir)s/sysroot/usr/include -idirafter %(androidndkdir)s/sysroot/usr/include/arm-linux-androideabi -idirafter %(clangllvmdir)s/lib64/clang/5.0/include -I%(androidndkdir)s/sources/cxx-stl/llvm-libc++/include + +clang_headers = +clang_flags = -nostdinc -x c++ -std=c++17 -fsigned-char -U__SSE__ + +cocos_headers = -I%(cocosdir)s/cocos -I%(cocosdir)s/cocos/renderer -I%(cocosdir)s -I%(cocosdir)s/cocos/platform/android -I%(cocosdir)s/external/sources -I%(cocosdir)s/external/ios/include/v8 + +cocos_flags = -DANDROID -DCC_PLATFORM=3 -DCC_PLATFORM_MAC_IOS=1 -DCC_PLATFORM_MAC_OSX=4 -DCC_PLATFORM_WINDOWS=2 -DCC_PLATFORM_ANDROID=3 + + +cxxgenerator_headers = + +# extra arguments for clang +extra_arguments = %(android_headers)s %(clang_headers)s %(cxxgenerator_headers)s %(cocos_headers)s %(android_flags)s %(clang_flags)s %(cocos_flags)s %(extra_flags)s + +# what headers to parse +headers = %(cocosdir)s/cocos/core/assets/AssetsModuleHeader.h + %(cocosdir)s/cocos/3d/assets/Mesh.h + %(cocosdir)s/cocos/3d/assets/Morph.h + %(cocosdir)s/cocos/3d/assets/MorphRendering.h + %(cocosdir)s/cocos/3d/assets/Skeleton.h + +hpp_headers = cocos/bindings/auto/jsb_gfx_auto.h cocos/bindings/auto/jsb_pipeline_auto.h +cpp_headers = cocos/bindings/auto/jsb_cocos_auto.h + +# what classes to produce code for. You can use regular expressions here. When testing the regular +# expression, it will be enclosed in "^$", like this: "^Menu*$". +classes = Asset BufferAsset, + IPropertyInfo ITechniqueInfo IBlockInfo ISamplerTextureInfo IAttributeInfo, + IDefineInfo IBuiltin IBuiltinInfo IBuiltins IShaderSource, + IShaderInfo EffectAsset IPassStates IPassInfo IPassInfoFull, + IInputAttachmentInfo, + IImageInfo, + IBufferInfo ITextureInfo ISamplerInfo, + RasterizerStateInfo DepthStencilStateInfo BlendTargetInfo BlendStateInfo, + IMemoryImageSource ImageAsset, + JsonAsset, + IMaterialInfo Material, + Prefab, + Error, + BoundingBox VertexIdChannel IGeometricInfo IFlatBuffer RenderingSubMesh, + IRenderTextureCreateInfo RenderTexture, + TextureBase, + SceneAsset, + SimpleTexture, + TextAsset, + ITexture2DSerializeData ITexture2DCreateInfo Texture2D, + ITextureCubeMipmap ITextureCubeSerializeMipmapData ITextureCubeSerializeData TextureCube, + IMeshBufferView, + Mesh ISubMesh IStruct IVertexBundle ICreateInfo, + MorphTarget SubMeshMorph Morph MorphRenderingInstance, + StdMorphRendering MorphRendering, + Skeleton + +# what should we skip? in the format ClassName::[function function] +# ClassName is a regular expression, but will be used like this: "^ClassName$" functions are also +# regular expressions, they will not be surrounded by "^$". If you want to skip a whole class, just +# add a single "*" as functions. See bellow for several examples. A special class name is "*", which +# will apply to all class names. This is a convenience wildcard to be able to skip similar named +# functions from all classes. +skip = Material::[getOwner setProperty$ getHash$ getHashForMaterial$], + Mesh::[(s|g)etNativeAsset getHash$], + SimpleTexture::[uploadDataWithArrayBuffer], + ImageAsset::[setData], + RasterizerStateInfo::[assignToGFX fromGFX], + DepthStencilStateInfo::[assignToGFX fromGFX], + BlendTargetInfo::[assignToGFX fromGFX], + BlendStateInfo::[assignToGFX fromGFX], + Texture2D::[deserialize], + TextureBase::[getHash$ getSamplerHash$], + Skeleton::[getHash$] + +field = Material::[morphRendering _effectAsset _techIdx _defines _states _props], + Mesh::[morphRendering], + TextAsset::[text], + Asset::[_native _nativeUrl], + TextureBase::[_format _minFilter _magFilter _mipFilter _wrapS _wrapT _wrapR _anisotropy _width _height] + +skip_public_fields = + +rename_functions = ICreateInfo::[structInfo=struct], + Asset::[decAssetRef=decRef addAssetRef=addRef], + IPassInfoFull::[switch_=switch], + Material::[getProperty=_getProperty _props=_propsInternal getHashForJS=getHash getHashForMaterialForJS=getHashForMaterial], + EffectAsset::[registerAsset=register], + Skeleton::[getBindposes=_getBindposes setBindposes=_setBindposes getHashForJS=getHash], + TextureBase::[getHashForJS=getHash getSamplerHashForJS=getSamplerHash], + Mesh::[getHashForJS=getHash] + + +getter_setter= Asset::[_uuid/getUuid/setUuid nativeUrl/getNativeUrl _nativeDep/getNativeDep isDefault/isDefault], + ImageAsset::[format url/getUrl?/setUrl?], + BufferAsset::[buffer], + TextureBase::[isCompressed/isCompressed _width:width/getWidth/setWidth _height:height/getHeight/setHeight], + SimpleTexture::[mipmapLevel/mipmapLevel], + RenderTexture::[window], + Mesh::[_hash:hash/getHashForJS/setHash data:_data/getData jointBufferIndices/getJointBufferIndices maxPosition/getMaxPosition minPosition/getMinPosition renderingSubMeshes/getRenderingSubMeshes subMeshCount/getSubMeshCount _nativeAsset/getAssetData/setAssetData], + Material::[effectAsset effectName technique/getTechniqueIndex hash/getHashForJS parent], + RenderingSubMesh::[mesh subMeshIdx flatBuffers:_flatBuffers jointMappedBuffers iaInfo:_iaInfo primitiveMode], + Skeleton::[_joints:joints/getJoints?/setJoints? _hash:hash/getHashForJS?/setHash?], + EffectAsset::[techniques shaders combinations] + + +rename_classes = + +# for all class names, should we remove something when registering in the target VM? +remove_prefix = + +# classes for which there will be no "parent" lookup +classes_have_no_parents = +# base classes which will be skipped when their sub-classes found them. +base_classes_to_skip = RefCounted + +# classes that create no constructor +# Set is special and we will use a hand-written constructor +abstract_classes = ShapeBase diff --git a/native/tools/tojs/cocos.ini b/native/tools/tojs/cocos.ini index 207a3cc630..f898cdd318 100644 --- a/native/tools/tojs/cocos.ini +++ b/native/tools/tojs/cocos.ini @@ -24,18 +24,20 @@ cxxgenerator_headers = extra_arguments = %(android_headers)s %(clang_headers)s %(cxxgenerator_headers)s %(cocos_headers)s %(android_flags)s %(clang_flags)s %(cocos_flags)s %(extra_flags)s # what headers to parse -headers = %(cocosdir)s/cocos/platform/FileUtils.h %(cocosdir)s/cocos/bindings/event/EventDispatcher.h %(cocosdir)s/cocos/platform/interfaces/modules/canvas/CanvasRenderingContext2D.h %(cocosdir)s/cocos/platform/interfaces/modules/Device.h %(cocosdir)s/cocos/platform/SAXParser.h +headers = %(cocosdir)s/cocos/platform/FileUtils.h %(cocosdir)s/cocos/bindings/event/EventDispatcher.h %(cocosdir)s/cocos/platform/interfaces/modules/canvas/CanvasRenderingContext2D.h %(cocosdir)s/cocos/platform/interfaces/modules/Device.h %(cocosdir)s/cocos/platform/SAXParser.h %(cocosdir)s/cocos/math/Vec2.h %(cocosdir)s/cocos/math/Vec3.h %(cocosdir)s/cocos/math/Quaternion.h %(cocosdir)s/cocos/math/Color.h %(cocosdir)s/cocos/core/data/Object.h replace_headers= # what classes to produce code for. You can use regular expressions here. When testing the regular # expression, it will be enclosed in "^$", like this: "^Menu*$". -classes = FileUtils$ SAXParser OSInterface ICanvasRenderingContext2D CanvasRenderingContext2D ICanvasGradient CanvasGradient Device DownloaderHints +classes = CCObject FileUtils$ SAXParser OSInterface ICanvasRenderingContext2D CanvasRenderingContext2D ICanvasGradient CanvasGradient Device DownloaderHints Vec2 Color classes_need_extend = -field = +field = Vec2::[x y], + Color::[r g b a], + CCObject::[_name _objFlags] # what should we skip? in the format ClassName::[function function] # ClassName is a regular expression, but will be used like this: "^ClassName$" functions are also @@ -44,19 +46,25 @@ field = # will apply to all class names. This is a convenience wildcard to be able to skip similar named # functions from all classes. -skip = FileUtils::[getFileData setFilenameLookupDictionary destroyInstance getFullPathCache getContents listFilesRecursively], +skip = FileUtils::[getFileData setFilenameLookupDictionary destroyInstance getFullPathCache getContents listFilesRecursively setDelegate], SAXParser::[(?!(init))], Device::[getDeviceMotionValue], CanvasRenderingContext2D::[setCanvasBufferUpdatedCallback set_.+ fillText strokeText fillRect measureText], Data::[takeBuffer getBytes fastSet copy], OSInterface::[dispatchEvent dispatchTouchEvent], - Value::[asValueVector asValueMap asIntKeyMap] + Vec2::[^(a|b|c|d|e|f|g|h|i|j|k|l|m|n|o|p|q|r|s|t|u|v|w|z)+], + Vec3::[^(a|b|c|d|e|f|g|h|i|j|k|l|m|n|o|p|q|r|s|t|u|v|w)+], + Quaternion::[^(a|b|c|d|e|f|g|h|i|j|k|l|m|n|o|p|q|r|s|t|u|v)+ zero], + Color::[^(c|d|e|f|h|i|j|k|l|m|n|o|p|q|s|t|u|v|w|z)+] -rename_functions = FileUtils::[loadFilenameLookupDictionaryFromFile=loadFilenameLookup] +rename_functions = FileUtils::[loadFilenameLookupDictionaryFromFile=loadFilenameLookup], + CCObject::[destroyImmediate=_destroyImmediate] -getter_setter=ICanvasRenderingContext2D::[width//setWidth height//setHeight fillStyle//setFillStyle font//setFont globalCompositeOperation//setGlobalCompositeOperation lineCap//setLineCap lineJoin//setLineJoin lineWidth//setLineWidth strokeStyle//setStrokeStyle textAlign//setTextAlign textBaseline//setTextBaseline] +getter_setter=ICanvasRenderingContext2D::[width//setWidth height//setHeight fillStyle//setFillStyle font//setFont globalCompositeOperation//setGlobalCompositeOperation lineCap//setLineCap lineJoin//setLineJoin lineWidth//setLineWidth strokeStyle//setStrokeStyle textAlign//setTextAlign textBaseline//setTextBaseline], + CCObject::[name hideFlags replicated/isReplicated/setReplicated isValid/isValid] -rename_classes = SAXParser::PlistParser +rename_classes = SAXParser::PlistParser, + Quaternion::Quat # for all class names, should we remove something when registering in the target VM? remove_prefix = @@ -65,7 +73,7 @@ remove_prefix = classes_have_no_parents = SAXParser # base classes which will be skipped when their sub-classes found them. -base_classes_to_skip = Ref Clonable +base_classes_to_skip = RefCounted Clonable # classes that create no constructor # Set is special and we will use a hand-written constructor diff --git a/native/tools/tojs/dragonbones.ini b/native/tools/tojs/dragonbones.ini index 7f1fce244e..fc71fe9e50 100644 --- a/native/tools/tojs/dragonbones.ini +++ b/native/tools/tojs/dragonbones.ini @@ -22,6 +22,8 @@ extra_arguments = %(android_headers)s %(clang_headers)s %(cxxgenerator_headers)s headers = %(cocosdir)s/cocos/editor-support/dragonbones-creator-support/CCDragonBonesHeaders.h +hpp_headers = cocos/bindings/auto/jsb_cocos_auto.h + classes = Rectangle DragonBonesData CCFactory CCArmatureDisplay Armature CCSlot WorldClock Animation Slot BaseFactory BaseObject TextureData CCTextureData TextureAtlasData CCTextureAtlasData AnimationState EventObject Bone Transform Matrix TransformObject ArmatureData BoneData SlotData SkinData AnimationData CCArmatureCacheDisplay ArmatureCacheMgr RealTimeAttachUtil CacheModeAttachUtil AttachUtilBase abstract_classes = DragonBonesData Armature CCSlot WorldClock Animation Slot BaseFactory BaseObject TextureData CCTextureData TextureAtlasData CCTextureAtlasData AnimationState EventObject Bone Transform Matrix TransformObject ArmatureData BoneData SlotData SkinData AnimationData AttachUtilBase @@ -73,11 +75,10 @@ remove_prefix = classes_have_no_parents = WorldClock AnimationData -base_classes_to_skip = Ref IArmatureProxy IAnimatable IMiddleware +base_classes_to_skip = RefCounted IArmatureProxy IAnimatable IMiddleware rename_functions = CCArmatureCacheDisplay::[getArmature=armature], - CCArmatureDisplay::[getArmature=armature], - CCFactory::[getFactory=getInstance] + CCArmatureDisplay::[getArmature=armature] rename_classes = diff --git a/native/tools/tojs/editor_support.ini b/native/tools/tojs/editor_support.ini index be771e9ecb..a8d40c0647 100644 --- a/native/tools/tojs/editor_support.ini +++ b/native/tools/tojs/editor_support.ini @@ -36,7 +36,7 @@ remove_prefix = classes_have_no_parents = -base_classes_to_skip = Ref IMiddleware +base_classes_to_skip = RefCounted IMiddleware abstract_classes = diff --git a/native/tools/tojs/extension.ini b/native/tools/tojs/extension.ini index bc4b922985..f1a55336de 100644 --- a/native/tools/tojs/extension.ini +++ b/native/tools/tojs/extension.ini @@ -59,7 +59,7 @@ remove_prefix = classes_have_no_parents = # base classes which will be skipped when their sub-classes found them. -base_classes_to_skip = Ref +base_classes_to_skip = RefCounted # classes that create no constructor # Set is special and we will use a hand-written constructor diff --git a/native/tools/tojs/gen_d_ts/.gitignore b/native/tools/tojs/gen_d_ts/.gitignore new file mode 100644 index 0000000000..252089dee2 --- /dev/null +++ b/native/tools/tojs/gen_d_ts/.gitignore @@ -0,0 +1,2 @@ +node_modules/ +out/ \ No newline at end of file diff --git a/native/tools/tojs/gen_d_ts/decl/predefine.d.ts b/native/tools/tojs/gen_d_ts/decl/predefine.d.ts new file mode 100644 index 0000000000..6fdb3f9638 --- /dev/null +++ b/native/tools/tojs/gen_d_ts/decl/predefine.d.ts @@ -0,0 +1,47 @@ +/* eslint-disable no-multiple-empty-lines */ +/* eslint-disable no-trailing-spaces */ +declare namespace jsb { + // type Node = any; + type Event = any; + type NodeEventProcessor = any; + type Mat4 = any; + type Mat3 = any; + type Vec2 = any; + type Vec3 = any; + type Vec4 = any; + type Quaternion = any; + type Rect = any; + type Color = any; + type NativeDep = any; + type RenderableComponent = any; + type ResizableBuffer = any; + type Size = any; + type DataPoolManager = any; + type IProgramInfo = any; + type ReflectionComp = any; + type SAXDelegator = any; + type Data = any; + type NodeUiProperties = any; + type CallbacksInvoker = any; + + type AnyFunction = any; + + type Component = any; // should be export latter +} + +// namespace cc { +// type Component = any; +// } + +declare namespace ns { + type RenderWindow = any; + type InstancedAttributeBlock = any; +} +declare namespace nr { + type InstancedAttributeBlock = any; + type PipelineSceneData = any; + type PipelineUBO = any; + type RenderElem = any; + type RenderQueue = any; + type UIPhase = any; +} diff --git a/native/tools/tojs/gen_d_ts/decl/typeinfo.d.ts b/native/tools/tojs/gen_d_ts/decl/typeinfo.d.ts new file mode 100644 index 0000000000..390b88aad5 --- /dev/null +++ b/native/tools/tojs/gen_d_ts/decl/typeinfo.d.ts @@ -0,0 +1,93 @@ + + + +declare interface NativeType { + name: string; + script_ns: string; + whole_name: string; + namespace_name: string; + namespaced_class_name: string; + is_const: boolean; + is_pointer: boolean; + is_reference: boolean; + is_rreference: boolean; + is_object: boolean; + is_struct: boolean; + is_function: boolean; + is_enum: boolean; + is_numeric: boolean; + enum_declare_type: string; + param_types: NativeType[]; + ret_type: NativeType|null; +} + + +declare interface NativeField { + name: string; + pretty_name: string; + signature_name: string; + type: NativeType; + is_static: boolean; + is_static_const:boolean; +} + + +declare interface NativeFunction { + name: string; + signature_name: string; + arguments: NativeType[]; + argumentTips: string[]; + static: boolean; + min_args:number; + is_overloaded: boolean; + is_constructor: boolean; + not_supported: boolean; + ret_type: NativeType; + current_class_name: string; + comment: string; + should_skip_function:boolean; +} + + +declare interface NativeOverloadedFunction { + name: string; + signature_name: string; + min_args: number; + comment: string; + is_ctor: boolean; + current_class_name: string|null; + implementations: NativeFunction[]; + should_skip_function:boolean; +} + +declare interface NativeAttribute { + name: string; + type: NativeType; + names: string[]; +} + +type MethodMap = { + [key: string]: NativeFunction|NativeOverloadedFunction +}; + +declare interface NativeClass { + namespace_name: string; + script_ns: string; + parents: string[]; + nested_classes: string[]; + class_name: string; + is_ref_class: boolean; + namespaced_class_name: string; + underlined_class_name: string; + is_struct: boolean; + is_abstract: boolean; + is_persistent: boolean; + is_class_owned_by_cpp: boolean; + has_constructor: boolean; + public_fields: NativeField[]; + override_methods?: MethodMap; + getter_setter: NativeAttribute[]; + methods: MethodMap; + static_methods: MethodMap; + dict_of_override_method_should_be_bound: MethodMap; +} \ No newline at end of file diff --git a/native/tools/tojs/gen_d_ts/index.ts b/native/tools/tojs/gen_d_ts/index.ts new file mode 100644 index 0000000000..d6c5687e84 --- /dev/null +++ b/native/tools/tojs/gen_d_ts/index.ts @@ -0,0 +1,587 @@ + +import fs from 'fs'; +import path from 'path'; + +const dir = path.normalize(path.join(__dirname, '../../../../cocos/bindings/auto')); +const jsonFiles = fs.readdirSync(dir).filter(x => x.endsWith('.json')).map(x => path.join(dir, x)); +const outFilePath = path.join(__dirname, 'jsb_auto.d.ts'); +let copyTo = path.normalize(path.join(__dirname, '../../../../../engine/@types/jsb.auto.d.ts')); +const copyFiles: string[] = [path.join(__dirname, '../decl/predefine.d.ts'), outFilePath]; + +if(process.argv.length >= 3) { + const argv = process.argv; + if( !fs.existsSync(path.join(argv[2], '@types'))) { + console.error(`Directory '${argv[2]}/@types' does not exists, not a engine path?`); + process.exit(-2); + } + copyTo = path.join(argv[2], '@types/jsb.auto.d.ts'); +} + + +const outFile = fs.openSync(outFilePath, 'w'); +const exportNamespaces = ['gfx', 'cc', 'jsb', 'nr']; + +let all_classes: NativeClass[] = []; +for (let f of jsonFiles) { + console.log(`require ${f}`); + const content = fs.readFileSync(f).toString(); + if (content.length > 0) { + all_classes = all_classes.concat(JSON.parse(content)); + } +} + +let nameToClass: { [key: string]: NativeClass } = {}; +let nsToClass: { [key: string]: NativeClass[] } = {}; +let fullNameToClass: { [key: string]: NativeClass } = {}; +let enumClassMap: {[key:string]:boolean} ={}; + + +interface TypeRecursive { + name: string; + children: TypeRecursive[]; + is_optional?: boolean; +} +namespace utils { + + let additional_type_mape: any = { + 'cc::Vec2': 'jsb.Vec2', + 'cc::Vec3': 'jsb.Vec3', + 'cc::Vec4': 'jsb.Vec4', + 'cc::Mat3': 'jsb.Mat3', + 'cc::Mat4': 'jsb.Mat4', + 'cc::Color': 'jsb.Color', + 'cc::Quaternion':'jsb.Quaternion', + // 'cc::Que': 'jsb.Mat4', + 'cc::gfx::AccessType': 'number', + 'cc::gfx::DescriptorType':'number', + 'cc::Value': 'any', + 'jsb.Device::MotionValue': 'any', + } + + function type_string_to_tree(input: string) { + let stack: TypeRecursive[] = [{ name: 'root', children: [] }]; + let l = input.length; + let p = 0; + for (let i = 0; i < l; i++) { + if (input.charAt(i) === '<') { + let n = { name: input.slice(p, i).trim(), children: [] }; + stack[stack.length - 1].children.push(n); + stack.push(n); + p = i + 1; + } else if (input.charAt(i) === '>') { + if (i > p) { + let n = { name: input.slice(p, i).trim(), children: [] }; + stack[stack.length - 1].children.push(n); + } + p = i + 1; + stack.pop(); + } else if (input.charAt(i) === ',') { + if (i > p) { + let n = { name: input.slice(p, i).trim(), children: [] }; + stack[stack.length - 1].children.push(n); + } + p = i + 1; + } + } + if (p < l) { + stack[stack.length - 1].children.push({ name: input.slice(p, l), children: [] }); + } + let ret = stack[0].children![0]; + return ret; + } + + export function parse_type_string(input: string, type_convert: (d: string) => string | undefined): string | undefined { + const info = type_string_to_tree(input); + const result = walk_through_type_tree(info, type_convert); + if (result) return (info.is_optional ? '?: ' : ' : ') + result; + } + + function onlyUnique(value: string, index: number, self: string[]) { + return self.indexOf(value) === index; + } + + function walk_through_type_tree(info: TypeRecursive, type_convert: (d: string) => string | undefined): string | undefined { + + if(/(const)?\s*void\s*\*/.test(info.name)) { + return 'ArrayBuffer'; + } + if(info.name == 'void') { + return 'void'; + } + if (/char\s*\*/.test(info.name)) { + return 'string'; + } + if (info.name.startsWith('std::string')) { + return 'string'; + } + if (info.name.startsWith('std::optional')) { + info.is_optional = true; + return walk_through_type_tree(info.children[0], type_convert); + } + + if(info.name.startsWith('std::array') && info.children[0].name.indexOf('::') < 0) { + + return convert_typed_array(info.children[0].name.match(/(.*)/)!) + } + + if (info.name.startsWith('std::vector') || info.name.startsWith('std::array')) { + return walk_through_type_tree(info.children[0], type_convert) + '[]'; + } + if (info.name.startsWith('std::tuple')) { + return '[' + info.children.map(x => walk_through_type_tree(x, type_convert)).join(', ') + ']' + } + if (info.name.startsWith('std::variant')) { + return '(' + info.children.map(x => walk_through_type_tree(x, type_convert)).filter(onlyUnique as any).join('|') + ')' + } + if (info.name.startsWith('std::unordered_map')) { + return `{[key:${walk_through_type_tree(info.children[0], type_convert)}]:${walk_through_type_tree(info.children[1], type_convert)}}`; + } + if (info.name.startsWith('std::any')) { + return `any`; + } + if (info.name.startsWith('std::map')) { + return `{[key:${walk_through_type_tree(info.children[0], type_convert)}]:${walk_through_type_tree(info.children[1], type_convert)};}`; + } + if (info.name.startsWith('std::shared_ptr')) { + return walk_through_type_tree(info.children[0], type_convert); + } + if (info.name.startsWith('std::monostate')) { + info.is_optional = true; + return `undefined`; + } + + if (/char|int|long|short|float|double/.test(info.name)) { + return 'number'; + } + if (/bool/.test(info.name)) { + return 'boolean'; + } + if (info.name.startsWith('std::function')) { + return `AnyFunction`; + } + if (info.name.indexOf('TypedArrayTemp') >= 0) { + return convert_typed_array(info.children[0].name.match(/(.*)/)!) + } + + if(info.name.indexOf('ArrayBuffer') >= 0) { + return 'ArrayBuffer'; + } + + if (info.name === 'nowhere') { + return 'unknown'; + } + + if (info.children.length > 1) { + throw new Error(`dont know how to handle ${JSON.stringify(info, null, 2)}`); + } + + return type_convert(info.name); + // return info.name; + } + + + export function cpptype_to_script_ns(name: string): string | undefined { + name = name.replace(/(\*|&)/g, '').trim(); + let m = fullNameToClass[name]; + if (m) { + return `${m.script_ns.replace(/::/g,'.')}`; + } + let s = additional_type_mape[name]; + if (s) return s; + + if(enumClassMap[name] && name.indexOf('::') > 0) { + return `number`; + } + + } + + function convert_typed_array(r: RegExpMatchArray): string { + let c = r[1]; + if (/unsigned char/.test(c)) { + return 'Uint8Array'; + } + if (/char/.test(c)) { + return 'Int8Array'; + } + if (/float/.test(c)) { + return 'Float32Array'; + } + if (/double/.test(c)) { + return 'Float64Array'; + } + if (/unsigned.*int/.test(c)) { + return 'Uint32Array'; + } + if (/unsigned.*short/.test(c)) { + return 'Uint16Array'; + } + if (/int/.test(c)) { + return 'Int32Array'; + } + if (/short/.test(c)) { + return 'Int16Array'; + } + return `Uint32Array /*${c}*/`; + } + + interface IType { + script_ns:string; + is_enum?:boolean; + namespace_name?:string; + whole_name?:string; + } + + export function fix_type_name(t: IType): string { + let r:string|undefined; + if(t.namespace_name !== undefined && t.namespace_name.length == 0) { + r = parse_type_string(t.whole_name!, fallback_step.bind(null, t)); + }else { + r = parse_type_string(t.script_ns, fallback_step.bind(null, t)); + } + if (r) + r = r.trim(); + r = fallback_step(t, r!); + r = r.replace(/::/g,'.').replace(/\*|&/,'').replace(/^const /,'').trim(); + if (r.startsWith('?:') || r.startsWith(':')) return r; + return ': ' + r; + } + + + function fallback_step(t: IType, r: string): string { + if(r.startsWith("const ")) { + r = r.slice(6); + } + let full = cpptype_to_script_ns(r); + if (full) { + return full; + } + + full = cpptype_to_script_ns(t.script_ns); + if (full) { + return full; + } + + { + let kls = nameToClass[r]; + // treat enum as number + if (!kls && t.is_enum) { + return 'number'; + } + if (!kls && r.startsWith('sp.')) { + return `unknown /*${t.script_ns}*/`; + } + + if (kls) { + return `${kls.script_ns.replace(/::/g, '.')}`; + } + } + return r; + } + + export function fix_type_name_clean(t: IType) { + let ret = fix_type_name(t); + if (ret.startsWith('?: ')) { + return ret.substr(3); + } + if (ret.startsWith(': ')) { + return ret.substr(2); + } + return ret; + } + + export function fix_type_name_undefined(t: IType) { + let ret = fix_type_name(t); + if (ret.startsWith('?: ')) { + return `undefined|${ret.substr(3)}`; + } + if (ret.startsWith(': ')) { + return ret.substr(2); + } + return ret; + } + + export function addIndent(content: string, spaces: number): string { + let sp: string = ''; + while (spaces-- > 0) { + sp += ' '; + } + return content.split('\n').map(x => { + if (!/^\s+$/.test(x)) { + return `${sp}${x}`; + } else { + return x; + } + }) + .join('\n'); + } + + export function align(alignment: number) { + return (3 - (alignment + 3) % 4) + alignment; + } + + export function alignText(text: string, alignment: number) { + while (text.length < alignment) { + text += ' '; + } + return text; + } + + interface RecursiveArray { + [key: number]: T | RecursiveArray; + length: number + } + + function flatMap(data: RecursiveArray, cb: (v: T) => T) { + let ret: T[] = []; + flatMapImpl(data, (v: T) => { + ret.push(cb(v)); + }); + return ret; + } + + function flatMapImpl(data: RecursiveArray, cb: (v: T) => void) { + for (let i = 0; i < data.length; i++) { + if (data[i] instanceof Array) { + flatMapImpl(data[i] as RecursiveArray, cb); + } else { + cb(data[i] as T); + } + } + } + + export function formatComment(comment: string): string[] { + return flatMap(comment.split(/\/).map(x => x.split('\n')), x => { + if (x.startsWith('*--')) { + return ' ' + x.substr(3); + } + if (x.startsWith('*')) { + return ' ' + x.substr(1); + } + if (x.startsWith('--')) { + return ' ' + x.substr(2); + } + return x; + }).map(x => x.trim()); //.filter(x=> x.length > 0); + } +} + +const UF = utils.fix_type_name; +const UFC = utils.fix_type_name_clean; +const UFU = utils.fix_type_name_undefined; + +function processMethod(m: NativeFunction | NativeOverloadedFunction): string[] { + let overloaded = m as NativeOverloadedFunction; + let method = m as NativeFunction; + let name = m.name; + if (overloaded.implementations) { + let ret: string[] = []; + for (let x of overloaded.implementations) { + ret = ret.concat(processMethod(x)); + } + return ret; + } else { + let tips = method.argumentTips || []; + let args = method.arguments.map((x, i) => `${tips[i] || ('arg' + i)}${UF(x)}`);//.join(', '); + if (method.is_constructor) { + //return [`new (${args}): ${method.current_class_name};`]; + return [`constructor(${args.join(', ')});`]; + } + const prefix = args.join(', ').indexOf('??') > 0 ? '// ' : ''; + const comment = method.comment.length > 0 ? `/**\n${utils.formatComment(method.comment).map(x => ' * ' + x).join('\n')}\n */\n` : ''; + const static_prefix = method.static ? 'static ' : ''; + let functions:string[] = []; // [`// min_args ${method.min_args} - ${method.arguments.length}`]; + for(let i = method.min_args; i <= method.arguments.length;i++) { + functions.push(`${prefix}${static_prefix}${name}(${args.slice(0, i).join(', ')}):${UFU(method.ret_type)}; // ${method.ret_type.namespaced_class_name}`) + } + return [`${comment}${functions.join('\n')}`]; + } +} + + +function processClass(klass: NativeClass): string { + let buffer: string[] = []; + + + const extends_field = klass.parents.length == 0 ? '' : + `extends ${klass.parents.map(x => UFC({ script_ns: utils.cpptype_to_script_ns(x) || x, is_enum: false, namespace_name:"???" }))} `; + + buffer.push('\n'); + + const sub_classes = all_classes.filter(x => (x.nested_classes[0] == klass.class_name) && x.nested_classes[0]); + if (sub_classes.length > 0) { + buffer.push(`export namespace ${klass.class_name} {`); + buffer.push(utils.addIndent(sub_classes.map(processClass).join('\n'), 4)); + buffer.push('} // endof namespace ${klass.class_name} \n'); + } + buffer.push(`// ts : ${klass.script_ns}\n// cpp: ${klass.namespaced_class_name}`); + buffer.push(`export class ${klass.class_name} ${extends_field}{`); + + + // if(klass.namespaced_class_name.indexOf("DrawInfo") >=0 ){ + // console.log(`attributes ${klass.getter_setter.map(x=>x.name)}`); + // } + + + + if (klass.getter_setter.length > 0) { + //export attributes + { + let attrBuffer: string[] = []; + attrBuffer.push(`// attributes list`); + let maxLeft = 0; + let maxMiddle = 0; + let lines: [string, string, string][] = []; + for (let attr of klass.getter_setter) { + for (let name of attr.names) { + let p: [string, string, string] = [`${name}`, `${UF(attr.type)};`, `// ${attr.type.namespaced_class_name}`]; + maxLeft = Math.max(maxLeft, p[0].length); + maxMiddle = Math.max(maxMiddle, p[1].length); + lines.push(p); + } + } + let left = utils.align(maxLeft); + let middle = utils.align(maxMiddle); + for (let l of lines) { + attrBuffer.push([utils.alignText(l[0], left), utils.alignText(l[1], middle), l[2]].join('')); + } + + buffer.push(utils.addIndent(attrBuffer.join('\n'), 4)) + } + } + + if (klass.public_fields.length > 0) { + //export attributes + { + let attrBuffer: string[] = []; + attrBuffer.push(`// public_fields list`); + let maxLeft = 0; + let maxMiddle = 0; + let lines: [string, string, string][] = []; + for (let attr of klass.public_fields) { + let p: [string, string, string] = [`${attr.is_static?"static ":""}${attr.is_static_const?"readonly ":""}${attr.name}`, `${UF(attr.type)};`, `// ${attr.type.namespaced_class_name}`]; + maxLeft = Math.max(maxLeft, p[0].length); + maxMiddle = Math.max(maxMiddle, p[1].length); + lines.push(p); + } + let left = utils.align(maxLeft); + let middle = utils.align(maxMiddle); + for (let l of lines) { + attrBuffer.push([utils.alignText(l[0], left), utils.alignText(l[1], middle), l[2]].join('')); + } + + buffer.push(utils.addIndent(attrBuffer.join('\n'), 4)) + } + } + + if (Object.keys(klass.static_methods).length > 0) { + // export methods + { + { + let methodBuffer: string[] = []; + methodBuffer.push(`// static methods list`); + for (let attr in klass.static_methods) { + const m = klass.static_methods[attr]; + if (attr.startsWith('operator')) continue; + methodBuffer.push(`${processMethod(m).join('\n')}`); + } + buffer.push(utils.addIndent(methodBuffer.join('\n'), 4)) + } + } + } + + if (Object.keys(klass.methods).length > 0) { + // export methods + { + { + let methodBuffer: string[] = []; + methodBuffer.push(`// methods list`); + for (let attr in klass.methods) { + const m = klass.methods[attr]; + if (attr.startsWith('operator')) continue; + methodBuffer.push(`${processMethod(m).join('\n')}`); + } + buffer.push(utils.addIndent(methodBuffer.join('\n'), 4)) + } + } + } + + + buffer.push(`} // endof class ${klass.class_name}`); + return buffer.join('\n'); +} + + +all_classes.reduce((prev, curr) => { + let ns = curr.script_ns.split('.'); + if (ns.length > 1) { + ns.pop(); + prev[ns[0]] = prev[ns[0]] ? prev[ns[0]].concat(curr) : [curr]; + } else { + console.error(`Skip bad namespace '${curr.script_ns}' from class ${curr.namespaced_class_name}`); + } + return prev; +}, nsToClass); + + +const register_all_enums = (fn :NativeFunction|NativeOverloadedFunction) => { + let ol = fn as NativeOverloadedFunction; + let sf = fn as NativeFunction; + if(ol.implementations) { + ol.implementations.forEach(x => register_all_enums(x)); + }else{ + if(sf.ret_type && sf.ret_type.is_enum) { + enumClassMap[sf.ret_type.namespaced_class_name] = true; + } + for(let t of sf.arguments) { + if(t.is_enum) { + enumClassMap[sf.ret_type.namespaced_class_name] = true; + } + } + } +}; + +// setup table +all_classes.forEach(kls => { + nameToClass[kls.script_ns] = kls; + fullNameToClass[kls.namespaced_class_name] = kls; + + for(let name in kls.methods) { + register_all_enums(kls.methods[name]); + } + for(let name in kls.static_methods) { + register_all_enums(kls.static_methods[name]); + } +}); + + + + +const topBuffer: string[] = []; + +for (let ns of exportNamespaces) { + let klist = nsToClass[ns]; + if (!klist) { + console.error(`[error] namespace '${ns}' not found!`); + continue; + } + topBuffer.push(`declare namespace ${ns} {`); + topBuffer.push(utils.addIndent(klist.filter(x => x.nested_classes.length == 0).map(processClass).join('\n'), 4)); + topBuffer.push(`} // endof namespace ${ns}\n`); +} + + + +fs.writeFileSync(outFile, topBuffer.join('\n')); + +fs.writeFileSync(outFile, `\n\n\n// ${all_classes.length} classes process!\n`); + +fs.closeSync(outFile); + +{ + copyTo = path.normalize(copyTo); + let finalFile = fs.openSync(copyTo, 'w'); + copyFiles.forEach(arr => fs.writeFileSync(finalFile, fs.readFileSync(arr).toString('utf8'))); + fs.closeSync(finalFile); + console.log(` -> copy jsb.auto.d.ts to ${copyTo}`) +} +console.log(` -> ${all_classes.length} classes exported`); diff --git a/native/tools/tojs/gen_d_ts/package-lock.json b/native/tools/tojs/gen_d_ts/package-lock.json new file mode 100644 index 0000000000..dbdee2b395 --- /dev/null +++ b/native/tools/tojs/gen_d_ts/package-lock.json @@ -0,0 +1,13 @@ +{ + "name": "gen_d_ts", + "version": "1.0.0", + "lockfileVersion": 1, + "requires": true, + "dependencies": { + "@types/node": { + "version": "16.10.3", + "resolved": "https://repo.huaweicloud.com/repository/npm/@types/node/-/node-16.10.3.tgz", + "integrity": "sha512-ho3Ruq+fFnBrZhUYI46n/bV2GjwzSkwuT4dTf0GkuNFmnb8nq4ny2z9JEVemFi6bdEJanHLlYfy9c6FN9B9McQ==" + } + } +} diff --git a/native/tools/tojs/gen_d_ts/package.json b/native/tools/tojs/gen_d_ts/package.json new file mode 100644 index 0000000000..a9b7227bd8 --- /dev/null +++ b/native/tools/tojs/gen_d_ts/package.json @@ -0,0 +1,14 @@ +{ + "name": "gen_d_ts", + "version": "1.0.0", + "description": "", + "main": "index.js", + "scripts": { + "test": "echo \"Error: no test specified\" && exit 1" + }, + "author": "", + "license": "ISC", + "dependencies": { + "@types/node": "^16.10.3" + } +} diff --git a/native/tools/tojs/gen_d_ts/tsconfig.json b/native/tools/tojs/gen_d_ts/tsconfig.json new file mode 100644 index 0000000000..ded628da40 --- /dev/null +++ b/native/tools/tojs/gen_d_ts/tsconfig.json @@ -0,0 +1,100 @@ +{ + "compilerOptions": { + /* Visit https://aka.ms/tsconfig.json to read more about this file */ + + /* Projects */ + // "incremental": true, /* Enable incremental compilation */ + // "composite": true, /* Enable constraints that allow a TypeScript project to be used with project references. */ + // "tsBuildInfoFile": "./", /* Specify the folder for .tsbuildinfo incremental compilation files. */ + // "disableSourceOfProjectReferenceRedirect": true, /* Disable preferring source files instead of declaration files when referencing composite projects */ + // "disableSolutionSearching": true, /* Opt a project out of multi-project reference checking when editing. */ + // "disableReferencedProjectLoad": true, /* Reduce the number of projects loaded automatically by TypeScript. */ + + /* Language and Environment */ + "target": "es5", /* Set the JavaScript language version for emitted JavaScript and include compatible library declarations. */ + // "lib": [], /* Specify a set of bundled library declaration files that describe the target runtime environment. */ + // "jsx": "preserve", /* Specify what JSX code is generated. */ + // "experimentalDecorators": true, /* Enable experimental support for TC39 stage 2 draft decorators. */ + // "emitDecoratorMetadata": true, /* Emit design-type metadata for decorated declarations in source files. */ + // "jsxFactory": "", /* Specify the JSX factory function used when targeting React JSX emit, e.g. 'React.createElement' or 'h' */ + // "jsxFragmentFactory": "", /* Specify the JSX Fragment reference used for fragments when targeting React JSX emit e.g. 'React.Fragment' or 'Fragment'. */ + // "jsxImportSource": "", /* Specify module specifier used to import the JSX factory functions when using `jsx: react-jsx*`.` */ + // "reactNamespace": "", /* Specify the object invoked for `createElement`. This only applies when targeting `react` JSX emit. */ + // "noLib": true, /* Disable including any library files, including the default lib.d.ts. */ + // "useDefineForClassFields": true, /* Emit ECMAScript-standard-compliant class fields. */ + + /* Modules */ + "module": "commonjs", /* Specify what module code is generated. */ + // "rootDir": "./", /* Specify the root folder within your source files. */ + // "moduleResolution": "node", /* Specify how TypeScript looks up a file from a given module specifier. */ + // "baseUrl": "./", /* Specify the base directory to resolve non-relative module names. */ + // "paths": {}, /* Specify a set of entries that re-map imports to additional lookup locations. */ + // "rootDirs": [], /* Allow multiple folders to be treated as one when resolving modules. */ + "typeRoots": ["node_modules/@types", "decl/"], /* Specify multiple folders that act like `./node_modules/@types`. */ + // "types": [], /* Specify type package names to be included without being referenced in a source file. */ + // "allowUmdGlobalAccess": true, /* Allow accessing UMD globals from modules. */ + // "resolveJsonModule": true, /* Enable importing .json files */ + // "noResolve": true, /* Disallow `import`s, `require`s or ``s from expanding the number of files TypeScript should add to a project. */ + + /* JavaScript Support */ + // "allowJs": true, /* Allow JavaScript files to be a part of your program. Use the `checkJS` option to get errors from these files. */ + // "checkJs": true, /* Enable error reporting in type-checked JavaScript files. */ + // "maxNodeModuleJsDepth": 1, /* Specify the maximum folder depth used for checking JavaScript files from `node_modules`. Only applicable with `allowJs`. */ + + /* Emit */ + // "declaration": true, /* Generate .d.ts files from TypeScript and JavaScript files in your project. */ + // "declarationMap": true, /* Create sourcemaps for d.ts files. */ + // "emitDeclarationOnly": true, /* Only output d.ts files and not JavaScript files. */ + // "sourceMap": true, /* Create source map files for emitted JavaScript files. */ + // "outFile": "./", /* Specify a file that bundles all outputs into one JavaScript file. If `declaration` is true, also designates a file that bundles all .d.ts output. */ + "outDir": "./out", /* Specify an output folder for all emitted files. */ + // "removeComments": true, /* Disable emitting comments. */ + // "noEmit": true, /* Disable emitting files from a compilation. */ + // "importHelpers": true, /* Allow importing helper functions from tslib once per project, instead of including them per-file. */ + // "importsNotUsedAsValues": "remove", /* Specify emit/checking behavior for imports that are only used for types */ + // "downlevelIteration": true, /* Emit more compliant, but verbose and less performant JavaScript for iteration. */ + // "sourceRoot": "", /* Specify the root path for debuggers to find the reference source code. */ + // "mapRoot": "", /* Specify the location where debugger should locate map files instead of generated locations. */ + // "inlineSourceMap": true, /* Include sourcemap files inside the emitted JavaScript. */ + // "inlineSources": true, /* Include source code in the sourcemaps inside the emitted JavaScript. */ + // "emitBOM": true, /* Emit a UTF-8 Byte Order Mark (BOM) in the beginning of output files. */ + // "newLine": "crlf", /* Set the newline character for emitting files. */ + // "stripInternal": true, /* Disable emitting declarations that have `@internal` in their JSDoc comments. */ + // "noEmitHelpers": true, /* Disable generating custom helper functions like `__extends` in compiled output. */ + // "noEmitOnError": true, /* Disable emitting files if any type checking errors are reported. */ + // "preserveConstEnums": true, /* Disable erasing `const enum` declarations in generated code. */ + // "declarationDir": "./", /* Specify the output directory for generated declaration files. */ + + /* Interop Constraints */ + // "isolatedModules": true, /* Ensure that each file can be safely transpiled without relying on other imports. */ + // "allowSyntheticDefaultImports": true, /* Allow 'import x from y' when a module doesn't have a default export. */ + "esModuleInterop": true, /* Emit additional JavaScript to ease support for importing CommonJS modules. This enables `allowSyntheticDefaultImports` for type compatibility. */ + // "preserveSymlinks": true, /* Disable resolving symlinks to their realpath. This correlates to the same flag in node. */ + "forceConsistentCasingInFileNames": true, /* Ensure that casing is correct in imports. */ + + /* Type Checking */ + "strict": true, /* Enable all strict type-checking options. */ + // "noImplicitAny": true, /* Enable error reporting for expressions and declarations with an implied `any` type.. */ + // "strictNullChecks": true, /* When type checking, take into account `null` and `undefined`. */ + // "strictFunctionTypes": true, /* When assigning functions, check to ensure parameters and the return values are subtype-compatible. */ + // "strictBindCallApply": true, /* Check that the arguments for `bind`, `call`, and `apply` methods match the original function. */ + // "strictPropertyInitialization": true, /* Check for class properties that are declared but not set in the constructor. */ + // "noImplicitThis": true, /* Enable error reporting when `this` is given the type `any`. */ + // "useUnknownInCatchVariables": true, /* Type catch clause variables as 'unknown' instead of 'any'. */ + // "alwaysStrict": true, /* Ensure 'use strict' is always emitted. */ + // "noUnusedLocals": true, /* Enable error reporting when a local variables aren't read. */ + // "noUnusedParameters": true, /* Raise an error when a function parameter isn't read */ + // "exactOptionalPropertyTypes": true, /* Interpret optional property types as written, rather than adding 'undefined'. */ + // "noImplicitReturns": true, /* Enable error reporting for codepaths that do not explicitly return in a function. */ + // "noFallthroughCasesInSwitch": true, /* Enable error reporting for fallthrough cases in switch statements. */ + // "noUncheckedIndexedAccess": true, /* Include 'undefined' in index signature results */ + // "noImplicitOverride": true, /* Ensure overriding members in derived classes are marked with an override modifier. */ + // "noPropertyAccessFromIndexSignature": true, /* Enforces using indexed accessors for keys declared using an indexed type */ + // "allowUnusedLabels": true, /* Disable error reporting for unused labels. */ + // "allowUnreachableCode": true, /* Disable error reporting for unreachable code. */ + + /* Completeness */ + // "skipDefaultLibCheck": true, /* Skip type checking .d.ts files that are included with TypeScript. */ + "skipLibCheck": true /* Skip type checking all .d.ts files. */ + } +} diff --git a/native/tools/tojs/genbindings.py b/native/tools/tojs/genbindings.py index 6719fd2b97..e0c655a34a 100755 --- a/native/tools/tojs/genbindings.py +++ b/native/tools/tojs/genbindings.py @@ -26,7 +26,10 @@ defaultSections = [ 'dragonbones', 'physics', 'scene', + 'geometry', + 'assets' ] + projectRoot = os.path.abspath(os.path.join(os.path.dirname(__file__), '..', '..')) defaultOutputDir = '%s/cocos/bindings/auto' % projectRoot @@ -178,6 +181,7 @@ def main(): if filename is None: filename = 'jsb_%s_auto' % section print ('!!----------Generating bindings for %s----------!!' % (section)) command = '%s -W ignore %s %s -s %s -t %s -o %s -n %s' % (python_bin, generator_py, cfg, section, target, directory, filename) + print ("command : %s" % (command)) # tasks.append(_run_cmd(command)) _run_cmd(command).communicate() @@ -185,9 +189,14 @@ def main(): for path in sys.argv[2:]: generate(path.replace('\\', '/')) else: + genCnt = 0 for section in defaultSections: if len(sys.argv) <= 1 or any(section in s for s in sys.argv[1:]): generate('%s/%s.ini' % (tojs_root, section), defaultOutputDir) + genCnt += 1 + if genCnt == 0: + print ('----------------------------------------') + print ('Warn: no ini found, update var `defaultSections`?') # for t in tasks: # t.communicate() diff --git a/native/tools/tojs/geometry.ini b/native/tools/tojs/geometry.ini new file mode 100644 index 0000000000..6ca9b05651 --- /dev/null +++ b/native/tools/tojs/geometry.ini @@ -0,0 +1,70 @@ +[geometry] +# the prefix to be added to the generated functions. You might or might not use this in your own +# templates +prefix = geometry + +#cpp_headers = + +# create a target namespace (in javascript, this would create some code like the equiv. to `ns = ns || {}`) +# all classes will be embedded in that namespace +target_namespace = ns + +android_headers = + +android_flags = -target armv7-none-linux-androideabi -D_LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS -DANDROID -D__ANDROID_API__=14 -gcc-toolchain %(gcc_toolchain_dir)s --sysroot=%(androidndkdir)s/platforms/android-14/arch-arm -idirafter %(androidndkdir)s/sources/android/support/include -idirafter %(androidndkdir)s/sysroot/usr/include -idirafter %(androidndkdir)s/sysroot/usr/include/arm-linux-androideabi -idirafter %(clangllvmdir)s/lib64/clang/5.0/include -I%(androidndkdir)s/sources/cxx-stl/llvm-libc++/include + +clang_headers = +clang_flags = -nostdinc -x c++ -std=c++17 -fsigned-char -U__SSE__ + +cocos_headers = -I%(cocosdir)s/cocos -I%(cocosdir)s/cocos/renderer -I%(cocosdir)s -I%(cocosdir)s/cocos/platform/android -I%(cocosdir)s/external/sources -I%(cocosdir)s/external/ios/include/v8 + +cocos_flags = -DANDROID -DCC_PLATFORM=3 -DCC_PLATFORM_MAC_IOS=1 -DCC_PLATFORM_MAC_OSX=4 -DCC_PLATFORM_WINDOWS=2 -DCC_PLATFORM_ANDROID=3 + + +cxxgenerator_headers = + +# extra arguments for clang +extra_arguments = %(android_headers)s %(clang_headers)s %(cxxgenerator_headers)s %(cocos_headers)s %(android_flags)s %(clang_flags)s %(cocos_flags)s %(extra_flags)s + +# what headers to parse +headers = %(cocosdir)s/cocos/core/geometry/Geometry.h + +hpp_headers = cocos/bindings/auto/jsb_cocos_auto.h + +# what classes to produce code for. You can use regular expressions here. When testing the regular +# expression, it will be enclosed in "^$", like this: "^Menu*$". +classes = AABB Obb Line Plane Frustum Capsule Sphere Triangle Ray ShapeBase + +# what should we skip? in the format ClassName::[function function] +# ClassName is a regular expression, but will be used like this: "^ClassName$" functions are also +# regular expressions, they will not be surrounded by "^$". If you want to skip a whole class, just +# add a single "*" as functions. See bellow for several examples. A special class name is "*", which +# will apply to all class names. This is a convenience wildcard to be able to skip similar named +# functions from all classes. +skip = AABB::[getBoundary aabbAabb aabbFrustum aabbPlan merge transform transformExtentM4 isValid setValid set fromPoints (g|s)etCenter (g|s)etHalfExtents], + Frustum::[update type planes split], + Plane::[clone copy normalize getSpotAngle fromNormalAndPoint fromPoints set], + Ray::[computeHit], + Sphere::[getBoundary] + +rename_functions = + +getter_setter = ShapeBase::[_type/getType/setType] + +rename_classes = + +field = AABB::[center halfExtents], + Frustum::[vertices planes], + Plane::[n d] + +# for all class names, should we remove something when registering in the target VM? +remove_prefix = + +# classes for which there will be no "parent" lookup +classes_have_no_parents = +# base classes which will be skipped when their sub-classes found them. +base_classes_to_skip = RefCounted + +# classes that create no constructor +# Set is special and we will use a hand-written constructor +abstract_classes = ShapeBase diff --git a/native/tools/tojs/gfx.ini b/native/tools/tojs/gfx.ini index 4976d8548e..c0099dd271 100644 --- a/native/tools/tojs/gfx.ini +++ b/native/tools/tojs/gfx.ini @@ -107,7 +107,7 @@ remove_prefix = classes_have_no_parents = # base classes which will be skipped when their sub-classes found them. -base_classes_to_skip = Ref Clonable Object +base_classes_to_skip = RefCounted Clonable Object # classes that create no constructor # Set is special and we will use a hand-written constructor diff --git a/native/tools/tojs/physics.ini b/native/tools/tojs/physics.ini index 8bf3e55cb0..9c23e9c391 100644 --- a/native/tools/tojs/physics.ini +++ b/native/tools/tojs/physics.ini @@ -16,7 +16,7 @@ android_flags = -target armv7-none-linux-androideabi -D_LIBCPP_DISABLE_VISIBILIT clang_headers = clang_flags = -nostdinc -x c++ -std=c++17 -fsigned-char -mfloat-abi=soft -U__SSE__ -cocos_headers = -I%(cocosdir)s -I%(cocosdir)s/cocos -I%(cocosdir)s/cocos/platform/android -I%(cocosdir)s/external/sources -I%(cocosdir)s/external/android/armeabi-v7a/include/v8 +cocos_headers = -I%(cocosdir)s -I%(cocosdir)s/cocos -I%(cocosdir)s/cocos/platform/android -I%(cocosdir)s/external/sources -I%(cocosdir)s/external/android/armeabi-v7a/include/v8 -I%(cocosdir)s/cocos/renderer cocos_flags = -DANDROID -DCC_PLATFORM=3 -DCC_PLATFORM_MAC_IOS=1 -DCC_PLATFORM_MAC_OSX=4 -DCC_PLATFORM_WINDOWS=2 -DCC_PLATFORM_ANDROID=3 diff --git a/native/tools/tojs/pipeline.ini b/native/tools/tojs/pipeline.ini index 1e2f1d7d1b..ac0c5ba47d 100644 --- a/native/tools/tojs/pipeline.ini +++ b/native/tools/tojs/pipeline.ini @@ -26,13 +26,13 @@ cxxgenerator_headers = extra_arguments = %(android_headers)s %(clang_headers)s %(cxxgenerator_headers)s %(cocos_headers)s %(android_flags)s %(clang_flags)s %(cocos_flags)s %(extra_flags)s # what headers to parse -headers = %(cocosdir)s/cocos/renderer/pipeline/forward/ForwardPipeline.h %(cocosdir)s/cocos/renderer/pipeline/forward/ForwardFlow.h %(cocosdir)s/cocos/renderer/pipeline/forward/ForwardStage.h %(cocosdir)s/cocos/renderer/pipeline/shadow/ShadowFlow.h %(cocosdir)s/cocos/renderer/pipeline/shadow/ShadowStage.h %(cocosdir)s/cocos/renderer/pipeline/RenderPipeline.h %(cocosdir)s/cocos/renderer/pipeline/RenderFlow.h %(cocosdir)s/cocos/renderer/pipeline/RenderStage.h %(cocosdir)s/cocos/renderer/pipeline/Define.h %(cocosdir)s/cocos/renderer/pipeline/GlobalDescriptorSetManager.h %(cocosdir)s/cocos/renderer/pipeline/InstancedBuffer.h %(cocosdir)s/cocos/renderer/pipeline/deferred/DeferredPipeline.h %(cocosdir)s/cocos/renderer/pipeline/deferred/MainFlow.h %(cocosdir)s/cocos/renderer/pipeline/deferred/GbufferStage.h %(cocosdir)s/cocos/renderer/pipeline/deferred/LightingStage.h %(cocosdir)s/cocos/renderer/pipeline/deferred/BloomStage.h %(cocosdir)s/cocos/renderer/pipeline/deferred/PostProcessStage.h %(cocosdir)s/cocos/renderer/pipeline/GeometryRenderer.h +headers = %(cocosdir)s/cocos/renderer/pipeline/forward/ForwardPipeline.h %(cocosdir)s/cocos/renderer/pipeline/forward/ForwardFlow.h %(cocosdir)s/cocos/renderer/pipeline/forward/ForwardStage.h %(cocosdir)s/cocos/renderer/pipeline/shadow/ShadowFlow.h %(cocosdir)s/cocos/renderer/pipeline/shadow/ShadowStage.h %(cocosdir)s/cocos/renderer/pipeline/RenderPipeline.h %(cocosdir)s/cocos/renderer/pipeline/RenderFlow.h %(cocosdir)s/cocos/renderer/pipeline/RenderStage.h %(cocosdir)s/cocos/renderer/pipeline/Define.h %(cocosdir)s/cocos/renderer/pipeline/GlobalDescriptorSetManager.h %(cocosdir)s/cocos/renderer/pipeline/InstancedBuffer.h %(cocosdir)s/cocos/renderer/pipeline/deferred/DeferredPipeline.h %(cocosdir)s/cocos/renderer/pipeline/deferred/MainFlow.h %(cocosdir)s/cocos/renderer/pipeline/deferred/GbufferStage.h %(cocosdir)s/cocos/renderer/pipeline/deferred/LightingStage.h %(cocosdir)s/cocos/renderer/pipeline/deferred/BloomStage.h %(cocosdir)s/cocos/renderer/pipeline/deferred/PostProcessStage.h %(cocosdir)s/cocos/renderer/pipeline/PipelineSceneData.h %(cocosdir)s/cocos/renderer/pipeline/BatchedBuffer.h %(cocosdir)s/cocos/renderer/pipeline/GeometryRenderer.h -hpp_headers = cocos/bindings/auto/jsb_gfx_auto.h cocos/bindings/auto/jsb_scene_auto.h +hpp_headers = cocos/bindings/auto/jsb_gfx_auto.h cocos/bindings/auto/jsb_scene_auto.h cocos/bindings/auto/jsb_assets_auto.h # what classes to produce code for. You can use regular expressions here. When testing the regular # expression, it will be enclosed in "^$", like this: "^Menu*$". -classes = RenderPipeline GlobalDSManager ForwardPipeline ForwardFlow ForwardStage ShadowFlow ShadowStage RenderPipelineInfo RenderFlowInfo RenderStageInfo RenderQueueDesc RenderFlow RenderStage InstancedBuffer DeferredPipeline GbufferStage MainFlow LightingStage BloomStage PostProcessStage GeometryRenderer +classes = RenderPipeline GlobalDSManager ForwardPipeline ForwardFlow ForwardStage ShadowFlow ShadowStage RenderPipelineInfo RenderFlowInfo RenderStageInfo RenderQueueDesc RenderFlow RenderStage InstancedBuffer BatchedBuffer DeferredPipeline GbufferStage MainFlow LightingStage BloomStage PostProcessStage SamplerLib PipelineSceneData BatchedItem RenderObject GeometryRenderer # what should we skip? in the format ClassName::[function function] # ClassName is a regular expression, but will be used like this: "^ClassName$" functions are also @@ -41,7 +41,7 @@ classes = RenderPipeline GlobalDSManager ForwardPipeline ForwardFlow ForwardStag # will apply to all class names. This is a convenience wildcard to be able to skip similar named # functions from all classes. skip = ForwardPipeline::[getOrCreateRenderPass getLightsUBO getValidLights getLightBuffers getLightIndexOffsets getLightIndices getCommandBuffers], - RenderPipeline::[getFlows getTag getGlobalBindings getMacros getDefaultTexture getPipelineSceneData getPipelineUBO getCommandBuffers], + RenderPipeline::[getFlows getTag getGlobalBindings getMacros getDefaultTexture getPipelineUBO getCommandBuffers getFrameGraph], RenderFlow::[render destroy getPriority getName], RenderStage::[render destroy getPriority getName], ForwardFlow::[initialize activate destroy render], @@ -49,7 +49,7 @@ skip = ForwardPipeline::[getOrCreateRenderPass getLightsUBO getValidLights getLi ShadowFlow::[initialize activate destroy render], ShadowStage::[initialize activate destroy render clearFramebuffer], InstancedBuffer::[merge uploadBuffers clear getInstances getPass hasPendingModels dynamicOffsets], - DeferredPipeline::[getOrCreateRenderPass getLightsUBO getValidLights getLightBuffers getLightIndexOffsets getLightIndices getQuadIA setDepth getDepth getRenderArea createQuadInputAssembler destroyQuadInputAssembler getDeferredRenderData updateQuadVertexData genQuadVertexData getIAByRenderArea], + DeferredPipeline::[getOrCreateRenderPass getLightsUBO getValidLights getLightBuffers getLightIndexOffsets getLightIndices getQuadIA setDepth getDepth getRenderArea createQuadInputAssembler destroyQuadInputAssembler getDeferredRenderData updateQuadVertexData genQuadVertexData getIAByRenderArea getFrameGraph getIAByRenderArea], MainFlow::[initialize activate destroy render getFrameBuffer createRenderPass createRenderTargets], GbufferStage::[initialize activate destroy render], LightingStage::[initialize activate destroy render initLightingBuffer gatherLights getReflectRenderQueue getSsprTexWidth getSsprTexHeight addDenoiseIndex getRendElement getReflectionComp getMatViewProj getSsprSampler], @@ -57,12 +57,14 @@ skip = ForwardPipeline::[getOrCreateRenderPass getLightsUBO getValidLights getLi PostProcessStage::[initialize activate destroy render getUIPhase getUIPhase], InstancedBuffer::[merge uploadBuffers clear getInstances getPass hasPendingModels dynamicOffsets], GlobalDSManager::[activate destroy], - GeometryRenderer::[activate flushFromJSB render destroy addDashedLine addLine addTriangle addQuad addBoundingBox addCross addFrustum addCapsule addCylinder addCone addCircle addArc addPolygon addDisc addSector addSphere addTorus addOctahedron addBezier addMesh addIndexedMesh] + GeometryRenderer::[activate flushFromJSB render destroy addDashedLine addLine addTriangle addQuad addBoundingBox addCross addFrustum addCapsule addCylinder addCone addCircle addArc addPolygon addDisc addSector addSphere addTorus addOctahedron addBezier addMesh addIndexedMesh], + PipelineSceneData::[(g|s)etRenderObjects (g|s)etShadowObjects getShadowFramebufferMap] rename_functions = -getter_setter = RenderPipeline::[globalDSManager descriptorSet descriptorSetLayout constantMacros clusterEnabled bloomEnabled], - BloomStage::[threshold intensity iterations] +getter_setter= RenderPipeline::[globalDSManager descriptorSet descriptorSetLayout constantMacros clusterEnabled bloomEnabled pipelineSceneData profiler], + PipelineSceneData::[isHDR/isHDR/setHDR shadingScale fog ambient skybox shadows/getShadows], + BloomStage::[threshold intensity iterations] rename_classes = @@ -72,7 +74,7 @@ remove_prefix = # classes for which there will be no "parent" lookup classes_have_no_parents = # base classes which will be skipped when their sub-classes found them. -base_classes_to_skip = Clonable Object +base_classes_to_skip = Clonable Object RefCounted # classes that create no constructor # Set is special and we will use a hand-written constructor diff --git a/native/tools/tojs/scene.ini b/native/tools/tojs/scene.ini index d583b236ec..37f79d5d5a 100644 --- a/native/tools/tojs/scene.ini +++ b/native/tools/tojs/scene.ini @@ -7,16 +7,16 @@ prefix = scene # create a target namespace (in javascript, this would create some code like the equiv. to `ns = ns || {}`) # all classes will be embedded in that namespace -target_namespace = ns +target_namespace = jsb android_headers = android_flags = -target armv7-none-linux-androideabi -D_LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS -DANDROID -D__ANDROID_API__=14 -gcc-toolchain %(gcc_toolchain_dir)s --sysroot=%(androidndkdir)s/platforms/android-14/arch-arm -idirafter %(androidndkdir)s/sources/android/support/include -idirafter %(androidndkdir)s/sysroot/usr/include -idirafter %(androidndkdir)s/sysroot/usr/include/arm-linux-androideabi -idirafter %(clangllvmdir)s/lib64/clang/5.0/include -I%(androidndkdir)s/sources/cxx-stl/llvm-libc++/include clang_headers = -clang_flags = -nostdinc -x c++ -std=c++14 -fsigned-char -U__SSE__ +clang_flags = -nostdinc -x c++ -std=c++17 -fsigned-char -U__SSE__ -cocos_headers = -I%(cocosdir)s/cocos -I%(cocosdir)s/cocos/renderer -I%(cocosdir)s -I%(cocosdir)s/cocos/platform/android -I%(cocosdir)s/external/sources -I%(cocosdir)s/external/android/armeabi-v7a/include/v8 +cocos_headers = -I%(cocosdir)s/cocos -I%(cocosdir)s/cocos/renderer -I%(cocosdir)s -I%(cocosdir)s/cocos/platform/android -I%(cocosdir)s/external/sources -I%(cocosdir)s/external/android/armeabi-v7a/include/v8 -I%(cocosdir)s/external/android/armeabi-v7a/include/uv cocos_flags = -DANDROID -DCC_PLATFORM=3 -DCC_PLATFORM_MAC_IOS=1 -DCC_PLATFORM_MAC_OSX=4 -DCC_PLATFORM_WINDOWS=2 -DCC_PLATFORM_ANDROID=3 @@ -26,13 +26,42 @@ cxxgenerator_headers = extra_arguments = %(android_headers)s %(clang_headers)s %(cxxgenerator_headers)s %(cocos_headers)s %(android_flags)s %(clang_flags)s %(cocos_flags)s %(extra_flags)s # what headers to parse -headers = %(cocosdir)s/cocos/scene/Node.h %(cocosdir)s/cocos/scene/BaseNode.h %(cocosdir)s/cocos/scene/Scene.h %(cocosdir)s/cocos/scene/Light.h %(cocosdir)s/cocos/scene/DirectionalLight.h %(cocosdir)s/cocos/scene/SpotLight.h %(cocosdir)s/cocos/scene/SphereLight.h %(cocosdir)s/cocos/scene/Model.h %(cocosdir)s/cocos/scene/SubModel.h %(cocosdir)s/cocos/scene/Pass.h %(cocosdir)s/cocos/scene/RenderScene.h %(cocosdir)s/cocos/scene/DrawBatch2D.h %(cocosdir)s/cocos/scene/Camera.h %(cocosdir)s/cocos/scene/RenderWindow.h %(cocosdir)s/cocos/scene/Camera.h %(cocosdir)s/cocos/scene/Define.h %(cocosdir)s/cocos/scene/AABB.h %(cocosdir)s/cocos/scene/Sphere.h +headers = %(cocosdir)s/cocos/core/data/Object.h + %(cocosdir)s/cocos/core/scene-graph/Node.h + %(cocosdir)s/cocos/core/scene-graph/Scene.h + %(cocosdir)s/cocos/core/scene-graph/SceneGlobals.h + %(cocosdir)s/cocos/scene/Light.h + %(cocosdir)s/cocos/scene/Fog.h + %(cocosdir)s/cocos/scene/Shadow.h + %(cocosdir)s/cocos/scene/Skybox.h + %(cocosdir)s/cocos/scene/DirectionalLight.h + %(cocosdir)s/cocos/scene/SpotLight.h + %(cocosdir)s/cocos/scene/SphereLight.h + %(cocosdir)s/cocos/scene/Model.h + %(cocosdir)s/cocos/scene/SubModel.h + %(cocosdir)s/cocos/scene/Pass.h + %(cocosdir)s/cocos/scene/RenderScene.h + %(cocosdir)s/cocos/scene/DrawBatch2D.h + %(cocosdir)s/cocos/scene/RenderWindow.h + %(cocosdir)s/cocos/scene/Camera.h + %(cocosdir)s/cocos/scene/Define.h + %(cocosdir)s/cocos/scene/Ambient.h + %(cocosdir)s/cocos/renderer/core/PassInstance.h + %(cocosdir)s/cocos/renderer/core/MaterialInstance.h + %(cocosdir)s/cocos/3d/models/MorphModel.h + %(cocosdir)s/cocos/3d/models/SkinningModel.h + %(cocosdir)s/cocos/3d/models/BakedSkinningModel.h + %(cocosdir)s/cocos/core/Root.h + %(cocosdir)s/cocos/renderer/core/ProgramLib.h + %(cocosdir)s/cocos/scene/Octree.h -hpp_headers = cocos/bindings/auto/jsb_gfx_auto.h +hpp_headers = cocos/bindings/auto/jsb_gfx_auto.h cocos/bindings/auto/jsb_geometry_auto.h cocos/bindings/auto/jsb_assets_auto.h + +cpp_headers = cocos/bindings/auto/jsb_pipeline_auto.h cocos/bindings/auto/jsb_cocos_auto.h # what classes to produce code for. You can use regular expressions here. When testing the regular # expression, it will be enclosed in "^$", like this: "^Menu*$". -classes = Light BaseNode Node Scene DirectionalLight SpotLight SphereLight Model SubModel Pass RenderScene DrawBatch2D Camera RenderWindow Frustum Plane AABB Sphere Fog Skybox Shadow PipelineSharedSceneData Ambient OctreeInfo Root SkinningModel JointInfo JointTransform BakedSkinningModel BakedJointInfo BakedAnimInfo +classes = Light DirectionalLight SpotLight SphereLight Model SubModel Pass RenderScene DrawBatch2D Camera RenderWindow Fog Skybox Shadows PipelineSharedSceneData Ambient Root SkinningModel BakedSkinningModel IRenderWindowInfo AmbientInfo IRenderSceneInfo ShadowsInfo BaseNode Node SkyboxInfo FogInfo ICameraInfo IMacroPatch IProgramInfo IDefineRecord MaterialInstance IMaterialInstanceInfo PassInstance ProgramLib Scene SceneGlobals InstancedAttributeBlock PassDynamicsValue MorphModel Octree OctreeInfo # what should we skip? in the format ClassName::[function function] # ClassName is a regular expression, but will be used like this: "^ClassName$" functions are also @@ -40,33 +69,67 @@ classes = Light BaseNode Node Scene DirectionalLight SpotLight SphereLight Model # add a single "*" as functions. See bellow for several examples. A special class name is "*", which # will apply to all class names. This is a convenience wildcard to be able to skip similar named # functions from all classes. -skip = Model::[setInstancedAttrBlock getType getLocalBuffer getModelBounds getWorldBounds setOctreeNode setScene getOctreeNode getScene _octreeNode _scene], - SubModel::[getDescriptorSet getInputAssembler getSubMesh setSubMeshBuffers], - Light::[getColor getColorTemperatureRGB getNode getType getUseColorTemperature], - Node::[getFlagsChanged getDirtyNode getLayer getWorldMatrix getWorldPosition getWorldRotation getWorldScale setFlagsChanged setDirtyFlag setDirtyNode setLayer setWorldMatrix setWorldPosition setWorldRotation invalidateChildren setWorldScale setLocalPosition setLocalRotation setLocalScale getNodeLayout getWorldRT updateWorldTransform updateWorldRTMatrix getDirtyFlag getPosition getScale getRotation getParent], - BaseNode::[addChild removeChild getFlagsChanged getDirtyNode getLayer getWorldMatrix getWorldPosition getWorldRotation getWorldScale setFlagsChanged setDirtyFlag setDirtyNode setLayer setWorldMatrix setWorldPosition setWorldRotation invalidateChildren setWorldScale setLocalPosition setLocalRotation setLocalScale getNodeLayout getWorldRT updateWorldTransform updateWorldRTMatrix getDirtyFlag getPosition getScale getRotation getParent], - DirectionalLight::[getDirection getIlluminanceHDR getIlluminanceLDR], - SpotLight::[getAABB getAngle getAspect getSpotAngle getDirection getFrustum getLuminanceHDR getLuminanceLDR getNeedUpdate getRange getPosition getSize], - SphereLight::[getAABB getLuminanceHDR getLuminanceLDR getPosition getRange getSize], - Pass::[setRootBufferAndBlock], - AABB::[getBoundary aabbAabb aabbFrustum aabbPlan merge transform transformExtentM4 setCenter getCenter getValid setValid setHalfExtents getHalfExtents set fromPoints], - Sphere::[define merge interset spherePlane sphereFrustum], - SkinningModel::[updateTransform updateUBOs uploadJointData updateWorldMatrix], - Frustum::[update type], - JointTransform::[node world local stamp], - JointInfo::[bound bindpose transform parents buffers indices target], - RenderScene::[updateBatches getOctree updateOctree _octree], - BakedAnimInfo::[buffer data dirty], - BakedJointInfo::[boundsInfo jointTextureInfo animInfo buffer], - BakedSkinningModel::[updateTransform updateUBOs], - DrawBatch2D::[visFlags descriptorSet inputAssembler passes shaders] +skip = Pass::[getBlocks], + AABB::[getBoundary aabbAabb aabbFrustum aabbPlan merge transform transformExtentM4 setCenter getCenter isValid setValid setHalfExtents getHalfExtents set fromPoints], + Model::[getEventProcessor getOctreeNode setOctreeNode], + SkinningModel::[uploadJointData], + Frustum::[update type planes], + Plane::[clone copy normalize getSpotAngle fromNormalAndPoint fromPoints set], + RenderScene::[updateBatches], + BakedSkinningModel::[updateInstancedJointTextureInfo updateModelBounds], + AmbientInfo::[activate], + Node::[setLayerPtr setUIPropsTransformDirtyCallback rotate$ setUserData getUserData getChildren rotateForJS setScale$ setRotation$ setRotationFromEuler$ setPosition$ isActiveInHierarchy setActiveInHierarchy setActiveInHierarchyPtr setRTS$ findComponent findChildComponent findChildComponents addComponent removeComponent getComponent getComponents getComponentInChildren getComponentsInChildren checkMultipleComp getEventProcessor dispatchEvent hasEventListener getUIProps getPosition getRotation getScale getEulerAngles getForward getUp getRight getWorldPosition getWorldRotation getWorldScale getWorldMatrix getWorldRS getWorldRT], + Camera::[screenPointToRay screenToWorld worldToScreen worldMatrixToScreen syncCameraEditor], + NodeUiProperties::[getUITransformComp setUITransformComp getUIComp setUIComp] # not impl -rename_functions = +rename_functions = Root::[initialize=_initialize], + Node::[resetChangedFlags=resetHasChangedFlags _parent=_parentInternal updateSiblingIndex=_updateSiblingIndex], + FogInfo::[_isEnabled=_enabled], + ProgramLib::[registerEffect=register], + Model::[initLocalDescriptors=_initLocalDescriptors updateLocalDescriptors=_updateLocalDescriptors updateInstancedAttributes=_updateInstancedAttributes getInstancedAttributeIndex=_getInstancedAttributeIndex], + Scene::[load=_load activate=_activate], + Pass::[initPassFromTarget=_initPassFromTarget] -getter_setter= +getter_setter = Root::[device:_device mainWindow curWindow tempWindow windows scenes cumulativeTime frameTime frameCount fps fixedFPS useDeferredPipeline/isUsingDeferredPipeline], + RenderWindow::[width height framebuffer cameras swapchain], + Pass::[root device shaderInfo localSetLayout program properties defines passIndex propertyIndex dynamics rootBufferDirty/isRootBufferDirty _rootBufferDirty/isRootBufferDirty/_setRootBufferDirty priority primitive stage phase rasterizerState depthStencilState blendState dynamicStates batchingScheme descriptorSet hash/getHashForJS pipelineLayout], + PassInstance::[parent], + Node::[uuid angle matrix hasChangedFlags/getChangedFlags/setChangedFlags active/isActive _persistNode/isPersistNode/setPersistNode _dirtyFlags/getDirtyFlag/setDirtyFlag], + Ambient::[skyColor skyIllum groundAlbedo enabled/isEnabled], + Light::[baked/isBaked/setBaked color useColorTemperature/isUseColorTemperature/setUseColorTemperature colorTemperature colorTemperatureRGB node type name scene], + DirectionalLight::[direction illuminance illuminanceHDR illuminanceLDR], + SpotLight::[position size range luminance luminanceHDR luminanceLDR direction spotAngle angle aspect aabb/getAABB frustum], + SphereLight::[position size range luminance luminanceHDR luminanceLDR aabb/getAABB], + Camera::[iso isoValue ec exposure shutter shutterValue apertureValue width height aspect matView matProj matProjInv matViewProj matViewProjInv scene name window forward aperture position projectionType/getProjectionType/setProjectionType fovAxis fov nearClip farClip viewport orthoHeight clearColor clearDepth clearFlag clearStencil enabled/isEnabled/setEnabled exposure frustum isWindowSize/isWindowSize/setWindowSize priority screenScale visibility node], + RenderScene::[name cameras? mainLight? sphereLights? spotLights? models], + Skybox::[model enabled/isEnabled/setEnabled useIBL/isUseIBL/setUseIBL isRGBE/isRGBE/setRGBE envmap], + Fog::[enabled/isEnabled/setEnabled fogColor type fogDensity fogStart fogEnd fogAtten fogTop fogRange fogRange colorArray], + Shadows::[enabled/isEnabled normal distance shadowColor type near far orthoSize size pcf shadowMapDirty/isShadowMapDirty bias normalBias saturation fixedArea invisibleOcclusionRange matLight instancingMaterial], + Model::[scene _subModels:subModels/getSubModels inited/isInited _localDataUpdated/isLocalDataUpdated/setLocalDataUpdated _worldBounds:worldBounds/getWorldBounds/setWorldBounds _modelBounds:modelBounds/getModelBounds/setModelBounds worldBoundBuffer localBuffer updateStamp isInstancingEnabled/isInstancingEnabled receiveShadow/isReceiveShadow/setReceiveShadow castShadow/isCastShadow/setCastShadow node transform visFlags enabled/isEnabled/setEnabled type instancedAttributes/getInstancedAttributeBlock/setInstancedAttributeBlock isDynamicBatching/isDynamicBatching/setDynamicBatching], + SubModel::[passes shaders subMesh priority inputAssembler descriptorSet patches planarInstanceShader planarShader], + ShadowsInfo::[type enabled/isEnabled/setEnabled normal distance shadowDistance shadowColor invisibleOcclusionRange fixedArea/isFixedArea/isFixedArea pcf bias normalBias near far orthoSize maxReceived size saturation], + AmbientInfo::[skyColor skyIllum groundAlbedo], + FogInfo::[type fogColor enable/isEnabled/setEnabled fogDensity fogStart fogEnd fogAtten fogTop fogRange], + SkyboxInfo::[applyDiffuseMap/isApplyDiffuseMap/setApplyDiffuseMap enabled/isEnabled/setEnabled useIBL/isUseIBL/setUseIBL useHDR/isUseHDR/setUseHDR envmap diffuseMap], + OctreeInfo::[enabled/isEnabled/setEnabled minPos maxPos depth], + Scene::[autoReleaseAssets/isAutoReleaseAssets/setAutoReleaseAssets] -rename_classes = +field = Ambient::[SUN_ILLUM SKY_ILLUM], + Camera::[SKYBOX_FLAG], + Shadows::[MAX_FAR COEFFICIENT_OF_EXPANSION], + ShadowsInfo::[_type _firstSetCSM _fixedArea _shadowDistance _invisibleOcclusionRange _enabled _normal _distance _shadowColor _autoAdapt _pcf _bias _normalBias _near _far _orthoSize _maxReceived _size _saturation], + AmbientInfo::[_skyColor _skyIllum _groundAlbedo], + FogInfo::[_type _fogColor _isEnabled _fogDensity _fogStart _fogEnd _fogAtten _fogTop _fogRange], + SkyboxInfo::[_applyDiffuseMap _envmapHDR _envmapLDR _diffuseMapHDR _diffuseMapLDR _enabled _useIBL _useHDR], + OctreeInfo::[_enabled _minPos _maxPos _depth], + Node::[_siblingIndex _parent _active$ _id] + + +skip_public_fields = IMaterialInstanceInfo::[owner], + IDefineRecord::[map] + +rename_classes = InstancedAttributeBlock::IInstancedAttributeBlock # for all class names, should we remove something when registering in the target VM? remove_prefix = @@ -74,8 +137,8 @@ remove_prefix = # classes for which there will be no "parent" lookup classes_have_no_parents = # base classes which will be skipped when their sub-classes found them. -base_classes_to_skip = +base_classes_to_skip = RefCounted # classes that create no constructor # Set is special and we will use a hand-written constructor -abstract_classes = Light +abstract_classes = EventListener diff --git a/native/tools/tojs/spine.ini b/native/tools/tojs/spine.ini index 3a32ea9276..084a084ebd 100644 --- a/native/tools/tojs/spine.ini +++ b/native/tools/tojs/spine.ini @@ -78,7 +78,7 @@ remove_prefix = classes_have_no_parents = -base_classes_to_skip = Ref IMiddleware SpineObject HasRendererObject Updatable Constraint +base_classes_to_skip = RefCounted IMiddleware SpineObject HasRendererObject Updatable Constraint abstract_classes = Animation TrackEntry AnimationState AnimationStateData Attachment AttachmentTimeline BoundingBoxAttachment Bone BoneData ClippingAttachment Color ColorTimeline CurveTimeline DeformTimeline DrawOrderTimeline Event EventData EventTimeline IkConstraint IkConstraintData IkConstraintTimeline MeshAttachment Polygon PathAttachment PathConstraint PathConstraintData PathConstraintMixTimeline PathConstraintPositionTimeline PathConstraintSpacingTimeline PointAttachment RegionAttachment RotateTimeline ScaleTimeline ShearTimeline Skeleton Slot Skin SlotData SkeletonBounds SkeletonData Timeline TransformConstraint TransformConstraintData TransformConstraintTimeline TranslateTimeline TwoColorTimeline VertexAttachment VertexEffect JitterVertexEffect SwirlVertexEffect ConstraintData diff --git a/native/tools/tojs/video.ini b/native/tools/tojs/video.ini index 18d4bd75bd..a016610672 100644 --- a/native/tools/tojs/video.ini +++ b/native/tools/tojs/video.ini @@ -53,7 +53,7 @@ remove_prefix = classes_have_no_parents = # base classes which will be skipped when their sub-classes found them. -base_classes_to_skip = Ref +base_classes_to_skip = RefCounted # classes that create no constructor # Set is special and we will use a hand-written constructor diff --git a/native/tools/tojs/webview.ini b/native/tools/tojs/webview.ini index cc941fcca2..d8a904655f 100644 --- a/native/tools/tojs/webview.ini +++ b/native/tools/tojs/webview.ini @@ -52,7 +52,7 @@ remove_prefix = classes_have_no_parents = # base classes which will be skipped when their sub-classes found them. -base_classes_to_skip = Ref +base_classes_to_skip = RefCounted # classes that create no constructor # Set is special and we will use a hand-written constructor diff --git a/native/utils/compile_file.js b/native/utils/compile_file.js new file mode 100644 index 0000000000..651a978c48 --- /dev/null +++ b/native/utils/compile_file.js @@ -0,0 +1,33 @@ + + +const fs = require('fs'); +const path = require('path'); +const child_process = require('child_process'); +const fp = path.join(__dirname, '..', 'compile_commands.json'); + +if(!fs.existsSync(fp)) { + console.error(`File ${fp} is not exists!`); + process.exit(-1); +} + +const db = JSON.parse(fs.readFileSync(fp).toString('utf8')); + +let fileName = process.argv[2]; +if(!fileName) { + console.error(`argument: file not provided!`); + process.exit(-1); +} + +fileName = path.normalize(fileName); + +for(let item of db) { + let up = path.normalize(item.file); + if(up.indexOf(fileName) > -1) { + console.log(`compiling file ${up}`); + let result = child_process.execSync(item.command, {cwd: item.directory, shell: true}); + console.log(result.toString('utf-8')); + process.exit(-1); + } +} + +console.error(' file not found '+ fileName); \ No newline at end of file diff --git a/native/utils/generate_compile_commands_ios.sh b/native/utils/generate_compile_commands_ios.sh index 95257492b9..d957aea57d 100755 --- a/native/utils/generate_compile_commands_ios.sh +++ b/native/utils/generate_compile_commands_ios.sh @@ -8,4 +8,6 @@ cmake -Sbuild -Bbuild -DCC_USE_GLES2=OFF -DCC_USE_VULKAN=OFF -DCC_USE_GLES3=OFF -DCMAKE_OSX_SYSROOT=iphoneos \ -DCMAKE_SYSTEM_NAME=iOS \ -GXcode -cp build/compile_commands.json . +if [[ -f build/compile_commands.json ]]; then + cp build/compile_commands.json . +fi