Panda3D
Loading...
Searching...
No Matches
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 */
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 */
29INLINE 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 */
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 */
52 // This is now inherited from the PandaNode base class.
54}
55
56/**
57 * Removes all solids from the node.
58 */
59INLINE void CollisionNode::
61 _solids.clear();
62 mark_internal_bounds_stale();
63}
64
65/**
66 *
67 */
68INLINE size_t CollisionNode::
69get_num_solids() const {
70 return _solids.size();
71}
72
73/**
74 *
75 */
76INLINE CPT(CollisionSolid) CollisionNode::
77get_solid(size_t n) const {
78 nassertr(n < get_num_solids(), nullptr);
79 return _solids[n].get_read_pointer();
80}
81
82/**
83 *
84 */
85INLINE PT(CollisionSolid) CollisionNode::
86modify_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 */
95INLINE void CollisionNode::
96set_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 */
105INLINE void CollisionNode::
106insert_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 */
118INLINE void CollisionNode::
119remove_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 */
129INLINE size_t CollisionNode::
130add_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 */
140INLINE int CollisionNode::
141get_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 */
157INLINE void CollisionNode::
158set_collider_sort(int sort) {
159 _collider_sort = sort;
160}
161
162/**
163 * Returns the default into_collide_mask assigned to new CollisionNodes.
164 */
167 return default_collision_node_collide_mask;
168}
get_into_collide_mask
Returns the current "into" CollideMask.
set_collider_sort
Sets a particular collider_sort value on this node.
insert_solid
Inserts the indicated solid to the node at the indicated position.
set_solid
Replaces the solid with the indicated index.
void set_collide_mask(CollideMask mask)
Simultaneously sets both the "from" and "into" CollideMask values to the same thing.
set_into_collide_mask
Sets the "into" CollideMask.
get_from_collide_mask
Returns the current "from" CollideMask.
get_collider_sort
Returns the collider_sort value that has been set for this particular node.
get_default_collide_mask
Returns the default into_collide_mask assigned to new CollisionNodes.
void clear_solids()
Removes all solids from the node.
remove_solid
Removes the solid with the indicated index.
set_from_collide_mask
Sets the "from" CollideMask.
size_t add_solid(const CollisionSolid *solid)
Adds the indicated solid to the node.
The abstract base class for all things that can collide with other things in the world,...
get_into_collide_mask
Returns the "into" collide mask for this node.
Definition pandaNode.h:264
set_into_collide_mask
Sets the "into" CollideMask.
Definition pandaNode.h:264