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:
authorCampbell Barton <ideasman42@gmail.com>2019-04-22 02:19:45 +0300
committerCampbell Barton <ideasman42@gmail.com>2019-04-22 12:48:16 +0300
commit620b960d3d8cfd90b9f0df6ba3671c33eccb8309 (patch)
tree64f69db4bf9d44f0a32d1c92b0714bf2dc98ff2d /source/blender/editors/animation/keyframes_general.c
parentbba60bb564cf5a16cfcac744d4ba82cf8eba3da9 (diff)
Cleanup: style, use braces for editors
Diffstat (limited to 'source/blender/editors/animation/keyframes_general.c')
-rw-r--r--source/blender/editors/animation/keyframes_general.c96
1 files changed, 64 insertions, 32 deletions
diff --git a/source/blender/editors/animation/keyframes_general.c b/source/blender/editors/animation/keyframes_general.c
index 3109ae6c553..5214c5f78fa 100644
--- a/source/blender/editors/animation/keyframes_general.c
+++ b/source/blender/editors/animation/keyframes_general.c
@@ -70,17 +70,20 @@
void delete_fcurve_key(FCurve *fcu, int index, bool do_recalc)
{
/* sanity check */
- if (fcu == NULL)
+ if (fcu == NULL) {
return;
+ }
/* verify the index:
* 1) cannot be greater than the number of available keyframes
* 2) negative indices are for specifying a value from the end of the array
*/
- if (abs(index) >= fcu->totvert)
+ if (abs(index) >= fcu->totvert) {
return;
- else if (index < 0)
+ }
+ else if (index < 0) {
index += fcu->totvert;
+ }
/* Delete this keyframe */
memmove(
@@ -88,14 +91,16 @@ void delete_fcurve_key(FCurve *fcu, int index, bool do_recalc)
fcu->totvert--;
if (fcu->totvert == 0) {
- if (fcu->bezt)
+ if (fcu->bezt) {
MEM_freeN(fcu->bezt);
+ }
fcu->bezt = NULL;
}
/* recalc handles - only if it won't cause problems */
- if (do_recalc)
+ if (do_recalc) {
calchandles_fcurve(fcu);
+ }
}
/* Delete selected keyframes in given F-Curve */
@@ -104,8 +109,9 @@ bool delete_fcurve_keys(FCurve *fcu)
int i;
bool changed = false;
- if (fcu->bezt == NULL) /* ignore baked curves */
+ if (fcu->bezt == NULL) { /* ignore baked curves */
return false;
+ }
/* Delete selected BezTriples */
for (i = 0; i < fcu->totvert; i++) {
@@ -118,16 +124,18 @@ bool delete_fcurve_keys(FCurve *fcu)
}
/* Free the array of BezTriples if there are not keyframes */
- if (fcu->totvert == 0)
+ if (fcu->totvert == 0) {
clear_fcurve_keys(fcu);
+ }
return changed;
}
void clear_fcurve_keys(FCurve *fcu)
{
- if (fcu->bezt)
+ if (fcu->bezt) {
MEM_freeN(fcu->bezt);
+ }
fcu->bezt = NULL;
fcu->totvert = 0;
@@ -142,8 +150,9 @@ void duplicate_fcurve_keys(FCurve *fcu)
int i;
/* this can only work when there is an F-Curve, and also when there are some BezTriples */
- if (ELEM(NULL, fcu, fcu->bezt))
+ if (ELEM(NULL, fcu, fcu->bezt)) {
return;
+ }
for (i = 0; i < fcu->totvert; i++) {
/* If a key is selected */
@@ -283,8 +292,9 @@ void clean_fcurve(struct bAnimContext *ac, bAnimListElem *ale, float thresh, boo
}
/* now free the memory used by the old BezTriples */
- if (old_bezts)
+ if (old_bezts) {
MEM_freeN(old_bezts);
+ }
/* final step, if there is just one key in fcurve, check if it's
* the default value and if is, remove fcurve completely. */
@@ -296,8 +306,9 @@ void clean_fcurve(struct bAnimContext *ac, bAnimListElem *ale, float thresh, boo
/* get property to read from, and get value as appropriate */
if (RNA_path_resolve_property(&id_ptr, fcu->rna_path, &ptr, &prop)) {
- if (RNA_property_type(prop) == PROP_FLOAT)
+ if (RNA_property_type(prop) == PROP_FLOAT) {
default_value = RNA_property_float_get_default_index(&ptr, prop, fcu->array_index);
+ }
}
if (fcu->bezt->vec[1][1] == default_value) {
@@ -336,8 +347,9 @@ void smooth_fcurve(FCurve *fcu)
/* first loop through - count how many verts are selected */
bezt = fcu->bezt;
for (i = 0; i < fcu->totvert; i++, bezt++) {
- if (BEZT_ISSEL_ANY(bezt))
+ if (BEZT_ISSEL_ANY(bezt)) {
totSel++;
+ }
}
/* if any points were selected, allocate tSmooth_Bezt points to work on */
@@ -357,10 +369,12 @@ void smooth_fcurve(FCurve *fcu)
tsb->h3 = &bezt->vec[2][1];
/* advance to the next tsb to populate */
- if (x < totSel - 1)
+ if (x < totSel - 1) {
tsb++;
- else
+ }
+ else {
break;
+ }
}
}
@@ -433,8 +447,9 @@ void sample_fcurve(FCurve *fcu)
int sfra, range;
int i, n;
- if (fcu->bezt == NULL) /* ignore baked */
+ if (fcu->bezt == NULL) { /* ignore baked */
return;
+ }
/* find selected keyframes... once pair has been found, add keyframes */
for (i = 0, bezt = fcu->bezt; i < fcu->totvert; i++, bezt++) {
@@ -543,12 +558,14 @@ void ANIM_fcurves_copybuf_free(void)
acn = aci->next;
/* free keyframes */
- if (aci->bezt)
+ if (aci->bezt) {
MEM_freeN(aci->bezt);
+ }
/* free RNA-path */
- if (aci->rna_path)
+ if (aci->rna_path) {
MEM_freeN(aci->rna_path);
+ }
/* free ourself */
BLI_freelinkN(&animcopybuf, aci);
@@ -583,8 +600,9 @@ short copy_animedit_keys(bAnimContext *ac, ListBase *anim_data)
* - this check should also eliminate any problems associated with using sample-data
*/
if (ANIM_fcurve_keyframes_loop(
- NULL, fcu, NULL, ANIM_editkeyframes_ok(BEZT_OK_SELECTED), NULL) == 0)
+ NULL, fcu, NULL, ANIM_editkeyframes_ok(BEZT_OK_SELECTED), NULL) == 0) {
continue;
+ }
/* init copybuf item info */
aci = MEM_callocN(sizeof(tAnimCopybufItem), "AnimCopybufItem");
@@ -607,8 +625,9 @@ short copy_animedit_keys(bAnimContext *ac, ListBase *anim_data)
if (pchan) {
aci->is_bone = true;
}
- if (bone_name)
+ if (bone_name) {
MEM_freeN(bone_name);
+ }
}
BLI_addtail(&animcopybuf, aci);
@@ -622,8 +641,9 @@ short copy_animedit_keys(bAnimContext *ac, ListBase *anim_data)
newbuf = MEM_callocN(sizeof(BezTriple) * (aci->totvert + 1), "copybuf beztriple");
/* assume that since we are just re-sizing the array, just copy all existing data across */
- if (aci->bezt)
+ if (aci->bezt) {
memcpy(newbuf, aci->bezt, sizeof(BezTriple) * (aci->totvert));
+ }
/* copy current beztriple across too */
nbezt = &newbuf[aci->totvert];
@@ -633,23 +653,27 @@ short copy_animedit_keys(bAnimContext *ac, ListBase *anim_data)
BEZT_SEL_ALL(nbezt);
/* free old array and set the new */
- if (aci->bezt)
+ if (aci->bezt) {
MEM_freeN(aci->bezt);
+ }
aci->bezt = newbuf;
aci->totvert++;
/* check if this is the earliest frame encountered so far */
- if (bezt->vec[1][0] < animcopy_firstframe)
+ if (bezt->vec[1][0] < animcopy_firstframe) {
animcopy_firstframe = bezt->vec[1][0];
- if (bezt->vec[1][0] > animcopy_lastframe)
+ }
+ if (bezt->vec[1][0] > animcopy_lastframe) {
animcopy_lastframe = bezt->vec[1][0];
+ }
}
}
}
/* check if anything ended up in the buffer */
- if (ELEM(NULL, animcopybuf.first, animcopybuf.last))
+ if (ELEM(NULL, animcopybuf.first, animcopybuf.last)) {
return -1;
+ }
/* in case 'relative' paste method is used */
animcopy_cfra = CFRA;
@@ -762,8 +786,9 @@ static tAnimCopybufItem *pastebuf_match_path_property(Main *bmain,
if (len_id <= len_path) {
/* note, paths which end with "] will fail with this test - Animated ID Props */
if (STREQ(identifier, fcu->rna_path + (len_path - len_id))) {
- if ((from_single) || (aci->array_index == fcu->array_index))
+ if ((from_single) || (aci->array_index == fcu->array_index)) {
break;
+ }
}
}
}
@@ -803,17 +828,21 @@ static void do_curve_mirror_flippping(tAnimCopybufItem *aci, BezTriple *bezt)
if (aci->is_bone) {
const size_t slength = strlen(aci->rna_path);
bool flip = false;
- if (BLI_strn_endswith(aci->rna_path, "location", slength) && aci->array_index == 0)
+ if (BLI_strn_endswith(aci->rna_path, "location", slength) && aci->array_index == 0) {
flip = true;
+ }
else if (BLI_strn_endswith(aci->rna_path, "rotation_quaternion", slength) &&
- ELEM(aci->array_index, 2, 3))
+ ELEM(aci->array_index, 2, 3)) {
flip = true;
+ }
else if (BLI_strn_endswith(aci->rna_path, "rotation_euler", slength) &&
- ELEM(aci->array_index, 1, 2))
+ ELEM(aci->array_index, 1, 2)) {
flip = true;
+ }
else if (BLI_strn_endswith(aci->rna_path, "rotation_axis_angle", slength) &&
- ELEM(aci->array_index, 2, 3))
+ ELEM(aci->array_index, 2, 3)) {
flip = true;
+ }
if (flip) {
bezt->vec[0][1] = -bezt->vec[0][1];
@@ -879,8 +908,9 @@ static void paste_animedit_keys_fcurve(
/* just start pasting, with the first keyframe on the current frame, and so on */
for (i = 0, bezt = aci->bezt; i < aci->totvert; i++, bezt++) {
/* temporarily apply offset to src beztriple while copying */
- if (flip)
+ if (flip) {
do_curve_mirror_flippping(aci, bezt);
+ }
bezt->vec[0][0] += offset;
bezt->vec[1][0] += offset;
@@ -897,8 +927,9 @@ static void paste_animedit_keys_fcurve(
bezt->vec[1][0] -= offset;
bezt->vec[2][0] -= offset;
- if (flip)
+ if (flip) {
do_curve_mirror_flippping(aci, bezt);
+ }
}
/* recalculate F-Curve's handles? */
@@ -1054,8 +1085,9 @@ short paste_animedit_keys(bAnimContext *ac,
}
/* don't continue if some fcurves were pasted */
- if (totmatch)
+ if (totmatch) {
break;
+ }
}
}