diff options
-rw-r--r-- | source/blender/editors/object/object_add.c | 75 | ||||
-rw-r--r-- | source/blender/editors/space_nla/space_nla.c | 8 | ||||
-rw-r--r-- | source/blender/makesrna/intern/rna_space.c | 2 |
3 files changed, 52 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; + } } } } diff --git a/source/blender/editors/space_nla/space_nla.c b/source/blender/editors/space_nla/space_nla.c index 5cd2a86adf8..e5f6b25ee25 100644 --- a/source/blender/editors/space_nla/space_nla.c +++ b/source/blender/editors/space_nla/space_nla.c @@ -340,6 +340,8 @@ static void nla_region_listener(wmWindow *UNUSED(win), case ND_OB_ACTIVE: case ND_FRAME: case ND_MARKERS: + case ND_LAYER_CONTENT: + case ND_OB_SELECT: ED_region_tag_redraw(ar); break; } @@ -349,6 +351,7 @@ static void nla_region_listener(wmWindow *UNUSED(win), case ND_BONE_ACTIVE: case ND_BONE_SELECT: case ND_KEYS: + case ND_DRAW: ED_region_tag_redraw(ar); break; } @@ -379,6 +382,8 @@ static void nla_main_region_listener(wmWindow *UNUSED(win), case ND_FRAME: case ND_FRAME_RANGE: case ND_MARKERS: + case ND_LAYER_CONTENT: + case ND_OB_SELECT: ED_region_tag_redraw(ar); break; } @@ -474,6 +479,8 @@ static void nla_channel_region_listener(wmWindow *UNUSED(win), case NC_SCENE: switch (wmn->data) { case ND_OB_ACTIVE: + case ND_LAYER_CONTENT: + case ND_OB_SELECT: ED_region_tag_redraw(ar); break; } @@ -483,6 +490,7 @@ static void nla_channel_region_listener(wmWindow *UNUSED(win), case ND_BONE_ACTIVE: case ND_BONE_SELECT: case ND_KEYS: + case ND_DRAW: ED_region_tag_redraw(ar); break; } diff --git a/source/blender/makesrna/intern/rna_space.c b/source/blender/makesrna/intern/rna_space.c index 292d3959fad..762c1985fa9 100644 --- a/source/blender/makesrna/intern/rna_space.c +++ b/source/blender/makesrna/intern/rna_space.c @@ -1280,6 +1280,8 @@ static const EnumPropertyItem *rna_3DViewShading_render_pass_itemf(bContext *C, RNA_enum_item_add(&result, &totitem, item); } } + + RNA_enum_item_end(&result, &totitem); *r_free = true; return result; } |