DNA: move View3D, View3DOverlay into DNA_view3d_defaults.h

This commit is contained in:
Campbell Barton 2019-09-12 06:48:13 +10:00
parent 6db00065c5
commit ff085e85d3
6 changed files with 71 additions and 61 deletions

View File

@ -51,6 +51,7 @@ set(INC
../../../extern/curve_fit_nd
../../../intern/smoke/extern
# dna_type_offsets.h
${CMAKE_CURRENT_BINARY_DIR}/../makesdna/intern
)

View File

@ -33,6 +33,9 @@ set(INC
../../../../intern/glew-mx
../../../../intern/guardedalloc
../../../../intern/smoke/extern
# dna_type_offsets.h
${CMAKE_CURRENT_BINARY_DIR}/../../makesdna/intern
)
set(INC_SYS
@ -96,3 +99,6 @@ if(WITH_MOD_SMOKE)
endif()
blender_add_lib(bf_editor_space_view3d "${SRC}" "${INC}" "${INC_SYS}" "${LIB}")
# Needed so we can use dna_type_offsets.h for defaults initialization.
add_dependencies(bf_editor_space_view3d bf_dna)

View File

@ -29,6 +29,7 @@
#include "DNA_object_types.h"
#include "DNA_scene_types.h"
#include "DNA_gpencil_types.h"
#include "DNA_defaults.h"
#include "MEM_guardedalloc.h"
@ -247,56 +248,11 @@ static SpaceLink *view3d_new(const ScrArea *UNUSED(sa), const Scene *scene)
View3D *v3d;
RegionView3D *rv3d;
v3d = MEM_callocN(sizeof(View3D), "initview3d");
v3d->spacetype = SPACE_VIEW3D;
v3d = DNA_struct_default_alloc(View3D);
if (scene) {
v3d->camera = scene->camera;
}
v3d->scenelock = true;
v3d->grid = 1.0f;
v3d->gridlines = 16;
v3d->gridsubdiv = 10;
BKE_screen_view3d_shading_init(&v3d->shading);
v3d->overlay.wireframe_threshold = 1.0f;
v3d->overlay.xray_alpha_bone = 0.5f;
v3d->overlay.texture_paint_mode_opacity = 1.0f;
v3d->overlay.weight_paint_mode_opacity = 1.0f;
v3d->overlay.vertex_paint_mode_opacity = 1.0f;
/* Intentionally different to vertex/paint mode,
* we typically want to see shading too. */
v3d->overlay.sculpt_mode_mask_opacity = 0.75f;
v3d->overlay.edit_flag = V3D_OVERLAY_EDIT_FACES | V3D_OVERLAY_EDIT_SEAMS |
V3D_OVERLAY_EDIT_SHARP | V3D_OVERLAY_EDIT_FREESTYLE_EDGE |
V3D_OVERLAY_EDIT_FREESTYLE_FACE | V3D_OVERLAY_EDIT_EDGES |
V3D_OVERLAY_EDIT_CREASES | V3D_OVERLAY_EDIT_BWEIGHTS |
V3D_OVERLAY_EDIT_CU_HANDLES | V3D_OVERLAY_EDIT_CU_NORMALS;
v3d->gridflag = V3D_SHOW_X | V3D_SHOW_Y | V3D_SHOW_FLOOR | V3D_SHOW_ORTHO_GRID;
v3d->flag = V3D_SELECT_OUTLINE;
v3d->flag2 = V3D_SHOW_RECONSTRUCTION | V3D_SHOW_ANNOTATION;
v3d->lens = 50.0f;
v3d->clip_start = 0.01f;
v3d->clip_end = 1000.0f;
v3d->overlay.gpencil_paper_opacity = 0.5f;
v3d->overlay.gpencil_grid_opacity = 0.9f;
v3d->bundle_size = 0.2f;
v3d->bundle_drawtype = OB_PLAINAXES;
/* stereo */
v3d->stereo3d_camera = STEREO_3D_ID;
v3d->stereo3d_flag |= V3D_S3D_DISPPLANE;
v3d->stereo3d_convergence_alpha = 0.15f;
v3d->stereo3d_volume_alpha = 0.05f;
/* grease pencil settings */
v3d->vertex_opacity = 1.0f;
v3d->gp_flag |= V3D_GP_SHOW_EDIT_LINES;
/* tool header */
ar = MEM_callocN(sizeof(ARegion), "tool header for view3d");

View File

@ -48,6 +48,27 @@
.studiolight_intensity = 1.0f, \
}
#define _DNA_DEFAULT_View3DOverlay \
{ \
.wireframe_threshold = 1.0f, \
.xray_alpha_bone = 0.5f, \
.texture_paint_mode_opacity = 1.0f, \
.weight_paint_mode_opacity = 1.0f, \
.vertex_paint_mode_opacity = 1.0f, \
/* Intentionally different to vertex/paint mode, \
* we typically want to see shading too. */ \
.sculpt_mode_mask_opacity = 0.75f, \
\
.edit_flag = V3D_OVERLAY_EDIT_FACES | V3D_OVERLAY_EDIT_SEAMS | \
V3D_OVERLAY_EDIT_SHARP | V3D_OVERLAY_EDIT_FREESTYLE_EDGE | \
V3D_OVERLAY_EDIT_FREESTYLE_FACE | V3D_OVERLAY_EDIT_EDGES | \
V3D_OVERLAY_EDIT_CREASES | V3D_OVERLAY_EDIT_BWEIGHTS | \
V3D_OVERLAY_EDIT_CU_HANDLES | V3D_OVERLAY_EDIT_CU_NORMALS, \
\
.gpencil_paper_opacity = 0.5f, \
.gpencil_grid_opacity = 0.9f, \
}
#define _DNA_DEFAULT_View3DCursor \
{ \
.rotation_mode = ROT_MODE_XYZ, \
@ -55,6 +76,39 @@
.rotation_axis = {0, 1, 0}, \
}
#define _DNA_DEFAULT_View3D \
{ \
.spacetype = SPACE_VIEW3D, \
.scenelock = true, \
.grid = 1.0f, \
.gridlines = 16, \
.gridsubdiv = 10, \
.shading = _DNA_DEFAULT_View3DShading, \
.overlay = _DNA_DEFAULT_View3DOverlay, \
\
.gridflag = V3D_SHOW_X | V3D_SHOW_Y | V3D_SHOW_FLOOR | V3D_SHOW_ORTHO_GRID, \
\
.flag = V3D_SELECT_OUTLINE, \
.flag2 = V3D_SHOW_RECONSTRUCTION | V3D_SHOW_ANNOTATION, \
\
.lens = 50.0f, \
.clip_start = 0.01f, \
.clip_end = 1000.0f, \
\
.bundle_size = 0.2f, \
.bundle_drawtype = OB_PLAINAXES, \
\
/* stereo */ \
.stereo3d_camera = STEREO_3D_ID, \
.stereo3d_flag = V3D_S3D_DISPPLANE, \
.stereo3d_convergence_alpha = 0.15f, \
.stereo3d_volume_alpha = 0.05f, \
\
/* Grease pencil settings. */ \
.vertex_opacity = 1.0f, \
.gp_flag = V3D_GP_SHOW_EDIT_LINES, \
}
/** \} */
/* clang-format on */

