Cleanup: Draw, Clang-Tidy else-after-return fixes (incomplete)

This addresses warnings from Clang-Tidy's `readability-else-after-return`
rule in the `source/blender/draw` module. Not all warnings are addressed
in this commit.

No functional changes.
This commit is contained in:
Sybren A. Stüvel 2020-08-07 11:49:59 +02:00
parent 88cc3f167f
commit 156448ba4b
21 changed files with 198 additions and 246 deletions

View File

@ -1021,9 +1021,8 @@ static void compute_cell_id(EEVEE_LightGrid *egrid,
if (visited_cells == cell_idx) { if (visited_cells == cell_idx) {
return; return;
} }
else {
visited_cells++; visited_cells++;
}
} }
} }
} }

View File

@ -483,9 +483,8 @@ static EeveeMaterialCache material_opaque(EEVEE_Data *vedata,
if (BLI_ghash_ensure_p(pd->material_hash, key, (void ***)&emc_p)) { if (BLI_ghash_ensure_p(pd->material_hash, key, (void ***)&emc_p)) {
return **emc_p; return **emc_p;
} }
else {
*emc_p = emc = BLI_memblock_alloc(sldata->material_cache); *emc_p = emc = BLI_memblock_alloc(sldata->material_cache);
}
material_shadow(vedata, sldata, ma, is_hair, emc); material_shadow(vedata, sldata, ma, is_hair, emc);

View File

@ -480,16 +480,15 @@ void EEVEE_motion_blur_cache_finish(EEVEE_Data *vedata)
GPU_VERTBUF_DISCARD_SAFE(mb_geom->vbo[MB_NEXT]); GPU_VERTBUF_DISCARD_SAFE(mb_geom->vbo[MB_NEXT]);
break; break;
} }
/* Modify the batch to include the previous & next position. */
if (i == MB_PREV) {
GPU_batch_vertbuf_add_ex(batch, vbo, true);
mb_geom->vbo[i] = NULL;
}
else { else {
/* Modify the batch to include the previous & next position. */ /* This VBO can be reuse by next time step. Don't pass ownership. */
if (i == MB_PREV) { GPU_batch_vertbuf_add_ex(batch, vbo, false);
GPU_batch_vertbuf_add_ex(batch, vbo, true);
mb_geom->vbo[i] = NULL;
}
else {
/* This VBO can be reuse by next time step. Don't pass ownership. */
GPU_batch_vertbuf_add_ex(batch, vbo, false);
}
} }
} }
} }

View File

@ -132,12 +132,11 @@ static int gpencil_tobject_dist_sort(const void *a, const void *b)
if (ob_a->camera_z > ob_b->camera_z) { if (ob_a->camera_z > ob_b->camera_z) {
return 1; return 1;
} }
else if (ob_a->camera_z < ob_b->camera_z) { if (ob_a->camera_z < ob_b->camera_z) {
return -1; return -1;
} }
else {
return 0; return 0;
}
} }
void gpencil_object_cache_sort(GPENCIL_PrivateData *pd) void gpencil_object_cache_sort(GPENCIL_PrivateData *pd)
@ -193,7 +192,7 @@ static float gpencil_layer_final_opacity_get(const GPENCIL_PrivateData *pd,
if (is_obact && is_fade) { if (is_obact && is_fade) {
return gpl->opacity * pd->fade_layer_opacity; return gpl->opacity * pd->fade_layer_opacity;
} }
else if (!is_obact && (pd->fade_gp_object_opacity > -1.0f)) { if (!is_obact && (pd->fade_gp_object_opacity > -1.0f)) {
return gpl->opacity * pd->fade_gp_object_opacity; return gpl->opacity * pd->fade_gp_object_opacity;
} }
} }

View File

@ -359,12 +359,11 @@ static float light_power_get(const Light *la)
if (la->type == LA_AREA) { if (la->type == LA_AREA) {
return 1.0f / (4.0f * M_PI); return 1.0f / (4.0f * M_PI);
} }
else if (la->type == LA_SPOT || la->type == LA_LOCAL) { if (la->type == LA_SPOT || la->type == LA_LOCAL) {
return 1.0f / (4.0f * M_PI * M_PI); return 1.0f / (4.0f * M_PI * M_PI);
} }
else {
return 1.0f / M_PI; return 1.0f / M_PI;
}
} }
void gpencil_light_pool_populate(GPENCIL_LightPool *lightpool, Object *ob) void gpencil_light_pool_populate(GPENCIL_LightPool *lightpool, Object *ob)

View File

