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:
authorJoshua Leung <aligorith@gmail.com>2009-03-17 03:31:10 +0300
committerJoshua Leung <aligorith@gmail.com>2009-03-17 03:31:10 +0300
commitb68f5d7e96ba2451c41ead3361f5faedc39acade (patch)
tree222200637166a4b35ead3a8dd7e9887fb177ad33
parent929c3fe91a2d73b5be476ebbc878f48f8b653e4b (diff)
F-Curve Modifier - Generator: Buttons for builtin-function mode (i.e. sin, cos, etc.)
-rw-r--r--source/blender/editors/animation/keyframing.c49
-rw-r--r--source/blender/editors/space_graph/graph_buttons.c54
2 files changed, 72 insertions, 31 deletions
diff --git a/source/blender/editors/animation/keyframing.c b/source/blender/editors/animation/keyframing.c
index f490fb77438..b031a544953 100644
--- a/source/blender/editors/animation/keyframing.c
+++ b/source/blender/editors/animation/keyframing.c
@@ -206,7 +206,7 @@ static int binarysearch_bezt_index (BezTriple array[], float frame, int arraylen
*/
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 @@ char *ANIM_build_keyingsets_menu (ListBase *list, short for_edit)
/* ******************************************* */
/* KEYFRAME MODIFICATION */
-/* mode for common_modifykey */
+/* mode for commonkey_modifykey */
enum {
COMMONKEY_MODE_INSERT = 0,
COMMONKEY_MODE_DELETE,
@@ -1623,34 +1623,6 @@ static void commonkey_context_getv3d (const bContext *C, ListBase *sources, bKey
/* 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 @@ static void commonkey_context_getsbuts (const bContext *C, ListBase *sources, bK
#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
diff --git a/source/blender/editors/space_graph/graph_buttons.c b/source/blender/editors/space_graph/graph_buttons.c
index 2484dee03a3..59e0fe0ef95 100644
--- a/source/blender/editors/space_graph/graph_buttons.c
+++ b/source/blender/editors/space_graph/graph_buttons.c
@@ -360,13 +360,65 @@ static void _draw_modifier__generator(uiBlock *block, FCurve *fcu, FModifier *fc
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;