Fix tile grid alignment issues
This commit is contained in:
parent
176b18866f
commit
647ac60ce7
BIN
map_editor.scn (Stored with Git LFS)
BIN
map_editor.scn (Stored with Git LFS)
Binary file not shown.
|
@ -62,9 +62,9 @@ class Chunk:
|
|||
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)) -
|
||||
(float(grid_size.x) * _GRID_ORIGIN.x), 0.0,
|
||||
(float(grid_size.x) * _GRID_ORIGIN.x) + 0.5, 0.0,
|
||||
(float(coordinate.y * _CHUNK_SIZE) + (i / _CHUNK_SIZE)) -
|
||||
(float(grid_size.y) * _GRID_ORIGIN.y))))
|
||||
(float(grid_size.y) * _GRID_ORIGIN.y) + 0.5)))
|
||||
|
||||
for i in _wall_meshes.size():
|
||||
var mesh := _wall_meshes[i]
|
||||
|
@ -76,9 +76,9 @@ class Chunk:
|
|||
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)) -
|
||||
(float(grid_size.x) * _GRID_ORIGIN.x), 0.0,
|
||||
(float(grid_size.x) * _GRID_ORIGIN.x) + 0.5, 0.0,
|
||||
(float(coordinate.y * _CHUNK_SIZE) + (i / _CHUNK_SIZE)) -
|
||||
(float(grid_size.y) * _GRID_ORIGIN.y))))
|
||||
(float(grid_size.y) * _GRID_ORIGIN.y) + 0.5)))
|
||||
|
||||
# (Re)-bake into multimesh instances for the chunk.
|
||||
var scenario_rid := tile_grid.get_world_3d().scenario
|
||||
|
@ -324,3 +324,9 @@ func plot_tile(coordinates: Vector2i, orientation: Orientation, tile: Tile) -> v
|
|||
Tile.Kind.WALL:
|
||||
chunk.set_wall_mesh(coordinates % _CHUNK_SIZE, orientation, mesh)
|
||||
chunk.invalidate(self, chunk_coordinates)
|
||||
|
||||
##
|
||||
##
|
||||
##
|
||||
func world_to_grid(world_position: Vector2) -> Vector2i:
|
||||
return Vector2i((world_position + (Vector2(size) * _GRID_ORIGIN)).round())
|
||||
|
|
Loading…
Reference in New Issue