diff --git a/source/blender/editors/space_view3d/view3d_view.c b/source/blender/editors/space_view3d/view3d_view.c index af86fb72070..8582952d1a0 100644 --- a/source/blender/editors/space_view3d/view3d_view.c +++ b/source/blender/editors/space_view3d/view3d_view.c @@ -592,6 +592,54 @@ void VIEW3D_OT_camera_to_view_selected(wmOperatorType *ot) ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; } +static void sync_viewport_camera_smoothview(bContext *C, View3D *v3d, Object *ob, const int smooth_viewtx) +{ + Main *bmain = CTX_data_main(C); + for (bScreen *screen = bmain->screen.first; screen != NULL; screen = screen->id.next) { + for (ScrArea *area = screen->areabase.first; area != NULL; area = area->next) { + for (SpaceLink *space_link = area->spacedata.first; space_link != NULL; space_link = space_link->next) { + if (space_link->spacetype == SPACE_VIEW3D) { + View3D *other_v3d = (View3D *)space_link; + if (other_v3d == v3d) { + continue; + } + if (other_v3d->camera == ob) { + continue; + } + if (v3d->scenelock) { + ListBase *lb = (space_link == area->spacedata.first) + ? &area->regionbase + : &space_link->regionbase; + for (ARegion *other_ar = lb->first; other_ar != NULL; other_ar = other_ar->next) { + if (other_ar->regiontype == RGN_TYPE_WINDOW) { + if (other_ar->regiondata) { + RegionView3D *other_rv3d = other_ar->regiondata; + if (other_rv3d->persp == RV3D_CAMOB) { + Object *other_camera_old = other_v3d->camera; + other_v3d->camera = ob; + ED_view3d_lastview_store(other_rv3d); + ED_view3d_smooth_view( + C, other_v3d, other_ar, smooth_viewtx, + &(const V3D_SmoothParams) { + .camera_old = other_camera_old, + .camera = other_v3d->camera, + .ofs = other_rv3d->ofs, + .quat = other_rv3d->viewquat, + .dist = &other_rv3d->dist, + .lens = &other_v3d->lens}); + } + else { + other_v3d->camera = ob; + } + } + } + } + } + } + } + } + } +} static int view3d_setobjectascamera_exec(bContext *C, wmOperator *op) { @@ -628,6 +676,7 @@ static int view3d_setobjectascamera_exec(bContext *C, wmOperator *op) } if (v3d->scenelock) { + sync_viewport_camera_smoothview(C, v3d, ob, smooth_viewtx); WM_event_add_notifier(C, NC_SCENE, scene); } WM_event_add_notifier(C, NC_OBJECT | ND_DRAW, scene); diff --git a/source/blender/makesrna/intern/rna_space.c b/source/blender/makesrna/intern/rna_space.c index 375d370097e..b6c393280ba 100644 --- a/source/blender/makesrna/intern/rna_space.c +++ b/source/blender/makesrna/intern/rna_space.c @@ -454,6 +454,15 @@ EnumPropertyItem *rna_TransformOrientation_itemf(bContext *C, PointerRNA *ptr, P } /* Space 3D View */ +static void rna_SpaceView3D_camera_update(Main *bmain, Scene *scene, PointerRNA *ptr) +{ + View3D *v3d = (View3D *)(ptr->data); + if (v3d->scenelock) { + scene->camera = v3d->camera; + BKE_screen_view3d_main_sync(&bmain->screen, scene); + } +} + static void rna_SpaceView3D_lock_camera_and_layers_set(PointerRNA *ptr, int value) { View3D *v3d = (View3D *)(ptr->data); @@ -2368,7 +2377,7 @@ static void rna_def_space_view3d(BlenderRNA *brna) RNA_def_property_pointer_sdna(prop, NULL, "camera"); RNA_def_property_ui_text(prop, "Camera", "Active camera used in this view (when unlocked from the scene's active camera)"); - RNA_def_property_update(prop, NC_SPACE | ND_SPACE_VIEW3D, NULL); + RNA_def_property_update(prop, NC_SPACE | ND_SPACE_VIEW3D, "rna_SpaceView3D_camera_update"); /* render border */ prop = RNA_def_property(srna, "use_render_border", PROP_BOOLEAN, PROP_NONE);