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>2015-08-04 11:34:20 +0300
committerCampbell Barton <ideasman42@gmail.com>2015-08-04 11:49:42 +0300
commitcff288cf3a0d71b610fa20875a321ea3b8db2388 (patch)
tree32d172a1953c6f5777690e616a8581fd8801be53 /source/blender/python/mathutils/mathutils_geometry.c
parent62c8f46ab6f16f99bcf848936a690e01f4c9e770 (diff)
Use PyC_ParseBool to parse bools
This could cause problems since they could be any int, then passed directly to internal functions that assume bools.
Diffstat (limited to 'source/blender/python/mathutils/mathutils_geometry.c')
-rw-r--r--source/blender/python/mathutils/mathutils_geometry.c30
1 files changed, 18 insertions, 12 deletions
diff --git a/source/blender/python/mathutils/mathutils_geometry.c b/source/blender/python/mathutils/mathutils_geometry.c
index ae5c058406f..2684371fd6a 100644
--- a/source/blender/python/mathutils/mathutils_geometry.c
+++ b/source/blender/python/mathutils/mathutils_geometry.c
@@ -42,6 +42,8 @@
#include "BLI_math.h"
#include "BLI_utildefines.h"
+
+#include "../generic/py_capi_utils.h"
#include "../generic/python_utildefines.h"
/*-------------------------DOC STRINGS ---------------------------*/
@@ -77,12 +79,14 @@ static PyObject *M_Geometry_intersect_ray_tri(PyObject *UNUSED(self), PyObject *
PyObject *py_ray, *py_ray_off, *py_tri[3];
float dir[3], orig[3], tri[3][3], e1[3], e2[3], pvec[3], tvec[3], qvec[3];
float det, inv_det, u, v, t;
- int clip = 1;
+ bool clip = true;
int i;
if (!PyArg_ParseTuple(
- args, "OOOOO|i:intersect_ray_tri",
- UNPACK3_EX(&, py_tri, ), &py_ray, &py_ray_off, &clip))
+ args, "OOOOO|O&:intersect_ray_tri",
+ UNPACK3_EX(&, py_tri, ),
+ &py_ray, &py_ray_off,
+ PyC_ParseBool, &clip))
{
return NULL;
}
@@ -477,12 +481,12 @@ static PyObject *M_Geometry_intersect_line_plane(PyObject *UNUSED(self), PyObjec
PyObject *py_line_a, *py_line_b, *py_plane_co, *py_plane_no;
float line_a[3], line_b[3], plane_co[3], plane_no[3];
float isect[3];
- int no_flip = false;
+ bool no_flip = false;
if (!PyArg_ParseTuple(
- args, "OOOO|i:intersect_line_plane",
+ args, "OOOO|O&:intersect_line_plane",
&py_line_a, &py_line_b, &py_plane_co, &py_plane_no,
- &no_flip))
+ PyC_ParseBool, &no_flip))
{
return NULL;
}
@@ -589,14 +593,15 @@ static PyObject *M_Geometry_intersect_line_sphere(PyObject *UNUSED(self), PyObje
PyObject *py_line_a, *py_line_b, *py_sphere_co;
float line_a[3], line_b[3], sphere_co[3];
float sphere_radius;
- int clip = true;
+ bool clip = true;
float isect_a[3];
float isect_b[3];
if (!PyArg_ParseTuple(
- args, "OOOf|i:intersect_line_sphere",
- &py_line_a, &py_line_b, &py_sphere_co, &sphere_radius, &clip))
+ args, "OOOf|O&:intersect_line_sphere",
+ &py_line_a, &py_line_b, &py_sphere_co, &sphere_radius,
+ PyC_ParseBool, &clip))
{
return NULL;
}
@@ -661,14 +666,15 @@ static PyObject *M_Geometry_intersect_line_sphere_2d(PyObject *UNUSED(self), PyO
PyObject *py_line_a, *py_line_b, *py_sphere_co;
float line_a[2], line_b[2], sphere_co[2];
float sphere_radius;
- int clip = true;
+ bool clip = true;
float isect_a[2];
float isect_b[2];
if (!PyArg_ParseTuple(
- args, "OOOf|i:intersect_line_sphere_2d",
- &py_line_a, &py_line_b, &py_sphere_co, &sphere_radius, &clip))
+ args, "OOOf|O&:intersect_line_sphere_2d",
+ &py_line_a, &py_line_b, &py_sphere_co, &sphere_radius,
+ PyC_ParseBool, &clip))
{
return NULL;
}