Reusing existing blenkernel function calc_action_range for Action.get_frame_range.

This commit is contained in:
Arystanbek Dyussenov 2009-07-12 07:20:49 +00:00
parent 11a47a02c7
commit ffa5636a8b

@ -39,36 +39,19 @@
#include "DNA_anim_types.h"
#include "DNA_curve_types.h"
/* return frame range of all curves (min, max) or (0, 0) if there are no keys */
/* return frame range of all curves (min, max) or (0, 1) if there are no keys */
int *rna_Action_get_frame_range(bAction *act, int *ret_length)
{
FCurve *cu;
int *ret;
float start, end;
calc_action_range(act, &start, &end, 1);
*ret_length= 2;
ret= MEM_callocN(*ret_length * sizeof(int), "rna_Action_get_frame_range");
ret[0]= 0;
ret[1]= 0;
for (cu= act->curves.first; cu; cu= cu->next) {
int verts= cu->totvert;
BezTriple *bezt= cu->bezt;
while (verts) {
int frame= (int)bezt->vec[1][0];
if (cu == act->curves.first && verts == cu->totvert)
ret[0]= ret[1]= frame;
if (frame < ret[0])
ret[0]= frame;
if (frame > ret[1])
ret[1]= frame;
bezt++;
verts--;
}
}
ret[0]= (int)start;
ret[1]= (int)end;
return ret;
}