diff options
author | Matt Bennice <mbennice@google.com> | 2022-08-11 11:09:08 -0700 |
---|---|---|
committer | Matt Bennice <mbennice@google.com> | 2022-08-11 11:09:08 -0700 |
commit | c7a67d509e8dea017493f7579aa6b8b6e71dee6b (patch) | |
tree | 1d7d4ad1010b31927d5075e9831842c3ddeacfec | |
parent | a1d96646c8ca28b99b2581dcfc4d74cc3b4de018 (diff) | |
download | bullet3-c7a67d509e8dea017493f7579aa6b8b6e71dee6b.tar.gz |
Update btSoftBody to handle close to degenerate triangles.
-rw-r--r-- | src/BulletSoftBody/btSoftBody.cpp | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/src/BulletSoftBody/btSoftBody.cpp b/src/BulletSoftBody/btSoftBody.cpp index e91c1b9a4..5d5073549 100644 --- a/src/BulletSoftBody/btSoftBody.cpp +++ b/src/BulletSoftBody/btSoftBody.cpp @@ -2816,6 +2816,16 @@ static void getBarycentric(const btVector3& p, btVector3& a, btVector3& b, btVec btScalar d20 = v2.dot(v0); btScalar d21 = v2.dot(v1); btScalar denom = d00 * d11 - d01 * d01; + if (denom == btScalar(0.0)) + { + bary.setY(btScalar(0.0)); + bary.setZ(btScalar(0.0)); + } + else + { + bary.setY((d11 * d20 - d01 * d21) / denom); + bary.setZ((d00 * d21 - d01 * d20) / denom); + } bary.setY((d11 * d20 - d01 * d21) / denom); bary.setZ((d00 * d21 - d01 * d20) / denom); bary.setX(btScalar(1) - bary.getY() - bary.getZ()); |