Skip to content

Commit

Permalink
Merge pull request #15703 from knoxHuang/develop
Browse files Browse the repository at this point in the history
Merge remote-tracking branch 'cocos-for-editor/v3.8.1' into develop
  • Loading branch information
minggo authored Jul 13, 2023
2 parents 10c28eb + 7c51d78 commit 67e502d
Show file tree
Hide file tree
Showing 207 changed files with 5,356 additions and 1,836 deletions.
8 changes: 6 additions & 2 deletions .github/workflows/native-compile-platforms.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ on:
paths:
- 'templates/**'
- 'native/**'
- '.github/workflows/native-compile-platforms.yml'

# github.head_ref is only defined on pull_request events
concurrency:
Expand All @@ -25,8 +26,11 @@ jobs:
EXT_VERSION=`node ./.github/workflows/get-native-external-version.js`
git clone --branch $EXT_VERSION --depth 1 https://github.com/cocos/cocos-engine-external native/external
- name: Install deps
run: |
choco install --forcex86 vulkan-sdk
uses: humbletim/[email protected]
with:
vulkan-query-version: 1.2.189.0
vulkan-components: Vulkan-Headers, Vulkan-Loader
vulkan-use-cache: true
- name: Compile win64
shell: bash
env:
Expand Down
10 changes: 7 additions & 3 deletions .github/workflows/native-simulator.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ on:
pull_request:
paths:
- 'native/**'
- '.github\workflows\native-simulator.yml'

# github.head_ref is only defined on pull_request events
concurrency:
Expand Down Expand Up @@ -32,9 +33,12 @@ jobs:
EXT_VERSION=`node ../.github/workflows/get-native-external-version.js`
git clone --branch $EXT_VERSION --depth 1 https://github.com/cocos/cocos-engine-external external
- name: install vulkan-sdk
run: |
choco install vulkan-sdk
- name: Install deps
uses: humbletim/[email protected]
with:
vulkan-query-version: 1.2.189.0
vulkan-components: Vulkan-Headers, Vulkan-Loader
vulkan-use-cache: true
- name: gen simulator
run: |
gulp gen-simulator
Expand Down
19 changes: 19 additions & 0 deletions @types/pal/minigame.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ declare module 'pal/minigame' {

// file system
getFileSystemManager(): FileSystemManager;
loadSubpackage? (option: LoadSubpackageOption): LoadSubpackageTask;

// input
onTouchStart: IEventManager<TouchEvent>;
Expand Down Expand Up @@ -249,3 +250,21 @@ declare class InnerAudioContext {
seek(position:number): any;
stop(): any;
}

interface LoadSubpackageOption {
name: string;
fail?: (...args: unknown[]) => void;
success?: (...args: unknown[]) => void;
complete?: (...args: unknown[]) => void;
}
interface LoadSubpackageTask {
onProgressUpdate(
listener: LoadSubpackageTaskOnProgressUpdateCallback
): void;
}
type LoadSubpackageTaskOnProgressUpdateCallback = (result: LoadSubpackageTaskOnProgressUpdateListenerResult) => void;
interface LoadSubpackageTaskOnProgressUpdateListenerResult {
progress: number;
totalBytesExpectedToWrite: number;
totalBytesWritten: number;
}
7 changes: 7 additions & 0 deletions @types/pal/wasm.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,11 @@ declare module 'pal/wasm' {
* @param binaryUrl the url of wasm or js mem, this should be a url relative from build output chunk.
*/
export function fetchBuffer (binaryUrl: string): Promise<ArrayBuffer>;

/**
* Sometimes we need to put wasm modules in subpackage to reduce code size.
* In this case we need to ensure that the wasm modules is ready before we import them.
* Please remember to invoke this method before we import wasm modules.
*/
export function ensureWasmModuleReady (): Promise<void>;
}
28 changes: 15 additions & 13 deletions cc.config.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,7 @@
"970b0598-bcb0-4714-91fb-2e81440dccd8",
"bcd64cc6-2dd9-43f6-abbe-66318d332032",
"d930590d-bb92-4cc8-8bd1-23cd027f9edf",
"a3cd009f-0ab0-420d-9278-b9fdab939bbc",
"5c601d96-e4c7-4698-991b-7ee674b11079",
"9361fd90-ba52-4f84-aa93-6e878fd576ca"
"a3cd009f-0ab0-420d-9278-b9fdab939bbc"
]
},
"gfx-webgl": {
Expand All @@ -25,17 +23,9 @@
"3d": {
"modules": ["3d"],
"dependentAssets": [
"1baf0fc9-befa-459c-8bdd-af1a450a0319",
"511d2633-09a7-4bdd-ac42-f778032124b3",
"5d45aa00-e064-4938-b314-4265f0c2258c",
"28d6d6b8-3f66-4a73-9795-17a0852ba2d4",
"ec8106fe-05bf-4e94-943c-e0d3b7bb5e45",
"620b6bf3-0369-4560-837f-2a2c00b73c26",
"2df0a40b-26c2-47ce-be0d-4d3cd4164737",
"39f74202-ead5-4a45-b966-273d526adbf1",
"8f6ac413-2f1e-4b88-b26f-54556b5dd510",
"45e7c0c8-2699-4912-b45f-d42bb8384189",
"84ac6f69-3086-455a-86a4-561da8ee710b"
"9361fd90-ba52-4f84-aa93-6e878fd576ca"
]
},
"animation": {
Expand Down Expand Up @@ -199,7 +189,13 @@
"cafd95c9-c558-46f9-9812-1224b65c09ee",
"28d6d6b8-3f66-4a73-9795-17a0852ba2d4",
"2df0a40b-26c2-47ce-be0d-4d3cd4164737",
"dace6a58-1705-48c7-a275-70afc9534e88"
"dace6a58-1705-48c7-a275-70afc9534e88",
"ec8106fe-05bf-4e94-943c-e0d3b7bb5e45",
"39f74202-ead5-4a45-b966-273d526adbf1",
"8f6ac413-2f1e-4b88-b26f-54556b5dd510",
"45e7c0c8-2699-4912-b45f-d42bb8384189",
"84ac6f69-3086-455a-86a4-561da8ee710b",
"5c601d96-e4c7-4698-991b-7ee674b11079"
]
},
"websocket": {
Expand Down Expand Up @@ -666,6 +662,12 @@
"type": "boolean",
"value": false,
"internal": true
},
"WASM_SUBPACKAGE": {
"comment": "An internal constant to indicate whether we use wasm assets as minigame subpackage.\nThis is useful when we need to reduce code size.",
"type": "boolean",
"value": false,
"internal": true
}
},

