🎉 Sort viewport tiles by distance to center

This commit is contained in:
Aitor Moreno 2025-03-27 16:14:38 +01:00 committed by Alejandro Alonso
parent b6c4376217
commit 8a8d89dfc0
2 changed files with 15 additions and 3 deletions

View file

@ -5,9 +5,15 @@ use skia_safe as skia;
use std::collections::{HashMap, HashSet};
pub type Tile = (i32, i32);
pub type TileWithDistance = (i32, i32, i32);
pub const TILE_SIZE: f32 = 512.;
// @see https://en.wikipedia.org/wiki/Taxicab_geometry
pub fn manhattan_distance(a: (i32, i32), b: (i32, i32)) -> i32 {
(a.0 - b.0).abs() + (a.1 - b.1).abs()
}
pub fn get_tile_dimensions() -> skia::ISize {
(TILE_SIZE as i32, TILE_SIZE as i32).into()
}