Panda3D
 All Classes Functions Variables Enumerations
bulletBodyNode.I
00001 // Filename: bulletBodyNode.I
00002 // Created by:  enn0x (19Nov10)
00003 //
00004 ////////////////////////////////////////////////////////////////////
00005 //
00006 // PANDA 3D SOFTWARE
00007 // Copyright (c) Carnegie Mellon University.  All rights reserved.
00008 //
00009 // All use of this software is subject to the terms of the revised BSD
00010 // license.  You should have received a copy of this license along
00011 // with this source code in a file named "LICENSE."
00012 //
00013 ////////////////////////////////////////////////////////////////////
00014 
00015 
00016 ////////////////////////////////////////////////////////////////////
00017 //     Function: BulletBodyNode::Destructor
00018 //       Access: Published
00019 //  Description:
00020 ////////////////////////////////////////////////////////////////////
00021 INLINE BulletBodyNode::
00022 ~BulletBodyNode() {
00023 
00024   if (_shape && (
00025       _shape->getShapeType() == COMPOUND_SHAPE_PROXYTYPE || 
00026       _shape->getShapeType() == EMPTY_SHAPE_PROXYTYPE)) {
00027     delete _shape;
00028   }
00029 }
00030 
00031 ////////////////////////////////////////////////////////////////////
00032 //     Function: BulletBodyNode::set_into_collide_mask
00033 //       Access: Published
00034 //  Description: 
00035 ////////////////////////////////////////////////////////////////////
00036 INLINE void BulletBodyNode::
00037 set_into_collide_mask(CollideMask mask) {
00038 
00039   PandaNode::set_into_collide_mask(mask);
00040 
00041 /*
00042   TODO: we would need a handle to the BulletWorld first
00043         possible, but has to be set/cleared upon attach/remove to world
00044 
00045   if (!_world) return;
00046 
00047   btBroadphaseProxy* proxy = get_object()->getBroadphaseHandle();
00048   if (proxy) {
00049     btBroadphaseInterface *broadphase = _world->get_broadphase();
00050     btDispatcher *dispatcher = _world->get_dispatcher();
00051 
00052     broadphase->getOverlappingPairCache()->cleanProxyFromPairs(proxy, dispatcher);
00053   }
00054 */
00055 }
00056 
00057 ////////////////////////////////////////////////////////////////////
00058 //     Function: BulletBodyNode::notify_collisions
00059 //       Access: Published
00060 //  Description:
00061 ////////////////////////////////////////////////////////////////////
00062 INLINE void BulletBodyNode::
00063 notify_collisions(bool value) {
00064 
00065   set_collision_flag(btCollisionObject::CF_CUSTOM_MATERIAL_CALLBACK, value);
00066 }
00067 
00068 ////////////////////////////////////////////////////////////////////
00069 //     Function: BulletBodyNode::notifies_collisions
00070 //       Access: Published
00071 //  Description:
00072 ////////////////////////////////////////////////////////////////////
00073 INLINE bool BulletBodyNode::
00074 notifies_collisions() const {
00075 
00076   return get_collision_flag(btCollisionObject::CF_CUSTOM_MATERIAL_CALLBACK);
00077 }
00078 
00079 ////////////////////////////////////////////////////////////////////
00080 //     Function: BulletBodyNode::set_collision_response
00081 //       Access: Published
00082 //  Description:
00083 ////////////////////////////////////////////////////////////////////
00084 INLINE void BulletBodyNode::
00085 set_collision_response(bool value) {
00086 
00087   set_collision_flag(btCollisionObject::CF_NO_CONTACT_RESPONSE, !value);
00088 }
00089 
00090 ////////////////////////////////////////////////////////////////////
00091 //     Function: BulletBodyNode::get_collision_response
00092 //       Access: Published
00093 //  Description:
00094 ////////////////////////////////////////////////////////////////////
00095 INLINE bool BulletBodyNode::
00096 get_collision_response() const {
00097 
00098   return !get_collision_flag(btCollisionObject::CF_NO_CONTACT_RESPONSE);
00099 }
00100 
00101 ////////////////////////////////////////////////////////////////////
00102 //     Function: BulletBodyNode::set_collision_flag
00103 //       Access: Protected
00104 //  Description:
00105 ////////////////////////////////////////////////////////////////////
00106 INLINE void BulletBodyNode::
00107 set_collision_flag(int flag, bool value) {
00108 
00109   int flags = get_object()->getCollisionFlags();
00110 
00111   if (value == true) {
00112     flags |= flag;
00113   }
00114   else {
00115     flags &= ~(flag);
00116   }
00117 
00118   get_object()->setCollisionFlags(flags);
00119 }
00120 
00121 ////////////////////////////////////////////////////////////////////
00122 //     Function: BulletBodyNode::get_collision_flag
00123 //       Access: Protected
00124 //  Description:
00125 ////////////////////////////////////////////////////////////////////
00126 INLINE bool BulletBodyNode::
00127 get_collision_flag(int flag) const {
00128 
00129   return (get_object()->getCollisionFlags() & flag) ? true : false;
00130 }
00131 
00132 ////////////////////////////////////////////////////////////////////
00133 //     Function: BulletBodyNode::is_static
00134 //       Access: Published
00135 //  Description:
00136 ////////////////////////////////////////////////////////////////////
00137 INLINE bool BulletBodyNode::
00138 is_static() const {
00139 
00140   return get_object()->isStaticObject();
00141 }
00142 
00143 ////////////////////////////////////////////////////////////////////
00144 //     Function: BulletBodyNode::is_kinematic
00145 //       Access: Published
00146 //  Description:
00147 ////////////////////////////////////////////////////////////////////
00148 INLINE bool BulletBodyNode::
00149 is_kinematic() const {
00150 
00151   return get_object()->isKinematicObject();
00152 }
00153 
00154 ////////////////////////////////////////////////////////////////////
00155 //     Function: BulletBodyNode::set_static
00156 //       Access: Published
00157 //  Description:
00158 ////////////////////////////////////////////////////////////////////
00159 INLINE void BulletBodyNode::
00160 set_static(bool value) {
00161 
00162   set_collision_flag(btCollisionObject::CF_STATIC_OBJECT, value);
00163 }
00164 
00165 ////////////////////////////////////////////////////////////////////
00166 //     Function: BulletBodyNode::set_kinematic
00167 //       Access: Published
00168 //  Description:
00169 ////////////////////////////////////////////////////////////////////
00170 INLINE void BulletBodyNode::
00171 set_kinematic(bool value) {
00172 
00173   set_collision_flag(btCollisionObject::CF_KINEMATIC_OBJECT, value);
00174 }
00175 
00176 ////////////////////////////////////////////////////////////////////
00177 //     Function: BulletBodyNode::get_restitution
00178 //       Access: Published
00179 //  Description:
00180 ////////////////////////////////////////////////////////////////////
00181 INLINE PN_stdfloat BulletBodyNode::
00182 get_restitution() const {
00183 
00184   return get_object()->getRestitution();
00185 }
00186 
00187 ////////////////////////////////////////////////////////////////////
00188 //     Function: BulletBodyNode::set_restitution
00189 //       Access: Published
00190 //  Description:
00191 ////////////////////////////////////////////////////////////////////
00192 INLINE void BulletBodyNode::
00193 set_restitution(PN_stdfloat restitution) {
00194 
00195   return get_object()->setRestitution(restitution);
00196 }
00197 
00198 ////////////////////////////////////////////////////////////////////
00199 //     Function: BulletBodyNode::get_friction
00200 //       Access: Published
00201 //  Description:
00202 ////////////////////////////////////////////////////////////////////
00203 INLINE PN_stdfloat BulletBodyNode::
00204 get_friction() const {
00205 
00206   return get_object()->getFriction();
00207 }
00208 
00209 ////////////////////////////////////////////////////////////////////
00210 //     Function: BulletBodyNode::set_friction
00211 //       Access: Published
00212 //  Description:
00213 ////////////////////////////////////////////////////////////////////
00214 INLINE void BulletBodyNode::
00215 set_friction(PN_stdfloat friction) {
00216 
00217   return get_object()->setFriction(friction);
00218 }
00219 
00220 ////////////////////////////////////////////////////////////////////
00221 //     Function: BulletBodyNode::has_anisotropic_friction
00222 //       Access: Published
00223 //  Description:
00224 ////////////////////////////////////////////////////////////////////
00225 INLINE bool BulletBodyNode::
00226 has_anisotropic_friction() const {
00227 
00228   return get_object()->hasAnisotropicFriction();
00229 }
00230 
00231 ////////////////////////////////////////////////////////////////////
00232 //     Function: BulletBodyNode::get_num_shapes
00233 //       Access: Published
00234 //  Description:
00235 ////////////////////////////////////////////////////////////////////
00236 INLINE int BulletBodyNode::
00237 get_num_shapes() const {
00238 
00239   return _shapes.size();
00240 }
00241 
00242 ////////////////////////////////////////////////////////////////////
00243 //     Function: BulletBodyNode::get_shape
00244 //       Access: Published
00245 //  Description:
00246 ////////////////////////////////////////////////////////////////////
00247 INLINE BulletShape *BulletBodyNode::
00248 get_shape(int idx) const {
00249 
00250   nassertr(idx >= 0 && idx < (int)_shapes.size(), NULL);
00251   return _shapes[idx];
00252 }
00253 
00254 ////////////////////////////////////////////////////////////////////
00255 //     Function: BulletBodyNode::set_debug_enabled
00256 //       Access: Published
00257 //  Description: Enables or disables the debug visualisation for
00258 //               this collision object. By default the debug 
00259 //               visualisation is enabled.
00260 ////////////////////////////////////////////////////////////////////
00261 INLINE void BulletBodyNode::
00262 set_debug_enabled(const bool enabled) {
00263 
00264   set_collision_flag(btCollisionObject::CF_DISABLE_VISUALIZE_OBJECT, !enabled);
00265 }
00266 
00267 ////////////////////////////////////////////////////////////////////
00268 //     Function: BulletBodyNode::is_debug_enabled
00269 //       Access: Published
00270 //  Description: Returns TRUE if the debug visualisation is enabled
00271 //               for this collision object, and FALSE if the debug
00272 //               visualisation is disabled.
00273 ////////////////////////////////////////////////////////////////////
00274 INLINE bool BulletBodyNode::
00275 is_debug_enabled() const {
00276 
00277   return !get_collision_flag(btCollisionObject::CF_DISABLE_VISUALIZE_OBJECT);
00278 }
00279 
 All Classes Functions Variables Enumerations