[engine] Spine 组件多纹理渲染、动态图集、与其它组件合批、region 换装

This commit is contained in:
SmallMain
2022-06-25 01:02:25 +08:00
parent 7dbe1a4f72
commit a414bb7945
7 changed files with 467 additions and 70 deletions

View File

@@ -191,6 +191,52 @@ let MeshBuffer = cc.Class({
this.requestStatic(vertexCount, indiceCount);
return this._offsetInfo;
},
requestForSpine(vertexCount, indiceCount) {
if (this._batcher._buffer !== this) {
this._batcher._flush();
this._batcher._buffer = this;
}
this.requestStaticForSpine(vertexCount, indiceCount);
return this._offsetInfo;
},
requestStaticForSpine(vertexCount, indiceCount) {
this.checkAndSwitchBuffer(vertexCount);
let byteOffset = this.byteOffset + vertexCount * this._vertexBytes;
let indiceOffset = this.indiceOffset + indiceCount;
let byteLength = this._vData.byteLength;
let indiceLength = this._iData.length;
if (byteOffset > byteLength || indiceOffset > indiceLength) {
while (byteLength < byteOffset || indiceLength < indiceOffset) {
this._initVDataCount *= 2;
this._initIDataCount *= 2;
byteLength = this._initVDataCount * 4;
indiceLength = this._initIDataCount;
}
this._reallocBuffer();
}
let offsetInfo = this._offsetInfo;
offsetInfo.vertexOffset = this.vertexOffset;
offsetInfo.indiceOffset = this.indiceOffset;
offsetInfo.byteOffset = this.byteOffset;
},
adjustForSpine(vertexCount, indiceCount) {
this.vertexOffset += vertexCount;
this.indiceOffset += indiceCount;
this.byteOffset = this.byteOffset + vertexCount * this._vertexBytes;
this._dirty = true;
},
_reallocBuffer () {
this._reallocVData(true);