diff options
author | Campbell Barton <ideasman42@gmail.com> | 2019-09-11 21:34:55 +0300 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2019-09-11 21:58:09 +0300 |
commit | 9a076dd95a01135ea50f9ccc675668db9f2155f4 (patch) | |
tree | a26c4ef274e5fbf469844009e9065e6c6e94ca8c | |
parent | 2f08a25d8300bc18b588d18bfa8099ead52ff5bb (diff) |
DNA: defaults for ID types
30 files changed, 1066 insertions, 343 deletions
diff --git a/source/blender/blenkernel/BKE_curve.h b/source/blender/blenkernel/BKE_curve.h index be49ca150b2..aeff6007292 100644 --- a/source/blender/blenkernel/BKE_curve.h +++ b/source/blender/blenkernel/BKE_curve.h @@ -72,7 +72,7 @@ typedef struct CVKeyIndex { /* ** Curve ** */ void BKE_curve_free(struct Curve *cu); void BKE_curve_editfont_free(struct Curve *cu); -void BKE_curve_init(struct Curve *cu); +void BKE_curve_init(struct Curve *cu, const short curve_type); struct Curve *BKE_curve_add(struct Main *bmain, const char *name, int type); void BKE_curve_copy_data(struct Main *bmain, struct Curve *cu_dst, diff --git a/source/blender/blenkernel/intern/brush.c b/source/blender/blenkernel/intern/brush.c index bdc836225c9..29c4ae624e9 100644 --- a/source/blender/blenkernel/intern/brush.c +++ b/source/blender/blenkernel/intern/brush.c @@ -24,6 +24,7 @@ #include "DNA_scene_types.h" #include "DNA_object_types.h" #include "DNA_gpencil_types.h" +#include "DNA_defaults.h" #include "BLI_math.h" #include "BLI_rand.h" @@ -60,74 +61,48 @@ void BKE_brush_system_exit(void) static void brush_defaults(Brush *brush) { - brush->blend = 0; - brush->flag = 0; - - brush->ob_mode = OB_MODE_ALL_PAINT; - - /* BRUSH SCULPT TOOL SETTINGS */ - brush->weight = 1.0f; /* weight of brush 0 - 1.0 */ - brush->size = 35; /* radius of the brush in pixels */ - brush->alpha = 0.5f; /* brush strength/intensity probably variable should be renamed? */ - brush->autosmooth_factor = 0.0f; - brush->topology_rake_factor = 0.0f; - brush->crease_pinch_factor = 0.5f; - brush->normal_radius_factor = 0.5f; - brush->sculpt_plane = SCULPT_DISP_DIR_AREA; - /* How far above or below the plane that is found by averaging the faces. */ - brush->plane_offset = 0.0f; - brush->plane_trim = 0.5f; - brush->clone.alpha = 0.5f; - brush->normal_weight = 0.0f; - brush->fill_threshold = 0.2f; - brush->flag |= BRUSH_ALPHA_PRESSURE; - - /* BRUSH PAINT TOOL SETTINGS */ - /* Default rgb color of the brush when painting - white. */ - brush->rgb[0] = 1.0f; - brush->rgb[1] = 1.0f; - brush->rgb[2] = 1.0f; - - zero_v3(brush->secondary_rgb); - - /* BRUSH STROKE SETTINGS */ - brush->flag |= (BRUSH_SPACE | BRUSH_SPACE_ATTEN); - /* How far each brush dot should be spaced as a percentage of brush diameter. */ - brush->spacing = 10; - - brush->smooth_stroke_radius = 75; - brush->smooth_stroke_factor = 0.9f; - - /* Time delay between dots of paint or sculpting when doing airbrush mode. */ - brush->rate = 0.1f; - - brush->jitter = 0.0f; - - /* BRUSH TEXTURE SETTINGS */ - BKE_texture_mtex_default(&brush->mtex); - BKE_texture_mtex_default(&brush->mask_mtex); - - brush->texture_sample_bias = 0; /* value to added to texture samples */ - brush->texture_overlay_alpha = 33; - brush->mask_overlay_alpha = 33; - brush->cursor_overlay_alpha = 33; - brush->overlay_flags = 0; - - /* brush appearance */ - - brush->add_col[0] = 1.00; /* add mode color is light red */ - brush->add_col[1] = 0.39; - brush->add_col[2] = 0.39; - - brush->sub_col[0] = 0.39; /* subtract mode color is light blue */ - brush->sub_col[1] = 0.39; - brush->sub_col[2] = 1.00; - - brush->stencil_pos[0] = 256; - brush->stencil_pos[1] = 256; - - brush->stencil_dimension[0] = 256; - brush->stencil_dimension[1] = 256; + + const Brush *brush_def = DNA_struct_default_get(Brush); + +#define FROM_DEFAULT(member) memcpy(&brush->member, &brush_def->member, sizeof(brush->member)) +#define FROM_DEFAULT_PTR(member) memcpy(brush->member, brush_def->member, sizeof(brush->member)) + + FROM_DEFAULT(blend); + FROM_DEFAULT(flag); + FROM_DEFAULT(weight); + FROM_DEFAULT(size); + FROM_DEFAULT(alpha); + FROM_DEFAULT(autosmooth_factor); + FROM_DEFAULT(topology_rake_factor); + FROM_DEFAULT(crease_pinch_factor); + FROM_DEFAULT(normal_radius_factor); + FROM_DEFAULT(sculpt_plane); + FROM_DEFAULT(plane_offset); + FROM_DEFAULT(clone.alpha); + FROM_DEFAULT(normal_weight); + FROM_DEFAULT(fill_threshold); + FROM_DEFAULT(flag); + FROM_DEFAULT_PTR(rgb); + FROM_DEFAULT_PTR(secondary_rgb); + FROM_DEFAULT(spacing); + FROM_DEFAULT(smooth_stroke_radius); + FROM_DEFAULT(smooth_stroke_factor); + FROM_DEFAULT(rate); + FROM_DEFAULT(jitter); + FROM_DEFAULT(texture_sample_bias); + FROM_DEFAULT(texture_overlay_alpha); + FROM_DEFAULT(mask_overlay_alpha); + FROM_DEFAULT(cursor_overlay_alpha); + FROM_DEFAULT(overlay_flags); + FROM_DEFAULT_PTR(add_col); + FROM_DEFAULT_PTR(sub_col); + FROM_DEFAULT(stencil_pos); + FROM_DEFAULT(stencil_dimension); + FROM_DEFAULT(mtex); + FROM_DEFAULT(mask_mtex); + +#undef FROM_DEFAULT +#undef FROM_DEFAULT_PTR } /* Datablock add/copy/free/make_local */ @@ -136,16 +111,11 @@ void BKE_brush_init(Brush *brush) { BLI_assert(MEMCMP_STRUCT_AFTER_IS_ZERO(brush, id)); + MEMCPY_STRUCT_AFTER(brush, DNA_struct_default_get(Brush), id); + /* enable fake user by default */ id_fake_user_set(&brush->id); - brush_defaults(brush); - - brush->sculpt_tool = SCULPT_TOOL_DRAW; /* sculpting defaults to the draw tool for new brushes */ - - /* A kernel radius of 1 has almost no effect (T63233). */ - brush->blur_kernel_radius = 2; - /* the default alpha falloff curve */ BKE_brush_curve_preset(brush, CURVE_PRESET_SMOOTH); } diff --git a/source/blender/blenkernel/intern/camera.c b/source/blender/blenkernel/intern/camera.c index a563a8d581c..f70c5bb99d6 100644 --- a/source/blender/blenkernel/intern/camera.c +++ b/source/blender/blenkernel/intern/camera.c @@ -30,6 +30,7 @@ #include "DNA_scene_types.h" #include "DNA_view3d_types.h" #include "DNA_ID.h" +#include "DNA_defaults.h" #include "BLI_math.h" #include "BLI_listbase.h" @@ -56,25 +57,7 @@ void BKE_camera_init(Camera *cam) { BLI_assert(MEMCMP_STRUCT_AFTER_IS_ZERO(cam, id)); - cam->lens = 50.0f; - cam->sensor_x = DEFAULT_SENSOR_WIDTH; - cam->sensor_y = DEFAULT_SENSOR_HEIGHT; - cam->clip_start = 0.1f; - cam->clip_end = 1000.0f; - cam->drawsize = 1.0f; - cam->ortho_scale = 6.0; - cam->flag |= CAM_SHOWPASSEPARTOUT; - cam->passepartalpha = 0.5f; - - cam->dof.aperture_fstop = 2.8f; - cam->dof.aperture_ratio = 1.0f; - cam->dof.focus_distance = 10.0f; - - /* stereoscopy 3d */ - cam->stereo.interocular_distance = 0.065f; - cam->stereo.convergence_distance = 30.f * 0.065f; - cam->stereo.pole_merge_angle_from = DEG2RADF(60.0f); - cam->stereo.pole_merge_angle_to = DEG2RADF(75.0f); + MEMCPY_STRUCT_AFTER(cam, DNA_struct_default_get(Camera), id); } void *BKE_camera_add(Main *bmain, const char *name) diff --git a/source/blender/blenkernel/intern/curve.c b/source/blender/blenkernel/intern/curve.c index 861663fdd6b..5f9a726d34a 100644 --- a/source/blender/blenkernel/intern/curve.c +++ b/source/blender/blenkernel/intern/curve.c @@ -36,6 +36,7 @@ #include "DNA_anim_types.h" #include "DNA_curve_types.h" #include "DNA_material_types.h" +#include "DNA_defaults.h" /* for dereferencing pointers */ #include "DNA_key_types.h" @@ -145,28 +146,13 @@ void BKE_curve_free(Curve *cu) MEM_SAFE_FREE(cu->tb); } -void BKE_curve_init(Curve *cu) -{ - /* BLI_assert(MEMCMP_STRUCT_AFTER_IS_ZERO(cu, id)); */ /* cu->type is already initialized... */ - - copy_v3_fl(cu->size, 1.0f); - cu->flag = CU_DEFORM_BOUNDS_OFF | CU_PATH_RADIUS; - cu->pathlen = 100; - cu->resolu = cu->resolv = (cu->type == OB_SURF) ? 4 : 12; - cu->width = 1.0; - cu->wordspace = 1.0; - cu->spacing = cu->linedist = 1.0; - cu->fsize = 1.0; - cu->ulheight = 0.05; - cu->texflag = CU_AUTOSPACE; - cu->smallcaps_scale = 0.75f; - /* XXX: this one seems to be the best one in most cases, at least for curve deform... */ - cu->twist_mode = CU_TWIST_MINIMUM; - cu->bevfac1 = 0.0f; - cu->bevfac2 = 1.0f; - cu->bevfac1_mapping = CU_BEVFAC_MAP_RESOLU; - cu->bevfac2_mapping = CU_BEVFAC_MAP_RESOLU; - cu->bevresol = 4; +void BKE_curve_init(Curve *cu, const short curve_type) +{ + BLI_assert(MEMCMP_STRUCT_AFTER_IS_ZERO(cu, id)); + + MEMCPY_STRUCT_AFTER(cu, DNA_struct_default_get(Curve), id); + + cu->type = curve_type; cu->bb = BKE_boundbox_alloc_unit(); @@ -182,6 +168,9 @@ void BKE_curve_init(Curve *cu) cu->tb = MEM_calloc_arrayN(MAXTEXTBOX, sizeof(TextBox), "textbox"); cu->tb[0].w = cu->tb[0].h = 0.0; } + else if (cu->type == OB_SURF) { + cu->resolv = 4; + } } Curve *BKE_curve_add(Main *bmain, const char *name, int type) @@ -189,9 +178,8 @@ Curve *BKE_curve_add(Main *bmain, const char *name, int type) Curve *cu; cu = BKE_libblock_alloc(bmain, ID_CU, name, 0); - cu->type = type; - BKE_curve_init(cu); + BKE_curve_init(cu, type); return cu; } diff --git a/source/blender/blenkernel/intern/image.c b/source/blender/blenkernel/intern/image.c index 523c0199daa..3718e35176f 100644 --- a/source/blender/blenkernel/intern/image.c +++ b/source/blender/blenkernel/intern/image.c @@ -57,6 +57,7 @@ #include "DNA_meshdata_types.h" #include "DNA_light_types.h" #include "DNA_world_types.h" +#include "DNA_defaults.h" #include "BLI_blenlib.h" #include "BLI_math_vector.h" @@ -298,10 +299,7 @@ static void image_init(Image *ima, short source, short type) ima->ok = IMA_OK; - ima->aspx = ima->aspy = 1.0; - ima->gen_x = 1024; - ima->gen_y = 1024; - ima->gen_type = IMA_GENTYPE_GRID; + MEMCPY_STRUCT_AFTER(ima, DNA_struct_default_get(Image), id); ima->source = source; ima->type = type; @@ -318,8 +316,6 @@ static void image_init(Image *ima, short source, short type) BKE_color_managed_colorspace_settings_init(&ima->colorspace_settings); ima->stereo3d_format = MEM_callocN(sizeof(Stereo3dFormat), "Image Stereo Format"); - - ima->gpuframenr = INT_MAX; } void BKE_image_init(struct Image *image) diff --git a/source/blender/blenkernel/intern/lattice.c b/source/blender/blenkernel/intern/lattice.c index e46b7ca5130..72b531c446a 100644 --- a/source/blender/blenkernel/intern/lattice.c +++ b/source/blender/blenkernel/intern/lattice.c @@ -41,6 +41,7 @@ #include "DNA_lattice_types.h" #include "DNA_curve_types.h" #include "DNA_key_types.h" +#include "DNA_defaults.h" #include "BKE_animsys.h" #include "BKE_anim.h" @@ -248,13 +249,10 @@ void BKE_lattice_init(Lattice *lt) { BLI_assert(MEMCMP_STRUCT_AFTER_IS_ZERO(lt, id)); - lt->flag = LT_GRID; - - lt->typeu = lt->typev = lt->typew = KEY_BSPLINE; + MEMCPY_STRUCT_AFTER(lt, DNA_struct_default_get(Lattice), id); lt->def = MEM_callocN(sizeof(BPoint), "lattvert"); /* temporary */ BKE_lattice_resize(lt, 2, 2, 2, NULL); /* creates a uniform lattice */ - lt->actbp = LT_ACTBP_NONE; } Lattice *BKE_lattice_add(Main *bmain, const char *name) diff --git a/source/blender/blenkernel/intern/library.c b/source/blender/blenkernel/intern/library.c index f6a5504acb2..f37d1dd5eed 100644 --- a/source/blender/blenkernel/intern/library.c +++ b/source/blender/blenkernel/intern/library.c @@ -1271,7 +1271,7 @@ void BKE_libblock_init_empty(ID *id) BKE_mesh_init((Mesh *)id); break; case ID_CU: - BKE_curve_init((Curve *)id); + BKE_curve_init((Curve *)id, 0); break; case ID_MB: BKE_mball_init((MetaBall *)id); diff --git a/source/blender/blenkernel/intern/light.c b/source/blender/blenkernel/intern/light.c index 07ec8d70af1..05fcba5c30d 100644 --- a/source/blender/blenkernel/intern/light.c +++ b/source/blender/blenkernel/intern/light.c @@ -32,6 +32,7 @@ #include "DNA_object_types.h" #include "DNA_scene_types.h" #include "DNA_texture_types.h" +#include "DNA_defaults.h" #include "BLI_math.h" #include "BLI_utildefines.h" @@ -48,40 +49,9 @@ void BKE_light_init(Light *la) { BLI_assert(MEMCMP_STRUCT_AFTER_IS_ZERO(la, id)); - la->r = la->g = la->b = la->k = 1.0f; - la->energy = 10.0f; - la->dist = 25.0f; - la->spotsize = DEG2RADF(45.0f); - la->spotblend = 0.15f; - la->att2 = 1.0f; - la->mode = LA_SHADOW; - la->bufsize = 512; - la->clipsta = 0.05f; - la->clipend = 40.0f; - la->bleedexp = 2.5f; - la->samp = 3; - la->bias = 1.0f; - la->soft = 3.0f; - la->area_size = la->area_sizey = la->area_sizez = 0.25f; - la->buffers = 1; - la->preview = NULL; - la->falloff_type = LA_FALLOFF_INVSQUARE; - la->coeff_const = 1.0f; - la->coeff_lin = 0.0f; - la->coeff_quad = 0.0f; - la->curfalloff = BKE_curvemapping_add(1, 0.0f, 1.0f, 1.0f, 0.0f); - la->cascade_max_dist = 200.0f; - la->cascade_count = 4; - la->cascade_exponent = 0.8f; - la->cascade_fade = 0.1f; - la->contact_dist = 0.2f; - la->contact_bias = 0.03f; - la->contact_spread = 0.2f; - la->contact_thickness = 0.2f; - la->spec_fac = 1.0f; - la->att_dist = 40.0f; - la->sun_angle = DEG2RADF(0.526f); + MEMCPY_STRUCT_AFTER(la, DNA_struct_default_get(Light), id); + la->curfalloff = BKE_curvemapping_add(1, 0.0f, 1.0f, 1.0f, 0.0f); BKE_curvemapping_initialize(la->curfalloff); } diff --git a/source/blender/blenkernel/intern/lightprobe.c b/source/blender/blenkernel/intern/lightprobe.c index 1c2f8d22f3e..06f1ee5050b 100644 --- a/source/blender/blenkernel/intern/lightprobe.c +++ b/source/blender/blenkernel/intern/lightprobe.c @@ -21,8 +21,11 @@ * \ingroup bke */ +#include <string.h> + #include "DNA_object_types.h" #include "DNA_lightprobe_types.h" +#include "DNA_defaults.h" #include "BLI_utildefines.h" @@ -35,17 +38,7 @@ void BKE_lightprobe_init(LightProbe *probe) { BLI_assert(MEMCMP_STRUCT_AFTER_IS_ZERO(probe, id)); - probe->grid_resolution_x = probe->grid_resolution_y = probe->grid_resolution_z = 4; - probe->distinf = 2.5f; - probe->distpar = 2.5f; - probe->falloff = 0.2f; - probe->clipsta = 0.8f; - probe->clipend = 40.0f; - probe->vis_bias = 1.0f; - probe->vis_blur = 0.2f; - probe->intensity = 1.0f; - - probe->flag = LIGHTPROBE_FLAG_SHOW_INFLUENCE; + MEMCPY_STRUCT_AFTER(probe, DNA_struct_default_get(LightProbe), id); } void *BKE_lightprobe_add(Main *bmain, const char *name) diff --git a/source/blender/blenkernel/intern/linestyle.c b/source/blender/blenkernel/intern/linestyle.c index e5fa5ff08b0..3436bd7a978 100644 --- a/source/blender/blenkernel/intern/linestyle.c +++ b/source/blender/blenkernel/intern/linestyle.c @@ -30,6 +30,7 @@ #include "DNA_object_types.h" #include "DNA_material_types.h" /* for ramp blend */ #include "DNA_texture_types.h" +#include "DNA_defaults.h" #include "BLI_blenlib.h" #include "BLI_math.h" @@ -76,34 +77,9 @@ void BKE_linestyle_init(FreestyleLineStyle *linestyle) { BLI_assert(MEMCMP_STRUCT_AFTER_IS_ZERO(linestyle, id)); - linestyle->panel = LS_PANEL_STROKES; - linestyle->r = linestyle->g = linestyle->b = 0.0f; - linestyle->alpha = 1.0f; - linestyle->thickness = 3.0f; - linestyle->thickness_position = LS_THICKNESS_CENTER; - linestyle->thickness_ratio = 0.5f; - linestyle->flag = LS_SAME_OBJECT | LS_NO_SORTING | LS_TEXTURE; - linestyle->chaining = LS_CHAINING_PLAIN; - linestyle->rounds = 3; - linestyle->min_angle = DEG2RADF(0.0f); - linestyle->max_angle = DEG2RADF(0.0f); - linestyle->min_length = 0.0f; - linestyle->max_length = 10000.0f; - linestyle->split_length = 100; - linestyle->chain_count = 10; - linestyle->sort_key = LS_SORT_KEY_DISTANCE_FROM_CAMERA; - linestyle->integration_type = LS_INTEGRATION_MEAN; - linestyle->texstep = 1.0f; - linestyle->pr_texture = TEX_PR_TEXTURE; - - BLI_listbase_clear(&linestyle->color_modifiers); - BLI_listbase_clear(&linestyle->alpha_modifiers); - BLI_listbase_clear(&linestyle->thickness_modifiers); - BLI_listbase_clear(&linestyle->geometry_modifiers); + MEMCPY_STRUCT_AFTER(linestyle, DNA_struct_default_get(FreestyleLineStyle), id); BKE_linestyle_geometry_modifier_add(linestyle, NULL, LS_MODIFIER_SAMPLING); - - linestyle->caps = LS_CAPS_BUTT; } FreestyleLineStyle *BKE_linestyle_new(struct Main *bmain, const char *name) diff --git a/source/blender/blenkernel/intern/mball.c b/source/blender/blenkernel/intern/mball.c index 19009322975..b127d5d4d0e 100644 --- a/source/blender/blenkernel/intern/mball.c +++ b/source/blender/blenkernel/intern/mball.c @@ -39,6 +39,7 @@ #include "DNA_object_types.h" #include "DNA_meta_types.h" #include "DNA_scene_types.h" +#include "DNA_defaults.h" #include "BLI_blenlib.h" #include "BLI_math.h" @@ -79,12 +80,7 @@ void BKE_mball_init(MetaBall *mb) { BLI_assert(MEMCMP_STRUCT_AFTER_IS_ZERO(mb, id)); - mb->size[0] = mb->size[1] = mb->size[2] = 1.0; - mb->texflag = MB_AUTOSPACE; - - mb->wiresize = 0.4f; - mb->rendersize = 0.2f; - mb->thresh = 0.6f; + MEMCPY_STRUCT_AFTER(mb, DNA_struct_default_get(MetaBall), id); } MetaBall *BKE_mball_add(Main *bmain, const char *name) diff --git a/source/blender/blenkernel/intern/speaker.c b/source/blender/blenkernel/intern/speaker.c index c7a0d65a2a9..46a74e25b8b 100644 --- a/source/blender/blenkernel/intern/speaker.c +++ b/source/blender/blenkernel/intern/speaker.c @@ -21,6 +21,7 @@ #include "DNA_object_types.h" #include "DNA_sound_types.h" #include "DNA_speaker_types.h" +#include "DNA_defaults.h" #include "BLI_math.h" #include "BLI_utildefines.h" @@ -34,18 +35,7 @@ void BKE_speaker_init(Speaker *spk) { BLI_assert(MEMCMP_STRUCT_AFTER_IS_ZERO(spk, id)); - spk->attenuation = 1.0f; - spk->cone_angle_inner = 360.0f; - spk->cone_angle_outer = 360.0f; - spk->cone_volume_outer = 1.0f; - spk->distance_max = FLT_MAX; - spk->distance_reference = 1.0f; - spk->flag = 0; - spk->pitch = 1.0f; - spk->sound = NULL; - spk->volume = 1.0f; - spk->volume_max = 1.0f; - spk->volume_min = 0.0f; + MEMCPY_STRUCT_AFTER(spk, DNA_struct_default_get(Speaker), id); } void *BKE_speaker_add(Main *bmain, const char *name) diff --git a/source/blender/blenkernel/intern/texture.c b/source/blender/blenkernel/intern/texture.c index 5c03b7730aa..fb8697b1ee0 100644 --- a/source/blender/blenkernel/intern/texture.c +++ b/source/blender/blenkernel/intern/texture.c @@ -41,6 +41,7 @@ #include "DNA_color_types.h" #include "DNA_particle_types.h" #include "DNA_linestyle_types.h" +#include "DNA_defaults.h" #include "IMB_imbuf.h" @@ -214,56 +215,11 @@ void BKE_texture_free(Tex *tex) void BKE_texture_default(Tex *tex) { - /* Not here, can be called with some pointers set. :/ */ - /* BLI_assert(MEMCMP_STRUCT_AFTER_IS_ZERO(tex, id)); */ - - tex->type = TEX_IMAGE; - tex->ima = NULL; - tex->stype = 0; - tex->flag = TEX_CHECKER_ODD; - tex->imaflag = TEX_INTERPOL | TEX_MIPMAP | TEX_USEALPHA; - tex->extend = TEX_REPEAT; - tex->cropxmin = tex->cropymin = 0.0; - tex->cropxmax = tex->cropymax = 1.0; - tex->texfilter = TXF_EWA; - tex->afmax = 8; - tex->xrepeat = tex->yrepeat = 1; - tex->sfra = 1; - tex->frames = 0; - tex->offset = 0; - tex->noisesize = 0.25; - tex->noisedepth = 2; - tex->turbul = 5.0; - tex->nabla = 0.025; // also in do_versions - tex->bright = 1.0; - tex->contrast = 1.0; - tex->saturation = 1.0; - tex->filtersize = 1.0; - tex->rfac = 1.0; - tex->gfac = 1.0; - tex->bfac = 1.0; - /* newnoise: init. */ - tex->noisebasis = 0; - tex->noisebasis2 = 0; - /* musgrave */ - tex->mg_H = 1.0; - tex->mg_lacunarity = 2.0; - tex->mg_octaves = 2.0; - tex->mg_offset = 1.0; - tex->mg_gain = 1.0; - tex->ns_outscale = 1.0; - /* distnoise */ - tex->dist_amount = 1.0; - /* voronoi */ - tex->vn_w1 = 1.0; - tex->vn_w2 = tex->vn_w3 = tex->vn_w4 = 0.0; - tex->vn_mexp = 2.5; - tex->vn_distm = 0; - tex->vn_coltype = 0; + BLI_assert(MEMCMP_STRUCT_AFTER_IS_ZERO(tex, id)); - BKE_imageuser_default(&tex->iuser); + MEMCPY_STRUCT_AFTER(tex, DNA_struct_default_get(Tex), id); - tex->preview = NULL; + BKE_imageuser_default(&tex->iuser); } void BKE_texture_type_set(Tex *tex, int type) @@ -288,69 +244,7 @@ Tex *BKE_texture_add(Main *bmain, const char *name) void BKE_texture_mtex_default(MTex *mtex) { - mtex->texco = TEXCO_UV; - mtex->mapto = MAP_COL; - mtex->object = NULL; - mtex->projx = PROJ_X; - mtex->projy = PROJ_Y; - mtex->projz = PROJ_Z; - mtex->mapping = MTEX_FLAT; - mtex->ofs[0] = 0.0; - mtex->ofs[1] = 0.0; - mtex->ofs[2] = 0.0; - mtex->size[0] = 1.0; - mtex->size[1] = 1.0; - mtex->size[2] = 1.0; - mtex->tex = NULL; - mtex->colormodel = 0; - mtex->r = 1.0; - mtex->g = 0.0; - mtex->b = 1.0; - mtex->k = 1.0; - mtex->def_var = 1.0; - mtex->blendtype = MTEX_BLEND; - mtex->colfac = 1.0; - mtex->norfac = 1.0; - mtex->varfac = 1.0; - mtex->dispfac = 0.2; - mtex->colspecfac = 1.0f; - mtex->mirrfac = 1.0f; - mtex->alphafac = 1.0f; - mtex->difffac = 1.0f; - mtex->specfac = 1.0f; - mtex->emitfac = 1.0f; - mtex->hardfac = 1.0f; - mtex->raymirrfac = 1.0f; - mtex->translfac = 1.0f; - mtex->ambfac = 1.0f; - mtex->colemitfac = 1.0f; - mtex->colreflfac = 1.0f; - mtex->coltransfac = 1.0f; - mtex->densfac = 1.0f; - mtex->scatterfac = 1.0f; - mtex->reflfac = 1.0f; - mtex->shadowfac = 1.0f; - mtex->zenupfac = 1.0f; - mtex->zendownfac = 1.0f; - mtex->blendfac = 1.0f; - mtex->timefac = 1.0f; - mtex->lengthfac = 1.0f; - mtex->clumpfac = 1.0f; - mtex->kinkfac = 1.0f; - mtex->kinkampfac = 1.0f; - mtex->roughfac = 1.0f; - mtex->twistfac = 1.0f; - mtex->padensfac = 1.0f; - mtex->lifefac = 1.0f; - mtex->sizefac = 1.0f; - mtex->ivelfac = 1.0f; - mtex->dampfac = 1.0f; - mtex->gravityfac = 1.0f; - mtex->fieldfac = 1.0f; - mtex->normapspace = MTEX_NSPACE_TANGENT; - mtex->brush_map_mode = MTEX_MAP_MODE_TILED; - mtex->random_angle = 2.0f * (float)M_PI; - mtex->brush_angle_mode = 0; + memcpy(mtex, DNA_struct_default_get(MTex), sizeof(*mtex)); } /* ------------------------------------------------------------------------- */ diff --git a/source/blender/blenkernel/intern/world.c b/source/blender/blenkernel/intern/world.c index 31fc87d7021..9ad357290c4 100644 --- a/source/blender/blenkernel/intern/world.c +++ b/source/blender/blenkernel/intern/world.c @@ -30,6 +30,7 @@ #include "DNA_world_types.h" #include "DNA_scene_types.h" #include "DNA_texture_types.h" +#include "DNA_defaults.h" #include "BLI_utildefines.h" #include "BLI_listbase.h" @@ -71,16 +72,7 @@ void BKE_world_init(World *wrld) { BLI_assert(MEMCMP_STRUCT_AFTER_IS_ZERO(wrld, id)); - wrld->horr = 0.05f; - wrld->horg = 0.05f; - wrld->horb = 0.05f; - - wrld->aodist = 10.0f; - wrld->aoenergy = 1.0f; - - wrld->preview = NULL; - wrld->miststa = 5.0f; - wrld->mistdist = 25.0f; + MEMCPY_STRUCT_AFTER(wrld, DNA_struct_default_get(World), id); } World *BKE_world_add(Main *bmain, const char *name) diff --git a/source/blender/makesdna/DNA_brush_defaults.h b/source/blender/makesdna/DNA_brush_defaults.h new file mode 100644 index 00000000000..cf4e74dfd41 --- /dev/null +++ b/source/blender/makesdna/DNA_brush_defaults.h @@ -0,0 +1,105 @@ +/* + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ + +/** \file + * \ingroup DNA + */ + +#ifndef __DNA_BRUSH_DEFAULTS_H__ +#define __DNA_BRUSH_DEFAULTS_H__ + +#include "DNA_texture_defaults.h" + +/* Struct members on own line. */ +/* clang-format off */ + +/* -------------------------------------------------------------------- */ +/** \name Brush Struct + * \{ */ + +#define _DNA_DEFAULT_Brush \ + { \ + .blend = 0, \ + .flag = (BRUSH_ALPHA_PRESSURE | BRUSH_SPACE | BRUSH_SPACE_ATTEN), \ + \ + .ob_mode = OB_MODE_ALL_PAINT, \ + \ + /* BRUSH SCULPT TOOL SETTINGS */ \ + .weight = 1.0f, /* weight of brush 0 - 1.0 */ \ + .size = 35, /* radius of the brush in pixels */ \ + .alpha = 0.5f, /* brush strength/intensity probably variable should be renamed? */ \ + .autosmooth_factor = 0.0f, \ + .topology_rake_factor = 0.0f, \ + .crease_pinch_factor = 0.5f, \ + .normal_radius_factor = 0.5f, \ + .sculpt_plane = SCULPT_DISP_DIR_AREA, \ + /* How far above or below the plane that is found by averaging the faces. */ \ + .plane_offset = 0.0f, \ + .plane_trim = 0.5f, \ + .clone.alpha = 0.5f, \ + .normal_weight = 0.0f, \ + .fill_threshold = 0.2f, \ + \ + /* BRUSH PAINT TOOL SETTINGS */ \ + /* Default rgb color of the brush when painting - white. */ \ + .rgb = {1.0f, 1.0f, 1.0f}, \ + \ + .secondary_rgb = {0, 0, 0}, \ + \ + /* BRUSH STROKE SETTINGS */ \ + /* How far each brush dot should be spaced as a percentage of brush diameter. */ \ + .spacing = 10, \ + \ + .smooth_stroke_radius = 75, \ + .smooth_stroke_factor = 0.9f, \ + \ + /* Time delay between dots of paint or sculpting when doing airbrush mode. */ \ + .rate = 0.1f, \ + \ + .jitter = 0.0f, \ + \ + .texture_sample_bias = 0, /* value to added to texture samples */ \ + .texture_overlay_alpha = 33, \ + .mask_overlay_alpha = 33, \ + .cursor_overlay_alpha = 33, \ + .overlay_flags = 0, \ + \ + /* brush appearance */ \ + \ + /* add mode color is light red */ \ + .add_col = {1.0, 0.39, 0.39}, \ + \ + /* subtract mode color is light blue */ \ + .sub_col = {0.39, 0.39, 1.0}, \ + \ + .stencil_pos = {256, 256}, \ + .stencil_dimension = {256, 256}, \ + \ + /* sculpting defaults to the draw tool for new brushes */ \ + .sculpt_tool = SCULPT_TOOL_DRAW, \ + \ + /* A kernel radius of 1 has almost no effect (T63233). */ \ + .blur_kernel_radius = 2, \ + \ + .mtex = _DNA_DEFAULT_MTex, \ + .mask_mtex = _DNA_DEFAULT_MTex, \ + } + +/** \} */ + +/* clang-format on */ + +#endif /* __DNA_BRUSH_DEFAULTS_H__ */ diff --git a/source/blender/makesdna/DNA_cachefile_defaults.h b/source/blender/makesdna/DNA_cachefile_defaults.h new file mode 100644 index 00000000000..4c4ff53ed90 --- /dev/null +++ b/source/blender/makesdna/DNA_cachefile_defaults.h @@ -0,0 +1,49 @@ +/* + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ + +/** \file + * \ingroup DNA + */ + +#ifndef __DNA_CACHEFILE_DEFAULTS_H__ +#define __DNA_CACHEFILE_DEFAULTS_H__ + +/* Struct members on own line. */ +/* clang-format off */ + +/* -------------------------------------------------------------------- */ +/** \name CacheFile Struct + * \{ */ + +#define _DNA_DEFAULT_CacheFile \ + { \ + .filepath[0] = '\0', \ + .override_frame = false, \ + .frame = 0.0f, \ + .is_sequence = false, \ + .scale = 1.0f, \ + .object_paths ={NULL, NULL}, \ + \ + .handle = NULL, \ + .handle_filepath[0] = '\0', \ + .handle_readers = NULL, \ + } + +/** \} */ + +/* clang-format on */ + +#endif /* __DNA_CACHEFILE_DEFAULTS_H__ */ diff --git a/source/blender/makesdna/DNA_camera_defaults.h b/source/blender/makesdna/DNA_camera_defaults.h new file mode 100644 index 00000000000..7a28f673ee4 --- /dev/null +++ b/source/blender/makesdna/DNA_camera_defaults.h @@ -0,0 +1,67 @@ +/* + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ + +/** \file + * \ingroup DNA + */ + +#ifndef __DNA_CAMERA_DEFAULTS_H__ +#define __DNA_CAMERA_DEFAULTS_H__ + +/* Struct members on own line. */ +/* clang-format off */ + +/* -------------------------------------------------------------------- */ +/** \name Camera Struct + * \{ */ + +#define _DNA_DEFAULT_CameraDOFSettings \ + { \ + .aperture_fstop = 2.8f, \ + .aperture_ratio = 1.0f, \ + .focus_distance = 10.0f, \ + } + +#define _DNA_DEFAULT_CameraStereoSettings \ + { \ + .interocular_distance = 0.065f, \ + .convergence_distance = 30.f * 0.065f, \ + .pole_merge_angle_from = DEG2RADF(60.0f), \ + .pole_merge_angle_to = DEG2RADF(75.0f), \ + } + +#define _DNA_DEFAULT_Camera \ + { \ + .lens = 50.0f, \ + .sensor_x = DEFAULT_SENSOR_WIDTH, \ + .sensor_y = DEFAULT_SENSOR_HEIGHT, \ + .clip_start = 0.1f, \ + .clip_end = 1000.0f, \ + .drawsize = 1.0f, \ + .ortho_scale = 6.0, \ + .flag = CAM_SHOWPASSEPARTOUT, \ + .passepartalpha = 0.5f, \ + \ + .dof = _DNA_DEFAULT_CameraDOFSettings, \ + \ + .stereo = _DNA_DEFAULT_CameraStereoSettings, \ + } + +/** \} */ + +/* clang-format on */ + +#endif /* __DNA_CAMERA_DEFAULTS_H__ */ diff --git a/source/blender/makesdna/DNA_curve_defaults.h b/source/blender/makesdna/DNA_curve_defaults.h new file mode 100644 index 00000000000..0fdfd5713e9 --- /dev/null +++ b/source/blender/makesdna/DNA_curve_defaults.h @@ -0,0 +1,59 @@ +/* + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ + +/** \file + * \ingroup DNA + */ + +#ifndef __DNA_CURVE_DEFAULTS_H__ +#define __DNA_CURVE_DEFAULTS_H__ + +/* Struct members on own line. */ +/* clang-format off */ + +/* -------------------------------------------------------------------- */ +/** \name Curve Struct + * \{ */ + +#define _DNA_DEFAULT_Curve \ + { \ + .size = {1, 1, 1}, \ + .flag = CU_DEFORM_BOUNDS_OFF | CU_PATH_RADIUS, \ + .pathlen = 100, \ + .resolu = 12, \ + .resolv = 12, \ + .width = 1.0, \ + .wordspace = 1.0, \ + .spacing = 1.0f, \ + .linedist = 1.0, \ + .fsize = 1.0, \ + .ulheight = 0.05, \ + .texflag = CU_AUTOSPACE, \ + .smallcaps_scale = 0.75f, \ + /* This one seems to be the best one in most cases, at least for curve deform. */ \ + .twist_mode = CU_TWIST_MINIMUM, \ + .bevfac1 = 0.0f, \ + .bevfac2 = 1.0f, \ + .bevfac1_mapping = CU_BEVFAC_MAP_RESOLU, \ + .bevfac2_mapping = CU_BEVFAC_MAP_RESOLU, \ + .bevresol = 4, \ + } + +/** \} */ + +/* clang-format on */ + +#endif /* __DNA_CURVE_DEFAULTS_H__ */ diff --git a/source/blender/makesdna/DNA_image_defaults.h b/source/blender/makesdna/DNA_image_defaults.h new file mode 100644 index 00000000000..e115f9e2b16 --- /dev/null +++ b/source/blender/makesdna/DNA_image_defaults.h @@ -0,0 +1,46 @@ +/* + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ + +/** \file + * \ingroup DNA + */ + +#ifndef __DNA_IMAGE_DEFAULTS_H__ +#define __DNA_IMAGE_DEFAULTS_H__ + +/* Struct members on own line. */ +/* clang-format off */ + +/* -------------------------------------------------------------------- */ +/** \name Image Struct + * \{ */ + +#define _DNA_DEFAULT_Image \ + { \ + .aspx = 1.0, \ + .aspy = 1.0, \ + .gen_x = 1024, \ + .gen_y = 1024, \ + .gen_type = IMA_GENTYPE_GRID, \ + \ + .gpuframenr = INT_MAX, \ + } + +/** \} */ + +/* clang-format on */ + +#endif /* __DNA_IMAGE_DEFAULTS_H__ */ diff --git a/source/blender/makesdna/DNA_lattice_defaults.h b/source/blender/makesdna/DNA_lattice_defaults.h new file mode 100644 index 00000000000..052aaba51d7 --- /dev/null +++ b/source/blender/makesdna/DNA_lattice_defaults.h @@ -0,0 +1,44 @@ +/* + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ + +/** \file + * \ingroup DNA + */ + +#ifndef __DNA_LATTICE_DEFAULTS_H__ +#define __DNA_LATTICE_DEFAULTS_H__ + +/* Struct members on own line. */ +/* clang-format off */ + +/* -------------------------------------------------------------------- */ +/** \name Lattice Struct + * \{ */ + +#define _DNA_DEFAULT_Lattice \ + { \ + .flag = LT_GRID, \ + .typeu = KEY_BSPLINE, \ + .typev = KEY_BSPLINE, \ + .typew = KEY_BSPLINE, \ + .actbp = LT_ACTBP_NONE, \ + } + +/** \} */ + +/* clang-format on */ + +#endif /* __DNA_LATTICE_DEFAULTS_H__ */ diff --git a/source/blender/makesdna/DNA_light_defaults.h b/source/blender/makesdna/DNA_light_defaults.h new file mode 100644 index 00000000000..dceaaf7c278 --- /dev/null +++ b/source/blender/makesdna/DNA_light_defaults.h @@ -0,0 +1,76 @@ +/* + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ + +/** \file + * \ingroup DNA + */ + +#ifndef __DNA_LIGHT_DEFAULTS_H__ +#define __DNA_LIGHT_DEFAULTS_H__ + +/* Struct members on own line. */ +/* clang-format off */ + +/* -------------------------------------------------------------------- */ +/** \name Light Struct + * \{ */ + +#define _DNA_DEFAULT_Light \ + { \ + .r = 1.0f, \ + .g = 1.0f, \ + .b = 1.0f, \ + .k = 1.0f, \ + .energy = 10.0f, \ + .dist = 25.0f, \ + .spotsize = DEG2RADF(45.0f), \ + .spotblend = 0.15f, \ + .att2 = 1.0f, \ + .mode = LA_SHADOW, \ + .bufsize = 512, \ + .clipsta = 0.05f, \ + .clipend = 40.0f, \ + .bleedexp = 2.5f, \ + .samp = 3, \ + .bias = 1.0f, \ + .soft = 3.0f, \ + .area_size = 0.25f, \ + .area_sizey = 0.25f, \ + .area_sizez = 0.25f, \ + .buffers = 1, \ + .preview = NULL, \ + .falloff_type = LA_FALLOFF_INVSQUARE, \ + .coeff_const = 1.0f, \ + .coeff_lin = 0.0f, \ + .coeff_quad = 0.0f, \ + .cascade_max_dist = 200.0f, \ + .cascade_count = 4, \ + .cascade_exponent = 0.8f, \ + .cascade_fade = 0.1f, \ + .contact_dist = 0.2f, \ + .contact_bias = 0.03f, \ + .contact_spread = 0.2f, \ + .contact_thickness = 0.2f, \ + .spec_fac = 1.0f, \ + .att_dist = 40.0f, \ + .sun_angle = DEG2RADF(0.526f), \ + } + +/** \} */ + +/* clang-format on */ + +#endif /* __DNA_LIGHT_DEFAULTS_H__ */ diff --git a/source/blender/makesdna/DNA_lightprobe_defaults.h b/source/blender/makesdna/DNA_lightprobe_defaults.h new file mode 100644 index 00000000000..7c7732d17e4 --- /dev/null +++ b/source/blender/makesdna/DNA_lightprobe_defaults.h @@ -0,0 +1,51 @@ +/* + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ + +/** \file + * \ingroup DNA + */ + +#ifndef __DNA_LIGHTPROBE_DEFAULTS_H__ +#define __DNA_LIGHTPROBE_DEFAULTS_H__ + +/* Struct members on own line. */ +/* clang-format off */ + +/* -------------------------------------------------------------------- */ +/** \name LightProbe Struct + * \{ */ + +#define _DNA_DEFAULT_LightProbe \ + { \ + .grid_resolution_x = 4, \ + .grid_resolution_y = 4, \ + .grid_resolution_z = 4, \ + .distinf = 2.5f, \ + .distpar = 2.5f, \ + .falloff = 0.2f, \ + .clipsta = 0.8f, \ + .clipend = 40.0f, \ + .vis_bias = 1.0f, \ + .vis_blur = 0.2f, \ + .intensity = 1.0f, \ + .flag = LIGHTPROBE_FLAG_SHOW_INFLUENCE, \ + } + +/** \} */ + +/* clang-format on */ + +#endif /* __DNA_LIGHTPROBE_DEFAULTS_H__ */ diff --git a/source/blender/makesdna/DNA_linestyle_defaults.h b/source/blender/makesdna/DNA_linestyle_defaults.h new file mode 100644 index 00000000000..2f9203050d1 --- /dev/null +++ b/source/blender/makesdna/DNA_linestyle_defaults.h @@ -0,0 +1,61 @@ +/* + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ + +/** \file + * \ingroup DNA + */ + +#ifndef __DNA_LINESTYLE_DEFAULTS_H__ +#define __DNA_LINESTYLE_DEFAULTS_H__ + +/* Struct members on own line. */ +/* clang-format off */ + +/* -------------------------------------------------------------------- */ +/** \name FreestyleLineStyle Struct + * \{ */ + +#define _DNA_DEFAULT_FreestyleLineStyle \ + { \ + .panel = LS_PANEL_STROKES, \ + .r = 0, \ + .g = 0, \ + .b = 0, \ + .alpha = 1.0f, \ + .thickness = 3.0f, \ + .thickness_position = LS_THICKNESS_CENTER, \ + .thickness_ratio = 0.5f, \ + .flag = LS_SAME_OBJECT | LS_NO_SORTING | LS_TEXTURE, \ + .chaining = LS_CHAINING_PLAIN, \ + .rounds = 3, \ + .min_angle = DEG2RADF(0.0f), \ + .max_angle = DEG2RADF(0.0f), \ + .min_length = 0.0f, \ + .max_length = 10000.0f, \ + .split_length = 100, \ + .chain_count = 10, \ + .sort_key = LS_SORT_KEY_DISTANCE_FROM_CAMERA, \ + .integration_type = LS_INTEGRATION_MEAN, \ + .texstep = 1.0f, \ + .pr_texture = TEX_PR_TEXTURE, \ + .caps = LS_CAPS_BUTT, \ + } + +/** \} */ + +/* clang-format on */ + +#endif /* __DNA_LINESTYLE_DEFAULTS_H__ */ diff --git a/source/blender/makesdna/DNA_meta_defaults.h b/source/blender/makesdna/DNA_meta_defaults.h new file mode 100644 index 00000000000..723f178ed58 --- /dev/null +++ b/source/blender/makesdna/DNA_meta_defaults.h @@ -0,0 +1,44 @@ +/* + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ + +/** \file + * \ingroup DNA + */ + +#ifndef __DNA_META_DEFAULTS_H__ +#define __DNA_META_DEFAULTS_H__ + +/* Struct members on own line. */ +/* clang-format off */ + +/* -------------------------------------------------------------------- */ +/** \name MetaBall Struct + * \{ */ + +#define _DNA_DEFAULT_MetaBall \ + { \ + .size = {1, 1, 1}, \ + .texflag = MB_AUTOSPACE, \ + .wiresize = 0.4f, \ + .rendersize = 0.2f, \ + .thresh = 0.6f, \ + } + +/** \} */ + +/* clang-format on */ + +#endif /* __DNA_META_DEFAULTS_H__ */ diff --git a/source/blender/makesdna/DNA_speaker_defaults.h b/source/blender/makesdna/DNA_speaker_defaults.h new file mode 100644 index 00000000000..d252a447701 --- /dev/null +++ b/source/blender/makesdna/DNA_speaker_defaults.h @@ -0,0 +1,51 @@ +/* + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ + +/** \file + * \ingroup DNA + */ + +#ifndef __DNA_SPEAKER_DEFAULTS_H__ +#define __DNA_SPEAKER_DEFAULTS_H__ + +/* Struct members on own line. */ +/* clang-format off */ + +/* -------------------------------------------------------------------- */ +/** \name Speaker Struct + * \{ */ + +#define _DNA_DEFAULT_Speaker \ + { \ + .attenuation = 1.0f, \ + .cone_angle_inner = 360.0f, \ + .cone_angle_outer = 360.0f, \ + .cone_volume_outer = 1.0f, \ + .distance_max = FLT_MAX, \ + .distance_reference = 1.0f, \ + .flag = 0, \ + .pitch = 1.0f, \ + .sound = NULL, \ + .volume = 1.0f, \ + .volume_max = 1.0f, \ + .volume_min = 0.0f, \ + } + +/** \} */ + +/* clang-format on */ + +#endif /* __DNA_SPEAKER_DEFAULTS_H__ */ diff --git a/source/blender/makesdna/DNA_texture_defaults.h b/source/blender/makesdna/DNA_texture_defaults.h new file mode 100644 index 00000000000..d5097c5ea21 --- /dev/null +++ b/source/blender/makesdna/DNA_texture_defaults.h @@ -0,0 +1,155 @@ +/* + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ + +/** \file + * \ingroup DNA + */ + +#ifndef __DNA_TEXTURE_DEFAULTS_H__ +#define __DNA_TEXTURE_DEFAULTS_H__ + +/* Struct members on own line. */ +/* clang-format off */ + +/* -------------------------------------------------------------------- */ +/** \name Texture Struct + * \{ */ + +#define _DNA_DEFAULT_MTex \ + { \ + .texco = TEXCO_UV, \ + .mapto = MAP_COL, \ + .object = NULL, \ + .projx = PROJ_X, \ + .projy = PROJ_Y, \ + .projz = PROJ_Z, \ + .mapping = MTEX_FLAT, \ + .ofs[0] = 0.0, \ + .ofs[1] = 0.0, \ + .ofs[2] = 0.0, \ + .size[0] = 1.0, \ + .size[1] = 1.0, \ + .size[2] = 1.0, \ + .tex = NULL, \ + .colormodel = 0, \ + .r = 1.0, \ + .g = 0.0, \ + .b = 1.0, \ + .k = 1.0, \ + .def_var = 1.0, \ + .blendtype = MTEX_BLEND, \ + .colfac = 1.0, \ + .norfac = 1.0, \ + .varfac = 1.0, \ + .dispfac = 0.2, \ + .colspecfac = 1.0f, \ + .mirrfac = 1.0f, \ + .alphafac = 1.0f, \ + .difffac = 1.0f, \ + .specfac = 1.0f, \ + .emitfac = 1.0f, \ + .hardfac = 1.0f, \ + .raymirrfac = 1.0f, \ + .translfac = 1.0f, \ + .ambfac = 1.0f, \ + .colemitfac = 1.0f, \ + .colreflfac = 1.0f, \ + .coltransfac = 1.0f, \ + .densfac = 1.0f, \ + .scatterfac = 1.0f, \ + .reflfac = 1.0f, \ + .shadowfac = 1.0f, \ + .zenupfac = 1.0f, \ + .zendownfac = 1.0f, \ + .blendfac = 1.0f, \ + .timefac = 1.0f, \ + .lengthfac = 1.0f, \ + .clumpfac = 1.0f, \ + .kinkfac = 1.0f, \ + .kinkampfac = 1.0f, \ + .roughfac = 1.0f, \ + .twistfac = 1.0f, \ + .padensfac = 1.0f, \ + .lifefac = 1.0f, \ + .sizefac = 1.0f, \ + .ivelfac = 1.0f, \ + .dampfac = 1.0f, \ + .gravityfac = 1.0f, \ + .fieldfac = 1.0f, \ + .normapspace = MTEX_NSPACE_TANGENT, \ + .brush_map_mode = MTEX_MAP_MODE_TILED, \ + .random_angle = 2.0f * (float)M_PI, \ + .brush_angle_mode = 0, \ + } \ + +#define _DNA_DEFAULT_Tex \ + { \ + .type = TEX_IMAGE, \ + .ima = NULL, \ + .stype = 0, \ + .flag = TEX_CHECKER_ODD, \ + .imaflag = TEX_INTERPOL | TEX_MIPMAP | TEX_USEALPHA, \ + .extend = TEX_REPEAT, \ + .cropxmin = 0.0, \ + .cropymin = 0.0, \ + .cropxmax = 1.0, \ + .cropymax = 1.0, \ + .texfilter = TXF_EWA, \ + .afmax = 8, \ + .xrepeat = 1, \ + .yrepeat = 1, \ + .sfra = 1, \ + .frames = 0, \ + .offset = 0, \ + .noisesize = 0.25, \ + .noisedepth = 2, \ + .turbul = 5.0, \ + .nabla = 0.025, /* also in do_versions. */ \ + .bright = 1.0, \ + .contrast = 1.0, \ + .saturation = 1.0, \ + .filtersize = 1.0, \ + .rfac = 1.0, \ + .gfac = 1.0, \ + .bfac = 1.0, \ + /* newnoise: init. */ \ + .noisebasis = 0, \ + .noisebasis2 = 0, \ + /* musgrave */ \ + .mg_H = 1.0, \ + .mg_lacunarity = 2.0, \ + .mg_octaves = 2.0, \ + .mg_offset = 1.0, \ + .mg_gain = 1.0, \ + .ns_outscale = 1.0, \ + /* distnoise */ \ + .dist_amount = 1.0, \ + /* voronoi */ \ + .vn_w1 = 1.0, \ + .vn_w2 = 0.0, \ + .vn_w3 = 0.0, \ + .vn_w4 = 0.0, \ + .vn_mexp = 2.5, \ + .vn_distm = 0, \ + .vn_coltype = 0, \ + .preview = NULL, \ + } + +/** \} */ + +/* clang-format on */ + +#endif /* __DNA_TEXTURE_DEFAULTS_H__ */ diff --git a/source/blender/makesdna/DNA_world_defaults.h b/source/blender/makesdna/DNA_world_defaults.h new file mode 100644 index 00000000000..c4d934381b4 --- /dev/null +++ b/source/blender/makesdna/DNA_world_defaults.h @@ -0,0 +1,49 @@ +/* + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ + +/** \file + * \ingroup DNA + */ + +#ifndef __DNA_WORLD_DEFAULTS_H__ +#define __DNA_WORLD_DEFAULTS_H__ + +/* Struct members on own line. */ +/* clang-format off */ + +/* -------------------------------------------------------------------- */ +/** \name World Struct + * \{ */ + +#define _DNA_DEFAULT_World \ + { \ + .horr = 0.05f, \ + .horg = 0.05f, \ + .horb = 0.05f, \ + \ + .aodist = 10.0f, \ + .aoenergy = 1.0f, \ + \ + .preview = NULL, \ + .miststa = 5.0f, \ + .mistdist = 25.0f, \ + } + +/** \} */ + +/* clang-format on */ + +#endif /* __DNA_WORLD_DEFAULTS_H__ */ diff --git a/source/blender/makesdna/intern/CMakeLists.txt b/source/blender/makesdna/intern/CMakeLists.txt index 342e466c3f7..bca27442e65 100644 --- a/source/blender/makesdna/intern/CMakeLists.txt +++ b/source/blender/makesdna/intern/CMakeLists.txt @@ -128,10 +128,21 @@ set(SRC ../../blenlib/intern/hash_mm2a.c ../../blenlib/intern/listbase.c + ../DNA_brush_defaults.h + ../DNA_cachefile_defaults.h + ../DNA_camera_defaults.h + ../DNA_curve_defaults.h + ../DNA_image_defaults.h + ../DNA_lattice_defaults.h + ../DNA_light_defaults.h + ../DNA_lightprobe_defaults.h + ../DNA_linestyle_defaults.h ../DNA_material_defaults.h ../DNA_mesh_defaults.h + ../DNA_meta_defaults.h ../DNA_object_defaults.h ../DNA_scene_defaults.h + ../DNA_texture_defaults.h ../DNA_vec_defaults.h ../DNA_view3d_defaults.h ) diff --git a/source/blender/makesdna/intern/dna_defaults.c b/source/blender/makesdna/intern/dna_defaults.c index 4662f3a0b01..7aecbb1789e 100644 --- a/source/blender/makesdna/intern/dna_defaults.c +++ b/source/blender/makesdna/intern/dna_defaults.c @@ -54,33 +54,100 @@ #include "DNA_defaults.h" +#include "DNA_brush_types.h" +#include "DNA_cachefile_types.h" +#include "DNA_camera_types.h" #include "DNA_curve_types.h" +#include "DNA_image_types.h" +#include "DNA_key_types.h" +#include "DNA_lattice_types.h" +#include "DNA_light_types.h" +#include "DNA_lightprobe_types.h" +#include "DNA_linestyle_types.h" #include "DNA_material_types.h" #include "DNA_mesh_types.h" +#include "DNA_meta_types.h" #include "DNA_object_types.h" #include "DNA_scene_types.h" +#include "DNA_speaker_types.h" +#include "DNA_texture_types.h" +#include "DNA_world_types.h" +#include "DNA_brush_defaults.h" +#include "DNA_cachefile_defaults.h" +#include "DNA_camera_defaults.h" +#include "DNA_curve_defaults.h" +#include "DNA_image_defaults.h" +#include "DNA_lattice_defaults.h" +#include "DNA_light_defaults.h" +#include "DNA_lightprobe_defaults.h" +#include "DNA_linestyle_defaults.h" #include "DNA_material_defaults.h" #include "DNA_mesh_defaults.h" +#include "DNA_meta_defaults.h" #include "DNA_object_defaults.h" #include "DNA_scene_defaults.h" +#include "DNA_speaker_defaults.h" +#include "DNA_texture_defaults.h" +#include "DNA_world_defaults.h" #define SDNA_DEFAULT_DECL_STRUCT(struct_name) \ const struct_name DNA_DEFAULT_##struct_name = _DNA_DEFAULT_##struct_name -/* DNA_scene_material.h */ +/* DNA_brush_defaults.h */ +SDNA_DEFAULT_DECL_STRUCT(Brush); + +/* DNA_cachefile_defaults.h */ +SDNA_DEFAULT_DECL_STRUCT(CacheFile); + +/* DNA_camera_defaults.h */ +SDNA_DEFAULT_DECL_STRUCT(Camera); +SDNA_DEFAULT_DECL_STRUCT(CameraDOFSettings); +SDNA_DEFAULT_DECL_STRUCT(CameraStereoSettings); + +/* DNA_curve_defaults.h */ +SDNA_DEFAULT_DECL_STRUCT(Curve); + +/* DNA_image_defaults.h */ +SDNA_DEFAULT_DECL_STRUCT(Image); + +/* DNA_lattice_defaults.h */ +SDNA_DEFAULT_DECL_STRUCT(Lattice); + +/* DNA_light_defaults.h */ +SDNA_DEFAULT_DECL_STRUCT(Light); + +/* DNA_lightprobe_defaults.h */ +SDNA_DEFAULT_DECL_STRUCT(LightProbe); + +/* DNA_linestyle_defaults.h */ +SDNA_DEFAULT_DECL_STRUCT(FreestyleLineStyle); + +/* DNA_material_defaults.h */ SDNA_DEFAULT_DECL_STRUCT(Material); -/* DNA_scene_mesh.h */ +/* DNA_mesh_defaults.h */ SDNA_DEFAULT_DECL_STRUCT(Mesh); -/* DNA_scene_object.h */ +/* DNA_meta_defaults.h */ +SDNA_DEFAULT_DECL_STRUCT(MetaBall); + +/* DNA_object_defaults.h */ SDNA_DEFAULT_DECL_STRUCT(Object); /* DNA_scene_defaults.h */ SDNA_DEFAULT_DECL_STRUCT(Scene); SDNA_DEFAULT_DECL_STRUCT(ToolSettings); +/* DNA_speaker_defaults.h */ +SDNA_DEFAULT_DECL_STRUCT(Speaker); + +/* DNA_texture_defaults.h */ +SDNA_DEFAULT_DECL_STRUCT(Tex); + +/* DNA_world_defaults.h */ +SDNA_DEFAULT_DECL_STRUCT(World); + #undef SDNA_DEFAULT_DECL_STRUCT /* Reuse existing definitions. */ @@ -108,12 +175,44 @@ extern const bTheme U_theme_default; /** Keep headers sorted. */ const void *DNA_default_table[SDNA_TYPE_MAX] = { + /* DNA_brush_defaults.h */ + SDNA_DEFAULT_DECL(Brush), + + /* DNA_cachefile_defaults.h */ + SDNA_DEFAULT_DECL(CacheFile), + + /* DNA_camera_defaults.h */ + SDNA_DEFAULT_DECL(Camera), + SDNA_DEFAULT_DECL_EX(CameraDOFSettings, Camera.dof), + SDNA_DEFAULT_DECL_EX(CameraStereoSettings, Camera.stereo), + + /* DNA_curve_defaults.h */ + SDNA_DEFAULT_DECL(Curve), + + /* DNA_image_defaults.h */ + SDNA_DEFAULT_DECL(Image), + + /* DNA_lattice_defaults.h */ + SDNA_DEFAULT_DECL(Lattice), + + /* DNA_light_defaults.h */ + SDNA_DEFAULT_DECL(Light), + + /* DNA_lightprobe_defaults.h */ + SDNA_DEFAULT_DECL(LightProbe), + + /* DNA_linestyle_defaults.h */ + SDNA_DEFAULT_DECL(FreestyleLineStyle), + /* DNA_material_defaults.h */ SDNA_DEFAULT_DECL(Material), /* DNA_mesh_defaults.h */ SDNA_DEFAULT_DECL(Mesh), + /* DNA_meta_defaults.h */ + SDNA_DEFAULT_DECL(MetaBall), + /* DNA_object_defaults.h */ SDNA_DEFAULT_DECL(Object), @@ -137,6 +236,13 @@ const void *DNA_default_table[SDNA_TYPE_MAX] = { SDNA_DEFAULT_DECL_EX(GP_Sculpt_Settings, ToolSettings.gp_sculpt), SDNA_DEFAULT_DECL_EX(GP_Sculpt_Guide, ToolSettings.gp_sculpt.guide), + /* DNA_speaker_defaults.h */ + SDNA_DEFAULT_DECL(Speaker), + + /* DNA_texture_defaults.h */ + SDNA_DEFAULT_DECL(Tex), + SDNA_DEFAULT_DECL_EX(MTex, Brush.mtex), + /* DNA_userdef_types.h */ SDNA_DEFAULT_DECL(UserDef), SDNA_DEFAULT_DECL(bTheme), @@ -146,6 +252,9 @@ const void *DNA_default_table[SDNA_TYPE_MAX] = { /* DNA_view3d_defaults.h */ SDNA_DEFAULT_DECL_EX(View3DShading, Scene.display.shading), SDNA_DEFAULT_DECL_EX(View3DCursor, Scene.cursor), + + /* DNA_world_defaults.h */ + SDNA_DEFAULT_DECL(World), }; #undef SDNA_DEFAULT_DECL #undef SDNA_DEFAULT_DECL_EX diff --git a/source/blender/makesrna/intern/rna_define.c b/source/blender/makesrna/intern/rna_define.c index 5392c81bd1f..5c41da4dfa3 100644 --- a/source/blender/makesrna/intern/rna_define.c +++ b/source/blender/makesrna/intern/rna_define.c @@ -71,7 +71,7 @@ static struct { #ifndef RNA_RUNTIME /** - * When set, report report details about which defaults are used. + * When set, report details about which defaults are used. * Noisy but handy when investigating default extraction. */ static bool debugSRNA_defaults = false; |