collisionLevelState.h 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. // Filename: collisionLevelState.h
  2. // Created by: drose (16Mar02)
  3. //
  4. ////////////////////////////////////////////////////////////////////
  5. //
  6. // PANDA 3D SOFTWARE
  7. // Copyright (c) Carnegie Mellon University. All rights reserved.
  8. //
  9. // All use of this software is subject to the terms of the revised BSD
  10. // license. You should have received a copy of this license along
  11. // with this source code in a file named "LICENSE."
  12. //
  13. ////////////////////////////////////////////////////////////////////
  14. #ifndef COLLISIONLEVELSTATE_H
  15. #define COLLISIONLEVELSTATE_H
  16. #include "pandabase.h"
  17. #include "collisionLevelStateBase.h"
  18. #include "collisionNode.h"
  19. #include "bitMask.h"
  20. #include "doubleBitMask.h"
  21. ////////////////////////////////////////////////////////////////////
  22. // Class : CollisionLevelState
  23. // Description : This is the state information the
  24. // CollisionTraverser retains for each level during
  25. // traversal.
  26. //
  27. // This is the template class that specifies the
  28. // CurrentMask type: the type of bitmask that is used to
  29. // keep track of the set of active colliders for each
  30. // node.
  31. ////////////////////////////////////////////////////////////////////
  32. template<class MaskType>
  33. class CollisionLevelState : public CollisionLevelStateBase {
  34. public:
  35. // By hiding this template from interrogate, we improve compile-time
  36. // speed and memory utilization.
  37. #ifndef CPPPARSER
  38. INLINE CollisionLevelState(const NodePath &node_path);
  39. INLINE CollisionLevelState(const CollisionLevelState<MaskType> &parent,
  40. PandaNode *child);
  41. INLINE CollisionLevelState(const CollisionLevelState<MaskType> &copy);
  42. INLINE void operator = (const CollisionLevelState<MaskType> &copy);
  43. INLINE void clear();
  44. INLINE void prepare_collider(const ColliderDef &def, const NodePath &root);
  45. bool any_in_bounds();
  46. bool apply_transform();
  47. INLINE static bool has_max_colliders();
  48. INLINE static int get_max_colliders();
  49. INLINE bool has_collider(int n) const;
  50. INLINE bool has_any_collider() const;
  51. INLINE void omit_collider(int n);
  52. private:
  53. // CurrentMask here is a locally-defined value that simply serves
  54. // to keep track of the colliders that are still interested in the
  55. // current node. Don't confuse it with CollideMask, which is a set
  56. // of user-defined bits that specify which CollisionSolids may
  57. // possibly intersect with each other.
  58. typedef MaskType CurrentMask;
  59. CurrentMask _current;
  60. friend class CollisionTraverser;
  61. #endif // CPPPARSER
  62. };
  63. #include "collisionLevelState.I"
  64. // Now instantiate a handful of implementations of CollisionLevelState:
  65. // one that uses a word-at-a-time bitmask to track the active
  66. // colliders, and a couple that use more words at a time.
  67. typedef CollisionLevelState<BitMaskNative> CollisionLevelStateSingle;
  68. typedef CollisionLevelState<DoubleBitMaskNative> CollisionLevelStateDouble;
  69. typedef CollisionLevelState<QuadBitMaskNative> CollisionLevelStateQuad;
  70. #endif