Refresh generated terrain assets and projection
This commit is contained in:
parent
3608be41ab
commit
05838406d0
53 changed files with 319 additions and 51 deletions
|
|
@ -481,6 +481,9 @@ func _validate_generated_region(
|
|||
assert(river_body_count == river_placement_count)
|
||||
|
||||
_validate_authored_chunk_surfaces(region, generator)
|
||||
_validate_projected_terrain_materials(
|
||||
generator.get_generated_chunks_root()
|
||||
)
|
||||
|
||||
var decorations := region.get_node("Decorations") as Node3D
|
||||
var anchors := region.get_node(
|
||||
|
|
@ -1147,21 +1150,28 @@ func _validate_tree_gatherable_anchors(
|
|||
anchors: GatherableAnchorSet3D,
|
||||
) -> void:
|
||||
var eligible_props: Dictionary[StringName, Node3D] = {}
|
||||
var expected_anchor_count := 0
|
||||
for child: Node in decorations.get_children():
|
||||
var prop := child as Node3D
|
||||
if prop == null:
|
||||
continue
|
||||
var prop_id := StringName(prop.get_meta(&"terrain_prop_id", &""))
|
||||
var definition := region.get_prop_catalog().definition_for_id(prop_id)
|
||||
if definition != null and definition.has_gatherable_surface():
|
||||
var socket_count := _count_authored_beetle_sockets(prop)
|
||||
if (
|
||||
definition != null
|
||||
and definition.has_gatherable_surface()
|
||||
and socket_count > 0
|
||||
):
|
||||
eligible_props[prop.name] = prop
|
||||
expected_anchor_count += socket_count
|
||||
var positions := anchors.get_spawn_positions()
|
||||
assert(positions.size() == eligible_props.size())
|
||||
assert(positions.size() == expected_anchor_count)
|
||||
assert(positions.size() >= 12)
|
||||
for child: Node in anchors.get_children():
|
||||
var anchor := child as Marker3D
|
||||
assert(anchor != null)
|
||||
assert(bool(anchor.get_meta(&"mesh_surface_sampled", false)))
|
||||
assert(bool(anchor.get_meta(&"authored_beetle_socket", false)))
|
||||
var prop_name := StringName(anchor.get_meta(&"terrain_prop_name", &""))
|
||||
assert(eligible_props.has(prop_name))
|
||||
var prop: Node3D = eligible_props[prop_name]
|
||||
|
|
@ -1169,14 +1179,17 @@ func _validate_tree_gatherable_anchors(
|
|||
var definition := region.get_prop_catalog().definition_for_id(prop_id)
|
||||
assert(definition != null and definition.has_gatherable_surface())
|
||||
var local_anchor := prop.to_local(anchor.global_position)
|
||||
assert(
|
||||
local_anchor.y
|
||||
>= definition.gatherable_surface_minimum_height - 0.001
|
||||
)
|
||||
assert(
|
||||
local_anchor.y
|
||||
<= definition.gatherable_surface_maximum_height + 0.001
|
||||
)
|
||||
assert(prop_id != &"prop_palm")
|
||||
assert(local_anchor.y >= 0.25 and local_anchor.y <= 2.0)
|
||||
|
||||
|
||||
func _count_authored_beetle_sockets(root_node: Node) -> int:
|
||||
var result := 0
|
||||
if String(root_node.name).to_lower().contains("beetle_socket"):
|
||||
result += 1
|
||||
for child: Node in root_node.get_children():
|
||||
result += _count_authored_beetle_sockets(child)
|
||||
return result
|
||||
|
||||
|
||||
func _find_mesh_instance(root_node: Node) -> MeshInstance3D:
|
||||
|
|
@ -1357,6 +1370,56 @@ func _material_names(mesh_instance: MeshInstance3D) -> PackedStringArray:
|
|||
return result
|
||||
|
||||
|
||||
func _validate_projected_terrain_materials(root: Node) -> void:
|
||||
var expected_sizes := {
|
||||
"grass_lite": 1.75,
|
||||
"sand": 2.6,
|
||||
"dirt": 2.5,
|
||||
}
|
||||
var surface_counts := {
|
||||
"grass_lite": 0,
|
||||
"sand": 0,
|
||||
"dirt": 0,
|
||||
}
|
||||
_validate_projected_material_node(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,
|
||||
expected_sizes: Dictionary,
|
||||
surface_counts: Dictionary,
|
||||
) -> void:
|
||||
var mesh_instance := root 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)
|
||||
if material == null or not expected_sizes.has(material.resource_name):
|
||||
continue
|
||||
var shader_material := material as ShaderMaterial
|
||||
assert(shader_material != null and shader_material.shader != null)
|
||||
assert(
|
||||
shader_material.shader.resource_path
|
||||
== "res://world/materials/terrain_surface_projection.gdshader"
|
||||
)
|
||||
assert(
|
||||
is_equal_approx(
|
||||
float(shader_material.get_shader_parameter(
|
||||
&"tile_world_size"
|
||||
)),
|
||||
float(expected_sizes[material.resource_name]),
|
||||
)
|
||||
)
|
||||
surface_counts[material.resource_name] += 1
|
||||
for child: Node in root.get_children():
|
||||
_validate_projected_material_node(
|
||||
child,
|
||||
expected_sizes,
|
||||
surface_counts,
|
||||
)
|
||||
|
||||
|
||||
func _validate_pond_collision(
|
||||
region: GeneratedWorldRegion,
|
||||
pond: MeshInstance3D,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue