Panda3D
 All Classes Functions Variables Enumerations
collisionLevelStateBase.I
00001 // Filename: collisionLevelStateBase.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: CollisionLevelStateBase::Constructor
00018 //       Access: Public
00019 //  Description:
00020 ////////////////////////////////////////////////////////////////////
00021 INLINE CollisionLevelStateBase::
00022 CollisionLevelStateBase(const NodePath &node_path) :
00023   _node_path(node_path),
00024   _colliders(get_class_type()),
00025   _include_mask(CollideMask::all_on())
00026 {
00027 }
00028 
00029 ////////////////////////////////////////////////////////////////////
00030 //     Function: CollisionLevelStateBase::Constructor
00031 //       Access: Public
00032 //  Description: This constructor goes to the next child node in the
00033 //               traversal.
00034 ////////////////////////////////////////////////////////////////////
00035 INLINE CollisionLevelStateBase::
00036 CollisionLevelStateBase(const CollisionLevelStateBase &parent, PandaNode *child) :
00037   _node_path(parent._node_path, child),
00038   _colliders(parent._colliders),
00039   _include_mask(parent._include_mask),
00040   _local_bounds(parent._local_bounds)
00041 {
00042 }
00043 
00044 ////////////////////////////////////////////////////////////////////
00045 //     Function: CollisionLevelStateBase::Copy Constructor
00046 //       Access: Public
00047 //  Description: 
00048 ////////////////////////////////////////////////////////////////////
00049 INLINE CollisionLevelStateBase::
00050 CollisionLevelStateBase(const CollisionLevelStateBase &copy) :
00051   _node_path(copy._node_path),
00052   _colliders(copy._colliders),
00053   _include_mask(copy._include_mask),
00054   _local_bounds(copy._local_bounds),
00055   _parent_bounds(copy._parent_bounds)
00056 {
00057 }
00058 
00059 ////////////////////////////////////////////////////////////////////
00060 //     Function: CollisionLevelStateBase::Copy Assignment Operator
00061 //       Access: Public
00062 //  Description: 
00063 ////////////////////////////////////////////////////////////////////
00064 INLINE void CollisionLevelStateBase::
00065 operator = (const CollisionLevelStateBase &copy) {
00066   _node_path = copy._node_path;
00067   _colliders = copy._colliders;
00068   _include_mask = copy._include_mask;
00069   _local_bounds = copy._local_bounds;
00070   _parent_bounds = copy._parent_bounds;
00071 }
00072 
00073 ////////////////////////////////////////////////////////////////////
00074 //     Function: CollisionLevelStateBase::get_node_path
00075 //       Access: Public
00076 //  Description: Returns the NodePath representing the node instance
00077 //               we have traversed to.
00078 ////////////////////////////////////////////////////////////////////
00079 INLINE NodePath CollisionLevelStateBase::
00080 get_node_path() const {
00081   return _node_path.get_node_path();
00082 }
00083 
00084 ////////////////////////////////////////////////////////////////////
00085 //     Function: CollisionLevelStateBase::node
00086 //       Access: Public
00087 //  Description: Returns the PandaNode pointer of the node we have
00088 //               traversed to.
00089 ////////////////////////////////////////////////////////////////////
00090 INLINE PandaNode *CollisionLevelStateBase::
00091 node() const {
00092   return _node_path.node();
00093 }
00094 
00095 ////////////////////////////////////////////////////////////////////
00096 //     Function: CollisionLevelStateBase::get_num_colliders
00097 //       Access: Public
00098 //  Description:
00099 ////////////////////////////////////////////////////////////////////
00100 INLINE int CollisionLevelStateBase::
00101 get_num_colliders() const {
00102   return _colliders.size();
00103 }
00104 
00105 ////////////////////////////////////////////////////////////////////
00106 //     Function: CollisionLevelStateBase::get_collider
00107 //       Access: Public
00108 //  Description:
00109 ////////////////////////////////////////////////////////////////////
00110 INLINE const CollisionSolid *CollisionLevelStateBase::
00111 get_collider(int n) const {
00112   nassertr(n >= 0 && n < (int)_colliders.size(), NULL);
00113 
00114   return _colliders[n]._collider;
00115 }
00116 
00117 ////////////////////////////////////////////////////////////////////
00118 //     Function: CollisionLevelStateBase::get_collider_node
00119 //       Access: Public
00120 //  Description:
00121 ////////////////////////////////////////////////////////////////////
00122 INLINE CollisionNode *CollisionLevelStateBase::
00123 get_collider_node(int n) const {
00124   nassertr(n >= 0 && n < (int)_colliders.size(), NULL);
00125 
00126   return _colliders[n]._node;
00127 }
00128 
00129 ////////////////////////////////////////////////////////////////////
00130 //     Function: CollisionLevelStateBase::get_collider_node_path
00131 //       Access: Public
00132 //  Description:
00133 ////////////////////////////////////////////////////////////////////
00134 INLINE NodePath CollisionLevelStateBase::
00135 get_collider_node_path(int n) const {
00136   nassertr(n >= 0 && n < (int)_colliders.size(), NodePath::fail());
00137 
00138   return _colliders[n]._node_path;
00139 }
00140 
00141 ////////////////////////////////////////////////////////////////////
00142 //     Function: CollisionLevelStateBase::get_local_bound
00143 //       Access: Public
00144 //  Description: Returns the bounding volume of the indicated
00145 //               collider, transformed into the current node's
00146 //               transform space.
00147 ////////////////////////////////////////////////////////////////////
00148 INLINE const GeometricBoundingVolume *CollisionLevelStateBase::
00149 get_local_bound(int n) const {
00150   nassertr(n >= 0 && n < (int)_colliders.size(), NULL);
00151   nassertr(n >= 0 && n < (int)_local_bounds.size(), NULL);
00152 
00153   // For whatever reason, the Intel compiler can't figure this line
00154   // out.
00155   //return _local_bounds[n];
00156 
00157   // But it can figure out this equivalent line.
00158   return *(_local_bounds + n);
00159 }
00160 
00161 ////////////////////////////////////////////////////////////////////
00162 //     Function: CollisionLevelStateBase::get_parent_bound
00163 //       Access: Public
00164 //  Description: Returns the bounding volume of the indicated
00165 //               collider, transformed into the previous node's
00166 //               transform space, but not transformed by the current
00167 //               node's transform.  This is appropriate for testing
00168 //               against the bounding volume of the current node
00169 //               (which does not have its own transform applied to
00170 //               it).
00171 ////////////////////////////////////////////////////////////////////
00172 INLINE const GeometricBoundingVolume *CollisionLevelStateBase::
00173 get_parent_bound(int n) const {
00174   nassertr(n >= 0 && n < (int)_colliders.size(), NULL);
00175   nassertr(n >= 0 && n < (int)_parent_bounds.size(), NULL);
00176 
00177   // But it can figure out this equivalent line.
00178   return *(_parent_bounds + n);
00179 }
00180 
00181 ////////////////////////////////////////////////////////////////////
00182 //     Function: CollisionLevelStateBase::set_include_mask
00183 //       Access: Public
00184 //  Description: Specifies the mask that is applied to the into
00185 //               CollideMask of nodes in the scene graph before
00186 //               testing for bits in common with the from CollideMask
00187 //               of colliders.  This is normally all bits on, but you
00188 //               may set it to some other mask to restrict certain
00189 //               bits from consideration.
00190 //
00191 //               This is used by the CollisionTraverser to restrict
00192 //               collision with geometry except under the lowest level
00193 //               of LOD.
00194 ////////////////////////////////////////////////////////////////////
00195 INLINE void CollisionLevelStateBase::
00196 set_include_mask(CollideMask include_mask) {
00197   _include_mask = include_mask;
00198 }
00199 
00200 
00201 ////////////////////////////////////////////////////////////////////
00202 //     Function: CollisionLevelStateBase::get_include_mask
00203 //       Access: Public
00204 //  Description: Returns the mask that is applied to the into
00205 //               CollideMask of nodes in the scene graph before
00206 //               testing for bits in common with the from CollideMask
00207 //               of colliders.  See set_include_mask().
00208 ////////////////////////////////////////////////////////////////////
00209 INLINE CollideMask CollisionLevelStateBase::
00210 get_include_mask() const {
00211   return _include_mask;
00212 }
 All Classes Functions Variables Enumerations