diff --git a/panda/src/collide/collisionLevelStateBase.cxx b/panda/src/collide/collisionLevelStateBase.cxx index 1c9a3405b0..fb793beab9 100644 --- a/panda/src/collide/collisionLevelStateBase.cxx +++ b/panda/src/collide/collisionLevelStateBase.cxx @@ -64,8 +64,6 @@ prepare_collider(const ColliderDef &def, const NodePath &root) { if (!bv->is_of_type(GeometricBoundingVolume::get_class_type())) { _local_bounds.push_back((GeometricBoundingVolume *)NULL); } else { - LPoint3f pos_delta = def._node_path.get_pos_delta(root); - // We can use a plain pointer, rather than a PT() here, because we // know we are going to save the volume in the vector, below. GeometricBoundingVolume *gbv; @@ -75,18 +73,20 @@ prepare_collider(const ColliderDef &def, const NodePath &root) { // world. The bounding volume should be extended by the object's // motion relative to each object it is considering a collision // with. That makes things complicated! - if (bv->as_bounding_sphere() && - pos_delta != LVector3f::zero()) { - // If the node has a delta, we have to include the starting - // position in the volume as well. We only do this for bounding - // spheres, since (a) other kinds of volumes may not extend so - // well, and (b) we've only implemented fluid-motion detection - // for CollisionSpheres anyway. - LMatrix4f inv_trans = LMatrix4f::translate_mat(-pos_delta); - PT(GeometricBoundingVolume) gbv_prev; - gbv_prev = DCAST(GeometricBoundingVolume, bv->make_copy()); - gbv_prev->xform(inv_trans); - gbv->extend_by(gbv_prev); + if (bv->as_bounding_sphere()) { + LPoint3f pos_delta = def._node_path.get_pos_delta(root); + if (pos_delta != LVector3f::zero()) { + // If the node has a delta, we have to include the starting + // position in the volume as well. We only do this for bounding + // spheres, since (a) other kinds of volumes may not extend so + // well, and (b) we've only implemented fluid-motion detection + // for CollisionSpheres anyway. + LMatrix4f inv_trans = LMatrix4f::translate_mat(-pos_delta); + PT(GeometricBoundingVolume) gbv_prev; + gbv_prev = DCAST(GeometricBoundingVolume, bv->make_copy()); + gbv_prev->xform(inv_trans); + gbv->extend_by(gbv_prev); + } } CPT(TransformState) rel_transform = def._node_path.get_transform(root.get_parent());