diff options
author | Campbell Barton <ideasman42@gmail.com> | 2018-07-05 23:56:18 +0300 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2018-07-05 23:56:18 +0300 |
commit | 08ae597d63d2e89888ae937c35357b2de62d7a8e (patch) | |
tree | 1b5ff1e7cf07dbdb38cd5ceefac6fe236a922d23 /source | |
parent | f5d096798cda8cca34a31a4a4ce441cb655b982c (diff) |
Cleanup: flag checks
Diffstat (limited to 'source')
8 files changed, 30 insertions, 26 deletions
diff --git a/source/blender/draw/engines/eevee/eevee_private.h b/source/blender/draw/engines/eevee/eevee_private.h index d077668197d..c2f9d16361d 100644 --- a/source/blender/draw/engines/eevee/eevee_private.h +++ b/source/blender/draw/engines/eevee/eevee_private.h @@ -94,7 +94,7 @@ extern struct DrawEngineType draw_engine_eevee_type; #define OVERLAY_ENABLED(v3d) ((v3d) && (v3d->flag2 & V3D_RENDER_OVERRIDE) == 0) #define LOOK_DEV_MODE_ENABLED(v3d) ((v3d) && (v3d->drawtype == OB_MATERIAL)) -#define LOOK_DEV_OVERLAY_ENABLED(v3d) (LOOK_DEV_MODE_ENABLED(v3d) && OVERLAY_ENABLED(v3d) && ((v3d->overlay.flag & V3D_OVERLAY_LOOK_DEV) > 0)) +#define LOOK_DEV_OVERLAY_ENABLED(v3d) (LOOK_DEV_MODE_ENABLED(v3d) && OVERLAY_ENABLED(v3d) && (v3d->overlay.flag & V3D_OVERLAY_LOOK_DEV)) #define USE_SCENE_LIGHT(v3d) ((!v3d) || (!LOOK_DEV_MODE_ENABLED(v3d)) || ((LOOK_DEV_MODE_ENABLED(v3d) && (v3d->shading.flag & V3D_SHADING_SCENE_LIGHT)))) /* World shader variations */ diff --git a/source/blender/draw/engines/eevee/shaders/ambient_occlusion_lib.glsl b/source/blender/draw/engines/eevee/shaders/ambient_occlusion_lib.glsl index 9d27224b5c9..fae310be90b 100644 --- a/source/blender/draw/engines/eevee/shaders/ambient_occlusion_lib.glsl +++ b/source/blender/draw/engines/eevee/shaders/ambient_occlusion_lib.glsl @@ -246,7 +246,7 @@ float gtao_multibounce(float visibility, vec3 albedo) float occlusion_compute(vec3 N, vec3 vpos, float user_occlusion, vec4 rand, out vec3 bent_normal) { #ifndef USE_REFRACTION - if ((int(aoSettings) & USE_AO) > 0) { + if ((int(aoSettings) & USE_AO) != 0) { float visibility; vec3 vnor = mat3(ViewMatrix) * N; diff --git a/source/blender/draw/engines/workbench/workbench_data.c b/source/blender/draw/engines/workbench/workbench_data.c index 4c68e41d010..1f5a1e17277 100644 --- a/source/blender/draw/engines/workbench/workbench_data.c +++ b/source/blender/draw/engines/workbench/workbench_data.c @@ -40,7 +40,7 @@ void workbench_private_data_init(WORKBENCH_PrivateData *wpd) wpd->shadow_multiplier = 1.0 - wpd->shading.shadow_intensity; WORKBENCH_UBO_World *wd = &wpd->world_data; - wd->matcap_orientation = (wpd->shading.flag & V3D_SHADING_MATCAP_FLIP_X) > 0; + wd->matcap_orientation = (wpd->shading.flag & V3D_SHADING_MATCAP_FLIP_X) != 0; wd->background_alpha = 1.0f; if ((v3d->flag3 & V3D_SHOW_WORLD) && diff --git a/source/blender/draw/engines/workbench/workbench_deferred.c b/source/blender/draw/engines/workbench/workbench_deferred.c index 1307f1c4446..d153728a000 100644 --- a/source/blender/draw/engines/workbench/workbench_deferred.c +++ b/source/blender/draw/engines/workbench/workbench_deferred.c @@ -720,7 +720,7 @@ void workbench_deferred_solid_cache_populate(WORKBENCH_Data *vedata, Object *ob) } } - if (SHADOW_ENABLED(wpd) && (ob->display.flag & OB_SHOW_SHADOW) > 0) { + if (SHADOW_ENABLED(wpd) && (ob->display.flag & OB_SHOW_SHADOW)) { bool is_manifold; struct Gwn_Batch *geom_shadow = DRW_cache_object_edge_detection_get(ob, &is_manifold); if (geom_shadow) { diff --git a/source/blender/draw/modes/shaders/object_grid_frag.glsl b/source/blender/draw/modes/shaders/object_grid_frag.glsl index 2b04bb0d855..82780e0cddc 100644 --- a/source/blender/draw/modes/shaders/object_grid_frag.glsl +++ b/source/blender/draw/modes/shaders/object_grid_frag.glsl @@ -113,12 +113,15 @@ void main() viewvec /= dist; float angle; - if ((gridFlag & PLANE_XZ) > 0) + if ((gridFlag & PLANE_XZ) != 0) { angle = viewvec.y; - else if ((gridFlag & PLANE_YZ) > 0) + } + else if ((gridFlag & PLANE_YZ) != 0) { angle = viewvec.x; - else + } + else { angle = viewvec.z; + } angle = 1.0 - abs(angle); angle *= angle; @@ -130,7 +133,7 @@ void main() fade = 1.0 - smoothstep(0.0, 0.5, dist - 0.5); dist = 1.0; /* avoid branch after */ - if ((gridFlag & PLANE_XY) > 0) { + if ((gridFlag & PLANE_XY) != 0) { float angle = 1.0 - abs(eye.z); dist = 1.0 + angle * 2.0; angle *= angle; @@ -138,7 +141,7 @@ void main() } } - if ((gridFlag & GRID) > 0) { + if ((gridFlag & GRID) != 0) { float grid_res = log(dist * gridResolution) * gridOneOverLogSubdiv; float blend = fract(-max(grid_res, 0.0)); @@ -150,11 +153,11 @@ void main() float scaleC = gridScale * pow(gridSubdiv, max(lvl + 1.0, 1.0)); vec2 grid_pos, grid_fwidth; - if ((gridFlag & PLANE_XZ) > 0) { + if ((gridFlag & PLANE_XZ) != 0) { grid_pos = wPos.xz; grid_fwidth = fwidthPos.xz; } - else if ((gridFlag & PLANE_YZ) > 0) { + else if ((gridFlag & PLANE_YZ) != 0) { grid_pos = wPos.yz; grid_fwidth = fwidthPos.yz; } @@ -175,19 +178,19 @@ void main() FragColor = vec4(colorGrid.rgb, 0.0); } - if ((gridFlag & (AXIS_X | AXIS_Y | AXIS_Z)) > 0) { + if ((gridFlag & (AXIS_X | AXIS_Y | AXIS_Z)) != 0) { /* Setup axes 'domains' */ vec3 axes_dist, axes_fwidth; - if ((gridFlag & AXIS_X) > 0) { + if ((gridFlag & AXIS_X) != 0) { axes_dist.x = dot(wPos.yz, planeAxes.yz); axes_fwidth.x = dot(fwidthPos.yz, planeAxes.yz); } - if ((gridFlag & AXIS_Y) > 0) { + if ((gridFlag & AXIS_Y) != 0) { axes_dist.y = dot(wPos.xz, planeAxes.xz); axes_fwidth.y = dot(fwidthPos.xz, planeAxes.xz); } - if ((gridFlag & AXIS_Z) > 0) { + if ((gridFlag & AXIS_Z) != 0) { axes_dist.z = dot(wPos.xy, planeAxes.xy); axes_fwidth.z = dot(fwidthPos.xy, planeAxes.xy); } @@ -195,19 +198,19 @@ void main() /* Computing all axes at once using vec3 */ vec3 axes = get_axes(axes_dist, axes_fwidth, 0.1); - if ((gridFlag & AXIS_X) > 0) { + if ((gridFlag & AXIS_X) != 0) { FragColor = mix(FragColor, colorGridAxisX, axes.x); } - if ((gridFlag & AXIS_Y) > 0) { + if ((gridFlag & AXIS_Y) != 0) { FragColor = mix(FragColor, colorGridAxisY, axes.y); } - if ((gridFlag & AXIS_Z) > 0) { + if ((gridFlag & AXIS_Z) != 0) { FragColor = mix(FragColor, colorGridAxisZ, axes.z); } } float scene_depth = texture(depthBuffer, sPos).r; - if ((gridFlag & GRID_BACK) > 0) { + if ((gridFlag & GRID_BACK) != 0) { fade *= (scene_depth == 1.0) ? 1.0 : 0.0; } else { diff --git a/source/blender/draw/modes/shaders/object_grid_vert.glsl b/source/blender/draw/modes/shaders/object_grid_vert.glsl index 3f99d8b5d0a..a346973a597 100644 --- a/source/blender/draw/modes/shaders/object_grid_vert.glsl +++ b/source/blender/draw/modes/shaders/object_grid_vert.glsl @@ -27,11 +27,11 @@ void main() vec3 vert_pos, proj_camera_pos; /* Project camera pos to the needed plane */ - if ((gridFlag & PLANE_XY) > 0) { + if ((gridFlag & PLANE_XY) != 0) { vert_pos = vec3(pos.x, pos.y, 0.0); proj_camera_pos = vec3(cameraPos.x, cameraPos.y, 0.0); } - else if ((gridFlag & PLANE_XZ) > 0) { + else if ((gridFlag & PLANE_XZ) != 0) { vert_pos = vec3(pos.x, 0.0, pos.y); proj_camera_pos = vec3(cameraPos.x, 0.0, cameraPos.z); } @@ -52,10 +52,10 @@ void main() vec3 realPos = proj_camera_pos + vert_pos; /* Used for additional Z axis */ - if ((gridFlag & CLIP_Z_POS) > 0) { + if ((gridFlag & CLIP_Z_POS) != 0) { realPos.z = max(realPos.z, 0.0); } - if ((gridFlag & CLIP_Z_NEG) > 0) { + if ((gridFlag & CLIP_Z_NEG) != 0) { realPos.z = min(-realPos.z, 0.0); } diff --git a/source/blender/makesrna/intern/rna_space.c b/source/blender/makesrna/intern/rna_space.c index 6a368fa4b41..92913e29f69 100644 --- a/source/blender/makesrna/intern/rna_space.c +++ b/source/blender/makesrna/intern/rna_space.c @@ -853,11 +853,12 @@ static const EnumPropertyItem *rna_View3DShading_studio_light_itemf( switch (v3d->drawtype) { case OB_SOLID: case OB_TEXTURE: - show_studiolight = (sl->flag & (STUDIOLIGHT_ORIENTATION_WORLD | STUDIOLIGHT_ORIENTATION_CAMERA)) > 0; + show_studiolight = ( + (sl->flag & (STUDIOLIGHT_ORIENTATION_WORLD | STUDIOLIGHT_ORIENTATION_CAMERA)) != 0); break; case OB_MATERIAL: - show_studiolight = (sl->flag & STUDIOLIGHT_ORIENTATION_WORLD) > 0; + show_studiolight = ((sl->flag & STUDIOLIGHT_ORIENTATION_WORLD) != 0); icon_id = sl->icon_id_radiance; break; } diff --git a/source/blender/makesrna/intern/rna_userdef.c b/source/blender/makesrna/intern/rna_userdef.c index 364a5694a07..9cde04c560e 100644 --- a/source/blender/makesrna/intern/rna_userdef.c +++ b/source/blender/makesrna/intern/rna_userdef.c @@ -761,7 +761,7 @@ static int rna_UserDef_studiolight_index_get(PointerRNA *ptr) static bool rna_UserDef_studiolight_is_user_defined_get(PointerRNA *ptr) { StudioLight *sl = (StudioLight *)ptr->data; - return (sl->flag & STUDIOLIGHT_USER_DEFINED) > 0; + return (sl->flag & STUDIOLIGHT_USER_DEFINED) != 0; } /* StudioLight.orientation */ |