improve mpcg
This improved performance significantly in some small test systems.
This commit is contained in:
		| @@ -124,8 +124,7 @@ struct b3SpringClothStep | ||||
| 	u32 iterations; | ||||
| }; | ||||
|  | ||||
| // This class implements a cloth. It treats cloth as a collection  | ||||
| // of masses connected by springs.  | ||||
| // A cloth it treats cloth as a collection of masses connected by springs.  | ||||
| // Large time steps can be taken. | ||||
| // If accuracy and stability are required, not performance,  | ||||
| // you can use this class instead of using b3Cloth. | ||||
| @@ -177,7 +176,7 @@ public: | ||||
| 	// Return the kinetic (or dynamic) energy in this system. | ||||
| 	float32 GetEnergy() const; | ||||
| 	 | ||||
| 	// Return the tension forces (due to springs) of each point mass. | ||||
| 	// Return the tension forces (due to springs) acting at each point mass. | ||||
| 	// Units are kg * m / s^2 | ||||
| 	void GetTension(b3Array<b3Vec3>& tensions) const; | ||||
|  | ||||
| @@ -222,6 +221,8 @@ protected: | ||||
| 	float32* m_m; | ||||
| 	float32* m_inv_m; | ||||
| 	b3Vec3* m_y; | ||||
| 	b3Vec3* m_z; | ||||
| 	b3Vec3* m_x0; | ||||
| 	b3MassType* m_types; | ||||
| 	u32 m_massCount; | ||||
|  | ||||
|   | ||||
| @@ -28,6 +28,7 @@ class b3SpringCloth; | ||||
| class b3StackAllocator; | ||||
|  | ||||
| struct b3DenseVec3; | ||||
| struct b3DiagMat33; | ||||
| struct b3SparseMat33; | ||||
|  | ||||
| struct b3MassContact; | ||||
| @@ -58,15 +59,15 @@ private: | ||||
| 	// Compute A and b in Ax = b | ||||
| 	void Compute_A_b(b3SparseMat33& A, b3DenseVec3& b) const; | ||||
|  | ||||
| 	// Compute the initial guess for the iterative solver. | ||||
| 	void Compute_x0(b3DenseVec3& x0); | ||||
| 	// Compute S. | ||||
| 	void Compute_S(b3DiagMat33& S); | ||||
|  | ||||
| 	// Compute the constraint projection matrix S. | ||||
| 	void Compute_S(b3Mat33* S); | ||||
| 	// Compute z.  | ||||
| 	void Compute_z(b3DenseVec3& z); | ||||
|  | ||||
| 	// Solve Ax = b. | ||||
| 	// Output x and the residual error f = Ax - b ~ 0. | ||||
| 	void Solve(b3DenseVec3& x0, b3DenseVec3& f, u32& iterations, const b3SparseMat33& A, const b3DenseVec3& b, const b3Mat33* S) const; | ||||
| 	void Solve(b3DenseVec3& x, b3DenseVec3& f, u32& iterations, const b3SparseMat33& A, const b3DenseVec3& b, const b3DiagMat33& S, const b3DenseVec3& z, const b3DenseVec3& y) const; | ||||
|  | ||||
| 	b3SpringCloth * m_cloth; | ||||
| 	float32 m_h; | ||||
| @@ -82,6 +83,8 @@ private: | ||||
| 	float32* m_m; | ||||
| 	float32* m_inv_m; | ||||
| 	b3Vec3* m_y; | ||||
| 	b3Vec3* m_z; | ||||
| 	b3Vec3* m_x0; | ||||
| 	b3MassType* m_types; | ||||
| 	u32 m_massCount; | ||||
|  | ||||
|   | ||||
		Reference in New Issue
	
	Block a user