[Bf-blender-cvs] [c3accabef90] blender-v2.83-release: Fix invalid rigid body constraint values during 2.83 development

Campbell Barton noreply at git.blender.org
Thu Apr 23 03:52:30 CEST 2020


Commit: c3accabef9097c2657e9407c2ef9c9d994c008c3
Author: Campbell Barton
Date:   Thu Apr 23 11:46:52 2020 +1000
Branches: blender-v2.83-release
https://developer.blender.org/rBc3accabef9097c2657e9407c2ef9c9d994c008c3

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.

===================================================================

M	source/blender/blenkernel/BKE_blender_version.h
M	source/blender/blenloader/intern/versioning_280.c
M	source/blender/makesdna/DNA_rigidbody_types.h

===================================================================

diff --git a/source/blender/blenkernel/BKE_blender_version.h b/source/blender/blenkernel/BKE_blender_version.h
index c9a4d81604b..cc029a3cbf9 100644
--- a/source/blender/blenkernel/BKE_blender_version.h
+++ b/source/blender/blenkernel/BKE_blender_version.h
@@ -27,7 +27,7 @@
  * \note Use #STRINGIFY() rather than defining with quotes.
  */
 #define BLENDER_VERSION 283
-#define BLENDER_SUBVERSION 13
+#define BLENDER_SUBVERSION 14
 /** Several breakages with 280, e.g. collections vs layers. */
 #define BLENDER_MINVERSION 280
 #define BLENDER_MINSUBVERSION 0
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. */
   }
 }
diff --git a/source/blender/makesdna/DNA_rigidbody_types.h b/source/blender/makesdna/DNA_rigidbody_types.h
index 5c514ef04e1..7ae97187c25 100644
--- a/source/blender/makesdna/DNA_rigidbody_types.h
+++ b/source/blender/makesdna/DNA_rigidbody_types.h
@@ -306,28 +306,28 @@ typedef enum eRigidBodyCon_Type {
   /** lets bodies rotate around a specified point */
   RBC_TYPE_POINT = 0,
   /** lets bodies rotate around a specified axis */
-  RBC_TYPE_HINGE,
+  RBC_TYPE_HINGE = 1,
   /** simulates wheel suspension */
-  /* RBC_TYPE_HINGE2, */ /* UNUSED */
+  /* RBC_TYPE_HINGE2 = 2, */ /* UNUSED */
   /** restricts movent to a specified axis */
-  RBC_TYPE_SLIDER,
+  RBC_TYPE_SLIDER = 3,
   /** lets object rotate within a specified cone */
-  /* RBC_TYPE_CONE_TWIST, */ /* UNUSED */
+  /* RBC_TYPE_CONE_TWIST = 4, */ /* UNUSED */
   /** allows user to specify constraint axes */
-  RBC_TYPE_6DOF,
+  RBC_TYPE_6DOF = 5,
   /** like 6DOF but has springs */
-  RBC_TYPE_6DOF_SPRING,
+  RBC_TYPE_6DOF_SPRING = 6,
   /** simulates a universal joint */
-  /* RBC_TYPE_UNIVERSAL, */ /* UNUSED */
+  /* RBC_TYPE_UNIVERSAL = 7, */ /* UNUSED */
   /** glues two bodies together */
-  RBC_TYPE_FIXED,
+  RBC_TYPE_FIXED = 8,
   /** similar to slider but also allows rotation around slider axis */
-  RBC_TYPE_PISTON,
+  RBC_TYPE_PISTON = 9,
   /** Simplified spring constraint with only once axis that's
    * automatically placed between the connected bodies */
-  /* RBC_TYPE_SPRING, */ /* UNUSED */
+  /* RBC_TYPE_SPRING = 10, */ /* UNUSED */
   /** dirves bodies by applying linear and angular forces */
-  RBC_TYPE_MOTOR,
+  RBC_TYPE_MOTOR = 11,
 } eRigidBodyCon_Type;
 
 /* Spring implementation type for RigidBodyOb */



More information about the Bf-blender-cvs mailing list