From f221d9128ddf593f7977251ed4214cfe682d7c40 Mon Sep 17 00:00:00 2001 From: Arystanbek Dyussenov Date: Sat, 11 Jul 2009 11:58:50 +0000 Subject: Added Scene.set_frame RNA function to get immediate scene update. Changing Scene.current_frame doesn't work in this case because it adds a notifier. Also added RNA_property_update call in pyrna_struct_setattro so that notifiers are added when a property changes. --- source/blender/makesrna/intern/rna_action_api.c | 48 +++++++++++++++++++++++++ 1 file changed, 48 insertions(+) create mode 100644 source/blender/makesrna/intern/rna_action_api.c (limited to 'source/blender/makesrna/intern/rna_action_api.c') diff --git a/source/blender/makesrna/intern/rna_action_api.c b/source/blender/makesrna/intern/rna_action_api.c new file mode 100644 index 00000000000..a758a2c56d0 --- /dev/null +++ b/source/blender/makesrna/intern/rna_action_api.c @@ -0,0 +1,48 @@ +/** + * ***** BEGIN GPL LICENSE BLOCK ***** + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + * + * The Original Code is Copyright (C) 2009 Blender Foundation. + * All rights reserved. + * + * + * Contributor(s): Blender Foundation + * + * ***** END GPL LICENSE BLOCK ***** + */ + +#include +#include +#include +#include + +#include "RNA_define.h" +#include "RNA_types.h" + +#include "DNA_action_types.h" + +#ifdef RNA_RUNTIME + +#else + +void RNA_api_action(StructRNA *srna) +{ + FunctionRNA *func; + PropertyRNA *parm; + +} + +#endif -- cgit v1.2.3 From 870a9d61042d8badb02673678dd1ed32a6ee994d Mon Sep 17 00:00:00 2001 From: Arystanbek Dyussenov Date: Sat, 11 Jul 2009 16:11:26 +0000 Subject: RNA functions can now return dynamic arrays (float, int/boolean). RNA handles freeing memory. Example code: http://pastebin.mozilla.org/662154. --- source/blender/makesrna/intern/rna_action_api.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'source/blender/makesrna/intern/rna_action_api.c') diff --git a/source/blender/makesrna/intern/rna_action_api.c b/source/blender/makesrna/intern/rna_action_api.c index a758a2c56d0..b989d2d66a9 100644 --- a/source/blender/makesrna/intern/rna_action_api.c +++ b/source/blender/makesrna/intern/rna_action_api.c @@ -36,6 +36,16 @@ #ifdef RNA_RUNTIME +int *rna_Action_get_frames(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; + return ret; +} + #else void RNA_api_action(StructRNA *srna) @@ -43,6 +53,11 @@ void RNA_api_action(StructRNA *srna) 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); + RNA_def_property_flag(parm, PROP_DYNAMIC_ARRAY); + RNA_def_function_return(func, parm); } #endif -- cgit v1.2.3 From 11a47a02c73387d9390f7b1d2a40b7c50cab9c6f Mon Sep 17 00:00:00 2001 From: Arystanbek Dyussenov Date: Sun, 12 Jul 2009 06:59:57 +0000 Subject: Added Action.get_frame_range returning a (min, max) pair or (0, 0) if there are no keys. --- source/blender/makesrna/intern/rna_action_api.c | 45 ++++++++++++++++++++----- 1 file changed, 36 insertions(+), 9 deletions(-) (limited to 'source/blender/makesrna/intern/rna_action_api.c') diff --git a/source/blender/makesrna/intern/rna_action_api.c b/source/blender/makesrna/intern/rna_action_api.c index b989d2d66a9..9f63d44f8ef 100644 --- a/source/blender/makesrna/intern/rna_action_api.c +++ b/source/blender/makesrna/intern/rna_action_api.c @@ -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 @@ void RNA_api_action(StructRNA *srna) 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); } -- cgit v1.2.3 From ffa5636a8b348d47d08b76644ec567d90cc9d3c5 Mon Sep 17 00:00:00 2001 From: Arystanbek Dyussenov Date: Sun, 12 Jul 2009 07:20:49 +0000 Subject: Reusing existing blenkernel function calc_action_range for Action.get_frame_range. --- source/blender/makesrna/intern/rna_action_api.c | 29 +++++-------------------- 1 file changed, 6 insertions(+), 23 deletions(-) (limited to 'source/blender/makesrna/intern/rna_action_api.c') diff --git a/source/blender/makesrna/intern/rna_action_api.c b/source/blender/makesrna/intern/rna_action_api.c index 9f63d44f8ef..2b51a424fcf 100644 --- a/source/blender/makesrna/intern/rna_action_api.c +++ b/source/blender/makesrna/intern/rna_action_api.c @@ -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; } -- cgit v1.2.3 From 7220792f187f91a2ef3eb0c930a13674b2a8a80a Mon Sep 17 00:00:00 2001 From: Arystanbek Dyussenov Date: Wed, 19 Aug 2009 09:52:13 +0000 Subject: Various fixes in rna_*_api.c files to remove compiler warnings. --- source/blender/makesrna/intern/rna_action_api.c | 2 ++ 1 file changed, 2 insertions(+) (limited to 'source/blender/makesrna/intern/rna_action_api.c') diff --git a/source/blender/makesrna/intern/rna_action_api.c b/source/blender/makesrna/intern/rna_action_api.c index 2b51a424fcf..11efa6d5f8a 100644 --- a/source/blender/makesrna/intern/rna_action_api.c +++ b/source/blender/makesrna/intern/rna_action_api.c @@ -36,6 +36,8 @@ #ifdef RNA_RUNTIME +#include "BKE_action.h" + #include "DNA_anim_types.h" #include "DNA_curve_types.h" -- cgit v1.2.3