Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJoshua Leung <aligorith@gmail.com>2011-01-11 01:10:28 +0300
committerJoshua Leung <aligorith@gmail.com>2011-01-11 01:10:28 +0300
commitcf25b10eb5bb61662ce0db6b3ef54a3e3e73a328 (patch)
tree0d7ffcdd0735d1788bfb3e679b6f7489605c1aab /source/blender/editors/transform
parentd841a206314922eec0a0fed0b87e3078b68487c9 (diff)
Todo #22395: Restoring Grease Pencil Editing Mode in DopeSheet Editor
This commit restores some basic functionality for retiming Grease Pencil sketches. Some of the functionality that existed before still hasn't been restored (namely snap/mirror tools as well as copy+paste), though it should be possible to use this for basic retiming and sketch-frame management again. - There's still a lot of work required to get this up to the standard of the rest of the animation editor code, as some of this code was originally just hacked in based on the old-style code. - Work is already required to not have to directly access the main db global to get the list of Grease Pencil datablocks to show, but that can come along with pending cleanups of the filtering code.
Diffstat (limited to 'source/blender/editors/transform')
-rw-r--r--source/blender/editors/transform/transform_conversions.c103
-rw-r--r--source/blender/editors/transform/transform_generics.c35
2 files changed, 67 insertions, 71 deletions
diff --git a/source/blender/editors/transform/transform_conversions.c b/source/blender/editors/transform/transform_conversions.c
index fce1247ec6f..8725e0ba5b9 100644
--- a/source/blender/editors/transform/transform_conversions.c
+++ b/source/blender/editors/transform/transform_conversions.c
@@ -47,6 +47,7 @@
#include "DNA_constraint_types.h"
#include "DNA_scene_types.h"
#include "DNA_meshdata_types.h"
+#include "DNA_gpencil_types.h"
#include "MEM_guardedalloc.h"
@@ -57,6 +58,7 @@
#include "BKE_constraint.h"
#include "BKE_depsgraph.h"
#include "BKE_fcurve.h"
+#include "BKE_gpencil.h"
#include "BKE_global.h"
#include "BKE_key.h"
#include "BKE_main.h"
@@ -2804,7 +2806,6 @@ static void createTransNlaData(bContext *C, TransInfo *t)
* It also makes sure gp-frames are still stored in chronological order after
* transform.
*/
-#if 0
static void posttrans_gpd_clean (bGPdata *gpd)
{
bGPDlayer *gpl;
@@ -2813,17 +2814,17 @@ static void posttrans_gpd_clean (bGPdata *gpd)
ListBase sel_buffer = {NULL, NULL};
bGPDframe *gpf, *gpfn;
bGPDframe *gfs, *gfsn;
-
+
/* loop 1: loop through and isolate selected gp-frames to buffer
* (these need to be sorted as they are isolated)
*/
for (gpf= gpl->frames.first; gpf; gpf= gpfn) {
short added= 0;
gpfn= gpf->next;
-
+
if (gpf->flag & GP_FRAME_SELECT) {
BLI_remlink(&gpl->frames, gpf);
-
+
/* find place to add them in buffer
* - go backwards as most frames will still be in order,
* so doing it this way will be faster
@@ -2840,27 +2841,27 @@ static void posttrans_gpd_clean (bGPdata *gpd)
BLI_addhead(&sel_buffer, gpf);
}
}
-
+
/* error checking: it is unlikely, but may be possible to have none selected */
if (sel_buffer.first == NULL)
continue;
-
+
/* if all were selected (i.e. gpl->frames is empty), then just transfer sel-buf over */
if (gpl->frames.first == NULL) {
gpl->frames.first= sel_buffer.first;
gpl->frames.last= sel_buffer.last;
-
+
continue;
}
-
+
/* loop 2: remove duplicates of frames in buffers */
for (gpf= gpl->frames.first; gpf && sel_buffer.first; gpf= gpfn) {
gpfn= gpf->next;
-
+
/* loop through sel_buffer, emptying stuff from front of buffer if ok */
for (gfs= sel_buffer.first; gfs && gpf; gfs= gfsn) {
gfsn= gfs->next;
-
+
/* if this buffer frame needs to go before current, add it! */
if (gfs->framenum < gpf->framenum) {
/* transfer buffer frame to frames list (before current) */
@@ -2872,24 +2873,22 @@ static void posttrans_gpd_clean (bGPdata *gpd)
/* transfer buffer frame to frames list (before current) */
BLI_remlink(&sel_buffer, gfs);
BLI_insertlinkbefore(&gpl->frames, gpf, gfs);
-
+
/* get rid of current frame */
- // TRANSFORM_FIX_ME
- //gpencil_layer_delframe(gpl, gpf);
+ gpencil_layer_delframe(gpl, gpf);
}
}
}
-
+
/* if anything is still in buffer, append to end */
for (gfs= sel_buffer.first; gfs; gfs= gfsn) {
gfsn= gfs->next;
-
+
BLI_remlink(&sel_buffer, gfs);
BLI_addtail(&gpl->frames, gfs);
}
}
}
-#endif
/* Called during special_aftertrans_update to make sure selected keyframes replace
* any other keyframes which may reside on that frame (that is not selected).
@@ -3012,15 +3011,14 @@ static int count_fcurve_keys(FCurve *fcu, char side, float cfra)
}
/* fully select selected beztriples, but only include if it's on the right side of cfra */
-#if 0
static int count_gplayer_frames(bGPDlayer *gpl, char side, float cfra)
{
bGPDframe *gpf;
int count = 0;
-
+
if (gpl == NULL)
return count;
-
+
/* only include points that occur on the right side of cfra */
for (gpf= gpl->frames.first; gpf; gpf= gpf->next) {
if (gpf->flag & GP_FRAME_SELECT) {
@@ -3028,10 +3026,9 @@ static int count_gplayer_frames(bGPDlayer *gpl, char side, float cfra)
count++;
}
}
-
+
return count;
}
-#endif
/* This function assigns the information to transdata */
static void TimeToTransData(TransData *td, float *time, AnimData *adt)
@@ -3068,23 +3065,23 @@ static TransData *ActionFCurveToTransData(TransData *td, TransData2D **td2dv, FC
/* only add if on the right 'side' of the current frame */
if (FrameOnMouseSide(side, bezt->vec[1][0], cfra)) {
TimeToTransData(td, bezt->vec[1], adt);
-
+
/*set flags to move handles as necassary*/
td->flag |= TD_MOVEHANDLE1|TD_MOVEHANDLE2;
td2d->h1 = bezt->vec[0];
td2d->h2 = bezt->vec[2];
-
+
VECCOPY2D(td2d->ih1, td2d->h1);
VECCOPY2D(td2d->ih2, td2d->h2);
-
+
td++;
td2d++;
}
}
}
-
+
*td2dv = td2d;
-
+
return td;
}
@@ -3119,12 +3116,11 @@ void flushTransGPactionData (TransInfo *t)
* The 'side' argument is needed for the extend mode. 'B' = both sides, 'R'/'L' mean only data
* on the named side are used.
*/
-#if 0
static int GPLayerToTransData (TransData *td, tGPFtransdata *tfd, bGPDlayer *gpl, char side, float cfra)
{
bGPDframe *gpf;
int count= 0;
-
+
/* check for select frames on right side of current frame */
for (gpf= gpl->frames.first; gpf; gpf= gpf->next) {
if (gpf->flag & GP_FRAME_SELECT) {
@@ -3132,10 +3128,10 @@ static int GPLayerToTransData (TransData *td, tGPFtransdata *tfd, bGPDlayer *gpl
/* memory is calloc'ed, so that should zero everything nicely for us */
td->val= &tfd->val;
td->ival= (float)gpf->framenum;
-
+
tfd->val= (float)gpf->framenum;
tfd->sdata= &gpf->framenum;
-
+
/* advance td now */
td++;
tfd++;
@@ -3143,10 +3139,9 @@ static int GPLayerToTransData (TransData *td, tGPFtransdata *tfd, bGPDlayer *gpl
}
}
}
-
+
return count;
}
-#endif
static void createTransActionData(bContext *C, TransInfo *t)
{
@@ -3199,10 +3194,10 @@ static void createTransActionData(bContext *C, TransInfo *t)
else
cfra = (float)CFRA;
- //if (ale->type == ANIMTYPE_GPLAYER)
- // count += count_gplayer_frames(ale->data, t->frame_side, cfra);
- //else
+ if (ale->type == ANIMTYPE_FCURVE)
count += count_fcurve_keys(ale->key_data, t->frame_side, cfra);
+ else
+ count += count_gplayer_frames(ale->data, t->frame_side, cfra);
}
/* stop if trying to build list if nothing selected */
@@ -3235,15 +3230,15 @@ static void createTransActionData(bContext *C, TransInfo *t)
/* loop 2: build transdata array */
for (ale= anim_data.first; ale; ale= ale->next) {
- //if (ale->type == ANIMTYPE_GPLAYER) {
- // bGPDlayer *gpl= (bGPDlayer *)ale->data;
- // int i;
- //
- // i = GPLayerToTransData(td, tfd, gpl, t->frame_side, cfra);
- // td += i;
- // tfd += i;
- //}
- //else {
+ if (ale->type == ANIMTYPE_GPLAYER) {
+ bGPDlayer *gpl= (bGPDlayer *)ale->data;
+ int i;
+
+ i = GPLayerToTransData(td, tfd, gpl, t->frame_side, cfra);
+ td += i;
+ tfd += i;
+ }
+ else {
AnimData *adt= ANIM_nla_mapping_get(&ac, ale);
FCurve *fcu= (FCurve *)ale->key_data;
@@ -3256,7 +3251,7 @@ static void createTransActionData(bContext *C, TransInfo *t)
cfra = (float)CFRA;
td= ActionFCurveToTransData(td, &td2d, fcu, adt, t->frame_side, cfra);
- //}
+ }
}
/* check if we're supposed to be setting minx/maxx for TimeSlide */
@@ -4916,27 +4911,21 @@ void special_aftertrans_update(bContext *C, TransInfo *t)
scene_marker_tfm_scale(t->scene, t->vec[0], SELECT);
}
}
-
-#if 0 // XXX future of this is still not clear
+
else if (ac.datatype == ANIMCONT_GPENCIL) {
/* remove duplicate frames and also make sure points are in order! */
if ((cancelled == 0) || (duplicate))
{
- bScreen *sc= (bScreen *)ac.data;
- ScrArea *sa;
+ bGPdata *gpd;
- /* BAD... we need to loop over all screen areas for current screen...
- * - sync this with actdata_filter_gpencil() in editaction.c
- */
- for (sa= sc->areabase.first; sa; sa= sa->next) {
- bGPdata *gpd= gpencil_data_get_active(sa);
-
- if (gpd)
+ // XXX: BAD! this get gpencil datablocks directly from main db...
+ // but that's how this currently works :/
+ for (gpd = G.main->gpencil.first; gpd; gpd = gpd->id.next) {
+ if (ID_REAL_USERS(gpd) > 1)
posttrans_gpd_clean(gpd);
}
}
}
-#endif // XXX future of this is still not clear
/* make sure all F-Curves are set correctly */
ANIM_editkeyframes_refresh(&ac);
diff --git a/source/blender/editors/transform/transform_generics.c b/source/blender/editors/transform/transform_generics.c
index dbf984b6659..839e813f1ae 100644
--- a/source/blender/editors/transform/transform_generics.c
+++ b/source/blender/editors/transform/transform_generics.c
@@ -349,22 +349,29 @@ void recalcData(TransInfo *t)
ANIM_animdata_context_getdata(&ac);
- /* get animdata blocks visible in editor, assuming that these will be the ones where things changed */
- filter= (ANIMFILTER_VISIBLE | ANIMFILTER_ANIMDATA);
- ANIM_animdata_filter(&ac, &anim_data, filter, ac.data, ac.datatype);
-
- /* just tag these animdata-blocks to recalc, assuming that some data there changed
- * BUT only do this if realtime updates are enabled
- */
- if ((saction->flag & SACTION_NOREALTIMEUPDATES) == 0) {
- for (ale= anim_data.first; ale; ale= ale->next) {
- /* set refresh tags for objects using this animation */
- ANIM_list_elem_update(t->scene, ale);
+ /* perform flush */
+ if (ac.datatype == ANIMCONT_GPENCIL) {
+ /* flush transform values back to actual coordinates */
+ flushTransGPactionData(t);
+ }
+ else {
+ /* get animdata blocks visible in editor, assuming that these will be the ones where things changed */
+ filter= (ANIMFILTER_VISIBLE | ANIMFILTER_ANIMDATA);
+ ANIM_animdata_filter(&ac, &anim_data, filter, ac.data, ac.datatype);
+
+ /* just tag these animdata-blocks to recalc, assuming that some data there changed
+ * BUT only do this if realtime updates are enabled
+ */
+ if ((saction->flag & SACTION_NOREALTIMEUPDATES) == 0) {
+ for (ale= anim_data.first; ale; ale= ale->next) {
+ /* set refresh tags for objects using this animation */
+ ANIM_list_elem_update(t->scene, ale);
+ }
}
+
+ /* now free temp channels */
+ BLI_freelistN(&anim_data);
}
-
- /* now free temp channels */
- BLI_freelistN(&anim_data);
}
else if (t->spacetype == SPACE_IPO) {
Scene *scene;