2023-01-31 23:33:14 +01:00
|
|
|
class_name Interior extends Node3D
|
2023-01-25 00:26:17 +01:00
|
|
|
|
2023-01-27 15:15:59 +01:00
|
|
|
const _CHUNK_SIZE := 32
|
2023-01-25 00:26:17 +01:00
|
|
|
|
2023-01-27 15:15:59 +01:00
|
|
|
const _GRID_ORIGIN := Vector2(0.5, 0.5)
|
|
|
|
|
2023-01-28 00:52:10 +01:00
|
|
|
##
|
|
|
|
##
|
|
|
|
##
|
|
|
|
enum Orientation {
|
|
|
|
NORTH,
|
|
|
|
EAST,
|
|
|
|
SOUTH,
|
|
|
|
WEST,
|
|
|
|
}
|
|
|
|
|
2023-01-27 15:15:59 +01:00
|
|
|
##
|
2023-01-27 16:49:56 +01:00
|
|
|
## Baked block of meshes making up a segment of the grid.
|
2023-01-27 15:15:59 +01:00
|
|
|
##
|
|
|
|
class Chunk:
|
2023-01-27 23:44:28 +01:00
|
|
|
var _floor_meshes: Array[Mesh] = []
|
|
|
|
|
2023-01-28 00:52:10 +01:00
|
|
|
var _floor_orientation := PackedInt32Array()
|
|
|
|
|
2023-01-27 16:49:56 +01:00
|
|
|
var _multimesh_instances: Array[MultiMeshInstance] = []
|
2023-01-25 00:26:17 +01:00
|
|
|
|
2023-01-27 23:44:28 +01:00
|
|
|
var _wall_meshes: Array[Mesh] = []
|
2023-01-25 00:26:17 +01:00
|
|
|
|
2023-01-28 00:52:10 +01:00
|
|
|
var _wall_orientation := PackedInt32Array()
|
|
|
|
|
2023-01-25 00:26:17 +01:00
|
|
|
func _init() -> void:
|
2023-01-27 23:44:28 +01:00
|
|
|
var buffer_size := _CHUNK_SIZE * _CHUNK_SIZE
|
|
|
|
|
|
|
|
_floor_meshes.resize(buffer_size)
|
2023-01-28 00:52:10 +01:00
|
|
|
_floor_orientation.resize(buffer_size)
|
2023-01-27 23:44:28 +01:00
|
|
|
_wall_meshes.resize(buffer_size)
|
2023-01-28 00:52:10 +01:00
|
|
|
_wall_orientation.resize(buffer_size)
|
2023-01-27 15:15:59 +01:00
|
|
|
|
|
|
|
##
|
2023-01-27 16:49:56 +01:00
|
|
|
## Invalidates the mesh block, re-baking its contents from the current mesh data set.
|
2023-01-27 15:15:59 +01:00
|
|
|
##
|
2023-01-31 23:33:14 +01:00
|
|
|
func invalidate(interior: Interior, coordinate: Vector2i) -> void:
|
2023-01-27 15:15:59 +01:00
|
|
|
# TODO: Once this is all lowered into native code, look for ways to parallelize the loops.
|
2023-01-27 16:49:56 +01:00
|
|
|
for multimesh_instance in _multimesh_instances:
|
2023-01-27 15:15:59 +01:00
|
|
|
RenderingServer.free_rid(multimesh_instance._instance_rid)
|
|
|
|
RenderingServer.free_rid(multimesh_instance._multimesh_rid)
|
|
|
|
|
2023-01-27 16:49:56 +01:00
|
|
|
_multimesh_instances.clear()
|
|
|
|
|
2023-01-27 15:15:59 +01:00
|
|
|
# Normalize mesh instance data for the chunk.
|
|
|
|
var transforms_by_mesh := {}
|
2023-01-31 23:33:14 +01:00
|
|
|
var grid_size := interior.size
|
2023-01-28 00:52:10 +01:00
|
|
|
var half_pi := PI / 2
|
2023-01-27 15:15:59 +01:00
|
|
|
|
2023-01-27 23:44:28 +01:00
|
|
|
for i in _floor_meshes.size():
|
|
|
|
var mesh := _floor_meshes[i]
|
|
|
|
|
|
|
|
if mesh != null:
|
|
|
|
if not(mesh in transforms_by_mesh):
|
|
|
|
transforms_by_mesh[mesh] = []
|
|
|
|
|
2023-01-28 00:52:10 +01:00
|
|
|
transforms_by_mesh[mesh].append(Transform3D(
|
|
|
|
Basis.IDENTITY.rotated(Vector3.UP, half_pi * _floor_orientation[i]), Vector3(
|
|
|
|
(float(coordinate.x * _CHUNK_SIZE) + (i % _CHUNK_SIZE)) -
|
2023-01-31 23:29:30 +01:00
|
|
|
(float(grid_size.x) * _GRID_ORIGIN.x) + 0.5, 0.0,
|
2023-01-28 00:52:10 +01:00
|
|
|
(float(coordinate.y * _CHUNK_SIZE) + (i / _CHUNK_SIZE)) -
|
2023-01-31 23:29:30 +01:00
|
|
|
(float(grid_size.y) * _GRID_ORIGIN.y) + 0.5)))
|
2023-01-27 23:44:28 +01:00
|
|
|
|
|
|
|
for i in _wall_meshes.size():
|
|
|
|
var mesh := _wall_meshes[i]
|
2023-01-27 15:15:59 +01:00
|
|
|
|
|
|
|
if mesh != null:
|
|
|
|
if not(mesh in transforms_by_mesh):
|
|
|
|
transforms_by_mesh[mesh] = []
|
|
|
|
|
2023-01-28 00:52:10 +01:00
|
|
|
transforms_by_mesh[mesh].append(Transform3D(
|
|
|
|
Basis.IDENTITY.rotated(Vector3.UP, half_pi * _wall_orientation[i]), Vector3(
|
|
|
|
(float(coordinate.x * _CHUNK_SIZE) + (i % _CHUNK_SIZE)) -
|
2023-01-31 23:29:30 +01:00
|
|
|
(float(grid_size.x) * _GRID_ORIGIN.x) + 0.5, 0.0,
|
2023-01-28 00:52:10 +01:00
|
|
|
(float(coordinate.y * _CHUNK_SIZE) + (i / _CHUNK_SIZE)) -
|
2023-01-31 23:29:30 +01:00
|
|
|
(float(grid_size.y) * _GRID_ORIGIN.y) + 0.5)))
|
2023-01-27 15:15:59 +01:00
|
|
|
|
2023-01-27 16:49:56 +01:00
|
|
|
# (Re)-bake into multimesh instances for the chunk.
|
2023-01-31 23:33:14 +01:00
|
|
|
var scenario_rid := interior.get_world_3d().scenario
|
|
|
|
var global_transform := interior.global_transform
|
2023-01-27 15:15:59 +01:00
|
|
|
|
|
|
|
for chunk_mesh in transforms_by_mesh:
|
|
|
|
var multimesh_instance := MultiMeshInstance.new(
|
|
|
|
scenario_rid, chunk_mesh.get_rid(), transforms_by_mesh[chunk_mesh])
|
|
|
|
|
|
|
|
multimesh_instance.set_offset(global_transform)
|
2023-01-27 16:49:56 +01:00
|
|
|
_multimesh_instances.append(multimesh_instance)
|
2023-01-27 15:15:59 +01:00
|
|
|
|
|
|
|
##
|
2023-01-27 23:44:28 +01:00
|
|
|
## Sets the floor mesh in the chunk at the location relative [code]coordinatess[/code] to
|
|
|
|
## [code]mesh[/code].
|
|
|
|
##
|
|
|
|
## *Note* that [method Chunk.invalidate] must be called at some point after to visually update
|
|
|
|
## the chunk.
|
|
|
|
##
|
2023-01-28 00:52:10 +01:00
|
|
|
func set_floor_mesh(coordinates: Vector2i, orientation: Orientation, mesh: Mesh) -> void:
|
|
|
|
var index := (_CHUNK_SIZE * coordinates.y) + coordinates.x
|
|
|
|
|
|
|
|
_floor_orientation[index] = orientation
|
|
|
|
_floor_meshes[index] = mesh
|
2023-01-27 23:44:28 +01:00
|
|
|
|
|
|
|
##
|
|
|
|
## Sets the wall mesh in the chunk at the location relative [code]coordinatess[/code] to
|
2023-01-27 16:49:56 +01:00
|
|
|
## [code]mesh[/code].
|
2023-01-27 15:15:59 +01:00
|
|
|
##
|
2023-01-27 16:49:56 +01:00
|
|
|
## *Note* that [method Chunk.invalidate] must be called at some point after to visually update
|
|
|
|
## the chunk.
|
2023-01-27 15:15:59 +01:00
|
|
|
##
|
2023-01-28 00:52:10 +01:00
|
|
|
func set_wall_mesh(coordinates: Vector2i, orientation: Orientation, mesh: Mesh) -> void:
|
|
|
|
var index := (_CHUNK_SIZE * coordinates.y) + coordinates.x
|
|
|
|
|
|
|
|
_wall_orientation[index] = orientation
|
|
|
|
_wall_meshes[index] = mesh
|
2023-01-25 00:26:17 +01:00
|
|
|
|
2023-01-27 15:15:59 +01:00
|
|
|
##
|
2023-01-27 23:44:28 +01:00
|
|
|
## Specialized multi-mesh instance convenience for use within the tile grid and its chunks.
|
2023-01-27 15:15:59 +01:00
|
|
|
##
|
|
|
|
class MultiMeshInstance:
|
2023-01-25 00:26:17 +01:00
|
|
|
var _instance_rid := RID()
|
|
|
|
|
|
|
|
var _multimesh_rid := RID()
|
|
|
|
|
2023-01-27 15:15:59 +01:00
|
|
|
func _init(scenario_rid: RID, mesh_rid: RID, transforms: Array) -> void:
|
2023-01-25 00:26:17 +01:00
|
|
|
_multimesh_rid = RenderingServer.multimesh_create()
|
|
|
|
_instance_rid = RenderingServer.instance_create2(_multimesh_rid, scenario_rid)
|
|
|
|
|
2023-01-27 15:15:59 +01:00
|
|
|
RenderingServer.multimesh_set_mesh(_multimesh_rid, mesh_rid)
|
2023-01-25 00:26:17 +01:00
|
|
|
|
|
|
|
var transform_count := transforms.size()
|
|
|
|
|
|
|
|
RenderingServer.multimesh_allocate_data(_multimesh_rid,
|
|
|
|
transform_count, RenderingServer.MULTIMESH_TRANSFORM_3D, true)
|
|
|
|
|
|
|
|
for i in transform_count:
|
|
|
|
RenderingServer.multimesh_instance_set_transform(_multimesh_rid, i, transforms[i])
|
|
|
|
|
2023-01-27 15:15:59 +01:00
|
|
|
##
|
2023-01-27 16:49:56 +01:00
|
|
|
## Sets the parent transform of all mesh instances under it to [code]offset[/code].
|
2023-01-27 15:15:59 +01:00
|
|
|
##
|
|
|
|
func set_offset(offset: Transform3D) -> void:
|
|
|
|
RenderingServer.instance_set_transform(_instance_rid, offset)
|
|
|
|
|
|
|
|
var _chunks: Array[Chunk] = []
|
2023-01-25 00:26:17 +01:00
|
|
|
|
2023-01-27 15:15:59 +01:00
|
|
|
var _chunks_size := Vector2i.ZERO
|
2023-01-25 00:26:17 +01:00
|
|
|
|
|
|
|
##
|
2023-01-27 23:44:28 +01:00
|
|
|
## Size of the tile grid (in engine units).
|
2023-01-25 00:26:17 +01:00
|
|
|
##
|
|
|
|
@export
|
|
|
|
var size: Vector2i:
|
|
|
|
set(value):
|
2023-01-27 15:15:59 +01:00
|
|
|
var chunk_size_factor := float(_CHUNK_SIZE)
|
2023-01-25 00:26:17 +01:00
|
|
|
|
2023-01-27 15:15:59 +01:00
|
|
|
_chunks.resize(int(ceilf(value.x / chunk_size_factor) * ceilf(value.y / chunk_size_factor)))
|
2023-01-25 00:26:17 +01:00
|
|
|
|
2023-01-27 15:15:59 +01:00
|
|
|
for i in _chunks.size():
|
|
|
|
_chunks[i] = Chunk.new()
|
|
|
|
|
|
|
|
_chunks_size = Vector2i((value / float(_CHUNK_SIZE)).ceil())
|
2023-01-25 00:26:17 +01:00
|
|
|
size = value
|
|
|
|
|
2023-01-27 15:15:59 +01:00
|
|
|
func _get_chunk(chunk_coordinate: Vector2i) -> Chunk:
|
|
|
|
return _chunks[(_chunks_size.x * chunk_coordinate.y) + chunk_coordinate.x]
|
|
|
|
|
2023-01-25 00:26:17 +01:00
|
|
|
func _notification(what: int) -> void:
|
|
|
|
match what:
|
|
|
|
NOTIFICATION_TRANSFORM_CHANGED:
|
|
|
|
for chunk in _chunks:
|
2023-01-27 16:49:56 +01:00
|
|
|
for multimesh_instance in chunk._multimesh_instances:
|
2023-01-27 15:15:59 +01:00
|
|
|
multimesh_instance.set_offset_transform(global_transform)
|
2023-01-25 00:26:17 +01:00
|
|
|
|
|
|
|
##
|
2023-01-27 23:44:28 +01:00
|
|
|
## Clears the entirety of the tile grid to only contain [code]tile[/code].
|
2023-01-25 00:26:17 +01:00
|
|
|
##
|
2023-01-27 16:49:56 +01:00
|
|
|
## For clearing a specific region of the mesh grid, see [method fill_mesh].
|
2023-01-25 00:26:17 +01:00
|
|
|
##
|
2023-01-31 23:33:14 +01:00
|
|
|
func clear_tiles(orientation: Orientation, tile: InteriorTile) -> void:
|
2023-01-27 23:44:28 +01:00
|
|
|
if tile == null:
|
|
|
|
for y in size.y:
|
|
|
|
for x in size.x:
|
|
|
|
var coordinates := Vector2i(x, y)
|
|
|
|
var chunk := _get_chunk(coordinates / _CHUNK_SIZE)
|
|
|
|
var chunk_coordinates := coordinates % _CHUNK_SIZE
|
2023-01-27 15:15:59 +01:00
|
|
|
|
2023-01-28 00:52:10 +01:00
|
|
|
chunk.set_floor_mesh(chunk_coordinates, orientation, null)
|
|
|
|
chunk.set_wall_mesh(chunk_coordinates, orientation, null)
|
2023-01-27 23:44:28 +01:00
|
|
|
|
|
|
|
else:
|
|
|
|
var mesh := tile.mesh
|
|
|
|
|
|
|
|
match tile.kind:
|
2023-01-31 23:33:14 +01:00
|
|
|
InteriorTile.Kind.FLOOR:
|
2023-01-27 23:44:28 +01:00
|
|
|
for y in size.y:
|
|
|
|
for x in size.x:
|
|
|
|
var coordinate := Vector2i(x, y)
|
|
|
|
|
|
|
|
_get_chunk(coordinate / _CHUNK_SIZE).\
|
2023-01-28 00:52:10 +01:00
|
|
|
set_floor_mesh(coordinate % _CHUNK_SIZE, orientation, mesh)
|
2023-01-27 23:44:28 +01:00
|
|
|
|
2023-01-31 23:33:14 +01:00
|
|
|
InteriorTile.Kind.WALL:
|
2023-01-27 23:44:28 +01:00
|
|
|
for y in size.y:
|
|
|
|
for x in size.x:
|
|
|
|
var coordinate := Vector2i(x, y)
|
|
|
|
|
|
|
|
_get_chunk(coordinate / _CHUNK_SIZE).\
|
2023-01-28 00:52:10 +01:00
|
|
|
set_floor_mesh(coordinate % _CHUNK_SIZE, orientation, mesh)
|
2023-01-25 00:26:17 +01:00
|
|
|
|
2023-01-27 15:15:59 +01:00
|
|
|
for y in _chunks_size.y:
|
|
|
|
for x in _chunks_size.x:
|
|
|
|
var chunk_coordinate := Vector2i(x, y)
|
2023-01-25 00:26:17 +01:00
|
|
|
|
2023-01-27 15:15:59 +01:00
|
|
|
_get_chunk(chunk_coordinate).invalidate(self, chunk_coordinate)
|
2023-01-25 00:26:17 +01:00
|
|
|
|
2023-01-27 15:15:59 +01:00
|
|
|
##
|
2023-01-27 23:44:28 +01:00
|
|
|
## Clears the region of the tile grid at [code]area[/code] to only contain [code]tile[/code].
|
2023-01-27 15:15:59 +01:00
|
|
|
##
|
2023-01-27 16:49:56 +01:00
|
|
|
## *Note* that [code]area[/code] *must* be within the area of the of the mesh grid, where
|
|
|
|
## [code]Vector2i.ZERO[/code] is the top-left and [member size] [code]- 1[/code] is the bottom-
|
|
|
|
## right.
|
|
|
|
##
|
|
|
|
## For clearing the whole of the mesh grid, see [method clear_mesh].
|
2023-01-27 15:15:59 +01:00
|
|
|
##
|
2023-01-31 23:33:14 +01:00
|
|
|
func fill_tiles(area: Rect2i, orientation: Orientation, tile: InteriorTile) -> void:
|
2023-01-27 20:36:54 +01:00
|
|
|
assert(get_area().encloses(area), "area must be within grid")
|
2023-01-25 00:26:17 +01:00
|
|
|
|
2023-01-27 15:15:59 +01:00
|
|
|
var filled_chunks := BitMap.new()
|
2023-01-25 00:26:17 +01:00
|
|
|
|
2023-01-27 15:15:59 +01:00
|
|
|
filled_chunks.resize(_chunks_size)
|
2023-01-25 00:26:17 +01:00
|
|
|
|
2023-01-27 23:44:28 +01:00
|
|
|
if tile == null:
|
|
|
|
for y in range(area.position.y, area.end.y):
|
|
|
|
for x in range(area.position.x, area.end.x):
|
|
|
|
var coordinates := Vector2i(x, y)
|
|
|
|
var chunk_coordinates := coordinates / _CHUNK_SIZE
|
|
|
|
var chunk := _get_chunk(coordinates / _CHUNK_SIZE)
|
|
|
|
var local_coordinates := coordinates % _CHUNK_SIZE
|
|
|
|
|
2023-01-28 00:52:10 +01:00
|
|
|
chunk.set_floor_mesh(local_coordinates, orientation, null)
|
|
|
|
chunk.set_wall_mesh(local_coordinates, orientation, null)
|
2023-01-27 23:44:28 +01:00
|
|
|
filled_chunks.set_bitv(chunk_coordinates, true)
|
|
|
|
|
|
|
|
else:
|
|
|
|
var mesh := tile.mesh
|
|
|
|
|
2023-01-28 00:52:10 +01:00
|
|
|
if tile.fixed_orientation:
|
|
|
|
orientation = Orientation.NORTH
|
|
|
|
|
2023-01-27 23:44:28 +01:00
|
|
|
match tile.kind:
|
2023-01-31 23:33:14 +01:00
|
|
|
InteriorTile.Kind.FLOOR:
|
2023-01-27 23:44:28 +01:00
|
|
|
for y in range(area.position.y, area.end.y):
|
|
|
|
for x in range(area.position.x, area.end.x):
|
|
|
|
var coordinate := Vector2i(x, y)
|
|
|
|
var chunk_coordinate := coordinate / _CHUNK_SIZE
|
|
|
|
|
2023-01-28 00:52:10 +01:00
|
|
|
_get_chunk(chunk_coordinate).set_floor_mesh(
|
|
|
|
coordinate % _CHUNK_SIZE, orientation, mesh)
|
|
|
|
|
2023-01-27 23:44:28 +01:00
|
|
|
filled_chunks.set_bitv(chunk_coordinate, true)
|
|
|
|
|
2023-01-31 23:33:14 +01:00
|
|
|
InteriorTile.Kind.WALL:
|
2023-01-27 23:44:28 +01:00
|
|
|
for y in range(area.position.y, area.end.y):
|
|
|
|
for x in range(area.position.x, area.end.x):
|
|
|
|
var coordinate := Vector2i(x, y)
|
|
|
|
var chunk_coordinate := coordinate / _CHUNK_SIZE
|
2023-01-25 00:26:17 +01:00
|
|
|
|
2023-01-28 00:52:10 +01:00
|
|
|
_get_chunk(chunk_coordinate).set_wall_mesh(
|
|
|
|
coordinate % _CHUNK_SIZE, orientation, mesh)
|
|
|
|
|
2023-01-27 23:44:28 +01:00
|
|
|
filled_chunks.set_bitv(chunk_coordinate, true)
|
2023-01-25 00:26:17 +01:00
|
|
|
|
2023-01-27 15:15:59 +01:00
|
|
|
for y in _chunks_size.y:
|
|
|
|
for x in _chunks_size.x:
|
|
|
|
if filled_chunks.get_bit(x, y):
|
|
|
|
var chunk_coordinate := Vector2i(x, y)
|
2023-01-25 00:26:17 +01:00
|
|
|
|
2023-01-27 15:15:59 +01:00
|
|
|
_get_chunk(chunk_coordinate).invalidate(self, chunk_coordinate)
|
2023-01-25 00:26:17 +01:00
|
|
|
|
2023-01-27 23:44:28 +01:00
|
|
|
##
|
|
|
|
##
|
|
|
|
##
|
2023-01-27 20:36:54 +01:00
|
|
|
func get_area() -> Rect2i:
|
|
|
|
return Rect2i(Vector2i.ZERO, size)
|
|
|
|
|
2023-01-27 15:15:59 +01:00
|
|
|
##
|
2023-01-27 23:44:28 +01:00
|
|
|
## Plots a single tile at [code]coordinates[/code] to be [code]tile[/code], overwriting whatever it
|
2023-01-27 16:49:56 +01:00
|
|
|
## previously contained.
|
|
|
|
##
|
|
|
|
## *Note* that [code]coordinates[/code] *must* be within the area of the of the mesh grid, where
|
|
|
|
## [code]Vector2i.ZERO[/code] is the top-left and [member size] [code]- 1[/code] is the bottom-
|
|
|
|
## right.
|
2023-01-27 15:15:59 +01:00
|
|
|
##
|
2023-01-27 16:49:56 +01:00
|
|
|
## For bulk-setting many meshes at once, see [method fill_mesh] and [method clear_mesh].
|
2023-01-27 15:15:59 +01:00
|
|
|
##
|
2023-01-31 23:33:14 +01:00
|
|
|
func plot_tile(coordinates: Vector2i, orientation: Orientation, tile: InteriorTile) -> void:
|
2023-01-27 20:36:54 +01:00
|
|
|
assert(get_area().has_point(coordinates), "coordinate must be within grid")
|
2023-01-25 00:26:17 +01:00
|
|
|
|
2023-01-27 16:49:56 +01:00
|
|
|
var chunk_coordinates := coordinates / _CHUNK_SIZE
|
|
|
|
var chunk := _get_chunk(chunk_coordinates)
|
2023-01-25 00:26:17 +01:00
|
|
|
|
2023-01-27 23:44:28 +01:00
|
|
|
if tile == null:
|
|
|
|
var local_coordinates := coordinates % _CHUNK_SIZE
|
2023-01-25 00:26:17 +01:00
|
|
|
|
2023-01-28 00:52:10 +01:00
|
|
|
chunk.set_floor_mesh(local_coordinates, orientation, null)
|
|
|
|
chunk.set_wall_mesh(local_coordinates, orientation, null)
|
2023-01-27 23:44:28 +01:00
|
|
|
chunk.invalidate(self, chunk_coordinates)
|
|
|
|
|
|
|
|
else:
|
|
|
|
var mesh := tile.mesh
|
|
|
|
|
2023-01-28 00:52:10 +01:00
|
|
|
if tile.fixed_orientation:
|
|
|
|
orientation = Orientation.NORTH
|
|
|
|
|
2023-01-27 23:44:28 +01:00
|
|
|
match tile.kind:
|
2023-01-31 23:33:14 +01:00
|
|
|
InteriorTile.Kind.FLOOR:
|
2023-01-28 00:52:10 +01:00
|
|
|
chunk.set_floor_mesh(coordinates % _CHUNK_SIZE, orientation, mesh)
|
2023-01-27 23:44:28 +01:00
|
|
|
chunk.invalidate(self, chunk_coordinates)
|
|
|
|
|
2023-01-31 23:33:14 +01:00
|
|
|
InteriorTile.Kind.WALL:
|
2023-01-28 00:52:10 +01:00
|
|
|
chunk.set_wall_mesh(coordinates % _CHUNK_SIZE, orientation, mesh)
|
2023-01-27 23:44:28 +01:00
|
|
|
chunk.invalidate(self, chunk_coordinates)
|
2023-01-31 23:29:30 +01:00
|
|
|
|
|
|
|
##
|
|
|
|
##
|
|
|
|
##
|
|
|
|
func world_to_grid(world_position: Vector2) -> Vector2i:
|
|
|
|
return Vector2i((world_position + (Vector2(size) * _GRID_ORIGIN)).round())
|