Render tile 0,0,0

This commit is contained in:
Maximilian Ammann 2022-01-23 22:06:47 +01:00
parent e6f3b180f4
commit 1d2f619bdc
3 changed files with 30 additions and 13 deletions

View File

@ -47,9 +47,17 @@ impl From<(u32, u32, u8)> for TileCoords {
impl From<WorldTileCoords> for TileCoords {
fn from(world_coords: WorldTileCoords) -> Self {
let mut tile_x = world_coords.x + crate::example::MUNICH_X as i32;
let mut tile_y = world_coords.y + crate::example::MUNICH_Y as i32;
if tile_x < 0 {
tile_x = 0;
}
if tile_y < 0 {
tile_y = 0;
}
TileCoords {
x: (world_coords.x + crate::example::MUNICH_X as i32) as u32,
y: (world_coords.y + crate::example::MUNICH_Y as i32) as u32,
x: tile_x as u32,
y: tile_y as u32,
z: world_coords.z,
}
}

View File

@ -1,8 +1,8 @@
use crate::io::worker_loop::WorkerLoop;
pub const MUNICH_X: u32 = 17425;
pub const MUNICH_Y: u32 = 11365;
pub const MUNICH_Z: u8 = 15;
pub const MUNICH_X: u32 = 0;
pub const MUNICH_Y: u32 = 0;
pub const MUNICH_Z: u8 = 0;
pub fn fetch_munich_tiles(worker_loop: &mut WorkerLoop) {
// This size matches the amount of tiles which are loaded on zoom 15 on FHD

View File

@ -3,6 +3,7 @@ use std::default::Default;
use std::{cmp, iter};
use crate::coords::{TileCoords, WorldCoords, WorldTileCoords};
use crate::example;
use wgpu::{Buffer, Limits, Queue};
use winit::dpi::PhysicalSize;
use winit::window::Window;
@ -258,7 +259,7 @@ impl RenderState {
};
let camera = camera::Camera::new(
(0.0, 5.0, 5000.0),
(0.0, 0.0, 5000.0),
cgmath::Deg(-90.0),
cgmath::Deg(0.0),
size.width,
@ -352,17 +353,17 @@ impl RenderState {
pub fn upload_tile_geometry(&mut self, worker_loop: &mut WorkerLoop) {
if let Some(view_box) = self.camera.view_bounding_box(&self.perspective) {
/*let view_box = self.camera.view_bounding_box2(&self.perspective).unwrap();*/
let min_world: WorldCoords = Point3::new(view_box.min.x, view_box.min.y, 15.0).into();
let min_world: WorldCoords = Point3::new(view_box.min.x, view_box.min.y, 0.0).into();
let min_world_tile: WorldTileCoords = min_world.into();
let min_tile: TileCoords = min_world_tile.into();
let max_world: WorldCoords = Point3::new(view_box.max.x, view_box.max.y, 15.0).into();
let max_world: WorldCoords = Point3::new(view_box.max.x, view_box.max.y, 0.0).into();
let max_world_tile: WorldTileCoords = max_world.into();
let max_tile: TileCoords = max_world_tile.into();
for x in min_tile.x..max_tile.x + 1 {
for y in min_tile.y..max_tile.y + 1 {
let to_be_fetched = (x, y, 15).into();
let z = example::MUNICH_Z;
let to_be_fetched = (x, y, z).into();
if !worker_loop.try_is_loaded(&to_be_fetched) {
// FIXME: is_loaded is not correct right now
worker_loop.try_fetch(to_be_fetched);
@ -374,6 +375,14 @@ impl RenderState {
let upload = worker_loop.pop_all();
for layer in upload.iter() {
match layer.layer_data.name() {
"boundary" => {}
"water" => {}
_ => {
continue;
}
};
let world_coords = layer.coords.into_world_tile();
self.tile_mask_pattern.update_bounds(&world_coords);
@ -385,11 +394,11 @@ impl RenderState {
.flat_map(|(i, _feature)| {
iter::repeat(ShaderFeatureStyle {
color: match layer.layer_data.name() {
"transportation" => [1.0, 0.0, 0.0, 1.0],
"building" => [0.0, 1.0, 1.0, 1.0],
//"transportation" => [1.0, 0.0, 0.0, 1.0],
//"building" => [0.0, 1.0, 1.0, 1.0],
"boundary" => [0.0, 0.0, 0.0, 1.0],
"water" => [0.0, 0.0, 0.7, 1.0],
"waterway" => [0.0, 0.0, 1.0, 1.0],
//"waterway" => [0.0, 0.0, 1.0, 1.0],
_ => [0.0, 0.0, 0.0, 0.0],
},
})