fix terrain brush pass error by material gc (#9125)

Co-authored-by: Myway3D1 <404793124@qq.com>
This commit is contained in:
Myway
2021-08-06 15:30:59 +08:00
committed by GitHub
parent c0c1c0313f
commit 5efab6d032
+11 -1
View File
@@ -209,6 +209,16 @@ class TerrainRenderable extends RenderableComponent {
return;
}
if (this._brushMaterial !== null && this._brushMaterial.passes !== null && this._brushMaterial.passes.length > 0) {
const passes = this._currentMaterial.passes;
for (let i = 0; i < passes.length; ++i) {
if (passes[i] === this._brushMaterial.passes[0]) {
passes.pop();
break;
}
}
}
this._clearMaterials();
this._currentMaterial = null;
@@ -557,8 +567,8 @@ export class TerrainBlock {
public setBrushMaterial (mtl: Material|null) {
if (this._renderable._brushMaterial !== mtl) {
this._renderable._brushMaterial = mtl;
this._renderable._invalidMaterial();
this._renderable._brushMaterial = mtl;
}
}