Jump to content

Collisions with SDF


ivr

Recommended Posts

Hello, everyone!

I'm trying to implement collisions in my solver. I was thinking of using SDFs, but I can't wrap my head around how to sample the value of the SDF of my collision geometry at the position of my particle.

From my understanding, the volumesample function would need the position vector of the voxel as a parameter. 

I could try to sample the position of my voxel based on the position of my particle using point clouds, but that may be null if the two are not colliding at a certain frame.

So that would bring me back to the calculation of the distance between two points and SDFs become useless. 

Is there a smart way of using SDFs for collisions? 

Link to comment
Share on other sites

in a wrangle, plug in the points you want to make "collide" in the first input, SDF in the second (i recommend turning on "Fill Interior")

float depth = volumesample(1, 0, @P); //how deep inside the volume is the point
vector grad = volumegradient(1, 0, @P); //direction to the surface of the volume (depth = 0) at the point's position

@P += -depth * grad; //to push the point to the surface of the volume, you need to invert either the depth or the gradient

 

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...