@ -924,12 +924,11 @@ static float get_bone_wire_thickness(const ArmatureDrawContext *ctx, int bonefla
if (ctx->const_color) { if (ctx->const_color) {
return ctx->const_wire; return ctx->const_wire;
} }
else if (boneflag & (BONE_DRAW_ACTIVE | BONE_SELECTED)) { if (boneflag & (BONE_DRAW_ACTIVE | BONE_SELECTED)) {
return 2.0f; return 2.0f;
} }
else {
return 1.0f; return 1.0f;
}
} }
static const float *get_bone_wire_color(const ArmatureDrawContext *ctx, static const float *get_bone_wire_color(const ArmatureDrawContext *ctx,
@ -2219,13 +2218,13 @@ static bool POSE_is_driven_by_active_armature(Object *ob)
} }
return is_active; return is_active;
} }
else {
Object *ob_mesh_deform = BKE_modifiers_is_deformed_by_meshdeform(ob); Object *ob_mesh_deform = BKE_modifiers_is_deformed_by_meshdeform(ob);
if (ob_mesh_deform) { if (ob_mesh_deform) {
/* Recursive. */ /* Recursive. */
return POSE_is_driven_by_active_armature(ob_mesh_deform); return POSE_is_driven_by_active_armature(ob_mesh_deform);
}
} }
return false; return false;
} }

View File

@ -1018,9 +1018,8 @@ static float camera_offaxis_shiftx_get(Scene *scene,
const float width = instdata->corner_x * 2.0f; const float width = instdata->corner_x * 2.0f;
return delta_shiftx * width; return delta_shiftx * width;
} }
else {
return 0.0; return 0.0;
}
} }
/** /**
* Draw the stereo 3d support elements (cameras, plane, volume). * Draw the stereo 3d support elements (cameras, plane, volume).

View File

@ -109,13 +109,12 @@ static eStereoViews camera_background_images_stereo_eye(const Scene *scene, cons
if ((scene->r.scemode & R_MULTIVIEW) == 0) { if ((scene->r.scemode & R_MULTIVIEW) == 0) {
return STEREO_LEFT_ID; return STEREO_LEFT_ID;
} }
else if (v3d->stereo3d_camera != STEREO_3D_ID) { if (v3d->stereo3d_camera != STEREO_3D_ID) {
/* show only left or right camera */ /* show only left or right camera */
return v3d->stereo3d_camera; return v3d->stereo3d_camera;
} }
else {
return v3d->multiview_eye; return v3d->multiview_eye;
}
} }
static void camera_background_images_stereo_setup(const Scene *scene, static void camera_background_images_stereo_setup(const Scene *scene,
@ -162,9 +161,8 @@ static struct GPUTexture *image_camera_background_texture_get(CameraBGImage *bgp
/* Frame is out of range, dont show. */ /* Frame is out of range, dont show. */
return NULL; return NULL;
} }
else {
camera_background_images_stereo_setup(scene, draw_ctx->v3d, image, iuser); camera_background_images_stereo_setup(scene, draw_ctx->v3d, image, iuser);
}
iuser->scene = draw_ctx->scene; iuser->scene = draw_ctx->scene;
ImBuf *ibuf = BKE_image_acquire_ibuf(image, iuser, &lock); ImBuf *ibuf = BKE_image_acquire_ibuf(image, iuser, &lock);

View File

@ -36,7 +36,7 @@ static bool paint_object_is_rendered_transparent(View3D *v3d, Object *ob)
if (v3d->shading.type == OB_WIRE) { if (v3d->shading.type == OB_WIRE) {
return true; return true;
} }
else if (v3d->shading.type == OB_SOLID) { if (v3d->shading.type == OB_SOLID) {
if (v3d->shading.flag & V3D_SHADING_XRAY) { if (v3d->shading.flag & V3D_SHADING_XRAY) {
return true; return true;
} }
@ -44,8 +44,8 @@ static bool paint_object_is_rendered_transparent(View3D *v3d, Object *ob)
if (ob && v3d->shading.color_type == V3D_SHADING_OBJECT_COLOR) { if (ob && v3d->shading.color_type == V3D_SHADING_OBJECT_COLOR) {
return ob->color[3] < 1.0f; return ob->color[3] < 1.0f;
} }
else if (ob && ob->type == OB_MESH && ob->data && if (ob && ob->type == OB_MESH && ob->data &&
v3d->shading.color_type == V3D_SHADING_MATERIAL_COLOR) { v3d->shading.color_type == V3D_SHADING_MATERIAL_COLOR) {
Mesh *me = ob->data; Mesh *me = ob->data;
for (int i = 0; i < me->totcol; i++) { for (int i = 0; i < me->totcol; i++) {
Material *mat = me->mat[i]; Material *mat = me->mat[i];

View File

@ -112,17 +112,15 @@ int workbench_antialiasing_sample_count_get(WORKBENCH_PrivateData *wpd)
/* Only draw using SMAA or no AA when navigating. */ /* Only draw using SMAA or no AA when navigating. */
return min_ii(wpd->preferences->viewport_aa, 1); return min_ii(wpd->preferences->viewport_aa, 1);
} }
else if (DRW_state_is_image_render()) { if (DRW_state_is_image_render()) {
if (draw_ctx->v3d) { if (draw_ctx->v3d) {
return scene->display.viewport_aa; return scene->display.viewport_aa;
} }
else {
return scene->display.render_aa; return scene->display.render_aa;
}
}
else {
return wpd->preferences->viewport_aa;
} }
return wpd->preferences->viewport_aa;
} }
void workbench_antialiasing_view_updated(WORKBENCH_Data *vedata) void workbench_antialiasing_view_updated(WORKBENCH_Data *vedata)
@ -361,53 +359,52 @@ bool workbench_antialiasing_setup(WORKBENCH_Data *vedata)
/* TAA accumulation has finish. Just copy the result back */ /* TAA accumulation has finish. Just copy the result back */
return false; return false;
} }
else {
const float *viewport_size = DRW_viewport_size_get();
const DRWView *default_view = DRW_view_default_get();
float *transform_offset;
switch (wpd->taa_sample_len) { const float *viewport_size = DRW_viewport_size_get();
default: const DRWView *default_view = DRW_view_default_get();
case 5: float *transform_offset;
transform_offset = e_data.jitter_5[min_ii(wpd->taa_sample, 5)];
break;
case 8:
transform_offset = e_data.jitter_8[min_ii(wpd->taa_sample, 8)];
break;
case 11:
transform_offset = e_data.jitter_11[min_ii(wpd->taa_sample, 11)];
break;
case 16:
transform_offset = e_data.jitter_16[min_ii(wpd->taa_sample, 16)];
break;
case 32:
transform_offset = e_data.jitter_32[min_ii(wpd->taa_sample, 32)];
break;
}
/* construct new matrices from transform delta */ switch (wpd->taa_sample_len) {
float winmat[4][4], viewmat[4][4], persmat[4][4]; default:
DRW_view_winmat_get(default_view, winmat, false); case 5:
DRW_view_viewmat_get(default_view, viewmat, false); transform_offset = e_data.jitter_5[min_ii(wpd->taa_sample, 5)];
DRW_view_persmat_get(default_view, persmat, false); break;
case 8:
window_translate_m4(winmat, transform_offset = e_data.jitter_8[min_ii(wpd->taa_sample, 8)];
persmat, break;
transform_offset[0] / viewport_size[0], case 11:
transform_offset[1] / viewport_size[1]); transform_offset = e_data.jitter_11[min_ii(wpd->taa_sample, 11)];
break;
if (wpd->view) { case 16:
/* When rendering just update the view. This avoids recomputing the culling. */ transform_offset = e_data.jitter_16[min_ii(wpd->taa_sample, 16)];
DRW_view_update_sub(wpd->view, viewmat, winmat); break;
} case 32:
else { transform_offset = e_data.jitter_32[min_ii(wpd->taa_sample, 32)];
/* TAA is not making a big change to the matrices. break;
* Reuse the main view culling by creating a sub-view. */
wpd->view = DRW_view_create_sub(default_view, viewmat, winmat);
}
DRW_view_set_active(wpd->view);
return true;
} }
/* construct new matrices from transform delta */
float winmat[4][4], viewmat[4][4], persmat[4][4];
DRW_view_winmat_get(default_view, winmat, false);
DRW_view_viewmat_get(default_view, viewmat, false);
DRW_view_persmat_get(default_view, persmat, false);
window_translate_m4(winmat,
persmat,
transform_offset[0] / viewport_size[0],
transform_offset[1] / viewport_size[1]);
if (wpd->view) {
/* When rendering just update the view. This avoids recomputing the culling. */
DRW_view_update_sub(wpd->view, viewmat, winmat);
}
else {
/* TAA is not making a big change to the matrices.
* Reuse the main view culling by creating a sub-view. */
wpd->view = DRW_view_create_sub(default_view, viewmat, winmat);
}
DRW_view_set_active(wpd->view);
return true;
} }
void workbench_antialiasing_draw_pass(WORKBENCH_Data *vedata) void workbench_antialiasing_draw_pass(WORKBENCH_Data *vedata)

