2
0
ShiroSmith 6 жил өмнө
parent
commit
4005f3246a

+ 49 - 22
hide/prefab/terrain/TerrainEditor.hx

@@ -110,32 +110,59 @@ class TerrainEditor {
 	}
 
 	function readyToSave() : Bool {
-		if( editContext == null )
-			return false;
-		if( terrainPrefab == null )
-			return false;
-		if( terrainPrefab.terrain == null )
-			return false;
-		if( terrainPrefab.terrain.surfaceArray == null )
-			return false;
-		if( terrainPrefab.terrain.surfaceArray.albedo == null || terrainPrefab.terrain.surfaceArray.albedo.isDisposed() )
-			return false;
-		if( terrainPrefab.terrain.surfaceArray.normal == null || terrainPrefab.terrain.surfaceArray.normal.isDisposed() )
-			return false;
-		if( terrainPrefab.terrain.surfaceArray.pbr == null || terrainPrefab.terrain.surfaceArray.pbr.isDisposed() )
-			return false;
-		for( tile in terrainPrefab.terrain.tiles ) {
-			if( tile == null )
+		var error = "Failed to save terrain : ";
+		if( editContext == null ){
+				trace(error + "editContext is null");
 				return false;
-			for( s in tile.surfaceWeights )
-				if( s == null || s.isDisposed() )
-					return false;
-			if( tile.heightMap == null || tile.heightMap.isDisposed() )
+			}
+		if( terrainPrefab == null ){
+				trace(error + "terrainPrefab is null");
 				return false;
-			if( tile.surfaceIndexMap == null || tile.surfaceIndexMap.isDisposed())
+			}
+		if( terrainPrefab.terrain == null ){
+				trace(error + "terrain is null");
 				return false;
-			if( tile.surfaceWeightArray == null || tile.surfaceWeightArray.isDisposed())
+			}
+		if( terrainPrefab.terrain.surfaceArray == null ){
+				trace(error + "surfaceArray is null");
+				return false;
+			}
+		if( terrainPrefab.terrain.surfaceArray.albedo == null || terrainPrefab.terrain.surfaceArray.albedo.isDisposed() ){
+				trace(error + "surfaceArray.albedo is null");
 				return false;
+			}
+		if( terrainPrefab.terrain.surfaceArray.normal == null || terrainPrefab.terrain.surfaceArray.normal.isDisposed() ){
+				trace(error + "surfaceArray.normal is null");
+				return false;
+			}
+		if( terrainPrefab.terrain.surfaceArray.pbr == null || terrainPrefab.terrain.surfaceArray.pbr.isDisposed() ){
+				trace(error + "surfaceArray.pbr is null");
+				return false;
+			}
+
+		for( tile in terrainPrefab.terrain.tiles ) {
+			if( tile == null ) {
+				trace(error + "tile is null");
+				return false;
+			}
+			for( s in tile.surfaceWeights ) {
+				if( s == null || s.isDisposed() ) {
+					trace(error + "surfaceWeights "+ tile.surfaceWeights.indexOf(s) +" is null or sisposed ");
+					return false;
+				}
+			}
+			if( tile.heightMap == null || tile.heightMap.isDisposed() ) {
+					trace(error + "heightMap is null or sisposed ");
+					return false;
+			}
+			if( tile.surfaceIndexMap == null || tile.surfaceIndexMap.isDisposed() ) {
+					trace(error + "surfaceIndexMap is null or sisposed ");
+					return false;
+			}
+			if( tile.surfaceWeightArray == null || tile.surfaceWeightArray.isDisposed() ) {
+					trace(error + "surfaceWeightArray is null or sisposed ");
+					return false;
+			}
 		}
 		return true;
 	}

+ 13 - 0
hrt/prefab/terrain/Terrain.hx

@@ -162,6 +162,19 @@ class Terrain extends Object3D {
 				}
 			}
 		}
+
+		#if editor
+		for( t in terrain.tiles ) {
+			if( t == null ) {
+				"Missing tile" + terrain.tiles.indexOf(t);
+				continue;
+			}
+			if( t.heightMap == null ) "Missing heightmap for tile" + terrain.tiles.indexOf(t);
+			if( t.surfaceIndexMap == null ) "Missing surfaceIndexMap for tile" + terrain.tiles.indexOf(t);
+			if( t.surfaceWeightArray == null ) "Missing surfaceWeightArray for tile" + terrain.tiles.indexOf(t);
+		}
+		#end
+
 		@:privateAccess hxd.res.Image.ENABLE_AUTO_WATCH = prevWatch;
 	}