2017-08-01 12:30:58 +00:00
|
|
|
/*
|
|
|
|
Bullet Continuous Collision Detection and Physics Library
|
2022-01-06 22:37:49 +00:00
|
|
|
Copyright (c) 2003-2006 Erwin Coumans https://bulletphysics.org
|
2017-08-01 12:30:58 +00:00
|
|
|
|
|
|
|
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,
|
|
|
|
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.
|
|
|
|
2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software.
|
|
|
|
3. This notice may not be removed or altered from any source distribution.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef B3_POINT2POINTCONSTRAINT_H
|
|
|
|
#define B3_POINT2POINTCONSTRAINT_H
|
|
|
|
|
|
|
|
#include "Bullet3Common/b3Vector3.h"
|
|
|
|
//#include "b3JacobianEntry.h"
|
|
|
|
#include "b3TypedConstraint.h"
|
|
|
|
|
|
|
|
class b3RigidBody;
|
|
|
|
|
|
|
|
#ifdef B3_USE_DOUBLE_PRECISION
|
2019-01-03 13:26:51 +00:00
|
|
|
#define b3Point2PointConstraintData b3Point2PointConstraintDoubleData
|
|
|
|
#define b3Point2PointConstraintDataName "b3Point2PointConstraintDoubleData"
|
2017-08-01 12:30:58 +00:00
|
|
|
#else
|
2019-01-03 13:26:51 +00:00
|
|
|
#define b3Point2PointConstraintData b3Point2PointConstraintFloatData
|
|
|
|
#define b3Point2PointConstraintDataName "b3Point2PointConstraintFloatData"
|
|
|
|
#endif //B3_USE_DOUBLE_PRECISION
|
2017-08-01 12:30:58 +00:00
|
|
|
|
2019-01-03 13:26:51 +00:00
|
|
|
struct b3ConstraintSetting
|
2017-08-01 12:30:58 +00:00
|
|
|
{
|
2019-01-03 13:26:51 +00:00
|
|
|
b3ConstraintSetting() : m_tau(b3Scalar(0.3)),
|
|
|
|
m_damping(b3Scalar(1.)),
|
|
|
|
m_impulseClamp(b3Scalar(0.))
|
2017-08-01 12:30:58 +00:00
|
|
|
{
|
|
|
|
}
|
2019-01-03 13:26:51 +00:00
|
|
|
b3Scalar m_tau;
|
|
|
|
b3Scalar m_damping;
|
|
|
|
b3Scalar m_impulseClamp;
|
2017-08-01 12:30:58 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
enum b3Point2PointFlags
|
|
|
|
{
|
|
|
|
B3_P2P_FLAGS_ERP = 1,
|
|
|
|
B3_P2P_FLAGS_CFM = 2
|
|
|
|
};
|
|
|
|
|
|
|
|
/// point to point constraint between two rigidbodies each with a pivotpoint that descibes the 'ballsocket' location in local space
|
2019-01-03 13:26:51 +00:00
|
|
|
B3_ATTRIBUTE_ALIGNED16(class)
|
|
|
|
b3Point2PointConstraint : public b3TypedConstraint
|
2017-08-01 12:30:58 +00:00
|
|
|
{
|
|
|
|
#ifdef IN_PARALLELL_SOLVER
|
|
|
|
public:
|
|
|
|
#endif
|
|
|
|
|
2019-01-03 13:26:51 +00:00
|
|
|
b3Vector3 m_pivotInA;
|
|
|
|
b3Vector3 m_pivotInB;
|
2017-08-01 12:30:58 +00:00
|
|
|
|
2019-01-03 13:26:51 +00:00
|
|
|
int m_flags;
|
|
|
|
b3Scalar m_erp;
|
|
|
|
b3Scalar m_cfm;
|
2017-08-01 12:30:58 +00:00
|
|
|
|
2019-01-03 13:26:51 +00:00
|
|
|
public:
|
|
|
|
B3_DECLARE_ALIGNED_ALLOCATOR();
|
2017-08-01 12:30:58 +00:00
|
|
|
|
2019-01-03 13:26:51 +00:00
|
|
|
b3ConstraintSetting m_setting;
|
2017-08-01 12:30:58 +00:00
|
|
|
|
2019-01-03 13:26:51 +00:00
|
|
|
b3Point2PointConstraint(int rbA, int rbB, const b3Vector3& pivotInA, const b3Vector3& pivotInB);
|
2017-08-01 12:30:58 +00:00
|
|
|
|
2019-01-03 13:26:51 +00:00
|
|
|
//b3Point2PointConstraint(int rbA,const b3Vector3& pivotInA);
|
2017-08-01 12:30:58 +00:00
|
|
|
|
2019-01-03 13:26:51 +00:00
|
|
|
virtual void getInfo1(b3ConstraintInfo1 * info, const b3RigidBodyData* bodies);
|
2017-08-01 12:30:58 +00:00
|
|
|
|
2019-01-03 13:26:51 +00:00
|
|
|
void getInfo1NonVirtual(b3ConstraintInfo1 * info, const b3RigidBodyData* bodies);
|
2017-08-01 12:30:58 +00:00
|
|
|
|
2019-01-03 13:26:51 +00:00
|
|
|
virtual void getInfo2(b3ConstraintInfo2 * info, const b3RigidBodyData* bodies);
|
2017-08-01 12:30:58 +00:00
|
|
|
|
2019-01-03 13:26:51 +00:00
|
|
|
void getInfo2NonVirtual(b3ConstraintInfo2 * info, const b3Transform& body0_trans, const b3Transform& body1_trans);
|
2017-08-01 12:30:58 +00:00
|
|
|
|
2019-01-03 13:26:51 +00:00
|
|
|
void updateRHS(b3Scalar timeStep);
|
2017-08-01 12:30:58 +00:00
|
|
|
|
2019-01-03 13:26:51 +00:00
|
|
|
void setPivotA(const b3Vector3& pivotA)
|
2017-08-01 12:30:58 +00:00
|
|
|
{
|
|
|
|
m_pivotInA = pivotA;
|
|
|
|
}
|
|
|
|
|
2019-01-03 13:26:51 +00:00
|
|
|
void setPivotB(const b3Vector3& pivotB)
|
2017-08-01 12:30:58 +00:00
|
|
|
{
|
|
|
|
m_pivotInB = pivotB;
|
|
|
|
}
|
|
|
|
|
|
|
|
const b3Vector3& getPivotInA() const
|
|
|
|
{
|
|
|
|
return m_pivotInA;
|
|
|
|
}
|
|
|
|
|
|
|
|
const b3Vector3& getPivotInB() const
|
|
|
|
{
|
|
|
|
return m_pivotInB;
|
|
|
|
}
|
|
|
|
|
2019-01-03 13:26:51 +00:00
|
|
|
///override the default global value of a parameter (such as ERP or CFM), optionally provide the axis (0..5).
|
2017-08-01 12:30:58 +00:00
|
|
|
///If no axis is provided, it uses the default axis for this constraint.
|
2019-01-03 13:26:51 +00:00
|
|
|
virtual void setParam(int num, b3Scalar value, int axis = -1);
|
2017-08-01 12:30:58 +00:00
|
|
|
///return the local value of parameter
|
2019-01-03 13:26:51 +00:00
|
|
|
virtual b3Scalar getParam(int num, int axis = -1) const;
|
2017-08-01 12:30:58 +00:00
|
|
|
|
2019-01-03 13:26:51 +00:00
|
|
|
// virtual int calculateSerializeBufferSize() const;
|
2017-08-01 12:30:58 +00:00
|
|
|
|
|
|
|
///fills the dataBuffer and returns the struct name (and 0 on failure)
|
2019-01-03 13:26:51 +00:00
|
|
|
// virtual const char* serialize(void* dataBuffer, b3Serializer* serializer) const;
|
2017-08-01 12:30:58 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
///do not change those serialization structures, it requires an updated sBulletDNAstr/sBulletDNAstr64
|
2019-01-03 13:26:51 +00:00
|
|
|
struct b3Point2PointConstraintFloatData
|
2017-08-01 12:30:58 +00:00
|
|
|
{
|
2019-01-03 13:26:51 +00:00
|
|
|
b3TypedConstraintData m_typeConstraintData;
|
|
|
|
b3Vector3FloatData m_pivotInA;
|
|
|
|
b3Vector3FloatData m_pivotInB;
|
2017-08-01 12:30:58 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
///do not change those serialization structures, it requires an updated sBulletDNAstr/sBulletDNAstr64
|
2019-01-03 13:26:51 +00:00
|
|
|
struct b3Point2PointConstraintDoubleData
|
2017-08-01 12:30:58 +00:00
|
|
|
{
|
2019-01-03 13:26:51 +00:00
|
|
|
b3TypedConstraintData m_typeConstraintData;
|
|
|
|
b3Vector3DoubleData m_pivotInA;
|
|
|
|
b3Vector3DoubleData m_pivotInB;
|
2017-08-01 12:30:58 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
/*
|
|
|
|
B3_FORCE_INLINE int b3Point2PointConstraint::calculateSerializeBufferSize() const
|
|
|
|
{
|
|
|
|
return sizeof(b3Point2PointConstraintData);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
///fills the dataBuffer and returns the struct name (and 0 on failure)
|
|
|
|
B3_FORCE_INLINE const char* b3Point2PointConstraint::serialize(void* dataBuffer, b3Serializer* serializer) const
|
|
|
|
{
|
|
|
|
b3Point2PointConstraintData* p2pData = (b3Point2PointConstraintData*)dataBuffer;
|
|
|
|
|
|
|
|
b3TypedConstraint::serialize(&p2pData->m_typeConstraintData,serializer);
|
|
|
|
m_pivotInA.serialize(p2pData->m_pivotInA);
|
|
|
|
m_pivotInB.serialize(p2pData->m_pivotInB);
|
|
|
|
|
|
|
|
return b3Point2PointConstraintDataName;
|
|
|
|
}
|
|
|
|
*/
|
|
|
|
|
2019-01-03 13:26:51 +00:00
|
|
|
#endif //B3_POINT2POINTCONSTRAINT_H
|