[3.0] [bugfix] spine debug graphics not drawing (#7849)

* fix graphics memleak

* revert change in graphics
This commit is contained in:
江战
2020-11-24 15:20:59 +08:00
committed by GitHub
parent a17e6a5f46
commit 04daf86633
2 changed files with 9 additions and 14 deletions
+1 -1
View File
@@ -445,7 +445,7 @@ function realTimeTraverse (worldMat?: Mat4) {
_debugMesh = _comp!.debugMesh;
if (graphics && (_debugBones || _debugSlots || _debugMesh)) {
graphics.clear();
graphics.lineWidth = 2;
graphics.lineWidth = 5;
}
// x y u v r1 g1 b1 a1 r2 g2 b2 a2 or x y u v r g b a
+8 -13
View File
@@ -125,7 +125,6 @@ js.setClassAlias(SpineSocket, 'sp.Skeleton.SpineSocket');
@menu('Components/SpineSkeleton')
@executeInEditMode
export class Skeleton extends UIRenderable {
public static SpineSocket = SpineSocket;
public static AnimationCacheMode = AnimationCacheMode;
@@ -206,7 +205,7 @@ export class Skeleton extends UIRenderable {
set animation (value: string) {
if (value) {
this.setAnimation(0, value, this.loop);
this.resetRenderData();
this.destroyRenderData();
this.markForUpdateRenderData();
} else if (!this.isAnimationCached()) {
this.clearTrack(0);
@@ -1282,12 +1281,6 @@ export class Skeleton extends UIRenderable {
}
}
public resetRenderData () {
if (this._meshRenderDataArray.length > 0) {
this._meshRenderDataArray.forEach((rd) => { rd.renderData.reset(); });
}
}
public getMaterialForBlendAndTint (src: GFXBlendFactor, dst: GFXBlendFactor, type: SpineMaterialType): MaterialInstance {
const key = `${type}/${src}/${dst}`;
let inst = this._materialCache[key];
@@ -1323,9 +1316,9 @@ export class Skeleton extends UIRenderable {
if (this._cachedSockets.size > 0) {
return Array.from(this._cachedSockets.keys()).sort();
}
return [];
}
// 当前的 _meshRenderDataArray 的索引, 以便 fillBuffers 选取 RenderData
public _meshRenderDataArrayIdx = 0;
protected _render (ui: UI) {
if (this._meshRenderDataArray) {
@@ -1333,7 +1326,6 @@ export class Skeleton extends UIRenderable {
this._meshRenderDataArrayIdx = i;
const m = this._meshRenderDataArray[i];
if (m.texture) {
// NOTE: 由于 commitComp 只支持单张纹理, 故分多次提交
ui.commitComp(this, m.texture, this._assembler, null);
}
}
@@ -1551,14 +1543,17 @@ export class Skeleton extends UIRenderable {
debugDraw.strokeColor = new Color(255, 0, 0, 255);
this._debugRenderer = debugDraw;
debugDrawNode.parent = this.node;
}
// this._debugRenderer.node.active = true;
this._debugRenderer.node.parent = this.node;
if (this.isAnimationCached()) {
warn('Debug bones or slots is invalid in cached mode');
}
} else if (this._debugRenderer) {
this._debugRenderer.node.parent = null;
this._debugRenderer.node.destroy();
this._debugRenderer = null;
// this._debugRenderer.node.active = false;
}
}
@@ -1567,7 +1562,7 @@ export class Skeleton extends UIRenderable {
if (this._assembler !== assembler) {
this._assembler = assembler;
}
if (this._meshRenderDataArray.length == 0) {
if (this._meshRenderDataArray.length === 0) {
if (this._assembler && this._assembler.createData) {
this._assembler.createData(this);
this.markForUpdateRenderData();