zenustech / zeno

ZEn NOde system - a simulation & rendering engine in nodes
http://zenustech.com
Mozilla Public License 2.0
1.2k stars 142 forks source link

[Question] Collision Handling of Cloth in ZENO #1988

Open WYK96 opened 3 weeks ago

WYK96 commented 3 weeks ago

Dear all,

Thanks for the great work! I am a beginner in cloth simulation. The collision handling technique in ZENO has inspired me a lot. After learning the code in ZENO, I am still struggling in some issues:

Q1: Imminent Collision Handling. In collision_utils.hpp, there is a function compute_imminent_collision_impulse which applies repulsion impulses to prevent imminent contacts, which is similiar to the method proposed by Brdison et al.[1] that handles repulsions utilizing inelastic collision and spring based force. The repulsions are applied to the velocities of cloth nodes in [1] with $I{c}=mv{n}/2$ for inelastic impulse and $I{r}=-min(\Delta tkd,m(\frac{.1d}{\Delta t}-v{N}))$ for spring based force. However, I noticed that the repulsions in compute_imminent_collision_impulse are applied to the positions of the cloth nodes with $I=(target\_repulsive\_dist - vr\_nrm) * pr$. My concern is: how is the magnitude of $I$ determined?

I tried integrating repulsion forces into my simulation framework. Although some imminent collisions have been detected and handled, the simulation result is sensitive to the configurations of imminent collisions. If I select a large repulsive thickness or scale up the magnitude of imminent repulsion, the cloth vertices suffers from jittering issue, whereas a small value makes the repulsive force does not take effect. Are there any references about how to evaluate the repulsive impulse in PBD framework for me to learn from?

Q2: Unhandled Collisions in CCD. In CollisionSolver.cu, a node named DetangleCCDCollisionWithBoundary is defined and implemented. The method iteratively performs continuous collision detection and solves it in a Jacobi fashion. If I understood correctly, the method never guarantees convergence. Alternatively, the CCD exits when the number of collisions is smaller than the number of acceptable collisions. In the Jacobi solve step that applies CCD impulse, the impulses whose magnitude is smaller than a pre-defined threshold will be ignored. Since the algorithm may exit at a failsafe state, how do you resolve the remaining unhandled collisions? If the remaining collisions are close with each other after performing CCD step, the simpliest way to resolve the collisions seems to be using the collision reponse method describled in Section 3.4 of Position Based Dynamics proposed by Müller et al.[2]. More specifically, for a detected VF collision, the vertex is projected onto the face with an extra thickness along the face normal. The approach can be also extended to the EE case.

Unfortunately, I did not find any code that achieve the goal in ZENO. What I've found is that ZENO provides a DCD constraint solver in ConstraintsSolver.cu. What makes me confused is that the DCD here is handled via imminent impulse, e.g., in node XPBDSolveSmooth, the DCD is solved with compute_imminent_collision_impulse. The impulse applied here is only helpful to prevent incoming collisions. For collisions that have already happened, e.g., a cloth penetrated with an obstacle or went into a tangled state, the method does not seem to work well. Is the exsiting collisions resolved by untangling approaches such as intersection contour minimization[3] or other techniques such as impact zone optimization? Please correct me if I missed or misunderstood anything.

Q3: Integration of Imminent Collision into Simulation Pipeline. I wonder how the imminent collision handling is integrated into the simulation pipeline, is it an one-pass approach or an interative approach? I wrote two possible pipelines:

Pipeline A: Regard imminent collisions as a constraint and solve it with the internal cloth dynamics

simulation_pipeline_A

Pipeline B: Resolve repulsive forces as a post-process procedure. After advancing to the candidate positions with internal cloth dynamics, the repulsion impulses are iteratively evaluated and solved.

simulation_pipeline_B

Could you please give me some advice on which approach of integrating repulsive forces is correct?

References

[1]. Bridson R, Fedkiw R, Anderson J. Robust treatment of collisions, contact and friction for cloth animation[J]. ACM Transactions on Graphics (TOG), 2002, 21(3): 594-603. [2]. Müller M, Heidelberger B, Hennix M, et al. Position based dynamics[J]. Journal of Visual Communication and Image Representation, 2007, 18(2): 109-118. [3]. Volino P, Magnenat-Thalmann N. Resolving surface collisions through intersection contour minimization[J]. ACM Transactions on Graphics (TOG), 2006, 25(3): 1154-1159.

WYK96 commented 3 weeks ago

Since much of code regarding PBD collision handling were written by @ShuliangLu , your advice will be very helpful for me :)

zhxx1987 commented 3 weeks ago

hi teemo, the actual simulation stepping pipeline is another complicated story where we may involved detangling in constrain iterations, and sockets for external arbitrary force routines defined by users. those things are all implemented using node-connections. the pipeline could be more complicated than the figures shown in your email.

please contact ShuLiang for details. you may setup a video chat to discuss that fashion.

On Fri, Aug 16, 2024 at 4:45 PM teemo @.***> wrote:

Dear all,

Thanks for the great work! I am a beginner in cloth simulation. The collision handling technique in ZENO has inspired me a lot. After learning the code in ZENO, I am still struggling in some issues:

