00001 // Filename: collisionNode.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: CollisionNode::set_collide_mask 00018 // Access: Published 00019 // Description: Simultaneously sets both the "from" and "into" 00020 // CollideMask values to the same thing. 00021 //////////////////////////////////////////////////////////////////// 00022 INLINE void CollisionNode:: 00023 set_collide_mask(CollideMask mask) { 00024 set_from_collide_mask(mask); 00025 set_into_collide_mask(mask); 00026 } 00027 00028 //////////////////////////////////////////////////////////////////// 00029 // Function: CollisionNode::set_into_collide_mask 00030 // Access: Published 00031 // Description: Sets the "into" CollideMask. In order for a 00032 // collision to be detected from another object into 00033 // this object, the intersection of the other object's 00034 // "from" mask and this object's "into" mask must be 00035 // nonzero. 00036 //////////////////////////////////////////////////////////////////// 00037 INLINE void CollisionNode:: 00038 set_into_collide_mask(CollideMask mask) { 00039 // This is now inherited from the PandaNode base class. 00040 PandaNode::set_into_collide_mask(mask); 00041 } 00042 00043 //////////////////////////////////////////////////////////////////// 00044 // Function: CollisionNode::get_from_collide_mask 00045 // Access: Published 00046 // Description: Returns the current "from" CollideMask. In order for 00047 // a collision to be detected from this object into 00048 // another object, the intersection of this object's 00049 // "from" mask and the other object's "into" mask must 00050 // be nonzero. 00051 //////////////////////////////////////////////////////////////////// 00052 INLINE CollideMask CollisionNode:: 00053 get_from_collide_mask() const { 00054 return _from_collide_mask; 00055 } 00056 00057 //////////////////////////////////////////////////////////////////// 00058 // Function: CollisionNode::get_into_collide_mask 00059 // Access: Published 00060 // Description: Returns the current "into" CollideMask. In order for 00061 // a collision to be detected from another object into 00062 // this object, the intersection of the other object's 00063 // "from" mask and this object's "into" mask must be 00064 // nonzero. 00065 //////////////////////////////////////////////////////////////////// 00066 INLINE CollideMask CollisionNode:: 00067 get_into_collide_mask() const { 00068 // This is now inherited from the PandaNode base class. 00069 return PandaNode::get_into_collide_mask(); 00070 } 00071 00072 //////////////////////////////////////////////////////////////////// 00073 // Function: CollisionNode::clear_solids 00074 // Access: Published 00075 // Description: Removes all solids from the node. 00076 //////////////////////////////////////////////////////////////////// 00077 INLINE void CollisionNode:: 00078 clear_solids() { 00079 _solids.clear(); 00080 mark_internal_bounds_stale(); 00081 } 00082 00083 //////////////////////////////////////////////////////////////////// 00084 // Function: CollisionNode::get_num_solids 00085 // Access: Published 00086 // Description: 00087 //////////////////////////////////////////////////////////////////// 00088 INLINE int CollisionNode:: 00089 get_num_solids() const { 00090 return _solids.size(); 00091 } 00092 00093 //////////////////////////////////////////////////////////////////// 00094 // Function: CollisionNode::get_solid 00095 // Access: Published 00096 // Description: 00097 //////////////////////////////////////////////////////////////////// 00098 INLINE CPT(CollisionSolid) CollisionNode:: 00099 get_solid(int n) const { 00100 nassertr(n >= 0 && n < get_num_solids(), NULL); 00101 return _solids[n].get_read_pointer(); 00102 } 00103 00104 //////////////////////////////////////////////////////////////////// 00105 // Function: CollisionNode::modify_solid 00106 // Access: Published 00107 // Description: 00108 //////////////////////////////////////////////////////////////////// 00109 INLINE PT(CollisionSolid) CollisionNode:: 00110 modify_solid(int n) { 00111 nassertr(n >= 0 && n < get_num_solids(), NULL); 00112 mark_internal_bounds_stale(); 00113 return _solids[n].get_write_pointer(); 00114 } 00115 00116 //////////////////////////////////////////////////////////////////// 00117 // Function: CollisionNode::set_solid 00118 // Access: Published 00119 // Description: Replaces the solid with the indicated index. 00120 //////////////////////////////////////////////////////////////////// 00121 INLINE void CollisionNode:: 00122 set_solid(int n, CollisionSolid *solid) { 00123 nassertv(n >= 0 && n < get_num_solids()); 00124 _solids[n] = solid; 00125 mark_internal_bounds_stale(); 00126 } 00127 00128 //////////////////////////////////////////////////////////////////// 00129 // Function: CollisionNode::remove_solid 00130 // Access: Published 00131 // Description: Removes the solid with the indicated index. This 00132 // will shift all subsequent indices down by one. 00133 //////////////////////////////////////////////////////////////////// 00134 INLINE void CollisionNode:: 00135 remove_solid(int n) { 00136 nassertv(n >= 0 && n < get_num_solids()); 00137 _solids.erase(_solids.begin() + n); 00138 mark_internal_bounds_stale(); 00139 } 00140 00141 //////////////////////////////////////////////////////////////////// 00142 // Function: CollisionNode::add_solid 00143 // Access: Published 00144 // Description: Adds the indicated solid to the node. Returns the 00145 // index of the new solid within the node's list of 00146 // solids. 00147 //////////////////////////////////////////////////////////////////// 00148 INLINE int CollisionNode:: 00149 add_solid(const CollisionSolid *solid) { 00150 _solids.push_back((CollisionSolid *)solid); 00151 mark_internal_bounds_stale(); 00152 return _solids.size() - 1; 00153 } 00154 00155 //////////////////////////////////////////////////////////////////// 00156 // Function: CollisionNode::get_collider_sort 00157 // Access: Published 00158 // Description: Returns the collider_sort value that has been set for 00159 // this particular node. See set_collider_sort(). 00160 //////////////////////////////////////////////////////////////////// 00161 INLINE int CollisionNode:: 00162 get_collider_sort() const { 00163 return _collider_sort; 00164 } 00165 00166 //////////////////////////////////////////////////////////////////// 00167 // Function: CollisionNode::set_collider_sort 00168 // Access: Published 00169 // Description: Sets a particular collider_sort value on this node. 00170 // This controls the order in which colliders (that is, 00171 // "from nodes") are grouped together for the collision 00172 // traversal. 00173 // 00174 // If there are 32 or fewer colliders added to any 00175 // particular CollisionTraverser, then this value has no 00176 // meaning. It is only useful if there are many 00177 // colliders, which may force the CollisionTraverser to 00178 // make multiple passes through the data; in that case, 00179 // it may be a useful optimization to group colliders 00180 // that have similar bounding volumes together (by 00181 // giving them similar sort values). 00182 //////////////////////////////////////////////////////////////////// 00183 INLINE void CollisionNode:: 00184 set_collider_sort(int sort) { 00185 _collider_sort = sort; 00186 } 00187 00188 //////////////////////////////////////////////////////////////////// 00189 // Function: CollisionNode::get_default_collide_mask 00190 // Access: Published, Static 00191 // Description: Returns the default into_collide_mask assigned to new 00192 // CollisionNodes. 00193 //////////////////////////////////////////////////////////////////// 00194 INLINE CollideMask CollisionNode:: 00195 get_default_collide_mask() { 00196 return default_collision_node_collide_mask; 00197 }