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"
21 #include "geometricBoundingVolume.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 */
43 class CollisionLevelStateBase {
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);
53 INLINE CollisionLevelStateBase(const CollisionLevelStateBase &parent,
54 PandaNode *child);
55 INLINE CollisionLevelStateBase(const CollisionLevelStateBase &copy);
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
bitMask.h
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
BitMask< uint32_t, 32 >
CollisionLevelStateBase::ColliderDef
Definition: collisionLevelStateBase.h:45
CollisionLevelStateBase
This is the state information the CollisionTraverser retains for each level during traversal.
Definition: collisionLevelStateBase.h:43
CollisionLevelStateBase::reserve
void reserve(int num_colliders)
Indicates an intention to add the indicated number of colliders to the level state.
Definition: collisionLevelStateBase.cxx:39
CollisionLevelStateBase::get_parent_bound
const GeometricBoundingVolume * get_parent_bound(int n) const
Returns the bounding volume of the indicated collider, transformed into the previous node's transform...
Definition: collisionLevelStateBase.I:139
CollisionLevelStateBase::node
PandaNode * node() const
Returns the PandaNode pointer of the node we have traversed to.
Definition: collisionLevelStateBase.I:74
CollisionLevelStateBase::get_local_bound
const GeometricBoundingVolume * get_local_bound(int n) const
Returns the bounding volume of the indicated collider, transformed into the current node's transform ...
Definition: collisionLevelStateBase.I:121
CollisionLevelStateBase::set_include_mask
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...
Definition: collisionLevelStateBase.I:157
CollisionLevelStateBase::prepare_collider
void prepare_collider(const ColliderDef &def, const NodePath &root)
Adds the indicated Collider to the set of Colliders in the current level state.
Definition: collisionLevelStateBase.cxx:49
CollisionLevelStateBase::get_node_path
NodePath get_node_path() const
Returns the NodePath representing the node instance we have traversed to.
Definition: collisionLevelStateBase.I:66
CollisionLevelStateBase::get_include_mask
CollideMask get_include_mask() const
Returns the mask that is applied to the into CollideMask of nodes in the scene graph before testing f...
Definition: collisionLevelStateBase.I:168
CollisionNode
A node in the scene graph that can hold any number of CollisionSolids.
Definition: collisionNode.h:30
CollisionSolid
The abstract base class for all things that can collide with other things in the world,...
Definition: collisionSolid.h:45
CollisionTraverser
This class manages the traversal through the scene graph to detect collisions.
Definition: collisionTraverser.h:46
GeometricBoundingVolume
This is another abstract class, for a general class of bounding volumes that actually enclose points ...
Definition: geometricBoundingVolume.h:29
NodePath
NodePath is the fundamental system for disambiguating instances, and also provides a higher-level int...
Definition: nodePath.h:159
PStatCollector
A lightweight class that represents a single element that may be timed and/or counted via stats.
Definition: pStatCollector.h:43
PandaNode
A basic node of the scene graph or data graph.
Definition: pandaNode.h:65
TypeHandle
TypeHandle is the identifier used to differentiate C++ class types.
Definition: typeHandle.h:81
WorkingNodePath
This is a class designed to support low-overhead traversals of the complete scene graph,...
Definition: workingNodePath.h:39
collisionLevelStateBase.I
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
collisionSolid.h
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
geometricBoundingVolume.h
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
luse.h
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
lvector3.h
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
nodePath.h
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
pStatCollector.h
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
pandabase.h
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
plist.h
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
pointerToArray.h
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
pointerTo.h
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
register_type.h
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
register_type
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
workingNodePath.h
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.