Skip to content

Commit

Permalink
fmt and clippy
Browse files Browse the repository at this point in the history
  • Loading branch information
shnewto committed Mar 1, 2024
1 parent c510c90 commit e06c8c4
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 9 deletions.
5 changes: 4 additions & 1 deletion examples/rapier2d_colliders.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,10 @@ use bevy::render::RenderPlugin;
use bevy_prototype_lyon::prelude::{Fill, GeometryBuilder, ShapePlugin};
use bevy_prototype_lyon::shapes;
use bevy_rapier2d::prelude::*;
use bevy_rapier_collider_gen::rapier2d::{multi_convex_polyline_collider_translated, single_convex_polyline_collider_translated, single_heightfield_collider_translated};
use bevy_rapier_collider_gen::rapier2d::{
multi_convex_polyline_collider_translated, single_convex_polyline_collider_translated,
single_heightfield_collider_translated,
};
use bevy_rapier_collider_gen::*;
use indoc::indoc;
use std::collections::HashMap;
Expand Down
12 changes: 9 additions & 3 deletions examples/xpbd_2d_colliders.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,15 @@ use bevy::render::settings::{RenderCreation, WgpuFeatures, WgpuSettings};
use bevy::render::RenderPlugin;
use bevy_prototype_lyon::prelude::{Fill, GeometryBuilder, ShapePlugin};
use bevy_prototype_lyon::shapes;
use bevy_rapier_collider_gen::xpbd_2d::{multi_convex_hull_collider_translated, single_convex_hull_collider_translated, single_heightfield_collider_raw, single_heightfield_collider_translated, single_polyline_collider_translated};
use bevy_rapier_collider_gen::xpbd_2d::{
multi_convex_hull_collider_translated, single_convex_hull_collider_translated,
single_heightfield_collider_raw, single_heightfield_collider_translated,
single_polyline_collider_translated,
};
use bevy_rapier_collider_gen::*;
use bevy_xpbd_2d::components::{CoefficientCombine, ColliderDensity, Friction, GravityScale, Restitution, RigidBody};
use bevy_xpbd_2d::components::{
CoefficientCombine, ColliderDensity, Friction, GravityScale, Restitution, RigidBody,
};
use bevy_xpbd_2d::math::Vector;
use bevy_xpbd_2d::plugins::debug::DebugRender;
use bevy_xpbd_2d::plugins::{PhysicsDebugPlugin, PhysicsPlugins};
Expand Down Expand Up @@ -87,7 +93,7 @@ pub fn car_spawn(
Friction::ZERO.with_combine_rule(CoefficientCombine::Min),
Restitution::ZERO.with_combine_rule(CoefficientCombine::Min),
ColliderDensity(2.0),
GravityScale(1.5),
GravityScale(1.5),
DebugRender::default().with_collider_color(Color::VIOLET),
));
}
Expand Down
7 changes: 3 additions & 4 deletions src/collider/xpbd_2d.rs
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,6 @@ pub fn multi_polyline_collider_raw(image: &Image) -> Vec<Collider> {
.collect()
}


// Is there an xpbd equivalent for this?
//
// Generate as many convex_polyline colliders as it can find in the image,
Expand Down Expand Up @@ -123,7 +122,7 @@ pub fn multi_heightfield_collider_raw(image: &Image) -> Vec<Collider> {
pub fn multi_convex_hull_collider_translated(image: &Image) -> Vec<Option<Collider>> {
multi_image_edge_translated(image)
.into_iter()
.map(|e| Collider::convex_hull(e))
.map(Collider::convex_hull)
.collect()
}

Expand All @@ -132,15 +131,15 @@ pub fn multi_convex_hull_collider_translated(image: &Image) -> Vec<Option<Collid
pub fn multi_convex_hull_collider_raw(image: &Image) -> Vec<Option<Collider>> {
multi_image_edges_raw(image)
.into_iter()
.map(|e| Collider::convex_hull(e))
.map(Collider::convex_hull)
.collect()
}

/// parses x,y points into y values at the top of the image (smallest y) and creates a
/// heightfield collider
fn heightfield_collider_from_points(v: &[Vec2]) -> Collider {
let hf = heights_from_points(v);
// convert v into a vector
// convert v into a vector
let x_scale = hf.len() as f32 - 1.0;
Collider::heightfield(hf, x_scale)
}
Expand Down
1 change: 0 additions & 1 deletion src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
#![doc = include_str!("../README.md")]


#[cfg(all(not(feature = "rapier2d"), not(feature = "xpbd_2d")))]
compile_error!("At least one of the features `rapier2d` or `xpbd_2d` must be enabled.");

Expand Down

0 comments on commit e06c8c4

Please sign in to comment.