From e7317b90e70eea6601cfb03b98d891755a27e5a1 Mon Sep 17 00:00:00 2001 From: Jovansonlee Cesar Date: Mon, 12 Jul 2021 17:03:10 +0800 Subject: Update to the lastest version of nalgebra and ncollide2d --- svgbob/Cargo.toml | 4 ++-- svgbob/src/buffer/cell_buffer/cell.rs | 4 ++-- svgbob/src/buffer/fragment_buffer/fragment.rs | 8 ++++---- svgbob/src/buffer/fragment_buffer/fragment/arc.rs | 2 +- svgbob/src/buffer/fragment_buffer/fragment/line.rs | 2 +- svgbob/src/buffer/fragment_buffer/fragment/polygon.rs | 2 +- svgbob/src/buffer/fragment_buffer/fragment/rect.rs | 2 +- svgbob/src/point.rs | 13 +++++++++++++ svgbob/src/util.rs | 9 +++------ 9 files changed, 28 insertions(+), 18 deletions(-) diff --git a/svgbob/Cargo.toml b/svgbob/Cargo.toml index dfdd130..917b9d4 100644 --- a/svgbob/Cargo.toml +++ b/svgbob/Cargo.toml @@ -10,8 +10,8 @@ keywords = ["ascii","plain","text", "svg", "bob"] license = "Apache-2.0" [dependencies] -nalgebra = "0.18.0" -ncollide2d = "0.19.1" +nalgebra = "0.28" +ncollide2d = "0.31" lazy_static = "1.3.0" sauron = { version = "0.34" } unicode-width = "0.1.5" diff --git a/svgbob/src/buffer/cell_buffer/cell.rs b/svgbob/src/buffer/cell_buffer/cell.rs index cf49dcb..098e6d5 100644 --- a/svgbob/src/buffer/cell_buffer/cell.rs +++ b/svgbob/src/buffer/cell_buffer/cell.rs @@ -142,8 +142,8 @@ impl Cell { /// The polyline is then used to testing for intersection with the line segment fn polyline(&self) -> Polyline { let aabb = self.bounding_box(); - let min = aabb.mins(); - let max = aabb.maxs(); + let min = aabb.mins; + let max = aabb.maxs; let x1 = min.x; let y1 = min.y; let x2 = max.x; diff --git a/svgbob/src/buffer/fragment_buffer/fragment.rs b/svgbob/src/buffer/fragment_buffer/fragment.rs index 40eeaf5..95e31e5 100644 --- a/svgbob/src/buffer/fragment_buffer/fragment.rs +++ b/svgbob/src/buffer/fragment_buffer/fragment.rs @@ -301,10 +301,10 @@ impl Fragment { pub fn is_intersecting(&self, bbox: &AABB) -> bool { let bbox: Polyline = Polyline::new( vec![ - *bbox.mins(), - *Point::new(bbox.maxs().x, bbox.mins().y), - *bbox.maxs(), - *Point::new(bbox.mins().x, bbox.maxs().y), + *Point::new(bbox.mins.x, bbox.mins.y), + *Point::new(bbox.maxs.x, bbox.mins.y), + *Point::new(bbox.maxs.x, bbox.maxs.y), + *Point::new(bbox.mins.x, bbox.maxs.y), ], None, ); diff --git a/svgbob/src/buffer/fragment_buffer/fragment/arc.rs b/svgbob/src/buffer/fragment_buffer/fragment/arc.rs index 756a8d4..5d7963e 100644 --- a/svgbob/src/buffer/fragment_buffer/fragment/arc.rs +++ b/svgbob/src/buffer/fragment_buffer/fragment/arc.rs @@ -139,7 +139,7 @@ impl Arc { impl Bounds for Arc { fn bounds(&self) -> (Point, Point) { let aabb = Segment::new(*self.start, *self.end).local_aabb(); - (Point::from(*aabb.mins()), Point::from(*aabb.maxs())) + (Point::from(*aabb.mins), Point::from(*aabb.maxs)) } } diff --git a/svgbob/src/buffer/fragment_buffer/fragment/line.rs b/svgbob/src/buffer/fragment_buffer/fragment/line.rs index 7e8be28..2360bb7 100644 --- a/svgbob/src/buffer/fragment_buffer/fragment/line.rs +++ b/svgbob/src/buffer/fragment_buffer/fragment/line.rs @@ -507,7 +507,7 @@ impl Line { impl Bounds for Line { fn bounds(&self) -> (Point, Point) { let aabb = Segment::new(*self.start, *self.end).local_aabb(); - (Point::from(*aabb.mins()), Point::from(*aabb.maxs())) + (Point::from(*aabb.mins), Point::from(*aabb.maxs)) } } diff --git a/svgbob/src/buffer/fragment_buffer/fragment/polygon.rs b/svgbob/src/buffer/fragment_buffer/fragment/polygon.rs index 46d751f..f61e53c 100644 --- a/svgbob/src/buffer/fragment_buffer/fragment/polygon.rs +++ b/svgbob/src/buffer/fragment_buffer/fragment/polygon.rs @@ -177,7 +177,7 @@ impl Bounds for Polygon { fn bounds(&self) -> (Point, Point) { let pl: Polyline = self.clone().into(); let aabb = pl.local_aabb(); - (Point::from(*aabb.mins()), Point::from(*aabb.maxs())) + (Point::from(*aabb.mins), Point::from(*aabb.maxs)) } } diff --git a/svgbob/src/buffer/fragment_buffer/fragment/rect.rs b/svgbob/src/buffer/fragment_buffer/fragment/rect.rs index a74cc6c..27264a8 100644 --- a/svgbob/src/buffer/fragment_buffer/fragment/rect.rs +++ b/svgbob/src/buffer/fragment_buffer/fragment/rect.rs @@ -110,7 +110,7 @@ impl Rect { impl Bounds for Rect { fn bounds(&self) -> (Point, Point) { let aabb = Segment::new(*self.start, *self.end).local_aabb(); - (Point::from(*aabb.mins()), Point::from(*aabb.maxs())) + (Point::from(*aabb.mins), Point::from(*aabb.maxs)) } } diff --git a/svgbob/src/point.rs b/svgbob/src/point.rs index 18a8015..7779650 100644 --- a/svgbob/src/point.rs +++ b/svgbob/src/point.rs @@ -1,6 +1,7 @@ use crate::buffer::CellGrid; use crate::util; use crate::Cell; +use nalgebra::coordinates::XY; use nalgebra::{Point2, Vector2}; use std::{ cmp::Ordering, @@ -109,6 +110,18 @@ impl From> for Point { } } +impl From> for Point { + fn from(point: XY) -> Self { + Point::new(point.x as f32, point.y as f32) + } +} + +impl From> for Point { + fn from(point: XY) -> Self { + Point::new(point.x, point.y) + } +} + impl Add for Point { type Output = Self; diff --git a/svgbob/src/util.rs b/svgbob/src/util.rs index 1ce68a3..4253c5f 100644 --- a/svgbob/src/util.rs +++ b/svgbob/src/util.rs @@ -1,8 +1,5 @@ use crate::Point; -use ncollide2d::{ - bounding_volume::AABB, math::Isometry, - query::point_internal::point_query::PointQuery, -}; +use ncollide2d::{bounding_volume::AABB, math::Isometry, query::PointQuery}; use std::cmp::Ordering; pub fn opt_ord(f1: Option, f2: Option) -> Ordering { @@ -38,8 +35,8 @@ fn clip_line_internal( let end_v = end.to_vector() - start_v; let clipped = aabb.clip_line(&start, &end_v); if let Some(clipped) = clipped { - let a = *clipped.a(); - let b = *clipped.b(); + let a = *clipped.a; + let b = *clipped.b; Some((a.into(), b.into())) } else { None -- cgit v1.2.3