This commit adds backwards compatability for the new floor constraint
authorRoland Hess <me@harkyman.com>
Fri, 22 Sep 2006 16:42:39 +0000 (16:42 +0000)
committerRoland Hess <me@harkyman.com>
Fri, 22 Sep 2006 16:42:39 +0000 (16:42 +0000)
feature. Old files that had "sticky" set would not show "sticky" under
the new system. Not that anyone ever actually used "sticky".

Also, these commits only add support for rotated external target objects,
not target bones inside the same armature.

source/blender/blenloader/intern/readfile.c
source/blender/makesdna/DNA_constraint_types.h

index 6ece27c2e462dc3912282bfa5aa1b2675b8a4dce..0a149ce5b06490b5a40056c2713a606ebcb337a2 100644 (file)
@@ -5587,11 +5587,59 @@ static void do_versions(FileData *fd, Library *lib, Main *main)
                
        if(main->versionfile <= 242) {
                Scene *sce;
+               Object *ob;
                
                for(sce= main->scene.first; sce; sce= sce->id.next) {
                        if (sce->toolsettings->select_thresh == 0.0f)
                                sce->toolsettings->select_thresh= 0.01f;
                }
+               
+               ob = main->object.first;
+
+               while (ob) {
+                       ListBase *list;
+                       list = &ob->constraints;
+
+                       /* check for already existing MinMax (floor) constraint
+                          and update the sticky flagging */
+
+                       if (list){
+                               bConstraint *curcon;
+                               for (curcon = list->first; curcon; curcon=curcon->next){
+                                       if (curcon->type == CONSTRAINT_TYPE_MINMAX){
+                                               bMinMaxConstraint *data = curcon->data;
+                                               if (data->sticky==1) {
+                                                       data->flag|=MINMAX_STICKY;
+                                               } else {
+                                                       data->flag&=~MINMAX_STICKY;
+                                               }
+                                       }
+                               }
+                       }
+
+                       if (ob->type == OB_ARMATURE) {
+                               if (ob->pose){
+                                       bConstraint *curcon;
+                                       bPoseChannel *pchan;
+                                       for (pchan = ob->pose->chanbase.first;
+                                                pchan; pchan=pchan->next){
+                                               for (curcon = pchan->constraints.first;
+                                                        curcon; curcon=curcon->next){
+                                                       if (curcon->type == CONSTRAINT_TYPE_MINMAX){
+                                                               bMinMaxConstraint *data = curcon->data;
+                                                               if (data->sticky==1) {
+                                                                       data->flag|=MINMAX_STICKY;
+                                                               } else {
+                                                                       data->flag&=~MINMAX_STICKY;
+                                                               }
+                                                       }
+                                               }
+                                       }
+                }
+                       }
+
+                       ob = ob->id.next;
+               }
        }
        
        /* WATCH IT!!!: pointers from libdata have not been converted yet here! */
index dcc4b88680dcc0d1f5cde6732fa9c8231aa41e30..8b8f8ae0f72e2772fa192aee3a7fd0141fb0c002 100644 (file)
@@ -100,6 +100,7 @@ typedef struct bMinMaxConstraint{
        int                     minmaxflag;
        float                   offset;
        int                             flag;
+       short                   sticky, stuck, pad1, pad2; /* for backward compatability */
        float                   cache[3];
        char            subtarget[32];
 } bMinMaxConstraint;