Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: code/trunk/src/external/bullet/BulletDynamics/ConstraintSolver/btGeneric6DofSpringConstraint.cpp @ 8351

Last change on this file since 8351 was 8351, checked in by rgrieder, 13 years ago

Merged kicklib2 branch back to trunk (includes former branches ois_update, mac_osx and kicklib).

Notes for updating

Linux:
You don't need an extra package for CEGUILua and Tolua, it's already shipped with CEGUI.
However you do need to make sure that the OgreRenderer is installed too with CEGUI 0.7 (may be a separate package).
Also, Orxonox now recognises if you install the CgProgramManager (a separate package available on newer Ubuntu on Debian systems).

Windows:
Download the new dependency packages versioned 6.0 and use these. If you have problems with that or if you don't like the in game console problem mentioned below, you can download the new 4.3 version of the packages (only available for Visual Studio 2005/2008).

Key new features:

  • *Support for Mac OS X*
  • Visual Studio 2010 support
  • Bullet library update to 2.77
  • OIS library update to 1.3
  • Support for CEGUI 0.7 —> Support for Arch Linux and even SuSE
  • Improved install target
  • Compiles now with GCC 4.6
  • Ogre Cg Shader plugin activated for Linux if available
  • And of course lots of bug fixes

There are also some regressions:

  • No support for CEGUI 0.5, Ogre 1.4 and boost 1.35 - 1.39 any more
  • In game console is not working in main menu for CEGUI 0.7
  • Tolua (just the C lib, not the application) and CEGUILua libraries are no longer in our repository. —> You will need to get these as well when compiling Orxonox
  • And of course lots of new bugs we don't yet know about
  • Property svn:eol-style set to native
File size: 4.5 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#include "btGeneric6DofSpringConstraint.h"
17#include "BulletDynamics/Dynamics/btRigidBody.h"
18#include "LinearMath/btTransformUtil.h"
19
20
21btGeneric6DofSpringConstraint::btGeneric6DofSpringConstraint(btRigidBody& rbA, btRigidBody& rbB, const btTransform& frameInA, const btTransform& frameInB ,bool useLinearReferenceFrameA)
22        : btGeneric6DofConstraint(rbA, rbB, frameInA, frameInB, useLinearReferenceFrameA)
23{
24        for(int i = 0; i < 6; i++)
25        {
26                m_springEnabled[i] = false;
27                m_equilibriumPoint[i] = btScalar(0.f);
28                m_springStiffness[i] = btScalar(0.f);
29                m_springDamping[i] = btScalar(1.f);
30        }
31}
32
33
34void btGeneric6DofSpringConstraint::enableSpring(int index, bool onOff)
35{
36        btAssert((index >= 0) && (index < 6));
37        m_springEnabled[index] = onOff;
38        if(index < 3)
39        {
40                m_linearLimits.m_enableMotor[index] = onOff;
41        }
42        else
43        {
44                m_angularLimits[index - 3].m_enableMotor = onOff;
45        }
46}
47
48
49
50void btGeneric6DofSpringConstraint::setStiffness(int index, btScalar stiffness)
51{
52        btAssert((index >= 0) && (index < 6));
53        m_springStiffness[index] = stiffness;
54}
55
56
57void btGeneric6DofSpringConstraint::setDamping(int index, btScalar damping)
58{
59        btAssert((index >= 0) && (index < 6));
60        m_springDamping[index] = damping;
61}
62
63
64void btGeneric6DofSpringConstraint::setEquilibriumPoint()
65{
66        calculateTransforms();
67        int i;
68
69        for( i = 0; i < 3; i++)
70        {
71                m_equilibriumPoint[i] = m_calculatedLinearDiff[i];
72        }
73        for(i = 0; i < 3; i++)
74        {
75                m_equilibriumPoint[i + 3] = m_calculatedAxisAngleDiff[i];
76        }
77}
78
79
80
81void btGeneric6DofSpringConstraint::setEquilibriumPoint(int index)
82{
83        btAssert((index >= 0) && (index < 6));
84        calculateTransforms();
85        if(index < 3)
86        {
87                m_equilibriumPoint[index] = m_calculatedLinearDiff[index];
88        }
89        else
90        {
91                m_equilibriumPoint[index] = m_calculatedAxisAngleDiff[index - 3];
92        }
93}
94
95void btGeneric6DofSpringConstraint::setEquilibriumPoint(int index, btScalar val)
96{
97        btAssert((index >= 0) && (index < 6));
98        m_equilibriumPoint[index] = val;
99}
100
101
102void btGeneric6DofSpringConstraint::internalUpdateSprings(btConstraintInfo2* info)
103{
104        // it is assumed that calculateTransforms() have been called before this call
105        int i;
106        btVector3 relVel = m_rbB.getLinearVelocity() - m_rbA.getLinearVelocity();
107        for(i = 0; i < 3; i++)
108        {
109                if(m_springEnabled[i])
110                {
111                        // get current position of constraint
112                        btScalar currPos = m_calculatedLinearDiff[i];
113                        // calculate difference
114                        btScalar delta = currPos - m_equilibriumPoint[i];
115                        // spring force is (delta * m_stiffness) according to Hooke's Law
116                        btScalar force = delta * m_springStiffness[i];
117                        btScalar velFactor = info->fps * m_springDamping[i] / btScalar(info->m_numIterations);
118                        m_linearLimits.m_targetVelocity[i] =  velFactor * force;
119                        m_linearLimits.m_maxMotorForce[i] =  btFabs(force) / info->fps;
120                }
121        }
122        for(i = 0; i < 3; i++)
123        {
124                if(m_springEnabled[i + 3])
125                {
126                        // get current position of constraint
127                        btScalar currPos = m_calculatedAxisAngleDiff[i];
128                        // calculate difference
129                        btScalar delta = currPos - m_equilibriumPoint[i+3];
130                        // spring force is (-delta * m_stiffness) according to Hooke's Law
131                        btScalar force = -delta * m_springStiffness[i+3];
132                        btScalar velFactor = info->fps * m_springDamping[i+3] / btScalar(info->m_numIterations);
133                        m_angularLimits[i].m_targetVelocity = velFactor * force;
134                        m_angularLimits[i].m_maxMotorForce = btFabs(force) / info->fps;
135                }
136        }
137}
138
139
140void btGeneric6DofSpringConstraint::getInfo2(btConstraintInfo2* info)
141{
142        // this will be called by constraint solver at the constraint setup stage
143        // set current motor parameters
144        internalUpdateSprings(info);
145        // do the rest of job for constraint setup
146        btGeneric6DofConstraint::getInfo2(info);
147}
148
149
150
151
Note: See TracBrowser for help on using the repository browser.