[Bf-blender-cvs] [4dfbaa34c98] master: PyAPI: allow any vector sequence for poly_3d_calc(..)

Campbell Barton noreply at git.blender.org
Tue May 18 06:16:46 CEST 2021


Commit: 4dfbaa34c98acd5940d7fb85b8d1f54ea7e4451e
Author: Campbell Barton
Date:   Tue May 18 14:09:03 2021 +1000
Branches: master
https://developer.blender.org/rB4dfbaa34c98acd5940d7fb85b8d1f54ea7e4451e

PyAPI: allow any vector sequence for poly_3d_calc(..)

Previously only vectors were accepted for the second point argument:
mathutils.interpolate.poly_3d_calc()

===================================================================

M	source/blender/python/mathutils/mathutils_interpolate.c

===================================================================

diff --git a/source/blender/python/mathutils/mathutils_interpolate.c b/source/blender/python/mathutils/mathutils_interpolate.c
index 6abb66899d5..bb6a7720c44 100644
--- a/source/blender/python/mathutils/mathutils_interpolate.c
+++ b/source/blender/python/mathutils/mathutils_interpolate.c
@@ -54,24 +54,15 @@ static PyObject *M_Interpolate_poly_3d_calc(PyObject *UNUSED(self), PyObject *ar
   PyObject *point, *veclist, *ret;
   int i;
 
-  if (!PyArg_ParseTuple(args, "OO!:poly_3d_calc", &veclist, &vector_Type, &point)) {
+  if (!PyArg_ParseTuple(args, "OO:poly_3d_calc", &veclist, &point)) {
     return NULL;
   }
 
-  if (BaseMath_ReadCallback((VectorObject *)point) == -1) {
+  if (mathutils_array_parse(
+          fp, 2, 3 | MU_ARRAY_ZERO, point, "pt must be a 2-3 dimensional vector") == -1) {
     return NULL;
   }
 
-  fp[0] = ((VectorObject *)point)->vec[0];
-  fp[1] = ((VectorObject *)point)->vec[1];
-  if (((VectorObject *)point)->size > 2) {
-    fp[2] = ((VectorObject *)point)->vec[2];
-  }
-  else {
-    /* if its a 2d vector then set the z to be zero */
-    fp[2] = 0.0f;
-  }
-
   len = mathutils_array_parse_alloc_v(((float **)&vecs), 3, veclist, __func__);
   if (len == -1) {
     return NULL;



More information about the Bf-blender-cvs mailing list