80 FMODIFIER_TYPE_MODNAME,
83 FMI_REQUIRES_SOME_REQUIREMENT,
123 if (ogen->coefficients) {
134 data->poly_order = 1;
136 cp =
data->coefficients =
MEM_callocN(
sizeof(
float) * 2,
"FMod_Generator_Coefs");
146 switch (
data->mode) {
149 const int arraysize_new =
data->poly_order + 1;
151 if (
data->arraysize != arraysize_new) {
153 data->arraysize = arraysize_new;
159 const int arraysize_new =
data->poly_order * 2;
161 if (
data->arraysize != arraysize_new) {
163 data->arraysize = arraysize_new;
178 switch (
data->mode) {
182 float *powers =
MEM_callocN(
sizeof(
float) *
data->arraysize,
"Poly Powers");
188 for (
uint i = 0; i <
data->arraysize; i++) {
191 powers[i] = powers[i - 1] *
evaltime;
199 for (
uint i = 0; i <
data->arraysize; i++) {
200 value +=
data->coefficients[i] * powers[i];
204 if (
data->poly_order) {
221 float value = 1.0f, *cp =
NULL;
226 for (cp =
data->coefficients, i = 0; (cp) && (i < (
uint)
data->poly_order); cp += 2, i++) {
227 value *= (cp[0] *
evaltime + cp[1]);
231 if (
data->poly_order) {
277 data->amplitude = 1.0f;
278 data->phase_multiplier = 1.0f;
287 if (
fabs(
x) < 0.0001) {
304 switch (
data->type) {
363 float value = (
float)(
data->amplitude * (
float)fn(arg) +
data->value_offset);
379 N_(
"Built-In Function"),
380 "FMod_FunctionGenerator",
437 float min = 0.0f,
max = 0.0f, fac = 0.0f;
446 lastfed = prevfed + (env->
totvert - 1);
454 else if (lastfed->time <=
evaltime) {
462 for (
a = 0; prevfed && fed && (
a < env->
totvert - 1);
a++, prevfed = fed, fed++) {
465 float afac, bfac,
diff;
471 min = bfac * prevfed->min + afac * fed->
min;
472 max = bfac * prevfed->max + afac * fed->
max;
508 #define BINARYSEARCH_FRAMEEQ_THRESH 0.0001f
515 int start = 0, end = arraylen;
516 int loopbreaker = 0, maxloop = arraylen * 2;
525 if ((arraylen <= 0) || (
array ==
NULL)) {
534 framenum =
array[0].time;
539 if (frame < framenum) {
547 return (arraylen - 1);
549 if (frame > framenum) {
556 for (loopbreaker = 0; (start <= end) && (loopbreaker < maxloop); loopbreaker++) {
560 int mid = start + ((end - start) / 2);
562 float midfra =
array[mid].time;
571 if (frame > midfra) {
574 else if (frame < midfra) {
580 if (loopbreaker == (maxloop - 1)) {
585 "\tround = %d: start = %d, end = %d, arraylen = %d",
595 #undef BINARYSEARCH_FRAMEEQ_THRESH
629 float prevkey[2], lastkey[2], cycyofs = 0.0f;
630 short side = 0, mode = 0;
653 prevkey[0] = prevbezt->
vec[1][0];
654 prevkey[1] = prevbezt->
vec[1][1];
656 lastkey[0] = lastbezt->
vec[1][0];
657 lastkey[1] = lastbezt->
vec[1][1];
664 prevkey[0] = prevfpt->
vec[0];
665 prevkey[1] = prevfpt->
vec[1];
667 lastkey[0] = lastfpt->
vec[0];
668 lastkey[1] = lastfpt->
vec[1];
676 if (
data->before_mode) {
678 mode =
data->before_mode;
679 cycles =
data->before_cycles;
684 if (
data->after_mode) {
686 mode =
data->after_mode;
687 cycles =
data->after_cycles;
691 if ((
ELEM(0, side, mode))) {
698 const float cycdx = lastkey[0] - prevkey[0];
699 const float cycdy = lastkey[1] - prevkey[1];
707 const float cycle = ((
float)side * (
evaltime - ofs) / cycdx);
710 const float cyct = fmod(
evaltime - ofs, cycdx);
718 else if (cycle > cycles) {
738 evaltime = (side == 1 ? lastkey[0] : prevkey[0]);
741 evaltime = (side == 1 ? prevkey[0] : lastkey[0]);
769 storage->cycyofs = cycyofs;
810 data->strength = 1.0f;
831 switch (
data->modification) {
833 *cvalue = *cvalue +
noise *
data->strength;
836 *cvalue = *cvalue -
noise *
data->strength;
839 *cvalue = *cvalue *
noise *
data->strength;
843 *cvalue = *cvalue + (
noise - 0.5f) *
data->strength;
934 return data->rect.xmin;
937 return data->rect.xmax;
954 *cvalue =
data->rect.ymin;
957 *cvalue =
data->rect.ymax;
986 data->step_size = 2.0f;
1000 if (evaltime < data->start_frame) {
1019 return ((
float)snapblock *
data->step_size) +
data->offset;
1086 CLOG_ERROR(&
LOG,
"No valid F-Curve Modifier type-info data available. Type = %i",
type);
1129 "Cannot add 'Cycles' modifier to F-Curve, as 'Cycles' modifier can only be "
1138 fcm->
curve = owner_fcu;
1208 for (fcm = dst->
first, srcfcm = src->
first; fcm && srcfcm;
1209 srcfcm = srcfcm->
next, fcm = fcm->
next) {
1274 if (modifiers ==
NULL) {
1279 for (fcm = modifiers->
first; fcm; fcm = fmn) {
1298 for (fcm = modifiers->
first; fcm; fcm = fcm->
next) {
1321 for (fm = modifiers->
first; fm; fm = fm->
next) {
1342 if ((mtype == 0) && (acttype == 0)) {
1343 return (modifiers && modifiers->
first);
1352 for (fcm = modifiers->
first; fcm; fcm = fcm->
next) {
1354 short mOk = 1, aOk = 1;
1358 mOk = (fcm->
type == mtype);
1361 aOk = (fmi->
acttype == acttype);
1422 if ((evaltime <= fcm->sfra) || (
evaltime >= fcm->
efra)) {
1428 float a = fcm->
sfra;
1434 float a = fcm->
efra;
1537 for (fcm = modifiers->
first; fcm; fcm = fcm->
next, fcm_index++) {
1553 float nval = *cvalue;
1557 *cvalue =
interpf(nval, *cvalue, influence);
1577 CLOG_ERROR(&
LOG,
"No F-Curve with F-Curve Modifiers to Bake");
typedef float(TangentPoint)[2]
@ FMI_TYPE_REPLACE_VALUES
@ FMI_TYPE_GENERATE_CURVE
void fcurve_store_samples(struct FCurve *fcu, void *data, int start, int end, FcuSampleFunc sample_cb)
@ FMI_REQUIRES_RUNTIME_CHECK
@ FMI_REQUIRES_ORIGINAL_DATA
void calchandles_fcurve(struct FCurve *fcu)
float fcurve_samplingcb_evalcurve(struct FCurve *fcu, void *data, float evaltime)
void IDP_FreeProperty(struct IDProperty *prop)
struct IDProperty * IDP_CopyProperty(const struct IDProperty *prop) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL()
#define LISTBASE_FOREACH(type, var, list)
void BLI_freelinkN(struct ListBase *listbase, void *vlink) ATTR_NONNULL(1)
void void void void void BLI_duplicatelist(struct ListBase *dst, const struct ListBase *src) ATTR_NONNULL(1
BLI_INLINE void BLI_listbase_clear(struct ListBase *lb)
void void BLI_INLINE bool BLI_listbase_is_single(const struct ListBase *lb)
void BLI_addtail(struct ListBase *listbase, void *vlink) ATTR_NONNULL(1)
MINLINE float interpf(float a, float b, float t)
float BLI_noise_turbulence(float noisesize, float x, float y, float z, int nr)
#define POINTER_OFFSET(v, ofs)
typedef double(DMatrix)[4][4]
#define CLOG_ERROR(clg_ref,...)
#define CLOG_WARN(clg_ref,...)
#define CLOG_STR_ERROR(clg_ref, str)
struct FMod_Cycles FMod_Cycles
struct FMod_Noise FMod_Noise
struct FMod_Envelope FMod_Envelope
@ FCM_EXTRAPOLATE_CYCLIC_OFFSET
struct FMod_Limits FMod_Limits
struct FMod_Generator FMod_Generator
@ 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
struct FMod_FunctionGenerator FMod_FunctionGenerator
struct FMod_Python FMod_Python
@ UI_PANEL_DATA_EXPAND_ROOT
_GL_VOID GLfloat value _GL_VOID_RET _GL_VOID const GLuint GLboolean *residences _GL_BOOL_RET _GL_VOID GLsizei GLfloat GLfloat GLfloat GLfloat const GLubyte *bitmap _GL_VOID_RET _GL_VOID GLenum type
Read Guarded memory(de)allocation.
#define MEM_recallocN(vmemh, len)
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 void fcm_limits_evaluate(FCurve *UNUSED(fcu), FModifier *fcm, float *cvalue, float UNUSED(evaltime), void *UNUSED(storage))
FModifier * add_fmodifier(ListBase *modifiers, int type, FCurve *owner_fcu)
const FModifierTypeInfo * fmodifier_get_typeinfo(const FModifier *fcm)
static FModifierTypeInfo FMI_ENVELOPE
FModifier * find_active_fmodifier(ListBase *modifiers)
static void fcm_envelope_new_data(void *mdata)
static void fcm_cycles_new_data(void *mdata)
void copy_fmodifiers(ListBase *dst, const ListBase *src)
static void fcm_fn_generator_new_data(void *mdata)
static void fcm_python_evaluate(FCurve *UNUSED(fcu), FModifier *UNUSED(fcm), float *UNUSED(cvalue), float UNUSED(evaltime), void *UNUSED(storage))
static void fcm_envelope_verify(FModifier *fcm)
static void fcm_generator_evaluate(FCurve *UNUSED(fcu), FModifier *fcm, float *cvalue, float evaltime, void *UNUSED(storage))
static void fcm_cycles_evaluate(FCurve *UNUSED(fcu), FModifier *UNUSED(fcm), float *cvalue, float UNUSED(evaltime), void *storage_)
static void fcm_noise_evaluate(FCurve *UNUSED(fcu), FModifier *fcm, float *cvalue, float evaltime, void *UNUSED(storage))
static float fcm_cycles_time(FCurve *fcu, FModifier *fcm, float UNUSED(cvalue), float evaltime, void *storage_)
static FModifierTypeInfo FMI_STEPPED
static void fcm_fn_generator_evaluate(FCurve *UNUSED(fcu), FModifier *fcm, float *cvalue, float evaltime, void *UNUSED(storage))
static FModifierTypeInfo FMI_GENERATOR
bool remove_fmodifier(ListBase *modifiers, FModifier *fcm)
static double sinc(double x)
static float fcm_limits_time(FCurve *UNUSED(fcu), FModifier *fcm, float UNUSED(cvalue), float evaltime, void *UNUSED(storage))
void set_active_fmodifier(ListBase *modifiers, FModifier *fcm)
struct tFCMED_Cycles tFCMED_Cycles
static void fcm_noise_new_data(void *mdata)
static FModifierTypeInfo FMI_CYCLES
static void fcm_stepped_new_data(void *mdata)
void evaluate_value_fmodifiers(FModifiersStackStorage *storage, ListBase *modifiers, FCurve *fcu, float *cvalue, float evaltime)
static void fcm_python_new_data(void *mdata)
static FModifierTypeInfo FMI_PYTHON
float evaluate_time_fmodifiers(FModifiersStackStorage *storage, ListBase *modifiers, FCurve *fcu, float cvalue, float evaltime)
static FModifierTypeInfo * fmodifiersTypeInfo[FMODIFIER_NUM_TYPES]
static void fcm_envelope_evaluate(FCurve *UNUSED(fcu), FModifier *fcm, float *cvalue, float evaltime, void *UNUSED(storage))
static void fcm_generator_new_data(void *mdata)
static void fcm_generator_free(FModifier *fcm)
static void fmods_init_typeinfo(void)
int BKE_fcm_envelope_find_index(FCM_EnvelopeData array[], float frame, int arraylen, bool *r_exists)
const FModifierTypeInfo * get_fmodifier_typeinfo(const int type)
bool list_has_suitable_fmodifier(ListBase *modifiers, int mtype, short acttype)
static FModifierTypeInfo FMI_LIMITS
FModifier * copy_fmodifier(const FModifier *src)
static void fcm_generator_verify(FModifier *fcm)
void free_fmodifiers(ListBase *modifiers)
uint evaluate_fmodifiers_storage_size_per_modifier(ListBase *modifiers)
static float fcm_stepped_time(FCurve *UNUSED(fcu), FModifier *fcm, float UNUSED(cvalue), float evaltime, void *UNUSED(storage))
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_python_free(FModifier *fcm)
static FModifierTypeInfo FMI_NOISE
static FModifierTypeInfo FMI_FN_GENERATOR
static void fcm_python_copy(FModifier *fcm, const FModifier *src)
#define BINARYSEARCH_FRAMEEQ_THRESH
void(* MEM_freeN)(void *vmemh)
void *(* MEM_dupallocN)(const void *vmemh)
void *(* MEM_callocN)(size_t len, const char *str)
IMETHOD Vector diff(const Vector &a, const Vector &b, double dt=1)
INLINE Rall1d< T, V, S > cos(const Rall1d< T, V, S > &arg)
INLINE Rall1d< T, V, S > log(const Rall1d< T, V, S > &arg)
INLINE Rall1d< T, V, S > sin(const Rall1d< T, V, S > &arg)
INLINE Rall1d< T, V, S > tan(const Rall1d< T, V, S > &arg)
static float noise(int n)
float(* evaluate_modifier_time)(struct FCurve *fcu, struct FModifier *fcm, float cvalue, float evaltime, void *storage)
void(* free_data)(struct FModifier *fcm)
void(* evaluate_modifier)(struct FCurve *fcu, struct FModifier *fcm, float *cvalue, float evaltime, void *storage)
void(* new_data)(void *mdata)
void(* copy_data)(struct FModifier *fcm, const struct FModifier *src)
ccl_device_inline float2 floor(const float2 &a)
ccl_device_inline float2 fabs(const float2 &a)
ccl_device_inline float3 ceil(const float3 &a)