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:
-rw-r--r--source/blender/blenkernel/intern/fcurve.c256
-rw-r--r--source/blender/editors/space_graph/graph_buttons.c129
-rw-r--r--source/blender/editors/space_graph/graph_intern.h2
-rw-r--r--source/blender/makesdna/DNA_anim_types.h45
-rw-r--r--source/blender/makesrna/RNA_access.h2
-rw-r--r--source/blender/makesrna/intern/rna_fcurve.c109
6 files changed, 231 insertions, 312 deletions
diff --git a/source/blender/blenkernel/intern/fcurve.c b/source/blender/blenkernel/intern/fcurve.c
index 27ca6332cdc..e52c63d1b21 100644
--- a/source/blender/blenkernel/intern/fcurve.c
+++ b/source/blender/blenkernel/intern/fcurve.c
@@ -1,5 +1,5 @@
/**
- * $Id: fcurve.c 21023 2009-06-20 04:02:49Z aligorith $
+ * $Id$
*
* ***** BEGIN GPL LICENSE BLOCK *****
*
@@ -1314,11 +1314,6 @@ static FModifierTypeInfo FMI_MODNAME = {
* 1) simple polynomial generator:
* - Exanded form - (y = C[0]*(x^(n)) + C[1]*(x^(n-1)) + ... + C[n])
* - Factorised form - (y = (C[0][0]*x + C[0][1]) * (C[1][0]*x + C[1][1]) * ... * (C[n][0]*x + C[n][1]))
- * 2) simple builin 'functions':
- * of the form (y = C[0] * fn( C[1]*x + C[2] ) + C[3])
- * where fn() can be any one of:
- * sin, cos, tan, ln, sqrt
- * 3) expression...
*/
static void fcm_generator_free (FModifier *fcm)
@@ -1409,44 +1404,10 @@ static void fcm_generator_verify (FModifier *fcm)
data->arraysize= data->poly_order * 2;
}
}
- break;
-
- case FCM_GENERATOR_FUNCTION: /* builtin function */
- {
- /* arraysize needs to be 4*/
- if (data->arraysize != 4) {
- float *nc;
-
- /* free the old data */
- if (data->coefficients)
- MEM_freeN(data->coefficients);
-
- /* make new coefficients array, and init using default values */
- nc= data->coefficients= MEM_callocN(sizeof(float)*4, "FMod_Generator_Coefs");
- data->arraysize= 4;
-
- nc[0]= 1.0f;
- nc[1]= 1.0f;
- nc[2]= 0.0f;
- nc[3]= 0.0f;
- }
- }
break;
}
}
-/* Unary 'normalised sine' function
- * y = sin(PI + x) / (PI * x),
- * except for x = 0 when y = 1.
- */
-static double sinc (double x)
-{
- if (fabs(x) < 0.0001)
- return 1.0;
- else
- return sin(M_PI * x) / (M_PI * x);
-}
-
static void fcm_generator_evaluate (FCurve *fcu, FModifier *fcm, float *cvalue, float evaltime)
{
FMod_Generator *data= (FMod_Generator *)fcm->data;
@@ -1509,86 +1470,6 @@ static void fcm_generator_evaluate (FCurve *fcu, FModifier *fcm, float *cvalue,
}
}
break;
-
- case FCM_GENERATOR_FUNCTION: /* builtin function */
- {
- double arg= data->coefficients[1]*evaltime + data->coefficients[2];
- double (*fn)(double v) = NULL;
-
- /* get function pointer to the func to use:
- * WARNING: must perform special argument validation hereto guard against crashes
- */
- switch (data->func_type)
- {
- /* simple ones */
- case FCM_GENERATOR_FN_SIN: /* sine wave */
- fn= sin;
- break;
- case FCM_GENERATOR_FN_COS: /* cosine wave */
- fn= cos;
- break;
- case FCM_GENERATOR_FN_SINC: /* normalised sine wave */
- fn= sinc;
- break;
-
- /* validation required */
- case FCM_GENERATOR_FN_TAN: /* tangent wave */
- {
- /* check that argument is not on one of the discontinuities (i.e. 90deg, 270 deg, etc) */
- if IS_EQ(fmod((arg - M_PI_2), M_PI), 0.0) {
- if ((data->flag & FCM_GENERATOR_ADDITIVE) == 0)
- *cvalue = 0.0f; /* no value possible here */
- }
- else
- fn= tan;
- }
- break;
- case FCM_GENERATOR_FN_LN: /* natural log */
- {
- /* check that value is greater than 1? */
- if (arg > 1.0f) {
- fn= log;
- }
- else {
- if ((data->flag & FCM_GENERATOR_ADDITIVE) == 0)
- *cvalue = 0.0f; /* no value possible here */
- }
- }
- break;
- case FCM_GENERATOR_FN_SQRT: /* square root */
- {
- /* no negative numbers */
- if (arg > 0.0f) {
- fn= sqrt;
- }
- else {
- if ((data->flag & FCM_GENERATOR_ADDITIVE) == 0)
- *cvalue = 0.0f; /* no value possible here */
- }
- }
- break;
-
- default:
- printf("Invalid Function-Generator for F-Modifier - %d \n", data->func_type);
- }
-
- /* execute function callback to set value if appropriate */
- if (fn) {
- float value= (float)(data->coefficients[0]*fn(arg) + data->coefficients[3]);
-
- if (data->flag & FCM_GENERATOR_ADDITIVE)
- *cvalue += value;
- else
- *cvalue= value;
- }
- }
- break;
-
-#ifndef DISABLE_PYTHON
- case FCM_GENERATOR_EXPRESSION: /* py-expression */
- // TODO...
- break;
-#endif /* DISABLE_PYTHON */
}
}
@@ -1607,6 +1488,128 @@ static FModifierTypeInfo FMI_GENERATOR = {
fcm_generator_evaluate /* evaluate */
};
+/* Built-In Function Generator F-Curve Modifier --------------------------- */
+
+/* This uses the general equation for equations:
+ * y = amplitude * fn(phase_multiplier*x + phase_offset) + y_offset
+ *
+ * where amplitude, phase_multiplier/offset, y_offset are user-defined coefficients,
+ * x is the evaluation 'time', and 'y' is the resultant value
+ *
+ * Functions available are
+ * sin, cos, tan, sinc (normalised sin), natural log, square root
+ */
+
+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;
+}
+
+/* Unary 'normalised sine' function
+ * y = sin(PI + x) / (PI * x),
+ * except for x = 0 when y = 1.
+ */
+static double sinc (double x)
+{
+ if (fabs(x) < 0.0001)
+ return 1.0;
+ else
+ return sin(M_PI * x) / (M_PI * x);
+}
+
+static void fcm_fn_generator_evaluate (FCurve *fcu, FModifier *fcm, float *cvalue, float evaltime)
+{
+ 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
+ */
+ switch (data->type)
+ {
+ /* simple ones */
+ case FCM_GENERATOR_FN_SIN: /* sine wave */
+ fn= sin;
+ break;
+ case FCM_GENERATOR_FN_COS: /* cosine wave */
+ fn= cos;
+ break;
+ case FCM_GENERATOR_FN_SINC: /* normalised sine wave */
+ fn= sinc;
+ break;
+
+ /* validation required */
+ case FCM_GENERATOR_FN_TAN: /* tangent wave */
+ {
+ /* check that argument is not on one of the discontinuities (i.e. 90deg, 270 deg, etc) */
+ if IS_EQ(fmod((arg - M_PI_2), M_PI), 0.0) {
+ if ((data->flag & FCM_GENERATOR_ADDITIVE) == 0)
+ *cvalue = 0.0f; /* no value possible here */
+ }
+ else
+ fn= tan;
+ }
+ break;
+ case FCM_GENERATOR_FN_LN: /* natural log */
+ {
+ /* check that value is greater than 1? */
+ if (arg > 1.0f) {
+ fn= log;
+ }
+ else {
+ if ((data->flag & FCM_GENERATOR_ADDITIVE) == 0)
+ *cvalue = 0.0f; /* no value possible here */
+ }
+ }
+ break;
+ case FCM_GENERATOR_FN_SQRT: /* square root */
+ {
+ /* no negative numbers */
+ if (arg > 0.0f) {
+ fn= sqrt;
+ }
+ else {
+ if ((data->flag & FCM_GENERATOR_ADDITIVE) == 0)
+ *cvalue = 0.0f; /* no value possible here */
+ }
+ }
+ break;
+
+ default:
+ printf("Invalid Function-Generator for F-Modifier - %d \n", data->type);
+ }
+
+ /* execute function callback to set value if appropriate */
+ if (fn) {
+ float value= (float)(data->amplitude*fn(arg) + data->value_offset);
+
+ if (data->flag & FCM_GENERATOR_ADDITIVE)
+ *cvalue += value;
+ else
+ *cvalue= value;
+ }
+}
+
+static FModifierTypeInfo FMI_FN_GENERATOR = {
+ FMODIFIER_TYPE_FN_GENERATOR, /* type */
+ sizeof(FMod_FunctionGenerator), /* size */
+ FMI_TYPE_GENERATE_CURVE, /* action type */
+ FMI_REQUIRES_NOTHING, /* requirements */
+ "Built-In Function", /* name */
+ "FMod_FunctionGenerator", /* struct name */
+ NULL, /* free data */
+ NULL, /* copy data */
+ fcm_fn_generator_new_data, /* new data */
+ NULL, /* verify */
+ NULL, /* evaluate time */
+ fcm_fn_generator_evaluate /* evaluate */
+};
+
/* Envelope F-Curve Modifier --------------------------- */
static void fcm_envelope_free (FModifier *fcm)
@@ -2081,12 +2084,13 @@ static void fmods_init_typeinfo ()
{
fmodifiersTypeInfo[0]= NULL; /* 'Null' F-Curve Modifier */
fmodifiersTypeInfo[1]= &FMI_GENERATOR; /* Generator F-Curve Modifier */
- fmodifiersTypeInfo[2]= &FMI_ENVELOPE; /* Envelope F-Curve Modifier */
- fmodifiersTypeInfo[3]= &FMI_CYCLES; /* Cycles F-Curve Modifier */
- fmodifiersTypeInfo[4]= &FMI_NOISE; /* Apply-Noise F-Curve Modifier */
- fmodifiersTypeInfo[5]= NULL/*&FMI_FILTER*/; /* Filter F-Curve Modifier */ // XXX unimplemented
- fmodifiersTypeInfo[6]= &FMI_PYTHON; /* Custom Python F-Curve Modifier */
- fmodifiersTypeInfo[7]= &FMI_LIMITS; /* Limits F-Curve Modifier */
+ fmodifiersTypeInfo[2]= &FMI_FN_GENERATOR; /* Built-In Function Generator F-Curve Modifier */
+ fmodifiersTypeInfo[3]= &FMI_ENVELOPE; /* Envelope F-Curve Modifier */
+ fmodifiersTypeInfo[4]= &FMI_CYCLES; /* Cycles F-Curve Modifier */
+ fmodifiersTypeInfo[5]= &FMI_NOISE; /* Apply-Noise F-Curve Modifier */
+ fmodifiersTypeInfo[6]= NULL/*&FMI_FILTER*/; /* Filter F-Curve Modifier */ // XXX unimplemented
+ fmodifiersTypeInfo[7]= &FMI_PYTHON; /* Custom Python F-Curve Modifier */
+ fmodifiersTypeInfo[8]= &FMI_LIMITS; /* Limits F-Curve Modifier */
}
/* This function should be used for getting the appropriate type-info when only
diff --git a/source/blender/editors/space_graph/graph_buttons.c b/source/blender/editors/space_graph/graph_buttons.c
index f2dcd297866..e68ee53521d 100644
--- a/source/blender/editors/space_graph/graph_buttons.c
+++ b/source/blender/editors/space_graph/graph_buttons.c
@@ -404,8 +404,7 @@ static void delete_fmodifier_cb (bContext *C, void *fcu_v, void *fcm_v)
static void draw_modifier__generator(uiBlock *block, FCurve *fcu, FModifier *fcm, int *yco, short *height, short width, short active, int rb_col)
{
FMod_Generator *data= (FMod_Generator *)fcm->data;
- char gen_mode[]="Generator Type%t|Expanded Polynomial%x0|Factorised Polynomial%x1|Built-In Function%x2|Expression%x3";
- char fn_type[]="Built-In Function%t|Sin%x0|Cos%x1|Tan%x2|Square Root%x3|Natural Log%x4|Normalised Sin%x5";
+ char gen_mode[]="Generator Type%t|Expanded Polynomial%x0|Factorised Polynomial%x1";
int cy= *yco - 30;
uiBut *but;
@@ -418,22 +417,16 @@ static void draw_modifier__generator(uiBlock *block, FCurve *fcu, FModifier *fcm
case FCM_GENERATOR_POLYNOMIAL_FACTORISED: /* factorised polynomial */
(*height) += 20 * data->poly_order + 15;
break;
- case FCM_GENERATOR_FUNCTION: /* builtin function */
- (*height) += 55; // xxx
- break;
- case FCM_GENERATOR_EXPRESSION: /* py-expression */
- // xxx nothing to draw
- break;
}
/* basic settings (backdrop + mode selector + some padding) */
DRAW_BACKDROP((*height));
uiBlockBeginAlign(block);
- but= uiDefButS(block, MENU, B_FMODIFIER_REDRAW, gen_mode, 10,cy,width-30,19, &data->mode, 0, 0, 0, 0, "Selects type of generator algorithm.");
+ but= uiDefButI(block, MENU, B_FMODIFIER_REDRAW, gen_mode, 10,cy,width-30,19, &data->mode, 0, 0, 0, 0, "Selects type of generator algorithm.");
uiButSetFunc(but, validate_fmodifier_cb, fcu, fcm);
cy -= 20;
- uiDefButBitS(block, TOG, FCM_GENERATOR_ADDITIVE, B_FMODIFIER_REDRAW, "Additive", 10,cy,width-30,19, &data->flag, 0, 0, 0, 0, "Values generated by this modifier are applied on top of the existing values instead of overwriting them");
+ uiDefButBitI(block, TOG, FCM_GENERATOR_ADDITIVE, B_FMODIFIER_REDRAW, "Additive", 10,cy,width-30,19, &data->flag, 0, 0, 0, 0, "Values generated by this modifier are applied on top of the existing values instead of overwriting them");
cy -= 35;
uiBlockEndAlign(block);
@@ -446,7 +439,7 @@ static void draw_modifier__generator(uiBlock *block, FCurve *fcu, FModifier *fcm
unsigned int i;
/* draw polynomial order selector */
- but= uiDefButS(block, NUM, B_FMODIFIER_REDRAW, "Poly Order: ", 10,cy,width-30,19, &data->poly_order, 1, 100, 0, 0, "'Order' of the Polynomial - for a polynomial with n terms, 'order' is n-1");
+ but= uiDefButI(block, NUM, B_FMODIFIER_REDRAW, "Poly Order: ", 10,cy,width-30,19, &data->poly_order, 1, 100, 0, 0, "'Order' of the Polynomial - for a polynomial with n terms, 'order' is n-1");
uiButSetFunc(but, validate_fmodifier_cb, fcu, fcm);
cy -= 35;
@@ -481,7 +474,7 @@ static void draw_modifier__generator(uiBlock *block, FCurve *fcu, FModifier *fcm
unsigned int i;
/* draw polynomial order selector */
- but= uiDefButS(block, NUM, B_FMODIFIER_REDRAW, "Poly Order: ", 10,cy,width-30,19, &data->poly_order, 1, 100, 0, 0, "'Order' of the Polynomial - for a polynomial with n terms, 'order' is n-1");
+ but= uiDefButI(block, NUM, B_FMODIFIER_REDRAW, "Poly Order: ", 10,cy,width-30,19, &data->poly_order, 1, 100, 0, 0, "'Order' of the Polynomial - for a polynomial with n terms, 'order' is n-1");
uiButSetFunc(but, validate_fmodifier_cb, fcu, fcm);
cy -= 35;
@@ -510,82 +503,42 @@ static void draw_modifier__generator(uiBlock *block, FCurve *fcu, FModifier *fcm
}
}
break;
-
- case FCM_GENERATOR_FUNCTION: /* built-in function */
- {
- float *cp= data->coefficients;
-
- /* draw function selector */
- but= uiDefButS(block, MENU, B_FMODIFIER_REDRAW, fn_type, 10,cy,width-30,19, &data->func_type, 0, 0, 0, 0, "Built-In Function to use");
- uiButSetFunc(but, validate_fmodifier_cb, fcu, fcm);
- cy -= 35;
-
- /* draw controls for equation of coefficients */
- /* row 1 */
- {
- uiDefBut(block, LABEL, 1, "y = ", 0, cy, 50, 20, NULL, 0.0, 0.0, 0, 0, "");
-
- uiDefButF(block, NUM, B_FMODIFIER_REDRAW, "", 50, cy, 150, 20, cp+3, -UI_FLT_MAX, UI_FLT_MAX, 10, 3, "Coefficient (D) for function");
- uiDefBut(block, LABEL, 1, "+", 200, cy, 30, 20, NULL, 0.0, 0.0, 0, 0, "");
- cy -= 20;
- }
-
- /* row 2 */
- {
- char func_name[32];
-
- /* coefficient outside bracket */
- uiDefButF(block, NUM, B_FMODIFIER_REDRAW, "", 5, cy, 80, 20, cp, -UI_FLT_MAX, UI_FLT_MAX, 10, 3, "Coefficient (A) for function");
-
- /* opening bracket */
- switch (data->func_type)
- {
- case FCM_GENERATOR_FN_SIN: /* sine wave */
- sprintf(func_name, "sin(");
- break;
- case FCM_GENERATOR_FN_COS: /* cosine wave */
- sprintf(func_name, "cos(");
- break;
- case FCM_GENERATOR_FN_TAN: /* tangent wave */
- sprintf(func_name, "tan(");
- break;
- case FCM_GENERATOR_FN_LN: /* natural log */
- sprintf(func_name, "ln(");
- break;
- case FCM_GENERATOR_FN_SQRT: /* square root */
- sprintf(func_name, "sqrt(");
- break;
- case FCM_GENERATOR_FN_SINC: /* normalised sine wave */
- sprintf(func_name, "sinc(");
- break;
- default: /* unknown */
- sprintf(func_name, "<fn?>(");
- break;
- }
- uiDefBut(block, LABEL, 1, func_name, 85, cy, 40, 20, NULL, 0.0, 0.0, 0, 0, "");
-
- /* coefficients inside bracket */
- uiDefButF(block, NUM, B_FMODIFIER_REDRAW, "", 120, cy, 75, 20, cp+1, -UI_FLT_MAX, UI_FLT_MAX, 10, 3, "Coefficient (B) of x");
-
- uiDefBut(block, LABEL, 1, "x+", 195, cy, 30, 20, NULL, 0.0, 0.0, 0, 0, "");
-
- uiDefButF(block, NUM, B_FMODIFIER_REDRAW, "", 225, cy, 80, 20, cp+2, -UI_FLT_MAX, UI_FLT_MAX, 10, 3, "Coefficient (C) of function");
-
- /* closing bracket */
- uiDefBut(block, LABEL, 1, ")", 300, cy, 30, 20, NULL, 0.0, 0.0, 0, 0, "");
- cy -= 20;
- }
- }
- break;
-
- case FCM_GENERATOR_EXPRESSION: /* py-expression */
- // TODO...
- break;
}
}
/* --------------- */
+/* draw settings for noise modifier */
+static void draw_modifier__fn_generator(uiBlock *block, FCurve *fcu, FModifier *fcm, int *yco, short *height, short width, short active, int rb_col)
+{
+ FMod_FunctionGenerator *data= (FMod_FunctionGenerator *)fcm->data;
+ int cy= (*yco - 30), cy1= (*yco - 50), cy2= (*yco - 70);
+ char fn_type[]="Built-In Function%t|Sin%x0|Cos%x1|Tan%x2|Square Root%x3|Natural Log%x4|Normalised Sin%x5";
+
+ /* set the height */
+ (*height) = 80;
+
+ /* basic settings (backdrop + some padding) */
+ DRAW_BACKDROP((*height));
+
+ uiDefButI(block, MENU, B_FMODIFIER_REDRAW, fn_type,
+ 3, cy, 300, 20, &data->type, 0, 0, 0, 0, "Type of function used to generate values");
+
+
+ uiDefButF(block, NUM, B_FMODIFIER_REDRAW, "Amplitude:",
+ 3, cy1, 150, 20, &data->amplitude, 0.000001, 10000.0, 0.01, 3, "Scale factor determining the maximum/minimum values.");
+ uiDefButF(block, NUM, B_FMODIFIER_REDRAW, "Value Offset:",
+ 3, cy2, 150, 20, &data->value_offset, 0.0, 10000.0, 0.01, 3, "Constant factor to offset values by.");
+
+ uiDefButF(block, NUM, B_FMODIFIER_REDRAW, "Phase Multiplier:",
+ 155, cy1, 150, 20, &data->phase_multiplier, 0.0, 100000.0, 0.1, 3, "Scale factor determining the 'speed' of the function.");
+ uiDefButF(block, NUM, B_FMODIFIER_REDRAW, "Phase Offset:",
+ 155, cy2, 150, 20, &data->phase_offset, 0.0, 100000.0, 0.1, 3, "Constant factor to offset time by for function.");
+
+}
+
+/* --------------- */
+
/* draw settings for cycles modifier */
static void draw_modifier__cycles(uiBlock *block, FCurve *fcu, FModifier *fcm, int *yco, short *height, short width, short active, int rb_col)
{
@@ -621,7 +574,7 @@ static void draw_modifier__noise(uiBlock *block, FCurve *fcu, FModifier *fcm, in
{
FMod_Noise *data= (FMod_Noise *)fcm->data;
int cy= (*yco - 30), cy1= (*yco - 50), cy2= (*yco - 70);
- char cyc_mode[]="Modification %t|Replace %x0|Add %x1|Subtract %x2|Multiply %x3";
+ char blend_mode[]="Modification %t|Replace %x0|Add %x1|Subtract %x2|Multiply %x3";
/* set the height */
(*height) = 80;
@@ -629,8 +582,8 @@ static void draw_modifier__noise(uiBlock *block, FCurve *fcu, FModifier *fcm, in
/* basic settings (backdrop + some padding) */
DRAW_BACKDROP((*height));
- uiDefButS(block, MENU, B_FMODIFIER_REDRAW, cyc_mode,
- 3, cy, 150, 20, &data->modification, 0, 0, 0, 0, "Method of modifying the existing F-Curve use before first keyframe");
+ uiDefButS(block, MENU, B_FMODIFIER_REDRAW, blend_mode,
+ 3, cy, 150, 20, &data->modification, 0, 0, 0, 0, "Method of combining the results of this modifier and other modifiers.");
uiDefButF(block, NUM, B_FMODIFIER_REDRAW, "Size:",
3, cy1, 150, 20, &data->size, 0.000001, 10000.0, 0.01, 3, "");
@@ -946,6 +899,10 @@ static void graph_panel_modifier_draw(uiBlock *block, FCurve *fcu, FModifier *fc
draw_modifier__generator(block, fcu, fcm, yco, &height, width, active, rb_col);
break;
+ case FMODIFIER_TYPE_FN_GENERATOR: /* Built-In Function Generator */
+ draw_modifier__fn_generator(block, fcu, fcm, yco, &height, width, active, rb_col);
+ break;
+
case FMODIFIER_TYPE_CYCLES: /* Cycles */
draw_modifier__cycles(block, fcu, fcm, yco, &height, width, active, rb_col);
break;
diff --git a/source/blender/editors/space_graph/graph_intern.h b/source/blender/editors/space_graph/graph_intern.h
index fd7fe7cc6c9..86e5451122d 100644
--- a/source/blender/editors/space_graph/graph_intern.h
+++ b/source/blender/editors/space_graph/graph_intern.h
@@ -32,6 +32,8 @@ struct bContext;
struct wmWindowManager;
struct bAnimContext;
struct bAnimListElem;
+struct FCurve;
+struct FModifier;
struct SpaceIpo;
struct ScrArea;
struct ARegion;
diff --git a/source/blender/makesdna/DNA_anim_types.h b/source/blender/makesdna/DNA_anim_types.h
index 2b089530236..ad3edde6552 100644
--- a/source/blender/makesdna/DNA_anim_types.h
+++ b/source/blender/makesdna/DNA_anim_types.h
@@ -1,5 +1,5 @@
/**
- * $Id: DNA_anim_types.h 21023 2009-06-20 04:02:49Z aligorith $
+ * $Id$
*
* ***** BEGIN GPL LICENSE BLOCK *****
*
@@ -66,6 +66,7 @@ typedef struct FModifier {
enum {
FMODIFIER_TYPE_NULL = 0,
FMODIFIER_TYPE_GENERATOR,
+ FMODIFIER_TYPE_FN_GENERATOR,
FMODIFIER_TYPE_ENVELOPE,
FMODIFIER_TYPE_CYCLES,
FMODIFIER_TYPE_NOISE, /* unimplemented - generate variations using some basic noise generator... */
@@ -91,39 +92,55 @@ enum {
/* --- */
-/* generator modifier data */
+/* Generator modifier data */
typedef struct FMod_Generator {
- /* generator based on PyExpression */
- char expression[256]; /* python expression to use as generator */
-
/* general generator information */
float *coefficients; /* coefficients array */
unsigned int arraysize; /* size of the coefficients array */
- short poly_order; /* order of polynomial generated (i.e. 1 for linear, 2 for quadratic) */
- short func_type; /* builtin math function eFMod_Generator_Functions */
-
- int pad;
+ int poly_order; /* order of polynomial generated (i.e. 1 for linear, 2 for quadratic) */
+ int mode; /* which 'generator' to use eFMod_Generator_Modes */
/* settings */
- short flag; /* settings */
- short mode; /* which 'generator' to use eFMod_Generator_Modes */
+ int flag; /* settings */
} FMod_Generator;
/* generator modes */
enum {
FCM_GENERATOR_POLYNOMIAL = 0,
FCM_GENERATOR_POLYNOMIAL_FACTORISED,
- FCM_GENERATOR_FUNCTION,
- FCM_GENERATOR_EXPRESSION,
} eFMod_Generator_Modes;
-/* generator flags */
+
+/* generator flags
+ * - shared by Generator and Function Generator
+ */
enum {
/* generator works in conjunction with other modifiers (i.e. doesn't replace those before it) */
FCM_GENERATOR_ADDITIVE = (1<<0),
} eFMod_Generator_Flags;
+
+/* 'Built-In Function' Generator modifier data
+ *
+ * This uses the general equation for equations:
+ * y = amplitude * fn(phase_multiplier*x + phase_offset) + y_offset
+ *
+ * where amplitude, phase_multiplier/offset, y_offset are user-defined coefficients,
+ * x is the evaluation 'time', and 'y' is the resultant value
+ */
+typedef struct FMod_FunctionGenerator {
+ /* coefficients for general equation (as above) */
+ float amplitude;
+ float phase_multiplier;
+ float phase_offset;
+ float value_offset;
+
+ /* flags */
+ int type; /* eFMod_Generator_Functions */
+ int flag; /* eFMod_Generator_flags */
+} FMod_FunctionGenerator;
+
/* 'function' generator types */
enum {
FCM_GENERATOR_FN_SIN = 0,
diff --git a/source/blender/makesrna/RNA_access.h b/source/blender/makesrna/RNA_access.h
index dda0d57f8ad..cf74a863401 100644
--- a/source/blender/makesrna/RNA_access.h
+++ b/source/blender/makesrna/RNA_access.h
@@ -177,8 +177,8 @@ extern StructRNA RNA_FCurve;
extern StructRNA RNA_FModifier;
extern StructRNA RNA_FModifierCycles;
extern StructRNA RNA_FModifierEnvelope;
+extern StructRNA RNA_FModifierFunctionGenerator;
extern StructRNA RNA_FModifierGenerator;
-extern StructRNA RNA_FModifierGenerator_Function;
extern StructRNA RNA_FModifierGenerator_PolyExpanded;
extern StructRNA RNA_FModifierLimits;
extern StructRNA RNA_FModifierNoise;
diff --git a/source/blender/makesrna/intern/rna_fcurve.c b/source/blender/makesrna/intern/rna_fcurve.c
index a1cd95c9d90..4a83b80a6cf 100644
--- a/source/blender/makesrna/intern/rna_fcurve.c
+++ b/source/blender/makesrna/intern/rna_fcurve.c
@@ -37,6 +37,7 @@
EnumPropertyItem fmodifier_type_items[] = {
{FMODIFIER_TYPE_NULL, "NULL", 0, "Invalid", ""},
{FMODIFIER_TYPE_GENERATOR, "GENERATOR", 0, "Generator", ""},
+ {FMODIFIER_TYPE_FN_GENERATOR, "FNGENERATOR", 0, "Built-In Function", ""},
{FMODIFIER_TYPE_ENVELOPE, "ENVELOPE", 0, "Envelope", ""},
{FMODIFIER_TYPE_CYCLES, "CYCLES", 0, "Cycles", ""},
{FMODIFIER_TYPE_NOISE, "NOISE", 0, "Noise", ""},
@@ -47,62 +48,6 @@ EnumPropertyItem fmodifier_type_items[] = {
#ifdef RNA_RUNTIME
-float FModGenFunc_amplitude_get(PointerRNA *ptr)
-{
- FModifier *fcm = (FModifier *)(ptr->data);
- FMod_Generator *data= (FMod_Generator*)(fcm->data);
- return (data->coefficients) ? (float)data->coefficients[0] : 1.0f;
-}
-
-void FModGenFunc_amplitude_set(PointerRNA *ptr, float value)
-{
- FModifier *fcm = (FModifier *)(ptr->data);
- FMod_Generator *data= (FMod_Generator*)(fcm->data);
- if (data->coefficients) data->coefficients[0]= value;
-}
-
-float FModGenFunc_pre_multiplier_get(PointerRNA *ptr)
-{
- FModifier *fcm = (FModifier *)(ptr->data);
- FMod_Generator *data= (FMod_Generator*)(fcm->data);
- return (data->coefficients) ? (float)data->coefficients[1] : 1.0f;
-}
-
-void FModGenFunc_pre_multiplier_set(PointerRNA *ptr, float value)
-{
- FModifier *fcm = (FModifier *)(ptr->data);
- FMod_Generator *data= (FMod_Generator*)(fcm->data);
- if (data->coefficients) data->coefficients[1]= value;
-}
-
-float FModGenFunc_x_offset_get(PointerRNA *ptr)
-{
- FModifier *fcm = (FModifier *)(ptr->data);
- FMod_Generator *data= (FMod_Generator*)(fcm->data);
- return (data->coefficients) ? (float)data->coefficients[2] : 0.0f;
-}
-
-void FModGenFunc_x_offset_set(PointerRNA *ptr, float value)
-{
- FModifier *fcm = (FModifier *)(ptr->data);
- FMod_Generator *data= (FMod_Generator*)(fcm->data);
- if (data->coefficients) data->coefficients[2]= value;
-}
-
-float FModGenFunc_y_offset_get(PointerRNA *ptr)
-{
- FModifier *fcm = (FModifier *)(ptr->data);
- FMod_Generator *data= (FMod_Generator*)(fcm->data);
- return (data->coefficients) ? (float)data->coefficients[3] : 0.0f;
-}
-
-void FModGenFunc_y_offset_set(PointerRNA *ptr, float value)
-{
- FModifier *fcm = (FModifier *)(ptr->data);
- FMod_Generator *data= (FMod_Generator*)(fcm->data);
- if (data->coefficients) data->coefficients[3]= value;
-}
-
/* --------- */
StructRNA *rna_FModifierType_refine(struct PointerRNA *ptr)
@@ -118,13 +63,12 @@ StructRNA *rna_FModifierType_refine(struct PointerRNA *ptr)
case FCM_GENERATOR_POLYNOMIAL:
return &RNA_FModifierGenerator_PolyExpanded;
//case FCM_GENERATOR_POLYNOMIAL_FACTORISED:
- case FCM_GENERATOR_FUNCTION:
- return &RNA_FModifierGenerator_Function;
- //case FCM_GENERATOR_EXPRESSION:
default:
return &RNA_FModifierGenerator;
}
}
+ case FMODIFIER_TYPE_FN_GENERATOR:
+ return &RNA_FModifierFunctionGenerator;
case FMODIFIER_TYPE_ENVELOPE:
return &RNA_FModifierEnvelope;
case FMODIFIER_TYPE_CYCLES:
@@ -222,8 +166,6 @@ static void rna_def_fmodifier_generator_common(StructRNA *srna)
static EnumPropertyItem prop_mode_items[] = {
{FCM_GENERATOR_POLYNOMIAL, "POLYNOMIAL", 0, "Expanded Polynomial", ""},
{FCM_GENERATOR_POLYNOMIAL_FACTORISED, "POLYNOMIAL_FACTORISED", 0, "Factorised Polynomial", ""},
- {FCM_GENERATOR_FUNCTION, "FUNCTION", 0, "Built-In Function", ""},
- {FCM_GENERATOR_EXPRESSION, "EXPRESSION", 0, "Expression", ""},
{0, NULL, 0, NULL, NULL}};
/* struct wrapping settings */
@@ -273,7 +215,7 @@ static void rna_def_fmodifier_generator_polyexpanded(BlenderRNA *brna)
//RNA_def_property_ui_text(prop, "Coefficients", "Coefficients for 'x' (starting from lowest power).");
}
-static void rna_def_fmodifier_generator_function(BlenderRNA *brna)
+static void rna_def_fmodifier_function_generator(BlenderRNA *brna)
{
StructRNA *srna;
PropertyRNA *prop;
@@ -286,35 +228,32 @@ static void rna_def_fmodifier_generator_function(BlenderRNA *brna)
{4, "LN", 0, "Natural Logarithm", ""},
{5, "SINC", 0, "Normalised Sine", "sin(x) / x"},
{0, NULL, 0, NULL, NULL}};
-
-
- srna= RNA_def_struct(brna, "FModifierGenerator_Function", "FModifier");
- RNA_def_struct_ui_text(srna, "Built-In Function Generator", "Generates values for modified F-Curve using Built-In Function.");
-
- /* common settings */
- rna_def_fmodifier_generator_common(srna);
- /* type */
- prop= RNA_def_property(srna, "func_type", PROP_ENUM, PROP_NONE);
- RNA_def_property_enum_items(prop, prop_type_items);
- RNA_def_property_ui_text(prop, "Type", "Type of Built-In function to use as generator.");
+ srna= RNA_def_struct(brna, "FModifierFunctionGenerator", "FModifier");
+ RNA_def_struct_ui_text(srna, "Built-In Function F-Curve Modifier", "Generates values using a Built-In Function.");
+ RNA_def_struct_sdna_from(srna, "FMod_FunctionGenerator", "data");
/* coefficients */
prop= RNA_def_property(srna, "amplitude", PROP_FLOAT, PROP_NONE);
- RNA_def_property_float_funcs(prop, "FModGenFunc_amplitude_get", "FModGenFunc_amplitude_set", NULL);
- RNA_def_property_ui_text(prop, "Amplitude", "Scale factor for y-values generated by the function.");
+ RNA_def_property_ui_text(prop, "Amplitude", "Scale factor determining the maximum/minimum values.");
+
+ prop= RNA_def_property(srna, "phase_multiplier", PROP_FLOAT, PROP_NONE);
+ RNA_def_property_ui_text(prop, "Phase Multiplier", "Scale factor determining the 'speed' of the function.");
- prop= RNA_def_property(srna, "pre_multiplier", PROP_FLOAT, PROP_NONE);
- RNA_def_property_float_funcs(prop, "FModGenFunc_pre_multiplier_get", "FModGenFunc_pre_multiplier_set", NULL);
- RNA_def_property_ui_text(prop, "PreMultiplier", "Scale factor for x-value inputs to function.");
+ prop= RNA_def_property(srna, "phase_offset", PROP_FLOAT, PROP_NONE);
+ RNA_def_property_ui_text(prop, "Phase Offset", "Constant factor to offset time by for function.");
- prop= RNA_def_property(srna, "x_offset", PROP_FLOAT, PROP_NONE);
- RNA_def_property_float_funcs(prop, "FModGenFunc_x_offset_get", "FModGenFunc_x_offset_set", NULL);
- RNA_def_property_ui_text(prop, "X Offset", "Offset for x-value inputs to function.");
+ prop= RNA_def_property(srna, "value_offset", PROP_FLOAT, PROP_NONE);
+ RNA_def_property_ui_text(prop, "Value Offset", "Constant factor to offset values by.");
- prop= RNA_def_property(srna, "y_offset", PROP_FLOAT, PROP_NONE);
- RNA_def_property_float_funcs(prop, "FModGenFunc_y_offset_get", "FModGenFunc_y_offset_set", NULL);
- RNA_def_property_ui_text(prop, "Y Offset", "Offset for y-values generated by the function.");
+ /* flags */
+ prop= RNA_def_property(srna, "additive", PROP_BOOLEAN, PROP_NONE);
+ RNA_def_property_boolean_sdna(prop, NULL, "flag", FCM_GENERATOR_ADDITIVE);
+ RNA_def_property_ui_text(prop, "Additive", "Values generated by this modifier are applied on top of the existing values instead of overwriting them.");
+
+ prop= RNA_def_property(srna, "type", PROP_ENUM, PROP_NONE);
+ RNA_def_property_enum_items(prop, prop_type_items);
+ RNA_def_property_ui_text(prop, "Type", "Type of built-in function to use.");
}
/* --------- */
@@ -646,7 +585,7 @@ void RNA_def_fcurve(BlenderRNA *brna)
rna_def_fmodifier_generator(brna);
rna_def_fmodifier_generator_polyexpanded(brna);
- rna_def_fmodifier_generator_function(brna);
+ rna_def_fmodifier_function_generator(brna);
rna_def_fmodifier_envelope(brna);
rna_def_fmodifier_cycles(brna);
rna_def_fmodifier_python(brna);