Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: code/branches/turret/src/external/bullet/BulletDynamics/ConstraintSolver/btPoint2PointConstraint.h @ 10077

Last change on this file since 10077 was 8393, checked in by rgrieder, 14 years ago

Updated Bullet from v2.77 to v2.78.
(I'm not going to make a branch for that since the update from 2.74 to 2.77 hasn't been tested that much either).

You will HAVE to do a complete RECOMPILE! I tested with MSVC and MinGW and they both threw linker errors at me.

  • Property svn:eol-style set to native
File size: 4.8 KB
Line 
1/*
2Bullet Continuous Collision Detection and Physics Library
3Copyright (c) 2003-2006 Erwin Coumans  http://continuousphysics.com/Bullet/
4
5This software is provided 'as-is', without any express or implied warranty.
6In no event will the authors be held liable for any damages arising from the use of this software.
7Permission is granted to anyone to use this software for any purpose,
8including commercial applications, and to alter it and redistribute it freely,
9subject to the following restrictions:
10
111. 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.
122. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software.
133. This notice may not be removed or altered from any source distribution.
14*/
15
16#ifndef BT_POINT2POINTCONSTRAINT_H
17#define BT_POINT2POINTCONSTRAINT_H
18
19#include "LinearMath/btVector3.h"
20#include "btJacobianEntry.h"
21#include "btTypedConstraint.h"
22
23class btRigidBody;
24
25
26#ifdef BT_USE_DOUBLE_PRECISION
27#define btPoint2PointConstraintData     btPoint2PointConstraintDoubleData
28#define btPoint2PointConstraintDataName "btPoint2PointConstraintDoubleData"
29#else
30#define btPoint2PointConstraintData     btPoint2PointConstraintFloatData
31#define btPoint2PointConstraintDataName "btPoint2PointConstraintFloatData"
32#endif //BT_USE_DOUBLE_PRECISION
33
34struct  btConstraintSetting
35{
36        btConstraintSetting()   :
37                m_tau(btScalar(0.3)),
38                m_damping(btScalar(1.)),
39                m_impulseClamp(btScalar(0.))
40        {
41        }
42        btScalar                m_tau;
43        btScalar                m_damping;
44        btScalar                m_impulseClamp;
45};
46
47enum btPoint2PointFlags
48{
49        BT_P2P_FLAGS_ERP = 1,
50        BT_P2P_FLAGS_CFM = 2
51};
52
53/// point to point constraint between two rigidbodies each with a pivotpoint that descibes the 'ballsocket' location in local space
54ATTRIBUTE_ALIGNED16(class) btPoint2PointConstraint : public btTypedConstraint
55{
56#ifdef IN_PARALLELL_SOLVER
57public:
58#endif
59        btJacobianEntry m_jac[3]; //3 orthogonal linear constraints
60       
61        btVector3       m_pivotInA;
62        btVector3       m_pivotInB;
63       
64        int                     m_flags;
65        btScalar        m_erp;
66        btScalar        m_cfm;
67       
68public:
69
70        ///for backwards compatibility during the transition to 'getInfo/getInfo2'
71        bool            m_useSolveConstraintObsolete;
72
73        btConstraintSetting     m_setting;
74
75        btPoint2PointConstraint(btRigidBody& rbA,btRigidBody& rbB, const btVector3& pivotInA,const btVector3& pivotInB);
76
77        btPoint2PointConstraint(btRigidBody& rbA,const btVector3& pivotInA);
78
79
80        virtual void    buildJacobian();
81
82        virtual void getInfo1 (btConstraintInfo1* info);
83
84        void getInfo1NonVirtual (btConstraintInfo1* info);
85
86        virtual void getInfo2 (btConstraintInfo2* info);
87
88        void getInfo2NonVirtual (btConstraintInfo2* info, const btTransform& body0_trans, const btTransform& body1_trans);
89
90        void    updateRHS(btScalar      timeStep);
91
92        void    setPivotA(const btVector3& pivotA)
93        {
94                m_pivotInA = pivotA;
95        }
96
97        void    setPivotB(const btVector3& pivotB)
98        {
99                m_pivotInB = pivotB;
100        }
101
102        const btVector3& getPivotInA() const
103        {
104                return m_pivotInA;
105        }
106
107        const btVector3& getPivotInB() const
108        {
109                return m_pivotInB;
110        }
111
112        ///override the default global value of a parameter (such as ERP or CFM), optionally provide the axis (0..5).
113        ///If no axis is provided, it uses the default axis for this constraint.
114        virtual void    setParam(int num, btScalar value, int axis = -1);
115        ///return the local value of parameter
116        virtual btScalar getParam(int num, int axis = -1) const;
117
118        virtual int     calculateSerializeBufferSize() const;
119
120        ///fills the dataBuffer and returns the struct name (and 0 on failure)
121        virtual const char*     serialize(void* dataBuffer, btSerializer* serializer) const;
122
123
124};
125
126///do not change those serialization structures, it requires an updated sBulletDNAstr/sBulletDNAstr64
127struct  btPoint2PointConstraintFloatData
128{
129        btTypedConstraintData   m_typeConstraintData;
130        btVector3FloatData      m_pivotInA;
131        btVector3FloatData      m_pivotInB;
132};
133
134///do not change those serialization structures, it requires an updated sBulletDNAstr/sBulletDNAstr64
135struct  btPoint2PointConstraintDoubleData
136{
137        btTypedConstraintData   m_typeConstraintData;
138        btVector3DoubleData     m_pivotInA;
139        btVector3DoubleData     m_pivotInB;
140};
141
142
143SIMD_FORCE_INLINE       int     btPoint2PointConstraint::calculateSerializeBufferSize() const
144{
145        return sizeof(btPoint2PointConstraintData);
146
147}
148
149        ///fills the dataBuffer and returns the struct name (and 0 on failure)
150SIMD_FORCE_INLINE       const char*     btPoint2PointConstraint::serialize(void* dataBuffer, btSerializer* serializer) const
151{
152        btPoint2PointConstraintData* p2pData = (btPoint2PointConstraintData*)dataBuffer;
153
154        btTypedConstraint::serialize(&p2pData->m_typeConstraintData,serializer);
155        m_pivotInA.serialize(p2pData->m_pivotInA);
156        m_pivotInB.serialize(p2pData->m_pivotInB);
157
158        return btPoint2PointConstraintDataName;
159}
160
161#endif //BT_POINT2POINTCONSTRAINT_H
Note: See TracBrowser for help on using the repository browser.