Blender  V2.93
view3d_intern.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 #include "ED_view3d.h"
27 
28 /* internal exports only */
29 
30 struct ARegion;
31 struct ARegionType;
32 struct BoundBox;
33 struct Depsgraph;
34 struct Object;
35 struct ViewLayer;
36 struct bContext;
37 struct wmGizmoGroupType;
38 struct wmGizmoType;
39 struct wmKeyConfig;
40 struct wmOperatorType;
41 struct wmWindowManager;
42 
43 /* drawing flags: */
44 enum {
45  DRAW_PICKING = (1 << 0),
46  DRAW_CONSTCOLOR = (1 << 1),
47  DRAW_SCENESET = (1 << 2),
48 };
49 
50 /* view3d_header.c */
52 
53 /* view3d_ops.c */
54 void view3d_operatortypes(void);
55 
56 /* view3d_edit.c */
57 void VIEW3D_OT_zoom(struct wmOperatorType *ot);
58 void VIEW3D_OT_dolly(struct wmOperatorType *ot);
60 void VIEW3D_OT_move(struct wmOperatorType *ot);
61 void VIEW3D_OT_rotate(struct wmOperatorType *ot);
62 #ifdef WITH_INPUT_NDOF
63 void VIEW3D_OT_ndof_orbit(struct wmOperatorType *ot);
64 void VIEW3D_OT_ndof_orbit_zoom(struct wmOperatorType *ot);
65 void VIEW3D_OT_ndof_pan(struct wmOperatorType *ot);
66 void VIEW3D_OT_ndof_all(struct wmOperatorType *ot);
67 #endif /* WITH_INPUT_NDOF */
92 
93 void view3d_boxview_copy(struct ScrArea *area, struct ARegion *region);
94 void view3d_boxview_sync(struct ScrArea *area, struct ARegion *region);
95 
96 void view3d_orbit_apply_dyn_ofs(float r_ofs[3],
97  const float ofs_old[3],
98  const float viewquat_old[4],
99  const float viewquat_new[4],
100  const float dyn_ofs[3]);
101 
102 #ifdef WITH_INPUT_NDOF
103 struct wmNDOFMotionData;
104 
105 void view3d_ndof_fly(const struct wmNDOFMotionData *ndof,
106  struct View3D *v3d,
107  struct RegionView3D *rv3d,
108  const bool use_precision,
109  const short protectflag,
110  bool *r_has_translate,
111  bool *r_has_rotate);
112 #endif /* WITH_INPUT_NDOF */
113 
114 /* view3d_fly.c */
115 void view3d_keymap(struct wmKeyConfig *keyconf);
116 void VIEW3D_OT_fly(struct wmOperatorType *ot);
117 
118 /* view3d_walk.c */
119 void VIEW3D_OT_walk(struct wmOperatorType *ot);
120 
121 /* view3d_draw.c */
122 void view3d_main_region_draw(const struct bContext *C, struct ARegion *region);
123 void view3d_draw_region_info(const struct bContext *C, struct ARegion *region);
124 
125 /* view3d_draw_legacy.c */
127  ViewContext *vc,
128  Scene *scene,
129  struct ViewLayer *view_layer,
130  View3D *v3d,
131  struct ARegion *region,
132  bool use_obedit_skip,
133  bool use_nearest);
134 
136  Scene *scene,
137  struct ARegion *region,
138  View3D *v3d);
139 
140 void view3d_update_depths_rect(struct ARegion *region, struct ViewDepths *d, struct rcti *rect);
141 float view3d_depth_near(struct ViewDepths *d);
142 
143 /* view3d_select.c */
144 void VIEW3D_OT_select(struct wmOperatorType *ot);
150 
151 /* view3d_view.c */
158 
160  const struct BoundBox *bb,
161  float obmat[4][4]);
162 bool ED_view3d_boundbox_clip(RegionView3D *rv3d, const struct BoundBox *bb);
163 
169 typedef struct V3D_SmoothParams {
171  const float *ofs, *quat, *dist, *lens;
172 
174  const float *dyn_ofs;
176 
178  struct wmWindowManager *wm,
179  struct wmWindow *win,
180  struct ScrArea *area,
181  struct View3D *v3d,
182  struct ARegion *region,
183  const int smooth_viewtx,
184  const V3D_SmoothParams *sview);
185 
187  struct View3D *v3d,
188  struct ARegion *region,
189  const int smooth_viewtx,
190  const V3D_SmoothParams *sview);
191 
193  struct View3D *v3d,
194  struct ARegion *region);
195 
197  struct ARegion *region,
198  const View3D *v3d,
199  const rcti *rect);
201  const struct Scene *scene,
202  const View3D *v3d,
203  RegionView3D *rv3d,
204  const float rect_scale[2]);
205 
206 void fly_modal_keymap(struct wmKeyConfig *keyconf);
207 void walk_modal_keymap(struct wmKeyConfig *keyconf);
208 void viewrotate_modal_keymap(struct wmKeyConfig *keyconf);
209 void viewmove_modal_keymap(struct wmKeyConfig *keyconf);
210 void viewzoom_modal_keymap(struct wmKeyConfig *keyconf);
211 void viewdolly_modal_keymap(struct wmKeyConfig *keyconf);
212 void viewplace_modal_keymap(struct wmKeyConfig *keyconf);
213 
214 /* view3d_buttons.c */
216 void view3d_buttons_register(struct ARegionType *art);
217 
218 /* view3d_camera_control.c */
220  Scene *scene,
221  View3D *v3d,
222  RegionView3D *rv3d);
224  const bool use_autokey,
225  struct bContext *C,
226  const bool do_rotate,
227  const bool do_translate);
228 void ED_view3d_cameracontrol_release(struct View3DCameraControl *vctrl, const bool restore);
230 
231 /* view3d_snap.c */
232 bool ED_view3d_minmax_verts(struct Object *obedit, float min[3], float max[3]);
233 
241 
242 /* view3d_placement.c */
244 
245 /* space_view3d.c */
246 extern const char *view3d_context_dir[]; /* doc access */
247 
248 /* view3d_widgets.c */
249 void VIEW3D_GGT_light_spot(struct wmGizmoGroupType *gzgt);
250 void VIEW3D_GGT_light_area(struct wmGizmoGroupType *gzgt);
251 void VIEW3D_GGT_light_target(struct wmGizmoGroupType *gzgt);
252 void VIEW3D_GGT_camera(struct wmGizmoGroupType *gzgt);
253 void VIEW3D_GGT_camera_view(struct wmGizmoGroupType *gzgt);
254 void VIEW3D_GGT_force_field(struct wmGizmoGroupType *gzgt);
255 void VIEW3D_GGT_empty_image(struct wmGizmoGroupType *gzgt);
257 void VIEW3D_GGT_navigate(struct wmGizmoGroupType *gzgt);
262 
263 void VIEW3D_GGT_ruler(struct wmGizmoGroupType *gzgt);
264 void VIEW3D_GT_ruler_item(struct wmGizmoType *gzt);
267 
268 void VIEW3D_GT_navigate_rotate(struct wmGizmoType *gzt);
269 
270 void VIEW3D_GGT_placement(struct wmGizmoGroupType *gzgt);
271 
272 /* workaround for trivial but noticeable camera bug caused by imprecision
273  * between view border calculation in 2D/3D space, workaround for bug T28037.
274  * without this define we get the old behavior which is to try and align them
275  * both which _mostly_ works fine, but when the camera moves beyond ~1000 in
276  * any direction it starts to fail */
277 #define VIEW3D_CAMERA_BORDER_HACK
278 #ifdef VIEW3D_CAMERA_BORDER_HACK
281 #endif
unsigned char uchar
Definition: BLI_sys_types.h:86
struct Depsgraph Depsgraph
Definition: DEG_depsgraph.h:51
#define C
Definition: RandGen.cpp:39
Scene scene
const Depsgraph * depsgraph
static void area(int d1, int d2, int e1, int e2, float weights[2])
#define min(a, b)
Definition: sort.c:51
const float * lens
const float * quat
const float * dist
struct Object * camera
struct Object * camera_old
const float * ofs
const float * dyn_ofs
float max
void VIEW3D_GT_ruler_item(struct wmGizmoType *gzt)
bool ED_view3d_minmax_verts(struct Object *obedit, float min[3], float max[3])
Definition: view3d_snap.c:985
void view3d_keymap(struct wmKeyConfig *keyconf)
Definition: view3d_ops.c:224
void ED_view3d_smooth_view(struct bContext *C, struct View3D *v3d, struct ARegion *region, const int smooth_viewtx, const V3D_SmoothParams *sview)
void viewdolly_modal_keymap(struct wmKeyConfig *keyconf)
Definition: view3d_edit.c:2459
void VIEW3D_OT_snap_selected_to_grid(struct wmOperatorType *ot)
Definition: view3d_snap.c:283
void VIEW3D_OT_zoom_camera_1_to_1(struct wmOperatorType *ot)
Definition: view3d_edit.c:3834
void VIEW3D_OT_toggle_shading(struct wmOperatorType *ot)
Definition: view3d_edit.c:5336
void VIEW3D_OT_camera_to_view(struct wmOperatorType *ot)
Definition: view3d_view.c:512
void VIEW3D_GGT_light_area(struct wmGizmoGroupType *gzgt)
float view3d_depth_near(struct ViewDepths *d)
Definition: view3d_draw.c:2300
void VIEW3D_OT_view_orbit(struct wmOperatorType *ot)
Definition: view3d_edit.c:4337
void VIEW3D_OT_walk(struct wmOperatorType *ot)
Definition: view3d_walk.c:1459
void VIEW3D_GGT_placement(struct wmGizmoGroupType *gzgt)
void view3d_operatortypes(void)
Definition: view3d_ops.c:150
void view3d_draw_region_info(const struct bContext *C, struct ARegion *region)
void view3d_orbit_apply_dyn_ofs(float r_ofs[3], const float ofs_old[3], const float viewquat_old[4], const float viewquat_new[4], const float dyn_ofs[3])
Definition: view3d_edit.c:286
void VIEW3D_OT_view_center_cursor(struct wmOperatorType *ot)
Definition: view3d_edit.c:3306
struct View3DCameraControl * ED_view3d_cameracontrol_acquire(struct Depsgraph *depsgraph, Scene *scene, View3D *v3d, RegionView3D *rv3d)
void VIEW3D_OT_clip_border(struct wmOperatorType *ot)
Definition: view3d_edit.c:4962
void VIEW3D_GGT_ruler(struct wmGizmoGroupType *gzgt)
void VIEW3D_GGT_camera_view(struct wmGizmoGroupType *gzgt)
void ED_view3d_cameracontrol_update(struct View3DCameraControl *vctrl, const bool use_autokey, struct bContext *C, const bool do_rotate, const bool do_translate)
void VIEW3D_OT_select_box(struct wmOperatorType *ot)
void ED_view3d_smooth_view_force_finish(struct bContext *C, struct View3D *v3d, struct ARegion *region)
Definition: view3d_view.c:428
void VIEW3D_OT_toggle_xray(struct wmOperatorType *ot)
Definition: view3d_edit.c:5390
void viewmove_modal_keymap(struct wmKeyConfig *keyconf)
Definition: view3d_edit.c:1692
void VIEW3D_OT_view_pan(struct wmOperatorType *ot)
Definition: view3d_edit.c:4663
void VIEW3D_OT_view_all(struct wmOperatorType *ot)
Definition: view3d_edit.c:2996
@ DRAW_PICKING
Definition: view3d_intern.h:45
@ DRAW_CONSTCOLOR
Definition: view3d_intern.h:46
@ DRAW_SCENESET
Definition: view3d_intern.h:47
void VIEW3D_OT_smoothview(struct wmOperatorType *ot)
Definition: view3d_view.c:444
struct V3D_SmoothParams V3D_SmoothParams
void ED_view3d_draw_select_loop(struct Depsgraph *depsgraph, ViewContext *vc, Scene *scene, struct ViewLayer *view_layer, View3D *v3d, struct ARegion *region, bool use_obedit_skip, bool use_nearest)
void VIEW3D_OT_zoom(struct wmOperatorType *ot)
Definition: view3d_edit.c:2426
void VIEW3D_OT_snap_selected_to_active(struct wmOperatorType *ot)
Definition: view3d_snap.c:634
void walk_modal_keymap(struct wmKeyConfig *keyconf)
Definition: view3d_walk.c:133
void VIEW3D_GT_navigate_rotate(struct wmGizmoType *gzt)
void VIEW3D_OT_snap_selected_to_cursor(struct wmOperatorType *ot)
Definition: view3d_snap.c:593
void VIEW3D_OT_background_image_add(struct wmOperatorType *ot)
Definition: view3d_edit.c:4820
void VIEW3D_OT_view_center_pick(struct wmOperatorType *ot)
Definition: view3d_edit.c:3358
void VIEW3D_OT_render_border(struct wmOperatorType *ot)
Definition: view3d_edit.c:3536
void VIEW3D_OT_snap_cursor_to_selected(struct wmOperatorType *ot)
Definition: view3d_snap.c:874
void VIEW3D_OT_background_image_remove(struct wmOperatorType *ot)
Definition: view3d_edit.c:4878
void VIEW3D_OT_view_persportho(struct wmOperatorType *ot)
Definition: view3d_edit.c:4712
void view3d_boxview_sync(struct ScrArea *area, struct ARegion *region)
Definition: view3d_utils.c:889
uchar view3d_camera_border_hack_col[3]
Definition: drawobject.c:104
void view3d_winmatrix_set(struct Depsgraph *depsgraph, struct ARegion *region, const View3D *v3d, const rcti *rect)
Definition: view3d_view.c:716
void VIEW3D_GGT_tool_generic_handle_normal(struct wmGizmoGroupType *gzgt)
bool view3d_camera_border_hack_test
Definition: drawobject.c:105
void VIEW3D_OT_select(struct wmOperatorType *ot)
void VIEW3D_OT_bone_select_menu(struct wmOperatorType *ot)
void VIEW3D_OT_camera_to_view_selected(struct wmOperatorType *ot)
Definition: view3d_view.c:555
void VIEW3D_OT_view_lock_to_active(struct wmOperatorType *ot)
Definition: view3d_edit.c:3260
void VIEW3D_OT_toggle_matcap_flip(struct wmOperatorType *ot)
Definition: view3d_header.c:84
void VIEW3D_OT_ruler_remove(struct wmOperatorType *ot)
void VIEW3D_OT_select_menu(struct wmOperatorType *ot)
void VIEW3D_OT_cursor3d(struct wmOperatorType *ot)
Definition: view3d_edit.c:5242
void view3d_buttons_register(struct ARegionType *art)
void VIEW3D_GGT_mesh_preselect_elem(struct wmGizmoGroupType *gzgt)
void view3d_main_region_draw(const struct bContext *C, struct ARegion *region)
void VIEW3D_OT_ruler_add(struct wmOperatorType *ot)
void VIEW3D_OT_view_center_lock(struct wmOperatorType *ot)
Definition: view3d_edit.c:3442
void VIEW3D_OT_fly(struct wmOperatorType *ot)
Definition: view3d_fly.c:1134
void VIEW3D_OT_select_circle(struct wmOperatorType *ot)
const char * view3d_context_dir[]
void VIEW3D_OT_select_lasso(struct wmOperatorType *ot)
void VIEW3D_OT_dolly(struct wmOperatorType *ot)
Definition: view3d_edit.c:2739
void fly_modal_keymap(struct wmKeyConfig *keyconf)
Definition: view3d_fly.c:105
void ED_view3d_cameracontrol_release(struct View3DCameraControl *vctrl, const bool restore)
struct Object * ED_view3d_cameracontrol_object_get(struct View3DCameraControl *vctrl)
void viewrotate_modal_keymap(struct wmKeyConfig *keyconf)
Definition: view3d_edit.c:615
void VIEW3D_GGT_empty_image(struct wmGizmoGroupType *gzgt)
void VIEW3D_OT_snap_cursor_to_grid(struct wmOperatorType *ot)
Definition: view3d_snap.c:676
void VIEW3D_OT_navigate(struct wmOperatorType *ot)
Definition: view3d_edit.c:4754
void ED_view3d_smooth_view_ex(const struct Depsgraph *depsgraph, struct wmWindowManager *wm, struct wmWindow *win, struct ScrArea *area, struct View3D *v3d, struct ARegion *region, const int smooth_viewtx, const V3D_SmoothParams *sview)
void VIEW3D_OT_zoom_border(struct wmOperatorType *ot)
Definition: view3d_edit.c:3771
void VIEW3D_GGT_light_spot(struct wmGizmoGroupType *gzgt)
void VIEW3D_OT_view_camera(struct wmOperatorType *ot)
Definition: view3d_edit.c:4201
void ED_view3d_draw_depth_loop(struct Depsgraph *depsgraph, Scene *scene, struct ARegion *region, View3D *v3d)
void VIEW3D_OT_clear_render_border(struct wmOperatorType *ot)
Definition: view3d_edit.c:3596
void VIEW3D_GGT_light_target(struct wmGizmoGroupType *gzgt)
void VIEW3D_GGT_armature_spline(struct wmGizmoGroupType *gzgt)
void VIEW3D_GGT_camera(struct wmGizmoGroupType *gzgt)
void VIEW3D_GGT_navigate(struct wmGizmoGroupType *gzgt)
void VIEW3D_OT_localview(struct wmOperatorType *ot)
Definition: view3d_view.c:1486
bool ED_view3d_boundbox_clip(RegionView3D *rv3d, const struct BoundBox *bb)
void VIEW3D_GGT_mesh_preselect_edgering(struct wmGizmoGroupType *gzgt)
void VIEW3D_OT_view_roll(struct wmOperatorType *ot)
Definition: view3d_edit.c:4578
void VIEW3D_OT_object_mode_pie_or_toggle(struct wmOperatorType *ot)
void VIEW3D_OT_snap_cursor_to_center(struct wmOperatorType *ot)
Definition: view3d_snap.c:960
void VIEW3D_OT_interactive_add(struct wmOperatorType *ot)
void VIEW3D_OT_object_as_camera(struct wmOperatorType *ot)
Definition: view3d_view.c:692
void VIEW3D_OT_localview_remove_from(struct wmOperatorType *ot)
Definition: view3d_view.c:1548
void view3d_boxview_copy(struct ScrArea *area, struct ARegion *region)
Definition: view3d_utils.c:914
void viewplace_modal_keymap(struct wmKeyConfig *keyconf)
void VIEW3D_OT_view_lock_clear(struct wmOperatorType *ot)
Definition: view3d_edit.c:3203
void view3d_viewmatrix_set(struct Depsgraph *depsgraph, const struct Scene *scene, const View3D *v3d, RegionView3D *rv3d, const float rect_scale[2])
void viewzoom_modal_keymap(struct wmKeyConfig *keyconf)
Definition: view3d_edit.c:1890
void VIEW3D_OT_snap_cursor_to_active(struct wmOperatorType *ot)
Definition: view3d_snap.c:923
void view3d_update_depths_rect(struct ARegion *region, struct ViewDepths *d, struct rcti *rect)
Definition: view3d_draw.c:2212
void VIEW3D_OT_view_axis(struct wmOperatorType *ot)
Definition: view3d_edit.c:4078
bool ED_view3d_boundbox_clip_ex(const RegionView3D *rv3d, const struct BoundBox *bb, float obmat[4][4])
void VIEW3D_OT_rotate(struct wmOperatorType *ot)
Definition: view3d_edit.c:1035
void VIEW3D_OT_view_selected(struct wmOperatorType *ot)
Definition: view3d_edit.c:3164
void VIEW3D_OT_move(struct wmOperatorType *ot)
Definition: view3d_edit.c:1861
void VIEW3D_OT_view_center_camera(struct wmOperatorType *ot)
Definition: view3d_edit.c:3410
void VIEW3D_GGT_tool_generic_handle_free(struct wmGizmoGroupType *gzgt)
void VIEW3D_GGT_force_field(struct wmGizmoGroupType *gzgt)
wmOperatorType * ot
Definition: wm_files.c:3156