Merge branch 'master' into blender2.8
authorGermano <germano.costa@ig.com.br>
Tue, 5 Dec 2017 13:19:47 +0000 (11:19 -0200)
committerGermano <germano.costa@ig.com.br>
Tue, 5 Dec 2017 13:19:47 +0000 (11:19 -0200)
# Conflicts:
# source/blender/editors/mesh/editmesh_select.c

release/scripts/startup/bl_ui/properties_data_bone.py
source/blender/blenkernel/BKE_animsys.h
source/blender/blenkernel/intern/anim_sys.c
source/blender/blenloader/intern/versioning_270.c
source/blender/editors/mesh/editmesh_select.c
source/blender/makesrna/intern/rna_armature.c

index e0e46e4a2667d1c7a702273806211c7f64bd30fc..f0ef00320591be7e81d055a870b0e3360c5e8be3 100644 (file)
@@ -188,13 +188,13 @@ class BONE_PT_curved(BoneButtonsPanel, Panel):
         row = col.row()
         sub = row.column(align=True)
         sub.label(text="Scale:")
-        sub.prop(bbone, "bbone_scalein", text="Scale In")
-        sub.prop(bbone, "bbone_scaleout", text="Scale Out")
+        sub.prop(bbone, "bbone_scalein", text="In")
+        sub.prop(bbone, "bbone_scaleout", text="Out")
 
         sub = row.column(align=True)
         sub.label("Easing:")
-        sub.prop(bbone, "bbone_easein", text="Ease In")
-        sub.prop(bbone, "bbone_easeout", text="Ease Out")
+        sub.prop(bbone, "bbone_easein", text="In")
+        sub.prop(bbone, "bbone_easeout", text="Out")
 
         if pchan:
             layout.separator()
index 622767baa1039addf9876e5cc8358dde58ccff9c..cd64cdce2b83122582f374a642643f863daa8cc7 100644 (file)
@@ -152,9 +152,15 @@ char *BKE_animdata_driver_path_hack(struct bContext *C, struct PointerRNA *ptr,
 /* Define for callback looper used in BKE_animdata_main_cb */
 typedef void (*ID_AnimData_Edit_Callback)(struct ID *id, struct AnimData *adt, void *user_data);
 
+/* Define for callback looper used in BKE_fcurves_main_cb */
+typedef void (*ID_FCurve_Edit_Callback)(struct ID *id, struct FCurve *fcu, void *user_data);
+
 
 /* Loop over all datablocks applying callback */
-void BKE_animdata_main_cb(struct Main *main, ID_AnimData_Edit_Callback func, void *user_data);
+void BKE_animdata_main_cb(struct Main *bmain, ID_AnimData_Edit_Callback func, void *user_data);
+
+/* Loop over all datablocks applying callback to all its F-Curves */
+void BKE_fcurves_main_cb(struct Main *bmain, ID_FCurve_Edit_Callback func, void *user_data);
 
 /* ************************************* */
 // TODO: overrides, remapping, and path-finding api's
index 5b7947df9dd3317ef1e58e6a2f7d1f8995d88311..07de2ad63429b1a3f05560f8311b18ee5f095937 100644 (file)
@@ -800,8 +800,7 @@ static void nlastrips_path_rename_fix(ID *owner_id, const char *prefix, const ch
        }
 }
 
-/* ----------------------- */
-
+/* Rename Sub-ID Entities in RNA Paths ----------------------- */
 
 /* Fix up the given RNA-Path
  *
@@ -947,8 +946,7 @@ void BKE_animdata_fix_paths_rename(ID *owner_id, AnimData *adt, ID *ref_id, cons
        MEM_freeN(newN);
 }
 
-/* *************************** */
-/* remove of individual paths */
+/* Remove FCurves with Prefix  -------------------------------------- */
 
 /* Check RNA-Paths for a list of F-Curves */
 static void fcurves_path_remove_fix(const char *prefix, ListBase *curves)
@@ -976,7 +974,6 @@ static void nlastrips_path_remove_fix(const char *prefix, ListBase *strips)
 
        /* recursively check strips, fixing only actions... */
        for (strip = strips->first; strip; strip = strip->next) {
-
                /* fix strip's action */
                if (strip->act)
                        fcurves_path_remove_fix(prefix, &strip->act->curves);
@@ -999,7 +996,6 @@ void BKE_animdata_fix_paths_remove(ID *id, const char *prefix)
 
                /* check if there's any AnimData to start with */
                if (adt) {
-
                        /* free fcurves */
                        if (adt->action)
                                fcurves_path_remove_fix(prefix, &adt->action->curves);
@@ -1017,6 +1013,75 @@ void BKE_animdata_fix_paths_remove(ID *id, const char *prefix)
        }
 }
 
