InteractiveComputerGraphics / PositionBasedDynamics

PositionBasedDynamics is a library for the physically-based simulation of rigid bodies, deformable solids and fluids.
MIT License
1.89k stars 358 forks source link

how to do the continuous collision response #93

Closed owenlqs123 closed 2 years ago

owenlqs123 commented 3 years ago

Dear PBD Team, i encounter the same problem as mentioned in the post (https://github.com/InteractiveComputerGraphics/PositionBasedDynamics/issues/61) when doing the continuous collision response. as in PBD algorithm, we use the original and the predicted positions to get the collision constraints by performing continuous collision detection. i have noticed that the functions solve_TrianglePointDistanceConstraint() and solve_EdgeEdgeDistanceConstraint() can provide the self collision response , but i got the same question as korzen described as follows: " For example lets take a case with elastic rod self-collisions where I check for edge-edge (i.e. segment-segment) collisions while tightening the knot. I have got particles initial positions x0 at t=0 at timestep start and predicted positions xp at t=1 after elastic rod constraints solve and some other collisions with static environment. I have got collisions between two edges eA and eB detected at tc .

The question now is how to compute a proper collision response? An intuitive solution would be to simply interpolate between x0 and xp using tc to collision configuration xc, compute the response delta positions dp at this configuration and set predicted positions xp=xc+dp. However, such "overriding" of predicted positions causes that the colliding edges get stuck in the air. I have also tried adding dp computed at tc directly to xp but this causes the edges to often go through each other.

Just to mention that the problem is more general and valid for edge-point or triangle-point (both moving) collisions as well."

Thank you so much for your help! owen

janbender commented 3 years ago

Maybe you could take a look at the paper of Bridson et al. "Robust treatment of collisions, contact and friction for cloth animation", 2002. In this paper they describe how to perform a continuous collision detection and how to resolve the collisions.

owenlqs123 commented 3 years ago

ok,thank you so much for your reply!

korzen commented 3 years ago

Please check also a paper called "GPU Ray-Traced Collision Detection for Cloth Simulation". It has got a very clear explanation of collision response for (self)-collisions between cloths and volumetric bodies.

Have a look at 3.3 Contact Points Generation: "After collision is detected and inversions are corrected we need to generate contact points for the physics response. To improve the reliability we use ray re-projection [Lehericey et al. 2013b] to comply with the MTD. The MTD (minimum translational distance [Cameron and Culley 1986]) is the shortest relative translation that puts the two objects in contact (and not in interpenetration). Ray reprojection guarantees that the contact point gives the shortest translation to separate the object relatively to the detected triangle by projecting the ray on the normal of the detected triangle."

I have not tried this for segment-segment intesection but it works for point-triangle.

Good luck