Expand Down
44 changes: 25 additions & 19 deletions cocos/2d/assembler/label/text-processing.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ const Alignment = [
const MAX_SIZE = 2048;
const _BASELINE_OFFSET = getBaselineOffset();
const _invisibleAlpha = (1 / 255).toFixed(3);
const MAX_CALCULATION_NUM = 3;

export interface IRenderData {
x: number;
Expand Down Expand Up @@ -79,9 +80,26 @@ export class TextProcessing {
public processingString (isBmFont: boolean, style: TextStyle, layout: TextLayout,
outputLayoutData: TextOutputLayoutData, inputString: string, out?: string[]): void {
if (!isBmFont) {
let loopTime = 0;
this._fontScale = this._getStyleFontScale(style.fontSize, style.fontScale);
this._updatePaddingRect(style, outputLayoutData);
this._calculateLabelFont(style, layout, outputLayoutData, inputString);
// check & limit canvas size
while ((outputLayoutData.canvasSize.width > MAX_SIZE || outputLayoutData.canvasSize.height > MAX_SIZE)
&& (loopTime <= MAX_CALCULATION_NUM)) {
loopTime++;
if (loopTime > MAX_CALCULATION_NUM) {
this._fontScale = 1;
} else {
const maxValue = Math.max(outputLayoutData.canvasSize.width, outputLayoutData.canvasSize.height); // Current Canvas Size max dimension

Check warning on line 94 in cocos/2d/assembler/label/text-processing.ts

View workflow job for this annotation

GitHub Actions / Run ESLint

This line has a length of 154. Maximum allowed is 150
const canvasScaleToMaxSizeRatio = MAX_SIZE / maxValue;
this._fontScale *= canvasScaleToMaxSizeRatio;
this._fontScale = Math.max(1, this._fontScale);
}

this._updatePaddingRect(style, outputLayoutData);
this._calculateLabelFont(style, layout, outputLayoutData, inputString);
}
} else {
if (!style.fntConfig) { // for char
this._fontScale = this._getStyleFontScale(style.originFontSize, style.fontScale);
Expand Down Expand Up @@ -167,8 +185,8 @@ export class TextProcessing {
}
canvasSizeY = (_splitStrings.length + BASELINE_RATIO)
* this._getLineHeight(layout.lineHeight, style.actualFontSize, style.fontSize);
const rawWidth = parseFloat(canvasSizeX.toFixed(2));
const rawHeight = parseFloat(canvasSizeY.toFixed(2));
const rawWidth = canvasSizeX;
const rawHeight = canvasSizeY;

outputLayoutData.canvasSize.width = rawWidth + outputLayoutData.canvasPadding.width * this._fontScale;
outputLayoutData.canvasSize.height = rawHeight + outputLayoutData.canvasPadding.height * this._fontScale;
Expand All @@ -179,22 +197,22 @@ export class TextProcessing {
case Overflow.SHRINK: {
this._calculateShrinkFont(paragraphedStrings, style, layout, outputLayoutData);
this._calculateWrapText(paragraphedStrings, style, layout, outputLayoutData);
outputLayoutData.canvasSize.width *= this._fontScale;
outputLayoutData.canvasSize.height *= this._fontScale;
outputLayoutData.canvasSize.width = outputLayoutData.nodeContentSize.width * this._fontScale;
outputLayoutData.canvasSize.height = outputLayoutData.nodeContentSize.height * this._fontScale;
break;
}
case Overflow.CLAMP: {
this._calculateWrapText(paragraphedStrings, style, layout, outputLayoutData);
outputLayoutData.canvasSize.width *= this._fontScale;
outputLayoutData.canvasSize.height *= this._fontScale;
outputLayoutData.canvasSize.width = outputLayoutData.nodeContentSize.width * this._fontScale;
outputLayoutData.canvasSize.height = outputLayoutData.nodeContentSize.height * this._fontScale;
break;
}
case Overflow.RESIZE_HEIGHT: {
this._calculateWrapText(paragraphedStrings, style, layout, outputLayoutData);
const rawHeight = (outputLayoutData.parsedString.length + BASELINE_RATIO)
* this._getLineHeight(layout.lineHeight, style.actualFontSize, style.fontSize);

outputLayoutData.canvasSize.width *= this._fontScale;
outputLayoutData.canvasSize.width = outputLayoutData.nodeContentSize.width * this._fontScale;
outputLayoutData.canvasSize.height = (rawHeight + outputLayoutData.canvasPadding.height * this._fontScale);
// set node height
outputLayoutData.nodeContentSize.height = (rawHeight + outputLayoutData.contentSizeExtend.height * this._fontScale) / this._fontScale;
Expand All @@ -204,18 +222,6 @@ export class TextProcessing {
// nop
}
}

// check & limit canvas size
if ((outputLayoutData.nodeContentSize.width < MAX_SIZE && outputLayoutData.nodeContentSize.height < MAX_SIZE)
&& (outputLayoutData.canvasSize.width > MAX_SIZE || outputLayoutData.canvasSize.height > MAX_SIZE)) {
const maxValue = Math.max(outputLayoutData.canvasSize.width, outputLayoutData.canvasSize.height);
let scale = MAX_SIZE / maxValue;
if (scale < 1) { scale = 1; }
this._fontScale = scale;

this._updatePaddingRect(style, outputLayoutData);
this._calculateLabelFont(style, layout, outputLayoutData, inputString); // only one time
}
}

// can cache
Expand Down
3 changes: 2 additions & 1 deletion cocos/2d/framework/render-root-2d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
*/

import { ccclass, disallowMultiple, executeInEditMode,
executionOrder, menu, requireComponent } from 'cc.decorator';
executionOrder, help, menu, requireComponent } from 'cc.decorator';
import { Component } from '../../scene-graph/component';
import { cclegacy } from '../../core';
import { UITransform } from './ui-transform';
Expand All @@ -33,6 +33,7 @@ import { UITransform } from './ui-transform';
* @zh 2D 对象数据收集的入口节点,所有的 2D渲染对象需在 RenderRoot 节点下才可以被渲染。
*/
@ccclass('cc.RenderRoot2D')
@help('i18n:cc.RenderRoot2D')
@executionOrder(100)
@menu('2D/RenderRoot2D')
@requireComponent(UITransform)
Expand Down
25 changes: 1 addition & 24 deletions cocos/2d/renderer/render-data.ts
Original file line number Diff line number Diff line change
Expand Up @@ -256,7 +256,7 @@ export class RenderData extends BaseRenderData {
this.syncRender2dBuffer();
}

get data ():IRenderData[] {
get data (): IRenderData[] {
return this._data;
}

Expand Down Expand Up @@ -304,10 +304,6 @@ export class RenderData extends BaseRenderData {
public hashDirty = true;

private _data: IRenderData[] = [];
private _pivotX = 0;
private _pivotY = 0;
private _width = 0;
private _height = 0;
private _frame: SpriteFrame | TextureBase | null = null;
protected _accessor: StaticVBAccessor = null!;
get accessor (): StaticVBAccessor { return this._accessor; }
Expand Down Expand Up @@ -495,26 +491,9 @@ export class RenderData extends BaseRenderData {
}
}

public updateSizeNPivot (width: number, height: number, pivotX: number, pivotY: number): void {
if (width !== this._width
|| height !== this._height
|| pivotX !== this._pivotX
|| pivotY !== this._pivotY) {
this._width = width;
this._height = height;
this._pivotX = pivotX;
this._pivotY = pivotY;
this.vertDirty = true;
}
}

public clear (): void {
this.resize(0, 0);
this._data.length = 0;
this._pivotX = 0;
this._pivotY = 0;
this._width = 0;
this._height = 0;
this.indices = null;
this.vertDirty = true;
this.material = null;
Expand Down Expand Up @@ -810,5 +789,3 @@ export class MeshRenderData extends BaseRenderData {
}
}
}

const _meshDataPool: RecyclePool<MeshRenderData> = new RecyclePool(() => new MeshRenderData(), 32);
8 changes: 4 additions & 4 deletions cocos/3d/framework/mesh-renderer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ class ModelBakeSettings extends EventTarget {
* @zh 模型是否是静态的并可以烘培光照贴图。
* 注意:模型顶点数据必须包含第二套 UV 属性来支持光照贴图烘焙。
*/
@group({ id: 'LightMap', name: 'LightMapSettings', displayOrder: 0 })
@group({ id: 'LightMap', name: 'LightMapSettings', displayOrder: 0, style: 'section' })
@editable
get bakeable (): boolean {
return this._bakeable;
Expand Down Expand Up @@ -210,7 +210,7 @@ class ModelBakeSettings extends EventTarget {
* @en Whether to use light probe which provides indirect light to dynamic objects.
* @zh 模型是否使用光照探针,光照探针为动态物体提供间接光。
*/
@group({ id: 'LightProbe', name: 'LightProbeSettings', displayOrder: 1 })
@group({ id: 'LightProbe', name: 'LightProbeSettings', displayOrder: 1, style: 'section' })
@editable
@type(CCBoolean)
get useLightProbe (): boolean {
Expand Down Expand Up @@ -241,7 +241,7 @@ class ModelBakeSettings extends EventTarget {
* @en Used to set whether to use the reflection probe or set probe's type.
* @zh 用于设置是否使用反射探针或者设置反射探针的类型。
*/
@group({ id: 'ReflectionProbe', name: 'ReflectionProbeSettings', displayOrder: 2 })
@group({ id: 'ReflectionProbe', name: 'ReflectionProbeSettings', displayOrder: 2, style: 'section' })
@type(Enum(ReflectionProbeType))
get reflectionProbe (): ReflectionProbeType {
return this._reflectionProbeType;
Expand Down Expand Up @@ -339,7 +339,7 @@ export class MeshRenderer extends ModelRenderer {
*/
@type(CCFloat)
@tooltip('i18n:model.shadow_bias')
@group({ id: 'DynamicShadow', name: 'DynamicShadowSettings', displayOrder: 2 })
@group({ id: 'DynamicShadow', name: 'DynamicShadowSettings', displayOrder: 2, style: 'section' })
@disallowAnimation
get shadowBias (): number {
return this._shadowBias;
Expand Down
7 changes: 3 additions & 4 deletions cocos/3d/lights/directional-light-component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,9 @@ import { cclegacy, clamp, warnID, CCBoolean, CCFloat, _decorator, settings, Sett
import { Camera, PCFType, Shadows, ShadowType, CSMOptimizationMode, CSMLevel } from '../../render-scene/scene';
import { Root } from '../../root';
import { MeshRenderer } from '../framework/mesh-renderer';
import { director } from '../../game/director';
import { rangeMin } from '../../core/data/decorators';

const { ccclass, menu, executeInEditMode, property, serializable, formerlySerializedAs, tooltip, help, visible, type, editable, slide, range } = _decorator;
const { ccclass, menu, executeInEditMode, property, serializable, formerlySerializedAs, tooltip, help,
visible, type, editable, slide, range } = _decorator;

/**
* @en The directional light component, only one real time directional light is permitted in one scene, it act as the main light of the scene.
Expand Down Expand Up @@ -97,7 +96,7 @@ export class DirectionalLight extends Light {
*/
@tooltip('i18n:lights.illuminance')
@editable
@rangeMin(0)
@range([0, Number.POSITIVE_INFINITY, 10])
@type(CCInteger)
get illuminance (): number {
const isHDR = (cclegacy.director.root as Root).pipeline.pipelineSceneData.isHDR;
Expand Down
2 changes: 1 addition & 1 deletion cocos/3d/lights/light-component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ export class Light extends Component {
* 光源色温。
*/
@slide
@range([1000, 15000, 1])
@range([1000, 15000, 100])
@tooltip('i18n:lights.color_temperature')
get colorTemperature (): number {
return this._colorTemperature;
Expand Down
Loading

0 comments on commit 67e502d

Please sign in to comment.