Panda3D

Loading...
Searching...
No Matches
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 */
17INLINE CollisionLevelStateBase::
18CollisionLevelStateBase(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 */
28INLINE CollisionLevelStateBase::
29CollisionLevelStateBase(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 */
40INLINE CollisionLevelStateBase::
41CollisionLevelStateBase(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 */
53INLINE void CollisionLevelStateBase::
54operator = (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 */
65INLINE NodePath CollisionLevelStateBase::
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 */
73INLINE PandaNode *CollisionLevelStateBase::
74 node() const {
75 return _node_path.node();
76}
77
78/**
79 *
80 */
81INLINE int CollisionLevelStateBase::
82get_num_colliders() const {
83 return _colliders.size();
84}
85
86/**
87 *
88 */
89INLINE const CollisionSolid *CollisionLevelStateBase::
90get_collider(int n) const {
91 nassertr(n >= 0 && n < (int)_colliders.size(), nullptr);
92
93 return _colliders[n]._collider;
94}
95
96/**
97 *
98 */
99INLINE CollisionNode *CollisionLevelStateBase::
100get_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 */
109INLINE NodePath CollisionLevelStateBase::
110get_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 */
120INLINE const GeometricBoundingVolume *CollisionLevelStateBase::
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 */
138INLINE const GeometricBoundingVolume *CollisionLevelStateBase::
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 */
156INLINE void CollisionLevelStateBase::
157 set_include_mask(CollideMask include_mask) {
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 */
167INLINE CollideMask CollisionLevelStateBase::
168 get_include_mask() const {
169 return _include_mask;
170}
CollisionLevelStateBase
This is the state information the CollisionTraverser retains for each level during traversal.
Definition collisionLevelStateBase.h:43
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::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
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
NodePath::fail
static NodePath fail()
Creates a NodePath with the ET_fail error type set.
Definition nodePath.I:149
PandaNode
A basic node of the scene graph or data graph.
Definition pandaNode.h:65