From a75e578539f9645269bc4b18d7b34a6f386eea5f Mon Sep 17 00:00:00 2001 From: David Rose Date: Wed, 22 Aug 2007 22:33:14 +0000 Subject: [PATCH] a node shouldn't collide with itself or with any descendants of itself --- panda/src/collide/collisionLevelState.I | 40 +++++++++++++++--------- panda/src/collide/collisionTraverser.cxx | 4 +-- 2 files changed, 28 insertions(+), 16 deletions(-) diff --git a/panda/src/collide/collisionLevelState.I b/panda/src/collide/collisionLevelState.I index f2db21dff7..f1a2d309ec 100644 --- a/panda/src/collide/collisionLevelState.I +++ b/panda/src/collide/collisionLevelState.I @@ -149,25 +149,37 @@ any_in_bounds() { // node. CollideMask from_mask = cnode->get_from_collide_mask() & _include_mask; if (!(from_mask & node()->get_net_collide_mask()).is_zero()) { - // There are bits in common, so go ahead and try the - // bounding volume. - const GeometricBoundingVolume *col_gbv = - get_local_bound(c); - - is_in = true; // If there's no bounding volume, we're implicitly in. - - if (col_gbv != (GeometricBoundingVolume *)NULL) { - is_in = (node_gbv->contains(col_gbv) != 0); - _node_volume_pcollector.add_level(1); - + // Also don't test a node with itself, or with any of its + // descendants. + if (node() == cnode) { #ifndef NDEBUG if (collide_cat.is_spam()) { - collide_cat.spam(); indent(collide_cat.spam(false), indent_level) - << "Comparing " << c << ": " << *col_gbv - << " to " << *node_gbv << ", is_in = " << is_in << "\n"; + << "Not comparing " << c << " to " << _node_path + << " (same node)\n"; } #endif // NDEBUG + + } else { + // There are bits in common, and it's not the same + // instance, so go ahead and try the bounding volume. + const GeometricBoundingVolume *col_gbv = + get_local_bound(c); + + is_in = true; // If there's no bounding volume, we're implicitly in. + + if (col_gbv != (GeometricBoundingVolume *)NULL) { + is_in = (node_gbv->contains(col_gbv) != 0); + _node_volume_pcollector.add_level(1); + +#ifndef NDEBUG + if (collide_cat.is_spam()) { + indent(collide_cat.spam(false), indent_level) + << "Comparing " << c << ": " << *col_gbv + << " to " << *node_gbv << ", is_in = " << is_in << "\n"; + } +#endif // NDEBUG + } } } diff --git a/panda/src/collide/collisionTraverser.cxx b/panda/src/collide/collisionTraverser.cxx index ea54e5335d..3ebf5d0dcb 100644 --- a/panda/src/collide/collisionTraverser.cxx +++ b/panda/src/collide/collisionTraverser.cxx @@ -1177,8 +1177,8 @@ compare_collider_to_node(CollisionEntry &entry, DCAST_INTO_V(cnode, entry._into_node); int num_solids = cnode->get_num_solids(); collide_cat.spam() - << "Colliding against CollisionNode " << entry._into_node << " which has " << num_solids - << " collision solids.\n"; + << "Colliding against CollisionNode " << entry._into_node + << " which has " << num_solids << " collision solids.\n"; for (int s = 0; s < num_solids; ++s) { entry._into = cnode->get_solid(s); if (entry._from != entry._into) {