Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Inset boundary particles during dynamic collider sampling #66

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 18 additions & 15 deletions src/integrations/rapier/fluids_pipeline.rs
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ impl ColliderCouplingSet {
&'a mut self,
colliders: &'a ColliderSet,
bodies: &'a mut RigidBodySet,
) -> ColliderCouplingManager {
) -> ColliderCouplingManager<'a> {
ColliderCouplingManager {
coupling: self,
colliders,
Expand Down Expand Up @@ -217,32 +217,35 @@ impl<'a> CouplingManager for ColliderCouplingManager<'a> {

let dpt = particle_pos - proj.point;

if let Some((normal, depth)) =
let Some((normal, depth)) =
Unit::try_new_and_get(dpt, f32::default_epsilon())
{
if proj.is_inside {
fluid.positions[*particle_id] -=
*normal * (depth + margin);
else {
continue;
};
if proj.is_inside {
fluid.positions[*particle_id] -=
*normal * (depth + margin);

let vel_err =
normal.dot(&fluid.velocities[*particle_id]);
let vel_err =
normal.dot(&fluid.velocities[*particle_id]);

if vel_err > na::zero::<f32>() {
fluid.velocities[*particle_id] -=
*normal * vel_err;
}
} else if depth > h + prediction {
continue;
if vel_err > na::zero::<f32>() {
fluid.velocities[*particle_id] -= *normal * vel_err;
}
} else if depth > h + prediction {
continue;
}

let normal = if proj.is_inside { -normal } else { normal };
let pos = proj.point - *normal * particle_radius;

let velocity =
body.map(|b| b.velocity_at_point(&proj.point));

boundary
.velocities
.push(velocity.unwrap_or(Vector::zeros()));
boundary.positions.push(proj.point);
boundary.positions.push(pos);
boundary.volumes.push(na::zero::<f32>());
coupling.features.push(feature);
}
Expand Down
Loading