diff options
author | Campbell Barton <campbell@blender.org> | 2022-09-30 07:16:14 +0300 |
---|---|---|
committer | Campbell Barton <campbell@blender.org> | 2022-09-30 07:51:49 +0300 |
commit | 8bdd4b468554446cb1351785f0db751e2f84341f (patch) | |
tree | d81bda8a17f036de212b2982d7b13093f5b35a9e /source/blender/editors/space_view3d/view3d_draw.cc | |
parent | 1c1dc5f8440d918aca480904c53e31a528aef42f (diff) |
Cleanup: use function style casts for C++
Diffstat (limited to 'source/blender/editors/space_view3d/view3d_draw.cc')
-rw-r--r-- | source/blender/editors/space_view3d/view3d_draw.cc | 50 |
1 files changed, 25 insertions, 25 deletions
diff --git a/source/blender/editors/space_view3d/view3d_draw.cc b/source/blender/editors/space_view3d/view3d_draw.cc index 6ae44594db9..57c104455cd 100644 --- a/source/blender/editors/space_view3d/view3d_draw.cc +++ b/source/blender/editors/space_view3d/view3d_draw.cc @@ -122,8 +122,8 @@ void ED_view3d_update_viewmat(Depsgraph *depsgraph, else { float rect_scale[2]; if (rect) { - rect_scale[0] = (float)BLI_rcti_size_x(rect) / (float)region->winx; - rect_scale[1] = (float)BLI_rcti_size_y(rect) / (float)region->winy; + rect_scale[0] = float(BLI_rcti_size_x(rect)) / float(region->winx); + rect_scale[1] = float(BLI_rcti_size_y(rect)) / float(region->winy); } /* NOTE: calls BKE_object_where_is_calc for camera... */ view3d_viewmatrix_set(depsgraph, scene, v3d, rv3d, rect ? rect_scale : nullptr); @@ -139,11 +139,11 @@ void ED_view3d_update_viewmat(Depsgraph *depsgraph, if (!offscreen && rv3d->persp == RV3D_CAMOB && v3d->camera) { rctf cameraborder; ED_view3d_calc_camera_border(scene, depsgraph, region, v3d, rv3d, &cameraborder, false); - rv3d->viewcamtexcofac[0] = (float)region->winx / BLI_rctf_size_x(&cameraborder); - rv3d->viewcamtexcofac[1] = (float)region->winy / BLI_rctf_size_y(&cameraborder); + rv3d->viewcamtexcofac[0] = float(region->winx) / BLI_rctf_size_x(&cameraborder); + rv3d->viewcamtexcofac[1] = float(region->winy) / BLI_rctf_size_y(&cameraborder); - rv3d->viewcamtexcofac[2] = -rv3d->viewcamtexcofac[0] * cameraborder.xmin / (float)region->winx; - rv3d->viewcamtexcofac[3] = -rv3d->viewcamtexcofac[1] * cameraborder.ymin / (float)region->winy; + rv3d->viewcamtexcofac[2] = -rv3d->viewcamtexcofac[0] * cameraborder.xmin / float(region->winx); + rv3d->viewcamtexcofac[3] = -rv3d->viewcamtexcofac[1] * cameraborder.ymin / float(region->winy); } else { rv3d->viewcamtexcofac[0] = rv3d->viewcamtexcofac[1] = 1.0f; @@ -168,10 +168,10 @@ void ED_view3d_update_viewmat(Depsgraph *depsgraph, len_px = 2.0f / sqrtf(min_ff(len_squared_v3(v1), len_squared_v3(v2))); if (rect) { - len_sc = (float)max_ii(BLI_rcti_size_x(rect), BLI_rcti_size_y(rect)); + len_sc = float(max_ii(BLI_rcti_size_x(rect), BLI_rcti_size_y(rect))); } else { - len_sc = (float)MAX2(region->winx, region->winy); + len_sc = float(MAX2(region->winx, region->winy)); } rv3d->pixsize = len_px / len_sc; @@ -561,10 +561,10 @@ static void drawviewborder(Scene *scene, Depsgraph *depsgraph, ARegion *region, * obscures the 3D camera border */ /* NOTE: with VIEW3D_CAMERA_BORDER_HACK defined this error isn't noticeable * but keep it here in case we need to remove the workaround */ - x1i = (int)(x1 - 1.0001f); - y1i = (int)(y1 - 1.0001f); - x2i = (int)(x2 + (1.0f - 0.0001f)); - y2i = (int)(y2 + (1.0f - 0.0001f)); + x1i = int(x1 - 1.0001f); + y1i = int(y1 - 1.0001f); + x2i = int(x2 + (1.0f - 0.0001f)); + y2i = int(y2 + (1.0f - 0.0001f)); uint shdr_pos = GPU_vertformat_attr_add( immVertexFormat(), "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT); @@ -843,7 +843,7 @@ float ED_scene_grid_scale(const Scene *scene, const char **r_grid_unit) if (r_grid_unit) { *r_grid_unit = BKE_unit_display_name_get(usys, i); } - return (float)BKE_unit_scalar_get(usys, i) / scene->unit.scale_length; + return float(BKE_unit_scalar_get(usys, i)) / scene->unit.scale_length; } } @@ -877,7 +877,7 @@ void ED_view3d_grid_steps(const Scene *scene, int i; for (i = 0; i < len; i++) { - r_grid_steps[i] = (float)BKE_unit_scalar_get(usys, len - 1 - i) * grid_scale; + r_grid_steps[i] = float(BKE_unit_scalar_get(usys, len - 1 - i)) * grid_scale; } for (; i < STEPS_LEN; i++) { /* Fill last slots */ @@ -1063,7 +1063,7 @@ static void draw_rotation_guide(const RegionView3D *rv3d) # define ROT_AXIS_DETAIL 13 const float s = 0.05f * scale; - const float step = 2.0f * (float)(M_PI / ROT_AXIS_DETAIL); + const float step = 2.0f * float(M_PI / ROT_AXIS_DETAIL); float q[4]; /* rotate ring so it's perpendicular to axis */ const int upright = fabsf(rv3d->rot_axis[2]) >= 0.95f; @@ -1386,7 +1386,7 @@ static void draw_selected_name( /* color depends on whether there is a keyframe */ if (id_frame_has_keyframe( - (ID *)ob, /* BKE_scene_ctime_get(scene) */ (float)cfra, ANIMFILTER_KEYS_LOCAL)) { + (ID *)ob, /* BKE_scene_ctime_get(scene) */ float(cfra), ANIMFILTER_KEYS_LOCAL)) { UI_FontThemeColor(font_id, TH_TIME_KEYFRAME); } else if (ED_gpencil_has_keyframe_v3d(scene, ob, cfra)) { @@ -2216,7 +2216,7 @@ void ED_view3d_select_id_validate(ViewContext *vc) int ED_view3d_backbuf_sample_size_clamp(ARegion *region, const float dist) { - return (int)min_ff(ceilf(dist), (float)max_ii(region->winx, region->winx)); + return int(min_ff(ceilf(dist), float(max_ii(region->winx, region->winx)))); } /** \} */ @@ -2281,7 +2281,7 @@ static ViewDepths *view3d_depths_create(ARegion *region) /* Convert in-place. */ int pixel_count = d->w * d->h; for (int i = 0; i < pixel_count; i++) { - d->depths[i] = (int_depths[i] >> 8u) / (float)0xFFFFFF; + d->depths[i] = (int_depths[i] >> 8u) / float(0xFFFFFF); } /* Assumed to be this as they are never changed. */ d->depth_range[0] = 0.0; @@ -2293,13 +2293,13 @@ static ViewDepths *view3d_depths_create(ARegion *region) float view3d_depth_near(ViewDepths *d) { /* Convert to float for comparisons. */ - const float near = (float)d->depth_range[0]; - const float far_real = (float)d->depth_range[1]; + const float near = float(d->depth_range[0]); + const float far_real = float(d->depth_range[1]); float far = far_real; const float *depths = d->depths; float depth = FLT_MAX; - int i = (int)d->w * (int)d->h; /* Cast to avoid short overflow. */ + int i = int(d->w) * int(d->h); /* Cast to avoid short overflow. */ /* Far is both the starting 'far' value * and the closest value found. */ @@ -2515,8 +2515,8 @@ void ED_scene_draw_fps(const Scene *scene, int xoffset, int *yoffset) printable[0] = '\0'; /* Doing an average for a more robust calculation. */ - fpsi->redrawtimes_fps[fpsi->redrawtime_index] = (float)(1.0 / - (fpsi->lredrawtime - fpsi->redrawtime)); + fpsi->redrawtimes_fps[fpsi->redrawtime_index] = float(1.0 / + (fpsi->lredrawtime - fpsi->redrawtime)); float fps = 0.0f; int tot = 0; @@ -2534,13 +2534,13 @@ void ED_scene_draw_fps(const Scene *scene, int xoffset, int *yoffset) const int font_id = BLF_default(); /* Is this more than half a frame behind? */ - if (fps + 0.5f < (float)(FPS)) { + if (fps + 0.5f < float(FPS)) { UI_FontThemeColor(font_id, TH_REDALERT); BLI_snprintf(printable, sizeof(printable), IFACE_("fps: %.2f"), fps); } else { UI_FontThemeColor(font_id, TH_TEXT_HI); - BLI_snprintf(printable, sizeof(printable), IFACE_("fps: %i"), (int)(fps + 0.5f)); + BLI_snprintf(printable, sizeof(printable), IFACE_("fps: %i"), int(fps + 0.5f)); } BLF_enable(font_id, BLF_SHADOW); |