52 for (
int i = 0; i <
m_dv.
size(); ++i)
102 f2 = f0 - alpha * scale * inner_product;
159 for (
int i = 0; i <
m_dv.
size(); ++i)
172 if (inner_product < -tol)
176 std::cout <<
"Looking backwards!" << std::endl;
182 inner_product = -inner_product;
184 else if (std::abs(inner_product) < tol)
188 std::cout <<
"Gradient Descent!" << std::endl;
193 m_ddv[i] = scale * residual[i];
195 inner_product = scale * res_norm * res_norm;
197 return inner_product;
261 return maxSquaredResidual;
281 m_dv[counter].setZero();
347 m_dv[counter].setZero();
424 BT_PROFILE(
"btDeformableBodySolver::predictDeformableMotion");
523 btScalar clampDeltaV = maxDisplacement / timeStep;
524 for (
int c = 0; c < 3; c++)
526 if (node.
m_v[c] > clampDeltaV)
528 node.
m_v[c] = clampDeltaV;
530 if (node.
m_v[c] < -clampDeltaV)
532 node.
m_v[c] = -clampDeltaV;
550 if (multibodyLinkCol)
static const int kMaxConjugateGradientIterations
const T & btMax(const T &a, const T &b)
btQuaternion inverse(const btQuaternion &q)
Return the inverse of a quaternion.
float btScalar
The btScalar type abstracts floating point numbers, to easily switch between double and single floati...
static btMatrix3x3 OuterProduct(const btScalar *v1, const btScalar *v2, const btScalar *v3, const btScalar *u1, const btScalar *u2, const btScalar *u3, int ndof)
static btVector3 generateUnitOrthogonalVector(const btVector3 &u)
static void findJacobian(const btMultiBodyLinkCollider *multibodyLinkCol, btMultiBodyJacobianData &jacobianData, const btVector3 &contact_point, const btVector3 &dir)
btSoftBody implementation by Nathanael Presson
static btMatrix3x3 Diagonal(btScalar x)
btVector3 btCross(const btVector3 &v1, const btVector3 &v2)
Return the cross product of two vectors.
virtual void reinitialize(bool nodeUpdated)=0
int size() const
return the number of elements in the array
void copyFromArray(const btAlignedObjectArray &otherArray)
void resize(int newsize, const T &fillData=T())
btCollisionObject can be used to manage collision detection objects.
btTransform & getWorldTransform()
int getInternalType() const
reserved for Bullet internal usage
const btCollisionShape * getCollisionShape() const
The btCollisionShape class provides an interface for collision shapes that can be shared among btColl...
virtual btScalar getMargin() const =0
int solve(MatrixX &A, TVStack &x, const TVStack &b, bool verbose=false)
int solve(MatrixX &A, TVStack &x, const TVStack &b, bool verbose=false)
virtual void updateSoftBodies()
Perform necessary per-step updates of soft bodies such as recomputing normals and bounding boxes.
virtual void solveDeformableConstraints(btScalar solverdt)
void updateEnergy(btScalar scale)
virtual void setConstraints(const btContactSolverInfo &infoGlobal)
virtual ~btDeformableBodySolver()
btDeformableBackwardEulerObjective * m_objective
virtual void applyTransforms(btScalar timeStep)
int m_maxNewtonIterations
btScalar computeDescentStep(TVStack &ddv, const TVStack &residual, bool verbose=false)
void predictDeformableMotion(btSoftBody *psb, btScalar dt)
btConjugateResidual< btDeformableBackwardEulerObjective > m_cr
btConjugateGradient< btDeformableBackwardEulerObjective > m_cg
virtual void reinitialize(const btAlignedObjectArray< btSoftBody * > &softBodies, btScalar dt)
virtual void setupDeformableSolve(bool implicit)
void setLineSearch(bool lineSearch)
btAlignedObjectArray< btSoftBody * > m_softBodies
virtual btScalar solveContactConstraints(btCollisionObject **deformableBodies, int numDeformableBodies, const btContactSolverInfo &infoGlobal)
btScalar m_newtonTolerance
virtual void predictMotion(btScalar solverdt)
Predict motion of soft bodies into next timestep.
void setImplicit(bool implicit)
void computeStep(TVStack &ddv, const TVStack &residual)
void updateTempPosition()
virtual void applyExplicitForce()
void updateDv(btScalar scale=1)
virtual btScalar dot(const TVStack &a, const TVStack &b)
The btMatrix3x3 class implements a 3x3 rotation matrix, to perform linear algebra in combination with...
btMatrix3x3 transpose() const
Return the transpose of the matrix.
static btMultiBodyLinkCollider * upcast(btCollisionObject *colObj)
btMultiBody * m_multiBody
btMultiBodyJacobianData jacobianData_t1
btMultiBodyJacobianData jacobianData_normal
btMultiBodyJacobianData jacobianData_t2
The btSoftBody is an class to simulate cloth and volumetric soft bodies.
void interpolateRenderMesh()
void updateFaceTree(bool use_velocity, bool margin)
void updateNodeTree(bool use_velocity, bool margin)
btAlignedObjectArray< DeformableFaceNodeContact > m_faceNodeContactsCCD
btSoftBodyWorldInfo * m_worldInfo
btAlignedObjectArray< DeformableFaceNodeContact > m_faceNodeContacts
btScalar m_maxSpeedSquared
btAlignedObjectArray< DeformableFaceRigidContact > m_faceRigidContacts
btAlignedObjectArray< DeformableNodeRigidAnchor > m_deformableAnchors
btAlignedObjectArray< DeformableNodeRigidContact > m_nodeRigidContacts
btSoftBodyWorldInfo * getWorldInfo()
void initializeFaceTree()
btVector3 can be used to represent 3D points and vectors.
const btScalar & getZ() const
Return the z value.
btVector3 & safeNormalize()
btScalar norm() const
Return the norm (length) of the vector.
const btScalar & getY() const
Return the y value.
const btScalar & getX() const
Return the x value.
btAlignedObjectArray< btScalar > m_deltaVelocitiesUnitImpulse
btAlignedObjectArray< btScalar > m_jacobians
btSparseSdf< 3 > m_sparsesdf
btScalar m_maxDisplacement
@ SDF_RD
Cluster vs convex rigid vs soft.
const btCollisionObject * m_colObj
btScalar Evaluate(const btVector3 &x, const btCollisionShape *shape, btVector3 &normal, btScalar margin)