Преглед изворни кода

3rdparty: bullet3: remove getters/setters from btMatrixX

Part-of: #259
Daniele Bartolini пре 1 година
родитељ
комит
ae77e3e0d6

+ 4 - 4
3rdparty/bullet3/src/BulletDynamics/Featherstone/btMultiBodyMLCPConstraintSolver.cpp

@@ -519,7 +519,7 @@ void btMultiBodyMLCPConstraintSolver::createMLCPFastRigidBody(const btContactSol
 	if (1)
 	{
 		// add cfm to the diagonal of m_A
-		for (int i = 0; i < m_A.rows(); ++i)
+		for (int i = 0; i < m_A.m_rows; ++i)
 		{
 			m_A.setElem(i, i, m_A(i, i) + infoGlobal.m_globalCfm / infoGlobal.m_timeStep);
 		}
@@ -628,7 +628,7 @@ void btMultiBodyMLCPConstraintSolver::createMLCPFastMultiBody(const btContactSol
 	}
 
 	// Add CFM to the diagonal of m_A
-	for (int i = 0; i < m_multiBodyA.rows(); ++i)
+	for (int i = 0; i < m_multiBodyA.m_rows; ++i)
 	{
 		m_multiBodyA.setElem(i, i, m_multiBodyA(i, i) + infoGlobal.m_globalCfm / infoGlobal.m_timeStep);
 	}
@@ -658,7 +658,7 @@ bool btMultiBodyMLCPConstraintSolver::solveMLCP(const btContactSolverInfo& infoG
 {
 	bool result = true;
 
-	if (m_A.rows() != 0)
+	if (m_A.m_rows != 0)
 	{
 		// If using split impulse, we solve 2 separate (M)LCPs
 		if (infoGlobal.m_splitImpulse)
@@ -680,7 +680,7 @@ bool btMultiBodyMLCPConstraintSolver::solveMLCP(const btContactSolverInfo& infoG
 	if (!result)
 		return false;
 
-	if (m_multiBodyA.rows() != 0)
+	if (m_multiBodyA.m_rows != 0)
 	{
 		result = m_solver->solveMLCP(m_multiBodyA, m_multiBodyB, m_multiBodyX, m_multiBodyLo, m_multiBodyHi, m_multiBodyLimitDependencies, infoGlobal.m_numIterations);
 	}

+ 7 - 7
3rdparty/bullet3/src/BulletDynamics/MLCPSolvers/btLemkeAlgorithm.cpp

@@ -4,8 +4,8 @@ Code was converted for the Bullet Continuous Collision Detection and Physics Lib
 
 This software is provided 'as-is', without any express or implied warranty.
 In no event will the authors be held liable for any damages arising from the use of this software.
-Permission is granted to anyone to use this software for any purpose, 
-including commercial applications, and to alter it and redistribute it freely, 
+Permission is granted to anyone to use this software for any purpose,
+including commercial applications, and to alter it and redistribute it freely,
 subject to the following restrictions:
 
 1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required.
@@ -228,7 +228,7 @@ int btLemkeAlgorithm::findLexicographicMinimum(const btMatrixXu& A, const int& p
         bool firstRow = true;
 	btScalar currentMin = 0.0;
 
-	int dim = A.rows();
+	int dim = A.m_rows;
 
 	for (int row = 0; row < dim; row++)
 	{
@@ -323,11 +323,11 @@ void btLemkeAlgorithm::GaussJordanEliminationStep(btMatrixXu& A, int pivotRowInd
 	cout << A << std::endl;
 #endif
 
-	for (int i = 0; i < A.rows(); i++)
+	for (int i = 0; i < A.m_rows; i++)
 	{
 		if (i != pivotRowIndex)
 		{
-			for (int j = 0; j < A.cols(); j++)
+			for (int j = 0; j < A.m_cols; j++)
 			{
 				if (j != pivotColumnIndex)
 				{
@@ -342,7 +342,7 @@ void btLemkeAlgorithm::GaussJordanEliminationStep(btMatrixXu& A, int pivotRowInd
 #ifdef BT_DEBUG_OSTREAM
 	cout << A << std::endl;
 #endif  //BT_DEBUG_OSTREAM
-	for (int i = 0; i < A.cols(); i++)
+	for (int i = 0; i < A.m_cols; i++)
 	{
 		A.mulElem(pivotRowIndex, i, -a);
 	}
@@ -350,7 +350,7 @@ void btLemkeAlgorithm::GaussJordanEliminationStep(btMatrixXu& A, int pivotRowInd
 	cout << A << std::endl;
 #endif  //#ifdef BT_DEBUG_OSTREAM
 
-	for (int i = 0; i < A.rows(); i++)
+	for (int i = 0; i < A.m_rows; i++)
 	{
 		if (i != pivotRowIndex)
 		{

+ 6 - 6
3rdparty/bullet3/src/BulletDynamics/MLCPSolvers/btMLCPSolver.cpp

@@ -4,8 +4,8 @@ Copyright (c) 2003-2013 Erwin Coumans  http://bulletphysics.org
 
 This software is provided 'as-is', without any express or implied warranty.
 In no event will the authors be held liable for any damages arising from the use of this software.
-Permission is granted to anyone to use this software for any purpose, 
-including commercial applications, and to alter it and redistribute it freely, 
+Permission is granted to anyone to use this software for any purpose,
+including commercial applications, and to alter it and redistribute it freely,
 subject to the following restrictions:
 
 1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required.
@@ -117,7 +117,7 @@ bool btMLCPSolver::solveMLCP(const btContactSolverInfo& infoGlobal)
 {
 	bool result = true;
 
-	if (m_A.rows() == 0)
+	if (m_A.m_rows == 0)
 		return true;
 
 	//if using split impulse, we solve 2 separate (M)LCPs
@@ -421,7 +421,7 @@ void btMLCPSolver::createMLCPFast(const btContactSolverInfo& infoGlobal)
 	if (1)
 	{
 		// add cfm to the diagonal of m_A
-		for (int i = 0; i < m_A.rows(); ++i)
+		for (int i = 0; i < m_A.m_rows; ++i)
 		{
 			m_A.setElem(i, i, m_A(i, i) + infoGlobal.m_globalCfm / infoGlobal.m_timeStep);
 		}
@@ -547,7 +547,7 @@ void btMLCPSolver::createMLCP(const btContactSolverInfo& infoGlobal)
 	if (1)
 	{
 		// add cfm to the diagonal of m_A
-		for (int i = 0; i < m_A.rows(); ++i)
+		for (int i = 0; i < m_A.m_rows; ++i)
 		{
 			m_A.setElem(i, i, m_A(i, i) + infoGlobal.m_globalCfm / infoGlobal.m_timeStep);
 		}
@@ -572,7 +572,7 @@ btScalar btMLCPSolver::solveGroupCacheFriendlyIterations(btCollisionObject** bod
 	bool result = true;
 	{
 		BT_PROFILE("solveMLCP");
-		//		printf("m_A(%d,%d)\n", m_A.rows(),m_A.cols());
+		//		printf("m_A(%d,%d)\n", m_A.m_rows,m_A.m_cols);
 		result = solveMLCP(infoGlobal);
 	}
 

+ 5 - 5
3rdparty/bullet3/src/BulletDynamics/MLCPSolvers/btSolveProjectedGaussSeidel.h

@@ -4,8 +4,8 @@ Copyright (c) 2003-2013 Erwin Coumans  http://bulletphysics.org
 
 This software is provided 'as-is', without any express or implied warranty.
 In no event will the authors be held liable for any damages arising from the use of this software.
-Permission is granted to anyone to use this software for any purpose, 
-including commercial applications, and to alter it and redistribute it freely, 
+Permission is granted to anyone to use this software for any purpose,
+including commercial applications, and to alter it and redistribute it freely,
 subject to the following restrictions:
 
 1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required.
@@ -34,15 +34,15 @@ public:
 
 	virtual bool solveMLCP(const btMatrixXu& A, const btVectorXu& b, btVectorXu& x, const btVectorXu& lo, const btVectorXu& hi, const btAlignedObjectArray<int>& limitDependency, int numIterations, bool useSparsity = true)
 	{
-		if (!A.rows())
+		if (!A.m_rows)
 			return true;
 		//the A matrix is sparse, so compute the non-zero elements
 		A.rowComputeNonZeroElements();
 
 		//A is a m-n matrix, m rows, n columns
-		btAssert(A.rows() == b.rows());
+		btAssert(A.m_rows == b.rows());
 
-		int i, j, numRows = A.rows();
+		int i, j, numRows = A.m_rows;
 
 		btScalar delta;
 

+ 27 - 34
3rdparty/bullet3/src/LinearMath/btMatrixX.h

@@ -4,8 +4,8 @@ Copyright (c) 2003-2013 Erwin Coumans  http://bulletphysics.org
 
 This software is provided 'as-is', without any express or implied warranty.
 In no event will the authors be held liable for any damages arising from the use of this software.
-Permission is granted to anyone to use this software for any purpose, 
-including commercial applications, and to alter it and redistribute it freely, 
+Permission is granted to anyone to use this software for any purpose,
+including commercial applications, and to alter it and redistribute it freely,
 subject to the following restrictions:
 
 1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required.
@@ -196,14 +196,7 @@ struct btMatrixX
 			m_storage.resize(rows * cols);
 		}
 	}
-	int cols() const
-	{
-		return m_cols;
-	}
-	int rows() const
-	{
-		return m_rows;
-	}
+
 	///we don't want this read/write operator(), because we cannot keep track of non-zero elements, use setElem instead
 	/*T& operator() (int row,int col)
 	{
@@ -243,7 +236,7 @@ struct btMatrixX
 	void copyLowerToUpperTriangle()
 	{
 		int count = 0;
-		for (int row = 0; row < rows(); row++)
+		for (int row = 0; row < m_rows; row++)
 		{
 			for (int col = 0; col < row; col++)
 			{
@@ -251,7 +244,7 @@ struct btMatrixX
 				count++;
 			}
 		}
-		//printf("copyLowerToUpperTriangle copied %d elements out of %dx%d=%d\n", count,rows(),cols(),cols()*rows());
+		//printf("copyLowerToUpperTriangle copied %d elements out of %dx%d=%d\n", count,m_rows,m_cols,m_cols*m_rows);
 	}
 
 	const T& operator()(int row, int col) const
@@ -275,10 +268,10 @@ struct btMatrixX
 
 	void setIdentity()
 	{
-		btAssert(rows() == cols());
+		btAssert(m_rows == m_cols);
 
 		setZero();
-		for (int row = 0; row < rows(); row++)
+		for (int row = 0; row < m_rows; row++)
 		{
 			setElem(row, row, 1);
 		}
@@ -287,10 +280,10 @@ struct btMatrixX
 	void printMatrix(const char* msg) const
 	{
 		printf("%s ---------------------\n", msg);
-		for (int i = 0; i < rows(); i++)
+		for (int i = 0; i < m_rows; i++)
 		{
 			printf("\n");
-			for (int j = 0; j < cols(); j++)
+			for (int j = 0; j < m_cols; j++)
 			{
 				printf("%2.1f\t", (*this)(i, j));
 			}
@@ -300,11 +293,11 @@ struct btMatrixX
 
 	void rowComputeNonZeroElements() const
 	{
-		m_rowNonZeroElements1.resize(rows());
-		for (int i = 0; i < rows(); i++)
+		m_rowNonZeroElements1.resize(m_rows);
+		for (int i = 0; i < m_rows; i++)
 		{
 			m_rowNonZeroElements1[i].resize(0);
-			for (int j = 0; j < cols(); j++)
+			for (int j = 0; j < m_cols; j++)
 			{
 				if ((*this)(i, j) != 0.f)
 				{
@@ -333,20 +326,20 @@ struct btMatrixX
 	btMatrixX operator*(const btMatrixX& other)
 	{
 		//btMatrixX*btMatrixX implementation, brute force
-		btAssert(cols() == other.rows());
+		btAssert(m_cols == other.m_rows);
 
-		btMatrixX res(rows(), other.cols());
+		btMatrixX res(m_rows, other.m_cols);
 		res.setZero();
 		//		BT_PROFILE("btMatrixX mul");
-		for (int i = 0; i < rows(); ++i)
+		for (int i = 0; i < m_rows; ++i)
 		{
 			{
-				for (int j = 0; j < other.cols(); ++j)
+				for (int j = 0; j < other.m_cols; ++j)
 				{
 					T dotProd = 0;
 					{
 						{
-							int c = cols();
+							int c = m_cols;
 
 							for (int k = 0; k < c; k++)
 							{
@@ -428,11 +421,11 @@ struct btMatrixX
 
 	void setSubMatrix(int rowstart, int colstart, int rowend, int colend, const btMatrixX& block)
 	{
-		btAssert(rowend + 1 - rowstart == block.rows());
-		btAssert(colend + 1 - colstart == block.cols());
-		for (int row = 0; row < block.rows(); row++)
+		btAssert(rowend + 1 - rowstart == block.m_rows);
+		btAssert(colend + 1 - colstart == block.m_cols);
+		for (int row = 0; row < block.m_rows; row++)
 		{
-			for (int col = 0; col < block.cols(); col++)
+			for (int col = 0; col < block.m_cols; col++)
 			{
 				setElem(rowstart + row, colstart + col, block(row, col));
 			}
@@ -453,9 +446,9 @@ struct btMatrixX
 
 	btMatrixX negative()
 	{
-		btMatrixX neg(rows(), cols());
-		for (int i = 0; i < rows(); i++)
-			for (int j = 0; j < cols(); j++)
+		btMatrixX neg(m_rows, m_cols);
+		for (int i = 0; i < m_rows; i++)
+			for (int j = 0; j < m_cols; j++)
 			{
 				T v = (*this)(i, j);
 				neg.setElem(i, j, -v);
@@ -476,13 +469,13 @@ std::ostream& operator<<(std::ostream& os, const btMatrixX<T>& mat)
 {
 	os << " [";
 	//printf("%s ---------------------\n",msg);
-	for (int i = 0; i < mat.rows(); i++)
+	for (int i = 0; i < mat.m_rows; i++)
 	{
-		for (int j = 0; j < mat.cols(); j++)
+		for (int j = 0; j < mat.m_cols; j++)
 		{
 			os << std::setw(12) << mat(i, j);
 		}
-		if (i != mat.rows() - 1)
+		if (i != mat.m_rows - 1)
 			os << std::endl
 			   << "  ";
 	}