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