April 13, 2021

Self-Collisions

A mirror collides with itself - if it were alive, would it be self-introspecting?

In this part, we implemented self-collision for the cloth so that when it falls or folds in on itself, it won't clip through. For this part, it was too slow to naively check each point against every other point; thus, we used spatial hashmaps to speed up these checks.

Our scheme consisted of dividing our space into 3D boxes, grouping all masses within a box into a single hash group, then to actually hash the mass, we floored the mass's coordinates to the nearest box, then hashed that floored position using this post (we tried others but this one was relatively fast).

To actually correct masses, if the mass was less than 2*thickness away from another mass, we added the correction vector to make the mass 2*thickness away to a cumulative vector sum, then averaged these at the end (and divided by simulation_steps to smooth it out more).

Below we see the correct behavior of the cloth falling in on itself.

We can also vary the density and the constant ks to affect the behavior of the cloth as it falls on itself. Let's see how changing the ks value affects the cloth below:

Self-collision with the ks value set to 1,000:

Self-collision with the ks value set to 10,000:

A lower ks value leads to springier cloth. We can see that in the differing collisions above where the cloth with the ks set to 1,000 ends up more spread out and disheveled. The cloth with the 10,000 ks resembles a big sheet of paper and ends up folding up nicely with large curls. Now let's see how changing the density of the cloth affects it:

Self-collision with density set 1:

Self-collision with density set 100:

The denser the cloth, the heavier it is, which affects how it falls into itself. We see that when the cloth has a density of 1, it ends up folding nicely on top of itself. It seems to resemble aluminum foil as it lies relatively straight and folds into curls. When the cloth has a density of 100, however, it doesn't fold up as nicely and lies on the ground, without any curly bends, resembling a folded up blanket.