Browse Source

assert not nan

David Rose 21 years ago
parent
commit
c71fd12dc7

+ 8 - 0
panda/src/pgraph/transformState.cxx

@@ -262,6 +262,7 @@ make_invalid() {
 CPT(TransformState) TransformState::
 make_pos_hpr_scale_shear(const LVecBase3f &pos, const LVecBase3f &hpr, 
                          const LVecBase3f &scale, const LVecBase3f &shear) {
+  nassertr(!(pos.is_nan() || hpr.is_nan() || scale.is_nan() || shear.is_nan()) , make_invalid());
   // Make a special-case check for the identity transform.
   if (pos == LVecBase3f(0.0f, 0.0f, 0.0f) &&
       hpr == LVecBase3f(0.0f, 0.0f, 0.0f) &&
@@ -289,6 +290,7 @@ make_pos_hpr_scale_shear(const LVecBase3f &pos, const LVecBase3f &hpr,
 CPT(TransformState) TransformState::
 make_pos_quat_scale_shear(const LVecBase3f &pos, const LQuaternionf &quat, 
                           const LVecBase3f &scale, const LVecBase3f &shear) {
+  nassertr(!(pos.is_nan() || quat.is_nan() || scale.is_nan() || shear.is_nan()) , make_invalid());
   // Make a special-case check for the identity transform.
   if (pos == LVecBase3f(0.0f, 0.0f, 0.0f) &&
       quat == LQuaternionf::ident_quat() &&
@@ -315,6 +317,7 @@ make_pos_quat_scale_shear(const LVecBase3f &pos, const LQuaternionf &quat,
 ////////////////////////////////////////////////////////////////////
 CPT(TransformState) TransformState::
 make_mat(const LMatrix4f &mat) {
+  nassertr(!mat.is_nan(), make_invalid());
   // Make a special-case check for the identity matrix.
   if (mat == LMatrix4f::ident_mat()) {
     return make_identity();
@@ -335,6 +338,7 @@ make_mat(const LMatrix4f &mat) {
 ////////////////////////////////////////////////////////////////////
 CPT(TransformState) TransformState::
 set_pos(const LVecBase3f &pos) const {
+  nassertr(!pos.is_nan(), this);
   nassertr(!is_invalid(), this);
   if (is_identity() || components_given()) {
     // If we started with a componentwise transform, we keep it that
@@ -362,6 +366,7 @@ set_pos(const LVecBase3f &pos) const {
 ////////////////////////////////////////////////////////////////////
 CPT(TransformState) TransformState::
 set_hpr(const LVecBase3f &hpr) const {
+  nassertr(!hpr.is_nan(), this);
   nassertr(!is_invalid(), this);
   //  nassertr(has_components(), this);
   return make_pos_hpr_scale_shear(get_pos(), hpr, get_scale(), get_shear());
@@ -376,6 +381,7 @@ set_hpr(const LVecBase3f &hpr) const {
 ////////////////////////////////////////////////////////////////////
 CPT(TransformState) TransformState::
 set_quat(const LQuaternionf &quat) const {
+  nassertr(!quat.is_nan(), this);
   nassertr(!is_invalid(), this);
   //  nassertr(has_components(), this);
   return make_pos_quat_scale_shear(get_pos(), quat, get_scale(), get_shear());
@@ -390,6 +396,7 @@ set_quat(const LQuaternionf &quat) const {
 ////////////////////////////////////////////////////////////////////
 CPT(TransformState) TransformState::
 set_scale(const LVecBase3f &scale) const {
+  nassertr(!scale.is_nan(), this);
   nassertr(!is_invalid(), this);
   //  nassertr(has_components(), this);
   if (quat_given()) {
@@ -408,6 +415,7 @@ set_scale(const LVecBase3f &scale) const {
 ////////////////////////////////////////////////////////////////////
 CPT(TransformState) TransformState::
 set_shear(const LVecBase3f &shear) const {
+  nassertr(!shear.is_nan(), this);
   nassertr(!is_invalid(), this);
   //  nassertr(has_components(), this);
   if (quat_given()) {

+ 11 - 3
panda/src/physics/physicsObject.I

@@ -32,7 +32,8 @@ set_mass(float m) {
 // Description : Vector position assignment
 ////////////////////////////////////////////////////////////////////
 INLINE void PhysicsObject::
-set_position(const LPoint3f& pos) {
+set_position(const LPoint3f &pos) {
+  nassertv(!pos.is_nan());
   _position = pos;
 }
 
@@ -43,6 +44,7 @@ set_position(const LPoint3f& pos) {
 ////////////////////////////////////////////////////////////////////
 INLINE void PhysicsObject::
 set_position(float x, float y, float z) {
+  nassertv(!LPoint3f(x, y, z).is_nan());
   _position.set(x, y, z);
 }
 
@@ -55,6 +57,7 @@ set_position(float x, float y, float z) {
 ////////////////////////////////////////////////////////////////////
 INLINE void PhysicsObject::
 reset_position(const LPoint3f &pos) {
+  nassertv(!pos.is_nan());
   _position = pos;
   _last_position = pos;
   _velocity.set(0.0f, 0.0f, 0.0f);
@@ -68,6 +71,7 @@ reset_position(const LPoint3f &pos) {
 ////////////////////////////////////////////////////////////////////
 INLINE void PhysicsObject::
 reset_orientation(const LOrientationf &orientation) {
+  nassertv(!orientation.is_nan());
   _orientation = orientation;
   _rotation.set(0.0f, 0.0f, 0.0f);
 }
@@ -78,7 +82,7 @@ reset_orientation(const LOrientationf &orientation) {
 // Description : Last position assignment
 ////////////////////////////////////////////////////////////////////
 INLINE void PhysicsObject::
-set_last_position(const LPoint3f& pos) {
+set_last_position(const LPoint3f &pos) {
   _last_position = pos;
 }
 
@@ -88,7 +92,8 @@ set_last_position(const LPoint3f& pos) {
 // Description : Vector velocity assignment
 ////////////////////////////////////////////////////////////////////
 INLINE void PhysicsObject::
-set_velocity(const LVector3f& vel) {
+set_velocity(const LVector3f &vel) {
+  nassertv(!vel.is_nan());
   _velocity = vel;
 }
 
@@ -99,6 +104,7 @@ set_velocity(const LVector3f& vel) {
 ////////////////////////////////////////////////////////////////////
 INLINE void PhysicsObject::
 set_velocity(float x, float y, float z) {
+  nassertv(!LVector3f(x, y, z).is_nan());
   _velocity.set(x, y, z);
 }
 
@@ -213,6 +219,7 @@ get_terminal_velocity() const {
 ////////////////////////////////////////////////////////////////////
 INLINE void PhysicsObject::
 set_orientation(const LOrientationf &orientation) {
+  nassertv(!orientation.is_nan());
   _orientation = orientation;
 }
 
@@ -223,6 +230,7 @@ set_orientation(const LOrientationf &orientation) {
 ////////////////////////////////////////////////////////////////////
 INLINE void PhysicsObject::
 set_rotation(const LVector3f &rotation) {
+  nassertv(!rotation.is_nan());
   _rotation = rotation;
 }
 

+ 1 - 0
panda/src/physics/physicsObject.cxx

@@ -103,6 +103,7 @@ get_lcs() const {
   if (_oriented) {
     m=m*_orientation;
   }
+  nassertr(!m.is_nan(), m);
   return m;
 }