math api edits - replace point-normal form for a plane with dist_to_plane_v3()

also correct python mathutils api, was missing vector checks.
This commit is contained in:
2013-08-23 14:37:22 +00:00
parent 01e22d1b9f
commit 09ff49755f
5 changed files with 40 additions and 25 deletions

View File

@@ -981,6 +981,7 @@ PyDoc_STRVAR(M_Geometry_distance_point_to_plane_doc,
static PyObject *M_Geometry_distance_point_to_plane(PyObject *UNUSED(self), PyObject *args)
{
VectorObject *pt, *plene_co, *plane_no;
float plane[4];
if (!PyArg_ParseTuple(args, "O!O!O!:distance_point_to_plane",
&vector_Type, &pt,
@@ -990,6 +991,15 @@ static PyObject *M_Geometry_distance_point_to_plane(PyObject *UNUSED(self), PyOb
return NULL;
}
if (pt->size != 3 ||
plene_co->size != 3 ||
plane_no->size != 3)
{
PyErr_SetString(PyExc_ValueError,
"One of more of the vector arguments wasn't a 3D vector");
return NULL;
}
if (BaseMath_ReadCallback(pt) == -1 ||
BaseMath_ReadCallback(plene_co) == -1 ||
BaseMath_ReadCallback(plane_no) == -1)
@@ -997,7 +1007,8 @@ static PyObject *M_Geometry_distance_point_to_plane(PyObject *UNUSED(self), PyOb
return NULL;
}
return PyFloat_FromDouble(dist_to_plane_v3(pt->vec, plene_co->vec, plane_no->vec));
plane_from_point_normal_v3(plane, plene_co->vec, plane_no->vec);
return PyFloat_FromDouble(dist_to_plane_v3(pt->vec, plane));
}
PyDoc_STRVAR(M_Geometry_barycentric_transform_doc,
@@ -1054,6 +1065,17 @@ static PyObject *M_Geometry_barycentric_transform(PyObject *UNUSED(self), PyObje
return NULL;
}
if (BaseMath_ReadCallback(vec_pt) == -1 ||
BaseMath_ReadCallback(vec_t1_src) == -1 ||
BaseMath_ReadCallback(vec_t2_src) == -1 ||
BaseMath_ReadCallback(vec_t3_src) == -1 ||
BaseMath_ReadCallback(vec_t1_tar) == -1 ||
BaseMath_ReadCallback(vec_t2_tar) == -1 ||
BaseMath_ReadCallback(vec_t3_tar) == -1)
{
return NULL;
}
barycentric_transform(vec, vec_pt->vec,
vec_t1_tar->vec, vec_t2_tar->vec, vec_t3_tar->vec,
vec_t1_src->vec, vec_t2_src->vec, vec_t3_src->vec);