[Bf-blender-cvs] [9088eac81be] temp-T96710-pbvh-pixels: Pose Library: use the right icon for the "More Info" button

2022-04-08 Thread Sybren A. Stüvel
Commit: 9088eac81be14ead7bb987b75f432983ca275053
Author: Sybren A. Stüvel
Date:   Thu Apr 7 11:24:43 2022 +0200
Branches: temp-T96710-pbvh-pixels
https://developer.blender.org/rB9088eac81be14ead7bb987b75f432983ca275053

Pose Library: use the right icon for the "More Info" button

===

M   release/scripts/startup/bl_ui/properties_data_armature.py

===

diff --git a/release/scripts/startup/bl_ui/properties_data_armature.py 
b/release/scripts/startup/bl_ui/properties_data_armature.py
index e436fe0b18d..5228c459d8c 100644
--- a/release/scripts/startup/bl_ui/properties_data_armature.py
+++ b/release/scripts/startup/bl_ui/properties_data_armature.py
@@ -177,7 +177,7 @@ class DATA_PT_pose_library(ArmatureButtonsPanel, Panel):
 col.label(text="which was replaced by the Asset Browser.")
 
 url = self.get_manual_url()
-col.operator('wm.url_open', text="More Info", icon="WORLD").url = url
+col.operator('wm.url_open', text="More Info", icon="URL").url = url
 
 layout.separator()

___
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
List details, subscription details or unsubscribe:
https://lists.blender.org/mailman/listinfo/bf-blender-cvs


[Bf-blender-cvs] [82c2e61fbdc] temp-T96710-pbvh-pixels: Cleanup: add clarifying comment to `bpy_app_getsets`

2022-04-08 Thread Sybren A. Stüvel
Commit: 82c2e61fbdc4ab05219a64f4aae42067d9c9cb59
Author: Sybren A. Stüvel
Date:   Thu Apr 7 12:51:48 2022 +0200
Branches: temp-T96710-pbvh-pixels
https://developer.blender.org/rB82c2e61fbdc4ab05219a64f4aae42067d9c9cb59

Cleanup: add clarifying comment to `bpy_app_getsets`

No functional changes.

===

M   source/blender/python/intern/bpy_app.c

===

diff --git a/source/blender/python/intern/bpy_app.c 
b/source/blender/python/intern/bpy_app.c
index 84fe27197f9..621cc79a8db 100644
--- a/source/blender/python/intern/bpy_app.c
+++ b/source/blender/python/intern/bpy_app.c
@@ -445,6 +445,8 @@ static PyGetSetDef bpy_app_getsets[] = {
  NULL,
  (void *)G_FLAG_SCRIPT_AUTOEXEC_FAIL_QUIET},
 {"autoexec_fail_message", bpy_app_autoexec_fail_message_get, NULL, NULL, 
NULL},
+
+/* End-of-list marker. */
 {NULL, NULL, NULL, NULL, NULL},
 };

___
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
List details, subscription details or unsubscribe:
https://lists.blender.org/mailman/listinfo/bf-blender-cvs


[Bf-blender-cvs] [e0abad2f6a2] temp-T96710-pbvh-pixels: Pose Library: avoid errors in the legacy panel when the add-on is disabled

2022-04-08 Thread Sybren A. Stüvel
Commit: e0abad2f6a2d416cf8ffc1803b3115870a58d6f4
Author: Sybren A. Stüvel
Date:   Thu Apr 7 11:27:19 2022 +0200
Branches: temp-T96710-pbvh-pixels
https://developer.blender.org/rBe0abad2f6a2d416cf8ffc1803b3115870a58d6f4

Pose Library: avoid errors in the legacy panel when the add-on is disabled

Avoid errors in the legacy Pose Library panel (in Armature properties)
when the Pose Library add-on is disabled.

It's unfortunate that a built-in panel now has knowledge of an add-on.
Then again, it's temporary (one or two Blender releases), and it now uses
feature detection instead of just assuming the add-on is enabled.

===

M   release/scripts/startup/bl_ui/properties_data_armature.py

===

diff --git a/release/scripts/startup/bl_ui/properties_data_armature.py 
b/release/scripts/startup/bl_ui/properties_data_armature.py
index 5228c459d8c..6980f07eba4 100644
--- a/release/scripts/startup/bl_ui/properties_data_armature.py
+++ b/release/scripts/startup/bl_ui/properties_data_armature.py
@@ -188,8 +188,12 @@ class DATA_PT_pose_library(ArmatureButtonsPanel, Panel):
 col.template_ID(ob, "pose_library", new="poselib.new", 
unlink="poselib.unlink")
 
 if poselib:
-col.operator('poselib.convert_old_object_poselib',
-text="Convert to Pose Assets", icon="ASSET_MANAGER")
+if hasattr(bpy.types, 'POSELIB_OT_convert_old_object_poselib'):
+col.operator('poselib.convert_old_object_poselib',
+text="Convert to Pose Assets", icon="ASSET_MANAGER")
+else:
+col.label(text="Enable the Pose Library add-on to convert", 
icon="ERROR")
+col.label(text="this legacy pose library to pose assets.", 
icon="BLANK1")
 
 # Put the deprecated stuff in its own sub-layout.
 
@@ -226,7 +230,6 @@ class DATA_PT_pose_library(ArmatureButtonsPanel, Panel):
 ).pose_index = poselib.pose_markers.active_index
 
 col.operator("poselib.action_sanitize", icon='HELP', text="")  # 
XXX: put in menu?
-col.operator("poselib.convert_old_poselib", icon='ASSET_MANAGER', 
text="")
 
 if pose_marker_active is not None:
 col.operator("poselib.pose_move", icon='TRIA_UP', 
text="").direction = 'UP'

___
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
List details, subscription details or unsubscribe:
https://lists.blender.org/mailman/listinfo/bf-blender-cvs


[Bf-blender-cvs] [1fc4efd9661] temp-T96710-pbvh-pixels: Cleanup: remove incorrect comment

2022-04-08 Thread Sybren A. Stüvel
Commit: 1fc4efd966121285577accbf7a9a1034b84923bc
Author: Sybren A. Stüvel
Date:   Thu Apr 7 11:01:29 2022 +0200
Branches: temp-T96710-pbvh-pixels
https://developer.blender.org/rB1fc4efd966121285577accbf7a9a1034b84923bc

Cleanup: remove incorrect comment

No functional changes.

===

M   release/scripts/modules/bpy/ops.py

===

diff --git a/release/scripts/modules/bpy/ops.py 
b/release/scripts/modules/bpy/ops.py
index 838bd81c0d2..e19128e41a9 100644
--- a/release/scripts/modules/bpy/ops.py
+++ b/release/scripts/modules/bpy/ops.py
@@ -93,7 +93,6 @@ class _BPyOpsSubModOp:
 return self._module.upper() + "_OT_" + self._func
 
 def idname_py(self):
-# submod.foo -> SUBMOD_OT_foo
 return self._module + "." + self._func
 
 def __call__(self, *args, **kw):

___
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
List details, subscription details or unsubscribe:
https://lists.blender.org/mailman/listinfo/bf-blender-cvs


[Bf-blender-cvs] [72c34068cb4] master: Fix T88281: Pose Library 'flip pose' sometimes flips wrong

2021-07-15 Thread Sybren A. Stüvel
Commit: 72c34068cb44effc009a3adfa929a2c1bbdf802e
Author: Sybren A. Stüvel
Date:   Fri Jul 9 17:24:16 2021 +0200
Branches: master
https://developer.blender.org/rB72c34068cb44effc009a3adfa929a2c1bbdf802e

Fix T88281: Pose Library 'flip pose' sometimes flips wrong

Correct cases where the X-axis of the bone (in pose space) aligns with
the pose-space Y or Z-axis. In these cases the decomposition of the
matrix fails, and a negative scale of the X-axis turns into a 180°
rotation around the Y-axis. An extra -1 scale to the X and Z axes of the
resulting matrix seems to fix things.

===

M   source/blender/blenkernel/intern/action_mirror.c

===

