From 735515a3f9e4c41738bf714d682b13db64adb638 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Mon, 22 Apr 2019 09:39:35 +1000 Subject: Cleanup: style, use braces for blenkernel --- source/blender/blenkernel/intern/camera.c | 54 ++++++++++++++++++++----------- 1 file changed, 36 insertions(+), 18 deletions(-) (limited to 'source/blender/blenkernel/intern/camera.c') diff --git a/source/blender/blenkernel/intern/camera.c b/source/blender/blenkernel/intern/camera.c index f4d09be2991..59811cfe373 100644 --- a/source/blender/blenkernel/intern/camera.c +++ b/source/blender/blenkernel/intern/camera.c @@ -129,8 +129,9 @@ void BKE_camera_free(Camera *ca) float BKE_camera_object_dof_distance(Object *ob) { Camera *cam = (Camera *)ob->data; - if (ob->type != OB_CAMERA) + if (ob->type != OB_CAMERA) { return 0.0f; + } if (cam->dof_ob) { float view_dir[3], dof_dir[3]; normalize_v3_v3(view_dir, ob->obmat[2]); @@ -143,8 +144,9 @@ float BKE_camera_object_dof_distance(Object *ob) float BKE_camera_sensor_size(int sensor_fit, float sensor_x, float sensor_y) { /* sensor size used to fit to. for auto, sensor_x is both x and y. */ - if (sensor_fit == CAMERA_SENSOR_FIT_VERT) + if (sensor_fit == CAMERA_SENSOR_FIT_VERT) { return sensor_y; + } return sensor_x; } @@ -152,10 +154,12 @@ float BKE_camera_sensor_size(int sensor_fit, float sensor_x, float sensor_y) int BKE_camera_sensor_fit(int sensor_fit, float sizex, float sizey) { if (sensor_fit == CAMERA_SENSOR_FIT_AUTO) { - if (sizex >= sizey) + if (sizex >= sizey) { return CAMERA_SENSOR_FIT_HOR; - else + } + else { return CAMERA_SENSOR_FIT_VERT; + } } return sensor_fit; @@ -181,15 +185,17 @@ void BKE_camera_params_init(CameraParams *params) void BKE_camera_params_from_object(CameraParams *params, const Object *ob) { - if (!ob) + if (!ob) { return; + } if (ob->type == OB_CAMERA) { /* camera object */ Camera *cam = ob->data; - if (cam->type == CAM_ORTHO) + if (cam->type == CAM_ORTHO) { params->is_ortho = true; + } params->lens = cam->lens; params->ortho_scale = cam->ortho_scale; @@ -207,8 +213,9 @@ void BKE_camera_params_from_object(CameraParams *params, const Object *ob) /* light object */ Light *la = ob->data; params->lens = 16.0f / tanf(la->spotsize * 0.5f); - if (params->lens == 0.0f) + if (params->lens == 0.0f) { params->lens = 35.0f; + } } else { params->lens = 35.0f; @@ -282,10 +289,12 @@ void BKE_camera_params_compute_viewplane( /* determine sensor fit */ sensor_fit = BKE_camera_sensor_fit(params->sensor_fit, xasp * winx, yasp * winy); - if (sensor_fit == CAMERA_SENSOR_FIT_HOR) + if (sensor_fit == CAMERA_SENSOR_FIT_HOR) { viewfac = winx; - else + } + else { viewfac = params->ycor * winy; + } pixsize /= viewfac; @@ -328,7 +337,7 @@ void BKE_camera_params_compute_matrix(CameraParams *params) rctf viewplane = params->viewplane; /* compute projection matrix */ - if (params->is_ortho) + if (params->is_ortho) { orthographic_m4(params->winmat, viewplane.xmin, viewplane.xmax, @@ -336,7 +345,8 @@ void BKE_camera_params_compute_matrix(CameraParams *params) viewplane.ymax, params->clip_start, params->clip_end); - else + } + else { perspective_m4(params->winmat, viewplane.xmin, viewplane.xmax, @@ -344,6 +354,7 @@ void BKE_camera_params_compute_matrix(CameraParams *params) viewplane.ymax, params->clip_start, params->clip_end); + } } /***************************** Camera View Frame *****************************/ @@ -723,8 +734,9 @@ static void camera_stereo3d_model_matrix(const Object *camera, size_to_mat4(sizemat, size); } - if (pivot == CAM_S3D_PIVOT_CENTER) + if (pivot == CAM_S3D_PIVOT_CENTER) { fac = 0.5f; + } fac_signed = is_left ? fac : -fac; @@ -865,13 +877,16 @@ bool BKE_camera_multiview_spherical_stereo(RenderData *rd, const Object *camera) Camera *cam; const bool is_multiview = (rd && rd->scemode & R_MULTIVIEW) != 0; - if (!is_multiview) + if (!is_multiview) { return false; + } - if (camera->type != OB_CAMERA) + if (camera->type != OB_CAMERA) { return false; - else + } + else { 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)) { @@ -895,8 +910,9 @@ static Object *camera_multiview_advanced(Scene *scene, Object *camera, const cha for (srv = scene->r.views.first; srv; srv = srv->next) { const int len_suffix = strlen(srv->suffix); - if ((len_suffix < len_suffix_max) || (len_name < len_suffix)) + if ((len_suffix < len_suffix_max) || (len_name < len_suffix)) { continue; + } if (STREQ(camera_name + (len_name - len_suffix), srv->suffix)) { BLI_snprintf(name, sizeof(name), "%.*s%s", (len_name - len_suffix), camera_name, suffix); @@ -951,15 +967,17 @@ static float camera_stereo3d_shift_x(const Object *camera, const char *viewname) convergence_mode = data->stereo.convergence_mode; pivot = data->stereo.pivot; - if (convergence_mode != CAM_S3D_OFFAXIS) + if (convergence_mode != CAM_S3D_OFFAXIS) { return shift; + } if (((pivot == CAM_S3D_PIVOT_LEFT) && is_left) || ((pivot == CAM_S3D_PIVOT_RIGHT) && !is_left)) { return shift; } - if (pivot == CAM_S3D_PIVOT_CENTER) + if (pivot == CAM_S3D_PIVOT_CENTER) { fac = 0.5f; + } fac_signed = is_left ? fac : -fac; shift += ((interocular_distance / data->sensor_x) * (data->lens / convergence_distance)) * -- cgit v1.2.3