diff options
author | Germano Cavalcante <germano.costa@ig.com.br> | 2021-11-17 20:54:14 +0300 |
---|---|---|
committer | Germano Cavalcante <germano.costa@ig.com.br> | 2021-11-18 19:52:30 +0300 |
commit | c7f9a782aafcdd08868504584b2621afcf1356c2 (patch) | |
tree | 8c76660b209cbcdca5e29109304531f5c1bb6325 /source/blender | |
parent | 25fa6c74b977ac983a34b9adf5ab2f20fe2f4932 (diff) |
Revert "Revert "Adjust snap source drawing when adding multiple snap points""
This reverts commit 77df32548b9f377a834b54d0b740a6a51bb2f0a5.
Diffstat (limited to 'source/blender')
-rw-r--r-- | source/blender/editors/space_view3d/view3d_cursor_snap.c | 26 | ||||
-rw-r--r-- | source/blender/editors/transform/transform_snap.c | 36 | ||||
-rw-r--r-- | source/blender/gpu/GPU_immediate_util.h | 2 | ||||
-rw-r--r-- | source/blender/gpu/intern/gpu_immediate_util.c | 29 |
4 files changed, 59 insertions, 34 deletions
diff --git a/source/blender/editors/space_view3d/view3d_cursor_snap.c b/source/blender/editors/space_view3d/view3d_cursor_snap.c index 961b0bd6862..ac80a70011a 100644 --- a/source/blender/editors/space_view3d/view3d_cursor_snap.c +++ b/source/blender/editors/space_view3d/view3d_cursor_snap.c @@ -414,13 +414,37 @@ void ED_view3d_cursor_snap_draw_util(RegionView3D *rv3d, } if (loc_prev) { + /* Draw an "X" indicating where the previous snap point is. + * This is useful for indicating perpendicular snap. */ + + /* v1, v2, v3 and v4 indicate the coordinates of the ends of the "X". */ + float vx[3], vy[3], v1[3], v2[3], v3[3], v4[4]; + /* Multiply by 0.75f so that the final size of the "X" is close to that of * the circle. * (A closer value is 0.7071f, but we don't need to be exact here). */ float x_size = 0.75f * radius * ED_view3d_pixel_size(rv3d, loc_prev); + mul_v3_v3fl(vx, view_inv[0], x_size); + mul_v3_v3fl(vy, view_inv[1], x_size); + + add_v3_v3v3(v1, vx, vy); + sub_v3_v3v3(v2, vx, vy); + negate_v3_v3(v3, v1); + negate_v3_v3(v4, v2); + + add_v3_v3(v1, loc_prev); + add_v3_v3(v2, loc_prev); + add_v3_v3(v3, loc_prev); + add_v3_v3(v4, loc_prev); + immUniformColor4ubv(color_line); - imm_drawX(loc_prev, x_size, view_inv, pos); + immBegin(GPU_PRIM_LINES, 4); + immVertex3fv(pos, v3); + immVertex3fv(pos, v1); + immVertex3fv(pos, v4); + immVertex3fv(pos, v2); + immEnd(); if (loc_curr && (snap_elem_type & SCE_SNAP_MODE_EDGE_PERPENDICULAR)) { /* Dashed line. */ diff --git a/source/blender/editors/transform/transform_snap.c b/source/blender/editors/transform/transform_snap.c index f52061f8910..8ed0a1f2ea8 100644 --- a/source/blender/editors/transform/transform_snap.c +++ b/source/blender/editors/transform/transform_snap.c @@ -237,12 +237,44 @@ void drawSnapping(const struct bContext *C, TransInfo *t) } if (t->modifiers & MOD_EDIT_SNAP_SOURCE) { + /* Indicate the new snap source position. */ + float snap_point[3]; getSnapPoint(t, snap_point); + float vx[3], vy[3], v[3]; + float size_tmp = ED_view3d_pixel_size(rv3d, snap_point) * size; + float size_fac = 0.5f; + + mul_v3_v3fl(vx, view_inv[0], size_tmp); + mul_v3_v3fl(vy, view_inv[1], size_tmp); + immUniformColor4ubv(col); - imm_drawX( - snap_point, 0.75f * size * ED_view3d_pixel_size(rv3d, snap_point), view_inv, pos); + + imm_drawcircball(snap_point, size_tmp, view_inv, pos); + + immBegin(GPU_PRIM_LINES, 8); + add_v3_v3v3(v, snap_point, vx); + immVertex3fv(pos, v); + madd_v3_v3fl(v, vx, size_fac); + immVertex3fv(pos, v); + + sub_v3_v3v3(v, snap_point, vx); + immVertex3fv(pos, v); + madd_v3_v3fl(v, vx, -size_fac); + immVertex3fv(pos, v); + + add_v3_v3v3(v, snap_point, vy); + immVertex3fv(pos, v); + madd_v3_v3fl(v, vy, size_fac); + immVertex3fv(pos, v); + + sub_v3_v3v3(v, snap_point, vy); + immVertex3fv(pos, v); + madd_v3_v3fl(v, vy, -size_fac); + immVertex3fv(pos, v); + + immEnd(); } immUnbindProgram(); diff --git a/source/blender/gpu/GPU_immediate_util.h b/source/blender/gpu/GPU_immediate_util.h index 5b14b139662..047c3d3da00 100644 --- a/source/blender/gpu/GPU_immediate_util.h +++ b/source/blender/gpu/GPU_immediate_util.h @@ -93,8 +93,6 @@ void imm_draw_cylinder_fill_3d( uint pos, float base, float top, float height, int slices, int stacks); void imm_drawcircball(const float cent[3], float rad, const float tmat[4][4], uint pos); -void imm_drawX(const float cent[3], float size, const float tmat[4][4], uint pos); - #ifdef __cplusplus } #endif diff --git a/source/blender/gpu/intern/gpu_immediate_util.c b/source/blender/gpu/intern/gpu_immediate_util.c index 2dd23fa46ae..df18b89bd67 100644 --- a/source/blender/gpu/intern/gpu_immediate_util.c +++ b/source/blender/gpu/intern/gpu_immediate_util.c @@ -654,32 +654,3 @@ void imm_drawcircball(const float cent[3], float rad, const float tmat[4][4], ui } immEnd(); } - -void imm_drawX(const float cent[3], float size, const float tmat[4][4], uint pos) -{ - /* Draw an "X" indicating where the previous snap point is. - * This is useful for indicating perpendicular snap. */ - - /* v1, v2, v3 and v4 indicate the coordinates of the ends of the "X". */ - float vx[3], vy[3], v1[3], v2[3], v3[3], v4[4]; - - mul_v3_v3fl(vx, tmat[0], size); - mul_v3_v3fl(vy, tmat[1], size); - - add_v3_v3v3(v1, vx, vy); - sub_v3_v3v3(v2, vx, vy); - negate_v3_v3(v3, v1); - negate_v3_v3(v4, v2); - - add_v3_v3(v1, cent); - add_v3_v3(v2, cent); - add_v3_v3(v3, cent); - add_v3_v3(v4, cent); - - immBegin(GPU_PRIM_LINES, 4); - immVertex3fv(pos, v3); - immVertex3fv(pos, v1); - immVertex3fv(pos, v4); - immVertex3fv(pos, v2); - immEnd(); -} |