bugfix [#22769] Undo Looses Active Camera

The problem was that the v3d could have a different camera to the scene even when locked.
VIEW3D_OT_viewnumpad was ignoring v3d->scenelock option and allowing an invalid state.
This commit is contained in:
2010-07-24 01:32:03 +00:00
parent a732678217
commit f148aa696e
4 changed files with 31 additions and 15 deletions

View File

@@ -1924,11 +1924,12 @@ static int viewnumpad_exec(bContext *C, wmOperator *op)
/* lastview - */
if(rv3d->persp != RV3D_CAMOB) {
Object *ob= OBACT;
if (!rv3d->smooth_timer) {
/* store settings of current view before allowing overwriting with camera view
* only if we're not currently in a view transition */
QUATCOPY(rv3d->lviewquat, rv3d->viewquat);
copy_qt_qt(rv3d->lviewquat, rv3d->viewquat);
rv3d->lview= rv3d->view;
rv3d->lpersp= rv3d->persp;
}
@@ -1941,20 +1942,35 @@ static int viewnumpad_exec(bContext *C, wmOperator *op)
handle_view3d_lock();
}
#endif
if(BASACT) {
/* check both G.vd as G.scene cameras */
if((v3d->camera==NULL || scene->camera==NULL) && OBACT->type==OB_CAMERA) {
v3d->camera= OBACT;
/*handle_view3d_lock();*/
/* first get the default camera for the view lock type */
if(v3d->scenelock) {
/* sets the camera view if available */
v3d->camera= scene->camera;
}
else {
/* use scene camera if one is not set (even though we're unlocked) */
if(v3d->camera==NULL) {
v3d->camera= scene->camera;
}
}
if(v3d->camera==NULL) {
v3d->camera= scene_find_camera(scene);
if (v3d->camera == NULL)
return OPERATOR_CANCELLED;
}
/* if the camera isnt found, check a number of options */
if(v3d->camera==NULL && ob && ob->type==OB_CAMERA)
v3d->camera= ob;
if(v3d->camera==NULL)
v3d->camera= scene_find_camera(scene);
/* couldnt find any useful camera, bail out */
if(v3d->camera==NULL)
return OPERATOR_CANCELLED;
/* important these dont get out of sync for locked scenes */
if(v3d->scenelock)
scene->camera= v3d->camera;
/* finally do snazzy view zooming */
rv3d->persp= RV3D_CAMOB;
smooth_view(C, NULL, v3d->camera, rv3d->ofs, rv3d->viewquat, &rv3d->dist, &v3d->lens);

View File

@@ -144,7 +144,7 @@ void view3d_settings_from_ob(struct Object *ob, float *ofs, float *quat, float *
void VIEW3D_OT_smoothview(struct wmOperatorType *ot);
void VIEW3D_OT_setcameratoview(struct wmOperatorType *ot);
void VIEW3D_OT_setobjectascamera(struct wmOperatorType *ot);
void VIEW3D_OT_object_as_camera(struct wmOperatorType *ot);
void VIEW3D_OT_localview(struct wmOperatorType *ot);
void VIEW3D_OT_game_start(struct wmOperatorType *ot);
void VIEW3D_OT_fly(struct wmOperatorType *ot);

View File

@@ -83,7 +83,7 @@ void view3d_operatortypes(void)
WM_operatortype_append(VIEW3D_OT_cursor3d);
WM_operatortype_append(VIEW3D_OT_select_lasso);
WM_operatortype_append(VIEW3D_OT_setcameratoview);
WM_operatortype_append(VIEW3D_OT_setobjectascamera);
WM_operatortype_append(VIEW3D_OT_object_as_camera);
WM_operatortype_append(VIEW3D_OT_localview);
WM_operatortype_append(VIEW3D_OT_game_start);
WM_operatortype_append(VIEW3D_OT_fly);

View File

@@ -458,7 +458,7 @@ static int view3d_setobjectascamera_exec(bContext *C, wmOperator *op)
return OPERATOR_FINISHED;
}
void VIEW3D_OT_setobjectascamera(wmOperatorType *ot)
void VIEW3D_OT_object_as_camera(wmOperatorType *ot)
{
/* identifiers */