diff options
author | Sergey Sharybin <sergey.vfx@gmail.com> | 2019-03-01 12:25:14 +0300 |
---|---|---|
committer | Sergey Sharybin <sergey.vfx@gmail.com> | 2019-03-01 12:25:14 +0300 |
commit | 2a731adae7d481b258e551db30c640660e81b4ea (patch) | |
tree | 26c78f27bc2273d8c391040aca8ada133089aba0 | |
parent | 0451043045bb2c9a0194546a5d528dfc832b3c8b (diff) |
Fix T62015: Duplicating object, rotating, pivot point not used
Was caused by another fix in the area, and root to the wrong though that
transformation is only initialized from a fully evaluated dependency graph.
The latter one is not a case when changing transformation mode.
Solved by copying transform to an evaluated object.
-rw-r--r-- | source/blender/blenkernel/BKE_object.h | 3 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/object.c | 24 | ||||
-rw-r--r-- | source/blender/editors/transform/transform_conversions.c | 14 |
3 files changed, 36 insertions, 5 deletions
diff --git a/source/blender/blenkernel/BKE_object.h b/source/blender/blenkernel/BKE_object.h index 66a3d96cbdc..58d648b4aa4 100644 --- a/source/blender/blenkernel/BKE_object.h +++ b/source/blender/blenkernel/BKE_object.h @@ -209,6 +209,9 @@ void BKE_object_tfm_protected_restore( const ObjectTfmProtectedChannels *obtfm, const short protectflag); +void BKE_object_tfm_copy( + struct Object *object_dst, + const struct Object *object_src); void BKE_object_eval_reset( struct Object *ob_eval); diff --git a/source/blender/blenkernel/intern/object.c b/source/blender/blenkernel/intern/object.c index ddfed90fd97..3c57a5f7086 100644 --- a/source/blender/blenkernel/intern/object.c +++ b/source/blender/blenkernel/intern/object.c @@ -1855,6 +1855,30 @@ void BKE_object_tfm_protected_restore(Object *ob, } } +void BKE_object_tfm_copy(Object *object_dst, const Object *object_src) +{ +#define TFMCPY(_v) (object_dst->_v = object_src->_v) +#define TFMCPY3D(_v) copy_v3_v3(object_dst->_v, object_src->_v) +#define TFMCPY4D(_v) copy_v4_v4(object_dst->_v, object_src->_v) + + TFMCPY3D(loc); + TFMCPY3D(dloc); + TFMCPY3D(scale); + TFMCPY3D(dscale); + TFMCPY3D(rot); + TFMCPY3D(drot); + TFMCPY4D(quat); + TFMCPY4D(dquat); + TFMCPY3D(rotAxis); + TFMCPY3D(drotAxis); + TFMCPY(rotAngle); + TFMCPY(drotAngle); + +#undef TFMCPY +#undef TFMCPY3D +#undef TFMCPY4D +} + void BKE_object_to_mat3(Object *ob, float mat[3][3]) /* no parent */ { float smat[3][3]; diff --git a/source/blender/editors/transform/transform_conversions.c b/source/blender/editors/transform/transform_conversions.c index 4c23806c0aa..7dc934b4cc3 100644 --- a/source/blender/editors/transform/transform_conversions.c +++ b/source/blender/editors/transform/transform_conversions.c @@ -5816,6 +5816,10 @@ static void ObjectToTransData(TransInfo *t, TransData *td, Object *ob) Object *object_eval = DEG_get_evaluated_object(t->depsgraph, ob); if (skip_invert == false && constinv == false) { object_eval->transflag |= OB_NO_CONSTRAINTS; /* BKE_object_where_is_calc checks this */ + /* It is possiblre to have transform data initialization prior to a + * complete dependency graph evaluated. Happens, for example, when + * changing transformation mode. */ + BKE_object_tfm_copy(object_eval, ob); BKE_object_where_is_calc(t->depsgraph, t->scene, object_eval); object_eval->transflag &= ~OB_NO_CONSTRAINTS; } @@ -5825,11 +5829,11 @@ static void ObjectToTransData(TransInfo *t, TransData *td, Object *ob) /* Copy newly evaluated fields to the original object, similar to how * active dependency graph will do it. */ copy_m4_m4(ob->obmat, object_eval->obmat); - /* Hack over hack, looks like in some cases eval object has not yet been fully flushed or so? - * In some cases, macro operators starting transform just after creating a new object (OBJECT_OT_duplicate), - * if dupli flags are not protected, they can be erased here (see T61787). */ - ob->transflag = ((object_eval->transflag & ~(OB_DUPLI | OB_DUPLIFACES_SCALE | OB_DUPLIROT)) | - (ob->transflag & (OB_DUPLI | OB_DUPLIFACES_SCALE | OB_DUPLIROT))); + /* Only copy negative scale flag, this is the only flag which is modifed by + * the BKE_object_where_is_calc(). The rest of the flags we need to keep, + * otherwise we might loose dupli flags (see T61787). */ + ob->transflag &= ~OB_NEG_SCALE; + ob->transflag |= (object_eval->transflag & OB_NEG_SCALE); td->ob = ob; |