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

feat: apply ground friction on predictive velocity correction too #7

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

sebcrozet
Copy link
Member

Before this change, ground friction was only applied on grid cells below the ground. Now, just like grid cells below the ground induce a friction impulse proportional to the normal velocity, the grid cells above the ground now apply friction proportional to the removed normal velocity due to the predictive contact.

@Vollkornaffe
Copy link
Collaborator

Vollkornaffe commented Nov 14, 2023

Noticeable improvement in the 2D examples. The material doesn't seem to slide as on ice, see the screenshots below.

Before:
Pasted image 20231114194321

After:
Pasted image 20231114194455

@Vollkornaffe Vollkornaffe self-assigned this Nov 15, 2023
@Vollkornaffe Vollkornaffe self-requested a review November 15, 2023 10:20
@Vollkornaffe Vollkornaffe removed their assignment Nov 15, 2023
@Vollkornaffe
Copy link
Collaborator

Hmm, it does look like the fluid example is worse off as the number of escaping particles is increased. I'm not sure why that is.
image

Copy link
Collaborator

@Vollkornaffe Vollkornaffe left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think changing the margin from half a grid cell to one-and-a-half is a good idea.

@@ -125,25 +126,29 @@ fn update_single_cell(

if apply_friction {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This could be a better name

Suggested change
if apply_friction {
if apply_friction_and_cancel_penetration {

let tangent_vel = cell_velocity - normal_vel * normal.into_inner();
let tangent_vel_norm = tangent_vel.norm();

let new_normal_vel = normal_vel.max(-dist_with_margin / dt);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Even if we zero the normal velocity out completely, particles can still approach the boundary as their non-zero-kernel space goes further. We may want to extend the margin s.t. we cover the whole range of an approaching particle.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This amounts to changing the line above to let dist_with_margin = (dist - cell_width * 1.5).max(0.0);.

This also restores the previous behavior in the fluid example btw.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants