18 template<
class MaskType>
22 _current(CurrentMask::all_off())
31 template<
class MaskType>
35 _current(parent._current)
44 template<
class MaskType>
48 _current(copy._current)
57 template<
class MaskType>
60 CollisionLevelStateBase::operator = (copy);
61 _current = copy._current;
69 template<
class MaskType>
72 CollisionLevelStateBase::clear();
82 template<
class MaskType>
85 int index = (int)_colliders.size();
86 nassertv(!CurrentMask::has_max_num_bits() ||
87 index <= CurrentMask::get_max_num_bits());
90 _current.set_bit(index);
101 template<
class MaskType>
105 int indent_level = 0;
106 if (collide_cat.is_spam()) {
107 indent_level = _node_path.get_num_nodes() * 2;
109 indent(collide_cat.spam(
false), indent_level)
110 <<
"Considering " << _node_path.get_node_path() <<
"\n";
117 if (node_bv->is_of_type(GeometricBoundingVolume::get_class_type())) {
121 int num_colliders = get_num_colliders();
122 for (
int c = 0; c < num_colliders; c++) {
130 if (!(from_mask & this_mask).is_zero()) {
133 if (pnode == cnode) {
135 if (collide_cat.is_spam()) {
136 indent(collide_cat.spam(
false), indent_level)
137 <<
"Not comparing " << c <<
" to " << _node_path
150 if (col_gbv !=
nullptr) {
151 is_in = (node_gbv->
contains(col_gbv) != 0);
152 _node_volume_pcollector.add_level(1);
155 if (collide_cat.is_spam()) {
156 indent(collide_cat.spam(
false), indent_level)
157 <<
"Comparing " << c <<
": " << *col_gbv
158 <<
" to " << *node_gbv <<
", is_in = " << is_in <<
"\n";
175 if (collide_cat.is_spam()) {
176 int num_active_colliders = 0;
177 int num_colliders = get_num_colliders();
178 for (
int c = 0; c < num_colliders; c++) {
180 num_active_colliders++;
185 indent(collide_cat.spam(
false), indent_level)
186 << _node_path.get_node_path() <<
" has " << num_active_colliders
187 <<
" interested colliders";
188 if (num_colliders != 0) {
189 collide_cat.spam(
false)
191 for (
int c = 0; c < num_colliders; c++) {
194 collide_cat.spam(
false)
195 <<
" " << c <<
". " << cnode->get_name();
198 collide_cat.spam(
false)
201 collide_cat.spam(
false)
205 return has_any_collider();
218 template<
class MaskType>
222 _parent_bounds = _local_bounds;
224 if (node()->is_final()) {
229 BoundingVolumes new_bounds;
231 int num_colliders = get_num_colliders();
232 new_bounds.reserve(num_colliders);
233 for (
int c = 0; c < num_colliders; c++) {
234 new_bounds.push_back(
nullptr);
237 _local_bounds = new_bounds;
245 node_transform->invert_compose(TransformState::make_identity());
246 if (!inv_transform->has_mat()) {
251 const LMatrix4 &mat = inv_transform->get_mat();
254 BoundingVolumes new_bounds;
256 int num_colliders = get_num_colliders();
257 new_bounds.reserve(num_colliders);
258 for (
int c = 0; c < num_colliders; c++) {
260 get_local_bound(c) ==
nullptr) {
261 new_bounds.push_back(
nullptr);
266 new_bound->xform(mat);
267 new_bounds.push_back(new_bound);
271 _local_bounds = new_bounds;
284 template<
class MaskType>
287 return CurrentMask::has_max_num_bits();
296 template<
class MaskType>
299 return CurrentMask::get_max_num_bits();
308 template<
class MaskType>
311 nassertr(n >= 0 && n < (
int)_colliders.size(),
false);
312 return (_current.get_bit(n));
320 template<
class MaskType>
323 return !_current.is_zero();
331 template<
class MaskType>
334 nassertv(n >= 0 && n < (
int)_colliders.size());
337 _current.clear_bit(n);
A basic node of the scene graph or data graph.
int contains(const GeometricBoundingVolume *vol) const
Returns the appropriate set of IntersectionFlags to indicate the amount of intersection with the indi...
This is the state information the CollisionTraverser retains for each level during traversal.
bool has_collider(int n) const
Returns true if the nth collider in the LevelState is still part of the level.
This is an abstract class for any volume in any sense which can be said to define the locality of ref...
This is another abstract class, for a general class of bounding volumes that actually enclose points ...
get_from_collide_mask
Returns the current "from" CollideMask.
bool any_in_bounds()
Checks the bounding volume of the current node against each of our colliders.
std::ostream & indent(std::ostream &out, int indent_level)
A handy function for doing text formatting.
void prepare_collider(const ColliderDef &def, const NodePath &root)
Adds the indicated Collider to the set of Colliders in the current level state.
CollideMask get_net_collide_mask(Thread *current_thread=Thread::get_current_thread()) const
Returns the union of all into_collide_mask() values set at CollisionNodes at this level and below.
bool has_collider(const NodePath &collider) const
Returns true if the indicated node is current in the set of nodes that will be tested each frame for ...
static bool has_max_colliders()
Returns true if there is any the maximum number of colliders that may be added to the CollisionLevelS...
void prepare_collider(const ColliderDef &def, const NodePath &root)
Adds the indicated Collider to the set of Colliders in the current level state.
A node in the scene graph that can hold any number of CollisionSolids.
This is the state information the CollisionTraverser retains for each level during traversal.
bool apply_transform()
Applies the inverse transform from the current node, if any, onto all the colliders in the level stat...
NodePath is the fundamental system for disambiguating instances, and also provides a higher-level int...
static int get_max_colliders()
Returns the maximum number of colliders that may be added to the CollisionLevelStateBase at any one t...