Panda3D
 All Classes Functions Variables Enumerations
collisionNode.I
1 // Filename: collisionNode.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: CollisionNode::set_collide_mask
18 // Access: Published
19 // Description: Simultaneously sets both the "from" and "into"
20 // CollideMask values to the same thing.
21 ////////////////////////////////////////////////////////////////////
22 INLINE void CollisionNode::
26 }
27 
28 ////////////////////////////////////////////////////////////////////
29 // Function: CollisionNode::set_into_collide_mask
30 // Access: Published
31 // Description: Sets the "into" CollideMask. In order for a
32 // collision to be detected from another object into
33 // this object, the intersection of the other object's
34 // "from" mask and this object's "into" mask must be
35 // nonzero.
36 ////////////////////////////////////////////////////////////////////
37 INLINE void CollisionNode::
39  // This is now inherited from the PandaNode base class.
41 }
42 
43 ////////////////////////////////////////////////////////////////////
44 // Function: CollisionNode::get_from_collide_mask
45 // Access: Published
46 // Description: Returns the current "from" CollideMask. In order for
47 // a collision to be detected from this object into
48 // another object, the intersection of this object's
49 // "from" mask and the other object's "into" mask must
50 // be nonzero.
51 ////////////////////////////////////////////////////////////////////
54  return _from_collide_mask;
55 }
56 
57 ////////////////////////////////////////////////////////////////////
58 // Function: CollisionNode::get_into_collide_mask
59 // Access: Published
60 // Description: Returns the current "into" CollideMask. In order for
61 // a collision to be detected from another object into
62 // this object, the intersection of the other object's
63 // "from" mask and this object's "into" mask must be
64 // nonzero.
65 ////////////////////////////////////////////////////////////////////
68  // This is now inherited from the PandaNode base class.
70 }
71 
72 ////////////////////////////////////////////////////////////////////
73 // Function: CollisionNode::clear_solids
74 // Access: Published
75 // Description: Removes all solids from the node.
76 ////////////////////////////////////////////////////////////////////
77 INLINE void CollisionNode::
79  _solids.clear();
81 }
82 
83 ////////////////////////////////////////////////////////////////////
84 // Function: CollisionNode::get_num_solids
85 // Access: Published
86 // Description:
87 ////////////////////////////////////////////////////////////////////
88 INLINE int CollisionNode::
89 get_num_solids() const {
90  return _solids.size();
91 }
92 
93 ////////////////////////////////////////////////////////////////////
94 // Function: CollisionNode::get_solid
95 // Access: Published
96 // Description:
97 ////////////////////////////////////////////////////////////////////
98 INLINE CPT(CollisionSolid) CollisionNode::
99 get_solid(int n) const {
100  nassertr(n >= 0 && n < get_num_solids(), NULL);
101  return _solids[n].get_read_pointer();
102 }
103 
104 ////////////////////////////////////////////////////////////////////
105 // Function: CollisionNode::modify_solid
106 // Access: Published
107 // Description:
108 ////////////////////////////////////////////////////////////////////
109 INLINE PT(CollisionSolid) CollisionNode::
110 modify_solid(int n) {
111  nassertr(n >= 0 && n < get_num_solids(), NULL);
112  mark_internal_bounds_stale();
113  return _solids[n].get_write_pointer();
114 }
115 
116 ////////////////////////////////////////////////////////////////////
117 // Function: CollisionNode::set_solid
118 // Access: Published
119 // Description: Replaces the solid with the indicated index.
120 ////////////////////////////////////////////////////////////////////
121 INLINE void CollisionNode::
122 set_solid(int n, CollisionSolid *solid) {
123  nassertv(n >= 0 && n < get_num_solids());
124  _solids[n] = solid;
126 }
127 
128 ////////////////////////////////////////////////////////////////////
129 // Function: CollisionNode::remove_solid
130 // Access: Published
131 // Description: Removes the solid with the indicated index. This
132 // will shift all subsequent indices down by one.
133 ////////////////////////////////////////////////////////////////////
134 INLINE void CollisionNode::
135 remove_solid(int n) {
136  nassertv(n >= 0 && n < get_num_solids());
137  _solids.erase(_solids.begin() + n);
139 }
140 
141 ////////////////////////////////////////////////////////////////////
142 // Function: CollisionNode::add_solid
143 // Access: Published
144 // Description: Adds the indicated solid to the node. Returns the
145 // index of the new solid within the node's list of
146 // solids.
147 ////////////////////////////////////////////////////////////////////
148 INLINE int CollisionNode::
149 add_solid(const CollisionSolid *solid) {
150  _solids.push_back((CollisionSolid *)solid);
152  return _solids.size() - 1;
153 }
154 
155 ////////////////////////////////////////////////////////////////////
156 // Function: CollisionNode::get_collider_sort
157 // Access: Published
158 // Description: Returns the collider_sort value that has been set for
159 // this particular node. See set_collider_sort().
160 ////////////////////////////////////////////////////////////////////
161 INLINE int CollisionNode::
163  return _collider_sort;
164 }
165 
166 ////////////////////////////////////////////////////////////////////
167 // Function: CollisionNode::set_collider_sort
168 // Access: Published
169 // Description: Sets a particular collider_sort value on this node.
170 // This controls the order in which colliders (that is,
171 // "from nodes") are grouped together for the collision
172 // traversal.
173 //
174 // If there are 32 or fewer colliders added to any
175 // particular CollisionTraverser, then this value has no
176 // meaning. It is only useful if there are many
177 // colliders, which may force the CollisionTraverser to
178 // make multiple passes through the data; in that case,
179 // it may be a useful optimization to group colliders
180 // that have similar bounding volumes together (by
181 // giving them similar sort values).
182 ////////////////////////////////////////////////////////////////////
183 INLINE void CollisionNode::
184 set_collider_sort(int sort) {
185  _collider_sort = sort;
186 }
187 
188 ////////////////////////////////////////////////////////////////////
189 // Function: CollisionNode::get_default_collide_mask
190 // Access: Published, Static
191 // Description: Returns the default into_collide_mask assigned to new
192 // CollisionNodes.
193 ////////////////////////////////////////////////////////////////////
196  return default_collision_node_collide_mask;
197 }
void set_collide_mask(CollideMask mask)
Simultaneously sets both the &quot;from&quot; and &quot;into&quot; CollideMask values to the same thing.
Definition: collisionNode.I:23
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).
CollideMask get_into_collide_mask() const
Returns the &quot;into&quot; collide mask for this node.
Definition: pandaNode.I:582
int get_collider_sort() const
Returns the collider_sort value that has been set for this particular node.
void mark_internal_bounds_stale(Thread *current_thread=Thread::get_current_thread())
Should be called by a derived class to mark the internal bounding volume stale, so that compute_inter...
Definition: pandaNode.cxx:2467
void set_collider_sort(int sort)
Sets a particular collider_sort value on this node.
void set_into_collide_mask(CollideMask mask)
Sets the &quot;into&quot; CollideMask.
Definition: pandaNode.cxx:2037
void set_into_collide_mask(CollideMask mask)
Sets the &quot;into&quot; CollideMask.
Definition: collisionNode.I:38
void clear_solids()
Removes all solids from the node.
Definition: collisionNode.I:78
static CollideMask get_default_collide_mask()
Returns the default into_collide_mask assigned to new CollisionNodes.
void set_solid(int n, CollisionSolid *solid)
Replaces the solid with the indicated index.
A node in the scene graph that can hold any number of CollisionSolids.
Definition: collisionNode.h:33
int add_solid(const CollisionSolid *solid)
Adds the indicated solid to the node.
CollideMask get_into_collide_mask() const
Returns the current &quot;into&quot; CollideMask.
Definition: collisionNode.I:67
CollideMask get_from_collide_mask() const
Returns the current &quot;from&quot; CollideMask.
Definition: collisionNode.I:53
void remove_solid(int n)
Removes the solid with the indicated index.
void set_from_collide_mask(CollideMask mask)
Sets the &quot;from&quot; CollideMask.