From 03ae98db9877323bfe4bbf62f2af62e46b286b72 Mon Sep 17 00:00:00 2001 From: Myway Date: Thu, 1 Aug 2019 15:16:03 +0800 Subject: [PATCH] 3d v1.0.0 terrain (#5037) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * 上传地形系统 * 上传地形系统 * 新增地形导出 * 新增Terrain Shader * vmath相关修改 * 修复TerrainSample启动崩溃问题 * 修改规范问题及生命周期问题 * 增加地形类型导出 * 修改Terrain部分序列化问题 * 暴露属性 * 解决画刷在Manage模式还会残留的问题 * 更新代码 * 解决画刷位置渲染错误,修改terrain材质的更新逻辑 --- cocos/renderer/terrain/terrain-editor-paint.ts | 4 ++-- cocos/renderer/terrain/terrain-editor-sculpt.ts | 4 ++-- cocos/renderer/terrain/terrain.ts | 16 +++++----------- 3 files changed, 9 insertions(+), 15 deletions(-) diff --git a/cocos/renderer/terrain/terrain-editor-paint.ts b/cocos/renderer/terrain/terrain-editor-paint.ts index e2e8858bea..ca8461adb3 100644 --- a/cocos/renderer/terrain/terrain-editor-paint.ts +++ b/cocos/renderer/terrain/terrain-editor-paint.ts @@ -32,8 +32,8 @@ export class TerrainEditorPaint extends TerrainEditorMode { const index = i.getIndex(); const bound = new Rect(); - bound.x = index[0] * terrain.info.tileSize; - bound.y = index[1] * terrain.info.tileSize; + bound.x = index[0] * TERRAIN_BLOCK_TILE_COMPLEXITY * terrain.info.tileSize; + bound.y = index[1] * TERRAIN_BLOCK_TILE_COMPLEXITY * terrain.info.tileSize; bound.width = TERRAIN_BLOCK_TILE_COMPLEXITY * terrain.info.tileSize; bound.height = TERRAIN_BLOCK_TILE_COMPLEXITY * terrain.info.tileSize; diff --git a/cocos/renderer/terrain/terrain-editor-sculpt.ts b/cocos/renderer/terrain/terrain-editor-sculpt.ts index 647de3823c..cc0d5f0a6c 100644 --- a/cocos/renderer/terrain/terrain-editor-sculpt.ts +++ b/cocos/renderer/terrain/terrain-editor-sculpt.ts @@ -22,8 +22,8 @@ export class TerrainEditorSculpt extends TerrainEditorMode { const index = block.getIndex(); const bound = new Rect(); - bound.x = index[0] * terrain.info.tileSize; - bound.y = index[1] * terrain.info.tileSize; + bound.x = index[0] * TERRAIN_BLOCK_TILE_COMPLEXITY * terrain.info.tileSize; + bound.y = index[1] * TERRAIN_BLOCK_TILE_COMPLEXITY * terrain.info.tileSize; bound.width = TERRAIN_BLOCK_TILE_COMPLEXITY * terrain.info.tileSize; bound.height = TERRAIN_BLOCK_TILE_COMPLEXITY * terrain.info.tileSize; diff --git a/cocos/renderer/terrain/terrain.ts b/cocos/renderer/terrain/terrain.ts index b8e0952f46..30f984b442 100644 --- a/cocos/renderer/terrain/terrain.ts +++ b/cocos/renderer/terrain/terrain.ts @@ -135,7 +135,11 @@ export class TerrainRenderable extends RenderableComponent { defines: block._getMaterialDefines(nlayers), }); - this._updateBrushMaterial(); + if (this._brushMaterial !== null) { + const passes = this._currentMaterial.passes; + + passes.push(this._brushMaterial.passes[0]); + } if (init) { this._model.initSubModel(0, this._meshData, this._currentMaterial); @@ -172,16 +176,6 @@ export class TerrainRenderable extends RenderableComponent { private _getBuiltinMaterial () { return builtinResMgr.get('missing-material'); } - - private _updateBrushMaterial () { - if (this._currentMaterial == null || this._brushMaterial == null) { - return; - } - - const passes = this._currentMaterial.passes; - - passes.push(this._brushMaterial.passes[0]); - } } @ccclass('cc.TerrainBlockInfo')