Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: code/branches/turret/src/external/bullet/BulletDynamics/ConstraintSolver/btGeneric6DofSpringConstraint.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.0 KB
Line 
1/*
2Bullet Continuous Collision Detection and Physics Library, http://bulletphysics.org
3Copyright (C) 2006, 2007 Sony Computer Entertainment Inc.
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_GENERIC_6DOF_SPRING_CONSTRAINT_H
17#define BT_GENERIC_6DOF_SPRING_CONSTRAINT_H
18
19
20#include "LinearMath/btVector3.h"
21#include "btTypedConstraint.h"
22#include "btGeneric6DofConstraint.h"
23
24
25/// Generic 6 DOF constraint that allows to set spring motors to any translational and rotational DOF
26
27/// DOF index used in enableSpring() and setStiffness() means:
28/// 0 : translation X
29/// 1 : translation Y
30/// 2 : translation Z
31/// 3 : rotation X (3rd Euler rotational around new position of X axis, range [-PI+epsilon, PI-epsilon] )
32/// 4 : rotation Y (2nd Euler rotational around new position of Y axis, range [-PI/2+epsilon, PI/2-epsilon] )
33/// 5 : rotation Z (1st Euler rotational around Z axis, range [-PI+epsilon, PI-epsilon] )
34
35class btGeneric6DofSpringConstraint : public btGeneric6DofConstraint
36{
37protected:
38        bool            m_springEnabled[6];
39        btScalar        m_equilibriumPoint[6];
40        btScalar        m_springStiffness[6];
41        btScalar        m_springDamping[6]; // between 0 and 1 (1 == no damping)
42        void internalUpdateSprings(btConstraintInfo2* info);
43public: 
44    btGeneric6DofSpringConstraint(btRigidBody& rbA, btRigidBody& rbB, const btTransform& frameInA, const btTransform& frameInB ,bool useLinearReferenceFrameA);
45        void enableSpring(int index, bool onOff);
46        void setStiffness(int index, btScalar stiffness);
47        void setDamping(int index, btScalar damping);
48        void setEquilibriumPoint(); // set the current constraint position/orientation as an equilibrium point for all DOF
49        void setEquilibriumPoint(int index);  // set the current constraint position/orientation as an equilibrium point for given DOF
50        void setEquilibriumPoint(int index, btScalar val);
51
52        virtual void setAxis( const btVector3& axis1, const btVector3& axis2);
53
54        virtual void getInfo2 (btConstraintInfo2* info);
55
56        virtual int     calculateSerializeBufferSize() const;
57        ///fills the dataBuffer and returns the struct name (and 0 on failure)
58        virtual const char*     serialize(void* dataBuffer, btSerializer* serializer) const;
59
60};
61
62
63///do not change those serialization structures, it requires an updated sBulletDNAstr/sBulletDNAstr64
64struct btGeneric6DofSpringConstraintData
65{
66        btGeneric6DofConstraintData     m_6dofData;
67       
68        int                     m_springEnabled[6];
69        float           m_equilibriumPoint[6];
70        float           m_springStiffness[6];
71        float           m_springDamping[6];
72};
73
74SIMD_FORCE_INLINE       int     btGeneric6DofSpringConstraint::calculateSerializeBufferSize() const
75{
76        return sizeof(btGeneric6DofSpringConstraintData);
77}
78
79        ///fills the dataBuffer and returns the struct name (and 0 on failure)
80SIMD_FORCE_INLINE       const char*     btGeneric6DofSpringConstraint::serialize(void* dataBuffer, btSerializer* serializer) const
81{
82        btGeneric6DofSpringConstraintData* dof = (btGeneric6DofSpringConstraintData*)dataBuffer;
83        btGeneric6DofConstraint::serialize(&dof->m_6dofData,serializer);
84
85        int i;
86        for (i=0;i<6;i++)
87        {
88                dof->m_equilibriumPoint[i] = m_equilibriumPoint[i];
89                dof->m_springDamping[i] = m_springDamping[i];
90                dof->m_springEnabled[i] = m_springEnabled[i]? 1 : 0;
91                dof->m_springStiffness[i] = m_springStiffness[i];
92        }
93        return "btGeneric6DofConstraintData";
94}
95
96#endif // BT_GENERIC_6DOF_SPRING_CONSTRAINT_H
97
Note: See TracBrowser for help on using the repository browser.