Blender  V2.93
ED_view3d.h
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 #pragma once
25 
26 #ifdef __cplusplus
27 extern "C" {
28 #endif
29 
30 /* ********* exports for space_view3d/ module ********** */
31 struct ARegion;
32 struct BMEdge;
33 struct BMElem;
34 struct BMFace;
35 struct BMVert;
36 struct BPoint;
37 struct Base;
38 struct BezTriple;
39 struct BoundBox;
40 struct Camera;
42 struct Depsgraph;
43 struct EditBone;
44 struct ID;
45 struct MVert;
46 struct Main;
47 struct MetaElem;
48 struct Nurb;
49 struct Object;
50 struct RV3DMatrixStore;
51 struct RegionView3D;
52 struct RenderEngineType;
53 struct Scene;
54 struct ScrArea;
55 struct View3D;
56 struct ViewContext;
57 struct ViewLayer;
58 struct bContext;
59 struct bPoseChannel;
60 struct bScreen;
61 struct rctf;
62 struct rcti;
63 struct wmGizmo;
64 struct wmWindow;
65 struct wmWindowManager;
66 
67 /* for derivedmesh drawing callbacks, for view3d_select, .... */
68 typedef struct ViewContext {
69  struct bContext *C;
70  struct Main *bmain;
71  /* Dependency graph is uses for depth drawing, viewport camera matrix access, and also some areas
72  * are re-using this to access evaluated entities.
73  *
74  * Moral of the story: assign to a fully evaluated state. */
76  struct Scene *scene;
78  struct Object *obact;
79  struct Object *obedit;
80  struct ARegion *region;
81  struct View3D *v3d;
82  struct wmWindow *win;
83  struct RegionView3D *rv3d;
84  struct BMEditMesh *em;
85  int mval[2];
87 
88 typedef struct ViewDepths {
89  unsigned short w, h;
90  short x, y; /* only for temp use for sub-rects, added to region->winx/y */
91  float *depths;
92  double depth_range[2];
93 
94  bool damaged;
96 
97 /* Rotate 3D cursor on placement. */
103 };
104 
106  const struct View3D *v3d,
107  float r_color[3]);
109  const struct Object *ob,
110  const struct View3D *v3d);
112  const int mval[2],
113  const bool use_depth,
114  float r_cursor_co[3]);
116  const int mval[2],
117  const bool use_depth,
118  enum eV3DCursorOrient orientation,
119  float r_cursor_co[3],
120  float r_cursor_quat[4]);
122  const int mval[2],
123  const bool use_depth,
124  enum eV3DCursorOrient orientation);
125 
126 struct Camera *ED_view3d_camera_data_get(struct View3D *v3d, struct RegionView3D *rv3d);
127 
128 void ED_view3d_to_m4(float mat[4][4], const float ofs[3], const float quat[4], const float dist);
129 void ED_view3d_from_m4(const float mat[4][4], float ofs[3], float quat[4], const float *dist);
130 
132  const struct Object *ob, float ofs[3], float quat[4], float *dist, float *lens);
134  struct Object *ob,
135  const float ofs[3],
136  const float quat[4],
137  const float dist);
138 
140  struct Depsgraph *depsgraph,
141  const struct Scene *scene,
142  struct Object *camera_ob);
143 
144 void ED_view3d_lastview_store(struct RegionView3D *rv3d);
145 
146 /* Depth buffer */
147 typedef enum {
153  struct ARegion *region,
154  struct View3D *v3d,
155  struct Object *obact,
157  bool update_cache);
159  const int mval[2],
160  int margin,
161  float *r_depth);
163  const int mval[2],
164  float r_normal[3]);
165 bool ED_view3d_depth_unproject(const struct ARegion *region,
166  const int mval[2],
167  const double depth,
168  float r_location_world[3]);
169 void ED_view3d_depth_tag_update(struct RegionView3D *rv3d);
170 
171 /* Projection */
172 #define IS_CLIPPED 12000
173 
174 /* return values for ED_view3d_project_...() */
175 typedef enum {
190 
191 /* some clipping tests are optional */
192 typedef enum {
199 } eV3DProjTest;
200 
201 #define V3D_PROJ_TEST_CLIP_DEFAULT \
202  (V3D_PROJ_TEST_CLIP_BB | V3D_PROJ_TEST_CLIP_WIN | V3D_PROJ_TEST_CLIP_NEAR)
203 #define V3D_PROJ_TEST_ALL \
204  (V3D_PROJ_TEST_CLIP_DEFAULT | V3D_PROJ_TEST_CLIP_FAR | V3D_PROJ_TEST_CLIP_ZERO)
205 
206 /* view3d_iterators.c */
207 
208 /* foreach iterators */
210  struct ViewContext *vc,
211  void (*func)(void *userData, struct MVert *eve, const float screen_co[2], int index),
212  void *userData,
213  const eV3DProjTest clip_flag);
215  struct ViewContext *vc,
216  void (*func)(void *userData, struct BMVert *eve, const float screen_co[2], int index),
217  void *userData,
218  const eV3DProjTest clip_flag);
220  void (*func)(void *userData,
221  struct BMEdge *eed,
222  const float screen_co_a[2],
223  const float screen_co_b[2],
224  int index),
225  void *userData,
226  const eV3DProjTest clip_flag);
227 
229  void (*func)(void *userData,
230  struct BMEdge *eed,
231  const float screen_co_a[2],
232  const float screen_co_b[2],
233  int index),
234  void *userData,
235  const eV3DProjTest clip_flag);
236 
238  struct ViewContext *vc,
239  void (*func)(void *userData, struct BMFace *efa, const float screen_co[2], int index),
240  void *userData,
241  const eV3DProjTest clip_flag);
243  void (*func)(void *userData,
244  struct Nurb *nu,
245  struct BPoint *bp,
246  struct BezTriple *bezt,
247  int beztindex,
248  bool handle_visible,
249  const float screen_co[2]),
250  void *userData,
251  const eV3DProjTest clip_flag);
253  void (*func)(void *userData,
254  struct MetaElem *ml,
255  const float screen_co[2]),
256  void *userData,
257  const eV3DProjTest clip_flag);
259  void (*func)(void *userData,
260  struct BPoint *bp,
261  const float screen_co[2]),
262  void *userData,
263  const eV3DProjTest clip_flag);
265  void (*func)(void *userData,
266  struct EditBone *ebone,
267  const float screen_co_a[2],
268  const float screen_co_b[2]),
269  void *userData,
270  const eV3DProjTest clip_flag);
271 void pose_foreachScreenBone(struct ViewContext *vc,
272  void (*func)(void *userData,
273  struct bPoseChannel *pchan,
274  const float screen_co_a[2],
275  const float screen_co_b[2]),
276  void *userData,
277  const eV3DProjTest clip_flag);
278 /* *** end iterators *** */
279 
280 /* view3d_project.c */
281 void ED_view3d_project_float_v2_m4(const struct ARegion *region,
282  const float co[3],
283  float r_co[2],
284  float mat[4][4]);
285 void ED_view3d_project_float_v3_m4(const struct ARegion *region,
286  const float co[3],
287  float r_co[3],
288  float mat[4][4]);
289 
290 eV3DProjStatus ED_view3d_project_base(const struct ARegion *region, struct Base *base);
291 
292 /* *** short *** */
294  float perspmat[4][4],
295  const bool is_local,
296  const float co[3],
297  short r_co[2],
298  const eV3DProjTest flag);
300  const float co[3],
301  short r_co[2],
302  const eV3DProjTest flag);
304  const float co[3],
305  short r_co[2],
306  const eV3DProjTest flag);
307 
308 /* *** int *** */
310  float perspmat[4][4],
311  const bool is_local,
312  const float co[3],
313  int r_co[2],
314  const eV3DProjTest flag);
316  const float co[3],
317  int r_co[2],
318  const eV3DProjTest flag);
320  const float co[3],
321  int r_co[2],
322  const eV3DProjTest flag);
323 
324 /* *** float *** */
326  float perspmat[4][4],
327  const bool is_local,
328  const float co[3],
329  float r_co[2],
330  const eV3DProjTest flag);
332  const float co[3],
333  float r_co[2],
334  const eV3DProjTest flag);
336  const float co[3],
337  float r_co[2],
338  const eV3DProjTest flag);
339 
340 float ED_view3d_pixel_size(const struct RegionView3D *rv3d, const float co[3]);
341 float ED_view3d_pixel_size_no_ui_scale(const struct RegionView3D *rv3d, const float co[3]);
342 
343 float ED_view3d_calc_zfac(const struct RegionView3D *rv3d, const float co[3], bool *r_flip);
344 bool ED_view3d_clip_segment(const struct RegionView3D *rv3d, float ray_start[3], float ray_end[3]);
346  const struct ARegion *region,
347  const struct View3D *v3d,
348  const float mval[2],
349  float ray_start[3],
350  float ray_normal[3],
351  const bool do_clip);
353  const struct ARegion *region,
354  const struct View3D *v3d,
355  const float mval[2],
356  float r_ray_co[3],
357  float r_ray_normal[3],
358  float r_ray_start[3],
359  bool do_clip);
360 void ED_view3d_win_to_ray(const struct ARegion *region,
361  const float mval[2],
362  float r_ray_start[3],
363  float r_ray_normal[3]);
364 void ED_view3d_global_to_vector(const struct RegionView3D *rv3d,
365  const float coord[3],
366  float vec[3]);
367 void ED_view3d_win_to_3d(const struct View3D *v3d,
368  const struct ARegion *region,
369  const float depth_pt[3],
370  const float mval[2],
371  float r_out[3]);
372 void ED_view3d_win_to_3d_int(const struct View3D *v3d,
373  const struct ARegion *region,
374  const float depth_pt[3],
375  const int mval[2],
376  float r_out[3]);
377 bool ED_view3d_win_to_3d_on_plane(const struct ARegion *region,
378  const float plane[4],
379  const float mval[2],
380  const bool do_clip,
381  float r_out[3]);
383  const float plane[4],
384  const float mval[2],
385  const bool do_clip,
386  const float plane_fallback[4],
387  float r_out[3]);
388 bool ED_view3d_win_to_3d_on_plane_int(const struct ARegion *region,
389  const float plane[4],
390  const int mval[2],
391  const bool do_clip,
392  float r_out[3]);
393 void ED_view3d_win_to_delta(const struct ARegion *region,
394  const float mval[2],
395  float out[3],
396  const float zfac);
397 void ED_view3d_win_to_origin(const struct ARegion *region, const float mval[2], float out[3]);
398 void ED_view3d_win_to_vector(const struct ARegion *region, const float mval[2], float out[3]);
400  const struct ARegion *region,
401  struct View3D *v3d,
402  const float mval[2],
403  float r_ray_start[3],
404  float r_ray_end[3],
405  const bool do_clip);
407  struct Object *ob,
408  float r_pmat[4][4]);
410  const float obmat[4][4],
411  float r_pmat[4][4]);
412 
413 void ED_view3d_project(const struct ARegion *region, const float world[3], float r_region_co[3]);
415  const struct ARegion *region, float regionx, float regiony, float regionz, float world[3]);
416 
417 /* end */
418 
419 void ED_view3d_dist_range_get(const struct View3D *v3d, float r_dist_range[2]);
421  const struct View3D *v3d,
422  const struct RegionView3D *rv3d,
423  float *r_clipsta,
424  float *r_clipend,
425  const bool use_ortho_factor);
427  const struct View3D *v3d,
428  const struct RegionView3D *rv3d,
429  int winxi,
430  int winyi,
431  struct rctf *r_viewplane,
432  float *r_clipsta,
433  float *r_clipend,
434  float *r_pixsize);
435 
436 void ED_view3d_polygon_offset(const struct RegionView3D *rv3d, const float dist);
437 
439  struct Depsgraph *depsgraph,
440  const struct ARegion *region,
441  const struct View3D *v3d,
442  const struct RegionView3D *rv3d,
443  struct rctf *r_viewborder,
444  const bool no_shift);
446  struct Depsgraph *depsgraph,
447  const struct ARegion *region,
448  const struct View3D *v3d,
449  const struct RegionView3D *rv3d,
450  float r_size[2]);
452  struct Depsgraph *depsgraph,
453  struct View3D *v3d,
454  struct ARegion *region,
455  struct rcti *rect);
456 
458  const struct BoundBox *clipbb,
459  const bool is_flip);
461  float planes[4][4],
462  const struct ARegion *region,
463  const struct Object *ob,
464  const struct rcti *rect);
465 bool ED_view3d_clipping_clamp_minmax(const struct RegionView3D *rv3d, float min[3], float max[3]);
466 
467 void ED_view3d_clipping_local(struct RegionView3D *rv3d, const float mat[4][4]);
468 bool ED_view3d_clipping_test(const struct RegionView3D *rv3d,
469  const float co[3],
470  const bool is_local);
471 
472 float ED_view3d_radius_to_dist_persp(const float angle, const float radius);
473 float ED_view3d_radius_to_dist_ortho(const float lens, const float radius);
474 float ED_view3d_radius_to_dist(const struct View3D *v3d,
475  const struct ARegion *region,
476  const struct Depsgraph *depsgraph,
477  const char persp,
478  const bool use_aspect,
479  const float radius);
480 
481 void imm_drawcircball(const float cent[3], float rad, const float tmat[4][4], unsigned int pos);
482 
483 /* Back-buffer select and draw support. */
485 int ED_view3d_backbuf_sample_size_clamp(struct ARegion *region, const float dist);
486 
488 
490  struct ARegion *region,
491  struct View3D *v3d,
492  const int mval[2],
493  float mouse_worldloc[3],
494  const bool alphaoverride,
495  const float fallback_depth_pt[3]);
496 
497 bool ED_view3d_autodist_simple(struct ARegion *region,
498  const int mval[2],
499  float mouse_worldloc[3],
500  int margin,
501  const float *force_depth);
502 bool ED_view3d_autodist_depth(struct ARegion *region, const int mval[2], int margin, float *depth);
503 bool ED_view3d_autodist_depth_seg(struct ARegion *region,
504  const int mval_sta[2],
505  const int mval_end[2],
506  int margin,
507  float *depth);
508 
509 /* select */
510 #define MAXPICKELEMS 2500
511 #define MAXPICKBUF (4 * MAXPICKELEMS)
512 
513 typedef enum {
514  /* all elements in the region, ignore depth */
516  /* pick also depth sorts (only for small regions!) */
518  /* sorts and only returns visible objects (only for small regions!) */
521 
522 typedef enum {
530 
532  const struct Object *obact);
533 
536 
538  unsigned int *buffer,
539  unsigned int bufsize,
540  const struct rcti *input,
541  eV3DSelectMode select_mode,
542  eV3DSelectObjectFilter select_filter);
544  unsigned int *buffer,
545  unsigned int bufsize,
546  const struct rcti *input,
547  eV3DSelectMode select_mode,
548  eV3DSelectObjectFilter select_filter,
549  uint select_id);
550 
551 /* view3d_select.c */
552 float ED_view3d_select_dist_px(void);
554  struct ViewContext *vc,
555  struct Depsgraph *depsgraph);
556 void ED_view3d_viewcontext_init_object(struct ViewContext *vc, struct Object *obact);
558 void view3d_region_operator_needs_opengl(struct wmWindow *win, struct ARegion *region);
559 
560 /* XXX should move to BLI_math */
561 bool edge_inside_circle(const float cent[2],
562  float radius,
563  const float screen_co_a[2],
564  const float screen_co_b[2]);
565 
566 /* get 3d region from context, also if mouse is in header or toolbar */
569  struct View3D **r_v3d,
570  struct ARegion **r_region);
572  const struct View3D *v3d,
573  struct ARegion **r_region);
575 
576 void ED_view3d_init_mats_rv3d(struct Object *ob, struct RegionView3D *rv3d);
577 void ED_view3d_init_mats_rv3d_gl(struct Object *ob, struct RegionView3D *rv3d);
578 #ifdef DEBUG
579 void ED_view3d_clear_mats_rv3d(struct RegionView3D *rv3d);
580 void ED_view3d_check_mats_rv3d(struct RegionView3D *rv3d);
581 #else
582 # define ED_view3d_clear_mats_rv3d(rv3d) (void)(rv3d)
583 # define ED_view3d_check_mats_rv3d(rv3d) (void)(rv3d)
584 #endif
585 
587 void ED_view3d_mats_rv3d_restore(struct RegionView3D *rv3d, struct RV3DMatrixStore *rv3dmat);
588 
590  struct Object *ob,
591  const float col[4],
592  const int facemap);
593 
594 struct RenderEngineType *ED_view3d_engine_type(const struct Scene *scene, int drawtype);
595 
598  struct wmWindow *win,
599  struct Depsgraph *depsgraph,
600  struct Scene *scene,
601  struct ARegion *region,
602  struct View3D *v3d,
603  const float viewmat[4][4],
604  const float winmat[4][4],
605  const struct rcti *rect);
606 
607 struct Base *ED_view3d_give_base_under_cursor(struct bContext *C, const int mval[2]);
608 struct Object *ED_view3d_give_object_under_cursor(struct bContext *C, const int mval[2]);
609 bool ED_view3d_is_object_under_cursor(struct bContext *C, const int mval[2]);
610 void ED_view3d_quadview_update(struct ScrArea *area, struct ARegion *region, bool do_clip);
612  const struct Scene *scene,
613  struct View3D *v3d,
614  struct ARegion *region,
615  const float viewmat[4][4],
616  const float winmat[4][4],
617  const struct rcti *rect,
618  bool offscreen);
619 bool ED_view3d_quat_from_axis_view(const char view, const char view_axis_roll, float r_quat[4]);
620 bool ED_view3d_quat_to_axis_view(const float viewquat[4],
621  const float epsilon,
622  char *r_view,
623  char *r_view_axis_rotation);
624 
627 bool ED_view3d_lock(struct RegionView3D *rv3d);
628 
629 void ED_view3d_datamask(const struct bContext *C,
630  const struct Scene *scene,
631  const struct View3D *v3d,
632  struct CustomData_MeshMasks *r_cddata_masks);
634  const struct Scene *scene,
635  const struct bScreen *screen,
636  struct CustomData_MeshMasks *r_cddata_masks);
637 
638 bool ED_view3d_offset_lock_check(const struct View3D *v3d, const struct RegionView3D *rv3d);
640  struct View3D *v3d,
641  struct RegionView3D *rv3d,
642  const char persp);
644  struct View3D *v3d,
645  struct ARegion *region);
646 
647 /* camera lock functions */
648 bool ED_view3d_camera_lock_check(const struct View3D *v3d, const struct RegionView3D *rv3d);
649 /* copy the camera to the view before starting a view transformation */
651  struct View3D *v3d,
652  struct RegionView3D *rv3d,
653  const bool calc_dist);
655  struct View3D *v3d,
656  struct RegionView3D *rv3d);
657 /* copy the view to the camera, return true if */
659  struct View3D *v3d,
660  struct RegionView3D *rv3d);
661 
663  struct ID *id_key,
664  struct bContext *C,
665  const bool do_rotate,
666  const bool do_translate);
667 bool ED_view3d_camera_lock_autokey(struct View3D *v3d,
668  struct RegionView3D *rv3d,
669  struct bContext *C,
670  const bool do_rotate,
671  const bool do_translate);
672 
673 void ED_view3d_lock_clear(struct View3D *v3d);
674 
675 #define VIEW3D_MARGIN 1.4f
676 #define VIEW3D_DIST_FALLBACK 1.0f
677 
678 float ED_view3d_offset_distance(const float mat[4][4],
679  const float ofs[3],
680  const float fallback_dist);
681 void ED_view3d_distance_set(struct RegionView3D *rv3d, const float dist);
683  const float dist_co[3],
684  const float dist_min);
685 
686 float ED_scene_grid_scale(const struct Scene *scene, const char **r_grid_unit);
687 float ED_view3d_grid_scale(const struct Scene *scene,
688  struct View3D *v3d,
689  const char **r_grid_unit);
690 void ED_view3d_grid_steps(const struct Scene *scene,
691  struct View3D *v3d,
692  struct RegionView3D *rv3d,
693  float *r_grid_steps);
695  struct View3D *v3d,
696  struct ARegion *region,
697  const char **r_grid_unit);
698 
699 void ED_scene_draw_fps(const struct Scene *scene, int xoffset, int *yoffset);
700 
701 /* render */
702 void ED_view3d_stop_render_preview(struct wmWindowManager *wm, struct ARegion *region);
703 void ED_view3d_shade_update(struct Main *bmain, struct View3D *v3d, struct ScrArea *area);
704 
705 #define XRAY_ALPHA(v3d) \
706  (((v3d)->shading.type == OB_WIRE) ? (v3d)->shading.xray_alpha_wire : (v3d)->shading.xray_alpha)
707 #define XRAY_FLAG(v3d) \
708  (((v3d)->shading.type == OB_WIRE) ? V3D_SHADING_XRAY_WIREFRAME : V3D_SHADING_XRAY)
709 #define XRAY_FLAG_ENABLED(v3d) (((v3d)->shading.flag & XRAY_FLAG(v3d)) != 0)
710 #define XRAY_ENABLED(v3d) (XRAY_FLAG_ENABLED(v3d) && (XRAY_ALPHA(v3d) < 1.0f))
711 #define XRAY_ACTIVE(v3d) (XRAY_ENABLED(v3d) && ((v3d)->shading.type < OB_MATERIAL))
712 
713 /* view3d_draw_legacy.c */
714 /* Try avoid using these more move out of legacy. */
716  struct Depsgraph *depsgraph,
717  struct ARegion *region,
718  struct View3D *v3d,
719  const bool do_foreground,
720  const bool do_camera_frame);
721 
722 /* view3d_gizmo_preselect_type.c */
724  struct wmGizmo *gz,
725  struct Base **r_base,
726  struct BMElem **r_ele);
727 
728 /* space_view3d.c */
730  struct ARegion *region,
731  const char *category_override);
732 
733 /* view3d_view.c */
734 bool ED_view3d_local_collections_set(struct Main *bmain, struct View3D *v3d);
735 void ED_view3d_local_collections_reset(struct bContext *C, const bool reset_all);
736 
737 #ifdef WITH_XR_OPENXR
738 void ED_view3d_xr_mirror_update(const struct ScrArea *area,
739  const struct View3D *v3d,
740  const bool enable);
741 void ED_view3d_xr_shading_update(struct wmWindowManager *wm,
742  const View3D *v3d,
743  const struct Scene *scene);
744 bool ED_view3d_is_region_xr_mirror_active(const struct wmWindowManager *wm,
745  const struct View3D *v3d,
746  const struct ARegion *region);
747 #endif
748 
749 #ifdef __cplusplus
750 }
751 #endif
unsigned int uint
Definition: BLI_sys_types.h:83
struct Depsgraph Depsgraph
Definition: DEG_depsgraph.h:51
bool ED_view3d_win_to_segment_clipped(struct Depsgraph *depsgraph, const struct ARegion *region, struct View3D *v3d, const float mval[2], float r_ray_start[3], float r_ray_end[3], const bool do_clip)
void ED_view3d_depth_tag_update(struct RegionView3D *rv3d)
eV3DProjStatus ED_view3d_project_int_object(const struct ARegion *region, const float co[3], int r_co[2], const eV3DProjTest flag)
float ED_view3d_radius_to_dist_ortho(const float lens, const float radius)
bool ED_view3d_win_to_3d_on_plane(const struct ARegion *region, const float plane[4], const float mval[2], const bool do_clip, float r_out[3])
void ED_view3d_stop_render_preview(struct wmWindowManager *wm, struct ARegion *region)
Definition: space_view3d.c:225
void nurbs_foreachScreenVert(struct ViewContext *vc, void(*func)(void *userData, struct Nurb *nu, struct BPoint *bp, struct BezTriple *bezt, int beztindex, bool handle_visible, const float screen_co[2]), void *userData, const eV3DProjTest clip_flag)
void ED_view3d_persp_switch_from_camera(const struct Depsgraph *depsgraph, struct View3D *v3d, struct RegionView3D *rv3d, const char persp)
bool ED_view3d_depth_read_cached(const ViewDepths *vd, const int mval[2], int margin, float *r_depth)
bool ED_view3d_camera_lock_sync(const struct Depsgraph *depsgraph, struct View3D *v3d, struct RegionView3D *rv3d)
eV3DProjStatus ED_view3d_project_int_global(const struct ARegion *region, const float co[3], int r_co[2], const eV3DProjTest flag)
void armature_foreachScreenBone(struct ViewContext *vc, void(*func)(void *userData, struct EditBone *ebone, const float screen_co_a[2], const float screen_co_b[2]), void *userData, const eV3DProjTest clip_flag)
bool ED_view3d_area_user_region(const struct ScrArea *area, const struct View3D *v3d, struct ARegion **r_region)
void ED_view3d_calc_camera_border(const struct Scene *scene, struct Depsgraph *depsgraph, const struct ARegion *region, const struct View3D *v3d, const struct RegionView3D *rv3d, struct rctf *r_viewborder, const bool no_shift)
void view3d_opengl_select_cache_end(void)
Definition: view3d_view.c:897
float ED_view3d_radius_to_dist(const struct View3D *v3d, const struct ARegion *region, const struct Depsgraph *depsgraph, const char persp, const bool use_aspect, const float radius)
void ED_view3d_mats_rv3d_restore(struct RegionView3D *rv3d, struct RV3DMatrixStore *rv3dmat)
Definition: view3d_draw.c:2487
eV3DProjStatus ED_view3d_project_base(const struct ARegion *region, struct Base *base)
void ED_view3d_calc_camera_border_size(const struct Scene *scene, struct Depsgraph *depsgraph, const struct ARegion *region, const struct View3D *v3d, const struct RegionView3D *rv3d, float r_size[2])
bool ED_view3d_clipping_clamp_minmax(const struct RegionView3D *rv3d, float min[3], float max[3])
void ED_view3d_local_collections_reset(struct bContext *C, const bool reset_all)
Definition: view3d_view.c:1661
struct RenderEngineType * ED_view3d_engine_type(const struct Scene *scene, int drawtype)
char ED_view3d_axis_view_opposite(char view)
void ED_view3d_init_mats_rv3d(struct Object *ob, struct RegionView3D *rv3d)
Definition: space_view3d.c:190
float ED_view3d_pixel_size(const struct RegionView3D *rv3d, const float co[3])
void mball_foreachScreenElem(struct ViewContext *vc, void(*func)(void *userData, struct MetaElem *ml, const float screen_co[2]), void *userData, const eV3DProjTest clip_flag)
eV3DProjTest
Definition: ED_view3d.h:192
@ V3D_PROJ_TEST_CLIP_FAR
Definition: ED_view3d.h:197
@ V3D_PROJ_TEST_CLIP_NEAR
Definition: ED_view3d.h:196
@ V3D_PROJ_TEST_CLIP_ZERO
Definition: ED_view3d.h:198
@ V3D_PROJ_TEST_NOP
Definition: ED_view3d.h:193
@ V3D_PROJ_TEST_CLIP_WIN
Definition: ED_view3d.h:195
@ V3D_PROJ_TEST_CLIP_BB
Definition: ED_view3d.h:194
void ED_view3d_win_to_3d_int(const struct View3D *v3d, const struct ARegion *region, const float depth_pt[3], const int mval[2], float r_out[3])
bool ED_view3d_viewplane_get(struct Depsgraph *depsgraph, const struct View3D *v3d, const struct RegionView3D *rv3d, int winxi, int winyi, struct rctf *r_viewplane, float *r_clipsta, float *r_clipend, float *r_pixsize)
bool ED_view3d_win_to_3d_on_plane_with_fallback(const struct ARegion *region, const float plane[4], const float mval[2], const bool do_clip, const float plane_fallback[4], float r_out[3])
bool ED_view3d_camera_lock_check(const struct View3D *v3d, const struct RegionView3D *rv3d)
eV3DProjStatus ED_view3d_project_short_object(const struct ARegion *region, const float co[3], short r_co[2], const eV3DProjTest flag)
#define ED_view3d_clear_mats_rv3d(rv3d)
Definition: ED_view3d.h:582
void ED_view3d_ob_project_mat_get(const struct RegionView3D *v3d, struct Object *ob, float r_pmat[4][4])
bool ED_view3d_clip_segment(const struct RegionView3D *rv3d, float ray_start[3], float ray_end[3])
void ED_view3d_cursor3d_position_rotation(struct bContext *C, const int mval[2], const bool use_depth, enum eV3DCursorOrient orientation, float r_cursor_co[3], float r_cursor_quat[4])
Definition: view3d_edit.c:5035
void ED_view3d_ob_project_mat_get_from_obmat(const struct RegionView3D *rv3d, const float obmat[4][4], float r_pmat[4][4])
eV3DProjStatus ED_view3d_project_float_object(const struct ARegion *region, const float co[3], float r_co[2], const eV3DProjTest flag)
char ED_view3d_lock_view_from_index(int index)
bool ED_operator_rv3d_user_region_poll(struct bContext *C)
Definition: view3d_view.c:684
void ED_view3d_viewcontext_init(struct bContext *C, struct ViewContext *vc, struct Depsgraph *depsgraph)
bool ED_view3d_quat_to_axis_view(const float viewquat[4], const float epsilon, char *r_view, char *r_view_axis_rotation)
bool ED_view3d_win_to_3d_on_plane_int(const struct ARegion *region, const float plane[4], const int mval[2], const bool do_clip, float r_out[3])
void ED_view3d_dist_range_get(const struct View3D *v3d, float r_dist_range[2])
struct Base * ED_view3d_give_base_under_cursor(struct bContext *C, const int mval[2])
eV3DProjStatus
Definition: ED_view3d.h:175
@ V3D_PROJ_RET_CLIP_WIN
Definition: ED_view3d.h:186
@ V3D_PROJ_RET_CLIP_BB
Definition: ED_view3d.h:184
@ V3D_PROJ_RET_CLIP_FAR
Definition: ED_view3d.h:180
@ V3D_PROJ_RET_CLIP_ZERO
Definition: ED_view3d.h:182
@ V3D_PROJ_RET_CLIP_NEAR
Definition: ED_view3d.h:178
@ V3D_PROJ_RET_OVERFLOW
Definition: ED_view3d.h:188
@ V3D_PROJ_RET_OK
Definition: ED_view3d.h:176
bool ED_view3d_camera_to_view_selected(struct Main *bmain, struct Depsgraph *depsgraph, const struct Scene *scene, struct Object *camera_ob)
void ED_view3d_win_to_delta(const struct ARegion *region, const float mval[2], float out[3], const float zfac)
bool ED_view3d_distance_set_from_location(struct RegionView3D *rv3d, const float dist_co[3], const float dist_min)
void ED_view3d_win_to_ray(const struct ARegion *region, const float mval[2], float r_ray_start[3], float r_ray_normal[3])
void ED_view3d_polygon_offset(const struct RegionView3D *rv3d, const float dist)
eV3DProjStatus ED_view3d_project_short_global(const struct ARegion *region, const float co[3], short r_co[2], const eV3DProjTest flag)
bool ED_view3d_depth_read_cached_normal(const ViewContext *vc, const int mval[2], float r_normal[3])
float ED_view3d_pixel_size_no_ui_scale(const struct RegionView3D *rv3d, const float co[3])
float ED_scene_grid_scale(const struct Scene *scene, const char **r_grid_unit)
bool ED_view3d_quat_from_axis_view(const char view, const char view_axis_roll, float r_quat[4])
float ED_view3d_grid_scale(const struct Scene *scene, struct View3D *v3d, const char **r_grid_unit)
void ED_view3d_viewcontext_init_object(struct ViewContext *vc, struct Object *obact)
void ED_scene_draw_fps(const struct Scene *scene, int xoffset, int *yoffset)
void ED_view3d_draw_bgpic_test(const struct Scene *scene, struct Depsgraph *depsgraph, struct ARegion *region, struct View3D *v3d, const bool do_foreground, const bool do_camera_frame)
void meshobject_foreachScreenVert(struct ViewContext *vc, void(*func)(void *userData, struct MVert *eve, const float screen_co[2], int index), void *userData, const eV3DProjTest clip_flag)
bool ED_view3d_offset_lock_check(const struct View3D *v3d, const struct RegionView3D *rv3d)
float ED_view3d_radius_to_dist_persp(const float angle, const float radius)
void ED_view3d_buttons_region_layout_ex(const struct bContext *C, struct ARegion *region, const char *category_override)
void ED_view3d_from_m4(const float mat[4][4], float ofs[3], float quat[4], const float *dist)
bool ED_view3d_local_collections_set(struct Main *bmain, struct View3D *v3d)
Definition: view3d_view.c:1637
void ED_view3d_draw_setup_view(const struct wmWindowManager *wm, struct wmWindow *win, struct Depsgraph *depsgraph, struct Scene *scene, struct ARegion *region, struct View3D *v3d, const float viewmat[4][4], const float winmat[4][4], const struct rcti *rect)
bool ED_view3d_persp_ensure(const struct Depsgraph *depsgraph, struct View3D *v3d, struct ARegion *region)
void ED_view3d_clipping_calc_from_boundbox(float clip[6][4], const struct BoundBox *clipbb, const bool is_flip)
bool ED_view3d_is_object_under_cursor(struct bContext *C, const int mval[2])
void ED_view3d_from_object(const struct Object *ob, float ofs[3], float quat[4], float *dist, float *lens)
eV3DProjStatus ED_view3d_project_int_ex(const struct ARegion *region, float perspmat[4][4], const bool is_local, const float co[3], int r_co[2], const eV3DProjTest flag)
bool ED_view3d_context_activate(struct bContext *C)
Definition: view3d_utils.c:244
float ED_view3d_offset_distance(const float mat[4][4], const float ofs[3], const float fallback_dist)
bool ED_view3d_camera_lock_autokey(struct View3D *v3d, struct RegionView3D *rv3d, struct bContext *C, const bool do_rotate, const bool do_translate)
Definition: view3d_utils.c:710
void ED_view3d_cursor3d_position(struct bContext *C, const int mval[2], const bool use_depth, float r_cursor_co[3])
Definition: view3d_edit.c:4993
void ED_view3d_win_to_vector(const struct ARegion *region, const float mval[2], float out[3])
void mesh_foreachScreenFace(struct ViewContext *vc, void(*func)(void *userData, struct BMFace *efa, const float screen_co[2], int index), void *userData, const eV3DProjTest clip_flag)
bool ED_view3d_depth_unproject(const struct ARegion *region, const int mval[2], const double depth, float r_location_world[3])
void ED_view3d_project_float_v3_m4(const struct ARegion *region, const float co[3], float r_co[3], float mat[4][4])
void ED_view3d_select_id_validate(struct ViewContext *vc)
Definition: view3d_draw.c:2192
void mesh_foreachScreenVert(struct ViewContext *vc, void(*func)(void *userData, struct BMVert *eve, const float screen_co[2], int index), void *userData, const eV3DProjTest clip_flag)
void ED_view3d_project(const struct ARegion *region, const float world[3], float r_region_co[3])
void ED_view3d_camera_lock_init_ex(const struct Depsgraph *depsgraph, struct View3D *v3d, struct RegionView3D *rv3d, const bool calc_dist)
struct ViewDepths ViewDepths
void ED_view3d_distance_set(struct RegionView3D *rv3d, const float dist)
void ED_view3d_update_viewmat(struct Depsgraph *depsgraph, const struct Scene *scene, struct View3D *v3d, struct ARegion *region, const float viewmat[4][4], const float winmat[4][4], const struct rcti *rect, bool offscreen)
bool ED_view3d_autodist(struct Depsgraph *depsgraph, struct ARegion *region, struct View3D *v3d, const int mval[2], float mouse_worldloc[3], const bool alphaoverride, const float fallback_depth_pt[3])
void ED_view3d_gizmo_mesh_preselect_get_active(struct bContext *C, struct wmGizmo *gz, struct Base **r_base, struct BMElem **r_ele)
struct ViewContext ViewContext
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
void imm_drawcircball(const float cent[3], float rad, const float tmat[4][4], unsigned int pos)
Definition: drawobject.c:90
void view3d_opengl_select_cache_begin(void)
Definition: view3d_view.c:892
eV3DCursorOrient
Definition: ED_view3d.h:98
@ V3D_CURSOR_ORIENT_XFORM
Definition: ED_view3d.h:101
@ V3D_CURSOR_ORIENT_GEOM
Definition: ED_view3d.h:102
@ V3D_CURSOR_ORIENT_VIEW
Definition: ED_view3d.h:100
@ V3D_CURSOR_ORIENT_NONE
Definition: ED_view3d.h:99
void ED_view3d_global_to_vector(const struct RegionView3D *rv3d, const float coord[3], float vec[3])
void ED_view3d_depth_override(struct Depsgraph *depsgraph, struct ARegion *region, struct View3D *v3d, struct Object *obact, eV3DDepthOverrideMode mode, bool update_cache)
Definition: view3d_draw.c:2331
eV3DProjStatus ED_view3d_project_short_ex(const struct ARegion *region, float perspmat[4][4], const bool is_local, const float co[3], short r_co[2], const eV3DProjTest flag)
struct Camera * ED_view3d_camera_data_get(struct View3D *v3d, struct RegionView3D *rv3d)
Definition: view3d_utils.c:109
void ED_view3d_project_float_v2_m4(const struct ARegion *region, const float co[3], float r_co[2], float mat[4][4])
void ED_view3d_to_object(const struct Depsgraph *depsgraph, struct Object *ob, const float ofs[3], const float quat[4], const float dist)
void ED_view3d_cursor3d_update(struct bContext *C, const int mval[2], const bool use_depth, enum eV3DCursorOrient orientation)
Definition: view3d_edit.c:5151
float ED_view3d_grid_view_scale(struct Scene *scene, struct View3D *v3d, struct ARegion *region, const char **r_grid_unit)
Definition: view3d_draw.c:917
eV3DSelectMode
Definition: ED_view3d.h:513
@ VIEW3D_SELECT_PICK_ALL
Definition: ED_view3d.h:517
@ VIEW3D_SELECT_PICK_NEAREST
Definition: ED_view3d.h:519
@ VIEW3D_SELECT_ALL
Definition: ED_view3d.h:515
void view3d_region_operator_needs_opengl(struct wmWindow *win, struct ARegion *region)
bool ED_view3d_clip_range_get(struct Depsgraph *depsgraph, const struct View3D *v3d, const struct RegionView3D *rv3d, float *r_clipsta, float *r_clipend, const bool use_ortho_factor)
bool ED_view3d_autodist_simple(struct ARegion *region, const int mval[2], float mouse_worldloc[3], int margin, const float *force_depth)
void ED_view3d_clipping_calc(struct BoundBox *bb, float planes[4][4], const struct ARegion *region, const struct Object *ob, const struct rcti *rect)
void ED_view3d_win_to_origin(const struct ARegion *region, const float mval[2], float out[3])
void ED_view3d_lastview_store(struct RegionView3D *rv3d)
Definition: view3d_utils.c:487
void ED_view3d_win_to_3d(const struct View3D *v3d, const struct ARegion *region, const float depth_pt[3], const float mval[2], float r_out[3])
bool ED_view3d_camera_autokey(const struct Scene *scene, struct ID *id_key, struct bContext *C, const bool do_rotate, const bool do_translate)
int view3d_opengl_select(struct ViewContext *vc, unsigned int *buffer, unsigned int bufsize, const struct rcti *input, eV3DSelectMode select_mode, eV3DSelectObjectFilter select_filter)
bool ED_view3d_lock(struct RegionView3D *rv3d)
eV3DSelectObjectFilter ED_view3d_select_filter_from_mode(const struct Scene *scene, const struct Object *obact)
eV3DProjStatus ED_view3d_project_float_ex(const struct ARegion *region, float perspmat[4][4], const bool is_local, const float co[3], float r_co[2], const eV3DProjTest flag)
void ED_view3d_clipping_local(struct RegionView3D *rv3d, const float mat[4][4])
Definition: view3d_edit.c:4921
void ED_view3d_camera_lock_init(const struct Depsgraph *depsgraph, struct View3D *v3d, struct RegionView3D *rv3d)
void lattice_foreachScreenVert(struct ViewContext *vc, void(*func)(void *userData, struct BPoint *bp, const float screen_co[2]), void *userData, const eV3DProjTest clip_flag)
void ED_view3d_background_color_get(const struct Scene *scene, const struct View3D *v3d, float r_color[3])
void view3d_operator_needs_opengl(const struct bContext *C)
void ED_view3d_screen_datamask(const struct bContext *C, const struct Scene *scene, const struct bScreen *screen, struct CustomData_MeshMasks *r_cddata_masks)
struct RegionView3D * ED_view3d_context_rv3d(struct bContext *C)
Definition: space_view3d.c:89
void pose_foreachScreenBone(struct ViewContext *vc, void(*func)(void *userData, struct bPoseChannel *pchan, const float screen_co_a[2], const float screen_co_b[2]), void *userData, const eV3DProjTest clip_flag)
bool ED_view3d_clipping_test(const struct RegionView3D *rv3d, const float co[3], const bool is_local)
void ED_view3d_grid_steps(const struct Scene *scene, struct View3D *v3d, struct RegionView3D *rv3d, float *r_grid_steps)
bool ED_view3d_unproject(const struct ARegion *region, float regionx, float regiony, float regionz, float world[3])
struct RV3DMatrixStore * ED_view3d_mats_rv3d_backup(struct RegionView3D *rv3d)
Definition: view3d_draw.c:2474
void mesh_foreachScreenEdge_clip_bb_segment(struct ViewContext *vc, void(*func)(void *userData, struct BMEdge *eed, const float screen_co_a[2], const float screen_co_b[2], int index), void *userData, const eV3DProjTest clip_flag)
bool edge_inside_circle(const float cent[2], float radius, const float screen_co_a[2], const float screen_co_b[2])
eV3DProjStatus ED_view3d_project_float_global(const struct ARegion *region, const float co[3], float r_co[2], const eV3DProjTest flag)
void ED_view3d_shade_update(struct Main *bmain, struct View3D *v3d, struct ScrArea *area)
Definition: space_view3d.c:248
bool ED_view3d_context_user_region(struct bContext *C, struct View3D **r_v3d, struct ARegion **r_region)
Definition: space_view3d.c:107
void ED_view3d_to_m4(float mat[4][4], const float ofs[3], const float quat[4], const float dist)
void ED_view3d_lock_clear(struct View3D *v3d)
Definition: view3d_utils.c:497
eV3DSelectObjectFilter
Definition: ED_view3d.h:522
@ VIEW3D_SELECT_FILTER_NOP
Definition: ED_view3d.h:524
@ VIEW3D_SELECT_FILTER_OBJECT_MODE_LOCK
Definition: ED_view3d.h:526
@ VIEW3D_SELECT_FILTER_WPAINT_POSE_MODE_LOCK
Definition: ED_view3d.h:528
void ED_draw_object_facemap(struct Depsgraph *depsgraph, struct Object *ob, const float col[4], const int facemap)
Definition: drawobject.c:110
bool ED_view3d_win_to_ray_clipped_ex(struct Depsgraph *depsgraph, const struct ARegion *region, const struct View3D *v3d, const float mval[2], float r_ray_co[3], float r_ray_normal[3], float r_ray_start[3], bool do_clip)
bool ED_view3d_calc_render_border(const struct Scene *scene, struct Depsgraph *depsgraph, struct View3D *v3d, struct ARegion *region, struct rcti *rect)
float ED_view3d_select_dist_px(void)
void ED_view3d_quadview_update(struct ScrArea *area, struct ARegion *region, bool do_clip)
Definition: view3d_utils.c:939
#define ED_view3d_check_mats_rv3d(rv3d)
Definition: ED_view3d.h:583
void ED_view3d_backbuf_depth_validate(struct ViewContext *vc)
float ED_view3d_calc_zfac(const struct RegionView3D *rv3d, const float co[3], bool *r_flip)
struct Object * ED_view3d_give_object_under_cursor(struct bContext *C, const int mval[2])
bool ED_view3d_win_to_ray_clipped(struct Depsgraph *depsgraph, const struct ARegion *region, const struct View3D *v3d, const float mval[2], float ray_start[3], float ray_normal[3], const bool do_clip)
void ED_view3d_datamask(const struct bContext *C, const struct Scene *scene, const struct View3D *v3d, struct CustomData_MeshMasks *r_cddata_masks)
void ED_view3d_init_mats_rv3d_gl(struct Object *ob, struct RegionView3D *rv3d)
Definition: space_view3d.c:200
void mesh_foreachScreenEdge(struct ViewContext *vc, void(*func)(void *userData, struct BMEdge *eed, const float screen_co_a[2], const float screen_co_b[2], int index), void *userData, const eV3DProjTest clip_flag)
bool ED_view3d_has_workbench_in_texture_color(const struct Scene *scene, const struct Object *ob, const struct View3D *v3d)
bool ED_view3d_autodist_depth_seg(struct ARegion *region, const int mval_sta[2], const int mval_end[2], int margin, float *depth)
int ED_view3d_backbuf_sample_size_clamp(struct ARegion *region, const float dist)
Definition: view3d_draw.c:2201
int view3d_opengl_select_with_id_filter(struct ViewContext *vc, unsigned int *buffer, unsigned int bufsize, const struct rcti *input, eV3DSelectMode select_mode, eV3DSelectObjectFilter select_filter, uint select_id)
bool ED_view3d_autodist_depth(struct ARegion *region, const int mval[2], int margin, float *depth)
static AppView * view
const int facemap[6][4]
Definition: Projections.cpp:57
#define C
Definition: RandGen.cpp:39
SIMD_FORCE_INLINE btScalar angle(const btVector3 &v) const
Return the angle between this and another vector.
Definition: btVector3.h:356
Scene scene
World world
const Depsgraph * depsgraph
uint pos
uint col
__kernel void ccl_constant KernelData ccl_global void ccl_global char ccl_global int ccl_global char ccl_global unsigned int ccl_global float * buffer
static void area(int d1, int d2, int e1, int e2, float weights[2])
static double epsilon
#define min(a, b)
Definition: sort.c:51
Definition: DNA_ID.h:273
Definition: BKE_main.h:116
struct Material ** mat
struct Depsgraph * depsgraph
Definition: ED_view3d.h:75
int mval[2]
Definition: ED_view3d.h:85
struct Scene * scene
Definition: ED_view3d.h:76
struct ARegion * region
Definition: ED_view3d.h:80
struct ViewLayer * view_layer
Definition: ED_view3d.h:77
struct BMEditMesh * em
Definition: ED_view3d.h:84
struct Main * bmain
Definition: ED_view3d.h:70
struct bContext * C
Definition: ED_view3d.h:69
struct Object * obact
Definition: ED_view3d.h:78
struct Object * obedit
Definition: ED_view3d.h:79
struct wmWindow * win
Definition: ED_view3d.h:82
struct View3D * v3d
Definition: ED_view3d.h:81
struct RegionView3D * rv3d
Definition: ED_view3d.h:83
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
float max