Changeset View
Changeset View
Standalone View
Standalone View
source/blender/blenloader/intern/versioning_280.c
| Show All 31 Lines | |||||
| #include "DNA_anim_types.h" | #include "DNA_anim_types.h" | ||||
| #include "DNA_object_types.h" | #include "DNA_object_types.h" | ||||
| #include "DNA_camera_types.h" | #include "DNA_camera_types.h" | ||||
| #include "DNA_cloth_types.h" | #include "DNA_cloth_types.h" | ||||
| #include "DNA_collection_types.h" | #include "DNA_collection_types.h" | ||||
| #include "DNA_constraint_types.h" | #include "DNA_constraint_types.h" | ||||
| #include "DNA_curveprofile_types.h" | #include "DNA_curveprofile_types.h" | ||||
| #include "DNA_freestyle_types.h" | |||||
| #include "DNA_gpu_types.h" | #include "DNA_gpu_types.h" | ||||
| #include "DNA_gpencil_types.h" | |||||
| #include "DNA_gpencil_modifier_types.h" | |||||
| #include "DNA_light_types.h" | #include "DNA_light_types.h" | ||||
| #include "DNA_layer_types.h" | #include "DNA_layer_types.h" | ||||
| #include "DNA_lightprobe_types.h" | #include "DNA_lightprobe_types.h" | ||||
| #include "DNA_linestyle_types.h" | |||||
| #include "DNA_material_types.h" | #include "DNA_material_types.h" | ||||
| #include "DNA_mesh_types.h" | #include "DNA_mesh_types.h" | ||||
| #include "DNA_modifier_types.h" | #include "DNA_modifier_types.h" | ||||
| #include "DNA_particle_types.h" | #include "DNA_particle_types.h" | ||||
| #include "DNA_rigidbody_types.h" | #include "DNA_rigidbody_types.h" | ||||
| #include "DNA_scene_types.h" | #include "DNA_scene_types.h" | ||||
| #include "DNA_screen_types.h" | #include "DNA_screen_types.h" | ||||
| #include "DNA_view3d_types.h" | #include "DNA_view3d_types.h" | ||||
| #include "DNA_genfile.h" | #include "DNA_genfile.h" | ||||
| #include "DNA_gpencil_types.h" | |||||
| #include "DNA_workspace_types.h" | #include "DNA_workspace_types.h" | ||||
| #include "DNA_key_types.h" | #include "DNA_key_types.h" | ||||
| #include "DNA_curve_types.h" | #include "DNA_curve_types.h" | ||||
| #include "DNA_armature_types.h" | #include "DNA_armature_types.h" | ||||
| #include "DNA_text_types.h" | #include "DNA_text_types.h" | ||||
| #include "DNA_texture_types.h" | |||||
| #include "DNA_world_types.h" | #include "DNA_world_types.h" | ||||
| #include "BKE_animsys.h" | #include "BKE_animsys.h" | ||||
| #include "BKE_cloth.h" | #include "BKE_cloth.h" | ||||
| #include "BKE_collection.h" | #include "BKE_collection.h" | ||||
| #include "BKE_constraint.h" | #include "BKE_constraint.h" | ||||
| #include "BKE_colortools.h" | #include "BKE_colortools.h" | ||||
| #include "BKE_customdata.h" | #include "BKE_customdata.h" | ||||
| ▲ Show 20 Lines • Show All 789 Lines • ▼ Show 20 Lines | |||||
| static void do_versions_local_collection_bits_set(LayerCollection *layer_collection) | static void do_versions_local_collection_bits_set(LayerCollection *layer_collection) | ||||
| { | { | ||||
| layer_collection->local_collections_bits = ~(0); | layer_collection->local_collections_bits = ~(0); | ||||
| LISTBASE_FOREACH (LayerCollection *, child, &layer_collection->layer_collections) { | LISTBASE_FOREACH (LayerCollection *, child, &layer_collection->layer_collections) { | ||||
| do_versions_local_collection_bits_set(child); | do_versions_local_collection_bits_set(child); | ||||
| } | } | ||||
| } | } | ||||
| static void do_version_curvemapping_flag_extend_extrapolate(CurveMapping *cumap) | |||||
| { | |||||
| #define CUMA_EXTEND_EXTRAPOLATE_OLD 1 | |||||
| for (int curve_map_index = 0; curve_map_index < 4; curve_map_index++) { | |||||
| CurveMap *cuma = &cumap->cm[curve_map_index]; | |||||
| if (cuma->flag & CUMA_EXTEND_EXTRAPOLATE_OLD) { | |||||
| cumap->flag |= CUMA_EXTEND_EXTRAPOLATE; | |||||
| return; | |||||
| } | |||||
| } | |||||
| #undef CUMA_EXTEND_EXTRAPOLATE_OLD | |||||
| } | |||||
| /* Util version to walk over all CurveMappings in the given `bmain` */ | |||||
| static void do_version_curvemapping_walker(Main *bmain, void (*callback)(CurveMapping *cumap)) | |||||
| { | |||||
| LISTBASE_FOREACH (Scene *, scene, &bmain->scenes) { | |||||
| callback(&scene->r.mblur_shutter_curve); | |||||
| if (scene->view_settings.curve_mapping) { | |||||
| callback(scene->view_settings.curve_mapping); | |||||
| } | |||||
| if (scene->ed != NULL) { | |||||
| LISTBASE_FOREACH (Sequence *, seq, &scene->ed->seqbase) { | |||||
| LISTBASE_FOREACH (SequenceModifierData *, smd, &seq->modifiers) { | |||||
| const SequenceModifierTypeInfo *smti = BKE_sequence_modifier_type_info_get(smd->type); | |||||
| if (smti) { | |||||
| if (smd->type == seqModifierType_Curves) { | |||||
| CurvesModifierData *cmd = (CurvesModifierData *)smd; | |||||
| callback(&cmd->curve_mapping); | |||||
| } | |||||
| else if (smd->type == seqModifierType_HueCorrect) { | |||||
| HueCorrectModifierData *hcmd = (HueCorrectModifierData *)smd; | |||||
| callback(&hcmd->curve_mapping); | |||||
| } | |||||
| } | |||||
| } | |||||
| } | |||||
| } | |||||
| // toolsettings | |||||
| ToolSettings *ts = scene->toolsettings; | |||||
| if (ts->vpaint) { | |||||
| callback(ts->vpaint->paint.cavity_curve); | |||||
| } | |||||
| if (ts->wpaint) { | |||||
| callback(ts->wpaint->paint.cavity_curve); | |||||
| } | |||||
| if (ts->sculpt) { | |||||
| callback(ts->sculpt->paint.cavity_curve); | |||||
| } | |||||
| if (ts->uvsculpt) { | |||||
| callback(ts->uvsculpt->paint.cavity_curve); | |||||
| } | |||||
| if (ts->gp_paint) { | |||||
| callback(ts->gp_paint->paint.cavity_curve); | |||||
| } | |||||
| if (ts->gp_interpolate.custom_ipo) { | |||||
| callback(ts->gp_interpolate.custom_ipo); | |||||
| } | |||||
| if (ts->gp_sculpt.cur_falloff) { | |||||
| callback(ts->gp_sculpt.cur_falloff); | |||||
| } | |||||
| if (ts->gp_sculpt.cur_primitive) { | |||||
| callback(ts->gp_sculpt.cur_primitive); | |||||
| } | |||||
| callback(ts->imapaint.paint.cavity_curve); | |||||
| } | |||||
| FOREACH_NODETREE_BEGIN (bmain, node_tree, id) { | |||||
| LISTBASE_FOREACH (bNode *, node, &node_tree->nodes) { | |||||
| if (ELEM(node->type, | |||||
| SH_NODE_CURVE_VEC, | |||||
| SH_NODE_CURVE_RGB, | |||||
| CMP_NODE_CURVE_VEC, | |||||
| CMP_NODE_CURVE_RGB, | |||||
| CMP_NODE_TIME, | |||||
| CMP_NODE_HUECORRECT, | |||||
| TEX_NODE_CURVE_RGB, | |||||
| TEX_NODE_CURVE_TIME)) { | |||||
| callback((CurveMapping *)node->storage); | |||||
| } | |||||
| } | |||||
| } | |||||
| FOREACH_NODETREE_END; | |||||
| LISTBASE_FOREACH (Light *, light, &bmain->lights) { | |||||
| if (light->curfalloff) { | |||||
| callback(light->curfalloff); | |||||
| } | |||||
| } | |||||
| LISTBASE_FOREACH (Brush *, brush, &bmain->brushes) { | |||||
| if (brush->curve) { | |||||
| callback(brush->curve); | |||||
| } | |||||
| if (brush->gpencil_settings) { | |||||
| if (brush->gpencil_settings->curve_sensitivity) { | |||||
| callback(brush->gpencil_settings->curve_sensitivity); | |||||
| } | |||||
| if (brush->gpencil_settings->curve_strength) { | |||||
| callback(brush->gpencil_settings->curve_strength); | |||||
| } | |||||
| if (brush->gpencil_settings->curve_jitter) { | |||||
| callback(brush->gpencil_settings->curve_jitter); | |||||
| } | |||||
| } | |||||
| } | |||||
| LISTBASE_FOREACH (ParticleSettings *, part, &bmain->particles) { | |||||
| if (part->clumpcurve) { | |||||
| callback(part->clumpcurve); | |||||
| } | |||||
| if (part->roughcurve) { | |||||
| callback(part->roughcurve); | |||||
| } | |||||
| if (part->twistcurve) { | |||||
| callback(part->twistcurve); | |||||
| } | |||||
| } | |||||
| /* Object */ | |||||
| LISTBASE_FOREACH (Object *, ob, &bmain->objects) { | |||||
| /* Object modifiers */ | |||||
| LISTBASE_FOREACH (ModifierData *, md, &ob->modifiers) { | |||||
| if (md->type == eModifierType_Hook) { | |||||
| HookModifierData *hmd = (HookModifierData *)md; | |||||
| if (hmd->curfalloff) { | |||||
| callback(hmd->curfalloff); | |||||
| } | |||||
| } | |||||
| else if (md->type == eModifierType_Warp) { | |||||
| WarpModifierData *tmd = (WarpModifierData *)md; | |||||
| if (tmd->curfalloff) { | |||||
| callback(tmd->curfalloff); | |||||
| } | |||||
| } | |||||
| else if (md->type == eModifierType_WeightVGEdit) { | |||||
| WeightVGEditModifierData *wmd = (WeightVGEditModifierData *)md; | |||||
| if (wmd->cmap_curve) { | |||||
| callback(wmd->cmap_curve); | |||||
| } | |||||
| } | |||||
| } | |||||
| /* Grease pencil modifiers */ | |||||
| LISTBASE_FOREACH (ModifierData *, md, &ob->greasepencil_modifiers) { | |||||
| if (md->type == eGpencilModifierType_Thick) { | |||||
| ThickGpencilModifierData *gpmd = (ThickGpencilModifierData *)md; | |||||
| if (gpmd->curve_thickness) { | |||||
| callback(gpmd->curve_thickness); | |||||
| } | |||||
| } | |||||
| else if (md->type == eGpencilModifierType_Hook) { | |||||
| HookGpencilModifierData *gpmd = (HookGpencilModifierData *)md; | |||||
| if (gpmd->curfalloff) { | |||||
| callback(gpmd->curfalloff); | |||||
| } | |||||
| } | |||||
| } | |||||
| } | |||||
| /* Free Style */ | |||||
| LISTBASE_FOREACH (struct FreestyleLineStyle *, linestyle, &bmain->linestyles) { | |||||
| LISTBASE_FOREACH (LineStyleModifier *, m, &linestyle->thickness_modifiers) { | |||||
| switch (m->type) { | |||||
| case LS_MODIFIER_ALONG_STROKE: | |||||
| callback(((LineStyleAlphaModifier_AlongStroke *)m)->curve); | |||||
| break; | |||||
| case LS_MODIFIER_DISTANCE_FROM_CAMERA: | |||||
| callback(((LineStyleAlphaModifier_DistanceFromCamera *)m)->curve); | |||||
| break; | |||||
| case LS_MODIFIER_DISTANCE_FROM_OBJECT: | |||||
| callback(((LineStyleAlphaModifier_DistanceFromObject *)m)->curve); | |||||
| break; | |||||
| case LS_MODIFIER_MATERIAL: | |||||
| callback(((LineStyleAlphaModifier_Material *)m)->curve); | |||||
| break; | |||||
| case LS_MODIFIER_TANGENT: | |||||
| callback(((LineStyleAlphaModifier_Tangent *)m)->curve); | |||||
| break; | |||||
| case LS_MODIFIER_NOISE: | |||||
| callback(((LineStyleAlphaModifier_Noise *)m)->curve); | |||||
| break; | |||||
| case LS_MODIFIER_CREASE_ANGLE: | |||||
| callback(((LineStyleAlphaModifier_CreaseAngle *)m)->curve); | |||||
| break; | |||||
| case LS_MODIFIER_CURVATURE_3D: | |||||
| callback(((LineStyleAlphaModifier_Curvature_3D *)m)->curve); | |||||
| break; | |||||
| } | |||||
| } | |||||
| LISTBASE_FOREACH (LineStyleModifier *, m, &linestyle->thickness_modifiers) { | |||||
| switch (m->type) { | |||||
| case LS_MODIFIER_ALONG_STROKE: | |||||
| callback(((LineStyleThicknessModifier_AlongStroke *)m)->curve); | |||||
| break; | |||||
| case LS_MODIFIER_DISTANCE_FROM_CAMERA: | |||||
| callback(((LineStyleThicknessModifier_DistanceFromCamera *)m)->curve); | |||||
| break; | |||||
| case LS_MODIFIER_DISTANCE_FROM_OBJECT: | |||||
| callback(((LineStyleThicknessModifier_DistanceFromObject *)m)->curve); | |||||
| break; | |||||
| case LS_MODIFIER_MATERIAL: | |||||
| callback(((LineStyleThicknessModifier_Material *)m)->curve); | |||||
| break; | |||||
| case LS_MODIFIER_TANGENT: | |||||
| callback(((LineStyleThicknessModifier_Tangent *)m)->curve); | |||||
| break; | |||||
| case LS_MODIFIER_CREASE_ANGLE: | |||||
| callback(((LineStyleThicknessModifier_CreaseAngle *)m)->curve); | |||||
| break; | |||||
| case LS_MODIFIER_CURVATURE_3D: | |||||
| callback(((LineStyleThicknessModifier_Curvature_3D *)m)->curve); | |||||
| break; | |||||
| } | |||||
| } | |||||
| } | |||||
| } | |||||
| void do_versions_after_linking_280(Main *bmain, ReportList *UNUSED(reports)) | void do_versions_after_linking_280(Main *bmain, ReportList *UNUSED(reports)) | ||||
| { | { | ||||
| bool use_collection_compat_28 = true; | bool use_collection_compat_28 = true; | ||||
| if (!MAIN_VERSION_ATLEAST(bmain, 280, 0)) { | if (!MAIN_VERSION_ATLEAST(bmain, 280, 0)) { | ||||
| use_collection_compat_28 = false; | use_collection_compat_28 = false; | ||||
| /* Convert group layer visibility flags to hidden nested collection. */ | /* Convert group layer visibility flags to hidden nested collection. */ | ||||
| Show All 33 Lines | for (Collection *collection = bmain->collections.first; collection; | ||||
| } | } | ||||
| BKE_collection_object_add(bmain, *collection_hidden, ob); | BKE_collection_object_add(bmain, *collection_hidden, ob); | ||||
| BKE_collection_object_remove(bmain, collection, ob, true); | BKE_collection_object_remove(bmain, collection, ob, true); | ||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| /* We need to assign lib pointer to generated hidden collections *after* all have been created, | /* We need to assign lib pointer to generated hidden collections *after* all have been | ||||
| * otherwise we'll end up with several data-blocks sharing same name/library, | * created, otherwise we'll end up with several data-blocks sharing same name/library, | ||||
| * which is FORBIDDEN! | * which is FORBIDDEN! Note: we need this to be recursive, since a child collection may be | ||||
| * Note: we need this to be recursive, | * sorted before its parent in bmain. */ | ||||
| * since a child collection may be sorted before its parent in bmain. */ | |||||
| for (Collection *collection = bmain->collections.first; collection != NULL; | for (Collection *collection = bmain->collections.first; collection != NULL; | ||||
| collection = collection->id.next) { | collection = collection->id.next) { | ||||
| do_version_collection_propagate_lib_to_children(collection); | do_version_collection_propagate_lib_to_children(collection); | ||||
| } | } | ||||
| /* Convert layers to collections. */ | /* Convert layers to collections. */ | ||||
| for (Scene *scene = bmain->scenes.first; scene; scene = scene->id.next) { | for (Scene *scene = bmain->scenes.first; scene; scene = scene->id.next) { | ||||
| do_version_layers_to_collections(bmain, scene); | do_version_layers_to_collections(bmain, scene); | ||||
| ▲ Show 20 Lines • Show All 287 Lines • ▼ Show 20 Lines | for (Brush *brush = bmain->brushes.first; brush; brush = brush->id.next) { | ||||
| if (brush->gpencil_settings != NULL) { | if (brush->gpencil_settings != NULL) { | ||||
| brush->gpencil_tool = brush->gpencil_settings->brush_type; | brush->gpencil_tool = brush->gpencil_settings->brush_type; | ||||
| } | } | ||||
| } | } | ||||
| BKE_paint_toolslots_init_from_main(bmain); | BKE_paint_toolslots_init_from_main(bmain); | ||||
| } | } | ||||
| if (!MAIN_VERSION_ATLEAST(bmain, 280, 38)) { | if (!MAIN_VERSION_ATLEAST(bmain, 280, 38)) { | ||||
| /* Ensure we get valid rigidbody object/constraint data in relevant collections' objects. */ | /* Ensure we get valid rigidbody object/constraint data in relevant collections' objects. | ||||
| */ | |||||
| for (Scene *scene = bmain->scenes.first; scene; scene = scene->id.next) { | for (Scene *scene = bmain->scenes.first; scene; scene = scene->id.next) { | ||||
| RigidBodyWorld *rbw = scene->rigidbody_world; | RigidBodyWorld *rbw = scene->rigidbody_world; | ||||
| if (rbw == NULL) { | if (rbw == NULL) { | ||||
| continue; | continue; | ||||
| } | } | ||||
| BKE_rigidbody_objects_collection_validate(scene, rbw); | BKE_rigidbody_objects_collection_validate(scene, rbw); | ||||
| ▲ Show 20 Lines • Show All 196 Lines • ▼ Show 20 Lines | FOREACH_NODETREE_BEGIN (bmain, ntree, id) { | ||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| FOREACH_NODETREE_END; | FOREACH_NODETREE_END; | ||||
| if (error & NTREE_DOVERSION_NEED_OUTPUT) { | if (error & NTREE_DOVERSION_NEED_OUTPUT) { | ||||
| BKE_report(fd->reports, RPT_ERROR, "Eevee material conversion problem. Error in console"); | BKE_report(fd->reports, RPT_ERROR, "Eevee material conversion problem. Error in console"); | ||||
| printf( | printf( | ||||
| "You need to connect Principled and Eevee Specular shader nodes to new material output " | "You need to connect Principled and Eevee Specular shader nodes to new material " | ||||
| "output " | |||||
| "nodes.\n"); | "nodes.\n"); | ||||
| } | } | ||||
| if (error & NTREE_DOVERSION_TRANSPARENCY_EMISSION) { | if (error & NTREE_DOVERSION_TRANSPARENCY_EMISSION) { | ||||
| BKE_report(fd->reports, RPT_ERROR, "Eevee material conversion problem. Error in console"); | BKE_report(fd->reports, RPT_ERROR, "Eevee material conversion problem. Error in console"); | ||||
| printf( | printf( | ||||
| "You need to combine transparency and emission shaders to the converted Principled " | "You need to combine transparency and emission shaders to the converted Principled " | ||||
| "shader nodes.\n"); | "shader nodes.\n"); | ||||
| ▲ Show 20 Lines • Show All 2,483 Lines • ▼ Show 20 Lines | for (bScreen *screen = bmain->screens.first; screen; screen = screen->id.next) { | ||||
| ar_tools->alignment = RGN_ALIGN_LEFT; | ar_tools->alignment = RGN_ALIGN_LEFT; | ||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| { | if (!MAIN_VERSION_ATLEAST(bmain, 282, 2)) { | ||||
| /* Versioning code until next subversion bump goes here. */ | do_version_curvemapping_walker(bmain, do_version_curvemapping_flag_extend_extrapolate); | ||||
| for (bScreen *screen = bmain->screens.first; screen; screen = screen->id.next) { | for (bScreen *screen = bmain->screens.first; screen; screen = screen->id.next) { | ||||
| for (ScrArea *sa = screen->areabase.first; sa; sa = sa->next) { | for (ScrArea *sa = screen->areabase.first; sa; sa = sa->next) { | ||||
| sa->flag &= ~AREA_FLAG_UNUSED_6; | sa->flag &= ~AREA_FLAG_UNUSED_6; | ||||
| } | } | ||||
| } | } | ||||
| /* Add custom curve profile to toolsettings for bevel tool */ | /* Add custom curve profile to toolsettings for bevel tool */ | ||||
| if (!DNA_struct_elem_find(fd->filesdna, "ToolSettings", "CurveProfile", "custom_profile")) { | if (!DNA_struct_elem_find(fd->filesdna, "ToolSettings", "CurveProfile", "custom_profile")) { | ||||
| Show All 39 Lines | for (Object *ob = bmain->objects.first; ob; ob = ob->id.next) { | ||||
| if (md->type == eModifierType_Cloth) { | if (md->type == eModifierType_Cloth) { | ||||
| ClothModifierData *clmd = (ClothModifierData *)md; | ClothModifierData *clmd = (ClothModifierData *)md; | ||||
| clmd->sim_parms->pressure_factor = 1; | clmd->sim_parms->pressure_factor = 1; | ||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| { | |||||
| /* Versioning code until next subversion bump goes here. */ | |||||
| } | |||||
| } | } | ||||