View File

@ -2909,9 +2909,8 @@ GPUBatch *DRW_cache_curve_edge_wire_get(Object *ob)
if (mesh_eval != NULL) { if (mesh_eval != NULL) {
return DRW_mesh_batch_cache_get_loose_edges(mesh_eval); return DRW_mesh_batch_cache_get_loose_edges(mesh_eval);
} }
else {
return DRW_curve_batch_cache_get_wire_edge(cu); return DRW_curve_batch_cache_get_wire_edge(cu);
}
} }
GPUBatch *DRW_cache_curve_edge_normal_get(Object *ob) GPUBatch *DRW_cache_curve_edge_normal_get(Object *ob)
@ -2947,9 +2946,8 @@ GPUBatch *DRW_cache_curve_surface_get(Object *ob)
if (mesh_eval != NULL) { if (mesh_eval != NULL) {
return DRW_mesh_batch_cache_get_surface(mesh_eval); return DRW_mesh_batch_cache_get_surface(mesh_eval);
} }
else {
return DRW_curve_batch_cache_get_triangles_with_normals(cu); return DRW_curve_batch_cache_get_triangles_with_normals(cu);
}
} }
GPUBatch *DRW_cache_curve_loose_edges_get(Object *ob) GPUBatch *DRW_cache_curve_loose_edges_get(Object *ob)
@ -2961,11 +2959,10 @@ GPUBatch *DRW_cache_curve_loose_edges_get(Object *ob)
if (mesh_eval != NULL) { if (mesh_eval != NULL) {
return DRW_mesh_batch_cache_get_loose_edges(mesh_eval); return DRW_mesh_batch_cache_get_loose_edges(mesh_eval);
} }
else {
/* TODO */ /* TODO */
UNUSED_VARS(cu); UNUSED_VARS(cu);
return NULL; return NULL;
}
} }
GPUBatch *DRW_cache_curve_face_wireframe_get(Object *ob) GPUBatch *DRW_cache_curve_face_wireframe_get(Object *ob)
@ -2977,9 +2974,8 @@ GPUBatch *DRW_cache_curve_face_wireframe_get(Object *ob)
if (mesh_eval != NULL) { if (mesh_eval != NULL) {
return DRW_mesh_batch_cache_get_wireframes_face(mesh_eval); return DRW_mesh_batch_cache_get_wireframes_face(mesh_eval);
} }
else {
return DRW_curve_batch_cache_get_wireframes_face(cu); return DRW_curve_batch_cache_get_wireframes_face(cu);
}
} }
GPUBatch *DRW_cache_curve_edge_detection_get(Object *ob, bool *r_is_manifold) GPUBatch *DRW_cache_curve_edge_detection_get(Object *ob, bool *r_is_manifold)
@ -2990,9 +2986,8 @@ GPUBatch *DRW_cache_curve_edge_detection_get(Object *ob, bool *r_is_manifold)
if (mesh_eval != NULL) { if (mesh_eval != NULL) {
return DRW_mesh_batch_cache_get_edge_detection(mesh_eval, r_is_manifold); return DRW_mesh_batch_cache_get_edge_detection(mesh_eval, r_is_manifold);
} }
else {
return DRW_curve_batch_cache_get_edge_detection(cu, r_is_manifold); return DRW_curve_batch_cache_get_edge_detection(cu, r_is_manifold);
}
} }
/* Return list of batches */ /* Return list of batches */
@ -3007,9 +3002,8 @@ GPUBatch **DRW_cache_curve_surface_shaded_get(Object *ob,
if (mesh_eval != NULL) { if (mesh_eval != NULL) {
return DRW_mesh_batch_cache_get_surface_shaded(mesh_eval, gpumat_array, gpumat_array_len); return DRW_mesh_batch_cache_get_surface_shaded(mesh_eval, gpumat_array, gpumat_array_len);
} }
else {
return DRW_curve_batch_cache_get_surface_shaded(cu, gpumat_array, gpumat_array_len); return DRW_curve_batch_cache_get_surface_shaded(cu, gpumat_array, gpumat_array_len);
}
} }
/** \} */ /** \} */
@ -3061,12 +3055,11 @@ GPUBatch *DRW_cache_text_edge_wire_get(Object *ob)
if (!has_surface) { if (!has_surface) {
return NULL; return NULL;
} }
else if (mesh_eval != NULL) { if (mesh_eval != NULL) {
return DRW_mesh_batch_cache_get_loose_edges(mesh_eval); return DRW_mesh_batch_cache_get_loose_edges(mesh_eval);
} }
else {
return DRW_curve_batch_cache_get_wire_edge(cu); return DRW_curve_batch_cache_get_wire_edge(cu);
}
} }
GPUBatch *DRW_cache_text_surface_get(Object *ob) GPUBatch *DRW_cache_text_surface_get(Object *ob)
@ -3080,9 +3073,8 @@ GPUBatch *DRW_cache_text_surface_get(Object *ob)
if (mesh_eval != NULL) { if (mesh_eval != NULL) {
return DRW_mesh_batch_cache_get_surface(mesh_eval); return DRW_mesh_batch_cache_get_surface(mesh_eval);
} }
else {
return DRW_curve_batch_cache_get_triangles_with_normals(cu); return DRW_curve_batch_cache_get_triangles_with_normals(cu);
}
} }
GPUBatch *DRW_cache_text_edge_detection_get(Object *ob, bool *r_is_manifold) GPUBatch *DRW_cache_text_edge_detection_get(Object *ob, bool *r_is_manifold)
@ -3096,9 +3088,8 @@ GPUBatch *DRW_cache_text_edge_detection_get(Object *ob, bool *r_is_manifold)
if (mesh_eval != NULL) { if (mesh_eval != NULL) {
return DRW_mesh_batch_cache_get_edge_detection(mesh_eval, r_is_manifold); return DRW_mesh_batch_cache_get_edge_detection(mesh_eval, r_is_manifold);
} }
else {
return DRW_curve_batch_cache_get_edge_detection(cu, r_is_manifold); return DRW_curve_batch_cache_get_edge_detection(cu, r_is_manifold);
}
} }
GPUBatch *DRW_cache_text_loose_edges_get(Object *ob) GPUBatch *DRW_cache_text_loose_edges_get(Object *ob)
@ -3112,9 +3103,8 @@ GPUBatch *DRW_cache_text_loose_edges_get(Object *ob)
if (mesh_eval != NULL) { if (mesh_eval != NULL) {
return DRW_mesh_batch_cache_get_loose_edges(mesh_eval); return DRW_mesh_batch_cache_get_loose_edges(mesh_eval);
} }
else {
return DRW_curve_batch_cache_get_wire_edge(cu); return DRW_curve_batch_cache_get_wire_edge(cu);
}
} }
GPUBatch *DRW_cache_text_face_wireframe_get(Object *ob) GPUBatch *DRW_cache_text_face_wireframe_get(Object *ob)
@ -3128,9 +3118,8 @@ GPUBatch *DRW_cache_text_face_wireframe_get(Object *ob)
if (mesh_eval != NULL) { if (mesh_eval != NULL) {
return DRW_mesh_batch_cache_get_wireframes_face(mesh_eval); return DRW_mesh_batch_cache_get_wireframes_face(mesh_eval);
} }
else {
return DRW_curve_batch_cache_get_wireframes_face(cu); return DRW_curve_batch_cache_get_wireframes_face(cu);
}
} }
GPUBatch **DRW_cache_text_surface_shaded_get(Object *ob, GPUBatch **DRW_cache_text_surface_shaded_get(Object *ob,
@ -3146,9 +3135,8 @@ GPUBatch **DRW_cache_text_surface_shaded_get(Object *ob,
if (mesh_eval != NULL) { if (mesh_eval != NULL) {
return DRW_mesh_batch_cache_get_surface_shaded(mesh_eval, gpumat_array, gpumat_array_len); return DRW_mesh_batch_cache_get_surface_shaded(mesh_eval, gpumat_array, gpumat_array_len);
} }
else {
return DRW_curve_batch_cache_get_surface_shaded(cu, gpumat_array, gpumat_array_len); return DRW_curve_batch_cache_get_surface_shaded(cu, gpumat_array, gpumat_array_len);
}
} }
/** \} */ /** \} */
@ -3166,9 +3154,8 @@ GPUBatch *DRW_cache_surf_surface_get(Object *ob)
if (mesh_eval != NULL) { if (mesh_eval != NULL) {
return DRW_mesh_batch_cache_get_surface(mesh_eval); return DRW_mesh_batch_cache_get_surface(mesh_eval);
} }
else {
return DRW_curve_batch_cache_get_triangles_with_normals(cu); return DRW_curve_batch_cache_get_triangles_with_normals(cu);
}
} }
GPUBatch *DRW_cache_surf_edge_wire_get(Object *ob) GPUBatch *DRW_cache_surf_edge_wire_get(Object *ob)
@ -3180,9 +3167,8 @@ GPUBatch *DRW_cache_surf_edge_wire_get(Object *ob)
if (mesh_eval != NULL) { if (mesh_eval != NULL) {
return DRW_mesh_batch_cache_get_loose_edges(mesh_eval); return DRW_mesh_batch_cache_get_loose_edges(mesh_eval);
} }
else {
return DRW_curve_batch_cache_get_wire_edge(cu); return DRW_curve_batch_cache_get_wire_edge(cu);
}
} }
GPUBatch *DRW_cache_surf_face_wireframe_get(Object *ob) GPUBatch *DRW_cache_surf_face_wireframe_get(Object *ob)
@ -3194,9 +3180,8 @@ GPUBatch *DRW_cache_surf_face_wireframe_get(Object *ob)
if (mesh_eval != NULL) { if (mesh_eval != NULL) {
return DRW_mesh_batch_cache_get_wireframes_face(mesh_eval); return DRW_mesh_batch_cache_get_wireframes_face(mesh_eval);
} }
else {
return DRW_curve_batch_cache_get_wireframes_face(cu); return DRW_curve_batch_cache_get_wireframes_face(cu);
}
} }
GPUBatch *DRW_cache_surf_edge_detection_get(Object *ob, bool *r_is_manifold) GPUBatch *DRW_cache_surf_edge_detection_get(Object *ob, bool *r_is_manifold)
@ -3207,9 +3192,8 @@ GPUBatch *DRW_cache_surf_edge_detection_get(Object *ob, bool *r_is_manifold)
if (mesh_eval != NULL) { if (mesh_eval != NULL) {
return DRW_mesh_batch_cache_get_edge_detection(mesh_eval, r_is_manifold); return DRW_mesh_batch_cache_get_edge_detection(mesh_eval, r_is_manifold);
} }
else {
return DRW_curve_batch_cache_get_edge_detection(cu, r_is_manifold); return DRW_curve_batch_cache_get_edge_detection(cu, r_is_manifold);
}
} }
GPUBatch *DRW_cache_surf_loose_edges_get(Object *ob) GPUBatch *DRW_cache_surf_loose_edges_get(Object *ob)
@ -3221,11 +3205,10 @@ GPUBatch *DRW_cache_surf_loose_edges_get(Object *ob)
if (mesh_eval != NULL) { if (mesh_eval != NULL) {
return DRW_mesh_batch_cache_get_loose_edges(mesh_eval); return DRW_mesh_batch_cache_get_loose_edges(mesh_eval);
} }
else {
/* TODO */ /* TODO */
UNUSED_VARS(cu); UNUSED_VARS(cu);
return NULL; return NULL;
}
} }
/* Return list of batches */ /* Return list of batches */
@ -3240,9 +3223,8 @@ GPUBatch **DRW_cache_surf_surface_shaded_get(Object *ob,
if (mesh_eval != NULL) { if (mesh_eval != NULL) {
return DRW_mesh_batch_cache_get_surface_shaded(mesh_eval, gpumat_array, gpumat_array_len); return DRW_mesh_batch_cache_get_surface_shaded(mesh_eval, gpumat_array, gpumat_array_len);
} }
else {
return DRW_curve_batch_cache_get_surface_shaded(cu, gpumat_array, gpumat_array_len); return DRW_curve_batch_cache_get_surface_shaded(cu, gpumat_array, gpumat_array_len);
}
} }
/** \} */ /** \} */

