diff options
author | Sybren A. Stüvel <sybren@blender.org> | 2020-08-07 13:30:43 +0300 |
---|---|---|
committer | Sybren A. Stüvel <sybren@blender.org> | 2020-08-07 14:38:06 +0300 |
commit | 1b272a649b40e99dba4185167f6cee7cbece1942 (patch) | |
tree | 2785f52c566b36cbdcbf9355f698dc520ffbb482 /source/blender/blenkernel/intern/camera.c | |
parent | cfc6f9eb18e701f5be601b95c45004e8cf7fbc81 (diff) |
Cleanup: Blenkernel, Clang-Tidy else-after-return fixes
This addresses warnings from Clang-Tidy's `readability-else-after-return`
rule in the `source/blender/blenkernel` module.
No functional changes.
Diffstat (limited to 'source/blender/blenkernel/intern/camera.c')
-rw-r--r-- | source/blender/blenkernel/intern/camera.c | 124 |
1 files changed, 59 insertions, 65 deletions
diff --git a/source/blender/blenkernel/intern/camera.c b/source/blender/blenkernel/intern/camera.c index 7c0e4064cdb..d8b4150b2b1 100644 --- a/source/blender/blenkernel/intern/camera.c +++ b/source/blender/blenkernel/intern/camera.c @@ -186,9 +186,8 @@ int BKE_camera_sensor_fit(int sensor_fit, float sizex, float sizey) if (sizex >= sizey) { return CAMERA_SENSOR_FIT_HOR; } - else { - return CAMERA_SENSOR_FIT_VERT; - } + + return CAMERA_SENSOR_FIT_VERT; } return sensor_fit; @@ -636,64 +635,63 @@ static bool camera_frame_fit_calc_from_data(CameraParams *params, return true; } - else { - float plane_isect_1[3], plane_isect_1_no[3], plane_isect_1_other[3]; - float plane_isect_2[3], plane_isect_2_no[3], plane_isect_2_other[3]; - float plane_isect_pt_1[3], plane_isect_pt_2[3]; + float plane_isect_1[3], plane_isect_1_no[3], plane_isect_1_other[3]; + float plane_isect_2[3], plane_isect_2_no[3], plane_isect_2_other[3]; - /* apply the dist-from-plane's to the transformed plane points */ - for (i = 0; i < CAMERA_VIEWFRAME_NUM_PLANES; i++) { - float co[3]; - mul_v3_v3fl(co, data->normal_tx[i], sqrtf_signed(data->dist_vals_sq[i])); - plane_from_point_normal_v3(plane_tx[i], co, data->normal_tx[i]); - } + float plane_isect_pt_1[3], plane_isect_pt_2[3]; - if ((!isect_plane_plane_v3(plane_tx[0], plane_tx[2], plane_isect_1, plane_isect_1_no)) || - (!isect_plane_plane_v3(plane_tx[1], plane_tx[3], plane_isect_2, plane_isect_2_no))) { - return false; - } + /* apply the dist-from-plane's to the transformed plane points */ + for (i = 0; i < CAMERA_VIEWFRAME_NUM_PLANES; i++) { + float co[3]; + mul_v3_v3fl(co, data->normal_tx[i], sqrtf_signed(data->dist_vals_sq[i])); + plane_from_point_normal_v3(plane_tx[i], co, data->normal_tx[i]); + } - 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_plane_plane_v3(plane_tx[0], plane_tx[2], plane_isect_1, plane_isect_1_no)) || + (!isect_plane_plane_v3(plane_tx[1], plane_tx[3], plane_isect_2, plane_isect_2_no))) { + return false; + } - 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) { - float cam_plane_no[3]; - 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); - float shift_fac = BKE_camera_sensor_size( - params->sensor_fit, params->sensor_x, params->sensor_y) / - params->lens; + 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) { + float cam_plane_no[3]; + float plane_isect_delta[3]; + float plane_isect_delta_len; - /* we want (0, 0, -1) transformed by camera_rotmat, this is a quicker shortcut. */ - negate_v3_v3(cam_plane_no, data->camera_rotmat[2]); + float shift_fac = BKE_camera_sensor_size( + params->sensor_fit, params->sensor_x, params->sensor_y) / + params->lens; - sub_v3_v3v3(plane_isect_delta, plane_isect_pt_2, plane_isect_pt_1); - plane_isect_delta_len = len_v3(plane_isect_delta); + /* we want (0, 0, -1) transformed by camera_rotmat, this is a quicker shortcut. */ + negate_v3_v3(cam_plane_no, data->camera_rotmat[2]); - if (dot_v3v3(plane_isect_delta, cam_plane_no) > 0.0f) { - copy_v3_v3(r_co, plane_isect_pt_1); + sub_v3_v3v3(plane_isect_delta, plane_isect_pt_2, plane_isect_pt_1); + plane_isect_delta_len = len_v3(plane_isect_delta); - /* offset shift */ - normalize_v3(plane_isect_1_no); - madd_v3_v3fl(r_co, plane_isect_1_no, params->shifty * plane_isect_delta_len * shift_fac); - } - else { - copy_v3_v3(r_co, plane_isect_pt_2); + 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_2_no); - madd_v3_v3fl(r_co, plane_isect_2_no, params->shiftx * plane_isect_delta_len * shift_fac); - } + /* offset shift */ + normalize_v3(plane_isect_1_no); + madd_v3_v3fl(r_co, plane_isect_1_no, params->shifty * plane_isect_delta_len * shift_fac); + } + else { + copy_v3_v3(r_co, plane_isect_pt_2); - return true; + /* offset shift */ + normalize_v3(plane_isect_2_no); + madd_v3_v3fl(r_co, plane_isect_2_no, params->shiftx * plane_isect_delta_len * shift_fac); } + + return true; } return false; @@ -775,11 +773,10 @@ static void camera_stereo3d_model_matrix(const Object *camera, camera_model_matrix(camera, r_modelmat); return; } - else { - float size[3]; - mat4_to_size(size, camera->obmat); - size_to_mat4(sizemat, size); - } + + float size[3]; + mat4_to_size(size, camera->obmat); + size_to_mat4(sizemat, size); if (pivot == CAM_S3D_PIVOT_CENTER) { fac = 0.5f; @@ -931,9 +928,8 @@ bool BKE_camera_multiview_spherical_stereo(const RenderData *rd, const Object *c if (camera->type != OB_CAMERA) { return false; } - else { - cam = camera->data; - } + + cam = camera->data; if ((rd->views_format == SCE_VIEWS_FORMAT_STEREO_3D) && ELEM(cam->type, CAM_PANO, CAM_PERSP) && ((cam->stereo.flag & CAM_S3D_SPHERICAL) != 0)) { @@ -984,13 +980,12 @@ Object *BKE_camera_multiview_render(const Scene *scene, Object *camera, const ch if (!is_multiview) { return camera; } - else if (scene->r.views_format == SCE_VIEWS_FORMAT_STEREO_3D) { + if (scene->r.views_format == SCE_VIEWS_FORMAT_STEREO_3D) { return camera; } - else { /* SCE_VIEWS_FORMAT_MULTIVIEW */ - const char *suffix = BKE_scene_multiview_view_suffix_get(&scene->r, viewname); - return camera_multiview_advanced(scene, camera, suffix); - } + /* SCE_VIEWS_FORMAT_MULTIVIEW */ + const char *suffix = BKE_scene_multiview_view_suffix_get(&scene->r, viewname); + return camera_multiview_advanced(scene, camera, suffix); } static float camera_stereo3d_shift_x(const Object *camera, const char *viewname) @@ -1044,12 +1039,11 @@ float BKE_camera_multiview_shift_x(const RenderData *rd, if (!is_multiview) { return data->shiftx; } - else if (rd->views_format == SCE_VIEWS_FORMAT_MULTIVIEW) { + if (rd->views_format == SCE_VIEWS_FORMAT_MULTIVIEW) { return data->shiftx; } - else { /* SCE_VIEWS_SETUP_BASIC */ - return camera_stereo3d_shift_x(camera, viewname); - } + /* SCE_VIEWS_SETUP_BASIC */ + return camera_stereo3d_shift_x(camera, viewname); } void BKE_camera_multiview_params(const RenderData *rd, |