Browse Source

assert against negative radius

David Rose 20 years ago
parent
commit
95826297fb
2 changed files with 6 additions and 0 deletions
  1. 3 0
      panda/src/collide/collisionSphere.I
  2. 3 0
      panda/src/collide/collisionTube.I

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

@@ -26,6 +26,7 @@ INLINE CollisionSphere::
 CollisionSphere(const LPoint3f &center, float radius) :
 CollisionSphere(const LPoint3f &center, float radius) :
   _center(center), _radius(radius)
   _center(center), _radius(radius)
 {
 {
+  nassertv(_radius >= 0.0f);
 }
 }
 
 
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
@@ -37,6 +38,7 @@ INLINE CollisionSphere::
 CollisionSphere(float cx, float cy, float cz, float radius) :
 CollisionSphere(float cx, float cy, float cz, float radius) :
   _center(cx, cy, cz), _radius(radius)
   _center(cx, cy, cz), _radius(radius)
 {
 {
+  nassertv(_radius >= 0.0f);
 }
 }
 
 
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
@@ -101,6 +103,7 @@ get_center() const {
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
 INLINE void CollisionSphere::
 INLINE void CollisionSphere::
 set_radius(float radius) {
 set_radius(float radius) {
+  nassertv(radius >= 0.0f);
   _radius = radius;
   _radius = radius;
   mark_internal_bounds_stale();
   mark_internal_bounds_stale();
   mark_viz_stale();
   mark_viz_stale();

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

@@ -27,6 +27,7 @@ CollisionTube(const LPoint3f &a, const LPoint3f &b, float radius) :
   _a(a), _b(b), _radius(radius)
   _a(a), _b(b), _radius(radius)
 {
 {
   recalc_internals();
   recalc_internals();
+  nassertv(_radius >= 0.0f);
 }
 }
 
 
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
@@ -41,6 +42,7 @@ CollisionTube(float ax, float ay, float az,
   _a(ax, ay, az), _b(bx, by, bz), _radius(radius)
   _a(ax, ay, az), _b(bx, by, bz), _radius(radius)
 {
 {
   recalc_internals();
   recalc_internals();
+  nassertv(_radius >= 0.0f);
 }
 }
 
 
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
@@ -137,6 +139,7 @@ get_point_b() const {
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
 INLINE void CollisionTube::
 INLINE void CollisionTube::
 set_radius(float radius) {
 set_radius(float radius) {
+  nassertv(radius >= 0.0f);
   _radius = radius;
   _radius = radius;
 
 
   // We don't need to call recalc_internals(), since the radius
   // We don't need to call recalc_internals(), since the radius