Panda3D
 All Classes Functions Variables Enumerations
collisionLevelStateBase.I
1 // Filename: collisionLevelStateBase.I
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 
16 ////////////////////////////////////////////////////////////////////
17 // Function: CollisionLevelStateBase::Constructor
18 // Access: Public
19 // Description:
20 ////////////////////////////////////////////////////////////////////
21 INLINE CollisionLevelStateBase::
22 CollisionLevelStateBase(const NodePath &node_path) :
23  _node_path(node_path),
24  _colliders(get_class_type()),
25  _include_mask(CollideMask::all_on())
26 {
27 }
28 
29 ////////////////////////////////////////////////////////////////////
30 // Function: CollisionLevelStateBase::Constructor
31 // Access: Public
32 // Description: This constructor goes to the next child node in the
33 // traversal.
34 ////////////////////////////////////////////////////////////////////
35 INLINE CollisionLevelStateBase::
36 CollisionLevelStateBase(const CollisionLevelStateBase &parent, PandaNode *child) :
37  _node_path(parent._node_path, child),
38  _colliders(parent._colliders),
39  _include_mask(parent._include_mask),
40  _local_bounds(parent._local_bounds)
41 {
42 }
43 
44 ////////////////////////////////////////////////////////////////////
45 // Function: CollisionLevelStateBase::Copy Constructor
46 // Access: Public
47 // Description:
48 ////////////////////////////////////////////////////////////////////
49 INLINE CollisionLevelStateBase::
50 CollisionLevelStateBase(const CollisionLevelStateBase &copy) :
51  _node_path(copy._node_path),
52  _colliders(copy._colliders),
53  _include_mask(copy._include_mask),
54  _local_bounds(copy._local_bounds),
55  _parent_bounds(copy._parent_bounds)
56 {
57 }
58 
59 ////////////////////////////////////////////////////////////////////
60 // Function: CollisionLevelStateBase::Copy Assignment Operator
61 // Access: Public
62 // Description:
63 ////////////////////////////////////////////////////////////////////
64 INLINE void CollisionLevelStateBase::
65 operator = (const CollisionLevelStateBase &copy) {
66  _node_path = copy._node_path;
67  _colliders = copy._colliders;
68  _include_mask = copy._include_mask;
69  _local_bounds = copy._local_bounds;
70  _parent_bounds = copy._parent_bounds;
71 }
72 
73 ////////////////////////////////////////////////////////////////////
74 // Function: CollisionLevelStateBase::get_node_path
75 // Access: Public
76 // Description: Returns the NodePath representing the node instance
77 // we have traversed to.
78 ////////////////////////////////////////////////////////////////////
80 get_node_path() const {
81  return _node_path.get_node_path();
82 }
83 
84 ////////////////////////////////////////////////////////////////////
85 // Function: CollisionLevelStateBase::node
86 // Access: Public
87 // Description: Returns the PandaNode pointer of the node we have
88 // traversed to.
89 ////////////////////////////////////////////////////////////////////
91 node() const {
92  return _node_path.node();
93 }
94 
95 ////////////////////////////////////////////////////////////////////
96 // Function: CollisionLevelStateBase::get_num_colliders
97 // Access: Public
98 // Description:
99 ////////////////////////////////////////////////////////////////////
100 INLINE int CollisionLevelStateBase::
101 get_num_colliders() const {
102  return _colliders.size();
103 }
104 
105 ////////////////////////////////////////////////////////////////////
106 // Function: CollisionLevelStateBase::get_collider
107 // Access: Public
108 // Description:
109 ////////////////////////////////////////////////////////////////////
110 INLINE const CollisionSolid *CollisionLevelStateBase::
111 get_collider(int n) const {
112  nassertr(n >= 0 && n < (int)_colliders.size(), NULL);
113 
114  return _colliders[n]._collider;
115 }
116 
117 ////////////////////////////////////////////////////////////////////
118 // Function: CollisionLevelStateBase::get_collider_node
119 // Access: Public
120 // Description:
121 ////////////////////////////////////////////////////////////////////
122 INLINE CollisionNode *CollisionLevelStateBase::
123 get_collider_node(int n) const {
124  nassertr(n >= 0 && n < (int)_colliders.size(), NULL);
125 
126  return _colliders[n]._node;
127 }
128 
129 ////////////////////////////////////////////////////////////////////
130 // Function: CollisionLevelStateBase::get_collider_node_path
131 // Access: Public
132 // Description:
133 ////////////////////////////////////////////////////////////////////
134 INLINE NodePath CollisionLevelStateBase::
135 get_collider_node_path(int n) const {
136  nassertr(n >= 0 && n < (int)_colliders.size(), NodePath::fail());
137 
138  return _colliders[n]._node_path;
139 }
140 
141 ////////////////////////////////////////////////////////////////////
142 // Function: CollisionLevelStateBase::get_local_bound
143 // Access: Public
144 // Description: Returns the bounding volume of the indicated
145 // collider, transformed into the current node's
146 // transform space.
147 ////////////////////////////////////////////////////////////////////
149 get_local_bound(int n) const {
150  nassertr(n >= 0 && n < (int)_colliders.size(), NULL);
151  nassertr(n >= 0 && n < (int)_local_bounds.size(), NULL);
152 
153  // For whatever reason, the Intel compiler can't figure this line
154  // out.
155  //return _local_bounds[n];
156 
157  // But it can figure out this equivalent line.
158  return *(_local_bounds + n);
159 }
160 
161 ////////////////////////////////////////////////////////////////////
162 // Function: CollisionLevelStateBase::get_parent_bound
163 // Access: Public
164 // Description: Returns the bounding volume of the indicated
165 // collider, transformed into the previous node's
166 // transform space, but not transformed by the current
167 // node's transform. This is appropriate for testing
168 // against the bounding volume of the current node
169 // (which does not have its own transform applied to
170 // it).
171 ////////////////////////////////////////////////////////////////////
173 get_parent_bound(int n) const {
174  nassertr(n >= 0 && n < (int)_colliders.size(), NULL);
175  nassertr(n >= 0 && n < (int)_parent_bounds.size(), NULL);
176 
177  // But it can figure out this equivalent line.
178  return *(_parent_bounds + n);
179 }
180 
181 ////////////////////////////////////////////////////////////////////
182 // Function: CollisionLevelStateBase::set_include_mask
183 // Access: Public
184 // Description: Specifies the mask that is applied to the into
185 // CollideMask of nodes in the scene graph before
186 // testing for bits in common with the from CollideMask
187 // of colliders. This is normally all bits on, but you
188 // may set it to some other mask to restrict certain
189 // bits from consideration.
190 //
191 // This is used by the CollisionTraverser to restrict
192 // collision with geometry except under the lowest level
193 // of LOD.
194 ////////////////////////////////////////////////////////////////////
195 INLINE void CollisionLevelStateBase::
197  _include_mask = include_mask;
198 }
199 
200 
201 ////////////////////////////////////////////////////////////////////
202 // Function: CollisionLevelStateBase::get_include_mask
203 // Access: Public
204 // Description: Returns the mask that is applied to the into
205 // CollideMask of nodes in the scene graph before
206 // testing for bits in common with the from CollideMask
207 // of colliders. See set_include_mask().
208 ////////////////////////////////////////////////////////////////////
211  return _include_mask;
212 }
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...
PandaNode * node() const
Returns the node traversed to so far.
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:185
NodePath get_node_path() const
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&#39;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&#39;s transform ...
NodePath get_node_path() const
Returns the NodePath representing the node instance we have traversed to.
A node in the scene graph that can hold any number of CollisionSolids.
Definition: collisionNode.h:33
This is the state information the CollisionTraverser retains for each level during traversal...
A general bitmask class.
Definition: bitMask.h:35
NodePath is the fundamental system for disambiguating instances, and also provides a higher-level int...
Definition: nodePath.h:165