Started to look into this but saw your commit 27916, is there anything else I should check?
On Wed, Mar 31, 2010 at 9:46 PM, Joshua Leung <[email protected]> wrote: > No no no no! > > This sort of operation MUST go through the API calls, not be hacked together > for individual places, otherwise you'll get animation loss problems (i.e. > animators will NOT be able to see curves afterwards). This is why it was set > to readonly for such a long time :) > > On Thu, Apr 1, 2010 at 8:02 AM, Campbell Barton <[email protected]>wrote: > >> Revision: 27907 >> >> http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=27907 >> Author: campbellbarton >> Date: 2010-03-31 21:02:39 +0200 (Wed, 31 Mar 2010) >> >> Log Message: >> ----------- >> support for adding remove action groups, as well as setting an action group >> from an fcurve (was readonly). >> >> Modified Paths: >> -------------- >> branches/render25/release/scripts/op/nla.py >> branches/render25/source/blender/makesrna/intern/rna_action.c >> branches/render25/source/blender/makesrna/intern/rna_fcurve.c >> >> Modified: branches/render25/release/scripts/op/nla.py >> =================================================================== >> --- branches/render25/release/scripts/op/nla.py 2010-03-31 18:02:56 UTC >> (rev 27906) >> +++ branches/render25/release/scripts/op/nla.py 2010-03-31 19:02:39 UTC >> (rev 27907) >> @@ -121,7 +121,22 @@ >> pbone.keyframe_insert("rotation_euler", -1, f) >> >> pbone.keyframe_insert("scale", -1, f) >> - >> + >> + # assign groups, could become a more generic function >> + agrp_loc = action.groups.add("Location") >> + agrp_rot = action.groups.add("Rotation") >> + agrp_sca = action.groups.add("Scale") >> + >> + for fcu in action.fcurves: >> + path = fcu.data_path.rsplit(".", 1)[-1] >> + >> + if path.startswith("loc"): >> + fcu.group = agrp_loc >> + if path.startswith("rot"): >> + fcu.group = agrp_rot >> + if path.startswith("sca"): >> + fcu.group = agrp_sca >> + >> return action >> >> >> >> Modified: branches/render25/source/blender/makesrna/intern/rna_action.c >> =================================================================== >> --- branches/render25/source/blender/makesrna/intern/rna_action.c >> 2010-03-31 18:02:56 UTC (rev 27906) >> +++ branches/render25/source/blender/makesrna/intern/rna_action.c >> 2010-03-31 19:02:39 UTC (rev 27907) >> @@ -55,6 +55,35 @@ >> iter->valid= (internal->link != NULL); >> } >> >> +static bActionGroup *rna_Action_groups_add(bAction *act, char *name) >> +{ >> + bActionGroup *agrp= MEM_callocN(sizeof(bActionGroup), >> "bActionGroup"); >> + strncpy(agrp->name, name, sizeof(agrp->name)); >> + BLI_addtail(&act->groups, agrp); >> + BLI_uniquename(&act->groups, agrp, "Group", '.', >> offsetof(bActionGroup, name), sizeof(agrp->name)); >> + return agrp; >> +} >> + >> +static void rna_Action_groups_remove(bAction *act, ReportList *reports, >> bActionGroup *agrp) >> +{ >> + FCurve *fcu; >> + >> + if(!BLI_remlink_safe(&act->groups, agrp)) { >> + BKE_reportf(reports, RPT_ERROR, "ActionGroup '%s' not found >> in action '%s'", agrp->name, act->id.name); >> + return; >> + } >> + >> + for(fcu= act->curves.first; fcu; fcu= fcu->next) { >> + if(fcu->grp==agrp) >> + fcu->grp= NULL; >> + } >> + >> + /* XXX, can these be added to drivers??? */ >> + >> + MEM_freeN(agrp); /* XXX, invalidate PyObject */ >> +} >> + >> + >> #else >> >> static void rna_def_dopesheet(BlenderRNA *brna) >> @@ -245,6 +274,35 @@ >> RNA_def_property_update(prop, NC_ANIMATION|ND_ANIMCHAN_EDIT, NULL); >> } >> >> +/* fcurve.keyframe_points */ >> +static void rna_def_action_groups(BlenderRNA *brna, PropertyRNA *cprop) >> +{ >> + StructRNA *srna; >> + >> + FunctionRNA *func; >> + PropertyRNA *parm; >> + >> + RNA_def_property_srna(cprop, "ActionGroups"); >> + srna= RNA_def_struct(brna, "ActionGroups", NULL); >> + RNA_def_struct_sdna(srna, "bAction"); >> + RNA_def_struct_ui_text(srna, "Action Points", "Collection of action >> groups"); >> + >> + func= RNA_def_function(srna, "add", "rna_Action_groups_add"); >> + RNA_def_function_ui_description(func, "Add a keyframe to the >> curve."); >> + parm= RNA_def_string(func, "name", "Group", 0, "", "New name for >> the action group."); >> + RNA_def_property_flag(parm, PROP_REQUIRED); >> + >> + parm= RNA_def_pointer(func, "action_group", "ActionGroup", "", >> "Newly created action group"); >> + RNA_def_function_return(func, parm); >> + >> + >> + func= RNA_def_function(srna, "remove", "rna_Action_groups_remove"); >> + RNA_def_function_ui_description(func, "Remove action group."); >> + RNA_def_function_flag(func, FUNC_USE_REPORTS); >> + parm= RNA_def_pointer(func, "action_group", "ActionGroup", "", >> "Action group to remove."); >> + RNA_def_property_flag(parm, PROP_REQUIRED|PROP_NEVER_NULL); >> +} >> + >> static void rna_def_action(BlenderRNA *brna) >> { >> StructRNA *srna; >> @@ -264,6 +322,7 @@ >> RNA_def_property_collection_sdna(prop, NULL, "groups", NULL); >> RNA_def_property_struct_type(prop, "ActionGroup"); >> RNA_def_property_ui_text(prop, "Groups", "Convenient groupings of >> F-Curves"); >> + rna_def_action_groups(brna, prop); >> >> prop= RNA_def_property(srna, "pose_markers", PROP_COLLECTION, >> PROP_NONE); >> RNA_def_property_collection_sdna(prop, NULL, "markers", NULL); >> >> Modified: branches/render25/source/blender/makesrna/intern/rna_fcurve.c >> =================================================================== >> --- branches/render25/source/blender/makesrna/intern/rna_fcurve.c >> 2010-03-31 18:02:56 UTC (rev 27906) >> +++ branches/render25/source/blender/makesrna/intern/rna_fcurve.c >> 2010-03-31 19:02:39 UTC (rev 27907) >> @@ -489,6 +489,28 @@ >> delete_fcurve_key(fcu, index, !do_fast); >> } >> >> +static void rna_FCurve_group_set(PointerRNA *ptr, PointerRNA value) >> +{ >> + FCurve *fcu= ptr->data; >> + >> + if(value.data && (ptr->id.data != value.id.data)) { >> + return; /* id's differ, cant do this, should raise an error >> */ >> + } >> + if(fcu->grp == value.data) { >> + return; /* nothing to do */ >> + } >> + >> + if(fcu->grp) { >> + BLI_remlink(&fcu->grp->channels, fcu); >> + } >> + >> + fcu->grp= value.data; >> + >> + if(fcu->grp) { >> + BLI_addtail(&fcu->grp->channels, fcu); >> + } >> +} >> + >> #else >> >> static void rna_def_fmodifier_generator(BlenderRNA *brna) >> @@ -1216,7 +1238,7 @@ >> RNA_def_property_flag(parm, PROP_REQUIRED); >> } >> >> -/* scene.objects */ >> +/* fcurve.keyframe_points */ >> static void rna_def_fcurve_keyframe_points(BlenderRNA *brna, PropertyRNA >> *cprop) >> { >> StructRNA *srna; >> @@ -1230,7 +1252,6 @@ >> RNA_def_struct_ui_text(srna, "Keyframe Points", "Collection of >> keyframe points"); >> >> func= RNA_def_function(srna, "add", "rna_FKeyframe_points_add"); >> - RNA_def_function_ui_description(func, "Add a keyframe to the >> curve."); >> RNA_def_function_ui_description(func, "Add a keyframe point to a >> F-Curve."); >> parm= RNA_def_float(func, "frame", 0.0f, -FLT_MAX, FLT_MAX, "", "X >> Value of this keyframe point", -FLT_MAX, FLT_MAX); >> RNA_def_property_flag(parm, PROP_REQUIRED); >> @@ -1287,10 +1308,11 @@ >> >> prop= RNA_def_property(srna, "group", PROP_POINTER, PROP_NONE); >> RNA_def_property_pointer_sdna(prop, NULL, "grp"); >> - RNA_def_property_clear_flag(prop, PROP_EDITABLE); // XXX this is >> not editable for now, since editing this will easily break the visible >> hierarchy >> + RNA_def_property_flag(prop, PROP_EDITABLE); >> RNA_def_property_ui_text(prop, "Group", "Action Group that this >> F-Curve belongs to"); >> - RNA_def_property_update(prop, NC_ANIMATION|ND_FCURVES_ORDER, NULL); >> - >> + RNA_def_property_pointer_funcs(prop, NULL, "rna_FCurve_group_set", >> NULL); >> + RNA_def_property_update(prop, NC_ANIMATION, NULL); >> + >> /* Path + Array Index */ >> prop= RNA_def_property(srna, "data_path", PROP_STRING, PROP_NONE); >> RNA_def_property_string_funcs(prop, "rna_FCurve_RnaPath_get", >> "rna_FCurve_RnaPath_length", "rna_FCurve_RnaPath_set"); >> >> >> _______________________________________________ >> Bf-blender-cvs mailing list >> [email protected] >> http://lists.blender.org/mailman/listinfo/bf-blender-cvs >> > _______________________________________________ > Bf-committers mailing list > [email protected] > http://lists.blender.org/mailman/listinfo/bf-committers > -- - Campbell _______________________________________________ Bf-committers mailing list [email protected] http://lists.blender.org/mailman/listinfo/bf-committers
