bullet: Sync with upstream 3.25

Remove upstreamed patch.
This commit is contained in:
Rémi Verschelde 2023-05-22 15:10:36 +02:00
parent 1538b870f1
commit b958e8a236
No known key found for this signature in database
GPG key ID: C3336907360768E1
12 changed files with 125 additions and 97 deletions

View file

@ -20,7 +20,7 @@ Files extracted from upstream source:
## bullet ## bullet
- Upstream: https://github.com/bulletphysics/bullet3 - Upstream: https://github.com/bulletphysics/bullet3
- Version: 3.24 (7dee3436e747958e7088dfdcea0e4ae031ce619e, 2022) - Version: 3.25 (2c204c49e56ed15ec5fcfa71d199ab6d6570b3f5, 2022)
- License: zlib - License: zlib
Files extracted from upstream source: Files extracted from upstream source:
@ -29,8 +29,6 @@ Files extracted from upstream source:
and CMakeLists.txt and premake4.lua files and CMakeLists.txt and premake4.lua files
- `LICENSE.txt`, and `VERSION` as `VERSION.txt` - `LICENSE.txt`, and `VERSION` as `VERSION.txt`
Includes some patches in the `patches` folder which have been sent upstream.
## certs ## certs

View file

@ -103,7 +103,8 @@ void btConvexTriangleCallback::processTriangle(btVector3* triangle, int partId,
if (m_convexBodyWrap->getCollisionShape()->isConvex()) if (m_convexBodyWrap->getCollisionShape()->isConvex())
{ {
#ifndef BT_DISABLE_CONVEX_CONCAVE_EARLY_OUT #ifdef BT_ENABLE_CONVEX_CONCAVE_EARLY_OUT
//todo: check this issue https://github.com/bulletphysics/bullet3/issues/4263
//an early out optimisation if the object is separated from the triangle //an early out optimisation if the object is separated from the triangle
//projected on the triangle normal) //projected on the triangle normal)
{ {
@ -139,7 +140,7 @@ void btConvexTriangleCallback::processTriangle(btVector3* triangle, int partId,
if (dist > contact_threshold) if (dist > contact_threshold)
return; return;
} }
#endif //BT_DISABLE_CONVEX_CONCAVE_EARLY_OUT #endif //BT_ENABLE_CONVEX_CONCAVE_EARLY_OUT
btTriangleShape tm(triangle[0], triangle[1], triangle[2]); btTriangleShape tm(triangle[0], triangle[1], triangle[2]);
tm.setMargin(m_collisionMarginTriangle); tm.setMargin(m_collisionMarginTriangle);

View file

@ -229,10 +229,12 @@ public:
m_min[0] = BT_MIN3(V1[0], V2[0], V3[0]); m_min[0] = BT_MIN3(V1[0], V2[0], V3[0]);
m_min[1] = BT_MIN3(V1[1], V2[1], V3[1]); m_min[1] = BT_MIN3(V1[1], V2[1], V3[1]);
m_min[2] = BT_MIN3(V1[2], V2[2], V3[2]); m_min[2] = BT_MIN3(V1[2], V2[2], V3[2]);
m_min[3] = 0.f;
m_max[0] = BT_MAX3(V1[0], V2[0], V3[0]); m_max[0] = BT_MAX3(V1[0], V2[0], V3[0]);
m_max[1] = BT_MAX3(V1[1], V2[1], V3[1]); m_max[1] = BT_MAX3(V1[1], V2[1], V3[1]);
m_max[2] = BT_MAX3(V1[2], V2[2], V3[2]); m_max[2] = BT_MAX3(V1[2], V2[2], V3[2]);
m_max[3] = 0.f;
} }
btAABB(const btVector3 &V1, btAABB(const btVector3 &V1,
@ -243,10 +245,12 @@ public:
m_min[0] = BT_MIN3(V1[0], V2[0], V3[0]); m_min[0] = BT_MIN3(V1[0], V2[0], V3[0]);
m_min[1] = BT_MIN3(V1[1], V2[1], V3[1]); m_min[1] = BT_MIN3(V1[1], V2[1], V3[1]);
m_min[2] = BT_MIN3(V1[2], V2[2], V3[2]); m_min[2] = BT_MIN3(V1[2], V2[2], V3[2]);
m_min[3] = 0.f;
m_max[0] = BT_MAX3(V1[0], V2[0], V3[0]); m_max[0] = BT_MAX3(V1[0], V2[0], V3[0]);
m_max[1] = BT_MAX3(V1[1], V2[1], V3[1]); m_max[1] = BT_MAX3(V1[1], V2[1], V3[1]);
m_max[2] = BT_MAX3(V1[2], V2[2], V3[2]); m_max[2] = BT_MAX3(V1[2], V2[2], V3[2]);
m_max[3] = 0.f;
m_min[0] -= margin; m_min[0] -= margin;
m_min[1] -= margin; m_min[1] -= margin;
@ -275,9 +279,11 @@ public:
m_min[0] = SIMD_INFINITY; m_min[0] = SIMD_INFINITY;
m_min[1] = SIMD_INFINITY; m_min[1] = SIMD_INFINITY;
m_min[2] = SIMD_INFINITY; m_min[2] = SIMD_INFINITY;
m_min[3] = 0.f;
m_max[0] = -SIMD_INFINITY; m_max[0] = -SIMD_INFINITY;
m_max[1] = -SIMD_INFINITY; m_max[1] = -SIMD_INFINITY;
m_max[2] = -SIMD_INFINITY; m_max[2] = -SIMD_INFINITY;
m_max[3] = 0.f;
} }
SIMD_FORCE_INLINE void increment_margin(btScalar margin) SIMD_FORCE_INLINE void increment_margin(btScalar margin)
@ -295,10 +301,12 @@ public:
m_min[0] = other.m_min[0] - margin; m_min[0] = other.m_min[0] - margin;
m_min[1] = other.m_min[1] - margin; m_min[1] = other.m_min[1] - margin;
m_min[2] = other.m_min[2] - margin; m_min[2] = other.m_min[2] - margin;
m_min[3] = 0.f;
m_max[0] = other.m_max[0] + margin; m_max[0] = other.m_max[0] + margin;
m_max[1] = other.m_max[1] + margin; m_max[1] = other.m_max[1] + margin;
m_max[2] = other.m_max[2] + margin; m_max[2] = other.m_max[2] + margin;
m_max[3] = 0.f;
} }
template <typename CLASS_POINT> template <typename CLASS_POINT>
@ -310,10 +318,12 @@ public:
m_min[0] = BT_MIN3(V1[0], V2[0], V3[0]); m_min[0] = BT_MIN3(V1[0], V2[0], V3[0]);
m_min[1] = BT_MIN3(V1[1], V2[1], V3[1]); m_min[1] = BT_MIN3(V1[1], V2[1], V3[1]);
m_min[2] = BT_MIN3(V1[2], V2[2], V3[2]); m_min[2] = BT_MIN3(V1[2], V2[2], V3[2]);
m_min[3] = 0.f;
m_max[0] = BT_MAX3(V1[0], V2[0], V3[0]); m_max[0] = BT_MAX3(V1[0], V2[0], V3[0]);
m_max[1] = BT_MAX3(V1[1], V2[1], V3[1]); m_max[1] = BT_MAX3(V1[1], V2[1], V3[1]);
m_max[2] = BT_MAX3(V1[2], V2[2], V3[2]); m_max[2] = BT_MAX3(V1[2], V2[2], V3[2]);
m_max[3] = 0.f;
} }
template <typename CLASS_POINT> template <typename CLASS_POINT>
@ -325,10 +335,12 @@ public:
m_min[0] = BT_MIN3(V1[0], V2[0], V3[0]); m_min[0] = BT_MIN3(V1[0], V2[0], V3[0]);
m_min[1] = BT_MIN3(V1[1], V2[1], V3[1]); m_min[1] = BT_MIN3(V1[1], V2[1], V3[1]);
m_min[2] = BT_MIN3(V1[2], V2[2], V3[2]); m_min[2] = BT_MIN3(V1[2], V2[2], V3[2]);
m_min[3] = 0.f;
m_max[0] = BT_MAX3(V1[0], V2[0], V3[0]); m_max[0] = BT_MAX3(V1[0], V2[0], V3[0]);
m_max[1] = BT_MAX3(V1[1], V2[1], V3[1]); m_max[1] = BT_MAX3(V1[1], V2[1], V3[1]);
m_max[2] = BT_MAX3(V1[2], V2[2], V3[2]); m_max[2] = BT_MAX3(V1[2], V2[2], V3[2]);
m_max[3] = 0.f;
m_min[0] -= margin; m_min[0] -= margin;
m_min[1] -= margin; m_min[1] -= margin;

