From ffc92ed12c6e680776d355ff9fcef70e5e28d7c8 Mon Sep 17 00:00:00 2001 From: dusoleil Date: Sun, 18 Sep 2022 08:32:29 -0400 Subject: Prototype levels of detail per chunk --- World.gd | 29 ++++++++++++++++++++++++++++- 1 file changed, 28 insertions(+), 1 deletion(-) (limited to 'World.gd') diff --git a/World.gd b/World.gd index 97f0a09..af2ba6a 100644 --- a/World.gd +++ b/World.gd @@ -4,7 +4,11 @@ export(NodePath) var traveler = null onready var _traveler = get_node(traveler) export var acceleration = 10.0 -onready var chunk_render_distance = $"ChunkRenderDistance/Radius".shape.radius +onready var lod_distance = $"ChunkRenderDistance" +onready var lod_mid = $"ChunkRenderMid" +onready var lod_close = $"ChunkRenderClose" + +onready var chunk_render_distance = lod_distance.get_node("Radius").shape.radius onready var chunk_half_size = $"Chunks/Chunk/Size".shape.radius onready var chunk_size = chunk_half_size * 2.0 @@ -13,9 +17,32 @@ func _ready(): ChunkLoader.world = self ChunkGen.chunk_half_size = self.chunk_half_size +func _on_ChunkRenderDistance_area_entered(area:Area): + if area.lod < area.LOD.DISTANCE: + area.lod = area.LOD.DISTANCE + area.lod_update() + +func _on_ChunkRenderMid_area_entered(area:Area): + if area.lod < area.LOD.MID: + area.lod = area.LOD.MID + area.lod_update() + +func _on_ChunkRenderClose_area_entered(area:Area): + if area.lod < area.LOD.CLOSE: + area.lod = area.LOD.CLOSE + area.lod_update() + func _on_ChunkRenderDistance_area_exited(area:Area): area.queue_free() +func _on_ChunkRenderMid_area_exited(area:Area): + area.lod = area.LOD.DISTANCE + area.lod_update() + +func _on_ChunkRenderClose_area_exited(area:Area): + area.lod = area.LOD.MID + area.lod_update() + func travel(direction:Vector3): var heading = _traveler.global_transform.basis heading = Basis(Vector3.UP*heading.get_euler().y) -- cgit v1.2.3