Browse Source

a minor optimization

David Rose 18 years ago
parent
commit
7d3f612ff9
1 changed files with 14 additions and 14 deletions
  1. 14 14
      panda/src/collide/collisionLevelStateBase.cxx

+ 14 - 14
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())) {
   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() && 
-        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());
     CPT(TransformState) rel_transform = def._node_path.get_transform(root.get_parent());