[Bf-blender-cvs] [cf9289b499a] temp-angavrilov: Dope Sheet: distinguish Constant and Linear from other interpolation modes.

Alexander Gavrilov noreply at git.blender.org
Fri Sep 30 12:23:35 CEST 2022


Commit: cf9289b499a9bcb5d4a00e8190db9c77ae8788f0
Author: Alexander Gavrilov
Date:   Sat Feb 5 14:11:29 2022 +0300
Branches: temp-angavrilov
https://developer.blender.org/rBcf9289b499a9bcb5d4a00e8190db9c77ae8788f0

Dope Sheet: distinguish Constant and Linear from other interpolation modes.

There is an option to display handles and interpolation modes in
the dope sheet, but the only interpolation mode it distinguishes
is Bezier. This adds distinct display for Constant and Linear:

- Constant is drawn as a thicker line.
- Linear is drawn the same as now.
- Other non-Bezier modes are drawn as a double line.

Constant, Linear and Bezier are the most common modes, so it makes
sense to distinguish them from all others.

Differential Revision: https://developer.blender.org/D15855

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

M	source/blender/editors/animation/keyframes_draw.c
M	source/blender/editors/animation/keyframes_keylist.cc
M	source/blender/editors/include/ED_keyframes_keylist.h

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

diff --git a/source/blender/editors/animation/keyframes_draw.c b/source/blender/editors/animation/keyframes_draw.c
index 6df9dc1e86d..673e68b2e95 100644
--- a/source/blender/editors/animation/keyframes_draw.c
+++ b/source/blender/editors/animation/keyframes_draw.c
@@ -287,14 +287,30 @@ static void draw_keylist_block_interpolation_line(const DrawKeylistUIData *ctx,
                                                   const ActKeyColumn *ab,
                                                   float ypos)
 {
+  float width = ctx->ipo_size;
+  bool fill = true;
+
+  switch (ab->block.ipo) {
+    case BEZT_IPO_CONST:
+      width *= 1.7f;
+      break;
+
+    case BEZT_IPO_LIN:
+      break;
+
+    default:
+      width *= 2.0f;
+      fill = false;
+  }
+
   UI_draw_roundbox_4fv(
       &(const rctf){
           .xmin = ab->cfra,
           .xmax = ab->next->cfra,
-          .ymin = ypos - ctx->ipo_size,
-          .ymax = ypos + ctx->ipo_size,
+          .ymin = ypos - width,
+          .ymax = ypos + width,
       },
-      true,
+      fill,
       3.0f,
       (ab->block.conflict & ACTKEYBLOCK_FLAG_NON_BEZIER) ? ctx->ipo_color_mix : ctx->ipo_color);
 }
diff --git a/source/blender/editors/animation/keyframes_keylist.cc b/source/blender/editors/animation/keyframes_keylist.cc
index da266dd4253..dac61f54c60 100644
--- a/source/blender/editors/animation/keyframes_keylist.cc
+++ b/source/blender/editors/animation/keyframes_keylist.cc
@@ -749,6 +749,10 @@ static void compute_keyblock_data(ActKeyBlockInfo *info,
   /* Remember non-bezier interpolation info. */
   if (prev->ipo != BEZT_IPO_BEZ) {
     info->flag |= ACTKEYBLOCK_FLAG_NON_BEZIER;
+    info->ipo = prev->ipo;
+  }
+  else {
+    info->ipo = -1;
   }
 
   info->sel = BEZT_ISSEL_ANY(prev) || BEZT_ISSEL_ANY(beztn);
@@ -765,6 +769,13 @@ static void add_keyblock_info(ActKeyColumn *col, const ActKeyBlockInfo *block)
     col->block.conflict |= (col->block.flag ^ block->flag);
     col->block.flag |= block->flag;
     col->block.sel |= block->sel;
+
+    /* Combine interpolations; detect conflicts and use max value. */
+    if (col->block.ipo != block->ipo) {
+      col->block.conflict |= ACTKEYBLOCK_FLAG_NON_BEZIER;
+    }
+
+    col->block.ipo = MAX2(col->block.ipo, block->ipo);
   }
 
   if (block->flag) {
diff --git a/source/blender/editors/include/ED_keyframes_keylist.h b/source/blender/editors/include/ED_keyframes_keylist.h
index 251b6e4d83d..d82d98777b8 100644
--- a/source/blender/editors/include/ED_keyframes_keylist.h
+++ b/source/blender/editors/include/ED_keyframes_keylist.h
@@ -37,6 +37,9 @@ typedef struct ActKeyBlockInfo {
 
   /* Selection flag. */
   char sel;
+
+  /* Interpolation mode. */
+  signed char ipo;
 } ActKeyBlockInfo;
 
 /* Keyframe Column Struct */



More information about the Bf-blender-cvs mailing list