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>2013-08-23 18:37:22 +0400
committerCampbell Barton <ideasman42@gmail.com>2013-08-23 18:37:22 +0400
commit09ff49755fc84a0dd4214099a0dd47facba83288 (patch)
treee317ad76b20daf06484a4e76004030cf0a5fc921 /source/blender/python
parent01e22d1b9f3606d97f06c2d8a2bc969214322e9c (diff)
math api edits - replace point-normal form for a plane with dist_to_plane_v3()
also correct python mathutils api, was missing vector checks.
Diffstat (limited to 'source/blender/python')
-rw-r--r--source/blender/python/mathutils/mathutils_geometry.c24
1 files changed, 23 insertions, 1 deletions
diff --git a/source/blender/python/mathutils/mathutils_geometry.c b/source/blender/python/mathutils/mathutils_geometry.c
index 8509c46b395..2d4aa988db2 100644
--- a/source/blender/python/mathutils/mathutils_geometry.c
+++ b/source/blender/python/mathutils/mathutils_geometry.c
@@ -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);