4 * ***** BEGIN GPL LICENSE BLOCK *****
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public License
8 * as published by the Free Software Foundation; either version 2
9 * of the License, or (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software Foundation,
18 * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
20 * The Original Code is Copyright (C) 2008 Blender Foundation.
21 * All rights reserved.
24 * Contributor(s): Blender Foundation
26 * ***** END GPL LICENSE BLOCK *****
36 /* ********* exports for space_view3d/ module ********** */
58 /* for derivedmesh drawing callbacks, for view3d_select, .... */
59 typedef struct ViewContext {
62 struct Object *obedit;
65 struct RegionView3D *rv3d;
70 typedef struct ViewDepths {
72 short x, y; /* only for temp use for sub-rects, added to ar->winx/y */
74 double depth_range[2];
80 float *give_cursor(struct Scene *scene, struct View3D *v3d);
82 int initgrabz(struct RegionView3D *rv3d, float x, float y, float z);
83 void window_to_3d(struct ARegion *ar, float *vec, short mx, short my);
84 void window_to_3d_delta(struct ARegion *ar, float *vec, short mx, short my);
85 void view3d_unproject(struct bglMats *mats, float out[3], const short x, const short y, const float z);
88 void view3d_update_depths(struct ARegion *ar);
89 float read_cached_depth(struct ViewContext *vc, int x, int y);
90 void request_depth_update(struct RegionView3D *rv3d);
93 #define IS_CLIPPED 12000
95 void view3d_calculate_clipping(struct BoundBox *bb, float planes[4][4], struct bglMats *mats, struct rcti *rect);
97 void project_short(struct ARegion *ar, float *vec, short *adr);
98 void project_short_noclip(struct ARegion *ar, float *vec, short *adr);
100 void project_int(struct ARegion *ar, float *vec, int *adr);
101 void project_int_noclip(struct ARegion *ar, float *vec, int *adr);
103 void project_float(struct ARegion *ar, float *vec, float *adr);
104 void project_float_noclip(struct ARegion *ar, float *vec, float *adr);
106 void viewvector(struct RegionView3D *rv3d, float coord[3], float vec[3]);
108 void viewline(struct ARegion *ar, struct View3D *v3d, float mval[2], float ray_start[3], float ray_end[3]);
109 void viewray(struct ARegion *ar, struct View3D *v3d, float mval[2], float ray_start[3], float ray_normal[3]);
111 int get_view3d_cliprange(struct View3D *v3d, struct RegionView3D *rv3d, float *clipsta, float *clipend);
112 int get_view3d_viewplane(struct View3D *v3d, struct RegionView3D *rv3d, int winxi, int winyi, struct rctf *viewplane, float *clipsta, float *clipend, float *pixsize);
113 int get_view3d_ortho(struct View3D *v3d, struct RegionView3D *rv3d);
114 void view3d_get_object_project_mat(struct RegionView3D *v3d, struct Object *ob, float pmat[4][4]);
115 void view3d_project_float(struct ARegion *a, float *vec, float *adr, float mat[4][4]);
116 void view3d_calc_camera_border(struct Scene *scene, struct ARegion *ar, struct RegionView3D *rv3d, struct View3D *v3d, struct rctf *viewborder_r, short do_shift);
118 /* drawobject.c iterators */
119 void mesh_foreachScreenVert(struct ViewContext *vc, void (*func)(void *userData, struct EditVert *eve, int x, int y, int index), void *userData, int clipVerts);
120 void mesh_foreachScreenEdge(struct ViewContext *vc, void (*func)(void *userData, struct EditEdge *eed, int x0, int y0, int x1, int y1, int index), void *userData, int clipVerts);
121 void mesh_foreachScreenFace(struct ViewContext *vc, void (*func)(void *userData, struct EditFace *efa, int x, int y, int index), void *userData);
122 void nurbs_foreachScreenVert(struct ViewContext *vc, void (*func)(void *userData, struct Nurb *nu, struct BPoint *bp, struct BezTriple *bezt, int beztindex, int x, int y), void *userData);
123 void lattice_foreachScreenVert(struct ViewContext *vc, void (*func)(void *userData, struct BPoint *bp, int x, int y), void *userData);
125 void ED_view3d_local_clipping(struct RegionView3D *rv3d, float mat[][4]);
126 int view3d_test_clipping(struct RegionView3D *rv3d, float *vec, int local);
127 void view3d_align_axis_to_vector(struct View3D *v3d, struct RegionView3D *rv3d, int axisidx, float vec[3]);
128 float view3d_pixel_size(struct RegionView3D *rv3d, const float co[3]);
130 void drawcircball(int mode, const float cent[3], float rad, float tmat[][4]);
132 /* backbuffer select and draw support */
133 void view3d_validate_backbuf(struct ViewContext *vc);
134 struct ImBuf *view3d_read_backbuf(struct ViewContext *vc, short xmin, short ymin, short xmax, short ymax);
135 unsigned int view3d_sample_backbuf_rect(struct ViewContext *vc, short mval[2], int size, unsigned int min, unsigned int max, int *dist, short strict,
136 void *handle, unsigned int (*indextest)(void *handle, unsigned int index));
137 unsigned int view3d_sample_backbuf(struct ViewContext *vc, int x, int y);
139 /* draws and does a 4x4 sample */
140 int view_autodist(struct Scene *scene, struct ARegion *ar, struct View3D *v3d, short *mval, float mouse_worldloc[3]);
142 /* only draw so view_autodist_simple can be called many times after */
143 int view_autodist_init(struct Scene *scene, struct ARegion *ar, struct View3D *v3d, int mode);
144 int view_autodist_simple(struct ARegion *ar, short mval[2], float mouse_worldloc[3], int margin, float *force_depth);
145 int view_autodist_depth(struct ARegion *ar, short mval[2], int margin, float *depth);
146 int view_autodist_depth_segment(struct ARegion *ar, short mval_sta[2], short mval_end[2], int margin, float *depth);
149 #define MAXPICKBUF 10000
150 short view3d_opengl_select(struct ViewContext *vc, unsigned int *buffer, unsigned int bufsize, rcti *input);
152 void view3d_set_viewcontext(struct bContext *C, struct ViewContext *vc);
153 void view3d_operator_needs_opengl(const struct bContext *C);
154 void view3d_region_operator_needs_opengl(struct wmWindow *win, struct ARegion *ar);
155 void view3d_get_view_aligned_coordinate(struct ViewContext *vc, float *fp, short mval[2]);
156 void view3d_get_transformation(struct ARegion *ar, struct RegionView3D *rv3d, struct Object *ob, struct bglMats *mats);
158 /* XXX should move to BLI_math */
159 int edge_inside_circle(short centx, short centy, short rad, short x1, short y1, short x2, short y2);
160 int lasso_inside(short mcords[][2], short moves, short sx, short sy);
161 int lasso_inside_edge(short mcords[][2], short moves, int x0, int y0, int x1, int y1);
163 /* get 3d region from context, also if mouse is in header or toolbar */
164 struct RegionView3D *ED_view3d_context_rv3d(struct bContext *C);
166 void ED_view3d_init_mats_rv3d(struct Object *ob, struct RegionView3D *rv3d);
168 int ED_view3d_scene_layer_set(int lay, const int *values, int *active);
170 int ED_view3d_context_activate(struct bContext *C);
171 void ED_view3d_draw_offscreen(struct Scene *scene, struct View3D *v3d, struct ARegion *ar,
172 int winx, int winy, float viewmat[][4], float winmat[][4]);
174 struct ImBuf *ED_view3d_draw_offscreen_imbuf(struct Scene *scene, struct View3D *v3d, struct ARegion *ar, int sizex, int sizey, unsigned int flag, char err_out[256]);
175 struct ImBuf *ED_view3d_draw_offscreen_imbuf_simple(Scene *scene, int width, int height, unsigned int flag, int drawtype, char err_out[256]);
178 Base *ED_view3d_give_base_under_cursor(struct bContext *C, short *mval);
179 void ED_view3d_quadview_update(struct ScrArea *sa, struct ARegion *ar, short do_clip);
180 int ED_view3d_lock(struct RegionView3D *rv3d);
182 unsigned int ED_viewedit_datamask(struct bScreen *screen);
184 #endif /* ED_VIEW3D_H */