[Bf-blender-cvs] [132522cba89] master: Cleanup: Separate keyframes_draw and keyframes_keylist.

Jeroen Bakker noreply at git.blender.org
Mon Jul 19 15:55:02 CEST 2021


Commit: 132522cba894954406877eba9067b9be06c60cde
Author: Jeroen Bakker
Date:   Mon Jul 19 15:53:04 2021 +0200
Branches: master
https://developer.blender.org/rB132522cba894954406877eba9067b9be06c60cde

Cleanup: Separate keyframes_draw and keyframes_keylist.

The keylist functions are used in other places for none drawing related
stuff. Fe pose_slide uses it.

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

M	source/blender/editors/animation/CMakeLists.txt
M	source/blender/editors/animation/anim_draw.c
M	source/blender/editors/animation/anim_motion_paths.c
M	source/blender/editors/animation/keyframes_draw.c
A	source/blender/editors/animation/keyframes_keylist.c
M	source/blender/editors/armature/pose_lib.c
M	source/blender/editors/armature/pose_slide.c
M	source/blender/editors/include/ED_keyframes_draw.h
A	source/blender/editors/include/ED_keyframes_keylist.h
M	source/blender/editors/interface/interface_icons.c
M	source/blender/editors/screen/screen_ops.c
M	source/blender/editors/space_action/action_select.c
M	source/blender/editors/space_nla/nla_draw.c

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

