[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [20775] branches/soc-2009-aligorith/source /blender: F-Modifiers (in Nla branch):

Joshua Leung aligorith at gmail.com
Wed Jun 10 07:03:27 CEST 2009


Revision: 20775
          http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=20775
Author:   aligorith
Date:     2009-06-10 07:03:27 +0200 (Wed, 10 Jun 2009)

Log Message:
-----------
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.

Modified Paths:
--------------
    branches/soc-2009-aligorith/source/blender/blenkernel/intern/fcurve.c
    branches/soc-2009-aligorith/source/blender/editors/space_graph/graph_buttons.c
    branches/soc-2009-aligorith/source/blender/makesdna/DNA_anim_types.h
    branches/soc-2009-aligorith/source/blender/makesrna/intern/rna_fcurve.c

Modified: branches/soc-2009-aligorith/source/blender/blenkernel/intern/fcurve.c
===================================================================
--- branches/soc-2009-aligorith/source/blender/blenkernel/intern/fcurve.c	2009-06-10 04:43:18 UTC (rev 20774)
+++ branches/soc-2009-aligorith/source/blender/blenkernel/intern/fcurve.c	2009-06-10 05:03:27 UTC (rev 20775)
@@ -1410,6 +1410,18 @@
 	}
 }
 
+/* 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 @@
 				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 @@
 					}
 				}
 					break;
-					
+				
 				default:
 					printf("Invalid Function-Generator for F-Modifier - %d \n", data->func_type);
 			}

Modified: branches/soc-2009-aligorith/source/blender/editors/space_graph/graph_buttons.c
===================================================================
--- branches/soc-2009-aligorith/source/blender/editors/space_graph/graph_buttons.c	2009-06-10 04:43:18 UTC (rev 20774)
+++ branches/soc-2009-aligorith/source/blender/editors/space_graph/graph_buttons.c	2009-06-10 05:03:27 UTC (rev 20775)
@@ -405,7 +405,7 @@
 {
 	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 @@
 					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;

Modified: branches/soc-2009-aligorith/source/blender/makesdna/DNA_anim_types.h
===================================================================
--- branches/soc-2009-aligorith/source/blender/makesdna/DNA_anim_types.h	2009-06-10 04:43:18 UTC (rev 20774)
+++ branches/soc-2009-aligorith/source/blender/makesdna/DNA_anim_types.h	2009-06-10 05:03:27 UTC (rev 20775)
@@ -108,6 +108,7 @@
 	FCM_GENERATOR_FN_TAN,
 	FCM_GENERATOR_FN_SQRT,
 	FCM_GENERATOR_FN_LN,
+	FCM_GENERATOR_FN_SINC,
 } eFMod_Generator_Functions;
 
 

Modified: branches/soc-2009-aligorith/source/blender/makesrna/intern/rna_fcurve.c
===================================================================
--- branches/soc-2009-aligorith/source/blender/makesrna/intern/rna_fcurve.c	2009-06-10 04:43:18 UTC (rev 20774)
+++ branches/soc-2009-aligorith/source/blender/makesrna/intern/rna_fcurve.c	2009-06-10 05:03:27 UTC (rev 20775)
@@ -284,6 +284,7 @@
 		{2, "TAN", "Tangent", ""},
 		{3, "SQRT", "Square Root", ""},
 		{4, "LN", "Natural Logarithm", ""},
+		{5, "SINC", "Normalised Sine", "sin(x) / x"},
 		{0, NULL, NULL, NULL}};
 		
 	





More information about the Bf-blender-cvs mailing list