diff options
author | Alexander Gavrilov <angavrilov@gmail.com> | 2018-08-05 18:48:05 +0300 |
---|---|---|
committer | Alexander Gavrilov <angavrilov@gmail.com> | 2018-10-04 19:55:44 +0300 |
commit | 61a24c799b2882c22a43591138a113d7f09be0ed (patch) | |
tree | ea85047e68ff64bf7e25329a7e7048f1b9dbfeb1 /source/blender/blenloader/intern/versioning_280.c | |
parent | 6932eaa2bcaff0649c82f6b31a205319c966bd15 (diff) |
Move B-Bone custom handle settings to Edit mode.
Custom handle settings actually affect the B-Bone rest shape,
so they should be changed in Edit mode rather than Pose mode.
This is necessary to be able to display the correct rest shape
of the bone in Edit Mode.
Also, instead of flags, introduce an enum to specify the handle
operation modes, so that new ones could be added later.
Differential Revision: https://developer.blender.org/D3588
Diffstat (limited to 'source/blender/blenloader/intern/versioning_280.c')
-rw-r--r-- | source/blender/blenloader/intern/versioning_280.c | 49 |
1 files changed, 49 insertions, 0 deletions
diff --git a/source/blender/blenloader/intern/versioning_280.c b/source/blender/blenloader/intern/versioning_280.c index 1e2ae48ccb1..5392e1dd4e8 100644 --- a/source/blender/blenloader/intern/versioning_280.c +++ b/source/blender/blenloader/intern/versioning_280.c @@ -60,7 +60,9 @@ #include "DNA_workspace_types.h" #include "DNA_key_types.h" #include "DNA_curve_types.h" +#include "DNA_armature_types.h" +#include "BKE_action.h" #include "BKE_collection.h" #include "BKE_constraint.h" #include "BKE_customdata.h" @@ -87,6 +89,8 @@ #include "BKE_key.h" #include "BKE_unit.h" +#include "DEG_depsgraph.h" + #include "BLT_translation.h" #include "BLO_readfile.h" @@ -860,6 +864,51 @@ void do_versions_after_linking_280(Main *bmain) } } } + + /* Move B-Bone custom handle settings from bPoseChannel to Bone. */ + if (!MAIN_VERSION_ATLEAST(bmain, 280, 25)) { + for (Object *ob = bmain->object.first; ob; ob = ob->id.next) { + bArmature *arm = ob->data; + + /* If it is an armature from the same file. */ + if (ob->pose && arm && arm->id.lib == ob->id.lib) { + bool rebuild = false; + + for (bPoseChannel *pchan = ob->pose->chanbase.first; pchan; pchan = pchan->next) { + /* If the 2.7 flag is enabled, processing is needed. */ + if (pchan->bone && (pchan->bboneflag & PCHAN_BBONE_CUSTOM_HANDLES)) { + /* If the settings in the Bone are not set, copy. */ + if (pchan->bone->bbone_prev_type == BBONE_HANDLE_AUTO && + pchan->bone->bbone_next_type == BBONE_HANDLE_AUTO && + pchan->bone->bbone_prev == NULL && pchan->bone->bbone_next == NULL) + { + pchan->bone->bbone_prev_type = (pchan->bboneflag & PCHAN_BBONE_CUSTOM_START_REL) ? BBONE_HANDLE_RELATIVE : BBONE_HANDLE_ABSOLUTE; + pchan->bone->bbone_next_type = (pchan->bboneflag & PCHAN_BBONE_CUSTOM_END_REL) ? BBONE_HANDLE_RELATIVE : BBONE_HANDLE_ABSOLUTE; + + if (pchan->bbone_prev) { + pchan->bone->bbone_prev = pchan->bbone_prev->bone; + } + if (pchan->bbone_next) { + pchan->bone->bbone_next = pchan->bbone_next->bone; + } + } + + rebuild = true; + pchan->bboneflag = 0; + } + } + + /* Tag pose rebuild for all objects that use this armature. */ + if (rebuild) { + for (Object *ob2 = bmain->object.first; ob2; ob2 = ob2->id.next) { + if (ob2->pose && ob2->data == arm) { + ob2->pose->flag |= POSE_RECALC; + } + } + } + } + } + } } /* NOTE: this version patch is intended for versions < 2.52.2, but was initially introduced in 2.27 already. |