diff options
author | Campbell Barton <ideasman42@gmail.com> | 2015-01-07 03:40:44 +0300 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2015-01-07 04:08:54 +0300 |
commit | 848c00f7e70950fa012627f84c89b32bb9a4deaa (patch) | |
tree | c0d26b61c436ffed04059917b034daf046aa9d38 /source/blender/blenloader | |
parent | 3bd01c60561c5e88f1a9b984852c77b32b7caa72 (diff) |
cleanup: de-duplicate code
Diffstat (limited to 'source/blender/blenloader')
-rw-r--r-- | source/blender/blenloader/intern/versioning_legacy.c | 93 |
1 files changed, 36 insertions, 57 deletions
diff --git a/source/blender/blenloader/intern/versioning_legacy.c b/source/blender/blenloader/intern/versioning_legacy.c index 1a1bc3a55be..6f298923397 100644 --- a/source/blender/blenloader/intern/versioning_legacy.c +++ b/source/blender/blenloader/intern/versioning_legacy.c @@ -515,6 +515,40 @@ static void do_version_free_effects_245(ListBase *lb) } } +static void do_version_constraints_245(ListBase *lb) +{ + bConstraint *con; + bConstraintTarget *ct; + + for (con = lb->first; con; con = con->next) { + if (con->type == CONSTRAINT_TYPE_PYTHON) { + bPythonConstraint *data = (bPythonConstraint *)con->data; + if (data->tar) { + /* version patching needs to be done */ + ct = MEM_callocN(sizeof(bConstraintTarget), "PyConTarget"); + + ct->tar = data->tar; + BLI_strncpy(ct->subtarget, data->subtarget, sizeof(ct->subtarget)); + ct->space = con->tarspace; + + BLI_addtail(&data->targets, ct); + data->tarnum++; + + /* clear old targets to avoid problems */ + data->tar = NULL; + data->subtarget[0] = '\0'; + } + } + else if (con->type == CONSTRAINT_TYPE_LOCLIKE) { + bLocateLikeConstraint *data = (bLocateLikeConstraint *)con->data; + + /* new headtail functionality makes Bone-Tip function obsolete */ + if (data->flag & LOCLIKE_TIP) + con->headtail = 1.0f; + } + } +} + PartEff *blo_do_version_give_parteff_245(Object *ob) { PartEff *paf; @@ -2951,69 +2985,14 @@ void blo_do_versions_pre250(FileData *fd, Library *lib, Main *main) if ((main->versionfile < 245) || (main->versionfile == 245 && main->subversionfile < 7)) { Object *ob; bPoseChannel *pchan; - bConstraint *con; - bConstraintTarget *ct; for (ob = main->object.first; ob; ob = ob->id.next) { if (ob->pose) { for (pchan = ob->pose->chanbase.first; pchan; pchan = pchan->next) { - for (con = pchan->constraints.first; con; con = con->next) { - if (con->type == CONSTRAINT_TYPE_PYTHON) { - bPythonConstraint *data = (bPythonConstraint *)con->data; - if (data->tar) { - /* version patching needs to be done */ - ct = MEM_callocN(sizeof(bConstraintTarget), "PyConTarget"); - - ct->tar = data->tar; - BLI_strncpy(ct->subtarget, data->subtarget, sizeof(ct->subtarget)); - ct->space = con->tarspace; - - BLI_addtail(&data->targets, ct); - data->tarnum++; - - /* clear old targets to avoid problems */ - data->tar = NULL; - data->subtarget[0] = '\0'; - } - } - else if (con->type == CONSTRAINT_TYPE_LOCLIKE) { - bLocateLikeConstraint *data = (bLocateLikeConstraint *)con->data; - - /* new headtail functionality makes Bone-Tip function obsolete */ - if (data->flag & LOCLIKE_TIP) - con->headtail = 1.0f; - } - } - } - } - - for (con = ob->constraints.first; con; con = con->next) { - if (con->type == CONSTRAINT_TYPE_PYTHON) { - bPythonConstraint *data = (bPythonConstraint *)con->data; - if (data->tar) { - /* version patching needs to be done */ - ct = MEM_callocN(sizeof(bConstraintTarget), "PyConTarget"); - - ct->tar = data->tar; - BLI_strncpy(ct->subtarget, data->subtarget, sizeof(ct->subtarget)); - ct->space = con->tarspace; - - BLI_addtail(&data->targets, ct); - data->tarnum++; - - /* clear old targets to avoid problems */ - data->tar = NULL; - data->subtarget[0] = '\0'; - } - } - else if (con->type == CONSTRAINT_TYPE_LOCLIKE) { - bLocateLikeConstraint *data = (bLocateLikeConstraint *)con->data; - - /* new headtail functionality makes Bone-Tip function obsolete */ - if (data->flag & LOCLIKE_TIP) - con->headtail = 1.0f; + do_version_constraints_245(&pchan->constraints); } } + do_version_constraints_245(&ob->constraints); if (ob->soft && ob->soft->keys) { SoftBody *sb = ob->soft; |