Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTon Roosendaal <ton@blender.org>2006-11-02 13:13:01 +0300
committerTon Roosendaal <ton@blender.org>2006-11-02 13:13:01 +0300
commit402287940afe32fb30e828d94d28705c3a0c48c6 (patch)
tree3283422f7a3c3855b62a71cb2a88ff5fd427b322 /source/blender/src/editconstraint.c
parentcdd474869226eef3e4142535efda9b5934604fc0 (diff)
Bugfix #5022
If you rename a Constraint, the used Constraint Channels (Ipo curves) were not renamed as well, making animations not work anymore. Now renaming works up to this level: - own object constraints - own object Action constraints This is identical to Bone renaming. Note that other actions (like in NLA) are not corrected for renaming. Have to look at ways to provide that once.
Diffstat (limited to 'source/blender/src/editconstraint.c')
-rw-r--r--source/blender/src/editconstraint.c63
1 files changed, 63 insertions, 0 deletions
diff --git a/source/blender/src/editconstraint.c b/source/blender/src/editconstraint.c
index aefec006930..10a930b9ebc 100644
--- a/source/blender/src/editconstraint.c
+++ b/source/blender/src/editconstraint.c
@@ -817,3 +817,66 @@ void ob_clear_constraints(void)
}
+/* con already has the new name */
+void rename_constraint(Object *ob, bConstraint *con, char *oldname)
+{
+ bConstraint *tcon;
+ bConstraintChannel *conchan;
+ ListBase *conlist= NULL;
+ int from_object= 0;
+ char *channame;
+
+ /* get context by searching for con (primitive...) */
+ for(tcon= ob->constraints.first; tcon; tcon= tcon->next)
+ if(tcon==con)
+ break;
+
+ if(tcon) {
+ conlist= &ob->constraints;
+ channame= "Object";
+ from_object= 1;
+ }
+ else if(ob->pose) {
+ bPoseChannel *pchan;
+
+ for(pchan= ob->pose->chanbase.first; pchan; pchan= pchan->next) {
+ for(tcon= pchan->constraints.first; tcon; tcon= tcon->next) {
+ if(tcon==con)
+ break;
+ }
+ if(tcon)
+ break;
+ }
+ if(tcon) {
+ conlist= &pchan->constraints;
+ channame= pchan->name;
+ }
+ }
+
+ if(conlist==NULL) {
+ printf("rename constraint failed\n"); /* should not happen in UI */
+ return;
+ }
+
+ /* first make sure it's a unique name within context */
+ unique_constraint_name (con, conlist);
+
+ /* own channels */
+ if(from_object) {
+ for(conchan= ob->constraintChannels.first; conchan; conchan= conchan->next) {
+ if( strcmp(oldname, conchan->name)==0 )
+ BLI_strncpy(conchan->name, con->name, sizeof(conchan->name));
+ }
+ }
+ /* own action */
+ if(ob->action) {
+ bActionChannel *achan= get_action_channel(ob->action, channame);
+ if(achan) {
+ conchan= get_constraint_channel(&achan->constraintChannels, oldname);
+ if(conchan)
+ BLI_strncpy(conchan->name, con->name, sizeof(conchan->name));
+ }
+ }
+
+}
+