diff --git a/dtool/src/parser-inc/btBulletDynamicsCommon.h b/dtool/src/parser-inc/btBulletDynamicsCommon.h index 2251bb607f..95bc7a03ca 100644 --- a/dtool/src/parser-inc/btBulletDynamicsCommon.h +++ b/dtool/src/parser-inc/btBulletDynamicsCommon.h @@ -55,6 +55,7 @@ class btOverlapFilterCallback; class btPairCachingGhostObject; class btParalleSequentialImpulseSolver; class btPersistentManifold; +class btRotationalLimitMotor; class btPlaneShape; class btPoint2PointConstraint; class btPolyhedralConvexShape; @@ -71,6 +72,7 @@ class btSphereShape; class btStaticPlaneShape; class btStridingMeshInterface; class btTransform; +class btTranslationalLimitMotor; class btTriangleMesh; class btTypedConstraint; class btTypedObject; diff --git a/panda/src/bullet/bulletGenericConstraint.cxx b/panda/src/bullet/bulletGenericConstraint.cxx index 24385244b7..6a16f6484c 100644 --- a/panda/src/bullet/bulletGenericConstraint.cxx +++ b/panda/src/bullet/bulletGenericConstraint.cxx @@ -143,3 +143,25 @@ set_angular_limit(int axis, PN_stdfloat low, PN_stdfloat high) { _constraint->setLimit(axis + 3, low, high); } +//////////////////////////////////////////////////////////////////// +// Function: BulletGenericConstraint::get_rotational_limit_motor +// Access: Published +// Description: +//////////////////////////////////////////////////////////////////// +BulletRotationalLimitMotor BulletGenericConstraint:: +get_rotational_limit_motor(int axis) { + + return BulletRotationalLimitMotor(*_constraint->getRotationalLimitMotor(axis)); +} + +//////////////////////////////////////////////////////////////////// +// Function: BulletGenericConstraint::get_translational_limit_motor +// Access: Published +// Description: +//////////////////////////////////////////////////////////////////// +BulletTranslationalLimitMotor BulletGenericConstraint:: +get_translational_limit_motor() { + + return BulletTranslationalLimitMotor(*_constraint->getTranslationalLimitMotor()); +} + diff --git a/panda/src/bullet/bulletGenericConstraint.h b/panda/src/bullet/bulletGenericConstraint.h index 4452ae6a23..79c4213730 100644 --- a/panda/src/bullet/bulletGenericConstraint.h +++ b/panda/src/bullet/bulletGenericConstraint.h @@ -20,6 +20,8 @@ #include "bullet_includes.h" #include "bullet_utils.h" #include "bulletConstraint.h" +#include "bulletRotationalLimitMotor.h" +#include "bulletTranslationalLimitMotor.h" #include "transformState.h" #include "luse.h" @@ -43,19 +45,27 @@ PUBLISHED: bool use_frame_a); INLINE ~BulletGenericConstraint(); - void set_linear_limit(int axis, PN_stdfloat low, PN_stdfloat high); - void set_angular_limit(int axis, PN_stdfloat low, PN_stdfloat high); - + // Geometry LVector3 get_axis(int axis) const; PN_stdfloat get_pivot(int axis) const; PN_stdfloat get_angle(int axis) const; + // Limit + void set_linear_limit(int axis, PN_stdfloat low, PN_stdfloat high); + void set_angular_limit(int axis, PN_stdfloat low, PN_stdfloat high); + + // Motors + BulletRotationalLimitMotor get_rotational_limit_motor(int axis); + BulletTranslationalLimitMotor get_translational_limit_motor(); + public: virtual btTypedConstraint *ptr() const; private: btGeneric6DofConstraint *_constraint; +//TODO btRotationalLimitMotor * getRotationalLimitMotor (int index) + //////////////////////////////////////////////////////////////////// public: static TypeHandle get_class_type() { diff --git a/panda/src/bullet/bulletRotationalLimitMotor.I b/panda/src/bullet/bulletRotationalLimitMotor.I new file mode 100644 index 0000000000..f3a0730f2e --- /dev/null +++ b/panda/src/bullet/bulletRotationalLimitMotor.I @@ -0,0 +1,216 @@ +// Filename: bulletRotationalLimitMotor.I +// Created by: enn0x (03Mar13) +// +//////////////////////////////////////////////////////////////////// +// +// PANDA 3D SOFTWARE +// Copyright (c) Carnegie Mellon University. All rights reserved. +// +// All use of this software is subject to the terms of the revised BSD +// license. You should have received a copy of this license along +// with this source code in a file named "LICENSE." +// +//////////////////////////////////////////////////////////////////// + + +//////////////////////////////////////////////////////////////////// +// Function: BulletRotationalLimitMotor::is_limited +// Access: Published +// Description: +//////////////////////////////////////////////////////////////////// +INLINE bool BulletRotationalLimitMotor:: +is_limited() const { + + return _motor.isLimited(); +} + +//////////////////////////////////////////////////////////////////// +// Function: BulletRotationalLimitMotor::set_motor_enabled +// Access: Published +// Description: +//////////////////////////////////////////////////////////////////// +INLINE void BulletRotationalLimitMotor:: +set_motor_enabled(bool enabled) { + + _motor.m_enableMotor = enabled; +} + +//////////////////////////////////////////////////////////////////// +// Function: BulletRotationalLimitMotor::get_motor_enabled +// Access: Published +// Description: +//////////////////////////////////////////////////////////////////// +INLINE bool BulletRotationalLimitMotor:: +get_motor_enabled() const { + + return _motor.m_enableMotor; +} + +//////////////////////////////////////////////////////////////////// +// Function: BulletRotationalLimitMotor::set_low_limit +// Access: Published +// Description: +//////////////////////////////////////////////////////////////////// +INLINE void BulletRotationalLimitMotor:: +set_low_limit(PN_stdfloat limit) { + + _motor.m_loLimit = (btScalar)limit; +} + +//////////////////////////////////////////////////////////////////// +// Function: BulletRotationalLimitMotor::set_high_limit +// Access: Published +// Description: +//////////////////////////////////////////////////////////////////// +INLINE void BulletRotationalLimitMotor:: +set_high_limit(PN_stdfloat limit) { + + _motor.m_hiLimit = (btScalar)limit; +} + +//////////////////////////////////////////////////////////////////// +// Function: BulletRotationalLimitMotor::set_target_velocity +// Access: Published +// Description: +//////////////////////////////////////////////////////////////////// +INLINE void BulletRotationalLimitMotor:: +set_target_velocity(PN_stdfloat velocity) { + + _motor.m_targetVelocity = (btScalar)velocity; +} + +//////////////////////////////////////////////////////////////////// +// Function: BulletRotationalLimitMotor::set_max_motor_force +// Access: Published +// Description: +//////////////////////////////////////////////////////////////////// +INLINE void BulletRotationalLimitMotor:: +set_max_motor_force(PN_stdfloat force) { + + _motor.m_maxMotorForce = (btScalar)force; +} + +//////////////////////////////////////////////////////////////////// +// Function: BulletRotationalLimitMotor::set_max_limit_force +// Access: Published +// Description: +//////////////////////////////////////////////////////////////////// +INLINE void BulletRotationalLimitMotor:: +set_max_limit_force(PN_stdfloat force) { + + _motor.m_maxLimitForce = (btScalar)force; +} + +//////////////////////////////////////////////////////////////////// +// Function: BulletRotationalLimitMotor::set_damping +// Access: Published +// Description: +//////////////////////////////////////////////////////////////////// +INLINE void BulletRotationalLimitMotor:: +set_damping(PN_stdfloat damping) { + + _motor.m_damping = (btScalar)damping; +} + +//////////////////////////////////////////////////////////////////// +// Function: BulletRotationalLimitMotor::set_softness +// Access: Published +// Description: +//////////////////////////////////////////////////////////////////// +INLINE void BulletRotationalLimitMotor:: +set_softness(PN_stdfloat softness) { + + _motor.m_limitSoftness = (btScalar)softness; +} + +//////////////////////////////////////////////////////////////////// +// Function: BulletRotationalLimitMotor::set_bounce +// Access: Published +// Description: +//////////////////////////////////////////////////////////////////// +INLINE void BulletRotationalLimitMotor:: +set_bounce(PN_stdfloat bounce) { + + _motor.m_bounce = (btScalar)bounce; +} + +//////////////////////////////////////////////////////////////////// +// Function: BulletRotationalLimitMotor::set_normal_cfm +// Access: Published +// Description: +//////////////////////////////////////////////////////////////////// +INLINE void BulletRotationalLimitMotor:: +set_normal_cfm(PN_stdfloat cfm) { + + _motor.m_normalCFM = (btScalar)cfm; +} + +//////////////////////////////////////////////////////////////////// +// Function: BulletRotationalLimitMotor::set_stop_cfm +// Access: Published +// Description: +//////////////////////////////////////////////////////////////////// +INLINE void BulletRotationalLimitMotor:: +set_stop_cfm(PN_stdfloat cfm) { + + _motor.m_stopCFM = (btScalar)cfm; +} + +//////////////////////////////////////////////////////////////////// +// Function: BulletRotationalLimitMotor::set_stop_erp +// Access: Published +// Description: +//////////////////////////////////////////////////////////////////// +INLINE void BulletRotationalLimitMotor:: +set_stop_erp(PN_stdfloat erp) { + + _motor.m_stopERP = (btScalar)erp; +} + +//////////////////////////////////////////////////////////////////// +// Function: BulletRotationalLimitMotor::get_current_limit +// Access: Published +// Description: Retrieves the current value of angle: +// 0 = free, +// 1 = at low limit, +// 2 = at high limit. +//////////////////////////////////////////////////////////////////// +INLINE int BulletRotationalLimitMotor:: +get_current_limit() const { + + return _motor.m_currentLimit; +} + +//////////////////////////////////////////////////////////////////// +// Function: BulletRotationalLimitMotor::get_current_error +// Access: Published +// Description: +//////////////////////////////////////////////////////////////////// +INLINE PN_stdfloat BulletRotationalLimitMotor:: +get_current_error() const { + + return (PN_stdfloat)_motor.m_currentLimitError; +} + +//////////////////////////////////////////////////////////////////// +// Function: BulletRotationalLimitMotor::get_current_position +// Access: Published +// Description: +//////////////////////////////////////////////////////////////////// +INLINE PN_stdfloat BulletRotationalLimitMotor:: +get_current_position() const { + + return (PN_stdfloat)_motor.m_currentPosition; +} + +//////////////////////////////////////////////////////////////////// +// Function: BulletRotationalLimitMotor::get_accumulated_impulse +// Access: Published +// Description: +//////////////////////////////////////////////////////////////////// +INLINE PN_stdfloat BulletRotationalLimitMotor:: +get_accumulated_impulse() const { + + return (PN_stdfloat)_motor.m_accumulatedImpulse; +} + diff --git a/panda/src/bullet/bulletRotationalLimitMotor.cxx b/panda/src/bullet/bulletRotationalLimitMotor.cxx new file mode 100644 index 0000000000..4420c4abf3 --- /dev/null +++ b/panda/src/bullet/bulletRotationalLimitMotor.cxx @@ -0,0 +1,48 @@ +// Filename: bulletRotationalLimitMotor.cxx +// Created by: enn0x (03Mar13) +// +//////////////////////////////////////////////////////////////////// +// +// PANDA 3D SOFTWARE +// Copyright (c) Carnegie Mellon University. All rights reserved. +// +// All use of this software is subject to the terms of the revised BSD +// license. You should have received a copy of this license along +// with this source code in a file named "LICENSE." +// +//////////////////////////////////////////////////////////////////// + +#include "bulletRotationalLimitMotor.h" + +//////////////////////////////////////////////////////////////////// +// Function: BulletRotationalLimitMotor::Constructor +// Access: Public +// Description: +//////////////////////////////////////////////////////////////////// +BulletRotationalLimitMotor:: +BulletRotationalLimitMotor(btRotationalLimitMotor &motor) + : _motor(motor) { + +} + +//////////////////////////////////////////////////////////////////// +// Function: BulletRotationalLimitMotor::Copy Constructor +// Access: Published +// Description: +//////////////////////////////////////////////////////////////////// +BulletRotationalLimitMotor:: +BulletRotationalLimitMotor(const BulletRotationalLimitMotor ©) + : _motor(copy._motor) { + +} + +//////////////////////////////////////////////////////////////////// +// Function: BulletRotationalLimitMotor::Destructor +// Access: Published +// Description: +//////////////////////////////////////////////////////////////////// +BulletRotationalLimitMotor:: +~BulletRotationalLimitMotor() { + +} + diff --git a/panda/src/bullet/bulletRotationalLimitMotor.h b/panda/src/bullet/bulletRotationalLimitMotor.h new file mode 100644 index 0000000000..674aff9baf --- /dev/null +++ b/panda/src/bullet/bulletRotationalLimitMotor.h @@ -0,0 +1,64 @@ +// Filename: bulletRotationalLimitMotor.h +// Created by: enn0x (03Mar13) +// +//////////////////////////////////////////////////////////////////// +// +// PANDA 3D SOFTWARE +// Copyright (c) Carnegie Mellon University. All rights reserved. +// +// All use of this software is subject to the terms of the revised BSD +// license. You should have received a copy of this license along +// with this source code in a file named "LICENSE." +// +//////////////////////////////////////////////////////////////////// + +#ifndef __BULLET_ROTATIONAL_LIMIT_MOTOR_H__ +#define __BULLET_ROTATIONAL_LIMIT_MOTOR_H__ + +#include "pandabase.h" + +#include "bullet_includes.h" +#include "bullet_utils.h" + +#include "luse.h" + +//////////////////////////////////////////////////////////////////// +// Class : BulletRotationalLimitMotor +// Description : Rotation Limit structure for generic joints. +//////////////////////////////////////////////////////////////////// +class EXPCL_PANDABULLET BulletRotationalLimitMotor { + +PUBLISHED: + BulletRotationalLimitMotor(const BulletRotationalLimitMotor ©); + ~BulletRotationalLimitMotor(); + + INLINE void set_motor_enabled(bool enable); + INLINE void set_low_limit(PN_stdfloat limit); + INLINE void set_high_limit(PN_stdfloat limit); + INLINE void set_target_velocity(PN_stdfloat velocity); + INLINE void set_max_motor_force(PN_stdfloat force); + INLINE void set_max_limit_force(PN_stdfloat force); + INLINE void set_damping(PN_stdfloat damping); + INLINE void set_softness(PN_stdfloat softness); + INLINE void set_bounce(PN_stdfloat bounce); + INLINE void set_normal_cfm(PN_stdfloat cfm); + INLINE void set_stop_cfm(PN_stdfloat cfm); + INLINE void set_stop_erp(PN_stdfloat erp); + + INLINE bool is_limited() const; + INLINE bool get_motor_enabled() const; + INLINE int get_current_limit() const; + INLINE PN_stdfloat get_current_error() const; + INLINE PN_stdfloat get_current_position() const; + INLINE PN_stdfloat get_accumulated_impulse() const; + +public: + BulletRotationalLimitMotor(btRotationalLimitMotor &motor); + +private: + btRotationalLimitMotor &_motor; +}; + +#include "bulletRotationalLimitMotor.I" + +#endif // __BULLET_ROTATIONAL_LIMIT_MOTOR_H__ diff --git a/panda/src/bullet/bulletTranslationalLimitMotor.I b/panda/src/bullet/bulletTranslationalLimitMotor.I new file mode 100644 index 0000000000..2089dd9780 --- /dev/null +++ b/panda/src/bullet/bulletTranslationalLimitMotor.I @@ -0,0 +1,216 @@ +// Filename: bulletTranslationalLimitMotor.I +// Created by: enn0x (03Mar13) +// +//////////////////////////////////////////////////////////////////// +// +// PANDA 3D SOFTWARE +// Copyright (c) Carnegie Mellon University. All rights reserved. +// +// All use of this software is subject to the terms of the revised BSD +// license. You should have received a copy of this license along +// with this source code in a file named "LICENSE." +// +//////////////////////////////////////////////////////////////////// + + +//////////////////////////////////////////////////////////////////// +// Function: BulletTranslationalLimitMotor::is_limited +// Access: Published +// Description: +//////////////////////////////////////////////////////////////////// +INLINE bool BulletTranslationalLimitMotor:: +is_limited(int axis) const { + + nassertr((0 <= axis) && (axis <= 2), false); + return _motor.isLimited(axis); +} + +//////////////////////////////////////////////////////////////////// +// Function: BulletTranslationalLimitMotor::set_motor_enabled +// Access: Published +// Description: +//////////////////////////////////////////////////////////////////// +INLINE void BulletTranslationalLimitMotor:: +set_motor_enabled(int axis, bool enabled) { + + nassertv((0 <= axis) && (axis <= 2)); + _motor.m_enableMotor[axis] = enabled; +} + +//////////////////////////////////////////////////////////////////// +// Function: BulletTranslationalLimitMotor::get_motor_enabled +// Access: Published +// Description: +//////////////////////////////////////////////////////////////////// +INLINE bool BulletTranslationalLimitMotor:: +get_motor_enabled(int axis) const { + + nassertr((0 <= axis) && (axis <= 2), false); + return _motor.m_enableMotor[axis]; +} + +//////////////////////////////////////////////////////////////////// +// Function: BulletTranslationalLimitMotor::set_low_limit +// Access: Published +// Description: +//////////////////////////////////////////////////////////////////// +INLINE void BulletTranslationalLimitMotor:: +set_low_limit(const LVecBase3 &limit) { + + nassertv(!limit.is_nan()); + _motor.m_lowerLimit = LVecBase3_to_btVector3(limit); +} + +//////////////////////////////////////////////////////////////////// +// Function: BulletTranslationalLimitMotor::set_high_limit +// Access: Published +// Description: +//////////////////////////////////////////////////////////////////// +INLINE void BulletTranslationalLimitMotor:: +set_high_limit(const LVecBase3 &limit) { + + nassertv(!limit.is_nan()); + _motor.m_upperLimit = LVecBase3_to_btVector3(limit); +} + +//////////////////////////////////////////////////////////////////// +// Function: BulletTranslationalLimitMotor::set_target_velocity +// Access: Published +// Description: +//////////////////////////////////////////////////////////////////// +INLINE void BulletTranslationalLimitMotor:: +set_target_velocity(const LVecBase3 &velocity) { + + nassertv(!velocity.is_nan()); + _motor.m_targetVelocity = LVecBase3_to_btVector3(velocity); +} + +//////////////////////////////////////////////////////////////////// +// Function: BulletTranslationalLimitMotor::set_max_motor_force +// Access: Published +// Description: +//////////////////////////////////////////////////////////////////// +INLINE void BulletTranslationalLimitMotor:: +set_max_motor_force(const LVecBase3 &force) { + + nassertv(!force.is_nan()); + _motor.m_maxMotorForce = LVecBase3_to_btVector3(force); +} + +//////////////////////////////////////////////////////////////////// +// Function: BulletTranslationalLimitMotor::set_damping +// Access: Published +// Description: +//////////////////////////////////////////////////////////////////// +INLINE void BulletTranslationalLimitMotor:: +set_damping(PN_stdfloat damping) { + + _motor.m_damping = (btScalar)damping; +} + +//////////////////////////////////////////////////////////////////// +// Function: BulletTranslationalLimitMotor::set_softness +// Access: Published +// Description: +//////////////////////////////////////////////////////////////////// +INLINE void BulletTranslationalLimitMotor:: +set_softness(PN_stdfloat softness) { + + _motor.m_limitSoftness = (btScalar)softness; +} + +//////////////////////////////////////////////////////////////////// +// Function: BulletTranslationalLimitMotor::set_restitution +// Access: Published +// Description: +//////////////////////////////////////////////////////////////////// +INLINE void BulletTranslationalLimitMotor:: +set_restitution(PN_stdfloat restitution) { + + _motor.m_restitution = (btScalar)restitution; +} + +//////////////////////////////////////////////////////////////////// +// Function: BulletTranslationalLimitMotor::set_normal_cfm +// Access: Published +// Description: +//////////////////////////////////////////////////////////////////// +INLINE void BulletTranslationalLimitMotor:: +set_normal_cfm(const LVecBase3 &cfm) { + + nassertv(!cfm.is_nan()); + _motor.m_normalCFM = LVecBase3_to_btVector3(cfm); +} + +//////////////////////////////////////////////////////////////////// +// Function: BulletTranslationalLimitMotor::set_stop_cfm +// Access: Published +// Description: +//////////////////////////////////////////////////////////////////// +INLINE void BulletTranslationalLimitMotor:: +set_stop_cfm(const LVecBase3 &cfm) { + + nassertv(!cfm.is_nan()); + _motor.m_stopCFM = LVecBase3_to_btVector3(cfm); +} + +//////////////////////////////////////////////////////////////////// +// Function: BulletTranslationalLimitMotor::set_stop_erp +// Access: Published +// Description: +//////////////////////////////////////////////////////////////////// +INLINE void BulletTranslationalLimitMotor:: +set_stop_erp(const LVecBase3 &erp) { + + nassertv(!erp.is_nan()); + _motor.m_stopERP = LVecBase3_to_btVector3(erp); +} + +//////////////////////////////////////////////////////////////////// +// Function: BulletTranslationalLimitMotor::get_current_limit +// Access: Published +// Description: Retrieves the current value of angle: +// 0 = free, +// 1 = at low limit, +// 2 = at high limit. +//////////////////////////////////////////////////////////////////// +INLINE int BulletTranslationalLimitMotor:: +get_current_limit(int axis) const { + + nassertr((0 <- axis) && (axis <=2), false); + return _motor.m_currentLimit[axis]; +} + +//////////////////////////////////////////////////////////////////// +// Function: BulletTranslationalLimitMotor::get_current_error +// Access: Published +// Description: +//////////////////////////////////////////////////////////////////// +INLINE LVector3 BulletTranslationalLimitMotor:: +get_current_error() const { + + return btVector3_to_LVector3(_motor.m_currentLimitError); +} + +//////////////////////////////////////////////////////////////////// +// Function: BulletTranslationalLimitMotor::get_current_diff +// Access: Published +// Description: +//////////////////////////////////////////////////////////////////// +INLINE LPoint3 BulletTranslationalLimitMotor:: +get_current_diff() const { + + return btVector3_to_LPoint3(_motor.m_currentLinearDiff); +} + +//////////////////////////////////////////////////////////////////// +// Function: BulletTranslationalLimitMotor::get_accumulated_impulse +// Access: Published +// Description: +//////////////////////////////////////////////////////////////////// +INLINE LVector3 BulletTranslationalLimitMotor:: +get_accumulated_impulse() const { + + return btVector3_to_LVector3(_motor.m_accumulatedImpulse); +} + diff --git a/panda/src/bullet/bulletTranslationalLimitMotor.cxx b/panda/src/bullet/bulletTranslationalLimitMotor.cxx new file mode 100644 index 0000000000..5164935ed3 --- /dev/null +++ b/panda/src/bullet/bulletTranslationalLimitMotor.cxx @@ -0,0 +1,48 @@ +// Filename: bulletTranslationalLimitMotor.cxx +// Created by: enn0x (03Mar13) +// +//////////////////////////////////////////////////////////////////// +// +// PANDA 3D SOFTWARE +// Copyright (c) Carnegie Mellon University. All rights reserved. +// +// All use of this software is subject to the terms of the revised BSD +// license. You should have received a copy of this license along +// with this source code in a file named "LICENSE." +// +//////////////////////////////////////////////////////////////////// + +#include "bulletTranslationalLimitMotor.h" + +//////////////////////////////////////////////////////////////////// +// Function: BulletTranslationalLimitMotor::Constructor +// Access: Public +// Description: +//////////////////////////////////////////////////////////////////// +BulletTranslationalLimitMotor:: +BulletTranslationalLimitMotor(btTranslationalLimitMotor &motor) + : _motor(motor) { + +} + +//////////////////////////////////////////////////////////////////// +// Function: BulletTranslationalLimitMotor::Copy Constructor +// Access: Published +// Description: +//////////////////////////////////////////////////////////////////// +BulletTranslationalLimitMotor:: +BulletTranslationalLimitMotor(const BulletTranslationalLimitMotor ©) + : _motor(copy._motor) { + +} + +//////////////////////////////////////////////////////////////////// +// Function: BulletTranslationalLimitMotor::Destructor +// Access: Published +// Description: +//////////////////////////////////////////////////////////////////// +BulletTranslationalLimitMotor:: +~BulletTranslationalLimitMotor() { + +} + diff --git a/panda/src/bullet/bulletTranslationalLimitMotor.h b/panda/src/bullet/bulletTranslationalLimitMotor.h new file mode 100644 index 0000000000..9330d1fd1f --- /dev/null +++ b/panda/src/bullet/bulletTranslationalLimitMotor.h @@ -0,0 +1,63 @@ +// Filename: bulletTranslationalLimitMotor.h +// Created by: enn0x (03Mar13) +// +//////////////////////////////////////////////////////////////////// +// +// PANDA 3D SOFTWARE +// Copyright (c) Carnegie Mellon University. All rights reserved. +// +// All use of this software is subject to the terms of the revised BSD +// license. You should have received a copy of this license along +// with this source code in a file named "LICENSE." +// +//////////////////////////////////////////////////////////////////// + +#ifndef __BULLET_TRANSLATIONAL_LIMIT_MOTOR_H__ +#define __BULLET_TRANSLATIONAL_LIMIT_MOTOR_H__ + +#include "pandabase.h" + +#include "bullet_includes.h" +#include "bullet_utils.h" + +#include "luse.h" + +//////////////////////////////////////////////////////////////////// +// Class : BulletTranslationalLimitMotor +// Description : Rotation Limit structure for generic joints. +//////////////////////////////////////////////////////////////////// +class EXPCL_PANDABULLET BulletTranslationalLimitMotor { + +PUBLISHED: + BulletTranslationalLimitMotor(const BulletTranslationalLimitMotor ©); + ~BulletTranslationalLimitMotor(); + + INLINE void set_motor_enabled(int axis, bool enable); + INLINE void set_low_limit(const LVecBase3 &limit); + INLINE void set_high_limit(const LVecBase3 & limit); + INLINE void set_target_velocity(const LVecBase3&velocity); + INLINE void set_max_motor_force(const LVecBase3 &force); + INLINE void set_damping(PN_stdfloat damping); + INLINE void set_softness(PN_stdfloat softness); + INLINE void set_restitution(PN_stdfloat restitution); + INLINE void set_normal_cfm(const LVecBase3 &cfm); + INLINE void set_stop_erp(const LVecBase3 &erp); + INLINE void set_stop_cfm(const LVecBase3 &cfm); + + INLINE bool is_limited(int axis) const; + INLINE bool get_motor_enabled(int axis) const; + INLINE int get_current_limit(int axis) const; + INLINE LVector3 get_current_error() const; + INLINE LPoint3 get_current_diff() const; + INLINE LVector3 get_accumulated_impulse() const; + +public: + BulletTranslationalLimitMotor(btTranslationalLimitMotor &motor); + +private: + btTranslationalLimitMotor &_motor; +}; + +#include "bulletTranslationalLimitMotor.I" + +#endif // __BULLET_TRANSLATIONAL_LIMIT_MOTOR_H__ diff --git a/panda/src/bullet/p3bullet_composite.cxx b/panda/src/bullet/p3bullet_composite.cxx index c7f5211341..85407ffd84 100644 --- a/panda/src/bullet/p3bullet_composite.cxx +++ b/panda/src/bullet/p3bullet_composite.cxx @@ -28,6 +28,7 @@ #include "bulletPersistentManifold.cxx" #include "bulletPlaneShape.cxx" #include "bulletRigidBodyNode.cxx" +#include "bulletRotationalLimitMotor.cxx" #include "bulletShape.cxx" #include "bulletSliderConstraint.cxx" #include "bulletSphereShape.cxx" @@ -38,6 +39,7 @@ #include "bulletSoftBodyShape.cxx" #include "bulletSoftBodyWorldInfo.cxx" #include "bulletTickCallbackData.cxx" +#include "bulletTranslationalLimitMotor.cxx" #include "bulletTriangleMesh.cxx" #include "bulletTriangleMeshShape.cxx" #include "bulletVehicle.cxx"