summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Chunk.tscn30
-rw-r--r--Main.tscn50
-rw-r--r--World.gd103
-rw-r--r--World.tscn38
4 files changed, 119 insertions, 102 deletions
diff --git a/Chunk.tscn b/Chunk.tscn
new file mode 100644
index 0000000..823aa51
--- /dev/null
+++ b/Chunk.tscn
@@ -0,0 +1,30 @@
+[gd_scene load_steps=5 format=2]
+
+[sub_resource type="SphereShape" id=1]
+radius = 50.0
+
+[sub_resource type="PlaneMesh" id=2]
+size = Vector2( 100, 100 )
+
+[sub_resource type="SpatialMaterial" id=3]
+flags_unshaded = true
+params_cull_mode = 2
+albedo_color = Color( 0.937255, 0, 1, 1 )
+
+[sub_resource type="PlaneMesh" id=4]
+size = Vector2( 98, 98 )
+
+[node name="Chunk" type="Area"]
+collision_layer = 32
+collision_mask = 0
+
+[node name="Size" type="CollisionShape" parent="."]
+shape = SubResource( 1 )
+
+[node name="Border" type="CSGMesh" parent="."]
+mesh = SubResource( 2 )
+material = SubResource( 3 )
+
+[node name="CSGMesh" type="CSGMesh" parent="Border"]
+operation = 2
+mesh = SubResource( 4 )
diff --git a/Main.tscn b/Main.tscn
index 9d305e6..97b6e10 100644
--- a/Main.tscn
+++ b/Main.tscn
@@ -1,11 +1,11 @@
-[gd_scene load_steps=20 format=2]
+[gd_scene load_steps=15 format=2]
[ext_resource path="res://character/fps_controller/fps_controller.tscn" type="PackedScene" id=1]
[ext_resource path="res://ship/ship/ship.tscn" type="PackedScene" id=2]
[ext_resource path="res://water/Water.tscn" type="PackedScene" id=3]
[ext_resource path="res://Float.tscn" type="PackedScene" id=4]
[ext_resource path="res://ship/ship/crate.tscn" type="PackedScene" id=5]
-[ext_resource path="res://World.gd" type="Script" id=6]
+[ext_resource path="res://World.tscn" type="PackedScene" id=6]
[ext_resource path="res://Ship.gd" type="Script" id=7]
[ext_resource path="res://FPS.gd" type="Script" id=8]
[ext_resource path="res://Main.gd" type="Script" id=9]
@@ -20,24 +20,6 @@ size = Vector2( 2000, 2000 )
[sub_resource type="SpatialMaterial" id=21]
albedo_color = Color( 0.941176, 0.658824, 0.215686, 1 )
-[sub_resource type="SpatialMaterial" id=14]
-albedo_color = Color( 0.298039, 0.054902, 0.054902, 1 )
-
-[sub_resource type="CubeMesh" id=15]
-material = SubResource( 14 )
-size = Vector3( 4, 4, 4 )
-
-[sub_resource type="MultiMesh" id=16]
-transform_format = 1
-instance_count = 128
-mesh = SubResource( 15 )
-transform_array = PoolVector3Array( 0.35759, 0, -0.933879, 0, 1, 0, 0.933879, 0, 0.35759, -132.354, 0, 25.9735, -0.166596, 0, -0.986025, 0, 1, 0, 0.986025, 0, -0.166596, -58.4885, 0, -121.658, -0.169897, 0, -0.985462, 0, 1, 0, 0.985462, 0, -0.169897, -237.192, 0, 45.1928, -0.112707, 0, -0.993628, 0, 1, 0, 0.993628, 0, -0.112707, -203.325, 0, -171.736, -0.0190256, 0, -0.999819, 0, 1, 0, 0.999819, 0, -0.0190256, 179.631, 0, 203.062, -0.935878, 0, -0.352325, 0, 1, 0, 0.352325, 0, -0.935878, 173.895, 0, -164.972, 0.0588548, 0, -0.998267, 0, 1, 0, 0.998267, 0, 0.0588548, -66.194, 0, 126.188, -0.996945, 0, 0.0781089, 0, 1, 0, -0.0781089, 0, -0.996945, -194.976, 0, -94.1853, 0.328425, 0, -0.94453, 0, 1, 0, 0.94453, 0, 0.328425, -80.116, 0, -215.377, -0.967746, 0, -0.251927, 0, 1, 0, 0.251927, 0, -0.967746, -105.352, 0, 65.2791, -0.936079, 0, -0.35179, 0, 1, 0, 0.35179, 0, -0.936079, 142.656, 0, 104.505, -0.997245, 0, -0.0741828, 0, 1, 0, 0.0741828, 0, -0.997245, 245.516, 0, 75.0552, -0.982368, 0, 0.18696, 0, 1, 0, -0.18696, 0, -0.982368, 58.7, 0, -63.9099, 0.106816, 0, -0.994279, 0, 1, 0, 0.994279, 0, 0.106816, 25.2356, 0, -34.1029, -0.20875, 0, -0.977969, 0, 1, 0, 0.977969, 0, -0.20875, 247.67, 0, 15.0077, -0.302054, 0, -0.953291, 0, 1, 0, 0.953291, 0, -0.302054, -156.547, 0, 172.732, -0.992106, 0, 0.125405, 0, 1, 0, -0.125405, 0, -0.992106, 247.02, 0, 207.665, -0.982566, 0, 0.185912, 0, 1, 0, -0.185912, 0, -0.982566, 177.603, 0, -49.0312, -0.949651, 0, 0.313311, 0, 1, 0, -0.313311, 0, -0.949651, -60.0598, 0, 53.5173, -0.999948, 0, -0.0101814, 0, 1, 0, 0.0101814, 0, -0.999948, 147.169, 0, 203.506, -0.998571, 0, -0.0534461, 0, 1, 0, 0.0534461, 0, -0.998571, -21.4644, 0, -92.849, -0.20624, 0, -0.978502, 0, 1, 0, 0.978502, 0, -0.20624, 51.5984, 0, 182.344, -0.999531, 0, -0.0306122, 0, 1, 0, 0.0306122, 0, -0.999531, 57.7288, 0, 159.342, -0.999559, 0, 0.0296817, 0, 1, 0, -0.0296817, 0, -0.999559, -153.744, 0, 113.534, -0.999711, 0, 0.0240541, 0, 1, 0, -0.0240541, 0, -0.999711, 11.7847, 0, 27.7344, -0.978851, 0, 0.204573, 0, 1, 0, -0.204573, 0, -0.978851, 3.7685, 0, -164.132, -0.30979, 0, -0.950805, 0, 1, 0, 0.950805, 0, -0.30979, 15.6672, 0, 34.9288, 0.108742, 0, -0.99407, 0, 1, 0, 0.99407, 0, 0.108742, 182.396, 0, -156.8, -0.964497, 0, 0.264095, 0, 1, 0, -0.264095, 0, -0.964497, -214.64, 0, -30.6637, -0.967866, 0, 0.251466, 0, 1, 0, -0.251466, 0, -0.967866, -228.476, 0, 183.049, 0.083052, 0, -0.996545, 0, 1, 0, 0.996545, 0, 0.083052, -59.2164, 0, -202.097, -0.998532, 0, -0.0541704, 0, 1, 0, 0.0541704, 0, -0.998532, 190.683, 0, -161.449, -0.943506, 0, 0.331357, 0, 1, 0, -0.331357, 0, -0.943506, -66.1227, 0, 14.806, 0.122434, 0, -0.992477, 0, 1, 0, 0.992477, 0, 0.122434, 66.7506, 0, 161.826, 0.141346, 0, -0.98996, 0, 1, 0, 0.98996, 0, 0.141346, -160.989, 0, 147.28, -0.962282, 0, -0.272052, 0, 1, 0, 0.272052, 0, -0.962282, -170.63, 0, -2.8079, -0.352045, 0, -0.935983, 0, 1, 0, 0.935983, 0, -0.352045, -111.789, 0, 147.694, -0.372722, 0, -0.927943, 0, 1, 0, 0.927943, 0, -0.372722, -193.423, 0, 185.104, -0.951295, 0, 0.308283, 0, 1, 0, -0.308283, 0, -0.951295, 12.4779, 0, 227.154, 0.188927, 0, -0.981991, 0, 1, 0, 0.981991, 0, 0.188927, 129.573, 0, -136.593, 0.156853, 0, -0.987622, 0, 1, 0, 0.987622, 0, 0.156853, -157.054, 0, 79.9971, -0.965351, 0, 0.260956, 0, 1, 0, -0.260956, 0, -0.965351, -17.076, 0, 101.827, -0.231306, 0, -0.972881, 0, 1, 0, 0.972881, 0, -0.231306, 218.131, 0, -176.038, -0.917955, 0, 0.396683, 0, 1, 0, -0.396683, 0, -0.917955, -49.9378, 0, 98.9674, -0.30023, 0, -0.953867, 0, 1, 0, 0.953867, 0, -0.30023, -147.821, 0, 227.766, -0.363415, 0, -0.931627, 0, 1, 0, 0.931627, 0, -0.363415, -144.353, 0, -106.868, -0.959804, 0, -0.28067, 0, 1, 0, 0.28067, 0, -0.959804, 165.874, 0, 137.093, -0.986663, 0, 0.162778, 0, 1, 0, -0.162778, 0, -0.986663, 247.901, 0, -204.139, 0.361552, 0, -0.932352, 0, 1, 0, 0.932352, 0, 0.361552, 118.66, 0, -63.4872, -0.996305, 0, 0.0858846, 0, 1, 0, -0.0858846, 0, -0.996305, 40.0315, 0, -140.072, -0.0252063, 0, -0.999682, 0, 1, 0, 0.999682, 0, -0.0252063, -53.9795, 0, -230.956, -0.263077, 0, -0.964775, 0, 1, 0, 0.964775, 0, -0.263077, -67.5406, 0, 241.857, -0.996247, 0, -0.0865599, 0, 1, 0, 0.0865599, 0, -0.996247, -130.862, 0, 121.502, -0.978612, 0, -0.205713, 0, 1, 0, 0.205713, 0, -0.978612, -152.62, 0, -120.933, -0.985639, 0, 0.168866, 0, 1, 0, -0.168866, 0, -0.985639, 94.6609, 0, -120.119, -0.985644, 0, -0.168839, 0, 1, 0, 0.168839, 0, -0.985644, -46.3315, 0, -135.932, -0.997343, 0, -0.0728552, 0, 1, 0, 0.0728552, 0, -0.997343, 212.666, 0, -210.117, 0.164823, 0, -0.986323, 0, 1, 0, 0.986323, 0, 0.164823, 38.4822, 0, -186.671, -0.941645, 0, -0.336607, 0, 1, 0, 0.336607, 0, -0.941645, -203.229, 0, 19.3772, -0.113492, 0, -0.993539, 0, 1, 0, 0.993539, 0, -0.113492, -237.146, 0, -207.678, -0.00882641, 0, -0.999961, 0, 1, 0, 0.999961, 0, -0.00882641, -186.211, 0, 97.6423, -0.93974, 0, 0.341891, 0, 1, 0, -0.341891, 0, -0.93974, 87.3621, 0, 40.0809, -0.995853, 0, -0.0909723, 0, 1, 0, 0.0909723, 0, -0.995853, -183.911, 0, 20.0592, 0.22151, 0, -0.975158, 0, 1, 0, 0.975158, 0, 0.22151, 143.017, 0, 119.487, 0.362591, 0, -0.931948, 0, 1, 0, 0.931948, 0, 0.362591, 116.205, 0, 28.7721, -0.998104, 0, -0.0615496, 0, 1, 0, 0.0615496, 0, -0.998104, 45.0201, 0, 122.077, 0.234306, 0, -0.972163, 0, 1, 0, 0.972163, 0, 0.234306, 84.9801, 0, 148.083, -0.142697, 0, -0.989766, 0, 1, 0, 0.989766, 0, -0.142697, -3.44455, 0, -180.806, 0.117511, 0, -0.993072, 0, 1, 0, 0.993072, 0, 0.117511, -49.4198, 0, 139.752, 0.169861, 0, -0.985468, 0, 1, 0, 0.985468, 0, 0.169861, 94.478, 0, 76.4108, 0.345079, 0, -0.938574, 0, 1, 0, 0.938574, 0, 0.345079, -31.1539, 0, 190.493, 0.0382106, 0, -0.99927, 0, 1, 0, 0.99927, 0, 0.0382106, 71.3307, 0, -8.99055, -0.944066, 0, -0.329756, 0, 1, 0, 0.329756, 0, -0.944066, 112.84, 0, 186.374, 0.102813, 0, -0.994701, 0, 1, 0, 0.994701, 0, 0.102813, -64.7515, 0, 21.125, -0.99805, 0, -0.0624175, 0, 1, 0, 0.0624175, 0, -0.99805, -187.773, 0, -76.3077, 0.354658, 0, -0.934996, 0, 1, 0, 0.934996, 0, 0.354658, 94.2989, 0, 85.0028, -0.938369, 0, -0.345635, 0, 1, 0, 0.345635, 0, -0.938369, -158.643, 0, 4.30212, -0.947115, 0, -0.320895, 0, 1, 0, 0.320895, 0, -0.947115, -228.162, 0, 52.8114, -0.153055, 0, -0.988218, 0, 1, 0, 0.988218, 0, -0.153055, -175.169, 0, 16.8836, 0.104669, 0, -0.994507, 0, 1, 0, 0.994507, 0, 0.104669, 203.129, 0, -195.882, -0.378617, 0, -0.925553, 0, 1, 0, 0.925553, 0, -0.378617, -177.482, 0, -27.9352, -0.945361, 0, -0.326026, 0, 1, 0, 0.326026, 0, -0.945361, -72.9087, 0, 122.183, 0.087574, 0, -0.996158, 0, 1, 0, 0.996158, 0, 0.087574, 139.865, 0, -227.454, 0.205411, 0, -0.978676, 0, 1, 0, 0.978676, 0, 0.205411, 185.328, 0, 249.65, -0.346264, 0, -0.938137, 0, 1, 0, 0.938137, 0, -0.346264, 118.653, 0, -156.251, -0.998793, 0, 0.0491192, 0, 1, 0, -0.0491192, 0, -0.998793, -194.36, 0, -153.296, -0.999196, 0, -0.0400879, 0, 1, 0, 0.0400879, 0, -0.999196, 206.055, 0, -97.1766, 0.320264, 0, -0.947328, 0, 1, 0, 0.947328, 0, 0.320264, -9.50861, 0, -82.5906, -0.999482, 0, 0.0321931, 0, 1, 0, -0.0321931, 0, -0.999482, 8.09274, 0, 52.5591, -0.340579, 0, -0.940216, 0, 1, 0, 0.940216, 0, -0.340579, 119.636, 0, 173.205, -0.986233, 0, -0.165361, 0, 1, 0, 0.165361, 0, -0.986233, -6.22897, 0, -50.6787, -0.999619, 0, 0.027588, 0, 1, 0, -0.027588, 0, -0.999619, -115.038, 0, 184.275, -0.28749, 0, -0.957784, 0, 1, 0, 0.957784, 0, -0.28749, -123.12, 0, -177.878, -0.216796, 0, -0.976217, 0, 1, 0, 0.976217, 0, -0.216796, -23.6949, 0, -119.185, -0.989482, 0, 0.144654, 0, 1, 0, -0.144654, 0, -0.989482, 211.98, 0, -158.666, -0.99323, 0, 0.116168, 0, 1, 0, -0.116168, 0, -0.99323, -91.3339, 0, -214.294, 0.351921, 0, -0.93603, 0, 1, 0, 0.93603, 0, 0.351921, 98.824, 0, -172.411, -0.193469, 0, -0.981106, 0, 1, 0, 0.981106, 0, -0.193469, 6.03069, 0, 224.216, -0.995109, 0, -0.098783, 0, 1, 0, 0.098783, 0, -0.995109, 82.9438, 0, 47.3094, -0.982752, 0, 0.184926, 0, 1, 0, -0.184926, 0, -0.982752, -39.8483, 0, 38.0248, -0.989099, 0, -0.147251, 0, 1, 0, 0.147251, 0, -0.989099, -174.222, 0, 181.286, -0.237543, 0, -0.971377, 0, 1, 0, 0.971377, 0, -0.237543, -132.222, 0, 85.7345, -0.992325, 0, 0.123659, 0, 1, 0, -0.123659, 0, -0.992325, 167.103, 0, -103.948, 0.0651524, 0, -0.997875, 0, 1, 0, 0.997875, 0, 0.0651524, -167.652, 0, 237.938, 0.244797, 0, -0.969574, 0, 1, 0, 0.969574, 0, 0.244797, 16.6177, 0, -149.998, -0.957481, 0, -0.288497, 0, 1, 0, 0.288497, 0, -0.957481, 171.397, 0, 168.462, -0.931978, 0, 0.362514, 0, 1, 0, -0.362514, 0, -0.931978, 119.002, 0, -114.3, -0.109316, 0, -0.994007, 0, 1, 0, 0.994007, 0, -0.109316, 106.135, 0, 117.777, -0.340095, 0, -0.940391, 0, 1, 0, 0.940391, 0, -0.340095, 115.411, 0, 68.8451, 0.284506, 0, -0.958674, 0, 1, 0, 0.958674, 0, 0.284506, 24.1306, 0, -201.735, 0.211316, 0, -0.977418, 0, 1, 0, 0.977418, 0, 0.211316, -132.272, 0, -173.93, -0.317435, 0, -0.94828, 0, 1, 0, 0.94828, 0, -0.317435, 46.7095, 0, -70.2094, -0.953531, 0, 0.301296, 0, 1, 0, -0.301296, 0, -0.953531, -86.2393, 0, -110.854, -0.204761, 0, -0.978812, 0, 1, 0, 0.978812, 0, -0.204761, -151.096, 0, -216.627, -0.989074, 0, 0.147421, 0, 1, 0, -0.147421, 0, -0.989074, -223.565, 0, -40.1842, -0.936225, 0, -0.351402, 0, 1, 0, 0.351402, 0, -0.936225, -170.448, 0, 79.0844, -0.977532, 0, -0.210789, 0, 1, 0, 0.210789, 0, -0.977532, 4.81291, 0, 241.894, -0.923839, 0, 0.38278, 0, 1, 0, -0.38278, 0, -0.923839, -41.5929, 0, 148.399, -0.203305, 0, -0.979115, 0, 1, 0, 0.979115, 0, -0.203305, -142.343, 0, 224.487, -0.00353323, 0, -0.999994, 0, 1, 0, 0.999994, 0, -0.00353323, 224.877, 0, 241.167, 0.00743366, 0, -0.999972, 0, 1, 0, 0.999972, 0, 0.00743366, -95.6667, 0, 16.6366, -0.966753, 0, -0.255712, 0, 1, 0, 0.255712, 0, -0.966753, -169.85, 0, 68.0472, -0.165087, 0, -0.986279, 0, 1, 0, 0.986279, 0, -0.165087, -102.518, 0, 167.262, -0.184838, 0, -0.982769, 0, 1, 0, 0.982769, 0, -0.184838, -78.4378, 0, 64.5587, -0.95449, 0, -0.298244, 0, 1, 0, 0.298244, 0, -0.95449, 48.029, 0, 93.6345, -0.323296, 0, -0.946298, 0, 1, 0, 0.946298, 0, -0.323296, 96.524, 0, -131.551, -0.326087, 0, -0.94534, 0, 1, 0, 0.94534, 0, -0.326087, -182.872, 0, -220.446, 0.0925047, 0, -0.995712, 0, 1, 0, 0.995712, 0, 0.0925047, 37.0471, 0, -154.822 )
-
-[sub_resource type="BoxShape" id=23]
-
-[sub_resource type="BoxShape" id=24]
-extents = Vector3( 300, 1000, 300 )
-
[sub_resource type="CapsuleShape" id=22]
radius = 11.4853
height = 97.7559
@@ -66,31 +48,8 @@ material/0 = SubResource( 21 )
[node name="Water" parent="." instance=ExtResource( 3 )]
transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, -1, 0 )
-[node name="World" type="RigidBody" parent="."]
-collision_layer = 0
-collision_mask = 0
-can_sleep = false
-axis_lock_linear_y = true
-axis_lock_angular_x = true
-axis_lock_angular_y = true
-axis_lock_angular_z = true
-linear_damp = 0.5
-script = ExtResource( 6 )
-
-[node name="MultiMeshInstance" type="MultiMeshInstance" parent="World"]
-transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, -3.18141, 0 )
-visible = false
-multimesh = SubResource( 16 )
-
-[node name="CollisionShape" type="CollisionShape" parent="World"]
-shape = SubResource( 23 )
-
-[node name="WorldGenCull" type="Area" parent="."]
-collision_layer = 0
-collision_mask = 40
-
-[node name="CollisionShape" type="CollisionShape" parent="WorldGenCull"]
-shape = SubResource( 24 )
+[node name="World" parent="." instance=ExtResource( 6 )]
+traveler = NodePath("../ShipRigidBody")
[node name="ShipRigidBody" type="RigidBody" parent="."]
collision_layer = 2
@@ -1909,6 +1868,5 @@ margin_right = 163.0
margin_bottom = 68.0
script = ExtResource( 8 )
-[connection signal="body_exited" from="WorldGenCull" to="World" method="_on_WorldGenCull_body_exited"]
[connection signal="entered" from="ShipRigidBody/lower_deck_trigger" to="." method="_on_lower_deck_trigger_entered"]
[connection signal="exited" from="ShipRigidBody/lower_deck_trigger" to="." method="_on_lower_deck_trigger_exited"]
diff --git a/World.gd b/World.gd
index 15e283f..6aba103 100644
--- a/World.gd
+++ b/World.gd
@@ -1,68 +1,59 @@
-extends RigidBody
+extends Spatial
+export(NodePath) var traveler = null
+onready var _traveler = get_node(traveler)
export var acceleration = 10.0
-export var generation_distance = 300.0
-export var generation_subdivision = 5.0
-var gen_coords = Vector2.ZERO
-const init_distance = 10
-
-onready var Rock = preload("res://Rock.tscn")
-onready var noise = OpenSimplexNoise.new()
-
-func _on_WorldGenCull_body_exited(body:Node):
- body.queue_free()
-
-func make_rock(xform:Transform):
- var rock = Rock.instance()
- rock.transform = xform
- self.add_child(rock)
-
-func generate_location(coords:Vector2):
- if coords.x < -init_distance || coords.x > init_distance || coords.y < -init_distance || coords.y > init_distance:
- if noise.get_noise_2d(coords.x,coords.y) > 0.6:
- coords *= generation_subdivision
- make_rock(Transform(Basis(), Vector3(coords.x,0.0,coords.y)))
-
-func generate_world():
- var new_coords = -(self.transform.origin / generation_subdivision).floor()
- new_coords = Vector2(new_coords.x,new_coords.z)
- var direction = new_coords - gen_coords
- var gen_max = generation_distance / generation_subdivision
- var gen_min = -gen_max
- if gen_coords.x != new_coords.x:
- for i in range(new_coords.y+gen_min,new_coords.y+gen_max):
- generate_location(Vector2(new_coords.x+(gen_min if direction.x < 0 else gen_max),i))
- if gen_coords.y != new_coords.y:
- for i in range(new_coords.x+gen_min,new_coords.x+gen_max):
- generate_location(Vector2(i,new_coords.y+(gen_min if direction.y < 0 else gen_max)))
- gen_coords = new_coords
+onready var Chunk = preload("res://Chunk.tscn")
+onready var chunk_size = $"WorldGen/Chunk/Size".shape.radius*2.0
+var chunks = {}
+
+func v2_coords(xform:Transform):
+ var coords = xform.origin
+ coords = Vector2(coords.x,coords.z)
+ return coords
+
+func chunk_coords(coords:Vector2):
+ coords = (coords / chunk_size).floor()
+ return coords
+
+func world_coords(coords:Vector2):
+ coords *= chunk_size
+ return Vector3(coords.x,0.0,coords.y)
+
+func gen_chunk(xform:Transform):
+ var chunk = Chunk.instance()
+ chunk.transform = xform
+ $"WorldGen".add_child(chunk)
+ chunks[chunk_coords(v2_coords(xform))] = chunk
+
+func gen_chunks():
+ var gen_center = -v2_coords($"WorldGen".transform)
+ var gen_radius = $"WorldGenCull/Radius".shape.radius-chunk_size
+ for x in range(-gen_radius, gen_radius, chunk_size):
+ for y in range(-gen_radius, gen_radius, chunk_size):
+ var gen_coords = Vector2(x,y)
+ var coords = chunk_coords(gen_coords + gen_center)
+ if gen_coords.length() <= gen_radius && !chunks.has(coords):
+ gen_chunk(Transform(Basis(), world_coords(coords)))
+
+func _on_WorldGenCull_area_exited(area:Area):
+ gen_chunks()
+ area.queue_free()
+ chunks.erase(chunk_coords(v2_coords(area.transform)))
func _ready():
- randomize()
- noise.seed = randi()
- noise.octaves = 4
- noise.period = 16
- noise.persistence = 0.001
- noise.lacunarity = 2.0
-
- var gen_max = generation_distance / generation_subdivision
- var gen_min = -gen_max
- for i in range(gen_min,gen_max):
- for j in range(gen_min,gen_max):
- generate_location(Vector2(i,j))
+ gen_chunks()
func travel(direction:Vector3):
- var boat = $"/root/Main/ShipRigidBody"
- var boat_direction = boat.global_transform.basis
- boat_direction = Basis(Vector3.UP*boat_direction.get_euler().y)
+ var heading = _traveler.global_transform.basis
+ heading = Basis(Vector3.UP*heading.get_euler().y)
direction = -direction
- direction = boat_direction * direction
+ direction = heading * direction
direction = direction.normalized()
- self.add_central_force(direction*acceleration)
+ $"WorldGen".add_central_force(direction*acceleration)
-func _integrate_forces(_state):
- generate_world()
+func _physics_process(_state):
var stick = Input.get_axis("ship_down","ship_up")
if stick != 0.0:
- travel(Vector3.FORWARD*stick)
+ self.travel(Vector3.FORWARD*stick)
diff --git a/World.tscn b/World.tscn
new file mode 100644
index 0000000..67e4848
--- /dev/null
+++ b/World.tscn
@@ -0,0 +1,38 @@
+[gd_scene load_steps=5 format=2]
+
+[ext_resource path="res://World.gd" type="Script" id=1]
+[ext_resource path="res://Chunk.tscn" type="PackedScene" id=3]
+
+[sub_resource type="BoxShape" id=23]
+
+[sub_resource type="SphereShape" id=24]
+radius = 1000.0
+
+[node name="World" type="Spatial"]
+script = ExtResource( 1 )
+
+[node name="WorldGen" type="RigidBody" parent="."]
+collision_layer = 0
+collision_mask = 0
+can_sleep = false
+axis_lock_linear_y = true
+axis_lock_angular_x = true
+axis_lock_angular_y = true
+axis_lock_angular_z = true
+linear_damp = 0.5
+
+[node name="CollisionShape" type="CollisionShape" parent="WorldGen"]
+shape = SubResource( 23 )
+
+[node name="Chunk" parent="WorldGen" instance=ExtResource( 3 )]
+visible = false
+collision_layer = 0
+
+[node name="WorldGenCull" type="Area" parent="."]
+collision_layer = 0
+collision_mask = 32
+
+[node name="Radius" type="CollisionShape" parent="WorldGenCull"]
+shape = SubResource( 24 )
+
+[connection signal="area_exited" from="WorldGenCull" to="." method="_on_WorldGenCull_area_exited"]