Compare commits

..

No commits in common. "4c36162aa571adce8b3601fa8a663debe203bedf" and "5bba4f019e943f002fb28aa858aea1e51a043134" have entirely different histories.

1 changed files with 7 additions and 27 deletions

View File

@ -23,7 +23,9 @@ struct Model {
engine: PhysicsEngine,
}
fn random_vec_in_rect(boundary: &Rect) -> nalgebra::Vector2<f32> {
fn random_vec(_app: &App) -> nalgebra::Vector2<f32> {
let boundary = _app.window_rect();
let x = random_range(-100., 100.);
let y = random_range(-150., boundary.top());
@ -34,15 +36,13 @@ fn fill_particles(app: &App, colliders: &mut ColliderSet, bodies: &mut RigidBody
// Keeping track of already placed balls to avoid overlap
// Need to look into a way to do this with rapier directly
let mut positions: Vec<nalgebra::Vector2<f32>> = Vec::new();
let boundary = &app.window_rect();
for _ in 0..PARTICLE_COUNT {
let mut xy = random_vec_in_rect(boundary);
let mut xy = random_vec(app);
while !positions
.iter()
.all(|pos| pos.metric_distance(&xy) > PARTICLE_SIZE * 2.)
{
xy = random_vec_in_rect(boundary)
xy = random_vec(app)
}
positions.push(xy);
@ -79,27 +79,9 @@ fn model(app: &App) -> Model {
..Default::default()
};
let boundary = app.window_rect();
/* Create the ground. */
let collider = ColliderBuilder::cuboid(boundary.w(), 4.)
.translation(vector![0., boundary.bottom()])
.build();
engine.state.colliders.insert(collider);
/* Create the walls. */
let collider = ColliderBuilder::cuboid(4., boundary.h())
.translation(vector![boundary.left(), 0.])
.build();
engine.state.colliders.insert(collider);
let collider = ColliderBuilder::cuboid(4., boundary.h())
.translation(vector![boundary.right(), 0.])
.build();
engine.state.colliders.insert(collider);
/* Create the ceiling. */
let collider = ColliderBuilder::cuboid(boundary.w(), 4.)
.translation(vector![0., boundary.top()])
let collider = ColliderBuilder::cuboid(100., 10.)
.translation(vector![0., -200.])
.build();
engine.state.colliders.insert(collider);
@ -115,8 +97,6 @@ fn event(app: &App, model: &mut Model, event: WindowEvent) {
}
if let Resized(_) = event {
// Rust borrowing rules means I need to first gather a list of handles,
// then delete them all
let handles: Vec<RigidBodyHandle> = model
.engine
.state