[Bf-blender-cvs] [dc873c4a7be] master: Fix T86975: GPencil interpolate sequence error when strokes are not selected

Antonio Vazquez noreply at git.blender.org
Sat Mar 27 12:51:26 CET 2021


Commit: dc873c4a7be494a6a3d8b4481ca6a1c096d361cd
Author: Antonio Vazquez
Date:   Sat Mar 27 12:51:18 2021 +0100
Branches: master
https://developer.blender.org/rBdc873c4a7be494a6a3d8b4481ca6a1c096d361cd

Fix T86975: GPencil interpolate sequence error when strokes are not selected

If the selection order is not used, need to put the strokes in inverse order because the Hash Iter returns the strokes in inverse order.

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

M	source/blender/editors/gpencil/gpencil_interpolate.c

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

diff --git a/source/blender/editors/gpencil/gpencil_interpolate.c b/source/blender/editors/gpencil/gpencil_interpolate.c
index bfa1ee6bcaf..1e5352b23db 100644
--- a/source/blender/editors/gpencil/gpencil_interpolate.c
+++ b/source/blender/editors/gpencil/gpencil_interpolate.c
@@ -1270,6 +1270,7 @@ static int gpencil_interpolate_seq_exec(bContext *C, wmOperator *op)
   }
 
   /* loop all layer to check if need interpolation */
+  bool use_select_order = false;
   LISTBASE_FOREACH (bGPDlayer *, gpl, &gpd->layers) {
     /* all layers or only active */
     if ((!all_layers) && (gpl != active_gpl)) {
@@ -1294,7 +1295,6 @@ static int gpencil_interpolate_seq_exec(bContext *C, wmOperator *op)
     /* Create a table with source and target pair of strokes. */
     GHash *used_strokes = BLI_ghash_ptr_new(__func__);
     GHash *pair_strokes = BLI_ghash_ptr_new(__func__);
-
     LISTBASE_FOREACH (bGPDstroke *, gps_from, &prevFrame->strokes) {
       bGPDstroke *gps_to = NULL;
       /* Only selected. */
@@ -1313,6 +1313,7 @@ static int gpencil_interpolate_seq_exec(bContext *C, wmOperator *op)
       /* Try to get the related stroke. */
       if ((is_multiedit) && (gps_from->select_index > 0)) {
         gps_to = gpencil_stroke_get_related(used_strokes, nextFrame, gps_from->select_index);
+        use_select_order = true;
       }
       /* If not found, get final stroke to interpolate using position in the array. */
       if (gps_to == NULL) {
@@ -1390,7 +1391,13 @@ static int gpencil_interpolate_seq_exec(bContext *C, wmOperator *op)
         bGPDframe *interFrame = BKE_gpencil_layer_frame_get(gpl, cframe, GP_GETFRAME_ADD_NEW);
         interFrame->key_type = BEZT_KEYTYPE_BREAKDOWN;
 
-        BLI_addtail(&interFrame->strokes, new_stroke);
+        /* If not using the selection order, the iter is inversed. */
+        if (use_select_order) {
+          BLI_addtail(&interFrame->strokes, new_stroke);
+        }
+        else {
+          BLI_addhead(&interFrame->strokes, new_stroke);
+        }
       }
     }



More information about the Bf-blender-cvs mailing list