diff options
author | Germano Cavalcante <mano-wii> | 2021-10-25 14:02:08 +0300 |
---|---|---|
committer | Germano Cavalcante <germano.costa@ig.com.br> | 2021-10-25 17:57:26 +0300 |
commit | a84f1c02d251a9ce6267030a46e02ed2d3ce22e1 (patch) | |
tree | 3f2e33fb29a844c2c5105862dfb99c4fb9aefcde /source/blender/gpu/intern/gpu_immediate_util.c | |
parent | b17038db31e0dd312dd3987fb9491bf402b3a40a (diff) |
Assets: Snapping with visual feedback while dragging
The drag and drop feature of objects in 3D View has been modified to include:
- Snap the object being dragged.
- Visual feedback through a box and the placement tool grid.
Maniphest Tasks: T90198
Differential Revision: https://developer.blender.org/D12912
Diffstat (limited to 'source/blender/gpu/intern/gpu_immediate_util.c')
-rw-r--r-- | source/blender/gpu/intern/gpu_immediate_util.c | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/source/blender/gpu/intern/gpu_immediate_util.c b/source/blender/gpu/intern/gpu_immediate_util.c index d18dc862ce7..d848ea09a2a 100644 --- a/source/blender/gpu/intern/gpu_immediate_util.c +++ b/source/blender/gpu/intern/gpu_immediate_util.c @@ -428,6 +428,33 @@ void imm_draw_cube_wire_3d(uint pos, const float co[3], const float aspect[3]) immEnd(); } +void imm_draw_cube_corners_3d(uint pos, + const float co[3], + const float aspect[3], + const float factor) +{ + float coords[ARRAY_SIZE(cube_coords)][3]; + + for (int i = 0; i < ARRAY_SIZE(cube_coords); i++) { + madd_v3_v3v3v3(coords[i], co, cube_coords[i], aspect); + } + + immBegin(GPU_PRIM_LINES, ARRAY_SIZE(cube_line_index) * 4); + for (int i = 0; i < ARRAY_SIZE(cube_line_index); i++) { + float vec[3], co[3]; + sub_v3_v3v3(vec, coords[cube_line_index[i][1]], coords[cube_line_index[i][0]]); + mul_v3_fl(vec, factor); + + immVertex3fv(pos, coords[cube_line_index[i][0]]); + add_v3_v3v3(co, coords[cube_line_index[i][0]], vec); + immVertex3fv(pos, co); + sub_v3_v3v3(co, coords[cube_line_index[i][1]], vec); + immVertex3fv(pos, co); + immVertex3fv(pos, coords[cube_line_index[i][1]]); + } + immEnd(); +} + /** * Draw a cylinder. Replacement for gluCylinder. * _warning_ : Slow, better use it only if you no other choices. |