Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'source/blender/editors/space_view3d/view3d_utils.c')
-rw-r--r--source/blender/editors/space_view3d/view3d_utils.c45
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;
+}
+
/** \} */
/* -------------------------------------------------------------------- */