Previous topic

Self Collision

Next topic

Internal cooking documentation

Inter Collision

Overview

Inter collision tries to keep multiple cloth objects from intersecting, but does not keep any cloth from self intersecting. It does this by keeping the particles from every cloth a minimum distance away from the particles of every other cloth. This distance can be set using Cloth::setInterCollisionDistance().

Broad phase collision detection

Acceleration structure

The acceleration structures used for Inter Collision are very similar to those used in Self Collision. The only addition is the broad phase which is used to cull cloth pairs based their bounding boxes, and cull particles from the narrow phase based on the overlapping volumes.

Broad phase collision detection

calculatePotentialColliders() takes care of the broad phase. It first calculates the individual bounding boxes of each cloth in world space. The sweep axis is determined using the bounding box enclosing all cloths. The worldspace bounding boxes are sorted by the lower boundary on the sweep axis. Sorting this way gives the following properties:

true = clothBounds[sortedIndices[i]].mLower <= clothBounds[sortedIndices[i+1]].mLower

if(clothBounds[sortedIndices[a]].mUpper < clothBounds[sortedIndices[b]].mLower)
{
       true = clothBounds[sortedIndices[a]].mUpper < clothBounds[sortedIndices[b+1]].mLower
       // b and all sorted cloths after b do not intersect a
}

Now the clothes are tested against the bounds of every other cloth.

For cloth A, all overlapping bounds of the other cloths are stored in temporary memory (in overlapBounds) in the local space of cloth A. All the particles of cloth A that overlap with any of those bounds are marked for narrow phase collision (and transformed to world space). Marking a particle for narrow phase collision is done by storing it in the mClothIndices and mParticleIndices arrays. Now the narrow phase only has to deal with the particles in those lists.

Differences with self collision

Some of the obvious differences:

  • Instead of iterating over all particles only particles from the mClothIndices and mParticleIndices arrays are used.
  • The particle cannot be directly accessed, the getParticle() function is used instead.
  • Intercollision has no equivalent to self collision indices.
  • The particles need to be transformed back into local space after collision response.