Blender  V3.3
transform_mode_vert_slide.c
Go to the documentation of this file.
1 /* SPDX-License-Identifier: GPL-2.0-or-later
2  * Copyright 2001-2002 NaN Holding BV. All rights reserved. */
3 
8 #include <stdlib.h>
9 
10 #include "MEM_guardedalloc.h"
11 
12 #include "BLI_math.h"
13 #include "BLI_string.h"
14 
15 #include "BKE_context.h"
16 #include "BKE_editmesh.h"
17 #include "BKE_unit.h"
18 
19 #include "GPU_immediate.h"
20 #include "GPU_matrix.h"
21 #include "GPU_state.h"
22 
23 #include "ED_screen.h"
24 
25 #include "WM_api.h"
26 #include "WM_types.h"
27 
28 #include "UI_interface.h"
29 #include "UI_resources.h"
30 
31 #include "BLT_translation.h"
32 
33 #include "transform.h"
34 #include "transform_constraints.h"
35 #include "transform_convert.h"
36 #include "transform_mode.h"
37 #include "transform_snap.h"
38 
39 /* -------------------------------------------------------------------- */
43 typedef struct TransDataVertSlideVert {
45  struct BMVert *v;
47  float co_orig_3d[3];
48  /* end generic */
49 
54 
55 typedef struct VertSlideData {
57  int totsv;
59 
60  /* result of ED_view3d_ob_project_mat_get */
61  float proj_mat[4][4];
63 
64 typedef struct VertSlideParams {
65  float perc;
66 
67  bool use_even;
68  bool flipped;
70 
72 {
73  VertSlideParams *slp = t->custom.mode.data;
74  VertSlideData *sld = TRANS_DATA_CONTAINER_FIRST_OK(t)->custom.mode.data;
75  TransDataVertSlideVert *sv = &sld->sv[sld->curr_sv_index];
76 
77  const float *co_orig_3d = sv->co_orig_3d;
78  const float *co_curr_3d = sv->co_link_orig_3d[sv->co_link_curr];
79 
80  float co_curr_2d[2], co_orig_2d[2];
81 
82  int mval_ofs[2], mval_start[2], mval_end[2];
83 
84  ED_view3d_project_float_v2_m4(t->region, co_orig_3d, co_orig_2d, sld->proj_mat);
85  ED_view3d_project_float_v2_m4(t->region, co_curr_3d, co_curr_2d, sld->proj_mat);
86 
87  ARRAY_SET_ITEMS(mval_ofs, t->mouse.imval[0] - co_orig_2d[0], t->mouse.imval[1] - co_orig_2d[1]);
88  ARRAY_SET_ITEMS(mval_start, co_orig_2d[0] + mval_ofs[0], co_orig_2d[1] + mval_ofs[1]);
89  ARRAY_SET_ITEMS(mval_end, co_curr_2d[0] + mval_ofs[0], co_curr_2d[1] + mval_ofs[1]);
90 
91  if (slp->flipped && slp->use_even) {
92  setCustomPoints(t, &t->mouse, mval_start, mval_end);
93  }
94  else {
95  setCustomPoints(t, &t->mouse, mval_end, mval_start);
96  }
97 }
98 
100 {
102 
103  /* setCustomPoints isn't normally changing as the mouse moves,
104  * in this case apply mouse input immediately so we don't refresh
105  * with the value from the previous points */
106  applyMouseInput(t, &t->mouse, t->mval, t->values);
107 }
108 
112 static void calcVertSlideMouseActiveVert(struct TransInfo *t, const int mval[2])
113 {
114  /* Active object may have no selected vertices. */
115  VertSlideData *sld = TRANS_DATA_CONTAINER_FIRST_OK(t)->custom.mode.data;
116  const float mval_fl[2] = {UNPACK2(mval)};
118 
119  /* set the vertex to use as a reference for the mouse direction 'curr_sv_index' */
120  float dist_sq = 0.0f;
121  float dist_min_sq = FLT_MAX;
122  int i;
123 
124  for (i = 0, sv = sld->sv; i < sld->totsv; i++, sv++) {
125  float co_2d[2];
126 
127  ED_view3d_project_float_v2_m4(t->region, sv->co_orig_3d, co_2d, sld->proj_mat);
128 
129  dist_sq = len_squared_v2v2(mval_fl, co_2d);
130  if (dist_sq < dist_min_sq) {
131  dist_min_sq = dist_sq;
132  sld->curr_sv_index = i;
133  }
134  }
135 }
136 
140 static void calcVertSlideMouseActiveEdges(struct TransInfo *t, const int mval[2])
141 {
142  VertSlideData *sld = TRANS_DATA_CONTAINER_FIRST_OK(t)->custom.mode.data;
143  const float imval_fl[2] = {UNPACK2(t->mouse.imval)};
144  const float mval_fl[2] = {UNPACK2(mval)};
145 
146  float dir[3];
148  int i;
149 
150  /* NOTE: we could save a matrix-multiply for each vertex
151  * by finding the closest edge in local-space.
152  * However this skews the outcome with non-uniform-scale. */
153 
154  /* First get the direction of the original mouse position. */
155  sub_v2_v2v2(dir, imval_fl, mval_fl);
156  ED_view3d_win_to_delta(t->region, dir, t->zfac, dir);
157  normalize_v3(dir);
158 
159  for (i = 0, sv = sld->sv; i < sld->totsv; i++, sv++) {
160  if (sv->co_link_tot > 1) {
161  float dir_dot_best = -FLT_MAX;
162  int co_link_curr_best = -1;
163  int j;
164 
165  for (j = 0; j < sv->co_link_tot; j++) {
166  float tdir[3];
167  float dir_dot;
168 
169  sub_v3_v3v3(tdir, sv->co_orig_3d, sv->co_link_orig_3d[j]);
170  mul_mat3_m4_v3(TRANS_DATA_CONTAINER_FIRST_OK(t)->obedit->obmat, tdir);
171  project_plane_v3_v3v3(tdir, tdir, t->viewinv[2]);
172 
173  normalize_v3(tdir);
174  dir_dot = dot_v3v3(dir, tdir);
175  if (dir_dot > dir_dot_best) {
176  dir_dot_best = dir_dot;
177  co_link_curr_best = j;
178  }
179  }
180 
181  if (co_link_curr_best != -1) {
182  sv->co_link_curr = co_link_curr_best;
183  }
184  }
185  }
186 }
187 
189 {
191  BMesh *bm = em->bm;
192  BMIter iter;
193  BMIter eiter;
194  BMEdge *e;
195  BMVert *v;
196  TransDataVertSlideVert *sv_array;
197  VertSlideData *sld = MEM_callocN(sizeof(*sld), "sld");
198  int j;
199 
200  sld->curr_sv_index = 0;
201 
202  j = 0;
203  BM_ITER_MESH (v, &iter, bm, BM_VERTS_OF_MESH) {
204  bool ok = false;
205  if (BM_elem_flag_test(v, BM_ELEM_SELECT) && v->e) {
206  BM_ITER_ELEM (e, &eiter, v, BM_EDGES_OF_VERT) {
208  ok = true;
209  break;
210  }
211  }
212  }
213 
214  if (ok) {
216  j += 1;
217  }
218  else {
220  }
221  }
222 
223  if (!j) {
224  MEM_freeN(sld);
225  return NULL;
226  }
227 
228  sv_array = MEM_callocN(sizeof(TransDataVertSlideVert) * j, "sv_array");
229 
230  j = 0;
231  BM_ITER_MESH (v, &iter, bm, BM_VERTS_OF_MESH) {
233  int k;
234  sv_array[j].v = v;
235  copy_v3_v3(sv_array[j].co_orig_3d, v->co);
236 
237  k = 0;
238  BM_ITER_ELEM (e, &eiter, v, BM_EDGES_OF_VERT) {
240  k++;
241  }
242  }
243 
244  sv_array[j].co_link_orig_3d = MEM_mallocN(sizeof(*sv_array[j].co_link_orig_3d) * k,
245  __func__);
246  sv_array[j].co_link_tot = k;
247 
248  k = 0;
249  BM_ITER_ELEM (e, &eiter, v, BM_EDGES_OF_VERT) {
251  BMVert *v_other = BM_edge_other_vert(e, v);
252  copy_v3_v3(sv_array[j].co_link_orig_3d[k], v_other->co);
253  k++;
254  }
255  }
256  j++;
257  }
258  }
259 
260  sld->sv = sv_array;
261  sld->totsv = j;
262 
263  /* most likely will be set below */
264  unit_m4(sld->proj_mat);
265 
266  if (t->spacetype == SPACE_VIEW3D) {
267  /* view vars */
268  RegionView3D *rv3d = NULL;
269  ARegion *region = t->region;
270 
271  rv3d = region ? region->regiondata : NULL;
272  if (rv3d) {
274  }
275  }
276 
277  return sld;
278 }
279 
282  TransCustomData *custom_data)
283 {
284  VertSlideData *sld = custom_data->data;
285 
286  if (!sld) {
287  return;
288  }
289 
290  if (sld->totsv > 0) {
291  TransDataVertSlideVert *sv = sld->sv;
292  int i = 0;
293  for (i = 0; i < sld->totsv; i++, sv++) {
295  }
296  }
297 
298  MEM_freeN(sld->sv);
299  MEM_freeN(sld);
300 
301  custom_data->data = NULL;
302 }
303 
304 static eRedrawFlag handleEventVertSlide(struct TransInfo *t, const struct wmEvent *event)
305 {
306  if (t->mode == TFM_VERT_SLIDE) {
307  VertSlideParams *slp = t->custom.mode.data;
308 
309  if (slp) {
310  switch (event->type) {
311  case EVT_EKEY:
312  if (event->val == KM_PRESS) {
313  slp->use_even = !slp->use_even;
314  if (slp->flipped) {
316  }
317  return TREDRAW_HARD;
318  }
319  break;
320  case EVT_FKEY:
321  if (event->val == KM_PRESS) {
322  slp->flipped = !slp->flipped;
324  return TREDRAW_HARD;
325  }
326  break;
327  case EVT_CKEY:
328  /* use like a modifier key */
329  if (event->val == KM_PRESS) {
330  t->flag ^= T_ALT_TRANSFORM;
332  return TREDRAW_HARD;
333  }
334  break;
335 #if 0
336  case EVT_MODAL_MAP:
337  switch (event->val) {
339  sld->curr_sv_index = ((sld->curr_sv_index - 1) + sld->totsv) % sld->totsv;
340  break;
342  sld->curr_sv_index = (sld->curr_sv_index + 1) % sld->totsv;
343  break;
344  }
345  break;
346 #endif
347  case MOUSEMOVE: {
348  /* don't recalculate the best edge */
349  const bool is_clamp = !(t->flag & T_ALT_TRANSFORM);
350  if (is_clamp) {
352  }
354  break;
355  }
356  default:
357  break;
358  }
359  }
360  }
361  return TREDRAW_NOTHING;
362 }
363 
365 {
366  if ((t->mode == TFM_VERT_SLIDE) && TRANS_DATA_CONTAINER_FIRST_OK(t)->custom.mode.data) {
367  const VertSlideParams *slp = t->custom.mode.data;
368  VertSlideData *sld = TRANS_DATA_CONTAINER_FIRST_OK(t)->custom.mode.data;
369  const bool is_clamp = !(t->flag & T_ALT_TRANSFORM);
370 
371  /* Non-Prop mode */
372  {
373  TransDataVertSlideVert *curr_sv = &sld->sv[sld->curr_sv_index];
375  const float ctrl_size = UI_GetThemeValuef(TH_FACEDOT_SIZE) + 1.5f;
376  const float line_size = UI_GetThemeValuef(TH_OUTLINE_WIDTH) + 0.5f;
377  const int alpha_shade = -160;
378  int i;
379 
381 
383 
384  GPU_matrix_push();
386 
387  GPU_line_width(line_size);
388 
389  const uint shdr_pos = GPU_vertformat_attr_add(
391 
394 
395  immBegin(GPU_PRIM_LINES, sld->totsv * 2);
396  if (is_clamp) {
397  sv = sld->sv;
398  for (i = 0; i < sld->totsv; i++, sv++) {
399  immVertex3fv(shdr_pos, sv->co_orig_3d);
400  immVertex3fv(shdr_pos, sv->co_link_orig_3d[sv->co_link_curr]);
401  }
402  }
403  else {
404  sv = sld->sv;
405  for (i = 0; i < sld->totsv; i++, sv++) {
406  float a[3], b[3];
408  mul_v3_fl(a, 100.0f);
409  negate_v3_v3(b, a);
410  add_v3_v3(a, sv->co_orig_3d);
411  add_v3_v3(b, sv->co_orig_3d);
412 
413  immVertex3fv(shdr_pos, a);
414  immVertex3fv(shdr_pos, b);
415  }
416  }
417  immEnd();
418 
419  GPU_point_size(ctrl_size);
420 
422  immVertex3fv(shdr_pos,
423  (slp->flipped && slp->use_even) ?
424  curr_sv->co_link_orig_3d[curr_sv->co_link_curr] :
425  curr_sv->co_orig_3d);
426  immEnd();
427 
429 
430  /* direction from active vertex! */
431  if ((t->mval[0] != t->mouse.imval[0]) || (t->mval[1] != t->mouse.imval[1])) {
432  float zfac;
433  float xy_delta[2];
434  float co_orig_3d[3];
435  float co_dest_3d[3];
436 
437  xy_delta[0] = t->mval[0] - t->mouse.imval[0];
438  xy_delta[1] = t->mval[1] - t->mouse.imval[1];
439 
440  mul_v3_m4v3(
441  co_orig_3d, TRANS_DATA_CONTAINER_FIRST_OK(t)->obedit->obmat, curr_sv->co_orig_3d);
442  zfac = ED_view3d_calc_zfac(t->region->regiondata, co_orig_3d);
443 
444  ED_view3d_win_to_delta(t->region, xy_delta, zfac, co_dest_3d);
445 
447  TRANS_DATA_CONTAINER_FIRST_OK(t)->obedit->obmat);
448  mul_mat3_m4_v3(TRANS_DATA_CONTAINER_FIRST_OK(t)->obedit->imat, co_dest_3d);
449 
450  add_v3_v3(co_dest_3d, curr_sv->co_orig_3d);
451 
452  GPU_line_width(1.0f);
453 
455 
456  float viewport_size[4];
457  GPU_viewport_size_get_f(viewport_size);
458  immUniform2f("viewport_size", viewport_size[2], viewport_size[3]);
459 
460  immUniform1i("colors_len", 0); /* "simple" mode */
461  immUniformColor4f(1.0f, 1.0f, 1.0f, 1.0f);
462  immUniform1f("dash_width", 6.0f);
463  immUniform1f("dash_factor", 0.5f);
464 
466  immVertex3fv(shdr_pos, curr_sv->co_orig_3d);
467  immVertex3fv(shdr_pos, co_dest_3d);
468  immEnd();
469 
471  }
472 
473  GPU_matrix_pop();
474 
476  }
477  }
478 }
479 
480 static void doVertSlide(TransInfo *t, float perc)
481 {
482  VertSlideParams *slp = t->custom.mode.data;
483 
484  slp->perc = perc;
485 
487  VertSlideData *sld = tc->custom.mode.data;
488  if (sld == NULL) {
489  continue;
490  }
491 
492  TransDataVertSlideVert *svlist = sld->sv, *sv;
493  int i;
494 
495  sv = svlist;
496 
497  if (slp->use_even == false) {
498  for (i = 0; i < sld->totsv; i++, sv++) {
499  interp_v3_v3v3(sv->v->co, sv->co_orig_3d, sv->co_link_orig_3d[sv->co_link_curr], perc);
500  }
501  }
502  else {
503  TransDataVertSlideVert *sv_curr = &sld->sv[sld->curr_sv_index];
504  const float edge_len_curr = len_v3v3(sv_curr->co_orig_3d,
505  sv_curr->co_link_orig_3d[sv_curr->co_link_curr]);
506  const float tperc = perc * edge_len_curr;
507 
508  for (i = 0; i < sld->totsv; i++, sv++) {
509  float edge_len;
510  float dir[3];
511 
512  sub_v3_v3v3(dir, sv->co_link_orig_3d[sv->co_link_curr], sv->co_orig_3d);
513  edge_len = normalize_v3(dir);
514 
515  if (edge_len > FLT_EPSILON) {
516  if (slp->flipped) {
517  madd_v3_v3v3fl(sv->v->co, sv->co_link_orig_3d[sv->co_link_curr], dir, -tperc);
518  }
519  else {
520  madd_v3_v3v3fl(sv->v->co, sv->co_orig_3d, dir, tperc);
521  }
522  }
523  else {
524  copy_v3_v3(sv->v->co, sv->co_orig_3d);
525  }
526  }
527  }
528  }
529 }
530 
531 static void vert_slide_snap_apply(TransInfo *t, float *value)
532 {
534  VertSlideData *sld = tc->custom.mode.data;
535  TransDataVertSlideVert *sv = &sld->sv[sld->curr_sv_index];
536 
537  float snap_point[3], co_orig_3d[3], co_curr_3d[3], dvec[3];
538  copy_v3_v3(co_orig_3d, sv->co_orig_3d);
539  copy_v3_v3(co_curr_3d, sv->co_link_orig_3d[sv->co_link_curr]);
540  if (tc->use_local_mat) {
541  mul_m4_v3(tc->mat, co_orig_3d);
542  mul_m4_v3(tc->mat, co_curr_3d);
543  }
544 
545  getSnapPoint(t, dvec);
546  sub_v3_v3(dvec, t->tsnap.snapTarget);
547  if (t->tsnap.snapElem & (SCE_SNAP_MODE_EDGE | SCE_SNAP_MODE_FACE_RAYCAST)) {
548  float co_dir[3];
549  sub_v3_v3v3(co_dir, co_curr_3d, co_orig_3d);
550  normalize_v3(co_dir);
551  if (t->tsnap.snapElem & SCE_SNAP_MODE_EDGE) {
553  }
554  else {
556  }
557  }
558 
559  add_v3_v3v3(snap_point, co_orig_3d, dvec);
560  *value = line_point_factor_v3(snap_point, co_orig_3d, co_curr_3d);
561 }
562 
563 static void applyVertSlide(TransInfo *t, const int UNUSED(mval[2]))
564 {
565  char str[UI_MAX_DRAW_STR];
566  size_t ofs = 0;
567  float final;
568  VertSlideParams *slp = t->custom.mode.data;
569  const bool flipped = slp->flipped;
570  const bool use_even = slp->use_even;
571  const bool is_clamp = !(t->flag & T_ALT_TRANSFORM);
572  const bool is_constrained = !(is_clamp == false || hasNumInput(&t->num));
573 
574  final = t->values[0] + t->values_modal_offset[0];
575 
576  applySnappingAsGroup(t, &final);
577  if (!validSnap(t)) {
578  transform_snap_increment(t, &final);
579  }
580 
581  /* only do this so out of range values are not displayed */
582  if (is_constrained) {
583  CLAMP(final, 0.0f, 1.0f);
584  }
585 
586  applyNumInput(&t->num, &final);
587 
588  t->values_final[0] = final;
589 
590  /* header string */
591  ofs += BLI_strncpy_rlen(str + ofs, TIP_("Vertex Slide: "), sizeof(str) - ofs);
592  if (hasNumInput(&t->num)) {
593  char c[NUM_STR_REP_LEN];
594  outputNumInput(&(t->num), c, &t->scene->unit);
595  ofs += BLI_strncpy_rlen(str + ofs, &c[0], sizeof(str) - ofs);
596  }
597  else {
598  ofs += BLI_snprintf_rlen(str + ofs, sizeof(str) - ofs, "%.4f ", final);
599  }
600  ofs += BLI_snprintf_rlen(
601  str + ofs, sizeof(str) - ofs, TIP_("(E)ven: %s, "), WM_bool_as_string(use_even));
602  if (use_even) {
603  ofs += BLI_snprintf_rlen(
604  str + ofs, sizeof(str) - ofs, TIP_("(F)lipped: %s, "), WM_bool_as_string(flipped));
605  }
606  ofs += BLI_snprintf_rlen(
607  str + ofs, sizeof(str) - ofs, TIP_("Alt or (C)lamp: %s"), WM_bool_as_string(is_clamp));
608  /* done with header string */
609 
610  /* do stuff here */
611  doVertSlide(t, final);
612 
613  recalcData(t);
614 
615  ED_area_status_text(t->area, str);
616 }
617 
618 void initVertSlide_ex(TransInfo *t, bool use_even, bool flipped, bool use_clamp)
619 {
620 
621  t->mode = TFM_VERT_SLIDE;
622  t->transform = applyVertSlide;
623  t->handleEvent = handleEventVertSlide;
624  t->tsnap.applySnap = vert_slide_snap_apply;
625  t->tsnap.distance = transform_snap_distance_len_squared_fn;
626 
627  {
628  VertSlideParams *slp = MEM_callocN(sizeof(*slp), __func__);
629  slp->use_even = use_even;
630  slp->flipped = flipped;
631  slp->perc = 0.0f;
632 
633  if (!use_clamp) {
634  t->flag |= T_ALT_TRANSFORM;
635  }
636 
637  t->custom.mode.data = slp;
638  t->custom.mode.use_free = true;
639  }
640 
641  bool ok = false;
644  if (sld) {
645  tc->custom.mode.data = sld;
646  tc->custom.mode.free_cb = freeVertSlideVerts;
647  ok = true;
648  }
649  }
650 
651  if (ok == false) {
652  t->state = TRANS_CANCEL;
653  return;
654  }
655 
658 
659  /* set custom point first if you want value to be initialized by init */
662 
663  t->idx_max = 0;
664  t->num.idx_max = 0;
665  t->snap[0] = 0.1f;
666  t->snap[1] = t->snap[0] * 0.1f;
667 
668  copy_v3_fl(t->num.val_inc, t->snap[0]);
669  t->num.unit_sys = t->scene->unit.system;
670  t->num.unit_type[0] = B_UNIT_NONE;
671 
672  t->flag |= T_NO_CONSTRAINT | T_NO_PROJECT;
673 }
674 
676 {
677  initVertSlide_ex(t, false, false, true);
678 }
679 
682 /* -------------------------------------------------------------------- */
687 {
688  if (t->spacetype == SPACE_VIEW3D) {
689  RegionView3D *rv3d = t->region->regiondata;
691  VertSlideData *sld = tc->custom.mode.data;
692  ED_view3d_ob_project_mat_get(rv3d, tc->obedit, sld->proj_mat);
693  }
694  }
695 
697 }
698 
typedef float(TangentPoint)[2]
BMEditMesh * BKE_editmesh_from_object(struct Object *ob)
Return the BMEditMesh for a given object.
Definition: editmesh.c:58
@ B_UNIT_NONE
Definition: BKE_unit.h:100
float line_point_factor_v3(const float p[3], const float l1[3], const float l2[3])
Definition: math_geom.c:3254
void unit_m4(float m[4][4])
Definition: rct.c:1090
void mul_mat3_m4_v3(const float M[4][4], float r[3])
Definition: math_matrix.c:790
bool invert_m4_m4(float R[4][4], const float A[4][4])
Definition: math_matrix.c:1287
void mul_m4_v3(const float M[4][4], float r[3])
Definition: math_matrix.c:729
void mul_v3_m4v3(float r[3], const float M[4][4], const float v[3])
Definition: math_matrix.c:739
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 float normalize_v3(float r[3])
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 project_plane_v3_v3v3(float out[3], const float p[3], const float v_plane[3])
Definition: math_vector.c:638
MINLINE float dot_v3v3(const float a[3], const float b[3]) ATTR_WARN_UNUSED_RESULT
void interp_v3_v3v3(float r[3], const float a[3], const float b[3], float t)
Definition: math_vector.c:29
MINLINE void add_v3_v3v3(float r[3], const float a[3], const float b[3])
MINLINE void sub_v2_v2v2(float r[2], const float a[2], const float b[2])
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])
size_t BLI_strncpy_rlen(char *__restrict dst, const char *__restrict src, size_t maxncpy) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL()
Definition: string.c:120
size_t BLI_snprintf_rlen(char *__restrict dst, size_t maxncpy, const char *__restrict format,...) ATTR_NONNULL(1
unsigned int uint
Definition: BLI_sys_types.h:67
#define UNPACK2(a)
#define ARRAY_SET_ITEMS(...)
#define UNUSED(x)
#define TIP_(msgid)
@ SCE_SNAP_MODE_EDGE
@ SCE_SNAP_MODE_FACE_RAYCAST
@ SPACE_VIEW3D
void outputNumInput(NumInput *n, char *str, struct UnitSettings *unit_settings)
Definition: numinput.c:87
#define NUM_STR_REP_LEN
Definition: ED_numinput.h:13
bool applyNumInput(NumInput *n, float *vec)
Definition: numinput.c:189
bool hasNumInput(const NumInput *n)
Definition: numinput.c:170
void ED_area_status_text(ScrArea *area, const char *str)
Definition: area.c:792
@ TFM_VERT_SLIDE
Definition: ED_transform.h:60
void ED_view3d_win_to_delta(const struct ARegion *region, const float xy_delta[2], float zfac, float r_out[3])
void ED_view3d_ob_project_mat_get(const struct RegionView3D *v3d, const struct Object *ob, float r_pmat[4][4])
void ED_view3d_project_float_v2_m4(const struct ARegion *region, const float co[3], float r_co[2], const float mat[4][4])
float ED_view3d_calc_zfac(const struct RegionView3D *rv3d, const float co[3])
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 immUnbindProgram(void)
void immBindBuiltinProgram(eGPUBuiltinShader shader_id)
void immUniform1i(const char *name, int x)
void immUniform1f(const char *name, float x)
GPUVertFormat * immVertexFormat(void)
void immVertex3fv(uint attr_id, const float data[3])
void immBegin(GPUPrimType, uint vertex_len)
void immEnd(void)
_GL_VOID GLfloat value _GL_VOID_RET _GL_VOID const GLuint GLboolean *residences _GL_BOOL_RET _GL_VOID GLsizei GLfloat GLfloat GLfloat GLfloat const GLubyte *bitmap _GL_VOID_RET _GL_VOID GLenum const void *lists _GL_VOID_RET _GL_VOID const GLdouble *equation _GL_VOID_RET _GL_VOID GLdouble GLdouble blue _GL_VOID_RET _GL_VOID GLfloat GLfloat blue _GL_VOID_RET _GL_VOID GLint GLint blue _GL_VOID_RET _GL_VOID GLshort GLshort blue _GL_VOID_RET _GL_VOID GLubyte GLubyte blue _GL_VOID_RET _GL_VOID GLuint GLuint blue _GL_VOID_RET _GL_VOID GLushort GLushort blue _GL_VOID_RET _GL_VOID GLbyte GLbyte GLbyte alpha _GL_VOID_RET _GL_VOID GLdouble GLdouble GLdouble alpha _GL_VOID_RET _GL_VOID GLfloat GLfloat GLfloat alpha _GL_VOID_RET _GL_VOID GLint GLint GLint alpha _GL_VOID_RET _GL_VOID GLshort GLshort GLshort alpha _GL_VOID_RET _GL_VOID GLubyte GLubyte GLubyte alpha _GL_VOID_RET _GL_VOID GLuint GLuint GLuint alpha _GL_VOID_RET _GL_VOID GLushort GLushort GLushort alpha _GL_VOID_RET _GL_VOID GLenum mode _GL_VOID_RET _GL_VOID GLint GLsizei GLsizei GLenum type _GL_VOID_RET _GL_VOID GLsizei GLenum GLenum const void *pixels _GL_VOID_RET _GL_VOID const void *pointer _GL_VOID_RET _GL_VOID GLdouble v _GL_VOID_RET _GL_VOID GLfloat v _GL_VOID_RET _GL_VOID GLint GLint i2 _GL_VOID_RET _GL_VOID GLint j _GL_VOID_RET _GL_VOID GLfloat param _GL_VOID_RET _GL_VOID GLint param _GL_VOID_RET _GL_VOID GLdouble GLdouble GLdouble GLdouble GLdouble zFar _GL_VOID_RET _GL_UINT GLdouble *equation _GL_VOID_RET _GL_VOID GLenum GLint *params _GL_VOID_RET _GL_VOID GLenum GLfloat *v _GL_VOID_RET _GL_VOID GLenum GLfloat *params _GL_VOID_RET _GL_VOID GLfloat *values _GL_VOID_RET _GL_VOID GLushort *values _GL_VOID_RET _GL_VOID GLenum GLfloat *params _GL_VOID_RET _GL_VOID GLenum GLdouble *params _GL_VOID_RET _GL_VOID GLenum GLint *params _GL_VOID_RET _GL_VOID GLsizei const void *pointer _GL_VOID_RET _GL_VOID GLsizei const void *pointer _GL_VOID_RET _GL_BOOL GLfloat param _GL_VOID_RET _GL_VOID GLint param _GL_VOID_RET _GL_VOID GLenum GLfloat param _GL_VOID_RET _GL_VOID GLenum GLint param _GL_VOID_RET _GL_VOID GLushort pattern _GL_VOID_RET _GL_VOID GLdouble GLdouble GLint GLint const GLdouble *points _GL_VOID_RET _GL_VOID GLdouble GLdouble GLint GLint GLdouble GLdouble GLint GLint const GLdouble *points _GL_VOID_RET _GL_VOID GLdouble GLdouble u2 _GL_VOID_RET _GL_VOID GLdouble GLdouble GLint GLdouble GLdouble v2 _GL_VOID_RET _GL_VOID GLenum GLfloat param _GL_VOID_RET _GL_VOID GLenum GLint param _GL_VOID_RET _GL_VOID GLenum mode _GL_VOID_RET _GL_VOID GLdouble GLdouble nz _GL_VOID_RET _GL_VOID GLfloat GLfloat nz _GL_VOID_RET _GL_VOID GLint GLint nz _GL_VOID_RET _GL_VOID GLshort GLshort nz _GL_VOID_RET _GL_VOID GLsizei const void *pointer _GL_VOID_RET _GL_VOID GLsizei const GLfloat *values _GL_VOID_RET _GL_VOID GLsizei const GLushort *values _GL_VOID_RET _GL_VOID GLint param _GL_VOID_RET _GL_VOID const GLuint const GLclampf *priorities _GL_VOID_RET _GL_VOID GLdouble y _GL_VOID_RET _GL_VOID GLfloat y _GL_VOID_RET _GL_VOID GLint y _GL_VOID_RET _GL_VOID GLshort y _GL_VOID_RET _GL_VOID GLdouble GLdouble z _GL_VOID_RET _GL_VOID GLfloat GLfloat z _GL_VOID_RET _GL_VOID GLint GLint z _GL_VOID_RET _GL_VOID GLshort GLshort z _GL_VOID_RET _GL_VOID GLdouble GLdouble GLdouble w _GL_VOID_RET _GL_VOID GLfloat GLfloat GLfloat w _GL_VOID_RET _GL_VOID GLint GLint GLint w _GL_VOID_RET _GL_VOID GLshort GLshort GLshort w _GL_VOID_RET _GL_VOID GLdouble GLdouble GLdouble y2 _GL_VOID_RET _GL_VOID GLfloat GLfloat GLfloat y2 _GL_VOID_RET _GL_VOID GLint GLint GLint y2 _GL_VOID_RET _GL_VOID GLshort GLshort GLshort y2 _GL_VOID_RET _GL_VOID GLdouble GLdouble GLdouble z _GL_VOID_RET _GL_VOID GLdouble GLdouble z _GL_VOID_RET _GL_VOID GLuint *buffer _GL_VOID_RET _GL_VOID GLdouble t _GL_VOID_RET _GL_VOID GLfloat t _GL_VOID_RET _GL_VOID GLint t _GL_VOID_RET _GL_VOID GLshort t _GL_VOID_RET _GL_VOID GLdouble t
void GPU_matrix_pop(void)
Definition: gpu_matrix.cc:126
#define GPU_matrix_mul(x)
Definition: GPU_matrix.h:224
void GPU_matrix_push(void)
Definition: gpu_matrix.cc:119
@ GPU_PRIM_LINES
Definition: GPU_primitive.h:20
@ GPU_PRIM_POINTS
Definition: GPU_primitive.h:19
@ GPU_SHADER_3D_LINE_DASHED_UNIFORM_COLOR
Definition: GPU_shader.h:350
@ GPU_SHADER_3D_UNIFORM_COLOR
Definition: GPU_shader.h:230
@ GPU_BLEND_ALPHA
Definition: GPU_state.h:62
void GPU_blend(eGPUBlend blend)
Definition: gpu_state.cc:39
void GPU_line_width(float width)
Definition: gpu_state.cc:158
void GPU_point_size(float size)
Definition: gpu_state.cc:164
@ GPU_DEPTH_LESS_EQUAL
Definition: GPU_state.h:86
@ GPU_DEPTH_NONE
Definition: GPU_state.h:83
void GPU_depth_test(eGPUDepthTest test)
Definition: gpu_state.cc:65
void GPU_viewport_size_get_f(float coords[4])
Definition: gpu_state.cc:259
@ GPU_FETCH_FLOAT
uint GPU_vertformat_attr_add(GPUVertFormat *, const char *name, GPUVertCompType, uint comp_len, GPUVertFetchMode)
@ GPU_COMP_F32
Read Guarded memory(de)allocation.
Group Output data from inside of a node group A color picker Mix two input colors RGB to Convert a color s luminance to a grayscale value Generate a normal vector and a dot product Bright Control the brightness and contrast of the input color Vector Map an input vectors to used to fine tune the interpolation of the input Camera Retrieve information about the camera and how it relates to the current shading point s position CLAMP
#define UI_MAX_DRAW_STR
Definition: UI_interface.h:91
@ TH_FACEDOT_SIZE
Definition: UI_resources.h:96
@ TH_EDGE_SELECT
Definition: UI_resources.h:85
@ TH_OUTLINE_WIDTH
Definition: UI_resources.h:82
float UI_GetThemeValuef(int colorid)
Definition: resources.c:1141
@ KM_PRESS
Definition: WM_types.h:267
@ BM_ELEM_HIDDEN
Definition: bmesh_class.h:472
@ BM_ELEM_SELECT
Definition: bmesh_class.h:471
@ BM_ELEM_TAG
Definition: bmesh_class.h:484
#define BM_elem_flag_disable(ele, hflag)
Definition: bmesh_inline.h:15
#define BM_elem_flag_test(ele, hflag)
Definition: bmesh_inline.h:12
#define BM_elem_flag_enable(ele, hflag)
Definition: bmesh_inline.h:14
#define BM_ITER_ELEM(ele, iter, data, itype)
#define BM_ITER_MESH(ele, iter, bm, itype)
@ BM_VERTS_OF_MESH
@ BM_EDGES_OF_VERT
ATTR_WARN_UNUSED_RESULT BMesh * bm
BLI_INLINE BMVert * BM_edge_other_vert(BMEdge *e, const BMVert *v) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL()
ATTR_WARN_UNUSED_RESULT const BMVert const BMEdge * e
ATTR_WARN_UNUSED_RESULT const BMVert * v
#define str(s)
void(* MEM_freeN)(void *vmemh)
Definition: mallocn.c:27
void *(* MEM_callocN)(size_t len, const char *str)
Definition: mallocn.c:31
void *(* MEM_mallocN)(size_t len, const char *str)
Definition: mallocn.c:33
static unsigned c
Definition: RandGen.cpp:83
static unsigned a[3]
Definition: RandGen.cpp:78
static const pxr::TfToken b("b", pxr::TfToken::Immortal)
#define TRANS_DATA_CONTAINER_FIRST_OK(t)
void applyMouseInput(struct TransInfo *t, struct MouseInput *mi, const int mval[2], float output[3])
void setCustomPoints(TransInfo *t, MouseInput *mi, const int start[2], const int end[2])
void initMouseInputMode(TransInfo *t, MouseInput *mi, MouseInputMode mode)
#define FOREACH_TRANS_DATA_CONTAINER(t, th)
void * regiondata
struct BMesh * bm
Definition: BKE_editmesh.h:40
float co[3]
Definition: bmesh_class.h:87
struct BMEdge * e
Definition: bmesh_class.h:97
TransDataVertSlideVert * sv
short val
Definition: WM_types.h:680
int mval[2]
Definition: WM_types.h:684
short type
Definition: WM_types.h:678
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])
void recalcData(TransInfo *t)
conversion and adaptation of different datablocks to a common struct.
transform modes used by different operators.
static void calcVertSlideCustomPoints(struct TransInfo *t)
static void applyVertSlide(TransInfo *t, const int UNUSED(mval[2]))
void initVertSlide_ex(TransInfo *t, bool use_even, bool flipped, bool use_clamp)
static void vert_slide_snap_apply(TransInfo *t, float *value)
void initVertSlide(TransInfo *t)
static VertSlideData * createVertSlideVerts(TransInfo *t, const TransDataContainer *tc)
static void doVertSlide(TransInfo *t, float perc)
static void freeVertSlideVerts(TransInfo *UNUSED(t), TransDataContainer *UNUSED(tc), TransCustomData *custom_data)
struct VertSlideData VertSlideData
static void vert_slide_update_input(TransInfo *t)
struct VertSlideParams VertSlideParams
void transform_mode_vert_slide_reproject_input(TransInfo *t)
static eRedrawFlag handleEventVertSlide(struct TransInfo *t, const struct wmEvent *event)
struct TransDataVertSlideVert TransDataVertSlideVert
static void calcVertSlideMouseActiveVert(struct TransInfo *t, const int mval[2])
void drawVertSlide(TransInfo *t)
static void calcVertSlideMouseActiveEdges(struct TransInfo *t, const int mval[2])
float transform_snap_distance_len_squared_fn(TransInfo *UNUSED(t), const float p1[3], const float p2[3])
bool validSnap(const TransInfo *t)
bool transform_snap_increment(const TransInfo *t, float *r_val)
void applySnappingAsGroup(TransInfo *t, float *vec)
void getSnapPoint(const TransInfo *t, float vec[3])
@ EVT_EKEY
@ EVT_MODAL_MAP
@ EVT_FKEY
@ EVT_CKEY
@ MOUSEMOVE
const char * WM_bool_as_string(bool test)
Definition: wm_keymap.c:2052