Index: source/blender/makesrna/intern/rna_internal.h =================================================================== --- source/blender/makesrna/intern/rna_internal.h (révision 27090) +++ source/blender/makesrna/intern/rna_internal.h (copie de travail) @@ -212,6 +212,7 @@ void RNA_api_action(StructRNA *srna); void RNA_api_armature_edit_bone(StructRNA *srna); +void RNA_api_fcurve(StructRNA *srna); void RNA_api_drivers(StructRNA *srna); void RNA_api_image(struct StructRNA *srna); void RNA_api_operator(struct StructRNA *srna); Index: source/blender/makesrna/intern/rna_fcurve_api.c =================================================================== --- source/blender/makesrna/intern/rna_fcurve_api.c (révision 27090) +++ source/blender/makesrna/intern/rna_fcurve_api.c (copie de travail) @@ -33,6 +33,7 @@ #include "RNA_types.h" #include "DNA_anim_types.h" +#include "DNA_curve_types.h" #ifdef RNA_RUNTIME @@ -43,8 +44,35 @@ #include "BKE_animsys.h" #include "BKE_fcurve.h" +#include "ED_keyframing.h" + +/* Create of modify a keyframe point on a F-Curve */ +BezTriple *rna_FCurve_add_point(FCurve *fcu, float x, float y) +{ + int idx; + + idx = insert_vert_fcurve(fcu, x, y, 0); + + return &(fcu->bezt[idx]); +} + #else +void RNA_api_fcurve(StructRNA *srna) +{ + FunctionRNA *func; + PropertyRNA *parm; + + func= RNA_def_function(srna, "add_point", "rna_FCurve_add_point"); + RNA_def_function_ui_description(func, "Add a keyframe point to a F-Curve."); + parm= RNA_def_float(func, "x", 0.0f, 0.0f, 0.0f, "", "X Value of this keyframe point", 0.0f, 0.0f); + RNA_def_property_flag(parm, PROP_REQUIRED); + parm= RNA_def_float(func, "y", 0.0f, 0.0f, 0.0f, "", "Y Value of this keyframe point", 0.0f, 0.0f); + RNA_def_property_flag(parm, PROP_REQUIRED); + parm= RNA_def_pointer(func, "keyframe", "Keyframe", "", "Newly created Keyframe."); + RNA_def_function_return(func, parm); +} + void RNA_api_drivers(StructRNA *srna) { // FunctionRNA *func; Index: source/blender/makesrna/intern/rna_action_api.c =================================================================== --- source/blender/makesrna/intern/rna_action_api.c (révision 27090) +++ source/blender/makesrna/intern/rna_action_api.c (copie de travail) @@ -41,6 +41,8 @@ #include "DNA_anim_types.h" #include "DNA_curve_types.h" +#include "ED_keyframing.h" + /* return frame range of all curves (min, max) or (0, 1) if there are no keys */ void rna_Action_get_frame_range(bAction *act, int **frame_range, int *length_r) { @@ -58,6 +60,16 @@ *frame_range= ret; } +/* add or get a FCurve attached to "data_path[array_index]" */ +FCurve *rna_Action_add_fcurve(bAction *act, char *data_path, int array_index) +{ + FCurve *fcu; + + fcu = verify_fcurve(act, NULL, data_path, array_index, 1); + + return fcu; +} + #else void RNA_api_action(StructRNA *srna) @@ -70,6 +82,18 @@ parm= RNA_def_int_array(func, "frame_range", 1, NULL, 0, 0, "", "Action frame range.", 0, 0); RNA_def_property_flag(parm, PROP_DYNAMIC); RNA_def_function_output(func, parm); + + func= RNA_def_function(srna, "add_fcurve", "rna_Action_add_fcurve"); + RNA_def_function_ui_description(func, "Add or Get a F-Curve for the specified channel."); + parm= RNA_def_string(func, "data_path", "", 0, "", "Data path the F-Curve will be associate to"); + RNA_def_property_flag(parm, PROP_REQUIRED); + parm= RNA_def_int(func, "array_index", 0, 0, 0, "", "Array index the F-Curve will be associate to", 0, 0); + RNA_def_property_flag(parm, PROP_REQUIRED); + parm= RNA_def_pointer(func, "fcurve", "FCurve", "", "Newly created F-Curve."); + RNA_def_function_return(func, parm); + + //PropertyRNA *RNA_def_int(StructOrFunctionRNA *cont, const char *identifier, int default_value, int hardmin, int hardmax, const char *ui_name, const char *ui_description, int softmin, int softmax); + //PropertyRNA *RNA_def_string(StructOrFunctionRNA *cont, const char *identifier, const char *default_value, int maxlen, const char *ui_name, const char *ui_description); } #endif Index: source/blender/makesrna/intern/rna_fcurve.c =================================================================== --- source/blender/makesrna/intern/rna_fcurve.c (révision 27090) +++ source/blender/makesrna/intern/rna_fcurve.c (copie de travail) @@ -1185,6 +1185,9 @@ RNA_def_property_ui_text(prop, "Modifiers", "Modifiers affecting the shape of the F-Curve"); rna_def_fcurve_modifiers(brna, prop); + + /* Functions */ + RNA_api_fcurve(srna); } /* *********************** */