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:
authorAlexander Gavrilov <angavrilov@gmail.com>2019-04-20 18:06:31 +0300
committerAlexander Gavrilov <angavrilov@gmail.com>2019-04-23 13:45:03 +0300
commit624e93bbef8a8a34be822c1a98df131439c32788 (patch)
tree592fce70ac6a810c6ee4ab9c0c3ce87ebedc14cf /source/blender/blenloader
parentc043ab1cf3bce77248a8d7dfa42b2e9f8f9611aa (diff)
B-Bones: split the Scale In/Out properties into X and Y values.
As far as I can tell, there is no technical reason why the B-Bone segment thickness scaling can't be separated into two axes. The only downside is the increase in complexity of the B-Bone settings, but this is inevitable due to the increase in flexibility. Updating the file is somewhat complicated though, because F-Curves and drivers have to be duplicated and updated to the new names. Reviewers: campbellbarton Subscribers: icappiello, jpbouza Differential Revision: https://developer.blender.org/D4716
Diffstat (limited to 'source/blender/blenloader')
-rw-r--r--source/blender/blenloader/intern/versioning_270.c8
-rw-r--r--source/blender/blenloader/intern/versioning_280.c97
2 files changed, 101 insertions, 4 deletions
diff --git a/source/blender/blenloader/intern/versioning_270.c b/source/blender/blenloader/intern/versioning_270.c
index bd405bd6410..20b2bfd95c8 100644
--- a/source/blender/blenloader/intern/versioning_270.c
+++ b/source/blender/blenloader/intern/versioning_270.c
@@ -256,8 +256,8 @@ static void do_version_action_editor_properties_region(ListBase *regionbase)
static void do_version_bones_super_bbone(ListBase *lb)
{
for (Bone *bone = lb->first; bone; bone = bone->next) {
- bone->scaleIn = 1.0f;
- bone->scaleOut = 1.0f;
+ bone->scale_in_x = bone->scale_in_y = 1.0f;
+ bone->scale_out_x = bone->scale_out_y = 1.0f;
do_version_bones_super_bbone(&bone->childbase);
}
@@ -1338,8 +1338,8 @@ void blo_do_versions_270(FileData *fd, Library *UNUSED(lib), Main *bmain)
if (ob->pose) {
for (bPoseChannel *pchan = ob->pose->chanbase.first; pchan; pchan = pchan->next) {
/* see do_version_bones_super_bbone()... */
- pchan->scaleIn = 1.0f;
- pchan->scaleOut = 1.0f;
+ pchan->scale_in_x = pchan->scale_in_y = 1.0f;
+ pchan->scale_out_x = pchan->scale_out_y = 1.0f;
/* also make sure some legacy (unused for over a decade) flags are unset,
* so that we can reuse them for stuff that matters now...
diff --git a/source/blender/blenloader/intern/versioning_280.c b/source/blender/blenloader/intern/versioning_280.c
index fbe0f70527b..73109cd9a6b 100644
--- a/source/blender/blenloader/intern/versioning_280.c
+++ b/source/blender/blenloader/intern/versioning_280.c
@@ -30,6 +30,7 @@
#include "BLI_string.h"
#include "BLI_utildefines.h"
+#include "DNA_anim_types.h"
#include "DNA_object_types.h"
#include "DNA_camera_types.h"
#include "DNA_cloth_types.h"
@@ -56,11 +57,13 @@
#include "DNA_text_types.h"
#include "BKE_action.h"
+#include "BKE_animsys.h"
#include "BKE_cloth.h"
#include "BKE_collection.h"
#include "BKE_constraint.h"
#include "BKE_colortools.h"
#include "BKE_customdata.h"
+#include "BKE_fcurve.h"
#include "BKE_freestyle.h"
#include "BKE_gpencil.h"
#include "BKE_idprop.h"
@@ -621,6 +624,74 @@ static ARegion *do_versions_add_region(int regiontype, const char *name)
return ar;
}
+static void do_version_bones_split_bbone_scale(ListBase *lb)
+{
+ for (Bone *bone = lb->first; bone; bone = bone->next) {
+ bone->scale_in_y = bone->scale_in_x;
+ bone->scale_out_y = bone->scale_out_x;
+
+ do_version_bones_split_bbone_scale(&bone->childbase);
+ }
+}
+
+static bool replace_bbone_scale_rnapath(char **p_old_path)
+{
+ char *old_path = *p_old_path;
+
+ if (old_path == NULL) {
+ return false;
+ }
+
+ if (BLI_str_endswith(old_path, "bbone_scalein") ||
+ BLI_str_endswith(old_path, "bbone_scaleout")) {
+ *p_old_path = BLI_strdupcat(old_path, "x");
+
+ MEM_freeN(old_path);
+ return true;
+ }
+
+ return false;
+}
+
+static void do_version_bbone_scale_fcurve_fix(ListBase *curves, FCurve *fcu)
+{
+ /* Update driver variable paths. */
+ if (fcu->driver) {
+ LISTBASE_FOREACH (DriverVar *, dvar, &fcu->driver->variables) {
+ DRIVER_TARGETS_LOOPER_BEGIN (dvar) {
+ replace_bbone_scale_rnapath(&dtar->rna_path);
+ }
+ DRIVER_TARGETS_LOOPER_END;
+ }
+ }
+
+ /* Update F-Curve's path. */
+ if (replace_bbone_scale_rnapath(&fcu->rna_path)) {
+ /* If matched, duplicate the curve and tweak name. */
+ FCurve *second = copy_fcurve(fcu);
+
+ second->rna_path[strlen(second->rna_path) - 1] = 'y';
+
+ BLI_insertlinkafter(curves, fcu, second);
+
+ /* Add to the curve group. */
+ second->grp = fcu->grp;
+
+ if (fcu->grp != NULL && fcu->grp->channels.last == fcu) {
+ fcu->grp->channels.last = second;
+ }
+ }
+}
+
+static void do_version_bbone_scale_animdata_cb(ID *UNUSED(id),
+ AnimData *adt,
+ void *UNUSED(wrapper_data))
+{
+ LISTBASE_FOREACH_MUTABLE (FCurve *, fcu, &adt->drivers) {
+ do_version_bbone_scale_fcurve_fix(&adt->drivers, fcu);
+ }
+}
+
void do_versions_after_linking_280(Main *bmain)
{
bool use_collection_compat_28 = true;
@@ -3203,6 +3274,32 @@ void blo_do_versions_280(FileData *fd, Library *UNUSED(lib), Main *bmain)
}
}
+ /* Split bbone_scalein/bbone_scaleout into x and y fields. */
+ if (!DNA_struct_elem_find(fd->filesdna, "bPoseChannel", "float", "scale_out_y")) {
+ /* Update armature data and pose channels. */
+ LISTBASE_FOREACH (bArmature *, arm, &bmain->armatures) {
+ do_version_bones_split_bbone_scale(&arm->bonebase);
+ }
+
+ LISTBASE_FOREACH (Object *, ob, &bmain->objects) {
+ if (ob->pose) {
+ LISTBASE_FOREACH (bPoseChannel *, pchan, &ob->pose->chanbase) {
+ pchan->scale_in_y = pchan->scale_in_x;
+ pchan->scale_out_y = pchan->scale_out_x;
+ }
+ }
+ }
+
+ /* Update action curves and drivers. */
+ LISTBASE_FOREACH (bAction *, act, &bmain->actions) {
+ LISTBASE_FOREACH_MUTABLE (FCurve *, fcu, &act->curves) {
+ do_version_bbone_scale_fcurve_fix(&act->curves, fcu);
+ }
+ }
+
+ BKE_animdata_main_cb(bmain, do_version_bbone_scale_animdata_cb, NULL);
+ }
+
/* Versioning code until next subversion bump goes here. */
}
}