[Bf-blender-cvs] [52f4ab44ad6] temp-transform-conversions-split: Transform: Move NLA conversion to is own file

mano-wii noreply at git.blender.org
Wed Sep 4 23:52:51 CEST 2019


Commit: 52f4ab44ad61d8a51f51b27c120e4c789d40b730
Author: mano-wii
Date:   Wed Sep 4 17:16:09 2019 -0300
Branches: temp-transform-conversions-split
https://developer.blender.org/rB52f4ab44ad61d8a51f51b27c120e4c789d40b730

Transform: Move NLA conversion to is own file

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

M	source/blender/editors/transform/CMakeLists.txt
M	source/blender/editors/transform/transform_conversions.c
M	source/blender/editors/transform/transform_conversions.h
M	source/blender/editors/transform/transform_conversions_actiondata.c
A	source/blender/editors/transform/transform_conversions_nla.c

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

diff --git a/source/blender/editors/transform/CMakeLists.txt b/source/blender/editors/transform/CMakeLists.txt
index edba894736f..e9af71288ee 100644
--- a/source/blender/editors/transform/CMakeLists.txt
+++ b/source/blender/editors/transform/CMakeLists.txt
@@ -48,6 +48,7 @@ set(SRC
   transform_conversions_lattice.c
   transform_conversions_mball.c
   transform_conversions_mesh.c
+  transform_conversions_nla.c
   transform_conversions_particle.c
   transform_generics.c
   transform_gizmo_2d.c
diff --git a/source/blender/editors/transform/transform_conversions.c b/source/blender/editors/transform/transform_conversions.c
index d53ed952189..698b7d45cf9 100644
--- a/source/blender/editors/transform/transform_conversions.c
+++ b/source/blender/editors/transform/transform_conversions.c
@@ -1193,225 +1193,6 @@ bool FrameOnMouseSide(char side, float frame, float cframe)
   }
 }
 
