Browse Source

Fix terrain "delete" brush mode

ShiroSmith 7 years ago
parent
commit
4c8e80602a

+ 0 - 2
hide/prefab/terrain/Brush.hx

@@ -43,11 +43,9 @@ enum Mode {
 }
 
 class BrushMode {
-
 	public var accumulate = false;
 	public var substract = false;
 	public var mode = Paint;
-
 	public function new(){}
 }
 

+ 2 - 0
hide/prefab/terrain/StrokeBuffer.hx

@@ -32,6 +32,8 @@ class StrokeBuffer {
 		tempTex = new h3d.mat.Texture(size, size, [Target], format);
 		tex.filter = Linear;
 		tempTex.filter = Linear;
+		tex.preventAutoDispose();
+		tempTex.preventAutoDispose();
 	}
 
 	public function reset(){

+ 3 - 3
hide/prefab/terrain/Terrain.hx

@@ -184,9 +184,9 @@ class Terrain extends Object3D {
 					surface.offset.y = surfaceProps.offsetY;
 					surface.angle = surfaceProps.angle;
 					surface.tilling = surfaceProps.tilling;
-					//albedo.dispose();
-					//normal.dispose();
-					//pbr.dispose();
+					albedo.dispose();
+					normal.dispose();
+					pbr.dispose();
 				}
 			}
 			wait();

+ 3 - 12
hide/prefab/terrain/TerrainEditor.hx

@@ -396,20 +396,13 @@ class TerrainEditor {
 	}
 
 	function useBrush( from : h3d.Vector, to : h3d.Vector, ctx : Context){
-
-		if(currentBrush.brushMode.mode == Delete){
-			 applyBrush(to, ctx);
-			 previewStrokeBuffers();
-			 return;
-		}
-
+		// First click
 		var dist = (to.sub(from)).length();
 		if(dist == 0){
 			applyBrush(from, ctx);
 			previewStrokeBuffers();
 			return;
 		}
-
 		if(dist + remainingDist >= currentBrush.step){
 			var dir = to.sub(from);
 			dir.normalize();
@@ -423,17 +416,14 @@ class TerrainEditor {
 					pos = pos.add(firstStep);
 				}else
 					pos = pos.add(step);
-
 				applyBrush(pos, ctx);
-
 				dist -= currentBrush.step - remainingDist;
 				remainingDist = 0;
 			}
 			remainingDist = dist;
 			previewStrokeBuffers();
-		}else{
+		}else
 			remainingDist += dist;
-		}
 	}
 
 	public function deleteTile(pos : h3d.Vector, ctx : Context){
@@ -443,6 +433,7 @@ class TerrainEditor {
 		if(tile == null) return;
 		terrainPrefab.terrain.removeTile(tile);
 		tileTrashBin.push(tile);
+		renderTerrainUV(ctx);
 	}
 
 	public function drawSurface(pos : h3d.Vector, ctx : Context){