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:
Diffstat (limited to 'source/blender/python/mathutils/mathutils_Vector.c')
-rw-r--r--source/blender/python/mathutils/mathutils_Vector.c9
1 files changed, 8 insertions, 1 deletions
diff --git a/source/blender/python/mathutils/mathutils_Vector.c b/source/blender/python/mathutils/mathutils_Vector.c
index 07bda4c2b91..54044b62e04 100644
--- a/source/blender/python/mathutils/mathutils_Vector.c
+++ b/source/blender/python/mathutils/mathutils_Vector.c
@@ -2268,6 +2268,11 @@ static int Vector_swizzle_set(VectorObject *self, PyObject *value, void *closure
axis_from = 0;
swizzleClosure = GET_INT_FROM_POINTER(closure);
+ /* We must first copy current vec into tvec, else some org values may be lost.
+ * See [#31760].
+ * Assuming self->size can't be higher than MAX_DIMENSIONS! */
+ memcpy(tvec, self->vec, self->size * sizeof(float));
+
while (swizzleClosure & SWIZZLE_VALID_AXIS) {
axis_to = swizzleClosure & SWIZZLE_AXIS;
tvec[axis_to] = vec_assign[axis_from];
@@ -2275,7 +2280,9 @@ static int Vector_swizzle_set(VectorObject *self, PyObject *value, void *closure
axis_from++;
}
- memcpy(self->vec, tvec, axis_from * sizeof(float));
+ /* We must copy back the whole tvec into vec, else some changes may be lost (e.g. xz...).
+ * See [#31760]. */
+ memcpy(self->vec, tvec, self->size * sizeof(float));
/* continue with BaseMathObject_WriteCallback at the end */
if (BaseMath_WriteCallback(self) == -1)