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>2018-07-27 10:41:58 +0300
committerCampbell Barton <ideasman42@gmail.com>2018-07-27 10:41:58 +0300
commit0093212be983c20ca7030bedec5699b79a663071 (patch)
tree4a89e4a037d0e1240de0b32c9b3886fa184df0d6 /source/blender/python
parent2032e4ec9edd33235bb496e7828dcc2fd7210ac0 (diff)
parentfe8d8aa27e26f1f8e4d5e1e3fcb6fc6288ebf226 (diff)
Merge branch 'master' into blender2.8
Diffstat (limited to 'source/blender/python')
-rw-r--r--source/blender/python/mathutils/mathutils_Vector.c16
1 files changed, 5 insertions, 11 deletions
diff --git a/source/blender/python/mathutils/mathutils_Vector.c b/source/blender/python/mathutils/mathutils_Vector.c
index a06a63c8067..6a40f22d9df 100644
--- a/source/blender/python/mathutils/mathutils_Vector.c
+++ b/source/blender/python/mathutils/mathutils_Vector.c
@@ -1127,23 +1127,17 @@ PyDoc_STRVAR(Vector_project_doc,
static PyObject *Vector_project(VectorObject *self, PyObject *value)
{
const int size = self->size;
- float tvec[MAX_DIMENSIONS];
- float vec[MAX_DIMENSIONS];
+ float *tvec;
double dot = 0.0f, dot2 = 0.0f;
int x;
- if (mathutils_array_parse(tvec, size, size, value, "Vector.project(other), invalid 'other' arg") == -1)
+ if (BaseMath_ReadCallback(self) == -1)
return NULL;
- if (self->size > 4) {
- PyErr_SetString(PyExc_ValueError,
- "Vector must be 2D, 3D or 4D");
+ if (mathutils_array_parse_alloc(&tvec, size, value, "Vector.project(other), invalid 'other' arg") == -1) {
return NULL;
}
- if (BaseMath_ReadCallback(self) == -1)
- return NULL;
-
/* get dot products */
for (x = 0; x < size; x++) {
dot += (double)(self->vec[x] * tvec[x]);
@@ -1152,9 +1146,9 @@ static PyObject *Vector_project(VectorObject *self, PyObject *value)
/* projection */
dot /= dot2;
for (x = 0; x < size; x++) {
- vec[x] = (float)dot * tvec[x];
+ tvec[x] *= (float)dot;
}
- return Vector_CreatePyObject(vec, size, Py_TYPE(self));
+ return Vector_CreatePyObject_alloc(tvec, size, Py_TYPE(self));
}
PyDoc_STRVAR(Vector_lerp_doc,