View File

@ -69,6 +69,7 @@
#include "DNA_meta_types.h"
#include "DNA_object_types.h"
#include "DNA_scene_types.h"
#include "DNA_space_types.h"
#include "DNA_speaker_types.h"
#include "DNA_texture_types.h"
#include "DNA_world_types.h"
@ -145,6 +146,9 @@ SDNA_DEFAULT_DECL_STRUCT(Speaker);
/* DNA_texture_defaults.h */
SDNA_DEFAULT_DECL_STRUCT(Tex);
/* DNA_view3d_defaults.h */
SDNA_DEFAULT_DECL_STRUCT(View3D);
/* DNA_world_defaults.h */
SDNA_DEFAULT_DECL_STRUCT(World);
@ -250,7 +254,9 @@ const void *DNA_default_table[SDNA_TYPE_MAX] = {
SDNA_DEFAULT_DECL_EX(WalkNavigation, UserDef.walk_navigation),
/* DNA_view3d_defaults.h */
SDNA_DEFAULT_DECL_EX(View3DShading, Scene.display.shading),
SDNA_DEFAULT_DECL(View3D),
SDNA_DEFAULT_DECL_EX(View3DOverlay, View3D.overlay),
SDNA_DEFAULT_DECL_EX(View3DShading, View3D.shading),
SDNA_DEFAULT_DECL_EX(View3DCursor, Scene.cursor),
/* DNA_world_defaults.h */

View File

@ -3305,7 +3305,6 @@ static void rna_def_space_view3d_overlay(BlenderRNA *brna)
RNA_def_property_ui_text(prop, "Grid Scale", "Distance between 3D View grid lines");
RNA_def_property_range(prop, 0.0f, FLT_MAX);
RNA_def_property_ui_range(prop, 0.001f, 1000.0f, 0.1f, 3);
RNA_def_property_float_default(prop, 1.0f);
RNA_def_property_update(prop, NC_SPACE | ND_SPACE_VIEW3D, NULL);
prop = RNA_def_property(srna, "grid_lines", PROP_INT, PROP_NONE);
@ -3313,14 +3312,12 @@ static void rna_def_space_view3d_overlay(BlenderRNA *brna)
RNA_def_property_ui_text(
prop, "Grid Lines", "Number of grid lines to display in perspective view");
RNA_def_property_range(prop, 0, 1024);
RNA_def_property_int_default(prop, 16);
RNA_def_property_update(prop, NC_SPACE | ND_SPACE_VIEW3D, NULL);
prop = RNA_def_property(srna, "grid_subdivisions", PROP_INT, PROP_NONE);
RNA_def_property_int_sdna(prop, NULL, "gridsubdiv");
RNA_def_property_ui_text(prop, "Grid Subdivisions", "Number of subdivisions between grid lines");
RNA_def_property_range(prop, 1, 1024);
RNA_def_property_int_default(prop, 10);
RNA_def_property_update(prop, NC_SPACE | ND_SPACE_VIEW3D, NULL);
prop = RNA_def_property(srna, "grid_scale_unit", PROP_FLOAT, PROP_NONE);
@ -3393,7 +3390,6 @@ static void rna_def_space_view3d_overlay(BlenderRNA *brna)
prop = RNA_def_property(srna, "xray_alpha_bone", PROP_FLOAT, PROP_FACTOR);
RNA_def_property_float_sdna(prop, NULL, "overlay.xray_alpha_bone");
RNA_def_property_float_default(prop, 0.5f);
RNA_def_property_ui_text(prop, "Opacity", "Opacity to use for bone selection");
RNA_def_property_range(prop, 0.0f, 1.0f);
RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
@ -3426,7 +3422,6 @@ static void rna_def_space_view3d_overlay(BlenderRNA *brna)
prop = RNA_def_property(srna, "wireframe_threshold", PROP_FLOAT, PROP_FACTOR);
RNA_def_property_float_sdna(prop, NULL, "overlay.wireframe_threshold");
RNA_def_property_float_default(prop, 0.5f);
RNA_def_property_ui_text(
prop, "Wireframe Threshold", "Adjust the number of wires displayed (1 for all wires)");
RNA_def_property_range(prop, 0.0f, 1.0f);
@ -3593,7 +3588,6 @@ static void rna_def_space_view3d_overlay(BlenderRNA *brna)
prop = RNA_def_property(srna, "texture_paint_mode_opacity", PROP_FLOAT, PROP_FACTOR);
RNA_def_property_float_sdna(prop, NULL, "overlay.texture_paint_mode_opacity");
RNA_def_property_float_default(prop, 1.0f);
RNA_def_property_ui_text(
prop, "Stencil Opacity", "Opacity of the texture paint mode stencil mask overlay");
RNA_def_property_range(prop, 0.0f, 1.0f);
@ -3601,7 +3595,6 @@ static void rna_def_space_view3d_overlay(BlenderRNA *brna)
prop = RNA_def_property(srna, "vertex_paint_mode_opacity", PROP_FLOAT, PROP_FACTOR);
RNA_def_property_float_sdna(prop, NULL, "overlay.vertex_paint_mode_opacity");
RNA_def_property_float_default(prop, 1.0f);
RNA_def_property_ui_text(
prop, "Vertex Paint Opacity", "Opacity of the vertex paint mode overlay");
RNA_def_property_range(prop, 0.0f, 1.0f);
@ -3609,7 +3602,6 @@ static void rna_def_space_view3d_overlay(BlenderRNA *brna)
prop = RNA_def_property(srna, "weight_paint_mode_opacity", PROP_FLOAT, PROP_FACTOR);
RNA_def_property_float_sdna(prop, NULL, "overlay.weight_paint_mode_opacity");
RNA_def_property_float_default(prop, 1.0f);
RNA_def_property_ui_text(
prop, "Weight Paint Opacity", "Opacity of the weight paint mode overlay");
RNA_def_property_range(prop, 0.0f, 1.0f);
@ -3617,7 +3609,6 @@ static void rna_def_space_view3d_overlay(BlenderRNA *brna)
prop = RNA_def_property(srna, "sculpt_mode_mask_opacity", PROP_FLOAT, PROP_FACTOR);
RNA_def_property_float_sdna(prop, NULL, "overlay.sculpt_mode_mask_opacity");
RNA_def_property_float_default(prop, 1.0f);
RNA_def_property_ui_text(prop, "Sculpt Mask Opacity", "");
RNA_def_property_range(prop, 0.0f, 1.0f);
RNA_def_property_update(prop, NC_SPACE | ND_SPACE_VIEW3D, NULL);
@ -3656,7 +3647,6 @@ static void rna_def_space_view3d_overlay(BlenderRNA *brna)
prop = RNA_def_property(srna, "gpencil_grid_opacity", PROP_FLOAT, PROP_NONE);
RNA_def_property_float_sdna(prop, NULL, "overlay.gpencil_grid_opacity");
RNA_def_property_range(prop, 0.1f, 1.0f);
RNA_def_property_float_default(prop, 0.9f);
RNA_def_property_ui_text(prop, "Opacity", "Canvas grid opacity");
RNA_def_property_update(prop, NC_SPACE | ND_SPACE_VIEW3D, NULL);
@ -3664,7 +3654,6 @@ static void rna_def_space_view3d_overlay(BlenderRNA *brna)
prop = RNA_def_property(srna, "gpencil_paper_opacity", PROP_FLOAT, PROP_NONE);
RNA_def_property_float_sdna(prop, NULL, "overlay.gpencil_paper_opacity");
RNA_def_property_range(prop, 0.0f, 1.0f);
RNA_def_property_float_default(prop, 0.5f);
RNA_def_property_ui_text(prop, "Opacity", "Fade factor");
RNA_def_property_update(prop, NC_SPACE | ND_SPACE_VIEW3D, NULL);
@ -3813,7 +3802,6 @@ static void rna_def_space_view3d(BlenderRNA *brna)
prop = RNA_def_property(srna, "clip_start", PROP_FLOAT, PROP_DISTANCE);
RNA_def_property_range(prop, 1e-6f, FLT_MAX);
RNA_def_property_ui_range(prop, 0.001f, FLT_MAX, 10, 3);
RNA_def_property_float_default(prop, 0.1f);
RNA_def_property_ui_text(
prop, "Clip Start", "3D View near clipping distance (perspective view only)");
RNA_def_property_update(prop, NC_SPACE | ND_SPACE_VIEW3D, NULL);
@ -3821,7 +3809,6 @@ static void rna_def_space_view3d(BlenderRNA *brna)
prop = RNA_def_property(srna, "clip_end", PROP_FLOAT, PROP_DISTANCE);
RNA_def_property_range(prop, 1e-6f, FLT_MAX);
RNA_def_property_ui_range(prop, 0.001f, FLT_MAX, 10, 3);
RNA_def_property_float_default(prop, 1000.0f);
RNA_def_property_ui_text(prop, "Clip End", "3D View far clipping distance");
RNA_def_property_update(prop, NC_SPACE | ND_SPACE_VIEW3D, NULL);