add flood swe module and 2km building bundles
This commit is contained in:
@@ -13,9 +13,10 @@ using UnityEngine;
|
||||
|
||||
public class GeoTileImporter : EditorWindow
|
||||
{
|
||||
private string tilesCsvPath = "Assets/GeoData/tile_index.csv";
|
||||
private string heightmapsDir = "Assets/GeoData/height_png16";
|
||||
private string orthoDir = "Assets/GeoData/ortho_jpg";
|
||||
private string tilesCsvPath = "Assets/GeoData/tile_index_river_vr.csv";
|
||||
private string heightmapsDir = "Assets/GeoData/height_png16_river/vr";
|
||||
private string orthoDir = "Assets/GeoData/ortho_jpg_river";
|
||||
private string orthoDirFallback = "Assets/GeoData/ortho_jpg";
|
||||
private string buildingsDir = "Assets/GeoData/buildings_tiles";
|
||||
private string buildingsEnhancedDir = "Assets/GeoData/buildings_enhanced";
|
||||
private string treesDir = "Assets/GeoData/trees_tiles";
|
||||
@@ -34,6 +35,7 @@ public class GeoTileImporter : EditorWindow
|
||||
private bool applyOrthoTextures = true;
|
||||
private bool importBuildings = true;
|
||||
private bool useEnhancedBuildings = false;
|
||||
private bool importBuildingsEvenTilesOnly = true;
|
||||
private bool importTrees = true;
|
||||
private bool importFurniture = false;
|
||||
private bool deleteExistingBuildings = false;
|
||||
@@ -83,7 +85,8 @@ public class GeoTileImporter : EditorWindow
|
||||
GUILayout.Label("Inputs", EditorStyles.boldLabel);
|
||||
tilesCsvPath = EditorGUILayout.TextField("tile_index.csv", tilesCsvPath);
|
||||
heightmapsDir = EditorGUILayout.TextField("height_png16 dir", heightmapsDir);
|
||||
orthoDir = EditorGUILayout.TextField("ortho_jpg dir", orthoDir);
|
||||
orthoDir = EditorGUILayout.TextField("ortho_jpg dir (primary)", orthoDir);
|
||||
orthoDirFallback = EditorGUILayout.TextField("ortho_jpg dir (fallback)", orthoDirFallback);
|
||||
buildingsDir = EditorGUILayout.TextField("buildings_glb dir", buildingsDir);
|
||||
treesDir = EditorGUILayout.TextField("trees_glb dir", treesDir);
|
||||
treeProxyPath = EditorGUILayout.TextField("tree_proxies.glb", treeProxyPath);
|
||||
@@ -103,6 +106,7 @@ public class GeoTileImporter : EditorWindow
|
||||
deleteExistingBuildings = EditorGUILayout.ToggleLeft("Delete existing buildings under parent", deleteExistingBuildings);
|
||||
importBuildings = EditorGUILayout.ToggleLeft("Import buildings (GLB per tile)", importBuildings);
|
||||
useEnhancedBuildings = EditorGUILayout.ToggleLeft("Use enhanced buildings (from buildings_enhanced/)", useEnhancedBuildings);
|
||||
importBuildingsEvenTilesOnly = EditorGUILayout.ToggleLeft("Import 2km buildings once (even X/Y tiles only)", importBuildingsEvenTilesOnly);
|
||||
|
||||
GUILayout.Space(5);
|
||||
treesParentName = EditorGUILayout.TextField("Trees parent name", treesParentName);
|
||||
@@ -287,10 +291,15 @@ public class GeoTileImporter : EditorWindow
|
||||
Debug.LogError($"[GeoTileImporter] Heightmap dir not found: {heightmapsDir}");
|
||||
return;
|
||||
}
|
||||
if (applyOrthoTextures && !Directory.Exists(orthoDir))
|
||||
if (applyOrthoTextures)
|
||||
{
|
||||
Debug.LogWarning($"[GeoTileImporter] Ortho dir not found: {orthoDir} (textures will be skipped).");
|
||||
applyOrthoTextures = false;
|
||||
bool primaryExists = Directory.Exists(orthoDir);
|
||||
bool fallbackExists = !string.IsNullOrWhiteSpace(orthoDirFallback) && Directory.Exists(orthoDirFallback);
|
||||
if (!primaryExists && !fallbackExists)
|
||||
{
|
||||
Debug.LogWarning($"[GeoTileImporter] Ortho dirs not found: primary={orthoDir}, fallback={orthoDirFallback} (textures will be skipped).");
|
||||
applyOrthoTextures = false;
|
||||
}
|
||||
}
|
||||
|
||||
RefreshTileIndexCache();
|
||||
@@ -431,6 +440,12 @@ public class GeoTileImporter : EditorWindow
|
||||
if (applyOrthoTextures)
|
||||
{
|
||||
string orthoPath = Path.Combine(orthoDir, $"{tileId}.jpg").Replace("\\", "/");
|
||||
if (!File.Exists(orthoPath) && !string.IsNullOrWhiteSpace(orthoDirFallback))
|
||||
{
|
||||
string fallbackPath = Path.Combine(orthoDirFallback, $"{tileId}.jpg").Replace("\\", "/");
|
||||
if (File.Exists(fallbackPath))
|
||||
orthoPath = fallbackPath;
|
||||
}
|
||||
if (File.Exists(orthoPath))
|
||||
{
|
||||
EnsureOrthoImportSettings(orthoPath);
|
||||
@@ -805,6 +820,56 @@ public class GeoTileImporter : EditorWindow
|
||||
public int Y;
|
||||
}
|
||||
|
||||
private static bool TryGetTileXY(string tileId, out int x, out int y)
|
||||
{
|
||||
x = 0;
|
||||
y = 0;
|
||||
if (string.IsNullOrWhiteSpace(tileId))
|
||||
return false;
|
||||
|
||||
var parts = tileId.Split('_');
|
||||
var coords = new List<int>();
|
||||
for (int i = 0; i < parts.Length; i++)
|
||||
{
|
||||
string part = parts[i];
|
||||
if (part.Length < 3)
|
||||
continue;
|
||||
|
||||
bool allDigits = true;
|
||||
for (int j = 0; j < part.Length; j++)
|
||||
{
|
||||
if (!char.IsDigit(part[j]))
|
||||
{
|
||||
allDigits = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (!allDigits)
|
||||
continue;
|
||||
|
||||
if (int.TryParse(part, NumberStyles.Integer, CultureInfo.InvariantCulture, out int value))
|
||||
coords.Add(value);
|
||||
}
|
||||
|
||||
if (coords.Count < 2)
|
||||
return false;
|
||||
|
||||
x = coords[coords.Count - 2];
|
||||
y = coords[coords.Count - 1];
|
||||
return true;
|
||||
}
|
||||
|
||||
private static bool ShouldImportBuildingsForTile(string tileId, bool evenTilesOnly)
|
||||
{
|
||||
if (!evenTilesOnly)
|
||||
return true;
|
||||
|
||||
if (!TryGetTileXY(tileId, out int x, out int y))
|
||||
return true;
|
||||
|
||||
return (x % 2 == 0) && (y % 2 == 0);
|
||||
}
|
||||
|
||||
private void ImportBuildings(List<(string tileId, float ux, float uz, float baseY)> placements)
|
||||
{
|
||||
@@ -829,9 +894,15 @@ public class GeoTileImporter : EditorWindow
|
||||
DestroyImmediate(parent.transform.GetChild(i).gameObject);
|
||||
}
|
||||
|
||||
int imported = 0, missing = 0;
|
||||
int imported = 0, missing = 0, skipped = 0;
|
||||
foreach (var (tileId, ux, uz, baseY) in placements)
|
||||
{
|
||||
if (!ShouldImportBuildingsForTile(tileId, importBuildingsEvenTilesOnly))
|
||||
{
|
||||
skipped++;
|
||||
continue;
|
||||
}
|
||||
|
||||
string glbPath = Path.Combine(activeDir, $"{tileId}.glb").Replace("\\", "/");
|
||||
if (!File.Exists(glbPath))
|
||||
{
|
||||
@@ -863,7 +934,7 @@ public class GeoTileImporter : EditorWindow
|
||||
imported++;
|
||||
}
|
||||
|
||||
Debug.Log($"[GeoTileImporter] Buildings ({sourceLabel}) imported={imported}, missing/failed={missing} under '{buildingsParentName}'.");
|
||||
Debug.Log($"[GeoTileImporter] Buildings ({sourceLabel}) imported={imported}, skipped={skipped}, missing/failed={missing} under '{buildingsParentName}'.");
|
||||
}
|
||||
|
||||
private void ImportTrees(List<(string tileId, float ux, float uz, float baseY)> placements)
|
||||
|
||||
Reference in New Issue
Block a user