diff options
author | Campbell Barton <ideasman42@gmail.com> | 2011-11-20 09:56:21 +0400 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2011-11-20 09:56:21 +0400 |
commit | e5f40a1aacfbdad8f802d6e80ea16c687d765daf (patch) | |
tree | 6057bda363ef3772ae3d7af9f445a94f2b8a7f05 /source/blender/blenkernel/intern | |
parent | acf30220c9d63e0f060ee69115fe82016de025d4 (diff) |
- pyapi mathutils.geometry.intersect_plane_plane
- isect_plane_plane_v3 uses better method
- minor refactor - arg name changes & some args as const.
Diffstat (limited to 'source/blender/blenkernel/intern')
-rw-r--r-- | source/blender/blenkernel/intern/camera.c | 72 |
1 files changed, 33 insertions, 39 deletions
diff --git a/source/blender/blenkernel/intern/camera.c b/source/blender/blenkernel/intern/camera.c index da7c0ab1774..08e8a80750e 100644 --- a/source/blender/blenkernel/intern/camera.c +++ b/source/blender/blenkernel/intern/camera.c @@ -456,7 +456,7 @@ static void camera_to_frame_view_cb(const float co[3], void *user_data) unsigned int i; for (i= 0; i < 4; i++) { - float nd= -dist_to_plane_v3(co, data->frame_tx[i], data->normal_tx[i]); + float nd= dist_to_plane_v3(co, data->frame_tx[i], data->normal_tx[i]); if (nd < data->dist_vals[i]) { data->dist_vals[i]= nd; } @@ -530,55 +530,49 @@ int camera_view_frame_fit_to_scene(Scene *scene, struct View3D *v3d, Object *cam mul_v3_v3fl(plane_tx[i], data_cb.normal_tx[i], data_cb.dist_vals[i]); } - if ( (isect_plane_plane_v3(plane_isect_1, plane_isect_1_no, - plane_tx[0], data_cb.normal_tx[0], - plane_tx[2], data_cb.normal_tx[2]) == 0) || - (isect_plane_plane_v3(plane_isect_2, plane_isect_2_no, - plane_tx[1], data_cb.normal_tx[1], - plane_tx[3], data_cb.normal_tx[3]) == 0)) + isect_plane_plane_v3(plane_isect_1, plane_isect_1_no, + plane_tx[0], data_cb.normal_tx[0], + plane_tx[2], data_cb.normal_tx[2]); + isect_plane_plane_v3(plane_isect_2, plane_isect_2_no, + plane_tx[1], data_cb.normal_tx[1], + plane_tx[3], data_cb.normal_tx[3]); + + add_v3_v3v3(plane_isect_1_other, plane_isect_1, plane_isect_1_no); + add_v3_v3v3(plane_isect_2_other, plane_isect_2, plane_isect_2_no); + + if (isect_line_line_v3(plane_isect_1, plane_isect_1_other, + plane_isect_2, plane_isect_2_other, + plane_isect_pt_1, plane_isect_pt_2) == 0) { - /* this is very unlikely */ return FALSE; } else { + float cam_plane_no[3]= {0.0f, 0.0f, -1.0f}; + float plane_isect_delta[3]; + float plane_isect_delta_len; - add_v3_v3v3(plane_isect_1_other, plane_isect_1, plane_isect_1_no); - add_v3_v3v3(plane_isect_2_other, plane_isect_2, plane_isect_2_no); - - if (isect_line_line_v3(plane_isect_1, plane_isect_1_other, - plane_isect_2, plane_isect_2_other, - plane_isect_pt_1, plane_isect_pt_2) == 0) - { - return FALSE; - } - else { - float cam_plane_no[3]= {0.0f, 0.0f, -1.0f}; - float plane_isect_delta[3]; - float plane_isect_delta_len; - - mul_m3_v3(rot_obmat, cam_plane_no); + mul_m3_v3(rot_obmat, cam_plane_no); - sub_v3_v3v3(plane_isect_delta, plane_isect_pt_2, plane_isect_pt_1); - plane_isect_delta_len= len_v3(plane_isect_delta); + sub_v3_v3v3(plane_isect_delta, plane_isect_pt_2, plane_isect_pt_1); + plane_isect_delta_len= len_v3(plane_isect_delta); - if (dot_v3v3(plane_isect_delta, cam_plane_no) > 0.0f) { - copy_v3_v3(r_co, plane_isect_pt_1); + if (dot_v3v3(plane_isect_delta, cam_plane_no) > 0.0f) { + copy_v3_v3(r_co, plane_isect_pt_1); - /* offset shift */ - normalize_v3(plane_isect_1_no); - madd_v3_v3fl(r_co, plane_isect_1_no, shift[1] * -plane_isect_delta_len); - } - else { - copy_v3_v3(r_co, plane_isect_pt_2); + /* offset shift */ + normalize_v3(plane_isect_1_no); + madd_v3_v3fl(r_co, plane_isect_1_no, shift[1] * -plane_isect_delta_len); + } + else { + copy_v3_v3(r_co, plane_isect_pt_2); - /* offset shift */ - normalize_v3(plane_isect_2_no); - madd_v3_v3fl(r_co, plane_isect_2_no, shift[0] * -plane_isect_delta_len); - } + /* offset shift */ + normalize_v3(plane_isect_2_no); + madd_v3_v3fl(r_co, plane_isect_2_no, shift[0] * -plane_isect_delta_len); + } - return TRUE; - } + return TRUE; } } } |