fix [#36107] Moving origin of instanced objects doesn't work properly

now use the active object first if its selected, this means when multiple instances are selected, using the active object gives a predictable outcome.
This commit is contained in:
2013-07-15 01:34:59 +00:00
parent 3c4c2478b6
commit d4ab6f3a9e
3 changed files with 29 additions and 7 deletions

View File

@@ -682,12 +682,17 @@ static int object_origin_set_exec(bContext *C, wmOperator *op)
{
Main *bmain = CTX_data_main(C);
Scene *scene = CTX_data_scene(C);
Object *obact = CTX_data_active_object(C);
Object *obedit = CTX_data_edit_object(C);
Object *tob;
float cursor[3], cent[3], cent_neg[3], centn[3];
int centermode = RNA_enum_get(op->ptr, "type");
int around = RNA_enum_get(op->ptr, "center"); /* initialized from v3d->around */
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;
@@ -746,12 +751,25 @@ static int object_origin_set_exec(bContext *C, wmOperator *op)
}
}
CTX_data_selected_editable_objects(C, &ctx_data_list);
/* reset flags */
CTX_DATA_BEGIN (C, Object *, ob, selected_editable_objects)
for (ctx_ob = ctx_data_list.first;
ctx_ob;
ctx_ob = ctx_ob->next)
{
Object *ob = ctx_ob->ptr.data;
ob->flag &= ~OB_DONE;
/* move active first */
if (ob == obact) {
ctx_ob_act = ctx_ob;
}
}
if (ctx_ob_act) {
BLI_rotatelist(&ctx_data_list, (LinkData *)ctx_ob_act);
}
CTX_DATA_END;
for (tob = bmain->object.first; tob; tob = tob->id.next) {
if (tob->data)
@@ -760,8 +778,12 @@ static int object_origin_set_exec(bContext *C, wmOperator *op)
((ID *)tob->dup_group)->flag &= ~LIB_DOIT;
}
CTX_DATA_BEGIN (C, Object *, ob, selected_editable_objects)
for (ctx_ob = ctx_data_list.first;
ctx_ob;
ctx_ob = ctx_ob->next)
{
Object *ob = ctx_ob->ptr.data;
if ((ob->flag & OB_DONE) == 0) {
int do_inverse_offset = FALSE;
ob->flag |= OB_DONE;
@@ -992,7 +1014,7 @@ static int object_origin_set_exec(bContext *C, wmOperator *op)
}
}
}
CTX_DATA_END;
BLI_freelistN(&ctx_data_list);
for (tob = bmain->object.first; tob; tob = tob->id.next)
if (tob->data && (((ID *)tob->data)->flag & LIB_DOIT))