[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [19319] branches/blender2.5/blender/source /blender/editors: F-Curve Modifier - Generator: Buttons for builtin-function mode (i.e.
Joshua Leung
aligorith at gmail.com
Tue Mar 17 01:31:11 CET 2009
Revision: 19319
http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=19319
Author: aligorith
Date: 2009-03-17 01:31:10 +0100 (Tue, 17 Mar 2009)
Log Message:
-----------
F-Curve Modifier - Generator: Buttons for builtin-function mode (i.e. sin, cos, etc.)
Modified Paths:
--------------
branches/blender2.5/blender/source/blender/editors/animation/keyframing.c
branches/blender2.5/blender/source/blender/editors/space_graph/graph_buttons.c
Modified: branches/blender2.5/blender/source/blender/editors/animation/keyframing.c
===================================================================
--- branches/blender2.5/blender/source/blender/editors/animation/keyframing.c 2009-03-16 21:39:12 UTC (rev 19318)
+++ branches/blender2.5/blender/source/blender/editors/animation/keyframing.c 2009-03-17 00:31:10 UTC (rev 19319)
@@ -206,7 +206,7 @@
*/
for (loopbreaker=0; (start <= end) && (loopbreaker < maxloop); loopbreaker++) {
/* compute and get midpoint */
- int mid = (start + end) / 2;
+ int mid = start + ((end - start) / 2); /* we calculate the midpoint this way to avoid int overflows... */
float midfra= array[mid].vec[1][0];
/* check if exactly equal to midpoint */
@@ -1046,7 +1046,7 @@
/* ******************************************* */
/* KEYFRAME MODIFICATION */
-/* mode for common_modifykey */
+/* mode for commonkey_modifykey */
enum {
COMMONKEY_MODE_INSERT = 0,
COMMONKEY_MODE_DELETE,
@@ -1623,34 +1623,6 @@
/* set id-block to key to */
ob= base->object;
cks->id= (ID *)ob;
-
- /* when ob's keyframes are in an action, default to using 'Object' as achan name */
- if (ob->ipoflag & OB_ACTION_OB)
- cks->actname= "Object";
-
- /* set ipo-flags */
- // TODO: add checks for lib-linked data
- if ((ob->ipo) || (ob->action)) {
- if (ob->ipo) {
- cks->ipo= ob->ipo;
- }
- else {
- bActionChannel *achan;
-
- cks->act= ob->action;
- achan= get_action_channel(ob->action, cks->actname);
-
- if (achan && achan->ipo)
- cks->ipo= achan->ipo;
- }
- /* cks->ipo can be NULL while editing */
- if(cks->ipo) {
- /* deselect all ipo-curves */
- for (icu= cks->ipo->curve.first; icu; icu= icu->next) {
- icu->flag &= ~IPO_SELECT;
- }
- }
- }
}
CTX_DATA_END;
}
@@ -1799,6 +1771,23 @@
#endif // XXX old keyingsets code based on adrcodes... to be restored in due course
+#if 0 // XXX new relative keyingsets code
+
+/* Check if context data is suitable for the given absolute Keying Set */
+static short keyingset_context_ok_poll (bContext *C, KeyingSet *ks)
+{
+
+ return 1;
+}
+
+/* Get list of data-sources from context for inserting keyframes using the given relative Keying Set */
+static short commonkey_get_context_data (bContext *C, ListBase *dsources, KeyingSet *ks)
+{
+
+}
+
+#endif // XXX new relative keyingsets code
+
/* Given a KeyingSet and context info (if required), modify keyframes for the channels specified
* by the KeyingSet. This takes into account many of the different combinations of using KeyingSets.
* Returns the number of channels that keyframes were added to
Modified: branches/blender2.5/blender/source/blender/editors/space_graph/graph_buttons.c
===================================================================
--- branches/blender2.5/blender/source/blender/editors/space_graph/graph_buttons.c 2009-03-16 21:39:12 UTC (rev 19318)
+++ branches/blender2.5/blender/source/blender/editors/space_graph/graph_buttons.c 2009-03-17 00:31:10 UTC (rev 19319)
@@ -360,13 +360,65 @@
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;
- // TODO: finish adding buttons...
+ /* 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, -FLT_MAX, 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, "", 0, cy, 80, 20, cp, -FLT_MAX, 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;
+ default: /* unknown */
+ sprintf(func_name, "<fn?>(");
+ break;
+ }
+ uiDefBut(block, LABEL, 1, func_name, 80, cy, 40, 20, NULL, 0.0, 0.0, 0, 0, "");
+
+ /* coefficients inside bracket */
+ uiDefButF(block, NUM, B_FMODIFIER_REDRAW, "", 115, cy, 75, 20, cp+1, -FLT_MAX, FLT_MAX, 10, 3, "Coefficient (B) of x");
+
+ uiDefBut(block, LABEL, 1, "x+", 190, cy, 30, 20, NULL, 0.0, 0.0, 0, 0, "");
+
+ uiDefButF(block, NUM, B_FMODIFIER_REDRAW, "", 220, cy, 80, 20, cp+2, -FLT_MAX, 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;
More information about the Bf-blender-cvs
mailing list