diff --git a/source/blender/editors/animation/CMakeLists.txt b/source/blender/editors/animation/CMakeLists.txt
index f50a5ffbb5e..7a53b54b5a4 100644
--- a/source/blender/editors/animation/CMakeLists.txt
+++ b/source/blender/editors/animation/CMakeLists.txt
@@ -47,6 +47,7 @@ set(SRC
   keyframes_draw.c
   keyframes_edit.c
   keyframes_general.c
+  keyframes_keylist.c
   keyframing.c
   keyingsets.c
   time_scrub_ui.c
diff --git a/source/blender/editors/animation/anim_draw.c b/source/blender/editors/animation/anim_draw.c
index 2fcd59a1bbe..baf8adf28d0 100644
--- a/source/blender/editors/animation/anim_draw.c
+++ b/source/blender/editors/animation/anim_draw.c
@@ -48,6 +48,7 @@
 #include "ED_anim_api.h"
 #include "ED_keyframes_draw.h"
 #include "ED_keyframes_edit.h"
+#include "ED_keyframes_keylist.h"
 
 #include "RNA_access.h"
 
diff --git a/source/blender/editors/animation/anim_motion_paths.c b/source/blender/editors/animation/anim_motion_paths.c
index 51a897600e1..bddd5dbff55 100644
--- a/source/blender/editors/animation/anim_motion_paths.c
+++ b/source/blender/editors/animation/anim_motion_paths.c
@@ -43,7 +43,7 @@
 #include "GPU_vertex_buffer.h"
 
 #include "ED_anim_api.h"
-#include "ED_keyframes_draw.h"
+#include "ED_keyframes_keylist.h"
 
 #include "CLG_log.h"
 
diff --git a/source/blender/editors/animation/keyframes_draw.c b/source/blender/editors/animation/keyframes_draw.c
index 06107b6fee6..4f512c9d7ca 100644
--- a/source/blender/editors/animation/keyframes_draw.c
+++ b/source/blender/editors/animation/keyframes_draw.c
@@ -24,28 +24,17 @@
 /* System includes ----------------------------------------------------- */
 
 #include <float.h>
-#include <math.h>
-#include <stdlib.h>
-#include <string.h>
-
-#include "MEM_guardedalloc.h"
 
 #include "BLI_dlrbTree.h"
 #include "BLI_listbase.h"
-#include "BLI_math.h"
 #include "BLI_rect.h"
-#include "BLI_utildefines.h"
 
 #include "DNA_anim_types.h"
-#include "DNA_brush_types.h"
-#include "DNA_cachefile_types.h"
 #include "DNA_gpencil_types.h"
 #include "DNA_mask_types.h"
 #include "DNA_object_types.h"
 #include "DNA_scene_types.h"
 
-#include "BKE_fcurve.h"
-
 #include "GPU_immediate.h"
 #include "GPU_state.h"
 
@@ -55,498 +44,7 @@
 
 #include "ED_anim_api.h"
 #include "ED_keyframes_draw.h"
-
-/* *************************** Keyframe Processing *************************** */
-
-/* ActKeyColumns (Keyframe Columns) ------------------------------------------ */
-
-BLI_INLINE bool is_cfra_eq(float a, float b)
-{
-  return IS_EQT(a, b, BEZT_BINARYSEARCH_THRESH);
-}
-
-BLI_INLINE bool is_cfra_lt(float a, float b)
-{
-  return (b - a) > BEZT_BINARYSEARCH_THRESH;
-}
-
-/* Comparator callback used for ActKeyColumns and cframe float-value pointer */
-/* NOTE: this is exported to other modules that use the ActKeyColumns for finding keyframes */
-short compare_ak_cfraPtr(void *node, void *data)
-{
-  ActKeyColumn *ak = (ActKeyColumn *)node;
-  const float *cframe = data;
-  float val = *cframe;
-
-  if (is_cfra_eq(val, ak->cfra)) {
-    return 0;
-  }
-
-  if (val < ak->cfra) {
-    return -1;
-  }
-  return 1;
-}
-
-/* --------------- */
-
-/* Set of references to three logically adjacent keys. */
-typedef struct BezTripleChain {
-  /* Current keyframe. */
-  BezTriple *cur;
-
-  /* Logical neighbors. May be NULL. */
-  BezTriple *prev, *next;
-} BezTripleChain;
-
-/* Categorize the interpolation & handle type of the keyframe. */
-static eKeyframeHandleDrawOpts bezt_handle_type(BezTriple *bezt)
-{
-  if (bezt->h1 == HD_AUTO_ANIM && bezt->h2 == HD_AUTO_ANIM) {
-    return KEYFRAME_HANDLE_AUTO_CLAMP;
-  }
-  if (ELEM(bezt->h1, HD_AUTO_ANIM, HD_AUTO) && ELEM(bezt->h2, HD_AUTO_ANIM, HD_AUTO)) {
-    return KEYFRAME_HANDLE_AUTO;
-  }
-  if (bezt->h1 == HD_VECT && bezt->h2 == HD_VECT) {
-    return KEYFRAME_HANDLE_VECTOR;
-  }
-  if (ELEM(HD_FREE, bezt->h1, bezt->h2)) {
-    return KEYFRAME_HANDLE_FREE;
-  }
-  return KEYFRAME_HANDLE_ALIGNED;
-}
-
-/* Determine if the keyframe is an extreme by comparing with neighbors.
- * Ends of fixed-value sections and of the whole curve are also marked.
- */
-static eKeyframeExtremeDrawOpts bezt_extreme_type(BezTripleChain *chain)
-{
-  if (chain->prev == NULL && chain->next == NULL) {
-    return KEYFRAME_EXTREME_NONE;
-  }
-
-  /* Keyframe values for the current one and neighbors. */
-  float cur_y = chain->cur->vec[1][1];
-  float prev_y = cur_y, next_y = cur_y;
-
-  if (chain->prev && !IS_EQF(cur_y, chain->prev->vec[1][1])) {
-    prev_y = chain->prev->vec[1][1];
-  }
-  if (chain->next && !IS_EQF(cur_y, chain->next->vec[1][1])) {
-    next_y = chain->next->vec[1][1];
-  }
-
-  /* Static hold. */
-  if (prev_y == cur_y && next_y == cur_y) {
-    return KEYFRAME_EXTREME_FLAT;
-  }
-
-  /* Middle of an incline. */
-  if ((prev_y < cur_y && next_y > cur_y) || (prev_y > cur_y && next_y < cur_y)) {
-    return KEYFRAME_EXTREME_NONE;
-  }
-
-  /* Bezier handle values for the overshoot check. */
-  bool l_bezier = chain->prev && chain->prev->ipo == BEZT_IPO_BEZ;
-  bool r_bezier = chain->next && chain->cur->ipo == BEZT_IPO_BEZ;
-  float handle_l = l_bezier ? chain->cur->vec[0][1] : cur_y;
-  float handle_r = r_bezier ? chain->cur->vec[2][1] : cur_y;
-
-  /* Detect extremes. One of the neighbors is allowed to be equal to current. */
-  if (prev_y < cur_y || next_y < cur_y) {
-    bool is_overshoot = (handle_l > cur_y || handle_r > cur_y);
-
-    return KEYFRAME_EXTREME_MAX | (is_overshoot ? KEYFRAME_EXTREME_MIXED : 0);
-  }
-
-  if (prev_y > cur_y || next_y > cur_y) {
-    bool is_overshoot = (handle_l < cur_y || handle_r < cur_y);
-
-    return KEYFRAME_EXTREME_MIN | (is_overshoot ? KEYFRAME_EXTREME_MIXED : 0);
-  }
-
-  return KEYFRAME_EXTREME_NONE;
-}
-
-/* Comparator callback used for ActKeyColumns and BezTripleChain */
-static short compare_ak_bezt(void *node, void *data)
-{
-  BezTripleChain *chain = data;
-
-  return compare_ak_cfraPtr(node, &chain->cur->vec[1][0]);
-}
-
-/* New node callback used for building ActKeyColumns from BezTripleChain */
-static DLRBT_Node *nalloc_ak_bezt(void *data)
-{
-  ActKeyColumn *ak = MEM_callocN(sizeof(ActKeyColumn), "ActKeyColumn");
-  BezTripleChain *chain = data;
-  BezTriple *bezt = chain->cur;
-
-  /* store settings based on state of BezTriple */
-  ak->cfra = bezt->vec[1][0];
-  ak->sel = BEZT_ISSEL_ANY(bezt) ? SELECT : 0;
-  ak->key_type = BEZKEYTYPE(bezt);
-  ak->handle_type = bezt_handle_type(bezt);
-  ak->extreme_type = bezt_extreme_type(chain);
-
-  /* count keyframes in this column */
-  ak->totkey = 1;
-
-  return (DLRBT_Node *)ak;
-}
-
-/* Node updater callback used for building ActKeyColumns from BezTripleChain */
-static void nupdate_ak_bezt(void *node, void *data)
-{
-  ActKeyColumn *ak = node;
-  BezTripleChain *chain = data;
-  BezTriple *bezt = chain->cur;
-
-  /* set selection status and 'touched' status */
-  if (BEZT_ISSEL_ANY(bezt)) {
-    ak->sel = SELECT;
-  }
-
-  /* count keyframes in this column */
-  ak->totkey++;
-
-  /* For keyframe type, 'proper' keyframes have priority over breakdowns
-   * (and other types for now). */
-  if (BEZKEYTYPE(bezt) == BEZT_KEYTYPE_KEYFRAME) {
-    ak->key_type = BEZT_KEYTYPE_KEYFRAME;
-  }
-
-  /* For interpolation type, select the highest value (enum is sorted). */
-  ak->handle_type = MAX2(ak->handle_type, bezt_handle_type(bezt));
-
-  /* For extremes, detect when combining different states. */
-  char new_extreme = bezt_extreme_type(chain);
-
-  if (new_extreme != ak->extreme_type) {
-    /* Replace the flat status without adding mixed. */
-    if (ak->extreme_type == KEYFRAME_EXTREME_FLAT) {
-      ak->extreme_type = new_extreme;
-    }
-    else if (new_extreme != KEYFRAME_EXTREME_FLAT) {
-      ak->extreme_type |= (new_extreme | KEYFRAME_EXTREME_MIXED);
-    }
-  }
-}
-
-/* ......... */
-
-/* Comparator callback used for ActKeyColumns and GPencil frame */
-static short compare_ak_gpframe(void *node, void *data)
-{
-  bGPDframe *gpf = (bGPDframe *)data;
-
-  float frame = gpf->framenum;
-  return compare_ak_cfraPtr(node, &frame);
-}
-
-/* New node callback used for building ActKeyColumns from GPencil frames */
-static DLRBT_Node *nalloc_ak_gpframe(void *data)
-{
-  ActKeyColumn *ak = MEM_callocN(sizeof(ActKeyColumn), "ActKeyColumnGPF");
-  bGPDframe *gpf = (bGPDframe *)data;
-
-  /* store settings based on state of BezTriple */
-  ak->cfra = gpf->framenum;
-  ak->sel = (gpf->flag & GP_FRAME_SELECT) ? SELECT : 0;
-  ak->key_type = gpf->key_type;
-
-  /* count keyframes in this column */
-  ak->totkey = 1;
-  /* Set as visible block. */
-  ak->totblock = 1;
-  ak->block.sel = ak->sel;
-  ak->block.flag |= ACTKEYBLOCK_FLAG_GPENCIL;
-
-  return (DLRBT_Node *)ak;
-}
-
-/* Node updater callback used for building ActKeyColumns from GPencil frames */
-static void nupdate_ak_gpframe(void *node, void *data)
-{
-  ActKeyColumn *ak = (ActKeyColumn *)node;
-  bGPDframe *gpf = (bGPDframe *)data;
-
-  /* set selection status and 'touched' status */
-  if (gpf->flag & GP_FRAME_SELECT) {
-    ak->sel = SELECT;
-  }
-
-  /* count keyframes in this column */
-  ak->totkey++;
-
-  /* for keyframe type, 'proper' keyframes have priority over breakdowns
-   * (and other types for now). */
-  if (gpf->key_type == BEZT_KEYTYPE_KEYFRAME) {
-    ak->key_type = BEZT_KEYTYPE_KEYFRAME;
-  }
-}
-
-/* ......... */
-
-/* Comparator callback used for ActKeyColumns and GPencil frame */
-static short compare_ak_masklayshape(void *node, void *data)
-{
-  MaskLayerShape *masklay_shape = (MaskLayerShape *)data;
-
-  float frame = masklay_shape->frame;
-  return compare_ak_cfraPtr(node, &frame);
-}
-
-/* New node callback used for building ActKeyColumns from GPencil frames */
-static DLRBT_Node *nalloc_ak_masklayshape(void *data)
-{
-  ActKeyColumn *ak = MEM_callocN(sizeof(ActKeyColumn), "ActKeyColumnGPF");
-  MaskLayerShape *masklay_shape = (MaskLayerShape *)data;
-
-  /* store settings based on state of BezTriple */
-  ak->cfra = masklay_shape->frame;
-  ak->sel = (masklay_shape->flag & MASK_SHAPE_SELECT) ? SELECT : 0;
-
-  /* count keyframes in this column */
-  ak->totkey = 1;
-
-  return (DLRBT_Node *)ak;
-}
-
-/* Node updater callback used for building ActKeyColumns from GPencil frames */
-static void nupdate_a

@@ Diff output truncated at 10240 characters. @@



More information about the Bf-blender-cvs mailing list