Blender V5.0
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.h"
10#include "BLI_math_matrix.h"
11#include "BLI_math_matrix.hh"
12#include "BLI_string_utf8.h"
13
14#include "BKE_unit.hh"
15
16#include "GPU_immediate.hh"
17#include "GPU_matrix.hh"
18#include "GPU_state.hh"
19
20#include "ED_screen.hh"
21
22#include "WM_api.hh"
23
24#include "RNA_access.hh"
25
26#include "UI_interface.hh"
27#include "UI_view2d.hh"
28
29#include "BLT_translation.hh"
30
31#include "transform.hh"
33#include "transform_convert.hh"
34#include "transform_mode.hh"
35#include "transform_snap.hh"
36
37namespace blender::ed::transform {
38
39/* -------------------------------------------------------------------- */
42
47
48 private:
49 float4x4 proj_mat;
50 float2 win_half;
51
52 public:
54 {
55 ARegion *region = t->region;
56
57 if (UNLIKELY(region == nullptr)) {
58 this->win_half = {1.0f, 1.0f};
59 this->proj_mat = float4x4::identity();
60 return;
61 }
62
63 this->win_half = {region->winx / 2.0f, region->winy / 2.0f};
64
65 if (t->spacetype == SPACE_VIEW3D) {
66 RegionView3D *rv3d = static_cast<RegionView3D *>(region->regiondata);
67 this->proj_mat = ED_view3d_ob_project_mat_get(rv3d, tc->obedit);
68
69 for (int i = 0; i < 4; i++) {
70 this->proj_mat[i][0] *= this->win_half[0];
71 this->proj_mat[i][1] *= this->win_half[1];
72 }
73 }
74 else {
75 const View2D *v2d = static_cast<View2D *>(t->view);
76 UI_view2d_view_to_region_m4(v2d, this->proj_mat.ptr());
77 this->proj_mat.location()[0] -= this->win_half[0];
78 this->proj_mat.location()[1] -= this->win_half[1];
79 }
80 }
81
83 {
84 return math::project_point(this->proj_mat, co).xy() + this->win_half;
85 }
86
90 void update_active_edges(TransInfo *t, const float2 &mval_fl)
91 {
92 /* First get the direction of the original mouse position. */
93 float2 dir = math::normalize(mval_fl - t->mouse.imval);
94
95 for (TransDataVertSlideVert &sv : this->sv) {
96 if (sv.co_link_orig_3d.size() <= 1) {
97 continue;
98 }
99
100 const float3 v_co_orig = sv.co_orig_3d();
101 float2 loc_src_2d = math::project_point(this->proj_mat, v_co_orig).xy();
102
103 float dir_dot_best = -FLT_MAX;
104 int co_link_curr_best = -1;
105
106 for (int j : sv.co_link_orig_3d.index_range()) {
107 const float3 &loc_dst = sv.co_link_orig_3d[j];
108 float2 loc_dst_2d = math::project_point(this->proj_mat, loc_dst).xy();
109 float2 tdir = math::normalize(loc_dst_2d - loc_src_2d);
110
111 float dir_dot = math::dot(dir, tdir);
112 if (dir_dot > dir_dot_best) {
113 dir_dot_best = dir_dot;
114 co_link_curr_best = j;
115 }
116 }
117
118 if (co_link_curr_best != -1) {
119 sv.co_link_curr = co_link_curr_best;
120 }
121 }
122 }
123
127 void update_active_vert(TransInfo * /*t*/, const float2 &mval_fl)
128 {
129 /* Set the vertex to use as a reference for the mouse direction `curr_sv_index`. */
130 float dist_min_sq = FLT_MAX;
131
132 for (int i : this->sv.index_range()) {
133 TransDataVertSlideVert &sv = this->sv[i];
134 const float2 co_2d = this->project(sv.co_orig_3d());
135 const float dist_sq = len_squared_v2v2(mval_fl, co_2d);
136 if (dist_sq < dist_min_sq) {
137 dist_min_sq = dist_sq;
138 this->curr_sv_index = i;
139 }
140 }
141 }
142};
143
150
152{
153 VertSlideParams *slp = static_cast<VertSlideParams *>(t->custom.mode.data);
154 VertSlideData *sld = static_cast<VertSlideData *>(
155 TRANS_DATA_CONTAINER_FIRST_OK(t)->custom.mode.data);
156 TransDataVertSlideVert *sv = &sld->sv[sld->curr_sv_index];
157
158 const float3 co_orig_3d = sv->co_orig_3d();
159 const float3 co_dest_3d = sv->co_dest_3d();
160
161 int mval_ofs[2], mval_start[2], mval_end[2];
162
163 const float2 co_orig_2d = sld->project(co_orig_3d);
164 const float2 co_curr_2d = sld->project(co_dest_3d);
165
166 ARRAY_SET_ITEMS(mval_ofs, t->mouse.imval[0] - co_orig_2d[0], t->mouse.imval[1] - co_orig_2d[1]);
167 ARRAY_SET_ITEMS(mval_start, co_orig_2d[0] + mval_ofs[0], co_orig_2d[1] + mval_ofs[1]);
168 ARRAY_SET_ITEMS(mval_end, co_curr_2d[0] + mval_ofs[0], co_curr_2d[1] + mval_ofs[1]);
169
170 if (slp->flipped && slp->use_even) {
171 setCustomPoints(t, &t->mouse, mval_start, mval_end);
172 }
173 else {
174 setCustomPoints(t, &t->mouse, mval_end, mval_start);
175 }
176}
177
179{
181
182 /* #setCustomPoints isn't normally changing as the mouse moves,
183 * in this case apply mouse input immediately so we don't refresh
184 * with the value from the previous points. */
185 applyMouseInput(t, &t->mouse, t->mval, t->values);
186}
187
189{
190 VertSlideData *sld = MEM_new<VertSlideData>(__func__);
193 }
194 else {
196 }
197
198 if (sld->sv.is_empty()) {
199 MEM_delete(sld);
200 return nullptr;
201 }
202
203 sld->curr_sv_index = 0;
204 sld->update_proj_mat(t, tc);
205 return sld;
206}
207
208static void freeVertSlideVerts(TransInfo * /*t*/,
209 TransDataContainer * /*tc*/,
210 TransCustomData *custom_data)
211{
212 VertSlideData *sld = static_cast<VertSlideData *>(custom_data->data);
213
214 if (!sld) {
215 return;
216 }
217
218 MEM_delete(sld);
219 custom_data->data = nullptr;
220}
221
223{
224 if (t->redraw && event->type != MOUSEMOVE) {
225 /* Event already handled. */
226 return TREDRAW_NOTHING;
227 }
228
229 VertSlideParams *slp = static_cast<VertSlideParams *>(t->custom.mode.data);
230 if (slp) {
231 switch (event->type) {
232 case EVT_EKEY:
233 if (event->val == KM_PRESS) {
234 slp->use_even = !slp->use_even;
235 if (slp->flipped) {
237 }
238 return TREDRAW_HARD;
239 }
240 break;
241 case EVT_FKEY:
242 if (event->val == KM_PRESS) {
243 slp->flipped = !slp->flipped;
245 return TREDRAW_HARD;
246 }
247 break;
248 case EVT_CKEY:
249 /* Use like a modifier key. */
250 if (event->val == KM_PRESS) {
251 t->flag ^= T_ALT_TRANSFORM;
253 return TREDRAW_HARD;
254 }
255 break;
256 case MOUSEMOVE: {
257 /* Don't recalculate the best edge. */
258 const bool is_clamp = !(t->flag & T_ALT_TRANSFORM);
259 if (is_clamp) {
261 VertSlideData *sld = static_cast<VertSlideData *>(tc->custom.mode.data);
262 sld->update_active_edges(t, float2(event->mval));
263 }
265 break;
266 }
267 default:
268 break;
269 }
270 }
271 return TREDRAW_NOTHING;
272}
273
275{
277 VertSlideData *sld = static_cast<VertSlideData *>(tc->custom.mode.data);
278 if (sld) {
279 const VertSlideParams *slp = static_cast<const VertSlideParams *>(t->custom.mode.data);
280 const bool is_clamp = !(t->flag & T_ALT_TRANSFORM);
281
282 /* Non-Prop mode. */
283 {
284 TransDataVertSlideVert *curr_sv = &sld->sv[sld->curr_sv_index];
285
286 const float3 co_orig_3d_act = curr_sv->co_orig_3d();
287 const float3 co_dest_3d_act = curr_sv->co_dest_3d();
288
289 const float ctrl_size = UI_GetThemeValuef(TH_FACEDOT_SIZE) + 1.5f;
290 const float line_size = UI_GetThemeValuef(TH_OUTLINE_WIDTH) + 0.5f;
291 const int alpha_shade = -160;
292
294
296
298 if (t->spacetype == SPACE_VIEW3D) {
299 GPU_matrix_mul(tc->obedit->object_to_world().ptr());
300 }
301 else {
302 GPU_matrix_scale_2f(1 / t->aspect[0], 1 / t->aspect[1]);
303 }
304
305 GPU_line_width(line_size);
306
307 const uint shdr_pos = GPU_vertformat_attr_add(
308 immVertexFormat(), "pos", blender::gpu::VertAttrType::SFLOAT_32_32_32);
309
312
313 immBegin(GPU_PRIM_LINES, sld->sv.size() * 2);
314 if (is_clamp) {
315 for (TransDataVertSlideVert &sv : sld->sv) {
316 immVertex3fv(shdr_pos, sv.co_orig_3d());
317 immVertex3fv(shdr_pos, sv.co_dest_3d());
318 }
319 }
320 else {
321 for (TransDataVertSlideVert &sv : sld->sv) {
322 const float3 co_orig_3d = sv.co_orig_3d();
323 const float3 co_dest_3d = sv.co_dest_3d();
324 float a[3], b[3];
325 sub_v3_v3v3(a, co_dest_3d, co_orig_3d);
326 mul_v3_fl(a, 100.0f);
327 negate_v3_v3(b, a);
328 add_v3_v3(a, co_orig_3d);
329 add_v3_v3(b, co_orig_3d);
330
331 immVertex3fv(shdr_pos, a);
332 immVertex3fv(shdr_pos, b);
333 }
334 }
335 immEnd();
336
338
340
341 GPU_point_size(ctrl_size);
343
345 immVertex3fv(shdr_pos, (slp->flipped && slp->use_even) ? co_dest_3d_act : co_orig_3d_act);
346 immEnd();
347
349
351
352 /* Direction from active vertex! */
353 if (!compare_v2v2(t->mval, t->mouse.imval, FLT_EPSILON)) {
354 /* 2D Pixel Space. */
359
360 float3 co_orig_3d_cpy = co_orig_3d_act;
361 if (t->spacetype != SPACE_VIEW3D) {
362 co_orig_3d_cpy[0] /= t->aspect[0];
363 co_orig_3d_cpy[1] /= t->aspect[1];
364 }
365
366 float2 loc_src_act_2d = sld->project(co_orig_3d_cpy);
367 float2 loc_mval_dir = loc_src_act_2d + (t->mval - t->mouse.imval);
368
369 GPU_line_width(1.0f);
370
371 const uint shdr_pos_2d = GPU_vertformat_attr_add(
372 immVertexFormat(), "pos", blender::gpu::VertAttrType::SFLOAT_32_32);
373
375
376 float viewport_size[4];
377 GPU_viewport_size_get_f(viewport_size);
378 immUniform2f("viewport_size", viewport_size[2], viewport_size[3]);
379
380 immUniform1i("colors_len", 0); /* "simple" mode. */
381 immUniformColor4f(1.0f, 1.0f, 1.0f, 1.0f);
382 immUniform1f("dash_width", 6.0f);
383 immUniform1f("udash_factor", 0.5f);
384
386 immVertex2fv(shdr_pos_2d, loc_src_act_2d);
387 immVertex2fv(shdr_pos_2d, loc_mval_dir);
388 immEnd();
389
391
394 }
395 }
396 }
397}
398
400 const float perc,
401 const bool use_even,
402 const bool use_flip,
403 float r_co[3])
404{
405 const float3 co_orig_3d = sv.co_orig_3d();
406 const float3 co_dest_3d = sv.co_dest_3d();
407 if (use_even == false) {
408 interp_v3_v3v3(r_co, co_orig_3d, co_dest_3d, perc);
409 }
410 else {
411 float dir[3];
412 sub_v3_v3v3(dir, co_dest_3d, co_orig_3d);
413 float edge_len = normalize_v3(dir);
414 if (edge_len > FLT_EPSILON) {
415 if (use_flip) {
416 madd_v3_v3v3fl(r_co, co_dest_3d, dir, -perc);
417 }
418 else {
419 madd_v3_v3v3fl(r_co, co_orig_3d, dir, perc);
420 }
421 }
422 else {
423 copy_v3_v3(r_co, co_orig_3d);
424 }
425 }
426}
427
428static void doVertSlide(TransInfo *t, float perc)
429{
430 VertSlideParams *slp = static_cast<VertSlideParams *>(t->custom.mode.data);
431
432 slp->perc = perc;
433
434 const bool use_even = slp->use_even;
435
437 VertSlideData *sld = static_cast<VertSlideData *>(tc->custom.mode.data);
438 if (sld == nullptr) {
439 continue;
440 }
441
442 float tperc = perc;
443 if (use_even) {
444 TransDataVertSlideVert *sv_curr = &sld->sv[sld->curr_sv_index];
445 const float edge_len_curr = len_v3v3(sv_curr->co_orig_3d(), sv_curr->co_dest_3d());
446 tperc *= edge_len_curr;
447 }
448
449 for (TransDataVertSlideVert &sv : sld->sv) {
450 vert_slide_apply_elem(sv, tperc, use_even, slp->flipped, sv.td->loc);
451 }
452 }
453}
454
455static void vert_slide_snap_apply(TransInfo *t, float *value)
456{
458 VertSlideData *sld = static_cast<VertSlideData *>(tc->custom.mode.data);
459 TransDataVertSlideVert *sv = &sld->sv[sld->curr_sv_index];
460 float3 co_orig_3d = sv->co_orig_3d();
461 float3 co_curr_3d = sv->co_dest_3d();
462
463 float snap_point[3], dvec[3];
464 if (tc->use_local_mat) {
465 mul_m4_v3(tc->mat, co_orig_3d);
466 mul_m4_v3(tc->mat, co_curr_3d);
467 }
468
469 getSnapPoint(t, dvec);
470 sub_v3_v3(dvec, t->tsnap.snap_source);
472 float co_dir[3];
473 sub_v3_v3v3(co_dir, co_curr_3d, co_orig_3d);
474 normalize_v3(co_dir);
477 }
478 else {
480 }
481 }
482
483 add_v3_v3v3(snap_point, co_orig_3d, dvec);
484 *value = line_point_factor_v3(snap_point, co_orig_3d, co_curr_3d);
485}
486
488{
489 char str[UI_MAX_DRAW_STR];
490 size_t ofs = 0;
491 float final;
492 VertSlideParams *slp = static_cast<VertSlideParams *>(t->custom.mode.data);
493 const bool flipped = slp->flipped;
494 const bool use_even = slp->use_even;
495 const bool is_clamp = !(t->flag & T_ALT_TRANSFORM);
496 const bool is_constrained = !(is_clamp == false || hasNumInput(&t->num));
497 const bool is_precision = t->modifiers & MOD_PRECISION;
498 const bool is_snap = t->modifiers & MOD_SNAP;
499 const bool is_snap_invert = t->modifiers & MOD_SNAP_INVERT;
500
501 final = t->values[0] + t->values_modal_offset[0];
502
504 if (!validSnap(t)) {
505 transform_snap_increment(t, &final);
506 }
507
508 /* Only do this so out of range values are not displayed. */
509 if (is_constrained) {
510 CLAMP(final, 0.0f, 1.0f);
511 }
512
513 applyNumInput(&t->num, &final);
514
515 t->values_final[0] = final;
516
517 /* Header string. */
518 ofs += BLI_strncpy_utf8_rlen(str + ofs, IFACE_("Vertex Slide: "), sizeof(str) - ofs);
519 if (hasNumInput(&t->num)) {
520 char c[NUM_STR_REP_LEN];
521 outputNumInput(&(t->num), c, t->scene->unit);
522 ofs += BLI_strncpy_utf8_rlen(str + ofs, &c[0], sizeof(str) - ofs);
523 }
524 else {
525 ofs += BLI_snprintf_utf8_rlen(str + ofs, sizeof(str) - ofs, "%.4f ", final);
526 }
527 /* Done with header string. */
528
529 /* Do stuff here. */
530 doVertSlide(t, final);
531
532 recalc_data(t);
533
535
536 wmOperator *op = slp->op;
537 if (!op) {
538 return;
539 }
540
542 status.opmodal(IFACE_("Confirm"), op->type, TFM_MODAL_CONFIRM);
543 status.opmodal(IFACE_("Cancel"), op->type, TFM_MODAL_CONFIRM);
544 status.opmodal(IFACE_("Snap"), op->type, TFM_MODAL_SNAP_TOGGLE, is_snap);
545 status.opmodal(IFACE_("Snap Invert"), op->type, TFM_MODAL_SNAP_INV_ON, is_snap_invert);
546 status.opmodal(IFACE_("Set Snap Base"), op->type, TFM_MODAL_EDIT_SNAP_SOURCE_ON);
547 status.opmodal(IFACE_("Move"), op->type, TFM_MODAL_TRANSLATE);
548 status.opmodal(IFACE_("Rotate"), op->type, TFM_MODAL_ROTATE);
549 status.opmodal(IFACE_("Resize"), op->type, TFM_MODAL_RESIZE);
550 status.opmodal(IFACE_("Precision Mode"), op->type, TFM_MODAL_PRECISION, is_precision);
551 status.item_bool(IFACE_("Clamp"), is_clamp, ICON_EVENT_C, ICON_EVENT_ALT);
552 status.item_bool(IFACE_("Even"), use_even, ICON_EVENT_E);
553 if (use_even) {
554 status.item_bool(IFACE_("Flipped"), flipped, ICON_EVENT_F);
555 }
556}
557
558static void vert_slide_transform_matrix_fn(TransInfo *t, float mat_xform[4][4])
559{
560 float delta[3];
561
562 VertSlideParams *slp = static_cast<VertSlideParams *>(t->custom.mode.data);
564 VertSlideData *sld = static_cast<VertSlideData *>(tc->custom.mode.data);
565 TransDataVertSlideVert &sv_active = sld->sv[sld->curr_sv_index];
566 float3 orig_co = sv_active.co_orig_3d();
567 const float3 &loc_dst_act = sv_active.co_dest_3d();
568
569 float tperc = t->values_final[0];
570 if (slp->use_even) {
571 const float edge_len_curr = len_v3v3(orig_co, loc_dst_act);
572 tperc *= edge_len_curr;
573 }
574
575 float3 final_co;
576 vert_slide_apply_elem(sv_active, tperc, slp->use_even, slp->flipped, final_co);
577
578 if (tc->use_local_mat) {
579 mul_m4_v3(tc->mat, orig_co);
580 mul_m4_v3(tc->mat, final_co);
581 }
582
583 sub_v3_v3v3(delta, final_co, orig_co);
584 add_v3_v3(mat_xform[3], delta);
585}
586
588 TransInfo *t, wmOperator *op, bool use_even, bool flipped, bool use_clamp)
589{
590
591 t->mode = TFM_VERT_SLIDE;
592
593 {
595 slp->use_even = use_even;
596 slp->flipped = flipped;
597 slp->perc = 0.0f;
598 slp->op = op;
599
600 if (!use_clamp) {
601 t->flag |= T_ALT_TRANSFORM;
602 }
603
604 t->custom.mode.data = slp;
605 t->custom.mode.use_free = true;
606 }
607
608 bool ok = false;
611 if (sld) {
612 sld->update_active_vert(t, t->mval);
613 sld->update_active_edges(t, t->mval);
614
615 tc->custom.mode.data = sld;
616 tc->custom.mode.free_cb = freeVertSlideVerts;
617 ok = true;
618 }
619 }
620
621 if (ok == false) {
622 t->state = TRANS_CANCEL;
623 return;
624 }
625
626 /* Set custom point first if you want value to be initialized by init. */
629
630 t->idx_max = 0;
631 t->num.idx_max = 0;
632 t->increment[0] = 0.1f;
633 t->increment_precision = 0.1f;
634
635 copy_v3_fl(t->num.val_inc, t->increment[0]);
636 t->num.unit_sys = t->scene->unit.system;
637 t->num.unit_type[0] = B_UNIT_NONE;
638}
639
641{
642 bool use_even = false;
643 bool flipped = false;
644 bool use_clamp = true;
645 if (op) {
646 PropertyRNA *prop;
647 prop = RNA_struct_find_property(op->ptr, "use_even");
648 use_even = (prop) ? RNA_property_boolean_get(op->ptr, prop) : false;
649 prop = RNA_struct_find_property(op->ptr, "flipped");
650 flipped = (prop) ? RNA_property_boolean_get(op->ptr, prop) : false;
651 prop = RNA_struct_find_property(op->ptr, "use_clamp");
652 use_clamp = (prop) ? RNA_property_boolean_get(op->ptr, prop) : true;
653 }
654 initVertSlide_ex(t, op, use_even, flipped, use_clamp);
655}
656
658
659/* -------------------------------------------------------------------- */
662
664{
666 VertSlideData *sld = static_cast<VertSlideData *>(tc->custom.mode.data);
667 if (sld) {
668 sld->update_proj_mat(t, tc);
669 }
670 }
671
673}
674
676
678 /*flags*/ T_NO_CONSTRAINT,
679 /*init_fn*/ initVertSlide,
680 /*transform_fn*/ applyVertSlide,
681 /*transform_matrix_fn*/ vert_slide_transform_matrix_fn,
682 /*handle_event_fn*/ handleEventVertSlide,
683 /*snap_distance_fn*/ transform_snap_distance_len_squared_fn,
684 /*snap_apply_fn*/ vert_slide_snap_apply,
685 /*draw_fn*/ drawVertSlide,
686};
687
688} // namespace blender::ed::transform
@ B_UNIT_NONE
Definition BKE_unit.hh:136
float line_point_factor_v3(const float p[3], const float l1[3], const float l2[3])
void mul_m4_v3(const float M[4][4], float r[3])
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
MINLINE void sub_v3_v3(float r[3], const float a[3])
MINLINE void sub_v3_v3v3(float r[3], const float a[3], const float b[3])
MINLINE void mul_v3_fl(float r[3], float f)
MINLINE void copy_v3_v3(float r[3], const float a[3])
MINLINE void negate_v3_v3(float r[3], const float a[3])
void interp_v3_v3v3(float r[3], const float a[3], const float b[3], float t)
MINLINE void add_v3_v3v3(float r[3], const float a[3], const float b[3])
MINLINE bool compare_v2v2(const float v1[2], const float v2[2], float limit) ATTR_WARN_UNUSED_RESULT
MINLINE void copy_v3_fl(float r[3], float f)
MINLINE void madd_v3_v3v3fl(float r[3], const float a[3], const float b[3], float f)
MINLINE void add_v3_v3(float r[3], const float a[3])
MINLINE float normalize_v3(float n[3])
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
size_t BLI_snprintf_utf8_rlen(char *__restrict dst, size_t dst_maxncpy, const char *__restrict format,...) ATTR_NONNULL(1
unsigned int uint
#define CLAMP(a, b, c)
#define ARRAY_SET_ITEMS(...)
#define UNLIKELY(x)
#define IFACE_(msgid)
@ SCE_SNAP_TO_EDGE
@ SCE_SNAP_TO_FACE
@ SPACE_VIEW3D
#define NUM_STR_REP_LEN
bool applyNumInput(NumInput *n, float *vec)
Definition numinput.cc:190
void outputNumInput(NumInput *n, char *str, const UnitSettings &unit_settings)
Definition numinput.cc:88
bool hasNumInput(const NumInput *n)
Definition numinput.cc:171
void ED_area_status_text(ScrArea *area, const char *str)
Definition area.cc:851
blender::float4x4 ED_view3d_ob_project_mat_get(const RegionView3D *rv3d, const Object *ob)
void immEnd()
void immUnbindProgram()
void immBindBuiltinProgram(GPUBuiltinShader shader_id)
void immUniform2f(const char *name, float x, float y)
void immUniformThemeColorShadeAlpha(int color_id, int color_offset, int alpha_offset)
void immUniformColor4f(float r, float g, float b, float a)
void immVertex2fv(uint attr_id, const float data[2])
void immUniform1i(const char *name, int x)
void immUniform1f(const char *name, float x)
GPUVertFormat * immVertexFormat()
void immVertex3fv(uint attr_id, const float data[3])
void immBegin(GPUPrimType, uint vertex_len)
void GPU_matrix_identity_set()
void GPU_matrix_scale_2f(float x, float y)
void GPU_matrix_push()
void GPU_matrix_push_projection()
#define GPU_matrix_mul(x)
void GPU_matrix_pop_projection()
void GPU_matrix_pop()
@ GPU_PRIM_LINES
@ GPU_PRIM_POINTS
@ GPU_SHADER_3D_LINE_DASHED_UNIFORM_COLOR
@ GPU_SHADER_3D_UNIFORM_COLOR
@ GPU_SHADER_3D_POINT_UNIFORM_COLOR
@ GPU_DEPTH_NONE
Definition GPU_state.hh:111
void GPU_line_width(float width)
Definition gpu_state.cc:166
@ GPU_BLEND_ALPHA
Definition GPU_state.hh:87
void GPU_blend(GPUBlend blend)
Definition gpu_state.cc:42
void GPU_depth_test(GPUDepthTest test)
Definition gpu_state.cc:68
void GPU_point_size(float size)
Definition gpu_state.cc:172
void GPU_viewport_size_get_f(float coords[4])
Definition gpu_state.cc:273
uint GPU_vertformat_attr_add(GPUVertFormat *format, blender::StringRef name, blender::gpu::VertAttrType type)
#define UI_MAX_DRAW_STR
@ TH_VERTEX_ACTIVE
@ TH_FACEDOT_SIZE
@ TH_EDGE_SELECT
@ TH_OUTLINE_WIDTH
float UI_GetThemeValuef(int colorid)
void UI_view2d_view_to_region_m4(const View2D *v2d, float matrix[4][4]) ATTR_NONNULL()
Definition view2d.cc:1808
@ KM_PRESS
Definition WM_types.hh:311
IndexRange index_range() const
Definition BLI_array.hh:360
#define str(s)
void * MEM_callocN(size_t len, const char *str)
Definition mallocn.cc:118
Array< TransDataVertSlideVert > transform_mesh_vert_slide_data_create(const TransDataContainer *tc, Vector< float3 > &r_loc_dst_buffer)
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])
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 applyVertSlide(TransInfo *t)
TransConvertTypeInfo TransConvertType_MeshUV
static void initVertSlide_ex(TransInfo *t, wmOperator *op, bool use_even, bool flipped, bool use_clamp)
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)
MatBase< float, 4, 4 > float4x4
VecBase< float, 2 > float2
VecBase< float, 3 > float3
const int status
PropertyRNA * RNA_struct_find_property(PointerRNA *ptr, const char *identifier)
bool RNA_property_boolean_get(PointerRNA *ptr, PropertyRNA *prop)
#define FLT_MAX
Definition stdcycles.h:14
void * regiondata
short idx_max
float val_inc[NUM_MAX_ELEMENTS]
int unit_type[NUM_MAX_ELEMENTS]
struct UnitSettings unit
const c_style_mat & ptr() const
VecBase< T, 2 > xy() const
TransConvertTypeInfo * data_type
Definition transform.hh:810
TransCustomDataContainer custom
Definition transform.hh:974
void update_active_edges(TransInfo *t, const float2 &mval_fl)
void update_proj_mat(TransInfo *t, const TransDataContainer *tc)
void update_active_vert(TransInfo *, const float2 &mval_fl)
wmEventType type
Definition WM_types.hh:757
short val
Definition WM_types.hh:759
int mval[2]
Definition WM_types.hh:763
struct wmOperatorType * type
struct PointerRNA * ptr
i
Definition text_draw.cc:230
#define TRANS_DATA_CONTAINER_FIRST_OK(t)
Definition transform.hh:37
#define FOREACH_TRANS_DATA_CONTAINER(t, th)
Definition transform.hh:42
conversion and adaptation of different datablocks to a common struct.
transform modes used by different operators.
@ EVT_EKEY
@ EVT_FKEY
@ EVT_CKEY
@ MOUSEMOVE
void wmOrtho2_region_pixelspace(const ARegion *region)