[Bf-taskforce25] [Bf-blender-cvs] SVN commit: /data/svn/bf-blender [21543] branches/soc-2009-kazanbas: Added Action.get_frame_range returning a (min, max) pair or (0, 0) if there are no keys.

Joshua Leung aligorith at gmail.com
Sun Jul 12 09:05:25 CEST 2009


Hi,

Just a heads up that there is actually a function in the Actions "API" (in
blenkernel, if you can call it one) that does this range checking that you
may want to use instead.

Joshua

On Sun, Jul 12, 2009 at 6:59 PM, Arystanbek Dyussenov
<arystan.d at gmail.com>wrote:

> Revision: 21543
>
> http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=21543
> Author:   kazanbas
> Date:     2009-07-12 08:59:57 +0200 (Sun, 12 Jul 2009)
>
> Log Message:
> -----------
> Added Action.get_frame_range returning a (min, max) pair or (0, 0) if there
> are no keys.
>
> Modified Paths:
> --------------
>    branches/soc-2009-kazanbas/release/io/export_fbx.py
>
>  branches/soc-2009-kazanbas/source/blender/makesrna/intern/rna_action_api.c
>
> Modified: branches/soc-2009-kazanbas/release/io/export_fbx.py
> ===================================================================
> --- branches/soc-2009-kazanbas/release/io/export_fbx.py 2009-07-12 04:29:36
> UTC (rev 21542)
> +++ branches/soc-2009-kazanbas/release/io/export_fbx.py 2009-07-12 06:59:57
> UTC (rev 21543)
> @@ -2577,17 +2577,18 @@
>                                        file.write('\n\tTake: "%s" {' %
> sane_name_mapping_take[blenAction.name])
>                                else:
>                                        file.write('\n\tTake: "%s" {' %
> sane_takename(blenAction))
> -
> -                               tmp = blenAction.getFrameNumbers()
> -                               if tmp:
> -                                       act_start =     min(tmp)
> -                                       act_end =       max(tmp)
> -                                       del tmp
> -                               else:
> -                                       # Fallback on this, theres not much
> else we can do? :/
> -                                       # when an action has no length
> -                                       act_start =     start
> -                                       act_end =       end
> +
> +                               act_start, act_end =
> blenAction.get_frame_range()
> +#                              tmp = blenAction.getFrameNumbers()
> +#                              if tmp:
> +#                                      act_start =     min(tmp)
> +#                                      act_end =       max(tmp)
> +#                                      del tmp
> +#                              else:
> +#                                      # Fallback on this, theres not much
> else we can do? :/
> +#                                      # when an action has no length
> +#                                      act_start =     start
> +#                                      act_end =       end
>
>                                # Set the action active
>                                for my_bone in ob_arms:
>
> Modified:
> branches/soc-2009-kazanbas/source/blender/makesrna/intern/rna_action_api.c
> ===================================================================
> ---
> branches/soc-2009-kazanbas/source/blender/makesrna/intern/rna_action_api.c
>  2009-07-12 04:29:36 UTC (rev 21542)
> +++
> branches/soc-2009-kazanbas/source/blender/makesrna/intern/rna_action_api.c
>  2009-07-12 06:59:57 UTC (rev 21543)
> @@ -36,13 +36,40 @@
>
>  #ifdef RNA_RUNTIME
>
> -int *rna_Action_get_frames(bAction *act, int *ret_length)
> +#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 */
> +int *rna_Action_get_frame_range(bAction *act, int *ret_length)
>  {
> -       *ret_length= 3;
> -       int *ret= MEM_callocN(*ret_length * sizeof(int), "action frames");
> -       ret[0] = 1;
> -       ret[1] = 2;
> -       ret[2] = 3;
> +       FCurve *cu;
> +       int *ret;
> +
> +       *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--;
> +               }
> +       }
> +
>        return ret;
>  }
>
> @@ -53,9 +80,9 @@
>        FunctionRNA *func;
>        PropertyRNA *parm;
>
> -       func= RNA_def_function(srna, "get_frames",
> "rna_Action_get_frames");
> -       RNA_def_function_ui_description(func, "Get action frames."); /* XXX
> describe better */
> -       parm= RNA_def_int_array(func, "frames", 1, NULL, 0, 0, "", "", 0,
> 0);
> +       func= RNA_def_function(srna, "get_frame_range",
> "rna_Action_get_frame_range");
> +       RNA_def_function_ui_description(func, "Get action frame range as a
> (min, max) tuple.");
> +       parm= RNA_def_int_array(func, "frame_range", 1, NULL, 0, 0, "",
> "Action frame range.", 0, 0);
>        RNA_def_property_flag(parm, PROP_DYNAMIC_ARRAY);
>        RNA_def_function_return(func, parm);
>  }
>
>
> _______________________________________________
> Bf-blender-cvs mailing list
> Bf-blender-cvs at blender.org
> http://lists.blender.org/mailman/listinfo/bf-blender-cvs
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.blender.org/pipermail/bf-taskforce25/attachments/20090712/8d90b8be/attachment.htm 


More information about the Bf-taskforce25 mailing list