feat: apply ground friction on predictive velocity correction too - #7
Open
sebcrozet wants to merge 1 commit into
Open
feat: apply ground friction on predictive velocity correction too#7sebcrozet wants to merge 1 commit into
sebcrozet wants to merge 1 commit into
Conversation
Collaborator
Collaborator
Vollkornaffe
requested changes
Nov 15, 2023
Vollkornaffe
left a comment
Collaborator
There was a problem hiding this comment.
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 { | |||
Collaborator
There was a problem hiding this comment.
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); |
Collaborator
There was a problem hiding this comment.
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.
Collaborator
There was a problem hiding this comment.
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.



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.