15 #include "bulletConeTwistConstraint.h"
16 #include "bulletRigidBodyNode.h"
18 #include "deg_2_rad.h"
20 TypeHandle BulletConeTwistConstraint::_type_handle;
27 BulletConeTwistConstraint::
29 const TransformState *frame_a) {
31 btRigidBody *ptr_a = btRigidBody::upcast(node_a->get_object());
32 btTransform trans_a = TransformState_to_btTrans(frame_a);
34 _constraint =
new btConeTwistConstraint(*ptr_a, trans_a);
42 BulletConeTwistConstraint::
45 const TransformState *frame_a,
46 const TransformState *frame_b) {
48 btRigidBody *ptr_a = btRigidBody::upcast(node_a->get_object());
49 btTransform trans_a = TransformState_to_btTrans(frame_a);
51 btRigidBody *ptr_b = btRigidBody::upcast(node_b->get_object());
52 btTransform trans_b = TransformState_to_btTrans(frame_b);
54 _constraint =
new btConeTwistConstraint(*ptr_a, *ptr_b, trans_a, trans_b);
62 btTypedConstraint *BulletConeTwistConstraint::
73 void BulletConeTwistConstraint::
74 set_limit(
int index, PN_stdfloat value) {
76 value = deg_2_rad(value);
78 _constraint->setLimit(index, value);
86 void BulletConeTwistConstraint::
87 set_limit(PN_stdfloat swing1, PN_stdfloat swing2, PN_stdfloat twist, PN_stdfloat softness, PN_stdfloat bias, PN_stdfloat relaxation) {
89 swing1 = deg_2_rad(swing1);
90 swing2 = deg_2_rad(swing2);
91 twist = deg_2_rad(twist);
93 _constraint->setLimit(swing1, swing2, twist, softness, bias, relaxation);
101 void BulletConeTwistConstraint::
102 set_damping(PN_stdfloat damping) {
104 _constraint->setDamping(damping);
112 PN_stdfloat BulletConeTwistConstraint::
113 get_fix_threshold()
const {
115 return _constraint->getFixThresh();
123 void BulletConeTwistConstraint::
124 set_fix_threshold(PN_stdfloat threshold) {
126 _constraint->setFixThresh(threshold);
134 void BulletConeTwistConstraint::
135 enable_motor(
bool enable) {
137 _constraint->enableMotor(enable);
145 void BulletConeTwistConstraint::
146 set_max_motor_impulse(PN_stdfloat max_impulse) {
148 _constraint->setMaxMotorImpulse(max_impulse);
156 void BulletConeTwistConstraint::
157 set_max_motor_impulse_normalized(PN_stdfloat max_impulse) {
159 _constraint->setMaxMotorImpulseNormalized(max_impulse);
167 void BulletConeTwistConstraint::
170 _constraint->setMotorTarget(LQuaternion_to_btQuat(quat));
178 void BulletConeTwistConstraint::
179 set_motor_target_in_constraint_space(
const LQuaternion &quat) {
181 _constraint->setMotorTargetInConstraintSpace(LQuaternion_to_btQuat(quat));
189 void BulletConeTwistConstraint::
190 set_frames(
const TransformState *ts_a,
const TransformState *ts_b) {
192 btTransform frame_a = TransformState_to_btTrans(ts_a);
193 btTransform frame_b = TransformState_to_btTrans(ts_b);
195 _constraint->setFrames(frame_a, frame_b);
This is the base quaternion class.
TypeHandle is the identifier used to differentiate C++ class types.