Skip to content

Commit

Permalink
Add support for concave inchographies
Browse files Browse the repository at this point in the history
Relates to #97.
  • Loading branch information
Indy2222 committed Jun 15, 2022
1 parent 60a5cc9 commit aa28bad
Show file tree
Hide file tree
Showing 9 changed files with 186 additions and 82 deletions.
104 changes: 96 additions & 8 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion crates/core/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,5 @@ bevy = "0.7.0"
iyes_progress = { version = "0.3.0", features = [ "iyes_loopless" ] }
glam = "0.20.2"
nalgebra = { version = "0.31.0", features = ["convert-glam020"] }
parry2d = { git = "https://github.com/Indy2222/parry", branch = "feature/dilation" }
parry2d = "0.9.0"
parry3d = "0.9.0"
3 changes: 2 additions & 1 deletion crates/index/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@ bevy = "0.7.0"
glam = "0.20.2"
iyes_loopless = "0.5.1"
parry3d = "0.9.0"
parry2d = { git = "https://github.com/Indy2222/parry", branch = "feature/dilation" }
parry2d = "0.9.0"
geo = "0.21.0"
ahash = "0.7.6"
nalgebra = { version = "0.31.0", features = ["convert-glam020"] }

Expand Down
8 changes: 4 additions & 4 deletions crates/index/src/shape.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use bevy::prelude::Component;
use parry2d::shape::ConvexPolygon;
use geo::Polygon;
use parry3d::{bounding_volume::AABB, math::Isometry, query::Ray, shape::Shape};

pub struct EntityShape {
Expand Down Expand Up @@ -40,15 +40,15 @@ impl EntityShape {

#[derive(Component, Clone)]
pub struct Ichnography {
bounds: ConvexPolygon,
bounds: Polygon<f32>,
}

impl Ichnography {
pub fn new(bounds: ConvexPolygon) -> Self {
pub fn new(bounds: Polygon<f32>) -> Self {
Self { bounds }
}

pub fn bounds(&self) -> &ConvexPolygon {
pub fn bounds(&self) -> &Polygon<f32> {
&self.bounds
}
}
21 changes: 11 additions & 10 deletions crates/index/src/systems.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ use de_core::{
projection::ToFlat,
state::GameState,
};
use geo::{LineString, Polygon};
use iyes_loopless::prelude::*;
use parry2d::{math::Point, shape::ConvexPolygon};
use parry3d::{
bounding_volume::{BoundingVolume, AABB},
math::Isometry,
Expand Down Expand Up @@ -119,15 +119,16 @@ fn insert(
};

let aabb = shape.compute_aabb().to_flat();
let ichnography = Ichnography::new(
ConvexPolygon::from_convex_polyline(vec![
Point::new(aabb.mins.x, aabb.maxs.y),
Point::new(aabb.mins.x, aabb.mins.y),
Point::new(aabb.maxs.x, aabb.mins.y),
Point::new(aabb.maxs.x, aabb.maxs.y),
])
.unwrap(),
);
let ichnography = Ichnography::new(Polygon::new(
LineString::from(vec![
(aabb.mins.x, aabb.maxs.y),
(aabb.mins.x, aabb.mins.y),
(aabb.maxs.x, aabb.mins.y),
(aabb.maxs.x, aabb.maxs.y),
(aabb.mins.x, aabb.maxs.y),
]),
vec![],
));

let position = Isometry::new(
transform.translation.into(),
Expand Down
2 changes: 1 addition & 1 deletion crates/map/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ de_core = { path = "../core", version = "0.1.0-dev" }
# other
bevy = "0.7"
glam = "0.20.2"
parry2d = { git = "https://github.com/Indy2222/parry", branch = "feature/dilation" }
parry2d = "0.9.0"
serde = "1.0"
serde_json = "1.0"
thiserror = "1.0"
Expand Down
5 changes: 4 additions & 1 deletion crates/pathing/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,11 @@ de_map = { path = "../map", version = "0.1.0-dev" }
# Other
bevy = "0.7"
glam = "^0.20.2"
parry2d = { git = "https://github.com/Indy2222/parry", branch = "feature/dilation" }
parry2d = "0.9.0"
nalgebra = { version = "0.31.0", features = ["convert-glam020"] }
geo = "0.21.0"
geo-types = "0.7.5"
geo-offset = { git = "https://github.com/Indy2222/geo-offset", branch = "master" }
ahash = "0.7.6"
approx = "0.5.1"
rstar = "0.9.3"
Expand Down
Loading

0 comments on commit aa28bad

Please sign in to comment.