From 6ff60d998295afe860872894e24215ff69cc3c5d Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Wed, 9 Oct 2019 17:08:51 +1100 Subject: PyAPI: avoid normal calculation for tessellate_polygon Use fixed normal for 2D input, no need to calculate it. --- source/blender/python/mathutils/mathutils_geometry.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'source/blender/python/mathutils/mathutils_geometry.c') diff --git a/source/blender/python/mathutils/mathutils_geometry.c b/source/blender/python/mathutils/mathutils_geometry.c index 13d36e5af91..f02fdf1fb80 100644 --- a/source/blender/python/mathutils/mathutils_geometry.c +++ b/source/blender/python/mathutils/mathutils_geometry.c @@ -1212,6 +1212,7 @@ static PyObject *M_Geometry_tessellate_polygon(PyObject *UNUSED(self), PyObject PyObject *tri_list; /*return this list of tri's */ PyObject *polyLine, *polyVec; int i, len_polylines, len_polypoints, ls_error = 0; + bool is_2d = true; /* Display #ListBase. */ ListBase dispbase = {NULL, NULL}; @@ -1269,6 +1270,7 @@ static PyObject *M_Geometry_tessellate_polygon(PyObject *UNUSED(self), PyObject fp[1] = ((VectorObject *)polyVec)->vec[1]; if (((VectorObject *)polyVec)->size > 2) { fp[2] = ((VectorObject *)polyVec)->vec[2]; + is_2d = false; } else { /* if its a 2d vector then set the z to be zero */ @@ -1295,8 +1297,7 @@ static PyObject *M_Geometry_tessellate_polygon(PyObject *UNUSED(self), PyObject } else if (totpoints) { /* now make the list to return */ - /* TODO, add normal arg */ - BKE_displist_fill(&dispbase, &dispbase, NULL, false); + BKE_displist_fill(&dispbase, &dispbase, is_2d ? ((const float[3]){0, 0, -1}) : NULL, false); /* The faces are stored in a new DisplayList * that's added to the head of the #ListBase. */ -- cgit v1.2.3