Browse Source

creating a zero-length ray or segment should trigger an assertion failure

David Rose 24 years ago
parent
commit
ac7279f393
2 changed files with 9 additions and 0 deletions
  1. 3 0
      panda/src/collide/collisionRay.I
  2. 6 0
      panda/src/collide/collisionSegment.I

+ 3 - 0
panda/src/collide/collisionRay.I

@@ -40,6 +40,7 @@ INLINE CollisionRay::
 CollisionRay(const LPoint3f &origin, const LVector3f &direction) :
   _origin(origin), _direction(direction)
 {
+  nassertv(_direction != LPoint3f::zero());
 }
 
 ////////////////////////////////////////////////////////////////////
@@ -52,6 +53,7 @@ CollisionRay(float ox, float oy, float oz,
              float dx, float dy, float dz) :
   _origin(ox, oy, oz), _direction(dx, dy, dz)
 {
+  nassertv(_direction != LPoint3f::zero());
 }
 
 ////////////////////////////////////////////////////////////////////
@@ -109,6 +111,7 @@ set_direction(const LVector3f &direction) {
   _direction = direction;
   mark_bound_stale();
   mark_viz_stale();
+  nassertv(_direction != LPoint3f::zero());
 }
 
 ////////////////////////////////////////////////////////////////////

+ 6 - 0
panda/src/collide/collisionSegment.I

@@ -40,6 +40,7 @@ INLINE CollisionSegment::
 CollisionSegment(const LPoint3f &a, const LPoint3f &b) :
   _a(a), _b(b)
 {
+  nassertv(_a != _b);
 }
 
 ////////////////////////////////////////////////////////////////////
@@ -52,6 +53,7 @@ CollisionSegment(float ax, float ay, float az,
                  float bx, float by, float bz) :
   _a(ax, ay, az), _b(bx, by, bz)
 {
+  nassertv(_a != _b);
 }
 
 ////////////////////////////////////////////////////////////////////
@@ -77,6 +79,9 @@ set_point_a(const LPoint3f &a) {
   _a = a;
   mark_bound_stale();
   mark_viz_stale();
+  // We don't assert here that a != b, on the assumption that you
+  // might be about to change both at once, and you'll probably start
+  // by changing a first.
 }
 
 ////////////////////////////////////////////////////////////////////
@@ -109,6 +114,7 @@ set_point_b(const LPoint3f &b) {
   _b = b;
   mark_bound_stale();
   mark_viz_stale();
+  nassertv(_a != _b);
 }
 
 ////////////////////////////////////////////////////////////////////