diff options
author | Rohan Rathi <rohanrathi08@gmail.com> | 2018-06-20 19:59:44 +0300 |
---|---|---|
committer | Rohan Rathi <rohanrathi08@gmail.com> | 2018-06-20 19:59:44 +0300 |
commit | c73a6b0d42f5ee16bb2af7d585035463854f4024 (patch) | |
tree | c366aeac74491653e0ba516b745116bfa6475f94 /source/blender/editors/transform | |
parent | dd752476b97aa3b35d1359422ca42e33d99ac851 (diff) | |
parent | 82dc5f91e86351e1a26769ec86d9054437eb77d6 (diff) |
Merge branch 'blender2.8' into soc-2018-bevel
Diffstat (limited to 'source/blender/editors/transform')
6 files changed, 104 insertions, 36 deletions
diff --git a/source/blender/editors/transform/transform.h b/source/blender/editors/transform/transform.h index c2548fe497f..d72d311e0f6 100644 --- a/source/blender/editors/transform/transform.h +++ b/source/blender/editors/transform/transform.h @@ -65,6 +65,7 @@ struct wmEvent; struct wmTimer; struct ARegion; struct ReportList; +struct RNG; struct EditBone; struct RenderEngineType; struct SnapObjectContext; @@ -536,6 +537,9 @@ typedef struct TransInfo { void *draw_handle_pixel; void *draw_handle_cursor; + /** Currently only used for random curve of proportional editing. */ + struct RNG *rng; + /** Typically for mode settings. */ TransCustomDataContainer custom; } TransInfo; diff --git a/source/blender/editors/transform/transform_conversions.c b/source/blender/editors/transform/transform_conversions.c index 6c608a0b5e4..8462004c549 100644 --- a/source/blender/editors/transform/transform_conversions.c +++ b/source/blender/editors/transform/transform_conversions.c @@ -1255,7 +1255,7 @@ static void createTransArmatureVerts(TransInfo *t) bool mirror = ((arm->flag & ARM_MIRROR_EDIT) != 0); int total_mirrored = 0, i; int oldtot; - BoneInitData *bid; + BoneInitData *bid = NULL; tc->data_len = 0; for (ebo = edbo->first; ebo; ebo = ebo->next) { @@ -2120,7 +2120,6 @@ static void createTransParticleVerts(bContext *C, TransInfo *t) void flushTransParticles(TransInfo *t) { FOREACH_TRANS_DATA_CONTAINER (t, tc) { - Scene *scene = t->scene; ViewLayer *view_layer = t->view_layer; Object *ob = OBACT(view_layer); @@ -8633,6 +8632,10 @@ void createTransData(bContext *C, TransInfo *t) createTransPaintCurveVerts(C, t); countAndCleanTransDataContainer(t); } + /* Mark as initialized if above checks fail. */ + if (t->data_len_all == -1) { + t->data_len_all = 0; + } } else { createTransObject(C, t); diff --git a/source/blender/editors/transform/transform_generics.c b/source/blender/editors/transform/transform_generics.c index 8bef63dba1a..053647cbfea 100644 --- a/source/blender/editors/transform/transform_generics.c +++ b/source/blender/editors/transform/transform_generics.c @@ -58,6 +58,8 @@ #include "BLI_rand.h" #include "BLI_utildefines.h" +#include "PIL_time.h" + #include "BLT_translation.h" #include "RNA_access.h" @@ -74,6 +76,7 @@ #include "BKE_fcurve.h" #include "BKE_lattice.h" #include "BKE_library.h" +#include "BKE_main.h" #include "BKE_nla.h" #include "BKE_context.h" #include "BKE_paint.h" @@ -1695,6 +1698,10 @@ void postTrans(bContext *C, TransInfo *t) MEM_freeN(t->mouse.data); } + if (t->rng != NULL) { + BLI_rng_free(t->rng); + } + freeSnapping(t); } @@ -2163,7 +2170,12 @@ void calculatePropRatio(TransInfo *t) td->factor = sqrtf(2 * dist - dist * dist); break; case PROP_RANDOM: - td->factor = BLI_frand() * dist; + if (t->rng == NULL) { + /* Lazy initialization. */ + uint rng_seed = (uint)(PIL_check_seconds_timer_i() & UINT_MAX); + t->rng = BLI_rng_new(rng_seed); + } + td->factor = BLI_rng_get_float(t->rng) * dist; break; case PROP_INVSQUARE: td->factor = dist * (2.0f - dist); diff --git a/source/blender/editors/transform/transform_input.c b/source/blender/editors/transform/transform_input.c index 270ef08be50..5b5c4902377 100644 --- a/source/blender/editors/transform/transform_input.c +++ b/source/blender/editors/transform/transform_input.c @@ -375,8 +375,11 @@ void initMouseInputMode(TransInfo *t, MouseInput *mi, MouseInputMode mode) MEM_freeN(mi_data_prev); } - /* bootstrap mouse input with initial values */ - applyMouseInput(t, mi, mi->imval, t->values); + /* Don't write into the values when non-modal because they are already set from operator redo values. */ + if (t->flag & T_MODAL) { + /* bootstrap mouse input with initial values */ + applyMouseInput(t, mi, mi->imval, t->values); + } } void setInputPostFct(MouseInput *mi, void (*post)(struct TransInfo *t, float values[3])) diff --git a/source/blender/editors/transform/transform_manipulator_3d.c b/source/blender/editors/transform/transform_manipulator_3d.c index b6782470f96..75da0fc2d23 100644 --- a/source/blender/editors/transform/transform_manipulator_3d.c +++ b/source/blender/editors/transform/transform_manipulator_3d.c @@ -107,8 +107,15 @@ #define MAN_SCALE_C (MAN_SCALE_X | MAN_SCALE_Y | MAN_SCALE_Z) /* threshold for testing view aligned manipulator axis */ -#define TW_AXIS_DOT_MIN 0.02f -#define TW_AXIS_DOT_MAX 0.1f +struct { + float min, max; +} g_tw_axis_range[2] = { + /* Regular range */ + {0.02f, 0.1f}, + /* Use a different range because we flip the dot product, + * also the view aligned planes are harder to see so hiding early is preferred. */ + {0.175f, 0.25f}, +}; /* axes as index */ enum { @@ -247,16 +254,18 @@ static bool manipulator_is_axis_visible( const RegionView3D *rv3d, const int twtype, const float idot[3], const int axis_type, const int axis_idx) { - bool is_plane = false; - const uint aidx_norm = manipulator_orientation_axis(axis_idx, &is_plane); - /* don't draw axis perpendicular to the view */ - if (aidx_norm < 3) { - float idot_axis = idot[aidx_norm]; - if (is_plane) { - idot_axis = 1.0f - idot_axis; - } - if (idot_axis < TW_AXIS_DOT_MIN) { - return false; + if ((axis_idx >= MAN_AXIS_RANGE_ROT_START && axis_idx < MAN_AXIS_RANGE_ROT_END) == 0) { + bool is_plane = false; + const uint aidx_norm = manipulator_orientation_axis(axis_idx, &is_plane); + /* don't draw axis perpendicular to the view */ + if (aidx_norm < 3) { + float idot_axis = idot[aidx_norm]; + if (is_plane) { + idot_axis = 1.0f - idot_axis; + } + if (idot_axis < g_tw_axis_range[is_plane].min) { + return false; + } } } @@ -333,22 +342,31 @@ static void manipulator_get_axis_color( const float alpha_hi = 1.0f; float alpha_fac; - bool is_plane = false; - const int axis_idx_norm = manipulator_orientation_axis(axis_idx, &is_plane); - /* get alpha fac based on axis angle, to fade axis out when hiding it because it points towards view */ - if (axis_idx_norm < 3) { - float idot_axis = idot[axis_idx_norm]; - if (is_plane) { - idot_axis = 1.0f - idot_axis; - } - alpha_fac = (idot_axis > TW_AXIS_DOT_MAX) ? - 1.0f : (idot_axis < TW_AXIS_DOT_MIN) ? - 0.0f : ((idot_axis - TW_AXIS_DOT_MIN) / (TW_AXIS_DOT_MAX - TW_AXIS_DOT_MIN)); - } - else { + if (axis_idx >= MAN_AXIS_RANGE_ROT_START && axis_idx < MAN_AXIS_RANGE_ROT_END) { + /* Never fade rotation rings. */ /* trackball rotation axis is a special case, we only draw a slight overlay */ alpha_fac = (axis_idx == MAN_AXIS_ROT_T) ? 0.1f : 1.0f; } + else { + bool is_plane = false; + const int axis_idx_norm = manipulator_orientation_axis(axis_idx, &is_plane); + /* get alpha fac based on axis angle, to fade axis out when hiding it because it points towards view */ + if (axis_idx_norm < 3) { + const float idot_min = g_tw_axis_range[is_plane].min; + const float idot_max = g_tw_axis_range[is_plane].max; + float idot_axis = idot[axis_idx_norm]; + if (is_plane) { + idot_axis = 1.0f - idot_axis; + } + alpha_fac = ( + (idot_axis > idot_max) ? + 1.0f : (idot_axis < idot_min) ? + 0.0f : ((idot_axis - idot_min) / (idot_max - idot_min))); + } + else { + alpha_fac = 1.0f; + } + } switch (axis_idx) { case MAN_AXIS_TRANS_X: @@ -1238,9 +1256,14 @@ static ManipulatorGroup *manipulatorgroup_init(wmManipulatorGroup *mgroup) * Custom handler for manipulator widgets */ static int manipulator_modal( - bContext *C, wmManipulator *widget, const wmEvent *UNUSED(event), + bContext *C, wmManipulator *widget, const wmEvent *event, eWM_ManipulatorTweak UNUSED(tweak_flag)) { + /* Avoid unnecessary updates, partially address: T55458. */ + if (ELEM(event->type, TIMER, INBETWEEN_MOUSEMOVE)) { + return OPERATOR_RUNNING_MODAL; + } + const ScrArea *sa = CTX_wm_area(C); ARegion *ar = CTX_wm_region(C); View3D *v3d = sa->spacedata.first; @@ -1315,6 +1338,14 @@ static void WIDGETGROUP_manipulator_setup(const bContext *C, wmManipulatorGroup case MAN_AXIS_SCALE_X: case MAN_AXIS_SCALE_Y: case MAN_AXIS_SCALE_Z: + if (axis_idx >= MAN_AXIS_RANGE_TRANS_START && axis_idx < MAN_AXIS_RANGE_TRANS_END) { + int draw_options = 0; + if ((man->twtype & (V3D_MANIP_ROTATE | V3D_MANIP_SCALE)) == 0) { + draw_options |= ED_MANIPULATOR_ARROW_DRAW_FLAG_STEM; + } + RNA_enum_set(axis->ptr, "draw_options", draw_options); + } + WM_manipulator_set_line_width(axis, MANIPULATOR_AXIS_LINE_WIDTH); break; case MAN_AXIS_ROT_X: @@ -1348,6 +1379,7 @@ static void WIDGETGROUP_manipulator_setup(const bContext *C, wmManipulatorGroup } else if (axis_idx == MAN_AXIS_ROT_C) { WM_manipulator_set_flag(axis, WM_MANIPULATOR_DRAW_VALUE, true); + WM_manipulator_set_scale(axis, 1.2f); } else { WM_manipulator_set_scale(axis, 0.2f); @@ -1447,6 +1479,13 @@ static void WIDGETGROUP_manipulator_refresh(const bContext *C, wmManipulatorGrou WM_manipulator_set_matrix_rotation_from_z_axis(axis, rv3d->twmat[aidx_norm]); RNA_float_set(axis->ptr, "length", len); + + if (axis_idx >= MAN_AXIS_RANGE_TRANS_START && axis_idx < MAN_AXIS_RANGE_TRANS_END) { + if (man->twtype & V3D_MANIP_ROTATE) { + /* Avoid rotate and translate arrows overlap. */ + start_co[2] += 0.215f; + } + } WM_manipulator_set_matrix_offset_location(axis, start_co); WM_manipulator_set_flag(axis, WM_MANIPULATOR_DRAW_OFFSET_SCALE, true); break; diff --git a/source/blender/editors/transform/transform_ops.c b/source/blender/editors/transform/transform_ops.c index 18d30db7a21..d98e3e3261a 100644 --- a/source/blender/editors/transform/transform_ops.c +++ b/source/blender/editors/transform/transform_ops.c @@ -45,6 +45,7 @@ #include "RNA_enum_types.h" #include "WM_api.h" +#include "WM_message.h" #include "WM_types.h" #include "UI_interface.h" @@ -170,6 +171,9 @@ static int select_orientation_exec(bContext *C, wmOperator *op) WM_event_add_notifier(C, NC_SCENE | ND_TOOLSETTINGS, NULL); + struct wmMsgBus *mbus = CTX_wm_message_bus(C); + WM_msg_publish_rna_prop(mbus, &scene->id, scene, Scene, transform_orientation); + return OPERATOR_FINISHED; } @@ -537,7 +541,7 @@ void Transform_Properties(struct wmOperatorType *ot, int flags) if (flags & P_PROPORTIONAL) { RNA_def_enum(ot->srna, "proportional", rna_enum_proportional_editing_items, 0, "Proportional Editing", ""); prop = RNA_def_enum(ot->srna, "proportional_edit_falloff", rna_enum_proportional_falloff_items, 0, - "Proportional Editing Falloff", "Falloff type for proportional editing mode"); + "Proportional Falloff", "Falloff type for proportional editing mode"); RNA_def_property_translation_context(prop, BLT_I18NCONTEXT_ID_CURVE); /* Abusing id_curve :/ */ RNA_def_float(ot->srna, "proportional_size", 1, T_PROP_SIZE_MIN, T_PROP_SIZE_MAX, "Proportional Size", "", 0.001f, 100.0f); @@ -563,17 +567,20 @@ void Transform_Properties(struct wmOperatorType *ot, int flags) } if (flags & P_GPENCIL_EDIT) { - RNA_def_boolean(ot->srna, "gpencil_strokes", 0, "Edit Grease Pencil", "Edit selected Grease Pencil strokes"); + prop = RNA_def_boolean(ot->srna, "gpencil_strokes", 0, "Edit Grease Pencil", "Edit selected Grease Pencil strokes"); + RNA_def_property_flag(prop, PROP_HIDDEN | PROP_SKIP_SAVE); } if (flags & P_CURSOR_EDIT) { - RNA_def_boolean(ot->srna, "cursor_transform", 0, "Transform Cursor", ""); + prop = RNA_def_boolean(ot->srna, "cursor_transform", 0, "Transform Cursor", ""); + RNA_def_property_flag(prop, PROP_HIDDEN | PROP_SKIP_SAVE); } if ((flags & P_OPTIONS) && !(flags & P_NO_TEXSPACE)) { - RNA_def_boolean(ot->srna, "texture_space", 0, "Edit Texture Space", "Edit Object data texture space"); + prop = RNA_def_boolean(ot->srna, "texture_space", 0, "Edit Texture Space", "Edit Object data texture space"); + RNA_def_property_flag(prop, PROP_HIDDEN | PROP_SKIP_SAVE); prop = RNA_def_boolean(ot->srna, "remove_on_cancel", 0, "Remove on Cancel", "Remove elements on cancel"); - RNA_def_property_flag(prop, PROP_HIDDEN); + RNA_def_property_flag(prop, PROP_HIDDEN | PROP_SKIP_SAVE); } if (flags & P_CORRECT_UV) { |