Skip to content

Commit

Permalink
Merge branch 'v3.8.5' of https://github.com/cocos/cocos-engine into 3…
Browse files Browse the repository at this point in the history
…85-spine-aot
  • Loading branch information
dumganhar committed Nov 5, 2024
2 parents bd05c2b + 3102bda commit 9247851
Show file tree
Hide file tree
Showing 61 changed files with 1,364 additions and 923 deletions.
5 changes: 3 additions & 2 deletions cocos/2d/assembler/label/text-processing.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ import {
isUnicodeSpace,
safeMeasureText,
} from '../../utils/text-utils';
import type { Batcher2D } from '../../renderer/batcher-2d';

const Alignment = [
'left', // macro.TextAlignment.LEFT
Expand Down Expand Up @@ -568,9 +569,9 @@ export class TextProcessing {
// since `tex.reset(...)` will reset `gfxTexture` and `gfxSampler`.
// The other non-JSB branch uses `tex.getHash()` which returns the hash value that will not be
// changed after `tex.reset(...)`, so there will be no problems for non-JSB branch.
cclegacy.director.root.batcher2D._releaseDescriptorSetCache(oldGfxTexture, oldGfxSampler);
(cclegacy.director.root.batcher2D as Batcher2D)._releaseDescriptorSetCache(oldGfxTexture, oldGfxSampler);
} else {
cclegacy.director.root.batcher2D._releaseDescriptorSetCache(tex.getHash());
(cclegacy.director.root.batcher2D as Batcher2D)._releaseDescriptorSetCache(tex.getHash());
}
}
}
Expand Down
21 changes: 7 additions & 14 deletions cocos/2d/components/rich-text.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
THE SOFTWARE.
*/

