2
Bullet Continuous Collision Detection and Physics Library
3
Copyright (c) 2003-2006 Erwin Coumans http://continuousphysics.com/Bullet/
5
This software is provided 'as-is', without any express or implied warranty.
6
In no event will the authors be held liable for any damages arising from the use of this software.
7
Permission is granted to anyone to use this software for any purpose,
8
including commercial applications, and to alter it and redistribute it freely,
9
subject to the following restrictions:
11
1. 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.
12
2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software.
13
3. This notice may not be removed or altered from any source distribution.
16
#ifndef GENERIC_6DOF_CONSTRAINT_H
17
#define GENERIC_6DOF_CONSTRAINT_H
19
#include "../../LinearMath/btVector3.h"
20
#include "btJacobianEntry.h"
21
#include "btTypedConstraint.h"
27
/// btGeneric6DofConstraint between two rigidbodies each with a pivotpoint that descibes the axis location in local space
28
/// btGeneric6DofConstraint can leave any of the 6 degree of freedom 'free' or 'locked'
29
/// Work in progress (is still a Hinge actually)
30
class btGeneric6DofConstraint : public btTypedConstraint
32
btJacobianEntry m_jacLinear[3]; // 3 orthogonal linear constraints
33
btJacobianEntry m_jacAng[3]; // 3 orthogonal angular constraints
35
btTransform m_frameInA; // the constraint space w.r.t body A
36
btTransform m_frameInB; // the constraint space w.r.t body B
38
btScalar m_lowerLimit[6]; // the constraint lower limits
39
btScalar m_upperLimit[6]; // the constraint upper limits
41
btScalar m_accumulatedImpulse[6];
43
btGeneric6DofConstraint& operator=(btGeneric6DofConstraint& other)
51
btGeneric6DofConstraint(btRigidBody& rbA, btRigidBody& rbB, const btTransform& frameInA, const btTransform& frameInB );
53
btGeneric6DofConstraint();
56
virtual void buildJacobian();
58
virtual void solveConstraint(btScalar timeStep);
60
void updateRHS(btScalar timeStep);
62
btScalar computeAngle(int axis) const;
64
void setLinearLowerLimit(const btVector3& linearLower)
66
m_lowerLimit[0] = linearLower.getX();
67
m_lowerLimit[1] = linearLower.getY();
68
m_lowerLimit[2] = linearLower.getZ();
71
void setLinearUpperLimit(const btVector3& linearUpper)
73
m_upperLimit[0] = linearUpper.getX();
74
m_upperLimit[1] = linearUpper.getY();
75
m_upperLimit[2] = linearUpper.getZ();
78
void setAngularLowerLimit(const btVector3& angularLower)
80
m_lowerLimit[3] = angularLower.getX();
81
m_lowerLimit[4] = angularLower.getY();
82
m_lowerLimit[5] = angularLower.getZ();
85
void setAngularUpperLimit(const btVector3& angularUpper)
87
m_upperLimit[3] = angularUpper.getX();
88
m_upperLimit[4] = angularUpper.getY();
89
m_upperLimit[5] = angularUpper.getZ();
92
//first 3 are linear, next 3 are angular
93
void SetLimit(int axis, btScalar lo, btScalar hi)
95
m_lowerLimit[axis] = lo;
96
m_upperLimit[axis] = hi;
99
//free means upper < lower,
100
//locked means upper == lower
101
//limited means upper > lower
102
//limitIndex: first 3 are linear, next 3 are angular
103
bool isLimited(int limitIndex)
105
return (m_upperLimit[limitIndex] >= m_lowerLimit[limitIndex]);
108
const btRigidBody& getRigidBodyA() const
112
const btRigidBody& getRigidBodyB() const
120
#endif //GENERIC_6DOF_CONSTRAINT_H