Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCampbell Barton <ideasman42@gmail.com>2020-04-17 11:48:33 +0300
committerCampbell Barton <ideasman42@gmail.com>2020-04-17 11:51:09 +0300
commitb6279b74156e1f6d17dc0fa324aee347b26c9bd0 (patch)
tree8160ffd32fd224a213471e3d30b78064f4cd0cd3 /source/blender/editors/object/object_transform.c
parent774b61189c9f371770b9970eb7b42dd502007d65 (diff)
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.
Diffstat (limited to 'source/blender/editors/object/object_transform.c')
-rw-r--r--source/blender/editors/object/object_transform.c28
1 files changed, 20 insertions, 8 deletions
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 {