00001 // Filename: collisionHandlerPhysical.I 00002 // Created by: drose (16Mar02) 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: CollisionHandlerPhysical::set_center 00018 // Access: Published 00019 // Description: Specifies an arbitrary NodePath that the handler is 00020 // always considered to be facing. It does not detect 00021 // collisions with surfaces that appear to be facing 00022 // away from this NodePath. This works best when the 00023 // collision surfaces in question are polygons. 00024 //////////////////////////////////////////////////////////////////// 00025 INLINE void CollisionHandlerPhysical:: 00026 set_center(const NodePath ¢er) { 00027 _center = center; 00028 } 00029 00030 //////////////////////////////////////////////////////////////////// 00031 // Function: CollisionHandlerPhysical::clear_center 00032 // Access: Published 00033 // Description: Clears the center NodePath specified with set_center. 00034 //////////////////////////////////////////////////////////////////// 00035 INLINE void CollisionHandlerPhysical:: 00036 clear_center() { 00037 _center = NodePath(); 00038 } 00039 00040 //////////////////////////////////////////////////////////////////// 00041 // Function: CollisionHandlerPhysical::get_center 00042 // Access: Published 00043 // Description: Returns the NodePath specified with set_center, or 00044 // the empty NodePath if nothing has been specified. 00045 //////////////////////////////////////////////////////////////////// 00046 INLINE const NodePath &CollisionHandlerPhysical:: 00047 get_center() const { 00048 return _center; 00049 } 00050 00051 //////////////////////////////////////////////////////////////////// 00052 // Function: CollisionHandlerPhysical::has_center 00053 // Access: Published 00054 // Description: Returns true if a NodePath has been specified with 00055 // set_center(), false otherwise. 00056 //////////////////////////////////////////////////////////////////// 00057 INLINE bool CollisionHandlerPhysical:: 00058 has_center() const { 00059 return !_center.is_empty(); 00060 } 00061 00062 //////////////////////////////////////////////////////////////////// 00063 // Function: CollisionHandlerPhysical::has_contact 00064 // Access: Public 00065 // Description: Did the handler make any contacts with anything 00066 // on the last collision pass? Depending on how your 00067 // world is setup, this can be used to tell if the 00068 // handler is out of the world (i.e. out of bounds). 00069 // That is the original use of this call. 00070 //////////////////////////////////////////////////////////////////// 00071 INLINE bool CollisionHandlerPhysical:: 00072 has_contact() const { 00073 return _has_contact; 00074 } 00075 00076 //////////////////////////////////////////////////////////////////// 00077 // Function: CollisionHandlerPhysical::ColliderDef::set_target 00078 // Access: Public 00079 // Description: 00080 //////////////////////////////////////////////////////////////////// 00081 INLINE void CollisionHandlerPhysical::ColliderDef:: 00082 set_target(const NodePath &target, DriveInterface *drive_interface) { 00083 _target = target; 00084 _drive_interface = drive_interface; 00085 } 00086 00087 //////////////////////////////////////////////////////////////////// 00088 // Function: CollisionHandlerPhysical::ColliderDef::updated_transform 00089 // Access: Public 00090 // Description: Called by the handler when it has changed the 00091 // transform on the target node, this applies the change 00092 // to the drive interface if one is specified. 00093 //////////////////////////////////////////////////////////////////// 00094 INLINE void CollisionHandlerPhysical::ColliderDef:: 00095 updated_transform() { 00096 if (_drive_interface != (DriveInterface *)NULL) { 00097 _drive_interface->set_mat(_target.get_mat()); 00098 _drive_interface->force_dgraph(); 00099 } 00100 }