64 FMODIFIER_TYPE_MODNAME,
67 FMI_REQUIRES_SOME_REQUIREMENT,
107 if (ogen->coefficients) {
118 data->poly_order = 1;
120 cp =
data->coefficients =
MEM_callocN(
sizeof(
float) * 2,
"FMod_Generator_Coefs");
130 switch (
data->mode) {
133 const int arraysize_new =
data->poly_order + 1;
135 if (
data->arraysize != arraysize_new) {
137 data->arraysize = arraysize_new;
143 const int arraysize_new =
data->poly_order * 2;
145 if (
data->arraysize != arraysize_new) {
147 data->arraysize = arraysize_new;
162 switch (
data->mode) {
166 float *powers =
MEM_callocN(
sizeof(
float) *
data->arraysize,
"Poly Powers");
172 for (
uint i = 0; i <
data->arraysize; i++) {
175 powers[i] = powers[i - 1] *
evaltime;
183 for (
uint i = 0; i <
data->arraysize; i++) {
184 value +=
data->coefficients[i] * powers[i];
188 if (
data->poly_order) {
205 float value = 1.0f, *cp =
NULL;
210 for (cp =
data->coefficients, i = 0; (cp) && (i < (
uint)
data->poly_order); cp += 2, i++) {
211 value *= (cp[0] *
evaltime + cp[1]);
215 if (
data->poly_order) {
261 data->amplitude = 1.0f;
262 data->phase_multiplier = 1.0f;
271 if (
fabs(
x) < 0.0001) {
288 switch (
data->type) {
347 float value = (
float)(
data->amplitude * (
float)fn(arg) +
data->value_offset);
363 N_(
"Built-In Function"),
364 "FMod_FunctionGenerator",
421 float min = 0.0f,
max = 0.0f, fac = 0.0f;
430 lastfed = prevfed + (env->
totvert - 1);
438 else if (lastfed->time <=
evaltime) {
446 for (
a = 0; prevfed && fed && (
a < env->
totvert - 1);
a++, prevfed = fed, fed++) {
449 float afac, bfac,
diff;
455 min = bfac * prevfed->min + afac * fed->
min;
456 max = bfac * prevfed->max + afac * fed->
max;
492 #define BINARYSEARCH_FRAMEEQ_THRESH 0.0001f
499 int start = 0, end = arraylen;
500 int loopbreaker = 0, maxloop = arraylen * 2;
509 if ((arraylen <= 0) || (
array ==
NULL)) {
518 framenum =
array[0].time;
523 if (frame < framenum) {
531 return (arraylen - 1);
533 if (frame > framenum) {
540 for (loopbreaker = 0; (start <= end) && (loopbreaker < maxloop); loopbreaker++) {
544 int mid = start + ((end - start) / 2);
546 float midfra =
array[mid].time;
555 if (frame > midfra) {
558 else if (frame < midfra) {
564 if (loopbreaker == (maxloop - 1)) {
569 "\tround = %d: start = %d, end = %d, arraylen = %d",
579 #undef BINARYSEARCH_FRAMEEQ_THRESH
613 float prevkey[2], lastkey[2], cycyofs = 0.0f;
614 short side = 0, mode = 0;
637 prevkey[0] = prevbezt->
vec[1][0];
638 prevkey[1] = prevbezt->
vec[1][1];
640 lastkey[0] = lastbezt->
vec[1][0];
641 lastkey[1] = lastbezt->
vec[1][1];
648 prevkey[0] = prevfpt->
vec[0];
649 prevkey[1] = prevfpt->
vec[1];
651 lastkey[0] = lastfpt->
vec[0];
652 lastkey[1] = lastfpt->
vec[1];
660 if (
data->before_mode) {
662 mode =
data->before_mode;
663 cycles =
data->before_cycles;
668 if (
data->after_mode) {
670 mode =
data->after_mode;
671 cycles =
data->after_cycles;
675 if (
ELEM(0, side, mode)) {
682 const float cycdx = lastkey[0] - prevkey[0];
683 const float cycdy = lastkey[1] - prevkey[1];
691 const float cycle = ((
float)side * (
evaltime - ofs) / cycdx);
694 const float cyct = fmod(
evaltime - ofs, cycdx);
702 else if (cycle > cycles) {
722 evaltime = (side == 1 ? lastkey[0] : prevkey[0]);
725 evaltime = (side == 1 ? prevkey[0] : lastkey[0]);
753 storage->cycyofs = cycyofs;
794 data->strength = 1.0f;
815 switch (
data->modification) {
817 *cvalue = *cvalue +
noise *
data->strength;
820 *cvalue = *cvalue -
noise *
data->strength;
823 *cvalue = *cvalue *
noise *
data->strength;
827 *cvalue = *cvalue + (
noise - 0.5f) *
data->strength;
918 return data->rect.xmin;
921 return data->rect.xmax;
938 *cvalue =
data->rect.ymin;
941 *cvalue =
data->rect.ymax;
970 data->step_size = 2.0f;
984 if (evaltime < data->start_frame) {
1003 return ((
float)snapblock *
data->step_size) +
data->offset;
1066 CLOG_ERROR(&
LOG,
"No valid F-Curve Modifier type-info data available. Type = %i",
type);
1102 "Cannot add 'Cycles' modifier to F-Curve, as 'Cycles' modifier can only be "
1111 fcm->
curve = owner_fcu;
1175 for (fcm = dst->
first, srcfcm =
src->first; fcm && srcfcm;
1176 srcfcm = srcfcm->
next, fcm = fcm->
next) {
1235 if (modifiers ==
NULL) {
1240 for (fcm = modifiers->
first; fcm; fcm = fmn) {
1256 for (fcm = modifiers->
first; fcm; fcm = fcm->
next) {
1276 for (fm = modifiers->
first; fm; fm = fm->
next) {
1291 if ((mtype == 0) && (acttype == 0)) {
1292 return (modifiers && modifiers->
first);
1301 for (fcm = modifiers->
first; fcm; fcm = fcm->
next) {
1303 short mOk = 1, aOk = 1;
1307 mOk = (fcm->
type == mtype);
1310 aOk = (fmi->
acttype == acttype);
1371 if ((evaltime < fcm->sfra) || (
evaltime > fcm->
efra)) {
1376 (evaltime <= fcm->sfra + fcm->
blendin)) {
1378 float a = fcm->
sfra;
1382 if ((fcm->
blendout != 0.0f) && (evaltime <= fcm->efra) &&
1385 float a = fcm->
efra;
1471 for (fcm = modifiers->
first; fcm; fcm = fcm->
next, fcm_index++) {
1487 float nval = *cvalue;
1491 *cvalue =
interpf(nval, *cvalue, influence);
1507 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 BKE_fcurve_handles_recalc(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)
#define BLT_I18NCONTEXT_ID_ACTION
#define CTX_N_(context, msgid)
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
SyclQueue void void * src
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)
ccl_device_inline float2 fabs(const float2 &a)
ccl_device_inline float3 ceil(const float3 &a)
ccl_device_inline float3 log(float3 v)
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 > sin(const Rall1d< T, V, S > &arg)
INLINE Rall1d< T, V, S > tan(const Rall1d< T, V, S > &arg)
static const pxr::TfToken b("b", pxr::TfToken::Immortal)
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)