+
+/* Apply Op to All FCurves in Database --------------------------- */
+
+/* "User-Data" wrapper used by BKE_fcurves_main_cb() */
+typedef struct AllFCurvesCbWrapper {
+       ID_FCurve_Edit_Callback func;  /* Operation to apply on F-Curve */
+       void *user_data;               /* Custom data for that operation */
+} AllFCurvesCbWrapper;
+
+/* Helper for adt_apply_all_fcurves_cb() - Apply wrapped operator to list of F-Curves */
+static void fcurves_apply_cb(ID *id, ListBase *fcurves, ID_FCurve_Edit_Callback func, void *user_data)
+{
+       FCurve *fcu;
+       
+       for (fcu = fcurves->first; fcu; fcu = fcu->next) {
+               func(id, fcu, user_data);
+       }
+}
+
+/* Helper for adt_apply_all_fcurves_cb() - Recursively go through each NLA strip */
+static void nlastrips_apply_all_curves_cb(ID *id, ListBase *strips, AllFCurvesCbWrapper *wrapper)
+{
+       NlaStrip *strip;
+       
+       for (strip = strips->first; strip; strip = strip->next) {
+               /* fix strip's action */
+               if (strip->act) {
+                       fcurves_apply_cb(id, &strip->act->curves, wrapper->func, wrapper->user_data);
+               }
+               
+               /* check sub-strips (if metas) */
+               nlastrips_apply_all_curves_cb(id, &strip->strips, wrapper);
+       }
+}
+
+/* Helper for BKE_fcurves_main_cb() - Dispatch wrapped operator to all F-Curves */
+static void adt_apply_all_fcurves_cb(ID *id, AnimData *adt, void *wrapper_data)
+{
+       AllFCurvesCbWrapper *wrapper = wrapper_data;
+       NlaTrack *nlt;
+       
+       if (adt->action) {
+               fcurves_apply_cb(id, &adt->action->curves, wrapper->func, wrapper->user_data);
+       }
+       
+       if (adt->tmpact) {
+               fcurves_apply_cb(id, &adt->tmpact->curves, wrapper->func, wrapper->user_data);
+       }
+       
+       /* free drivers - stored as a list of F-Curves */
+       fcurves_apply_cb(id, &adt->drivers, wrapper->func, wrapper->user_data);
+       
+       /* NLA Data - Animation Data for Strips */
+       for (nlt = adt->nla_tracks.first; nlt; nlt = nlt->next) {
+               nlastrips_apply_all_curves_cb(id, &nlt->strips, wrapper);
+       }
+}
+
+/* apply the given callback function on all F-Curves attached to data in main database */
+void BKE_fcurves_main_cb(Main *mainptr, ID_FCurve_Edit_Callback func, void *user_data)
+{
+       /* Wrap F-Curve operation stuff to pass to the general AnimData-level func */
+       AllFCurvesCbWrapper wrapper = {func, user_data};
+       
+       /* Use the AnimData-based function so that we don't have to reimplement all that stuff */
+       BKE_animdata_main_cb(mainptr, adt_apply_all_fcurves_cb, &wrapper);
+}
+
+
 /* Whole Database Ops -------------------------------------------- */
 
 /* apply the given callback function on all data in main database */
index b945f5bdcd3e4ae13ea1e83a132a0dd211fa6180..bf2d5c8e326a5763f27251c234e6f44de3bb60b6 100644 (file)
@@ -62,6 +62,8 @@
 #include "BKE_animsys.h"
 #include "BKE_brush.h"
 #include "BKE_colortools.h"
+#include "BKE_fcurve.h"
+#include "BKE_gpencil.h"
 #include "BKE_library.h"
 #include "BKE_main.h"
 #include "BKE_mask.h"
@@ -71,7 +73,6 @@
 #include "BKE_sequencer.h"
 #include "BKE_screen.h"
 #include "BKE_tracking.h"
-#include "BKE_gpencil.h"
 
 #include "BLI_math.h"
 #include "BLI_listbase.h"
@@ -285,6 +286,67 @@ static void do_versions_compositor_render_passes(bNodeTree *ntree)
        }
 }
 
