disable view3d dolly, move, pan -- when the view offset is locked, also corrected fly modes offset lock check

and added ED_view3d_offset_lock_check() to reuse between functions.
This commit is contained in:
Campbell Barton 2013-05-03 07:29:25 +00:00
parent 2a78a14369
commit a947ea0a1e
3 changed files with 34 additions and 3 deletions

@ -298,6 +298,8 @@ bool ED_view3d_lock(struct RegionView3D *rv3d);
uint64_t ED_view3d_datamask(struct Scene *scene, struct View3D *v3d);
uint64_t ED_view3d_screen_datamask(struct bScreen *screen);
bool ED_view3d_offset_lock_check(struct View3D *v3d, struct RegionView3D *rv3d);
/* camera lock functions */
bool ED_view3d_camera_lock_check(struct View3D *v3d, struct RegionView3D *rv3d);
/* copy the camera to the view before starting a view transformation */

@ -86,6 +86,27 @@
/* for ndof prints */
// #define DEBUG_NDOF_MOTION
static void view3d_offset_lock_report(ReportList *reports)
{
BKE_report(reports, RPT_WARNING, "View offset is locked");
}
bool ED_view3d_offset_lock_check(struct View3D *v3d, struct RegionView3D *rv3d)
{
return (rv3d->persp != RV3D_CAMOB) && (v3d->ob_centre_cursor || v3d->ob_centre);
}
#define VIEW3D_OP_OFS_LOCK_TEST(C, op) \
{ \
View3D *v3d_tmp = CTX_wm_view3d(C); \
RegionView3D *rv3d_tmp = CTX_wm_region_view3d(C); \
if (ED_view3d_offset_lock_check(v3d_tmp, rv3d_tmp)) { \
view3d_offset_lock_report((op)->reports); \
return OPERATOR_CANCELLED; \
} \
} (void)0
/* ********************** view3d_edit: view manipulations ********************* */
bool ED_view3d_camera_lock_check(View3D *v3d, RegionView3D *rv3d)
@ -1286,7 +1307,7 @@ void VIEW3D_OT_ndof_orbit_zoom(struct wmOperatorType *ot)
/* -- "pan" navigation
* -- zoom or dolly?
*/
static int ndof_pan_invoke(bContext *C, wmOperator *UNUSED(op), const wmEvent *event)
static int ndof_pan_invoke(bContext *C, wmOperator *op, const wmEvent *event)
{
if (event->type != NDOF_MOTION)
return OPERATOR_CANCELLED;
@ -1295,6 +1316,8 @@ static int ndof_pan_invoke(bContext *C, wmOperator *UNUSED(op), const wmEvent *e
RegionView3D *rv3d = CTX_wm_region_view3d(C);
wmNDOFMotionData *ndof = (wmNDOFMotionData *) event->customdata;
VIEW3D_OP_OFS_LOCK_TEST(C, op);
ED_view3d_camera_lock_init(v3d, rv3d);
rv3d->rot_angle = 0.f; /* we're panning here! so erase any leftover rotation from other operators */
@ -1586,6 +1609,8 @@ static int viewmove_invoke(bContext *C, wmOperator *op, const wmEvent *event)
{
ViewOpsData *vod;
VIEW3D_OP_OFS_LOCK_TEST(C, op);
/* makes op->customdata */
viewops_data_create(C, op, event);
vod = op->customdata;
@ -2164,6 +2189,8 @@ static int viewdolly_invoke(bContext *C, wmOperator *op, const wmEvent *event)
{
ViewOpsData *vod;
VIEW3D_OP_OFS_LOCK_TEST(C, op);
/* makes op->customdata */
viewops_data_create(C, op, event);
vod = op->customdata;
@ -3482,6 +3509,8 @@ static int viewpan_exec(bContext *C, wmOperator *op)
float zfac;
int pandir;
VIEW3D_OP_OFS_LOCK_TEST(C, op);
pandir = RNA_enum_get(op->ptr, "type");
ED_view3d_camera_lock_init(v3d, rv3d);

@ -304,8 +304,8 @@ static bool initFlyInfo(bContext *C, FlyInfo *fly, wmOperator *op, const wmEvent
return false;
}
if (fly->v3d->ob_centre) {
BKE_report(op->reports, RPT_ERROR, "Cannot fly when the view is locked to an object");
if (ED_view3d_offset_lock_check(fly->v3d, fly->rv3d)) {
BKE_report(op->reports, RPT_ERROR, "Cannot fly when the view offset is locked");
return false;
}