feat: Fix building sizes to street width, fix all for pavement

This commit is contained in:
Dendy 2026-03-06 09:53:09 +01:00
parent 125cb3fdb0
commit 6b44466f6d
2 changed files with 59 additions and 29 deletions

View File

@ -4,6 +4,7 @@ extends Node3D
var exits: Array = [false, false, false, false] var exits: Array = [false, false, false, false]
const STREET_WIDTH: float = 40 const STREET_WIDTH: float = 40
const ASPHALT_WIDTH: float = 20
@onready var exit_area = $BuildingAreas/B_area_E/Collision @onready var exit_area = $BuildingAreas/B_area_E/Collision
@onready var building_area = $BuildingAreas/B_area/Collision @onready var building_area = $BuildingAreas/B_area/Collision
var building_scn = preload("res://building.tscn") var building_scn = preload("res://building.tscn")
@ -14,7 +15,6 @@ func _ready() -> void:
var building_side = (Global.chunk_size - STREET_WIDTH) / 2 var building_side = (Global.chunk_size - STREET_WIDTH) / 2
var building_center = (building_side + STREET_WIDTH) / 2 var building_center = (building_side + STREET_WIDTH) / 2
building_area.shape.size.z = building_side building_area.shape.size.z = building_side
building_area.shape.size.x = building_side building_area.shape.size.x = building_side
building_area.position.x = building_center building_area.position.x = building_center
@ -22,8 +22,30 @@ func _ready() -> void:
exit_area.shape.size.z = STREET_WIDTH exit_area.shape.size.z = STREET_WIDTH
exit_area.shape.size.x = building_side exit_area.shape.size.x = building_side
var pavement_side = (Global.chunk_size - ASPHALT_WIDTH) / 2
var pavement_center = (pavement_side + ASPHALT_WIDTH) / 2
$BuildingAreas/B_area/Pavement.mesh.size.x = pavement_side
$BuildingAreas/B_area/Pavement.mesh.size.z = pavement_side
$BuildingAreas/B_area/Pavement.position.x = pavement_center
$BuildingAreas/B_area/Pavement.position.z = pavement_center
$BuildingAreas/B_area_E/Pavement.mesh.size.z = Global.chunk_size
$BuildingAreas/B_area_E/Pavement.mesh.size.x = pavement_side
var z_correction_factor = STREET_WIDTH / 40
var x_correction_factor = building_side / 55
for st_body in $BuildingAreas.get_children(): for st_body in $BuildingAreas.get_children():
st_body.get_node("Collision").position.x = building_center st_body.get_node("Collision").position.x = building_center
if st_body.name != "B_area":
st_body.get_node("Building").scale.z = 0.8 * z_correction_factor
st_body.get_node("Building").scale.x = 1.1 * x_correction_factor
st_body.get_node("Building").position.x = building_center
st_body.get_node("Pavement").position.x = pavement_center
else:
st_body.get_node("Building").scale.z = 1.1 * x_correction_factor
st_body.get_node("Building").scale.x = 1.1 * x_correction_factor
st_body.get_node("Building").position.x = building_center
st_body.get_node("Building").position.z = building_center
for degree in range(1, 4): for degree in range(1, 4):
var new_area = $BuildingAreas/B_area.duplicate() var new_area = $BuildingAreas/B_area.duplicate()
@ -35,6 +57,10 @@ func update() -> void:
$BuildingAreas/B_area_S/Building.visible = true $BuildingAreas/B_area_S/Building.visible = true
$BuildingAreas/B_area_E/Building.visible = true $BuildingAreas/B_area_E/Building.visible = true
$BuildingAreas/B_area_W/Building.visible = true $BuildingAreas/B_area_W/Building.visible = true
$BuildingAreas/B_area_N/Pavement.visible = true
$BuildingAreas/B_area_S/Pavement.visible = true
$BuildingAreas/B_area_E/Pavement.visible = true
$BuildingAreas/B_area_W/Pavement.visible = true
var i = 0 var i = 0
for exit in exits: for exit in exits:
@ -45,14 +71,18 @@ func update() -> void:
if i == 0: #n if i == 0: #n
$BuildingAreas/B_area_N/Collision.disabled = true $BuildingAreas/B_area_N/Collision.disabled = true
$BuildingAreas/B_area_N/Building.visible = false $BuildingAreas/B_area_N/Building.visible = false
$BuildingAreas/B_area_N/Pavement.visible = false
if i == 1: #s if i == 1: #s
$BuildingAreas/B_area_S/Collision.disabled = true $BuildingAreas/B_area_S/Collision.disabled = true
$BuildingAreas/B_area_S/Building.visible = false $BuildingAreas/B_area_S/Building.visible = false
$BuildingAreas/B_area_S/Pavement.visible = false
if i == 2: #w if i == 2: #w
$BuildingAreas/B_area_W/Collision.disabled = true $BuildingAreas/B_area_W/Collision.disabled = true
$BuildingAreas/B_area_W/Building.visible = false $BuildingAreas/B_area_W/Building.visible = false
$BuildingAreas/B_area_W/Pavement.visible = false
if i == 3: #e if i == 3: #e
$BuildingAreas/B_area_E/Collision.disabled = true $BuildingAreas/B_area_E/Collision.disabled = true
$BuildingAreas/B_area_E/Building.visible = false $BuildingAreas/B_area_E/Building.visible = false
$BuildingAreas/B_area_E/Pavement.visible = false
i += 1 i += 1

