summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatt Bennice <mbennice@google.com>2022-08-11 11:09:08 -0700
committerMatt Bennice <mbennice@google.com>2022-08-11 11:09:08 -0700
commitc7a67d509e8dea017493f7579aa6b8b6e71dee6b (patch)
tree1d7d4ad1010b31927d5075e9831842c3ddeacfec
parenta1d96646c8ca28b99b2581dcfc4d74cc3b4de018 (diff)
downloadbullet3-c7a67d509e8dea017493f7579aa6b8b6e71dee6b.tar.gz
Update btSoftBody to handle close to degenerate triangles.
-rw-r--r--src/BulletSoftBody/btSoftBody.cpp10
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());