Jump to content
Sign in to follow this  
ivr

Collisions with SDF

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? 

Share this post


Link to post
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

 

Share this post


Link to post
Share on other sites

Thank you, Dominik! Easier than I thought...

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×