Restrict generated clam spots to visible sand
This commit is contained in:
parent
4dc87235ec
commit
966968e54d
2 changed files with 74 additions and 1 deletions
|
|
@ -18,7 +18,7 @@ func get_surface_triangles() -> Array[PackedVector3Array]:
|
|||
var terrain_root: Node = get_node_or_null(terrain_source)
|
||||
if terrain_root == null:
|
||||
return triangles
|
||||
for mesh_instance: MeshInstance3D in _collect_mesh_instances(terrain_root):
|
||||
for mesh_instance: MeshInstance3D in _terrain_mesh_instances(terrain_root):
|
||||
var mesh: Mesh = mesh_instance.mesh
|
||||
if mesh == null:
|
||||
continue
|
||||
|
|
@ -92,6 +92,23 @@ func _append_triangle(
|
|||
result.append(PackedVector3Array([a, b, c]))
|
||||
|
||||
|
||||
func _terrain_mesh_instances(terrain_root: Node) -> Array[MeshInstance3D]:
|
||||
# Generated terrain can contain authored base layers beneath raised visual
|
||||
# overlays. Those meshes are useful for closing terrain seams, but they are
|
||||
# not necessarily the visible surface and must not produce buried dig spots.
|
||||
# A terrain provider may therefore expose its authoritative primary meshes.
|
||||
if terrain_root.has_method(&"get_primary_terrain_meshes"):
|
||||
var provided: Variant = terrain_root.call(&"get_primary_terrain_meshes")
|
||||
var meshes: Array[MeshInstance3D] = []
|
||||
if provided is Array:
|
||||
for value: Variant in provided:
|
||||
var mesh_instance := value as MeshInstance3D
|
||||
if mesh_instance != null:
|
||||
meshes.append(mesh_instance)
|
||||
return meshes
|
||||
return _collect_mesh_instances(terrain_root)
|
||||
|
||||
|
||||
func _collect_mesh_instances(root: Node) -> Array[MeshInstance3D]:
|
||||
var meshes: Array[MeshInstance3D] = []
|
||||
if root is MeshInstance3D:
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue