Skip to content

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

Open
sebcrozet wants to merge 1 commit into
masterfrom
ground_friction
Open

feat: apply ground friction on predictive velocity correction too#7
sebcrozet wants to merge 1 commit into
masterfrom
ground_friction

Conversation

@sebcrozet

Copy link
Copy Markdown
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

Vollkornaffe commented Nov 14, 2023

Copy link
Copy Markdown
Collaborator

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
Copy Markdown
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

@Vollkornaffe Vollkornaffe left a comment

Copy link
Copy Markdown
Collaborator

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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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.

2 participants