08-10-2025, 08:11 AM
(This post was last modified: 08-10-2025, 08:14 AM by josemendez.)
(07-10-2025, 01:09 PM)Qriva0 Wrote: Hi, I wonder what would be a good way to modify distance field during runtime.
In my case there are several distance fields, we can treat them as animation keyframes to make this example simple -I want to interpolate between them over time and use it for collision.
Hi!
This idea won't work at all, but more on that below.
(07-10-2025, 01:09 PM)Qriva0 Wrote: The problem with ASDF is those trees have got different number of nodes and it's not trivial to generate new interpolated SDF. What would be good way to tackle this problem?
The simplest way I can think of is to make sure both trees have the same topology: same depth, every level densely populated. Then you can just interpolate every node with its corresponding node in the second distance field.
You can achieve this by setting the max error parameter to zero (so nodes will always be generated regardless of how much remaining error with the ground truth surface there is) and controlling the depth of the tree using max depth.
Note that the max depth parameter is clamped to a minimum, you might need to slightly modify Obi's code to allow it to reach zero.
(07-10-2025, 01:09 PM)Qriva0 Wrote: Furthermore main question is if such a collision is going to work properly when it comes to simulations itself, I did test with hard swapping colliders and without interpolation it jumps, because of depenetration, so I am not even sure if this would work for normal timesteps (50-60).
This is the main problem indeed: collisions won't work properly when using SDF "flipbooks" (interpolated or not).
Collisions are inherently velocity-based: if you have two objects A and B and you know their velocities, you can calculate the point where they will collide in the near future, and reduce their velocities to prevent penetration. You can also alter their velocities in the direction tangential to the contact normal to account for friction.
However if either object moves and its velocity doesn't reflect this movement (for instance, its velocity its zero) then it has effectively teleported, and it may end up penetrating other objects. The physics engine cannot do anything to prevent this penetration as it can't predict it in advance, and once it can detect it it's already too late: it can only try to correct it after it has already happened. This is done by pushing either/both objects out of each other, but this modifies their velocities in an unphysical way. Obi allows you to control the maximum velocity that objects can move out of each other once they've already overlapped (ObiSolver->max depenetration).
So in the case of SDF flipbooks we don't have any velocity information, so we lose proper collision response (no overlaps, friction) and fall back to depenetration, which is just a quick fix for a situation that shouldn't have happened in the first place.
This is the same reason why animating MeshColliders in Unity doesn't make sense and why it's not supported at all.
kind regards,

