Blender  V2.93
transform_mode_vert_slide.c
Go to the documentation of this file.
1 /*
2  * This program is free software; you can redistribute it and/or
3  * modify it under the terms of the GNU General Public License
4  * as published by the Free Software Foundation; either version 2
5  * of the License, or (at your option) any later version.
6  *
7  * This program is distributed in the hope that it will be useful,
8  * but WITHOUT ANY WARRANTY; without even the implied warranty of
9  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10  * GNU General Public License for more details.
11  *
12  * You should have received a copy of the GNU General Public License
13  * along with this program; if not, write to the Free Software Foundation,
14  * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
15  *
16  * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
17  * All rights reserved.
18  */
19 
24 #include <stdlib.h>
25 
26 #include "MEM_guardedalloc.h"
27 
28 #include "BLI_math.h"
29 #include "BLI_string.h"
30 
31 #include "BKE_context.h"
32 #include "BKE_editmesh.h"
33 #include "BKE_unit.h"
34 
35 #include "GPU_immediate.h"
36 #include "GPU_matrix.h"
37 #include "GPU_state.h"
38 
39 #include "ED_screen.h"
40 
41 #include "WM_api.h"
42 #include "WM_types.h"
43 
44 #include "UI_interface.h"
45 #include "UI_resources.h"
46 
47 #include "BLT_translation.h"
48 
49 #include "transform.h"
50 #include "transform_constraints.h"
51 #include "transform_convert.h"
52 #include "transform_mode.h"
53 #include "transform_snap.h"
54 
55 /* -------------------------------------------------------------------- */
59 typedef struct TransDataVertSlideVert {
61  struct BMVert *v;
63  float co_orig_3d[3];
64  /* end generic */
65 
70 
71 typedef struct VertSlideData {
73  int totsv;
75 
76  /* result of ED_view3d_ob_project_mat_get */
77  float proj_mat[4][4];
79 
80 typedef struct VertSlideParams {
81  float perc;
82 
83  bool use_even;
84  bool flipped;
86 
88 {
89  VertSlideParams *slp = t->custom.mode.data;
90  VertSlideData *sld = TRANS_DATA_CONTAINER_FIRST_OK(t)->custom.mode.data;
91  TransDataVertSlideVert *sv = &sld->sv[sld->curr_sv_index];
92 
93  const float *co_orig_3d = sv->co_orig_3d;
94  const float *co_curr_3d = sv->co_link_orig_3d[sv->co_link_curr];
95 
96  float co_curr_2d[2], co_orig_2d[2];
97 
98  int mval_ofs[2], mval_start[2], mval_end[2];
99 
100  ED_view3d_project_float_v2_m4(t->region, co_orig_3d, co_orig_2d, sld->proj_mat);
101  ED_view3d_project_float_v2_m4(t->region, co_curr_3d, co_curr_2d, sld->proj_mat);
102 
103  ARRAY_SET_ITEMS(mval_ofs, t->mouse.imval[0] - co_orig_2d[0], t->mouse.imval[1] - co_orig_2d[1]);
104  ARRAY_SET_ITEMS(mval_start, co_orig_2d[0] + mval_ofs[0], co_orig_2d[1] + mval_ofs[1]);
105  ARRAY_SET_ITEMS(mval_end, co_curr_2d[0] + mval_ofs[0], co_curr_2d[1] + mval_ofs[1]);
106 
107  if (slp->flipped && slp->use_even) {
108  setCustomPoints(t, &t->mouse, mval_start, mval_end);
109  }
110  else {
111  setCustomPoints(t, &t->mouse, mval_end, mval_start);
112  }
113 
114  /* setCustomPoints isn't normally changing as the mouse moves,
115  * in this case apply mouse input immediately so we don't refresh
116  * with the value from the previous points */
117  applyMouseInput(t, &t->mouse, t->mval, t->values);
118 }
119 
123 static void calcVertSlideMouseActiveVert(struct TransInfo *t, const int mval[2])
124 {
125  /* Active object may have no selected vertices. */
126  VertSlideData *sld = TRANS_DATA_CONTAINER_FIRST_OK(t)->custom.mode.data;
127  const float mval_fl[2] = {UNPACK2(mval)};
129 
130  /* set the vertex to use as a reference for the mouse direction 'curr_sv_index' */
131  float dist_sq = 0.0f;
132  float dist_min_sq = FLT_MAX;
133  int i;
134 
135  for (i = 0, sv = sld->sv; i < sld->totsv; i++, sv++) {
136  float co_2d[2];
137 
138  ED_view3d_project_float_v2_m4(t->region, sv->co_orig_3d, co_2d, sld->proj_mat);
139 
140  dist_sq = len_squared_v2v2(mval_fl, co_2d);
141  if (dist_sq < dist_min_sq) {
142  dist_min_sq = dist_sq;
143  sld->curr_sv_index = i;
144  }
145  }
146 }
147 
151 static void calcVertSlideMouseActiveEdges(struct TransInfo *t, const int mval[2])
152 {
153  VertSlideData *sld = TRANS_DATA_CONTAINER_FIRST_OK(t)->custom.mode.data;
154  const float imval_fl[2] = {UNPACK2(t->mouse.imval)};
155  const float mval_fl[2] = {UNPACK2(mval)};
156 
157  float dir[3];
159  int i;
160 
161  /* note: we could save a matrix-multiply for each vertex
162  * by finding the closest edge in local-space.
163  * However this skews the outcome with non-uniform-scale. */
164 
165  /* first get the direction of the original mouse position */
166  sub_v2_v2v2(dir, imval_fl, mval_fl);
167  ED_view3d_win_to_delta(t->region, dir, dir, t->zfac);
168  normalize_v3(dir);
169 
170  for (i = 0, sv = sld->sv; i < sld->totsv; i++, sv++) {
171  if (sv->co_link_tot > 1) {
172  float dir_dot_best = -FLT_MAX;
173  int co_link_curr_best = -1;
174  int j;
175 
176  for (j = 0; j < sv->co_link_tot; j++) {
177  float tdir[3];
178  float dir_dot;
179 
180  sub_v3_v3v3(tdir, sv->co_orig_3d, sv->co_link_orig_3d[j]);
181  mul_mat3_m4_v3(TRANS_DATA_CONTAINER_FIRST_OK(t)->obedit->obmat, tdir);
182  project_plane_v3_v3v3(tdir, tdir, t->viewinv[2]);
183 
184  normalize_v3(tdir);
185  dir_dot = dot_v3v3(dir, tdir);
186  if (dir_dot > dir_dot_best) {
187  dir_dot_best = dir_dot;
188  co_link_curr_best = j;
189  }
190  }
191 
192  if (co_link_curr_best != -1) {
193  sv->co_link_curr = co_link_curr_best;
194  }
195  }
196  }
197 }
198 
200 {
202  BMesh *bm = em->bm;
203  BMIter iter;
204  BMIter eiter;
205  BMEdge *e;
206  BMVert *v;
207  TransDataVertSlideVert *sv_array;
208  VertSlideData *sld = MEM_callocN(sizeof(*sld), "sld");
209  int j;
210 
211  sld->curr_sv_index = 0;
212 
213  j = 0;
214  BM_ITER_MESH (v, &iter, bm, BM_VERTS_OF_MESH) {
215  bool ok = false;
216  if (BM_elem_flag_test(v, BM_ELEM_SELECT) && v->e) {
217  BM_ITER_ELEM (e, &eiter, v, BM_EDGES_OF_VERT) {
219  ok = true;
220  break;
221  }
222  }
223  }
224 
225  if (ok) {
227  j += 1;
228  }
229  else {
231  }
232  }
233 
234  if (!j) {
235  MEM_freeN(sld);
236  return NULL;
237  }
238 
239  sv_array = MEM_callocN(sizeof(TransDataVertSlideVert) * j, "sv_array");
240 
241  j = 0;
242  BM_ITER_MESH (v, &iter, bm, BM_VERTS_OF_MESH) {
244  int k;
245  sv_array[j].v = v;
246  copy_v3_v3(sv_array[j].co_orig_3d, v->co);
247 
248  k = 0;
249  BM_ITER_ELEM (e, &eiter, v, BM_EDGES_OF_VERT) {
251  k++;
252  }
253  }
254 
255  sv_array[j].co_link_orig_3d = MEM_mallocN(sizeof(*sv_array[j].co_link_orig_3d) * k,
256  __func__);
257  sv_array[j].co_link_tot = k;
258 
259  k = 0;
260  BM_ITER_ELEM (e, &eiter, v, BM_EDGES_OF_VERT) {
262  BMVert *v_other = BM_edge_other_vert(e, v);
263  copy_v3_v3(sv_array[j].co_link_orig_3d[k], v_other->co);
264  k++;
265  }
266  }
267  j++;
268  }
269  }
270 
271  sld->sv = sv_array;
272  sld->totsv = j;
273 
274  /* most likely will be set below */
275  unit_m4(sld->proj_mat);
276 
277  if (t->spacetype == SPACE_VIEW3D) {
278  /* view vars */
279  RegionView3D *rv3d = NULL;
280  ARegion *region = t->region;
281 
282  rv3d = region ? region->regiondata : NULL;
283  if (rv3d) {
285  }
286  }
287 
288  return sld;
289 }
290 
293  TransCustomData *custom_data)
294 {
295  VertSlideData *sld = custom_data->data;
296 
297  if (!sld) {
298  return;
299  }
300 
301  if (sld->totsv > 0) {
302  TransDataVertSlideVert *sv = sld->sv;
303  int i = 0;
304  for (i = 0; i < sld->totsv; i++, sv++) {
306  }
307  }
308 
309  MEM_freeN(sld->sv);
310  MEM_freeN(sld);
311 
312  custom_data->data = NULL;
313 }
314 
315 static eRedrawFlag handleEventVertSlide(struct TransInfo *t, const struct wmEvent *event)
316 {
317  if (t->mode == TFM_VERT_SLIDE) {
318  VertSlideParams *slp = t->custom.mode.data;
319 
320  if (slp) {
321  switch (event->type) {
322  case EVT_EKEY:
323  if (event->val == KM_PRESS) {
324  slp->use_even = !slp->use_even;
325  if (slp->flipped) {
327  }
328  return TREDRAW_HARD;
329  }
330  break;
331  case EVT_FKEY:
332  if (event->val == KM_PRESS) {
333  slp->flipped = !slp->flipped;
335  return TREDRAW_HARD;
336  }
337  break;
338  case EVT_CKEY:
339  /* use like a modifier key */
340  if (event->val == KM_PRESS) {
341  t->flag ^= T_ALT_TRANSFORM;
343  return TREDRAW_HARD;
344  }
345  break;
346 #if 0
347  case EVT_MODAL_MAP:
348  switch (event->val) {
350  sld->curr_sv_index = ((sld->curr_sv_index - 1) + sld->totsv) % sld->totsv;
351  break;
353  sld->curr_sv_index = (sld->curr_sv_index + 1) % sld->totsv;
354  break;
355  }
356  break;
357 #endif
358  case MOUSEMOVE: {
359  /* don't recalculate the best edge */
360  const bool is_clamp = !(t->flag & T_ALT_TRANSFORM);
361  if (is_clamp) {
363  }
365  break;
366  }
367  default:
368  break;
369  }
370  }
371  }
372  return TREDRAW_NOTHING;
373 }
374 
376 {
377  if ((t->mode == TFM_VERT_SLIDE) && TRANS_DATA_CONTAINER_FIRST_OK(t)->custom.mode.data) {
378  const VertSlideParams *slp = t->custom.mode.data;
379  VertSlideData *sld = TRANS_DATA_CONTAINER_FIRST_OK(t)->custom.mode.data;
380  const bool is_clamp = !(t->flag & T_ALT_TRANSFORM);
381 
382  /* Non-Prop mode */
383  {
384  TransDataVertSlideVert *curr_sv = &sld->sv[sld->curr_sv_index];
386  const float ctrl_size = UI_GetThemeValuef(TH_FACEDOT_SIZE) + 1.5f;
387  const float line_size = UI_GetThemeValuef(TH_OUTLINE_WIDTH) + 0.5f;
388  const int alpha_shade = -160;
389  int i;
390 
392 
394 
395  GPU_matrix_push();
397 
398  GPU_line_width(line_size);
399 
400  const uint shdr_pos = GPU_vertformat_attr_add(
402 
405 
406  immBegin(GPU_PRIM_LINES, sld->totsv * 2);
407  if (is_clamp) {
408  sv = sld->sv;
409  for (i = 0; i < sld->totsv; i++, sv++) {
410  immVertex3fv(shdr_pos, sv->co_orig_3d);
411  immVertex3fv(shdr_pos, sv->co_link_orig_3d[sv->co_link_curr]);
412  }
413  }
414  else {
415  sv = sld->sv;
416  for (i = 0; i < sld->totsv; i++, sv++) {
417  float a[3], b[3];
419  mul_v3_fl(a, 100.0f);
420  negate_v3_v3(b, a);
421  add_v3_v3(a, sv->co_orig_3d);
422  add_v3_v3(b, sv->co_orig_3d);
423 
424  immVertex3fv(shdr_pos, a);
425  immVertex3fv(shdr_pos, b);
426  }
427  }
428  immEnd();
429 
430  GPU_point_size(ctrl_size);
431 
433  immVertex3fv(shdr_pos,
434  (slp->flipped && slp->use_even) ?
435  curr_sv->co_link_orig_3d[curr_sv->co_link_curr] :
436  curr_sv->co_orig_3d);
437  immEnd();
438 
440 
441  /* direction from active vertex! */
442  if ((t->mval[0] != t->mouse.imval[0]) || (t->mval[1] != t->mouse.imval[1])) {
443  float zfac;
444  float mval_ofs[2];
445  float co_orig_3d[3];
446  float co_dest_3d[3];
447 
448  mval_ofs[0] = t->mval[0] - t->mouse.imval[0];
449  mval_ofs[1] = t->mval[1] - t->mouse.imval[1];
450 
451  mul_v3_m4v3(
452  co_orig_3d, TRANS_DATA_CONTAINER_FIRST_OK(t)->obedit->obmat, curr_sv->co_orig_3d);
453  zfac = ED_view3d_calc_zfac(t->region->regiondata, co_orig_3d, NULL);
454 
455  ED_view3d_win_to_delta(t->region, mval_ofs, co_dest_3d, zfac);
456 
458  TRANS_DATA_CONTAINER_FIRST_OK(t)->obedit->obmat);
459  mul_mat3_m4_v3(TRANS_DATA_CONTAINER_FIRST_OK(t)->obedit->imat, co_dest_3d);
460 
461  add_v3_v3(co_dest_3d, curr_sv->co_orig_3d);
462 
463  GPU_line_width(1.0f);
464 
466 
467  float viewport_size[4];
468  GPU_viewport_size_get_f(viewport_size);
469  immUniform2f("viewport_size", viewport_size[2], viewport_size[3]);
470 
471  immUniform1i("colors_len", 0); /* "simple" mode */
472  immUniformColor4f(1.0f, 1.0f, 1.0f, 1.0f);
473  immUniform1f("dash_width", 6.0f);
474  immUniform1f("dash_factor", 0.5f);
475 
477  immVertex3fv(shdr_pos, curr_sv->co_orig_3d);
478  immVertex3fv(shdr_pos, co_dest_3d);
479  immEnd();
480 
482  }
483 
484  GPU_matrix_pop();
485 
487  }
488  }
489 }
490 
491 static void doVertSlide(TransInfo *t, float perc)
492 {
493  VertSlideParams *slp = t->custom.mode.data;
494 
495  slp->perc = perc;
496 
498  VertSlideData *sld = tc->custom.mode.data;
499  if (sld == NULL) {
500  continue;
501  }
502 
503  TransDataVertSlideVert *svlist = sld->sv, *sv;
504  int i;
505 
506  sv = svlist;
507 
508  if (slp->use_even == false) {
509  for (i = 0; i < sld->totsv; i++, sv++) {
510  interp_v3_v3v3(sv->v->co, sv->co_orig_3d, sv->co_link_orig_3d[sv->co_link_curr], perc);
511  }
512  }
513  else {
514  TransDataVertSlideVert *sv_curr = &sld->sv[sld->curr_sv_index];
515  const float edge_len_curr = len_v3v3(sv_curr->co_orig_3d,
516  sv_curr->co_link_orig_3d[sv_curr->co_link_curr]);
517  const float tperc = perc * edge_len_curr;
518 
519  for (i = 0; i < sld->totsv; i++, sv++) {
520  float edge_len;
521  float dir[3];
522 
523  sub_v3_v3v3(dir, sv->co_link_orig_3d[sv->co_link_curr], sv->co_orig_3d);
524  edge_len = normalize_v3(dir);
525 
526  if (edge_len > FLT_EPSILON) {
527  if (slp->flipped) {
528  madd_v3_v3v3fl(sv->v->co, sv->co_link_orig_3d[sv->co_link_curr], dir, -tperc);
529  }
530  else {
531  madd_v3_v3v3fl(sv->v->co, sv->co_orig_3d, dir, tperc);
532  }
533  }
534  else {
535  copy_v3_v3(sv->v->co, sv->co_orig_3d);
536  }
537  }
538  }
539  }
540 }
541 
542 static void vert_slide_snap_apply(TransInfo *t, float *value)
543 {
545  VertSlideData *sld = tc->custom.mode.data;
546  TransDataVertSlideVert *sv = &sld->sv[sld->curr_sv_index];
547 
548  float snap_point[3], co_orig_3d[3], co_curr_3d[3], dvec[3];
549  copy_v3_v3(co_orig_3d, sv->co_orig_3d);
550  copy_v3_v3(co_curr_3d, sv->co_link_orig_3d[sv->co_link_curr]);
551  if (tc->use_local_mat) {
552  mul_m4_v3(tc->mat, co_orig_3d);
553  mul_m4_v3(tc->mat, co_curr_3d);
554  }
555 
556  getSnapPoint(t, dvec);
557  sub_v3_v3(dvec, t->tsnap.snapTarget);
558  if (t->tsnap.snapElem & (SCE_SNAP_MODE_EDGE | SCE_SNAP_MODE_FACE)) {
559  float co_dir[3];
560  sub_v3_v3v3(co_dir, co_curr_3d, co_orig_3d);
561  normalize_v3(co_dir);
562  if (t->tsnap.snapElem & SCE_SNAP_MODE_EDGE) {
564  }
565  else {
567  }
568  }
569 
570  add_v3_v3v3(snap_point, co_orig_3d, dvec);
571  *value = line_point_factor_v3(snap_point, co_orig_3d, co_curr_3d);
572 }
573 
574 static void applyVertSlide(TransInfo *t, const int UNUSED(mval[2]))
575 {
576  char str[UI_MAX_DRAW_STR];
577  size_t ofs = 0;
578  float final;
579  VertSlideParams *slp = t->custom.mode.data;
580  const bool flipped = slp->flipped;
581  const bool use_even = slp->use_even;
582  const bool is_clamp = !(t->flag & T_ALT_TRANSFORM);
583  const bool is_constrained = !(is_clamp == false || hasNumInput(&t->num));
584 
585  final = t->values[0];
586 
587  applySnapping(t, &final);
588  if (!validSnap(t)) {
589  transform_snap_increment(t, &final);
590  }
591 
592  /* only do this so out of range values are not displayed */
593  if (is_constrained) {
594  CLAMP(final, 0.0f, 1.0f);
595  }
596 
597  applyNumInput(&t->num, &final);
598 
599  t->values_final[0] = final;
600 
601  /* header string */
602  ofs += BLI_strncpy_rlen(str + ofs, TIP_("Vertex Slide: "), sizeof(str) - ofs);
603  if (hasNumInput(&t->num)) {
604  char c[NUM_STR_REP_LEN];
605  outputNumInput(&(t->num), c, &t->scene->unit);
606  ofs += BLI_strncpy_rlen(str + ofs, &c[0], sizeof(str) - ofs);
607  }
608  else {
609  ofs += BLI_snprintf(str + ofs, sizeof(str) - ofs, "%.4f ", final);
610  }
611  ofs += BLI_snprintf(
612  str + ofs, sizeof(str) - ofs, TIP_("(E)ven: %s, "), WM_bool_as_string(use_even));
613  if (use_even) {
614  ofs += BLI_snprintf(
615  str + ofs, sizeof(str) - ofs, TIP_("(F)lipped: %s, "), WM_bool_as_string(flipped));
616  }
617  ofs += BLI_snprintf(
618  str + ofs, sizeof(str) - ofs, TIP_("Alt or (C)lamp: %s"), WM_bool_as_string(is_clamp));
619  /* done with header string */
620 
621  /* do stuff here */
622  doVertSlide(t, final);
623 
624  recalcData(t);
625 
626  ED_area_status_text(t->area, str);
627 }
628 
629 void initVertSlide_ex(TransInfo *t, bool use_even, bool flipped, bool use_clamp)
630 {
631 
632  t->mode = TFM_VERT_SLIDE;
633  t->transform = applyVertSlide;
634  t->handleEvent = handleEventVertSlide;
635  t->tsnap.applySnap = vert_slide_snap_apply;
636  t->tsnap.distance = transform_snap_distance_len_squared_fn;
637 
638  {
639  VertSlideParams *slp = MEM_callocN(sizeof(*slp), __func__);
640  slp->use_even = use_even;
641  slp->flipped = flipped;
642  slp->perc = 0.0f;
643 
644  if (!use_clamp) {
645  t->flag |= T_ALT_TRANSFORM;
646  }
647 
648  t->custom.mode.data = slp;
649  t->custom.mode.use_free = true;
650  }
651 
652  bool ok = false;
655  if (sld) {
656  tc->custom.mode.data = sld;
657  tc->custom.mode.free_cb = freeVertSlideVerts;
658  ok = true;
659  }
660  }
661 
662  if (ok == false) {
663  t->state = TRANS_CANCEL;
664  return;
665  }
666 
669 
670  /* set custom point first if you want value to be initialized by init */
673 
674  t->idx_max = 0;
675  t->num.idx_max = 0;
676  t->snap[0] = 0.1f;
677  t->snap[1] = t->snap[0] * 0.1f;
678 
679  copy_v3_fl(t->num.val_inc, t->snap[0]);
680  t->num.unit_sys = t->scene->unit.system;
681  t->num.unit_type[0] = B_UNIT_NONE;
682 
683  t->flag |= T_NO_CONSTRAINT | T_NO_PROJECT;
684 }
685 
687 {
688  initVertSlide_ex(t, false, false, true);
689 }
typedef float(TangentPoint)[2]
BMEditMesh * BKE_editmesh_from_object(struct Object *ob)
Return the BMEditMesh for a given object.
Definition: editmesh.c:85
@ B_UNIT_NONE
Definition: BKE_unit.h:78
float line_point_factor_v3(const float p[3], const float l1[3], const float l2[3])
Definition: math_geom.c:3449
void unit_m4(float m[4][4])
Definition: rct.c:1140
void mul_mat3_m4_v3(const float M[4][4], float r[3])
Definition: math_matrix.c:794
bool invert_m4_m4(float R[4][4], const float A[4][4])
Definition: math_matrix.c:1278
void mul_m4_v3(const float M[4][4], float r[3])
Definition: math_matrix.c:732
void mul_v3_m4v3(float r[3], const float M[4][4], const float v[3])
Definition: math_matrix.c:742
void interp_v3_v3v3(float r[3], const float a[3], const float b[3], const float t)
Definition: math_vector.c:49
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:740
MINLINE float dot_v3v3(const float a[3], const float b[3]) ATTR_WARN_UNUSED_RESULT
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, const size_t maxncpy) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL()
Definition: string.c:187
size_t BLI_snprintf(char *__restrict dst, size_t maxncpy, const char *__restrict format,...) ATTR_NONNULL(1
unsigned int uint
Definition: BLI_sys_types.h:83
#define UNPACK2(a)
#define ARRAY_SET_ITEMS(...)
#define UNUSED(x)
#define TIP_(msgid)
#define SCE_SNAP_MODE_FACE
#define SCE_SNAP_MODE_EDGE
@ SPACE_VIEW3D
void outputNumInput(NumInput *n, char *str, struct UnitSettings *unit_settings)
Definition: numinput.c:102
#define NUM_STR_REP_LEN
Definition: ED_numinput.h:27
bool applyNumInput(NumInput *n, float *vec)
Definition: numinput.c:207
bool hasNumInput(const NumInput *n)
Definition: numinput.c:185
void ED_area_status_text(ScrArea *area, const char *str)
Definition: area.c:815
@ TFM_VERT_SLIDE
Definition: ED_transform.h:75
void ED_view3d_ob_project_mat_get(const struct RegionView3D *v3d, struct Object *ob, float r_pmat[4][4])
void ED_view3d_win_to_delta(const struct ARegion *region, const float mval[2], float out[3], const float zfac)
void ED_view3d_project_float_v2_m4(const struct ARegion *region, const float co[3], float r_co[2], float mat[4][4])
float ED_view3d_calc_zfac(const struct RegionView3D *rv3d, const float co[3], bool *r_flip)
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:142
#define GPU_matrix_mul(x)
Definition: GPU_matrix.h:223
void GPU_matrix_push(void)
Definition: gpu_matrix.cc:135
@ GPU_PRIM_LINES
Definition: GPU_primitive.h:36
@ GPU_PRIM_POINTS
Definition: GPU_primitive.h:35
@ GPU_SHADER_3D_LINE_DASHED_UNIFORM_COLOR
Definition: GPU_shader.h:366
@ GPU_SHADER_3D_UNIFORM_COLOR
Definition: GPU_shader.h:200
@ GPU_BLEND_ALPHA
Definition: GPU_state.h:57
void GPU_blend(eGPUBlend blend)
Definition: gpu_state.cc:55
void GPU_line_width(float width)
Definition: gpu_state.cc:173
void GPU_point_size(float size)
Definition: gpu_state.cc:179
@ GPU_DEPTH_LESS_EQUAL
Definition: GPU_state.h:81
@ GPU_DEPTH_NONE
Definition: GPU_state.h:78
void GPU_depth_test(eGPUDepthTest test)
Definition: gpu_state.cc:75
void GPU_viewport_size_get_f(float coords[4])
Definition: gpu_state.cc:279
@ 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 RGB to Bright Vector Camera CLAMP
#define UI_MAX_DRAW_STR
Definition: UI_interface.h:90
@ TH_FACEDOT_SIZE
Definition: UI_resources.h:112
@ TH_EDGE_SELECT
Definition: UI_resources.h:101
@ TH_OUTLINE_WIDTH
Definition: UI_resources.h:98
float UI_GetThemeValuef(int colorid)
Definition: resources.c:1164
#define KM_PRESS
Definition: WM_types.h:242
@ 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:29
#define BM_elem_flag_test(ele, hflag)
Definition: bmesh_inline.h:26
#define BM_elem_flag_enable(ele, hflag)
Definition: bmesh_inline.h:28
#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:41
void *(* MEM_callocN)(size_t len, const char *str)
Definition: mallocn.c:45
void *(* MEM_mallocN)(size_t len, const char *str)
Definition: mallocn.c:47
static unsigned c
Definition: RandGen.cpp:97
static unsigned a[3]
Definition: RandGen.cpp:92
void * regiondata
struct BMesh * bm
Definition: BKE_editmesh.h:52
float co[3]
Definition: bmesh_class.h:99
struct BMEdge * e
Definition: bmesh_class.h:109
TransCustomData mode
Definition: transform.h:426
TransCustomDataContainer custom
Definition: transform.h:501
struct Object * obedit
Definition: transform.h:461
float mat[4][4]
Definition: transform.h:463
TransDataVertSlideVert * sv
short val
Definition: WM_types.h:579
int mval[2]
Definition: WM_types.h:583
short type
Definition: WM_types.h:577
@ INPUT_CUSTOM_RATIO
Definition: transform.h:739
void recalcData(TransInfo *t)
#define TRANS_DATA_CONTAINER_FIRST_OK(t)
Definition: transform.h:808
eRedrawFlag
Definition: transform.h:197
@ TREDRAW_NOTHING
Definition: transform.h:198
@ TREDRAW_HARD
Definition: transform.h:199
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])
@ T_ALT_TRANSFORM
Definition: transform.h:140
@ T_NO_PROJECT
Definition: transform.h:135
@ T_NO_CONSTRAINT
Definition: transform.h:106
@ TRANS_CANCEL
Definition: transform.h:193
@ TFM_MODAL_EDGESLIDE_UP
Definition: transform.h:278
@ TFM_MODAL_EDGESLIDE_DOWN
Definition: transform.h:279
void initMouseInputMode(TransInfo *t, MouseInput *mi, MouseInputMode mode)
#define FOREACH_TRANS_DATA_CONTAINER(t, th)
Definition: transform.h:813
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])
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
struct VertSlideParams VertSlideParams
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])
void applySnapping(TransInfo *t, float *vec)
bool transform_snap_increment(TransInfo *t, float *r_val)
float transform_snap_distance_len_squared_fn(TransInfo *UNUSED(t), const float p1[3], const float p2[3])
bool validSnap(const TransInfo *t)
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:2003