Fix typo in tessellate

This commit is contained in:
Maximilian Ammann 2022-03-07 14:57:27 +01:00
parent ff80bea405
commit 30c4f93249
12 changed files with 60 additions and 51 deletions

View File

@ -109,7 +109,7 @@ name = "desktop"
crate-type = ["bin"]
[[bench]]
name = "tesselation"
name = "tessellation"
harness = false
[package.metadata.android]

View File

@ -2,13 +2,13 @@ use criterion::{criterion_group, criterion_main, Criterion};
use lyon::tessellation::VertexBuffers;
use mapr::io::static_tile_fetcher::StaticTileFetcher;
use mapr::io::{HttpFetcherConfig, TileFetcher};
use mapr::tesselation::Tesselated;
use mapr::tessellation::Tessellated;
use std::io::Cursor;
use vector_tile::parse_tile_reader;
use vector_tile::tile::Layer;
fn tessselate(layer: &Layer) {
let _: (VertexBuffers<_, u32>, _) = layer.tesselate().unwrap();
let _: (VertexBuffers<_, u32>, _) = layer.tessellate().unwrap();
}
fn tile1(c: &mut Criterion) {

View File

@ -6,7 +6,7 @@
coordinates ([Plot](https://en.wikipedia.org/wiki/IEEE_754#/media/File:IEEE754.svg))
* [Perils of World Space](https://paroj.github.io/gltut/Positioning/Tut07%20The%20Perils%20of%20World%20Space.html)
### Create paths for tesselating streets
### Create paths for tessellating streets
Streets can have unusual shaped like shown [here](https://www.google.de/maps/@48.1353883,11.5717232,19z) in Munich. OSM
does not offer such data and therefore just renders an ordinary street contour like

View File

@ -3,18 +3,27 @@
## Next Major Goals
* Improve buffer_pool eviction rules
* Use MPI: https://doc.rust-lang.org/book/ch16-02-message-passing.html
* Input-handling via events and functional pipelines
* Show old tiles until new tile is ready
* Show old tiles until new tile is ready / Show mixed tiles, based on availability
* Use a simple style definition
* type: background/fill/line
* minzoom/maxzoom
* source
* source-layer
* paint (fill-color)
* Map feeling:
* Wrap world around in x direction
* Limit panning in y direction
* Nicer default map style
* Nicer default map style
## Intermediate Goals
* Support multiple projections? PoC such that we are sure the renderer is acceptable
## Future Goals
* Very simple text rendering
* Cache tesselation results
* Cache tessellation results
* We have three "caches": downloaded tiles, tessellated tiles, gpu tiles
* Handle missing tiles
* Support different tile raster addressing
* Support multiple projections?

View File

@ -88,12 +88,12 @@ Projects:
* [Multi-channel signed distance field generator](https://github.com/Chlumsky/msdfgen)
* [MSDF font atlas generator ](https://github.com/Chlumsky/msdf-atlas-gen)
## Tesselation
## Tessellation
Projects:
* [earcutr](https://github.com/donbright/earcutr)
* [Line Tesselation in MapLibre](https://github.com/maplibre/maplibre-gl-js/blob/main/src/data/bucket/line_bucket.ts)
* [Line Tessellation in MapLibre](https://github.com/maplibre/maplibre-gl-js/blob/main/src/data/bucket/line_bucket.ts)
## Render Graphs

View File

@ -11,33 +11,33 @@ use vector_tile::tile::Layer;
use crate::io::web_tile_fetcher::WebTileFetcher;
use crate::io::{HttpFetcherConfig, TileFetcher};
use crate::render::ShaderVertex;
use crate::tesselation::{IndexDataType, OverAlignedVertexBuffer, Tesselated};
use crate::tessellation::{IndexDataType, OverAlignedVertexBuffer, Tessellated};
use std::collections::btree_map::Entry;
#[derive(Clone)]
pub enum TesselationResult {
pub enum TessellationResult {
Unavailable(EmptyLayer),
TesselatedLayer(TesselatedLayer),
TessellatedLayer(TessellatedLayer),
}
impl TesselationResult {
impl TessellationResult {
pub fn get_tile_coords(&self) -> TileCoords {
match self {
TesselationResult::Unavailable(result) => result.coords,
TesselationResult::TesselatedLayer(result) => result.coords,
TessellationResult::Unavailable(result) => result.coords,
TessellationResult::TessellatedLayer(result) => result.coords,
}
}
pub fn layer_name(&self) -> &str {
match self {
TesselationResult::Unavailable(result) => result.layer_name.as_str(),
TesselationResult::TesselatedLayer(result) => result.layer_data.name(),
TessellationResult::Unavailable(result) => result.layer_name.as_str(),
TessellationResult::TessellatedLayer(result) => result.layer_data.name(),
}
}
}
#[derive(Clone)]
pub struct TesselatedLayer {
pub struct TessellatedLayer {
pub coords: TileCoords,
pub buffer: OverAlignedVertexBuffer<ShaderVertex, IndexDataType>,
/// Holds for each feature the count of indices
@ -52,7 +52,7 @@ pub struct EmptyLayer {
}
pub struct TileResultStore {
store: Mutex<BTreeMap<TileCoords, Vec<TesselationResult>>>,
store: Mutex<BTreeMap<TileCoords, Vec<TessellationResult>>>,
}
impl TileResultStore {
@ -62,7 +62,7 @@ impl TileResultStore {
}
}
fn push(&self, result: TesselationResult) -> bool {
fn push(&self, result: TessellationResult) -> bool {
if let Ok(mut map) = self.store.lock() {
match map.entry(result.get_tile_coords()) {
Entry::Vacant(entry) => {
@ -78,11 +78,11 @@ impl TileResultStore {
}
}
fn get_tesselated_layers_at(
fn get_tessellated_layers_at(
&self,
coords: &TileCoords,
skip_layers: &Vec<String>,
) -> Vec<TesselationResult> {
) -> Vec<TessellationResult> {
let mut ret = Vec::new();
if let Ok(map) = self.store.try_lock() {
if let Some(results) = map.get(coords) {
@ -97,18 +97,18 @@ impl TileResultStore {
ret
}
fn get_missing_tesselated_layer_names_at(
fn get_missing_tessellated_layer_names_at(
&self,
coords: &TileCoords,
layers: &Vec<String>,
) -> Vec<String> {
if let Ok(loaded) = self.store.try_lock() {
if let Some(tesselated_layers) = loaded.get(coords) {
if let Some(tessellated_layers) = loaded.get(coords) {
let mut result = Vec::new();
for layer in layers {
if tesselated_layers
if tessellated_layers
.iter()
.find(|tesselated_layer| tesselated_layer.layer_name() == layer)
.find(|tessellated_layer| tessellated_layer.layer_name() == layer)
.is_none()
{
result.push(layer.clone());
@ -159,7 +159,7 @@ impl WorkerLoop {
let missing_layers = self
.tile_result_store
.get_missing_tesselated_layer_names_at(&coords, &layers);
.get_missing_tessellated_layer_names_at(&coords, &layers);
if missing_layers.is_empty() {
return;
@ -170,13 +170,13 @@ impl WorkerLoop {
}
}
pub fn get_tesselated_layers_at(
pub fn get_tessellated_layers_at(
&self,
coords: &TileCoords,
skip_layers: &Vec<String>,
) -> Vec<TesselationResult> {
) -> Vec<TessellationResult> {
self.tile_result_store
.get_tesselated_layers_at(coords, skip_layers)
.get_tessellated_layers_at(coords, skip_layers)
}
pub async fn run_loop(&mut self) {
@ -198,9 +198,9 @@ impl WorkerLoop {
.iter()
.find(|layer| to_load.as_str() == layer.name())
{
if let Some((buffer, feature_indices)) = layer.tesselate() {
if let Some((buffer, feature_indices)) = layer.tessellate() {
self.tile_result_store.push(
TesselationResult::TesselatedLayer(TesselatedLayer {
TessellationResult::TessellatedLayer(TessellatedLayer {
coords,
buffer: buffer.into(),
feature_indices,

View File

@ -11,4 +11,4 @@ pub mod io;
pub mod main_loop;
// Used for benchmarking
pub mod tesselation;
pub mod tessellation;

View File

@ -9,7 +9,7 @@ use wgpu::BufferAddress;
use crate::coords::TileCoords;
use crate::render::shaders::ShaderTileMetadata;
use crate::tesselation::OverAlignedVertexBuffer;
use crate::tessellation::OverAlignedVertexBuffer;
pub trait Queue<B> {
fn write_buffer(&self, buffer: &B, offset: wgpu::BufferAddress, data: &[u8]);

View File

@ -11,5 +11,5 @@ mod tile_mask_pattern;
pub mod camera;
pub mod render_state;
// These are created during tesselation and must be public
// These are created during tessellation and must be public
pub use shaders::ShaderVertex;

View File

@ -7,7 +7,7 @@ use wgpu::{Buffer, Limits, Queue};
use winit::dpi::PhysicalSize;
use winit::window::Window;
use crate::io::worker_loop::{TesselationResult, TileRequest, WorkerLoop};
use crate::io::worker_loop::{TessellationResult, TileRequest, WorkerLoop};
use crate::platform::{COLOR_TEXTURE_FORMAT, MIN_BUFFER_SIZE};
use crate::render::buffer_pool::{BackingBufferDescriptor, BufferPool};
use crate::render::camera;
@ -16,7 +16,7 @@ use crate::render::options::{
TILE_META_COUNT, VERTEX_BUFFER_SIZE,
};
use crate::render::tile_mask_pattern::TileMaskPattern;
use crate::tesselation::IndexDataType;
use crate::tessellation::IndexDataType;
use crate::util::math::Aabb2;
use crate::util::FPSMeter;
@ -390,11 +390,11 @@ impl RenderState {
for tile_coords in view_region.iter() {
let loaded_layers = self.buffer_pool.get_loaded_layers(&tile_coords);
let layers = worker_loop.get_tesselated_layers_at(&tile_coords, &loaded_layers);
let layers = worker_loop.get_tessellated_layers_at(&tile_coords, &loaded_layers);
for result in layers {
match result {
TesselationResult::Unavailable(_) => {}
TesselationResult::TesselatedLayer(layer) => {
TessellationResult::Unavailable(_) => {}
TessellationResult::TessellatedLayer(layer) => {
let world_coords = layer.coords.into_world_tile();
let feature_metadata = layer

View File

@ -15,10 +15,10 @@ use vector_tile::geometry::{Command, Geometry};
use vector_tile::tile::Layer;
use crate::render::ShaderVertex;
use crate::tesselation::{Tesselated, VertexConstructor, DEFAULT_TOLERANCE};
use crate::tessellation::{Tessellated, VertexConstructor, DEFAULT_TOLERANCE};
impl<I: Add + From<lyon::lyon_tessellation::VertexId> + MaxIndex + Pod> Tesselated<I> for Layer {
fn tesselate(&self) -> Option<(VertexBuffers<ShaderVertex, I>, Vec<u32>)> {
impl<I: Add + From<lyon::lyon_tessellation::VertexId> + MaxIndex + Pod> Tessellated<I> for Layer {
fn tessellate(&self) -> Option<(VertexBuffers<ShaderVertex, I>, Vec<u32>)> {
let mut buffer: VertexBuffers<ShaderVertex, I> = VertexBuffers::new();
let mut feature_indices: Vec<u32> = Vec::new();
let mut current_index = 0;
@ -46,8 +46,8 @@ impl<I: Add + From<lyon::lyon_tessellation::VertexId> + MaxIndex + Pod> Tesselat
};
}
let mut fill_tesselator = FillTessellator::new();
fill_tesselator
let mut fill_tessellator = FillTessellator::new();
fill_tessellator
.tessellate_path(
&polygon_builder.build(),
&FillOptions::tolerance(DEFAULT_TOLERANCE)
@ -87,9 +87,9 @@ impl<I: Add + From<lyon::lyon_tessellation::VertexId> + MaxIndex + Pod> Tesselat
line_string_builder.end(false);
}
let mut stroke_tesselator = StrokeTessellator::new();
let mut stroke_tessellator = StrokeTessellator::new();
stroke_tesselator
stroke_tessellator
.tessellate_path(
&line_string_builder.build(),
&StrokeOptions::tolerance(DEFAULT_TOLERANCE),

View File

@ -1,4 +1,4 @@
//! Tesselation for lines and polygons is implemented here.
//! Tessellation for lines and polygons is implemented here.
use bytemuck::Pod;
use std::ops::Add;
@ -16,11 +16,11 @@ const DEFAULT_TOLERANCE: f32 = 0.02;
pub type IndexDataType = u16; // Must match INDEX_FORMAT
pub trait Tesselated<I: Add> {
pub trait Tessellated<I: Add> {
/// Returns a vertex buffer which represents some object like a layer. Each object can contain
/// multiple features. For each feature also the amount of indices is returned.
///
fn tesselate(&self) -> Option<(VertexBuffers<ShaderVertex, I>, Vec<u32>)>;
fn tessellate(&self) -> Option<(VertexBuffers<ShaderVertex, I>, Vec<u32>)>;
}
pub struct VertexConstructor {}