From 8220c651a40bb50f69fab539bdb437b09f1b5000 Mon Sep 17 00:00:00 2001 From: gibbz00 Date: Mon, 12 Jun 2023 13:08:11 +0200 Subject: [PATCH 01/13] Seperate out color handling. --- src/lib.rs | 13 ++++++------- src/line_string.rs | 4 +--- 2 files changed, 7 insertions(+), 10 deletions(-) diff --git a/src/lib.rs b/src/lib.rs index cc88fed..f7fca70 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -1,14 +1,14 @@ -use std::num::TryFromIntError; use bevy::prelude::*; use geo::algorithm::coords_iter::CoordsIter; +use std::num::TryFromIntError; mod line_string; mod point; pub enum PreparedMesh { Point(Vec), - LineString { mesh: Mesh, color: Color }, - Polygon { mesh: Mesh, color: Color }, + LineString { mesh: Mesh }, + Polygon { mesh: Mesh }, } type Vertex = [f32; 3]; // [x, y, z] @@ -42,7 +42,6 @@ pub struct BuildBevyMeshesContext { pub fn build_bevy_meshes( geo: &G, - color: Color, ) -> Result, TryFromIntError> { let mut ctx = BuildBevyMeshesContext::default(); @@ -51,11 +50,11 @@ pub fn build_bevy_meshes( info_span!("Building Bevy meshes").in_scope(|| { Ok([ ctx.point_mesh_builder.build(), - ctx.line_string_mesh_builder.build(color), + ctx.line_string_mesh_builder.build(), ctx.polygon_mesh_builder .build() - .map(|mesh| PreparedMesh::Polygon { mesh, color }), - ctx.polygon_border_mesh_builder.build(Color::BLACK), + .map(|mesh| PreparedMesh::Polygon { mesh }), + ctx.polygon_border_mesh_builder.build(), ] .into_iter() .flatten()) diff --git a/src/line_string.rs b/src/line_string.rs index 94db32c..1f99ee4 100644 --- a/src/line_string.rs +++ b/src/line_string.rs @@ -1,5 +1,4 @@ use crate::Vertex; -use bevy::prelude::Color; use std::num; #[derive(Default)] @@ -29,7 +28,7 @@ impl LineStringMeshBuilder { Ok(()) } - pub fn build(self, color: Color) -> Option { + pub fn build(self) -> Option { if self.vertices.is_empty() { None } else { @@ -39,7 +38,6 @@ impl LineStringMeshBuilder { self.vertices, self.indices, ), - color, }) } } From 17a589d1c440ad87a559ad57e1ecf39599905967 Mon Sep 17 00:00:00 2001 From: gibbz00 Date: Mon, 12 Jun 2023 15:38:27 +0200 Subject: [PATCH 02/13] Pass exterior/interior ring(s) meshes with the polygon mesh: Makes it possible to distinguish them from regular line strings. --- src/lib.rs | 32 ++++++++++++++++---------------- src/line_string.rs | 22 ++++++++++++++-------- src/point.rs | 4 +++- src/polygon.rs | 42 ++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 75 insertions(+), 25 deletions(-) create mode 100644 src/polygon.rs diff --git a/src/lib.rs b/src/lib.rs index f7fca70..49b971e 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -4,11 +4,18 @@ use std::num::TryFromIntError; mod line_string; mod point; +mod polygon; pub enum PreparedMesh { Point(Vec), - LineString { mesh: Mesh }, - Polygon { mesh: Mesh }, + LineString { + mesh: Mesh, + }, + Polygon { + polygon_mesh: Mesh, + exterior_mesh: Mesh, + interior_meshes: Vec, + }, } type Vertex = [f32; 3]; // [x, y, z] @@ -32,12 +39,15 @@ fn build_mesh_from_vertices( mesh } +trait BuildMesh { + fn build(self) -> Option; +} + #[derive(Default)] pub struct BuildBevyMeshesContext { point_mesh_builder: point::PointMeshBuilder, line_string_mesh_builder: line_string::LineStringMeshBuilder, - polygon_mesh_builder: bevy_earcutr::PolygonMeshBuilder, - polygon_border_mesh_builder: line_string::LineStringMeshBuilder, + polygon_mesh_builder: polygon::PolygonMeshBuilder, } pub fn build_bevy_meshes( @@ -51,10 +61,7 @@ pub fn build_bevy_meshes( Ok([ ctx.point_mesh_builder.build(), ctx.line_string_mesh_builder.build(), - ctx.polygon_mesh_builder - .build() - .map(|mesh| PreparedMesh::Polygon { mesh }), - ctx.polygon_border_mesh_builder.build(), + ctx.polygon_mesh_builder.build(), ] .into_iter() .flatten()) @@ -91,14 +98,7 @@ impl BuildBevyMeshes for geo::Polygon { &self, ctx: &mut BuildBevyMeshesContext, ) -> Result<(), TryFromIntError> { - ctx.polygon_mesh_builder - .add_earcutr_input(polygon_to_earcutr_input(self)); - ctx.polygon_border_mesh_builder - .add_line_string(self.exterior())?; - for interior in self.interiors() { - ctx.polygon_border_mesh_builder.add_line_string(interior)?; - } - Ok(()) + ctx.polygon_mesh_builder.add_polygon_components(self) } } diff --git a/src/line_string.rs b/src/line_string.rs index 1f99ee4..47b071e 100644 --- a/src/line_string.rs +++ b/src/line_string.rs @@ -27,18 +27,24 @@ impl LineStringMeshBuilder { } Ok(()) } +} + +impl From for bevy::prelude::Mesh { + fn from(line_string_builder: LineStringMeshBuilder) -> Self { + crate::build_mesh_from_vertices( + bevy::render::render_resource::PrimitiveTopology::LineList, + line_string_builder.vertices, + line_string_builder.indices, + ) + } +} - pub fn build(self) -> Option { +impl crate::BuildMesh for LineStringMeshBuilder { + fn build(self) -> Option { if self.vertices.is_empty() { None } else { - Some(crate::PreparedMesh::LineString { - mesh: crate::build_mesh_from_vertices( - bevy::render::render_resource::PrimitiveTopology::LineList, - self.vertices, - self.indices, - ), - }) + Some(crate::PreparedMesh::LineString { mesh: self.into() }) } } } diff --git a/src/point.rs b/src/point.rs index a1aa3ba..bb622b8 100644 --- a/src/point.rs +++ b/src/point.rs @@ -11,8 +11,10 @@ impl PointMeshBuilder { self.points.push(*point); Ok(()) } +} - pub fn build(self) -> Option { +impl crate::BuildMesh for PointMeshBuilder { + fn build(self) -> Option { if self.points.is_empty() { None } else { diff --git a/src/polygon.rs b/src/polygon.rs new file mode 100644 index 0000000..b9e1d2d --- /dev/null +++ b/src/polygon.rs @@ -0,0 +1,42 @@ +use crate::{line_string::LineStringMeshBuilder, PreparedMesh}; + +#[derive(Default)] +pub struct PolygonMeshBuilder { + polygon: bevy_earcutr::PolygonMeshBuilder, + exterior: LineStringMeshBuilder, + interiors: Vec, +} + +impl PolygonMeshBuilder { + pub fn add_polygon_components( + &mut self, + polygon: &geo::Polygon, + ) -> Result<(), std::num::TryFromIntError> { + self.polygon + .add_earcutr_input(crate::polygon_to_earcutr_input(polygon)); + self.exterior.add_line_string(polygon.exterior())?; + for interior in polygon.interiors() { + let mut interior_line_string_builder = LineStringMeshBuilder::default(); + interior_line_string_builder.add_line_string(interior)?; + self.interiors.push(interior_line_string_builder); + } + + Ok(()) + } +} + +impl crate::BuildMesh for PolygonMeshBuilder { + fn build(self) -> Option { + self.polygon + .build() + .map(|polygon_mesh| PreparedMesh::Polygon { + polygon_mesh, + exterior_mesh: self.exterior.into(), + interior_meshes: self + .interiors + .into_iter() + .map(|interior_builder| interior_builder.into()) + .collect(), + }) + } +} From a8ec0dac8ec5fde912171fa947d89d418cddc5b6 Mon Sep 17 00:00:00 2001 From: gibbz00 Date: Mon, 12 Jun 2023 15:47:53 +0200 Subject: [PATCH 03/13] Move line string mesh building logic to `linestring.rs` --- src/lib.rs | 21 --------------------- src/line_string.rs | 25 ++++++++++++++++++------- 2 files changed, 18 insertions(+), 28 deletions(-) diff --git a/src/lib.rs b/src/lib.rs index 49b971e..6f07c6a 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -18,27 +18,6 @@ pub enum PreparedMesh { }, } -type Vertex = [f32; 3]; // [x, y, z] - -fn build_mesh_from_vertices( - primitive_topology: bevy::render::render_resource::PrimitiveTopology, - vertices: Vec, - indices: Vec, -) -> Mesh { - let num_vertices = vertices.len(); - let mut mesh = Mesh::new(primitive_topology); - mesh.set_indices(Some(bevy::render::mesh::Indices::U32(indices))); - mesh.insert_attribute(Mesh::ATTRIBUTE_POSITION, vertices); - - let normals = vec![[0.0, 0.0, 0.0]; num_vertices]; - let uvs = vec![[0.0, 0.0]; num_vertices]; - - mesh.insert_attribute(Mesh::ATTRIBUTE_NORMAL, normals); - mesh.insert_attribute(Mesh::ATTRIBUTE_UV_0, uvs); - - mesh -} - trait BuildMesh { fn build(self) -> Option; } diff --git a/src/line_string.rs b/src/line_string.rs index 47b071e..b6e8fac 100644 --- a/src/line_string.rs +++ b/src/line_string.rs @@ -1,6 +1,8 @@ -use crate::Vertex; +use bevy::prelude::Mesh; use std::num; +type Vertex = [f32; 3]; // [x, y, z] + #[derive(Default)] pub struct LineStringMeshBuilder { vertices: Vec, @@ -29,13 +31,22 @@ impl LineStringMeshBuilder { } } -impl From for bevy::prelude::Mesh { +impl From for Mesh { fn from(line_string_builder: LineStringMeshBuilder) -> Self { - crate::build_mesh_from_vertices( - bevy::render::render_resource::PrimitiveTopology::LineList, - line_string_builder.vertices, - line_string_builder.indices, - ) + let vertices = line_string_builder.vertices; + let indices = line_string_builder.indices; + let num_vertices = vertices.len(); + let mut mesh = Mesh::new(bevy::render::render_resource::PrimitiveTopology::LineList); + mesh.set_indices(Some(bevy::render::mesh::Indices::U32(indices))); + mesh.insert_attribute(Mesh::ATTRIBUTE_POSITION, vertices); + + let normals = vec![[0.0, 0.0, 0.0]; num_vertices]; + let uvs = vec![[0.0, 0.0]; num_vertices]; + + mesh.insert_attribute(Mesh::ATTRIBUTE_NORMAL, normals); + mesh.insert_attribute(Mesh::ATTRIBUTE_UV_0, uvs); + + mesh } } From da3e4a202c51b0ad5ed79bdeeb5c708b5b6ab55a Mon Sep 17 00:00:00 2001 From: gibbz00 Date: Mon, 12 Jun 2023 15:53:11 +0200 Subject: [PATCH 04/13] Move polygon mesh building logic to `polygon.rs` --- src/lib.rs | 27 --------------------------- src/polygon.rs | 29 ++++++++++++++++++++++++++++- 2 files changed, 28 insertions(+), 28 deletions(-) diff --git a/src/lib.rs b/src/lib.rs index 6f07c6a..cb2f676 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -1,5 +1,4 @@ use bevy::prelude::*; -use geo::algorithm::coords_iter::CoordsIter; use std::num::TryFromIntError; mod line_string; @@ -176,29 +175,3 @@ impl BuildBevyMeshes for geo::GeometryCollection { Ok(()) } } - -fn polygon_to_earcutr_input(polygon: &geo::Polygon) -> bevy_earcutr::EarcutrInput { - let mut vertices = Vec::with_capacity(polygon.coords_count() * 2); - let mut interior_indices = Vec::with_capacity(polygon.interiors().len()); - debug_assert!(polygon.exterior().0.len() >= 4); - - flat_line_string_coords_2(polygon.exterior(), &mut vertices); - - for interior in polygon.interiors() { - debug_assert!(interior.0.len() >= 4); - interior_indices.push(vertices.len() / 2); - flat_line_string_coords_2(interior, &mut vertices); - } - - bevy_earcutr::EarcutrInput { - vertices, - interior_indices, - } -} - -fn flat_line_string_coords_2(line_string: &geo::LineString, vertices: &mut Vec) { - for coord in &line_string.0 { - vertices.push(coord.x); - vertices.push(coord.y); - } -} diff --git a/src/polygon.rs b/src/polygon.rs index b9e1d2d..0d5003a 100644 --- a/src/polygon.rs +++ b/src/polygon.rs @@ -1,4 +1,5 @@ use crate::{line_string::LineStringMeshBuilder, PreparedMesh}; +use geo::algorithm::coords_iter::CoordsIter; #[derive(Default)] pub struct PolygonMeshBuilder { @@ -13,7 +14,7 @@ impl PolygonMeshBuilder { polygon: &geo::Polygon, ) -> Result<(), std::num::TryFromIntError> { self.polygon - .add_earcutr_input(crate::polygon_to_earcutr_input(polygon)); + .add_earcutr_input(Self::polygon_to_earcutr_input(polygon)); self.exterior.add_line_string(polygon.exterior())?; for interior in polygon.interiors() { let mut interior_line_string_builder = LineStringMeshBuilder::default(); @@ -23,6 +24,32 @@ impl PolygonMeshBuilder { Ok(()) } + + fn polygon_to_earcutr_input(polygon: &geo::Polygon) -> bevy_earcutr::EarcutrInput { + let mut vertices = Vec::with_capacity(polygon.coords_count() * 2); + let mut interior_indices = Vec::with_capacity(polygon.interiors().len()); + debug_assert!(polygon.exterior().0.len() >= 4); + + Self::flat_line_string_coords_2(polygon.exterior(), &mut vertices); + + for interior in polygon.interiors() { + debug_assert!(interior.0.len() >= 4); + interior_indices.push(vertices.len() / 2); + Self::flat_line_string_coords_2(interior, &mut vertices); + } + + bevy_earcutr::EarcutrInput { + vertices, + interior_indices, + } + } + + fn flat_line_string_coords_2(line_string: &geo::LineString, vertices: &mut Vec) { + for coord in &line_string.0 { + vertices.push(coord.x); + vertices.push(coord.y); + } + } } impl crate::BuildMesh for PolygonMeshBuilder { From 60f5bc70284e394831da887d88b6f8f87f2e5547 Mon Sep 17 00:00:00 2001 From: gibbz00 Date: Mon, 12 Jun 2023 16:22:40 +0200 Subject: [PATCH 05/13] Bump version to 0.4. New color handling introduces breaking API changes. --- Cargo.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Cargo.toml b/Cargo.toml index 8310400..29cec50 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,7 +1,7 @@ [package] name = "geo-bevy" description = "Generate Bevy meshes from `geo` types" -version = "0.3.0" +version = "0.4.0" authors = ["Corey Farwell "] edition = "2021" repository = "https://github.com/frewsxcv/geo-bevy" From 376fa175d6cd6a78ba4f21d65c216bfbf56b32bd Mon Sep 17 00:00:00 2001 From: gibbz00 Date: Thu, 22 Jun 2023 22:24:30 +0200 Subject: [PATCH 06/13] Ability to build mesh for a specified geometry. --- Cargo.toml | 5 ++ src/lib.rs | 156 ++++++++++++++++++++++++++++++++------------- src/line_string.rs | 14 ++-- src/polygon.rs | 38 +++++++---- 4 files changed, 150 insertions(+), 63 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 29cec50..c81fc98 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -11,3 +11,8 @@ license = "MIT OR Apache-2.0" bevy-earcutr = "0.9" bevy = { version = "0.10", default-features = false, features = ["bevy_render"] } geo = "0.25" +geo-types = "0.7" + +[patch.crates-io] +# TEMP: https://github.com/georust/geo/pull/1020 is yet to included in a release. +geo-types = { git = "https://github.com/georust/geo" } diff --git a/src/lib.rs b/src/lib.rs index cb2f676..90af78d 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -1,39 +1,72 @@ -use bevy::prelude::*; +use crate::polygon::PolygonMesh; +use bevy::prelude::{info_span, Mesh}; +use geo_types::geometry::*; +use line_string::LineStringMeshBuilder; +use polygon::PolygonMeshBuilder; use std::num::TryFromIntError; mod line_string; mod point; mod polygon; -pub enum PreparedMesh { - Point(Vec), - LineString { - mesh: Mesh, - }, - Polygon { - polygon_mesh: Mesh, - exterior_mesh: Mesh, - interior_meshes: Vec, - }, +pub fn line_to_mesh(line: &Line) -> Result, TryFromIntError> { + line_string_to_mesh(&line.into()) } -trait BuildMesh { - fn build(self) -> Option; +pub fn line_string_to_mesh(line_string: &LineString) -> Result, TryFromIntError> { + let mut mesh_builder = LineStringMeshBuilder::default(); + mesh_builder.add_line_string(line_string)?; + Ok(mesh_builder.into()) } -#[derive(Default)] -pub struct BuildBevyMeshesContext { - point_mesh_builder: point::PointMeshBuilder, - line_string_mesh_builder: line_string::LineStringMeshBuilder, - polygon_mesh_builder: polygon::PolygonMeshBuilder, +pub fn multi_line_string_to_mesh( + multi_line_string: &MultiLineString, +) -> Result, TryFromIntError> { + let line_strings = &multi_line_string.0; + let mut line_string_meshes = Vec::with_capacity(line_strings.len()); + + for line_string in line_strings { + if let Some(line_string_mesh) = line_string_to_mesh(line_string)? { + line_string_meshes.push(line_string_mesh); + } + } + + Ok(line_string_meshes) +} + +pub fn polygon_to_mesh(polygon: &Polygon) -> Result, TryFromIntError> { + let mut mesh_builder = PolygonMeshBuilder::default(); + mesh_builder.add_polygon(polygon)?; + Ok(mesh_builder.into()) +} + +pub fn multi_polygon_to_mesh( + multi_polygon: &MultiPolygon, +) -> Result, TryFromIntError> { + let polygons = &multi_polygon.0; + let mut polygon_meshes = Vec::with_capacity(polygons.len()); + for polygon in polygons { + if let Some(polygon_mesh) = polygon_to_mesh(polygon)? { + polygon_meshes.push(polygon_mesh); + } + } + + Ok(polygon_meshes) +} + +pub fn rect_to_mesh(rect: &Rect) -> Result, TryFromIntError> { + polygon_to_mesh(&rect.to_polygon()) } -pub fn build_bevy_meshes( - geo: &G, -) -> Result, TryFromIntError> { +pub fn triangle_to_mesh(triangle: &Triangle) -> Result, TryFromIntError> { + polygon_to_mesh(&triangle.to_polygon()) +} + +pub fn geometry_to_mesh(geometry: &Geometry) -> Result, TryFromIntError> { let mut ctx = BuildBevyMeshesContext::default(); - info_span!("Populating Bevy mesh builder").in_scope(|| geo.populate_mesh_builders(&mut ctx))?; + info_span!("Populating Bevy mesh builder") + .in_scope(|| geometry.populate_mesh_builders(&mut ctx))?; info_span!("Building Bevy meshes").in_scope(|| { Ok([ @@ -42,10 +75,41 @@ pub fn build_bevy_meshes( ctx.polygon_mesh_builder.build(), ] .into_iter() - .flatten()) + .find(|prepared_mesh| prepared_mesh.is_some()) + .unwrap_or_default()) }) } +pub fn geometry_collection_to_mesh( + geometry_collection: &GeometryCollection, +) -> Result, TryFromIntError> { + let mut geometry_meshes = Vec::with_capacity(geometry_collection.len()); + for geometry in geometry_collection { + if let Some(geometry_mesh) = geometry_to_mesh(geometry)? { + geometry_meshes.push(geometry_mesh); + } + } + + Ok(geometry_meshes) +} + +pub enum PreparedMesh { + Point(Vec), + LineString { mesh: Mesh }, + Polygon(polygon::PolygonMesh), +} + +trait BuildMesh { + fn build(self) -> Option; +} + +#[derive(Default)] +pub struct BuildBevyMeshesContext { + point_mesh_builder: point::PointMeshBuilder, + line_string_mesh_builder: LineStringMeshBuilder, + polygon_mesh_builder: polygon::PolygonMeshBuilder, +} + pub trait BuildBevyMeshes { fn populate_mesh_builders( &self, @@ -53,7 +117,7 @@ pub trait BuildBevyMeshes { ) -> Result<(), TryFromIntError>; } -impl BuildBevyMeshes for geo::Point { +impl BuildBevyMeshes for Point { fn populate_mesh_builders( &self, ctx: &mut BuildBevyMeshesContext, @@ -62,7 +126,7 @@ impl BuildBevyMeshes for geo::Point { } } -impl BuildBevyMeshes for geo::LineString { +impl BuildBevyMeshes for LineString { fn populate_mesh_builders( &self, ctx: &mut BuildBevyMeshesContext, @@ -71,16 +135,16 @@ impl BuildBevyMeshes for geo::LineString { } } -impl BuildBevyMeshes for geo::Polygon { +impl BuildBevyMeshes for Polygon { fn populate_mesh_builders( &self, ctx: &mut BuildBevyMeshesContext, ) -> Result<(), TryFromIntError> { - ctx.polygon_mesh_builder.add_polygon_components(self) + ctx.polygon_mesh_builder.add_polygon(self) } } -impl BuildBevyMeshes for geo::MultiPoint { +impl BuildBevyMeshes for MultiPoint { fn populate_mesh_builders( &self, ctx: &mut BuildBevyMeshesContext, @@ -92,7 +156,7 @@ impl BuildBevyMeshes for geo::MultiPoint { } } -impl BuildBevyMeshes for geo::MultiLineString { +impl BuildBevyMeshes for MultiLineString { fn populate_mesh_builders( &self, ctx: &mut BuildBevyMeshesContext, @@ -104,7 +168,7 @@ impl BuildBevyMeshes for geo::MultiLineString { } } -impl BuildBevyMeshes for geo::MultiPolygon { +impl BuildBevyMeshes for MultiPolygon { fn populate_mesh_builders( &self, ctx: &mut BuildBevyMeshesContext, @@ -116,16 +180,16 @@ impl BuildBevyMeshes for geo::MultiPolygon { } } -impl BuildBevyMeshes for geo::Line { +impl BuildBevyMeshes for Line { fn populate_mesh_builders( &self, ctx: &mut BuildBevyMeshesContext, ) -> Result<(), TryFromIntError> { - geo::LineString::new(vec![self.start, self.end]).populate_mesh_builders(ctx) + LineString::from(self).populate_mesh_builders(ctx) } } -impl BuildBevyMeshes for geo::Triangle { +impl BuildBevyMeshes for Triangle { fn populate_mesh_builders( &self, ctx: &mut BuildBevyMeshesContext, @@ -134,7 +198,7 @@ impl BuildBevyMeshes for geo::Triangle { } } -impl BuildBevyMeshes for geo::Rect { +impl BuildBevyMeshes for Rect { fn populate_mesh_builders( &self, ctx: &mut BuildBevyMeshesContext, @@ -143,28 +207,28 @@ impl BuildBevyMeshes for geo::Rect { } } -impl BuildBevyMeshes for geo::Geometry { +impl BuildBevyMeshes for Geometry { fn populate_mesh_builders( &self, ctx: &mut BuildBevyMeshesContext, ) -> Result<(), TryFromIntError> { match self { - geo::Geometry::Point(g) => g.populate_mesh_builders(ctx)?, - geo::Geometry::Line(g) => g.populate_mesh_builders(ctx)?, - geo::Geometry::LineString(g) => g.populate_mesh_builders(ctx)?, - geo::Geometry::Polygon(g) => g.populate_mesh_builders(ctx)?, - geo::Geometry::MultiPoint(g) => g.populate_mesh_builders(ctx)?, - geo::Geometry::MultiLineString(g) => g.populate_mesh_builders(ctx)?, - geo::Geometry::MultiPolygon(g) => g.populate_mesh_builders(ctx)?, - geo::Geometry::GeometryCollection(g) => g.populate_mesh_builders(ctx)?, - geo::Geometry::Triangle(g) => g.populate_mesh_builders(ctx)?, - geo::Geometry::Rect(g) => g.populate_mesh_builders(ctx)?, + Geometry::Point(g) => g.populate_mesh_builders(ctx)?, + Geometry::Line(g) => g.populate_mesh_builders(ctx)?, + Geometry::LineString(g) => g.populate_mesh_builders(ctx)?, + Geometry::Polygon(g) => g.populate_mesh_builders(ctx)?, + Geometry::MultiPoint(g) => g.populate_mesh_builders(ctx)?, + Geometry::MultiLineString(g) => g.populate_mesh_builders(ctx)?, + Geometry::MultiPolygon(g) => g.populate_mesh_builders(ctx)?, + Geometry::GeometryCollection(g) => g.populate_mesh_builders(ctx)?, + Geometry::Triangle(g) => g.populate_mesh_builders(ctx)?, + Geometry::Rect(g) => g.populate_mesh_builders(ctx)?, }; Ok(()) } } -impl BuildBevyMeshes for geo::GeometryCollection { +impl BuildBevyMeshes for GeometryCollection { fn populate_mesh_builders( &self, ctx: &mut BuildBevyMeshesContext, diff --git a/src/line_string.rs b/src/line_string.rs index b6e8fac..634d31d 100644 --- a/src/line_string.rs +++ b/src/line_string.rs @@ -50,12 +50,18 @@ impl From for Mesh { } } -impl crate::BuildMesh for LineStringMeshBuilder { - fn build(self) -> Option { - if self.vertices.is_empty() { +impl From for Option { + fn from(line_string_mesh_builder: LineStringMeshBuilder) -> Self { + if line_string_mesh_builder.vertices.is_empty() { None } else { - Some(crate::PreparedMesh::LineString { mesh: self.into() }) + Some(line_string_mesh_builder.into()) } } } + +impl crate::BuildMesh for LineStringMeshBuilder { + fn build(self) -> Option { + Option::::from(self).map(|mesh| crate::PreparedMesh::LineString { mesh }) + } +} diff --git a/src/polygon.rs b/src/polygon.rs index 0d5003a..587ad45 100644 --- a/src/polygon.rs +++ b/src/polygon.rs @@ -1,5 +1,13 @@ use crate::{line_string::LineStringMeshBuilder, PreparedMesh}; -use geo::algorithm::coords_iter::CoordsIter; +use bevy::prelude::Mesh; +use geo::CoordsIter; +use geo_types::{LineString, Polygon}; + +pub struct PolygonMesh { + pub polygon_mesh: Mesh, + pub exterior_mesh: Mesh, + pub interior_meshes: Vec, +} #[derive(Default)] pub struct PolygonMeshBuilder { @@ -9,10 +17,7 @@ pub struct PolygonMeshBuilder { } impl PolygonMeshBuilder { - pub fn add_polygon_components( - &mut self, - polygon: &geo::Polygon, - ) -> Result<(), std::num::TryFromIntError> { + pub fn add_polygon(&mut self, polygon: &Polygon) -> Result<(), std::num::TryFromIntError> { self.polygon .add_earcutr_input(Self::polygon_to_earcutr_input(polygon)); self.exterior.add_line_string(polygon.exterior())?; @@ -25,7 +30,7 @@ impl PolygonMeshBuilder { Ok(()) } - fn polygon_to_earcutr_input(polygon: &geo::Polygon) -> bevy_earcutr::EarcutrInput { + fn polygon_to_earcutr_input(polygon: &Polygon) -> bevy_earcutr::EarcutrInput { let mut vertices = Vec::with_capacity(polygon.coords_count() * 2); let mut interior_indices = Vec::with_capacity(polygon.interiors().len()); debug_assert!(polygon.exterior().0.len() >= 4); @@ -44,7 +49,7 @@ impl PolygonMeshBuilder { } } - fn flat_line_string_coords_2(line_string: &geo::LineString, vertices: &mut Vec) { + fn flat_line_string_coords_2(line_string: &LineString, vertices: &mut Vec) { for coord in &line_string.0 { vertices.push(coord.x); vertices.push(coord.y); @@ -52,14 +57,15 @@ impl PolygonMeshBuilder { } } -impl crate::BuildMesh for PolygonMeshBuilder { - fn build(self) -> Option { - self.polygon +impl From for Option { + fn from(polygon_mesh_builder: PolygonMeshBuilder) -> Self { + polygon_mesh_builder + .polygon .build() - .map(|polygon_mesh| PreparedMesh::Polygon { + .map(|polygon_mesh| PolygonMesh { polygon_mesh, - exterior_mesh: self.exterior.into(), - interior_meshes: self + exterior_mesh: polygon_mesh_builder.exterior.into(), + interior_meshes: polygon_mesh_builder .interiors .into_iter() .map(|interior_builder| interior_builder.into()) @@ -67,3 +73,9 @@ impl crate::BuildMesh for PolygonMeshBuilder { }) } } + +impl crate::BuildMesh for PolygonMeshBuilder { + fn build(self) -> Option { + Option::::from(self).map(PreparedMesh::Polygon) + } +} From e8947a3c8d9a956e1bdd40e99b83dbc954ad7e75 Mon Sep 17 00:00:00 2001 From: gibbz00 Date: Thu, 22 Jun 2023 22:26:25 +0200 Subject: [PATCH 07/13] PreparedMesh -> GeometryMesh --- src/lib.rs | 8 ++++---- src/line_string.rs | 4 ++-- src/point.rs | 4 ++-- src/polygon.rs | 6 +++--- 4 files changed, 11 insertions(+), 11 deletions(-) diff --git a/src/lib.rs b/src/lib.rs index 90af78d..2740357 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -62,7 +62,7 @@ pub fn triangle_to_mesh(triangle: &Triangle) -> Result, TryF polygon_to_mesh(&triangle.to_polygon()) } -pub fn geometry_to_mesh(geometry: &Geometry) -> Result, TryFromIntError> { +pub fn geometry_to_mesh(geometry: &Geometry) -> Result, TryFromIntError> { let mut ctx = BuildBevyMeshesContext::default(); info_span!("Populating Bevy mesh builder") @@ -82,7 +82,7 @@ pub fn geometry_to_mesh(geometry: &Geometry) -> Result, Try pub fn geometry_collection_to_mesh( geometry_collection: &GeometryCollection, -) -> Result, TryFromIntError> { +) -> Result, TryFromIntError> { let mut geometry_meshes = Vec::with_capacity(geometry_collection.len()); for geometry in geometry_collection { if let Some(geometry_mesh) = geometry_to_mesh(geometry)? { @@ -93,14 +93,14 @@ pub fn geometry_collection_to_mesh( Ok(geometry_meshes) } -pub enum PreparedMesh { +pub enum GeometryMesh { Point(Vec), LineString { mesh: Mesh }, Polygon(polygon::PolygonMesh), } trait BuildMesh { - fn build(self) -> Option; + fn build(self) -> Option; } #[derive(Default)] diff --git a/src/line_string.rs b/src/line_string.rs index 634d31d..add6da8 100644 --- a/src/line_string.rs +++ b/src/line_string.rs @@ -61,7 +61,7 @@ impl From for Option { } impl crate::BuildMesh for LineStringMeshBuilder { - fn build(self) -> Option { - Option::::from(self).map(|mesh| crate::PreparedMesh::LineString { mesh }) + fn build(self) -> Option { + Option::::from(self).map(|mesh| crate::GeometryMesh::LineString { mesh }) } } diff --git a/src/point.rs b/src/point.rs index bb622b8..7619c12 100644 --- a/src/point.rs +++ b/src/point.rs @@ -14,11 +14,11 @@ impl PointMeshBuilder { } impl crate::BuildMesh for PointMeshBuilder { - fn build(self) -> Option { + fn build(self) -> Option { if self.points.is_empty() { None } else { - Some(crate::PreparedMesh::Point(self.points)) + Some(crate::GeometryMesh::Point(self.points)) } } } diff --git a/src/polygon.rs b/src/polygon.rs index 587ad45..063cf22 100644 --- a/src/polygon.rs +++ b/src/polygon.rs @@ -1,4 +1,4 @@ -use crate::{line_string::LineStringMeshBuilder, PreparedMesh}; +use crate::{line_string::LineStringMeshBuilder, GeometryMesh}; use bevy::prelude::Mesh; use geo::CoordsIter; use geo_types::{LineString, Polygon}; @@ -75,7 +75,7 @@ impl From for Option { } impl crate::BuildMesh for PolygonMeshBuilder { - fn build(self) -> Option { - Option::::from(self).map(PreparedMesh::Polygon) + fn build(self) -> Option { + Option::::from(self).map(GeometryMesh::Polygon) } } From 903878d73d7410ba0885057219eb794051e0e8f2 Mon Sep 17 00:00:00 2001 From: gibbz00 Date: Thu, 22 Jun 2023 22:31:25 +0200 Subject: [PATCH 08/13] Place mesh building traits and implementations in a separate file. --- src/build_mesh.rs | 143 +++++++++++++++++++++++++++++++++++++++++++ src/lib.rs | 148 ++------------------------------------------- src/line_string.rs | 2 +- src/point.rs | 2 +- src/polygon.rs | 2 +- 5 files changed, 151 insertions(+), 146 deletions(-) create mode 100644 src/build_mesh.rs diff --git a/src/build_mesh.rs b/src/build_mesh.rs new file mode 100644 index 0000000..64c2ba0 --- /dev/null +++ b/src/build_mesh.rs @@ -0,0 +1,143 @@ +use geo_types::*; +use std::num::TryFromIntError; + +pub trait BuildMesh { + fn build(self) -> Option; +} + +#[derive(Default)] +pub struct BuildBevyMeshesContext { + pub point_mesh_builder: crate::point::PointMeshBuilder, + pub line_string_mesh_builder: crate::line_string::LineStringMeshBuilder, + pub polygon_mesh_builder: crate::polygon::PolygonMeshBuilder, +} + +pub trait BuildBevyMeshes { + fn populate_mesh_builders( + &self, + ctx: &mut BuildBevyMeshesContext, + ) -> Result<(), TryFromIntError>; +} + +impl BuildBevyMeshes for Point { + fn populate_mesh_builders( + &self, + ctx: &mut BuildBevyMeshesContext, + ) -> Result<(), TryFromIntError> { + ctx.point_mesh_builder.add_point(self) + } +} + +impl BuildBevyMeshes for LineString { + fn populate_mesh_builders( + &self, + ctx: &mut BuildBevyMeshesContext, + ) -> Result<(), TryFromIntError> { + ctx.line_string_mesh_builder.add_line_string(self) + } +} + +impl BuildBevyMeshes for Polygon { + fn populate_mesh_builders( + &self, + ctx: &mut BuildBevyMeshesContext, + ) -> Result<(), TryFromIntError> { + ctx.polygon_mesh_builder.add_polygon(self) + } +} + +impl BuildBevyMeshes for MultiPoint { + fn populate_mesh_builders( + &self, + ctx: &mut BuildBevyMeshesContext, + ) -> Result<(), TryFromIntError> { + for point in &self.0 { + point.populate_mesh_builders(ctx)?; + } + Ok(()) + } +} + +impl BuildBevyMeshes for MultiLineString { + fn populate_mesh_builders( + &self, + ctx: &mut BuildBevyMeshesContext, + ) -> Result<(), TryFromIntError> { + for line_string in &self.0 { + line_string.populate_mesh_builders(ctx)?; + } + Ok(()) + } +} + +impl BuildBevyMeshes for MultiPolygon { + fn populate_mesh_builders( + &self, + ctx: &mut BuildBevyMeshesContext, + ) -> Result<(), TryFromIntError> { + for polygon in &self.0 { + polygon.populate_mesh_builders(ctx)?; + } + Ok(()) + } +} + +impl BuildBevyMeshes for Line { + fn populate_mesh_builders( + &self, + ctx: &mut BuildBevyMeshesContext, + ) -> Result<(), TryFromIntError> { + LineString::from(self).populate_mesh_builders(ctx) + } +} + +impl BuildBevyMeshes for Triangle { + fn populate_mesh_builders( + &self, + ctx: &mut BuildBevyMeshesContext, + ) -> Result<(), TryFromIntError> { + self.to_polygon().populate_mesh_builders(ctx) + } +} + +impl BuildBevyMeshes for Rect { + fn populate_mesh_builders( + &self, + ctx: &mut BuildBevyMeshesContext, + ) -> Result<(), TryFromIntError> { + self.to_polygon().populate_mesh_builders(ctx) + } +} + +impl BuildBevyMeshes for Geometry { + fn populate_mesh_builders( + &self, + ctx: &mut BuildBevyMeshesContext, + ) -> Result<(), TryFromIntError> { + match self { + Geometry::Point(g) => g.populate_mesh_builders(ctx)?, + Geometry::Line(g) => g.populate_mesh_builders(ctx)?, + Geometry::LineString(g) => g.populate_mesh_builders(ctx)?, + Geometry::Polygon(g) => g.populate_mesh_builders(ctx)?, + Geometry::MultiPoint(g) => g.populate_mesh_builders(ctx)?, + Geometry::MultiLineString(g) => g.populate_mesh_builders(ctx)?, + Geometry::MultiPolygon(g) => g.populate_mesh_builders(ctx)?, + Geometry::GeometryCollection(g) => g.populate_mesh_builders(ctx)?, + Geometry::Triangle(g) => g.populate_mesh_builders(ctx)?, + Geometry::Rect(g) => g.populate_mesh_builders(ctx)?, + }; + Ok(()) + } +} + +impl BuildBevyMeshes for GeometryCollection { + fn populate_mesh_builders( + &self, + ctx: &mut BuildBevyMeshesContext, + ) -> Result<(), TryFromIntError> { + for g in self { + g.populate_mesh_builders(ctx)?; + } + Ok(()) + } +} diff --git a/src/lib.rs b/src/lib.rs index 2740357..54c045f 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -1,10 +1,13 @@ -use crate::polygon::PolygonMesh; use bevy::prelude::{info_span, Mesh}; +use build_mesh::BuildBevyMeshes; +use build_mesh::BuildMesh; use geo_types::geometry::*; use line_string::LineStringMeshBuilder; +use polygon::PolygonMesh; use polygon::PolygonMeshBuilder; use std::num::TryFromIntError; +mod build_mesh; mod line_string; mod point; mod polygon; @@ -63,7 +66,7 @@ pub fn triangle_to_mesh(triangle: &Triangle) -> Result, TryF } pub fn geometry_to_mesh(geometry: &Geometry) -> Result, TryFromIntError> { - let mut ctx = BuildBevyMeshesContext::default(); + let mut ctx = build_mesh::BuildBevyMeshesContext::default(); info_span!("Populating Bevy mesh builder") .in_scope(|| geometry.populate_mesh_builders(&mut ctx))?; @@ -98,144 +101,3 @@ pub enum GeometryMesh { LineString { mesh: Mesh }, Polygon(polygon::PolygonMesh), } - -trait BuildMesh { - fn build(self) -> Option; -} - -#[derive(Default)] -pub struct BuildBevyMeshesContext { - point_mesh_builder: point::PointMeshBuilder, - line_string_mesh_builder: LineStringMeshBuilder, - polygon_mesh_builder: polygon::PolygonMeshBuilder, -} - -pub trait BuildBevyMeshes { - fn populate_mesh_builders( - &self, - ctx: &mut BuildBevyMeshesContext, - ) -> Result<(), TryFromIntError>; -} - -impl BuildBevyMeshes for Point { - fn populate_mesh_builders( - &self, - ctx: &mut BuildBevyMeshesContext, - ) -> Result<(), TryFromIntError> { - ctx.point_mesh_builder.add_point(self) - } -} - -impl BuildBevyMeshes for LineString { - fn populate_mesh_builders( - &self, - ctx: &mut BuildBevyMeshesContext, - ) -> Result<(), TryFromIntError> { - ctx.line_string_mesh_builder.add_line_string(self) - } -} - -impl BuildBevyMeshes for Polygon { - fn populate_mesh_builders( - &self, - ctx: &mut BuildBevyMeshesContext, - ) -> Result<(), TryFromIntError> { - ctx.polygon_mesh_builder.add_polygon(self) - } -} - -impl BuildBevyMeshes for MultiPoint { - fn populate_mesh_builders( - &self, - ctx: &mut BuildBevyMeshesContext, - ) -> Result<(), TryFromIntError> { - for point in &self.0 { - point.populate_mesh_builders(ctx)?; - } - Ok(()) - } -} - -impl BuildBevyMeshes for MultiLineString { - fn populate_mesh_builders( - &self, - ctx: &mut BuildBevyMeshesContext, - ) -> Result<(), TryFromIntError> { - for line_string in &self.0 { - line_string.populate_mesh_builders(ctx)?; - } - Ok(()) - } -} - -impl BuildBevyMeshes for MultiPolygon { - fn populate_mesh_builders( - &self, - ctx: &mut BuildBevyMeshesContext, - ) -> Result<(), TryFromIntError> { - for polygon in &self.0 { - polygon.populate_mesh_builders(ctx)?; - } - Ok(()) - } -} - -impl BuildBevyMeshes for Line { - fn populate_mesh_builders( - &self, - ctx: &mut BuildBevyMeshesContext, - ) -> Result<(), TryFromIntError> { - LineString::from(self).populate_mesh_builders(ctx) - } -} - -impl BuildBevyMeshes for Triangle { - fn populate_mesh_builders( - &self, - ctx: &mut BuildBevyMeshesContext, - ) -> Result<(), TryFromIntError> { - self.to_polygon().populate_mesh_builders(ctx) - } -} - -impl BuildBevyMeshes for Rect { - fn populate_mesh_builders( - &self, - ctx: &mut BuildBevyMeshesContext, - ) -> Result<(), TryFromIntError> { - self.to_polygon().populate_mesh_builders(ctx) - } -} - -impl BuildBevyMeshes for Geometry { - fn populate_mesh_builders( - &self, - ctx: &mut BuildBevyMeshesContext, - ) -> Result<(), TryFromIntError> { - match self { - Geometry::Point(g) => g.populate_mesh_builders(ctx)?, - Geometry::Line(g) => g.populate_mesh_builders(ctx)?, - Geometry::LineString(g) => g.populate_mesh_builders(ctx)?, - Geometry::Polygon(g) => g.populate_mesh_builders(ctx)?, - Geometry::MultiPoint(g) => g.populate_mesh_builders(ctx)?, - Geometry::MultiLineString(g) => g.populate_mesh_builders(ctx)?, - Geometry::MultiPolygon(g) => g.populate_mesh_builders(ctx)?, - Geometry::GeometryCollection(g) => g.populate_mesh_builders(ctx)?, - Geometry::Triangle(g) => g.populate_mesh_builders(ctx)?, - Geometry::Rect(g) => g.populate_mesh_builders(ctx)?, - }; - Ok(()) - } -} - -impl BuildBevyMeshes for GeometryCollection { - fn populate_mesh_builders( - &self, - ctx: &mut BuildBevyMeshesContext, - ) -> Result<(), TryFromIntError> { - for g in self { - g.populate_mesh_builders(ctx)?; - } - Ok(()) - } -} diff --git a/src/line_string.rs b/src/line_string.rs index add6da8..f80da36 100644 --- a/src/line_string.rs +++ b/src/line_string.rs @@ -60,7 +60,7 @@ impl From for Option { } } -impl crate::BuildMesh for LineStringMeshBuilder { +impl crate::build_mesh::BuildMesh for LineStringMeshBuilder { fn build(self) -> Option { Option::::from(self).map(|mesh| crate::GeometryMesh::LineString { mesh }) } diff --git a/src/point.rs b/src/point.rs index 7619c12..6ca5491 100644 --- a/src/point.rs +++ b/src/point.rs @@ -13,7 +13,7 @@ impl PointMeshBuilder { } } -impl crate::BuildMesh for PointMeshBuilder { +impl crate::build_mesh::BuildMesh for PointMeshBuilder { fn build(self) -> Option { if self.points.is_empty() { None diff --git a/src/polygon.rs b/src/polygon.rs index 063cf22..2aed068 100644 --- a/src/polygon.rs +++ b/src/polygon.rs @@ -74,7 +74,7 @@ impl From for Option { } } -impl crate::BuildMesh for PolygonMeshBuilder { +impl crate::build_mesh::BuildMesh for PolygonMeshBuilder { fn build(self) -> Option { Option::::from(self).map(GeometryMesh::Polygon) } From 30116fe830dd0861f54af8ea2c3bf44782371a10 Mon Sep 17 00:00:00 2001 From: gibbz00 Date: Thu, 22 Jun 2023 22:34:08 +0200 Subject: [PATCH 09/13] Make `GeometryMesh::LineString` a newtype struct. --- src/lib.rs | 2 +- src/line_string.rs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/lib.rs b/src/lib.rs index 54c045f..44c5765 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -98,6 +98,6 @@ pub fn geometry_collection_to_mesh( pub enum GeometryMesh { Point(Vec), - LineString { mesh: Mesh }, + LineString(Mesh), Polygon(polygon::PolygonMesh), } diff --git a/src/line_string.rs b/src/line_string.rs index f80da36..8eee34e 100644 --- a/src/line_string.rs +++ b/src/line_string.rs @@ -62,6 +62,6 @@ impl From for Option { impl crate::build_mesh::BuildMesh for LineStringMeshBuilder { fn build(self) -> Option { - Option::::from(self).map(|mesh| crate::GeometryMesh::LineString { mesh }) + Option::::from(self).map(|mesh| crate::GeometryMesh::LineString(mesh)) } } From 94cd24188ae9d5b3ab98d943bb3a2cd54183a5e1 Mon Sep 17 00:00:00 2001 From: gibbz00 Date: Fri, 23 Jun 2023 23:00:28 +0200 Subject: [PATCH 10/13] Remove redundant closure. --- src/line_string.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/line_string.rs b/src/line_string.rs index 8eee34e..ccd93d5 100644 --- a/src/line_string.rs +++ b/src/line_string.rs @@ -62,6 +62,6 @@ impl From for Option { impl crate::build_mesh::BuildMesh for LineStringMeshBuilder { fn build(self) -> Option { - Option::::from(self).map(|mesh| crate::GeometryMesh::LineString(mesh)) + Option::::from(self).map(crate::GeometryMesh::LineString) } } From dbc21443debcfa4e652d16ddac917f9c2b0ffad5 Mon Sep 17 00:00:00 2001 From: gibbz00 Date: Fri, 23 Jun 2023 23:05:19 +0200 Subject: [PATCH 11/13] `PolygonMesh.polygon_mesh` -> `PolygonMesh.mesh` --- src/polygon.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/polygon.rs b/src/polygon.rs index 2aed068..6bfa576 100644 --- a/src/polygon.rs +++ b/src/polygon.rs @@ -4,7 +4,7 @@ use geo::CoordsIter; use geo_types::{LineString, Polygon}; pub struct PolygonMesh { - pub polygon_mesh: Mesh, + pub mesh: Mesh, pub exterior_mesh: Mesh, pub interior_meshes: Vec, } @@ -63,7 +63,7 @@ impl From for Option { .polygon .build() .map(|polygon_mesh| PolygonMesh { - polygon_mesh, + mesh: polygon_mesh, exterior_mesh: polygon_mesh_builder.exterior.into(), interior_meshes: polygon_mesh_builder .interiors From cc92339ed7cb122c177cfb9fd623af22bf95c677 Mon Sep 17 00:00:00 2001 From: gibbz00 Date: Fri, 23 Jun 2023 23:09:16 +0200 Subject: [PATCH 12/13] Make `PolygonMesh` public. --- src/lib.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/lib.rs b/src/lib.rs index 44c5765..039b38d 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -1,12 +1,12 @@ use bevy::prelude::{info_span, Mesh}; -use build_mesh::BuildBevyMeshes; -use build_mesh::BuildMesh; +use build_mesh::{BuildBevyMeshes, BuildMesh}; use geo_types::geometry::*; use line_string::LineStringMeshBuilder; -use polygon::PolygonMesh; use polygon::PolygonMeshBuilder; use std::num::TryFromIntError; +pub use polygon::PolygonMesh; + mod build_mesh; mod line_string; mod point; From fa1f58a5c51c40ce461fab3a49d63bc2e9605e90 Mon Sep 17 00:00:00 2001 From: gibbz00 Date: Sat, 1 Jul 2023 17:35:06 +0200 Subject: [PATCH 13/13] Remove temporary `geo-types` patch. --- Cargo.toml | 4 ---- 1 file changed, 4 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index c81fc98..366a800 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -12,7 +12,3 @@ bevy-earcutr = "0.9" bevy = { version = "0.10", default-features = false, features = ["bevy_render"] } geo = "0.25" geo-types = "0.7" - -[patch.crates-io] -# TEMP: https://github.com/georust/geo/pull/1020 is yet to included in a release. -geo-types = { git = "https://github.com/georust/geo" }