diff options
author | mano-wii <germano.costa@ig.com.br> | 2018-10-03 22:25:10 +0300 |
---|---|---|
committer | mano-wii <germano.costa@ig.com.br> | 2018-10-03 23:45:56 +0300 |
commit | c52485c16ac44ffdf39195034e85181fb2346311 (patch) | |
tree | 44e41d5bcd61c000b0ad945bb6f50726580dcd4c /source | |
parent | dfce96dbf77a3f10f0911192b3e0b844d40e569e (diff) |
Editor Transform: use the dial3d drawing in the rotation operation
Diffstat (limited to 'source')
-rw-r--r-- | source/blender/editors/transform/transform.c | 3 | ||||
-rw-r--r-- | source/blender/editors/transform/transform.h | 1 | ||||
-rw-r--r-- | source/blender/editors/transform/transform_gizmo_3d.c | 73 |
3 files changed, 77 insertions, 0 deletions
diff --git a/source/blender/editors/transform/transform.c b/source/blender/editors/transform/transform.c index 49a583a3650..1a9515c82b0 100644 --- a/source/blender/editors/transform/transform.c +++ b/source/blender/editors/transform/transform.c @@ -1999,6 +1999,9 @@ static void drawTransformView(const struct bContext *C, ARegion *UNUSED(ar), voi /* edge slide, vert slide */ drawEdgeSlide(t); drawVertSlide(t); + + /* Rotation */ + drawDial3d(t); } /* just draw a little warning message in the top-right corner of the viewport to warn that autokeying is enabled */ diff --git a/source/blender/editors/transform/transform.h b/source/blender/editors/transform/transform.h index 8bcfed9d716..758e2182de8 100644 --- a/source/blender/editors/transform/transform.h +++ b/source/blender/editors/transform/transform.h @@ -718,6 +718,7 @@ void restoreBones(TransDataContainer *tc); /* return 0 when no gimbal for selection */ bool gimbal_axis(struct Object *ob, float gmat[3][3]); +void drawDial3d(const TransInfo *t); /*********************** TransData Creation and General Handling *********** */ void createTransData(struct bContext *C, TransInfo *t); diff --git a/source/blender/editors/transform/transform_gizmo_3d.c b/source/blender/editors/transform/transform_gizmo_3d.c index 9a2c69d5a46..568fe499a75 100644 --- a/source/blender/editors/transform/transform_gizmo_3d.c +++ b/source/blender/editors/transform/transform_gizmo_3d.c @@ -78,6 +78,7 @@ #include "ED_gizmo_library.h" #include "ED_gizmo_utils.h" +#include "UI_interface.h" #include "UI_resources.h" /* local module include */ @@ -86,6 +87,7 @@ #include "MEM_guardedalloc.h" #include "GPU_select.h" +#include "GPU_state.h" #include "GPU_immediate.h" #include "GPU_matrix.h" @@ -1237,6 +1239,77 @@ static void gizmo_xform_message_subscribe( WM_msg_subscribe_rna_anon_prop(mbus, Window, view_layer, &msg_sub_value_gz_tag_refresh); } + +void drawDial3d(const TransInfo *t) +{ + if (t->mode == TFM_ROTATION && t->spacetype == SPACE_VIEW3D) { + float scale, line_with, increment, color[4], mat_basis[4][4], mat_final[4][4]; + int axis_idx; + + scale = UI_DPI_FAC * U.gizmo_size; + line_with = GIZMO_AXIS_LINE_WIDTH + 1.0f; + + copy_m4_m3(mat_basis, t->spacemtx); + copy_v3_v3(mat_basis[3], t->center_global); + + const TransCon *tc = &(t->con); + if (tc->mode & CON_APPLY) { + if (tc->mode & CON_AXIS0) { + axis_idx = MAN_AXIS_ROT_X; + negate_v3_v3(mat_basis[2], tc->mtx[0]); + } + else if (tc->mode & CON_AXIS1) { + axis_idx = MAN_AXIS_ROT_Y; + negate_v3_v3(mat_basis[2], tc->mtx[1]); + } + else if (tc->mode & CON_AXIS2) { + axis_idx = MAN_AXIS_ROT_Z; + negate_v3_v3(mat_basis[2], tc->mtx[2]); + } + else BLI_assert(0); + } + else { + axis_idx = MAN_AXIS_ROT_C; + negate_v3_v3(mat_basis[2], t->axis); + scale *= 1.2f; + line_with -= 1.0f; + } + + BLI_assert(axis_idx >= MAN_AXIS_RANGE_ROT_START && axis_idx < MAN_AXIS_RANGE_ROT_END); + gizmo_get_axis_color(axis_idx, NULL, color, color); + + ortho_basis_v3v3_v3(mat_basis[0], mat_basis[1], mat_basis[2]); + copy_m4_m4(mat_final, mat_basis); + scale *= ED_view3d_pixel_size_no_ui_scale(t->ar->regiondata, mat_final[3]); + mul_mat3_m4_fl(mat_final, scale); + + if ((t->tsnap.mode & (SCE_SNAP_MODE_INCREMENT | SCE_SNAP_MODE_GRID)) + && activeSnap(t)) + { + increment = (t->modifiers & MOD_PRECISION) ? t->snap[2] : t->snap[1]; + } + else { + increment = t->snap[0]; + } + + GPU_depth_test(false); + GPU_blend(true); + + /* XXX force AntiAlias. */ + GPU_line_smooth(true); + + ED_gizmotypes_dial_3d_draw_util( + mat_basis, mat_final, line_with, color, NULL, 0.0f, 0.0f, + ED_GIZMO_DIAL_DRAW_FLAG_ANGLE_VALUE, + 0.0f, t->values[0], increment); + + GPU_line_smooth(false); + + GPU_depth_test(true); + GPU_blend(false); + } +} + /** \} */ |