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:
Diffstat (limited to 'source/blender/blenkernel/intern/fcurve.c')
-rw-r--r--source/blender/blenkernel/intern/fcurve.c321
1 files changed, 214 insertions, 107 deletions
diff --git a/source/blender/blenkernel/intern/fcurve.c b/source/blender/blenkernel/intern/fcurve.c
index f93a5e65845..f4ac586d9c4 100644
--- a/source/blender/blenkernel/intern/fcurve.c
+++ b/source/blender/blenkernel/intern/fcurve.c
@@ -81,8 +81,9 @@ static CLG_LogRef LOG = {"bke.fcurve"};
/* Frees the F-Curve itself too, so make sure BLI_remlink is called before calling this... */
void free_fcurve(FCurve *fcu)
{
- if (fcu == NULL)
+ if (fcu == NULL) {
return;
+ }
/* free curve data */
MEM_SAFE_FREE(fcu->bezt);
@@ -105,8 +106,9 @@ void free_fcurves(ListBase *list)
FCurve *fcu, *fcn;
/* sanity check */
- if (list == NULL)
+ if (list == NULL) {
return;
+ }
/* free data - no need to call remlink before freeing each curve,
* as we store reference to next, and freeing only touches the curve
@@ -129,8 +131,9 @@ FCurve *copy_fcurve(const FCurve *fcu)
FCurve *fcu_d;
/* sanity check */
- if (fcu == NULL)
+ if (fcu == NULL) {
return NULL;
+ }
/* make a copy */
fcu_d = MEM_dupallocN(fcu);
@@ -161,8 +164,9 @@ void copy_fcurves(ListBase *dst, ListBase *src)
FCurve *dfcu, *sfcu;
/* sanity checks */
- if (ELEM(NULL, dst, src))
+ if (ELEM(NULL, dst, src)) {
return;
+ }
/* clear destination list first */
BLI_listbase_clear(dst);
@@ -189,12 +193,14 @@ FCurve *id_data_find_fcurve(
PropertyRNA *prop;
char *path;
- if (r_driven)
+ if (r_driven) {
*r_driven = false;
+ }
/* only use the current action ??? */
- if (ELEM(NULL, adt, adt->action))
+ if (ELEM(NULL, adt, adt->action)) {
return NULL;
+ }
RNA_pointer_create(id, type, data, &ptr);
prop = RNA_struct_find_property(&ptr, prop_name);
@@ -204,14 +210,16 @@ FCurve *id_data_find_fcurve(
if (path) {
/* animation takes priority over drivers */
- if ((adt->action) && (adt->action->curves.first))
+ if ((adt->action) && (adt->action->curves.first)) {
fcu = list_find_fcurve(&adt->action->curves, path, index);
+ }
/* if not animated, check if driven */
if ((fcu == NULL) && (adt->drivers.first)) {
fcu = list_find_fcurve(&adt->drivers, path, index);
- if (fcu && r_driven)
+ if (fcu && r_driven) {
*r_driven = true;
+ }
fcu = NULL;
}
@@ -228,16 +236,18 @@ FCurve *list_find_fcurve(ListBase *list, const char rna_path[], const int array_
FCurve *fcu;
/* sanity checks */
- if (ELEM(NULL, list, rna_path) || (array_index < 0))
+ if (ELEM(NULL, list, rna_path) || (array_index < 0)) {
return NULL;
+ }
/* check paths of curves, then array indices... */
for (fcu = list->first; fcu; fcu = fcu->next) {
/* simple string-compare (this assumes that they have the same root...) */
if (fcu->rna_path && STREQ(fcu->rna_path, rna_path)) {
/* now check indices */
- if (fcu->array_index == array_index)
+ if (fcu->array_index == array_index) {
return fcu;
+ }
}
}
@@ -251,8 +261,9 @@ FCurve *iter_step_fcurve(FCurve *fcu_iter, const char rna_path[])
FCurve *fcu;
/* sanity checks */
- if (ELEM(NULL, fcu_iter, rna_path))
+ if (ELEM(NULL, fcu_iter, rna_path)) {
return NULL;
+ }
/* check paths of curves, then array indices... */
for (fcu = fcu_iter; fcu; fcu = fcu->next) {
@@ -284,10 +295,12 @@ int list_find_data_fcurves(ListBase *dst,
int matches = 0;
/* sanity checks */
- if (ELEM(NULL, dst, src, dataPrefix, dataName))
+ if (ELEM(NULL, dst, src, dataPrefix, dataName)) {
return 0;
- else if ((dataPrefix[0] == 0) || (dataName[0] == 0))
+ }
+ else if ((dataPrefix[0] == 0) || (dataName[0] == 0)) {
return 0;
+ }
/* search each F-Curve one by one */
for (fcu = src->first; fcu; fcu = fcu->next) {
@@ -343,10 +356,12 @@ FCurve *rna_get_fcurve_context_ui(bContext *C,
*r_driven = false;
*r_special = false;
- if (r_animdata)
+ if (r_animdata) {
*r_animdata = NULL;
- if (r_action)
+ }
+ if (r_action) {
*r_action = NULL;
+ }
/* Special case for NLA Control Curves... */
if (BKE_nlastrip_has_curves_for_property(ptr, prop)) {
@@ -390,8 +405,9 @@ FCurve *rna_get_fcurve_context_ui(bContext *C,
if (adt->action && adt->action->curves.first) {
fcu = list_find_fcurve(&adt->action->curves, path, rnaindex);
- if (fcu && r_action)
+ if (fcu && r_action) {
*r_action = adt->action;
+ }
}
/* if not animated, check if driven */
@@ -399,15 +415,17 @@ FCurve *rna_get_fcurve_context_ui(bContext *C,
fcu = list_find_fcurve(&adt->drivers, path, rnaindex);
if (fcu) {
- if (r_animdata)
+ if (r_animdata) {
*r_animdata = adt;
+ }
*r_driven = true;
}
}
if (fcu && r_action) {
- if (r_animdata)
+ if (r_animdata) {
*r_animdata = adt;
+ }
*r_action = adt->action;
break;
}
@@ -463,8 +481,9 @@ static int binarysearch_bezt_index_ex(
*r_replace = true;
return 0;
}
- else if (frame < framenum)
+ else if (frame < framenum) {
return 0;
+ }
/* 'Last' Keyframe */
framenum = array[(arraylen - 1)].vec[1][0];
@@ -472,8 +491,9 @@ static int binarysearch_bezt_index_ex(
*r_replace = true;
return (arraylen - 1);
}
- else if (frame > framenum)
+ else if (frame > framenum) {
return arraylen;
+ }
}
/* most of the time, this loop is just to find where to put it
@@ -492,10 +512,12 @@ static int binarysearch_bezt_index_ex(
}
/* repeat in upper/lower half */
- if (frame > midfra)
+ if (frame > midfra) {
start = mid + 1;
- else if (frame < midfra)
+ }
+ else if (frame < midfra) {
end = mid - 1;
+ }
}
/* print error if loop-limit exceeded */
@@ -539,8 +561,9 @@ static short get_fcurve_end_keyframes(FCurve *fcu,
*last = NULL;
/* sanity checks */
- if (fcu->bezt == NULL)
+ if (fcu->bezt == NULL) {
return found;
+ }
/* only include selected items? */
if (do_sel_only) {
@@ -656,10 +679,12 @@ bool calc_fcurve_bounds(FCurve *fcu,
FPoint *fpt;
for (fpt = fcu->fpt, i = 0; i < fcu->totvert; fpt++, i++) {
- if (fpt->vec[1] < yminv)
+ if (fpt->vec[1] < yminv) {
yminv = fpt->vec[1];
- if (fpt->vec[1] > ymaxv)
+ }
+ if (fpt->vec[1] > ymaxv) {
ymaxv = fpt->vec[1];
+ }
foundvert = true;
}
@@ -668,29 +693,38 @@ bool calc_fcurve_bounds(FCurve *fcu,
}
if (foundvert) {
- if (xmin)
+ if (xmin) {
*xmin = xminv;
- if (xmax)
+ }
+ if (xmax) {
*xmax = xmaxv;
+ }
- if (ymin)
+ if (ymin) {
*ymin = yminv;
- if (ymax)
+ }
+ if (ymax) {
*ymax = ymaxv;
+ }
}
else {
- if (G.debug & G_DEBUG)
+ if (G.debug & G_DEBUG) {
printf("F-Curve calc bounds didn't find anything, so assuming minimum bounds of 1.0\n");
+ }
- if (xmin)
+ if (xmin) {
*xmin = 0.0f;
- if (xmax)
+ }
+ if (xmax) {
*xmax = 1.0f;
+ }
- if (ymin)
+ if (ymin) {
*ymin = 0.0f;
- if (ymax)
+ }
+ if (ymax) {
*ymax = 1.0f;
+ }
}
return foundvert;
@@ -753,12 +787,14 @@ bool calc_fcurve_range(
bool fcurve_are_keyframes_usable(FCurve *fcu)
{
/* F-Curve must exist */
- if (fcu == NULL)
+ if (fcu == NULL) {
return false;
+ }
/* F-Curve must not have samples - samples are mutually exclusive of keyframes */
- if (fcu->fpt)
+ if (fcu->fpt) {
return false;
+ }
/* if it has modifiers, none of these should "drastically" alter the curve */
if (fcu->modifiers.first) {
@@ -768,8 +804,9 @@ bool fcurve_are_keyframes_usable(FCurve *fcu)
/* TODO: optionally, only check modifier if it is the active one... */
for (fcm = fcu->modifiers.last; fcm; fcm = fcm->prev) {
/* ignore if muted/disabled */
- if (fcm->flag & (FMODIFIER_FLAG_DISABLED | FMODIFIER_FLAG_MUTED))
+ if (fcm->flag & (FMODIFIER_FLAG_DISABLED | FMODIFIER_FLAG_MUTED)) {
continue;
+ }
/* type checks */
switch (fcm->type) {
@@ -783,15 +820,17 @@ bool fcurve_are_keyframes_usable(FCurve *fcu)
case FMODIFIER_TYPE_GENERATOR: {
FMod_Generator *data = (FMod_Generator *)fcm->data;
- if ((data->flag & FCM_GENERATOR_ADDITIVE) == 0)
+ if ((data->flag & FCM_GENERATOR_ADDITIVE) == 0) {
return false;
+ }
break;
}
case FMODIFIER_TYPE_FN_GENERATOR: {
FMod_FunctionGenerator *data = (FMod_FunctionGenerator *)fcm->data;
- if ((data->flag & FCM_GENERATOR_ADDITIVE) == 0)
+ if ((data->flag & FCM_GENERATOR_ADDITIVE) == 0) {
return false;
+ }
break;
}
/* always harmful - cannot allow */
@@ -816,12 +855,14 @@ bool BKE_fcurve_is_protected(FCurve *fcu)
bool fcurve_is_keyframable(FCurve *fcu)
{
/* F-Curve's keyframes must be "usable" (i.e. visible + have an effect on final result) */
- if (fcurve_are_keyframes_usable(fcu) == 0)
+ if (fcurve_are_keyframes_usable(fcu) == 0) {
return false;
+ }
/* F-Curve must currently be editable too */
- if (BKE_fcurve_is_protected(fcu))
+ if (BKE_fcurve_is_protected(fcu)) {
return false;
+ }
/* F-Curve is keyframable */
return true;
@@ -837,21 +878,25 @@ void bezt_add_to_cfra_elem(ListBase *lb, BezTriple *bezt)
for (ce = lb->first; ce; ce = ce->next) {
/* double key? */
if (IS_EQT(ce->cfra, bezt->vec[1][0], BEZT_BINARYSEARCH_THRESH)) {
- if (bezt->f2 & SELECT)
+ if (bezt->f2 & SELECT) {
ce->sel = bezt->f2;
+ }
return;
}
/* should key be inserted before this column? */
- else if (ce->cfra > bezt->vec[1][0])
+ else if (ce->cfra > bezt->vec[1][0]) {
break;
+ }
}
/* create a new column */
cen = MEM_callocN(sizeof(CfraElem), "add_to_cfra_elem");
- if (ce)
+ if (ce) {
BLI_insertlinkbefore(lb, ce, cen);
- else
+ }
+ else {
BLI_addtail(lb, cen);
+ }
cen->cfra = bezt->vec[1][0];
cen->sel = bezt->f2;
@@ -901,10 +946,12 @@ void fcurve_store_samples(FCurve *fcu, void *data, int start, int end, FcuSample
}
/* free any existing sample/keyframe data on curve */
- if (fcu->bezt)
+ if (fcu->bezt) {
MEM_freeN(fcu->bezt);
- if (fcu->fpt)
+ }
+ if (fcu->fpt) {
MEM_freeN(fcu->fpt);
+ }
/* store the samples */
fcu->bezt = NULL;
@@ -964,16 +1011,18 @@ bool BKE_fcurve_is_cyclic(FCurve *fcu)
static BezTriple *cycle_offset_triple(
bool cycle, BezTriple *out, const BezTriple *in, const BezTriple *from, const BezTriple *to)
{
- if (!cycle)
+ if (!cycle) {
return NULL;
+ }
memcpy(out, in, sizeof(BezTriple));
float delta[3];
sub_v3_v3v3(delta, to->vec[1], from->vec[1]);
- for (int i = 0; i < 3; i++)
+ for (int i = 0; i < 3; i++) {
add_v3_v3(out->vec[i], delta);
+ }
return out;
}
@@ -991,8 +1040,9 @@ void calchandles_fcurve(FCurve *fcu)
* - need bezier keys
* - only bezier-interpolation has handles (for now)
*/
- if (ELEM(NULL, fcu, fcu->bezt) || (a < 2) /*|| ELEM(fcu->ipo, BEZT_IPO_CONST, BEZT_IPO_LIN)*/)
+ if (ELEM(NULL, fcu, fcu->bezt) || (a < 2) /*|| ELEM(fcu->ipo, BEZT_IPO_CONST, BEZT_IPO_LIN)*/) {
return;
+ }
/* if the first modifier is Cycles, smooth the curve through the cycle */
BezTriple *first = &fcu->bezt[0], *last = &fcu->bezt[fcu->totvert - 1];
@@ -1008,10 +1058,12 @@ void calchandles_fcurve(FCurve *fcu)
/* loop over all beztriples, adjusting handles */
while (a--) {
/* clamp timing of handles to be on either side of beztriple */
- if (bezt->vec[0][0] > bezt->vec[1][0])
+ if (bezt->vec[0][0] > bezt->vec[1][0]) {
bezt->vec[0][0] = bezt->vec[1][0];
- if (bezt->vec[2][0] < bezt->vec[1][0])
+ }
+ if (bezt->vec[2][0] < bezt->vec[1][0]) {
bezt->vec[2][0] = bezt->vec[1][0];
+ }
/* calculate auto-handles */
BKE_nurb_handle_calc(bezt, prev, next, true, fcu->auto_smoothing);
@@ -1066,8 +1118,9 @@ void testhandles_fcurve(FCurve *fcu, const bool use_handle)
unsigned int a;
/* only beztriples have handles (bpoints don't though) */
- if (ELEM(NULL, fcu, fcu->bezt))
+ if (ELEM(NULL, fcu, fcu->bezt)) {
return;
+ }
/* loop over beztriples */
for (a = 0, bezt = fcu->bezt; a < fcu->totvert; a++, bezt++) {
@@ -1126,8 +1179,9 @@ short test_time_fcurve(FCurve *fcu)
unsigned int a;
/* sanity checks */
- if (fcu == NULL)
+ if (fcu == NULL) {
return 0;
+ }
/* currently, only need to test beztriples */
if (fcu->bezt) {
@@ -1135,8 +1189,9 @@ short test_time_fcurve(FCurve *fcu)
/* loop through all BezTriples, stopping when one exceeds the one after it */
for (a = 0, bezt = fcu->bezt; a < (fcu->totvert - 1); a++, bezt++) {
- if (bezt->vec[1][0] > (bezt + 1)->vec[1][0])
+ if (bezt->vec[1][0] > (bezt + 1)->vec[1][0]) {
return 1;
+ }
}
}
else if (fcu->fpt) {
@@ -1144,8 +1199,9 @@ short test_time_fcurve(FCurve *fcu)
/* loop through all FPoints, stopping when one exceeds the one after it */
for (a = 0, fpt = fcu->fpt; a < (fcu->totvert - 1); a++, fpt++) {
- if (fpt->vec[0] > (fpt + 1)->vec[0])
+ if (fpt->vec[0] > (fpt + 1)->vec[0]) {
return 1;
+ }
}
}
@@ -1178,8 +1234,9 @@ typedef struct DriverVarTypeInfo {
static ID *dtar_id_ensure_proxy_from(ID *id)
{
- if (id && GS(id->name) == ID_OB && ((Object *)id)->proxy_from)
+ if (id && GS(id->name) == ID_OB && ((Object *)id)->proxy_from) {
return (ID *)(((Object *)id)->proxy_from);
+ }
return id;
}
@@ -1193,8 +1250,9 @@ static float dtar_get_prop_val(ChannelDriver *driver, DriverTarget *dtar)
float value = 0.0f;
/* sanity check */
- if (ELEM(NULL, driver, dtar))
+ if (ELEM(NULL, driver, dtar)) {
return 0.0f;
+ }
id = dtar_id_ensure_proxy_from(dtar->id);
@@ -1301,8 +1359,9 @@ bool driver_get_variable_property(ChannelDriver *driver,
int index = -1;
/* sanity check */
- if (ELEM(NULL, driver, dtar))
+ if (ELEM(NULL, driver, dtar)) {
return false;
+ }
id = dtar_id_ensure_proxy_from(dtar->id);
@@ -1703,10 +1762,12 @@ static DriverVarTypeInfo dvar_types[MAX_DVAR_TYPES] = {
static const DriverVarTypeInfo *get_dvar_typeinfo(int type)
{
/* check if valid type */
- if ((type >= 0) && (type < MAX_DVAR_TYPES))
+ if ((type >= 0) && (type < MAX_DVAR_TYPES)) {
return &dvar_types[type];
- else
+ }
+ else {
return NULL;
+ }
}
/* Driver API --------------------------------- */
@@ -1715,8 +1776,9 @@ static const DriverVarTypeInfo *get_dvar_typeinfo(int type)
void driver_free_variable(ListBase *variables, DriverVar *dvar)
{
/* sanity checks */
- if (dvar == NULL)
+ if (dvar == NULL) {
return;
+ }
/* free target vars
* - need to go over all of them, not just up to the ones that are used
@@ -1725,8 +1787,9 @@ void driver_free_variable(ListBase *variables, DriverVar *dvar)
*/
DRIVER_TARGETS_LOOPER_BEGIN (dvar) {
/* free RNA path if applicable */
- if (dtar->rna_path)
+ if (dtar->rna_path) {
MEM_freeN(dtar->rna_path);
+ }
}
DRIVER_TARGETS_LOOPER_END;
@@ -1754,8 +1817,9 @@ void driver_variables_copy(ListBase *dst_vars, const ListBase *src_vars)
/* need to go over all targets so that we don't leave any dangling paths */
DRIVER_TARGETS_LOOPER_BEGIN (dvar) {
/* make a copy of target's rna path if available */
- if (dtar->rna_path)
+ if (dtar->rna_path) {
dtar->rna_path = MEM_dupallocN(dtar->rna_path);
+ }
}
DRIVER_TARGETS_LOOPER_END;
}
@@ -1767,8 +1831,9 @@ void driver_change_variable_type(DriverVar *dvar, int type)
const DriverVarTypeInfo *dvti = get_dvar_typeinfo(type);
/* sanity check */
- if (ELEM(NULL, dvar, dvti))
+ if (ELEM(NULL, dvar, dvti)) {
return;
+ }
/* set the new settings */
dvar->type = type;
@@ -1784,8 +1849,9 @@ void driver_change_variable_type(DriverVar *dvar, int type)
dtar->flag = flags;
/* object ID types only, or idtype not yet initialized */
- if ((flags & DTAR_FLAG_ID_OB_ONLY) || (dtar->idtype == 0))
+ if ((flags & DTAR_FLAG_ID_OB_ONLY) || (dtar->idtype == 0)) {
dtar->idtype = ID_OB;
+ }
}
DRIVER_TARGETS_LOOPER_END;
}
@@ -1800,8 +1866,9 @@ void driver_variable_name_validate(DriverVar *dvar)
};
/* sanity checks */
- if (dvar == NULL)
+ if (dvar == NULL) {
return;
+ }
/* clear all invalid-name flags */
dvar->flag &= ~DVAR_ALL_INVALID_FLAGS;
@@ -1833,10 +1900,12 @@ void driver_variable_name_validate(DriverVar *dvar)
for (int i = 0; i < sizeof(special_char_blacklist); i++) {
char *match = strchr(dvar->name, special_char_blacklist[i]);
- if (match == dvar->name)
+ if (match == dvar->name) {
dvar->flag |= DVAR_FLAG_INVALID_START_CHAR;
- else if (match != NULL)
+ }
+ else if (match != NULL) {
dvar->flag |= DVAR_FLAG_INVALID_HAS_SPECIAL;
+ }
}
/* 4) Check if the name is a reserved keyword
@@ -1850,8 +1919,9 @@ void driver_variable_name_validate(DriverVar *dvar)
#endif
/* If any these conditions match, the name is invalid */
- if (dvar->flag & DVAR_ALL_INVALID_FLAGS)
+ if (dvar->flag & DVAR_ALL_INVALID_FLAGS) {
dvar->flag |= DVAR_FLAG_INVALID_NAME;
+ }
}
/* Add a new driver variable */
@@ -1860,8 +1930,9 @@ DriverVar *driver_add_new_variable(ChannelDriver *driver)
DriverVar *dvar;
/* sanity checks */
- if (driver == NULL)
+ if (driver == NULL) {
return NULL;
+ }
/* make a new variable */
dvar = MEM_callocN(sizeof(DriverVar), "DriverVar");
@@ -1893,8 +1964,9 @@ void fcurve_free_driver(FCurve *fcu)
DriverVar *dvar, *dvarn;
/* sanity checks */
- if (ELEM(NULL, fcu, fcu->driver))
+ if (ELEM(NULL, fcu, fcu->driver)) {
return;
+ }
driver = fcu->driver;
/* free driver targets */
@@ -1905,8 +1977,9 @@ void fcurve_free_driver(FCurve *fcu)
#ifdef WITH_PYTHON
/* free compiled driver expression */
- if (driver->expr_comp)
+ if (driver->expr_comp) {
BPY_DECREF(driver->expr_comp);
+ }
#endif
BLI_expr_pylike_free(driver->expr_simple);
@@ -1922,8 +1995,9 @@ ChannelDriver *fcurve_copy_driver(const ChannelDriver *driver)
ChannelDriver *ndriver;
/* sanity checks */
- if (driver == NULL)
+ if (driver == NULL) {
return NULL;
+ }
/* copy all data */
ndriver = MEM_dupallocN(driver);
@@ -2074,8 +2148,9 @@ float driver_get_variable_value(ChannelDriver *driver, DriverVar *dvar)
const DriverVarTypeInfo *dvti;
/* sanity check */
- if (ELEM(NULL, driver, dvar))
+ if (ELEM(NULL, driver, dvar)) {
return 0.0f;
+ }
/* call the relevant callbacks to get the variable value
* using the variable type info, storing the obtained value
@@ -2083,10 +2158,12 @@ float driver_get_variable_value(ChannelDriver *driver, DriverVar *dvar)
*/
dvti = get_dvar_typeinfo(dvar->type);
- if (dvti && dvti->get_value)
+ if (dvti && dvti->get_value) {
dvar->curval = dvti->get_value(driver, dvar);
- else
+ }
+ else {
dvar->curval = 0.0f;
+ }
return dvar->curval;
}
@@ -2104,8 +2181,9 @@ float evaluate_driver(PathResolvedRNA *anim_rna,
DriverVar *dvar;
/* check if driver can be evaluated */
- if (driver_orig->flag & DRIVER_FLAG_INVALID)
+ if (driver_orig->flag & DRIVER_FLAG_INVALID) {
return 0.0f;
+ }
switch (driver->type) {
case DRIVER_TYPE_AVERAGE: /* average values of driver targets */
@@ -2129,10 +2207,12 @@ float evaluate_driver(PathResolvedRNA *anim_rna,
}
/* perform operations on the total if appropriate */
- if (driver->type == DRIVER_TYPE_AVERAGE)
+ if (driver->type == DRIVER_TYPE_AVERAGE) {
driver->curval = tot ? (value / (float)tot) : 0.0f;
- else
+ }
+ else {
driver->curval = value;
+ }
}
break;
}
@@ -2151,13 +2231,15 @@ float evaluate_driver(PathResolvedRNA *anim_rna,
/* check if greater/smaller than the baseline */
if (driver->type == DRIVER_TYPE_MAX) {
/* max? */
- if (tmp_val > value)
+ if (tmp_val > value) {
value = tmp_val;
+ }
}
else {
/* min? */
- if (tmp_val < value)
+ if (tmp_val < value) {
value = tmp_val;
+ }
}
}
else {
@@ -2232,8 +2314,9 @@ void correct_bezpart(float v1[2], float v2[2], float v3[2], float v4[2])
len2 = fabsf(h2[0]);
/* if the handles have no length, no need to do any corrections */
- if ((len1 + len2) == 0.0f)
+ if ((len1 + len2) == 0.0f) {
return;
+ }
/* the two handles cross over each other, so force them
* apart using the proportion they overlap
@@ -2274,23 +2357,28 @@ static int findzero(float x, float q0, float q1, float q2, float q3, float *o)
t = sqrt(d);
o[0] = (float)(sqrt3d(-q + t) + sqrt3d(-q - t) - a);
- if ((o[0] >= (float)SMALL) && (o[0] <= 1.000001f))
+ if ((o[0] >= (float)SMALL) && (o[0] <= 1.000001f)) {
return 1;
- else
+ }
+ else {
return 0;
+ }
}
else if (d == 0.0) {
t = sqrt3d(-q);
o[0] = (float)(2 * t - a);
- if ((o[0] >= (float)SMALL) && (o[0] <= 1.000001f))
+ if ((o[0] >= (float)SMALL) && (o[0] <= 1.000001f)) {
nr++;
+ }
o[nr] = (float)(-t - a);
- if ((o[nr] >= (float)SMALL) && (o[nr] <= 1.000001f))
+ if ((o[nr] >= (float)SMALL) && (o[nr] <= 1.000001f)) {
return nr + 1;
- else
+ }
+ else {
return nr;
+ }
}
else {
phi = acos(-q / sqrt(-(p * p * p)));
@@ -2299,18 +2387,22 @@ static int findzero(float x, float q0, float q1, float q2, float q3, float *o)
q = sqrt(3 - 3 * p * p);
o[0] = (float)(2 * t * p - a);
- if ((o[0] >= (float)SMALL) && (o[0] <= 1.000001f))
+ if ((o[0] >= (float)SMALL) && (o[0] <= 1.000001f)) {
nr++;
+ }
o[nr] = (float)(-t * (p + q) - a);
- if ((o[nr] >= (float)SMALL) && (o[nr] <= 1.000001f))
+ if ((o[nr] >= (float)SMALL) && (o[nr] <= 1.000001f)) {
nr++;
+ }
o[nr] = (float)(-t * (p - q) - a);
- if ((o[nr] >= (float)SMALL) && (o[nr] <= 1.000001f))
+ if ((o[nr] >= (float)SMALL) && (o[nr] <= 1.000001f)) {
return nr + 1;
- else
+ }
+ else {
return nr;
+ }
}
}
else {
@@ -2326,30 +2418,37 @@ static int findzero(float x, float q0, float q1, float q2, float q3, float *o)
p = sqrt(p);
o[0] = (float)((-b - p) / (2 * a));
- if ((o[0] >= (float)SMALL) && (o[0] <= 1.000001f))
+ if ((o[0] >= (float)SMALL) && (o[0] <= 1.000001f)) {
nr++;
+ }
o[nr] = (float)((-b + p) / (2 * a));
- if ((o[nr] >= (float)SMALL) && (o[nr] <= 1.000001f))
+ if ((o[nr] >= (float)SMALL) && (o[nr] <= 1.000001f)) {
return nr + 1;
- else
+ }
+ else {
return nr;
+ }
}
else if (p == 0) {
o[0] = (float)(-b / (2 * a));
- if ((o[0] >= (float)SMALL) && (o[0] <= 1.000001f))
+ if ((o[0] >= (float)SMALL) && (o[0] <= 1.000001f)) {
return 1;
- else
+ }
+ else {
return 0;
+ }
}
}
else if (b != 0.0) {
o[0] = (float)(-c / b);
- if ((o[0] >= (float)SMALL) && (o[0] <= 1.000001f))
+ if ((o[0] >= (float)SMALL) && (o[0] <= 1.000001f)) {
return 1;
- else
+ }
+ else {
return 0;
+ }
}
else if (c == 0.0) {
o[0] = 0.0;
@@ -2509,9 +2608,10 @@ static float fcurve_eval_keyframes(FCurve *fcu, BezTriple *bezts, float evaltime
* This lower bound was established in b888a32eee8147b028464336ad2404d8155c64dd
*/
a = binarysearch_bezt_index_ex(bezts, evaltime, fcu->totvert, 0.0001, &exact);
- if (G.debug & G_DEBUG)
+ if (G.debug & G_DEBUG) {
printf(
"eval fcurve '%s' - %f => %u/%u, %d\n", fcu->rna_path, evaltime, a, fcu->totvert, exact);
+ }
if (exact) {
/* index returned must be interpreted differently when it sits on top of an existing keyframe
@@ -2586,13 +2686,14 @@ static float fcurve_eval_keyframes(FCurve *fcu, BezTriple *bezts, float evaltime
/* break; */
}
else {
- if (G.debug & G_DEBUG)
+ if (G.debug & G_DEBUG) {
printf(" ERROR: findzero() failed at %f with %f %f %f %f\n",
evaltime,
v1[0],
v2[0],
v3[0],
v4[0]);
+ }
}
}
break;
@@ -2795,12 +2896,13 @@ static float fcurve_eval_keyframes(FCurve *fcu, BezTriple *bezts, float evaltime
}
}
else {
- if (G.debug & G_DEBUG)
+ if (G.debug & G_DEBUG) {
printf(" ERROR: failed eval - p=%f b=%f, t=%f (%f)\n",
prevbezt->vec[1][0],
bezt->vec[1][0],
evaltime,
fabsf(bezt->vec[1][0] - evaltime));
+ }
}
}
@@ -2834,10 +2936,12 @@ static float fcurve_eval_samples(FCurve *fcu, FPoint *fpts, float evaltime)
fpt = prevfpt + ((int)evaltime - (int)prevfpt->vec[0]);
/* if not exactly on the frame, perform linear interpolation with the next one */
- if ((t != 0.0f) && (t < 1.0f))
+ if ((t != 0.0f) && (t < 1.0f)) {
cvalue = interpf(fpt->vec[1], (fpt + 1)->vec[1], 1.0f - t);
- else
+ }
+ else {
cvalue = fpt->vec[1];
+ }
}
/* return value */
@@ -2865,10 +2969,12 @@ static float evaluate_fcurve_ex(FCurve *fcu, float evaltime, float cvalue)
* - 'devaltime' instead of 'evaltime', as this is the time that the last time-modifying
* F-Curve modifier on the stack requested the curve to be evaluated at
*/
- if (fcu->bezt)
+ if (fcu->bezt) {
cvalue = fcurve_eval_keyframes(fcu, fcu->bezt, devaltime);
- else if (fcu->fpt)
+ }
+ else if (fcu->fpt) {
cvalue = fcurve_eval_samples(fcu, fcu->fpt, devaltime);
+ }
/* evaluate modifiers */
evaluate_value_fmodifiers(&storage, &fcu->modifiers, fcu, &cvalue, devaltime);
@@ -2876,8 +2982,9 @@ static float evaluate_fcurve_ex(FCurve *fcu, float evaltime, float cvalue)
/* if curve can only have integral values, perform truncation (i.e. drop the decimal part)
* here so that the curve can be sampled correctly
*/
- if (fcu->flag & FCURVE_INT_VALUES)
+ if (fcu->flag & FCURVE_INT_VALUES) {
cvalue = floorf(cvalue + 0.5f);
+ }
/* return evaluated value */
return cvalue;