-/* ********************* NLA EDITOR ************************* */
-
-static void createTransNlaData(bContext *C, TransInfo *t)
-{
-  Scene *scene = t->scene;
-  SpaceNla *snla = NULL;
-  TransData *td = NULL;
-  TransDataNla *tdn = NULL;
-
-  bAnimContext ac;
-  ListBase anim_data = {NULL, NULL};
-  bAnimListElem *ale;
-  int filter;
-
-  int count = 0;
-
-  TransDataContainer *tc = TRANS_DATA_CONTAINER_FIRST_SINGLE(t);
-
-  /* determine what type of data we are operating on */
-  if (ANIM_animdata_get_context(C, &ac) == 0) {
-    return;
-  }
-  snla = (SpaceNla *)ac.sl;
-
-  /* filter data */
-  filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE | ANIMFILTER_FOREDIT);
-  ANIM_animdata_filter(&ac, &anim_data, filter, ac.data, ac.datatype);
-
-  /* which side of the current frame should be allowed */
-  if (t->mode == TFM_TIME_EXTEND) {
-    /* only side on which mouse is gets transformed */
-    float xmouse, ymouse;
-
-    UI_view2d_region_to_view(&ac.ar->v2d, t->mouse.imval[0], t->mouse.imval[1], &xmouse, &ymouse);
-    t->frame_side = (xmouse > CFRA) ? 'R' : 'L';
-  }
-  else {
-    /* normal transform - both sides of current frame are considered */
-    t->frame_side = 'B';
-  }
-
-  /* loop 1: count how many strips are selected (consider each strip as 2 points) */
-  for (ale = anim_data.first; ale; ale = ale->next) {
-    NlaTrack *nlt = (NlaTrack *)ale->data;
-    NlaStrip *strip;
-
-    /* make some meta-strips for chains of selected strips */
-    BKE_nlastrips_make_metas(&nlt->strips, 1);
-
-    /* only consider selected strips */
-    for (strip = nlt->strips.first; strip; strip = strip->next) {
-      // TODO: we can make strips have handles later on...
-      /* transition strips can't get directly transformed */
-      if (strip->type != NLASTRIP_TYPE_TRANSITION) {
-        if (strip->flag & NLASTRIP_FLAG_SELECT) {
-          if (FrameOnMouseSide(t->frame_side, strip->start, (float)CFRA)) {
-            count++;
-          }
-          if (FrameOnMouseSide(t->frame_side, strip->end, (float)CFRA)) {
-            count++;
-          }
-        }
-      }
-    }
-  }
-
-  /* stop if trying to build list if nothing selected */
-  if (count == 0) {
-    /* clear temp metas that may have been created but aren't needed now
-     * because they fell on the wrong side of CFRA
-     */
-    for (ale = anim_data.first; ale; ale = ale->next) {
-      NlaTrack *nlt = (NlaTrack *)ale->data;
-      BKE_nlastrips_clear_metas(&nlt->strips, 0, 1);
-    }
-
-    /* cleanup temp list */
-    ANIM_animdata_freelist(&anim_data);
-    return;
-  }
-
-  /* allocate memory for data */
-  tc->data_len = count;
-
-  tc->data = MEM_callocN(tc->data_len * sizeof(TransData), "TransData(NLA Editor)");
-  td = tc->data;
-  tc->custom.type.data = tdn = MEM_callocN(tc->data_len * sizeof(TransDataNla),
-                                           "TransDataNla (NLA Editor)");
-  tc->custom.type.use_free = true;
-
-  /* loop 2: build transdata array */
-  for (ale = anim_data.first; ale; ale = ale->next) {
-    /* only if a real NLA-track */
-    if (ale->type == ANIMTYPE_NLATRACK) {
-      AnimData *adt = ale->adt;
-      NlaTrack *nlt = (NlaTrack *)ale->data;
-      NlaStrip *strip;
-
-      /* only consider selected strips */
-      for (strip = nlt->strips.first; strip; strip = strip->next) {
-        // TODO: we can make strips have handles later on...
-        /* transition strips can't get directly transformed */
-        if (strip->type != NLASTRIP_TYPE_TRANSITION) {
-          if (strip->flag & NLASTRIP_FLAG_SELECT) {
-            /* our transform data is constructed as follows:
-             * - only the handles on the right side of the current-frame get included
-             * - td structs are transform-elements operated on by the transform system
-             *   and represent a single handle. The storage/pointer used (val or loc) depends on
-             *   whether we're scaling or transforming. Ultimately though, the handles
-             *   the td writes to will simply be a dummy in tdn
-             * - for each strip being transformed, a single tdn struct is used, so in some
-             *   cases, there will need to be 1 of these tdn elements in the array skipped...
-             */
-            float center[3], yval;
-
-            /* firstly, init tdn settings */
-            tdn->id = ale->id;
-            tdn->oldTrack = tdn->nlt = nlt;
-            tdn->strip = strip;
-            tdn->trackIndex = BLI_findindex(&adt->nla_tracks, nlt);
-
-            yval = (float)(tdn->trackIndex * NLACHANNEL_STEP(snla));
-
-            tdn->h1[0] = strip->start;
-            tdn->h1[1] = yval;
-            tdn->h2[0] = strip->end;
-            tdn->h2[1] = yval;
-
-            center[0] = (float)CFRA;
-            center[1] = yval;
-            center[2] = 0.0f;
-
-            /* set td's based on which handles are applicable */
-            if (FrameOnMouseSide(t->frame_side, strip->start, (float)CFRA)) {
-              /* just set tdn to assume that it only has one handle for now */
-              tdn->handle = -1;
-
-              /* now, link the transform data up to this data */
-              if (ELEM(t->mode, TFM_TRANSLATION, TFM_TIME_EXTEND)) {
-                td->loc = tdn->h1;
-                copy_v3_v3(td->iloc, tdn->h1);
-
-                /* store all the other gunk that is required by transform */
-                copy_v3_v3(td->center, center);
-                memset(td->axismtx, 0, sizeof(td->axismtx));
-                td->axismtx[2][2] = 1.0f;
-
-                td->ext = NULL;
-                td->val = NULL;
-
-                td->flag |= TD_SELECTED;
-                td->dist = 0.0f;
-
-                unit_m3(td->mtx);
-                unit_m3(td->smtx);
-              }
-              else {
-                /* time scaling only needs single value */
-                td->val = &tdn->h1[0];
-                td->ival = tdn->h1[0];
-              }
-
-              td->extra = tdn;
-              td++;
-            }
-            if (FrameOnMouseSide(t->frame_side, strip->end, (float)CFRA)) {
-              /* if tdn is already holding the start handle,
-               * then we're doing both, otherwise, only end */
-              tdn->handle = (tdn->handle) ? 2 : 1;
-
-              /* now, link the transform data up to this data */
-              if (ELEM(t->mode, TFM_TRANSLATION, TFM_TIME_EXTEND)) {
-                td->loc = tdn->h2;
-                copy_v3_v3(td->iloc, tdn->h2);
-
-                /* store all the other gunk that is required by transform */
-                copy_v3_v3(td->center, center);
-                memset(td->axismtx, 0, sizeof(td->axismtx));
-                td->axismtx[2][2] = 1.0f;
-
-                td->ext = NULL;
-                td->val = NULL;
-
-                td->flag |= TD_SELECTED;
-                td->dist = 0.0f;
-
-                unit_m3(td->mtx);
-                unit_m3(td->smtx);
-              }
-              else {
-                /* time scaling only needs single value */
-                td->val = &tdn->h2[0];
-                td->ival = tdn->h2[0];
-              }
-
-              td->extra = tdn;
-              td++;
-            }
-
-            /* If both handles were used, skip the next tdn (i.e. leave it blank)
-             * since the counting code is dumb.
-             * Otherwise, just advance to the next one.
-             */
-            if (tdn->handle == 2) {
-              tdn += 2;
-            }
-            else {
-              tdn++;
-            }
-          }
-        }
-      }
-    }
-  }
-
-  /* cleanup temp list */
-  ANIM_animdata_freelist(&anim_data);
-}
-
 /* ********************* ACTION EDITOR ****************** */
 
 static int gpf_cmp_frame(void *thunk, const void *a, const void *b)
