This patch includes several performance, stability, and reliability improvements to cloth collisions.
Changes included in this patch (could be broken into smaller commits if deemed necessary):
- Fix several collision bugs.
- Collisions caused cloth to be simulated twice per step, hurting performance, and accelerating cloth motion by a factor of two.
- Collider objects were ignoring substeps, and instead being evaluated with the state at the end of the frame.
- Several other smaller fixes.
- Fix some mathematical mistakes.
- Algorithmic improvements for both performance and stability/reliability.
- Use static BVH overlap, to reduce false positives, as moving collisions are not computed anyway.
- Apply all object collisions simultaneously, instead of sequentially, thus not favouring colliders later in the array over earlier ones.
- Implement new self-collision model based on face contacts instead of vertex proximity.
- Multithread collision detection.
- Implement new collision point computation function, which is faster and better tailored to our collision system than the Bullet one (also removes Bullet dependency for cloth)
- Implement single sided collisions, to prevent cloth from getting "stuck" inside the collider.
- Implement normal overrides, forcing collision impulses to act in the direction of the collider normal (gives better results for some simulations)
- Move friction to the collider settings, allowing a cloth to have different frictions with different colliders.
- Remove repulses, as they were just a hack to deal with unreliable collisions.
- Implement impulse clamping to prevent explosions from extreme collisions.