a minor optimization

This commit is contained in:
David Rose 2007-07-24 22:32:46 +00:00
parent bff1583902
commit 7d3f612ff9

View File

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