diff options
author | Campbell Barton <ideasman42@gmail.com> | 2009-11-11 22:58:30 +0300 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2009-11-11 22:58:30 +0300 |
commit | 53250f85dbecdc4cdd6eded772972b137f3f8c6c (patch) | |
tree | 2deea82dca566fd752753d34b7df3e38ba4d0216 /source/blender/makesrna/intern/rna_pose_api.c | |
parent | 047ee04418a5a785177258dd965f94571d553b57 (diff) |
object.constraints.add()/remove()/active, same for PoseChannel
modified internal api for minimal rna wrapper functions.
TODO
- missing updates for pose channels
- typecheck for pose/object constraints
Diffstat (limited to 'source/blender/makesrna/intern/rna_pose_api.c')
-rw-r--r-- | source/blender/makesrna/intern/rna_pose_api.c | 58 |
1 files changed, 58 insertions, 0 deletions
diff --git a/source/blender/makesrna/intern/rna_pose_api.c b/source/blender/makesrna/intern/rna_pose_api.c index 40bb131b3f9..ae83b728dd6 100644 --- a/source/blender/makesrna/intern/rna_pose_api.c +++ b/source/blender/makesrna/intern/rna_pose_api.c @@ -33,6 +33,7 @@ #include "RNA_define.h" #include "RNA_types.h" +#include "RNA_enum_types.h" #include "DNA_object_types.h" @@ -43,14 +44,71 @@ /* #include "DNA_anim_types.h" */ #include "DNA_action_types.h" /* bPose */ +#include "BKE_constraint.h" /* bPose */ + +static bConstraint *rna_PoseChannel_constraints_add(bPoseChannel *pchan, bContext *C, int type) +{ + //WM_event_add_notifier(C, NC_OBJECT|ND_CONSTRAINT|NA_ADDED, object); + // TODO, pass object also + // TODO, new pose bones don't have updated draw flags + return add_pose_constraint(NULL, pchan, NULL, type); +} + +static int rna_PoseChannel_constraints_remove(bPoseChannel *pchan, bContext *C, int index) +{ + bConstraint *con= BLI_findlink(&pchan->constraints, index); + + if(con) { + free_constraint_data(con); + BLI_freelinkN(&pchan->constraints, con); + + //ED_object_constraint_set_active(object, NULL); + //WM_event_add_notifier(C, NC_OBJECT|ND_CONSTRAINT, object); + + return 1; + } + else { + return 0; + } +} + #else void RNA_api_pose(StructRNA *srna) { /* FunctionRNA *func; */ /* PropertyRNA *parm; */ +} + +void RNA_api_pose_channel(StructRNA *srna) +{ + FunctionRNA *func; + PropertyRNA *parm; + + + /* Constraint collection */ + func= RNA_def_function(srna, "constraints__add", "rna_PoseChannel_constraints_add"); + RNA_def_function_flag(func, FUNC_USE_CONTEXT); + RNA_def_function_ui_description(func, "Add a constraint to this object"); + /* return type */ + parm= RNA_def_pointer(func, "constraint", "Constraint", "", "New constraint."); + RNA_def_function_return(func, parm); + /* object to add */ + parm= RNA_def_enum(func, "type", constraint_type_items, 1, "", "Constraint type to add."); + RNA_def_property_flag(parm, PROP_REQUIRED); + + func= RNA_def_function(srna, "constraints__remove", "rna_PoseChannel_constraints_remove"); + RNA_def_function_flag(func, FUNC_USE_CONTEXT); + RNA_def_function_ui_description(func, "Remove a constraint from this object."); + /* return type */ + parm= RNA_def_boolean(func, "success", 0, "Success", "Removed the constraint successfully."); + RNA_def_function_return(func, parm); + /* object to add */ + parm= RNA_def_int(func, "index", 0, 0, INT_MAX, "Index", "", 0, INT_MAX); + RNA_def_property_flag(parm, PROP_REQUIRED); } + #endif |