From b059a2ef1d119a6553e44d7bddd7d15049e00318 Mon Sep 17 00:00:00 2001 From: Overside srl Date: Mon, 25 May 2026 23:12:57 +0200 Subject: [PATCH] put constant for generation as parameters --- core/biome_generator/biome_generator.gd | 33 ++++++++++--------- docs/museums/biome_generator/museum_map.tscn | 6 ++-- .../scene/chunk_country_corner_02.tscn | 8 ++--- 3 files changed, 23 insertions(+), 24 deletions(-) diff --git a/core/biome_generator/biome_generator.gd b/core/biome_generator/biome_generator.gd index c37bbdf..aa1e6a7 100644 --- a/core/biome_generator/biome_generator.gd +++ b/core/biome_generator/biome_generator.gd @@ -10,19 +10,6 @@ const ENTITY_SPAWN_ANY: int = 0 const ENTITY_SPAWN_HUMANOID_ONLY: int = 1 const ENTITY_SPAWN_ANIMAL_ONLY: int = 2 -const CHUNK_GENERATION_FRAME_BUDGET_USEC: int = 2000 #2 ms/frame to generate chunks -const CHUNK_CLEANUP_FRAME_BUDGET_USEC: int = 1000 #1 ms/frame per cleanup -const LAMPPOST_WIRE_FRAME_BUDGET_USEC: int = 1000 #1 ms/frame per i fili dei lampioni -#(about 4 ms o work for frame) -#Se compaiono chunk troppo lentamente davanti al treno: -#aumentare generazione a 3000 o 4000 -#Se ci sono micro-scatti: -#abbassare generazione a 1000 o 1500 -#Se i fili appaiono in ritardo: -#aumentare wire a 1500 o 2000 -#Se il cleanup causa scatti: -#abbassare cleanup a 500 - const MAX_CHUNK_UNIQUENESS: int = 5 const RIVER_SIDE_ORDER: Array[String] = ["north", "est", "south", "west"] const RIVER_DIRECTIONS: Dictionary = { @@ -38,6 +25,20 @@ const RIVER_NEIGHBOUR_OFFSETS: Dictionary = { "west": Vector2i(-1, 0), } +@export_group("Generation") +@export var chunk_generation_frame_budget_usec: int = 1500 #2 ms/frame to generate chunks +@export var chunk_cleanup_frame_budget_usec: int = 1000 #1 ms/frame per cleanup +@export var lampost_wire_frame_budget_usec: int = 1000 #1 ms/frame per i fili dei lampioni +#(about 4 ms of work for frame) +#Se compaiono chunk troppo lentamente davanti al treno: +#aumentare generazione a 3000 o 4000 +#Se ci sono micro-scatti: +#abbassare generazione a 1000 o 1500 +#Se i fili appaiono in ritardo: +#aumentare wire a 1500 o 2000 +#Se il cleanup causa scatti: +#abbassare cleanup a 500 + @export_group("Rails") @export var rail_path: Path3D #rail path @export var railway_pool: Resource @@ -483,7 +484,7 @@ func _queue_has_frame_budget(start_usec: int, budget_usec: int, processed: int) func _drain_generation_queue() -> void: var processed: int = 0 var start_usec: int = Time.get_ticks_usec() - while pending_generation_cursor < pending_generation_cells.size() and _queue_has_frame_budget(start_usec, CHUNK_GENERATION_FRAME_BUDGET_USEC, processed): + while pending_generation_cursor < pending_generation_cells.size() and _queue_has_frame_budget(start_usec, chunk_generation_frame_budget_usec, processed): var grid_pos: Vector2i = pending_generation_cells[pending_generation_cursor] pending_generation_cursor += 1 if board.has(grid_pos): @@ -501,7 +502,7 @@ func _drain_generation_queue() -> void: func _drain_cleanup_queue() -> void: var processed: int = 0 var start_usec: int = Time.get_ticks_usec() - while pending_cleanup_cursor < pending_cleanup_cells.size() and _queue_has_frame_budget(start_usec, CHUNK_CLEANUP_FRAME_BUDGET_USEC, processed): + while pending_cleanup_cursor < pending_cleanup_cells.size() and _queue_has_frame_budget(start_usec, chunk_cleanup_frame_budget_usec, processed): var grid_pos: Vector2i = pending_cleanup_cells[pending_cleanup_cursor] pending_cleanup_cursor += 1 if not board.has(grid_pos): @@ -529,7 +530,7 @@ func _queue_lamppost_wire_connection(grid_pos: Vector2i) -> void: func _drain_wire_queue() -> void: var processed: int = 0 var start_usec: int = Time.get_ticks_usec() - while pending_wire_cursor < pending_wire_cells.size() and _queue_has_frame_budget(start_usec, LAMPPOST_WIRE_FRAME_BUDGET_USEC, processed): + while pending_wire_cursor < pending_wire_cells.size() and _queue_has_frame_budget(start_usec, lampost_wire_frame_budget_usec, processed): var grid_pos: Vector2i = pending_wire_cells[pending_wire_cursor] pending_wire_cursor += 1 pending_wire_lookup.erase(grid_pos) diff --git a/docs/museums/biome_generator/museum_map.tscn b/docs/museums/biome_generator/museum_map.tscn index b6ec1c0..628f0cf 100644 --- a/docs/museums/biome_generator/museum_map.tscn +++ b/docs/museums/biome_generator/museum_map.tscn @@ -5,7 +5,6 @@ [ext_resource type="Texture2D" uid="uid://dest0qa7vaid0" path="res://core/daynight/stars_albedo.png" id="3_ncg1s"] [ext_resource type="Script" uid="uid://brcimd12tx3dm" path="res://core/daynight/edge_detection_compositor.gd" id="4_5uio4"] [ext_resource type="PackedScene" uid="uid://ujv2f1l4d2ps" path="res://core/biome_generator/biome_generator.tscn" id="5_yeh4a"] -[ext_resource type="Resource" uid="uid://nrm040srfjwo" path="res://core/biome_generator/railway_pool.tres" id="6_awm2r"] [ext_resource type="Script" uid="uid://wv6kcqkibium" path="res://core/biome_generator/biome.gd" id="6_s3jnv"] [ext_resource type="PackedScene" uid="uid://crlk31ecl480n" path="res://tgcc/chunk/countryside/scene/chunk_country_corner_03.tscn" id="7_4elh6"] [ext_resource type="PackedScene" uid="uid://b8blm6bwintf7" path="res://tgcc/chunk/countryside/scene/chunk_country_empty_01.tscn" id="7_xgfli"] @@ -145,7 +144,7 @@ data = PackedByteArray("//vQZAAOhpd2PgtGR7JsJPfgYSYSJ6387g9rgIGKF+EZgxxoAM4TYIWm [sub_resource type="Curve3D" id="Curve3D_ndco5"] closed = true -bake_interval = 150.82 +bake_interval = 50.0 _data = { "points": PackedVector3Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 20, 0, 0, 0, 0, 0, 0, 0, 0, 40, 0, 0, 0, 0, 0, 0, 0, 0, 60, 0, 0, 0, 0, 0, 0, 0, 0, 80, 0, 0, 0, 0, 0, 0, 0, 0, 100, 0, 0, 0, 0, 0, 0, 0, 0, 120, 0, 0, 0, 0, 0, 0, -4.372, 0, 140, 0, 0, 0, 0, 0, 0, -20.963, 0, 160, 0, 0, 0, 0, 0, 0, -40.62518, 0, 168.52754, 0, 0, 0, 0, 0, 0, -60, 0, 170, 0, 0, 0, 0, 0, 0, -80, 0, 170, 0, 0, 0, 0, 0, 0, -100, 0, 170, 0, 0, 0, 0, 0, 0, -120.42937, 0, 171.50279, 0, 0, 0, 0, 0, 0, -141.41747, 7.6293945e-06, 180.5982, 0, 0, 0, 0, 0, 0, -155.77005, 7.6293945e-06, 198.35184, 0, 0, 0, 0, 0, 0, -160.14105, 7.6293945e-06, 219.80951, 0, 0, 0, 0, 0, 0, -163.99007, 7.6293945e-06, 239.36005, 0, 0, 0, 0, 0, 0, -175.77509, 7.6293945e-06, 256.16028, 0, 0, 0, 0, 0, 0, -195.62283, 7.6293945e-06, 267.46912, 0, 0, 0, 0, 0, 0, -219.9999, 7.6293945e-06, 270.11758, 0, 0, 0, 0, 0, 0, -240, 0, 270.118, 0, 0, 0, 0, 0, 0, -260, 0, 270.118, 0, 0, 0, 0, 0, 0, -275.19666, 7.6293945e-06, 270.55228, 0, 0, 0, 0, 0, 0, -294.2925, 7.6293945e-06, 276.05307, 0, 0, 0, 0, 0, 0, -307.19006, 7.6293945e-06, 286.9095, 0, 0, 0, 0, 0, 0, -317.32443, 7.6293945e-06, 303.14682, 0, 0, 0, 0, 0, 0, -320, 0, 320, 0, 0, 0, 0, 0, 0, -320, 0, 340, 0, 0, 0, 0, 0, 0, -320, 0, 360, 0, 0, 0, 0, 0, 0, -320, 0, 380, 0, 0, 0, 0, 0, 0, -316.78876, 7.6293945e-06, 396.91193, 0, 0, 0, 0, 0, 0, -307.68207, 7.6293945e-06, 412.70596, 0, 0, 0, 0, 0, 0, -291.08273, 7.6293945e-06, 424.7491, 0, 0, 0, 0, 0, 0, -270, 0, 429.994, 0, 0, 0, 0, 0, 0, -250, 0, 429.994, 0, 0, 0, 0, 0, 0, -229.90146, 7.6293945e-06, 433.90823, 0, 0, 0, 0, 0, 0, -217.15442, 7.6293945e-06, 442.98242, 0, 0, 0, 0, 0, 0, -204.60803, 7.6293945e-06, 459.93704, 0, 0, 0, 0, 0, 0, -200, 0, 480, 0, 0, 0, 0, 0, 0, -200, 0, 500, 0, 0, 0, 0, 0, 0, -195.5338, 7.6293945e-06, 520.0368, 0, 0, 0, 0, 0, 0, -184.9173, 7.6293945e-06, 535.07776, 0, 0, 0, 0, 0, 0, -170.36423, 7.6293945e-06, 545.0799, 0, 0, 0, 0, 0, 0, -150.56184, 0, 549.8127, 0, 0, 0, 0, 0, 0, -130, 0, 550, 0, 0, 0, 0, 0, 0, -110, 0, 550, 0, 0, 0, 0, 0, 0, -90, 0, 550, 0, 0, 0, 0, 0, 0, -70, 0, 550, 0, 0, 0, 0, 0, 0, -50, 0, 550, 0, 0, 0, 0, 0, 0, -29.862535, 7.6293945e-06, 545.3371, 0, 0, 0, 0, 0, 0, -13.215244, 7.6293945e-06, 533.0626, 0, 0, 0, 0, 0, 0, -4.098665, 7.6293945e-06, 519.6814, 0, 0, 0, 0, 0, 0, -0.048213482, 7.6293945e-06, 500.107, 0, 0, 0, 0, 0, 0, 3.7920675, 7.6293945e-06, 480.64902, 0, 0, 0, 0, 0, 0, 13.513225, 7.6293945e-06, 465.9133, 0, 0, 0, 0, 0, 0, 29.76715, 7.6293945e-06, 454.41486, 0, 0, 0, 0, 0, 0, 49.711926, 7.6293945e-06, 450.12488, 0, 0, 0, 0, 0, 0, 70, 0, 450, 0, 0, 0, 0, 0, 0, 90, 0, 450, 0, 0, 0, 0, 0, 0, 110.055405, 7.6293945e-06, 445.42627, 0, 0, 0, 0, 0, 0, 126.975784, 7.6293945e-06, 432.8683, 0, 0, 0, 0, 0, 0, 136.95703, 7.6293945e-06, 417.5506, 0, 0, 0, 0, 0, 0, 140, 0, 400, 0, 0, 0, 0, 0, 0, 140, 0, 380, 0, 0, 0, 0, 0, 0, 140, 0, 360, 0, 0, 0, 0, 0, 0, 140, 0, 340, 0, 0, 0, 0, 0, 0, 140, 0, 320, 0, 0, 0, 0, 0, 0, 140, 0, 300, 0, 0, 0, 0, 0, 0, 140, 0, 280, 0, 0, 0, 0, 0, 0, 140, 0, 260, 0, 0, 0, 0, 0, 0, 140, 0, 240, 0, 0, 0, 0, 0, 0, 140, 0, 220, 0, 0, 0, 0, 0, 0, 140, 0, 200, 0, 0, 0, 0, 0, 0, 140, 0, 180, 0, 0, 0, 0, 0, 0, 140, 0, 160, 0, 0, 0, 0, 0, 0, 140, 0, 140, 0, 0, 0, 0, 0, 0, 140, 0, 120, 0, 0, 0, 0, 0, 0, 140, 0, 100, 0, 0, 0, 0, 0, 0, 140, 0, 80, 0, 0, 0, 0, 0, 0, 140, 0, 60, 0, 0, 0, 0, 0, 0, 140, 0, 40, 0, 0, 0, 0, 0, 0, 140, 0, 20, 0, 0, 0, 0, 0, 0, 140, 0, 0, 0, 0, 0, 0, 0, 0, 136.2151, 7.6293945e-06, -18.930761, 0, 0, 0, 0, 0, 0, 124.47424, 7.6293945e-06, -35.771675, 0, 0, 0, 0, 0, 0, 109.556854, 7.6293945e-06, -45.911987, 0, 0, 0, 0, 0, 0, 90, 0, -50, 0, 0, 0, 0, 0, 0, 70, 0, -50, 0, 0, 0, 0, 0, 0, 50, 0, -50, 0, 0, 0, 0, 0, 0, 30.626865, 7.6293945e-06, -46.35706, 0, 0, 0, 0, 0, 0, 14.519331, 7.6293945e-06, -35.468895, 0, 0, 0, 0, 0, 0, 3.52941, 7.6293945e-06, -19.590664), "tilts": PackedFloat32Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0) @@ -161,10 +160,9 @@ compositor = SubResource("Compositor_mb5yv") [node name="biome_generator" parent="." unique_id=1861369341 node_paths=PackedStringArray("rail_path") instance=ExtResource("5_yeh4a")] rail_path = NodePath("../rail") -railway_pool = ExtResource("6_awm2r") biome_list = Array[ExtResource("6_s3jnv")]([SubResource("Resource_3qrd0")]) entity_pool = ExtResource("35_hmtvu") -eye_line = 5 +eye_line = 4 [node name="Terrain" type="MeshInstance3D" parent="." unique_id=219178561] visible = false diff --git a/tgcc/chunk/countryside/scene/chunk_country_corner_02.tscn b/tgcc/chunk/countryside/scene/chunk_country_corner_02.tscn index 755ab3c..bd2771a 100644 --- a/tgcc/chunk/countryside/scene/chunk_country_corner_02.tscn +++ b/tgcc/chunk/countryside/scene/chunk_country_corner_02.tscn @@ -57,16 +57,16 @@ script = ExtResource("2_yfmnf") south = true west = true -[node name="Argini" parent="." index="0" unique_id=487109030] +[node name="Argini" parent="." index="0" unique_id=357182272] surface_material_override/0 = ExtResource("2_02qm6") -[node name="Sentieri" parent="." index="1" unique_id=320924856 groups=["weather_node"]] +[node name="Sentieri" parent="." index="1" unique_id=1704203551 groups=["weather_node"]] surface_material_override/0 = ExtResource("3_yfmnf") -[node name="Terreno" parent="." index="2" unique_id=1980435075] +[node name="Terreno" parent="." index="2" unique_id=1478648388] surface_material_override/0 = ExtResource("2_02qm6") -[node name="Water" parent="." index="3" unique_id=424969495] +[node name="Water" parent="." index="3" unique_id=415433510] surface_material_override/0 = ExtResource("4_x1bjv") [node name="grass" type="Node3D" parent="." index="4" unique_id=543668848 groups=["weather_vegetables_node", "wind_node"]]