diff options
author | Campbell Barton <ideasman42@gmail.com> | 2012-12-27 09:08:16 +0400 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2012-12-27 09:08:16 +0400 |
commit | f9b2788ddc5ab09bac12c9e2da10213eb3383650 (patch) | |
tree | 78bb77be54710e90268955ca0c417764dc9cb7bd /source/blender/blenlib | |
parent | 89364fd0fa5e55c42bee6c245c4b5e00b481338a (diff) |
correction for poly_to_tri_count() when given zero poly count.
Diffstat (limited to 'source/blender/blenlib')
-rw-r--r-- | source/blender/blenlib/intern/math_geom_inline.c | 13 |
1 files changed, 10 insertions, 3 deletions
diff --git a/source/blender/blenlib/intern/math_geom_inline.c b/source/blender/blenlib/intern/math_geom_inline.c index 9bb824be85e..f32b477787b 100644 --- a/source/blender/blenlib/intern/math_geom_inline.c +++ b/source/blender/blenlib/intern/math_geom_inline.c @@ -173,9 +173,16 @@ MINLINE int min_axis_v3(const float vec[3]) */ MINLINE int poly_to_tri_count(const int poly_count, const int corner_count) { - const double poly_count_d = (double)poly_count; - const double corner_count_d = (double)corner_count; - return (int)((((corner_count_d / poly_count_d) - 2.0) * poly_count_d) + 0.5); + if (poly_count != 0) { + const double poly_count_d = (double)poly_count; + const double corner_count_d = (double)corner_count; + BLI_assert(poly_count > 0); + BLI_assert(corner_count > 0); + return (int)((((corner_count_d / poly_count_d) - 2.0) * poly_count_d) + 0.5); + } + else { + return 0; + } } #endif /* __MATH_GEOM_INLINE_C__ */ |