View File

@ -474,10 +474,9 @@ BLI_INLINE const float *bm_vert_co_get(const MeshRenderData *mr, const BMVert *e
if (vert_coords != NULL) { if (vert_coords != NULL) {
return vert_coords[BM_elem_index_get(eve)]; return vert_coords[BM_elem_index_get(eve)];
} }
else {
UNUSED_VARS(mr); UNUSED_VARS(mr);
return eve->co; return eve->co;
}
} }
BLI_INLINE const float *bm_vert_no_get(const MeshRenderData *mr, const BMVert *eve) BLI_INLINE const float *bm_vert_no_get(const MeshRenderData *mr, const BMVert *eve)
@ -486,10 +485,9 @@ BLI_INLINE const float *bm_vert_no_get(const MeshRenderData *mr, const BMVert *e
if (vert_normals != NULL) { if (vert_normals != NULL) {
return vert_normals[BM_elem_index_get(eve)]; return vert_normals[BM_elem_index_get(eve)];
} }
else {
UNUSED_VARS(mr); UNUSED_VARS(mr);
return eve->no; return eve->no;
}
} }
BLI_INLINE const float *bm_face_no_get(const MeshRenderData *mr, const BMFace *efa) BLI_INLINE const float *bm_face_no_get(const MeshRenderData *mr, const BMFace *efa)
@ -498,10 +496,9 @@ BLI_INLINE const float *bm_face_no_get(const MeshRenderData *mr, const BMFace *e
if (poly_normals != NULL) { if (poly_normals != NULL) {
return poly_normals[BM_elem_index_get(efa)]; return poly_normals[BM_elem_index_get(efa)];
} }
else {
UNUSED_VARS(mr); UNUSED_VARS(mr);
return efa->no; return efa->no;
}
} }
/** \} */ /** \} */
@ -2937,7 +2934,7 @@ static float evaluate_vertex_weight(const MDeformVert *dvert, const DRW_MeshWeig
if ((wstate->defgroup_active < 0) && (wstate->defgroup_len > 0)) { if ((wstate->defgroup_active < 0) && (wstate->defgroup_len > 0)) {
return -2.0f; return -2.0f;
} }
else if (dvert == NULL) { if (dvert == NULL) {
return (wstate->alert_mode != OB_DRAW_GROUPUSER_NONE) ? -1.0f : 0.0f; return (wstate->alert_mode != OB_DRAW_GROUPUSER_NONE) ? -1.0f : 0.0f;
} }
@ -4296,7 +4293,7 @@ static void statvis_calc_sharp(const MeshRenderData *mr, float *r_sharp)
/* non-manifold edge, yet... */ /* non-manifold edge, yet... */
continue; continue;
} }
else if (*pval != NULL) { if (*pval != NULL) {
const float *f1_no = mr->poly_normals[mp_index]; const float *f1_no = mr->poly_normals[mp_index];
const float *f2_no = *pval; const float *f2_no = *pval;
angle = angle_normalized_v3v3(f1_no, f2_no); angle = angle_normalized_v3v3(f1_no, f2_no);

View File

@ -135,9 +135,8 @@ static GpencilBatchCache *gpencil_batch_cache_get(Object *ob, int cfra)
gpencil_batch_cache_clear(cache); gpencil_batch_cache_clear(cache);
return gpencil_batch_cache_init(ob, cfra); return gpencil_batch_cache_init(ob, cfra);
} }
else {
return cache; return cache;
}
} }
void DRW_gpencil_batch_cache_dirty_tag(bGPdata *gpd) void DRW_gpencil_batch_cache_dirty_tag(bGPdata *gpd)

