Blender  V2.93
view3d_draw.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 <math.h>
25 
26 #include "BLI_jitter_2d.h"
27 #include "BLI_listbase.h"
28 #include "BLI_math.h"
29 #include "BLI_rect.h"
30 #include "BLI_string.h"
31 #include "BLI_string_utils.h"
32 #include "BLI_threads.h"
33 
34 #include "BKE_armature.h"
35 #include "BKE_camera.h"
36 #include "BKE_collection.h"
37 #include "BKE_context.h"
38 #include "BKE_customdata.h"
39 #include "BKE_global.h"
40 #include "BKE_image.h"
41 #include "BKE_key.h"
42 #include "BKE_layer.h"
43 #include "BKE_main.h"
44 #include "BKE_object.h"
45 #include "BKE_paint.h"
46 #include "BKE_scene.h"
47 #include "BKE_studiolight.h"
48 #include "BKE_unit.h"
49 
50 #include "BLF_api.h"
51 
52 #include "BLT_translation.h"
53 
54 #include "DNA_armature_types.h"
55 #include "DNA_brush_types.h"
56 #include "DNA_camera_types.h"
57 #include "DNA_key_types.h"
58 #include "DNA_mesh_types.h"
59 #include "DNA_object_types.h"
60 #include "DNA_view3d_types.h"
62 
63 #include "DRW_engine.h"
64 #include "DRW_select_buffer.h"
65 
66 #include "ED_gpencil.h"
67 #include "ED_info.h"
68 #include "ED_keyframing.h"
69 #include "ED_screen.h"
70 #include "ED_screen_types.h"
71 #include "ED_transform.h"
72 #include "ED_view3d_offscreen.h"
73 
74 #include "DEG_depsgraph_query.h"
75 
76 #include "GPU_batch.h"
77 #include "GPU_batch_presets.h"
78 #include "GPU_framebuffer.h"
79 #include "GPU_immediate.h"
80 #include "GPU_immediate_util.h"
81 #include "GPU_material.h"
82 #include "GPU_matrix.h"
83 #include "GPU_state.h"
84 #include "GPU_viewport.h"
85 
86 #include "MEM_guardedalloc.h"
87 
88 #include "UI_interface.h"
89 #include "UI_resources.h"
90 
91 #include "RE_engine.h"
92 
93 #include "WM_api.h"
94 #include "WM_types.h"
95 
96 #include "RNA_access.h"
97 
98 #include "IMB_imbuf.h"
99 #include "IMB_imbuf_types.h"
100 
101 #include "view3d_intern.h" /* own include */
102 
103 #define M_GOLDEN_RATIO_CONJUGATE 0.618033988749895f
104 
105 #define VIEW3D_OVERLAY_LINEHEIGHT (0.9f * U.widget_unit)
106 
107 /* -------------------------------------------------------------------- */
115  const Scene *scene,
116  View3D *v3d,
117  ARegion *region,
118  const float viewmat[4][4],
119  const float winmat[4][4],
120  const rcti *rect,
121  bool offscreen)
122 {
123  RegionView3D *rv3d = region->regiondata;
124 
125  /* setup window matrices */
126  if (winmat) {
127  copy_m4_m4(rv3d->winmat, winmat);
128  }
129  else {
130  view3d_winmatrix_set(depsgraph, region, v3d, rect);
131  }
132 
133  /* setup view matrix */
134  if (viewmat) {
135  copy_m4_m4(rv3d->viewmat, viewmat);
136  }
137  else {
138  float rect_scale[2];
139  if (rect) {
140  rect_scale[0] = (float)BLI_rcti_size_x(rect) / (float)region->winx;
141  rect_scale[1] = (float)BLI_rcti_size_y(rect) / (float)region->winy;
142  }
143  /* note: calls BKE_object_where_is_calc for camera... */
144  view3d_viewmatrix_set(depsgraph, scene, v3d, rv3d, rect ? rect_scale : NULL);
145  }
146  /* update utility matrices */
147  mul_m4_m4m4(rv3d->persmat, rv3d->winmat, rv3d->viewmat);
148  invert_m4_m4(rv3d->persinv, rv3d->persmat);
149  invert_m4_m4(rv3d->viewinv, rv3d->viewmat);
150 
151  /* calculate GLSL view dependent values */
152 
153  /* store window coordinates scaling/offset */
154  if (!offscreen && rv3d->persp == RV3D_CAMOB && v3d->camera) {
155  rctf cameraborder;
156  ED_view3d_calc_camera_border(scene, depsgraph, region, v3d, rv3d, &cameraborder, false);
157  rv3d->viewcamtexcofac[0] = (float)region->winx / BLI_rctf_size_x(&cameraborder);
158  rv3d->viewcamtexcofac[1] = (float)region->winy / BLI_rctf_size_y(&cameraborder);
159 
160  rv3d->viewcamtexcofac[2] = -rv3d->viewcamtexcofac[0] * cameraborder.xmin / (float)region->winx;
161  rv3d->viewcamtexcofac[3] = -rv3d->viewcamtexcofac[1] * cameraborder.ymin / (float)region->winy;
162  }
163  else {
164  rv3d->viewcamtexcofac[0] = rv3d->viewcamtexcofac[1] = 1.0f;
165  rv3d->viewcamtexcofac[2] = rv3d->viewcamtexcofac[3] = 0.0f;
166  }
167 
168  /* Calculate pixel-size factor once, this is used for lights and object-centers. */
169  {
170  /* note: '1.0f / len_v3(v1)' replaced 'len_v3(rv3d->viewmat[0])'
171  * because of float point precision problems at large values T23908. */
172  float v1[3], v2[3];
173  float len_px, len_sc;
174 
175  v1[0] = rv3d->persmat[0][0];
176  v1[1] = rv3d->persmat[1][0];
177  v1[2] = rv3d->persmat[2][0];
178 
179  v2[0] = rv3d->persmat[0][1];
180  v2[1] = rv3d->persmat[1][1];
181  v2[2] = rv3d->persmat[2][1];
182 
183  len_px = 2.0f / sqrtf(min_ff(len_squared_v3(v1), len_squared_v3(v2)));
184 
185  if (rect) {
186  len_sc = (float)max_ii(BLI_rcti_size_x(rect), BLI_rcti_size_y(rect));
187  }
188  else {
189  len_sc = (float)MAX2(region->winx, region->winy);
190  }
191 
192  rv3d->pixsize = len_px / len_sc;
193  }
194 }
195 
197  Scene *scene,
198  View3D *v3d,
199  ARegion *region,
200  const float viewmat[4][4],
201  const float winmat[4][4],
202  const rcti *rect)
203 {
204  RegionView3D *rv3d = region->regiondata;
205 
206  ED_view3d_update_viewmat(depsgraph, scene, v3d, region, viewmat, winmat, rect, false);
207 
208  /* set for opengl */
210  GPU_matrix_set(rv3d->viewmat);
211 }
212 
214  const Scene *scene,
215  View3D *v3d,
216  ARegion *region,
217  const float viewmat[4][4],
218  const float winmat[4][4])
219 {
220  RegionView3D *rv3d = region->regiondata;
221  ED_view3d_update_viewmat(depsgraph, scene, v3d, region, viewmat, winmat, NULL, true);
222 
223  /* set for opengl */
225  GPU_matrix_set(rv3d->viewmat);
226 }
227 
229  const Scene *scene,
230  View3D *v3d,
231  RegionView3D *rv3d)
232 {
233  if ((scene->r.scemode & R_MULTIVIEW) == 0) {
234  return false;
235  }
236 
237  if ((v3d->camera == NULL) || (v3d->camera->type != OB_CAMERA) || rv3d->persp != RV3D_CAMOB) {
238  return false;
239  }
240 
241  switch (v3d->stereo3d_camera) {
242  case STEREO_MONO_ID:
243  return false;
244  break;
245  case STEREO_3D_ID:
246  /* win will be NULL when calling this from the selection or draw loop. */
247  if ((win == NULL) || (WM_stereo3d_enabled(win, true) == false)) {
248  return false;
249  }
252  return false;
253  }
254  break;
255  /* We always need the stereo calculation for left and right cameras. */
256  case STEREO_LEFT_ID:
257  case STEREO_RIGHT_ID:
258  default:
259  break;
260  }
261  return true;
262 }
263 
264 /* setup the view and win matrices for the multiview cameras
265  *
266  * unlike view3d_stereo3d_setup_offscreen, when view3d_stereo3d_setup is called
267  * we have no winmatrix (i.e., projection matrix) defined at that time.
268  * Since the camera and the camera shift are needed for the winmat calculation
269  * we do a small hack to replace it temporarily so we don't need to change the
270  * view3d)main_region_setup_view() code to account for that.
271  */
273  Depsgraph *depsgraph, Scene *scene, View3D *v3d, ARegion *region, const rcti *rect)
274 {
275  bool is_left;
276  const char *names[2] = {STEREO_LEFT_NAME, STEREO_RIGHT_NAME};
277  const char *viewname;
278 
279  /* show only left or right camera */
280  if (v3d->stereo3d_camera != STEREO_3D_ID) {
281  v3d->multiview_eye = v3d->stereo3d_camera;
282  }
283 
286 
287  /* update the viewport matrices with the new camera */
289  Camera *data, *data_eval;
290  float viewmat[4][4];
291  float shiftx;
292 
293  data = (Camera *)v3d->camera->data;
294  data_eval = (Camera *)DEG_get_evaluated_id(depsgraph, &data->id);
295 
296  shiftx = data_eval->shiftx;
297 
299  data_eval->shiftx = BKE_camera_multiview_shift_x(&scene->r, v3d->camera, viewname);
300 
302  view3d_main_region_setup_view(depsgraph, scene, v3d, region, viewmat, NULL, rect);
303 
304  data_eval->shiftx = shiftx;
306  }
307  else { /* SCE_VIEWS_FORMAT_MULTIVIEW */
308  float viewmat[4][4];
309  Object *view_ob = v3d->camera;
310  Object *camera = BKE_camera_multiview_render(scene, v3d->camera, viewname);
311 
313  v3d->camera = camera;
314 
315  BKE_camera_multiview_view_matrix(&scene->r, camera, false, viewmat);
316  view3d_main_region_setup_view(depsgraph, scene, v3d, region, viewmat, NULL, rect);
317 
318  v3d->camera = view_ob;
320  }
321 }
322 
323 #ifdef WITH_XR_OPENXR
324 static void view3d_xr_mirror_setup(const wmWindowManager *wm,
326  Scene *scene,
327  View3D *v3d,
328  ARegion *region,
329  const rcti *rect)
330 {
331  RegionView3D *rv3d = region->regiondata;
332  float viewmat[4][4];
333  const float lens_old = v3d->lens;
334 
335  if (!WM_xr_session_state_viewer_pose_matrix_info_get(&wm->xr, viewmat, &v3d->lens)) {
336  /* Can't get info from XR session, use fallback values. */
337  copy_m4_m4(viewmat, rv3d->viewmat);
338  v3d->lens = lens_old;
339  }
340  view3d_main_region_setup_view(depsgraph, scene, v3d, region, viewmat, NULL, rect);
341 
342  /* Reset overridden View3D data */
343  v3d->lens = lens_old;
344 }
345 #endif /* WITH_XR_OPENXR */
346 
351  wmWindow *win,
353  Scene *scene,
354  ARegion *region,
355  View3D *v3d,
356  const float viewmat[4][4],
357  const float winmat[4][4],
358  const rcti *rect)
359 {
360  RegionView3D *rv3d = region->regiondata;
361 
362 #ifdef WITH_XR_OPENXR
363  /* Setup the view matrix. */
364  if (ED_view3d_is_region_xr_mirror_active(wm, v3d, region)) {
365  view3d_xr_mirror_setup(wm, depsgraph, scene, v3d, region, rect);
366  }
367  else
368 #endif
369  if (view3d_stereo3d_active(win, scene, v3d, rv3d)) {
370  view3d_stereo3d_setup(depsgraph, scene, v3d, region, rect);
371  }
372  else {
373  view3d_main_region_setup_view(depsgraph, scene, v3d, region, viewmat, winmat, rect);
374  }
375 
376 #ifndef WITH_XR_OPENXR
377  UNUSED_VARS(wm);
378 #endif
379 }
380 
383 /* -------------------------------------------------------------------- */
387 static void view3d_camera_border(const Scene *scene,
388  struct Depsgraph *depsgraph,
389  const ARegion *region,
390  const View3D *v3d,
391  const RegionView3D *rv3d,
392  rctf *r_viewborder,
393  const bool no_shift,
394  const bool no_zoom)
395 {
397  rctf rect_view, rect_camera;
398  Object *camera_eval = DEG_get_evaluated_object(depsgraph, v3d->camera);
399 
400  /* get viewport viewplane */
403  if (no_zoom) {
404  params.zoom = 1.0f;
405  }
406  BKE_camera_params_compute_viewplane(&params, region->winx, region->winy, 1.0f, 1.0f);
407  rect_view = params.viewplane;
408 
409  /* get camera viewplane */
411  /* fallback for non camera objects */
412  params.clip_start = v3d->clip_start;
413  params.clip_end = v3d->clip_end;
414  BKE_camera_params_from_object(&params, camera_eval);
415  if (no_shift) {
416  params.shiftx = 0.0f;
417  params.shifty = 0.0f;
418  }
421  rect_camera = params.viewplane;
422 
423  /* get camera border within viewport */
424  r_viewborder->xmin = ((rect_camera.xmin - rect_view.xmin) / BLI_rctf_size_x(&rect_view)) *
425  region->winx;
426  r_viewborder->xmax = ((rect_camera.xmax - rect_view.xmin) / BLI_rctf_size_x(&rect_view)) *
427  region->winx;
428  r_viewborder->ymin = ((rect_camera.ymin - rect_view.ymin) / BLI_rctf_size_y(&rect_view)) *
429  region->winy;
430  r_viewborder->ymax = ((rect_camera.ymax - rect_view.ymin) / BLI_rctf_size_y(&rect_view)) *
431  region->winy;
432 }
433 
436  const ARegion *region,
437  const View3D *v3d,
438  const RegionView3D *rv3d,
439  float r_size[2])
440 {
441  rctf viewborder;
442 
443  view3d_camera_border(scene, depsgraph, region, v3d, rv3d, &viewborder, true, true);
444  r_size[0] = BLI_rctf_size_x(&viewborder);
445  r_size[1] = BLI_rctf_size_y(&viewborder);
446 }
447 
450  const ARegion *region,
451  const View3D *v3d,
452  const RegionView3D *rv3d,
453  rctf *r_viewborder,
454  const bool no_shift)
455 {
456  view3d_camera_border(scene, depsgraph, region, v3d, rv3d, r_viewborder, no_shift, false);
457 }
458 
459 static void drawviewborder_grid3(uint shdr_pos, float x1, float x2, float y1, float y2, float fac)
460 {
461  float x3, y3, x4, y4;
462 
463  x3 = x1 + fac * (x2 - x1);
464  y3 = y1 + fac * (y2 - y1);
465  x4 = x1 + (1.0f - fac) * (x2 - x1);
466  y4 = y1 + (1.0f - fac) * (y2 - y1);
467 
469 
470  immVertex2f(shdr_pos, x1, y3);
471  immVertex2f(shdr_pos, x2, y3);
472 
473  immVertex2f(shdr_pos, x1, y4);
474  immVertex2f(shdr_pos, x2, y4);
475 
476  immVertex2f(shdr_pos, x3, y1);
477  immVertex2f(shdr_pos, x3, y2);
478 
479  immVertex2f(shdr_pos, x4, y1);
480  immVertex2f(shdr_pos, x4, y2);
481 
482  immEnd();
483 }
484 
485 /* harmonious triangle */
487  uint shdr_pos, float x1, float x2, float y1, float y2, const char golden, const char dir)
488 {
489  float ofs;
490  float w = x2 - x1;
491  float h = y2 - y1;
492 
494 
495  if (w > h) {
496  if (golden) {
497  ofs = w * (1.0f - M_GOLDEN_RATIO_CONJUGATE);
498  }
499  else {
500  ofs = h * (h / w);
501  }
502  if (dir == 'B') {
503  SWAP(float, y1, y2);
504  }
505 
506  immVertex2f(shdr_pos, x1, y1);
507  immVertex2f(shdr_pos, x2, y2);
508 
509  immVertex2f(shdr_pos, x2, y1);
510  immVertex2f(shdr_pos, x1 + (w - ofs), y2);
511 
512  immVertex2f(shdr_pos, x1, y2);
513  immVertex2f(shdr_pos, x1 + ofs, y1);
514  }
515  else {
516  if (golden) {
517  ofs = h * (1.0f - M_GOLDEN_RATIO_CONJUGATE);
518  }
519  else {
520  ofs = w * (w / h);
521  }
522  if (dir == 'B') {
523  SWAP(float, x1, x2);
524  }
525 
526  immVertex2f(shdr_pos, x1, y1);
527  immVertex2f(shdr_pos, x2, y2);
528 
529  immVertex2f(shdr_pos, x2, y1);
530  immVertex2f(shdr_pos, x1, y1 + ofs);
531 
532  immVertex2f(shdr_pos, x1, y2);
533  immVertex2f(shdr_pos, x2, y1 + (h - ofs));
534  }
535 
536  immEnd();
537 }
538 
540 {
541  float x1, x2, y1, y2;
542  float x1i, x2i, y1i, y2i;
543 
544  rctf viewborder;
545  Camera *ca = NULL;
546  RegionView3D *rv3d = region->regiondata;
547 
548  if (v3d->camera == NULL) {
549  return;
550  }
551  if (v3d->camera->type == OB_CAMERA) {
552  ca = v3d->camera->data;
553  }
554 
555  ED_view3d_calc_camera_border(scene, depsgraph, region, v3d, rv3d, &viewborder, false);
556  /* the offsets */
557  x1 = viewborder.xmin;
558  y1 = viewborder.ymin;
559  x2 = viewborder.xmax;
560  y2 = viewborder.ymax;
561 
562  GPU_line_width(1.0f);
563 
564  /* apply offsets so the real 3D camera shows through */
565 
566  /* note: quite un-scientific but without this bit extra
567  * 0.0001 on the lower left the 2D border sometimes
568  * obscures the 3D camera border */
569  /* note: with VIEW3D_CAMERA_BORDER_HACK defined this error isn't noticeable
570  * but keep it here in case we need to remove the workaround */
571  x1i = (int)(x1 - 1.0001f);
572  y1i = (int)(y1 - 1.0001f);
573  x2i = (int)(x2 + (1.0f - 0.0001f));
574  y2i = (int)(y2 + (1.0f - 0.0001f));
575 
576  uint shdr_pos = GPU_vertformat_attr_add(
578 
579  /* First, solid lines. */
580  {
582 
583  /* passepartout, specified in camera edit buttons */
584  if (ca && (ca->flag & CAM_SHOWPASSEPARTOUT) && ca->passepartalpha > 0.000001f) {
585  const float winx = (region->winx + 1);
586  const float winy = (region->winy + 1);
587 
588  float alpha = 1.0f;
589 
590  if (ca->passepartalpha != 1.0f) {
592  alpha = ca->passepartalpha;
593  }
594 
595  immUniformColor4f(0.0f, 0.0f, 0.0f, alpha);
596 
597  if (x1i > 0.0f) {
598  immRectf(shdr_pos, 0.0f, winy, x1i, 0.0f);
599  }
600  if (x2i < winx) {
601  immRectf(shdr_pos, x2i, winy, winx, 0.0f);
602  }
603  if (y2i < winy) {
604  immRectf(shdr_pos, x1i, winy, x2i, y2i);
605  }
606  if (y2i > 0.0f) {
607  immRectf(shdr_pos, x1i, y1i, x2i, 0.0f);
608  }
609 
611  }
612 
614  imm_draw_box_wire_2d(shdr_pos, x1i, y1i, x2i, y2i);
615 
616 #ifdef VIEW3D_CAMERA_BORDER_HACK
617  if (view3d_camera_border_hack_test == true) {
619  imm_draw_box_wire_2d(shdr_pos, x1i + 1, y1i + 1, x2i - 1, y2i - 1);
621  }
622 #endif
623 
625  }
626 
627  /* When overlays are disabled, only show camera outline & passepartout. */
628  if (v3d->flag2 & V3D_HIDE_OVERLAYS) {
629  return;
630  }
631 
632  /* And now, the dashed lines! */
634 
635  {
636  float viewport_size[4];
637  GPU_viewport_size_get_f(viewport_size);
638  immUniform2f("viewport_size", viewport_size[2], viewport_size[3]);
639 
640  immUniform1i("colors_len", 0); /* "simple" mode */
641  immUniform1f("dash_width", 6.0f);
642  immUniform1f("dash_factor", 0.5f);
643 
644  /* outer line not to confuse with object selection */
645  if (v3d->flag2 & V3D_LOCK_CAMERA) {
647  imm_draw_box_wire_2d(shdr_pos, x1i - 1, y1i - 1, x2i + 1, y2i + 1);
648  }
649 
651  imm_draw_box_wire_2d(shdr_pos, x1i, y1i, x2i, y2i);
652  }
653 
654  /* Render Border. */
655  if (scene->r.mode & R_BORDER) {
656  float x3, y3, x4, y4;
657 
658  x3 = floorf(x1 + (scene->r.border.xmin * (x2 - x1))) - 1;
659  y3 = floorf(y1 + (scene->r.border.ymin * (y2 - y1))) - 1;
660  x4 = floorf(x1 + (scene->r.border.xmax * (x2 - x1))) + (U.pixelsize - 1);
661  y4 = floorf(y1 + (scene->r.border.ymax * (y2 - y1))) + (U.pixelsize - 1);
662 
663  immUniformColor3f(1.0f, 0.25f, 0.25f);
664  imm_draw_box_wire_2d(shdr_pos, x3, y3, x4, y4);
665  }
666 
667  /* safety border */
668  if (ca) {
671 
672  if (ca->dtx & CAM_DTX_CENTER) {
673  float x3, y3;
674 
675  x3 = x1 + 0.5f * (x2 - x1);
676  y3 = y1 + 0.5f * (y2 - y1);
677 
679 
680  immVertex2f(shdr_pos, x1, y3);
681  immVertex2f(shdr_pos, x2, y3);
682 
683  immVertex2f(shdr_pos, x3, y1);
684  immVertex2f(shdr_pos, x3, y2);
685 
686  immEnd();
687  }
688 
689  if (ca->dtx & CAM_DTX_CENTER_DIAG) {
691 
692  immVertex2f(shdr_pos, x1, y1);
693  immVertex2f(shdr_pos, x2, y2);
694 
695  immVertex2f(shdr_pos, x1, y2);
696  immVertex2f(shdr_pos, x2, y1);
697 
698  immEnd();
699  }
700 
701  if (ca->dtx & CAM_DTX_THIRDS) {
702  drawviewborder_grid3(shdr_pos, x1, x2, y1, y2, 1.0f / 3.0f);
703  }
704 
705  if (ca->dtx & CAM_DTX_GOLDEN) {
706  drawviewborder_grid3(shdr_pos, x1, x2, y1, y2, 1.0f - M_GOLDEN_RATIO_CONJUGATE);
707  }
708 
709  if (ca->dtx & CAM_DTX_GOLDEN_TRI_A) {
710  drawviewborder_triangle(shdr_pos, x1, x2, y1, y2, 0, 'A');
711  }
712 
713  if (ca->dtx & CAM_DTX_GOLDEN_TRI_B) {
714  drawviewborder_triangle(shdr_pos, x1, x2, y1, y2, 0, 'B');
715  }
716 
717  if (ca->dtx & CAM_DTX_HARMONY_TRI_A) {
718  drawviewborder_triangle(shdr_pos, x1, x2, y1, y2, 1, 'A');
719  }
720 
721  if (ca->dtx & CAM_DTX_HARMONY_TRI_B) {
722  drawviewborder_triangle(shdr_pos, x1, x2, y1, y2, 1, 'B');
723  }
724 
725  if (ca->flag & CAM_SHOW_SAFE_MARGINS) {
726  UI_draw_safe_areas(shdr_pos,
727  &(const rctf){
728  .xmin = x1,
729  .xmax = x2,
730  .ymin = y1,
731  .ymax = y2,
732  },
735 
736  if (ca->flag & CAM_SHOW_SAFE_CENTER) {
737  UI_draw_safe_areas(shdr_pos,
738  &(const rctf){
739  .xmin = x1,
740  .xmax = x2,
741  .ymin = y1,
742  .ymax = y2,
743  },
746  }
747  }
748 
749  if (ca->flag & CAM_SHOWSENSOR) {
750  /* determine sensor fit, and get sensor x/y, for auto fit we
751  * assume and square sensor and only use sensor_x */
752  float sizex = scene->r.xsch * scene->r.xasp;
753  float sizey = scene->r.ysch * scene->r.yasp;
754  int sensor_fit = BKE_camera_sensor_fit(ca->sensor_fit, sizex, sizey);
755  float sensor_x = ca->sensor_x;
756  float sensor_y = (ca->sensor_fit == CAMERA_SENSOR_FIT_AUTO) ? ca->sensor_x : ca->sensor_y;
757 
758  /* determine sensor plane */
759  rctf rect;
760 
761  if (sensor_fit == CAMERA_SENSOR_FIT_HOR) {
762  float sensor_scale = (x2i - x1i) / sensor_x;
763  float sensor_height = sensor_scale * sensor_y;
764 
765  rect.xmin = x1i;
766  rect.xmax = x2i;
767  rect.ymin = (y1i + y2i) * 0.5f - sensor_height * 0.5f;
768  rect.ymax = rect.ymin + sensor_height;
769  }
770  else {
771  float sensor_scale = (y2i - y1i) / sensor_y;
772  float sensor_width = sensor_scale * sensor_x;
773 
774  rect.xmin = (x1i + x2i) * 0.5f - sensor_width * 0.5f;
775  rect.xmax = rect.xmin + sensor_width;
776  rect.ymin = y1i;
777  rect.ymax = y2i;
778  }
779 
780  /* draw */
782 
783  /* TODO Was using:
784  * UI_draw_roundbox_4fv(false, rect.xmin, rect.ymin, rect.xmax, rect.ymax, 2.0f, color);
785  * We'll probably need a new imm_draw_line_roundbox_dashed dor that - though in practice the
786  * 2.0f round corner effect was nearly not visible anyway... */
787  imm_draw_box_wire_2d(shdr_pos, rect.xmin, rect.ymin, rect.xmax, rect.ymax);
788  }
789 
791  }
792 
794  /* end dashed lines */
795 
796  /* camera name - draw in highlighted text color */
797  if (ca && ((v3d->overlay.flag & V3D_OVERLAY_HIDE_TEXT) == 0) && (ca->flag & CAM_SHOWNAME)) {
799  BLF_draw_default(x1i,
800  y1i - (0.7f * U.widget_unit),
801  0.0f,
802  v3d->camera->id.name + 2,
803  sizeof(v3d->camera->id.name) - 2);
804  }
805 }
806 
807 static void drawrenderborder(ARegion *region, View3D *v3d)
808 {
809  /* use the same program for everything */
810  uint shdr_pos = GPU_vertformat_attr_add(
812 
813  GPU_line_width(1.0f);
814 
816 
817  float viewport_size[4];
818  GPU_viewport_size_get_f(viewport_size);
819  immUniform2f("viewport_size", viewport_size[2], viewport_size[3]);
820 
821  immUniform1i("colors_len", 0); /* "simple" mode */
822  immUniform4f("color", 1.0f, 0.25f, 0.25f, 1.0f);
823  immUniform1f("dash_width", 6.0f);
824  immUniform1f("dash_factor", 0.5f);
825 
826  imm_draw_box_wire_2d(shdr_pos,
827  v3d->render_border.xmin * region->winx,
828  v3d->render_border.ymin * region->winy,
829  v3d->render_border.xmax * region->winx,
830  v3d->render_border.ymax * region->winy);
831 
833 }
834 
837 /* -------------------------------------------------------------------- */
842 float ED_scene_grid_scale(const Scene *scene, const char **r_grid_unit)
843 {
844  /* apply units */
845  if (scene->unit.system) {
846  const void *usys;
847  int len;
848 
850 
851  if (usys) {
852  int i = BKE_unit_base_get(usys);
853  if (r_grid_unit) {
854  *r_grid_unit = BKE_unit_display_name_get(usys, i);
855  }
856  return (float)BKE_unit_scalar_get(usys, i) / scene->unit.scale_length;
857  }
858  }
859 
860  return 1.0f;
861 }
862 
863 float ED_view3d_grid_scale(const Scene *scene, View3D *v3d, const char **r_grid_unit)
864 {
865  return v3d->grid * ED_scene_grid_scale(scene, r_grid_unit);
866 }
867 
868 #define STEPS_LEN 8
870  View3D *v3d,
871  RegionView3D *rv3d,
872  float r_grid_steps[STEPS_LEN])
873 {
874  const void *usys;
875  int len;
877  float grid_scale = v3d->grid;
879 
880  if (usys) {
881  if (rv3d->view == RV3D_VIEW_USER) {
882  /* Skip steps */
883  len = BKE_unit_base_get(usys) + 1;
884  }
885 
886  grid_scale /= scene->unit.scale_length;
887 
888  int i;
889  for (i = 0; i < len; i++) {
890  r_grid_steps[i] = (float)BKE_unit_scalar_get(usys, len - 1 - i) * grid_scale;
891  }
892  for (; i < STEPS_LEN; i++) {
893  /* Fill last slots */
894  r_grid_steps[i] = 10.0f * r_grid_steps[i - 1];
895  }
896  }
897  else {
898  if (rv3d->view != RV3D_VIEW_USER) {
899  /* Allow 3 more subdivisions. */
900  grid_scale /= powf(v3d->gridsubdiv, 3);
901  }
902  int subdiv = 1;
903  for (int i = 0;; i++) {
904  r_grid_steps[i] = grid_scale * subdiv;
905 
906  if (i == STEPS_LEN - 1) {
907  break;
908  }
909  subdiv *= v3d->gridsubdiv;
910  }
911  }
912 }
913 
914 /* Simulates the grid scale that is actually viewed.
915  * The actual code is seen in `object_grid_frag.glsl` (see `grid_res`).
916  * Currently the simulation is only done when RV3D_VIEW_IS_AXIS. */
918  View3D *v3d,
919  ARegion *region,
920  const char **r_grid_unit)
921 {
922  float grid_scale;
923  RegionView3D *rv3d = region->regiondata;
924  if (!rv3d->is_persp && RV3D_VIEW_IS_AXIS(rv3d->view)) {
925  /* Decrease the distance between grid snap points depending on zoom. */
926  float dist = 12.0f / (region->sizex * rv3d->winmat[0][0]);
927  float grid_steps[STEPS_LEN];
928  ED_view3d_grid_steps(scene, v3d, rv3d, grid_steps);
929  /* Skip last item, in case the 'mid_dist' is greater than the largest unit. */
930  int i;
931  for (i = 0; i < ARRAY_SIZE(grid_steps) - 1; i++) {
932  grid_scale = grid_steps[i];
933  if (grid_scale > dist) {
934  break;
935  }
936  }
937 
938  if (r_grid_unit) {
939  const void *usys;
940  int len;
942 
943  if (usys) {
944  *r_grid_unit = BKE_unit_display_name_get(usys, len - i - 1);
945  }
946  }
947  }
948  else {
949  grid_scale = ED_view3d_grid_scale(scene, v3d, r_grid_unit);
950  }
951 
952  return grid_scale;
953 }
954 
955 #undef STEPS_LEN
956 
957 static void draw_view_axis(RegionView3D *rv3d, const rcti *rect)
958 {
959  const float k = U.rvisize * U.pixelsize; /* axis size */
960  /* axis alpha offset (rvibright has range 0-10) */
961  const int bright = -20 * (10 - U.rvibright);
962 
963  /* Axis center in screen coordinates.
964  *
965  * - Unit size offset so small text doesn't draw outside the screen
966  * - Extra X offset because of the panel expander.
967  */
968  const float startx = rect->xmax - (k + UI_UNIT_X * 1.5);
969  const float starty = rect->ymax - (k + UI_UNIT_Y);
970 
971  float axis_pos[3][2];
972  uchar axis_col[3][4];
973 
974  int axis_order[3] = {0, 1, 2};
975  axis_sort_v3(rv3d->viewinv[2], axis_order);
976 
977  for (int axis_i = 0; axis_i < 3; axis_i++) {
978  int i = axis_order[axis_i];
979 
980  /* get position of each axis tip on screen */
981  float vec[3] = {0.0f};
982  vec[i] = 1.0f;
983  mul_qt_v3(rv3d->viewquat, vec);
984  axis_pos[i][0] = startx + vec[0] * k;
985  axis_pos[i][1] = starty + vec[1] * k;
986 
987  /* get color of each axis */
988  UI_GetThemeColorShade3ubv(TH_AXIS_X + i, bright, axis_col[i]); /* rgb */
989  axis_col[i][3] = 255 * hypotf(vec[0], vec[1]); /* alpha */
990  }
991 
992  /* draw axis lines */
993  GPU_line_width(2.0f);
994  GPU_line_smooth(true);
996 
1000 
1003 
1004  for (int axis_i = 0; axis_i < 3; axis_i++) {
1005  int i = axis_order[axis_i];
1006 
1007  immAttr4ubv(col, axis_col[i]);
1008  immVertex2f(pos, startx, starty);
1009  immAttr4ubv(col, axis_col[i]);
1010  immVertex2fv(pos, axis_pos[i]);
1011  }
1012 
1013  immEnd();
1014  immUnbindProgram();
1015  GPU_line_smooth(false);
1016 
1017  /* draw axis names */
1018  for (int axis_i = 0; axis_i < 3; axis_i++) {
1019  int i = axis_order[axis_i];
1020 
1021  const char axis_text[2] = {'x' + i, '\0'};
1022  BLF_color4ubv(BLF_default(), axis_col[i]);
1023  BLF_draw_default_ascii(axis_pos[i][0] + 2, axis_pos[i][1] + 2, 0.0f, axis_text, 1);
1024  }
1025 }
1026 
1027 #ifdef WITH_INPUT_NDOF
1028 /* draw center and axis of rotation for ongoing 3D mouse navigation */
1029 static void draw_rotation_guide(const RegionView3D *rv3d)
1030 {
1031  float o[3]; /* center of rotation */
1032  float end[3]; /* endpoints for drawing */
1033 
1034  uchar color[4] = {0, 108, 255, 255}; /* bright blue so it matches device LEDs */
1035 
1036  negate_v3_v3(o, rv3d->ofs);
1037 
1039  GPU_depth_mask(false); /* don't overwrite zbuf */
1040 
1044 
1046 
1047  if (rv3d->rot_angle != 0.0f) {
1048  /* -- draw rotation axis -- */
1049  float scaled_axis[3];
1050  const float scale = rv3d->dist;
1051  mul_v3_v3fl(scaled_axis, rv3d->rot_axis, scale);
1052 
1054  color[3] = 0; /* more transparent toward the ends */
1055  immAttr4ubv(col, color);
1056  add_v3_v3v3(end, o, scaled_axis);
1057  immVertex3fv(pos, end);
1058 
1059 # if 0
1060  color[3] = 0.2f + fabsf(rv3d->rot_angle); /* modulate opacity with angle */
1061  /* ^^ neat idea, but angle is frame-rate dependent, so it's usually close to 0.2 */
1062 # endif
1063 
1064  color[3] = 127; /* more opaque toward the center */
1065  immAttr4ubv(col, color);
1066  immVertex3fv(pos, o);
1067 
1068  color[3] = 0;
1069  immAttr4ubv(col, color);
1070  sub_v3_v3v3(end, o, scaled_axis);
1071  immVertex3fv(pos, end);
1072  immEnd();
1073 
1074  /* -- draw ring around rotation center -- */
1075  {
1076 # define ROT_AXIS_DETAIL 13
1077 
1078  const float s = 0.05f * scale;
1079  const float step = 2.0f * (float)(M_PI / ROT_AXIS_DETAIL);
1080 
1081  float q[4]; /* rotate ring so it's perpendicular to axis */
1082  const int upright = fabsf(rv3d->rot_axis[2]) >= 0.95f;
1083  if (!upright) {
1084  const float up[3] = {0.0f, 0.0f, 1.0f};
1085  float vis_angle, vis_axis[3];
1086 
1087  cross_v3_v3v3(vis_axis, up, rv3d->rot_axis);
1088  vis_angle = acosf(dot_v3v3(up, rv3d->rot_axis));
1089  axis_angle_to_quat(q, vis_axis, vis_angle);
1090  }
1091 
1092  immBegin(GPU_PRIM_LINE_LOOP, ROT_AXIS_DETAIL);
1093  color[3] = 63; /* somewhat faint */
1094  immAttr4ubv(col, color);
1095  float angle = 0.0f;
1096  for (int i = 0; i < ROT_AXIS_DETAIL; i++, angle += step) {
1097  float p[3] = {s * cosf(angle), s * sinf(angle), 0.0f};
1098 
1099  if (!upright) {
1100  mul_qt_v3(q, p);
1101  }
1102 
1103  add_v3_v3(p, o);
1104  immVertex3fv(pos, p);
1105  }
1106  immEnd();
1107 
1108 # undef ROT_AXIS_DETAIL
1109  }
1110 
1111  color[3] = 255; /* solid dot */
1112  }
1113  else {
1114  color[3] = 127; /* see-through dot */
1115  }
1116 
1117  immUnbindProgram();
1118 
1119  /* -- draw rotation center -- */
1121  GPU_point_size(5.0f);
1123  immAttr4ubv(col, color);
1124  immVertex3fv(pos, o);
1125  immEnd();
1126  immUnbindProgram();
1127 
1129  GPU_depth_mask(true);
1130 }
1131 #endif /* WITH_INPUT_NDOF */
1132 
1136 static void view3d_draw_border(const bContext *C, ARegion *region)
1137 {
1140  RegionView3D *rv3d = region->regiondata;
1141  View3D *v3d = CTX_wm_view3d(C);
1142 
1143  if (rv3d->persp == RV3D_CAMOB) {
1144  drawviewborder(scene, depsgraph, region, v3d);
1145  }
1146  else if (v3d->flag2 & V3D_RENDER_BORDER) {
1147  drawrenderborder(region, v3d);
1148  }
1149 }
1150 
1153 /* -------------------------------------------------------------------- */
1161 {
1162  /* TODO viewport */
1163 }
1164 
1168 static const char *view3d_get_name(View3D *v3d, RegionView3D *rv3d)
1169 {
1170  const char *name = NULL;
1171 
1172  switch (rv3d->view) {
1173  case RV3D_VIEW_FRONT:
1174  if (rv3d->persp == RV3D_ORTHO) {
1175  name = IFACE_("Front Orthographic");
1176  }
1177  else {
1178  name = IFACE_("Front Perspective");
1179  }
1180  break;
1181  case RV3D_VIEW_BACK:
1182  if (rv3d->persp == RV3D_ORTHO) {
1183  name = IFACE_("Back Orthographic");
1184  }
1185  else {
1186  name = IFACE_("Back Perspective");
1187  }
1188  break;
1189  case RV3D_VIEW_TOP:
1190  if (rv3d->persp == RV3D_ORTHO) {
1191  name = IFACE_("Top Orthographic");
1192  }
1193  else {
1194  name = IFACE_("Top Perspective");
1195  }
1196  break;
1197  case RV3D_VIEW_BOTTOM:
1198  if (rv3d->persp == RV3D_ORTHO) {
1199  name = IFACE_("Bottom Orthographic");
1200  }
1201  else {
1202  name = IFACE_("Bottom Perspective");
1203  }
1204  break;
1205  case RV3D_VIEW_RIGHT:
1206  if (rv3d->persp == RV3D_ORTHO) {
1207  name = IFACE_("Right Orthographic");
1208  }
1209  else {
1210  name = IFACE_("Right Perspective");
1211  }
1212  break;
1213  case RV3D_VIEW_LEFT:
1214  if (rv3d->persp == RV3D_ORTHO) {
1215  name = IFACE_("Left Orthographic");
1216  }
1217  else {
1218  name = IFACE_("Left Perspective");
1219  }
1220  break;
1221 
1222  default:
1223  if (rv3d->persp == RV3D_CAMOB) {
1224  if ((v3d->camera) && (v3d->camera->type == OB_CAMERA)) {
1225  Camera *cam;
1226  cam = v3d->camera->data;
1227  if (cam->type == CAM_PERSP) {
1228  name = IFACE_("Camera Perspective");
1229  }
1230  else if (cam->type == CAM_ORTHO) {
1231  name = IFACE_("Camera Orthographic");
1232  }
1233  else {
1234  BLI_assert(cam->type == CAM_PANO);
1235  name = IFACE_("Camera Panoramic");
1236  }
1237  }
1238  else {
1239  name = IFACE_("Object as Camera");
1240  }
1241  }
1242  else {
1243  name = (rv3d->persp == RV3D_ORTHO) ? IFACE_("User Orthographic") :
1244  IFACE_("User Perspective");
1245  }
1246  }
1247 
1248  return name;
1249 }
1250 
1251 static void draw_viewport_name(ARegion *region, View3D *v3d, int xoffset, int *yoffset)
1252 {
1253  RegionView3D *rv3d = region->regiondata;
1254  const char *name = view3d_get_name(v3d, rv3d);
1255  const char *name_array[3] = {name, NULL, NULL};
1256  int name_array_len = 1;
1257  const int font_id = BLF_default();
1258 
1259  /* 6 is the maximum size of the axis roll text. */
1260  /* increase size for unicode languages (Chinese in utf-8...) */
1261 #ifdef WITH_INTERNATIONAL
1262  char tmpstr[96 + 6];
1263 #else
1264  char tmpstr[32 + 6];
1265 #endif
1266 
1267  BLF_enable(font_id, BLF_SHADOW);
1268  BLF_shadow(font_id, 5, (const float[4]){0.0f, 0.0f, 0.0f, 1.0f});
1269  BLF_shadow_offset(font_id, 1, -1);
1270 
1271  if (RV3D_VIEW_IS_AXIS(rv3d->view) && (rv3d->view_axis_roll != RV3D_VIEW_AXIS_ROLL_0)) {
1272  const char *axis_roll;
1273  switch (rv3d->view_axis_roll) {
1275  axis_roll = " 90\xC2\xB0";
1276  break;
1278  axis_roll = " 180\xC2\xB0";
1279  break;
1280  default:
1281  axis_roll = " -90\xC2\xB0";
1282  break;
1283  }
1284  name_array[name_array_len++] = axis_roll;
1285  }
1286 
1287  if (v3d->localvd) {
1288  name_array[name_array_len++] = IFACE_(" (Local)");
1289  }
1290 
1291  if (name_array_len > 1) {
1292  BLI_string_join_array(tmpstr, sizeof(tmpstr), name_array, name_array_len);
1293  name = tmpstr;
1294  }
1295 
1297 
1298  *yoffset -= VIEW3D_OVERLAY_LINEHEIGHT;
1299 
1300  BLF_draw_default(xoffset, *yoffset, 0.0f, name, sizeof(tmpstr));
1301 
1302  BLF_disable(font_id, BLF_SHADOW);
1303 }
1304 
1311  Scene *scene, ViewLayer *view_layer, Object *ob, int xoffset, int *yoffset)
1312 {
1313  const int cfra = CFRA;
1314  const char *msg_pin = " (Pinned)";
1315  const char *msg_sep = " : ";
1316 
1317  const int font_id = BLF_default();
1318 
1319  char info[300];
1320  char *s = info;
1321 
1322  s += sprintf(s, "(%d)", cfra);
1323 
1324  if ((ob == NULL) || (ob->mode == OB_MODE_OBJECT)) {
1325  LayerCollection *layer_collection = view_layer->active_collection;
1326  s += sprintf(s,
1327  " %s%s",
1328  BKE_collection_ui_name_get(layer_collection->collection),
1329  (ob == NULL) ? "" : " |");
1330  }
1331 
1332  /*
1333  * info can contain:
1334  * - a frame (7 + 2)
1335  * - a collection name (MAX_NAME + 3)
1336  * - 3 object names (MAX_NAME)
1337  * - 2 BREAD_CRUMB_SEPARATORs (6)
1338  * - a SHAPE_KEY_PINNED marker and a trailing '\0' (9+1) - translated, so give some room!
1339  * - a marker name (MAX_NAME + 3)
1340  */
1341 
1342  /* get name of marker on current frame (if available) */
1343  const char *markern = BKE_scene_find_marker_name(scene, cfra);
1344 
1345  /* check if there is an object */
1346  if (ob) {
1347  *s++ = ' ';
1348  s += BLI_strcpy_rlen(s, ob->id.name + 2);
1349 
1350  /* name(s) to display depends on type of object */
1351  if (ob->type == OB_ARMATURE) {
1352  bArmature *arm = ob->data;
1353 
1354  /* show name of active bone too (if possible) */
1355  if (arm->edbo) {
1356  if (arm->act_edbone) {
1357  s += BLI_strcpy_rlen(s, msg_sep);
1358  s += BLI_strcpy_rlen(s, arm->act_edbone->name);
1359  }
1360  }
1361  else if (ob->mode & OB_MODE_POSE) {
1362  if (arm->act_bone) {
1363 
1364  if (arm->act_bone->layer & arm->layer) {
1365  s += BLI_strcpy_rlen(s, msg_sep);
1366  s += BLI_strcpy_rlen(s, arm->act_bone->name);
1367  }
1368  }
1369  }
1370  }
1371  else if (ELEM(ob->type, OB_MESH, OB_LATTICE, OB_CURVE)) {
1372  /* try to display active bone and active shapekey too (if they exist) */
1373 
1374  if (ob->type == OB_MESH && ob->mode & OB_MODE_WEIGHT_PAINT) {
1375  Object *armobj = BKE_object_pose_armature_get(ob);
1376  if (armobj && armobj->mode & OB_MODE_POSE) {
1377  bArmature *arm = armobj->data;
1378  if (arm->act_bone) {
1379  if (arm->act_bone->layer & arm->layer) {
1380  s += BLI_strcpy_rlen(s, msg_sep);
1381  s += BLI_strcpy_rlen(s, arm->act_bone->name);
1382  }
1383  }
1384  }
1385  }
1386 
1387  Key *key = BKE_key_from_object(ob);
1388  if (key) {
1389  KeyBlock *kb = BLI_findlink(&key->block, ob->shapenr - 1);
1390  if (kb) {
1391  s += BLI_strcpy_rlen(s, msg_sep);
1392  s += BLI_strcpy_rlen(s, kb->name);
1393  if (ob->shapeflag & OB_SHAPE_LOCK) {
1394  s += BLI_strcpy_rlen(s, IFACE_(msg_pin));
1395  }
1396  }
1397  }
1398  }
1399 
1400  /* color depends on whether there is a keyframe */
1402  (ID *)ob, /* BKE_scene_frame_get(scene) */ (float)cfra, ANIMFILTER_KEYS_LOCAL)) {
1404  }
1405  else if (ED_gpencil_has_keyframe_v3d(scene, ob, cfra)) {
1407  }
1408  else {
1409  UI_FontThemeColor(font_id, TH_TEXT_HI);
1410  }
1411  }
1412  else {
1413  /* no object */
1414  if (ED_gpencil_has_keyframe_v3d(scene, NULL, cfra)) {
1416  }
1417  else {
1418  UI_FontThemeColor(font_id, TH_TEXT_HI);
1419  }
1420  }
1421 
1422  if (markern) {
1423  s += sprintf(s, " <%s>", markern);
1424  }
1425 
1426  BLF_enable(font_id, BLF_SHADOW);
1427  BLF_shadow(font_id, 5, (const float[4]){0.0f, 0.0f, 0.0f, 1.0f});
1428  BLF_shadow_offset(font_id, 1, -1);
1429 
1430  *yoffset -= VIEW3D_OVERLAY_LINEHEIGHT;
1431  BLF_draw_default(xoffset, *yoffset, 0.0f, info, sizeof(info));
1432 
1433  BLF_disable(font_id, BLF_SHADOW);
1434 }
1435 
1437  Scene *scene, ARegion *region, View3D *v3d, int xoffset, int *yoffset)
1438 {
1439  RegionView3D *rv3d = region->regiondata;
1440  if (!rv3d->is_persp && RV3D_VIEW_IS_AXIS(rv3d->view)) {
1441  const char *grid_unit = NULL;
1442  int font_id = BLF_default();
1443  ED_view3d_grid_view_scale(scene, v3d, region, &grid_unit);
1444 
1445  if (grid_unit) {
1446  char numstr[32] = "";
1447  UI_FontThemeColor(font_id, TH_TEXT_HI);
1448  if (v3d->grid != 1.0f) {
1449  BLI_snprintf(numstr, sizeof(numstr), "%s x %.4g", grid_unit, v3d->grid);
1450  }
1451 
1452  *yoffset -= VIEW3D_OVERLAY_LINEHEIGHT;
1453  BLF_enable(font_id, BLF_SHADOW);
1454  BLF_shadow(font_id, 5, (const float[4]){0.0f, 0.0f, 0.0f, 1.0f});
1455  BLF_shadow_offset(font_id, 1, -1);
1457  xoffset, *yoffset, 0.0f, numstr[0] ? numstr : grid_unit, sizeof(numstr));
1458 
1459  BLF_disable(font_id, BLF_SHADOW);
1460  }
1461  }
1462 }
1463 
1468 {
1469  RegionView3D *rv3d = region->regiondata;
1470  View3D *v3d = CTX_wm_view3d(C);
1473  Main *bmain = CTX_data_main(C);
1474  ViewLayer *view_layer = CTX_data_view_layer(C);
1475 
1476 #ifdef WITH_INPUT_NDOF
1477  if ((U.ndof_flag & NDOF_SHOW_GUIDE) && ((RV3D_LOCK_FLAGS(rv3d) & RV3D_LOCK_ROTATION) == 0) &&
1478  (rv3d->persp != RV3D_CAMOB)) {
1479  /* TODO: draw something else (but not this) during fly mode */
1480  draw_rotation_guide(rv3d);
1481  }
1482 #endif
1483 
1484  /* correct projection matrix */
1485  ED_region_pixelspace(region);
1486 
1487  /* local coordinate visible rect inside region, to accommodate overlapping ui */
1488  const rcti *rect = ED_region_visible_rect(region);
1489 
1490  view3d_draw_border(C, region);
1492 
1494 
1496  /* pass */
1497  }
1498  else {
1499  switch ((eUserpref_MiniAxisType)U.mini_axis_type) {
1501  /* The gizmo handles its own drawing. */
1502  break;
1504  draw_view_axis(rv3d, rect);
1506  break;
1507  }
1508  }
1509 
1510  int xoffset = rect->xmin + (0.5f * U.widget_unit);
1511  int yoffset = rect->ymax - (0.1f * U.widget_unit);
1512 
1513  if ((v3d->flag2 & V3D_HIDE_OVERLAYS) == 0 && (v3d->overlay.flag & V3D_OVERLAY_HIDE_TEXT) == 0) {
1514  if ((U.uiflag & USER_SHOW_FPS) && ED_screen_animation_no_scrub(wm)) {
1515  ED_scene_draw_fps(scene, xoffset, &yoffset);
1516  }
1517  else if (U.uiflag & USER_SHOW_VIEWPORTNAME) {
1518  draw_viewport_name(region, v3d, xoffset, &yoffset);
1519  }
1520 
1521  if (U.uiflag & USER_DRAWVIEWINFO) {
1522  Object *ob = OBACT(view_layer);
1523  draw_selected_name(scene, view_layer, ob, xoffset, &yoffset);
1524  }
1525 
1527  /* draw below the viewport name */
1528  draw_grid_unit_name(scene, region, v3d, xoffset, &yoffset);
1529  }
1530 
1532  }
1533 
1534  if ((v3d->flag2 & V3D_HIDE_OVERLAYS) == 0 && (v3d->overlay.flag & V3D_OVERLAY_STATS)) {
1535  ED_info_draw_stats(bmain, scene, view_layer, xoffset, &yoffset, VIEW3D_OVERLAY_LINEHEIGHT);
1536  }
1537 
1539 }
1540 
1543 /* -------------------------------------------------------------------- */
1547 static void view3d_draw_view(const bContext *C, ARegion *region)
1548 {
1550  CTX_wm_window(C),
1552  CTX_data_scene(C),
1553  region,
1554  CTX_wm_view3d(C),
1555  NULL,
1556  NULL,
1557  NULL);
1558 
1559  /* Only 100% compliant on new spec goes below */
1560  DRW_draw_view(C);
1561 }
1562 
1564 {
1565  /*
1566  * Temporary viewport draw modes until we have a proper system.
1567  * all modes are done in the draw manager, except external render
1568  * engines like Cycles.
1569  */
1571  if (drawtype == OB_MATERIAL && (type->flag & RE_USE_EEVEE_VIEWPORT)) {
1573  }
1574  return type;
1575 }
1576 
1578 {
1579  Main *bmain = CTX_data_main(C);
1580  View3D *v3d = CTX_wm_view3d(C);
1581 
1582  view3d_draw_view(C, region);
1583 
1587 
1588  /* No depth test for drawing action zones afterwards. */
1590 
1592  /* TODO: Clear cache? */
1593 }
1594 
1597 /* -------------------------------------------------------------------- */
1602  const Scene *scene,
1603  View3D *v3d,
1604  ARegion *region,
1605  const float winmat[4][4],
1606  const char *viewname)
1607 {
1608  /* update the viewport matrices with the new camera */
1610  float viewmat[4][4];
1611  const bool is_left = STREQ(viewname, STEREO_LEFT_NAME);
1612 
1614  view3d_main_region_setup_offscreen(depsgraph, scene, v3d, region, viewmat, winmat);
1615  }
1616  else { /* SCE_VIEWS_FORMAT_MULTIVIEW */
1617  float viewmat[4][4];
1618  Object *camera = BKE_camera_multiview_render(scene, v3d->camera, viewname);
1619 
1620  BKE_camera_multiview_view_matrix(&scene->r, camera, false, viewmat);
1621  view3d_main_region_setup_offscreen(depsgraph, scene, v3d, region, viewmat, winmat);
1622  }
1623 }
1624 
1626  const Scene *scene,
1627  eDrawType drawtype,
1628  View3D *v3d,
1629  ARegion *region,
1630  int winx,
1631  int winy,
1632  const float viewmat[4][4],
1633  const float winmat[4][4],
1634  bool is_image_render,
1635  bool draw_background,
1636  const char *viewname,
1637  const bool do_color_management,
1638  const bool restore_rv3d_mats,
1639  GPUOffScreen *ofs,
1640  GPUViewport *viewport)
1641 {
1642  RegionView3D *rv3d = region->regiondata;
1643  RenderEngineType *engine_type = ED_view3d_engine_type(scene, drawtype);
1644 
1645  /* Store `orig` variables. */
1646  struct {
1647  struct bThemeState theme_state;
1648 
1649  /* #View3D */
1650  eDrawType v3d_shading_type;
1651 
1652  /* #Region */
1653  int region_winx, region_winy;
1654  rcti region_winrct;
1655 
1656  /* #RegionView3D */
1661  struct RV3DMatrixStore *rv3d_mats;
1662  } orig = {
1663  .v3d_shading_type = v3d->shading.type,
1664 
1665  .region_winx = region->winx,
1666  .region_winy = region->winy,
1667  .region_winrct = region->winrct,
1668 
1669  .rv3d_mats = ED_view3d_mats_rv3d_backup(region->regiondata),
1670  };
1671 
1672  UI_Theme_Store(&orig.theme_state);
1674 
1675  /* Set temporary new size. */
1676  region->winx = winx;
1677  region->winy = winy;
1678  region->winrct.xmin = 0;
1679  region->winrct.ymin = 0;
1680  region->winrct.xmax = winx;
1681  region->winrct.ymax = winy;
1682 
1683  /* There are too many functions inside the draw manager that check the shading type,
1684  * so use a temporary override instead. */
1685  v3d->shading.type = drawtype;
1686 
1687  /* Set flags. */
1689 
1690  {
1691  /* free images which can have changed on frame-change
1692  * warning! can be slow so only free animated images - campbell */
1693  BKE_image_free_anim_gputextures(G.main); /* XXX :((( */
1694  }
1695 
1698  GPU_matrix_push();
1700 
1701  if ((viewname != NULL && viewname[0] != '\0') && (viewmat == NULL) &&
1702  rv3d->persp == RV3D_CAMOB && v3d->camera) {
1703  view3d_stereo3d_setup_offscreen(depsgraph, scene, v3d, region, winmat, viewname);
1704  }
1705  else {
1707  }
1708 
1709  /* main drawing call */
1711  engine_type,
1712  region,
1713  v3d,
1714  is_image_render,
1716  do_color_management,
1717  ofs,
1718  viewport);
1720  GPU_matrix_pop();
1721 
1722  /* Restore all `orig` members. */
1723  region->winx = orig.region_winx;
1724  region->winy = orig.region_winy;
1725  region->winrct = orig.region_winrct;
1726 
1727  /* Optionally do _not_ restore rv3d matrices (e.g. they are used/stored in the ImBuff for
1728  * reprojection, see texture_paint_image_from_view_exec(). */
1729  if (restore_rv3d_mats) {
1730  ED_view3d_mats_rv3d_restore(region->regiondata, orig.rv3d_mats);
1731  }
1732  MEM_freeN(orig.rv3d_mats);
1733 
1734  UI_Theme_Restore(&orig.theme_state);
1735 
1736  v3d->shading.type = orig.v3d_shading_type;
1737 
1738  G.f &= ~G_FLAG_RENDER_VIEWPORT;
1739 }
1740 
1746  Scene *scene,
1747  View3DShading *shading_override,
1748  int drawtype,
1749  int winx,
1750  int winy,
1751  uint draw_flags,
1752  const float viewmat[4][4],
1753  const float winmat[4][4],
1754  float clip_start,
1755  float clip_end,
1756  bool is_image_render,
1757  bool draw_background,
1758  const char *viewname,
1759  const bool do_color_management,
1760  GPUOffScreen *ofs,
1761  GPUViewport *viewport)
1762 {
1763  View3D v3d = {NULL};
1764  ARegion ar = {NULL};
1765  RegionView3D rv3d = {{{0}}};
1766 
1767  v3d.regionbase.first = v3d.regionbase.last = &ar;
1768  ar.regiondata = &rv3d;
1770 
1771  View3DShading *source_shading_settings = &scene->display.shading;
1772  if (draw_flags & V3D_OFSDRAW_OVERRIDE_SCENE_SETTINGS && shading_override != NULL) {
1773  source_shading_settings = shading_override;
1774  }
1775  memcpy(&v3d.shading, source_shading_settings, sizeof(View3DShading));
1776  v3d.shading.type = drawtype;
1777 
1778  if (shading_override) {
1779  /* Pass. */
1780  }
1781  else if (drawtype == OB_MATERIAL) {
1783  }
1784 
1785  if (draw_flags & V3D_OFSDRAW_SHOW_ANNOTATION) {
1786  v3d.flag2 |= V3D_SHOW_ANNOTATION;
1787  }
1788  if (draw_flags & V3D_OFSDRAW_SHOW_GRIDFLOOR) {
1790  v3d.grid = 1.0f;
1791  v3d.gridlines = 16;
1792  v3d.gridsubdiv = 10;
1793 
1794  /* Show grid, disable other overlays (set all available _HIDE_ flags). */
1798  v3d.flag |= V3D_HIDE_HELPLINES;
1799  }
1800  else {
1801  v3d.flag2 = V3D_HIDE_OVERLAYS;
1802  }
1803 
1804  rv3d.persp = RV3D_PERSP;
1805  v3d.clip_start = clip_start;
1806  v3d.clip_end = clip_end;
1807  /* Actually not used since we pass in the projection matrix. */
1808  v3d.lens = 0;
1809 
1811  scene,
1812  drawtype,
1813  &v3d,
1814  &ar,
1815  winx,
1816  winy,
1817  viewmat,
1818  winmat,
1819  is_image_render,
1821  viewname,
1822  do_color_management,
1823  true,
1824  ofs,
1825  viewport);
1826 }
1827 
1835  Scene *scene,
1836  eDrawType drawtype,
1837  View3D *v3d,
1838  ARegion *region,
1839  int sizex,
1840  int sizey,
1841  eImBufFlags imbuf_flag,
1842  int alpha_mode,
1843  const char *viewname,
1844  const bool restore_rv3d_mats,
1845  /* output vars */
1846  GPUOffScreen *ofs,
1847  char err_out[256])
1848 {
1849  RegionView3D *rv3d = region->regiondata;
1850  const bool draw_sky = (alpha_mode == R_ADDSKY);
1851 
1852  /* view state */
1853  bool is_ortho = false;
1854  float winmat[4][4];
1855 
1856  if (ofs && ((GPU_offscreen_width(ofs) != sizex) || (GPU_offscreen_height(ofs) != sizey))) {
1857  /* sizes differ, can't reuse */
1858  ofs = NULL;
1859  }
1860 
1862 
1863  if (old_fb) {
1865  }
1866 
1867  const bool own_ofs = (ofs == NULL);
1869 
1870  if (own_ofs) {
1871  /* bind */
1872  ofs = GPU_offscreen_create(sizex, sizey, true, false, err_out);
1873  if (ofs == NULL) {
1875  return NULL;
1876  }
1877  }
1878 
1879  GPU_offscreen_bind(ofs, true);
1880 
1881  /* read in pixels & stamp */
1882  ImBuf *ibuf = IMB_allocImBuf(sizex, sizey, 32, imbuf_flag);
1883 
1884  /* render 3d view */
1885  if (rv3d->persp == RV3D_CAMOB && v3d->camera) {
1887  Object *camera = BKE_camera_multiview_render(scene, v3d->camera, viewname);
1888  const Object *camera_eval = DEG_get_evaluated_object(depsgraph, camera);
1889 
1891  /* fallback for non camera objects */
1892  params.clip_start = v3d->clip_start;
1893  params.clip_end = v3d->clip_end;
1894  BKE_camera_params_from_object(&params, camera_eval);
1895  BKE_camera_multiview_params(&scene->r, &params, camera_eval, viewname);
1898 
1899  is_ortho = params.is_ortho;
1900  copy_m4_m4(winmat, params.winmat);
1901  }
1902  else {
1903  rctf viewplane;
1904  float clip_start, clipend;
1905 
1906  is_ortho = ED_view3d_viewplane_get(
1907  depsgraph, v3d, rv3d, sizex, sizey, &viewplane, &clip_start, &clipend, NULL);
1908  if (is_ortho) {
1910  viewplane.xmin,
1911  viewplane.xmax,
1912  viewplane.ymin,
1913  viewplane.ymax,
1914  -clipend,
1915  clipend);
1916  }
1917  else {
1919  viewplane.xmin,
1920  viewplane.xmax,
1921  viewplane.ymin,
1922  viewplane.ymax,
1923  clip_start,
1924  clipend);
1925  }
1926  }
1927 
1928  /* XXX(jbakker): `do_color_management` should be controlled by the caller. Currently when doing a
1929  * viewport render animation and saving to an 8bit file format, color management would be applied
1930  * twice. Once here, and once when saving the saving to disk. In this case the Save As Render
1931  * option cannot be controlled either. But when doing an off-screen render you want to do the
1932  * color management here.
1933  *
1934  * This option was added here to increase the performance for quick view-port preview renders.
1935  * When using workbench the color differences haven't been reported as a bug. But users also use
1936  * the viewport rendering to render Eevee scenes. In the later situation the saved colors are
1937  * totally wrong. */
1938  const bool do_color_management = (ibuf->rect_float == NULL);
1940  scene,
1941  drawtype,
1942  v3d,
1943  region,
1944  sizex,
1945  sizey,
1946  NULL,
1947  winmat,
1948  true,
1949  draw_sky,
1950  viewname,
1951  do_color_management,
1952  restore_rv3d_mats,
1953  ofs,
1954  NULL);
1955 
1956  if (ibuf->rect_float) {
1958  }
1959  else if (ibuf->rect) {
1961  }
1962 
1963  /* unbind */
1964  GPU_offscreen_unbind(ofs, true);
1965 
1966  if (own_ofs) {
1967  GPU_offscreen_free(ofs);
1968  }
1969 
1971 
1972  if (old_fb) {
1973  GPU_framebuffer_bind(old_fb);
1974  }
1975 
1976  if (ibuf->rect_float && ibuf->rect) {
1977  IMB_rect_from_float(ibuf);
1978  }
1979 
1980  return ibuf;
1981 }
1982 
1992  Scene *scene,
1993  View3DShading *shading_override,
1994  eDrawType drawtype,
1995  Object *camera,
1996  int width,
1997  int height,
1998  eImBufFlags imbuf_flag,
1999  eV3DOffscreenDrawFlag draw_flags,
2000  int alpha_mode,
2001  const char *viewname,
2002  GPUOffScreen *ofs,
2003  char err_out[256])
2004 {
2005  View3D v3d = {NULL};
2006  ARegion region = {NULL};
2007  RegionView3D rv3d = {{{0}}};
2008 
2009  /* connect data */
2010  v3d.regionbase.first = v3d.regionbase.last = &region;
2011  region.regiondata = &rv3d;
2012  region.regiontype = RGN_TYPE_WINDOW;
2013 
2014  v3d.camera = camera;
2015  View3DShading *source_shading_settings = &scene->display.shading;
2016  if (draw_flags & V3D_OFSDRAW_OVERRIDE_SCENE_SETTINGS && shading_override != NULL) {
2017  source_shading_settings = shading_override;
2018  }
2019  memcpy(&v3d.shading, source_shading_settings, sizeof(View3DShading));
2020  v3d.shading.type = drawtype;
2021 
2022  if (drawtype == OB_MATERIAL) {
2025  }
2026  else if (drawtype == OB_RENDER) {
2029  }
2030 
2031  v3d.flag2 = V3D_HIDE_OVERLAYS;
2032  /* HACK: When rendering gpencil objects this opacity is used to mix vertex colors in when not in
2033  * render mode. */
2035 
2036  if (draw_flags & V3D_OFSDRAW_SHOW_ANNOTATION) {
2037  v3d.flag2 |= V3D_SHOW_ANNOTATION;
2038  }
2039  if (draw_flags & V3D_OFSDRAW_SHOW_GRIDFLOOR) {
2041  }
2042 
2044 
2045  rv3d.persp = RV3D_CAMOB;
2046 
2047  copy_m4_m4(rv3d.viewinv, v3d.camera->obmat);
2048  normalize_m4(rv3d.viewinv);
2049  invert_m4_m4(rv3d.viewmat, rv3d.viewinv);
2050 
2051  {
2053  const Object *view_camera_eval = DEG_get_evaluated_object(
2055 
2057  BKE_camera_params_from_object(&params, view_camera_eval);
2058  BKE_camera_multiview_params(&scene->r, &params, view_camera_eval, viewname);
2061 
2062  copy_m4_m4(rv3d.winmat, params.winmat);
2063  v3d.clip_start = params.clip_start;
2064  v3d.clip_end = params.clip_end;
2065  v3d.lens = params.lens;
2066  }
2067 
2068  mul_m4_m4m4(rv3d.persmat, rv3d.winmat, rv3d.viewmat);
2069  invert_m4_m4(rv3d.persinv, rv3d.viewinv);
2070 
2072  scene,
2073  drawtype,
2074  &v3d,
2075  &region,
2076  width,
2077  height,
2078  imbuf_flag,
2079  alpha_mode,
2080  viewname,
2081  true,
2082  ofs,
2083  err_out);
2084 }
2085 
2088 /* -------------------------------------------------------------------- */
2092 static bool view3d_clipping_test(const float co[3], const float clip[6][4])
2093 {
2094  if (plane_point_side_v3(clip[0], co) > 0.0f) {
2095  if (plane_point_side_v3(clip[1], co) > 0.0f) {
2096  if (plane_point_side_v3(clip[2], co) > 0.0f) {
2097  if (plane_point_side_v3(clip[3], co) > 0.0f) {
2098  return false;
2099  }
2100  }
2101  }
2102  }
2103 
2104  return true;
2105 }
2106 
2116 bool ED_view3d_clipping_test(const RegionView3D *rv3d, const float co[3], const bool is_local)
2117 {
2118  return view3d_clipping_test(co, is_local ? rv3d->clip_local : rv3d->clip);
2119 }
2120 
2123 /* -------------------------------------------------------------------- */
2131  ViewLayer *view_layer,
2132  ARegion *region,
2133  View3D *v3d,
2134  Object *obact)
2135 {
2136  /* TODO: Use a flag in the selection engine itself. */
2138  return;
2139  }
2140  Object *obact_eval = DEG_get_evaluated_object(depsgraph, obact);
2141 
2143  UNUSED_VARS_NDEBUG(region);
2144 
2145  if (obact_eval && (obact_eval->mode & (OB_MODE_VERTEX_PAINT | OB_MODE_WEIGHT_PAINT) ||
2146  BKE_paint_select_face_test(obact_eval))) {
2147  /* do nothing */
2148  }
2149  /* texture paint mode sampling */
2150  else if (obact_eval && (obact_eval->mode & OB_MODE_TEXTURE_PAINT) &&
2151  (v3d->shading.type > OB_WIRE)) {
2152  /* do nothing */
2153  }
2154  else if ((obact_eval && (obact_eval->mode & OB_MODE_PARTICLE_EDIT)) && !XRAY_ENABLED(v3d)) {
2155  /* do nothing */
2156  }
2157  else {
2159  return;
2160  }
2161 
2162  if (obact_eval && ((obact_eval->base_flag & BASE_VISIBLE_DEPSGRAPH) != 0)) {
2163  Base *base = BKE_view_layer_base_find(view_layer, obact);
2164  DRW_select_buffer_context_create(&base, 1, -1);
2165  }
2166 
2168 }
2169 
2170 /* TODO: Creating, attaching texture, and destroying a framebuffer is quite slow.
2171  * Calling this function should be avoided during interactive drawing. */
2172 static void view3d_opengl_read_Z_pixels(GPUViewport *viewport, rcti *rect, void *data)
2173 {
2175 
2176  GPUFrameBuffer *tmp_fb = GPU_framebuffer_create(__func__);
2177  GPU_framebuffer_texture_attach(tmp_fb, dtxl->depth, 0, 0);
2178  GPU_framebuffer_bind(tmp_fb);
2179 
2181  rect->xmin,
2182  rect->ymin,
2183  BLI_rcti_size_x(rect),
2184  BLI_rcti_size_y(rect),
2186  data);
2187 
2189  GPU_framebuffer_free(tmp_fb);
2190 }
2191 
2193 {
2194  validate_object_select_id(vc->depsgraph, vc->view_layer, vc->region, vc->v3d, vc->obact);
2195 }
2196 
2201 int ED_view3d_backbuf_sample_size_clamp(ARegion *region, const float dist)
2202 {
2203  return (int)min_ff(ceilf(dist), (float)max_ii(region->winx, region->winx));
2204 }
2205 
2208 /* -------------------------------------------------------------------- */
2213 {
2214  /* clamp rect by region */
2215  rcti r = {
2216  .xmin = 0,
2217  .xmax = region->winx - 1,
2218  .ymin = 0,
2219  .ymax = region->winy - 1,
2220  };
2221 
2222  /* Constrain rect to depth bounds */
2223  BLI_rcti_isect(&r, rect, rect);
2224 
2225  /* assign values to compare with the ViewDepths */
2226  int x = rect->xmin;
2227  int y = rect->ymin;
2228 
2229  int w = BLI_rcti_size_x(rect);
2230  int h = BLI_rcti_size_y(rect);
2231 
2232  if (w <= 0 || h <= 0) {
2233  if (d->depths) {
2234  MEM_freeN(d->depths);
2235  }
2236  d->depths = NULL;
2237 
2238  d->damaged = false;
2239  }
2240  else if (d->w != w || d->h != h || d->x != x || d->y != y || d->depths == NULL) {
2241  d->x = x;
2242  d->y = y;
2243  d->w = w;
2244  d->h = h;
2245 
2246  if (d->depths) {
2247  MEM_freeN(d->depths);
2248  }
2249 
2250  d->depths = MEM_mallocN(sizeof(float) * d->w * d->h, "View depths Subset");
2251 
2252  d->damaged = true;
2253  }
2254 
2255  if (d->damaged) {
2256  GPUViewport *viewport = WM_draw_region_get_viewport(region);
2257  view3d_opengl_read_Z_pixels(viewport, rect, d->depths);
2258  /* Range is assumed to be this as they are never changed. */
2259  d->depth_range[0] = 0.0;
2260  d->depth_range[1] = 1.0;
2261  d->damaged = false;
2262  }
2263 }
2264 
2265 /* Note, with nouveau drivers the glReadPixels() is very slow. T24339. */
2267 {
2268  RegionView3D *rv3d = region->regiondata;
2269 
2270  /* Create storage for, and, if necessary, copy depth buffer. */
2271  if (!rv3d->depths) {
2272  rv3d->depths = MEM_callocN(sizeof(ViewDepths), "ViewDepths");
2273  }
2274  if (rv3d->depths) {
2275  ViewDepths *d = rv3d->depths;
2276  if (d->w != region->winx || d->h != region->winy || !d->depths) {
2277  d->w = region->winx;
2278  d->h = region->winy;
2279  if (d->depths) {
2280  MEM_freeN(d->depths);
2281  }
2282  d->depths = MEM_mallocN(sizeof(float) * d->w * d->h, "View depths");
2283  d->damaged = true;
2284  }
2285 
2286  if (d->damaged) {
2287  GPUViewport *viewport = WM_draw_region_get_viewport(region);
2290 
2291  /* Assumed to be this as they are never changed. */
2292  d->depth_range[0] = 0.0;
2293  d->depth_range[1] = 1.0;
2294  d->damaged = false;
2295  }
2296  }
2297 }
2298 
2299 /* Utility function to find the closest Z value, use for auto-depth. */
2301 {
2302  /* Convert to float for comparisons. */
2303  const float near = (float)d->depth_range[0];
2304  const float far_real = (float)d->depth_range[1];
2305  float far = far_real;
2306 
2307  const float *depths = d->depths;
2308  float depth = FLT_MAX;
2309  int i = (int)d->w * (int)d->h; /* Cast to avoid short overflow. */
2310 
2311  /* Far is both the starting 'far' value
2312  * and the closest value found. */
2313  while (i--) {
2314  depth = *depths++;
2315  if ((depth < far) && (depth > near)) {
2316  far = depth;
2317  }
2318  }
2319 
2320  return far == far_real ? FLT_MAX : far;
2321 }
2322 
2332  ARegion *region,
2333  View3D *v3d,
2334  Object *obact,
2335  eV3DDepthOverrideMode mode,
2336  bool update_cache)
2337 {
2339  return;
2340  }
2341  struct bThemeState theme_state;
2343  RegionView3D *rv3d = region->regiondata;
2344 
2345  short flag = v3d->flag;
2346  /* temp set drawtype to solid */
2347  /* Setting these temporarily is not nice */
2348  v3d->flag &= ~V3D_SELECT_OUTLINE;
2349 
2350  /* Tools may request depth outside of regular drawing code. */
2351  UI_Theme_Store(&theme_state);
2353 
2355  G_MAIN->wm.first, NULL, depsgraph, scene, region, v3d, NULL, NULL, NULL);
2356 
2357  /* get surface depth without bias */
2358  rv3d->rflag |= RV3D_ZOFFSET_DISABLED;
2359 
2360  /* Needed in cases the 3D Viewport isn't already setup. */
2363 
2364  GPUViewport *viewport = WM_draw_region_get_viewport(region);
2365  /* When Blender is starting, a click event can trigger a depth test while the viewport is not
2366  * yet available. */
2367  if (viewport != NULL) {
2368  switch (mode) {
2369  case V3D_DEPTH_NO_GPENCIL:
2370  DRW_draw_depth_loop(depsgraph, region, v3d, viewport);
2371  break;
2373  DRW_draw_depth_loop_gpencil(depsgraph, region, v3d, viewport);
2374  break;
2375  case V3D_DEPTH_OBJECT_ONLY:
2377  scene, region, v3d, viewport, DEG_get_evaluated_object(depsgraph, obact));
2378  break;
2379  }
2380 
2381  if (rv3d->depths != NULL) {
2382  rv3d->depths->damaged = true;
2383  /* TODO: Clear cache? */
2384  }
2385  if (update_cache) {
2386  view3d_depth_cache_update(region);
2387  }
2388  }
2389 
2391 
2392  rv3d->rflag &= ~RV3D_ZOFFSET_DISABLED;
2393 
2394  v3d->flag = flag;
2396 
2397  UI_Theme_Restore(&theme_state);
2398 }
2399 
2402 /* -------------------------------------------------------------------- */
2407  const Scene *UNUSED(scene),
2408  const View3D *v3d,
2409  CustomData_MeshMasks *r_cddata_masks)
2410 {
2412  r_cddata_masks->lmask |= CD_MASK_MLOOPUV | CD_MASK_MLOOPCOL;
2413  r_cddata_masks->vmask |= CD_MASK_ORCO | CD_MASK_PROP_COLOR;
2414  }
2415  else if (v3d->shading.type == OB_SOLID) {
2417  r_cddata_masks->lmask |= CD_MASK_MLOOPUV;
2418  }
2420  r_cddata_masks->lmask |= CD_MASK_MLOOPCOL;
2421  r_cddata_masks->vmask |= CD_MASK_ORCO | CD_MASK_PROP_COLOR;
2422  }
2423  }
2424 
2427  r_cddata_masks->vmask |= CD_MASK_MDEFORMVERT;
2428  }
2429  if ((CTX_data_mode_enum(C) == CTX_MODE_SCULPT)) {
2430  r_cddata_masks->vmask |= CD_MASK_PAINT_MASK;
2431  r_cddata_masks->pmask |= CD_MASK_SCULPT_FACE_SETS;
2432  }
2433 }
2434 
2435 /* Goes over all modes and view3d settings. */
2437  const Scene *scene,
2438  const bScreen *screen,
2439  CustomData_MeshMasks *r_cddata_masks)
2440 {
2442 
2443  /* Check if we need tfaces & mcols due to view mode. */
2444  LISTBASE_FOREACH (const ScrArea *, area, &screen->areabase) {
2445  if (area->spacetype == SPACE_VIEW3D) {
2446  ED_view3d_datamask(C, scene, area->spacedata.first, r_cddata_masks);
2447  }
2448  }
2449 }
2450 
2453 /* -------------------------------------------------------------------- */
2465  float winmat[4][4];
2466  float viewmat[4][4];
2467  float viewinv[4][4];
2468  float persmat[4][4];
2469  float persinv[4][4];
2471  float pixsize;
2472 };
2473 
2475 {
2476  struct RV3DMatrixStore *rv3dmat = MEM_mallocN(sizeof(*rv3dmat), __func__);
2477  copy_m4_m4(rv3dmat->winmat, rv3d->winmat);
2478  copy_m4_m4(rv3dmat->viewmat, rv3d->viewmat);
2479  copy_m4_m4(rv3dmat->persmat, rv3d->persmat);
2480  copy_m4_m4(rv3dmat->persinv, rv3d->persinv);
2481  copy_m4_m4(rv3dmat->viewinv, rv3d->viewinv);
2482  copy_v4_v4(rv3dmat->viewcamtexcofac, rv3d->viewcamtexcofac);
2483  rv3dmat->pixsize = rv3d->pixsize;
2484  return rv3dmat;
2485 }
2486 
2487 void ED_view3d_mats_rv3d_restore(struct RegionView3D *rv3d, struct RV3DMatrixStore *rv3dmat_pt)
2488 {
2489  struct RV3DMatrixStore *rv3dmat = rv3dmat_pt;
2490  copy_m4_m4(rv3d->winmat, rv3dmat->winmat);
2491  copy_m4_m4(rv3d->viewmat, rv3dmat->viewmat);
2492  copy_m4_m4(rv3d->persmat, rv3dmat->persmat);
2493  copy_m4_m4(rv3d->persinv, rv3dmat->persinv);
2494  copy_m4_m4(rv3d->viewinv, rv3dmat->viewinv);
2495  copy_v4_v4(rv3d->viewcamtexcofac, rv3dmat->viewcamtexcofac);
2496  rv3d->pixsize = rv3dmat->pixsize;
2497 }
2498 
2501 /* -------------------------------------------------------------------- */
2509 void ED_scene_draw_fps(const Scene *scene, int xoffset, int *yoffset)
2510 {
2512  char printable[16];
2513 
2514  if (!fpsi || !fpsi->lredrawtime || !fpsi->redrawtime) {
2515  return;
2516  }
2517 
2518  printable[0] = '\0';
2519 
2520  /* Doing an average for a more robust calculation. */
2521  fpsi->redrawtimes_fps[fpsi->redrawtime_index] = (float)(1.0 /
2522  (fpsi->lredrawtime - fpsi->redrawtime));
2523 
2524  float fps = 0.0f;
2525  int tot = 0;
2526  for (int i = 0; i < REDRAW_FRAME_AVERAGE; i++) {
2527  if (fpsi->redrawtimes_fps[i]) {
2528  fps += fpsi->redrawtimes_fps[i];
2529  tot++;
2530  }
2531  }
2532  if (tot) {
2534  fps = fps / tot;
2535  }
2536 
2537  const int font_id = BLF_default();
2538 
2539  /* Is this more than half a frame behind? */
2540  if (fps + 0.5f < (float)(FPS)) {
2541  UI_FontThemeColor(font_id, TH_REDALERT);
2542  BLI_snprintf(printable, sizeof(printable), IFACE_("fps: %.2f"), fps);
2543  }
2544  else {
2545  UI_FontThemeColor(font_id, TH_TEXT_HI);
2546  BLI_snprintf(printable, sizeof(printable), IFACE_("fps: %i"), (int)(fps + 0.5f));
2547  }
2548 
2549  BLF_enable(font_id, BLF_SHADOW);
2550  BLF_shadow(font_id, 5, (const float[4]){0.0f, 0.0f, 0.0f, 1.0f});
2551  BLF_shadow_offset(font_id, 1, -1);
2552 
2553  *yoffset -= VIEW3D_OVERLAY_LINEHEIGHT;
2554 
2555 #ifdef WITH_INTERNATIONAL
2556  BLF_draw_default(xoffset, *yoffset, 0.0f, printable, sizeof(printable));
2557 #else
2558  BLF_draw_default_ascii(xoffset, *yoffset, 0.0f, printable, sizeof(printable));
2559 #endif
2560 
2561  BLF_disable(font_id, BLF_SHADOW);
2562 }
2563 
2566 /* -------------------------------------------------------------------- */
2571 {
2573  return (type && type->view_update && type->view_draw);
2574 }
2575 
2577  const Scene *scene, Depsgraph *depsgraph, View3D *v3d, ARegion *region, rcti *rect)
2578 {
2579  RegionView3D *rv3d = region->regiondata;
2580  bool use_border;
2581 
2582  /* Test if there is a 3d view rendering. */
2584  return false;
2585  }
2586 
2587  /* Test if there is a border render. */
2588  if (rv3d->persp == RV3D_CAMOB) {
2589  use_border = (scene->r.mode & R_BORDER) != 0;
2590  }
2591  else {
2592  use_border = (v3d->flag2 & V3D_RENDER_BORDER) != 0;
2593  }
2594 
2595  if (!use_border) {
2596  return false;
2597  }
2598 
2599  /* Compute border. */
2600  if (rv3d->persp == RV3D_CAMOB) {
2601  rctf viewborder;
2602  ED_view3d_calc_camera_border(scene, depsgraph, region, v3d, rv3d, &viewborder, false);
2603 
2604  rect->xmin = viewborder.xmin + scene->r.border.xmin * BLI_rctf_size_x(&viewborder);
2605  rect->ymin = viewborder.ymin + scene->r.border.ymin * BLI_rctf_size_y(&viewborder);
2606  rect->xmax = viewborder.xmin + scene->r.border.xmax * BLI_rctf_size_x(&viewborder);
2607  rect->ymax = viewborder.ymin + scene->r.border.ymax * BLI_rctf_size_y(&viewborder);
2608  }
2609  else {
2610  rect->xmin = v3d->render_border.xmin * region->winx;
2611  rect->xmax = v3d->render_border.xmax * region->winx;
2612  rect->ymin = v3d->render_border.ymin * region->winy;
2613  rect->ymax = v3d->render_border.ymax * region->winy;
2614  }
2615 
2616  BLI_rcti_translate(rect, region->winrct.xmin, region->winrct.ymin);
2617  BLI_rcti_isect(&region->winrct, rect, rect);
2618 
2619  return true;
2620 }
2621 
typedef float(TangentPoint)[2]
Camera data-block and utility functions.
void BKE_camera_multiview_params(const struct RenderData *rd, struct CameraParams *params, const struct Object *camera, const char *viewname)
float BKE_camera_multiview_shift_x(const struct RenderData *rd, const struct Object *camera, const char *viewname)
void BKE_camera_multiview_view_matrix(const struct RenderData *rd, const struct Object *camera, const bool is_left, float r_viewmat[4][4])
struct Object * BKE_camera_multiview_render(const struct Scene *scene, struct Object *camera, const char *viewname)
int BKE_camera_sensor_fit(int sensor_fit, float sizex, float sizey)
Definition: camera.c:252
void BKE_camera_params_init(CameraParams *params)
Definition: camera.c:271
void BKE_camera_params_from_view3d(CameraParams *params, struct Depsgraph *depsgraph, const struct View3D *v3d, const struct RegionView3D *rv3d)
void BKE_camera_params_from_object(CameraParams *params, const struct Object *cam_ob)
void BKE_camera_params_compute_viewplane(CameraParams *params, int winx, int winy, float aspx, float aspy)
Definition: camera.c:370
void BKE_camera_params_compute_matrix(CameraParams *params)
Definition: camera.c:436
const char * BKE_collection_ui_name_get(struct Collection *collection)
Definition: collection.c:776
struct Scene * CTX_data_scene(const bContext *C)
Definition: context.c:1034
struct wmWindowManager * CTX_wm_manager(const bContext *C)
Definition: context.c:689
@ CTX_MODE_SCULPT
Definition: BKE_context.h:123
@ CTX_MODE_EDIT_MESH
Definition: BKE_context.h:115
struct ViewLayer * CTX_data_view_layer(const bContext *C)
Definition: context.c:1044
struct View3D * CTX_wm_view3d(const bContext *C)
Definition: context.c:760
struct Depsgraph * CTX_data_expect_evaluated_depsgraph(const bContext *C)
Definition: context.c:1415
struct Main * CTX_data_main(const bContext *C)
Definition: context.c:1018
struct wmWindow * CTX_wm_window(const bContext *C)
Definition: context.c:699
enum eContextObjectMode CTX_data_mode_enum(const bContext *C)
Definition: context.c:1174
CustomData interface, see also DNA_customdata_types.h.
void CustomData_MeshMasks_update(CustomData_MeshMasks *mask_dst, const CustomData_MeshMasks *mask_src)
Definition: customdata.c:76
const CustomData_MeshMasks CD_MASK_BAREMESH
Definition: customdata.c:1919
#define G_MAIN
Definition: BKE_global.h:232
@ G_FLAG_RENDER_VIEWPORT
Definition: BKE_global.h:110
void BKE_image_free_anim_gputextures(struct Main *bmain)
Definition: image_gpu.c:532
void BKE_image_free_old_gputextures(struct Main *bmain)
Definition: image_gpu.c:543
struct Key * BKE_key_from_object(const struct Object *ob)
struct Base * BKE_view_layer_base_find(struct ViewLayer *view_layer, struct Object *ob)
Definition: layer.c:394
General operations, lookup, etc. for blender objects.
struct Object * BKE_object_pose_armature_get(struct Object *ob)
Definition: object.c:2487
bool BKE_paint_select_face_test(struct Object *ob)
Definition: paint.c:968
bool BKE_scene_multiview_is_stereo3d(const struct RenderData *rd)
const char * BKE_scene_find_marker_name(const struct Scene *scene, int frame)
const char * BKE_unit_display_name_get(const void *usys_pt, int index)
Definition: unit.c:1294
void BKE_unit_system_get(int system, int type, const void **r_usys_pt, int *r_len)
Definition: unit.c:1267
@ B_UNIT_LENGTH
Definition: BKE_unit.h:79
int BKE_unit_base_get(const void *usys_pt)
Definition: unit.c:1280
double BKE_unit_scalar_get(const void *usys_pt, int index)
Definition: unit.c:1307
void BLF_draw_default(float x, float y, float z, const char *str, size_t len) ATTR_NONNULL()
Definition: blf_default.c:71
int BLF_default(void)
Definition: blf_default.c:55
void BLF_shadow_offset(int fontid, int x, int y)
Definition: blf.c:841
void BLF_shadow(int fontid, int level, const float rgba[4]) ATTR_NONNULL(3)
Definition: blf.c:831
void BLF_disable(int fontid, int option)
Definition: blf.c:283
void BLF_draw_default_ascii(float x, float y, float z, const char *str, size_t len) ATTR_NONNULL()
Definition: blf_default.c:82
void BLF_batch_draw_begin(void)
Definition: blf.c:470
void BLF_enable(int fontid, int option)
Definition: blf.c:274
#define BLF_SHADOW
Definition: BLF_api.h:271
void BLF_batch_draw_end(void)
Definition: blf.c:483
void BLF_color4ubv(int fontid, const unsigned char rgba[4])
Definition: blf.c:387
#define BLI_assert(a)
Definition: BLI_assert.h:58
#define LISTBASE_FOREACH(type, var, list)
Definition: BLI_listbase.h:172
void * BLI_findlink(const struct ListBase *listbase, int number) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(1)
MINLINE float min_ff(float a, float b)
MINLINE int max_ii(int a, int b)
#define M_PI
Definition: BLI_math_base.h:38
MINLINE float plane_point_side_v3(const float plane[4], const float co[3])
void perspective_m4(float mat[4][4], const float left, const float right, const float bottom, const float top, const float nearClip, const float farClip)
Definition: math_geom.c:4830
void orthographic_m4(float mat[4][4], const float left, const float right, const float bottom, const float top, const float nearClip, const float farClip)
Definition: math_geom.c:4802
void mul_m4_m4m4(float R[4][4], const float A[4][4], const float B[4][4])
Definition: math_matrix.c:262
bool invert_m4_m4(float R[4][4], const float A[4][4])
Definition: math_matrix.c:1278
void copy_m4_m4(float m1[4][4], const float m2[4][4])
Definition: math_matrix.c:95
void normalize_m4(float R[4][4]) ATTR_NONNULL()
Definition: math_matrix.c:1952
void axis_angle_to_quat(float r[4], const float axis[3], const float angle)
void mul_qt_v3(const float q[4], float r[3])
Definition: math_rotation.c:97
MINLINE void copy_v4_v4(float r[4], const float a[4])
void axis_sort_v3(const float axis_values[3], int r_axis_order[3])
Definition: math_vector.c:1090
MINLINE float len_squared_v3(const float v[3]) ATTR_WARN_UNUSED_RESULT
MINLINE void sub_v3_v3v3(float r[3], const float a[3], const float b[3])
MINLINE void negate_v3_v3(float r[3], const float a[3])
MINLINE float dot_v3v3(const float a[3], const float b[3]) ATTR_WARN_UNUSED_RESULT
MINLINE void add_v3_v3v3(float r[3], const float a[3], const float b[3])
MINLINE void cross_v3_v3v3(float r[3], const float a[3], const float b[3])
MINLINE void mul_v3_v3fl(float r[3], const float a[3], float f)
MINLINE void add_v3_v3(float r[3], const float a[3])
BLI_INLINE int BLI_rcti_size_y(const struct rcti *rct)
Definition: BLI_rect.h:157
void BLI_rcti_translate(struct rcti *rect, int x, int y)
Definition: rct.c:597
bool BLI_rcti_isect(const struct rcti *src1, const struct rcti *src2, struct rcti *dest)
BLI_INLINE int BLI_rcti_size_x(const struct rcti *rct)
Definition: BLI_rect.h:153
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
size_t BLI_strcpy_rlen(char *__restrict dst, const char *__restrict src) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL()
Definition: string.c:201
size_t BLI_snprintf(char *__restrict dst, size_t maxncpy, const char *__restrict format,...) ATTR_NONNULL(1
char * BLI_string_join_array(char *result, size_t result_len, const char *strings[], uint strings_len) ATTR_NONNULL()
Definition: string_utils.c:419
unsigned char uchar
Definition: BLI_sys_types.h:86
unsigned int uint
Definition: BLI_sys_types.h:83
void BLI_thread_unlock(int type)
Definition: threads.cc:389
void BLI_thread_lock(int type)
Definition: threads.cc:384
@ LOCK_VIEW3D
Definition: BLI_threads.h:75
#define ARRAY_SIZE(arr)
#define UNUSED_VARS(...)
#define SWAP(type, a, b)
#define UNUSED_VARS_NDEBUG(...)
#define UNUSED(x)
#define MAX2(a, b)
#define ELEM(...)
#define STREQ(a, b)
#define IFACE_(msgid)
struct Depsgraph Depsgraph
Definition: DEG_depsgraph.h:51
struct ID * DEG_get_evaluated_id(const struct Depsgraph *depsgraph, struct ID *id)
struct Object * DEG_get_evaluated_object(const struct Depsgraph *depsgraph, struct Object *object)
struct Scene * DEG_get_evaluated_scene(const struct Depsgraph *graph)
@ CAM_DTX_GOLDEN_TRI_A
@ CAM_DTX_CENTER
@ CAM_DTX_HARMONY_TRI_A
@ CAM_DTX_GOLDEN
@ CAM_DTX_GOLDEN_TRI_B
@ CAM_DTX_HARMONY_TRI_B
@ CAM_DTX_CENTER_DIAG
@ CAM_DTX_THIRDS
@ CAM_SHOWPASSEPARTOUT
@ CAM_SHOW_SAFE_MARGINS
@ CAM_SHOW_SAFE_CENTER
@ CAM_SHOWNAME
@ CAM_SHOWSENSOR
@ CAM_PERSP
@ CAM_PANO
@ CAM_ORTHO
@ CAMERA_SENSOR_FIT_HOR
@ CAMERA_SENSOR_FIT_AUTO
#define CD_MASK_SCULPT_FACE_SETS
#define CD_MASK_PROP_COLOR
#define CD_MASK_ORCO
#define CD_MASK_MDEFORMVERT
#define CD_MASK_MLOOPCOL
#define CD_MASK_MLOOPUV
#define CD_MASK_PAINT_MASK
@ BASE_VISIBLE_DEPSGRAPH
eDrawType
@ OB_WIRE
@ OB_TEXTURE
@ OB_SOLID
@ OB_RENDER
@ OB_MATERIAL
@ OB_MODE_PARTICLE_EDIT
@ OB_MODE_WEIGHT_PAINT
@ OB_MODE_POSE
@ OB_MODE_TEXTURE_PAINT
@ OB_MODE_OBJECT
@ OB_MODE_VERTEX_PAINT
Object is a sort of wrapper for general info.
@ OB_SHAPE_LOCK
@ OB_LATTICE
@ OB_CAMERA
@ OB_ARMATURE
@ OB_MESH
@ OB_CURVE
#define STEREO_LEFT_NAME
#define R_BORDER
@ R_ADDSKY
#define R_MULTIVIEW
#define CFRA
#define OBACT(_view_layer)
@ SCE_VIEWS_FORMAT_STEREO_3D
@ SCE_VIEWS_FORMAT_MULTIVIEW
#define STEREO_RIGHT_NAME
@ STEREO_MONO_ID
@ STEREO_LEFT_ID
@ STEREO_RIGHT_ID
@ STEREO_3D_ID
#define FPS
@ SCE_PASS_COMBINED
@ RGN_TYPE_WINDOW
@ SPACE_VIEW3D
@ USER_SHOW_VIEWPORTNAME
@ USER_DRAWVIEWINFO
@ USER_SHOW_FPS
@ NDOF_SHOW_GUIDE
eUserpref_MiniAxisType
@ USER_MINI_AXIS_TYPE_GIZMO
@ USER_MINI_AXIS_TYPE_MINIMAL
@ USER_MINI_AXIS_TYPE_NONE
eV3DOffscreenDrawFlag
@ V3D_OFSDRAW_OVERRIDE_SCENE_SETTINGS
@ V3D_OFSDRAW_SHOW_GRIDFLOOR
@ V3D_OFSDRAW_SHOW_ANNOTATION
@ V3D_SHADING_BACKGROUND_WORLD
@ V3D_SHADING_TEXTURE_COLOR
@ V3D_SHADING_VERTEX_COLOR
#define V3D_SHOW_ANNOTATION
#define RV3D_VIEW_IS_AXIS(view)
#define V3D_LOCK_CAMERA
@ V3D_OVERLAY_EDIT_WEIGHT
#define RV3D_LOCK_FLAGS(rv3d)
#define RV3D_CAMOB
#define V3D_HIDE_HELPLINES
#define RV3D_ZOFFSET_DISABLED
#define RV3D_VIEW_BACK
#define V3D_SELECT_OUTLINE
#define V3D_SHOW_Z
#define RV3D_VIEW_BOTTOM
#define V3D_RENDER_BORDER
@ RV3D_LOCK_ROTATION
@ V3D_RUNTIME_DEPTHBUF_OVERRIDDEN
#define V3D_SHOW_Y
#define RV3D_VIEW_LEFT
#define RV3D_VIEW_RIGHT
#define V3D_SHOW_X
#define RV3D_PERSP
#define RV3D_VIEW_TOP
#define V3D_HIDE_OVERLAYS
@ V3D_OVERLAY_HIDE_OBJECT_ORIGINS
@ V3D_OVERLAY_HIDE_BONES
@ V3D_OVERLAY_HIDE_MOTION_PATHS
@ V3D_OVERLAY_HIDE_OBJECT_XTRAS
@ V3D_OVERLAY_HIDE_CURSOR
@ V3D_OVERLAY_HIDE_TEXT
@ V3D_OVERLAY_STATS
@ RV3D_VIEW_AXIS_ROLL_180
@ RV3D_VIEW_AXIS_ROLL_90
@ RV3D_VIEW_AXIS_ROLL_0
#define RV3D_VIEW_USER
@ V3D_SHADING_SCENE_WORLD_RENDER
@ V3D_SHADING_SCENE_WORLD
@ V3D_SHADING_SCENE_LIGHTS
@ V3D_SHADING_SCENE_LIGHTS_RENDER
#define RV3D_VIEW_FRONT
#define V3D_SHOW_FLOOR
#define RV3D_ORTHO
@ V3D_GIZMO_HIDE
@ V3D_GIZMO_HIDE_NAVIGATE
void DRW_draw_region_engine_info(int xoffset, int *yoffset, int line_height)
void DRW_draw_view(const struct bContext *C)
void DRW_opengl_context_enable(void)
void DRW_draw_depth_loop_gpencil(struct Depsgraph *depsgraph, struct ARegion *region, struct View3D *v3d, struct GPUViewport *viewport)
void DRW_draw_render_loop_offscreen(struct Depsgraph *depsgraph, struct RenderEngineType *engine_type, struct ARegion *region, struct View3D *v3d, const bool is_image_render, const bool draw_background, const bool do_color_management, struct GPUOffScreen *ofs, struct GPUViewport *viewport)
void DRW_cache_free_old_batches(struct Main *bmain)
Definition: draw_manager.c:981
void DRW_draw_depth_object(struct Scene *scene, struct ARegion *region, struct View3D *v3d, struct GPUViewport *viewport, struct Object *object)
void DRW_draw_depth_loop(struct Depsgraph *depsgraph, struct ARegion *region, struct View3D *v3d, struct GPUViewport *viewport)
void DRW_opengl_context_disable(void)
void DRW_select_buffer_context_create(struct Base **bases, const uint bases_len, short select_mode)
void ED_info_draw_stats(struct Main *bmain, struct Scene *scene, struct ViewLayer *view_layer, int x, int *y, int height)
Definition: info_stats.c:685
@ ANIMFILTER_KEYS_LOCAL
bScreen * ED_screen_animation_no_scrub(const struct wmWindowManager *wm)
void ED_region_pixelspace(struct ARegion *region)
Definition: area.c:137
const rcti * ED_region_visible_rect(ARegion *region)
Definition: area.c:3682
#define REDRAW_FRAME_AVERAGE
#define XRAY_ENABLED(v3d)
Definition: ED_view3d.h:710
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)
eV3DDepthOverrideMode
Definition: ED_view3d.h:147
@ V3D_DEPTH_NO_GPENCIL
Definition: ED_view3d.h:148
@ V3D_DEPTH_GPENCIL_ONLY
Definition: ED_view3d.h:149
@ V3D_DEPTH_OBJECT_ONLY
Definition: ED_view3d.h:150
struct GPUFrameBuffer GPUFrameBuffer
void GPU_framebuffer_restore(void)
GPUFrameBuffer * GPU_framebuffer_active_get(void)
void GPU_framebuffer_free(GPUFrameBuffer *fb)
void GPU_framebuffer_bind(GPUFrameBuffer *fb)
GPUFrameBuffer * GPU_framebuffer_create(const char *name)
void immUniform4f(const char *name, float x, float y, float z, float w)
void immUniformThemeColorAlpha(int color_id, float a)
void immUniform2f(const char *name, float x, float y)
void immUniformThemeColorShadeAlpha(int color_id, int color_offset, int alpha_offset)
void immAttr4ubv(uint attr_id, const unsigned char data[4])
void immUniformColor4f(float r, float g, float b, float a)
void immUnbindProgram(void)
void immVertex2f(uint attr_id, float x, float y)
void immUniformThemeColor(int color_id)
void immBindBuiltinProgram(eGPUBuiltinShader shader_id)
void immVertex2fv(uint attr_id, const float data[2])
void immUniformColor3ubv(const unsigned char rgb[3])
void immUniform1i(const char *name, int x)
void immUniformThemeColor3(int color_id)
void immUniform1f(const char *name, float x)
GPUVertFormat * immVertexFormat(void)
void immUniformColor3f(float r, float g, float b)
void immVertex3fv(uint attr_id, const float data[3])
void immBegin(GPUPrimType, uint vertex_len)
void immEnd(void)
void imm_draw_box_wire_2d(uint pos, float x1, float y1, float x2, float y2)
void immRectf(uint pos, float x1, float y1, float x2, float y2)
_GL_VOID GLfloat value _GL_VOID_RET _GL_VOID const GLuint GLboolean *residences _GL_BOOL_RET _GL_VOID GLsizei GLfloat GLfloat GLfloat GLfloat const GLubyte *bitmap _GL_VOID_RET _GL_VOID GLenum const void *lists _GL_VOID_RET _GL_VOID const GLdouble *equation _GL_VOID_RET _GL_VOID GLdouble GLdouble blue _GL_VOID_RET _GL_VOID GLfloat GLfloat blue _GL_VOID_RET _GL_VOID GLint GLint blue _GL_VOID_RET _GL_VOID GLshort GLshort blue _GL_VOID_RET _GL_VOID GLubyte GLubyte blue _GL_VOID_RET _GL_VOID GLuint GLuint blue _GL_VOID_RET _GL_VOID GLushort GLushort blue _GL_VOID_RET _GL_VOID GLbyte GLbyte GLbyte alpha _GL_VOID_RET _GL_VOID GLdouble GLdouble GLdouble alpha _GL_VOID_RET _GL_VOID GLfloat GLfloat GLfloat alpha _GL_VOID_RET _GL_VOID GLint GLint GLint alpha _GL_VOID_RET _GL_VOID GLshort GLshort GLshort alpha _GL_VOID_RET _GL_VOID GLubyte GLubyte GLubyte alpha _GL_VOID_RET _GL_VOID GLuint GLuint GLuint alpha _GL_VOID_RET _GL_VOID GLushort GLushort GLushort alpha _GL_VOID_RET _GL_VOID GLenum mode _GL_VOID_RET _GL_VOID GLint GLsizei GLsizei GLenum type _GL_VOID_RET _GL_VOID GLsizei GLenum GLenum const void *pixels _GL_VOID_RET _GL_VOID const void *pointer _GL_VOID_RET _GL_VOID GLdouble v _GL_VOID_RET _GL_VOID GLfloat v _GL_VOID_RET _GL_VOID GLint GLint i2 _GL_VOID_RET _GL_VOID GLint j _GL_VOID_RET _GL_VOID GLfloat param _GL_VOID_RET _GL_VOID GLint param _GL_VOID_RET _GL_VOID GLdouble GLdouble GLdouble GLdouble GLdouble zFar _GL_VOID_RET _GL_UINT GLdouble *equation _GL_VOID_RET _GL_VOID GLenum GLint *params _GL_VOID_RET _GL_VOID GLenum GLfloat *v _GL_VOID_RET _GL_VOID GLenum GLfloat *params _GL_VOID_RET _GL_VOID GLfloat *values _GL_VOID_RET _GL_VOID GLushort *values _GL_VOID_RET _GL_VOID GLenum GLfloat *params _GL_VOID_RET _GL_VOID GLenum GLdouble *params _GL_VOID_RET _GL_VOID GLenum GLint *params _GL_VOID_RET _GL_VOID GLsizei const void *pointer _GL_VOID_RET _GL_VOID GLsizei const void *pointer _GL_VOID_RET _GL_BOOL GLfloat param _GL_VOID_RET _GL_VOID GLint param _GL_VOID_RET _GL_VOID GLenum GLfloat param _GL_VOID_RET _GL_VOID GLenum GLint param _GL_VOID_RET _GL_VOID GLushort pattern _GL_VOID_RET _GL_VOID GLdouble GLdouble GLint GLint const GLdouble *points _GL_VOID_RET _GL_VOID GLdouble GLdouble GLint GLint GLdouble GLdouble GLint GLint const GLdouble *points _GL_VOID_RET _GL_VOID GLdouble GLdouble u2 _GL_VOID_RET _GL_VOID GLdouble GLdouble GLint GLdouble GLdouble v2 _GL_VOID_RET _GL_VOID GLenum GLfloat param _GL_VOID_RET _GL_VOID GLenum GLint param _GL_VOID_RET _GL_VOID GLenum mode _GL_VOID_RET _GL_VOID GLdouble GLdouble nz _GL_VOID_RET _GL_VOID GLfloat GLfloat nz _GL_VOID_RET _GL_VOID GLint GLint nz _GL_VOID_RET _GL_VOID GLshort GLshort nz _GL_VOID_RET _GL_VOID GLsizei const void *pointer _GL_VOID_RET _GL_VOID GLsizei const GLfloat *values _GL_VOID_RET _GL_VOID GLsizei const GLushort *values _GL_VOID_RET _GL_VOID GLint param _GL_VOID_RET _GL_VOID const GLuint const GLclampf *priorities _GL_VOID_RET _GL_VOID GLdouble y _GL_VOID_RET _GL_VOID GLfloat y _GL_VOID_RET _GL_VOID GLint y _GL_VOID_RET _GL_VOID GLshort y _GL_VOID_RET _GL_VOID GLdouble GLdouble z _GL_VOID_RET _GL_VOID GLfloat GLfloat z _GL_VOID_RET _GL_VOID GLint GLint z _GL_VOID_RET _GL_VOID GLshort GLshort z _GL_VOID_RET _GL_VOID GLdouble GLdouble GLdouble w _GL_VOID_RET _GL_VOID GLfloat GLfloat GLfloat w _GL_VOID_RET _GL_VOID GLint GLint GLint w _GL_VOID_RET _GL_VOID GLshort GLshort GLshort w _GL_VOID_RET _GL_VOID GLdouble y1
_GL_VOID GLfloat value _GL_VOID_RET _GL_VOID const GLuint GLboolean *residences _GL_BOOL_RET _GL_VOID GLsizei GLfloat GLfloat GLfloat GLfloat const GLubyte *bitmap _GL_VOID_RET _GL_VOID GLenum const void *lists _GL_VOID_RET _GL_VOID const GLdouble *equation _GL_VOID_RET _GL_VOID GLdouble GLdouble blue _GL_VOID_RET _GL_VOID GLfloat GLfloat blue _GL_VOID_RET _GL_VOID GLint GLint blue _GL_VOID_RET _GL_VOID GLshort GLshort blue _GL_VOID_RET _GL_VOID GLubyte GLubyte blue _GL_VOID_RET _GL_VOID GLuint GLuint blue _GL_VOID_RET _GL_VOID GLushort GLushort blue _GL_VOID_RET _GL_VOID GLbyte GLbyte GLbyte alpha _GL_VOID_RET _GL_VOID GLdouble GLdouble GLdouble alpha _GL_VOID_RET _GL_VOID GLfloat GLfloat GLfloat alpha _GL_VOID_RET _GL_VOID GLint GLint GLint alpha _GL_VOID_RET _GL_VOID GLshort GLshort GLshort alpha _GL_VOID_RET _GL_VOID GLubyte GLubyte GLubyte alpha _GL_VOID_RET _GL_VOID GLuint GLuint GLuint alpha _GL_VOID_RET _GL_VOID GLushort GLushort GLushort alpha _GL_VOID_RET _GL_VOID GLenum mode _GL_VOID_RET _GL_VOID GLint GLsizei GLsizei GLenum type _GL_VOID_RET _GL_VOID GLsizei GLenum GLenum const void *pixels _GL_VOID_RET _GL_VOID const void *pointer _GL_VOID_RET _GL_VOID GLdouble v _GL_VOID_RET _GL_VOID GLfloat v _GL_VOID_RET _GL_VOID GLint GLint i2 _GL_VOID_RET _GL_VOID GLint j _GL_VOID_RET _GL_VOID GLfloat param _GL_VOID_RET _GL_VOID GLint param _GL_VOID_RET _GL_VOID GLdouble GLdouble GLdouble GLdouble GLdouble zFar _GL_VOID_RET _GL_UINT GLdouble *equation _GL_VOID_RET _GL_VOID GLenum GLint *params _GL_VOID_RET _GL_VOID GLenum GLfloat *v _GL_VOID_RET _GL_VOID GLenum GLfloat *params _GL_VOID_RET _GL_VOID GLfloat *values _GL_VOID_RET _GL_VOID GLushort *values _GL_VOID_RET _GL_VOID GLenum GLfloat *params _GL_VOID_RET _GL_VOID GLenum GLdouble *params _GL_VOID_RET _GL_VOID GLenum GLint *params _GL_VOID_RET _GL_VOID GLsizei const void *pointer _GL_VOID_RET _GL_VOID GLsizei const void *pointer _GL_VOID_RET _GL_BOOL GLfloat param _GL_VOID_RET _GL_VOID GLint param _GL_VOID_RET _GL_VOID GLenum GLfloat param _GL_VOID_RET _GL_VOID GLenum GLint param _GL_VOID_RET _GL_VOID GLushort pattern _GL_VOID_RET _GL_VOID GLdouble GLdouble GLint GLint const GLdouble *points _GL_VOID_RET _GL_VOID GLdouble GLdouble GLint GLint GLdouble GLdouble GLint GLint const GLdouble *points _GL_VOID_RET _GL_VOID GLdouble GLdouble u2 _GL_VOID_RET _GL_VOID GLdouble GLdouble GLint GLdouble GLdouble v2 _GL_VOID_RET _GL_VOID GLenum GLfloat param _GL_VOID_RET _GL_VOID GLenum GLint param _GL_VOID_RET _GL_VOID GLenum mode _GL_VOID_RET _GL_VOID GLdouble GLdouble nz _GL_VOID_RET _GL_VOID GLfloat GLfloat nz _GL_VOID_RET _GL_VOID GLint GLint nz _GL_VOID_RET _GL_VOID GLshort GLshort nz _GL_VOID_RET _GL_VOID GLsizei const void *pointer _GL_VOID_RET _GL_VOID GLsizei const GLfloat *values _GL_VOID_RET _GL_VOID GLsizei const GLushort *values _GL_VOID_RET _GL_VOID GLint param _GL_VOID_RET _GL_VOID const GLuint const GLclampf *priorities _GL_VOID_RET _GL_VOID GLdouble y _GL_VOID_RET _GL_VOID GLfloat y _GL_VOID_RET _GL_VOID GLint y _GL_VOID_RET _GL_VOID GLshort y _GL_VOID_RET _GL_VOID GLdouble GLdouble z _GL_VOID_RET _GL_VOID GLfloat GLfloat z _GL_VOID_RET _GL_VOID GLint GLint z _GL_VOID_RET _GL_VOID GLshort GLshort z _GL_VOID_RET _GL_VOID GLdouble GLdouble GLdouble w _GL_VOID_RET _GL_VOID GLfloat GLfloat GLfloat w _GL_VOID_RET _GL_VOID GLint GLint GLint w _GL_VOID_RET _GL_VOID GLshort GLshort GLshort w _GL_VOID_RET _GL_VOID GLdouble GLdouble GLdouble y2 _GL_VOID_RET _GL_VOID GLfloat GLfloat GLfloat y2 _GL_VOID_RET _GL_VOID GLint GLint GLint y2 _GL_VOID_RET _GL_VOID GLshort GLshort GLshort y2 _GL_VOID_RET _GL_VOID GLdouble GLdouble GLdouble z _GL_VOID_RET _GL_VOID GLdouble GLdouble z _GL_VOID_RET _GL_VOID GLuint *buffer _GL_VOID_RET _GL_VOID GLdouble t _GL_VOID_RET _GL_VOID GLfloat t _GL_VOID_RET _GL_VOID GLint t _GL_VOID_RET _GL_VOID GLshort t _GL_VOID_RET _GL_VOID GLdouble GLdouble r _GL_VOID_RET _GL_VOID GLfloat GLfloat r _GL_VOID_RET _GL_VOID GLint GLint r _GL_VOID_RET _GL_VOID GLshort GLshort r _GL_VOID_RET _GL_VOID GLdouble GLdouble r
_GL_VOID GLfloat value _GL_VOID_RET _GL_VOID const GLuint GLboolean *residences _GL_BOOL_RET _GL_VOID GLsizei GLfloat GLfloat GLfloat GLfloat const GLubyte *bitmap _GL_VOID_RET _GL_VOID GLenum const void *lists _GL_VOID_RET _GL_VOID const GLdouble *equation _GL_VOID_RET _GL_VOID GLdouble GLdouble blue _GL_VOID_RET _GL_VOID GLfloat GLfloat blue _GL_VOID_RET _GL_VOID GLint GLint blue _GL_VOID_RET _GL_VOID GLshort GLshort blue _GL_VOID_RET _GL_VOID GLubyte GLubyte blue _GL_VOID_RET _GL_VOID GLuint GLuint blue _GL_VOID_RET _GL_VOID GLushort GLushort blue _GL_VOID_RET _GL_VOID GLbyte GLbyte GLbyte alpha _GL_VOID_RET _GL_VOID GLdouble GLdouble GLdouble alpha _GL_VOID_RET _GL_VOID GLfloat GLfloat GLfloat alpha _GL_VOID_RET _GL_VOID GLint GLint GLint alpha _GL_VOID_RET _GL_VOID GLshort GLshort GLshort alpha _GL_VOID_RET _GL_VOID GLubyte GLubyte GLubyte alpha _GL_VOID_RET _GL_VOID GLuint GLuint GLuint alpha _GL_VOID_RET _GL_VOID GLushort GLushort GLushort alpha _GL_VOID_RET _GL_VOID GLenum mode _GL_VOID_RET _GL_VOID GLint GLsizei width
_GL_VOID GLfloat value _GL_VOID_RET _GL_VOID const GLuint GLboolean *residences _GL_BOOL_RET _GL_VOID GLsizei GLfloat GLfloat GLfloat GLfloat const GLubyte *bitmap _GL_VOID_RET _GL_VOID GLenum const void *lists _GL_VOID_RET _GL_VOID const GLdouble *equation _GL_VOID_RET _GL_VOID GLdouble GLdouble blue _GL_VOID_RET _GL_VOID GLfloat GLfloat blue _GL_VOID_RET _GL_VOID GLint GLint blue _GL_VOID_RET _GL_VOID GLshort GLshort blue _GL_VOID_RET _GL_VOID GLubyte GLubyte blue _GL_VOID_RET _GL_VOID GLuint GLuint blue _GL_VOID_RET _GL_VOID GLushort GLushort blue _GL_VOID_RET _GL_VOID GLbyte GLbyte GLbyte alpha _GL_VOID_RET _GL_VOID GLdouble GLdouble GLdouble alpha _GL_VOID_RET _GL_VOID GLfloat GLfloat GLfloat alpha _GL_VOID_RET _GL_VOID GLint GLint GLint alpha _GL_VOID_RET _GL_VOID GLshort GLshort GLshort alpha _GL_VOID_RET _GL_VOID GLubyte GLubyte GLubyte alpha _GL_VOID_RET _GL_VOID GLuint GLuint GLuint alpha _GL_VOID_RET _GL_VOID GLushort GLushort GLushort alpha _GL_VOID_RET _GL_VOID GLenum mode _GL_VOID_RET _GL_VOID GLint GLsizei GLsizei GLenum type _GL_VOID_RET _GL_VOID GLsizei GLenum GLenum const void *pixels _GL_VOID_RET _GL_VOID const void *pointer _GL_VOID_RET _GL_VOID GLdouble v _GL_VOID_RET _GL_VOID GLfloat v _GL_VOID_RET _GL_VOID GLint GLint i2 _GL_VOID_RET _GL_VOID GLint j _GL_VOID_RET _GL_VOID GLfloat param _GL_VOID_RET _GL_VOID GLint param _GL_VOID_RET _GL_VOID GLdouble GLdouble GLdouble GLdouble GLdouble zFar _GL_VOID_RET _GL_UINT GLdouble *equation _GL_VOID_RET _GL_VOID GLenum GLint *params _GL_VOID_RET _GL_VOID GLenum GLfloat *v _GL_VOID_RET _GL_VOID GLenum GLfloat *params _GL_VOID_RET _GL_VOID GLfloat *values _GL_VOID_RET _GL_VOID GLushort *values _GL_VOID_RET _GL_VOID GLenum GLfloat *params _GL_VOID_RET _GL_VOID GLenum GLdouble *params _GL_VOID_RET _GL_VOID GLenum GLint *params _GL_VOID_RET _GL_VOID GLsizei const void *pointer _GL_VOID_RET _GL_VOID GLsizei const void *pointer _GL_VOID_RET _GL_BOOL GLfloat param _GL_VOID_RET _GL_VOID GLint param _GL_VOID_RET _GL_VOID GLenum GLfloat param _GL_VOID_RET _GL_VOID GLenum GLint param _GL_VOID_RET _GL_VOID GLushort pattern _GL_VOID_RET _GL_VOID GLdouble GLdouble GLint GLint const GLdouble *points _GL_VOID_RET _GL_VOID GLdouble GLdouble GLint GLint GLdouble GLdouble GLint GLint const GLdouble *points _GL_VOID_RET _GL_VOID GLdouble GLdouble u2 _GL_VOID_RET _GL_VOID GLdouble GLdouble GLint GLdouble GLdouble v2 _GL_VOID_RET _GL_VOID GLenum GLfloat param _GL_VOID_RET _GL_VOID GLenum GLint param _GL_VOID_RET _GL_VOID GLenum mode _GL_VOID_RET _GL_VOID GLdouble GLdouble nz _GL_VOID_RET _GL_VOID GLfloat GLfloat nz _GL_VOID_RET _GL_VOID GLint GLint nz _GL_VOID_RET _GL_VOID GLshort GLshort nz _GL_VOID_RET _GL_VOID GLsizei const void *pointer _GL_VOID_RET _GL_VOID GLsizei const GLfloat *values _GL_VOID_RET _GL_VOID GLsizei const GLushort *values _GL_VOID_RET _GL_VOID GLint param _GL_VOID_RET _GL_VOID const GLuint const GLclampf *priorities _GL_VOID_RET _GL_VOID GLdouble y _GL_VOID_RET _GL_VOID GLfloat y _GL_VOID_RET _GL_VOID GLint y _GL_VOID_RET _GL_VOID GLshort y _GL_VOID_RET _GL_VOID GLdouble GLdouble z _GL_VOID_RET _GL_VOID GLfloat GLfloat z _GL_VOID_RET _GL_VOID GLint GLint z _GL_VOID_RET _GL_VOID GLshort GLshort z _GL_VOID_RET _GL_VOID GLdouble GLdouble GLdouble w _GL_VOID_RET _GL_VOID GLfloat GLfloat GLfloat w _GL_VOID_RET _GL_VOID GLint GLint GLint w _GL_VOID_RET _GL_VOID GLshort GLshort GLshort w _GL_VOID_RET _GL_VOID GLdouble GLdouble x2
_GL_VOID GLfloat value _GL_VOID_RET _GL_VOID const GLuint GLboolean *residences _GL_BOOL_RET _GL_VOID GLsizei GLfloat GLfloat GLfloat GLfloat const GLubyte *bitmap _GL_VOID_RET _GL_VOID GLenum type
_GL_VOID GLfloat value _GL_VOID_RET _GL_VOID const GLuint GLboolean *residences _GL_BOOL_RET _GL_VOID GLsizei height
_GL_VOID GLfloat value _GL_VOID_RET _GL_VOID const GLuint GLboolean *residences _GL_BOOL_RET _GL_VOID GLsizei GLfloat GLfloat GLfloat GLfloat const GLubyte *bitmap _GL_VOID_RET _GL_VOID GLenum const void *lists _GL_VOID_RET _GL_VOID const GLdouble *equation _GL_VOID_RET _GL_VOID GLdouble GLdouble blue _GL_VOID_RET _GL_VOID GLfloat GLfloat blue _GL_VOID_RET _GL_VOID GLint GLint blue _GL_VOID_RET _GL_VOID GLshort GLshort blue _GL_VOID_RET _GL_VOID GLubyte GLubyte blue _GL_VOID_RET _GL_VOID GLuint GLuint blue _GL_VOID_RET _GL_VOID GLushort GLushort blue _GL_VOID_RET _GL_VOID GLbyte GLbyte GLbyte alpha _GL_VOID_RET _GL_VOID GLdouble GLdouble GLdouble alpha _GL_VOID_RET _GL_VOID GLfloat GLfloat GLfloat alpha _GL_VOID_RET _GL_VOID GLint GLint GLint alpha _GL_VOID_RET _GL_VOID GLshort GLshort GLshort alpha _GL_VOID_RET _GL_VOID GLubyte GLubyte GLubyte alpha _GL_VOID_RET _GL_VOID GLuint GLuint GLuint alpha _GL_VOID_RET _GL_VOID GLushort GLushort GLushort alpha _GL_VOID_RET _GL_VOID GLenum mode _GL_VOID_RET _GL_VOID GLint y
_GL_VOID GLfloat value _GL_VOID_RET _GL_VOID const GLuint GLboolean *residences _GL_BOOL_RET _GL_VOID GLsizei GLfloat GLfloat GLfloat GLfloat const GLubyte *bitmap _GL_VOID_RET _GL_VOID GLenum const void *lists _GL_VOID_RET _GL_VOID const GLdouble *equation _GL_VOID_RET _GL_VOID GLdouble GLdouble blue _GL_VOID_RET _GL_VOID GLfloat GLfloat blue _GL_VOID_RET _GL_VOID GLint GLint blue _GL_VOID_RET _GL_VOID GLshort GLshort blue _GL_VOID_RET _GL_VOID GLubyte GLubyte blue _GL_VOID_RET _GL_VOID GLuint GLuint blue _GL_VOID_RET _GL_VOID GLushort GLushort blue _GL_VOID_RET _GL_VOID GLbyte GLbyte GLbyte alpha _GL_VOID_RET _GL_VOID GLdouble GLdouble GLdouble alpha _GL_VOID_RET _GL_VOID GLfloat GLfloat GLfloat alpha _GL_VOID_RET _GL_VOID GLint GLint GLint alpha _GL_VOID_RET _GL_VOID GLshort GLshort GLshort alpha _GL_VOID_RET _GL_VOID GLubyte GLubyte GLubyte alpha _GL_VOID_RET _GL_VOID GLuint GLuint GLuint alpha _GL_VOID_RET _GL_VOID GLushort GLushort GLushort alpha _GL_VOID_RET _GL_VOID GLenum mode _GL_VOID_RET _GL_VOID GLint GLsizei GLsizei GLenum type _GL_VOID_RET _GL_VOID GLsizei GLenum GLenum const void *pixels _GL_VOID_RET _GL_VOID const void *pointer _GL_VOID_RET _GL_VOID GLdouble v _GL_VOID_RET _GL_VOID GLfloat v _GL_VOID_RET _GL_VOID GLint GLint i2 _GL_VOID_RET _GL_VOID GLint j _GL_VOID_RET _GL_VOID GLfloat param _GL_VOID_RET _GL_VOID GLint param _GL_VOID_RET _GL_VOID GLdouble GLdouble GLdouble GLdouble GLdouble zFar _GL_VOID_RET _GL_UINT GLdouble *equation _GL_VOID_RET _GL_VOID GLenum GLint *params _GL_VOID_RET _GL_VOID GLenum GLfloat *v _GL_VOID_RET _GL_VOID GLenum GLfloat *params _GL_VOID_RET _GL_VOID GLfloat *values _GL_VOID_RET _GL_VOID GLushort *values _GL_VOID_RET _GL_VOID GLenum GLfloat *params _GL_VOID_RET _GL_VOID GLenum GLdouble *params _GL_VOID_RET _GL_VOID GLenum GLint *params _GL_VOID_RET _GL_VOID GLsizei const void *pointer _GL_VOID_RET _GL_VOID GLsizei const void *pointer _GL_VOID_RET _GL_BOOL GLfloat param _GL_VOID_RET _GL_VOID GLint param _GL_VOID_RET _GL_VOID GLenum GLfloat param _GL_VOID_RET _GL_VOID GLenum GLint param _GL_VOID_RET _GL_VOID GLushort pattern _GL_VOID_RET _GL_VOID GLdouble GLdouble GLint GLint const GLdouble *points _GL_VOID_RET _GL_VOID GLdouble GLdouble GLint GLint GLdouble v1
void GPU_pass_cache_garbage_collect(void)
Definition: gpu_codegen.c:1068
void GPU_matrix_pop(void)
Definition: gpu_matrix.cc:142
void GPU_matrix_pop_projection(void)
Definition: gpu_matrix.cc:156
#define GPU_matrix_set(x)
Definition: GPU_matrix.h:224
void GPU_matrix_push(void)
Definition: gpu_matrix.cc:135
#define GPU_matrix_projection_set(x)
Definition: GPU_matrix.h:225
void GPU_matrix_identity_set(void)
Definition: gpu_matrix.cc:184
void GPU_matrix_push_projection(void)
Definition: gpu_matrix.cc:149
@ GPU_PRIM_LINE_LOOP
Definition: GPU_primitive.h:39
@ GPU_PRIM_LINES
Definition: GPU_primitive.h:36
@ GPU_PRIM_POINTS
Definition: GPU_primitive.h:35
@ GPU_PRIM_LINE_STRIP
Definition: GPU_primitive.h:38
@ GPU_SHADER_3D_SMOOTH_COLOR
Definition: GPU_shader.h:215
@ GPU_SHADER_2D_LINE_DASHED_UNIFORM_COLOR
Definition: GPU_shader.h:365
@ GPU_SHADER_2D_UNIFORM_COLOR
Definition: GPU_shader.h:171
@ GPU_SHADER_3D_POINT_FIXED_SIZE_VARYING_COLOR
Definition: GPU_shader.h:325
@ GPU_SHADER_2D_FLAT_COLOR
Definition: GPU_shader.h:178
@ GPU_BLEND_NONE
Definition: GPU_state.h:55
@ GPU_BLEND_ALPHA
Definition: GPU_state.h:57
void GPU_blend(eGPUBlend blend)
Definition: gpu_state.cc:55
void GPU_line_width(float width)
Definition: gpu_state.cc:173
void GPU_line_smooth(bool enable)
Definition: gpu_state.cc:85
void GPU_depth_mask(bool depth)
Definition: gpu_state.cc:117
void GPU_point_size(float size)
Definition: gpu_state.cc:179
@ GPU_DEPTH_NONE
Definition: GPU_state.h:78
void GPU_depth_test(eGPUDepthTest test)
Definition: gpu_state.cc:75
void GPU_viewport_size_get_f(float coords[4])
Definition: gpu_state.cc:279
@ GPU_DATA_UBYTE
Definition: GPU_texture.h:175
@ GPU_DATA_FLOAT
Definition: GPU_texture.h:172
@ GPU_FETCH_FLOAT
@ GPU_FETCH_INT_TO_FLOAT_UNIT
uint GPU_vertformat_attr_add(GPUVertFormat *, const char *name, GPUVertCompType, uint comp_len, GPUVertFetchMode)
@ GPU_COMP_F32
@ GPU_COMP_U8
void * GPU_viewport_texture_list_get(GPUViewport *viewport)
Definition: gpu_viewport.c:331
void * GPU_viewport_framebuffer_list_get(GPUViewport *viewport)
Definition: gpu_viewport.c:326
struct ImBuf * IMB_allocImBuf(unsigned int x, unsigned int y, unsigned char planes, unsigned int flags)
Definition: allocimbuf.c:478
void IMB_rect_from_float(struct ImBuf *ibuf)
Definition: divers.c:720
Contains defines and structs used throughout the imbuf module.
eImBufFlags
Read Guarded memory(de)allocation.
#define RE_USE_EEVEE_VIEWPORT
Definition: RE_engine.h:61
#define C
Definition: RandGen.cpp:39
#define UI_UNIT_Y
#define UI_UNIT_X
void UI_draw_safe_areas(uint pos, const struct rctf *rect, const float title_aspect[2], const float action_aspect[2])
@ TH_TIME_KEYFRAME
Definition: UI_resources.h:117
@ TH_BACK
Definition: UI_resources.h:55
@ TH_TIME_GP_KEYFRAME
Definition: UI_resources.h:118
@ TH_REDALERT
Definition: UI_resources.h:50
@ TH_AXIS_X
Definition: UI_resources.h:316
@ TH_VIEW_OVERLAY
Definition: UI_resources.h:343
@ TH_TEXT_HI
Definition: UI_resources.h:59
void UI_Theme_Restore(struct bThemeState *theme_state)
Definition: resources.c:1098
void UI_FontThemeColor(int fontid, int colorid)
Definition: resources.c:1156
void UI_GetThemeColorShade3ubv(int colorid, int offset, unsigned char col[3])
Definition: resources.c:1235
void UI_SetTheme(int spacetype, int regionid)
Definition: resources.c:1064
void UI_Theme_Store(struct bThemeState *theme_state)
Definition: resources.c:1094
ATTR_WARN_UNUSED_RESULT const BMVert * v2
unsigned int U
Definition: btGjkEpa3.h:78
SIMD_FORCE_INLINE const btScalar & w() const
Return the w value.
Definition: btQuadWord.h:119
SIMD_FORCE_INLINE btScalar angle(const btVector3 &v) const
Return the angle between this and another vector.
Definition: btVector3.h:356
static float is_left(const float p0[2], const float p1[2], const float p2[2])
Definition: convexhull_2d.c:51
Scene scene
const Depsgraph * depsgraph
static CCL_NAMESPACE_BEGIN const double alpha
uchar view3d_camera_border_hack_col[3]
Definition: drawobject.c:104
bool view3d_camera_border_hack_test
Definition: drawobject.c:105
RenderEngineType * RE_engines_find(const char *idname)
Definition: engine.c:108
bool ED_gpencil_has_keyframe_v3d(Scene *UNUSED(scene), Object *ob, int cfra)
uint pos
uint col
void GPU_offscreen_free(GPUOffScreen *ofs)
void GPU_offscreen_unbind(GPUOffScreen *UNUSED(ofs), bool restore)
void GPU_framebuffer_texture_attach(GPUFrameBuffer *fb, GPUTexture *tex, int slot, int mip)
void GPU_offscreen_read_pixels(GPUOffScreen *ofs, eGPUDataFormat format, void *pixels)
GPUOffScreen * GPU_offscreen_create(int width, int height, bool depth, bool high_bitdepth, char err_out[256])
int GPU_offscreen_width(const GPUOffScreen *ofs)
void GPU_offscreen_bind(GPUOffScreen *ofs, bool save)
int GPU_offscreen_height(const GPUOffScreen *ofs)
void GPU_framebuffer_read_depth(GPUFrameBuffer *gpu_fb, int x, int y, int w, int h, eGPUDataFormat format, void *data)
uiWidgetBaseParameters params[MAX_WIDGET_BASE_BATCH]
#define sinf(x)
#define cosf(x)
#define powf(x, y)
#define ceilf(x)
#define hypotf(x, y)
#define floorf(x)
#define acosf(x)
#define fabsf(x)
#define sqrtf(x)
bool id_frame_has_keyframe(ID *id, float frame, short filter)
Definition: keyframing.c:2969
format
Definition: logImageCore.h:47
static char ** names
Definition: makesdna.c:162
void(* MEM_freeN)(void *vmemh)
Definition: mallocn.c:41
void *(* MEM_callocN)(size_t len, const char *str)
Definition: mallocn.c:45
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])
const char * RE_engine_id_BLENDER_EEVEE
Definition: scene.c:1742
void * regiondata
short regiontype
char name[64]
char sensor_fit
float sensor_y
float shiftx
float passepartalpha
float sensor_x
struct GPUFrameBuffer * depth_only_fb
struct GPUTexture * depth
char name[64]
Definition: BKE_armature.h:57
Definition: DNA_ID.h:273
char name[66]
Definition: DNA_ID.h:283
unsigned int * rect
float * rect_float
char name[64]
Definition: DNA_key_types.h:68
ListBase block
struct Collection * collection
void * last
Definition: DNA_listBase.h:47
void * first
Definition: DNA_listBase.h:47
Definition: BKE_main.h:116
short base_flag
short shapenr
float obmat[4][4]
void * data
char shapeflag
float viewinv[4][4]
Definition: view3d_draw.c:2467
float persinv[4][4]
Definition: view3d_draw.c:2469
float viewmat[4][4]
Definition: view3d_draw.c:2466
float persmat[4][4]
Definition: view3d_draw.c:2468
float viewcamtexcofac[4]
Definition: view3d_draw.c:2470
float winmat[4][4]
Definition: view3d_draw.c:2465
float viewcamtexcofac[4]
float viewquat[4]
float persmat[4][4]
float clip[6][4]
float persinv[4][4]
float viewmat[4][4]
struct ViewDepths * depths
float clip_local[6][4]
float viewinv[4][4]
float winmat[4][4]
char engine[32]
short views_format
View3DShading shading
struct SceneDisplay display
void * fps_info
struct RenderData r
struct UnitSettings unit
struct DisplaySafeAreas safe_areas
float redrawtimes_fps[REDRAW_FRAME_AVERAGE]
float gpencil_vertex_paint_opacity
char multiview_eye
View3DOverlay overlay
rctf render_border
float clip_end
View3D_Runtime runtime
struct Object * camera
short gridsubdiv
char stereo3d_camera
struct View3D * localvd
short gridlines
ListBase regionbase
char gizmo_flag
View3DShading shading
float clip_start
struct Depsgraph * depsgraph
Definition: ED_view3d.h:75
struct ARegion * region
Definition: ED_view3d.h:80
struct ViewLayer * view_layer
Definition: ED_view3d.h:77
struct Object * obact
Definition: ED_view3d.h:78
struct View3D * v3d
Definition: ED_view3d.h:81
short y
Definition: ED_view3d.h:90
bool damaged
Definition: ED_view3d.h:94
unsigned short w
Definition: ED_view3d.h:89
float * depths
Definition: ED_view3d.h:91
short x
Definition: ED_view3d.h:90
double depth_range[2]
Definition: ED_view3d.h:92
unsigned short h
Definition: ED_view3d.h:89
LayerCollection * active_collection
struct EditBone * act_edbone
unsigned int layer
ListBase * edbo
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
static void draw_background(const rcti *rect)
Definition: time_scrub_ui.c:63
#define G(x, y, z)
uint len
static void draw_viewport_name(ARegion *region, View3D *v3d, int xoffset, int *yoffset)
Definition: view3d_draw.c:1251
void ED_view3d_calc_camera_border_size(const Scene *scene, Depsgraph *depsgraph, const ARegion *region, const View3D *v3d, const RegionView3D *rv3d, float r_size[2])
Definition: view3d_draw.c:434
void ED_view3d_draw_offscreen_simple(Depsgraph *depsgraph, Scene *scene, View3DShading *shading_override, int drawtype, int winx, int winy, uint draw_flags, const float viewmat[4][4], const float winmat[4][4], float clip_start, float clip_end, bool is_image_render, bool draw_background, const char *viewname, const bool do_color_management, GPUOffScreen *ofs, GPUViewport *viewport)
Definition: view3d_draw.c:1745
void ED_view3d_depth_override(Depsgraph *depsgraph, ARegion *region, View3D *v3d, Object *obact, eV3DDepthOverrideMode mode, bool update_cache)
Definition: view3d_draw.c:2331
void view3d_update_depths_rect(ARegion *region, ViewDepths *d, rcti *rect)
Definition: view3d_draw.c:2212
static void view3d_draw_border(const bContext *C, ARegion *region)
Definition: view3d_draw.c:1136
float ED_view3d_grid_scale(const Scene *scene, View3D *v3d, const char **r_grid_unit)
Definition: view3d_draw.c:863
bool ED_view3d_calc_render_border(const Scene *scene, Depsgraph *depsgraph, View3D *v3d, ARegion *region, rcti *rect)
Definition: view3d_draw.c:2576
static void drawviewborder(Scene *scene, Depsgraph *depsgraph, ARegion *region, View3D *v3d)
Definition: view3d_draw.c:539
static void view3d_main_region_setup_view(Depsgraph *depsgraph, Scene *scene, View3D *v3d, ARegion *region, const float viewmat[4][4], const float winmat[4][4], const rcti *rect)
Definition: view3d_draw.c:196
static bool view3d_stereo3d_active(wmWindow *win, const Scene *scene, View3D *v3d, RegionView3D *rv3d)
Definition: view3d_draw.c:228
static void view3d_draw_grease_pencil(const bContext *UNUSED(C))
Definition: view3d_draw.c:1160
void view3d_draw_region_info(const bContext *C, ARegion *region)
Definition: view3d_draw.c:1467
static void view3d_stereo3d_setup(Depsgraph *depsgraph, Scene *scene, View3D *v3d, ARegion *region, const rcti *rect)
Definition: view3d_draw.c:272
void view3d_main_region_draw(const bContext *C, ARegion *region)
Definition: view3d_draw.c:1577
RenderEngineType * ED_view3d_engine_type(const Scene *scene, int drawtype)
Definition: view3d_draw.c:1563
static void view3d_stereo3d_setup_offscreen(Depsgraph *depsgraph, const Scene *scene, View3D *v3d, ARegion *region, const float winmat[4][4], const char *viewname)
Definition: view3d_draw.c:1601
static void view3d_main_region_setup_offscreen(Depsgraph *depsgraph, const Scene *scene, View3D *v3d, ARegion *region, const float viewmat[4][4], const float winmat[4][4])
Definition: view3d_draw.c:213
float view3d_depth_near(ViewDepths *d)
Definition: view3d_draw.c:2300
#define VIEW3D_OVERLAY_LINEHEIGHT
Definition: view3d_draw.c:105
static void draw_selected_name(Scene *scene, ViewLayer *view_layer, Object *ob, int xoffset, int *yoffset)
Definition: view3d_draw.c:1310
static void view3d_camera_border(const Scene *scene, struct Depsgraph *depsgraph, const ARegion *region, const View3D *v3d, const RegionView3D *rv3d, rctf *r_viewborder, const bool no_shift, const bool no_zoom)
Definition: view3d_draw.c:387
void ED_view3d_calc_camera_border(const Scene *scene, Depsgraph *depsgraph, const ARegion *region, const View3D *v3d, const RegionView3D *rv3d, rctf *r_viewborder, const bool no_shift)
Definition: view3d_draw.c:448
static bool view3d_clipping_test(const float co[3], const float clip[6][4])
Definition: view3d_draw.c:2092
static void view3d_draw_view(const bContext *C, ARegion *region)
Definition: view3d_draw.c:1547
void ED_view3d_datamask(const bContext *C, const Scene *UNUSED(scene), const View3D *v3d, CustomData_MeshMasks *r_cddata_masks)
Definition: view3d_draw.c:2406
static void validate_object_select_id(struct Depsgraph *depsgraph, ViewLayer *view_layer, ARegion *region, View3D *v3d, Object *obact)
Definition: view3d_draw.c:2130
void ED_view3d_draw_setup_view(const wmWindowManager *wm, wmWindow *win, Depsgraph *depsgraph, Scene *scene, ARegion *region, View3D *v3d, const float viewmat[4][4], const float winmat[4][4], const rcti *rect)
Definition: view3d_draw.c:350
static void draw_grid_unit_name(Scene *scene, ARegion *region, View3D *v3d, int xoffset, int *yoffset)
Definition: view3d_draw.c:1436
void ED_view3d_grid_steps(const Scene *scene, View3D *v3d, RegionView3D *rv3d, float r_grid_steps[STEPS_LEN])
Definition: view3d_draw.c:869
#define STEPS_LEN
Definition: view3d_draw.c:868
int ED_view3d_backbuf_sample_size_clamp(ARegion *region, const float dist)
Definition: view3d_draw.c:2201
void ED_view3d_select_id_validate(ViewContext *vc)
Definition: view3d_draw.c:2192
float ED_view3d_grid_view_scale(Scene *scene, View3D *v3d, ARegion *region, const char **r_grid_unit)
Definition: view3d_draw.c:917
void ED_view3d_draw_offscreen(Depsgraph *depsgraph, const Scene *scene, eDrawType drawtype, View3D *v3d, ARegion *region, int winx, int winy, const float viewmat[4][4], const float winmat[4][4], bool is_image_render, bool draw_background, const char *viewname, const bool do_color_management, const bool restore_rv3d_mats, GPUOffScreen *ofs, GPUViewport *viewport)
Definition: view3d_draw.c:1625
ImBuf * ED_view3d_draw_offscreen_imbuf(Depsgraph *depsgraph, Scene *scene, eDrawType drawtype, View3D *v3d, ARegion *region, int sizex, int sizey, eImBufFlags imbuf_flag, int alpha_mode, const char *viewname, const bool restore_rv3d_mats, GPUOffScreen *ofs, char err_out[256])
Definition: view3d_draw.c:1834
static bool view3d_main_region_do_render_draw(const Scene *scene)
Definition: view3d_draw.c:2570
bool ED_view3d_clipping_test(const RegionView3D *rv3d, const float co[3], const bool is_local)
Definition: view3d_draw.c:2116
static void draw_view_axis(RegionView3D *rv3d, const rcti *rect)
Definition: view3d_draw.c:957
static void view3d_depth_cache_update(ARegion *region)
Definition: view3d_draw.c:2266
static void drawviewborder_grid3(uint shdr_pos, float x1, float x2, float y1, float y2, float fac)
Definition: view3d_draw.c:459
void ED_view3d_screen_datamask(const bContext *C, const Scene *scene, const bScreen *screen, CustomData_MeshMasks *r_cddata_masks)
Definition: view3d_draw.c:2436
void ED_view3d_mats_rv3d_restore(struct RegionView3D *rv3d, struct RV3DMatrixStore *rv3dmat_pt)
Definition: view3d_draw.c:2487
static void drawviewborder_triangle(uint shdr_pos, float x1, float x2, float y1, float y2, const char golden, const char dir)
Definition: view3d_draw.c:486
struct RV3DMatrixStore * ED_view3d_mats_rv3d_backup(struct RegionView3D *rv3d)
Definition: view3d_draw.c:2474
void ED_view3d_update_viewmat(Depsgraph *depsgraph, const Scene *scene, View3D *v3d, ARegion *region, const float viewmat[4][4], const float winmat[4][4], const rcti *rect, bool offscreen)
Definition: view3d_draw.c:114
#define M_GOLDEN_RATIO_CONJUGATE
Definition: view3d_draw.c:103
ImBuf * ED_view3d_draw_offscreen_imbuf_simple(Depsgraph *depsgraph, Scene *scene, View3DShading *shading_override, eDrawType drawtype, Object *camera, int width, int height, eImBufFlags imbuf_flag, eV3DOffscreenDrawFlag draw_flags, int alpha_mode, const char *viewname, GPUOffScreen *ofs, char err_out[256])
Definition: view3d_draw.c:1991
void ED_scene_draw_fps(const Scene *scene, int xoffset, int *yoffset)
Definition: view3d_draw.c:2509
static void drawrenderborder(ARegion *region, View3D *v3d)
Definition: view3d_draw.c:807
static const char * view3d_get_name(View3D *v3d, RegionView3D *rv3d)
Definition: view3d_draw.c:1168
float ED_scene_grid_scale(const Scene *scene, const char **r_grid_unit)
Definition: view3d_draw.c:842
static void view3d_opengl_read_Z_pixels(GPUViewport *viewport, rcti *rect, void *data)
Definition: view3d_draw.c:2172
void view3d_winmatrix_set(struct Depsgraph *depsgraph, struct ARegion *region, const View3D *v3d, const rcti *rect)
Definition: view3d_view.c:716
void view3d_viewmatrix_set(struct Depsgraph *depsgraph, const struct Scene *scene, const View3D *v3d, RegionView3D *rv3d, const float rect_scale[2])
void WM_draw_region_viewport_unbind(ARegion *region)
Definition: wm_draw.c:1141
void WM_draw_region_viewport_bind(ARegion *region)
Definition: wm_draw.c:1136
GPUViewport * WM_draw_region_get_viewport(ARegion *region)
Definition: wm_draw.c:634
void WM_draw_region_viewport_ensure(ARegion *region, short space_type)
Definition: wm_draw.c:1130
bool WM_stereo3d_enabled(wmWindow *win, bool skip_stereo3d_check)
Definition: wm_stereo.c:156
bool WM_xr_session_state_viewer_pose_matrix_info_get(const wmXrData *xr, float r_viewmat[4][4], float *r_focal_len)