summaryrefslogtreecommitdiffstats
path: root/world/chunk
diff options
context:
space:
mode:
authordusoleil <howcansocksbereal@gmail.com>2022-09-20 18:52:46 -0400
committerdusoleil <howcansocksbereal@gmail.com>2022-09-20 18:52:46 -0400
commit743c526b46a1d1c6e0b7ef8b9b0f10b22ee43ab3 (patch)
treed7e1a2f2c0182664b7fe0e5b40d8b35a7433f8fa /world/chunk
parent02cbcb1a7f09c2b4d9ca89bb25cfc0a8a4354b63 (diff)
downloadgodot_wildjam_49-743c526b46a1d1c6e0b7ef8b9b0f10b22ee43ab3.tar.gz
godot_wildjam_49-743c526b46a1d1c6e0b7ef8b9b0f10b22ee43ab3.zip
Simplify and Fix Monument Code
Simplify the monument chunks to just be a bounding box with the scene origin at the center. This allows us to automatically calculate the chunks with only the bounds provided. It also fixes the issues with scaling and rotation.
Diffstat (limited to 'world/chunk')
-rw-r--r--world/chunk/Chunk.gd2
-rw-r--r--world/chunk/Chunk.tscn1
-rw-r--r--world/chunk/ChunkGen.gd7
-rw-r--r--world/chunk/ChunkLoader.gd3
4 files changed, 6 insertions, 7 deletions
diff --git a/world/chunk/Chunk.gd b/world/chunk/Chunk.gd
index a7d18a2..d1f91f7 100644
--- a/world/chunk/Chunk.gd
+++ b/world/chunk/Chunk.gd
@@ -11,7 +11,7 @@ onready var _collision_enabled = lod_close.collision_layer
func _ready():
lod_update()
- $"%Coords".text = str(ChunkLoader.v2_coords(self.transform.origin))
+ $"Coords".text = str(ChunkLoader.v2_coords(self.transform.origin))
func lod_update():
match lod:
diff --git a/world/chunk/Chunk.tscn b/world/chunk/Chunk.tscn
index 34f40bf..3dbff96 100644
--- a/world/chunk/Chunk.tscn
+++ b/world/chunk/Chunk.tscn
@@ -46,7 +46,6 @@ collision_layer = 8
collision_mask = 0
[node name="Coords" type="Label3D" parent="."]
-unique_name_in_owner = true
pixel_size = 0.3
billboard = 1
double_sided = false
diff --git a/world/chunk/ChunkGen.gd b/world/chunk/ChunkGen.gd
index 994d624..4d0c94d 100644
--- a/world/chunk/ChunkGen.gd
+++ b/world/chunk/ChunkGen.gd
@@ -17,8 +17,9 @@ func _ready():
self.rng.seed = self._seed
func setup_monuments():
- monuments.push_back(DockMonument.new(Transform(Basis().rotated(Vector3.UP,0.0),Vector3(0.0,0.0,-600.0))))
+ monuments.push_back(DockMonument.new(Transform(Basis().scaled(Vector3(2.0,2.0,2.0)),Vector3(0.0,0.0,-600.0))))
monuments.push_back(DockMonument.new(Transform(Basis().rotated(Vector3.UP,PI),Vector3(0.0,0.0,600.0))))
+ monuments.push_back(DockMonument.new(Transform(Basis().scaled(Vector3(1.5,1.5,1.5)).rotated(Vector3.UP,PI/4.0),Vector3(700.0,0.0,0.0))))
func rng_2dv(coords:Vector2):
self.rng.seed = hash(coords)
@@ -41,9 +42,9 @@ func get_monument_at_chunk(chunk_coords:Vector2):
return null
func gen_monument(chunk, monument):
- var offset_to_origin = monument.origin_chunk - ChunkLoader.v2_coords(chunk.transform.origin)
var inst = monument.scene.instance()
- inst.transform.origin = ChunkLoader.v3_coords(offset_to_origin)
+ var offset_to_origin = monument.xform.origin - chunk.transform.origin
+ inst.transform.origin = offset_to_origin
inst.transform.basis = monument.xform.basis
chunk.add_child(inst)
diff --git a/world/chunk/ChunkLoader.gd b/world/chunk/ChunkLoader.gd
index 0ea422a..5b1c2c0 100644
--- a/world/chunk/ChunkLoader.gd
+++ b/world/chunk/ChunkLoader.gd
@@ -126,6 +126,5 @@ func finish_chunk(chunk):
var coords = v2_coords(chunk.transform.origin)
loaded_chunks[coords] = weakref(chunk)
var monument = ChunkGen.get_monument_at_chunk(coords)
- if monument != null:
- if monument.loaded_chunk == null:
+ if monument != null && monument.loaded_chunk == null:
monument.loaded_chunk = coords