View File

@ -83,10 +83,9 @@ static int lattice_render_verts_len_get(Lattice *lt)
if ((lt->flag & LT_OUTSIDE) == 0) { if ((lt->flag & LT_OUTSIDE) == 0) {
return vert_len_calc(u, v, w); return vert_len_calc(u, v, w);
} }
else {
/* TODO remove internal coords */ /* TODO remove internal coords */
return vert_len_calc(u, v, w); return vert_len_calc(u, v, w);
}
} }
static int lattice_render_edges_len_get(Lattice *lt) static int lattice_render_edges_len_get(Lattice *lt)
@ -102,10 +101,9 @@ static int lattice_render_edges_len_get(Lattice *lt)
if ((lt->flag & LT_OUTSIDE) == 0) { if ((lt->flag & LT_OUTSIDE) == 0) {
return edge_len_calc(u, v, w); return edge_len_calc(u, v, w);
} }
else {
/* TODO remove internal coords */ /* TODO remove internal coords */
return edge_len_calc(u, v, w); return edge_len_calc(u, v, w);
}
} }
/* ---------------------------------------------------------------------- */ /* ---------------------------------------------------------------------- */
@ -252,12 +250,11 @@ static bool lattice_batch_cache_valid(Lattice *lt)
if (cache->is_dirty) { if (cache->is_dirty) {
return false; return false;
} }
else {
if ((cache->dims.u_len != lt->pntsu) || (cache->dims.v_len != lt->pntsv) || if ((cache->dims.u_len != lt->pntsu) || (cache->dims.v_len != lt->pntsv) ||
(cache->dims.w_len != lt->pntsw) || (cache->dims.w_len != lt->pntsw) ||
((cache->show_only_outside != ((lt->flag & LT_OUTSIDE) != 0)))) { ((cache->show_only_outside != ((lt->flag & LT_OUTSIDE) != 0)))) {
return false; return false;
}
} }
return true; return true;