View file

@ -169,9 +169,12 @@ btVectorXu btLemkeAlgorithm::solve(unsigned int maxloops /* = 0*/)
/*the column becomes part of the basis*/ /*the column becomes part of the basis*/
basis[pivotRowIndex] = pivotColIndexOld; basis[pivotRowIndex] = pivotColIndexOld;
bool isRayTermination = false;
pivotRowIndex = findLexicographicMinimum(A, pivotColIndex); pivotRowIndex = findLexicographicMinimum(A, pivotColIndex, z0Row, isRayTermination);
if (isRayTermination)
{
break; // ray termination
}
if (z0Row == pivotRowIndex) if (z0Row == pivotRowIndex)
{ //if z0 leaves the basis the solution is found --> one last elimination step is necessary { //if z0 leaves the basis the solution is found --> one last elimination step is necessary
GaussJordanEliminationStep(A, pivotRowIndex, pivotColIndex, basis); GaussJordanEliminationStep(A, pivotRowIndex, pivotColIndex, basis);
@ -217,79 +220,100 @@ btVectorXu btLemkeAlgorithm::solve(unsigned int maxloops /* = 0*/)
return solutionVector; return solutionVector;
} }
int btLemkeAlgorithm::findLexicographicMinimum(const btMatrixXu& A, const int& pivotColIndex) int btLemkeAlgorithm::findLexicographicMinimum(const btMatrixXu& A, const int& pivotColIndex, const int& z0Row, bool& isRayTermination)
{ {
int RowIndex = 0; isRayTermination = false;
btAlignedObjectArray<int> activeRows;
bool firstRow = true;
btScalar currentMin = 0.0;
int dim = A.rows(); int dim = A.rows();
btAlignedObjectArray<btVectorXu> Rows;
for (int row = 0; row < dim; row++) for (int row = 0; row < dim; row++)
{ {
btVectorXu vec(dim + 1); const btScalar denom = A(row, pivotColIndex);
vec.setZero(); //, INIT, 0.)
Rows.push_back(vec);
btScalar a = A(row, pivotColIndex);
if (a > 0)
{
Rows[row][0] = A(row, 2 * dim + 1) / a;
Rows[row][1] = A(row, 2 * dim) / a;
for (int j = 2; j < dim + 1; j++)
Rows[row][j] = A(row, j - 1) / a;
#ifdef BT_DEBUG_OSTREAM if (denom > btMachEps())
// if (DEBUGLEVEL) { {
// cout << "Rows(" << row << ") = " << Rows[row] << endl; const btScalar q = A(row, dim + dim + 1) / denom;
// } if (firstRow)
#endif {
currentMin = q;
activeRows.push_back(row);
firstRow = false;
} }
else if (fabs(currentMin - q) < btMachEps())
{
activeRows.push_back(row);
} }
else if (currentMin > q)
for (int i = 0; i < Rows.size(); i++)
{ {
if (Rows[i].nrm2() > 0.) currentMin = q;
{ activeRows.clear();
int j = 0; activeRows.push_back(row);
for (; j < Rows.size(); j++)
{
if (i != j)
{
if (Rows[j].nrm2() > 0.)
{
btVectorXu test(dim + 1);
for (int ii = 0; ii < dim + 1; ii++)
{
test[ii] = Rows[j][ii] - Rows[i][ii];
}
//=Rows[j] - Rows[i]
if (!LexicographicPositive(test))
break;
} }
} }
} }
if (j == Rows.size()) if (activeRows.size() == 0)
{ {
RowIndex += i; isRayTermination = true;
break; return 0;
} }
} else if (activeRows.size() == 1)
}
return RowIndex;
}
bool btLemkeAlgorithm::LexicographicPositive(const btVectorXu& v)
{ {
int i = 0; return activeRows[0];
// if (DEBUGLEVEL) }
// cout << "v " << v << endl;
while (i < v.size() - 1 && fabs(v[i]) < btMachEps()) // if there are multiple rows, check if they contain the row for z_0.
i++; for (int i = 0; i < activeRows.size(); i++)
if (v[i] > 0) {
return true; if (activeRows[i] == z0Row)
{
return z0Row;
}
}
return false; // look through the columns of the inverse of the basic matrix from left to right until the tie is broken.
for (int col = 0; col < dim ; col++)
{
btAlignedObjectArray<int> activeRowsCopy(activeRows);
activeRows.clear();
firstRow = true;
for (int i = 0; i<activeRowsCopy.size();i++)
{
const int row = activeRowsCopy[i];
// denom is positive here as an invariant.
const btScalar denom = A(row, pivotColIndex);
const btScalar ratio = A(row, col) / denom;
if (firstRow)
{
currentMin = ratio;
activeRows.push_back(row);
firstRow = false;
}
else if (fabs(currentMin - ratio) < btMachEps())
{
activeRows.push_back(row);
}
else if (currentMin > ratio)
{
currentMin = ratio;
activeRows.clear();
activeRows.push_back(row);
}
}
if (activeRows.size() == 1)
{
return activeRows[0];
}
}
// must not reach here.
isRayTermination = true;
return 0;
} }
void btLemkeAlgorithm::GaussJordanEliminationStep(btMatrixXu& A, int pivotRowIndex, int pivotColumnIndex, const btAlignedObjectArray<int>& basis) void btLemkeAlgorithm::GaussJordanEliminationStep(btMatrixXu& A, int pivotRowIndex, int pivotColumnIndex, const btAlignedObjectArray<int>& basis)

