Main Page   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members   File Members  

panda/src/collide/collisionNode.I

Go to the documentation of this file.
00001 // Filename: collisionNode.I
00002 // Created by:  drose (16Mar02)
00003 //
00004 ////////////////////////////////////////////////////////////////////
00005 //
00006 // PANDA 3D SOFTWARE
00007 // Copyright (c) 2001, Disney Enterprises, Inc.  All rights reserved
00008 //
00009 // All use of this software is subject to the terms of the Panda 3d
00010 // Software license.  You should have received a copy of this license
00011 // along with this source code; you will also find a current copy of
00012 // the license at http://www.panda3d.org/license.txt .
00013 //
00014 // To contact the maintainers of this program write to
00015 // panda3d@yahoogroups.com .
00016 //
00017 ////////////////////////////////////////////////////////////////////
00018 
00019 
00020 ////////////////////////////////////////////////////////////////////
00021 //     Function: CollisionNode::set_collide_mask
00022 //       Access: Published
00023 //  Description: Simultaneously sets both the "from" and "into"
00024 //               CollideMask values to the same thing.
00025 ////////////////////////////////////////////////////////////////////
00026 INLINE void CollisionNode::
00027 set_collide_mask(CollideMask mask) {
00028   set_from_collide_mask(mask);
00029   set_into_collide_mask(mask);
00030 }
00031 
00032 ////////////////////////////////////////////////////////////////////
00033 //     Function: CollisionNode::set_from_collide_mask
00034 //       Access: Published
00035 //  Description: Sets the "from" CollideMask.  In order for a
00036 //               collision to be detected from this object into
00037 //               another object, the intersection of this object's
00038 //               "from" mask and the other object's "into" mask must
00039 //               be nonzero.
00040 ////////////////////////////////////////////////////////////////////
00041 INLINE void CollisionNode::
00042 set_from_collide_mask(CollideMask mask) {
00043   _from_collide_mask = mask;
00044 }
00045 
00046 ////////////////////////////////////////////////////////////////////
00047 //     Function: CollisionNode::set_into_collide_mask
00048 //       Access: Published
00049 //  Description: Sets the "into" CollideMask.  In order for a
00050 //               collision to be detected from another object into
00051 //               this object, the intersection of the other object's
00052 //               "from" mask and this object's "into" mask must be
00053 //               nonzero.
00054 ////////////////////////////////////////////////////////////////////
00055 INLINE void CollisionNode::
00056 set_into_collide_mask(CollideMask mask) {
00057   _into_collide_mask = mask;
00058 
00059   // We mark the bound stale when this changes, not because the actual
00060   // bounding volume changes, but rather because we piggyback the
00061   // computing of the _net_collide_mask on the bounding volume.
00062   mark_bound_stale();
00063 }
00064 
00065 ////////////////////////////////////////////////////////////////////
00066 //     Function: CollisionNode::get_from_collide_mask
00067 //       Access: Published
00068 //  Description: Returns the current "from" CollideMask.  In order for
00069 //               a collision to be detected from this object into
00070 //               another object, the intersection of this object's
00071 //               "from" mask and the other object's "into" mask must
00072 //               be nonzero.
00073 ////////////////////////////////////////////////////////////////////
00074 INLINE CollideMask CollisionNode::
00075 get_from_collide_mask() const {
00076   return _from_collide_mask;
00077 }
00078 
00079 ////////////////////////////////////////////////////////////////////
00080 //     Function: CollisionNode::get_into_collide_mask
00081 //       Access: Published
00082 //  Description: Returns the current "into" CollideMask.  In order for
00083 //               a collision to be detected from another object into
00084 //               this object, the intersection of the other object's
00085 //               "from" mask and this object's "into" mask must be
00086 //               nonzero.
00087 ////////////////////////////////////////////////////////////////////
00088 INLINE CollideMask CollisionNode::
00089 get_into_collide_mask() const {
00090   return _into_collide_mask;
00091 }
00092 
00093 ////////////////////////////////////////////////////////////////////
00094 //     Function: CollisionNode::set_collide_geom
00095 //       Access: Published
00096 //  Description: Sets the state of the "collide geom" flag for this
00097 //               CollisionNode.  Normally, this is false; when this is
00098 //               set true, the CollisionSolids in this node will test
00099 //               for collisions with actual renderable geometry, in
00100 //               addition to whatever CollisionSolids may be indicated
00101 //               by the from_collide_mask.
00102 //
00103 //               Setting this to true causes this to test *all*
00104 //               GeomNodes for collisions.  It is an all-or-none
00105 //               thing; there is no way to collide with only some
00106 //               GeomNodes, as GeomNodes have no into_collide_mask.
00107 ////////////////////////////////////////////////////////////////////
00108 INLINE void CollisionNode::
00109 set_collide_geom(bool flag) {
00110   if (flag) {
00111     _flags |= F_collide_geom;
00112   } else {
00113     _flags &= ~F_collide_geom;
00114   }
00115 }
00116 
00117 ////////////////////////////////////////////////////////////////////
00118 //     Function: CollisionNode::get_collide_geom
00119 //       Access: Published
00120 //  Description: Returns the current state of the collide_geom flag.
00121 //               See set_collide_geom().
00122 ////////////////////////////////////////////////////////////////////
00123 INLINE bool CollisionNode::
00124 get_collide_geom() const {
00125   return (_flags & F_collide_geom) != 0;
00126 }
00127 
00128 ////////////////////////////////////////////////////////////////////
00129 //     Function: CollisionNode::get_num_solids
00130 //       Access: Published
00131 //  Description:
00132 ////////////////////////////////////////////////////////////////////
00133 INLINE int CollisionNode::
00134 get_num_solids() const {
00135   return _solids.size();
00136 }
00137 
00138 ////////////////////////////////////////////////////////////////////
00139 //     Function: CollisionNode::get_solid
00140 //       Access: Published
00141 //  Description:
00142 ////////////////////////////////////////////////////////////////////
00143 INLINE CollisionSolid *CollisionNode::
00144 get_solid(int n) const {
00145   nassertr(n >= 0 && n < get_num_solids(), NULL);
00146   return _solids[n];
00147 }
00148 
00149 ////////////////////////////////////////////////////////////////////
00150 //     Function: CollisionNode::remove_solid
00151 //       Access: Published
00152 //  Description: Removes the solid with the indicated index.  This
00153 //               will shift all subsequent indices down by one.
00154 ////////////////////////////////////////////////////////////////////
00155 INLINE void CollisionNode::
00156 remove_solid(int n) {
00157   nassertv(n >= 0 && n < get_num_solids());
00158   _solids.erase(_solids.begin() + n);
00159   mark_bound_stale();
00160 }
00161 
00162 ////////////////////////////////////////////////////////////////////
00163 //     Function: CollisionNode::add_solid
00164 //       Access: Published
00165 //  Description: Adds the indicated solid to the node.  Returns the
00166 //               index of the new solid within the node's list of
00167 //               solids.
00168 ////////////////////////////////////////////////////////////////////
00169 INLINE int CollisionNode::
00170 add_solid(CollisionSolid *solid) {
00171   _solids.push_back(solid);
00172   mark_bound_stale();
00173   return _solids.size() - 1;
00174 }
00175 
00176 ////////////////////////////////////////////////////////////////////
00177 //     Function: CollisionNode::clear_velocity
00178 //       Access: Published
00179 //  Description: Removes the velocity information associated with the
00180 //               node.  See set_velocity().
00181 ////////////////////////////////////////////////////////////////////
00182 INLINE void CollisionNode::
00183 clear_velocity() {
00184   _flags &= ~F_has_velocity;
00185 }
00186 
00187 ////////////////////////////////////////////////////////////////////
00188 //     Function: CollisionNode::has_velocity
00189 //       Access: Published
00190 //  Description: Returns true if the node has an associated velocity,
00191 //               false otherwise.  See set_velocity().
00192 ////////////////////////////////////////////////////////////////////
00193 INLINE bool CollisionNode::
00194 has_velocity() const {
00195   return (_flags & F_has_velocity) != 0;
00196 }
00197 
00198 ////////////////////////////////////////////////////////////////////
00199 //     Function: CollisionNode::get_velocity
00200 //       Access: Published
00201 //  Description: Returns the instantaneous velocity of the node, in
00202 //               its own coordinate space.  This represents the delta
00203 //               between its current position and its position last
00204 //               frame.  See set_velocity().
00205 ////////////////////////////////////////////////////////////////////
00206 INLINE const LVector3f &CollisionNode::
00207 get_velocity() const {
00208   nassertr(has_velocity(), _velocity);
00209   return _velocity;
00210 }

Generated on Fri May 2 00:35:37 2003 for Panda by doxygen1.3