From 42360e64dab6d61877898669eb711bcdd8eed504 Mon Sep 17 00:00:00 2001 From: Jeroen Bakker Date: Mon, 20 Jan 2020 08:37:04 +0100 Subject: [PATCH 1/3] Fix T73233: Image Editor Color Picker Crash When using the color picker on a image editor it tries to read the color from the original image. When there is no original image the code crashes during the determination of the UDIM tile number. There are 2 approaches to solve this. 1. Modify `BKE_image_get_tile_from_pos` to support NULL pointers. 2. Modify `ED_space_image_color_sample` with an early exit. This patch modifies `ED_space_image_color_sample` with an early exit. Reviewed By: brecht Differential Revision: https://developer.blender.org/D6629 --- source/blender/editors/space_image/image_ops.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/source/blender/editors/space_image/image_ops.c b/source/blender/editors/space_image/image_ops.c index 2ed8b8c87ff..17c6f76a1d9 100644 --- a/source/blender/editors/space_image/image_ops.c +++ b/source/blender/editors/space_image/image_ops.c @@ -3356,6 +3356,9 @@ static void image_sample_draw(const bContext *C, ARegion *ar, void *arg_info) /* Returns color in linear space, matching ED_space_node_color_sample(). */ bool ED_space_image_color_sample(SpaceImage *sima, ARegion *ar, int mval[2], float r_col[3]) { + if (sima->image == NULL) { + return false; + } float uv[2]; UI_view2d_region_to_view(&ar->v2d, mval[0], mval[1], &uv[0], &uv[1]); int tile = BKE_image_get_tile_from_pos(sima->image, uv, uv, NULL); From 3436eea1f5ccb458c383b8d86759a5cf6cf59381 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Wed, 22 Jan 2020 02:50:28 +1100 Subject: [PATCH 2/3] Fix T73297: Incorrect lock properties tooltip --- source/blender/makesrna/intern/rna_object.c | 8 ++++---- source/blender/makesrna/intern/rna_pose.c | 8 ++++---- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/source/blender/makesrna/intern/rna_object.c b/source/blender/makesrna/intern/rna_object.c index 75594d1b295..950fa49db2e 100644 --- a/source/blender/makesrna/intern/rna_object.c +++ b/source/blender/makesrna/intern/rna_object.c @@ -2663,14 +2663,14 @@ static void rna_def_object(BlenderRNA *brna) prop = RNA_def_property(srna, "lock_location", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "protectflag", OB_LOCK_LOCX); RNA_def_property_array(prop, 3); - RNA_def_property_ui_text(prop, "Lock Location", "Lock editing of location in the interface"); + RNA_def_property_ui_text(prop, "Lock Location", "Lock editing of location when transforming"); RNA_def_property_ui_icon(prop, ICON_UNLOCKED, 1); RNA_def_property_update(prop, NC_OBJECT | ND_TRANSFORM, "rna_Object_internal_update"); prop = RNA_def_property(srna, "lock_rotation", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "protectflag", OB_LOCK_ROTX); RNA_def_property_array(prop, 3); - RNA_def_property_ui_text(prop, "Lock Rotation", "Lock editing of rotation in the interface"); + RNA_def_property_ui_text(prop, "Lock Rotation", "Lock editing of rotation when transforming"); RNA_def_property_ui_icon(prop, ICON_UNLOCKED, 1); RNA_def_property_update(prop, NC_OBJECT | ND_TRANSFORM, "rna_Object_internal_update"); @@ -2682,7 +2682,7 @@ static void rna_def_object(BlenderRNA *brna) RNA_def_property_ui_text( prop, "Lock Rotation (4D Angle)", - "Lock editing of 'angle' component of four-component rotations in the interface"); + "Lock editing of 'angle' component of four-component rotations when transforming"); /* XXX this needs a better name */ prop = RNA_def_property(srna, "lock_rotations_4d", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "protectflag", OB_LOCK_ROT4D); @@ -2694,7 +2694,7 @@ static void rna_def_object(BlenderRNA *brna) prop = RNA_def_property(srna, "lock_scale", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "protectflag", OB_LOCK_SCALEX); RNA_def_property_array(prop, 3); - RNA_def_property_ui_text(prop, "Lock Scale", "Lock editing of scale in the interface"); + RNA_def_property_ui_text(prop, "Lock Scale", "Lock editing of scale when transforming"); RNA_def_property_ui_icon(prop, ICON_UNLOCKED, 1); RNA_def_property_update(prop, NC_OBJECT | ND_TRANSFORM, "rna_Object_internal_update"); diff --git a/source/blender/makesrna/intern/rna_pose.c b/source/blender/makesrna/intern/rna_pose.c index 43d0402d00a..85c4352d277 100644 --- a/source/blender/makesrna/intern/rna_pose.c +++ b/source/blender/makesrna/intern/rna_pose.c @@ -1356,7 +1356,7 @@ static void rna_def_pose_channel(BlenderRNA *brna) prop = RNA_def_property(srna, "lock_location", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "protectflag", OB_LOCK_LOCX); RNA_def_property_array(prop, 3); - RNA_def_property_ui_text(prop, "Lock Location", "Lock editing of location in the interface"); + RNA_def_property_ui_text(prop, "Lock Location", "Lock editing of location when transforming"); RNA_def_property_ui_icon(prop, ICON_UNLOCKED, 1); RNA_def_property_editable_func(prop, "rna_PoseChannel_proxy_editable"); RNA_def_property_update(prop, NC_OBJECT | ND_POSE, "rna_Pose_update"); @@ -1364,7 +1364,7 @@ static void rna_def_pose_channel(BlenderRNA *brna) prop = RNA_def_property(srna, "lock_rotation", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "protectflag", OB_LOCK_ROTX); RNA_def_property_array(prop, 3); - RNA_def_property_ui_text(prop, "Lock Rotation", "Lock editing of rotation in the interface"); + RNA_def_property_ui_text(prop, "Lock Rotation", "Lock editing of rotation when transforming"); RNA_def_property_ui_icon(prop, ICON_UNLOCKED, 1); RNA_def_property_editable_func(prop, "rna_PoseChannel_proxy_editable"); RNA_def_property_update(prop, NC_OBJECT | ND_POSE, "rna_Pose_update"); @@ -1376,7 +1376,7 @@ static void rna_def_pose_channel(BlenderRNA *brna) RNA_def_property_ui_text( prop, "Lock Rotation (4D Angle)", - "Lock editing of 'angle' component of four-component rotations in the interface"); + "Lock editing of 'angle' component of four-component rotations when transforming"); RNA_def_property_ui_icon(prop, ICON_UNLOCKED, 1); RNA_def_property_editable_func(prop, "rna_PoseChannel_proxy_editable"); RNA_def_property_update(prop, NC_OBJECT | ND_POSE, "rna_Pose_update"); @@ -1394,7 +1394,7 @@ static void rna_def_pose_channel(BlenderRNA *brna) prop = RNA_def_property(srna, "lock_scale", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "protectflag", OB_LOCK_SCALEX); RNA_def_property_array(prop, 3); - RNA_def_property_ui_text(prop, "Lock Scale", "Lock editing of scale in the interface"); + RNA_def_property_ui_text(prop, "Lock Scale", "Lock editing of scale when transforming"); RNA_def_property_ui_icon(prop, ICON_UNLOCKED, 1); RNA_def_property_editable_func(prop, "rna_PoseChannel_proxy_editable"); RNA_def_property_update(prop, NC_OBJECT | ND_POSE, "rna_Pose_update"); From 8d163d597652aec1f2ca926ba978447dd8476619 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Wed, 22 Jan 2020 02:51:01 +1100 Subject: [PATCH 3/3] Docs: describe turn-table gimble lock mitigation --- .../editors/space_view3d/view3d_edit.c | 27 ++++++++++++++++++- 1 file changed, 26 insertions(+), 1 deletion(-) diff --git a/source/blender/editors/space_view3d/view3d_edit.c b/source/blender/editors/space_view3d/view3d_edit.c index 3dcde401216..a4714249da2 100644 --- a/source/blender/editors/space_view3d/view3d_edit.c +++ b/source/blender/editors/space_view3d/view3d_edit.c @@ -758,7 +758,32 @@ static void viewrotate_apply(ViewOpsData *vod, const int event_xy[2]) quat_to_mat3(m, vod->curr.viewquat); invert_m3_m3(m_inv, m); - /* avoid gimble lock */ + /* Avoid Gimble Lock + * + * Even though turn-table mode is in use, this can occur when the user exits the camera view + * or when aligning the view to a rotated object. + * + * We have gimble lock when the user's view is rotated +/- 90 degrees along the view axis. + * In this case the vertical rotation is the same as the sideways turntable motion. + * Making it impossible to get out of the gimble locked state without resetting the view. + * + * The logic below lets the user exit out of this state without any abrupt 'fix' + * which would be disorienting. + * + * This works by blending two horizons: + * - Rotated-horizon: `cross_v3_v3v3(xaxis, zvec_global, m_inv[2])` + * When only this is used, this turntable rotation works - but it's side-ways + * (as if the entire turn-table has been placed on it's side) + * While there is no gimble lock, it's also awkward to use. + * - Un-rotated-horizon: `m_inv[0]` + * When only this is used, the turntable rotation can have gimbal lock. + * + * The solution used here is to blend between these two values, + * so the severity of the gimbal lock is used to blend the rotated horizon. + * Blending isn't essential, it just makes the transition smoother. + * + * This allows sideways turn-table rotation on a Z axis that isn't world-space Z, + * While up-down turntable rotation eventually corrects gimble lock. */ #if 1 if (len_squared_v3v3(zvec_global, m_inv[2]) > 0.001f) { float fac;