forked from bartvdbraak/blender
fixed crash when NDOF operators were called without an NDOF_MOTION event
This commit is contained in:
parent
79e359f92a
commit
5dd2b3e06f
@ -447,6 +447,9 @@ void IMAGE_OT_view_zoom(wmOperatorType *ot)
|
||||
|
||||
static int view_ndof_invoke(bContext *C, wmOperator *UNUSED(op), wmEvent *event)
|
||||
{
|
||||
if (event->type != NDOF_MOTION)
|
||||
return OPERATOR_CANCELLED;
|
||||
else {
|
||||
SpaceImage *sima= CTX_wm_space_image(C);
|
||||
ARegion *ar= CTX_wm_region(C);
|
||||
|
||||
@ -468,6 +471,9 @@ static int view_ndof_invoke(bContext *C, wmOperator *UNUSED(op), wmEvent *event)
|
||||
*/
|
||||
float zoom_factor = 1.f + zoom_sensitivity * dt * -ndof->tvec[2];
|
||||
|
||||
if (U.ndof_flag & NDOF_ZOOM_INVERT)
|
||||
zoom_factor = -zoom_factor;
|
||||
|
||||
sima_zoom_set_factor(sima, ar, zoom_factor);
|
||||
sima->xof += pan_x;
|
||||
sima->yof += pan_y;
|
||||
@ -475,6 +481,7 @@ static int view_ndof_invoke(bContext *C, wmOperator *UNUSED(op), wmEvent *event)
|
||||
ED_region_tag_redraw(ar);
|
||||
|
||||
return OPERATOR_FINISHED;
|
||||
}
|
||||
}
|
||||
|
||||
void IMAGE_OT_view_ndof(wmOperatorType *ot)
|
||||
|
@ -949,6 +949,9 @@ static int ndof_orbit_invoke(bContext *C, wmOperator *UNUSED(op), wmEvent *event
|
||||
// -- zooming
|
||||
// -- panning in rotationally-locked views
|
||||
{
|
||||
if (event->type != NDOF_MOTION)
|
||||
return OPERATOR_CANCELLED;
|
||||
else {
|
||||
RegionView3D* rv3d = CTX_wm_region_view3d(C);
|
||||
wmNDOFMotionData* ndof = (wmNDOFMotionData*) event->customdata;
|
||||
|
||||
@ -981,6 +984,10 @@ static int ndof_orbit_invoke(bContext *C, wmOperator *UNUSED(op), wmEvent *event
|
||||
// proportional to arclength = radius * angle
|
||||
|
||||
float zoom_distance = zoom_sensitivity * rv3d->dist * dt * ndof->tvec[2];
|
||||
|
||||
if (U.ndof_flag & NDOF_ZOOM_INVERT)
|
||||
zoom_distance = -zoom_distance;
|
||||
|
||||
rv3d->dist += zoom_distance;
|
||||
}
|
||||
|
||||
@ -1005,23 +1012,6 @@ static int ndof_orbit_invoke(bContext *C, wmOperator *UNUSED(op), wmEvent *event
|
||||
|
||||
if (U.flag & USER_TRACKBALL) {
|
||||
float rot[4];
|
||||
#if 0 // -------------------------- Mike's nifty original version
|
||||
float view_inv_conj[4];
|
||||
|
||||
ndof_to_quat(ndof, rot);
|
||||
// mul_qt_fl(rot, rot_sensitivity);
|
||||
// ^^ no apparent effect
|
||||
|
||||
if (invert)
|
||||
invert_qt(rot);
|
||||
|
||||
copy_qt_qt(view_inv_conj, view_inv);
|
||||
conjugate_qt(view_inv_conj);
|
||||
|
||||
// transform rotation from view to world coordinates
|
||||
mul_qt_qtqt(rot, view_inv, rot);
|
||||
mul_qt_qtqt(rot, rot, view_inv_conj);
|
||||
#else // ---------------------------------------- Mike's revised version
|
||||
float axis[3];
|
||||
float angle = rot_sensitivity * ndof_to_axis_angle(ndof, axis);
|
||||
|
||||
@ -1036,7 +1026,7 @@ static int ndof_orbit_invoke(bContext *C, wmOperator *UNUSED(op), wmEvent *event
|
||||
copy_v3_v3(rv3d->rot_axis, axis);
|
||||
|
||||
axis_angle_to_quat(rot, axis, angle);
|
||||
#endif // --------------------------------------------
|
||||
|
||||
// apply rotation
|
||||
mul_qt_qtqt(rv3d->viewquat, rv3d->viewquat, rot);
|
||||
} else {
|
||||
@ -1077,6 +1067,7 @@ static int ndof_orbit_invoke(bContext *C, wmOperator *UNUSED(op), wmEvent *event
|
||||
ED_region_tag_redraw(CTX_wm_region(C));
|
||||
|
||||
return OPERATOR_FINISHED;
|
||||
}
|
||||
}
|
||||
|
||||
void VIEW3D_OT_ndof_orbit(struct wmOperatorType *ot)
|
||||
@ -1098,9 +1089,13 @@ static int ndof_pan_invoke(bContext *C, wmOperator *UNUSED(op), wmEvent *event)
|
||||
// -- "pan" navigation
|
||||
// -- zoom or dolly?
|
||||
{
|
||||
if (event->type != NDOF_MOTION)
|
||||
return OPERATOR_CANCELLED;
|
||||
else {
|
||||
RegionView3D* rv3d = CTX_wm_region_view3d(C);
|
||||
wmNDOFMotionData* ndof = (wmNDOFMotionData*) event->customdata;
|
||||
|
||||
|
||||
rv3d->rot_angle = 0.f; // we're panning here! so erase any leftover rotation from other operators
|
||||
|
||||
if (ndof->progress != P_FINISHING) {
|
||||
@ -1149,6 +1144,7 @@ static int ndof_pan_invoke(bContext *C, wmOperator *UNUSED(op), wmEvent *event)
|
||||
ED_region_tag_redraw(CTX_wm_region(C));
|
||||
|
||||
return OPERATOR_FINISHED;
|
||||
}
|
||||
}
|
||||
|
||||
void VIEW3D_OT_ndof_pan(struct wmOperatorType *ot)
|
||||
|
Loading…
Reference in New Issue
Block a user