Changeset View
Changeset View
Standalone View
Standalone View
source/blender/blenloader/intern/versioning_defaults.c
| Show All 40 Lines | |||||
| #include "DNA_light_types.h" | #include "DNA_light_types.h" | ||||
| #include "BKE_appdir.h" | #include "BKE_appdir.h" | ||||
| #include "BKE_brush.h" | #include "BKE_brush.h" | ||||
| #include "BKE_colortools.h" | #include "BKE_colortools.h" | ||||
| #include "BKE_layer.h" | #include "BKE_layer.h" | ||||
| #include "BKE_library.h" | #include "BKE_library.h" | ||||
| #include "BKE_main.h" | #include "BKE_main.h" | ||||
| #include "BKE_mesh.h" | |||||
| #include "BKE_node.h" | #include "BKE_node.h" | ||||
| #include "BKE_paint.h" | #include "BKE_paint.h" | ||||
| #include "BKE_screen.h" | #include "BKE_screen.h" | ||||
| #include "BKE_workspace.h" | #include "BKE_workspace.h" | ||||
| #include "BLO_readfile.h" | #include "BLO_readfile.h" | ||||
| /** | /** | ||||
| ▲ Show 20 Lines • Show All 168 Lines • ▼ Show 20 Lines | if (blo_is_builtin_template(app_template)) { | ||||
| while (!BLI_listbase_is_empty(&workspace->tools)) { | while (!BLI_listbase_is_empty(&workspace->tools)) { | ||||
| BKE_workspace_tool_remove(workspace, workspace->tools.first); | BKE_workspace_tool_remove(workspace, workspace->tools.first); | ||||
| } | } | ||||
| /* For 2D animation template. */ | /* For 2D animation template. */ | ||||
| if (STREQ(workspace->id.name + 2, "Drawing")) { | if (STREQ(workspace->id.name + 2, "Drawing")) { | ||||
| workspace->object_mode = OB_MODE_PAINT_GPENCIL; | workspace->object_mode = OB_MODE_PAINT_GPENCIL; | ||||
| } | } | ||||
| /* For Sculpting template. */ | |||||
| if (STREQ(workspace->id.name + 2, "Sculpting")) { | |||||
| for (WorkSpaceLayout *layout = layouts->first; layout; layout = layout->next) { | |||||
| bScreen *screen = layout->screen; | |||||
| if (screen) { | |||||
| for (ScrArea *sa = screen->areabase.first; sa; sa = sa->next) { | |||||
| for (ARegion *ar = sa->regionbase.first; ar; ar = ar->next) { | |||||
| if (sa->spacetype == SPACE_VIEW3D) { | |||||
| View3D *v3d = sa->spacedata.first; | |||||
| v3d->shading.flag &= ~V3D_SHADING_CAVITY; | |||||
| copy_v3_fl(v3d->shading.single_color, 1.0f); | |||||
| STRNCPY(v3d->shading.matcap, "basic_1"); | |||||
| } | |||||
| } | |||||
| } | |||||
| } | |||||
| } | |||||
| } | |||||
| } | } | ||||
| } | } | ||||
| static void blo_update_defaults_scene(Main *bmain, Scene *scene) | static void blo_update_defaults_scene(Main *bmain, Scene *scene) | ||||
| { | { | ||||
| BLI_strncpy(scene->r.engine, RE_engine_id_BLENDER_EEVEE, sizeof(scene->r.engine)); | BLI_strncpy(scene->r.engine, RE_engine_id_BLENDER_EEVEE, sizeof(scene->r.engine)); | ||||
| scene->r.cfra = 1.0f; | scene->r.cfra = 1.0f; | ||||
| ▲ Show 20 Lines • Show All 99 Lines • ▼ Show 20 Lines | for (WorkSpace *workspace = bmain->workspaces.first; workspace; workspace = workspace->id.next) { | ||||
| LISTBASE_FOREACH_MUTABLE (WorkSpaceLayout *, layout_iter, &workspace->layouts) { | LISTBASE_FOREACH_MUTABLE (WorkSpaceLayout *, layout_iter, &workspace->layouts) { | ||||
| if (layout != layout_iter) { | if (layout != layout_iter) { | ||||
| BKE_workspace_layout_remove(bmain, workspace, layout_iter); | BKE_workspace_layout_remove(bmain, workspace, layout_iter); | ||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| /* Scenes */ | /* Scenes */ | ||||
| for (Scene *scene = bmain->scenes.first; scene; scene = scene->id.next) { | for (Scene *scene = bmain->scenes.first; scene; scene = scene->id.next) { | ||||
| blo_update_defaults_scene(bmain, scene); | blo_update_defaults_scene(bmain, scene); | ||||
| if (app_template && STREQ(app_template, "Video_Editing")) { | if (app_template && STREQ(app_template, "Video_Editing")) { | ||||
| /* Filmic is too slow, use standard until it is optimized. */ | /* Filmic is too slow, use standard until it is optimized. */ | ||||
brecht: This part editing meshes should not be inside the loop over workspaces. Meshes are not per… | |||||
| STRNCPY(scene->view_settings.view_transform, "Standard"); | STRNCPY(scene->view_settings.view_transform, "Standard"); | ||||
| STRNCPY(scene->view_settings.look, "None"); | STRNCPY(scene->view_settings.look, "None"); | ||||
| } | } | ||||
| else { | else { | ||||
| /* AV Sync break physics sim caching, disable until that is fixed. */ | /* AV Sync break physics sim caching, disable until that is fixed. */ | ||||
| scene->audio.flag &= ~AUDIO_SYNC; | scene->audio.flag &= ~AUDIO_SYNC; | ||||
| scene->flag &= ~SCE_FRAME_DROP; | scene->flag &= ~SCE_FRAME_DROP; | ||||
| } | } | ||||
| /* Change default selection mode for Grease Pencil. */ | /* Change default selection mode for Grease Pencil. */ | ||||
| if (app_template && STREQ(app_template, "2D_Animation")) { | if (app_template && STREQ(app_template, "2D_Animation")) { | ||||
| ToolSettings *ts = scene->toolsettings; | ToolSettings *ts = scene->toolsettings; | ||||
Done Inline ActionsThis part editing the screen was meant to stay in BLO_update_defaults_workspace. brecht: This part editing the screen was meant to stay in `BLO_update_defaults_workspace`. | |||||
| ts->gpencil_selectmode_edit = GP_SELECTMODE_STROKE; | ts->gpencil_selectmode_edit = GP_SELECTMODE_STROKE; | ||||
| } | } | ||||
| } | } | ||||
| /* Objects */ | /* Objects */ | ||||
| rename_id_for_versioning(bmain, ID_OB, "Lamp", "Light"); | rename_id_for_versioning(bmain, ID_OB, "Lamp", "Light"); | ||||
| rename_id_for_versioning(bmain, ID_LA, "Lamp", "Light"); | rename_id_for_versioning(bmain, ID_LA, "Lamp", "Light"); | ||||
| if (app_template && STREQ(app_template, "2D_Animation")) { | if (app_template && STREQ(app_template, "2D_Animation")) { | ||||
| for (Object *object = bmain->objects.first; object; object = object->id.next) { | for (Object *object = bmain->objects.first; object; object = object->id.next) { | ||||
| if (object->type == OB_GPENCIL) { | if (object->type == OB_GPENCIL) { | ||||
| /* Set grease pencil object in drawing mode */ | /* Set grease pencil object in drawing mode */ | ||||
| bGPdata *gpd = (bGPdata *)object->data; | bGPdata *gpd = (bGPdata *)object->data; | ||||
| object->mode = OB_MODE_PAINT_GPENCIL; | object->mode = OB_MODE_PAINT_GPENCIL; | ||||
| gpd->flag |= GP_DATA_STROKE_PAINTMODE; | gpd->flag |= GP_DATA_STROKE_PAINTMODE; | ||||
| break; | break; | ||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| for (Mesh *mesh = bmain->meshes.first; mesh; mesh = mesh->id.next) { | for (Mesh *mesh = bmain->meshes.first; mesh; mesh = mesh->id.next) { | ||||
| /* Match default for new meshes. */ | /* Match default for new meshes. */ | ||||
| mesh->smoothresh = DEG2RADF(30); | mesh->smoothresh = DEG2RADF(30); | ||||
| /* For Sculpting template. */ | |||||
| if (app_template && STREQ(app_template, "Sculpting")) { | |||||
| mesh->remesh_voxel_size = 0.035f; | |||||
| mesh->flag |= ME_REMESH_FIX_POLES | ME_REMESH_REPROJECT_VOLUME; | |||||
| BKE_mesh_smooth_flag_set(mesh, false); | |||||
| } | |||||
| } | } | ||||
| for (Camera *camera = bmain->cameras.first; camera; camera = camera->id.next) { | for (Camera *camera = bmain->cameras.first; camera; camera = camera->id.next) { | ||||
| /* Initialize to a useful value. */ | /* Initialize to a useful value. */ | ||||
| camera->dof.focus_distance = 10.0f; | camera->dof.focus_distance = 10.0f; | ||||
| camera->dof.aperture_fstop = 2.8f; | camera->dof.aperture_fstop = 2.8f; | ||||
| } | } | ||||
| ▲ Show 20 Lines • Show All 138 Lines • Show Last 20 Lines | |||||
This part editing meshes should not be inside the loop over workspaces. Meshes are not per-workspace so this makes no sense. They are part of an app template, which is why I suggested the app template test in my comment.