Panda3D
collisionLevelStateBase.h
Go to the documentation of this file.
1 /**
2  * PANDA 3D SOFTWARE
3  * Copyright (c) Carnegie Mellon University. All rights reserved.
4  *
5  * All use of this software is subject to the terms of the revised BSD
6  * license. You should have received a copy of this license along
7  * with this source code in a file named "LICENSE."
8  *
9  * @file collisionLevelStateBase.h
10  * @author drose
11  * @date 2002-03-16
12  */
13 
14 #ifndef COLLISIONLEVELSTATEBASE_H
15 #define COLLISIONLEVELSTATEBASE_H
16 
17 #include "pandabase.h"
18 
19 #include "luse.h"
20 #include "pointerToArray.h"
22 #include "nodePath.h"
23 #include "workingNodePath.h"
24 #include "pointerTo.h"
25 #include "plist.h"
26 #include "pStatCollector.h"
27 #include "bitMask.h"
28 #include "lvector3.h"
29 #include "register_type.h"
30 #include "collisionSolid.h"
31 
32 
33 class CollisionSolid;
34 class CollisionNode;
35 
36 /**
37  * This is the state information the CollisionTraverser retains for each level
38  * during traversal.
39  *
40  * The CollisionLevelStateBase is the non-template base class. The template
41  * version further specifies this on CurrentMask type.
42  */
44 public:
45  class ColliderDef {
46  public:
47  CPT(CollisionSolid) _collider;
48  CollisionNode *_node;
49  NodePath _node_path;
50  };
51 
52  INLINE CollisionLevelStateBase(const NodePath &node_path);
54  PandaNode *child);
56  INLINE void operator = (const CollisionLevelStateBase &copy);
57 
58  void clear();
59  void reserve(int num_colliders);
60  void prepare_collider(const ColliderDef &def, const NodePath &root);
61 
62  INLINE NodePath get_node_path() const;
63  INLINE PandaNode *node() const;
64 
65  INLINE int get_num_colliders() const;
66 
67  INLINE const CollisionSolid *get_collider(int n) const;
68  INLINE CollisionNode *get_collider_node(int n) const;
69  INLINE NodePath get_collider_node_path(int n) const;
70  INLINE const GeometricBoundingVolume *get_local_bound(int n) const;
71  INLINE const GeometricBoundingVolume *get_parent_bound(int n) const;
72 
73  INLINE void set_include_mask(CollideMask include_mask);
74  INLINE CollideMask get_include_mask() const;
75 
76 protected:
77  WorkingNodePath _node_path;
78 
79  typedef PTA(ColliderDef) Colliders;
80  Colliders _colliders;
81  CollideMask _include_mask;
82 
83  typedef PTA(CPT(GeometricBoundingVolume)) BoundingVolumes;
84  BoundingVolumes _local_bounds;
85  BoundingVolumes _parent_bounds;
86 
87  static PStatCollector _node_volume_pcollector;
88 
89 public:
90  static TypeHandle get_class_type() {
91  return _type_handle;
92  }
93  static void init_type() {
94  register_type(_type_handle, "CollisionLevelStateBase");
95  }
96 
97 private:
98  static TypeHandle _type_handle;
99 
100  friend class CollisionTraverser;
101 };
102 
103 #include "collisionLevelStateBase.I"
104 
105 #endif
A basic node of the scene graph or data graph.
Definition: pandaNode.h:64
NodePath get_node_path() const
Returns the NodePath representing the node instance we have traversed to.
CollideMask get_include_mask() const
Returns the mask that is applied to the into CollideMask of nodes in the scene graph before testing f...
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
The abstract base class for all things that can collide with other things in the world,...
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...
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
void register_type(TypeHandle &type_handle, const std::string &name)
This inline function is just a convenient way to call TypeRegistry::register_type(),...
Definition: register_type.I:22
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
This is a class designed to support low-overhead traversals of the complete scene graph,...
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
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 ...
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
const GeometricBoundingVolume * get_local_bound(int n) const
Returns the bounding volume of the indicated collider, transformed into the current node's transform ...
const GeometricBoundingVolume * get_parent_bound(int n) const
Returns the bounding volume of the indicated collider, transformed into the previous node's transform...
void reserve(int num_colliders)
Indicates an intention to add the indicated number of colliders to the level state.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
void prepare_collider(const ColliderDef &def, const NodePath &root)
Adds the indicated Collider to the set of Colliders in the current level state.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
A node in the scene graph that can hold any number of CollisionSolids.
Definition: collisionNode.h:30
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:81
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:161
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PandaNode * node() const
Returns the PandaNode pointer of the node we have traversed to.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.