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:
Diffstat (limited to 'source/blender/editors/object/object_add.c')
-rw-r--r--source/blender/editors/object/object_add.c75
1 files changed, 42 insertions, 33 deletions
diff --git a/source/blender/editors/object/object_add.c b/source/blender/editors/object/object_add.c
index 7891f59a62e..a8eaa663285 100644
--- a/source/blender/editors/object/object_add.c
+++ b/source/blender/editors/object/object_add.c
@@ -410,45 +410,54 @@ bool ED_object_add_generic_get_opts(bContext *C,
rot = _rot;
}
- prop = RNA_struct_find_property(op->ptr, "align");
- int alignment = RNA_property_enum_get(op->ptr, prop);
- bool alignment_set = RNA_property_is_set(op->ptr, prop);
-
if (RNA_struct_property_is_set(op->ptr, "rotation")) {
+ /* If rotation is set, always use it. Alignment (and corresponding user preference)
+ * can be ignored since this is in world space anyways.
+ * To not confuse (e.g. on redo), dont set it to ALIGN_WORLD in the op UI though. */
*is_view_aligned = false;
- RNA_property_enum_set(op->ptr, prop, ALIGN_WORLD);
- alignment = ALIGN_WORLD;
- }
- else if (alignment_set) {
- *is_view_aligned = alignment == ALIGN_VIEW;
+ RNA_float_get_array(op->ptr, "rotation", rot);
}
else {
- *is_view_aligned = (U.flag & USER_ADD_VIEWALIGNED) != 0;
- if (*is_view_aligned) {
- RNA_property_enum_set(op->ptr, prop, ALIGN_VIEW);
- alignment = ALIGN_VIEW;
+ int alignment = ALIGN_WORLD;
+ prop = RNA_struct_find_property(op->ptr, "align");
+
+ if (RNA_property_is_set(op->ptr, prop)) {
+ /* If alignment is set, always use it. */
+ *is_view_aligned = alignment == ALIGN_VIEW;
+ alignment = RNA_property_enum_get(op->ptr, prop);
}
- else if (U.flag & USER_ADD_CURSORALIGNED) {
- RNA_property_enum_set(op->ptr, prop, ALIGN_CURSOR);
- alignment = ALIGN_CURSOR;
+ else {
+ /* If alignment is not set, use User Preferences. */
+ *is_view_aligned = (U.flag & USER_ADD_VIEWALIGNED) != 0;
+ if (*is_view_aligned) {
+ RNA_property_enum_set(op->ptr, prop, ALIGN_VIEW);
+ alignment = ALIGN_VIEW;
+ }
+ else if ((U.flag & USER_ADD_CURSORALIGNED) != 0) {
+ RNA_property_enum_set(op->ptr, prop, ALIGN_CURSOR);
+ alignment = ALIGN_CURSOR;
+ }
+ else {
+ RNA_property_enum_set(op->ptr, prop, ALIGN_WORLD);
+ alignment = ALIGN_WORLD;
+ }
}
- }
-
- switch (alignment) {
- case ALIGN_WORLD:
- RNA_float_get_array(op->ptr, "rotation", rot);
- break;
- case ALIGN_VIEW:
- ED_object_rotation_from_view(C, rot, view_align_axis);
- RNA_float_set_array(op->ptr, "rotation", rot);
- break;
- case ALIGN_CURSOR: {
- const Scene *scene = CTX_data_scene(C);
- float tmat[3][3];
- BKE_scene_cursor_rot_to_mat3(&scene->cursor, tmat);
- mat3_normalized_to_eul(rot, tmat);
- RNA_float_set_array(op->ptr, "rotation", rot);
- break;
+ switch (alignment) {
+ case ALIGN_WORLD:
+ RNA_float_get_array(op->ptr, "rotation", rot);
+ break;
+ case ALIGN_VIEW:
+ ED_object_rotation_from_view(C, rot, view_align_axis);
+ RNA_float_set_array(op->ptr, "rotation", rot);
+ break;
+ case ALIGN_CURSOR: {
+ const Scene *scene = CTX_data_scene(C);
+ float tmat[3][3];
+ BKE_scene_cursor_rot_to_mat3(&scene->cursor, tmat);
+ mat3_normalized_to_eul(rot, tmat);
+ RNA_float_set_array(op->ptr, "rotation", rot);
+ break;
+ }
}
}
}