Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCampbell Barton <ideasman42@gmail.com>2012-12-27 09:08:16 +0400
committerCampbell Barton <ideasman42@gmail.com>2012-12-27 09:08:16 +0400
commitf9b2788ddc5ab09bac12c9e2da10213eb3383650 (patch)
tree78bb77be54710e90268955ca0c417764dc9cb7bd /source/blender
parent89364fd0fa5e55c42bee6c245c4b5e00b481338a (diff)
correction for poly_to_tri_count() when given zero poly count.
Diffstat (limited to 'source/blender')
-rw-r--r--source/blender/blenlib/intern/math_geom_inline.c13
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__ */