2 Copyright (c) 2013 Advanced Micro Devices, Inc.
4 This software is provided 'as-is', without any express or implied warranty.
5 In no event will the authors be held liable for any damages arising from the use of this software.
6 Permission is granted to anyone to use this software for any purpose,
7 including commercial applications, and to alter it and redistribute it freely,
8 subject to the following restrictions:
10 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.
11 2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software.
12 3. This notice may not be removed or altered from any source distribution.
14 //Originally written by Erwin Coumans
16 #ifndef B3_GPU_GENERIC_CONSTRAINT_H
17 #define B3_GPU_GENERIC_CONSTRAINT_H
19 #include "Bullet3Common/b3Quaternion.h"
20 struct b3RigidBodyData;
21 enum B3_CONSTRAINT_FLAGS
23 B3_CONSTRAINT_FLAG_ENABLED = 1,
26 enum b3GpuGenericConstraintType
28 B3_GPU_POINT2POINT_CONSTRAINT_TYPE = 3,
29 B3_GPU_FIXED_CONSTRAINT_TYPE = 4,
30 // B3_HINGE_CONSTRAINT_TYPE,
31 // B3_CONETWIST_CONSTRAINT_TYPE,
32 // B3_D6_CONSTRAINT_TYPE,
33 // B3_SLIDER_CONSTRAINT_TYPE,
34 // B3_CONTACT_CONSTRAINT_TYPE,
35 // B3_D6_SPRING_CONSTRAINT_TYPE,
36 // B3_GEAR_CONSTRAINT_TYPE,
38 B3_GPU_MAX_CONSTRAINT_TYPE
41 struct b3GpuConstraintInfo2
43 // integrator parameters: frames per second (1/stepsize), default error
44 // reduction parameter (0..1).
47 // for the first and second body, pointers to two (linear and angular)
48 // n*3 jacobian sub matrices, stored by rows. these matrices will have
49 // been initialized to 0 on entry. if the second body is zero then the
50 // J2xx pointers may be 0.
51 b3Scalar *m_J1linearAxis, *m_J1angularAxis, *m_J2linearAxis, *m_J2angularAxis;
53 // elements to jump from one row to the next in J's
56 // right hand sides of the equation J*v = c + cfm * lambda. cfm is the
57 // "constraint force mixing" vector. c is set to zero on entry, cfm is
58 // set to a constant value (typically very small or zero) value on entry.
59 b3Scalar *m_constraintError, *cfm;
61 // lo and hi limits for variables (set to -/+ infinity on entry).
62 b3Scalar *m_lowerLimit, *m_upperLimit;
64 // findex vector for variables. see the LCP solver interface for a
65 // description of what this does. this is set to -1 on entry.
66 // note that the returned indexes are relative to the first index of
69 // number of solver iterations
72 //damping of the velocity
76 B3_ATTRIBUTE_ALIGNED16(struct)
77 b3GpuGenericConstraint
82 float m_breakingImpulseThreshold;
86 b3Quaternion m_relTargetAB;
92 int getRigidBodyA() const
96 int getRigidBodyB() const
101 const b3Vector3& getPivotInA() const
106 const b3Vector3& getPivotInB() const
111 int isEnabled() const
113 return m_flags & B3_CONSTRAINT_FLAG_ENABLED;
116 float getBreakingImpulseThreshold() const
118 return m_breakingImpulseThreshold;
121 ///internal method used by the constraint solver, don't use them directly
122 void getInfo1(unsigned int* info, const b3RigidBodyData* bodies);
124 ///internal method used by the constraint solver, don't use them directly
125 void getInfo2(b3GpuConstraintInfo2 * info, const b3RigidBodyData* bodies);
128 #endif //B3_GPU_GENERIC_CONSTRAINT_H