diff options
author | nokoe <nokoe@mailbox.org> | 2024-09-26 19:38:58 +0200 |
---|---|---|
committer | nokoe <nokoe@mailbox.org> | 2024-09-26 20:28:08 +0200 |
commit | 2031a8b9d2bf568f538cc9223713f50c77bac897 (patch) | |
tree | 82d9ed6f8502bcd1d949e28d4d61528b8478c437 /client/map/map.gd | |
parent | 2a96dbb14fe268c90025d1d0af5e66dc9b00f214 (diff) | |
download | hurrycurry-2031a8b9d2bf568f538cc9223713f50c77bac897.tar hurrycurry-2031a8b9d2bf568f538cc9223713f50c77bac897.tar.bz2 hurrycurry-2031a8b9d2bf568f538cc9223713f50c77bac897.tar.zst |
floor as one mesh
Diffstat (limited to 'client/map/map.gd')
-rw-r--r-- | client/map/map.gd | 14 |
1 files changed, 9 insertions, 5 deletions
diff --git a/client/map/map.gd b/client/map/map.gd index ce3c6dfa..40451c57 100644 --- a/client/map/map.gd +++ b/client/map/map.gd @@ -21,6 +21,8 @@ extends Node3D var tile_by_pos: Dictionary = {} var autobake = false var currently_baked = false +var floor_mesher := FloorMesher.new() +var floor_node := MeshInstance3D.new() func get_tile_name(pos: Vector2i): var e = tile_by_pos.get(str(pos)) @@ -32,11 +34,10 @@ func get_tile_instance(pos: Vector2i) -> Tile: else: return null func set_tile(pos: Vector2i, name_: String, neighbors: Array = [null,null,null,null]) -> Tile: - var tile = TileFactory.produce(name_, str(pos), neighbors) + var tile = TileFactory.produce(name_, pos, neighbors, floor_mesher) add_child(tile) tile.position = Vector3(pos.x, 0, pos.y) tile_by_pos[str(pos)] = [pos, name_, tile, neighbors] - if autobake: voxelgi_timer.start(1) return tile func clear_tile(pos: Vector2i): @@ -47,12 +48,16 @@ func clear_tile(pos: Vector2i): tile.name += "_queued_free" tile.queue_free() -@onready var voxelgi_timer: Timer = $Timer @onready var voxelgi: VoxelGI = $VoxelGI func _ready(): - voxelgi_timer.connect("timeout", gi_bake) Settings.hook_changed("graphics.gi", false, apply_gi_setting) + floor_node.material_override = preload("res://map/tiles/floor_material.tres") + add_child(floor_node) + +func flush() -> void: + floor_node.mesh = floor_mesher.flush() + gi_bake() func apply_gi_setting(state): if state == "voxelgi" and not currently_baked: @@ -61,7 +66,6 @@ func apply_gi_setting(state): currently_baked = false voxelgi.data = null - func gi_bake(): if Global.get_setting("graphics.gi") != "voxelgi": return print("Map: Rebaking VoxelGI") |