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>2009-10-16 10:24:39 +0400
committerJoshua Leung <aligorith@gmail.com>2009-10-16 10:24:39 +0400
commit004199efd4708ad903e8d53df09163dc282b9cee (patch)
treeb6422c40f50da63c13d5d20211248734903ab74c /source/blender/editors/transform/transform_conversions.c
parent7016400278d9857eac8e0a2f6310d400ecfa2d3f (diff)
Graph Editor - Transform Crash Fix
The code for transforming a mixture of keyframes with bezier and non-bezier interpolation was crashing. The old code only took all the handles when a keyframe was bezier, and one when it was not; but sometimes this underestimated the situation (the first handle is only really used if the previous keyframe was bezier, as per the standard evaluation rules for these, but it didn't really check for this). Now, it just adds them whenever, since there is the possibility that keyframes may be moved before other unselected ones, in which case the handles may become invalid. Thanks to Lee (from Durian, who found the crash), and Jess Balint (who had submitted a patch with some steps towards fixing this)
Diffstat (limited to 'source/blender/editors/transform/transform_conversions.c')
-rw-r--r--source/blender/editors/transform/transform_conversions.c82
1 files changed, 39 insertions, 43 deletions
diff --git a/source/blender/editors/transform/transform_conversions.c b/source/blender/editors/transform/transform_conversions.c
index 496a9665371..abcf1748149 100644
--- a/source/blender/editors/transform/transform_conversions.c
+++ b/source/blender/editors/transform/transform_conversions.c
@@ -3342,7 +3342,7 @@ static void createTransGraphEditData(bContext *C, TransInfo *t)
bAnimListElem *ale;
int filter;
- BezTriple *bezt, *prevbezt;
+ BezTriple *bezt;
int count=0, i;
float cfra;
char side;
@@ -3382,29 +3382,28 @@ static void createTransGraphEditData(bContext *C, TransInfo *t)
else
cfra = (float)CFRA;
+ /* F-Curve may not have any keyframes */
+ if (fcu->bezt == NULL)
+ continue;
+
/* only include BezTriples whose 'keyframe' occurs on the same side of the current frame as mouse */
- if (fcu->bezt) {
- for (i=0, bezt=fcu->bezt; i < fcu->totvert; i++, bezt++) {
- if (FrameOnMouseSide(side, bezt->vec[1][0], cfra)) {
- if (v2d->around == V3D_LOCAL) {
- /* for local-pivot we only need to count the number of selected handles only, so that centerpoitns don't
- * don't get moved wrong
- */
- if (bezt->ipo == BEZT_IPO_BEZ) {
- if (bezt->f1 & SELECT) count++;
- if (bezt->f3 & SELECT) count++;
- }
- else if (bezt->f2 & SELECT) count++;
- }
- else {
- /* for 'normal' pivots */
- if (bezt->ipo == BEZT_IPO_BEZ) {
- if (bezt->f1 & SELECT) count++;
- if (bezt->f2 & SELECT) count++;
- if (bezt->f3 & SELECT) count++;
- }
- else if (bezt->f2 & SELECT) count++;
+ for (i=0, bezt=fcu->bezt; i < fcu->totvert; i++, bezt++) {
+ if (FrameOnMouseSide(side, bezt->vec[1][0], cfra)) {
+ if (v2d->around == V3D_LOCAL) {
+ /* for local-pivot we only need to count the number of selected handles only, so that centerpoints don't
+ * don't get moved wrong
+ */
+ if (bezt->ipo == BEZT_IPO_BEZ) {
+ if (bezt->f1 & SELECT) count++;
+ if (bezt->f3 & SELECT) count++;
}
+ else if (bezt->f2 & SELECT) count++; // TODO: could this cause problems?
+ }
+ else {
+ /* for 'normal' pivots - just include anything that is selected */
+ if (bezt->f1 & SELECT) count++;
+ if (bezt->f2 & SELECT) count++;
+ if (bezt->f3 & SELECT) count++;
}
}
}
@@ -3440,38 +3439,35 @@ static void createTransGraphEditData(bContext *C, TransInfo *t)
cfra = BKE_nla_tweakedit_remap(adt, (float)CFRA, NLATIME_CONVERT_UNMAP);
else
cfra = (float)CFRA;
+
+ /* F-Curve may not have any keyframes */
+ if (fcu->bezt == NULL)
+ continue;
/* only include BezTriples whose 'keyframe' occurs on the same side of the current frame as mouse (if applicable) */
- bezt= fcu->bezt;
- prevbezt= NULL;
-
- for (i=0; i < fcu->totvert; i++, prevbezt=bezt, bezt++) {
+ for (i=0, bezt= fcu->bezt; i < fcu->totvert; i++, bezt++) {
if (FrameOnMouseSide(side, bezt->vec[1][0], cfra)) {
TransDataCurveHandleFlags *hdata = NULL;
short h1=1, h2=1;
- /* only include handles if selected, and interpolaton mode uses beztriples */
- if ( (!prevbezt && (bezt->ipo==BEZT_IPO_BEZ)) || (prevbezt && (prevbezt->ipo==BEZT_IPO_BEZ)) ) {
- if (bezt->f1 & SELECT) {
- hdata = initTransDataCurveHandes(td, bezt);
- bezt_to_transdata(td++, td2d++, adt, bezt->vec[0], bezt->vec[1], 1, 1, intvals);
- }
- else
- h1= 0;
+ /* only include handles if selected, irrespective of the interpolation modes */
+ if (bezt->f1 & SELECT) {
+ hdata = initTransDataCurveHandes(td, bezt);
+ bezt_to_transdata(td++, td2d++, adt, bezt->vec[0], bezt->vec[1], 1, 1, intvals);
}
- if (bezt->ipo == BEZT_IPO_BEZ) {
- if (bezt->f3 & SELECT) {
- if (hdata==NULL)
- hdata = initTransDataCurveHandes(td, bezt);
- bezt_to_transdata(td++, td2d++, adt, bezt->vec[2], bezt->vec[1], 1, 1, intvals);
- }
- else
- h2= 0;
+ else
+ h1= 0;
+ if (bezt->f3 & SELECT) {
+ if (hdata==NULL)
+ hdata = initTransDataCurveHandes(td, bezt);
+ bezt_to_transdata(td++, td2d++, adt, bezt->vec[2], bezt->vec[1], 1, 1, intvals);
}
+ else
+ h2= 0;
/* only include main vert if selected */
if (bezt->f2 & SELECT) {
- /* if scaling around individuals centers, do no include keyframes */
+ /* if scaling around individuals centers, do not include keyframes */
if (v2d->around != V3D_LOCAL) {
/* if handles were not selected, store their selection status */
if (!(bezt->f1 & SELECT) && !(bezt->f3 & SELECT)) {