diff --git a/source/blender/render/RE_bake.h b/source/blender/render/RE_bake.h index 236add10d86..efde1a94bc5 100644 --- a/source/blender/render/RE_bake.h +++ b/source/blender/render/RE_bake.h @@ -21,7 +21,7 @@ struct Render; extern "C" { #endif -typedef struct BakeImage { +struct BakeImage { struct Image *image; int tile_number; float uv_offset[2]; @@ -31,9 +31,9 @@ typedef struct BakeImage { /* For associating render result layer with image. */ char render_layer_name[RE_MAXNAME]; -} BakeImage; +}; -typedef struct BakeTargets { +struct BakeTargets { /* All images of the object. */ BakeImage *images; int images_num; @@ -49,17 +49,17 @@ typedef struct BakeTargets { /* Baking to non-color data image. */ bool is_noncolor; -} BakeTargets; +}; -typedef struct BakePixel { +struct BakePixel { int primitive_id, object_id; int seed; float uv[2]; float du_dx, du_dy; float dv_dx, dv_dy; -} BakePixel; +}; -typedef struct BakeHighPolyData { +struct BakeHighPolyData { struct Object *ob; struct Object *ob_eval; struct Mesh *mesh; @@ -67,7 +67,7 @@ typedef struct BakeHighPolyData { float obmat[4][4]; float imat[4][4]; -} BakeHighPolyData; +}; /* `external_engine.cc` */ diff --git a/source/blender/render/RE_engine.h b/source/blender/render/RE_engine.h index 5a8303f52ad..021cf7573e6 100644 --- a/source/blender/render/RE_engine.h +++ b/source/blender/render/RE_engine.h @@ -71,7 +71,7 @@ enum RenderEngineFlag { extern ListBase R_engines; -typedef struct RenderEngineType { +struct RenderEngineType { struct RenderEngineType *next, *prev; /* type info */ @@ -120,17 +120,17 @@ typedef struct RenderEngineType { /* RNA integration */ ExtensionRNA rna_ext; -} RenderEngineType; +}; -typedef void (*update_render_passes_cb_t)(void *userdata, - struct Scene *scene, - struct ViewLayer *view_layer, - const char *name, - int channels, - const char *chanid, - eNodeSocketDatatype type); +using update_render_passes_cb_t = void (*)(void *userdata, + struct Scene *scene, + struct ViewLayer *view_layer, + const char *name, + int channels, + const char *chanid, + eNodeSocketDatatype type); -typedef struct RenderEngine { +struct RenderEngine { RenderEngineType *type; void *py_instance; @@ -170,7 +170,7 @@ typedef struct RenderEngine { struct GPUContext *blender_gpu_context; /* Whether to restore DRWState after RenderEngine display pass. */ bool gpu_restore_context; -} RenderEngine; +}; RenderEngine *RE_engine_create(RenderEngineType *type); void RE_engine_free(RenderEngine *engine); diff --git a/source/blender/render/RE_multires_bake.h b/source/blender/render/RE_multires_bake.h index f66c3c2bc3d..954f0090145 100644 --- a/source/blender/render/RE_multires_bake.h +++ b/source/blender/render/RE_multires_bake.h @@ -19,7 +19,7 @@ struct Scene; extern "C" { #endif -typedef struct MultiresBakeRender { +struct MultiresBakeRender { Scene *scene; DerivedMesh *lores_dm, *hires_dm; int bake_margin; @@ -51,7 +51,7 @@ typedef struct MultiresBakeRender { bool *stop; bool *do_update; float *progress; -} MultiresBakeRender; +}; void RE_multires_bake_images(struct MultiresBakeRender *bkr); diff --git a/source/blender/render/RE_pipeline.h b/source/blender/render/RE_pipeline.h index 9baaee9a94f..bbe14b4e225 100644 --- a/source/blender/render/RE_pipeline.h +++ b/source/blender/render/RE_pipeline.h @@ -38,9 +38,7 @@ extern "C" { #define RE_MAXNAME ((MAX_ID_NAME - 2) + 10) /* only used as handle */ -typedef struct Render Render; - -typedef struct RenderView { +struct RenderView { struct RenderView *next, *prev; char name[64]; /* EXR_VIEW_MAXNAME */ @@ -48,9 +46,9 @@ typedef struct RenderView { * The ibuf is only allocated if it has an actual data in one of its buffers (float, byte, or * GPU). */ struct ImBuf *ibuf; -} RenderView; +}; -typedef struct RenderPass { +struct RenderPass { struct RenderPass *next, *prev; int channels; char name[64]; /* amount defined in IMB_openexr.hh */ @@ -72,7 +70,7 @@ typedef struct RenderPass { int view_id; /* quick lookup */ char _pad0[4]; -} RenderPass; +}; /** * - A render-layer is a full image, but with all passes and samples. @@ -80,7 +78,7 @@ typedef struct RenderPass { * - After render, the Combined pass is in combined, * for render-layers read from files it is a real pass. */ -typedef struct RenderLayer { +struct RenderLayer { struct RenderLayer *next, *prev; /** copy of RenderData */ @@ -93,10 +91,9 @@ typedef struct RenderLayer { void *exrhandle; ListBase passes; +}; -} RenderLayer; - -typedef struct RenderResult { +struct RenderResult { struct RenderResult *next, *prev; /* The number of users of this render result. Default value is 0. The result is freed when @@ -145,16 +142,16 @@ typedef struct RenderResult { struct StampData *stamp_data; bool passes_allocated; -} RenderResult; +}; -typedef struct RenderStats { +struct RenderStats { int cfra; bool localview; double starttime, lastframetime; const char *infostr, *statstr; char scene_name[MAX_ID_NAME - 2]; float mem_used, mem_peak; -} RenderStats; +}; /* *********************** API ******************** */ diff --git a/source/blender/render/RE_texture.h b/source/blender/render/RE_texture.h index 40403360eac..ee1d5fa56e6 100644 --- a/source/blender/render/RE_texture.h +++ b/source/blender/render/RE_texture.h @@ -83,12 +83,12 @@ void RE_point_density_fix_linking(void); /** * Texture evaluation result. */ -typedef struct TexResult { +struct TexResult { float tin; float trgba[4]; /* Is actually a boolean: When true -> use alpha, false -> set alpha to 1.0. */ int talpha; -} TexResult; +}; /* This one uses nodes. */ diff --git a/source/blender/render/hydra/light_tasks_delegate.cc b/source/blender/render/hydra/light_tasks_delegate.cc index 3c4330f1fcf..8c5bd99d328 100644 --- a/source/blender/render/hydra/light_tasks_delegate.cc +++ b/source/blender/render/hydra/light_tasks_delegate.cc @@ -28,7 +28,7 @@ pxr::VtValue LightTasksDelegate::Get(pxr::SdfPath const &id, pxr::TfToken const if (id == simple_task_id_) { return pxr::VtValue(simple_task_params_); } - else if (id == skydome_task_id_) { + if (id == skydome_task_id_) { return pxr::VtValue(skydome_task_params_); } } diff --git a/source/blender/render/hydra/light_tasks_delegate.hh b/source/blender/render/hydra/light_tasks_delegate.hh index 61216a2df53..9e235b783b6 100644 --- a/source/blender/render/hydra/light_tasks_delegate.hh +++ b/source/blender/render/hydra/light_tasks_delegate.hh @@ -12,7 +12,7 @@ namespace blender::render::hydra { class LightTasksDelegate : public pxr::HdSceneDelegate { public: - LightTasksDelegate(pxr::HdRenderIndex *parentIndex, pxr::SdfPath const &delegate_id); + LightTasksDelegate(pxr::HdRenderIndex *parent_index, pxr::SdfPath const &delegate_id); ~LightTasksDelegate() override = default; /* Delegate methods */ diff --git a/source/blender/render/hydra/python.cc b/source/blender/render/hydra/python.cc index 1ce7e4ebf22..5e58fbc1c13 100644 --- a/source/blender/render/hydra/python.cc +++ b/source/blender/render/hydra/python.cc @@ -15,8 +15,6 @@ #include "BKE_context.hh" -#include "RE_engine.h" - #include "RNA_prototypes.hh" #include "hydra/image.hh" diff --git a/source/blender/render/hydra/render_task_delegate.cc b/source/blender/render/hydra/render_task_delegate.cc index d2450aa68f7..8062ef60697 100644 --- a/source/blender/render/hydra/render_task_delegate.cc +++ b/source/blender/render/hydra/render_task_delegate.cc @@ -14,7 +14,7 @@ #include "MEM_guardedalloc.h" -#include "Eigen/Core" +#include #include "engine.hh" diff --git a/source/blender/render/hydra/viewport_engine.hh b/source/blender/render/hydra/viewport_engine.hh index 32f1751e606..e55c9b56da0 100644 --- a/source/blender/render/hydra/viewport_engine.hh +++ b/source/blender/render/hydra/viewport_engine.hh @@ -42,7 +42,7 @@ class ViewportEngine : public Engine { void render(bContext *context); protected: - void notify_status(float progress, const std::string &title, const std::string &info) override; + void notify_status(float progress, const std::string &info, const std::string &status) override; }; } // namespace blender::render::hydra diff --git a/source/blender/render/intern/compositor.cc b/source/blender/render/intern/compositor.cc index bfa3d9db308..8fa976b64ed 100644 --- a/source/blender/render/intern/compositor.cc +++ b/source/blender/render/intern/compositor.cc @@ -24,8 +24,6 @@ #include "IMB_imbuf.hh" -#include "DEG_depsgraph_query.hh" - #include "COM_context.hh" #include "COM_domain.hh" #include "COM_evaluator.hh" @@ -37,6 +35,7 @@ #include "WM_api.hh" #include "GPU_context.hh" +#include "GPU_state.hh" #include "render_types.h" @@ -256,12 +255,10 @@ class Context : public compositor::Context { if (render_size == output_result_.domain().size) { return output_result_; } - else { - /* Otherwise, the size changed, so release its data and reset it, then we reallocate it on - * the new render size below. */ - output_result_.release(); - output_result_.reset(); - } + /* Otherwise, the size changed, so release its data and reset it, then we reallocate it on + * the new render size below. */ + output_result_.release(); + output_result_.reset(); } output_result_.allocate_texture(render_size, false); @@ -282,12 +279,10 @@ class Context : public compositor::Context { { return viewer_output_result_; } - else { - /* Otherwise, the size or precision changed, so release its data and reset it, then we - * reallocate it on the new domain below. */ - viewer_output_result_.release(); - viewer_output_result_.reset(); - } + /* Otherwise, the size or precision changed, so release its data and reset it, then we + * reallocate it on the new domain below. */ + viewer_output_result_.release(); + viewer_output_result_.reset(); } viewer_output_result_.set_precision(precision); diff --git a/source/blender/render/intern/engine.cc b/source/blender/render/intern/engine.cc index 499ed466198..67acca332ba 100644 --- a/source/blender/render/intern/engine.cc +++ b/source/blender/render/intern/engine.cc @@ -12,7 +12,6 @@ #include "MEM_guardedalloc.h" -#include "BLI_ghash.h" #include "BLI_listbase.h" #include "BLI_math_bits.h" #include "BLI_string.h" diff --git a/source/blender/render/intern/initrender.cc b/source/blender/render/intern/initrender.cc index 93a98cfc5b7..a6b4e629c74 100644 --- a/source/blender/render/intern/initrender.cc +++ b/source/blender/render/intern/initrender.cc @@ -9,20 +9,19 @@ /* Global includes */ #include -#include #include #include -#include "MEM_guardedalloc.h" - #include "BLI_math_base.h" #include "BLI_math_matrix.h" #include "BLI_rect.h" -#include "BLI_utildefines.h" + +#include "DNA_scene_types.h" #include "BKE_camera.h" /* this module */ +#include "RE_pipeline.h" #include "render_types.h" /* ****************** MASKS and LUTS **************** */ diff --git a/source/blender/render/intern/multires_bake.cc b/source/blender/render/intern/multires_bake.cc index e9bd5369b27..3a34d9f8966 100644 --- a/source/blender/render/intern/multires_bake.cc +++ b/source/blender/render/intern/multires_bake.cc @@ -10,6 +10,7 @@ #include "MEM_guardedalloc.h" +#include "DNA_modifier_types.h" #include "DNA_scene_types.h" #include "BLI_listbase.h" @@ -27,7 +28,6 @@ #include "BKE_mesh.hh" #include "BKE_mesh_legacy_derived_mesh.hh" #include "BKE_mesh_tangent.hh" -#include "BKE_modifier.hh" #include "BKE_multires.hh" #include "BKE_subsurf.hh" @@ -526,14 +526,14 @@ static void do_multires_bake(MultiresBakeRender *bkr, /* Copy sharp faces and edges, for corner normals domain and tangents * to be computed correctly. */ - if (sharp_edges) { + if (sharp_edges != nullptr) { bke::MutableAttributeAccessor attributes = temp_mesh->attributes_for_write(); attributes.add("sharp_edge", bke::AttrDomain::Edge, bke::AttributeInitVArray(VArray::ForSpan( Span(sharp_edges, temp_mesh->edges_num)))); } - if (sharp_faces) { + if (sharp_faces != nullptr) { bke::MutableAttributeAccessor attributes = temp_mesh->attributes_for_write(); attributes.add("sharp_face", bke::AttrDomain::Face, @@ -633,7 +633,7 @@ static void do_multires_bake(MultiresBakeRender *bkr, BLI_threadpool_end(&threads); } else { - do_multires_bake_thread(&handles[0]); + do_multires_bake_thread(handles.data()); } for (i = 0; i < tot_thread; i++) { diff --git a/source/blender/render/intern/pipeline.cc b/source/blender/render/intern/pipeline.cc index e4af2b26dce..54a572515f2 100644 --- a/source/blender/render/intern/pipeline.cc +++ b/source/blender/render/intern/pipeline.cc @@ -9,23 +9,18 @@ #include #include -#include -#include #include #include #include #include #include "DNA_anim_types.h" -#include "DNA_collection_types.h" #include "DNA_image_types.h" #include "DNA_node_types.h" #include "DNA_object_types.h" -#include "DNA_particle_types.h" #include "DNA_scene_types.h" #include "DNA_sequence_types.h" #include "DNA_space_types.h" -#include "DNA_userdef_types.h" #include "DNA_windowmanager_types.h" #include "MEM_guardedalloc.h" @@ -1192,8 +1187,8 @@ static Scene *get_scene_referenced_by_node(const bNode *node) if (node->type_legacy == CMP_NODE_R_LAYERS) { return reinterpret_cast(node->id); } - else if (node->type_legacy == CMP_NODE_CRYPTOMATTE && - node->custom1 == CMP_NODE_CRYPTOMATTE_SOURCE_RENDER) + if (node->type_legacy == CMP_NODE_CRYPTOMATTE && + node->custom1 == CMP_NODE_CRYPTOMATTE_SOURCE_RENDER) { return reinterpret_cast(node->id); } diff --git a/source/blender/render/intern/render_result.cc b/source/blender/render/intern/render_result.cc index 3ffadd52693..4fe1be7c168 100644 --- a/source/blender/render/intern/render_result.cc +++ b/source/blender/render/intern/render_result.cc @@ -19,11 +19,9 @@ #include "BLI_rect.h" #include "BLI_string.h" #include "BLI_string_utils.hh" -#include "BLI_threads.h" #include "BLI_utildefines.h" #include "BKE_appdir.hh" -#include "BKE_global.hh" #include "BKE_image.hh" #include "BKE_image_format.hh" #include "BKE_image_save.hh" diff --git a/source/blender/render/intern/render_result.h b/source/blender/render/intern/render_result.h index 448ecc152ad..e84c1e1f676 100644 --- a/source/blender/render/intern/render_result.h +++ b/source/blender/render/intern/render_result.h @@ -8,6 +8,8 @@ #pragma once +#include "BKE_global.hh" /* IWYU pragma: keep. Used in macro. */ + #define PASS_VECTOR_MAX 10000.0f #define RR_ALL_LAYERS NULL diff --git a/source/blender/render/intern/render_types.h b/source/blender/render/intern/render_types.h index c4010a5a4a8..bc847b5a106 100644 --- a/source/blender/render/intern/render_types.h +++ b/source/blender/render/intern/render_types.h @@ -135,7 +135,7 @@ struct Render : public BaseRender { /* NOTE: Currently unused, provision for the future. * Add these now to allow the guarded memory allocator to catch C-specific function calls. */ Render() = default; - virtual ~Render(); + ~Render() override; blender::render::TilesHighlight *get_tile_highlight() override { diff --git a/source/blender/render/intern/texture_common.h b/source/blender/render/intern/texture_common.h index 8677a2874a9..864978abec5 100644 --- a/source/blender/render/intern/texture_common.h +++ b/source/blender/render/intern/texture_common.h @@ -8,6 +8,8 @@ #pragma once +#include "BLI_math_color.h" /* IWYU pragma: keep. Used in macros. */ + #ifdef __cplusplus extern "C" { #endif diff --git a/source/blender/render/intern/texture_image.cc b/source/blender/render/intern/texture_image.cc index 89bbc7c1f10..87ddb2ec8ea 100644 --- a/source/blender/render/intern/texture_image.cc +++ b/source/blender/render/intern/texture_image.cc @@ -23,7 +23,6 @@ #include "DNA_image_types.h" #include "DNA_texture_types.h" -#include "BLI_math_color.h" #include "BLI_math_interp.hh" #include "BLI_math_vector.h" #include "BLI_rect.h" @@ -303,9 +302,7 @@ static void clipx_rctf_swap(rctf *stack, short *count, float x1, float x2) rf->xmax += (x2 - x1); } else { - if (rf->xmax > x2) { - rf->xmax = x2; - } + rf->xmax = std::min(rf->xmax, x2); newrct = stack + *count; (*count)++; @@ -327,9 +324,7 @@ static void clipx_rctf_swap(rctf *stack, short *count, float x1, float x2) rf->xmax -= (x2 - x1); } else { - if (rf->xmin < x1) { - rf->xmin = x1; - } + rf->xmin = std::max(rf->xmin, x1); newrct = stack + *count; (*count)++; @@ -363,9 +358,7 @@ static void clipy_rctf_swap(rctf *stack, short *count, float y1, float y2) rf->ymax += (y2 - y1); } else { - if (rf->ymax > y2) { - rf->ymax = y2; - } + rf->ymax = std::min(rf->ymax, y2); newrct = stack + *count; (*count)++; @@ -387,9 +380,7 @@ static void clipy_rctf_swap(rctf *stack, short *count, float y1, float y2) rf->ymax -= (y2 - y1); } else { - if (rf->ymin < y1) { - rf->ymin = y1; - } + rf->ymin = std::max(rf->ymin, y1); newrct = stack + *count; (*count)++; @@ -424,12 +415,8 @@ static float clipx_rctf(rctf *rf, float x1, float x2) size = BLI_rctf_size_x(rf); - if (rf->xmin < x1) { - rf->xmin = x1; - } - if (rf->xmax > x2) { - rf->xmax = x2; - } + rf->xmin = std::max(rf->xmin, x1); + rf->xmax = std::min(rf->xmax, x2); if (rf->xmin > rf->xmax) { rf->xmin = rf->xmax; return 0.0; @@ -446,12 +433,8 @@ static float clipy_rctf(rctf *rf, float y1, float y2) size = BLI_rctf_size_y(rf); - if (rf->ymin < y1) { - rf->ymin = y1; - } - if (rf->ymax > y2) { - rf->ymax = y2; - } + rf->ymin = std::max(rf->ymin, y1); + rf->ymax = std::min(rf->ymax, y2); if (rf->ymin > rf->ymax) { rf->ymin = rf->ymax; @@ -476,12 +459,8 @@ static void boxsampleclip(ImBuf *ibuf, const rctf *rf, TexResult *texres) starty = int(floor(rf->ymin)); endy = int(floor(rf->ymax)); - if (startx < 0) { - startx = 0; - } - if (starty < 0) { - starty = 0; - } + startx = std::max(startx, 0); + starty = std::max(starty, 0); if (endx >= ibuf->x) { endx = ibuf->x - 1; } @@ -706,16 +685,12 @@ static int ibuf_get_color_clip(float col[4], ImBuf *ibuf, int x, int y, int extf y %= ibuf->y; y += (y < 0) ? ibuf->y : 0; break; - default: { /* as extend, if clipped, set alpha to 0.0 */ - if (x < 0) { - x = 0; - } /* TXF alpha: clip = 1; } */ + default: { /* as extend, if clipped, set alpha to 0.0 */ + x = std::max(x, 0); /* TXF alpha: clip = 1; } */ if (x >= ibuf->x) { x = ibuf->x - 1; - } /* TXF alpha: clip = 1; } */ - if (y < 0) { - y = 0; - } /* TXF alpha: clip = 1; } */ + } /* TXF alpha: clip = 1; } */ + y = std::max(y, 0); /* TXF alpha: clip = 1; } */ if (y >= ibuf->y) { y = ibuf->y - 1; } /* TXF alpha: clip = 1; } */ @@ -1035,12 +1010,8 @@ static int imagewraposa_aniso(Tex *tex, /* Make sure the filtersize is minimal in pixels * (normal, ref map can have miniature pixel dx/dy). */ const float addval = (0.5f * tex->filtersize) / float(std::min(ibuf->x, ibuf->y)); - if (addval > minx) { - minx = addval; - } - if (addval > miny) { - miny = addval; - } + minx = std::max(addval, minx); + miny = std::max(addval, miny); } else if (tex->filtersize != 1.0f) { minx *= tex->filtersize; @@ -1439,12 +1410,8 @@ int imagewraposa(Tex *tex, * (normal, ref map can have miniature pixel dx/dy). */ float addval = (0.5f * tex->filtersize) / float(std::min(ibuf->x, ibuf->y)); - if (addval > minx) { - minx = addval; - } - if (addval > miny) { - miny = addval; - } + minx = std::max(addval, minx); + miny = std::max(addval, miny); } else if (tex->filtersize != 1.0f) { minx *= tex->filtersize; @@ -1636,9 +1603,7 @@ int imagewraposa(Tex *tex, dx = minx; dy = miny; maxd = max_ff(dx, dy); - if (maxd > 0.5f) { - maxd = 0.5f; - } + maxd = std::min(maxd, 0.5f); pixsize = 1.0f / float(std::min(ibuf->x, ibuf->y)); @@ -1656,12 +1621,8 @@ int imagewraposa(Tex *tex, if (previbuf != curibuf || (tex->imaflag & TEX_INTERPOL)) { /* sample at least 1 pixel */ - if (minx < 0.5f / ibuf->x) { - minx = 0.5f / ibuf->x; - } - if (miny < 0.5f / ibuf->y) { - miny = 0.5f / ibuf->y; - } + minx = std::max(minx, 0.5f / ibuf->x); + miny = std::max(miny, 0.5f / ibuf->y); } maxx = fx + minx; @@ -1695,12 +1656,8 @@ int imagewraposa(Tex *tex, const int intpol = tex->imaflag & TEX_INTERPOL; if (intpol) { /* sample 1 pixel minimum */ - if (minx < 0.5f / ibuf->x) { - minx = 0.5f / ibuf->x; - } - if (miny < 0.5f / ibuf->y) { - miny = 0.5f / ibuf->y; - } + minx = std::max(minx, 0.5f / ibuf->x); + miny = std::max(miny, 0.5f / ibuf->y); } boxsample(ibuf, fx - minx, fy - miny, fx + minx, fy + miny, texres, imaprepeat, imapextend); diff --git a/source/blender/render/intern/texture_margin.cc b/source/blender/render/intern/texture_margin.cc index 02a9c75454a..7a26b8fcbea 100644 --- a/source/blender/render/intern/texture_margin.cc +++ b/source/blender/render/intern/texture_margin.cc @@ -29,7 +29,6 @@ #include #include -#include namespace blender::render::texturemargin { @@ -88,14 +87,14 @@ class TextureMarginMap { zbuf_free_span(&zspan_); } - inline void set_pixel(int x, int y, uint32_t value) + void set_pixel(int x, int y, uint32_t value) { BLI_assert(x < w_); BLI_assert(x >= 0); pixel_data_[y * w_ + x] = value; } - inline uint32_t get_pixel(int x, int y) const + uint32_t get_pixel(int x, int y) const { if (x < 0 || y < 0 || x >= w_ || y >= h_) { return 0xFFFFFFFF; diff --git a/source/blender/render/intern/texture_pointdensity.cc b/source/blender/render/intern/texture_pointdensity.cc index 079fa3f30d7..44cf54f5370 100644 --- a/source/blender/render/intern/texture_pointdensity.cc +++ b/source/blender/render/intern/texture_pointdensity.cc @@ -12,9 +12,9 @@ #include "MEM_guardedalloc.h" -#include "BLI_blenlib.h" #include "BLI_color.hh" #include "BLI_kdopbvh.hh" +#include "BLI_listbase.h" #include "BLI_math_color.h" #include "BLI_math_matrix.h" #include "BLI_math_vector.h" diff --git a/source/blender/render/intern/texture_procedural.cc b/source/blender/render/intern/texture_procedural.cc index e18a753efa2..1a323911d07 100644 --- a/source/blender/render/intern/texture_procedural.cc +++ b/source/blender/render/intern/texture_procedural.cc @@ -6,8 +6,8 @@ * \ingroup render */ +#include #include -#include #include #include @@ -16,7 +16,6 @@ #include "BLI_rand.h" #include "BLI_utildefines.h" -#include "DNA_image_types.h" #include "DNA_material_types.h" #include "DNA_node_types.h" #include "DNA_texture_types.h" @@ -29,8 +28,6 @@ #include "NOD_texture.h" -#include "MEM_guardedalloc.h" - #include "texture_common.h" #include "RE_texture.h" @@ -99,9 +96,7 @@ static int blend(const Tex *tex, const float texvec[3], TexResult *texres) } else { /* sphere TEX_SPHERE */ texres->tin = 1.0f - sqrtf(x * x + y * y + texvec[2] * texvec[2]); - if (texres->tin < 0.0f) { - texres->tin = 0.0f; - } + texres->tin = std::max(texres->tin, 0.0f); if (tex->stype == TEX_HALO) { texres->tin *= texres->tin; /* Halo. */ } @@ -395,9 +390,7 @@ static int stucci(const Tex *tex, const float texvec[3], TexResult *texres) texres->tin = 1.0f - texres->tin; } - if (texres->tin < 0.0f) { - texres->tin = 0.0f; - } + texres->tin = std::max(texres->tin, 0.0f); return retval; } @@ -530,9 +523,7 @@ static int voronoiTex(const Tex *tex, const float texvec[3], TexResult *texres) texres->trgba[2] += aw4 * ca[2]; if (ELEM(tex->vn_coltype, TEX_COL2, TEX_COL3)) { float t1 = (da[1] - da[0]) * 10; - if (t1 > 1) { - t1 = 1; - } + t1 = std::min(t1, 1); if (tex->vn_coltype == TEX_COL3) { t1 *= texres->tin; } @@ -848,9 +839,7 @@ static void do_2d_mapping( } } - if (max < tex->yrepeat) { - max = tex->yrepeat; - } + max = std::max(max, tex->yrepeat); dxt[1] *= tex->yrepeat; dyt[1] *= tex->yrepeat; diff --git a/source/blender/render/intern/tile_highlight.h b/source/blender/render/intern/tile_highlight.h index f7daaf46820..b6a77d664f8 100644 --- a/source/blender/render/intern/tile_highlight.h +++ b/source/blender/render/intern/tile_highlight.h @@ -42,11 +42,11 @@ class TilesHighlight { uint64_t hash() const; - inline bool operator==(const Tile &other) const + bool operator==(const Tile &other) const { return rect == other.rect; } - inline bool operator!=(const Tile &other) const + bool operator!=(const Tile &other) const { return !(*this == other); } diff --git a/source/blender/render/intern/zbuf.cc b/source/blender/render/intern/zbuf.cc index 134f22ba46c..91038ddc61b 100644 --- a/source/blender/render/intern/zbuf.cc +++ b/source/blender/render/intern/zbuf.cc @@ -13,6 +13,7 @@ /* Common includes */ /*---------------------------------------------------------------------------*/ +#include #include #include "MEM_guardedalloc.h" @@ -84,9 +85,7 @@ static void zbuf_add_to_span(ZSpan *zspan, const float v1[2], const float v2[2]) my2 = zspan->recty - 1; } /* clip bottom */ - if (my0 < 0) { - my0 = 0; - } + my0 = std::max(my0, 0); if (my0 > my2) { return; @@ -124,12 +123,8 @@ static void zbuf_add_to_span(ZSpan *zspan, const float v1[2], const float v2[2]) if (zspan->maxp1 == nullptr || zspan->maxp1[1] < maxv[1]) { zspan->maxp1 = maxv; } - if (my0 < zspan->miny1) { - zspan->miny1 = my0; - } - if (my2 > zspan->maxy1) { - zspan->maxy1 = my2; - } + zspan->miny1 = std::min(my0, zspan->miny1); + zspan->maxy1 = std::max(my2, zspan->maxy1); } else { // printf("right span my0 %d my2 %d\n", my0, my2); @@ -139,12 +134,8 @@ static void zbuf_add_to_span(ZSpan *zspan, const float v1[2], const float v2[2]) if (zspan->maxp2 == nullptr || zspan->maxp2[1] < maxv[1]) { zspan->maxp2 = maxv; } - if (my0 < zspan->miny2) { - zspan->miny2 = my0; - } - if (my2 > zspan->maxy2) { - zspan->maxy2 = my2; - } + zspan->miny2 = std::min(my0, zspan->miny2); + zspan->maxy2 = std::max(my2, zspan->maxy2); } for (y = my2; y >= my0; y--, xs0 += dx0) { @@ -236,9 +227,7 @@ void zspan_scanconvert(ZSpan *zspan, if (sn2 >= rectx) { sn2 = rectx - 1; } - if (sn1 < 0) { - sn1 = 0; - } + sn1 = std::max(sn1, 0); u = ((double(sn1) * uxd) + uy0) - (i * uyd); v = ((double(sn1) * vxd) + vy0) - (i * vyd); diff --git a/source/blender/render/intern/zbuf.h b/source/blender/render/intern/zbuf.h index 0100c2c2590..e9ecef6a4b7 100644 --- a/source/blender/render/intern/zbuf.h +++ b/source/blender/render/intern/zbuf.h @@ -13,13 +13,13 @@ extern "C" { #endif /** Span fill in method, is also used to localize data for Z-buffering. */ -typedef struct ZSpan { +struct ZSpan { int rectx, recty; /* range for clipping */ int miny1, maxy1, miny2, maxy2; /* actual filled in range */ const float *minp1, *maxp1, *minp2, *maxp2; /* vertex pointers detect min/max range in */ float *span1, *span2; -} ZSpan; +}; /** * Each Z-buffer has coordinates transformed to local rect coordinates, so we can simply clip.