Răsfoiți Sursa

Remove interactive for terrain

ShiroSmith 6 ani în urmă
părinte
comite
821e96880b

+ 7 - 0
hide/comp/SceneEditor.hx

@@ -1,5 +1,6 @@
 package hide.comp;
 
+import hrt.prefab.terrain.Terrain;
 import h3d.scene.Mesh;
 import h3d.col.FPoint;
 import h3d.col.Ray;
@@ -521,6 +522,12 @@ class SceneEditor {
 		var obj3d = Std.downcast(elt, Object3D);
 		if(obj3d == null)
 			return;
+
+		// Disable Interactive for the terrain
+		var terrain = Std.downcast(elt, Terrain);
+		if(terrain != null)
+			return;
+
 		var contexts = context.shared.contexts;
 		var ctx = contexts[elt];
 		if(ctx == null)

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

@@ -94,6 +94,7 @@ class TerrainEditor {
 		heightStrokeBufferArray.dispose();
 		weightStrokeBufferArray.dispose();
 		brushPreview.remove();
+		if( interactive != null ) interactive.remove();
 	}
 
 	public function saveTextures()  {
@@ -721,6 +722,8 @@ class TerrainEditor {
 	public function setSelected( ctx : Context, b : Bool ) {
 		if( b ) {
 			var s2d = @:privateAccess ctx.local2d.getScene();
+			if( interactive == null ) 
+				interactive.remove();
 			interactive = new h2d.Interactive(10000, 10000, s2d);
 			interactive.propagateEvents = true;
 			interactive.cancelEvents = false;

+ 1 - 4
hrt/prefab/terrain/Terrain.hx

@@ -397,6 +397,7 @@ class Terrain extends Object3D {
 		#else
 		terrain = new TerrainMesh(ctx.local3d);
 		#end
+
 		terrain.cellCount = getCellCount();
 		terrain.cellSize = getCellSize();
 		terrain.tileSize = terrain.cellCount * terrain.cellSize;
@@ -444,10 +445,6 @@ class Terrain extends Object3D {
 		#end
 	}
 
-	override function removeInstance( ctx : Context ) : Bool {
-		return false; // TODO
-	}
-
 	function getCellCount() {
 		var resolution = Math.max(0.1, cellSize);
 		var cellCount = Math.ceil(Math.min(1000, tileSize / resolution));