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:
authorBastien Montagne <montagne29@wanadoo.fr>2012-06-11 22:58:34 +0400
committerBastien Montagne <montagne29@wanadoo.fr>2012-06-11 22:58:34 +0400
commitcf0d350b5199b2a5ecc4b70e9fba51ae780b3711 (patch)
tree306fa6e2e982b0e952a06839004a04cfda841c63 /source/blender/python/mathutils
parentc945e03c7578a9cb044ceeb8f7f1e3b5c0e13e01 (diff)
Fixing first part of [#31760] Assignments not working properly for Object.dimensions
Problem was in fact that non-linear-contiguous axis assignement was broken (i.e. location.xy would work as expected, but location.xz would only affect .x part)... Now all possibilities should work fine. Did not try to fix the problem specific to obj.dimension (when assigning multiple times to this array, only the last one is taken into account - in fact, a simple print() shows that assigning to dimension is not taken into account immediately), not sure whether this is normal behavior, or if we need a specific "update" of some kind for this prop?
Diffstat (limited to 'source/blender/python/mathutils')
-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)