2 * ***** BEGIN GPL LICENSE BLOCK *****
4 * This program is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU General Public License
6 * as published by the Free Software Foundation; either version 2
7 * of the License, or (at your option) any later version.
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software Foundation,
16 * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
18 * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
19 * All rights reserved.
21 * The Original Code is: all of this file.
23 * Contributor(s): none yet.
25 * ***** END GPL LICENSE BLOCK *****
28 /** \file DNA_view3d_types.h
32 #ifndef __DNA_VIEW3D_TYPES_H__
33 #define __DNA_VIEW3D_TYPES_H__
44 struct SmoothView3DStore;
50 #include "DNA_listBase.h"
51 #include "DNA_image_types.h"
52 #include "DNA_object_types.h"
53 #include "DNA_movieclip_types.h"
54 #include "DNA_gpu_types.h"
56 /* ******************************** */
58 /* The near/far thing is a Win EXCEPTION, caused by indirect includes from <windows.h>.
59 * Thus, leave near/far in the code, and undef for windows. */
65 typedef struct RegionView3D {
67 float winmat[4][4]; /* GL_PROJECTION matrix */
68 float viewmat[4][4]; /* GL_MODELVIEW matrix */
69 float viewinv[4][4]; /* inverse of viewmat */
70 float persmat[4][4]; /* viewmat*winmat */
71 float persinv[4][4]; /* inverse of persmat */
72 float viewcamtexcofac[4]; /* offset/scale for camera glsl texcoords */
74 /* viewmat/persmat multiplied with object matrix, while drawing and selection */
75 float viewmatob[4][4];
76 float persmatob[4][4];
78 /* user defined clipping planes */
80 float clip_local[6][4]; /* clip in object space, means we can test for clipping in editmode without first going into worldspace */
81 struct BoundBox *clipbb;
83 struct RegionView3D *localvd; /* allocated backup of its self while in localview */
84 struct RenderEngine *render_engine;
85 struct ViewDepths *depths;
88 /* animated smooth view */
89 struct SmoothView3DStore *sms;
90 struct wmTimer *smooth_timer;
93 /* transform gizmo matrix */
95 /* min/max dot product on twmat xyz axis. */
96 float tw_axis_min[3], tw_axis_max[3];
97 float tw_axis_matrix[3][3];
99 float gridview DNA_DEPRECATED;
101 float viewquat[4]; /* view rotation, must be kept normalized */
102 float dist; /* distance from 'ofs' along -viewinv[2] vector, where result is negative as is 'ofs' */
103 float camdx, camdy; /* camera view offsets, 1.0 = viewplane moves entire width/height */
104 float pixsize; /* runtime only */
105 float ofs[3]; /* view center & orbit pivot, negative of worldspace location,
106 * also matches -viewinv[3][0:3] in ortho mode.*/
107 float camzoom; /* viewport zoom on the camera frame, see BKE_screen_view3d_zoom_to_fac */
108 char is_persp; /* check if persp/ortho view, since 'persp' cant be used for this since
109 * it can have cameras assigned as well. (only set in view3d_winmatrix_set) */
113 char viewlock_quad; /* options for quadview (store while out of quad view) */
115 float ofs_lock[2]; /* normalized offset for locked view: (-1, -1) bottom left, (1, 1) upper right */
117 short twdrawflag; /* XXX can easily get rid of this (Julian) */
121 /* last view (use when switching out of camera view) */
123 short lpersp, lview; /* lpersp can never be set to 'RV3D_CAMOB' */
125 /* active rotation from NDOF or elsewhere */
130 typedef struct View3DCursor {
136 /* 3D Viewport Shading settings */
137 typedef struct View3DShading {
138 short type; /* Shading type (VIEW3D_SHADE_SOLID, ..) */
139 short prev_type; /* Runtime, for toggle between rendered viewport. */
146 char background_type;
148 char studio_light[256]; /* FILE_MAXFILE */
149 char matcap[256]; /* FILE_MAXFILE */
151 float shadow_intensity;
152 float single_color[3];
154 float studiolight_rot_z;
155 float studiolight_background;
157 float object_outline_color[3];
159 float xray_alpha_wire;
161 float cavity_valley_factor;
162 float cavity_ridge_factor;
164 float background_color[3];
168 /* 3D Viewport Overlay settings */
169 typedef struct View3DOverlay {
172 /* Edit mode settings */
174 float normals_length;
175 float backwire_opacity;
177 /* Paint mode settings */
180 /* Weight paint mode settings */
184 /* Alpha for texture, weight, vertex paint overlay */
185 float texture_paint_mode_opacity;
186 float vertex_paint_mode_opacity;
187 float weight_paint_mode_opacity;
189 /* Armature edit/pose mode settings */
191 float xray_alpha_bone;
194 float wireframe_threshold;
196 /* grease pencil settings */
197 float gpencil_paper_opacity;
198 float gpencil_grid_opacity;
199 float gpencil_fade_layer;
203 /* 3D ViewPort Struct */
204 typedef struct View3D {
205 struct SpaceLink *next, *prev;
206 ListBase regionbase; /* storage of regions for inactive spaces */
210 /* End 'SpaceLink' header. */
212 float viewquat[4] DNA_DEPRECATED;
213 float dist DNA_DEPRECATED;
215 float bundle_size; /* size of bundles in reconstructed data */
216 char bundle_drawtype; /* display style for bundle */
219 unsigned int lay_prev DNA_DEPRECATED; /* for active layer toggle */
220 unsigned int lay_used DNA_DEPRECATED; /* used while drawing */
222 int object_type_exclude_viewport;
223 int object_type_exclude_select;
225 short persp DNA_DEPRECATED;
226 short view DNA_DEPRECATED;
228 struct Object *camera, *ob_centre;
231 struct View3D *localvd; /* allocated backup of its self while in localview */
233 char ob_centre_bone[64]; /* optional string for armature bone to define center, MAXBONENAME */
235 unsigned int lay DNA_DEPRECATED;
236 int layact DNA_DEPRECATED;
238 short ob_centre_cursor; /* optional bool for 3d cursor to define center */
246 float ofs[3] DNA_DEPRECATED; /* XXX deprecated */
252 short matcap_icon; /* icon id */
255 short gridsubdiv; /* Number of subdivisions in the grid between each highlighted grid line */
258 /* transform gizmo info */
259 char _pad5[2], gizmo_flag;
263 /* drawflags, denoting state */
267 char multiview_eye; /* multiview current eye - for internal use */
269 /* actually only used to define the opacity of the grease pencil vertex in edit mode */
270 float vertex_opacity;
272 /* note, 'fx_settings.dof' is currently _not_ allocated,
273 * instead set (temporarily) from camera */
274 struct GPUFXSettings fx_settings;
276 void *properties_storage; /* Nkey panel stores stuff here (runtime only!) */
278 /* XXX deprecated? */
279 struct bGPdata *gpd DNA_DEPRECATED; /* Grease-Pencil Data (annotation layers) */
281 /* Stereoscopy settings */
283 char stereo3d_camera;
285 float stereo3d_convergence_factor;
286 float stereo3d_volume_alpha;
287 float stereo3d_convergence_alpha;
289 /* Display settings */
290 short drawtype DNA_DEPRECATED;
293 View3DShading shading;
294 View3DOverlay overlay;
298 /* View3D->stereo_flag (short) */
299 #define V3D_S3D_DISPCAMERAS (1 << 0)
300 #define V3D_S3D_DISPPLANE (1 << 1)
301 #define V3D_S3D_DISPVOLUME (1 << 2)
303 /* View3D->flag (short) */
304 /*#define V3D_FLAG_DEPRECATED_1 (1 << 0) */ /*UNUSED */
305 /*#define V3D_FLAG_DEPRECATED_2 (1 << 1) */ /* UNUSED */
306 #define V3D_HIDE_HELPLINES 4
307 #define V3D_INVALID_BACKBUF 8
309 /* #define V3D_FLAG_DEPRECATED_10 (1 << 10) */ /* UNUSED */
310 #define V3D_SELECT_OUTLINE 2048
311 #define V3D_ZBUF_SELECT 4096 /* XXX: DNA deprecated */
312 #define V3D_GLOBAL_STATS 8192
313 #define V3D_DRAW_CENTERS 32768
315 /* RegionView3d->persp */
320 /* RegionView3d->rflag */
321 #define RV3D_CLIPPING 4
322 #define RV3D_NAVIGATING 8
323 #define RV3D_GPULIGHT_UPDATE 16
324 /*#define RV3D_IS_GAME_ENGINE 32 *//* UNUSED */
326 * Disable zbuffer offset, skip calls to #ED_view3d_polygon_offset.
327 * Use when precise surface depth is needed and picking bias isn't, see T45434).
329 #define RV3D_ZOFFSET_DISABLED 64
331 /* RegionView3d->viewlock */
332 #define RV3D_LOCKED (1 << 0)
333 #define RV3D_BOXVIEW (1 << 1)
334 #define RV3D_BOXCLIP (1 << 2)
335 /* RegionView3d->viewlock_quad */
336 #define RV3D_VIEWLOCK_INIT (1 << 7)
338 /* RegionView3d->view */
339 #define RV3D_VIEW_USER 0
340 #define RV3D_VIEW_FRONT 1
341 #define RV3D_VIEW_BACK 2
342 #define RV3D_VIEW_LEFT 3
343 #define RV3D_VIEW_RIGHT 4
344 #define RV3D_VIEW_TOP 5
345 #define RV3D_VIEW_BOTTOM 6
346 #define RV3D_VIEW_CAMERA 8
348 #define RV3D_VIEW_IS_AXIS(view) \
349 (((view) >= RV3D_VIEW_FRONT) && ((view) <= RV3D_VIEW_BOTTOM))
351 /* View3d->flag2 (int) */
352 #define V3D_RENDER_OVERRIDE (1 << 2)
353 #define V3D_SOLID_TEX (1 << 3)
354 #define V3D_SHOW_ANNOTATION (1 << 4)
355 #define V3D_LOCK_CAMERA (1 << 5)
356 #define V3D_RENDER_SHADOW (1 << 6) /* This is a runtime only flag that's used to tell draw_mesh_object() that we're doing a shadow pass instead of a regular draw */
357 #define V3D_SHOW_RECONSTRUCTION (1 << 7)
358 #define V3D_SHOW_CAMERAPATH (1 << 8)
359 #define V3D_SHOW_BUNDLENAME (1 << 9)
360 #define V3D_BACKFACE_CULLING (1 << 10)
361 #define V3D_RENDER_BORDER (1 << 11)
362 #define V3D_SOLID_MATCAP (1 << 12) /* user flag */
363 #define V3D_SHOW_SOLID_MATCAP (1 << 13) /* runtime flag */
364 #define V3D_OCCLUDE_WIRE (1 << 14) /* XXX: DNA deprecated */
365 #define V3D_SHOW_MODE_SHADE_OVERRIDE (1 << 15) /* XXX: DNA deprecated */
367 /* View3d->gp_flag (short) */
368 #define V3D_GP_SHOW_PAPER (1 << 0) /* Activate paper to cover all viewport */
369 #define V3D_GP_SHOW_GRID (1 << 1) /* Activate paper grid */
370 #define V3D_GP_SHOW_EDIT_LINES (1 << 2)
371 #define V3D_GP_SHOW_MULTIEDIT_LINES (1 << 3)
372 #define V3D_GP_SHOW_ONION_SKIN (1 << 4) /* main switch at view level */
373 #define V3D_GP_FADE_NOACTIVE_LAYERS (1 << 5) /* fade layers not active */
375 /* View3DShading->light */
377 V3D_LIGHTING_FLAT = 0,
378 V3D_LIGHTING_STUDIO = 1,
379 V3D_LIGHTING_MATCAP = 2,
382 /* View3DShading->flag */
384 V3D_SHADING_OBJECT_OUTLINE = (1 << 0),
385 V3D_SHADING_XRAY = (1 << 1),
386 V3D_SHADING_SHADOW = (1 << 2),
387 V3D_SHADING_SCENE_LIGHTS = (1 << 3),
388 V3D_SHADING_SPECULAR_HIGHLIGHT = (1 << 4),
389 V3D_SHADING_CAVITY = (1 << 5),
390 V3D_SHADING_MATCAP_FLIP_X = (1 << 6),
391 V3D_SHADING_SCENE_WORLD = (1 << 7),
392 V3D_SHADING_XRAY_BONE = (1 << 8),
395 /* View3DShading->color_type */
397 V3D_SHADING_MATERIAL_COLOR = 0,
398 V3D_SHADING_RANDOM_COLOR = 1,
399 V3D_SHADING_SINGLE_COLOR = 2,
400 V3D_SHADING_TEXTURE_COLOR = 3,
403 /* View3DShading->background_type */
405 V3D_SHADING_BACKGROUND_THEME = 0,
406 V3D_SHADING_BACKGROUND_WORLD = 1,
407 V3D_SHADING_BACKGROUND_VIEWPORT = 2,
410 /* View3DOverlay->flag */
412 V3D_OVERLAY_FACE_ORIENTATION = (1 << 0),
413 V3D_OVERLAY_HIDE_CURSOR = (1 << 1),
414 V3D_OVERLAY_BONE_SELECT = (1 << 2),
415 V3D_OVERLAY_LOOK_DEV = (1 << 3),
416 V3D_OVERLAY_WIREFRAMES = (1 << 4),
417 V3D_OVERLAY_HIDE_TEXT = (1 << 5),
418 V3D_OVERLAY_HIDE_MOTION_PATHS = (1 << 6),
419 V3D_OVERLAY_ONION_SKINS = (1 << 7),
420 V3D_OVERLAY_HIDE_BONES = (1 << 8),
421 V3D_OVERLAY_HIDE_OBJECT_XTRAS = (1 << 9),
422 V3D_OVERLAY_HIDE_OBJECT_ORIGINS = (1 << 10),
425 /* View3DOverlay->edit_flag */
427 V3D_OVERLAY_EDIT_VERT_NORMALS = (1 << 0),
428 V3D_OVERLAY_EDIT_LOOP_NORMALS = (1 << 1),
429 V3D_OVERLAY_EDIT_FACE_NORMALS = (1 << 2),
431 V3D_OVERLAY_EDIT_OCCLUDE_WIRE = (1 << 3),
433 V3D_OVERLAY_EDIT_WEIGHT = (1 << 4),
435 V3D_OVERLAY_EDIT_EDGES = (1 << 5),
436 V3D_OVERLAY_EDIT_FACES = (1 << 6),
437 V3D_OVERLAY_EDIT_FACE_DOT = (1 << 7),
439 V3D_OVERLAY_EDIT_SEAMS = (1 << 8),
440 V3D_OVERLAY_EDIT_SHARP = (1 << 9),
441 V3D_OVERLAY_EDIT_CREASES = (1 << 10),
442 V3D_OVERLAY_EDIT_BWEIGHTS = (1 << 11),
444 V3D_OVERLAY_EDIT_FREESTYLE_EDGE = (1 << 12),
445 V3D_OVERLAY_EDIT_FREESTYLE_FACE = (1 << 13),
447 V3D_OVERLAY_EDIT_STATVIS = (1 << 14),
448 V3D_OVERLAY_EDIT_EDGE_LEN = (1 << 15),
449 V3D_OVERLAY_EDIT_EDGE_ANG = (1 << 16),
450 V3D_OVERLAY_EDIT_FACE_ANG = (1 << 17),
451 V3D_OVERLAY_EDIT_FACE_AREA = (1 << 18),
452 V3D_OVERLAY_EDIT_INDICES = (1 << 19),
454 V3D_OVERLAY_EDIT_CU_HANDLES = (1 << 20),
455 V3D_OVERLAY_EDIT_CU_NORMALS = (1 << 21),
458 /* View3DOverlay->arm_flag */
460 V3D_OVERLAY_ARM_TRANSP_BONES = (1 << 0),
463 /* View3DOverlay->paint_flag */
465 V3D_OVERLAY_PAINT_WIRE = (1 << 0),
468 /* View3DOverlay->wpaint_flag */
470 V3D_OVERLAY_WPAINT_CONTOURS = (1 << 0),
475 /* center of the bounding box */
476 V3D_AROUND_CENTER_BOUNDS = 0,
477 /* center from the sum of all points divided by the total */
478 V3D_AROUND_CENTER_MEAN = 3,
479 /* pivot around the 2D/3D cursor */
480 V3D_AROUND_CURSOR = 1,
481 /* pivot around each items own origin */
482 V3D_AROUND_LOCAL_ORIGINS = 2,
483 /* pivot around the active items origin */
484 V3D_AROUND_ACTIVE = 4,
487 /*View3D types (only used in tools, not actually saved)*/
488 #define V3D_VIEW_STEPLEFT 1
489 #define V3D_VIEW_STEPRIGHT 2
490 #define V3D_VIEW_STEPDOWN 3
491 #define V3D_VIEW_STEPUP 4
492 #define V3D_VIEW_PANLEFT 5
493 #define V3D_VIEW_PANRIGHT 6
494 #define V3D_VIEW_PANDOWN 7
495 #define V3D_VIEW_PANUP 8
497 /* View3d->gridflag */
498 #define V3D_SHOW_FLOOR 1
503 /* Scene.orientation_type */
504 #define V3D_MANIP_GLOBAL 0
505 #define V3D_MANIP_LOCAL 1
506 #define V3D_MANIP_NORMAL 2
507 #define V3D_MANIP_VIEW 3
508 #define V3D_MANIP_GIMBAL 4
509 #define V3D_MANIP_CURSOR 5
510 #define V3D_MANIP_CUSTOM_MATRIX (V3D_MANIP_CUSTOM - 1) /* Runtime only, never saved to DNA. */
511 #define V3D_MANIP_CUSTOM 1024
513 /* View3d.mpr_flag (also) */
516 V3D_GIZMO_HIDE = (1 << 0),
517 V3D_GIZMO_HIDE_NAVIGATE = (1 << 1),
518 V3D_GIZMO_HIDE_CONTEXT = (1 << 2),
519 V3D_GIZMO_HIDE_TOOL = (1 << 3),
522 #define RV3D_CAMZOOM_MIN -30
523 #define RV3D_CAMZOOM_MAX 600
525 /* #BKE_screen_view3d_zoom_to_fac() values above */
526 #define RV3D_CAMZOOM_MIN_FACTOR 0.1657359312880714853f
527 #define RV3D_CAMZOOM_MAX_FACTOR 44.9852813742385702928f