+
+static char *replace_bbone_easing_rnapath(char *old_path)
+{
+       char *new_path = NULL;
+       
+       /* NOTE: This will break paths for any bones/custom-properties
+        * which happen be named after the bbone property id's
+        */
+       if (strstr(old_path, "bbone_in"))
+               new_path = BLI_str_replaceN(old_path, "bbone_in", "bbone_easein");
+       else if (strstr(old_path, "bbone_out"))
+               new_path = BLI_str_replaceN(old_path, "bbone_out", "bbone_easeout");
+       
+       if (new_path) {
+               MEM_freeN(old_path);
+               return new_path;
+       }
+       else {
+               return old_path;
+       }
+}
+
+static void do_version_bbone_easing_fcurve_fix(ID *UNUSED(id), FCurve *fcu, void *UNUSED(user_data))
+{
+       /* F-Curve's path (for bbone_in/out) */
+       if (fcu->rna_path) {
+               fcu->rna_path = replace_bbone_easing_rnapath(fcu->rna_path);
+       }
+       
+       /* Driver -> Driver Vars (for bbone_in/out) */
+       if (fcu->driver) {
+               for (DriverVar *dvar = fcu->driver->variables.first; dvar; dvar = dvar->next) {
+                       DRIVER_TARGETS_LOOPER(dvar)
+                       {
+                               if (dtar->rna_path) {
+                                       dtar->rna_path = replace_bbone_easing_rnapath(dtar->rna_path);
+                               }
+                       }
+                       DRIVER_TARGETS_LOOPER_END;
+               }
+       }
+       
+       /* FModifiers -> Stepped (for frame_start/end) */
+       if (fcu->modifiers.first) {
+               for (FModifier *fcm = fcu->modifiers.first; fcm; fcm = fcm->next) {
+                       if (fcm->type == FMODIFIER_TYPE_STEPPED) {
+                               FMod_Stepped *data = fcm->data;
+                               
+                               /* Modifier doesn't work if the modifier's copy of start/end frame are both 0
+                                * as those were only getting written to the fcm->data copy (T52009)
+                                */
+                               if ((fcm->sfra == fcm->efra) && (fcm->sfra == 0)) {
+                                       fcm->sfra = data->start_frame;
+                                       fcm->efra = data->end_frame;
+                               }
+                       }
+               }
+       }
+}
+
+
 void blo_do_versions_270(FileData *fd, Library *UNUSED(lib), Main *main)
 {
        if (!MAIN_VERSION_ATLEAST(main, 270, 0)) {
@@ -1742,4 +1804,10 @@ void do_versions_after_linking_270(Main *main)
                        }
                } FOREACH_NODETREE_END
        }
+       
+       if (!MAIN_VERSION_ATLEAST(main, 279, 2)) {
+               /* B-Bones (bbone_in/out -> bbone_easein/out) + Stepped FMod Frame Start/End fix */
+               /* if (!DNA_struct_elem_find(fd->filesdna, "Bone", "float", "bbone_easein")) */
+               BKE_fcurves_main_cb(main, do_version_bbone_easing_fcurve_fix, NULL);
+       }
 }
index a075ed657d14f01ba752fbb57dc5df05c0da4c03..3e0afd3095ecbd400a6fe834a9deda0c860db0e1 100644 (file)
@@ -640,9 +640,17 @@ BMEdge *EDBM_edge_find_nearest_ex(
                unsigned int index;
                BMEdge *eed;
 
+               /* Make sure that the edges also are considered to find nearest.
+                * TODO: cleanup: add `selectmode` as a parameter */
+               const short ts_selectmode = vc->scene->toolsettings->selectmode;
+               vc->scene->toolsettings->selectmode |= SCE_SELECT_EDGE;
+
                /* No afterqueue (yet), so we check it now, otherwise the bm_xxxofs indices are bad. */
                ED_view3d_backbuf_validate(eval_ctx, vc);
 
+               /* restore `selectmode` */
+               vc->scene->toolsettings->selectmode = ts_selectmode;
+
                index = ED_view3d_backbuf_sample_rect(eval_ctx, vc, vc->mval, dist_px, bm_solidoffs, bm_wireoffs, &dist_test);
                eed = index ? BM_edge_at_index_find_or_table(bm, index - 1) : NULL;
 
index f8a492c3cee198925b8fb35c1cdd8500f9a67e9f..1ec0fd92a67a8190d0ac0650d760be70131a0333 100644 (file)
@@ -549,14 +549,14 @@ void rna_def_bone_curved_common(StructRNA *srna, bool is_posebone)
        RNA_def_property_float_sdna(prop, NULL, "ease1");
        RNA_def_property_range(prop, -5.0f, 5.0f);
        RNA_def_property_float_default(prop, 1.0f);
-       RNA_def_property_ui_text(prop, "B-Bone Ease In", "Length of first Bezier Handle (for B-Bones only)");
+       RNA_def_property_ui_text(prop, "Ease In", "Length of first Bezier Handle (for B-Bones only)");
        RNA_DEF_CURVEBONE_UPDATE(prop, is_posebone);
        
        prop = RNA_def_property(srna, "bbone_easeout", PROP_FLOAT, PROP_NONE);
        RNA_def_property_float_sdna(prop, NULL, "ease2");
        RNA_def_property_range(prop, -5.0f, 5.0f);
        RNA_def_property_float_default(prop, 1.0f);
-       RNA_def_property_ui_text(prop, "B-Bone Ease Out", "Length of second Bezier Handle (for B-Bones only)");
+       RNA_def_property_ui_text(prop, "Ease Out", "Length of second Bezier Handle (for B-Bones only)");
        RNA_DEF_CURVEBONE_UPDATE(prop, is_posebone);
 
        /* Scale In/Out */