View File

@ -803,9 +803,8 @@ GPUBatch *DRW_mesh_batch_cache_get_loose_edges(Mesh *me)
if (cache->no_loose_wire) { if (cache->no_loose_wire) {
return NULL; return NULL;
} }
else {
return DRW_batch_request(&cache->batch.loose_edges); return DRW_batch_request(&cache->batch.loose_edges);
}
} }
GPUBatch *DRW_mesh_batch_cache_get_surface_weights(Mesh *me) GPUBatch *DRW_mesh_batch_cache_get_surface_weights(Mesh *me)

View File

@ -128,9 +128,8 @@ static bool particle_batch_cache_valid(ParticleSystem *psys)
if (cache->is_dirty == false) { if (cache->is_dirty == false) {
return true; return true;
} }
else {
return false; return false;
}
return true; return true;
} }
@ -647,14 +646,13 @@ static float particle_key_weight(const ParticleData *particle, int strand, float
if (t == 1.0) { if (t == 1.0) {
return hkeys[part->totkey - 1].weight; return hkeys[part->totkey - 1].weight;
} }
else {
float interp = t / edit_key_seg_t; float interp = t / edit_key_seg_t;
int index = (int)interp; int index = (int)interp;
interp -= floorf(interp); /* Time between 2 edit key */ interp -= floorf(interp); /* Time between 2 edit key */
float s1 = hkeys[index].weight; float s1 = hkeys[index].weight;
float s2 = hkeys[index + 1].weight; float s2 = hkeys[index + 1].weight;
return s1 + interp * (s2 - s1); return s1 + interp * (s2 - s1);
}
} }
static int particle_batch_cache_fill_segments_edit( static int particle_batch_cache_fill_segments_edit(

View File

@ -455,11 +455,11 @@ bool DRW_object_is_flat(Object *ob, int *r_axis)
*r_axis = 0; *r_axis = 0;
return true; return true;
} }
else if (dim[1] == 0.0f) { if (dim[1] == 0.0f) {
*r_axis = 1; *r_axis = 1;
return true; return true;
} }
else if (dim[2] == 0.0f) { if (dim[2] == 0.0f) {
*r_axis = 2; *r_axis = 2;
return true; return true;
} }

