فهرست منبع

fix max_dist bug with CollisionBox

David Rose 14 سال پیش
والد
کامیت
6335c11050
1فایلهای تغییر یافته به همراه2 افزوده شده و 1 حذف شده
  1. 2 1
      panda/src/collide/collisionBox.cxx

+ 2 - 1
panda/src/collide/collisionBox.cxx

@@ -383,6 +383,8 @@ test_intersection_from_sphere(const CollisionEntry &entry) const {
       edge_dist = dist_to_polygon(p, _points[ip]);
       edge_dist = dist_to_polygon(p, _points[ip]);
     }
     }
 
 
+    max_dist = from_radius;
+
     // Now we have edge_dist, which is the distance from the sphere
     // Now we have edge_dist, which is the distance from the sphere
     // center to the nearest edge of the polygon, within the polygon's
     // center to the nearest edge of the polygon, within the polygon's
     // plane. edge_dist<0 means the point is within the polygon.
     // plane. edge_dist<0 means the point is within the polygon.
@@ -403,7 +405,6 @@ test_intersection_from_sphere(const CollisionEntry &entry) const {
     // remain from the plane, based on its distance from the nearest
     // remain from the plane, based on its distance from the nearest
     // edge.
     // edge.
 
 
-    max_dist = from_radius;
     if (edge_dist >= 0.0f) {
     if (edge_dist >= 0.0f) {
       float max_dist_2 = max(from_radius_2 - edge_dist * edge_dist, 0.0f);
       float max_dist_2 = max(from_radius_2 - edge_dist * edge_dist, 0.0f);
       max_dist = csqrt(max_dist_2);
       max_dist = csqrt(max_dist_2);