Blender  V2.93
view3d_view.c
Go to the documentation of this file.
1 /*
2  * This program is free software; you can redistribute it and/or
3  * modify it under the terms of the GNU General Public License
4  * as published by the Free Software Foundation; either version 2
5  * of the License, or (at your option) any later version.
6  *
7  * This program is distributed in the hope that it will be useful,
8  * but WITHOUT ANY WARRANTY; without even the implied warranty of
9  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10  * GNU General Public License for more details.
11  *
12  * You should have received a copy of the GNU General Public License
13  * along with this program; if not, write to the Free Software Foundation,
14  * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
15  *
16  * The Original Code is Copyright (C) 2008 Blender Foundation.
17  * All rights reserved.
18  */
19 
24 #include "DNA_camera_types.h"
26 #include "DNA_object_types.h"
27 #include "DNA_scene_types.h"
28 
29 #include "MEM_guardedalloc.h"
30 
31 #include "BLI_linklist.h"
32 #include "BLI_listbase.h"
33 #include "BLI_math.h"
34 #include "BLI_rect.h"
35 #include "BLI_utildefines.h"
36 
37 #include "BKE_action.h"
38 #include "BKE_camera.h"
39 #include "BKE_context.h"
40 #include "BKE_global.h"
41 #include "BKE_gpencil_modifier.h"
42 #include "BKE_idprop.h"
43 #include "BKE_layer.h"
44 #include "BKE_main.h"
45 #include "BKE_modifier.h"
46 #include "BKE_object.h"
47 #include "BKE_report.h"
48 #include "BKE_scene.h"
49 
50 #include "DEG_depsgraph.h"
51 #include "DEG_depsgraph_query.h"
52 
53 #include "UI_resources.h"
54 
55 #include "GPU_matrix.h"
56 #include "GPU_select.h"
57 #include "GPU_state.h"
58 
59 #include "WM_api.h"
60 #include "WM_types.h"
61 
62 #include "ED_object.h"
63 #include "ED_screen.h"
64 
65 #include "DRW_engine.h"
66 
67 #include "RNA_access.h"
68 #include "RNA_define.h"
69 
70 #include "view3d_intern.h" /* own include */
71 
72 /* -------------------------------------------------------------------- */
78 /* This operator is one of the 'timer refresh' ones like animation playback */
79 
81  float dist;
82  float lens;
83  float quat[4];
84  float ofs[3];
85 };
86 
88  /* source*/
89  struct SmoothView3DState src; /* source */
90  struct SmoothView3DState dst; /* destination */
91  struct SmoothView3DState org; /* original */
92 
93  bool to_camera;
94 
96  float dyn_ofs[3];
97 
98  /* When smooth-view is enabled, store the 'rv3d->view' here,
99  * assign back when the view motion is completed. */
100  char org_view;
101 
102  double time_allowed;
103 };
104 
106  const View3D *v3d,
107  const RegionView3D *rv3d)
108 {
109  copy_v3_v3(sms_state->ofs, rv3d->ofs);
110  copy_qt_qt(sms_state->quat, rv3d->viewquat);
111  sms_state->dist = rv3d->dist;
112  sms_state->lens = v3d->lens;
113 }
114 
115 static void view3d_smooth_view_state_restore(const struct SmoothView3DState *sms_state,
116  View3D *v3d,
117  RegionView3D *rv3d)
118 {
119  copy_v3_v3(rv3d->ofs, sms_state->ofs);
120  copy_qt_qt(rv3d->viewquat, sms_state->quat);
121  rv3d->dist = sms_state->dist;
122  v3d->lens = sms_state->lens;
123 }
124 
125 /* will start timer if appropriate */
126 /* the arguments are the desired situation */
128  /* avoid passing in the context */
129  const Depsgraph *depsgraph,
130  wmWindowManager *wm,
131  wmWindow *win,
132  ScrArea *area,
133  View3D *v3d,
134  ARegion *region,
135  const int smooth_viewtx,
136  const V3D_SmoothParams *sview)
137 {
138  RegionView3D *rv3d = region->regiondata;
139  struct SmoothView3DStore sms = {{0}};
140  bool ok = false;
141 
142  /* initialize sms */
143  view3d_smooth_view_state_backup(&sms.dst, v3d, rv3d);
144  view3d_smooth_view_state_backup(&sms.src, v3d, rv3d);
145  /* If smooth-view runs multiple times. */
146  if (rv3d->sms == NULL) {
147  view3d_smooth_view_state_backup(&sms.org, v3d, rv3d);
148  }
149  else {
150  sms.org = rv3d->sms->org;
151  }
152  sms.org_view = rv3d->view;
153 
154  /* sms.to_camera = false; */ /* initialized to zero anyway */
155 
156  /* note on camera locking, this is a little confusing but works ok.
157  * we may be changing the view 'as if' there is no active camera, but in fact
158  * there is an active camera which is locked to the view.
159  *
160  * In the case where smooth view is moving _to_ a camera we don't want that
161  * camera to be moved or changed, so only when the camera is not being set should
162  * we allow camera option locking to initialize the view settings from the camera.
163  */
164  if (sview->camera == NULL && sview->camera_old == NULL) {
166  }
167 
168  /* store the options we want to end with */
169  if (sview->ofs) {
170  copy_v3_v3(sms.dst.ofs, sview->ofs);
171  }
172  if (sview->quat) {
173  copy_qt_qt(sms.dst.quat, sview->quat);
174  }
175  if (sview->dist) {
176  sms.dst.dist = *sview->dist;
177  }
178  if (sview->lens) {
179  sms.dst.lens = *sview->lens;
180  }
181 
182  if (sview->dyn_ofs) {
183  BLI_assert(sview->ofs == NULL);
184  BLI_assert(sview->quat != NULL);
185 
186  copy_v3_v3(sms.dyn_ofs, sview->dyn_ofs);
187  sms.use_dyn_ofs = true;
188 
189  /* calculate the final destination offset */
190  view3d_orbit_apply_dyn_ofs(sms.dst.ofs, sms.src.ofs, sms.src.quat, sms.dst.quat, sms.dyn_ofs);
191  }
192 
193  if (sview->camera) {
194  Object *ob_camera_eval = DEG_get_evaluated_object(depsgraph, sview->camera);
195  if (sview->ofs != NULL) {
197  ob_camera_eval->obmat, sview->ofs, VIEW3D_DIST_FALLBACK);
198  }
199  ED_view3d_from_object(ob_camera_eval, sms.dst.ofs, sms.dst.quat, &sms.dst.dist, &sms.dst.lens);
200  sms.to_camera = true; /* restore view3d values in end */
201  }
202 
203  /* skip smooth viewing for external render engine draw */
204  if (smooth_viewtx && !(v3d->shading.type == OB_RENDER && rv3d->render_engine)) {
205  bool changed = false; /* zero means no difference */
206 
207  if (sview->camera_old != sview->camera) {
208  changed = true;
209  }
210  else if (sms.dst.dist != rv3d->dist) {
211  changed = true;
212  }
213  else if (sms.dst.lens != v3d->lens) {
214  changed = true;
215  }
216  else if (!equals_v3v3(sms.dst.ofs, rv3d->ofs)) {
217  changed = true;
218  }
219  else if (!equals_v4v4(sms.dst.quat, rv3d->viewquat)) {
220  changed = true;
221  }
222 
223  /* The new view is different from the old one
224  * so animate the view */
225  if (changed) {
226  /* original values */
227  if (sview->camera_old) {
228  Object *ob_camera_old_eval = DEG_get_evaluated_object(depsgraph, sview->camera_old);
229  if (sview->ofs != NULL) {
230  sms.src.dist = ED_view3d_offset_distance(ob_camera_old_eval->obmat, sview->ofs, 0.0f);
231  }
233  ob_camera_old_eval, sms.src.ofs, sms.src.quat, &sms.src.dist, &sms.src.lens);
234  }
235  /* grid draw as floor */
236  if ((RV3D_LOCK_FLAGS(rv3d) & RV3D_LOCK_ROTATION) == 0) {
237  /* use existing if exists, means multiple calls to smooth view
238  * wont lose the original 'view' setting */
239  rv3d->view = RV3D_VIEW_USER;
240  }
241 
242  sms.time_allowed = (double)smooth_viewtx / 1000.0;
243 
244  /* if this is view rotation only
245  * we can decrease the time allowed by
246  * the angle between quats
247  * this means small rotations wont lag */
248  if (sview->quat && !sview->ofs && !sview->dist) {
249  /* scale the time allowed by the rotation */
250  /* 180deg == 1.0 */
251  sms.time_allowed *= (double)fabsf(
253  M_PI;
254  }
255 
256  /* ensure it shows correct */
257  if (sms.to_camera) {
258  /* use ortho if we move from an ortho view to an ortho camera */
259  Object *ob_camera_eval = DEG_get_evaluated_object(depsgraph, sview->camera);
260  rv3d->persp = (((rv3d->is_persp == false) && (ob_camera_eval->type == OB_CAMERA) &&
261  (((Camera *)ob_camera_eval->data)->type == CAM_ORTHO)) ?
262  RV3D_ORTHO :
263  RV3D_PERSP);
264  }
265 
266  rv3d->rflag |= RV3D_NAVIGATING;
267 
268  /* not essential but in some cases the caller will tag the area for redraw, and in that
269  * case we can get a flicker of the 'org' user view but we want to see 'src' */
270  view3d_smooth_view_state_restore(&sms.src, v3d, rv3d);
271 
272  /* keep track of running timer! */
273  if (rv3d->sms == NULL) {
274  rv3d->sms = MEM_mallocN(sizeof(struct SmoothView3DStore), "smoothview v3d");
275  }
276  *rv3d->sms = sms;
277  if (rv3d->smooth_timer) {
278  WM_event_remove_timer(wm, win, rv3d->smooth_timer);
279  }
280  /* #TIMER1 is hard-coded in key-map. */
281  rv3d->smooth_timer = WM_event_add_timer(wm, win, TIMER1, 1.0 / 100.0);
282 
283  ok = true;
284  }
285  }
286 
287  /* if we get here nothing happens */
288  if (ok == false) {
289  if (sms.to_camera == false) {
290  copy_v3_v3(rv3d->ofs, sms.dst.ofs);
291  copy_qt_qt(rv3d->viewquat, sms.dst.quat);
292  rv3d->dist = sms.dst.dist;
293  v3d->lens = sms.dst.lens;
294 
296  }
297 
298  if (RV3D_LOCK_FLAGS(rv3d) & RV3D_BOXVIEW) {
299  view3d_boxview_copy(area, region);
300  }
301 
302  ED_region_tag_redraw(region);
303  }
304 }
305 
307  View3D *v3d,
308  ARegion *region,
309  const int smooth_viewtx,
310  const struct V3D_SmoothParams *sview)
311 {
314  wmWindow *win = CTX_wm_window(C);
316 
317  ED_view3d_smooth_view_ex(depsgraph, wm, win, area, v3d, region, smooth_viewtx, sview);
318 }
319 
320 /* only meant for timer usage */
321 static void view3d_smoothview_apply(bContext *C, View3D *v3d, ARegion *region, bool sync_boxview)
322 {
323  RegionView3D *rv3d = region->regiondata;
324  struct SmoothView3DStore *sms = rv3d->sms;
325  float step, step_inv;
326 
327  if (sms->time_allowed != 0.0) {
328  step = (float)((rv3d->smooth_timer->duration) / sms->time_allowed);
329  }
330  else {
331  step = 1.0f;
332  }
333 
334  /* end timer */
335  if (step >= 1.0f) {
336 
337  /* if we went to camera, store the original */
338  if (sms->to_camera) {
339  rv3d->persp = RV3D_CAMOB;
340  view3d_smooth_view_state_restore(&sms->org, v3d, rv3d);
341  }
342  else {
344 
345  view3d_smooth_view_state_restore(&sms->dst, v3d, rv3d);
346 
348  ED_view3d_camera_lock_autokey(v3d, rv3d, C, true, true);
349  }
350 
351  if ((RV3D_LOCK_FLAGS(rv3d) & RV3D_LOCK_ROTATION) == 0) {
352  rv3d->view = sms->org_view;
353  }
354 
355  MEM_freeN(rv3d->sms);
356  rv3d->sms = NULL;
357 
359  rv3d->smooth_timer = NULL;
360  rv3d->rflag &= ~RV3D_NAVIGATING;
361  }
362  else {
363  /* ease in/out */
364  step = (3.0f * step * step - 2.0f * step * step * step);
365 
366  step_inv = 1.0f - step;
367 
368  interp_qt_qtqt(rv3d->viewquat, sms->src.quat, sms->dst.quat, step);
369 
370  if (sms->use_dyn_ofs) {
372  rv3d->ofs, sms->src.ofs, sms->src.quat, rv3d->viewquat, sms->dyn_ofs);
373  }
374  else {
375  interp_v3_v3v3(rv3d->ofs, sms->src.ofs, sms->dst.ofs, step);
376  }
377 
378  rv3d->dist = sms->dst.dist * step + sms->src.dist * step_inv;
379  v3d->lens = sms->dst.lens * step + sms->src.lens * step_inv;
380 
384  ED_view3d_camera_lock_autokey(v3d, rv3d, C, true, true);
385  }
386 
387  /* Event handling won't know if a UI item has been moved under the pointer. */
389  }
390 
391  if (sync_boxview && (RV3D_LOCK_FLAGS(rv3d) & RV3D_BOXVIEW)) {
393  }
394 
395  /* note: this doesn't work right because the v3d->lens is now used in ortho mode r51636,
396  * when switching camera in quad-view the other ortho views would zoom & reset.
397  *
398  * For now only redraw all regions when smooth-view finishes.
399  */
400  if (step >= 1.0f) {
402  }
403  else {
404  ED_region_tag_redraw(region);
405  }
406 }
407 
408 static int view3d_smoothview_invoke(bContext *C, wmOperator *UNUSED(op), const wmEvent *event)
409 {
410  View3D *v3d = CTX_wm_view3d(C);
411  ARegion *region = CTX_wm_region(C);
412  RegionView3D *rv3d = region->regiondata;
413 
414  /* escape if not our timer */
415  if (rv3d->smooth_timer == NULL || rv3d->smooth_timer != event->customdata) {
416  return OPERATOR_PASS_THROUGH;
417  }
418 
419  view3d_smoothview_apply(C, v3d, region, true);
420 
421  return OPERATOR_FINISHED;
422 }
423 
429 {
430  RegionView3D *rv3d = region->regiondata;
431 
432  if (rv3d && rv3d->sms) {
433  rv3d->sms->time_allowed = 0.0; /* force finishing */
434  view3d_smoothview_apply(C, v3d, region, false);
435 
436  /* force update of view matrix so tools that run immediately after
437  * can use them without redrawing first */
440  ED_view3d_update_viewmat(depsgraph, scene, v3d, region, NULL, NULL, NULL, false);
441  }
442 }
443 
445 {
446  /* identifiers */
447  ot->name = "Smooth View";
448  ot->idname = "VIEW3D_OT_smoothview";
449 
450  /* api callbacks */
452 
453  /* flags */
455 
457 }
458 
461 /* -------------------------------------------------------------------- */
466 {
468  View3D *v3d;
469  ARegion *region;
470  RegionView3D *rv3d;
471 
473 
474  ED_view3d_context_user_region(C, &v3d, &region);
475  rv3d = region->regiondata;
476 
478 
480 
481  ED_view3d_to_object(depsgraph, v3d->camera, rv3d->ofs, rv3d->viewquat, rv3d->dist);
482 
484 
486  rv3d->persp = RV3D_CAMOB;
487 
489 
490  return OPERATOR_FINISHED;
491 }
492 
494 {
495  View3D *v3d;
496  ARegion *region;
497 
498  if (ED_view3d_context_user_region(C, &v3d, &region)) {
499  RegionView3D *rv3d = region->regiondata;
500  if (v3d && v3d->camera && !ID_IS_LINKED(v3d->camera)) {
501  if (rv3d && (RV3D_LOCK_FLAGS(rv3d) & RV3D_LOCK_ANY_TRANSFORM) == 0) {
502  if (rv3d->persp != RV3D_CAMOB) {
503  return true;
504  }
505  }
506  }
507  }
508 
509  return false;
510 }
511 
513 {
514  /* identifiers */
515  ot->name = "Align Camera to View";
516  ot->description = "Set camera view to active view";
517  ot->idname = "VIEW3D_OT_camera_to_view";
518 
519  /* api callbacks */
522 
523  /* flags */
525 }
526 
529 /* -------------------------------------------------------------------- */
533 /* unlike VIEW3D_OT_view_selected this is for framing a render and not
534  * meant to take into account vertex/bone selection for eg. */
536 {
537  Main *bmain = CTX_data_main(C);
540  View3D *v3d = CTX_wm_view3d(C); /* can be NULL */
541  Object *camera_ob = v3d ? v3d->camera : scene->camera;
542 
543  if (camera_ob == NULL) {
544  BKE_report(op->reports, RPT_ERROR, "No active camera");
545  return OPERATOR_CANCELLED;
546  }
547 
548  if (ED_view3d_camera_to_view_selected(bmain, depsgraph, scene, camera_ob)) {
550  return OPERATOR_FINISHED;
551  }
552  return OPERATOR_CANCELLED;
553 }
554 
556 {
557  /* identifiers */
558  ot->name = "Camera Fit Frame to Selected";
559  ot->description = "Move the camera so selected objects are framed";
560  ot->idname = "VIEW3D_OT_camera_to_view_selected";
561 
562  /* api callbacks */
565 
566  /* flags */
568 }
569 
572 /* -------------------------------------------------------------------- */
577  View3D *v3d,
578  Object *ob,
579  const int smooth_viewtx)
580 {
581  Main *bmain = CTX_data_main(C);
582  for (bScreen *screen = bmain->screens.first; screen != NULL; screen = screen->id.next) {
583  for (ScrArea *area = screen->areabase.first; area != NULL; area = area->next) {
584  for (SpaceLink *space_link = area->spacedata.first; space_link != NULL;
585  space_link = space_link->next) {
586  if (space_link->spacetype == SPACE_VIEW3D) {
587  View3D *other_v3d = (View3D *)space_link;
588  if (other_v3d == v3d) {
589  continue;
590  }
591  if (other_v3d->camera == ob) {
592  continue;
593  }
594  if (v3d->scenelock) {
595  ListBase *lb = (space_link == area->spacedata.first) ? &area->regionbase :
596  &space_link->regionbase;
597  for (ARegion *other_region = lb->first; other_region != NULL;
598  other_region = other_region->next) {
599  if (other_region->regiontype == RGN_TYPE_WINDOW) {
600  if (other_region->regiondata) {
601  RegionView3D *other_rv3d = other_region->regiondata;
602  if (other_rv3d->persp == RV3D_CAMOB) {
603  Object *other_camera_old = other_v3d->camera;
604  other_v3d->camera = ob;
605  ED_view3d_lastview_store(other_rv3d);
607  other_v3d,
608  other_region,
609  smooth_viewtx,
610  &(const V3D_SmoothParams){
611  .camera_old = other_camera_old,
612  .camera = other_v3d->camera,
613  .ofs = other_rv3d->ofs,
614  .quat = other_rv3d->viewquat,
615  .dist = &other_rv3d->dist,
616  .lens = &other_v3d->lens,
617  });
618  }
619  else {
620  other_v3d->camera = ob;
621  }
622  }
623  }
624  }
625  }
626  }
627  }
628  }
629  }
630 }
631 
633 {
634  View3D *v3d;
635  ARegion *region;
636  RegionView3D *rv3d;
637 
640 
641  const int smooth_viewtx = WM_operator_smooth_viewtx_get(op);
642 
643  /* no NULL check is needed, poll checks */
644  ED_view3d_context_user_region(C, &v3d, &region);
645  rv3d = region->regiondata;
646 
647  if (ob) {
648  Object *camera_old = (rv3d->persp == RV3D_CAMOB) ? V3D_CAMERA_SCENE(scene, v3d) : NULL;
649  rv3d->persp = RV3D_CAMOB;
650  v3d->camera = ob;
651  if (v3d->scenelock && scene->camera != ob) {
652  scene->camera = ob;
654  }
655 
656  /* unlikely but looks like a glitch when set to the same */
657  if (camera_old != ob) {
659 
661  v3d,
662  region,
663  smooth_viewtx,
664  &(const V3D_SmoothParams){
665  .camera_old = camera_old,
666  .camera = v3d->camera,
667  .ofs = rv3d->ofs,
668  .quat = rv3d->viewquat,
669  .dist = &rv3d->dist,
670  .lens = &v3d->lens,
671  });
672  }
673 
674  if (v3d->scenelock) {
675  sync_viewport_camera_smoothview(C, v3d, ob, smooth_viewtx);
677  }
679  }
680 
681  return OPERATOR_FINISHED;
682 }
683 
685 {
686  View3D *v3d_dummy;
687  ARegion *region_dummy;
688 
689  return ED_view3d_context_user_region(C, &v3d_dummy, &region_dummy);
690 }
691 
693 {
694  /* identifiers */
695  ot->name = "Set Active Object as Camera";
696  ot->description = "Set the active object as the active camera for this view or scene";
697  ot->idname = "VIEW3D_OT_object_as_camera";
698 
699  /* api callbacks */
702 
703  /* flags */
705 }
706 
709 /* -------------------------------------------------------------------- */
717  ARegion *region,
718  const View3D *v3d,
719  const rcti *rect)
720 {
721  RegionView3D *rv3d = region->regiondata;
722  rctf full_viewplane;
723  float clipsta, clipend;
724  bool is_ortho;
725 
726  is_ortho = ED_view3d_viewplane_get(
727  depsgraph, v3d, rv3d, region->winx, region->winy, &full_viewplane, &clipsta, &clipend, NULL);
728  rv3d->is_persp = !is_ortho;
729 
730 #if 0
731  printf("%s: %d %d %f %f %f %f %f %f\n",
732  __func__,
733  winx,
734  winy,
735  full_viewplane.xmin,
736  full_viewplane.ymin,
737  full_viewplane.xmax,
738  full_viewplane.ymax,
739  clipsta,
740  clipend);
741 #endif
742 
743  /* Note the code here was tweaked to avoid an apparent compiler bug in clang 13 (see T91680). */
744  rctf viewplane;
745  if (rect) {
746  /* Smaller viewplane subset for selection picking. */
747  viewplane.xmin = full_viewplane.xmin +
748  (BLI_rctf_size_x(&full_viewplane) * (rect->xmin / (float)region->winx));
749  viewplane.ymin = full_viewplane.ymin +
750  (BLI_rctf_size_y(&full_viewplane) * (rect->ymin / (float)region->winy));
751  viewplane.xmax = full_viewplane.xmin +
752  (BLI_rctf_size_x(&full_viewplane) * (rect->xmax / (float)region->winx));
753  viewplane.ymax = full_viewplane.ymin +
754  (BLI_rctf_size_y(&full_viewplane) * (rect->ymax / (float)region->winy));
755  }
756  else {
757  viewplane = full_viewplane;
758  }
759 
760  if (is_ortho) {
762  viewplane.xmin, viewplane.xmax, viewplane.ymin, viewplane.ymax, clipsta, clipend);
763  }
764  else {
766  viewplane.xmin, viewplane.xmax, viewplane.ymin, viewplane.ymax, clipsta, clipend);
767  }
768 
769  /* update matrix in 3d view region */
771 }
772 
773 static void obmat_to_viewmat(RegionView3D *rv3d, Object *ob)
774 {
775  float bmat[4][4];
776 
777  rv3d->view = RV3D_VIEW_USER; /* don't show the grid */
778 
779  normalize_m4_m4(bmat, ob->obmat);
780  invert_m4_m4(rv3d->viewmat, bmat);
781 
782  /* view quat calculation, needed for add object */
784 }
785 
799  const Scene *scene,
800  const View3D *v3d,
801  RegionView3D *rv3d,
802  const float rect_scale[2])
803 {
804  if (rv3d->persp == RV3D_CAMOB) { /* obs/camera */
805  if (v3d->camera) {
806  Object *ob_camera_eval = DEG_get_evaluated_object(depsgraph, v3d->camera);
807  obmat_to_viewmat(rv3d, ob_camera_eval);
808  }
809  else {
810  quat_to_mat4(rv3d->viewmat, rv3d->viewquat);
811  rv3d->viewmat[3][2] -= rv3d->dist;
812  }
813  }
814  else {
815  bool use_lock_ofs = false;
816 
817  /* should be moved to better initialize later on XXX */
818  if (RV3D_LOCK_FLAGS(rv3d) & RV3D_LOCK_ROTATION) {
819  ED_view3d_lock(rv3d);
820  }
821 
822  quat_to_mat4(rv3d->viewmat, rv3d->viewquat);
823  if (rv3d->persp == RV3D_PERSP) {
824  rv3d->viewmat[3][2] -= rv3d->dist;
825  }
826  if (v3d->ob_center) {
828  float vec[3];
829 
830  copy_v3_v3(vec, ob_eval->obmat[3]);
831  if (ob_eval->type == OB_ARMATURE && v3d->ob_center_bone[0]) {
833  if (pchan) {
834  copy_v3_v3(vec, pchan->pose_mat[3]);
835  mul_m4_v3(ob_eval->obmat, vec);
836  }
837  }
838  translate_m4(rv3d->viewmat, -vec[0], -vec[1], -vec[2]);
839  use_lock_ofs = true;
840  }
841  else if (v3d->ob_center_cursor) {
842  float vec[3];
844  translate_m4(rv3d->viewmat, -vec[0], -vec[1], -vec[2]);
845  use_lock_ofs = true;
846  }
847  else {
848  translate_m4(rv3d->viewmat, rv3d->ofs[0], rv3d->ofs[1], rv3d->ofs[2]);
849  }
850 
851  /* lock offset */
852  if (use_lock_ofs) {
853  float persmat[4][4], persinv[4][4];
854  float vec[3];
855 
856  /* we could calculate the real persmat/persinv here
857  * but it would be unreliable so better to later */
858  mul_m4_m4m4(persmat, rv3d->winmat, rv3d->viewmat);
859  invert_m4_m4(persinv, persmat);
860 
861  mul_v2_v2fl(vec, rv3d->ofs_lock, rv3d->is_persp ? rv3d->dist : 1.0f);
862  vec[2] = 0.0f;
863 
864  if (rect_scale) {
865  /* Since 'RegionView3D.winmat' has been calculated and this function doesn't take the
866  * 'ARegion' we don't know about the region size.
867  * Use 'rect_scale' when drawing a sub-region to apply 2D offset,
868  * scaled by the difference between the sub-region and the region size.
869  */
870  vec[0] /= rect_scale[0];
871  vec[1] /= rect_scale[1];
872  }
873 
874  mul_mat3_m4_v3(persinv, vec);
875  translate_m4(rv3d->viewmat, vec[0], vec[1], vec[2]);
876  }
877  /* end lock offset */
878  }
879 }
880 
883 /* -------------------------------------------------------------------- */
893 {
895 }
896 
898 {
900 }
901 
907  const rcti *rect;
909 };
910 
912 {
913  bool continue_pass = false;
915  if (stage == DRW_SELECT_PASS_PRE) {
917  data->buffer, data->buffer_len, data->rect, data->gpu_select_mode, data->hits);
918  /* always run POST after PRE. */
919  continue_pass = true;
920  }
921  else if (stage == DRW_SELECT_PASS_POST) {
922  int hits = GPU_select_end();
923  if (data->pass == 0) {
924  /* quirk of GPU_select_end, only take hits value from first call. */
925  data->hits = hits;
926  }
927  if (data->gpu_select_mode == GPU_SELECT_NEAREST_FIRST_PASS) {
928  data->gpu_select_mode = GPU_SELECT_NEAREST_SECOND_PASS;
929  continue_pass = (hits > 0);
930  }
931  data->pass += 1;
932  }
933  else {
934  BLI_assert(0);
935  }
936  return continue_pass;
937 }
938 
940 {
942  if (obact && (obact->mode & OB_MODE_ALL_WEIGHT_PAINT) &&
945  }
947  }
949 }
950 
953 {
954  const Object *obact = user_data;
955  return BKE_object_is_mode_compat(ob, obact->mode);
956 }
957 
963 {
964  LinkNode *ob_pose_list = user_data;
965  return ob_pose_list && (BLI_linklist_index(ob_pose_list, DEG_get_original_object(ob)) != -1);
966 }
967 
976  uint *buffer,
977  uint bufsize,
978  const rcti *input,
979  eV3DSelectMode select_mode,
980  eV3DSelectObjectFilter select_filter)
981 {
982  struct bThemeState theme_state;
983  const wmWindowManager *wm = CTX_wm_manager(vc->C);
985  Scene *scene = vc->scene;
986  View3D *v3d = vc->v3d;
987  ARegion *region = vc->region;
988  rcti rect;
989  int hits = 0;
990  const bool use_obedit_skip = (OBEDIT_FROM_VIEW_LAYER(vc->view_layer) != NULL) &&
991  (vc->obedit == NULL);
992  const bool is_pick_select = (U.gpu_flag & USER_GPU_FLAG_NO_DEPT_PICK) == 0;
993  const bool do_passes = ((is_pick_select == false) &&
994  (select_mode == VIEW3D_SELECT_PICK_NEAREST));
995  const bool use_nearest = (is_pick_select && select_mode == VIEW3D_SELECT_PICK_NEAREST);
996  bool draw_surface = true;
997 
998  char gpu_select_mode;
999 
1000  /* case not a box select */
1001  if (input->xmin == input->xmax) {
1002  /* seems to be default value for bones only now */
1003  BLI_rcti_init_pt_radius(&rect, (const int[2]){input->xmin, input->ymin}, 12);
1004  }
1005  else {
1006  rect = *input;
1007  }
1008 
1009  if (is_pick_select) {
1010  if (select_mode == VIEW3D_SELECT_PICK_NEAREST) {
1011  gpu_select_mode = GPU_SELECT_PICK_NEAREST;
1012  }
1013  else if (select_mode == VIEW3D_SELECT_PICK_ALL) {
1014  gpu_select_mode = GPU_SELECT_PICK_ALL;
1015  }
1016  else {
1017  gpu_select_mode = GPU_SELECT_ALL;
1018  }
1019  }
1020  else {
1021  if (do_passes) {
1022  gpu_select_mode = GPU_SELECT_NEAREST_FIRST_PASS;
1023  }
1024  else {
1025  gpu_select_mode = GPU_SELECT_ALL;
1026  }
1027  }
1028 
1029  /* Important to use 'vc->obact', not 'OBACT(vc->view_layer)' below,
1030  * so it will be NULL when hidden. */
1031  struct {
1032  DRW_ObjectFilterFn fn;
1033  void *user_data;
1034  } object_filter = {NULL, NULL};
1035  switch (select_filter) {
1037  Object *obact = vc->obact;
1038  if (obact && obact->mode != OB_MODE_OBJECT) {
1039  object_filter.fn = drw_select_filter_object_mode_lock;
1040  object_filter.user_data = obact;
1041  }
1042  break;
1043  }
1045  Object *obact = vc->obact;
1046  BLI_assert(obact && (obact->mode & OB_MODE_ALL_WEIGHT_PAINT));
1047  /* While this uses 'alloca' in a loop (which we typically avoid),
1048  * the number of items is nearly always 1, maybe 2..3 in rare cases. */
1049  LinkNode *ob_pose_list = NULL;
1050  if (obact->type == OB_GPENCIL) {
1051  GpencilVirtualModifierData virtualModifierData;
1053  obact, &virtualModifierData);
1054  for (; md; md = md->next) {
1055  if (md->type == eGpencilModifierType_Armature) {
1057  if (agmd->object && (agmd->object->mode & OB_MODE_POSE)) {
1058  BLI_linklist_prepend_alloca(&ob_pose_list, agmd->object);
1059  }
1060  }
1061  }
1062  }
1063  else {
1064  VirtualModifierData virtualModifierData;
1066  &virtualModifierData);
1067  for (; md; md = md->next) {
1068  if (md->type == eModifierType_Armature) {
1070  if (amd->object && (amd->object->mode & OB_MODE_POSE)) {
1071  BLI_linklist_prepend_alloca(&ob_pose_list, amd->object);
1072  }
1073  }
1074  }
1075  }
1077  object_filter.user_data = ob_pose_list;
1078  break;
1079  }
1081  break;
1082  }
1083 
1084  /* Tools may request depth outside of regular drawing code. */
1085  UI_Theme_Store(&theme_state);
1087 
1088  /* Re-use cache (rect must be smaller than the cached)
1089  * other context is assumed to be unchanged */
1090  if (GPU_select_is_cached()) {
1091  GPU_select_begin(buffer, bufsize, &rect, gpu_select_mode, 0);
1093  hits = GPU_select_end();
1094  goto finally;
1095  }
1096 
1097  /* All of the queries need to be perform on the drawing context. */
1099 
1100  G.f |= G_FLAG_PICKSEL;
1101 
1102  /* Important we use the 'viewmat' and don't re-calculate since
1103  * the object & bone view locking takes 'rect' into account, see: T51629. */
1105  wm, vc->win, depsgraph, scene, region, v3d, vc->rv3d->viewmat, NULL, &rect);
1106 
1107  if (!XRAY_ACTIVE(v3d)) {
1109  }
1110 
1111  /* If in xray mode, we select the wires in priority. */
1112  if (XRAY_ACTIVE(v3d) && use_nearest) {
1113  /* We need to call "GPU_select_*" API's inside DRW_draw_select_loop
1114  * because the OpenGL context created & destroyed inside this function. */
1115  struct DrawSelectLoopUserData drw_select_loop_user_data = {
1116  .pass = 0,
1117  .hits = 0,
1118  .buffer = buffer,
1119  .buffer_len = bufsize,
1120  .rect = &rect,
1121  .gpu_select_mode = gpu_select_mode,
1122  };
1123  draw_surface = false;
1125  region,
1126  v3d,
1127  use_obedit_skip,
1128  draw_surface,
1129  use_nearest,
1130  &rect,
1132  &drw_select_loop_user_data,
1133  object_filter.fn,
1134  object_filter.user_data);
1135  hits = drw_select_loop_user_data.hits;
1136  /* FIX: This cleanup the state before doing another selection pass.
1137  * (see T56695) */
1139  }
1140 
1141  if (hits == 0) {
1142  /* We need to call "GPU_select_*" API's inside DRW_draw_select_loop
1143  * because the OpenGL context created & destroyed inside this function. */
1144  struct DrawSelectLoopUserData drw_select_loop_user_data = {
1145  .pass = 0,
1146  .hits = 0,
1147  .buffer = buffer,
1148  .buffer_len = bufsize,
1149  .rect = &rect,
1150  .gpu_select_mode = gpu_select_mode,
1151  };
1152  /* If are not in wireframe mode, we need to use the mesh surfaces to check for hits */
1153  draw_surface = (v3d->shading.type > OB_WIRE) || !XRAY_ENABLED(v3d);
1155  region,
1156  v3d,
1157  use_obedit_skip,
1158  draw_surface,
1159  use_nearest,
1160  &rect,
1162  &drw_select_loop_user_data,
1163  object_filter.fn,
1164  object_filter.user_data);
1165  hits = drw_select_loop_user_data.hits;
1166  }
1167 
1168  G.f &= ~G_FLAG_PICKSEL;
1170  wm, vc->win, depsgraph, scene, region, v3d, vc->rv3d->viewmat, NULL, NULL);
1171 
1172  if (!XRAY_ACTIVE(v3d)) {
1174  }
1175 
1177 
1178 finally:
1179 
1180  if (hits < 0) {
1181  printf("Too many objects in select buffer\n"); /* XXX make error message */
1182  }
1183 
1184  UI_Theme_Restore(&theme_state);
1185 
1186  return hits;
1187 }
1188 
1190  uint *buffer,
1191  uint bufsize,
1192  const rcti *input,
1193  eV3DSelectMode select_mode,
1194  eV3DSelectObjectFilter select_filter,
1195  uint select_id)
1196 {
1197  int hits = view3d_opengl_select(vc, buffer, bufsize, input, select_mode, select_filter);
1198 
1199  /* Selection sometimes uses -1 for an invalid selection ID, remove these as they
1200  * interfere with detection of actual number of hits in the selection. */
1201  if (hits > 0) {
1203  }
1204  return hits;
1205 }
1206 
1209 /* -------------------------------------------------------------------- */
1214 {
1215  ScrArea *area;
1216  bScreen *screen;
1217 
1218  ushort local_view_bits = 0;
1219 
1220  /* Sometimes we lose a local-view: when an area is closed.
1221  * Check all areas: which local-views are in use? */
1222  for (screen = bmain->screens.first; screen; screen = screen->id.next) {
1223  for (area = screen->areabase.first; area; area = area->next) {
1224  SpaceLink *sl = area->spacedata.first;
1225  for (; sl; sl = sl->next) {
1226  if (sl->spacetype == SPACE_VIEW3D) {
1227  View3D *v3d = (View3D *)sl;
1228  if (v3d->localvd) {
1229  local_view_bits |= v3d->local_view_uuid;
1230  }
1231  }
1232  }
1233  }
1234  }
1235 
1236  for (int i = 0; i < 16; i++) {
1237  if ((local_view_bits & (1 << i)) == 0) {
1238  return (1 << i);
1239  }
1240  }
1241 
1242  return 0;
1243 }
1244 
1246  wmWindowManager *wm,
1247  wmWindow *win,
1248  Main *bmain,
1249  ViewLayer *view_layer,
1250  ScrArea *area,
1251  const bool frame_selected,
1252  const int smooth_viewtx,
1253  ReportList *reports)
1254 {
1255  View3D *v3d = area->spacedata.first;
1256  Base *base;
1257  float min[3], max[3], box[3];
1258  float size = 0.0f;
1259  uint local_view_bit;
1260  bool ok = false;
1261 
1262  if (v3d->localvd) {
1263  return ok;
1264  }
1265 
1266  INIT_MINMAX(min, max);
1267 
1268  local_view_bit = free_localview_bit(bmain);
1269 
1270  if (local_view_bit == 0) {
1271  /* TODO(dfelinto): We can kick one of the other 3D views out of local view
1272  * specially if it is not being used. */
1273  BKE_report(reports, RPT_ERROR, "No more than 16 local views");
1274  ok = false;
1275  }
1276  else {
1277  Object *obedit = OBEDIT_FROM_VIEW_LAYER(view_layer);
1278  if (obedit) {
1279  for (base = FIRSTBASE(view_layer); base; base = base->next) {
1280  base->local_view_bits &= ~local_view_bit;
1281  }
1282  FOREACH_BASE_IN_EDIT_MODE_BEGIN (view_layer, v3d, base_iter) {
1283  BKE_object_minmax(base_iter->object, min, max, false);
1284  base_iter->local_view_bits |= local_view_bit;
1285  ok = true;
1286  }
1288  }
1289  else {
1290  for (base = FIRSTBASE(view_layer); base; base = base->next) {
1291  if (BASE_SELECTED(v3d, base)) {
1292  BKE_object_minmax(base->object, min, max, false);
1293  base->local_view_bits |= local_view_bit;
1294  ok = true;
1295  }
1296  else {
1297  base->local_view_bits &= ~local_view_bit;
1298  }
1299  }
1300  }
1301 
1302  sub_v3_v3v3(box, max, min);
1303  size = max_fff(box[0], box[1], box[2]);
1304  }
1305 
1306  if (ok == false) {
1307  return false;
1308  }
1309 
1310  ARegion *region;
1311 
1312  v3d->localvd = MEM_mallocN(sizeof(View3D), "localview");
1313 
1314  memcpy(v3d->localvd, v3d, sizeof(View3D));
1315  v3d->local_view_uuid = local_view_bit;
1316 
1317  for (region = area->regionbase.first; region; region = region->next) {
1318  if (region->regiontype == RGN_TYPE_WINDOW) {
1319  RegionView3D *rv3d = region->regiondata;
1320  bool ok_dist = true;
1321 
1322  /* New view values. */
1323  Object *camera_old = NULL;
1324  float dist_new, ofs_new[3];
1325 
1326  rv3d->localvd = MEM_mallocN(sizeof(RegionView3D), "localview region");
1327  memcpy(rv3d->localvd, rv3d, sizeof(RegionView3D));
1328 
1329  if (frame_selected) {
1330  float mid[3];
1331  mid_v3_v3v3(mid, min, max);
1332  negate_v3_v3(ofs_new, mid);
1333 
1334  if (rv3d->persp == RV3D_CAMOB) {
1335  rv3d->persp = RV3D_PERSP;
1336  camera_old = v3d->camera;
1337  }
1338 
1339  if (rv3d->persp == RV3D_ORTHO) {
1340  if (size < 0.0001f) {
1341  ok_dist = false;
1342  }
1343  }
1344 
1345  if (ok_dist) {
1346  dist_new = ED_view3d_radius_to_dist(
1347  v3d, region, depsgraph, rv3d->persp, true, (size / 2) * VIEW3D_MARGIN);
1348 
1349  if (rv3d->persp == RV3D_PERSP) {
1350  /* Don't zoom closer than the near clipping plane. */
1351  dist_new = max_ff(dist_new, v3d->clip_start * 1.5f);
1352  }
1353  }
1354 
1356  wm,
1357  win,
1358  area,
1359  v3d,
1360  region,
1361  smooth_viewtx,
1362  &(const V3D_SmoothParams){
1363  .camera_old = camera_old,
1364  .ofs = ofs_new,
1365  .quat = rv3d->viewquat,
1366  .dist = ok_dist ? &dist_new : NULL,
1367  .lens = &v3d->lens,
1368  });
1369  }
1370  }
1371  }
1372 
1373  return ok;
1374 }
1375 
1377  wmWindowManager *wm,
1378  wmWindow *win,
1379  ViewLayer *view_layer,
1380  ScrArea *area,
1381  const bool frame_selected,
1382  const int smooth_viewtx)
1383 {
1384  View3D *v3d = area->spacedata.first;
1385 
1386  if (v3d->localvd == NULL) {
1387  return;
1388  }
1389 
1390  for (Base *base = FIRSTBASE(view_layer); base; base = base->next) {
1391  if (base->local_view_bits & v3d->local_view_uuid) {
1392  base->local_view_bits &= ~v3d->local_view_uuid;
1393  }
1394  }
1395 
1396  Object *camera_old = v3d->camera;
1397  Object *camera_new = v3d->localvd->camera;
1398 
1399  v3d->local_view_uuid = 0;
1400  v3d->camera = v3d->localvd->camera;
1401 
1402  MEM_freeN(v3d->localvd);
1403  v3d->localvd = NULL;
1404 
1405  LISTBASE_FOREACH (ARegion *, region, &area->regionbase) {
1406  if (region->regiontype == RGN_TYPE_WINDOW) {
1407  RegionView3D *rv3d = region->regiondata;
1408 
1409  if (rv3d->localvd == NULL) {
1410  continue;
1411  }
1412 
1413  if (frame_selected) {
1414  Object *camera_old_rv3d, *camera_new_rv3d;
1415 
1416  camera_old_rv3d = (rv3d->persp == RV3D_CAMOB) ? camera_old : NULL;
1417  camera_new_rv3d = (rv3d->localvd->persp == RV3D_CAMOB) ? camera_new : NULL;
1418 
1419  rv3d->view = rv3d->localvd->view;
1420  rv3d->persp = rv3d->localvd->persp;
1421  rv3d->camzoom = rv3d->localvd->camzoom;
1422 
1424  wm,
1425  win,
1426  area,
1427  v3d,
1428  region,
1429  smooth_viewtx,
1430  &(const V3D_SmoothParams){
1431  .camera_old = camera_old_rv3d,
1432  .camera = camera_new_rv3d,
1433  .ofs = rv3d->localvd->ofs,
1434  .quat = rv3d->localvd->viewquat,
1435  .dist = &rv3d->localvd->dist,
1436  });
1437  }
1438 
1439  MEM_freeN(rv3d->localvd);
1440  rv3d->localvd = NULL;
1441  }
1442  }
1443 }
1444 
1446 {
1448  const int smooth_viewtx = WM_operator_smooth_viewtx_get(op);
1450  wmWindow *win = CTX_wm_window(C);
1451  Main *bmain = CTX_data_main(C);
1453  ViewLayer *view_layer = CTX_data_view_layer(C);
1454  ScrArea *area = CTX_wm_area(C);
1455  View3D *v3d = CTX_wm_view3d(C);
1456  bool frame_selected = RNA_boolean_get(op->ptr, "frame_selected");
1457  bool changed;
1458 
1459  if (v3d->localvd) {
1460  view3d_localview_exit(depsgraph, wm, win, view_layer, area, frame_selected, smooth_viewtx);
1461  changed = true;
1462  }
1463  else {
1464  changed = view3d_localview_init(
1465  depsgraph, wm, win, bmain, view_layer, area, frame_selected, smooth_viewtx, op->reports);
1466  }
1467 
1468  if (changed) {
1469  DEG_id_type_tag(bmain, ID_OB);
1471 
1472  /* Unselected objects become selected when exiting. */
1473  if (v3d->localvd == NULL) {
1476  }
1477  else {
1479  }
1480 
1481  return OPERATOR_FINISHED;
1482  }
1483  return OPERATOR_CANCELLED;
1484 }
1485 
1487 {
1488  /* identifiers */
1489  ot->name = "Local View";
1490  ot->description = "Toggle display of selected object(s) separately and centered in view";
1491  ot->idname = "VIEW3D_OT_localview";
1492 
1493  /* api callbacks */
1494  ot->exec = localview_exec;
1495  ot->flag = OPTYPE_UNDO; /* localview changes object layer bitflags */
1496 
1498 
1500  "frame_selected",
1501  true,
1502  "Frame Selected",
1503  "Move the view to frame the selected objects");
1504 }
1505 
1507 {
1508  View3D *v3d = CTX_wm_view3d(C);
1509  Main *bmain = CTX_data_main(C);
1511  ViewLayer *view_layer = CTX_data_view_layer(C);
1512  bool changed = false;
1513 
1514  for (Base *base = FIRSTBASE(view_layer); base; base = base->next) {
1515  if (BASE_SELECTED(v3d, base)) {
1516  base->local_view_bits &= ~v3d->local_view_uuid;
1518 
1519  if (base == BASACT(view_layer)) {
1520  view_layer->basact = NULL;
1521  }
1522  changed = true;
1523  }
1524  }
1525 
1526  if (changed) {
1527  DEG_on_visible_update(bmain, false);
1531  return OPERATOR_FINISHED;
1532  }
1533 
1534  BKE_report(op->reports, RPT_ERROR, "No object selected");
1535  return OPERATOR_CANCELLED;
1536 }
1537 
1539 {
1540  if (CTX_data_edit_object(C) != NULL) {
1541  return false;
1542  }
1543 
1544  View3D *v3d = CTX_wm_view3d(C);
1545  return v3d && v3d->localvd;
1546 }
1547 
1549 {
1550  /* identifiers */
1551  ot->name = "Remove from Local View";
1552  ot->description = "Move selected objects out of local view";
1553  ot->idname = "VIEW3D_OT_localview_remove_from";
1554 
1555  /* api callbacks */
1559  ot->flag = OPTYPE_UNDO;
1560 }
1561 
1564 /* -------------------------------------------------------------------- */
1568 static uint free_localcollection_bit(Main *bmain, ushort local_collections_uuid, bool *r_reset)
1569 {
1570  ScrArea *area;
1571  bScreen *screen;
1572 
1573  ushort local_view_bits = 0;
1574 
1575  /* Check all areas: which localviews are in use? */
1576  for (screen = bmain->screens.first; screen; screen = screen->id.next) {
1577  for (area = screen->areabase.first; area; area = area->next) {
1578  SpaceLink *sl = area->spacedata.first;
1579  for (; sl; sl = sl->next) {
1580  if (sl->spacetype == SPACE_VIEW3D) {
1581  View3D *v3d = (View3D *)sl;
1582  if (v3d->flag & V3D_LOCAL_COLLECTIONS) {
1583  local_view_bits |= v3d->local_collections_uuid;
1584  }
1585  }
1586  }
1587  }
1588  }
1589 
1590  /* First try to keep the old uuid. */
1591  if (local_collections_uuid && ((local_collections_uuid & local_view_bits) == 0)) {
1592  return local_collections_uuid;
1593  }
1594 
1595  /* Otherwise get the first free available. */
1596  for (int i = 0; i < 16; i++) {
1597  if ((local_view_bits & (1 << i)) == 0) {
1598  *r_reset = true;
1599  return (1 << i);
1600  }
1601  }
1602 
1603  return 0;
1604 }
1605 
1606 static void local_collections_reset_uuid(LayerCollection *layer_collection,
1607  const ushort local_view_bit)
1608 {
1609  if (layer_collection->flag & LAYER_COLLECTION_HIDE) {
1610  layer_collection->local_collections_bits &= ~local_view_bit;
1611  }
1612  else {
1613  layer_collection->local_collections_bits |= local_view_bit;
1614  }
1615 
1616  LISTBASE_FOREACH (LayerCollection *, child, &layer_collection->layer_collections) {
1617  local_collections_reset_uuid(child, local_view_bit);
1618  }
1619 }
1620 
1621 static void view3d_local_collections_reset(Main *bmain, const uint local_view_bit)
1622 {
1623  LISTBASE_FOREACH (Scene *, scene, &bmain->scenes) {
1624  LISTBASE_FOREACH (ViewLayer *, view_layer, &scene->view_layers) {
1625  LISTBASE_FOREACH (LayerCollection *, layer_collection, &view_layer->layer_collections) {
1626  local_collections_reset_uuid(layer_collection, local_view_bit);
1627  }
1628  }
1629  }
1630 }
1631 
1638 {
1639  if ((v3d->flag & V3D_LOCAL_COLLECTIONS) == 0) {
1640  return true;
1641  }
1642 
1643  bool reset = false;
1644  v3d->flag &= ~V3D_LOCAL_COLLECTIONS;
1645  uint local_view_bit = free_localcollection_bit(bmain, v3d->local_collections_uuid, &reset);
1646 
1647  if (local_view_bit == 0) {
1648  return false;
1649  }
1650 
1651  v3d->local_collections_uuid = local_view_bit;
1652  v3d->flag |= V3D_LOCAL_COLLECTIONS;
1653 
1654  if (reset) {
1655  view3d_local_collections_reset(bmain, local_view_bit);
1656  }
1657 
1658  return true;
1659 }
1660 
1661 void ED_view3d_local_collections_reset(struct bContext *C, const bool reset_all)
1662 {
1663  Main *bmain = CTX_data_main(C);
1664  uint local_view_bit = ~(0);
1665  bool do_reset = false;
1666 
1667  /* Reset only the ones that are not in use. */
1668  LISTBASE_FOREACH (bScreen *, screen, &bmain->screens) {
1669  LISTBASE_FOREACH (ScrArea *, area, &screen->areabase) {
1670  LISTBASE_FOREACH (SpaceLink *, sl, &area->spacedata) {
1671  if (sl->spacetype == SPACE_VIEW3D) {
1672  View3D *v3d = (View3D *)sl;
1673  if (v3d->local_collections_uuid) {
1674  if (v3d->flag & V3D_LOCAL_COLLECTIONS) {
1675  local_view_bit &= ~v3d->local_collections_uuid;
1676  }
1677  else {
1678  do_reset = true;
1679  }
1680  }
1681  }
1682  }
1683  }
1684  }
1685 
1686  if (do_reset) {
1687  view3d_local_collections_reset(bmain, local_view_bit);
1688  }
1689  else if (reset_all && (do_reset || (local_view_bit != ~(0)))) {
1690  view3d_local_collections_reset(bmain, ~(0));
1691  View3D v3d = {.local_collections_uuid = ~(0)};
1694  }
1695 }
1696 
1699 /* -------------------------------------------------------------------- */
1703 #ifdef WITH_XR_OPENXR
1704 
1705 static void view3d_xr_mirror_begin(RegionView3D *rv3d)
1706 {
1707  /* If there is no session yet, changes below should not be applied! */
1708  BLI_assert(WM_xr_session_exists(&((wmWindowManager *)G_MAIN->wm.first)->xr));
1709 
1711  /* Force perspective view. This isn't reset but that's not really an issue. */
1712  rv3d->persp = RV3D_PERSP;
1713 }
1714 
1715 static void view3d_xr_mirror_end(RegionView3D *rv3d)
1716 {
1718 }
1719 
1720 void ED_view3d_xr_mirror_update(const ScrArea *area, const View3D *v3d, const bool enable)
1721 {
1722  ARegion *region_rv3d;
1723 
1725 
1726  if (ED_view3d_area_user_region(area, v3d, &region_rv3d)) {
1727  if (enable) {
1728  view3d_xr_mirror_begin(region_rv3d->regiondata);
1729  }
1730  else {
1731  view3d_xr_mirror_end(region_rv3d->regiondata);
1732  }
1733  }
1734 }
1735 
1736 void ED_view3d_xr_shading_update(wmWindowManager *wm, const View3D *v3d, const Scene *scene)
1737 {
1739  View3DShading *xr_shading = &wm->xr.session_settings.shading;
1740  /* Flags that shouldn't be overridden by the 3D View shading. */
1741  const int flag_copy = V3D_SHADING_WORLD_ORIENTATION;
1742 
1744 
1745  if (v3d->shading.type == OB_RENDER) {
1747  /* Keep old shading while using Cycles or another engine, they are typically not usable in
1748  * VR. */
1749  return;
1750  }
1751  }
1752 
1753  if (xr_shading->prop) {
1754  IDP_FreeProperty(xr_shading->prop);
1755  xr_shading->prop = NULL;
1756  }
1757 
1758  /* Copy shading from View3D to VR view. */
1759  const int old_xr_shading_flag = xr_shading->flag;
1760  *xr_shading = v3d->shading;
1761  xr_shading->flag = (xr_shading->flag & ~flag_copy) | (old_xr_shading_flag & flag_copy);
1762  if (v3d->shading.prop) {
1763  xr_shading->prop = IDP_CopyProperty(xr_shading->prop);
1764  }
1765  }
1766 }
1767 
1768 bool ED_view3d_is_region_xr_mirror_active(const wmWindowManager *wm,
1769  const View3D *v3d,
1770  const ARegion *region)
1771 {
1772  return (v3d->flag & V3D_XR_SESSION_MIRROR) &&
1773  /* The free region (e.g. the camera region in quad-view) is always
1774  * the last in the list base. We don't want any other to be affected. */
1775  !region->next && //
1776  WM_xr_session_is_ready(&wm->xr);
1777 }
1778 
1779 #endif
1780 
typedef float(TangentPoint)[2]
Blender kernel action and pose functionality.
struct bPoseChannel * BKE_pose_channel_find_name(const struct bPose *pose, const char *name)
Camera data-block and utility functions.
struct ScrArea * CTX_wm_area(const bContext *C)
Definition: context.c:714
struct Scene * CTX_data_scene(const bContext *C)
Definition: context.c:1034
struct Object * CTX_data_edit_object(const bContext *C)
Definition: context.c:1296
struct wmWindowManager * CTX_wm_manager(const bContext *C)
Definition: context.c:689
struct ViewLayer * CTX_data_view_layer(const bContext *C)
Definition: context.c:1044
struct Depsgraph * CTX_data_ensure_evaluated_depsgraph(const bContext *C)
Definition: context.c:1424
struct Object * CTX_data_active_object(const bContext *C)
Definition: context.c:1279
struct View3D * CTX_wm_view3d(const bContext *C)
Definition: context.c:760
struct ARegion * CTX_wm_region(const bContext *C)
Definition: context.c:725
struct Main * CTX_data_main(const bContext *C)
Definition: context.c:1018
struct wmWindow * CTX_wm_window(const bContext *C)
Definition: context.c:699
#define G_MAIN
Definition: BKE_global.h:232
@ G_FLAG_PICKSEL
Definition: BKE_global.h:111
struct GpencilModifierData * BKE_gpencil_modifiers_get_virtual_modifierlist(const struct Object *ob, struct GpencilVirtualModifierData *data)
void IDP_FreeProperty(struct IDProperty *prop)
Definition: idprop.c:1040
struct IDProperty * IDP_CopyProperty(const struct IDProperty *prop) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL()
#define FOREACH_BASE_IN_EDIT_MODE_BEGIN(_view_layer, _v3d, _instance)
Definition: BKE_layer.h:275
void BKE_layer_collection_local_sync(struct ViewLayer *view_layer, const struct View3D *v3d)
#define FOREACH_BASE_IN_EDIT_MODE_END
Definition: BKE_layer.h:278
struct ModifierData * BKE_modifiers_get_virtual_modifierlist(const struct Object *ob, struct VirtualModifierData *data)
General operations, lookup, etc. for blender objects.
struct Object * BKE_object_pose_armature_get(struct Object *ob)
Definition: object.c:2487
bool BKE_object_is_mode_compat(const struct Object *ob, eObjectMode object_mode)
Definition: object.c:1982
void BKE_object_minmax(struct Object *ob, float r_min[3], float r_max[3], const bool use_hidden)
Definition: object.c:3964
void BKE_object_tfm_protected_backup(const struct Object *ob, ObjectTfmProtectedChannels *obtfm)
void BKE_object_tfm_protected_restore(struct Object *ob, const ObjectTfmProtectedChannels *obtfm, const short protectflag)
Definition: object.c:3158
void BKE_report(ReportList *reports, ReportType type, const char *message)
Definition: report.c:104
bool BKE_scene_uses_blender_eevee(const struct Scene *scene)
bool BKE_scene_uses_blender_workbench(const struct Scene *scene)
#define BLI_assert(a)
Definition: BLI_assert.h:58
#define LISTBASE_FOREACH(type, var, list)
Definition: BLI_listbase.h:172
MINLINE float max_fff(float a, float b, float c)
MINLINE float max_ff(float a, float b)
#define M_PI
Definition: BLI_math_base.h:38
void mul_m4_m4m4(float R[4][4], const float A[4][4], const float B[4][4])
Definition: math_matrix.c:262
void mul_mat3_m4_v3(const float M[4][4], float r[3])
Definition: math_matrix.c:794
void translate_m4(float mat[4][4], float tx, float ty, float tz)
Definition: math_matrix.c:2325
bool invert_m4_m4(float R[4][4], const float A[4][4])
Definition: math_matrix.c:1278
void mul_m4_v3(const float M[4][4], float r[3])
Definition: math_matrix.c:732
void normalize_m4_m4(float R[4][4], const float M[4][4]) ATTR_NONNULL()
Definition: math_matrix.c:1972
float angle_signed_normalized_qtqt(const float q1[4], const float q2[4])
void interp_qt_qtqt(float q[4], const float a[4], const float b[4], const float t)
void mat4_normalized_to_quat(float q[4], const float mat[4][4])
void copy_qt_qt(float q[4], const float a[4])
Definition: math_rotation.c:52
void quat_to_mat4(float mat[4][4], const float q[4])
void interp_v3_v3v3(float r[3], const float a[3], const float b[3], const float t)
Definition: math_vector.c:49
MINLINE bool equals_v4v4(const float a[4], const float b[4]) ATTR_WARN_UNUSED_RESULT
MINLINE void sub_v3_v3v3(float r[3], const float a[3], const float b[3])
MINLINE void copy_v3_v3(float r[3], const float a[3])
MINLINE void negate_v3_v3(float r[3], const float a[3])
MINLINE bool equals_v3v3(const float a[3], const float b[3]) ATTR_WARN_UNUSED_RESULT
void mid_v3_v3v3(float r[3], const float a[3], const float b[3])
Definition: math_vector.c:270
MINLINE void mul_v2_v2fl(float r[2], const float a[2], float f)
void BLI_rcti_init_pt_radius(struct rcti *rect, const int xy[2], int size)
Definition: rct.c:508
BLI_INLINE float BLI_rctf_size_x(const struct rctf *rct)
Definition: BLI_rect.h:161
BLI_INLINE float BLI_rctf_size_y(const struct rctf *rct)
Definition: BLI_rect.h:165
unsigned int uint
Definition: BLI_sys_types.h:83
unsigned short ushort
Definition: BLI_sys_types.h:84
#define INIT_MINMAX(min, max)
#define UNUSED(x)
typedef double(DMatrix)[4][4]
void DEG_on_visible_update(struct Main *bmain, const bool do_time)
struct Depsgraph Depsgraph
Definition: DEG_depsgraph.h:51
void DEG_id_type_tag(struct Main *bmain, short id_type)
void DEG_id_tag_update(struct ID *id, int flag)
struct Object * DEG_get_original_object(struct Object *object)
struct Object * DEG_get_evaluated_object(const struct Depsgraph *depsgraph, struct Object *object)
@ ID_RECALC_TRANSFORM
Definition: DNA_ID.h:599
@ ID_RECALC_COPY_ON_WRITE
Definition: DNA_ID.h:654
@ ID_RECALC_SELECT
Definition: DNA_ID.h:638
@ ID_RECALC_BASE_FLAGS
Definition: DNA_ID.h:641
#define ID_IS_LINKED(_id)
Definition: DNA_ID.h:426
@ ID_OB
Definition: DNA_ID_enums.h:59
@ CAM_ORTHO
@ eGpencilModifierType_Armature
@ LAYER_COLLECTION_HIDE
@ BASE_SELECTED
@ eModifierType_Armature
@ OB_WIRE
@ OB_RENDER
#define OB_MODE_ALL_WEIGHT_PAINT
@ OB_MODE_POSE
@ OB_MODE_OBJECT
Object is a sort of wrapper for general info.
@ OB_CAMERA
@ OB_ARMATURE
@ OB_GPENCIL
@ SCE_OBJECT_MODE_LOCK
#define OBEDIT_FROM_VIEW_LAYER(view_layer)
#define FIRSTBASE(_view_layer)
#define V3D_CAMERA_SCENE(scene, v3d)
#define BASACT(_view_layer)
@ RGN_TYPE_WINDOW
@ SPACE_VIEW3D
@ USER_GPU_FLAG_NO_DEPT_PICK
#define RV3D_LOCK_FLAGS(rv3d)
#define RV3D_CAMOB
#define V3D_XR_SESSION_MIRROR
@ RV3D_LOCK_ANY_TRANSFORM
@ RV3D_LOCK_ROTATION
@ RV3D_BOXVIEW
@ V3D_RUNTIME_XR_SESSION_ROOT
#define RV3D_PERSP
#define V3D_LOCAL_COLLECTIONS
#define RV3D_VIEW_USER
@ V3D_SHADING_WORLD_ORIENTATION
#define RV3D_NAVIGATING
#define RV3D_ORTHO
@ OPERATOR_CANCELLED
@ OPERATOR_FINISHED
@ OPERATOR_PASS_THROUGH
void DRW_opengl_context_enable(void)
eDRWSelectStage
Definition: DRW_engine.h:74
@ DRW_SELECT_PASS_POST
Definition: DRW_engine.h:76
@ DRW_SELECT_PASS_PRE
Definition: DRW_engine.h:75
bool(* DRW_ObjectFilterFn)(struct Object *ob, void *user_data)
Definition: DRW_engine.h:79
void DRW_opengl_context_disable(void)
void DRW_draw_select_loop(struct Depsgraph *depsgraph, struct ARegion *region, struct View3D *v3d, bool use_obedit_skip, bool draw_surface, bool use_nearest, const struct rcti *rect, DRW_SelectPassFn select_pass_fn, void *select_pass_user_data, DRW_ObjectFilterFn object_filter_fn, void *object_filter_user_data)
void ED_object_base_select(struct Base *base, eObjectSelect_Mode mode)
Definition: object_select.c:98
@ BA_DESELECT
Definition: ED_object.h:146
void ED_area_tag_redraw(ScrArea *area)
Definition: area.c:745
bScreen * ED_screen_animation_playing(const struct wmWindowManager *wm)
void ED_region_tag_redraw(struct ARegion *region)
Definition: area.c:667
bool ED_operator_view3d_active(struct bContext *C)
Definition: screen_ops.c:230
bool ED_operator_scene_editable(struct bContext *C)
Definition: screen_ops.c:192
bool ED_view3d_camera_lock_sync(const struct Depsgraph *depsgraph, struct View3D *v3d, struct RegionView3D *rv3d)
bool ED_view3d_area_user_region(const struct ScrArea *area, const struct View3D *v3d, struct ARegion **r_region)
#define XRAY_ENABLED(v3d)
Definition: ED_view3d.h:710
float ED_view3d_radius_to_dist(const struct View3D *v3d, const struct ARegion *region, const struct Depsgraph *depsgraph, const char persp, const bool use_aspect, const float radius)
bool ED_view3d_viewplane_get(struct Depsgraph *depsgraph, const struct View3D *v3d, const struct RegionView3D *rv3d, int winxi, int winyi, struct rctf *r_viewplane, float *r_clipsta, float *r_clipend, float *r_pixsize)
bool ED_view3d_camera_to_view_selected(struct Main *bmain, struct Depsgraph *depsgraph, const struct Scene *scene, struct Object *camera_ob)
#define VIEW3D_DIST_FALLBACK
Definition: ED_view3d.h:676
void ED_view3d_draw_setup_view(const struct wmWindowManager *wm, struct wmWindow *win, struct Depsgraph *depsgraph, struct Scene *scene, struct ARegion *region, struct View3D *v3d, const float viewmat[4][4], const float winmat[4][4], const struct rcti *rect)
#define VIEW3D_MARGIN
Definition: ED_view3d.h:675
#define XRAY_ACTIVE(v3d)
Definition: ED_view3d.h:711
void ED_view3d_from_object(const struct Object *ob, float ofs[3], float quat[4], float *dist, float *lens)
float ED_view3d_offset_distance(const float mat[4][4], const float ofs[3], const float fallback_dist)
bool ED_view3d_camera_lock_autokey(struct View3D *v3d, struct RegionView3D *rv3d, struct bContext *C, const bool do_rotate, const bool do_translate)
Definition: view3d_utils.c:710
void ED_view3d_update_viewmat(struct Depsgraph *depsgraph, const struct Scene *scene, struct View3D *v3d, struct ARegion *region, const float viewmat[4][4], const float winmat[4][4], const struct rcti *rect, bool offscreen)
void ED_view3d_to_object(const struct Depsgraph *depsgraph, struct Object *ob, const float ofs[3], const float quat[4], const float dist)
eV3DSelectMode
Definition: ED_view3d.h:513
@ VIEW3D_SELECT_PICK_ALL
Definition: ED_view3d.h:517
@ VIEW3D_SELECT_PICK_NEAREST
Definition: ED_view3d.h:519
void ED_view3d_lastview_store(struct RegionView3D *rv3d)
Definition: view3d_utils.c:487
bool ED_view3d_lock(struct RegionView3D *rv3d)
void ED_view3d_camera_lock_init(const struct Depsgraph *depsgraph, struct View3D *v3d, struct RegionView3D *rv3d)
bool ED_view3d_context_user_region(struct bContext *C, struct View3D **r_v3d, struct ARegion **r_region)
Definition: space_view3d.c:107
eV3DSelectObjectFilter
Definition: ED_view3d.h:522
@ VIEW3D_SELECT_FILTER_NOP
Definition: ED_view3d.h:524
@ VIEW3D_SELECT_FILTER_OBJECT_MODE_LOCK
Definition: ED_view3d.h:526
@ VIEW3D_SELECT_FILTER_WPAINT_POSE_MODE_LOCK
Definition: ED_view3d.h:528
void GPU_matrix_ortho_set(float left, float right, float bottom, float top, float near, float far)
Definition: gpu_matrix.cc:415
void GPU_matrix_frustum_set(float left, float right, float bottom, float top, float near, float far)
Definition: gpu_matrix.cc:438
#define GPU_matrix_projection_get(x)
Definition: GPU_matrix.h:227
uint GPU_select_buffer_remove_by_id(uint *buffer, int hits, uint select_id)
Definition: gpu_select.c:215
void GPU_select_cache_begin(void)
Definition: gpu_select.c:159
bool GPU_select_is_cached(void)
Definition: gpu_select.c:185
void GPU_select_cache_load_id(void)
Definition: gpu_select.c:169
void GPU_select_cache_end(void)
Definition: gpu_select.c:177
@ GPU_SELECT_NEAREST_SECOND_PASS
Definition: GPU_select.h:39
@ GPU_SELECT_NEAREST_FIRST_PASS
Definition: GPU_select.h:38
@ GPU_SELECT_PICK_ALL
Definition: GPU_select.h:41
@ GPU_SELECT_ALL
Definition: GPU_select.h:36
@ GPU_SELECT_PICK_NEAREST
Definition: GPU_select.h:42
unsigned int GPU_select_end(void)
Definition: gpu_select.c:131
void GPU_select_begin(unsigned int *buffer, unsigned int bufsize, const struct rcti *input, char mode, int oldhits)
@ GPU_DEPTH_LESS_EQUAL
Definition: GPU_state.h:81
@ GPU_DEPTH_NONE
Definition: GPU_state.h:78
void GPU_depth_test(eGPUDepthTest test)
Definition: gpu_state.cc:75
Read Guarded memory(de)allocation.
#define C
Definition: RandGen.cpp:39
void UI_Theme_Restore(struct bThemeState *theme_state)
Definition: resources.c:1098
void UI_SetTheme(int spacetype, int regionid)
Definition: resources.c:1064
void UI_Theme_Store(struct bThemeState *theme_state)
Definition: resources.c:1094
#define ND_DRAW
Definition: WM_types.h:362
#define ND_OB_ACTIVE
Definition: WM_types.h:340
@ OPTYPE_INTERNAL
Definition: WM_types.h:175
@ OPTYPE_UNDO
Definition: WM_types.h:155
@ OPTYPE_REGISTER
Definition: WM_types.h:153
#define ND_OB_SELECT
Definition: WM_types.h:342
#define NC_SCENE
Definition: WM_types.h:279
#define ND_TRANSFORM
Definition: WM_types.h:357
#define ND_SPACE_VIEW3D
Definition: WM_types.h:423
#define NC_OBJECT
Definition: WM_types.h:280
#define NC_SPACE
Definition: WM_types.h:293
static DBVT_INLINE btScalar size(const btDbvtVolume &a)
Definition: btDbvt.cpp:52
unsigned int U
Definition: btGjkEpa3.h:78
void reset()
clear internal cached data and reset random seed
EvaluationStage stage
Definition: deg_eval.cc:96
Scene scene
const Depsgraph * depsgraph
void * user_data
#define fabsf(x)
__kernel void ccl_constant KernelData ccl_global void ccl_global char ccl_global int ccl_global char ccl_global unsigned int ccl_global float * buffer
void(* MEM_freeN)(void *vmemh)
Definition: mallocn.c:41
void *(* MEM_mallocN)(size_t len, const char *str)
Definition: mallocn.c:47
static void area(int d1, int d2, int e1, int e2, float weights[2])
bool RNA_boolean_get(PointerRNA *ptr, const char *name)
Definition: rna_access.c:6261
PropertyRNA * RNA_def_boolean(StructOrFunctionRNA *cont_, const char *identifier, bool default_value, const char *ui_name, const char *ui_description)
Definition: rna_define.c:3481
#define min(a, b)
Definition: sort.c:51
void * regiondata
struct ARegion * next
short regiontype
struct Base * next
struct Object * object
unsigned short local_view_bits
struct GpencilModifierData * next
void * next
Definition: DNA_ID.h:274
ListBase layer_collections
unsigned short local_collections_bits
void * first
Definition: DNA_listBase.h:47
Definition: BKE_main.h:116
ListBase scenes
Definition: BKE_main.h:146
ListBase screens
Definition: BKE_main.h:161
struct ModifierData * next
struct bPose * pose
float obmat[4][4]
float quat[4]
short protectflag
void * data
struct RenderEngine * render_engine
struct SmoothView3DStore * sms
float viewquat[4]
struct RegionView3D * localvd
float viewmat[4][4]
struct wmTimer * smooth_timer
float winmat[4][4]
struct ToolSettings * toolsettings
View3DCursor cursor
ListBase view_layers
struct Object * camera
struct SmoothView3DState dst
Definition: view3d_view.c:90
struct SmoothView3DState src
Definition: view3d_view.c:89
float dyn_ofs[3]
Definition: view3d_view.c:96
struct SmoothView3DState org
Definition: view3d_view.c:91
const float * lens
const float * quat
const float * dist
struct Object * camera
struct Object * camera_old
const float * ofs
const float * dyn_ofs
struct IDProperty * prop
unsigned short local_view_uuid
View3D_Runtime runtime
struct Object * camera
struct View3D * localvd
char ob_center_bone[64]
short scenelock
char spacetype
unsigned short local_collections_uuid
short ob_center_cursor
struct Object * ob_center
View3DShading shading
float clip_start
struct Depsgraph * depsgraph
Definition: ED_view3d.h:75
struct Scene * scene
Definition: ED_view3d.h:76
struct ARegion * region
Definition: ED_view3d.h:80
struct ViewLayer * view_layer
Definition: ED_view3d.h:77
struct bContext * C
Definition: ED_view3d.h:69
struct Object * obact
Definition: ED_view3d.h:78
struct Object * obedit
Definition: ED_view3d.h:79
struct wmWindow * win
Definition: ED_view3d.h:82
struct View3D * v3d
Definition: ED_view3d.h:81
struct RegionView3D * rv3d
Definition: ED_view3d.h:83
struct Base * basact
struct View3DShading shading
Definition: DNA_xr_types.h:31
float pose_mat[4][4]
ListBase areabase
float xmax
Definition: DNA_vec_types.h:85
float xmin
Definition: DNA_vec_types.h:85
float ymax
Definition: DNA_vec_types.h:86
float ymin
Definition: DNA_vec_types.h:86
int ymin
Definition: DNA_vec_types.h:80
int ymax
Definition: DNA_vec_types.h:80
int xmin
Definition: DNA_vec_types.h:79
int xmax
Definition: DNA_vec_types.h:79
void * customdata
Definition: WM_types.h:631
int(* invoke)(struct bContext *, struct wmOperator *, const struct wmEvent *) ATTR_WARN_UNUSED_RESULT
Definition: WM_types.h:752
const char * name
Definition: WM_types.h:721
const char * idname
Definition: WM_types.h:723
bool(* poll)(struct bContext *) ATTR_WARN_UNUSED_RESULT
Definition: WM_types.h:776
struct StructRNA * srna
Definition: WM_types.h:802
const char * description
Definition: WM_types.h:726
int(* exec)(struct bContext *, struct wmOperator *) ATTR_WARN_UNUSED_RESULT
Definition: WM_types.h:736
struct ReportList * reports
struct PointerRNA * ptr
double duration
Definition: WM_types.h:705
XrSessionSettings session_settings
float max
#define G(x, y, z)
void view3d_orbit_apply_dyn_ofs(float r_ofs[3], const float ofs_old[3], const float viewquat_old[4], const float viewquat_new[4], const float dyn_ofs[3])
Definition: view3d_edit.c:286
void view3d_boxview_copy(struct ScrArea *area, struct ARegion *region)
Definition: view3d_utils.c:914
static void local_collections_reset_uuid(LayerCollection *layer_collection, const ushort local_view_bit)
Definition: view3d_view.c:1606
static bool view3d_localview_init(const Depsgraph *depsgraph, wmWindowManager *wm, wmWindow *win, Main *bmain, ViewLayer *view_layer, ScrArea *area, const bool frame_selected, const int smooth_viewtx, ReportList *reports)
Definition: view3d_view.c:1245
void view3d_opengl_select_cache_end(void)
Definition: view3d_view.c:897
static int localview_remove_from_exec(bContext *C, wmOperator *op)
Definition: view3d_view.c:1506
void ED_view3d_local_collections_reset(struct bContext *C, const bool reset_all)
Definition: view3d_view.c:1661
void VIEW3D_OT_localview(wmOperatorType *ot)
Definition: view3d_view.c:1486
static void view3d_local_collections_reset(Main *bmain, const uint local_view_bit)
Definition: view3d_view.c:1621
int view3d_opengl_select(ViewContext *vc, uint *buffer, uint bufsize, const rcti *input, eV3DSelectMode select_mode, eV3DSelectObjectFilter select_filter)
Definition: view3d_view.c:975
static uint free_localview_bit(Main *bmain)
Definition: view3d_view.c:1213
static void obmat_to_viewmat(RegionView3D *rv3d, Object *ob)
Definition: view3d_view.c:773
static int localview_exec(bContext *C, wmOperator *op)
Definition: view3d_view.c:1445
void VIEW3D_OT_localview_remove_from(wmOperatorType *ot)
Definition: view3d_view.c:1548
static void view3d_localview_exit(const Depsgraph *depsgraph, wmWindowManager *wm, wmWindow *win, ViewLayer *view_layer, ScrArea *area, const bool frame_selected, const int smooth_viewtx)
Definition: view3d_view.c:1376
void VIEW3D_OT_camera_to_view_selected(wmOperatorType *ot)
Definition: view3d_view.c:555
static void view3d_smooth_view_state_backup(struct SmoothView3DState *sms_state, const View3D *v3d, const RegionView3D *rv3d)
Definition: view3d_view.c:105
static int view3d_camera_to_view_selected_exec(bContext *C, wmOperator *op)
Definition: view3d_view.c:535
static bool drw_select_loop_pass(eDRWSelectStage stage, void *user_data)
Definition: view3d_view.c:911
static bool drw_select_filter_object_mode_lock(Object *ob, void *user_data)
Definition: view3d_view.c:952
static int view3d_camera_to_view_exec(bContext *C, wmOperator *UNUSED(op))
Definition: view3d_view.c:465
void view3d_winmatrix_set(Depsgraph *depsgraph, ARegion *region, const View3D *v3d, const rcti *rect)
Definition: view3d_view.c:716
static bool drw_select_filter_object_mode_lock_for_weight_paint(Object *ob, void *user_data)
Definition: view3d_view.c:962
static void sync_viewport_camera_smoothview(bContext *C, View3D *v3d, Object *ob, const int smooth_viewtx)
Definition: view3d_view.c:576
static uint free_localcollection_bit(Main *bmain, ushort local_collections_uuid, bool *r_reset)
Definition: view3d_view.c:1568
void view3d_viewmatrix_set(Depsgraph *depsgraph, const Scene *scene, const View3D *v3d, RegionView3D *rv3d, const float rect_scale[2])
Definition: view3d_view.c:798
eV3DSelectObjectFilter ED_view3d_select_filter_from_mode(const Scene *scene, const Object *obact)
Definition: view3d_view.c:939
static bool localview_remove_from_poll(bContext *C)
Definition: view3d_view.c:1538
void ED_view3d_smooth_view_ex(const Depsgraph *depsgraph, wmWindowManager *wm, wmWindow *win, ScrArea *area, View3D *v3d, ARegion *region, const int smooth_viewtx, const V3D_SmoothParams *sview)
Definition: view3d_view.c:127
bool ED_view3d_local_collections_set(Main *bmain, struct View3D *v3d)
Definition: view3d_view.c:1637
void view3d_opengl_select_cache_begin(void)
Definition: view3d_view.c:892
static int view3d_smoothview_invoke(bContext *C, wmOperator *UNUSED(op), const wmEvent *event)
Definition: view3d_view.c:408
int view3d_opengl_select_with_id_filter(ViewContext *vc, uint *buffer, uint bufsize, const rcti *input, eV3DSelectMode select_mode, eV3DSelectObjectFilter select_filter, uint select_id)
Definition: view3d_view.c:1189
void ED_view3d_smooth_view(bContext *C, View3D *v3d, ARegion *region, const int smooth_viewtx, const struct V3D_SmoothParams *sview)
Definition: view3d_view.c:306
void ED_view3d_smooth_view_force_finish(bContext *C, View3D *v3d, ARegion *region)
Definition: view3d_view.c:428
static void view3d_smooth_view_state_restore(const struct SmoothView3DState *sms_state, View3D *v3d, RegionView3D *rv3d)
Definition: view3d_view.c:115
void VIEW3D_OT_camera_to_view(wmOperatorType *ot)
Definition: view3d_view.c:512
static bool view3d_camera_to_view_poll(bContext *C)
Definition: view3d_view.c:493
bool ED_operator_rv3d_user_region_poll(bContext *C)
Definition: view3d_view.c:684
void VIEW3D_OT_smoothview(wmOperatorType *ot)
Definition: view3d_view.c:444
static int view3d_setobjectascamera_exec(bContext *C, wmOperator *op)
Definition: view3d_view.c:632
void VIEW3D_OT_object_as_camera(wmOperatorType *ot)
Definition: view3d_view.c:692
static void view3d_smoothview_apply(bContext *C, View3D *v3d, ARegion *region, bool sync_boxview)
Definition: view3d_view.c:321
void WM_event_add_notifier(const bContext *C, uint type, void *reference)
void WM_event_add_mousemove(wmWindow *win)
@ TIMER1
wmOperatorType * ot
Definition: wm_files.c:3156
int WM_operator_confirm(bContext *C, wmOperator *op, const wmEvent *UNUSED(event))
int WM_operator_smooth_viewtx_get(const wmOperator *op)
Definition: wm_operators.c:944
void WM_event_remove_timer(wmWindowManager *wm, wmWindow *UNUSED(win), wmTimer *timer)
Definition: wm_window.c:1669
wmTimer * WM_event_add_timer(wmWindowManager *wm, wmWindow *win, int event_type, double timestep)
Definition: wm_window.c:1632
bool WM_xr_session_is_ready(const wmXrData *xr)
bool WM_xr_session_exists(const wmXrData *xr)
Definition: wm_xr_session.c:99