diff options
-rw-r--r-- | source/blender/editors/include/ED_view3d.h | 1 | ||||
-rw-r--r-- | source/blender/editors/space_view3d/view3d_edit.c | 9 | ||||
-rw-r--r-- | source/blender/editors/space_view3d/view3d_view.c | 58 |
3 files changed, 13 insertions, 55 deletions
diff --git a/source/blender/editors/include/ED_view3d.h b/source/blender/editors/include/ED_view3d.h index e2405425891..a90e91a7242 100644 --- a/source/blender/editors/include/ED_view3d.h +++ b/source/blender/editors/include/ED_view3d.h @@ -206,7 +206,6 @@ void project_int_noclip(struct ARegion *ar, const float vec[3], int adr[2]); void project_float(struct ARegion *ar, const float vec[3], float adr[2]); void project_float_noclip(struct ARegion *ar, const float vec[3], float adr[2]); -void ED_view3d_ob_clip_range_get(struct Object *ob, float *lens, float *clipsta, float *clipend); int ED_view3d_clip_range_get(struct View3D *v3d, struct RegionView3D *rv3d, float *clipsta, float *clipend); int ED_view3d_viewplane_get(struct View3D *v3d, struct RegionView3D *rv3d, int winxi, int winyi, struct rctf *viewplane, float *clipsta, float *clipend); void ED_view3d_ob_project_mat_get(struct RegionView3D *v3d, struct Object *ob, float pmat[4][4]); diff --git a/source/blender/editors/space_view3d/view3d_edit.c b/source/blender/editors/space_view3d/view3d_edit.c index fe3a5a3b4d5..39ef6b3c84a 100644 --- a/source/blender/editors/space_view3d/view3d_edit.c +++ b/source/blender/editors/space_view3d/view3d_edit.c @@ -47,6 +47,7 @@ #include "BLI_rand.h" #include "BLI_utildefines.h" +#include "BKE_camera.h" #include "BKE_context.h" #include "BKE_image.h" #include "BKE_library.h" @@ -3513,8 +3514,12 @@ void ED_view3d_from_object(Object *ob, float ofs[3], float quat[4], float *dist, { ED_view3d_from_m4(ob->obmat, ofs, quat, dist); - if (lens) { - ED_view3d_ob_clip_range_get(ob, lens, NULL, NULL); + if(lens) { + CameraParams params; + + camera_params_init(¶ms); + camera_params_from_object(¶ms, ob); + *lens= params.lens; } } diff --git a/source/blender/editors/space_view3d/view3d_view.c b/source/blender/editors/space_view3d/view3d_view.c index cf838cb94ce..c416a60e410 100644 --- a/source/blender/editors/space_view3d/view3d_view.c +++ b/source/blender/editors/space_view3d/view3d_view.c @@ -104,31 +104,6 @@ float *give_cursor(Scene *scene, View3D *v3d) } -/* Gets the lens and clipping values from a camera of lamp type object */ -void ED_view3d_ob_clip_range_get(Object *ob, float *lens, float *clipsta, float *clipend) -{ - if(ob->type==OB_LAMP ) { - Lamp *la = ob->data; - if (lens) { - float x1, fac; - fac= cosf((float)M_PI*la->spotsize/360.0f); - x1= saacos(fac); - *lens= 16.0f*fac/sinf(x1); - } - if (clipsta) *clipsta= la->clipsta; - if (clipend) *clipend= la->clipend; - } - else if(ob->type==OB_CAMERA) { - Camera *cam= ob->data; - if (lens) *lens= cam->lens; - if (clipsta) *clipsta= cam->clipsta; - if (clipend) *clipend= cam->clipend; - } - else { - if (lens) *lens= 35.0f; - } -} - /* ****************** smooth view operator ****************** */ /* This operator is one of the 'timer refresh' ones like animation playback */ @@ -985,36 +960,15 @@ void project_float_noclip(ARegion *ar, const float vec[3], float adr[2]) /* copies logic of get_view3d_viewplane(), keep in sync */ int ED_view3d_clip_range_get(View3D *v3d, RegionView3D *rv3d, float *clipsta, float *clipend) { - int orth= 0; - - *clipsta= v3d->near; - *clipend= v3d->far; - - if(rv3d->persp==RV3D_CAMOB) { - if(v3d->camera) { - if(v3d->camera->type==OB_LAMP ) { - Lamp *la= v3d->camera->data; - *clipsta= la->clipsta; - *clipend= la->clipend; - } - else if(v3d->camera->type==OB_CAMERA) { - Camera *cam= v3d->camera->data; - *clipsta= cam->clipsta; - *clipend= cam->clipend; + CameraParams params; - if(cam->type==CAM_ORTHO) - orth= 1; - } - } - } + camera_params_init(¶ms); + camera_params_from_view3d(¶ms, v3d, rv3d); - if(rv3d->persp==RV3D_ORTHO) { - *clipend *= 0.5f; // otherwise too extreme low zbuffer quality - *clipsta= - *clipend; - orth= 1; - } + *clipsta= params.clipsta; + *clipend= params.clipend; - return orth; + return params.is_ortho; } /* also exposed in previewrender.c */ |