Blender V5.3
transform_generics.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 <algorithm>
10
11#include "DNA_brush_types.h"
12
13#include "BLI_listbase.hh"
14#include "BLI_math_matrix.hh"
15#include "BLI_math_matrix_c.hh"
17#include "BLI_math_vector_c.hh"
18#include "BLI_rand_c.hh"
19#include "BLI_string_utf8.hh"
20#include "BLI_time.hh"
21
22#include "BLT_translation.hh"
23
24#include "RNA_access.hh"
25
26#include "BKE_brush.hh"
27#include "BKE_context.hh"
28#include "BKE_layer.hh"
29#include "BKE_mask.hh"
30#include "BKE_modifier.hh"
31#include "BKE_paint.hh"
32#include "BKE_screen.hh"
33
34#include "SEQ_transform.hh"
35
36#include "ED_clip.hh"
37#include "ED_image.hh"
38#include "ED_object.hh"
39#include "ED_screen.hh"
40#include "ED_space_api.hh"
41#include "ED_uvedit.hh"
42
43#include "WM_api.hh"
44
45#include "UI_view2d.hh"
46
47#include "SEQ_sequencer.hh"
48
49#include "transform.hh"
50#include "transform_convert.hh"
51#include "transform_gizmo.hh"
53#include "transform_snap.hh"
54
55namespace blender::ed::transform {
56
57/* ************************** GENERICS **************************** */
58
63
68
69static void *t_view_get(TransInfo *t)
70{
71 if (t->spacetype == SPACE_VIEW3D) {
72 View3D *v3d = t->area->spacedata.first_as<View3D>();
73 return static_cast<void *>(v3d);
74 }
75 if (t->region) {
76 return static_cast<void *>(&t->region->v2d);
77 }
78 return nullptr;
79}
80
81static int t_around_get(TransInfo *t)
82{
83 if (t->flag & T_OVERRIDE_CENTER) {
84 /* Avoid initialization of individual origins (#V3D_AROUND_LOCAL_ORIGINS). */
86 }
87
88 ScrArea *area = t->area;
89 switch (t->spacetype) {
90 case SPACE_VIEW3D: {
91 if (t->mode == TFM_BEND) {
92 /* Bend always uses the cursor. */
93 return V3D_AROUND_CURSOR;
94 }
96 }
97 case SPACE_IMAGE: {
98 SpaceImage *sima = area->spacedata.first_as<SpaceImage>();
99 return sima->around;
100 }
101 case SPACE_GRAPH: {
102 SpaceGraph *sipo = area->spacedata.first_as<SpaceGraph>();
103 return sipo->around;
104 }
105 case SPACE_CLIP: {
106 SpaceClip *sclip = area->spacedata.first_as<SpaceClip>();
107 return sclip->around;
108 }
109 case SPACE_SEQ: {
112 }
113 break;
114 }
115 default:
116 break;
117 }
118
120}
121
122void initTransInfo(bContext *C, TransInfo *t, wmOperator *op, const wmEvent *event)
123{
124 Main *bmain = CTX_data_main(C);
125 Scene *sce = CTX_data_scene(C);
126 ViewLayer *view_layer = CTX_data_view_layer(C);
127 BKE_view_layer_synced_ensure(*bmain, sce, view_layer);
128 Object *obact = BKE_view_layer_active_object_get(view_layer);
129 const eObjectMode object_mode = obact ? obact->mode : OB_MODE_OBJECT;
131 ARegion *region = CTX_wm_region(C);
132 ScrArea *area = CTX_wm_area(C);
133 const bool is_sequencer = CTX_wm_space_seq(C) != nullptr;
134 if (!is_sequencer) {
135 t->scene = sce;
136 t->view_layer = view_layer;
137 }
138 else {
140 t->view_layer = t->scene ? BKE_view_layer_default_render(t->scene) : nullptr;
141 }
142
143 PropertyRNA *prop;
144
147 t->bmain = bmain;
148
149 t->area = area;
150 t->region = region;
151 t->settings = ts;
152 t->reports = op ? op->reports : nullptr;
153
154 t->helpline = HLP_NONE;
155
156 t->flag = eTFlag(0);
157
158 if (obact && !(t->options & (CTX_CURSOR | CTX_TEXTURE_SPACE)) &&
160 {
161 t->obedit_type = obact->type;
162 }
163 else {
164 t->obedit_type = -1;
165 }
166
167 if (t->options & CTX_CURSOR) {
168 /* Cursor should always use the drag start as the combination of click-drag to place & move
169 * doesn't work well if the click location isn't used when transforming. */
171 }
172
173 /* Many kinds of transform only use a single handle. */
174 if (t->data_container == nullptr) {
176 t->data_container_len = 1;
177 }
178
179 t->redraw = TREDRAW_HARD; /* Redraw first time. */
180
181 float2 mval;
182 if (event) {
183 if (t->flag & T_EVENT_DRAG_START) {
184 WM_event_drag_start_mval_fl(event, region, mval);
185 }
186 else {
187 mval = float2(event->mval);
188 }
189 }
190 else {
191 mval = float2(0, 0);
192 }
193
194 t->mval = mval;
195
196 /* Initialize this mouse variable in advance as it is required by
197 * `transform_convert_frame_side_dir_get` which is called before `initMouseInput`. */
198 t->mouse.imval = mval;
199
200 t->mode_info = nullptr;
201
202 t->data_len_all = 0;
203
205
206 unit_m3(t->mat);
207
208 /* Default to rotate on the Z axis. */
209 t->orient_axis = 2;
210 t->orient_axis_ortho = 1;
211
212 /* If there's an event, we're modal. */
213 if (event) {
214 t->flag |= T_MODAL;
215
216 /* Keymap for shortcut header prints. */
218 }
219
220 /* Crease needs edge flag. */
223 }
224
225 t->remove_on_cancel = false;
226
227 if (op && (prop = RNA_struct_find_property(op->ptr, "remove_on_cancel")) &&
228 RNA_property_is_set(op->ptr, prop))
229 {
230 if (RNA_property_boolean_get(op->ptr, prop)) {
231 t->remove_on_cancel = true;
232 }
233 }
234
235 /* Grease Pencil editing context. */
236 if (t->obedit_type == OB_GREASE_PENCIL &&
237 (object_mode == OB_MODE_EDIT || object_mode == OB_MODE_PAINT_GREASE_PENCIL) &&
238 ((area == nullptr) || (area->spacetype == SPACE_VIEW3D)))
239 {
241 }
242
243 /* Assign the space type, some exceptions for running in different mode. */
244 if (area == nullptr) {
245 /* Background mode. */
247 }
248 else if (((region == nullptr) || (region->regiondata == nullptr)) &&
249 (area->spacetype == SPACE_VIEW3D))
250 {
251 /* Running the operator through the text editor where e.g. `area.type` was
252 * set to 'VIEW_3D' but the viewport was not updated. */
254 }
255 else {
256 /* Normal operation. */
257 t->spacetype = area->spacetype;
258 }
259
260 /* Handle #T_ALT_TRANSFORM initialization, we may use for different operators. */
261 if (op) {
262 const char *prop_id = nullptr;
263 if (t->mode == TFM_SHRINKFATTEN) {
264 prop_id = "use_even_offset";
265 }
266
267 if (prop_id && (prop = RNA_struct_find_property(op->ptr, prop_id))) {
269 }
270 }
271
272 if (t->spacetype == SPACE_VIEW3D) {
274
275 t->animtimer = (animscreen) ? animscreen->animtimer : nullptr;
276
278 t->flag |= T_V3D_ALIGN;
279 }
280
281 if (object_mode & (OB_MODE_ALL_PAINT_MESH | OB_MODE_SCULPT_CURVES)) {
283 Brush *brush = (paint) ? BKE_paint_brush(paint) : nullptr;
284 if (brush && (brush->stroke_method == BRUSH_STROKE_CURVE)) {
286 }
287 }
288
289 /* Initialize UV transform from. */
290 if (op && (prop = RNA_struct_find_property(op->ptr, "correct_uv"))) {
291 if (RNA_property_is_set(op->ptr, prop)) {
292 if (RNA_property_boolean_get(op->ptr, prop)) {
294 }
295 else {
297 }
298 }
299 else {
302 }
303 }
304 }
305 else if (t->spacetype == SPACE_IMAGE) {
306 SpaceImage *sima = area->spacedata.first_as<SpaceImage>();
309 /* UV transform. */
310 }
311 else if (sima->mode == SI_MODE_MASK) {
312 t->options |= CTX_MASK;
313 }
314 else if (sima->mode == SI_MODE_PAINT) {
316 Brush *brush = (paint) ? BKE_paint_brush(paint) : nullptr;
317 if (brush && (brush->stroke_method == BRUSH_STROKE_CURVE)) {
319 }
320 }
321 /* Image not in UV edit, nor in mask mode, can happen for some tools. */
322 }
323 else if (t->spacetype == SPACE_CLIP) {
324 SpaceClip *sclip = area->spacedata.first_as<SpaceClip>();
327 }
328 else if (ED_space_clip_check_show_maskedit(sclip)) {
329 t->options |= CTX_MASK;
330 }
331 }
332 else if (t->spacetype == SPACE_SEQ && region->regiontype == RGN_TYPE_PREVIEW) {
334
335 /* Needed for auto-keying transforms in preview during playback. */
337 t->animtimer = (animscreen) ? animscreen->animtimer : nullptr;
338 }
339
341
342 if (op && (prop = RNA_struct_find_property(op->ptr, "center_override")) &&
343 RNA_property_is_set(op->ptr, prop))
344 {
348 }
349
350 t->view = t_view_get(t);
351 t->around = t_around_get(t);
352
353 /* Exceptional case. */
356 const bool use_island = transdata_check_local_islands(t, t->around);
357
358 if ((t->obedit_type != -1) && !use_island) {
359 t->options |= CTX_NO_PET;
360 }
361 }
362 }
363
364 bool t_values_set_is_array = false;
365
366 if (op && (prop = RNA_struct_find_property(op->ptr, "value")) &&
367 RNA_property_is_set(op->ptr, prop))
368 {
369 float values[4] = {0}; /* In case value isn't length 4, avoid uninitialized memory. */
370 if (RNA_property_array_check(prop)) {
371 RNA_property_float_get_array(op->ptr, prop, values);
372 t_values_set_is_array = true;
373 }
374 else {
375 values[0] = RNA_property_float_get(op->ptr, prop);
376 }
377
378 if (t->flag & T_MODAL) {
379 /* Run before init functions so 'values_modal_offset' can be applied on mouse input. */
381 }
382 else {
383 copy_v4_v4(t->values, values);
385 }
386 }
387
388 if (op && (prop = RNA_struct_find_property(op->ptr, "constraint_axis"))) {
389 bool constraint_axis[3] = {false, false, false};
390 if (t_values_set_is_array && t->flag & T_INPUT_IS_VALUES_FINAL) {
391 /* For operators whose `t->values` is array (as Move and Scale), set constraint so that the
392 * orientation is more intuitive in the Redo Panel. */
393 constraint_axis[0] = constraint_axis[1] = constraint_axis[2] = true;
394 }
395 else if (RNA_property_is_set(op->ptr, prop)) {
396 RNA_property_boolean_get_array(op->ptr, prop, constraint_axis);
397 }
398
399 if (constraint_axis[0] || constraint_axis[1] || constraint_axis[2]) {
400 t->con.mode |= CON_APPLY;
401
402 if (constraint_axis[0]) {
403 t->con.mode |= CON_AXIS0;
404 }
405 if (constraint_axis[1]) {
406 t->con.mode |= CON_AXIS1;
407 }
408 if (constraint_axis[2]) {
409 t->con.mode |= CON_AXIS2;
410 }
411 }
412 }
413
414 {
415 eTOType orient_types[3];
416 eTOType orient_type_apply = O_DEFAULT;
417 float custom_matrix[3][3];
418
419 int orient_type_scene = V3D_ORIENT_GLOBAL;
420 int orient_type_default = -1;
421 int orient_type_set = -1;
422 int orient_type_matrix_set = -1;
423
424 if ((t->spacetype == SPACE_VIEW3D) && (t->region->regiontype == RGN_TYPE_WINDOW)) {
426 orient_type_scene = orient_slot->type;
427 if (orient_type_scene == V3D_ORIENT_CUSTOM) {
428 const int index_custom = orient_slot->index_custom;
429 orient_type_scene += index_custom;
430 }
431 }
432
433 if (op && ((prop = RNA_struct_find_property(op->ptr, "orient_type")) &&
434 RNA_property_is_set(op->ptr, prop)))
435 {
436 orient_type_set = RNA_property_enum_get(op->ptr, prop);
437 if (orient_type_set >= V3D_ORIENT_CUSTOM + BIF_countTransformOrientation(C)) {
438 orient_type_set = V3D_ORIENT_GLOBAL;
439 }
440 }
441
442 if (op && (prop = RNA_struct_find_property(op->ptr, "orient_axis"))) {
443 t->orient_axis = RNA_property_enum_get(op->ptr, prop);
444 }
445
446 if (op && (prop = RNA_struct_find_property(op->ptr, "orient_axis_ortho"))) {
448 }
449
450 /* The properties "orient_matrix" and "orient_matrix_type" are used to store the orientation
451 * calculated in the first operator call. This allows for reuse of the orientation during
452 * subsequent calls of the same operator. When making adjustments through the Redo panel
453 * (#OP_IS_REPEAT), reusing the orientation prevents unpredictable changes that can occur when
454 * using #V3D_ORIENT_VIEW. However, when activated by #SCREEN_OT_repeat_last
455 * (#OP_IS_REPEAT_LAST), it's best to avoid reusing the orientation to prevent unintended
456 * changes. */
457 if (op && !(op->flag & OP_IS_REPEAT_LAST) &&
458 ((prop = RNA_struct_find_property(op->ptr, "orient_matrix")) &&
459 RNA_property_is_set(op->ptr, prop)))
460 {
461 RNA_property_float_get_array(op->ptr, prop, &custom_matrix[0][0]);
462
463 if ((prop = RNA_struct_find_property(op->ptr, "orient_matrix_type")) &&
464 RNA_property_is_set(op->ptr, prop))
465 {
466 orient_type_matrix_set = RNA_property_enum_get(op->ptr, prop);
467 }
468 else if (orient_type_set == -1) {
469 orient_type_set = V3D_ORIENT_CUSTOM_MATRIX;
470 }
471 }
472
473 orient_type_default = orient_type_scene;
474
475 if (orient_type_set != -1) {
476 if (!(t->con.mode & CON_APPLY)) {
477 /* Only overwrite default if not constrained. */
478 orient_type_default = orient_type_set;
480 }
481 }
482 else if (orient_type_matrix_set != -1) {
483 orient_type_set = orient_type_matrix_set;
484 if (!(t->con.mode & CON_APPLY)) {
485 /* Only overwrite default if not constrained. */
486 orient_type_default = orient_type_set;
488 }
489 }
490
491 if (orient_type_set == -1) {
492 if (orient_type_scene == V3D_ORIENT_GLOBAL) {
493 orient_type_set = V3D_ORIENT_LOCAL;
494 }
495 else {
496 orient_type_set = V3D_ORIENT_GLOBAL;
497 }
498
499 if (t->con.mode & CON_APPLY) {
500 orient_type_apply = O_SCENE;
501 }
502 }
503 else {
504 orient_type_apply = O_SET;
505 }
506
507 BLI_assert(!ELEM(-1, orient_type_default, orient_type_set));
508 if (orient_type_matrix_set == orient_type_set) {
509 /* Constraints are forced to use the custom matrix when redoing. */
510 orient_type_set = V3D_ORIENT_CUSTOM_MATRIX;
511 }
512
513 orient_types[O_DEFAULT] = eTOType(orient_type_default);
514 orient_types[O_SCENE] = eTOType(orient_type_scene);
515 orient_types[O_SET] = eTOType(orient_type_set);
516
517 for (int i = 0; i < 3; i++) {
518 /* For efficiency, avoid calculating the same orientation twice. */
519 int j;
520 for (j = 0; j < i; j++) {
521 if (orient_types[j] == orient_types[i]) {
522 memcpy(&t->orient[i], &t->orient[j], sizeof(*t->orient));
523 break;
524 }
525 }
526 if (j == i) {
528 C, t, orient_types[i], custom_matrix, t->orient[i].matrix);
529 }
530 }
531
532 t->orient_type_mask = 0;
533 for (int i = 0; i < 3; i++) {
534 const int type = t->orient[i].type;
535 if (type < V3D_ORIENT_CUSTOM_MATRIX) {
536 BLI_assert(type < 32);
537 t->orient_type_mask |= (1 << type);
538 }
539 }
540
541 transform_orientations_current_set(t, orient_type_apply);
542 }
543
544 if (op && ((prop = RNA_struct_find_property(op->ptr, "release_confirm")) &&
545 RNA_property_is_set(op->ptr, prop)))
546 {
547 if (RNA_property_boolean_get(op->ptr, prop)) {
549 }
550 }
551 else {
552 /* Release confirms preference should not affect node editor (#69288, #70504). */
554 ((U.flag & USER_RELEASECONFIRM) || (t->spacetype == SPACE_NODE)))
555 {
556 /* Global "release confirm" on mouse bindings. */
558 }
559 }
560
561 if (op &&
562 ((prop = RNA_struct_find_property(op->ptr, "mirror")) && RNA_property_is_set(op->ptr, prop)))
563 {
564 if (!RNA_property_boolean_get(op->ptr, prop)) {
565 t->flag |= T_NO_MIRROR;
566 }
567 }
568 else if ((t->spacetype == SPACE_VIEW3D) && (t->obedit_type == OB_MESH)) {
569 /* Pass. */
570 }
571 else {
572 /* Avoid mirroring for unsupported contexts. */
573 t->flag |= T_NO_MIRROR;
574 }
575
576 /* Setting proportional editing flag only if property exist in operator. Otherwise, assume it's
577 * not supported. */
578 if (op && (prop = RNA_struct_find_property(op->ptr, "use_proportional_edit"))) {
579 if (RNA_property_is_set(op->ptr, prop)) {
580 if (RNA_property_boolean_get(op->ptr, prop)) {
581 t->flag |= T_PROP_EDIT;
582 if (RNA_boolean_get(op->ptr, "use_proportional_connected")) {
584 }
585 if (RNA_boolean_get(op->ptr, "use_proportional_projected")) {
587 }
588 }
589 }
590 else {
591 /* Use settings from scene only if modal. */
592 if (t->flag & T_MODAL) {
593 if ((t->options & CTX_NO_PET) == 0) {
594 bool use_prop_edit = false;
595 if (t->spacetype == SPACE_GRAPH) {
596 use_prop_edit = ts->proportional_fcurve;
597 }
598 else if (t->spacetype == SPACE_ACTION) {
599 use_prop_edit = ts->proportional_action;
600 }
601 else if (t->options & CTX_MASK) {
602 use_prop_edit = ts->proportional_mask;
603 }
604 else if (object_mode == OB_MODE_OBJECT) {
605 /* No active object means #TransConvertType_Object [see #convert_type_get()], so use
606 * tool-setting for *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;
617 }
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 {
629 t->prop_size = RNA_property_float_get(op->ptr, prop);
630 }
631 else {
633 }
634
635 /* TRANSFORM_FIX_ME rna restrictions. */
636 if (t->prop_size <= 0.00001f) {
637 printf("Proportional size (%f) under 0.00001, resetting to 1!\n", t->prop_size);
638 t->prop_size = 1.0f;
639 }
640
641 if (op && ((prop = RNA_struct_find_property(op->ptr, "proportional_edit_falloff")) &&
642 RNA_property_is_set(op->ptr, prop)))
643 {
644 t->prop_mode = RNA_property_enum_get(op->ptr, prop);
645 }
646 else {
647 t->prop_mode = ts->prop_mode;
648 }
649 }
650 else { /* Add not pet option to context when not available. */
651 t->options |= CTX_NO_PET;
652 }
653
654 if (op && (prop = RNA_struct_find_property(op->ptr, "use_automerge_and_split")) &&
655 RNA_property_is_set(op->ptr, prop))
656 {
657 if (RNA_property_boolean_get(op->ptr, prop)) {
659 }
660 }
661 else if (t->obedit_type == OB_MESH) {
662 char automerge = t->scene->toolsettings->automerge;
663 if (automerge & AUTO_MERGE) {
664 t->flag |= T_AUTOMERGE;
665 if (automerge & AUTO_MERGE_AND_SPLIT) {
666 t->flag |= T_AUTOSPLIT;
667 }
668 }
669 }
670
671 if (op && (prop = RNA_struct_find_property(op->ptr, "use_duplicated_keyframes")) &&
672 RNA_property_is_set(op->ptr, prop))
673 {
674 if (RNA_property_boolean_get(op->ptr, prop)) {
676 }
677 }
678
679/* Mirror is not supported with proportional editing, turn it off. */
680#if 0
681 if (t->flag & T_PROP_EDIT) {
682 t->flag &= ~T_MIRROR;
683 }
684#endif
685
686 /* Disable cursor wrap when edge panning is enabled. */
687 if (t->options & CTX_VIEW2D_EDGE_PAN) {
689 }
690
691 if ((t->flag & T_MODAL) && (t->keymap != nullptr) &&
692 ELEM(t->mode,
699 {
700 const wmKeyMapItem *kmi_passthrough = nullptr;
701 for (const wmKeyMapItem &kmi : t->keymap->items) {
702 if (kmi.flag & KMI_INACTIVE) {
703 continue;
704 }
705
707 kmi_passthrough = &kmi;
708 break;
709 }
710 }
711 t->vod = ED_view3d_navigation_init(C, kmi_passthrough);
712 }
713
714 if (t->mode == TFM_TRANSLATION) {
715 if ((prop = RNA_struct_find_property(op->ptr, "translate_origin")) &&
716 RNA_property_is_set(op->ptr, prop))
717 {
718 if (RNA_property_boolean_get(op->ptr, prop)) {
719 t->flag |= T_ORIGIN;
720 }
721 }
722 }
723
727 initNumInput(&t->num);
728
730}
731
733{
734 if (custom_data->free_cb) {
735 /* Can take over freeing t->data and data_2d etc... */
736 custom_data->free_cb(t, tc, custom_data);
737 BLI_assert(custom_data->data == nullptr);
738 }
739 else if ((custom_data->data != nullptr) && custom_data->use_free) {
740 MEM_delete_void(custom_data->data);
741 custom_data->data = nullptr;
742 }
743 /* In case modes are switched in the same transform session. */
744 custom_data->free_cb = nullptr;
745 custom_data->use_free = false;
746}
747
751{
752 TransCustomData *custom_data = &tcdc->first_elem;
753 for (int i = 0; i < TRANS_CUSTOM_DATA_ELEM_MAX; i++, custom_data++) {
754 freeTransCustomData(t, tc, custom_data);
755 }
756}
757
759{
760 freeTransCustomData(t, nullptr, &t->custom.mode);
762 freeTransCustomData(t, tc, &tc->custom.mode);
763 }
764}
765
767{
768 if (t->draw_handle_view) {
770 }
771 if (t->draw_handle_pixel) {
773 }
774 if (t->draw_handle_cursor) {
776 }
777
778 if (t->flag & T_MODAL_CURSOR_SET) {
780 }
781
782 /* Free all custom-data. */
783 freeTransCustomDataContainer(t, nullptr, &t->custom);
786 }
787
788 /* #postTrans can be called when nothing is selected, so data is nullptr already. */
789 if (t->data_len_all != 0) {
791 /* Free data malloced per trans-data. */
793 TransData *td = tc->data;
794 for (int a = 0; a < tc->data_len; a++, td++) {
795 if (td->flag & TD_BEZTRIPLE) {
796 MEM_delete(td->hdata);
797 }
798 }
799 }
800 MEM_delete(tc->data);
801
802 MEM_SAFE_DELETE(tc->data_mirror);
803 MEM_SAFE_DELETE(tc->data_ext);
804 MEM_SAFE_DELETE(tc->data_2d);
805 MEM_SAFE_DELETE(tc->sorted_index_map);
806 }
807 }
808
809 MEM_SAFE_DELETE(t->data_container);
810 t->data_container = nullptr;
811
812 t->tsnap.points.free_no_destruct();
813
814 if (t->spacetype == SPACE_IMAGE) {
815 if (t->options & (CTX_MASK | CTX_PAINT_CURVE)) {
816 /* Pass. */
817 }
818 else {
819 SpaceImage *sima = t->area->spacedata.first_as<SpaceImage>();
820 if (sima->flag & SI_LIVE_UNWRAP) {
822 }
823 }
824 }
825
826 if (t->mouse.data) {
828 }
829
830 if (t->rng != nullptr) {
831 BLI_rng_free(t->rng);
832 }
833
834 freeSnapping(t);
835
836 if (t->vod) {
838 }
839}
840
842{
843 if (td_basic->loc) {
844 copy_v3_v3(td_basic->loc, td_basic->iloc);
845 }
846
847 /* TODO(mano-wii): Only use 3D or larger vectors in `td->loc`.
848 * If `loc` and `val` point to the same address, it may indicate that `loc` is not 3D which is
849 * not safe for `copy_v3_v3`. */
850 if (td_basic->val && td_basic->val != td_basic->loc) {
851 *td_basic->val = td_basic->ival;
852 }
853}
854
855static void restoreElement(TransData *td)
856{
857 transdata_restore_basic(static_cast<TransDataBasic *>(td));
858
859 if (td->flag & TD_BEZTRIPLE) {
860 *(td->hdata->h1) = td->hdata->ih1;
861 *(td->hdata->h2) = td->hdata->ih2;
862 }
863}
864
866{
868
869 TransData *td;
870 TransData2D *td2d;
871 TransDataMirror *tdm;
872
873 for (td = tc->data; td < tc->data + tc->data_len; td++) {
874 restoreElement(td);
875 }
876
877 for (tdm = tc->data_mirror; tdm < tc->data_mirror + tc->data_mirror_len; tdm++) {
878 transdata_restore_basic(static_cast<TransDataBasic *>(tdm));
879 }
880
881 if (tc->data_ext) {
882 for (int i = 0; i < tc->data_len; i++) {
883 if (tc->data[i].flag & TD_NO_EXT) {
884 continue;
885 }
886
887 TransDataExtension *td_ext = &tc->data_ext[i];
888 if (td_ext->rot) {
889 copy_v3_v3(td_ext->rot, td_ext->irot);
890 }
891 if (td_ext->rotAngle) {
892 *td_ext->rotAngle = td_ext->irotAngle;
893 }
894 if (td_ext->rotAxis) {
895 copy_v3_v3(td_ext->rotAxis, td_ext->irotAxis);
896 }
897 /* XXX, `drotAngle` & `drotAxis` not used yet. */
898 if (td_ext->scale) {
899 copy_v3_v3(td_ext->scale, td_ext->iscale);
900 }
901 if (td_ext->quat) {
902 copy_qt_qt(td_ext->quat, td_ext->iquat);
903 }
904 }
905 }
906
907 for (td2d = tc->data_2d; tc->data_2d && td2d < tc->data_2d + tc->data_len; td2d++) {
908 if (td2d->h1) {
909 td2d->h1[0] = td2d->ih1[0];
910 td2d->h1[1] = td2d->ih1[1];
911 }
912 if (td2d->h2) {
913 td2d->h2[0] = td2d->ih2[0];
914 td2d->h2[1] = td2d->ih2[1];
915 }
916 }
917
918 unit_m3(t->mat);
919 }
920
921 recalc_data(t);
922}
923
929
930void calculateCenterLocal(TransInfo *t, const float center_global[3])
931{
932 /* Setting constraint center. */
933 /* NOTE: init functions may over-ride `t->center`. */
935 if (tc->use_local_mat) {
936 mul_v3_m4v3(tc->center_local, tc->imat, center_global);
937 }
938 else {
939 copy_v3_v3(tc->center_local, center_global);
940 }
941 }
942}
943
944void calculateCenterCursor(TransInfo *t, float r_center[3])
945{
946 const float *cursor = t->scene->cursor.location;
947 copy_v3_v3(r_center, cursor);
948
949 /* If edit or pose mode, move cursor in local space. */
950 if (t->options & CTX_PAINT_CURVE) {
951 if (ED_view3d_project_float_global(t->region, cursor, r_center, V3D_PROJ_TEST_NOP) !=
953 {
955 }
956 r_center[2] = 0.0f;
957 }
958}
959
960void calculateCenterCursor2D(TransInfo *t, float r_center[2])
961{
962 float cursor_local_buf[2];
963 const float *cursor = nullptr;
964
965 if (t->spacetype == SPACE_IMAGE) {
966 SpaceImage *sima = t->area->spacedata.first_as<SpaceImage>();
967 cursor = sima->cursor;
968 }
969 if (t->spacetype == SPACE_SEQ) {
970 SpaceSeq *sseq = t->area->spacedata.first_as<SpaceSeq>();
971 const float2 cursor_pixel = seq::image_preview_unit_to_px(t->scene, sseq->cursor);
972 copy_v2_v2(cursor_local_buf, cursor_pixel);
973 cursor = cursor_local_buf;
974 }
975 else if (t->spacetype == SPACE_CLIP) {
976 SpaceClip *space_clip = t->area->spacedata.first_as<SpaceClip>();
977 cursor = space_clip->cursor;
978 }
979
980 if (cursor) {
981 if (t->options & CTX_MASK) {
982 float co[2];
983
984 if (t->spacetype == SPACE_IMAGE) {
985 SpaceImage *sima = t->area->spacedata.first_as<SpaceImage>();
986 BKE_mask_coord_from_image(sima->image, &sima->iuser, co, cursor);
987 }
988 else if (t->spacetype == SPACE_CLIP) {
989 SpaceClip *space_clip = t->area->spacedata.first_as<SpaceClip>();
990 BKE_mask_coord_from_movieclip(space_clip->clip, &space_clip->user, co, cursor);
991 }
992 else {
993 BLI_assert_msg(0, "Shall not happen");
994 }
995
996 r_center[0] = co[0] * t->aspect[0];
997 r_center[1] = co[1] * t->aspect[1];
998 }
999 else if (t->options & CTX_PAINT_CURVE) {
1000 if (t->spacetype == SPACE_IMAGE) {
1001 r_center[0] = ui::view2d_view_to_region_x(&t->region->v2d, cursor[0]);
1002 r_center[1] = ui::view2d_view_to_region_y(&t->region->v2d, cursor[1]);
1003 }
1004 }
1005 else {
1006 r_center[0] = cursor[0] * t->aspect[0];
1007 r_center[1] = cursor[1] * t->aspect[1];
1008 }
1009 }
1010}
1011
1012void calculateCenterCursorGraph2D(TransInfo *t, float r_center[2])
1013{
1014 SpaceGraph *sipo = t->area->spacedata.first_as<SpaceGraph>();
1015 Scene *scene = t->scene;
1016
1017 /* Cursor is combination of current frame, and graph-editor cursor value. */
1018 if (sipo->mode == SIPO_MODE_DRIVERS) {
1019 r_center[0] = sipo->cursorTime;
1020 r_center[1] = sipo->cursorVal;
1021 }
1022 else {
1023 r_center[0] = float(scene->r.cfra);
1024 r_center[1] = sipo->cursorVal;
1025 }
1026}
1027
1029 const TransDataBasic *td_basic,
1030 float r_vec[3])
1031{
1032 if (td_basic->flag & TD_SELECTED) {
1033 if (!(td_basic->flag & TD_NOCENTER)) {
1034 if (tc->use_local_mat) {
1035 mul_v3_m4v3(r_vec, tc->mat, td_basic->center);
1036 }
1037 else {
1038 copy_v3_v3(r_vec, td_basic->center);
1039 }
1040 return true;
1041 }
1042 }
1043 return false;
1044}
1045
1046void calculateCenterMedian(TransInfo *t, float r_center[3])
1047{
1048 float partial[3] = {0.0f, 0.0f, 0.0f};
1049 int total = 0;
1050
1052 float center[3];
1053 for (int i = 0; i < tc->data_len; i++) {
1054 if (transdata_center_global_get(tc, static_cast<TransDataBasic *>(&tc->data[i]), center)) {
1055 add_v3_v3(partial, center);
1056 total++;
1057 }
1058 }
1059 for (int i = 0; i < tc->data_mirror_len; i++) {
1061 tc, static_cast<TransDataBasic *>(&tc->data_mirror[i]), center))
1062 {
1063 add_v3_v3(partial, center);
1064 total++;
1065 }
1066 }
1067 }
1068 if (total) {
1069 mul_v3_fl(partial, 1.0f / float(total));
1070 }
1071 copy_v3_v3(r_center, partial);
1072}
1073
1074void calculateCenterBound(TransInfo *t, float r_center[3])
1075{
1076 float max[3], min[3];
1077 bool changed = false;
1080 float center[3];
1081 for (int i = 0; i < tc->data_len; i++) {
1082 if (transdata_center_global_get(tc, static_cast<TransDataBasic *>(&tc->data[i]), center)) {
1083 minmax_v3v3_v3(min, max, center);
1084 changed = true;
1085 }
1086 }
1087 for (int i = 0; i < tc->data_mirror_len; i++) {
1089 tc, static_cast<TransDataBasic *>(&tc->data_mirror[i]), center))
1090 {
1091 minmax_v3v3_v3(min, max, center);
1092 changed = true;
1093 }
1094 }
1095 }
1096 if (changed) {
1097 mid_v3_v3v3(r_center, min, max);
1098 }
1099}
1100
1101bool calculateCenterActive(TransInfo *t, bool select_only, float r_center[3])
1102{
1104
1105 if (t->spacetype != SPACE_VIEW3D) {
1106 return false;
1107 }
1108 /* The cursor has no active object concept. Return false so the "active" center isn't used
1109 * in contexts where it doesn't make sense ("Active Snap Base" for e.g.), See: #151283. */
1110 if (t->options & CTX_CURSOR) {
1111 return false;
1112 }
1113
1114 if (tc->obedit) {
1115 if (object::calc_active_center_for_editmode(tc->obedit, select_only, r_center)) {
1116 mul_m4_v3(tc->obedit->object_to_world().ptr(), r_center);
1117 return true;
1118 }
1119 }
1120 else if (t->options & CTX_POSE_BONE) {
1123 if (object::calc_active_center_for_posemode(ob, select_only, r_center)) {
1124 mul_m4_v3(ob->object_to_world().ptr(), r_center);
1125 return true;
1126 }
1127 }
1128 else if (t->options & CTX_PAINT_CURVE) {
1131 PaintCurve *pc = br->paint_curve;
1132 copy_v3_v3(r_center, pc->points[pc->add_index - 1].bez.vec[1]);
1134 r_center[2] = 0.0f;
1135 return true;
1136 }
1137 else {
1138 /* Object mode. */
1141 if (base && ((!select_only) || ((base->flag & BASE_SELECTED) != 0))) {
1142 copy_v3_v3(r_center, base->object->object_to_world().location());
1143 return true;
1144 }
1145 }
1146
1147 return false;
1148}
1149
1150static void calculateCenter_FromAround(TransInfo *t, int around, float r_center[3])
1151{
1152 switch (around) {
1154 calculateCenterBound(t, r_center);
1155 break;
1157 calculateCenterMedian(t, r_center);
1158 break;
1159 case V3D_AROUND_CURSOR:
1161 calculateCenterCursor2D(t, r_center);
1162 }
1163 else if (t->spacetype == SPACE_GRAPH) {
1164 calculateCenterCursorGraph2D(t, r_center);
1165 }
1166 else {
1167 calculateCenterCursor(t, r_center);
1168 }
1169 break;
1171 /* Individual element center uses median center for helpline and such. */
1172 calculateCenterMedian(t, r_center);
1173 break;
1174 case V3D_AROUND_ACTIVE: {
1175 if (calculateCenterActive(t, false, r_center)) {
1176 /* Pass. */
1177 }
1178 else {
1179 /* Fallback. */
1180 calculateCenterMedian(t, r_center);
1181 }
1182 break;
1183 }
1184 }
1185}
1186
1188{
1189 /* #ED_view3d_calc_zfac() defines a factor for perspective depth correction,
1190 * used in #ED_view3d_win_to_delta(). */
1191
1192 /* `zfac` is only used #convertViewVec only in cases operator was invoked in #RGN_TYPE_WINDOW
1193 * and never used in other cases.
1194 *
1195 * We need special case here as well, since #ED_view3d_calc_zfac will crash when called
1196 * for a region different from #RGN_TYPE_WINDOW.
1197 */
1198 if ((t->spacetype == SPACE_VIEW3D) && (t->region->regiontype == RGN_TYPE_WINDOW)) {
1199 t->zfac = ED_view3d_calc_zfac(static_cast<const RegionView3D *>(t->region->regiondata),
1200 t->center_global);
1201 }
1202 else if (t->spacetype == SPACE_IMAGE) {
1203 SpaceImage *sima = t->area->spacedata.first_as<SpaceImage>();
1204 t->zfac = 1.0f / sima->zoom;
1205 }
1206 else if (t->region) {
1207 View2D *v2d = &t->region->v2d;
1208 /* Get zoom factor the same way as in
1209 * #ui_view2d_curRect_validate_resize - better keep in sync! */
1210 const float zoomx = float(BLI_rcti_size_x(&v2d->mask) + 1) / BLI_rctf_size_x(&v2d->cur);
1211 t->zfac = 1.0f / zoomx;
1212 }
1213}
1214
1216{
1217 if ((t->flag & T_OVERRIDE_CENTER) == 0) {
1219 }
1221
1223
1224 /* For panning from the camera-view. */
1225 if ((t->options & CTX_OBJECT) && (t->flag & T_OVERRIDE_CENTER) == 0) {
1226 if (t->spacetype == SPACE_VIEW3D && t->region && t->region->regiontype == RGN_TYPE_WINDOW) {
1227
1228 if (t->options & CTX_CAMERA) {
1229 float axis[3];
1230 /* `persinv` is nasty, use `viewinv` instead, always right. */
1231 copy_v3_v3(axis, t->viewinv[2]);
1232 normalize_v3(axis);
1233
1234 /* 6.0 = 6 grid units. */
1235 axis[0] = t->center_global[0] - 6.0f * axis[0];
1236 axis[1] = t->center_global[1] - 6.0f * axis[1];
1237 axis[2] = t->center_global[2] - 6.0f * axis[2];
1238
1239 projectFloatView(t, axis, t->center2d);
1240
1241 /* Rotate only needs correct 2d center, grab needs #ED_view3d_calc_zfac() value. */
1242 if (t->mode == TFM_TRANSLATION) {
1243 copy_v3_v3(t->center_global, axis);
1244 }
1245 }
1246 }
1247 }
1248
1249 calculateZfac(t);
1250}
1251
1253{
1254 float zoom_prev = t->zfac;
1255 float zoom_new;
1256 if ((t->spacetype == SPACE_VIEW3D) && (t->region->regiontype == RGN_TYPE_WINDOW)) {
1257 if (!t->persp) {
1258 zoom_prev *= len_v3(t->persinv[0]);
1259 }
1260
1262 calculateZfac(t);
1263
1264 zoom_new = t->zfac;
1265 if (!t->persp) {
1266 zoom_new *= len_v3(t->persinv[0]);
1267 }
1268
1269 for (int i = 0; i < ARRAY_SIZE(t->orient); i++) {
1270 if (t->orient[i].type == V3D_ORIENT_VIEW) {
1271 copy_m3_m4(t->orient[i].matrix, t->viewinv);
1272 normalize_m3(t->orient[i].matrix);
1273 if (t->orient_curr == i) {
1274 copy_m3_m3(t->spacemtx, t->orient[i].matrix);
1276 }
1277 }
1278 }
1279 }
1280 else {
1281 calculateZfac(t);
1282 zoom_new = t->zfac;
1283 }
1284
1287 transform_input_update(t, zoom_prev / zoom_new);
1288}
1289
1291{
1292 int i;
1293 float dist;
1294 const bool connected = (t->flag & T_PROP_CONNECTED) != 0;
1295
1296 t->proptext[0] = '\0';
1297
1298 if (t->flag & T_PROP_EDIT) {
1299 const char *pet_id = nullptr;
1301 TransData *td = tc->data;
1302 for (i = 0; i < tc->data_len; i++, td++) {
1303 if (td->flag & TD_SELECTED) {
1304 td->factor = 1.0f;
1305 }
1306 else if ((connected ? td->dist : td->rdist) > t->prop_size) {
1307 td->factor = 0.0f;
1308 restoreElement(td);
1309 }
1310 else {
1311 /* Use `rdist` for falloff calculations, it is the real distance. */
1312 if (connected) {
1313 dist = (t->prop_size - td->dist) / t->prop_size;
1314 }
1315 else {
1316 dist = (t->prop_size - td->rdist) / t->prop_size;
1317 }
1318
1319 /*
1320 * Clamp to positive numbers.
1321 * Certain corner cases with connectivity and individual centers
1322 * can give values of rdist larger than propsize.
1323 */
1324 dist = std::max(dist, 0.0f);
1325
1326 switch (t->prop_mode) {
1327 case PROP_SHARP:
1328 td->factor = dist * dist;
1329 break;
1330 case PROP_SMOOTH:
1331 /* Float imprecision can cause a `dist` approaching 1.0
1332 * to assign `td->factor` exceeding 1.0. See #147530. */
1333 td->factor = std::min(1.0f, 3.0f * dist * dist - 2.0f * dist * dist * dist);
1334 break;
1335 case PROP_ROOT:
1336 td->factor = sqrtf(dist);
1337 break;
1338 case PROP_LIN:
1339 td->factor = dist;
1340 break;
1341 case PROP_CONST:
1342 td->factor = 1.0f;
1343 break;
1344 case PROP_SPHERE:
1345 td->factor = sqrtf(2 * dist - dist * dist);
1346 break;
1347 case PROP_RANDOM:
1348 if (t->rng == nullptr) {
1349 /* Lazy initialization. */
1350 uint rng_seed = uint(BLI_time_now_seconds_i() & UINT_MAX);
1351 t->rng = BLI_rng_new(rng_seed);
1352 }
1353 td->factor = BLI_rng_get_float(t->rng) * dist;
1354 break;
1355 case PROP_INVSQUARE:
1356 td->factor = dist * (2.0f - dist);
1357 break;
1358 default:
1359 td->factor = 1;
1360 break;
1361 }
1362 /* An assert here likely means clamping is needed. */
1363 BLI_assert(td->factor <= 1.0f);
1364 }
1365 }
1366 }
1367
1368 switch (t->prop_mode) {
1369 case PROP_SHARP:
1370 pet_id = N_("(Sharp)");
1371 break;
1372 case PROP_SMOOTH:
1373 pet_id = N_("(Smooth)");
1374 break;
1375 case PROP_ROOT:
1376 pet_id = N_("(Root)");
1377 break;
1378 case PROP_LIN:
1379 pet_id = N_("(Linear)");
1380 break;
1381 case PROP_CONST:
1382 pet_id = N_("(Constant)");
1383 break;
1384 case PROP_SPHERE:
1385 pet_id = N_("(Sphere)");
1386 break;
1387 case PROP_RANDOM:
1388 pet_id = N_("(Random)");
1389 break;
1390 case PROP_INVSQUARE:
1391 pet_id = N_("(InvSquare)");
1392 break;
1393 default:
1394 break;
1395 }
1396
1397 if (pet_id) {
1398 STRNCPY_UTF8(t->proptext, IFACE_(pet_id));
1399 }
1400 }
1401 else {
1403 TransData *td = tc->data;
1404 for (i = 0; i < tc->data_len; i++, td++) {
1405 td->factor = 1.0;
1406 }
1407 }
1408 }
1409}
1410
1412 TransDataExtension *td_ext,
1413 float mat[3][3],
1414 bool use_drot)
1415{
1416 float smat[3][3];
1417 float fmat[3][3];
1418 float obmat[3][3];
1419
1420 float dmat[3][3]; /* Delta rotation. */
1421 float dmat_inv[3][3];
1422
1423 mul_m3_m3m3(smat, td->smtx, mat);
1424
1425 /* Logic from #BKE_object_rot_to_mat3. */
1426 if (use_drot) {
1427 if (td_ext->rotOrder > 0) {
1428 eulO_to_mat3(dmat, td_ext->drot, td_ext->rotOrder);
1429 }
1430 else if (td_ext->rotOrder == ROT_MODE_AXISANGLE) {
1431#if 0
1432 axis_angle_to_mat3(dmat, td_ext->drotAxis, td_ext->drotAngle);
1433#else
1434 unit_m3(dmat);
1435#endif
1436 }
1437 else {
1438 float tquat[4];
1439 normalize_qt_qt(tquat, td_ext->dquat);
1440 quat_to_mat3(dmat, tquat);
1441 }
1442
1443 invert_m3_m3(dmat_inv, dmat);
1444 }
1445
1446 if (td_ext->rotOrder == ROT_MODE_QUAT) {
1447 float quat[4];
1448
1449 /* Calculate the total rotation. */
1450 quat_to_mat3(obmat, td_ext->iquat);
1451 if (use_drot) {
1452 mul_m3_m3m3(obmat, dmat, obmat);
1453 }
1454
1455 /* `mat = transform`, `obmat = object rotation`. */
1456 mul_m3_m3m3(fmat, smat, obmat);
1457
1458 if (use_drot) {
1459 mul_m3_m3m3(fmat, dmat_inv, fmat);
1460 }
1461
1462 mat3_to_quat(quat, fmat);
1463
1464 /* Apply. */
1465 copy_qt_qt(td_ext->quat, quat);
1466 }
1467 else if (td_ext->rotOrder == ROT_MODE_AXISANGLE) {
1468 float axis[3], angle;
1469
1470 /* Calculate the total rotation. */
1471 axis_angle_to_mat3(obmat, td_ext->irotAxis, td_ext->irotAngle);
1472 if (use_drot) {
1473 mul_m3_m3m3(obmat, dmat, obmat);
1474 }
1475
1476 /* `mat = transform`, `obmat = object rotation`. */
1477 mul_m3_m3m3(fmat, smat, obmat);
1478
1479 if (use_drot) {
1480 mul_m3_m3m3(fmat, dmat_inv, fmat);
1481 }
1482
1483 mat3_to_axis_angle(axis, &angle, fmat);
1484
1485 /* Apply. */
1486 copy_v3_v3(td_ext->rotAxis, axis);
1487 *td_ext->rotAngle = angle;
1488 }
1489 else {
1490 float eul[3];
1491
1492 /* Calculate the total rotation. */
1493 eulO_to_mat3(obmat, td_ext->irot, td_ext->rotOrder);
1494 if (use_drot) {
1495 mul_m3_m3m3(obmat, dmat, obmat);
1496 }
1497
1498 /* `mat = transform`, `obmat = object rotation`. */
1499 mul_m3_m3m3(fmat, smat, obmat);
1500
1501 if (use_drot) {
1502 mul_m3_m3m3(fmat, dmat_inv, fmat);
1503 }
1504
1505 mat3_to_compatible_eulO(eul, td_ext->rot, td_ext->rotOrder, fmat);
1506
1507 /* Apply. */
1508 copy_v3_v3(td_ext->rot, eul);
1509 }
1510}
1511
1513{
1514 if (!(ob->mode & OB_MODE_ALL_WEIGHT_PAINT)) {
1515 return nullptr;
1516 }
1517 /* Important that ob_armature can be set even when its not selected #23412.
1518 * Lines below just check is also visible. */
1520 if (ob_armature && ob_armature->mode & OB_MODE_POSE) {
1522 Base *base_arm = BKE_view_layer_base_find(t->view_layer, ob_armature);
1523 if (base_arm) {
1524 View3D *v3d = static_cast<View3D *>(t->view);
1525 if (BASE_VISIBLE(v3d, base_arm)) {
1526 return ob_armature;
1527 }
1528 }
1529 }
1530 return nullptr;
1531}
1532
1533std::optional<float3> mouse_delta_to_world_dir(const TransInfo *t, const float2 &delta)
1534{
1535 if (math::is_zero(delta)) {
1536 return std::nullopt;
1537 }
1538 float3 dir;
1539
1540 if (t->spacetype == SPACE_VIEW3D) {
1541 if (!(t->region && t->region->regiondata)) {
1542 return std::nullopt;
1543 }
1544
1545 const RegionView3D *rv3d = static_cast<const RegionView3D *>(t->region->regiondata);
1546 dir = (float4x4(rv3d->viewinv) * float4(delta, 0.0f, 0.0f)).xyz();
1547 }
1548 else {
1549 /* In 2D views (UV Editor), use the mouse movement directly on the XY plane. */
1550 dir = float3(delta.x, delta.y, 0.0f);
1551 }
1552
1553 dir = math::normalize(dir);
1554 /* Skip zero length results after transform. */
1555 if (math::is_zero(dir)) {
1556 return std::nullopt;
1557 }
1558
1559 return dir;
1560}
1561
1562} // namespace blender::ed::transform
Random number functions.
#define STRNCPY_UTF8(dst, src)
Platform independent time functions.
#define IFACE_(msgid)
#define OB_MODE_ALL_PAINT_MESH
#define OB_MODE_ALL_WEIGHT_PAINT
#define BASE_VISIBLE(v3d, base)
#define C
Definition RandGen.cpp:29
#define INIT_MINMAX(min, max)
#define SET_FLAG_FROM_TEST(value, test, flag)
#define ELEM(...)
#define BLI_assert_msg(a, msg)
btScalar max
SIMD_FORCE_INLINE btScalar angle(const btVector3 &v) const
Return the angle between this and another vector.
Definition btVector3.h:356
#define UINT_MAX
Definition hash_md5.cc:46
bool calc_active_center_for_editmode(Object *obedit, bool select_only, float r_center[3])
bool calc_active_center_for_posemode(Object *ob, bool select_only, float r_center[3])
void calculateCenter(TransInfo *t)
void calculateCenterLocal(TransInfo *t, const float center_global[3])
void setTransformViewMatrices(TransInfo *t)
void resetTransRestrictions(TransInfo *t)
static void * t_view_get(TransInfo *t)
void recalc_data(TransInfo *t)
static void freeTransCustomDataContainer(TransInfo *t, TransDataContainer *tc, TransCustomDataContainer *tcdc)
void calculateCenterMedian(TransInfo *t, float r_center[3])
bool calculateCenterActive(TransInfo *t, bool select_only, float r_center[3])
void calculateCenter2D(TransInfo *t)
void projectFloatView(TransInfo *t, const float vec[3], float adr[2])
void calculateCenterBound(TransInfo *t, float r_center[3])
static void restoreElement(TransData *td)
void restoreTransObjects(TransInfo *t)
void transform_gizmo_3d_model_from_constraint_and_mode_init(TransInfo *t)
void freeTransCustomDataForMode(TransInfo *t)
Object * transform_object_deform_pose_armature_get(const TransInfo *t, Object *ob)
static bool transdata_center_global_get(const TransDataContainer *tc, const TransDataBasic *td_basic, float r_vec[3])
void resetTransModal(TransInfo *t)
void transform_snap_grid_init(const TransInfo *t, float r_snap[3], float *r_snap_precision)
static int t_around_get(TransInfo *t)
void setTransformViewAspect(TransInfo *t, float r_aspect[3])
void projectFloatViewCenterFallback(TransInfo *t, float adr[2])
void transformViewUpdate(TransInfo *t)
void calculateCenterCursor2D(TransInfo *t, float r_center[2])
void initTransInfo(bContext *C, TransInfo *t, wmOperator *op, const wmEvent *event)
int BIF_countTransformOrientation(const bContext *C)
static void transdata_restore_basic(TransDataBasic *td_basic)
void calculateCenterCursorGraph2D(TransInfo *t, float r_center[2])
void transform_input_update(TransInfo *t, const float fac)
void transform_data_ext_rotate(TransData *td, TransDataExtension *td_ext, float mat[3][3], bool use_drot)
void freeSnapping(TransInfo *t)
void calculateCenterCursor(TransInfo *t, float r_center[3])
void calculatePropRatio(TransInfo *t)
short transform_orientation_matrix_get(bContext *C, TransInfo *t, short orient_index, const float custom[3][3], float r_spacemtx[3][3])
static void calculateCenter_FromAround(TransInfo *t, int around, float r_center[3])
void postTrans(bContext *C, TransInfo *t)
std::optional< float3 > mouse_delta_to_world_dir(const TransInfo *t, const float2 &delta)
static void calculateZfac(TransInfo *t)
static void freeTransCustomData(TransInfo *t, TransDataContainer *tc, TransCustomData *custom_data)
bool transdata_check_local_islands(TransInfo *t, short around)
void transform_orientations_current_set(TransInfo *t, const short orient_index)
bool is_zero(const T &a)
MatBase< T, NumCol, NumRow > normalize(const MatBase< T, NumCol, NumRow > &a)
float2 image_preview_unit_to_px(const Scene *scene, const float2 co_src)
int tool_settings_pivot_point_get(Scene *scene)
Definition sequencer.cc:457
float view2d_view_to_region_y(const View2D *v2d, float y)
Definition view2d.cc:1678
float view2d_view_to_region_x(const View2D *v2d, float x)
Definition view2d.cc:1673
UserDef U
Definition blender.cc:58
wmKeyMap * WM_keymap_active(const wmWindowManager *wm, wmKeyMap *keymap)
BLI_assert(slot->slot_subtype.map==BMO_OP_SLOT_SUBTYPE_MAP_FLT)
@ UVCALC_TRANSFORM_CORRECT_SLIDE
@ V3D_PROJ_RET_OK
Definition ED_view3d.hh:273
ViewOpsData * ED_view3d_navigation_init(bContext *C, const wmKeyMapItem *kmi_merge)
ScrArea * CTX_wm_area(const bContext *C)
void WM_event_drag_start_mval_fl(const wmEvent *event, const ARegion *region, float r_mval[2])
Object * BKE_view_layer_active_object_get(const ViewLayer *view_layer)
void RNA_property_float_get_array(PointerRNA *ptr, PropertyRNA *prop, float *values)
Scene * CTX_data_sequencer_scene(const bContext *C)
PropertyRNA * RNA_struct_find_property(PointerRNA *ptr, const char *identifier)
MINLINE void copy_v3_v3(float r[3], const float a[3])
unsigned int uint
Definition BKE_text.h:55
int64_t BLI_time_now_seconds_i()
Definition time.cc:36
void copy_m3_m4(float m1[3][3], const float m2[4][4])
@ V3D_ORIENT_CUSTOM_MATRIX
void minmax_v3v3_v3(float min[3], float max[3], const float vec[3])
void copy_m3_m3(float m1[3][3], const float m2[3][3])
Depsgraph * CTX_data_depsgraph_pointer(const bContext *C)
bool invert_m3_m3(float inverse[3][3], const float mat[3][3])
void mul_v3_m4v3(float r[3], const float mat[4][4], const float vec[3])
MINLINE void copy_v2_v2(float r[2], const float a[2])
void RNA_property_boolean_get_array(PointerRNA *ptr, PropertyRNA *prop, bool *values)
void normalize_m3(float R[3][3]) ATTR_NONNULL()
int RNA_property_enum_get(PointerRNA *ptr, PropertyRNA *prop)
Object * BKE_modifiers_is_deformed_by_armature(Object *ob)
@ V3D_AROUND_CENTER_BOUNDS
@ V3D_AROUND_LOCAL_ORIGINS
@ V3D_AROUND_CENTER_MEDIAN
void mat3_to_compatible_eulO(float eul[3], const float oldrot[3], short order, const float mat[3][3])
void axis_angle_to_mat3(float R[3][3], const float axis[3], float angle)
wmWindow * CTX_wm_window(const bContext *C)
Base * BKE_view_layer_active_base_get(ViewLayer *view_layer)
MatBase< float, 4, 4 > float4x4
void MEM_delete_void(void *vmemh)
struct RNG * BLI_rng_new(unsigned int seed)
Definition rand.cc:41
bool ED_space_clip_check_show_trackedit(const SpaceClip *sc)
ViewLayer * CTX_data_view_layer(const bContext *C)
SpaceSeq * CTX_wm_space_seq(const bContext *C)
MINLINE void mul_v3_fl(float r[3], float f)
bool RNA_property_boolean_get(PointerRNA *ptr, PropertyRNA *prop)
bool RNA_property_array_check(PropertyRNA *prop)
void BKE_brush_tag_unsaved_changes(Brush *brush)
Definition brush.cc:843
VecBase< float, 4 > float4
void eulO_to_mat3(float M[3][3], const float e[3], short order)
void mul_m4_v3(const float M[4][4], float r[3])
void quat_to_mat3(float m[3][3], const float q[4])
VecBase< float, 2 > float2
MINLINE void mul_v3_v3(float r[3], const float a[3])
void * MEM_new_zeroed(size_t len, const char *str) ATTR_WARN_UNUSED_RESULT ATTR_ALLOC_SIZE(1) ATTR_NONNULL(2)
void BKE_mask_coord_from_image(Image *image, ImageUser *iuser, float r_co[2], const float co[2])
bool ED_region_draw_cb_exit(ARegionType *art, void *handle)
void copy_qt_qt(float q[4], const float a[4])
@ OB_MODE_SCULPT_CURVES
@ OB_MODE_EDIT_GPENCIL_LEGACY
@ OB_MODE_PAINT_GREASE_PENCIL
BMesh const char void * data
wmWindowManager * CTX_wm_manager(const bContext *C)
void initNumInput(NumInput *n)
Definition numinput.cc:85
eV3DProjStatus ED_view3d_project_float_global(const ARegion *region, const float co[3], float r_co[2], eV3DProjTest flag)
void BKE_mask_coord_from_movieclip(MovieClip *clip, MovieClipUser *user, float r_co[2], const float co[2])
bool ED_space_clip_check_show_maskedit(const SpaceClip *sc)
void WM_cursor_modal_restore(wmWindow *win)
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)
float ED_view3d_calc_zfac(const RegionView3D *rv3d, const float co[3])
ToolSettings * CTX_data_tool_settings(const bContext *C)
void BLI_rng_free(struct RNG *rng) ATTR_NONNULL(1)
Definition rand.cc:55
MINLINE float len_v3(const float a[3]) ATTR_WARN_UNUSED_RESULT
bool RNA_boolean_get(PointerRNA *ptr, const char *name)
void mat3_to_axis_angle(float axis[3], float *angle, const float mat[3][3])
MINLINE void zero_v3(float r[3])
BLI_INLINE int BLI_rcti_size_x(const struct rcti *rct)
Definition BLI_rect.hh:203
void invert_m3_m3_safe_ortho(float inverse[3][3], const float mat[3][3])
wmMsgBus * CTX_wm_message_bus(const bContext *C)
void ED_uvedit_live_unwrap_end(bool cancel)
float BLI_rng_get_float(struct RNG *rng) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(1)
Definition rand.cc:90
float RNA_property_float_get(PointerRNA *ptr, PropertyRNA *prop)
MINLINE float normalize_v3(float n[3])
MINLINE void add_v3_v3(float r[3], const float a[3])
void mid_v3_v3v3(float r[3], const float a[3], const float b[3])
Main * CTX_data_main(const bContext *C)
void unit_m3(float m[3][3])
BLI_INLINE float BLI_rctf_size_x(const struct rctf *rct)
Definition BLI_rect.hh:211
Paint * BKE_paint_get_active_from_context(const bContext *C)
@ V3D_PROJ_TEST_NOP
Definition ED_view3d.hh:295
Base * BKE_view_layer_base_find(ViewLayer *view_layer, Object *ob)
Brush * BKE_paint_brush(Paint *paint)
void RNA_property_boolean_set(PointerRNA *ptr, PropertyRNA *prop, bool value)
Scene * CTX_data_scene(const bContext *C)
MINLINE void copy_v4_v4(float r[4], const float a[4])
void mul_m3_m3m3(float R[3][3], const float A[3][3], const float B[3][3])
void ED_view3d_navigation_free(bContext *C, ViewOpsData *vod)
VecBase< float, 3 > float3
ViewLayer * BKE_view_layer_default_render(const Scene *scene)
ARegion * CTX_wm_region(const bContext *C)
bool ED_space_image_show_uvedit(const SpaceImage *sima, Object *obedit)
MINLINE bool is_zero_v3(const float v[3]) ATTR_WARN_UNUSED_RESULT
Paint * BKE_paint_get_active(const Main &bmain, Scene *sce, ViewLayer *view_layer)
void mat3_to_quat(float q[4], const float mat[3][3])
bool RNA_property_is_set(PointerRNA *ptr, PropertyRNA *prop)
bScreen * ED_screen_animation_playing(const wmWindowManager *wm)
bool WM_paint_cursor_end(wmPaintCursor *handle)
float normalize_qt_qt(float r[4], const float q[4])
#define sqrtf
KERNEL_FEATURE_LIGHT_PASSES KERNEL_FEATURE_PATH_GUIDING float
#define min(a, b)
Definition sort.cc:38
bke::ARegionRuntime * runtime
eRegion_Type regiontype
struct Object * object
struct PaintCurve * paint_curve
PaintCurvePoint * points
TransformOrientationSlot orientation_slots[4]
View3DCursor cursor
struct ToolSettings * toolsettings
ListBaseT< SpaceLink > spacedata
struct MovieClip * clip
struct MovieClipUser user
eView3D_Around around
eGraphEdit_Mode mode
struct ImageUser iuser
eSpaceImage_Mode mode
eSpaceImage_Flag flag
struct ImagePaintSettings imapaint
eTool_UvCalcFlag uvcalc_flag
struct wmTimer * animtimer
struct ARegionType * type
void(*) free_cb(TransInfo *, TransDataContainer *tc, TransCustomData *custom_data)
Definition transform.hh:655
TransDataCurveHandleFlags * hdata
Definition transform.hh:539
struct blender::ed::transform::TransInfo::@074260112357037217233016050204226071352346123342 orient[3]
TransCustomDataContainer custom
TransDataContainer * data_container
Definition transform.hh:828
ListBaseT< TransSnapPoint > points
Definition transform.hh:576
ListBaseT< wmKeyMapItem > items
struct ReportList * reports
struct wmOperatorType * type
#define TRANS_CUSTOM_DATA_ELEM_MAX
Definition transform.hh:674
#define TRANS_DATA_CONTAINER_FIRST_OK(t)
Definition transform.hh:43
#define T_ALL_RESTRICTIONS
Definition transform.hh:33
#define FOREACH_TRANS_DATA_CONTAINER(t, th)
Definition transform.hh:48
conversion and adaptation of different datablocks to a common struct.
#define N_(msgid)
#define ISMOUSE_BUTTON(event_type)