Add turning rivers and lake edge variation
This commit is contained in:
parent
f2b96f2c1f
commit
6fd1aa0388
53 changed files with 2039 additions and 386 deletions
|
|
@ -136,17 +136,30 @@ func _validate_generated_region(
|
|||
assert(maxi(
|
||||
generator._river_feature_footprint_size.x,
|
||||
generator._river_feature_footprint_size.y,
|
||||
) >= 7)
|
||||
) >= 4)
|
||||
assert(mini(
|
||||
generator._river_feature_footprint_size.x,
|
||||
generator._river_feature_footprint_size.y,
|
||||
) == 2)
|
||||
) >= 4)
|
||||
assert(generator._river_feature_flow_direction in [
|
||||
Vector2i.RIGHT,
|
||||
Vector2i.DOWN,
|
||||
Vector2i.LEFT,
|
||||
Vector2i.UP,
|
||||
])
|
||||
assert(generator._river_feature_outlet_direction in [
|
||||
Vector2i.RIGHT,
|
||||
Vector2i.DOWN,
|
||||
Vector2i.LEFT,
|
||||
Vector2i.UP,
|
||||
])
|
||||
assert(
|
||||
generator._river_feature_flow_direction.x
|
||||
* generator._river_feature_outlet_direction.x
|
||||
+ generator._river_feature_flow_direction.y
|
||||
* generator._river_feature_outlet_direction.y
|
||||
== 0
|
||||
)
|
||||
assert(generator.elevated_cliff_coastal_feature_required)
|
||||
assert(placements.size() == expected_chunk_count)
|
||||
assert(placements[center_index].begins_with("chunk_spawn@"))
|
||||
|
|
@ -226,6 +239,10 @@ func _validate_generated_region(
|
|||
assert(_placement_count(placements, "chunk_0030") == 1)
|
||||
assert(_placement_count(placements, "chunk_0031") == 1)
|
||||
assert(_placement_count(placements, "chunk_0032") == 1)
|
||||
assert(_placement_count(placements, "chunk_0033") == 1)
|
||||
assert(_placement_count(placements, "chunk_0034") == 1)
|
||||
assert(_placement_count(placements, "chunk_0035") == 1)
|
||||
assert(_placement_count(placements, "chunk_0036") == 1)
|
||||
assert(
|
||||
_placement_count(placements, "chunk_0014")
|
||||
== (2 if has_secondary_elevation else 0)
|
||||
|
|
@ -239,12 +256,15 @@ func _validate_generated_region(
|
|||
assert(_placement_count(placements, "chunk_0022") == 4)
|
||||
assert(_placement_count(placements, "chunk_0023") == 4)
|
||||
var lake_edge_count := _placement_count(placements, "chunk_0017")
|
||||
var lake_edge_variant_count := _placement_count(placements, "chunk_0037")
|
||||
var lake_fill_count := _placement_count(placements, "chunk_0019")
|
||||
var lake_narrow_count := _placement_count(placements, "chunk_0021")
|
||||
var lake_size := generator._lake_feature_footprint_size.x
|
||||
assert(lake_size in [7, 8])
|
||||
assert(lake_fill_count == (lake_size - 2) * (lake_size - 2))
|
||||
assert(lake_edge_count == (lake_size - 6) * 4)
|
||||
assert(lake_edge_count + lake_edge_variant_count == (lake_size - 6) * 4)
|
||||
assert(lake_edge_count > 0)
|
||||
assert(lake_edge_variant_count > 0)
|
||||
assert(lake_narrow_count == 8)
|
||||
assert(_placement_count(placements, "chunk_9999") == 0)
|
||||
assert(_placement_count(placements, "chunk_9998") == 0)
|
||||
|
|
@ -257,13 +277,14 @@ func _validate_generated_region(
|
|||
== (1 if has_secondary_elevation else 0)
|
||||
)
|
||||
assert(_placement_count(placements, "chunk_9995") == 0)
|
||||
var river_length := maxi(
|
||||
generator._river_feature_footprint_size.x,
|
||||
generator._river_feature_footprint_size.y,
|
||||
var river_coordinate_count := generator._river_feature_coordinates.size()
|
||||
var river_edge_count := (
|
||||
_placement_count(placements, "chunk_0024")
|
||||
+ _placement_count(placements, "chunk_0025")
|
||||
)
|
||||
assert(river_length in [7, 8])
|
||||
assert(_placement_count(placements, "chunk_0024") == river_length - 2)
|
||||
assert(_placement_count(placements, "chunk_0025") == river_length - 2)
|
||||
assert(river_coordinate_count >= 12)
|
||||
assert(generator._river_feature_placements.size() == river_coordinate_count)
|
||||
assert(river_edge_count == river_coordinate_count - 8)
|
||||
var river_source_coordinates := generator._river_source_coordinates(
|
||||
generator._river_feature_origin,
|
||||
generator._river_feature_footprint_size,
|
||||
|
|
@ -297,7 +318,7 @@ func _validate_generated_region(
|
|||
assert(
|
||||
not generator._coordinate_is_inside_grid(
|
||||
outlet_coordinate
|
||||
+ generator._river_feature_flow_direction
|
||||
+ generator._river_feature_outlet_direction
|
||||
)
|
||||
)
|
||||
assert(outlet_coordinates.size() == 2)
|
||||
|
|
@ -379,7 +400,7 @@ func _validate_generated_region(
|
|||
] = surface_polygon.size()
|
||||
_validate_complete_coastline(generator)
|
||||
assert(fresh_root.get_child_count() == fresh_placement_count)
|
||||
assert(river_placement_count == river_length * 2)
|
||||
assert(river_placement_count == river_coordinate_count)
|
||||
assert(
|
||||
polygon_sizes_by_coordinate.size()
|
||||
== 20 + river_placement_count
|
||||
|
|
@ -1025,19 +1046,48 @@ func _validate_decoration_transform(
|
|||
prop.global_position + Vector3.DOWN * 8.0,
|
||||
1,
|
||||
)
|
||||
var prop_body := prop.get_node_or_null(
|
||||
"TrunkCollision",
|
||||
) as CollisionObject3D
|
||||
if prop_body != null:
|
||||
query.exclude = [prop_body.get_rid()]
|
||||
var excluded_colliders: Array[RID] = []
|
||||
var decorations := region.get_node("Decorations") as Node3D
|
||||
for decoration: Node in decorations.get_children():
|
||||
var prop_body := decoration.get_node_or_null(
|
||||
"TrunkCollision",
|
||||
) as CollisionObject3D
|
||||
if prop_body != null:
|
||||
excluded_colliders.append(prop_body.get_rid())
|
||||
query.exclude = excluded_colliders
|
||||
var hit := region.get_world_3d().direct_space_state.intersect_ray(query)
|
||||
# Stacked cliff walls can overhang a neighboring cell. Match the placement
|
||||
# sampler by ignoring steep faces until the ray reaches walkable terrain.
|
||||
while (
|
||||
not hit.is_empty()
|
||||
and absf((hit.get("normal", Vector3.ZERO) as Vector3).dot(Vector3.UP))
|
||||
< 0.35
|
||||
):
|
||||
var steep_collider := hit.get("collider") as CollisionObject3D
|
||||
assert(steep_collider != null)
|
||||
excluded_colliders.append(steep_collider.get_rid())
|
||||
query.exclude = excluded_colliders
|
||||
hit = region.get_world_3d().direct_space_state.intersect_ray(query)
|
||||
assert(
|
||||
not hit.is_empty(),
|
||||
"No terrain collision below %s (%s) at %s."
|
||||
% [prop.name, definition.stable_id, prop.global_position],
|
||||
)
|
||||
var ground_position: Vector3 = hit["position"]
|
||||
assert(absf(ground_position.y - prop.global_position.y) <= 0.01)
|
||||
assert(
|
||||
absf(ground_position.y - prop.global_position.y) <= 0.01,
|
||||
"Terrain height %s does not match %s (%s) at %s."
|
||||
% [
|
||||
ground_position.y,
|
||||
prop.name,
|
||||
definition.stable_id,
|
||||
"%s in chunk %s; hit %s" % [
|
||||
prop.global_position,
|
||||
prop.get_meta(&"terrain_chunk_coordinate", Vector2i(-1, -1)),
|
||||
(hit.get("collider") as Node).get_path(),
|
||||
],
|
||||
],
|
||||
)
|
||||
|
||||
|
||||
func _validate_tree_gatherable_anchors(
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue