Fix T68112: Align View on object add is broken
No need to use BKE_object_where_is_calc() in this case: there is no parenting or constraint system involved on object add. So simply use direct object matrix calculation from it's local transform. No need in dependency graph either in this case.
This commit is contained in:
@@ -606,7 +606,7 @@ static void txt_add_object(bContext *C, TextLine *firstline, int totline, const
|
||||
base = view_layer->basact;
|
||||
|
||||
/* seems to assume view align ? TODO - look into this, could be an operator option */
|
||||
ED_object_base_init_transform(C, base, NULL, rot);
|
||||
ED_object_base_init_transform_on_add(base->object, NULL, rot);
|
||||
|
||||
BKE_object_where_is_calc(depsgraph, scene, obedit);
|
||||
|
||||
|
||||
@@ -197,10 +197,9 @@ void ED_object_sculptmode_exit(struct bContext *C, struct Depsgraph *depsgraph);
|
||||
void ED_object_location_from_view(struct bContext *C, float loc[3]);
|
||||
void ED_object_rotation_from_quat(float rot[3], const float quat[4], const char align_axis);
|
||||
void ED_object_rotation_from_view(struct bContext *C, float rot[3], const char align_axis);
|
||||
void ED_object_base_init_transform(struct bContext *C,
|
||||
struct Base *base,
|
||||
const float loc[3],
|
||||
const float rot[3]);
|
||||
void ED_object_base_init_transform_on_add(struct Object *obejct,
|
||||
const float loc[3],
|
||||
const float rot[3]);
|
||||
float ED_object_new_primitive_matrix(struct bContext *C,
|
||||
struct Object *editob,
|
||||
const float loc[3],
|
||||
|
||||
@@ -232,29 +232,17 @@ void ED_object_rotation_from_view(bContext *C, float rot[3], const char align_ax
|
||||
}
|
||||
}
|
||||
|
||||
void ED_object_base_init_transform(bContext *C, Base *base, const float loc[3], const float rot[3])
|
||||
void ED_object_base_init_transform_on_add(Object *object, const float loc[3], const float rot[3])
|
||||
{
|
||||
Object *ob = base->object;
|
||||
Scene *scene = CTX_data_scene(C);
|
||||
Depsgraph *depsgraph = CTX_data_ensure_evaluated_depsgraph(C);
|
||||
|
||||
if (!scene) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (loc) {
|
||||
copy_v3_v3(ob->loc, loc);
|
||||
copy_v3_v3(object->loc, loc);
|
||||
}
|
||||
|
||||
if (rot) {
|
||||
copy_v3_v3(ob->rot, rot);
|
||||
copy_v3_v3(object->rot, rot);
|
||||
}
|
||||
|
||||
Scene *scene_eval = DEG_get_evaluated_scene(depsgraph);
|
||||
Object *object_eval = DEG_get_evaluated_object(depsgraph, ob);
|
||||
BKE_object_transform_copy(object_eval, ob);
|
||||
BKE_object_where_is_calc(depsgraph, scene_eval, object_eval);
|
||||
BKE_object_transform_copy(ob, object_eval);
|
||||
BKE_object_to_mat4(object, object->obmat);
|
||||
}
|
||||
|
||||
/* Uses context to figure out transform for primitive.
|
||||
@@ -494,7 +482,7 @@ Object *ED_object_add_type(bContext *C,
|
||||
ED_object_base_activate(C, view_layer->basact);
|
||||
|
||||
/* more editor stuff */
|
||||
ED_object_base_init_transform(C, view_layer->basact, loc, rot);
|
||||
ED_object_base_init_transform_on_add(ob, loc, rot);
|
||||
|
||||
/* TODO(sergey): This is weird to manually tag objects for update, better to
|
||||
* use DEG_id_tag_update here perhaps.
|
||||
|
||||
Reference in New Issue
Block a user