mirror of
https://github.com/maplibre/maplibre-rs.git
synced 2025-12-08 19:05:57 +00:00
Move helper to util
This commit is contained in:
parent
aac5a2cc02
commit
8f57242d64
@ -1,49 +1,7 @@
|
||||
use crate::coords::WorldTileCoords;
|
||||
|
||||
struct MinMaxBoundingBox {
|
||||
min_x: i32,
|
||||
min_y: i32,
|
||||
max_x: i32,
|
||||
max_y: i32,
|
||||
initialized: bool,
|
||||
}
|
||||
|
||||
impl MinMaxBoundingBox {
|
||||
fn new() -> Self {
|
||||
Self {
|
||||
min_x: i32::MAX,
|
||||
min_y: i32::MAX,
|
||||
max_x: i32::MIN,
|
||||
max_y: i32::MIN,
|
||||
initialized: false,
|
||||
}
|
||||
}
|
||||
|
||||
pub fn is_initialized(&self) -> bool {
|
||||
self.initialized
|
||||
}
|
||||
|
||||
pub fn update(&mut self, world_coords: &WorldTileCoords) {
|
||||
self.initialized = true;
|
||||
|
||||
if world_coords.x < self.min_x {
|
||||
self.min_x = world_coords.x;
|
||||
}
|
||||
|
||||
if world_coords.y < self.min_y {
|
||||
self.min_y = world_coords.y;
|
||||
}
|
||||
|
||||
if world_coords.x > self.max_x {
|
||||
self.max_x = world_coords.x;
|
||||
}
|
||||
|
||||
if world_coords.y > self.max_y {
|
||||
self.max_y = world_coords.y;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// The tile mask pattern assigns each tile a value which can be used for stencil testing.
|
||||
/// The pattern can be reviewed [here](https://maxammann.org/mapr/docs/stencil-masking.html).
|
||||
pub struct TileMaskPattern {}
|
||||
|
||||
impl TileMaskPattern {
|
||||
|
||||
@ -3,4 +3,49 @@
|
||||
mod fps_meter;
|
||||
pub mod math;
|
||||
|
||||
use crate::coords::WorldTileCoords;
|
||||
pub use fps_meter::FPSMeter;
|
||||
|
||||
struct MinMaxBoundingBox {
|
||||
min_x: i32,
|
||||
min_y: i32,
|
||||
max_x: i32,
|
||||
max_y: i32,
|
||||
initialized: bool,
|
||||
}
|
||||
|
||||
impl MinMaxBoundingBox {
|
||||
fn new() -> Self {
|
||||
Self {
|
||||
min_x: i32::MAX,
|
||||
min_y: i32::MAX,
|
||||
max_x: i32::MIN,
|
||||
max_y: i32::MIN,
|
||||
initialized: false,
|
||||
}
|
||||
}
|
||||
|
||||
pub fn is_initialized(&self) -> bool {
|
||||
self.initialized
|
||||
}
|
||||
|
||||
pub fn update(&mut self, world_coords: &WorldTileCoords) {
|
||||
self.initialized = true;
|
||||
|
||||
if world_coords.x < self.min_x {
|
||||
self.min_x = world_coords.x;
|
||||
}
|
||||
|
||||
if world_coords.y < self.min_y {
|
||||
self.min_y = world_coords.y;
|
||||
}
|
||||
|
||||
if world_coords.x > self.max_x {
|
||||
self.max_x = world_coords.x;
|
||||
}
|
||||
|
||||
if world_coords.y > self.max_y {
|
||||
self.max_y = world_coords.y;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user