From 1c9395b31106ae7be49fe580bda7bd352e8ceb98 Mon Sep 17 00:00:00 2001 From: David Rose Date: Thu, 29 Dec 2011 22:23:14 +0000 Subject: [PATCH] a few checks against bad data --- panda/src/grutil/pfmFile.I | 1 + panda/src/grutil/pfmFile.cxx | 11 ++++++++--- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/panda/src/grutil/pfmFile.I b/panda/src/grutil/pfmFile.I index 9cbd4d0ab5..42f2b48621 100755 --- a/panda/src/grutil/pfmFile.I +++ b/panda/src/grutil/pfmFile.I @@ -109,6 +109,7 @@ get_point(int x, int y) const { //////////////////////////////////////////////////////////////////// INLINE void PfmFile:: set_point(int x, int y, const LVecBase3 &point) { + nassertv(!point.is_nan()); nassertv(x >= 0 && x < _x_size); nassertv(y >= 0 && y < _y_size); _table[y * _x_size + x] = point; diff --git a/panda/src/grutil/pfmFile.cxx b/panda/src/grutil/pfmFile.cxx index 9f4c950273..003f05f22e 100755 --- a/panda/src/grutil/pfmFile.cxx +++ b/panda/src/grutil/pfmFile.cxx @@ -208,7 +208,9 @@ read(istream &in) { LittleEndian value(&data, sizeof(data)); PN_float32 result; value.store_value(&result, sizeof(result)); - point[ci] = result; + if (!cnan(result)) { + point[ci] = result; + } } _table.push_back(point); } @@ -221,7 +223,9 @@ read(istream &in) { BigEndian value(&data, sizeof(data)); PN_float32 result; value.store_value(&result, sizeof(result)); - point[ci] = result; + if (!cnan(result)) { + point[ci] = result; + } } _table.push_back(point); } @@ -841,7 +845,7 @@ make_vis_mesh_geom(GeomNode *gnode, bool inverted) const { for (int xi = x_begin; xi < x_end; ++xi) { const LPoint3 &point = get_point(xi, yi); LPoint2 uv(PN_stdfloat(xi) / PN_stdfloat(_x_size - 1), - PN_stdfloat(yi) / PN_stdfloat(_y_size - 1)); + PN_stdfloat(yi) / PN_stdfloat(_y_size - 1)); if (_vis_inverse) { vertex.add_data2(uv); @@ -879,6 +883,7 @@ make_vis_mesh_geom(GeomNode *gnode, bool inverted) const { n[2] += v0[0] * v1[1] - v0[1] * v1[0]; } n.normalize(); + nassertv(!n.is_nan()); if (inverted) { n = -n; }