Blender V5.3
editors/transform/transform.cc
Go to the documentation of this file.
1/* SPDX-FileCopyrightText: 2001-2002 NaN Holding BV. All rights reserved.
2 *
3 * SPDX-License-Identifier: GPL-2.0-or-later */
4
8
9#include "BLI_listbase.hh"
10#include "BLI_math_matrix_c.hh"
11#include "BLI_math_vector_c.hh"
12#include "BLI_rect.hh"
13
14#include "BKE_camera.h"
15#include "BKE_context.hh"
16#include "BKE_editmesh.hh"
17#include "BKE_global.hh"
18#include "BKE_layer.hh"
19#include "BKE_mask.hh"
20#include "BKE_screen.hh"
21#include "BKE_workspace.hh"
22
23#include "GPU_state.hh"
24
25#include "ED_clip.hh"
26#include "ED_image.hh"
27#include "ED_screen.hh"
28#include "ED_space_api.hh"
29#include "ED_uvedit.hh"
30
31#include "ANIM_keyframing.hh"
32
33#include "SEQ_sequencer.hh"
34#include "SEQ_transform.hh"
35
36#include "WM_api.hh"
37#include "WM_message.hh"
38
39#include "UI_interface_icons.hh"
40#include "UI_resources.hh"
41#include "UI_view2d.hh"
42
43#include "RNA_access.hh"
44
45#include "BLF_api.hh"
46#include "BLT_translation.hh"
47
48#include "transform.hh"
50#include "transform_convert.hh"
52#include "transform_gizmo.hh"
53#include "transform_mode.hh"
55#include "transform_snap.hh"
56
57/* Disabling, since when you type you know what you are doing,
58 * and being able to set it to zero is handy. */
59// #define USE_NUM_NO_ZERO.
60
61namespace blender::ed::transform {
62
63/* -------------------------------------------------------------------- */
66
67void transform_view_vector_calc(const TransInfo *t, const float focus[3], float r_vec[3])
68{
69 if (t->persp != RV3D_ORTHO) {
70 sub_v3_v3v3(r_vec, t->viewinv[3], focus);
71 }
72 else {
73 copy_v3_v3(r_vec, t->viewinv[2]);
74 }
75 normalize_v3(r_vec);
76}
77
79{
81 return false;
82 }
83 return ((around == V3D_AROUND_LOCAL_ORIGINS) &&
85}
86
88
89/* -------------------------------------------------------------------- */
92
94{
95 if (!(t->options & CTX_PAINT_CURVE) && (t->spacetype == SPACE_VIEW3D) && t->region &&
97 {
98 RegionView3D *rv3d = static_cast<RegionView3D *>(t->region->regiondata);
99
100 copy_m4_m4(t->viewmat, rv3d->viewmat);
101 copy_m4_m4(t->viewinv, rv3d->viewinv);
102 copy_m4_m4(t->persmat, rv3d->persmat);
103 copy_m4_m4(t->persinv, rv3d->persinv);
104 t->persp = rv3d->persp;
105 }
106 else {
107 unit_m4(t->viewmat);
108 unit_m4(t->viewinv);
109 unit_m4(t->persmat);
110 unit_m4(t->persinv);
111 t->persp = RV3D_ORTHO;
112 }
113
115}
116
117void setTransformViewAspect(TransInfo *t, float r_aspect[3])
118{
119 copy_v3_fl(r_aspect, 1.0f);
120
121 if (t->spacetype == SPACE_IMAGE) {
122 SpaceImage *sima = t->area->spacedata.first_as<SpaceImage>();
123
124 if (t->options & CTX_MASK) {
125 ED_space_image_get_aspect(sima, &r_aspect[0], &r_aspect[1]);
126 }
127 else if (t->options & CTX_PAINT_CURVE) {
128 /* Pass. */
129 }
130 else {
131 ED_space_image_get_uv_aspect(sima, &r_aspect[0], &r_aspect[1]);
132 }
133 }
134 else if (t->spacetype == SPACE_SEQ) {
135 if (t->options & CTX_CURSOR) {
137 const float2 aspect = seq::image_preview_unit_to_px(scene, r_aspect);
138 copy_v2_v2(r_aspect, aspect);
139 }
140 }
141 else if (t->spacetype == SPACE_CLIP) {
142 SpaceClip *sclip = t->area->spacedata.first_as<SpaceClip>();
143
144 if (t->options & CTX_MOVIECLIP) {
145 ED_space_clip_get_aspect_dimension_aware(sclip, &r_aspect[0], &r_aspect[1]);
146 }
147 else {
148 ED_space_clip_get_aspect(sclip, &r_aspect[0], &r_aspect[1]);
149 }
150 }
151 else if (t->spacetype == SPACE_GRAPH) {
152 /* Depends on context of usage. */
153 }
154}
155
156static void convertViewVec2D(View2D *v2d, float r_vec[3], int dx, int dy)
157{
158 float divx = BLI_rcti_size_x(&v2d->mask);
159 float divy = BLI_rcti_size_y(&v2d->mask);
160
161 r_vec[0] = BLI_rctf_size_x(&v2d->cur) * dx / divx;
162 r_vec[1] = BLI_rctf_size_y(&v2d->cur) * dy / divy;
163 r_vec[2] = 0.0f;
164}
165
166static void convertViewVec2D_mask(View2D *v2d, float r_vec[3], int dx, int dy)
167{
168 float divx = BLI_rcti_size_x(&v2d->mask);
169 float divy = BLI_rcti_size_y(&v2d->mask);
170
171 float mulx = BLI_rctf_size_x(&v2d->cur);
172 float muly = BLI_rctf_size_y(&v2d->cur);
173
174 /* Difference with #convertViewVec2D. */
175 /* Clamp w/h, mask only. */
176 if (mulx / divx < muly / divy) {
177 divy = divx;
178 muly = mulx;
179 }
180 else {
181 divx = divy;
182 mulx = muly;
183 }
184 /* End difference. */
185
186 r_vec[0] = mulx * dx / divx;
187 r_vec[1] = muly * dy / divy;
188 r_vec[2] = 0.0f;
189}
190
191void convertViewVec(TransInfo *t, float r_vec[3], double dx, double dy)
192{
193 if ((t->spacetype == SPACE_VIEW3D) && (t->region->regiontype == RGN_TYPE_WINDOW)) {
194 if (t->options & CTX_PAINT_CURVE) {
195 r_vec[0] = dx;
196 r_vec[1] = dy;
197 }
198 else {
199 const float xy_delta[2] = {float(dx), float(dy)};
200 ED_view3d_win_to_delta(t->region, xy_delta, t->zfac, r_vec);
201 }
202 }
203 else if (t->spacetype == SPACE_IMAGE) {
204 if (t->options & CTX_MASK) {
205 convertViewVec2D_mask(static_cast<View2D *>(t->view), r_vec, dx, dy);
206 }
207 else if (t->options & CTX_PAINT_CURVE) {
208 r_vec[0] = dx;
209 r_vec[1] = dy;
210 }
211 else {
212 convertViewVec2D(static_cast<View2D *>(t->view), r_vec, dx, dy);
213 }
214
215 r_vec[0] *= t->aspect[0];
216 r_vec[1] *= t->aspect[1];
217 }
218 else if (ELEM(t->spacetype, SPACE_GRAPH, SPACE_NLA)) {
219 convertViewVec2D(static_cast<View2D *>(t->view), r_vec, dx, dy);
220 }
221 else if (ELEM(t->spacetype, SPACE_NODE, SPACE_SEQ)) {
222 convertViewVec2D(&t->region->v2d, r_vec, dx, dy);
223 }
224 else if (t->spacetype == SPACE_CLIP) {
225 if (t->options & CTX_MASK) {
226 convertViewVec2D_mask(static_cast<View2D *>(t->view), r_vec, dx, dy);
227 }
228 else {
229 convertViewVec2D(static_cast<View2D *>(t->view), r_vec, dx, dy);
230 }
231
232 r_vec[0] *= t->aspect[0];
233 r_vec[1] *= t->aspect[1];
234 }
235 else {
236 printf("%s: called in an invalid context\n", __func__);
237 zero_v3(r_vec);
238 }
239}
240
242{
243 const ARegion *region = t->region;
244
245 if (region == nullptr) [[unlikely]] {
246 /* While this function probably wont be calved without a region.
247 * Doing so shouldn't cause errors. */
248 adr[0] = 0.0f;
249 adr[1] = 0.0f;
250 return;
251 }
252
253 bool changed = false;
254 switch (t->spacetype) {
255 case SPACE_VIEW3D: {
256 if (region->regiontype == RGN_TYPE_WINDOW) {
257 /* NOTE(@ideasman42): When picking a fallback there isn't a "correct" location.
258 * By default the region center is the fallback, use this unless there is a reason not to.
259 *
260 * One exception is when transforming the camera from the camera viewpoint.
261 * In this case it's logical to use the camera frames center, see: #141663. */
262 if (t->options & CTX_CAMERA) {
263 const View3D *v3d = static_cast<View3D *>(t->view);
264 const RegionView3D *rv3d = static_cast<RegionView3D *>(region->regiondata);
265 if (rv3d->persp == RV3D_CAMOB && v3d->camera) {
266 /* Exclude any camera "shift" because the un-shifted point is the pivot.
267 *
268 * This may not be the case when transforming a cameras parent however
269 * in these situations it's not practical to find a screen space location
270 * for a 3D point that couldn't be projected. */
271 const bool no_shift = true;
272 rctf viewborder = {0};
273 viewborder = BKE_camera_view_border(t->scene,
274 t->depsgraph,
275 v3d,
276 rv3d,
277 region->winx,
278 region->winy,
279 no_shift,
280 false,
281 true);
282 adr[0] = BLI_rctf_cent_x(&viewborder);
283 adr[1] = BLI_rctf_cent_y(&viewborder);
284 changed = true;
285 }
286 }
287 }
288 break;
289 }
290 }
291
292 if (changed == false) {
293 adr[0] = region->winx / 2.0f;
294 adr[1] = region->winy / 2.0f;
295 }
296}
297
298void projectIntViewEx(TransInfo *t, const float vec[3], int adr[2], const eV3DProjTest flag)
299{
300 if (t->spacetype == SPACE_VIEW3D) {
301 if (t->region->regiontype == RGN_TYPE_WINDOW) {
302 if (ED_view3d_project_int_global(t->region, vec, adr, flag) != V3D_PROJ_RET_OK) {
303 /* This is what was done in 2.64, perhaps we can be smarter? */
304 adr[0] = int(2140000000.0f);
305 adr[1] = int(2140000000.0f);
306 }
307 }
308 }
309 else if (t->spacetype == SPACE_IMAGE) {
310 SpaceImage *sima = t->area->spacedata.first_as<SpaceImage>();
311
312 if (t->options & CTX_MASK) {
313 float v[2];
314
315 v[0] = vec[0] / t->aspect[0];
316 v[1] = vec[1] / t->aspect[1];
317
318 BKE_mask_coord_to_image(sima->image, &sima->iuser, v, v);
319
321
322 adr[0] = v[0];
323 adr[1] = v[1];
324 }
325 else if (t->options & CTX_PAINT_CURVE) {
326 adr[0] = vec[0];
327 adr[1] = vec[1];
328 }
329 else {
330 if (t->view) {
331 const float v[2] = {
332 vec[0] / t->aspect[0],
333 vec[1] / t->aspect[1],
334 };
336 static_cast<const View2D *>(t->view), v[0], v[1], &adr[0], &adr[1]);
337 }
338 else {
339 adr[0] = 0;
340 adr[1] = 0;
341 }
342 }
343 }
344 else if (t->spacetype == SPACE_ACTION) {
345 int out[2] = {0, 0};
346#if 0
347 SpaceAction *sact = t->area->spacedata.first;
348
349 if (sact->flag & SACTION_DRAWTIME) {
350 // vec[0] = vec[0] / ((t->scene->r.frs_sec / t->scene->r.frs_sec_base));
351 /* Same as below. */
352 ui::view2d_view_to_region((View2D *)t->view, vec[0], vec[1], &out[0], &out[1]);
353 }
354 else
355#endif
356 if (t->view) {
357 ui::view2d_view_to_region(static_cast<View2D *>(t->view), vec[0], vec[1], &out[0], &out[1]);
358 }
359
360 adr[0] = out[0];
361 adr[1] = out[1];
362 }
363 else if (ELEM(t->spacetype, SPACE_GRAPH, SPACE_NLA)) {
364 int out[2] = {0, 0};
365 if (t->view) {
366 ui::view2d_view_to_region(static_cast<View2D *>(t->view), vec[0], vec[1], &out[0], &out[1]);
367 }
368 adr[0] = out[0];
369 adr[1] = out[1];
370 }
371 else if (t->spacetype == SPACE_SEQ) { /* XXX not tested yet, but should work. */
372 int out[2] = {0, 0};
373 if (t->view) {
374 ui::view2d_view_to_region(static_cast<View2D *>(t->view), vec[0], vec[1], &out[0], &out[1]);
375 }
376 adr[0] = out[0];
377 adr[1] = out[1];
378 }
379 else if (t->spacetype == SPACE_CLIP) {
380 SpaceClip *sc = t->area->spacedata.first_as<SpaceClip>();
381
382 if (t->options & CTX_MASK) {
384
385 if (clip) {
386 float v[2];
387
388 v[0] = vec[0] / t->aspect[0];
389 v[1] = vec[1] / t->aspect[1];
390
392
394
395 adr[0] = v[0];
396 adr[1] = v[1];
397 }
398 else {
399 adr[0] = 0;
400 adr[1] = 0;
401 }
402 }
403 else if (t->options & CTX_MOVIECLIP) {
404 if (t->view) {
405 const float v[2] = {
406 vec[0] / t->aspect[0],
407 vec[1] / t->aspect[1],
408 };
410 static_cast<const View2D *>(t->view), v[0], v[1], &adr[0], &adr[1]);
411 }
412 else {
413 adr[0] = 0;
414 adr[1] = 0;
415 }
416 }
417 else {
418 BLI_assert(0);
419 }
420 }
421 else if (t->spacetype == SPACE_NODE) {
422 if (t->view) {
423 ui::view2d_view_to_region(static_cast<View2D *>(t->view), vec[0], vec[1], &adr[0], &adr[1]);
424 }
425 else {
426 adr[0] = 0;
427 adr[1] = 0;
428 }
429 }
430}
431void projectIntView(TransInfo *t, const float vec[3], int adr[2])
432{
434}
435
436void projectFloatViewEx(TransInfo *t, const float vec[3], float adr[2], const eV3DProjTest flag)
437{
438 switch (t->spacetype) {
439 case SPACE_VIEW3D: {
440 if (t->options & CTX_PAINT_CURVE) {
441 adr[0] = vec[0];
442 adr[1] = vec[1];
443 }
444 else if (t->region->regiontype == RGN_TYPE_WINDOW) {
445 /* Allow points behind the view #33643. */
446 if (ED_view3d_project_float_global(t->region, vec, adr, flag) != V3D_PROJ_RET_OK) {
447 /* XXX, 2.64 and prior did this, weak! */
449 }
450 return;
451 }
452 break;
453 }
454 default: {
455 int a[2] = {0, 0};
456 projectIntView(t, vec, a);
457 adr[0] = a[0];
458 adr[1] = a[1];
459 break;
460 }
461 }
462}
463void projectFloatView(TransInfo *t, const float vec[3], float adr[2])
464{
466}
467
468void applyAspectRatio(TransInfo *t, float vec[2])
469{
470 if ((t->spacetype == SPACE_IMAGE) && (t->mode == TFM_TRANSLATION) &&
471 !(t->options & CTX_PAINT_CURVE))
472 {
473 SpaceImage *sima = t->area->spacedata.first_as<SpaceImage>();
474
475 if ((sima->flag & SI_COORDFLOATS) == 0) {
476 int width, height;
477 ED_space_image_get_size(sima, &width, &height);
478
479 vec[0] *= width;
480 vec[1] *= height;
481 }
482
483 vec[0] /= t->aspect[0];
484 vec[1] /= t->aspect[1];
485 }
486 else if ((t->spacetype == SPACE_CLIP) && (t->mode == TFM_TRANSLATION)) {
487 if (t->options & (CTX_MOVIECLIP | CTX_MASK)) {
488 vec[0] /= t->aspect[0];
489 vec[1] /= t->aspect[1];
490 }
491 }
492}
493
494void removeAspectRatio(TransInfo *t, float vec[2])
495{
496 if ((t->spacetype == SPACE_IMAGE) && (t->mode == TFM_TRANSLATION)) {
497 SpaceImage *sima = t->area->spacedata.first_as<SpaceImage>();
498
499 if ((sima->flag & SI_COORDFLOATS) == 0) {
500 int width, height;
501 ED_space_image_get_size(sima, &width, &height);
502
503 vec[0] /= width;
504 vec[1] /= height;
505 }
506
507 vec[0] *= t->aspect[0];
508 vec[1] *= t->aspect[1];
509 }
510 else if ((t->spacetype == SPACE_CLIP) && (t->mode == TFM_TRANSLATION)) {
511 if (t->options & (CTX_MOVIECLIP | CTX_MASK)) {
512 vec[0] *= t->aspect[0];
513 vec[1] *= t->aspect[1];
514 }
515 }
516}
517
518static void viewRedrawForce(const bContext *C, TransInfo *t)
519{
520 if (t->options & CTX_GPENCIL_STROKES) {
521 if (t->obedit_type == OB_GREASE_PENCIL) {
523 }
524 }
525 else if (t->spacetype == SPACE_VIEW3D) {
526 if (t->options & CTX_PAINT_CURVE) {
527 wmWindow *window = CTX_wm_window(C);
529 }
530 else {
531 /* Do we need more refined tags? */
532 if (t->options & CTX_POSE_BONE) {
534 }
535 else {
537 }
538
539 /* For real-time animation record - send notifiers recognized by animation editors. */
540 /* XXX: is this notifier a lame duck? */
541 if ((t->animtimer) && animrig::is_autokey_on(t->scene)) {
543 }
544 }
545 }
546 else if (t->spacetype == SPACE_ACTION) {
547 // SpaceAction *saction = (SpaceAction *)t->area->spacedata.first;
549 }
550 else if (t->spacetype == SPACE_GRAPH) {
551 // SpaceGraph *sipo = (SpaceGraph *)t->area->spacedata.first;
553 }
554 else if (t->spacetype == SPACE_NLA) {
556 }
557 else if (t->spacetype == SPACE_NODE) {
558 // ED_area_tag_redraw(t->area);
560 }
561 else if (t->spacetype == SPACE_SEQ) {
563 /* Key-frames on strips has been moved, so make sure related editors are informed. */
565 }
566 else if (t->spacetype == SPACE_IMAGE) {
567 if (t->options & CTX_MASK) {
569
571 }
572 else if (t->options & CTX_PAINT_CURVE) {
573 wmWindow *window = CTX_wm_window(C);
575 }
576 else if (t->options & CTX_CURSOR) {
578 }
579 else {
580 /* XXX how to deal with lock? */
581 SpaceImage *sima = t->area->spacedata.first_as<SpaceImage>();
582 if (sima->lock) {
585 if (ob->type == OB_MESH) {
587 }
588 }
589 }
590 else {
592 }
593 }
594 }
595 else if (t->spacetype == SPACE_CLIP) {
596 SpaceClip *sc = t->area->spacedata.first_as<SpaceClip>();
597
600
601 /* Objects could be parented to tracking data, so send this for viewport refresh. */
603
605 }
608
610 }
611 }
612}
613
615{
616 ED_area_status_text(t->area, nullptr);
617 WorkSpace *workspace = CTX_wm_workspace(C);
618 if (workspace) {
620 }
621
622 if (t->spacetype == SPACE_VIEW3D) {
623 /* If auto-keying is enabled, send notifiers that keyframes were added. */
626 }
627
628 /* Redraw UV editor. */
629 const char uvcalc_correct_flag = ELEM(t->mode, TFM_VERT_SLIDE, TFM_EDGE_SLIDE) ?
632
633 if ((t->data_type == &TransConvertType_Mesh) &&
634 (t->settings->uvcalc_flag & uvcalc_correct_flag))
635 {
637 }
638 }
639}
640
642
643/* -------------------------------------------------------------------- */
646
647static bool transform_modal_item_poll(const wmOperator *op, int value)
648{
649 const TransInfo *t = static_cast<const TransInfo *>(op->customdata);
651 if (value == TFM_MODAL_EDIT_SNAP_SOURCE_OFF) {
652 return true;
653 }
654 if (!ELEM(
656 {
657 return false;
658 }
659 }
660
661 switch (value) {
662 case TFM_MODAL_CANCEL: {
663 /* TODO: Canceling with LMB is not possible when the operator is activated
664 * through tweak and the LMB is pressed.
665 * Therefore, this item should not appear in the status bar. */
666 break;
667 }
671 if ((t->flag & T_PROP_EDIT) == 0) {
672 return false;
673 }
674 break;
675 }
679 return false;
680 }
681 if (value == TFM_MODAL_ADD_SNAP) {
682 if (!(t->tsnap.status & SNAP_TARGET_FOUND)) {
683 return false;
684 }
685 }
686 else {
687 if (!t->tsnap.selectedPoint) {
688 return false;
689 }
690 }
691 break;
692 }
693 case TFM_MODAL_AXIS_Z:
698 if (t->flag & T_2D_EDIT) {
699 return false;
700 }
701 [[fallthrough]];
702 case TFM_MODAL_AXIS_X:
703 case TFM_MODAL_AXIS_Y:
705 if (t->flag & T_NO_CONSTRAINT) {
706 return false;
707 }
708 break;
709 case TFM_MODAL_CONS_OFF: {
710 if ((t->con.mode & CON_APPLY) == 0) {
711 return false;
712 }
713 break;
714 }
719 if (t->spacetype != SPACE_NODE) {
720 return false;
721 }
722 break;
723 }
726 if ((t->flag & T_AUTOIK) == 0) {
727 return false;
728 }
729 break;
730 }
732 case TFM_MODAL_ROTATE:
733 case TFM_MODAL_RESIZE:
738 return false;
739 }
740 if (value == TFM_MODAL_TRANSLATE && t->mode == TFM_TRANSLATION) {
741 /* The tracking transform in MovieClip has an alternate translate that modifies the offset
742 * of the tracks. */
744 }
745 if (value == TFM_MODAL_ROTATE && t->mode == TFM_ROTATION) {
746 return false;
747 }
748 if (value == TFM_MODAL_RESIZE && t->mode == TFM_RESIZE) {
749 /* The tracking transform in MovieClip has an alternate resize that only affects the
750 * tracker size and not the search area. */
752 }
753 if (value == TFM_MODAL_VERT_EDGE_SLIDE &&
755 /* WORKAROUND: Avoid repeated keys in status bar.
756 *
757 * Previously, `Vert/Edge Slide` and `Move` were triggered by the same modal key.
758 * But now, to fix #100129 (Status bar incorrectly shows "[G] Move"), `Vert/Edge Slide`
759 * has its own modal key. However by default it uses the same key as `Move` (G). So, to
760 * avoid displaying the same key twice (G and G), only display this modal key during the
761 * `Move` operation.
762 *
763 * Ideally we should check if it really uses the same key. */
764 t->mode != TFM_TRANSLATION))
765 {
766 return false;
767 }
768 if (value == TFM_MODAL_TRACKBALL &&
769 /* WORKAROUND: Avoid repeated keys in status bar.
770 *
771 * Previously, `Trackball` and `Rotate` were triggered by the same modal key.
772 * But to fix the status bar incorrectly showing "[R] Rotate", `Trackball` has now its
773 * own modal key. However by default it uses the same key as `Rotate` (R). So, to avoid
774 * displaying the same key twice (R and R), only display this modal key during the
775 * `Rotate` operation.
776 *
777 * Ideally we should check if it really uses the same key. */
778 t->mode != TFM_ROTATION)
779 {
780 return false;
781 }
782 if (value == TFM_MODAL_ROTATE_NORMALS) {
783 return t->mode == TFM_ROTATION && t->data_type == &TransConvertType_Mesh;
784 }
785 break;
786 }
788 return false;
791 return false;
792 }
793 if (!ELEM(
795 {
796 /* More modes can be added over time if this feature proves useful for them. */
797 return false;
798 }
799 if (t->options & CTX_CAMERA) {
800 /* Not supported. */
801 return false;
802 }
803 break;
804 }
807 /* Returning `false` will not prevent the navigation from working, it will just not display
808 * the shortcut in the header.
809 * Return `false` here to prevent this modal item from affecting the state with
810 * #T_ALT_TRANSFORM is used by the operator. */
811 return false;
812 }
813 return t->vod != nullptr;
815 if (t->spacetype != SPACE_SEQ) {
816 return false;
817 }
819 return false;
820 }
821 break;
826 if (t->spacetype != SPACE_SEQ || t->mode != TFM_SEQ_SLIDE ||
828 {
829 return false;
830 }
831 break;
832 }
833 }
834 return true;
835}
836
838{
839 static const EnumPropertyItem modal_items[] = {
840 {TFM_MODAL_CONFIRM, "CONFIRM", 0, "Confirm", ""},
841 {TFM_MODAL_CANCEL, "CANCEL", 0, "Cancel", ""},
842 {TFM_MODAL_AXIS_X, "AXIS_X", 0, "X Axis", ""},
843 {TFM_MODAL_AXIS_Y, "AXIS_Y", 0, "Y Axis", ""},
844 {TFM_MODAL_AXIS_Z, "AXIS_Z", 0, "Z Axis", ""},
845 {TFM_MODAL_PLANE_X, "PLANE_X", 0, "X Plane", ""},
846 {TFM_MODAL_PLANE_Y, "PLANE_Y", 0, "Y Plane", ""},
847 {TFM_MODAL_PLANE_Z, "PLANE_Z", 0, "Z Plane", ""},
848 {TFM_MODAL_CONS_OFF, "CONS_OFF", 0, "Clear Constraints", ""},
849 {TFM_MODAL_EDIT_SNAP_SOURCE_ON, "EDIT_SNAP_SOURCE_ON", 0, "Set Snap Base", ""},
850 {TFM_MODAL_EDIT_SNAP_SOURCE_OFF, "EDIT_SNAP_SOURCE_OFF", 0, "Set Snap Base (Off)", ""},
851 {TFM_MODAL_SNAP_INV_ON, "SNAP_INV_ON", 0, "Snap Invert", ""},
852 {TFM_MODAL_SNAP_INV_OFF, "SNAP_INV_OFF", 0, "Snap Invert (Off)", ""},
853 {TFM_MODAL_SNAP_TOGGLE, "SNAP_TOGGLE", 0, "Snap Toggle", ""},
854 {TFM_MODAL_ADD_SNAP, "ADD_SNAP", 0, "Add Snap Point", ""},
855 {TFM_MODAL_REMOVE_SNAP, "REMOVE_SNAP", 0, "Remove Last Snap Point", ""},
856 {NUM_MODAL_INCREMENT_UP, "INCREMENT_UP", 0, "Numinput Increment Up", ""},
857 {NUM_MODAL_INCREMENT_DOWN, "INCREMENT_DOWN", 0, "Numinput Increment Down", ""},
858 {TFM_MODAL_PROPSIZE_UP, "PROPORTIONAL_SIZE_UP", 0, "Increase Proportional Influence", ""},
860 "PROPORTIONAL_SIZE_DOWN",
861 0,
862 "Decrease Proportional Influence",
863 ""},
864 {TFM_MODAL_PROPSIZE, "PROPORTIONAL_SIZE", 0, "Adjust Proportional Influence", ""},
865 {TFM_MODAL_AUTOIK_LEN_INC, "AUTOIK_CHAIN_LEN_UP", 0, "Increase Max AutoIK Chain Length", ""},
867 "AUTOIK_CHAIN_LEN_DOWN",
868 0,
869 "Decrease Max AutoIK Chain Length",
870 ""},
872 "INSERTOFS_TOGGLE_DIR",
873 0,
874 "Toggle Direction for Node Auto-Offset",
875 ""},
876 {TFM_MODAL_NODE_ATTACH_ON, "NODE_ATTACH_ON", 0, "Node Attachment", ""},
877 {TFM_MODAL_NODE_ATTACH_OFF, "NODE_ATTACH_OFF", 0, "Node Attachment (Off)", ""},
878 {TFM_MODAL_TRANSLATE, "TRANSLATE", 0, "Move", ""},
879 {TFM_MODAL_VERT_EDGE_SLIDE, "VERT_EDGE_SLIDE", 0, "Vert/Edge Slide", ""},
880 {TFM_MODAL_ROTATE, "ROTATE", 0, "Rotate", ""},
881 {TFM_MODAL_TRACKBALL, "TRACKBALL", 0, "Trackball", ""},
882 {TFM_MODAL_RESIZE, "RESIZE", 0, "Resize", ""},
883 {TFM_MODAL_ROTATE_NORMALS, "ROTATE_NORMALS", 0, "Rotate Normals", ""},
884 {TFM_MODAL_AUTOCONSTRAINT, "AUTOCONSTRAIN", 0, "Automatic Constraint", ""},
885 {TFM_MODAL_AUTOCONSTRAINTPLANE, "AUTOCONSTRAINPLANE", 0, "Automatic Constraint Plane", ""},
886 {TFM_MODAL_PRECISION, "PRECISION", 0, "Precision Mode", ""},
887 {TFM_MODAL_PASSTHROUGH_NAVIGATE, "PASSTHROUGH_NAVIGATE", 0, "Navigate", ""},
888 {TFM_MODAL_NODE_FRAME, "NODE_FRAME", 0, "Attach/Detach Frame", ""},
889 {TFM_MODAL_STRIP_CLAMP, "STRIP_CLAMP_TOGGLE", 0, "Clamp Strips", ""},
890 {TFM_MODAL_STRIP_OVERLAP_SHUFFLE, "STRIP_OVERLAP_SHUFFLE", 0, "Shuffle", ""},
891 {TFM_MODAL_STRIP_OVERLAP_RIPPLE, "STRIP_OVERLAP_RIPPLE", 0, "Ripple", ""},
892 {TFM_MODAL_STRIP_OVERLAP_OVERWRITE, "STRIP_OVERLAP_OVERWRITE", 0, "Overwrite", ""},
893 {TFM_MODAL_STRIP_RIPPLE_INSERT, "STRIP_RIPPLE_INSERT", 0, "Ripple Insert", ""},
894 {0, nullptr, 0, nullptr, nullptr},
895 };
896
897 wmKeyMap *keymap = WM_modalkeymap_ensure(keyconf, "Transform Modal Map", modal_items);
899
900 /* Default modal map values:
901 *
902 * \code{.c}
903 * WM_modalkeymap_add_item(keymap,
904 * &(const KeyMapItem_Params){
905 * .type = EVT_RETKEY,
906 * .value = KM_PRESS,
907 * .modifier = KM_ANY,
908 * .direction = KM_ANY,
909 * },
910 * TFM_MODAL_CONFIRM);
911 * WM_modalkeymap_add_item(keymap,
912 * &(const KeyMapItem_Params){
913 * .type = EVT_ESCKEY,
914 * .value = KM_PRESS,
915 * .modifier = KM_ANY,
916 * .direction = KM_ANY,
917 * },
918 * TFM_MODAL_CANCEL);
919 * WM_modalkeymap_add_item(keymap,
920 * &(const KeyMapItem_Params){
921 * .type = EVT_PAGEUPKEY,
922 * .value = KM_PRESS,
923 * .modifier = KM_ANY,
924 * .direction = KM_ANY,
925 * },
926 * TFM_MODAL_AUTOIK_LEN_INC);
927 * WM_modalkeymap_add_item(keymap,
928 * &(const KeyMapItem_Params){
929 * .type = EVT_PAGEDOWNKEY,
930 * .value = KM_PRESS,
931 * .modifier = KM_ANY,
932 * .direction = KM_ANY,
933 * },
934 * TFM_MODAL_AUTOIK_LEN_DEC);
935 * WM_modalkeymap_add_item(keymap,
936 * &(const KeyMapItem_Params){
937 * .type = EVT_GKEY,
938 * .value = KM_PRESS,
939 * .modifier = KM_ANY,
940 * .direction = KM_ANY,
941 * },
942 * TFM_MODAL_TRANSLATE);
943 * WM_modalkeymap_add_item(keymap,
944 * &(const KeyMapItem_Params){
945 * .type = EVT_RKEY,
946 * .value = KM_PRESS,
947 * .modifier = KM_ANY,
948 * .direction = KM_ANY,
949 * },
950 * TFM_MODAL_ROTATE);
951 * WM_modalkeymap_add_item(keymap,
952 * &(const KeyMapItem_Params){
953 * .type = EVT_SKEY,
954 * .value = KM_PRESS,
955 * .modifier = KM_ANY,
956 * .direction = KM_ANY,
957 * },
958 * TFM_MODAL_RESIZE);
959 * WM_modalkeymap_add_item(keymap,
960 * &(const KeyMapItem_Params){
961 * .type = MIDDLEMOUSE,
962 * .value = KM_PRESS,
963 * .modifier = KM_ANY,
964 * .direction = KM_ANY,
965 * },
966 * TFM_MODAL_AUTOCONSTRAINT);
967 * WM_modalkeymap_add_item(keymap,
968 * &(const KeyMapItem_Params){
969 * .type = MIDDLEMOUSE,
970 * .value = KM_PRESS,
971 * .modifier = KM_SHIFT,
972 * .direction = KM_ANY,
973 * },
974 * TFM_MODAL_AUTOCONSTRAINTPLANE);
975 * \endcode
976 */
977
978 return keymap;
979}
980
982
983/* -------------------------------------------------------------------- */
986
987static bool transform_event_modal_constraint(TransInfo *t, short modal_type)
988{
989 if (t->flag & T_NO_CONSTRAINT) {
990 return false;
991 }
992
993 if (t->flag & T_2D_EDIT && ELEM(modal_type, TFM_MODAL_AXIS_Z, TFM_MODAL_PLANE_Z)) {
994 return false;
995 }
996
997 int constraint_curr = -1;
998
1001
1002 /* Avoid changing orientation in this case. */
1003 constraint_curr = -2;
1004 }
1005 else if (t->con.mode & CON_APPLY) {
1006 constraint_curr = t->con.mode & (CON_AXIS0 | CON_AXIS1 | CON_AXIS2);
1007 }
1008
1009 int constraint_new;
1010 const char *msg_2d = "", *msg_3d = "";
1011
1012 /* Initialize. */
1013 switch (modal_type) {
1014 case TFM_MODAL_AXIS_X:
1015 msg_2d = IFACE_("along X");
1016 msg_3d = IFACE_("along %s X");
1017 constraint_new = CON_AXIS0;
1018 break;
1019 case TFM_MODAL_AXIS_Y:
1020 msg_2d = IFACE_("along Y");
1021 msg_3d = IFACE_("along %s Y");
1022 constraint_new = CON_AXIS1;
1023 break;
1024 case TFM_MODAL_AXIS_Z:
1025 msg_2d = IFACE_("along Z");
1026 msg_3d = IFACE_("along %s Z");
1027 constraint_new = CON_AXIS2;
1028 break;
1029 case TFM_MODAL_PLANE_X:
1030 msg_3d = IFACE_("locking %s X");
1031 constraint_new = CON_AXIS1 | CON_AXIS2;
1032 break;
1033 case TFM_MODAL_PLANE_Y:
1034 msg_3d = IFACE_("locking %s Y");
1035 constraint_new = CON_AXIS0 | CON_AXIS2;
1036 break;
1037 case TFM_MODAL_PLANE_Z:
1038 msg_3d = IFACE_("locking %s Z");
1039 constraint_new = CON_AXIS0 | CON_AXIS1;
1040 break;
1041 default:
1042 /* Invalid key. */
1043 return false;
1044 }
1045
1046 if (t->flag & T_2D_EDIT) {
1047 BLI_assert(modal_type < TFM_MODAL_PLANE_X);
1048 if (constraint_new == CON_AXIS2) {
1049 return false;
1050 }
1051
1053 /* Setup the 2d msg string so it writes out the transform space. */
1054 msg_2d = msg_3d;
1055
1056 short orient_index = 1;
1057 if (t->orient_curr == O_DEFAULT || ELEM(constraint_curr, -1, constraint_new)) {
1058 /* Successive presses on existing axis, cycle orientation modes. */
1059 orient_index = short((t->orient_curr + 1) % int(ARRAY_SIZE(t->orient)));
1060 }
1061
1062 transform_orientations_current_set(t, orient_index);
1063 if (orient_index != 0) {
1064 /* Make sure that we don't stop the constraint unless we are looped back around to
1065 * "no constraint". */
1066 constraint_curr = -1;
1067 }
1068 }
1069
1070 if (constraint_curr == constraint_new) {
1071 stopConstraint(t);
1072 }
1073 else {
1074 setUserConstraint(t, constraint_new, msg_2d);
1075 }
1076 }
1077 else {
1078 short orient_index = 1;
1079 if (t->orient_curr == O_DEFAULT || ELEM(constraint_curr, -1, constraint_new)) {
1080 /* Successive presses on existing axis, cycle orientation modes. */
1081 orient_index = short((t->orient_curr + 1) % int(ARRAY_SIZE(t->orient)));
1082 }
1083
1084 transform_orientations_current_set(t, orient_index);
1085 if (orient_index == 0) {
1086 stopConstraint(t);
1087 }
1088 else {
1089 setUserConstraint(t, constraint_new, msg_3d);
1090 }
1091
1092 /* Take the opportunity to update the gizmo. */
1094 }
1095 return true;
1096}
1097
1099{
1100 bool is_snap_enabled = (t->modifiers & MOD_SNAP) != 0;
1101
1102 eSnapFlag *snap_flag_ptr;
1103
1104 wmMsgParams_RNA msg_key_params = {{}};
1105 msg_key_params.ptr = RNA_pointer_create_discrete(&t->scene->id, RNA_ToolSettings, t->settings);
1106 if ((snap_flag_ptr = transform_snap_flag_from_spacetype_ptr(t, &msg_key_params.prop)) &&
1107 (is_snap_enabled != bool(*snap_flag_ptr & SCE_SNAP)))
1108 {
1109 SET_FLAG_FROM_TEST(*snap_flag_ptr, is_snap_enabled, SCE_SNAP);
1110 WM_msg_publish_rna_params(t->mbus, &msg_key_params);
1111 }
1112}
1113
1115{
1116 bool is_navigating = t->vod ? ((static_cast<RegionView3D *>(t->region->regiondata))->rflag &
1117 RV3D_NAVIGATING) != 0 :
1118 false;
1119
1120 /* Handle modal numinput events first, if already activated. */
1121 if (!is_navigating && ((event->val == KM_PRESS) || (event->type == EVT_MODAL_MAP)) &&
1122 hasNumInput(&t->num) && handleNumInput(t->context, &(t->num), event))
1123 {
1124 t->redraw |= TREDRAW_HARD;
1125 }
1126 else if (event->type == TIMER) {
1127 if (ED_uvedit_live_unwrap_timer_check(static_cast<const wmTimer *>(event->customdata))) {
1128 t->redraw |= TREDRAW_HARD;
1129 }
1130 }
1131 else if (!is_navigating && event->type == MOUSEMOVE) {
1132 t->mval = float2(event->mval);
1133
1134 /* Use this for soft redraw. Might cause flicker in object mode. */
1135 // t->redraw |= TREDRAW_SOFT;
1136 t->redraw |= TREDRAW_HARD;
1137
1138 if (t->state == TRANS_STARTING) {
1139 t->state = TRANS_RUNNING;
1140 }
1141
1142 applyMouseInput(t, &t->mouse, t->mval, t->values);
1143
1144 /* Snapping mouse move events. */
1145 t->redraw |= handleSnapping(t, event);
1146 }
1147 /* Handle modal keymap first. */
1148 /* Enforce redraw of transform when modifiers are used. */
1149 else if (event->type == EVT_MODAL_MAP) {
1150 switch (event->val) {
1151 case TFM_MODAL_CANCEL:
1152 if (!(t->modifiers & MOD_EDIT_SNAP_SOURCE)) {
1153 t->state = TRANS_CANCEL;
1154 }
1155 break;
1156 case TFM_MODAL_CONFIRM:
1157 if (!(t->modifiers & MOD_EDIT_SNAP_SOURCE)) {
1158 t->state = TRANS_CONFIRM;
1159 }
1160 break;
1162 case TFM_MODAL_ROTATE:
1163 case TFM_MODAL_RESIZE:
1167 /* Only switch when supported. */
1169 break;
1170 }
1171
1172 if ((event->val == TFM_MODAL_TRANSLATE && t->mode == TFM_TRANSLATION) ||
1173 (event->val == TFM_MODAL_RESIZE && t->mode == TFM_RESIZE))
1174 {
1177
1178 t->flag ^= T_ALT_TRANSFORM;
1179 t->redraw |= TREDRAW_HARD;
1180 }
1181 break;
1182 }
1183
1184 if ((event->val == TFM_MODAL_ROTATE && t->mode == TFM_ROTATION) ||
1185 (event->val == TFM_MODAL_TRACKBALL && t->mode == TFM_TRACKBALL) ||
1187 (event->val == TFM_MODAL_VERT_EDGE_SLIDE &&
1189 {
1190 break;
1191 }
1192
1194 break;
1195 }
1196
1198 resetTransModal(t);
1200
1201 if (event->val == TFM_MODAL_TRANSLATE) {
1203 }
1204 else if (event->val == TFM_MODAL_ROTATE) {
1205 transform_mode_init(t, nullptr, TFM_ROTATION);
1206 }
1207 else if (event->val == TFM_MODAL_TRACKBALL) {
1209 }
1210 else if (event->val == TFM_MODAL_ROTATE_NORMALS) {
1212 }
1213 else if (event->val == TFM_MODAL_RESIZE) {
1214 /* Scale isn't normally very useful after extrude along normals, see #39756 */
1215 if ((t->con.mode & CON_APPLY) && (t->orient[t->orient_curr].type == V3D_ORIENT_NORMAL)) {
1216 stopConstraint(t);
1217 }
1218 transform_mode_init(t, nullptr, TFM_RESIZE);
1219 }
1220 else {
1221 /* First try Edge Slide. */
1223 /* If that fails, try Vertex Slide. */
1224 if (t->state == TRANS_CANCEL) {
1225 resetTransModal(t);
1226 t->state = TRANS_STARTING;
1228 }
1229 /* Vert Slide can fail on unconnected vertices (rare but possible). */
1230 if (t->state == TRANS_CANCEL) {
1231 resetTransModal(t);
1232 t->state = TRANS_STARTING;
1235 }
1236 }
1237
1238 /* Need to reinitialize after mode change. */
1240 applyMouseInput(t, &t->mouse, t->mval, t->values);
1241 t->redraw |= TREDRAW_HARD;
1242 break;
1243
1245 if (!(t->modifiers & MOD_SNAP_INVERT)) {
1248 t->redraw |= TREDRAW_HARD;
1249 }
1250 break;
1252 if (t->modifiers & MOD_SNAP_INVERT) {
1255 t->redraw |= TREDRAW_HARD;
1256 }
1257 break;
1259 t->modifiers ^= MOD_SNAP;
1262 t->redraw |= TREDRAW_HARD;
1263 break;
1264 case TFM_MODAL_AXIS_X:
1265 case TFM_MODAL_AXIS_Y:
1266 case TFM_MODAL_AXIS_Z:
1267 case TFM_MODAL_PLANE_X:
1268 case TFM_MODAL_PLANE_Y:
1269 case TFM_MODAL_PLANE_Z:
1270 if (transform_event_modal_constraint(t, event->val)) {
1271 t->redraw |= TREDRAW_HARD;
1272 }
1273 break;
1274 case TFM_MODAL_CONS_OFF:
1275 if ((t->flag & T_NO_CONSTRAINT) == 0) {
1276 stopConstraint(t);
1277 t->redraw |= TREDRAW_HARD;
1278 }
1279 break;
1280 case TFM_MODAL_ADD_SNAP:
1281 addSnapPoint(t);
1282 t->redraw |= TREDRAW_HARD;
1283 break;
1285 removeSnapPoint(t);
1286 t->redraw |= TREDRAW_HARD;
1287 break;
1288 case TFM_MODAL_PROPSIZE:
1289 /* MOUSEPAN usage... */
1290 if (t->flag & T_PROP_EDIT) {
1291 float fac = 1.0f + 0.005f * (event->xy[1] - event->prev_xy[1]);
1292 t->prop_size *= fac;
1293 if (t->spacetype == SPACE_VIEW3D && t->persp != RV3D_ORTHO) {
1294 t->prop_size = max_ff(min_ff(t->prop_size, (static_cast<View3D *>(t->view))->clip_end),
1296 }
1297 else {
1299 }
1301 t->redraw |= TREDRAW_HARD;
1302 }
1303 break;
1305 if (t->flag & T_PROP_EDIT) {
1306 t->prop_size *= (t->modifiers & MOD_PRECISION) ? 1.01f : 1.1f;
1307 if (t->spacetype == SPACE_VIEW3D && t->persp != RV3D_ORTHO) {
1308 t->prop_size = min_ff(t->prop_size, (static_cast<View3D *>(t->view))->clip_end);
1309 }
1310 else {
1312 }
1314 t->redraw |= TREDRAW_HARD;
1315 }
1316 break;
1318 if (t->flag & T_PROP_EDIT) {
1319 t->prop_size /= (t->modifiers & MOD_PRECISION) ? 1.01f : 1.1f;
1322 t->redraw |= TREDRAW_HARD;
1323 }
1324 break;
1326 if (t->flag & T_AUTOIK) {
1328 t->redraw |= TREDRAW_HARD;
1329 }
1330 break;
1332 if (t->flag & T_AUTOIK) {
1334 t->redraw |= TREDRAW_HARD;
1335 }
1336 break;
1338 if (t->spacetype == SPACE_NODE) {
1339 SpaceNode *snode = t->area->spacedata.first_as<SpaceNode>();
1340
1342
1345 }
1346 else if (snode->insert_ofs_dir == SNODE_INSERTOFS_DIR_LEFT) {
1348 }
1349 else {
1350 BLI_assert(0);
1351 }
1352
1353 t->redraw |= TREDRAW_SOFT;
1354 }
1355 break;
1358 t->redraw |= TREDRAW_HARD;
1359 break;
1362 t->redraw |= TREDRAW_HARD;
1363 break;
1366 t->redraw |= TREDRAW_HARD;
1367 break;
1368
1371 if ((t->flag & T_RELEASE_CONFIRM) && (event->prev_val == KM_RELEASE) &&
1372 event->prev_type == t->launch_event)
1373 {
1374 /* Confirm transform if launch key is released after mouse move. */
1375 t->state = TRANS_CONFIRM;
1376 }
1377 else if ((t->flag & T_NO_CONSTRAINT) == 0) {
1379 /* Confirm. */
1382 t->redraw = TREDRAW_HARD;
1383 }
1384 else {
1385 if (t->options & CTX_CAMERA) {
1386 /* Exception for switching to dolly, or trackball, in camera view. */
1387 if (t->mode == TFM_TRANSLATION) {
1388 setLocalConstraint(t, (CON_AXIS2), IFACE_("along local Z"));
1389 }
1390 else if (t->mode == TFM_ROTATION) {
1393 }
1394 t->redraw = TREDRAW_HARD;
1395 }
1396 else {
1397 t->modifiers |= (event->val == TFM_MODAL_AUTOCONSTRAINT) ?
1400 if (t->con.mode & CON_APPLY) {
1401 stopConstraint(t);
1403
1404 /* In this case we might just want to remove the constraint,
1405 * so set #TREDRAW_SOFT to only select the constraint on the next mouse move event.
1406 * This way we can kind of "cancel" due to confirmation without constraint. */
1407 t->redraw = TREDRAW_SOFT;
1408 }
1409 else {
1411
1412 /* When first called, set #TREDRAW_HARD to select constraint immediately in
1413 * #selectConstraint. */
1415 }
1416 }
1417 }
1418 }
1419 break;
1421 if (is_navigating) {
1422 /* WORKAROUND: During navigation, due to key conflicts, precision may be unintentionally
1423 * enabled. */
1424 }
1425 else if (event->prev_val == KM_PRESS) {
1427 /* Mouse position during Snap to Grid is not affected by precision. */
1428 if (!(transform_snap_is_active(t) && validSnap(t) &&
1430 {
1431 t->mouse.precision = true;
1432 }
1433
1434 t->redraw |= TREDRAW_HARD;
1435 }
1436 else if (event->prev_val == KM_RELEASE) {
1438 t->mouse.precision = false;
1439 t->redraw |= TREDRAW_HARD;
1440 }
1441 break;
1443 if (!(t->modifiers & MOD_EDIT_SNAP_SOURCE)) {
1445 t->redraw |= TREDRAW_HARD;
1446 }
1447 break;
1450 t->redraw |= TREDRAW_HARD;
1451 break;
1455 t->redraw |= TREDRAW_HARD;
1456 break;
1460 t->redraw |= TREDRAW_HARD;
1461 break;
1465 t->redraw |= TREDRAW_HARD;
1466 break;
1471 {
1472 break;
1473 }
1475 t->redraw |= TREDRAW_HARD;
1476 break;
1477 }
1478 default:
1479 break;
1480 }
1481 }
1482 /* Else do non-mapped events. */
1483 else if (event->val == KM_PRESS) {
1484 switch (event->type) {
1485 case EVT_CKEY:
1486 if (event->flag & WM_EVENT_IS_REPEAT) {
1487 break;
1488 }
1489 if (event->modifier & KM_ALT) {
1490 if (!(t->options & CTX_NO_PET)) {
1491 t->flag ^= T_PROP_CONNECTED;
1494 t->redraw = TREDRAW_HARD;
1495 }
1496 }
1497 break;
1498 case EVT_OKEY:
1499 if (event->flag & WM_EVENT_IS_REPEAT) {
1500 break;
1501 }
1502 if ((t->flag & T_PROP_EDIT) && (event->modifier & KM_SHIFT)) {
1503 t->prop_mode = (t->prop_mode + 1) % PROP_MODE_MAX;
1505 t->redraw |= TREDRAW_HARD;
1506 }
1507 break;
1508 case EVT_PADPLUSKEY:
1509 if ((event->modifier & KM_ALT) && (t->flag & T_PROP_EDIT)) {
1510 t->prop_size *= (t->modifiers & MOD_PRECISION) ? 1.01f : 1.1f;
1511 if (t->spacetype == SPACE_VIEW3D && t->persp != RV3D_ORTHO) {
1512 t->prop_size = min_ff(t->prop_size, (static_cast<View3D *>(t->view))->clip_end);
1513 }
1515 t->redraw = TREDRAW_HARD;
1516 }
1517 break;
1518 case EVT_PADMINUS:
1519 if ((event->modifier & KM_ALT) && (t->flag & T_PROP_EDIT)) {
1520 t->prop_size /= (t->modifiers & MOD_PRECISION) ? 1.01f : 1.1f;
1522 t->redraw = TREDRAW_HARD;
1523 }
1524 break;
1525 case EVT_LEFTALTKEY:
1526 case EVT_RIGHTALTKEY:
1528 t->flag |= T_ALT_TRANSFORM;
1529 t->redraw |= TREDRAW_HARD;
1530 }
1531 break;
1532 default:
1533 break;
1534 }
1535 }
1536 else if (event->val == KM_RELEASE) {
1537 switch (event->type) {
1538 case EVT_LEFTALTKEY:
1539 case EVT_RIGHTALTKEY:
1540 /* TODO: Modal Map */
1542 t->flag &= ~T_ALT_TRANSFORM;
1543 t->redraw |= TREDRAW_HARD;
1544 }
1545 break;
1546 default: {
1547 break;
1548 }
1549 }
1550
1551 /* Confirm transform if launch key is released after mouse move. */
1552 if ((t->flag & T_RELEASE_CONFIRM) && event->type == t->launch_event) {
1553 t->state = TRANS_CONFIRM;
1554 }
1555 }
1556
1557 /* Per transform event, if present. */
1558 if (t->mode_info && t->mode_info->handle_event_fn) {
1559 t->redraw |= t->mode_info->handle_event_fn(t, event);
1560 }
1561
1562 /* Try to init modal numinput now, if possible. */
1563 if (!t->redraw && ((event->val == KM_PRESS) || (event->type == EVT_MODAL_MAP)) &&
1564 handleNumInput(t->context, &(t->num), event))
1565 {
1566 t->redraw |= TREDRAW_HARD;
1567 }
1568
1569 if (t->redraw && !ISMOUSE_MOTION(event->type)) {
1570 /* The status area is currently also tagged to update by the notifiers in
1571 * `viewRedrawForce`. However, this may change in the future, and tagging
1572 * the region twice doesn't add any overhead. */
1574
1576 ED_workspace_status_text(t->context, nullptr);
1577 }
1578 }
1579
1580 if (!is_navigating && t->redraw) {
1581 return wmOperatorStatus(0);
1582 }
1583 return OPERATOR_PASS_THROUGH;
1584}
1585
1587
1588/* -------------------------------------------------------------------- */
1591
1592bool calculateTransformCenter(bContext *C, int centerMode, float cent3d[3], float cent2d[2])
1593{
1594 TransInfo *t = MEM_new_zeroed<TransInfo>("TransInfo data");
1595 bool success;
1596
1597 t->context = C;
1598
1599 t->state = TRANS_RUNNING;
1600
1601 /* Avoid calculating proportional editing. */
1602 t->options = CTX_NO_PET;
1603
1604 t->mode = TFM_DUMMY;
1605
1606 initTransInfo(C, t, nullptr, nullptr);
1607
1608 /* Avoid doing connectivity lookups (when V3D_AROUND_LOCAL_ORIGINS is set). */
1610
1611 create_trans_data(C, t); /* Make TransData structs from selection. */
1612
1613 t->around = centerMode; /* Override user-defined mode. */
1614
1615 if (t->data_len_all == 0) {
1616 success = false;
1617 }
1618 else {
1619 success = true;
1620
1621 calculateCenter(t);
1622
1623 if (cent2d) {
1624 copy_v2_v2(cent2d, t->center2d);
1625 }
1626
1627 if (cent3d) {
1628 /* Copy center from constraint center. Transform center can be local. */
1629 copy_v3_v3(cent3d, t->center_global);
1630 }
1631 }
1632
1633 /* Does insert keyframes, and clears base flags; doesn't read `transdata`. */
1635
1636 postTrans(C, t);
1637
1638 MEM_delete(t);
1639
1640 return success;
1641}
1642
1644
1645/* -------------------------------------------------------------------- */
1648
1650{
1651 /* Don't show overlays when not the active view and when overlay is disabled: #57139 */
1652 if (region != t->region) {
1653 return false;
1654 }
1655
1656 switch (t->spacetype) {
1657 case SPACE_VIEW3D: {
1658 const View3D *v3d = static_cast<const View3D *>(t->view);
1659 return (v3d->flag2 & V3D_HIDE_OVERLAYS) == 0;
1660 }
1661 case SPACE_IMAGE: {
1662 const SpaceImage *sima = t->area->spacedata.first_as<SpaceImage>();
1663 return (sima->overlay.flag & SI_OVERLAY_SHOW_OVERLAYS) != 0;
1664 }
1665 case SPACE_SEQ: {
1666 const SpaceSeq *sseq = t->area->spacedata.first_as<SpaceSeq>();
1667 return (sseq->flag & SEQ_SHOW_OVERLAY) != 0;
1668 }
1669 case SPACE_ACTION: {
1670 const SpaceAction *sact = t->area->spacedata.first_as<SpaceAction>();
1671 return (sact->overlays.flag & ADS_OVERLAY_SHOW_OVERLAYS) != 0;
1672 }
1673 case SPACE_GRAPH: {
1674 /* There is no overlay flag defined yet for the Graph Editor. But there is the proportional
1675 * editing drawing that will not happen if we return false here. */
1676 return true;
1677 }
1678 case SPACE_CLIP: {
1679 const SpaceClip *sclip = t->area->spacedata.first_as<SpaceClip>();
1680 return (sclip->overlay.flag & SC_SHOW_OVERLAYS) != 0;
1681 }
1682 }
1683 return false;
1684}
1685
1686static void drawTransformView(const bContext * /*C*/, ARegion *region, void *arg)
1687{
1688 TransInfo *t = static_cast<TransInfo *>(arg);
1689
1690 if (!transinfo_show_overlay(t, region)) {
1691 return;
1692 }
1693
1694 GPU_line_width(1.0f);
1695
1696 drawConstraint(t);
1697
1698 switch (t->spacetype) {
1699 case SPACE_GRAPH:
1700 case SPACE_ACTION:
1701 /* Different visualization because the proportional editing in these editors only looks at
1702 * the x-axis. */
1703 drawPropRange(t);
1704 break;
1705
1706 default:
1707 drawPropCircle(t);
1708 break;
1709 }
1710
1711 drawSnapping(t);
1712
1713 if (region == t->region && t->mode_info && t->mode_info->draw_fn) {
1714 t->mode_info->draw_fn(t);
1715 }
1716}
1717
1722static void drawAutoKeyWarning(TransInfo *t, ARegion *region)
1723{
1724 const char *printable = IFACE_("Auto Keying On");
1725 float printable_size[2];
1726 int xco, yco;
1727 int offset = 0;
1728
1729 const rcti *rect = ED_region_visible_rect(region);
1730
1731 View3D *v3d = nullptr;
1732 Scene *scene = nullptr;
1733 if (t->spacetype == SPACE_VIEW3D) {
1734 v3d = static_cast<View3D *>(t->view);
1735 scene = t->scene;
1736 }
1737
1738 const int font_id = BLF_set_default();
1740 font_id, printable, BLF_DRAW_STR_DUMMY_MAX, &printable_size[0], &printable_size[1]);
1741
1742 /* Check to see if the Navigation Gizmo is enabled. */
1743 if ((t->spacetype != SPACE_VIEW3D) || (v3d == nullptr) ||
1745 {
1746 offset = 10;
1747 }
1748 else {
1749 /* Depending on user MINI_AXIS preference, pad accordingly. */
1750 switch (eUserpref_MiniAxisType(U.mini_axis_type)) {
1752 offset = U.gizmo_size_navigate_v3d;
1753 break;
1755 offset = U.rvisize * std::min((U.pixelsize / U.scale_factor), 1.0f) * 2.5f;
1756 break;
1758 offset = U.rvisize;
1759 break;
1760 }
1761 }
1762
1763 offset *= U.scale_factor;
1764
1765 xco = (rect->xmax - U.widget_unit) - int(printable_size[0]) - offset;
1766 yco = (rect->ymax - U.widget_unit);
1767
1768 /* Warning text (to clarify meaning of overlays)
1769 * - Original color was red to match the icon, but that clashes badly with a less nasty border.
1770 */
1771
1772 float text_color[4], shadow_color[4];
1773 if (v3d && scene) {
1774 ED_view3d_text_colors_get(scene, v3d, text_color, shadow_color);
1775 }
1776 else {
1778 ui::theme::get_color_4fv(TH_BACK, text_color);
1779 }
1780 BLF_color4fv(BLF_default(), text_color);
1782 BLF_draw_default(xco, yco, 0.0f, printable, BLF_DRAW_STR_DUMMY_MAX);
1783
1784 /* Auto-key recording icon. */
1786
1787 xco -= U.widget_unit;
1788 yco -= int(printable_size[1]) / 2;
1789
1790 ui::icon_draw(xco, yco, ICON_REC);
1791
1793}
1794
1795static void drawTransformPixel(const bContext * /*C*/, ARegion *region, void *arg)
1796{
1797 TransInfo *t = static_cast<TransInfo *>(arg);
1798
1799 if (!transinfo_show_overlay(t, region)) {
1800 return;
1801 }
1802
1803 if (region != t->region) {
1804 return;
1805 }
1806
1807 /* Draw auto-key-framing hint in the corner
1808 * - only draw if enabled (advanced users may be distracted/annoyed),
1809 * for objects that will be auto-keyframed (no point otherwise),
1810 * AND only for the active region (as showing all is too overwhelming)
1811 */
1812 if ((U.keying_flag & AUTOKEY_FLAG_NOWARNING) == 0) {
1813 if (t->options & (CTX_OBJECT | CTX_POSE_BONE)) {
1814 Scene *scene = t->scene;
1815 ViewLayer *view_layer = t->view_layer;
1816 BKE_view_layer_synced_ensure(*t->bmain, scene, view_layer);
1817 Object *ob = BKE_view_layer_active_object_get(view_layer);
1818
1819 if (ob && animrig::autokeyframe_cfra_can_key(scene, &ob->id)) {
1820 drawAutoKeyWarning(t, region);
1821 }
1822 }
1823 }
1824}
1825
1827
1828/* -------------------------------------------------------------------- */
1831
1833{
1835 PropertyRNA *prop;
1836
1837 bool use_prop_edit = false;
1838 int prop_edit_flag = 0;
1839
1840 /* Save proportional edit settings.
1841 * Skip saving proportional edit if it was not actually used.
1842 * Note that this value is being saved even if the operation is canceled. This is to maintain a
1843 * behavior already used by users. */
1844 if (!(t->options & CTX_NO_PET)) {
1845 if (t->flag & T_PROP_EDIT_ALL) {
1846 if (t->flag & T_PROP_EDIT) {
1847 use_prop_edit = true;
1848 }
1849 if (t->flag & T_PROP_CONNECTED) {
1850 prop_edit_flag |= PROP_EDIT_CONNECTED;
1851 }
1852 if (t->flag & T_PROP_PROJECTED) {
1853 prop_edit_flag |= PROP_EDIT_PROJECTED;
1854 }
1855 }
1856
1857 /* If modal, save settings back in scene if not set as operator argument. */
1858 if ((t->flag & T_MODAL) || (op->flag & OP_IS_REPEAT)) {
1859 /* Save settings if not set in operator. */
1860 if ((prop = RNA_struct_find_property(op->ptr, "use_proportional_edit")) &&
1861 !RNA_property_is_set(op->ptr, prop))
1862 {
1865 const eObjectMode object_mode = obact ? obact->mode : OB_MODE_OBJECT;
1866
1867 if (t->spacetype == SPACE_GRAPH) {
1868 ts->proportional_fcurve = use_prop_edit;
1869 }
1870 else if (t->spacetype == SPACE_ACTION) {
1871 ts->proportional_action = use_prop_edit;
1872 }
1873 else if (t->options & CTX_MASK) {
1874 ts->proportional_mask = use_prop_edit;
1875 }
1876 else if (object_mode == OB_MODE_OBJECT) {
1877 /* No active object means #TransConvertType_Object [see #convert_type_get()],
1878 * so use tool-setting for *object*. */
1879 ts->proportional_objects = use_prop_edit;
1880 }
1881 else {
1882 if (use_prop_edit) {
1884 }
1885 else {
1887 }
1888 }
1889 }
1890
1891 if ((prop = RNA_struct_find_property(op->ptr, "proportional_size"))) {
1892 ts->proportional_size = RNA_property_is_set(op->ptr, prop) ?
1893 RNA_property_float_get(op->ptr, prop) :
1894 t->prop_size;
1895 }
1896
1897 if ((prop = RNA_struct_find_property(op->ptr, "proportional_edit_falloff")) &&
1898 !RNA_property_is_set(op->ptr, prop))
1899 {
1900 ts->prop_mode = t->prop_mode;
1901 }
1902 }
1903 }
1904
1905 if (t->state == TRANS_CANCEL) {
1906 /* No need to edit operator properties or tool settings if we are canceling the operation.
1907 * These properties must match the original ones. */
1908 return;
1909 }
1910
1911 if (!(t->options & CTX_NO_PET)) {
1912 if ((prop = RNA_struct_find_property(op->ptr, "use_proportional_edit"))) {
1913 RNA_property_boolean_set(op->ptr, prop, use_prop_edit);
1914 RNA_boolean_set(op->ptr, "use_proportional_connected", prop_edit_flag & PROP_EDIT_CONNECTED);
1915 RNA_boolean_set(op->ptr, "use_proportional_projected", prop_edit_flag & PROP_EDIT_PROJECTED);
1916 RNA_enum_set(op->ptr, "proportional_edit_falloff", t->prop_mode);
1917 RNA_float_set(op->ptr, "proportional_size", t->prop_size);
1918 }
1919 }
1920
1921 /* Save back mode in case we're in the generic operator. */
1922 if ((prop = RNA_struct_find_property(op->ptr, "mode"))) {
1923 RNA_property_enum_set(op->ptr, prop, t->mode);
1924 }
1925
1926 if ((prop = RNA_struct_find_property(op->ptr, "value"))) {
1927 if (RNA_property_array_check(prop)) {
1929 }
1930 else {
1931 RNA_property_float_set(op->ptr, prop, t->values_final[0]);
1932 }
1933 }
1934
1935 /* Shear uses offset internally, but the operator property is angle.
1936 * Convert offset to angle before saving. */
1937 if (t->mode == TFM_SHEAR) {
1938 const float angle_rad = atanf(t->values_final[0]);
1939 RNA_float_set(op->ptr, "angle", angle_rad);
1940 }
1941
1942 /* Save snapping settings. */
1943 if ((prop = RNA_struct_find_property(op->ptr, "snap"))) {
1944
1945 /* Update the snap toggle in `ToolSettings`. */
1946 if (
1947 /* Update only if snapping has changed during a modal operation. */
1948 (t->flag & T_MODAL) &&
1949 /* Skip updating if the snapping mode does not match the snap types. */
1951 /* Skip updating the snap toggle if it was not explicitly set by the user. */
1952 !(t->modifiers & MOD_SNAP_FORCED) &&
1953 /* Skip updating the snap toggle if snapping was enabled via operator properties. */
1954 !RNA_property_is_set(op->ptr, prop))
1955 {
1957 }
1958
1959 bool is_snap_enabled = (t->modifiers & MOD_SNAP) != 0;
1960 RNA_property_boolean_set(op->ptr, prop, is_snap_enabled);
1961
1962 if ((prop = RNA_struct_find_property(op->ptr, "snap_elements"))) {
1963 RNA_property_enum_set(op->ptr, prop, t->tsnap.mode);
1965 op->ptr, "use_snap_project", (t->tsnap.mode & SCE_SNAP_INDIVIDUAL_PROJECT) != 0);
1966 RNA_enum_set(op->ptr, "snap_target", t->tsnap.source_operation);
1967
1969 RNA_boolean_set(op->ptr, "use_snap_self", (target & SCE_SNAP_TARGET_NOT_ACTIVE) == 0);
1970 RNA_boolean_set(op->ptr, "use_snap_edit", (target & SCE_SNAP_TARGET_NOT_EDITED) == 0);
1971 RNA_boolean_set(op->ptr, "use_snap_nonedit", (target & SCE_SNAP_TARGET_NOT_NONEDITED) == 0);
1973 op->ptr, "use_snap_selectable", (target & SCE_SNAP_TARGET_ONLY_SELECTABLE) != 0);
1974 }
1975 }
1976
1977 if ((prop = RNA_struct_find_property(op->ptr, "mirror"))) {
1978 RNA_property_boolean_set(op->ptr, prop, (t->flag & T_NO_MIRROR) == 0);
1979 }
1980
1981 if ((prop = RNA_struct_find_property(op->ptr, "orient_axis"))) {
1982 if (t->flag & T_MODAL) {
1983 if (t->con.mode & CON_APPLY) {
1984 int orient_axis = constraintModeToIndex(t);
1985 if (orient_axis != -1) {
1986 RNA_property_enum_set(op->ptr, prop, orient_axis);
1987 }
1988 }
1989 else {
1990 RNA_property_enum_set(op->ptr, prop, t->orient_axis);
1991 }
1992 }
1993 }
1994 if ((prop = RNA_struct_find_property(op->ptr, "orient_axis_ortho"))) {
1995 if (t->flag & T_MODAL) {
1997 }
1998 }
1999
2000 if ((prop = RNA_struct_find_property(op->ptr, "orient_type"))) {
2001 short orient_type_set, orient_type_curr;
2002 orient_type_set = RNA_property_is_set(op->ptr, prop) ? RNA_property_enum_get(op->ptr, prop) :
2003 -1;
2004 orient_type_curr = t->orient[t->orient_curr].type;
2005
2006 if (!ELEM(orient_type_curr, orient_type_set, V3D_ORIENT_CUSTOM_MATRIX)) {
2007 RNA_property_enum_set(op->ptr, prop, orient_type_curr);
2008 orient_type_set = orient_type_curr;
2009 }
2010
2011 if ((prop = RNA_struct_find_property(op->ptr, "orient_matrix_type")) &&
2012 !RNA_property_is_set(op->ptr, prop))
2013 {
2014 /* Set the first time to register on redo. */
2015 RNA_property_enum_set(op->ptr, prop, orient_type_set);
2016 RNA_float_set_array(op->ptr, "orient_matrix", &t->spacemtx[0][0]);
2017 }
2018 }
2019
2020 if ((prop = RNA_struct_find_property(op->ptr, "constraint_axis"))) {
2021 bool constraint_axis[3] = {false, false, false};
2022 if (t->con.mode & CON_APPLY) {
2023 if (t->con.mode & CON_AXIS0) {
2024 constraint_axis[0] = true;
2025 }
2026 if (t->con.mode & CON_AXIS1) {
2027 constraint_axis[1] = true;
2028 }
2029 if (t->con.mode & CON_AXIS2) {
2030 constraint_axis[2] = true;
2031 }
2032 RNA_property_boolean_set_array(op->ptr, prop, constraint_axis);
2033 }
2034 else {
2035 RNA_property_unset(op->ptr, prop);
2036 }
2037 }
2038
2039 {
2040 const char *prop_id = nullptr;
2041 bool prop_state = true;
2042 if (t->mode == TFM_SHRINKFATTEN) {
2043 prop_id = "use_even_offset";
2044 prop_state = false;
2045 }
2046
2047 if (prop_id && (prop = RNA_struct_find_property(op->ptr, prop_id))) {
2048 RNA_property_boolean_set(op->ptr, prop, ((t->flag & T_ALT_TRANSFORM) == 0) == prop_state);
2049 }
2050 }
2051
2052 if ((prop = RNA_struct_find_property(op->ptr, "correct_uv"))) {
2054 op->ptr, prop, (t->settings->uvcalc_flag & UVCALC_TRANSFORM_CORRECT_SLIDE) != 0);
2055 }
2056
2057 /* Save sequencer ripple settings. */
2058 if ((prop = RNA_struct_find_property(op->ptr, "overlap_mode")) &&
2059 !RNA_property_is_set(op->ptr, prop))
2060 {
2062 if (scene != nullptr) {
2063 const eSeqRippleFlag ripple_flag = seq::tool_settings_ripple_flag_get(scene);
2065 RNA_boolean_set(op->ptr, "all_channels", (ripple_flag & SEQ_RIPPLE_ALL_CHANNELS) != 0);
2066 RNA_boolean_set(op->ptr, "markers", (ripple_flag & SEQ_RIPPLE_MARKERS) != 0);
2067 RNA_boolean_set(op->ptr, "insert", (ripple_flag & SEQ_RIPPLE_INSERT) != 0);
2068 }
2069 }
2070}
2071
2072bool initTransform(bContext *C, TransInfo *t, wmOperator *op, const wmEvent *event, int mode)
2073{
2074 int options = 0;
2075 PropertyRNA *prop;
2076
2077 mode = transform_mode_really_used(C, eTfmMode(mode));
2078
2079 t->context = C;
2080
2081 /* Added initialize, for external calls to set stuff in TransInfo, like undo string. */
2082
2083 t->state = TRANS_STARTING;
2084
2085 if ((prop = RNA_struct_find_property(op->ptr, "cursor_transform")) &&
2086 RNA_property_is_set(op->ptr, prop))
2087 {
2088 if (RNA_property_boolean_get(op->ptr, prop)) {
2090 }
2091 }
2092
2093 if ((prop = RNA_struct_find_property(op->ptr, "texture_space")) &&
2094 RNA_property_is_set(op->ptr, prop))
2095 {
2096 if (RNA_property_boolean_get(op->ptr, prop)) {
2098 }
2099 }
2100
2101 if ((prop = RNA_struct_find_property(op->ptr, "gpencil_strokes")) &&
2102 RNA_property_is_set(op->ptr, prop))
2103 {
2104 if (RNA_property_boolean_get(op->ptr, prop)) {
2106 }
2107 }
2108
2109 if ((prop = RNA_struct_find_property(op->ptr, "view2d_edge_pan")) &&
2110 RNA_property_is_set(op->ptr, prop))
2111 {
2112 if (RNA_property_boolean_get(op->ptr, prop)) {
2114 }
2115 }
2116
2118
2119 t->mode = eTfmMode(mode);
2120
2121 /* Needed to translate tweak events to mouse buttons. */
2123 t->is_launch_event_drag = event ? (event->val == KM_PRESS_DRAG) : false;
2124
2125 unit_m3(t->spacemtx);
2126
2127 initTransInfo(C, t, op, event);
2128
2129 if (!G.background) {
2130 if (t->spacetype == SPACE_VIEW3D) {
2137 }
2138 else if (ELEM(t->spacetype,
2140 SPACE_CLIP,
2141 SPACE_NODE,
2144 SPACE_SEQ))
2145 {
2150 }
2151 }
2152
2153 create_trans_data(C, t); /* Make #TransData structs from selection. */
2154
2155 if (t->data_len_all == 0) {
2156 postTrans(C, t);
2157 return false;
2158 }
2159
2160 /* When proportional editing is enabled, data_len_all can be non zero when
2161 * nothing is selected, if this is the case we can end the transform early.
2162 *
2163 * By definition transform-data has selected items in beginning,
2164 * so only the first item in each container needs to be checked
2165 * when looking for the presence of selected data. */
2166 if (t->flag & T_PROP_EDIT) {
2167 bool has_selected_any = false;
2169 if (tc->data_len == 0) {
2170 continue;
2171 }
2172
2173 if (!tc->sorted_index_map) {
2174 BLI_assert_msg(tc->data[0].flag & TD_SELECTED,
2175 "Without sorted_index_map, all items are expected to be selected");
2176 has_selected_any = true;
2177 break;
2178 }
2179
2180 const int first_selected_index = tc->sorted_index_map[0];
2181 TransData *td = &tc->data[first_selected_index];
2182 if (td->flag & TD_SELECTED) {
2183 has_selected_any = true;
2184 break;
2185 }
2186 }
2187
2188 if (!has_selected_any) {
2189 postTrans(C, t);
2190 return false;
2191 }
2192 }
2193
2194 if (event) {
2195 /* Stupid code to have Ctrl-Click on gizmo work ok.
2196 *
2197 * Do this only for translation/rotation/resize because only these
2198 * modes are available from gizmo and doing such check could
2199 * lead to keymap conflicts for other modes (see #31584)
2200 */
2202 for (const wmKeyMapItem &kmi : t->keymap->items) {
2203 if (kmi.flag & KMI_INACTIVE) {
2204 continue;
2205 }
2206
2207 if ((kmi.propvalue == TFM_MODAL_SNAP_INV_ON) &&
2209 {
2211 break;
2212 }
2213 }
2214 }
2215 if (t->data_type == &TransConvertType_Node) {
2216 /* Set the initial auto-attach flag based on whether the chosen keymap key is pressed at the
2217 * start of the operator. */
2219 for (const wmKeyMapItem &kmi : t->keymap->items) {
2220 if (kmi.flag & KMI_INACTIVE) {
2221 continue;
2222 }
2223
2224 if ((kmi.propvalue == TFM_MODAL_NODE_ATTACH_OFF) &&
2226 {
2228 break;
2229 }
2230 }
2231 }
2232 }
2233
2234 initSnapping(t, op); /* Initialize snapping data AFTER mode flags. */
2235
2236 /* EVIL! pose-mode code can switch translation to rotate when 1 bone is selected.
2237 * will be removed (ton). */
2238
2239 /* EVIL2: we gave as argument also texture space context bit... was cleared. */
2240
2241 /* EVIL3: extend mode for animation editors also switches modes...
2242 * but is best way to avoid duplicate code. */
2243 mode = t->mode;
2244
2246 calculateCenter(t);
2247
2248 if (event) {
2249 /* Initialize accurate transform to settings requested by keymap. */
2250 bool use_accurate = false;
2251 if ((prop = RNA_struct_find_property(op->ptr, "use_accurate")) &&
2252 RNA_property_is_set(op->ptr, prop))
2253 {
2254 if (RNA_property_boolean_get(op->ptr, prop)) {
2255 use_accurate = true;
2256 }
2257 }
2258
2259 initMouseInput(t, &t->mouse, t->center2d, t->mval, use_accurate);
2260 }
2261
2262 transform_mode_init(t, op, mode);
2263
2264 if (t->state == TRANS_CANCEL) {
2265 postTrans(C, t);
2266 return false;
2267 }
2268
2269 /* Transformation axis from operator. */
2270 if ((prop = RNA_struct_find_property(op->ptr, "orient_axis")) &&
2271 RNA_property_is_set(op->ptr, prop))
2272 {
2273 t->orient_axis = RNA_property_enum_get(op->ptr, prop);
2274 }
2275 if ((prop = RNA_struct_find_property(op->ptr, "orient_axis_ortho")) &&
2276 RNA_property_is_set(op->ptr, prop))
2277 {
2279 }
2280
2281 /* Constraint init from operator. */
2282 if (t->con.mode & CON_APPLY) {
2283 setUserConstraint(t, t->con.mode, "%s");
2284 }
2285
2286 /* Don't write into the values when non-modal because they are already set from operator redo
2287 * values. */
2288 if (t->flag & T_MODAL) {
2289 /* Setup the mouse input with initial values. */
2290 applyMouseInput(t, &t->mouse, t->mouse.imval, t->values);
2291 }
2292
2293 if ((prop = RNA_struct_find_property(op->ptr, "preserve_clnor"))) {
2294 if ((t->flag & T_EDIT) && t->obedit_type == OB_MESH) {
2295
2298 bool do_skip = false;
2299
2300 /* Currently only used for two of three most frequent transform ops,
2301 * can include more ops.
2302 * Note that scaling cannot be included here,
2303 * non-uniform scaling will affect normals. */
2305 if (bm->totvertsel == bm->totvert) {
2306 /* No need to invalidate if whole mesh is selected. */
2307 do_skip = true;
2308 }
2309 }
2310
2311 if (t->flag & T_MODAL) {
2312 RNA_property_boolean_set(op->ptr, prop, false);
2313 }
2314 else if (!do_skip) {
2315 const bool preserve_clnor = RNA_property_boolean_get(op->ptr, prop);
2316 if (preserve_clnor) {
2318 t->flag |= T_CLNOR_REBUILD;
2319 }
2321 }
2322 }
2323 }
2324 }
2325
2326 if ((t->flag & T_MODAL) && t->mode_info && t->mode_info->status_fn) {
2327 t->mode_info->status_fn(t);
2328 }
2329
2330 t->context = nullptr;
2331
2332 return true;
2333}
2334
2336{
2337 t->context = C;
2338
2339 if (t->redraw == TREDRAW_HARD) {
2341 if (t->mode_info) {
2342 t->mode_info->transform_fn(t); /* Calls #recalc_data(). */
2343 if ((t->flag & T_MODAL) && t->mode_info->status_fn) {
2344 t->mode_info->status_fn(t);
2345 }
2346 }
2347 }
2348
2349 if (t->redraw & TREDRAW_SOFT) {
2350 viewRedrawForce(C, t);
2351 }
2352
2354
2355 /* If auto confirm is on, break after one pass. */
2356 if (t->options & CTX_AUTOCONFIRM) {
2357 t->state = TRANS_CONFIRM;
2358 }
2359
2360 t->context = nullptr;
2361}
2362
2364{
2366
2367 t->context = C;
2368
2370 /* Handle restoring objects. */
2371 if (t->state == TRANS_CANCEL) {
2372 exit_code = OPERATOR_CANCELLED;
2373 restoreTransObjects(t); /* Calls #recalc_data(). */
2374 }
2375 else {
2376 if (t->flag & T_CLNOR_REBUILD) {
2379 BM_lnorspace_rebuild(bm, true);
2380 }
2381 }
2382 exit_code = OPERATOR_FINISHED;
2383 }
2384
2385 /* Does insert keyframes, and clears base flags; doesn't read `transdata`. */
2387
2388 /* Free data, also handles overlap [in freeTransCustomData()]. */
2389 postTrans(C, t);
2390
2391 /* Send events out for redraws. */
2392 viewRedrawPost(C, t);
2393
2394 viewRedrawForce(C, t);
2395
2397 }
2398
2399 t->context = nullptr;
2400
2401 return exit_code;
2402}
2403
2405
2406/* -------------------------------------------------------------------- */
2409
2411{
2412 /* Currently only checks for editmode. */
2413 if (t->flag & T_EDIT) {
2414 if ((t->around == V3D_AROUND_LOCAL_ORIGINS) &&
2416 {
2417 /* Not all editmode supports axis-matrix. */
2418 return true;
2419 }
2420 }
2421
2422 return false;
2423}
2424
2425bool transform_apply_matrix(TransInfo *t, float mat[4][4])
2426{
2427 if (t->mode_info && t->mode_info->transform_matrix_fn) {
2428 t->mode_info->transform_matrix_fn(t, mat);
2429 return true;
2430 }
2431 return false;
2432}
2433
2434void transform_final_value_get(const TransInfo *t, float *value, const int value_num)
2435{
2436 memcpy(value, t->values_final, sizeof(float) * value_num);
2437}
2438
2439void view_vector_calc(const TransInfo *t, const float focus[3], float r_vec[3])
2440{
2441 if (t->persp != RV3D_ORTHO) {
2442 sub_v3_v3v3(r_vec, t->viewinv[3], focus);
2443 }
2444 else {
2445 copy_v3_v3(r_vec, t->viewinv[2]);
2446 }
2447 normalize_v3(r_vec);
2448}
2449
2451
2452} // namespace blender::ed::transform
Functions to insert, delete or modify keyframes.
Camera data-block and utility functions.
#define BLF_DRAW_STR_DUMMY_MAX
Definition BLF_api.hh:456
#define IFACE_(msgid)
#define RGN_TYPE_ANY
#define SPACE_TYPE_ANY
#define NUM_MODAL_INCREMENT_DOWN
#define NUM_MODAL_INCREMENT_UP
#define REGION_DRAW_POST_VIEW
#define REGION_DRAW_POST_PIXEL
#define C
Definition RandGen.cpp:29
#define ND_SEQUENCER
Definition WM_types.hh:456
#define NC_GEOM
Definition WM_types.hh:406
#define ND_DATA
Definition WM_types.hh:552
#define NC_ANIMATION
Definition WM_types.hh:401
#define NC_MOVIECLIP
Definition WM_types.hh:410
#define NC_SCENE
Definition WM_types.hh:391
#define ND_SPACE_NODE_VIEW
Definition WM_types.hh:579
#define NA_ADDED
Definition WM_types.hh:636
#define ND_POSE
Definition WM_types.hh:482
#define NA_EDITED
Definition WM_types.hh:634
#define ND_NLA
Definition WM_types.hh:540
#define ND_TRANSFORM
Definition WM_types.hh:475
#define NC_MASK
Definition WM_types.hh:411
#define ND_KEYS
Definition WM_types.hh:504
#define ND_KEYFRAME
Definition WM_types.hh:537
#define NC_OBJECT
Definition WM_types.hh:392
#define NC_SPACE
Definition WM_types.hh:405
#define SET_FLAG_FROM_TEST(value, test, flag)
#define ELEM(...)
#define BLI_assert_msg(a, msg)
CCL_NAMESPACE_BEGIN struct Options options
bool is_autokey_on(const Scene *scene)
bool autokeyframe_cfra_can_key(const Scene *scene, ID *id)
static void viewRedrawPost(bContext *C, TransInfo *t)
void calculateCenter(TransInfo *t)
void transformApply(bContext *C, TransInfo *t)
TransConvertTypeInfo TransConvertType_Mesh
void setTransformViewMatrices(TransInfo *t)
void resetTransRestrictions(TransInfo *t)
wmKeyMap * transform_modal_keymap(wmKeyConfig *keyconf)
TransConvertTypeInfo TransConvertType_Sequencer
void transform_snap_reset_from_mode(TransInfo *t, wmOperator *op)
void special_aftertrans_update(bContext *C, TransInfo *t)
void postSelectConstraint(TransInfo *t)
void transform_snap_flag_from_modifiers_set(TransInfo *t)
TransConvertTypeInfo TransConvertType_Node
bool calculateTransformCenter(bContext *C, int centerMode, float cent3d[3], float cent2d[2])
bool transform_mode_is_changeable(const int mode)
void setUserConstraint(TransInfo *t, int mode, const char text_[])
static void convertViewVec2D_mask(View2D *v2d, float r_vec[3], int dx, int dy)
void removeSnapPoint(TransInfo *t)
bool transformModeUseSnap(const TransInfo *t)
void initSnapping(TransInfo *t, wmOperator *op)
bool validSnap(const TransInfo *t)
void setLocalConstraint(TransInfo *t, int mode, const char text[])
static bool transform_modal_item_poll(const wmOperator *op, int value)
void projectFloatView(TransInfo *t, const float vec[3], float adr[2])
static void drawTransformPixel(const bContext *, ARegion *region, void *arg)
void view_vector_calc(const TransInfo *t, const float focus[3], float r_vec[3])
void transform_draw_cursor_draw(bContext *C, const int2 &xy, const float2 &, void *customdata)
void initMouseInput(TransInfo *t, MouseInput *mi, const float2 &center, const float2 &mval, bool precision)
void convertViewVec(TransInfo *t, float r_vec[3], double dx, double dy)
static void convertViewVec2D(View2D *v2d, float r_vec[3], int dx, int dy)
void restoreTransObjects(TransInfo *t)
eRedrawFlag handleSnapping(TransInfo *t, const wmEvent *event)
void saveTransform(bContext *C, TransInfo *t, wmOperator *op)
void resetTransModal(TransInfo *t)
eTfmMode transform_mode_really_used(bContext *C, eTfmMode mode)
void transform_view_vector_calc(const TransInfo *t, const float focus[3], float r_vec[3])
static bool transinfo_show_overlay(TransInfo *t, ARegion *region)
void projectFloatViewEx(TransInfo *t, const float vec[3], float adr[2], const eV3DProjTest flag)
static void drawAutoKeyWarning(TransInfo *t, ARegion *region)
static void viewRedrawForce(const bContext *C, TransInfo *t)
void addSnapPoint(TransInfo *t)
void applyMouseInput(TransInfo *t, MouseInput *mi, const float2 &mval, float output[3])
void transform_autoik_update(TransInfo *t, short mode)
void transform_gizmo_3d_model_from_constraint_and_mode_set(TransInfo *t)
static void drawTransformView(const bContext *, ARegion *region, void *arg)
void projectIntView(TransInfo *t, const float vec[3], int adr[2])
void transform_mode_snap_source_init(TransInfo *t, wmOperator *op)
void setTransformViewAspect(TransInfo *t, float r_aspect[3])
void projectFloatViewCenterFallback(TransInfo *t, float adr[2])
void drawSnapping(TransInfo *t)
wmOperatorStatus transformEvent(TransInfo *t, wmOperator *op, const wmEvent *event)
void initTransInfo(bContext *C, TransInfo *t, wmOperator *op, const wmEvent *event)
bool transform_snap_is_active(const TransInfo *t)
void sort_trans_data_dist(TransInfo *t)
bool transform_draw_cursor_poll(bContext *C)
static bool transform_event_modal_constraint(TransInfo *t, short modal_type)
void removeAspectRatio(TransInfo *t, float vec[2])
void projectIntViewEx(TransInfo *t, const float vec[3], int adr[2], const eV3DProjTest flag)
void initSelectConstraint(TransInfo *t)
eSnapFlag * transform_snap_flag_from_spacetype_ptr(TransInfo *t, const PropertyRNA **r_prop=nullptr)
void selectConstraint(TransInfo *t)
void transform_final_value_get(const TransInfo *t, float *value, const int value_num)
wmOperatorStatus transformEnd(bContext *C, TransInfo *t)
void calculatePropRatio(TransInfo *t)
static void tool_settings_update_snap_toggle(TransInfo *t)
bool initTransform(bContext *C, TransInfo *t, wmOperator *op, const wmEvent *event, int mode)
void postTrans(bContext *C, TransInfo *t)
TransConvertTypeInfo TransConvertType_MeshUV
TransConvertTypeInfo TransConvertType_Tracking
void transform_mode_init(TransInfo *t, wmOperator *op, const int mode)
bool transform_apply_matrix(TransInfo *t, float mat[4][4])
void applyAspectRatio(TransInfo *t, float vec[2])
void drawConstraint(TransInfo *t)
int constraintModeToIndex(const TransInfo *t)
void drawPropCircle(TransInfo *t)
void transform_gizmo_3d_model_from_constraint_and_mode_restore(TransInfo *t)
void create_trans_data(bContext *C, TransInfo *t)
bool transdata_check_local_islands(TransInfo *t, short around)
void transform_orientations_current_set(TransInfo *t, const short orient_index)
float2 image_preview_unit_to_px(const Scene *scene, const float2 co_src)
SequencerToolSettings * tool_settings_ensure(Scene *scene)
Definition sequencer.cc:393
eSeqRippleFlag tool_settings_ripple_flag_get(Scene *scene)
Definition sequencer.cc:451
void tool_settings_overlap_mode_set(Scene *scene, eSeqOverlapMode overlap_mode)
Definition sequencer.cc:439
eSeqOverlapMode tool_settings_overlap_mode_get(Scene *scene)
Definition sequencer.cc:445
void get_color_4fv(int colorid, float col[4])
void view2d_view_to_region(const View2D *v2d, float x, float y, int *r_region_x, int *r_region_y) ATTR_NONNULL()
Definition view2d.cc:1705
void icon_draw(float x, float y, int icon_id)
MINLINE float min_ff(float a, float b)
void WM_main_add_notifier(uint type, void *reference)
eV3DProjStatus ED_view3d_project_int_global(const ARegion *region, const float co[3], int r_co[2], eV3DProjTest flag)
UserDef U
Definition blender.cc:58
BLI_assert(slot->slot_subtype.map==BMO_OP_SLOT_SUBTYPE_MAP_FLT)
void RNA_float_set_array(PointerRNA *ptr, const char *name, const float *values)
@ UVCALC_TRANSFORM_CORRECT_SLIDE
@ UVCALC_TRANSFORM_CORRECT
@ V3D_PROJ_RET_OK
Definition ED_view3d.hh:273
Object * BKE_view_layer_active_object_get(const ViewLayer *view_layer)
Scene * CTX_data_sequencer_scene(const bContext *C)
PropertyRNA * RNA_struct_find_property(PointerRNA *ptr, const char *identifier)
BMesh * BKE_editmesh_bmesh_get_for_write(Mesh *mesh)
Definition editmesh.cc:79
MINLINE void copy_v3_v3(float r[3], const float a[3])
void ED_space_image_get_aspect(SpaceImage *sima, float *r_aspx, float *r_aspy)
bool handleNumInput(bContext *C, NumInput *n, const wmEvent *event)
Definition numinput.cc:344
WorkSpace * CTX_wm_workspace(const bContext *C)
@ V3D_ORIENT_CUSTOM_MATRIX
void BLF_shadow(int fontid, FontShadowType type, const float rgba[4]=nullptr)
Definition blf.cc:967
void RNA_property_float_set(PointerRNA *ptr, PropertyRNA *prop, float value)
MINLINE void copy_v2_v2(float r[2], const float a[2])
int RNA_property_enum_get(PointerRNA *ptr, PropertyRNA *prop)
void ED_space_image_get_size(SpaceImage *sima, int *r_width, int *r_height)
@ V3D_AROUND_CENTER_BOUNDS
@ V3D_AROUND_LOCAL_ORIGINS
bool ED_uvedit_live_unwrap_timer_check(const wmTimer *timer)
void ED_clip_point_stable_pos__reverse(const SpaceClip *sc, const 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?...
bool hasNumInput(const NumInput *n)
Definition numinput.cc:188
bool is_negative_m4(const float mat[4][4])
wmWindow * CTX_wm_window(const bContext *C)
void RNA_enum_set(PointerRNA *ptr, const char *name, int value)
void RNA_property_float_set_array(PointerRNA *ptr, PropertyRNA *prop, const float *values)
void RNA_property_boolean_set_array(PointerRNA *ptr, PropertyRNA *prop, const bool *values)
ATTR_WARN_UNUSED_RESULT const BMVert * v
@ SI_OVERLAY_SHOW_OVERLAYS
const rcti * ED_region_visible_rect(ARegion *region)
Definition area.cc:4791
bool ED_space_clip_check_show_trackedit(const SpaceClip *sc)
@ ADS_OVERLAY_SHOW_OVERLAYS
void GPU_line_width(float width)
Definition gpu_state.cc:151
@ GPU_BLEND_NONE
Definition GPU_state.hh:88
@ GPU_BLEND_ALPHA
Definition GPU_state.hh:90
void ED_space_clip_get_aspect(const SpaceClip *sc, float *r_aspx, float *r_aspy)
bool RNA_property_boolean_get(PointerRNA *ptr, PropertyRNA *prop)
bool RNA_property_array_check(PropertyRNA *prop)
Global G
Definition blender.cc:57
@ USER_MINI_AXIS_TYPE_GIZMO
@ USER_MINI_AXIS_TYPE_MINIMAL
int BLF_set_default()
void BKE_mask_coord_to_movieclip(MovieClip *clip, MovieClipUser *user, float r_co[2], const float co[2])
@ SCE_SNAP_TARGET_NOT_ACTIVE
@ SCE_SNAP_TARGET_NOT_NONEDITED
@ SCE_SNAP_TARGET_ONLY_SELECTABLE
@ SCE_SNAP_TARGET_NOT_EDITED
@ WM_EVENT_IS_REPEAT
Definition WM_types.hh:744
BLI_INLINE int BLI_rcti_size_y(const struct rcti *rct)
Definition BLI_rect.hh:207
void * ED_region_draw_cb_activate(ARegionType *art, void(*draw)(const bContext *, ARegion *, void *), void *customdata, int type)
VecBase< float, 2 > float2
void * MEM_new_zeroed(size_t len, const char *str) ATTR_WARN_UNUSED_RESULT ATTR_ALLOC_SIZE(1) ATTR_NONNULL(2)
Object * BKE_view_layer_edit_object_get(const ViewLayer *view_layer)
int BLF_default()
BLI_INLINE float BLI_rctf_size_y(const struct rctf *rct)
Definition BLI_rect.hh:215
rctf BKE_camera_view_border(const struct Scene *scene, const struct Depsgraph *depsgraph, const struct View3D *v3d, const struct RegionView3D *rv3d, int winx, int winy, bool no_shift, bool no_zoom, bool no_roll)
eV3DProjStatus ED_view3d_project_float_global(const ARegion *region, const float co[3], float r_co[2], eV3DProjTest flag)
bool ED_space_clip_check_show_maskedit(const SpaceClip *sc)
@ SCE_SNAP_INDIVIDUAL_PROJECT
void RNA_property_unset(PointerRNA *ptr, PropertyRNA *prop)
void ED_space_clip_get_aspect_dimension_aware(const SpaceClip *sc, float *r_aspx, float *r_aspy)
constexpr size_t ARRAY_SIZE(const T(&arg)[N]) noexcept
bool BKE_view_layer_synced_ensure(const Main &bmain, const Scene *scene, ViewLayer *view_layer)
void unit_m4(float m[4][4])
PointerRNA RNA_pointer_create_discrete(ID *id, StructRNA *type, void *data)
Mask * CTX_data_edit_mask(const bContext *C)
void WM_window_status_area_tag_redraw(wmWindow *win)
void ED_area_status_text(ScrArea *area, const char *str)
Definition area.cc:975
ToolSettings * CTX_data_tool_settings(const bContext *C)
MINLINE void zero_v3(float r[3])
BLI_INLINE int BLI_rcti_size_x(const struct rcti *rct)
Definition BLI_rect.hh:203
void WM_event_add_notifier(const bContext *C, uint type, void *reference)
void RNA_float_set(PointerRNA *ptr, const char *name, float value)
void RNA_boolean_set(PointerRNA *ptr, const char *name, bool value)
bool WM_event_modifier_flag_match_kmi_press(const wmEventModifierFlag event_modifier, const wmKeyMapItem *kmi)
wmPaintCursor * WM_paint_cursor_activate(short space_type, short region_type, wmPaintCursorPoll poll, wmPaintCursorDraw draw, void *customdata)
@ SEQ_RIPPLE_ALL_CHANNELS
float RNA_property_float_get(PointerRNA *ptr, PropertyRNA *prop)
MINLINE float normalize_v3(float n[3])
void BLF_draw_default(float x, float y, float z, const char *str, size_t str_len) ATTR_NONNULL()
void BKE_editmesh_lnorspace_update(BMesh *bm)
Definition editmesh.cc:253
MINLINE void sub_v3_v3v3(float r[3], const float a[3], const float b[3])
void BKE_workspace_status_clear(WorkSpace *workspace)
Definition workspace.cc:720
void unit_m3(float m[3][3])
MovieClip * ED_space_clip_get_clip(const SpaceClip *sc)
MINLINE void copy_v3_fl(float r[3], float f)
BLI_INLINE float BLI_rctf_size_x(const struct rctf *rct)
Definition BLI_rect.hh:211
MINLINE float max_ff(float a, float b)
void ED_space_image_get_uv_aspect(SpaceImage *sima, float *r_aspx, float *r_aspy)
BLI_INLINE float BLI_rctf_cent_y(const struct rctf *rct)
Definition BLI_rect.hh:198
@ V3D_PROJ_TEST_NOP
Definition ED_view3d.hh:295
void RNA_property_enum_set(PointerRNA *ptr, PropertyRNA *prop, int value)
@ KM_PRESS_DRAG
Definition WM_types.hh:332
@ KM_RELEASE
Definition WM_types.hh:325
void RNA_property_boolean_set(PointerRNA *ptr, PropertyRNA *prop, bool value)
void BKE_mask_coord_to_image(Image *image, ImageUser *iuser, float r_co[2], const float co[2])
@ SNODE_INSERTOFS_DIR_LEFT
@ SNODE_INSERTOFS_DIR_RIGHT
wmKeyMap * WM_modalkeymap_ensure(wmKeyConfig *keyconf, const char *idname, const EnumPropertyItem *items)
Definition wm_keymap.cc:972
void GPU_blend(GPUBlend blend)
Definition gpu_state.cc:44
void copy_m4_m4(float m1[4][4], const float m2[4][4])
void ED_view3d_text_colors_get(const Scene *scene, const View3D *v3d, float r_text_color[4], float r_shadow_color[4])
int WM_userdef_event_type_from_keymap_type(int kmitype)
void BLF_width_and_height(int fontid, const char *str, size_t str_len, float *r_width, float *r_height) ATTR_NONNULL()
Definition blf.cc:822
void ED_image_point_pos__reverse(SpaceImage *sima, const ARegion *region, const float co[2], float r_co[2])
void BM_lnorspace_rebuild(BMesh *bm, bool preserve_clnor)
void ED_workspace_status_text(bContext *C, const char *str)
Definition area.cc:1153
@ V3D_GIZMO_HIDE_NAVIGATE
BLI_INLINE float BLI_rctf_cent_x(const struct rctf *rct)
Definition BLI_rect.hh:194
void WM_msg_publish_rna_params(wmMsgBus *mbus, const wmMsgParams_RNA *msg_key_params)
void ED_view3d_win_to_delta(const ARegion *region, const float xy_delta[2], float zfac, float r_out[3], bool precise=false)
bool RNA_property_is_set(PointerRNA *ptr, PropertyRNA *prop)
void WM_paint_cursor_tag_redraw(wmWindow *win, ARegion *)
Definition wm_draw.cc:1698
void BLF_color4fv(int fontid, const float rgba[4])
Definition blf.cc:507
void ED_area_tag_redraw(ScrArea *area)
Definition area.cc:784
void BM_lnorspace_invalidate(BMesh *bm, const bool do_invalidate_all)
#define atanf
KERNEL_FEATURE_LIGHT_PASSES KERNEL_FEATURE_PATH_GUIDING float
bke::ARegionRuntime * runtime
eRegion_Type regiontype
eRegionView3D_Persp persp
ListBaseT< SpaceLink > spacedata
SpaceActionOverlays_Flag flag
SpaceActionOverlays overlays
struct MovieClip * clip
struct MovieClipUser user
struct SpaceClipOverlay overlay
eSpaceImageOverlay_Flag flag
struct ImageUser iuser
SpaceImageOverlay overlay
eSpaceImage_Flag flag
eSpaceNode_InsertOffsetDir insert_ofs_dir
eSpaceSeq_Flag flag
eTool_UvCalcFlag uvcalc_flag
eView3D_Flag2 flag2
struct Object * camera
eView3D_GizmoFlag gizmo_flag
struct ARegionType * type
struct blender::ed::transform::TransInfo::@074260112357037217233016050204226071352346123342 orient[3]
TransConvertTypeInfo * data_type
Definition transform.hh:836
void(*) transform_matrix_fn(TransInfo *, float[4][4])
enum eRedrawFlag(*) handle_event_fn(TransInfo *, const wmEvent *)
eWM_EventFlag flag
Definition WM_types.hh:848
wmEventType type
Definition WM_types.hh:817
wmEventType prev_type
Definition WM_types.hh:872
wmEventModifierFlag modifier
Definition WM_types.hh:834
bool(*) poll_modal_item(const struct wmOperator *op, int value)
ListBaseT< wmKeyMapItem > items
const PropertyRNA * prop
#define T_PROP_SIZE_MIN
Definition transform.hh:37
#define T_PROP_EDIT_ALL
Definition transform.hh:34
#define T_PROP_SIZE_MAX
Definition transform.hh:38
#define FOREACH_TRANS_DATA_CONTAINER(t, th)
Definition transform.hh:48
conversion and adaptation of different datablocks to a common struct.
transform modes used by different operators.
#define ISMOUSE_MOTION(event_type)