forked from panda3d/panda3d
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcollisionNode.I
More file actions
168 lines (153 loc) · 4.4 KB
/
collisionNode.I
File metadata and controls
168 lines (153 loc) · 4.4 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
/**
* PANDA 3D SOFTWARE
* Copyright (c) Carnegie Mellon University. All rights reserved.
*
* All use of this software is subject to the terms of the revised BSD
* license. You should have received a copy of this license along
* with this source code in a file named "LICENSE."
*
* @file collisionNode.I
* @author drose
* @date 2002-03-16
*/
/**
* Simultaneously sets both the "from" and "into" CollideMask values to the
* same thing.
*/
INLINE void CollisionNode::
set_collide_mask(CollideMask mask) {
set_from_collide_mask(mask);
set_into_collide_mask(mask);
}
/**
* Sets the "into" CollideMask. In order for a collision to be detected from
* another object into this object, the intersection of the other object's
* "from" mask and this object's "into" mask must be nonzero.
*/
INLINE void CollisionNode::
set_into_collide_mask(CollideMask mask) {
// This is now inherited from the PandaNode base class.
PandaNode::set_into_collide_mask(mask);
}
/**
* Returns the current "from" CollideMask. In order for a collision to be
* detected from this object into another object, the intersection of this
* object's "from" mask and the other object's "into" mask must be nonzero.
*/
INLINE CollideMask CollisionNode::
get_from_collide_mask() const {
return _from_collide_mask;
}
/**
* Returns the current "into" CollideMask. In order for a collision to be
* detected from another object into this object, the intersection of the
* other object's "from" mask and this object's "into" mask must be nonzero.
*/
INLINE CollideMask CollisionNode::
get_into_collide_mask() const {
// This is now inherited from the PandaNode base class.
return PandaNode::get_into_collide_mask();
}
/**
* Removes all solids from the node.
*/
INLINE void CollisionNode::
clear_solids() {
_solids.clear();
mark_internal_bounds_stale();
}
/**
*
*/
INLINE size_t CollisionNode::
get_num_solids() const {
return _solids.size();
}
/**
*
*/
INLINE CPT(CollisionSolid) CollisionNode::
get_solid(size_t n) const {
nassertr(n < get_num_solids(), nullptr);
return _solids[n].get_read_pointer();
}
/**
*
*/
INLINE PT(CollisionSolid) CollisionNode::
modify_solid(size_t n) {
nassertr(n < get_num_solids(), nullptr);
mark_internal_bounds_stale();
return _solids[n].get_write_pointer();
}
/**
* Replaces the solid with the indicated index.
*/
INLINE void CollisionNode::
set_solid(size_t n, CollisionSolid *solid) {
nassertv(n < get_num_solids());
_solids[n] = solid;
mark_internal_bounds_stale();
}
/**
* Inserts the indicated solid to the node at the indicated position.
*/
INLINE void CollisionNode::
insert_solid(size_t n, const CollisionSolid *solid) {
if (n > _solids.size()) {
n = _solids.size();
}
_solids.insert(_solids.begin() + n, (CollisionSolid *)solid);
mark_internal_bounds_stale();
}
/**
* Removes the solid with the indicated index. This will shift all subsequent
* indices down by one.
*/
INLINE void CollisionNode::
remove_solid(size_t n) {
nassertv(n < get_num_solids());
_solids.erase(_solids.begin() + n);
mark_internal_bounds_stale();
}
/**
* Adds the indicated solid to the node. Returns the index of the new solid
* within the node's list of solids.
*/
INLINE size_t CollisionNode::
add_solid(const CollisionSolid *solid) {
_solids.push_back((CollisionSolid *)solid);
mark_internal_bounds_stale();
return _solids.size() - 1;
}
/**
* Returns the collider_sort value that has been set for this particular node.
* See set_collider_sort().
*/
INLINE int CollisionNode::
get_collider_sort() const {
return _collider_sort;
}
/**
* Sets a particular collider_sort value on this node. This controls the
* order in which colliders (that is, "from nodes") are grouped together for
* the collision traversal.
*
* If there are 32 or fewer colliders added to any particular
* CollisionTraverser, then this value has no meaning. It is only useful if
* there are many colliders, which may force the CollisionTraverser to make
* multiple passes through the data; in that case, it may be a useful
* optimization to group colliders that have similar bounding volumes together
* (by giving them similar sort values).
*/
INLINE void CollisionNode::
set_collider_sort(int sort) {
_collider_sort = sort;
}
/**
* Returns the default into_collide_mask assigned to new CollisionNodes.
*/
INLINE CollideMask CollisionNode::
get_default_collide_mask() {
return default_collision_node_collide_mask;
}