[Bf-blender-cvs] [b6279b74156] blender-v2.83-release: Fix T75794: Light point gizmo translate jumps
Campbell Barton
noreply at git.blender.org
Fri Apr 17 10:52:22 CEST 2020
Commit: b6279b74156e1f6d17dc0fa324aee347b26c9bd0
Author: Campbell Barton
Date: Fri Apr 17 18:48:33 2020 +1000
Branches: blender-v2.83-release
https://developer.blender.org/rBb6279b74156e1f6d17dc0fa324aee347b26c9bd0
Fix T75794: Light point gizmo translate jumps
Holding Ctrl while dragging the light point gizmo would use
uninitialized stack memory if the normal had not been
initialized by a surface.
Now holding Ctrl can be used to drag,
even when there is no surface to orient to.
===================================================================
M source/blender/editors/object/object_transform.c
===================================================================
diff --git a/source/blender/editors/object/object_transform.c b/source/blender/editors/object/object_transform.c
index 46245d21d5b..7b3955a0cf8 100644
--- a/source/blender/editors/object/object_transform.c
+++ b/source/blender/editors/object/object_transform.c
@@ -1912,7 +1912,7 @@ static int object_transform_axis_target_modal(bContext *C, wmOperator *op, const
normal_found = true;
}
- if (normal_found) {
+ {
#ifdef USE_RELATIVE_ROTATION
if (is_translate_init && xfd->object_data_len > 1) {
float xform_rot_offset_inv_first[3][3];
@@ -1941,16 +1941,26 @@ static int object_transform_axis_target_modal(bContext *C, wmOperator *op, const
item->xform_dist = len_v3v3(item->ob->obmat[3], location_world);
normalize_v3_v3(ob_axis, item->ob->obmat[2]);
/* Scale to avoid adding distance when moving between surfaces. */
- float scale = fabsf(dot_v3v3(ob_axis, normal));
- item->xform_dist *= scale;
+ if (normal_found) {
+ float scale = fabsf(dot_v3v3(ob_axis, normal));
+ item->xform_dist *= scale;
+ }
}
float target_normal[3];
- copy_v3_v3(target_normal, normal);
+
+ if (normal_found) {
+ copy_v3_v3(target_normal, normal);
+ }
+ else {
+ normalize_v3_v3(target_normal, item->ob->obmat[2]);
+ }
#ifdef USE_RELATIVE_ROTATION
- if (i != 0) {
- mul_m3_v3(item->xform_rot_offset, target_normal);
+ if (normal_found) {
+ if (i != 0) {
+ mul_m3_v3(item->xform_rot_offset, target_normal);
+ }
}
#endif
{
@@ -1967,8 +1977,10 @@ static int object_transform_axis_target_modal(bContext *C, wmOperator *op, const
item->ob, item->rot_mat, item->rot_mat[2], location_world);
WM_event_add_notifier(C, NC_OBJECT | ND_TRANSFORM, item->ob);
}
- copy_v3_v3(xfd->prev.normal, normal);
- xfd->prev.is_normal_valid = true;
+ if (normal_found) {
+ copy_v3_v3(xfd->prev.normal, normal);
+ xfd->prev.is_normal_valid = true;
+ }
}
}
else {
More information about the Bf-blender-cvs
mailing list