Forráskód Böngészése

assert against negative radius

David Rose 20 éve
szülő
commit
95826297fb

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

@@ -26,6 +26,7 @@ INLINE CollisionSphere::
 CollisionSphere(const LPoint3f &center, float radius) :
   _center(center), _radius(radius)
 {
+  nassertv(_radius >= 0.0f);
 }
 
 ////////////////////////////////////////////////////////////////////
@@ -37,6 +38,7 @@ INLINE CollisionSphere::
 CollisionSphere(float cx, float cy, float cz, float radius) :
   _center(cx, cy, cz), _radius(radius)
 {
+  nassertv(_radius >= 0.0f);
 }
 
 ////////////////////////////////////////////////////////////////////
@@ -101,6 +103,7 @@ get_center() const {
 ////////////////////////////////////////////////////////////////////
 INLINE void CollisionSphere::
 set_radius(float radius) {
+  nassertv(radius >= 0.0f);
   _radius = radius;
   mark_internal_bounds_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)
 {
   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)
 {
   recalc_internals();
+  nassertv(_radius >= 0.0f);
 }
 
 ////////////////////////////////////////////////////////////////////
@@ -137,6 +139,7 @@ get_point_b() const {
 ////////////////////////////////////////////////////////////////////
 INLINE void CollisionTube::
 set_radius(float radius) {
+  nassertv(radius >= 0.0f);
   _radius = radius;
 
   // We don't need to call recalc_internals(), since the radius