View File

@ -792,9 +792,8 @@ DrawDataList *DRW_drawdatalist_from_id(ID *id)
IdDdtTemplate *idt = (IdDdtTemplate *)id; IdDdtTemplate *idt = (IdDdtTemplate *)id;
return &idt->drawdata; return &idt->drawdata;
} }
else {
return NULL; return NULL;
}
} }
DrawData *DRW_drawdata_get(ID *id, DrawEngineType *engine_type) DrawData *DRW_drawdata_get(ID *id, DrawEngineType *engine_type)

View File

@ -594,28 +594,26 @@ static DRWResourceHandle drw_resource_handle(DRWShadingGroup *shgroup,
DRWResourceHandle handle = 0; DRWResourceHandle handle = 0;
return handle; return handle;
} }
else {
return drw_resource_handle_new(obmat, NULL); return drw_resource_handle_new(obmat, NULL);
}
if (DST.ob_handle == 0) {
DST.ob_handle = drw_resource_handle_new(obmat, ob);
DST.ob_state_obinfo_init = false;
}
if (shgroup->objectinfo) {
if (!DST.ob_state_obinfo_init) {
DST.ob_state_obinfo_init = true;
DRWObjectInfos *ob_infos = DRW_memblock_elem_from_handle(DST.vmempool->obinfos,
&DST.ob_handle);
drw_call_obinfos_init(ob_infos, ob);
} }
} }
else {
if (DST.ob_handle == 0) {
DST.ob_handle = drw_resource_handle_new(obmat, ob);
DST.ob_state_obinfo_init = false;
}
if (shgroup->objectinfo) { return DST.ob_handle;
if (!DST.ob_state_obinfo_init) {
DST.ob_state_obinfo_init = true;
DRWObjectInfos *ob_infos = DRW_memblock_elem_from_handle(DST.vmempool->obinfos,
&DST.ob_handle);
drw_call_obinfos_init(ob_infos, ob);
}
}
return DST.ob_handle;
}
} }
static void command_type_set(uint64_t *command_type_bits, int index, eDRWCommandType type) static void command_type_set(uint64_t *command_type_bits, int index, eDRWCommandType type)
@ -1904,9 +1902,8 @@ float DRW_view_near_distance_get(const DRWView *view)
if (DRW_view_is_persp_get(view)) { if (DRW_view_is_persp_get(view)) {
return -projmat[3][2] / (projmat[2][2] - 1.0f); return -projmat[3][2] / (projmat[2][2] - 1.0f);
} }
else {
return -(projmat[3][2] + 1.0f) / projmat[2][2]; return -(projmat[3][2] + 1.0f) / projmat[2][2];
}
} }
float DRW_view_far_distance_get(const DRWView *view) float DRW_view_far_distance_get(const DRWView *view)
@ -1917,9 +1914,8 @@ float DRW_view_far_distance_get(const DRWView *view)
if (DRW_view_is_persp_get(view)) { if (DRW_view_is_persp_get(view)) {
return -projmat[3][2] / (projmat[2][2] + 1.0f); return -projmat[3][2] / (projmat[2][2] + 1.0f);
} }
else {
return -(projmat[3][2] - 1.0f) / projmat[2][2]; return -(projmat[3][2] - 1.0f) / projmat[2][2];
}
} }
void DRW_view_viewmat_get(const DRWView *view, float mat[4][4], bool inverse) void DRW_view_viewmat_get(const DRWView *view, float mat[4][4], bool inverse)
@ -2026,18 +2022,16 @@ static int pass_shgroup_dist_sort(const void *a, const void *b)
if (shgrp_a->z_sorting.distance < shgrp_b->z_sorting.distance) { if (shgrp_a->z_sorting.distance < shgrp_b->z_sorting.distance) {
return 1; return 1;
} }
else if (shgrp_a->z_sorting.distance > shgrp_b->z_sorting.distance) { if (shgrp_a->z_sorting.distance > shgrp_b->z_sorting.distance) {
return -1; return -1;
} }
else {
/* If distances are the same, keep original order. */ /* If distances are the same, keep original order. */
if (shgrp_a->z_sorting.original_index > shgrp_b->z_sorting.original_index) { if (shgrp_a->z_sorting.original_index > shgrp_b->z_sorting.original_index) {
return -1; return -1;
}
else {
return 0;
}
} }
return 0;
} }
/* ------------------ Shading group sorting --------------------- */ /* ------------------ Shading group sorting --------------------- */