View file

@ -71,8 +71,7 @@ public:
} }
protected: protected:
int findLexicographicMinimum(const btMatrixXu& A, const int& pivotColIndex); int findLexicographicMinimum(const btMatrixXu& A, const int& pivotColIndex, const int& z0Row, bool& isRayTermination);
bool LexicographicPositive(const btVectorXu& v);
void GaussJordanEliminationStep(btMatrixXu& A, int pivotRowIndex, int pivotColumnIndex, const btAlignedObjectArray<int>& basis); void GaussJordanEliminationStep(btMatrixXu& A, int pivotRowIndex, int pivotColumnIndex, const btAlignedObjectArray<int>& basis);
bool greaterZero(const btVectorXu& vector); bool greaterZero(const btVectorXu& vector);
bool validBasis(const btAlignedObjectArray<int>& basis); bool validBasis(const btAlignedObjectArray<int>& basis);

View file

@ -2807,7 +2807,7 @@ bool btSoftBody::checkDeformableContact(const btCollisionObjectWrapper* colObjWr
// //
// Compute barycentric coordinates (u, v, w) for // Compute barycentric coordinates (u, v, w) for
// point p with respect to triangle (a, b, c) // point p with respect to triangle (a, b, c)
static void getBarycentric(const btVector3& p, btVector3& a, btVector3& b, btVector3& c, btVector3& bary) static void getBarycentric(const btVector3& p, const btVector3& a, const btVector3& b, const btVector3& c, btVector3& bary)
{ {
btVector3 v0 = b - a, v1 = c - a, v2 = p - a; btVector3 v0 = b - a, v1 = c - a, v2 = p - a;
btScalar d00 = v0.dot(v0); btScalar d00 = v0.dot(v0);
@ -2816,8 +2816,17 @@ static void getBarycentric(const btVector3& p, btVector3& a, btVector3& b, btVec
btScalar d20 = v2.dot(v0); btScalar d20 = v2.dot(v0);
btScalar d21 = v2.dot(v1); btScalar d21 = v2.dot(v1);
btScalar denom = d00 * d11 - d01 * d01; btScalar denom = d00 * d11 - d01 * d01;
// In the case of a degenerate triangle, pick a vertex.
if (btFabs(denom) < SIMD_EPSILON)
{
bary.setY(btScalar(0.0));
bary.setZ(btScalar(0.0));
}
else
{
bary.setY((d11 * d20 - d01 * d21) / denom); bary.setY((d11 * d20 - d01 * d21) / denom);
bary.setZ((d00 * d21 - d01 * d20) / denom); bary.setZ((d00 * d21 - d01 * d20) / denom);
}
bary.setX(btScalar(1) - bary.getY() - bary.getZ()); bary.setX(btScalar(1) - bary.getY() - bary.getZ());
} }

View file

@ -678,7 +678,9 @@ HullError HullLibrary::CreateConvexHull(const HullDesc &desc, // describes the
if (vcount < 8) vcount = 8; if (vcount < 8) vcount = 8;
btAlignedObjectArray<btVector3> vertexSource; btAlignedObjectArray<btVector3> vertexSource;
vertexSource.resize(static_cast<int>(vcount)); btVector3 zero;
zero.setZero();
vertexSource.resize(static_cast<int>(vcount), zero);
btVector3 scale; btVector3 scale;

View file

@ -25,7 +25,7 @@ subject to the following restrictions:
#include <float.h> #include <float.h>
/* SVN $Revision$ on $Date$ from http://bullet.googlecode.com*/ /* SVN $Revision$ on $Date$ from http://bullet.googlecode.com*/
#define BT_BULLET_VERSION 324 #define BT_BULLET_VERSION 325
inline int btGetVersion() inline int btGetVersion()
{ {

View file

@ -481,7 +481,7 @@ public:
buffer[9] = '3'; buffer[9] = '3';
buffer[10] = '2'; buffer[10] = '2';
buffer[11] = '4'; buffer[11] = '5';
} }
virtual void startSerialization() virtual void startSerialization()
@ -512,7 +512,7 @@ public:
currentPtr += BT_HEADER_LENGTH; currentPtr += BT_HEADER_LENGTH;
for (int i = 0; i < m_chunkPtrs.size(); i++) for (int i = 0; i < m_chunkPtrs.size(); i++)
{ {
int curLength = sizeof(btChunk) + m_chunkPtrs[i]->m_length; int curLength = (int)sizeof(btChunk) + m_chunkPtrs[i]->m_length;
memcpy(currentPtr, m_chunkPtrs[i], curLength); memcpy(currentPtr, m_chunkPtrs[i], curLength);
btAlignedFree(m_chunkPtrs[i]); btAlignedFree(m_chunkPtrs[i]);
currentPtr += curLength; currentPtr += curLength;

View file

@ -1 +1 @@
3.24 3.25

View file

@ -1,17 +0,0 @@
diff --git a/thirdparty/bullet/BulletSoftBody/btSparseSDF.h b/thirdparty/bullet/BulletSoftBody/btSparseSDF.h
index ae1288d9e6..243b80f8ae 100644
--- a/thirdparty/bullet/BulletSoftBody/btSparseSDF.h
+++ b/thirdparty/bullet/BulletSoftBody/btSparseSDF.h
@@ -233,9 +233,9 @@ struct btSparseSdf
//int sz = sizeof(Cell);
if (ncells > m_clampCells)
{
- static int numResets = 0;
- numResets++;
- // printf("numResets=%d\n",numResets);
+ //static int numResets = 0;
+ //numResets++;
+ //printf("numResets=%d\n",numResets);
Reset();
}