diff options
author | Joshua Leung <aligorith@gmail.com> | 2009-06-10 09:03:27 +0400 |
---|---|---|
committer | Joshua Leung <aligorith@gmail.com> | 2009-06-10 09:03:27 +0400 |
commit | 867e1291350de7c128c18c9f9a2e7c4b7a5513f4 (patch) | |
tree | 83538c77dc690760e74121c6c195258da69ad005 /source/blender | |
parent | 2f8290434ca1e36c8a60ebc405a3edaacd41e9a9 (diff) |
F-Modifiers (in Nla branch):
For fun, added 'sinc' (i.e. y = sin(pi*x)/(pi*x)) as a type of builtin function usable through the generator modifier. This makes a nice 'jolt' which tapers off.
Diffstat (limited to 'source/blender')
-rw-r--r-- | source/blender/blenkernel/intern/fcurve.c | 17 | ||||
-rw-r--r-- | source/blender/editors/space_graph/graph_buttons.c | 5 | ||||
-rw-r--r-- | source/blender/makesdna/DNA_anim_types.h | 1 | ||||
-rw-r--r-- | source/blender/makesrna/intern/rna_fcurve.c | 1 |
4 files changed, 22 insertions, 2 deletions
diff --git a/source/blender/blenkernel/intern/fcurve.c b/source/blender/blenkernel/intern/fcurve.c index 6a3870f8f31..5820761234c 100644 --- a/source/blender/blenkernel/intern/fcurve.c +++ b/source/blender/blenkernel/intern/fcurve.c @@ -1410,6 +1410,18 @@ static void fcm_generator_verify (FModifier *fcm) } } +/* 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; @@ -1490,6 +1502,9 @@ static void fcm_generator_evaluate (FCurve *fcu, FModifier *fcm, float *cvalue, 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 */ @@ -1527,7 +1542,7 @@ static void fcm_generator_evaluate (FCurve *fcu, FModifier *fcm, float *cvalue, } } break; - + default: printf("Invalid Function-Generator for F-Modifier - %d \n", data->func_type); } diff --git a/source/blender/editors/space_graph/graph_buttons.c b/source/blender/editors/space_graph/graph_buttons.c index a4babaad74c..5b00205b5d0 100644 --- a/source/blender/editors/space_graph/graph_buttons.c +++ b/source/blender/editors/space_graph/graph_buttons.c @@ -405,7 +405,7 @@ static void draw_modifier__generator(uiBlock *block, FCurve *fcu, FModifier *fcm { 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"; + char fn_type[]="Built-In Function%t|Sin%x0|Cos%x1|Tan%x2|Square Root%x3|Natural Log%x4|Normalised Sin%x5"; int cy= *yco - 30; uiBut *but; @@ -555,6 +555,9 @@ static void draw_modifier__generator(uiBlock *block, FCurve *fcu, FModifier *fcm 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; diff --git a/source/blender/makesdna/DNA_anim_types.h b/source/blender/makesdna/DNA_anim_types.h index c19318629f6..a784adaf35f 100644 --- a/source/blender/makesdna/DNA_anim_types.h +++ b/source/blender/makesdna/DNA_anim_types.h @@ -108,6 +108,7 @@ enum { FCM_GENERATOR_FN_TAN, FCM_GENERATOR_FN_SQRT, FCM_GENERATOR_FN_LN, + FCM_GENERATOR_FN_SINC, } eFMod_Generator_Functions; diff --git a/source/blender/makesrna/intern/rna_fcurve.c b/source/blender/makesrna/intern/rna_fcurve.c index ea26118f267..69103536310 100644 --- a/source/blender/makesrna/intern/rna_fcurve.c +++ b/source/blender/makesrna/intern/rna_fcurve.c @@ -284,6 +284,7 @@ static void rna_def_fmodifier_generator_function(BlenderRNA *brna) {2, "TAN", "Tangent", ""}, {3, "SQRT", "Square Root", ""}, {4, "LN", "Natural Logarithm", ""}, + {5, "SINC", "Normalised Sine", "sin(x) / x"}, {0, NULL, NULL, NULL}}; |