Blender V5.3
transform_mode_vert_slide.cc
Go to the documentation of this file.
1/* SPDX-FileCopyrightText: 2001-2002 NaN Holding BV. All rights reserved.
2 *
3 * SPDX-License-Identifier: GPL-2.0-or-later */
4
8
9#include "BLI_math_geom_c.hh"
10#include "BLI_math_matrix.hh"
11#include "BLI_math_matrix_c.hh"
12#include "BLI_string_utf8.hh"
13
14#include "BKE_report.hh"
15#include "BKE_unit.hh"
16
17#include "GPU_immediate.hh"
18#include "GPU_matrix.hh"
19#include "GPU_state.hh"
20
21#include "ED_screen.hh"
22
23#include "WM_api.hh"
24
25#include "RNA_access.hh"
26
27#include "UI_interface.hh"
28#include "UI_view2d.hh"
29
30#include "BLT_translation.hh"
31
32#include "transform.hh"
34#include "transform_convert.hh"
35#include "transform_mode.hh"
36#include "transform_snap.hh"
37
38namespace blender::ed::transform {
39
40/* -------------------------------------------------------------------- */
43
48
49 private:
50 float4x4 proj_mat;
51 float2 win_half;
52
53 public:
55 {
56 ARegion *region = t->region;
57
58 if (region == nullptr) [[unlikely]] {
59 this->win_half = {1.0f, 1.0f};
60 this->proj_mat = float4x4::identity();
61 return;
62 }
63
64 this->win_half = {region->winx / 2.0f, region->winy / 2.0f};
65
66 if (t->spacetype == SPACE_VIEW3D) {
67 RegionView3D *rv3d = static_cast<RegionView3D *>(region->regiondata);
68 this->proj_mat = ED_view3d_ob_project_mat_get(rv3d, tc->obedit);
69
70 for (int i = 0; i < 4; i++) {
71 this->proj_mat[i][0] *= this->win_half[0];
72 this->proj_mat[i][1] *= this->win_half[1];
73 }
74 }
75 else {
76 const View2D *v2d = static_cast<View2D *>(t->view);
77 ui::view2d_view_to_region_m4(v2d, this->proj_mat.ptr());
78 this->proj_mat.location()[0] -= this->win_half[0];
79 this->proj_mat.location()[1] -= this->win_half[1];
80 }
81 }
82
84 {
85 return math::project_point(this->proj_mat, co).xy() + this->win_half;
86 }
87
93 {
94 const bool is_uv = (t->data_type == &TransConvertType_MeshUV);
95 const float4x4 &obmat = tc->obedit->object_to_world();
96
97 for (TransDataVertSlideVert &sv : this->sv) {
98 if (sv.co_link_orig_3d.size() <= 1) {
99 continue;
100 }
101
102 const float3 v_co_orig = sv.co_orig_3d();
103
104 float dir_dot_best = -FLT_MAX;
105 int co_link_curr_best = -1;
106
107 for (int j : sv.co_link_orig_3d.index_range()) {
108 const float3 &loc_dst = sv.co_link_orig_3d[j];
109
110 float dir_dot;
111 if (is_uv) {
112 const float2 co_orig_2d = this->project(v_co_orig);
113 const float2 loc_dst_2d = this->project(loc_dst);
114 const float2 tdir = math::normalize(loc_dst_2d - co_orig_2d);
115 dir_dot = math::dot(float2(dir), tdir);
116 }
117 else {
118 const float3 dir_local = loc_dst - v_co_orig;
119 const float3 tdir = math::normalize((obmat * float4(dir_local, 0.0f)).xyz());
120 dir_dot = math::dot(dir, tdir);
121 }
122
123 if (dir_dot > dir_dot_best) {
124 dir_dot_best = dir_dot;
125 co_link_curr_best = j;
126 }
127 }
128
129 if (co_link_curr_best != -1) {
130 sv.co_link_curr = co_link_curr_best;
131 }
132 }
133 }
134
138 void update_active_vert(TransInfo * /*t*/, const float2 &mval_fl)
139 {
140 /* Set the vertex to use as a reference for the mouse direction `curr_sv_index`. */
141 float dist_min_sq = FLT_MAX;
142
143 for (int i : this->sv.index_range()) {
144 TransDataVertSlideVert &sv = this->sv[i];
145 const float2 co_2d = this->project(sv.co_orig_3d());
146 const float dist_sq = len_squared_v2v2(mval_fl, co_2d);
147 if (dist_sq < dist_min_sq) {
148 dist_min_sq = dist_sq;
149 this->curr_sv_index = i;
150 }
151 }
152 }
153};
154
156 float perc;
162 std::optional<float3> dir_3d;
163};
164
166{
167 VertSlideParams *slp = static_cast<VertSlideParams *>(t->custom.mode.data);
169 VertSlideData *sld = static_cast<VertSlideData *>(tc->custom.mode.data);
170 TransDataVertSlideVert *sv = &sld->sv[sld->curr_sv_index];
171
172 const float3 co_orig_3d = sv->co_orig_3d();
173 const float3 co_dest_3d = sv->co_dest_3d();
174
175 int mval_ofs[2], mval_start[2], mval_end[2];
176
177 const float2 co_orig_2d = sld->project(co_orig_3d);
178 const float2 co_curr_2d = sld->project(co_dest_3d);
179
180 ARRAY_SET_ITEMS(mval_ofs, t->mouse.imval[0] - co_orig_2d[0], t->mouse.imval[1] - co_orig_2d[1]);
181 ARRAY_SET_ITEMS(mval_start, co_orig_2d[0] + mval_ofs[0], co_orig_2d[1] + mval_ofs[1]);
182 ARRAY_SET_ITEMS(mval_end, co_curr_2d[0] + mval_ofs[0], co_curr_2d[1] + mval_ofs[1]);
183
184 if (slp->flipped && slp->use_even) {
185 setCustomPoints(t, &t->mouse, mval_start, mval_end);
186 }
187 else {
188 setCustomPoints(t, &t->mouse, mval_end, mval_start);
189 }
190}
191
193{
195
196 /* #setCustomPoints isn't normally changing as the mouse moves,
197 * in this case apply mouse input immediately so we don't refresh
198 * with the value from the previous points. */
199 applyMouseInput(t, &t->mouse, t->mval, t->values);
200}
201
203{
204 VertSlideData *sld = MEM_new<VertSlideData>(__func__);
207 }
208 else {
210 }
211
212 if (sld->sv.is_empty()) {
213 MEM_delete(sld);
214 return nullptr;
215 }
216
217 sld->curr_sv_index = 0;
218 sld->update_proj_mat(t, tc);
219 return sld;
220}
221
222static void freeVertSlideVerts(TransInfo * /*t*/,
223 TransDataContainer * /*tc*/,
224 TransCustomData *custom_data)
225{
226 VertSlideData *sld = static_cast<VertSlideData *>(custom_data->data);
227
228 if (!sld) {
229 return;
230 }
231
232 MEM_delete(sld);
233 custom_data->data = nullptr;
234}
235
236static void freeVertSlideParams(TransInfo * /*t*/,
237 TransDataContainer * /*tc*/,
238 TransCustomData *custom_data)
239{
240 MEM_delete(static_cast<VertSlideParams *>(custom_data->data));
241 custom_data->data = nullptr;
242}
243
245{
246 VertSlideParams *slp = static_cast<VertSlideParams *>(t->custom.mode.data);
247 const bool is_event_handled = t->redraw && (event->type != MOUSEMOVE);
248 if (slp) {
249 slp->update_status_bar |= is_event_handled;
250 }
251
252 if (is_event_handled) {
253 /* Event already handled. */
254 return TREDRAW_NOTHING;
255 }
256
257 if (slp) {
258 switch (event->type) {
259 case EVT_EKEY:
260 if (event->val == KM_PRESS) {
261 slp->use_even = !slp->use_even;
262 if (slp->flipped) {
264 }
265 slp->update_status_bar = true;
266 return TREDRAW_HARD;
267 }
268 break;
269 case EVT_FKEY:
270 if (event->val == KM_PRESS) {
271 slp->flipped = !slp->flipped;
273 slp->update_status_bar = true;
274 return TREDRAW_HARD;
275 }
276 break;
277 case EVT_CKEY:
278 /* Use like a modifier key. */
279 if (event->val == KM_PRESS) {
280 t->flag ^= T_ALT_TRANSFORM;
282 slp->update_status_bar = true;
283 return TREDRAW_HARD;
284 }
285 break;
286 case MOUSEMOVE: {
287 /* Don't recalculate the best edge. */
288 const bool is_clamp = !(t->flag & T_ALT_TRANSFORM);
289 if (is_clamp) {
290 const float2 delta = float2(event->mval) - t->mouse.imval;
291 if (const std::optional<float3> dir3_opt = mouse_delta_to_world_dir(t, delta)) {
292 const float3 &dir_unit = *dir3_opt;
293 /* Update the slide direction for every selected object. */
295 VertSlideData *sld = static_cast<VertSlideData *>(tc->custom.mode.data);
296 if (sld) {
297 sld->update_active_edges(t, tc, dir_unit);
298 }
299 }
300 if (slp->op) {
301 if (PropertyRNA *prop = RNA_struct_find_property(slp->op->ptr, "direction")) {
302 RNA_property_float_set_array(slp->op->ptr, prop, &dir_unit.x);
303 }
304 }
305 slp->dir_3d = dir_unit;
306 }
307 }
309 break;
310 }
311 default:
312 break;
313 }
314 }
315 return TREDRAW_NOTHING;
316}
317
319{
321 VertSlideData *sld = static_cast<VertSlideData *>(tc->custom.mode.data);
322 if (sld) {
323 const VertSlideParams *slp = static_cast<const VertSlideParams *>(t->custom.mode.data);
324 const bool is_clamp = !(t->flag & T_ALT_TRANSFORM);
325
326 /* Non-Prop mode. */
327 {
328 TransDataVertSlideVert *curr_sv = &sld->sv[sld->curr_sv_index];
329
330 const float3 co_orig_3d_act = curr_sv->co_orig_3d();
331 const float3 co_dest_3d_act = curr_sv->co_dest_3d();
332
333 const float ctrl_size = ui::theme::get_value_f(TH_FACEDOT_SIZE) + 1.5f;
334 const float line_size = ui::theme::get_value_f(TH_OUTLINE_WIDTH) + 0.5f;
335 const int alpha_shade = -160;
336
338
340
342 if (t->spacetype == SPACE_VIEW3D) {
343 GPU_matrix_mul(tc->obedit->object_to_world().ptr());
344 }
345 else {
346 GPU_matrix_scale_2f(1 / t->aspect[0], 1 / t->aspect[1]);
347 }
348
349 GPU_line_width(line_size);
350
351 const uint shdr_pos = GPU_vertformat_attr_add(
352 immVertexFormat(), "pos", gpu::VertAttrType::SFLOAT_32_32_32);
353
356
357 immBegin(GPU_PRIM_LINES, sld->sv.size() * 2);
358 if (is_clamp) {
359 for (TransDataVertSlideVert &sv : sld->sv) {
360 immVertex3fv(shdr_pos, sv.co_orig_3d());
361 immVertex3fv(shdr_pos, sv.co_dest_3d());
362 }
363 }
364 else {
365 for (TransDataVertSlideVert &sv : sld->sv) {
366 const float3 co_orig_3d = sv.co_orig_3d();
367 const float3 co_dest_3d = sv.co_dest_3d();
368 float a[3], b[3];
369 sub_v3_v3v3(a, co_dest_3d, co_orig_3d);
370 mul_v3_fl(a, 100.0f);
371 negate_v3_v3(b, a);
372 add_v3_v3(a, co_orig_3d);
373 add_v3_v3(b, co_orig_3d);
374
375 immVertex3fv(shdr_pos, a);
376 immVertex3fv(shdr_pos, b);
377 }
378 }
379 immEnd();
380
382
384
385 GPU_point_size(ctrl_size);
387
389 immVertex3fv(shdr_pos, (slp->flipped && slp->use_even) ? co_dest_3d_act : co_orig_3d_act);
390 immEnd();
391
393
395
396 /* Direction from active vertex! */
397 if (!compare_v2v2(t->mval, t->mouse.imval, FLT_EPSILON)) {
398 /* 2D Pixel Space. */
403
404 float3 co_orig_3d_cpy = co_orig_3d_act;
405 if (t->spacetype != SPACE_VIEW3D) {
406 co_orig_3d_cpy[0] /= t->aspect[0];
407 co_orig_3d_cpy[1] /= t->aspect[1];
408 }
409
410 float2 loc_src_act_2d = sld->project(co_orig_3d_cpy);
411 float2 loc_mval_dir = loc_src_act_2d + (t->mval - t->mouse.imval);
412
413 GPU_line_width(1.0f);
414
415 const uint shdr_pos_2d = GPU_vertformat_attr_add(
416 immVertexFormat(), "pos", gpu::VertAttrType::SFLOAT_32_32);
417
419
420 float viewport_size[4];
421 GPU_viewport_size_get_f(viewport_size);
422 immUniform2f("viewport_size", viewport_size[2], viewport_size[3]);
423
424 immUniform1i("colors_len", 0); /* "simple" mode. */
425 immUniformColor4f(1.0f, 1.0f, 1.0f, 1.0f);
426 immUniform1f("dash_width", 6.0f);
427 immUniform1f("udash_factor", 0.5f);
428
430 immVertex2fv(shdr_pos_2d, loc_src_act_2d);
431 immVertex2fv(shdr_pos_2d, loc_mval_dir);
432 immEnd();
433
435
438 }
439 }
440 }
441}
442
444 const float perc,
445 const bool use_even,
446 const bool use_flip,
447 float r_co[3])
448{
449 const float3 co_orig_3d = sv.co_orig_3d();
450 const float3 co_dest_3d = sv.co_dest_3d();
451 if (use_even == false) {
452 interp_v3_v3v3(r_co, co_orig_3d, co_dest_3d, perc);
453 }
454 else {
455 float dir[3];
456 sub_v3_v3v3(dir, co_dest_3d, co_orig_3d);
457 float edge_len = normalize_v3(dir);
458 if (edge_len > FLT_EPSILON) {
459 if (use_flip) {
460 madd_v3_v3v3fl(r_co, co_dest_3d, dir, -perc);
461 }
462 else {
463 madd_v3_v3v3fl(r_co, co_orig_3d, dir, perc);
464 }
465 }
466 else {
467 copy_v3_v3(r_co, co_orig_3d);
468 }
469 }
470}
471
472static void doVertSlide(TransInfo *t, float perc)
473{
474 VertSlideParams *slp = static_cast<VertSlideParams *>(t->custom.mode.data);
475
476 slp->perc = perc;
477
478 const bool use_even = slp->use_even;
479
481 VertSlideData *sld = static_cast<VertSlideData *>(tc->custom.mode.data);
482 if (sld == nullptr) {
483 continue;
484 }
485
486 float tperc = perc;
487 if (use_even) {
488 TransDataVertSlideVert *sv_curr = &sld->sv[sld->curr_sv_index];
489 const float edge_len_curr = len_v3v3(sv_curr->co_orig_3d(), sv_curr->co_dest_3d());
490 tperc *= edge_len_curr;
491 }
492
493 for (TransDataVertSlideVert &sv : sld->sv) {
494 vert_slide_apply_elem(sv, tperc, use_even, slp->flipped, sv.td->loc);
495 }
496 }
497}
498
499static void vert_slide_snap_apply(TransInfo *t, float *value)
500{
502 VertSlideData *sld = static_cast<VertSlideData *>(tc->custom.mode.data);
503 TransDataVertSlideVert *sv = &sld->sv[sld->curr_sv_index];
504 float3 co_orig_3d = sv->co_orig_3d();
505 float3 co_curr_3d = sv->co_dest_3d();
506
507 float snap_point[3], dvec[3];
508 if (tc->use_local_mat) {
509 mul_m4_v3(tc->mat, co_orig_3d);
510 mul_m4_v3(tc->mat, co_curr_3d);
511 }
512
513 getSnapPoint(t, dvec);
514 sub_v3_v3(dvec, t->tsnap.snap_source);
516 float co_dir[3];
517 sub_v3_v3v3(co_dir, co_curr_3d, co_orig_3d);
518 normalize_v3(co_dir);
521 }
522 else {
524 }
525 }
526
527 add_v3_v3v3(snap_point, co_orig_3d, dvec);
528 *value = line_point_factor_v3(snap_point, co_orig_3d, co_curr_3d);
529}
530
532{
533 char str[UI_MAX_DRAW_STR];
534 size_t ofs = 0;
535 float final;
536 const bool is_clamp = !(t->flag & T_ALT_TRANSFORM);
537 const bool is_constrained = !(is_clamp == false || hasNumInput(&t->num));
538
539 final = t->values[0] + t->values_modal_offset[0];
540
542 if (!validSnap(t)) {
543 transform_snap_increment(t, &final);
544 }
545
546 /* Only do this so out of range values are not displayed. */
547 if (is_constrained) {
548 CLAMP(final, 0.0f, 1.0f);
549 }
550
551 applyNumInput(&t->num, &final);
552
553 t->values_final[0] = final;
554
555 /* Header string. */
556 ofs += BLI_strncpy_utf8_rlen(str + ofs, IFACE_("Vertex Slide: "), sizeof(str) - ofs);
557 if (hasNumInput(&t->num)) {
558 char c[NUM_STR_REP_LEN];
559 outputNumInput(&(t->num), c, t->scene->unit);
560 ofs += BLI_strncpy_utf8_rlen(str + ofs, &c[0], sizeof(str) - ofs);
561 }
562 else {
563 ofs += BLI_snprintf_utf8_rlen(str + ofs, sizeof(str) - ofs, "%.4f ", final);
564 }
565 /* Done with header string. */
566
567 /* Do stuff here. */
568 doVertSlide(t, final);
569
570 recalc_data(t);
571
573}
574
576{
577 if (t->keymap == nullptr) {
578 return;
579 }
580 const wmKeyMap &keymap = *t->keymap;
581
582 VertSlideParams *slp = static_cast<VertSlideParams *>(t->custom.mode.data);
583 if (!slp->update_status_bar) {
584 return;
585 }
586 slp->update_status_bar = false;
587
588 const bool flipped = slp->flipped;
589 const bool use_even = slp->use_even;
590 const bool is_clamp = !(t->flag & T_ALT_TRANSFORM);
591 const bool is_precision = t->modifiers & MOD_PRECISION;
592 const bool is_snap = t->modifiers & MOD_SNAP;
593 const bool is_snap_invert = t->modifiers & MOD_SNAP_INVERT;
594
595 WorkspaceStatus status(t->context);
596 status.modal_keymap(IFACE_("Confirm"), keymap, TFM_MODAL_CONFIRM);
597 status.modal_keymap(IFACE_("Cancel"), keymap, TFM_MODAL_CANCEL);
598 status.modal_keymap(IFACE_("Snap"), keymap, TFM_MODAL_SNAP_TOGGLE, is_snap);
599 status.modal_keymap(IFACE_("Snap Invert"), keymap, TFM_MODAL_SNAP_INV_ON, is_snap_invert);
600 status.modal_keymap(IFACE_("Set Snap Base"), keymap, TFM_MODAL_EDIT_SNAP_SOURCE_ON);
601 status.modal_keymap(IFACE_("Move"), keymap, TFM_MODAL_TRANSLATE);
602 status.modal_keymap(IFACE_("Rotate"), keymap, TFM_MODAL_ROTATE);
603 status.modal_keymap(IFACE_("Resize"), keymap, TFM_MODAL_RESIZE);
604 status.modal_keymap(IFACE_("Precision Mode"), keymap, TFM_MODAL_PRECISION, is_precision);
605 status.item_bool(IFACE_("Clamp"), is_clamp, ICON_EVENT_C, ICON_EVENT_ALT);
606 status.item_bool(IFACE_("Even"), use_even, ICON_EVENT_E);
607 if (use_even) {
608 status.item_bool(IFACE_("Flipped"), flipped, ICON_EVENT_F);
609 }
610}
611
612static void vert_slide_transform_matrix_fn(TransInfo *t, float mat_xform[4][4])
613{
614 float delta[3];
615
616 VertSlideParams *slp = static_cast<VertSlideParams *>(t->custom.mode.data);
618 VertSlideData *sld = static_cast<VertSlideData *>(tc->custom.mode.data);
619 TransDataVertSlideVert &sv_active = sld->sv[sld->curr_sv_index];
620 float3 orig_co = sv_active.co_orig_3d();
621 const float3 &loc_dst_act = sv_active.co_dest_3d();
622
623 float tperc = t->values_final[0];
624 if (slp->use_even) {
625 const float edge_len_curr = len_v3v3(orig_co, loc_dst_act);
626 tperc *= edge_len_curr;
627 }
628
629 float3 final_co;
630 vert_slide_apply_elem(sv_active, tperc, slp->use_even, slp->flipped, final_co);
631
632 if (tc->use_local_mat) {
633 mul_m4_v3(tc->mat, orig_co);
634 mul_m4_v3(tc->mat, final_co);
635 }
636
637 sub_v3_v3v3(delta, final_co, orig_co);
638 add_v3_v3(mat_xform[3], delta);
639}
640
642 TransInfo *t, wmOperator *op, bool use_even, bool flipped, bool use_clamp)
643{
644 if ((t->flag & T_EDIT) == 0 || (t->obedit_type != OB_MESH)) {
645 BKE_report(t->reports, RPT_ERROR, "'Vertex Slide' is only supported in mesh edit mode");
646 t->state = TRANS_CANCEL;
647 return;
648 }
649
650 t->mode = TFM_VERT_SLIDE;
651
652 {
653 VertSlideParams *slp = MEM_new<VertSlideParams>(__func__);
654 slp->use_even = use_even;
655 slp->flipped = flipped;
656 slp->perc = 0.0f;
657 slp->op = op;
658 slp->update_status_bar = true;
659
660 if (!use_clamp) {
661 t->flag |= T_ALT_TRANSFORM;
662 }
663
664 if (op) {
665 PropertyRNA *prop = RNA_struct_find_property(op->ptr, "direction");
666 if (prop && RNA_property_is_set(op->ptr, prop)) {
667 float3 d;
668 RNA_property_float_get_array(op->ptr, prop, d);
669 slp->dir_3d = math::normalize(d);
670 }
671 }
672
673 t->custom.mode.data = slp;
674 t->custom.mode.use_free = false;
675 t->custom.mode.free_cb = freeVertSlideParams;
676 }
677
678 bool ok = false;
679 const float3 init_dir = [&t]() {
680 const VertSlideParams *slp = static_cast<VertSlideParams *>(t->custom.mode.data);
681 if (std::optional<float3> dir = slp->dir_3d; dir) {
682 return *dir;
683 }
684 const float2 delta = float2(t->mval) - t->mouse.imval;
685 if (std::optional<float3> dir = mouse_delta_to_world_dir(t, delta); dir) {
686 return *dir;
687 }
688 /* Fallback direction so the operator initializes before any mouse movement. */
689 return float3(1, 0, 0);
690 }();
691
694 if (sld) {
695 sld->update_active_vert(t, t->mval);
696 sld->update_active_edges(t, tc, init_dir);
697
698 tc->custom.mode.data = sld;
699 tc->custom.mode.free_cb = freeVertSlideVerts;
700 ok = true;
701 }
702 }
703
704 if (ok == false) {
705 t->state = TRANS_CANCEL;
706 return;
707 }
708
709 /* Set custom point first if you want value to be initialized by init. */
712
713 t->idx_max = 0;
714 t->num.idx_max = 0;
715 t->increment[0] = 0.1f;
716 t->increment_precision = 0.1f;
717
718 copy_v3_fl(t->num.val_inc, t->increment[0]);
719 t->num.unit_sys = t->scene->unit.system;
720 t->num.unit_type[0] = B_UNIT_NONE;
721}
722
724{
725 bool use_even = false;
726 bool flipped = false;
727 bool use_clamp = true;
728 if (op) {
729 PropertyRNA *prop;
730 prop = RNA_struct_find_property(op->ptr, "use_even");
731 use_even = (prop) ? RNA_property_boolean_get(op->ptr, prop) : false;
732 prop = RNA_struct_find_property(op->ptr, "flipped");
733 flipped = (prop) ? RNA_property_boolean_get(op->ptr, prop) : false;
734 prop = RNA_struct_find_property(op->ptr, "use_clamp");
735 use_clamp = (prop) ? RNA_property_boolean_get(op->ptr, prop) : true;
736 }
737 initVertSlide_ex(t, op, use_even, flipped, use_clamp);
738}
739
741
742/* -------------------------------------------------------------------- */
745
747{
749 VertSlideData *sld = static_cast<VertSlideData *>(tc->custom.mode.data);
750 if (sld) {
751 sld->update_proj_mat(t, tc);
752 }
753 }
754
756}
757
759
761 /*flags*/ T_NO_CONSTRAINT,
762 /*init_fn*/ initVertSlide,
763 /*transform_fn*/ applyVertSlide,
764 /*transform_matrix_fn*/ vert_slide_transform_matrix_fn,
765 /*handle_event_fn*/ handleEventVertSlide,
766 /*snap_distance_fn*/ transform_snap_distance_len_squared_fn,
767 /*snap_apply_fn*/ vert_slide_snap_apply,
768 /*draw_fn*/ drawVertSlide,
769 /*status_fn*/ vert_slide_status,
770};
771
772} // namespace blender::ed::transform
#define IFACE_(msgid)
#define NUM_STR_REP_LEN
#define UI_MAX_DRAW_STR
#define CLAMP(a, b, c)
#define ARRAY_SET_ITEMS(...)
IndexRange index_range() const
Definition BLI_array.hh:371
void modal_keymap(std::string text, const wmKeyMap &keymap, int propvalue, bool inverted=false)
Definition area.cc:1119
void item_bool(std::string text, bool inverted, int icon1, int icon2=0)
Definition area.cc:1097
#define str(s)
#define FLT_MAX
#define FLT_EPSILON
Array< TransDataVertSlideVert > transform_mesh_vert_slide_data_create(const TransDataContainer *tc, Vector< float3 > &r_loc_dst_buffer)
TransDataContainer * transform_mode_container_first_ok(TransInfo *t)
void initMouseInputMode(TransInfo *t, MouseInput *mi, MouseInputMode mode)
void recalc_data(TransInfo *t)
static void calcVertSlideCustomPoints(TransInfo *t)
void getSnapPoint(const TransInfo *t, float vec[3])
static void vert_slide_status(TransInfo *t)
Array< TransDataVertSlideVert > transform_mesh_uv_vert_slide_data_create(const TransInfo *t, TransDataContainer *tc, Vector< float3 > &r_loc_dst_buffer)
bool transform_snap_increment(const TransInfo *t, float *r_val)
void transform_mode_vert_slide_reproject_input(TransInfo *t)
void transform_snap_mixed_apply(TransInfo *t, float *vec)
bool validSnap(const TransInfo *t)
void transform_constraint_snap_axis_to_face(const TransInfo *t, const float axis[3], float r_out[3])
void transform_constraint_snap_axis_to_edge(const TransInfo *t, const float axis[3], float r_out[3])
static void vert_slide_snap_apply(TransInfo *t, float *value)
static eRedrawFlag handleEventVertSlide(TransInfo *t, const wmEvent *event)
static void doVertSlide(TransInfo *t, float perc)
float transform_snap_distance_len_squared_fn(TransInfo *, const float p1[3], const float p2[3])
void setCustomPoints(TransInfo *t, MouseInput *mi, const int mval_start[2], const int mval_end[2])
static void vert_slide_transform_matrix_fn(TransInfo *t, float mat_xform[4][4])
static void vert_slide_apply_elem(const TransDataVertSlideVert &sv, const float perc, const bool use_even, const bool use_flip, float r_co[3])
static VertSlideData * createVertSlideVerts(TransInfo *t, TransDataContainer *tc)
void applyMouseInput(TransInfo *t, MouseInput *mi, const float2 &mval, float output[3])
static void initVertSlide(TransInfo *t, wmOperator *op)
static void drawVertSlide(TransInfo *t)
static void vert_slide_update_input(TransInfo *t)
static void freeVertSlideParams(TransInfo *, TransDataContainer *, TransCustomData *custom_data)
static void applyVertSlide(TransInfo *t)
TransConvertTypeInfo TransConvertType_MeshUV
static void initVertSlide_ex(TransInfo *t, wmOperator *op, bool use_even, bool flipped, bool use_clamp)
std::optional< float3 > mouse_delta_to_world_dir(const TransInfo *t, const float2 &delta)
static void freeVertSlideVerts(TransInfo *, TransDataContainer *, TransCustomData *custom_data)
T dot(const QuaternionBase< T > &a, const QuaternionBase< T > &b)
VectorT project_point(const MatT &mat, const VectorT &point)
MatBase< T, NumCol, NumRow > normalize(const MatBase< T, NumCol, NumRow > &a)
float get_value_f(int colorid)
void view2d_view_to_region_m4(const View2D *v2d, float matrix[4][4]) ATTR_NONNULL()
Definition view2d.cc:1789
MINLINE void madd_v3_v3v3fl(float r[3], const float a[3], const float b[3], float f)
MINLINE void negate_v3_v3(float r[3], const float a[3])
float line_point_factor_v3(const float p[3], const float l1[3], const float l2[3])
void wmOrtho2_region_pixelspace(const ARegion *region)
void RNA_property_float_get_array(PointerRNA *ptr, PropertyRNA *prop, float *values)
void immEnd()
PropertyRNA * RNA_struct_find_property(PointerRNA *ptr, const char *identifier)
MINLINE void copy_v3_v3(float r[3], const float a[3])
unsigned int uint
Definition BKE_text.h:55
MINLINE void add_v3_v3v3(float r[3], const float a[3], const float b[3])
void immUniform2f(const char *name, float x, float y)
float4x4 ED_view3d_ob_project_mat_get(const RegionView3D *rv3d, const Object *ob)
void GPU_matrix_identity_set()
char size_t BLI_strncpy_utf8_rlen(char *__restrict dst, const char *__restrict src, size_t dst_maxncpy) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(1
GPUVertFormat * immVertexFormat()
void GPU_point_size(float size)
Definition gpu_state.cc:157
void immBegin(GPUPrimType, uint vertex_len)
bool hasNumInput(const NumInput *n)
Definition numinput.cc:188
void RNA_property_float_set_array(PointerRNA *ptr, PropertyRNA *prop, const float *values)
@ TH_VERTEX_ACTIVE
MatBase< float, 4, 4 > float4x4
void immUnbindProgram()
void GPU_matrix_mul(const float m[4][4])
MINLINE void mul_v3_fl(float r[3], float f)
void GPU_line_width(float width)
Definition gpu_state.cc:151
void GPU_matrix_scale_2f(float x, float y)
@ GPU_BLEND_ALPHA
Definition GPU_state.hh:90
bool RNA_property_boolean_get(PointerRNA *ptr, PropertyRNA *prop)
MINLINE void sub_v3_v3(float r[3], const float a[3])
VecBase< float, 4 > float4
void immBindBuiltinProgram(GPUBuiltinShader shader_id)
void mul_m4_v3(const float M[4][4], float r[3])
VecBase< float, 2 > float2
void immUniform1f(const char *name, float x)
@ GPU_DEPTH_NONE
Definition GPU_state.hh:132
void GPU_viewport_size_get_f(float coords[4])
Definition gpu_state.cc:258
void BKE_report(ReportList *reports, eReportType type, const char *message)
Definition report.cc:162
@ GPU_SHADER_3D_POINT_UNIFORM_COLOR
@ GPU_SHADER_3D_LINE_DASHED_UNIFORM_COLOR
void immUniformColor4f(float r, float g, float b, float a)
void interp_v3_v3v3(float r[3], const float a[3], const float b[3], float t)
void ED_area_status_text(ScrArea *area, const char *str)
Definition area.cc:975
void immUniformThemeColorShadeAlpha(int color_id, int color_offset, int alpha_offset)
uint GPU_vertformat_attr_add(GPUVertFormat *format, StringRef name, gpu::VertAttrType type)
bool applyNumInput(NumInput *n, float *vec)
Definition numinput.cc:207
MINLINE float normalize_v3(float n[3])
MINLINE void add_v3_v3(float r[3], const float a[3])
void immVertex3fv(uint attr_id, const float data[3])
MINLINE void sub_v3_v3v3(float r[3], const float a[3], const float b[3])
MINLINE void copy_v3_fl(float r[3], float f)
void GPU_matrix_pop_projection()
void outputNumInput(NumInput *n, char *str, const UnitSettings &unit_settings)
Definition numinput.cc:104
void GPU_blend(GPUBlend blend)
Definition gpu_state.cc:44
void immUniform1i(const char *name, int x)
VecBase< float, 3 > float3
MINLINE float len_v3v3(const float a[3], const float b[3]) ATTR_WARN_UNUSED_RESULT
MINLINE float len_squared_v2v2(const float a[2], const float b[2]) ATTR_WARN_UNUSED_RESULT
void immVertex2fv(uint attr_id, const float data[2])
@ B_UNIT_NONE
Definition BKE_unit.hh:165
void GPU_matrix_pop()
void GPU_matrix_push_projection()
size_t BLI_snprintf_utf8_rlen(char *__restrict dst, size_t dst_maxncpy, const char *__restrict format,...) ATTR_NONNULL(1
void GPU_depth_test(GPUDepthTest test)
Definition gpu_state.cc:70
bool RNA_property_is_set(PointerRNA *ptr, PropertyRNA *prop)
void GPU_matrix_push()
MINLINE bool compare_v2v2(const float v1[2], const float v2[2], float limit) ATTR_WARN_UNUSED_RESULT
const c_style_mat & ptr() const
int unit_type[NUM_MAX_ELEMENTS]
float val_inc[NUM_MAX_ELEMENTS]
struct UnitSettings unit
TransConvertTypeInfo * data_type
Definition transform.hh:836
TransCustomDataContainer custom
void update_active_edges(TransInfo *t, const TransDataContainer *tc, const float3 &dir)
void update_proj_mat(TransInfo *t, const TransDataContainer *tc)
void update_active_vert(TransInfo *, const float2 &mval_fl)
wmEventType type
Definition WM_types.hh:817
#define FOREACH_TRANS_DATA_CONTAINER(t, th)
Definition transform.hh:48
conversion and adaptation of different datablocks to a common struct.
transform modes used by different operators.