ivr Posted June 30, 2019 Share Posted June 30, 2019 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? Quote Link to comment Share on other sites More sharing options...
3dome Posted July 1, 2019 Share Posted July 1, 2019 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 Quote Link to comment Share on other sites More sharing options...
ivr Posted July 2, 2019 Author Share Posted July 2, 2019 Thank you, Dominik! Easier than I thought... Quote Link to comment Share on other sites More sharing options...
Recommended Posts
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.