diff options
author | Germano Cavalcante <mano-wii> | 2021-11-17 17:02:54 +0300 |
---|---|---|
committer | Germano Cavalcante <germano.costa@ig.com.br> | 2021-11-18 19:52:18 +0300 |
commit | 25fa6c74b977ac983a34b9adf5ab2f20fe2f4932 (patch) | |
tree | 15c3b0f937436348bd82752d43abd7440ed68b23 /source | |
parent | 3531021d1b8fe271b210f6b28d5058b8894da64a (diff) |
Revert "Revert "Transform: interactive mode for editing a 'Snap Source'""
This reverts commit 805181bffae647a24e939c651da72a08c5c2b7cb.
Diffstat (limited to 'source')
-rw-r--r-- | source/blender/editors/space_view3d/view3d_cursor_snap.c | 26 | ||||
-rw-r--r-- | source/blender/editors/transform/transform.c | 59 | ||||
-rw-r--r-- | source/blender/editors/transform/transform.h | 7 | ||||
-rw-r--r-- | source/blender/editors/transform/transform_input.c | 15 | ||||
-rw-r--r-- | source/blender/editors/transform/transform_snap.c | 158 | ||||
-rw-r--r-- | source/blender/editors/transform/transform_snap.h | 4 | ||||
-rw-r--r-- | source/blender/editors/transform/transform_snap_object.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 |
9 files changed, 276 insertions, 60 deletions
diff --git a/source/blender/editors/space_view3d/view3d_cursor_snap.c b/source/blender/editors/space_view3d/view3d_cursor_snap.c index ac80a70011a..961b0bd6862 100644 --- a/source/blender/editors/space_view3d/view3d_cursor_snap.c +++ b/source/blender/editors/space_view3d/view3d_cursor_snap.c @@ -414,37 +414,13 @@ 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); - immBegin(GPU_PRIM_LINES, 4); - immVertex3fv(pos, v3); - immVertex3fv(pos, v1); - immVertex3fv(pos, v4); - immVertex3fv(pos, v2); - immEnd(); + imm_drawX(loc_prev, x_size, view_inv, pos); if (loc_curr && (snap_elem_type & SCE_SNAP_MODE_EDGE_PERPENDICULAR)) { /* Dashed line. */ diff --git a/source/blender/editors/transform/transform.c b/source/blender/editors/transform/transform.c index ae4c3f02c46..c376c718245 100644 --- a/source/blender/editors/transform/transform.c +++ b/source/blender/editors/transform/transform.c @@ -578,6 +578,21 @@ static void viewRedrawPost(bContext *C, TransInfo *t) static bool transform_modal_item_poll(const wmOperator *op, int value) { const TransInfo *t = op->customdata; + if (t->modifiers & MOD_EDIT_SNAP_SOURCE) { + if (value == TFM_MODAL_EDIT_SNAP_SOURCE) { + return true; + } + else if (!ELEM(value, + TFM_MODAL_CANCEL, + TFM_MODAL_CONFIRM, + TFM_MODAL_SNAP_INV_ON, + TFM_MODAL_SNAP_INV_OFF, + TFM_MODAL_ADD_SNAP, + TFM_MODAL_REMOVE_SNAP)) { + return false; + } + } + switch (value) { case TFM_MODAL_CANCEL: { /* TODO: Canceling with LMB is not possible when the operator is activated @@ -593,6 +608,13 @@ static bool transform_modal_item_poll(const wmOperator *op, int value) } break; } + case TFM_MODAL_SNAP_INV_ON: + case TFM_MODAL_SNAP_INV_OFF: { + if (t->modifiers & MOD_SNAP_TEMP) { + return false; + } + break; + } case TFM_MODAL_ADD_SNAP: case TFM_MODAL_REMOVE_SNAP: { if (t->spacetype != SPACE_VIEW3D) { @@ -664,6 +686,19 @@ static bool transform_modal_item_poll(const wmOperator *op, int value) } break; } + case TFM_MODAL_EDIT_SNAP_SOURCE: { + if (t->spacetype != SPACE_VIEW3D) { + return false; + } + if (t->flag & T_RELEASE_CONFIRM) { + return false; + } + if (!ELEM(t->mode, TFM_TRANSLATION, TFM_ROTATION, TFM_RESIZE)) { + /* More modes can be added over time if this feature proves useful for them. */ + return false; + } + break; + } } return true; } @@ -714,6 +749,7 @@ wmKeyMap *transform_modal_keymap(wmKeyConfig *keyconf) {TFM_MODAL_AUTOCONSTRAINT, "AUTOCONSTRAIN", 0, "Automatic Constraint", ""}, {TFM_MODAL_AUTOCONSTRAINTPLANE, "AUTOCONSTRAINPLANE", 0, "Automatic Constraint Plane", ""}, {TFM_MODAL_PRECISION, "PRECISION", 0, "Precision Mode", ""}, + {TFM_MODAL_EDIT_SNAP_SOURCE, "EDIT_SNAP_SOURCE", 0, "Snap Source Toggle", ""}, {0, NULL, 0, NULL, NULL}, }; @@ -891,7 +927,12 @@ int transformEvent(TransInfo *t, const wmEvent *event) handled = true; break; case TFM_MODAL_CONFIRM: - t->state = TRANS_CONFIRM; + if (t->modifiers & MOD_EDIT_SNAP_SOURCE) { + tranform_snap_source_mod_confirm(t); + } + else { + t->state = TRANS_CONFIRM; + } handled = true; break; case TFM_MODAL_TRANSLATE: @@ -1156,6 +1197,9 @@ int transformEvent(TransInfo *t, const wmEvent *event) t->redraw |= TREDRAW_HARD; } break; + case TFM_MODAL_EDIT_SNAP_SOURCE: + tranform_snap_source_mod_toggle(t); + break; /* Those two are only handled in transform's own handler, see T44634! */ case TFM_MODAL_EDGESLIDE_UP: case TFM_MODAL_EDGESLIDE_DOWN: @@ -1532,7 +1576,7 @@ void saveTransform(bContext *C, TransInfo *t, wmOperator *op) if (t->flag & T_MODAL) { /* do we check for parameter? */ - if (transformModeUseSnap(t)) { + if (transformModeUseSnap(t) && !(t->modifiers & MOD_SNAP_TEMP)) { if (!(t->modifiers & MOD_SNAP) != !(ts->snap_flag & SCE_SNAP)) { if (t->modifiers & MOD_SNAP) { ts->snap_flag |= SCE_SNAP; @@ -1920,14 +1964,17 @@ void transformApply(bContext *C, TransInfo *t) if ((t->redraw & TREDRAW_HARD) || (t->draw_handle_apply == NULL && (t->redraw & TREDRAW_SOFT))) { selectConstraint(t); - if (t->transform) { + if (t->modifiers & MOD_EDIT_SNAP_SOURCE) { + tranform_snap_source_mod_update(t); + } + else if (t->transform) { t->transform(t, t->mval); /* calls recalcData() */ - viewRedrawForce(C, t); } - t->redraw = TREDRAW_NOTHING; } - else if (t->redraw & TREDRAW_SOFT) { + + if (t->redraw & (TREDRAW_HARD | TREDRAW_SOFT)) { viewRedrawForce(C, t); + t->redraw = TREDRAW_NOTHING; } /* If auto confirm is on, break after one pass */ diff --git a/source/blender/editors/transform/transform.h b/source/blender/editors/transform/transform.h index d78cd13f8b8..6219bdba6b7 100644 --- a/source/blender/editors/transform/transform.h +++ b/source/blender/editors/transform/transform.h @@ -163,7 +163,9 @@ typedef enum { MOD_PRECISION = 1 << 1, MOD_SNAP = 1 << 2, MOD_SNAP_INVERT = 1 << 3, - MOD_CONSTRAINT_SELECT_PLANE = 1 << 4, + MOD_SNAP_TEMP = 1 << 4, + MOD_CONSTRAINT_SELECT_PLANE = 1 << 5, + MOD_EDIT_SNAP_SOURCE = 1 << 6, } eTModifier; /** #TransSnap.status */ @@ -294,6 +296,8 @@ enum { TFM_MODAL_AUTOCONSTRAINTPLANE = 29, TFM_MODAL_PRECISION = 30, + + TFM_MODAL_EDIT_SNAP_SOURCE = 31, }; /** \} */ @@ -761,6 +765,7 @@ void applyMouseInput(struct TransInfo *t, struct MouseInput *mi, const int mval[2], float output[3]); +void transform_input_reset(MouseInput *mi, const int mval[2]); void setCustomPoints(TransInfo *t, MouseInput *mi, const int start[2], const int end[2]); void setCustomPointsFromDirection(TransInfo *t, MouseInput *mi, const float dir[2]); diff --git a/source/blender/editors/transform/transform_input.c b/source/blender/editors/transform/transform_input.c index 0b46d0b9a13..d9a29b8d6b7 100644 --- a/source/blender/editors/transform/transform_input.c +++ b/source/blender/editors/transform/transform_input.c @@ -418,6 +418,10 @@ void setInputPostFct(MouseInput *mi, void (*post)(struct TransInfo *t, float val void applyMouseInput(TransInfo *t, MouseInput *mi, const int mval[2], float output[3]) { + if (t->modifiers & MOD_EDIT_SNAP_SOURCE) { + return; + } + double mval_db[2]; if (mi->use_virtual_mval) { @@ -455,4 +459,15 @@ void applyMouseInput(TransInfo *t, MouseInput *mi, const int mval[2], float outp } } +void transform_input_reset(MouseInput *mi, const int mval[2]) +{ + copy_v2_v2_int(mi->imval, mval); + if (ELEM(mi->apply, InputAngle, InputAngleSpring)) { + struct InputAngle_Data *data = mi->data; + data->mval_prev[0] = mi->imval[0]; + data->mval_prev[1] = mi->imval[1]; + data->angle = 0.0f; + } +} + /** \} */ diff --git a/source/blender/editors/transform/transform_snap.c b/source/blender/editors/transform/transform_snap.c index 71f26ef0594..f52061f8910 100644 --- a/source/blender/editors/transform/transform_snap.c +++ b/source/blender/editors/transform/transform_snap.c @@ -136,6 +136,10 @@ bool validSnap(const TransInfo *t) bool activeSnap(const TransInfo *t) { + if (t->modifiers & MOD_SNAP_TEMP) { + return true; + } + return ((t->modifiers & (MOD_SNAP | MOD_SNAP_INVERT)) == MOD_SNAP) || ((t->modifiers & (MOD_SNAP | MOD_SNAP_INVERT)) == MOD_SNAP_INVERT); } @@ -178,7 +182,7 @@ bool transformModeUseSnap(const TransInfo *t) static bool doForceIncrementSnap(const TransInfo *t) { - return !transformModeUseSnap(t); + return !(t->modifiers & MOD_SNAP_TEMP) && !transformModeUseSnap(t); } void drawSnapping(const struct bContext *C, TransInfo *t) @@ -232,6 +236,15 @@ void drawSnapping(const struct bContext *C, TransInfo *t) imm_drawcircball(p->co, ED_view3d_pixel_size(rv3d, p->co) * size, view_inv, pos); } + if (t->modifiers & MOD_EDIT_SNAP_SOURCE) { + float snap_point[3]; + getSnapPoint(t, snap_point); + + immUniformColor4ubv(col); + imm_drawX( + snap_point, 0.75f * size * ED_view3d_pixel_size(rv3d, snap_point), view_inv, pos); + } + immUnbindProgram(); } @@ -244,7 +257,7 @@ void drawSnapping(const struct bContext *C, TransInfo *t) loc_prev = t->tsnap.snapTarget; } - if (validSnap(t)) { + if (t->tsnap.status & POINT_INIT) { loc_cur = t->tsnap.snapPoint; } @@ -477,8 +490,7 @@ void applyGridAbsolute(TransInfo *t) void applySnapping(TransInfo *t, float *vec) { - /* Each Trans Data already makes the snap to face */ - if (doForceIncrementSnap(t)) { + if (!transformModeUseSnap(t) && !(t->modifiers & MOD_SNAP_TEMP)) { return; } @@ -659,6 +671,20 @@ static short snap_select_type_get(TransInfo *t) return r_snap_select; } +static void snap_object_context_setup(TransInfo *t) +{ + if (t->data_type != TC_MESH_VERTS) { + return; + } + /* Ignore elements being transformed. */ + ED_transform_snap_object_context_set_editmesh_callbacks( + t->tsnap.object_context, + (bool (*)(BMVert *, void *))BM_elem_cb_check_hflag_disabled, + bm_edge_is_snap_target, + bm_face_is_snap_target, + POINTER_FROM_UINT((BM_ELEM_SELECT | BM_ELEM_HIDDEN))); +} + static void initSnappingMode(TransInfo *t) { ToolSettings *ts = t->settings; @@ -670,27 +696,13 @@ static void initSnappingMode(TransInfo *t) t->tsnap.project = 0; } - if (ELEM(t->spacetype, SPACE_VIEW3D, SPACE_IMAGE, SPACE_NODE, SPACE_SEQ)) { - /* Not with camera selected in camera view. */ - if (!(t->options & CTX_CAMERA)) { - setSnappingCallback(t); - } - } + setSnappingCallback(t); if (t->spacetype == SPACE_VIEW3D) { if (t->tsnap.object_context == NULL) { t->tsnap.use_backface_culling = snap_use_backface_culling(t); t->tsnap.object_context = ED_transform_snap_object_context_create(t->scene, 0); - - if (t->data_type == TC_MESH_VERTS) { - /* Ignore elements being transformed. */ - ED_transform_snap_object_context_set_editmesh_callbacks( - t->tsnap.object_context, - (bool (*)(BMVert *, void *))BM_elem_cb_check_hflag_disabled, - bm_edge_is_snap_target, - bm_face_is_snap_target, - POINTER_FROM_UINT((BM_ELEM_SELECT | BM_ELEM_HIDDEN))); - } + snap_object_context_setup(t); } } else if (t->spacetype == SPACE_SEQ) { @@ -775,10 +787,16 @@ void freeSnapping(TransInfo *t) static void setSnappingCallback(TransInfo *t) { if (t->spacetype == SPACE_VIEW3D) { + if (t->options & CTX_CAMERA) { + /* Not with camera selected in camera view. */ + return; + } t->tsnap.calcSnap = snap_calc_view3d_fn; } - else if (t->spacetype == SPACE_IMAGE && t->obedit_type == OB_MESH) { - t->tsnap.calcSnap = snap_calc_uv_fn; + else if (t->spacetype == SPACE_IMAGE) { + if (t->obedit_type == OB_MESH) { + t->tsnap.calcSnap = snap_calc_uv_fn; + } } else if (t->spacetype == SPACE_NODE) { t->tsnap.calcSnap = snap_calc_node_fn; @@ -788,6 +806,9 @@ static void setSnappingCallback(TransInfo *t) /* The target is calculated along with the snap point. */ return; } + else { + return; + } switch (t->tsnap.target) { case SCE_SNAP_TARGET_CLOSEST: @@ -905,6 +926,15 @@ void getSnapPoint(const TransInfo *t, float vec[3]) } } +static void transform_snap_multipoints_free(TransInfo *t) +{ + if (t->tsnap.status & MULTI_POINTS) { + BLI_freelistN(&t->tsnap.points); + t->tsnap.status &= ~MULTI_POINTS; + t->tsnap.selectedPoint = NULL; + } +} + /** \} */ /* -------------------------------------------------------------------- */ @@ -1619,6 +1649,90 @@ bool transform_snap_increment(const TransInfo *t, float *r_val) return transform_snap_increment_ex(t, false, r_val); } +static void snap_source_mod_start(TransInfo *t) +{ + t->modifiers |= MOD_EDIT_SNAP_SOURCE; + t->tsnap.modeSelect = SNAP_ALL; + if ((t->tsnap.status & TARGET_INIT) == 0) { + /* Calculate the current target for the perpendicular snap. */ + t->tsnap.targetSnap(t); + + /* Fallback. */ + TargetSnapMedian(t); + } + t->tsnap.targetSnap = NULL; + + if ((t->tsnap.mode & ~(SCE_SNAP_MODE_INCREMENT | SCE_SNAP_MODE_GRID)) == 0) { + /* Initialize snap modes for geometry. */ + t->tsnap.mode &= ~(SCE_SNAP_MODE_INCREMENT | SCE_SNAP_MODE_GRID); + t->tsnap.mode |= SCE_SNAP_MODE_GEOM; + } + + if (!activeSnap(t) || !transformModeUseSnap(t)) { + t->modifiers |= MOD_SNAP_TEMP; + } + + restoreTransObjects(t); + + if (t->data_type == TC_MESH_VERTS) { + ED_transform_snap_object_context_set_editmesh_callbacks( + t->tsnap.object_context, NULL, NULL, NULL, NULL); + } + + t->redraw |= TREDRAW_SOFT; +} + +static void snap_source_mod_end(TransInfo *t) +{ + t->modifiers &= ~MOD_EDIT_SNAP_SOURCE; + + /* Restore. */ + t->tsnap.modeSelect = snap_select_type_get(t); + snap_object_context_setup(t); + transform_snap_multipoints_free(t); +} + +void tranform_snap_source_mod_toggle(TransInfo *t) +{ + if (t->flag & T_RELEASE_CONFIRM) { + return; + } + + if (!(t->modifiers & MOD_EDIT_SNAP_SOURCE)) { + snap_source_mod_start(t); + } + else if (t->modifiers & MOD_EDIT_SNAP_SOURCE) { + /* Cancel. */ + t->modifiers &= ~MOD_SNAP_TEMP; + t->tsnap.mode = snap_mode_from_scene(t); + setSnappingCallback(t); + snap_source_mod_end(t); + } +} + +void tranform_snap_source_mod_update(TransInfo *t) +{ + BLI_assert(t->modifiers & MOD_EDIT_SNAP_SOURCE); + + /* Time base quirky code to go around findnearest slowness */ + /* TODO: add exception for object mode, no need to slow it down then. */ + double current = PIL_check_seconds_timer(); + if (current - t->tsnap.last >= 0.01) { + t->tsnap.calcSnap(t, NULL); + t->tsnap.last = current; + t->redraw |= TREDRAW_SOFT; + } +} + +void tranform_snap_source_mod_confirm(TransInfo *t) +{ + BLI_assert(t->modifiers & MOD_EDIT_SNAP_SOURCE); + getSnapPoint(t, t->tsnap.snapTarget); + + transform_input_reset(&t->mouse, t->mval); + snap_source_mod_end(t); +} + /** \} */ /* -------------------------------------------------------------------- */ diff --git a/source/blender/editors/transform/transform_snap.h b/source/blender/editors/transform/transform_snap.h index ed7f93304bc..af13dac7ee7 100644 --- a/source/blender/editors/transform/transform_snap.h +++ b/source/blender/editors/transform/transform_snap.h @@ -52,6 +52,10 @@ bool transform_snap_increment_ex(const TransInfo *t, bool use_local_space, float bool transform_snap_increment(const TransInfo *t, float *val); bool transform_snap_grid(TransInfo *t, float *val); +void tranform_snap_source_mod_toggle(TransInfo *t); +void tranform_snap_source_mod_update(TransInfo *t); +void tranform_snap_source_mod_confirm(TransInfo *t); + bool activeSnap(const TransInfo *t); bool activeSnap_with_project(const TransInfo *t); diff --git a/source/blender/editors/transform/transform_snap_object.c b/source/blender/editors/transform/transform_snap_object.c index 4b981e763f1..9f05a0a9562 100644 --- a/source/blender/editors/transform/transform_snap_object.c +++ b/source/blender/editors/transform/transform_snap_object.c @@ -391,9 +391,8 @@ static SnapObjectData *snap_object_data_editmesh_get(SnapObjectContext *sctx, } else if (sod->mesh_runtime) { if (sod->mesh_runtime != snap_object_data_editmesh_runtime_get(ob_eval)) { - if (G.moving) { + if (G.moving && !sod->treedata_editmesh.cached && !sod->cached[0] && !sod->cached[1]) { /* Hack to avoid updating while transforming. */ - BLI_assert(!sod->treedata_editmesh.cached && !sod->cached[0] && !sod->cached[1]); sod->mesh_runtime = snap_object_data_editmesh_runtime_get(ob_eval); } else { @@ -2830,6 +2829,15 @@ void ED_transform_snap_object_context_destroy(SnapObjectContext *sctx) MEM_freeN(sctx); } +static void transform_snap_object_context_cache_clear(SnapObjectContext *sctx) +{ + BLI_ghash_clear(sctx->cache.object_map, NULL, snap_object_data_free); + if (sctx->cache.data_to_object_map != NULL) { + BLI_ghash_clear(sctx->cache.data_to_object_map, NULL, NULL); + } + BLI_memarena_clear(sctx->cache.mem_arena); +} + void ED_transform_snap_object_context_set_editmesh_callbacks( SnapObjectContext *sctx, bool (*test_vert_fn)(BMVert *, void *user_data), @@ -2837,11 +2845,27 @@ void ED_transform_snap_object_context_set_editmesh_callbacks( bool (*test_face_fn)(BMFace *, void *user_data), void *user_data) { - sctx->callbacks.edit_mesh.test_vert_fn = test_vert_fn; - sctx->callbacks.edit_mesh.test_edge_fn = test_edge_fn; - sctx->callbacks.edit_mesh.test_face_fn = test_face_fn; + bool is_cache_dirty = false; + if (sctx->callbacks.edit_mesh.test_vert_fn != test_vert_fn) { + sctx->callbacks.edit_mesh.test_vert_fn = test_vert_fn; + is_cache_dirty = true; + } + if (sctx->callbacks.edit_mesh.test_edge_fn != test_edge_fn) { + sctx->callbacks.edit_mesh.test_edge_fn = test_edge_fn; + is_cache_dirty = true; + } + if (sctx->callbacks.edit_mesh.test_face_fn != test_face_fn) { + sctx->callbacks.edit_mesh.test_face_fn = test_face_fn; + is_cache_dirty = true; + } + if (sctx->callbacks.edit_mesh.user_data != user_data) { + sctx->callbacks.edit_mesh.user_data = user_data; + is_cache_dirty = true; + } - sctx->callbacks.edit_mesh.user_data = user_data; + if (is_cache_dirty) { + transform_snap_object_context_cache_clear(sctx); + } } bool ED_transform_snap_object_project_ray_ex(SnapObjectContext *sctx, diff --git a/source/blender/gpu/GPU_immediate_util.h b/source/blender/gpu/GPU_immediate_util.h index 047c3d3da00..5b14b139662 100644 --- a/source/blender/gpu/GPU_immediate_util.h +++ b/source/blender/gpu/GPU_immediate_util.h @@ -93,6 +93,8 @@ 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 df18b89bd67..2dd23fa46ae 100644 --- a/source/blender/gpu/intern/gpu_immediate_util.c +++ b/source/blender/gpu/intern/gpu_immediate_util.c @@ -654,3 +654,32 @@ 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(); +} |