Skip to content

Commit

Permalink
Update
Browse files Browse the repository at this point in the history
  • Loading branch information
dumganhar committed Oct 20, 2024
1 parent 632b7e9 commit 5eb3040
Show file tree
Hide file tree
Showing 8 changed files with 12 additions and 36 deletions.
4 changes: 2 additions & 2 deletions cocos/2d/components/label.ts
Original file line number Diff line number Diff line change
Expand Up @@ -955,7 +955,7 @@ export class Label extends UIRenderer {
this._applyFontTexture();
}
if (this._assembler) {
this._assembler.updateRenderData(this);
this._assembler.updateRenderData!(this);
}
}

Expand Down Expand Up @@ -1033,7 +1033,7 @@ export class Label extends UIRenderer {
}
this.changeMaterialForDefine();
if (this._assembler) {
this._assembler.updateRenderData(this);
this._assembler.updateRenderData!(this);
}
}
} else {
Expand Down
9 changes: 5 additions & 4 deletions 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 { RenderData } from '../renderer/render-data';

/**
* @en
Expand Down Expand Up @@ -604,11 +605,11 @@ export class Sprite extends UIRenderer {

if (!this._renderData) {
if (this._assembler && this._assembler.createData) {
this._renderData = this._assembler.createData(this);
this._renderData!.material = this.getRenderMaterial(0);
this._renderData = this._assembler.createData(this) as RenderData;
this._renderData.material = this.getRenderMaterial(0);
this.markForUpdateRenderData();
if (this.spriteFrame) {
this._assembler.updateUVs(this);
this._assembler.updateUVs!(this);
}
this._updateColor();
}
Expand Down Expand Up @@ -679,7 +680,7 @@ export class Sprite extends UIRenderer {

private _updateUVs (): void {
if (this._assembler) {
this._assembler.updateUVs(this);
this._assembler.updateUVs!(this);
}
}

Expand Down
5 changes: 3 additions & 2 deletions cocos/2d/framework/ui-renderer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -401,8 +401,9 @@ export class UIRenderer extends Renderer {
* @deprecated Since v3.7.0, this is an engine private interface that will be removed in the future.
*/
public updateRenderer (): void {
if (this._assembler) {
this._assembler.updateRenderData(this);
const assembler = this._assembler;
if (assembler && assembler.updateRenderData) {
assembler.updateRenderData(this);
}
this._renderFlag = this._canRender();
this._renderEntity.enabled = this._renderFlag;
Expand Down
2 changes: 1 addition & 1 deletion cocos/2d/renderer/base.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ export interface IAssembler {
fillBuffers? (comp: UIRenderer, renderer: IBatcher): void;
updateUVs? (comp: UIRenderer, ...args: any[]): void;
updateColor? (comp: UIRenderer): void;
updateRenderData (comp: UIRenderer): void;
updateRenderData? (comp: UIRenderer): void;
update? (comp: UIRenderer, dt: number): void;
resetAssemblerData? (data: any): void;
removeData? (data: BaseRenderData): void;
Expand Down
2 changes: 1 addition & 1 deletion cocos/2d/renderer/batcher-2d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -436,7 +436,7 @@ export class Batcher2D implements IBatcher {
}
}

assembler.fillBuffers(comp, this);
if (assembler.fillBuffers) assembler.fillBuffers(comp, this);
}

/**
Expand Down
7 changes: 0 additions & 7 deletions cocos/dragon-bones/assembler/simple.ts
Original file line number Diff line number Diff line change
Expand Up @@ -129,13 +129,6 @@ let _accessor: StaticVBAccessor = null!;
* 可通过 `UI.simple` 获取该组装器。
*/
class Simple implements IAssembler {
fillBuffers (comp: ArmatureDisplay, renderer: IBatcher): void {

}
updateUVs (comp: ArmatureDisplay): void {

}

private accessor = _accessor;
private vCount = 32767;
ensureAccessor (): StaticVBAccessor {
Expand Down
4 changes: 0 additions & 4 deletions cocos/particle-2d/motion-streak-2d-assembler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -233,10 +233,6 @@ class MotionStreakAssembler implements IAssembler {
}
}

updateColor (comp: MotionStreak): void {
// do nothing
}

fillBuffers (comp: MotionStreak, renderer: IBatcher): void {
const renderData = comp.renderData!;
const chunk = renderData.chunk;
Expand Down
15 changes: 0 additions & 15 deletions cocos/particle-2d/particle-system-2d-assembler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,33 +26,18 @@
import type { IAssembler, IAssemblerManager } from '../2d/renderer/base';
import { ParticleSystem2D } from './particle-system-2d';
import { MeshRenderData } from '../2d/renderer/render-data';
import type { IBatcher } from '../2d/renderer/i-batcher';
import { cclegacy } from '../core';

export class Particle2DAssembler implements IAssembler {
maxParticleDeltaTime = 0;

updateUVs (comp: ParticleSystem2D): void {

}

updateColor (comp: ParticleSystem2D): void {

}

createData (comp: ParticleSystem2D): MeshRenderData {
return MeshRenderData.add();
}

removeData (data: MeshRenderData): void {
MeshRenderData.remove(data);
}

updateRenderData (): void {
}

fillBuffers (comp: ParticleSystem2D, renderer: IBatcher): void {
}
}

export const particle2DAssembler = new Particle2DAssembler();
Expand Down

0 comments on commit 5eb3040

Please sign in to comment.