2017-08-01 12:30:58 +00:00
|
|
|
/*
|
|
|
|
Copyright (c) 2013 Advanced Micro Devices, Inc.
|
|
|
|
|
|
|
|
This software is provided 'as-is', without any express or implied warranty.
|
|
|
|
In no event will the authors be held liable for any damages arising from the use of this software.
|
|
|
|
Permission is granted to anyone to use this software for any purpose,
|
|
|
|
including commercial applications, and to alter it and redistribute it freely,
|
|
|
|
subject to the following restrictions:
|
|
|
|
|
|
|
|
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.
|
|
|
|
2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software.
|
|
|
|
3. This notice may not be removed or altered from any source distribution.
|
|
|
|
*/
|
|
|
|
//Originally written by Erwin Coumans
|
|
|
|
|
|
|
|
#ifndef B3_GPU_GENERIC_CONSTRAINT_H
|
|
|
|
#define B3_GPU_GENERIC_CONSTRAINT_H
|
|
|
|
|
|
|
|
#include "Bullet3Common/b3Quaternion.h"
|
|
|
|
struct b3RigidBodyData;
|
|
|
|
enum B3_CONSTRAINT_FLAGS
|
|
|
|
{
|
2019-01-03 13:26:51 +00:00
|
|
|
B3_CONSTRAINT_FLAG_ENABLED = 1,
|
2017-08-01 12:30:58 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
enum b3GpuGenericConstraintType
|
|
|
|
{
|
2019-01-03 13:26:51 +00:00
|
|
|
B3_GPU_POINT2POINT_CONSTRAINT_TYPE = 3,
|
|
|
|
B3_GPU_FIXED_CONSTRAINT_TYPE = 4,
|
|
|
|
// B3_HINGE_CONSTRAINT_TYPE,
|
|
|
|
// B3_CONETWIST_CONSTRAINT_TYPE,
|
|
|
|
// B3_D6_CONSTRAINT_TYPE,
|
|
|
|
// B3_SLIDER_CONSTRAINT_TYPE,
|
|
|
|
// B3_CONTACT_CONSTRAINT_TYPE,
|
|
|
|
// B3_D6_SPRING_CONSTRAINT_TYPE,
|
|
|
|
// B3_GEAR_CONSTRAINT_TYPE,
|
|
|
|
|
2017-08-01 12:30:58 +00:00
|
|
|
B3_GPU_MAX_CONSTRAINT_TYPE
|
|
|
|
};
|
|
|
|
|
2019-01-03 13:26:51 +00:00
|
|
|
struct b3GpuConstraintInfo2
|
2017-08-01 12:30:58 +00:00
|
|
|
{
|
|
|
|
// integrator parameters: frames per second (1/stepsize), default error
|
|
|
|
// reduction parameter (0..1).
|
2019-01-03 13:26:51 +00:00
|
|
|
b3Scalar fps, erp;
|
2017-08-01 12:30:58 +00:00
|
|
|
|
|
|
|
// for the first and second body, pointers to two (linear and angular)
|
|
|
|
// n*3 jacobian sub matrices, stored by rows. these matrices will have
|
|
|
|
// been initialized to 0 on entry. if the second body is zero then the
|
|
|
|
// J2xx pointers may be 0.
|
2019-01-03 13:26:51 +00:00
|
|
|
b3Scalar *m_J1linearAxis, *m_J1angularAxis, *m_J2linearAxis, *m_J2angularAxis;
|
2017-08-01 12:30:58 +00:00
|
|
|
|
|
|
|
// elements to jump from one row to the next in J's
|
|
|
|
int rowskip;
|
|
|
|
|
|
|
|
// right hand sides of the equation J*v = c + cfm * lambda. cfm is the
|
|
|
|
// "constraint force mixing" vector. c is set to zero on entry, cfm is
|
|
|
|
// set to a constant value (typically very small or zero) value on entry.
|
2019-01-03 13:26:51 +00:00
|
|
|
b3Scalar *m_constraintError, *cfm;
|
2017-08-01 12:30:58 +00:00
|
|
|
|
|
|
|
// lo and hi limits for variables (set to -/+ infinity on entry).
|
2019-01-03 13:26:51 +00:00
|
|
|
b3Scalar *m_lowerLimit, *m_upperLimit;
|
2017-08-01 12:30:58 +00:00
|
|
|
|
|
|
|
// findex vector for variables. see the LCP solver interface for a
|
|
|
|
// description of what this does. this is set to -1 on entry.
|
|
|
|
// note that the returned indexes are relative to the first index of
|
|
|
|
// the constraint.
|
2019-01-03 13:26:51 +00:00
|
|
|
int* findex;
|
2017-08-01 12:30:58 +00:00
|
|
|
// number of solver iterations
|
|
|
|
int m_numIterations;
|
|
|
|
|
|
|
|
//damping of the velocity
|
2019-01-03 13:26:51 +00:00
|
|
|
b3Scalar m_damping;
|
2017-08-01 12:30:58 +00:00
|
|
|
};
|
|
|
|
|
2019-01-03 13:26:51 +00:00
|
|
|
B3_ATTRIBUTE_ALIGNED16(struct)
|
|
|
|
b3GpuGenericConstraint
|
2017-08-01 12:30:58 +00:00
|
|
|
{
|
2019-01-03 13:26:51 +00:00
|
|
|
int m_constraintType;
|
|
|
|
int m_rbA;
|
|
|
|
int m_rbB;
|
|
|
|
float m_breakingImpulseThreshold;
|
2017-08-01 12:30:58 +00:00
|
|
|
|
|
|
|
b3Vector3 m_pivotInA;
|
|
|
|
b3Vector3 m_pivotInB;
|
|
|
|
b3Quaternion m_relTargetAB;
|
|
|
|
|
2019-01-03 13:26:51 +00:00
|
|
|
int m_flags;
|
2017-08-01 12:30:58 +00:00
|
|
|
int m_uid;
|
|
|
|
int m_padding[2];
|
|
|
|
|
2019-01-03 13:26:51 +00:00
|
|
|
int getRigidBodyA() const
|
2017-08-01 12:30:58 +00:00
|
|
|
{
|
|
|
|
return m_rbA;
|
|
|
|
}
|
2019-01-03 13:26:51 +00:00
|
|
|
int getRigidBodyB() const
|
2017-08-01 12:30:58 +00:00
|
|
|
{
|
|
|
|
return m_rbB;
|
|
|
|
}
|
|
|
|
|
|
|
|
const b3Vector3& getPivotInA() const
|
|
|
|
{
|
|
|
|
return m_pivotInA;
|
|
|
|
}
|
|
|
|
|
|
|
|
const b3Vector3& getPivotInB() const
|
|
|
|
{
|
|
|
|
return m_pivotInB;
|
|
|
|
}
|
|
|
|
|
|
|
|
int isEnabled() const
|
|
|
|
{
|
|
|
|
return m_flags & B3_CONSTRAINT_FLAG_ENABLED;
|
|
|
|
}
|
|
|
|
|
|
|
|
float getBreakingImpulseThreshold() const
|
|
|
|
{
|
|
|
|
return m_breakingImpulseThreshold;
|
|
|
|
}
|
|
|
|
|
|
|
|
///internal method used by the constraint solver, don't use them directly
|
2019-01-03 13:26:51 +00:00
|
|
|
void getInfo1(unsigned int* info, const b3RigidBodyData* bodies);
|
2017-08-01 12:30:58 +00:00
|
|
|
|
|
|
|
///internal method used by the constraint solver, don't use them directly
|
2019-01-03 13:26:51 +00:00
|
|
|
void getInfo2(b3GpuConstraintInfo2 * info, const b3RigidBodyData* bodies);
|
2017-08-01 12:30:58 +00:00
|
|
|
};
|
|
|
|
|
2019-01-03 13:26:51 +00:00
|
|
|
#endif //B3_GPU_GENERIC_CONSTRAINT_H
|