Skip to content

Commit d87ac4e

Browse files
committed
Refactor
Refactor the code to split the pieces into their own respective functions. Begin setting up the system to be able to produce objects for the large objects placement code. Rework the code to better attain control over the procedural nature of large object areas, lakes, rivers.
1 parent 3b2100d commit d87ac4e

File tree

4 files changed

+779
-574
lines changed

4 files changed

+779
-574
lines changed

demo/Prefabs/SimpleCube.tscn

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
[gd_scene load_steps=2 format=3 uid="uid://eha0t8rebsfu"]
2+
3+
[sub_resource type="BoxMesh" id="BoxMesh_v0y2m"]
4+
5+
[node name="SimpleCube" type="Node3D"]
6+
7+
[node name="CSGMesh3D" type="CSGMesh3D" parent="."]
8+
mesh = SubResource("BoxMesh_v0y2m")

demo/terrain_gen_script.gd

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
extends TerrainGen
22

3+
var simple_cube = preload("res://Prefabs/SimpleCube.tscn")
4+
35
enum NoiseType {
46
VALUE = 5,
57
VALUE_CUBIC = 4,
@@ -30,11 +32,15 @@ func _ready():
3032

3133
#var elevation_map: Array = result["elevationMap"]
3234
#print("Elevation at (0,0): ", elevation_map[0][0])
33-
#
34-
#var flat_zones: Array = result["flatZones"]
35-
#for zone in flat_zones:
36-
#print("Flat zone at (%d, %d) with elevation %d" % [zone["x"], zone["y"], zone["elevation"]])
37-
#
35+
36+
var flat_zones: Array = result["flatZones"]
37+
38+
for zone in flat_zones:
39+
var new_object = simple_cube.instantiate();
40+
var spawn_position = zone
41+
new_object.global_transform.origin = Vector3(spawn_position) + Vector3(0, 0.27, 0)
42+
add_child(new_object)
43+
#
3844
## Access Poisson samples
3945
#var poisson_points: Array = result["poissonPoints"]
4046
#for point in poisson_points:

0 commit comments

Comments
 (0)