diff --git a/source/blender/blenkernel/intern/action_mirror.c 
b/source/blender/blenkernel/intern/action_mirror.c
index 69e0091444b..ba041388981 100644
--- a/source/blender/blenkernel/intern/action_mirror.c
+++ b/source/blender/blenkernel/intern/action_mirror.c
@@ -322,6 +322,24 @@ static void action_flip_pchan(Object *ob_arm,
 /* Move back to bone-space space, using the flipped bone if it exists. */
 mul_m4_m4m4(chan_mat, arm_mat_inv, chan_mat);
 
+/* The rest pose having an X-axis that is not mapping to a left/right 
direction (so aligned
+ * with the Y or Z axis) creates issues when flipping the pose. Instead of 
a negative scale on
+ * the X-axis, it turns into a 180 degree rotation over the Y-axis. This 
has only been observed
+ * with non-flippable bones, hence the check for `pchan_flip`. */
+const float unit_x[4] = {1.0f, 0.0f, 0.0f, 0.0f};
+const bool is_problematic = pchan_flip == NULL &&
+fabsf(dot_v4v4(pchan->bone->arm_mat[0], 
unit_x)) <= 1e-6;
+if (is_problematic) {
+  /* Matrix needs to flip both the X and Z axes to come out right. */
+  float extra_mat[4][4] = {
+  {-1.0f, 0.0f, 0.0f, 0.0f},
+  {0.0f, 1.0f, 0.0f, 0.0f},
+  {0.0f, 0.0f, -1.0f, 0.0f},
+  {0.0f, 0.0f, 0.0f, 1.0f},
+  };
+  mul_m4_m4m4(chan_mat, extra_mat, chan_mat);
+}
+
 BKE_pchan_apply_mat4(_temp, chan_mat, false);
 
 /* Write the values back to the F-curves. */

___
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
List details, subscription details or unsubscribe:
https://lists.blender.org/mailman/listinfo/bf-blender-cvs


[Bf-blender-cvs] [80e127089cd] temp-asset-browser-poselib-merge: Asset Browser: Python mixin utility for category-specific panels

2021-07-14 Thread Sybren A. Stüvel
Commit: 80e127089cd25d4d89bf9fdb5347daa596610fd0
Author: Sybren A. Stüvel
Date:   Mon Jul 12 13:27:09 2021 +0200
Branches: temp-asset-browser-poselib-merge
https://developer.blender.org/rB80e127089cd25d4d89bf9fdb5347daa596610fd0

Asset Browser: Python mixin utility for category-specific panels

Using this mixin for a panel definition, it's possible to set in which
categories the panel should appear. This is used by the Pose Library
add-on.

===

M   release/scripts/modules/bpy_extras/asset_utils.py

===

diff --git a/release/scripts/modules/bpy_extras/asset_utils.py 
b/release/scripts/modules/bpy_extras/asset_utils.py
index e41d4fa..2cd5dddefbc 100644
--- a/release/scripts/modules/bpy_extras/asset_utils.py
+++ b/release/scripts/modules/bpy_extras/asset_utils.py
@@ -56,6 +56,17 @@ class AssetBrowserPanel:
 return SpaceAssetInfo.is_asset_browser_poll(context)
 
 
+class AssetBrowserSpecificCategoryPanel(AssetBrowserPanel):
+asset_categories = set()  # Set of strings like 'ANIMATIONS', see 
`asset_category_items` in rna_space.c
+
+@classmethod
+def poll(cls, context):
+return (
+SpaceAssetInfo.is_asset_browser_poll(context)
+and context.space_data.params.asset_category in 
cls.asset_categories
+)
+
+
 class AssetMetaDataPanel:
 bl_space_type = 'FILE_BROWSER'
 bl_region_type = 'TOOL_PROPS'

___
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
List details, subscription details or unsubscribe:
https://lists.blender.org/mailman/listinfo/bf-blender-cvs


[Bf-blender-cvs] [afa3c66668d] lineart-shadow: Fix T89435: Reordering FCurves can cause crash or corruption

2021-07-13 Thread Sybren A. Stüvel
Commit: afa3c8debdc5b31707dbb8da39c5460acebe
Author: Sybren A. Stüvel
Date:   Tue Jul 6 15:36:27 2021 +0300
Branches: lineart-shadow
https://developer.blender.org/rBafa3c8debdc5b31707dbb8da39c5460acebe

Fix T89435: Reordering FCurves can cause crash or corruption

Correctly reset `prev` and `next` pointers of action group FCurves when
separating them into distinct `ListBase`s per `bActionGroup`.

These `NULL` pointers are necessary to temporarily demarcate the start &
end of the `bActionGroup::channels` list. Having them still point to
other FCurves caused ordering issues when moving curves towards the
start/end of a group.

This commit corrects the above issue and adds versioning code to rectify
any ordering issues that may have been caused. For this purpose the
`BKE_action_groups_reconstruct()` function is rewritten to avoid relying
on the `bAction::curves` list order or `prev` link integrity.

Differential Revision: https://developer.blender.org/D11811

===

M   source/blender/blenkernel/BKE_blender_version.h
M   source/blender/blenkernel/CMakeLists.txt
M   source/blender/blenkernel/intern/action.c
A   source/blender/blenkernel/intern/action_test.cc
M   source/blender/blenloader/intern/versioning_300.c
M   source/blender/editors/animation/anim_channels_edit.c

===

diff --git a/source/blender/blenkernel/BKE_blender_version.h 
b/source/blender/blenkernel/BKE_blender_version.h
index 9d286b94b04..30f6ad7475d 100644
--- a/source/blender/blenkernel/BKE_blender_version.h
+++ b/source/blender/blenkernel/BKE_blender_version.h
@@ -39,7 +39,7 @@ extern "C" {
 
 /* Blender file format version. */
 #define BLENDER_FILE_VERSION BLENDER_VERSION
-#define BLENDER_FILE_SUBVERSION 8
+#define BLENDER_FILE_SUBVERSION 9
 
 /* Minimum Blender version that supports reading file written with the current
  * version. Older Blender versions will test this and show a warning if the 
file
diff --git a/source/blender/blenkernel/CMakeLists.txt 
b/source/blender/blenkernel/CMakeLists.txt
index a0aee552759..2c25b940578 100644
--- a/source/blender/blenkernel/CMakeLists.txt
+++ b/source/blender/blenkernel/CMakeLists.txt
@@ -765,6 +765,7 @@ add_dependencies(bf_blenkernel bf_dna)
 
 if(WITH_GTESTS)
   set(TEST_SRC
+intern/action_test.cc
 intern/armature_test.cc
 intern/cryptomatte_test.cc
 intern/fcurve_test.cc
diff --git a/source/blender/blenkernel/intern/action.c 
b/source/blender/blenkernel/intern/action.c
index 13ca5ecf23c..d55f023d209 100644
--- a/source/blender/blenkernel/intern/action.c
+++ b/source/blender/blenkernel/intern/action.c
@@ -497,9 +497,8 @@ void action_groups_add_channel(bAction *act, bActionGroup 
*agrp, FCurve *fcurve)
 }
 
 /* Reconstruct group channel pointers.
- * Assumes that the channels are still in the proper order, i.e. that channels 
of the same group
- * are adjacent in the act->channels list. It also assumes that the groups
- * referred to by the FCurves are already in act->groups.
+ * Assumes that the groups referred to by the FCurves are already in 
act->groups.
+ * Reorders the main channel list to match group order.
  */
 void BKE_action_groups_reconstruct(bAction *act)
 {
@@ -514,23 +513,30 @@ void BKE_action_groups_reconstruct(bAction *act)
 BLI_listbase_clear(>channels);
   }
 
-  bActionGroup *grp;
-  bActionGroup *last_grp = NULL;
-  LISTBASE_FOREACH (FCurve *, fcurve, >curves) {
-if (fcurve->grp == NULL) {
-  continue;
-}
+  /* Sort the channels into the group lists, destroying the act->curves list. 
*/
+  ListBase ungrouped = {NULL, NULL};
 
-grp = fcurve->grp;
-if (last_grp != grp) {
-  /* If this is the first time we see this group, this must be the first 
channel. */
-  grp->channels.first = fcurve;
+  LISTBASE_FOREACH_MUTABLE (FCurve *, fcurve, >curves) {
+if (fcurve->grp) {
+  BLI_assert(BLI_findindex(>groups, fcurve->grp) >= 0);
+
+  BLI_addtail(>grp->channels, fcurve);
+}
+else {
+  BLI_addtail(, fcurve);
 }
+  }
+
+  /* Recombine into the main list. */
+  BLI_listbase_clear(>curves);
 
-/* This is the last channel, until it's overwritten by a later iteration. 
*/
-grp->channels.last = fcurve;
-last_grp = grp;
+  LISTBASE_FOREACH (bActionGroup *, group, >groups) {
+/* Copy the list header to preserve the pointers in the group. */
+ListBase tmp = group->channels;
+BLI_movelisttolist(>curves, );
   }
+
+  BLI_movelisttolist(>curves, );
 }
 
 /* Remove the given channel from all groups */
diff --git a/source/blender/blenkernel/intern/action_test.cc 
b/source/blender/blenkernel/intern/action_test.cc
new file mode 100644
index 000..cd8751ec358
--- /dev/null
+++ b/source/blender/blenkernel/intern/action_test.cc
@@ -0,0 +1,144 @@
+/*
+ * This progra

[454f41041a2] lineart-shadow: Deps: upgrade OpenXR 1.0.14 → 1.0.17

2021-07-13 Thread Sybren A. Stüvel
Commit: 454f41041a253bae9c5bde977dd06e22f551fee1
Author: Sybren A. Stüvel
Date:   Fri Jul 9 11:06:40 2021 +0200
Branches: lineart-shadow
https://developer.blender.org/rB454f41041a253bae9c5bde977dd06e22f551fee1

Deps: upgrade OpenXR 1.0.14 → 1.0.17

Simple upgrade of OpenXR to 1.0.17. A version bump was enough, no
Blender code had to change.

Reviewed By: LazyDodo, mont29

Differential Revision: https://developer.blender.org/D11848

===

M   build_files/build_environment/cmake/versions.cmake
M   build_files/build_environment/install_deps.sh

===

diff --git a/build_files/build_environment/cmake/versions.cmake 
b/build_files/build_environment/cmake/versions.cmake
index 2d015440d5d..bb0ee961f05 100644
--- a/build_files/build_environment/cmake/versions.cmake
+++ b/build_files/build_environment/cmake/versions.cmake
@@ -456,9 +456,9 @@ set(NASM_HASH 
aded8b796c996a486a56e0515c83e414116decc3b184d88043480b32eb0a8589)
 set(NASM_HASH_TYPE SHA256)
 set(NASM_FILE nasm-${NASM_VERSION}.tar.gz)
 
-set(XR_OPENXR_SDK_VERSION 1.0.14)
+set(XR_OPENXR_SDK_VERSION 1.0.17)
 set(XR_OPENXR_SDK_URI 
https://github.com/KhronosGroup/OpenXR-SDK/archive/release-${XR_OPENXR_SDK_VERSION}.tar.gz)
-set(XR_OPENXR_SDK_HASH 0df6b2fd6045423451a77ff6bc3e1a75)
+set(XR_OPENXR_SDK_HASH bf0fd8828837edff01047474e90013e1)
 set(XR_OPENXR_SDK_HASH_TYPE MD5)
 set(XR_OPENXR_SDK_FILE OpenXR-SDK-${XR_OPENXR_SDK_VERSION}.tar.gz)
 
diff --git a/build_files/build_environment/install_deps.sh 
b/build_files/build_environment/install_deps.sh
index 1b6b34435e1..c5b7198d012 100755
--- a/build_files/build_environment/install_deps.sh
+++ b/build_files/build_environment/install_deps.sh
@@ -572,7 +572,7 @@ FFMPEG_FORCE_REBUILD=false
 FFMPEG_SKIP=false
 _ffmpeg_list_sep=";"
 
-XR_OPENXR_VERSION="1.0.14"
+XR_OPENXR_VERSION="1.0.17"
 XR_OPENXR_VERSION_SHORT="1.0"
 XR_OPENXR_VERSION_MIN="1.0.8"
 XR_OPENXR_VERSION_MAX="2.0"
@@ -1108,9 +1108,9 @@ FFMPEG_SOURCE=( 
"http://ffmpeg.org/releases/ffmpeg-$FFMPEG_VERSION.tar.bz2; )
 
 XR_OPENXR_USE_REPO=false
 
XR_OPENXR_SOURCE=("https://github.com/KhronosGroup/OpenXR-SDK/archive/release-${XR_OPENXR_VERSION}.tar.gz;)
-#~ XR_OPENXR_SOURCE_REPO=("https://github.com/KhronosGroup/OpenXR-SDK.git;)
-#~ XR_OPENXR_REPO_UID="5900c51562769b03bea699dc0352cae56acb6419d"
-#~ XR_OPENXR_REPO_BRANCH="master"
+XR_OPENXR_SOURCE_REPO=("https://github.com/KhronosGroup/OpenXR-SDK.git;)
+XR_OPENXR_REPO_UID="bf21ccb1007bb531b45d9978919a56ea5059c245"
+XR_OPENXR_REPO_BRANCH="master"
 
 # C++11 is required now
 CXXFLAGS_BACK=$CXXFLAGS

___
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
List details, subscription details or unsubscribe:
https://lists.blender.org/mailman/listinfo/bf-blender-cvs


[Bf-blender-cvs] [209d2bcfa9c] asset-browser-poselib: Merge remote-tracking branch 'origin/master' into asset-browser-poselib

2021-06-14 Thread Sybren A. Stüvel
Commit: 209d2bcfa9ce1429879c24f657ace39feb04fb3c
Author: Sybren A. Stüvel
Date:   Mon Jun 14 16:31:30 2021 +0200
Branches: asset-browser-poselib
https://developer.blender.org/rB209d2bcfa9ce1429879c24f657ace39feb04fb3c

Merge remote-tracking branch 'origin/master' into asset-browser-poselib

===



===



___
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
List details, subscription details or unsubscribe:
https://lists.blender.org/mailman/listinfo/bf-blender-cvs


[Bf-blender-cvs] [b27b33f8117] temp-gpencil-bezier-stroke-type: Previews: allow undo'ing datablock preview generation

2021-04-13 Thread Sybren A. Stüvel
Commit: b27b33f81179cb8ec498b9186cd7af5db24f10b8
Author: Sybren A. Stüvel
Date:   Mon Apr 12 18:08:25 2021 +0200
Branches: temp-gpencil-bezier-stroke-type
https://developer.blender.org/rBb27b33f81179cb8ec498b9186cd7af5db24f10b8

Previews: allow undo'ing datablock preview generation

Allow users to undo the effect of the "Generate Preview" operator in the
asset browser (`ED_OT_lib_id_generate_preview`). Without this, the
button is too dangerous.

===

M   source/blender/editors/util/ed_util_ops.cc

===

diff --git a/source/blender/editors/util/ed_util_ops.cc 
b/source/blender/editors/util/ed_util_ops.cc
index 06f1b999d58..462f7768f81 100644
--- a/source/blender/editors/util/ed_util_ops.cc
+++ b/source/blender/editors/util/ed_util_ops.cc
@@ -149,7 +149,7 @@ static void ED_OT_lib_id_generate_preview(wmOperatorType 
*ot)
   ot->exec = lib_id_generate_preview_exec;
 
   /* flags */
-  ot->flag = OPTYPE_INTERNAL;
+  ot->flag = OPTYPE_INTERNAL | OPTYPE_REGISTER | OPTYPE_UNDO;
 }
 
 /** \} */

___
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
https://lists.blender.org/mailman/listinfo/bf-blender-cvs


[0af8ddab2df] sculpt-dev: CMake/Deps: OpenImageDenoise 1.2.3 → 1.3.0

2021-02-15 Thread Sybren A. Stüvel
Commit: 0af8ddab2dfe29a1993c56dab74e1cf0e712f4f0
Author: Sybren A. Stüvel
Date:   Fri Feb 12 13:34:22 2021 +0100
Branches: sculpt-dev
https://developer.blender.org/rB0af8ddab2dfe29a1993c56dab74e1cf0e712f4f0

CMake/Deps: OpenImageDenoise 1.2.3 → 1.3.0

===

M   build_files/build_environment/cmake/versions.cmake

===

diff --git a/build_files/build_environment/cmake/versions.cmake 
b/build_files/build_environment/cmake/versions.cmake
index 42f858a31c1..8eff4c3180d 100644
--- a/build_files/build_environment/cmake/versions.cmake
+++ b/build_files/build_environment/cmake/versions.cmake
@@ -301,9 +301,9 @@ set(USD_VERSION 20.05)
 set(USD_URI 
https://github.com/PixarAnimationStudios/USD/archive/v${USD_VERSION}.tar.gz)
 set(USD_HASH 6d679e739e7f65725d9c029e37dda9fc)
 
-set(OIDN_VERSION 1.2.3)
+set(OIDN_VERSION 1.3.0)
 set(OIDN_URI 
https://github.com/OpenImageDenoise/oidn/releases/download/v${OIDN_VERSION}/oidn-${OIDN_VERSION}.src.tar.gz)
-set(OIDN_HASH 1f11466c2c3efc27faba5ec7078d12b2)
+set(OIDN_HASH 301a5a0958d375a942014df0679b9270)
 
 set(LIBGLU_VERSION 9.0.1)
 set(LIBGLU_URI 
ftp://ftp.freedesktop.org/pub/mesa/glu/glu-${LIBGLU_VERSION}.tar.xz)

___
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
https://lists.blender.org/mailman/listinfo/bf-blender-cvs


[14fe422b48e] sculpt-dev: CMake/Deps: upgrade USD 20.05 → 21.02

2021-02-15 Thread Sybren A. Stüvel
Commit: 14fe422b48e563eb8298b3d27fbe7d7ba6bc67e2
Author: Sybren A. Stüvel
Date:   Tue Feb 9 10:38:41 2021 +0100
Branches: sculpt-dev
https://developer.blender.org/rB14fe422b48e563eb8298b3d27fbe7d7ba6bc67e2

CMake/Deps: upgrade USD 20.05 → 21.02

USD version 21.02 includes two of the changes Blender used to patch in,
which have now been removed from `usd.diff`. Unfortunately 21.02
introduces another issue where LZ4 symbols are accidentally exported,
causing linker errors. Fortunately these symbols are only used for
resting, so I added a patch hunk that simply removes their `extern "C"`
declaration.

The LZ4 linker issue has been reported upstream at
https://github.com/PixarAnimationStudios/USD/issues/1447.

Reviewed By: sebbas, mont29

Differential Revision: https://developer.blender.org/D10367

===

M   build_files/build_environment/cmake/versions.cmake
M   build_files/build_environment/patches/usd.diff

===

diff --git a/build_files/build_environment/cmake/versions.cmake 
b/build_files/build_environment/cmake/versions.cmake
index 8eff4c3180d..4a879c793a1 100644
--- a/build_files/build_environment/cmake/versions.cmake
+++ b/build_files/build_environment/cmake/versions.cmake
@@ -297,9 +297,9 @@ set(EMBREE_VERSION 3.10.0)
 set(EMBREE_URI https://github.com/embree/embree/archive/v${EMBREE_VERSION}.zip)
 set(EMBREE_HASH 4bbe29e7eaa46417efc75fc5f1e8eb87)
 
-set(USD_VERSION 20.05)
+set(USD_VERSION 21.02)
 set(USD_URI 
https://github.com/PixarAnimationStudios/USD/archive/v${USD_VERSION}.tar.gz)
-set(USD_HASH 6d679e739e7f65725d9c029e37dda9fc)
+set(USD_HASH 1dd1e2092d085ed393c1f7c450a4155a)
 
 set(OIDN_VERSION 1.3.0)
 set(OIDN_URI 
https://github.com/OpenImageDenoise/oidn/releases/download/v${OIDN_VERSION}/oidn-${OIDN_VERSION}.src.tar.gz)
diff --git a/build_files/build_environment/patches/usd.diff 
b/build_files/build_environment/patches/usd.diff
index 27b4955f849..42527a4f443 100644
--- a/build_files/build_environment/patches/usd.diff
+++ b/build_files/build_environment/patches/usd.diff
@@ -26,36 +26,30 @@ diff -Naur external_usd_base/cmake/macros/Public.cmake 
external_usd/cmake/macros
  endforeach()
  foreach(lib ${PXR_OBJECT_LIBS})
  set(objects "${objects};\$")
-
-diff --git a/pxr/base/arch/align.h b/pxr/base/arch/align.h
-index f3cabf4..ebc8a69 100644
 a/pxr/base/arch/align.h
-+++ b/pxr/base/arch/align.h
-@@ -77,7 +77,11 @@ ArchAlignMemory(void *base)
- /// The size of a CPU cache line on the current processor architecture in 
bytes.
- ///
- /// \hideinitializer
-+#if defined(ARCH_OS_DARWIN) && defined(ARCH_CPU_ARM)
-+#define ARCH_CACHE_LINE_SIZE 128
-+#else
- #define ARCH_CACHE_LINE_SIZE 64
-+#endif
+diff -ru USD-20.11/pxr/base/tf/pxrLZ4/lz4.cpp 
external_usd/pxr/base/tf/pxrLZ4/lz4.cpp
+--- USD-20.11/pxr/base/tf/pxrLZ4/lz4.cpp2020-10-14 19:25:19.0 
+0100
 external_usd/pxr/base/tf/pxrLZ4/lz4.cpp 2021-02-09 09:28:51.496190085 
+
+@@ -614,6 +614,15 @@
+ /*-
+ *  Internal Definitions used in Tests
+ **/
++
++/***
++ * Disabled in Blender. The BLOSC library also exposes these
++ * functions, and this causes 'duplicate symbol' linker errors.
++ *
++ * This problem has been reported upstream at
++ * https://github.com/PixarAnimationStudios/USD/issues/1447
++ *
++ ***
+ #if defined (__cplusplus)
+ extern "C" {
+ #endif
+@@ -627,6 +636,7 @@
+ #if defined (__cplusplus)
+ }
+ #endif
++/
  
- ///@}
- 
-diff --git a/pxr/base/arch/math.h b/pxr/base/arch/math.h
-index 3e66c37..64a052c 100644
 a/pxr/base/arch/math.h
-+++ b/pxr/base/arch/math.h
-@@ -42,7 +42,7 @@ PXR_NAMESPACE_OPEN_SCOPE
- /// \addtogroup group_arch_Math
- ///@{
- 
--#if defined (ARCH_CPU_INTEL) || defined(doxygen)
-+#if defined (ARCH_CPU_INTEL) || defined(ARCH_CPU_ARM) || defined(doxygen)
- 
- /// This is the smallest value e such that 1+e^2 == 1, using floats.
- /// True for all IEEE754 chipsets.
-
-
-
+ /*-**
+ *  Compression functions

___
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
https://lists.blender.org/mailman/listinfo/bf-blender-cvs


[Bf-blender-cvs] [4fd2a465544] temp-T52744-euler-filter: Merge remote-tracking branch 'origin/master' into temp-T52744-euler-filter

2020-11-19 Thread Sybren A. Stüvel
Commit: 4fd2a465544b43de739a52012edbd92bf37e1301
Author: Sybren A. Stüvel
Date:   Thu Nov 19 13:06:50 2020 +0100
Branches: temp-T52744-euler-filter
https://developer.blender.org/rB4fd2a465544b43de739a52012edbd92bf37e1301

Merge remote-tracking branch 'origin/master' into temp-T52744-euler-filter

===



===



___
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
https://lists.blender.org/mailman/listinfo/bf-blender-cvs


[Bf-blender-cvs] [e6b106eb9df] temp-T52744-euler-filter: Cleanup: Animation, fix uninitialised variable in Euler filter code

2020-11-19 Thread Sybren A. Stüvel
Commit: e6b106eb9df7b634207b13ff56bfdedaac5ef111
Author: Sybren A. Stüvel
Date:   Thu Nov 19 13:02:13 2020 +0100
Branches: temp-T52744-euler-filter
https://developer.blender.org/rBe6b106eb9df7b634207b13ff56bfdedaac5ef111

Cleanup: Animation, fix uninitialised variable in Euler filter code

No functional changes.

===

M   source/blender/editors/space_graph/graph_edit.c

===

diff --git a/source/blender/editors/space_graph/graph_edit.c 
b/source/blender/editors/space_graph/graph_edit.c
index 678a1358174..52424ab9147 100644
--- a/source/blender/editors/space_graph/graph_edit.c
+++ b/source/blender/editors/space_graph/graph_edit.c
@@ -2615,7 +2615,7 @@ static ListBase /*tEulerFilter*/ 
euler_filter_group_channels(
 const ListBase /*bAnimListElem*/ *anim_data, ReportList *reports, int 
*r_num_groups)
 {
   ListBase euler_groups = {NULL, NULL};
-  tEulerFilter *euf;
+  tEulerFilter *euf = NULL;
   *r_num_groups = 0;
 
   LISTBASE_FOREACH (bAnimListElem *, ale, anim_data) {

___
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
https://lists.blender.org/mailman/listinfo/bf-blender-cvs


[Bf-blender-cvs] [af7af488d48] master: Cleanup: Animation, fix uninitialised variable in Euler filter code

2020-11-19 Thread Sybren A. Stüvel
Commit: af7af488d483852ac97e4450c33800612bfc6d6a
Author: Sybren A. Stüvel
Date:   Thu Nov 19 13:02:13 2020 +0100
Branches: master
https://developer.blender.org/rBaf7af488d483852ac97e4450c33800612bfc6d6a

Cleanup: Animation, fix uninitialised variable in Euler filter code

No functional changes.

===

M   source/blender/editors/space_graph/graph_edit.c

===

diff --git a/source/blender/editors/space_graph/graph_edit.c 
b/source/blender/editors/space_graph/graph_edit.c
index bf76d4a632a..09440ee7d98 100644
--- a/source/blender/editors/space_graph/graph_edit.c
+++ b/source/blender/editors/space_graph/graph_edit.c
@@ -2615,7 +2615,7 @@ static ListBase /*tEulerFilter*/ 
euler_filter_group_channels(
 const ListBase /*bAnimListElem*/ *anim_data, ReportList *reports, int 
*r_num_groups)
 {
   ListBase euler_groups = {NULL, NULL};
-  tEulerFilter *euf;
+  tEulerFilter *euf = NULL;
   *r_num_groups = 0;
 
   LISTBASE_FOREACH (bAnimListElem *, ale, anim_data) {

___
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
https://lists.blender.org/mailman/listinfo/bf-blender-cvs


[Bf-blender-cvs] [226feb52eca] master: Cleanup: Animation, refactor Euler filter

2020-11-19 Thread Sybren A. Stüvel
Commit: 226feb52eca303c31bc799034ec5eb7598383391
Author: Sybren A. Stüvel
Date:   Thu Nov 19 12:03:09 2020 +0100
Branches: master
https://developer.blender.org/rB226feb52eca303c31bc799034ec5eb7598383391

Cleanup: Animation, refactor Euler filter

Split up the Euler filter function into two more functions. The Euler
filter operator works in two stages (find channels that define the X/Y/Z
Euler rotations, and perform filtering on those channels), and each
stage now has its own function. This makes it clearer which data are
used in which part of the code, and makes future improvements easier.

No functional changes.

===

M   source/blender/editors/space_graph/graph_edit.c

===

diff --git a/source/blender/editors/space_graph/graph_edit.c 
b/source/blender/editors/space_graph/graph_edit.c
index ae15b651059..bf76d4a632a 100644
--- a/source/blender/editors/space_graph/graph_edit.c
+++ b/source/blender/editors/space_graph/graph_edit.c
@@ -2610,39 +2610,18 @@ typedef struct tEulerFilter {
   const char *rna_path;
 } tEulerFilter;
 
-static int graphkeys_euler_filter_exec(bContext *C, wmOperator *op)
+/* Find groups of `rotation_euler` channels. */
+static ListBase /*tEulerFilter*/ euler_filter_group_channels(
+const ListBase /*bAnimListElem*/ *anim_data, ReportList *reports, int 
*r_num_groups)
 {
-  bAnimContext ac;
-
-  ListBase anim_data = {NULL, NULL};
-  bAnimListElem *ale;
-  int filter;
-
-  ListBase eulers = {NULL, NULL};
-  tEulerFilter *euf = NULL;
-  int groups = 0, failed = 0;
-
-  /* Get editor data. */
-  if (ANIM_animdata_get_context(C, ) == 0) {
-return OPERATOR_CANCELLED;
-  }
-
-  /* The process is done in two passes:
-   * 1) Sets of three related rotation curves are identified from the selected 
channels,
-   *and are stored as a single 'operation unit' for the next step.
-   * 2) Each set of three F-Curves is processed for each keyframe, with the 
values being
-   *processed as necessary.
-   */
-
-  /* Step 1: extract only the rotation f-curves. */
-  filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_SEL | 
ANIMFILTER_CURVE_VISIBLE |
-ANIMFILTER_FOREDIT | ANIMFILTER_NODUPLIS);
-  ANIM_animdata_filter(, _data, filter, ac.data, ac.datatype);
+  ListBase euler_groups = {NULL, NULL};
+  tEulerFilter *euf;
+  *r_num_groups = 0;
 
-  for (ale = anim_data.first; ale; ale = ale->next) {
-FCurve *fcu = (FCurve *)ale->data;
+  LISTBASE_FOREACH (bAnimListElem *, ale, anim_data) {
+FCurve *const fcu = (FCurve *)ale->data;
 
-/* Check if this is an appropriate F-Curve
+/* Check if this is an appropriate F-Curve:
  * - Only rotation curves.
  * - For pchan curves, make sure we're only using the euler curves.
  */
@@ -2650,7 +2629,7 @@ static int graphkeys_euler_filter_exec(bContext *C, 
wmOperator *op)
   continue;
 }
 if (ELEM(fcu->array_index, 0, 1, 2) == 0) {
-  BKE_reportf(op->reports,
+  BKE_reportf(reports,
   RPT_WARNING,
   "Euler Rotation F-Curve has invalid index (ID='%s', 
Path='%s', Index=%d)",
   (ale->id) ? ale->id->name : TIP_(""),
@@ -2659,6 +2638,10 @@ static int graphkeys_euler_filter_exec(bContext *C, 
wmOperator *op)
   continue;
 }
 
+/* Assume that this animation channel will be touched by the Euler filter. 
Doing this here
+ * saves another loop over the animation data. */
+ale->update |= ANIM_UPDATE_DEFAULT;
+
 /* Optimization: assume that xyz curves will always be stored 
consecutively,
  * so if the paths or the ID's don't match up, then a curve needs to be 
added
  * to a new group.
@@ -2666,40 +2649,34 @@ static int graphkeys_euler_filter_exec(bContext *C, 
wmOperator *op)
 if ((euf) && (euf->id == ale->id) && (STREQ(euf->rna_path, 
fcu->rna_path))) {
   /* This should be fine to add to the existing group then. */
   euf->fcurves[fcu->array_index] = fcu;
-}
-else {
-  /* Just add to a new block. */
-  euf = MEM_callocN(sizeof(tEulerFilter), "tEulerFilter");
-  BLI_addtail(, euf);
-  groups++;
-
-  euf->id = ale->id;
-  /* This should be safe, since we're only using it for a short time. */
-  euf->rna_path = fcu->rna_path;
-  euf->fcurves[fcu->array_index] = fcu;
+  continue;
 }
 
-ale->update |= ANIM_UPDATE_DEFAULT;
-  }
+/* Just add to a new block. */
+euf = MEM_callocN(sizeof(tEulerFilter), "tEulerFilter");
+BLI_addtail(_groups, euf);
+++*r_num_groups;
 
-  if (groups == 0) {
-ANIM_animdata_freelist(_data);
-BKE_report(op->reports, RPT_WARNING, "No Euler Rotation F-Curves to fix 
up");
-return OPERATOR_CANCELLED;
+euf->id = ale->id;
+/* This

[Bf-blender-cvs] [3daacbe6638] temp-T52744-euler-filter: New Euler filter implementation

2020-11-19 Thread Sybren A. Stüvel
Commit: 3daacbe6638741177f0ca6a458b4715351edc7a4
Author: Sybren A. Stüvel
Date:   Thu Nov 19 12:41:13 2020 +0100
Branches: temp-T52744-euler-filter
https://developer.blender.org/rB3daacbe6638741177f0ca6a458b4715351edc7a4

New Euler filter implementation

This new discontinuity filter performs actions on the entire Euler
rotation, rather than on the individual X/Y/Z channels only. This should
make it fix a wider range of discontinuities, for example those in .

Manifest Task: T52744

===

M   source/blender/blenkernel/BKE_fcurve.h
M   source/blender/blenkernel/intern/fcurve.c
M   source/blender/editors/space_graph/graph_edit.c

===

diff --git a/source/blender/blenkernel/BKE_fcurve.h 
b/source/blender/blenkernel/BKE_fcurve.h
index f527f40d0d7..4569e68ea4a 100644
--- a/source/blender/blenkernel/BKE_fcurve.h
+++ b/source/blender/blenkernel/BKE_fcurve.h
@@ -248,6 +248,10 @@ bool BKE_fcurve_calc_bounds(struct FCurve *fcu,
 void BKE_fcurve_active_keyframe_set(struct FCurve *fcu, const struct BezTriple 
*active_bezt);
 int BKE_fcurve_active_keyframe_index(const struct FCurve *fcu);
 
+/* Move the indexed keyframe to the given value, and move the handles with it 
to ensure the slope
+ * remains the same. */
+void BKE_fcurve_keyframe_move_value_with_handles(struct BezTriple *keyframe, 
float new_value);
+
 /* .. */
 
 /* Are keyframes on F-Curve of any use (to final result, and to show in 
editors)? */
diff --git a/source/blender/blenkernel/intern/fcurve.c 
b/source/blender/blenkernel/intern/fcurve.c
index e6d3696b198..bcd2fe098b7 100644
--- a/source/blender/blenkernel/intern/fcurve.c
+++ b/source/blender/blenkernel/intern/fcurve.c
@@ -884,6 +884,14 @@ int BKE_fcurve_active_keyframe_index(const FCurve *fcu)
 
 /** \} */
 
+void BKE_fcurve_keyframe_move_value_with_handles(struct BezTriple *keyframe, 
const float new_value)
+{
+  const float value_delta = new_value - keyframe->vec[1][1];
+  keyframe->vec[0][1] += value_delta;
+  keyframe->vec[1][1] = new_value;
+  keyframe->vec[2][1] += value_delta;
+}
+
 /*  */
 /** \name Status Checks
  * \{ */
diff --git a/source/blender/editors/space_graph/graph_edit.c 
b/source/blender/editors/space_graph/graph_edit.c
index bf76d4a632a..678a1358174 100644
--- a/source/blender/editors/space_graph/graph_edit.c
+++ b/source/blender/editors/space_graph/graph_edit.c
@@ -2690,40 +2690,52 @@ static int euler_filter_perform_filter(ListBase 
/*tEulerFilter*/ *eulers, Report
   continue;
 }
 
-/* Simple method: just treat any difference between
- * keys of greater than 180 degrees as being a flip. */
-/* FIXME: there are more complicated methods that
- * will be needed to fix more cases than just some */
-for (int f = 0; f < 3; f++) {
-  FCurve *fcu = euf->fcurves[f];
-  BezTriple *bezt, *prev;
-  uint i;
-
-  /* Skip if not enough vets to do a decent analysis of */
-  if (fcu->totvert <= 2) {
-continue;
-  }
-
-  /* Prev follows bezt, bezt = "current" point to be fixed. */
-  /* Our method depends on determining a "difference" from the previous 
vert. */
-  for (i = 1, prev = fcu->bezt, bezt = fcu->bezt + 1; i < fcu->totvert; 
i++, prev = bezt++) {
-const float sign = (prev->vec[1][1] > bezt->vec[1][1]) ? 1.0f : -1.0f;
+FCurve *fcu_rot_x = euf->fcurves[0];
+FCurve *fcu_rot_y = euf->fcurves[1];
+FCurve *fcu_rot_z = euf->fcurves[2];
+if (fcu_rot_x->totvert != fcu_rot_y->totvert || fcu_rot_y->totvert != 
fcu_rot_z->totvert) {
+  /* Report which components are missing. */
+  BKE_reportf(reports,
+  RPT_WARNING,
+  "XYZ rotations not equally keyed for ID='%s' and 
RNA-Path='%s'",
+  euf->id->name,
+  euf->rna_path);
 
-/* >= 180 degree flip? */
-if ((sign * (prev->vec[1][1] - bezt->vec[1][1])) < (float)M_PI) {
-  continue;
-}
+  /* Keep track of number of failed sets, and carry on to next group. */
+  failed++;
+  continue;
+}
 
-/* 360 degrees to add/subtract frame value until difference
- * is acceptably small that there's no more flip. */
-const float fac = sign * 2.0f * (float)M_PI;
+if (fcu_rot_x->totvert < 2) {
+  /* Single rotations are trivially "filtered". */
+  continue;
+}
 
-while ((sign * (prev->vec[1][1] - bezt->vec[1][1])) >= (float)M_PI) {
-  bezt->vec[0][1] += fac;
-  bezt->vec[1][1] += fac;
-  bezt->vec[2][1] += fac;
-}
-  }
+float last_euler[3] = {
+fcu_rot_x->bezt[0].vec[1][1],
+  

[Bf-blender-cvs] [b62a2cfa084] temp-T52744-euler-filter: Cleanup: Animation, refactor Euler filter

2020-11-19 Thread Sybren A. Stüvel
Commit: b62a2cfa084e9e0b39c56b45336bfccafec0abb4
Author: Sybren A. Stüvel
Date:   Thu Nov 19 12:03:09 2020 +0100
Branches: temp-T52744-euler-filter
https://developer.blender.org/rBb62a2cfa084e9e0b39c56b45336bfccafec0abb4

Cleanup: Animation, refactor Euler filter

Split up the Euler filter function into two more functions. The Euler
filter operator works in two stages (find channels that define the X/Y/Z
Euler rotations, and perform filtering on those channels), and each
stage now has its own function. This makes it clearer which data are
used in which part of the code, and makes future improvements easier.

No functional changes.

===

M   source/blender/editors/space_graph/graph_edit.c

===

diff --git a/source/blender/editors/space_graph/graph_edit.c 
b/source/blender/editors/space_graph/graph_edit.c
index ae15b651059..bf76d4a632a 100644
--- a/source/blender/editors/space_graph/graph_edit.c
+++ b/source/blender/editors/space_graph/graph_edit.c
@@ -2610,39 +2610,18 @@ typedef struct tEulerFilter {
   const char *rna_path;
 } tEulerFilter;
 
-static int graphkeys_euler_filter_exec(bContext *C, wmOperator *op)
+/* Find groups of `rotation_euler` channels. */
+static ListBase /*tEulerFilter*/ euler_filter_group_channels(
+const ListBase /*bAnimListElem*/ *anim_data, ReportList *reports, int 
*r_num_groups)
 {
-  bAnimContext ac;
-
-  ListBase anim_data = {NULL, NULL};
-  bAnimListElem *ale;
-  int filter;
-
-  ListBase eulers = {NULL, NULL};
-  tEulerFilter *euf = NULL;
-  int groups = 0, failed = 0;
-
-  /* Get editor data. */
-  if (ANIM_animdata_get_context(C, ) == 0) {
-return OPERATOR_CANCELLED;
-  }
-
-  /* The process is done in two passes:
-   * 1) Sets of three related rotation curves are identified from the selected 
channels,
-   *and are stored as a single 'operation unit' for the next step.
-   * 2) Each set of three F-Curves is processed for each keyframe, with the 
values being
-   *processed as necessary.
-   */
-
-  /* Step 1: extract only the rotation f-curves. */
-  filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_SEL | 
ANIMFILTER_CURVE_VISIBLE |
-ANIMFILTER_FOREDIT | ANIMFILTER_NODUPLIS);
-  ANIM_animdata_filter(, _data, filter, ac.data, ac.datatype);
+  ListBase euler_groups = {NULL, NULL};
+  tEulerFilter *euf;
+  *r_num_groups = 0;
 
-  for (ale = anim_data.first; ale; ale = ale->next) {
-FCurve *fcu = (FCurve *)ale->data;
+  LISTBASE_FOREACH (bAnimListElem *, ale, anim_data) {
+FCurve *const fcu = (FCurve *)ale->data;
 
-/* Check if this is an appropriate F-Curve
+/* Check if this is an appropriate F-Curve:
  * - Only rotation curves.
  * - For pchan curves, make sure we're only using the euler curves.
  */
@@ -2650,7 +2629,7 @@ static int graphkeys_euler_filter_exec(bContext *C, 
wmOperator *op)
   continue;
 }
 if (ELEM(fcu->array_index, 0, 1, 2) == 0) {
-  BKE_reportf(op->reports,
+  BKE_reportf(reports,
   RPT_WARNING,
   "Euler Rotation F-Curve has invalid index (ID='%s', 
Path='%s', Index=%d)",
   (ale->id) ? ale->id->name : TIP_(""),
@@ -2659,6 +2638,10 @@ static int graphkeys_euler_filter_exec(bContext *C, 
wmOperator *op)
   continue;
 }
 
+/* Assume that this animation channel will be touched by the Euler filter. 
Doing this here
+ * saves another loop over the animation data. */
+ale->update |= ANIM_UPDATE_DEFAULT;
+
 /* Optimization: assume that xyz curves will always be stored 
consecutively,
  * so if the paths or the ID's don't match up, then a curve needs to be 
added
  * to a new group.
@@ -2666,40 +2649,34 @@ static int graphkeys_euler_filter_exec(bContext *C, 
wmOperator *op)
 if ((euf) && (euf->id == ale->id) && (STREQ(euf->rna_path, 
fcu->rna_path))) {
   /* This should be fine to add to the existing group then. */
   euf->fcurves[fcu->array_index] = fcu;
-}
-else {
-  /* Just add to a new block. */
-  euf = MEM_callocN(sizeof(tEulerFilter), "tEulerFilter");
-  BLI_addtail(, euf);
-  groups++;
-
-  euf->id = ale->id;
-  /* This should be safe, since we're only using it for a short time. */
-  euf->rna_path = fcu->rna_path;
-  euf->fcurves[fcu->array_index] = fcu;
+  continue;
 }
 
-ale->update |= ANIM_UPDATE_DEFAULT;
-  }
+/* Just add to a new block. */
+euf = MEM_callocN(sizeof(tEulerFilter), "tEulerFilter");
+BLI_addtail(_groups, euf);
+++*r_num_groups;
 
-  if (groups == 0) {
-ANIM_animdata_freelist(_data);
-BKE_report(op->reports, RPT_WARNING, "No Euler Rotation F-Curves to fix 
up");
-return OPERATOR_CANCELLED;
+euf->id = ale->id;
+/* This

[Bf-blender-cvs] [fd88246d61d] master: Fix error message prefix in `Quaternion.to_euler()`

2020-11-19 Thread Sybren A. Stüvel
Commit: fd88246d61d64cd39d06ff3484e7d68428886c1a
Author: Sybren A. Stüvel
Date:   Thu Nov 19 11:26:54 2020 +0100
Branches: master
https://developer.blender.org/rBfd88246d61d64cd39d06ff3484e7d68428886c1a

Fix error message prefix in `Quaternion.to_euler()`

Fix copy-paste error of error message prefix, so that the Quaternion
function no longer says it's a Matrix function error.

===

M   source/blender/python/mathutils/mathutils_Quaternion.c

===

diff --git a/source/blender/python/mathutils/mathutils_Quaternion.c 
b/source/blender/python/mathutils/mathutils_Quaternion.c
index b0e6b330968..8d2ab614728 100644
--- a/source/blender/python/mathutils/mathutils_Quaternion.c
+++ b/source/blender/python/mathutils/mathutils_Quaternion.c
@@ -95,7 +95,7 @@ static PyObject *Quaternion_to_euler(QuaternionObject *self, 
PyObject *args)
   }
 
   if (order_str) {
-order = euler_order_from_string(order_str, "Matrix.to_euler()");
+order = euler_order_from_string(order_str, "Quaternion.to_euler()");
 
 if (order == -1) {
   return NULL;

___
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
https://lists.blender.org/mailman/listinfo/bf-blender-cvs


[Bf-blender-cvs] [ae648981471] master: Cleanup: fix bad comment separator

2020-11-19 Thread Sybren A. Stüvel
Commit: ae648981471bc25d1454cbf6886c4baa674e9690
Author: Sybren A. Stüvel
Date:   Thu Nov 19 11:04:30 2020 +0100
Branches: master
https://developer.blender.org/rBae648981471bc25d1454cbf6886c4baa674e9690

Cleanup: fix bad comment separator

Replace `* /` with `*/` to actually end the comment. As it was, the code
compiled but caused an "`/*` in comment" warning.

No functional changes.

===

M   source/blender/editors/space_sequencer/sequencer_proxy.c

===

diff --git a/source/blender/editors/space_sequencer/sequencer_proxy.c 
b/source/blender/editors/space_sequencer/sequencer_proxy.c
index 060b6059faa..2d23520814a 100644
--- a/source/blender/editors/space_sequencer/sequencer_proxy.c
+++ b/source/blender/editors/space_sequencer/sequencer_proxy.c
@@ -47,9 +47,9 @@
 /* Own include. */
 #include "sequencer_intern.h"
 
-/** /
-/** \name Proxy Job Manager
- * \{ */
+/**/
+/** \name Proxy Job Manager
+ * \{ */
 
 typedef struct ProxyBuildJob {
   struct Main *main;

___
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
https://lists.blender.org/mailman/listinfo/bf-blender-cvs


[Bf-blender-cvs] [a25bc796335] master: Merge remote-tracking branch 'origin/blender-v2.91-release'

2020-11-17 Thread Sybren A. Stüvel
Commit: a25bc7963353c09308bb93a3fc6f0bc756fd71ef
Author: Sybren A. Stüvel
Date:   Tue Nov 17 11:11:34 2020 +0100
Branches: master
https://developer.blender.org/rBa25bc7963353c09308bb93a3fc6f0bc756fd71ef

Merge remote-tracking branch 'origin/blender-v2.91-release'

===



===



___
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
https://lists.blender.org/mailman/listinfo/bf-blender-cvs


[Bf-blender-cvs] [02efc0111c1] blender-v2.91-release: Fix T82588: Box Select selects keyframes hidden by "Only Show Selected"

2020-11-17 Thread Sybren A. Stüvel
Commit: 02efc0111c1f7c913b750ca7757ba482fe610af2
Author: Sybren A. Stüvel
Date:   Tue Nov 17 10:58:40 2020 +0100
Branches: blender-v2.91-release
https://developer.blender.org/rB02efc0111c1f7c913b750ca7757ba482fe610af2

Fix T82588: Box Select selects keyframes hidden by "Only Show Selected"

Select only editable keys on selected curves when "Only Show Selected
Curves" is enabled in the Graph Editor's View menu.

This prevents selecting invisible keys with box, circle, and lasso
select in the Graph Editor.

Reviewed By: looch

Differential Revision: https://developer.blender.org/D9580

===

M   source/blender/editors/space_graph/graph_select.c

===

diff --git a/source/blender/editors/space_graph/graph_select.c 
b/source/blender/editors/space_graph/graph_select.c
index 57aaa1fefce..ba684972dd7 100644
--- a/source/blender/editors/space_graph/graph_select.c
+++ b/source/blender/editors/space_graph/graph_select.c
@@ -529,6 +529,9 @@ static void box_select_graphkeys(bAnimContext *ac,
 
   /* filter data */
   filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_CURVE_VISIBLE | 
ANIMFILTER_NODUPLIS);
+  if (sipo->flag & SIPO_SELCUVERTSONLY) {
+filter |= ANIMFILTER_FOREDIT | ANIMFILTER_SELEDIT;
+  }
   ANIM_animdata_filter(ac, _data, filter, ac->data, ac->datatype);
 
   /* get beztriple editing/validation funcs  */

___
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
https://lists.blender.org/mailman/listinfo/bf-blender-cvs


[Bf-blender-cvs] [d1fa04680c0] temp-T82588-box-select-invisible-keys: Fix T82588: Box Select selects keyframes hidden by "Only Show Selected"

2020-11-16 Thread Sybren A. Stüvel
Commit: d1fa04680c0a5443e180ba06da9b3b5cf5b1042d
Author: Sybren A. Stüvel
Date:   Mon Nov 16 18:30:04 2020 +0100
Branches: temp-T82588-box-select-invisible-keys
https://developer.blender.org/rBd1fa04680c0a5443e180ba06da9b3b5cf5b1042d

Fix T82588: Box Select selects keyframes hidden by "Only Show Selected"

Select only editable keys on selected curves when "Only Show Selected Curves" 
is enabled in the Graph Editor's View menu.

This prevents selecting invisible keys with box, circle, and lasso select in 
the Graph Editor.

===

M   source/blender/editors/space_graph/graph_select.c

===

diff --git a/source/blender/editors/space_graph/graph_select.c 
b/source/blender/editors/space_graph/graph_select.c
index 57aaa1fefce..ba684972dd7 100644
--- a/source/blender/editors/space_graph/graph_select.c
+++ b/source/blender/editors/space_graph/graph_select.c
@@ -529,6 +529,9 @@ static void box_select_graphkeys(bAnimContext *ac,
 
   /* filter data */
   filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_CURVE_VISIBLE | 
ANIMFILTER_NODUPLIS);
+  if (sipo->flag & SIPO_SELCUVERTSONLY) {
+filter |= ANIMFILTER_FOREDIT | ANIMFILTER_SELEDIT;
+  }
   ANIM_animdata_filter(ac, _data, filter, ac->data, ac->datatype);
 
   /* get beztriple editing/validation funcs  */

___
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
https://lists.blender.org/mailman/listinfo/bf-blender-cvs


[Bf-blender-cvs] [b78bebb2af0] master: Merge remote-tracking branch 'origin/blender-v2.91-release'

2020-11-16 Thread Sybren A. Stüvel
Commit: b78bebb2af0f5cf8e351d42cded4a17abac31d3f
Author: Sybren A. Stüvel
Date:   Mon Nov 16 14:15:01 2020 +0100
Branches: master
https://developer.blender.org/rBb78bebb2af0f5cf8e351d42cded4a17abac31d3f

Merge remote-tracking branch 'origin/blender-v2.91-release'

===



===



___
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
https://lists.blender.org/mailman/listinfo/bf-blender-cvs


[Bf-blender-cvs] [cb9f6dfebdf] master: Merge remote-tracking branch 'origin/blender-v2.91-release'

2020-11-16 Thread Sybren A. Stüvel
Commit: cb9f6dfebdfb6742257218eb952e3cae44a6a2b2
Author: Sybren A. Stüvel
Date:   Mon Nov 16 12:23:05 2020 +0100
Branches: master
https://developer.blender.org/rBcb9f6dfebdfb6742257218eb952e3cae44a6a2b2

Merge remote-tracking branch 'origin/blender-v2.91-release'

===



===



___
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
https://lists.blender.org/mailman/listinfo/bf-blender-cvs


[Bf-blender-cvs] [ada79b4707e] blender-v2.91-release: Fix T82740: Drivers on movie clip datablock crash on file open

2020-11-16 Thread Sybren A. Stüvel
Commit: ada79b4707edc859a9616390f8dc319c1d2e35c2
Author: Sybren A. Stüvel
Date:   Mon Nov 16 12:11:09 2020 +0100
Branches: blender-v2.91-release
https://developer.blender.org/rBada79b4707edc859a9616390f8dc319c1d2e35c2

Fix T82740: Drivers on movie clip datablock crash on file open

Add call to `BKE_animdata_blend_read_data()` after remapping the MovieClip
datablock address.

===

M   source/blender/blenkernel/intern/movieclip.c

===

diff --git a/source/blender/blenkernel/intern/movieclip.c 
b/source/blender/blenkernel/intern/movieclip.c
index 40b12d8a777..54131342489 100644
--- a/source/blender/blenkernel/intern/movieclip.c
+++ b/source/blender/blenkernel/intern/movieclip.c
@@ -274,6 +274,7 @@ static void movieclip_blend_read_data(BlendDataReader 
*reader, ID *id)
   MovieTracking *tracking = >tracking;
 
   BLO_read_data_address(reader, >adt);
+  BKE_animdata_blend_read_data(reader, clip->adt);
 
   direct_link_movieTracks(reader, >tracks);
   direct_link_moviePlaneTracks(reader, >plane_tracks);

___
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
https://lists.blender.org/mailman/listinfo/bf-blender-cvs


[Bf-blender-cvs] [feb71f1d714] master: Animation: Expand unit tests for `BKE_fcurve_active_keyframe_index()`

2020-11-10 Thread Sybren A. Stüvel
Commit: feb71f1d714887715fd9319c91edfe71eddb4a56
Author: Sybren A. Stüvel
Date:   Tue Nov 10 15:33:14 2020 +0100
Branches: master
https://developer.blender.org/rBfeb71f1d714887715fd9319c91edfe71eddb4a56

Animation: Expand unit tests for `BKE_fcurve_active_keyframe_index()`

Expand unit test for `BKE_fcurve_active_keyframe_index()` to test edge
cases better.

This also introduces a new test macro `EXPECT_BLI_ASSERT()`, which can be
used to test that an assertion fails successfully.

No functional changes to actual Blender code.

===

M   intern/guardedalloc/tests/guardedalloc_overflow_test.cc
M   source/blender/blenkernel/intern/fcurve.c
M   source/blender/blenkernel/intern/fcurve_test.cc
M   tests/gtests/testing/testing.h

===

diff --git a/intern/guardedalloc/tests/guardedalloc_overflow_test.cc 
b/intern/guardedalloc/tests/guardedalloc_overflow_test.cc
index e5754bc95ea..efbfc171fff 100644
--- a/intern/guardedalloc/tests/guardedalloc_overflow_test.cc
+++ b/intern/guardedalloc/tests/guardedalloc_overflow_test.cc
@@ -5,11 +5,6 @@
 #include "MEM_guardedalloc.h"
 
 /* We expect to abort on integer overflow, to prevent possible exploits. */
-#ifdef _WIN32
-#  define ABORT_PREDICATE ::testing::ExitedWithCode(3)
-#else
-#  define ABORT_PREDICATE ::testing::KilledBySignal(SIGABRT)
-#endif
 
 #if defined(__GNUC__) && !defined(__clang__)
 /* Disable since it's the purpose of this test. */
diff --git a/source/blender/blenkernel/intern/fcurve.c 
b/source/blender/blenkernel/intern/fcurve.c
index 8bfc626379f..e6d3696b198 100644
--- a/source/blender/blenkernel/intern/fcurve.c
+++ b/source/blender/blenkernel/intern/fcurve.c
@@ -855,7 +855,7 @@ void BKE_fcurve_active_keyframe_set(FCurve *fcu, const 
BezTriple *active_bezt)
   }
 
   /* The active keyframe should always be selected. */
-  BLI_assert(BEZT_ISSEL_ANY(active_bezt));
+  BLI_assert(BEZT_ISSEL_ANY(active_bezt) || !"active keyframe must be 
selected");
 
   fcu->active_keyframe_index = (int)offset;
 }
diff --git a/source/blender/blenkernel/intern/fcurve_test.cc 
b/source/blender/blenkernel/intern/fcurve_test.cc
index 97dd541e2b9..fb6ce02d146 100644
--- a/source/blender/blenkernel/intern/fcurve_test.cc
+++ b/source/blender/blenkernel/intern/fcurve_test.cc
@@ -22,6 +22,7 @@
 #include "BKE_fcurve.h"
 
 #include "ED_keyframing.h"
+#include "ED_types.h" /* For SELECT. */
 
 #include "DNA_anim_types.h"
 
@@ -295,17 +296,38 @@ TEST(fcurve_active_keyframe, ActiveKeyframe)
   EXPECT_EQ(BKE_fcurve_active_keyframe_index(fcu), 
FCURVE_ACTIVE_KEYFRAME_NONE);
 
   /* Check a "normal" action. */
+  fcu->bezt[2].f2 |= SELECT;
   BKE_fcurve_active_keyframe_set(fcu, >bezt[2]);
   EXPECT_EQ(BKE_fcurve_active_keyframe_index(fcu), 2);
 
-  /* Check out of bounds. */
+  /* Check setting an unselected keyframe as active. */
+  fcu->bezt[2].f1 = fcu->bezt[2].f2 = fcu->bezt[2].f3 = 0;
+  EXPECT_BLI_ASSERT(BKE_fcurve_active_keyframe_set(fcu, >bezt[2]),
+"active keyframe must be selected");
+  EXPECT_EQ(BKE_fcurve_active_keyframe_index(fcu), 
FCURVE_ACTIVE_KEYFRAME_NONE);
+
+  /* Check out of bounds (lower). */
   BKE_fcurve_active_keyframe_set(fcu, fcu->bezt - 20);
+  EXPECT_EQ(fcu->active_keyframe_index, FCURVE_ACTIVE_KEYFRAME_NONE)
+  << "Setting out-of-bounds value via the API should result in valid 
active_keyframe_index";
   EXPECT_EQ(BKE_fcurve_active_keyframe_index(fcu), 
FCURVE_ACTIVE_KEYFRAME_NONE);
 
-  /* Check out of bounds again. */
+  fcu->active_keyframe_index = -20;
+  EXPECT_EQ(BKE_fcurve_active_keyframe_index(fcu), FCURVE_ACTIVE_KEYFRAME_NONE)
+  << "Even with active_keyframe_index out of bounds, getting it via the 
API should produce a "
+ "valid value";
+
+  /* Check out of bounds (higher). */
   BKE_fcurve_active_keyframe_set(fcu, fcu->bezt + 4);
+  EXPECT_EQ(fcu->active_keyframe_index, FCURVE_ACTIVE_KEYFRAME_NONE)
+  << "Setting out-of-bounds value via the API should result in valid 
active_keyframe_index";
   EXPECT_EQ(BKE_fcurve_active_keyframe_index(fcu), 
FCURVE_ACTIVE_KEYFRAME_NONE);
 
+  fcu->active_keyframe_index = fcu->totvert;
+  EXPECT_EQ(BKE_fcurve_active_keyframe_index(fcu), FCURVE_ACTIVE_KEYFRAME_NONE)
+  << "Even with active_keyframe_index out of bounds, getting it via the 
API should produce a "
+ "valid value";
+
   BKE_fcurve_free(fcu);
 }
 
diff --git a/tests/gtests/testing/testing.h b/tests/gtests/testing/testing.h
index 34928035b7d..8136a93314e 100644
--- a/tests/gtests/testing/testing.h
+++ b/tests/gtests/testing/testing.h
@@ -137,4 +137,22 @@ inline void EXPECT_EQ_ARRAY_ND(const T *expected, const T 
*actual, const size_t
   }
 }
 
+#

[Bf-blender-cvs] [2a2bc090960] master: Merge remote-tracking branch 'origin/blender-v2.91-release'

2020-11-10 Thread Sybren A. Stüvel
Commit: 2a2bc090960695e2fc1e701b016126e5e8cc595a
Author: Sybren A. Stüvel
Date:   Tue Nov 10 14:02:28 2020 +0100
Branches: master
https://developer.blender.org/rB2a2bc090960695e2fc1e701b016126e5e8cc595a

Merge remote-tracking branch 'origin/blender-v2.91-release'

===



===



___
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
https://lists.blender.org/mailman/listinfo/bf-blender-cvs


[Bf-blender-cvs] [4960780d76b] blender-v2.91-release: Animation: More explicit boundary checks when setting active keyframe

2020-11-10 Thread Sybren A. Stüvel
Commit: 4960780d76bf5a157404cfa5b126cd8ab87caec8
Author: Sybren A. Stüvel
Date:   Tue Nov 10 13:44:47 2020 +0100
Branches: blender-v2.91-release
https://developer.blender.org/rB4960780d76bf5a157404cfa5b126cd8ab87caec8

Animation: More explicit boundary checks when setting active keyframe

Fix unit test failing in debug mode by having more explicit boundary checks
when setting an FCurve's active keyframe.

No functional changes.

===

M   source/blender/blenkernel/intern/fcurve.c

===

diff --git a/source/blender/blenkernel/intern/fcurve.c 
b/source/blender/blenkernel/intern/fcurve.c
index dcf4c78dfd8..003e926e0ae 100644
--- a/source/blender/blenkernel/intern/fcurve.c
+++ b/source/blender/blenkernel/intern/fcurve.c
@@ -841,11 +841,23 @@ bool BKE_fcurve_calc_range(
  */
 void BKE_fcurve_active_keyframe_set(FCurve *fcu, const BezTriple *active_bezt)
 {
+  if (active_bezt == NULL) {
+fcu->active_keyframe_index = FCURVE_ACTIVE_KEYFRAME_NONE;
+return;
+  }
+
+  /* Gracefully handle out-of-bounds pointers. Ideally this would do a 
BLI_assert() as well, but
+   * then the unit tests would break in debug mode. */
+  ptrdiff_t offset = active_bezt - fcu->bezt;
+  if (offset < 0 || offset >= fcu->totvert) {
+fcu->active_keyframe_index = FCURVE_ACTIVE_KEYFRAME_NONE;
+return;
+  }
+
   /* The active keyframe should always be selected. */
-  BLI_assert((active_bezt == NULL) ||
- ((active_bezt->f1 | active_bezt->f2 | active_bezt->f3) & SELECT));
-  fcu->active_keyframe_index = (active_bezt == NULL) ? 
FCURVE_ACTIVE_KEYFRAME_NONE :
-   active_bezt - fcu->bezt;
+  BLI_assert(BEZT_ISSEL_ANY(active_bezt));
+
+  fcu->active_keyframe_index = (int)offset;
 }
 
 /**

___
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
https://lists.blender.org/mailman/listinfo/bf-blender-cvs


[Bf-blender-cvs] [5da05dd6278] master: Fix T82210: Animation, Bake Action cleanup

2020-11-09 Thread Sybren A. Stüvel
Commit: 5da05dd627869eb0cff81f74b6bbfd7875f86e51
Author: Sybren A. Stüvel
Date:   Mon Nov 9 12:41:46 2020 +0100
Branches: master
https://developer.blender.org/rB5da05dd627869eb0cff81f74b6bbfd7875f86e51

Fix T82210: Animation, Bake Action cleanup

Make post-bake cleanup of the Bake Action operator optional, and disable
by default.

Previously Bake Action would do two things:
- Bake the Action
- Clean up the FCurves

It is now possible (and even the default) to only perform the baking
operation.

Reviewed By: #animation_rigging, looch, sybren

Maniphest Tasks: T82210

Differential Revision: https://developer.blender.org/D9453

===

M   release/scripts/startup/bl_operators/anim.py

===

diff --git a/release/scripts/startup/bl_operators/anim.py 
b/release/scripts/startup/bl_operators/anim.py
index 8334557d1f6..ab79ebe3957 100644
--- a/release/scripts/startup/bl_operators/anim.py
+++ b/release/scripts/startup/bl_operators/anim.py
@@ -247,6 +247,11 @@ class NLA_OT_bake(Operator):
 "(useful for baking only part of bones in an armature)",
 default=False,
 )
+clean_curves: BoolProperty(
+name="Clean Curves",
+description="After baking curves, remove redundant keys",
+default=False,
+)
 bake_types: EnumProperty(
 name="Bake Data",
 description="Which data's transformations to bake",
@@ -282,7 +287,7 @@ class NLA_OT_bake(Operator):
 do_visual_keying=self.visual_keying,
 do_constraint_clear=self.clear_constraints,
 do_parents_clear=self.clear_parents,
-do_clean=True,
+do_clean=self.clean_curves,
 )
 
 if not any(actions):

___
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
https://lists.blender.org/mailman/listinfo/bf-blender-cvs


[Bf-blender-cvs] [25375c769a1] master: Cleanup: Sequencer, remove unused function

2020-11-09 Thread Sybren A. Stüvel
Commit: 25375c769a158c54396f60b9ceecd3c267871f3e
Author: Sybren A. Stüvel
Date:   Mon Nov 9 10:58:00 2020 +0100
Branches: master
https://developer.blender.org/rB25375c769a158c54396f60b9ceecd3c267871f3e

Cleanup: Sequencer, remove unused function

Remove `static int clear_scene_in_allseqs_fn(...)`. It was a utility
function for `BKE_sequencer_clear_scene_in_allseqs()`, which was removed
in c063813c30e55ddc8f42ef7632d9dfa109dfddff.

No functional changes.

===

M   source/blender/sequencer/intern/sequencer.c

===

diff --git a/source/blender/sequencer/intern/sequencer.c 
b/source/blender/sequencer/intern/sequencer.c
index 4671c02fe01..67b3b9f5fbd 100644
--- a/source/blender/sequencer/intern/sequencer.c
+++ b/source/blender/sequencer/intern/sequencer.c
@@ -1016,14 +1016,6 @@ int BKE_sequencer_cmp_time_startdisp(const void *a, 
const void *b)
   return (seq_a->startdisp > seq_b->startdisp);
 }
 
-static int clear_scene_in_allseqs_fn(Sequence *seq, void *arg_pt)
-{
-  if (seq->scene == (Scene *)arg_pt) {
-seq->scene = NULL;
-  }
-  return 1;
-}
-
 typedef struct SeqUniqueInfo {
   Sequence *seq;
   char name_src[SEQ_NAME_MAXSTR];

___
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
https://lists.blender.org/mailman/listinfo/bf-blender-cvs


[Bf-blender-cvs] [ad85256e710] master: Animation: move group colors switch to user preferences

2020-11-09 Thread Sybren A. Stüvel
Commit: ad85256e71081016fe7b4009f8a0c0cd7e18dafe
Author: Sybren A. Stüvel
Date:   Fri Oct 30 10:57:46 2020 +0100
Branches: master
https://developer.blender.org/rBad85256e71081016fe7b4009f8a0c0cd7e18dafe

Animation: move group colors switch to user preferences

Move the "Show Group Colors" toggle from a per-editor option to a single
user preference in the Animation preferences. The Grease Pencil
animation channel side panel allows picking a channel color; this now
shows a message when channel colors are disabled.

The old "Show Group Colors" toggle had to be set per editor, and was on
by default. This meant that disabling group colors would require an
action for every file, for every editor. It is very hard to select a
color that works both as bone color in the 3D Viewport (needs to be
bright there) as well as the channel list (needs to be dark there), most
animators turn channel list colors off.

Differential Revision: https://developer.blender.org/D9391

===

M   release/scripts/startup/bl_ui/properties_grease_pencil_common.py
M   release/scripts/startup/bl_ui/space_dopesheet.py
M   release/scripts/startup/bl_ui/space_userpref.py
M   source/blender/blenkernel/BKE_blender_version.h
M   source/blender/blenloader/intern/versioning_userdef.c
M   source/blender/editors/animation/anim_channels_defines.c
M   source/blender/editors/space_action/action_draw.c
M   source/blender/makesdna/DNA_action_types.h
M   source/blender/makesdna/DNA_space_types.h
M   source/blender/makesdna/DNA_userdef_types.h
M   source/blender/makesrna/intern/rna_space.c
M   source/blender/makesrna/intern/rna_userdef.c

===

diff --git a/release/scripts/startup/bl_ui/properties_grease_pencil_common.py 
b/release/scripts/startup/bl_ui/properties_grease_pencil_common.py
index e41858587bf..8201ce080b1 100644
--- a/release/scripts/startup/bl_ui/properties_grease_pencil_common.py
+++ b/release/scripts/startup/bl_ui/properties_grease_pencil_common.py
@@ -881,13 +881,18 @@ class GreasePencilLayerDisplayPanel:
 gpd = ob.data
 gpl = gpd.layers.active
 
-row = layout.row(align=True)
+use_colors = context.preferences.edit.use_anim_channel_group_colors
+
+col = layout.column(align=True)
+col.active = use_colors
+row = col.row(align=True)
 row.prop(gpl, "channel_color")
+if not use_colors:
+col.label(text="Channel Colors are disabled in Animation 
preferences")
 
 row = layout.row(align=True)
 row.prop(gpl, "use_solo_mode", text="Show Only on Keyframed")
 
-
 class GreasePencilFlipTintColors(Operator):
 bl_label = "Flip Colors"
 bl_idname = "gpencil.tint_flip"
diff --git a/release/scripts/startup/bl_ui/space_dopesheet.py 
b/release/scripts/startup/bl_ui/space_dopesheet.py
index 9a716621b08..676e93f4ce9 100644
--- a/release/scripts/startup/bl_ui/space_dopesheet.py
+++ b/release/scripts/startup/bl_ui/space_dopesheet.py
@@ -347,7 +347,6 @@ class DOPESHEET_MT_view(Menu):
 col.active = context.space_data.mode != 'SHAPEKEY'
 col.prop(st, "show_sliders")
 
-layout.prop(st, "show_group_colors")
 layout.prop(st, "show_interpolation")
 layout.prop(st, "show_extremes")
 layout.prop(st, "use_auto_merge_keyframes")
diff --git a/release/scripts/startup/bl_ui/space_userpref.py 
b/release/scripts/startup/bl_ui/space_userpref.py
index 8c1409f00ac..91871acfbc5 100644
--- a/release/scripts/startup/bl_ui/space_userpref.py
+++ b/release/scripts/startup/bl_ui/space_userpref.py
@@ -543,6 +543,7 @@ class USERPREF_PT_animation_fcurves(AnimationPanel, 
CenterAlignMixIn, Panel):
 flow.prop(edit, "keyframe_new_interpolation_type", text="Default 
Interpolation")
 flow.prop(edit, "keyframe_new_handle_type", text="Default Handles")
 flow.prop(edit, "use_insertkey_xyz_to_rgb", text="XYZ to RGB")
+flow.prop(edit, "use_anim_channel_group_colors")
 
 
 # -
diff --git a/source/blender/blenkernel/BKE_blender_version.h 
b/source/blender/blenkernel/BKE_blender_version.h
index 5a64140b917..9fa32013ba6 100644
--- a/source/blender/blenkernel/BKE_blender_version.h
+++ b/source/blender/blenkernel/BKE_blender_version.h
@@ -39,7 +39,7 @@ extern "C" {
 
 /* Blender file format version. */
 #define BLENDER_FILE_VERSION BLENDER_VERSION
-#define BLENDER_FILE_SUBVERSION 3
+#define BLENDER_FILE_SUBVERSION 4
 
 /* Minimum Blender version that supports reading file written with the current
  * version. Older Blender versions will test this and show a warning if 

[Bf-blender-cvs] [16732def37c] master: Cleanup: Clang-Tidy modernize-use-nullptr

2020-11-06 Thread Sybren A. Stüvel
Commit: 16732def37c5a66f3ea28dbe247b09cc6bca6677
Author: Sybren A. Stüvel
Date:   Fri Nov 6 17:49:09 2020 +0100
Branches: master
https://developer.blender.org/rB16732def37c5a66f3ea28dbe247b09cc6bca6677

Cleanup: Clang-Tidy modernize-use-nullptr

Replace `NULL` with `nullptr` in C++ code.

No functional changes.

===

M   .clang-tidy
M   source/blender/blenkernel/intern/fcurve_test.cc
M   source/blender/blenkernel/intern/lattice_deform_test.cc
M   source/blender/blenkernel/intern/simulation.cc
M   source/blender/blenkernel/intern/volume.cc
M   source/blender/blenkernel/intern/volume_render.cc
M   source/blender/blenlib/intern/delaunay_2d.cc
M   source/blender/blenlib/intern/mesh_intersect.cc
M   source/blender/blenlib/intern/task_pool.cc
M   source/blender/blenlib/intern/task_range.cc
M   source/blender/blenlib/tests/BLI_array_store_test.cc
M   source/blender/blenlib/tests/BLI_array_utils_test.cc
M   source/blender/blenlib/tests/BLI_delaunay_2d_test.cc
M   source/blender/blenlib/tests/BLI_expr_pylike_eval_test.cc
M   source/blender/blenlib/tests/BLI_ghash_test.cc
M   source/blender/blenlib/tests/BLI_heap_simple_test.cc
M   source/blender/blenlib/tests/BLI_heap_test.cc
M   source/blender/blenlib/tests/BLI_kdopbvh_test.cc
M   source/blender/blenlib/tests/BLI_linklist_lockfree_test.cc
M   source/blender/blenlib/tests/BLI_listbase_test.cc
M   source/blender/blenlib/tests/BLI_path_util_test.cc
M   source/blender/blenlib/tests/BLI_polyfill_2d_test.cc
M   source/blender/blenlib/tests/BLI_string_test.cc
M   source/blender/blenlib/tests/BLI_string_utf8_test.cc
M   source/blender/blenlib/tests/BLI_task_graph_test.cc
M   source/blender/blenlib/tests/BLI_task_test.cc
M   source/blender/blenlib/tests/BLI_vector_test.cc
M   source/blender/blenlib/tests/performance/BLI_ghash_performance_test.cc
M   source/blender/blenlib/tests/performance/BLI_task_performance_test.cc
M   source/blender/blenloader/tests/blendfile_loading_base_test.cc
M   source/blender/bmesh/tests/bmesh_core_test.cc
M   source/blender/bmesh/tools/bmesh_boolean.cc
M   source/blender/compositor/intern/COM_CPUDevice.cpp
M   source/blender/compositor/intern/COM_CompositorContext.cpp
M   source/blender/compositor/intern/COM_Converter.cpp
M   source/blender/compositor/intern/COM_ExecutionGroup.cpp
M   source/blender/compositor/intern/COM_MemoryBuffer.cpp
M   source/blender/compositor/intern/COM_MemoryProxy.cpp
M   source/blender/compositor/intern/COM_Node.cpp
M   source/blender/compositor/intern/COM_NodeGraph.cpp
M   source/blender/compositor/intern/COM_NodeOperation.cpp
M   source/blender/compositor/intern/COM_NodeOperationBuilder.cpp
M   source/blender/compositor/intern/COM_OpenCLDevice.cpp
M   source/blender/compositor/intern/COM_SingleThreadedOperation.cpp
M   source/blender/compositor/intern/COM_WorkScheduler.cpp
M   source/blender/compositor/nodes/COM_BlurNode.cpp
M   source/blender/compositor/nodes/COM_ChannelMatteNode.cpp
M   source/blender/compositor/nodes/COM_CombineColorNode.cpp
M   source/blender/compositor/nodes/COM_ConvertAlphaNode.cpp
M   source/blender/compositor/nodes/COM_DefocusNode.cpp
M   source/blender/compositor/nodes/COM_FilterNode.cpp
M   source/blender/compositor/nodes/COM_GlareNode.cpp
M   source/blender/compositor/nodes/COM_ImageNode.cpp
M   source/blender/compositor/nodes/COM_KeyingNode.cpp
M   source/blender/compositor/nodes/COM_MathNode.cpp
M   source/blender/compositor/nodes/COM_MovieClipNode.cpp
M   source/blender/compositor/nodes/COM_OutputFileNode.cpp
M   source/blender/compositor/nodes/COM_RenderLayersNode.cpp
M   source/blender/compositor/nodes/COM_SeparateColorNode.cpp
M   source/blender/compositor/nodes/COM_ZCombineNode.cpp
M   source/blender/compositor/operations/COM_AntiAliasOperation.cpp
M   source/blender/compositor/operations/COM_BilateralBlurOperation.cpp
M   source/blender/compositor/operations/COM_BlurBaseOperation.cpp
M   source/blender/compositor/operations/COM_BokehBlurOperation.cpp
M   source/blender/compositor/operations/COM_BokehImageOperation.cpp
M   source/blender/compositor/operations/COM_BoxMaskOperation.cpp
M   source/blender/compositor/operations/COM_BrightnessOperation.cpp
M   source/blender/compositor/operations/COM_CalculateMeanOperation.cpp
M   
source/blender/compositor/operations/COM_CalculateStandardDeviationOperation.cpp
M   source/blender/compositor/operations/COM_ChangeHSVOperation.cpp
M   source/blender/compositor/operations/COM_ChannelMatteOperation.cpp
M   source/blender/compositor/operations/COM_ChromaMatteOperation.cpp
M   source/blender/compositor/operations/COM_ColorBalanceASCCDLOperation.cpp
M   source/blender/compositor/operations

[Bf-blender-cvs] [88926375a0e] master: Clang-Tidy: error out when executable not found

2020-11-06 Thread Sybren A. Stüvel
Commit: 88926375a0e4e45f72c87b9e487c060ddd3c9216
Author: Sybren A. Stüvel
Date:   Fri Nov 6 14:34:04 2020 +0100
Branches: master
https://developer.blender.org/rB88926375a0e4e45f72c87b9e487c060ddd3c9216

Clang-Tidy: error out when executable not found

Stop with an error when the Clang-Tidy executable cannot be found.

Without this check, CMake will happily report "Found Clang-Tidy" but with
the fallback version (0, 0, 0), when `CLANG_TIDY_EXECUTABLE` points to a
non-existing executable.

===

M   build_files/cmake/Modules/FindClangTidy.cmake

===

diff --git a/build_files/cmake/Modules/FindClangTidy.cmake 
b/build_files/cmake/Modules/FindClangTidy.cmake
index d576ad8f100..04c5dfda448 100644
--- a/build_files/cmake/Modules/FindClangTidy.cmake
+++ b/build_files/cmake/Modules/FindClangTidy.cmake
@@ -43,7 +43,10 @@ find_program(CLANG_TIDY_EXECUTABLE
 ${_clang_tidy_SEARCH_DIRS}
 )
 
-if(CLANG_TIDY_EXECUTABLE)
+if(CLANG_TIDY_EXECUTABLE AND NOT EXISTS ${CLANG_TIDY_EXECUTABLE})
+  message(WARNING "Cached or directly specified Clang-Tidy executable does not 
exist.")
+  set(CLANG_TIDY_FOUND FALSE)
+elseif(CLANG_TIDY_EXECUTABLE)
   # Mark clang-tidy as found.
   set(CLANG_TIDY_FOUND TRUE)

___
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
https://lists.blender.org/mailman/listinfo/bf-blender-cvs


[Bf-blender-cvs] [047819e7280] master: Cleanup: Alembic, simplify material assignment code

2020-11-06 Thread Sybren A. Stüvel
Commit: 047819e72805cdf34e5966453609b664e92a912f
Author: Sybren A. Stüvel
Date:   Fri Nov 6 13:09:08 2020 +0100
Branches: master
https://developer.blender.org/rB047819e72805cdf34e5966453609b664e92a912f

Cleanup: Alembic, simplify material assignment code

Refactor material assignment code such that:
- `build_mat_map()` just returns the built map (instead of relying on
  modifying a map passed as parameter),
- `LISTBASE_FOREACH` is used to loop over a `ListBase` (instead of a
  hand-crafted for-loop),
- just `return` when not enough material slots can be created (instead
  of setting a boolean to false, then doing some useless work, then
  checking the boolean),
- reorder some code for clarity, and
- rename `mat_map` to `matname_to_material` so that the semantics are
  clearer.

No functional changes.

===

M   source/blender/io/alembic/intern/abc_reader_mesh.cc

===

diff --git a/source/blender/io/alembic/intern/abc_reader_mesh.cc 
b/source/blender/io/alembic/intern/abc_reader_mesh.cc
index 28e42b1f70f..93520087d83 100644
--- a/source/blender/io/alembic/intern/abc_reader_mesh.cc
+++ b/source/blender/io/alembic/intern/abc_reader_mesh.cc
@@ -33,6 +33,7 @@
 #include "DNA_object_types.h"
 
 #include "BLI_compiler_compat.h"
+#include "BLI_listbase.h"
 #include "BLI_math_geom.h"
 
 #include "BKE_main.h"
@@ -70,55 +71,44 @@ namespace blender::io::alembic {
 /* Some helpers for mesh generation */
 namespace utils {
 
-static void build_mat_map(const Main *bmain, std::map 
_map)
+static std::map build_material_map(const Main *bmain)
 {
-  Material *material = static_cast(bmain->materials.first);
-
-  for (; material; material = static_cast(material->id.next)) {
+  std::map mat_map;
+  LISTBASE_FOREACH (Material *, material, >materials) {
 mat_map[material->id.name + 2] = material;
   }
+  return mat_map;
 }
 
 static void assign_materials(Main *bmain,
  Object *ob,
  const std::map _index_map)
 {
-  bool can_assign = true;
-  std::map::const_iterator it = mat_index_map.begin();
-
-  int matcount = 0;
-  for (; it != mat_index_map.end(); ++it, matcount++) {
+  std::map::const_iterator it;
+  for (it = mat_index_map.begin(); it != mat_index_map.end(); ++it) {
 if (!BKE_object_material_slot_add(bmain, ob)) {
-  can_assign = false;
-  break;
+  return;
 }
   }
 
-  /* TODO(kevin): use global map? */
-  std::map mat_map;
-  build_mat_map(bmain, mat_map);
-
+  std::map matname_to_material = 
build_material_map(bmain);
   std::map::iterator mat_iter;
 
-  if (can_assign) {
-it = mat_index_map.begin();
-
-for (; it != mat_index_map.end(); ++it) {
-  std::string mat_name = it->first;
-  mat_iter = mat_map.find(mat_name);
+  for (it = mat_index_map.begin(); it != mat_index_map.end(); ++it) {
+const std::string mat_name = it->first;
+const int mat_index = it->second;
 
-  Material *assigned_mat;
-
-  if (mat_iter == mat_map.end()) {
-assigned_mat = BKE_material_add(bmain, mat_name.c_str());
-mat_map[mat_name] = assigned_mat;
-  }
-  else {
-assigned_mat = mat_iter->second;
-  }
-
-  BKE_object_material_assign(bmain, ob, assigned_mat, it->second, 
BKE_MAT_ASSIGN_OBDATA);
+Material *assigned_mat;
+mat_iter = matname_to_material.find(mat_name);
+if (mat_iter == matname_to_material.end()) {
+  assigned_mat = BKE_material_add(bmain, mat_name.c_str());
+  matname_to_material[mat_name] = assigned_mat;
+}
+else {
+  assigned_mat = mat_iter->second;
 }
+
+BKE_object_material_assign(bmain, ob, assigned_mat, mat_index, 
BKE_MAT_ASSIGN_OBDATA);
   }
 }

___
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
https://lists.blender.org/mailman/listinfo/bf-blender-cvs


[Bf-blender-cvs] [94ce248b30e] master: Cleanup: Alembic, simplify expression

2020-11-06 Thread Sybren A. Stüvel
Commit: 94ce248b30e8c43ac3108c2d670a1d6a42516f87
Author: Sybren A. Stüvel
Date:   Fri Nov 6 13:27:03 2020 +0100
Branches: master
https://developer.blender.org/rB94ce248b30e8c43ac3108c2d670a1d6a42516f87

Cleanup: Alembic, simplify expression

Change `1 + current_mat++` to `++current_mat`.

No functional changes.

===

M   source/blender/io/alembic/intern/abc_reader_mesh.cc

===

diff --git a/source/blender/io/alembic/intern/abc_reader_mesh.cc 
b/source/blender/io/alembic/intern/abc_reader_mesh.cc
index 93520087d83..c3576ccf259 100644
--- a/source/blender/io/alembic/intern/abc_reader_mesh.cc
+++ b/source/blender/io/alembic/intern/abc_reader_mesh.cc
@@ -727,7 +727,7 @@ void AbcMeshReader::assign_facesets_to_mpoly(const 
ISampleSelector _sel,
 const std::string _name = face_sets[i];
 
 if (r_mat_map.find(grp_name) == r_mat_map.end()) {
-  r_mat_map[grp_name] = 1 + current_mat++;
+  r_mat_map[grp_name] = ++current_mat;
 }
 
 const int assigned_mat = r_mat_map[grp_name];

___
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
https://lists.blender.org/mailman/listinfo/bf-blender-cvs


[Bf-blender-cvs] [c830f213045] temp-T82134-anim-group-colors-to-prefs: Update Grease Pencil anim channel side panel to show a warning when channel colors are disabled.

2020-11-02 Thread Sybren A. Stüvel
Commit: c830f213045ed81c28e60858d90adecf0ba03002
Author: Sybren A. Stüvel
Date:   Mon Nov 2 17:20:47 2020 +0100
Branches: temp-T82134-anim-group-colors-to-prefs
https://developer.blender.org/rBc830f213045ed81c28e60858d90adecf0ba03002

Update Grease Pencil anim channel side panel to show a warning when channel 
colors are disabled.

===

M   release/scripts/startup/bl_ui/properties_grease_pencil_common.py

===

diff --git a/release/scripts/startup/bl_ui/properties_grease_pencil_common.py 
b/release/scripts/startup/bl_ui/properties_grease_pencil_common.py
index d9dbb60b3b6..da7563b2d4b 100644
--- a/release/scripts/startup/bl_ui/properties_grease_pencil_common.py
+++ b/release/scripts/startup/bl_ui/properties_grease_pencil_common.py
@@ -880,13 +880,18 @@ class GreasePencilLayerDisplayPanel:
 gpd = ob.data
 gpl = gpd.layers.active
 
-row = layout.row(align=True)
+use_colors = context.preferences.edit.use_anim_channel_group_colors
+
+col = layout.column(align=True)
+col.active = use_colors
+row = col.row(align=True)
 row.prop(gpl, "channel_color")
+if not use_colors:
+col.label(text="Channel Colors are disabled in Animation 
preferences")
 
 row = layout.row(align=True)
 row.prop(gpl, "use_solo_mode", text="Show Only on Keyframed")
 
-
 class GreasePencilFlipTintColors(Operator):
 bl_label = "Flip Colors"
 bl_idname = "gpencil.tint_flip"

___
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
https://lists.blender.org/mailman/listinfo/bf-blender-cvs


[Bf-blender-cvs] [87b8d6a7b58] temp-T82134-anim-group-colors-to-prefs: Merge remote-tracking branch 'origin/master' into temp-T82134-anim-group-colors-to-prefs

2020-11-02 Thread Sybren A. Stüvel
Commit: 87b8d6a7b5812ed448eb36f27c713ac439f63f12
Author: Sybren A. Stüvel
Date:   Mon Nov 2 17:22:32 2020 +0100
Branches: temp-T82134-anim-group-colors-to-prefs
https://developer.blender.org/rB87b8d6a7b5812ed448eb36f27c713ac439f63f12

Merge remote-tracking branch 'origin/master' into 
temp-T82134-anim-group-colors-to-prefs

===



===



___
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
https://lists.blender.org/mailman/listinfo/bf-blender-cvs


[Bf-blender-cvs] [576bd986220] master: Grease Pencil UI code: use `row` for rows in the UI

2020-11-02 Thread Sybren A. Stüvel
Commit: 576bd9862209125c03dc1b12afb0aade618f9bc0
Author: Sybren A. Stüvel
Date:   Mon Nov 2 17:18:21 2020 +0100
Branches: master
https://developer.blender.org/rB576bd9862209125c03dc1b12afb0aade618f9bc0

Grease Pencil UI code: use `row` for rows in the UI

Rename `col` to `row` when it's actually a row (and not a column).

No functional changes.

===

M   release/scripts/startup/bl_ui/properties_grease_pencil_common.py

===

diff --git a/release/scripts/startup/bl_ui/properties_grease_pencil_common.py 
b/release/scripts/startup/bl_ui/properties_grease_pencil_common.py
index 97e87f5451c..d9dbb60b3b6 100644
--- a/release/scripts/startup/bl_ui/properties_grease_pencil_common.py
+++ b/release/scripts/startup/bl_ui/properties_grease_pencil_common.py
@@ -880,11 +880,11 @@ class GreasePencilLayerDisplayPanel:
 gpd = ob.data
 gpl = gpd.layers.active
 
-col = layout.row(align=True)
-col.prop(gpl, "channel_color")
+row = layout.row(align=True)
+row.prop(gpl, "channel_color")
 
-col = layout.row(align=True)
-col.prop(gpl, "use_solo_mode", text="Show Only on Keyframed")
+row = layout.row(align=True)
+row.prop(gpl, "use_solo_mode", text="Show Only on Keyframed")
 
 
 class GreasePencilFlipTintColors(Operator):

___
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
https://lists.blender.org/mailman/listinfo/bf-blender-cvs


[Bf-blender-cvs] [abcb0845405] temp-T82156-parenting-and-constraints: Merge remote-tracking branch 'origin/master' into temp-T82156-parenting-and-constraints

2020-11-02 Thread Sybren A. Stüvel
Commit: abcb0845405036640bbbdce7b2fe1cfc9293236c
Author: Sybren A. Stüvel
Date:   Mon Nov 2 15:50:44 2020 +0100
Branches: temp-T82156-parenting-and-constraints
https://developer.blender.org/rBabcb0845405036640bbbdce7b2fe1cfc9293236c

Merge remote-tracking branch 'origin/master' into 
temp-T82156-parenting-and-constraints

===



===



___
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
https://lists.blender.org/mailman/listinfo/bf-blender-cvs


[Bf-blender-cvs] [3e9823ac4af] temp-T82156-parenting-and-constraints: Cleanup: Sanitise return value of `ED_object_parent_set()`

2020-11-02 Thread Sybren A. Stüvel
Commit: 3e9823ac4afa42f7f9e2d89e5b29f7d74d6d0359
Author: Sybren A. Stüvel
Date:   Mon Nov 2 10:56:45 2020 +0100
Branches: temp-T82156-parenting-and-constraints
https://developer.blender.org/rB3e9823ac4afa42f7f9e2d89e5b29f7d74d6d0359

Cleanup: Sanitise return value of `ED_object_parent_set()`

Return `false` from `ED_object_parent_set()` when parent and child are
the same object. This would break the parenting operator, as returning
`false` stops its loop over all selected objects. This tight coupling
caused T82312.

The loop now has its own check for this, so that it properly continues,
and the implementation of `ED_object_parent_set()` is decoupled from its
surrounding code.

No functional changes.

===

M   source/blender/editors/include/ED_object.h
M   source/blender/editors/object/object_relations.c

===

diff --git a/source/blender/editors/include/ED_object.h 
b/source/blender/editors/include/ED_object.h
index 6fdd65fdcc9..2e9b711c99a 100644
--- a/source/blender/editors/include/ED_object.h
+++ b/source/blender/editors/include/ED_object.h
@@ -160,6 +160,7 @@ extern struct EnumPropertyItem prop_clear_parent_types[];
 extern struct EnumPropertyItem prop_make_parent_types[];
 #endif
 
+/* Set the object's parent, return true iff successful. */
 bool ED_object_parent_set(struct ReportList *reports,
   const struct bContext *C,
   struct Scene *scene,
diff --git a/source/blender/editors/object/object_relations.c 
b/source/blender/editors/object/object_relations.c
index 3d65a9e5fcb..46624a76999 100644
--- a/source/blender/editors/object/object_relations.c
+++ b/source/blender/editors/object/object_relations.c
@@ -696,7 +696,7 @@ bool ED_object_parent_set(ReportList *reports,
   /* Preconditions. */
   if (ob == par) {
 /* Parenting an object to itself is impossible. */
-return true;
+return false;
   }
 
   if (BKE_object_parent_loop_check(par, ob)) {
@@ -981,6 +981,12 @@ struct ParentingContext {
 static bool parent_set_nonvertex_parent(bContext *C, struct ParentingContext 
*parenting_context)
 {
   CTX_DATA_BEGIN (C, Object *, ob, selected_editable_objects) {
+if (ob == parenting_context->par) {
+  /* ED_object_parent_set() will fail (and thus return false), but this 
case shouldn't break
+   * this loop. It's expected that the active object is also selected. */
+  continue;
+}
+
 if (!ED_object_parent_set(parenting_context->reports,
   C,
   parenting_context->scene,
@@ -1005,6 +1011,12 @@ static bool 
parent_set_vertex_parent_with_kdtree(bContext *C,
   int vert_par[3] = {0, 0, 0};
 
   CTX_DATA_BEGIN (C, Object *, ob, selected_editable_objects) {
+if (ob == parenting_context->par) {
+  /* ED_object_parent_set() will fail (and thus return false), but this 
case shouldn't break
+   * this loop. It's expected that the active object is also selected. */
+  continue;
+}
+
 parent_set_vert_find(tree, ob, vert_par, parenting_context->is_vertex_tri);
 if (!ED_object_parent_set(parenting_context->reports,
   C,

___
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
https://lists.blender.org/mailman/listinfo/bf-blender-cvs


[Bf-blender-cvs] [e5e2a10a137] temp-T82156-parenting-and-constraints: Cleanup: Document output of `BKE_object_where_is_calc` and friends

2020-11-02 Thread Sybren A. Stüvel
Commit: e5e2a10a137081060e1e64dee16523ebd4d617ae
Author: Sybren A. Stüvel
Date:   Mon Nov 2 15:16:05 2020 +0100
Branches: temp-T82156-parenting-and-constraints
https://developer.blender.org/rBe5e2a10a137081060e1e64dee16523ebd4d617ae

Cleanup: Document output of `BKE_object_where_is_calc` and friends

Add a comment to the declaration of the `BKE_object_where_is_calc...()`
functions to explain where the result of the calculation is stored.

No functional changes.

===

M   source/blender/blenkernel/BKE_object.h

===

diff --git a/source/blender/blenkernel/BKE_object.h 
b/source/blender/blenkernel/BKE_object.h
index 0a992f2cb58..b7015942cb4 100644
--- a/source/blender/blenkernel/BKE_object.h
+++ b/source/blender/blenkernel/BKE_object.h
@@ -191,6 +191,8 @@ struct Base **BKE_object_pose_base_array_get(struct 
ViewLayer *view_layer,
  unsigned int *r_bases_len);
 
 void BKE_object_get_parent_matrix(struct Object *ob, struct Object *par, float 
r_parentmat[4][4]);
+
+/* Compute object world transform and store it in ob->obmat. */
 void BKE_object_where_is_calc(struct Depsgraph *depsgraph, struct Scene 
*scene, struct Object *ob);
 void BKE_object_where_is_calc_ex(struct Depsgraph *depsgraph,
  struct Scene *scene,

___
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
https://lists.blender.org/mailman/listinfo/bf-blender-cvs


[Bf-blender-cvs] [75d1139fb52] temp-T82156-parenting-and-constraints: Fix T82156: Object with Copy Rotation Constraints translates when being parented

2020-11-02 Thread Sybren A. Stüvel
Commit: 75d1139fb522b15655efca103f3354e8018fb591
Author: Sybren A. Stüvel
Date:   Mon Nov 2 15:20:33 2020 +0100
Branches: temp-T82156-parenting-and-constraints
https://developer.blender.org/rB75d1139fb522b15655efca103f3354e8018fb591

Fix T82156: Object with Copy Rotation Constraints translates when being parented

Avoid application of constraints when computing the parent-inverse
matrix.

Constraints are meant to be evaluated last; object transforms are
computed this order:

1. `parent->obmat` (the parent object's world matrix)
2. `ob->parentinv` (the object's parent-inverse matrix)
3. Object's loc/rot/scale
4. Object's constraint evaluation

When the constraints are used to compute the parent-inverse matrix,
their effect is moved from step 4 to step 2 in this list, potentially
rotating or scaling the object's local transform. This causes unwanted
movement as reported in T82156.

This behaviour (erroneously taking the constraints into account) has
been in Blender since the first commit, so historically I can only find
"Initial revision" as context.

===

M   source/blender/blenkernel/intern/object.c

===

diff --git a/source/blender/blenkernel/intern/object.c 
b/source/blender/blenkernel/intern/object.c
index 6bfee0194b0..8f3cb06273d 100644
--- a/source/blender/blenkernel/intern/object.c
+++ b/source/blender/blenkernel/intern/object.c
@@ -2855,7 +2855,11 @@ void BKE_object_workob_calc_parent(Depsgraph *depsgraph, 
Scene *scene, Object *o
   workob->par2 = ob->par2;
   workob->par3 = ob->par3;
 
-  workob->constraints = ob->constraints;
+  /* The effects of constraints should NOT be included in the parent-inverse 
matrix. Constraints
+   * are supposed to be applied after the object's local loc/rot/scale. If the 
(inverted) effect of
+   * constraints would be included in the parent inverse matrix, these would 
be applied before the
+   * object's local loc/rot/scale instead of after. For example, a "Copy 
Rotation" constraint would
+   * rotate the object's local translation as well. See T82156. */
 
   BLI_strncpy(workob->parsubstr, ob->parsubstr, sizeof(workob->parsubstr));

___
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
https://lists.blender.org/mailman/listinfo/bf-blender-cvs


[Bf-blender-cvs] [7872bcafa0f] master: Cleanup: Document output of `BKE_object_where_is_calc` and friends

2020-11-02 Thread Sybren A. Stüvel
Commit: 7872bcafa0ffdc642406ac87e5261f69bb0d7bfb
Author: Sybren A. Stüvel
Date:   Mon Nov 2 15:16:05 2020 +0100
Branches: master
https://developer.blender.org/rB7872bcafa0ffdc642406ac87e5261f69bb0d7bfb

Cleanup: Document output of `BKE_object_where_is_calc` and friends

Add a comment to the declaration of the `BKE_object_where_is_calc...()`
functions to explain where the result of the calculation is stored.

No functional changes.

===

M   source/blender/blenkernel/BKE_object.h

===

diff --git a/source/blender/blenkernel/BKE_object.h 
b/source/blender/blenkernel/BKE_object.h
index 0a992f2cb58..b7015942cb4 100644
--- a/source/blender/blenkernel/BKE_object.h
+++ b/source/blender/blenkernel/BKE_object.h
@@ -191,6 +191,8 @@ struct Base **BKE_object_pose_base_array_get(struct 
ViewLayer *view_layer,
  unsigned int *r_bases_len);
 
 void BKE_object_get_parent_matrix(struct Object *ob, struct Object *par, float 
r_parentmat[4][4]);
+
+/* Compute object world transform and store it in ob->obmat. */
 void BKE_object_where_is_calc(struct Depsgraph *depsgraph, struct Scene 
*scene, struct Object *ob);
 void BKE_object_where_is_calc_ex(struct Depsgraph *depsgraph,
  struct Scene *scene,

___
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
https://lists.blender.org/mailman/listinfo/bf-blender-cvs


[Bf-blender-cvs] [7887e91d316] master: Cleanup: Sanitise return value of `ED_object_parent_set()`

2020-11-02 Thread Sybren A. Stüvel
Commit: 7887e91d316567366e99fb0d066861cb89ae5816
Author: Sybren A. Stüvel
Date:   Mon Nov 2 10:56:45 2020 +0100
Branches: master
https://developer.blender.org/rB7887e91d316567366e99fb0d066861cb89ae5816

Cleanup: Sanitise return value of `ED_object_parent_set()`

Consistently return `false` from `ED_object_parent_set()` when parenting
is not possible. Before, when parent and child were the same object, the
function would return `true` even though the parent-child relation was
not made.

Just returning `false` in the `parent == child` case would break the
parenting operator, as `false` stops its loop over all selected objects.
This tight coupling caused T82312. The loop now has its own check for
this, so that it properly continues, and the implementation of
`ED_object_parent_set()` is decoupled from its surrounding code.

No functional changes.

===

M   source/blender/editors/include/ED_object.h
M   source/blender/editors/object/object_relations.c

===

diff --git a/source/blender/editors/include/ED_object.h 
b/source/blender/editors/include/ED_object.h
index 6fdd65fdcc9..2e9b711c99a 100644
--- a/source/blender/editors/include/ED_object.h
+++ b/source/blender/editors/include/ED_object.h
@@ -160,6 +160,7 @@ extern struct EnumPropertyItem prop_clear_parent_types[];
 extern struct EnumPropertyItem prop_make_parent_types[];
 #endif
 
+/* Set the object's parent, return true iff successful. */
 bool ED_object_parent_set(struct ReportList *reports,
   const struct bContext *C,
   struct Scene *scene,
diff --git a/source/blender/editors/object/object_relations.c 
b/source/blender/editors/object/object_relations.c
index 3d65a9e5fcb..46624a76999 100644
--- a/source/blender/editors/object/object_relations.c
+++ b/source/blender/editors/object/object_relations.c
@@ -696,7 +696,7 @@ bool ED_object_parent_set(ReportList *reports,
   /* Preconditions. */
   if (ob == par) {
 /* Parenting an object to itself is impossible. */
-return true;
+return false;
   }
 
   if (BKE_object_parent_loop_check(par, ob)) {
@@ -981,6 +981,12 @@ struct ParentingContext {
 static bool parent_set_nonvertex_parent(bContext *C, struct ParentingContext 
*parenting_context)
 {
   CTX_DATA_BEGIN (C, Object *, ob, selected_editable_objects) {
+if (ob == parenting_context->par) {
+  /* ED_object_parent_set() will fail (and thus return false), but this 
case shouldn't break
+   * this loop. It's expected that the active object is also selected. */
+  continue;
+}
+
 if (!ED_object_parent_set(parenting_context->reports,
   C,
   parenting_context->scene,
@@ -1005,6 +1011,12 @@ static bool 
parent_set_vertex_parent_with_kdtree(bContext *C,
   int vert_par[3] = {0, 0, 0};
 
   CTX_DATA_BEGIN (C, Object *, ob, selected_editable_objects) {
+if (ob == parenting_context->par) {
+  /* ED_object_parent_set() will fail (and thus return false), but this 
case shouldn't break
+   * this loop. It's expected that the active object is also selected. */
+  continue;
+}
+
 parent_set_vert_find(tree, ob, vert_par, parenting_context->is_vertex_tri);
 if (!ED_object_parent_set(parenting_context->reports,
   C,

___
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
https://lists.blender.org/mailman/listinfo/bf-blender-cvs


[Bf-blender-cvs] [b801369c8e6] master: Merge remote-tracking branch 'origin/blender-v2.91-release'

2020-11-02 Thread Sybren A. Stüvel
Commit: b801369c8e6edb4da4c6558f024c8c868626f86b
Author: Sybren A. Stüvel
Date:   Mon Nov 2 11:06:22 2020 +0100
Branches: master
https://developer.blender.org/rBb801369c8e6edb4da4c6558f024c8c868626f86b

Merge remote-tracking branch 'origin/blender-v2.91-release'

===



===



___
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
https://lists.blender.org/mailman/listinfo/bf-blender-cvs


[Bf-blender-cvs] [9e736fc9848] blender-v2.91-release: Revert "Parenting: fix return value when parenting object to itself"

2020-11-02 Thread Sybren A. Stüvel
Commit: 9e736fc98481949e50f50dc59aaedc336ea76811
Author: Sybren A. Stüvel
Date:   Mon Nov 2 10:11:19 2020 +0100
Branches: blender-v2.91-release
https://developer.blender.org/rB9e736fc98481949e50f50dc59aaedc336ea76811

Revert "Parenting: fix return value when parenting object to itself"

This reverts commit ad35fa1993a49f663f782af1c9c41640e94b7eb8, it had
unintended side-effects (T82312).

===

M   source/blender/editors/object/object_relations.c

===

diff --git a/source/blender/editors/object/object_relations.c 
b/source/blender/editors/object/object_relations.c
index 97e4203c3ac..de3e5f3d5f9 100644
--- a/source/blender/editors/object/object_relations.c
+++ b/source/blender/editors/object/object_relations.c
@@ -696,7 +696,7 @@ bool ED_object_parent_set(ReportList *reports,
   /* Preconditions. */
   if (ob == par) {
 /* Parenting an object to itself is impossible. */
-return false;
+return true;
   }
 
   if (BKE_object_parent_loop_check(par, ob)) {

___
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
https://lists.blender.org/mailman/listinfo/bf-blender-cvs


[Bf-blender-cvs] [cc09c0d0484] master: Revert "Parenting: fix return value when parenting object to itself"

2020-11-02 Thread Sybren A. Stüvel
Commit: cc09c0d0484be334c985ccd143c46c266abb8aa0
Author: Sybren A. Stüvel
Date:   Mon Nov 2 10:11:19 2020 +0100
Branches: master
https://developer.blender.org/rBcc09c0d0484be334c985ccd143c46c266abb8aa0

Revert "Parenting: fix return value when parenting object to itself"

This reverts commit ad35fa1993a49f663f782af1c9c41640e94b7eb8, it had
unintended side-effects (T82312).

===

M   source/blender/editors/object/object_relations.c

===

diff --git a/source/blender/editors/object/object_relations.c 
b/source/blender/editors/object/object_relations.c
index 12c61b75ff7..3d65a9e5fcb 100644
--- a/source/blender/editors/object/object_relations.c
+++ b/source/blender/editors/object/object_relations.c
@@ -696,7 +696,7 @@ bool ED_object_parent_set(ReportList *reports,
   /* Preconditions. */
   if (ob == par) {
 /* Parenting an object to itself is impossible. */
-return false;
+return true;
   }
 
   if (BKE_object_parent_loop_check(par, ob)) {

___
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
https://lists.blender.org/mailman/listinfo/bf-blender-cvs


[Bf-blender-cvs] [f6d9a365345] master: Merge remote-tracking branch 'origin/blender-v2.91-release'

2020-10-30 Thread Sybren A. Stüvel
Commit: f6d9a3653458f1f8a89452b944306da159159747
Author: Sybren A. Stüvel
Date:   Fri Oct 30 13:17:49 2020 +0100
Branches: master
https://developer.blender.org/rBf6d9a3653458f1f8a89452b944306da159159747

Merge remote-tracking branch 'origin/blender-v2.91-release'

===



===



___
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
https://lists.blender.org/mailman/listinfo/bf-blender-cvs


[Bf-blender-cvs] [ad35fa1993a] blender-v2.91-release: Parenting: fix return value when parenting object to itself

2020-10-30 Thread Sybren A. Stüvel
Commit: ad35fa1993a49f663f782af1c9c41640e94b7eb8
Author: Sybren A. Stüvel
Date:   Fri Oct 30 12:39:13 2020 +0100
Branches: blender-v2.91-release
https://developer.blender.org/rBad35fa1993a49f663f782af1c9c41640e94b7eb8

Parenting: fix return value when parenting object to itself

Ensure parenting an object to itself is seen as error, by returning
`false`.

This error was introduced as part of a supposed-to-be-non-functional
cleanup rBb8d4a2aff8069dd7d6fb91ad0d9427eed489b68f.

===

M   source/blender/editors/object/object_relations.c

===

diff --git a/source/blender/editors/object/object_relations.c 
b/source/blender/editors/object/object_relations.c
index de3e5f3d5f9..97e4203c3ac 100644
--- a/source/blender/editors/object/object_relations.c
+++ b/source/blender/editors/object/object_relations.c
@@ -696,7 +696,7 @@ bool ED_object_parent_set(ReportList *reports,
   /* Preconditions. */
   if (ob == par) {
 /* Parenting an object to itself is impossible. */
-return true;
+return false;
   }
 
   if (BKE_object_parent_loop_check(par, ob)) {

___
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
https://lists.blender.org/mailman/listinfo/bf-blender-cvs


[Bf-blender-cvs] [70210eb5cea] temp-T82134-anim-group-colors-to-prefs: Animation: move group colors switch to user preferences

2020-10-30 Thread Sybren A. Stüvel
Commit: 70210eb5cea816da32842ea370675efacbbdb109
Author: Sybren A. Stüvel
Date:   Fri Oct 30 10:57:46 2020 +0100
Branches: temp-T82134-anim-group-colors-to-prefs
https://developer.blender.org/rB70210eb5cea816da32842ea370675efacbbdb109

Animation: move group colors switch to user preferences

Move the "Show Group Colors" toggle from a per-editor option to a single
user preference in the Animation preferences.

The old "Show Group Colors" toggle had to be set per editor, and was on
by default. This meant that disabling group colors would require an action
for every file, for every editor.

Differential Revision: https://developer.blender.org/D9391

===

M   release/scripts/startup/bl_ui/space_dopesheet.py
M   release/scripts/startup/bl_ui/space_userpref.py
M   source/blender/blenloader/intern/versioning_userdef.c
M   source/blender/editors/animation/anim_channels_defines.c
M   source/blender/editors/space_action/action_draw.c
M   source/blender/makesdna/DNA_action_types.h
M   source/blender/makesdna/DNA_space_types.h
M   source/blender/makesdna/DNA_userdef_types.h
M   source/blender/makesrna/intern/rna_space.c
M   source/blender/makesrna/intern/rna_userdef.c

===

diff --git a/release/scripts/startup/bl_ui/space_dopesheet.py 
b/release/scripts/startup/bl_ui/space_dopesheet.py
index 9a716621b08..676e93f4ce9 100644
--- a/release/scripts/startup/bl_ui/space_dopesheet.py
+++ b/release/scripts/startup/bl_ui/space_dopesheet.py
@@ -347,7 +347,6 @@ class DOPESHEET_MT_view(Menu):
 col.active = context.space_data.mode != 'SHAPEKEY'
 col.prop(st, "show_sliders")
 
-layout.prop(st, "show_group_colors")
 layout.prop(st, "show_interpolation")
 layout.prop(st, "show_extremes")
 layout.prop(st, "use_auto_merge_keyframes")
diff --git a/release/scripts/startup/bl_ui/space_userpref.py 
b/release/scripts/startup/bl_ui/space_userpref.py
index 1707c21c164..32959d7de5b 100644
--- a/release/scripts/startup/bl_ui/space_userpref.py
+++ b/release/scripts/startup/bl_ui/space_userpref.py
@@ -543,6 +543,7 @@ class USERPREF_PT_animation_fcurves(AnimationPanel, 
CenterAlignMixIn, Panel):
 flow.prop(edit, "keyframe_new_interpolation_type", text="Default 
Interpolation")
 flow.prop(edit, "keyframe_new_handle_type", text="Default Handles")
 flow.prop(edit, "use_insertkey_xyz_to_rgb", text="XYZ to RGB")
+flow.prop(edit, "use_anim_channel_group_colors")
 
 
 # -
diff --git a/source/blender/blenloader/intern/versioning_userdef.c 
b/source/blender/blenloader/intern/versioning_userdef.c
index 6b6d226bd90..df617d70479 100644
--- a/source/blender/blenloader/intern/versioning_userdef.c
+++ b/source/blender/blenloader/intern/versioning_userdef.c
@@ -811,6 +811,8 @@ void blo_do_versions_userdef(UserDef *userdef)
*/
   {
 /* Keep this block, even when empty. */
+
+userdef->animation_flag = USER_ANIM_SHOW_CHANNEL_GROUP_COLORS;
   }
 
   if (userdef->pixelsize == 0.0f) {
diff --git a/source/blender/editors/animation/anim_channels_defines.c 
b/source/blender/editors/animation/anim_channels_defines.c
index 338cbf2cded..c70a86eab1d 100644
--- a/source/blender/editors/animation/anim_channels_defines.c
+++ b/source/blender/editors/animation/anim_channels_defines.c
@@ -54,6 +54,7 @@
 #include "DNA_simulation_types.h"
 #include "DNA_space_types.h"
 #include "DNA_speaker_types.h"
+#include "DNA_userdef_types.h"
 #include "DNA_volume_types.h"
 #include "DNA_world_types.h"
 
@@ -170,28 +171,9 @@ static void acf_generic_dataexpand_backdrop(bAnimContext 
*ac,
 }
 
 /* helper method to test if group colors should be drawn */
-static bool acf_show_channel_colors(bAnimContext *ac)
+static bool acf_show_channel_colors(void)
 {
-  bool showGroupColors = false;
-
-  if (ac->sl) {
-switch (ac->spacetype) {
-  case SPACE_ACTION: {
-SpaceAction *saction = (SpaceAction *)ac->sl;
-showGroupColors = !(saction->flag & SACTION_NODRAWGCOLORS);
-
-break;
-  }
-  case SPACE_GRAPH: {
-SpaceGraph *sipo = (SpaceGraph *)ac->sl;
-showGroupColors = !(sipo->flag & SIPO_NODRAWGCOLORS);
-
-break;
-  }
-}
-  }
-
-  return showGroupColors;
+  return (U.animation_flag & USER_ANIM_SHOW_CHANNEL_GROUP_COLORS) != 0;
 }
 
 /* get backdrop color for generic channels */
@@ -200,7 +182,7 @@ static void acf_generic_channel_color(bAnimContext *ac, 
bAnimListElem *ale, floa
   const bAnimChannelType *acf = ANIM_channel_get_typeinfo(ale);
   bActionGroup *grp = NULL;
   s

[Bf-blender-cvs] [f4e8c0c104f] master: Anim UI: Playback Sync menu improvement

2020-10-29 Thread Sybren A. Stüvel
Commit: f4e8c0c104f3efb66b36f15101dd16242cd43549
Author: Sybren A. Stüvel
Date:   Thu Oct 29 12:31:48 2020 +0100
Branches: master
https://developer.blender.org/rBf4e8c0c104f3efb66b36f15101dd16242cd43549

Anim UI: Playback Sync menu improvement

Relabel the Playback Synchronisation menu so that it's clear:
- what does happen (instead of describing what does //not// happen), and
- that the synchronisation options don't just affect audio.

The changes are:
- Change label from "Audio" to "Sync"
- Change the labels of the sync enum:
- No Sync → Play Every Frame
- Frame Dropping stays the same
- AV-sync → Sync to Audio

The "Audio" label has moved one option down, as that option does
actually relate to audio.

Reviewed By: looch, Severin, HooglyBoogly, campbellbarton

Differential Revision: https://developer.blender.org/D9269

===

M   release/scripts/startup/bl_ui/space_time.py
M   source/blender/makesrna/intern/rna_scene.c

===

diff --git a/release/scripts/startup/bl_ui/space_time.py 
b/release/scripts/startup/bl_ui/space_time.py
index 290bbdb1ab6..16b02db9377 100644
--- a/release/scripts/startup/bl_ui/space_time.py
+++ b/release/scripts/startup/bl_ui/space_time.py
@@ -241,8 +241,8 @@ class TIME_PT_playback(TimelinePanelButtons, Panel):
 screen = context.screen
 scene = context.scene
 
-col = layout.column()
-col.prop(scene, "sync_mode", text="Audio")
+layout.prop(scene, "sync_mode", text="Sync")
+col = layout.column(heading="Audio")
 col.prop(scene, "use_audio_scrub", text="Scrubbing")
 col.prop(scene, "use_audio", text="Mute")
 
diff --git a/source/blender/makesrna/intern/rna_scene.c 
b/source/blender/makesrna/intern/rna_scene.c
index 62d5917bc10..7b7c1516b50 100644
--- a/source/blender/makesrna/intern/rna_scene.c
+++ b/source/blender/makesrna/intern/rna_scene.c
@@ -7359,9 +7359,9 @@ void RNA_def_scene(BlenderRNA *brna)
   };
 
   static const EnumPropertyItem sync_mode_items[] = {
-  {0, "NONE", 0, "No Sync", "Do not sync, play every frame"},
+  {0, "NONE", 0, "Play Every Frame", "Do not sync, play every frame"},
   {SCE_FRAME_DROP, "FRAME_DROP", 0, "Frame Dropping", "Drop frames if 
playback is too slow"},
-  {AUDIO_SYNC, "AUDIO_SYNC", 0, "AV-sync", "Sync to audio playback, 
dropping frames"},
+  {AUDIO_SYNC, "AUDIO_SYNC", 0, "Sync to Audio", "Sync to audio playback, 
dropping frames"},
   {0, NULL, 0, NULL, NULL},
   };

___
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
https://lists.blender.org/mailman/listinfo/bf-blender-cvs


[Bf-blender-cvs] [87d654535c7] temp-T81874-box-select-active-keyframe: Animation: Change active FCurve in box/circle/lasso select

2020-10-26 Thread Sybren A. Stüvel
Commit: 87d654535c7162c8f3f1230d43137b43cd9cd864
Author: Sybren A. Stüvel
Date:   Mon Oct 26 18:18:31 2020 +0100
Branches: temp-T81874-box-select-active-keyframe
https://developer.blender.org/rB87d654535c7162c8f3f1230d43137b43cd9cd864

Animation: Change active FCurve in box/circle/lasso select

Update the active FCurve when box/circle/lasso-selecting, such that after
the operator has finished the active curve is actually the last-operated-on
FCurve.

The operator already would deactivate the active FCurve. However, it would
not re-activate one any more, which caused the active keyframe to become
inactive.

===

M   source/blender/editors/space_graph/graph_select.c

===

diff --git a/source/blender/editors/space_graph/graph_select.c 
b/source/blender/editors/space_graph/graph_select.c
index 5dabdafd27b..f28d8162d14 100644
--- a/source/blender/editors/space_graph/graph_select.c
+++ b/source/blender/editors/space_graph/graph_select.c
@@ -628,6 +628,7 @@ static void box_select_graphkeys(bAnimContext *ac,
 /* select the curve too now that curve will be touched */
 if (selectmode == SELECT_ADD) {
   fcu->flag |= FCURVE_SELECTED;
+  ANIM_set_active_channel(ac, ac->data, ac->datatype, filter, fcu, 
ANIMTYPE_FCURVE);
 }
   }

___
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
https://lists.blender.org/mailman/listinfo/bf-blender-cvs


[Bf-blender-cvs] [eccfa53ad42] temp-T81874-box-select-active-keyframe: Fix T81874: Box Select Keyframes doesnt set an active keyframe

2020-10-26 Thread Sybren A. Stüvel
Commit: eccfa53ad42ca98b6b7b8eec55fa4720b6ab43b2
Author: Sybren A. Stüvel
Date:   Mon Oct 26 14:49:14 2020 +0100
Branches: temp-T81874-box-select-active-keyframe
https://developer.blender.org/rBeccfa53ad42ca98b6b7b8eec55fa4720b6ab43b2

Fix T81874: Box Select Keyframes doesnt set an active keyframe

Set the active keyframe on box/circle/lasso select in the graph editor.

For every FCurve that is influenced by the select operator that doesn't
have an active keyframe yet, the right-most keyframe is marked as the
active Keyframe.

Note that what is seen as the active keyframe for the graph editor also
depends on the active FCurve, which is not changed by box/circle/lasso
select.

===

M   source/blender/editors/space_graph/graph_select.c

===

diff --git a/source/blender/editors/space_graph/graph_select.c 
b/source/blender/editors/space_graph/graph_select.c
index 57aaa1fefce..5dabdafd27b 100644
--- a/source/blender/editors/space_graph/graph_select.c
+++ b/source/blender/editors/space_graph/graph_select.c
@@ -501,6 +501,24 @@ void GRAPH_OT_select_all(wmOperatorType *ot)
  * The selection backend is also reused for the Lasso and Circle select 
operators.
  */
 
+static short fcurve_activate_keyframe(KeyframeEditData *ked, struct BezTriple 
*bezt)
+{
+  BKE_fcurve_active_keyframe_set(ked->fcu, bezt);
+  return 0;
+}
+
+/* Mark the last-selected keyframe as "active".
+ * Does nothing when the FCurve already has an active keyframe. */
+static void fcurve_activate_last_selected_key(KeyframeEditData *ked,
+  FCurve *fcu,
+  const KeyframeEditFunc ok_cb)
+{
+  if (BKE_fcurve_active_keyframe_index(fcu) != FCURVE_ACTIVE_KEYFRAME_NONE) {
+return;
+  }
+  ANIM_fcurve_keyframes_loop(ked, fcu, ok_cb, fcurve_activate_keyframe, NULL);
+}
+
 /* Box Select only selects keyframes now, as overshooting handles often get 
caught too,
  * which means that they may be inadvertently moved as well. However, 
incl_handles overrides
  * this, and allow handles to be considered independently too.
@@ -612,6 +630,10 @@ static void box_select_graphkeys(bAnimContext *ac,
   fcu->flag |= FCURVE_SELECTED;
 }
   }
+
+  if (ELEM(selectmode, SELECT_ADD, SELECT_REPLACE)) {
+fcurve_activate_last_selected_key(, fcu, ok_cb);
+  }
 }
 
 /* un-apply NLA mapping from all the keyframes */

___
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
https://lists.blender.org/mailman/listinfo/bf-blender-cvs


[Bf-blender-cvs] [786e160aff1] master: Merge remote-tracking branch 'origin/blender-v2.91-release'

2020-10-26 Thread Sybren A. Stüvel
Commit: 786e160aff1049682ed9cc600d78148b0cdda473
Author: Sybren A. Stüvel
Date:   Mon Oct 26 13:52:36 2020 +0100
Branches: master
https://developer.blender.org/rB786e160aff1049682ed9cc600d78148b0cdda473

Merge remote-tracking branch 'origin/blender-v2.91-release'

===



===



___
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
https://lists.blender.org/mailman/listinfo/bf-blender-cvs


[8a51178df98] blender-v2.91-release: Fix: Animation, Draw active keyframe handles only when Bézier

2020-10-26 Thread Sybren A. Stüvel
Commit: 8a51178df987418433593d8692246585fa7220cd
Author: Sybren A. Stüvel
Date:   Fri Oct 23 16:32:51 2020 +0200
Branches: blender-v2.91-release
https://developer.blender.org/rB8a51178df987418433593d8692246585fa7220cd

Fix: Animation, Draw active keyframe handles only when Bézier

Draw the handles for the active keyframe only when the interpolation type
is set to Bézier. This now matches the behaviour of handles of regular
(non-active) keyframes.

===

M   source/blender/editors/space_graph/graph_draw.c

===

diff --git a/source/blender/editors/space_graph/graph_draw.c 
b/source/blender/editors/space_graph/graph_draw.c
index d430e331b6c..2e33f3ef4c7 100644
--- a/source/blender/editors/space_graph/graph_draw.c
+++ b/source/blender/editors/space_graph/graph_draw.c
@@ -321,10 +321,12 @@ static void draw_fcurve_active_handle_vertices(const 
FCurve *fcu,
   immUniformColor3fvAlpha(active_col, 0.01f); /* Almost invisible - only keep 
for smoothness. */
   immBeginAtMost(GPU_PRIM_POINTS, 2);
 
-  if ((bezt->f1 & SELECT)) {
+  const BezTriple *left_bezt = active_keyframe_index > 0 ? 
>bezt[active_keyframe_index - 1] :
+   bezt;
+  if (left_bezt->ipo == BEZT_IPO_BEZ && (bezt->f1 & SELECT)) {
 immVertex2fv(pos, bezt->vec[0]);
   }
-  if ((bezt->f3 & SELECT)) {
+  if (bezt->ipo == BEZT_IPO_BEZ && (bezt->f3 & SELECT)) {
 immVertex2fv(pos, bezt->vec[2]);
   }
   immEnd();

___
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
https://lists.blender.org/mailman/listinfo/bf-blender-cvs


[Bf-blender-cvs] [d62309a20e4] blender-v2.91-release: Fix T81890: Active keyframe changes on deselect of keyframe

2020-10-26 Thread Sybren A. Stüvel
Commit: d62309a20e4855cc0feaf5aa78046d5dc8be638f
Author: Sybren A. Stüvel
Date:   Fri Oct 23 17:39:29 2020 +0200
Branches: blender-v2.91-release
https://developer.blender.org/rBd62309a20e4855cc0feaf5aa78046d5dc8be638f

Fix T81890: Active keyframe changes on deselect of keyframe

Activate an FCurve only on selecting, and not on deselecting a keyframe
or a handle.

Reviewed By: HooglyBoogly, Severin, looch, #animation_rigging

Differential Revision: https://developer.blender.org/D9328

===

M   source/blender/editors/space_graph/graph_select.c

===

diff --git a/source/blender/editors/space_graph/graph_select.c 
b/source/blender/editors/space_graph/graph_select.c
index df89a4ff725..57aaa1fefce 100644
--- a/source/blender/editors/space_graph/graph_select.c
+++ b/source/blender/editors/space_graph/graph_select.c
@@ -1481,6 +1481,7 @@ static int mouse_graph_keys(bAnimContext *ac,
 
   /* if points can be selected on this F-Curve */
   /* TODO: what about those with no keyframes? */
+  bool something_was_selected = false;
   if (!curves_only && ((nvi->fcu->flag & FCURVE_PROTECTED) == 0)) {
 /* only if there's keyframe */
 if (nvi->bezt) {
@@ -1488,14 +1489,17 @@ static int mouse_graph_keys(bAnimContext *ac,
   if (select_mode == SELECT_INVERT) {
 if (nvi->hpoint == NEAREST_HANDLE_KEY) {
   bezt->f2 ^= SELECT;
+  something_was_selected = (bezt->f2 & SELECT);
 }
 else if (nvi->hpoint == NEAREST_HANDLE_LEFT) {
   /* toggle selection */
   bezt->f1 ^= SELECT;
+  something_was_selected = (bezt->f1 & SELECT);
 }
 else {
   /* toggle selection */
   bezt->f3 ^= SELECT;
+  something_was_selected = (bezt->f3 & SELECT);
 }
   }
   else {
@@ -1508,6 +1512,7 @@ static int mouse_graph_keys(bAnimContext *ac,
 else {
   bezt->f3 |= SELECT;
 }
+something_was_selected = true;
   }
 
   if (!run_modal && BEZT_ISSEL_ANY(bezt) && !already_selected) {
@@ -1558,10 +1563,10 @@ static int mouse_graph_keys(bAnimContext *ac,
 }
   }
 
-  /* Set active F-Curve, except when dragging the selected keys.
-   * needs to be called with (sipo->flag & SIPO_SELCUVERTSONLY)
+  /* Set active F-Curve when something was actually selected (so not on a 
deselect), except when
+   * dragging the selected keys. Needs to be called with (sipo->flag & 
SIPO_SELCUVERTSONLY),
* otherwise the active flag won't be set T26452. */
-  if (!run_modal && nvi->fcu->flag & FCURVE_SELECTED) {
+  if (!run_modal && (nvi->fcu->flag & FCURVE_SELECTED) && 
something_was_selected) {
 /* NOTE: Sync the filter flags with findnearest_fcurve_vert. */
 int filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_CURVE_VISIBLE | 
ANIMFILTER_NODUPLIS);
 ANIM_set_active_channel(ac, ac->data, ac->datatype, filter, nvi->fcu, 
nvi->ctype);

___
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
https://lists.blender.org/mailman/listinfo/bf-blender-cvs


[Bf-blender-cvs] [83ddd658a68] master: Fix T81890: Active keyframe changes on deselect of keyframe

2020-10-23 Thread Sybren A. Stüvel
Commit: 83ddd658a685a96f88ce91cc82fa1768d69bf562
Author: Sybren A. Stüvel
Date:   Fri Oct 23 17:39:29 2020 +0200
Branches: master
https://developer.blender.org/rB83ddd658a685a96f88ce91cc82fa1768d69bf562

Fix T81890: Active keyframe changes on deselect of keyframe

Activate an FCurve only on selecting, and not on deselecting a keyframe
or a handle.

Reviewed By: HooglyBoogly, Severin, looch, #animation_rigging

Differential Revision: https://developer.blender.org/D9328

===

M   source/blender/editors/space_graph/graph_select.c

===

diff --git a/source/blender/editors/space_graph/graph_select.c 
b/source/blender/editors/space_graph/graph_select.c
index df89a4ff725..57aaa1fefce 100644
--- a/source/blender/editors/space_graph/graph_select.c
+++ b/source/blender/editors/space_graph/graph_select.c
@@ -1481,6 +1481,7 @@ static int mouse_graph_keys(bAnimContext *ac,
 
   /* if points can be selected on this F-Curve */
   /* TODO: what about those with no keyframes? */
+  bool something_was_selected = false;
   if (!curves_only && ((nvi->fcu->flag & FCURVE_PROTECTED) == 0)) {
 /* only if there's keyframe */
 if (nvi->bezt) {
@@ -1488,14 +1489,17 @@ static int mouse_graph_keys(bAnimContext *ac,
   if (select_mode == SELECT_INVERT) {
 if (nvi->hpoint == NEAREST_HANDLE_KEY) {
   bezt->f2 ^= SELECT;
+  something_was_selected = (bezt->f2 & SELECT);
 }
 else if (nvi->hpoint == NEAREST_HANDLE_LEFT) {
   /* toggle selection */
   bezt->f1 ^= SELECT;
+  something_was_selected = (bezt->f1 & SELECT);
 }
 else {
   /* toggle selection */
   bezt->f3 ^= SELECT;
+  something_was_selected = (bezt->f3 & SELECT);
 }
   }
   else {
@@ -1508,6 +1512,7 @@ static int mouse_graph_keys(bAnimContext *ac,
 else {
   bezt->f3 |= SELECT;
 }
+something_was_selected = true;
   }
 
   if (!run_modal && BEZT_ISSEL_ANY(bezt) && !already_selected) {
@@ -1558,10 +1563,10 @@ static int mouse_graph_keys(bAnimContext *ac,
 }
   }
 
-  /* Set active F-Curve, except when dragging the selected keys.
-   * needs to be called with (sipo->flag & SIPO_SELCUVERTSONLY)
+  /* Set active F-Curve when something was actually selected (so not on a 
deselect), except when
+   * dragging the selected keys. Needs to be called with (sipo->flag & 
SIPO_SELCUVERTSONLY),
* otherwise the active flag won't be set T26452. */
-  if (!run_modal && nvi->fcu->flag & FCURVE_SELECTED) {
+  if (!run_modal && (nvi->fcu->flag & FCURVE_SELECTED) && 
something_was_selected) {
 /* NOTE: Sync the filter flags with findnearest_fcurve_vert. */
 int filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_CURVE_VISIBLE | 
ANIMFILTER_NODUPLIS);
 ANIM_set_active_channel(ac, ac->data, ac->datatype, filter, nvi->fcu, 
nvi->ctype);

___
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
https://lists.blender.org/mailman/listinfo/bf-blender-cvs


[0d1b1c341f4] master: Fix: Animation, Draw active keyframe handles only when Bézier

2020-10-23 Thread Sybren A. Stüvel
Commit: 0d1b1c341f4fe386f0818978ff8df1a81e91cd50
Author: Sybren A. Stüvel
Date:   Fri Oct 23 16:32:51 2020 +0200
Branches: master
https://developer.blender.org/rB0d1b1c341f4fe386f0818978ff8df1a81e91cd50

Fix: Animation, Draw active keyframe handles only when Bézier

Draw the handles for the active keyframe only when the interpolation type
is set to Bézier. This now matches the behaviour of handles of regular
(non-active) keyframes.

===

M   source/blender/editors/space_graph/graph_draw.c

===

diff --git a/source/blender/editors/space_graph/graph_draw.c 
b/source/blender/editors/space_graph/graph_draw.c
index d430e331b6c..2e33f3ef4c7 100644
--- a/source/blender/editors/space_graph/graph_draw.c
+++ b/source/blender/editors/space_graph/graph_draw.c
@@ -321,10 +321,12 @@ static void draw_fcurve_active_handle_vertices(const 
FCurve *fcu,
   immUniformColor3fvAlpha(active_col, 0.01f); /* Almost invisible - only keep 
for smoothness. */
   immBeginAtMost(GPU_PRIM_POINTS, 2);
 
-  if ((bezt->f1 & SELECT)) {
+  const BezTriple *left_bezt = active_keyframe_index > 0 ? 
>bezt[active_keyframe_index - 1] :
+   bezt;
+  if (left_bezt->ipo == BEZT_IPO_BEZ && (bezt->f1 & SELECT)) {
 immVertex2fv(pos, bezt->vec[0]);
   }
-  if ((bezt->f3 & SELECT)) {
+  if (bezt->ipo == BEZT_IPO_BEZ && (bezt->f3 & SELECT)) {
 immVertex2fv(pos, bezt->vec[2]);
   }
   immEnd();

___
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
https://lists.blender.org/mailman/listinfo/bf-blender-cvs


[Bf-blender-cvs] [477d983c2e8] master: Animation: Improve labels on Snap menu in graph editor

2020-10-19 Thread Sybren A. Stüvel
Commit: 477d983c2e8ab298cbf638d5aadd77fad9c2f677
Author: Sybren A. Stüvel
Date:   Mon Oct 19 14:01:51 2020 +0200
Branches: master
https://developer.blender.org/rB477d983c2e8ab298cbf638d5aadd77fad9c2f677

Animation: Improve labels on Snap menu in graph editor

Add "Selection to" as prefix for those menu items that move the selected
keyframes to something, for both the Key → Snap menu and the Shift+S pie
menu.

No functional changes.

===

M   release/scripts/startup/bl_ui/space_graph.py

===

diff --git a/release/scripts/startup/bl_ui/space_graph.py 
b/release/scripts/startup/bl_ui/space_graph.py
index 212a3d5ea2b..1bf7465e54c 100644
--- a/release/scripts/startup/bl_ui/space_graph.py
+++ b/release/scripts/startup/bl_ui/space_graph.py
@@ -324,11 +324,11 @@ class GRAPH_MT_key_snap(Menu):
 def draw(self, _context):
 layout = self.layout
 
-layout.operator("graph.snap", text="Current Frame").type = 'CFRA'
-layout.operator("graph.snap", text="Cursor Value").type = 'VALUE'
-layout.operator("graph.snap", text="Nearest Frame").type = 
'NEAREST_FRAME'
-layout.operator("graph.snap", text="Nearest Second").type = 
'NEAREST_SECOND'
-layout.operator("graph.snap", text="Nearest Marker").type = 
'NEAREST_MARKER'
+layout.operator("graph.snap", text="Selection to Current Frame").type 
= 'CFRA'
+layout.operator("graph.snap", text="Selection to Cursor Value").type = 
'VALUE'
+layout.operator("graph.snap", text="Selection to Nearest Frame").type 
= 'NEAREST_FRAME'
+layout.operator("graph.snap", text="Selection to Nearest Second").type 
= 'NEAREST_SECOND'
+layout.operator("graph.snap", text="Selection to Nearest Marker").type 
= 'NEAREST_MARKER'
 layout.operator("graph.snap", text="Flatten Handles").type = 
'HORIZONTAL'
 layout.separator()
 layout.operator("graph.frame_jump", text="Cursor to Selection")
@@ -399,11 +399,11 @@ class GRAPH_MT_snap_pie(Menu):
 layout = self.layout
 pie = layout.menu_pie()
 
-pie.operator("graph.snap", text="Current Frame").type = 'CFRA'
-pie.operator("graph.snap", text="Cursor Value").type = 'VALUE'
-pie.operator("graph.snap", text="Nearest Frame").type = 'NEAREST_FRAME'
-pie.operator("graph.snap", text="Nearest Second").type = 
'NEAREST_SECOND'
-pie.operator("graph.snap", text="Nearest Marker").type = 
'NEAREST_MARKER'
+pie.operator("graph.snap", text="Selection to Current Frame").type = 
'CFRA'
+pie.operator("graph.snap", text="Selection to Cursor Value").type = 
'VALUE'
+pie.operator("graph.snap", text="Selection to Nearest Frame").type = 
'NEAREST_FRAME'
+pie.operator("graph.snap", text="Selection to Nearest Second").type = 
'NEAREST_SECOND'
+pie.operator("graph.snap", text="Selection to Nearest Marker").type = 
'NEAREST_MARKER'
 pie.operator("graph.snap", text="Flatten Handles").type = 'HORIZONTAL'
 pie.operator("graph.frame_jump", text="Cursor to Selection")
 pie.operator("graph.snap_cursor_value", text="Cursor Value to 
Selection")

___
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
https://lists.blender.org/mailman/listinfo/bf-blender-cvs


[Bf-blender-cvs] [5ebdbcafcb2] master: Animation: Snap Cursor Value operator

2020-10-16 Thread Sybren A. Stüvel
Commit: 5ebdbcafcb2703f14f33738f1e852e5a3e1ab33a
Author: Sybren A. Stüvel
Date:   Fri Oct 16 16:44:06 2020 +0200
Branches: master
https://developer.blender.org/rB5ebdbcafcb2703f14f33738f1e852e5a3e1ab33a

Animation: Snap Cursor Value operator

Add operator to snap the 2D Cursor value to selected keyframes. This is
doing almost the same as the "Cursor to Selected" operator, except that
it doesn't affect the current frame, just the Y-coordinate (the value)
of the 2D cursor.

The "snap cursor" operators are added to the Key → Snap menu and to the
Snap pie menu. This means that these menus are now extended in meaning,
to not only mean "snap the selected keyframes to the cursor", but also
for some options "snap the cursor to selected keyframes".

This fixes T76596.

===

M   release/scripts/startup/bl_ui/space_graph.py
M   source/blender/editors/space_graph/graph_buttons.c
M   source/blender/editors/space_graph/graph_edit.c
M   source/blender/editors/space_graph/graph_intern.h
M   source/blender/editors/space_graph/graph_ops.c

===

diff --git a/release/scripts/startup/bl_ui/space_graph.py 
b/release/scripts/startup/bl_ui/space_graph.py
index 078b1c9ff38..212a3d5ea2b 100644
--- a/release/scripts/startup/bl_ui/space_graph.py
+++ b/release/scripts/startup/bl_ui/space_graph.py
@@ -262,8 +262,7 @@ class GRAPH_MT_key(Menu):
 layout = self.layout
 
 layout.menu("GRAPH_MT_key_transform", text="Transform")
-
-layout.operator_menu_enum("graph.snap", "type", text="Snap")
+layout.menu("GRAPH_MT_key_snap", text="Snap")
 layout.operator_menu_enum("graph.mirror", "type", text="Mirror")
 
 layout.separator()
@@ -319,6 +318,23 @@ class GRAPH_MT_key_transform(Menu):
 layout.operator("transform.resize", text="Scale")
 
 
+class GRAPH_MT_key_snap(Menu):
+bl_label = "Snap"
+
+def draw(self, _context):
+layout = self.layout
+
+layout.operator("graph.snap", text="Current Frame").type = 'CFRA'
+layout.operator("graph.snap", text="Cursor Value").type = 'VALUE'
+layout.operator("graph.snap", text="Nearest Frame").type = 
'NEAREST_FRAME'
+layout.operator("graph.snap", text="Nearest Second").type = 
'NEAREST_SECOND'
+layout.operator("graph.snap", text="Nearest Marker").type = 
'NEAREST_MARKER'
+layout.operator("graph.snap", text="Flatten Handles").type = 
'HORIZONTAL'
+layout.separator()
+layout.operator("graph.frame_jump", text="Cursor to Selection")
+layout.operator("graph.snap_cursor_value", text="Cursor Value to 
Selection")
+
+
 class GRAPH_MT_delete(Menu):
 bl_label = "Delete"
 
@@ -389,6 +405,8 @@ class GRAPH_MT_snap_pie(Menu):
 pie.operator("graph.snap", text="Nearest Second").type = 
'NEAREST_SECOND'
 pie.operator("graph.snap", text="Nearest Marker").type = 
'NEAREST_MARKER'
 pie.operator("graph.snap", text="Flatten Handles").type = 'HORIZONTAL'
+pie.operator("graph.frame_jump", text="Cursor to Selection")
+pie.operator("graph.snap_cursor_value", text="Cursor Value to 
Selection")
 
 
 class GRAPH_MT_channel_context_menu(Menu):
@@ -441,6 +459,7 @@ classes = (
 GRAPH_MT_channel,
 GRAPH_MT_key,
 GRAPH_MT_key_transform,
+GRAPH_MT_key_snap,
 GRAPH_MT_delete,
 GRAPH_MT_context_menu,
 GRAPH_MT_channel_context_menu,
diff --git a/source/blender/editors/space_graph/graph_buttons.c 
b/source/blender/editors/space_graph/graph_buttons.c
index be3e49fd810..a491ce29bd4 100644
--- a/source/blender/editors/space_graph/graph_buttons.c
+++ b/source/blender/editors/space_graph/graph_buttons.c
@@ -161,6 +161,7 @@ static void graph_panel_cursor(const bContext *C, Panel 
*panel)
 
   sub = uiLayoutColumn(col, true);
   uiItemO(sub, IFACE_("Cursor to Selection"), ICON_NONE, 
"GRAPH_OT_frame_jump");
+  uiItemO(sub, IFACE_("Cursor Value to Selection"), ICON_NONE, 
"GRAPH_OT_snap_cursor_value");
 }
 
 /* *** active F-Curve ** */
diff --git a/source/blender/editors/space_graph/graph_edit.c 
b/source/blender/editors/space_graph/graph_edit.c
index 3ec68971dea..c9b26674351 100644
--- a/source/blender/editors/space_graph/graph_edit.c
+++ b/source/blender/editors/space_graph/graph_edit.c
@@ -2838,6 +2838,46 @@ void GRAPH_OT_frame_jump(wmOperatorType *ot)
   ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
 }

[Bf-blender-cvs] [df4a93aca0a] master: Cleanup: Animation, split up frame jump operator

2020-10-16 Thread Sybren A. Stüvel
Commit: df4a93aca0a7c6f00370b1aad7439526434e30ce
Author: Sybren A. Stüvel
Date:   Fri Oct 16 16:07:50 2020 +0200
Branches: master
https://developer.blender.org/rBdf4a93aca0a7c6f00370b1aad7439526434e30ce

Cleanup: Animation, split up frame jump operator

Split up `GRAPH_OT_frame_jump` exec function and added some local variables
to give names to the cryptic `ked.f1`, `ked.f2`, and `ked.i1`.

No functional changes.

===

M   source/blender/editors/space_graph/graph_edit.c

===

diff --git a/source/blender/editors/space_graph/graph_edit.c 
b/source/blender/editors/space_graph/graph_edit.c
index 9fe6b4e06f6..3ec68971dea 100644
--- a/source/blender/editors/space_graph/graph_edit.c
+++ b/source/blender/editors/space_graph/graph_edit.c
@@ -2738,34 +2738,27 @@ static bool graphkeys_framejump_poll(bContext *C)
   return graphop_visible_keyframes_poll(C);
 }
 
-/* snap current-frame indicator to 'average time' of selected keyframe */
-static int graphkeys_framejump_exec(bContext *C, wmOperator *UNUSED(op))
+static KeyframeEditData sum_selected_keyframes(bAnimContext *ac)
 {
-  bAnimContext ac;
   ListBase anim_data = {NULL, NULL};
   bAnimListElem *ale;
   int filter;
   KeyframeEditData ked;
 
-  /* get editor data */
-  if (ANIM_animdata_get_context(C, ) == 0) {
-return OPERATOR_CANCELLED;
-  }
-
   /* init edit data */
   memset(, 0, sizeof(KeyframeEditData));
 
   /* loop over action data, averaging values */
   filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_CURVE_VISIBLE | 
ANIMFILTER_NODUPLIS);
-  ANIM_animdata_filter(, _data, filter, ac.data, ac.datatype);
+  ANIM_animdata_filter(ac, _data, filter, ac->data, ac->datatype);
 
   for (ale = anim_data.first; ale; ale = ale->next) {
-AnimData *adt = ANIM_nla_mapping_get(, ale);
-short mapping_flag = ANIM_get_normalization_flags();
+AnimData *adt = ANIM_nla_mapping_get(ac, ale);
+short mapping_flag = ANIM_get_normalization_flags(ac);
 KeyframeEditData current_ked;
 float offset;
 float unit_scale = ANIM_unit_mapping_get_factor(
-ac.scene, ale->id, ale->key_data, mapping_flag | 
ANIM_UNITCONV_ONLYKEYS, );
+ac->scene, ale->id, ale->key_data, mapping_flag | 
ANIM_UNITCONV_ONLYKEYS, );
 
 memset(_ked, 0, sizeof(current_ked));
 
@@ -2786,24 +2779,43 @@ static int graphkeys_framejump_exec(bContext *C, 
wmOperator *UNUSED(op))
 
   ANIM_animdata_freelist(_data);
 
+  return ked;
+}
+
+/* snap current-frame indicator to 'average time' of selected keyframe */
+static int graphkeys_framejump_exec(bContext *C, wmOperator *UNUSED(op))
+{
+  bAnimContext ac;
+
+  /* get editor data */
+  if (ANIM_animdata_get_context(C, ) == 0) {
+return OPERATOR_CANCELLED;
+  }
+
+  const KeyframeEditData keyframe_sum = sum_selected_keyframes();
+  const float sum_time = keyframe_sum.f1;
+  const float sum_value = keyframe_sum.f2;
+  const int num_keyframes = keyframe_sum.i1;
+
+  if (num_keyframes == 0) {
+return OPERATOR_FINISHED;
+  }
+
   /* set the new current frame and cursor values, based on the average time 
and value */
-  if (ked.i1) {
-SpaceGraph *sipo = (SpaceGraph *)ac.sl;
-Scene *scene = ac.scene;
+  SpaceGraph *sipo = (SpaceGraph *)ac.sl;
+  Scene *scene = ac.scene;
 
-/* take the average values, rounding to the nearest int as necessary for 
int results */
-if (sipo->mode == SIPO_MODE_DRIVERS) {
-  /* Drivers Mode - Affects cursor (float) */
-  sipo->cursorTime = ked.f1 / (float)ked.i1;
-  sipo->cursorVal = ked.f2 / (float)ked.i1;
-}
-else {
-  /* Animation Mode - Affects current frame (int) */
-  CFRA = round_fl_to_int(ked.f1 / ked.i1);
-  SUBFRA = 0.f;
-  sipo->cursorVal = ked.f2 / (float)ked.i1;
-}
+  /* take the average values, rounding to the nearest int as necessary for int 
results */
+  if (sipo->mode == SIPO_MODE_DRIVERS) {
+/* Drivers Mode - Affects cursor (float) */
+sipo->cursorTime = sum_time / (float)num_keyframes;
+  }
+  else {
+/* Animation Mode - Affects current frame (int) */
+CFRA = round_fl_to_int(sum_time / num_keyframes);
+SUBFRA = 0.f;
   }
+  sipo->cursorVal = sum_value / (float)num_keyframes;
 
   /* set notifier that things have changed */
   WM_event_add_notifier(C, NC_SCENE | ND_FRAME, ac.scene);

___
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
https://lists.blender.org/mailman/listinfo/bf-blender-cvs


[Bf-blender-cvs] [491d777efcf] master: Cleanup: remove debug printf()

2020-10-16 Thread Sybren A. Stüvel
Commit: 491d777efcfcb51a666253d9e994205b749ea5ff
Author: Sybren A. Stüvel
Date:   Fri Oct 16 10:59:43 2020 +0200
Branches: master
https://developer.blender.org/rB491d777efcfcb51a666253d9e994205b749ea5ff

Cleanup: remove debug printf()

No functional changes.

===

M   source/blender/editors/animation/anim_channels_edit.c

===

diff --git a/source/blender/editors/animation/anim_channels_edit.c 
b/source/blender/editors/animation/anim_channels_edit.c
index 5bed6175ebc..77ebc1606fa 100644
--- a/source/blender/editors/animation/anim_channels_edit.c
+++ b/source/blender/editors/animation/anim_channels_edit.c
@@ -393,7 +393,6 @@ static void anim_channels_select_set(bAnimContext *ac,
 
 ACHANNEL_SET_FLAG(fcu, sel, FCURVE_SELECTED);
 fcu->flag &= ~FCURVE_ACTIVE;
-printf("selecting and deactivating FCurve[%s; %d]\n", 
fcu->rna_path, fcu->array_index);
 break;
   }
   case ANIMTYPE_SHAPEKEY: {

___
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
https://lists.blender.org/mailman/listinfo/bf-blender-cvs


[Bf-blender-cvs] [c5bdbc340a2] master: Fix T62463: unable to select anim channel for unselected node

2020-10-16 Thread Sybren A. Stüvel
Commit: c5bdbc340a2113f15803115f6d3db72082a49473
Author: Sybren A. Stüvel
Date:   Fri Oct 16 10:15:24 2020 +0200
Branches: master
https://developer.blender.org/rBc5bdbc340a2113f15803115f6d3db72082a49473

Fix T62463: unable to select anim channel for unselected node

Remove the code that synchronises selection state of shader node animation
channels. This code is only used in a few cases where selection of these
animation channels is changed, and then potentially does the wrong thing
and disallows selection of animation channels altogether.

This removal is meant to be a temporary situation, to unblock animation
channel selection. See T74159 for the overall effort to improve selection
sync.

===

M   source/blender/editors/animation/anim_deps.c

===

diff --git a/source/blender/editors/animation/anim_deps.c 
b/source/blender/editors/animation/anim_deps.c
index 9e81880984b..b2225ec138f 100644
--- a/source/blender/editors/animation/anim_deps.c
+++ b/source/blender/editors/animation/anim_deps.c
@@ -233,57 +233,8 @@ static void animchan_sync_fcurve_scene(bAnimListElem *ale)
   }
 }
 
-static void animchan_sync_fcurve_nodetree(bAnimListElem *ale, FCurve 
**active_fcurve)
-{
-  ID *owner_id = ale->id;
-  BLI_assert(GS(owner_id->name) == ID_NT);
-  bNodeTree *ntree = (bNodeTree *)owner_id;
-  FCurve *fcu = (FCurve *)ale->data;
-
-  /* check for selected nodes */
-  if (!strstr(fcu->rna_path, "nodes")) {
-return;
-  }
-
-  /* get strip name, and check if this strip is selected */
-  char *node_name = BLI_str_quoted_substrN(fcu->rna_path, "nodes[");
-  bNode *node = nodeFindNodebyName(ntree, node_name);
-  if (node_name) {
-MEM_freeN(node_name);
-  }
-  if (node == NULL) {
-return;
-  }
-
-  /* update selection status */
-  if (node->flag & NODE_SELECT) {
-fcu->flag |= FCURVE_SELECTED;
-  }
-  else {
-fcu->flag &= ~FCURVE_SELECTED;
-  }
-
-  /* update active status */
-  /* XXX: this may interfere with setting bones as active if both exist at 
once;
-   * then again, if that's the case, production setups aren't likely to be 
animating
-   * nodes while working with bones?
-   */
-  if (node->flag & NODE_ACTIVE) {
-if (*active_fcurve == NULL) {
-  fcu->flag |= FCURVE_ACTIVE;
-  *active_fcurve = fcu;
-}
-else {
-  fcu->flag &= ~FCURVE_ACTIVE;
-}
-  }
-  else {
-fcu->flag &= ~FCURVE_ACTIVE;
-  }
-}
-
 /* perform syncing updates for F-Curves */
-static void animchan_sync_fcurve(bAnimListElem *ale, FCurve **active_fcurve)
+static void animchan_sync_fcurve(bAnimListElem *ale)
 {
   FCurve *fcu = (FCurve *)ale->data;
   ID *owner_id = ale->id;
@@ -299,9 +250,6 @@ static void animchan_sync_fcurve(bAnimListElem *ale, FCurve 
**active_fcurve)
 case ID_SCE:
   animchan_sync_fcurve_scene(ale);
   break;
-case ID_NT:
-  animchan_sync_fcurve_nodetree(ale, active_fcurve);
-  break;
 default:
   break;
   }
@@ -340,7 +288,6 @@ void ANIM_sync_animchannels_to_data(const bContext *C)
   int filter;
 
   bActionGroup *active_agrp = NULL;
-  FCurve *active_fcurve = NULL;
 
   /* get animation context info for filtering the channels */
   if (ANIM_animdata_get_context(C, ) == 0) {
@@ -364,7 +311,7 @@ void ANIM_sync_animchannels_to_data(const bContext *C)
 break;
 
   case ANIMTYPE_FCURVE:
-animchan_sync_fcurve(ale, _fcurve);
+animchan_sync_fcurve(ale);
 break;
 
   case ANIMTYPE_GPLAYER:

___
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
https://lists.blender.org/mailman/listinfo/bf-blender-cvs


[Bf-blender-cvs] [5722de6098a] master: Cleanup: Animation, remove unused parameters

2020-10-16 Thread Sybren A. Stüvel
Commit: 5722de6098ab99a03c2a8469bef3efbec8232e00
Author: Sybren A. Stüvel
Date:   Fri Oct 16 10:17:06 2020 +0200
Branches: master
https://developer.blender.org/rB5722de6098ab99a03c2a8469bef3efbec8232e00

Cleanup: Animation, remove unused parameters

No functional changes.

===

M   source/blender/editors/animation/anim_deps.c

===

diff --git a/source/blender/editors/animation/anim_deps.c 
b/source/blender/editors/animation/anim_deps.c
index a9ab89c693d..9e81880984b 100644
--- a/source/blender/editors/animation/anim_deps.c
+++ b/source/blender/editors/animation/anim_deps.c
@@ -283,9 +283,7 @@ static void animchan_sync_fcurve_nodetree(bAnimListElem 
*ale, FCurve **active_fc
 }
 
 /* perform syncing updates for F-Curves */
-static void animchan_sync_fcurve(bAnimContext *UNUSED(ac),
- bAnimListElem *ale,
- FCurve **active_fcurve)
+static void animchan_sync_fcurve(bAnimListElem *ale, FCurve **active_fcurve)
 {
   FCurve *fcu = (FCurve *)ale->data;
   ID *owner_id = ale->id;
@@ -310,7 +308,7 @@ static void animchan_sync_fcurve(bAnimContext *UNUSED(ac),
 }
 
 /* perform syncing updates for GPencil Layers */
-static void animchan_sync_gplayer(bAnimContext *UNUSED(ac), bAnimListElem *ale)
+static void animchan_sync_gplayer(bAnimListElem *ale)
 {
   bGPDlayer *gpl = (bGPDlayer *)ale->data;
 
@@ -366,11 +364,11 @@ void ANIM_sync_animchannels_to_data(const bContext *C)
 break;
 
   case ANIMTYPE_FCURVE:
-animchan_sync_fcurve(, ale, _fcurve);
+animchan_sync_fcurve(ale, _fcurve);
 break;
 
   case ANIMTYPE_GPLAYER:
-animchan_sync_gplayer(, ale);
+animchan_sync_gplayer(ale);
 break;
 }
   }

___
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
https://lists.blender.org/mailman/listinfo/bf-blender-cvs


[Bf-blender-cvs] [91af828e8bf] master: Fix T81743: Changed behaviour in RGB Curves node interpolation

2020-10-15 Thread Sybren A. Stüvel
Commit: 91af828e8bfaa04cbd49f1859e06a1f76749102d
Author: Sybren A. Stüvel
Date:   Thu Oct 15 19:38:20 2020 +0200
Branches: master
https://developer.blender.org/rB91af828e8bfaa04cbd49f1859e06a1f76749102d

Fix T81743: Changed behaviour in RGB Curves node interpolation

Restore the old `correct_bezpart()` (pre-rBda95d1d851b4) function as
`BKE_curve_correct_bezpart()`, and use that where the old behaviour was
desired (that is, curve maps like used by the RGB Curves shader node).

The new (post-rBda95d1d851b4) function is also renamed to
`BKE_fcurve_correct_bezpart()` to avoid confusion.

===

M   source/blender/blenkernel/BKE_curve.h
M   source/blender/blenkernel/BKE_fcurve.h
M   source/blender/blenkernel/intern/colortools.c
M   source/blender/blenkernel/intern/curve.c
M   source/blender/blenkernel/intern/fcurve.c
M   source/blender/editors/animation/anim_draw.c
M   source/blender/editors/space_graph/graph_draw.c

===

diff --git a/source/blender/blenkernel/BKE_curve.h 
b/source/blender/blenkernel/BKE_curve.h
index d9138db2769..dcb4a993da1 100644
--- a/source/blender/blenkernel/BKE_curve.h
+++ b/source/blender/blenkernel/BKE_curve.h
@@ -158,6 +158,8 @@ void BKE_curve_rect_from_textbox(const struct Curve *cu,
  const struct TextBox *tb,
  struct rctf *r_rect);
 
+void BKE_curve_correct_bezpart(const float v1[2], float v2[2], float v3[2], 
const float v4[2]);
+
 /* ** Nurbs ** */
 
 bool BKE_nurbList_index_get_co(struct ListBase *editnurb, const int index, 
float r_co[3]);
diff --git a/source/blender/blenkernel/BKE_fcurve.h 
b/source/blender/blenkernel/BKE_fcurve.h
index e0c0f91b34b..c9bc5e83a1f 100644
--- a/source/blender/blenkernel/BKE_fcurve.h
+++ b/source/blender/blenkernel/BKE_fcurve.h
@@ -285,7 +285,7 @@ void testhandles_fcurve(struct FCurve *fcu, eBezTriple_Flag 
sel_flag, const bool
 void sort_time_fcurve(struct FCurve *fcu);
 bool test_time_fcurve(struct FCurve *fcu);
 
-void correct_bezpart(const float v1[2], float v2[2], float v3[2], const float 
v4[2]);
+void BKE_fcurve_correct_bezpart(const float v1[2], float v2[2], float v3[2], 
const float v4[2]);
 
 /*  Evaluation   */
 
diff --git a/source/blender/blenkernel/intern/colortools.c 
b/source/blender/blenkernel/intern/colortools.c
index 77a29bf41b8..34e8e8bc6fb 100644
--- a/source/blender/blenkernel/intern/colortools.c
+++ b/source/blender/blenkernel/intern/colortools.c
@@ -715,7 +715,8 @@ static void curvemap_make_table(const CurveMapping *cumap, 
CurveMap *cuma)
   float *point = allpoints;
 
   for (int a = 0; a < cuma->totpoint - 1; a++, point += 2 * CM_RESOL) {
-correct_bezpart(bezt[a].vec[1], bezt[a].vec[2], bezt[a + 1].vec[0], bezt[a 
+ 1].vec[1]);
+BKE_curve_correct_bezpart(
+bezt[a].vec[1], bezt[a].vec[2], bezt[a + 1].vec[0], bezt[a + 
1].vec[1]);
 BKE_curve_forward_diff_bezier(bezt[a].vec[1][0],
   bezt[a].vec[2][0],
   bezt[a + 1].vec[0][0],
diff --git a/source/blender/blenkernel/intern/curve.c 
b/source/blender/blenkernel/intern/curve.c
index c0da1f41c88..01636c7eb2b 100644
--- a/source/blender/blenkernel/intern/curve.c
+++ b/source/blender/blenkernel/intern/curve.c
@@ -5566,6 +5566,47 @@ void BKE_curve_rect_from_textbox(const struct Curve *cu,
   r_rect->ymin = r_rect->ymax - tb->h;
 }
 
+/* This function is almost the same as BKE_fcurve_correct_bezpart(), but 
doesn't allow as large a
+ * tangent. */
+void BKE_curve_correct_bezpart(const float v1[2], float v2[2], float v3[2], 
const float v4[2])
+{
+  float h1[2], h2[2], len1, len2, len, fac;
+
+  /* Calculate handle deltas. */
+  h1[0] = v1[0] - v2[0];
+  h1[1] = v1[1] - v2[1];
+
+  h2[0] = v4[0] - v3[0];
+  h2[1] = v4[1] - v3[1];
+
+  /* Calculate distances:
+   * - len  = span of time between keyframes
+   * - len1 = length of handle of start key
+   * - len2 = length of handle of end key
+   */
+  len = v4[0] - v1[0];
+  len1 = fabsf(h1[0]);
+  len2 = fabsf(h2[0]);
+
+  /* If the handles have no length, no need to do any corrections. */
+  if ((len1 + len2) == 0.0f) {
+return;
+  }
+
+  /* the two handles cross over each other, so force them
+   * apart using the proportion they overlap
+   */
+  if ((len1 + len2) > len) {
+fac = len / (len1 + len2);
+
+v2[0] = (v1[0] - fac * h1[0]);
+v2[1] = (v1[1] - fac * h1[1]);
+
+v3[0] = (v4[0] - fac * h2[0]);
+v3[1] = (v4[1] - fac * h2[1]);
+  }
+}
+
 /*  Depsgraph evaluation  */
 
 void BKE_curve_eval_geometry(Depsgraph *depsgraph, Curve *curve)
diff --git a/source/blender/blenkernel/intern/fcurve.c 
b/source/blender/blenkernel/intern/fcurve.c
index 18e6479ea07..2287170c29d 100644
--- a/source/blender/blenkernel/intern/fcurve.c
+++ b/source/blender/blenkernel/intern/fcurve.c
@

[Bf-blender-cvs] [78d1aa4d521] master: Cleanup: Animation, simplify channel selection code

2020-10-15 Thread Sybren A. Stüvel
Commit: 78d1aa4d521cff25b07af2f6f8790d51b8b26064
Author: Sybren A. Stüvel
Date:   Tue Oct 13 14:43:19 2020 +0200
Branches: master
https://developer.blender.org/rB78d1aa4d521cff25b07af2f6f8790d51b8b26064

Cleanup: Animation, simplify channel selection code

Split up `ANIM_deselect_anim_channels()` into
`ANIM_anim_channels_select_set()` and
`ANIM_anim_channels_select_toggle()`.

`ANIM_anim_channels_select_set()` is equivalent to the old
`ANIM_deselect_anim_channels(..., false, ACHANNEL_SETFLAG_xxx)`.

`ANIM_anim_channels_select_toggle()` is equivalent to the old
`ANIM_deselect_anim_channels(..., true, ACHANNEL_SETFLAG_ADD)`.

`ANIM_deselect_anim_channels(..., true, ACHANNEL_SETFLAG_CLEAR)` was
also called once. The `true` parameter suggested the "toggle" behaviour
was intended, but the `ACHANNEL_SETFLAG_CLEAR` argument prevented any
toggling. This is now replaced with `ANIM_anim_channels_select_set(ac,
ACHANNEL_SETFLAG_CLEAR)` to make this explicit.

No functional changes, just a cleanup in order to better understand how
the selection works.

===

M   source/blender/editors/animation/anim_channels_edit.c
M   source/blender/editors/include/ED_anim_api.h
M   source/blender/editors/screen/screen_ops.c
M   source/blender/editors/space_action/action_select.c
M   source/blender/editors/space_graph/graph_select.c
M   source/blender/editors/space_nla/nla_channels.c
M   source/blender/editors/space_nla/nla_select.c

===

diff --git a/source/blender/editors/animation/anim_channels_edit.c 
b/source/blender/editors/animation/anim_channels_edit.c
index 8a13872ca61..5bed6175ebc 100644
--- a/source/blender/editors/animation/anim_channels_edit.c
+++ b/source/blender/editors/animation/anim_channels_edit.c
@@ -253,109 +253,107 @@ static void select_pchan_for_action_group(bAnimContext 
*ac, bActionGroup *agrp,
   }
 }
 
-/* Deselect all animation channels
- * - data: pointer to datatype, as contained in bAnimContext
- * - datatype: the type of data that 'data' represents (eAnimCont_Types)
- * - test: check if deselecting instead of selecting
- * - sel: eAnimChannels_SetFlag;
- */
-void ANIM_deselect_anim_channels(
-bAnimContext *ac, void *data, eAnimCont_Types datatype, bool test, 
eAnimChannels_SetFlag sel)
+static ListBase /* bAnimListElem */ anim_channels_for_selection(bAnimContext 
*ac)
 {
   ListBase anim_data = {NULL, NULL};
-  bAnimListElem *ale;
-  int filter;
 
   /* filter data */
   /* NOTE: no list visible, otherwise, we get dangling */
-  filter = ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_CHANNELS;
-  ANIM_animdata_filter(ac, _data, filter, data, datatype);
+  const int filter = ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_CHANNELS;
+  ANIM_animdata_filter(ac, _data, filter, ac->data, ac->datatype);
 
-  /* See if we should be selecting or deselecting */
-  if (test) {
-for (ale = anim_data.first; ale; ale = ale->next) {
-  if (sel == 0) {
-break;
-  }
+  return anim_data;
+}
 
-  switch (ale->type) {
-case ANIMTYPE_SCENE:
-  if (ale->flag & SCE_DS_SELECTED) {
-sel = ACHANNEL_SETFLAG_CLEAR;
-  }
-  break;
-case ANIMTYPE_OBJECT:
+static eAnimChannels_SetFlag anim_channels_selection_flag_for_toggle(const 
ListBase anim_data)
+{
+  /* See if we should be selecting or deselecting. */
+  for (bAnimListElem *ale = anim_data.first; ale; ale = ale->next) {
+switch (ale->type) {
+  case ANIMTYPE_SCENE:
+if (ale->flag & SCE_DS_SELECTED) {
+  return ACHANNEL_SETFLAG_CLEAR;
+}
+break;
+  case ANIMTYPE_OBJECT:
 #if 0 /* for now, do not take object selection into account, since it gets too 
annoying */
   if (ale->flag & SELECT) {
-sel = ACHANNEL_SETFLAG_CLEAR;
+return ACHANNEL_SETFLAG_CLEAR;
   }
 #endif
-  break;
-case ANIMTYPE_GROUP:
-  if (ale->flag & AGRP_SELECTED) {
-sel = ACHANNEL_SETFLAG_CLEAR;
-  }
-  break;
-case ANIMTYPE_FCURVE:
-case ANIMTYPE_NLACURVE:
-  if (ale->flag & FCURVE_SELECTED) {
-sel = ACHANNEL_SETFLAG_CLEAR;
-  }
-  break;
-case ANIMTYPE_SHAPEKEY:
-  if (ale->flag & KEYBLOCK_SEL) {
-sel = ACHANNEL_SETFLAG_CLEAR;
-  }
-  break;
-case ANIMTYPE_NLATRACK:
-  if (ale->flag & NLATRACK_SELECTED) {
-sel = ACHANNEL_SETFLAG_CLEAR;
-  }
-  break;
+break;
+  case ANIMTYPE_GROUP:
+if (ale->flag & AGRP_SELECTED) {
+  return ACHANNEL_SETFLAG_CLEAR;
+}
+break;
+  case ANIMTYPE_FCURVE:
+  case ANIMTYPE_NLACURVE:
+if (ale->flag & FCURVE_SELECTED) {
+  return ACHANNE

[Bf-blender-cvs] [1ec1e36ac1d] master: Cleanup: Animation, rename function to match operator

2020-10-15 Thread Sybren A. Stüvel
Commit: 1ec1e36ac1d87c0404509204a332da797e8fc831
Author: Sybren A. Stüvel
Date:   Tue Oct 13 12:45:08 2020 +0200
Branches: master
https://developer.blender.org/rB1ec1e36ac1d87c0404509204a332da797e8fc831

Cleanup: Animation, rename function to match operator

Rename `animchannels_deselectall_exec` → `animchannels_selectall_exec` so
that it matches the operator `ANIM_OT_channels_select_all`.

No functional changes.

===

M   source/blender/editors/animation/anim_channels_edit.c

===

diff --git a/source/blender/editors/animation/anim_channels_edit.c 
b/source/blender/editors/animation/anim_channels_edit.c
index 92b37628263..8a13872ca61 100644
--- a/source/blender/editors/animation/anim_channels_edit.c
+++ b/source/blender/editors/animation/anim_channels_edit.c
@@ -2526,7 +2526,7 @@ static void ANIM_OT_channels_find(wmOperatorType *ot)
 
 /* ** Select All Operator *** */
 
-static int animchannels_deselectall_exec(bContext *C, wmOperator *op)
+static int animchannels_selectall_exec(bContext *C, wmOperator *op)
 {
   bAnimContext ac;
 
@@ -2569,7 +2569,7 @@ static void ANIM_OT_channels_select_all(wmOperatorType 
*ot)
   ot->description = "Toggle selection of all animation channels";
 
   /* api callbacks */
-  ot->exec = animchannels_deselectall_exec;
+  ot->exec = animchannels_selectall_exec;
   ot->poll = animedit_poll_channels_nla_tweakmode_off;
 
   /* flags */

___
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
https://lists.blender.org/mailman/listinfo/bf-blender-cvs


[Bf-blender-cvs] [9db111b5fd3] arcpatch-D9019: Cleanup: Animation, rename function to match operator

2020-10-13 Thread Sybren A. Stüvel
Commit: 9db111b5fd3fb50e8d59becd65d529fb4bd46322
Author: Sybren A. Stüvel
Date:   Tue Oct 13 12:45:08 2020 +0200
Branches: arcpatch-D9019
https://developer.blender.org/rB9db111b5fd3fb50e8d59becd65d529fb4bd46322

Cleanup: Animation, rename function to match operator

Rename `animchannels_deselectall_exec` → `animchannels_selectall_exec` so
that it matches the operator `ANIM_OT_channels_select_all`.

No functional changes.

===

M   source/blender/editors/animation/anim_channels_edit.c

===

diff --git a/source/blender/editors/animation/anim_channels_edit.c 
b/source/blender/editors/animation/anim_channels_edit.c
index 92b37628263..8a13872ca61 100644
--- a/source/blender/editors/animation/anim_channels_edit.c
+++ b/source/blender/editors/animation/anim_channels_edit.c
@@ -2526,7 +2526,7 @@ static void ANIM_OT_channels_find(wmOperatorType *ot)
 
 /* ** Select All Operator *** */
 
-static int animchannels_deselectall_exec(bContext *C, wmOperator *op)
+static int animchannels_selectall_exec(bContext *C, wmOperator *op)
 {
   bAnimContext ac;
 
@@ -2569,7 +2569,7 @@ static void ANIM_OT_channels_select_all(wmOperatorType 
*ot)
   ot->description = "Toggle selection of all animation channels";
 
   /* api callbacks */
-  ot->exec = animchannels_deselectall_exec;
+  ot->exec = animchannels_selectall_exec;
   ot->poll = animedit_poll_channels_nla_tweakmode_off;
 
   /* flags */

___
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
https://lists.blender.org/mailman/listinfo/bf-blender-cvs


[Bf-blender-cvs] [6f0b0823781] master: Animation: fix assertion failure on unsetting active keyframe

2020-10-12 Thread Sybren A. Stüvel
Commit: 6f0b082378133afd944cc6af2e992c5f9fb12cd3
Author: Sybren A. Stüvel
Date:   Mon Oct 12 17:27:27 2020 +0200
Branches: master
https://developer.blender.org/rB6f0b082378133afd944cc6af2e992c5f9fb12cd3

Animation: fix assertion failure on unsetting active keyframe

Avoid NULL pointer dereference when checking keyframe selection state in
`BLI_assert()` call.

===

M   source/blender/blenkernel/intern/fcurve.c

===

diff --git a/source/blender/blenkernel/intern/fcurve.c 
b/source/blender/blenkernel/intern/fcurve.c
index d57ef45107c..2f8a8fcffdc 100644
--- a/source/blender/blenkernel/intern/fcurve.c
+++ b/source/blender/blenkernel/intern/fcurve.c
@@ -840,7 +840,7 @@ bool BKE_fcurve_calc_range(
 void BKE_fcurve_active_keyframe_set(FCurve *fcu, const BezTriple *active_bezt)
 {
   /* The active keyframe should always be selected. */
-  BLI_assert(active_bezt->f2 & SELECT);
+  BLI_assert(active_bezt == NULL || (active_bezt->f2 & SELECT));
   fcu->active_keyframe_index = (active_bezt == NULL) ? 
FCURVE_ACTIVE_KEYFRAME_NONE :
active_bezt - fcu->bezt;
 }

___
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
https://lists.blender.org/mailman/listinfo/bf-blender-cvs


[Bf-blender-cvs] [5e6c7de3e91] master: Animation: enforce that the active keyframe is always selected

2020-10-12 Thread Sybren A. Stüvel
Commit: 5e6c7de3e918f7ecbf4ea898f6e5b8a2373ad17e
Author: Sybren A. Stüvel
Date:   Mon Oct 12 16:55:46 2020 +0200
Branches: master
https://developer.blender.org/rB5e6c7de3e918f7ecbf4ea898f6e5b8a2373ad17e

Animation: enforce that the active keyframe is always selected

Check selection state in `BKE_fcurve_active_keyframe_index()`, and only
return the active keyframe index when that keyframe is actually selected.
This is now also asserted in the `BKE_fcurve_active_keyframe_set()` function,
which is now also used when inserting a keyframe.

===

M   source/blender/blenkernel/intern/fcurve.c
M   source/blender/editors/animation/keyframing.c
M   source/blender/makesdna/DNA_anim_types.h

===

diff --git a/source/blender/blenkernel/intern/fcurve.c 
b/source/blender/blenkernel/intern/fcurve.c
index d2a9064a373..d57ef45107c 100644
--- a/source/blender/blenkernel/intern/fcurve.c
+++ b/source/blender/blenkernel/intern/fcurve.c
@@ -839,6 +839,8 @@ bool BKE_fcurve_calc_range(
  */
 void BKE_fcurve_active_keyframe_set(FCurve *fcu, const BezTriple *active_bezt)
 {
+  /* The active keyframe should always be selected. */
+  BLI_assert(active_bezt->f2 & SELECT);
   fcu->active_keyframe_index = (active_bezt == NULL) ? 
FCURVE_ACTIVE_KEYFRAME_NONE :
active_bezt - fcu->bezt;
 }
@@ -850,12 +852,18 @@ int BKE_fcurve_active_keyframe_index(const FCurve *fcu)
 {
   const int active_keyframe_index = fcu->active_keyframe_index;
 
-  /* Sanity checks. */
+  /* Array access boundary checks. */
   if ((fcu->bezt == NULL) || (active_keyframe_index >= fcu->totvert) ||
   (active_keyframe_index < 0)) {
 return FCURVE_ACTIVE_KEYFRAME_NONE;
   }
 
+  const BezTriple *active_bezt = >bezt[active_keyframe_index];
+  if ((active_bezt->f2 & SELECT) == 0) {
+/* The active keyframe should always be selected. If it's not selected, it 
can't be active. */
+return FCURVE_ACTIVE_KEYFRAME_NONE;
+  }
+
   return active_keyframe_index;
 }
 
diff --git a/source/blender/editors/animation/keyframing.c 
b/source/blender/editors/animation/keyframing.c
index c2a772604f2..967ca13c17d 100644
--- a/source/blender/editors/animation/keyframing.c
+++ b/source/blender/editors/animation/keyframing.c
@@ -605,8 +605,7 @@ int insert_vert_fcurve(
 
   /* add temp beztriple to keyframes */
   a = insert_bezt_fcurve(fcu, , flag);
-
-  fcu->active_keyframe_index = a;
+  BKE_fcurve_active_keyframe_set(fcu, >bezt[a]);
 
   /* what if 'a' is a negative index?
* for now, just exit to prevent any segfaults
diff --git a/source/blender/makesdna/DNA_anim_types.h 
b/source/blender/makesdna/DNA_anim_types.h
index f17d8b84790..1a74166da31 100644
--- a/source/blender/makesdna/DNA_anim_types.h
+++ b/source/blender/makesdna/DNA_anim_types.h
@@ -593,6 +593,9 @@ typedef struct FCurve {
   /**
* Index of active keyframe in #bezt for numerical editing in the interface. 
A value of
* #FCURVE_ACTIVE_KEYFRAME_NONE indicates that the FCurve has no active 
keyframe.
+   *
+   * Do not access directly, use #BKE_fcurve_active_keyframe_index() and
+   * #BKE_fcurve_active_keyframe_set() instead.
*/
   int active_keyframe_index;

___
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
https://lists.blender.org/mailman/listinfo/bf-blender-cvs


[Bf-blender-cvs] [058a69974ab] master: Cleanup: split `animchan_sync_fcurve()` into smaller functions

2020-10-12 Thread Sybren A. Stüvel
Commit: 058a69974abd602a788ebd972edca171ee8e100b
Author: Sybren A. Stüvel
Date:   Mon Oct 12 16:56:49 2020 +0200
Branches: master
https://developer.blender.org/rB058a69974abd602a788ebd972edca171ee8e100b

Cleanup: split `animchan_sync_fcurve()` into smaller functions

Split `animchan_sync_fcurve()` into functions for handling Scenes and
Node Trees.

No functional changes.

===

M   source/blender/editors/animation/anim_deps.c

===

diff --git a/source/blender/editors/animation/anim_deps.c 
b/source/blender/editors/animation/anim_deps.c
index 831de3e7bc4..a9ab89c693d 100644
--- a/source/blender/editors/animation/anim_deps.c
+++ b/source/blender/editors/animation/anim_deps.c
@@ -199,6 +199,89 @@ static void animchan_sync_group(bAnimContext *ac, 
bAnimListElem *ale, bActionGro
   }
 }
 
+static void animchan_sync_fcurve_scene(bAnimListElem *ale)
+{
+  ID *owner_id = ale->id;
+  BLI_assert(GS(owner_id->name) == ID_SCE);
+  Scene *scene = (Scene *)owner_id;
+  FCurve *fcu = (FCurve *)ale->data;
+
+  /* only affect if F-Curve involves sequence_editor.sequences */
+  if (!strstr(fcu->rna_path, "sequences_all")) {
+return;
+  }
+
+  Editing *ed = BKE_sequencer_editing_get(scene, false);
+
+  /* get strip name, and check if this strip is selected */
+  char *seq_name = BLI_str_quoted_substrN(fcu->rna_path, "sequences_all[");
+  Sequence *seq = BKE_sequence_get_by_name(ed->seqbasep, seq_name, false);
+  if (seq_name) {
+MEM_freeN(seq_name);
+  }
+
+  if (seq == NULL) {
+return;
+  }
+
+  /* update selection status */
+  if (seq->flag & SELECT) {
+fcu->flag |= FCURVE_SELECTED;
+  }
+  else {
+fcu->flag &= ~FCURVE_SELECTED;
+  }
+}
+
+static void animchan_sync_fcurve_nodetree(bAnimListElem *ale, FCurve 
**active_fcurve)
+{
+  ID *owner_id = ale->id;
+  BLI_assert(GS(owner_id->name) == ID_NT);
+  bNodeTree *ntree = (bNodeTree *)owner_id;
+  FCurve *fcu = (FCurve *)ale->data;
+
+  /* check for selected nodes */
+  if (!strstr(fcu->rna_path, "nodes")) {
+return;
+  }
+
+  /* get strip name, and check if this strip is selected */
+  char *node_name = BLI_str_quoted_substrN(fcu->rna_path, "nodes[");
+  bNode *node = nodeFindNodebyName(ntree, node_name);
+  if (node_name) {
+MEM_freeN(node_name);
+  }
+  if (node == NULL) {
+return;
+  }
+
+  /* update selection status */
+  if (node->flag & NODE_SELECT) {
+fcu->flag |= FCURVE_SELECTED;
+  }
+  else {
+fcu->flag &= ~FCURVE_SELECTED;
+  }
+
+  /* update active status */
+  /* XXX: this may interfere with setting bones as active if both exist at 
once;
+   * then again, if that's the case, production setups aren't likely to be 
animating
+   * nodes while working with bones?
+   */
+  if (node->flag & NODE_ACTIVE) {
+if (*active_fcurve == NULL) {
+  fcu->flag |= FCURVE_ACTIVE;
+  *active_fcurve = fcu;
+}
+else {
+  fcu->flag &= ~FCURVE_ACTIVE;
+}
+  }
+  else {
+fcu->flag &= ~FCURVE_ACTIVE;
+  }
+}
+
 /* perform syncing updates for F-Curves */
 static void animchan_sync_fcurve(bAnimContext *UNUSED(ac),
  bAnimListElem *ale,
@@ -214,77 +297,15 @@ static void animchan_sync_fcurve(bAnimContext *UNUSED(ac),
 return;
   }
 
-  if (GS(owner_id->name) == ID_SCE) {
-Scene *scene = (Scene *)owner_id;
-
-/* only affect if F-Curve involves sequence_editor.sequences */
-if ((fcu->rna_path) && strstr(fcu->rna_path, "sequences_all")) {
-  Editing *ed = BKE_sequencer_editing_get(scene, false);
-  Sequence *seq;
-  char *seq_name;
-
-  /* get strip name, and check if this strip is selected */
-  seq_name = BLI_str_quoted_substrN(fcu->rna_path, "sequences_all[");
-  seq = BKE_sequence_get_by_name(ed->seqbasep, seq_name, false);
-  if (seq_name) {
-MEM_freeN(seq_name);
-  }
-
-  /* update selection status */
-  if (seq) {
-if (seq->flag & SELECT) {
-  fcu->flag |= FCURVE_SELECTED;
-}
-else {
-  fcu->flag &= ~FCURVE_SELECTED;
-}
-  }
-}
-  }
-  else if (GS(owner_id->name) == ID_NT) {
-bNodeTree *ntree = (bNodeTree *)owner_id;
-
-/* check for selected nodes */
-if ((fcu->rna_path) && strstr(fcu->rna_path, "nodes")) {
-  bNode *node;
-  char *node_name;
-
-  /* get strip name, and check if this strip is selected */
-  node_name = BLI_str_quoted_substrN(fcu->rna_path, "nodes[");
-  node = nodeFindNodebyName(ntree, node_name);
-  if (node_name) {
-MEM_freeN(node_name);
-  }
-
-  /* update selection/active status */
-  if (node) {
-/* update selection stat

[Bf-blender-cvs] [e3ad392b984] master: Animation: always try to match the existing curve when inserting keys

2020-10-12 Thread Sybren A. Stüvel
Commit: e3ad392b9849a56ad05e1711e06be0d77843aafb
Author: Sybren A. Stüvel
Date:   Wed Oct 7 16:40:51 2020 +0200
Branches: master
https://developer.blender.org/rBe3ad392b9849a56ad05e1711e06be0d77843aafb

Animation: always try to match the existing curve when inserting keys

Previously Blender would only match the existing curve slope when the
to-be-inserted key value was already very close to the curve. This check
is now removed, allowing for sliders in the graph editor to subtly
change the curve, and for keyframes added with ctrl+click to follow the
curve better.

===

M   source/blender/editors/animation/keyframing.c

===

diff --git a/source/blender/editors/animation/keyframing.c 
b/source/blender/editors/animation/keyframing.c
index 431ec9e0526..c2a772604f2 100644
--- a/source/blender/editors/animation/keyframing.c
+++ b/source/blender/editors/animation/keyframing.c
@@ -516,7 +516,7 @@ static void subdivide_nonauto_handles(const FCurve *fcu,
   }
 
   /* Decide when to force auto to manual. */
-  if (!BEZT_IS_AUTOH(bezt) || fabsf(delta) >= 0.001f) {
+  if (!BEZT_IS_AUTOH(bezt)) {
 return;
   }
   if ((prev_auto || next_auto) && fcu->auto_smoothing == 
FCURVE_SMOOTH_CONT_ACCEL) {

___
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
https://lists.blender.org/mailman/listinfo/bf-blender-cvs


[Bf-blender-cvs] [1db26e1698f] master: Cleanup: Animation, small cleanups on anim channel selection code

2020-10-12 Thread Sybren A. Stüvel
Commit: 1db26e1698f68a57e3707b11852ed4160e455f9b
Author: Sybren A. Stüvel
Date:   Thu Oct 8 15:01:44 2020 +0200
Branches: master
https://developer.blender.org/rB1db26e1698f68a57e3707b11852ed4160e455f9b

Cleanup: Animation, small cleanups on anim channel selection code

Clean up some code by using early returns.

No functional changes.

===

M   source/blender/editors/animation/anim_channels_edit.c

===

diff --git a/source/blender/editors/animation/anim_channels_edit.c 
b/source/blender/editors/animation/anim_channels_edit.c
index 0b7ec0d377c..ae27d0e426d 100644
--- a/source/blender/editors/animation/anim_channels_edit.c
+++ b/source/blender/editors/animation/anim_channels_edit.c
@@ -2881,74 +2881,77 @@ static int click_select_channel_object(bContext *C,
   Object *ob = base->object;
   AnimData *adt = ob->adt;
 
-  /* set selection status */
-  if (base->flag & BASE_SELECTABLE) {
-if (selectmode == SELECT_INVERT) {
-  /* swap select */
-  ED_object_base_select(base, BA_INVERT);
+  if ((base->flag & BASE_SELECTABLE) == 0) {
+return 0;
+  }
 
-  if (adt) {
-adt->flag ^= ADT_UI_SELECTED;
-  }
+  if (selectmode == SELECT_INVERT) {
+/* swap select */
+ED_object_base_select(base, BA_INVERT);
+
+if (adt) {
+  adt->flag ^= ADT_UI_SELECTED;
 }
-else {
-  Base *b;
-
-  /* deselect all */
-  /* TODO: should this deselect all other types of channels too? */
-  for (b = view_layer->object_bases.first; b; b = b->next) {
-ED_object_base_select(b, BA_DESELECT);
-if (b->object->adt) {
-  b->object->adt->flag &= ~(ADT_UI_SELECTED | ADT_UI_ACTIVE);
-}
+  }
+  else {
+Base *b;
+
+/* deselect all */
+/* TODO: should this deselect all other types of channels too? */
+for (b = view_layer->object_bases.first; b; b = b->next) {
+  ED_object_base_select(b, BA_DESELECT);
+  if (b->object->adt) {
+b->object->adt->flag &= ~(ADT_UI_SELECTED | ADT_UI_ACTIVE);
   }
+}
 
-  /* select object now */
-  ED_object_base_select(base, BA_SELECT);
-  if (adt) {
-adt->flag |= ADT_UI_SELECTED;
-  }
+/* select object now */
+ED_object_base_select(base, BA_SELECT);
+if (adt) {
+  adt->flag |= ADT_UI_SELECTED;
 }
+  }
 
-/* change active object - regardless of whether it is now selected 
[T37883] */
-ED_object_base_activate(C, base); /* adds notifier */
+  /* change active object - regardless of whether it is now selected [T37883] 
*/
+  ED_object_base_activate(C, base); /* adds notifier */
 
-if ((adt) && (adt->flag & ADT_UI_SELECTED)) {
-  adt->flag |= ADT_UI_ACTIVE;
-}
+  if ((adt) && (adt->flag & ADT_UI_SELECTED)) {
+adt->flag |= ADT_UI_ACTIVE;
+  }
 
-/* Ensure we exit editmode on whatever object was active before
- * to avoid getting stuck there - T48747. */
-if (ob != CTX_data_edit_object(C)) {
-  ED_object_editmode_exit(C, EM_FREEDATA);
-}
-return (ND_ANIMCHAN | NA_SELECTED);
+  /* Ensure we exit editmode on whatever object was active before
+   * to avoid getting stuck there - T48747. */
+  if (ob != CTX_data_edit_object(C)) {
+ED_object_editmode_exit(C, EM_FREEDATA);
   }
-  return 0;
+  return (ND_ANIMCHAN | NA_SELECTED);
 }
 
 static int click_select_channel_dummy(bAnimContext *ac,
   bAnimListElem *ale,
   const short /* eEditKeyframes_Select or 
-1 */ selectmode)
 {
-  /* sanity checking... */
-  if (ale->adt) {
-/* select/deselect */
-if (selectmode == SELECT_INVERT) {
-  /* inverse selection status of this AnimData block only */
-  ale->adt->flag ^= ADT_UI_SELECTED;
-}
-else {
-  /* select AnimData block by itself */
-  ANIM_deselect_anim_channels(ac, ac->data, ac->datatype, false, 
ACHANNEL_SETFLAG_CLEAR);
-  ale->adt->flag |= ADT_UI_SELECTED;
-}
+  if (ale->adt == NULL) {
+/* TODO(Sybren): this should return 0, as nothing changed. */
+return (ND_ANIMCHAN | NA_SELECTED);
+  }
 
-/* set active? */
-if ((ale->adt) && (ale->adt->flag & ADT_UI_SELECTED)) {
-  ale->adt->flag |= ADT_UI_ACTIVE;
-}
+  /* select/deselect */
+  if (selectmode == SELECT_INVERT) {
+/* inverse selection status of this AnimData block only */
+ale->adt->flag ^= ADT_UI_SELECTED;
+  }
+  else {
+/* select AnimData block by itself */
+ANIM_deselect_anim_channels(ac, ac->data, ac->datatype, false, 
ACHANNEL_SETFLAG_CLEAR);
+ale->adt->flag |= ADT_UI_SELECTED;
   }
+
+  /* set active? */
+  if (ale->adt->flag & ADT_UI_SELECTED) {
+ale->adt->flag

[Bf-blender-cvs] [bfd7840358f] master: Cleanup: Animation, split `mouse_anim_channels()` into separate functions

2020-10-12 Thread Sybren A. Stüvel
Commit: bfd7840358f8f37d7558063857e621c12ec69794
Author: Sybren A. Stüvel
Date:   Thu Oct 8 14:54:55 2020 +0200
Branches: master
https://developer.blender.org/rBbfd7840358f8f37d7558063857e621c12ec69794

Cleanup: Animation, split `mouse_anim_channels()` into separate functions

Clean up the code that handles mouse clicks on animation channels in the
non-NLA animation editors, by splitting into separate functions.

No functional changes.

===

M   source/blender/editors/animation/anim_channels_edit.c

===

diff --git a/source/blender/editors/animation/anim_channels_edit.c 
b/source/blender/editors/animation/anim_channels_edit.c
index bb27b0e11d1..0b7ec0d377c 100644
--- a/source/blender/editors/animation/anim_channels_edit.c
+++ b/source/blender/editors/animation/anim_channels_edit.c
@@ -2848,7 +2848,337 @@ static void ANIM_OT_channels_rename(wmOperatorType *ot)
 /*  Mouse-Click Operator *** */
 /* Handle selection changes due to clicking on channels. Settings will get 
caught by UI code... */
 
-static int mouse_anim_channels(bContext *C, bAnimContext *ac, int 
channel_index, short selectmode)
+static int click_select_channel_scene(bAnimListElem *ale,
+  const short /* eEditKeyframes_Select or 
-1 */ selectmode)
+{
+  Scene *sce = (Scene *)ale->data;
+  AnimData *adt = sce->adt;
+
+  /* set selection status */
+  if (selectmode == SELECT_INVERT) {
+/* swap select */
+sce->flag ^= SCE_DS_SELECTED;
+if (adt) {
+  adt->flag ^= ADT_UI_SELECTED;
+}
+  }
+  else {
+sce->flag |= SCE_DS_SELECTED;
+if (adt) {
+  adt->flag |= ADT_UI_SELECTED;
+}
+  }
+  return (ND_ANIMCHAN | NA_SELECTED);
+}
+
+static int click_select_channel_object(bContext *C,
+   bAnimContext *ac,
+   bAnimListElem *ale,
+   const short /* eEditKeyframes_Select or 
-1 */ selectmode)
+{
+  ViewLayer *view_layer = ac->view_layer;
+  Base *base = (Base *)ale->data;
+  Object *ob = base->object;
+  AnimData *adt = ob->adt;
+
+  /* set selection status */
+  if (base->flag & BASE_SELECTABLE) {
+if (selectmode == SELECT_INVERT) {
+  /* swap select */
+  ED_object_base_select(base, BA_INVERT);
+
+  if (adt) {
+adt->flag ^= ADT_UI_SELECTED;
+  }
+}
+else {
+  Base *b;
+
+  /* deselect all */
+  /* TODO: should this deselect all other types of channels too? */
+  for (b = view_layer->object_bases.first; b; b = b->next) {
+ED_object_base_select(b, BA_DESELECT);
+if (b->object->adt) {
+  b->object->adt->flag &= ~(ADT_UI_SELECTED | ADT_UI_ACTIVE);
+}
+  }
+
+  /* select object now */
+  ED_object_base_select(base, BA_SELECT);
+  if (adt) {
+adt->flag |= ADT_UI_SELECTED;
+  }
+}
+
+/* change active object - regardless of whether it is now selected 
[T37883] */
+ED_object_base_activate(C, base); /* adds notifier */
+
+if ((adt) && (adt->flag & ADT_UI_SELECTED)) {
+  adt->flag |= ADT_UI_ACTIVE;
+}
+
+/* Ensure we exit editmode on whatever object was active before
+ * to avoid getting stuck there - T48747. */
+if (ob != CTX_data_edit_object(C)) {
+  ED_object_editmode_exit(C, EM_FREEDATA);
+}
+return (ND_ANIMCHAN | NA_SELECTED);
+  }
+  return 0;
+}
+
+static int click_select_channel_dummy(bAnimContext *ac,
+  bAnimListElem *ale,
+  const short /* eEditKeyframes_Select or 
-1 */ selectmode)
+{
+  /* sanity checking... */
+  if (ale->adt) {
+/* select/deselect */
+if (selectmode == SELECT_INVERT) {
+  /* inverse selection status of this AnimData block only */
+  ale->adt->flag ^= ADT_UI_SELECTED;
+}
+else {
+  /* select AnimData block by itself */
+  ANIM_deselect_anim_channels(ac, ac->data, ac->datatype, false, 
ACHANNEL_SETFLAG_CLEAR);
+  ale->adt->flag |= ADT_UI_SELECTED;
+}
+
+/* set active? */
+if ((ale->adt) && (ale->adt->flag & ADT_UI_SELECTED)) {
+  ale->adt->flag |= ADT_UI_ACTIVE;
+}
+  }
+  return (ND_ANIMCHAN | NA_SELECTED);
+}
+
+static int click_select_channel_group(bAnimContext *ac,
+  bAnimListElem *ale,
+  const short /* eEditKeyframes_Select or 
-1 */ selectmode,
+  const int filter)
+{
+  bActionGroup *agrp = (bActionGroup *)ale->data;
+
+  Object *ob = NULL;
+  bPoseChannel *pchan = NULL;
+
+  /* Armatures-Specific Feature:
+   * Since groups are used to collect F-Curves of t

[Bf-blender-cvs] [fc5c5f0636b] master: Animation: avoid WM notification when nothing changed

2020-10-12 Thread Sybren A. Stüvel
Commit: fc5c5f0636bf03539d972293bd07b428b71877a9
Author: Sybren A. Stüvel
Date:   Thu Oct 8 15:03:21 2020 +0200
Branches: master
https://developer.blender.org/rBfc5c5f0636bf03539d972293bd07b428b71877a9

Animation: avoid WM notification when nothing changed

Avoid WM notification when a dummy channel is clicked in the animation
channel list (dopesheet, graph editor) if that channel has no animation
data.

===

M   source/blender/editors/animation/anim_channels_edit.c

===

diff --git a/source/blender/editors/animation/anim_channels_edit.c 
b/source/blender/editors/animation/anim_channels_edit.c
index ae27d0e426d..92b37628263 100644
--- a/source/blender/editors/animation/anim_channels_edit.c
+++ b/source/blender/editors/animation/anim_channels_edit.c
@@ -2932,8 +2932,7 @@ static int click_select_channel_dummy(bAnimContext *ac,
   const short /* eEditKeyframes_Select or 
-1 */ selectmode)
 {
   if (ale->adt == NULL) {
-/* TODO(Sybren): this should return 0, as nothing changed. */
-return (ND_ANIMCHAN | NA_SELECTED);
+return 0;
   }
 
   /* select/deselect */

___
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
https://lists.blender.org/mailman/listinfo/bf-blender-cvs


[Bf-blender-cvs] [0e0cc2cea91] temp-fcurve-key-insert-follow-curve: Animation: always try to match the existing curve when inserting keys

2020-10-07 Thread Sybren A. Stüvel
Commit: 0e0cc2cea91e4f57d34ee039e0c915d6c8ee4116
Author: Sybren A. Stüvel
Date:   Wed Oct 7 16:40:51 2020 +0200
Branches: temp-fcurve-key-insert-follow-curve
https://developer.blender.org/rB0e0cc2cea91e4f57d34ee039e0c915d6c8ee4116

Animation: always try to match the existing curve when inserting keys

Previously Blender would only match the existing curve slope when the
to-be-inserted key value was already very close to the curve. This check
is now removed, allowing for sliders in the graph editor to subtly
change the curve, and for keyframes added with ctrl+click to follow the
curve better.

===

M   source/blender/editors/animation/keyframing.c

===

diff --git a/source/blender/editors/animation/keyframing.c 
b/source/blender/editors/animation/keyframing.c
index e4b73ea65a0..b992757dd3f 100644
--- a/source/blender/editors/animation/keyframing.c
+++ b/source/blender/editors/animation/keyframing.c
@@ -516,7 +516,7 @@ static void subdivide_nonauto_handles(const FCurve *fcu,
   }
 
   /* Decide when to force auto to manual. */
-  if (!BEZT_IS_AUTOH(bezt) || fabsf(delta) >= 0.001f) {
+  if (!BEZT_IS_AUTOH(bezt)) {
 return;
   }
   if ((prev_auto || next_auto) && fcu->auto_smoothing == 
FCURVE_SMOOTH_CONT_ACCEL) {

___
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
https://lists.blender.org/mailman/listinfo/bf-blender-cvs


[Bf-blender-cvs] [763cd94b6c5] master: Cleanup: Alembic, fix compiler warning about missing declaration

2020-10-07 Thread Sybren A. Stüvel
Commit: 763cd94b6c5917c6d383fa9f92b9f059e63642d7
Author: Sybren A. Stüvel
Date:   Wed Oct 7 12:41:45 2020 +0200
Branches: master
https://developer.blender.org/rB763cd94b6c5917c6d383fa9f92b9f059e63642d7

Cleanup: Alembic, fix compiler warning about missing declaration

Mark the `has_animated_geom_params()` function as `static`, as it's only
used in that particular compilation unit.

No functional changes.

===

M   source/blender/io/alembic/intern/abc_reader_mesh.cc

===

diff --git a/source/blender/io/alembic/intern/abc_reader_mesh.cc 
b/source/blender/io/alembic/intern/abc_reader_mesh.cc
index 93e4c7b154a..b7fcdbc2087 100644
--- a/source/blender/io/alembic/intern/abc_reader_mesh.cc
+++ b/source/blender/io/alembic/intern/abc_reader_mesh.cc
@@ -508,7 +508,7 @@ bool is_valid_animated(const ICompoundProperty 
arbGeomParams, const PropertyHead
   return geom_param.valid() && !geom_param.isConstant();
 }
 
-bool has_animated_geom_params(const ICompoundProperty arbGeomParams)
+static bool has_animated_geom_params(const ICompoundProperty arbGeomParams)
 {
   if (!arbGeomParams.valid()) {
 return false;

___
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
https://lists.blender.org/mailman/listinfo/bf-blender-cvs


[Bf-blender-cvs] [3f2b1f1b667] blender-v2.83-release: Fix T81218: Crash in pose mode using a driver on bendy bone Segment

2020-10-07 Thread Sybren A. Stüvel
Commit: 3f2b1f1b667d00494b01ed4b9d65196f45eb75d3
Author: Sybren A. Stüvel
Date:   Tue Oct 6 17:49:57 2020 +0200
Branches: blender-v2.83-release
https://developer.blender.org/rB3f2b1f1b667d00494b01ed4b9d65196f45eb75d3

Fix T81218: Crash in pose mode using a driver on bendy bone Segment

The example file in T81218 has a driver that maps a bone's X-location to
the number of BBone segments. This caused a dependency cycle, which
resulted in bad thread serialisation, which caused the crash.

This patch breaks the dependency cycle `BONE_LOCAL` →
`DRIVER(bones["Bone"].bbone_segments)` → `BONE_LOCAL`. The 'Driver Data'
relation now points to `BONE_SEGMENTS` when the driven property starts
with `bbone_`.

Differential Revision: https://developer.blender.org/D9122

===

M   source/blender/depsgraph/intern/builder/deg_builder_relations.cc

===

diff --git a/source/blender/depsgraph/intern/builder/deg_builder_relations.cc 
b/source/blender/depsgraph/intern/builder/deg_builder_relations.cc
index 4fb893b350c..182404a848b 100644
--- a/source/blender/depsgraph/intern/builder/deg_builder_relations.cc
+++ b/source/blender/depsgraph/intern/builder/deg_builder_relations.cc
@@ -1453,6 +1453,9 @@ void DepsgraphRelationBuilder::build_driver_data(ID *id, 
FCurve *fcu)
  * which will affect the evaluation of corresponding pose bones. */
 Bone *bone = (Bone *)property_entry_key.ptr.data;
 if (bone != nullptr) {
+  const char *prop_identifier = 
RNA_property_identifier(property_entry_key.prop);
+  const bool driver_targets_bbone = STRPREFIX(prop_identifier, "bbone_");
+
   /* Find objects which use this, and make their eval callbacks
* depend on this. */
   for (IDNode *to_node : graph_->id_nodes) {
@@ -1462,8 +1465,9 @@ void DepsgraphRelationBuilder::build_driver_data(ID *id, 
FCurve *fcu)
   if (object->data == id_ptr && object->pose != nullptr) {
 bPoseChannel *pchan = BKE_pose_channel_find_name(object->pose, 
bone->name);
 if (pchan != nullptr) {
-  OperationKey bone_key(
-  >id, NodeType::BONE, pchan->name, 
OperationCode::BONE_LOCAL);
+  OperationCode target_op = driver_targets_bbone ? 
OperationCode::BONE_SEGMENTS :
+   
OperationCode::BONE_LOCAL;
+  OperationKey bone_key(>id, NodeType::BONE, pchan->name, 
target_op);
   add_relation(driver_key, bone_key, "Arm Bone -> Driver -> Bone");
 }
   }

___
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
https://lists.blender.org/mailman/listinfo/bf-blender-cvs


[Bf-blender-cvs] [d43e3f34d26] master: Fix T81218: Crash in pose mode using a driver on bendy bone Segment

2020-10-06 Thread Sybren A. Stüvel
Commit: d43e3f34d26daca4f2b0f4c524a35a98cc85d1ce
Author: Sybren A. Stüvel
Date:   Tue Oct 6 17:49:57 2020 +0200
Branches: master
https://developer.blender.org/rBd43e3f34d26daca4f2b0f4c524a35a98cc85d1ce

Fix T81218: Crash in pose mode using a driver on bendy bone Segment

The example file in T81218 has a driver that maps a bone's X-location to
the number of BBone segments. This caused a dependency cycle, which
resulted in bad thread serialisation, which caused the crash.

This patch breaks the dependency cycle `BONE_LOCAL` →
`DRIVER(bones["Bone"].bbone_segments)` → `BONE_LOCAL`. The 'Driver Data'
relation now points to `BONE_SEGMENTS` when the driven property starts
with `bbone_`.

Differential Revision: https://developer.blender.org/D9122

===

M   source/blender/depsgraph/intern/builder/deg_builder_relations.cc

===

diff --git a/source/blender/depsgraph/intern/builder/deg_builder_relations.cc 
b/source/blender/depsgraph/intern/builder/deg_builder_relations.cc
index 26839c67324..c0630cd47c6 100644
--- a/source/blender/depsgraph/intern/builder/deg_builder_relations.cc
+++ b/source/blender/depsgraph/intern/builder/deg_builder_relations.cc
@@ -1489,6 +1489,9 @@ void DepsgraphRelationBuilder::build_driver_data(ID *id, 
FCurve *fcu)
   return;
 }
 
+const char *prop_identifier = 
RNA_property_identifier(property_entry_key.prop);
+const bool driver_targets_bbone = STRPREFIX(prop_identifier, "bbone_");
+
 /* Find objects which use this, and make their eval callbacks depend on 
this. */
 for (IDNode *to_node : graph_->id_nodes) {
   if (GS(to_node->id_orig->name) != ID_OB) {
@@ -1506,7 +1509,9 @@ void DepsgraphRelationBuilder::build_driver_data(ID *id, 
FCurve *fcu)
 continue;
   }
 
-  OperationKey bone_key(>id, NodeType::BONE, pchan->name, 
OperationCode::BONE_LOCAL);
+  OperationCode target_op = driver_targets_bbone ? 
OperationCode::BONE_SEGMENTS :
+   
OperationCode::BONE_LOCAL;
+  OperationKey bone_key(>id, NodeType::BONE, pchan->name, 
target_op);
   add_relation(driver_key, bone_key, "Arm Bone -> Driver -> Bone");
 }
 /* Make the driver depend on COW, similar to the generic case below. */

___
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
https://lists.blender.org/mailman/listinfo/bf-blender-cvs


[Bf-blender-cvs] [f7c78b1c7c1] temp-T81218-bbone-segments-driver-crash: Fix T81218: Crash in pose mode using a driver on bendy bone Segment

2020-10-06 Thread Sybren A. Stüvel
Commit: f7c78b1c7c1f6aceeb5e63e73e1ef9d841e9e2df
Author: Sybren A. Stüvel
Date:   Tue Oct 6 13:51:30 2020 +0200
Branches: temp-T81218-bbone-segments-driver-crash
https://developer.blender.org/rBf7c78b1c7c1f6aceeb5e63e73e1ef9d841e9e2df

Fix T81218: Crash in pose mode using a driver on bendy bone Segment

The example file in T81218 has a driver that maps a bone's X-location to the 
number of BBone segments. This caused a dependency cycle, which resulted in bad 
thread serialisation, which caused the crash.

This patch breaks the dependency cycle `BONE_LOCAL` → 
`DRIVER(bones["Bone"].bbone_segments)` → `BONE_LOCAL`. The 'Driver Data' 
relation now points to `BONE_SEGMENTS` when the driven property starts with 
`bbone_`.

Differential Revision: https://developer.blender.org/D9122

===

M   source/blender/depsgraph/intern/builder/deg_builder_relations.cc

===

diff --git a/source/blender/depsgraph/intern/builder/deg_builder_relations.cc 
b/source/blender/depsgraph/intern/builder/deg_builder_relations.cc
index 26839c67324..c0630cd47c6 100644
--- a/source/blender/depsgraph/intern/builder/deg_builder_relations.cc
+++ b/source/blender/depsgraph/intern/builder/deg_builder_relations.cc
@@ -1489,6 +1489,9 @@ void DepsgraphRelationBuilder::build_driver_data(ID *id, 
FCurve *fcu)
   return;
 }
 
+const char *prop_identifier = 
RNA_property_identifier(property_entry_key.prop);
+const bool driver_targets_bbone = STRPREFIX(prop_identifier, "bbone_");
+
 /* Find objects which use this, and make their eval callbacks depend on 
this. */
 for (IDNode *to_node : graph_->id_nodes) {
   if (GS(to_node->id_orig->name) != ID_OB) {
@@ -1506,7 +1509,9 @@ void DepsgraphRelationBuilder::build_driver_data(ID *id, 
FCurve *fcu)
 continue;
   }
 
-  OperationKey bone_key(>id, NodeType::BONE, pchan->name, 
OperationCode::BONE_LOCAL);
+  OperationCode target_op = driver_targets_bbone ? 
OperationCode::BONE_SEGMENTS :
+   
OperationCode::BONE_LOCAL;
+  OperationKey bone_key(>id, NodeType::BONE, pchan->name, 
target_op);
   add_relation(driver_key, bone_key, "Arm Bone -> Driver -> Bone");
 }
 /* Make the driver depend on COW, similar to the generic case below. */

___
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
https://lists.blender.org/mailman/listinfo/bf-blender-cvs


[Bf-blender-cvs] [f3fce877b34] master: Cleanup: Depsgraph, reduce nesting of driver relations code

2020-10-06 Thread Sybren A. Stüvel
Commit: f3fce877b34154224ff0d1e7789b28382fa8f0ea
Author: Sybren A. Stüvel
Date:   Tue Oct 6 13:13:42 2020 +0200
Branches: master
https://developer.blender.org/rBf3fce877b34154224ff0d1e7789b28382fa8f0ea

Cleanup: Depsgraph, reduce nesting of driver relations code

Reduce nesting of `DepsgraphRelationBuilder::build_driver_data()` by
flipping conditions and `return`/`continue` early.

No functional changes.

===

M   source/blender/depsgraph/intern/builder/deg_builder_relations.cc

===

diff --git a/source/blender/depsgraph/intern/builder/deg_builder_relations.cc 
b/source/blender/depsgraph/intern/builder/deg_builder_relations.cc
index 525f9e304cb..26839c67324 100644
--- a/source/blender/depsgraph/intern/builder/deg_builder_relations.cc
+++ b/source/blender/depsgraph/intern/builder/deg_builder_relations.cc
@@ -1484,31 +1484,35 @@ void DepsgraphRelationBuilder::build_driver_data(ID 
*id, FCurve *fcu)
 /* Drivers on armature-level bone settings (i.e. bbone stuff),
  * which will affect the evaluation of corresponding pose bones. */
 Bone *bone = (Bone *)property_entry_key.ptr.data;
-if (bone != nullptr) {
-  /* Find objects which use this, and make their eval callbacks
-   * depend on this. */
-  for (IDNode *to_node : graph_->id_nodes) {
-if (GS(to_node->id_orig->name) == ID_OB) {
-  Object *object = (Object *)to_node->id_orig;
-  /* We only care about objects with pose data which use this. */
-  if (object->data == id_ptr && object->pose != nullptr) {
-bPoseChannel *pchan = BKE_pose_channel_find_name(object->pose, 
bone->name);
-if (pchan != nullptr) {
-  OperationKey bone_key(
-  >id, NodeType::BONE, pchan->name, 
OperationCode::BONE_LOCAL);
-  add_relation(driver_key, bone_key, "Arm Bone -> Driver -> Bone");
-}
-  }
-}
+if (bone == nullptr) {
+  fprintf(stderr, "Couldn't find armature bone name for driver path - 
'%s'\n", rna_path);
+  return;
+}
+
+/* Find objects which use this, and make their eval callbacks depend on 
this. */
+for (IDNode *to_node : graph_->id_nodes) {
+  if (GS(to_node->id_orig->name) != ID_OB) {
+continue;
   }
-  /* Make the driver depend on COW, similar to the generic case below. */
-  if (id_ptr != id) {
-ComponentKey cow_key(id_ptr, NodeType::COPY_ON_WRITE);
-add_relation(cow_key, driver_key, "Driven CoW -> Driver", 
RELATION_CHECK_BEFORE_ADD);
+
+  /* We only care about objects with pose data which use this. */
+  Object *object = (Object *)to_node->id_orig;
+  if (object->data != id_ptr || object->pose == nullptr) {
+continue;
+  }
+
+  bPoseChannel *pchan = BKE_pose_channel_find_name(object->pose, 
bone->name);
+  if (pchan == nullptr) {
+continue;
   }
+
+  OperationKey bone_key(>id, NodeType::BONE, pchan->name, 
OperationCode::BONE_LOCAL);
+  add_relation(driver_key, bone_key, "Arm Bone -> Driver -> Bone");
 }
-else {
-  fprintf(stderr, "Couldn't find armature bone name for driver path - 
'%s'\n", rna_path);
+/* Make the driver depend on COW, similar to the generic case below. */
+if (id_ptr != id) {
+  ComponentKey cow_key(id_ptr, NodeType::COPY_ON_WRITE);
+  add_relation(cow_key, driver_key, "Driven CoW -> Driver", 
RELATION_CHECK_BEFORE_ADD);
 }
   }
   else {

___
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
https://lists.blender.org/mailman/listinfo/bf-blender-cvs


[Bf-blender-cvs] [8b72d9cc153] master: Insert keyframes while preserving shape of curve

2020-10-05 Thread Sybren A. Stüvel
Commit: 8b72d9cc1530fb6fbd37b6a2e02aa61242f8d24a
Author: Sybren A. Stüvel
Date:   Mon Oct 5 13:16:10 2020 +0200
Branches: master
https://developer.blender.org/rB8b72d9cc1530fb6fbd37b6a2e02aa61242f8d24a

Insert keyframes while preserving shape of curve

Apply the De Casteljau algorithm to split the Bèzier curve at the X
coordinate where the new key is inserted, and uses the result to update
both the newly inserted and surrounding handles.

For curves that use Auto keyframes this has been largely addressed by
the new algorithm from D2884. This commit extends this to non-auto
handles.

This code is heavily based on D3172 by Alexander Gavrilov (@angavrilov).

Manifest Task: https://developer.blender.org/T81353

===

M   source/blender/blenkernel/BKE_fcurve.h
M   source/blender/blenkernel/intern/fcurve.c
M   source/blender/blenkernel/intern/fcurve_test.cc
M   source/blender/editors/animation/keyframing.c

===

diff --git a/source/blender/blenkernel/BKE_fcurve.h 
b/source/blender/blenkernel/BKE_fcurve.h
index 52ef86671cc..9b6189612ba 100644
--- a/source/blender/blenkernel/BKE_fcurve.h
+++ b/source/blender/blenkernel/BKE_fcurve.h
@@ -267,6 +267,18 @@ typedef enum eFCU_Cycle_Type {
 
 eFCU_Cycle_Type BKE_fcurve_get_cycle_type(struct FCurve *fcu);
 
+/** Adjust Bezier handles of all three given BezTriples, so that `bezt` can be 
inserted between
+ * `prev` and `next` without changing the resulting curve shape.
+ *
+ * \param r_pdelta: return Y difference between `bezt` and the original curve 
value at its X
+ * position.
+ * \return Whether the split was succesful.
+ */
+bool BKE_bezt_subdivide_handles(struct BezTriple *bezt,
+struct BezTriple *prev,
+struct BezTriple *next,
+float *r_pdelta);
+
 /*  Curve Sanity   */
 
 void calchandles_fcurve(struct FCurve *fcu);
diff --git a/source/blender/blenkernel/intern/fcurve.c 
b/source/blender/blenkernel/intern/fcurve.c
index 05c8e5b2bac..d0f23221ed0 100644
--- a/source/blender/blenkernel/intern/fcurve.c
+++ b/source/blender/blenkernel/intern/fcurve.c
@@ -1352,17 +1352,14 @@ void correct_bezpart(const float v1[2], float v2[2], 
float v3[2], const float v4
   }
 }
 
-/* find root ('zero') */
-static int findzero(float x, float q0, float q1, float q2, float q3, float *o)
+/** Find roots of cubic equation (c0 x³ + c1 x² + c2 x + c3)
+ * \return number of roots in `o`.
+ * NOTE: it is up to the caller to allocate enough memory for `o`. */
+static int solve_cubic(double c0, double c1, double c2, double c3, float *o)
 {
-  double c0, c1, c2, c3, a, b, c, p, q, d, t, phi;
+  double a, b, c, p, q, d, t, phi;
   int nr = 0;
 
-  c0 = q0 - x;
-  c1 = 3.0f * (q1 - q0);
-  c2 = 3.0f * (q0 - 2.0f * q1 + q2);
-  c3 = q3 - q0 + 3.0f * (q1 - q2);
-
   if (c3 != 0.0) {
 a = c2 / c3;
 b = c1 / c3;
@@ -1469,6 +1466,17 @@ static int findzero(float x, float q0, float q1, float 
q2, float q3, float *o)
   return 0;
 }
 
+/* Find root(s) ('zero') of a Bezier curve. */
+static int findzero(float x, float q0, float q1, float q2, float q3, float *o)
+{
+  const double c0 = q0 - x;
+  const double c1 = 3.0f * (q1 - q0);
+  const double c2 = 3.0f * (q0 - 2.0f * q1 + q2);
+  const double c3 = q3 - q0 + 3.0f * (q1 - q2);
+
+  return solve_cubic(c0, c1, c2, c3, o);
+}
+
 static void berekeny(float f1, float f2, float f3, float f4, float *o, int b)
 {
   float t, c0, c1, c2, c3;
@@ -1485,6 +1493,68 @@ static void berekeny(float f1, float f2, float f3, float 
f4, float *o, int b)
   }
 }
 
+/* Recompute handles to neatly subdivide the prev-next range at bezt. */
+bool BKE_bezt_subdivide_handles(struct BezTriple *bezt,
+struct BezTriple *prev,
+struct BezTriple *next,
+float *r_pdelta)
+{
+  /* The four points that make up this section of the Bezier curve. */
+  const float *prev_coords = prev->vec[1];
+  float *prev_handle_right = prev->vec[2];
+  float *next_handle_left = next->vec[0];
+  const float *next_coords = next->vec[1];
+
+  float *new_handle_left = bezt->vec[0];
+  const float *new_coords = bezt->vec[1];
+  float *new_handle_right = bezt->vec[2];
+
+  if (new_coords[0] <= prev_coords[0] || new_coords[0] >= next_coords[0]) {
+/* The new keyframe is outside the (prev_coords, next_coords) range. */
+return false;
+  }
+
+  /* Apply evaluation-time limits and compute the effective curve. */
+  correct_bezpart(prev_coords, prev_handle_right, next_handle_left, 
next_coords);
+  float roots[4];
+  if (!findzero(new_coords[0],
+prev_coords[0],
+prev_handle_right[0],
+next_handle_left[0],
+next_coords[0],
+roots)) {
+return fal

[Bf-blender-cvs] [dfbf8682980] master: Initialize CLOG to fix crashing unit tests

2020-10-05 Thread Sybren A. Stüvel
Commit: dfbf8682980ba51451ccc7d1ee4cc02497dfeec3
Author: Sybren A. Stüvel
Date:   Mon Oct 5 14:24:07 2020 +0200
Branches: master
https://developer.blender.org/rBdfbf8682980ba51451ccc7d1ee4cc02497dfeec3

Initialize CLOG to fix crashing unit tests

Initialize CLOG in the blendfile-loading unit test superclass. Since
rB8683d4e88f2e CLOG is used by more areas in Blender, and without
initialisation it crashes.

===

M   source/blender/blenloader/CMakeLists.txt
M   source/blender/blenloader/tests/blendfile_loading_base_test.cc

===

diff --git a/source/blender/blenloader/CMakeLists.txt 
b/source/blender/blenloader/CMakeLists.txt
index 1c5cd548bb8..c44bd8d0039 100644
--- a/source/blender/blenloader/CMakeLists.txt
+++ b/source/blender/blenloader/CMakeLists.txt
@@ -34,6 +34,7 @@ set(INC
   ../sequencer
   ../windowmanager
   ../../../intern/guardedalloc
+  ../../../intern/clog
 
   # for writefile.c: dna_type_offsets.h
   ${CMAKE_BINARY_DIR}/source/blender/makesdna/intern
diff --git a/source/blender/blenloader/tests/blendfile_loading_base_test.cc 
b/source/blender/blenloader/tests/blendfile_loading_base_test.cc
index c743e6bcd3f..e34be68abbf 100644
--- a/source/blender/blenloader/tests/blendfile_loading_base_test.cc
+++ b/source/blender/blenloader/tests/blendfile_loading_base_test.cc
@@ -48,6 +48,8 @@
 #include "WM_api.h"
 #include "wm.h"
 
+#include "CLG_log.h"
+
 BlendfileLoadingBaseTest::~BlendfileLoadingBaseTest()
 {
 }
@@ -58,12 +60,14 @@ void BlendfileLoadingBaseTest::SetUpTestCase()
 
   /* Minimal code to make loading a blendfile and constructing a depsgraph not 
crash, copied from
* main() in creator.c. */
+  CLG_init();
   BLI_threadapi_init();
 
   DNA_sdna_current_init();
   BKE_blender_globals_init();
 
   BKE_idtype_init();
+  BKE_appdir_init();
   IMB_init();
   BKE_images_init();
   BKE_modifier_init();
@@ -100,6 +104,8 @@ void BlendfileLoadingBaseTest::TearDownTestCase()
 
   BKE_tempdir_session_purge();
 
+  CLG_exit();
+
   testing::Test::TearDownTestCase();
 }

___
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
https://lists.blender.org/mailman/listinfo/bf-blender-cvs


[Bf-blender-cvs] [90a27d5aa91] master: Cleanup: Use enum for return values in context callbacks

2020-10-02 Thread Sybren A. Stüvel
Commit: 90a27d5aa91a1b6a25ea14e11c889d47f77f4cf7
Author: Sybren A. Stüvel
Date:   Fri Oct 2 18:56:25 2020 +0200
Branches: master
https://developer.blender.org/rB90a27d5aa91a1b6a25ea14e11c889d47f77f4cf7

Cleanup: Use enum for return values in context callbacks

Define enum `eContextResult` and use its values for returns, instead of
just returning 1, 0, or -1 (and always having some comment that explains
what -1 means).

This also cleans up the mixup between returning `0` and `false`, and `1`
and `true`. An inconsistency was discovered during this cleanup, and
marked with `TODO(sybren)`. It's not fixed here, as it would consititute
a functional change.

The enum isn't used everywhere, as enums in C and C++ can have different
storage sizes. To prevent issues, callback functions are still declared
as returning`int`. To at least make things easier to understand for
humans, I marked those with `int /*eContextResult*/`.

This is a followup of D9090, and is intended to unify how context
callbacks return values. This will make it easier to extend the approach
in D9090 to those functions.

No functional changes.

Differential Revision: https://developer.blender.org/D9095

===

M   source/blender/blenkernel/BKE_context.h
M   source/blender/blenkernel/BKE_screen.h
M   source/blender/blenkernel/intern/context.c
M   source/blender/editors/screen/screen_context.c
M   source/blender/editors/space_buttons/buttons_context.c
M   source/blender/editors/space_clip/space_clip.c
M   source/blender/editors/space_image/space_image.c
M   source/blender/editors/space_node/space_node.c
M   source/blender/editors/space_sequencer/space_sequencer.c
M   source/blender/editors/space_text/space_text.c
M   source/blender/makesdna/DNA_screen_types.h
M   source/blender/python/intern/bpy_rna.c

===

diff --git a/source/blender/blenkernel/BKE_context.h 
b/source/blender/blenkernel/BKE_context.h
index f3e4a18b9bd..5c534803781 100644
--- a/source/blender/blenkernel/BKE_context.h
+++ b/source/blender/blenkernel/BKE_context.h
@@ -74,9 +74,26 @@ typedef struct bContext bContext;
 struct bContextDataResult;
 typedef struct bContextDataResult bContextDataResult;
 
-typedef int (*bContextDataCallback)(const bContext *C,
-const char *member,
-bContextDataResult *result);
+/* Result of context lookups.
+ * The specific values are important, and used implicitly in ctx_data_get(). 
Some functions also
+ * still accept/return `int` instead, to ensure that the compiler uses the 
correct storage size
+ * when mixing C/C++ code. */
+typedef enum eContextResult {
+  /* The context member was found, and its data is available. */
+  CTX_RESULT_OK = 1,
+
+  /* The context member was not found. */
+  CTX_RESULT_MEMBER_NOT_FOUND = 0,
+
+  /* The context member was found, but its data is not available.
+   * For example, "active_bone" is a valid context member, but has not data in 
Object mode. */
+  CTX_RESULT_NO_DATA = -1,
+} eContextResult;
+
+/* Function mapping a context member name to its value. */
+typedef int /*eContextResult*/ (*bContextDataCallback)(const bContext *C,
+   const char *member,
+   bContextDataResult 
*result);
 
 typedef struct bContextStoreEntry {
   struct bContextStoreEntry *next, *prev;
@@ -213,7 +230,7 @@ ListBase CTX_data_dir_get_ex(const bContext *C,
  const bool use_rna,
  const bool use_all);
 ListBase CTX_data_dir_get(const bContext *C);
-int CTX_data_get(
+int /*eContextResult*/ CTX_data_get(
 const bContext *C, const char *member, PointerRNA *r_ptr, ListBase *r_lb, 
short *r_type);
 
 void CTX_data_id_pointer_set(bContextDataResult *result, struct ID *id);
diff --git a/source/blender/blenkernel/BKE_screen.h 
b/source/blender/blenkernel/BKE_screen.h
index bcc58ecf2c5..35a3d0415a8 100644
--- a/source/blender/blenkernel/BKE_screen.h
+++ b/source/blender/blenkernel/BKE_screen.h
@@ -26,6 +26,8 @@
 
 #include "RNA_types.h"
 
+#include "BKE_context.h"
+
 #ifdef __cplusplus
 extern "C" {
 #endif
@@ -106,7 +108,7 @@ typedef struct SpaceType {
   void (*gizmos)(void);
 
   /* return context data */
-  int (*context)(const struct bContext *C, const char *member, struct 
bContextDataResult *result);
+  bContextDataCallback context;
 
   /* Used when we want to replace an ID by another (or NULL). */
   void (*id_remap)(struct ScrArea *area,
@@ -181,7 +183,7 @@ typedef struct ARegionType {
   void (*cursor)(struct wmWindow *win, struct ScrArea *area, struct ARegion 
*region);
 
   /* return context data */
-  int (*context)(const struct bContext *C, const char *member, struct 
bContextDataResult *

[Bf-blender-cvs] [c65c4149c9b] master: Cleanup: Refactor `ed_screen_context()` to use hash lookups

2020-10-02 Thread Sybren A. Stüvel
Commit: c65c4149c9be8a1811eb389f657216fab071dfc5
Author: Sybren A. Stüvel
Date:   Fri Oct 2 12:57:11 2020 +0200
Branches: master
https://developer.blender.org/rBc65c4149c9be8a1811eb389f657216fab071dfc5

Cleanup: Refactor `ed_screen_context()` to use hash lookups

Refactor `ed_screen_context()` to use `GHash` lookups instead of a
sequence of string comparisons. This should provide a nice speedup,
given that the hash for `member` only has to be computed once instead of
matching it to each possible string.

Reviwed by: brecht

Differential Revision: https://developer.blender.org/D9090

===

M   source/blender/editors/screen/screen_context.c

===

diff --git a/source/blender/editors/screen/screen_context.c 
b/source/blender/editors/screen/screen_context.c
index 84f16e8667d..e32d374d094 100644
--- a/source/blender/editors/screen/screen_context.c
+++ b/source/blender/editors/screen/screen_context.c
@@ -43,6 +43,7 @@
 
 #include "BKE_action.h"
 #include "BKE_armature.h"
+#include "BKE_blender.h"
 #include "BKE_context.h"
 #include "BKE_gpencil.h"
 #include "BKE_layer.h"
@@ -976,6 +977,81 @@ static int screen_ctx_active_editable_fcurve(const 
bContext *C, bContextDataResu
   return -1; /* found but not available */
 }
 
+/* Registry of context callback functions. */
+
+typedef int (*context_callback)(const bContext *C, bContextDataResult *result);
+static GHash *ed_screen_context_functions = NULL;
+
+static void free_context_function_ghash(void *UNUSED(user_data))
+{
+  BLI_ghash_free(ed_screen_context_functions, NULL, NULL);
+}
+static inline void register_context_function(const char *member, 
context_callback function)
+{
+  BLI_ghash_insert(ed_screen_context_functions, (void *)member, function);
+}
+
+static void ensure_ed_screen_context_functions(void)
+{
+  if (ed_screen_context_functions != NULL) {
+return;
+  }
+
+  /* Murmur hash is faster for smaller strings (according to BLI_hash_mm2). */
+  ed_screen_context_functions = BLI_ghash_new(
+  BLI_ghashutil_strhash_p_murmur, BLI_ghashutil_strcmp, __func__);
+
+  BKE_blender_atexit_register(free_context_function_ghash, NULL);
+
+  register_context_function("scene", screen_ctx_scene);
+  register_context_function("visible_objects", screen_ctx_visible_objects);
+  register_context_function("selectable_objects", 
screen_ctx_selectable_objects);
+  register_context_function("selected_objects", screen_ctx_selected_objects);
+  register_context_function("selected_editable_objects", 
screen_ctx_selected_editable_objects);
+  register_context_function("editable_objects", screen_ctx_editable_objects);
+  register_context_function("objects_in_mode", screen_ctx_objects_in_mode);
+  register_context_function("objects_in_mode_unique_data", 
screen_ctx_objects_in_mode_unique_data);
+  register_context_function("visible_bones", screen_ctx_visible_bones);
+  register_context_function("editable_bones", screen_ctx_editable_bones);
+  register_context_function("selected_bones", screen_ctx_selected_bones);
+  register_context_function("selected_editable_bones", 
screen_ctx_selected_editable_bones);
+  register_context_function("visible_pose_bones", 
screen_ctx_visible_pose_bones);
+  register_context_function("selected_pose_bones", 
screen_ctx_selected_pose_bones);
+  register_context_function("selected_pose_bones_from_active_object",
+screen_ctx_selected_pose_bones_from_active_object);
+  register_context_function("active_bone", screen_ctx_active_bone);
+  register_context_function("active_pose_bone", screen_ctx_active_pose_bone);
+  register_context_function("active_object", screen_ctx_active_object);
+  register_context_function("object", screen_ctx_object);
+  register_context_function("edit_object", screen_ctx_edit_object);
+  register_context_function("sculpt_object", screen_ctx_sculpt_object);
+  register_context_function("vertex_paint_object", 
screen_ctx_vertex_paint_object);
+  register_context_function("weight_paint_object", 
screen_ctx_weight_paint_object);
+  register_context_function("image_paint_object", 
screen_ctx_image_paint_object);
+  register_context_function("particle_edit_object", 
screen_ctx_particle_edit_object);
+  register_context_function("pose_object", screen_ctx_pose_object);
+  register_context_function("sequences", screen_ctx_sequences);
+  register_context_function("selected_sequences", 
screen_ctx_selected_sequences);
+  register_context_function("selected_editable_sequences", 
screen_ctx_selected_editable_sequences);
+  register_context

[Bf-blender-cvs] [ab72406dc34] master: Cleanup: split up `ed_screen_context()` into separate functions

2020-10-02 Thread Sybren A. Stüvel
Commit: ab72406dc347b428b5ef6981afd1ca45781f0ae6
Author: Sybren A. Stüvel
Date:   Fri Oct 2 11:56:06 2020 +0200
Branches: master
https://developer.blender.org/rBab72406dc347b428b5ef6981afd1ca45781f0ae6

Cleanup: split up `ed_screen_context()` into separate functions

Refactor `ed_screen_context()` to call separate functions, instead of
having the entire functionality in one function. Each function now only
retrieves the data it needs from the context. Furthermore, some string
comparisons are removed.

No functional changes.

Reviwed by: brecht

Differential Revision: https://developer.blender.org/D9090

===

M   source/blender/editors/screen/screen_context.c

===

diff --git a/source/blender/editors/screen/screen_context.c 
b/source/blender/editors/screen/screen_context.c
index 89d6befbb25..84f16e8667d 100644
--- a/source/blender/editors/screen/screen_context.c
+++ b/source/blender/editors/screen/screen_context.c
@@ -37,6 +37,7 @@
 #include "DNA_space_types.h"
 #include "DNA_windowmanager_types.h"
 
+#include "BLI_ghash.h"
 #include "BLI_listbase.h"
 #include "BLI_utildefines.h"
 
@@ -110,669 +111,1016 @@ const char *screen_context_dir[] = {
 NULL,
 };
 
-int ed_screen_context(const bContext *C, const char *member, 
bContextDataResult *result)
+/* Each function `screen_ctx_XXX()` will be called when the screen context 
"XXX" is requested.
+ * ensure_ed_screen_context_functions() is responsible for creating the hash 
map from context
+ * member name to function.
+ *
+ * Each function returns:
+ *1 for "the member name was found and returned data is valid"
+ *0 for "the member name was not found"
+ *   -1 for "the member name was found but data is not available"
+ *
+ * */
+
+static int screen_ctx_scene(const bContext *C, bContextDataResult *result)
+{
+  wmWindow *win = CTX_wm_window(C);
+  Scene *scene = WM_window_get_active_scene(win);
+  CTX_data_id_pointer_set(result, >id);
+  return 1;
+}
+static int screen_ctx_visible_objects(const bContext *C, bContextDataResult 
*result)
+{
+  wmWindow *win = CTX_wm_window(C);
+  View3D *v3d = CTX_wm_view3d(C); /* This may be NULL in a lot of cases. */
+  ViewLayer *view_layer = WM_window_get_active_view_layer(win);
+
+  LISTBASE_FOREACH (Base *, base, _layer->object_bases) {
+if (BASE_VISIBLE(v3d, base)) {
+  CTX_data_id_list_add(result, >object->id);
+}
+  }
+  CTX_data_type_set(result, CTX_DATA_TYPE_COLLECTION);
+  return 1;
+}
+static int screen_ctx_selectable_objects(const bContext *C, bContextDataResult 
*result)
+{
+  wmWindow *win = CTX_wm_window(C);
+  View3D *v3d = CTX_wm_view3d(C); /* This may be NULL in a lot of cases. */
+  ViewLayer *view_layer = WM_window_get_active_view_layer(win);
+
+  LISTBASE_FOREACH (Base *, base, _layer->object_bases) {
+if (BASE_SELECTABLE(v3d, base)) {
+  CTX_data_id_list_add(result, >object->id);
+}
+  }
+  CTX_data_type_set(result, CTX_DATA_TYPE_COLLECTION);
+  return 1;
+}
+static int screen_ctx_selected_objects(const bContext *C, bContextDataResult 
*result)
+{
+  wmWindow *win = CTX_wm_window(C);
+  View3D *v3d = CTX_wm_view3d(C); /* This may be NULL in a lot of cases. */
+  ViewLayer *view_layer = WM_window_get_active_view_layer(win);
+
+  LISTBASE_FOREACH (Base *, base, _layer->object_bases) {
+if (BASE_SELECTED(v3d, base)) {
+  CTX_data_id_list_add(result, >object->id);
+}
+  }
+  CTX_data_type_set(result, CTX_DATA_TYPE_COLLECTION);
+  return 1;
+}
+static int screen_ctx_selected_editable_objects(const bContext *C, 
bContextDataResult *result)
+{
+  wmWindow *win = CTX_wm_window(C);
+  View3D *v3d = CTX_wm_view3d(C); /* This may be NULL in a lot of cases. */
+  ViewLayer *view_layer = WM_window_get_active_view_layer(win);
+
+  LISTBASE_FOREACH (Base *, base, _layer->object_bases) {
+if (BASE_SELECTED_EDITABLE(v3d, base)) {
+  CTX_data_id_list_add(result, >object->id);
+}
+  }
+  CTX_data_type_set(result, CTX_DATA_TYPE_COLLECTION);
+  return 1;
+}
+static int screen_ctx_editable_objects(const bContext *C, bContextDataResult 
*result)
+{
+  wmWindow *win = CTX_wm_window(C);
+  View3D *v3d = CTX_wm_view3d(C); /* This may be NULL in a lot of cases. */
+  ViewLayer *view_layer = WM_window_get_active_view_layer(win);
+
+  /* Visible + Editable, but not necessarily selected */
+  LISTBASE_FOREACH (Base *, base, _layer->object_bases) {
+if (BASE_EDITABLE(v3d, base)) {
+  CTX_data_id_list_add(result, >object->id);
+}
+  }
+  CTX_data_type_set(result, CTX_DATA_TYPE_COLLECTION);
+  return 1;
+}
+static int screen_ctx_objects_in_mode(const bContext *C, bContextDataResult 
*result)
+{
+  wmWindow *win = CTX_wm_window(C);
+  View3D *v3d = CTX_wm_view3d(C); /* This may be NULL in a lot of cas

[Bf-blender-cvs] [b81aad9064d] temp-cleanup-screen-context: Cleanup: refactor `ed_screen_context()` to use hash lookups

2020-10-02 Thread Sybren A. Stüvel
Commit: b81aad9064d626d1d75873672774594fd9bb70a5
Author: Sybren A. Stüvel
Date:   Fri Oct 2 11:56:06 2020 +0200
Branches: temp-cleanup-screen-context
https://developer.blender.org/rBb81aad9064d626d1d75873672774594fd9bb70a5

Cleanup: refactor `ed_screen_context()` to use hash lookups

Refactor `ed_screen_context()` to use `GHash` lookups instead of a sequence
of string comparisons, and move each context member into its own function.

===

M   source/blender/editors/screen/screen_context.c

===

diff --git a/source/blender/editors/screen/screen_context.c 
b/source/blender/editors/screen/screen_context.c
index 89d6befbb25..8ca10b7b493 100644
--- a/source/blender/editors/screen/screen_context.c
+++ b/source/blender/editors/screen/screen_context.c
@@ -37,6 +37,7 @@
 #include "DNA_space_types.h"
 #include "DNA_windowmanager_types.h"
 
+#include "BLI_ghash.h"
 #include "BLI_listbase.h"
 #include "BLI_utildefines.h"
 
@@ -110,197 +111,242 @@ const char *screen_context_dir[] = {
 NULL,
 };
 
-int ed_screen_context(const bContext *C, const char *member, 
bContextDataResult *result)
+/* Each function `screen_ctx_XXX()` will be called when the screen context 
"XXX" is requested.
+ * ensure_ed_screen_context_functions() is responsible for creating the hash 
map from context
+ * member name to function.
+ *
+ * Each function returns:
+ *1 for "the member name was found and returned data is valid"
+ *0 for "the member name was not found"
+ *   -1 for "the member name was found but data is not available"
+ *
+ * */
+
+static int screen_ctx_scene(const bContext *C, bContextDataResult *result)
 {
   wmWindow *win = CTX_wm_window(C);
-  View3D *v3d = CTX_wm_view3d(C); /* This may be NULL in a lot of cases. */
-  bScreen *screen = CTX_wm_screen(C);
-  ScrArea *area = CTX_wm_area(C);
   Scene *scene = WM_window_get_active_scene(win);
+  CTX_data_id_pointer_set(result, >id);
+  return 1;
+}
+static int screen_ctx_visible_objects(const bContext *C, bContextDataResult 
*result)
+{
+  wmWindow *win = CTX_wm_window(C);
+  View3D *v3d = CTX_wm_view3d(C); /* This may be NULL in a lot of cases. */
   ViewLayer *view_layer = WM_window_get_active_view_layer(win);
-  Object *obact = view_layer->basact ? view_layer->basact->object : NULL;
-  Object *obedit = OBEDIT_FROM_VIEW_LAYER(view_layer);
 
-  if (CTX_data_dir(member)) {
-CTX_data_dir_set(result, screen_context_dir);
-return 1;
-  }
-  if (CTX_data_equals(member, "scene")) {
-CTX_data_id_pointer_set(result, >id);
-return 1;
-  }
-  if (CTX_data_equals(member, "visible_objects")) {
-LISTBASE_FOREACH (Base *, base, _layer->object_bases) {
-  if (BASE_VISIBLE(v3d, base)) {
-CTX_data_id_list_add(result, >object->id);
-  }
+  LISTBASE_FOREACH (Base *, base, _layer->object_bases) {
+if (BASE_VISIBLE(v3d, base)) {
+  CTX_data_id_list_add(result, >object->id);
 }
-CTX_data_type_set(result, CTX_DATA_TYPE_COLLECTION);
-return 1;
   }
-  if (CTX_data_equals(member, "selectable_objects")) {
-LISTBASE_FOREACH (Base *, base, _layer->object_bases) {
-  if (BASE_SELECTABLE(v3d, base)) {
-CTX_data_id_list_add(result, >object->id);
-  }
+  CTX_data_type_set(result, CTX_DATA_TYPE_COLLECTION);
+  return 1;
+}
+static int screen_ctx_selectable_objects(const bContext *C, bContextDataResult 
*result)
+{
+  wmWindow *win = CTX_wm_window(C);
+  View3D *v3d = CTX_wm_view3d(C); /* This may be NULL in a lot of cases. */
+  ViewLayer *view_layer = WM_window_get_active_view_layer(win);
+
+  LISTBASE_FOREACH (Base *, base, _layer->object_bases) {
+if (BASE_SELECTABLE(v3d, base)) {
+  CTX_data_id_list_add(result, >object->id);
 }
-CTX_data_type_set(result, CTX_DATA_TYPE_COLLECTION);
-return 1;
   }
-  if (CTX_data_equals(member, "selected_objects")) {
-LISTBASE_FOREACH (Base *, base, _layer->object_bases) {
-  if (BASE_SELECTED(v3d, base)) {
-CTX_data_id_list_add(result, >object->id);
-  }
+  CTX_data_type_set(result, CTX_DATA_TYPE_COLLECTION);
+  return 1;
+}
+static int screen_ctx_selected_objects(const bContext *C, bContextDataResult 
*result)
+{
+  wmWindow *win = CTX_wm_window(C);
+  View3D *v3d = CTX_wm_view3d(C); /* This may be NULL in a lot of cases. */
+  ViewLayer *view_layer = WM_window_get_active_view_layer(win);
+
+  LISTBASE_FOREACH (Base *, base, _layer->object_bases) {
+if (BASE_SELECTED(v3d, base)) {
+  CTX_data_id_list_add(result, >object->id);
 }
-CTX_data_type_set(result, CTX_DATA_TYPE_COLLECTION);
-return 1;
   }
-  if (CTX_data_equals(member, "selected_editable_objects")) {
-LISTBASE_FOREACH (Base 

[Bf-blender-cvs] [bab2260b59c] master: Fix T71981: Alembic vertex interpolation can jumble mesh

2020-09-29 Thread Sybren A. Stüvel
Commit: bab2260b59c7bffe1e16b5e860ac36b5fdc31bf0
Author: Sybren A. Stüvel
Date:   Tue Sep 29 14:34:01 2020 +0200
Branches: master
https://developer.blender.org/rBbab2260b59c7bffe1e16b5e860ac36b5fdc31bf0

Fix T71981: Alembic vertex interpolation can jumble mesh

Add an option to disable Alembic vertex interpolation.
Bump subversion from 5 to 6.

Alembic stores mesh samples at specific time keys; when a frame in
Blender maps to a timecode between two samples, Blender will interpolate
the mesh vertex positions. This interpolation only happens when the mesh
has a constant topology, but sometimes this was not detected properly
when the vertices change order, but the number of mesh elements remains
the same. This would result in a mesh with jumbled up vertices (T71981).
With this patch, users have the ability to disable vertex interpolation.

An alternative would be to have better detection of topology changes,
but that that'll cause a considerable slowdown.

Maniphest Tasks: T71981

Differential Revision: https://developer.blender.org/D9041

===

M   source/blender/blenkernel/BKE_blender_version.h
M   source/blender/blenloader/intern/versioning_290.c
M   source/blender/io/alembic/intern/abc_customdata.h
M   source/blender/io/alembic/intern/abc_reader_mesh.cc
M   source/blender/io/alembic/intern/abc_reader_mesh.h
M   source/blender/io/alembic/intern/abc_reader_points.cc
M   source/blender/makesdna/DNA_modifier_types.h
M   source/blender/makesrna/intern/rna_modifier.c
M   source/blender/modifiers/intern/MOD_meshsequencecache.c

===

diff --git a/source/blender/blenkernel/BKE_blender_version.h 
b/source/blender/blenkernel/BKE_blender_version.h
index 23efea81e57..e43043b034f 100644
--- a/source/blender/blenkernel/BKE_blender_version.h
+++ b/source/blender/blenkernel/BKE_blender_version.h
@@ -39,7 +39,7 @@ extern "C" {
 
 /* Blender file format version. */
 #define BLENDER_FILE_VERSION BLENDER_VERSION
-#define BLENDER_FILE_SUBVERSION 5
+#define BLENDER_FILE_SUBVERSION 6
 
 /* Minimum Blender version that supports reading file written with the current
  * version. Older Blender versions will test this and show a warning if the 
file
diff --git a/source/blender/blenloader/intern/versioning_290.c 
b/source/blender/blenloader/intern/versioning_290.c
index 3c95a998d90..1b9e53ded63 100644
--- a/source/blender/blenloader/intern/versioning_290.c
+++ b/source/blender/blenloader/intern/versioning_290.c
@@ -724,18 +724,7 @@ void blo_do_versions_290(FileData *fd, Library 
*UNUSED(lib), Main *bmain)
 }
   }
 
-  /**
-   * Versioning code until next subversion bump goes here.
-   *
-   * \note Be sure to check when bumping the version:
-   * - "versioning_userdef.c", #BLO_version_defaults_userpref_blend
-   * - "versioning_userdef.c", #do_versions_theme
-   *
-   * \note Keep this message at the bottom of the function.
-   */
-  {
-/* Keep this block, even when empty. */
-
+  if (!MAIN_VERSION_ATLEAST(bmain, 291, 6)) {
 /* Darken Inactive Overlay. */
 if (!DNA_struct_elem_find(fd->filesdna, "View3DOverlay", "float", 
"fade_alpha")) {
   for (bScreen *screen = bmain->screens.first; screen; screen = 
screen->id.next) {
@@ -759,5 +748,30 @@ void blo_do_versions_290(FileData *fd, Library 
*UNUSED(lib), Main *bmain)
 mesh->symmetry = mesh->editflag & (ME_SYMMETRY_X | ME_SYMMETRY_Y | 
ME_SYMMETRY_Z);
   }
 }
+
+/* Alembic importer: allow vertex interpolation by default. */
+for (Object *object = bmain->objects.first; object != NULL; object = 
object->id.next) {
+  LISTBASE_FOREACH (ModifierData *, md, >modifiers) {
+if (md->type != eModifierType_MeshSequenceCache) {
+  continue;
+}
+
+MeshSeqCacheModifierData *data = (MeshSeqCacheModifierData *)md;
+data->read_flag |= MOD_MESHSEQ_INTERPOLATE_VERTICES;
+  }
+}
+  }
+
+  /**
+   * Versioning code until next subversion bump goes here.
+   *
+   * \note Be sure to check when bumping the version:
+   * - "versioning_userdef.c", #BLO_version_defaults_userpref_blend
+   * - "versioning_userdef.c", #do_versions_theme
+   *
+   * \note Keep this message at the bottom of the function.
+   */
+  {
+/* Keep this block, even when empty. */
   }
 }
diff --git a/source/blender/io/alembic/intern/abc_customdata.h 
b/source/blender/io/alembic/intern/abc_customdata.h
index e98ec271b9f..4eb515f132c 100644
--- a/source/blender/io/alembic/intern/abc_customdata.h
+++ b/source/blender/io/alembic/intern/abc_customdata.h
@@ -66,6 +66,7 @@ struct CDStreamConfig {
 
   float weight;
   float time;
+  bool use_vertex_interpolation;
   Alembic::AbcGeom::index_t index;
   Alembic::AbcGeom::index_t ceil_index;
 
diff --git a/source/ble

[Bf-blender-cvs] [48a0c931eea] master: Fix T80121: Forcefield F-curve modifier changes don't reset cache

2020-09-28 Thread Sybren A. Stüvel
Commit: 48a0c931eea84fb072ce0b958090dda4b27cabff
Author: Sybren A. Stüvel
Date:   Mon Sep 28 17:13:40 2020 +0200
Branches: master
https://developer.blender.org/rB48a0c931eea84fb072ce0b958090dda4b27cabff

Fix T80121: Forcefield F-curve modifier changes don't reset cache

Add a dependency graph relation Force Object Animation → Scene Rigid
Body World Rebuild. This ensures that the rigid body world is rebuilt
when a force object is re-tagged for animation updates.

The extra relation doesn't add any new calculations when the animation
is running, as the Time Source node already had a relation to the
scene's `RIGIDBODY_REBUILD` node.

The relation is created directly to the `RIGIDBODY_REBUILD` Operation. I
would have liked to target the containing Component instead. However,
that has the `RIGIDBODY_SIM` operation as entry node, which isn't enough
to actually fix T80121.

Reviewers: Sergey

Differential Revision: https://developer.blender.org/T80121

===

M   source/blender/depsgraph/intern/builder/deg_builder_relations.cc
M   source/blender/depsgraph/intern/builder/deg_builder_relations.h

===

diff --git a/source/blender/depsgraph/intern/builder/deg_builder_relations.cc 
b/source/blender/depsgraph/intern/builder/deg_builder_relations.cc
index 14f9db767a9..525f9e304cb 100644
--- a/source/blender/depsgraph/intern/builder/deg_builder_relations.cc
+++ b/source/blender/depsgraph/intern/builder/deg_builder_relations.cc
@@ -1252,6 +1252,7 @@ void DepsgraphRelationBuilder::build_animdata(ID *id)
 ComponentKey animation_key(id, NodeType::ANIMATION);
 ComponentKey parameters_key(id, NodeType::PARAMETERS);
 add_relation(animation_key, parameters_key, "Animation -> Parameters");
+build_animdata_force(id);
   }
 }
 
@@ -1396,6 +1397,24 @@ void DepsgraphRelationBuilder::build_animation_images(ID 
*id)
   }
 }
 
+void DepsgraphRelationBuilder::build_animdata_force(ID *id)
+{
+  if (GS(id->name) != ID_OB) {
+return;
+  }
+
+  const Object *object = (Object *)id;
+  if (object->pd == nullptr || object->pd->forcefield == PFIELD_NULL) {
+return;
+  }
+
+  /* Updates to animation data (in the UI, for example by altering FCurve 
Modifier parameters
+   * animating force field strength) may need to rebuild the rigid body world. 
*/
+  ComponentKey animation_key(id, NodeType::ANIMATION);
+  OperationKey rigidbody_key(_->id, NodeType::TRANSFORM, 
OperationCode::RIGIDBODY_REBUILD);
+  add_relation(animation_key, rigidbody_key, "Animation -> Rigid Body");
+}
+
 void DepsgraphRelationBuilder::build_action(bAction *action)
 {
   if (built_map_.checkIsBuiltAndTag(action)) {
diff --git a/source/blender/depsgraph/intern/builder/deg_builder_relations.h 
b/source/blender/depsgraph/intern/builder/deg_builder_relations.h
index 39768b9fdb6..7f5e4cafeea 100644
--- a/source/blender/depsgraph/intern/builder/deg_builder_relations.h
+++ b/source/blender/depsgraph/intern/builder/deg_builder_relations.h
@@ -241,6 +241,7 @@ class DepsgraphRelationBuilder : public DepsgraphBuilder {
OperationNode *operation_from,
ListBase *strips);
   virtual void build_animdata_drivers(ID *id);
+  virtual void build_animdata_force(ID *id);
   virtual void build_animation_images(ID *id);
   virtual void build_action(bAction *action);
   virtual void build_driver(ID *id, FCurve *fcurve);

___
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
https://lists.blender.org/mailman/listinfo/bf-blender-cvs


[Bf-blender-cvs] [b88a9cf1714] master: Cleanup: Animation, fix comments

2020-09-28 Thread Sybren A. Stüvel
Commit: b88a9cf1714ba2b81b51035f6f302c10e2ebc6a2
Author: Sybren A. Stüvel
Date:   Mon Sep 28 12:04:19 2020 +0200
Branches: master
https://developer.blender.org/rBb88a9cf1714ba2b81b51035f6f302c10e2ebc6a2

Cleanup: Animation, fix comments

Remove one outdated comment, and make the other into a proper sentence.

No functional changes

===

M   source/blender/makesrna/intern/rna_fcurve.c

===

diff --git a/source/blender/makesrna/intern/rna_fcurve.c 
b/source/blender/makesrna/intern/rna_fcurve.c
index bbeebb4861e..12b8f9be675 100644
--- a/source/blender/makesrna/intern/rna_fcurve.c
+++ b/source/blender/makesrna/intern/rna_fcurve.c
@@ -590,12 +590,11 @@ static bool rna_FCurve_is_empty_get(PointerRNA *ptr)
 
 static void rna_tag_animation_update(Main *bmain, ID *id)
 {
-  /* Actually recalculate object properties, or just update COW. */
   const int tags = ID_RECALC_ANIMATION;
   AnimData *adt = BKE_animdata_from_id(id);
 
   if (adt && adt->action) {
-/* action is separate datablock, needs separate tag */
+/* Action is separate datablock, needs separate tag. */
 DEG_id_tag_update_ex(bmain, >action->id, tags);
   }

___
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
https://lists.blender.org/mailman/listinfo/bf-blender-cvs


[Bf-blender-cvs] [3158fc2593e] master: Fix T80967: Alembic, crash when the imported sim from Houdini starts

2020-09-28 Thread Sybren A. Stüvel
Commit: 3158fc2593e1afc29280187d9e427a6c21a8f37f
Author: Sybren A. Stüvel
Date:   Mon Sep 28 14:12:33 2020 +0200
Branches: master
https://developer.blender.org/rB3158fc2593e1afc29280187d9e427a6c21a8f37f

Fix T80967: Alembic, crash when the imported sim from Houdini starts

Compare mesh loop count with number of loop normals before reading the
loop normals.

Houdini doesn't always write the correct loop normals to Alembic. When a
mesh is animated and then replaced by a fluid simulation, Houdini will
still write the original mesh's loop normals, but the mesh
verts/loops/polys are from the simulation. In such cases the normals
cannot be mapped to the mesh, so it's better to ignore them.

===

M   source/blender/io/alembic/intern/abc_reader_mesh.cc

===

diff --git a/source/blender/io/alembic/intern/abc_reader_mesh.cc 
b/source/blender/io/alembic/intern/abc_reader_mesh.cc
index 5a42be2bb02..ead908e87c2 100644
--- a/source/blender/io/alembic/intern/abc_reader_mesh.cc
+++ b/source/blender/io/alembic/intern/abc_reader_mesh.cc
@@ -271,10 +271,19 @@ static void process_loop_normals(CDStreamConfig , 
const N3fArraySamplePtr
 return;
   }
 
+  Mesh *mesh = config.mesh;
+  if (loop_count != mesh->totloop) {
+/* This happens in certain Houdini exports. When a mesh is animated and 
then replaced by a
+ * fluid simulation, Houdini will still write the original mesh's loop 
normals, but the mesh
+ * verts/loops/polys are from the simulation. In such cases the normals 
cannot be mapped to the
+ * mesh, so it's better to ignore them. */
+process_no_normals(config);
+return;
+  }
+
   float(*lnors)[3] = static_cast(
   MEM_malloc_arrayN(loop_count, sizeof(float[3]), "ABC::FaceNormals"));
 
-  Mesh *mesh = config.mesh;
   MPoly *mpoly = mesh->mpoly;
   const N3fArraySample _normals = *loop_normals_ptr;
   int abc_index = 0;

___
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
https://lists.blender.org/mailman/listinfo/bf-blender-cvs


[Bf-blender-cvs] [825a32439aa] master: Cleanup: Animation, remove unused parameter from anim tagging function

2020-09-28 Thread Sybren A. Stüvel
Commit: 825a32439aae577afd424fba48094cb8f92d2541
Author: Sybren A. Stüvel
Date:   Mon Sep 28 12:03:04 2020 +0200
Branches: master
https://developer.blender.org/rB825a32439aae577afd424fba48094cb8f92d2541

Cleanup: Animation, remove unused parameter from anim tagging function

Remove `bool flush` parameter from `rna_tag_animation_update()`, as every
call uses `true` anyway.

No functional changes.

===

M   source/blender/makesrna/intern/rna_fcurve.c

===

diff --git a/source/blender/makesrna/intern/rna_fcurve.c 
b/source/blender/makesrna/intern/rna_fcurve.c
index ac4395f08c9..bbeebb4861e 100644
--- a/source/blender/makesrna/intern/rna_fcurve.c
+++ b/source/blender/makesrna/intern/rna_fcurve.c
@@ -588,11 +588,10 @@ static bool rna_FCurve_is_empty_get(PointerRNA *ptr)
   return BKE_fcurve_is_empty(fcu);
 }
 
-static void rna_tag_animation_update(Main *bmain, ID *id, bool flush)
+static void rna_tag_animation_update(Main *bmain, ID *id)
 {
   /* Actually recalculate object properties, or just update COW. */
-  int tags = flush ? ID_RECALC_ANIMATION : ID_RECALC_ANIMATION_NO_FLUSH;
-
+  const int tags = ID_RECALC_ANIMATION;
   AnimData *adt = BKE_animdata_from_id(id);
 
   if (adt && adt->action) {
@@ -609,7 +608,7 @@ static void rna_FCurve_update_data_ex(ID *id, FCurve *fcu, 
Main *bmain)
   sort_time_fcurve(fcu);
   calchandles_fcurve(fcu);
 
-  rna_tag_animation_update(bmain, id, true);
+  rna_tag_animation_update(bmain, id);
 }
 
 /* RNA update callback for F-Curves after curve shape changes */
@@ -631,7 +630,7 @@ static void rna_FCurve_update_data_relations(Main *bmain,
  */
 static void rna_FCurve_update_eval(Main *bmain, Scene *UNUSED(scene), 
PointerRNA *ptr)
 {
-  rna_tag_animation_update(bmain, ptr->owner_id, true);
+  rna_tag_animation_update(bmain, ptr->owner_id);
 }
 
 static PointerRNA rna_FCurve_active_modifier_get(PointerRNA *ptr)
@@ -751,7 +750,7 @@ static void rna_FModifier_update(Main *bmain, Scene 
*UNUSED(scene), PointerRNA *
 calchandles_fcurve(fcm->curve);
   }
 
-  rna_tag_animation_update(bmain, id, true);
+  rna_tag_animation_update(bmain, id);
 }
 
 static void rna_FModifier_verify_data_update(Main *bmain, Scene *scene, 
PointerRNA *ptr)
@@ -977,7 +976,7 @@ static BezTriple *rna_FKeyframe_points_insert(
   fcu, frame, value, (char)keyframe_type, flag | INSERTKEY_NO_USERPREF);
 
   if ((fcu->bezt) && (index >= 0)) {
-rna_tag_animation_update(bmain, id, true);
+rna_tag_animation_update(bmain, id);
 
 return fcu->bezt + index;
   }
@@ -1003,7 +1002,7 @@ static void rna_FKeyframe_points_add(ID *id, FCurve *fcu, 
Main *bmain, int tot)
   bezt++;
 }
 
-rna_tag_animation_update(bmain, id, true);
+rna_tag_animation_update(bmain, id);
   }
 }
 
@@ -1020,7 +1019,7 @@ static void rna_FKeyframe_points_remove(
   delete_fcurve_key(fcu, index, !do_fast);
   RNA_POINTER_INVALIDATE(bezt_ptr);
 
-  rna_tag_animation_update(bmain, id, true);
+  rna_tag_animation_update(bmain, id);
 }
 
 static FCM_EnvelopeData *rna_FModifierEnvelope_points_add(
@@ -1030,7 +1029,7 @@ static FCM_EnvelopeData *rna_FModifierEnvelope_points_add(
   FMod_Envelope *env = (FMod_Envelope *)fmod->data;
   int i;
 
-  rna_tag_animation_update(bmain, id, true);
+  rna_tag_animation_update(bmain, id);
 
   /* init template data */
   fed.min = -1.0f;
@@ -1082,7 +1081,7 @@ static void rna_FModifierEnvelope_points_remove(
 return;
   }
 
-  rna_tag_animation_update(bmain, id, true);
+  rna_tag_animation_update(bmain, id);
 
   if (env->totvert > 1) {
 /* move data after the removed point */
@@ -1109,7 +1108,7 @@ static void rna_FModifierEnvelope_points_remove(
 
 static void rna_Keyframe_update(Main *bmain, Scene *UNUSED(scene), PointerRNA 
*ptr)
 {
-  rna_tag_animation_update(bmain, ptr->owner_id, true);
+  rna_tag_animation_update(bmain, ptr->owner_id);
 }
 
 #else

___
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
https://lists.blender.org/mailman/listinfo/bf-blender-cvs


[Bf-blender-cvs] [3fe97bced44] master: Cleanup: animation, split up ANIM_flush_setting_anim_channels()

2020-09-28 Thread Sybren A. Stüvel
Commit: 3fe97bced448d9f080057087b2b92cc8b9213dc4
Author: Sybren A. Stüvel
Date:   Fri Sep 25 16:03:00 2020 +0200
Branches: master
https://developer.blender.org/rB3fe97bced448d9f080057087b2b92cc8b9213dc4

Cleanup: animation, split up ANIM_flush_setting_anim_channels()

Split up `ANIM_flush_setting_anim_channels()` into smaller functions. This
makes it easier to understand how it works, and makes future improvements
also easier.

No functional changes.

===

M   source/blender/editors/animation/anim_channels_edit.c

===

diff --git a/source/blender/editors/animation/anim_channels_edit.c 
b/source/blender/editors/animation/anim_channels_edit.c
index 560b14bfd9a..be4ee859f89 100644
--- a/source/blender/editors/animation/anim_channels_edit.c
+++ b/source/blender/editors/animation/anim_channels_edit.c
@@ -461,64 +461,14 @@ void ANIM_deselect_anim_channels(
 
 /*  Graph Editor 
- */
 
-/* Flush visibility (for Graph Editor) changes up/down hierarchy for changes 
in the given setting
- * - anim_data: list of the all the anim channels that can be chosen
- *   -> filtered using ANIMFILTER_CHANNELS only, since if we took VISIBLE too,
- *  then the channels under closed expanders get ignored...
- * - ale_setting: the anim channel (not in the anim_data list directly, though 
occurring there)
- *   with the new state of the setting that we want flushed up/down the 
hierarchy
- * - setting: type of setting to set
- * - on: whether the visibility setting has been enabled or disabled
- */
-void ANIM_flush_setting_anim_channels(bAnimContext *ac,
-  ListBase *anim_data,
-  bAnimListElem *ale_setting,
-  eAnimChannel_Settings setting,
-  eAnimChannels_SetFlag mode)
+/* Copy a certain channel setting to parents of the modified channel. */
+static void anim_flush_channel_setting_up(bAnimContext *ac,
+  const eAnimChannel_Settings setting,
+  const eAnimChannels_SetFlag mode,
+  bAnimListElem *const match,
+  const int matchLevel)
 {
-  bAnimListElem *ale, *match = NULL;
-  int prevLevel = 0, matchLevel = 0;
-
-  /* sanity check */
-  if (ELEM(NULL, anim_data, anim_data->first)) {
-return;
-  }
-
-  if (setting == ACHANNEL_SETTING_ALWAYS_VISIBLE) {
-return;
-  }
-
-  /* find the channel that got changed */
-  for (ale = anim_data->first; ale; ale = ale->next) {
-/* compare data, and type as main way of identifying the channel */
-if ((ale->data == ale_setting->data) && (ale->type == ale_setting->type)) {
-  /* We also have to check the ID, this is assigned to,
-   * since a block may have multiple users. */
-  /* TODO: is the owner-data more revealing? */
-  if (ale->id == ale_setting->id) {
-match = ale;
-break;
-  }
-}
-  }
-  if (match == NULL) {
-printf("ERROR: no channel matching the one changed was found\n");
-return;
-  }
-
-  {
-const bAnimChannelType *acf = ANIM_channel_get_typeinfo(ale_setting);
-if (acf == NULL) {
-  printf("ERROR: no channel info for the changed channel\n");
-  return;
-}
-
-/* get the level of the channel that was affected
- *   - we define the level as simply being the offset for the start of the 
channel
- */
-matchLevel = (acf->get_offset) ? acf->get_offset(ac, ale_setting) : 0;
-prevLevel = matchLevel;
-  }
+  int prevLevel = matchLevel;
 
   /* flush up?
*
@@ -534,9 +484,8 @@ void ANIM_flush_setting_anim_channels(bAnimContext *ac,
   ((setting != ACHANNEL_SETTING_VISIBLE) && (mode == 
ACHANNEL_SETFLAG_CLEAR))) {
 /* Go backwards in the list, until the highest-ranking element
  * (by indention has been covered). */
-for (ale = match->prev; ale; ale = ale->prev) {
+for (bAnimListElem *ale = match->prev; ale; ale = ale->prev) {
   const bAnimChannelType *acf = ANIM_channel_get_typeinfo(ale);
-  int level;
 
   /* if no channel info was found, skip, since this type might not have 
any useful info */
   if (acf == NULL) {
@@ -546,7 +495,7 @@ void ANIM_flush_setting_anim_channels(bAnimContext *ac,
   /* get the level of the current channel traversed
*   - we define the level as simply being the offset for the start of 
the channel
*/
-  level = (acf->get_offset) ? acf->get_offset(ac, ale) : 0;
+  const int level = (acf->get_offset) ? acf->get_offset(ac, ale) : 0;
 
   /* if the level is 'less than' (i.e. more important) the level we'

[Bf-blender-cvs] [f808f2a4950] master: Fix T81214: Crash on Action constraint without action

2020-09-28 Thread Sybren A. Stüvel
Commit: f808f2a4950a99f74780ea87e9d62ee36bc4ff35
Author: Sybren A. Stüvel
Date:   Mon Sep 28 11:23:34 2020 +0200
Branches: master
https://developer.blender.org/rBf808f2a4950a99f74780ea87e9d62ee36bc4ff35

Fix T81214: Crash on Action constraint without action

A `NULL` pointer check was missing.

===

M   source/blender/blenkernel/intern/anim_data.c

===

diff --git a/source/blender/blenkernel/intern/anim_data.c 
b/source/blender/blenkernel/intern/anim_data.c
index eb2cdf585c4..e7c6e00a61f 100644
--- a/source/blender/blenkernel/intern/anim_data.c
+++ b/source/blender/blenkernel/intern/anim_data.c
@@ -239,6 +239,11 @@ bool BKE_animdata_action_ensure_idroot(const ID *owner, 
bAction *action)
 {
   const int idcode = GS(owner->name);
 
+  if (action == NULL) {
+/* A NULL action is usable by any ID type. */
+return true;
+  }
+
   if (action->idroot == 0) {
 /* First time this Action is assigned, lock it to this ID type. */
 action->idroot = idcode;

___
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
https://lists.blender.org/mailman/listinfo/bf-blender-cvs


[Bf-blender-cvs] [1f5331ee870] master: Cleanup: animation, simplify `anim_flush_channel_setting_up()`

2020-09-28 Thread Sybren A. Stüvel
Commit: 1f5331ee87018cb51a029d786ef138653815e56e
Author: Sybren A. Stüvel
Date:   Fri Sep 25 16:30:01 2020 +0200
Branches: master
https://developer.blender.org/rB1f5331ee87018cb51a029d786ef138653815e56e

Cleanup: animation, simplify `anim_flush_channel_setting_up()`

Simplify `anim_flush_channel_setting_up()` by flipping conditions and
returning early. This makes it easier to understand what is actually
happening in the code.

No functional changes.

===

M   source/blender/editors/animation/anim_channels_edit.c

===

diff --git a/source/blender/editors/animation/anim_channels_edit.c 
b/source/blender/editors/animation/anim_channels_edit.c
index be4ee859f89..80976d150c0 100644
--- a/source/blender/editors/animation/anim_channels_edit.c
+++ b/source/blender/editors/animation/anim_channels_edit.c
@@ -468,8 +468,6 @@ static void anim_flush_channel_setting_up(bAnimContext *ac,
   bAnimListElem *const match,
   const int matchLevel)
 {
-  int prevLevel = matchLevel;
-
   /* flush up?
*
* For Visibility:
@@ -480,49 +478,57 @@ static void anim_flush_channel_setting_up(bAnimContext 
*ac,
* - only flush up if the current state is now disabled (negative 'off' 
state is default)
*   (otherwise, it's too much work to force the parents to be active too)
*/
-  if (((setting == ACHANNEL_SETTING_VISIBLE) && (mode != 
ACHANNEL_SETFLAG_CLEAR)) ||
-  ((setting != ACHANNEL_SETTING_VISIBLE) && (mode == 
ACHANNEL_SETFLAG_CLEAR))) {
-/* Go backwards in the list, until the highest-ranking element
- * (by indention has been covered). */
-for (bAnimListElem *ale = match->prev; ale; ale = ale->prev) {
-  const bAnimChannelType *acf = ANIM_channel_get_typeinfo(ale);
+  if (setting == ACHANNEL_SETTING_VISIBLE) {
+if (mode == ACHANNEL_SETFLAG_CLEAR) {
+  return;
+}
+  }
+  else {
+if (mode != ACHANNEL_SETFLAG_CLEAR) {
+  return;
+}
+  }
 
-  /* if no channel info was found, skip, since this type might not have 
any useful info */
-  if (acf == NULL) {
-continue;
-  }
+  /* Go backwards in the list, until the highest-ranking element
+   * (by indention has been covered). */
+  int prevLevel = matchLevel;
+  for (bAnimListElem *ale = match->prev; ale; ale = ale->prev) {
+const bAnimChannelType *acf = ANIM_channel_get_typeinfo(ale);
 
-  /* get the level of the current channel traversed
-   *   - we define the level as simply being the offset for the start of 
the channel
-   */
-  const int level = (acf->get_offset) ? acf->get_offset(ac, ale) : 0;
+/* if no channel info was found, skip, since this type might not have any 
useful info */
+if (acf == NULL) {
+  continue;
+}
 
-  /* if the level is 'less than' (i.e. more important) the level we're 
matching
-   * but also 'less than' the level just tried (i.e. only the 1st group 
above grouped F-Curves,
-   * when toggling visibility of F-Curves, gets flushed, which should 
happen if we don't let
-   * prevLevel get updated below once the first 1st group is found).
-   */
-  if (level < prevLevel) {
-/* flush the new status... */
-ANIM_channel_setting_set(ac, ale, setting, mode);
+/* Get the level of the current channel traversed
+ *   - we define the level as simply being the offset for the start of the 
channel
+ */
+const int level = (acf->get_offset) ? acf->get_offset(ac, ale) : 0;
 
-/* store this level as the 'old' level now */
-prevLevel = level;
-  }
-  /* if the level is 'greater than' (i.e. less important) than the 
previous level... */
-  else if (level > prevLevel) {
-/* if previous level was a base-level (i.e. 0 offset / root of one 
hierarchy),
- * stop here
- */
-if (prevLevel == 0) {
-  break;
-  /* otherwise, this level weaves into another sibling hierarchy to 
the previous one just
-   * finished, so skip until we get to the parent of this level
-   */
-}
-continue;
+if (level == prevLevel) {
+  /* Don't influence siblings. */
+  continue;
+}
+
+if (level > prevLevel) {
+  /* If previous level was a base-level (i.e. 0 offset / root of one 
hierarchy), stop here. */
+  if (prevLevel == 0) {
+return;
   }
+
+  /* Otherwise, this level weaves into another sibling hierarchy to the 
previous one just
+   * finished, so skip until we get to the parent of this level. */
+  continue;
 }
+
+/* The level is 'less than' (i.e. more important) the level we're matching 
but also 'less
+ * than' the level just tried (i.e. only the 1st group above grouped 
F-Curves, when toggling
+ * v

[Bf-blender-cvs] [64583f3e8d0] master: Animation: set Action `idroot` at assignment instead of just at evaluation

2020-09-25 Thread Sybren A. Stüvel
Commit: 64583f3e8d0f337a977c9a90b874bee733a37402
Author: Sybren A. Stüvel
Date:   Fri Sep 25 11:07:32 2020 +0200
Branches: master
https://developer.blender.org/rB64583f3e8d0f337a977c9a90b874bee733a37402

Animation: set Action `idroot` at assignment instead of just at evaluation

Actions are either locked to a specific ID type, or "floating". Actions
in the floating state are now locked when they are assigned to an ID block.
Previously (rB94b99b5d4a7c20cf2) this was done at evaluation time, which
caused various problems:
- The ID type was set on the evaluated copy, and inconsistently flushed
  back to the original.
- A newly created Action could not be assigned to an Action constraint,
  unless a depsgraph evaluation was be forced first.

This is now resolved by calling `BKE_animdata_set_action()` to set the
action (instead of direct assignment) where possible, and calling
`BKE_animdata_action_ensure_idroot()` otherwise.

Manifest Task: https://developer.blender.org/T80986

===

M   source/blender/blenkernel/BKE_anim_data.h
M   source/blender/blenkernel/intern/action.c
M   source/blender/blenkernel/intern/anim_data.c
M   source/blender/editors/animation/keyframing.c
M   source/blender/makesdna/DNA_anim_types.h
M   source/blender/makesrna/intern/rna_space.c

===

diff --git a/source/blender/blenkernel/BKE_anim_data.h 
b/source/blender/blenkernel/BKE_anim_data.h
index 48ea06ea9d8..5293d8dd9b0 100644
--- a/source/blender/blenkernel/BKE_anim_data.h
+++ b/source/blender/blenkernel/BKE_anim_data.h
@@ -58,6 +58,10 @@ bool BKE_animdata_set_action(struct ReportList *reports, 
struct ID *id, struct b
 
 bool BKE_animdata_action_editable(const struct AnimData *adt);
 
+/* Ensure that the action's idroot is set correctly given the ID type of the 
owner.
+ * Return true if it is, false if it was already set to an incompatible type. 
*/
+bool BKE_animdata_action_ensure_idroot(const struct ID *owner, struct bAction 
*action);
+
 /* Free AnimData */
 void BKE_animdata_free(struct ID *id, const bool do_id_user);
 
diff --git a/source/blender/blenkernel/intern/action.c 
b/source/blender/blenkernel/intern/action.c
index 64a8ae15fd3..1ce0d07a135 100644
--- a/source/blender/blenkernel/intern/action.c
+++ b/source/blender/blenkernel/intern/action.c
@@ -47,6 +47,7 @@
 #include "BLT_translation.h"
 
 #include "BKE_action.h"
+#include "BKE_anim_data.h"
 #include "BKE_anim_visualization.h"
 #include "BKE_animsys.h"
 #include "BKE_armature.h"
@@ -1817,6 +1818,7 @@ void what_does_obaction(Object *ob,
 workob->adt = 
 
 adt.action = act;
+BKE_animdata_action_ensure_idroot(>id, act);
 
 /* execute effects of Action on to workob (or it's PoseChannels) */
 BKE_animsys_evaluate_animdata(>id, , anim_eval_context, 
ADT_RECALC_ANIM, false);
diff --git a/source/blender/blenkernel/intern/anim_data.c 
b/source/blender/blenkernel/intern/anim_data.c
index 30b75734e77..eb2cdf585c4 100644
--- a/source/blender/blenkernel/intern/anim_data.c
+++ b/source/blender/blenkernel/intern/anim_data.c
@@ -186,6 +186,11 @@ bool BKE_animdata_set_action(ReportList *reports, ID *id, 
bAction *act)
 return false;
   }
 
+  if (adt->action == act) {
+/* Don't bother reducing and increasing the user count when there is 
nothing changing. */
+return true;
+  }
+
   if (!BKE_animdata_action_editable(adt)) {
 /* Cannot remove, otherwise things turn to custard. */
 BKE_report(reports, RPT_ERROR, "Cannot change action, as it is still being 
edited in NLA");
@@ -204,7 +209,7 @@ bool BKE_animdata_set_action(ReportList *reports, ID *id, 
bAction *act)
   }
 
   /* Action must have same type as owner. */
-  if (!ELEM(act->idroot, 0, GS(id->name))) {
+  if (!BKE_animdata_action_ensure_idroot(id, act)) {
 /* Cannot set to this type. */
 BKE_reportf(
 reports,
@@ -230,6 +235,19 @@ bool BKE_animdata_action_editable(const AnimData *adt)
   return !is_tweaking_strip;
 }
 
+bool BKE_animdata_action_ensure_idroot(const ID *owner, bAction *action)
+{
+  const int idcode = GS(owner->name);
+
+  if (action->idroot == 0) {
+/* First time this Action is assigned, lock it to this ID type. */
+action->idroot = idcode;
+return true;
+  }
+
+  return (action->idroot == idcode);
+}
+
 /* Freeing  */
 
 /* Free AnimData used by the nominated ID-block, and clear ID-block's AnimData 
pointer */
@@ -673,6 +691,7 @@ void BKE_animdata_transfer_by_basepath(Main *bmain, ID 
*srcID, ID *dstID, ListBa
  * and name it in a similar way so that it can be easily found again. */
 if (dstAdt->action == NULL) {
   dstAdt->action = BKE_action_add(bmain, srcAdt->action->id.name + 2);
+  BKE_animdata_action_ensure_i

[Bf-blender-cvs] [8ffd03aef7b] master: Cleanup: animation, remove commented-out code

2020-09-25 Thread Sybren A. Stüvel
Commit: 8ffd03aef7b06d63d340e0b6892229927439e20f
Author: Sybren A. Stüvel
Date:   Fri Sep 25 10:16:01 2020 +0200
Branches: master
https://developer.blender.org/rB8ffd03aef7b06d63d340e0b6892229927439e20f

Cleanup: animation, remove commented-out code

The code was commented out in rB6307c65534f6d5cf29d08220cea0dbcca9a0e118,
11 years ago.

No functional changes.

===

M   source/blender/makesrna/intern/rna_space.c

===

diff --git a/source/blender/makesrna/intern/rna_space.c 
b/source/blender/makesrna/intern/rna_space.c
index 18c80006496..c04f6dbcc94 100644
--- a/source/blender/makesrna/intern/rna_space.c
+++ b/source/blender/makesrna/intern/rna_space.c
@@ -1924,8 +1924,8 @@ static void 
rna_SpaceDopeSheetEditor_action_update(bContext *C, PointerRNA *ptr)
   Main *bmain = CTX_data_main(C);
   Object *obact = OBACT(view_layer);
 
-  /* we must set this action to be the one used by active object (if not 
pinned) */
-  if (obact /* && saction->pin == 0*/) {
+  /* We must set this action to be the one used by active object. */
+  if (obact) {
 AnimData *adt = NULL;
 
 if (saction->mode == SACTCONT_ACTION) {

___
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
https://lists.blender.org/mailman/listinfo/bf-blender-cvs


[Bf-blender-cvs] [2ef68edad8b] master: Cleanup: animation, deduplicate "can edit action" logic

2020-09-25 Thread Sybren A. Stüvel
Commit: 2ef68edad8b9832d55c185d4db948417e74ae8c2
Author: Sybren A. Stüvel
Date:   Thu Sep 24 18:22:30 2020 +0200
Branches: master
https://developer.blender.org/rB2ef68edad8b9832d55c185d4db948417e74ae8c2

Cleanup: animation, deduplicate "can edit action" logic

Move "action editable" check from RNA code to Blender kernel
`BKE_animdata_action_editable()`.

No functional changes.

===

M   source/blender/blenkernel/BKE_anim_data.h
M   source/blender/blenkernel/intern/anim_data.c
M   source/blender/makesrna/intern/rna_animation.c

===

diff --git a/source/blender/blenkernel/BKE_anim_data.h 
b/source/blender/blenkernel/BKE_anim_data.h
index 8507793b1dc..48ea06ea9d8 100644
--- a/source/blender/blenkernel/BKE_anim_data.h
+++ b/source/blender/blenkernel/BKE_anim_data.h
@@ -56,6 +56,8 @@ struct AnimData *BKE_animdata_add_id(struct ID *id);
 /* Set active action used by AnimData from the given ID-block */
 bool BKE_animdata_set_action(struct ReportList *reports, struct ID *id, struct 
bAction *act);
 
+bool BKE_animdata_action_editable(const struct AnimData *adt);
+
 /* Free AnimData */
 void BKE_animdata_free(struct ID *id, const bool do_id_user);
 
diff --git a/source/blender/blenkernel/intern/anim_data.c 
b/source/blender/blenkernel/intern/anim_data.c
index 24908469a77..30b75734e77 100644
--- a/source/blender/blenkernel/intern/anim_data.c
+++ b/source/blender/blenkernel/intern/anim_data.c
@@ -180,17 +180,14 @@ bool BKE_animdata_set_action(ReportList *reports, ID *id, 
bAction *act)
 {
   AnimData *adt = BKE_animdata_from_id(id);
 
-  /* animdata validity check */
+  /* Animdata validity check. */
   if (adt == NULL) {
 BKE_report(reports, RPT_WARNING, "No AnimData to set action on");
 return false;
   }
 
-  /* active action is only editable when it is not a tweaking strip
-   * see rna_AnimData_action_editable() in rna_animation.c
-   */
-  if ((adt->flag & ADT_NLA_EDIT_ON) || (adt->actstrip) || (adt->tmpact)) {
-/* cannot remove, otherwise things turn to custard */
+  if (!BKE_animdata_action_editable(adt)) {
+/* Cannot remove, otherwise things turn to custard. */
 BKE_report(reports, RPT_ERROR, "Cannot change action, as it is still being 
edited in NLA");
 return false;
   }
@@ -200,8 +197,6 @@ bool BKE_animdata_set_action(ReportList *reports, ID *id, 
bAction *act)
 id_us_min((ID *)adt->action);
   }
 
-  /* Assume that AnimData's action can in fact be edited. */
-
   if (act == NULL) {
 /* Just clearing the action. */
 adt->action = NULL;
@@ -227,6 +222,14 @@ bool BKE_animdata_set_action(ReportList *reports, ID *id, 
bAction *act)
   return true;
 }
 
+bool BKE_animdata_action_editable(const AnimData *adt)
+{
+  /* Active action is only editable when it is not a tweaking strip. */
+  const bool is_tweaking_strip = (adt->flag & ADT_NLA_EDIT_ON) || 
adt->actstrip != NULL ||
+ adt->tmpact != NULL;
+  return !is_tweaking_strip;
+}
+
 /* Freeing  */
 
 /* Free AnimData used by the nominated ID-block, and clear ID-block's AnimData 
pointer */
diff --git a/source/blender/makesrna/intern/rna_animation.c 
b/source/blender/makesrna/intern/rna_animation.c
index 823446a9d3b..a50d27a726b 100644
--- a/source/blender/makesrna/intern/rna_animation.c
+++ b/source/blender/makesrna/intern/rna_animation.c
@@ -144,14 +144,7 @@ static void rna_AnimData_dependency_update(Main *bmain, 
Scene *scene, PointerRNA
 static int rna_AnimData_action_editable(PointerRNA *ptr, const char 
**UNUSED(r_info))
 {
   AnimData *adt = (AnimData *)ptr->data;
-
-  /* active action is only editable when it is not a tweaking strip */
-  if ((adt->flag & ADT_NLA_EDIT_ON) || (adt->actstrip) || (adt->tmpact)) {
-return 0;
-  }
-  else {
-return PROP_EDITABLE;
-  }
+  return BKE_animdata_action_editable(adt) ? PROP_EDITABLE : 0;
 }
 
 static void rna_AnimData_action_set(PointerRNA *ptr,

___
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
https://lists.blender.org/mailman/listinfo/bf-blender-cvs


[Bf-blender-cvs] [2e1339bc0b5] master: Cleanup: document and simplify `BKE_animdata_set_action()`

2020-09-25 Thread Sybren A. Stüvel
Commit: 2e1339bc0b55bcde8d2f3936011c645aab8b263c
Author: Sybren A. Stüvel
Date:   Thu Sep 24 18:08:59 2020 +0200
Branches: master
https://developer.blender.org/rB2e1339bc0b55bcde8d2f3936011c645aab8b263c

Cleanup: document and simplify `BKE_animdata_set_action()`

Simplify `BKE_animdata_set_action()` by flipping some conditions and using
early returns, and document which parameters can be `NULL`.

No functional changes.

===

M   source/blender/blenkernel/intern/anim_data.c

===

diff --git a/source/blender/blenkernel/intern/anim_data.c 
b/source/blender/blenkernel/intern/anim_data.c
index 4d815077e91..24908469a77 100644
--- a/source/blender/blenkernel/intern/anim_data.c
+++ b/source/blender/blenkernel/intern/anim_data.c
@@ -169,16 +169,21 @@ AnimData *BKE_animdata_add_id(ID *id)
 /**
  * Called when user tries to change the active action of an AnimData block
  * (via RNA, Outliner, etc.)
+ *
+ * \param reports can be NULL.
+ * \param id the owner of the animation data
+ * \param act the Action to set, or NULL to clear.
+ *
+ * Return true when the action was succesfully updated, false otherwise.
  */
 bool BKE_animdata_set_action(ReportList *reports, ID *id, bAction *act)
 {
   AnimData *adt = BKE_animdata_from_id(id);
-  bool ok = false;
 
   /* animdata validity check */
   if (adt == NULL) {
 BKE_report(reports, RPT_WARNING, "No AnimData to set action on");
-return ok;
+return false;
   }
 
   /* active action is only editable when it is not a tweaking strip
@@ -187,42 +192,39 @@ bool BKE_animdata_set_action(ReportList *reports, ID *id, 
bAction *act)
   if ((adt->flag & ADT_NLA_EDIT_ON) || (adt->actstrip) || (adt->tmpact)) {
 /* cannot remove, otherwise things turn to custard */
 BKE_report(reports, RPT_ERROR, "Cannot change action, as it is still being 
edited in NLA");
-return ok;
+return false;
   }
 
-  /* manage usercount for current action */
+  /* Reduce usercount for current action. */
   if (adt->action) {
 id_us_min((ID *)adt->action);
   }
 
-  /* assume that AnimData's action can in fact be edited... */
-  if (act) {
-/* action must have same type as owner */
-if (ELEM(act->idroot, 0, GS(id->name))) {
-  /* can set */
-  adt->action = act;
-  id_us_plus((ID *)adt->action);
-  ok = true;
-}
-else {
-  /* cannot set */
-  BKE_reportf(
-  reports,
-  RPT_ERROR,
-  "Could not set action '%s' onto ID '%s', as it does not have 
suitably rooted paths "
-  "for this purpose",
-  act->id.name + 2,
-  id->name);
-  /* ok = false; */
-}
-  }
-  else {
-/* just clearing the action... */
+  /* Assume that AnimData's action can in fact be edited. */
+
+  if (act == NULL) {
+/* Just clearing the action. */
 adt->action = NULL;
-ok = true;
+return true;
   }
 
-  return ok;
+  /* Action must have same type as owner. */
+  if (!ELEM(act->idroot, 0, GS(id->name))) {
+/* Cannot set to this type. */
+BKE_reportf(
+reports,
+RPT_ERROR,
+"Could not set action '%s' onto ID '%s', as it does not have suitably 
rooted paths "
+"for this purpose",
+act->id.name + 2,
+id->name);
+return false;
+  }
+
+  adt->action = act;
+  id_us_plus((ID *)adt->action);
+
+  return true;
 }
 
 /* Freeing  */

___
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
https://lists.blender.org/mailman/listinfo/bf-blender-cvs


  1   2   3   4   5   6   7   8   9   10   >