Blender  V3.3
transform_generics.c
Go to the documentation of this file.
1 /* SPDX-License-Identifier: GPL-2.0-or-later
2  * Copyright 2001-2002 NaN Holding BV. All rights reserved. */
3 
8 #include <math.h>
9 
10 #include "MEM_guardedalloc.h"
11 
12 #include "DNA_gpencil_types.h"
13 
14 #include "BLI_blenlib.h"
15 #include "BLI_math.h"
16 #include "BLI_rand.h"
17 
18 #include "PIL_time.h"
19 
20 #include "BLT_translation.h"
21 
22 #include "RNA_access.h"
23 
24 #include "GPU_immediate.h"
25 #include "GPU_matrix.h"
26 
27 #include "BKE_context.h"
28 #include "BKE_layer.h"
29 #include "BKE_mask.h"
30 #include "BKE_modifier.h"
31 #include "BKE_paint.h"
32 
33 #include "SEQ_transform.h"
34 
35 #include "ED_clip.h"
36 #include "ED_image.h"
37 #include "ED_object.h"
38 #include "ED_screen.h"
39 #include "ED_space_api.h"
40 #include "ED_uvedit.h"
41 
42 #include "WM_api.h"
43 #include "WM_types.h"
44 
45 #include "UI_resources.h"
46 #include "UI_view2d.h"
47 
48 #include "SEQ_sequencer.h"
49 
50 #include "transform.h"
51 #include "transform_convert.h"
52 #include "transform_mode.h"
53 #include "transform_orientations.h"
54 #include "transform_snap.h"
55 
56 /* ************************** GENERICS **************************** */
57 
58 void drawLine(TransInfo *t, const float center[3], const float dir[3], char axis, short options)
59 {
60  if (!ELEM(t->spacetype, SPACE_VIEW3D, SPACE_SEQ)) {
61  return;
62  }
63 
64  float v1[3], v2[3], v3[3];
65  uchar col[3], col2[3];
66 
67  if (t->spacetype == SPACE_VIEW3D) {
68  View3D *v3d = t->view;
69 
70  copy_v3_v3(v3, dir);
71  mul_v3_fl(v3, v3d->clip_end);
72 
73  sub_v3_v3v3(v2, center, v3);
74  add_v3_v3v3(v1, center, v3);
75  }
76  else if (t->spacetype == SPACE_SEQ) {
77  View2D *v2d = t->view;
78 
79  copy_v3_v3(v3, dir);
80  float max_dist = max_ff(BLI_rctf_size_x(&v2d->cur), BLI_rctf_size_y(&v2d->cur));
81  mul_v3_fl(v3, max_dist);
82 
83  sub_v3_v3v3(v2, center, v3);
84  add_v3_v3v3(v1, center, v3);
85  }
86 
88 
89  if (options & DRAWLIGHT) {
90  col[0] = col[1] = col[2] = 220;
91  }
92  else {
94  }
95  UI_make_axis_color(col, col2, axis);
96 
98 
100  immUniformColor3ubv(col2);
101 
103  immVertex3fv(pos, v1);
104  immVertex3fv(pos, v2);
105  immEnd();
106 
108 
109  GPU_matrix_pop();
110 }
111 
113 {
115 }
116 
118 {
119  t->flag &= ~T_ALL_RESTRICTIONS;
120 }
121 
122 static void *t_view_get(TransInfo *t)
123 {
124  if (t->spacetype == SPACE_VIEW3D) {
125  View3D *v3d = t->area->spacedata.first;
126  return (void *)v3d;
127  }
128  if (t->region) {
129  return (void *)&t->region->v2d;
130  }
131  return NULL;
132 }
133 
135 {
136  if (t->flag & T_OVERRIDE_CENTER) {
137  /* Avoid initialization of individual origins (#V3D_AROUND_LOCAL_ORIGINS). */
139  }
140 
141  ScrArea *area = t->area;
142  switch (t->spacetype) {
143  case SPACE_VIEW3D: {
144  if (t->mode == TFM_BEND) {
145  /* Bend always uses the cursor. */
146  return V3D_AROUND_CURSOR;
147  }
148  return t->settings->transform_pivot_point;
149  }
150  case SPACE_IMAGE: {
151  SpaceImage *sima = area->spacedata.first;
152  return sima->around;
153  }
154  case SPACE_GRAPH: {
155  SpaceGraph *sipo = area->spacedata.first;
156  return sipo->around;
157  }
158  case SPACE_CLIP: {
159  SpaceClip *sclip = area->spacedata.first;
160  return sclip->around;
161  }
162  case SPACE_SEQ: {
163  if (t->region->regiontype == RGN_TYPE_PREVIEW) {
164  return SEQ_tool_settings_pivot_point_get(t->scene);
165  }
166  break;
167  }
168  default:
169  break;
170  }
171 
173 }
174 
175 void initTransInfo(bContext *C, TransInfo *t, wmOperator *op, const wmEvent *event)
176 {
177  Scene *sce = CTX_data_scene(C);
178  ViewLayer *view_layer = CTX_data_view_layer(C);
179  Object *obact = OBACT(view_layer);
180  const eObjectMode object_mode = obact ? obact->mode : OB_MODE_OBJECT;
182  ARegion *region = CTX_wm_region(C);
184 
186  PropertyRNA *prop;
187 
188  t->mbus = CTX_wm_message_bus(C);
189  t->depsgraph = CTX_data_depsgraph_pointer(C);
190  t->scene = sce;
191  t->view_layer = view_layer;
192  t->area = area;
193  t->region = region;
194  t->settings = ts;
195  t->reports = op ? op->reports : NULL;
196 
197  t->helpline = HLP_NONE;
198 
199  t->flag = 0;
200 
201  if (obact && !(t->options & (CTX_CURSOR | CTX_TEXTURE_SPACE)) &&
202  ELEM(object_mode, OB_MODE_EDIT, OB_MODE_EDIT_GPENCIL)) {
203  t->obedit_type = obact->type;
204  }
205  else {
206  t->obedit_type = -1;
207  }
208 
209  if (t->options & CTX_CURSOR) {
210  /* Cursor should always use the drag start as the combination of click-drag to place & move
211  * doesn't work well if the click location isn't used when transforming. */
212  t->flag |= T_EVENT_DRAG_START;
213  }
214 
215  /* Many kinds of transform only use a single handle. */
216  if (t->data_container == NULL) {
217  t->data_container = MEM_callocN(sizeof(*t->data_container), __func__);
218  t->data_container_len = 1;
219  }
220 
221  t->redraw = TREDRAW_HARD; /* redraw first time */
222 
223  int mval[2];
224  if (event) {
225  if (t->flag & T_EVENT_DRAG_START) {
226  WM_event_drag_start_mval(event, region, mval);
227  }
228  else {
229  copy_v2_v2_int(mval, event->mval);
230  }
231  }
232  else {
233  zero_v2_int(mval);
234  }
235  copy_v2_v2_int(t->mval, mval);
236  copy_v2_v2_int(t->mouse.imval, mval);
237  copy_v2_v2_int(t->con.imval, mval);
238 
239  t->transform = NULL;
240  t->handleEvent = NULL;
241 
242  t->data_len_all = 0;
243 
244  zero_v3(t->center_global);
245 
246  unit_m3(t->mat);
247 
248  /* Default to rotate on the Z axis. */
249  t->orient_axis = 2;
250  t->orient_axis_ortho = 1;
251 
252  /* if there's an event, we're modal */
253  if (event) {
254  t->flag |= T_MODAL;
255  }
256 
257  /* Crease needs edge flag */
258  if (ELEM(t->mode, TFM_EDGE_CREASE, TFM_BWEIGHT)) {
259  t->options |= CTX_EDGE_DATA;
260  }
261 
262  t->remove_on_cancel = false;
263 
264  if (op && (prop = RNA_struct_find_property(op->ptr, "remove_on_cancel")) &&
265  RNA_property_is_set(op->ptr, prop)) {
266  if (RNA_property_boolean_get(op->ptr, prop)) {
267  t->remove_on_cancel = true;
268  }
269  }
270 
271  /* GPencil editing context */
272  if (GPENCIL_EDIT_MODE(gpd)) {
273  t->options |= CTX_GPENCIL_STROKES;
274  }
275 
276  /* Assign the space type, some exceptions for running in different mode */
277  if (area == NULL) {
278  /* background mode */
279  t->spacetype = SPACE_EMPTY;
280  }
281  else if ((region == NULL) && (area->spacetype == SPACE_VIEW3D)) {
282  /* running in the text editor */
283  t->spacetype = SPACE_EMPTY;
284  }
285  else {
286  /* normal operation */
287  t->spacetype = area->spacetype;
288  }
289 
290  /* handle T_ALT_TRANSFORM initialization, we may use for different operators */
291  if (op) {
292  const char *prop_id = NULL;
293  if (t->mode == TFM_SHRINKFATTEN) {
294  prop_id = "use_even_offset";
295  }
296 
297  if (prop_id && (prop = RNA_struct_find_property(op->ptr, prop_id))) {
299  }
300  }
301 
302  if (t->spacetype == SPACE_VIEW3D) {
304 
305  t->animtimer = (animscreen) ? animscreen->animtimer : NULL;
306 
307  if (t->scene->toolsettings->transform_flag & SCE_XFORM_AXIS_ALIGN) {
308  t->flag |= T_V3D_ALIGN;
309  }
310 
311  if (object_mode & OB_MODE_ALL_PAINT) {
313  if (p && p->brush && (p->brush->flag & BRUSH_CURVE)) {
314  t->options |= CTX_PAINT_CURVE;
315  }
316  }
317 
318  /* initialize UV transform from */
319  if (op && ((prop = RNA_struct_find_property(op->ptr, "correct_uv")))) {
320  if (RNA_property_is_set(op->ptr, prop)) {
321  if (RNA_property_boolean_get(op->ptr, prop)) {
322  t->settings->uvcalc_flag |= UVCALC_TRANSFORM_CORRECT_SLIDE;
323  }
324  else {
325  t->settings->uvcalc_flag &= ~UVCALC_TRANSFORM_CORRECT_SLIDE;
326  }
327  }
328  else {
330  op->ptr, prop, (t->settings->uvcalc_flag & UVCALC_TRANSFORM_CORRECT_SLIDE) != 0);
331  }
332  }
333  }
334  else if (t->spacetype == SPACE_IMAGE) {
335  SpaceImage *sima = area->spacedata.first;
336  if (ED_space_image_show_uvedit(sima, OBACT(t->view_layer))) {
337  /* UV transform */
338  }
339  else if (sima->mode == SI_MODE_MASK) {
340  t->options |= CTX_MASK;
341  }
342  else if (sima->mode == SI_MODE_PAINT) {
343  Paint *p = &sce->toolsettings->imapaint.paint;
344  if (p->brush && (p->brush->flag & BRUSH_CURVE)) {
345  t->options |= CTX_PAINT_CURVE;
346  }
347  }
348  /* image not in uv edit, nor in mask mode, can happen for some tools */
349  }
350  else if (t->spacetype == SPACE_CLIP) {
351  SpaceClip *sclip = area->spacedata.first;
353  t->options |= CTX_MOVIECLIP;
354  }
355  else if (ED_space_clip_check_show_maskedit(sclip)) {
356  t->options |= CTX_MASK;
357  }
358  }
359  else if (t->spacetype == SPACE_SEQ && region->regiontype == RGN_TYPE_PREVIEW) {
360  t->options |= CTX_SEQUENCER_IMAGE;
361 
362  /* Needed for autokeying transforms in preview during playback. */
364  t->animtimer = (animscreen) ? animscreen->animtimer : NULL;
365  }
366 
367  setTransformViewAspect(t, t->aspect);
368 
369  if (op && (prop = RNA_struct_find_property(op->ptr, "center_override")) &&
370  RNA_property_is_set(op->ptr, prop)) {
371  RNA_property_float_get_array(op->ptr, prop, t->center_global);
372  mul_v3_v3(t->center_global, t->aspect);
373  t->flag |= T_OVERRIDE_CENTER;
374  }
375 
376  t->view = t_view_get(t);
377  t->around = t_around_get(t);
378 
379  /* Exceptional case. */
380  if (t->around == V3D_AROUND_LOCAL_ORIGINS) {
381  if (ELEM(t->mode, TFM_ROTATION, TFM_RESIZE, TFM_TRACKBALL)) {
382  const bool use_island = transdata_check_local_islands(t, t->around);
383 
384  if ((t->obedit_type != -1) && !use_island) {
385  t->options |= CTX_NO_PET;
386  }
387  }
388  }
389 
390  bool t_values_set_is_array = false;
391 
392  if (op && (prop = RNA_struct_find_property(op->ptr, "value")) &&
393  RNA_property_is_set(op->ptr, prop)) {
394  float values[4] = {0}; /* in case value isn't length 4, avoid uninitialized memory. */
395  if (RNA_property_array_check(prop)) {
396  RNA_property_float_get_array(op->ptr, prop, values);
397  t_values_set_is_array = true;
398  }
399  else {
400  values[0] = RNA_property_float_get(op->ptr, prop);
401  }
402 
403  if (t->flag & T_MODAL) {
404  /* Run before init functions so 'values_modal_offset' can be applied on mouse input. */
405  copy_v4_v4(t->values_modal_offset, values);
406  }
407  else {
408  copy_v4_v4(t->values, values);
409  t->flag |= T_INPUT_IS_VALUES_FINAL;
410  }
411  }
412 
413  if (op && (prop = RNA_struct_find_property(op->ptr, "constraint_axis"))) {
414  bool constraint_axis[3] = {false, false, false};
415  if (t_values_set_is_array && t->flag & T_INPUT_IS_VALUES_FINAL) {
416  /* For operators whose `t->values` is array (as Move and Scale), set constraint so that the
417  * orientation is more intuitive in the Redo Panel. */
418  constraint_axis[0] = constraint_axis[1] = constraint_axis[2] = true;
419  }
420  else if (RNA_property_is_set(op->ptr, prop)) {
421  RNA_property_boolean_get_array(op->ptr, prop, constraint_axis);
422  }
423 
424  if (constraint_axis[0] || constraint_axis[1] || constraint_axis[2]) {
425  t->con.mode |= CON_APPLY;
426 
427  if (constraint_axis[0]) {
428  t->con.mode |= CON_AXIS0;
429  }
430  if (constraint_axis[1]) {
431  t->con.mode |= CON_AXIS1;
432  }
433  if (constraint_axis[2]) {
434  t->con.mode |= CON_AXIS2;
435  }
436  }
437  }
438 
439  {
440  short orient_types[3];
441  float custom_matrix[3][3];
442 
443  int orient_type_scene = V3D_ORIENT_GLOBAL;
444  int orient_type_default = -1;
445  int orient_type_set = -1;
446  int orient_type_matrix_set = -1;
447 
448  if ((t->spacetype == SPACE_VIEW3D) && (t->region->regiontype == RGN_TYPE_WINDOW)) {
449  TransformOrientationSlot *orient_slot = &t->scene->orientation_slots[SCE_ORIENT_DEFAULT];
450  orient_type_scene = orient_slot->type;
451  if (orient_type_scene == V3D_ORIENT_CUSTOM) {
452  const int index_custom = orient_slot->index_custom;
453  orient_type_scene += index_custom;
454  }
455  }
456 
457  if (op && ((prop = RNA_struct_find_property(op->ptr, "orient_type")) &&
458  RNA_property_is_set(op->ptr, prop))) {
459  orient_type_set = RNA_property_enum_get(op->ptr, prop);
460  if (orient_type_set >= V3D_ORIENT_CUSTOM + BIF_countTransformOrientation(C)) {
461  orient_type_set = V3D_ORIENT_GLOBAL;
462  }
463  }
464 
465  if (op && (prop = RNA_struct_find_property(op->ptr, "orient_axis"))) {
466  t->orient_axis = RNA_property_enum_get(op->ptr, prop);
467  }
468 
469  if (op && (prop = RNA_struct_find_property(op->ptr, "orient_axis_ortho"))) {
470  t->orient_axis_ortho = RNA_property_enum_get(op->ptr, prop);
471  }
472 
473  if (op && ((prop = RNA_struct_find_property(op->ptr, "orient_matrix")) &&
474  RNA_property_is_set(op->ptr, prop))) {
475  RNA_property_float_get_array(op->ptr, prop, &custom_matrix[0][0]);
476 
477  if ((prop = RNA_struct_find_property(op->ptr, "orient_matrix_type")) &&
478  RNA_property_is_set(op->ptr, prop)) {
479  orient_type_matrix_set = RNA_property_enum_get(op->ptr, prop);
480  }
481  else if (orient_type_set == -1) {
482  orient_type_set = V3D_ORIENT_CUSTOM_MATRIX;
483  }
484  }
485 
486  orient_type_default = orient_type_scene;
487 
488  if (orient_type_set != -1) {
489  if (!(t->con.mode & CON_APPLY)) {
490  /* Only overwrite default if not constrained. */
491  orient_type_default = orient_type_set;
492  t->is_orient_default_overwrite = true;
493  }
494  }
495  else if (orient_type_matrix_set != -1) {
496  orient_type_set = orient_type_matrix_set;
497  if (!(t->con.mode & CON_APPLY)) {
498  /* Only overwrite default if not constrained. */
499  orient_type_default = orient_type_set;
500  t->is_orient_default_overwrite = true;
501  }
502  }
503  else if (t->con.mode & CON_APPLY) {
504  orient_type_set = orient_type_scene;
505  }
506  else if (orient_type_scene == V3D_ORIENT_GLOBAL) {
507  orient_type_set = V3D_ORIENT_LOCAL;
508  }
509  else {
510  orient_type_set = V3D_ORIENT_GLOBAL;
511  }
512 
513  BLI_assert(!ELEM(-1, orient_type_default, orient_type_set));
514  if (orient_type_matrix_set == orient_type_set) {
515  /* Constraints are forced to use the custom matrix when redoing. */
516  orient_type_set = V3D_ORIENT_CUSTOM_MATRIX;
517  }
518 
519  orient_types[O_DEFAULT] = (short)orient_type_default;
520  orient_types[O_SCENE] = (short)orient_type_scene;
521  orient_types[O_SET] = (short)orient_type_set;
522 
523  for (int i = 0; i < 3; i++) {
524  /* For efficiency, avoid calculating the same orientation twice. */
525  int j;
526  for (j = 0; j < i; j++) {
527  if (orient_types[j] == orient_types[i]) {
528  memcpy(&t->orient[i], &t->orient[j], sizeof(*t->orient));
529  break;
530  }
531  }
532  if (j == i) {
533  t->orient[i].type = transform_orientation_matrix_get(
534  C, t, orient_types[i], custom_matrix, t->orient[i].matrix);
535  }
536  }
537 
538  t->orient_type_mask = 0;
539  for (int i = 0; i < 3; i++) {
540  const int type = t->orient[i].type;
542  BLI_assert(type < 32);
543  t->orient_type_mask |= (1 << type);
544  }
545  }
546 
547  transform_orientations_current_set(t, (t->con.mode & CON_APPLY) ? 2 : 0);
548  }
549 
550  if (op && ((prop = RNA_struct_find_property(op->ptr, "release_confirm")) &&
551  RNA_property_is_set(op->ptr, prop))) {
552  if (RNA_property_boolean_get(op->ptr, prop)) {
553  t->flag |= T_RELEASE_CONFIRM;
554  }
555  }
556  else {
557  /* Release confirms preference should not affect node editor (T69288, T70504). */
558  if (ISMOUSE_BUTTON(t->launch_event) &&
559  ((U.flag & USER_RELEASECONFIRM) || (t->spacetype == SPACE_NODE))) {
560  /* Global "release confirm" on mouse bindings */
561  t->flag |= T_RELEASE_CONFIRM;
562  }
563  }
564 
565  if (op && ((prop = RNA_struct_find_property(op->ptr, "mirror")) &&
566  RNA_property_is_set(op->ptr, prop))) {
567  if (!RNA_property_boolean_get(op->ptr, prop)) {
568  t->flag |= T_NO_MIRROR;
569  }
570  }
571  else if ((t->spacetype == SPACE_VIEW3D) && (t->obedit_type == OB_MESH)) {
572  /* pass */
573  }
574  else {
575  /* Avoid mirroring for unsupported contexts. */
576  t->flag |= T_NO_MIRROR;
577  }
578 
579  /* setting PET flag only if property exist in operator. Otherwise, assume it's not supported */
580  if (op && (prop = RNA_struct_find_property(op->ptr, "use_proportional_edit"))) {
581  if (RNA_property_is_set(op->ptr, prop)) {
582  if (RNA_property_boolean_get(op->ptr, prop)) {
583  t->flag |= T_PROP_EDIT;
584  if (RNA_boolean_get(op->ptr, "use_proportional_connected")) {
585  t->flag |= T_PROP_CONNECTED;
586  }
587  if (RNA_boolean_get(op->ptr, "use_proportional_projected")) {
588  t->flag |= T_PROP_PROJECTED;
589  }
590  }
591  }
592  else {
593  /* use settings from scene only if modal */
594  if (t->flag & T_MODAL) {
595  if ((t->options & CTX_NO_PET) == 0) {
596  bool use_prop_edit = false;
597  if (t->spacetype == SPACE_GRAPH) {
598  use_prop_edit = ts->proportional_fcurve;
599  }
600  else if (t->spacetype == SPACE_ACTION) {
601  use_prop_edit = ts->proportional_action;
602  }
603  else if (t->options & CTX_MASK) {
604  use_prop_edit = ts->proportional_mask;
605  }
606  else if (obact && obact->mode == OB_MODE_OBJECT) {
607  use_prop_edit = ts->proportional_objects;
608  }
609  else {
610  use_prop_edit = (ts->proportional_edit & PROP_EDIT_USE) != 0;
611  }
612 
613  if (use_prop_edit) {
614  t->flag |= T_PROP_EDIT;
616  t->flag |= T_PROP_CONNECTED;
617  }
619  t->flag |= T_PROP_PROJECTED;
620  }
621  }
622  }
623  }
624  }
625 
626  if (op && ((prop = RNA_struct_find_property(op->ptr, "proportional_size")) &&
627  RNA_property_is_set(op->ptr, prop))) {
628  t->prop_size = RNA_property_float_get(op->ptr, prop);
629  }
630  else {
631  t->prop_size = ts->proportional_size;
632  }
633 
634  /* TRANSFORM_FIX_ME rna restrictions */
635  if (t->prop_size <= 0.00001f) {
636  printf("Proportional size (%f) under 0.00001, resetting to 1!\n", t->prop_size);
637  t->prop_size = 1.0f;
638  }
639 
640  if (op && ((prop = RNA_struct_find_property(op->ptr, "proportional_edit_falloff")) &&
641  RNA_property_is_set(op->ptr, prop))) {
642  t->prop_mode = RNA_property_enum_get(op->ptr, prop);
643  }
644  else {
645  t->prop_mode = ts->prop_mode;
646  }
647  }
648  else { /* add not pet option to context when not available */
649  t->options |= CTX_NO_PET;
650  }
651 
652  if (t->obedit_type == OB_MESH) {
653  if (op && (prop = RNA_struct_find_property(op->ptr, "use_automerge_and_split")) &&
654  RNA_property_is_set(op->ptr, prop)) {
655  if (RNA_property_boolean_get(op->ptr, prop)) {
656  t->flag |= T_AUTOMERGE | T_AUTOSPLIT;
657  }
658  }
659  else {
660  char automerge = t->scene->toolsettings->automerge;
661  if (automerge & AUTO_MERGE) {
662  t->flag |= T_AUTOMERGE;
663  if (automerge & AUTO_MERGE_AND_SPLIT) {
664  t->flag |= T_AUTOSPLIT;
665  }
666  }
667  }
668  }
669 
670  /* Mirror is not supported with PET, turn it off. */
671 #if 0
672  if (t->flag & T_PROP_EDIT) {
673  t->flag &= ~T_MIRROR;
674  }
675 #endif
676 
677  /* Disable cursor wrap when edge panning is enabled. */
678  if (t->options & CTX_VIEW2D_EDGE_PAN) {
679  t->flag |= T_NO_CURSOR_WRAP;
680  }
681 
683  initNumInput(&t->num);
684 }
685 
687 {
688  if (custom_data->free_cb) {
689  /* Can take over freeing t->data and data_2d etc... */
690  custom_data->free_cb(t, tc, custom_data);
691  BLI_assert(custom_data->data == NULL);
692  }
693  else if ((custom_data->data != NULL) && custom_data->use_free) {
694  MEM_freeN(custom_data->data);
695  custom_data->data = NULL;
696  }
697  /* In case modes are switched in the same transform session. */
698  custom_data->free_cb = NULL;
699  custom_data->use_free = false;
700 }
701 
703  TransDataContainer *tc,
705 {
706  TransCustomData *custom_data = &tcdc->first_elem;
707  for (int i = 0; i < TRANS_CUSTOM_DATA_ELEM_MAX; i++, custom_data++) {
708  freeTransCustomData(t, tc, custom_data);
709  }
710 }
711 
713 {
714  freeTransCustomData(t, NULL, &t->custom.mode);
716  freeTransCustomData(t, tc, &tc->custom.mode);
717  }
718 }
719 
721 {
722  if (t->draw_handle_view) {
723  ED_region_draw_cb_exit(t->region->type, t->draw_handle_view);
724  }
725  if (t->draw_handle_pixel) {
726  ED_region_draw_cb_exit(t->region->type, t->draw_handle_pixel);
727  }
728  if (t->draw_handle_cursor) {
729  WM_paint_cursor_end(t->draw_handle_cursor);
730  }
731 
732  if (t->flag & T_MODAL_CURSOR_SET) {
734  }
735 
736  /* Free all custom-data */
737  freeTransCustomDataContainer(t, NULL, &t->custom);
739  freeTransCustomDataContainer(t, tc, &tc->custom);
740  }
741 
742  /* postTrans can be called when nothing is selected, so data is NULL already */
743  if (t->data_len_all != 0) {
745  /* free data malloced per trans-data */
746  if (ELEM(t->obedit_type, OB_CURVES_LEGACY, OB_SURF, OB_GPENCIL) ||
747  (t->spacetype == SPACE_GRAPH)) {
748  TransData *td = tc->data;
749  for (int a = 0; a < tc->data_len; a++, td++) {
750  if (td->flag & TD_BEZTRIPLE) {
751  MEM_freeN(td->hdata);
752  }
753  }
754  }
755  MEM_freeN(tc->data);
756 
757  MEM_SAFE_FREE(tc->data_mirror);
758  MEM_SAFE_FREE(tc->data_ext);
759  MEM_SAFE_FREE(tc->data_2d);
760  }
761  }
762 
763  MEM_SAFE_FREE(t->data_container);
764  t->data_container = NULL;
765 
766  BLI_freelistN(&t->tsnap.points);
767 
768  if (t->spacetype == SPACE_IMAGE) {
769  if (t->options & (CTX_MASK | CTX_PAINT_CURVE)) {
770  /* pass */
771  }
772  else {
773  SpaceImage *sima = t->area->spacedata.first;
774  if (sima->flag & SI_LIVE_UNWRAP) {
776  }
777  }
778  }
779 
780  if (t->mouse.data) {
781  MEM_freeN(t->mouse.data);
782  }
783 
784  if (t->rng != NULL) {
785  BLI_rng_free(t->rng);
786  }
787 
788  freeSnapping(t);
789 }
790 
792 {
794 
795  TransData *td;
796 
797  for (td = tc->data; td < tc->data + tc->data_len; td++) {
798  copy_v3_v3(td->iloc, td->loc);
799  if (td->ext->rot) {
800  copy_v3_v3(td->ext->irot, td->ext->rot);
801  }
802  if (td->ext->size) {
803  copy_v3_v3(td->ext->isize, td->ext->size);
804  }
805  }
806  recalcData(t);
807 }
808 
810 {
811  /* TransData for crease has no loc */
812  if (td_basic->loc) {
813  copy_v3_v3(td_basic->loc, td_basic->iloc);
814  }
815 }
816 
817 static void restoreElement(TransData *td)
818 {
820 
821  if (td->val && td->val != td->loc) {
822  *td->val = td->ival;
823  }
824 
825  if (td->ext && (td->flag & TD_NO_EXT) == 0) {
826  if (td->ext->rot) {
827  copy_v3_v3(td->ext->rot, td->ext->irot);
828  }
829  if (td->ext->rotAngle) {
830  *td->ext->rotAngle = td->ext->irotAngle;
831  }
832  if (td->ext->rotAxis) {
833  copy_v3_v3(td->ext->rotAxis, td->ext->irotAxis);
834  }
835  /* XXX, drotAngle & drotAxis not used yet */
836  if (td->ext->size) {
837  copy_v3_v3(td->ext->size, td->ext->isize);
838  }
839  if (td->ext->quat) {
840  copy_qt_qt(td->ext->quat, td->ext->iquat);
841  }
842  }
843 
844  if (td->flag & TD_BEZTRIPLE) {
845  *(td->hdata->h1) = td->hdata->ih1;
846  *(td->hdata->h2) = td->hdata->ih2;
847  }
848 }
849 
851 {
853 
854  TransData *td;
855  TransData2D *td2d;
856  TransDataMirror *tdm;
857 
858  for (td = tc->data; td < tc->data + tc->data_len; td++) {
859  restoreElement(td);
860  }
861 
862  for (tdm = tc->data_mirror; tdm < tc->data_mirror + tc->data_mirror_len; tdm++) {
864  }
865 
866  for (td2d = tc->data_2d; tc->data_2d && td2d < tc->data_2d + tc->data_len; td2d++) {
867  if (td2d->h1) {
868  td2d->h1[0] = td2d->ih1[0];
869  td2d->h1[1] = td2d->ih1[1];
870  }
871  if (td2d->h2) {
872  td2d->h2[0] = td2d->ih2[0];
873  td2d->h2[1] = td2d->ih2[1];
874  }
875  }
876 
877  unit_m3(t->mat);
878  }
879 
880  recalcData(t);
881 }
882 
884 {
885  BLI_assert(!is_zero_v3(t->aspect));
886  projectFloatView(t, t->center_global, t->center2d);
887 }
888 
889 void calculateCenterLocal(TransInfo *t, const float center_global[3])
890 {
891  /* Setting constraint center. */
892  /* NOTE: init functions may over-ride `t->center`. */
894  if (tc->use_local_mat) {
895  mul_v3_m4v3(tc->center_local, tc->imat, center_global);
896  }
897  else {
898  copy_v3_v3(tc->center_local, center_global);
899  }
900  }
901 }
902 
903 void calculateCenterCursor(TransInfo *t, float r_center[3])
904 {
905  const float *cursor = t->scene->cursor.location;
906  copy_v3_v3(r_center, cursor);
907 
908  /* If edit or pose mode, move cursor in local space */
909  if (t->options & CTX_PAINT_CURVE) {
910  if (ED_view3d_project_float_global(t->region, cursor, r_center, V3D_PROJ_TEST_NOP) !=
911  V3D_PROJ_RET_OK) {
912  r_center[0] = t->region->winx / 2.0f;
913  r_center[1] = t->region->winy / 2.0f;
914  }
915  r_center[2] = 0.0f;
916  }
917 }
918 
919 void calculateCenterCursor2D(TransInfo *t, float r_center[2])
920 {
921  float cursor_local_buf[2];
922  const float *cursor = NULL;
923 
924  if (t->spacetype == SPACE_IMAGE) {
925  SpaceImage *sima = (SpaceImage *)t->area->spacedata.first;
926  cursor = sima->cursor;
927  }
928  if (t->spacetype == SPACE_SEQ) {
929  SpaceSeq *sseq = (SpaceSeq *)t->area->spacedata.first;
930  SEQ_image_preview_unit_to_px(t->scene, sseq->cursor, cursor_local_buf);
931  cursor = cursor_local_buf;
932  }
933  else if (t->spacetype == SPACE_CLIP) {
934  SpaceClip *space_clip = (SpaceClip *)t->area->spacedata.first;
935  cursor = space_clip->cursor;
936  }
937 
938  if (cursor) {
939  if (t->options & CTX_MASK) {
940  float co[2];
941 
942  if (t->spacetype == SPACE_IMAGE) {
943  SpaceImage *sima = (SpaceImage *)t->area->spacedata.first;
944  BKE_mask_coord_from_image(sima->image, &sima->iuser, co, cursor);
945  }
946  else if (t->spacetype == SPACE_CLIP) {
947  SpaceClip *space_clip = (SpaceClip *)t->area->spacedata.first;
948  BKE_mask_coord_from_movieclip(space_clip->clip, &space_clip->user, co, cursor);
949  }
950  else {
951  BLI_assert_msg(0, "Shall not happen");
952  }
953 
954  r_center[0] = co[0] * t->aspect[0];
955  r_center[1] = co[1] * t->aspect[1];
956  }
957  else if (t->options & CTX_PAINT_CURVE) {
958  if (t->spacetype == SPACE_IMAGE) {
959  r_center[0] = UI_view2d_view_to_region_x(&t->region->v2d, cursor[0]);
960  r_center[1] = UI_view2d_view_to_region_y(&t->region->v2d, cursor[1]);
961  }
962  }
963  else {
964  r_center[0] = cursor[0] * t->aspect[0];
965  r_center[1] = cursor[1] * t->aspect[1];
966  }
967  }
968 }
969 
970 void calculateCenterCursorGraph2D(TransInfo *t, float r_center[2])
971 {
972  SpaceGraph *sipo = (SpaceGraph *)t->area->spacedata.first;
973  Scene *scene = t->scene;
974 
975  /* cursor is combination of current frame, and graph-editor cursor value */
976  if (sipo->mode == SIPO_MODE_DRIVERS) {
977  r_center[0] = sipo->cursorTime;
978  r_center[1] = sipo->cursorVal;
979  }
980  else {
981  r_center[0] = (float)(scene->r.cfra);
982  r_center[1] = sipo->cursorVal;
983  }
984 }
985 
987  const TransDataBasic *td_basic,
988  float r_vec[3])
989 {
990  if (td_basic->flag & TD_SELECTED) {
991  if (!(td_basic->flag & TD_NOCENTER)) {
992  if (tc->use_local_mat) {
993  mul_v3_m4v3(r_vec, tc->mat, td_basic->center);
994  }
995  else {
996  copy_v3_v3(r_vec, td_basic->center);
997  }
998  return true;
999  }
1000  }
1001  return false;
1002 }
1003 
1004 void calculateCenterMedian(TransInfo *t, float r_center[3])
1005 {
1006  float partial[3] = {0.0f, 0.0f, 0.0f};
1007  int total = 0;
1008 
1010  float center[3];
1011  for (int i = 0; i < tc->data_len; i++) {
1012  if (transdata_center_global_get(tc, (TransDataBasic *)&tc->data[i], center)) {
1013  add_v3_v3(partial, center);
1014  total++;
1015  }
1016  }
1017  for (int i = 0; i < tc->data_mirror_len; i++) {
1018  if (transdata_center_global_get(tc, (TransDataBasic *)&tc->data_mirror[i], center)) {
1019  add_v3_v3(partial, center);
1020  total++;
1021  }
1022  }
1023  }
1024  if (total) {
1025  mul_v3_fl(partial, 1.0f / (float)total);
1026  }
1027  copy_v3_v3(r_center, partial);
1028 }
1029 
1030 void calculateCenterBound(TransInfo *t, float r_center[3])
1031 {
1032  float max[3], min[3];
1033  bool changed = false;
1034  INIT_MINMAX(min, max);
1036  float center[3];
1037  for (int i = 0; i < tc->data_len; i++) {
1038  if (transdata_center_global_get(tc, (TransDataBasic *)&tc->data[i], center)) {
1040  changed = true;
1041  }
1042  }
1043  for (int i = 0; i < tc->data_mirror_len; i++) {
1044  if (transdata_center_global_get(tc, (TransDataBasic *)&tc->data_mirror[i], center)) {
1046  changed = true;
1047  }
1048  }
1049  }
1050  if (changed) {
1051  mid_v3_v3v3(r_center, min, max);
1052  }
1053 }
1054 
1055 bool calculateCenterActive(TransInfo *t, bool select_only, float r_center[3])
1056 {
1058 
1059  if (t->spacetype != SPACE_VIEW3D) {
1060  return false;
1061  }
1062  if (tc->obedit) {
1063  if (ED_object_calc_active_center_for_editmode(tc->obedit, select_only, r_center)) {
1064  mul_m4_v3(tc->obedit->obmat, r_center);
1065  return true;
1066  }
1067  }
1068  else if (t->options & CTX_POSE_BONE) {
1069  ViewLayer *view_layer = t->view_layer;
1070  Object *ob = OBACT(view_layer);
1071  if (ED_object_calc_active_center_for_posemode(ob, select_only, r_center)) {
1072  mul_m4_v3(ob->obmat, r_center);
1073  return true;
1074  }
1075  }
1076  else if (t->options & CTX_PAINT_CURVE) {
1077  Paint *p = BKE_paint_get_active(t->scene, t->view_layer);
1078  Brush *br = p->brush;
1079  PaintCurve *pc = br->paint_curve;
1080  copy_v3_v3(r_center, pc->points[pc->add_index - 1].bez.vec[1]);
1081  r_center[2] = 0.0f;
1082  return true;
1083  }
1084  else {
1085  /* object mode */
1086  ViewLayer *view_layer = t->view_layer;
1087  Object *ob = OBACT(view_layer);
1088  Base *base = BASACT(view_layer);
1089  if (ob && ((!select_only) || ((base->flag & BASE_SELECTED) != 0))) {
1090  copy_v3_v3(r_center, ob->obmat[3]);
1091  return true;
1092  }
1093  }
1094 
1095  return false;
1096 }
1097 
1098 static void calculateCenter_FromAround(TransInfo *t, int around, float r_center[3])
1099 {
1100  switch (around) {
1102  calculateCenterBound(t, r_center);
1103  break;
1105  calculateCenterMedian(t, r_center);
1106  break;
1107  case V3D_AROUND_CURSOR:
1108  if (ELEM(t->spacetype, SPACE_IMAGE, SPACE_SEQ, SPACE_CLIP)) {
1109  calculateCenterCursor2D(t, r_center);
1110  }
1111  else if (t->spacetype == SPACE_GRAPH) {
1112  calculateCenterCursorGraph2D(t, r_center);
1113  }
1114  else {
1115  calculateCenterCursor(t, r_center);
1116  }
1117  break;
1119  /* Individual element center uses median center for helpline and such */
1120  calculateCenterMedian(t, r_center);
1121  break;
1122  case V3D_AROUND_ACTIVE: {
1123  if (calculateCenterActive(t, false, r_center)) {
1124  /* pass */
1125  }
1126  else {
1127  /* fallback */
1128  calculateCenterMedian(t, r_center);
1129  }
1130  break;
1131  }
1132  }
1133 }
1134 
1136 {
1137  /* ED_view3d_calc_zfac() defines a factor for perspective depth correction,
1138  * used in ED_view3d_win_to_delta() */
1139 
1140  /* zfac is only used convertViewVec only in cases operator was invoked in RGN_TYPE_WINDOW
1141  * and never used in other cases.
1142  *
1143  * We need special case here as well, since ED_view3d_calc_zfac will crash when called
1144  * for a region different from RGN_TYPE_WINDOW.
1145  */
1146  if ((t->spacetype == SPACE_VIEW3D) && (t->region->regiontype == RGN_TYPE_WINDOW)) {
1147  t->zfac = ED_view3d_calc_zfac(t->region->regiondata, t->center_global);
1148  }
1149  else if (t->spacetype == SPACE_IMAGE) {
1150  SpaceImage *sima = t->area->spacedata.first;
1151  t->zfac = 1.0f / sima->zoom;
1152  }
1153  else if (t->region) {
1154  View2D *v2d = &t->region->v2d;
1155  /* Get zoom fac the same way as in
1156  * `ui_view2d_curRect_validate_resize` - better keep in sync! */
1157  const float zoomx = (float)(BLI_rcti_size_x(&v2d->mask) + 1) / BLI_rctf_size_x(&v2d->cur);
1158  t->zfac = 1.0f / zoomx;
1159  }
1160 }
1161 
1163 {
1164  if ((t->flag & T_OVERRIDE_CENTER) == 0) {
1165  calculateCenter_FromAround(t, t->around, t->center_global);
1166  }
1167  calculateCenterLocal(t, t->center_global);
1168 
1170 
1171  /* For panning from the camera-view. */
1172  if ((t->options & CTX_OBJECT) && (t->flag & T_OVERRIDE_CENTER) == 0) {
1173  if (t->spacetype == SPACE_VIEW3D && t->region && t->region->regiontype == RGN_TYPE_WINDOW) {
1174 
1175  if (t->options & CTX_CAMERA) {
1176  float axis[3];
1177  /* persinv is nasty, use viewinv instead, always right */
1178  copy_v3_v3(axis, t->viewinv[2]);
1179  normalize_v3(axis);
1180 
1181  /* 6.0 = 6 grid units */
1182  axis[0] = t->center_global[0] - 6.0f * axis[0];
1183  axis[1] = t->center_global[1] - 6.0f * axis[1];
1184  axis[2] = t->center_global[2] - 6.0f * axis[2];
1185 
1186  projectFloatView(t, axis, t->center2d);
1187 
1188  /* Rotate only needs correct 2d center, grab needs #ED_view3d_calc_zfac() value. */
1189  if (t->mode == TFM_TRANSLATION) {
1190  copy_v3_v3(t->center_global, axis);
1191  }
1192  }
1193  }
1194  }
1195 
1196  calculateZfac(t);
1197 }
1198 
1199 /* Called every time the view changes due to navigation.
1200  * Adjusts the mouse position relative to the object. */
1202 {
1203  float zoom_prev = t->zfac;
1204  float zoom_new;
1205  if ((t->spacetype == SPACE_VIEW3D) && (t->region->regiontype == RGN_TYPE_WINDOW)) {
1206  if (!t->persp) {
1207  zoom_prev *= len_v3(t->persinv[0]);
1208  }
1209 
1211  calculateZfac(t);
1212 
1213  zoom_new = t->zfac;
1214  if (!t->persp) {
1215  zoom_new *= len_v3(t->persinv[0]);
1216  }
1217 
1218  for (int i = 0; i < ARRAY_SIZE(t->orient); i++) {
1219  if (t->orient[i].type == V3D_ORIENT_VIEW) {
1220  copy_m3_m4(t->orient[i].matrix, t->viewinv);
1221  normalize_m3(t->orient[i].matrix);
1222  if (t->orient_curr == i) {
1223  copy_m3_m3(t->spacemtx, t->orient[i].matrix);
1224  invert_m3_m3_safe_ortho(t->spacemtx_inv, t->spacemtx);
1225  }
1226  }
1227  }
1228  }
1229  else {
1230  calculateZfac(t);
1231  zoom_new = t->zfac;
1232  }
1233 
1235  transform_input_update(t, zoom_prev / zoom_new);
1236 }
1237 
1239 {
1240  int i;
1241  float dist;
1242  const bool connected = (t->flag & T_PROP_CONNECTED) != 0;
1243 
1244  t->proptext[0] = '\0';
1245 
1246  if (t->flag & T_PROP_EDIT) {
1247  const char *pet_id = NULL;
1249  TransData *td = tc->data;
1250  for (i = 0; i < tc->data_len; i++, td++) {
1251  if (td->flag & TD_SELECTED) {
1252  td->factor = 1.0f;
1253  }
1254  else if ((connected && (td->flag & TD_NOTCONNECTED || td->dist > t->prop_size)) ||
1255  (connected == 0 && td->rdist > t->prop_size)) {
1256  td->factor = 0.0f;
1257  restoreElement(td);
1258  }
1259  else {
1260  /* Use rdist for falloff calculations, it is the real distance */
1261  if (connected) {
1262  dist = (t->prop_size - td->dist) / t->prop_size;
1263  }
1264  else {
1265  dist = (t->prop_size - td->rdist) / t->prop_size;
1266  }
1267 
1268  /*
1269  * Clamp to positive numbers.
1270  * Certain corner cases with connectivity and individual centers
1271  * can give values of rdist larger than propsize.
1272  */
1273  if (dist < 0.0f) {
1274  dist = 0.0f;
1275  }
1276 
1277  switch (t->prop_mode) {
1278  case PROP_SHARP:
1279  td->factor = dist * dist;
1280  break;
1281  case PROP_SMOOTH:
1282  td->factor = 3.0f * dist * dist - 2.0f * dist * dist * dist;
1283  break;
1284  case PROP_ROOT:
1285  td->factor = sqrtf(dist);
1286  break;
1287  case PROP_LIN:
1288  td->factor = dist;
1289  break;
1290  case PROP_CONST:
1291  td->factor = 1.0f;
1292  break;
1293  case PROP_SPHERE:
1294  td->factor = sqrtf(2 * dist - dist * dist);
1295  break;
1296  case PROP_RANDOM:
1297  if (t->rng == NULL) {
1298  /* Lazy initialization. */
1299  uint rng_seed = (uint)(PIL_check_seconds_timer_i() & UINT_MAX);
1300  t->rng = BLI_rng_new(rng_seed);
1301  }
1302  td->factor = BLI_rng_get_float(t->rng) * dist;
1303  break;
1304  case PROP_INVSQUARE:
1305  td->factor = dist * (2.0f - dist);
1306  break;
1307  default:
1308  td->factor = 1;
1309  break;
1310  }
1311  }
1312  }
1313  }
1314 
1315  switch (t->prop_mode) {
1316  case PROP_SHARP:
1317  pet_id = N_("(Sharp)");
1318  break;
1319  case PROP_SMOOTH:
1320  pet_id = N_("(Smooth)");
1321  break;
1322  case PROP_ROOT:
1323  pet_id = N_("(Root)");
1324  break;
1325  case PROP_LIN:
1326  pet_id = N_("(Linear)");
1327  break;
1328  case PROP_CONST:
1329  pet_id = N_("(Constant)");
1330  break;
1331  case PROP_SPHERE:
1332  pet_id = N_("(Sphere)");
1333  break;
1334  case PROP_RANDOM:
1335  pet_id = N_("(Random)");
1336  break;
1337  case PROP_INVSQUARE:
1338  pet_id = N_("(InvSquare)");
1339  break;
1340  default:
1341  break;
1342  }
1343 
1344  if (pet_id) {
1345  BLI_strncpy(t->proptext, IFACE_(pet_id), sizeof(t->proptext));
1346  }
1347  }
1348  else {
1350  TransData *td = tc->data;
1351  for (i = 0; i < tc->data_len; i++, td++) {
1352  td->factor = 1.0;
1353  }
1354  }
1355  }
1356 }
1357 
1358 void transform_data_ext_rotate(TransData *td, float mat[3][3], bool use_drot)
1359 {
1360  float totmat[3][3];
1361  float smat[3][3];
1362  float fmat[3][3];
1363  float obmat[3][3];
1364 
1365  float dmat[3][3]; /* delta rotation */
1366  float dmat_inv[3][3];
1367 
1368  mul_m3_m3m3(totmat, mat, td->mtx);
1369  mul_m3_m3m3(smat, td->smtx, mat);
1370 
1371  /* logic from BKE_object_rot_to_mat3 */
1372  if (use_drot) {
1373  if (td->ext->rotOrder > 0) {
1374  eulO_to_mat3(dmat, td->ext->drot, td->ext->rotOrder);
1375  }
1376  else if (td->ext->rotOrder == ROT_MODE_AXISANGLE) {
1377 #if 0
1378  axis_angle_to_mat3(dmat, td->ext->drotAxis, td->ext->drotAngle);
1379 #else
1380  unit_m3(dmat);
1381 #endif
1382  }
1383  else {
1384  float tquat[4];
1385  normalize_qt_qt(tquat, td->ext->dquat);
1386  quat_to_mat3(dmat, tquat);
1387  }
1388 
1389  invert_m3_m3(dmat_inv, dmat);
1390  }
1391 
1392  if (td->ext->rotOrder == ROT_MODE_QUAT) {
1393  float quat[4];
1394 
1395  /* Calculate the total rotation. */
1396  quat_to_mat3(obmat, td->ext->iquat);
1397  if (use_drot) {
1398  mul_m3_m3m3(obmat, dmat, obmat);
1399  }
1400 
1401  /* mat = transform, obmat = object rotation */
1402  mul_m3_m3m3(fmat, smat, obmat);
1403 
1404  if (use_drot) {
1405  mul_m3_m3m3(fmat, dmat_inv, fmat);
1406  }
1407 
1408  mat3_to_quat(quat, fmat);
1409 
1410  /* apply */
1411  copy_qt_qt(td->ext->quat, quat);
1412  }
1413  else if (td->ext->rotOrder == ROT_MODE_AXISANGLE) {
1414  float axis[3], angle;
1415 
1416  /* Calculate the total rotation. */
1417  axis_angle_to_mat3(obmat, td->ext->irotAxis, td->ext->irotAngle);
1418  if (use_drot) {
1419  mul_m3_m3m3(obmat, dmat, obmat);
1420  }
1421 
1422  /* mat = transform, obmat = object rotation */
1423  mul_m3_m3m3(fmat, smat, obmat);
1424 
1425  if (use_drot) {
1426  mul_m3_m3m3(fmat, dmat_inv, fmat);
1427  }
1428 
1429  mat3_to_axis_angle(axis, &angle, fmat);
1430 
1431  /* apply */
1432  copy_v3_v3(td->ext->rotAxis, axis);
1433  *td->ext->rotAngle = angle;
1434  }
1435  else {
1436  float eul[3];
1437 
1438  /* Calculate the total rotation. */
1439  eulO_to_mat3(obmat, td->ext->irot, td->ext->rotOrder);
1440  if (use_drot) {
1441  mul_m3_m3m3(obmat, dmat, obmat);
1442  }
1443 
1444  /* mat = transform, obmat = object rotation */
1445  mul_m3_m3m3(fmat, smat, obmat);
1446 
1447  if (use_drot) {
1448  mul_m3_m3m3(fmat, dmat_inv, fmat);
1449  }
1450 
1451  mat3_to_compatible_eulO(eul, td->ext->rot, td->ext->rotOrder, fmat);
1452 
1453  /* apply */
1454  copy_v3_v3(td->ext->rot, eul);
1455  }
1456 }
1457 
1459 {
1460  if (!(ob->mode & OB_MODE_ALL_WEIGHT_PAINT)) {
1461  return NULL;
1462  }
1463  /* Important that ob_armature can be set even when its not selected T23412.
1464  * Lines below just check is also visible. */
1465  Object *ob_armature = BKE_modifiers_is_deformed_by_armature(ob);
1466  if (ob_armature && ob_armature->mode & OB_MODE_POSE) {
1467  Base *base_arm = BKE_view_layer_base_find(t->view_layer, ob_armature);
1468  if (base_arm) {
1469  View3D *v3d = t->view;
1470  if (BASE_VISIBLE(v3d, base_arm)) {
1471  return ob_armature;
1472  }
1473  }
1474  }
1475  return NULL;
1476 }
typedef float(TangentPoint)[2]
struct ScrArea * CTX_wm_area(const bContext *C)
Definition: context.c:738
struct Scene * CTX_data_scene(const bContext *C)
Definition: context.c:1090
struct wmWindowManager * CTX_wm_manager(const bContext *C)
Definition: context.c:713
struct ViewLayer * CTX_data_view_layer(const bContext *C)
Definition: context.c:1100
struct bGPdata * CTX_data_gpencil_data(const bContext *C)
Definition: context.c:1445
struct wmMsgBus * CTX_wm_message_bus(const bContext *C)
Definition: context.c:770
struct ARegion * CTX_wm_region(const bContext *C)
Definition: context.c:749
struct Depsgraph * CTX_data_depsgraph_pointer(const bContext *C)
Definition: context.c:1505
struct ToolSettings * CTX_data_tool_settings(const bContext *C)
Definition: context.c:1282
struct wmWindow * CTX_wm_window(const bContext *C)
Definition: context.c:723
struct Base * BKE_view_layer_base_find(struct ViewLayer *view_layer, struct Object *ob)
Definition: layer.c:379
void BKE_mask_coord_from_image(struct Image *image, struct ImageUser *iuser, float r_co[2], const float co[2])
Definition: mask.c:1217
void BKE_mask_coord_from_movieclip(struct MovieClip *clip, struct MovieClipUser *user, float r_co[2], const float co[2])
Definition: mask.c:1200
struct Object * BKE_modifiers_is_deformed_by_armature(struct Object *ob)
struct Paint * BKE_paint_get_active(struct Scene *sce, struct ViewLayer *view_layer)
Definition: paint.c:444
struct Paint * BKE_paint_get_active_from_context(const struct bContext *C)
#define BLI_assert(a)
Definition: BLI_assert.h:46
#define BLI_assert_msg(a, msg)
Definition: BLI_assert.h:53
void void BLI_freelistN(struct ListBase *listbase) ATTR_NONNULL(1)
Definition: listbase.c:466
MINLINE float max_ff(float a, float b)
void copy_m3_m3(float m1[3][3], const float m2[3][3])
Definition: math_matrix.c:71
void unit_m3(float m[3][3])
Definition: math_matrix.c:40
void copy_m3_m4(float m1[3][3], const float m2[4][4])
Definition: math_matrix.c:87
void invert_m3_m3_safe_ortho(float Ainv[3][3], const float A[3][3])
Definition: math_matrix.c:3199
void normalize_m3(float R[3][3]) ATTR_NONNULL()
Definition: math_matrix.c:1912
void mul_m4_v3(const float M[4][4], float r[3])
Definition: math_matrix.c:729
bool invert_m3_m3(float R[3][3], const float A[3][3])
Definition: math_matrix.c:1180
void mul_v3_m4v3(float r[3], const float M[4][4], const float v[3])
Definition: math_matrix.c:739
void mul_m3_m3m3(float R[3][3], const float A[3][3], const float B[3][3])
Definition: math_matrix.c:388
void eulO_to_mat3(float mat[3][3], const float eul[3], short order)
void mat3_to_compatible_eulO(float eul[3], const float old[3], short order, const float mat[3][3])
void mat3_to_quat(float q[4], const float mat[3][3])
float normalize_qt_qt(float r[4], const float q[4])
void mat3_to_axis_angle(float axis[3], float *angle, const float M[3][3])
void copy_qt_qt(float q[4], const float a[4])
Definition: math_rotation.c:33
void quat_to_mat3(float mat[3][3], const float q[4])
void axis_angle_to_mat3(float R[3][3], const float axis[3], float angle)
MINLINE void copy_v4_v4(float r[4], const float a[4])
void minmax_v3v3_v3(float min[3], float max[3], const float vec[3])
Definition: math_vector.c:867
MINLINE float normalize_v3(float r[3])
MINLINE void mul_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_v2_v2_int(int r[2], const int a[2])
MINLINE void copy_v3_v3(float r[3], const float a[3])
MINLINE bool is_zero_v3(const float a[3]) ATTR_WARN_UNUSED_RESULT
MINLINE void add_v3_v3v3(float r[3], const float a[3], const float b[3])
void mid_v3_v3v3(float r[3], const float a[3], const float b[3])
Definition: math_vector.c:237
MINLINE void zero_v3(float r[3])
MINLINE void add_v3_v3(float r[3], const float a[3])
MINLINE float len_v3(const float a[3]) ATTR_WARN_UNUSED_RESULT
Random number functions.
void BLI_rng_free(struct RNG *rng) ATTR_NONNULL(1)
Definition: rand.cc:58
struct RNG * BLI_rng_new(unsigned int seed)
Definition: rand.cc:39
float BLI_rng_get_float(struct RNG *rng) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(1)
Definition: rand.cc:93
BLI_INLINE int BLI_rcti_size_x(const struct rcti *rct)
Definition: BLI_rect.h:186
BLI_INLINE float BLI_rctf_size_x(const struct rctf *rct)
Definition: BLI_rect.h:194
BLI_INLINE float BLI_rctf_size_y(const struct rctf *rct)
Definition: BLI_rect.h:198
char * BLI_strncpy(char *__restrict dst, const char *__restrict src, size_t maxncpy) ATTR_NONNULL()
Definition: string.c:64
unsigned char uchar
Definition: BLI_sys_types.h:70
unsigned int uint
Definition: BLI_sys_types.h:67
#define INIT_MINMAX(min, max)
#define ARRAY_SIZE(arr)
#define SET_FLAG_FROM_TEST(value, test, flag)
#define ELEM(...)
#define IFACE_(msgid)
@ ROT_MODE_QUAT
@ ROT_MODE_AXISANGLE
@ BRUSH_CURVE
#define GPENCIL_EDIT_MODE(gpd)
@ BASE_SELECTED
#define OB_MODE_ALL_PAINT
#define OB_MODE_ALL_WEIGHT_PAINT
eObjectMode
@ OB_MODE_EDIT_GPENCIL
@ OB_MODE_EDIT
@ OB_MODE_POSE
@ OB_MODE_OBJECT
@ OB_SURF
@ OB_MESH
@ OB_CURVES_LEGACY
@ OB_GPENCIL
#define PROP_RANDOM
@ SCE_XFORM_AXIS_ALIGN
#define PROP_LIN
@ AUTO_MERGE
@ AUTO_MERGE_AND_SPLIT
#define PROP_SPHERE
#define UVCALC_TRANSFORM_CORRECT_SLIDE
#define BASACT(_view_layer)
#define OBACT(_view_layer)
@ SCE_ORIENT_DEFAULT
#define PROP_SMOOTH
@ PROP_EDIT_PROJECTED
@ PROP_EDIT_USE
@ PROP_EDIT_CONNECTED
#define PROP_ROOT
#define PROP_INVSQUARE
#define PROP_CONST
#define PROP_SHARP
#define BASE_VISIBLE(v3d, base)
@ RGN_TYPE_WINDOW
@ RGN_TYPE_PREVIEW
@ SI_LIVE_UNWRAP
@ SPACE_CLIP
@ SPACE_ACTION
@ SPACE_NODE
@ SPACE_SEQ
@ SPACE_EMPTY
@ SPACE_IMAGE
@ SPACE_GRAPH
@ SPACE_VIEW3D
@ SIPO_MODE_DRIVERS
@ SI_MODE_PAINT
@ SI_MODE_MASK
@ USER_RELEASECONFIRM
@ V3D_AROUND_ACTIVE
@ V3D_AROUND_CENTER_BOUNDS
@ V3D_AROUND_CURSOR
@ V3D_AROUND_CENTER_MEDIAN
@ V3D_AROUND_LOCAL_ORIGINS
@ V3D_ORIENT_CUSTOM
@ V3D_ORIENT_GLOBAL
@ V3D_ORIENT_CUSTOM_MATRIX
@ V3D_ORIENT_LOCAL
@ V3D_ORIENT_VIEW
bool ED_space_clip_check_show_trackedit(struct SpaceClip *sc)
Definition: clip_editor.c:546
bool ED_space_clip_check_show_maskedit(struct SpaceClip *sc)
Definition: clip_editor.c:555
bool ED_space_image_show_uvedit(const struct SpaceImage *sima, struct Object *obedit)
void initNumInput(NumInput *n)
Definition: numinput.c:69
bool ED_object_calc_active_center_for_posemode(struct Object *ob, bool select_only, float r_center[3])
Definition: object_utils.c:100
bool ED_object_calc_active_center_for_editmode(struct Object *obedit, bool select_only, float r_center[3])
Definition: object_utils.c:41
bScreen * ED_screen_animation_playing(const struct wmWindowManager *wm)
bool ED_region_draw_cb_exit(struct ARegionType *art, void *handle)
Definition: spacetypes.c:241
@ TFM_RESIZE
Definition: ED_transform.h:32
@ TFM_SHRINKFATTEN
Definition: ED_transform.h:37
@ TFM_BEND
Definition: ED_transform.h:36
@ TFM_ROTATION
Definition: ED_transform.h:31
@ TFM_BWEIGHT
Definition: ED_transform.h:57
@ TFM_EDGE_CREASE
Definition: ED_transform.h:41
@ TFM_TRANSLATION
Definition: ED_transform.h:30
@ TFM_TRACKBALL
Definition: ED_transform.h:39
int BIF_countTransformOrientation(const struct bContext *C)
void ED_uvedit_live_unwrap_end(short cancel)
@ V3D_PROJ_TEST_NOP
Definition: ED_view3d.h:234
eV3DProjStatus ED_view3d_project_float_global(const struct ARegion *region, const float co[3], float r_co[2], eV3DProjTest flag)
@ V3D_PROJ_RET_OK
Definition: ED_view3d.h:217
float ED_view3d_calc_zfac(const struct RegionView3D *rv3d, const float co[3])
NSNotificationCenter * center
void immUnbindProgram(void)
void immBindBuiltinProgram(eGPUBuiltinShader shader_id)
void immUniformColor3ubv(const unsigned char rgb[3])
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 type
_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
_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 v1
void GPU_matrix_pop(void)
Definition: gpu_matrix.cc:126
void GPU_matrix_push(void)
Definition: gpu_matrix.cc:119
@ GPU_PRIM_LINES
Definition: GPU_primitive.h:20
@ GPU_SHADER_3D_UNIFORM_COLOR
Definition: GPU_shader.h:230
@ 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.
#define MEM_SAFE_FREE(v)
Platform independent time functions.
#define C
Definition: RandGen.cpp:25
void UI_make_axis_color(const unsigned char src_col[3], unsigned char dst_col[3], char axis)
Definition: resources.c:1462
@ TH_GRID
Definition: UI_resources.h:68
void UI_GetThemeColor3ubv(int colorid, unsigned char col[3])
Definition: resources.c:1323
float UI_view2d_view_to_region_x(const struct View2D *v2d, float x)
float UI_view2d_view_to_region_y(const struct View2D *v2d, float y)
ATTR_WARN_UNUSED_RESULT const BMVert * v2
unsigned int U
Definition: btGjkEpa3.h:78
SIMD_FORCE_INLINE btScalar angle(const btVector3 &v) const
Return the angle between this and another vector.
Definition: btVector3.h:356
CCL_NAMESPACE_BEGIN struct Options options
Scene scene
uint pos
uint col
#define UINT_MAX
Definition: hash_md5.c:43
void(* MEM_freeN)(void *vmemh)
Definition: mallocn.c:27
void *(* MEM_callocN)(size_t len, const char *str)
Definition: mallocn.c:31
MINLINE void zero_v2_int(int r[2])
#define sqrtf(x)
Definition: metal/compat.h:243
static unsigned a[3]
Definition: RandGen.cpp:78
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:2767
bool RNA_property_array_check(PropertyRNA *prop)
Definition: rna_access.c:1080
void RNA_property_float_get_array(PointerRNA *ptr, PropertyRNA *prop, float *values)
Definition: rna_access.c:2879
bool RNA_property_is_set(PointerRNA *ptr, PropertyRNA *prop)
Definition: rna_access.c:5271
void RNA_property_boolean_get_array(PointerRNA *ptr, PropertyRNA *prop, bool *values)
Definition: rna_access.c:2242
PropertyRNA * RNA_struct_find_property(PointerRNA *ptr, const char *identifier)
Definition: rna_access.c:717
bool RNA_property_boolean_get(PointerRNA *ptr, PropertyRNA *prop)
Definition: rna_access.c:2153
void RNA_property_boolean_set(PointerRNA *ptr, PropertyRNA *prop, bool value)
Definition: rna_access.c:2180
int RNA_property_enum_get(PointerRNA *ptr, PropertyRNA *prop)
Definition: rna_access.c:3402
bool RNA_boolean_get(PointerRNA *ptr, const char *name)
Definition: rna_access.c:4863
int SEQ_tool_settings_pivot_point_get(Scene *scene)
Definition: sequencer.c:382
#define min(a, b)
Definition: sort.c:35
#define TRANS_DATA_CONTAINER_FIRST_OK(t)
void transform_input_update(TransInfo *t, const float fac)
#define TRANS_DATA_CONTAINER_FIRST_SINGLE(t)
#define FOREACH_TRANS_DATA_CONTAINER(t, th)
void SEQ_image_preview_unit_to_px(const Scene *scene, const float co_src[2], float co_dst[2])
short regiontype
short flag
float vec[3][3]
struct PaintCurve * paint_curve
float obmat[4][4]
PaintCurvePoint * points
struct Brush * brush
struct ToolSettings * toolsettings
struct RenderData r
struct MovieClipUser user
float cursor[2]
struct MovieClip * clip
float cursor[2]
struct ImageUser iuser
struct Image * image
float cursor[2]
struct ImagePaintSettings imapaint
void(* free_cb)(struct TransInfo *, struct TransDataContainer *tc, struct TransCustomData *custom_data)
float ih2[2]
float ih1[2]
TransDataCurveHandleFlags * hdata
float smtx[3][3]
float mtx[3][3]
TransDataExtension * ext
float * val
float clip_end
struct wmTimer * animtimer
int mval[2]
Definition: WM_types.h:684
struct ReportList * reports
struct PointerRNA * ptr
long int PIL_check_seconds_timer_i(void)
Definition: time.c:74
void setTransformViewAspect(TransInfo *t, float r_aspect[3])
Definition: transform.c:98
bool transdata_check_local_islands(TransInfo *t, short around)
Definition: transform.c:64
void setTransformViewMatrices(TransInfo *t)
Definition: transform.c:74
void projectFloatView(TransInfo *t, const float vec[3], float adr[2])
Definition: transform.c:366
void recalcData(TransInfo *t)
conversion and adaptation of different datablocks to a common struct.
@ TD_BEZTRIPLE
@ TD_NOTCONNECTED
@ TD_NO_EXT
@ TD_SELECTED
@ TD_NOCENTER
static int t_around_get(TransInfo *t)
Object * transform_object_deform_pose_armature_get(const TransInfo *t, Object *ob)
void calculateCenter(TransInfo *t)
void postTrans(bContext *C, TransInfo *t)
bool calculateCenterActive(TransInfo *t, bool select_only, float r_center[3])
void transform_data_ext_rotate(TransData *td, float mat[3][3], bool use_drot)
void initTransInfo(bContext *C, TransInfo *t, wmOperator *op, const wmEvent *event)
void calculateCenterCursor2D(TransInfo *t, float r_center[2])
static void * t_view_get(TransInfo *t)
static void transdata_restore_basic(TransDataBasic *td_basic)
void resetTransRestrictions(TransInfo *t)
void calculateCenter2D(TransInfo *t)
static void calculateZfac(TransInfo *t)
void calculateCenterCursorGraph2D(TransInfo *t, float r_center[2])
static void freeTransCustomDataContainer(TransInfo *t, TransDataContainer *tc, TransCustomDataContainer *tcdc)
void calculateCenterMedian(TransInfo *t, float r_center[3])
static void restoreElement(TransData *td)
static void freeTransCustomData(TransInfo *t, TransDataContainer *tc, TransCustomData *custom_data)
static void calculateCenter_FromAround(TransInfo *t, int around, float r_center[3])
void calculateCenterCursor(TransInfo *t, float r_center[3])
void resetTransModal(TransInfo *t)
void restoreTransObjects(TransInfo *t)
static bool transdata_center_global_get(const TransDataContainer *tc, const TransDataBasic *td_basic, float r_vec[3])
void calculatePropRatio(TransInfo *t)
void applyTransObjects(TransInfo *t)
void drawLine(TransInfo *t, const float center[3], const float dir[3], char axis, short options)
void tranformViewUpdate(TransInfo *t)
void calculateCenterLocal(TransInfo *t, const float center_global[3])
void freeTransCustomDataForMode(TransInfo *t)
void calculateCenterBound(TransInfo *t, float r_center[3])
float max
transform modes used by different operators.
void transform_orientations_current_set(TransInfo *t, const short orient_index)
short transform_orientation_matrix_get(bContext *C, TransInfo *t, short orient_index, const float custom[3][3], float r_spacemtx[3][3])
void freeSnapping(TransInfo *t)
#define N_(msgid)
void WM_cursor_modal_restore(wmWindow *win)
Definition: wm_cursors.c:200
void WM_event_drag_start_mval(const wmEvent *event, const ARegion *region, int r_mval[2])
#define ISMOUSE_BUTTON(event_type)
bool WM_paint_cursor_end(wmPaintCursor *handle)