From c3accabef9097c2657e9407c2ef9c9d994c008c3 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Thu, 23 Apr 2020 11:46:52 +1000 Subject: Fix invalid rigid body constraint values during 2.83 development Own error in cleanup from 5dcb6fb22f3f unintentionally changed enum values. Although this code violated our own rules to use explicit values to avoid this happening. --- source/blender/blenloader/intern/versioning_280.c | 52 +++++++++++++++++------ 1 file changed, 39 insertions(+), 13 deletions(-) (limited to 'source/blender/blenloader/intern/versioning_280.c') diff --git a/source/blender/blenloader/intern/versioning_280.c b/source/blender/blenloader/intern/versioning_280.c index b90413aa5ca..329767ef202 100644 --- a/source/blender/blenloader/intern/versioning_280.c +++ b/source/blender/blenloader/intern/versioning_280.c @@ -4998,19 +4998,7 @@ void blo_do_versions_280(FileData *fd, Library *UNUSED(lib), Main *bmain) } } - /** - * Versioning code until next subversion bump goes here. - * - * \note Be sure to check when bumping the version: - * - #do_versions_after_linking_280 in this file. - * - "versioning_userdef.c", #BLO_version_defaults_userpref_blend - * - "versioning_userdef.c", #do_versions_theme - * - * \note Keep this message at the bottom of the function. - */ - { - /* Keep this block, even when empty. */ - + if (!MAIN_VERSION_ATLEAST(bmain, 283, 14)) { /* Solidify modifier merge tolerance. */ if (!DNA_struct_elem_find(fd->filesdna, "SolidifyModifierData", "float", "merge_tolerance")) { for (Object *ob = bmain->objects.first; ob; ob = ob->id.next) { @@ -5023,5 +5011,43 @@ void blo_do_versions_280(FileData *fd, Library *UNUSED(lib), Main *bmain) } } } + + /* Enumerator was incorrect for a time in 2.83 development. + * Note that this only corrects values known to be invalid. */ + for (Object *ob = bmain->objects.first; ob; ob = ob->id.next) { + RigidBodyCon *rbc = ob->rigidbody_constraint; + if (rbc != NULL) { + enum { + INVALID_RBC_TYPE_SLIDER = 2, + INVALID_RBC_TYPE_6DOF_SPRING = 4, + INVALID_RBC_TYPE_MOTOR = 7, + }; + switch (rbc->type) { + case INVALID_RBC_TYPE_SLIDER: + rbc->type = RBC_TYPE_SLIDER; + break; + case INVALID_RBC_TYPE_6DOF_SPRING: + rbc->type = RBC_TYPE_6DOF_SPRING; + break; + case INVALID_RBC_TYPE_MOTOR: + rbc->type = RBC_TYPE_MOTOR; + break; + } + } + } + } + + /** + * Versioning code until next subversion bump goes here. + * + * \note Be sure to check when bumping the version: + * - #do_versions_after_linking_280 in this file. + * - "versioning_userdef.c", #BLO_version_defaults_userpref_blend + * - "versioning_userdef.c", #do_versions_theme + * + * \note Keep this message at the bottom of the function. + */ + { + /* Keep this block, even when empty. */ } } -- cgit v1.2.3