From b56715de034b38d630387cd6218ebfbdf766f36c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sybren=20A=2E=20St=C3=BCvel?= Date: Tue, 1 Oct 2024 15:32:57 +0200 Subject: [PATCH] Anim: Fix bug updating F-Curves for new Curve (object) points When modifying a Curve object's points, its animation data is updated to ensure that changes in point index are reflected in the F-Curve data paths. This already worked fine for pre-existing Curve points, but didn't happen correctly for points that were newly added since entering edit mode. --- source/blender/editors/curve/editcurve.cc | 26 +++++++++++++++++++++-- 1 file changed, 24 insertions(+), 2 deletions(-) diff --git a/source/blender/editors/curve/editcurve.cc b/source/blender/editors/curve/editcurve.cc index 8aa6f4c38c0..40da834eb2a 100644 --- a/source/blender/editors/curve/editcurve.cc +++ b/source/blender/editors/curve/editcurve.cc @@ -963,9 +963,10 @@ static void fcurve_path_rename(const char *orig_rna_path, pt_index = 0; while (a--) { + SNPRINTF(rna_path, "splines[%d].bezier_points[%d]", nu_index, pt_index); + keyIndex = getCVKeyIndex(editnurb, bezt); if (keyIndex) { - SNPRINTF(rna_path, "splines[%d].bezier_points[%d]", nu_index, pt_index); SNPRINTF(orig_rna_path, "splines[%d].bezier_points[%d]", keyIndex->nu_index, @@ -987,6 +988,16 @@ static void fcurve_path_rename(const char *orig_rna_path, keyIndex->nu_index = nu_index; keyIndex->pt_index = pt_index; } + else { + /* In this case, the bezier point exists. It just hasn't been indexed yet (which seems to + * happen on entering edit mode, so points added after that may not have such an index + * yet) */ + + /* This is a no-op when it comes to the manipulation of F-Curves. It does find the + * relevant F-Curves to place them in `processed_fcurves`, which will prevent them from + * being deleted later on. */ + fcurve_path_rename(rna_path, rna_path, orig_curves, processed_fcurves); + } bezt++; pt_index++; @@ -998,9 +1009,10 @@ static void fcurve_path_rename(const char *orig_rna_path, pt_index = 0; while (a--) { + SNPRINTF(rna_path, "splines[%d].points[%d]", nu_index, pt_index); + keyIndex = getCVKeyIndex(editnurb, bp); if (keyIndex) { - SNPRINTF(rna_path, "splines[%d].points[%d]", nu_index, pt_index); SNPRINTF( orig_rna_path, "splines[%d].points[%d]", keyIndex->nu_index, keyIndex->pt_index); fcurve_path_rename(orig_rna_path, rna_path, orig_curves, processed_fcurves); @@ -1008,6 +1020,16 @@ static void fcurve_path_rename(const char *orig_rna_path, keyIndex->nu_index = nu_index; keyIndex->pt_index = pt_index; } + else { + /* In this case, the bezier point exists. It just hasn't been indexed yet (which seems to + * happen on entering edit mode, so points added after that may not have such an index + * yet) */ + + /* This is a no-op when it comes to the manipulation of F-Curves. It does find the + * relevant F-Curves to place them in `processed_fcurves`, which will prevent them from + * being deleted later on. */ + fcurve_path_rename(rna_path, rna_path, orig_curves, processed_fcurves); + } bp++; pt_index++;