Changeset View
Changeset View
Standalone View
Standalone View
source/blender/blenloader/intern/versioning_270.c
| Show All 28 Lines | |||||
| #include "BLI_compiler_attrs.h" | #include "BLI_compiler_attrs.h" | ||||
| /* for MinGW32 definition of NULL, could use BLI_blenlib.h instead too */ | /* for MinGW32 definition of NULL, could use BLI_blenlib.h instead too */ | ||||
| #include <stddef.h> | #include <stddef.h> | ||||
| /* allow readfile to use deprecated functionality */ | /* allow readfile to use deprecated functionality */ | ||||
| #define DNA_DEPRECATED_ALLOW | #define DNA_DEPRECATED_ALLOW | ||||
| #include "DNA_anim_types.h" | |||||
| #include "DNA_armature_types.h" | #include "DNA_armature_types.h" | ||||
| #include "DNA_brush_types.h" | #include "DNA_brush_types.h" | ||||
| #include "DNA_camera_types.h" | #include "DNA_camera_types.h" | ||||
| #include "DNA_cloth_types.h" | #include "DNA_cloth_types.h" | ||||
| #include "DNA_constraint_types.h" | #include "DNA_constraint_types.h" | ||||
| #include "DNA_gpencil_types.h" | #include "DNA_gpencil_types.h" | ||||
| #include "DNA_sdna_types.h" | #include "DNA_sdna_types.h" | ||||
| #include "DNA_sequence_types.h" | #include "DNA_sequence_types.h" | ||||
| #include "DNA_space_types.h" | #include "DNA_space_types.h" | ||||
| #include "DNA_screen_types.h" | #include "DNA_screen_types.h" | ||||
| #include "DNA_object_force.h" | #include "DNA_object_force.h" | ||||
| #include "DNA_object_types.h" | #include "DNA_object_types.h" | ||||
| #include "DNA_mask_types.h" | #include "DNA_mask_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_linestyle_types.h" | #include "DNA_linestyle_types.h" | ||||
| #include "DNA_actuator_types.h" | #include "DNA_actuator_types.h" | ||||
| #include "DNA_view3d_types.h" | #include "DNA_view3d_types.h" | ||||
| #include "DNA_smoke_types.h" | #include "DNA_smoke_types.h" | ||||
| #include "DNA_rigidbody_types.h" | #include "DNA_rigidbody_types.h" | ||||
| #include "DNA_genfile.h" | #include "DNA_genfile.h" | ||||
| #include "BKE_animsys.h" | |||||
| #include "BKE_colortools.h" | #include "BKE_colortools.h" | ||||
| #include "BKE_library.h" | #include "BKE_library.h" | ||||
| #include "BKE_main.h" | #include "BKE_main.h" | ||||
| #include "BKE_mask.h" | #include "BKE_mask.h" | ||||
| #include "BKE_modifier.h" | #include "BKE_modifier.h" | ||||
| #include "BKE_node.h" | #include "BKE_node.h" | ||||
| #include "BKE_scene.h" | #include "BKE_scene.h" | ||||
| #include "BKE_sequencer.h" | #include "BKE_sequencer.h" | ||||
| #include "BKE_screen.h" | #include "BKE_screen.h" | ||||
| #include "BKE_tracking.h" | #include "BKE_tracking.h" | ||||
| #include "BKE_gpencil.h" | #include "BKE_gpencil.h" | ||||
| #include "BLI_math.h" | #include "BLI_math.h" | ||||
| #include "BLI_listbase.h" | #include "BLI_listbase.h" | ||||
| #include "BLI_string.h" | #include "BLI_string.h" | ||||
| #include "BLO_readfile.h" | #include "BLO_readfile.h" | ||||
| #include "NOD_common.h" | |||||
| #include "NOD_socket.h" | |||||
| #include "readfile.h" | #include "readfile.h" | ||||
| #include "MEM_guardedalloc.h" | #include "MEM_guardedalloc.h" | ||||
| /** | /** | ||||
| * Setup rotation stabilization from ancient single track spec. | * Setup rotation stabilization from ancient single track spec. | ||||
| * Former Version of 2D stabilization used a single tracking marker to determine the rotation | * Former Version of 2D stabilization used a single tracking marker to determine the rotation | ||||
| * to be compensated. Now several tracks can contribute to rotation detection and this feature | * to be compensated. Now several tracks can contribute to rotation detection and this feature | ||||
| ▲ Show 20 Lines • Show All 103 Lines • ▼ Show 20 Lines | static void do_version_bones_super_bbone(ListBase *lb) | ||||
| for (Bone *bone = lb->first; bone; bone = bone->next) { | for (Bone *bone = lb->first; bone; bone = bone->next) { | ||||
| bone->scaleIn = 1.0f; | bone->scaleIn = 1.0f; | ||||
| bone->scaleOut = 1.0f; | bone->scaleOut = 1.0f; | ||||
| do_version_bones_super_bbone(&bone->childbase); | do_version_bones_super_bbone(&bone->childbase); | ||||
| } | } | ||||
| } | } | ||||
| /* TODO(sergey): Consider making it somewhat more generic function in BLI_anim.h. */ | |||||
mont29: Agree - but we can do that outside of this patch as well. | |||||
| static void anim_change_prop_name(FCurve *fcu, | |||||
| const char *prefix, | |||||
| const char *old_prop_name, | |||||
| const char *new_prop_name) | |||||
| { | |||||
| const char *old_path = BLI_sprintfN("%s.%s", prefix, old_prop_name); | |||||
| if (STREQ(fcu->rna_path, old_path)) { | |||||
| MEM_freeN(fcu->rna_path); | |||||
| fcu->rna_path = BLI_sprintfN("%s.%s", prefix, new_prop_name); | |||||
| } | |||||
| MEM_freeN((char *)old_path); | |||||
| } | |||||
| static void do_version_hue_sat_node(bNodeTree *ntree, bNode *node) | |||||
| { | |||||
| /* Make sure new sockets are properly created. */ | |||||
| node_verify_socket_templates(ntree, node); | |||||
| /* Convert value from old storage to new sockets. */ | |||||
| NodeHueSat *nhs = node->storage; | |||||
| bNodeSocket *hue = nodeFindSocket(node, SOCK_IN, "Hue"), | |||||
| *saturation = nodeFindSocket(node, SOCK_IN, "Saturation"), | |||||
| *value = nodeFindSocket(node, SOCK_IN, "Value"); | |||||
| ((bNodeSocketValueFloat *)hue->default_value)->value = nhs->hue; | |||||
| ((bNodeSocketValueFloat *)saturation->default_value)->value = nhs->sat; | |||||
| ((bNodeSocketValueFloat *)value->default_value)->value = nhs->val; | |||||
| /* Take care of possible animation. */ | |||||
| AnimData *adt = BKE_animdata_from_id(&ntree->id); | |||||
| if (adt != NULL && adt->action != NULL) { | |||||
Not Done Inline Actionsto be removed now mont29: to be removed now | |||||
| const char *prefix = BLI_sprintfN("nodes[\"%s\"]", node->name); | |||||
| for (FCurve *fcu = adt->action->curves.first; fcu != NULL; fcu = fcu->next) { | |||||
| if (STRPREFIX(fcu->rna_path, prefix)) { | |||||
| anim_change_prop_name(fcu, prefix, "color_hue", "inputs[1].default_value"); | |||||
| anim_change_prop_name(fcu, prefix, "color_saturation", "inputs[2].default_value"); | |||||
| anim_change_prop_name(fcu, prefix, "color_value", "inputs[3].default_value"); | |||||
| } | |||||
| } | |||||
| MEM_freeN((char *)prefix); | |||||
| } | |||||
| /* Free storage, it is no longer used. */ | |||||
| MEM_freeN(node->storage); | |||||
| node->storage = NULL; | |||||
| } | |||||
| void blo_do_versions_270(FileData *fd, Library *UNUSED(lib), Main *main) | void blo_do_versions_270(FileData *fd, Library *UNUSED(lib), Main *main) | ||||
| { | { | ||||
| if (!MAIN_VERSION_ATLEAST(main, 270, 0)) { | if (!MAIN_VERSION_ATLEAST(main, 270, 0)) { | ||||
| if (!DNA_struct_elem_find(fd->filesdna, "BevelModifierData", "float", "profile")) { | if (!DNA_struct_elem_find(fd->filesdna, "BevelModifierData", "float", "profile")) { | ||||
| Object *ob; | Object *ob; | ||||
| for (ob = main->object.first; ob; ob = ob->id.next) { | for (ob = main->object.first; ob; ob = ob->id.next) { | ||||
| ▲ Show 20 Lines • Show All 1,310 Lines • ▼ Show 20 Lines | for (Mask *mask = main->mask.first; mask; mask = mask->id.next) { | ||||
| for (MaskSplinePoint *mspoint = mspline->points; i < mspline->tot_point; mspoint++, i++) { | for (MaskSplinePoint *mspoint = mspline->points; i < mspline->tot_point; mspoint++, i++) { | ||||
| if (mspoint->parent.id_type == 0) { | if (mspoint->parent.id_type == 0) { | ||||
| BKE_mask_parent_init(&mspoint->parent); | BKE_mask_parent_init(&mspoint->parent); | ||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| } | |||||
| } | |||||
| void do_versions_after_linking_270(Main *main) | |||||
| { | |||||
| /* To be added to next subversion bump! */ | |||||
| { | |||||
| FOREACH_NODETREE(main, ntree, id) { | |||||
| if (ntree->type == NTREE_COMPOSIT) { | |||||
| ntreeSetTypes(NULL, ntree); | |||||
| for (bNode *node = ntree->nodes.first; node; node = node->next) { | |||||
| if (node->type == CMP_NODE_HUE_SAT) { | |||||
| do_version_hue_sat_node(ntree, node); | |||||
| } | |||||
| } | |||||
| } | |||||
| } FOREACH_NODETREE_END | |||||
| } | } | ||||
| } | } | ||||
Agree - but we can do that outside of this patch as well.