Terrain restore不再处理asset (#6203)

This commit is contained in:
Myway
2020-02-21 19:00:14 +08:00
committed by GitHub
parent b07d91cf98
commit 0250cd663b
+4 -4
View File
@@ -896,7 +896,7 @@ export class Terrain extends Component {
public onRestore () {
this.onDisable();
this.onLoad();
this._buildImp();
this._buildImp(true);
}
public update (dtime: number) {
@@ -1255,12 +1255,12 @@ export class Terrain extends Component {
}
}
private _buildImp () {
private _buildImp (restore: boolean = false) {
if (this.valid) {
return true;
}
if (this.__asset != null) {
if (!restore && this.__asset != null) {
this._tileSize = this.__asset.tileSize;
this._blockCount = this.__asset.blockCount;
this._weightMapSize = this.__asset.weightMapSize;
@@ -1295,7 +1295,7 @@ export class Terrain extends Component {
// build heights & normals
const vcount = this.vertexCount[0] * this.vertexCount[1];
if (this._heights.length !== vcount) {
if (this._heights === null || this._heights.length !== vcount) {
this._heights = new Uint16Array(vcount);
this._normals = new Array<number>(vcount * 3);