import { ccclass, executeInEditMode, executionOrder, help, menu, tooltip, multiline, type, displayOrder, serializable } from 'cc.decorator';
import { ccclass, executeInEditMode, executionOrder, help, menu, multiline, type, displayOrder, serializable, editable } from 'cc.decorator';
import { DEBUG, DEV, EDITOR } from 'internal:constants';
import { Font, SpriteAtlas, TTFFont, SpriteFrame } from '../assets';
import { EventTouch } from '../../input/types';
Expand Down Expand Up @@ -162,7 +162,6 @@ export class RichText extends Component {
* 富文本显示的文本内容。
*/
@multiline
@tooltip('i18n:richtext.string')
get string (): string {
return this._string;
}
Expand All @@ -183,7 +182,6 @@ export class RichText extends Component {
* 文本内容的水平对齐方式。
*/
@type(HorizontalTextAlignment)
@tooltip('i18n:richtext.horizontal_align')
get horizontalAlign (): HorizontalTextAlignment {
return this._horizontalAlign;
}
Expand All @@ -206,7 +204,6 @@ export class RichText extends Component {
* 文本内容的竖直对齐方式。
*/
@type(VerticalTextAlignment)
@tooltip('i18n:richtext.vertical_align')
get verticalAlign (): VerticalTextAlignment {
return this._verticalAlign;
}
Expand All @@ -228,7 +225,7 @@ export class RichText extends Component {
* @zh
* 富文本字体大小。
*/
@tooltip('i18n:richtext.font_size')
@editable
get fontSize (): number {
return this._fontSize;
}
Expand Down Expand Up @@ -270,7 +267,7 @@ export class RichText extends Component {
* @zh
* 富文本定制系统字体。
*/
@tooltip('i18n:richtext.font_family')
@editable
get fontFamily (): string {
return this._fontFamily;
}
Expand All @@ -289,7 +286,6 @@ export class RichText extends Component {
* 富文本定制字体。
*/
@type(Font)
@tooltip('i18n:richtext.font')
get font (): TTFFont | null {
return this._font;
}
Expand All @@ -313,12 +309,11 @@ export class RichText extends Component {

/**
* @en
* Whether use system font name or not.
* Whether to use system font name or not.
*
* @zh
* 是否使用系统字体。
*/
@tooltip('i18n:richtext.use_system_font')
@displayOrder(12)
get useSystemFont (): boolean {
return this._isSystemFontUsed;
Expand Down Expand Up @@ -350,7 +345,6 @@ export class RichText extends Component {
* 文本缓存模式, 该模式只支持系统字体。
*/
@type(CacheMode)
@tooltip('i18n:richtext.cache_mode')
get cacheMode (): CacheMode {
return this._cacheMode;
}
Expand All @@ -369,7 +363,7 @@ export class RichText extends Component {
* @zh
* 富文本的最大宽度。
*/
@tooltip('i18n:richtext.max_width')
@editable
get maxWidth (): number {
return this._maxWidth;
}
Expand All @@ -391,7 +385,7 @@ export class RichText extends Component {
* @zh
* 富文本行高。
*/
@tooltip('i18n:richtext.line_height')
@editable
get lineHeight (): number {
return this._lineHeight;
}
Expand All @@ -414,7 +408,6 @@ export class RichText extends Component {
* 对于 img 标签里面的 src 属性名称,都需要在 imageAtlas 里面找到一个有效的 spriteFrame,否则 img tag 会判定为无效。
*/
@type(SpriteAtlas)
@tooltip('i18n:richtext.image_atlas')
get imageAtlas (): SpriteAtlas | null {
return this._imageAtlas;
}
Expand All @@ -437,7 +430,7 @@ export class RichText extends Component {
* @zh
* 选中此选项后,RichText 将阻止节点边界框中的所有输入事件(鼠标和触摸),从而防止输入事件穿透到底层节点。
*/
@tooltip('i18n:richtext.handleTouchEvent')
@editable
get handleTouchEvent (): boolean {
return this._handleTouchEvent;
}
Expand Down
3 changes: 2 additions & 1 deletion cocos/2d/components/sprite.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ import { PixelFormat } from '../../asset/assets/asset-enum';
import { TextureBase } from '../../asset/assets/texture-base';
import { Material, RenderTexture } from '../../asset/assets';
import { NodeEventType } from '../../scene-graph/node-event';
import assetManager from '../../asset/asset-manager/asset-manager';

/**
* @en
Expand Down Expand Up @@ -727,7 +728,7 @@ export class Sprite extends UIRenderer {
}

if (!this.spriteAtlas || this.spriteAtlas.uuid !== spriteFrame.atlasUuid) {
cclegacy.assetManager.loadAny(spriteFrame.atlasUuid, (err: Error, asset: SpriteAtlas) => {
assetManager.loadAny(spriteFrame.atlasUuid, (err: Error, asset: SpriteAtlas) => {
if (err) {
this.spriteAtlas = null;
error(err);
Expand Down
7 changes: 4 additions & 3 deletions cocos/2d/framework/render-root-2d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ import { ccclass, disallowMultiple, executeInEditMode,
import { Component } from '../../scene-graph/component';
import { cclegacy } from '../../core';
import { UITransform } from './ui-transform';
import type { Batcher2D } from '../renderer/batcher-2d';

/**
* @en The entry node for 2D object data collection, all 2D rendering objects need to be rendered under the RenderRoot node.
Expand All @@ -41,14 +42,14 @@ import { UITransform } from './ui-transform';
@executeInEditMode
export class RenderRoot2D extends Component {
public onEnable (): void {
cclegacy.director.root!.batcher2D.addScreen(this);
(cclegacy.director.root!.batcher2D as Batcher2D).addScreen(this);
}

public onDisable (): void {
cclegacy.director.root!.batcher2D.removeScreen(this);
(cclegacy.director.root!.batcher2D as Batcher2D).removeScreen(this);
}

public onDestroy (): void {
cclegacy.director.root!.batcher2D.removeScreen(this);
(cclegacy.director.root!.batcher2D as Batcher2D).removeScreen(this);
}
}
4 changes: 2 additions & 2 deletions cocos/2d/framework/sprite-renderer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ import { Material } from '../../asset/assets';
import { Color, Vec2, cclegacy } from '../../core';
import { ModelLocalBindings } from '../../rendering/define';
import { Model } from '../../render-scene/scene';
import { Root } from '../../root';
import type { Root } from '../../root';
import { TransformBit } from '../../scene-graph/node-enum';
import { SpriteFrame } from '../assets/sprite-frame';
import { ModelRenderer } from '../../misc';
Expand Down Expand Up @@ -138,7 +138,7 @@ export class SpriteRenderer extends ModelRenderer {

public onDestroy (): void {
if (this._model) {
cclegacy.director.root.destroyModel(this._model);
(cclegacy.director.root as Root).destroyModel(this._model);
this._model = null;
this._models.length = 0;
}
Expand Down
1 change: 0 additions & 1 deletion cocos/2d/framework/ui-renderer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,6 @@ export class UIRenderer extends Renderer {
*/
@type(Material)
@displayOrder(0)
@displayName('CustomMaterial')
@disallowAnimation
get customMaterial (): Material | null {
return this._customMaterial;
Expand Down
16 changes: 10 additions & 6 deletions cocos/2d/renderer/batcher-2d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ import { scene } from '../../render-scene';
import { builtinResMgr } from '../../asset/asset-manager';
import { RenderingSubMesh } from '../../asset/assets';
import { IAssembler } from './base';
import type { Director } from '../../game/director';

const _dsInfo = new DescriptorSetInfo(null!);
const m4_1 = new Mat4();
Expand Down Expand Up @@ -160,7 +161,7 @@ export class Batcher2D implements IBatcher {
StencilManager.sharedManager!.destroy();

if (this._maskClearModel && this._maskModelMesh) {
cclegacy.director.root.destroyModel(this._maskClearModel);
(cclegacy.director.root as Root).destroyModel(this._maskClearModel);
this._maskModelMesh.destroy();
}
if (this._maskClearMtl) {
Expand Down Expand Up @@ -571,7 +572,7 @@ export class Batcher2D implements IBatcher {
dssHash = StencilManager.sharedManager!.getStencilHash(comp.stencilStage);
}

const stamp: number = cclegacy.director.getTotalFrames();
const stamp: number = (cclegacy.director as Director).getTotalFrames();
if (model) {
model.updateTransform(stamp);
model.updateUBOs(stamp);
Expand Down Expand Up @@ -866,7 +867,10 @@ export class Batcher2D implements IBatcher {
// TODO: Not a good way to do the job
// Although it's a private method, it is invoked in text-processing.ts and texture-base.ts
// by legacyCC.director.root.batcher2D._releaseDescriptorSetCache
private _releaseDescriptorSetCache (textureHash: number | Texture, sampler: Sampler | null = null): void {
/**
* @engineInternal
*/
public _releaseDescriptorSetCache (textureHash: number | Texture | null, sampler: Sampler | null = null): void {
if (JSB) {
this._nativeObj.releaseDescriptorSetCache(textureHash as Texture, sampler as Sampler);
} else {
Expand All @@ -879,7 +883,7 @@ export class Batcher2D implements IBatcher {
if (!this._maskClearModel) {
this._maskClearMtl = builtinResMgr.get<Material>('default-clear-stencil');

this._maskClearModel = cclegacy.director.root.createModel(scene.Model);
this._maskClearModel = (cclegacy.director.root as Root).createModel(scene.Model);
const stride = getAttributeStride(vfmt);
const gfxDevice: Device = deviceManager.gfxDevice;
const vertexBuffer = gfxDevice.createBuffer(new BufferInfo(
Expand All @@ -903,7 +907,7 @@ export class Batcher2D implements IBatcher {
this._maskModelMesh = new RenderingSubMesh([vertexBuffer], vfmt, PrimitiveMode.TRIANGLE_LIST, indexBuffer);
this._maskModelMesh.subMeshIdx = 0;

this._maskClearModel!.initSubModel(0, this._maskModelMesh, this._maskClearMtl);
this._maskClearModel.initSubModel(0, this._maskModelMesh, this._maskClearMtl);
}
}

Expand All @@ -925,7 +929,7 @@ export class Batcher2D implements IBatcher {
}

const model = this._maskClearModel!;
const stamp: number = cclegacy.director.getTotalFrames();
const stamp: number = (cclegacy.director as Director).getTotalFrames();
if (model) {
model.updateTransform(stamp);
model.updateUBOs(stamp);
Expand Down
15 changes: 9 additions & 6 deletions cocos/3d/framework/mesh-renderer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ import { getPhaseID } from '../../rendering/pass-phase';
import { SubModel } from '../../render-scene/scene';
import { isEnableEffect } from '../../rendering/define';
import type { Model } from '../../render-scene/scene';
import type { ReflectionProbeManager } from '../reflection-probe';

const { ccclass, help, executeInEditMode, executionOrder, menu, visible, type,
formerlySerializedAs, serializable, editable, disallowAnimation } = _decorator;
Expand Down Expand Up @@ -646,7 +647,7 @@ export class MeshRenderer extends ModelRenderer {

public onDestroy (): void {
if (this._model) {
cclegacy.director.root.destroyModel(this._model);
(cclegacy.director.root as Root).destroyModel(this._model);
this._model = null;
this._models.length = 0;
}
Expand Down Expand Up @@ -979,7 +980,7 @@ export class MeshRenderer extends ModelRenderer {
model.visFlags = this.visibility;
model.node = model.transform = this.node;
this._models.length = 0;
this._models.push(this._model);
this._models.push(model);
if (this._morphInstance && model instanceof MorphModel) {
model.setMorphRendering(this._morphInstance);
}
Expand Down Expand Up @@ -1167,16 +1168,18 @@ export class MeshRenderer extends ModelRenderer {
protected onReflectionProbeChanged (): void {
this._updateUseReflectionProbe();
this._onUpdateLocalShadowBiasAndProbeId();
const reflectionProbeManager = cclegacy.internal.reflectionProbeManager as ReflectionProbeManager;
const model = this._model!;
if (this.bakeSettings.reflectionProbe === ReflectionProbeType.BAKED_CUBEMAP
|| this.bakeSettings.reflectionProbe === ReflectionProbeType.BLEND_PROBES
|| this.bakeSettings.reflectionProbe === ReflectionProbeType.BLEND_PROBES_AND_SKYBOX) {
cclegacy.internal.reflectionProbeManager.selectReflectionProbe(this._model);
if (!cclegacy.internal.reflectionProbeManager.getUsedReflectionProbe(this._model, false)) {
reflectionProbeManager.selectReflectionProbe(model);
if (!reflectionProbeManager.getUsedReflectionProbe(model, false)) {
warnID(16302);
}
} else if (this.bakeSettings.reflectionProbe === ReflectionProbeType.PLANAR_REFLECTION) {
cclegacy.internal.reflectionProbeManager.selectPlanarReflectionProbe(this._model);
if (!cclegacy.internal.reflectionProbeManager.getUsedReflectionProbe(this._model, true)) {
reflectionProbeManager.selectPlanarReflectionProbe(model);
if (!reflectionProbeManager.getUsedReflectionProbe(model, true)) {
warnID(16302);
}
}
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 @@ -272,7 +272,7 @@ export class Light extends Component {

protected _destroyLight (): void {
if (this._light) {
cclegacy.director.root.recycleLight(this._light);
(cclegacy.director.root as Root).recycleLight(this._light);
this._light = null;
}
}
Expand Down
3 changes: 2 additions & 1 deletion cocos/3d/reflection-probe/reflection-probe-manager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ import { Texture } from '../../gfx';
import { Camera, Model } from '../../render-scene/scene';
import { ProbeType, ReflectionProbe } from '../../render-scene/scene/reflection-probe';
import { Layers } from '../../scene-graph/layers';
import type { Director } from '../../game/director';

const REFLECTION_PROBE_DEFAULT_MASK = Layers.makeMaskExclude([Layers.BitMask.UI_2D, Layers.BitMask.UI_3D, Layers.BitMask.GIZMOS, Layers.BitMask.EDITOR,
Layers.BitMask.SCENE_GIZMO, Layers.BitMask.PROFILER, Layers.Enum.IGNORE_RAYCAST]);
Expand Down Expand Up @@ -74,7 +75,7 @@ export class ReflectionProbeManager {
*/
public registerEvent (): void {
if (!this._registeredEvent) {
cclegacy.director.on(cclegacy.Director.EVENT_BEFORE_UPDATE, this.onUpdateProbes, this);
cclegacy.director.on(cclegacy.DirectorEvent.BEFORE_UPDATE, this.onUpdateProbes, this);
this._registeredEvent = true;
}
}
Expand Down
3 changes: 2 additions & 1 deletion cocos/3d/skinned-mesh-renderer/skinned-mesh-renderer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ import type { SkeletalAnimation } from '../skeletal-animation';
import { cclegacy, assertIsTrue } from '../../core';
import { SkinningModel } from '../models/skinning-model';
import { BakedSkinningModel } from '../models/baked-skinning-model';
import type { Root } from '../../root';

/**
* @en The skinned mesh renderer component.
Expand Down Expand Up @@ -130,7 +131,7 @@ export class SkinnedMeshRenderer extends MeshRenderer {
if (!force && this._modelType === modelType) { return; }
this._modelType = modelType;
if (this._model) {
cclegacy.director.root.destroyModel(this._model);
(cclegacy.director.root as Root).destroyModel(this._model);
this._model = null;
this._models.length = 0;
this._updateModels();
Expand Down
6 changes: 4 additions & 2 deletions cocos/animation/animation-clip.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ import { EmbeddedPlayableState, EmbeddedPlayer } from './embedded-player/embedde
import { AuxiliaryCurveEntry } from './auxiliary-curve-entry';
import { removeIf } from '../core/utils/array';
import { invokeComponentMethodsEngagedInAnimationEvent } from './event/event-emitter';
import type { DataPoolManager } from '../3d/skeletal-animation/data-pool-manager';

export declare namespace AnimationClip {
export interface IEvent {
Expand Down Expand Up @@ -410,8 +411,9 @@ export class AnimationClip extends Asset {
}

public destroy (): boolean {
if (cclegacy.director.root?.dataPoolManager) {
(cclegacy.director.root.dataPoolManager).releaseAnimationClip(this);
const dataPoolManager = cclegacy.director.root?.dataPoolManager as (DataPoolManager | null);
if (dataPoolManager) {
dataPoolManager.releaseAnimationClip(this);
}
SkelAnimDataHub.destroy(this);
return super.destroy();
Expand Down
Loading

0 comments on commit 9247851

Please sign in to comment.