64 FMODIFIER_TYPE_MODNAME,
67 FMI_REQUIRES_SOME_REQUIREMENT,
95 if (
data->coefficients) {
117 data->poly_order = 1;
129 switch (
data->mode) {
132 const int arraysize_new =
data->poly_order + 1;
134 if (
data->arraysize != arraysize_new) {
135 data->coefficients =
static_cast<float *
>(
137 data->arraysize = arraysize_new;
143 const int arraysize_new =
data->poly_order * 2;
145 if (
data->arraysize != arraysize_new) {
146 data->coefficients =
static_cast<float *
>(
148 data->arraysize = arraysize_new;
166 switch (
data->mode) {
188 value +=
data->coefficients[
i] * powers[
i];
192 if (
data->poly_order) {
209 float value = 1.0f, *cp =
nullptr;
214 for (cp =
data->coefficients,
i = 0; (cp) && (
i <
uint(
data->poly_order)); cp += 2,
i++) {
215 value *= (cp[0] *
evaltime + cp[1]);
219 if (
data->poly_order) {
265 data->amplitude = 1.0f;
266 data->phase_multiplier = 1.0f;
275 if (
fabs(
x) < 0.0001) {
290 double (*fn)(
double v) =
nullptr;
295 switch (
data->type) {
354 float value = (
data->amplitude *
float(fn(arg)) +
data->value_offset);
371 "FMod_FunctionGenerator",
431 float min = 0.0f,
max = 0.0f, fac = 0.0f;
435 if (env->
data ==
nullptr) {
440 lastfed = prevfed + (env->
totvert - 1);
456 for (a = 0; prevfed && fed && (a < env->
totvert - 1); a++, prevfed = fed, fed++) {
459 float afac, bfac,
diff;
461 diff = fed->time - prevfed->time;
465 min = bfac * prevfed->min + afac * fed->min;
466 max = bfac * prevfed->max + afac * fed->max;
502#define BINARYSEARCH_FRAMEEQ_THRESH 0.0001f
509 int start = 0, end = arraylen;
510 int loopbreaker = 0, maxloop = arraylen * 2;
519 if ((arraylen <= 0) || (
array ==
nullptr)) {
528 framenum =
array[0].time;
533 if (frame < framenum) {
538 framenum =
array[(arraylen - 1)].time;
541 return (arraylen - 1);
543 if (frame > framenum) {
550 for (loopbreaker = 0; (start <= end) && (loopbreaker < maxloop); loopbreaker++) {
554 int mid = start + ((end - start) / 2);
556 float midfra =
array[mid].time;
565 if (frame > midfra) {
568 else if (frame < midfra) {
574 if (loopbreaker == (maxloop - 1)) {
579 "\tround = %d: start = %d, end = %d, arraylen = %d",
589#undef BINARYSEARCH_FRAMEEQ_THRESH
623 float firstkey[2], lastkey[2], cycyofs = 0.0f;
624 short side = 0, mode = 0;
635 if (fcu ==
nullptr || (fcu->
bezt ==
nullptr && fcu->
fpt ==
nullptr)) {
644 firstkey[0] = firstbezt->
vec[1][0];
645 firstkey[1] = firstbezt->
vec[1][1];
647 lastkey[0] = lastbezt->
vec[1][0];
648 lastkey[1] = lastbezt->
vec[1][1];
655 firstkey[0] = prevfpt->
vec[0];
656 firstkey[1] = prevfpt->
vec[1];
658 lastkey[0] = lastfpt->
vec[0];
659 lastkey[1] = lastfpt->
vec[1];
667 if (
data->before_mode) {
669 mode =
data->before_mode;
670 cycles =
data->before_cycles;
675 if (
data->after_mode) {
677 mode =
data->after_mode;
678 cycles =
data->after_cycles;
682 if (
ELEM(0, side, mode)) {
689 const float cycdx = lastkey[0] - firstkey[0];
690 const float cycdy = lastkey[1] - firstkey[1];
700 const double cycle = side * (double(
evaltime) - double(ofs)) /
double(cycdx);
710 else if (cycle > cycles) {
730 evaltime = (side == 1 ? lastkey[0] : firstkey[0]);
733 evaltime = (side == 1 ? firstkey[0] : lastkey[0]);
802 data->strength = 1.0f;
807 data->lacunarity = 2.0f;
808 data->roughness = 0.5f;
809 data->legacy_noise = 0;
820 if (
data->legacy_noise) {
830 if (
data->size == 0.0f) {
834 scale = 1.0 /
data->size;
838 const float offset = 0.61803398874;
850 switch (
data->modification) {
852 *cvalue = *cvalue +
noise *
data->strength;
855 *cvalue = *cvalue -
noise *
data->strength;
858 *cvalue = *cvalue *
noise *
data->strength;
862 *cvalue = *cvalue + (
noise - 0.5f) *
data->strength;
895 return data->rect.xmin;
898 return data->rect.xmax;
915 *cvalue =
data->rect.ymin;
918 *cvalue =
data->rect.ymax;
946 data->step_size = 2.0f;
979 return (
float(snapblock) *
data->step_size) +
data->offset;
1032 "fmodifiersTypeInfo should be indexed by the modifier type number");
1051 CLOG_ERROR(&
LOG,
"No valid F-Curve Modifier type-info data available. Type = %i", type);
1078 if (
ELEM(
nullptr, modifiers, fmi)) {
1087 "Cannot add 'Cycles' modifier to F-Curve, as 'Cycles' modifier can only be "
1096 fcm->
curve = owner_fcu;
1131 if (src ==
nullptr) {
1138 dst->
curve =
nullptr;
1156 if (
ELEM(
nullptr, dst, src)) {
1165 srcfcm = srcfcm->
next, fcm = fcm->
next)
1171 fcm->
curve =
nullptr;
1185 if (fcm ==
nullptr) {
1225 if (modifiers ==
nullptr) {
1230 for (fcm =
static_cast<FModifier *
>(modifiers->
first); fcm; fcm = fmn) {
1239 if (
ELEM(
nullptr, modifiers, modifiers->
first)) {
1257 if (
ELEM(
nullptr, modifiers, modifiers->
first)) {
1275 if ((mtype == 0) && (acttype == 0)) {
1276 return (modifiers && modifiers->
first);
1280 if (
ELEM(
nullptr, modifiers, modifiers->
first)) {
1287 short mOk = 1, aOk = 1;
1291 mOk = (fcm->type == mtype);
1294 aOk = (fmi->
acttype == acttype);
1312 if (
ELEM(
nullptr, modifiers, modifiers->
first)) {
1321 if (fmi ==
nullptr) {
1339 if (fcm ==
nullptr) {
1363 float a = fcm->
sfra;
1365 return influence * (
evaltime - a) / (
b - a);
1371 float a = fcm->
efra;
1373 return influence * (
evaltime - a) / (
b - a);
1388 if (
ELEM(
nullptr, modifiers, modifiers->
last)) {
1408 fcm = fcm->
prev, fcm_index--)
1412 if (fmi ==
nullptr) {
1450 if (
ELEM(
nullptr, modifiers, modifiers->
first)) {
1460 for (fcm =
static_cast<FModifier *
>(modifiers->
first); fcm; fcm = fcm->
next, fcm_index++) {
1463 if (fmi ==
nullptr) {
1477 float nval = *cvalue;
1481 *cvalue =
interpf(nval, *cvalue, influence);
1497 CLOG_ERROR(&
LOG,
"No F-Curve with F-Curve Modifiers to Bake");
@ FMI_TYPE_REPLACE_VALUES
@ FMI_TYPE_GENERATE_CURVE
void BKE_fmodifier_name_set(FModifier *fcm, const char *name)
void BKE_fcurve_handles_recalc(FCurve *fcu)
@ FMI_REQUIRES_RUNTIME_CHECK
@ FMI_REQUIRES_ORIGINAL_DATA
void fcurve_store_samples(FCurve *fcu, void *data, int start, int end, FcuSampleFunc sample_cb)
float fcurve_samplingcb_evalcurve(FCurve *fcu, void *data, float evaltime)
#define BLI_assert_msg(a, msg)
#define LISTBASE_FOREACH(type, var, list)
BLI_INLINE void BLI_listbase_clear(ListBase *lb)
void BLI_freelinkN(ListBase *listbase, void *vlink) ATTR_NONNULL(1)
void BLI_addtail(ListBase *listbase, void *vlink) ATTR_NONNULL(1)
void void void void void void BLI_duplicatelist(ListBase *dst, const ListBase *src) ATTR_NONNULL(1
void void BLI_INLINE bool BLI_listbase_is_single(const ListBase *lb)
MINLINE float interpf(float target, float origin, float t)
float BLI_noise_turbulence(float noisesize, float x, float y, float z, int nr)
#define POINTER_OFFSET(v, ofs)
#define BLT_I18NCONTEXT_ID_ACTION
#define CTX_N_(context, msgid)
#define CLOG_ERROR(clg_ref,...)
#define CLOG_WARN(clg_ref,...)
#define CLOG_STR_ERROR(clg_ref, str)
@ FCM_EXTRAPOLATE_CYCLIC_OFFSET
@ FCM_NOISE_MODIF_REPLACE
@ FCM_NOISE_MODIF_SUBTRACT
@ FCM_NOISE_MODIF_MULTIPLY
@ FMODIFIER_TYPE_FN_GENERATOR
@ FMODIFIER_TYPE_GENERATOR
@ FMODIFIER_TYPE_ENVELOPE
@ FCM_GENERATOR_POLYNOMIAL_FACTORISED
@ FCM_GENERATOR_POLYNOMIAL
@ FMODIFIER_FLAG_USEINFLUENCE
@ FMODIFIER_FLAG_DISABLED
@ FMODIFIER_FLAG_RANGERESTRICT
@ UI_PANEL_DATA_EXPAND_ROOT
Read Guarded memory(de)allocation.
#define MEM_recallocN(vmemh, len)
BMesh const char void * data
ATTR_WARN_UNUSED_RESULT const BMVert * v
void fcurve_bake_modifiers(FCurve *fcu, int start, int end)
static float eval_fmodifier_influence(FModifier *fcm, float evaltime)
static FModifierTypeInfo FMI_ENVELOPE
static void fcm_envelope_new_data(void *mdata)
FModifier * copy_fmodifier(const FModifier *src)
static void fcm_cycles_new_data(void *mdata)
float evaluate_time_fmodifiers(FModifiersStackStorage *storage, const ListBase *modifiers, const FCurve *fcu, float cvalue, float evaltime)
void copy_fmodifiers(ListBase *dst, const ListBase *src)
static float fcm_cycles_time(const FCurve *fcu, const FModifier *fcm, float, float evaltime, void *storage_)
static void fcm_fn_generator_new_data(void *mdata)
static void fcm_envelope_verify(FModifier *fcm)
uint evaluate_fmodifiers_storage_size_per_modifier(const ListBase *modifiers)
void evaluate_value_fmodifiers(FModifiersStackStorage *storage, const ListBase *modifiers, const FCurve *fcu, float *cvalue, float evaltime)
static void fcm_limits_evaluate(const FCurve *, const FModifier *fcm, float *cvalue, float, void *)
static FModifierTypeInfo FMI_STEPPED
static FModifierTypeInfo FMI_GENERATOR
static float fcm_limits_time(const FCurve *, const FModifier *fcm, float, float evaltime, void *)
FModifier * add_fmodifier(ListBase *modifiers, int type, FCurve *owner_fcu)
bool remove_fmodifier(ListBase *modifiers, FModifier *fcm)
static double sinc(double x)
bool list_has_suitable_fmodifier(const ListBase *modifiers, int mtype, short acttype)
static float fcm_stepped_time(const FCurve *, const FModifier *fcm, float, float evaltime, void *)
static void fcm_fn_generator_evaluate(const FCurve *, const FModifier *fcm, float *cvalue, float evaltime, void *)
void set_active_fmodifier(ListBase *modifiers, FModifier *fcm)
static void fcm_noise_new_data(void *mdata)
static FModifierTypeInfo FMI_CYCLES
static void fcm_stepped_new_data(void *mdata)
const FModifierTypeInfo * get_fmodifier_typeinfo(const int type)
static void fcm_cycles_evaluate(const FCurve *, const FModifier *, float *cvalue, float, void *storage_)
static FModifierTypeInfo * fmodifiersTypeInfo[FMODIFIER_NUM_TYPES]
static void fcm_generator_new_data(void *mdata)
static void fcm_generator_free(FModifier *fcm)
int BKE_fcm_envelope_find_index(FCM_EnvelopeData array[], float frame, int arraylen, bool *r_exists)
FModifier * find_active_fmodifier(ListBase *modifiers)
static FModifierTypeInfo FMI_LIMITS
static void fmods_init_typeinfo()
static void fcm_generator_evaluate(const FCurve *, const FModifier *fcm, float *cvalue, float evaltime, void *)
static void fcm_generator_verify(FModifier *fcm)
void free_fmodifiers(ListBase *modifiers)
static void fcm_generator_copy(FModifier *fcm, const FModifier *src)
static void fcm_envelope_free(FModifier *fcm)
static void fcm_envelope_copy(FModifier *fcm, const FModifier *src)
static void fcm_envelope_evaluate(const FCurve *, const FModifier *fcm, float *cvalue, float evaltime, void *)
const FModifierTypeInfo * fmodifier_get_typeinfo(const FModifier *fcm)
static FModifierTypeInfo FMI_NOISE
static FModifierTypeInfo FMI_FN_GENERATOR
#define BINARYSEARCH_FRAMEEQ_THRESH
static void fcm_noise_evaluate(const FCurve *, const FModifier *fcm, float *cvalue, float evaltime, void *)
IMETHOD Vector diff(const Vector &a, const Vector &b, double dt)
void * MEM_calloc_arrayN(size_t len, size_t size, const char *str)
void * MEM_callocN(size_t len, const char *str)
void * MEM_dupallocN(const void *vmemh)
void MEM_freeN(void *vmemh)
ccl_device_inline float2 fmod(const float2 a, const float b)
ccl_device_inline float2 fabs(const float2 a)
float perlin_fbm(T p, float detail, float roughness, float lacunarity, bool normalize)
VecBase< float, 2 > float2
static float noise(int n)
void(* copy_data)(FModifier *fcm, const FModifier *src)
void(* new_data)(void *mdata)
void(* free_data)(FModifier *fcm)
void(* evaluate_modifier)(const FCurve *fcu, const FModifier *fcm, float *cvalue, float evaltime, void *storage)
float(* evaluate_modifier_time)(const FCurve *fcu, const FModifier *fcm, float cvalue, float evaltime, void *storage)