24 #ifndef BT_MULTIBODY_H
25 #define BT_MULTIBODY_H
34 #ifdef BT_USE_DOUBLE_PRECISION
35 #define btMultiBodyData btMultiBodyDoubleData
36 #define btMultiBodyDataName "btMultiBodyDoubleData"
37 #define btMultiBodyLinkData btMultiBodyLinkDoubleData
38 #define btMultiBodyLinkDataName "btMultiBodyLinkDoubleData"
40 #define btMultiBodyData btMultiBodyFloatData
41 #define btMultiBodyDataName "btMultiBodyFloatData"
42 #define btMultiBodyLinkData btMultiBodyLinkFloatData
43 #define btMultiBodyLinkDataName "btMultiBodyLinkFloatData"
63 bool canSleep,
bool deprecatedMultiDof =
true);
68 void setupFixed(
int i,
73 const btVector3 &parentComToThisPivotOffset,
74 const btVector3 &thisPivotToThisComOffset,
bool deprecatedDisableParentCollision =
true);
76 void setupPrismatic(
int i,
82 const btVector3 &parentComToThisPivotOffset,
83 const btVector3 &thisPivotToThisComOffset,
84 bool disableParentCollision);
86 void setupRevolute(
int i,
92 const btVector3 &parentComToThisPivotOffset,
93 const btVector3 &thisPivotToThisComOffset,
94 bool disableParentCollision =
false);
96 void setupSpherical(
int i,
101 const btVector3 &parentComToThisPivotOffset,
102 const btVector3 &thisPivotToThisComOffset,
103 bool disableParentCollision =
false);
105 void setupPlanar(
int i,
111 const btVector3 &parentComToThisComOffset,
112 bool disableParentCollision =
false);
116 return m_links[index];
121 return m_links[index];
126 m_baseCollider = collider;
130 return m_baseCollider;
134 return m_baseCollider;
139 if (index >= 0 && index < getNumLinks())
141 return getLink(index).m_collider;
148 if (index >= 0 && index < getNumLinks())
150 return getLink(index).m_collider;
160 int getParent(
int link_num)
const;
172 const btVector3 &getLinkInertia(
int i)
const;
191 return btVector3(m_realBuf[3], m_realBuf[4], m_realBuf[5]);
200 return m_basePos_interpolate;
204 return m_baseQuat_interpolate;
213 m_basePos_interpolate = pos;
232 m_realBuf[3] = vel[0];
233 m_realBuf[4] = vel[1];
234 m_realBuf[5] = vel[2];
239 m_baseQuat_interpolate = rot;
243 m_realBuf[0] = omega[0];
244 m_realBuf[1] = omega[1];
245 m_realBuf[2] = omega[2];
255 btScalar *getJointVelMultiDof(
int i);
256 btScalar *getJointPosMultiDof(
int i);
258 const btScalar *getJointVelMultiDof(
int i)
const;
259 const btScalar *getJointPosMultiDof(
int i)
const;
261 void setJointPos(
int i,
btScalar q);
262 void setJointVel(
int i,
btScalar qdot);
263 void setJointPosMultiDof(
int i,
const double *q);
264 void setJointVelMultiDof(
int i,
const double *qdot);
265 void setJointPosMultiDof(
int i,
const float *q);
266 void setJointVelMultiDof(
int i,
const float *qdot);
274 return &m_realBuf[0];
292 const btVector3 &getRVector(
int i)
const;
294 const btVector3 &getInterpolateRVector(
int i)
const;
295 const btQuaternion &getInterpolateParentToLocalRot(
int i)
const;
322 void clearForcesAndTorques();
323 void clearConstraintForces();
325 void clearVelocities();
332 void addLinkForce(
int i,
const btVector3 &f);
333 void addLinkTorque(
int i,
const btVector3 &t);
337 m_baseConstraintForce += f;
340 void addLinkConstraintForce(
int i,
const btVector3 &f);
341 void addLinkConstraintTorque(
int i,
const btVector3 &t);
343 void addJointTorque(
int i,
btScalar Q);
344 void addJointTorqueMultiDof(
int i,
int dof,
btScalar Q);
345 void addJointTorqueMultiDof(
int i,
const btScalar *Q);
349 const btVector3 &getLinkForce(
int i)
const;
350 const btVector3 &getLinkTorque(
int i)
const;
351 btScalar getJointTorque(
int i)
const;
352 btScalar *getJointTorqueMultiDof(
int i);
371 void computeAccelerationsArticulatedBodyAlgorithmMultiDof(
btScalar dt,
375 bool isConstraintPass,
376 bool jointFeedbackInWorldSpace,
377 bool jointFeedbackInJointFrame
402 for (
int dof = 0; dof < 6 + getNumDofs(); ++dof)
404 m_deltaV[dof] += delta_vee[dof] * multiplier;
409 applyDeltaVeeMultiDof(&m_deltaV[0], 1);
411 for (
int dof = 0; dof < 6 + getNumDofs(); ++dof)
435 for (
int dof = 0; dof < 6 + getNumDofs(); ++dof)
437 m_realBuf[dof] += delta_vee[dof] * multiplier;
438 btClamp(m_realBuf[dof], -m_maxCoordinateVelocity, m_maxCoordinateVelocity);
446 void predictPositionsMultiDof(
btScalar dt);
466 void fillConstraintJacobianMultiDof(
int link,
482 m_canSleep = canSleep;
498 m_canWakeup = canWakeup;
503 void checkMotionAndSleepIfRequired(
btScalar timestep);
512 m_fixedBase = fixedBase;
527 m_links.resize(numLinks);
532 return m_linearDamping;
536 m_linearDamping = damp;
540 return m_angularDamping;
544 m_angularDamping = damp;
549 return m_useGyroTerm;
553 m_useGyroTerm = useGyro;
557 return m_maxCoordinateVelocity;
561 m_maxCoordinateVelocity = maxVel;
566 return m_maxAppliedImpulse;
570 m_maxAppliedImpulse = maxImp;
574 m_hasSelfCollision = hasSelfCollision;
578 return m_hasSelfCollision;
581 void finalizeMultiDof();
594 __posUpdated = updated;
600 return m_internalNeedsJointFeedback;
656 static void spatialTransform(
const btMatrix3x3 &rotation_matrix,
674 int dofOffset = 0, cfgOffset = 0;
675 for (
int bidx = 0; bidx < m_links.size(); ++bidx)
677 m_links[bidx].m_dofOffset = dofOffset;
678 m_links[bidx].m_cfgOffset = cfgOffset;
679 dofOffset += m_links[bidx].m_dofCount;
680 cfgOffset += m_links[bidx].m_posVarCount;
void btClamp(T &a, const T &lb, const T &ub)
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...
#define ATTRIBUTE_ALIGNED16(a)
void * m_userObjectPointer
users can point to their objects, m_userPointer is not used by Bullet, see setUserPointer/getUserPoin...
The btMatrix3x3 class implements a 3x3 rotation matrix, to perform linear algebra in combination with...
virtual int calculateSerializeBufferSize() const
virtual const char * serialize(void *dataBuffer, class btSerializer *serializer) const
fills the dataBuffer and returns the struct name (and 0 on failure)
btScalar m_maxCoordinateVelocity
void useRK4Integration(bool use)
const btScalar * getDeltaVelocityVector() const
void setMaxCoordinateVelocity(btScalar maxVel)
void * getUserPointer() const
users can point to their objects, userPointer is not used by Bullet
btMultiBodyLinkCollider * getLinkCollider(int index)
void setMaxAppliedImpulse(btScalar maxImp)
btAlignedObjectArray< btMultibodyLink > m_links
btAlignedObjectArray< btMatrix3x3 > m_matrixBuf
btMultiBodyLinkCollider * m_baseCollider
void fillContactJacobianMultiDof(int link, const btVector3 &contact_point, const btVector3 &normal, btScalar *jac, btAlignedObjectArray< btScalar > &scratch_r, btAlignedObjectArray< btVector3 > &scratch_v, btAlignedObjectArray< btMatrix3x3 > &scratch_m) const
bool getUseGyroTerm() const
bool getCanWakeup() const
void setCanSleep(bool canSleep)
void setUseGyroTerm(bool useGyro)
int getCompanionId() const
btScalar getAngularDamping() const
const btQuaternion & getInterpolateWorldToBaseRot() const
int getUserIndex2() const
btVector3 m_basePos_interpolate
btAlignedObjectArray< btVector3 > m_vectorBuf
void addBaseConstraintForce(const btVector3 &f)
btScalar m_maxAppliedImpulse
void setBaseMass(btScalar mass)
void setBaseInertia(const btVector3 &inertia)
btScalar m_angularDamping
void setHasSelfCollision(bool hasSelfCollision)
void * m_userObjectPointer
void setLinearDamping(btScalar damp)
bool hasSelfCollision() const
void setUserIndex2(int index)
void setBaseVel(const btVector3 &vel)
btMatrix3x3 m_cachedInertiaLowerRight
void setBaseOmega(const btVector3 &omega)
void addBaseTorque(const btVector3 &t)
void useGlobalVelocities(bool use)
BT_DECLARE_ALIGNED_ALLOCATOR()
const btQuaternion & getWorldToBaseRot() const
btAlignedObjectArray< btScalar > m_realBuf
btVector3 m_baseConstraintTorque
void operator=(const btMultiBody &)
void setBaseName(const char *name)
memory of setBaseName needs to be manager by user
const btVector3 & getBasePos() const
btVector3 getBaseOmega() const
btQuaternion m_baseQuat_interpolate
btMultibodyLink & getLink(int index)
void setBasePos(const btVector3 &pos)
bool m_useGlobalVelocities
bool isUsingGlobalVelocities() const
btMatrix3x3 m_cachedInertiaLowerLeft
btMultiBodyLinkCollider * getBaseCollider()
void setAngularDamping(btScalar damp)
const btMultibodyLink & getLink(int index) const
const char * getBaseName() const
bool hasFixedBase() const
void setUserPointer(void *userPointer)
users can point to their objects, userPointer is not used by Bullet
const btVector3 & getBaseForce() const
void processDeltaVeeMultiDof2()
void setPosUpdated(bool updated)
btScalar getMaxAppliedImpulse() const
btMatrix3x3 m_cachedInertiaTopLeft
bool isUsingRK4Integration() const
bool m_cachedInertiaValid
bool internalNeedsJointFeedback() const
void setNumLinks(int numLinks)
const btVector3 & getBaseInertia() const
const btMultiBodyLinkCollider * getLinkCollider(int index) const
const btScalar * getVelocityVector() const
btTransform getBaseWorldTransform() const
btScalar getLinearDamping() const
void setCanWakeup(bool canWakeup)
const btMultiBodyLinkCollider * getBaseCollider() const
btMatrix3x3 m_cachedInertiaTopRight
btScalar getBaseMass() const
void setFixedBase(bool fixedBase)
const btVector3 & getBaseTorque() const
btScalar getMaxCoordinateVelocity() const
btAlignedObjectArray< btScalar > m_deltaV
int getNumPosVars() const
void updateLinksDofOffsets()
const btVector3 & getInterpolateBasePos() const
void addBaseConstraintTorque(const btVector3 &t)
bool isPosUpdated() const
bool m_internalNeedsJointFeedback
the m_needsJointFeedback gets updated/computed during the stepVelocitiesMultiDof and it for internal ...
btVector3 m_baseConstraintForce
void setWorldToBaseRot(const btQuaternion &rot)
void setCompanionId(int id)
btMultiBody(const btMultiBody &)
void applyDeltaVeeMultiDof(const btScalar *delta_vee, btScalar multiplier)
const btVector3 getBaseVel() const
void addBaseForce(const btVector3 &f)
void applyDeltaVeeMultiDof2(const btScalar *delta_vee, btScalar multiplier)
void setUserIndex(int index)
users can point to their objects, userPointer is not used by Bullet
void setBaseCollider(btMultiBodyLinkCollider *collider)
void setBaseWorldTransform(const btTransform &tr)
The btQuaternion implements quaternion to perform linear algebra rotations in combination with btMatr...
btQuaternion inverse() const
Return the inverse of this quaternion.
btVector3 can be used to represent 3D points and vectors.
do not change those serialization structures, it requires an updated sBulletDNAstr/sBulletDNAstr64
do not change those serialization structures, it requires an updated sBulletDNAstr/sBulletDNAstr64
do not change those serialization structures, it requires an updated sBulletDNAstr/sBulletDNAstr64
btVector3DoubleData m_baseWorldPosition
btVector3DoubleData m_baseInertia
btVector3DoubleData m_baseLinearVelocity
btCollisionObjectDoubleData * m_baseCollider
btVector3DoubleData m_baseAngularVelocity
btQuaternionDoubleData m_baseWorldOrientation
btMultiBodyLinkDoubleData * m_links
do not change those serialization structures, it requires an updated sBulletDNAstr/sBulletDNAstr64
btCollisionObjectFloatData * m_baseCollider
btQuaternionFloatData m_baseWorldOrientation
btVector3FloatData m_baseInertia
btVector3FloatData m_baseAngularVelocity
btVector3FloatData m_baseLinearVelocity
btMultiBodyLinkFloatData * m_links
btVector3FloatData m_baseWorldPosition
btQuaternionDoubleData m_zeroRotParentToThis
btVector3DoubleData m_absFrameLocVelocityBottom
btCollisionObjectDoubleData * m_linkCollider
btVector3DoubleData m_jointAxisBottom[6]
btVector3DoubleData m_thisPivotToThisComOffset
btVector3DoubleData m_absFrameTotVelocityTop
btVector3DoubleData m_parentComToThisPivotOffset
btVector3DoubleData m_jointAxisTop[6]
btVector3DoubleData m_absFrameTotVelocityBottom
btVector3DoubleData m_absFrameLocVelocityTop
double m_jointMaxVelocity
btVector3DoubleData m_linkInertia
btCollisionObjectFloatData * m_linkCollider
btVector3FloatData m_absFrameLocVelocityTop
btQuaternionFloatData m_zeroRotParentToThis
btVector3FloatData m_absFrameTotVelocityBottom
btVector3FloatData m_jointAxisBottom[6]
btVector3FloatData m_parentComToThisPivotOffset
btVector3FloatData m_absFrameLocVelocityBottom
btVector3FloatData m_linkInertia
btVector3FloatData m_thisPivotToThisComOffset
btVector3FloatData m_absFrameTotVelocityTop
btVector3FloatData m_jointAxisTop[6]
These spatial algebra classes are used for btMultiBody, see BulletDynamics/Featherstone.