Fix compilation errors in Bullet 2.84/2.85

This commit is contained in:
rdb 2016-10-16 00:14:05 +02:00
parent 955ca0d334
commit e2fe951322
3 changed files with 42 additions and 8 deletions

View File

@ -43,6 +43,7 @@ This issue fixes several bugs that were still found in 1.9.2.
* Fix exception when creating intervals before ShowBase is started * Fix exception when creating intervals before ShowBase is started
* Fix rare X11 .ico cursor bug; also now supports PNG-compressed icons * Fix rare X11 .ico cursor bug; also now supports PNG-compressed icons
* Add keyword argument support to make() methods such as Shader.make() * Add keyword argument support to make() methods such as Shader.make()
* Fix compilation errors with Bullet 2.84
------------------------ RELEASE 1.9.2 ------------------------ ------------------------ RELEASE 1.9.2 ------------------------

View File

@ -14,6 +14,10 @@
#include "bulletCharacterControllerNode.h" #include "bulletCharacterControllerNode.h"
#if BT_BULLET_VERSION >= 285
static const btVector3 up_vectors[3] = {btVector3(1.0f, 0.0f, 0.0f), btVector3(0.0f, 1.0f, 0.0f), btVector3(0.0f, 0.0f, 1.0f)};
#endif
TypeHandle BulletCharacterControllerNode::_type_handle; TypeHandle BulletCharacterControllerNode::_type_handle;
//////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////
@ -57,8 +61,13 @@ BulletCharacterControllerNode(BulletShape *shape, PN_stdfloat step_height, const
_angular_movement = 0.0f; _angular_movement = 0.0f;
// Character controller // Character controller
#if BT_BULLET_VERSION >= 285
_character = new btKinematicCharacterController(_ghost, convex, step_height, up_vectors[_up]);
_character->setGravity(up_vectors[_up] * -(btScalar)9.81f);
#else
_character = new btKinematicCharacterController(_ghost, convex, step_height, _up); _character = new btKinematicCharacterController(_ghost, convex, step_height, _up);
_character->setGravity((btScalar)9.81f); _character->setGravity((btScalar)9.81f);
#endif
// Retain a pointer to the shape // Retain a pointer to the shape
_shape = shape; _shape = shape;
@ -301,8 +310,11 @@ get_max_slope() const {
//////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////
PN_stdfloat BulletCharacterControllerNode:: PN_stdfloat BulletCharacterControllerNode::
get_gravity() const { get_gravity() const {
#if BT_BULLET_VERSION >= 285
return -(PN_stdfloat)_character->getGravity()[_up];
#else
return (PN_stdfloat)_character->getGravity(); return (PN_stdfloat)_character->getGravity();
#endif
} }
//////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////
@ -311,8 +323,11 @@ get_gravity() const {
//////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////
void BulletCharacterControllerNode:: void BulletCharacterControllerNode::
set_gravity(PN_stdfloat gravity) { set_gravity(PN_stdfloat gravity) {
#if BT_BULLET_VERSION >= 285
_character->setGravity(up_vectors[_up] * -(btScalar)gravity);
#else
_character->setGravity((btScalar)gravity); _character->setGravity((btScalar)gravity);
#endif
} }

View File

@ -29,8 +29,15 @@ INLINE BulletManifoldPoint::
//////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////
INLINE void BulletManifoldPoint:: INLINE void BulletManifoldPoint::
set_lateral_friction_initialized(bool value) { set_lateral_friction_initialized(bool value) {
#if BT_BULLET_VERSION >= 285
if (value) {
_pt.m_contactPointFlags |= BT_CONTACT_FLAG_LATERAL_FRICTION_INITIALIZED;
} else {
_pt.m_contactPointFlags &= ~BT_CONTACT_FLAG_LATERAL_FRICTION_INITIALIZED;
}
#else
_pt.m_lateralFrictionInitialized = value; _pt.m_lateralFrictionInitialized = value;
#endif
} }
//////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////
@ -40,8 +47,11 @@ set_lateral_friction_initialized(bool value) {
//////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////
INLINE bool BulletManifoldPoint:: INLINE bool BulletManifoldPoint::
get_lateral_friction_initialized() const { get_lateral_friction_initialized() const {
#if BT_BULLET_VERSION >= 285
return (_pt.m_contactPointFlags & BT_CONTACT_FLAG_LATERAL_FRICTION_INITIALIZED) != 0;
#else
return _pt.m_lateralFrictionInitialized; return _pt.m_lateralFrictionInitialized;
#endif
} }
//////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////
@ -238,8 +248,9 @@ get_applied_impulse_lateral2() const {
//////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////
INLINE void BulletManifoldPoint:: INLINE void BulletManifoldPoint::
set_contact_cfm1(PN_stdfloat value) { set_contact_cfm1(PN_stdfloat value) {
#if BT_BULLET_VERSION < 285
_pt.m_contactCFM1 = (btScalar)value; _pt.m_contactCFM1 = (btScalar)value;
#endif
} }
//////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////
@ -249,8 +260,11 @@ set_contact_cfm1(PN_stdfloat value) {
//////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////
INLINE PN_stdfloat BulletManifoldPoint:: INLINE PN_stdfloat BulletManifoldPoint::
get_contact_cfm1() const { get_contact_cfm1() const {
#if BT_BULLET_VERSION < 285
return (PN_stdfloat)_pt.m_contactCFM1; return (PN_stdfloat)_pt.m_contactCFM1;
#else
return 0;
#endif
} }
//////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////
@ -260,8 +274,9 @@ get_contact_cfm1() const {
//////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////
INLINE void BulletManifoldPoint:: INLINE void BulletManifoldPoint::
set_contact_cfm2(PN_stdfloat value) { set_contact_cfm2(PN_stdfloat value) {
#if BT_BULLET_VERSION < 285
_pt.m_contactCFM2 = (btScalar)value; _pt.m_contactCFM2 = (btScalar)value;
#endif
} }
//////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////
@ -271,7 +286,10 @@ set_contact_cfm2(PN_stdfloat value) {
//////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////
INLINE PN_stdfloat BulletManifoldPoint:: INLINE PN_stdfloat BulletManifoldPoint::
get_contact_cfm2() const { get_contact_cfm2() const {
#if BT_BULLET_VERSION < 285
return (PN_stdfloat)_pt.m_contactCFM2; return (PN_stdfloat)_pt.m_contactCFM2;
#else
return 0;
#endif
} }