Blender  V2.93
transform.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 "DNA_gpencil_types.h"
29 #include "DNA_mask_types.h"
30 #include "DNA_mesh_types.h"
31 
32 #include "BLI_math.h"
33 #include "BLI_rect.h"
34 
35 #include "BKE_context.h"
36 #include "BKE_editmesh.h"
37 #include "BKE_mask.h"
38 #include "BKE_scene.h"
39 
40 #include "GPU_state.h"
41 
42 #include "ED_clip.h"
43 #include "ED_gpencil.h"
44 #include "ED_image.h"
45 #include "ED_keyframing.h"
46 #include "ED_node.h"
47 #include "ED_screen.h"
48 #include "ED_space_api.h"
49 
50 #include "WM_api.h"
51 #include "WM_message.h"
52 #include "WM_types.h"
53 
54 #include "UI_interface_icons.h"
55 #include "UI_resources.h"
56 #include "UI_view2d.h"
57 
58 #include "RNA_access.h"
59 
60 #include "BLF_api.h"
61 #include "BLT_translation.h"
62 
63 #include "transform.h"
64 #include "transform_constraints.h"
65 #include "transform_convert.h"
66 #include "transform_draw_cursors.h"
67 #include "transform_mode.h"
68 #include "transform_orientations.h"
69 #include "transform_snap.h"
70 
71 /* Disabling, since when you type you know what you are doing,
72  * and being able to set it to zero is handy. */
73 /* #define USE_NUM_NO_ZERO */
74 
75 static void drawTransformApply(const struct bContext *C, ARegion *region, void *arg);
76 
77 static void initSnapSpatial(TransInfo *t, float r_snap[3]);
78 
80 {
81  if (t->options & (CTX_CURSOR | CTX_TEXTURE_SPACE)) {
82  return false;
83  }
84  return ((around == V3D_AROUND_LOCAL_ORIGINS) && (ELEM(t->obedit_type, OB_MESH, OB_GPENCIL)));
85 }
86 
87 /* ************************** SPACE DEPENDENT CODE **************************** */
88 
90 {
91  if (!(t->options & CTX_PAINT_CURVE) && (t->spacetype == SPACE_VIEW3D) && t->region &&
92  (t->region->regiontype == RGN_TYPE_WINDOW)) {
93  RegionView3D *rv3d = t->region->regiondata;
94 
95  copy_m4_m4(t->viewmat, rv3d->viewmat);
96  copy_m4_m4(t->viewinv, rv3d->viewinv);
97  copy_m4_m4(t->persmat, rv3d->persmat);
98  copy_m4_m4(t->persinv, rv3d->persinv);
99  t->persp = rv3d->persp;
100  }
101  else {
102  unit_m4(t->viewmat);
103  unit_m4(t->viewinv);
104  unit_m4(t->persmat);
105  unit_m4(t->persinv);
106  t->persp = RV3D_ORTHO;
107  }
108 
110  calculateCenterLocal(t, t->center_global);
111 }
112 
113 void setTransformViewAspect(TransInfo *t, float r_aspect[3])
114 {
115  copy_v3_fl(r_aspect, 1.0f);
116 
117  if (t->spacetype == SPACE_IMAGE) {
118  SpaceImage *sima = t->area->spacedata.first;
119 
120  if (t->options & CTX_MASK) {
121  ED_space_image_get_aspect(sima, &r_aspect[0], &r_aspect[1]);
122  }
123  else if (t->options & CTX_PAINT_CURVE) {
124  /* pass */
125  }
126  else {
127  ED_space_image_get_uv_aspect(sima, &r_aspect[0], &r_aspect[1]);
128  }
129  }
130  else if (t->spacetype == SPACE_CLIP) {
131  SpaceClip *sclip = t->area->spacedata.first;
132 
133  if (t->options & CTX_MOVIECLIP) {
134  ED_space_clip_get_aspect_dimension_aware(sclip, &r_aspect[0], &r_aspect[1]);
135  }
136  else {
137  ED_space_clip_get_aspect(sclip, &r_aspect[0], &r_aspect[1]);
138  }
139  }
140  else if (t->spacetype == SPACE_GRAPH) {
141  /* Depends on context of usage. */
142  }
143 }
144 
145 static void convertViewVec2D(View2D *v2d, float r_vec[3], int dx, int dy)
146 {
147  float divx = BLI_rcti_size_x(&v2d->mask);
148  float divy = BLI_rcti_size_y(&v2d->mask);
149 
150  r_vec[0] = BLI_rctf_size_x(&v2d->cur) * dx / divx;
151  r_vec[1] = BLI_rctf_size_y(&v2d->cur) * dy / divy;
152  r_vec[2] = 0.0f;
153 }
154 
155 static void convertViewVec2D_mask(View2D *v2d, float r_vec[3], int dx, int dy)
156 {
157  float divx = BLI_rcti_size_x(&v2d->mask);
158  float divy = BLI_rcti_size_y(&v2d->mask);
159 
160  float mulx = BLI_rctf_size_x(&v2d->cur);
161  float muly = BLI_rctf_size_y(&v2d->cur);
162 
163  /* difference with convertViewVec2D */
164  /* clamp w/h, mask only */
165  if (mulx / divx < muly / divy) {
166  divy = divx;
167  muly = mulx;
168  }
169  else {
170  divx = divy;
171  mulx = muly;
172  }
173  /* end difference */
174 
175  r_vec[0] = mulx * dx / divx;
176  r_vec[1] = muly * dy / divy;
177  r_vec[2] = 0.0f;
178 }
179 
180 void convertViewVec(TransInfo *t, float r_vec[3], double dx, double dy)
181 {
182  if ((t->spacetype == SPACE_VIEW3D) && (t->region->regiontype == RGN_TYPE_WINDOW)) {
183  if (t->options & CTX_PAINT_CURVE) {
184  r_vec[0] = dx;
185  r_vec[1] = dy;
186  }
187  else {
188  const float mval_f[2] = {(float)dx, (float)dy};
189  ED_view3d_win_to_delta(t->region, mval_f, r_vec, t->zfac);
190  }
191  }
192  else if (t->spacetype == SPACE_IMAGE) {
193  if (t->options & CTX_MASK) {
194  convertViewVec2D_mask(t->view, r_vec, dx, dy);
195  }
196  else if (t->options & CTX_PAINT_CURVE) {
197  r_vec[0] = dx;
198  r_vec[1] = dy;
199  }
200  else {
201  convertViewVec2D(t->view, r_vec, dx, dy);
202  }
203 
204  r_vec[0] *= t->aspect[0];
205  r_vec[1] *= t->aspect[1];
206  }
207  else if (ELEM(t->spacetype, SPACE_GRAPH, SPACE_NLA)) {
208  convertViewVec2D(t->view, r_vec, dx, dy);
209  }
210  else if (ELEM(t->spacetype, SPACE_NODE, SPACE_SEQ)) {
211  convertViewVec2D(&t->region->v2d, r_vec, dx, dy);
212  }
213  else if (t->spacetype == SPACE_CLIP) {
214  if (t->options & CTX_MASK) {
215  convertViewVec2D_mask(t->view, r_vec, dx, dy);
216  }
217  else {
218  convertViewVec2D(t->view, r_vec, dx, dy);
219  }
220 
221  r_vec[0] *= t->aspect[0];
222  r_vec[1] *= t->aspect[1];
223  }
224  else {
225  printf("%s: called in an invalid context\n", __func__);
226  zero_v3(r_vec);
227  }
228 }
229 
230 void projectIntViewEx(TransInfo *t, const float vec[3], int adr[2], const eV3DProjTest flag)
231 {
232  if (t->spacetype == SPACE_VIEW3D) {
233  if (t->region->regiontype == RGN_TYPE_WINDOW) {
234  if (ED_view3d_project_int_global(t->region, vec, adr, flag) != V3D_PROJ_RET_OK) {
235  /* this is what was done in 2.64, perhaps we can be smarter? */
236  adr[0] = (int)2140000000.0f;
237  adr[1] = (int)2140000000.0f;
238  }
239  }
240  }
241  else if (t->spacetype == SPACE_IMAGE) {
242  SpaceImage *sima = t->area->spacedata.first;
243 
244  if (t->options & CTX_MASK) {
245  float v[2];
246 
247  v[0] = vec[0] / t->aspect[0];
248  v[1] = vec[1] / t->aspect[1];
249 
250  BKE_mask_coord_to_image(sima->image, &sima->iuser, v, v);
251 
252  ED_image_point_pos__reverse(sima, t->region, v, v);
253 
254  adr[0] = v[0];
255  adr[1] = v[1];
256  }
257  else if (t->options & CTX_PAINT_CURVE) {
258  adr[0] = vec[0];
259  adr[1] = vec[1];
260  }
261  else {
262  float v[2];
263 
264  v[0] = vec[0] / t->aspect[0];
265  v[1] = vec[1] / t->aspect[1];
266 
267  UI_view2d_view_to_region(t->view, v[0], v[1], &adr[0], &adr[1]);
268  }
269  }
270  else if (t->spacetype == SPACE_ACTION) {
271  int out[2] = {0, 0};
272 #if 0
273  SpaceAction *sact = t->area->spacedata.first;
274 
275  if (sact->flag & SACTION_DRAWTIME) {
276  // vec[0] = vec[0] / ((t->scene->r.frs_sec / t->scene->r.frs_sec_base));
277  /* same as below */
278  UI_view2d_view_to_region((View2D *)t->view, vec[0], vec[1], &out[0], &out[1]);
279  }
280  else
281 #endif
282  {
283  UI_view2d_view_to_region((View2D *)t->view, vec[0], vec[1], &out[0], &out[1]);
284  }
285 
286  adr[0] = out[0];
287  adr[1] = out[1];
288  }
289  else if (ELEM(t->spacetype, SPACE_GRAPH, SPACE_NLA)) {
290  int out[2] = {0, 0};
291 
292  UI_view2d_view_to_region((View2D *)t->view, vec[0], vec[1], &out[0], &out[1]);
293  adr[0] = out[0];
294  adr[1] = out[1];
295  }
296  else if (t->spacetype == SPACE_SEQ) { /* XXX not tested yet, but should work */
297  int out[2] = {0, 0};
298 
299  UI_view2d_view_to_region((View2D *)t->view, vec[0], vec[1], &out[0], &out[1]);
300  adr[0] = out[0];
301  adr[1] = out[1];
302  }
303  else if (t->spacetype == SPACE_CLIP) {
304  SpaceClip *sc = t->area->spacedata.first;
305 
306  if (t->options & CTX_MASK) {
307  MovieClip *clip = ED_space_clip_get_clip(sc);
308 
309  if (clip) {
310  float v[2];
311 
312  v[0] = vec[0] / t->aspect[0];
313  v[1] = vec[1] / t->aspect[1];
314 
315  BKE_mask_coord_to_movieclip(sc->clip, &sc->user, v, v);
316 
317  ED_clip_point_stable_pos__reverse(sc, t->region, v, v);
318 
319  adr[0] = v[0];
320  adr[1] = v[1];
321  }
322  else {
323  adr[0] = 0;
324  adr[1] = 0;
325  }
326  }
327  else if (t->options & CTX_MOVIECLIP) {
328  float v[2];
329 
330  v[0] = vec[0] / t->aspect[0];
331  v[1] = vec[1] / t->aspect[1];
332 
333  UI_view2d_view_to_region(t->view, v[0], v[1], &adr[0], &adr[1]);
334  }
335  else {
336  BLI_assert(0);
337  }
338  }
339  else if (t->spacetype == SPACE_NODE) {
340  UI_view2d_view_to_region((View2D *)t->view, vec[0], vec[1], &adr[0], &adr[1]);
341  }
342 }
343 void projectIntView(TransInfo *t, const float vec[3], int adr[2])
344 {
346 }
347 
348 void projectFloatViewEx(TransInfo *t, const float vec[3], float adr[2], const eV3DProjTest flag)
349 {
350  switch (t->spacetype) {
351  case SPACE_VIEW3D: {
352  if (t->options & CTX_PAINT_CURVE) {
353  adr[0] = vec[0];
354  adr[1] = vec[1];
355  }
356  else if (t->region->regiontype == RGN_TYPE_WINDOW) {
357  /* allow points behind the view T33643. */
358  if (ED_view3d_project_float_global(t->region, vec, adr, flag) != V3D_PROJ_RET_OK) {
359  /* XXX, 2.64 and prior did this, weak! */
360  adr[0] = t->region->winx / 2.0f;
361  adr[1] = t->region->winy / 2.0f;
362  }
363  return;
364  }
365  break;
366  }
367  default: {
368  int a[2] = {0, 0};
369  projectIntView(t, vec, a);
370  adr[0] = a[0];
371  adr[1] = a[1];
372  break;
373  }
374  }
375 }
376 void projectFloatView(TransInfo *t, const float vec[3], float adr[2])
377 {
379 }
380 
381 void applyAspectRatio(TransInfo *t, float vec[2])
382 {
383  if ((t->spacetype == SPACE_IMAGE) && (t->mode == TFM_TRANSLATION) &&
384  !(t->options & CTX_PAINT_CURVE)) {
385  SpaceImage *sima = t->area->spacedata.first;
386 
387  if ((sima->flag & SI_COORDFLOATS) == 0) {
388  int width, height;
390 
391  vec[0] *= width;
392  vec[1] *= height;
393  }
394 
395  vec[0] /= t->aspect[0];
396  vec[1] /= t->aspect[1];
397  }
398  else if ((t->spacetype == SPACE_CLIP) && (t->mode == TFM_TRANSLATION)) {
399  if (t->options & (CTX_MOVIECLIP | CTX_MASK)) {
400  vec[0] /= t->aspect[0];
401  vec[1] /= t->aspect[1];
402  }
403  }
404 }
405 
406 void removeAspectRatio(TransInfo *t, float vec[2])
407 {
408  if ((t->spacetype == SPACE_IMAGE) && (t->mode == TFM_TRANSLATION)) {
409  SpaceImage *sima = t->area->spacedata.first;
410 
411  if ((sima->flag & SI_COORDFLOATS) == 0) {
412  int width, height;
414 
415  vec[0] /= width;
416  vec[1] /= height;
417  }
418 
419  vec[0] *= t->aspect[0];
420  vec[1] *= t->aspect[1];
421  }
422  else if ((t->spacetype == SPACE_CLIP) && (t->mode == TFM_TRANSLATION)) {
423  if (t->options & (CTX_MOVIECLIP | CTX_MASK)) {
424  vec[0] *= t->aspect[0];
425  vec[1] *= t->aspect[1];
426  }
427  }
428 }
429 
430 static void viewRedrawForce(const bContext *C, TransInfo *t)
431 {
432  if (t->options & CTX_GPENCIL_STROKES) {
434  if (gpd) {
436  }
438  }
439  else if (t->spacetype == SPACE_VIEW3D) {
440  if (t->options & CTX_PAINT_CURVE) {
441  wmWindow *window = CTX_wm_window(C);
442  WM_paint_cursor_tag_redraw(window, t->region);
443  }
444  else {
445  /* Do we need more refined tags? */
446  if (t->options & CTX_POSE_BONE) {
448  }
449  else {
451  }
452 
453  /* For real-time animation record - send notifiers recognized by animation editors */
454  /* XXX: is this notifier a lame duck? */
455  if ((t->animtimer) && IS_AUTOKEY_ON(t->scene)) {
457  }
458  }
459  }
460  else if (t->spacetype == SPACE_ACTION) {
461  // SpaceAction *saction = (SpaceAction *)t->area->spacedata.first;
463  }
464  else if (t->spacetype == SPACE_GRAPH) {
465  // SpaceGraph *sipo = (SpaceGraph *)t->area->spacedata.first;
467  }
468  else if (t->spacetype == SPACE_NLA) {
470  }
471  else if (t->spacetype == SPACE_NODE) {
472  // ED_area_tag_redraw(t->area);
474  }
475  else if (t->spacetype == SPACE_SEQ) {
477  /* Key-frames on strips has been moved, so make sure related editors are informed. */
479  }
480  else if (t->spacetype == SPACE_IMAGE) {
481  if (t->options & CTX_MASK) {
483 
485  }
486  else if (t->options & CTX_PAINT_CURVE) {
487  wmWindow *window = CTX_wm_window(C);
488  WM_paint_cursor_tag_redraw(window, t->region);
489  }
490  else if (t->options & CTX_CURSOR) {
491  ED_area_tag_redraw(t->area);
492  }
493  else {
494  /* XXX how to deal with lock? */
495  SpaceImage *sima = (SpaceImage *)t->area->spacedata.first;
496  if (sima->lock) {
498  }
499  else {
500  ED_area_tag_redraw(t->area);
501  }
502  }
503  }
504  else if (t->spacetype == SPACE_CLIP) {
505  SpaceClip *sc = (SpaceClip *)t->area->spacedata.first;
506 
508  MovieClip *clip = ED_space_clip_get_clip(sc);
509 
510  /* objects could be parented to tracking data, so send this for viewport refresh */
512 
514  }
515  else if (ED_space_clip_check_show_maskedit(sc)) {
517 
519  }
520  }
521 }
522 
524 {
525  ED_area_status_text(t->area, NULL);
526 
527  if (t->spacetype == SPACE_VIEW3D) {
528  /* if autokeying is enabled, send notifiers that keyframes were added */
529  if (IS_AUTOKEY_ON(t->scene)) {
531  }
532 
533  /* redraw UV editor */
534  const char uvcalc_correct_flag = ELEM(t->mode, TFM_VERT_SLIDE, TFM_EDGE_SLIDE) ?
537 
538  if ((t->data_type == TC_MESH_VERTS) && (t->settings->uvcalc_flag & uvcalc_correct_flag)) {
540  }
541 
542  /* XXX temp, first hack to get auto-render in compositor work (ton) */
544  }
545 
546 #if 0 /* TRANSFORM_FIX_ME */
547  if (t->spacetype == SPACE_VIEW3D) {
548  allqueue(REDRAWBUTSOBJECT, 0);
549  allqueue(REDRAWVIEW3D, 0);
550  }
551  else if (t->spacetype == SPACE_IMAGE) {
552  allqueue(REDRAWIMAGE, 0);
553  allqueue(REDRAWVIEW3D, 0);
554  }
555  else if (ELEM(t->spacetype, SPACE_ACTION, SPACE_NLA, SPACE_GRAPH)) {
556  allqueue(REDRAWVIEW3D, 0);
557  allqueue(REDRAWACTION, 0);
558  allqueue(REDRAWNLA, 0);
559  allqueue(REDRAWIPO, 0);
560  allqueue(REDRAWTIME, 0);
561  allqueue(REDRAWBUTSOBJECT, 0);
562  }
563 
564  scrarea_queue_headredraw(curarea);
565 #endif
566 }
567 
568 /* ************************************************* */
569 
570 static bool transform_modal_item_poll(const wmOperator *op, int value)
571 {
572  const TransInfo *t = op->customdata;
573  switch (value) {
574  case TFM_MODAL_CANCEL: {
575  /* TODO: Canceling with LMB is not possible when the operator is activated
576  * through tweak and the LMB is pressed.
577  * Therefore, this item should not appear in the status bar. */
578  break;
579  }
580  case TFM_MODAL_PROPSIZE:
583  if ((t->flag & T_PROP_EDIT) == 0) {
584  return false;
585  }
586  break;
587  }
588  case TFM_MODAL_ADD_SNAP:
589  case TFM_MODAL_REMOVE_SNAP: {
590  if (t->spacetype != SPACE_VIEW3D) {
591  return false;
592  }
593  if ((t->tsnap.mode & ~(SCE_SNAP_MODE_INCREMENT | SCE_SNAP_MODE_GRID)) == 0) {
594  return false;
595  }
596  if (!validSnap(t)) {
597  return false;
598  }
599  break;
600  }
601  case TFM_MODAL_AXIS_X:
602  case TFM_MODAL_AXIS_Y:
603  case TFM_MODAL_AXIS_Z:
604  case TFM_MODAL_PLANE_X:
605  case TFM_MODAL_PLANE_Y:
606  case TFM_MODAL_PLANE_Z:
608  if (t->flag & T_NO_CONSTRAINT) {
609  return false;
610  }
611  if (!ELEM(value, TFM_MODAL_AXIS_X, TFM_MODAL_AXIS_Y)) {
612  if (t->flag & T_2D_EDIT) {
613  return false;
614  }
615  }
616  break;
617  }
618  case TFM_MODAL_CONS_OFF: {
619  if ((t->con.mode & CON_APPLY) == 0) {
620  return false;
621  }
622  break;
623  }
626  if (t->mode != TFM_EDGE_SLIDE) {
627  return false;
628  }
629  break;
630  }
632  if (t->spacetype != SPACE_NODE) {
633  return false;
634  }
635  break;
636  }
639  if ((t->flag & T_AUTOIK) == 0) {
640  return false;
641  }
642  break;
643  }
644  case TFM_MODAL_TRANSLATE:
645  case TFM_MODAL_ROTATE:
646  case TFM_MODAL_RESIZE: {
647  if (!transform_mode_is_changeable(t->mode)) {
648  return false;
649  }
650  break;
651  }
652  }
653  return true;
654 }
655 
656 /* called in transform_ops.c, on each regeneration of keymaps */
658 {
659  static const EnumPropertyItem modal_items[] = {
660  {TFM_MODAL_CONFIRM, "CONFIRM", 0, "Confirm", ""},
661  {TFM_MODAL_CANCEL, "CANCEL", 0, "Cancel", ""},
662  {TFM_MODAL_AXIS_X, "AXIS_X", 0, "X Axis", ""},
663  {TFM_MODAL_AXIS_Y, "AXIS_Y", 0, "Y Axis", ""},
664  {TFM_MODAL_AXIS_Z, "AXIS_Z", 0, "Z Axis", ""},
665  {TFM_MODAL_PLANE_X, "PLANE_X", 0, "X Plane", ""},
666  {TFM_MODAL_PLANE_Y, "PLANE_Y", 0, "Y Plane", ""},
667  {TFM_MODAL_PLANE_Z, "PLANE_Z", 0, "Z Plane", ""},
668  {TFM_MODAL_CONS_OFF, "CONS_OFF", 0, "Clear Constraints", ""},
669  {TFM_MODAL_SNAP_INV_ON, "SNAP_INV_ON", 0, "Snap Invert", ""},
670  {TFM_MODAL_SNAP_INV_OFF, "SNAP_INV_OFF", 0, "Snap Invert (Off)", ""},
671  {TFM_MODAL_SNAP_TOGGLE, "SNAP_TOGGLE", 0, "Snap Toggle", ""},
672  {TFM_MODAL_ADD_SNAP, "ADD_SNAP", 0, "Add Snap Point", ""},
673  {TFM_MODAL_REMOVE_SNAP, "REMOVE_SNAP", 0, "Remove Last Snap Point", ""},
674  {NUM_MODAL_INCREMENT_UP, "INCREMENT_UP", 0, "Numinput Increment Up", ""},
675  {NUM_MODAL_INCREMENT_DOWN, "INCREMENT_DOWN", 0, "Numinput Increment Down", ""},
676  {TFM_MODAL_PROPSIZE_UP, "PROPORTIONAL_SIZE_UP", 0, "Increase Proportional Influence", ""},
678  "PROPORTIONAL_SIZE_DOWN",
679  0,
680  "Decrease Proportional Influence",
681  ""},
682  {TFM_MODAL_AUTOIK_LEN_INC, "AUTOIK_CHAIN_LEN_UP", 0, "Increase Max AutoIK Chain Length", ""},
684  "AUTOIK_CHAIN_LEN_DOWN",
685  0,
686  "Decrease Max AutoIK Chain Length",
687  ""},
688  {TFM_MODAL_EDGESLIDE_UP, "EDGESLIDE_EDGE_NEXT", 0, "Select Next Edge Slide Edge", ""},
689  {TFM_MODAL_EDGESLIDE_DOWN, "EDGESLIDE_PREV_NEXT", 0, "Select Previous Edge Slide Edge", ""},
690  {TFM_MODAL_PROPSIZE, "PROPORTIONAL_SIZE", 0, "Adjust Proportional Influence", ""},
692  "INSERTOFS_TOGGLE_DIR",
693  0,
694  "Toggle Direction for Node Auto-Offset",
695  ""},
696  {TFM_MODAL_TRANSLATE, "TRANSLATE", 0, "Move", ""},
697  {TFM_MODAL_ROTATE, "ROTATE", 0, "Rotate", ""},
698  {TFM_MODAL_RESIZE, "RESIZE", 0, "Resize", ""},
699  {TFM_MODAL_AUTOCONSTRAINT, "AUTOCONSTRAIN", 0, "Automatic Constraint", ""},
700  {TFM_MODAL_AUTOCONSTRAINTPLANE, "AUTOCONSTRAINPLANE", 0, "Automatic Constraint Plane", ""},
701  {TFM_MODAL_PRECISION, "PRECISION", 0, "Precision Mode", ""},
702  {0, NULL, 0, NULL, NULL},
703  };
704 
705  wmKeyMap *keymap = WM_modalkeymap_ensure(keyconf, "Transform Modal Map", modal_items);
707 
708  /* Default modal map values:
709  *
710  * \code{.c}
711  * WM_modalkeymap_add_item(keymap, EVT_RETKEY, KM_PRESS, KM_ANY, 0, TFM_MODAL_CONFIRM);
712  * WM_modalkeymap_add_item(keymap, EVT_ESCKEY, KM_PRESS, KM_ANY, 0, TFM_MODAL_CANCEL);
713  * WM_modalkeymap_add_item(keymap, EVT_PAGEUPKEY, KM_PRESS, KM_ANY, 0, TFM_MODAL_AUTOIK_LEN_INC);
714  * WM_modalkeymap_add_item(
715  * keymap, EVT_PAGEDOWNKEY, KM_PRESS, KM_ANY, 0, TFM_MODAL_AUTOIK_LEN_DEC);
716  * WM_modalkeymap_add_item(keymap, EVT_GKEY, KM_PRESS, KM_ANY, 0, TFM_MODAL_TRANSLATE);
717  * WM_modalkeymap_add_item(keymap, EVT_RKEY, KM_PRESS, KM_ANY, 0, TFM_MODAL_ROTATE);
718  * WM_modalkeymap_add_item(keymap, EVT_SKEY, KM_PRESS, KM_ANY, 0, TFM_MODAL_RESIZE);
719  * WM_modalkeymap_add_item(keymap, MIDDLEMOUSE, KM_PRESS, KM_ANY, 0, TFM_MODAL_AUTOCONSTRAINT);
720  * WM_modalkeymap_add_item(
721  * keymap, MIDDLEMOUSE, KM_PRESS, KM_SHIFT, 0, TFM_MODAL_AUTOCONSTRAINTPLANE);
722  * \endcode
723  */
724 
725  return keymap;
726 }
727 
728 static bool transform_event_modal_constraint(TransInfo *t, short modal_type)
729 {
730  if (t->flag & T_NO_CONSTRAINT) {
731  return false;
732  }
733 
734  if (t->flag & T_2D_EDIT && ELEM(modal_type, TFM_MODAL_AXIS_Z, TFM_MODAL_PLANE_Z)) {
735  return false;
736  }
737 
738  int constraint_curr = -1;
739 
742 
743  /* Avoid changing orientation in this case. */
744  constraint_curr = -2;
745  }
746  else if (t->con.mode & CON_APPLY) {
747  constraint_curr = t->con.mode & (CON_AXIS0 | CON_AXIS1 | CON_AXIS2);
748  }
749 
750  int constraint_new;
751  const char *msg_2d = "", *msg_3d = "";
752 
753  /* Initialize */
754  switch (modal_type) {
755  case TFM_MODAL_AXIS_X:
756  msg_2d = TIP_("along X");
757  msg_3d = TIP_("along %s X");
758  constraint_new = CON_AXIS0;
759  break;
760  case TFM_MODAL_AXIS_Y:
761  msg_2d = TIP_("along Y");
762  msg_3d = TIP_("along %s Y");
763  constraint_new = CON_AXIS1;
764  break;
765  case TFM_MODAL_AXIS_Z:
766  msg_2d = TIP_("along Z");
767  msg_3d = TIP_("along %s Z");
768  constraint_new = CON_AXIS2;
769  break;
770  case TFM_MODAL_PLANE_X:
771  msg_3d = TIP_("locking %s X");
772  constraint_new = CON_AXIS1 | CON_AXIS2;
773  break;
774  case TFM_MODAL_PLANE_Y:
775  msg_3d = TIP_("locking %s Y");
776  constraint_new = CON_AXIS0 | CON_AXIS2;
777  break;
778  case TFM_MODAL_PLANE_Z:
779  msg_3d = TIP_("locking %s Z");
780  constraint_new = CON_AXIS0 | CON_AXIS1;
781  break;
782  default:
783  /* Invalid key */
784  return false;
785  }
786 
787  if (t->flag & T_2D_EDIT) {
788  BLI_assert(modal_type < TFM_MODAL_PLANE_X);
789  if (constraint_new == CON_AXIS2) {
790  return false;
791  }
792  if (constraint_curr == constraint_new) {
793  stopConstraint(t);
794  }
795  else {
796  setUserConstraint(t, constraint_new, msg_2d);
797  }
798  }
799  else {
800  short orient_index = 1;
801  if (t->orient_curr == O_DEFAULT || ELEM(constraint_curr, -1, constraint_new)) {
802  /* Successive presses on existing axis, cycle orientation modes. */
803  orient_index = (short)((t->orient_curr + 1) % (int)ARRAY_SIZE(t->orient));
804  }
805 
806  transform_orientations_current_set(t, orient_index);
807  if (orient_index == 0) {
808  stopConstraint(t);
809  }
810  else {
811  setUserConstraint(t, constraint_new, msg_3d);
812  }
813  }
814  t->redraw |= TREDRAW_HARD;
815  return true;
816 }
817 
818 int transformEvent(TransInfo *t, const wmEvent *event)
819 {
820  bool handled = false;
821  const int modifiers_prev = t->modifiers;
822  const int mode_prev = t->mode;
823 
824  /* Handle modal numinput events first, if already activated. */
825  if (((event->val == KM_PRESS) || (event->type == EVT_MODAL_MAP)) && hasNumInput(&t->num) &&
826  handleNumInput(t->context, &(t->num), event)) {
827  t->redraw |= TREDRAW_HARD;
828  handled = true;
829  }
830  else if (event->type == MOUSEMOVE) {
832  t->con.mode |= CON_SELECT;
833  }
834 
835  copy_v2_v2_int(t->mval, event->mval);
836 
837  /* Use this for soft redraw. Might cause flicker in object mode */
838  // t->redraw |= TREDRAW_SOFT;
839  t->redraw |= TREDRAW_HARD;
840 
841  if (t->state == TRANS_STARTING) {
842  t->state = TRANS_RUNNING;
843  }
844 
845  applyMouseInput(t, &t->mouse, t->mval, t->values);
846 
847  /* Snapping mouse move events. */
848  t->redraw |= handleSnapping(t, event);
849  handled = true;
850  }
851  /* handle modal keymap first */
852  /* enforce redraw of transform when modifiers are used */
853  else if (event->type == EVT_MODAL_MAP) {
854  switch (event->val) {
855  case TFM_MODAL_CANCEL:
856  t->state = TRANS_CANCEL;
857  handled = true;
858  break;
859  case TFM_MODAL_CONFIRM:
860  t->state = TRANS_CONFIRM;
861  handled = true;
862  break;
863  case TFM_MODAL_TRANSLATE:
864  /* only switch when... */
865  if (t->mode == TFM_TRANSLATION) {
866  if (!(t->options & (CTX_CURSOR | CTX_TEXTURE_SPACE)) && (t->obedit_type == OB_MESH) &&
867  (t->spacetype == SPACE_VIEW3D)) {
871 
872  /* first try edge slide */
874  /* if that fails, do vertex slide */
875  if (t->state == TRANS_CANCEL) {
877  t->state = TRANS_STARTING;
879  }
880  /* vert slide can fail on unconnected vertices (rare but possible) */
881  if (t->state == TRANS_CANCEL) {
883  t->state = TRANS_STARTING;
887  }
888  initSnapping(t, NULL); /* need to reinit after mode change */
889  t->redraw |= TREDRAW_HARD;
890  handled = true;
891  }
892  else if (t->options & (CTX_MOVIECLIP | CTX_MASK)) {
894 
895  t->flag ^= T_ALT_TRANSFORM;
896  t->redraw |= TREDRAW_HARD;
897  handled = true;
898  }
899  }
900  else if (transform_mode_is_changeable(t->mode)) {
905  initSnapping(t, NULL); /* need to reinit after mode change */
906  t->redraw |= TREDRAW_HARD;
907  handled = true;
908  }
909  break;
910  case TFM_MODAL_ROTATE:
911  /* only switch when... */
912  if (!(t->options & CTX_TEXTURE_SPACE) && !(t->options & (CTX_MOVIECLIP | CTX_MASK))) {
913  if (transform_mode_is_changeable(t->mode)) {
917 
918  if (t->mode == TFM_ROTATION) {
920  }
921  else {
923  }
924  initSnapping(t, NULL); /* need to reinit after mode change */
925  t->redraw |= TREDRAW_HARD;
926  handled = true;
927  }
928  }
929  break;
930  case TFM_MODAL_RESIZE:
931  /* only switch when... */
932  if (t->mode == TFM_RESIZE) {
933  if (t->options & CTX_MOVIECLIP) {
935 
936  t->flag ^= T_ALT_TRANSFORM;
937  t->redraw |= TREDRAW_HARD;
938  handled = true;
939  }
940  }
941  else if (transform_mode_is_changeable(t->mode)) {
942  /* Scale isn't normally very useful after extrude along normals, see T39756 */
943  if ((t->con.mode & CON_APPLY) && (t->orient[t->orient_curr].type == V3D_ORIENT_NORMAL)) {
944  stopConstraint(t);
945  }
946 
951  initSnapping(t, NULL); /* need to reinit after mode change */
952  t->redraw |= TREDRAW_HARD;
953  handled = true;
954  }
955  break;
956 
958  t->modifiers |= MOD_SNAP_INVERT;
959  t->redraw |= TREDRAW_HARD;
960  handled = true;
961  break;
963  t->modifiers &= ~MOD_SNAP_INVERT;
964  t->redraw |= TREDRAW_HARD;
965  handled = true;
966  break;
968  t->modifiers ^= MOD_SNAP;
969  t->redraw |= TREDRAW_HARD;
970  handled = true;
971  break;
972  case TFM_MODAL_AXIS_X:
973  case TFM_MODAL_AXIS_Y:
974  case TFM_MODAL_AXIS_Z:
975  case TFM_MODAL_PLANE_X:
976  case TFM_MODAL_PLANE_Y:
977  case TFM_MODAL_PLANE_Z:
978  if (transform_event_modal_constraint(t, event->val)) {
979  handled = true;
980  }
981  break;
982  case TFM_MODAL_CONS_OFF:
983  if ((t->flag & T_NO_CONSTRAINT) == 0) {
984  stopConstraint(t);
985  t->redraw |= TREDRAW_HARD;
986  handled = true;
987  }
988  break;
989  case TFM_MODAL_ADD_SNAP:
990  addSnapPoint(t);
991  t->redraw |= TREDRAW_HARD;
992  handled = true;
993  break;
996  t->redraw |= TREDRAW_HARD;
997  handled = true;
998  break;
999  case TFM_MODAL_PROPSIZE:
1000  /* MOUSEPAN usage... */
1001  if (t->flag & T_PROP_EDIT) {
1002  float fac = 1.0f + 0.005f * (event->y - event->prevy);
1003  t->prop_size *= fac;
1004  if (t->spacetype == SPACE_VIEW3D && t->persp != RV3D_ORTHO) {
1005  t->prop_size = max_ff(min_ff(t->prop_size, ((View3D *)t->view)->clip_end),
1006  T_PROP_SIZE_MIN);
1007  }
1008  else {
1009  t->prop_size = max_ff(min_ff(t->prop_size, T_PROP_SIZE_MAX), T_PROP_SIZE_MIN);
1010  }
1012  t->redraw |= TREDRAW_HARD;
1013  handled = true;
1014  }
1015  break;
1016  case TFM_MODAL_PROPSIZE_UP:
1017  if (t->flag & T_PROP_EDIT) {
1018  t->prop_size *= (t->modifiers & MOD_PRECISION) ? 1.01f : 1.1f;
1019  if (t->spacetype == SPACE_VIEW3D && t->persp != RV3D_ORTHO) {
1020  t->prop_size = min_ff(t->prop_size, ((View3D *)t->view)->clip_end);
1021  }
1022  else {
1023  t->prop_size = min_ff(t->prop_size, T_PROP_SIZE_MAX);
1024  }
1026  t->redraw |= TREDRAW_HARD;
1027  handled = true;
1028  }
1029  break;
1031  if (t->flag & T_PROP_EDIT) {
1032  t->prop_size /= (t->modifiers & MOD_PRECISION) ? 1.01f : 1.1f;
1033  t->prop_size = max_ff(t->prop_size, T_PROP_SIZE_MIN);
1035  t->redraw |= TREDRAW_HARD;
1036  handled = true;
1037  }
1038  break;
1040  if (t->flag & T_AUTOIK) {
1042  t->redraw |= TREDRAW_HARD;
1043  handled = true;
1044  }
1045  break;
1047  if (t->flag & T_AUTOIK) {
1049  t->redraw |= TREDRAW_HARD;
1050  handled = true;
1051  }
1052  break;
1054  if (t->spacetype == SPACE_NODE) {
1055  SpaceNode *snode = (SpaceNode *)t->area->spacedata.first;
1056 
1057  BLI_assert(t->area->spacetype == t->spacetype);
1058 
1059  if (snode->insert_ofs_dir == SNODE_INSERTOFS_DIR_RIGHT) {
1061  }
1062  else if (snode->insert_ofs_dir == SNODE_INSERTOFS_DIR_LEFT) {
1064  }
1065  else {
1066  BLI_assert(0);
1067  }
1068 
1069  t->redraw |= TREDRAW_SOFT;
1070  }
1071  break;
1074  if ((t->flag & T_RELEASE_CONFIRM) && (event->prevval == KM_RELEASE) &&
1075  event->prevtype == t->launch_event) {
1076  /* Confirm transform if launch key is released after mouse move. */
1077  t->state = TRANS_CONFIRM;
1078  }
1079  else if ((t->flag & T_NO_CONSTRAINT) == 0) {
1081  /* Confirm. */
1084  }
1085  else {
1086  if (t->options & CTX_CAMERA) {
1087  /* Exception for switching to dolly, or trackball, in camera view. */
1088  if (t->mode == TFM_TRANSLATION) {
1089  setLocalConstraint(t, (CON_AXIS2), TIP_("along local Z"));
1090  }
1091  else if (t->mode == TFM_ROTATION) {
1094  }
1095  }
1096  else {
1097  t->modifiers |= (event->val == TFM_MODAL_AUTOCONSTRAINT) ?
1100  if (t->con.mode & CON_APPLY) {
1101  stopConstraint(t);
1102  }
1103  else {
1106  }
1107  }
1108  }
1109  t->redraw |= TREDRAW_HARD;
1110  handled = true;
1111  }
1112  break;
1113  case TFM_MODAL_PRECISION:
1114  if (event->prevval == KM_PRESS) {
1115  t->modifiers |= MOD_PRECISION;
1116  /* Shift is modifier for higher precision transform. */
1117  t->mouse.precision = 1;
1118  t->redraw |= TREDRAW_HARD;
1119  }
1120  else if (event->prevval == KM_RELEASE) {
1121  t->modifiers &= ~MOD_PRECISION;
1122  t->mouse.precision = 0;
1123  t->redraw |= TREDRAW_HARD;
1124  }
1125  break;
1126  /* Those two are only handled in transform's own handler, see T44634! */
1129  default:
1130  break;
1131  }
1132  }
1133  /* Else do non-mapped events. */
1134  else if (event->val == KM_PRESS) {
1135  switch (event->type) {
1136  case EVT_CKEY:
1137  if (event->is_repeat) {
1138  break;
1139  }
1140  if (event->alt) {
1141  if (!(t->options & CTX_NO_PET)) {
1142  t->flag ^= T_PROP_CONNECTED;
1145  t->redraw = TREDRAW_HARD;
1146  handled = true;
1147  }
1148  }
1149  break;
1150  case EVT_OKEY:
1151  if (event->is_repeat) {
1152  break;
1153  }
1154  if (t->flag & T_PROP_EDIT && event->shift) {
1155  t->prop_mode = (t->prop_mode + 1) % PROP_MODE_MAX;
1157  t->redraw |= TREDRAW_HARD;
1158  handled = true;
1159  }
1160  break;
1161  case EVT_PADPLUSKEY:
1162  if (event->alt && t->flag & T_PROP_EDIT) {
1163  t->prop_size *= (t->modifiers & MOD_PRECISION) ? 1.01f : 1.1f;
1164  if (t->spacetype == SPACE_VIEW3D && t->persp != RV3D_ORTHO) {
1165  t->prop_size = min_ff(t->prop_size, ((View3D *)t->view)->clip_end);
1166  }
1168  t->redraw = TREDRAW_HARD;
1169  handled = true;
1170  }
1171  break;
1172  case EVT_PADMINUS:
1173  if (event->alt && t->flag & T_PROP_EDIT) {
1174  t->prop_size /= (t->modifiers & MOD_PRECISION) ? 1.01f : 1.1f;
1176  t->redraw = TREDRAW_HARD;
1177  handled = true;
1178  }
1179  break;
1180  case EVT_LEFTALTKEY:
1181  case EVT_RIGHTALTKEY:
1182  if (ELEM(t->spacetype, SPACE_SEQ, SPACE_VIEW3D)) {
1183  t->flag |= T_ALT_TRANSFORM;
1184  t->redraw |= TREDRAW_HARD;
1185  handled = true;
1186  }
1187  break;
1188  case EVT_NKEY:
1189  if (event->is_repeat) {
1190  break;
1191  }
1192  if (ELEM(t->mode, TFM_ROTATION)) {
1193  if ((t->flag & T_EDIT) && t->obedit_type == OB_MESH) {
1195  resetTransModal(t);
1198  t->redraw = TREDRAW_HARD;
1199  handled = true;
1200  }
1201  }
1202  break;
1203  default:
1204  break;
1205  }
1206 
1207  /* Snapping key events */
1208  t->redraw |= handleSnapping(t, event);
1209  }
1210  else if (event->val == KM_RELEASE) {
1211  switch (event->type) {
1212  case EVT_LEFTALTKEY:
1213  case EVT_RIGHTALTKEY:
1214  /* TODO: Modal Map */
1215  if (ELEM(t->spacetype, SPACE_SEQ, SPACE_VIEW3D)) {
1216  t->flag &= ~T_ALT_TRANSFORM;
1217  t->redraw |= TREDRAW_HARD;
1218  handled = true;
1219  }
1220  break;
1221  }
1222 
1223  /* confirm transform if launch key is released after mouse move */
1224  if ((t->flag & T_RELEASE_CONFIRM) && event->type == t->launch_event) {
1225  t->state = TRANS_CONFIRM;
1226  }
1227  }
1228 
1229  /* if we change snap options, get the unsnapped values back */
1230  if ((mode_prev != t->mode) || ((t->modifiers & (MOD_SNAP | MOD_SNAP_INVERT)) !=
1231  (modifiers_prev & (MOD_SNAP | MOD_SNAP_INVERT)))) {
1232  applyMouseInput(t, &t->mouse, t->mval, t->values);
1233  }
1234 
1235  /* Per transform event, if present */
1236  if (t->handleEvent && (!handled ||
1237  /* Needed for vertex slide, see T38756. */
1238  (event->type == MOUSEMOVE))) {
1239  t->redraw |= t->handleEvent(t, event);
1240  }
1241 
1242  /* Try to init modal numinput now, if possible. */
1243  if (!(handled || t->redraw) && ((event->val == KM_PRESS) || (event->type == EVT_MODAL_MAP)) &&
1244  handleNumInput(t->context, &(t->num), event)) {
1245  t->redraw |= TREDRAW_HARD;
1246  handled = true;
1247  }
1248 
1249  if (t->redraw && !ELEM(event->type, MOUSEMOVE, INBETWEEN_MOUSEMOVE)) {
1251  }
1252 
1253  if (handled || t->redraw) {
1254  return 0;
1255  }
1256  return OPERATOR_PASS_THROUGH;
1257 }
1258 
1259 bool calculateTransformCenter(bContext *C, int centerMode, float cent3d[3], float cent2d[2])
1260 {
1261  TransInfo *t = MEM_callocN(sizeof(TransInfo), "TransInfo data");
1262  bool success;
1263 
1264  t->context = C;
1265 
1266  t->state = TRANS_RUNNING;
1267 
1268  /* avoid calculating PET */
1269  t->options = CTX_NO_PET;
1270 
1271  t->mode = TFM_DUMMY;
1272 
1273  initTransInfo(C, t, NULL, NULL);
1274 
1275  /* avoid doing connectivity lookups (when V3D_AROUND_LOCAL_ORIGINS is set) */
1276  t->around = V3D_AROUND_CENTER_BOUNDS;
1277 
1278  createTransData(C, t); /* make TransData structs from selection */
1279 
1280  t->around = centerMode; /* override user-defined mode. */
1281 
1282  if (t->data_len_all == 0) {
1283  success = false;
1284  }
1285  else {
1286  success = true;
1287 
1288  calculateCenter(t);
1289 
1290  if (cent2d) {
1291  copy_v2_v2(cent2d, t->center2d);
1292  }
1293 
1294  if (cent3d) {
1295  /* Copy center from constraint center. Transform center can be local */
1296  copy_v3_v3(cent3d, t->center_global);
1297  }
1298  }
1299 
1300  /* aftertrans does insert keyframes, and clears base flags; doesn't read transdata */
1302 
1303  postTrans(C, t);
1304 
1305  MEM_freeN(t);
1306 
1307  return success;
1308 }
1309 
1310 static bool transinfo_show_overlay(const struct bContext *C, TransInfo *t, ARegion *region)
1311 {
1312  /* Don't show overlays when not the active view and when overlay is disabled: T57139 */
1313  bool ok = false;
1314  if (region == t->region) {
1315  ok = true;
1316  }
1317  else {
1318  ScrArea *area = CTX_wm_area(C);
1319  if (area->spacetype == SPACE_VIEW3D) {
1320  View3D *v3d = area->spacedata.first;
1321  if ((v3d->flag2 & V3D_HIDE_OVERLAYS) == 0) {
1322  ok = true;
1323  }
1324  }
1325  }
1326  return ok;
1327 }
1328 
1329 static void drawTransformView(const struct bContext *C, ARegion *region, void *arg)
1330 {
1331  TransInfo *t = arg;
1332 
1333  if (!transinfo_show_overlay(C, t, region)) {
1334  return;
1335  }
1336 
1337  GPU_line_width(1.0f);
1338 
1339  drawConstraint(t);
1340  drawPropCircle(C, t);
1341  drawSnapping(C, t);
1342 
1343  if (region == t->region) {
1344  /* edge slide, vert slide */
1345  drawEdgeSlide(t);
1346  drawVertSlide(t);
1347 
1348  /* Rotation */
1349  drawDial3d(t);
1350  }
1351 }
1352 
1353 /* just draw a little warning message in the top-right corner of the viewport
1354  * to warn that autokeying is enabled */
1356 {
1357  const char *printable = IFACE_("Auto Keying On");
1358  float printable_size[2];
1359  int xco, yco;
1360 
1361  const rcti *rect = ED_region_visible_rect(region);
1362 
1363  const int font_id = BLF_default();
1365  font_id, printable, BLF_DRAW_STR_DUMMY_MAX, &printable_size[0], &printable_size[1]);
1366 
1367  xco = (rect->xmax - U.widget_unit) - (int)printable_size[0];
1368  yco = (rect->ymax - U.widget_unit);
1369 
1370  /* warning text (to clarify meaning of overlays)
1371  * - original color was red to match the icon, but that clashes badly with a less nasty border
1372  */
1373  uchar color[3];
1375  BLF_color3ubv(font_id, color);
1376 #ifdef WITH_INTERNATIONAL
1377  BLF_draw_default(xco, yco, 0.0f, printable, BLF_DRAW_STR_DUMMY_MAX);
1378 #else
1379  BLF_draw_default_ascii(xco, yco, 0.0f, printable, BLF_DRAW_STR_DUMMY_MAX);
1380 #endif
1381 
1382  /* autokey recording icon... */
1384 
1385  xco -= U.widget_unit;
1386  yco -= (int)printable_size[1] / 2;
1387 
1388  UI_icon_draw(xco, yco, ICON_REC);
1389 
1391 }
1392 
1393 static void drawTransformPixel(const struct bContext *C, ARegion *region, void *arg)
1394 {
1395  TransInfo *t = arg;
1396 
1397  if (!transinfo_show_overlay(C, t, region)) {
1398  return;
1399  }
1400 
1401  if (region == t->region) {
1402  Scene *scene = t->scene;
1403  ViewLayer *view_layer = t->view_layer;
1404  Object *ob = OBACT(view_layer);
1405 
1406  /* draw auto-key-framing hint in the corner
1407  * - only draw if enabled (advanced users may be distracted/annoyed),
1408  * for objects that will be autokeyframed (no point otherwise),
1409  * AND only for the active region (as showing all is too overwhelming)
1410  */
1411  if ((U.autokey_flag & AUTOKEY_FLAG_NOWARNING) == 0) {
1412  if (region == t->region) {
1413  if (t->options & (CTX_OBJECT | CTX_POSE_BONE)) {
1414  if (ob && autokeyframe_cfra_can_key(scene, &ob->id)) {
1415  drawAutoKeyWarning(t, region);
1416  }
1417  }
1418  }
1419  }
1420  }
1421 }
1422 
1427 {
1429  PropertyRNA *prop;
1430 
1431  /* Save back mode in case we're in the generic operator */
1432  if ((prop = RNA_struct_find_property(op->ptr, "mode"))) {
1433  RNA_property_enum_set(op->ptr, prop, t->mode);
1434  }
1435 
1436  if ((prop = RNA_struct_find_property(op->ptr, "value"))) {
1437  if (RNA_property_array_check(prop)) {
1438  RNA_property_float_set_array(op->ptr, prop, t->values_final);
1439  }
1440  else {
1441  RNA_property_float_set(op->ptr, prop, t->values_final[0]);
1442  }
1443  }
1444 
1445  bool use_prop_edit = false;
1446  int prop_edit_flag = 0;
1447  if (t->flag & T_PROP_EDIT_ALL) {
1448  if (t->flag & T_PROP_EDIT) {
1449  use_prop_edit = true;
1450  }
1451  if (t->flag & T_PROP_CONNECTED) {
1452  prop_edit_flag |= PROP_EDIT_CONNECTED;
1453  }
1454  if (t->flag & T_PROP_PROJECTED) {
1455  prop_edit_flag |= PROP_EDIT_PROJECTED;
1456  }
1457  }
1458 
1459  /* If modal, save settings back in scene if not set as operator argument */
1460  if ((t->flag & T_MODAL) || (op->flag & OP_IS_REPEAT)) {
1461  /* save settings if not set in operator */
1462 
1463  /* skip saving proportional edit if it was not actually used */
1464  if (!(t->options & CTX_NO_PET)) {
1465  if ((prop = RNA_struct_find_property(op->ptr, "use_proportional_edit")) &&
1466  !RNA_property_is_set(op->ptr, prop)) {
1467  const Object *obact = OBACT(t->view_layer);
1468 
1469  if (t->spacetype == SPACE_GRAPH) {
1470  ts->proportional_fcurve = use_prop_edit;
1471  }
1472  else if (t->spacetype == SPACE_ACTION) {
1473  ts->proportional_action = use_prop_edit;
1474  }
1475  else if (t->options & CTX_MASK) {
1476  ts->proportional_mask = use_prop_edit;
1477  }
1478  else if (obact && obact->mode == OB_MODE_OBJECT) {
1479  ts->proportional_objects = use_prop_edit;
1480  }
1481  else {
1482  if (use_prop_edit) {
1484  }
1485  else {
1487  }
1488  }
1489  }
1490 
1491  if ((prop = RNA_struct_find_property(op->ptr, "proportional_size"))) {
1492  ts->proportional_size = RNA_property_is_set(op->ptr, prop) ?
1493  RNA_property_float_get(op->ptr, prop) :
1494  t->prop_size;
1495  }
1496 
1497  if ((prop = RNA_struct_find_property(op->ptr, "proportional_edit_falloff")) &&
1498  !RNA_property_is_set(op->ptr, prop)) {
1499  ts->prop_mode = t->prop_mode;
1500  }
1501  }
1502  }
1503 
1504  if (t->flag & T_MODAL) {
1505  /* do we check for parameter? */
1506  if (transformModeUseSnap(t)) {
1507  if (!(t->modifiers & MOD_SNAP) != !(ts->snap_flag & SCE_SNAP)) {
1508  if (t->modifiers & MOD_SNAP) {
1509  ts->snap_flag |= SCE_SNAP;
1510  }
1511  else {
1512  ts->snap_flag &= ~SCE_SNAP;
1513  }
1514  WM_msg_publish_rna_prop(t->mbus, &t->scene->id, ts, ToolSettings, use_snap);
1515  }
1516  }
1517  }
1518 
1519  if ((prop = RNA_struct_find_property(op->ptr, "use_proportional_edit"))) {
1520  RNA_property_boolean_set(op->ptr, prop, use_prop_edit);
1521  RNA_boolean_set(op->ptr, "use_proportional_connected", prop_edit_flag & PROP_EDIT_CONNECTED);
1522  RNA_boolean_set(op->ptr, "use_proportional_projected", prop_edit_flag & PROP_EDIT_PROJECTED);
1523  RNA_enum_set(op->ptr, "proportional_edit_falloff", t->prop_mode);
1524  RNA_float_set(op->ptr, "proportional_size", t->prop_size);
1525  }
1526 
1527  if ((prop = RNA_struct_find_property(op->ptr, "mirror"))) {
1528  RNA_property_boolean_set(op->ptr, prop, (t->flag & T_NO_MIRROR) == 0);
1529  }
1530 
1531  if ((prop = RNA_struct_find_property(op->ptr, "orient_axis"))) {
1532  if (t->flag & T_MODAL) {
1533  if (t->con.mode & CON_APPLY) {
1534  int orient_axis = constraintModeToIndex(t);
1535  if (orient_axis != -1) {
1536  RNA_property_enum_set(op->ptr, prop, orient_axis);
1537  }
1538  }
1539  else {
1540  RNA_property_enum_set(op->ptr, prop, t->orient_axis);
1541  }
1542  }
1543  }
1544  if ((prop = RNA_struct_find_property(op->ptr, "orient_axis_ortho"))) {
1545  if (t->flag & T_MODAL) {
1546  RNA_property_enum_set(op->ptr, prop, t->orient_axis_ortho);
1547  }
1548  }
1549 
1550  if ((prop = RNA_struct_find_property(op->ptr, "orient_type"))) {
1551  short orient_type_set, orient_type_curr;
1552  orient_type_set = RNA_property_is_set(op->ptr, prop) ? RNA_property_enum_get(op->ptr, prop) :
1553  -1;
1554  orient_type_curr = t->orient[t->orient_curr].type;
1555 
1556  if (!ELEM(orient_type_curr, orient_type_set, V3D_ORIENT_CUSTOM_MATRIX)) {
1557  RNA_property_enum_set(op->ptr, prop, orient_type_curr);
1558  orient_type_set = orient_type_curr;
1559  }
1560 
1561  if (((prop = RNA_struct_find_property(op->ptr, "orient_matrix_type")) &&
1562  !RNA_property_is_set(op->ptr, prop))) {
1563  /* Set the first time to register on redo. */
1564  RNA_property_enum_set(op->ptr, prop, orient_type_set);
1565  RNA_float_set_array(op->ptr, "orient_matrix", &t->spacemtx[0][0]);
1566  }
1567  }
1568 
1569  if ((prop = RNA_struct_find_property(op->ptr, "constraint_axis"))) {
1570  bool constraint_axis[3] = {false, false, false};
1571  if (t->con.mode & CON_APPLY) {
1572  if (t->con.mode & CON_AXIS0) {
1573  constraint_axis[0] = true;
1574  }
1575  if (t->con.mode & CON_AXIS1) {
1576  constraint_axis[1] = true;
1577  }
1578  if (t->con.mode & CON_AXIS2) {
1579  constraint_axis[2] = true;
1580  }
1581  RNA_property_boolean_set_array(op->ptr, prop, constraint_axis);
1582  }
1583  else {
1584  RNA_property_unset(op->ptr, prop);
1585  }
1586  }
1587 
1588  {
1589  const char *prop_id = NULL;
1590  bool prop_state = true;
1591  if (t->mode == TFM_SHRINKFATTEN) {
1592  prop_id = "use_even_offset";
1593  prop_state = false;
1594  }
1595 
1596  if (prop_id && (prop = RNA_struct_find_property(op->ptr, prop_id))) {
1597  RNA_property_boolean_set(op->ptr, prop, ((t->flag & T_ALT_TRANSFORM) == 0) == prop_state);
1598  }
1599  }
1600 
1601  if ((prop = RNA_struct_find_property(op->ptr, "correct_uv"))) {
1603  op->ptr, prop, (t->settings->uvcalc_flag & UVCALC_TRANSFORM_CORRECT_SLIDE) != 0);
1604  }
1605 }
1606 
1607 static void initSnapSpatial(TransInfo *t, float r_snap[2])
1608 {
1609  if (t->spacetype == SPACE_VIEW3D) {
1610  if (t->region->regiondata) {
1611  View3D *v3d = t->area->spacedata.first;
1612  r_snap[0] = ED_view3d_grid_view_scale(t->scene, v3d, t->region, NULL) * 1.0f;
1613  r_snap[1] = r_snap[0] * 0.1f;
1614  }
1615  }
1616  else if (t->spacetype == SPACE_IMAGE) {
1617  r_snap[0] = 0.0625f;
1618  r_snap[1] = 0.03125f;
1619  }
1620  else if (t->spacetype == SPACE_CLIP) {
1621  r_snap[0] = 0.125f;
1622  r_snap[1] = 0.0625f;
1623  }
1624  else if (t->spacetype == SPACE_NODE) {
1625  r_snap[0] = r_snap[1] = ED_node_grid_size();
1626  }
1627  else if (t->spacetype == SPACE_GRAPH) {
1628  r_snap[0] = 1.0;
1629  r_snap[1] = 0.1f;
1630  }
1631  else {
1632  r_snap[0] = r_snap[1] = 1.0f;
1633  }
1634 }
1635 
1641 bool initTransform(bContext *C, TransInfo *t, wmOperator *op, const wmEvent *event, int mode)
1642 {
1643  int options = 0;
1644  PropertyRNA *prop;
1645 
1646  mode = transform_mode_really_used(C, mode);
1647 
1648  t->context = C;
1649 
1650  /* added initialize, for external calls to set stuff in TransInfo, like undo string */
1651 
1652  t->state = TRANS_STARTING;
1653 
1654  if ((prop = RNA_struct_find_property(op->ptr, "cursor_transform")) &&
1655  RNA_property_is_set(op->ptr, prop)) {
1656  if (RNA_property_boolean_get(op->ptr, prop)) {
1657  options |= CTX_CURSOR;
1658  }
1659  }
1660 
1661  if ((prop = RNA_struct_find_property(op->ptr, "texture_space")) &&
1662  RNA_property_is_set(op->ptr, prop)) {
1663  if (RNA_property_boolean_get(op->ptr, prop)) {
1665  }
1666  }
1667 
1668  if ((prop = RNA_struct_find_property(op->ptr, "gpencil_strokes")) &&
1669  RNA_property_is_set(op->ptr, prop)) {
1670  if (RNA_property_boolean_get(op->ptr, prop)) {
1672  }
1673  }
1674 
1675  t->options = options;
1676 
1677  t->mode = mode;
1678 
1679  /* Needed to translate tweak events to mouse buttons. */
1680  t->launch_event = event ? WM_userdef_event_type_from_keymap_type(event->type) : -1;
1681  t->is_launch_event_tweak = event ? ISTWEAK(event->type) : false;
1682 
1683  /* XXX Remove this when wm_operator_call_internal doesn't use window->eventstate
1684  * (which can have type = 0) */
1685  /* For gizmo only, so assume LEFTMOUSE. */
1686  if (t->launch_event == 0) {
1687  t->launch_event = LEFTMOUSE;
1688  }
1689 
1690  unit_m3(t->spacemtx);
1691 
1692  initTransInfo(C, t, op, event);
1693 
1694  if (t->spacetype == SPACE_VIEW3D) {
1695  t->draw_handle_apply = ED_region_draw_cb_activate(
1696  t->region->type, drawTransformApply, t, REGION_DRAW_PRE_VIEW);
1697  t->draw_handle_view = ED_region_draw_cb_activate(
1698  t->region->type, drawTransformView, t, REGION_DRAW_POST_VIEW);
1699  t->draw_handle_pixel = ED_region_draw_cb_activate(
1700  t->region->type, drawTransformPixel, t, REGION_DRAW_POST_PIXEL);
1701  t->draw_handle_cursor = WM_paint_cursor_activate(
1703  }
1704  else if (t->spacetype == SPACE_IMAGE) {
1705  t->draw_handle_view = ED_region_draw_cb_activate(
1706  t->region->type, drawTransformView, t, REGION_DRAW_POST_VIEW);
1707  t->draw_handle_cursor = WM_paint_cursor_activate(
1709  }
1710  else if (t->spacetype == SPACE_CLIP) {
1711  t->draw_handle_view = ED_region_draw_cb_activate(
1712  t->region->type, drawTransformView, t, REGION_DRAW_POST_VIEW);
1713  t->draw_handle_cursor = WM_paint_cursor_activate(
1715  }
1716  else if (t->spacetype == SPACE_NODE) {
1717  t->draw_handle_view = ED_region_draw_cb_activate(
1718  t->region->type, drawTransformView, t, REGION_DRAW_POST_VIEW);
1719  t->draw_handle_cursor = WM_paint_cursor_activate(
1721  }
1722  else if (t->spacetype == SPACE_GRAPH) {
1723  t->draw_handle_view = ED_region_draw_cb_activate(
1724  t->region->type, drawTransformView, t, REGION_DRAW_POST_VIEW);
1725  t->draw_handle_cursor = WM_paint_cursor_activate(
1727  }
1728  else if (t->spacetype == SPACE_ACTION) {
1729  t->draw_handle_view = ED_region_draw_cb_activate(
1730  t->region->type, drawTransformView, t, REGION_DRAW_POST_VIEW);
1731  t->draw_handle_cursor = WM_paint_cursor_activate(
1733  }
1734 
1735  createTransData(C, t); /* Make #TransData structs from selection. */
1736 
1737  if (t->data_len_all == 0) {
1738  postTrans(C, t);
1739  return 0;
1740  }
1741 
1742  /* When proportional editing is enabled, data_len_all can be non zero when
1743  * nothing is selected, if this is the case we can end the transform early.
1744  *
1745  * By definition transform-data has selected items in beginning,
1746  * so only the first item in each container needs to be checked
1747  * when looking for the presence of selected data. */
1748  if (t->flag & T_PROP_EDIT) {
1749  bool has_selected_any = false;
1751  if (tc->data->flag & TD_SELECTED) {
1752  has_selected_any = true;
1753  break;
1754  }
1755  }
1756 
1757  if (!has_selected_any) {
1758  postTrans(C, t);
1759  return 0;
1760  }
1761  }
1762 
1763  if (event) {
1764  /* keymap for shortcut header prints */
1765  t->keymap = WM_keymap_active(CTX_wm_manager(C), op->type->modalkeymap);
1766 
1767  /* Stupid code to have Ctrl-Click on gizmo work ok.
1768  *
1769  * Do this only for translation/rotation/resize because only these
1770  * modes are available from gizmo and doing such check could
1771  * lead to keymap conflicts for other modes (see T31584)
1772  */
1774  wmKeyMapItem *kmi;
1775 
1776  for (kmi = t->keymap->items.first; kmi; kmi = kmi->next) {
1777  if (kmi->flag & KMI_INACTIVE) {
1778  continue;
1779  }
1780 
1781  if (kmi->propvalue == TFM_MODAL_SNAP_INV_ON && kmi->val == KM_PRESS) {
1782  if ((ELEM(kmi->type, EVT_LEFTCTRLKEY, EVT_RIGHTCTRLKEY) && event->ctrl) ||
1783  (ELEM(kmi->type, EVT_LEFTSHIFTKEY, EVT_RIGHTSHIFTKEY) && event->shift) ||
1784  (ELEM(kmi->type, EVT_LEFTALTKEY, EVT_RIGHTALTKEY) && event->alt) ||
1785  ((kmi->type == EVT_OSKEY) && event->oskey)) {
1786  t->modifiers |= MOD_SNAP_INVERT;
1787  }
1788  break;
1789  }
1790  }
1791  }
1792  }
1793 
1794  initSnapping(t, op); /* Initialize snapping data AFTER mode flags */
1795 
1796  initSnapSpatial(t, t->snap_spatial);
1797 
1798  /* EVIL! posemode code can switch translation to rotate when 1 bone is selected.
1799  * will be removed (ton) */
1800 
1801  /* EVIL2: we gave as argument also texture space context bit... was cleared */
1802 
1803  /* EVIL3: extend mode for animation editors also switches modes...
1804  * but is best way to avoid duplicate code */
1805  mode = t->mode;
1806 
1808  calculateCenter(t);
1809 
1810  if (event) {
1811  /* Initialize accurate transform to settings requested by keymap. */
1812  bool use_accurate = false;
1813  if ((prop = RNA_struct_find_property(op->ptr, "use_accurate")) &&
1814  RNA_property_is_set(op->ptr, prop)) {
1815  if (RNA_property_boolean_get(op->ptr, prop)) {
1816  use_accurate = true;
1817  }
1818  }
1819  initMouseInput(t, &t->mouse, t->center2d, event->mval, use_accurate);
1820  }
1821 
1822  transform_mode_init(t, op, mode);
1823 
1824  if (t->state == TRANS_CANCEL) {
1825  postTrans(C, t);
1826  return 0;
1827  }
1828 
1829  /* Transformation axis from operator */
1830  if ((prop = RNA_struct_find_property(op->ptr, "orient_axis")) &&
1831  RNA_property_is_set(op->ptr, prop)) {
1832  t->orient_axis = RNA_property_enum_get(op->ptr, prop);
1833  }
1834  if ((prop = RNA_struct_find_property(op->ptr, "orient_axis_ortho")) &&
1835  RNA_property_is_set(op->ptr, prop)) {
1836  t->orient_axis_ortho = RNA_property_enum_get(op->ptr, prop);
1837  }
1838 
1839  /* Constraint init from operator */
1840  if (t->con.mode & CON_APPLY) {
1841  setUserConstraint(t, t->con.mode, "%s");
1842  }
1843 
1844  /* Don't write into the values when non-modal because they are already set from operator redo
1845  * values. */
1846  if (t->flag & T_MODAL) {
1847  /* Setup the mouse input with initial values. */
1848  applyMouseInput(t, &t->mouse, t->mouse.imval, t->values);
1849  }
1850 
1851  if ((prop = RNA_struct_find_property(op->ptr, "preserve_clnor"))) {
1852  if ((t->flag & T_EDIT) && t->obedit_type == OB_MESH) {
1853 
1855  if ((((Mesh *)(tc->obedit->data))->flag & ME_AUTOSMOOTH)) {
1856  BMEditMesh *em = NULL; /* BKE_editmesh_from_object(t->obedit); */
1857  bool do_skip = false;
1858 
1859  /* Currently only used for two of three most frequent transform ops,
1860  * can include more ops.
1861  * Note that scaling cannot be included here,
1862  * non-uniform scaling will affect normals. */
1863  if (ELEM(t->mode, TFM_TRANSLATION, TFM_ROTATION)) {
1864  if (em->bm->totvertsel == em->bm->totvert) {
1865  /* No need to invalidate if whole mesh is selected. */
1866  do_skip = true;
1867  }
1868  }
1869 
1870  if (t->flag & T_MODAL) {
1871  RNA_property_boolean_set(op->ptr, prop, false);
1872  }
1873  else if (!do_skip) {
1874  const bool preserve_clnor = RNA_property_boolean_get(op->ptr, prop);
1875  if (preserve_clnor) {
1876  BKE_editmesh_lnorspace_update(em, tc->obedit->data);
1877  t->flag |= T_CLNOR_REBUILD;
1878  }
1879  BM_lnorspace_invalidate(em->bm, true);
1880  }
1881  }
1882  }
1883  }
1884  }
1885 
1886  t->context = NULL;
1887 
1888  return 1;
1889 }
1890 
1892 {
1893  t->context = C;
1894 
1895  if ((t->redraw & TREDRAW_HARD) || (t->draw_handle_apply == NULL && (t->redraw & TREDRAW_SOFT))) {
1897  if (t->transform) {
1898  t->transform(t, t->mval); /* calls recalcData() */
1899  viewRedrawForce(C, t);
1900  }
1901  t->redraw = TREDRAW_NOTHING;
1902  }
1903  else if (t->redraw & TREDRAW_SOFT) {
1904  viewRedrawForce(C, t);
1905  }
1906 
1907  /* If auto confirm is on, break after one pass */
1908  if (t->options & CTX_AUTOCONFIRM) {
1909  t->state = TRANS_CONFIRM;
1910  }
1911 
1912  t->context = NULL;
1913 }
1914 
1915 static void drawTransformApply(const bContext *C, ARegion *UNUSED(region), void *arg)
1916 {
1917  TransInfo *t = arg;
1918 
1919  if (t->redraw & TREDRAW_SOFT) {
1920  t->redraw |= TREDRAW_HARD;
1921  transformApply((bContext *)C, t);
1922  }
1923 }
1924 
1926 {
1927  int exit_code = OPERATOR_RUNNING_MODAL;
1928 
1929  t->context = C;
1930 
1931  if (!ELEM(t->state, TRANS_STARTING, TRANS_RUNNING)) {
1932  /* handle restoring objects */
1933  if (t->state == TRANS_CANCEL) {
1934  exit_code = OPERATOR_CANCELLED;
1935  restoreTransObjects(t); /* calls recalcData() */
1936  }
1937  else {
1938  if (t->flag & T_CLNOR_REBUILD) {
1940  BMEditMesh *em = BKE_editmesh_from_object(tc->obedit);
1941  BM_lnorspace_rebuild(em->bm, true);
1942  }
1943  }
1944  exit_code = OPERATOR_FINISHED;
1945  }
1946 
1947  /* aftertrans does insert keyframes, and clears base flags; doesn't read transdata */
1949 
1950  /* Free data, also handles overlap [in freeTransCustomData()]. */
1951  postTrans(C, t);
1952 
1953  /* send events out for redraws */
1954  viewRedrawPost(C, t);
1955 
1956  viewRedrawForce(C, t);
1957  }
1958 
1959  t->context = NULL;
1960 
1961  return exit_code;
1962 }
1963 
1964 /* TODO, move to: transform_query.c */
1966 {
1967  /* currently only checks for editmode */
1968  if (t->flag & T_EDIT) {
1969  if ((t->around == V3D_AROUND_LOCAL_ORIGINS) &&
1970  (ELEM(t->obedit_type, OB_MESH, OB_CURVE, OB_MBALL, OB_ARMATURE))) {
1971  /* not all editmode supports axis-matrix */
1972  return true;
1973  }
1974  }
1975 
1976  return false;
1977 }
typedef float(TangentPoint)[2]
struct ScrArea * CTX_wm_area(const bContext *C)
Definition: context.c:714
struct Scene * CTX_data_scene(const bContext *C)
Definition: context.c:1034
struct wmWindowManager * CTX_wm_manager(const bContext *C)
Definition: context.c:689
struct Mask * CTX_data_edit_mask(const bContext *C)
Definition: context.c:1316
struct ToolSettings * CTX_data_tool_settings(const bContext *C)
Definition: context.c:1208
struct wmWindow * CTX_wm_window(const bContext *C)
Definition: context.c:699
void BKE_editmesh_lnorspace_update(BMEditMesh *em, struct Mesh *me)
Definition: editmesh.c:264
BMEditMesh * BKE_editmesh_from_object(struct Object *ob)
Return the BMEditMesh for a given object.
Definition: editmesh.c:85
void BKE_mask_coord_to_image(struct Image *image, struct ImageUser *iuser, float r_co[2], const float co[2])
Definition: mask.c:1283
void BKE_mask_coord_to_movieclip(struct MovieClip *clip, struct MovieClipUser *user, float r_co[2], const float co[2])
Definition: mask.c:1266
void BLF_draw_default(float x, float y, float z, const char *str, size_t len) ATTR_NONNULL()
Definition: blf_default.c:71
void BLF_color3ubv(int fontid, const unsigned char rgb[3])
Definition: blf.c:411
int BLF_default(void)
Definition: blf_default.c:55
void BLF_width_and_height(int fontid, const char *str, size_t len, float *r_width, float *r_height) ATTR_NONNULL()
Definition: blf.c:698
#define BLF_DRAW_STR_DUMMY_MAX
Definition: BLF_api.h:283
void BLF_draw_default_ascii(float x, float y, float z, const char *str, size_t len) ATTR_NONNULL()
Definition: blf_default.c:82
#define BLI_assert(a)
Definition: BLI_assert.h:58
MINLINE float max_ff(float a, float b)
MINLINE float min_ff(float a, float b)
void unit_m3(float m[3][3])
Definition: math_matrix.c:58
void unit_m4(float m[4][4])
Definition: rct.c:1140
void copy_m4_m4(float m1[4][4], const float m2[4][4])
Definition: math_matrix.c:95
MINLINE void copy_v2_v2(float r[2], const float a[2])
MINLINE void copy_v2_v2_int(int r[2], const int a[2])
MINLINE void copy_v3_v3(float r[3], const float a[3])
MINLINE void copy_v3_fl(float r[3], float f)
MINLINE void zero_v3(float r[3])
BLI_INLINE int BLI_rcti_size_y(const struct rcti *rct)
Definition: BLI_rect.h:157
BLI_INLINE int BLI_rcti_size_x(const struct rcti *rct)
Definition: BLI_rect.h:153
BLI_INLINE float BLI_rctf_size_x(const struct rctf *rct)
Definition: BLI_rect.h:161
BLI_INLINE float BLI_rctf_size_y(const struct rctf *rct)
Definition: BLI_rect.h:165
unsigned char uchar
Definition: BLI_sys_types.h:86
#define ARRAY_SIZE(arr)
#define UNUSED(x)
#define ELEM(...)
#define TIP_(msgid)
#define IFACE_(msgid)
void DEG_id_tag_update(struct ID *id, int flag)
@ ID_RECALC_GEOMETRY
Definition: DNA_ID.h:611
@ SACTION_DRAWTIME
@ ME_AUTOSMOOTH
@ OB_MODE_OBJECT
@ OB_MBALL
@ OB_ARMATURE
@ OB_MESH
@ OB_CURVE
@ OB_GPENCIL
#define OBEDIT_FROM_VIEW_LAYER(view_layer)
#define SCE_SNAP
#define UVCALC_TRANSFORM_CORRECT_SLIDE
#define OBACT(_view_layer)
@ PROP_EDIT_PROJECTED
@ PROP_EDIT_USE
@ PROP_EDIT_CONNECTED
#define UVCALC_TRANSFORM_CORRECT
#define PROP_MODE_MAX
#define SCE_SNAP_MODE_GRID
#define SCE_SNAP_MODE_INCREMENT
#define RGN_TYPE_ANY
@ RGN_TYPE_WINDOW
@ SI_COORDFLOATS
@ SPACE_CLIP
@ SPACE_ACTION
@ SPACE_NODE
@ SPACE_NLA
@ SPACE_SEQ
@ SPACE_IMAGE
@ SPACE_GRAPH
@ SPACE_VIEW3D
@ SNODE_INSERTOFS_DIR_RIGHT
@ SNODE_INSERTOFS_DIR_LEFT
#define SPACE_TYPE_ANY
@ AUTOKEY_FLAG_NOWARNING
@ V3D_ORIENT_NORMAL
@ V3D_ORIENT_CUSTOM_MATRIX
@ V3D_AROUND_CENTER_BOUNDS
@ V3D_AROUND_LOCAL_ORIGINS
#define V3D_HIDE_OVERLAYS
#define RV3D_ORTHO
@ OPERATOR_CANCELLED
@ OPERATOR_FINISHED
@ OPERATOR_RUNNING_MODAL
@ OPERATOR_PASS_THROUGH
void ED_clip_point_stable_pos__reverse(struct SpaceClip *sc, struct ARegion *region, const float co[2], float r_co[2])
the reverse of ED_clip_point_stable_pos(), gets the marker region coords. better name here?...
Definition: clip_editor.c:518
void ED_space_clip_get_aspect(struct SpaceClip *sc, float *aspx, float *aspy)
Definition: clip_editor.c:171
bool ED_space_clip_check_show_trackedit(struct SpaceClip *sc)
Definition: clip_editor.c:548
void ED_space_clip_get_aspect_dimension_aware(struct SpaceClip *sc, float *aspx, float *aspy)
Definition: clip_editor.c:192
bool ED_space_clip_check_show_maskedit(struct SpaceClip *sc)
Definition: clip_editor.c:557
struct MovieClip * ED_space_clip_get_clip(struct SpaceClip *sc)
Definition: clip_editor.c:572
void ED_space_image_get_uv_aspect(struct SpaceImage *sima, float *r_aspx, float *r_aspy)
Definition: image_edit.c:282
void ED_image_point_pos__reverse(struct SpaceImage *sima, const struct ARegion *region, const float co[2], float r_co[2])
void ED_space_image_get_size(struct SpaceImage *sima, int *r_width, int *r_height)
Definition: image_edit.c:215
void ED_space_image_get_aspect(struct SpaceImage *sima, float *r_aspx, float *r_aspy)
Definition: image_edit.c:256
#define IS_AUTOKEY_ON(scene)
float ED_node_grid_size(void)
Definition: node_draw.cc:96
#define NUM_MODAL_INCREMENT_DOWN
Definition: ED_numinput.h:104
#define NUM_MODAL_INCREMENT_UP
Definition: ED_numinput.h:103
bool hasNumInput(const NumInput *n)
Definition: numinput.c:185
bool handleNumInput(struct bContext *C, NumInput *n, const struct wmEvent *event)
void ED_area_tag_redraw(ScrArea *area)
Definition: area.c:745
void ED_area_status_text(ScrArea *area, const char *str)
Definition: area.c:815
const rcti * ED_region_visible_rect(ARegion *region)
Definition: area.c:3682
#define REGION_DRAW_POST_VIEW
Definition: ED_space_api.h:66
void * ED_region_draw_cb_activate(struct ARegionType *art, void(*draw)(const struct bContext *, struct ARegion *, void *), void *customdata, int type)
Definition: spacetypes.c:238
#define REGION_DRAW_POST_PIXEL
Definition: ED_space_api.h:67
#define REGION_DRAW_PRE_VIEW
Definition: ED_space_api.h:68
@ TFM_RESIZE
Definition: ED_transform.h:48
@ TFM_EDGE_SLIDE
Definition: ED_transform.h:74
@ TFM_SHRINKFATTEN
Definition: ED_transform.h:53
@ TFM_VERT_SLIDE
Definition: ED_transform.h:75
@ TFM_ROTATION
Definition: ED_transform.h:47
@ TFM_TRANSLATION
Definition: ED_transform.h:46
@ TFM_NORMAL_ROTATION
Definition: ED_transform.h:78
@ TFM_DUMMY
Definition: ED_transform.h:45
@ TFM_TRACKBALL
Definition: ED_transform.h:55
eV3DProjStatus ED_view3d_project_int_global(const struct ARegion *region, const float co[3], int r_co[2], const eV3DProjTest flag)
eV3DProjTest
Definition: ED_view3d.h:192
@ V3D_PROJ_TEST_NOP
Definition: ED_view3d.h:193
@ V3D_PROJ_RET_OK
Definition: ED_view3d.h:176
void ED_view3d_win_to_delta(const struct ARegion *region, const float mval[2], float out[3], const float zfac)
float ED_view3d_grid_view_scale(struct Scene *scene, struct View3D *v3d, struct ARegion *region, const char **r_grid_unit)
Definition: view3d_draw.c:917
eV3DProjStatus ED_view3d_project_float_global(const struct ARegion *region, const float co[3], float r_co[2], const eV3DProjTest flag)
_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 width
_GL_VOID GLfloat value _GL_VOID_RET _GL_VOID const GLuint GLboolean *residences _GL_BOOL_RET _GL_VOID GLsizei height
_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
@ GPU_BLEND_NONE
Definition: GPU_state.h:55
@ 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
Read Guarded memory(de)allocation.
#define C
Definition: RandGen.cpp:39
void UI_icon_draw(float x, float y, int icon_id)
@ TH_TEXT_HI
Definition: UI_resources.h:59
void UI_GetThemeColorShade3ubv(int colorid, int offset, unsigned char col[3])
Definition: resources.c:1235
void UI_view2d_view_to_region(const struct View2D *v2d, float x, float y, int *r_region_x, int *r_region_y) ATTR_NONNULL()
#define ND_SEQUENCER
Definition: WM_types.h:337
#define ND_TRANSFORM_DONE
Definition: WM_types.h:352
#define NC_GEOM
Definition: WM_types.h:294
#define ND_DATA
Definition: WM_types.h:408
#define NC_ANIMATION
Definition: WM_types.h:289
#define NC_MOVIECLIP
Definition: WM_types.h:298
#define NC_SCENE
Definition: WM_types.h:279
#define ND_SPACE_NODE_VIEW
Definition: WM_types.h:431
#define ND_POSE
Definition: WM_types.h:359
#define NA_EDITED
Definition: WM_types.h:462
#define KM_PRESS
Definition: WM_types.h:242
#define NC_GPENCIL
Definition: WM_types.h:300
#define ND_NLA
Definition: WM_types.h:397
#define ND_TRANSFORM
Definition: WM_types.h:357
#define NC_MASK
Definition: WM_types.h:299
#define ND_KEYS
Definition: WM_types.h:364
#define ND_KEYFRAME
Definition: WM_types.h:394
#define NC_OBJECT
Definition: WM_types.h:280
#define NC_SPACE
Definition: WM_types.h:293
#define KM_RELEASE
Definition: WM_types.h:243
void BM_lnorspace_invalidate(BMesh *bm, const bool do_invalidate_all)
Definition: bmesh_mesh.c:1418
void BM_lnorspace_rebuild(BMesh *bm, bool preserve_clnor)
Definition: bmesh_mesh.c:1486
ATTR_WARN_UNUSED_RESULT const BMVert * v
unsigned int U
Definition: btGjkEpa3.h:78
CCL_NAMESPACE_BEGIN struct Options options
Scene scene
bGPdata * ED_gpencil_data_get_active(const bContext *C)
bool autokeyframe_cfra_can_key(const Scene *scene, ID *id)
Definition: keyframing.c:2779
void(* MEM_freeN)(void *vmemh)
Definition: mallocn.c:41
void *(* MEM_callocN)(size_t len, const char *str)
Definition: mallocn.c:45
static unsigned a[3]
Definition: RandGen.cpp:92
static void area(int d1, int d2, int e1, int e2, float weights[2])
float RNA_property_float_get(PointerRNA *ptr, PropertyRNA *prop)
Definition: rna_access.c:2941
bool RNA_property_array_check(PropertyRNA *prop)
Definition: rna_access.c:1223
void RNA_boolean_set(PointerRNA *ptr, const char *name, bool value)
Definition: rna_access.c:6272
bool RNA_property_is_set(PointerRNA *ptr, PropertyRNA *prop)
Definition: rna_access.c:6655
void RNA_property_enum_set(PointerRNA *ptr, PropertyRNA *prop, int value)
Definition: rna_access.c:3562
PropertyRNA * RNA_struct_find_property(PointerRNA *ptr, const char *identifier)
Definition: rna_access.c:866
bool RNA_property_boolean_get(PointerRNA *ptr, PropertyRNA *prop)
Definition: rna_access.c:2331
void RNA_property_boolean_set(PointerRNA *ptr, PropertyRNA *prop, bool value)
Definition: rna_access.c:2358
void RNA_float_set(PointerRNA *ptr, const char *name, float value)
Definition: rna_access.c:6366
void RNA_property_float_set_array(PointerRNA *ptr, PropertyRNA *prop, const float *values)
Definition: rna_access.c:3132
int RNA_property_enum_get(PointerRNA *ptr, PropertyRNA *prop)
Definition: rna_access.c:3543
void RNA_property_float_set(PointerRNA *ptr, PropertyRNA *prop, float value)
Definition: rna_access.c:2964
void RNA_enum_set(PointerRNA *ptr, const char *name, int value)
Definition: rna_access.c:6413
void RNA_float_set_array(PointerRNA *ptr, const char *name, const float *values)
Definition: rna_access.c:6390
void RNA_property_unset(PointerRNA *ptr, PropertyRNA *prop)
Definition: rna_access.c:6665
void RNA_property_boolean_set_array(PointerRNA *ptr, PropertyRNA *prop, const bool *values)
Definition: rna_access.c:2482
struct BMesh * bm
Definition: BKE_editmesh.h:52
int totvert
Definition: bmesh_class.h:297
int totvertsel
Definition: bmesh_class.h:298
float persmat[4][4]
float persinv[4][4]
float viewmat[4][4]
float viewinv[4][4]
struct MovieClipUser user
struct MovieClip * clip
struct ImageUser iuser
struct Image * image
int ymax
Definition: DNA_vec_types.h:80
int xmax
Definition: DNA_vec_types.h:79
short shift
Definition: WM_types.h:618
short ctrl
Definition: WM_types.h:618
short val
Definition: WM_types.h:579
short oskey
Definition: WM_types.h:618
int mval[2]
Definition: WM_types.h:583
short prevtype
Definition: WM_types.h:602
short prevval
Definition: WM_types.h:604
short alt
Definition: WM_types.h:618
short type
Definition: WM_types.h:577
char is_repeat
Definition: WM_types.h:599
struct wmKeyMapItem * next
bool(* poll_modal_item)(const struct wmOperator *op, int value)
struct wmKeyMap * modalkeymap
Definition: WM_types.h:820
struct wmOperatorType * type
struct PointerRNA * ptr
wmKeyMap * transform_modal_keymap(wmKeyConfig *keyconf)
Definition: transform.c:657
void projectFloatViewEx(TransInfo *t, const float vec[3], float adr[2], const eV3DProjTest flag)
Definition: transform.c:348
bool checkUseAxisMatrix(TransInfo *t)
Definition: transform.c:1965
static bool transform_modal_item_poll(const wmOperator *op, int value)
Definition: transform.c:570
void transformApply(bContext *C, TransInfo *t)
Definition: transform.c:1891
static void convertViewVec2D(View2D *v2d, float r_vec[3], int dx, int dy)
Definition: transform.c:145
static void drawTransformApply(const struct bContext *C, ARegion *region, void *arg)
static void drawTransformView(const struct bContext *C, ARegion *region, void *arg)
Definition: transform.c:1329
void setTransformViewAspect(TransInfo *t, float r_aspect[3])
Definition: transform.c:113
static void drawTransformPixel(const struct bContext *C, ARegion *region, void *arg)
Definition: transform.c:1393
bool transdata_check_local_islands(TransInfo *t, short around)
Definition: transform.c:79
void saveTransform(bContext *C, TransInfo *t, wmOperator *op)
Definition: transform.c:1426
static bool transform_event_modal_constraint(TransInfo *t, short modal_type)
Definition: transform.c:728
bool initTransform(bContext *C, TransInfo *t, wmOperator *op, const wmEvent *event, int mode)
Definition: transform.c:1641
void projectIntViewEx(TransInfo *t, const float vec[3], int adr[2], const eV3DProjTest flag)
Definition: transform.c:230
void convertViewVec(TransInfo *t, float r_vec[3], double dx, double dy)
Definition: transform.c:180
int transformEvent(TransInfo *t, const wmEvent *event)
Definition: transform.c:818
void removeAspectRatio(TransInfo *t, float vec[2])
Definition: transform.c:406
static void initSnapSpatial(TransInfo *t, float r_snap[3])
static void viewRedrawPost(bContext *C, TransInfo *t)
Definition: transform.c:523
static void viewRedrawForce(const bContext *C, TransInfo *t)
Definition: transform.c:430
void setTransformViewMatrices(TransInfo *t)
Definition: transform.c:89
bool calculateTransformCenter(bContext *C, int centerMode, float cent3d[3], float cent2d[2])
Definition: transform.c:1259
static void drawAutoKeyWarning(TransInfo *UNUSED(t), ARegion *region)
Definition: transform.c:1355
void projectFloatView(TransInfo *t, const float vec[3], float adr[2])
Definition: transform.c:376
static void convertViewVec2D_mask(View2D *v2d, float r_vec[3], int dx, int dy)
Definition: transform.c:155
void projectIntView(TransInfo *t, const float vec[3], int adr[2])
Definition: transform.c:343
void applyAspectRatio(TransInfo *t, float vec[2])
Definition: transform.c:381
static bool transinfo_show_overlay(const struct bContext *C, TransInfo *t, ARegion *region)
Definition: transform.c:1310
int transformEnd(bContext *C, TransInfo *t)
Definition: transform.c:1925
void calculateCenter(TransInfo *t)
@ CON_APPLY
Definition: transform.h:177
@ CON_SELECT
Definition: transform.h:182
@ CON_AXIS1
Definition: transform.h:180
@ CON_AXIS0
Definition: transform.h:179
@ CON_AXIS2
Definition: transform.h:181
@ CTX_MOVIECLIP
Definition: transform.h:84
@ CTX_PAINT_CURVE
Definition: transform.h:86
@ CTX_AUTOCONFIRM
Definition: transform.h:92
@ CTX_CURSOR
Definition: transform.h:80
@ CTX_POSE_BONE
Definition: transform.h:87
@ CTX_OBJECT
Definition: transform.h:85
@ CTX_GPENCIL_STROKES
Definition: transform.h:82
@ CTX_MASK
Definition: transform.h:83
@ CTX_TEXTURE_SPACE
Definition: transform.h:88
@ CTX_NO_PET
Definition: transform.h:90
@ CTX_CAMERA
Definition: transform.h:79
@ MOD_SNAP_INVERT
Definition: transform.h:160
@ MOD_CONSTRAINT_SELECT_AXIS
Definition: transform.h:157
@ MOD_PRECISION
Definition: transform.h:158
@ MOD_CONSTRAINT_SELECT_PLANE
Definition: transform.h:161
@ MOD_SNAP
Definition: transform.h:159
void resetTransRestrictions(TransInfo *t)
void postTrans(struct bContext *C, TransInfo *t)
void calculateCenter2D(TransInfo *t)
@ TREDRAW_NOTHING
Definition: transform.h:198
@ TREDRAW_SOFT
Definition: transform.h:200
@ TREDRAW_HARD
Definition: transform.h:199
void applyMouseInput(struct TransInfo *t, struct MouseInput *mi, const int mval[2], float output[3])
@ T_PROP_EDIT_ALL
Definition: transform.h:114
@ T_RELEASE_CONFIRM
Definition: transform.h:137
@ T_CLNOR_REBUILD
Definition: transform.h:147
@ T_MODAL
Definition: transform.h:132
@ T_AUTOIK
Definition: transform.h:122
@ T_PROP_CONNECTED
Definition: transform.h:112
@ T_ALT_TRANSFORM
Definition: transform.h:140
@ T_NO_MIRROR
Definition: transform.h:125
@ T_PROP_EDIT
Definition: transform.h:111
@ T_2D_EDIT
Definition: transform.h:118
@ T_NO_CONSTRAINT
Definition: transform.h:106
@ T_EDIT
Definition: transform.h:102
@ T_PROP_PROJECTED
Definition: transform.h:113
void resetTransModal(TransInfo *t)
void restoreTransObjects(TransInfo *t)
@ TRANS_CONFIRM
Definition: transform.h:192
@ TRANS_STARTING
Definition: transform.h:190
@ TRANS_RUNNING
Definition: transform.h:191
@ TRANS_CANCEL
Definition: transform.h:193
void drawDial3d(const TransInfo *t)
@ TFM_MODAL_AUTOIK_LEN_INC
Definition: transform.h:275
@ TFM_MODAL_PROPSIZE
Definition: transform.h:282
@ TFM_MODAL_AXIS_Y
Definition: transform.h:260
@ TFM_MODAL_RESIZE
Definition: transform.h:255
@ TFM_MODAL_AUTOCONSTRAINT
Definition: transform.h:286
@ TFM_MODAL_CONFIRM
Definition: transform.h:252
@ TFM_MODAL_EDGESLIDE_UP
Definition: transform.h:278
@ TFM_MODAL_ADD_SNAP
Definition: transform.h:266
@ TFM_MODAL_SNAP_TOGGLE
Definition: transform.h:258
@ TFM_MODAL_PLANE_X
Definition: transform.h:262
@ TFM_MODAL_EDGESLIDE_DOWN
Definition: transform.h:279
@ TFM_MODAL_REMOVE_SNAP
Definition: transform.h:267
@ TFM_MODAL_CONS_OFF
Definition: transform.h:265
@ TFM_MODAL_AUTOCONSTRAINTPLANE
Definition: transform.h:287
@ TFM_MODAL_AXIS_X
Definition: transform.h:259
@ TFM_MODAL_ROTATE
Definition: transform.h:254
@ TFM_MODAL_AUTOIK_LEN_DEC
Definition: transform.h:276
@ TFM_MODAL_PROPSIZE_UP
Definition: transform.h:273
@ TFM_MODAL_PLANE_Y
Definition: transform.h:263
@ TFM_MODAL_SNAP_INV_ON
Definition: transform.h:256
@ TFM_MODAL_AXIS_Z
Definition: transform.h:261
@ TFM_MODAL_INSERTOFS_TOGGLE_DIR
Definition: transform.h:284
@ TFM_MODAL_PLANE_Z
Definition: transform.h:264
@ TFM_MODAL_CANCEL
Definition: transform.h:251
@ TFM_MODAL_PROPSIZE_DOWN
Definition: transform.h:274
@ TFM_MODAL_PRECISION
Definition: transform.h:289
@ TFM_MODAL_TRANSLATE
Definition: transform.h:253
@ TFM_MODAL_SNAP_INV_OFF
Definition: transform.h:257
void calculatePropRatio(TransInfo *t)
void initTransInfo(struct bContext *C, TransInfo *t, struct wmOperator *op, const struct wmEvent *event)
void calculateCenterLocal(TransInfo *t, const float center_global[3])
void initMouseInput(TransInfo *t, MouseInput *mi, const float center[2], const int mval[2], const bool precision)
#define FOREACH_TRANS_DATA_CONTAINER(t, th)
Definition: transform.h:813
@ TC_MESH_VERTS
Definition: transform.h:227
void drawConstraint(TransInfo *t)
void drawPropCircle(const struct bContext *C, TransInfo *t)
int constraintModeToIndex(const TransInfo *t)
void postSelectConstraint(TransInfo *t)
void setUserConstraint(TransInfo *t, int mode, const char ftext[])
void stopConstraint(TransInfo *t)
void setLocalConstraint(TransInfo *t, int mode, const char text[])
void initSelectConstraint(TransInfo *t)
void selectConstraint(TransInfo *t)
void transform_autoik_update(TransInfo *t, short mode)
void special_aftertrans_update(bContext *C, TransInfo *t)
void sort_trans_data_dist(TransInfo *t)
void createTransData(bContext *C, TransInfo *t)
conversion and adaptation of different datablocks to a common struct.
#define T_PROP_SIZE_MIN
@ TD_SELECTED
#define T_PROP_SIZE_MAX
bool transform_draw_cursor_poll(bContext *C)
void transform_draw_cursor_draw(bContext *UNUSED(C), int x, int y, void *customdata)
void transform_mode_init(TransInfo *t, wmOperator *op, const int mode)
int transform_mode_really_used(bContext *C, int mode)
bool transform_mode_is_changeable(const int mode)
transform modes used by different operators.
void drawEdgeSlide(TransInfo *t)
void drawVertSlide(TransInfo *t)
void transform_orientations_current_set(TransInfo *t, const short orient_index)
bool transformModeUseSnap(const TransInfo *t)
void addSnapPoint(TransInfo *t)
bool validSnap(const TransInfo *t)
eRedrawFlag handleSnapping(TransInfo *t, const wmEvent *event)
void removeSnapPoint(TransInfo *t)
void drawSnapping(const struct bContext *C, TransInfo *t)
void initSnapping(TransInfo *t, wmOperator *op)
ccl_device_inline float4 mask(const int4 &mask, const float4 &a)
void WM_paint_cursor_tag_redraw(wmWindow *win, ARegion *UNUSED(region))
Definition: wm_draw.c:1025
int WM_userdef_event_type_from_keymap_type(int kmitype)
void WM_window_status_area_tag_redraw(wmWindow *win)
void WM_main_add_notifier(unsigned int type, void *reference)
void WM_event_add_notifier(const bContext *C, uint type, void *reference)
#define ISTWEAK(event_type)
@ EVT_OKEY
@ EVT_MODAL_MAP
@ EVT_RIGHTCTRLKEY
@ EVT_CKEY
@ EVT_OSKEY
@ EVT_LEFTCTRLKEY
@ MOUSEMOVE
@ EVT_RIGHTALTKEY
@ EVT_PADMINUS
@ LEFTMOUSE
@ EVT_NKEY
@ EVT_LEFTALTKEY
@ INBETWEEN_MOUSEMOVE
@ EVT_RIGHTSHIFTKEY
@ EVT_LEFTSHIFTKEY
@ EVT_PADPLUSKEY
wmKeyMap * WM_keymap_active(const wmWindowManager *wm, wmKeyMap *keymap)
Definition: wm_keymap.c:1895
wmKeyMap * WM_modalkeymap_ensure(wmKeyConfig *keyconf, const char *idname, const EnumPropertyItem *items)
Definition: wm_keymap.c:888
#define WM_msg_publish_rna_prop(mbus, id_, data_, type_, prop_)
wmPaintCursor * WM_paint_cursor_activate(short space_type, short region_type, bool(*poll)(bContext *C), wmPaintCursorDraw draw, void *customdata)