change to r52888, since we dont always want ED_view3d_offset_distance() to give a corrected value, instead pass a fallback so callers don't allow zero by accident.
This commit is contained in:
@@ -295,7 +295,8 @@ void ED_view3D_background_image_remove(struct View3D *v3d, struct BGpic *bgpic);
|
||||
void ED_view3D_background_image_clear(struct View3D *v3d);
|
||||
|
||||
#define VIEW3D_MARGIN 1.4f
|
||||
float ED_view3d_offset_distance(float mat[4][4], float ofs[3]);
|
||||
#define VIEW3D_DIST_FALLBACK 1.0f
|
||||
float ED_view3d_offset_distance(float mat[4][4], const float ofs[3], const float dist_fallback);
|
||||
|
||||
float ED_scene_grid_scale(struct Scene *scene, const char **grid_unit);
|
||||
float ED_view3d_grid_scale(struct Scene *scene, struct View3D *v3d, const char **grid_unit);
|
||||
|
@@ -96,7 +96,8 @@ int ED_view3d_camera_lock_check(View3D *v3d, RegionView3D *rv3d)
|
||||
void ED_view3d_camera_lock_init(View3D *v3d, RegionView3D *rv3d)
|
||||
{
|
||||
if (ED_view3d_camera_lock_check(v3d, rv3d)) {
|
||||
rv3d->dist = ED_view3d_offset_distance(v3d->camera->obmat, rv3d->ofs);
|
||||
/* using a fallback dist is OK here since ED_view3d_from_object() compensates for it */
|
||||
rv3d->dist = ED_view3d_offset_distance(v3d->camera->obmat, rv3d->ofs, VIEW3D_DIST_FALLBACK);
|
||||
ED_view3d_from_object(v3d->camera, rv3d->ofs, rv3d->viewquat, &rv3d->dist, NULL);
|
||||
}
|
||||
}
|
||||
@@ -895,7 +896,7 @@ static int viewrotate_invoke(bContext *C, wmOperator *op, wmEvent *event)
|
||||
|
||||
/* changed since 2.4x, use the camera view */
|
||||
if (vod->v3d->camera) {
|
||||
rv3d->dist = ED_view3d_offset_distance(vod->v3d->camera->obmat, rv3d->ofs);
|
||||
rv3d->dist = ED_view3d_offset_distance(vod->v3d->camera->obmat, rv3d->ofs, VIEW3D_DIST_FALLBACK);
|
||||
ED_view3d_from_object(vod->v3d->camera, rv3d->ofs, rv3d->viewquat, &rv3d->dist, NULL);
|
||||
}
|
||||
|
||||
@@ -3977,7 +3978,11 @@ int ED_view3d_autodist_depth_seg(ARegion *ar, const int mval_sta[2], const int m
|
||||
return (*depth == FLT_MAX) ? 0 : 1;
|
||||
}
|
||||
|
||||
float ED_view3d_offset_distance(float mat[4][4], float ofs[3])
|
||||
/* problem - ofs[3] can be on same location as camera itself.
|
||||
* Blender needs proper dist value for zoom.
|
||||
* use fallback_dist to override small values
|
||||
*/
|
||||
float ED_view3d_offset_distance(float mat[4][4], const float ofs[3], const float fallback_dist)
|
||||
{
|
||||
float pos[4] = {0.0f, 0.0f, 0.0f, 1.0f};
|
||||
float dir[4] = {0.0f, 0.0f, 1.0f, 0.0f};
|
||||
@@ -3990,11 +3995,10 @@ float ED_view3d_offset_distance(float mat[4][4], float ofs[3])
|
||||
|
||||
dist = dot_v3v3(pos, dir);
|
||||
|
||||
/* problem - ofs[3] can be on same location as camera itself.
|
||||
Blender needs proper dist value for zoom */
|
||||
if (fabsf(dist) <= FLT_EPSILON) {
|
||||
return 1.0f;
|
||||
if ((dist < FLT_EPSILON) && (fallback_dist != 0.0f)) {
|
||||
dist = fallback_dist;
|
||||
}
|
||||
|
||||
return dist;
|
||||
}
|
||||
|
||||
|
@@ -161,7 +161,7 @@ void view3d_smooth_view(bContext *C, View3D *v3d, ARegion *ar, Object *oldcamera
|
||||
if (lens) sms.new_lens = *lens;
|
||||
|
||||
if (camera) {
|
||||
sms.new_dist = ED_view3d_offset_distance(camera->obmat, ofs);
|
||||
sms.new_dist = ED_view3d_offset_distance(camera->obmat, ofs, VIEW3D_DIST_FALLBACK);
|
||||
ED_view3d_from_object(camera, sms.new_ofs, sms.new_quat, &sms.new_dist, &sms.new_lens);
|
||||
sms.to_camera = TRUE; /* restore view3d values in end */
|
||||
}
|
||||
@@ -186,7 +186,7 @@ void view3d_smooth_view(bContext *C, View3D *v3d, ARegion *ar, Object *oldcamera
|
||||
|
||||
/* original values */
|
||||
if (oldcamera) {
|
||||
sms.orig_dist = ED_view3d_offset_distance(oldcamera->obmat, rv3d->ofs);
|
||||
sms.orig_dist = ED_view3d_offset_distance(oldcamera->obmat, rv3d->ofs, 0.0f);
|
||||
ED_view3d_from_object(oldcamera, sms.orig_ofs, sms.orig_quat, &sms.orig_dist, &sms.orig_lens);
|
||||
}
|
||||
else {
|
||||
|
Reference in New Issue
Block a user