Commit 2a62f6d9 authored by haiyoucuv's avatar haiyoucuv

init

parent db5f8677
...@@ -1514,7 +1514,7 @@ ...@@ -1514,7 +1514,7 @@
"__prefab": null, "__prefab": null,
"_contentSize": { "_contentSize": {
"__type__": "cc.Size", "__type__": "cc.Size",
"width": 106, "width": 58,
"height": 58 "height": 58
}, },
"_anchorPoint": { "_anchorPoint": {
......
...@@ -283,6 +283,7 @@ export class Snake extends Component { ...@@ -283,6 +283,7 @@ export class Snake extends Component {
); );
this.head.setPosition(newHeadPos); this.head.setPosition(newHeadPos);
this.head.setScale(this.scale, this.scale); this.head.setScale(this.scale, this.scale);
this.head.setSiblingIndex(this.bodyArr.length);
const space = ~~(this.SEGMENT_SPACING * this.scale); const space = ~~(this.SEGMENT_SPACING * this.scale);
......
...@@ -39,8 +39,8 @@ CCProgram sprite-vs %{ ...@@ -39,8 +39,8 @@ CCProgram sprite-vs %{
in vec2 a_texCoord; in vec2 a_texCoord;
in vec4 a_color; in vec4 a_color;
out vec4 color; out lowp vec4 color;
out vec3 uv0; out mediump vec3 uv0;
vec4 vert () { vec4 vert () {
vec4 pos = vec4(a_position, 1); vec4 pos = vec4(a_position, 1);
...@@ -57,11 +57,11 @@ CCProgram sprite-vs %{ ...@@ -57,11 +57,11 @@ CCProgram sprite-vs %{
pos = cc_matViewProj * pos; pos = cc_matViewProj * pos;
#endif #endif
// uv0 = a_texCoord;
float id = mod(a_texCoord.x,10.0);
uv0.x = (a_texCoord.x - id)*0.000001;
uv0.y = a_texCoord.y; uv0.y = a_texCoord.y;
uv0.z = id; uv0.z = mod(a_texCoord.x,10.0);
//uv0.z = fract(a_texCoord.x*0.1);
//uv0.z = floor(uv0.z*10.0+0.1);
uv0.x = (a_texCoord.x-uv0.z)*0.000001;
#if SAMPLE_FROM_RT #if SAMPLE_FROM_RT
CC_HANDLE_RT_SAMPLE_FLIP(uv0.xy); CC_HANDLE_RT_SAMPLE_FLIP(uv0.xy);
...@@ -73,14 +73,14 @@ CCProgram sprite-vs %{ ...@@ -73,14 +73,14 @@ CCProgram sprite-vs %{
}% }%
CCProgram sprite-fs %{ CCProgram sprite-fs %{
precision highp float; precision mediump float;
#include <builtin/internal/embedded-alpha> #include <builtin/internal/embedded-alpha>
#include <builtin/internal/alpha-test> #include <builtin/internal/alpha-test>
in vec4 color; in lowp vec4 color;
#if USE_TEXTURE #if USE_TEXTURE
in vec3 uv0; in mediump vec3 uv0;
#pragma builtin(local) #pragma builtin(local)
layout(set = 2, binding = 12) uniform sampler2D cc_spriteTexture; layout(set = 2, binding = 12) uniform sampler2D cc_spriteTexture;
uniform sampler2D texture1; uniform sampler2D texture1;
...@@ -96,19 +96,19 @@ CCProgram sprite-fs %{ ...@@ -96,19 +96,19 @@ CCProgram sprite-fs %{
vec4 o = vec4(1, 1, 1, 1); vec4 o = vec4(1, 1, 1, 1);
#if USE_TEXTURE #if USE_TEXTURE
if(uv0.z<0.5) if(uv0.z == 0.0)
o *= CCSampleWithAlphaSeparated(cc_spriteTexture, uv0.xy); o *= CCSampleWithAlphaSeparated(cc_spriteTexture, uv0.xy);
else if(uv0.z<1.5) else if(uv0.z == 1.0)
o *= CCSampleWithAlphaSeparated(texture1, uv0.xy); o *= CCSampleWithAlphaSeparated(texture1, uv0.xy);
else if(uv0.z<2.5) else if(uv0.z == 2.0)
o *= CCSampleWithAlphaSeparated(texture2, uv0.xy); o *= CCSampleWithAlphaSeparated(texture2, uv0.xy);
else if(uv0.z<3.5) else if(uv0.z == 3.0)
o *= CCSampleWithAlphaSeparated(texture3, uv0.xy); o *= CCSampleWithAlphaSeparated(texture3, uv0.xy);
else if(uv0.z<4.5) else if(uv0.z == 4.0)
o *= CCSampleWithAlphaSeparated(texture4, uv0.xy); o *= CCSampleWithAlphaSeparated(texture4, uv0.xy);
else if(uv0.z<5.5) else if(uv0.z == 5.0)
o *= CCSampleWithAlphaSeparated(texture5, uv0.xy); o *= CCSampleWithAlphaSeparated(texture5, uv0.xy);
else if(uv0.z<6.5) else if(uv0.z == 6.0)
o *= CCSampleWithAlphaSeparated(texture6, uv0.xy); o *= CCSampleWithAlphaSeparated(texture6, uv0.xy);
else else
o *= CCSampleWithAlphaSeparated(texture7, uv0.xy); o *= CCSampleWithAlphaSeparated(texture7, uv0.xy);
......
//*// //*//
import { import {
__private,
assert,
BaseRenderData, BaseRenderData,
BitmapFont,
cclegacy,
Color,
Component,
Director, Director,
director,
Game, Game,
game,
gfx,
Label,
Material, Material,
MotionStreak, MotionStreak,
murmurhash2_32_gc,
Node, Node,
ParticleSystem2D, renderer,
resources,
Sprite, Sprite,
SpriteFrame, SpriteFrame,
StencilManager, StencilManager,
TiledLayer, TiledLayer,
TiledRenderData,
UIRenderer, UIRenderer,
__private, VERSION
_decorator, } from "cc";
assert, import { DEBUG, EDITOR, JSB } from "cc/env";
cclegacy,
director,
game,
renderer,
resources
} from 'cc';
import { DEBUG, EDITOR, JSB } from 'cc/env';
const {ccclass, property} = _decorator; const MAX_TEX = 8; //最大纹理
//@ts-ignore
gfx.Texture.prototype.texID = -1; //当前纹理id
//@ts-ignore
Material.prototype.isMultTextures = false; //多纹理材质标记
export const MultBatch2D: any = { export const MultBatch2D: any = {
enable: false, enable: false,
parent: null, parent: null,
textures: [], incID: 0,
count: 0,
hash: 0, hash: 0,
reset: function () { reset: function () {
this.textures.length = 0; this.incID += this.count;
this.count = 0;
} }
}; };
const loadMultTextures = function () {
MultBatch2D.enable = false; //提前加载多纹理材质
resources.load("MultTextures/Mult-material", Material, (err, material) => {
if (!err) {
let mat = cclegacy.builtinResMgr.get("ui-sprite-material");
if (mat) {
mat._hash = MultBatch2D.hash = Material.getHash(mat);
MultBatch2D.parent = material;
MultBatch2D.enable = true;
material.addRef();
}
}
});
};
let _cacheUseCount: number = 0; let _cacheUseCount: number = 0;
let _cacheMaterials: Array<Material> = []; let _cacheMaterials: Array<Material> = [];
const getMultMaterial = function (oldMat: any) { const getMultMaterial = function (oldMat: any) {
MultBatch2D.reset(); MultBatch2D.reset();
if (!MultBatch2D.enable || if (!MultBatch2D.enable ||
!oldMat || !oldMat.isMultTextures) { !oldMat || !oldMat.isMultTextures) {
return oldMat; return oldMat;
} }
//if (!MultBatch2D.enable) return null; if (!MultBatch2D.parent
|| !MultBatch2D.parent.isValid) {
loadMultTextures();
return oldMat;
}
let newMat: any = _cacheMaterials[_cacheUseCount++]; let newMat: any = _cacheMaterials[_cacheUseCount++];
if (!newMat) { if (!newMat || !newMat.isValid) {
const material = {parent: MultBatch2D.parent}; const material = { parent: MultBatch2D.parent };
newMat = new renderer.MaterialInstance(material); newMat = new renderer.MaterialInstance(material);
newMat['isMultTextures'] = true; _cacheMaterials[_cacheUseCount - 1] = newMat;
_cacheMaterials.push(newMat); newMat["isMultTextures"] = true;
newMat["cacheTextures"] = [-1];
newMat.addRef();
} }
return newMat; return newMat;
} };
//如果有异常组件,或者自定义组件, //@ts-ignore
//在这进行添加排除,不参与多纹理合批 Component.prototype.useMult = false;
//组件控制开关 useMult: 可以开启自定义组件是不参与多纹理
const excludeMaterial = function (uir: UIRenderer, material: any) { const excludeMaterial = function (uir: UIRenderer, material: any) {
if (!material) return; if (!material) return;
let enable: boolean = true; material["isMultTextures"] = false;
if (enable && TiledLayer) { //@ts-ignore
enable = !(uir instanceof TiledLayer); if (uir.useMult || uir instanceof Sprite || uir instanceof Label) {
} if (MultBatch2D.hash == material.hash) {
if (enable && MotionStreak) { material["isMultTextures"] = true;
enable = !(uir instanceof MotionStreak); }
}
if (enable && ParticleSystem2D) {
enable = !(uir instanceof ParticleSystem2D);
}
material['isMultTextures'] = false;
if (enable && MultBatch2D.hash == material.hash) {
material['isMultTextures'] = true;
} }
} };
game.once(Game.EVENT_GAME_INITED, () => { game.once(Game.EVENT_GAME_INITED, () => {
if (EDITOR || JSB) return; if (EDITOR || JSB) return;
//提前加载多纹理材质 loadMultTextures();
resources.load("MultTextures/Mult-material", Material, (err, material) => {
if (!err) {
let mat = cclegacy.builtinResMgr.get('ui-sprite-material');
MultBatch2D.hash = Material.getHash(mat);
MultBatch2D.parent = material;
MultBatch2D.enable = true;
}
});
const UIR: any = UIRenderer.prototype; const UIR: any = UIRenderer.prototype;
const updateMaterial: any = UIR.updateMaterial; const updateMaterial: any = UIR.updateMaterial;
UIR.updateMaterial = function () { UIR.updateMaterial = function () {
updateMaterial.call(this); //this.getSharedMaterial(0); updateMaterial.call(this); //this.getSharedMaterial(0);
excludeMaterial(this, this.customMaterial || this.material); excludeMaterial(this, this.customMaterial || this.material);
} };
}); });
...@@ -108,18 +128,41 @@ game.once(Game.EVENT_GAME_INITED, () => { ...@@ -108,18 +128,41 @@ game.once(Game.EVENT_GAME_INITED, () => {
game.once(Game.EVENT_ENGINE_INITED, () => { game.once(Game.EVENT_ENGINE_INITED, () => {
if (EDITOR || JSB) return; if (EDITOR || JSB) return;
cclegacy.UI.RenderData.prototype.texID = -1; director.on(Director.EVENT_AFTER_DRAW, (dt) => {
cclegacy.UI.RenderData.prototype.texDirty = true;
cclegacy.UI.RenderData.prototype.dataDirty = true;
Object.defineProperty(cclegacy.UI.RenderData.prototype, "vertDirty", { MultBatch2D.reset();
_cacheUseCount = 0;
});
const RenderData = cclegacy.UI.RenderData.prototype;
RenderData.texID = -1;
RenderData.sprite = false;
RenderData.texDirty = true;
RenderData.dataDirty = 0x0;
RenderData.updateHash = function () {
if (this.material && this.material.isMultTextures) {
const bid = this.chunk ? this.chunk.bufferId : 100000;
this.dataHash = bid * 1000000000 + this.layer;
this.hashDirty = false;
// console.log("updateHash:" + this.chunk.bufferId );
} else {
const bid = this.chunk ? this.chunk.bufferId : -1;
const hashString = `${bid}${this.layer} ${this.textureHash}`;
this.dataHash = murmurhash2_32_gc(hashString, 666);
this.hashDirty = false;
}
};
Object.defineProperty(RenderData, "vertDirty", {
get: function () { get: function () {
return this._vertDirty; return this._vertDirty;
}, },
set: function (val: boolean) { set: function (val: boolean) {
this._vertDirty = val; this._vertDirty = val;
if (val === true) { if (val === true && !this.sprite) {
this.dataDirty = true; this.dataDirty |= 1;
} }
if (this._renderDrawInfo && val) { if (this._renderDrawInfo && val) {
this._renderDrawInfo.setVertDirty(val); this._renderDrawInfo.setVertDirty(val);
...@@ -127,7 +170,7 @@ game.once(Game.EVENT_ENGINE_INITED, () => { ...@@ -127,7 +170,7 @@ game.once(Game.EVENT_ENGINE_INITED, () => {
} }
}); });
Object.defineProperty(cclegacy.UI.RenderData.prototype, "textureDirty", { Object.defineProperty(RenderData, "textureDirty", {
get: function () { get: function () {
return this.texDirty; return this.texDirty;
}, },
...@@ -139,37 +182,82 @@ game.once(Game.EVENT_ENGINE_INITED, () => { ...@@ -139,37 +182,82 @@ game.once(Game.EVENT_ENGINE_INITED, () => {
} }
}); });
const UIR: any = UIRenderer.prototype;
const _updateColor: any = UIR._updateColor;
UIR._updateColor = function () {
let dataDirty = false;
let rd = this.renderData;
if (rd) dataDirty = rd.dataDirty;
_updateColor.call(this); let str = (VERSION.concat());
str = str.replace(".", "").replace(".", "");
if (parseInt(str) < 384) { //修复 renderManager
const UIR: any = UIRenderer.prototype;
const markForUpdateRenderData = UIR.markForUpdateRenderData;
UIR.markForUpdateRenderData = function (enable = true) {
markForUpdateRenderData.call(this, enable);
if (enable && this.renderData) {
if (!this.renderData.sprite)
this.renderData.dataDirty |= 2;
}
};
const updateRenderer = UIR.updateRenderer;
UIR.updateRenderer = function () {
updateRenderer.call(this);
if (this.renderData) {
if (!this.renderData.sprite)
this.renderData.dataDirty &= (~2);
}
};
if (rd) {
rd.dataDirty = dataDirty;
}
} }
const SPR: any = Sprite.prototype; let SPRA: any = cclegacy.UI.spriteAssembler;
const _render = SPR._render; if (SPRA) {
SPR._render = function (render: any) { const spriteAssembler = SPRA.getAssembler;
if (this.node.hasChangedFlags) { SPRA.getAssembler = function (sprite: Sprite) {
if (this.type === Sprite.Type.TILED const spr = spriteAssembler.call(this, sprite);
|| this.type === Sprite.Type.FILLED if (spr.changeUV == undefined) {
&& this.fillType === Sprite.FillType.RADIAL) { spr.changeUV = function (s: any) {
let rd = this.renderData; let rd = s.renderData;
rd && (rd.dataDirty = true); if (rd) {
rd.dataDirty = 1;
rd.sprite = true;
}
};
const UVs = spr.updateUVs;
if (UVs) {
if (sprite.type == Sprite.Type.FILLED &&
sprite.fillType != Sprite.FillType.RADIAL) {
spr.updateUVs = function (s: any, f0: number, f1: number) {
UVs.call(this, s, f0, f1);
this.changeUV(s);
};
} else {
spr.updateUVs = function (s: any) {
UVs.call(this, s);
this.changeUV(s);
};
}
}
const verUV = spr.updateWorldVertexAndUVData;
if (verUV) {
spr.updateWorldVertexAndUVData = function (s: any, c: any) {
verUV.call(this, s, c);
this.changeUV(s);
};
}
} }
}
_render.call(this, render); return spr;
};
} }
cclegacy.internal.Batcher2D.prototype.cacheTextures = [];
cclegacy.internal.Batcher2D.prototype.currMaterial = null; cclegacy.internal.Batcher2D.prototype.currMaterial = null;
cclegacy.internal.Batcher2D.prototype.isMultTextures = false;
Object.defineProperty(cclegacy.internal.Batcher2D.prototype, "_currMaterial", { Object.defineProperty(cclegacy.internal.Batcher2D.prototype, "_currMaterial", {
get: function () { get: function () {
return this.currMaterial; return this.currMaterial;
...@@ -177,35 +265,26 @@ game.once(Game.EVENT_ENGINE_INITED, () => { ...@@ -177,35 +265,26 @@ game.once(Game.EVENT_ENGINE_INITED, () => {
set: function (metrial: any) { set: function (metrial: any) {
if (this.currMaterial === metrial) return; if (this.currMaterial === metrial) return;
this.currMaterial = getMultMaterial(metrial); this.currMaterial = getMultMaterial(metrial);
if (MultBatch2D.enable) {
this.isMultTextures = false;
if (this.currMaterial && this.currMaterial.isMultTextures) {
this.cacheTextures = this.currMaterial.cacheTextures;
this.isMultTextures = true;
}
}
} }
}); });
director.on(Director.EVENT_AFTER_DRAW, (dt) => {
cclegacy.internal.Batcher2D._rdHash = -1;
MultBatch2D.reset();
_cacheUseCount = 0;
});
const MAX_TEX = 8;
const _texture = {
texture: new cclegacy.SimpleTexture(),
defalut: new cclegacy.SimpleTexture(),
setFrame(frame: any) {
this.texture['_gfxSampler'] = frame.getGFXSampler();
this.texture['_gfxTextureView'] = frame.getGFXTexture();
}
};
const Stage_ENTER_LEVEL = 2; const Stage_ENTER_LEVEL = 2;
const Stage_ENTER_LEVEL_INVERTED = 6; const Stage_ENTER_LEVEL_INVERTED = 6;
//@ts-ignore //@ts-ignore
type TextureBase = __private._cocos_asset_assets_texture_base__TextureBase; type TextureBase = __private._cocos_asset_assets_texture_base__TextureBase;
cclegacy.internal.Batcher2D.prototype._rdHash = -1;
cclegacy.internal.Batcher2D.prototype.commitComp = function (comp: UIRenderer, renderData: BaseRenderData | null, frame: TextureBase | SpriteFrame | null, assembler: any, transform: Node | null) { cclegacy.internal.Batcher2D.prototype.commitComp = function (comp: UIRenderer, renderData: BaseRenderData | null, frame: TextureBase | SpriteFrame | null, assembler: any, transform: Node | null) {
let rdHash = -1;
let dataHash = 0; let dataHash = 0;
let mat: any; let mat: any = null;
let bufferID = -1; let bufferID = -1;
if (renderData && renderData.chunk) { if (renderData && renderData.chunk) {
...@@ -213,9 +292,6 @@ game.once(Game.EVENT_ENGINE_INITED, () => { ...@@ -213,9 +292,6 @@ game.once(Game.EVENT_ENGINE_INITED, () => {
dataHash = renderData.dataHash; dataHash = renderData.dataHash;
mat = renderData.material; mat = renderData.material;
bufferID = renderData.chunk.bufferId; bufferID = renderData.chunk.bufferId;
// as RenderData;
let rd: any = renderData;
rdHash = bufferID << 16 | rd.layer;
} }
...@@ -230,26 +306,17 @@ game.once(Game.EVENT_ENGINE_INITED, () => { ...@@ -230,26 +306,17 @@ game.once(Game.EVENT_ENGINE_INITED, () => {
let texID = -1; let texID = -1;
let texture = null; let texture = null;
let MB = MultBatch2D;
let flushBatch = false; let flushBatch = false;
let isMultTextures = false; if (MB.enable && mat && mat.isMultTextures) {
if (MultBatch2D.enable && mat && mat.isMultTextures) { if (frame && frame.isValid)
texture = frame && frame.getGFXTexture(); texture = frame.getGFXTexture();
texID = MultBatch2D.textures.indexOf(texture); if (texture) {
isMultTextures = true;
if (texID < 0) { //@ts-ignore
if (MultBatch2D.textures.length == MAX_TEX) { texID = texture.texID - MB.incID;
// MultBatch2D.textures.length = 0; flushBatch = texID < 0 && MB.count >= MAX_TEX;
flushBatch = true; if (this.isMultTextures) mat = this._currMaterial;
}
}
if (this._currMaterial && this._currMaterial.isMultTextures) {
mat = this._currMaterial;
dataHash = this._currHash;
if (this._rdHash != rdHash) {
flushBatch = true;
texID = -1;
}
} }
} }
...@@ -263,7 +330,7 @@ game.once(Game.EVENT_ENGINE_INITED, () => { ...@@ -263,7 +330,7 @@ game.once(Game.EVENT_ENGINE_INITED, () => {
this.updateBuffer(renderData.vertexFormat, bufferID); this.updateBuffer(renderData.vertexFormat, bufferID);
} }
this._rdHash = rdHash;
this._currRenderData = renderData; this._currRenderData = renderData;
this._currHash = renderData ? renderData.dataHash : 0; this._currHash = renderData ? renderData.dataHash : 0;
this._currComponent = comp; this._currComponent = comp;
...@@ -273,7 +340,7 @@ game.once(Game.EVENT_ENGINE_INITED, () => { ...@@ -273,7 +340,7 @@ game.once(Game.EVENT_ENGINE_INITED, () => {
this._currLayer = comp.node.layer; this._currLayer = comp.node.layer;
if (frame) { if (frame) {
if (DEBUG) { if (DEBUG) {
assert(frame.isValid, 'frame should not be invalid, it may have been released'); assert(frame.isValid, "frame should not be invalid, it may have been released");
} }
this._currTexture = frame.getGFXTexture(); this._currTexture = frame.getGFXTexture();
this._currSampler = frame.getGFXSampler(); this._currSampler = frame.getGFXSampler();
...@@ -290,47 +357,149 @@ game.once(Game.EVENT_ENGINE_INITED, () => { ...@@ -290,47 +357,149 @@ game.once(Game.EVENT_ENGINE_INITED, () => {
assembler.fillBuffers(comp, this); assembler.fillBuffers(comp, this);
if (isMultTextures) { if (texture !== null) {
if (texID < 0 || MB.count === 0) {
if (texID < 0) { texID = MB.count++;
texID = MultBatch2D.textures.length; //@ts-ignore
MultBatch2D.textures.push(texture); let id = texture.objectID;
if (texID > 0) { //@ts-ignore
_texture.setFrame(frame); texture.texID = texID + MB.incID;
const name = "texture" + texID;
this._currMaterial.setProperty(name, _texture.texture); let caches = this.cacheTextures;
if (texID > 0 && caches[texID] !== id) {
caches[texID] = id;
this._currMaterial.setProperty("texture" + texID, texture);
} }
} }
this._fillDatas(renderData, texID); this._fillDatas(renderData, texID);
} }
} };
cclegacy.internal.Batcher2D.prototype["_fillDatas"] = function (renderData: any, texID: number) { cclegacy.internal.Batcher2D.prototype["_fillDatas"] = function (renderData: any, texID: number) {
// if (!renderData) return;
if (!renderData) return;
let uvX = 0; let uvX = 0;
let vbuf = renderData.chunk.vb; let vbuf = renderData.chunk.vb;
if (renderData.dataDirty) { if (renderData.dataDirty === 1) {
renderData.dataDirty = false; renderData.dataDirty = 0;
for (let i = 0, length = vbuf.length; i < length; i += 9) { for (let i = 0, length = vbuf.length; i < length; i += 9) {
uvX = ~~(vbuf[i + 3] * 100000); uvX = ~~(vbuf[i + 3] * 100000);
vbuf[i + 3] = uvX * 10 + texID; vbuf[i + 3] = uvX * 10 + texID;
} }
} else { } else {
if (renderData.texID != texID) { if (renderData.texID !== texID) {
for (let i = 0, length = vbuf.length; i < length; i += 9) { for (let i = 0, length = vbuf.length; i < length; i += 9) {
uvX = ~~(vbuf[i + 3] * 0.1); uvX = ~~(vbuf[i + 3] * 0.1);
vbuf[i + 3] = uvX * 10 + texID; vbuf[i + 3] = uvX * 10 + texID;
} }
} }
} }
renderData.dataDirty = 0;
renderData.texID = texID; renderData.texID = texID;
}; };
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
if (MotionStreak) {
//@ts-ignore
MotionStreak.prototype.useMult = true;
const motionStreak: any = MotionStreak.Assembler;
const motionAssembler = motionStreak.getAssembler;
motionStreak.getAssembler = function (comp: Label) {
let assembler = motionAssembler.call(this, comp);
if (!assembler.changDirty) {
assembler.changDirty = function (comp: MotionStreak) {
if (comp.points.length >= 2) {
let rd: any = comp.renderData;
//标记刷新纹理id数据
rd && (rd.dataDirty = 1);
}
};
const update = assembler.update;
assembler.update = function (comp: MotionStreak, dt: number) {
update.call(this, comp, dt);
this.changDirty(comp);
};
}
return assembler;
};
}
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
if (TiledLayer) {
const Tiled: any = TiledLayer.prototype;
;
Tiled.useMult = true;
Tiled.dataDirty = false;
const setUserNodeDirty = Tiled.setUserNodeDirty;
Tiled.setUserNodeDirty = function (dirty: boolean) {
setUserNodeDirty.call(this, dirty);
if (!dirty) {
//标记刷新纹理id数据
this.dataDirty = true;
}
};
Tiled._render = function (ui: any): void {
for (let i = 0; i < this._tiledDataArray.length; i++) {
this._tiledDataArrayIdx = i;
const m = this._tiledDataArray[i];
if (m.subNodes) {
// 提前处理 User Nodes
m.subNodes.forEach((c: any) => {
if (c) ui.walk(c.node);
});
} else {
const td = m as TiledRenderData;
if (td.texture) {
const data = this.tiledDataArray[this._tiledDataArrayIdx] as TiledRenderData;
let rd: any = data.renderData;
if (rd) {
//切换实际绘画renderdata
let isDirty = false;
rd.renderData = data.renderData;
rd.renderData.material = this.material;
if (rd.texture !== data.texture) {
rd.texture = data.texture;
isDirty = true;
}
if (rd.layer !== this.node.layer) {
rd.layer = this.node.layer;
isDirty = true;
}
//更新renderdata hash
isDirty && rd.updateHash();
if (this.dataDirty) {
rd.dataDirty = 1;
}
}
// NOTE: 由于 commitComp 只支持单张纹理, 故分多次提交
ui.commitComp(this, rd.renderData, rd.texture, this._assembler, null);
}
}
}
this.dataDirty = false;
this.node._static = true;
};
}
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
}); });
//*/ //*/
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment