Panda3D
 All Classes Functions Variables Enumerations
collisionLevelStateBase.h
1 // Filename: collisionLevelStateBase.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 COLLISIONLEVELSTATEBASE_H
16 #define COLLISIONLEVELSTATEBASE_H
17 
18 #include "pandabase.h"
19 
20 #include "luse.h"
21 #include "pointerToArray.h"
22 #include "geometricBoundingVolume.h"
23 #include "nodePath.h"
24 #include "workingNodePath.h"
25 #include "pointerTo.h"
26 #include "plist.h"
27 #include "pStatCollector.h"
28 #include "bitMask.h"
29 #include "lvector3.h"
30 #include "register_type.h"
31 #include "collisionSolid.h"
32 
33 
34 class CollisionSolid;
35 class CollisionNode;
36 
37 ////////////////////////////////////////////////////////////////////
38 // Class : CollisionLevelStateBase
39 // Description : This is the state information the
40 // CollisionTraverser retains for each level during
41 // traversal.
42 //
43 // The CollisionLevelStateBase is the non-template base
44 // class. The template version further specifies this
45 // on CurrentMask type.
46 ////////////////////////////////////////////////////////////////////
48 public:
49  class ColliderDef {
50  public:
51  CPT(CollisionSolid) _collider;
52  CollisionNode *_node;
53  NodePath _node_path;
54  };
55 
56  INLINE CollisionLevelStateBase(const NodePath &node_path);
58  PandaNode *child);
60  INLINE void operator = (const CollisionLevelStateBase &copy);
61 
62  void clear();
63  void reserve(int num_colliders);
64  void prepare_collider(const ColliderDef &def, const NodePath &root);
65 
66  INLINE NodePath get_node_path() const;
67  INLINE PandaNode *node() const;
68 
69  INLINE int get_num_colliders() const;
70 
71  INLINE const CollisionSolid *get_collider(int n) const;
72  INLINE CollisionNode *get_collider_node(int n) const;
73  INLINE NodePath get_collider_node_path(int n) const;
74  INLINE const GeometricBoundingVolume *get_local_bound(int n) const;
75  INLINE const GeometricBoundingVolume *get_parent_bound(int n) const;
76 
77  INLINE void set_include_mask(CollideMask include_mask);
78  INLINE CollideMask get_include_mask() const;
79 
80 protected:
81  WorkingNodePath _node_path;
82 
83  typedef PTA(ColliderDef) Colliders;
84  Colliders _colliders;
85  CollideMask _include_mask;
86 
87  typedef PTA(CPT(GeometricBoundingVolume)) BoundingVolumes;
88  BoundingVolumes _local_bounds;
89  BoundingVolumes _parent_bounds;
90 
91  static PStatCollector _node_volume_pcollector;
92 
93 public:
94  static TypeHandle get_class_type() {
95  return _type_handle;
96  }
97  static void init_type() {
98  register_type(_type_handle, "CollisionLevelStateBase");
99  }
100 
101 private:
102  static TypeHandle _type_handle;
103 
104  friend class CollisionTraverser;
105 };
106 
107 #include "collisionLevelStateBase.I"
108 
109 #endif
110 
111 
A basic node of the scene graph or data graph.
Definition: pandaNode.h:72
The abstract base class for all things that can collide with other things in the world, and all the things they can collide with (except geometry).
void set_include_mask(CollideMask include_mask)
Specifies the mask that is applied to the into CollideMask of nodes in the scene graph before testing...
CollideMask get_include_mask() const
Returns the mask that is applied to the into CollideMask of nodes in the scene graph before testing f...
This is a class designed to support low-overhead traversals of the complete scene graph...
A lightweight class that represents a single element that may be timed and/or counted via stats...
This is another abstract class, for a general class of bounding volumes that actually enclose points ...
const GeometricBoundingVolume * get_parent_bound(int n) const
Returns the bounding volume of the indicated collider, transformed into the previous node's transform...
PandaNode * node() const
Returns the PandaNode pointer of the node we have traversed to.
const GeometricBoundingVolume * get_local_bound(int n) const
Returns the bounding volume of the indicated collider, transformed into the current node's transform ...
void reserve(int num_colliders)
Indicates an intention to add the indicated number of colliders to the level state.
NodePath get_node_path() const
Returns the NodePath representing the node instance we have traversed to.
void prepare_collider(const ColliderDef &def, const NodePath &root)
Adds the indicated Collider to the set of Colliders in the current level state.
A node in the scene graph that can hold any number of CollisionSolids.
Definition: collisionNode.h:33
This class manages the traversal through the scene graph to detect collisions.
TypeHandle is the identifier used to differentiate C++ class types.
Definition: typeHandle.h:85
This is the state information the CollisionTraverser retains for each level during traversal...
NodePath is the fundamental system for disambiguating instances, and also provides a higher-level int...
Definition: nodePath.h:165