diff --git a/source/blender/editors/transform/transform_conversions.h b/source/blender/editors/transform/transform_conversions.h
index 5113ed3c1d0..a60c1f658d4 100644
--- a/source/blender/editors/transform/transform_conversions.h
+++ b/source/blender/editors/transform/transform_conversions.h
@@ -96,6 +96,9 @@ void createTransEditVerts(TransInfo *t);
 void createTransEdge(TransInfo *t);
 void createTransUVs(bContext *C, TransInfo *t);
 
+/* transform_conversions_nla.c */
+void createTransNlaData(bContext *C, TransInfo *t);
+
 /* transform_conversions_particle.c */
 void createTransParticleVerts(bContext *C, TransInfo *t);
 #endif
diff --git a/source/blender/editors/transform/transform_conversions_actiondata.c b/source/blender/editors/transform/transform_conversions_actiondata.c
index e9d42cb98f8..b15ad1fcef2 100644
--- a/source/blender/editors/transform/transform_conversions_actiondata.c
+++ b/source/blender/editors/transform/transform_conversions_actiondata.c
@@ -39,7 +39,7 @@
 
 #include "ED_anim_api.h"
 
-#include "UI_view2d.h" /
+#include "UI_view2d.h"
 
 #include "transform.h"
 #include "transform_conversions.h"
diff --git a/source/blender/editors/transform/transform_conversions_nla.c b/source/blender/editors/transform/transform_conversions_nla.c
new file mode 100644
index 00000000000..2641c580a26
--- /dev/null
+++ b/source/blender/editors/transform/transform_conversions_nla.c
@@ -0,0 +1,265 @@
+/*
+ * This program is free software; you can redistribute it and/or
+ * modify it under 

@@ Diff output truncated at 10240 characters. @@



More information about the Bf-blender-cvs mailing list