Panda3D
collisionLevelStateBase.I
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.I
10  * @author drose
11  * @date 2002-03-16
12  */
13 
14 /**
15  *
16  */
17 INLINE CollisionLevelStateBase::
18 CollisionLevelStateBase(const NodePath &node_path) :
19  _node_path(node_path),
20  _colliders(get_class_type()),
21  _include_mask(CollideMask::all_on())
22 {
23 }
24 
25 /**
26  * This constructor goes to the next child node in the traversal.
27  */
28 INLINE CollisionLevelStateBase::
29 CollisionLevelStateBase(const CollisionLevelStateBase &parent, PandaNode *child) :
30  _node_path(parent._node_path, child),
31  _colliders(parent._colliders),
32  _include_mask(parent._include_mask),
33  _local_bounds(parent._local_bounds)
34 {
35 }
36 
37 /**
38  *
39  */
40 INLINE CollisionLevelStateBase::
41 CollisionLevelStateBase(const CollisionLevelStateBase &copy) :
42  _node_path(copy._node_path),
43  _colliders(copy._colliders),
44  _include_mask(copy._include_mask),
45  _local_bounds(copy._local_bounds),
46  _parent_bounds(copy._parent_bounds)
47 {
48 }
49 
50 /**
51  *
52  */
53 INLINE void CollisionLevelStateBase::
54 operator = (const CollisionLevelStateBase &copy) {
55  _node_path = copy._node_path;
56  _colliders = copy._colliders;
57  _include_mask = copy._include_mask;
58  _local_bounds = copy._local_bounds;
59  _parent_bounds = copy._parent_bounds;
60 }
61 
62 /**
63  * Returns the NodePath representing the node instance we have traversed to.
64  */
66 get_node_path() const {
67  return _node_path.get_node_path();
68 }
69 
70 /**
71  * Returns the PandaNode pointer of the node we have traversed to.
72  */
74 node() const {
75  return _node_path.node();
76 }
77 
78 /**
79  *
80  */
81 INLINE int CollisionLevelStateBase::
82 get_num_colliders() const {
83  return _colliders.size();
84 }
85 
86 /**
87  *
88  */
89 INLINE const CollisionSolid *CollisionLevelStateBase::
90 get_collider(int n) const {
91  nassertr(n >= 0 && n < (int)_colliders.size(), nullptr);
92 
93  return _colliders[n]._collider;
94 }
95 
96 /**
97  *
98  */
99 INLINE CollisionNode *CollisionLevelStateBase::
100 get_collider_node(int n) const {
101  nassertr(n >= 0 && n < (int)_colliders.size(), nullptr);
102 
103  return _colliders[n]._node;
104 }
105 
106 /**
107  *
108  */
109 INLINE NodePath CollisionLevelStateBase::
110 get_collider_node_path(int n) const {
111  nassertr(n >= 0 && n < (int)_colliders.size(), NodePath::fail());
112 
113  return _colliders[n]._node_path;
114 }
115 
116 /**
117  * Returns the bounding volume of the indicated collider, transformed into the
118  * current node's transform space.
119  */
121 get_local_bound(int n) const {
122  nassertr(n >= 0 && n < (int)_colliders.size(), nullptr);
123  nassertr(n >= 0 && n < (int)_local_bounds.size(), nullptr);
124 
125  // For whatever reason, the Intel compiler can't figure this line out.
126  // return _local_bounds[n];
127 
128  // But it can figure out this equivalent line.
129  return *(_local_bounds + n);
130 }
131 
132 /**
133  * Returns the bounding volume of the indicated collider, transformed into the
134  * previous node's transform space, but not transformed by the current node's
135  * transform. This is appropriate for testing against the bounding volume of
136  * the current node (which does not have its own transform applied to it).
137  */
139 get_parent_bound(int n) const {
140  nassertr(n >= 0 && n < (int)_colliders.size(), nullptr);
141  nassertr(n >= 0 && n < (int)_parent_bounds.size(), nullptr);
142 
143  // But it can figure out this equivalent line.
144  return *(_parent_bounds + n);
145 }
146 
147 /**
148  * Specifies the mask that is applied to the into CollideMask of nodes in the
149  * scene graph before testing for bits in common with the from CollideMask of
150  * colliders. This is normally all bits on, but you may set it to some other
151  * mask to restrict certain bits from consideration.
152  *
153  * This is used by the CollisionTraverser to restrict collision with geometry
154  * except under the lowest level of LOD.
155  */
156 INLINE void CollisionLevelStateBase::
158  _include_mask = include_mask;
159 }
160 
161 
162 /**
163  * Returns the mask that is applied to the into CollideMask of nodes in the
164  * scene graph before testing for bits in common with the from CollideMask of
165  * colliders. See set_include_mask().
166  */
169  return _include_mask;
170 }
A basic node of the scene graph or data graph.
Definition: pandaNode.h:64
PandaNode * node() const
Returns the node traversed to so far.
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...
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...
This is another abstract class, for a general class of bounding volumes that actually enclose points ...
static NodePath fail()
Creates a NodePath with the ET_fail error type set.
Definition: nodePath.I:149
const GeometricBoundingVolume * get_local_bound(int n) const
Returns the bounding volume of the indicated collider, transformed into the current node's transform ...
get_node_path
Constructs and returns an actual NodePath that represents the same path we have just traversed.
const GeometricBoundingVolume * get_parent_bound(int n) const
Returns the bounding volume of the indicated collider, transformed into the previous node's transform...
A node in the scene graph that can hold any number of CollisionSolids.
Definition: collisionNode.h:30
This is the state information the CollisionTraverser retains for each level during traversal.
A general bitmask class.
Definition: bitMask.h:32
NodePath is the fundamental system for disambiguating instances, and also provides a higher-level int...
Definition: nodePath.h:161
PandaNode * node() const
Returns the PandaNode pointer of the node we have traversed to.