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
path: root/source
diff options
context:
space:
mode:
authorCampbell Barton <ideasman42@gmail.com>2012-08-28 15:27:46 +0400
committerCampbell Barton <ideasman42@gmail.com>2012-08-28 15:27:46 +0400
commit7aeaeaf37805d7d906787e5ad5d0d76817dd0bc5 (patch)
tree417a06e6a3d5497883b917021b6d4ed4950d59e6 /source
parent8fd747114388dbbb10733415eaa707f9801abf1a (diff)
fix bug in mathutils.geometry.intersect_point_line() where 4D vectors were treated as 2D.
also change behavior to return a 2d vector when all args are 2D.
Diffstat (limited to 'source')
-rw-r--r--source/blender/python/mathutils/mathutils_geometry.c15
1 files changed, 8 insertions, 7 deletions
diff --git a/source/blender/python/mathutils/mathutils_geometry.c b/source/blender/python/mathutils/mathutils_geometry.c
index 524515ac460..19f9aa2dc88 100644
--- a/source/blender/python/mathutils/mathutils_geometry.c
+++ b/source/blender/python/mathutils/mathutils_geometry.c
@@ -728,6 +728,7 @@ static PyObject *M_Geometry_intersect_point_line(PyObject *UNUSED(self), PyObjec
float pt_in[3], pt_out[3], l1[3], l2[3];
float lambda;
PyObject *ret;
+ int size = 2;
if (!PyArg_ParseTuple(args, "O!O!O!:intersect_point_line",
&vector_Type, &pt,
@@ -745,20 +746,20 @@ static PyObject *M_Geometry_intersect_point_line(PyObject *UNUSED(self), PyObjec
}
/* accept 2d verts */
- if (pt->size == 3) { copy_v3_v3(pt_in, pt->vec); }
- else { pt_in[2] = 0.0f; copy_v2_v2(pt_in, pt->vec); }
+ if (pt->size >= 3) { copy_v3_v3(pt_in, pt->vec); size = 3; }
+ else { copy_v2_v2(pt_in, pt->vec); pt_in[2] = 0.0f; }
- if (line_1->size == 3) { copy_v3_v3(l1, line_1->vec); }
- else { l1[2] = 0.0f; copy_v2_v2(l1, line_1->vec); }
+ if (line_1->size >= 3) { copy_v3_v3(l1, line_1->vec); size = 3; }
+ else { copy_v2_v2(l1, line_1->vec); l1[2] = 0.0f; }
- if (line_2->size == 3) { copy_v3_v3(l2, line_2->vec); }
- else { l2[2] = 0.0f; copy_v2_v2(l2, line_2->vec); }
+ if (line_2->size >= 3) { copy_v3_v3(l2, line_2->vec); size = 3; }
+ else { copy_v2_v2(l2, line_2->vec); l2[2] = 0.0f; }
/* do the calculation */
lambda = closest_to_line_v3(pt_out, pt_in, l1, l2);
ret = PyTuple_New(2);
- PyTuple_SET_ITEM(ret, 0, Vector_CreatePyObject(pt_out, 3, Py_NEW, NULL));
+ PyTuple_SET_ITEM(ret, 0, Vector_CreatePyObject(pt_out, size, Py_NEW, NULL));
PyTuple_SET_ITEM(ret, 1, PyFloat_FromDouble(lambda));
return ret;
}