Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/source
diff options
context:
space:
mode:
authorCampbell Barton <ideasman42@gmail.com>2019-09-11 23:48:13 +0300
committerCampbell Barton <ideasman42@gmail.com>2019-09-11 23:48:13 +0300
commitff085e85d3d9824cb0f0b11272e618f6d3272293 (patch)
treef7f79e73d812ee43f302974db7a505faaf38c618 /source
parent6db00065c5e7f0e16e6970d6351560c36a9536ba (diff)
DNA: move View3D, View3DOverlay into DNA_view3d_defaults.h
Diffstat (limited to 'source')
-rw-r--r--source/blender/blenkernel/CMakeLists.txt1
-rw-r--r--source/blender/editors/space_view3d/CMakeLists.txt6
-rw-r--r--source/blender/editors/space_view3d/space_view3d.c50
-rw-r--r--source/blender/makesdna/DNA_view3d_defaults.h54
-rw-r--r--source/blender/makesdna/intern/dna_defaults.c8
-rw-r--r--source/blender/makesrna/intern/rna_space.c13
6 files changed, 71 insertions, 61 deletions
diff --git a/source/blender/blenkernel/CMakeLists.txt b/source/blender/blenkernel/CMakeLists.txt
index 0e2f6e2184e..4bf2f53f8f7 100644
--- a/source/blender/blenkernel/CMakeLists.txt
+++ b/source/blender/blenkernel/CMakeLists.txt
@@ -51,6 +51,7 @@ set(INC
../../../extern/curve_fit_nd
../../../intern/smoke/extern
+ # dna_type_offsets.h
${CMAKE_CURRENT_BINARY_DIR}/../makesdna/intern
)
diff --git a/source/blender/editors/space_view3d/CMakeLists.txt b/source/blender/editors/space_view3d/CMakeLists.txt
index dc375958eb4..7c75f0ea907 100644
--- a/source/blender/editors/space_view3d/CMakeLists.txt
+++ b/source/blender/editors/space_view3d/CMakeLists.txt
@@ -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)
diff --git a/source/blender/editors/space_view3d/space_view3d.c b/source/blender/editors/space_view3d/space_view3d.c
index a8f662991b6..e9a834cb6a1 100644
--- a/source/blender/editors/space_view3d/space_view3d.c
+++ b/source/blender/editors/space_view3d/space_view3d.c
@@ -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");
diff --git a/source/blender/makesdna/DNA_view3d_defaults.h b/source/blender/makesdna/DNA_view3d_defaults.h
index 2964e77a421..365b1993d80 100644
--- a/source/blender/makesdna/DNA_view3d_defaults.h
+++ b/source/blender/makesdna/DNA_view3d_defaults.h
@@ -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 */
diff --git a/source/blender/makesdna/intern/dna_defaults.c b/source/blender/makesdna/intern/dna_defaults.c
index 7aecbb1789e..289b2e1df34 100644
--- a/source/blender/makesdna/intern/dna_defaults.c
+++ b/source/blender/makesdna/intern/dna_defaults.c
@@ -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 */
diff --git a/source/blender/makesrna/intern/rna_space.c b/source/blender/makesrna/intern/rna_space.c
index b4b124b10bc..da30abb6e7a 100644
--- a/source/blender/makesrna/intern/rna_space.c
+++ b/source/blender/makesrna/intern/rna_space.c
@@ -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);