2 Bullet Continuous Collision Detection and Physics Library
3 Copyright (c) 2003-2006 Erwin Coumans https://bulletphysics.org
5 This software is provided 'as-is', without any express or implied warranty.
6 In no event will the authors be held liable for any damages arising from the use of this software.
7 Permission is granted to anyone to use this software for any purpose,
8 including commercial applications, and to alter it and redistribute it freely,
9 subject to the following restrictions:
11 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.
12 2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software.
13 3. This notice may not be removed or altered from any source distribution.
16 #ifndef B3_POINT2POINTCONSTRAINT_H
17 #define B3_POINT2POINTCONSTRAINT_H
19 #include "Bullet3Common/b3Vector3.h"
20 //#include "b3JacobianEntry.h"
21 #include "b3TypedConstraint.h"
25 #ifdef B3_USE_DOUBLE_PRECISION
26 #define b3Point2PointConstraintData b3Point2PointConstraintDoubleData
27 #define b3Point2PointConstraintDataName "b3Point2PointConstraintDoubleData"
29 #define b3Point2PointConstraintData b3Point2PointConstraintFloatData
30 #define b3Point2PointConstraintDataName "b3Point2PointConstraintFloatData"
31 #endif //B3_USE_DOUBLE_PRECISION
33 struct b3ConstraintSetting
35 b3ConstraintSetting() : m_tau(b3Scalar(0.3)),
36 m_damping(b3Scalar(1.)),
37 m_impulseClamp(b3Scalar(0.))
42 b3Scalar m_impulseClamp;
45 enum b3Point2PointFlags
51 /// point to point constraint between two rigidbodies each with a pivotpoint that descibes the 'ballsocket' location in local space
52 B3_ATTRIBUTE_ALIGNED16(class)
53 b3Point2PointConstraint : public b3TypedConstraint
55 #ifdef IN_PARALLELL_SOLVER
67 B3_DECLARE_ALIGNED_ALLOCATOR();
69 b3ConstraintSetting m_setting;
71 b3Point2PointConstraint(int rbA, int rbB, const b3Vector3& pivotInA, const b3Vector3& pivotInB);
73 //b3Point2PointConstraint(int rbA,const b3Vector3& pivotInA);
75 virtual void getInfo1(b3ConstraintInfo1 * info, const b3RigidBodyData* bodies);
77 void getInfo1NonVirtual(b3ConstraintInfo1 * info, const b3RigidBodyData* bodies);
79 virtual void getInfo2(b3ConstraintInfo2 * info, const b3RigidBodyData* bodies);
81 void getInfo2NonVirtual(b3ConstraintInfo2 * info, const b3Transform& body0_trans, const b3Transform& body1_trans);
83 void updateRHS(b3Scalar timeStep);
85 void setPivotA(const b3Vector3& pivotA)
90 void setPivotB(const b3Vector3& pivotB)
95 const b3Vector3& getPivotInA() const
100 const b3Vector3& getPivotInB() const
105 ///override the default global value of a parameter (such as ERP or CFM), optionally provide the axis (0..5).
106 ///If no axis is provided, it uses the default axis for this constraint.
107 virtual void setParam(int num, b3Scalar value, int axis = -1);
108 ///return the local value of parameter
109 virtual b3Scalar getParam(int num, int axis = -1) const;
111 // virtual int calculateSerializeBufferSize() const;
113 ///fills the dataBuffer and returns the struct name (and 0 on failure)
114 // virtual const char* serialize(void* dataBuffer, b3Serializer* serializer) const;
117 ///do not change those serialization structures, it requires an updated sBulletDNAstr/sBulletDNAstr64
118 struct b3Point2PointConstraintFloatData
120 b3TypedConstraintData m_typeConstraintData;
121 b3Vector3FloatData m_pivotInA;
122 b3Vector3FloatData m_pivotInB;
125 ///do not change those serialization structures, it requires an updated sBulletDNAstr/sBulletDNAstr64
126 struct b3Point2PointConstraintDoubleData
128 b3TypedConstraintData m_typeConstraintData;
129 b3Vector3DoubleData m_pivotInA;
130 b3Vector3DoubleData m_pivotInB;
134 B3_FORCE_INLINE int b3Point2PointConstraint::calculateSerializeBufferSize() const
136 return sizeof(b3Point2PointConstraintData);
140 ///fills the dataBuffer and returns the struct name (and 0 on failure)
141 B3_FORCE_INLINE const char* b3Point2PointConstraint::serialize(void* dataBuffer, b3Serializer* serializer) const
143 b3Point2PointConstraintData* p2pData = (b3Point2PointConstraintData*)dataBuffer;
145 b3TypedConstraint::serialize(&p2pData->m_typeConstraintData,serializer);
146 m_pivotInA.serialize(p2pData->m_pivotInA);
147 m_pivotInB.serialize(p2pData->m_pivotInB);
149 return b3Point2PointConstraintDataName;
153 #endif //B3_POINT2POINTCONSTRAINT_H