-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
594e767
commit 42c750e
Showing
4 changed files
with
137 additions
and
39 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,117 +1,166 @@ | ||
use edges::Edges; | ||
|
||
use crate::utils::{ | ||
avian2d::{convex_hull_collider, convex_polyline_collider, heightfield_collider, Collider}, | ||
generate_collider, generate_multi_collider, | ||
}; | ||
use bevy_render::prelude::Image; | ||
|
||
/// Generate a single polyline collider from the image, | ||
/// coordinates translated to either side of (0, 0) | ||
#[must_use] | ||
pub fn single_polyline_collider_translated(image: &Image) -> Collider { | ||
pub fn single_polyline_collider_translated<I>(image: I) -> Collider | ||
where | ||
Edges: From<I>, | ||
{ | ||
generate_collider(image, |points| Collider::polyline(points, None), true) | ||
} | ||
|
||
/// Generate a single polyline collider from the image, | ||
/// coordinates left alone and all in positive x and y | ||
#[must_use] | ||
pub fn single_polyline_collider_raw(image: &Image) -> Collider { | ||
pub fn single_polyline_collider_raw<I>(image: I) -> Collider | ||
where | ||
Edges: From<I>, | ||
{ | ||
generate_collider(image, |points| Collider::polyline(points, None), false) | ||
} | ||
|
||
/// Generate a single `convex_polyline` collider from the image, | ||
/// coordinates translated to either side of (0, 0) | ||
#[must_use] | ||
pub fn single_convex_polyline_collider_translated(image: &Image) -> Option<Collider> { | ||
pub fn single_convex_polyline_collider_translated<I>(image: I) -> Option<Collider> | ||
where | ||
Edges: From<I>, | ||
{ | ||
generate_collider(image, convex_polyline_collider, true) | ||
} | ||
|
||
/// Generate a single `convex_polyline` collider from the image, | ||
/// coordinates left alone and all in positive x and y | ||
#[must_use] | ||
pub fn single_convex_polyline_collider_raw(image: &Image) -> Option<Collider> { | ||
pub fn single_convex_polyline_collider_raw<I>(image: I) -> Option<Collider> | ||
where | ||
Edges: From<I>, | ||
{ | ||
generate_collider(image, convex_polyline_collider, false) | ||
} | ||
|
||
/// Generate a single `convex_hull` collider from the image, | ||
/// coordinates translated to either side of (0, 0) | ||
#[must_use] | ||
pub fn single_convex_hull_collider_translated(image: &Image) -> Option<Collider> { | ||
pub fn single_convex_hull_collider_translated<I>(image: I) -> Option<Collider> | ||
where | ||
Edges: From<I>, | ||
{ | ||
generate_collider(image, convex_hull_collider, true) | ||
} | ||
|
||
/// Generate a single `convex_hull` collider from the image, | ||
/// coordinates left alone and all in positive x and y | ||
#[must_use] | ||
pub fn single_convex_hull_collider_raw(image: &Image) -> Option<Collider> { | ||
pub fn single_convex_hull_collider_raw<I>(image: I) -> Option<Collider> | ||
where | ||
Edges: From<I>, | ||
{ | ||
generate_collider(image, convex_hull_collider, false) | ||
} | ||
|
||
/// Generate a single heightfield collider from the image, | ||
/// coordinates translated to either side of (0, 0) | ||
#[must_use] | ||
pub fn single_heightfield_collider_translated(image: &Image) -> Collider { | ||
pub fn single_heightfield_collider_translated<I>(image: I) -> Collider | ||
where | ||
Edges: From<I>, | ||
{ | ||
generate_collider(image, heightfield_collider, true) | ||
} | ||
|
||
/// Generate a single heightfield collider from the image, | ||
/// coordinates left alone and all in positive x and y | ||
#[must_use] | ||
pub fn single_heightfield_collider_raw(image: &Image) -> Collider { | ||
pub fn single_heightfield_collider_raw<I>(image: I) -> Collider | ||
where | ||
Edges: From<I>, | ||
{ | ||
generate_collider(image, heightfield_collider, false) | ||
} | ||
|
||
/// Generate as many polyline colliders as it can find in the image, | ||
/// coordinates translated to either side of (0, 0) | ||
#[must_use] | ||
pub fn multi_polyline_collider_translated(image: &Image) -> Vec<Collider> { | ||
pub fn multi_polyline_collider_translated<I>(image: I) -> Vec<Collider> | ||
where | ||
Edges: From<I>, | ||
{ | ||
generate_multi_collider(image, |points| Collider::polyline(points, None), true) | ||
} | ||
|
||
/// Generate as many polyline colliders as it can find in the image, | ||
/// coordinates left alone and all in positive x and y | ||
#[must_use] | ||
pub fn multi_polyline_collider_raw(image: &Image) -> Vec<Collider> { | ||
pub fn multi_polyline_collider_raw<I>(image: I) -> Vec<Collider> | ||
where | ||
Edges: From<I>, | ||
{ | ||
generate_multi_collider(image, |points| Collider::polyline(points, None), false) | ||
} | ||
|
||
/// Generate as many `convex_polyline` colliders as it can find in the image, | ||
/// coordinates translated to either side of (0, 0) | ||
#[must_use] | ||
pub fn multi_convex_polyline_collider_translated(image: &Image) -> Vec<Option<Collider>> { | ||
pub fn multi_convex_polyline_collider_translated<I>(image: I) -> Vec<Option<Collider>> | ||
where | ||
Edges: From<I>, | ||
{ | ||
generate_multi_collider(image, convex_polyline_collider, true) | ||
} | ||
|
||
/// Generate as many `convex_polyline` colliders as it can find in the image, | ||
/// coordinates left alone and all in positive x and y | ||
#[must_use] | ||
pub fn multi_convex_polyline_collider_raw(image: &Image) -> Vec<Option<Collider>> { | ||
pub fn multi_convex_polyline_collider_raw<I>(image: I) -> Vec<Option<Collider>> | ||
where | ||
Edges: From<I>, | ||
{ | ||
generate_multi_collider(image, convex_polyline_collider, false) | ||
} | ||
|
||
/// Generate as many heightfield colliders as it can find in the image, | ||
/// coordinates translated to either side of (0, 0) | ||
#[must_use] | ||
pub fn multi_heightfield_collider_translated(image: &Image) -> Vec<Collider> { | ||
pub fn multi_heightfield_collider_translated<I>(image: I) -> Vec<Collider> | ||
where | ||
Edges: From<I>, | ||
{ | ||
generate_multi_collider(image, heightfield_collider, true) | ||
} | ||
|
||
/// Generate as many heightfield colliders as it can find in the image, | ||
/// coordinates left alone and all in positive x and y | ||
#[must_use] | ||
pub fn multi_heightfield_collider_raw(image: &Image) -> Vec<Collider> { | ||
pub fn multi_heightfield_collider_raw<I>(image: I) -> Vec<Collider> | ||
where | ||
Edges: From<I>, | ||
{ | ||
generate_multi_collider(image, heightfield_collider, false) | ||
} | ||
|
||
/// Generate as many `convex_hull` colliders as it can find in the image, | ||
/// coordinates translated to either side of (0, 0) | ||
#[must_use] | ||
pub fn multi_convex_hull_collider_translated(image: &Image) -> Vec<Option<Collider>> { | ||
pub fn multi_convex_hull_collider_translated<I>(image: I) -> Vec<Option<Collider>> | ||
where | ||
Edges: From<I>, | ||
{ | ||
generate_multi_collider(image, convex_hull_collider, true) | ||
} | ||
|
||
/// Generate as many `convex_hull` colliders as it can find in the image, | ||
/// coordinates left alone and all in positive x and y | ||
#[must_use] | ||
pub fn multi_convex_hull_collider_raw(image: &Image) -> Vec<Option<Collider>> { | ||
pub fn multi_convex_hull_collider_raw<I>(image: I) -> Vec<Option<Collider>> | ||
where | ||
Edges: From<I>, | ||
{ | ||
generate_multi_collider(image, convex_hull_collider, false) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,117 +1,166 @@ | ||
use edges::Edges; | ||
|
||
use crate::utils::{ | ||
generate_collider, generate_multi_collider, | ||
rapier2d::{convex_hull_collider, convex_polyline_collider, heightfield_collider, Collider}, | ||
}; | ||
use bevy_render::prelude::Image; | ||
|
||
/// Generate a single polyline collider from the image, | ||
/// coordinates translated to either side of (0, 0) | ||
#[must_use] | ||
pub fn single_polyline_collider_translated(image: &Image) -> Collider { | ||
pub fn single_polyline_collider_translated<I>(image: I) -> Collider | ||
where | ||
Edges: From<I>, | ||
{ | ||
generate_collider(image, |points| Collider::polyline(points, None), true) | ||
} | ||
|
||
/// Generate a single polyline collider from the image, | ||
/// coordinates left alone and all in positive x and y | ||
#[must_use] | ||
pub fn single_polyline_collider_raw(image: &Image) -> Collider { | ||
pub fn single_polyline_collider_raw<I>(image: I) -> Collider | ||
where | ||
Edges: From<I>, | ||
{ | ||
generate_collider(image, |points| Collider::polyline(points, None), false) | ||
} | ||
|
||
/// Generate a single `convex_polyline` collider from the image, | ||
/// coordinates translated to either side of (0, 0) | ||
#[must_use] | ||
pub fn single_convex_polyline_collider_translated(image: &Image) -> Option<Collider> { | ||
pub fn single_convex_polyline_collider_translated<I>(image: I) -> Option<Collider> | ||
where | ||
Edges: From<I>, | ||
{ | ||
generate_collider(image, convex_polyline_collider, true) | ||
} | ||
|
||
/// Generate a single `convex_polyline` collider from the image, | ||
/// coordinates left alone and all in positive x and y | ||
#[must_use] | ||
pub fn single_convex_polyline_collider_raw(image: &Image) -> Option<Collider> { | ||
pub fn single_convex_polyline_collider_raw<I>(image: I) -> Option<Collider> | ||
where | ||
Edges: From<I>, | ||
{ | ||
generate_collider(image, convex_polyline_collider, false) | ||
} | ||
|
||
/// Generate a single `convex_hull` collider from the image, | ||
/// coordinates translated to either side of (0, 0) | ||
#[must_use] | ||
pub fn single_convex_hull_collider_translated(image: &Image) -> Option<Collider> { | ||
pub fn single_convex_hull_collider_translated<I>(image: I) -> Option<Collider> | ||
where | ||
Edges: From<I>, | ||
{ | ||
generate_collider(image, convex_hull_collider, true) | ||
} | ||
|
||
/// Generate a single `convex_hull` collider from the image, | ||
/// coordinates left alone and all in positive x and y | ||
#[must_use] | ||
pub fn single_convex_hull_collider_raw(image: &Image) -> Option<Collider> { | ||
pub fn single_convex_hull_collider_raw<I>(image: I) -> Option<Collider> | ||
where | ||
Edges: From<I>, | ||
{ | ||
generate_collider(image, convex_hull_collider, false) | ||
} | ||
|
||
/// Generate a single heightfield collider from the image, | ||
/// coordinates translated to either side of (0, 0) | ||
#[must_use] | ||
pub fn single_heightfield_collider_translated(image: &Image) -> Collider { | ||
pub fn single_heightfield_collider_translated<I>(image: I) -> Collider | ||
where | ||
Edges: From<I>, | ||
{ | ||
generate_collider(image, heightfield_collider, true) | ||
} | ||
|
||
/// Generate a single heightfield collider from the image, | ||
/// coordinates left alone and all in positive x and y | ||
#[must_use] | ||
pub fn single_heightfield_collider_raw(image: &Image) -> Collider { | ||
pub fn single_heightfield_collider_raw<I>(image: I) -> Collider | ||
where | ||
Edges: From<I>, | ||
{ | ||
generate_collider(image, heightfield_collider, false) | ||
} | ||
|
||
/// Generate as many polyline colliders as it can find in the image, | ||
/// coordinates translated to either side of (0, 0) | ||
#[must_use] | ||
pub fn multi_polyline_collider_translated(image: &Image) -> Vec<Collider> { | ||
pub fn multi_polyline_collider_translated<I>(image: I) -> Vec<Collider> | ||
where | ||
Edges: From<I>, | ||
{ | ||
generate_multi_collider(image, |points| Collider::polyline(points, None), true) | ||
} | ||
|
||
/// Generate as many polyline colliders as it can find in the image, | ||
/// coordinates left alone and all in positive x and y | ||
#[must_use] | ||
pub fn multi_polyline_collider_raw(image: &Image) -> Vec<Collider> { | ||
pub fn multi_polyline_collider_raw<I>(image: I) -> Vec<Collider> | ||
where | ||
Edges: From<I>, | ||
{ | ||
generate_multi_collider(image, |points| Collider::polyline(points, None), false) | ||
} | ||
|
||
/// Generate as many `convex_polyline` colliders as it can find in the image, | ||
/// coordinates translated to either side of (0, 0) | ||
#[must_use] | ||
pub fn multi_convex_polyline_collider_translated(image: &Image) -> Vec<Option<Collider>> { | ||
pub fn multi_convex_polyline_collider_translated<I>(image: I) -> Vec<Option<Collider>> | ||
where | ||
Edges: From<I>, | ||
{ | ||
generate_multi_collider(image, convex_polyline_collider, true) | ||
} | ||
|
||
/// Generate as many `convex_polyline` colliders as it can find in the image, | ||
/// coordinates left alone and all in positive x and y | ||
#[must_use] | ||
pub fn multi_convex_polyline_collider_raw(image: &Image) -> Vec<Option<Collider>> { | ||
pub fn multi_convex_polyline_collider_raw<I>(image: I) -> Vec<Option<Collider>> | ||
where | ||
Edges: From<I>, | ||
{ | ||
generate_multi_collider(image, convex_polyline_collider, false) | ||
} | ||
|
||
/// Generate as many heightfield colliders as it can find in the image, | ||
/// coordinates translated to either side of (0, 0) | ||
#[must_use] | ||
pub fn multi_heightfield_collider_translated(image: &Image) -> Vec<Collider> { | ||
pub fn multi_heightfield_collider_translated<I>(image: I) -> Vec<Collider> | ||
where | ||
Edges: From<I>, | ||
{ | ||
generate_multi_collider(image, heightfield_collider, true) | ||
} | ||
|
||
/// Generate as many heightfield colliders as it can find in the image, | ||
/// coordinates left alone and all in positive x and y | ||
#[must_use] | ||
pub fn multi_heightfield_collider_raw(image: &Image) -> Vec<Collider> { | ||
pub fn multi_heightfield_collider_raw<I>(image: I) -> Vec<Collider> | ||
where | ||
Edges: From<I>, | ||
{ | ||
generate_multi_collider(image, heightfield_collider, false) | ||
} | ||
|
||
/// Generate as many `convex_hull` colliders as it can find in the image, | ||
/// coordinates translated to either side of (0, 0) | ||
#[must_use] | ||
pub fn multi_convex_hull_collider_translated(image: &Image) -> Vec<Option<Collider>> { | ||
pub fn multi_convex_hull_collider_translated<I>(image: I) -> Vec<Option<Collider>> | ||
where | ||
Edges: From<I>, | ||
{ | ||
generate_multi_collider(image, convex_hull_collider, true) | ||
} | ||
|
||
/// Generate as many `convex_hull` colliders as it can find in the image, | ||
/// coordinates left alone and all in positive x and y | ||
#[must_use] | ||
pub fn multi_convex_hull_collider_raw(image: &Image) -> Vec<Option<Collider>> { | ||
pub fn multi_convex_hull_collider_raw<I>(image: I) -> Vec<Option<Collider>> | ||
where | ||
Edges: From<I>, | ||
{ | ||
generate_multi_collider(image, convex_hull_collider, false) | ||
} |
Oops, something went wrong.