Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: code/trunk/src/external/bullet/BulletDynamics/ConstraintSolver/btPoint2PointConstraint.cpp @ 9032

Last change on this file since 9032 was 8351, checked in by rgrieder, 14 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: 6.0 KB
RevLine 
[1963]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
17#include "btPoint2PointConstraint.h"
18#include "BulletDynamics/Dynamics/btRigidBody.h"
19#include <new>
20
21
22
23
[8351]24
[1963]25btPoint2PointConstraint::btPoint2PointConstraint(btRigidBody& rbA,btRigidBody& rbB, const btVector3& pivotInA,const btVector3& pivotInB)
[2882]26:btTypedConstraint(POINT2POINT_CONSTRAINT_TYPE,rbA,rbB),m_pivotInA(pivotInA),m_pivotInB(pivotInB),
[8351]27m_flags(0),
[2882]28m_useSolveConstraintObsolete(false)
[1963]29{
30
31}
32
33
34btPoint2PointConstraint::btPoint2PointConstraint(btRigidBody& rbA,const btVector3& pivotInA)
[2882]35:btTypedConstraint(POINT2POINT_CONSTRAINT_TYPE,rbA),m_pivotInA(pivotInA),m_pivotInB(rbA.getCenterOfMassTransform()(pivotInA)),
[8351]36m_flags(0),
[2882]37m_useSolveConstraintObsolete(false)
[1963]38{
39       
40}
41
42void    btPoint2PointConstraint::buildJacobian()
43{
[8351]44
[2882]45        ///we need it for both methods
46        {
47                m_appliedImpulse = btScalar(0.);
[1963]48
[2882]49                btVector3       normal(0,0,0);
[1963]50
[2882]51                for (int i=0;i<3;i++)
52                {
53                        normal[i] = 1;
54                        new (&m_jac[i]) btJacobianEntry(
[1963]55                        m_rbA.getCenterOfMassTransform().getBasis().transpose(),
56                        m_rbB.getCenterOfMassTransform().getBasis().transpose(),
57                        m_rbA.getCenterOfMassTransform()*m_pivotInA - m_rbA.getCenterOfMassPosition(),
58                        m_rbB.getCenterOfMassTransform()*m_pivotInB - m_rbB.getCenterOfMassPosition(),
59                        normal,
60                        m_rbA.getInvInertiaDiagLocal(),
61                        m_rbA.getInvMass(),
62                        m_rbB.getInvInertiaDiagLocal(),
63                        m_rbB.getInvMass());
64                normal[i] = 0;
[2882]65                }
[1963]66        }
67
[8351]68
[1963]69}
70
[2882]71void btPoint2PointConstraint::getInfo1 (btConstraintInfo1* info)
[1963]72{
[8351]73        getInfo1NonVirtual(info);
74}
75
76void btPoint2PointConstraint::getInfo1NonVirtual (btConstraintInfo1* info)
77{
[2882]78        if (m_useSolveConstraintObsolete)
79        {
80                info->m_numConstraintRows = 0;
81                info->nub = 0;
82        } else
83        {
84                info->m_numConstraintRows = 3;
85                info->nub = 3;
86        }
87}
[1963]88
[8351]89
90
91
[2882]92void btPoint2PointConstraint::getInfo2 (btConstraintInfo2* info)
93{
[8351]94        getInfo2NonVirtual(info, m_rbA.getCenterOfMassTransform(),m_rbB.getCenterOfMassTransform());
95}
96
97void btPoint2PointConstraint::getInfo2NonVirtual (btConstraintInfo2* info, const btTransform& body0_trans, const btTransform& body1_trans)
98{
[2882]99        btAssert(!m_useSolveConstraintObsolete);
[1963]100
[2882]101         //retrieve matrices
102
103        // anchor points in global coordinates with respect to body PORs.
104   
105    // set jacobian
106    info->m_J1linearAxis[0] = 1;
[8351]107        info->m_J1linearAxis[info->rowskip+1] = 1;
108        info->m_J1linearAxis[2*info->rowskip+2] = 1;
[2882]109
110        btVector3 a1 = body0_trans.getBasis()*getPivotInA();
111        {
112                btVector3* angular0 = (btVector3*)(info->m_J1angularAxis);
113                btVector3* angular1 = (btVector3*)(info->m_J1angularAxis+info->rowskip);
114                btVector3* angular2 = (btVector3*)(info->m_J1angularAxis+2*info->rowskip);
115                btVector3 a1neg = -a1;
116                a1neg.getSkewSymmetricMatrix(angular0,angular1,angular2);
117        }
118   
119        /*info->m_J2linearAxis[0] = -1;
120    info->m_J2linearAxis[s+1] = -1;
121    info->m_J2linearAxis[2*s+2] = -1;
122        */
[1963]123       
[2882]124        btVector3 a2 = body1_trans.getBasis()*getPivotInB();
125   
126        {
127                btVector3 a2n = -a2;
128                btVector3* angular0 = (btVector3*)(info->m_J2angularAxis);
129                btVector3* angular1 = (btVector3*)(info->m_J2angularAxis+info->rowskip);
130                btVector3* angular2 = (btVector3*)(info->m_J2angularAxis+2*info->rowskip);
131                a2.getSkewSymmetricMatrix(angular0,angular1,angular2);
132        }
133   
[1963]134
135
[2882]136    // set right hand side
[8351]137        btScalar currERP = (m_flags & BT_P2P_FLAGS_ERP) ? m_erp : info->erp;
138    btScalar k = info->fps * currERP;
[2882]139    int j;
140        for (j=0; j<3; j++)
141    {
[8351]142        info->m_constraintError[j*info->rowskip] = k * (a2[j] + body1_trans.getOrigin()[j] - a1[j] - body0_trans.getOrigin()[j]);
[2882]143                //printf("info->m_constraintError[%d]=%f\n",j,info->m_constraintError[j]);
144    }
[8351]145        if(m_flags & BT_P2P_FLAGS_CFM)
146        {
147                for (j=0; j<3; j++)
148                {
149                        info->cfm[j*info->rowskip] = m_cfm;
150                }
151        }
[1963]152
[2882]153        btScalar impulseClamp = m_setting.m_impulseClamp;//
154        for (j=0; j<3; j++)
155    {
156                if (m_setting.m_impulseClamp > 0)
157                {
158                        info->m_lowerLimit[j*info->rowskip] = -impulseClamp;
159                        info->m_upperLimit[j*info->rowskip] = impulseClamp;
160                }
161        }
[8351]162        info->m_damping = m_setting.m_damping;
[1963]163       
[2882]164}
165
166
[8351]167
168void    btPoint2PointConstraint::updateRHS(btScalar     timeStep)
[2882]169{
[8351]170        (void)timeStep;
[2882]171
[8351]172}
[2882]173
[8351]174///override the default global value of a parameter (such as ERP or CFM), optionally provide the axis (0..5).
175///If no axis is provided, it uses the default axis for this constraint.
176void btPoint2PointConstraint::setParam(int num, btScalar value, int axis)
177{
178        if(axis != -1)
179        {
180                btAssertConstrParams(0);
181        }
182        else
183        {
184                switch(num)
185                {
186                        case BT_CONSTRAINT_ERP :
187                        case BT_CONSTRAINT_STOP_ERP :
188                                m_erp = value; 
189                                m_flags |= BT_P2P_FLAGS_ERP;
190                                break;
191                        case BT_CONSTRAINT_CFM :
192                        case BT_CONSTRAINT_STOP_CFM :
193                                m_cfm = value; 
194                                m_flags |= BT_P2P_FLAGS_CFM;
195                                break;
196                        default: 
197                                btAssertConstrParams(0);
[2882]198                }
[1963]199        }
200}
201
[8351]202///return the local value of parameter
203btScalar btPoint2PointConstraint::getParam(int num, int axis) const 
[1963]204{
[8351]205        btScalar retVal(SIMD_INFINITY);
206        if(axis != -1)
207        {
208                btAssertConstrParams(0);
209        }
210        else
211        {
212                switch(num)
213                {
214                        case BT_CONSTRAINT_ERP :
215                        case BT_CONSTRAINT_STOP_ERP :
216                                btAssertConstrParams(m_flags & BT_P2P_FLAGS_ERP);
217                                retVal = m_erp; 
218                                break;
219                        case BT_CONSTRAINT_CFM :
220                        case BT_CONSTRAINT_STOP_CFM :
221                                btAssertConstrParams(m_flags & BT_P2P_FLAGS_CFM);
222                                retVal = m_cfm; 
223                                break;
224                        default: 
225                                btAssertConstrParams(0);
226                }
227        }
228        return retVal;
[1963]229}
[8351]230       
Note: See TracBrowser for help on using the repository browser.