[Bf-blender-cvs] [6a0906c09a2] blender-v2.93-release: Fix T87854: Add clamp option to Path Animation

Sebastian Parborg noreply at git.blender.org
Thu May 20 20:44:49 CEST 2021


Commit: 6a0906c09a263f5fb17449407f5988c4bda53436
Author: Sebastian Parborg
Date:   Thu May 20 20:41:10 2021 +0200
Branches: blender-v2.93-release
https://developer.blender.org/rB6a0906c09a263f5fb17449407f5988c4bda53436

Fix T87854: Add clamp option to Path Animation

Previously, the "follow path constraint" and "follow parented curve"
were clamped.  This restriction was lifted in rBcf2baa585cc8

Add back an option to get the old behavior in the "Path animation" settings.

Reviewed By: Sybren

Differential Revision: http://developer.blender.org/D11263

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

M	release/scripts/startup/bl_ui/properties_data_curve.py
M	source/blender/blenkernel/intern/constraint.c
M	source/blender/blenkernel/intern/object.c
M	source/blender/blenloader/intern/versioning_290.c
M	source/blender/makesdna/DNA_curve_types.h
M	source/blender/makesrna/intern/rna_curve.c

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

diff --git a/release/scripts/startup/bl_ui/properties_data_curve.py b/release/scripts/startup/bl_ui/properties_data_curve.py
index 4bd2d66e257..85f672cd50f 100644
--- a/release/scripts/startup/bl_ui/properties_data_curve.py
+++ b/release/scripts/startup/bl_ui/properties_data_curve.py
@@ -267,6 +267,7 @@ class DATA_PT_pathanim(CurveButtonsPanelCurve, Panel):
         # these are for paths only
         col.separator()
 
+        col.prop(curve, "use_path_clamp")
         col.prop(curve, "use_path_follow")
 
 
diff --git a/source/blender/blenkernel/intern/constraint.c b/source/blender/blenkernel/intern/constraint.c
index 2ee030ca83f..bcd2c75be0d 100644
--- a/source/blender/blenkernel/intern/constraint.c
+++ b/source/blender/blenkernel/intern/constraint.c
@@ -1473,8 +1473,12 @@ static void followpath_get_tarmat(struct Depsgraph *UNUSED(depsgraph),
          * that's animated, but this will only work if it actually is animated...
          *
          * we divide the curvetime calculated in the previous step by the length of the path,
-         * to get a time factor, which then gets clamped to lie within 0.0 - 1.0 range. */
+         * to get a time factor. */
         curvetime /= cu->pathlen;
+
+        if (cu->flag & CU_PATH_CLAMP) {
+          CLAMP(curvetime, 0.0f, 1.0f);
+        }
       }
       else {
         /* fixed position along curve */
diff --git a/source/blender/blenkernel/intern/object.c b/source/blender/blenkernel/intern/object.c
index 825f660fa3a..34c77cd9155 100644
--- a/source/blender/blenkernel/intern/object.c
+++ b/source/blender/blenkernel/intern/object.c
@@ -3288,6 +3288,10 @@ static bool ob_parcurve(Object *ob, Object *par, float r_mat[4][4])
     ctime = cu->ctime;
   }
 
+  if (cu->flag & CU_PATH_CLAMP) {
+    CLAMP(ctime, 0.0f, 1.0f);
+  }
+
   unit_m4(r_mat);
 
   /* vec: 4 items! */
diff --git a/source/blender/blenloader/intern/versioning_290.c b/source/blender/blenloader/intern/versioning_290.c
index 97fe9fb04c4..565e62158ff 100644
--- a/source/blender/blenloader/intern/versioning_290.c
+++ b/source/blender/blenloader/intern/versioning_290.c
@@ -2080,6 +2080,11 @@ void blo_do_versions_290(FileData *fd, Library *UNUSED(lib), Main *bmain)
         }
       }
     }
+
+    LISTBASE_FOREACH (Curve *, cu, &bmain->curves) {
+      /* Turn on clamping as this was implicit before. */
+      cu->flag |= CU_PATH_CLAMP;
+    }
   }
 
   /**
diff --git a/source/blender/makesdna/DNA_curve_types.h b/source/blender/makesdna/DNA_curve_types.h
index 517c5c6c5f1..716c480bab8 100644
--- a/source/blender/makesdna/DNA_curve_types.h
+++ b/source/blender/makesdna/DNA_curve_types.h
@@ -328,7 +328,7 @@ enum {
   CU_BACK = 1 << 2,
   CU_PATH = 1 << 3,
   CU_FOLLOW = 1 << 4,
-  /* CU_UV_ORCO = 1 << 5, */ /* DEPRECATED */
+  CU_PATH_CLAMP = 1 << 5,
   CU_DEFORM_BOUNDS_OFF = 1 << 6,
   CU_STRETCH = 1 << 7,
   /* CU_OFFS_PATHDIST   = 1 << 8, */  /* DEPRECATED */
diff --git a/source/blender/makesrna/intern/rna_curve.c b/source/blender/makesrna/intern/rna_curve.c
index e670b17b79a..abc96ddc820 100644
--- a/source/blender/makesrna/intern/rna_curve.c
+++ b/source/blender/makesrna/intern/rna_curve.c
@@ -1030,6 +1030,14 @@ static void rna_def_path(BlenderRNA *UNUSED(brna), StructRNA *srna)
   RNA_def_property_ui_text(prop, "Follow", "Make curve path children to rotate along the path");
   RNA_def_property_update(prop, 0, "rna_Curve_update_data");
 
+  prop = RNA_def_property(srna, "use_path_clamp", PROP_BOOLEAN, PROP_NONE);
+  RNA_def_property_boolean_sdna(prop, NULL, "flag", CU_PATH_CLAMP);
+  RNA_def_property_ui_text(
+      prop,
+      "Clamp",
+      "Clamp the curve path children so they can't travel past the start/end point of the curve");
+  RNA_def_property_update(prop, 0, "rna_Curve_update_data");
+
   prop = RNA_def_property(srna, "use_stretch", PROP_BOOLEAN, PROP_NONE);
   RNA_def_property_boolean_sdna(prop, NULL, "flag", CU_STRETCH);
   RNA_def_property_ui_text(prop,



More information about the Bf-blender-cvs mailing list