View File

@ -36,7 +36,7 @@ size = Vector3(55, 50, 55)
[sub_resource type="BoxMesh" id="BoxMesh_381vs"] [sub_resource type="BoxMesh" id="BoxMesh_381vs"]
lightmap_size_hint = Vector2i(479, 391) lightmap_size_hint = Vector2i(479, 391)
material = ExtResource("3_a0kup") material = ExtResource("3_a0kup")
size = Vector3(65, 1, 65) size = Vector3(55, 1, 55)
[sub_resource type="BoxShape3D" id="BoxShape3D_a0kup"] [sub_resource type="BoxShape3D" id="BoxShape3D_a0kup"]
size = Vector3(55, 50, 40) size = Vector3(55, 50, 40)
@ -44,7 +44,7 @@ size = Vector3(55, 50, 40)
[sub_resource type="BoxMesh" id="BoxMesh_7yqgf"] [sub_resource type="BoxMesh" id="BoxMesh_7yqgf"]
lightmap_size_hint = Vector2i(479, 391) lightmap_size_hint = Vector2i(479, 391)
material = ExtResource("4_7yqgf") material = ExtResource("4_7yqgf")
size = Vector3(65, 1, 65) size = Vector3(55, 1, 150)
[node name="Chunk" type="Node3D" unique_id=1195945545] [node name="Chunk" type="Node3D" unique_id=1195945545]
script = ExtResource("1_kdh3y") script = ExtResource("1_kdh3y")
@ -87,26 +87,26 @@ transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 47.5, 0, 47.5)
shape = SubResource("BoxShape3D_kdh3y") shape = SubResource("BoxShape3D_kdh3y")
debug_color = Color(0.7365185, 0.46945518, 0, 0.41960785) debug_color = Color(0.7365185, 0.46945518, 0, 0.41960785)
[node name="Building" parent="BuildingAreas/B_area" unique_id=228050854 instance=ExtResource("2_eat54")] [node name="Pavement" type="MeshInstance3D" parent="BuildingAreas/B_area" unique_id=1041049709]
transform = Transform3D(1.0948861, 0, 0, 0, 1.0948861, 0, 0, 0, 1.0948861, 47.70289, 2.3668175, 47.375614) transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 47.5, 0.2, 47.5)
[node name="MeshInstance3D" type="MeshInstance3D" parent="BuildingAreas/B_area/Building" unique_id=1041049709]
transform = Transform3D(0.9133367, 0, 0, 0, 0.9133367, 0, 0, 0, 0.9133367, -4.9015274, -2.236999, -4.4171753)
mesh = SubResource("BoxMesh_381vs") mesh = SubResource("BoxMesh_381vs")
[node name="Building" parent="BuildingAreas/B_area" unique_id=228050854 instance=ExtResource("2_eat54")]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 47.70289, 2.3668175, 47.375614)
[node name="B_area_E" type="StaticBody3D" parent="BuildingAreas" unique_id=164651542] [node name="B_area_E" type="StaticBody3D" parent="BuildingAreas" unique_id=164651542]
[node name="Collision" type="CollisionShape3D" parent="BuildingAreas/B_area_E" unique_id=2080946797] [node name="Collision" type="CollisionShape3D" parent="BuildingAreas/B_area_E" unique_id=2080946797]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 47.5, 0, 0) transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 47.5, 0, 0)
shape = SubResource("BoxShape3D_a0kup") shape = SubResource("BoxShape3D_a0kup")
[node name="Building" parent="BuildingAreas/B_area_E" unique_id=496327803 instance=ExtResource("2_eat54")] [node name="Pavement" type="MeshInstance3D" parent="BuildingAreas/B_area_E" unique_id=2097051923]
transform = Transform3D(1.1296118, 0, 0, 0, 1.0989345, 0, 0, 0, 0.8093087, 47.032215, 2.198969, 0) transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 47.5, 0.21, 0)
[node name="MeshInstance3D" type="MeshInstance3D" parent="BuildingAreas/B_area_E/Building" unique_id=2097051923]
transform = Transform3D(0.7908016, 0, 0, 0, 0.9999995, 0, 0, 0, 2.8399127, -7.5103607, -2.0044072, 0)
mesh = SubResource("BoxMesh_7yqgf") mesh = SubResource("BoxMesh_7yqgf")
[node name="Building" parent="BuildingAreas/B_area_E" unique_id=496327803 instance=ExtResource("2_eat54")]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 47.032215, 2.198969, 0)
[node name="B_area_W" type="StaticBody3D" parent="BuildingAreas" unique_id=1412614477] [node name="B_area_W" type="StaticBody3D" parent="BuildingAreas" unique_id=1412614477]
transform = Transform3D(-1, 0, 8.742278e-08, 0, 1, 0, -8.742278e-08, 0, -1, 0, 0, 0) transform = Transform3D(-1, 0, 8.742278e-08, 0, 1, 0, -8.742278e-08, 0, -1, 0, 0, 0)
@ -114,13 +114,13 @@ transform = Transform3D(-1, 0, 8.742278e-08, 0, 1, 0, -8.742278e-08, 0, -1, 0, 0
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 47.5, 0, 0) transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 47.5, 0, 0)
shape = SubResource("BoxShape3D_a0kup") shape = SubResource("BoxShape3D_a0kup")
[node name="Building" parent="BuildingAreas/B_area_W" unique_id=1691268780 instance=ExtResource("2_eat54")] [node name="Pavement" type="MeshInstance3D" parent="BuildingAreas/B_area_W" unique_id=1625091819]
transform = Transform3D(1.1296118, 0, 0, 0, 1.0989345, 0, 0, 0, 0.8093087, 47.032215, 2.198969, 0) transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 39.596638, 0.19459271, 2.2737368e-13)
[node name="MeshInstance3D" type="MeshInstance3D" parent="BuildingAreas/B_area_W/Building" unique_id=1625091819]
transform = Transform3D(0.7908016, 0, 0, 0, 0.9999995, 0, 0, 0, 2.8399127, -7.5103607, -2.0044072, 0)
mesh = SubResource("BoxMesh_7yqgf") mesh = SubResource("BoxMesh_7yqgf")
[node name="Building" parent="BuildingAreas/B_area_W" unique_id=1691268780 instance=ExtResource("2_eat54")]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 47.107, 2.199, 0)
[node name="B_area_S" type="StaticBody3D" parent="BuildingAreas" unique_id=1192841263] [node name="B_area_S" type="StaticBody3D" parent="BuildingAreas" unique_id=1192841263]
transform = Transform3D(-4.371139e-08, 0, -1, 0, 1, 0, 1, 0, -4.371139e-08, 0, 0, 0) transform = Transform3D(-4.371139e-08, 0, -1, 0, 1, 0, 1, 0, -4.371139e-08, 0, 0, 0)
@ -128,13 +128,13 @@ transform = Transform3D(-4.371139e-08, 0, -1, 0, 1, 0, 1, 0, -4.371139e-08, 0, 0
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 47.5, 0, 0) transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 47.5, 0, 0)
shape = SubResource("BoxShape3D_a0kup") shape = SubResource("BoxShape3D_a0kup")
[node name="Building" parent="BuildingAreas/B_area_S" unique_id=819634987 instance=ExtResource("2_eat54")] [node name="Pavement" type="MeshInstance3D" parent="BuildingAreas/B_area_S" unique_id=1325249889]
transform = Transform3D(1.1296118, 0, 0, 0, 1.0989345, 0, 0, 0, 0.8093087, 47.032215, 2.198969, 0) transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 39.521854, 0.19456172, 0)
[node name="MeshInstance3D" type="MeshInstance3D" parent="BuildingAreas/B_area_S/Building" unique_id=1325249889]
transform = Transform3D(0.7908016, 0, 0, 0, 0.9999995, 0, 0, 0, 2.8399127, -7.5103607, -2.0044072, 0)
mesh = SubResource("BoxMesh_7yqgf") mesh = SubResource("BoxMesh_7yqgf")
[node name="Building" parent="BuildingAreas/B_area_S" unique_id=819634987 instance=ExtResource("2_eat54")]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 47.032215, 2.198969, 0)
[node name="B_area_N" type="StaticBody3D" parent="BuildingAreas" unique_id=1360962540] [node name="B_area_N" type="StaticBody3D" parent="BuildingAreas" unique_id=1360962540]
transform = Transform3D(-4.371139e-08, 0, 1, 0, 1, 0, -1, 0, -4.371139e-08, 0, 0, 0) transform = Transform3D(-4.371139e-08, 0, 1, 0, 1, 0, -1, 0, -4.371139e-08, 0, 0, 0)
@ -142,9 +142,9 @@ transform = Transform3D(-4.371139e-08, 0, 1, 0, 1, 0, -1, 0, -4.371139e-08, 0, 0
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 47.5, 0, 0) transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 47.5, 0, 0)
shape = SubResource("BoxShape3D_a0kup") shape = SubResource("BoxShape3D_a0kup")
[node name="Building" parent="BuildingAreas/B_area_N" unique_id=737365486 instance=ExtResource("2_eat54")] [node name="Pavement" type="MeshInstance3D" parent="BuildingAreas/B_area_N" unique_id=1889416504]
transform = Transform3D(1.1296118, 0, 0, 0, 1.0989345, 0, 0, 0, 0.8093087, 47.032215, 2.198969, 0) transform = Transform3D(1, 0, -7.1054274e-15, 0, 1, 0, 7.1054274e-15, 0, 1, 39.521854, 0.19456172, 0)
[node name="MeshInstance3D" type="MeshInstance3D" parent="BuildingAreas/B_area_N/Building" unique_id=1889416504]
transform = Transform3D(0.7908016, 0, 0, 0, 0.9999995, 0, 0, 0, 2.8399127, -7.5103607, -2.0044072, 0)
mesh = SubResource("BoxMesh_7yqgf") mesh = SubResource("BoxMesh_7yqgf")
[node name="Building" parent="BuildingAreas/B_area_N" unique_id=737365486 instance=ExtResource("2_eat54")]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 47.032215, 2.198969, 0)