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/BKE_fcurve.h3
-rw-r--r--source/blender/blenkernel/intern/fcurve.c67
-rw-r--r--source/blender/editors/space_graph/graph_edit.c35
-rw-r--r--source/blender/editors/space_graph/graph_ops.c8
4 files changed, 90 insertions, 23 deletions
diff --git a/source/blender/blenkernel/BKE_fcurve.h b/source/blender/blenkernel/BKE_fcurve.h
index 87c230eec91..dd5e0dd6e21 100644
--- a/source/blender/blenkernel/BKE_fcurve.h
+++ b/source/blender/blenkernel/BKE_fcurve.h
@@ -89,6 +89,9 @@ struct FCurve *list_find_fcurve(ListBase *list, const char rna_path[], const int
/* get the time extents for F-Curve */
void calc_fcurve_range(struct FCurve *fcu, float *min, float *max);
+/* get the bounding-box extents for F-Curve */
+void calc_fcurve_bounds(struct FCurve *fcu, float *xmin, float *xmax, float *ymin, float *ymax);
+
/* -------- Curve Sanity -------- */
void calchandles_fcurve(struct FCurve *fcu);
diff --git a/source/blender/blenkernel/intern/fcurve.c b/source/blender/blenkernel/intern/fcurve.c
index 72e4932e622..6f8732a35e2 100644
--- a/source/blender/blenkernel/intern/fcurve.c
+++ b/source/blender/blenkernel/intern/fcurve.c
@@ -170,6 +170,73 @@ FCurve *list_find_fcurve (ListBase *list, const char rna_path[], const int array
return NULL;
}
+/* Calculate the extents of F-Curve's data */
+void calc_fcurve_bounds (FCurve *fcu, float *xmin, float *xmax, float *ymin, float *ymax)
+{
+ float xminv=999999999.0f, xmaxv=-999999999.0f;
+ float yminv=999999999.0f, ymaxv=-999999999.0f;
+ short foundvert=0;
+ int i;
+
+ if (fcu->totvert) {
+ if (fcu->bezt) {
+ /* frame range can be directly calculated from end verts */
+ if (xmin || xmax) {
+ xminv= MIN2(xminv, fcu->bezt[0].vec[1][0]);
+ xmaxv= MAX2(xmaxv, fcu->bezt[fcu->totvert-1].vec[1][0]);
+ }
+
+ /* only loop over keyframes to find extents for values if needed */
+ if (ymin || ymax) {
+ BezTriple *bezt;
+
+ for (bezt=fcu->bezt, i=0; i < fcu->totvert; bezt++, i++) {
+ yminv= MIN2(yminv, bezt->vec[1][1]);
+ ymaxv= MAX2(ymaxv, bezt->vec[1][1]);
+ }
+ }
+ }
+ else if (fcu->fpt) {
+ /* frame range can be directly calculated from end verts */
+ if (xmin || xmax) {
+ xminv= MIN2(xminv, fcu->fpt[0].vec[0]);
+ xmaxv= MAX2(xmaxv, fcu->fpt[fcu->totvert-1].vec[0]);
+ }
+
+ /* only loop over keyframes to find extents for values if needed */
+ if (ymin || ymax) {
+ FPoint *fpt;
+
+ for (fpt=fcu->fpt, i=0; i < fcu->totvert; fpt++, i++) {
+ yminv= MIN2(yminv, fpt->vec[1]);
+ ymaxv= MAX2(ymaxv, fpt->vec[1]);
+ }
+ }
+ }
+
+ foundvert=1;
+ }
+
+ /* minimum sizes are 1.0f */
+ if (foundvert) {
+ if (xminv == xmaxv) xmaxv += 1.0f;
+ if (yminv == ymaxv) ymaxv += 1.0f;
+
+ if (xmin) *xmin= xminv;
+ if (xmax) *xmax= xmaxv;
+
+ if (ymin) *ymin= yminv;
+ if (ymax) *ymax= ymaxv;
+ }
+ else {
+ if (xmin) *xmin= 0.0f;
+ if (xmax) *xmax= 0.0f;
+
+ if (ymin) *ymin= 1.0f;
+ if (ymax) *ymax= 1.0f;
+ }
+}
+
/* Calculate the extents of F-Curve's keyframes */
void calc_fcurve_range (FCurve *fcu, float *start, float *end)
{
diff --git a/source/blender/editors/space_graph/graph_edit.c b/source/blender/editors/space_graph/graph_edit.c
index 08f724bb9a4..e5edbf7d5bb 100644
--- a/source/blender/editors/space_graph/graph_edit.c
+++ b/source/blender/editors/space_graph/graph_edit.c
@@ -84,15 +84,13 @@
#include "graph_intern.h"
-#if 0 // XXX code to be sanitied for new system
-
/* ************************************************************************** */
/* KEYFRAME-RANGE STUFF */
/* *************************** Calculate Range ************************** */
/* Get the min/max keyframes*/
-static void get_keyframe_extents (bAnimContext *ac, float *xmin, float *xmax, float *ymin, float *ymax)
+static void get_graph_keyframe_extents (bAnimContext *ac, float *xmin, float *xmax, float *ymin, float *ymax)
{
ListBase anim_data = {NULL, NULL};
bAnimListElem *ale;
@@ -105,23 +103,19 @@ static void get_keyframe_extents (bAnimContext *ac, float *xmin, float *xmax, fl
/* set large values to try to override */
if (xmin) *xmin= 999999999.0f;
if (xmax) *xmax= -999999999.0f;
- //if (ymin) *ymin= 999999999.0f;
- //if (ymax) *ymax= -999999999.0f;
-
- // XXX
- if (ymin) *ymin= -10;
- if (ymax) *ymax= 10;
+ if (ymin) *ymin= 999999999.0f;
+ if (ymax) *ymax= -999999999.0f;
/* check if any channels to set range with */
if (anim_data.first) {
/* go through channels, finding max extents */
for (ale= anim_data.first; ale; ale= ale->next) {
- Object *nob= ANIM_nla_mapping_get(ac, ale);
+ Object *nob= NULL; //ANIM_nla_mapping_get(ac, ale);
FCurve *fcu= (FCurve *)ale->key_data;
float tmin, tmax;
/* get range and apply necessary scaling before */
- calc_fcurve_range(fcu, &tmin, &tmax);
+ calc_fcurve_bounds(fcu, &tmin, &tmax, ymin, ymax);
if (nob) {
tmin= get_action_frame_inv(nob, tmin);
@@ -146,6 +140,9 @@ static void get_keyframe_extents (bAnimContext *ac, float *xmin, float *xmax, fl
if (xmin) *xmin= -5;
if (xmax) *xmax= 100;
}
+
+ if (ymin) *ymin= -5;
+ if (ymax) *ymax= 5;
}
}
@@ -166,7 +163,7 @@ static int graphkeys_previewrange_exec(bContext *C, wmOperator *op)
scene= ac.scene;
/* set the range directly */
- get_keyframe_extents(&ac, &min, &max);
+ get_graph_keyframe_extents(&ac, &min, &max, NULL, NULL);
scene->r.psfra= (int)floor(min + 0.5f);
scene->r.pefra= (int)floor(max + 0.5f);
@@ -205,13 +202,13 @@ static int graphkeys_viewall_exec(bContext *C, wmOperator *op)
v2d= &ac.ar->v2d;
/* set the horizontal range, with an extra offset so that the extreme keys will be in view */
- get_keyframe_extents(&ac, &v2d->cur.xmin, &v2d->cur.xmax, &v2d->cur.ymin, &v2d->cur.ymax);
+ get_graph_keyframe_extents(&ac, &v2d->cur.xmin, &v2d->cur.xmax, &v2d->cur.ymin, &v2d->cur.ymax);
- extra= 0.05f * (v2d->cur.xmax - v2d->cur.xmin);
+ extra= 0.1f * (v2d->cur.xmax - v2d->cur.xmin);
v2d->cur.xmin -= extra;
v2d->cur.xmax += extra;
- extra= 0.05f * (v2d->cur.ymax - v2d->cur.ymin);
+ extra= 0.1f * (v2d->cur.ymax - v2d->cur.ymin);
v2d->cur.ymin -= extra;
v2d->cur.ymax += extra;
@@ -238,17 +235,17 @@ void GRAPHEDIT_OT_view_all (wmOperatorType *ot)
ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
}
+
/* ************************************************************************** */
/* GENERAL STUFF */
+#if 0 // XXX stuff to be sanitised for the new anim system
+
// TODO:
// - insert key
/* ******************** Copy/Paste Keyframes Operator ************************* */
-/* - The copy/paste buffer currently stores a set of Action Channels, with temporary
- * IPO-blocks, and also temporary IpoCurves which only contain the selected keyframes.
- * - Only pastes between compatable data is possible (i.e. same achan->name, ipo-curve type, etc.)
- * Unless there is only one element in the buffer, names are also tested to check for compatability.
+/* - xxx...
* - All pasted frames are offset by the same amount. This is calculated as the difference in the times of
* the current frame and the 'first keyframe' (i.e. the earliest one in all channels).
* - The earliest frame is calculated per copy operation.
diff --git a/source/blender/editors/space_graph/graph_ops.c b/source/blender/editors/space_graph/graph_ops.c
index 9c7fa307a7f..09c5b9c7f07 100644
--- a/source/blender/editors/space_graph/graph_ops.c
+++ b/source/blender/editors/space_graph/graph_ops.c
@@ -97,8 +97,8 @@ void graphedit_operatortypes(void)
{
/* view */
WM_operatortype_append(GRAPHEDIT_OT_view_togglehandles);
- //WM_operatortype_append(GRAPHEDIT_OT_set_previewrange);
- //WM_operatortype_append(GRAPHEDIT_OT_view_all);
+ WM_operatortype_append(GRAPHEDIT_OT_set_previewrange);
+ WM_operatortype_append(GRAPHEDIT_OT_view_all);
/* keyframes */
/* selection */
@@ -183,8 +183,8 @@ static void graphedit_keymap_keyframes (wmWindowManager *wm, ListBase *keymap)
#endif // XXX code to be sanitied for new system
/* auto-set range */
- //WM_keymap_add_item(keymap, "GRAPHEDIT_OT_set_previewrange", PKEY, KM_PRESS, KM_CTRL|KM_ALT, 0);
- //WM_keymap_add_item(keymap, "GRAPHEDIT_OT_view_all", HOMEKEY, KM_PRESS, 0, 0);
+ WM_keymap_add_item(keymap, "GRAPHEDIT_OT_set_previewrange", PKEY, KM_PRESS, KM_CTRL|KM_ALT, 0);
+ WM_keymap_add_item(keymap, "GRAPHEDIT_OT_view_all", HOMEKEY, KM_PRESS, 0, 0);
/* transform system */
transform_keymap_for_space(wm, keymap, SPACE_IPO);