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())) {
_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());