Changeset View
Changeset View
Standalone View
Standalone View
source/blender/blenkernel/intern/scene.c
| Show All 37 Lines | |||||
| #include "DNA_scene_types.h" | #include "DNA_scene_types.h" | ||||
| #include "DNA_screen_types.h" | #include "DNA_screen_types.h" | ||||
| #include "DNA_sequence_types.h" | #include "DNA_sequence_types.h" | ||||
| #include "DNA_space_types.h" | #include "DNA_space_types.h" | ||||
| #include "DNA_view3d_types.h" | #include "DNA_view3d_types.h" | ||||
| #include "DNA_windowmanager_types.h" | #include "DNA_windowmanager_types.h" | ||||
| #include "DNA_workspace_types.h" | #include "DNA_workspace_types.h" | ||||
| #include "DNA_gpencil_types.h" | #include "DNA_gpencil_types.h" | ||||
| #include "DNA_defaults.h" | |||||
| #include "BLI_math.h" | #include "BLI_math.h" | ||||
| #include "BLI_blenlib.h" | #include "BLI_blenlib.h" | ||||
| #include "BLI_utildefines.h" | #include "BLI_utildefines.h" | ||||
| #include "BLI_callbacks.h" | #include "BLI_callbacks.h" | ||||
| #include "BLI_string.h" | #include "BLI_string.h" | ||||
| #include "BLI_string_utils.h" | #include "BLI_string_utils.h" | ||||
| #include "BLI_threads.h" | #include "BLI_threads.h" | ||||
| ▲ Show 20 Lines • Show All 489 Lines • ▼ Show 20 Lines | void BKE_scene_init(Scene *sce) | ||||
| ParticleEditSettings *pset; | ParticleEditSettings *pset; | ||||
| int a; | int a; | ||||
| const char *colorspace_name; | const char *colorspace_name; | ||||
| SceneRenderView *srv; | SceneRenderView *srv; | ||||
| CurveMapping *mblur_shutter_curve; | CurveMapping *mblur_shutter_curve; | ||||
| BLI_assert(MEMCMP_STRUCT_AFTER_IS_ZERO(sce, id)); | BLI_assert(MEMCMP_STRUCT_AFTER_IS_ZERO(sce, id)); | ||||
| MEMCPY_STRUCT_AFTER(sce, DNA_struct_default_get(Scene), id); | |||||
| sce->cursor.rotation_mode = ROT_MODE_XYZ; | |||||
| sce->cursor.rotation_quaternion[0] = 1.0f; | |||||
| sce->cursor.rotation_axis[1] = 1.0f; | |||||
| sce->r.mode = R_OSA; | |||||
| sce->r.cfra = 1; | |||||
| sce->r.sfra = 1; | |||||
| sce->r.efra = 250; | |||||
| sce->r.frame_step = 1; | |||||
| sce->r.xsch = 1920; | |||||
| sce->r.ysch = 1080; | |||||
| sce->r.xasp = 1; | |||||
| sce->r.yasp = 1; | |||||
| sce->r.tilex = 256; | |||||
| sce->r.tiley = 256; | |||||
| sce->r.size = 100; | |||||
| sce->r.im_format.planes = R_IMF_PLANES_RGBA; | |||||
| sce->r.im_format.imtype = R_IMF_IMTYPE_PNG; | |||||
| sce->r.im_format.depth = R_IMF_CHAN_DEPTH_8; | |||||
| sce->r.im_format.quality = 90; | |||||
| sce->r.im_format.compress = 15; | |||||
| sce->r.displaymode = R_OUTPUT_WINDOW; | |||||
| sce->r.framapto = 100; | |||||
| sce->r.images = 100; | |||||
| sce->r.framelen = 1.0; | |||||
| sce->r.blurfac = 0.5; | |||||
| sce->r.frs_sec = 24; | |||||
| sce->r.frs_sec_base = 1; | |||||
| /* OCIO_TODO: for forwards compatibility only, so if no tonecurve are used, | |||||
| * images would look in the same way as in current blender | |||||
| * | |||||
| * perhaps at some point should be completely deprecated? | |||||
| */ | |||||
| sce->r.color_mgt_flag |= R_COLOR_MANAGEMENT; | |||||
| sce->r.gauss = 1.5; | |||||
| sce->r.dither_intensity = 1.0f; | |||||
| sce->r.bake_mode = 0; | |||||
| sce->r.bake_filter = 16; | |||||
| sce->r.bake_flag = R_BAKE_CLEAR; | |||||
| sce->r.bake_samples = 256; | |||||
| sce->r.bake_biasdist = 0.001; | |||||
| sce->r.bake.flag = R_BAKE_CLEAR; | |||||
| sce->r.bake.pass_filter = R_BAKE_PASS_FILTER_ALL; | |||||
| sce->r.bake.width = 512; | |||||
| sce->r.bake.height = 512; | |||||
| sce->r.bake.margin = 16; | |||||
| sce->r.bake.normal_space = R_BAKE_SPACE_TANGENT; | |||||
| sce->r.bake.normal_swizzle[0] = R_BAKE_POSX; | |||||
| sce->r.bake.normal_swizzle[1] = R_BAKE_POSY; | |||||
| sce->r.bake.normal_swizzle[2] = R_BAKE_POSZ; | |||||
| BLI_strncpy(sce->r.bake.filepath, U.renderdir, sizeof(sce->r.bake.filepath)); | BLI_strncpy(sce->r.bake.filepath, U.renderdir, sizeof(sce->r.bake.filepath)); | ||||
| sce->r.bake.im_format.planes = R_IMF_PLANES_RGBA; | |||||
| sce->r.bake.im_format.imtype = R_IMF_IMTYPE_PNG; | |||||
| sce->r.bake.im_format.depth = R_IMF_CHAN_DEPTH_8; | |||||
| sce->r.bake.im_format.quality = 90; | |||||
| sce->r.bake.im_format.compress = 15; | |||||
| sce->r.scemode = R_DOCOMP | R_DOSEQ | R_EXTENSION; | |||||
| sce->r.stamp = R_STAMP_TIME | R_STAMP_FRAME | R_STAMP_DATE | R_STAMP_CAMERA | R_STAMP_SCENE | R_STAMP_FILENAME | R_STAMP_RENDERTIME | R_STAMP_MEMORY; | |||||
| sce->r.stamp_font_id = 12; | |||||
| sce->r.fg_stamp[0] = sce->r.fg_stamp[1] = sce->r.fg_stamp[2] = 0.8f; | |||||
| sce->r.fg_stamp[3] = 1.0f; | |||||
| sce->r.bg_stamp[0] = sce->r.bg_stamp[1] = sce->r.bg_stamp[2] = 0.0f; | |||||
| sce->r.bg_stamp[3] = 0.25f; | |||||
| sce->r.seq_prev_type = OB_SOLID; | |||||
| sce->r.seq_rend_type = OB_SOLID; | |||||
| sce->r.seq_flag = 0; | |||||
| sce->r.threads = 1; | |||||
| sce->r.simplify_subsurf = 6; | |||||
| sce->r.simplify_particles = 1.0f; | |||||
| sce->r.border.xmin = 0.0f; | |||||
| sce->r.border.ymin = 0.0f; | |||||
| sce->r.border.xmax = 1.0f; | |||||
| sce->r.border.ymax = 1.0f; | |||||
| sce->r.preview_start_resolution = 64; | |||||
| sce->r.line_thickness_mode = R_LINE_THICKNESS_ABSOLUTE; | |||||
| sce->r.unit_line_thickness = 1.0f; | |||||
| mblur_shutter_curve = &sce->r.mblur_shutter_curve; | mblur_shutter_curve = &sce->r.mblur_shutter_curve; | ||||
| curvemapping_set_defaults(mblur_shutter_curve, 1, 0.0f, 0.0f, 1.0f, 1.0f); | curvemapping_set_defaults(mblur_shutter_curve, 1, 0.0f, 0.0f, 1.0f, 1.0f); | ||||
| curvemapping_initialize(mblur_shutter_curve); | curvemapping_initialize(mblur_shutter_curve); | ||||
| curvemap_reset(mblur_shutter_curve->cm, | curvemap_reset(mblur_shutter_curve->cm, | ||||
| &mblur_shutter_curve->clipr, | &mblur_shutter_curve->clipr, | ||||
| CURVE_PRESET_MAX, | CURVE_PRESET_MAX, | ||||
| CURVEMAP_SLOPE_POS_NEG); | CURVEMAP_SLOPE_POS_NEG); | ||||
| sce->toolsettings = MEM_callocN(sizeof(struct ToolSettings), "Tool Settings Struct"); | sce->toolsettings = DNA_struct_default_alloc(ToolSettings); | ||||
| sce->toolsettings->object_flag |= SCE_OBJECT_MODE_LOCK; | |||||
| sce->toolsettings->doublimit = 0.001; | |||||
| sce->toolsettings->vgroup_weight = 1.0f; | |||||
| sce->toolsettings->uvcalc_margin = 0.001f; | |||||
| sce->toolsettings->uvcalc_flag = UVCALC_TRANSFORM_CORRECT; | |||||
| sce->toolsettings->unwrapper = 1; | |||||
| sce->toolsettings->select_thresh = 0.01f; | |||||
| sce->toolsettings->gizmo_flag = SCE_GIZMO_SHOW_TRANSLATE | SCE_GIZMO_SHOW_ROTATE | SCE_GIZMO_SHOW_SCALE; | |||||
| sce->toolsettings->selectmode = SCE_SELECT_VERTEX; | |||||
| sce->toolsettings->uv_selectmode = UV_SELECT_VERTEX; | |||||
| sce->toolsettings->autokey_mode = U.autokey_mode; | sce->toolsettings->autokey_mode = U.autokey_mode; | ||||
| sce->toolsettings->transform_pivot_point = V3D_AROUND_CENTER_MEDIAN; | |||||
| sce->toolsettings->snap_mode = SCE_SNAP_MODE_INCREMENT; | |||||
| sce->toolsettings->snap_node_mode = SCE_SNAP_MODE_GRID; | |||||
| sce->toolsettings->snap_uv_mode = SCE_SNAP_MODE_INCREMENT; | |||||
| sce->toolsettings->snap_transform_mode_flag = SCE_SNAP_TRANSFORM_MODE_TRANSLATE; | |||||
| sce->toolsettings->curve_paint_settings.curve_type = CU_BEZIER; | |||||
| sce->toolsettings->curve_paint_settings.flag |= CURVE_PAINT_FLAG_CORNERS_DETECT; | |||||
| sce->toolsettings->curve_paint_settings.error_threshold = 8; | |||||
| sce->toolsettings->curve_paint_settings.radius_max = 1.0f; | |||||
| sce->toolsettings->curve_paint_settings.corner_angle = DEG2RADF(70.0f); | |||||
| sce->toolsettings->statvis.overhang_axis = OB_NEGZ; | |||||
| sce->toolsettings->statvis.overhang_min = 0; | |||||
| sce->toolsettings->statvis.overhang_max = DEG2RADF(45.0f); | |||||
| sce->toolsettings->statvis.thickness_max = 0.1f; | |||||
| sce->toolsettings->statvis.thickness_samples = 1; | |||||
| sce->toolsettings->statvis.distort_min = DEG2RADF(5.0f); | |||||
| sce->toolsettings->statvis.distort_max = DEG2RADF(45.0f); | |||||
| sce->toolsettings->statvis.sharp_min = DEG2RADF(90.0f); | |||||
| sce->toolsettings->statvis.sharp_max = DEG2RADF(180.0f); | |||||
| sce->toolsettings->proportional_size = 1.0f; | |||||
| sce->toolsettings->imapaint.paint.flags |= PAINT_SHOW_BRUSH; | |||||
| sce->toolsettings->imapaint.normal_angle = 80; | |||||
| sce->toolsettings->imapaint.seam_bleed = 2; | |||||
| /* grease pencil multiframe falloff curve */ | /* grease pencil multiframe falloff curve */ | ||||
| sce->toolsettings->gp_sculpt.cur_falloff = curvemapping_add(1, 0.0f, 0.0f, 1.0f, 1.0f); | sce->toolsettings->gp_sculpt.cur_falloff = curvemapping_add(1, 0.0f, 0.0f, 1.0f, 1.0f); | ||||
| CurveMapping *gp_falloff_curve = sce->toolsettings->gp_sculpt.cur_falloff; | CurveMapping *gp_falloff_curve = sce->toolsettings->gp_sculpt.cur_falloff; | ||||
| curvemapping_initialize(gp_falloff_curve); | curvemapping_initialize(gp_falloff_curve); | ||||
| curvemap_reset( | curvemap_reset( | ||||
| gp_falloff_curve->cm, | gp_falloff_curve->cm, | ||||
| &gp_falloff_curve->clipr, | &gp_falloff_curve->clipr, | ||||
| CURVE_PRESET_GAUSS, | CURVE_PRESET_GAUSS, | ||||
| CURVEMAP_SLOPE_POSITIVE); | CURVEMAP_SLOPE_POSITIVE); | ||||
| sce->toolsettings->gp_sculpt.cur_primitive = curvemapping_add(1, 0.0f, 0.0f, 1.0f, 1.0f); | sce->toolsettings->gp_sculpt.cur_primitive = curvemapping_add(1, 0.0f, 0.0f, 1.0f, 1.0f); | ||||
| CurveMapping *gp_primitive_curve = sce->toolsettings->gp_sculpt.cur_primitive; | CurveMapping *gp_primitive_curve = sce->toolsettings->gp_sculpt.cur_primitive; | ||||
| curvemapping_initialize(gp_primitive_curve); | curvemapping_initialize(gp_primitive_curve); | ||||
| curvemap_reset( | curvemap_reset( | ||||
| gp_primitive_curve->cm, | gp_primitive_curve->cm, | ||||
| &gp_primitive_curve->clipr, | &gp_primitive_curve->clipr, | ||||
| CURVE_PRESET_BELL, | CURVE_PRESET_BELL, | ||||
| CURVEMAP_SLOPE_POSITIVE); | CURVEMAP_SLOPE_POSITIVE); | ||||
| sce->toolsettings->gp_sculpt.guide.spacing = 20.0f; | |||||
| sce->physics_settings.gravity[0] = 0.0f; | |||||
| sce->physics_settings.gravity[1] = 0.0f; | |||||
| sce->physics_settings.gravity[2] = -9.81f; | |||||
| sce->physics_settings.flag = PHYS_GLOBAL_GRAVITY; | |||||
| sce->unit.system = USER_UNIT_METRIC; | sce->unit.system = USER_UNIT_METRIC; | ||||
| sce->unit.scale_length = 1.0f; | sce->unit.scale_length = 1.0f; | ||||
| sce->unit.length_unit = bUnit_GetBaseUnitOfType(USER_UNIT_METRIC, B_UNIT_LENGTH); | sce->unit.length_unit = bUnit_GetBaseUnitOfType(USER_UNIT_METRIC, B_UNIT_LENGTH); | ||||
| sce->unit.mass_unit = bUnit_GetBaseUnitOfType(USER_UNIT_METRIC, B_UNIT_MASS); | sce->unit.mass_unit = bUnit_GetBaseUnitOfType(USER_UNIT_METRIC, B_UNIT_MASS); | ||||
| sce->unit.time_unit = bUnit_GetBaseUnitOfType(USER_UNIT_METRIC, B_UNIT_TIME); | sce->unit.time_unit = bUnit_GetBaseUnitOfType(USER_UNIT_METRIC, B_UNIT_TIME); | ||||
| pset = &sce->toolsettings->particle; | pset = &sce->toolsettings->particle; | ||||
| pset->flag = PE_KEEP_LENGTHS | PE_LOCK_FIRST | PE_DEFLECT_EMITTER | PE_AUTO_VELOCITY; | pset->flag = PE_KEEP_LENGTHS | PE_LOCK_FIRST | PE_DEFLECT_EMITTER | PE_AUTO_VELOCITY; | ||||
| pset->emitterdist = 0.25f; | pset->emitterdist = 0.25f; | ||||
| pset->totrekey = 5; | pset->totrekey = 5; | ||||
| pset->totaddkey = 5; | pset->totaddkey = 5; | ||||
| pset->brushtype = PE_BRUSH_COMB; | pset->brushtype = PE_BRUSH_COMB; | ||||
| pset->draw_step = 2; | pset->draw_step = 2; | ||||
| pset->fade_frames = 2; | pset->fade_frames = 2; | ||||
| pset->selectmode = SCE_SELECT_PATH; | pset->selectmode = SCE_SELECT_PATH; | ||||
| for (a = 0; a < ARRAY_SIZE(pset->brush); a++) { | for (a = 0; a < ARRAY_SIZE(pset->brush); a++) { | ||||
| pset->brush[a].strength = 0.5f; | pset->brush[a].strength = 0.5f; | ||||
| pset->brush[a].size = 50; | pset->brush[a].size = 50; | ||||
| pset->brush[a].step = 10; | pset->brush[a].step = 10; | ||||
| pset->brush[a].count = 10; | pset->brush[a].count = 10; | ||||
| } | } | ||||
| pset->brush[PE_BRUSH_CUT].strength = 1.0f; | pset->brush[PE_BRUSH_CUT].strength = 1.0f; | ||||
| sce->r.ffcodecdata.audio_mixrate = 48000; | |||||
| sce->r.ffcodecdata.audio_volume = 1.0f; | |||||
| sce->r.ffcodecdata.audio_bitrate = 192; | |||||
| sce->r.ffcodecdata.audio_channels = 2; | |||||
| BLI_strncpy(sce->r.engine, RE_engine_id_BLENDER_EEVEE, sizeof(sce->r.engine)); | BLI_strncpy(sce->r.engine, RE_engine_id_BLENDER_EEVEE, sizeof(sce->r.engine)); | ||||
| sce->audio.distance_model = 2.0f; | |||||
| sce->audio.doppler_factor = 1.0f; | |||||
| sce->audio.speed_of_sound = 343.3f; | |||||
| sce->audio.volume = 1.0f; | |||||
| sce->audio.flag = AUDIO_SYNC; | |||||
| BLI_strncpy(sce->r.pic, U.renderdir, sizeof(sce->r.pic)); | BLI_strncpy(sce->r.pic, U.renderdir, sizeof(sce->r.pic)); | ||||
| BLI_rctf_init(&sce->r.safety, 0.1f, 0.9f, 0.1f, 0.9f); | BLI_rctf_init(&sce->r.safety, 0.1f, 0.9f, 0.1f, 0.9f); | ||||
| sce->r.osa = 8; | |||||
| /* note; in header_info.c the scene copy happens..., if you add more to renderdata it has to be checked there */ | /* note; in header_info.c the scene copy happens..., if you add more to renderdata it has to be checked there */ | ||||
| /* multiview - stereo */ | /* multiview - stereo */ | ||||
| BKE_scene_add_render_view(sce, STEREO_LEFT_NAME); | BKE_scene_add_render_view(sce, STEREO_LEFT_NAME); | ||||
| srv = sce->r.views.first; | srv = sce->r.views.first; | ||||
| BLI_strncpy(srv->suffix, STEREO_LEFT_SUFFIX, sizeof(srv->suffix)); | BLI_strncpy(srv->suffix, STEREO_LEFT_SUFFIX, sizeof(srv->suffix)); | ||||
| Show All 26 Lines | BKE_color_managed_view_settings_init_render(&sce->r.bake.im_format.view_settings, | ||||
| "Filmic"); | "Filmic"); | ||||
| /* Safe Areas */ | /* Safe Areas */ | ||||
| copy_v2_fl2(sce->safe_areas.title, 10.0f / 100.0f, 5.0f / 100.0f); | copy_v2_fl2(sce->safe_areas.title, 10.0f / 100.0f, 5.0f / 100.0f); | ||||
| copy_v2_fl2(sce->safe_areas.action, 3.5f / 100.0f, 3.5f / 100.0f); | copy_v2_fl2(sce->safe_areas.action, 3.5f / 100.0f, 3.5f / 100.0f); | ||||
| copy_v2_fl2(sce->safe_areas.title_center, 17.5f / 100.0f, 5.0f / 100.0f); | copy_v2_fl2(sce->safe_areas.title_center, 17.5f / 100.0f, 5.0f / 100.0f); | ||||
| copy_v2_fl2(sce->safe_areas.action_center, 15.0f / 100.0f, 5.0f / 100.0f); | copy_v2_fl2(sce->safe_areas.action_center, 15.0f / 100.0f, 5.0f / 100.0f); | ||||
| sce->preview = NULL; | |||||
| /* GP Sculpt brushes */ | /* GP Sculpt brushes */ | ||||
| { | { | ||||
| GP_Sculpt_Settings *gset = &sce->toolsettings->gp_sculpt; | GP_Sculpt_Settings *gset = &sce->toolsettings->gp_sculpt; | ||||
| GP_Sculpt_Data *gp_brush; | GP_Sculpt_Data *gp_brush; | ||||
| float curcolor_add[3], curcolor_sub[3]; | float curcolor_add[3], curcolor_sub[3]; | ||||
| ARRAY_SET_ITEMS(curcolor_add, 1.0f, 0.6f, 0.6f); | ARRAY_SET_ITEMS(curcolor_add, 1.0f, 0.6f, 0.6f); | ||||
| ARRAY_SET_ITEMS(curcolor_sub, 0.6f, 0.6f, 1.0f); | ARRAY_SET_ITEMS(curcolor_sub, 0.6f, 0.6f, 1.0f); | ||||
| ▲ Show 20 Lines • Show All 68 Lines • ▼ Show 20 Lines | for (int i = 0; i < ARRAY_SIZE(sce->orientation_slots); i++) { | ||||
| sce->orientation_slots[i].index_custom = -1; | sce->orientation_slots[i].index_custom = -1; | ||||
| } | } | ||||
| /* Master Collection */ | /* Master Collection */ | ||||
| sce->master_collection = BKE_collection_master_add(); | sce->master_collection = BKE_collection_master_add(); | ||||
| BKE_view_layer_add(sce, "View Layer"); | BKE_view_layer_add(sce, "View Layer"); | ||||
| /* SceneDisplay */ | |||||
| copy_v3_v3(sce->display.light_direction, (float[3]){M_SQRT1_3, M_SQRT1_3, M_SQRT1_3}); | |||||
| sce->display.shadow_shift = 0.1f; | |||||
| sce->display.shadow_focus = 0.0f; | |||||
| sce->display.matcap_ssao_distance = 0.2f; | |||||
| sce->display.matcap_ssao_attenuation = 1.0f; | |||||
| sce->display.matcap_ssao_samples = 16; | |||||
| /* OpenGL Render. */ | |||||
| BKE_screen_view3d_shading_init(&sce->display.shading); | |||||
| /* SceneEEVEE */ | /* SceneEEVEE */ | ||||
| sce->eevee.gi_diffuse_bounces = 3; | sce->eevee.gi_diffuse_bounces = 3; | ||||
| sce->eevee.gi_cubemap_resolution = 512; | sce->eevee.gi_cubemap_resolution = 512; | ||||
| sce->eevee.gi_visibility_resolution = 32; | sce->eevee.gi_visibility_resolution = 32; | ||||
| sce->eevee.gi_cubemap_draw_size = 0.3f; | sce->eevee.gi_cubemap_draw_size = 0.3f; | ||||
| sce->eevee.gi_irradiance_draw_size = 0.1f; | sce->eevee.gi_irradiance_draw_size = 0.1f; | ||||
| sce->eevee.gi_irradiance_smoothing = 0.1f; | sce->eevee.gi_irradiance_smoothing = 0.1f; | ||||
| sce->eevee.gi_filter_quality = 1.0f; | sce->eevee.gi_filter_quality = 1.0f; | ||||
| ▲ Show 20 Lines • Show All 1,443 Lines • Show Last 20 Lines | |||||