I am working on collision resolution for a custom solver I am writing. I am using the gas-build-collision-mask node to get the SDF and a velocity field of the collision objects. However, for my collision resolution, I would like to separate the normal and tangential velocity components. What is the best way to do this?
Since my solver is on a grid, I considered just using the gas-enforce-boundary node (since this is pretty much exactly what I am trying to do). However, as far as I know, it will zero out the relative velocity in both normal and tangential directions. I would like to only zero out the relative normal velocity, and optionally, add dynamic friction to the tangential direction.
Any help is much appreciated.
Get collision normals from collision mask
1467 1 0- Isaac Nygaard
- Member
- 4 posts
- Joined: 1月 2014
- Offline
- Isaac Nygaard
- Member
- 4 posts
- Joined: 1月 2014
- Offline
It turns out, the gradient of the SDF gives the normal field. So, if you have a collision/SDF field col and position x, y, z, you can get the normal with:
UT_Vector3 n(
col->getValue(x-1,y,z) - col->getValue(x+1,y,z),
col->getValue(x,y-1,z) - col->getValue(x,y+1,z),
col->getValue(x,y,z-1) - col->getValue(x,y,z+1)
);
n.normalize();
UT_Vector3 n(
col->getValue(x-1,y,z) - col->getValue(x+1,y,z),
col->getValue(x,y-1,z) - col->getValue(x,y+1,z),
col->getValue(x,y,z-1) - col->getValue(x,y,z+1)
);
n.normalize();
-
- Quick Links