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 /** GL_PROJECTION matrix. */
69 /** GL_MODELVIEW matrix. */
71 /** Inverse of viewmat. */
73 /** Viewmat*winmat. */
75 /** Inverse of persmat. */
77 /** Offset/scale for camera glsl texcoords. */
78 float viewcamtexcofac[4];
80 /** viewmat/persmat multiplied with object matrix, while drawing and selection. */
81 float viewmatob[4][4];
82 float persmatob[4][4];
84 /** User defined clipping planes. */
86 /** Clip in object space, means we can test for clipping in editmode without first going into worldspace. */
87 float clip_local[6][4];
88 struct BoundBox *clipbb;
90 /** Allocated backup of its self while in localview. */
91 struct RegionView3D *localvd;
92 struct RenderEngine *render_engine;
93 struct ViewDepths *depths;
96 /** Animated smooth view. */
97 struct SmoothView3DStore *sms;
98 struct wmTimer *smooth_timer;
101 /** Transform gizmo matrix. */
103 /** min/max dot product on twmat xyz axis. */
104 float tw_axis_min[3], tw_axis_max[3];
105 float tw_axis_matrix[3][3];
107 float gridview DNA_DEPRECATED;
109 /** View rotation, must be kept normalized. */
111 /** Distance from 'ofs' along -viewinv[2] vector, where result is negative as is 'ofs'. */
113 /** Camera view offsets, 1.0 = viewplane moves entire width/height. */
118 * View center & orbit pivot, negative of worldspace location,
119 * also matches -viewinv[3][0:3] in ortho mode.
122 /** Viewport zoom on the camera frame, see BKE_screen_view3d_zoom_to_fac. */
125 * Check if persp/ortho view, since 'persp' cant be used for this since
126 * it can have cameras assigned as well. (only set in #view3d_winmatrix_set)
132 /** Options for quadview (store while out of quad view). */
135 /** Normalized offset for locked view: (-1, -1) bottom left, (1, 1) upper right. */
138 /** XXX can easily get rid of this (Julian). */
143 /** Last view (use when switching out of camera view). */
145 /** Lpersp can never be set to 'RV3D_CAMOB'. */
148 /** Active rotation from NDOF or elsewhere. */
153 typedef struct View3DCursor {
159 /* 3D Viewport Shading settings */
160 typedef struct View3DShading {
161 /** Shading type (VIEW3D_SHADE_SOLID, ..). */
163 /** Runtime, for toggle between rendered viewport. */
171 char background_type;
176 char studio_light[256];
178 char lookdev_light[256];
182 float shadow_intensity;
183 float single_color[3];
185 float studiolight_rot_z;
186 float studiolight_background;
188 float object_outline_color[3];
190 float xray_alpha_wire;
192 float cavity_valley_factor;
193 float cavity_ridge_factor;
195 float background_color[3];
197 float curvature_ridge_factor;
198 float curvature_valley_factor;
202 /* 3D Viewport Overlay settings */
203 typedef struct View3DOverlay {
206 /* Edit mode settings */
208 float normals_length;
209 float backwire_opacity;
211 /* Paint mode settings */
214 /* Weight paint mode settings */
218 /* Alpha for texture, weight, vertex paint overlay */
219 float texture_paint_mode_opacity;
220 float vertex_paint_mode_opacity;
221 float weight_paint_mode_opacity;
223 /* Armature edit/pose mode settings */
225 float xray_alpha_bone;
228 float wireframe_threshold;
230 /* grease pencil settings */
231 float gpencil_paper_opacity;
232 float gpencil_grid_opacity;
233 float gpencil_fade_layer;
237 /* 3D ViewPort Struct */
238 typedef struct View3D {
239 struct SpaceLink *next, *prev;
240 /** Storage of regions for inactive spaces. */
245 /* End 'SpaceLink' header. */
247 float viewquat[4] DNA_DEPRECATED;
248 float dist DNA_DEPRECATED;
250 /** Size of bundles in reconstructed data. */
252 /** Display style for bundle. */
253 char bundle_drawtype;
256 /** For active layer toggle. */
257 unsigned int lay_prev DNA_DEPRECATED;
258 /** Used while drawing. */
259 unsigned int lay_used DNA_DEPRECATED;
261 int object_type_exclude_viewport;
262 int object_type_exclude_select;
264 short persp DNA_DEPRECATED;
265 short view DNA_DEPRECATED;
267 struct Object *camera, *ob_centre;
270 /** Allocated backup of its self while in localview. */
271 struct View3D *localvd;
273 /** Optional string for armature bone to define center, MAXBONENAME. */
274 char ob_centre_bone[64];
276 unsigned short local_view_uuid;
278 int layact DNA_DEPRECATED;
280 /** Optional bool for 3d cursor to define center. */
281 short ob_centre_cursor;
289 float ofs[3] DNA_DEPRECATED;
297 /** Number of subdivisions in the grid between each highlighted grid line. */
301 /* transform gizmo info */
302 char _pad5[2], gizmo_flag;
306 /* drawflags, denoting state */
310 /** Multiview current eye - for internal use. */
313 /* actually only used to define the opacity of the grease pencil vertex in edit mode */
314 float vertex_opacity;
316 /* note, 'fx_settings.dof' is currently _not_ allocated,
317 * instead set (temporarily) from camera */
318 struct GPUFXSettings fx_settings;
320 /** Nkey panel stores stuff here (runtime only!). */
321 void *properties_storage;
323 /* XXX deprecated? */
324 /** Grease-Pencil Data (annotation layers). */
325 struct bGPdata *gpd DNA_DEPRECATED;
327 /* Stereoscopy settings */
329 char stereo3d_camera;
331 float stereo3d_convergence_factor;
332 float stereo3d_volume_alpha;
333 float stereo3d_convergence_alpha;
335 /* Display settings */
336 short drawtype DNA_DEPRECATED;
339 View3DShading shading;
340 View3DOverlay overlay;
344 /* View3D->stereo_flag (short) */
345 #define V3D_S3D_DISPCAMERAS (1 << 0)
346 #define V3D_S3D_DISPPLANE (1 << 1)
347 #define V3D_S3D_DISPVOLUME (1 << 2)
349 /* View3D->flag (short) */
350 #define V3D_FLAG_DEPRECATED_0 (1 << 0) /* cleared */
351 #define V3D_FLAG_DEPRECATED_1 (1 << 1) /* cleared */
352 #define V3D_HIDE_HELPLINES (1 << 2)
353 #define V3D_INVALID_BACKBUF (1 << 3)
355 #define V3D_FLAG_DEPRECATED_10 (1 << 10) /* cleared */
356 #define V3D_SELECT_OUTLINE (1 << 11)
357 #define V3D_FLAG_DEPRECATED_12 (1 << 12) /* cleared */
358 #define V3D_GLOBAL_STATS (1 << 13)
359 #define V3D_DRAW_CENTERS (1 << 15)
361 /* RegionView3d->persp */
366 /* RegionView3d->rflag */
367 #define RV3D_CLIPPING (1 << 2)
368 #define RV3D_NAVIGATING (1 << 3)
369 #define RV3D_GPULIGHT_UPDATE (1 << 4)
370 /*#define RV3D_IS_GAME_ENGINE (1 << 5) *//* UNUSED */
372 * Disable zbuffer offset, skip calls to #ED_view3d_polygon_offset.
373 * Use when precise surface depth is needed and picking bias isn't, see T45434).
375 #define RV3D_ZOFFSET_DISABLED 64
377 /* RegionView3d->viewlock */
378 #define RV3D_LOCKED (1 << 0)
379 #define RV3D_BOXVIEW (1 << 1)
380 #define RV3D_BOXCLIP (1 << 2)
381 /* RegionView3d->viewlock_quad */
382 #define RV3D_VIEWLOCK_INIT (1 << 7)
384 /* RegionView3d->view */
385 #define RV3D_VIEW_USER 0
386 #define RV3D_VIEW_FRONT 1
387 #define RV3D_VIEW_BACK 2
388 #define RV3D_VIEW_LEFT 3
389 #define RV3D_VIEW_RIGHT 4
390 #define RV3D_VIEW_TOP 5
391 #define RV3D_VIEW_BOTTOM 6
392 #define RV3D_VIEW_CAMERA 8
394 #define RV3D_VIEW_IS_AXIS(view) \
395 (((view) >= RV3D_VIEW_FRONT) && ((view) <= RV3D_VIEW_BOTTOM))
397 /* View3d->flag2 (int) */
398 #define V3D_RENDER_OVERRIDE (1 << 2)
399 #define V3D_FLAG2_DEPRECATED_3 (1 << 3) /* cleared */
400 #define V3D_SHOW_ANNOTATION (1 << 4)
401 #define V3D_LOCK_CAMERA (1 << 5)
402 #define V3D_FLAG2_DEPRECATED_6 (1 << 6) /* cleared */
403 #define V3D_SHOW_RECONSTRUCTION (1 << 7)
404 #define V3D_SHOW_CAMERAPATH (1 << 8)
405 #define V3D_SHOW_BUNDLENAME (1 << 9)
406 #define V3D_FLAG2_DEPRECATED_10 (1 << 10) /* cleared */
407 #define V3D_RENDER_BORDER (1 << 11)
408 #define V3D_FLAG2_DEPRECATED_12 (1 << 12) /* cleared */
409 #define V3D_FLAG2_DEPRECATED_13 (1 << 13) /* cleared */
410 #define V3D_FLAG2_DEPRECATED_14 (1 << 14) /* cleared */
411 #define V3D_FLAG2_DEPRECATED_15 (1 << 15) /* cleared */
413 /* View3d->gp_flag (short) */
414 #define V3D_GP_SHOW_PAPER (1 << 0) /* Activate paper to cover all viewport */
415 #define V3D_GP_SHOW_GRID (1 << 1) /* Activate paper grid */
416 #define V3D_GP_SHOW_EDIT_LINES (1 << 2)
417 #define V3D_GP_SHOW_MULTIEDIT_LINES (1 << 3)
418 #define V3D_GP_SHOW_ONION_SKIN (1 << 4) /* main switch at view level */
419 #define V3D_GP_FADE_NOACTIVE_LAYERS (1 << 5) /* fade layers not active */
421 /* View3DShading->light */
423 V3D_LIGHTING_FLAT = 0,
424 V3D_LIGHTING_STUDIO = 1,
425 V3D_LIGHTING_MATCAP = 2,
428 /* View3DShading->flag */
430 V3D_SHADING_OBJECT_OUTLINE = (1 << 0),
431 V3D_SHADING_XRAY = (1 << 1),
432 V3D_SHADING_SHADOW = (1 << 2),
433 V3D_SHADING_SCENE_LIGHTS = (1 << 3),
434 V3D_SHADING_SPECULAR_HIGHLIGHT = (1 << 4),
435 V3D_SHADING_CAVITY = (1 << 5),
436 V3D_SHADING_MATCAP_FLIP_X = (1 << 6),
437 V3D_SHADING_SCENE_WORLD = (1 << 7),
438 V3D_SHADING_XRAY_BONE = (1 << 8),
439 V3D_SHADING_WORLD_ORIENTATION = (1 << 9),
440 V3D_SHADING_BACKFACE_CULLING = (1 << 10),
443 /* View3DShading->color_type */
445 V3D_SHADING_MATERIAL_COLOR = 0,
446 V3D_SHADING_RANDOM_COLOR = 1,
447 V3D_SHADING_SINGLE_COLOR = 2,
448 V3D_SHADING_TEXTURE_COLOR = 3,
449 V3D_SHADING_OBJECT_COLOR = 4,
452 /* View3DShading->background_type */
454 V3D_SHADING_BACKGROUND_THEME = 0,
455 V3D_SHADING_BACKGROUND_WORLD = 1,
456 V3D_SHADING_BACKGROUND_VIEWPORT = 2,
459 /* View3DShading->cavity_type */
461 V3D_SHADING_CAVITY_SSAO = 0,
462 V3D_SHADING_CAVITY_CURVATURE = 1,
463 V3D_SHADING_CAVITY_BOTH = 2,
466 /* View3DOverlay->flag */
468 V3D_OVERLAY_FACE_ORIENTATION = (1 << 0),
469 V3D_OVERLAY_HIDE_CURSOR = (1 << 1),
470 V3D_OVERLAY_BONE_SELECT = (1 << 2),
471 V3D_OVERLAY_LOOK_DEV = (1 << 3),
472 V3D_OVERLAY_WIREFRAMES = (1 << 4),
473 V3D_OVERLAY_HIDE_TEXT = (1 << 5),
474 V3D_OVERLAY_HIDE_MOTION_PATHS = (1 << 6),
475 V3D_OVERLAY_ONION_SKINS = (1 << 7),
476 V3D_OVERLAY_HIDE_BONES = (1 << 8),
477 V3D_OVERLAY_HIDE_OBJECT_XTRAS = (1 << 9),
478 V3D_OVERLAY_HIDE_OBJECT_ORIGINS = (1 << 10),
481 /* View3DOverlay->edit_flag */
483 V3D_OVERLAY_EDIT_VERT_NORMALS = (1 << 0),
484 V3D_OVERLAY_EDIT_LOOP_NORMALS = (1 << 1),
485 V3D_OVERLAY_EDIT_FACE_NORMALS = (1 << 2),
487 V3D_OVERLAY_EDIT_OCCLUDE_WIRE = (1 << 3),
489 V3D_OVERLAY_EDIT_WEIGHT = (1 << 4),
491 V3D_OVERLAY_EDIT_EDGES = (1 << 5),
492 V3D_OVERLAY_EDIT_FACES = (1 << 6),
493 V3D_OVERLAY_EDIT_FACE_DOT = (1 << 7),
495 V3D_OVERLAY_EDIT_SEAMS = (1 << 8),
496 V3D_OVERLAY_EDIT_SHARP = (1 << 9),
497 V3D_OVERLAY_EDIT_CREASES = (1 << 10),
498 V3D_OVERLAY_EDIT_BWEIGHTS = (1 << 11),
500 V3D_OVERLAY_EDIT_FREESTYLE_EDGE = (1 << 12),
501 V3D_OVERLAY_EDIT_FREESTYLE_FACE = (1 << 13),
503 V3D_OVERLAY_EDIT_STATVIS = (1 << 14),
504 V3D_OVERLAY_EDIT_EDGE_LEN = (1 << 15),
505 V3D_OVERLAY_EDIT_EDGE_ANG = (1 << 16),
506 V3D_OVERLAY_EDIT_FACE_ANG = (1 << 17),
507 V3D_OVERLAY_EDIT_FACE_AREA = (1 << 18),
508 V3D_OVERLAY_EDIT_INDICES = (1 << 19),
510 V3D_OVERLAY_EDIT_CU_HANDLES = (1 << 20),
511 V3D_OVERLAY_EDIT_CU_NORMALS = (1 << 21),
514 /* View3DOverlay->arm_flag */
516 V3D_OVERLAY_ARM_TRANSP_BONES = (1 << 0),
519 /* View3DOverlay->paint_flag */
521 V3D_OVERLAY_PAINT_WIRE = (1 << 0),
524 /* View3DOverlay->wpaint_flag */
526 V3D_OVERLAY_WPAINT_CONTOURS = (1 << 0),
531 /* center of the bounding box */
532 V3D_AROUND_CENTER_BOUNDS = 0,
533 /* center from the sum of all points divided by the total */
534 V3D_AROUND_CENTER_MEDIAN = 3,
535 /* pivot around the 2D/3D cursor */
536 V3D_AROUND_CURSOR = 1,
537 /* pivot around each items own origin */
538 V3D_AROUND_LOCAL_ORIGINS = 2,
539 /* pivot around the active items origin */
540 V3D_AROUND_ACTIVE = 4,
543 /*View3D types (only used in tools, not actually saved)*/
544 #define V3D_VIEW_STEPLEFT 1
545 #define V3D_VIEW_STEPRIGHT 2
546 #define V3D_VIEW_STEPDOWN 3
547 #define V3D_VIEW_STEPUP 4
548 #define V3D_VIEW_PANLEFT 5
549 #define V3D_VIEW_PANRIGHT 6
550 #define V3D_VIEW_PANDOWN 7
551 #define V3D_VIEW_PANUP 8
553 /* View3d->gridflag */
554 #define V3D_SHOW_FLOOR (1 << 0)
555 #define V3D_SHOW_X (1 << 1)
556 #define V3D_SHOW_Y (1 << 2)
557 #define V3D_SHOW_Z (1 << 3)
559 /** #TransformOrientationSlot.type */
560 #define V3D_MANIP_GLOBAL 0
561 #define V3D_MANIP_LOCAL 1
562 #define V3D_MANIP_NORMAL 2
563 #define V3D_MANIP_VIEW 3
564 #define V3D_MANIP_GIMBAL 4
565 #define V3D_MANIP_CURSOR 5
566 #define V3D_MANIP_CUSTOM_MATRIX (V3D_MANIP_CUSTOM - 1) /* Runtime only, never saved to DNA. */
567 #define V3D_MANIP_CUSTOM 1024
569 /* View3d.mpr_flag (also) */
572 V3D_GIZMO_HIDE = (1 << 0),
573 V3D_GIZMO_HIDE_NAVIGATE = (1 << 1),
574 V3D_GIZMO_HIDE_CONTEXT = (1 << 2),
575 V3D_GIZMO_HIDE_TOOL = (1 << 3),
578 #define RV3D_CAMZOOM_MIN -30
579 #define RV3D_CAMZOOM_MAX 600
581 /* #BKE_screen_view3d_zoom_to_fac() values above */
582 #define RV3D_CAMZOOM_MIN_FACTOR 0.1657359312880714853f
583 #define RV3D_CAMZOOM_MAX_FACTOR 44.9852813742385702928f