Panda3D
collisionLevelState.h
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 
15 #ifndef COLLISIONLEVELSTATE_H
16 #define COLLISIONLEVELSTATE_H
17 
18 #include "pandabase.h"
19 
20 #include "collisionLevelStateBase.h"
21 #include "collisionNode.h"
22 #include "bitMask.h"
23 #include "doubleBitMask.h"
24 
25 ////////////////////////////////////////////////////////////////////
26 // Class : CollisionLevelState
27 // Description : This is the state information the
28 // CollisionTraverser retains for each level during
29 // traversal.
30 //
31 // This is the template class that specifies the
32 // CurrentMask type: the type of bitmask that is used to
33 // keep track of the set of active colliders for each
34 // node.
35 ////////////////////////////////////////////////////////////////////
36 template<class MaskType>
38 public:
39  // By hiding this template from interrogate, we improve compile-time
40  // speed and memory utilization.
41 #ifndef CPPPARSER
42  INLINE CollisionLevelState(const NodePath &node_path);
43  INLINE CollisionLevelState(const CollisionLevelState<MaskType> &parent,
44  PandaNode *child);
45  INLINE CollisionLevelState(const CollisionLevelState<MaskType> &copy);
46  INLINE void operator = (const CollisionLevelState<MaskType> &copy);
47 
48  INLINE void clear();
49  INLINE void prepare_collider(const ColliderDef &def, const NodePath &root);
50 
51  bool any_in_bounds();
52  bool apply_transform();
53 
54  INLINE static bool has_max_colliders();
55  INLINE static int get_max_colliders();
56 
57  INLINE bool has_collider(int n) const;
58  INLINE bool has_any_collider() const;
59 
60  INLINE void omit_collider(int n);
61 
62 private:
63  // CurrentMask here is a locally-defined value that simply serves
64  // to keep track of the colliders that are still interested in the
65  // current node. Don't confuse it with CollideMask, which is a set
66  // of user-defined bits that specify which CollisionSolids may
67  // possibly intersect with each other.
68  typedef MaskType CurrentMask;
69  CurrentMask _current;
70 
71  friend class CollisionTraverser;
72 #endif // CPPPARSER
73 };
74 
75 #include "collisionLevelState.I"
76 
77 // Now instantiate a handful of implementations of CollisionLevelState:
78 // one that uses a word-at-a-time bitmask to track the active
79 // colliders, and a couple that use more words at a time.
80 
84 
85 #endif
86 
87 
A basic node of the scene graph or data graph.
Definition: pandaNode.h:72
This is the state information the CollisionTraverser retains for each level during traversal...
bool has_collider(int n) const
Returns true if the nth collider in the LevelState is still part of the level.
bool any_in_bounds()
Checks the bounding volume of the current node against each of our colliders.
void prepare_collider(const ColliderDef &def, const NodePath &root)
Adds the indicated Collider to the set of Colliders in the current level state.
static bool has_max_colliders()
Returns true if there is any the maximum number of colliders that may be added to the CollisionLevelS...
This class manages the traversal through the scene graph to detect collisions.
This is the state information the CollisionTraverser retains for each level during traversal...
bool apply_transform()
Applies the inverse transform from the current node, if any, onto all the colliders in the level stat...
NodePath is the fundamental system for disambiguating instances, and also provides a higher-level int...
Definition: nodePath.h:165
static int get_max_colliders()
Returns the maximum number of colliders that may be added to the CollisionLevelStateBase at any one t...