From e2fe9513220395e52f54f1c95eb0d71a29376232 Mon Sep 17 00:00:00 2001 From: rdb Date: Sun, 16 Oct 2016 00:14:05 +0200 Subject: [PATCH 1/3] Fix compilation errors in Bullet 2.84/2.85 --- doc/ReleaseNotes | 1 + .../bullet/bulletCharacterControllerNode.cxx | 19 ++++++++++-- panda/src/bullet/bulletManifoldPoint.I | 30 +++++++++++++++---- 3 files changed, 42 insertions(+), 8 deletions(-) diff --git a/doc/ReleaseNotes b/doc/ReleaseNotes index da8e24ae0f..88631b2244 100644 --- a/doc/ReleaseNotes +++ b/doc/ReleaseNotes @@ -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 rare X11 .ico cursor bug; also now supports PNG-compressed icons * Add keyword argument support to make() methods such as Shader.make() +* Fix compilation errors with Bullet 2.84 ------------------------ RELEASE 1.9.2 ------------------------ diff --git a/panda/src/bullet/bulletCharacterControllerNode.cxx b/panda/src/bullet/bulletCharacterControllerNode.cxx index f0cb471e40..648b8a76e6 100644 --- a/panda/src/bullet/bulletCharacterControllerNode.cxx +++ b/panda/src/bullet/bulletCharacterControllerNode.cxx @@ -14,6 +14,10 @@ #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; //////////////////////////////////////////////////////////////////// @@ -57,8 +61,13 @@ BulletCharacterControllerNode(BulletShape *shape, PN_stdfloat step_height, const _angular_movement = 0.0f; // 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->setGravity((btScalar)9.81f); +#endif // Retain a pointer to the shape _shape = shape; @@ -301,8 +310,11 @@ get_max_slope() const { //////////////////////////////////////////////////////////////////// PN_stdfloat BulletCharacterControllerNode:: get_gravity() const { - +#if BT_BULLET_VERSION >= 285 + return -(PN_stdfloat)_character->getGravity()[_up]; +#else return (PN_stdfloat)_character->getGravity(); +#endif } //////////////////////////////////////////////////////////////////// @@ -311,8 +323,11 @@ get_gravity() const { //////////////////////////////////////////////////////////////////// void BulletCharacterControllerNode:: set_gravity(PN_stdfloat gravity) { - +#if BT_BULLET_VERSION >= 285 + _character->setGravity(up_vectors[_up] * -(btScalar)gravity); +#else _character->setGravity((btScalar)gravity); +#endif } diff --git a/panda/src/bullet/bulletManifoldPoint.I b/panda/src/bullet/bulletManifoldPoint.I index e99c2060ca..9ebfa6e1ec 100644 --- a/panda/src/bullet/bulletManifoldPoint.I +++ b/panda/src/bullet/bulletManifoldPoint.I @@ -29,8 +29,15 @@ INLINE BulletManifoldPoint:: //////////////////////////////////////////////////////////////////// INLINE void BulletManifoldPoint:: 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; +#endif } //////////////////////////////////////////////////////////////////// @@ -40,8 +47,11 @@ set_lateral_friction_initialized(bool value) { //////////////////////////////////////////////////////////////////// INLINE bool BulletManifoldPoint:: 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; +#endif } //////////////////////////////////////////////////////////////////// @@ -238,8 +248,9 @@ get_applied_impulse_lateral2() const { //////////////////////////////////////////////////////////////////// INLINE void BulletManifoldPoint:: set_contact_cfm1(PN_stdfloat value) { - +#if BT_BULLET_VERSION < 285 _pt.m_contactCFM1 = (btScalar)value; +#endif } //////////////////////////////////////////////////////////////////// @@ -249,8 +260,11 @@ set_contact_cfm1(PN_stdfloat value) { //////////////////////////////////////////////////////////////////// INLINE PN_stdfloat BulletManifoldPoint:: get_contact_cfm1() const { - +#if BT_BULLET_VERSION < 285 return (PN_stdfloat)_pt.m_contactCFM1; +#else + return 0; +#endif } //////////////////////////////////////////////////////////////////// @@ -260,8 +274,9 @@ get_contact_cfm1() const { //////////////////////////////////////////////////////////////////// INLINE void BulletManifoldPoint:: set_contact_cfm2(PN_stdfloat value) { - +#if BT_BULLET_VERSION < 285 _pt.m_contactCFM2 = (btScalar)value; +#endif } //////////////////////////////////////////////////////////////////// @@ -271,7 +286,10 @@ set_contact_cfm2(PN_stdfloat value) { //////////////////////////////////////////////////////////////////// INLINE PN_stdfloat BulletManifoldPoint:: get_contact_cfm2() const { - +#if BT_BULLET_VERSION < 285 return (PN_stdfloat)_pt.m_contactCFM2; +#else + return 0; +#endif } From ea82d9d66426a489bed7c14fb117c7028dffe175 Mon Sep 17 00:00:00 2001 From: rdb Date: Thu, 20 Oct 2016 11:02:19 +0200 Subject: [PATCH 2/3] Preserve "intangible" and "level" collide flags in bam2egg --- doc/ReleaseNotes | 1 + panda/src/egg2pg/eggSaver.cxx | 20 ++++++++++++++++---- 2 files changed, 17 insertions(+), 4 deletions(-) diff --git a/doc/ReleaseNotes b/doc/ReleaseNotes index 88631b2244..a05c4487e4 100644 --- a/doc/ReleaseNotes +++ b/doc/ReleaseNotes @@ -32,6 +32,7 @@ This issue fixes several bugs that were still found in 1.9.2. * Fix RAM caching of 2D texture arrays * Fix Ctrl+C interrupt propagation to runtime applications * Support for InvSphere, Box and Tube solids in bam2egg +* Preserve "intangible" and "level" collide flags in bam2egg * Add normalized() method to vectors * asyncFlattenStrong with inPlace=True caused node to disappear * Fix asyncFlattenStrong called on nodes without parent diff --git a/panda/src/egg2pg/eggSaver.cxx b/panda/src/egg2pg/eggSaver.cxx index 99a36c50a7..647337e6bf 100644 --- a/panda/src/egg2pg/eggSaver.cxx +++ b/panda/src/egg2pg/eggSaver.cxx @@ -449,8 +449,20 @@ convert_collision_node(CollisionNode *node, const WorkingNodePath &node_path, // traverse solids for (int i = 0; i < num_solids; i++) { CPT(CollisionSolid) child = node->get_solid(i); + int flags = EggGroup::CF_descend; + + if (!child->is_tangible()) { + flags |= EggGroup::CF_intangible; + } + + if (child->has_effective_normal() && + child->get_effective_normal() == LVector3::up()) { + flags |= EggGroup::CF_level; + } + if (child->is_of_type(CollisionPolygon::get_class_type())) { egg_group->set_cs_type(EggGroup::CST_polyset); + egg_group->set_collide_flags(flags); EggPolygon *egg_poly = new EggPolygon; egg_group->add_child(egg_poly); @@ -476,7 +488,6 @@ convert_collision_node(CollisionNode *node, const WorkingNodePath &node_path, egg_sphere = egg_group; } else { egg_sphere = new EggGroup; - egg_sphere->set_collide_flags(EggGroup::CF_descend); egg_group->add_child(egg_sphere); } @@ -485,6 +496,7 @@ convert_collision_node(CollisionNode *node, const WorkingNodePath &node_path, } else { egg_sphere->set_cs_type(EggGroup::CST_sphere); } + egg_sphere->set_collide_flags(flags); EggVertex ev1, ev2; ev1.set_pos(LCAST(double, (center + offset) * net_mat)); @@ -518,10 +530,10 @@ convert_collision_node(CollisionNode *node, const WorkingNodePath &node_path, egg_plane = egg_group; } else { egg_plane = new EggGroup; - egg_plane->set_collide_flags(EggGroup::CF_descend); egg_group->add_child(egg_plane); } egg_plane->set_cs_type(EggGroup::CST_plane); + egg_plane->set_collide_flags(flags); EggVertex ev0, ev1, ev2; ev0.set_pos(LCAST(double, origin * net_mat)); @@ -545,10 +557,10 @@ convert_collision_node(CollisionNode *node, const WorkingNodePath &node_path, egg_box = egg_group; } else { egg_box = new EggGroup; - egg_box->set_collide_flags(EggGroup::CF_descend); egg_group->add_child(egg_box); } egg_box->set_cs_type(EggGroup::CST_box); + egg_box->set_collide_flags(flags); // Just add the min and max points. EggVertex ev0, ev1; @@ -584,10 +596,10 @@ convert_collision_node(CollisionNode *node, const WorkingNodePath &node_path, egg_tube = egg_group; } else { egg_tube = new EggGroup; - egg_tube->set_collide_flags(EggGroup::CF_descend); egg_group->add_child(egg_tube); } egg_tube->set_cs_type(EggGroup::CST_tube); + egg_tube->set_collide_flags(flags); // Add two points for the endcaps, and then two points around the // centroid to indicate the radius. From 34b8e0844ee11988a57c5205074779f0f81ae8ce Mon Sep 17 00:00:00 2001 From: rdb Date: Thu, 20 Oct 2016 11:13:44 +0200 Subject: [PATCH 3/3] Fix compile errors in unicode conversion in max exporter --- pandatool/src/maxegg/maxEggLoader.cxx | 11 +++++++++-- pandatool/src/maxegg/maxToEggConverter.cxx | 15 +++++++++++++++ 2 files changed, 24 insertions(+), 2 deletions(-) diff --git a/pandatool/src/maxegg/maxEggLoader.cxx b/pandatool/src/maxegg/maxEggLoader.cxx index 5129045100..d6adf0ec41 100644 --- a/pandatool/src/maxegg/maxEggLoader.cxx +++ b/pandatool/src/maxegg/maxEggLoader.cxx @@ -291,7 +291,7 @@ void MaxEggJoint::CreateMaxBone(void) _node->SetRenderable(FALSE); #ifdef _UNICODE - TCHAR *wname [1024]; + TCHAR wname[1024]; wname[1023] = 0; mbstowcs(wname, _egg_joint->get_name().c_str(), 1023); _node->SetName(wname); @@ -468,7 +468,14 @@ MaxEggMesh *MaxEggLoader::GetMesh(EggVertexPool *pool) result->_tvert_count = 0; result->_cvert_count = 0; result->_face_count = 0; - result->_node->SetName(TSTR(name.c_str())); +#ifdef _UNICODE + TCHAR wname[1024]; + wname[1023] = 0; + mbstowcs(wname, name.c_str(), 1023); + result->_node->SetName(wname); +#else + result->_node->SetName((char*) name.c_str()); +#endif _mesh_tab[pool] = result; } return result; diff --git a/pandatool/src/maxegg/maxToEggConverter.cxx b/pandatool/src/maxegg/maxToEggConverter.cxx index bcc32aeff3..37f5011f00 100644 --- a/pandatool/src/maxegg/maxToEggConverter.cxx +++ b/pandatool/src/maxegg/maxToEggConverter.cxx @@ -589,7 +589,14 @@ make_nurbs_curve(INode *max_node, NURBSCVCurve *curve, return false; } +#ifdef _UNICODE + char mbname[1024]; + mbname[1023] = 0; + wcstombs(mbname, max_node->GetName(), 1023); + string name(mbname); +#else string name = max_node->GetName(); +#endif string vpool_name = name + ".cvs"; EggVertexPool *vpool = new EggVertexPool(vpool_name); @@ -652,7 +659,15 @@ make_polyset(INode *max_node, Mesh *mesh, // all the vertices up front, we'll start with an empty vpool, and // add vertices to it on the fly. +#ifdef _UNICODE + char mbname[1024]; + mbname[1023] = 0; + wcstombs(mbname, max_node->GetName(), 1023); + string node_name(mbname); +#else string node_name = max_node->GetName(); +#endif + string vpool_name = node_name + ".verts"; EggVertexPool *vpool = new EggVertexPool(vpool_name); egg_group->add_child(vpool);