View File

@ -518,7 +518,7 @@ static bool draw_culling_box_test(const float (*frustum_planes)[4], const BoundB
* Go to next plane. */ * Go to next plane. */
break; break;
} }
else if (v == 7) { if (v == 7) {
/* 8 points behind this plane. */ /* 8 points behind this plane. */
return false; return false;
} }
@ -995,9 +995,8 @@ static void draw_call_single_do(DRWShadingGroup *shgroup,
draw_select_buffer(shgroup, state, batch, &handle); draw_select_buffer(shgroup, state, batch, &handle);
return; return;
} }
else {
GPU_select_load_id(state->select_id); GPU_select_load_id(state->select_id);
}
} }
draw_geometry_execute(shgroup, draw_geometry_execute(shgroup,

View File

@ -88,7 +88,7 @@ static bool is_cursor_visible(const DRWContextState *draw_ctx, Scene *scene, Vie
/* no exception met? then don't draw cursor! */ /* no exception met? then don't draw cursor! */
return false; return false;
} }
else if (draw_ctx->object_mode & OB_MODE_WEIGHT_GPENCIL) { if (draw_ctx->object_mode & OB_MODE_WEIGHT_GPENCIL) {
/* grease pencil hide always in some modes */ /* grease pencil hide always in some modes */
return false; return false;
} }