blur camera

This commit is contained in:
Matteo Sonaglioni
2026-03-13 01:36:48 +01:00
parent a905a410aa
commit 83dc8e997c
3 changed files with 60 additions and 20 deletions

View File

@@ -85,12 +85,10 @@ sky = SubResource("Sky_dhgqn")
ambient_light_source = 2 ambient_light_source = 2
tonemap_mode = 2 tonemap_mode = 2
tonemap_exposure = 1.2 tonemap_exposure = 1.2
ssr_enabled = true
ssil_enabled = true ssil_enabled = true
ssil_radius = 8.61
glow_enabled = true glow_enabled = true
glow_normalized = true glow_normalized = true
glow_bloom = 0.4 glow_bloom = 0.5
fog_enabled = true fog_enabled = true
fog_mode = 1 fog_mode = 1
fog_density = 0.25 fog_density = 0.25
@@ -232,9 +230,16 @@ sub_emitter_amount_at_collision = 1
material = ExtResource("3_4wepm") material = ExtResource("3_4wepm")
size = Vector2(0.05, 1) size = Vector2(0.05, 1)
[sub_resource type="CameraAttributesPractical" id="CameraAttributesPractical_gwrkm"]
dof_blur_far_enabled = true
dof_blur_far_distance = 410.0
dof_blur_far_transition = 150.0
dof_blur_near_distance = 0.06
dof_blur_amount = 0.5
[sub_resource type="Curve3D" id="Curve3D_bedag"] [sub_resource type="Curve3D" id="Curve3D_bedag"]
closed = true closed = true
bake_interval = 50.0 bake_interval = 150.82
_data = { _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), "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) "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)
@@ -695,9 +700,10 @@ environment = SubResource("Environment_igfsh")
compositor = SubResource("Compositor_17jdd") compositor = SubResource("Compositor_17jdd")
[node name="SubViewportContainer" type="SubViewportContainer" parent="." unique_id=1680514424] [node name="SubViewportContainer" type="SubViewportContainer" parent="." unique_id=1680514424]
texture_filter = 1 texture_filter = 4
offset_right = 1920.0 offset_right = 1920.0
offset_bottom = 1080.0 offset_bottom = 1080.0
stretch = true
mouse_target = true mouse_target = true
[node name="SubViewport" type="SubViewport" parent="SubViewportContainer" unique_id=1099909885] [node name="SubViewport" type="SubViewport" parent="SubViewportContainer" unique_id=1099909885]
@@ -805,6 +811,7 @@ camera_alta = NodePath("../CameraAlta")
[node name="CameraIso" type="Camera3D" parent="SubViewportContainer/SubViewport/World/Camere/CameraPivot" unique_id=375499667] [node name="CameraIso" type="Camera3D" parent="SubViewportContainer/SubViewport/World/Camere/CameraPivot" unique_id=375499667]
transform = Transform3D(0.5778576, -0.57709634, 0.57709634, 0, 0.7071067, 0.7071067, -0.8161376, -0.408607, 0.408607, 231.45, 295, 173.79) transform = Transform3D(0.5778576, -0.57709634, 0.57709634, 0, 0.7071067, 0.7071067, -0.8161376, -0.408607, 0.408607, 231.45, 295, 173.79)
attributes = SubResource("CameraAttributesPractical_gwrkm")
projection = 1 projection = 1
size = 35.0 size = 35.0
near = 0.001 near = 0.001

View File

