fix: harden recovery flow and clean diagnostics
This commit is contained in:
parent
0158b0215f
commit
ff78710303
64 changed files with 1163 additions and 418 deletions
|
|
@ -18,6 +18,12 @@ const Gatherables: GatherableCatalog = preload(
|
|||
const PrecipitationOcclusionType = preload(
|
||||
"res://world/environment/precipitation_occlusion.gd"
|
||||
)
|
||||
const FOLIAGE_WIND_SHADER: Shader = preload(
|
||||
"res://world/materials/foliage_wind.gdshader"
|
||||
)
|
||||
const FOLIAGE_WIND_SOURCE_MATERIALS_META: StringName = (
|
||||
&"foliage_wind_source_materials"
|
||||
)
|
||||
const FIRST_SEED := 13001
|
||||
const SECOND_SEED := 13002
|
||||
const RIVER_FALLBACK_SEED := 13012
|
||||
|
|
@ -130,8 +136,8 @@ func _validate_generated_region(
|
|||
var placements := generator.placement_keys()
|
||||
var expected_chunk_count := generator.grid_size.x * generator.grid_size.y
|
||||
var center := Vector2i(
|
||||
generator.grid_size.x / 2,
|
||||
generator.grid_size.y / 2,
|
||||
int(float(generator.grid_size.x) / 2.0),
|
||||
int(float(generator.grid_size.y) / 2.0),
|
||||
)
|
||||
var center_index := center.y * generator.grid_size.x + center.x
|
||||
assert(generator.grid_size == Vector2i(20, 20))
|
||||
|
|
@ -341,7 +347,7 @@ func _validate_generated_region(
|
|||
):
|
||||
var outlet_coordinate := Vector2i(
|
||||
index % generator.grid_size.x,
|
||||
index / generator.grid_size.x,
|
||||
int(float(index) / float(generator.grid_size.x)),
|
||||
)
|
||||
outlet_coordinates.append(outlet_coordinate)
|
||||
assert(
|
||||
|
|
@ -366,7 +372,7 @@ func _validate_generated_region(
|
|||
for index: int in placements.size():
|
||||
var coordinate := Vector2i(
|
||||
index % generator.grid_size.x,
|
||||
index / generator.grid_size.x,
|
||||
int(float(index) / float(generator.grid_size.x)),
|
||||
)
|
||||
if placements[index].begins_with("chunk_0001@"):
|
||||
assert(generator._distance_from_map_boundary(coordinate) <= 1)
|
||||
|
|
@ -587,8 +593,8 @@ func _validate_generated_region(
|
|||
Vector2i.ZERO,
|
||||
)
|
||||
var spawn_coordinate := Vector2i(
|
||||
generator.grid_size.x / 2,
|
||||
generator.grid_size.y / 2,
|
||||
int(float(generator.grid_size.x) / 2.0),
|
||||
int(float(generator.grid_size.y) / 2.0),
|
||||
)
|
||||
var spawn_distance := (
|
||||
absi(coordinate.x - spawn_coordinate.x)
|
||||
|
|
@ -1146,8 +1152,8 @@ func _validate_biome_catalog(
|
|||
for biome_id: StringName in EXPECTED_BIOME_IDS:
|
||||
assert(counts.get(biome_id, 0) > 0)
|
||||
var center := Vector2i(
|
||||
generator.grid_size.x / 2,
|
||||
generator.grid_size.y / 2,
|
||||
int(float(generator.grid_size.x) / 2.0),
|
||||
int(float(generator.grid_size.y) / 2.0),
|
||||
)
|
||||
assert(region.get_biome_at(center) == &"biome_plains")
|
||||
for child: Node in generator.get_generated_chunks_root().get_children():
|
||||
|
|
@ -1504,12 +1510,27 @@ func _has_material_variant_override(
|
|||
return false
|
||||
var mesh_instance := root_node as MeshInstance3D
|
||||
if mesh_instance != null and mesh_instance.mesh != null:
|
||||
var source_materials: Dictionary = mesh_instance.get_meta(
|
||||
FOLIAGE_WIND_SOURCE_MATERIALS_META,
|
||||
{},
|
||||
)
|
||||
for surface_index: int in mesh_instance.mesh.get_surface_count():
|
||||
var override := mesh_instance.get_surface_override_material(
|
||||
surface_index
|
||||
)
|
||||
if override != null and override in variants:
|
||||
return true
|
||||
var wind_material := override as ShaderMaterial
|
||||
if (
|
||||
wind_material != null
|
||||
and wind_material.shader == FOLIAGE_WIND_SHADER
|
||||
):
|
||||
var source_material: Material = source_materials.get(
|
||||
surface_index,
|
||||
null,
|
||||
) as Material
|
||||
if source_material != null and source_material in variants:
|
||||
return true
|
||||
for child: Node in root_node.get_children():
|
||||
if _has_material_variant_override(child, variants):
|
||||
return true
|
||||
|
|
@ -1647,7 +1668,7 @@ func _material_names(mesh_instance: MeshInstance3D) -> PackedStringArray:
|
|||
return result
|
||||
|
||||
|
||||
func _validate_projected_terrain_materials(root: Node) -> void:
|
||||
func _validate_projected_terrain_materials(projected_root: Node) -> void:
|
||||
var expected_sizes := {
|
||||
"grass_lite": 1.75,
|
||||
"sand": 2.6,
|
||||
|
|
@ -1658,17 +1679,21 @@ func _validate_projected_terrain_materials(root: Node) -> void:
|
|||
"sand": 0,
|
||||
"dirt": 0,
|
||||
}
|
||||
_validate_projected_material_node(root, expected_sizes, surface_counts)
|
||||
_validate_projected_material_node(
|
||||
projected_root,
|
||||
expected_sizes,
|
||||
surface_counts,
|
||||
)
|
||||
for material_name: String in expected_sizes:
|
||||
assert(surface_counts[material_name] > 0)
|
||||
|
||||
|
||||
func _validate_projected_material_node(
|
||||
root: Node,
|
||||
node: Node,
|
||||
expected_sizes: Dictionary,
|
||||
surface_counts: Dictionary,
|
||||
) -> void:
|
||||
var mesh_instance := root as MeshInstance3D
|
||||
var mesh_instance := node as MeshInstance3D
|
||||
if mesh_instance != null and mesh_instance.mesh != null:
|
||||
for surface_index: int in mesh_instance.mesh.get_surface_count():
|
||||
var material := mesh_instance.get_active_material(surface_index)
|
||||
|
|
@ -1689,7 +1714,7 @@ func _validate_projected_material_node(
|
|||
)
|
||||
)
|
||||
surface_counts[material.resource_name] += 1
|
||||
for child: Node in root.get_children():
|
||||
for child: Node in node.get_children():
|
||||
_validate_projected_material_node(
|
||||
child,
|
||||
expected_sizes,
|
||||
|
|
@ -1708,8 +1733,10 @@ func _validate_pond_collision(
|
|||
var vertices := arrays[Mesh.ARRAY_VERTEX] as PackedVector3Array
|
||||
var normals := arrays[Mesh.ARRAY_NORMAL] as PackedVector3Array
|
||||
var indices := arrays[Mesh.ARRAY_INDEX] as PackedInt32Array
|
||||
var triangle_count := (
|
||||
indices.size() / 3 if not indices.is_empty() else vertices.size() / 3
|
||||
var triangle_count: int = (
|
||||
int(float(indices.size()) / 3.0)
|
||||
if not indices.is_empty()
|
||||
else int(float(vertices.size()) / 3.0)
|
||||
)
|
||||
for triangle_index: int in triangle_count:
|
||||
var offset := triangle_index * 3
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue