diff options
author | Howard Trickey <howard.trickey@gmail.com> | 2021-07-18 22:10:34 +0300 |
---|---|---|
committer | Howard Trickey <howard.trickey@gmail.com> | 2021-07-18 22:10:34 +0300 |
commit | 72d1ddfc9ce44afcf39226aa035249e2c29c1f5e (patch) | |
tree | 243190fd32cac2d8765937e2a2f4e7fefe454f28 /source/blender/python/mathutils/mathutils_geometry.c | |
parent | 4ed029fc02b022cb5ff28ed3ce70992c450d2be5 (diff) |
Make it optional to track input->output mapping in delaunay_2d_calc.
Some uses of delaunay_2d_calc don't need to know the original verts,
edges, and faces that correspond to output elements.
This change adds a "need_ids" value to the CDT input spec, default true,
which tracks the input ids only when true.
The python api mathutils.geometry.delaunay_2d_cdt gets an optional
final bool argument that is the value of need_ids. If the argument
is not supplied, it is true by default, so this won't break old uses
of the API.
On a sample text test, not tracking ids save about 30% of the runtime.
For most inputs the difference will not be so dramatic: it only really
kicks in if there are a lot of holes.
Diffstat (limited to 'source/blender/python/mathutils/mathutils_geometry.c')
-rw-r--r-- | source/blender/python/mathutils/mathutils_geometry.c | 15 |
1 files changed, 13 insertions, 2 deletions
diff --git a/source/blender/python/mathutils/mathutils_geometry.c b/source/blender/python/mathutils/mathutils_geometry.c index 88b3bddddf6..9b9c12aa1d1 100644 --- a/source/blender/python/mathutils/mathutils_geometry.c +++ b/source/blender/python/mathutils/mathutils_geometry.c @@ -1505,6 +1505,9 @@ static PyObject *list_of_lists_from_arrays(const int *array, PyObject *ret, *sublist; int i, j, sublist_len, sublist_start, val; + if (array == NULL) { + return PyList_New(0); + } ret = PyList_New(toplevel_len); for (i = 0; i < toplevel_len; i++) { sublist_len = len_table[i]; @@ -1561,6 +1564,7 @@ static PyObject *M_Geometry_delaunay_2d_cdt(PyObject *UNUSED(self), PyObject *ar PyObject *vert_coords, *edges, *faces, *item; int output_type; float epsilon; + bool need_ids = true; float(*in_coords)[2] = NULL; int(*in_edges)[2] = NULL; int *in_faces = NULL; @@ -1578,8 +1582,14 @@ static PyObject *M_Geometry_delaunay_2d_cdt(PyObject *UNUSED(self), PyObject *ar PyObject *ret_value = NULL; int i; - if (!PyArg_ParseTuple( - args, "OOOif:delaunay_2d_cdt", &vert_coords, &edges, &faces, &output_type, &epsilon)) { + if (!PyArg_ParseTuple(args, + "OOOif|p:delaunay_2d_cdt", + &vert_coords, + &edges, + &faces, + &output_type, + &epsilon, + &need_ids)) { return NULL; } @@ -1609,6 +1619,7 @@ static PyObject *M_Geometry_delaunay_2d_cdt(PyObject *UNUSED(self), PyObject *ar in.faces_start_table = in_faces_start_table; in.faces_len_table = in_faces_len_table; in.epsilon = epsilon; + in.need_ids = need_ids; res = BLI_delaunay_2d_cdt_calc(&in, output_type); |