NvCloth
NvCloth copied to clipboard
Sphere CCD penerating limit is wrong.
In NvCloth, the following implement is wrong:
// skip continuous collision if the (un-clamped) particle
// trajectory only touches the outer skin of the cone.
T4f rMin = prevRadius + halfB * minusA * (curRadius - prevRadius);
collisionMask = collisionMask & (discriminant > minusA * rMin * rMin * sSkeletonWidth);
The definition of quadratic polynomial $ y = at^2 + b^2 + c $ actually represent difference between relative distance $d'$ of particle and sphere radius $r(t)$: $$ y(t) := d'^2 - r^2(t) $$ where $$ r(t) := r_0 + t\left( r_1 - r_0\right) $$ The minimum of $y$: $$ y_{\min} = y\left(-\frac{b}{2a}\right) = \frac{4ac - b^2}{4a} \doteq -\frac{d}{4a} $$ where $\Delta := d = b^2 - 4ac$. We restrict $y_{\min}$ no less than $s r_{\min}$, where:
- $s$ is a ratio of distance where particle penetrates cone of sphere trajectory. in NvCloth, it is $-0.36$:
sSkeletonWidth = simd4f(cloth::sqr(1 - 0.2f) - 1); - $r_{\min}$ is radius of sphere at $t = -b / 2a$: $$ r_{\min} = r\left(-\frac{b}{2a} \right) = r_0 -{\color{blue}\frac{b}{2a}}\left( r_1 - r_0 \right) $$
So the fact is $$ \begin{align*} & y_{\min} \ge s r^2_{\min} \ & \frac{d}{4} \ge -a r^2_{\min} s \end{align*} $$
Far from today, @lchut raise a question about this issue.