diff options
author | Campbell Barton <ideasman42@gmail.com> | 2018-06-17 18:05:51 +0300 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2018-06-17 18:05:51 +0300 |
commit | 6fc8a74886a30f89562bb542ef3b24cc64b3208a (patch) | |
tree | df0503b6cf4f6b762eca66b90f4360c495d624aa /source/blender/blenkernel/intern/fmodifier.c | |
parent | a262ea8c47f8106f66e16935c556f383ef306861 (diff) |
Cleanup: trailing space for blenkernel
Diffstat (limited to 'source/blender/blenkernel/intern/fmodifier.c')
-rw-r--r-- | source/blender/blenkernel/intern/fmodifier.c | 298 |
1 files changed, 149 insertions, 149 deletions
diff --git a/source/blender/blenkernel/intern/fmodifier.c b/source/blender/blenkernel/intern/fmodifier.c index f3d0a5fe085..b69bce088d2 100644 --- a/source/blender/blenkernel/intern/fmodifier.c +++ b/source/blender/blenkernel/intern/fmodifier.c @@ -67,7 +67,7 @@ void *fmodifiers_storage_get(FModifierStackStorage *storage, FModifier *fcm); * times. In addition to this, each modifier should have a type-info struct, where * its functions are attached for use. */ - + /* Template for type-info data: * - make a copy of this when creating new modifiers, and just change the functions * pointed to as necessary @@ -110,7 +110,7 @@ static FModifierTypeInfo FMI_MODNAME = { static void fcm_generator_free(FModifier *fcm) { FMod_Generator *data = (FMod_Generator *)fcm->data; - + /* free polynomial coefficients array */ if (data->coefficients) MEM_freeN(data->coefficients); @@ -120,7 +120,7 @@ static void fcm_generator_copy(FModifier *fcm, const FModifier *src) { FMod_Generator *gen = (FMod_Generator *)fcm->data; FMod_Generator *ogen = (FMod_Generator *)src->data; - + /* copy coefficients array? */ if (ogen->coefficients) gen->coefficients = MEM_dupallocN(ogen->coefficients); @@ -130,19 +130,19 @@ static void fcm_generator_new_data(void *mdata) { FMod_Generator *data = (FMod_Generator *)mdata; float *cp; - + /* set default generator to be linear 0-1 (gradient = 1, y-offset = 0) */ data->poly_order = 1; data->arraysize = 2; cp = data->coefficients = MEM_callocN(sizeof(float) * 2, "FMod_Generator_Coefs"); - cp[0] = 0; // y-offset + cp[0] = 0; // y-offset cp[1] = 1; // gradient } static void fcm_generator_verify(FModifier *fcm) { FMod_Generator *data = (FMod_Generator *)fcm->data; - + /* requirements depend on mode */ switch (data->mode) { case FCM_GENERATOR_POLYNOMIAL: /* expanded polynomial expression */ @@ -173,8 +173,8 @@ static void fcm_generator_verify(FModifier *fcm) static void fcm_generator_evaluate(FCurve *UNUSED(fcu), FModifier *fcm, float *cvalue, float evaltime) { FMod_Generator *data = (FMod_Generator *)fcm->data; - - /* behavior depends on mode + + /* behavior depends on mode * NOTE: the data in its default state is fine too */ switch (data->mode) { @@ -184,8 +184,8 @@ static void fcm_generator_evaluate(FCurve *UNUSED(fcu), FModifier *fcm, float *c float *powers = MEM_callocN(sizeof(float) * data->arraysize, "Poly Powers"); float value = 0.0f; unsigned int i; - - /* for each x^n, precalculate value based on previous one first... this should be + + /* for each x^n, precalculate value based on previous one first... this should be * faster that calling pow() for each entry */ for (i = 0; i < data->arraysize; i++) { @@ -195,11 +195,11 @@ static void fcm_generator_evaluate(FCurve *UNUSED(fcu), FModifier *fcm, float *c else powers[0] = 1; } - + /* for each coefficient, add to value, which we'll write to *cvalue in one go */ for (i = 0; i < data->arraysize; i++) value += data->coefficients[i] * powers[i]; - + /* only if something changed, write *cvalue in one go */ if (data->poly_order) { if (data->flag & FCM_GENERATOR_ADDITIVE) @@ -207,9 +207,9 @@ static void fcm_generator_evaluate(FCurve *UNUSED(fcu), FModifier *fcm, float *c else *cvalue = value; } - + /* cleanup */ - if (powers) + if (powers) MEM_freeN(powers); break; } @@ -217,11 +217,11 @@ static void fcm_generator_evaluate(FCurve *UNUSED(fcu), FModifier *fcm, float *c { float value = 1.0f, *cp = NULL; unsigned int i; - + /* for each coefficient pair, solve for that bracket before accumulating in value by multiplying */ for (cp = data->coefficients, i = 0; (cp) && (i < (unsigned int)data->poly_order); cp += 2, i++) value *= (cp[0] * evaltime + cp[1]); - + /* only if something changed, write *cvalue in one go */ if (data->poly_order) { if (data->flag & FCM_GENERATOR_ADDITIVE) @@ -266,7 +266,7 @@ static FModifierTypeInfo FMI_GENERATOR = { static void fcm_fn_generator_new_data(void *mdata) { FMod_FunctionGenerator *data = (FMod_FunctionGenerator *)mdata; - + /* set amplitude and phase multiplier to 1.0f so that something is generated */ data->amplitude = 1.0f; data->phase_multiplier = 1.0f; @@ -289,9 +289,9 @@ static void fcm_fn_generator_evaluate(FCurve *UNUSED(fcu), FModifier *fcm, float FMod_FunctionGenerator *data = (FMod_FunctionGenerator *)fcm->data; double arg = data->phase_multiplier * evaltime + data->phase_offset; double (*fn)(double v) = NULL; - + /* get function pointer to the func to use: - * WARNING: must perform special argument validation hereto guard against crashes + * WARNING: must perform special argument validation hereto guard against crashes */ switch (data->type) { /* simple ones */ @@ -304,7 +304,7 @@ static void fcm_fn_generator_evaluate(FCurve *UNUSED(fcu), FModifier *fcm, float case FCM_GENERATOR_FN_SINC: /* normalized sine wave */ fn = sinc; break; - + /* validation required */ case FCM_GENERATOR_FN_TAN: /* tangent wave */ { @@ -346,11 +346,11 @@ static void fcm_fn_generator_evaluate(FCurve *UNUSED(fcu), FModifier *fcm, float break; } - + /* execute function callback to set value if appropriate */ if (fn) { float value = (float)(data->amplitude * (float)fn(arg) + data->value_offset); - + if (data->flag & FCM_GENERATOR_ADDITIVE) *cvalue += value; else @@ -380,7 +380,7 @@ static FModifierTypeInfo FMI_FN_GENERATOR = { static void fcm_envelope_free(FModifier *fcm) { FMod_Envelope *env = (FMod_Envelope *)fcm->data; - + /* free envelope data array */ if (env->data) MEM_freeN(env->data); @@ -390,7 +390,7 @@ static void fcm_envelope_copy(FModifier *fcm, const FModifier *src) { FMod_Envelope *env = (FMod_Envelope *)fcm->data; FMod_Envelope *oenv = (FMod_Envelope *)src->data; - + /* copy envelope data array */ if (oenv->data) env->data = MEM_dupallocN(oenv->data); @@ -399,7 +399,7 @@ static void fcm_envelope_copy(FModifier *fcm, const FModifier *src) static void fcm_envelope_new_data(void *mdata) { FMod_Envelope *env = (FMod_Envelope *)mdata; - + /* set default min/max ranges */ env->min = -1.0f; env->max = 1.0f; @@ -408,7 +408,7 @@ static void fcm_envelope_new_data(void *mdata) static void fcm_envelope_verify(FModifier *fcm) { FMod_Envelope *env = (FMod_Envelope *)fcm->data; - + /* if the are points, perform bubble-sort on them, as user may have changed the order */ if (env->data) { /* XXX todo... */ @@ -421,13 +421,13 @@ static void fcm_envelope_evaluate(FCurve *UNUSED(fcu), FModifier *fcm, float *cv FCM_EnvelopeData *fed, *prevfed, *lastfed; float min = 0.0f, max = 0.0f, fac = 0.0f; int a; - + /* get pointers */ if (env->data == NULL) return; prevfed = env->data; fed = prevfed + 1; lastfed = prevfed + (env->totvert - 1); - + /* get min/max values for envelope at evaluation time (relative to mid-value) */ if (prevfed->time >= evaltime) { /* before or on first sample, so just extend value */ @@ -446,20 +446,20 @@ static void fcm_envelope_evaluate(FCurve *UNUSED(fcu), FModifier *fcm, float *cv /* evaltime occurs within the interval defined by these two envelope points */ if ((prevfed->time <= evaltime) && (fed->time >= evaltime)) { float afac, bfac, diff; - + diff = fed->time - prevfed->time; afac = (evaltime - prevfed->time) / diff; bfac = (fed->time - evaltime) / diff; - + min = bfac * prevfed->min + afac * fed->min; max = bfac * prevfed->max + afac * fed->max; - + break; } } } - - /* adjust *cvalue + + /* adjust *cvalue * - fac is the ratio of how the current y-value corresponds to the reference range * - thus, the new value is found by mapping the old range to the new! */ @@ -572,7 +572,7 @@ int BKE_fcm_envelope_find_index(FCM_EnvelopeData array[], float frame, int array /* Cycles F-Curve Modifier --------------------------- */ -/* This modifier changes evaltime to something that exists within the curve's frame-range, +/* This modifier changes evaltime to something that exists within the curve's frame-range, * then re-evaluates modifier stack up to this point using the new time. This re-entrant behavior * is very likely to be more time-consuming than the original approach... (which was tightly integrated into * the calculation code...). @@ -588,11 +588,11 @@ int BKE_fcm_envelope_find_index(FCM_EnvelopeData array[], float frame, int array typedef struct tFCMED_Cycles { float cycyofs; /* y-offset to apply */ } tFCMED_Cycles; - + static void fcm_cycles_new_data(void *mdata) { FMod_Cycles *data = (FMod_Cycles *)mdata; - + /* turn on cycles by default */ data->before_mode = data->after_mode = FCM_EXTRAPOLATE_CYCLIC; } @@ -605,38 +605,38 @@ static float fcm_cycles_time(FModifierStackStorage *storage, FCurve *fcu, FModif short side = 0, mode = 0; int cycles = 0; float ofs = 0; - + /* check if modifier is first in stack, otherwise disable ourself... */ /* FIXME... */ if (fcm->prev) { fcm->flag |= FMODIFIER_FLAG_DISABLED; return evaltime; } - + /* calculate new evaltime due to cyclic interpolation */ if (fcu && fcu->bezt) { BezTriple *prevbezt = fcu->bezt; BezTriple *lastbezt = prevbezt + fcu->totvert - 1; - + prevkey[0] = prevbezt->vec[1][0]; prevkey[1] = prevbezt->vec[1][1]; - + lastkey[0] = lastbezt->vec[1][0]; lastkey[1] = lastbezt->vec[1][1]; } else if (fcu && fcu->fpt) { FPoint *prevfpt = fcu->fpt; FPoint *lastfpt = prevfpt + fcu->totvert - 1; - + prevkey[0] = prevfpt->vec[0]; prevkey[1] = prevfpt->vec[1]; - + lastkey[0] = lastfpt->vec[0]; lastkey[1] = lastfpt->vec[1]; } else return evaltime; - + /* check if modifier will do anything * 1) if in data range, definitely don't do anything * 2) if before first frame or after last frame, make sure some cycling is in use @@ -659,26 +659,26 @@ static float fcm_cycles_time(FModifierStackStorage *storage, FCurve *fcu, FModif } if ((ELEM(0, side, mode))) return evaltime; - + /* find relative place within a cycle */ { float cycdx = 0, cycdy = 0; float cycle = 0, cyct = 0; - + /* calculate period and amplitude (total height) of a cycle */ cycdx = lastkey[0] - prevkey[0]; cycdy = lastkey[1] - prevkey[1]; - + /* check if cycle is infinitely small, to be point of being impossible to use */ if (cycdx == 0) return evaltime; - + /* calculate the 'number' of the cycle */ cycle = ((float)side * (evaltime - ofs) / cycdx); - + /* calculate the time inside the cycle */ cyct = fmod(evaltime - ofs, cycdx); - + /* check that cyclic is still enabled for the specified time */ if (cycles == 0) { /* catch this case so that we don't exit when we have (cycles = 0) @@ -687,11 +687,11 @@ static float fcm_cycles_time(FModifierStackStorage *storage, FCurve *fcu, FModif } else if (cycle > cycles) { /* we are too far away from range to evaluate - * TODO: but we should still hold last value... + * TODO: but we should still hold last value... */ return evaltime; } - + /* check if 'cyclic extrapolation', and thus calculate y-offset for this cycle */ if (mode == FCM_EXTRAPOLATE_CYCLIC_OFFSET) { if (side < 0) @@ -700,17 +700,17 @@ static float fcm_cycles_time(FModifierStackStorage *storage, FCurve *fcu, FModif cycyofs = (float)ceil((evaltime - ofs) / cycdx); cycyofs *= cycdy; } - + /* special case for cycle start/end */ if (cyct == 0.0f) { evaltime = (side == 1 ? lastkey[0] : prevkey[0]); - + if ((mode == FCM_EXTRAPOLATE_MIRROR) && ((int)cycle % 2)) evaltime = (side == 1 ? prevkey[0] : lastkey[0]); } /* calculate where in the cycle we are (overwrite evaltime to reflect this) */ else if ((mode == FCM_EXTRAPOLATE_MIRROR) && ((int)(cycle + 1) % 2)) { - /* when 'mirror' option is used and cycle number is odd, this cycle is played in reverse + /* when 'mirror' option is used and cycle number is odd, this cycle is played in reverse * - for 'before' extrapolation, we need to flip in a different way, otherwise values past * then end of the curve get referenced (result of fmod will be negative, and with different phase) */ @@ -725,22 +725,22 @@ static float fcm_cycles_time(FModifierStackStorage *storage, FCurve *fcu, FModif } if (evaltime < prevkey[0]) evaltime += cycdx; } - + /* store temp data if needed */ if (mode == FCM_EXTRAPOLATE_CYCLIC_OFFSET) { tFCMED_Cycles *edata; - + /* for now, this is just a float, but we could get more stuff... */ edata = MEM_callocN(sizeof(tFCMED_Cycles), "tFCMED_Cycles"); edata->cycyofs = cycyofs; fmodifiers_storage_put(storage, fcm, edata); } - + /* return the new frame to evaluate */ return evaltime; } - + static void fcm_cycles_evaluate(FModifierStackStorage *storage, FCurve *UNUSED(fcu), FModifier *fcm, float *cvalue, float UNUSED(evaltime)) { @@ -750,7 +750,7 @@ static void fcm_cycles_evaluate(FModifierStackStorage *storage, FCurve *UNUSED(f if (edata) { /* add cyclic offset - no need to check for now, otherwise the data wouldn't exist! */ *cvalue += edata->cycyofs; - + /* free temp data */ MEM_freeN(edata); fmodifiers_storage_remove(storage, fcm); @@ -779,7 +779,7 @@ static FModifierTypeInfo FMI_CYCLES = { static void fcm_noise_new_data(void *mdata) { FMod_Noise *data = (FMod_Noise *)mdata; - + /* defaults */ data->size = 1.0f; data->strength = 1.0f; @@ -788,18 +788,18 @@ static void fcm_noise_new_data(void *mdata) data->depth = 0; data->modification = FCM_NOISE_MODIF_REPLACE; } - + static void fcm_noise_evaluate(FCurve *UNUSED(fcu), FModifier *fcm, float *cvalue, float evaltime) { FMod_Noise *data = (FMod_Noise *)fcm->data; float noise; - + /* generate noise using good ol' Blender Noise * - 0.1 is passed as the 'z' value, otherwise evaluation fails for size = phase = 1 * with evaltime being an integer (which happens when evaluating on frame by frame basis) */ noise = BLI_turbulence(data->size, evaltime - data->offset, data->phase, 0.1f, data->depth); - + /* combine the noise with existing motion data */ switch (data->modification) { case FCM_NOISE_MODIF_ADD: @@ -837,7 +837,7 @@ static FModifierTypeInfo FMI_NOISE = { /* Filter F-Curve Modifier --------------------------- */ -#if 0 // XXX not yet implemented +#if 0 // XXX not yet implemented static FModifierTypeInfo FMI_FILTER = { FMODIFIER_TYPE_FILTER, /* type */ sizeof(FMod_Filter), /* size */ @@ -862,7 +862,7 @@ static FModifierTypeInfo FMI_FILTER = { static void fcm_python_free(FModifier *fcm) { FMod_Python *data = (FMod_Python *)fcm->data; - + /* id-properties */ IDP_FreeProperty(data->prop); MEM_freeN(data->prop); @@ -871,7 +871,7 @@ static void fcm_python_free(FModifier *fcm) static void fcm_python_new_data(void *mdata) { FMod_Python *data = (FMod_Python *)mdata; - + /* everything should be set correctly by calloc, except for the prop->type constant.*/ data->prop = MEM_callocN(sizeof(IDProperty), "PyFModifierProps"); data->prop->type = IDP_GROUP; @@ -881,7 +881,7 @@ static void fcm_python_copy(FModifier *fcm, const FModifier *src) { FMod_Python *pymod = (FMod_Python *)fcm->data; FMod_Python *opymod = (FMod_Python *)src->data; - + pymod->prop = IDP_CopyProperty(opymod->prop); } @@ -889,9 +889,9 @@ static void fcm_python_evaluate(FCurve *UNUSED(fcu), FModifier *UNUSED(fcm), flo { #ifdef WITH_PYTHON //FMod_Python *data = (FMod_Python *)fcm->data; - + /* FIXME... need to implement this modifier... - * It will need it execute a script using the custom properties + * It will need it execute a script using the custom properties */ #endif /* WITH_PYTHON */ } @@ -919,13 +919,13 @@ static FModifierTypeInfo FMI_PYTHON = { static float fcm_limits_time(FCurve *UNUSED(fcu), FModifier *fcm, float UNUSED(cvalue), float evaltime) { FMod_Limits *data = (FMod_Limits *)fcm->data; - + /* check for the time limits */ if ((data->flag & FCM_LIMIT_XMIN) && (evaltime < data->rect.xmin)) return data->rect.xmin; if ((data->flag & FCM_LIMIT_XMAX) && (evaltime > data->rect.xmax)) return data->rect.xmax; - + /* modifier doesn't change time */ return evaltime; } @@ -933,7 +933,7 @@ static float fcm_limits_time(FCurve *UNUSED(fcu), FModifier *fcm, float UNUSED(c static void fcm_limits_evaluate(FCurve *UNUSED(fcu), FModifier *fcm, float *cvalue, float UNUSED(evaltime)) { FMod_Limits *data = (FMod_Limits *)fcm->data; - + /* value limits now */ if ((data->flag & FCM_LIMIT_YMIN) && (*cvalue < data->rect.ymin)) *cvalue = data->rect.ymin; @@ -944,7 +944,7 @@ static void fcm_limits_evaluate(FCurve *UNUSED(fcu), FModifier *fcm, float *cval static FModifierTypeInfo FMI_LIMITS = { FMODIFIER_TYPE_LIMITS, /* type */ sizeof(FMod_Limits), /* size */ - FMI_TYPE_GENERATE_CURVE, /* action type */ /* XXX... err... */ + FMI_TYPE_GENERATE_CURVE, /* action type */ /* XXX... err... */ FMI_REQUIRES_RUNTIME_CHECK, /* requirements */ N_("Limits"), /* name */ "FMod_Limits", /* struct name */ @@ -963,7 +963,7 @@ static FModifierTypeInfo FMI_LIMITS = { static void fcm_stepped_new_data(void *mdata) { FMod_Stepped *data = (FMod_Stepped *)mdata; - + /* just need to set the step-size to 2-frames by default */ /* XXX: or would 5 be more normal? */ data->step_size = 2.0f; @@ -973,7 +973,7 @@ static float fcm_stepped_time(FCurve *UNUSED(fcu), FModifier *fcm, float UNUSED( { FMod_Stepped *data = (FMod_Stepped *)fcm->data; int snapblock; - + /* check range clamping to see if we should alter the timing to achieve the desired results */ if (data->flag & FCM_STEPPED_NO_BEFORE) { if (evaltime < data->start_frame) @@ -983,15 +983,15 @@ static float fcm_stepped_time(FCurve *UNUSED(fcu), FModifier *fcm, float UNUSED( if (evaltime > data->end_frame) return evaltime; } - - /* we snap to the start of the previous closest block of 'step_size' frames - * after the start offset has been discarded + + /* we snap to the start of the previous closest block of 'step_size' frames + * after the start offset has been discarded * - i.e. round down */ snapblock = (int)((evaltime - data->offset) / data->step_size); - - /* reapply the offset, and multiple the snapblock by the size of the steps to get - * the new time to evaluate at + + /* reapply the offset, and multiple the snapblock by the size of the steps to get + * the new time to evaluate at */ return ((float)snapblock * data->step_size) + data->offset; } @@ -999,7 +999,7 @@ static float fcm_stepped_time(FCurve *UNUSED(fcu), FModifier *fcm, float UNUSED( static FModifierTypeInfo FMI_STEPPED = { FMODIFIER_TYPE_STEPPED, /* type */ sizeof(FMod_Limits), /* size */ - FMI_TYPE_GENERATE_CURVE, /* action type */ /* XXX... err... */ + FMI_TYPE_GENERATE_CURVE, /* action type */ /* XXX... err... */ FMI_REQUIRES_RUNTIME_CHECK, /* requirements */ N_("Stepped"), /* name */ "FMod_Stepped", /* struct name */ @@ -1047,7 +1047,7 @@ const FModifierTypeInfo *get_fmodifier_typeinfo(const int type) fmods_init_typeinfo(); FMI_INIT = 0; } - + /* only return for valid types */ if ((type >= FMODIFIER_TYPE_NULL) && (type < FMODIFIER_NUM_TYPES)) @@ -1058,10 +1058,10 @@ const FModifierTypeInfo *get_fmodifier_typeinfo(const int type) else { printf("No valid F-Curve Modifier type-info data available. Type = %i\n", type); } - + return NULL; -} - +} + /* This function should always be used to get the appropriate type-info, as it * has checks which prevent segfaults in some weird cases. */ @@ -1081,11 +1081,11 @@ FModifier *add_fmodifier(ListBase *modifiers, int type, FCurve *owner_fcu) { const FModifierTypeInfo *fmi = get_fmodifier_typeinfo(type); FModifier *fcm; - + /* sanity checks */ if (ELEM(NULL, modifiers, fmi)) return NULL; - + /* special checks for whether modifier can be added */ if ((modifiers->first) && (type == FMODIFIER_TYPE_CYCLES)) { /* cycles modifier must be first in stack, so for now, don't add if it can't be */ @@ -1093,7 +1093,7 @@ FModifier *add_fmodifier(ListBase *modifiers, int type, FCurve *owner_fcu) printf("Error: Cannot add 'Cycles' modifier to F-Curve, as 'Cycles' modifier can only be first in stack.\n"); return NULL; } - + /* add modifier itself */ fcm = MEM_callocN(sizeof(FModifier), "F-Curve Modifier"); fcm->type = type; @@ -1101,14 +1101,14 @@ FModifier *add_fmodifier(ListBase *modifiers, int type, FCurve *owner_fcu) fcm->curve = owner_fcu; fcm->influence = 1.0f; BLI_addtail(modifiers, fcm); - + /* tag modifier as "active" if no other modifiers exist in the stack yet */ if (BLI_listbase_is_single(modifiers)) fcm->flag |= FMODIFIER_FLAG_ACTIVE; - + /* add modifier's data */ fcm->data = MEM_callocN(fmi->size, fmi->structName); - + /* init custom settings if necessary */ if (fmi->new_data) fmi->new_data(fcm->data); @@ -1116,7 +1116,7 @@ FModifier *add_fmodifier(ListBase *modifiers, int type, FCurve *owner_fcu) /* update the fcurve if the Cycles modifier is added */ if ((owner_fcu) && (type == FMODIFIER_TYPE_CYCLES)) calchandles_fcurve(owner_fcu); - + /* return modifier for further editing */ return fcm; } @@ -1126,23 +1126,23 @@ FModifier *copy_fmodifier(const FModifier *src) { const FModifierTypeInfo *fmi = fmodifier_get_typeinfo(src); FModifier *dst; - + /* sanity check */ if (src == NULL) return NULL; - + /* copy the base data, clearing the links */ dst = MEM_dupallocN(src); dst->next = dst->prev = NULL; dst->curve = NULL; - + /* make a new copy of the F-Modifier's data */ dst->data = MEM_dupallocN(src->data); - + /* only do specific constraints if required */ if (fmi && fmi->copy_data) fmi->copy_data(dst, src); - + /* return the new modifier */ return dst; } @@ -1151,20 +1151,20 @@ FModifier *copy_fmodifier(const FModifier *src) void copy_fmodifiers(ListBase *dst, const ListBase *src) { FModifier *fcm, *srcfcm; - + if (ELEM(NULL, dst, src)) return; - + BLI_listbase_clear(dst); BLI_duplicatelist(dst, src); - + for (fcm = dst->first, srcfcm = src->first; fcm && srcfcm; srcfcm = srcfcm->next, fcm = fcm->next) { const FModifierTypeInfo *fmi = fmodifier_get_typeinfo(fcm); - + /* make a new copy of the F-Modifier's data */ fcm->data = MEM_dupallocN(fcm->data); fcm->curve = NULL; - + /* only do specific constraints if required */ if (fmi && fmi->copy_data) fmi->copy_data(fcm, srcfcm); @@ -1175,11 +1175,11 @@ void copy_fmodifiers(ListBase *dst, const ListBase *src) bool remove_fmodifier(ListBase *modifiers, FModifier *fcm) { const FModifierTypeInfo *fmi = fmodifier_get_typeinfo(fcm); - + /* sanity check */ if (fcm == NULL) return false; - + /* removing the cycles modifier requires a handle update */ FCurve *update_fcu = (fcm->type == FMODIFIER_TYPE_CYCLES) ? fcm->curve : NULL; @@ -1187,11 +1187,11 @@ bool remove_fmodifier(ListBase *modifiers, FModifier *fcm) if (fcm->data) { if (fmi && fmi->free_data) fmi->free_data(fcm); - + /* free modifier's data (fcm->data) */ MEM_freeN(fcm->data); } - + /* remove modifier from stack */ if (modifiers) { BLI_freelinkN(modifiers, fcm); @@ -1214,11 +1214,11 @@ bool remove_fmodifier(ListBase *modifiers, FModifier *fcm) void free_fmodifiers(ListBase *modifiers) { FModifier *fcm, *fmn; - + /* sanity check */ if (modifiers == NULL) return; - + /* free each modifier in order - modifier is unlinked from list and freed */ for (fcm = modifiers->first; fcm; fcm = fmn) { fmn = fcm->next; @@ -1230,17 +1230,17 @@ void free_fmodifiers(ListBase *modifiers) FModifier *find_active_fmodifier(ListBase *modifiers) { FModifier *fcm; - + /* sanity checks */ if (ELEM(NULL, modifiers, modifiers->first)) return NULL; - + /* loop over modifiers until 'active' one is found */ for (fcm = modifiers->first; fcm; fcm = fcm->next) { if (fcm->flag & FMODIFIER_FLAG_ACTIVE) return fcm; } - + /* no modifier is active */ return NULL; } @@ -1249,55 +1249,55 @@ FModifier *find_active_fmodifier(ListBase *modifiers) void set_active_fmodifier(ListBase *modifiers, FModifier *fcm) { FModifier *fm; - + /* sanity checks */ if (ELEM(NULL, modifiers, modifiers->first)) return; - + /* deactivate all, and set current one active */ for (fm = modifiers->first; fm; fm = fm->next) fm->flag &= ~FMODIFIER_FLAG_ACTIVE; - + /* make given modifier active */ if (fcm) fcm->flag |= FMODIFIER_FLAG_ACTIVE; } -/* Do we have any modifiers which match certain criteria +/* Do we have any modifiers which match certain criteria * - mtype - type of modifier (if 0, doesn't matter) * - acttype - type of action to perform (if -1, doesn't matter) */ bool list_has_suitable_fmodifier(ListBase *modifiers, int mtype, short acttype) { FModifier *fcm; - + /* if there are no specific filtering criteria, just skip */ if ((mtype == 0) && (acttype == 0)) return (modifiers && modifiers->first); - + /* sanity checks */ if (ELEM(NULL, modifiers, modifiers->first)) return false; - + /* find the first mdifier fitting these criteria */ for (fcm = modifiers->first; fcm; fcm = fcm->next) { const FModifierTypeInfo *fmi = fmodifier_get_typeinfo(fcm); short mOk = 1, aOk = 1; /* by default 1, so that when only one test, won't fail */ - + /* check if applicable ones are fullfilled */ if (mtype) mOk = (fcm->type == mtype); if (acttype > -1) aOk = (fmi->acttype == acttype); - + /* if both are ok, we've found a hit */ if (mOk && aOk) return true; } - + /* no matches */ return false; -} +} /* Evaluation API --------------------------- */ @@ -1359,19 +1359,19 @@ void *fmodifiers_storage_get(FModifierStackStorage *storage, FModifier *fcm) static float eval_fmodifier_influence(FModifier *fcm, float evaltime) { float influence; - + /* sanity check */ - if (fcm == NULL) + if (fcm == NULL) return 0.0f; - - /* should we use influence stored in modifier or not + + /* should we use influence stored in modifier or not * NOTE: this is really just a hack so that we don't need to version patch old files ;) */ if (fcm->flag & FMODIFIER_FLAG_USEINFLUENCE) influence = fcm->influence; else influence = 1.0f; - + /* restricted range or full range? */ if (fcm->flag & FMODIFIER_FLAG_RANGERESTRICT) { if ((evaltime <= fcm->sfra) || (evaltime >= fcm->efra)) { @@ -1391,7 +1391,7 @@ static float eval_fmodifier_influence(FModifier *fcm, float evaltime) return influence * (evaltime - a) / (b - a); } } - + /* just return the influence of the modifier */ return influence; } @@ -1411,7 +1411,7 @@ float evaluate_time_fmodifiers(FModifierStackStorage *storage, ListBase *modifie FCurve *fcu, float cvalue, float evaltime) { FModifier *fcm; - + /* sanity checks */ if (ELEM(NULL, modifiers, modifiers->last)) return evaltime; @@ -1419,22 +1419,22 @@ float evaluate_time_fmodifiers(FModifierStackStorage *storage, ListBase *modifie if (fcu && fcu->flag & FCURVE_MOD_OFF) return evaltime; - /* Starting from the end of the stack, calculate the time effects of various stacked modifiers - * on the time the F-Curve should be evaluated at. + /* Starting from the end of the stack, calculate the time effects of various stacked modifiers + * on the time the F-Curve should be evaluated at. * * This is done in reverse order to standard evaluation, as when this is done in standard * order, each modifier would cause jumps to other points in the curve, forcing all - * previous ones to be evaluated again for them to be correct. However, if we did in the + * previous ones to be evaluated again for them to be correct. However, if we did in the * reverse order as we have here, we can consider them a macro to micro type of waterfall * effect, which should get us the desired effects when using layered time manipulations * (such as multiple 'stepped' modifiers in sequence, causing different stepping rates) */ for (fcm = modifiers->last; fcm; fcm = fcm->prev) { const FModifierTypeInfo *fmi = fmodifier_get_typeinfo(fcm); - - if (fmi == NULL) + + if (fmi == NULL) continue; - + /* if modifier cannot be applied on this frame (whatever scale it is on, it won't affect the results) * hence we shouldn't bother seeing what it would do given the chance */ @@ -1453,13 +1453,13 @@ float evaluate_time_fmodifiers(FModifierStackStorage *storage, ListBase *modifie else { nval = fmi->evaluate_modifier_time_storage(storage, fcu, fcm, cvalue, evaltime); } - + evaltime = interpf(nval, evaltime, influence); } } } } - + /* return the modified evaltime */ return evaltime; } @@ -1471,21 +1471,21 @@ void evaluate_value_fmodifiers(FModifierStackStorage *storage, ListBase *modifie FCurve *fcu, float *cvalue, float evaltime) { FModifier *fcm; - + /* sanity checks */ if (ELEM(NULL, modifiers, modifiers->first)) return; if (fcu->flag & FCURVE_MOD_OFF) return; - + /* evaluate modifiers */ for (fcm = modifiers->first; fcm; fcm = fcm->next) { const FModifierTypeInfo *fmi = fmodifier_get_typeinfo(fcm); - - if (fmi == NULL) + + if (fmi == NULL) continue; - + /* only evaluate if there's a callback for this, and if F-Modifier can be evaluated on this frame */ if ((fcm->flag & FMODIFIER_FLAG_RANGERESTRICT) == 0 || ((fcm->sfra <= evaltime) && (fcm->efra >= evaltime)) ) @@ -1507,7 +1507,7 @@ void evaluate_value_fmodifiers(FModifierStackStorage *storage, ListBase *modifie } } } -} +} /* ---------- */ @@ -1517,24 +1517,24 @@ void evaluate_value_fmodifiers(FModifierStackStorage *storage, ListBase *modifie void fcurve_bake_modifiers(FCurve *fcu, int start, int end) { ChannelDriver *driver; - + /* sanity checks */ /* TODO: make these tests report errors using reports not printf's */ if (ELEM(NULL, fcu, fcu->modifiers.first)) { printf("Error: No F-Curve with F-Curve Modifiers to Bake\n"); return; } - + /* temporarily, disable driver while we sample, so that they don't influence the outcome */ driver = fcu->driver; fcu->driver = NULL; - + /* bake the modifiers, by sampling the curve at each frame */ fcurve_store_samples(fcu, NULL, start, end, fcurve_samplingcb_evalcurve); - + /* free the modifiers now */ free_fmodifiers(&fcu->modifiers); - + /* restore driver */ fcu->driver = driver; } |