From 2d4170963b7a85ac0daf7e7236ff9224ff5e4476 Mon Sep 17 00:00:00 2001 From: David Rose Date: Tue, 31 Jan 2012 23:45:22 +0000 Subject: [PATCH] a few more degenerate cases --- panda/src/grutil/pfmFile.cxx | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/panda/src/grutil/pfmFile.cxx b/panda/src/grutil/pfmFile.cxx index bacc9d2133..f7c583a03e 100755 --- a/panda/src/grutil/pfmFile.cxx +++ b/panda/src/grutil/pfmFile.cxx @@ -458,8 +458,15 @@ resize(int new_x_size, int new_y_size) { double from_x0, from_x1, from_y0, from_y1; - double x_scale = (double)(_x_size - 1) / (double)(new_x_size - 1); - double y_scale = (double)(_y_size - 1) / (double)(new_y_size - 1); + double x_scale = 1.0; + double y_scale = 1.0; + + if (new_x_size > 1) { + x_scale = (double)(_x_size - 1) / (double)(new_x_size - 1); + } + if (new_y_size > 1) { + y_scale = (double)(_y_size - 1) / (double)(new_y_size - 1); + } from_y0 = 0.0; for (int to_y = 0; to_y < new_y_size; ++to_y) { @@ -992,7 +999,10 @@ box_filter_region(LPoint3 &result, result = LPoint3::zero(); double coverage = 0.0; - assert(y0 >= 0.0 && y1 >= 0.0); + if (x1 < x0 || y1 < y0) { + return; + } + nassertv(y0 >= 0.0 && y1 >= 0.0); int y = (int)y0; // Get the first (partial) row