bugfix [#24122] Shift-C doesn't work in "Camera View"

also fixed some glitches with smoothview.
This commit is contained in:
Campbell Barton
2010-10-05 13:15:58 +00:00
parent 629ddacd48
commit 1bf56930ac
2 changed files with 26 additions and 36 deletions

View File

@@ -1274,7 +1274,7 @@ void VIEW3D_OT_zoom(wmOperatorType *ot)
RNA_def_int(ot->srna, "my", 0, 0, INT_MAX, "Zoom Position Y", "", 0, INT_MAX);
}
static int viewhome_exec(bContext *C, wmOperator *op) /* was view3d_home() in 2.4x */
static int view3d_all_exec(bContext *C, wmOperator *op) /* was view3d_home() in 2.4x */
{
ARegion *ar= CTX_wm_region(C);
View3D *v3d = CTX_wm_view3d(C);
@@ -1289,12 +1289,11 @@ static int viewhome_exec(bContext *C, wmOperator *op) /* was view3d_home() in 2.
int ok= 1, onedone=0;
if(center) {
min[0]= min[1]= min[2]= 0.0f;
max[0]= max[1]= max[2]= 0.0f;
/* in 2.4x this also move the cursor to (0, 0, 0) (with shift+c). */
curs= give_cursor(scene, v3d);
curs[0]= curs[1]= curs[2]= 0.0;
zero_v3(min);
zero_v3(max);
zero_v3(curs);
}
else {
INIT_MINMAX(min, max);
@@ -1318,9 +1317,7 @@ static int viewhome_exec(bContext *C, wmOperator *op) /* was view3d_home() in 2.
return OPERATOR_FINISHED;
}
afm[0]= (max[0]-min[0]);
afm[1]= (max[1]-min[1]);
afm[2]= (max[2]-min[2]);
sub_v3_v3v3(afm, max, min);
size= 0.7f*MAX3(afm[0], afm[1], afm[2]);
if(size==0.0) ok= 0;
@@ -1342,7 +1339,7 @@ static int viewhome_exec(bContext *C, wmOperator *op) /* was view3d_home() in 2.
if (rv3d->persp==RV3D_CAMOB) {
rv3d->persp= RV3D_PERSP;
smooth_view(C, NULL, v3d->camera, new_ofs, NULL, &new_dist, NULL);
smooth_view(C, v3d->camera, NULL, new_ofs, NULL, &new_dist, NULL);
}
else {
smooth_view(C, NULL, NULL, new_ofs, NULL, &new_dist, NULL);
@@ -1358,17 +1355,6 @@ static int viewhome_exec(bContext *C, wmOperator *op) /* was view3d_home() in 2.
return OPERATOR_FINISHED;
}
static int viewhome_poll(bContext *C)
{
if(ED_operator_view3d_active(C)) {
RegionView3D *rv3d= CTX_wm_region_view3d(C); //XXX, when accessed from a header menu this doesnt work!
if(rv3d && rv3d->persp!=RV3D_CAMOB) {
return 1;
}
}
return 0;
}
void VIEW3D_OT_view_all(wmOperatorType *ot)
{
@@ -1378,8 +1364,8 @@ void VIEW3D_OT_view_all(wmOperatorType *ot)
ot->idname= "VIEW3D_OT_view_all";
/* api callbacks */
ot->exec= viewhome_exec;
ot->poll= viewhome_poll;
ot->exec= view3d_all_exec;
ot->poll= ED_operator_view3d_active;
/* flags */
ot->flag= 0;

View File

@@ -205,7 +205,7 @@ void smooth_view(bContext *C, Object *oldcamera, Object *camera, float *ofs, flo
if(quat) copy_qt_qt(sms.new_quat, quat);
if(dist) sms.new_dist= *dist;
if(lens) sms.new_lens= *lens;
if (camera) {
view3d_settings_from_ob(camera, sms.new_ofs, sms.new_quat, &sms.new_dist, &sms.new_lens);
sms.to_camera= 1; /* restore view3d values in end */
@@ -214,15 +214,15 @@ void smooth_view(bContext *C, Object *oldcamera, Object *camera, float *ofs, flo
if (C && U.smooth_viewtx) {
int changed = 0; /* zero means no difference */
if (sms.new_dist != rv3d->dist)
if (oldcamera != camera)
changed = 1;
if (sms.new_lens != v3d->lens)
else if (sms.new_dist != rv3d->dist)
changed = 1;
if (!equals_v3v3(sms.new_ofs, rv3d->ofs))
else if (sms.new_lens != v3d->lens)
changed = 1;
if (!equals_v4v4(sms.new_quat, rv3d->viewquat))
else if (!equals_v3v3(sms.new_ofs, rv3d->ofs))
changed = 1;
else if (!equals_v4v4(sms.new_quat, rv3d->viewquat))
changed = 1;
/* The new view is different from the old one
@@ -449,17 +449,21 @@ static int view3d_setobjectascamera_exec(bContext *C, wmOperator *op)
View3D *v3d = CTX_wm_view3d(C);
RegionView3D *rv3d= CTX_wm_region_view3d(C);
Scene *scene= CTX_data_scene(C);
if(BASACT) {
Object *ob = CTX_data_active_object(C);
if(ob) {
Object *camera_old= (rv3d->persp == RV3D_CAMOB && scene->camera) ? scene->camera : NULL;
rv3d->persp= RV3D_CAMOB;
v3d->camera= OBACT;
v3d->camera= ob;
if(v3d->scenelock)
scene->camera= OBACT;
smooth_view(C, NULL, v3d->camera, rv3d->ofs, rv3d->viewquat, &rv3d->dist, &v3d->lens);
scene->camera= ob;
if(camera_old != ob) /* unlikely but looks like a glitch when set to the same */
smooth_view(C, camera_old, v3d->camera, rv3d->ofs, rv3d->viewquat, &rv3d->dist, &v3d->lens);
WM_event_add_notifier(C, NC_SCENE|ND_RENDER_OPTIONS|NC_OBJECT|ND_DRAW, CTX_data_scene(C));
}
WM_event_add_notifier(C, NC_SCENE|ND_RENDER_OPTIONS|NC_OBJECT|ND_DRAW, CTX_data_scene(C));
return OPERATOR_FINISHED;
}