Fix #120862: Add eps arguments to points_in_planes #120910

Merged
YimingWu merged 2 commits from ChengduLittleA/blender:fix-120862 into main 2024-04-24 09:38:31 +02:00
1 changed files with 8 additions and 5 deletions

View File

@ -1146,13 +1146,17 @@ static void points_in_planes_fn(const float co[3], int i, int j, int k, void *us
PyDoc_STRVAR(
/* Wrap. */
M_Geometry_points_in_planes_doc,
".. function:: points_in_planes(planes)\n"
".. function:: points_in_planes(planes, epsilon_coplanar=1e-4f, epsilon_isect=1e-6f)\n"
ChengduLittleA marked this conversation as resolved Outdated

Use full prefix epsilon_ (although these aren't named), epsilon is used elsewhere in the mathutils API.

Use full prefix `epsilon_` (although these aren't named), epsilon is used elsewhere in the mathutils API.
"\n"
" Returns a list of points inside all planes given and a list of index values for "
"the planes used.\n"
"\n"
" :arg planes: List of planes (4D vectors).\n"
" :type planes: list of :class:`mathutils.Vector`\n"
" :arg epsilon_coplanar: Epsilon value for interpreting plane pairs as co-plannar.\n"
" :type epsilon_coplanar: float\n"
" :arg epsilon_isect: Epsilon value for intersection.\n"
" :type epsilon_isect: float\n"
" :return: two lists, once containing the vertices inside the planes, another "
"containing the plane indices used\n"
" :rtype: pair of lists\n");
@ -1160,9 +1164,11 @@ static PyObject *M_Geometry_points_in_planes(PyObject * /*self*/, PyObject *args
{
PyObject *py_planes;
float(*planes)[4];
float eps_coplanar = 1e-4f;
float eps_isect = 1e-6f;
uint planes_len;
if (!PyArg_ParseTuple(args, "O:points_in_planes", &py_planes)) {
if (!PyArg_ParseTuple(args, "O|ff:points_in_planes", &py_planes, &eps_coplanar, &eps_isect)) {
return nullptr;
}
@ -1183,9 +1189,6 @@ static PyObject *M_Geometry_points_in_planes(PyObject * /*self*/, PyObject *args
memset(user_data.planes_used, 0, sizeof(char) * planes_len);
const float eps_coplanar = 1e-4f;
const float eps_isect = 1e-6f;
const bool has_isect = isect_planes_v3_fn(
planes, planes_len, eps_coplanar, eps_isect, points_in_planes_fn, &user_data);
PyMem_Free(planes);