Panda3D
|
00001 // Filename: collisionLevelState.h 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 #ifndef COLLISIONLEVELSTATE_H 00016 #define COLLISIONLEVELSTATE_H 00017 00018 #include "pandabase.h" 00019 00020 #include "collisionLevelStateBase.h" 00021 #include "collisionNode.h" 00022 #include "bitMask.h" 00023 #include "doubleBitMask.h" 00024 00025 //////////////////////////////////////////////////////////////////// 00026 // Class : CollisionLevelState 00027 // Description : This is the state information the 00028 // CollisionTraverser retains for each level during 00029 // traversal. 00030 // 00031 // This is the template class that specifies the 00032 // CurrentMask type: the type of bitmask that is used to 00033 // keep track of the set of active colliders for each 00034 // node. 00035 //////////////////////////////////////////////////////////////////// 00036 template<class MaskType> 00037 class CollisionLevelState : public CollisionLevelStateBase { 00038 public: 00039 // By hiding this template from interrogate, we improve compile-time 00040 // speed and memory utilization. 00041 #ifndef CPPPARSER 00042 INLINE CollisionLevelState(const NodePath &node_path); 00043 INLINE CollisionLevelState(const CollisionLevelState<MaskType> &parent, 00044 PandaNode *child); 00045 INLINE CollisionLevelState(const CollisionLevelState<MaskType> ©); 00046 INLINE void operator = (const CollisionLevelState<MaskType> ©); 00047 00048 INLINE void clear(); 00049 INLINE void prepare_collider(const ColliderDef &def, const NodePath &root); 00050 00051 bool any_in_bounds(); 00052 bool apply_transform(); 00053 00054 INLINE static bool has_max_colliders(); 00055 INLINE static int get_max_colliders(); 00056 00057 INLINE bool has_collider(int n) const; 00058 INLINE bool has_any_collider() const; 00059 00060 INLINE void omit_collider(int n); 00061 00062 private: 00063 // CurrentMask here is a locally-defined value that simply serves 00064 // to keep track of the colliders that are still interested in the 00065 // current node. Don't confuse it with CollideMask, which is a set 00066 // of user-defined bits that specify which CollisionSolids may 00067 // possibly intersect with each other. 00068 typedef MaskType CurrentMask; 00069 CurrentMask _current; 00070 00071 friend class CollisionTraverser; 00072 #endif // CPPPARSER 00073 }; 00074 00075 #include "collisionLevelState.I" 00076 00077 // Now instantiate a handful of implementations of CollisionLevelState: 00078 // one that uses a word-at-a-time bitmask to track the active 00079 // colliders, and a couple that use more words at a time. 00080 00081 typedef CollisionLevelState<BitMaskNative> CollisionLevelStateSingle; 00082 typedef CollisionLevelState<DoubleBitMaskNative> CollisionLevelStateDouble; 00083 typedef CollisionLevelState<QuadBitMaskNative> CollisionLevelStateQuad; 00084 00085 #endif 00086 00087