[Bf-blender-cvs] [6f0602c] wiggly-widgets: Dragging the light handle will now point the lamp to the point in 3D where user is dragging over.
Antony Riakiotakis
noreply at git.blender.org
Tue Oct 7 12:48:42 CEST 2014
Commit: 6f0602ca17a3cbe361b219f88c7ec85a1c036916
Author: Antony Riakiotakis
Date: Tue Oct 7 12:48:29 2014 +0200
Branches: wiggly-widgets
https://developer.blender.org/rB6f0602ca17a3cbe361b219f88c7ec85a1c036916
Dragging the light handle will now point the lamp to the point in 3D
where user is dragging over.
===================================================================
M source/blender/editors/interface/interface_generic_widgets.c
===================================================================
diff --git a/source/blender/editors/interface/interface_generic_widgets.c b/source/blender/editors/interface/interface_generic_widgets.c
index 7d08254..99ffd0e 100644
--- a/source/blender/editors/interface/interface_generic_widgets.c
+++ b/source/blender/editors/interface/interface_generic_widgets.c
@@ -42,9 +42,11 @@
#include "BLI_math.h"
#include "BKE_context.h"
+#include "BKE_depsgraph.h"
#include "BKE_object.h"
#include "ED_view3d.h"
+#include "ED_screen.h"
#include "WM_types.h"
#include "WM_api.h"
@@ -100,28 +102,41 @@ static int lamp_position_modal(bContext *C, wmOperator *op, const wmEvent *event
ARegion *ar = CTX_wm_region(C);
View3D *v3d = CTX_wm_view3d(C);
float world_pos[3];
-
+ int flag = v3d->flag2;
+
+ v3d->flag2 |= V3D_RENDER_OVERRIDE;
+
view3d_operator_needs_opengl(C);
if (ED_view3d_autodist(scene, ar, v3d, event->mval, world_pos, true, NULL)) {
float axis[3];
+
+ /* restore the floag here */
+ v3d->flag2 = flag;
+
sub_v3_v3(world_pos, ob->obmat[3]);
normalize_v3(world_pos);
cross_v3_v3v3(axis, data->lvec, world_pos);
- if (normalize_v3(axis) > 0.001) {
+ if (normalize_v3(axis) > 0.0001) {
float mat[4][4];
float quat[4], qfinal[4];
+ float angle = saacos(dot_v3v3(world_pos, data->lvec));
/* transform the initial rotation quaternion to the new position and set the matrix to the lamp */
- axis_angle_to_quat(quat, axis, saacos(dot_v3v3(axis, data->lvec)));
+ axis_angle_to_quat(quat, axis, angle);
mul_qt_qtqt(qfinal, quat, data->quat);
quat_to_mat4(mat, qfinal);
copy_v3_v3(mat[3], ob->obmat[3]);
- BKE_object_apply_mat4(ob, mat, true, true);
+ BKE_object_apply_mat4(ob, mat, true, false);
+ DAG_id_tag_update(&ob->id, OB_RECALC_OB);
+
+ ED_region_tag_redraw(ar);
}
}
+ v3d->flag2 = flag;
+
break;
}
More information about the Bf-blender-cvs
mailing list