Blender V5.3
view3d_edit.cc
Go to the documentation of this file.
1/* SPDX-FileCopyrightText: 2008 Blender Authors
2 *
3 * SPDX-License-Identifier: GPL-2.0-or-later */
4
10
11#include "DNA_armature_types.h"
12#include "DNA_camera_types.h"
13#include "DNA_world_types.h"
14
15#include "MEM_guardedalloc.h"
16
17#include "BLI_listbase.hh"
18#include "BLI_math_geom_c.hh"
19#include "BLI_math_matrix.hh"
20#include "BLI_math_matrix_c.hh"
23#include "BLI_math_vector_c.hh"
24#include "BLI_rect.hh"
25#include "BLI_string_utf8.hh"
26
27#include "BKE_action.hh"
28#include "BKE_armature.hh"
29#include "BKE_camera.h"
30#include "BKE_lib_id.hh"
31#include "BKE_object.hh"
32#include "BKE_report.hh"
33#include "BKE_scene.hh"
34#include "BKE_screen.hh"
35
37
38#include "WM_api.hh"
39#include "WM_message.hh"
40
41#include "RNA_access.hh"
42#include "RNA_define.hh"
43
44#include "ED_screen.hh"
45#include "ED_transform.hh"
47#include "ED_undo.hh"
48
49#include "view3d_intern.hh" /* own include */
50#include "view3d_navigate.hh"
51
52namespace blender {
53
54/* test for unlocked camera view in quad view */
56{
57 View3D *v3d;
58 ARegion *region;
59
60 if (ED_view3d_context_user_region(C, &v3d, &region)) {
61 RegionView3D *rv3d = static_cast<RegionView3D *>(region->regiondata);
62 if ((rv3d->persp == RV3D_CAMOB) && !(RV3D_LOCK_FLAGS(rv3d) & RV3D_LOCK_ANY_TRANSFORM)) {
63 return true;
64 }
65 }
66
67 return false;
68}
69
71{
72 View3D *v3d = CTX_wm_view3d(C);
73 if (v3d) {
75 if (rv3d) {
76 return ED_view3d_offset_lock_check(v3d, rv3d);
77 }
78 }
79 return false;
80}
81
82/* -------------------------------------------------------------------- */
85
87{
88 View3D *v3d = CTX_wm_view3d(C);
89
90 if (v3d) {
92
94
95 return OPERATOR_FINISHED;
96 }
97
98 return OPERATOR_CANCELLED;
99}
100
102{
103
104 /* identifiers */
105 ot->name = "View Lock Clear";
106 ot->description = "Clear all view locking";
107 ot->idname = "VIEW3D_OT_view_lock_clear";
108
109 /* API callbacks. */
112
113 /* flags */
114 ot->flag = 0;
115}
116
118
119/* -------------------------------------------------------------------- */
122
124{
125 View3D *v3d = CTX_wm_view3d(C);
127
128 if (v3d) {
130
131 v3d->ob_center = obact; /* can be nullptr */
132
133 if (obact && obact->type == OB_ARMATURE) {
134 if (obact->mode & OB_MODE_POSE) {
135 Depsgraph *depsgraph = CTX_data_ensure_evaluated_depsgraph(C);
136 Object *obact_eval = DEG_get_evaluated(depsgraph, obact);
138 if (pcham_act) {
139 STRNCPY_UTF8(v3d->ob_center_bone, pcham_act->name);
140 }
141 }
142 else {
143 EditBone *ebone_act = (id_cast<bArmature *>(obact->data))->act_edbone;
144 if (ebone_act) {
145 STRNCPY_UTF8(v3d->ob_center_bone, ebone_act->name);
146 }
147 }
148 }
149
151
152 return OPERATOR_FINISHED;
153 }
154
155 return OPERATOR_CANCELLED;
156}
157
159{
160
161 /* identifiers */
162 ot->name = "View Lock to Active";
163 ot->description = "Lock the view to the active object/bone";
164 ot->idname = "VIEW3D_OT_view_lock_to_active";
165
166 /* API callbacks. */
169
170 /* flags */
171 ot->flag = 0;
172}
173
175
176/* -------------------------------------------------------------------- */
179
181{
182 Depsgraph *depsgraph = CTX_data_ensure_evaluated_depsgraph(C);
183 Scene *scene = CTX_data_scene(C);
184 float xfac, yfac;
185
186 View3D *v3d;
187 ARegion *region;
188 RegionView3D *rv3d;
189
190 /* no nullptr check is needed, poll checks */
191 ED_view3d_context_user_region(C, &v3d, &region);
192 rv3d = static_cast<RegionView3D *>(region->regiondata);
193
194 rv3d->camdx = rv3d->camdy = 0.0f;
195 rv3d->camroll = 0.0f;
196 rv3d->rflag &= ~RV3D_FLIP_X;
197
198 const rctf viewborder = BKE_camera_view_border(
199 scene, depsgraph, v3d, rv3d, region->winx, region->winy, true, true, false);
200 const float2 size = {BLI_rctf_size_x(&viewborder), BLI_rctf_size_y(&viewborder)};
201
202 /* 4px is just a little room from the edge of the area */
203 xfac = float(region->winx) / float(size[0] + 4);
204 yfac = float(region->winy) / float(size[1] + 4);
205
208
210
211 return OPERATOR_FINISHED;
212}
213
215{
216 /* identifiers */
217 ot->name = "Frame Camera Bounds";
218 ot->description = "Center the camera view, resizing the view to fit its bounds";
219 ot->idname = "VIEW3D_OT_view_center_camera";
220
221 /* API callbacks. */
224
225 /* flags */
226 ot->flag = 0;
227}
228
230
231/* -------------------------------------------------------------------- */
234
245
247{
248 /* identifiers */
249 ot->name = "View Lock Center";
250 ot->description = "Center the view lock offset";
251 ot->idname = "VIEW3D_OT_view_center_lock";
252
253 /* API callbacks. */
256
257 /* flags */
258 ot->flag = 0;
259}
260
262
263/* -------------------------------------------------------------------- */
266
268{
269 View3D *v3d = CTX_wm_view3d(C);
270 ARegion *region = CTX_wm_region(C);
272
273 Scene *scene = CTX_data_scene(C);
274
275 rcti rect;
276 rctf vb, border;
277
278 /* get box select values using rna */
280
281 /* calculate range */
282
283 if (rv3d->persp == RV3D_CAMOB) {
284 const Depsgraph *depsgraph = CTX_data_ensure_evaluated_depsgraph(C);
286 scene, depsgraph, v3d, rv3d, region->winx, region->winy, false, false, true);
287 }
288 else {
289 vb.xmin = 0;
290 vb.ymin = 0;
291 vb.xmax = region->winx;
292 vb.ymax = region->winy;
293 }
294
295 border.xmin = float(rect.xmin);
296 border.ymin = float(rect.ymin);
297 border.xmax = float(rect.xmax);
298 border.ymax = float(rect.ymax);
299
300 /* Apply flip. */
301 if (rv3d->persp == RV3D_CAMOB && (rv3d->rflag & RV3D_FLIP_X) != 0) {
302 std::swap(border.xmin, border.xmax);
303 border.xmin = region->winx - border.xmin;
304 border.xmax = region->winx - border.xmax;
305 }
306
307 /* Remove the roll to put the border in view border space, expanding to fully cover the box. */
308 if (rv3d->persp == RV3D_CAMOB && rv3d->camroll != 0.0f) {
309 const float pivot[2] = {region->winx / 2.0f, region->winy / 2.0f};
310 BLI_rctf_rotate_expand_around(&border, &border, pivot, -rv3d->camroll);
311 }
312
313 border.xmin = (border.xmin - vb.xmin) / BLI_rctf_size_x(&vb);
314 border.ymin = (border.ymin - vb.ymin) / BLI_rctf_size_y(&vb);
315 border.xmax = (border.xmax - vb.xmin) / BLI_rctf_size_x(&vb);
316 border.ymax = (border.ymax - vb.ymin) / BLI_rctf_size_y(&vb);
317
318 /* actually set border */
319 CLAMP(border.xmin, 0.0f, 1.0f);
320 CLAMP(border.ymin, 0.0f, 1.0f);
321 CLAMP(border.xmax, 0.0f, 1.0f);
322 CLAMP(border.ymax, 0.0f, 1.0f);
323
324 if (rv3d->persp == RV3D_CAMOB) {
325 scene->r.border = border;
326
328 }
329 else {
330 v3d->render_border = border;
331
333 }
334
335 /* drawing a border outside the camera view switches off border rendering */
336 if (border.xmin == border.xmax || border.ymin == border.ymax) {
337 if (rv3d->persp == RV3D_CAMOB) {
338 scene->r.mode &= ~R_BORDER;
339 }
340 else {
342 }
343 }
344 else {
345 if (rv3d->persp == RV3D_CAMOB) {
346 scene->r.mode |= R_BORDER;
347 }
348 else {
349 v3d->flag2 |= V3D_RENDER_BORDER;
350 }
351 }
352
353 if (rv3d->persp == RV3D_CAMOB) {
355 ED_undo_push(C, op->type->name);
356 }
357 return OPERATOR_FINISHED;
358}
359
361{
362 /* identifiers */
363 ot->name = "Set Render Region";
364 ot->description = "Set the boundaries of the border render and enable border render";
365 ot->idname = "VIEW3D_OT_render_border";
366
367 /* API callbacks. */
372
374
375 /* flags */
376 /* No undo, edited data is usually not undo-able, otherwise (camera view),
377 * a manual undo push is done. */
378 ot->flag = OPTYPE_REGISTER;
379
380 /* properties */
382}
383
385
386/* -------------------------------------------------------------------- */
389
391{
392 View3D *v3d = CTX_wm_view3d(C);
394
395 Scene *scene = CTX_data_scene(C);
396 rctf *border = nullptr;
397
398 if (rv3d->persp == RV3D_CAMOB) {
399 scene->r.mode &= ~R_BORDER;
400 border = &scene->r.border;
401
403 }
404 else {
406 border = &v3d->render_border;
407
409 }
410
411 border->xmin = 0.0f;
412 border->ymin = 0.0f;
413 border->xmax = 1.0f;
414 border->ymax = 1.0f;
415
416 if (rv3d->persp == RV3D_CAMOB) {
418 ED_undo_push(C, op->type->name);
419 }
420 return OPERATOR_FINISHED;
421}
422
424{
425 /* identifiers */
426 ot->name = "Clear Render Region";
427 ot->description = "Clear the boundaries of the border render and disable border render";
428 ot->idname = "VIEW3D_OT_clear_render_border";
429
430 /* API callbacks. */
433
434 /* flags */
435 /* No undo, edited data is usually not undo-able, otherwise (camera view),
436 * a manual undo push is done. */
437 ot->flag = OPTYPE_REGISTER;
438}
439
441
442/* -------------------------------------------------------------------- */
447
449 Depsgraph *depsgraph,
450 ARegion *region,
451 View3D *v3d)
452{
453 RegionView3D *rv3d = static_cast<RegionView3D *>(region->regiondata);
454
455 int im_width, im_height;
456 BKE_render_resolution(&scene->r, false, &im_width, &im_height);
457
458 const rctf viewborder = BKE_camera_view_border(
459 scene, depsgraph, v3d, rv3d, region->winx, region->winy, true, true, false);
460
461 rv3d->camzoom = BKE_screen_view3d_zoom_from_fac(float(im_width) / BLI_rctf_size_x(&viewborder));
463}
464
466{
467 Depsgraph *depsgraph = CTX_data_ensure_evaluated_depsgraph(C);
468 Scene *scene = CTX_data_scene(C);
469
470 View3D *v3d;
471 ARegion *region;
472
473 /* no nullptr check is needed, poll checks */
474 ED_view3d_context_user_region(C, &v3d, &region);
475
476 /* NOTE: don't call #ED_view3d_smooth_view_force_finish as the camera zoom
477 * isn't controlled by smooth-view, there is no need to "finish". */
478
479 view3d_set_1_to_1_viewborder(scene, depsgraph, region, v3d);
480
482
483 return OPERATOR_FINISHED;
484}
485
487{
488 /* identifiers */
489 ot->name = "Zoom Camera 1:1";
490 ot->description = "Match the camera to 1:1 to the render output";
491 ot->idname = "VIEW3D_OT_zoom_camera_1_to_1";
492
493 /* API callbacks. */
496
497 /* flags */
498 ot->flag = 0;
499}
500
502
503/* -------------------------------------------------------------------- */
508
509static void view3d_set_view_angle(ARegion *region, View3D *v3d, const float input_angle)
510{
511 RegionView3D *rv3d = static_cast<RegionView3D *>(region->regiondata);
512 const float angle = angle_wrap_rad(input_angle);
513
514 if (rv3d->persp == RV3D_CAMOB) {
515 const bool is_camera_lock = ED_view3d_camera_lock_check(v3d, rv3d);
516 if (!is_camera_lock) {
517 rv3d->camroll = angle;
518 return;
519 }
520 }
521
522 const float horizon_plane[3] = {0.0f, 0.0f, 1.0f};
523 /* Match the top & bottom axis-views, without this the angle
524 * would be relative and repeated runs would accumulate. */
525 const float axis_fallback[3] = {1.0f, 0.0f, 0.0f};
526
527 view3d_horizon_correct_quat(rv3d->viewquat, horizon_plane, false, axis_fallback, angle, 1.0f);
528
529 rv3d->view = RV3D_VIEW_USER;
530}
531
533{
534 View3D *v3d;
535 ARegion *region;
536
537 const float angle = RNA_float_get(op->ptr, "angle");
538
539 /* no nullptr check is needed, poll checks */
540 ED_view3d_context_user_region(C, &v3d, &region);
542
543 view3d_set_view_angle(region, v3d, angle);
544 ED_region_tag_redraw(region);
545
546 return OPERATOR_FINISHED;
547}
548
550{
551 /* identifiers */
552 ot->name = "Set View Roll";
553 ot->description = "Set the view roll angle";
554 ot->idname = "VIEW3D_OT_view_roll_set";
555
556 /* API callbacks. */
559
560 /* properties */
561 ot->prop = RNA_def_float(ot->srna, "angle", 0, -FLT_MAX, FLT_MAX, "Roll", "", -FLT_MAX, FLT_MAX);
563}
564
566
567/* -------------------------------------------------------------------- */
572
573enum class FlipDirection : int8_t {
574 Horizontal = 0,
575 Vertical = 1,
576};
577
579 {int(FlipDirection::Horizontal), "HORIZONTAL", 0, "Horizontal", ""},
580 {int(FlipDirection::Vertical), "VERTICAL", 0, "Vertical", ""},
581 {0, nullptr, 0, nullptr, nullptr},
582};
583
585{
586 View3D *v3d;
587 ARegion *region;
588
589 const FlipDirection direction = FlipDirection(RNA_enum_get(op->ptr, "direction"));
590
591 ED_view3d_context_user_region(C, &v3d, &region);
593
594 RegionView3D *rv3d = static_cast<RegionView3D *>(region->regiondata);
595
596 rv3d->rflag ^= RV3D_FLIP_X;
597
598 if (direction == FlipDirection::Vertical) {
599 rv3d->camroll = angle_wrap_rad(rv3d->camroll + M_PI);
600 }
601
602 ED_region_tag_redraw(region);
603
604 return OPERATOR_FINISHED;
605}
606
608{
609 ot->name = "Flip View";
610 ot->description = "Flip the camera view along the given direction";
611 ot->idname = "VIEW3D_OT_view_flip";
612
615
616 ot->prop = RNA_def_enum(ot->srna,
617 "direction",
620 "Flip Direction",
621 "");
623}
624
626
627/* -------------------------------------------------------------------- */
630
632{
633 View3D *v3d;
634 ARegion *region;
635 RegionView3D *rv3d;
636
637 /* no nullptr check is needed, poll checks */
638 ED_view3d_context_user_region(C, &v3d, &region);
640
641 rv3d = static_cast<RegionView3D *>(region->regiondata);
642
643 /* Could add a separate lock flag for locking persp. */
644 if ((RV3D_LOCK_FLAGS(rv3d) & RV3D_LOCK_ANY_TRANSFORM) == 0) {
645 if (rv3d->persp != RV3D_ORTHO) {
646 rv3d->persp = RV3D_ORTHO;
647 }
648 else {
649 rv3d->persp = RV3D_PERSP;
650 }
651 rv3d->rflag &= ~RV3D_WAS_CAMOB;
652 ED_region_tag_redraw(region);
653 }
654
655 return OPERATOR_FINISHED;
656}
657
659{
660 /* identifiers */
661 ot->name = "View Perspective/Orthographic";
662 ot->description = "Switch the current view from perspective/orthographic projection";
663 ot->idname = "VIEW3D_OT_view_persportho";
664
665 /* API callbacks. */
668
669 /* flags */
670 ot->flag = 0;
671}
672
674
675/* -------------------------------------------------------------------- */
680
682 wmOperator * /*op*/,
683 const wmEvent *event)
684{
685 eViewNavigation_Method mode = eViewNavigation_Method(U.navigation_mode);
686
687 switch (mode) {
689 WM_operator_name_call(C, "VIEW3D_OT_fly", wm::OpCallContext::InvokeDefault, nullptr, event);
690 break;
692 default:
693 WM_operator_name_call(C, "VIEW3D_OT_walk", wm::OpCallContext::InvokeDefault, nullptr, event);
694 break;
695 }
696
697 return OPERATOR_FINISHED;
698}
699
701{
702 /* identifiers */
703 ot->name = "View Navigation (Walk/Fly)";
704 ot->description =
705 "Interactively navigate around the scene (uses the mode (walk/fly) preference)";
706 ot->idname = "VIEW3D_OT_navigate";
707
708 /* API callbacks. */
711}
712
714
715/* -------------------------------------------------------------------- */
718
720{
721 /* Needed to support drag-and-drop & camera buttons context. */
722 View3D *v3d = CTX_wm_view3d(C);
723 if (v3d != nullptr) {
724 if (v3d->camera && v3d->camera->data && v3d->camera->type == OB_CAMERA) {
725 return id_cast<Camera *>(v3d->camera->data);
726 }
727 return nullptr;
728 }
729
730 return static_cast<Camera *>(CTX_data_pointer_get_type(C, "camera", RNA_Camera).data);
731}
732
734{
736 Image *ima;
737 CameraBGImage *bgpic;
738
739 ima = id_cast<Image *>(WM_operator_drop_load_path(C, op, ID_IM));
740 /* may be nullptr, continue anyway */
741
743 bgpic->ima = ima;
744
745 cam->flag |= CAM_SHOW_BG_IMAGE;
746
749
750 return OPERATOR_FINISHED;
751}
752
757
759{
760 /* identifiers */
761 ot->name = "Add Camera Background Image";
762 ot->description = "Add a new background image to the active camera";
763 ot->idname = "VIEW3D_OT_camera_background_image_add";
764
765 /* API callbacks. */
768
769 /* flags */
771
772 /* properties */
774 ot->srna, "filepath", nullptr, FILE_MAX, "Filepath", "Path to image file");
777 prop = RNA_def_boolean(ot->srna,
778 "relative_path",
779 true,
780 "Relative Path",
781 "Select the file relative to the blend file");
783
785}
786
788
789/* -------------------------------------------------------------------- */
792
794{
795 Camera *cam = static_cast<Camera *>(CTX_data_pointer_get_type(C, "camera", RNA_Camera).data);
796 const int index = RNA_int_get(op->ptr, "index");
797 CameraBGImage *bgpic_rem = static_cast<CameraBGImage *>(BLI_findlink(&cam->bg_images, index));
798
799 if (bgpic_rem) {
800 if (ID_IS_OVERRIDE_LIBRARY(cam) &&
802 {
805 "Cannot remove background image %d from camera '%s', as it is from the linked "
806 "reference data",
807 index,
808 cam->id.name + 2);
809 return OPERATOR_CANCELLED;
810 }
811
812 id_us_min(id_cast<ID *>(bgpic_rem->ima));
813 id_us_min(id_cast<ID *>(bgpic_rem->clip));
814
816
819
820 return OPERATOR_FINISHED;
821 }
822 return OPERATOR_CANCELLED;
823}
824
826{
827 /* identifiers */
828 ot->name = "Remove Camera Background Image";
829 ot->description = "Remove a background image from the camera";
830 ot->idname = "VIEW3D_OT_camera_background_image_remove";
831
832 /* API callbacks. */
835
836 /* flags */
837 ot->flag = 0;
838
839 /* properties */
841 ot->srna, "index", 0, 0, INT_MAX, "Index", "Background image index to remove", 0, INT_MAX);
842}
843
845
846/* -------------------------------------------------------------------- */
849
851{
852 Main *bmain = CTX_data_main(C);
853 Scene *scene = CTX_data_scene(C);
854
855 World *world = id_cast<World *>(
857 if (world == nullptr) {
858 return OPERATOR_CANCELLED;
859 }
860
861 id_us_min(id_cast<ID *>(scene->world));
862 id_us_plus(&world->id);
863 scene->world = world;
864
867
869
870 return OPERATOR_FINISHED;
871}
872
874{
876}
877
879{
880 /* identifiers */
881 ot->name = "Drop World";
882 ot->description = "Drop a world into the scene";
883 ot->idname = "VIEW3D_OT_drop_world";
884
885 /* API callbacks. */
886 ot->exec = drop_world_exec;
887 ot->poll = drop_world_poll;
888
889 /* flags */
891
892 /* properties */
894}
895
897
898/* -------------------------------------------------------------------- */
903
904static void calc_local_clipping(float clip_local[6][4],
905 const BoundBox *clipbb,
906 const float mat[4][4])
907{
908 BoundBox clipbb_local;
909 float imat[4][4];
910
911 invert_m4_m4(imat, mat);
912
913 for (int i = 0; i < 8; i++) {
914 mul_v3_m4v3(clipbb_local.vec[i], imat, clipbb->vec[i]);
915 }
916
917 ED_view3d_clipping_calc_from_boundbox(clip_local, &clipbb_local, is_negative_m4(mat));
918}
919
920void ED_view3d_clipping_local(RegionView3D *rv3d, const float mat[4][4])
921{
922 if ((rv3d->rflag & RV3D_CLIPPING) && (rv3d->clipbb != nullptr)) {
923 calc_local_clipping(rv3d->clip_local, rv3d->clipbb, mat);
924 }
925}
926
928{
929 ARegion *region = CTX_wm_region(C);
931 rcti rect;
932
934
935 rv3d->rflag |= RV3D_CLIPPING;
936 rv3d->clipbb = MEM_new<BoundBox>("clipbb");
937
938 /* nullptr object because we don't want it in object space */
939 ED_view3d_clipping_calc(rv3d->clipbb, rv3d->clip, region, nullptr, &rect);
940
941 return OPERATOR_FINISHED;
942}
943
945{
947 ARegion *region = CTX_wm_region(C);
948
949 if (rv3d->rflag & RV3D_CLIPPING) {
950 rv3d->rflag &= ~RV3D_CLIPPING;
951 ED_region_tag_redraw(region);
952 MEM_SAFE_DELETE(rv3d->clipbb);
953 return OPERATOR_FINISHED;
954 }
955 return WM_gesture_box_invoke(C, op, event);
956}
957
959{
960 if (const View3D *v3d = CTX_wm_view3d(C)) {
961 if (ELEM(v3d->shading.type, OB_WIRE, OB_SOLID)) {
962 if (CTX_wm_region_view3d(C)) {
963 return true;
964 }
965 }
966 }
967
968 CTX_wm_operator_poll_msg_set(C, "Clipping works in Wireframe and Solid viewport shading only");
969 return false;
970}
971
973{
974
975 /* identifiers */
976 ot->name = "Clipping Region";
977 ot->description = "Set the view clipping region";
978 ot->idname = "VIEW3D_OT_clip_border";
979
980 /* API callbacks. */
985
987
988 /* flags */
989 ot->flag = 0;
990
991 /* properties */
993}
994
996
997/* -------------------------------------------------------------------- */
1000
1002 const int mval[2],
1003 const bool use_depth,
1004 float r_cursor_co[3])
1005{
1006 ARegion *region = CTX_wm_region(C);
1007 View3D *v3d = CTX_wm_view3d(C);
1008 RegionView3D *rv3d = static_cast<RegionView3D *>(region->regiondata);
1009 bool flip;
1010 bool depth_used = false;
1011
1012 /* normally the caller should ensure this,
1013 * but this is called from areas that aren't already dealing with the viewport */
1014 if (rv3d == nullptr) {
1015 return;
1016 }
1017
1018 ED_view3d_calc_zfac_ex(rv3d, r_cursor_co, &flip);
1019
1020 /* Reset the depth based on the view offset (we _know_ the offset is in front of us). */
1021 if (flip) {
1022 negate_v3_v3(r_cursor_co, rv3d->ofs);
1023 /* re initialize, no need to check flip again */
1024 ED_view3d_calc_zfac(rv3d, r_cursor_co);
1025 }
1026
1027 if (use_depth) { /* maybe this should be accessed some other way */
1028 Depsgraph *depsgraph = CTX_data_ensure_evaluated_depsgraph(C);
1029
1031
1032 /* Ensure the depth buffer is updated for #ED_view3d_autodist. */
1033 ED_view3d_depth_override(depsgraph, region, v3d, nullptr, V3D_DEPTH_ALL, false, nullptr);
1034
1035 if (ED_view3d_autodist(region, v3d, mval, r_cursor_co, nullptr)) {
1036 depth_used = true;
1037 }
1038 }
1039
1040 if (depth_used == false) {
1041 float depth_pt[3];
1042 copy_v3_v3(depth_pt, r_cursor_co);
1043 ED_view3d_win_to_3d_int(v3d, region, depth_pt, mval, r_cursor_co);
1044 }
1045}
1046
1048 const int mval[2],
1049 const bool use_depth,
1050 enum eV3DCursorOrient orientation,
1051 float r_cursor_co[3],
1052 float r_cursor_quat[4])
1053{
1054 View3D *v3d = CTX_wm_view3d(C);
1055 ARegion *region = CTX_wm_region(C);
1056 RegionView3D *rv3d = static_cast<RegionView3D *>(region->regiondata);
1057
1058 /* XXX, caller should check. */
1059 if (rv3d == nullptr) {
1060 return;
1061 }
1062
1063 ED_view3d_cursor3d_position(C, mval, use_depth, r_cursor_co);
1064
1065 if (orientation == V3D_CURSOR_ORIENT_NONE) {
1066 /* pass */
1067 }
1068 else if (orientation == V3D_CURSOR_ORIENT_VIEW) {
1069 copy_qt_qt(r_cursor_quat, rv3d->viewquat);
1070 r_cursor_quat[0] *= -1.0f;
1071 }
1072 else if (orientation == V3D_CURSOR_ORIENT_XFORM) {
1073 float mat[3][3];
1075 mat3_to_quat(r_cursor_quat, mat);
1076 }
1077 else if (orientation == V3D_CURSOR_ORIENT_GEOM) {
1078 copy_qt_qt(r_cursor_quat, rv3d->viewquat);
1079 r_cursor_quat[0] *= -1.0f;
1080
1081 const float mval_fl[2] = {float(mval[0]), float(mval[1])};
1082 float ray_no[3];
1083 float ray_co[3];
1084
1086
1087 float obmat[4][4];
1088 const Object *ob_dummy = nullptr;
1089 float dist_px = 0;
1096 region,
1097 v3d,
1099 &params,
1100 nullptr,
1101 mval_fl,
1102 nullptr,
1103 &dist_px,
1104 ray_co,
1105 ray_no,
1106 nullptr,
1107 &ob_dummy,
1108 obmat,
1109 nullptr) != 0)
1110 {
1111 if (use_depth) {
1112 copy_v3_v3(r_cursor_co, ray_co);
1113 }
1114
1115 /* Math normal (Z). */
1116 {
1117 float tquat[4];
1118 float z_src[3] = {0, 0, 1};
1119 mul_qt_v3(r_cursor_quat, z_src);
1120 rotation_between_vecs_to_quat(tquat, z_src, ray_no);
1121 mul_qt_qtqt(r_cursor_quat, tquat, r_cursor_quat);
1122 }
1123
1124 /* Match object matrix (X). */
1125 {
1126 const float ortho_axis_dot[3] = {
1127 dot_v3v3(ray_no, obmat[0]),
1128 dot_v3v3(ray_no, obmat[1]),
1129 dot_v3v3(ray_no, obmat[2]),
1130 };
1131 const int ortho_axis = axis_dominant_v3_ortho_single(ortho_axis_dot);
1132
1133 float tquat_best[4];
1134 float angle_best = -1.0f;
1135
1136 float tan_dst[3];
1137 project_plane_v3_v3v3(tan_dst, obmat[ortho_axis], ray_no);
1138 normalize_v3(tan_dst);
1139
1140 /* As the tangent is arbitrary from the users point of view,
1141 * make the cursor 'roll' on the shortest angle.
1142 * otherwise this can cause noticeable 'flipping', see #72419. */
1143 for (int axis = 0; axis < 2; axis++) {
1144 float tan_src[3] = {0, 0, 0};
1145 tan_src[axis] = 1.0f;
1146 mul_qt_v3(r_cursor_quat, tan_src);
1147
1148 for (int axis_sign = 0; axis_sign < 2; axis_sign++) {
1149 float tquat_test[4];
1150 rotation_between_vecs_to_quat(tquat_test, tan_src, tan_dst);
1151 const float angle_test = angle_normalized_qt(tquat_test);
1152 if (angle_test < angle_best || angle_best == -1.0f) {
1153 angle_best = angle_test;
1154 copy_qt_qt(tquat_best, tquat_test);
1155 }
1156 negate_v3(tan_src);
1157 }
1158 }
1159 mul_qt_qtqt(r_cursor_quat, tquat_best, r_cursor_quat);
1160 }
1161 }
1163 }
1164}
1165
1167 const int mval[2],
1168 const bool use_depth,
1169 enum eV3DCursorOrient orientation)
1170{
1171 Scene *scene = CTX_data_scene(C);
1172 View3D *v3d = CTX_wm_view3d(C);
1173 ARegion *region = CTX_wm_region(C);
1174 RegionView3D *rv3d = static_cast<RegionView3D *>(region->regiondata);
1175
1176 View3DCursor *cursor_curr = &scene->cursor;
1177 View3DCursor cursor_prev = *cursor_curr;
1178
1179 {
1180 math::Quaternion quat, quat_prev;
1181 quat = cursor_curr->rotation();
1182 copy_qt_qt(&quat_prev.w, &quat.w);
1184 C, mval, use_depth, orientation, cursor_curr->location, &quat.w);
1185
1186 if (!equals_v4v4(&quat_prev.w, &quat.w)) {
1187 if ((cursor_curr->rotation_mode == ROT_MODE_AXISANGLE) && RV3D_VIEW_IS_AXIS(rv3d->view)) {
1188 float tmat[3][3], cmat[3][3];
1189 quat_to_mat3(tmat, &quat.w);
1190 negate_v3_v3(cursor_curr->rotation_axis, tmat[2]);
1191 axis_angle_to_mat3(cmat, cursor_curr->rotation_axis, 0.0f);
1193 cmat[0], tmat[0], cursor_curr->rotation_axis);
1194 }
1195 else {
1196 cursor_curr->set_rotation(quat, true);
1197 }
1198 }
1199 }
1200
1201 /* offset the cursor lock to avoid jumping to new offset */
1202 if (v3d->ob_center_cursor) {
1203 if (U.uiflag & USER_LOCK_CURSOR_ADJUST) {
1204
1205 float co_2d_curr[2], co_2d_prev[2];
1206
1208 region, cursor_prev.location, co_2d_prev, V3D_PROJ_TEST_NOP) == V3D_PROJ_RET_OK) &&
1210 region, cursor_curr->location, co_2d_curr, V3D_PROJ_TEST_NOP) == V3D_PROJ_RET_OK))
1211 {
1212 rv3d->ofs_lock[0] += (co_2d_curr[0] - co_2d_prev[0]) / (region->winx * 0.5f);
1213 rv3d->ofs_lock[1] += (co_2d_curr[1] - co_2d_prev[1]) / (region->winy * 0.5f);
1214 }
1215 }
1216 else {
1217 /* Cursor may be outside of the view,
1218 * prevent it getting 'lost', see: #40353 & #45301 */
1219 zero_v2(rv3d->ofs_lock);
1220 }
1221 }
1222
1223 if (v3d->localvd) {
1225 }
1226 else {
1228 }
1229
1230 {
1231 wmMsgBus *mbus = CTX_wm_message_bus(C);
1232 wmMsgParams_RNA msg_key_params = {{}};
1233 msg_key_params.ptr = RNA_pointer_create_discrete(&scene->id, RNA_View3DCursor, &scene->cursor);
1234 WM_msg_publish_rna_params(mbus, &msg_key_params);
1235 }
1236
1238}
1239
1241{
1242 bool use_depth = (U.uiflag & USER_DEPTH_CURSOR);
1243 {
1244 PropertyRNA *prop = RNA_struct_find_property(op->ptr, "use_depth");
1245 if (RNA_property_is_set(op->ptr, prop)) {
1246 use_depth = RNA_property_boolean_get(op->ptr, prop);
1247 }
1248 else {
1249 RNA_property_boolean_set(op->ptr, prop, use_depth);
1250 }
1251 }
1252 const enum eV3DCursorOrient orientation = eV3DCursorOrient(RNA_enum_get(op->ptr, "orientation"));
1253 ED_view3d_cursor3d_update(C, event->mval, use_depth, orientation);
1254
1255 /* Use pass-through to allow click-drag to transform the cursor. */
1257}
1258
1260{
1261
1262 /* identifiers */
1263 ot->name = "Set 3D Cursor";
1264 ot->description = "Set the location of the 3D cursor";
1265 ot->idname = "VIEW3D_OT_cursor3d";
1266
1267 /* API callbacks. */
1269
1271
1272 /* flags */
1273 // ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO;
1274
1275 PropertyRNA *prop;
1276 static const EnumPropertyItem orientation_items[] = {
1277 {V3D_CURSOR_ORIENT_NONE, "NONE", 0, "None", "Leave orientation unchanged"},
1278 {V3D_CURSOR_ORIENT_VIEW, "VIEW", 0, "View", "Orient to the viewport"},
1280 "XFORM",
1281 0,
1282 "Transform",
1283 "Orient to the current transform setting"},
1284 {V3D_CURSOR_ORIENT_GEOM, "GEOM", 0, "Geometry", "Match the surface normal"},
1285 {0, nullptr, 0, nullptr, nullptr},
1286 };
1287
1288 prop = RNA_def_boolean(
1289 ot->srna, "use_depth", true, "Surface Project", "Project onto the surface");
1291
1292 prop = RNA_def_enum(ot->srna,
1293 "orientation",
1294 orientation_items,
1296 "Orientation",
1297 "Preset viewpoint to use");
1299}
1300
1302
1303/* -------------------------------------------------------------------- */
1306
1308 {OB_WIRE, "WIREFRAME", 0, "Wireframe", "Toggle wireframe shading"},
1309 {OB_SOLID, "SOLID", 0, "Solid", "Toggle solid shading"},
1310 {OB_MATERIAL, "MATERIAL", 0, "Material Preview", "Toggle material preview shading"},
1311 {OB_RENDER, "RENDERED", 0, "Rendered", "Toggle rendered shading"},
1312 {0, nullptr, 0, nullptr, nullptr},
1313};
1314
1316{
1317 Main *bmain = CTX_data_main(C);
1318 View3D *v3d = CTX_wm_view3d(C);
1319 ScrArea *area = CTX_wm_area(C);
1320 const eDrawType type = eDrawType(RNA_enum_get(op->ptr, "type"));
1321
1322 if (type == OB_SOLID) {
1323 if (v3d->shading.type != type) {
1324 v3d->shading.type = type;
1325 }
1326 else if (v3d->shading.type == OB_WIRE) {
1327 v3d->shading.type = OB_SOLID;
1328 }
1329 else {
1330 v3d->shading.type = OB_WIRE;
1331 }
1332 }
1333 else {
1334 eDrawType *prev_type = ((type == OB_WIRE) ? &v3d->shading.prev_type_wire :
1335 &v3d->shading.prev_type);
1336 if (v3d->shading.type == type) {
1337 if (*prev_type == type || !ELEM(*prev_type, OB_WIRE, OB_SOLID, OB_MATERIAL, OB_RENDER)) {
1338 *prev_type = OB_SOLID;
1339 }
1340 v3d->shading.type = *prev_type;
1341 }
1342 else {
1343 *prev_type = v3d->shading.type;
1344 v3d->shading.type = type;
1345 }
1346 }
1347
1348 ED_view3d_shade_update(bmain, v3d, area);
1350
1351 return OPERATOR_FINISHED;
1352}
1353
1355{
1356 PropertyRNA *prop;
1357
1358 /* identifiers */
1359 ot->name = "Toggle Shading Type";
1360 ot->description = "Toggle shading type in 3D viewport";
1361 ot->idname = "VIEW3D_OT_toggle_shading";
1362
1363 /* API callbacks. */
1366
1367 prop = RNA_def_enum(
1368 ot->srna, "type", prop_shading_type_items, 0, "Type", "Shading type to toggle");
1370}
1371
1373
1374/* -------------------------------------------------------------------- */
1377
1379{
1380 View3D *v3d = CTX_wm_view3d(C);
1381 ScrArea *area = CTX_wm_area(C);
1383
1384 if (obact && ((obact->mode & OB_MODE_POSE) ||
1386 {
1388 }
1389 else {
1390 const bool xray_active = ((obact && (obact->mode & OB_MODE_EDIT)) ||
1391 ELEM(v3d->shading.type, OB_WIRE, OB_SOLID));
1392
1393 if (v3d->shading.type == OB_WIRE) {
1395 }
1396 else {
1398 }
1399 if (!xray_active) {
1400 BKE_report(op->reports, RPT_INFO, "X-Ray not available in current mode");
1401 }
1402 }
1403
1404 ED_area_tag_redraw(area);
1406
1407 return OPERATOR_FINISHED;
1408}
1409
1411{
1412 /* identifiers */
1413 ot->name = "Toggle X-Ray";
1414 ot->idname = "VIEW3D_OT_toggle_xray";
1415 ot->description = "Transparent scene display. Allow selecting through items";
1416
1417 /* API callbacks. */
1418 ot->exec = toggle_xray_exec;
1420}
1421
1423
1424} // namespace blender
Blender kernel action and pose functionality.
Camera data-block and utility functions.
General operations, lookup, etc. for blender objects.
#define M_PI
#define FILE_MAX
#define STRNCPY_UTF8(dst, src)
#define ID_IS_OVERRIDE_LIBRARY(_id)
Definition DNA_ID.h:736
#define RV3D_VIEW_IS_AXIS(view)
#define RV3D_CAMZOOM_MAX
#define RV3D_LOCK_FLAGS(rv3d)
#define RV3D_CAMZOOM_MIN
Read Blender memory allocation and freeing.
#define C
Definition RandGen.cpp:29
#define ND_WORLD
Definition WM_types.hh:471
#define ND_RENDER_OPTIONS
Definition WM_types.hh:454
#define NC_SCENE
Definition WM_types.hh:391
#define NA_EDITED
Definition WM_types.hh:634
#define NC_CAMERA
Definition WM_types.hh:414
#define ND_SPACE_VIEW3D
Definition WM_types.hh:571
#define NS_VIEW3D_SHADING
Definition WM_types.hh:627
#define NC_SPACE
Definition WM_types.hh:405
#define ND_DRAW_RENDER_VIEWPORT
Definition WM_types.hh:511
#define CLAMP(a, b, c)
#define ELEM(...)
SIMD_FORCE_INLINE btScalar angle(const btVector3 &v) const
Return the angle between this and another vector.
Definition btVector3.h:356
#define FLT_MAX
#define INT_MAX
eSnapMode snap_object_project_view3d_ex(SnapObjectContext *sctx, Depsgraph *depsgraph, const ARegion *region, const View3D *v3d, const eSnapMode snap_to, const SnapObjectParams *params, const float init_co[3], const float mval[2], const float prev_co[3], float *dist_px, float r_loc[3], float r_no[3], int *r_index, const Object **r_ob, float r_obmat[4][4], float r_face_nor[3])
void snap_object_context_destroy(SnapObjectContext *sctx)
SnapObjectContext * snap_object_context_create()
void calc_orientation_from_type(const bContext *C, float r_mat[3][3])
QuaternionBase< float > Quaternion
BMesh Iterators.
ID * WM_operator_drop_load_path(bContext *C, wmOperator *op, const short idcode)
@ V3D_OVERLAY_BONE_SELECT
MINLINE float min_ff(float a, float b)
bool ED_view3d_context_user_region(bContext *C, View3D **r_v3d, ARegion **r_region)
UserDef U
Definition blender.cc:58
void VIEW3D_OT_view_roll_set(wmOperatorType *ot)
MINLINE void negate_v3_v3(float r[3], const float a[3])
@ V3D_PROJ_RET_OK
Definition ED_view3d.hh:273
bool ED_operator_scene_editable(bContext *C)
void VIEW3D_OT_view_center_lock(wmOperatorType *ot)
void BKE_camera_background_image_remove(struct Camera *cam, struct CameraBGImage *bgpic)
static wmOperatorStatus view3d_set_roll_exec(bContext *C, wmOperator *op)
ScrArea * CTX_wm_area(const bContext *C)
bool ED_view3d_camera_lock_check(const View3D *v3d, const RegionView3D *rv3d)
int RNA_enum_get(PointerRNA *ptr, const char *name)
static bool view3d_camera_user_poll(bContext *C)
void VIEW3D_OT_clear_render_border(wmOperatorType *ot)
PropertyRNA * RNA_def_string(StructOrFunctionRNA *cont_, const char *identifier, const char *default_value, const int maxlen, const char *ui_name, const char *ui_description)
void ED_view3d_clipping_local(RegionView3D *rv3d, const float mat[4][4])
@ RPT_WARNING
Definition BKE_report.hh:40
void VIEW3D_OT_view_persportho(wmOperatorType *ot)
PropertyRNA * RNA_struct_find_property(PointerRNA *ptr, const char *identifier)
static wmOperatorStatus render_border_exec(bContext *C, wmOperator *op)
void VIEW3D_OT_clip_border(wmOperatorType *ot)
bool ED_operator_rv3d_user_region_poll(bContext *C)
static wmOperatorStatus camera_background_image_add_exec(bContext *C, wmOperator *op)
wmOperatorStatus WM_gesture_box_invoke(bContext *C, wmOperator *op, const wmEvent *event)
void WM_operator_properties_id_lookup(wmOperatorType *ot, const bool add_name_prop)
MINLINE void copy_v3_v3(float r[3], const float a[3])
void BLI_rctf_rotate_expand_around(rctf *dst, const rctf *src, const float pivot[2], float angle)
Definition rct.cc:1145
void ED_view3d_cursor3d_position_rotation(bContext *C, const int mval[2], bool use_depth, enum eV3DCursorOrient orientation, float r_cursor_co[3], float r_cursor_quat[4])
void id_us_plus(ID *id)
Definition lib_id.cc:433
static wmOperatorStatus view3d_clipping_invoke(bContext *C, wmOperator *op, const wmEvent *event)
ID * WM_operator_properties_id_lookup_from_name_or_session_uid(Main *bmain, PointerRNA *ptr, const ID_Type type)
void mul_v3_m4v3(float r[3], const float mat[4][4], const float vec[3])
static wmOperatorStatus view3d_clipping_exec(bContext *C, wmOperator *op)
float angle_normalized_qt(const float q[4])
void VIEW3D_OT_view_lock_clear(wmOperatorType *ot)
void ED_view3d_cursor3d_position(bContext *C, const int mval[2], bool use_depth, float r_cursor_co[3])
void VIEW3D_OT_toggle_shading(wmOperatorType *ot)
bool invert_m4_m4(float inverse[4][4], const float mat[4][4])
void VIEW3D_OT_view_lock_to_active(wmOperatorType *ot)
static bool camera_background_image_add_poll(bContext *C)
PropertyRNA * RNA_def_enum(StructOrFunctionRNA *cont_, const char *identifier, const EnumPropertyItem *items, const int default_value, const char *ui_name, const char *ui_description)
void WM_operator_properties_border(wmOperatorType *ot)
void axis_angle_to_mat3(float R[3][3], const float axis[3], float angle)
int RNA_int_get(PointerRNA *ptr, const char *name)
bool is_negative_m4(const float mat[4][4])
static void calc_local_clipping(float clip_local[6][4], const BoundBox *clipbb, const float mat[4][4])
void view3d_operator_needs_gpu(const bContext *C)
void rotation_between_vecs_to_quat(float q[4], const float v1[3], const float v2[3])
void mul_qt_qtqt(float q[4], const float a[4], const float b[4])
RegionView3D * ED_view3d_context_rv3d(bContext *C)
@ RV3D_LOCK_ANY_TRANSFORM
static bool drop_world_poll(bContext *C)
void ED_region_tag_redraw(ARegion *region)
Definition area.cc:681
@ V3D_SHADING_XRAY_WIREFRAME
static void view3d_set_1_to_1_viewborder(Scene *scene, Depsgraph *depsgraph, ARegion *region, View3D *v3d)
bool ED_operator_camera_poll(bContext *C)
void VIEW3D_OT_view_center_camera(wmOperatorType *ot)
static wmOperatorStatus clear_render_border_exec(bContext *C, wmOperator *)
float angle_signed_on_axis_v3v3_v3(const float v1[3], const float v2[3], const float axis[3]) ATTR_WARN_UNUSED_RESULT
void BKE_render_resolution(const RenderData *r, const bool use_crop, int *r_width, int *r_height)
Definition scene.cc:3168
static wmOperatorStatus view3d_navigate_invoke(bContext *C, wmOperator *, const wmEvent *event)
bool RNA_property_boolean_get(PointerRNA *ptr, PropertyRNA *prop)
void mul_qt_v3(const float q[4], float r[3])
void quat_to_mat3(float m[3][3], const float q[4])
void ED_view3d_lock_clear(View3D *v3d)
void VIEW3D_OT_navigate(wmOperatorType *ot)
void * BLI_findlink(const ListBase *listbase, int number) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(1)
Definition listbase.cc:541
MINLINE bool equals_v4v4(const float v1[4], const float v2[4]) ATTR_WARN_UNUSED_RESULT
bool ED_view3d_autodist(ARegion *region, View3D *v3d, const int mval[2], float mouse_worldloc[3], const float fallback_depth_pt[3])
void CTX_wm_operator_poll_msg_set(bContext *C, const char *msg)
VecBase< float, 2 > float2
static wmOperatorStatus view3d_flip_view_exec(bContext *C, wmOperator *op)
void VIEW3D_OT_cursor3d(wmOperatorType *ot)
static wmOperatorStatus view3d_cursor3d_invoke(bContext *C, wmOperator *op, const wmEvent *event)
void VIEW3D_OT_render_border(wmOperatorType *ot)
static wmOperatorStatus toggle_xray_exec(bContext *C, wmOperator *op)
static wmOperatorStatus view_lock_to_active_exec(bContext *C, wmOperator *)
void copy_qt_qt(float q[4], const float a[4])
@ CAM_BGIMG_FLAG_OVERRIDE_LIBRARY_LOCAL
void DEG_id_tag_update(ID *id, unsigned int flags)
void BKE_report(ReportList *reports, eReportType type, const char *message)
Definition report.cc:162
Object * BKE_object_pose_armature_get(Object *ob)
Definition object.cc:2507
T * DEG_get_evaluated(const Depsgraph *depsgraph, T *id)
static wmOperatorStatus viewpersportho_exec(bContext *C, wmOperator *)
static Camera * background_image_camera_from_context(bContext *C)
float BKE_screen_view3d_zoom_from_fac(float zoomfac)
Definition screen.cc:1288
BLI_INLINE float BLI_rctf_size_y(const struct rctf *rct)
Definition BLI_rect.hh:215
Depsgraph * CTX_data_ensure_evaluated_depsgraph(const bContext *C, bool rna_write_check=false)
void ED_undo_push(bContext *C, const char *str, UndoEncodeHints hints=UndoEncodeHints(0))
Definition ed_undo.cc:103
static wmOperatorStatus view3d_zoom_1_to_1_camera_exec(bContext *C, wmOperator *)
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)
static wmOperatorStatus view3d_center_lock_exec(bContext *C, wmOperator *)
void WM_operator_properties_border_to_rcti(wmOperator *op, rcti *r_rect)
void ED_view3d_cursor3d_update(bContext *C, const int mval[2], bool use_depth, enum eV3DCursorOrient orientation)
void VIEW3D_OT_zoom_camera_1_to_1(wmOperatorType *ot)
void RNA_def_property_subtype(PropertyRNA *prop, PropertySubType subtype)
MINLINE void negate_v3(float r[3])
PointerRNA RNA_pointer_create_discrete(ID *id, StructRNA *type, void *data)
bool ED_operator_view3d_active(bContext *C)
float ED_view3d_calc_zfac(const RegionView3D *rv3d, const float co[3])
RegionView3D * CTX_wm_region_view3d(const bContext *C)
wmOperatorStatus WM_operator_name_call(bContext *C, const char *opstring, wm::OpCallContext context, PointerRNA *properties, const wmEvent *event)
void WM_event_add_notifier(const bContext *C, uint type, void *reference)
wmMsgBus * CTX_wm_message_bus(const bContext *C)
void VIEW3D_OT_view_flip(wmOperatorType *ot)
MINLINE int axis_dominant_v3_ortho_single(const float vec[3])
void project_plane_v3_v3v3(float out[3], const float p[3], const float v_plane[3])
@ V3D_CURSOR_ORIENT_XFORM
Definition ED_view3d.hh:103
@ V3D_CURSOR_ORIENT_NONE
Definition ED_view3d.hh:101
@ V3D_CURSOR_ORIENT_VIEW
Definition ED_view3d.hh:102
@ V3D_CURSOR_ORIENT_GEOM
Definition ED_view3d.hh:104
MINLINE float normalize_v3(float n[3])
bool ED_view3d_offset_lock_check(const View3D *v3d, const RegionView3D *rv3d)
wmOperatorStatus WM_gesture_box_modal(bContext *C, wmOperator *op, const wmEvent *event)
void RNA_def_property_flag(PropertyRNA *prop, PropertyFlag flag)
PropertyRNA * RNA_def_int(StructOrFunctionRNA *cont_, const char *identifier, const int default_value, const int hardmin, const int hardmax, const char *ui_name, const char *ui_description, const int softmin, const int softmax)
struct CameraBGImage * BKE_camera_background_image_new(struct Camera *cam)
void BKE_reportf(ReportList *reports, eReportType type, const char *format,...) ATTR_PRINTF_FORMAT(3
Definition report.cc:191
Main * CTX_data_main(const bContext *C)
void VIEW3D_OT_toggle_xray(wmOperatorType *ot)
BLI_INLINE float BLI_rctf_size_x(const struct rctf *rct)
Definition BLI_rect.hh:211
void ED_view3d_clipping_calc(BoundBox *bb, float planes[4][4], const ARegion *region, const Object *ob, const rcti *rect)
void ED_view3d_depth_override(Depsgraph *depsgraph, ARegion *region, View3D *v3d, Object *obact, eV3DDepthOverrideMode mode, bool use_overlay, ViewDepths **r_depths)
float ED_view3d_calc_zfac_ex(const RegionView3D *rv3d, const float co[3], bool *r_flip)
@ ID_RECALC_SYNC_TO_EVAL
Definition DNA_ID.h:1118
@ PROP_SKIP_SAVE
Definition RNA_types.hh:414
@ PROP_PATH_SUPPORTS_BLEND_RELATIVE
Definition RNA_types.hh:526
@ PROP_HIDDEN
Definition RNA_types.hh:408
@ V3D_PROJ_TEST_NOP
Definition ED_view3d.hh:295
bool ED_operator_region_view3d_active(bContext *C)
void WM_gesture_box_cancel(bContext *C, wmOperator *op)
void ED_view3d_smooth_view_force_finish(bContext *C, View3D *v3d, ARegion *region)
@ V3D_DEPTH_ALL
Definition ED_view3d.hh:207
void ED_view3d_win_to_3d_int(const View3D *v3d, const ARegion *region, const float depth_pt[3], const int mval[2], float r_out[3])
void VIEW3D_OT_camera_background_image_remove(wmOperatorType *ot)
void ED_view3d_clipping_calc_from_boundbox(float clip[4][4], const BoundBox *bb, bool is_flip)
void DEG_relations_tag_update(Main *bmain)
bPoseChannel * BKE_pose_channel_active_if_bonecoll_visible(Object *ob) ATTR_WARN_UNUSED_RESULT
void RNA_property_boolean_set(PointerRNA *ptr, PropertyRNA *prop, bool value)
Scene * CTX_data_scene(const bContext *C)
@ OPTYPE_REGISTER
Definition WM_types.hh:188
@ OPTYPE_UNDO
Definition WM_types.hh:190
@ OPTYPE_INTERNAL
Definition WM_types.hh:210
static wmOperatorStatus toggle_shading_exec(bContext *C, wmOperator *op)
static void view3d_set_view_angle(ARegion *region, View3D *v3d, const float input_angle)
static wmOperatorStatus view3d_center_camera_exec(bContext *C, wmOperator *)
PropertyRNA * RNA_def_boolean(StructOrFunctionRNA *cont_, const char *identifier, const bool default_value, const char *ui_name, const char *ui_description)
static bool view3d_region_wire_or_solid_poll(bContext *C)
static const EnumPropertyItem prop_flip_directions[]
@ PROP_FILEPATH
Definition RNA_types.hh:284
void VIEW3D_OT_drop_world(wmOperatorType *ot)
PropertyRNA * RNA_def_float(StructOrFunctionRNA *cont_, const char *identifier, const float default_value, const float hardmin, const float hardmax, const char *ui_name, const char *ui_description, const float softmin, const float softmax)
Object * CTX_data_active_object(const bContext *C)
MINLINE float dot_v3v3(const float a[3], const float b[3]) ATTR_WARN_UNUSED_RESULT
static bool view3d_lock_poll(bContext *C)
void id_us_min(ID *id)
Definition lib_id.cc:441
MINLINE void zero_v2(float r[2])
ARegion * CTX_wm_region(const bContext *C)
float view3d_horizon_correct_quat(float quat[4], const float horizon_plane[3], const bool horizon_plane_no_flip, const float axis_fallback[3], const float angle_target, const float factor)
void WM_msg_publish_rna_params(wmMsgBus *mbus, const wmMsgParams_RNA *msg_key_params)
float RNA_float_get(PointerRNA *ptr, const char *name)
void mat3_to_quat(float q[4], const float mat[3][3])
PointerRNA CTX_data_pointer_get_type(const bContext *C, const char *member, StructRNA *type)
bool RNA_property_is_set(PointerRNA *ptr, PropertyRNA *prop)
static const EnumPropertyItem prop_shading_type_items[]
View3D * CTX_wm_view3d(const bContext *C)
void VIEW3D_OT_camera_background_image_add(wmOperatorType *ot)
signed char int8_t
Definition BKE_text.h:76
static wmOperatorStatus view_lock_clear_exec(bContext *C, wmOperator *)
void ED_area_tag_redraw(ScrArea *area)
Definition area.cc:784
void ED_view3d_shade_update(Main *bmain, View3D *v3d, ScrArea *area)
static wmOperatorStatus camera_background_image_remove_exec(bContext *C, wmOperator *op)
static wmOperatorStatus drop_world_exec(bContext *C, wmOperator *op)
float angle_wrap_rad(float angle)
KERNEL_FEATURE_LIGHT_PASSES KERNEL_FEATURE_PATH_GUIDING float
struct MovieClip * clip
eCamera_BGImage_Flag flag
eRegionView3D_Flag rflag
struct BoundBox * clipbb
eRegionView3D_Persp persp
eRegionView3D_View view
struct World * world
View3DCursor cursor
struct RenderData r
eView3DOverlay_Flag flag
eView3DShading_Flag flag
View3DOverlay overlay
eView3D_Flag2 flag2
struct Object * ob_center
struct Object * camera
View3DShading shading
struct View3D * localvd
wmOperatorStatus(*) exec(bContext *C, wmOperator *op) ATTR_WARN_UNUSED_RESULT
Definition WM_types.hh:1125
const char * description
Definition WM_types.hh:1115
void(*) cancel(bContext *C, wmOperator *op)
Definition WM_types.hh:1149
bool(*) poll(bContext *C) ATTR_WARN_UNUSED_RESULT
Definition WM_types.hh:1165
wmOperatorStatus(*) invoke(bContext *C, wmOperator *op, const wmEvent *event) ATTR_WARN_UNUSED_RESULT
Definition WM_types.hh:1141
wmOperatorStatus(*) modal(bContext *C, wmOperator *op, const wmEvent *event) ATTR_WARN_UNUSED_RESULT
Definition WM_types.hh:1157
struct ReportList * reports
struct wmOperatorType * type