Browse Source

*** empty log message ***

David Rose 25 years ago
parent
commit
67873faecb

+ 2 - 2
panda/src/collide/collisionHandlerEvent.I

@@ -45,7 +45,7 @@ operator = (const CollisionHandlerEvent::SortEntries &) {
 //                  %fn  - the name of the "from" object's node
 //                  %in  - the name of the "into" object's node
 //                  %ft  - 't' if "from" is tangible, 'i' if intangible
-//                  %ft  - 't' if "into" is tangible, 'i' if intangible
+//                  %it  - 't' if "into" is tangible, 'i' if intangible
 //
 //               The event name will be based on the in_pattern
 //               string specified here, with all occurrences of the
@@ -82,7 +82,7 @@ get_in_pattern() const {
 //  Description: Sets the pattern string that indicates how the event
 //               names are generated when a collision between two
 //               particular nodes is *still* detected.  This event is
-//               each consecutive time a collision between two
+//               thrown each consecutive time a collision between two
 //               particular nodes is detected, starting with the
 //               second time.
 //

+ 5 - 0
panda/src/collide/collisionSegment.h

@@ -17,6 +17,11 @@ class ProjectionNode;
 // Description : A finite line segment, with two specific endpoints
 //               but no thickness.  It's similar to a CollisionRay,
 //               except it does not continue to infinity.
+//
+//               It does have an ordering, from point A to point B.
+//               If more than a single point of the segment is
+//               intersecting a solid, the reported intersection point
+//               is generally the closest on the segment to point A.
 ////////////////////////////////////////////////////////////////////
 class EXPCL_PANDA CollisionSegment : public CollisionSolid {
 PUBLISHED:

+ 7 - 3
panda/src/collide/collisionSphere.cxx

@@ -186,7 +186,7 @@ test_intersection_from_segment(CollisionHandler *record,
   DCAST_INTO_R(segment, entry.get_from(), 0);
 
   LPoint3f from_a = segment->get_point_a() * entry.get_wrt_space();
-  LVector3f from_b = segment->get_point_b() * entry.get_wrt_space();
+  LPoint3f from_b = segment->get_point_b() * entry.get_wrt_space();
   LVector3f from_direction = from_b - from_a;
 
   double t1, t2;
@@ -210,9 +210,13 @@ test_intersection_from_segment(CollisionHandler *record,
 
   LPoint3f into_intersection_point;
   if (t1 < 0.0) {
-    into_intersection_point = from_a + t2 * from_direction;
+    // Point a is within the sphere.  The first intersection point is
+    // point a itself.
+    into_intersection_point = from_a;
   } else {
-    into_intersection_point = from_b + t1 * from_direction;
+    // Point a is outside the sphere, and point b is either inside the
+    // sphere or beyond it.  The first intersection point is at t1.
+    into_intersection_point = from_a + t1 * from_direction;
   }
   new_entry->set_into_intersection_point(into_intersection_point);