@@ -36,12 +36,10 @@ func _ready() -> void:
# Creiamo l'interfaccia a schermo! # Creiamo l'interfaccia a schermo!
_crea_ui_gps() _crea_ui_gps()
print("✅ Generatore a Distretti Dinamici Pronto.") print("✅ Generatore a Distretti Dinamici Pronto (Versione Ottimizzata).")
print("Premere il tasto 'B' per abilitare/disabilitare il terzo bioma.") print("Premere il tasto 'B' per abilitare/disabilitare il terzo bioma.")
# --- NUOVA FUNZIONE: CREA LE SCRITTE A SCHERMO --- # --- CREA LE SCRITTE A SCHERMO ---
# --- NUOVA FUNZIONE: CREA LE SCRITTE A SCHERMO (CORRETTA) ---
# --- NUOVA FUNZIONE: CREA LE SCRITTE A SCHERMO ---
func _crea_ui_gps() -> void: func _crea_ui_gps() -> void:
var canvas = CanvasLayer.new() var canvas = CanvasLayer.new()
canvas.layer = 10 canvas.layer = 10
@@ -59,18 +57,18 @@ func _crea_ui_gps() -> void:
# --- SCRITTA BIOMA ATTUALE (Titolo) --- # --- SCRITTA BIOMA ATTUALE (Titolo) ---
lbl_bioma = Label.new() lbl_bioma = Label.new()
lbl_bioma.add_theme_font_size_override("font_size", 10) # <--- QUI CAMBI LA GRANDEZZA (Prima era 26) lbl_bioma.add_theme_font_size_override("font_size", 10)
lbl_bioma.add_theme_color_override("font_color", Color(1, 0.9, 0.4)) lbl_bioma.add_theme_color_override("font_color", Color(1, 0.9, 0.4))
lbl_bioma.add_theme_color_override("font_outline_color", Color.BLACK) lbl_bioma.add_theme_color_override("font_outline_color", Color.BLACK)
lbl_bioma.add_theme_constant_override("outline_size", 3) # Ho ridotto anche il bordo nero per non impastare il testo piccolo lbl_bioma.add_theme_constant_override("outline_size", 3)
lbl_bioma.text = "📍 Avvio GPS..." lbl_bioma.text = "📍 Avvio GPS..."
vbox.add_child(lbl_bioma) vbox.add_child(lbl_bioma)
# --- SCRITTA METRI MANCANTI (Sottotitolo) --- # --- SCRITTA METRI MANCANTI (Sottotitolo) ---
lbl_distanza = Label.new() lbl_distanza = Label.new()
lbl_distanza.add_theme_font_size_override("font_size", 8) # <--- QUI CAMBI LA GRANDEZZA (Prima era 20) lbl_distanza.add_theme_font_size_override("font_size", 8)
lbl_distanza.add_theme_color_override("font_outline_color", Color.BLACK) lbl_distanza.add_theme_color_override("font_outline_color", Color.BLACK)
lbl_distanza.add_theme_constant_override("outline_size", 3) # Bordo ridotto proporzionalmente lbl_distanza.add_theme_constant_override("outline_size", 3)
lbl_distanza.text = "Calcolo tragitto..." lbl_distanza.text = "Calcolo tragitto..."
vbox.add_child(lbl_distanza) vbox.add_child(lbl_distanza)
@@ -93,9 +91,14 @@ func _physics_process(_delta: float) -> void:
if pos_attuale != ultima_pos_griglia_treno: if pos_attuale != ultima_pos_griglia_treno:
ultima_pos_griglia_treno = pos_attuale ultima_pos_griglia_treno = pos_attuale
# 1. Genera i nuovi chunk davanti al treno
_genera_attorno_al_treno(pos_attuale) _genera_attorno_al_treno(pos_attuale)
# Il treno ha fatto 20 metri (ha cambiato cella), quindi aggiorniamo il GPS a schermo! # 2. Pulisce i chunk vecchi dietro al treno (OTTIMIZZAZIONE)
_pulisci_chunk_lontani(pos_attuale)
# 3. Aggiorna il GPS a schermo
_radar_bioma_treno() _radar_bioma_treno()
func _genera_attorno_al_treno(centro: Vector2i) -> void: func _genera_attorno_al_treno(centro: Vector2i) -> void:
@@ -185,12 +188,16 @@ func _piazza_bioma_compatibile(pos_griglia: Vector2i) -> void:
add_child(nuovo_chunk) add_child(nuovo_chunk)
nuovo_chunk.position = Vector3(pos_griglia.x * dimensione_chunk, 0, pos_griglia.y * dimensione_chunk) nuovo_chunk.position = Vector3(pos_griglia.x * dimensione_chunk, 0, pos_griglia.y * dimensione_chunk)
nuovo_chunk.rotation.y = scelto.rotazione * (-PI / 2.0) nuovo_chunk.rotation.y = scelto.rotazione * (-PI / 2.0)
scacchiera[pos_griglia] = {"tipo": "bioma", "uscite": scelto.uscite}
# MODIFICA: Salviamo il riferimento al nodo per poterlo eliminare in futuro
scacchiera[pos_griglia] = {"tipo": "bioma", "uscite": scelto.uscite, "nodo": nuovo_chunk}
else: else:
var backup = catalogo_zona[0].instantiate() var backup = catalogo_zona[0].instantiate()
add_child(backup) add_child(backup)
backup.position = Vector3(pos_griglia.x * dimensione_chunk, 0, pos_griglia.y * dimensione_chunk) backup.position = Vector3(pos_griglia.x * dimensione_chunk, 0, pos_griglia.y * dimensione_chunk)
scacchiera[pos_griglia] = {"tipo": "bioma", "uscite": {"nord":false, "est":false, "sud":false, "ovest":false}}
# MODIFICA: Salviamo il riferimento al nodo
scacchiera[pos_griglia] = {"tipo": "bioma", "uscite": {"nord":false, "est":false, "sud":false, "ovest":false}, "nodo": backup}
func _richiede_connessione(pos_vicino: Vector2i, lato_richiesto: String) -> int: func _richiede_connessione(pos_vicino: Vector2i, lato_richiesto: String) -> int:
if not scacchiera.has(pos_vicino): _registra_cella_con_laser(pos_vicino) if not scacchiera.has(pos_vicino): _registra_cella_con_laser(pos_vicino)
@@ -208,16 +215,13 @@ func _get_nome_bioma(valore: float) -> String:
elif valore < 0.4: return "Foresta-Altro" elif valore < 0.4: return "Foresta-Altro"
else: return "Altro (Deserto/Neve)" else: return "Altro (Deserto/Neve)"
# --- AGGIORNAMENTO GPS A SCHERMO ---
# --- AGGIORNAMENTO GPS A SCHERMO --- # --- AGGIORNAMENTO GPS A SCHERMO ---
func _radar_bioma_treno() -> void: func _radar_bioma_treno() -> void:
# SICUREZZA: Controlliamo che il treno esista davvero prima di leggerne la posizione!
if path_treno == null or path_treno.curve == null or path_treno.treno_istanziato == null: if path_treno == null or path_treno.curve == null or path_treno.treno_istanziato == null:
return return
var pos_treno = path_treno.treno_istanziato.global_position var pos_treno = path_treno.treno_istanziato.global_position
var grid_x = roundi(pos_treno.x / dimensione_chunk) var grid_x = roundi(pos_treno.x / dimensione_chunk)
# ... il resto del codice rimane identico ...
var grid_z = roundi(pos_treno.z / dimensione_chunk) var grid_z = roundi(pos_treno.z / dimensione_chunk)
var valore_attuale = generatore_rumore.get_noise_2d(grid_x, grid_z) var valore_attuale = generatore_rumore.get_noise_2d(grid_x, grid_z)
var bioma_attuale = _get_nome_bioma(valore_attuale) var bioma_attuale = _get_nome_bioma(valore_attuale)
@@ -242,10 +246,37 @@ func _radar_bioma_treno() -> void:
prossimo_bioma = bioma_futuro prossimo_bioma = bioma_futuro
break break
# MODIFICA: Invece di usare print, aggiorniamo l'interfaccia a schermo!
if lbl_bioma and lbl_distanza: if lbl_bioma and lbl_distanza:
lbl_bioma.text = bioma_attuale lbl_bioma.text = bioma_attuale
if prossimo_bioma != "": if prossimo_bioma != "":
lbl_distanza.text = str(distanza_cambio) + "m ➔ " + prossimo_bioma lbl_distanza.text = str(distanza_cambio) + "m ➔ " + prossimo_bioma
else: else:
lbl_distanza.text = "Nessun cambio nei prossimi 600m" lbl_distanza.text = "Nessun cambio nei prossimi 600m"
# --- NUOVA FUNZIONE: SPAZZINO DEI CHUNK LONTANI ---
func _pulisci_chunk_lontani(centro_attuale: Vector2i) -> void:
var celle_da_rimuovere = []
var margine_sicurezza = 2 # Eliminiamo solo i chunk fuori dal raggio visivo + 2
for pos_griglia in scacchiera.keys():
var cella = scacchiera[pos_griglia]
if cella["tipo"] == "ostacolo":
continue
var dist_x = abs(pos_griglia.x - centro_attuale.x)
var dist_z = abs(pos_griglia.y - centro_attuale.y)
# Se il chunk è troppo lontano dalla telecamera...
if dist_x > raggio_visivo + margine_sicurezza or dist_z > raggio_visivo + margine_sicurezza:
# 1. Distruggiamo il modello 3D per liberare memoria video
if cella.has("nodo") and is_instance_valid(cella["nodo"]):
cella["nodo"].queue_free()
# 2. Ci segniamo questa posizione per rimuoverla dalla logica
celle_da_rimuovere.append(pos_griglia)
# 3. Puliamo la scacchiera (liberando memoria RAM)
for pos in celle_da_rimuovere:
scacchiera.erase(pos)

View File

@@ -29,6 +29,8 @@ window/size/viewport_height=720
[rendering] [rendering]
textures/canvas_textures/default_texture_filter=2 textures/canvas_textures/default_texture_filter=2
lights_and_shadows/directional_shadow/soft_shadow_filter_quality=1
anti_aliasing/quality/use_taa=true
[shader_globals] [shader_globals]