diff options
author | Germano Cavalcante <mano-wii> | 2022-04-04 22:16:36 +0300 |
---|---|---|
committer | Germano Cavalcante <germano.costa@ig.com.br> | 2022-04-04 22:20:34 +0300 |
commit | 0ebcc711fc2767f2d260d8e124af1074da9c8a59 (patch) | |
tree | f8c2abf1692e87b14556df2f1149f893c1282a8b /source/blender/editors/space_view3d/view3d_utils.c | |
parent | b5f3f8ef1d52e58cfe2fc8747047c45267055fab (diff) |
Fix T95678: Thumbnails are not working with big / large Objects
The internal camera used to render the thumbnails also has to consider
`clip_start` and `clip_end`.
Reviewed By: Severin
Maniphest Tasks: T95678
Differential Revision: https://developer.blender.org/D14138
Diffstat (limited to 'source/blender/editors/space_view3d/view3d_utils.c')
-rw-r--r-- | source/blender/editors/space_view3d/view3d_utils.c | 45 |
1 files changed, 40 insertions, 5 deletions
diff --git a/source/blender/editors/space_view3d/view3d_utils.c b/source/blender/editors/space_view3d/view3d_utils.c index 744fc61ddcf..e6895c0f4a3 100644 --- a/source/blender/editors/space_view3d/view3d_utils.c +++ b/source/blender/editors/space_view3d/view3d_utils.c @@ -1440,16 +1440,19 @@ void ED_view3d_to_object(const Depsgraph *depsgraph, BKE_object_apply_mat4_ex(ob, mat, ob_eval->parent, ob_eval->parentinv, true); } -bool ED_view3d_camera_to_view_selected(struct Main *bmain, - Depsgraph *depsgraph, - const Scene *scene, - Object *camera_ob) +static bool view3d_camera_to_view_selected_impl(struct Main *bmain, + Depsgraph *depsgraph, + const Scene *scene, + Object *camera_ob, + float *r_clip_start, + float *r_clip_end) { Object *camera_ob_eval = DEG_get_evaluated_object(depsgraph, camera_ob); float co[3]; /* the new location to apply */ float scale; /* only for ortho cameras */ - if (BKE_camera_view_frame_fit_to_scene(depsgraph, scene, camera_ob_eval, co, &scale)) { + if (BKE_camera_view_frame_fit_to_scene( + depsgraph, scene, camera_ob_eval, co, &scale, r_clip_start, r_clip_end)) { ObjectTfmProtectedChannels obtfm; float obmat_new[4][4]; @@ -1475,6 +1478,38 @@ bool ED_view3d_camera_to_view_selected(struct Main *bmain, return false; } +bool ED_view3d_camera_to_view_selected(struct Main *bmain, + Depsgraph *depsgraph, + const Scene *scene, + Object *camera_ob) +{ + return view3d_camera_to_view_selected_impl(bmain, depsgraph, scene, camera_ob, NULL, NULL); +} + +bool ED_view3d_camera_to_view_selected_with_set_clipping(struct Main *bmain, + Depsgraph *depsgraph, + const Scene *scene, + Object *camera_ob) +{ + float clip_start; + float clip_end; + if (view3d_camera_to_view_selected_impl( + bmain, depsgraph, scene, camera_ob, &clip_start, &clip_end)) { + + ((Camera *)camera_ob->data)->clip_start = clip_start; + ((Camera *)camera_ob->data)->clip_end = clip_end; + + /* TODO: Support update via #ID_RECALC_PARAMETERS. */ + Object *camera_ob_eval = DEG_get_evaluated_object(depsgraph, camera_ob); + ((Camera *)camera_ob_eval->data)->clip_start = clip_start; + ((Camera *)camera_ob_eval->data)->clip_end = clip_end; + + return true; + } + + return false; +} + /** \} */ /* -------------------------------------------------------------------- */ |