Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: code/trunk/src/external/bullet/BulletDynamics/ConstraintSolver/btTypedConstraint.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: 3.9 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
17#include "btTypedConstraint.h"
18#include "BulletDynamics/Dynamics/btRigidBody.h"
19#include "LinearMath/btSerializer.h"
20
21
22#define DEFAULT_DEBUGDRAW_SIZE btScalar(0.3f)
23
24btTypedConstraint::btTypedConstraint(btTypedConstraintType type, btRigidBody& rbA)
25:btTypedObject(type),
26m_userConstraintType(-1),
27m_userConstraintId(-1),
28m_needsFeedback(false),
29m_rbA(rbA),
30m_rbB(getFixedBody()),
31m_appliedImpulse(btScalar(0.)),
32m_dbgDrawSize(DEFAULT_DEBUGDRAW_SIZE)
33{
34}
35
36
37btTypedConstraint::btTypedConstraint(btTypedConstraintType type, btRigidBody& rbA,btRigidBody& rbB)
38:btTypedObject(type),
39m_userConstraintType(-1),
40m_userConstraintId(-1),
41m_needsFeedback(false),
42m_rbA(rbA),
43m_rbB(rbB),
44m_appliedImpulse(btScalar(0.)),
45m_dbgDrawSize(DEFAULT_DEBUGDRAW_SIZE)
46{
47}
48
49
50
51
52btScalar btTypedConstraint::getMotorFactor(btScalar pos, btScalar lowLim, btScalar uppLim, btScalar vel, btScalar timeFact)
53{
54        if(lowLim > uppLim)
55        {
56                return btScalar(1.0f);
57        }
58        else if(lowLim == uppLim)
59        {
60                return btScalar(0.0f);
61        }
62        btScalar lim_fact = btScalar(1.0f);
63        btScalar delta_max = vel / timeFact;
64        if(delta_max < btScalar(0.0f))
65        {
66                if((pos >= lowLim) && (pos < (lowLim - delta_max)))
67                {
68                        lim_fact = (lowLim - pos) / delta_max;
69                }
70                else if(pos  < lowLim)
71                {
72                        lim_fact = btScalar(0.0f);
73                }
74                else
75                {
76                        lim_fact = btScalar(1.0f);
77                }
78        }
79        else if(delta_max > btScalar(0.0f))
80        {
81                if((pos <= uppLim) && (pos > (uppLim - delta_max)))
82                {
83                        lim_fact = (uppLim - pos) / delta_max;
84                }
85                else if(pos  > uppLim)
86                {
87                        lim_fact = btScalar(0.0f);
88                }
89                else
90                {
91                        lim_fact = btScalar(1.0f);
92                }
93        }
94        else
95        {
96                        lim_fact = btScalar(0.0f);
97        }
98        return lim_fact;
99}
100
101///fills the dataBuffer and returns the struct name (and 0 on failure)
102const char*     btTypedConstraint::serialize(void* dataBuffer, btSerializer* serializer) const
103{
104        btTypedConstraintData* tcd = (btTypedConstraintData*) dataBuffer;
105
106        tcd->m_rbA = (btRigidBodyData*)serializer->getUniquePointer(&m_rbA);
107        tcd->m_rbB = (btRigidBodyData*)serializer->getUniquePointer(&m_rbB);
108        char* name = (char*) serializer->findNameForPointer(this);
109        tcd->m_name = (char*)serializer->getUniquePointer(name);
110        if (tcd->m_name)
111        {
112                serializer->serializeName(name);
113        }
114
115        tcd->m_objectType = m_objectType;
116        tcd->m_needsFeedback = m_needsFeedback;
117        tcd->m_userConstraintId =m_userConstraintId;
118        tcd->m_userConstraintType =m_userConstraintType;
119
120        tcd->m_appliedImpulse = float(m_appliedImpulse);
121        tcd->m_dbgDrawSize = float(m_dbgDrawSize );
122
123        tcd->m_disableCollisionsBetweenLinkedBodies = false;
124
125        int i;
126        for (i=0;i<m_rbA.getNumConstraintRefs();i++)
127                if (m_rbA.getConstraintRef(i) == this)
128                        tcd->m_disableCollisionsBetweenLinkedBodies = true;
129        for (i=0;i<m_rbB.getNumConstraintRefs();i++)
130                if (m_rbB.getConstraintRef(i) == this)
131                        tcd->m_disableCollisionsBetweenLinkedBodies = true;
132
133        return "btTypedConstraintData";
134}
135
136btRigidBody& btTypedConstraint::getFixedBody()
137{
138        static btRigidBody s_fixed(0, 0,0);
139        s_fixed.setMassProps(btScalar(0.),btVector3(btScalar(0.),btScalar(0.),btScalar(0.)));
140        return s_fixed;
141}
142
Note: See TracBrowser for help on using the repository browser.