diff --git a/source/blender/draw/engines/compositor/compositor_engine.cc b/source/blender/draw/engines/compositor/compositor_engine.cc index a4b85747526..626ca1a4c9e 100644 --- a/source/blender/draw/engines/compositor/compositor_engine.cc +++ b/source/blender/draw/engines/compositor/compositor_engine.cc @@ -12,8 +12,6 @@ #include "DNA_ID.h" #include "DNA_ID_enums.h" -#include "DNA_camera_types.h" -#include "DNA_object_types.h" #include "DNA_scene_types.h" #include "DNA_vec_types.h" #include "DNA_view3d_types.h" @@ -32,6 +30,7 @@ #include "COM_texture_pool.hh" #include "GPU_context.hh" +#include "GPU_state.hh" #include "GPU_texture.hh" #include "draw_view_data.hh" diff --git a/source/blender/draw/engines/eevee_next/eevee_ambient_occlusion.cc b/source/blender/draw/engines/eevee_next/eevee_ambient_occlusion.cc index da292ac5ca2..dc13894a167 100644 --- a/source/blender/draw/engines/eevee_next/eevee_ambient_occlusion.cc +++ b/source/blender/draw/engines/eevee_next/eevee_ambient_occlusion.cc @@ -26,8 +26,6 @@ #include "eevee_ambient_occlusion.hh" #include "eevee_instance.hh" -#include "GPU_capabilities.hh" - namespace blender::eevee { /* -------------------------------------------------------------------- */ diff --git a/source/blender/draw/engines/eevee_next/eevee_camera.cc b/source/blender/draw/engines/eevee_next/eevee_camera.cc index a10332edd19..b4a38906bd9 100644 --- a/source/blender/draw/engines/eevee_next/eevee_camera.cc +++ b/source/blender/draw/engines/eevee_next/eevee_camera.cc @@ -92,7 +92,7 @@ void Camera::sync() int2 film_extent = inst_.film.film_extent_get(); int2 film_offset = inst_.film.film_offset_get(); /* Over-scan in film pixel. Not the same as `render_overscan_get`. */ - int film_overscan = inst_.film.overscan_pixels_get(overscan_, film_extent); + int film_overscan = Film::overscan_pixels_get(overscan_, film_extent); rcti film_rect; BLI_rcti_init(&film_rect, diff --git a/source/blender/draw/engines/eevee_next/eevee_camera.hh b/source/blender/draw/engines/eevee_next/eevee_camera.hh index 65320297c68..f82b2df6ae9 100644 --- a/source/blender/draw/engines/eevee_next/eevee_camera.hh +++ b/source/blender/draw/engines/eevee_next/eevee_camera.hh @@ -8,6 +8,7 @@ * \ingroup eevee */ +#include "BLI_math_geom.h" #include "BLI_math_matrix.h" #include "eevee_shader_shared.hh" diff --git a/source/blender/draw/engines/eevee_next/eevee_cryptomatte.cc b/source/blender/draw/engines/eevee_next/eevee_cryptomatte.cc index b0b2cc22bd4..d45e0d3ea51 100644 --- a/source/blender/draw/engines/eevee_next/eevee_cryptomatte.cc +++ b/source/blender/draw/engines/eevee_next/eevee_cryptomatte.cc @@ -3,8 +3,6 @@ * SPDX-License-Identifier: GPL-2.0-or-later */ #include "BKE_cryptomatte.hh" -#include "GPU_material.hh" - #include "eevee_cryptomatte.hh" #include "eevee_instance.hh" #include "eevee_renderbuffers.hh" @@ -13,10 +11,10 @@ namespace blender::eevee { void Cryptomatte::begin_sync() { - const eViewLayerEEVEEPassType enabled_passes = static_cast( - inst_.film.enabled_passes_get() & - (EEVEE_RENDER_PASS_CRYPTOMATTE_OBJECT | EEVEE_RENDER_PASS_CRYPTOMATTE_ASSET | - EEVEE_RENDER_PASS_CRYPTOMATTE_MATERIAL)); + const eViewLayerEEVEEPassType enabled_passes = (inst_.film.enabled_passes_get() & + (EEVEE_RENDER_PASS_CRYPTOMATTE_OBJECT | + EEVEE_RENDER_PASS_CRYPTOMATTE_ASSET | + EEVEE_RENDER_PASS_CRYPTOMATTE_MATERIAL)); session_.reset(); object_layer_ = nullptr; diff --git a/source/blender/draw/engines/eevee_next/eevee_hizbuffer.cc b/source/blender/draw/engines/eevee_next/eevee_hizbuffer.cc index 6fcdf7a2d3e..6beebb09d48 100644 --- a/source/blender/draw/engines/eevee_next/eevee_hizbuffer.cc +++ b/source/blender/draw/engines/eevee_next/eevee_hizbuffer.cc @@ -2,8 +2,6 @@ * * SPDX-License-Identifier: GPL-2.0-or-later */ -#include "BKE_global.hh" - #include "eevee_instance.hh" #include "eevee_hizbuffer.hh" diff --git a/source/blender/draw/engines/eevee_next/eevee_light.hh b/source/blender/draw/engines/eevee_next/eevee_light.hh index 8fdee1cc9d5..ae622d05b30 100644 --- a/source/blender/draw/engines/eevee_next/eevee_light.hh +++ b/source/blender/draw/engines/eevee_next/eevee_light.hh @@ -21,13 +21,10 @@ #pragma once -#include "BLI_bitmap.h" -#include "BLI_vector.hh" #include "DNA_light_types.h" #include "eevee_camera.hh" #include "eevee_sampling.hh" -#include "eevee_shader.hh" #include "eevee_shader_shared.hh" #include "eevee_sync.hh" @@ -49,7 +46,6 @@ struct Light : public LightData, NonCopyable { ShadowDirectional *directional = nullptr; ShadowPunctual *punctual = nullptr; - public: Light() { /* Avoid valgrind warning. */ @@ -96,7 +92,7 @@ struct Light : public LightData, NonCopyable { const float3 &scale, const float3 &z_axis, float threshold, - bool do_jitter); + bool use_jitter); float shape_radiance_get(); float point_radiance_get(); }; diff --git a/source/blender/draw/engines/eevee_next/eevee_lightcache.cc b/source/blender/draw/engines/eevee_next/eevee_lightcache.cc index 8b2b1bd29fb..bc36ec19577 100644 --- a/source/blender/draw/engines/eevee_next/eevee_lightcache.cc +++ b/source/blender/draw/engines/eevee_next/eevee_lightcache.cc @@ -31,7 +31,6 @@ #include "wm_window.hh" -#include "eevee_engine.h" #include "eevee_instance.hh" #include "eevee_lightcache.hh" @@ -144,7 +143,7 @@ class LightBake { /** * Called from worker thread. */ - void run(bool *stop = nullptr, bool *do_update = nullptr, float *progress = nullptr) + void run(const bool *stop = nullptr, bool *do_update = nullptr, float *progress = nullptr) { DEG_graph_relations_update(depsgraph_); DEG_evaluate_on_framechange(depsgraph_, frame_); diff --git a/source/blender/draw/engines/eevee_next/eevee_lightprobe.cc b/source/blender/draw/engines/eevee_next/eevee_lightprobe.cc index 23ad7ed1887..34bec550159 100644 --- a/source/blender/draw/engines/eevee_next/eevee_lightprobe.cc +++ b/source/blender/draw/engines/eevee_next/eevee_lightprobe.cc @@ -11,13 +11,10 @@ */ #include "DNA_lightprobe_types.h" -#include "WM_api.hh" #include "eevee_instance.hh" #include "eevee_lightprobe.hh" -#include "draw_debug.hh" - #include namespace blender::eevee { diff --git a/source/blender/draw/engines/eevee_next/eevee_lightprobe_volume.cc b/source/blender/draw/engines/eevee_next/eevee_lightprobe_volume.cc index fa27765ed32..93f68dc6f26 100644 --- a/source/blender/draw/engines/eevee_next/eevee_lightprobe_volume.cc +++ b/source/blender/draw/engines/eevee_next/eevee_lightprobe_volume.cc @@ -241,16 +241,14 @@ void VolumeProbeModule::set_view(View & /*view*/) if (_a.x != _b.x) { return _a.x < _b.x; } - else if (_a.y != _b.y) { + if (_a.y != _b.y) { return _a.y < _b.y; } - else if (_a.z != _b.z) { + if (_a.z != _b.z) { return _a.z < _b.z; } - else { - /* Fallback to memory address, since there's no good alternative. */ - return a < b; - } + /* Fallback to memory address, since there's no good alternative. */ + return a < b; }); /* Insert grids in UBO in sorted order. */ @@ -1166,7 +1164,7 @@ void IrradianceBake::raylists_build() using namespace blender::math; float2 rand_uv = inst_.sampling.rng_2d_get(eSamplingDimension::SAMPLING_LENS_U); - const float3 ray_direction = inst_.sampling.sample_sphere(rand_uv); + const float3 ray_direction = Sampling::sample_sphere(rand_uv); const float3 up = ray_direction; const float3 forward = cross(up, normalize(orthogonal(up))); const float4x4 viewinv = from_orthonormal_axes(float3(0.0f), forward, up); diff --git a/source/blender/draw/engines/eevee_next/eevee_lookdev.cc b/source/blender/draw/engines/eevee_next/eevee_lookdev.cc index 4aa40f68a95..4109cbc6d34 100644 --- a/source/blender/draw/engines/eevee_next/eevee_lookdev.cc +++ b/source/blender/draw/engines/eevee_next/eevee_lookdev.cc @@ -41,7 +41,7 @@ LookdevWorld::LookdevWorld() rotate->custom1 = NODE_VECTOR_ROTATE_TYPE_AXIS_Z; bNodeSocket *rotate_vector_in = bke::node_find_socket(rotate, SOCK_IN, "Vector"); angle_socket_ = static_cast( - static_cast(bke::node_find_socket(rotate, SOCK_IN, "Angle")->default_value)); + bke::node_find_socket(rotate, SOCK_IN, "Angle")->default_value); bNodeSocket *rotate_out = bke::node_find_socket(rotate, SOCK_OUT, "Vector"); bNode *environment = bke::node_add_static_node(nullptr, ntree, SH_NODE_TEX_ENVIRONMENT); @@ -54,7 +54,7 @@ LookdevWorld::LookdevWorld() bNodeSocket *background_out = bke::node_find_socket(background, SOCK_OUT, "Background"); bNodeSocket *background_color_in = bke::node_find_socket(background, SOCK_IN, "Color"); intensity_socket_ = static_cast( - static_cast(bke::node_find_socket(background, SOCK_IN, "Strength")->default_value)); + bke::node_find_socket(background, SOCK_IN, "Strength")->default_value); bNode *output = bke::node_add_static_node(nullptr, ntree, SH_NODE_OUTPUT_WORLD); bNodeSocket *output_in = bke::node_find_socket(output, SOCK_IN, "Surface"); @@ -130,7 +130,7 @@ bool LookdevWorld::sync(const LookdevParameters &new_parameters) LookdevModule::LookdevModule(Instance &inst) : inst_(inst) {} -LookdevModule::~LookdevModule() {} +LookdevModule::~LookdevModule() = default; void LookdevModule::init(const rcti *visible_rect) { @@ -162,7 +162,7 @@ static eDRWLevelOfDetail calc_level_of_detail(const float viewport_scale) if (res_scale > 0.7f) { return DRW_LOD_HIGH; } - else if (res_scale > 0.25f) { + if (res_scale > 0.25f) { return DRW_LOD_MEDIUM; } return DRW_LOD_LOW; @@ -199,7 +199,7 @@ void LookdevModule::sync() const Camera &cam = inst_.camera; float sphere_distance = cam.data_get().clip_near; int2 display_extent = inst_.film.display_extent_get(); - float pixel_radius = inst_.shadows.screen_pixel_radius( + float pixel_radius = ShadowModule::screen_pixel_radius( cam.data_get().wininv, cam.is_perspective(), display_extent); if (cam.is_perspective()) { @@ -303,7 +303,7 @@ void LookdevModule::display() /** \name Parameters * \{ */ -LookdevParameters::LookdevParameters() {} +LookdevParameters::LookdevParameters() = default; LookdevParameters::LookdevParameters(const ::View3D *v3d) { diff --git a/source/blender/draw/engines/eevee_next/eevee_material.cc b/source/blender/draw/engines/eevee_next/eevee_material.cc index 063d7898bad..9929fd9dc23 100644 --- a/source/blender/draw/engines/eevee_next/eevee_material.cc +++ b/source/blender/draw/engines/eevee_next/eevee_material.cc @@ -15,8 +15,6 @@ #include "NOD_shader.h" -#include "draw_cache.hh" - #include "eevee_instance.hh" #include "eevee_material.hh" diff --git a/source/blender/draw/engines/eevee_next/eevee_pipeline.cc b/source/blender/draw/engines/eevee_next/eevee_pipeline.cc index 9d2b02d0373..f766c26805f 100644 --- a/source/blender/draw/engines/eevee_next/eevee_pipeline.cc +++ b/source/blender/draw/engines/eevee_next/eevee_pipeline.cc @@ -960,9 +960,7 @@ PassMain::Sub *DeferredPipeline::prepass_add(::Material *blender_mat, if (!use_combined_lightprobe_eval && (blender_mat->blend_flag & MA_BL_SS_REFRACTION)) { return refraction_layer_.prepass_add(blender_mat, gpumat, has_motion); } - else { - return opaque_layer_.prepass_add(blender_mat, gpumat, has_motion); - } + return opaque_layer_.prepass_add(blender_mat, gpumat, has_motion); } PassMain::Sub *DeferredPipeline::material_add(::Material *blender_mat, GPUMaterial *gpumat) @@ -970,9 +968,7 @@ PassMain::Sub *DeferredPipeline::material_add(::Material *blender_mat, GPUMateri if (!use_combined_lightprobe_eval && (blender_mat->blend_flag & MA_BL_SS_REFRACTION)) { return refraction_layer_.material_add(blender_mat, gpumat); } - else { - return opaque_layer_.material_add(blender_mat, gpumat); - } + return opaque_layer_.material_add(blender_mat, gpumat); } void DeferredPipeline::render(View &main_view, @@ -1212,7 +1208,7 @@ std::optional> VolumePipeline::object_integration_range() const bool VolumePipeline::use_hit_list() const { - for (auto &layer : layers_) { + for (const auto &layer : layers_) { if (layer->use_hit_list) { return true; } diff --git a/source/blender/draw/engines/eevee_next/eevee_pipeline.hh b/source/blender/draw/engines/eevee_next/eevee_pipeline.hh index f5c11ade864..6b16f441877 100644 --- a/source/blender/draw/engines/eevee_next/eevee_pipeline.hh +++ b/source/blender/draw/engines/eevee_next/eevee_pipeline.hh @@ -15,7 +15,6 @@ #include "BLI_math_bits.h" #include "DRW_render.hh" -#include "draw_shader_shared.hh" #include "eevee_lut.hh" #include "eevee_raytrace.hh" @@ -352,8 +351,8 @@ class DeferredPipeline { void begin_sync(); void end_sync(); - PassMain::Sub *prepass_add(::Material *material, GPUMaterial *gpumat, bool has_motion); - PassMain::Sub *material_add(::Material *material, GPUMaterial *gpumat); + PassMain::Sub *prepass_add(::Material *blender_mat, GPUMaterial *gpumat, bool has_motion); + PassMain::Sub *material_add(::Material *blender_mat, GPUMaterial *gpumat); void render(View &main_view, View &render_view, @@ -440,9 +439,9 @@ class VolumeLayer { GPUMaterial *gpumat); /* Return true if the given bounds overlaps any of the contained object in this layer. */ - bool bounds_overlaps(const VolumeObjectBounds &object_aabb) const; + bool bounds_overlaps(const VolumeObjectBounds &object_bounds) const; - void add_object_bound(const VolumeObjectBounds &object_aabb); + void add_object_bound(const VolumeObjectBounds &object_bounds); void sync(); void render(View &view, Texture &occupancy_tx); @@ -476,7 +475,7 @@ class VolumePipeline { bool has_scatter() const { - for (auto &layer : layers_) { + for (const auto &layer : layers_) { if (layer->has_scatter) { return true; } @@ -485,7 +484,7 @@ class VolumePipeline { } bool has_absorption() const { - for (auto &layer : layers_) { + for (const auto &layer : layers_) { if (layer->has_absorption) { return true; } @@ -517,8 +516,8 @@ class DeferredProbePipeline { void begin_sync(); void end_sync(); - PassMain::Sub *prepass_add(::Material *material, GPUMaterial *gpumat); - PassMain::Sub *material_add(::Material *material, GPUMaterial *gpumat); + PassMain::Sub *prepass_add(::Material *blender_mat, GPUMaterial *gpumat); + PassMain::Sub *material_add(::Material *blender_mat, GPUMaterial *gpumat); void render(View &view, Framebuffer &prepass_fb, @@ -557,8 +556,8 @@ class PlanarProbePipeline : DeferredLayerBase { void begin_sync(); void end_sync(); - PassMain::Sub *prepass_add(::Material *material, GPUMaterial *gpumat); - PassMain::Sub *material_add(::Material *material, GPUMaterial *gpumat); + PassMain::Sub *prepass_add(::Material *blender_mat, GPUMaterial *gpumat); + PassMain::Sub *material_add(::Material *blender_mat, GPUMaterial *gpumat); void render(View &view, GPUTexture *depth_layer_tx, @@ -664,7 +663,7 @@ class UtilityTexture : public Texture { GPU_texture_update_mipmap(*this, 0, GPU_DATA_FLOAT, data.data()); } - ~UtilityTexture(){}; + ~UtilityTexture() = default; }; /** \} */ @@ -691,7 +690,6 @@ class PipelineModule { UtilityTexture utility_tx; PipelineInfoData &data; - public: PipelineModule(Instance &inst, PipelineInfoData &data) : background(inst), world(inst), diff --git a/source/blender/draw/engines/eevee_next/eevee_renderbuffers.cc b/source/blender/draw/engines/eevee_next/eevee_renderbuffers.cc index 55311a7ea3e..b88b246bf65 100644 --- a/source/blender/draw/engines/eevee_next/eevee_renderbuffers.cc +++ b/source/blender/draw/engines/eevee_next/eevee_renderbuffers.cc @@ -12,9 +12,6 @@ * Input needs to be jittered so that the filter converges to the right result. */ -#include "BLI_rect.h" - -#include "GPU_framebuffer.hh" #include "GPU_texture.hh" #include "DRW_render.hh" @@ -109,9 +106,8 @@ void RenderBuffers::acquire(int2 extent) cryptomatte_format = GPU_RGBA32F; } cryptomatte_tx.acquire( - pass_extent(static_cast(EEVEE_RENDER_PASS_CRYPTOMATTE_OBJECT | - EEVEE_RENDER_PASS_CRYPTOMATTE_ASSET | - EEVEE_RENDER_PASS_CRYPTOMATTE_MATERIAL)), + pass_extent((EEVEE_RENDER_PASS_CRYPTOMATTE_OBJECT | EEVEE_RENDER_PASS_CRYPTOMATTE_ASSET | + EEVEE_RENDER_PASS_CRYPTOMATTE_MATERIAL)), cryptomatte_format, GPU_TEXTURE_USAGE_SHADER_READ | GPU_TEXTURE_USAGE_SHADER_WRITE); } diff --git a/source/blender/draw/engines/eevee_next/eevee_shader.cc b/source/blender/draw/engines/eevee_next/eevee_shader.cc index 1e788a3698d..85b0ba26c44 100644 --- a/source/blender/draw/engines/eevee_next/eevee_shader.cc +++ b/source/blender/draw/engines/eevee_next/eevee_shader.cc @@ -716,7 +716,7 @@ void ShaderModule::material_create_info_amend(GPUMaterial *gpumat, GPUCodegenOut attr_load << (!codegen.attr_load.empty() ? codegen.attr_load : ""); attr_load << "}\n\n"; - std::stringstream vert_gen, frag_gen, comp_gen; + std::stringstream vert_gen, frag_gen; if (do_vertex_attrib_load) { vert_gen << global_vars.str() << attr_load.str(); diff --git a/source/blender/draw/engines/eevee_next/eevee_shader_shared.hh b/source/blender/draw/engines/eevee_next/eevee_shader_shared.hh index 0dbaa146cfa..9e2da8dc714 100644 --- a/source/blender/draw/engines/eevee_next/eevee_shader_shared.hh +++ b/source/blender/draw/engines/eevee_next/eevee_shader_shared.hh @@ -1279,12 +1279,10 @@ static inline int light_local_tilemap_count(LightData light) if (is_spot_light(light.type)) { return (light_spot_data_get(light).spot_tan > tanf(M_PI / 4.0)) ? 5 : 1; } - else if (is_area_light(light.type)) { + if (is_area_light(light.type)) { return 5; } - else { - return 6; - } + return 6; } /** \} */ diff --git a/source/blender/draw/engines/eevee_next/eevee_subsurface.cc b/source/blender/draw/engines/eevee_next/eevee_subsurface.cc index 1e3cfe3a664..0a1ef6f8937 100644 --- a/source/blender/draw/engines/eevee_next/eevee_subsurface.cc +++ b/source/blender/draw/engines/eevee_next/eevee_subsurface.cc @@ -6,13 +6,11 @@ * \ingroup eevee */ -#include "BLI_vector.hh" +#include #include "eevee_instance.hh" #include "eevee_subsurface.hh" -#include - namespace blender::eevee { /* -------------------------------------------------------------------- */ @@ -167,9 +165,7 @@ float SubsurfaceModule::burley_sample(float d, float x_rand) } r = r - f / f_; - if (r < 0.0) { - r = 0.0; - } + r = std::max(r, 0.0); } return r * d; diff --git a/source/blender/draw/engines/eevee_next/eevee_world.cc b/source/blender/draw/engines/eevee_next/eevee_world.cc index 6dd5544ce26..a2c90b654d0 100644 --- a/source/blender/draw/engines/eevee_next/eevee_world.cc +++ b/source/blender/draw/engines/eevee_next/eevee_world.cc @@ -9,8 +9,6 @@ #include "BKE_lib_id.hh" #include "BKE_node.hh" #include "BKE_node_legacy_types.hh" -#include "BKE_world.h" -#include "BLI_math_rotation.h" #include "DEG_depsgraph_query.hh" #include "NOD_shader.h" diff --git a/source/blender/draw/engines/gpencil/gpencil_engine_c.cc b/source/blender/draw/engines/gpencil/gpencil_engine_c.cc index 7f8e8bf5b6c..9988d259f40 100644 --- a/source/blender/draw/engines/gpencil/gpencil_engine_c.cc +++ b/source/blender/draw/engines/gpencil/gpencil_engine_c.cc @@ -495,7 +495,7 @@ static GPENCIL_tObject *grease_pencil_object_cache_populate( pass.bind_ubo("gp_materials", ubo_mat); pass.bind_texture("gpFillTexture", tex_fill); pass.bind_texture("gpStrokeTexture", tex_stroke); - pass.push_constant("gpMaterialOffset", int(mat_ofs)); + pass.push_constant("gpMaterialOffset", mat_ofs); /* Since we don't use the sbuffer in GPv3, this is always 0. */ pass.push_constant("gpStrokeIndexOffset", 0.0f); pass.push_constant("viewportSize", float2(DRW_viewport_size_get())); diff --git a/source/blender/draw/engines/gpencil/gpencil_shader_fx.cc b/source/blender/draw/engines/gpencil/gpencil_shader_fx.cc index 51e79fa418f..188591caa52 100644 --- a/source/blender/draw/engines/gpencil/gpencil_shader_fx.cc +++ b/source/blender/draw/engines/gpencil/gpencil_shader_fx.cc @@ -281,7 +281,7 @@ static void gpencil_vfx_pixelize(PixelShaderFxData *fx, Object *ob, gpIterVfxDat grp.push_constant("targetPixelOffset", float2(ob_center)); grp.push_constant("accumOffset", float2(pixel_size[0], 0.0f)); int samp_count = (pixel_size[0] / vp_size_inv[0] > 3.0) ? 2 : 1; - grp.push_constant("sampCount", int(use_antialiasing ? samp_count : 0)); + grp.push_constant("sampCount", (use_antialiasing ? samp_count : 0)); grp.draw_procedural(GPU_PRIM_TRIS, 1, 3); } @@ -293,7 +293,7 @@ static void gpencil_vfx_pixelize(PixelShaderFxData *fx, Object *ob, gpIterVfxDat grp.push_constant("targetPixelSize", float2(pixsize_uniform)); grp.push_constant("accumOffset", float2(0.0f, pixel_size[1])); int samp_count = (pixel_size[1] / vp_size_inv[1] > 3.0) ? 2 : 1; - grp.push_constant("sampCount", int(use_antialiasing ? samp_count : 0)); + grp.push_constant("sampCount", (use_antialiasing ? samp_count : 0)); grp.draw_procedural(GPU_PRIM_TRIS, 1, 3); } } diff --git a/source/blender/draw/engines/image/image_drawing_mode.cc b/source/blender/draw/engines/image/image_drawing_mode.cc index d42acac9351..26f1797d00f 100644 --- a/source/blender/draw/engines/image/image_drawing_mode.cc +++ b/source/blender/draw/engines/image/image_drawing_mode.cc @@ -46,7 +46,7 @@ void ScreenSpaceDrawingMode::add_depth_shgroups(::Image *image, ImageUser *image float4x4 image_mat = float4x4::identity(); ResourceHandle handle = instance_.manager->resource_handle(image_mat); - ImageUser tile_user = {0}; + ImageUser tile_user = {nullptr}; if (image_user) { tile_user = *image_user; } @@ -256,7 +256,7 @@ void ScreenSpaceDrawingMode::do_full_update_gpu_texture(TextureInfo &info, const int texture_width = GPU_texture_width(info.texture); const int texture_height = GPU_texture_height(info.texture); IMB_initImBuf(&texture_buffer, texture_width, texture_height, 0, IB_rectfloat); - ImageUser tile_user = {0}; + ImageUser tile_user = {nullptr}; if (image_user) { tile_user = *image_user; } diff --git a/source/blender/draw/engines/overlay/overlay_armature.cc b/source/blender/draw/engines/overlay/overlay_armature.cc index 47e8599960c..78e6d063dfd 100644 --- a/source/blender/draw/engines/overlay/overlay_armature.cc +++ b/source/blender/draw/engines/overlay/overlay_armature.cc @@ -1954,12 +1954,12 @@ namespace { * * See the functions below. */ -static ArmatureBoneDrawStrategyOcta strat_octa; -static ArmatureBoneDrawStrategyLine strat_line; -static ArmatureBoneDrawStrategyBBone strat_b_bone; -static ArmatureBoneDrawStrategyEnvelope strat_envelope; -static ArmatureBoneDrawStrategyWire strat_wire; -static ArmatureBoneDrawStrategyEmpty strat_empty; +ArmatureBoneDrawStrategyOcta strat_octa; +ArmatureBoneDrawStrategyLine strat_line; +ArmatureBoneDrawStrategyBBone strat_b_bone; +ArmatureBoneDrawStrategyEnvelope strat_envelope; +ArmatureBoneDrawStrategyWire strat_wire; +ArmatureBoneDrawStrategyEmpty strat_empty; }; // namespace /** diff --git a/source/blender/draw/engines/overlay/overlay_next_armature.hh b/source/blender/draw/engines/overlay/overlay_next_armature.hh index 124f74f18e6..c891ead3e73 100644 --- a/source/blender/draw/engines/overlay/overlay_next_armature.hh +++ b/source/blender/draw/engines/overlay/overlay_next_armature.hh @@ -126,11 +126,9 @@ class Armatures : Overlay { return std::make_unique(this->selection_type_, "CustomBoneWireStrip"); }); } - else { - return *custom_shape_wire.lookup_or_add_cb(geom, [this]() { - return std::make_unique(this->selection_type_, "CustomBoneWire"); - }); - } + return *custom_shape_wire.lookup_or_add_cb(geom, [this]() { + return std::make_unique(this->selection_type_, "CustomBoneWire"); + }); } BoneBuffers(const SelectionType selection_type) : selection_type_(selection_type){}; @@ -624,7 +622,6 @@ class Armatures : Overlay { } /* Public for the time of the Overlay Next port to avoid duplicated logic. */ - public: static void draw_armature_pose(Armatures::DrawContext *ctx); static void draw_armature_edit(Armatures::DrawContext *ctx); diff --git a/source/blender/draw/engines/overlay/overlay_next_engine.cc b/source/blender/draw/engines/overlay/overlay_next_engine.cc index 4719f5012a7..ebd26630d38 100644 --- a/source/blender/draw/engines/overlay/overlay_next_engine.cc +++ b/source/blender/draw/engines/overlay/overlay_next_engine.cc @@ -82,9 +82,7 @@ static void OVERLAY_next_draw_scene(void *vedata) static void OVERLAY_next_instance_free(void *instance_) { Instance *instance = (Instance *)instance_; - if (instance != nullptr) { - delete instance; - } + delete instance; } static void OVERLAY_next_engine_free() diff --git a/source/blender/draw/engines/overlay/overlay_next_image.hh b/source/blender/draw/engines/overlay/overlay_next_image.hh index 706e60b6b59..da8d5b6912b 100644 --- a/source/blender/draw/engines/overlay/overlay_next_image.hh +++ b/source/blender/draw/engines/overlay/overlay_next_image.hh @@ -8,7 +8,9 @@ #pragma once -#include "overlay_next_private.hh" +#include "DNA_scene_types.h" + +#include "BKE_image.hh" namespace blender::draw::overlay { diff --git a/source/blender/draw/engines/overlay/overlay_next_lattice.hh b/source/blender/draw/engines/overlay/overlay_next_lattice.hh index 710faa95eee..b4200c92969 100644 --- a/source/blender/draw/engines/overlay/overlay_next_lattice.hh +++ b/source/blender/draw/engines/overlay/overlay_next_lattice.hh @@ -8,8 +8,7 @@ #pragma once -#include "ED_lattice.hh" - +#include "draw_cache.hh" #include "draw_cache_impl.hh" #include "draw_common_c.hh" #include "overlay_next_base.hh" diff --git a/source/blender/draw/engines/overlay/overlay_next_mesh.hh b/source/blender/draw/engines/overlay/overlay_next_mesh.hh index f967f410190..d10ae87c066 100644 --- a/source/blender/draw/engines/overlay/overlay_next_mesh.hh +++ b/source/blender/draw/engines/overlay/overlay_next_mesh.hh @@ -12,7 +12,6 @@ #include "BKE_customdata.hh" #include "BKE_editmesh.hh" -#include "BKE_global.hh" #include "BKE_mask.h" #include "BKE_mesh_types.hh" #include "BKE_paint.hh" @@ -21,10 +20,10 @@ #include "DNA_brush_types.h" #include "DNA_mask_types.h" #include "DNA_mesh_types.h" -#include "ED_image.hh" #include "ED_view3d.hh" #include "GPU_capabilities.hh" +#include "draw_cache.hh" #include "draw_cache_impl.hh" #include "draw_manager_text.hh" #include "overlay_next_base.hh" diff --git a/source/blender/draw/engines/overlay/overlay_next_motion_path.hh b/source/blender/draw/engines/overlay/overlay_next_motion_path.hh index 56b738d5db2..3a61d78dbd4 100644 --- a/source/blender/draw/engines/overlay/overlay_next_motion_path.hh +++ b/source/blender/draw/engines/overlay/overlay_next_motion_path.hh @@ -8,7 +8,7 @@ #pragma once -#include "BKE_paint.hh" +#include "BLI_string.h" #include "DEG_depsgraph_query.hh" diff --git a/source/blender/draw/engines/overlay/overlay_next_particle.hh b/source/blender/draw/engines/overlay/overlay_next_particle.hh index 1c277b9368d..ca6225ccc3e 100644 --- a/source/blender/draw/engines/overlay/overlay_next_particle.hh +++ b/source/blender/draw/engines/overlay/overlay_next_particle.hh @@ -8,12 +8,15 @@ #pragma once +#include "BKE_material.hh" #include "BKE_pointcache.h" #include "DEG_depsgraph_query.hh" #include "DNA_collection_types.h" +#include "DNA_material_types.h" #include "DNA_particle_types.h" #include "ED_particle.hh" +#include "draw_cache.hh" #include "overlay_next_base.hh" namespace blender::draw::overlay { diff --git a/source/blender/draw/engines/overlay/overlay_next_shape.cc b/source/blender/draw/engines/overlay/overlay_next_shape.cc index 68ace254bd1..39b8f5576c6 100644 --- a/source/blender/draw/engines/overlay/overlay_next_shape.cc +++ b/source/blender/draw/engines/overlay/overlay_next_shape.cc @@ -985,7 +985,7 @@ ShapeCache::ShapeCache() { Vector verts; for (const uint3 &tri : bone_box_solid_tris) { - for (const int i : IndexRange(tri.type_length)) { + for (const int i : IndexRange(uint3::type_length)) { const int v = tri[i]; const float x = bone_box_verts[v][2]; const float y = bone_box_verts[v][0]; diff --git a/source/blender/draw/engines/select/select_debug_engine.cc b/source/blender/draw/engines/select/select_debug_engine.cc index aba93986eac..0e3b9d43919 100644 --- a/source/blender/draw/engines/select/select_debug_engine.cc +++ b/source/blender/draw/engines/select/select_debug_engine.cc @@ -11,13 +11,10 @@ #include "BLT_translation.hh" #include "DNA_ID.h" -#include "DNA_vec_types.h" #include "DRW_engine.hh" -#include "DRW_select_buffer.hh" #include "draw_manager.hh" -#include "draw_manager_c.hh" #include "draw_pass.hh" #include "select_engine.hh" diff --git a/source/blender/draw/engines/select/select_draw_utils.cc b/source/blender/draw/engines/select/select_draw_utils.cc index fb72086e5cd..2cc5c743419 100644 --- a/source/blender/draw/engines/select/select_draw_utils.cc +++ b/source/blender/draw/engines/select/select_draw_utils.cc @@ -10,18 +10,14 @@ #include "BKE_editmesh.hh" #include "BKE_mesh.hh" -#include "BKE_object.hh" #include "DNA_mesh_types.h" #include "DNA_scene_types.h" #include "ED_view3d.hh" -#include "DEG_depsgraph.hh" #include "DEG_depsgraph_query.hh" -#include "DRW_select_buffer.hh" - #include "draw_cache_impl.hh" #include "select_private.hh" diff --git a/source/blender/draw/engines/select/select_engine.cc b/source/blender/draw/engines/select/select_engine.cc index aa4fee4bc72..821a808ae99 100644 --- a/source/blender/draw/engines/select/select_engine.cc +++ b/source/blender/draw/engines/select/select_engine.cc @@ -145,14 +145,14 @@ static void select_cache_init(void *vedata) auto &sub = inst.depth_only_ps.sub("DepthOnly"); sub.shader_set(sh->select_id_uniform); sub.push_constant("retopologyOffset", retopology_offset); - sub.push_constant("select_id", int(0)); + sub.push_constant("select_id", 0); inst.depth_only = ⊂ } if (retopology_occlusion) { auto &sub = inst.depth_only_ps.sub("Occlusion"); sub.shader_set(sh->select_id_uniform); sub.push_constant("retopologyOffset", 0.0f); - sub.push_constant("select_id", int(0)); + sub.push_constant("select_id", 0); inst.depth_occlude = ⊂ } @@ -169,7 +169,7 @@ static void select_cache_init(void *vedata) else { auto &sub = inst.select_face_ps.sub("FaceNoSelect"); sub.shader_set(sh->select_id_uniform); - sub.push_constant("select_id", int(0)); + sub.push_constant("select_id", 0); sub.push_constant("retopologyOffset", retopology_offset); inst.select_face_uniform = ⊂ } diff --git a/source/blender/draw/engines/select/select_instance.cc b/source/blender/draw/engines/select/select_instance.cc index da39453ed44..6e2f9c03b87 100644 --- a/source/blender/draw/engines/select/select_instance.cc +++ b/source/blender/draw/engines/select/select_instance.cc @@ -80,9 +80,7 @@ static void SELECT_next_draw_scene(void *vedata) static void SELECT_next_instance_free(void *instance_) { Instance *instance = (Instance *)instance_; - if (instance != nullptr) { - delete instance; - } + delete instance; } static const DrawEngineDataSize SELECT_next_data_size = DRW_VIEWPORT_DATA_SIZE(SELECT_NextData); diff --git a/source/blender/draw/engines/workbench/workbench_effect_antialiasing.cc b/source/blender/draw/engines/workbench/workbench_effect_antialiasing.cc index f0eeb810722..b15fc8454b5 100644 --- a/source/blender/draw/engines/workbench/workbench_effect_antialiasing.cc +++ b/source/blender/draw/engines/workbench/workbench_effect_antialiasing.cc @@ -5,6 +5,7 @@ #include "workbench_private.hh" #include "BLI_jitter_2d.h" +#include "BLI_math_geom.h" #include "BLI_smaa_textures.h" namespace blender::workbench { diff --git a/source/blender/draw/engines/workbench/workbench_volume.cc b/source/blender/draw/engines/workbench/workbench_volume.cc index e91aa170a29..6817ab322ac 100644 --- a/source/blender/draw/engines/workbench/workbench_volume.cc +++ b/source/blender/draw/engines/workbench/workbench_volume.cc @@ -9,6 +9,7 @@ #include "BKE_volume.hh" #include "BKE_volume_render.hh" +#include "BLI_math_geom.h" #include "BLI_rand.h" #include "DNA_fluid_types.h" #include "DNA_modifier_types.h" diff --git a/source/blender/draw/intern/DRW_gpu_wrapper.hh b/source/blender/draw/intern/DRW_gpu_wrapper.hh index f5a5fdefde3..a9b54dfc24e 100644 --- a/source/blender/draw/intern/DRW_gpu_wrapper.hh +++ b/source/blender/draw/intern/DRW_gpu_wrapper.hh @@ -416,7 +416,7 @@ class StorageVectorBuffer : public StorageArrayBuffer { public: StorageVectorBuffer(const char *name = nullptr) : StorageArrayBuffer(name){}; - ~StorageVectorBuffer(){}; + ~StorageVectorBuffer() = default; /** * Set item count to zero but does not free memory or resize the buffer. @@ -1032,30 +1032,22 @@ class Texture : NonCopyable { if (h == 0) { return GPU_texture_create_1d(name_, w, mip_len, format, usage, data); } - else if (cubemap) { + if (cubemap) { if (layered) { return GPU_texture_create_cube_array(name_, w, d, mip_len, format, usage, data); } - else { - return GPU_texture_create_cube(name_, w, mip_len, format, usage, data); - } + return GPU_texture_create_cube(name_, w, mip_len, format, usage, data); } - else if (d == 0) { + if (d == 0) { if (layered) { return GPU_texture_create_1d_array(name_, w, h, mip_len, format, usage, data); } - else { - return GPU_texture_create_2d(name_, w, h, mip_len, format, usage, data); - } + return GPU_texture_create_2d(name_, w, h, mip_len, format, usage, data); } - else { - if (layered) { - return GPU_texture_create_2d_array(name_, w, h, d, mip_len, format, usage, data); - } - else { - return GPU_texture_create_3d(name_, w, h, d, mip_len, format, usage, data); - } + if (layered) { + return GPU_texture_create_2d_array(name_, w, h, d, mip_len, format, usage, data); } + return GPU_texture_create_3d(name_, w, h, d, mip_len, format, usage, data); } }; diff --git a/source/blender/draw/intern/draw_cache.cc b/source/blender/draw/intern/draw_cache.cc index 00c5c529564..922d634cb58 100644 --- a/source/blender/draw/intern/draw_cache.cc +++ b/source/blender/draw/intern/draw_cache.cc @@ -25,7 +25,6 @@ #include "BLI_utildefines.h" #include "BKE_context.hh" -#include "BKE_material.hh" #include "BKE_object.hh" #include "GPU_batch.hh" diff --git a/source/blender/draw/intern/draw_cache_extract_mesh_render_data.cc b/source/blender/draw/intern/draw_cache_extract_mesh_render_data.cc index e8ce4cc63c7..2f1638aad31 100644 --- a/source/blender/draw/intern/draw_cache_extract_mesh_render_data.cc +++ b/source/blender/draw/intern/draw_cache_extract_mesh_render_data.cc @@ -11,6 +11,7 @@ #include "BLI_array.hh" #include "BLI_array_utils.hh" #include "BLI_enumerable_thread_specific.hh" +#include "BLI_math_geom.h" #include "BLI_task.hh" #include "BLI_virtual_array.hh" @@ -191,7 +192,7 @@ static void accumululate_material_counts_mesh( } return count; }, - std::plus()); + std::plus<>()); } else { all_tri_counts.local().first() = poly_to_tri_count(mr.faces_num, mr.corners_num); diff --git a/source/blender/draw/intern/draw_cache_impl.hh b/source/blender/draw/intern/draw_cache_impl.hh index 51078105138..78441693a27 100644 --- a/source/blender/draw/intern/draw_cache_impl.hh +++ b/source/blender/draw/intern/draw_cache_impl.hh @@ -68,9 +68,9 @@ void DRW_volume_batch_cache_dirty_tag(Volume *volume, int mode); void DRW_volume_batch_cache_validate(Volume *volume); void DRW_volume_batch_cache_free(Volume *volume); -void DRW_grease_pencil_batch_cache_dirty_tag(GreasePencil *grase_pencil, int mode); -void DRW_grease_pencil_batch_cache_validate(GreasePencil *grase_pencil); -void DRW_grease_pencil_batch_cache_free(GreasePencil *grase_pencil); +void DRW_grease_pencil_batch_cache_dirty_tag(GreasePencil *grease_pencil, int mode); +void DRW_grease_pencil_batch_cache_validate(GreasePencil *grease_pencil); +void DRW_grease_pencil_batch_cache_free(GreasePencil *grease_pencil); /** \} */ diff --git a/source/blender/draw/intern/draw_cache_impl_subdivision.cc b/source/blender/draw/intern/draw_cache_impl_subdivision.cc index 28e7d3c0e8a..bc0403f6580 100644 --- a/source/blender/draw/intern/draw_cache_impl_subdivision.cc +++ b/source/blender/draw/intern/draw_cache_impl_subdivision.cc @@ -30,11 +30,10 @@ #include "GPU_compute.hh" #include "GPU_index_buffer.hh" #include "GPU_state.hh" +#include "GPU_uniform_buffer.hh" #include "GPU_vertex_buffer.hh" -#include "opensubdiv_capi.hh" #include "opensubdiv_capi_type.hh" -#include "opensubdiv_converter_capi.hh" #include "opensubdiv_evaluator_capi.hh" #ifdef WITH_OPENSUBDIV # include "opensubdiv_evaluator.hh" diff --git a/source/blender/draw/intern/draw_manager_c.cc b/source/blender/draw/intern/draw_manager_c.cc index 946fae0e904..42aa8750e3c 100644 --- a/source/blender/draw/intern/draw_manager_c.cc +++ b/source/blender/draw/intern/draw_manager_c.cc @@ -80,7 +80,9 @@ #include "draw_common_c.hh" #include "draw_manager_c.hh" #include "draw_manager_profiling.hh" -#include "draw_manager_testing.hh" +#ifdef WITH_GPU_DRAW_TESTS +# include "draw_manager_testing.hh" +#endif #include "draw_manager_text.hh" #include "draw_shader.hh" #include "draw_subdivision.hh" @@ -625,7 +627,7 @@ void **DRW_duplidata_get(void *vedata) return nullptr; } ViewportEngineData *ved = (ViewportEngineData *)vedata; - DRWRegisteredDrawEngine *engine_type = (DRWRegisteredDrawEngine *)ved->engine_type; + DRWRegisteredDrawEngine *engine_type = ved->engine_type; return &DST.dupli_datas[engine_type->index]; } diff --git a/source/blender/draw/intern/draw_manager_shader.cc b/source/blender/draw/intern/draw_manager_shader.cc index f5779a0eee8..59f67cd2b59 100644 --- a/source/blender/draw/intern/draw_manager_shader.cc +++ b/source/blender/draw/intern/draw_manager_shader.cc @@ -16,6 +16,7 @@ #include "GPU_capabilities.hh" #include "GPU_material.hh" +#include "GPU_state.hh" #include "WM_api.hh" @@ -69,7 +70,7 @@ static DRWShaderCompiler &compiler_data() return compiler_data_; } -static void *drw_deferred_shader_compilation_exec(void *) +static void *drw_deferred_shader_compilation_exec(void * /*unused*/) { using namespace blender; diff --git a/source/blender/draw/intern/draw_pbvh.cc b/source/blender/draw/intern/draw_pbvh.cc index 1b327f92b29..866785a56ae 100644 --- a/source/blender/draw/intern/draw_pbvh.cc +++ b/source/blender/draw/intern/draw_pbvh.cc @@ -10,6 +10,7 @@ */ #include "BLI_map.hh" +#include "BLI_math_geom.h" #include "BLI_math_vector_types.hh" #include "BLI_utildefines.h" #include "BLI_vector.hh" @@ -146,7 +147,7 @@ class DrawCacheImpl : public DrawCache { BitVector<> dirty_topology_; public: - virtual ~DrawCacheImpl() override; + ~DrawCacheImpl() override; void tag_positions_changed(const IndexMask &node_mask) override; void tag_visibility_changed(const IndexMask &node_mask) override; diff --git a/source/blender/draw/intern/draw_view.cc b/source/blender/draw/intern/draw_view.cc index ab19cedf1dc..71fce7bb330 100644 --- a/source/blender/draw/intern/draw_view.cc +++ b/source/blender/draw/intern/draw_view.cc @@ -13,10 +13,13 @@ #include "GPU_compute.hh" #include "GPU_debug.hh" -#include "draw_debug.hh" #include "draw_shader.hh" #include "draw_view.hh" +#ifdef _DEBUG +# include "draw_debug.hh" +#endif + namespace blender::draw { std::atomic View::global_sync_counter_ = 1; diff --git a/source/blender/draw/intern/draw_view_c.cc b/source/blender/draw/intern/draw_view_c.cc index 27714ee33ab..c382c403857 100644 --- a/source/blender/draw/intern/draw_view_c.cc +++ b/source/blender/draw/intern/draw_view_c.cc @@ -20,6 +20,7 @@ #include "GPU_immediate.hh" #include "GPU_matrix.hh" #include "GPU_shader.hh" +#include "GPU_state.hh" #include "UI_resources.hh" #include "UI_view2d.hh" diff --git a/source/blender/draw/intern/draw_view_data.cc b/source/blender/draw/intern/draw_view_data.cc index 57d0e8b3b41..34eb11a5adc 100644 --- a/source/blender/draw/intern/draw_view_data.cc +++ b/source/blender/draw/intern/draw_view_data.cc @@ -277,7 +277,7 @@ ViewportEngineData *DRW_view_data_enabled_engine_iter_step(DRWEngineIterator *it draw::Manager *DRW_manager_get() { BLI_assert(DST.view_data_active->manager); - return reinterpret_cast(DST.view_data_active->manager); + return DST.view_data_active->manager; } draw::ObjectRef DRW_object_ref_get(Object *object) @@ -291,7 +291,7 @@ void DRW_manager_begin_sync() if (DST.view_data_active->manager == nullptr) { return; } - reinterpret_cast(DST.view_data_active->manager)->begin_sync(); + DST.view_data_active->manager->begin_sync(); } void DRW_manager_end_sync() @@ -299,5 +299,5 @@ void DRW_manager_end_sync() if (DST.view_data_active->manager == nullptr) { return; } - reinterpret_cast(DST.view_data_active->manager)->end_sync(); + DST.view_data_active->manager->end_sync(); } diff --git a/source/blender/draw/intern/draw_volume.cc b/source/blender/draw/intern/draw_volume.cc index eb9300ee1a3..302887f6241 100644 --- a/source/blender/draw/intern/draw_volume.cc +++ b/source/blender/draw/intern/draw_volume.cc @@ -279,12 +279,10 @@ PassType *volume_sub_pass_implementation(PassType &ps, if (ob == nullptr) { return volume_world_grids_init(ps, attrs); } - else if (ob->type == OB_VOLUME) { + if (ob->type == OB_VOLUME) { return volume_object_grids_init(ps, ob, attrs); } - else { - return drw_volume_object_mesh_init(ps, scene, ob, attrs); - } + return drw_volume_object_mesh_init(ps, scene, ob, attrs); } PassMain::Sub *volume_sub_pass(PassMain::Sub &ps, diff --git a/source/blender/draw/intern/mesh_extractors/extract_mesh_ibo_tris.cc b/source/blender/draw/intern/mesh_extractors/extract_mesh_ibo_tris.cc index 6f486c213db..78b6cb51f98 100644 --- a/source/blender/draw/intern/mesh_extractors/extract_mesh_ibo_tris.cc +++ b/source/blender/draw/intern/mesh_extractors/extract_mesh_ibo_tris.cc @@ -8,6 +8,8 @@ #include "BKE_editmesh.hh" +#include "BLI_math_geom.h" + #include "GPU_index_buffer.hh" #include "extract_mesh.hh" diff --git a/source/blender/draw/intern/mesh_extractors/extract_mesh_vbo_edge_fac.cc b/source/blender/draw/intern/mesh_extractors/extract_mesh_vbo_edge_fac.cc index 86a92a6b884..373502b7596 100644 --- a/source/blender/draw/intern/mesh_extractors/extract_mesh_vbo_edge_fac.cc +++ b/source/blender/draw/intern/mesh_extractors/extract_mesh_vbo_edge_fac.cc @@ -118,7 +118,7 @@ static void extract_edge_factor_bm(const MeshRenderData &mr, MutableSpan vbo_ BMesh &bm = *mr.bm; threading::parallel_for(IndexRange(bm.totface), 2048, [&](const IndexRange range) { for (const int face_index : range) { - const BMFace &face = *BM_face_at_index(&const_cast(bm), face_index); + const BMFace &face = *BM_face_at_index(&bm, face_index); const BMLoop *loop = BM_FACE_FIRST_LOOP(&face); for ([[maybe_unused]] const int i : IndexRange(face.len)) { const int index = BM_elem_index_get(loop); diff --git a/source/blender/draw/intern/mesh_extractors/extract_mesh_vbo_edituv_stretch_area.cc b/source/blender/draw/intern/mesh_extractors/extract_mesh_vbo_edituv_stretch_area.cc index b3e088cac9f..7f5d76cde05 100644 --- a/source/blender/draw/intern/mesh_extractors/extract_mesh_vbo_edituv_stretch_area.cc +++ b/source/blender/draw/intern/mesh_extractors/extract_mesh_vbo_edituv_stretch_area.cc @@ -6,6 +6,7 @@ * \ingroup draw */ +#include "BLI_math_geom.h" #include "BLI_math_vector_types.hh" #include "BKE_attribute.hh" diff --git a/source/blender/draw/intern/mesh_extractors/extract_mesh_vbo_mesh_analysis.cc b/source/blender/draw/intern/mesh_extractors/extract_mesh_vbo_mesh_analysis.cc index 98933db57ad..542f3ff9e6e 100644 --- a/source/blender/draw/intern/mesh_extractors/extract_mesh_vbo_mesh_analysis.cc +++ b/source/blender/draw/intern/mesh_extractors/extract_mesh_vbo_mesh_analysis.cc @@ -6,10 +6,13 @@ * \ingroup draw */ +#include + #include "MEM_guardedalloc.h" #include "BLI_jitter_2d.h" #include "BLI_map.hh" +#include "BLI_math_geom.h" #include "BLI_math_matrix.h" #include "BLI_math_rotation.h" #include "BLI_ordered_edge.hh" @@ -176,9 +179,7 @@ static void statvis_calc_thickness(const MeshRenderData &mr, MutableSpan angle_fac = angle_fac * angle_fac * angle_fac; angle_fac = 1.0f - angle_fac; dist /= angle_fac; - if (dist < face_dists[index]) { - face_dists[index] = dist; - } + face_dists[index] = std::min(dist, face_dists[index]); } } } @@ -230,9 +231,7 @@ static void statvis_calc_thickness(const MeshRenderData &mr, MutableSpan angle_fac = angle_fac * angle_fac * angle_fac; angle_fac = 1.0f - angle_fac; hit.dist /= angle_fac; - if (hit.dist < face_dists[index]) { - face_dists[index] = hit.dist; - } + face_dists[index] = std::min(hit.dist, face_dists[index]); } } } diff --git a/source/blender/draw/tests/draw_pass_test.cc b/source/blender/draw/tests/draw_pass_test.cc index 0690867918a..125400d6b51 100644 --- a/source/blender/draw/tests/draw_pass_test.cc +++ b/source/blender/draw/tests/draw_pass_test.cc @@ -4,6 +4,7 @@ #include "testing/testing.h" +#include "BLI_math_geom.h" #include "BLI_math_matrix.hh" #include "draw_cache.hh" diff --git a/source/blender/draw/tests/eevee_test.cc b/source/blender/draw/tests/eevee_test.cc index 4863fa56454..c1e1125da9c 100644 --- a/source/blender/draw/tests/eevee_test.cc +++ b/source/blender/draw/tests/eevee_test.cc @@ -4,20 +4,9 @@ #include "testing/testing.h" -#include "BKE_context.hh" -#include "BKE_idtype.hh" -#include "BKE_main.hh" -#include "BKE_node.hh" -#include "BKE_object.hh" - -#include "BLI_vector.hh" - -#include "RNA_define.hh" - #include "GPU_batch.hh" #include "draw_shader.hh" #include "draw_testing.hh" -#include "engines/eevee_next/eevee_instance.hh" #include "engines/eevee_next/eevee_precompute.hh" namespace blender::draw { @@ -343,7 +332,7 @@ static void test_eevee_shadow_tag_update() const uint lod5_len = SHADOW_TILEMAP_LOD5_LEN; auto stringify_result = [&](uint start, uint len) -> std::string { - std::string result = ""; + std::string result; for (auto i : IndexRange(start, len)) { result += (shadow_tile_unpack(tiles_data[i]).do_update) ? "x" : "-"; } @@ -590,7 +579,7 @@ class TestDefrag { pages_cached_data.read(); pages_infos_data.read(); - std::string result = ""; + std::string result; int expect_cached_len = 0; for (auto i : IndexRange(descriptor_offset, descriptor.size())) { if (pages_cached_data[i % SHADOW_MAX_PAGE].y != -1) { @@ -917,7 +906,7 @@ static void test_eevee_shadow_finalize() { uint *pixels = tilemap_tx.read(GPU_DATA_UINT); - std::string result = ""; + std::string result; for (auto y : IndexRange(SHADOW_TILEMAP_RES)) { for (auto x : IndexRange(SHADOW_TILEMAP_RES)) { ShadowTileData tile = shadow_tile_unpack(pixels[y * SHADOW_TILEMAP_RES + x]); @@ -967,7 +956,7 @@ static void test_eevee_shadow_finalize() { auto stringify_view = [](Span data) -> std::string { - std::string result = ""; + std::string result; for (auto x : data) { result += (x == 0u) ? '-' : ((x == 0xFFFFFFFFu) ? 'x' : '0' + (x % 10)); } @@ -1296,7 +1285,7 @@ static void test_eevee_shadow_tilemap_amend() uint *pixels = tilemap_tx.read(GPU_DATA_UINT); auto stringify_tilemap = [&](int tilemap_index) -> std::string { - std::string result = ""; + std::string result; for (auto y : IndexRange(SHADOW_TILEMAP_RES)) { for (auto x : IndexRange(SHADOW_TILEMAP_RES)) { /* NOTE: assumes that tilemap_index is < SHADOW_TILEMAP_PER_ROW. */ @@ -1317,7 +1306,7 @@ static void test_eevee_shadow_tilemap_amend() }; auto stringify_lod = [&](int tilemap_index) -> std::string { - std::string result = ""; + std::string result; for (auto y : IndexRange(SHADOW_TILEMAP_RES)) { for (auto x : IndexRange(SHADOW_TILEMAP_RES)) { /* NOTE: assumes that tilemap_index is < SHADOW_TILEMAP_PER_ROW. */ @@ -1338,7 +1327,7 @@ static void test_eevee_shadow_tilemap_amend() }; auto stringify_offset = [&](int tilemap_index) -> std::string { - std::string result = ""; + std::string result; for (auto y : IndexRange(SHADOW_TILEMAP_RES)) { for (auto x : IndexRange(SHADOW_TILEMAP_RES)) { /* NOTE: assumes that tilemap_index is < SHADOW_TILEMAP_PER_ROW. */ @@ -1747,7 +1736,7 @@ static void test_eevee_shadow_page_mask_ex(int max_view_per_tilemap) StringRefNull expected_lod5 = "-"; auto stringify_result = [&](uint start, uint len) -> std::string { - std::string result = ""; + std::string result; for (auto i : IndexRange(start, len)) { result += (shadow_tile_unpack(tiles_data[i]).is_used) ? "x" : "-"; } @@ -1755,7 +1744,7 @@ static void test_eevee_shadow_page_mask_ex(int max_view_per_tilemap) }; auto empty_result = [&](uint len) -> std::string { - std::string result = ""; + std::string result; for ([[maybe_unused]] const int i : IndexRange(len)) { result += "-"; }