diff --git a/src/world/generation/feature/arcology/arcology.tscn b/src/world/generation/feature/arcology/arcology.tscn index b31b108..fdfda0d 100644 --- a/src/world/generation/feature/arcology/arcology.tscn +++ b/src/world/generation/feature/arcology/arcology.tscn @@ -1,4 +1,4 @@ -[gd_scene load_steps=8 format=3 uid="uid://nllc8ljmn37g"] +[gd_scene load_steps=10 format=3 uid="uid://nllc8ljmn37g"] [ext_resource type="Script" uid="uid://drk82eeqk2mjs" path="res://src/world/generation/feature/generation_feature.gd" id="1_ek7o7"] [ext_resource type="Material" uid="uid://0ja682cfcvu3" path="res://assets/materials/shaders/megalith_base.material" id="2_pko82"] @@ -12,9 +12,18 @@ size = Vector2(100000, 100000) [sub_resource type="ConcavePolygonShape3D" id="ConcavePolygonShape3D_ek7o7"] data = PackedVector3Array(50000, 0, 50000, -50000, 0, 50000, 50000, 0, -50000, -50000, 0, 50000, -50000, 0, -50000, 50000, 0, -50000) -[node name="Arcology" type="Node3D" node_paths=PackedStringArray("sub_layers")] +[sub_resource type="Curve" id="Curve_0w44q"] +_limits = [1.0, 4.0, 0.0, 1.0] +_data = [Vector2(0, 4), 0.0, -7.386, 0, 0, Vector2(1, 1), 0.0, 0.0, 0, 0] +point_count = 2 + +[sub_resource type="Curve" id="Curve_amoo5"] +_limits = [1.0, 4.0, 0.0, 1.0] +_data = [Vector2(0, 1), 0.0, 0.0, 0, 0, Vector2(1, 4), 0.0, 0.0, 0, 0] +point_count = 2 + +[node name="Arcology" type="Node3D"] script = ExtResource("1_ek7o7") -sub_layers = [NodePath("MetroGridLayer"), NodePath("MetroGridLayer2"), NodePath("MetroGridLayer3"), NodePath("MetroGridLayer4")] metadata/_custom_type_script = "uid://drk82eeqk2mjs" [node name="InnerPyramid" type="CSGCylinder3D" parent="."] @@ -81,21 +90,109 @@ script = ExtResource("4_kox75") end_margin_pct = 0.01 metadata/_custom_type_script = "uid://cv0o1lirqeq44" -[node name="MetroGridLayer" parent="." instance=ExtResource("4_fy7wq")] -simple_construct_threshold = 0.3 -bounding_box = AABB(0, 0, 0, 99497, 100, 503) +[node name="MetroQuadrant" type="Node3D" parent="."] -[node name="MetroGridLayer2" parent="." instance=ExtResource("4_fy7wq")] -transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 99497, 0, 0) -simple_construct_threshold = 0.3 -bounding_box = AABB(0, 0, 0, 503, 100, 99497) +[node name="OuterMetro" type="Node3D" parent="MetroQuadrant"] -[node name="MetroGridLayer3" parent="." instance=ExtResource("4_fy7wq")] -transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 503, 0, 99497) -simple_construct_threshold = 0.3 -bounding_box = AABB(0, 0, 0, 99497, 100, 503) +[node name="MetroGridLayer" parent="MetroQuadrant/OuterMetro" instance=ExtResource("4_fy7wq")] +transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 55, 0, 55) +bounding_box = AABB(0, 0, 0, 49088, 100, 448) -[node name="MetroGridLayer4" parent="." instance=ExtResource("4_fy7wq")] -transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 503) -simple_construct_threshold = 0.3 -bounding_box = AABB(0, 0, 0, 503, 100, 99497) +[node name="MetroGridLayer2" parent="MetroQuadrant/OuterMetro" instance=ExtResource("4_fy7wq")] +transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 55, 0, 503) +bounding_box = AABB(0, 0, 0, 448, 100, 48640) + +[node name="InnerMetro" type="Node3D" parent="MetroQuadrant"] + +[node name="MetroGridLayer" parent="MetroQuadrant/InnerMetro" instance=ExtResource("4_fy7wq")] +transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 45047, 0, 503) +construct_height_factor_x = SubResource("Curve_0w44q") +construct_height_factor_z = SubResource("Curve_amoo5") +bounding_box = AABB(0, 0, 0, 4096, 100, 44480) + +[node name="MetroGridLayer2" parent="MetroQuadrant/InnerMetro" instance=ExtResource("4_fy7wq")] +transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 503, 0, 45047) +construct_height_factor_x = SubResource("Curve_amoo5") +construct_height_factor_z = SubResource("Curve_0w44q") +bounding_box = AABB(0, 0, 0, 44480, 100, 4096) + +[node name="MetroQuadrant2" type="Node3D" parent="."] +transform = Transform3D(-4.371139e-08, 0, 1, 0, 1, 0, -1, 0, -4.371139e-08, 0, 0, 100000) + +[node name="OuterMetro" type="Node3D" parent="MetroQuadrant2"] + +[node name="MetroGridLayer" parent="MetroQuadrant2/OuterMetro" instance=ExtResource("4_fy7wq")] +transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 55, 0, 55) +bounding_box = AABB(0, 0, 0, 49088, 100, 448) + +[node name="MetroGridLayer2" parent="MetroQuadrant2/OuterMetro" instance=ExtResource("4_fy7wq")] +transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 55, 0, 503) +bounding_box = AABB(0, 0, 0, 448, 100, 48640) + +[node name="InnerMetro" type="Node3D" parent="MetroQuadrant2"] + +[node name="MetroGridLayer" parent="MetroQuadrant2/InnerMetro" instance=ExtResource("4_fy7wq")] +transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 45047, 0, 503) +construct_height_factor_x = SubResource("Curve_0w44q") +construct_height_factor_z = SubResource("Curve_amoo5") +bounding_box = AABB(0, 0, 0, 4096, 100, 44480) + +[node name="MetroGridLayer2" parent="MetroQuadrant2/InnerMetro" instance=ExtResource("4_fy7wq")] +transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 503, 0, 45047) +construct_height_factor_x = SubResource("Curve_amoo5") +construct_height_factor_z = SubResource("Curve_0w44q") +bounding_box = AABB(0, 0, 0, 44480, 100, 4096) + +[node name="MetroQuadrant3" type="Node3D" parent="."] +transform = Transform3D(-1, 0, -8.742278e-08, 0, 1, 0, 8.742278e-08, 0, -1, 100000, 0, 100000) + +[node name="OuterMetro" type="Node3D" parent="MetroQuadrant3"] + +[node name="MetroGridLayer" parent="MetroQuadrant3/OuterMetro" instance=ExtResource("4_fy7wq")] +transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 55, 0, 55) +bounding_box = AABB(0, 0, 0, 49088, 100, 448) + +[node name="MetroGridLayer2" parent="MetroQuadrant3/OuterMetro" instance=ExtResource("4_fy7wq")] +transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 55, 0, 503) +bounding_box = AABB(0, 0, 0, 448, 100, 48640) + +[node name="InnerMetro" type="Node3D" parent="MetroQuadrant3"] + +[node name="MetroGridLayer" parent="MetroQuadrant3/InnerMetro" instance=ExtResource("4_fy7wq")] +transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 45047, 0, 503) +construct_height_factor_x = SubResource("Curve_0w44q") +construct_height_factor_z = SubResource("Curve_amoo5") +bounding_box = AABB(0, 0, 0, 4096, 100, 44480) + +[node name="MetroGridLayer2" parent="MetroQuadrant3/InnerMetro" instance=ExtResource("4_fy7wq")] +transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 503, 0, 45047) +construct_height_factor_x = SubResource("Curve_amoo5") +construct_height_factor_z = SubResource("Curve_0w44q") +bounding_box = AABB(0, 0, 0, 44480, 100, 4096) + +[node name="MetroQuadrant4" type="Node3D" parent="."] +transform = Transform3D(-4.371139e-08, 0, -1, 0, 1, 0, 1, 0, -4.371139e-08, 100000, 0, 0) + +[node name="OuterMetro" type="Node3D" parent="MetroQuadrant4"] + +[node name="MetroGridLayer" parent="MetroQuadrant4/OuterMetro" instance=ExtResource("4_fy7wq")] +transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 55, 0, 55) +bounding_box = AABB(0, 0, 0, 49088, 100, 448) + +[node name="MetroGridLayer2" parent="MetroQuadrant4/OuterMetro" instance=ExtResource("4_fy7wq")] +transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 55, 0, 503) +bounding_box = AABB(0, 0, 0, 448, 100, 48640) + +[node name="InnerMetro" type="Node3D" parent="MetroQuadrant4"] + +[node name="MetroGridLayer" parent="MetroQuadrant4/InnerMetro" instance=ExtResource("4_fy7wq")] +transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 45047, 0, 503) +construct_height_factor_x = SubResource("Curve_0w44q") +construct_height_factor_z = SubResource("Curve_amoo5") +bounding_box = AABB(0, 0, 0, 4096, 100, 44480) + +[node name="MetroGridLayer2" parent="MetroQuadrant4/InnerMetro" instance=ExtResource("4_fy7wq")] +transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 503, 0, 45047) +construct_height_factor_x = SubResource("Curve_amoo5") +construct_height_factor_z = SubResource("Curve_0w44q") +bounding_box = AABB(0, 0, 0, 44480, 100, 4096) diff --git a/src/world/generation/feature/generation_feature.gd b/src/world/generation/feature/generation_feature.gd index 06c9812..28580cb 100644 --- a/src/world/generation/feature/generation_feature.gd +++ b/src/world/generation/feature/generation_feature.gd @@ -6,11 +6,27 @@ class_name GenerationFeature extends Node3D @export var noise_scale := Vector3.ONE @export var noise_offset := Vector3.ZERO -@export var sub_layers: Array[GenerationLayer] - +var sub_layers: Array[GenerationLayer]: + get(): + if not _defined_sub_layers: + sub_layers = _find_sub_layers(self) + _defined_sub_layers = true + return sub_layers +var _defined_sub_layers := false var _generated := false +func _find_sub_layers(node: Node) -> Array[GenerationLayer]: + var layers: Array[GenerationLayer] = [] + if node is GenerationLayer: + layers.append(node) + for c: Node in node.get_children(): + # Do not walk outside of this scene + if c.owner in [owner, self]: + layers.append_array(_find_sub_layers(c)) + return layers + + func probe() -> void: # TODO may want to make low-detail & high-detail probes distinct if not _generated: diff --git a/src/world/generation/layer/grid_layer/grid_layer.gd b/src/world/generation/layer/grid_layer/grid_layer.gd index dc7caa1..cbd1570 100644 --- a/src/world/generation/layer/grid_layer/grid_layer.gd +++ b/src/world/generation/layer/grid_layer/grid_layer.gd @@ -42,8 +42,10 @@ func probe_radius(center: Vector3, radius: float) -> void: var rad_diff := Vector3(radius, 0, radius) # Translate probe box limits to grid space - var grid_low := world_to_local(center - rad_diff).floor() - var grid_high := world_to_local(center + rad_diff).floor() + var a := world_to_local(center - rad_diff).floor() + var b := world_to_local(center + rad_diff).floor() + var grid_low := Vector2(minf(a.x, b.x), minf(a.y, b.y)) + var grid_high := Vector2(maxf(a.x, b.x), maxf(a.y, b.y)) var grid_max := _plane_size().floor() # Constrain to bounding box @@ -96,7 +98,6 @@ func _init_debug_draw() -> void: _debug_box = BoxMesh.new() var mat := StandardMaterial3D.new() mat.transparency = BaseMaterial3D.TRANSPARENCY_ALPHA - mat.cull_mode = BaseMaterial3D.CULL_DISABLED mat.shading_mode = BaseMaterial3D.SHADING_MODE_UNSHADED _debug_box.material = mat _debug_meshinstance = MeshInstance3D.new() diff --git a/src/world/generation/layer/metro_grid_layer/metro_grid_layer.gd b/src/world/generation/layer/metro_grid_layer/metro_grid_layer.gd index b407996..c6e7c2c 100644 --- a/src/world/generation/layer/metro_grid_layer/metro_grid_layer.gd +++ b/src/world/generation/layer/metro_grid_layer/metro_grid_layer.gd @@ -9,7 +9,7 @@ extends GridLayer @export var noise_offset := Vector3.ZERO @export_group("Construct Parameters") -@export var simple_construct_threshold := 0.4 +@export var simple_construct_threshold := 0.3 @export var construct_height_factor_x: Curve @export var construct_height_factor_z: Curve