feat(tools): polyline Canyon and Escarpment primitives with outline noise
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
This commit is contained in:
1 parent
520a62863b
commit
aae9bcd301
2 files changed
+156
-1
No files matched your search
@@ -8,7 +8,7 @@ const SiteTerrainData = preload("res://game/domain/sites/site_terrain_data.gd")
|
||||
|
||||
const ZONE1_TERRAIN_PATH := "res://content/sites/zone1_vigilant_terrain.res"
|
||||
|
||||
const TEST_COUNT := 16
|
||||
const TEST_COUNT := 26
|
||||
|
||||
var _failures: Array[String] = []
|
||||
|
||||
@@ -18,6 +18,8 @@ func _init() -> void:
|
||||
_test_materials_and_determinism()
|
||||
_test_modifiers_and_primitive_materials()
|
||||
_test_zone1_artefact_is_stable()
|
||||
_test_canyon()
|
||||
_test_escarpment()
|
||||
|
||||
if _failures.is_empty():
|
||||
print("Site baker unit tests: %d passed, 0 failed." % TEST_COUNT)
|
||||
@@ -113,6 +115,35 @@ func _test_modifiers_and_primitive_materials() -> void:
|
||||
_expect(flat_data.materials[flat_data.index_of(0, 0)] == SonarMaterial.Value.SAND, "primitive material is local")
|
||||
|
||||
|
||||
func _test_canyon() -> void:
|
||||
var canyon := SiteTerrainBaker.Canyon.new(
|
||||
PackedVector2Array([Vector2(-20.0, 0.0), Vector2(0.0, 0.0), Vector2(0.0, 20.0)]),
|
||||
4.0, 10.0, 1.0, 0, 0.0
|
||||
)
|
||||
_expect(is_equal_approx(canyon.elevation_delta(-10.0, 0.0), -10.0), "canyon floor sits at depth on the first leg")
|
||||
_expect(is_equal_approx(canyon.elevation_delta(1.5, 10.0), -10.0), "canyon floor is flat across its width on the second leg")
|
||||
_expect(is_equal_approx(canyon.elevation_delta(-10.0, 6.0), 0.0), "canyon stops past half width plus softness")
|
||||
_expect(is_equal_approx(canyon.elevation_delta(15.0, -15.0), 0.0), "canyon is zero far from the path")
|
||||
_expect(is_equal_approx(canyon.elevation_delta(0.0, 20.0), 0.0), "canyon closes at its last vertex")
|
||||
_expect(canyon.elevation_delta(-10.0, 4.0) < -4.0 and canyon.elevation_delta(-10.0, 4.0) > -6.0, "canyon wall is half way down at half width")
|
||||
var rough := SiteTerrainBaker.Canyon.new(
|
||||
PackedVector2Array([Vector2(-200.0, 0.0), Vector2(200.0, 0.0)]), 8.0, 10.0, 2.0, 7, 3.0
|
||||
)
|
||||
var wall_values: Dictionary = {}
|
||||
for x in range(-100, 101, 10):
|
||||
wall_values[snappedf(rough.elevation_delta(float(x), 8.0), 0.01)] = true
|
||||
_expect(wall_values.size() > 3, "outline noise makes the canyon wall irregular along the path")
|
||||
|
||||
|
||||
func _test_escarpment() -> void:
|
||||
var cliff := SiteTerrainBaker.Escarpment.new(
|
||||
PackedVector2Array([Vector2(-50.0, 0.0), Vector2(50.0, 0.0)]), 10.0, 2.0, 0.5, 0, 0.0
|
||||
)
|
||||
_expect(is_equal_approx(cliff.elevation_delta(0.0, -10.0), 0.0), "escarpment leaves the left (north) side alone")
|
||||
_expect(is_equal_approx(cliff.elevation_delta(0.0, 2.0), -10.0), "escarpment drops by drop_m on the right (south) side")
|
||||
_expect(is_equal_approx(cliff.elevation_delta(0.0, 12.0), -15.0), "escarpment keeps falling at slope_beyond")
|
||||
|
||||
|
||||
func _test_zone1_artefact_is_stable() -> void:
|
||||
var versioned := load(ZONE1_TERRAIN_PATH) as SiteTerrainData
|
||||
_expect(versioned != null, "versioned zone 1 terrain loads")
|
||||
|
||||
Reference in new issue
Block a user