Q1: Imminent Collision Handling. In collision_utils.hpp https://github.com/zenustech/zeno/blob/master/projects/CuLagrange/fem/collision_energy/collision_utils.hpp, there is a function compute_imminent_collision_impulse https://github.com/zenustech/zeno/blob/master/projects/CuLagrange/fem/collision_energy/collision_utils.hpp#L987 which applies repulsion impulses to prevent imminent contacts, which is similiar to the method proposed by Brdison et al.[1] that handles repulsions utilizing inelastic collision and spring based force. The repulsions are applied to the velocities of cloth nodes in [1] with $I{c}=mv{n}/2$ for inelastic impulse and $I{r}=-min(\Delta tkd,m(\frac{.1d}{\Delta t}-v{N}))$ for spring based force. However, I noticed that the repulsions in compute_imminent_collision_impulse https://github.com/zenustech/zeno/blob/master/projects/CuLagrange/fem/collision_energy/collision_utils.hpp#L987 are applied to the positions of the cloth nodes with $I=(target_repulsive_dist

  • vr_nrm) * pr$. My concern is: how is the magnitude of $I$ is determined?

I tried integrating repulsion forces into my simulation framework. Although some imminent collisions have been detected and handled, the simulation result is sensitive to the configurations of imminent collisions. If I select a large repulsive thickness or scale up the magnitude of imminent repulsion, the cloth vertices suffers from jittering issue, whereas a small value makes the repulsive force does not take effect. Are there any references about how to evaluate the repulsive impulse in PBD framework for me to learn from?

Q2: Unhandled Collisions in CCD. In CollisionSolver.cu https://github.com/zenustech/zeno/blob/master/projects/CuLagrange/pbd/CollisionSolver.cu, a node named DetangleCCDCollisionWithBoundary https://github.com/zenustech/zeno/blob/master/projects/CuLagrange/pbd/CollisionSolver.cu#L314 is defined and implemented. The method iteratively performs continuous collision detection and solves it in a Jacobi fashion. If I understood correctly, the method never guarantees convergence. Alternatively, the CCD exits when the number of collisions is smaller than the number of acceptable collisions. In the Jacobi solve step that applies CCD impulse, the impulses whose magnitude is smaller than a pre-defined threshold will be ignored. Since the algorithm is not a failsafe method, how do you resolve the remaining unhandled collisions? If the remaining collisions are close with each other after performing CCD step, the simpliest way to resolve the collisions seems to be using the collision reponse method describled in Section 3.4 of Position Based Dynamics proposed by Müller et al.[2]. More specifically, for a detected VF collision, the vertex is projected onto the face with an extra thickness along the face normal. The approach can be also extended to the EE case.

Unfortunately, I did not find any code that achieve the goal in ZENO. What I've found is that ZENO provides a DCD constraint solver in ConstraintsSolver.cu https://github.com/zenustech/zeno/blob/master/projects/CuLagrange/pbd/ConstraintsSolver.cu. What makes me confused is that the DCD here is handled via imminent impulse, e.g., in node XPBDSolveSmooth https://github.com/zenustech/zeno/blob/master/projects/CuLagrange/pbd/ConstraintsSolver.cu#L316, the DCD is solved with compute_imminent_collision_impulse https://github.com/zenustech/zeno/blob/master/projects/CuLagrange/pbd/ConstraintsSolver.cu#L499. The impulse applied here is only helpful to prevent incoming collisions. For collisions that have already happened, e.g., a cloth penetrated with an obstacle or went into a tangled state, the method does not seem to work well. Is the exsiting collisions resolved by untangling approaches such as intersection contour minimization[3] or other techniques such as impact zone optimization? Please correct me if I missed or misunderstood anything.

Q3: Integration of Imminent Collision into Simulation Pipeline. I wonder how the imminent collision handling is integrated into the simulation pipeline, is it an one-pass approach or an interative approach? I wrote two possible pipelines:

Pipeline A: Regard imminent collisions as a constraint and solve it with the internal cloth dynamics

simulation_pipeline_A.jpg (view on web) https://github.com/user-attachments/assets/ea8306cc-3181-4ff4-a5ed-bb44dc1a6c08

Pipeline B: Resolve repulsive forces as a post-process procedure. After advancing to the candidate positions with internal cloth dynamics, the repulsion impulses are iteratively evaluated and solved.

simulation_pipeline_B.jpg (view on web) https://github.com/user-attachments/assets/2f38d32c-98a5-40e7-b334-590997ba75fb

Could you please give me some advice on which approach of integrating repulsive forces is correct? References

[1]. Bridson R, Fedkiw R, Anderson J. Robust treatment of collisions, contact and friction for cloth animation[J]. ACM Transactions on Graphics (TOG), 2002, 21(3): 594-603. [2]. Müller M, Heidelberger B, Hennix M, et al. Position based dynamics[J]. Journal of Visual Communication and Image Representation, 2007, 18(2): 109-118. [3]. Volino P, Magnenat-Thalmann N. Resolving surface collisions through intersection contour minimization[J]. ACM Transactions on Graphics (TOG), 2006, 25(3): 1154-1159.

— Reply to this email directly, view it on GitHub https://github.com/zenustech/zeno/issues/1988, or unsubscribe https://github.com/notifications/unsubscribe-auth/AC5IJS272MGOL46XZ747W5DZRW33NAVCNFSM6AAAAABMTVDZLOVHI2DSMVQWIX3LMV43ASLTON2WKOZSGQ3DSOBQHA3TMMQ . You are receiving this because you are subscribed to this thread.Message ID: @.***>

WYK96 commented 2 weeks ago

Thank you for your reply. May I ask if the contact information for ShuLiang @ShuliangLu is publicly available(e.g., WeChat or E-mail)?