sync repo

This commit is contained in:
Erwin Coumans
2015-11-11 12:44:26 -08:00
parent 91204e8ed2
commit f6a8079353
16 changed files with 239 additions and 62 deletions

View File

@@ -1,3 +1,6 @@
#include "PhysicsClient.h" #include "PhysicsClient.h"
PhysicsClient::~PhysicsClient() {} PhysicsClient::~PhysicsClient()
{
}

View File

@@ -337,13 +337,15 @@ void PhysicsClientExample::prepareAndSubmitCommand(int commandId)
}; };
} }
PhysicsClientExample::PhysicsClientExample(GUIHelperInterface* helper) PhysicsClientExample::PhysicsClientExample(GUIHelperInterface* helper)
:SharedMemoryCommon(helper), :SharedMemoryCommon(helper),
m_physicsClientHandle(0), m_physicsClientHandle(0),
m_selectedBody(-1),
m_prevSelectedBody(-1),
m_wantsTermination(false), m_wantsTermination(false),
m_sharedMemoryKey(SHARED_MEMORY_KEY), m_sharedMemoryKey(SHARED_MEMORY_KEY),
m_selectedBody(-1),
m_prevSelectedBody(-1),
m_numMotors(0) m_numMotors(0)
{ {
b3Printf("Started PhysicsClientExample\n"); b3Printf("Started PhysicsClientExample\n");

View File

@@ -3,6 +3,7 @@
#include "Win32SharedMemory.h" #include "Win32SharedMemory.h"
#include "LinearMath/btAlignedObjectArray.h" #include "LinearMath/btAlignedObjectArray.h"
#include "LinearMath/btVector3.h" #include "LinearMath/btVector3.h"
#include <string.h>
#include "Bullet3Common/b3Logging.h" #include "Bullet3Common/b3Logging.h"
#include "../Utils/b3ResourcePath.h" #include "../Utils/b3ResourcePath.h"
@@ -71,6 +72,15 @@ struct PhysicsClientSharedMemoryInternalData {
bool canSubmitCommand() const; bool canSubmitCommand() const;
}; };
static char* strDup(const char* const str)
{
#ifdef _WIN32
return _strdup(str);
#else
return strdup(str);
#endif
}
int PhysicsClientSharedMemory::getNumJoints(int bodyIndex) const int PhysicsClientSharedMemory::getNumJoints(int bodyIndex) const
{ {
BodyJointInfoCache** bodyJointsPtr = m_data->m_bodyJointMap[bodyIndex]; BodyJointInfoCache** bodyJointsPtr = m_data->m_bodyJointMap[bodyIndex];
@@ -188,24 +198,24 @@ const SharedMemoryStatus* PhysicsClientSharedMemory::processServerStatus() {
} }
if (serverCmd.m_dataStreamArguments.m_streamChunkLength > 0) { if (serverCmd.m_dataStreamArguments.m_streamChunkLength > 0) {
bParse::btBulletFile* bf = new bParse::btBulletFile( bParse::btBulletFile bf(
this->m_data->m_testBlock1->m_bulletStreamDataServerToClient, this->m_data->m_testBlock1->m_bulletStreamDataServerToClient,
serverCmd.m_dataStreamArguments.m_streamChunkLength); serverCmd.m_dataStreamArguments.m_streamChunkLength);
bf->setFileDNAisMemoryDNA(); bf.setFileDNAisMemoryDNA();
bf->parse(false); bf.parse(false);
int bodyIndex = serverCmd.m_dataStreamArguments.m_bodyUniqueId; int bodyIndex = serverCmd.m_dataStreamArguments.m_bodyUniqueId;
BodyJointInfoCache* bodyJoints = new BodyJointInfoCache; BodyJointInfoCache* bodyJoints = new BodyJointInfoCache;
m_data->m_bodyJointMap.insert(bodyIndex,bodyJoints); m_data->m_bodyJointMap.insert(bodyIndex,bodyJoints);
for (int i = 0; i < bf->m_multiBodies.size(); i++) { for (int i = 0; i < bf.m_multiBodies.size(); i++) {
int flag = bf->getFlags(); int flag = bf.getFlags();
int qOffset = 7; int qOffset = 7;
int uOffset = 6; int uOffset = 6;
if ((flag & bParse::FD_DOUBLE_PRECISION) != 0) { if ((flag & bParse::FD_DOUBLE_PRECISION) != 0) {
Bullet::btMultiBodyDoubleData* mb = Bullet::btMultiBodyDoubleData* mb =
(Bullet::btMultiBodyDoubleData*)bf->m_multiBodies[i]; (Bullet::btMultiBodyDoubleData*)bf.m_multiBodies[i];
if (mb->m_baseName) { if (mb->m_baseName) {
if (m_data->m_verboseOutput) { if (m_data->m_verboseOutput) {
b3Printf("mb->m_baseName = %s\n", mb->m_baseName); b3Printf("mb->m_baseName = %s\n", mb->m_baseName);
@@ -227,14 +237,14 @@ const SharedMemoryStatus* PhysicsClientSharedMemory::processServerStatus() {
b3Printf("mb->m_links[%d].m_linkName = %s\n", link, b3Printf("mb->m_links[%d].m_linkName = %s\n", link,
mb->m_links[link].m_linkName); mb->m_links[link].m_linkName);
} }
info.m_linkName = mb->m_links[link].m_linkName; info.m_linkName = strDup(mb->m_links[link].m_linkName);
} }
if (mb->m_links[link].m_jointName) { if (mb->m_links[link].m_jointName) {
if (m_data->m_verboseOutput) { if (m_data->m_verboseOutput) {
b3Printf("mb->m_links[%d].m_jointName = %s\n", link, b3Printf("mb->m_links[%d].m_jointName = %s\n", link,
mb->m_links[link].m_jointName); mb->m_links[link].m_jointName);
} }
info.m_jointName = mb->m_links[link].m_jointName; info.m_jointName = strDup(mb->m_links[link].m_jointName);
} }
info.m_jointType = mb->m_links[link].m_jointType; info.m_jointType = mb->m_links[link].m_jointType;
@@ -251,7 +261,7 @@ const SharedMemoryStatus* PhysicsClientSharedMemory::processServerStatus() {
} else { } else {
Bullet::btMultiBodyFloatData* mb = Bullet::btMultiBodyFloatData* mb =
(Bullet::btMultiBodyFloatData*)bf->m_multiBodies[i]; (Bullet::btMultiBodyFloatData*)bf.m_multiBodies[i];
if (mb->m_baseName) { if (mb->m_baseName) {
if (m_data->m_verboseOutput) { if (m_data->m_verboseOutput) {
b3Printf("mb->m_baseName = %s\n", mb->m_baseName); b3Printf("mb->m_baseName = %s\n", mb->m_baseName);
@@ -272,14 +282,14 @@ const SharedMemoryStatus* PhysicsClientSharedMemory::processServerStatus() {
b3Printf("mb->m_links[%d].m_linkName = %s\n", link, b3Printf("mb->m_links[%d].m_linkName = %s\n", link,
mb->m_links[link].m_linkName); mb->m_links[link].m_linkName);
} }
info.m_linkName = mb->m_links[link].m_linkName; info.m_linkName = strDup(mb->m_links[link].m_linkName);
} }
if (mb->m_links[link].m_jointName) { if (mb->m_links[link].m_jointName) {
if (m_data->m_verboseOutput) { if (m_data->m_verboseOutput) {
b3Printf("mb->m_links[%d].m_jointName = %s\n", link, b3Printf("mb->m_links[%d].m_jointName = %s\n", link,
mb->m_links[link].m_jointName); mb->m_links[link].m_jointName);
} }
info.m_jointName = mb->m_links[link].m_jointName; info.m_jointName = strDup(mb->m_links[link].m_jointName);
} }
info.m_jointType = mb->m_links[link].m_jointType; info.m_jointType = mb->m_links[link].m_jointType;
if ((mb->m_links[link].m_jointType == eRevoluteType) || if ((mb->m_links[link].m_jointType == eRevoluteType) ||
@@ -293,7 +303,7 @@ const SharedMemoryStatus* PhysicsClientSharedMemory::processServerStatus() {
} }
} }
} }
if (bf->ok()) { if (bf.ok()) {
if (m_data->m_verboseOutput) { if (m_data->m_verboseOutput) {
b3Printf("Received robot description ok!\n"); b3Printf("Received robot description ok!\n");
} }
@@ -401,6 +411,17 @@ const SharedMemoryStatus* PhysicsClientSharedMemory::processServerStatus() {
BodyJointInfoCache** bodyJointsPtr = m_data->m_bodyJointMap.getAtIndex(i); BodyJointInfoCache** bodyJointsPtr = m_data->m_bodyJointMap.getAtIndex(i);
if (bodyJointsPtr && *bodyJointsPtr) if (bodyJointsPtr && *bodyJointsPtr)
{ {
BodyJointInfoCache* bodyJoints = *bodyJointsPtr;
for (int j=0;j<bodyJoints->m_jointInfo.size();j++) {
if (bodyJoints->m_jointInfo[j].m_jointName)
{
free(bodyJoints->m_jointInfo[j].m_jointName);
}
if (bodyJoints->m_jointInfo[j].m_linkName)
{
free(bodyJoints->m_jointInfo[j].m_linkName);
}
}
delete (*bodyJointsPtr); delete (*bodyJointsPtr);
} }
} }

View File

@@ -1196,23 +1196,32 @@ inline void btDbvt::collideOCL( const btDbvtNode* root,
//void * memmove ( void * destination, const void * source, size_t num ); //void * memmove ( void * destination, const void * source, size_t num );
//#if DBVT_USE_MEMMOVE #if DBVT_USE_MEMMOVE
// memmove(&stack[j],&stack[j-1],sizeof(int)*(stack.size()-j-1)); {
//#else int num_items_to_move = stack.size()-1-j;
for(int k=stack.size()-1;k>j;--k) if(num_items_to_move > 0)
{ memmove(&stack[j+1],&stack[j],sizeof(int)*num_items_to_move);
}
#else
for(int k=stack.size()-1;k>j;--k) {
stack[k]=stack[k-1]; stack[k]=stack[k-1];
} }
//#endif #endif
stack[j]=allocate(ifree,stock,nes[q]); stack[j]=allocate(ifree,stock,nes[q]);
/* Insert 1 */ /* Insert 1 */
j=nearest(&stack[0],&stock[0],nes[1-q].value,j,stack.size()); j=nearest(&stack[0],&stock[0],nes[1-q].value,j,stack.size());
stack.push_back(0); stack.push_back(0);
//#if DBVT_USE_MEMMOVE #if DBVT_USE_MEMMOVE
// memmove(&stack[j],&stack[j-1],sizeof(int)*(stack.size()-j-1)); {
//#else int num_items_to_move = stack.size()-1-j;
for(int k=stack.size()-1;k>j;--k) stack[k]=stack[k-1]; if(num_items_to_move > 0)
//#endif memmove(&stack[j+1],&stack[j],sizeof(int)*num_items_to_move);
}
#else
for(int k=stack.size()-1;k>j;--k) {
stack[k]=stack[k-1];
}
#endif
stack[j]=allocate(ifree,stock,nes[1-q]); stack[j]=allocate(ifree,stock,nes[1-q]);
} }
else else

View File

@@ -196,10 +196,6 @@ public:
m_pointCache[insertIndex].m_appliedImpulseLateral1 = appliedLateralImpulse1; m_pointCache[insertIndex].m_appliedImpulseLateral1 = appliedLateralImpulse1;
m_pointCache[insertIndex].m_appliedImpulseLateral2 = appliedLateralImpulse2; m_pointCache[insertIndex].m_appliedImpulseLateral2 = appliedLateralImpulse2;
m_pointCache[insertIndex].m_appliedImpulse = appliedImpulse;
m_pointCache[insertIndex].m_appliedImpulseLateral1 = appliedLateralImpulse1;
m_pointCache[insertIndex].m_appliedImpulseLateral2 = appliedLateralImpulse2;
m_pointCache[insertIndex].m_lifeTime = lifeTime; m_pointCache[insertIndex].m_lifeTime = lifeTime;
#else #else

View File

@@ -294,7 +294,10 @@ bool btVoronoiSimplexSolver::inSimplex(const btVector3& w)
#else #else
if (m_simplexVectorW[i] == w) if (m_simplexVectorW[i] == w)
#endif #endif
{
found = true; found = true;
break;
}
} }
//check in case lastW is already removed //check in case lastW is already removed

View File

@@ -170,6 +170,11 @@ public:
{ {
m_angularOnly = angularOnly; m_angularOnly = angularOnly;
} }
bool getAngularOnly() const
{
return m_angularOnly;
}
void setLimit(int limitIndex,btScalar limitValue) void setLimit(int limitIndex,btScalar limitValue)
{ {
@@ -196,6 +201,33 @@ public:
}; };
} }
btScalar getLimit(int limitIndex) const
{
switch (limitIndex)
{
case 3:
{
return m_twistSpan;
break;
}
case 4:
{
return m_swingSpan2;
break;
}
case 5:
{
return m_swingSpan1;
break;
}
default:
{
btAssert(0 && "Invalid limitIndex specified for btConeTwistConstraint");
return 0.0;
}
};
}
// setLimit(), a few notes: // setLimit(), a few notes:
// _softness: // _softness:
// 0->1, recommend ~0.8->1. // 0->1, recommend ~0.8->1.
@@ -218,8 +250,8 @@ public:
m_relaxationFactor = _relaxationFactor; m_relaxationFactor = _relaxationFactor;
} }
const btTransform& getAFrame() { return m_rbAFrame; }; const btTransform& getAFrame() const { return m_rbAFrame; };
const btTransform& getBFrame() { return m_rbBFrame; }; const btTransform& getBFrame() const { return m_rbBFrame; };
inline int getSolveTwistLimit() inline int getSolveTwistLimit()
{ {
@@ -239,27 +271,43 @@ public:
void calcAngleInfo(); void calcAngleInfo();
void calcAngleInfo2(const btTransform& transA, const btTransform& transB,const btMatrix3x3& invInertiaWorldA,const btMatrix3x3& invInertiaWorldB); void calcAngleInfo2(const btTransform& transA, const btTransform& transB,const btMatrix3x3& invInertiaWorldA,const btMatrix3x3& invInertiaWorldB);
inline btScalar getSwingSpan1() inline btScalar getSwingSpan1() const
{ {
return m_swingSpan1; return m_swingSpan1;
} }
inline btScalar getSwingSpan2() inline btScalar getSwingSpan2() const
{ {
return m_swingSpan2; return m_swingSpan2;
} }
inline btScalar getTwistSpan() inline btScalar getTwistSpan() const
{ {
return m_twistSpan; return m_twistSpan;
} }
inline btScalar getTwistAngle() inline btScalar getLimitSoftness() const
{
return m_limitSoftness;
}
inline btScalar getBiasFactor() const
{
return m_biasFactor;
}
inline btScalar getRelaxationFactor() const
{
return m_relaxationFactor;
}
inline btScalar getTwistAngle() const
{ {
return m_twistAngle; return m_twistAngle;
} }
bool isPastSwingLimit() { return m_solveSwingLimit; } bool isPastSwingLimit() { return m_solveSwingLimit; }
btScalar getDamping() const { return m_damping; }
void setDamping(btScalar damping) { m_damping = damping; } void setDamping(btScalar damping) { m_damping = damping; }
void enableMotor(bool b) { m_bMotorEnabled = b; } void enableMotor(bool b) { m_bMotorEnabled = b; }
bool isMotorEnabled() const { return m_bMotorEnabled; }
btScalar getMaxMotorImpulse() const { return m_maxMotorImpulse; }
bool isMaxMotorImpulseNormalized() const { return m_bNormalizedMotorStrength; }
void setMaxMotorImpulse(btScalar maxMotorImpulse) { m_maxMotorImpulse = maxMotorImpulse; m_bNormalizedMotorStrength = false; } void setMaxMotorImpulse(btScalar maxMotorImpulse) { m_maxMotorImpulse = maxMotorImpulse; m_bNormalizedMotorStrength = false; }
void setMaxMotorImpulseNormalized(btScalar maxMotorImpulse) { m_maxMotorImpulse = maxMotorImpulse; m_bNormalizedMotorStrength = true; } void setMaxMotorImpulseNormalized(btScalar maxMotorImpulse) { m_maxMotorImpulse = maxMotorImpulse; m_bNormalizedMotorStrength = true; }
@@ -271,6 +319,7 @@ public:
// note: if q violates the joint limits, the internal target is clamped to avoid conflicting impulses (very bad for stability) // note: if q violates the joint limits, the internal target is clamped to avoid conflicting impulses (very bad for stability)
// note: don't forget to enableMotor() // note: don't forget to enableMotor()
void setMotorTarget(const btQuaternion &q); void setMotorTarget(const btQuaternion &q);
const btQuaternion& getMotorTarget() const { return m_qTarget; }
// same as above, but q is the desired rotation of frameA wrt frameB in constraint space // same as above, but q is the desired rotation of frameA wrt frameB in constraint space
void setMotorTargetInConstraintSpace(const btQuaternion &q); void setMotorTargetInConstraintSpace(const btQuaternion &q);
@@ -297,6 +346,11 @@ public:
///return the local value of parameter ///return the local value of parameter
virtual btScalar getParam(int num, int axis = -1) const; virtual btScalar getParam(int num, int axis = -1) const;
int getFlags() const
{
return m_flags;
}
virtual int calculateSerializeBufferSize() const; virtual int calculateSerializeBufferSize() const;
///fills the dataBuffer and returns the struct name (and 0 on failure) ///fills the dataBuffer and returns the struct name (and 0 on failure)

View File

@@ -111,14 +111,14 @@ public:
//! Is limited //! Is limited
bool isLimited() bool isLimited() const
{ {
if(m_loLimit > m_hiLimit) return false; if(m_loLimit > m_hiLimit) return false;
return true; return true;
} }
//! Need apply correction //! Need apply correction
bool needApplyTorques() bool needApplyTorques() const
{ {
if(m_currentLimit == 0 && m_enableMotor == false) return false; if(m_currentLimit == 0 && m_enableMotor == false) return false;
return true; return true;
@@ -207,11 +207,11 @@ public:
- limited means upper > lower - limited means upper > lower
- limitIndex: first 3 are linear, next 3 are angular - limitIndex: first 3 are linear, next 3 are angular
*/ */
inline bool isLimited(int limitIndex) inline bool isLimited(int limitIndex) const
{ {
return (m_upperLimit[limitIndex] >= m_lowerLimit[limitIndex]); return (m_upperLimit[limitIndex] >= m_lowerLimit[limitIndex]);
} }
inline bool needApplyForce(int limitIndex) inline bool needApplyForce(int limitIndex) const
{ {
if(m_currentLimit[limitIndex] == 0 && m_enableMotor[limitIndex] == false) return false; if(m_currentLimit[limitIndex] == 0 && m_enableMotor[limitIndex] == false) return false;
return true; return true;
@@ -457,7 +457,7 @@ public:
m_linearLimits.m_lowerLimit = linearLower; m_linearLimits.m_lowerLimit = linearLower;
} }
void getLinearLowerLimit(btVector3& linearLower) void getLinearLowerLimit(btVector3& linearLower) const
{ {
linearLower = m_linearLimits.m_lowerLimit; linearLower = m_linearLimits.m_lowerLimit;
} }
@@ -467,7 +467,7 @@ public:
m_linearLimits.m_upperLimit = linearUpper; m_linearLimits.m_upperLimit = linearUpper;
} }
void getLinearUpperLimit(btVector3& linearUpper) void getLinearUpperLimit(btVector3& linearUpper) const
{ {
linearUpper = m_linearLimits.m_upperLimit; linearUpper = m_linearLimits.m_upperLimit;
} }
@@ -478,7 +478,7 @@ public:
m_angularLimits[i].m_loLimit = btNormalizeAngle(angularLower[i]); m_angularLimits[i].m_loLimit = btNormalizeAngle(angularLower[i]);
} }
void getAngularLowerLimit(btVector3& angularLower) void getAngularLowerLimit(btVector3& angularLower) const
{ {
for(int i = 0; i < 3; i++) for(int i = 0; i < 3; i++)
angularLower[i] = m_angularLimits[i].m_loLimit; angularLower[i] = m_angularLimits[i].m_loLimit;
@@ -490,7 +490,7 @@ public:
m_angularLimits[i].m_hiLimit = btNormalizeAngle(angularUpper[i]); m_angularLimits[i].m_hiLimit = btNormalizeAngle(angularUpper[i]);
} }
void getAngularUpperLimit(btVector3& angularUpper) void getAngularUpperLimit(btVector3& angularUpper) const
{ {
for(int i = 0; i < 3; i++) for(int i = 0; i < 3; i++)
angularUpper[i] = m_angularLimits[i].m_hiLimit; angularUpper[i] = m_angularLimits[i].m_hiLimit;
@@ -532,7 +532,7 @@ public:
- limited means upper > lower - limited means upper > lower
- limitIndex: first 3 are linear, next 3 are angular - limitIndex: first 3 are linear, next 3 are angular
*/ */
bool isLimited(int limitIndex) bool isLimited(int limitIndex) const
{ {
if(limitIndex<3) if(limitIndex<3)
{ {
@@ -549,8 +549,11 @@ public:
btConstraintInfo2 *info, int row, btVector3& ax1, int rotational, int rotAllowed = false); btConstraintInfo2 *info, int row, btVector3& ax1, int rotational, int rotAllowed = false);
// access for UseFrameOffset // access for UseFrameOffset
bool getUseFrameOffset() { return m_useOffsetForConstraintFrame; } bool getUseFrameOffset() const { return m_useOffsetForConstraintFrame; }
void setUseFrameOffset(bool frameOffsetOnOff) { m_useOffsetForConstraintFrame = frameOffsetOnOff; } void setUseFrameOffset(bool frameOffsetOnOff) { m_useOffsetForConstraintFrame = frameOffsetOnOff; }
bool getUseLinearReferenceFrameA() const { return m_useLinearReferenceFrameA; }
void setUseLinearReferenceFrameA(bool linearReferenceFrameA) { m_useLinearReferenceFrameA = linearReferenceFrameA; }
///override the default global value of a parameter (such as ERP or CFM), optionally provide the axis (0..5). ///override the default global value of a parameter (such as ERP or CFM), optionally provide the axis (0..5).
///If no axis is provided, it uses the default axis for this constraint. ///If no axis is provided, it uses the default axis for this constraint.
@@ -560,6 +563,10 @@ public:
void setAxis( const btVector3& axis1, const btVector3& axis2); void setAxis( const btVector3& axis1, const btVector3& axis2);
virtual int getFlags() const
{
return m_flags;
}
virtual int calculateSerializeBufferSize() const; virtual int calculateSerializeBufferSize() const;

View File

@@ -63,6 +63,26 @@ public:
void setEquilibriumPoint(int index); // set the current constraint position/orientation as an equilibrium point for given DOF void setEquilibriumPoint(int index); // set the current constraint position/orientation as an equilibrium point for given DOF
void setEquilibriumPoint(int index, btScalar val); void setEquilibriumPoint(int index, btScalar val);
bool isSpringEnabled(int index) const
{
return m_springEnabled[index];
}
btScalar getStiffness(int index) const
{
return m_springStiffness[index];
}
btScalar getDamping(int index) const
{
return m_springDamping[index];
}
btScalar getEquilibriumPoint(int index) const
{
return m_equilibriumPoint[index];
}
virtual void setAxis( const btVector3& axis1, const btVector3& axis2); virtual void setAxis( const btVector3& axis1, const btVector3& axis2);
virtual void getInfo2 (btConstraintInfo2* info); virtual void getInfo2 (btConstraintInfo2* info);

View File

@@ -177,6 +177,7 @@ public:
// maintain a given angular target. // maintain a given angular target.
void enableMotor(bool enableMotor) { m_enableAngularMotor = enableMotor; } void enableMotor(bool enableMotor) { m_enableAngularMotor = enableMotor; }
void setMaxMotorImpulse(btScalar maxMotorImpulse) { m_maxMotorImpulse = maxMotorImpulse; } void setMaxMotorImpulse(btScalar maxMotorImpulse) { m_maxMotorImpulse = maxMotorImpulse; }
void setMotorTargetVelocity(btScalar motorTargetVelocity) { m_motorTargetVelocity = motorTargetVelocity; }
void setMotorTarget(const btQuaternion& qAinB, btScalar dt); // qAinB is rotation of body A wrt body B. void setMotorTarget(const btQuaternion& qAinB, btScalar dt); // qAinB is rotation of body A wrt body B.
void setMotorTarget(btScalar targetAngle, btScalar dt); void setMotorTarget(btScalar targetAngle, btScalar dt);
@@ -193,6 +194,33 @@ public:
m_relaxationFactor = _relaxationFactor; m_relaxationFactor = _relaxationFactor;
#endif #endif
} }
btScalar getLimitSoftness() const
{
#ifdef _BT_USE_CENTER_LIMIT_
return m_limit.getSoftness();
#else
return m_limitSoftness;
#endif
}
btScalar getLimitBiasFactor() const
{
#ifdef _BT_USE_CENTER_LIMIT_
return m_limit.getBiasFactor();
#else
return m_biasFactor;
#endif
}
btScalar getLimitRelaxationFactor() const
{
#ifdef _BT_USE_CENTER_LIMIT_
return m_limit.getRelaxationFactor();
#else
return m_relaxationFactor;
#endif
}
void setAxis(btVector3& axisInA) void setAxis(btVector3& axisInA)
{ {
@@ -297,13 +325,20 @@ public:
// access for UseFrameOffset // access for UseFrameOffset
bool getUseFrameOffset() { return m_useOffsetForConstraintFrame; } bool getUseFrameOffset() { return m_useOffsetForConstraintFrame; }
void setUseFrameOffset(bool frameOffsetOnOff) { m_useOffsetForConstraintFrame = frameOffsetOnOff; } void setUseFrameOffset(bool frameOffsetOnOff) { m_useOffsetForConstraintFrame = frameOffsetOnOff; }
// access for UseReferenceFrameA
bool getUseReferenceFrameA() const { return m_useReferenceFrameA; }
void setUseReferenceFrameA(bool useReferenceFrameA) { m_useReferenceFrameA = useReferenceFrameA; }
///override the default global value of a parameter (such as ERP or CFM), optionally provide the axis (0..5). ///override the default global value of a parameter (such as ERP or CFM), optionally provide the axis (0..5).
///If no axis is provided, it uses the default axis for this constraint. ///If no axis is provided, it uses the default axis for this constraint.
virtual void setParam(int num, btScalar value, int axis = -1); virtual void setParam(int num, btScalar value, int axis = -1);
///return the local value of parameter ///return the local value of parameter
virtual btScalar getParam(int num, int axis = -1) const; virtual btScalar getParam(int num, int axis = -1) const;
virtual int getFlags() const
{
return m_flags;
}
virtual int calculateSerializeBufferSize() const; virtual int calculateSerializeBufferSize() const;

View File

@@ -116,6 +116,11 @@ public:
virtual void setParam(int num, btScalar value, int axis = -1); virtual void setParam(int num, btScalar value, int axis = -1);
///return the local value of parameter ///return the local value of parameter
virtual btScalar getParam(int num, int axis = -1) const; virtual btScalar getParam(int num, int axis = -1) const;
virtual int getFlags() const
{
return m_flags;
}
virtual int calculateSerializeBufferSize() const; virtual int calculateSerializeBufferSize() const;

View File

@@ -280,6 +280,11 @@ public:
virtual void setParam(int num, btScalar value, int axis = -1); virtual void setParam(int num, btScalar value, int axis = -1);
///return the local value of parameter ///return the local value of parameter
virtual btScalar getParam(int num, int axis = -1) const; virtual btScalar getParam(int num, int axis = -1) const;
virtual int getFlags() const
{
return m_flags;
}
virtual int calculateSerializeBufferSize() const; virtual int calculateSerializeBufferSize() const;

View File

@@ -92,7 +92,8 @@ btMultiBody::btMultiBody(int n_links,
btScalar mass, btScalar mass,
const btVector3 &inertia, const btVector3 &inertia,
bool fixedBase, bool fixedBase,
bool canSleep) bool canSleep,
bool /*deprecatedUseMultiDof*/)
: :
m_baseCollider(0), m_baseCollider(0),
m_baseName(0), m_baseName(0),
@@ -137,7 +138,7 @@ void btMultiBody::setupFixed(int i,
int parent, int parent,
const btQuaternion &rotParentToThis, const btQuaternion &rotParentToThis,
const btVector3 &parentComToThisPivotOffset, const btVector3 &parentComToThisPivotOffset,
const btVector3 &thisPivotToThisComOffset) const btVector3 &thisPivotToThisComOffset, bool /*deprecatedDisableParentCollision*/)
{ {
m_links[i].m_mass = mass; m_links[i].m_mass = mass;

View File

@@ -63,7 +63,7 @@ public:
btScalar mass, // mass of base btScalar mass, // mass of base
const btVector3 &inertia, // inertia of base, in base frame; assumed diagonal const btVector3 &inertia, // inertia of base, in base frame; assumed diagonal
bool fixedBase, // whether the base is fixed (true) or can move (false) bool fixedBase, // whether the base is fixed (true) or can move (false)
bool canSleep); bool canSleep, bool deprecatedMultiDof=true);
virtual ~btMultiBody(); virtual ~btMultiBody();
@@ -75,7 +75,7 @@ public:
int parent, int parent,
const btQuaternion &rotParentToThis, const btQuaternion &rotParentToThis,
const btVector3 &parentComToThisPivotOffset, const btVector3 &parentComToThisPivotOffset,
const btVector3 &thisPivotToThisComOffset); const btVector3 &thisPivotToThisComOffset, bool deprecatedDisableParentCollision=true);
void setupPrismatic(int i, void setupPrismatic(int i,
@@ -337,7 +337,8 @@ void addJointTorque(int i, btScalar Q);
// improvement, at least on Windows (where dynamic memory // improvement, at least on Windows (where dynamic memory
// allocation appears to be fairly slow). // allocation appears to be fairly slow).
// //
void computeAccelerationsArticulatedBodyAlgorithmMultiDof(btScalar dt, void computeAccelerationsArticulatedBodyAlgorithmMultiDof(btScalar dt,
btAlignedObjectArray<btScalar> &scratch_r, btAlignedObjectArray<btScalar> &scratch_r,
btAlignedObjectArray<btVector3> &scratch_v, btAlignedObjectArray<btVector3> &scratch_v,
@@ -345,17 +346,26 @@ void addJointTorque(int i, btScalar Q);
bool isConstraintPass=false bool isConstraintPass=false
); );
///stepVelocitiesMultiDof is deprecated, use computeAccelerationsArticulatedBodyAlgorithmMultiDof instead
void stepVelocitiesMultiDof(btScalar dt,
btAlignedObjectArray<btScalar> &scratch_r,
btAlignedObjectArray<btVector3> &scratch_v,
btAlignedObjectArray<btMatrix3x3> &scratch_m,
bool isConstraintPass=false)
{
computeAccelerationsArticulatedBodyAlgorithmMultiDof(dt,scratch_r,scratch_v,scratch_m,isConstraintPass);
}
// calcAccelerationDeltasMultiDof // calcAccelerationDeltasMultiDof
// input: force vector (in same format as jacobian, i.e.: // input: force vector (in same format as jacobian, i.e.:
// 3 torque values, 3 force values, num_links joint torque values) // 3 torque values, 3 force values, num_links joint torque values)
// output: 3 omegadot values, 3 vdot values, num_links q_double_dot values // output: 3 omegadot values, 3 vdot values, num_links q_double_dot values
// (existing contents of output array are replaced) // (existing contents of output array are replaced)
// stepVelocities must have been called first. // calcAccelerationDeltasMultiDof must have been called first.
void calcAccelerationDeltasMultiDof(const btScalar *force, btScalar *output, void calcAccelerationDeltasMultiDof(const btScalar *force, btScalar *output,
btAlignedObjectArray<btScalar> &scratch_r, btAlignedObjectArray<btScalar> &scratch_r,
btAlignedObjectArray<btVector3> &scratch_v) const; btAlignedObjectArray<btVector3> &scratch_v) const;
void applyDeltaVeeMultiDof2(const btScalar * delta_vee, btScalar multiplier) void applyDeltaVeeMultiDof2(const btScalar * delta_vee, btScalar multiplier)
{ {

View File

@@ -39,6 +39,12 @@ subject to the following restrictions:
#include <new> //for placement new #include <new> //for placement new
#endif //BT_USE_PLACEMENT_NEW #endif //BT_USE_PLACEMENT_NEW
// The register keyword is deprecated in C++11 so don't use it.
#if __cplusplus > 199711L
#define BT_REGISTER
#else
#define BT_REGISTER register
#endif
///The btAlignedObjectArray template class uses a subset of the stl::vector interface for its methods ///The btAlignedObjectArray template class uses a subset of the stl::vector interface for its methods
///It is developed to replace stl::vector to avoid portability issues, including STL alignment issues to add SIMD/SSE data ///It is developed to replace stl::vector to avoid portability issues, including STL alignment issues to add SIMD/SSE data
@@ -211,7 +217,7 @@ protected:
SIMD_FORCE_INLINE void resize(int newsize, const T& fillData=T()) SIMD_FORCE_INLINE void resize(int newsize, const T& fillData=T())
{ {
const register int curSize = size(); const BT_REGISTER int curSize = size();
if (newsize < curSize) if (newsize < curSize)
{ {
@@ -238,7 +244,7 @@ protected:
} }
SIMD_FORCE_INLINE T& expandNonInitializing( ) SIMD_FORCE_INLINE T& expandNonInitializing( )
{ {
const register int sz = size(); const BT_REGISTER int sz = size();
if( sz == capacity() ) if( sz == capacity() )
{ {
reserve( allocSize(size()) ); reserve( allocSize(size()) );
@@ -251,7 +257,7 @@ protected:
SIMD_FORCE_INLINE T& expand( const T& fillValue=T()) SIMD_FORCE_INLINE T& expand( const T& fillValue=T())
{ {
const register int sz = size(); const BT_REGISTER int sz = size();
if( sz == capacity() ) if( sz == capacity() )
{ {
reserve( allocSize(size()) ); reserve( allocSize(size()) );
@@ -267,7 +273,7 @@ protected:
SIMD_FORCE_INLINE void push_back(const T& _Val) SIMD_FORCE_INLINE void push_back(const T& _Val)
{ {
const register int sz = size(); const BT_REGISTER int sz = size();
if( sz == capacity() ) if( sz == capacity() )
{ {
reserve( allocSize(size()) ); reserve( allocSize(size()) );

View File

@@ -127,7 +127,7 @@ public:
/**@brief Set from an array /**@brief Set from an array
* @param m A pointer to a 15 element array (12 rotation(row major padded on the right by 1), and 3 translation */ * @param m A pointer to a 16 element array (12 rotation(row major padded on the right by 1), and 3 translation */
void setFromOpenGLMatrix(const btScalar *m) void setFromOpenGLMatrix(const btScalar *m)
{ {
m_basis.setFromOpenGLSubMatrix(m); m_basis.setFromOpenGLSubMatrix(m);
@@ -135,7 +135,7 @@ public:
} }
/**@brief Fill an array representation /**@brief Fill an array representation
* @param m A pointer to a 15 element array (12 rotation(row major padded on the right by 1), and 3 translation */ * @param m A pointer to a 16 element array (12 rotation(row major padded on the right by 1), and 3 translation */
void getOpenGLMatrix(btScalar *m) const void getOpenGLMatrix(btScalar *m) const
{ {
m_basis.getOpenGLSubMatrix(m); m_basis.getOpenGLSubMatrix(m);