diff options
author | Sergey Sharybin <sergey.vfx@gmail.com> | 2019-06-19 15:36:07 +0300 |
---|---|---|
committer | Sergey Sharybin <sergey.vfx@gmail.com> | 2019-06-19 17:44:36 +0300 |
commit | 1699de17bddb9f04f58af59f7651420287f27d52 (patch) | |
tree | 12b96db1aa0bd7cb8307b2d7e3338c793a300f82 /source/blender/editors | |
parent | 1fb545391665bcdf8b02545f846112a258e9b749 (diff) |
Fix order of modifications for Set Origin.
The logic of parent update is very similar to Apply Transform, so made it
so parents are handled before children.
Diffstat (limited to 'source/blender/editors')
-rw-r--r-- | source/blender/editors/object/object_transform.c | 33 |
1 files changed, 14 insertions, 19 deletions
diff --git a/source/blender/editors/object/object_transform.c b/source/blender/editors/object/object_transform.c index 8d7a421cad1..394fea2cf27 100644 --- a/source/blender/editors/object/object_transform.c +++ b/source/blender/editors/object/object_transform.c @@ -971,10 +971,6 @@ static int object_origin_set_exec(bContext *C, wmOperator *op) const float *cursor = scene->cursor.location; int centermode = RNA_enum_get(op->ptr, "type"); - ListBase ctx_data_list; - CollectionPointerLink *ctx_ob; - CollectionPointerLink *ctx_ob_act = NULL; - /* keep track of what is changed */ int tot_change = 0, tot_lib_error = 0, tot_multiuser_arm_error = 0; @@ -1043,23 +1039,24 @@ static int object_origin_set_exec(bContext *C, wmOperator *op) } } - CTX_data_selected_editable_objects(C, &ctx_data_list); + int num_objects; + Object **objects = sorted_selected_editable_objects(C, &num_objects); + if (objects == NULL) { + return OPERATOR_CANCELLED; + } /* reset flags */ - for (ctx_ob = ctx_data_list.first; ctx_ob; ctx_ob = ctx_ob->next) { - Object *ob = ctx_ob->ptr.data; + for (int object_index = 0; object_index < num_objects; ++object_index) { + Object *ob = objects[object_index]; ob->flag &= ~OB_DONE; /* move active first */ if (ob == obact) { - ctx_ob_act = ctx_ob; + memmove(&objects[1], objects, object_index); + objects[0] = ob; } } - if (ctx_ob_act) { - BLI_listbase_rotate_first(&ctx_data_list, (LinkData *)ctx_ob_act); - } - for (tob = bmain->objects.first; tob; tob = tob->id.next) { if (tob->data) { ((ID *)tob->data)->tag &= ~LIB_TAG_DOIT; @@ -1069,8 +1066,8 @@ static int object_origin_set_exec(bContext *C, wmOperator *op) } } - for (ctx_ob = ctx_data_list.first; ctx_ob; ctx_ob = ctx_ob->next) { - Object *ob = ctx_ob->ptr.data; + for (int object_index = 0; object_index < num_objects; ++object_index) { + Object *ob = objects[object_index]; if ((ob->flag & OB_DONE) == 0) { bool do_inverse_offset = false; @@ -1345,7 +1342,6 @@ static int object_origin_set_exec(bContext *C, wmOperator *op) /* offset other selected objects */ if (do_inverse_offset && (centermode != GEOMETRY_TO_ORIGIN)) { - CollectionPointerLink *ctx_link_other; float obmat[4][4]; /* was the object data modified @@ -1369,9 +1365,8 @@ static int object_origin_set_exec(bContext *C, wmOperator *op) //{ /* use existing context looper */ - for (ctx_link_other = ctx_data_list.first; ctx_link_other; - ctx_link_other = ctx_link_other->next) { - Object *ob_other = ctx_link_other->ptr.data; + for (int other_object_index = 0; other_object_index < num_objects; ++other_object_index) { + Object *ob_other = objects[other_object_index]; if ((ob_other->flag & OB_DONE) == 0 && ((ob->data && (ob->data == ob_other->data)) || @@ -1395,7 +1390,7 @@ static int object_origin_set_exec(bContext *C, wmOperator *op) } } } - BLI_freelistN(&ctx_data_list); + MEM_freeN(objects); for (tob = bmain->objects.first; tob; tob = tob->id.next) { if (tob->data && (((ID *)tob->data)->tag & LIB_TAG_DOIT)) { |