diff options
author | Campbell Barton <ideasman42@gmail.com> | 2017-08-10 09:35:45 +0300 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2017-08-10 09:35:45 +0300 |
commit | 464c045b31b54d284da59efa71530fb6092696d3 (patch) | |
tree | ec1e252d3f212453e6a874683559d1a9a96b85cc /source/blender/editors/manipulator_library | |
parent | 8520cb4af022fd3a0db44cff2b70815fdc235ae9 (diff) |
Manipulator: grab3d option to align to view
Use for lamp-target, makes it easier to click on.
Diffstat (limited to 'source/blender/editors/manipulator_library')
-rw-r--r-- | source/blender/editors/manipulator_library/manipulator_types/grab3d_manipulator.c | 30 |
1 files changed, 24 insertions, 6 deletions
diff --git a/source/blender/editors/manipulator_library/manipulator_types/grab3d_manipulator.c b/source/blender/editors/manipulator_library/manipulator_types/grab3d_manipulator.c index 7a002a9cfc8..01376cf6184 100644 --- a/source/blender/editors/manipulator_library/manipulator_types/grab3d_manipulator.c +++ b/source/blender/editors/manipulator_library/manipulator_types/grab3d_manipulator.c @@ -87,14 +87,13 @@ typedef struct GrabInteraction { /* -------------------------------------------------------------------- */ static void grab_geom_draw( - const wmManipulator *mpr, const float color[4], const bool select) + const wmManipulator *mpr, const float color[4], const bool select, const int draw_options) { #ifdef USE_MANIPULATOR_CUSTOM_DIAL UNUSED_VARS(grab3d, col, axis_modal_mat); wm_manipulator_geometryinfo_draw(&wm_manipulator_geom_data_grab3d, select); #else const int draw_style = RNA_enum_get(mpr->ptr, "draw_style"); - const int draw_options = RNA_enum_get(mpr->ptr, "draw_options"); const bool filled = (draw_options & ED_MANIPULATOR_GRAB_DRAW_FLAG_FILL) != 0; glLineWidth(mpr->line_width); @@ -151,11 +150,14 @@ static void grab3d_get_translate( } static void grab3d_draw_intern( - const bContext *UNUSED(C), wmManipulator *mpr, + const bContext *C, wmManipulator *mpr, const bool select, const bool highlight) { + const int draw_options = RNA_enum_get(mpr->ptr, "draw_options"); + const bool align_view = (draw_options & ED_MANIPULATOR_GRAB_DRAW_FLAG_ALIGN_VIEW) != 0; float color[4]; float matrix_final[4][4]; + float matrix_align[4][4]; manipulator_color_get(mpr, highlight, color); @@ -163,9 +165,19 @@ static void grab3d_draw_intern( gpuPushMatrix(); gpuMultMatrix(matrix_final); - glEnable(GL_BLEND); - grab_geom_draw(mpr, color, select); + if (align_view) { + float matrix_final_unit[4][4]; + RegionView3D *rv3d = CTX_wm_region_view3d(C); + normalize_m4_m4(matrix_final_unit, matrix_final); + mul_m4_m4m4(matrix_align, rv3d->viewmat, matrix_final_unit); + zero_v3(matrix_align[3]); + transpose_m4(matrix_align); + gpuMultMatrix(matrix_align); + } + + glEnable(GL_BLEND); + grab_geom_draw(mpr, color, select, draw_options); glDisable(GL_BLEND); gpuPopMatrix(); @@ -180,8 +192,13 @@ static void grab3d_draw_intern( gpuPushMatrix(); gpuMultMatrix(matrix_final); + + if (align_view) { + gpuMultMatrix(matrix_align); + } + glEnable(GL_BLEND); - grab_geom_draw(mpr, (const float [4]){0.5f, 0.5f, 0.5f, 0.5f}, select); + grab_geom_draw(mpr, (const float [4]){0.5f, 0.5f, 0.5f, 0.5f}, select, draw_options); glDisable(GL_BLEND); gpuPopMatrix(); } @@ -313,6 +330,7 @@ static void MANIPULATOR_WT_grab_3d(wmManipulatorType *wt) }; static EnumPropertyItem rna_enum_draw_options[] = { {ED_MANIPULATOR_GRAB_DRAW_FLAG_FILL, "FILL", 0, "Filled", ""}, + {ED_MANIPULATOR_GRAB_DRAW_FLAG_ALIGN_VIEW, "ALIGN_VIEW", 0, "Align View", ""}, {0, NULL, 0, NULL, NULL} }; |